Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
0a9fcc3
feat(cli): workspace-qualified extensions REST (daemon multi-workspace)
doudouOUC Jul 10, 2026
563a173
qwen: address PR review feedback (#6638)
doudouOUC Jul 10, 2026
59b2f88
qwen: address PR review feedback (#6638)
doudouOUC Jul 10, 2026
9dd2e92
qwen: address PR review feedback (#6638)
doudouOUC Jul 10, 2026
d6c3b70
feat(cli): add concurrent extension preparation
doudouOUC Jul 10, 2026
f3e76ff
fix(cli): remove redundant extension context build
doudouOUC Jul 10, 2026
40c9118
codex: address PR review feedback (#6638)
doudouOUC Jul 10, 2026
d47f4a7
codex: address PR review feedback (#6638)
doudouOUC Jul 10, 2026
d2c3e81
fix(cli): address extension review feedback
doudouOUC Jul 10, 2026
4ff8c18
merge: resolve conflicts with origin/main for PR #6638
qwen-code-dev-bot Jul 11, 2026
db259e7
fix(extensions): address final review feedback
doudouOUC Jul 11, 2026
8d9db32
fix(extensions): address latest review feedback
doudouOUC Jul 11, 2026
c6d4c83
codex: address PR review feedback (#6638)
doudouOUC Jul 11, 2026
3c1cede
fix(core): reject links in npm extension archives
doudouOUC Jul 11, 2026
f34fbb8
fix(core): limit npm extension archive downloads
doudouOUC Jul 11, 2026
e8e5f84
fix(extensions): address review follow-ups
doudouOUC Jul 11, 2026
113f896
fix(extensions): address latest review feedback
doudouOUC Jul 11, 2026
3067e51
chore: merge main into workspace extension branch
doudouOUC Jul 11, 2026
8e25074
chore: merge latest main into extension branch
doudouOUC Jul 11, 2026
6cff963
fix(extensions): release rejected operation slots
doudouOUC Jul 11, 2026
15004ea
fix(extensions): address operation review feedback
doudouOUC Jul 11, 2026
c1cae5e
fix(extensions): align archive handling contracts
doudouOUC Jul 11, 2026
2643a3a
fix(extensions): preserve watcher generation state
doudouOUC Jul 11, 2026
21207cc
docs(extensions): align management contracts
doudouOUC Jul 11, 2026
2904340
fix(sdk): bound extension operation polls
doudouOUC Jul 12, 2026
1e26633
test(core): cover forged prepared commits
doudouOUC Jul 12, 2026
5658cb3
test(core): assert activation generation increment
doudouOUC Jul 12, 2026
44afb9c
fix(extensions): close archive and polling gaps
doudouOUC Jul 12, 2026
1654fa5
fix(cli): retry suppressed extension generations
doudouOUC Jul 12, 2026
96f80ec
test(cli): cover archive URL extension updates
doudouOUC Jul 12, 2026
b60129c
fix(sdk): preserve unbounded operation waits
doudouOUC Jul 12, 2026
cce3571
fix(core): share npm redirect download deadline
doudouOUC Jul 12, 2026
85387ec
fix(core): preserve extension reload diagnostics
doudouOUC Jul 12, 2026
a9aea07
fix(core): preserve installed Claude plugin paths
doudouOUC Jul 12, 2026
25ccbc1
fix(cli): return committed activation state
doudouOUC Jul 12, 2026
ab3496f
fix(cli): preserve extension preparation errors
doudouOUC Jul 12, 2026
5f23e58
fix(core): validate extension setting env vars
doudouOUC Jul 12, 2026
59ab121
fix(cli): target extension reconciliation
doudouOUC Jul 12, 2026
abde5b4
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
b81c7be
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
1e57061
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
83cb011
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
6b61cbb
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
f5ee95d
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
9c5bb7c
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
65e50f0
test(cli): cover resultless legacy commit warnings
doudouOUC Jul 12, 2026
bee57c8
fix(cli): retain suppressed extension generations
doudouOUC Jul 12, 2026
abffbc3
fix(cli): record legacy runtime reconciliation
doudouOUC Jul 12, 2026
e7cf348
fix(cli): validate extension clients by runtime
doudouOUC Jul 12, 2026
d92f71c
fix(cli): record workspace activation refresh
doudouOUC Jul 12, 2026
85f9c35
test(cli): stop extension reconcilers after cases
doudouOUC Jul 12, 2026
19885ce
fix(cli): resolve global runtimes at reconciliation
doudouOUC Jul 12, 2026
0ed83ab
fix(cli): reconcile newly registered runtimes
doudouOUC Jul 12, 2026
adb59a4
fix(cli): prevent overlapping runtime reconciliation
doudouOUC Jul 12, 2026
774975f
fix(cli): dispose late runtime apps during shutdown
doudouOUC Jul 12, 2026
cb38bdc
fix(core): keep projection repair best effort
doudouOUC Jul 12, 2026
9183308
fix(core): preserve committed store results
doudouOUC Jul 12, 2026
2566f1f
fix(core): quarantine corrupt store journals
doudouOUC Jul 12, 2026
7a1679d
fix(core): harden npm download redirects
doudouOUC Jul 12, 2026
420a5df
fix(extensions): address review edge cases
doudouOUC Jul 12, 2026
04640a5
merge(serve): reconcile extension_management_v2 with origin/main work…
qwen-code-dev-bot Jul 12, 2026
7f07ad7
chore: merge upstream main into extension management
doudouOUC Jul 12, 2026
60c8596
chore: reconcile concurrent upstream merges
doudouOUC Jul 12, 2026
4f34aa3
fix(extensions): honor cancellation between preparation stages
doudouOUC Jul 12, 2026
c0fbc57
fix(extensions): retry prepared cleanup failures
doudouOUC Jul 12, 2026
4ab8a71
test(extensions): cover committed artifact recovery boundary
doudouOUC Jul 12, 2026
8e3f2e8
fix(serve): release extension refresh queue on timeout
doudouOUC Jul 12, 2026
6f38769
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
8249a65
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
d557154
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
f524413
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
ec653f9
fix: address extension review feedback
doudouOUC Jul 12, 2026
9fa98ca
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
2f5e496
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
c1c6199
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
4d55a5c
codex: address PR review feedback (#6638)
doudouOUC Jul 12, 2026
bd8c4d2
fix(core): reconcile extension store compatibility state
doudouOUC Jul 12, 2026
2c7c08d
fix(core): bound npm redirects and isolate extension tests
doudouOUC Jul 12, 2026
8893d3a
fix(core): make extension uninstall store-authoritative
doudouOUC Jul 12, 2026
ea1d112
fix(core): defer prepared extension secret mutations
doudouOUC Jul 12, 2026
4549a39
fix(core): validate staged extensions before commit
doudouOUC Jul 12, 2026
47b575e
fix(core): enforce public extension network policy
doudouOUC Jul 12, 2026
4029e5a
fix(core): handle extension response failures
doudouOUC Jul 13, 2026
eaf6e7a
fix(extensions): surface committed refresh warnings
doudouOUC Jul 13, 2026
ba9fa61
fix(cli): guard timer unref calls
doudouOUC Jul 13, 2026
a81fe71
fix(extensions): release commit lane after durable writes
doudouOUC Jul 13, 2026
5437ecc
test(serve): update mutation callback assertions
doudouOUC Jul 13, 2026
bb93910
fix(serve): refresh live extension instructions
doudouOUC Jul 13, 2026
0bf9de6
fix(extensions): address latest review feedback
doudouOUC Jul 13, 2026
7077c24
fix(extensions): address follow-up review findings
doudouOUC Jul 13, 2026
b3a8623
fix(extensions): address remaining activation feedback
doudouOUC Jul 13, 2026
31e1b4a
fix(serve): preserve preparation queue status
doudouOUC Jul 13, 2026
20c44fa
fix(extensions): enforce network request deadlines
doudouOUC Jul 13, 2026
f1d9ab2
docs(serve): clarify single-workspace capabilities
doudouOUC Jul 13, 2026
d8242a7
fix(extensions): guard deferred settings commit
doudouOUC Jul 13, 2026
330d1e6
fix(extensions): cancel archive extraction
doudouOUC Jul 13, 2026
e70ab39
fix(extensions): harden refresh recovery
doudouOUC Jul 13, 2026
d5ebf30
fix(serve): serialize extension reconciliation
doudouOUC Jul 13, 2026
c215581
fix(extensions): address post-commit review feedback
doudouOUC Jul 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions docs/design/daemon-multi-workspace-extensions-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Daemon Multi-Workspace: Workspace-Qualified Extensions REST

## Summary

Mirror the daemon's extension-management REST surface from the singular,
primary-bound `/workspace/extensions/*` to an additional workspace-qualified
`/workspaces/:workspace/extensions/*`, reusing the Phase 3 (issue #6378) runtime
resolver and trust gate. Extensions were the last core REST surface deliberately
left on the primary in Phase 3 (see the `workspace_qualified_rest_core` note in
`packages/cli/src/serve/capabilities.ts`). A new baseline capability tag,
`workspace_qualified_extensions`, lets clients discover the plural surface, and
the SDK `WorkspaceDaemonClient` gains matching convenience methods.

## Motivation

`qwen serve` can host several workspaces in one daemon. Phase 3 brought the core
REST surface (file, status, settings, permissions, trust, lifecycle, MCP, tool,
memory, agents, session storage) to `/workspaces/:workspace/...`, but explicitly
excluded extensions. This change closes that gap so ACP/SDK clients (and, later,
the Web Shell) can manage extensions for a specific hosted workspace rather than
only the primary one.

## Design

### Per-workspace controller extraction

Unlike the stateless Phase 3 routes (which duplicate handlers), the extensions
routes hold significant per-workspace mutable state: an install-serialization
queue, an async operation-history map, and a short-lived status cache. To avoid
duplicating ~400 lines of handler logic and to keep that state correct, the
per-workspace machinery is factored into
`createExtensionsController(deps)` in
`packages/cli/src/serve/routes/workspace-extensions-controller.ts`. Each
controller binds one workspace's `bridge`, `workspaceService`, and
`workspaceCwd`, and owns that workspace's queue, operation map, and status cache.

`registerWorkspaceExtensionRoutes` in
`packages/cli/src/serve/routes/workspace-extensions.ts` writes the nine handlers
once inside an internal `registerFor(base, resolveController)` and mounts them
twice:

- Singular `base = '/workspace/extensions'`, resolving to the primary
controller (behavior unchanged).
- Plural `base = '/workspaces/:workspace/extensions'`, resolving the runtime per
request and dispatching to that runtime's controller.

A `Map<workspaceCwd, ExtensionsController>` is seeded with the primary
controller, so the primary workspace shares one queue/operation-map/cache across
both the singular and plural routes (two competing install queues for one
extensions directory would risk corruption and inconsistent operation polling).
Non-primary controllers are created lazily on first plural request.

### Resolution and trust gate

The plural resolver reuses `workspace-route-runtime.ts`:

- `resolveWorkspaceRuntimeFromParam` — unknown selector -> `400 { code:
"workspace_mismatch" }`, never falling back to the primary.
- `requireTrustedWorkspaceRuntime` — used for mutations only.

Trust policy follows the two established Phase 3 precedents by verb: reads
(`GET` status, `GET` operations) resolve the runtime only (mirroring
`registerWorkspaceQualifiedFileReadRoutes`), while mutations
(install/check-updates/refresh/enable/disable/update/delete) additionally
require a trusted workspace (mirroring MCP control), returning
`403 { code: "untrusted_workspace" }` and never spawning work on an untrusted
workspace.

### Routes

Nine routes, mirrored 1:1:

- `GET /workspaces/:workspace/extensions`
- `GET /workspaces/:workspace/extensions/operations/:operationId`
- `POST /workspaces/:workspace/extensions/install`
- `POST /workspaces/:workspace/extensions/check-updates`
- `POST /workspaces/:workspace/extensions/refresh`
- `POST /workspaces/:workspace/extensions/:name/enable`
- `POST /workspaces/:workspace/extensions/:name/disable`
- `POST /workspaces/:workspace/extensions/:name/update`
- `DELETE /workspaces/:workspace/extensions/:name`

### Capability

A new baseline tag `workspace_qualified_extensions: { since: 'v1' }` is added to
`SERVE_CAPABILITY_REGISTRY` (not in `CONDITIONAL_SERVE_FEATURES`), advertised
unconditionally like `workspace_qualified_rest_core`: presence means the plural
routes exist on this build, independent of how many workspaces are hosted. A
dedicated tag (rather than folding into `workspace_qualified_rest_core`) is used
because `rest_core` is a baseline tag that already ships advertised without
extensions, so folding would give clients no version signal; a dedicated tag
preserves the codebase's "tag presence = behavior on" contract and matches the
Phase 4 precedent of adding its own tag. The `ServeFeature` type derives from the
registry, so no additional type wiring is needed; the `/capabilities` response
picks the tag up automatically via `getAdvertisedServeFeatures`.

### SDK

`WorkspaceDaemonClient` (obtained via `client.workspaceByCwd` /
`client.workspaceById`) gains `workspaceExtensions`, `extensionOperationStatus`,
`installExtension`, `checkExtensionUpdates`, `refreshExtensions`,
`enableExtension`, `disableExtension`, `updateExtension`, and
`uninstallExtension`, reusing the existing extension request/response types.

## Testing

- `packages/cli/src/serve/routes/workspace-qualified-extensions.test.ts`:
capability advertisement; trusted/untrusted reads; unknown-selector mismatch;
untrusted-mutation refusal; a mutation runs on the target workspace's bridge
(not the primary); the primary controller is shared across singular and plural
routes; per-workspace operation-history isolation.
- `packages/cli/src/serve/server.test.ts`: the baseline feature-set assertions
include the new tag; existing singular extension-route tests are unchanged.
- `packages/sdk-typescript/test/unit/DaemonClient.test.ts`: the plural extension
methods hit the expected `/workspaces/:workspace/extensions/*` URLs.

## Out of scope

- Relaxing the mutation trust gate to allow read-only access to untrusted
workspaces (currently a conservative refusal for mutations only).
- Dynamic workspace add/remove (Phase 5); the controller map uses lazy
get-or-create, which is equivalent under today's static registry.
- Web Shell UI for per-workspace extension management.
5 changes: 4 additions & 1 deletion docs/developers/qwen-serve-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ registry. Clients **must** gate UI off `features`, not off `mode` (per design
'workspace_hooks', 'session_hooks', 'workspace_extensions',
'session_branch', 'rate_limit', 'workspace_reload',
'multi_workspace_sessions', 'workspace_qualified_rest_core',
'workspace_qualified_extensions',
'client_mcp_over_ws', 'cdp_tunnel_over_ws', 'browser_automation_mcp']
```

Expand All @@ -209,7 +210,7 @@ registry. Clients **must** gate UI off `features`, not off `mode` (per design

`session_archive` advertises the v1 directory-state archive API: `POST /sessions/archive`, `POST /sessions/unarchive`, and `GET /workspace/:id/sessions?archiveState=active|archived`. Archived sessions cannot be loaded or resumed until they are unarchived.

`workspace_qualified_rest_core` advertises plural core REST routes under `/workspaces/:workspace/...`. The selector resolves as exact workspace id first, then as a URL-encoded absolute cwd after canonicalization. On single-workspace daemons, `workspaces[]` is absent unless `multi_workspace_sessions` is also advertised, so clients use `capabilities.workspaceCwd` as the cwd selector. Trust status and trust request routes are available for registered untrusted workspaces; file read routes follow the existing filesystem read policy. File write routes and all other plural core routes require a trusted workspace and return `403 { code: "untrusted_workspace" }` when the selected runtime is untrusted. This plural trust gate is intentionally stricter than some legacy primary-workspace read routes, which keep their existing compatibility behavior and are not drop-in replacements. This tag covers the core file, status, settings, permissions, trust, lifecycle, MCP control, tool toggle, memory, workspace agent CRUD, and session storage surfaces. It does not cover auth, voice, extensions, ACP/WebSocket transport, or channel-worker routing.
`workspace_qualified_rest_core` advertises plural core REST routes under `/workspaces/:workspace/...`. The selector resolves as exact workspace id first, then as a URL-encoded absolute cwd after canonicalization. On single-workspace daemons, `workspaces[]` is absent unless `multi_workspace_sessions` is also advertised, so clients use `capabilities.workspaceCwd` as the cwd selector. Trust status and trust request routes are available for registered untrusted workspaces; file read routes follow the existing filesystem read policy. File write routes and all other plural core routes require a trusted workspace and return `403 { code: "untrusted_workspace" }` when the selected runtime is untrusted. This plural trust gate is intentionally stricter than some legacy primary-workspace read routes, which keep their existing compatibility behavior and are not drop-in replacements. This tag covers the core file, status, settings, permissions, trust, lifecycle, MCP control, tool toggle, memory, workspace agent CRUD, and session storage surfaces. It does not cover auth, voice, ACP/WebSocket transport, or channel-worker routing.

`session_lsp` advertises `GET /session/:id/lsp`, the read-only structured LSP status snapshot for daemon clients. Older daemons return `404`; pre-flight this tag before exposing remote LSP status.

Expand All @@ -234,6 +235,8 @@ When `workspace_qualified_rest_core` is advertised, the same file surface is als

The same tag also exposes workspace-qualified project-agent CRUD at `/workspaces/:workspace/agents` and `/workspaces/:workspace/agents/:agentType`. These plural routes only read or mutate project-level agents for the selected workspace; `global` and `user` scope requests return `400 { code: "global_scope_not_supported_for_workspace_route" }`. Workspace-less `/workspace/agents` routes retain their existing primary-workspace behavior and remain the only REST surface for user-level agent scope.

`workspace_qualified_extensions` advertises the plural extension-management surface at `/workspaces/:workspace/extensions/*`, mirroring the primary-workspace `/workspace/extensions/*` routes: `GET /workspaces/:workspace/extensions` (status), `GET /workspaces/:workspace/extensions/operations/:operationId`, `POST /workspaces/:workspace/extensions/{install,check-updates,refresh}`, `POST /workspaces/:workspace/extensions/:name/{enable,disable,update}`, and `DELETE /workspaces/:workspace/extensions/:name`. Reads resolve the selected runtime only; mutations require a trusted workspace and otherwise return `403 { code: "untrusted_workspace" }`. Each workspace has its own asynchronous extension-operation queue and status cache; the primary workspace shares one queue across the singular and plural routes. Advertised unconditionally (like `workspace_qualified_rest_core`), independent of how many workspaces are hosted. The workspace-less `/workspace/extensions/*` routes retain their existing primary-workspace behavior.

`daemon_status` advertises `GET /daemon/status`, the consolidated read-only
operator diagnostic snapshot documented below.

Expand Down
1 change: 1 addition & 0 deletions integration-tests/cli/qwen-serve-routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ describe('qwen serve — capabilities envelope', () => {
'session_branch',
'workspace_reload',
'workspace_qualified_rest_core',
'workspace_qualified_extensions',
'voice_transcribe',
]);
});
Expand Down
13 changes: 11 additions & 2 deletions packages/cli/src/serve/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,18 @@ export const SERVE_CAPABILITY_REGISTRY = {
// workspace agent CRUD, and persisted session organization surfaces.
// Workspace-qualified settings also require the existing
// `workspace_settings` tag because that surface depends on settings
// persistence. ACP/WebSocket, auth, voice, and extensions stay on their
// existing primary-workspace routes in this phase.
// persistence. ACP/WebSocket, auth, and voice stay on their existing
// primary-workspace routes in this phase; workspace-qualified extensions
// are advertised separately via `workspace_qualified_extensions`.
workspace_qualified_rest_core: { since: 'v1' },
// Workspace-qualified extension management under
// `/workspaces/:workspace/extensions/*` (mirror of the primary-workspace
// `/workspace/extensions/*` surface). Reads resolve the target runtime;
// mutations additionally require the workspace to be trusted. Advertised
// UNCONDITIONALLY (like `workspace_qualified_rest_core`): presence means the
// plural routes exist on this build, independent of how many workspaces are
// currently hosted.
workspace_qualified_extensions: { since: 'v1' },
// Phase 2 "reverse tool channel" (issue #5626). A connected WS client (e.g.
// the Chrome extension) can host an MCP server that the daemon's agent
// calls by carrying `mcp_message` JSON-RPC frames over the daemon WS,
Expand Down
Loading
Loading