@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.0.0

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 (179) hide show
  1. package/NOTICE.md +13 -7
  2. package/README.en.md +20 -12
  3. package/README.md +20 -12
  4. package/compatibility.json +82 -46
  5. package/icon.png +0 -0
  6. package/lib/artifacts.js +148 -25
  7. package/lib/client/ActivityPanel.js +26 -5
  8. package/lib/client/WorkspaceActivity.js +6 -4
  9. package/lib/client/activity-monitor.js +113 -41
  10. package/lib/client/locales.js +14 -0
  11. package/lib/client.js +433 -199
  12. package/lib/client.js.map +1 -1
  13. package/lib/command.js +7 -4
  14. package/lib/git-artifact-stamp.json +2 -2
  15. package/lib/harness-compat.js +120 -62
  16. package/lib/index.js +7 -10
  17. package/lib/mailbox.js +15 -5
  18. package/lib/members.js +221 -154
  19. package/lib/snapshot.js +15 -10
  20. package/lib/state.js +41 -8
  21. package/lib/tools.js +123 -64
  22. package/lib/types/artifacts.d.ts +6 -3
  23. package/lib/types/client/activity-monitor.d.ts +13 -4
  24. package/lib/types/client/locales.d.ts +14 -0
  25. package/lib/types/harness-compat.d.ts +63 -16
  26. package/lib/types/mailbox.d.ts +2 -0
  27. package/lib/types/members.d.ts +5 -17
  28. package/lib/types/snapshot.d.ts +12 -7
  29. package/lib/types/state.d.ts +10 -3
  30. package/lib/types/types.d.ts +5 -0
  31. package/lib/types/web-routes.d.ts +2 -0
  32. package/lib/types/workspace-audit-service.d.ts +35 -0
  33. package/lib/types/workspace-audit-worker.d.ts +1 -0
  34. package/lib/web-routes.js +31 -0
  35. package/lib/workspace-audit-service.js +165 -0
  36. package/lib/workspace-audit-worker.js +11 -0
  37. package/lib/workspace-audit.js +6 -5
  38. package/locale/en.json +6 -0
  39. package/locale/zh.json +6 -0
  40. package/package.json +69 -64
  41. package/pnpm-workspace.yaml +306 -273
  42. package/release-notes/v0.1.25.md +16 -0
  43. package/release-notes/v0.1.26.md +19 -0
  44. package/release-notes/v0.1.27.md +42 -0
  45. package/release-notes/v0.1.28.md +45 -0
  46. package/release-notes/v0.1.29.md +23 -0
  47. package/release-notes/v1.1.0.md +42 -0
  48. package/release-notes/v2.0.0.md +17 -0
  49. package/scripts/artwork-role-match.test.mjs +517 -0
  50. package/scripts/capabilities.test.mjs +301 -0
  51. package/scripts/check-install-channel.mjs +55 -0
  52. package/scripts/check-install-channel.test.mjs +39 -0
  53. package/scripts/clean-build.mjs +14 -0
  54. package/scripts/client-harness-migration.test.mjs +46 -0
  55. package/scripts/compatibility.mjs +20 -0
  56. package/scripts/compatibility.test.mjs +187 -0
  57. package/scripts/corrupt-teamjson.test.mjs +180 -0
  58. package/scripts/custom-artwork.test.mjs +273 -0
  59. package/scripts/fallback-tdd.mjs +61 -0
  60. package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
  61. package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
  62. package/scripts/fixtures/harness-complex-case.mjs +201 -0
  63. package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
  64. package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
  65. package/scripts/fixtures/harness-issue-case.mjs +51 -0
  66. package/scripts/fixtures/harness-issue159-case.mjs +28 -0
  67. package/scripts/fixtures/harness-model-case.mjs +127 -0
  68. package/scripts/fixtures/harness-model-case.test.mjs +37 -0
  69. package/scripts/fixtures/harness-model-driver.mjs +100 -0
  70. package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
  71. package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
  72. package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
  73. package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
  74. package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
  75. package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
  76. package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
  77. package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
  78. package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
  79. package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
  80. package/scripts/git-artifacts.mjs +64 -0
  81. package/scripts/git-artifacts.test.mjs +32 -0
  82. package/scripts/harness-compat-tdd.mjs +492 -0
  83. package/scripts/harness-issue-verify.mjs +26 -0
  84. package/scripts/harness-model-benchmark.mjs +163 -0
  85. package/scripts/harness-runtime-platform.test.mjs +31 -0
  86. package/scripts/harness-runtime-scenarios.mjs +297 -0
  87. package/scripts/harness-runtime-verify.mjs +169 -0
  88. package/scripts/harness-source-verify.mjs +211 -0
  89. package/scripts/harness-source-verify.test.mjs +97 -0
  90. package/scripts/harness-validation.mjs +68 -0
  91. package/scripts/harness-validation.test.mjs +95 -0
  92. package/scripts/http-body.test.mjs +72 -0
  93. package/scripts/import-vendor-artwork.mjs +78 -0
  94. package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
  95. package/scripts/issue-159.test.mjs +78 -0
  96. package/scripts/issue-188.test.mjs +148 -0
  97. package/scripts/issue-189.test.mjs +100 -0
  98. package/scripts/issue-203-card.test.mjs +181 -0
  99. package/scripts/issue-205.test.mjs +163 -0
  100. package/scripts/issue-234.test.mjs +424 -0
  101. package/scripts/issue-236-stale-module.test.mjs +63 -0
  102. package/scripts/issue-236.test.mjs +59 -0
  103. package/scripts/issue-262.test.mjs +98 -0
  104. package/scripts/issue-336.test.mjs +404 -0
  105. package/scripts/legacy-session-source-repair.test.mjs +201 -0
  106. package/scripts/lifecycle-verify.mjs +1573 -0
  107. package/scripts/lineage-identity.test.mjs +77 -0
  108. package/scripts/member-failure-tdd.mjs +451 -0
  109. package/scripts/member-spawn-recovery.test.mjs +92 -0
  110. package/scripts/quality-gates-amend.test.mjs +161 -0
  111. package/scripts/quality-gates-content-bound.test.mjs +572 -0
  112. package/scripts/quality-gates-cross-binding.test.mjs +184 -0
  113. package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
  114. package/scripts/quality-gates-repair-scope.test.mjs +143 -0
  115. package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
  116. package/scripts/quality-gates-tdd.mjs +1238 -0
  117. package/scripts/quality-gates-work-order.test.mjs +494 -0
  118. package/scripts/readme-version.mjs +89 -0
  119. package/scripts/readme-version.test.mjs +77 -0
  120. package/scripts/release-metadata.mjs +45 -0
  121. package/scripts/release-metadata.test.mjs +66 -0
  122. package/scripts/scoped-release.test.mjs +52 -0
  123. package/scripts/stability-tdd.mjs +144 -0
  124. package/scripts/stress-verify.mjs +548 -0
  125. package/scripts/symlink-support.mjs +46 -0
  126. package/scripts/sync-skill.mjs +103 -0
  127. package/scripts/tool-policies.test.mjs +280 -0
  128. package/scripts/update-skills.mjs +105 -0
  129. package/scripts/update-skills.test.mjs +79 -0
  130. package/scripts/upgrade-status.mjs +66 -0
  131. package/scripts/upgrade-status.test.mjs +83 -0
  132. package/scripts/verify-package.mjs +73 -0
  133. package/scripts/verify.mjs +2199 -0
  134. package/scripts/web-routes-verify.mjs +142 -0
  135. package/scripts/workspace-activity.test.mjs +346 -0
  136. package/scripts/workspace-summary.test.mjs +49 -0
  137. package/src/artifacts.ts +487 -0
  138. package/src/artwork-source.ts +262 -0
  139. package/src/capabilities.ts +113 -0
  140. package/src/client/ActivityPanel.module.css +2390 -0
  141. package/src/client/ActivityPanel.tsx +1507 -0
  142. package/src/client/AgentTeamsCard.module.css +148 -0
  143. package/src/client/AgentTeamsCard.tsx +155 -0
  144. package/src/client/StagingPlanEditor.tsx +829 -0
  145. package/src/client/TeamChatEntry.tsx +27 -0
  146. package/src/client/WorkspaceActivity.module.css +41 -0
  147. package/src/client/WorkspaceActivity.tsx +137 -0
  148. package/src/client/activity-model.ts +372 -0
  149. package/src/client/activity-monitor.ts +440 -0
  150. package/src/client/agent-teams-card-definition.ts +250 -0
  151. package/src/client/artwork.ts +374 -0
  152. package/src/client/icons.tsx +17 -0
  153. package/src/client/index.tsx +140 -0
  154. package/src/client/locales.ts +481 -0
  155. package/src/client/panel-geometry.ts +194 -0
  156. package/src/client/session-navigation.ts +73 -0
  157. package/src/client/workspace-state.ts +52 -0
  158. package/src/command.ts +145 -0
  159. package/src/css-modules.d.ts +4 -0
  160. package/src/event-types.ts +177 -0
  161. package/src/events.ts +78 -0
  162. package/src/harness-compat.ts +570 -0
  163. package/src/index.ts +599 -0
  164. package/src/lineage.ts +248 -0
  165. package/src/mailbox.ts +185 -0
  166. package/src/members.ts +1230 -0
  167. package/src/profiles.ts +765 -0
  168. package/src/quality-gates.ts +2124 -0
  169. package/src/scheduler.ts +554 -0
  170. package/src/snapshot.ts +333 -0
  171. package/src/state.ts +1317 -0
  172. package/src/tool-names.ts +14 -0
  173. package/src/tool-policies.ts +219 -0
  174. package/src/tools.ts +2939 -0
  175. package/src/types.ts +414 -0
  176. package/src/web-routes.ts +128 -0
  177. package/src/workspace-audit-service.ts +182 -0
  178. package/src/workspace-audit-worker.ts +12 -0
  179. package/src/workspace-audit.ts +57 -0
@@ -0,0 +1,14 @@
1
+ /** Stable business API names; exposure changes never rename these operations. */
2
+ export const TEAM_TOOL_NAMES = [
3
+ 'agent_teams_create', 'agent_teams_approve', 'agent_teams_edit_plan',
4
+ 'agent_teams_add_member', 'agent_teams_remove_member', 'agent_teams_create_task',
5
+ 'agent_teams_reassign_task', 'agent_teams_claim_task', 'agent_teams_update_task',
6
+ 'agent_teams_amend_task',
7
+ 'agent_teams_send_message', 'agent_teams_status', 'agent_teams_resume', 'agent_teams_delete',
8
+ ] as const
9
+
10
+ export const MEMBER_TOOL_NAMES: readonly string[] = [
11
+ 'agent_teams_claim_task', 'agent_teams_update_task', 'agent_teams_send_message', 'agent_teams_status',
12
+ ]
13
+
14
+ export const CAPTAIN_TOOL_NAMES = TEAM_TOOL_NAMES.filter(name => !MEMBER_TOOL_NAMES.includes(name))
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Owner-declared, reusable per-member tool policies (#59).
3
+ *
4
+ * A deployment owner declares reusable policies under `toolPolicies`; a member
5
+ * *selects* one by id (`tool_policy` on `agent_teams_add_member`, an inline
6
+ * plan member, or a profile member row). The Captain model can therefore only
7
+ * choose an existing policy — it can never submit raw allow/deny lists or
8
+ * invent one at runtime.
9
+ *
10
+ * One pure resolver turns the selection into the immutable effective filter
11
+ * that is persisted on the member (`toolPolicy` + `toolFilter`) and handed to
12
+ * the existing `startContinuable({ toolFilter })` seam, which hides the named
13
+ * tools from the child's schemas and rejects their execution. This is tool
14
+ * visibility / invocation policy for global tools, not an OS sandbox.
15
+ *
16
+ * Invariants (issue #59):
17
+ * 1. the captain-only deny list always applies and cannot be undone by a
18
+ * policy — the host intersects `allow` and `deny`, so a denied name never
19
+ * becomes visible again;
20
+ * 2. the four member coordination tools stay available, and a policy may not
21
+ * deny them;
22
+ * 3. an allow-list policy explicitly includes those coordination tools;
23
+ * 4. the effective deny list is the union of the policy deny list and the
24
+ * captain-only deny list.
25
+ * @module dsh-agent-teams/tool-policies
26
+ */
27
+
28
+ import { CAPTAIN_TOOL_NAMES, MEMBER_TOOL_NAMES } from './tool-names.ts'
29
+
30
+ /** Host tools denied when member delegation is switched off (`memberMaxDepth: 0`). */
31
+ const DEPTH_DENY_TOOLS = ['subagent', 'send_message'] as const
32
+
33
+ /** The PTC presentation transport is reserved and cannot be named by a filter. */
34
+ const RESERVED_TOOL_NAME = 'run_code'
35
+
36
+ /**
37
+ * Deny names the lenient spawn retry may drop when the host reports them
38
+ * unknown: exactly the built-in captain-only and depth entries (#163/#164).
39
+ * Names an owner policy declares are never relaxed — a policy that the host
40
+ * cannot apply must fail loud instead of silently applying a different one.
41
+ */
42
+ export const BUILTIN_DENY_TOOLS: readonly string[] = [...CAPTAIN_TOOL_NAMES, ...DEPTH_DENY_TOOLS]
43
+
44
+ /** One owner-declared reusable member tool policy. */
45
+ export interface MemberToolPolicy {
46
+ /** Global tool names that stay visible; coordination tools are added automatically. */
47
+ allow?: string[]
48
+ /** Global tool names removed from visibility; captain-only tools are added automatically. */
49
+ deny?: string[]
50
+ }
51
+
52
+ /** The immutable effective filter of one member. */
53
+ export interface MemberToolFilter {
54
+ /** Visible global tools; absent means "no allow-list" (everything not denied stays). */
55
+ allow?: string[]
56
+ /** Removed global tools; never empty (the captain-only deny list is always included). */
57
+ deny: string[]
58
+ }
59
+
60
+ /** How the running host resolves the depth entries; both fields are optional. */
61
+ export interface ToolPolicyContext {
62
+ /** Member delegation depth cap; `0` denies the host delegation tools when they exist. */
63
+ maxDepth?: number
64
+ /** Names the host's `tools.restrict()` would admit, or undefined without a registry view. */
65
+ knownTools?: ReadonlySet<string>
66
+ }
67
+
68
+ /** Trim, drop blanks, and de-duplicate names, preserving first-seen order. */
69
+ export function dedupeToolNames(names: readonly string[]): string[] {
70
+ const seen = new Set<string>()
71
+ const result: string[] = []
72
+ for (const raw of names) {
73
+ const name = raw.trim()
74
+ if (name === '' || seen.has(name)) continue
75
+ seen.add(name)
76
+ result.push(name)
77
+ }
78
+ return result
79
+ }
80
+
81
+ /**
82
+ * Validate and normalize one declared policy. Empty policies and empty lists
83
+ * are configuration mistakes: an `allow: []` policy would hide even the
84
+ * coordination tools, and a policy with neither list restricts nothing.
85
+ * Denying a required coordination tool is rejected for the same reason.
86
+ * @param id - the policy id, used in error messages.
87
+ * @param policy - the declared policy.
88
+ * @returns the normalized policy (trimmed, de-duplicated, blanks dropped).
89
+ */
90
+ export function normalizeToolPolicy(id: string, policy: MemberToolPolicy): MemberToolPolicy {
91
+ const allow = policy.allow === undefined ? undefined : dedupeToolNames(policy.allow)
92
+ const deny = policy.deny === undefined ? undefined : dedupeToolNames(policy.deny)
93
+ if (allow === undefined && deny === undefined) {
94
+ throw new Error(`tool policy "${id}" must declare "allow" and/or "deny"`)
95
+ }
96
+ if (allow !== undefined && allow.length === 0) {
97
+ throw new Error(`tool policy "${id}" has an empty allow list`)
98
+ }
99
+ if (deny !== undefined && deny.length === 0) {
100
+ throw new Error(`tool policy "${id}" has an empty deny list`)
101
+ }
102
+ const reserved = [...allow ?? [], ...deny ?? []].filter(name => name === RESERVED_TOOL_NAME)
103
+ if (reserved.length > 0) {
104
+ throw new Error(`tool policy "${id}" names the reserved presentation transport "${RESERVED_TOOL_NAME}"`)
105
+ }
106
+ const required = (deny ?? []).filter(name => MEMBER_TOOL_NAMES.includes(name))
107
+ if (required.length > 0) {
108
+ throw new Error(
109
+ `tool policy "${id}" denies required member coordination tool${required.length > 1 ? 's' : ''} ${required.join(', ')}; those tools stay available to every member`,
110
+ )
111
+ }
112
+ return {
113
+ ...allow === undefined ? {} : { allow },
114
+ ...deny === undefined ? {} : { deny },
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Validate every configured policy once, at plugin mount, so a malformed
120
+ * deployment config fails loud instead of at the first member creation.
121
+ * @param raw - the configured `toolPolicies` map.
122
+ * @returns normalized policies keyed by trimmed id.
123
+ */
124
+ export function parseToolPolicies(raw: Record<string, MemberToolPolicy> | undefined | null): Record<string, MemberToolPolicy> {
125
+ // Null-prototype: a policy id is data, so `constructor`, `toString`, or
126
+ // `__proto__` must never resolve through the object prototype.
127
+ const policies: Record<string, MemberToolPolicy> = Object.create(null) as Record<string, MemberToolPolicy>
128
+ for (const [rawId, policy] of Object.entries(raw ?? {})) {
129
+ const id = rawId.trim()
130
+ if (id === '') throw new Error('configured toolPolicies include an empty policy id')
131
+ if (Object.hasOwn(policies, id)) throw new Error(`configured toolPolicies include duplicate policy id "${id}"`)
132
+ policies[id] = normalizeToolPolicy(id, policy)
133
+ }
134
+ return policies
135
+ }
136
+
137
+ /**
138
+ * The policy behind one selected id, or `undefined` when this deployment no
139
+ * longer declares it (a config change after the member was created). Used on
140
+ * paths that must not fail a durable record merely because the owner edited
141
+ * configuration; selection itself uses {@link requireToolPolicy}.
142
+ * @param policies - normalized configured policies.
143
+ * @param id - the selected policy id.
144
+ * @returns the declared policy, or undefined.
145
+ */
146
+ export function optionalToolPolicy(policies: Record<string, MemberToolPolicy>, id: string): MemberToolPolicy | undefined {
147
+ return Object.hasOwn(policies, id) ? policies[id] : undefined
148
+ }
149
+
150
+ /**
151
+ * The deny names one spawn may relax for a member that selected a policy.
152
+ *
153
+ * The built-in captain/depth entries keep the #163/#164 recovery path, but a
154
+ * name the owner explicitly declared in the policy's own `deny` list is never
155
+ * relaxable — even when it is also a built-in entry (`send_message` and
156
+ * `subagent` are depth entries, and every captain-only name is a built-in
157
+ * deny). Dropping such a name would spawn the member under a different policy
158
+ * than the owner declared, which is contract drift rather than recovery.
159
+ * @param policy - the member's selected policy, or undefined when the member
160
+ * selected none (or the id is no longer configured).
161
+ * @param policySelected - whether the member selected a policy at all. A
162
+ * selected id whose policy is no longer configured relaxes nothing, so the
163
+ * member fails loud instead of spawning under an unknown filter.
164
+ * @returns the deny names the lenient retry may drop.
165
+ */
166
+ export function memberSpawnRelaxableDeny(policy: MemberToolPolicy | undefined, policySelected = policy !== undefined): readonly string[] {
167
+ if (!policySelected) return BUILTIN_DENY_TOOLS
168
+ if (policy === undefined) return []
169
+ const ownerDeny = new Set(policy.deny ?? [])
170
+ return BUILTIN_DENY_TOOLS.filter(name => !ownerDeny.has(name))
171
+ }
172
+
173
+ /**
174
+ * The policy behind one selected id. A model-facing selection may only name a
175
+ * policy the deployment owner declared, so an unknown id is an error raised
176
+ * before any member is persisted.
177
+ * @param policies - normalized configured policies.
178
+ * @param id - the selected policy id.
179
+ * @returns the declared policy.
180
+ */
181
+ export function requireToolPolicy(policies: Record<string, MemberToolPolicy>, id: string): MemberToolPolicy {
182
+ // Own-property lookup only: `constructor`, `toString`, and `__proto__` are
183
+ // unknown ids, not accidentally inherited functions.
184
+ const policy = Object.hasOwn(policies, id) ? policies[id] : undefined
185
+ if (policy === undefined) {
186
+ const available = Object.keys(policies).sort()
187
+ throw new Error(
188
+ `unknown tool policy "${id}"${available.length === 0
189
+ ? ' (no toolPolicies are configured in this deployment)'
190
+ : ` (configured: ${available.join(', ')})`}`,
191
+ )
192
+ }
193
+ return policy
194
+ }
195
+
196
+ /**
197
+ * Turn a selected policy (or no policy) into the immutable effective filter.
198
+ *
199
+ * Without `knownTools` the host's delegation names are forwarded verbatim, as
200
+ * before #163: the spawn retry drops whatever the host reports unknown.
201
+ * @param policy - the normalized policy, or undefined for the legacy behavior.
202
+ * @param context - depth cap and the host's restrictable-name view.
203
+ * @returns the effective filter handed to `startContinuable`.
204
+ */
205
+ export function resolveMemberToolFilter(policy: MemberToolPolicy | undefined, context: ToolPolicyContext = {}): MemberToolFilter {
206
+ if (policy !== undefined && policy.allow === undefined && policy.deny === undefined) {
207
+ throw new Error('a tool policy must declare "allow" and/or "deny"')
208
+ }
209
+ const depthDeny = context.maxDepth === 0
210
+ ? DEPTH_DENY_TOOLS.filter(name => context.knownTools === undefined || context.knownTools.has(name))
211
+ : []
212
+ const deny = dedupeToolNames([...(policy?.deny ?? []), ...CAPTAIN_TOOL_NAMES, ...depthDeny])
213
+ if (policy?.allow === undefined) return { deny }
214
+ // A denied name can never be re-admitted: allow and deny intersect in the
215
+ // host, and the snapshot must say the same thing the host will enforce.
216
+ const allow = dedupeToolNames([...policy.allow, ...MEMBER_TOOL_NAMES]).filter(name => !deny.includes(name))
217
+ if (allow.length === 0) throw new Error('a tool policy allow list cannot be empty once captain-only tools are removed')
218
+ return { allow, deny }
219
+ }