@dsh-teamwork/dsh-teamwork 0.6.1 → 0.8.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 (65) hide show
  1. package/README.md +109 -2
  2. package/icon.svg +4 -0
  3. package/lib/aes-gcm.js +22 -0
  4. package/lib/aes-gcm.js.map +1 -0
  5. package/lib/assistant-tools.js +421 -0
  6. package/lib/assistant-tools.js.map +1 -0
  7. package/lib/bridge.js +127 -8
  8. package/lib/bridge.js.map +1 -1
  9. package/lib/cli.js +1 -1
  10. package/lib/cli.js.map +1 -1
  11. package/lib/client.js +206 -18
  12. package/lib/client.js.map +1 -1
  13. package/lib/config-sync.js +2 -1
  14. package/lib/config-sync.js.map +1 -1
  15. package/lib/index.js +187 -73
  16. package/lib/index.js.map +1 -1
  17. package/lib/local-share.js +87 -0
  18. package/lib/local-share.js.map +1 -0
  19. package/lib/panel.js +9 -0
  20. package/lib/panel.js.map +1 -1
  21. package/lib/phone-security.js +283 -0
  22. package/lib/phone-security.js.map +1 -0
  23. package/lib/phone-session.js +20 -0
  24. package/lib/phone-session.js.map +1 -0
  25. package/lib/phone-uploads.js +136 -0
  26. package/lib/phone-uploads.js.map +1 -0
  27. package/lib/platform-models.js +2 -2
  28. package/lib/platform-models.js.map +1 -1
  29. package/lib/preset-context.js +1 -1
  30. package/lib/preset-context.js.map +1 -1
  31. package/lib/relay.js +9 -4
  32. package/lib/relay.js.map +1 -1
  33. package/lib/secure-channel.js +398 -0
  34. package/lib/secure-channel.js.map +1 -0
  35. package/lib/types/aes-gcm.d.ts +3 -0
  36. package/lib/types/aes-gcm.d.ts.map +1 -0
  37. package/lib/types/assistant-tools.d.ts +7 -0
  38. package/lib/types/assistant-tools.d.ts.map +1 -0
  39. package/lib/types/bridge.d.ts +5 -0
  40. package/lib/types/bridge.d.ts.map +1 -1
  41. package/lib/types/client.d.ts +432 -195
  42. package/lib/types/client.d.ts.map +1 -1
  43. package/lib/types/config-sync.d.ts +1 -1
  44. package/lib/types/config-sync.d.ts.map +1 -1
  45. package/lib/types/index.d.ts.map +1 -1
  46. package/lib/types/local-share.d.ts +11 -0
  47. package/lib/types/local-share.d.ts.map +1 -0
  48. package/lib/types/panel.d.ts +39 -5
  49. package/lib/types/panel.d.ts.map +1 -1
  50. package/lib/types/phone-security.d.ts +59 -0
  51. package/lib/types/phone-security.d.ts.map +1 -0
  52. package/lib/types/phone-session.d.ts +52 -0
  53. package/lib/types/phone-session.d.ts.map +1 -0
  54. package/lib/types/phone-uploads.d.ts +75 -0
  55. package/lib/types/phone-uploads.d.ts.map +1 -0
  56. package/lib/types/platform-models.d.ts.map +1 -1
  57. package/lib/types/preset-context.d.ts +2 -0
  58. package/lib/types/preset-context.d.ts.map +1 -1
  59. package/lib/types/preset-session.d.ts +1 -1
  60. package/lib/types/relay.d.ts +10 -2
  61. package/lib/types/relay.d.ts.map +1 -1
  62. package/lib/types/secure-channel.d.ts +79 -0
  63. package/lib/types/secure-channel.d.ts.map +1 -0
  64. package/lib/web/client.js +850 -269
  65. package/package.json +11 -2
package/README.md CHANGED
@@ -39,13 +39,18 @@ pnpm typecheck
39
39
  DSH web 和桌面端的左侧栏有 Teamwork 入口,打开后是主区域的 Teamwork 面板:
40
40
 
41
41
  - 未登录:点“在浏览器中登录”,在网页上确认授权,面板随即自动完成登录。插件在本机 `127.0.0.1` 的一个临时端口上等授权码,最多等十分钟,兑换成功后立即关闭;浏览器和 DSH 不在同一台机器时,把网页上显示的那一行粘贴到面板里。页面底部显示当前服务器,可以改成自建或本地地址,或恢复默认;服务器只接受 https,本机地址可以用 http。更改服务器会退出当前登录并清除旧服务器的团队配置。
