@dsh-teamwork/dsh-teamwork 0.8.4 → 0.10.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 (88) hide show
  1. package/README.md +5 -2
  2. package/README.zh-CN.md +1 -1
  3. package/assets/readme/icon-256.png +0 -0
  4. package/assets/readme/review-and-publish.png +0 -0
  5. package/assets/readme/teamwork-panel.png +0 -0
  6. package/assets/readme/versions-and-backups.png +0 -0
  7. package/docs/development.md +88 -3
  8. package/docs/en/guide.md +50 -2
  9. package/docs/zh-CN/guide.md +20 -2
  10. package/icon.svg +7 -4
  11. package/lib/audit-archive.js +174 -0
  12. package/lib/audit-archive.js.map +1 -0
  13. package/lib/audit-cli.js +91 -0
  14. package/lib/audit-cli.js.map +1 -0
  15. package/lib/bridge.js +32 -10
  16. package/lib/bridge.js.map +1 -1
  17. package/lib/client.js +58 -15
  18. package/lib/client.js.map +1 -1
  19. package/lib/config-sync.js +1 -1
  20. package/lib/config-sync.js.map +1 -1
  21. package/lib/index.js +356 -97
  22. package/lib/index.js.map +1 -1
  23. package/lib/locale.js +18 -0
  24. package/lib/locale.js.map +1 -0
  25. package/lib/login-callback.js +1 -1
  26. package/lib/login-callback.js.map +1 -1
  27. package/lib/messages.js +119 -0
  28. package/lib/messages.js.map +1 -0
  29. package/lib/panel.js +27 -20
  30. package/lib/panel.js.map +1 -1
  31. package/lib/phone-security.js +120 -2
  32. package/lib/phone-security.js.map +1 -1
  33. package/lib/pin-lock.js +89 -0
  34. package/lib/pin-lock.js.map +1 -0
  35. package/lib/platform-models.js +10 -7
  36. package/lib/platform-models.js.map +1 -1
  37. package/lib/plugin-status.js +4 -4
  38. package/lib/plugin-status.js.map +1 -1
  39. package/lib/preset-session.js +2 -1
  40. package/lib/preset-session.js.map +1 -1
  41. package/lib/relay.js +14 -9
  42. package/lib/relay.js.map +1 -1
  43. package/lib/shared-mode.js +151 -0
  44. package/lib/shared-mode.js.map +1 -0
  45. package/lib/shared-owner.js +122 -0
  46. package/lib/shared-owner.js.map +1 -0
  47. package/lib/shared-roster.js +112 -0
  48. package/lib/shared-roster.js.map +1 -0
  49. package/lib/task-session.js +55 -19
  50. package/lib/task-session.js.map +1 -1
  51. package/lib/token-file.js +34 -0
  52. package/lib/token-file.js.map +1 -0
  53. package/lib/types/audit-archive.d.ts +78 -0
  54. package/lib/types/audit-archive.d.ts.map +1 -0
  55. package/lib/types/audit-cli.d.ts +14 -0
  56. package/lib/types/audit-cli.d.ts.map +1 -0
  57. package/lib/types/bridge.d.ts +7 -3
  58. package/lib/types/bridge.d.ts.map +1 -1
  59. package/lib/types/client.d.ts +27 -4
  60. package/lib/types/client.d.ts.map +1 -1
  61. package/lib/types/index.d.ts +3 -0
  62. package/lib/types/index.d.ts.map +1 -1
  63. package/lib/types/locale.d.ts +13 -0
  64. package/lib/types/locale.d.ts.map +1 -0
  65. package/lib/types/messages.d.ts +67 -0
  66. package/lib/types/messages.d.ts.map +1 -0
  67. package/lib/types/panel.d.ts +64 -8
  68. package/lib/types/panel.d.ts.map +1 -1
  69. package/lib/types/phone-security.d.ts +37 -0
  70. package/lib/types/phone-security.d.ts.map +1 -1
  71. package/lib/types/pin-lock.d.ts +36 -0
  72. package/lib/types/pin-lock.d.ts.map +1 -0
  73. package/lib/types/platform-models.d.ts.map +1 -1
  74. package/lib/types/preset-session.d.ts.map +1 -1
  75. package/lib/types/relay.d.ts +15 -1
  76. package/lib/types/relay.d.ts.map +1 -1
  77. package/lib/types/shared-mode.d.ts +50 -0
  78. package/lib/types/shared-mode.d.ts.map +1 -0
  79. package/lib/types/shared-owner.d.ts +42 -0
  80. package/lib/types/shared-owner.d.ts.map +1 -0
  81. package/lib/types/shared-roster.d.ts +49 -0
  82. package/lib/types/shared-roster.d.ts.map +1 -0
  83. package/lib/types/task-session.d.ts +63 -2
  84. package/lib/types/task-session.d.ts.map +1 -1
  85. package/lib/types/token-file.d.ts +11 -0
  86. package/lib/types/token-file.d.ts.map +1 -0
  87. package/lib/web/client.js +1138 -378
  88. package/package.json +8 -1
package/README.md CHANGED
@@ -17,8 +17,11 @@ The team assistant helps with sharing, usage and administration in conversation.
17
17
 
18
18
  ![Teamwork panel in a real DSH host, with demonstration team resources](https://raw.githubusercontent.com/dsh-teamwork/dsh-teamwork/main/assets/readme/teamwork-panel.png)
19
19
 
20
- The plugin panel currently uses Simplified Chinese. The web console supports
21
- English and Simplified Chinese. Screenshots use a local demonstration team.
20
+ The plugin panel and the web console speak English and Simplified Chinese:
21
+ the panel follows the language of your Teamwork account (**Account** in the
22
+ panel). Terminal `/teamwork` output is always English; model replies follow the
23
+ conversation. Screenshots use a local
24
+ demonstration team.
22
25
 
23
26
  ## What you can do
24
27
 
package/README.zh-CN.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  ![真实 DSH 宿主中的 Teamwork 面板,使用本地演示团队](https://raw.githubusercontent.com/dsh-teamwork/dsh-teamwork/main/assets/readme/teamwork-panel.png)
17
17
 
18
- 插件面板目前使用简体中文;网页控制台支持英文和简体中文。截图均来自本地演示团队。
18
+ 插件面板和网页控制台都支持英文和简体中文;面板跟随你的 Teamwork 账号语言(面板中的“我的账号”)。终端 `/teamwork` 命令的输出统一为英文;模型的回复跟随对话语言。截图均来自本地演示团队。
19
19
 
20
20
  ## 可以做什么
21
21
 
Binary file
Binary file
@@ -24,6 +24,14 @@ versions are pinned to rc.3 and Zod to 4.6.6 to avoid recursive type expansion
24
24
  across mismatched versions. Never add `@deepseek-ai/dsh-*` to runtime dependencies:
25
25
  hoisted installations can shadow the upgraded host even when the plugin is disabled.
26
26
 
27
+ For a live host, `pnpm dev` links this checkout into a `web` profile under the
28
+ gitignored `.dsh-home/` (as `DSH_HOME`, so `~/.dsh` is untouched), watch-builds `lib/`
29
+ with `dsh-hmr` reloading it, and boots `dsh web`; arguments after `pnpm dev` reach
30
+ `dsh web`. Put local overrides such as `apiEndpoint` in the gitignored
31
+ `cordis.local.patch.yml`, which outranks the generated `.dsh-home/cordis.patch.yml`.
32
+ `DSH_CLI` selects a specific host. `pnpm dev:reset` deletes the dev home, including
33
+ its sign-in cache. On exit the browser bundle is rebuilt without source maps.
34
+
27
35
  The real-host suites install the packed plugin in temporary profiles and use
28
36
  an isolated local fixture registry and package store:
29
37
 
@@ -66,8 +74,13 @@ retain the previous snapshot. Sync never installs plugins or uploads conversatio
66
74
  Team models use `teamwork-platform` with the configuration ID as wire model.
67
75
  `src/platform-models.ts` adapts text, tool calls and streamed output to the chosen
68
76
  service's `/api/llm/chat/completions`. There is no provider-direct fallback or
69
- local provider-key lookup. Model capability values come from team configuration;
70
- missing context/output limits use 32K/4096, with output bounded by context.
77
+ local provider-key lookup. Model capability values come from team configuration.
78
+ A model, or a preset's model, without `contextWindow` is not guessed: the adapter
79
+ does not offer it; selection, readiness, `agent/request` and sync report
80
+ `modelLimitProblem` (`say('model.noContextWindow')`), and the panel words
81
+ `contextWindowMissing` itself. (A guessed 32K window left DSH's compaction,
82
+ which reserves 64K headroom by default, no budget: `MODEL_SWITCH_COMPACTION_FAILED`.)
83
+ A missing output limit uses 4096, bounded by the context window.
71
84
  Multimodal input and other provider protocols are not implemented by this adapter.
72
85
 
73
86
  Presets use native `agentPresets` registration, mounting, selection and revisions.
@@ -85,7 +98,9 @@ preset definitions are not reconstructed. Unstamped/forked sessions are stamped
85
98
  on first inference. A pinned revision does not freeze current server permissions,
86
99
  routing or budgets.
87
100
 
88
- Task summaries use native session projections. Follow-up/recovery checks model,
101
+ Task summaries use native session projections; `teamworkStep` gives the phone's
102
+ session list a running turn's tool-call count and the latest call's target (its
103
+ first line, at most 120 characters, never file contents). Follow-up/recovery checks model,
89
104
  team access, generations and dependencies before admission. Retry confirms a new
90
105
  recovery instruction for failed/blocked/cancelled/truncated/interrupted work; it
91
106
  never replays tools. Queued/guidance input is not bypassed. Cancellation keeps
@@ -106,6 +121,76 @@ conflicts. Exact historical pins remain installable. Existing local plugins use
106
121
  the host's separate update flow. See the community server's
107
122
  [resource contract](https://github.com/dsh-teamwork/dsh-teamwork-platform/blob/main/docs/tech/team-assistant.md).
108
123
 
124
+ ## Host-provided token
125
+
126
+ `tokenFile` (`src/token-file.ts`) is for hosts that sign DSH in themselves, such
127
+ as a DSH Teamwork cloud computer, where a supervisor writes a short-lived token
128
+ after DSH has booted. The file is polled once a second with `watchFile`, which
129
+ sees an atomic replacement that a directory watch can miss, and only a changed
130
+ value reaches `TeamworkClient.useToken`. Renewing one token with another keeps
131
+ the session revision, so pending approvals and preset stamps survive renewal;
132
+ gaining or losing a token moves it, and losing one drops the cache. A 401/403
133
+ still clears the token until the file changes. In this mode the relay is never
134
+ opened, and sign-in, sign-out and server changes are refused: the server reaches
135
+ a cloud computer itself, and the token belongs to the host, not a member.
136
+
137
+ ## Shared mode
138
+
139
+ `src/shared-mode.ts` makes a DSH its team's shared DSH (the server's
140
+ `docs/tech/shared-dsh.md`, part of the community edition). `/teamwork share enable <key>` trades a team
141
+ host key for a one-hour host token (platform ADR 0047): the server's nonce is
142
+ signed with this DSH's identity key from `<cache>.phone-keys.json`, and the first
143
+ exchange binds the key to that identity, so a copied key is refused elsewhere.
144
+ The key is saved to `<cache>.shared.json` (mode 0600) only once accepted, the
145
+ token reaches `TeamworkClient.useToken` like a host-provided one, and it is
146
+ renewed ten minutes before it ends, or a minute after a failure that may pass;
147
+ a key the server no longer accepts drops the token. Enabling signs a personal
148
+ account out first, and while shared, sign-in and sign-out are refused and the
149
+ relay connects with the host token. A host-provided token (`tokenFile`)
150
+ excludes shared mode.
151
+
152
+ `src/shared-roster.ts` is the DSH's own roster (`<cache>.shared-roster.json`,
153
+ mode 0600): invites (a single-use secret per listed member, kept as a hash, a
154
+ day long), each member's paired devices, and each session's starter. A member's
155
+ handset joins through the relay, pins this DSH's key from the invite, and hands
156
+ the secret over inside the channel; `PhoneSecurity` admits it through the
157
+ roster instead of a safety code. The relay's `members` list prunes the roster.
158
+ `src/shared-owner.ts` is what the bridge asks before any call or stream and
159
+ after `session/create` and `session/list`: a member reaches only sessions they
160
+ started, sees only their events, and answers only questions they were shown.
161
+
162
+ `src/pin-lock.ts` is the PIN lock, on a shared DSH and on a personal computer
163
+ alike (`<cache>.pins.json`, mode 0600): one four-digit PIN per member (`owner`
164
+ on a personal computer), kept as scrypt, and a failure count that survives a
165
+ restart. Once a channel is authorized, `PhoneSecurity` tells the phone
166
+ `pinRequired` (with `set` when the member has none yet), answers `unlock` and
167
+ `setPin` with `unlocked`, `pinWrong`, `pinLocked` or `pinInvalid`, and refuses
168
+ every call (`teamwork/locked`) and stream until unlocked, and again after
169
+ fifteen minutes with nothing sent. Five wrong PINs lock the member on every
170
+ device until `/teamwork share unlock <email>` or `/teamwork pin reset` clears
171
+ it. Signing out, entering or leaving shared mode clears every PIN.
172
+
173
+ `src/audit-archive.ts` is a shared DSH's audit archive (the server's ADR 0045):
174
+ every frame between a member's device and this DSH, both ways, becomes a record
175
+ (member, device, direction, time; a string over 64 KiB kept as its length and
176
+ SHA-256). Records collect for a minute or 1 MiB, are HPKE-sealed (`@hpke/core`,
177
+ exact version) to the admin's audit public key under a header the AEAD binds
178
+ (host, sequence, the previous segment's SHA-256, the key's fingerprint), signed
179
+ with the identity key the host key is bound to, written to
180
+ `<cache>.audit.json.queue/`, and uploaded in order to
181
+ `POST /relay/shared/archive`; a segment leaves the queue only once the server
182
+ holds it. `<cache>.audit.json` keeps the key and the chain's position. No
183
+ member is admitted until `/teamwork share audit-key` sets a key; leaving
184
+ shared mode flushes and forgets it. `src/audit-cli.ts` is the
185
+ `dsh-teamwork-audit` bin the admin runs on their own machine: `keygen` writes
186
+ a key pair (mode 0600, never overwriting), `read` opens an exported archive
187
+ and reports a gap, an alteration or another key.
188
+
189
+ The panel's **Shared DSH** page (`Shared` in `src/web/TeamworkPanel.tsx`, the
190
+ `share-*` routes in `src/panel.ts`) runs the same functions as
191
+ `/teamwork share`; in shared mode `PanelState.shared` is set, no profile is
192
+ read, and the header offers that page in place of Phone and Account.
193
+
109
194
  ## Phone transport
110
195
 
111
196
  The hosted relay is optional and discovered through `GET /api/relay`. The host
package/docs/en/guide.md CHANGED
@@ -46,11 +46,44 @@ phone pairing to that team. A person may belong to several teams.
46
46
 
47
47
  Create or join teams in the web console. New teams receive a built-in assistant;
48
48
  existing teams are unchanged. Team renaming does not automatically rename the
49
- assistant. Use its preset with a working model and ask it to inspect real state.
49
+ assistant. It leads the panel's presets: **Ask the assistant** starts a session
50
+ with it. Give it a working model and ask it to inspect real state. While an
51
+ administrator browses a team, the panel's header shows how many submissions wait
52
+ for review and opens them in the console.
53
+
54
+ ### A team's shared DSH
55
+
56
+ On the hosted service a team admin can make one DSH the team's own: create a
57
+ key under **Shared DSHs** in the team's console, then run
58
+ `/teamwork share enable <key>` in that DSH. It then signs in as the team, not as
59
+ a person: personal sign-in is refused while it is shared, it syncs that one
60
+ team, and its team-model calls are billed to the team. The first machine that
61
+ uses a key keeps it; the same key on another machine is refused, and an admin
62
+ who rotates or deletes the key cuts it off. `/teamwork share disable` deletes
63
+ the key. A team admin chooses in the console who may reach it; for each of
64
+ them, run `/teamwork share invite <email>` here and hand the link over in
65
+ person or through a channel the team trusts, never through the Teamwork server.
66
+ Each member's sessions are theirs alone: others cannot list, follow or answer
67
+ them. Phone and web clients that open the link arrive in a later release.
68
+
69
+ A shared DSH admits nobody until its admin sets the team's audit key. On their
70
+ own computer the admin runs `dsh-teamwork-audit keygen` (installed with this
71
+ package), which writes `audit-key.json` and prints
72
+ `/teamwork share audit-key <public key>` to run here. From then on this DSH
73
+ seals every exchange with a member's device to that key and uploads it; the
74
+ server keeps it and cannot read it. The admin downloads it from the console and
75
+ opens it with `dsh-teamwork-audit read <file> --key audit-key.json`. A lost key
76
+ cannot be recovered.
77
+
78
+ Everything above can also be done in the Teamwork panel: **Use this DSH as a
79
+ team's shared DSH** on its sign-in screen or account page turns shared mode on,
80
+ and its **Shared DSH** page then sets the audit key, lists the members who may
81
+ reach it with their devices, makes an invite (a link and a QR code), unlocks a
82
+ member locked out by wrong PINs, and turns shared mode off.
50
83
 
51
84
  ## Choose a model or preset
52
85
 
53
- Use **New session** for a team preset. **Use in current session** works only
86
+ Use **New session** for a team preset. **Use in this blank session** works only
54
87
  before the conversation begins. Started sessions keep their preset generation;
55
88
  use a new session to adopt an update. A restart cannot promise to reconstruct a
56
89
  deleted old preset: a version mismatch blocks team inference and gives recovery
@@ -94,6 +127,14 @@ Run these in DSH's command input, not your shell. IDs come from `/teamwork list`
94
127
  | --- | --- |
95
128
  | `/teamwork login` | Open browser authorization. |
96
129
  | `/teamwork authorize <code>` | Redeem a fallback authorization code. |
130
+ | `/teamwork share enable <key>` | Make this DSH its team's shared DSH with a team host key (hosted service). |
131
+ | `/teamwork share disable` | End shared mode and delete its key. |
132
+ | `/teamwork share status` | Show the shared DSH's name, team and host token. |
133
+ | `/teamwork share invite <email>` | A single-use link, valid a day, that pairs one listed member's device with this shared DSH. |
134
+ | `/teamwork share members` | The members who may reach this shared DSH, and their devices. |
135
+ | `/teamwork share unlock <email>` | Clear a member's PIN and lock on this shared DSH; they set a new PIN next time. |
136
+ | `/teamwork share audit-key <key>` | Seal this shared DSH's archive to the key `dsh-teamwork-audit keygen` printed; members are admitted only once it is set. |
137
+ | `/teamwork pin reset` | Clear your own phone PIN and lock on this computer; set a new one from your phone. |
97
138
  | `/teamwork status` | Show authentication, sync status and recent errors. |
98
139
  | `/teamwork sync` | Refresh the team's resources. |
99
140
  | `/teamwork list` | List configuration IDs. |
@@ -133,6 +174,13 @@ Advanced profile configuration can override the inserted plugin entry:
133
174
 
134
175
  `syncIntervalMs` accepts integer milliseconds from 10000 to 86400000.
135
176
  `autoSync: false` disables login-triggered and periodic sync; manual sync remains.
177
+
178
+ A host that signs DSH in itself, such as a DSH Teamwork cloud computer, sets
179
+ `tokenFile` to the absolute path of a file holding a plugin token. The plugin
180
+ reads it at start and follows every change, including an atomic replacement;
181
+ an empty or missing file signs it out. In this mode sign-in, sign-out and
182
+ changing servers are refused, `apiEndpoint` names the server, and the phone
183
+ relay is never opened.
136
184
  Do not duplicate the package's `insert` entry in a profile.
137
185
 
138
186
  ## Data and phone access
@@ -21,11 +21,19 @@
21
21
 
22
22
  授权完成后立即同步,默认每 60 秒刷新。用团队下拉框浏览一个或所有团队;改变浏览范围不改变已有会话的目标团队,也不能把手机授权限制到这个团队。一个账号可以加入多个团队。
23
23
 
24
- 在网页控制台创建或加入团队。新团队会获得内置助理,已有团队不自动补建;重命名团队不会自动重命名助理。为助理预设选择可用模型后,要求它读取真实状态再操作。
24
+ 在网页控制台创建或加入团队。新团队会获得内置助理,已有团队不自动补建;重命名团队不会自动重命名助理。助理排在面板预设的最前面,点击“问问助理”即可用它新建会话。为助理选择可用模型后,要求它读取真实状态再操作。管理员浏览某个团队时,面板顶部会显示待审核的提交数量,点击即可在控制台打开。
25
+
26
+ ### 团队共享 DSH
27
+
28
+ 在托管服务上,团队管理员可以把一台 DSH 设为团队自己的:在团队控制台的**共享 DSH**里创建 key,再在那台 DSH 中运行 `/teamwork share enable <key>`。之后它以团队身份登录而不是个人:共享期间拒绝个人登录,只同步这一个团队,团队模型的调用计入团队。第一台使用 key 的机器会绑定它,同一个 key 换到其他机器上会被拒绝;管理员更换或删除 key 后它立即失效。`/teamwork share disable` 会删除 key。团队管理员在控制台决定谁可以访问它;对其中每个人,在这里运行 `/teamwork share invite <email>`,并当面或通过团队信任的渠道交给对方,不要经过 Teamwork 服务器。每个成员的会话只属于自己,其他人无法查看、跟随或回答。打开邀请链接的手机和网页客户端将在后续版本提供。
29
+
30
+ 共享 DSH 在管理员设置团队审计密钥之前不会接纳任何人。管理员在自己的电脑上运行 `dsh-teamwork-audit keygen`(随本插件包安装),它会写出 `audit-key.json` 并打印要在这里运行的 `/teamwork share audit-key <public key>`。此后这台 DSH 会把与成员设备之间的每次交互加密到这把密钥并上传,服务器保存它却无法读取。管理员在控制台下载归档,用 `dsh-teamwork-audit read <file> --key audit-key.json` 打开。丢失的密钥无法找回。
31
+
32
+ 以上操作也都可以在 Teamwork 面板中完成:在登录页或账号页选择**把这台 DSH 设为团队的共享 DSH** 即可开启共享模式;开启后的**共享 DSH** 页可以设置审计密钥、查看可访问的成员及其设备、生成邀请(链接和二维码)、为输错 PIN 被锁定的成员解锁,以及关闭共享模式。
25
33
 
26
34
  ## 选择模型或预设
27
35
 
28
- 使用“新建会话”应用团队预设。“用于当前会话”仅适用于尚未开始对话的会话。已开始的会话保留原预设代次,使用新会话采用更新。跨重启不保证重建已删除的旧预设;发现版本不一致时会阻止团队推理并给出恢复指引。
36
+ 使用“新建会话”应用团队预设。“用于当前空白会话”仅适用于尚未开始对话的会话。已开始的会话保留原预设代次,使用新会话采用更新。跨重启不保证重建已删除的旧预设;发现版本不一致时会阻止团队推理并给出恢复指引。
29
37
 
30
38
  必需工具和固定版本的插件依赖必须就绪,可选工具缺失只提示。工具已注册仍须满足 DSH 授权与运行条件。团队模型经过团队服务;继承本地模型的预设继续使用所继承的模型。
31
39
 
@@ -51,6 +59,14 @@
51
59
  | --- | --- |
52
60
  | `/teamwork login` | 打开浏览器授权。 |
53
61
  | `/teamwork authorize <code>` | 兑换备用授权码。 |
62
+ | `/teamwork share enable <key>` | 用团队授权 key 把这台 DSH 设为团队的共享 DSH(托管服务)。 |
63
+ | `/teamwork share disable` | 关闭共享模式并删除 key。 |
64
+ | `/teamwork share status` | 查看共享 DSH 的名称、团队和 token 状态。 |
65
+ | `/teamwork share invite <email>` | 生成一次性邀请链接(一天内有效),让名单中的一位成员把设备配对到这台共享 DSH。 |
66
+ | `/teamwork share members` | 查看可访问这台共享 DSH 的成员及其设备。 |
67
+ | `/teamwork share unlock <email>` | 清除某个成员在这台共享 DSH 上的 PIN 和锁定,对方下次连接时重新设置。 |
68
+ | `/teamwork share audit-key <key>` | 把这台共享 DSH 的归档加密到 `dsh-teamwork-audit keygen` 打印的密钥;设置之后才会接纳成员。 |
69
+ | `/teamwork pin reset` | 清除你自己手机在这台计算机上的 PIN 和锁定,再从手机设置新的。 |
54
70
  | `/teamwork status` | 查看登录、同步和最近错误。 |
55
71
  | `/teamwork sync` | 刷新团队资源。 |
56
72
  | `/teamwork list` | 列出配置 ID。 |
@@ -85,6 +101,8 @@
85
101
 
86
102
  `syncIntervalMs` 接受 10000–86400000 之间的整数毫秒。`autoSync: false` 关闭登录触发与定时同步,手动同步仍可用。不要重复复制包内的 `insert` 条目。
87
103
 
104
+ 由宿主自行为 DSH 登录的环境(例如 DSH Teamwork 云电脑)可以把 `tokenFile` 设为一个文件的绝对路径,文件内容是插件令牌。插件启动时读取它,并跟随之后的每次变化(包括原子替换);文件为空或不存在即视为退出登录。此模式下不能在插件里登录、退出或切换服务器,服务器由 `apiEndpoint` 指定,也不会连接手机中转。
105
+
88
106
  ## 数据与手机连接
89
107
 
90
108
  令牌只在宿主内存中保存,重启需要登录;团队配置以私有文件权限缓存。旧缓存不是登录授权。网络失败时保留缓存;401/403 会清除团队注册并暂停同步,等待重新登录。供应商密钥保留在服务端,团队模型的提示词与上下文经过其网关。
package/icon.svg CHANGED
@@ -1,4 +1,7 @@
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>
1
+ <svg width="64" height="64" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
2
+ <rect id="plate" width="400" height="400" fill="#1E2F6D"></rect>
3
+ <path id="mark" fill="#F8F5EF" d="M185.89 163.76C162.65 148.53 128.19 148.57 93.22 161.01C68.77 169.86 48.13 170.02 31.16 163.85C49.59 192.62 84.41 213.93 127.56 217.69C158.83 220.04 182.52 219.82 192.45 234.01L198.98 312.7L249.02 299.3L215.33 227.88C216.83 210.63 237.46 198.97 263.37 181.3C298.85 156.47 318.35 120.6 319.93 86.47C308.32 100.31 290.36 110.48 264.77 115.04C228.26 121.76 198.39 138.96 185.89 163.76Z"/>
4
+ <path id="sea" fill="#111A42" d="M-4 291.5L-2 290.5L0 289.5L2 288.5L4 287.53L6 286.59L8 285.71L10 284.9L12 284.17L14 283.53L16 282.99L18 282.56L20 282.25L22 282.06L24 282L26 282.06L28 282.25L30 282.56L32 282.99L34 283.53L36 284.17L38 284.9L40 285.71L42 286.59L44 287.53L46 288.5L48 289.5L50 290.5L52 291.5L54 292.47L56 293.41L58 294.29L60 295.1L62 295.83L64 296.47L66 297.01L68 297.44L70 297.75L72 297.94L74 298L76 297.94L78 297.75L80 297.44L82 297.01L84 296.47L86 295.83L88 295.1L90 294.29L92 293.41L94 292.47L96 291.5L98 290.5L100 289.5L102 288.5L104 287.53L106 286.59L108 285.71L110 284.9L112 284.17L114 283.53L116 282.99L118 282.56L120 282.25L122 282.06L124 282L126 282.06L128 282.25L130 282.56L132 282.99L134 283.53L136 284.17L138 284.9L140 285.71L142 286.59L144 287.53L146 288.5L148 289.5L150 290.5L152 291.5L154 292.47L156 293.41L158 294.29L160 295.1L162 295.83L164 296.47L166 297.01L168 297.44L170 297.75L172 297.94L174 298L176 297.94L178 297.75L180 297.44L182 297.01L184 296.47L186 295.83L188 295.1L190 294.29L192 293.41L194 292.47L196 291.5L198 290.5L200 289.5L202 288.5L204 287.53L206 286.59L208 285.71L210 284.9L212 284.17L214 283.53L216 282.99L218 282.56L220 282.25L222 282.06L224 282L226 282.06L228 282.25L230 282.56L232 282.99L234 283.53L236 284.17L238 284.9L240 285.71L242 286.59L244 287.53L246 288.5L248 289.5L250 290.5L252 291.5L254 292.47L256 293.41L258 294.29L260 295.1L262 295.83L264 296.47L266 297.01L268 297.44L270 297.75L272 297.94L274 298L276 297.94L278 297.75L280 297.44L282 297.01L284 296.47L286 295.83L288 295.1L290 294.29L292 293.41L294 292.47L296 291.5L298 290.5L300 289.5L302 288.5L304 287.53L306 286.59L308 285.71L310 284.9L312 284.17L314 283.53L316 282.99L318 282.56L320 282.25L322 282.06L324 282L326 282.06L328 282.25L330 282.56L332 282.99L334 283.53L336 284.17L338 284.9L340 285.71L342 286.59L344 287.53L346 288.5L348 289.5L350 290.5L352 291.5L354 292.47L356 293.41L358 294.29L360 295.1L362 295.83L364 296.47L366 297.01L368 297.44L370 297.75L372 297.94L374 298L376 297.94L378 297.75L380 297.44L382 297.01L384 296.47L386 295.83L388 295.1L390 294.29L392 293.41L394 292.47L396 291.5L398 290.5L400 289.5L402 288.5L404 287.53L404 404L-4 404Z"/>
5
+ <path id="surface" fill="#7B91D4" d="M-6.66 286.12L-4.69 285.14L-2.69 284.13L-0.66 283.12L1.41 282.11L3.52 281.13L5.66 280.19L7.83 279.31L10.05 278.49L12.3 277.77L14.59 277.16L16.91 276.66L19.26 276.3L21.62 276.07L24 276L26.38 276.07L28.74 276.3L31.09 276.66L33.41 277.16L35.7 277.77L37.95 278.49L40.17 279.31L42.34 280.19L44.48 281.13L46.59 282.11L48.66 283.12L50.69 284.13L52.69 285.14L54.66 286.12L56.59 287.06L58.48 287.94L60.34 288.76L62.17 289.5L63.95 290.16L65.7 290.72L67.41 291.18L69.09 291.54L70.74 291.8L72.38 291.95L74 292L75.62 291.95L77.26 291.8L78.91 291.54L80.59 291.18L82.3 290.72L84.05 290.16L85.83 289.5L87.66 288.76L89.52 287.94L91.41 287.06L93.34 286.12L95.31 285.14L97.31 284.13L99.34 283.12L101.41 282.11L103.52 281.13L105.66 280.19L107.83 279.31L110.05 278.49L112.3 277.77L114.59 277.16L116.91 276.66L119.26 276.3L121.62 276.07L124 276L126.38 276.07L128.74 276.3L131.09 276.66L133.41 277.16L135.7 277.77L137.95 278.49L140.17 279.31L142.34 280.19L144.48 281.13L146.59 282.11L148.66 283.12L150.69 284.13L152.69 285.14L154.66 286.12L156.59 287.06L158.48 287.94L160.34 288.76L162.17 289.5L163.95 290.16L165.7 290.72L167.41 291.18L169.09 291.54L170.74 291.8L172.38 291.95L174 292L175.62 291.95L177.26 291.8L178.91 291.54L180.59 291.18L182.3 290.72L184.05 290.16L185.83 289.5L187.66 288.76L189.52 287.94L191.41 287.06L193.34 286.12L195.31 285.14L197.31 284.13L199.34 283.12L201.41 282.11L203.52 281.13L205.66 280.19L207.83 279.31L210.05 278.49L212.3 277.77L214.59 277.16L216.91 276.66L219.26 276.3L221.62 276.07L224 276L226.38 276.07L228.74 276.3L231.09 276.66L233.41 277.16L235.7 277.77L237.95 278.49L240.17 279.31L242.34 280.19L244.48 281.13L246.59 282.11L248.66 283.12L250.69 284.13L252.69 285.14L254.66 286.12L256.59 287.06L258.48 287.94L260.34 288.76L262.17 289.5L263.95 290.16L265.7 290.72L267.41 291.18L269.09 291.54L270.74 291.8L272.38 291.95L274 292L275.62 291.95L277.26 291.8L278.91 291.54L280.59 291.18L282.3 290.72L284.05 290.16L285.83 289.5L287.66 288.76L289.52 287.94L291.41 287.06L293.34 286.12L295.31 285.14L297.31 284.13L299.34 283.12L301.41 282.11L303.52 281.13L305.66 280.19L307.83 279.31L310.05 278.49L312.3 277.77L314.59 277.16L316.91 276.66L319.26 276.3L321.62 276.07L324 276L326.38 276.07L328.74 276.3L331.09 276.66L333.41 277.16L335.7 277.77L337.95 278.49L340.17 279.31L342.34 280.19L344.48 281.13L346.59 282.11L348.66 283.12L350.69 284.13L352.69 285.14L354.66 286.12L356.59 287.06L358.48 287.94L360.34 288.76L362.17 289.5L363.95 290.16L365.7 290.72L367.41 291.18L369.09 291.54L370.74 291.8L372.38 291.95L374 292L375.62 291.95L377.26 291.8L378.91 291.54L380.59 291.18L382.3 290.72L384.05 290.16L385.83 289.5L387.66 288.76L389.52 287.94L391.41 287.06L393.34 286.12L395.31 285.14L397.31 284.13L399.34 283.12L401.41 282.11L406.59 292.94L404.66 293.88L402.69 294.86L400.69 295.87L398.66 296.88L396.59 297.89L394.48 298.87L392.34 299.81L390.17 300.69L387.95 301.51L385.7 302.23L383.41 302.84L381.09 303.34L378.74 303.7L376.38 303.93L374 304L371.62 303.93L369.26 303.7L366.91 303.34L364.59 302.84L362.3 302.23L360.05 301.51L357.83 300.69L355.66 299.81L353.52 298.87L351.41 297.89L349.34 296.88L347.31 295.87L345.31 294.86L343.34 293.88L341.41 292.94L339.52 292.06L337.66 291.24L335.83 290.5L334.05 289.84L332.3 289.28L330.59 288.82L328.91 288.46L327.26 288.2L325.62 288.05L324 288L322.38 288.05L320.74 288.2L319.09 288.46L317.41 288.82L315.7 289.28L313.95 289.84L312.17 290.5L310.34 291.24L308.48 292.06L306.59 292.94L304.66 293.88L302.69 294.86L300.69 295.87L298.66 296.88L296.59 297.89L294.48 298.87L292.34 299.81L290.17 300.69L287.95 301.51L285.7 302.23L283.41 302.84L281.09 303.34L278.74 303.7L276.38 303.93L274 304L271.62 303.93L269.26 303.7L266.91 303.34L264.59 302.84L262.3 302.23L260.05 301.51L257.83 300.69L255.66 299.81L253.52 298.87L251.41 297.89L249.34 296.88L247.31 295.87L245.31 294.86L243.34 293.88L241.41 292.94L239.52 292.06L237.66 291.24L235.83 290.5L234.05 289.84L232.3 289.28L230.59 288.82L228.91 288.46L227.26 288.2L225.62 288.05L224 288L222.38 288.05L220.74 288.2L219.09 288.46L217.41 288.82L215.7 289.28L213.95 289.84L212.17 290.5L210.34 291.24L208.48 292.06L206.59 292.94L204.66 293.88L202.69 294.86L200.69 295.87L198.66 296.88L196.59 297.89L194.48 298.87L192.34 299.81L190.17 300.69L187.95 301.51L185.7 302.23L183.41 302.84L181.09 303.34L178.74 303.7L176.38 303.93L174 304L171.62 303.93L169.26 303.7L166.91 303.34L164.59 302.84L162.3 302.23L160.05 301.51L157.83 300.69L155.66 299.81L153.52 298.87L151.41 297.89L149.34 296.88L147.31 295.87L145.31 294.86L143.34 293.88L141.41 292.94L139.52 292.06L137.66 291.24L135.83 290.5L134.05 289.84L132.3 289.28L130.59 288.82L128.91 288.46L127.26 288.2L125.62 288.05L124 288L122.38 288.05L120.74 288.2L119.09 288.46L117.41 288.82L115.7 289.28L113.95 289.84L112.17 290.5L110.34 291.24L108.48 292.06L106.59 292.94L104.66 293.88L102.69 294.86L100.69 295.87L98.66 296.88L96.59 297.89L94.48 298.87L92.34 299.81L90.17 300.69L87.95 301.51L85.7 302.23L83.41 302.84L81.09 303.34L78.74 303.7L76.38 303.93L74 304L71.62 303.93L69.26 303.7L66.91 303.34L64.59 302.84L62.3 302.23L60.05 301.51L57.83 300.69L55.66 299.81L53.52 298.87L51.41 297.89L49.34 296.88L47.31 295.87L45.31 294.86L43.34 293.88L41.41 292.94L39.52 292.06L37.66 291.24L35.83 290.5L34.05 289.84L32.3 289.28L30.59 288.82L28.91 288.46L27.26 288.2L25.62 288.05L24 288L22.38 288.05L20.74 288.2L19.09 288.46L17.41 288.82L15.7 289.28L13.95 289.84L12.17 290.5L10.34 291.24L8.48 292.06L6.59 292.94L4.66 293.88L2.69 294.86L0.69 295.87L-1.34 296.88Z"/>
6
+ <path id="swell" fill="#2B3F86" d="M-5.18 331.11L-3.2 330.5L-1.2 329.87L0.82 329.24L2.85 328.62L4.91 328.02L6.97 327.45L9.06 326.93L11.16 326.44L13.27 326.02L15.4 325.66L17.54 325.38L19.69 325.17L21.84 325.04L24 325L26.16 325.04L28.31 325.17L30.46 325.38L32.6 325.66L34.73 326.02L36.84 326.44L38.94 326.93L41.03 327.45L43.09 328.02L45.15 328.62L47.18 329.24L49.2 329.87L51.2 330.5L53.18 331.11L55.15 331.71L57.09 332.28L59.03 332.81L60.94 333.3L62.84 333.73L64.73 334.11L66.6 334.43L68.46 334.68L70.31 334.86L72.16 334.96L74 335L75.84 334.96L77.69 334.86L79.54 334.68L81.4 334.43L83.27 334.11L85.16 333.73L87.06 333.3L88.97 332.81L90.91 332.28L92.85 331.71L94.82 331.11L96.8 330.5L98.8 329.87L100.82 329.24L102.85 328.62L104.91 328.02L106.97 327.45L109.06 326.93L111.16 326.44L113.27 326.02L115.4 325.66L117.54 325.38L119.69 325.17L121.84 325.04L124 325L126.16 325.04L128.31 325.17L130.46 325.38L132.6 325.66L134.73 326.02L136.84 326.44L138.94 326.93L141.03 327.45L143.09 328.02L145.15 328.62L147.18 329.24L149.2 329.87L151.2 330.5L153.18 331.11L155.15 331.71L157.09 332.28L159.03 332.81L160.94 333.3L162.84 333.73L164.73 334.11L166.6 334.43L168.46 334.68L170.31 334.86L172.16 334.96L174 335L175.84 334.96L177.69 334.86L179.54 334.68L181.4 334.43L183.27 334.11L185.16 333.73L187.06 333.3L188.97 332.81L190.91 332.28L192.85 331.71L194.82 331.11L196.8 330.5L198.8 329.87L200.82 329.24L202.85 328.62L204.91 328.02L206.97 327.45L209.06 326.93L211.16 326.44L213.27 326.02L215.4 325.66L217.54 325.38L219.69 325.17L221.84 325.04L224 325L226.16 325.04L228.31 325.17L230.46 325.38L232.6 325.66L234.73 326.02L236.84 326.44L238.94 326.93L241.03 327.45L243.09 328.02L245.15 328.62L247.18 329.24L249.2 329.87L251.2 330.5L253.18 331.11L255.15 331.71L257.09 332.28L259.03 332.81L260.94 333.3L262.84 333.73L264.73 334.11L266.6 334.43L268.46 334.68L270.31 334.86L272.16 334.96L274 335L275.84 334.96L277.69 334.86L279.54 334.68L281.4 334.43L283.27 334.11L285.16 333.73L287.06 333.3L288.97 332.81L290.91 332.28L292.85 331.71L294.82 331.11L296.8 330.5L298.8 329.87L300.82 329.24L302.85 328.62L304.91 328.02L306.97 327.45L309.06 326.93L311.16 326.44L313.27 326.02L315.4 325.66L317.54 325.38L319.69 325.17L321.84 325.04L324 325L326.16 325.04L328.31 325.17L330.46 325.38L332.6 325.66L334.73 326.02L336.84 326.44L338.94 326.93L341.03 327.45L343.09 328.02L345.15 328.62L347.18 329.24L349.2 329.87L351.2 330.5L353.18 331.11L355.15 331.71L357.09 332.28L359.03 332.81L360.94 333.3L362.84 333.73L364.73 334.11L366.6 334.43L368.46 334.68L370.31 334.86L372.16 334.96L374 335L375.84 334.96L377.69 334.86L379.54 334.68L381.4 334.43L383.27 334.11L385.16 333.73L387.06 333.3L388.97 332.81L390.91 332.28L392.85 331.71L394.82 331.11L396.8 330.5L398.8 329.87L400.82 329.24L402.85 328.62L405.15 336.29L403.18 336.89L401.2 337.5L399.2 338.13L397.18 338.76L395.15 339.38L393.09 339.98L391.03 340.55L388.94 341.07L386.84 341.56L384.73 341.98L382.6 342.34L380.46 342.62L378.31 342.83L376.16 342.96L374 343L371.84 342.96L369.69 342.83L367.54 342.62L365.4 342.34L363.27 341.98L361.16 341.56L359.06 341.07L356.97 340.55L354.91 339.98L352.85 339.38L350.82 338.76L348.8 338.13L346.8 337.5L344.82 336.89L342.85 336.29L340.91 335.72L338.97 335.19L337.06 334.7L335.16 334.27L333.27 333.89L331.4 333.57L329.54 333.32L327.69 333.14L325.84 333.04L324 333L322.16 333.04L320.31 333.14L318.46 333.32L316.6 333.57L314.73 333.89L312.84 334.27L310.94 334.7L309.03 335.19L307.09 335.72L305.15 336.29L303.18 336.89L301.2 337.5L299.2 338.13L297.18 338.76L295.15 339.38L293.09 339.98L291.03 340.55L288.94 341.07L286.84 341.56L284.73 341.98L282.6 342.34L280.46 342.62L278.31 342.83L276.16 342.96L274 343L271.84 342.96L269.69 342.83L267.54 342.62L265.4 342.34L263.27 341.98L261.16 341.56L259.06 341.07L256.97 340.55L254.91 339.98L252.85 339.38L250.82 338.76L248.8 338.13L246.8 337.5L244.82 336.89L242.85 336.29L240.91 335.72L238.97 335.19L237.06 334.7L235.16 334.27L233.27 333.89L231.4 333.57L229.54 333.32L227.69 333.14L225.84 333.04L224 333L222.16 333.04L220.31 333.14L218.46 333.32L216.6 333.57L214.73 333.89L212.84 334.27L210.94 334.7L209.03 335.19L207.09 335.72L205.15 336.29L203.18 336.89L201.2 337.5L199.2 338.13L197.18 338.76L195.15 339.38L193.09 339.98L191.03 340.55L188.94 341.07L186.84 341.56L184.73 341.98L182.6 342.34L180.46 342.62L178.31 342.83L176.16 342.96L174 343L171.84 342.96L169.69 342.83L167.54 342.62L165.4 342.34L163.27 341.98L161.16 341.56L159.06 341.07L156.97 340.55L154.91 339.98L152.85 339.38L150.82 338.76L148.8 338.13L146.8 337.5L144.82 336.89L142.85 336.29L140.91 335.72L138.97 335.19L137.06 334.7L135.16 334.27L133.27 333.89L131.4 333.57L129.54 333.32L127.69 333.14L125.84 333.04L124 333L122.16 333.04L120.31 333.14L118.46 333.32L116.6 333.57L114.73 333.89L112.84 334.27L110.94 334.7L109.03 335.19L107.09 335.72L105.15 336.29L103.18 336.89L101.2 337.5L99.2 338.13L97.18 338.76L95.15 339.38L93.09 339.98L91.03 340.55L88.94 341.07L86.84 341.56L84.73 341.98L82.6 342.34L80.46 342.62L78.31 342.83L76.16 342.96L74 343L71.84 342.96L69.69 342.83L67.54 342.62L65.4 342.34L63.27 341.98L61.16 341.56L59.06 341.07L56.97 340.55L54.91 339.98L52.85 339.38L50.82 338.76L48.8 338.13L46.8 337.5L44.82 336.89L42.85 336.29L40.91 335.72L38.97 335.19L37.06 334.7L35.16 334.27L33.27 333.89L31.4 333.57L29.54 333.32L27.69 333.14L25.84 333.04L24 333L22.16 333.04L20.31 333.14L18.46 333.32L16.6 333.57L14.73 333.89L12.84 334.27L10.94 334.7L9.03 335.19L7.09 335.72L5.15 336.29L3.18 336.89L1.2 337.5L-0.8 338.13L-2.82 338.76ZM-4.63 367.72L-2.64 367.29L-0.64 366.85L1.37 366.41L3.39 365.98L5.41 365.57L7.45 365.18L9.5 364.81L11.55 364.48L13.62 364.19L15.68 363.95L17.76 363.76L19.84 363.61L21.92 363.53L24 363.5L26.08 363.53L28.16 363.61L30.24 363.76L32.32 363.95L34.38 364.19L36.45 364.48L38.5 364.81L40.55 365.18L42.59 365.57L44.61 365.98L46.63 366.41L48.64 366.85L50.64 367.29L52.63 367.72L54.61 368.15L56.59 368.55L58.55 368.93L60.5 369.27L62.45 369.58L64.38 369.86L66.32 370.08L68.24 370.26L70.16 370.39L72.08 370.47L74 370.5L75.92 370.47L77.84 370.39L79.76 370.26L81.68 370.08L83.62 369.86L85.55 369.58L87.5 369.27L89.45 368.93L91.41 368.55L93.39 368.15L95.37 367.72L97.36 367.29L99.36 366.85L101.37 366.41L103.39 365.98L105.41 365.57L107.45 365.18L109.5 364.81L111.55 364.48L113.62 364.19L115.68 363.95L117.76 363.76L119.84 363.61L121.92 363.53L124 363.5L126.08 363.53L128.16 363.61L130.24 363.76L132.32 363.95L134.38 364.19L136.45 364.48L138.5 364.81L140.55 365.18L142.59 365.57L144.61 365.98L146.63 366.41L148.64 366.85L150.64 367.29L152.63 367.72L154.61 368.15L156.59 368.55L158.55 368.93L160.5 369.27L162.45 369.58L164.38 369.86L166.32 370.08L168.24 370.26L170.16 370.39L172.08 370.47L174 370.5L175.92 370.47L177.84 370.39L179.76 370.26L181.68 370.08L183.62 369.86L185.55 369.58L187.5 369.27L189.45 368.93L191.41 368.55L193.39 368.15L195.37 367.72L197.36 367.29L199.36 366.85L201.37 366.41L203.39 365.98L205.41 365.57L207.45 365.18L209.5 364.81L211.55 364.48L213.62 364.19L215.68 363.95L217.76 363.76L219.84 363.61L221.92 363.53L224 363.5L226.08 363.53L228.16 363.61L230.24 363.76L232.32 363.95L234.38 364.19L236.45 364.48L238.5 364.81L240.55 365.18L242.59 365.57L244.61 365.98L246.63 366.41L248.64 366.85L250.64 367.29L252.63 367.72L254.61 368.15L256.59 368.55L258.55 368.93L260.5 369.27L262.45 369.58L264.38 369.86L266.32 370.08L268.24 370.26L270.16 370.39L272.08 370.47L274 370.5L275.92 370.47L277.84 370.39L279.76 370.26L281.68 370.08L283.62 369.86L285.55 369.58L287.5 369.27L289.45 368.93L291.41 368.55L293.39 368.15L295.37 367.72L297.36 367.29L299.36 366.85L301.37 366.41L303.39 365.98L305.41 365.57L307.45 365.18L309.5 364.81L311.55 364.48L313.62 364.19L315.68 363.95L317.76 363.76L319.84 363.61L321.92 363.53L324 363.5L326.08 363.53L328.16 363.61L330.24 363.76L332.32 363.95L334.38 364.19L336.45 364.48L338.5 364.81L340.55 365.18L342.59 365.57L344.61 365.98L346.63 366.41L348.64 366.85L350.64 367.29L352.63 367.72L354.61 368.15L356.59 368.55L358.55 368.93L360.5 369.27L362.45 369.58L364.38 369.86L366.32 370.08L368.24 370.26L370.16 370.39L372.08 370.47L374 370.5L375.92 370.47L377.84 370.39L379.76 370.26L381.68 370.08L383.62 369.86L385.55 369.58L387.5 369.27L389.45 368.93L391.41 368.55L393.39 368.15L395.37 367.72L397.36 367.29L399.36 366.85L401.37 366.41L403.39 365.98L404.61 371.85L402.63 372.28L400.64 372.71L398.64 373.15L396.63 373.59L394.61 374.02L392.59 374.43L390.55 374.82L388.5 375.19L386.45 375.52L384.38 375.81L382.32 376.05L380.24 376.24L378.16 376.39L376.08 376.47L374 376.5L371.92 376.47L369.84 376.39L367.76 376.24L365.68 376.05L363.62 375.81L361.55 375.52L359.5 375.19L357.45 374.82L355.41 374.43L353.39 374.02L351.37 373.59L349.36 373.15L347.36 372.71L345.37 372.28L343.39 371.85L341.41 371.45L339.45 371.07L337.5 370.73L335.55 370.42L333.62 370.14L331.68 369.92L329.76 369.74L327.84 369.61L325.92 369.53L324 369.5L322.08 369.53L320.16 369.61L318.24 369.74L316.32 369.92L314.38 370.14L312.45 370.42L310.5 370.73L308.55 371.07L306.59 371.45L304.61 371.85L302.63 372.28L300.64 372.71L298.64 373.15L296.63 373.59L294.61 374.02L292.59 374.43L290.55 374.82L288.5 375.19L286.45 375.52L284.38 375.81L282.32 376.05L280.24 376.24L278.16 376.39L276.08 376.47L274 376.5L271.92 376.47L269.84 376.39L267.76 376.24L265.68 376.05L263.62 375.81L261.55 375.52L259.5 375.19L257.45 374.82L255.41 374.43L253.39 374.02L251.37 373.59L249.36 373.15L247.36 372.71L245.37 372.28L243.39 371.85L241.41 371.45L239.45 371.07L237.5 370.73L235.55 370.42L233.62 370.14L231.68 369.92L229.76 369.74L227.84 369.61L225.92 369.53L224 369.5L222.08 369.53L220.16 369.61L218.24 369.74L216.32 369.92L214.38 370.14L212.45 370.42L210.5 370.73L208.55 371.07L206.59 371.45L204.61 371.85L202.63 372.28L200.64 372.71L198.64 373.15L196.63 373.59L194.61 374.02L192.59 374.43L190.55 374.82L188.5 375.19L186.45 375.52L184.38 375.81L182.32 376.05L180.24 376.24L178.16 376.39L176.08 376.47L174 376.5L171.92 376.47L169.84 376.39L167.76 376.24L165.68 376.05L163.62 375.81L161.55 375.52L159.5 375.19L157.45 374.82L155.41 374.43L153.39 374.02L151.37 373.59L149.36 373.15L147.36 372.71L145.37 372.28L143.39 371.85L141.41 371.45L139.45 371.07L137.5 370.73L135.55 370.42L133.62 370.14L131.68 369.92L129.76 369.74L127.84 369.61L125.92 369.53L124 369.5L122.08 369.53L120.16 369.61L118.24 369.74L116.32 369.92L114.38 370.14L112.45 370.42L110.5 370.73L108.55 371.07L106.59 371.45L104.61 371.85L102.63 372.28L100.64 372.71L98.64 373.15L96.63 373.59L94.61 374.02L92.59 374.43L90.55 374.82L88.5 375.19L86.45 375.52L84.38 375.81L82.32 376.05L80.24 376.24L78.16 376.39L76.08 376.47L74 376.5L71.92 376.47L69.84 376.39L67.76 376.24L65.68 376.05L63.62 375.81L61.55 375.52L59.5 375.19L57.45 374.82L55.41 374.43L53.39 374.02L51.37 373.59L49.36 373.15L47.36 372.71L45.37 372.28L43.39 371.85L41.41 371.45L39.45 371.07L37.5 370.73L35.55 370.42L33.62 370.14L31.68 369.92L29.76 369.74L27.84 369.61L25.92 369.53L24 369.5L22.08 369.53L20.16 369.61L18.24 369.74L16.32 369.92L14.38 370.14L12.45 370.42L10.5 370.73L8.55 371.07L6.59 371.45L4.61 371.85L2.63 372.28L0.64 372.71L-1.36 373.15L-3.37 373.59Z"/>
7
+ </svg>
@@ -0,0 +1,174 @@
1
+ /**
2
+ * A shared DSH's audit archive (the server's `docs/tech/shared-dsh.md`, "The audit archive", and its ADR 0045): every
3
+ * frame between a member's device and this DSH, recorded with the member, the device and the time, sealed to a key
4
+ * only the team's admin holds, and uploaded to the server, which keeps it and cannot open it.
5
+ *
6
+ * Records collect for a minute, or until they reach 1 MiB, and become one segment: the records as JSON, HPKE-sealed
7
+ * (RFC 9180: DHKEM X25519, HKDF-SHA256, AES-256-GCM) to the audit public key, under a clear header the AEAD binds
8
+ * (host, sequence, the previous segment's SHA-256, the key's fingerprint), signed by this DSH's identity key. A
9
+ * segment is written to a queue on disk before it is uploaded, in order, so a lost connection loses nothing; the chain
10
+ * makes a dropped or altered segment show when the admin reads it (`dsh-teamwork-audit read`, src/audit-cli.ts).
11
+ * A string over 64 KiB in a frame (a file's bytes) is recorded by its length and SHA-256 only.
12
+ */
13
+ import { createHash, randomBytes } from 'node:crypto';
14
+ import { mkdir, readdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
15
+ import { dirname, join } from 'node:path';
16
+ import { Aes256Gcm, CipherSuite, DhkemX25519HkdfSha256, HkdfSha256 } from '@hpke/core';
17
+ import { z } from 'zod';
18
+ export const suite = new CipherSuite({ kem: new DhkemX25519HkdfSha256(), kdf: new HkdfSha256(), aead: new Aes256Gcm() });
19
+ export const SEGMENT_BYTES = 1 << 20;
20
+ export const SEGMENT_MS = 60 * 1000;
21
+ const LARGE_STRING = 64 * 1024;
22
+ const sha256 = (data) => createHash('sha256').update(data).digest('hex');
23
+ /** A string's UTF-8 bytes as the ArrayBuffer HPKE takes. */
24
+ export const bytesOf = (text) => { const bytes = new TextEncoder().encode(text); return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength); };
25
+ const b64 = (bytes) => Buffer.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)).toString('base64');
26
+ /** The clear header the AEAD binds: whoever opens a segment knows these were not moved between segments. */
27
+ export const segmentHeader = (s) => `dsh-teamwork audit segment\n${s.host}\n${s.seq}\n${s.prev}\n${s.key}`;
28
+ /** What this DSH signs, and the server checks before it keeps a segment (its `server/relay/archive.go`). */
29
+ export const segmentSigned = (s) => `${segmentHeader(s)}\n${sha256(`${s.enc}.${s.ct}`)}`;
30
+ export const keyFingerprint = (publicKey) => sha256(Buffer.from(publicKey, 'base64'));
31
+ /** A frame as the archive keeps it: large strings by their length and digest. */
32
+ export function recordable(value) {
33
+ if (typeof value === 'string')
34
+ return value.length > LARGE_STRING ? { omitted: value.length, sha256: sha256(value) } : value;
35
+ if (Array.isArray(value))
36
+ return value.map(recordable);
37
+ if (value && typeof value === 'object')
38
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, recordable(v)]));
39
+ return value;
40
+ }
41
+ /** The audit key, and where this host's chain stands: a different host starts its own chain. */
42
+ const stateSchema = z.object({ publicKey: z.string().optional(), host: z.string().optional(), seq: z.number().int().min(0), prev: z.string() });
43
+ export const auditArchivePath = (cachePath) => cachePath.replace(/(\.json)?$/, '.audit.json');
44
+ export class AuditArchive {
45
+ options;
46
+ state;
47
+ records = [];
48
+ bytes = 0;
49
+ timer;
50
+ sealing = Promise.resolve();
51
+ draining;
52
+ publicKey;
53
+ constructor(options) {
54
+ this.options = options;
55
+ }
56
+ get queue() { return `${this.options.path}.queue`; }
57
+ load() {
58
+ return (this.state ??= readFile(this.options.path, 'utf8').then((text) => stateSchema.parse(JSON.parse(text)), (error) => { if (error.code === 'ENOENT')
59
+ return { seq: 0, prev: '' }; throw error; }).then((state) => { this.publicKey = state.publicKey; return state; }));
60
+ }
61
+ async save(state) {
62
+ await mkdir(dirname(this.options.path), { recursive: true, mode: 0o700 });
63
+ const temporary = `${this.options.path}.${randomBytes(8).toString('hex')}.tmp`;
64
+ try {
65
+ await writeFile(temporary, JSON.stringify(state), { mode: 0o600 });
66
+ await rename(temporary, this.options.path);
67
+ }
68
+ finally {
69
+ await rm(temporary, { force: true });
70
+ }
71
+ }
72
+ /** Whether an audit key is set: a shared DSH admits no member until it is. */
73
+ async ready() { return !!(await this.load()).publicKey; }
74
+ /** The audit key's fingerprint, or undefined before one is set. */
75
+ async fingerprint() { const { publicKey } = await this.load(); return publicKey ? keyFingerprint(publicKey) : undefined; }
76
+ /** The admin's audit public key (raw X25519, base64, from `dsh-teamwork-audit keygen`). New segments are sealed to it. */
77
+ async setKey(publicKey) {
78
+ const raw = Buffer.from(publicKey.trim(), 'base64');
79
+ if (raw.length !== 32)
80
+ throw new Error('That is not an audit public key. Run dsh-teamwork-audit keygen on your own machine and paste the key it prints.');
81
+ await suite.kem.deserializePublicKey(raw.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength));
82
+ await this.flush();
83
+ this.sealing = this.sealing.then(async () => {
84
+ const state = await this.load();
85
+ state.publicKey = raw.toString('base64');
86
+ this.publicKey = state.publicKey;
87
+ await this.save(state);
88
+ });
89
+ await this.sealing;
90
+ return keyFingerprint(raw.toString('base64'));
91
+ }
92
+ /** Records one frame of a member's; nothing is recorded before an audit key is set. */
93
+ record(entry) {
94
+ if (!this.publicKey)
95
+ return;
96
+ const record = { at: new Date(this.options.now?.() ?? Date.now()).toISOString(), ...entry, frame: recordable(entry.frame) };
97
+ this.records.push(record);
98
+ this.bytes += JSON.stringify(record).length;
99
+ if (this.bytes >= SEGMENT_BYTES)
100
+ void this.flush();
101
+ else if (!this.timer) {
102
+ this.timer = setTimeout(() => void this.flush(), SEGMENT_MS);
103
+ this.timer.unref?.();
104
+ }
105
+ }
106
+ /** Seals what has collected into the next segment, queues it on disk, and uploads the queue. */
107
+ flush() {
108
+ if (this.timer)
109
+ clearTimeout(this.timer);
110
+ this.timer = undefined;
111
+ const records = this.records.splice(0);
112
+ this.bytes = 0;
113
+ if (records.length)
114
+ this.sealing = this.sealing.then(() => this.seal(records)).catch((error) => this.options.log?.(`audit archive: ${error.message}`));
115
+ return this.sealing.then(() => this.drain());
116
+ }
117
+ async seal(records) {
118
+ const state = await this.load(), host = this.options.hostId();
119
+ if (!state.publicKey || !host)
120
+ return;
121
+ if (state.host !== host)
122
+ Object.assign(state, { host, seq: 0, prev: '' });
123
+ const header = { host, seq: state.seq + 1, prev: state.prev, key: keyFingerprint(state.publicKey) };
124
+ const sender = await suite.createSenderContext({ recipientPublicKey: await suite.kem.deserializePublicKey(new Uint8Array(Buffer.from(state.publicKey, 'base64')).buffer) });
125
+ const ct = await sender.seal(bytesOf(JSON.stringify(records)), bytesOf(segmentHeader(header)));
126
+ const unsigned = { ...header, enc: b64(sender.enc), ct: b64(ct) };
127
+ const identity = await this.options.identity();
128
+ const segment = { v: 1, ...unsigned, sig: b64(await identity.privateKey.sign(new TextEncoder().encode(segmentSigned(unsigned)))) };
129
+ const body = JSON.stringify(segment);
130
+ await mkdir(this.queue, { recursive: true, mode: 0o700 });
131
+ await writeFile(join(this.queue, `${String(segment.seq).padStart(12, '0')}.json`), body, { mode: 0o600 });
132
+ await this.save({ ...state, seq: segment.seq, prev: sha256(body) });
133
+ state.seq = segment.seq;
134
+ state.prev = sha256(body);
135
+ }
136
+ /** Uploads queued segments in order; one the server refuses as out of order stops the queue and is said. */
137
+ drain() {
138
+ return (this.draining ??= (async () => {
139
+ try {
140
+ const files = (await readdir(this.queue).catch(() => [])).filter((f) => f.endsWith('.json')).sort();
141
+ for (const file of files) {
142
+ const body = await readFile(join(this.queue, file), 'utf8');
143
+ const { status } = await this.options.upload(body);
144
+ if (status === 200 || status === 201) {
145
+ await rm(join(this.queue, file), { force: true });
146
+ continue;
147
+ }
148
+ this.options.log?.(`audit archive: the server refused segment ${file} (${status}); it stays queued.`);
149
+ break;
150
+ }
151
+ }
152
+ catch (error) {
153
+ this.options.log?.(`audit archive: could not upload (${error.message}); retrying with the next segment.`);
154
+ }
155
+ finally {
156
+ this.draining = undefined;
157
+ }
158
+ })());
159
+ }
160
+ stop() { if (this.timer)
161
+ clearTimeout(this.timer); this.timer = undefined; }
162
+ /**
163
+ * Shared mode ended: what collected is sealed and sent if it can be, then the key goes, so nothing more is recorded.
164
+ * The chain's place stays: the same shared host enabled again continues its chain rather than restarting it.
165
+ */
166
+ async clear() {
167
+ await this.flush();
168
+ this.stop();
169
+ this.publicKey = undefined;
170
+ this.sealing = this.sealing.then(async () => { const state = await this.load(); delete state.publicKey; await this.save(state); });
171
+ await this.sealing;
172
+ }
173
+ }
174
+ //# sourceMappingURL=audit-archive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-archive.js","sourceRoot":"","sources":["../src/audit-archive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,qBAAqB,EAAE,EAAE,GAAG,EAAE,IAAI,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,SAAS,EAAE,EAAE,CAAC,CAAC;AACzH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC;AACrC,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC;AAK/B,MAAM,MAAM,GAAG,CAAC,IAAyB,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9F,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,GAAG,MAAM,KAAK,GAAG,IAAI,WAAW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