dsh-remote-agent 0.4.3 → 0.6.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.
package/lib/protocol.js CHANGED
@@ -25,6 +25,12 @@ export const HUB_TO_NODE = Object.freeze({
25
25
  * ed25519 身份签出(绑定双方公钥 + 连接 nonce)。中继只转发,无法伪造。
26
26
  */
27
27
  E2E_ACK: 'hub/e2e',
28
+ /**
29
+ * 远程文件请求(提案 #25):hub → node 的只读文件操作(ls/read/grep/tree)。
30
+ * 载荷 { op, ...params };reqId 用信封 id 本身,node 回 fs/res 时 replyTo 对上。
31
+ * 必须加密(E2E_REQUIRED_TYPES):目录结构 / 文件内容都是敏感信息。
32
+ */
33
+ FS_REQ: 'fs/req',
28
34
  TASK_START: 'task/start',
29
35
  TASK_CANCEL: 'task/cancel',
30
36
  TASK_QUERY: 'task/query',
@@ -60,6 +66,11 @@ export const NODE_TO_HUB = Object.freeze({
60
66
  * 旧 hub 按未知帧忽略 → 协商不成就继续明文(混跑安全)。
61
67
  */
62
68
  E2E_OFFER: 'node/e2e',
69
+ /**
70
+ * 远程文件响应(提案 #25):node → hub 的 fs/req 结果。载荷
71
+ * { replyTo, ok, result?, code?, message? }。加密发送(node→hub 默认封密)。
72
+ */
73
+ FS_RES: 'fs/res',
63
74
  PONG: 'pong',
64
75
  ERROR: 'error',
65
76
  })
@@ -137,6 +148,8 @@ export const ERROR_CODE = Object.freeze({
137
148
  ARTIFACT_MISSING: 'artifact-missing',
138
149
  ARTIFACT_TOO_LARGE: 'artifact-too-large',
139
150
  HASH_MISMATCH: 'hash-mismatch',
151
+ /** 远程文件请求超时(提案 #25):node 未在时限内回 fs/res。 */
152
+ FS_TIMEOUT: 'fs-timeout',
140
153
  /** hub 身份验证失败:指纹不匹配 / 签名无效 / nonce 对不上 / 时间戳超窗。 */
141
154
  HUB_IDENTITY_MISMATCH: 'hub-identity-mismatch',
142
155
  /** relay 模式下 hub 身份帧尚未到达(宽限窗口内),任务暂不执行。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote-agent",
3
- "version": "0.4.3",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "把另一台电脑变成你 DSH 的远程 Agent 同事:副机本地持久跑任务、独立 Agent 循环,只回传 handoff 摘要与产物清单,成品按需拉取。",
6
6
  "license": "MIT",
@@ -417,9 +417,24 @@ for (const [i, [file, why]] of MAINT_FILES.entries()) {
417
417
  /五分钟上手/.test(rootReadme) && /--doctor/.test(rootReadme) && /dsh-remote-setup/.test(rootReadme),
418
418
  'README.md 五分钟上手一节')
419
419
  check('37', 'package.json 声明了 dsh-remote-setup 的 bin 入口且文件存在',
420
- pkg.bin?.['dsh-remote-setup'] === './bin/dsh-remote-setup.js'
421
- && fs.existsSync(path.join(ROOT, 'bin', 'dsh-remote-setup.js')),
422
- 'package.json bin + bin/dsh-remote-setup.js')
420
+ // ⚠ 路径写法:**规范形态是不带 `./` 前缀**。
421
+ //
422
+ // npm 对 `bin` 里的 `./bin/x.js` 会给出警告并在发布时**自动移除前缀**:
423
+ // npm warn publish "bin[dsh-remote-setup]" script name bin/dsh-remote-setup.js
424
+ // was invalid and removed
425
+ // 那条 warn 的措辞容易误读成"这条 bin 被删了",实际是"前缀被修正了" ——
426
+ // 但它说明**写 `./` 是非规范形态**,应当避免。
427
+ //
428
+ // 这条断言原本写死 `'./bin/dsh-remote-setup.js'`,等于在保护一个
429
+ // npm 会改写掉的写法。现在接受规范形态(无前缀),并容忍带前缀的历史
430
+ // 配置 —— `npm pkg fix` 会把带前缀的改成规范形态。
431
+ (() => {
432
+ const v = pkg.bin?.['dsh-remote-setup']
433
+ if (typeof v !== 'string') return false
434
+ return v.replace(/^\.\//, '') === 'bin/dsh-remote-setup.js'
435
+ && fs.existsSync(path.join(ROOT, 'bin', 'dsh-remote-setup.js'))
436
+ })(),
437
+ 'package.json bin(规范形态:不带 ./ 前缀)+ bin/dsh-remote-setup.js')
423
438
  check('38', '生成器替用户填好 inject: [](worker 片段必须自带)',
424
439
  /inject:\s*\[\]/.test(setupLib),
425
440
  'lib/setup.js buildWorkerYaml')
@@ -185,14 +185,14 @@ try {
185
185
  }
186
186
 
187
187
  if (applyHub) {
188
- // 4a. inject 齐全 → 不抛,且 8 个工具都在
188
+ // 4a. inject 齐全 → 不抛,且 12 个工具都在(8 任务 + 4 文件,提案 #25)
189
189
  try {
190
190
  const ctx = fakeCtx(declared)
191
191
  applyHub(ctx, { role: 'hub', nodeToken: 'nt_diag' })
192
192
  check('inject 齐全时 applyHub 不抛', true)
193
193
  check(
194
- 'inject 齐全时注册 8 个 remote_* 工具',
195
- ctx.registered.tools.length === 8,
194
+ 'inject 齐全时注册 12 个 remote_* 工具',
195
+ ctx.registered.tools.length === 12,
196
196
  `实际 ${ctx.registered.tools.length} 个:${ctx.registered.tools.join(', ') || '(无)'}`,
197
197
  )
198
198
  check('inject 齐全时注册了路由', ctx.registered.routes.length > 0, `${ctx.registered.routes.length} 条`)