mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-10-06 14:33:11 +08:00
f26d734a848297d8dcf460b0bb739174e76511f0
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2b7ceea667 |
refactor: define canvas UI as an SDK client tool (#1797)
* refactor: define canvas UI as an SDK client tool Send a JSON-defined canvas_ui_client tool on new, profile-based, and resumed conversation requests while retaining the legacy Python registration for persisted conversations. Normalize the new SDK event kinds to the existing Canvas UI rendering. Co-authored-by: smolpaws <engel@enyst.org> Co-authored-by: openhands <openhands@all-hands.dev> * fix: omit canvas client tool from ACP launches * refactor: rename canvas client tool Use the semantic canvas_ui_control name and contain the SDK-generated action discriminator behind exported constants. Co-authored-by: Engel Nyst <engel.nyst@gmail.com> --------- Co-authored-by: Engel Nyst <engel.nyst@gmail.com> Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: Debug Agent <157206163+simonrosenberg@users.noreply.github.com> |
||
|
|
b2ba5889d3 |
fix(examples): inherit acp-docker image from config/defaults.json (#1434)
* fix(examples): inherit acp-docker image from config/defaults.json
examples/acp-docker/docker-compose.yml hardcoded the agent-server image at
`1.25.0-python`. Canvas enforces `compatibility.minimumAgentServer` (1.28.0)
from the repo's single source of truth, so the example default fell below the
floor and rendered "Disconnected — requires 1.28.0 or newer" — a reviewer
following the quickstart as written never reached the feature.
examples/acp-docker was the lone in-repo file hardcoding a version instead of
inheriting from config/defaults.json (14 other files read it; check-sdk-version
-sync only validates the released PyPI package, not in-repo files).
- scripts/gen-acp-docker-env.mjs: read defaults.json, pin AGENT_SERVER_IMAGE to
`${images.agentServer}:${versions.agentServer}-python` in examples/acp-docker
/.env (idempotent upsert; mirrors scripts/docker-build.mjs).
- package.json: `npm run example:acp-docker:env`.
- docker-compose.yml: no-config fallback `1.25.0-python` -> `latest-python`,
always >= the compatibility floor, so zero-config `docker compose up` never
shows "Disconnected"; the generated .env overrides with the pinned SoT
version for the reproducible path.
- .env.example / README.md: document both paths; correct the version narrative
(floor is the defaults.json compatibility pin; #3510 is the deeper functional
floor at/below it).
- __tests__/scripts/acp-docker-env-sync.test.ts: assert the generator's tag
matches defaults.json, the pin satisfies the floor, and the compose fallback
stays `latest-python`. Mirrors docs-version-sync.test.ts — the guard that
makes "can't silently drift" true.
* test(examples): harden acp-docker env-sync per review
Addresses the cli-review-panel findings worth acting on (the rest were
cosmetic or matched the no-validation idiom of scripts/docker-build.mjs):
- gte() in the test guarded with parseSemver — a non-numeric pin (sha /
pre-release) now fails the floor check loudly instead of silently
comparing NaN. The floor check is a CI gate; its one piece of logic
shouldn't mis-compare in silence.
- compose-fallback assertion derives the registry from config.images
.agentServer instead of hardcoding ghcr.io/openhands/... — a registry
change no longer false-fails a test that only cares about the latest-python
tag.
- upsertEnvLine now has unit tests (append / replace-in-place+preserve /
idempotent / commented-template-line / keyless-line guard), making the
"idempotent upsert" claim defensible. It was the one untested piece of real
logic.
- upsertEnvLine guards a keyless line (no "=") with a clear throw, instead of
an empty key matching every line and rewriting the whole file.
* fix(examples): guard acp-docker env-sync entrypoint against undefined argv[1]
The CLI entrypoint guard called pathToFileURL(process.argv[1]) unconditionally.
process.argv[1] is undefined in some ESM contexts (e.g. importing the module for
its exports via `node --input-type=module -e "import(...)"`), so the guard threw
ERR_INVALID_ARG_TYPE at import, before any exported helper was reachable.
Short-circuit on process.argv[1] before pathToFileURL so importing the module is
side-effect-free while the CLI path is unchanged. Add a regression test that
reproduces the bare-import context and asserts a clean exit.
Addresses the review finding on #1434.
* docs(acp-docker): trim verbose comments per review
Address all-hands-bot's review suggestions on #1434:
- test header describes the current invariant, not the prior-state history
(that narration belonged in the PR description)
- docker-compose.yml: condense the image-pin comment to the how-to-override;
the compatibility-floor / #3510 rationale already lives in README §1 + the test
- .env.example: 7-line pin explainer down to 2
Comment-only; env-sync test still 10/10 green, prettier clean.
* Clarify ACP Docker image version guidance
Co-authored-by: openhands <openhands@all-hands.dev>
---------
Co-authored-by: enyst <engel.nyst@gmail.com>
Co-authored-by: openhands <openhands@all-hands.dev>
|
||
|
|
ec4616c1c7 |
feat(acp): containerized + cloud ACP — onboarding, secrets, and recycled-sandbox resume (#1013/#1014/#988) (#1102)
* feat(acp): containerized ACP — credential onboarding + inline secrets (#1013/#1014) Wire the canvas halves of agent-canvas#1014 (Docker) and #1013 (credential onboarding) so a user can run an ACP agent (Codex / Claude Code / Gemini) against a containerized agent-server through Canvas, with credentials supplied in the UI. Credential onboarding UX (#1013): - Extend the ACP secrets step beyond the API key to the per-provider reserved credentials a fresh container needs: Codex CODEX_AUTH_JSON, Claude CLAUDE_CODE_OAUTH_TOKEN, Gemini GOOGLE_APPLICATION_CREDENTIALS_JSON + GOOGLE_CLOUD_PROJECT/LOCATION + GOOGLE_GENAI_USE_VERTEXAI. File-content blobs render as multiline fields. - Make the step capability-driven: required on a backend with no host login (cloud, or a logged-out local/Docker backend per the auth probe), optional when a login is detected or the probe can't classify (native dev). - Fix the orphaned-secret bug: warn instead of toasting "Saved" when the active backend can't consume the credential (cloud can't yet read file secrets). Send secrets + model (start request): - buildStartConversationRequest emits reserved ACP credentials inline as StaticSecrets (overriding any same-named LookupSecret) and mirrors them onto agent_context.secrets, so the SDK's acp_file_secrets defaults materialise the *_JSON blobs before the CLI spawns. The orchestrator reads back the saved reserved values for the active provider (local backends only). - Preselect a Vertex-safe acp_model for Gemini (gemini-2.5-flash) so a fresh container doesn't hit gemini-cli's preview default that 404s on Vertex. - Never auto-promote *_BASE_URL to an inline secret (an inherited base URL breaks the Claude OAuth token's bearer auth). Docker setup + docs: - examples/acp-docker/ docker-compose (persistent volume + canvas_ui tool mount + credential notes); .env.sample + docs point VITE_BACKEND_BASE_URL at it. - docs/ACP_AGENTS.md gains a "Running ACP agents in a Docker container" section. Per-conversation isolation (acp_isolate_data_dir) left as a documented TODO — the field isn't exposed on ACPAgentSettings in the released typescript-client. Tests + e2e: - Unit tests for the StaticSecret emission, reserved-credential sets, Vertex model default, getSecretValues read-back, and the required-credentials matrix. - tests/e2e/live-acp/: a vite-node harness that builds each provider's request via buildStartConversationRequest and POSTs it to a real container. Validated with REAL API calls against agent-server c950fdb-python: Codex ✅, Claude ✅, Gemini ✅ (materialise ADC -> vertex-ai -> real reply). Gemini's default-config init is blocked by an SDK/gemini-cli set_session_mode("yolo") issue (documented caveat, not a credential problem). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(acp): make containerized credentials survive the real conversation-start path Validating end-to-end through the application's own orchestrator (buildStartConversationRequestWithEncryptedSettings) against a live container — rather than the request builder in isolation — surfaced two real bugs that would have broken the feature in the product: 1. secrets_encrypted mangled the plaintext reserved StaticSecrets. The app always fetches settings in encrypted mode, so the start request carried secrets_encrypted=true. The agent-server then runs every secret value through cipher.decrypt() during validation — including our reserved ACP creds, which are read back as PLAINTEXT. Result: the credential was silently dropped (decrypt fails → None) on a cipher backend, or a hard 500 ("cipher not configured") on a fresh container with no OH_SECRET_KEY. Fix: don't set secrets_encrypted for ACP conversations — an ACP agent has no encrypted agent secret (no LLM api_key), and its provider creds ride as plaintext StaticSecrets. 2. A different provider's leftover file-content secret broke the active provider. A CODEX_AUTH_JSON saved while onboarding Codex leaks into a later Claude conversation via the global-secrets → LookupSecret path. The SDK materialises file secrets eagerly at spawn by resolving the secret source, and a LookupSecret resolution stalls → ReadTimeout → "Failed to start ACP server: timed out". Fix: reserved file-content blobs (the multiline *_JSON creds) never travel as LookupSecrets — the active provider's is sent inline as a StaticSecret, any other provider's is dropped (getAllReservedAcpFileSecretNames). Re-validated through the app orchestrator against agent-server c950fdb-python (onboarding createSecret → buildAcpAgentSettingsDiff PATCH → orchestrator read-back → real reply): Codex ✅, Claude ✅ (leftover CODEX_AUTH_JSON correctly dropped). Gemini's app path is correct (StaticSecrets emitted, vertex-ai auth reached); this run hit the documented invalid_rapt stale-ADC caveat (host ADC expired since the prior fresh-ADC pass) — an environment issue, not code. Adds regression tests (secrets_encrypted suppressed for ACP / kept for non-ACP; leftover file blob dropped not LookupSecret'd; getAllReservedAcpFileSecretNames) and the app-path e2e harness (tests/e2e/live-acp/acp-docker-app-e2e.mts). Notes OH_SECRET_KEY as optional (secret persistence) in the compose example. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: address PR review feedback (#1102) - retag acp_isolate_data_dir TODO #1014 (this PR) -> #1019 (the per-conversation isolation follow-up the knob serves) - note the Gemini Vertex scalars (PROJECT/LOCATION/USE_VERTEXAI) are plain config / a routing flag, not secrets Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(acp): order subscription credential before API key in onboarding Show each provider's reserved subscription/Vertex credential first (Claude CLAUDE_CODE_OAUTH_TOKEN, Codex CODEX_AUTH_JSON, Gemini Vertex SA), then the API key, then the base URL — the subscription token is the primary auth path for ACP providers, with the API key as the fallback. Display order only; getAcpProviderSecrets consumers are order-independent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(i18n): disable i18next value escaping so React handles it i18next's default escapeValue double-escapes interpolated values on top of React's own escaping, rendering paths like ~/.codex/auth.json as ~/.codex/auth.json. Set interpolation.escapeValue=false (the standard react-i18next config); React still escapes at render time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(acp): unify secret wire-delivery; keep "reserved" as onboarding-only Drop the reserved-vs-custom split in how secrets reach the agent-server. Previously, provider credentials ("reserved") rode inline as StaticSecrets while user secrets rode as loopback LookupSecrets — a fork introduced only to dodge a deadlock: the SDK resolved an ACP agent's secrets synchronously on its event loop at CLI spawn, so a loopback LookupSecret self-deadlocked. That deadlock is fixed at the source in software-agent-sdk#3510 (ACP cold-start runs off the event loop), so the workaround is no longer needed. Now every secret — env-var credential, file-content blob, or user secret — ships uniformly as a LookupSecret, for ACP and non-ACP alike. The SDK resolves and (for file blobs) materialises them off the loop, so the loopback fetch is safe. "Reserved" survives only as an onboarding/validation concept (which fields to prompt for per provider, capability-driven required steps) — it no longer affects the wire. Removed: StaticSecret type, acpStaticSecrets option + the inline path, the file-blob lookupSkip, SecretsService.getSecretValues, and the reserved-name value read-back. Kept: secrets_encrypted suppression for ACP (an ACP request carries no encrypted payload, and a fresh ACP container may have no OH_SECRET_KEY cipher). Note: getReservedAcpSecretNames / getAllReservedAcpFileSecretNames in constants/acp-providers.ts are now unused by the wire; the former is still useful for validation, the latter can be pruned. Depends on software-agent-sdk#3510. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(acp): prune now-dead reserved-secret wire helpers Follow-up to the wire-delivery unification: getReservedAcpSecretNames and getAllReservedAcpFileSecretNames were only ever consumed by the inline StaticSecret / file-blob-skip path, which is gone. They have no remaining production callers, so remove them (and their tests). The reserved-credential field definitions (ACP_RESERVED_CREDENTIALS, getAcpProviderSecrets) and the ``reserved`` / ``multiline`` flags stay — onboarding still reads them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(acp): re-point containerized ACP at SDK 1.25.0 (#3510) + fix e2e harnesses The unified LookupSecret delivery (e076e9bb) depends on software-agent-sdk#3510 (ACP cold-start off the event loop), which first ships in v1.25.0. The example compose/docs/e2e all still defaulted to agent-server:c950fdb-python, which predates #3510 and deadlocks the first ACP turn ("Failed to start ACP server: timed out"). Bump every default to 1.25.0-python and document it as the minimum. Also realign the live-acp e2e harnesses, which still encoded the removed StaticSecret API (the PR's headline evidence predated the unification): - acp-docker-e2e.mts: store each credential via SecretsService.createSecret, send name-only customSecrets, assert every emitted secret is a LookupSecret. - acp-docker-app-e2e.mts: flip the assertion StaticSecret -> LookupSecret; drop the stale getSecretValues reference. - Both: fix a polling bug where "idle" (the transient pre-run state) was treated as terminal, so the loop bailed before the agent ran and read an empty reply. Terminal is now {finished, error, stuck, stopped}. Correct the stale StaticSecret doc comments in constants/acp-providers.ts (reserved is now an onboarding/validation marker, not a wire distinction). Re-validated in-container against agent-server:1.25.0-python: Codex and Claude pass end-to-end on both harnesses (LookupSecret resolves off-loop, no deadlock, even with leftover cross-provider file-secrets present). Gemini's credential path is proven (vertex-ai auth reached) but the turn is blocked by gemini-cli 0.45.x ignoring the requested acp_model and running gemini-3-flash — an SDK model-selection concern tracked in software-agent-sdk#3532, not a Canvas bug; the docs/e2e notes are corrected accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(acp): improve credential hint text with fetch commands Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * feat(acp): show provider credentials in Settings → Agent Adds a Credentials section to /settings/agent when an ACP provider is selected, so users can set or rotate tokens/keys after onboarding without hunting through Settings → Secrets. Mirrors the onboarding fields exactly (same hints, same already-saved placeholders, Optional tag on multiline fields) with its own Save button that writes directly to the secret store. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor(acp): drop the agent_context.secrets mirror — request.secrets is the sole channel The mirror's justification ("ACPAgent's spawn-time env loop reads from agent_context.secrets, not the registry") predates the pinned minimum agent-server: 1.25.0 already injects the ACP spawn env from secret_registry, seeded from request.secrets (sdk#3299/#3464), and sdk#3528 removes the agent_context drain entirely. Keeping the mirror preserved a second, dead credential channel — the exact coupling agent-canvas#1039 is eliminating. Canvas now sends every credential in top-level request.secrets only. Tests inverted to pin the single-channel contract; adapter/type comments updated to match. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(acp): non-flash Gemini default, shared credential form, review cleanups - ACP_VERTEX_SAFE_MODEL → gemini-2.5-pro: gemini-cli 0.45.x re-resolves any *-flash id at generation time to its current default flash (sdk#3532), so a flash pin is never honored; docs + e2e defaults updated to match - extract AcpSecretField + useSaveAcpSecrets and move AcpCredentialsSection to components/ — onboarding and Settings → Agent share one field renderer and one save flow (incl. the orphaned-file-credential warning on cloud) - a required credentials step is only satisfied by an actual credential (a masked `secret` field) — a base URL or GCP scalar alone no longer unblocks - warn inline when CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_BASE_URL are both set (typed or saved) — the pair silently breaks bearer auth - drop the near-dead `reserved` field flag; collapse the leftover two-block secrets scaffolding in buildStartConversationRequest - sync 14 stale locales on the OAuth/file-blob hints; fix issue refs (TODO #1019→#1014 — #1019 is closed; OpenHands#1016→agent-canvas#1016) - tests: settings credentials-section coverage, non-flash pin, conflict matrix, tightened-gate cases Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(acp): unify default-model surfaces + dedupe credential forms and e2e harness Review-pass cleanups: - Route ALL three default-model surfaces (onboarding diff builder, Settings -> Agent seeding, start-request null fallback, + chat-input display) through getAcpPreferredDefaultModel, so the Vertex-safe Gemini override can't diverge between surfaces. New regression tests pin the diff-builder and start-request fallbacks to it. - Extract useAcpCredentialForm + AcpConflictWarnings: the onboarding step and the Settings credentials section now share the values state, existing-secret lookups, conflict pairs, and save flow. - Extract tests/e2e/live-acp/harness.mts: provider plans, host credential collectors, and HTTP/poll helpers shared by both live scripts (a model default can no longer drift between them). - Restore the TODO(#1019) retag (accidentally reverted to the self-referencing #1014 in the last cleanup commit); same fix in docs/ACP_AGENTS.md. - Drop the tautological ACP_VERTEX_SAFE_MODEL literal assertion, fix a dead key-ternary in getAcpProviderSecrets, TODO(#1016) on the cloud file-credential capability check, and document that baked .env creds don't satisfy the onboarding login probe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: address PR review feedback (#1102) - Restore package-lock.json to main — the npm-install churn (29 dropped "dev": true flags) was never meant to ship with this PR - Note why global escapeValue:false is safe (React escapes at render; no translated string hits dangerouslySetInnerHTML) - Note the non-macOS skip path in the e2e claudeOAuthToken collector Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(acp): tighten the credential gate + clarify base-URL docs (#1102 review) - A file blob no longer satisfies the required credential step on a backend that can't materialise it (cloud, #1016) — the save flow already warned it was orphaned, so it can't be what opens the gate. consumesFileCredentials moves into useAcpCredentialForm so the gate and the save warning share one capability check. - Next stays disabled while the login probe is still classifying a local backend, so a fast click can't slip past a gate about to come up "unauthenticated". A probe that completes as "unknown" stays permissive. - Docs: a saved *_BASE_URL secret does ride along on every start request like any other saved secret; Canvas only never derives one from LLM settings. Reword the two claims that suggested otherwise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(e2e): record 2026-06-07 re-validation — all three providers pass Fresh 1.25.0-python container + fresh volume at the branch tip: Codex and Claude pass both scripts; Gemini's full turn now passes too (fresh ADC + gemini-2.5-pro + session-mode override), upgrading the previous "blocked on model selection" row. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(acp): resume a recycled cloud ACP conversation via bootstrap prompt (#988) A cloud ACP conversation whose sandbox was recycled (STOPPED/MISSING, e.g. the runtime idle-stopped or hit its TTL) was a read-only dead end: the chat input was replaced by the archived banner, and cloud createConversation never re-provisions an existing conversation_id. The backend already supports resuming such a conversation — re-issuing the start with the same conversation_id rebuilds it and, for ACP, replays the durable event store as a bootstrap prompt (OpenHands#14640) — but nothing in canvas triggered it. Surface it: - AppConversationStartRequest.conversation_id so the cloud start path can target an existing conversation. - wakeRecycledCloudConversation(id, repoSelection): re-POST /api/v1/app-conversations with the conversation_id (and repo selection, so the rebuilt working dir matches the original cwd an ACP resume keys off). - useWakeConversation mutation: wakes + invalidates the conversation queries so the active-conversation poll reconnects once the fresh sandbox is RUNNING. - A Resume button in the archived banner for an ACP conversation whose sandbox is MISSING (ERROR stays read-only). Validated e2e against a local SaaS-equivalent stack (OpenHands main app_server + a main-built agent-server image, Docker sandboxes): create an ACP conversation, docker rm -f the sandbox, wake → fresh sandbox + bootstrap-prompt resume, the agent recalls prior context (codeword) and the <<RESUMED CONVERSATION>> marker is present. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * feat(acp): consume file-content credentials on cloud too (#988) Cloud now materialises reserved file-content credentials (Codex auth.json, Gemini Vertex SA) from the per-user encrypted secret store via agent_context.secrets at conversation start (the cloud backend pins an SDK that materialises reserved file secrets), so a pasted blob is consumable on every supported backend — not just local. Drop the local-only gate on consumesFileCredentials: a Codex/Gemini file blob now satisfies the onboarding credential gate on cloud and saving it toasts success instead of the orphaned-credential warning. Folds the remaining cloud-enablement piece in from the native-resume canvas branch (the wake/bootstrap-resume path landed separately); native session/load is a backend-only concern (SDK + OpenHands), so canvas needs nothing further. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Debug Agent <debug@example.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |