-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(serve): workspace memory and agents CRUD (#4175 Wave 4 PR 16) #4249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e9827fd
feat(serve): workspace memory and agents CRUD (#4175 Wave 4 PR 16)
doudouOUC 3d5e605
fix(serve): address Codex P2 review on PR 16 (#4175 Wave 4 PR 16 foll…
doudouOUC 134c43c
fix(serve): apply round-1 review fold-in 2a (HIGH + CodeQL) on PR 16
doudouOUC 63e637b
fix(serve): apply round-1 review fold-in 2b (MEDIUM + tests) on PR 16
doudouOUC dd82ef8
docs(serve): apply round-1 review fold-in 2c (doc/type tightening) on…
doudouOUC b91e96c
fix(serve): apply round-2 review fold-in 2d on PR 16
doudouOUC 800673b
fix(serve): apply round-3 review fold-in 2e on PR 16
doudouOUC 41b14e2
fix(sdk): expose `changed` on DaemonAgentMutationResult (PR 16 round-4)
doudouOUC ed5a0d5
fix(serve): apply round-6 review fold-in 2g on PR 16
doudouOUC 1b1378a
fix(serve): apply round-7 review fold-in 2h on PR 16
doudouOUC 0a2ba6e
fix(serve): apply round-8 review fold-in 2i on PR 16
doudouOUC 9aa1678
Merge branch 'main' into feat/serve-workspace-memory-agents-crud
doudouOUC 79ca27d
fix(serve): apply round-9 review fold-in 2j on PR 16
doudouOUC 1a51f1f
Merge branch 'main' into feat/serve-workspace-memory-agents-crud
doudouOUC d598915
Merge branch 'main' into feat/serve-workspace-memory-agents-crud
doudouOUC f693f74
fix(serve): skip two Windows-incompatible test fixtures on win32
doudouOUC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /** | ||
| * Returns whether the daemon should expose verbose error context in | ||
| * HTTP responses. Mirrors `isServeDebugLoggingEnabled` in | ||
| * `httpAcpBridge.ts` (which gates stderr-side debug log output). | ||
| * | ||
| * Extracted into its own module in fold-in 2i so route files | ||
| * (`workspaceMemory.ts`, `workspaceAgents.ts`, future Wave 4 mutation | ||
| * routes) can share one canonical predicate when deciding whether to | ||
| * include `errorMessage` / `filePath` in their response bodies. | ||
| * Without the toggle, error responses carry only structured fields | ||
| * (`code` / `scope` / `mode` / `osCode` / ...) so absolute filesystem | ||
| * paths from Node's fs error messages don't leak to authenticated | ||
| * remote callers. | ||
| * | ||
| * Accepts any non-falsy value for the env var; explicit literals | ||
| * `"0" / "false" / "off" / "no"` (case-insensitive, with surrounding | ||
| * whitespace trimmed) disable. Matches the bridge's existing | ||
| * `isServeDebugLoggingEnabled` semantics so the two toggles move in | ||
| * lockstep — operators set `QWEN_SERVE_DEBUG=1` and get both stderr | ||
| * verbosity and response-body detail. | ||
| */ | ||
| export function isServeDebugMode(): boolean { | ||
| const value = process.env['QWEN_SERVE_DEBUG']; | ||
| if (!value) return false; | ||
| return !['0', 'false', 'off', 'no'].includes(value.trim().toLowerCase()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -348,6 +348,28 @@ export interface HttpAcpBridge { | |||||||||
| */ | ||||||||||
| getHeartbeatState(sessionId: string): BridgeHeartbeatState | undefined; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Issue #4175 PR 16: workspace-level event fan-out for mutations that | ||||||||||
| * change daemon-wide state (memory writes, agent CRUD). Publishes the | ||||||||||
| * event onto every live session's `EventBus` so SSE subscribers | ||||||||||
| * observe it through the existing per-session stream rather than a | ||||||||||
| * new workspace-level channel. Best-effort per session — a closed | ||||||||||
| * bus is silently skipped (mirrors the `permission_resolved` | ||||||||||
| * try/catch). When zero sessions are active the event drops on the | ||||||||||
| * floor; the route's read-after-write contract remains correct. | ||||||||||
| */ | ||||||||||
| publishWorkspaceEvent(event: Omit<BridgeEvent, 'id' | 'v'>): void; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Issue #4175 PR 16: union of every live session's `clientIds`. Used | ||||||||||
| * by workspace-level mutation routes (memory write, agent CRUD) to | ||||||||||
| * validate the optional `X-Qwen-Client-Id` header without requiring | ||||||||||
| * a session id. Returns a snapshot — callers must not mutate. | ||||||||||
| * Wave 5 PR 24 will replace this with a workspace-scoped client | ||||||||||
| * registry decoupled from sessions. | ||||||||||
| */ | ||||||||||
| knownClientIds(): ReadonlySet<string>; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Read daemon-runtime MCP status for the bound workspace. Does not spawn an | ||||||||||
| * ACP child when the daemon is idle; idle daemons return initialized:false. | ||||||||||
|
|
@@ -3235,6 +3257,61 @@ export function createHttpAcpBridge(opts: BridgeOptions): HttpAcpBridge { | |||||||||
| }; | ||||||||||
| }, | ||||||||||
|
|
||||||||||
| publishWorkspaceEvent(event) { | ||||||||||
| // Issue #4175 PR 16. Workspace-level mutations (memory writes / | ||||||||||
| // agent CRUD) need a fan-out path that doesn't require a session | ||||||||||
| // id. Iterate every live session's bus best-effort — a closed bus | ||||||||||
| // (mid-shutdown, or evicted under load) is silently skipped, same | ||||||||||
|
doudouOUC marked this conversation as resolved.
|
||||||||||
| // posture as `permission_resolved` at line 1717. | ||||||||||
| // | ||||||||||
| // We deliberately do NOT track delivery success per session here: | ||||||||||
| // the route handler's contract is "read-after-write" and any SSE | ||||||||||
| // subscriber that misses the event can re-fetch via the route's | ||||||||||
| // GET sibling. Stage 5 PR 24 PermissionMediator can layer a | ||||||||||
| // proper workspace event bus on top if adapters need stricter | ||||||||||
| // delivery semantics. | ||||||||||
| // | ||||||||||
| // Per-entry exceptions go to stderr in normal operation, but | ||||||||||
| // are downgraded to the debug channel when `shuttingDown` is | ||||||||||
| // true. `EventBus.publish` is documented never to throw (BX9_p | ||||||||||
| // contract at eventBus.ts:186), so anything landing here in | ||||||||||
| // normal ops is by definition unexpected — silencing it via | ||||||||||
| // QWEN_SERVE_DEBUG would let a true regression succeed at the | ||||||||||
| // route layer (200 OK) while SSE subscribers stop seeing | ||||||||||
| // events. The shutdown gate keeps the common race noise out of | ||||||||||
| // the production log without hiding actual bugs. | ||||||||||
| for (const entry of byId.values()) { | ||||||||||
| try { | ||||||||||
| entry.events.publish(event); | ||||||||||
| } catch (err) { | ||||||||||
| const detail = | ||||||||||
| `publishWorkspaceEvent: bus publish failed for session ` + | ||||||||||
| `${JSON.stringify(entry.sessionId)} (type=${event.type}): ` + | ||||||||||
| `${err instanceof Error ? err.message : String(err)}`; | ||||||||||
| if (shuttingDown) { | ||||||||||
| writeServeDebugLine(detail); | ||||||||||
| } else { | ||||||||||
| writeStderrLine(`qwen serve: ${detail}`); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| }, | ||||||||||
|
|
||||||||||
| knownClientIds() { | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— DeepSeek/deepseek-v4-pro via Qwen Code /review |
||||||||||
| // Snapshot the union of every live session's stamped client ids. | ||||||||||
|
doudouOUC marked this conversation as resolved.
|
||||||||||
| // Returned as a fresh Set so callers can mutate-safely (the live | ||||||||||
| // per-session maps stay private). Workspace-level mutation routes | ||||||||||
| // use this to validate `X-Qwen-Client-Id` without owning a | ||||||||||
|
doudouOUC marked this conversation as resolved.
|
||||||||||
| // session id; PR 24 will replace it with a workspace-scoped | ||||||||||
| // registry that doesn't conflate session-attach with workspace- | ||||||||||
| // attach. | ||||||||||
| const out = new Set<string>(); | ||||||||||
| for (const entry of byId.values()) { | ||||||||||
| for (const id of entry.clientIds.keys()) out.add(id); | ||||||||||
| } | ||||||||||
| return out; | ||||||||||
| }, | ||||||||||
|
|
||||||||||
| async getWorkspaceMcpStatus() { | ||||||||||
| return requestWorkspaceStatus(SERVE_STATUS_EXT_METHODS.workspaceMcp, () => | ||||||||||
| createIdleWorkspaceMcpStatus(boundWorkspace), | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion]
publishWorkspaceEvent缺少 workspace discriminator 参数 — 未来多 workspace 支持的信息泄露隐患该方法遍历所有活跃 session 并向每个 bus 发布,无按 session 的 workspace 范围检查。当前 daemon 绑定到单一 workspace(
boundWorkspace),因此风险为零。但如果未来添加多 workspace 支持而未改造此 fan-out 路径,workspace A 的 memory 写入会将memory_changed事件泄露给 workspace B 的 SSE 订阅者。— DeepSeek/deepseek-v4-pro via Qwen Code /review