42
- - 顶栏:团队名和身份、当前服务器、同步状态、立即同步、退出;管理员多一个跳到网页 `/team` 的"管理团队"。管理团队只在网页完成。
42
+ - 顶栏:图标右侧为“我的团队 > 当前团队”,手机连接、我的账号在右。Teamwork 名称、服务器、本机信息、同步状态和刷新位于底部贴边的状态栏,内容单独滚动。手机连接独立于团队资源;配对授权整台 DSH 可访问的会话,目前不能只授权某个团队。
43
+ - 团队资源:使用顶栏的自定义下拉框切换团队,预设、模型和插件均标注所属团队。多团队首次登录先选择浏览范围,之后按服务器与账号记住选择;筛选不会改变已有会话或手机授权。发布配置和管理成员仍在网页完成。
44
+ - 我的账号:显示名称、邮箱与账号语言,通过宿主接口读取和保存个人资料。可更换服务器或确认退出;令牌不会发给浏览器,重启 DSH 仍需重新授权。
45
+ - 个人资料的未保存草稿会在切换页面时保留,可撤销修改;保存失败保留输入并提供重试。手机操作期间阻止重复提交,解除配对失败保留确认;配对码过期可重新生成,“收起配对码”仅隐藏展示,不会提前使服务器上的码失效。
43
46
  - 预设:每个预设的模型、就绪状态(必需工具、依赖插件),"用于当前会话"(仅限尚未开始对话的会话)和"新建会话"。
44
47
  - 团队模型:用于当前会话,只改本会话,不改本地默认设置。
45
48
  - 团队插件:固定版本的状态;安装前在面板里确认,确认绑定当时的精确版本。
46
49
 
47
50
  面板通过宿主端的 `/api/teamwork/*` 路由(`src/panel.ts`)工作,与 `/teamwork` 命令调用同一组函数;平台令牌只留在宿主进程里,不会发到浏览器。DSH 只允许本机所有者访问这些路由。会话恢复相关的子命令(`session`、`continue`、`cancel`、`retry`)只保留为命令。
48
51
 
52
+ 面板读取的是宿主已同步的配置,每次状态请求只扫描一次本机插件清单,供所有预设复用;没有插件依赖或团队插件时不扫描。清单不跨请求缓存,下一次刷新会重新检查插件状态。状态轮询在上一次请求结束后再计时,刷新失败保留已有内容。
53
+
49
54
  ## 命令
50
55
 
51
56
  在 DSH 原生命令输入框中使用:
@@ -66,7 +71,7 @@ DSH web 和桌面端的左侧栏有 Teamwork 入口,打开后是主区域的 T
66
71
 
67
72
  团队提示词作为独立 scoped section 追加,按字面文本处理,不替换本地 persona,也不解释 `{{...}}` 模板。
68
73
 
69
- 团队注册 ID 以 `team:<teamId>:<configId>` 命名。插件只释放自己持有的注册,不枚举或删除本地配置。已运行会话可能继续持有旧的 DSH 预设版本;更新后的版本用于新选择或新会话。用户确认安装的插件不会因为退出团队而被自动卸载。
74
+ 团队注册 ID 以 `team:<teamId>:<configId>` 命名,显示名是 `[团队名] 预设名`;团队改名后会重新注册。预设引用的模型和插件只在它自己的团队里查找,不跨团队。插件只释放自己持有的注册,不枚举或删除本地配置。已运行会话可能继续持有旧的 DSH 预设版本;更新后的版本用于新选择或新会话。用户确认安装的插件不会因为退出团队而被自动卸载。
70
75
 
71
76
  也可以用 `TEAMWORK_URL=... TEAMWORK_CACHE=... pnpm cli` 运行交互式同步客户端。CLI 写入缓存后,需要重新加载 DSH 插件;优先使用宿主中的 `/teamwork` 命令。
72
77
 
@@ -151,3 +156,105 @@ DSH_CLI=/tmp/dsh-test-runtime/node_modules/@deepseek-ai/dsh/lib/bin.js pnpm test
151
156
  ## 许可证
152
157
 
153
158
  Apache License 2.0(`LICENSE`)。名称“DSH Teamwork”和鲸鱼标志不随代码授权(`NOTICE`),派生项目需使用自己的名称和标志。
159
+
160
+ ## Phone session configuration
161
+
162
+ Paired phones may choose an existing session folder and a registered native
163
+ preset when creating a session. The bridge provides two narrowly scoped calls:
164
+ `teamwork/configuration` reports the desktop's preset roster, team versions,
165
+ dependency states and current session configuration; `teamwork/selectModel`
166
+ changes a catalog model and optional advertised reasoning effort on an idle
167
+ session. Native `session/selectModel` is no longer allowed for phones because
168
+ it also saves the desktop default. Session-specific operations first pass the
169
+ native admission check under the pairing's identity. Before forwarding a prompt,
170
+ the bridge uses the same team, preset-version, plugin and tool readiness checks
171
+ as local actions, returning a bounded `teamwork/` error code on refusal.
172
+
173
+ The relay envelope is unchanged. Rebuild the plugin and mobile app together for
174
+ these settings. This grants no new team permissions and exposes no credentials;
175
+ phones remain paired to the same account's own DSH, across teams. The desktop
176
+ pairing confirmation states this scope explicitly.
177
+
178
+ ## Verified phone encryption
179
+
180
+ The phone and desktop authenticate each other with pinned Ed25519 device
181
+ identities over libp2p Noise XX. A six-letter, single-use code locates the
182
+ computer; initial pairing requires comparing the eight-digit safety code on
183
+ both screens, confirming on the phone, then approving on the desktop. A QR link
184
+ also pins the desktop public key. Later connections use fresh handshakes and
185
+ saved keys. Missing or changed keys require pairing again, with no plaintext
186
+ fallback. Existing plaintext pairings must be replaced.
187
+
188
+ After authentication, each endpoint sends a fresh independent AES-256 sending
189
+ key inside Noise. Messages and uploads then bypass Noise and use native
190
+ AES-256-GCM: Node/OpenSSL on desktop and Expo Crypto on mobile. Each opaque
191
+ `data` record authenticates its channel, sending direction and monotonic counter;
192
+ replay, reordering, cipher failure or exhausted key budgets close the channel.
193
+ The small Noise handshake remains JS; application payloads have no JS cipher
194
+ fallback. Upgrade relay and both clients together. Saved verified device keys
195
+ remain valid across this transport change.
196
+
197
+ `src/secure-channel.ts` owns the wire and has an identical mobile copy checked
198
+ by integration tests. `src/phone-security.ts` gates every bridge request on a
199
+ locally saved device roster. The identity seed and account/server-scoped peers
200
+ are atomically saved in `<cache>.phone-keys.json` with restrictive permissions.
201
+ Desktop revocation closes the channel and saves trust removal before calling
202
+ the relay. Phone revocation requires an encrypted desktop acknowledgement; an
203
+ offline desktop must reconnect before it completes.
204
+
205
+ The relay can see public keys, account/device metadata, timing and sizes, but
206
+ cannot read encrypted methods, conversation content, tool data or uploads.
207
+ Generic notifications omit session ids and question types. Local DSH storage
208
+ and the hosted team-model gateway remain separate boundaries: model context
209
+ still passes through that gateway. Update relay, plugin and mobile together.
210
+
211
+ ## Phone file attachments
212
+
213
+ Phones query upload limits through `teamwork/configuration`, then use four
214
+ allow-listed calls: `teamwork/uploadStart`, `teamwork/uploadChunk`,
215
+ `teamwork/uploadFinish` and `teamwork/uploadCancel`. Intake passes native
216
+ session admission. Files can be staged while the agent is busy or the model
217
+ is unavailable; readiness is enforced on a new prompt, not on file transfer.
218
+ Phones transfer selected files immediately and submit completed receipts only
219
+ when the member presses Send. Transfer ids and completed receipts are bound to
220
+ the pairing and exact session, and chunks stream with backpressure
221
+ to DSH's authenticated binary upload service. The relay envelope is unchanged.
222
+
223
+ The initial budgets are five files per message, 20 MiB per file, 50 MiB total,
224
+ 256 KiB raw chunks, one active transfer per pairing and two per host. Transfers
225
+ expire after 60 seconds idle or five minutes total; completed plugin receipts
226
+ expire after ten minutes. Detach, revocation and cancellation release transfer
227
+ state. The plugin does not delete DSH's stored objects or workspace files.
228
+
229
+ Prompts use native file receipts and stable request ids. An already-accepted
230
+ request may reach native deduplication before the busy/readiness check; new
231
+ work still passes all checks and validates its receipt metadata. This slice
232
+ supports ordinary files, not image input or document extraction. Update the
233
+ mobile app and plugin together. Build output under `lib/` is included.
234
+
235
+ 预算由所选团队的服务端计算,插件底栏异步显示当前成员的积分剩余、Token 限额或待核实状态。切换资源团队不会改变正在使用的会话模型;模型和上游的其他限制仍由网关在请求时检查。读取失败显示“预算暂不可用”,不影响配置列表和同步。
236
+
237
+
238
+ ## Team assistant and reviewed sharing
239
+
240
+ New teams receive a built-in assistant that can inherit a local/session model.
241
+ The assistant's tools bind operations to its active team, reuse server permissions,
242
+ and require real host approval for mutations. They cover sync, configuration,
243
+ usage/budgets, preset submissions, local plugin preparation/upload, review and
244
+ historical restoration. Provider keys and account passwords use secure console forms.
245
+
246
+ Members can submit new or updated presets/plugins on the platform's sharing page;
247
+ administrators approve frozen revisions. Publication does not install a plugin.
248
+ Private archives are downloaded through host authentication, verified by SHA-256,
249
+ and installed disabled before the normal conflict checks and activation. Existing
250
+ local installations remain protected; upgrades use the local plugin manager.
251
+
252
+ Pinned preset dependencies survive catalog updates through historical plugin
253
+ metadata. Use `/teamwork install <configId>@<version>` for an exact retained pin.
254
+ The platform's history page supports comparison, backup export and restoration
255
+ as a new reviewed publication. Existing conversations retain their preset version.
256
+
257
+ Run `pnpm test:assistant` with `DSH_CLI` set as in the host-test instructions.
258
+ It verifies model inheritance, team-bound tools, denied approval, authenticated
259
+ archive download and real local-archive installation. Host tests isolate their
260
+ package stores so an earlier fixture cannot satisfy the download check.
package/icon.svg ADDED
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 400 400">
2
+ <rect width="400" height="400" fill="#1E2F6D"/>
3
+ <path fill="#F8F5EF" d="M206.84 178.37L203.20 176.51L197.50 174.07L191.54 172.04L185.35 170.41L178.93 169.17L172.31 168.32L165.50 167.86L158.53 167.77L151.41 168.06L144.16 168.72L136.80 169.75L129.35 171.13L121.82 172.87L114.23 174.96L109.15 176.54L98.77 180.09L95.30 181.17L90.18 182.60L86.83 183.42L81.88 184.48L77.03 185.31L72.29 185.93L67.65 186.34L61.63 186.57L57.23 186.50L51.52 186.10L47.35 185.57L41.96 184.58L36.75 183.26L31.71 181.62L34.49 185.76L37.47 189.81L40.64 193.76L44.00 197.60L47.54 201.33L51.26 204.95L55.15 208.44L59.21 211.81L63.44 215.04L67.84 218.14L72.39 221.10L77.09 223.91L81.95 226.57L86.95 229.08L94.72 232.53L102.79 235.59L111.15 238.26L119.80 240.51L125.70 241.78L134.78 243.30L140.96 244.06L144.09 244.36L173.55 246.46L180.99 247.20L187.94 248.12L194.39 249.29L200.32 250.79L203.07 251.68L205.68 252.68L209.32 254.39L212.63 256.39L215.59 258.72L218.18 261.38L219.71 263.37L223.20 305.34L228.75 306.83L233.12 307.74L237.50 308.33L241.25 308.55L245.00 308.50L249.38 308.10L253.75 307.35L258.75 306.16L268.56 303.21L246.40 256.22L246.73 253.74L247.28 251.31L248.06 248.95L249.61 245.50L250.90 243.25L252.39 241.04L254.06 238.85L255.91 236.70L257.94 234.56L260.13 232.43L264.98 228.19L270.41 223.93L277.92 218.50L302.38 201.94L304.94 200.12L309.92 196.37L317.01 190.52L321.49 186.47L327.85 180.20L333.75 173.71L339.20 167.02L344.20 160.15L347.28 155.48L350.15 150.75L352.81 145.96L355.27 141.12L357.52 136.24L359.57 131.33L361.40 126.38L363.02 121.41L364.43 116.42L365.63 111.42L366.61 106.41L367.38 101.41L367.94 96.41L368.27 91.43L364.74 95.37L360.88 99.12L356.71 102.68L353.38 105.22L348.64 108.41L344.87 110.67L339.54 113.49L335.33 115.45L330.91 117.29L326.31 118.98L321.50 120.54L318.18 121.50L313.04 122.82L309.49 123.63L298.73 125.74L293.54 126.91L285.93 128.90L278.54 131.16L271.39 133.69L264.50 136.48L257.89 139.53L253.65 141.71L249.55 144.00L245.59 146.40L239.93 150.20L236.35 152.87L232.93 155.65L228.12 160.01L225.13 163.04L222.32 166.18L218.46 171.06L215.04 176.17L212.07 181.49ZM0.00 299.31L6.29 300.81L19.95 304.97L27.09 306.81L30.85 307.55L34.71 308.11L38.64 308.45L42.44 308.56L45.78 308.48L49.55 308.17L52.80 307.74L56.57 307.06L60.13 306.25L63.75 305.29L76.43 301.42L80.87 300.19L85.96 299.11L90.20 298.63L92.48 298.57L95.22 298.67L97.56 298.92L100.48 299.40L106.29 300.81L119.95 304.97L126.98 306.78L130.85 307.55L134.55 308.09L137.85 308.40L141.64 308.56L145.61 308.49L149.55 308.17L153.42 307.64L157.20 306.93L160.85 306.07L164.44 305.10L179.80 300.47L183.48 299.58L186.92 298.96L190.65 298.61L194.30 298.61L198.04 298.98L202.57 299.84L194.87 271.11L192.61 271.07L189.26 271.14L185.49 271.44L182.24 271.86L178.58 272.51L174.89 273.34L171.27 274.29L157.98 278.34L153.04 279.67L149.99 280.33L147.56 280.72L144.76 280.99L142.48 281.06L140.20 281.00L137.40 280.73L134.98 280.35L131.93 279.70L127.00 278.38L113.68 274.32L109.51 273.23L105.83 272.42L102.03 271.77L98.93 271.39L95.61 271.14L92.44 271.07L88.64 271.18L84.71 271.52L80.85 272.08L77.09 272.82L69.95 274.66L55.73 278.98L49.99 280.33L47.09 280.78L44.76 280.99L42.48 281.06L39.73 280.97L35.96 280.52L31.93 279.70L27.57 278.54L16.42 275.11L10.94 273.58L5.08 272.28L0.00 271.51ZM284.83 299.31L289.73 298.66L292.48 298.57L295.69 298.71L299.01 299.13L302.00 299.72L305.73 300.65L319.95 304.97L327.09 306.81L330.85 307.55L334.71 308.11L338.64 308.45L342.44 308.56L345.78 308.48L349.71 308.16L353.42 307.64L357.31 306.90L364.44 305.10L379.25 300.61L382.97 299.69L385.96 299.11L389.73 298.66L392.93 298.57L396.15 298.75L400.00 299.31L400.00 271.51L395.61 271.14L390.85 271.08L386.27 271.36L381.47 271.98L377.09 272.82L372.66 273.91L367.92 275.26L357.41 278.50L352.52 279.80L347.56 280.72L345.22 280.96L342.93 281.06L340.65 281.02L338.34 280.84L335.96 280.52L332.97 279.94L327.57 278.54L316.46 275.13L311.57 273.75L306.45 272.55L301.11 271.64L297.98 271.30L294.99 271.12L289.43 271.13L283.78 271.64L277.70 272.69Z"/>
4
+ </svg>
package/lib/aes-gcm.js ADDED
@@ -0,0 +1,22 @@
1
+ /** Native OpenSSL AES-256-GCM; wire records contain ciphertext followed by the 16-byte tag. */
2
+ import { createCipheriv, createDecipheriv, createSecretKey } from 'node:crypto';
3
+ export async function importAesKey(bytes) {
4
+ if (bytes.length !== 32)
5
+ throw new Error('invalid_aes_key');
6
+ const key = createSecretKey(bytes);
7
+ return {
8
+ async encrypt(plaintext, nonce, additionalData) {
9
+ const cipher = createCipheriv('aes-256-gcm', key, nonce, { authTagLength: 16 });
10
+ cipher.setAAD(additionalData);
11
+ return new Uint8Array(Buffer.concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()]));
12
+ },
13
+ async decrypt(ciphertext, nonce, additionalData) {
14
+ const decipher = createDecipheriv('aes-256-gcm', key, nonce, { authTagLength: 16 });
15
+ decipher.setAAD(additionalData);
16
+ decipher.setAuthTag(ciphertext.subarray(-16));
17
+ // Never expose update()'s plaintext before final() authenticates the tag.
18
+ return new Uint8Array(Buffer.concat([decipher.update(ciphertext.subarray(0, -16)), decipher.final()]));
19
+ },
20
+ };
21
+ }
22
+ //# sourceMappingURL=aes-gcm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aes-gcm.js","sourceRoot":"","sources":["../src/aes-gcm.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,OAAO,EAAE,cAAc,EAAE,gB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AAC"}
@@ -0,0 +1,421 @@
1
+ import { readFile, rm } from 'node:fs/promises';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { preparePlugin } from './local-share.js';
4
+ import { z } from 'zod';
5
+ const filters = z
6
+ .object({
7
+ configId: z.string().optional(),
8
+ userId: z.string().optional(),
9
+ authorId: z.string().optional(),
10
+ from: z.string().optional(),
11
+ to: z.string().optional(),
12
+ kind: z.string().optional(),
13
+ offset: z.string().optional(),
14
+ page: z.string().optional(),
15
+ size: z.string().optional(),
16
+ })
17
+ .strict();
18
+ const query = z
19
+ .object({
20
+ filters: filters.optional(),
21
+ action: z.enum([
22
+ 'status',
23
+ 'sync',
24
+ 'configs',
25
+ 'usage',
26
+ 'budgets',
27
+ 'members',
28
+ 'submissions',
29
+ 'history',
30
+ 'providers',
31
+ ]),
32
+ })
33
+ .strict();
34
+ /** The server is authoritative for access; the active preset fixes the destination. */
35
+ export function registerAssistantTools(ctx, client, preset, sync, install) {
36
+ const bindings = new Map();
37
+ const previews = new Map();
38
+ const writes = new Set([
39
+ 'teamwork_prepare_plugin',
40
+ 'teamwork_share_plugin',
41
+ 'teamwork_share_preset',
42
+ 'teamwork_review',
43
+ 'teamwork_manage',
44
+ 'teamwork_export_usage',
45
+ 'teamwork_new_session',
46
+ 'teamwork_install',
47
+ ]);
48
+ ctx.on('tools/pre-execute', async (exec, next) => {
49
+ if (!writes.has(exec.name))
50
+ return next();
51
+ const policy = await next();
52
+ if (policy.kind === 'deny' || policy.kind === 'cancel')
53
+ return policy;
54
+ const bound = exec.agent && preset(exec.agent);
55
+ if (!bound)
56
+ return { kind: 'deny', reason: 'A team-bound preset is required' };
57
+ bindings.set(exec.token, {
58
+ epoch: client.sessionRevision(),
59
+ teamId: bound.teamId,
60
+ presetId: bound.id,
61
+ version: bound.version,
62
+ });
63
+ let preview = '';
64
+ if (exec.name === 'teamwork_share_plugin') {
65
+ const args = z.object({ previewId: z.string() }).passthrough().parse(exec.arguments);
66
+ const saved = previews.get(args.previewId);
67
+ if (!saved ||
68
+ saved.agentId !== String(exec.agent?.id) ||
69
+ saved.teamId !== bound.teamId ||
70
+ saved.epoch !== client.sessionRevision())
71
+ return { kind: 'deny', reason: 'Prepared package is unavailable' };
72
+ preview = JSON.stringify({
73
+ package: saved.plugin.package,
74
+ version: saved.plugin.version,
75
+ sha256: saved.plugin.sha256,
76
+ size: saved.plugin.size,
77
+ files: saved.plugin.files,
78
+ });
79
+ }
80
+ if (exec.name === 'teamwork_review') {
81
+ const args = z
82
+ .object({ id: z.string(), revision: z.number() })
83
+ .passthrough()
84
+ .parse(exec.arguments);
85
+ const current = await client.reviewPreview(bound.teamId, args.id, exec.signal);
86
+ if (current.revision !== args.revision)
87
+ return {
88
+ kind: 'deny',
89
+ reason: 'Submission revision changed. Read the current proposal.',
90
+ };
91
+ preview = JSON.stringify(current);
92
+ }
93
+ return {
94
+ kind: 'ask',
95
+ reason: `Team ${bound.teamId}: review the exact ${exec.name} arguments before permitting this operation. ${preview}`,
96
+ };
97
+ });
98
+ ctx.on('tools/result', (exec) => {
99
+ bindings.delete(exec.token);
100
+ });
101
+ ctx.effect(() => async () => {
102
+ await Promise.all([...previews.values()].map((preview) => rm(preview.plugin.directory, { recursive: true, force: true })));
103
+ previews.clear();
104
+ bindings.clear();
105
+ });
106
+ const output = {
107
+ schema: { type: 'object', additionalProperties: true },
108
+ render: (_args, value) => [
109
+ { type: 'text', text: JSON.stringify(value) },
110
+ ],
111
+ };
112
+ const add = (name, description, schema, execute) => {
113
+ ctx.effect(() => ctx.tools.register({
114
+ name,
115
+ description,
116
+ parameters: schema,
117
+ output,
118
+ async execute(input, exec) {
119
+ const bound = exec.agent && preset(exec.agent), binding = bindings.get(exec.token);
120
+ if (!exec.agent ||
121
+ !bound ||
122
+ !binding ||
123
+ binding.epoch !== client.sessionRevision() ||
124
+ binding.teamId !== bound.teamId ||
125
+ binding.presetId !== bound.id ||
126
+ binding.version !== bound.version)
127
+ throw Error('Approval expired because the account or team preset changed');
128
+ return execute(input, exec.agent, exec.signal, bound.teamId);
129
+ },
130
+ }, { when: ({ agent }) => !!preset(agent) }));
131
+ };
132
+ add('teamwork_prepare_plugin', 'Prepare a local plugin inside this session workspace without executing lifecycle scripts. Returns the exact archive file list and digest; does not upload. Requires host permission.', {
133
+ type: 'object',
134
+ properties: { directory: { type: 'string' } },
135
+ required: ['directory'],
136
+ additionalProperties: false,
137
+ }, async (input, agent, signal, teamId) => {
138
+ const { directory } = z
139
+ .object({ directory: z.string().min(1) })
140
+ .strict()
141
+ .parse(input);
142
+ if (previews.size >= 20)
143
+ throw Error('Too many prepared packages; restart the plugin to discard old preparations');
144
+ const epoch = client.sessionRevision();
145
+ const cwd = agent.session.header.cwd;
146
+ if (!cwd)
147
+ throw Error('Session workspace is unavailable');
148
+ const plugin = await preparePlugin(cwd, directory, signal);
149
+ if (epoch !== client.sessionRevision() || preset(agent)?.teamId !== teamId) {
150
+ await rm(plugin.directory, { recursive: true, force: true });
151
+ throw Error('Account or team changed during preparation');
152
+ }
153
+ const previewId = randomUUID();
154
+ previews.set(previewId, { plugin, agentId: String(agent.id), epoch, teamId });
155
+ return {
156
+ previewId,
157
+ teamId,
158
+ package: plugin.package,
159
+ version: plugin.version,
160
+ sha256: plugin.sha256,
161
+ size: plugin.size,
162
+ files: plugin.files,
163
+ uploaded: false,
164
+ };
165
+ });
166
+ add('teamwork_share_plugin', 'Upload a previously prepared plugin and submit it for administrator review. Show its exact preview to the user first. A configId/baseVersion updates an existing team plugin. This does not publish or install.', {
167
+ type: 'object',
168
+ properties: {
169
+ previewId: { type: 'string' },
170
+ name: { type: 'string' },
171
+ note: { type: 'string' },
172
+ configId: { type: 'string' },
173
+ baseVersion: { type: 'integer', minimum: 0 },
174
+ },
175
+ required: ['previewId', 'name', 'note', 'baseVersion'],
176
+ additionalProperties: false,
177
+ }, async (input, agent, signal, teamId) => {
178
+ const data = z
179
+ .object({
180
+ previewId: z.string(),
181
+ name: z.string().min(1).max(120),
182
+ note: z.string().max(2000),
183
+ configId: z.string().max(32).optional(),
184
+ baseVersion: z.number().int().min(0),
185
+ })
186
+ .strict()
187
+ .parse(input);
188
+ const saved = previews.get(data.previewId);
189
+ if (!saved ||
190
+ saved.agentId !== String(agent.id) ||
191
+ saved.epoch !== client.sessionRevision() ||
192
+ saved.teamId !== teamId)
193
+ throw Error('Prepared archive is unavailable for this session');
194
+ const bytes = await readFile(saved.plugin.path);
195
+ const result = await client.submitPlugin(teamId, bytes, saved.plugin.sha256, {
196
+ name: data.name,
197
+ note: data.note,
198
+ configId: data.configId,
199
+ baseVersion: data.baseVersion,
200
+ }, signal);
201
+ previews.delete(data.previewId);
202
+ await rm(saved.plugin.directory, { recursive: true, force: true });
203
+ return { teamId, result, published: false };
204
+ });
205
+ add('teamwork_share_preset', 'Submit the exact proposed preset for administrator review. Use configId and baseVersion for updates. This does not publish. Remove local paths and secrets and map dependencies to this team before submission.', {
206
+ type: 'object',
207
+ properties: {
208
+ config: { type: 'object' },
209
+ configId: { type: 'string' },
210
+ baseVersion: { type: 'integer', minimum: 0 },
211
+ note: { type: 'string' },
212
+ },
213
+ required: ['config', 'baseVersion', 'note'],
214
+ additionalProperties: false,
215
+ }, async (input, _agent, signal, teamId) => {
216
+ const data = z
217
+ .object({
218
+ config: z
219
+ .object({
220
+ kind: z.literal('preset'),
221
+ name: z.string().min(1).max(120),
222
+ data: z.record(z.string(), z.unknown()),
223
+ })
224
+ .strict(),
225
+ configId: z.string().max(32).optional(),
226
+ baseVersion: z.number().int().min(0),
227
+ note: z.string().max(2000),
228
+ })
229
+ .strict()
230
+ .parse(input);
231
+ if (/-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----|sk-[A-Za-z0-9_-]{20,}/.test(JSON.stringify(data.config)))
232
+ throw Error('Remove potential credentials before sharing');
233
+ const draft = z
234
+ .object({ id: z.string(), revision: z.number() })
235
+ .parse(await client.assistantChange(teamId, 'saveDraft', data, signal));
236
+ const result = await client.assistantChange(teamId, 'submit', draft, signal);
237
+ return { teamId, result, published: false };
238
+ });
239
+ add('teamwork_review', 'Submit or withdraw your proposal, or explicitly approve/reject as a team administrator. Inspect current submission contents and revision first. Host confirmation is always required; a model flag cannot approve.', {
240
+ type: 'object',
241
+ properties: {
242
+ action: { type: 'string', enum: ['submit', 'withdraw', 'approve', 'reject'] },
243
+ id: { type: 'string' },
244
+ revision: { type: 'integer', minimum: 1 },
245
+ reason: { type: 'string' },
246
+ },
247
+ required: ['action', 'id', 'revision'],
248
+ additionalProperties: false,
249
+ }, async (input, _agent, signal, teamId) => {
250
+ const data = z
251
+ .object({
252
+ action: z.enum(['submit', 'withdraw', 'approve', 'reject']),
253
+ id: z.string().min(1).max(32),
254
+ revision: z.number().int().positive(),
255
+ reason: z.string().max(2000).optional(),
256
+ })
257
+ .strict()
258
+ .parse(input);
259
+ const { action, ...body } = data;
260
+ return { teamId, result: await client.assistantChange(teamId, action, body, signal) };
261
+ });
262
+ add('teamwork_manage', 'Administrator operations on the bound team: create/update/delete configuration, revision-checked budget changes, remove a member, or prepare a historical restore. editDraft edits an owned draft. Query current state first; show the complete proposed change. Provider key entry and account creation with passwords must use secure console forms.', {
263
+ type: 'object',
264
+ properties: {
265
+ action: {
266
+ type: 'string',
267
+ enum: [
268
+ 'createConfig',
269
+ 'updateConfig',
270
+ 'deleteConfig',
271
+ 'setBudget',
272
+ 'removeMember',
273
+ 'restore',
274
+ 'editDraft',
275
+ ],
276
+ },
277
+ input: { type: 'object' },
278
+ },
279
+ required: ['action', 'input'],
280
+ additionalProperties: false,
281
+ }, async (input, _agent, signal, teamId) => {
282
+ const data = z
283
+ .object({
284
+ action: z.enum([
285
+ 'createConfig',
286
+ 'updateConfig',
287
+ 'deleteConfig',
288
+ 'setBudget',
289
+ 'removeMember',
290
+ 'restore',
291
+ 'editDraft',
292
+ ]),
293
+ input: z.record(z.string(), z.unknown()),
294
+ })
295
+ .strict()
296
+ .parse(input);
297
+ if (['updateConfig', 'deleteConfig', 'removeMember', 'restore', 'editDraft'].includes(data.action) &&
298
+ !z
299
+ .string()
300
+ .regex(/^[A-Za-z0-9_-]{1,32}$/)
301
+ .safeParse(data.input.id).success)
302
+ throw Error('An exact resource id is required');
303
+ if (data.action === 'setBudget' && !('revision' in data.input))
304
+ throw Error('Read the current budget revision first');
305
+ return {
306
+ teamId,
307
+ result: await client.assistantChange(teamId, data.action, data.input, signal),
308
+ };
309
+ });
310
+ add('teamwork_export_usage', 'Export authorized usage to a private local CSV file. Members export only their own allowed usage; administrators can filter by member/model/time.', {
311
+ type: 'object',
312
+ properties: { filters: { type: 'object', additionalProperties: { type: 'string' } } },
313
+ additionalProperties: false,
314
+ }, async (input, _agent, signal, teamId) => {
315
+ const data = z.object({ filters: filters.optional() }).strict().parse(input);
316
+ return {
317
+ teamId,
318
+ path: await client.exportUsage(teamId, data.filters ?? {}, signal),
319
+ };
320
+ });
321
+ add('teamwork_new_session', 'Create a new session from a preset of the bound team. Does not start a task or change the existing conversation.', {
322
+ type: 'object',
323
+ properties: { id: { type: 'string' } },
324
+ required: ['id'],
325
+ additionalProperties: false,
326
+ }, async (input, agent, signal, teamId) => {
327
+ const { id } = z
328
+ .object({ id: z.string().regex(/^[A-Za-z0-9_-]{1,32}$/) })
329
+ .strict()
330
+ .parse(input);
331
+ if (!client
332
+ .current()
333
+ ?.teams.find((t) => t.teamId === teamId)
334
+ ?.configs.some((c) => c.id === id && c.kind === 'preset'))
335
+ throw Error('Choose a preset in this team');
336
+ const commands = ctx.get('commands');
337
+ if (!commands)
338
+ throw Error('Host command service is unavailable');
339
+ const result = await commands.execute(agent, `/teamwork new ${id}`, [], signal);
340
+ if (!result)
341
+ throw Error('Host did not handle session creation');
342
+ if (result.result.kind === 'error')
343
+ throw Error(result.result.text);
344
+ return { teamId, result: result.result };
345
+ });
346
+ add('teamwork_install', 'Install and enable an exact published team plugin after explicit host approval. This changes the local DSH profile for all sessions and may execute plugin code. Existing local plugins are protected; upgrades use the local plugin manager.', {
347
+ type: 'object',
348
+ properties: { id: { type: 'string' }, version: { type: 'string' } },
349
+ required: ['id', 'version'],
350
+ additionalProperties: false,
351
+ }, async (input, _agent, _signal, teamId) => {
352
+ const { id, version } = z
353
+ .object({
354
+ id: z.string().regex(/^[A-Za-z0-9_-]{1,32}$/),
355
+ version: z.string().regex(/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/),
356
+ })
357
+ .strict()
358
+ .parse(input);
359
+ const team = client.current()?.teams.find((t) => t.teamId === teamId);
360
+ if (!team?.configs.some((c) => c.id === id && c.kind === 'plugin') &&
361
+ !team?.pluginVersions?.some((c) => c.configId === id))
362
+ throw Error('Choose a plugin in this team');
363
+ return { teamId, result: await install(id, version) };
364
+ });
365
+ ctx.effect(() => ctx.tools.register({
366
+ name: 'teamwork_query',
367
+ description: 'Inspect the team bound to this preset: status, configuration, personal usage, applicable budgets or members. Administrators receive their permitted team usage. Sync refreshes team configuration. Unknown usage is not zero.',
368
+ parameters: {
369
+ type: 'object',
370
+ properties: {
371
+ action: {
372
+ type: 'string',
373
+ enum: [
374
+ 'status',
375
+ 'sync',
376
+ 'configs',
377
+ 'usage',
378
+ 'budgets',
379
+ 'members',
380
+ 'submissions',
381
+ 'history',
382
+ 'providers',
383
+ ],
384
+ },
385
+ filters: { type: 'object', additionalProperties: { type: 'string' } },
386
+ },
387
+ required: ['action'],
388
+ additionalProperties: false,
389
+ },
390
+ output: {
391
+ schema: { type: 'object', additionalProperties: true },
392
+ render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }],
393
+ },
394
+ async execute(input, exec) {
395
+ const { action, filters: requestedFilters } = query.parse(input);
396
+ if (!exec.agent)
397
+ throw new Error('A team-bound session is required');
398
+ const bound = preset(exec.agent);
399
+ if (!bound)
400
+ throw new Error('A team-bound preset is required');
401
+ const epoch = client.sessionRevision(), teamId = bound.teamId;
402
+ if (action === 'status')
403
+ return {
404
+ teamId,
405
+ authenticated: client.authenticated(),
406
+ team: client.current()?.teams.find((t) => t.teamId === teamId)?.teamName ?? null,
407
+ };
408
+ if (action === 'sync') {
409
+ await sync();
410
+ if (epoch !== client.sessionRevision() || preset(exec.agent)?.teamId !== teamId)
411
+ throw new Error('Session changed during sync');
412
+ return { teamId, synced: true };
413
+ }
414
+ const result = await client.assistantRead(teamId, action, exec.signal, requestedFilters);
415
+ if (preset(exec.agent)?.teamId !== teamId)
416
+ throw new Error('Team changed during operation');
417
+ return { teamId, result };
418
+ },
419
+ }, { when: ({ agent }) => !!preset(agent) }));
420
+ }
421
+ //# sourceMappingURL=assistant-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assistant-tools.js","sourceRoot":"","sources":["../src/assistant-tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAuB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,OAAO,GAAG,CAAC;KACd,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAA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