@wowyuarm/dsh-agent-team 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +13 -0
  2. package/README.zh.md +13 -0
  3. package/package.json +52 -47
  4. package/packages/agent-team/README.md +4 -2
  5. package/packages/agent-team/README.zh.md +4 -2
  6. package/packages/agent-team/lib/context-management.js +40 -50
  7. package/packages/agent-team/lib/context-projection.js +10 -0
  8. package/packages/agent-team/lib/index.js +235 -112
  9. package/packages/agent-team/lib/invariant.js +38 -4
  10. package/packages/agent-team/lib/ledger.js +554 -271
  11. package/packages/agent-team/lib/member-context.js +6 -2
  12. package/packages/agent-team/lib/member-time-context.js +20 -5
  13. package/packages/agent-team/lib/pressure-policy.js +33 -9
  14. package/packages/agent-team/lib/session-event-cursor.js +116 -0
  15. package/packages/agent-team/lib/session-remediation.js +38 -26
  16. package/packages/agent-team/lib/spec.js +46 -34
  17. package/packages/agent-team/lib/stored-session-reader.js +138 -0
  18. package/packages/agent-team/lib/typert.host.js +107 -40
  19. package/packages/agent-team/lib/typert.remote-client.d.ts.map +1 -1
  20. package/packages/agent-team/lib/typert.remote-client.js +84 -32
  21. package/packages/agent-team/lib/types/context-management.d.ts +7 -0
  22. package/packages/agent-team/lib/types/context-management.d.ts.map +1 -1
  23. package/packages/agent-team/lib/types/context-projection.d.ts +8 -0
  24. package/packages/agent-team/lib/types/context-projection.d.ts.map +1 -1
  25. package/packages/agent-team/lib/types/index.d.ts +78 -2
  26. package/packages/agent-team/lib/types/index.d.ts.map +1 -1
  27. package/packages/agent-team/lib/types/invariant.d.ts.map +1 -1
  28. package/packages/agent-team/lib/types/ledger.d.ts +180 -7
  29. package/packages/agent-team/lib/types/ledger.d.ts.map +1 -1
  30. package/packages/agent-team/lib/types/member-context.d.ts.map +1 -1
  31. package/packages/agent-team/lib/types/member-time-context.d.ts.map +1 -1
  32. package/packages/agent-team/lib/types/pressure-policy.d.ts +18 -0
  33. package/packages/agent-team/lib/types/pressure-policy.d.ts.map +1 -1
  34. package/packages/agent-team/lib/types/session-event-cursor.d.ts +119 -0
  35. package/packages/agent-team/lib/types/session-event-cursor.d.ts.map +1 -0
  36. package/packages/agent-team/lib/types/session-remediation.d.ts +23 -0
  37. package/packages/agent-team/lib/types/session-remediation.d.ts.map +1 -1
  38. package/packages/agent-team/lib/types/spec.d.ts.map +1 -1
  39. package/packages/agent-team/lib/types/stored-session-reader.d.ts +92 -0
  40. package/packages/agent-team/lib/types/stored-session-reader.d.ts.map +1 -0
  41. package/packages/agent-team/lib/types/types/entities.d.ts +28 -2
  42. package/packages/agent-team/lib/types/types/entities.d.ts.map +1 -1
  43. package/packages/agent-team/lib/types/types/operations.d.ts +45 -19
  44. package/packages/agent-team/lib/types/types/operations.d.ts.map +1 -1
  45. package/packages/agent-team/lib/types/types/requests-results.d.ts +44 -3
  46. package/packages/agent-team/lib/types/types/requests-results.d.ts.map +1 -1
  47. package/packages/agent-team/preset/team-member/agent.cordis.yml +3 -1
  48. package/packages/client-agent-team/README.md +1 -1
  49. package/packages/client-agent-team/README.zh.md +1 -1
  50. package/packages/client-agent-team/lib/client.js +1068 -375
  51. package/packages/client-agent-team/lib/client.js.map +1 -1
  52. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.d.ts.map +1 -1
  53. package/packages/client-agent-team/lib/types/client/TeamAgentsPanel.js +24 -4
  54. package/packages/client-agent-team/lib/types/client/TeamChannelPage.d.ts.map +1 -1
  55. package/packages/client-agent-team/lib/types/client/TeamChannelPage.js +42 -22
  56. package/packages/client-agent-team/lib/types/client/TeamChannelsPanel.d.ts.map +1 -1
  57. package/packages/client-agent-team/lib/types/client/TeamChannelsPanel.js +13 -24
  58. package/packages/client-agent-team/lib/types/client/TeamComposer.d.ts +11 -5
  59. package/packages/client-agent-team/lib/types/client/TeamComposer.d.ts.map +1 -1
  60. package/packages/client-agent-team/lib/types/client/TeamComposer.js +15 -9
  61. package/packages/client-agent-team/lib/types/client/TeamConversation.d.ts +1 -1
  62. package/packages/client-agent-team/lib/types/client/TeamConversation.d.ts.map +1 -1
  63. package/packages/client-agent-team/lib/types/client/TeamConversation.js +8 -1
  64. package/packages/client-agent-team/lib/types/client/TeamInboxPage.d.ts +21 -0
  65. package/packages/client-agent-team/lib/types/client/TeamInboxPage.d.ts.map +1 -0
  66. package/packages/client-agent-team/lib/types/client/TeamInboxPage.js +71 -0
  67. package/packages/client-agent-team/lib/types/client/TeamMemberEditor.d.ts.map +1 -1
  68. package/packages/client-agent-team/lib/types/client/TeamMemberEditor.js +8 -24
  69. package/packages/client-agent-team/lib/types/client/TeamMessage.d.ts +9 -2
  70. package/packages/client-agent-team/lib/types/client/TeamMessage.d.ts.map +1 -1
  71. package/packages/client-agent-team/lib/types/client/TeamMessage.js +11 -4
  72. package/packages/client-agent-team/lib/types/client/TeamPresenceDot.d.ts +8 -0
  73. package/packages/client-agent-team/lib/types/client/TeamPresenceDot.d.ts.map +1 -1
  74. package/packages/client-agent-team/lib/types/client/TeamPresenceDot.js +21 -1
  75. package/packages/client-agent-team/lib/types/client/TeamThreadPage.d.ts.map +1 -1
  76. package/packages/client-agent-team/lib/types/client/TeamThreadPage.js +102 -28
  77. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts +1 -1
  78. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.d.ts.map +1 -1
  79. package/packages/client-agent-team/lib/types/client/TeamWorkspaceBrowser.js +50 -7
  80. package/packages/client-agent-team/lib/types/client/index.d.ts.map +1 -1
  81. package/packages/client-agent-team/lib/types/client/index.js +17 -6
  82. package/packages/client-agent-team/lib/types/client/locales.d.ts +18 -0
  83. package/packages/client-agent-team/lib/types/client/locales.d.ts.map +1 -1
  84. package/packages/client-agent-team/lib/types/client/locales.js +18 -0
  85. package/packages/client-agent-team/lib/types/client/navigation.d.ts +10 -0
  86. package/packages/client-agent-team/lib/types/client/navigation.d.ts.map +1 -1
  87. package/packages/client-agent-team/lib/types/client/navigation.js +18 -7
  88. package/packages/client-agent-team/lib/types/client/scope-coverage.d.ts +41 -0
  89. package/packages/client-agent-team/lib/types/client/scope-coverage.d.ts.map +1 -0
  90. package/packages/client-agent-team/lib/types/client/scope-coverage.js +64 -0
  91. package/packages/client-agent-team/lib/types/client/slots.d.ts +7 -1
  92. package/packages/client-agent-team/lib/types/client/slots.d.ts.map +1 -1
  93. package/packages/client-agent-team/lib/types/client/team-changes.d.ts +26 -1
  94. package/packages/client-agent-team/lib/types/client/team-changes.d.ts.map +1 -1
  95. package/packages/client-agent-team/lib/types/client/team-changes.js +66 -15
  96. package/packages/client-agent-team/lib/types/client/team-dialog-save.d.ts +20 -0
  97. package/packages/client-agent-team/lib/types/client/team-dialog-save.d.ts.map +1 -0
  98. package/packages/client-agent-team/lib/types/client/team-dialog-save.js +36 -0
  99. package/packages/client-agent-team/lib/types/client/team-formatters.d.ts +9 -0
  100. package/packages/client-agent-team/lib/types/client/team-formatters.d.ts.map +1 -1
  101. package/packages/client-agent-team/lib/types/client/team-formatters.js +34 -6
  102. package/packages/tool-agent-team/README.md +1 -1
  103. package/packages/tool-agent-team/README.zh.md +1 -1
  104. package/packages/tool-agent-team/lib/context-tools.js +18 -14
  105. package/packages/tool-agent-team/lib/host-access.js +20 -0
  106. package/packages/tool-agent-team/lib/index.js +16 -17
  107. package/packages/tool-agent-team/lib/types/context-tools.d.ts.map +1 -1
  108. package/packages/tool-agent-team/lib/types/host-access.d.ts +14 -0
  109. package/packages/tool-agent-team/lib/types/host-access.d.ts.map +1 -0
  110. package/packages/tool-agent-team/lib/types/index.d.ts.map +1 -1
package/README.md CHANGED
@@ -80,6 +80,19 @@ Team mode
80
80
 
81
81
  Create an Agent only in a trusted Workspace. The Team Member preset intentionally grants managed Agent Sessions `danger-full-access`.
82
82
 
83
+ ## Not to be confused with
84
+
85
+ Three other DSH plugins carry similar names and solve a different problem — one of them may fit you better:
86
+
87
+ | Plugin | What it is | Its unit of work |
88
+ | --- | --- | --- |
89
+ | [`NanmiCoder/dsh-agent-teams`](https://github.com/NanmiCoder/dsh-agent-teams) | Turns the current DSH session into a captain that assembles sub-agents, splits a goal into dependency-aware tasks, and coordinates them through direct messages | one **session** |
90
+ | [`toolclub/dsh-agent-team-gui`](https://github.com/toolclub/dsh-agent-team-gui) | A reusable plan → implement → review team with a model chosen per member, and a Run Center for token usage | one **workflow run** |
91
+ | [`limuyang2/agent-team`](https://github.com/limuyang2/agent-team) — publishes `@limuyang2/dsh-agent-team` | Builds a team of independent root agents inside one DSH window: mix models and providers, assign one Leader, and let every member work in its own conversation over a shared Workspace | one **assembled team** |
92
+ | **`dsh-agent-team`** (this plugin) | Every agent is a durable Member identity with its own private memory, notes and skills; Channels and responsibilities are yours to assign, and a Task Thread is one line of progress | a **standing team** |
93
+
94
+ The practical difference: a Member you created last week is still the same Member today — same memory, same responsibilities, same private notes — after its session ended, its context rolled over, or DSH restarted. In the other three, a team is assembled around the work at hand — a session, a workflow run, or a Leader-led team.
95
+
83
96
  ## Uninstall
84
97
 
85
98
  Remove the bundle from the profile; this also removes its composed layers:
package/README.zh.md CHANGED
@@ -80,6 +80,19 @@ Team mode
80
80
 
81
81
  只在可信 Workspace 中创建 Agent。Team Member preset 会给被管理的 Agent Session 授予 `danger-full-access`。
82
82
 
83
+ ## 与同名插件的区别
84
+
85
+ 另外三个 DSH 插件名字相近,但解决的是不同的问题 —— 其中一个可能更适合你:
86
+
87
+ | 插件 | 它是什么 | 工作单位 |
88
+ | --- | --- | --- |
89
+ | [`NanmiCoder/dsh-agent-teams`](https://github.com/NanmiCoder/dsh-agent-teams) | 把**当前** DSH session 变成 captain,由它组建 sub-agent、把目标拆成带依赖的任务、并通过直接通信协调 | 一个 **session** |
90
+ | [`toolclub/dsh-agent-team-gui`](https://github.com/toolclub/dsh-agent-team-gui) | 可复用的「规划 → 实现 → 评审」团队,每个成员可选不同模型,Run Center 查看 token 用量 | 一次 **workflow run** |
91
+ | [`limuyang2/agent-team`](https://github.com/limuyang2/agent-team)(npm 名 `@limuyang2/dsh-agent-team`) | 在一个 DSH 窗口里组一支独立 root agent 的队:混用模型与 provider、指定一个 Leader,每个成员在自己的会话里工作、共享同一个 Workspace | 一支**组起来执行任务的队** |
92
+ | **`dsh-agent-team`**(本插件) | 每个 agent 是持久 Member 身份,带自己的私有记忆、笔记与技能;Channel 与职责由你分配,Task Thread 是一条进度线 | 一支**常驻团队** |
93
+
94
+ 实际差别:你上周创建的 Member,今天还是同一个 Member —— 同样的记忆、职责和私有笔记 —— 即使它的 session 已结束、上下文已滚动、或 DSH 重启过。另外三个里,团队是围绕手头这次工作组建的 —— 一次 session、一次 workflow run,或一支有 Leader 的队。
95
+
83
96
  ## 卸载
84
97
 
85
98
  从 profile 移除 bundle,同时会移除它组合进来的层:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wowyuarm/dsh-agent-team",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "A persistent agent team for long-running collaboration in DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,9 @@
23
23
  "generate:typert": "node --import tsx scripts/generate-typert.mjs",
24
24
  "prepack": "npm run build",
25
25
  "clean:build-outputs": "node scripts/clean-build-outputs.mjs",
26
- "test": "npm run generate:typert && vitest run",
26
+ "check:docs": "node scripts/check-docs.mjs",
27
+ "check:core-skills": "node scripts/check-core-skills.mjs",
28
+ "test": "npm run generate:typert && npm run check:docs && npm run check:core-skills && vitest run",
27
29
  "test:browser": "npm run build && node scripts/run-browser-test.mjs",
28
30
  "preview": "node scripts/check-preview-credentials.mjs && npm run build && node scripts/run-preview.mjs",
29
31
  "preview:ui": "npm run build && node scripts/run-ui-preview.mjs",
@@ -130,57 +132,60 @@
130
132
  },
131
133
  "peerDependencies": {
132
134
  "@deepseek-ai/cordis": "^4.0.1",
133
- "@deepseek-ai/dsh-agent": ">=0.1.5-rc.1 <0.2.0",
134
- "@deepseek-ai/dsh-agent-default-model": ">=0.1.5-rc.1 <0.2.0",
135
- "@deepseek-ai/dsh-agent-presets": ">=0.1.5-rc.1 <0.2.0",
136
- "@deepseek-ai/dsh-agent-tool-presentation": ">=0.1.5-rc.1 <0.2.0",
137
- "@deepseek-ai/dsh-api-remotes": ">=0.1.5-rc.1 <0.2.0",
138
- "@deepseek-ai/dsh-api-session-controller": ">=0.1.5-rc.1 <0.2.0",
139
- "@deepseek-ai/dsh-api-workspace-controller": ">=0.1.5-rc.1 <0.2.0",
140
- "@deepseek-ai/dsh-brand": ">=0.1.5-rc.1 <0.2.0",
141
- "@deepseek-ai/dsh-client-locale": ">=0.1.5-rc.1 <0.2.0",
142
- "@deepseek-ai/dsh-client-ui-conversation": ">=0.1.5-rc.1 <0.2.0",
143
- "@deepseek-ai/dsh-client-ui-input-trigger": ">=0.1.5-rc.1 <0.2.0",
144
- "@deepseek-ai/dsh-client-ui-layout": ">=0.1.5-rc.1 <0.2.0",
145
- "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.5-rc.1 <0.2.0",
146
- "@deepseek-ai/dsh-client-ui-renderer": ">=0.1.5-rc.1 <0.2.0",
147
- "@deepseek-ai/dsh-client-ui-settings-general": ">=0.1.5-rc.1 <0.2.0",
148
- "@deepseek-ai/dsh-client-ui-sidebar": ">=0.1.5-rc.1 <0.2.0",
149
- "@deepseek-ai/dsh-client-ui-slots": ">=0.1.5-rc.1 <0.2.0",
150
- "@deepseek-ai/dsh-client-ui-workspace": ">=0.1.5-rc.1 <0.2.0",
151
- "@deepseek-ai/dsh-command-compact": ">=0.1.5-rc.1 <0.2.0",
152
- "@deepseek-ai/dsh-compaction": ">=0.1.5-rc.1 <0.2.0",
153
- "@deepseek-ai/dsh-home-paths": ">=0.1.5-rc.1 <0.2.0",
154
- "@deepseek-ai/dsh-invariants": ">=0.1.5-rc.1 <0.2.0",
155
- "@deepseek-ai/dsh-llm": ">=0.1.5-rc.1 <0.2.0",
156
- "@deepseek-ai/dsh-sandbox-policy": ">=0.1.5-rc.1 <0.2.0",
157
- "@deepseek-ai/dsh-scope": ">=0.1.5-rc.1 <0.2.0",
158
- "@deepseek-ai/dsh-session": ">=0.1.5-rc.1 <0.2.0",
159
- "@deepseek-ai/dsh-session-format-catalog": ">=0.1.5-rc.1 <0.2.0",
160
- "@deepseek-ai/dsh-session-persistence": ">=0.1.5-rc.1 <0.2.0",
161
- "@deepseek-ai/dsh-skill": ">=0.1.5-rc.1 <0.2.0",
162
- "@deepseek-ai/dsh-skill-filesystem": ">=0.1.5-rc.1 <0.2.0",
163
- "@deepseek-ai/dsh-storage-domain": ">=0.1.5-rc.1 <0.2.0",
164
- "@deepseek-ai/dsh-token-meter": ">=0.1.5-rc.1 <0.2.0",
165
- "@deepseek-ai/dsh-tool-bash": ">=0.1.5-rc.1 <0.2.0",
166
- "@deepseek-ai/dsh-tool-fs": ">=0.1.5-rc.1 <0.2.0",
167
- "@deepseek-ai/dsh-tool-fs-search": ">=0.1.5-rc.1 <0.2.0",
168
- "@deepseek-ai/dsh-tool-jobs": ">=0.1.5-rc.1 <0.2.0",
169
- "@deepseek-ai/dsh-tool-pwsh": ">=0.1.5-rc.1 <0.2.0",
170
- "@deepseek-ai/dsh-tool-skill": ">=0.1.5-rc.1 <0.2.0",
171
- "@deepseek-ai/dsh-tool-todo": ">=0.1.5-rc.1 <0.2.0",
172
- "@deepseek-ai/dsh-tool-web": ">=0.1.5-rc.1 <0.2.0",
173
- "@deepseek-ai/dsh-tools": ">=0.1.5-rc.1 <0.2.0",
174
- "@deepseek-ai/dsh-typert-protocol": ">=0.1.5-rc.1 <0.2.0",
175
- "@deepseek-ai/dsh-workspace": ">=0.1.5-rc.1 <0.2.0",
135
+ "@deepseek-ai/dsh-agent": ">=0.1.5-rc.1 <0.1.6",
136
+ "@deepseek-ai/dsh-agent-default-model": ">=0.1.5-rc.1 <0.1.6",
137
+ "@deepseek-ai/dsh-agent-presets": ">=0.1.5-rc.1 <0.1.6",
138
+ "@deepseek-ai/dsh-agent-tool-presentation": ">=0.1.5-rc.1 <0.1.6",
139
+ "@deepseek-ai/dsh-api-remotes": ">=0.1.5-rc.1 <0.1.6",
140
+ "@deepseek-ai/dsh-api-session-controller": ">=0.1.5-rc.1 <0.1.6",
141
+ "@deepseek-ai/dsh-api-workspace-controller": ">=0.1.5-rc.1 <0.1.6",
142
+ "@deepseek-ai/dsh-brand": ">=0.1.5-rc.1 <0.1.6",
143
+ "@deepseek-ai/dsh-client-locale": ">=0.1.5-rc.1 <0.1.6",
144
+ "@deepseek-ai/dsh-client-ui-conversation": ">=0.1.5-rc.1 <0.1.6",
145
+ "@deepseek-ai/dsh-client-ui-input-trigger": ">=0.1.5-rc.1 <0.1.6",
146
+ "@deepseek-ai/dsh-client-ui-layout": ">=0.1.5-rc.1 <0.1.6",
147
+ "@deepseek-ai/dsh-client-ui-primitives": ">=0.1.5-rc.1 <0.1.6",
148
+ "@deepseek-ai/dsh-client-ui-renderer": ">=0.1.5-rc.1 <0.1.6",
149
+ "@deepseek-ai/dsh-client-ui-settings-general": ">=0.1.5-rc.1 <0.1.6",
150
+ "@deepseek-ai/dsh-client-ui-sidebar": ">=0.1.5-rc.1 <0.1.6",
151
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.1.5-rc.1 <0.1.6",
152
+ "@deepseek-ai/dsh-client-ui-workspace": ">=0.1.5-rc.1 <0.1.6",
153
+ "@deepseek-ai/dsh-command-compact": ">=0.1.5-rc.1 <0.1.6",
154
+ "@deepseek-ai/dsh-compaction": ">=0.1.5-rc.1 <0.1.6",
155
+ "@deepseek-ai/dsh-home-paths": ">=0.1.5-rc.1 <0.1.6",
156
+ "@deepseek-ai/dsh-invariants": ">=0.1.5-rc.1 <0.1.6",
157
+ "@deepseek-ai/dsh-llm": ">=0.1.5-rc.1 <0.1.6",
158
+ "@deepseek-ai/dsh-sandbox-policy": ">=0.1.5-rc.1 <0.1.6",
159
+ "@deepseek-ai/dsh-scope": ">=0.1.5-rc.1 <0.1.6",
160
+ "@deepseek-ai/dsh-session": ">=0.1.5-rc.1 <0.1.6",
161
+ "@deepseek-ai/dsh-session-format-catalog": ">=0.1.5-rc.1 <0.1.6",
162
+ "@deepseek-ai/dsh-session-persistence": ">=0.1.5-rc.1 <0.1.6",
163
+ "@deepseek-ai/dsh-skill": ">=0.1.5-rc.1 <0.1.6",
164
+ "@deepseek-ai/dsh-skill-filesystem": ">=0.1.5-rc.1 <0.1.6",
165
+ "@deepseek-ai/dsh-storage-domain": ">=0.1.5-rc.1 <0.1.6",
166
+ "@deepseek-ai/dsh-token-meter": ">=0.1.5-rc.1 <0.1.6",
167
+ "@deepseek-ai/dsh-tool-bash": ">=0.1.5-rc.1 <0.1.6",
168
+ "@deepseek-ai/dsh-tool-fs": ">=0.1.5-rc.1 <0.1.6",
169
+ "@deepseek-ai/dsh-tool-fs-search": ">=0.1.5-rc.1 <0.1.6",
170
+ "@deepseek-ai/dsh-tool-jobs": ">=0.1.5-rc.1 <0.1.6",
171
+ "@deepseek-ai/dsh-tool-pwsh": ">=0.1.5-rc.1 <0.1.6",
172
+ "@deepseek-ai/dsh-tool-skill": ">=0.1.5-rc.1 <0.1.6",
173
+ "@deepseek-ai/dsh-tool-todo": ">=0.1.5-rc.1 <0.1.6",
174
+ "@deepseek-ai/dsh-tool-web": ">=0.1.5-rc.1 <0.1.6",
175
+ "@deepseek-ai/dsh-tools": ">=0.1.5-rc.1 <0.1.6",
176
+ "@deepseek-ai/dsh-typert-protocol": ">=0.1.5-rc.1 <0.1.6",
177
+ "@deepseek-ai/dsh-workspace": ">=0.1.5-rc.1 <0.1.6",
176
178
  "react": "^18.2.0"
177
179
  },
178
180
  "keywords": [
181
+ "agent-team",
179
182
  "deepseek-harness",
180
183
  "dsh",
181
184
  "dsh-plugin",
182
- "agent-team",
183
185
  "multi-agent",
184
- "ai-agents"
186
+ "agent-orchestration",
187
+ "ai-agents",
188
+ "deepseek",
189
+ "multi-agent-systems"
185
190
  ]
186
191
  }
@@ -8,10 +8,12 @@ The Host capability for one Agent Team in a dshHome. `ctx.agentTeam` owns the ap
8
8
 
9
9
  The Service consumes `ctx.storageDomain`, `ctx.workspaceRegistry`, `ctx.agents`, `ctx.agentDefaultModel`, `ctx.agentPresets`, `ctx.tools`, `ctx.sessions`, and `ctx.sessionPersistence`. It opens the versioned `agent_team` Domain before Cordis publishes `ctx.agentTeam`. The first boot appends one `team/initialized` operation for the stable Human Member; later boots replay the same operation and do not append another record.
10
10
 
11
- `status()` returns the current durable sequence, operation count, channel count, Agent Member count, and Human Member ref. It performs no model request and no storage write. `validateLedger()` checks the package-owned projection against the durable operation table.
11
+ `status()` returns the current durable sequence, operation count, channel count, Agent Member count, and Human Member ref. It performs no model request and no storage write. `validateLedger()` checks the package-owned projection against the durable operation table. The invariant companion re-derives that whole table at mount — an unreplayable ledger fails startup — but adopts the record-level replay the ledger constructor already ran while nothing has committed since, gated on the record count, head sequence, and head operation id, which only the operations table's single writer can change. Any commit in between, and every later validation, replays the durable records again. Afterwards the invariant re-derives once per burst of commits, after the committing call has returned, so a Thread read never waits on an O(ledger) replay; a divergence is logged where it is detected and re-raised on every later commit until a replay comes back clean.
12
12
 
13
13
  Every operation record carries a positive global sequence, unique operation and request ids, an actor snapshot, and the previous operation id. Replay rejects invalid record fields, table-key/id mismatches, sequence gaps, broken previous links, repeated ids, and invalid state transitions. An identical request-id retry returns the original receipt; a changed payload with the same request id rejects.
14
14
 
15
+ One durable record stores progress instead of the projection it reported. A `team/thread-read` receipt carries the Workspace, Member, Thread ref, optional Task ref, read watermark, and Inbox delta; the Thread, its facts, the anchor, the reader's Attention, and the unread count left behind are re-derived from the projection on every replay. Records written before this form froze that whole picture beside the delta: one strict union accepts both shapes, the legacy record keeps its own full derivation as its expected value, and loading normalizes and validates it without rewriting a stored byte. A record that fits neither shape — a receipt carrying a picture field, a legacy record missing the Task it belongs to or one of its facts — fails the domain open rather than being guessed at. An identical retry of a committed read returns the original receipt with the picture the current projection derives.
16
+
15
17
  ## Durability and lifecycle
16
18
 
17
19
  `storage-domain` validates every record at the durable read boundary and rejects a backend unit stamped with another version. The Team updates its projection only after `KvTable.put()` resolves. Its Fiber owns the Domain handle; disposal rejects new Service calls through Cordis removal, drains accepted Domain writes, and closes the backend unit before the name can reopen.
@@ -32,7 +34,7 @@ Adding a Member to a Channel grants future read/send/claim authority but injects
32
34
 
33
35
  Member replies require the exact current Thread revision and atomically update Message and Thread facts. `threadRef` is the primary collaboration identity; released task-only Clients may send a Host-resolved `taskRef` alias for taskful Threads, while Task/Claim operations remain Task-ref based. Unread work must be read before a mutation; stale revisions are rejected after that unread gate. A closed Task rejects replies and new Attention; reopening restores the Task without restoring prior Attention. Taskless Threads still support replies, follow, mentions, Inbox, read, and history, but have no Claims or Task-resolution path. Top-level Messages may mention Agents directly: mentioned Members start following the new Thread. In an existing Thread, a Human reply mentioning an unfollowed Agent requires a process-local, one-use confirmation token before the operation commits, while such Member replies are rejected with member_not_following. Message facts carry their structured mention refs, and the Client renders mention chips only for those Members. Claim/done/release and Task changes are ordered host-authored Activities. Active Claims exclude only the same normalized Direction; different Directions can run concurrently. Task state is derived from Claims unless Human acceptance or closure overrides it. Close releases active Claims and clears Thread Attention atomically. Member removal marks the member inactive, releases owned active Claims, clears its Attention and direct markers, and archives the session after the durable commit. Message and Activity facts share one bounded sequence cursor.
34
36
 
35
- `changes()` is the Client invalidation stream. Each request declares one optional `scope` — workspace, channel, or thread — plus an abortable transport signal; a committed operation wakes only waiters whose scope matches the scopes derived from that operation (member lifecycle and presence wake their Workspace; content operations wake their Channel and Thread). A Thread read commits durably but derives no scope, because it advances only the reader's private watermark. After each commit the Host notifies only the Members whose Inbox projection the operation can have changed — the operation's Attention/marker delta plus current followers of the touched Threads — never every live Agent.
37
+ `changes()` is the Client invalidation stream. Each request declares one optional `scope` — workspace, channel, or thread — plus an abortable transport signal; a committed operation wakes only waiters whose scope matches the scopes derived from that operation (member lifecycle and presence wake their Workspace; content operations wake their Channel and Thread). A Thread read derives no scope, because it advances only the reader's private watermark — and a read that finds nothing unread for its reader (no watermark to advance, no marker to consume) appends no operation at all: it answers with the same projection-derived picture and no receipt, so an already-read Thread costs neither a durable write nor a replay. After each commit the Host notifies only the Members whose Inbox projection the operation can have changed — the operation's Attention/marker delta plus current followers of the touched Threads — never every live Agent.
36
38
 
37
39
  M1 supports one Host writer. The ledger is permanent and has no snapshot or compaction path.
38
40
 
@@ -8,10 +8,12 @@
8
8
 
9
9
  Service 使用 `ctx.storageDomain`、`ctx.workspaceRegistry`、`ctx.agents`、`ctx.agentDefaultModel`、`ctx.agentPresets`、`ctx.tools`、`ctx.sessions` 和 `ctx.sessionPersistence`,并在 Cordis 发布 `ctx.agentTeam` 前打开带版本的 `agent_team` Domain。首次启动为稳定 Human Member 追加一条 `team/initialized` operation;后续启动重放同一 operation,不追加新记录。
10
10
 
11
- `status()` 返回当前持久 sequence、operation 数量、channel 数量、Agent Member 数量和 Human Member ref。它不发起模型请求,也不写 storage。`validateLedger()` 对照持久 operation table 检查包内 projection。
11
+ `status()` 返回当前持久 sequence、operation 数量、channel 数量、Agent Member 数量和 Human Member ref。它不发起模型请求,也不写 storage。`validateLedger()` 对照持久 operation table 检查包内 projection。invariant companion 在挂载时完整重导该表——重放不通过的账本会让启动失败——但当这期间没有任何提交落地时,它会复用账本构造期已经跑过的那次记录级重放:该复用只能用一次,并受三项同一性检查把关(记录条数、末条 sequence、末条 operation id),而这三项只有 operations 表的唯一写者——账本的 commit 路径——能改变。期间任何一次提交、以及此后的每次校验,都会重新重放持久记录。此后每批提交只跑一次,且安排在这次提交调用返回**之后**执行,所以打开 Thread 不会等待 O(账本) 的重放。漂移由这次延后重放记录日志,并在随后每次提交上重新抛出,直到某次重放干净为止。
12
12
 
13
13
  每条 operation record 包含正数全局 sequence、唯一 operation/request id、actor snapshot 和前一条 operation id。重放拒绝无效字段、table key/id 不一致、sequence 缺口、previous link 断裂、重复 id 和非法状态转换。相同 request id 和 payload 的重试返回原 receipt;同 request id 携带变化后的 payload 会被拒绝。
14
14
 
15
+ 有一类记录存的是「进度」,而不是它当场报告的那份投影。`team/thread-read` receipt 只携带 Workspace、Member、Thread ref、可选 Task ref、read watermark 与 Inbox delta;Thread、其 facts、anchor、读者的 Attention 与读完后剩余的未读计数,都在每次重放时从 projection 重新派生,因此重放一条读不再需要克隆一份假设投影、也不再重新数未读。这个形态之前写入的记录会把整份画面连同 delta 一起冻结:同一个 strict union 同时接受两形,旧记录以自身完整派生作为 expected 值,加载时就地 normalize 与校验,绝不改写任何已存储字节。两形都不符的记录——receipt 里多带画面字段、旧记录缺了所属 Task 或缺了一条 fact——会让整个 domain 打不开,而不是被猜测。对一次已提交读的相同重试返回原 receipt,画面取自当前 projection,从不返回冻结的旧画面。
16
+
15
17
  ## 持久化与生命周期
16
18
 
17
19
  `storage-domain` 在持久读取处校验每条 record,并拒绝被其他版本标记的 backend unit。Team 只在 `KvTable.put()` 完成后更新 projection。其 Fiber 持有 Domain handle;dispose 通过 Cordis 移除拒绝新的 Service 调用,排空已接受的 Domain write,并在名称可重新打开前关闭 backend unit。
@@ -32,7 +34,7 @@ Skills 是 Member 私有的:preset 不带共享 skill-filesystem row,Host
32
34
 
33
35
  Member reply 必须携带准确的当前 Thread revision,并在一个 operation 内更新 Message 和 Thread facts。`threadRef` 是协作主身份;released task-only Client 可为 taskful Thread 传入 Host-resolved `taskRef` alias,而 Task/Claim 操作仍以 Task ref 为准。未读工作必须先 read;revision 过期时拒绝写入。Closed Task 拒绝 reply 和新的 Attention;reopen 恢复 Task,但不恢复之前的 Attention。taskless Thread 仍支持 reply、follow、mention、Inbox、read 和 history,但没有 Claim 或 Task resolution path。顶层消息可以直接 mention Agent:被 mention 的 Member 会开始关注新 Thread。在既有 Thread 中,Human 的 reply 提到 unfollowed Agent 时必须先取得 process-local one-use confirmation token 才提交 operation;Member 的此类 reply 会以 member_not_following 拒绝。Message fact 携带自身的 structured mention refs,Client 只为这些 Member 渲染 mention chip。claim/done/release 和 Task change 是有序的 host-authored Activity。Active Claim 只排斥相同的 normalized Direction;不同 Direction 可以并行。Task status 从 Claims 派生,Human accept/close 是覆盖事实。Close 原子释放 active Claims 并清除 Thread Attention。Member remove 原子标记 inactive、释放 owned active Claims、清除该成员的 Attention 和 direct markers,再归档 session。Message 与 Activity facts 共用一个有界 sequence cursor。
34
36
 
35
- `changes()` 是 Client 失效通知流。每个请求声明一个可选 `scope`(workspace、channel 或 thread)和可取消的传输 signal;一次提交的 operation 只唤醒 scope 与该 operation 派生范围匹配的 waiter(成员生命周期与 presence 唤醒其 Workspace,内容操作唤醒其 Channel 与 Thread)。Thread read 会持久化提交但不派生任何 scope,因为它只推进读者自己的私有水位。每次提交后,Host 只通知 Inbox projection 可能被该 operation 改变的 Member——即 operation 的 Attention/marker delta 加上被触及 Thread 的当前关注者——而不是全部在线 Agent。
37
+ `changes()` 是 Client 失效通知流。每个请求声明一个可选 `scope`(workspace、channel 或 thread)和可取消的传输 signal;一次提交的 operation 只唤醒 scope 与该 operation 派生范围匹配的 waiter(成员生命周期与 presence 唤醒其 Workspace,内容操作唤醒其 Channel 与 Thread)。Thread read 不派生任何 scope,因为它只推进读者自己的私有水位——而一次读如果对读者没有任何未读(没有水位可推进、没有 marker 可消费),就完全不追加 operation:它返回同一份由 projection 派生的画面且不带 receipt,所以已读完的 Thread 既不付一次持久写、也不付一次重放。每次提交后,Host 只通知 Inbox projection 可能被该 operation 改变的 Member——即 operation 的 Attention/marker delta 加上被触及 Thread 的当前关注者——而不是全部在线 Agent。
36
38
 
37
39
  M1 支持单个 Host writer。Ledger 永久保留,不提供 snapshot 或 compaction。
38
40
 
@@ -23,6 +23,22 @@ import { AGENT_TEAM_PLUGIN_ID, createCheckpointContinuationMessage, createHandof
23
23
  import { CONTEXT_CHECKPOINT_TOOL_NAME, CONTEXT_ROLLOVER_TOOL_NAME, continuationDelivered, foldContextProjection, } from "./context-projection.js";
24
24
  /** Stable summary of the one-shot rollover pressure notice (ticket 03 wires delivery). */
25
25
  export const CONTEXT_PRESSURE_NOTICE_SUMMARY = 'Context pressure: prepare a handoff';
26
+ /**
27
+ * Rebuild one Member's in-process intent from the projection's pending
28
+ * rollover. Three call sites consume it — the live result, crash recovery
29
+ * with the turn still open, and crash recovery past the turn end — and they
30
+ * must agree field for field; this is the single definition of that list.
31
+ */
32
+ function intentFromPending(pending) {
33
+ return {
34
+ toolCallId: pending.toolCallId,
35
+ resultSeq: pending.resultSeq,
36
+ turn: pending.turn,
37
+ handoff: pending.handoff,
38
+ ...(pending.checkpointRef === undefined ? {} : { checkpointRef: pending.checkpointRef }),
39
+ relatedFiles: pending.relatedFiles,
40
+ };
41
+ }
26
42
  export class ContextManagementCoordinator {
27
43
  options;
28
44
  members = new Map();
@@ -166,18 +182,7 @@ export class ContextManagementCoordinator {
166
182
  return;
167
183
  if (this.members.has(memberId))
168
184
  return;
169
- this.members.set(memberId, {
170
- agent,
171
- intent: {
172
- toolCallId: pending.toolCallId,
173
- resultSeq: pending.resultSeq,
174
- turn: pending.turn,
175
- handoff: pending.handoff,
176
- ...(pending.checkpointRef === undefined ? {} : { checkpointRef: pending.checkpointRef }),
177
- relatedFiles: pending.relatedFiles,
178
- },
179
- turnEnded: false,
180
- });
185
+ this.members.set(memberId, { agent, intent: intentFromPending(pending), turnEnded: false });
181
186
  }
182
187
  onUserMessage(memberId, _agent, event) {
183
188
  // Quiet-continuation delivery bookkeeping is projection-owned; the
@@ -216,6 +221,23 @@ export class ContextManagementCoordinator {
216
221
  this.members.delete(memberId);
217
222
  });
218
223
  }
224
+ /**
225
+ * Claim the in-process latch for one resolved checkpoint continuation.
226
+ * Returns the latch key when this caller won it, or undefined when the
227
+ * checkpoint never concluded a turn, was already delivered durably, or is
228
+ * latched already. The caller releases the latch on its own failure path.
229
+ */
230
+ claimContinuationLatch(memberId, state, checkpoint) {
231
+ if (checkpoint.turnEndSeq === -1)
232
+ return undefined;
233
+ if (continuationDelivered(state, checkpoint.checkpointRef))
234
+ return undefined;
235
+ const latch = `${memberId}:${checkpoint.checkpointRef}`;
236
+ if (this.scheduledContinuations.has(latch))
237
+ return undefined;
238
+ this.scheduledContinuations.add(latch);
239
+ return latch;
240
+ }
219
241
  /**
220
242
  * Quiet follow-ups for checkpoints resolved by the turn that just ended.
221
243
  * A successful `context_checkpoint` result concludes its turn; the Host
@@ -233,14 +255,9 @@ export class ContextManagementCoordinator {
233
255
  if (state === undefined)
234
256
  return;
235
257
  for (const checkpoint of state.checkpoints) {
236
- if (checkpoint.turnEndSeq === -1)
258
+ const latch = this.claimContinuationLatch(memberId, state, checkpoint);
259
+ if (latch === undefined)
237
260
  continue;
238
- if (continuationDelivered(state, checkpoint.checkpointRef))
239
- continue;
240
- const latch = `${memberId}:${checkpoint.checkpointRef}`;
241
- if (this.scheduledContinuations.has(latch))
242
- continue;
243
- this.scheduledContinuations.add(latch);
244
261
  // The turn/end observer fires inside the session append publication
245
262
  // (a synchronous followup would reenter the publishing append), and a
246
263
  // next-turn message queued while the driver is still converging never
@@ -310,18 +327,7 @@ export class ContextManagementCoordinator {
310
327
  if (pending.turnEndSeq === -1) {
311
328
  // The containing turn never ended durably; treat the intent as still
312
329
  // waiting and observe the live events from here.
313
- this.members.set(memberId, {
314
- agent,
315
- intent: {
316
- toolCallId: pending.toolCallId,
317
- resultSeq: pending.resultSeq,
318
- turn: pending.turn,
319
- handoff: pending.handoff,
320
- ...(pending.checkpointRef === undefined ? {} : { checkpointRef: pending.checkpointRef }),
321
- relatedFiles: pending.relatedFiles,
322
- },
323
- turnEnded: false,
324
- });
330
+ this.members.set(memberId, { agent, intent: intentFromPending(pending), turnEnded: false });
325
331
  return;
326
332
  }
327
333
  // The turn already ended before the crash; the Agent is idle at
@@ -329,18 +335,7 @@ export class ContextManagementCoordinator {
329
335
  const member = this.options.memberForAgent(agent);
330
336
  if (member === undefined)
331
337
  return;
332
- const transition = {
333
- agent,
334
- intent: {
335
- toolCallId: pending.toolCallId,
336
- resultSeq: pending.resultSeq,
337
- turn: pending.turn,
338
- handoff: pending.handoff,
339
- ...(pending.checkpointRef === undefined ? {} : { checkpointRef: pending.checkpointRef }),
340
- relatedFiles: pending.relatedFiles,
341
- },
342
- turnEnded: true,
343
- };
338
+ const transition = { agent, intent: intentFromPending(pending), turnEnded: true };
344
339
  this.members.set(memberId, transition);
345
340
  void this.performTransition(memberId, member, transition);
346
341
  }
@@ -358,14 +353,9 @@ export class ContextManagementCoordinator {
358
353
  if (memberId === undefined)
359
354
  return;
360
355
  for (const checkpoint of state.checkpoints) {
361
- if (checkpoint.turnEndSeq === -1)
362
- continue;
363
- if (continuationDelivered(state, checkpoint.checkpointRef))
364
- continue;
365
- const latch = `${memberId}:${checkpoint.checkpointRef}`;
366
- if (this.scheduledContinuations.has(latch))
356
+ const latch = this.claimContinuationLatch(memberId, state, checkpoint);
357
+ if (latch === undefined)
367
358
  continue;
368
- this.scheduledContinuations.add(latch);
369
359
  try {
370
360
  agent.followup(createCheckpointContinuationMessage(checkpoint.checkpointRef));
371
361
  }
@@ -176,6 +176,16 @@ export function foldContextProjection(events, inheritedEventCount = 0, sessionId
176
176
  }
177
177
  return state;
178
178
  }
179
+ /**
180
+ * The same fold as {@link foldContextProjection}, as the `{ start, step }` pair
181
+ * the incremental Session cursor consumes. The cursor route and the cold fold
182
+ * therefore share one transition function: a Session's projection cannot
183
+ * depend on which of the two read it.
184
+ */
185
+ export const contextProjectionFold = (sessionId) => ({
186
+ start: emptyState(),
187
+ step: (state, event) => applyContextEvent(state, event, sessionId),
188
+ });
179
189
  /**
180
190
  * The host-only projection unit; no wire view is published. The definition is
181
191
  * a factory: each Session folds with its own identity so checkpoint refs