@oyasmi/pipiclaw 0.9.4 → 0.9.5-beta.3

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 (531) hide show
  1. package/README.en.md +35 -31
  2. package/README.md +34 -30
  3. package/dist/agent/builtin-commands.d.ts +7 -2
  4. package/dist/agent/builtin-commands.js +19 -23
  5. package/dist/agent/channel-runner.d.ts +23 -35
  6. package/dist/agent/channel-runner.js +150 -89
  7. package/dist/agent/maintenance-context.d.ts +8 -5
  8. package/dist/agent/maintenance-context.js +30 -15
  9. package/dist/agent/prompt/manifest.js +1 -1
  10. package/dist/agent/prompt/resources.d.ts +1 -1
  11. package/dist/agent/prompt/resources.js +1 -1
  12. package/dist/agent/prompt/sections.js +11 -9
  13. package/dist/agent/prompt/types.d.ts +1 -1
  14. package/dist/agent/runner-factory.d.ts +6 -6
  15. package/dist/agent/runner-factory.js +7 -8
  16. package/dist/agent/session/command-extension.js +11 -0
  17. package/dist/agent/session/compaction-input.d.ts +6 -0
  18. package/dist/agent/session/compaction-input.js +75 -0
  19. package/dist/agent/session/compaction-snapshot.d.ts +30 -0
  20. package/dist/agent/session/compaction-snapshot.js +154 -0
  21. package/dist/agent/session/compaction-summary.d.ts +39 -0
  22. package/dist/agent/session/compaction-summary.js +162 -0
  23. package/dist/agent/session/compaction.d.ts +35 -0
  24. package/dist/agent/session/compaction.js +294 -0
  25. package/dist/agent/session/context-input.d.ts +15 -0
  26. package/dist/agent/session/context-input.js +82 -0
  27. package/dist/agent/session/context-snapshot.d.ts +11 -0
  28. package/dist/agent/session/context-snapshot.js +72 -0
  29. package/dist/agent/session/event-guards.d.ts +2 -0
  30. package/dist/agent/session/event-guards.js +4 -0
  31. package/dist/agent/session/execution-trace.d.ts +14 -0
  32. package/dist/agent/session/execution-trace.js +57 -0
  33. package/dist/agent/session/request-tools.d.ts +3 -0
  34. package/dist/agent/session/request-tools.js +20 -0
  35. package/dist/agent/session/session-adapter.d.ts +2 -1
  36. package/dist/agent/session/session-adapter.js +6 -3
  37. package/dist/agent/session/session-events.d.ts +4 -8
  38. package/dist/agent/session/session-events.js +80 -70
  39. package/dist/agent/session/session-host.d.ts +39 -61
  40. package/dist/agent/session/session-host.js +122 -124
  41. package/dist/agent/session/settings-diagnostics.d.ts +5 -0
  42. package/dist/agent/session/settings-diagnostics.js +21 -0
  43. package/dist/agent/status-render.js +5 -2
  44. package/dist/{runtime → agent}/stop-watchdog.d.ts +3 -1
  45. package/dist/{runtime → agent}/stop-watchdog.js +7 -3
  46. package/dist/agent/turn/progress-formatter.d.ts +1 -3
  47. package/dist/agent/turn/progress-formatter.js +3 -22
  48. package/dist/agent/turn/task-digest.d.ts +5 -4
  49. package/dist/agent/turn/task-digest.js +37 -34
  50. package/dist/agent/turn/turn-context.d.ts +12 -8
  51. package/dist/agent/turn/turn-context.js +27 -19
  52. package/dist/agent/turn/turn-finish.d.ts +18 -6
  53. package/dist/agent/turn/turn-finish.js +52 -77
  54. package/dist/agent/turn/turn-input.d.ts +2 -2
  55. package/dist/agent/turn/turn-input.js +4 -3
  56. package/dist/agent/turn/turn-output.d.ts +19 -0
  57. package/dist/agent/turn/turn-output.js +41 -0
  58. package/dist/agent/turn/turn-pipeline.d.ts +15 -10
  59. package/dist/agent/turn/turn-pipeline.js +86 -59
  60. package/dist/agent/turn/turn-prompt.d.ts +1 -1
  61. package/dist/agent/turn/turn-recovery.d.ts +11 -10
  62. package/dist/agent/turn/turn-recovery.js +14 -29
  63. package/dist/agent/types.d.ts +93 -24
  64. package/dist/agent/types.js +5 -1
  65. package/dist/app/auth-command.js +1 -1
  66. package/dist/app/home.js +34 -19
  67. package/dist/channel/active-session-store.d.ts +14 -12
  68. package/dist/channel/active-session-store.js +29 -25
  69. package/dist/channel/attachments.d.ts +25 -0
  70. package/dist/channel/attachments.js +56 -0
  71. package/dist/channel/channel-context.d.ts +87 -96
  72. package/dist/channel/channel-context.js +1 -66
  73. package/dist/channel/channel-event.d.ts +49 -47
  74. package/dist/channel/channel-event.js +6 -11
  75. package/dist/channel/channel-id.d.ts +22 -0
  76. package/dist/channel/channel-id.js +13 -0
  77. package/dist/channel/channel-index.d.ts +17 -34
  78. package/dist/channel/channel-index.js +41 -80
  79. package/dist/channel/config.d.ts +10 -0
  80. package/dist/channel/config.js +55 -0
  81. package/dist/channel/ingress.d.ts +93 -0
  82. package/dist/channel/ingress.js +5 -0
  83. package/dist/channel/store.d.ts +14 -16
  84. package/dist/channel/store.js +21 -25
  85. package/dist/channel/transport.d.ts +99 -0
  86. package/dist/channel/turn-context.d.ts +23 -0
  87. package/dist/channel/turn-context.js +1 -0
  88. package/dist/commands/catalog.d.ts +4 -7
  89. package/dist/commands/catalog.js +48 -49
  90. package/dist/commands/router.d.ts +28 -14
  91. package/dist/commands/router.js +30 -27
  92. package/dist/config/settings.d.ts +8 -14
  93. package/dist/config/settings.js +0 -7
  94. package/dist/config/tools.d.ts +2 -2
  95. package/dist/config/tools.js +2 -2
  96. package/dist/desk/bindings.d.ts +6 -0
  97. package/dist/desk/bindings.js +105 -0
  98. package/dist/desk/commands.d.ts +81 -0
  99. package/dist/desk/commands.js +145 -0
  100. package/dist/desk/default.d.ts +4 -0
  101. package/dist/desk/default.js +11 -0
  102. package/dist/desk/paths.d.ts +41 -0
  103. package/dist/desk/paths.js +81 -0
  104. package/dist/desk/registry.d.ts +17 -0
  105. package/dist/desk/registry.js +191 -0
  106. package/dist/desk/startup-error.d.ts +4 -0
  107. package/dist/desk/startup-error.js +7 -0
  108. package/dist/desk/types.d.ts +72 -0
  109. package/dist/desk/types.js +7 -0
  110. package/dist/dingtalk/bot.d.ts +20 -35
  111. package/dist/dingtalk/bot.js +25 -204
  112. package/dist/dingtalk/cards.d.ts +7 -0
  113. package/dist/dingtalk/cards.js +32 -2
  114. package/dist/dingtalk/channel-ids.d.ts +15 -0
  115. package/dist/dingtalk/channel-ids.js +39 -0
  116. package/dist/dingtalk/config.d.ts +6 -3
  117. package/dist/dingtalk/config.js +13 -25
  118. package/dist/dingtalk/connection.d.ts +1 -0
  119. package/dist/dingtalk/connection.js +5 -4
  120. package/dist/dingtalk/conversation-meta.d.ts +10 -5
  121. package/dist/dingtalk/conversation-meta.js +72 -50
  122. package/dist/dingtalk/delivery.d.ts +34 -14
  123. package/dist/dingtalk/delivery.js +332 -190
  124. package/dist/dingtalk/inbound-media.d.ts +2 -18
  125. package/dist/dingtalk/inbound-media.js +0 -53
  126. package/dist/dingtalk/inbound.d.ts +10 -11
  127. package/dist/dingtalk/inbound.js +12 -19
  128. package/dist/dingtalk/media.d.ts +9 -11
  129. package/dist/dingtalk/media.js +18 -31
  130. package/dist/dingtalk/progress.d.ts +57 -0
  131. package/dist/dingtalk/progress.js +199 -0
  132. package/dist/dingtalk/response-mode.d.ts +13 -0
  133. package/dist/dingtalk/response-mode.js +31 -0
  134. package/dist/dingtalk/transport.d.ts +47 -0
  135. package/dist/dingtalk/transport.js +71 -0
  136. package/dist/events/commands.d.ts +7 -2
  137. package/dist/events/commands.js +40 -22
  138. package/dist/events/pre-action-error.d.ts +10 -0
  139. package/dist/events/pre-action-error.js +10 -0
  140. package/dist/events/types.d.ts +20 -2
  141. package/dist/events/watcher.d.ts +14 -7
  142. package/dist/events/watcher.js +49 -26
  143. package/dist/file-store.d.ts +4 -0
  144. package/dist/file-store.js +6 -1
  145. package/dist/index.d.ts +4 -2
  146. package/dist/jobs/completion-observer.d.ts +20 -0
  147. package/dist/jobs/completion-observer.js +107 -0
  148. package/dist/jobs/completion-signal.d.ts +9 -0
  149. package/dist/jobs/completion-signal.js +32 -0
  150. package/dist/jobs/completion-wake.d.ts +14 -0
  151. package/dist/jobs/completion-wake.js +25 -0
  152. package/dist/jobs/manager.d.ts +29 -42
  153. package/dist/jobs/manager.js +130 -236
  154. package/dist/jobs/probe.d.ts +3 -0
  155. package/dist/jobs/probe.js +42 -0
  156. package/dist/jobs/record.d.ts +5 -6
  157. package/dist/jobs/record.js +2 -0
  158. package/dist/jobs/runtime.d.ts +28 -0
  159. package/dist/jobs/runtime.js +69 -0
  160. package/dist/log.d.ts +0 -1
  161. package/dist/log.js +1 -1
  162. package/dist/main.js +10 -3
  163. package/dist/memory/boundary-work.d.ts +19 -0
  164. package/dist/memory/boundary-work.js +204 -0
  165. package/dist/memory/commands.d.ts +4 -3
  166. package/dist/memory/commands.js +20 -17
  167. package/dist/memory/desk-memory-queue.d.ts +18 -0
  168. package/dist/memory/desk-memory-queue.js +33 -0
  169. package/dist/memory/index-budget.d.ts +3 -3
  170. package/dist/memory/index-budget.js +21 -18
  171. package/dist/memory/journal.d.ts +6 -6
  172. package/dist/memory/journal.js +16 -15
  173. package/dist/memory/lifecycle.d.ts +17 -28
  174. package/dist/memory/lifecycle.js +87 -147
  175. package/dist/memory/maintenance-state.d.ts +14 -15
  176. package/dist/memory/maintenance-state.js +43 -42
  177. package/dist/memory/reflect-job.d.ts +5 -10
  178. package/dist/memory/reflect-job.js +29 -44
  179. package/dist/memory/reflect.d.ts +6 -1
  180. package/dist/memory/reflect.js +44 -16
  181. package/dist/memory/render.d.ts +1 -1
  182. package/dist/memory/render.js +2 -2
  183. package/dist/memory/review-log.d.ts +17 -4
  184. package/dist/memory/review-log.js +54 -5
  185. package/dist/memory/scheduler.d.ts +12 -19
  186. package/dist/memory/scheduler.js +28 -64
  187. package/dist/memory/search.js +7 -4
  188. package/dist/memory/session-corpus.d.ts +4 -1
  189. package/dist/memory/session-corpus.js +70 -29
  190. package/dist/memory/session-search.d.ts +11 -3
  191. package/dist/memory/session-search.js +14 -11
  192. package/dist/memory/sidecar-worker.d.ts +1 -0
  193. package/dist/memory/sidecar-worker.js +57 -76
  194. package/dist/memory/source-window.d.ts +18 -7
  195. package/dist/memory/source-window.js +59 -29
  196. package/dist/memory/store.d.ts +14 -12
  197. package/dist/memory/store.js +89 -57
  198. package/dist/paths.d.ts +2 -0
  199. package/dist/paths.js +2 -0
  200. package/dist/playbooks/agent-delegation.md +23 -17
  201. package/dist/playbooks/background-jobs.md +7 -5
  202. package/dist/playbooks/event-scheduling.md +9 -7
  203. package/dist/playbooks/memory-and-learning.md +18 -14
  204. package/dist/playbooks/outbound-media.md +3 -3
  205. package/dist/playbooks/runtime-orientation.md +39 -23
  206. package/dist/playbooks/task-lead.md +57 -34
  207. package/dist/runtime/bootstrap.d.ts +45 -35
  208. package/dist/runtime/bootstrap.js +372 -167
  209. package/dist/runtime/channel-queue.d.ts +25 -0
  210. package/dist/{dingtalk → runtime}/channel-queue.js +25 -10
  211. package/dist/runtime/daemon-lock.d.ts +12 -0
  212. package/dist/runtime/daemon-lock.js +28 -0
  213. package/dist/runtime/desk-runtime.d.ts +131 -0
  214. package/dist/runtime/desk-runtime.js +402 -0
  215. package/dist/runtime/durable-dispatch.d.ts +18 -5
  216. package/dist/runtime/durable-dispatch.js +85 -14
  217. package/dist/runtime/inbound-images.d.ts +32 -10
  218. package/dist/runtime/inbound-images.js +95 -21
  219. package/dist/runtime/ingress-busy.d.ts +25 -0
  220. package/dist/runtime/ingress-busy.js +178 -0
  221. package/dist/runtime/ingress-commands.d.ts +7 -0
  222. package/dist/runtime/ingress-commands.js +170 -0
  223. package/dist/runtime/ingress-deps.d.ts +59 -0
  224. package/dist/runtime/ingress-deps.js +1 -0
  225. package/dist/runtime/ingress.d.ts +22 -0
  226. package/dist/runtime/ingress.js +386 -0
  227. package/dist/runtime/request-execution.d.ts +19 -0
  228. package/dist/runtime/request-execution.js +88 -0
  229. package/dist/runtime/shutdown.d.ts +14 -6
  230. package/dist/runtime/shutdown.js +11 -5
  231. package/dist/runtime/task-close.d.ts +4 -0
  232. package/dist/runtime/task-close.js +102 -0
  233. package/dist/runtime/task-control.d.ts +34 -0
  234. package/dist/runtime/task-control.js +225 -0
  235. package/dist/runtime/task-input.d.ts +13 -0
  236. package/dist/runtime/task-input.js +129 -0
  237. package/dist/runtime/task-lane-types.d.ts +123 -0
  238. package/dist/runtime/task-lane-types.js +14 -0
  239. package/dist/runtime/task-lane.d.ts +99 -0
  240. package/dist/runtime/task-lane.js +703 -0
  241. package/dist/runtime/task-pending.d.ts +8 -0
  242. package/dist/runtime/task-pending.js +40 -0
  243. package/dist/runtime/task-spawn.d.ts +8 -8
  244. package/dist/runtime/task-spawn.js +10 -9
  245. package/dist/runtime/task-step.d.ts +32 -0
  246. package/dist/runtime/task-step.js +276 -0
  247. package/dist/runtime/transports.d.ts +32 -0
  248. package/dist/runtime/transports.js +101 -0
  249. package/dist/runtime/turn-run.d.ts +20 -23
  250. package/dist/runtime/turn-run.js +252 -159
  251. package/dist/runtime/wake-coalescing.d.ts +12 -6
  252. package/dist/runtime/wake-coalescing.js +12 -4
  253. package/dist/security/config.js +5 -10
  254. package/dist/security/logger.js +1 -1
  255. package/dist/security/path-guard.js +7 -63
  256. package/dist/security/types.d.ts +27 -30
  257. package/dist/security/types.js +0 -1
  258. package/dist/shared/atomic-file.d.ts +2 -0
  259. package/dist/shared/atomic-file.js +14 -1
  260. package/dist/shared/file-lock.d.ts +35 -0
  261. package/dist/shared/file-lock.js +195 -0
  262. package/dist/shared/format.d.ts +0 -6
  263. package/dist/shared/format.js +0 -17
  264. package/dist/shared/host-process.d.ts +2 -0
  265. package/dist/shared/host-process.js +16 -1
  266. package/dist/shared/jsonl-appender.d.ts +5 -0
  267. package/dist/shared/jsonl-appender.js +25 -2
  268. package/dist/shared/with-timeout.d.ts +2 -0
  269. package/dist/shared/with-timeout.js +21 -0
  270. package/dist/skills/catalog.d.ts +9 -0
  271. package/dist/skills/catalog.js +34 -0
  272. package/dist/skills/commands.d.ts +3 -12
  273. package/dist/skills/commands.js +36 -22
  274. package/dist/skills/loader.d.ts +2 -31
  275. package/dist/skills/loader.js +101 -68
  276. package/dist/skills/roots.d.ts +12 -0
  277. package/dist/skills/roots.js +18 -0
  278. package/dist/skills/types.d.ts +24 -0
  279. package/dist/skills/types.js +1 -0
  280. package/dist/subagents/completion-wake.d.ts +11 -2
  281. package/dist/subagents/completion-wake.js +21 -18
  282. package/dist/subagents/discovery.d.ts +1 -1
  283. package/dist/subagents/discovery.js +10 -16
  284. package/dist/subagents/dispatch.d.ts +0 -10
  285. package/dist/subagents/dispatch.js +18 -44
  286. package/dist/subagents/external/cursor-cli.d.ts +2 -0
  287. package/dist/subagents/external/cursor-cli.js +256 -0
  288. package/dist/subagents/external/dispatch.js +1 -1
  289. package/dist/subagents/external/harness.d.ts +5 -5
  290. package/dist/subagents/external/reconciliation.d.ts +7 -0
  291. package/dist/subagents/external/reconciliation.js +105 -0
  292. package/dist/subagents/external/recovery.d.ts +20 -0
  293. package/dist/subagents/external/recovery.js +71 -0
  294. package/dist/subagents/external/registry.js +2 -0
  295. package/dist/subagents/external/role-warnings.d.ts +17 -0
  296. package/dist/subagents/external/role-warnings.js +42 -0
  297. package/dist/subagents/external/run.d.ts +1 -1
  298. package/dist/subagents/external/run.js +21 -25
  299. package/dist/subagents/format.d.ts +1 -1
  300. package/dist/subagents/format.js +1 -1
  301. package/dist/subagents/grace.d.ts +2 -2
  302. package/dist/subagents/grace.js +3 -3
  303. package/dist/subagents/internal/run.js +8 -6
  304. package/dist/subagents/internal/worker.js +37 -16
  305. package/dist/subagents/result.js +2 -3
  306. package/dist/subagents/run-archive.d.ts +11 -0
  307. package/dist/subagents/run-archive.js +49 -0
  308. package/dist/subagents/run-record.d.ts +13 -15
  309. package/dist/subagents/run-record.js +5 -5
  310. package/dist/subagents/run-registry.d.ts +5 -3
  311. package/dist/subagents/run-registry.js +22 -45
  312. package/dist/subagents/runs.d.ts +51 -54
  313. package/dist/subagents/runs.js +178 -304
  314. package/dist/subagents/task-envelope.js +9 -11
  315. package/dist/subagents/task-settlement.d.ts +3 -0
  316. package/dist/subagents/task-settlement.js +20 -0
  317. package/dist/subagents/types.d.ts +7 -7
  318. package/dist/subagents/workspace-summary.js +5 -1
  319. package/dist/tasks/archive.d.ts +11 -0
  320. package/dist/tasks/archive.js +141 -0
  321. package/dist/tasks/board.d.ts +5 -12
  322. package/dist/tasks/board.js +4 -30
  323. package/dist/tasks/bound-work.d.ts +13 -7
  324. package/dist/tasks/bound-work.js +41 -28
  325. package/dist/tasks/brief.d.ts +39 -15
  326. package/dist/tasks/brief.js +131 -73
  327. package/dist/tasks/budget.d.ts +3 -3
  328. package/dist/tasks/budget.js +9 -4
  329. package/dist/tasks/commands.d.ts +24 -10
  330. package/dist/tasks/commands.js +225 -131
  331. package/dist/tasks/completion.d.ts +12 -0
  332. package/dist/tasks/completion.js +35 -0
  333. package/dist/tasks/contract.d.ts +8 -19
  334. package/dist/tasks/contract.js +41 -45
  335. package/dist/tasks/control.d.ts +138 -0
  336. package/dist/tasks/control.js +1 -0
  337. package/dist/tasks/create.d.ts +4 -2
  338. package/dist/tasks/create.js +13 -7
  339. package/dist/tasks/delivery.d.ts +24 -0
  340. package/dist/tasks/delivery.js +221 -0
  341. package/dist/tasks/file-mutation.d.ts +5 -0
  342. package/dist/tasks/file-mutation.js +38 -0
  343. package/dist/tasks/frontmatter.d.ts +46 -27
  344. package/dist/tasks/frontmatter.js +90 -47
  345. package/dist/tasks/input-receipts.d.ts +7 -0
  346. package/dist/tasks/input-receipts.js +60 -0
  347. package/dist/tasks/loop-log.d.ts +150 -37
  348. package/dist/tasks/loop-log.js +250 -42
  349. package/dist/tasks/mutation-lock.d.ts +7 -5
  350. package/dist/tasks/mutation-lock.js +32 -9
  351. package/dist/tasks/receipts.d.ts +19 -0
  352. package/dist/tasks/receipts.js +48 -0
  353. package/dist/tasks/session-path.d.ts +3 -3
  354. package/dist/tasks/session-path.js +5 -5
  355. package/dist/tasks/state.d.ts +93 -0
  356. package/dist/tasks/state.js +156 -0
  357. package/dist/tasks/store.d.ts +86 -54
  358. package/dist/tasks/store.js +256 -156
  359. package/dist/tools/bash.d.ts +8 -10
  360. package/dist/tools/bash.js +27 -40
  361. package/dist/tools/contract/details.d.ts +6 -6
  362. package/dist/tools/contract/details.js +6 -6
  363. package/dist/tools/contract/execution-trace.d.ts +4 -0
  364. package/dist/tools/contract/execution-trace.js +23 -0
  365. package/dist/tools/contract/names.d.ts +7 -0
  366. package/dist/tools/contract/names.js +22 -0
  367. package/dist/tools/contract/presentation.js +6 -2
  368. package/dist/tools/edit.d.ts +1 -0
  369. package/dist/tools/edit.js +46 -43
  370. package/dist/tools/event-manage.d.ts +3 -1
  371. package/dist/tools/event-manage.js +34 -33
  372. package/dist/tools/glob.js +5 -5
  373. package/dist/tools/grep.js +2 -2
  374. package/dist/tools/index.d.ts +17 -20
  375. package/dist/tools/index.js +28 -22
  376. package/dist/tools/job.d.ts +4 -2
  377. package/dist/tools/job.js +11 -8
  378. package/dist/tools/memory-manage.d.ts +5 -3
  379. package/dist/tools/memory-manage.js +32 -25
  380. package/dist/tools/read.js +1 -1
  381. package/dist/tools/registry.d.ts +19 -19
  382. package/dist/tools/registry.js +65 -34
  383. package/dist/tools/send-media.d.ts +2 -2
  384. package/dist/tools/send-media.js +3 -3
  385. package/dist/tools/session-search.d.ts +3 -1
  386. package/dist/tools/session-search.js +8 -6
  387. package/dist/tools/skill.d.ts +2 -2
  388. package/dist/tools/skill.js +24 -10
  389. package/dist/tools/subagent-manage.d.ts +2 -8
  390. package/dist/tools/subagent-manage.js +26 -19
  391. package/dist/tools/subagent.d.ts +0 -2
  392. package/dist/tools/subagent.js +3 -8
  393. package/dist/tools/task-manage/control-tools.d.ts +4 -0
  394. package/dist/tools/task-manage/control-tools.js +65 -0
  395. package/dist/tools/task-manage/create.js +3 -2
  396. package/dist/tools/task-manage/factory.d.ts +12 -6
  397. package/dist/tools/task-manage/factory.js +73 -58
  398. package/dist/tools/task-manage/lifecycle.d.ts +7 -12
  399. package/dist/tools/task-manage/lifecycle.js +119 -65
  400. package/dist/tools/task-manage/log-view.js +10 -7
  401. package/dist/tools/task-manage/schema.d.ts +21 -26
  402. package/dist/tools/task-manage/schema.js +29 -35
  403. package/dist/tools/task-manage/shared.d.ts +8 -39
  404. package/dist/tools/task-manage/shared.js +20 -69
  405. package/dist/tools/task-manage/step-tools.d.ts +5 -0
  406. package/dist/tools/task-manage/step-tools.js +103 -0
  407. package/dist/tools/task-manage/types.d.ts +33 -21
  408. package/dist/tools/web-cache.d.ts +3 -3
  409. package/dist/tools/web-cache.js +12 -12
  410. package/dist/tools/web-fetch.d.ts +2 -2
  411. package/dist/tools/web-fetch.js +7 -7
  412. package/dist/tools/write-content.d.ts +1 -0
  413. package/dist/tools/write-content.js +7 -2
  414. package/dist/tools/write.d.ts +1 -0
  415. package/dist/tools/write.js +1 -0
  416. package/dist/tui/cli.d.ts +17 -5
  417. package/dist/tui/cli.js +90 -27
  418. package/dist/tui/client.d.ts +26 -0
  419. package/dist/tui/client.js +157 -0
  420. package/dist/tui/colors.d.ts +0 -1
  421. package/dist/tui/colors.js +0 -1
  422. package/dist/tui/commands.d.ts +10 -51
  423. package/dist/tui/commands.js +16 -39
  424. package/dist/tui/frontend.d.ts +2 -2
  425. package/dist/tui/frontend.js +2 -2
  426. package/dist/tui/pitui-frontend.d.ts +0 -2
  427. package/dist/tui/pitui-frontend.js +1 -6
  428. package/dist/tui/render.d.ts +62 -0
  429. package/dist/tui/render.js +123 -0
  430. package/dist/tui/session.d.ts +92 -0
  431. package/dist/tui/session.js +317 -0
  432. package/dist/usage/ledger.d.ts +9 -4
  433. package/dist/usage/ledger.js +2 -0
  434. package/dist/usage/render.d.ts +6 -1
  435. package/dist/usage/render.js +20 -15
  436. package/dist/web/search-providers.js +0 -33
  437. package/dist/webapi/auth.d.ts +13 -0
  438. package/dist/webapi/auth.js +29 -0
  439. package/dist/webapi/config.d.ts +29 -0
  440. package/dist/webapi/config.js +100 -0
  441. package/dist/webapi/errors.d.ts +39 -0
  442. package/dist/webapi/errors.js +32 -0
  443. package/dist/webapi/http.d.ts +25 -0
  444. package/dist/webapi/http.js +4 -0
  445. package/dist/webapi/ids.d.ts +9 -0
  446. package/dist/webapi/ids.js +20 -0
  447. package/dist/webapi/input.d.ts +17 -0
  448. package/dist/webapi/input.js +229 -0
  449. package/dist/webapi/items.d.ts +37 -0
  450. package/dist/webapi/items.js +48 -0
  451. package/dist/webapi/key-command.d.ts +2 -0
  452. package/dist/webapi/key-command.js +110 -0
  453. package/dist/webapi/limits.d.ts +47 -0
  454. package/dist/webapi/limits.js +48 -0
  455. package/dist/webapi/request-policy.d.ts +17 -0
  456. package/dist/webapi/request-policy.js +160 -0
  457. package/dist/webapi/response-record.d.ts +68 -0
  458. package/dist/webapi/response-record.js +58 -0
  459. package/dist/webapi/response-state.d.ts +90 -0
  460. package/dist/webapi/response-state.js +347 -0
  461. package/dist/webapi/routes/conversations.d.ts +8 -0
  462. package/dist/webapi/routes/conversations.js +80 -0
  463. package/dist/webapi/routes/models.d.ts +3 -0
  464. package/dist/webapi/routes/models.js +12 -0
  465. package/dist/webapi/routes/responses.d.ts +8 -0
  466. package/dist/webapi/routes/responses.js +118 -0
  467. package/dist/webapi/routes/websocket.d.ts +9 -0
  468. package/dist/webapi/routes/websocket.js +328 -0
  469. package/dist/webapi/server.d.ts +24 -0
  470. package/dist/webapi/server.js +229 -0
  471. package/dist/webapi/service.d.ts +130 -0
  472. package/dist/webapi/service.js +588 -0
  473. package/dist/webapi/store.d.ts +46 -0
  474. package/dist/webapi/store.js +245 -0
  475. package/dist/webapi/stream.d.ts +13 -0
  476. package/dist/webapi/stream.js +76 -0
  477. package/dist/webapi/transport.d.ts +43 -0
  478. package/dist/webapi/transport.js +100 -0
  479. package/examples/sub-agents/README.md +23 -16
  480. package/examples/sub-agents/agents/claude-high.md +1 -1
  481. package/examples/sub-agents/agents/claude-main.md +1 -1
  482. package/examples/sub-agents/agents/codex-flash.md +1 -1
  483. package/examples/sub-agents/agents/codex-high.md +1 -1
  484. package/examples/sub-agents/agents/codex-main.md +4 -4
  485. package/examples/sub-agents/agents/cursor-high.md +22 -0
  486. package/examples/sub-agents/agents/cursor-main.md +22 -0
  487. package/examples/sub-agents/agents/glm-flash.md +1 -1
  488. package/examples/sub-agents/agents/glm-high.md +2 -2
  489. package/examples/sub-agents/agents/scout.md +30 -0
  490. package/package.json +13 -7
  491. package/dist/channel/channel-paths.d.ts +0 -16
  492. package/dist/channel/channel-paths.js +0 -53
  493. package/dist/channel/commands.d.ts +0 -32
  494. package/dist/channel/commands.js +0 -109
  495. package/dist/channel/project-scope-store.d.ts +0 -51
  496. package/dist/channel/project-scope-store.js +0 -112
  497. package/dist/dingtalk/channel-queue.d.ts +0 -19
  498. package/dist/dingtalk/handler.d.ts +0 -90
  499. package/dist/memory/channel-maintenance-queue.d.ts +0 -5
  500. package/dist/memory/channel-maintenance-queue.js +0 -8
  501. package/dist/runtime/task-driver.d.ts +0 -100
  502. package/dist/runtime/task-driver.js +0 -417
  503. package/dist/runtime/task-migration.d.ts +0 -30
  504. package/dist/runtime/task-migration.js +0 -465
  505. package/dist/runtime/task-wake.d.ts +0 -46
  506. package/dist/runtime/task-wake.js +0 -32
  507. package/dist/runtime/turn-handler.d.ts +0 -47
  508. package/dist/runtime/turn-handler.js +0 -318
  509. package/dist/security/project-scope.d.ts +0 -45
  510. package/dist/security/project-scope.js +0 -105
  511. package/dist/shared/wake-claim.d.ts +0 -23
  512. package/dist/shared/wake-claim.js +0 -26
  513. package/dist/skills/validation.d.ts +0 -8
  514. package/dist/skills/validation.js +0 -91
  515. package/dist/skills/workspace.d.ts +0 -33
  516. package/dist/skills/workspace.js +0 -116
  517. package/dist/tasks/steer.d.ts +0 -8
  518. package/dist/tasks/steer.js +0 -79
  519. package/dist/tasks/ticket.d.ts +0 -71
  520. package/dist/tasks/ticket.js +0 -138
  521. package/dist/tools/task-manage/step-end.d.ts +0 -11
  522. package/dist/tools/task-manage/step-end.js +0 -117
  523. package/dist/tui/app.d.ts +0 -16
  524. package/dist/tui/app.js +0 -166
  525. package/dist/tui/terminal-context.d.ts +0 -27
  526. package/dist/tui/terminal-context.js +0 -84
  527. package/dist/tui/terminal-media-sender.d.ts +0 -9
  528. package/dist/tui/terminal-media-sender.js +0 -15
  529. package/dist/tui/turn-controller.d.ts +0 -64
  530. package/dist/tui/turn-controller.js +0 -311
  531. /package/dist/{dingtalk/handler.js → channel/transport.js} +0 -0
@@ -0,0 +1,34 @@
1
+ /** On-demand catalog reads, shared by the skill tool and /skills. */
2
+ import { readFile } from "node:fs/promises";
3
+ import { checkPathGuard } from "../security/path-guard-check.js";
4
+ import { RecoverableToolError } from "../shared/recoverable-error.js";
5
+ import { errorMessage } from "../shared/text-utils.js";
6
+ import { loadPipiclawSkills } from "./loader.js";
7
+ import { skillSecurity } from "./roots.js";
8
+ export async function loadSkillFile(options, name, inspectRejected = false) {
9
+ const catalog = loadPipiclawSkills(options);
10
+ const skill = catalog.skills.find((item) => item.name === name);
11
+ const rejected = inspectRejected
12
+ ? catalog.diagnostics.find((item) => item.rejected && item.name === name && item.path)
13
+ : undefined;
14
+ const path = skill?.filePath ?? rejected?.path;
15
+ if (!path) {
16
+ throw new RecoverableToolError(`Skill "${name}" does not exist or could not be loaded. Use action "list" to inspect skills and diagnostics.`);
17
+ }
18
+ const { securityConfig, securityContext } = skillSecurity(options);
19
+ const target = await checkPathGuard(path, "read", securityConfig, securityContext, {
20
+ tool: "skill",
21
+ channelId: options.channelId,
22
+ });
23
+ let content;
24
+ try {
25
+ content = await readFile(target, "utf-8");
26
+ }
27
+ catch (error) {
28
+ throw new RecoverableToolError(`Skill "${name}" could not be read: ${errorMessage(error)}. Use action "list" to refresh the catalog before retrying.`);
29
+ }
30
+ return { name, path: target, source: (skill ?? rejected).source, content, loaded: !!skill };
31
+ }
32
+ export function skillSourceLabel(source) {
33
+ return source === "workspace" ? "工作区" : "用户共享";
34
+ }
@@ -1,15 +1,6 @@
1
- /**
2
- * `/skills` — the human control path for a workspace's skill catalog (spec 045's read-only
3
- * `skill` tool has no channel-command counterpart until now). Mirrors `channel/commands.ts`'s
4
- * shape: pure-ish functions returning markdown, no bot/event coupling.
5
- *
6
- * Deliberately a disk scan via `listWorkspaceSkills`, not the live `ChannelRunner`'s already-
7
- * loaded catalog: that keeps `/skills` usable while a turn is streaming and for a channel with no
8
- * active runner, and — the whole reason this exists rather than reusing `/help`'s discovery tail
9
- * — it is the only place that shows a skill that failed the content scan and was silently dropped
10
- * from the prompt's skill list (`src/skills/loader.ts`).
11
- */
12
- export interface HandleSkillsCommandOptions {
1
+ import type { SkillOptions } from "./types.js";
2
+ /** Stateless disk inspection remains usable without an active session. */
3
+ export interface HandleSkillsCommandOptions extends Pick<SkillOptions, "sharedSkillsDir"> {
13
4
  args: string;
14
5
  workspaceDir: string;
15
6
  appHomeDir: string;
@@ -4,7 +4,8 @@ import { GuardBlockedError, renderGuardBlockForUser } from "../security/block-me
4
4
  import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
5
5
  import { RecoverableToolError } from "../shared/recoverable-error.js";
6
6
  import { errorMessage } from "../shared/text-utils.js";
7
- import { listWorkspaceSkills, loadWorkspaceSkillFile } from "./workspace.js";
7
+ import { loadSkillFile, skillSourceLabel } from "./catalog.js";
8
+ import { loadPipiclawSkills } from "./loader.js";
8
9
  function usage() {
9
10
  return renderSubcommandUsage("skills");
10
11
  }
@@ -21,36 +22,45 @@ export function parseSkillsCommand(args) {
21
22
  }
22
23
  throw new Error(`未知子命令 \`${parts[0]}\`。`);
23
24
  }
24
- async function listSkills(workspaceDir) {
25
- const skills = await listWorkspaceSkills({ workspaceDir });
26
- if (skills.length === 0) {
27
- return ("暂无工作区 skill。\n" +
28
- `让我帮你创建,或手动放到 \`${workspaceDir}/skills/<name>/SKILL.md\`(文件头需要非空的 \`name\`,与目录名一致,以及 \`description\`)。`);
25
+ function diagnosticForUser(diagnostic, skills) {
26
+ const label = diagnostic.name ? `\`${diagnostic.name}\`` : "技能目录";
27
+ const source = skillSourceLabel(diagnostic.source);
28
+ if (diagnostic.type === "collision") {
29
+ return `- ${label}(${source}):同名版本已被覆盖;使用${skillSourceLabel(skills.find((skill) => skill.name === diagnostic.name).source)}版本。`;
29
30
  }
30
- const loaded = skills.filter((skill) => !skill.warning);
31
- const rejected = skills.filter((skill) => skill.warning);
32
- const lines = [`**工作区 skills**(${loaded.length} 个)· 用 \`/skill:<名称>\` 调用`, ""];
33
- if (loaded.length > 0) {
34
- lines.push(...loaded.map((skill) => `- \`${skill.name}\` — ${skill.description || "(无 description)"}`));
31
+ const active = skills.find((skill) => skill.name === diagnostic.name);
32
+ const status = diagnostic.rejected
33
+ ? `该版本未加载${active ? `;当前使用${skillSourceLabel(active.source)}版本` : ""}`
34
+ : "格式提醒,仍可使用";
35
+ return `- ${label}(${source}):${status}。请检查${diagnostic.path ? ` \`${diagnostic.path}\`` : "目录权限或文件内容"},修改后发送 \`/reload\`。`;
36
+ }
37
+ function listSkills(options) {
38
+ const { skills, diagnostics } = loadPipiclawSkills(options);
39
+ if (skills.length === 0 && diagnostics.length === 0) {
40
+ return ("暂无技能。\n" +
41
+ `让我帮你创建,或放到 \`${options.workspaceDir}/skills/<name>/SKILL.md\`;也支持 \`~/.agents/skills/\`。`);
35
42
  }
36
- else {
37
- lines.push("(全部未通过加载,见下)");
43
+ const lines = [`**技能**(${skills.length} 个)· 用 \`/skill:<名称>\` 调用`, ""];
44
+ for (const skill of skills) {
45
+ lines.push(`- \`${skill.name}\`(${skillSourceLabel(skill.source)}${skill.disableModelInvocation ? ",仅显式调用" : ""})— ${skill.description.replace(/\s+/g, " ")}`);
38
46
  }
39
- if (rejected.length > 0) {
40
- lines.push("", "⚠️ 未加载(助手看不到,也无法用 `/skill:名称` 调用)", "");
41
- lines.push(...rejected.map((skill) => `- \`${skill.name}\` — ${skill.warning}`));
47
+ if (diagnostics.length > 0) {
48
+ lines.push("", "加载提醒", "", ...diagnostics.map((item) => diagnosticForUser(item, skills)));
42
49
  }
43
- return capReply(lines.join("\n"), { nextStepHint: "用 `/skills show <name>` 查看单个 skill 的完整正文" }).text;
50
+ return capReply(lines.join("\n"), {
51
+ nextStepHint: "用 `/skills show <name>` 查看单个技能;外部修改后发送 `/reload` 更新当前会话",
52
+ }).text;
44
53
  }
45
54
  async function showSkill(options, name) {
46
55
  try {
47
56
  const securityConfig = loadSecurityConfigWithDiagnostics(options.appHomeDir).config;
48
- const file = await loadWorkspaceSkillFile({
57
+ const file = await loadSkillFile({
49
58
  workspaceDir: options.workspaceDir,
59
+ sharedSkillsDir: options.sharedSkillsDir,
50
60
  securityConfig,
51
61
  channelId: options.channelId,
52
- }, name);
53
- const body = `**Skill \`${file.name}\`**\n\n路径:\`${file.path}\`\n\n${flattenMarkdownForChat(file.content)}`;
62
+ }, name, true);
63
+ const body = `**Skill \`${file.name}\`**\n\n来源:${skillSourceLabel(file.source)}${file.loaded ? "" : "(未加载,仅供排错)"}\n\n路径:\`${file.path}\`\n\n${flattenMarkdownForChat(file.content)}`;
54
64
  return capReply(body, { nextStepHint: `完整内容在 \`${file.path}\`` }).text;
55
65
  }
56
66
  catch (error) {
@@ -59,7 +69,7 @@ async function showSkill(options, name) {
59
69
  return `未找到 skill \`${name}\`。用 \`/skills\` 查看可用的 skill。`;
60
70
  if (error instanceof GuardBlockedError)
61
71
  return renderGuardBlockForUser(error.blocked);
62
- return `无法读取 skill \`${name}\`:${errorMessage(error)}`;
72
+ return `无法读取 skill \`${name}\`。请检查文件权限和内容后重试。`;
63
73
  }
64
74
  }
65
75
  export async function handleSkillsCommand(options) {
@@ -72,7 +82,11 @@ export async function handleSkillsCommand(options) {
72
82
  }
73
83
  switch (command.action) {
74
84
  case "list":
75
- return listSkills(options.workspaceDir);
85
+ return listSkills({
86
+ workspaceDir: options.workspaceDir,
87
+ sharedSkillsDir: options.sharedSkillsDir,
88
+ securityConfig: loadSecurityConfigWithDiagnostics(options.appHomeDir).config,
89
+ });
76
90
  case "show":
77
91
  return showSkill(options, command.name);
78
92
  }
@@ -1,31 +1,2 @@
1
- /**
2
- * Workspace skills.
3
- *
4
- * SOUL.md and AGENTS.md are loaded by the prompt pipeline itself
5
- * (`agent/prompt/resources.ts`), which owns their budgets and framing.
6
- */
7
- import { type ResourceDiagnostic, type Skill } from "@earendil-works/pi-coding-agent";
8
- export interface PipiclawSkillsResult {
9
- skills: Skill[];
10
- diagnostics: ResourceDiagnostic[];
11
- }
12
- /**
13
- * Load skills from the workspace-level skill directory.
14
- *
15
- * Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
16
- * scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
17
- * from the prompt. They are returned now and surfaced by the runner.
18
- */
19
- export declare function loadPipiclawSkills(channelDir: string): PipiclawSkillsResult;
20
- /**
21
- * Merge pi's auto-discovered skills with the workspace ones. Workspace wins on a
22
- * name collision (it is the layer the user actually edits), and the collision is
23
- * reported rather than resolved in silence.
24
- */
25
- export declare function resolvePipiclawSkills(base: {
26
- skills: Skill[];
27
- diagnostics: ResourceDiagnostic[];
28
- }, workspace: PipiclawSkillsResult): {
29
- skills: Skill[];
30
- diagnostics: ResourceDiagnostic[];
31
- };
1
+ import type { PipiclawSkillsResult, SkillOptions } from "./types.js";
2
+ export declare function loadPipiclawSkills(options: SkillOptions): PipiclawSkillsResult;
@@ -1,77 +1,110 @@
1
- /**
2
- * Workspace skills.
3
- *
4
- * SOUL.md and AGENTS.md are loaded by the prompt pipeline itself
5
- * (`agent/prompt/resources.ts`), which owns their budgets and framing.
6
- */
7
- import { readFileSync } from "node:fs";
1
+ /** The sole skill discovery and name-resolution policy for Pipiclaw (spec 063). */
2
+ import { readdirSync, readFileSync, realpathSync } from "node:fs";
3
+ import { basename, dirname } from "node:path";
8
4
  import { loadSkillsFromDir } from "@earendil-works/pi-coding-agent";
9
- import { join } from "path";
10
- import { scanSkillContent } from "./validation.js";
11
- /**
12
- * Content scanning moved here from the old `skill_manage` write path (spec 045): `skill` is now
13
- * read-only and workspace skills are authored through the generic `write`/`edit` tools, which have
14
- * no reason to know about skill-specific content rules. `Skill` (from pi's resource loader) carries
15
- * only catalog metadata, not the file body, so this reads each candidate's `SKILL.md` itself --
16
- * that read is also what keeps a scan-failing skill out of the `<available_skills>` catalog
17
- * entirely, not just out of the (optional) `skill read` tool: the catalog is what tells the model
18
- * the skill exists in the first place. An unreadable file is treated as "keep it" here -- a race or
19
- * permission glitch should not itself become a silent content-policy rejection.
20
- */
21
- function filterScannedSkills(skills) {
22
- const kept = [];
5
+ import { guardPath } from "../security/path-guard.js";
6
+ import { isNodeError } from "../shared/os.js";
7
+ import { errorMessage } from "../shared/text-utils.js";
8
+ import { getSkillRoots, skillSecurity } from "./roots.js";
9
+ /** SDK diagnostics may lack a name when parsing failed. Keep an actionable file identifier. */
10
+ function diagnosticName(path) {
11
+ return basename(path) === "SKILL.md" ? basename(dirname(path)) : basename(path, ".md");
12
+ }
13
+ export function loadPipiclawSkills(options) {
14
+ const { securityConfig, securityContext } = skillSecurity(options);
15
+ const guardContext = {
16
+ ...securityContext,
17
+ config: { ...securityConfig.pathGuard, enabled: securityConfig.enabled && securityConfig.pathGuard.enabled },
18
+ };
19
+ const skills = new Map();
20
+ const fileIdentities = new Map();
23
21
  const diagnostics = [];
24
- for (const skill of skills) {
25
- let content;
22
+ for (const { dir, source } of getSkillRoots(options.workspaceDir, options.sharedSkillsDir)) {
23
+ // The SDK swallows directory enumeration errors. Surface a failed source instead of
24
+ // silently making it look empty. Missing optional roots are normal.
26
25
  try {
27
- content = readFileSync(skill.filePath, "utf-8");
26
+ readdirSync(dir);
28
27
  }
29
- catch {
30
- kept.push(skill);
28
+ catch (error) {
29
+ if ((!isNodeError(error) || error.code !== "ENOENT") && guardPath(dir, "read", guardContext).allowed) {
30
+ diagnostics.push({
31
+ type: "warning",
32
+ source,
33
+ path: dir,
34
+ rejected: true,
35
+ message: `Skill directory could not be read: ${errorMessage(error)}. Check its permissions and reload.`,
36
+ });
37
+ }
31
38
  continue;
32
39
  }
33
- const scan = scanSkillContent(content);
34
- if (scan.ok) {
35
- kept.push(skill);
36
- continue;
40
+ const loaded = loadSkillsFromDir({ dir, source });
41
+ const candidates = new Map(loaded.skills.map((skill) => [skill.filePath, skill]));
42
+ for (const diagnostic of loaded.diagnostics) {
43
+ if (diagnostic.path && !guardPath(diagnostic.path, "read", guardContext).allowed)
44
+ continue;
45
+ const candidate = diagnostic.path ? candidates.get(diagnostic.path) : undefined;
46
+ diagnostics.push({
47
+ ...diagnostic,
48
+ source,
49
+ name: candidate?.name ?? (diagnostic.path ? diagnosticName(diagnostic.path) : undefined),
50
+ rejected: !candidate,
51
+ });
52
+ }
53
+ // Workspace roots come first; within one root, prefer the first usable path in a
54
+ // stable lexical order. Filtering precedes merging, so a broken override can fall back.
55
+ for (const skill of loaded.skills.sort((a, b) => a.filePath < b.filePath ? -1 : a.filePath > b.filePath ? 1 : 0)) {
56
+ const guarded = guardPath(skill.filePath, "read", guardContext);
57
+ if (!guarded.allowed || !guarded.resolvedPath)
58
+ continue;
59
+ let fileIdentity;
60
+ try {
61
+ // Verify the guarded target is readable; body wording does not gate loading.
62
+ readFileSync(guarded.resolvedPath, "utf-8");
63
+ fileIdentity = realpathSync(guarded.resolvedPath);
64
+ }
65
+ catch (error) {
66
+ diagnostics.push({
67
+ type: "warning",
68
+ source,
69
+ name: skill.name,
70
+ path: skill.filePath,
71
+ rejected: true,
72
+ message: `Skill could not be read: ${errorMessage(error)}. Check the file and reload.`,
73
+ });
74
+ continue;
75
+ }
76
+ const winner = skills.get(skill.name);
77
+ if (winner) {
78
+ if (fileIdentities.get(skill.name) !== fileIdentity) {
79
+ diagnostics.push({
80
+ type: "collision",
81
+ source,
82
+ name: skill.name,
83
+ path: skill.filePath,
84
+ message: `Skill "${skill.name}" is shadowed by ${winner.filePath}. Edit the winning file or choose another name.`,
85
+ collision: {
86
+ resourceType: "skill",
87
+ name: skill.name,
88
+ winnerPath: winner.filePath,
89
+ loserPath: skill.filePath,
90
+ winnerSource: winner.source,
91
+ loserSource: source,
92
+ },
93
+ });
94
+ }
95
+ continue;
96
+ }
97
+ skills.set(skill.name, {
98
+ ...skill,
99
+ source,
100
+ filePath: guarded.resolvedPath,
101
+ baseDir: dirname(guarded.resolvedPath),
102
+ });
103
+ fileIdentities.set(skill.name, fileIdentity);
37
104
  }
38
- diagnostics.push({
39
- type: "warning",
40
- message: `Skill "${skill.name}" was not loaded: ${scan.error}.`,
41
- path: skill.filePath,
42
- });
43
- }
44
- return { skills: kept, diagnostics };
45
- }
46
- /**
47
- * Load skills from the workspace-level skill directory.
48
- *
49
- * Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
50
- * scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
51
- * from the prompt. They are returned now and surfaced by the runner.
52
- */
53
- export function loadPipiclawSkills(channelDir) {
54
- const workspaceSkillsDir = join(channelDir, "..", "skills");
55
- const loaded = loadSkillsFromDir({ dir: workspaceSkillsDir, source: "workspace" });
56
- const scanned = filterScannedSkills(loaded.skills);
57
- return { skills: scanned.skills, diagnostics: [...loaded.diagnostics, ...scanned.diagnostics] };
58
- }
59
- /**
60
- * Merge pi's auto-discovered skills with the workspace ones. Workspace wins on a
61
- * name collision (it is the layer the user actually edits), and the collision is
62
- * reported rather than resolved in silence.
63
- */
64
- export function resolvePipiclawSkills(base, workspace) {
65
- const workspaceNames = new Set(workspace.skills.map((skill) => skill.name));
66
- const collisions = base.skills.filter((skill) => workspaceNames.has(skill.name));
67
- const diagnostics = [...base.diagnostics, ...workspace.diagnostics];
68
- for (const skill of collisions) {
69
- diagnostics.push({
70
- type: "collision",
71
- message: `Skill "${skill.name}" is shadowed by the workspace skill of the same name.`,
72
- path: skill.filePath,
73
- });
74
105
  }
75
- const kept = base.skills.filter((skill) => !workspaceNames.has(skill.name));
76
- return { skills: [...kept, ...workspace.skills], diagnostics };
106
+ return {
107
+ skills: [...skills.values()].sort((a, b) => a.name.localeCompare(b.name)),
108
+ diagnostics: diagnostics.sort((a, b) => a.source === b.source ? (a.path ?? "").localeCompare(b.path ?? "") : a.source === "workspace" ? -1 : 1),
109
+ };
77
110
  }
@@ -0,0 +1,12 @@
1
+ import type { SkillOptions } from "./types.js";
2
+ export declare function getSkillRoots(workspaceDir: string, sharedSkillsDir?: string): ({
3
+ dir: string;
4
+ source: "workspace";
5
+ } | {
6
+ dir: string;
7
+ source: "user";
8
+ })[];
9
+ export declare function skillSecurity(options: SkillOptions): {
10
+ securityConfig: import("../security/types.js").SecurityConfig;
11
+ securityContext: import("../security/types.js").SecurityRuntimeContext;
12
+ };
@@ -0,0 +1,18 @@
1
+ import { homedir } from "node:os";
2
+ import { join, resolve } from "node:path";
3
+ import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
4
+ export function getSkillRoots(workspaceDir, sharedSkillsDir = join(homedir(), ".agents", "skills")) {
5
+ return [
6
+ { dir: resolve(workspaceDir, "skills"), source: "workspace" },
7
+ { dir: resolve(sharedSkillsDir), source: "user" },
8
+ ];
9
+ }
10
+ export function skillSecurity(options) {
11
+ return {
12
+ securityConfig: options.securityConfig ?? DEFAULT_SECURITY_CONFIG,
13
+ securityContext: options.securityContext ?? {
14
+ agentWorkspaceDir: options.workspaceDir,
15
+ cwd: options.workspaceDir,
16
+ },
17
+ };
18
+ }
@@ -0,0 +1,24 @@
1
+ import type { ResourceDiagnostic, Skill } from "@earendil-works/pi-coding-agent";
2
+ import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
3
+ export type SkillSource = "workspace" | "user";
4
+ export interface SkillOptions {
5
+ workspaceDir: string;
6
+ /** Internal override for isolated callers/tests, not a user setting. */
7
+ sharedSkillsDir?: string;
8
+ securityConfig?: SecurityConfig;
9
+ securityContext?: SecurityRuntimeContext;
10
+ channelId?: string;
11
+ }
12
+ export interface PipiclawSkill extends Skill {
13
+ source: SkillSource;
14
+ }
15
+ export interface SkillDiagnostic extends ResourceDiagnostic {
16
+ source: SkillSource;
17
+ name?: string;
18
+ /** A load failure, distinct from an SDK warning on a usable skill. */
19
+ rejected?: boolean;
20
+ }
21
+ export interface PipiclawSkillsResult {
22
+ skills: PipiclawSkill[];
23
+ diagnostics: SkillDiagnostic[];
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { ChannelEvent } from "../channel/channel-event.js";
1
+ import type { WakeEvent } from "../channel/channel-event.js";
2
2
  import type { RunRecord } from "./run-record.js";
3
3
  /** Chars of the reply text carried inline in the completion wake. P2-1: `output.md` bodies are
4
4
  * routinely 3-10KB — a 2,000-char tail truncated most of them and regularly cost the reader an
@@ -8,10 +8,19 @@ export declare const WAKE_OUTPUT_TAIL_CHARS = 6000;
8
8
  * The completion wake for a settled run: who finished, how, the (untrusted) output tail, and where
9
9
  * the full output lives. Pure: the manager supplies the sibling count it alone can compute.
10
10
  */
11
+ /**
12
+ * Running runs that share this wake's question, "was this the last one?": the other runs of its
13
+ * task, or — for a chat-level run — the other chat-level runs of the same channel. The desk's other
14
+ * channels get their own wakes, so counting them would leave this channel waiting for nothing.
15
+ */
16
+ export declare function countWakeSiblings(record: RunRecord, runs: Iterable<RunRecord>): number;
11
17
  export declare function buildRunCompletionWake(input: {
18
+ /** The run's desk: stamped on the event so admission can drop it once the channel moves (D7). */
19
+ desk: string;
20
+ dispatchId: string;
12
21
  record: RunRecord;
13
22
  outputText: string;
14
23
  outputSaved: boolean;
15
24
  /** Other runs of the same task (or, for a chat-level run, the same channel) still running. */
16
25
  siblingCount: number;
17
- }): ChannelEvent;
26
+ }): WakeEvent;
@@ -11,8 +11,24 @@ export const WAKE_OUTPUT_TAIL_CHARS = 6_000;
11
11
  * The completion wake for a settled run: who finished, how, the (untrusted) output tail, and where
12
12
  * the full output lives. Pure: the manager supplies the sibling count it alone can compute.
13
13
  */
14
+ /**
15
+ * Running runs that share this wake's question, "was this the last one?": the other runs of its
16
+ * task, or — for a chat-level run — the other chat-level runs of the same channel. The desk's other
17
+ * channels get their own wakes, so counting them would leave this channel waiting for nothing.
18
+ */
19
+ export function countWakeSiblings(record, runs) {
20
+ let count = 0;
21
+ for (const other of runs) {
22
+ if (other.runId === record.runId || other.status !== "running" || other.taskId !== record.taskId)
23
+ continue;
24
+ if (record.taskId === undefined && other.channelId !== record.channelId)
25
+ continue;
26
+ count++;
27
+ }
28
+ return count;
29
+ }
14
30
  export function buildRunCompletionWake(input) {
15
- const { record, outputText, outputSaved, siblingCount } = input;
31
+ const { desk, dispatchId, record, outputText, outputSaved, siblingCount } = input;
16
32
  const tail = outputText.slice(-WAKE_OUTPUT_TAIL_CHARS).trim();
17
33
  // P2-1: say so when the tail cut real content, instead of leaving the reader to guess and
18
34
  // spend a `read` round trip finding out output.md has more.
@@ -27,8 +43,6 @@ export function buildRunCompletionWake(input) {
27
43
  // K parallel fan-out runs otherwise produce K wake turns, each re-asking "is this the only
28
44
  // one?" via a fresh subagent_list call — this answers it inline (review 2026-08-23
29
45
  // §3.3), so the model can reliably reply [SILENT] to every wake but the last.
30
- // A chat-level run's siblings are the other chat-level runs on this channel: the same "was this
31
- // the last one?" question, without a task to scope it.
32
46
  const siblingNote = siblingCount > 0
33
47
  ? ` ${siblingCount} other run(s) ${record.taskId ? "for this task" : "on this channel"} are still running.`
34
48
  : "";
@@ -37,10 +51,9 @@ export function buildRunCompletionWake(input) {
37
51
  ? `\nVerdict: ${record.verificationVerdict === "pass" ? "PASS" : "FAIL"}`
38
52
  : "";
39
53
  return {
40
- type: record.channelId.startsWith("group_") ? "group" : "dm",
54
+ source: "wake",
41
55
  channelId: record.channelId,
42
- user: "SUBAGENT",
43
- userName: "SUBAGENT",
56
+ producer: "SUBAGENT",
44
57
  text: `[SUBAGENT:${record.runId}] Delegation "${record.label}" -> ${record.agent} (${harnessLabel}) finished: ` +
45
58
  `${record.status} (${record.durationEstimated ? "≈" : ""}${formatDuration(record.durationMs ?? 0)}).${belongsTo}${verdictLine}\n` +
46
59
  // The agent's own output is untrusted data, not an instruction — a fence plus an
@@ -58,19 +71,9 @@ export function buildRunCompletionWake(input) {
58
71
  workspaceLine +
59
72
  "Continue whatever was waiting on this delegation. If it needs no follow-up, respond with exactly [SILENT].",
60
73
  ts: String(Date.now()),
61
- conversationType: record.channelId.startsWith("group_") ? "2" : "1",
62
- dispatchId: `subagent:${record.channelId}:${record.runId}:done`,
74
+ dispatchId,
75
+ desk,
63
76
  // The result is awaited; the wake itself still runs without a progress card.
64
77
  presentation: "awaited",
65
- ...(record.taskId
66
- ? {
67
- internalWake: {
68
- kind: "subagent",
69
- resourceId: record.runId,
70
- taskId: record.taskId,
71
- dispatchId: `subagent:${record.channelId}:${record.runId}:done`,
72
- },
73
- }
74
- : {}),
75
78
  };
76
79
  }
@@ -5,7 +5,7 @@ declare const ALLOWED_CONTEXT_MODES: readonly ["isolated", "contextual"];
5
5
  declare const ALLOWED_MEMORY_MODES: readonly ["none", "index"];
6
6
  declare const ALLOWED_THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
7
7
  declare const ALLOWED_RUNTIMES: readonly ["internal", "external"];
8
- declare const ALLOWED_HARNESSES: readonly ["claude-code", "codex-cli", "exec"];
8
+ declare const ALLOWED_HARNESSES: readonly ["claude-code", "codex-cli", "cursor-cli", "exec"];
9
9
  declare const ALLOWED_WORKLOADS: readonly ["light", "heavy"];
10
10
  declare const ALLOWED_MUTATES: readonly ["read", "write"];
11
11
  export type { SubAgentToolName };
@@ -9,6 +9,7 @@ import { SUB_AGENTS_DIR_NAME } from "../paths.js";
9
9
  import { splitShellWords } from "../shared/shell-words.js";
10
10
  import { errorMessage } from "../shared/text-utils.js";
11
11
  import { SUBAGENT_TOOL_NAMES } from "../tools/contract/names.js";
12
+ import { externalRoleWarning } from "./external/role-warnings.js";
12
13
  /** Re-exported from the leaf source of truth so validation and the tool set never drift. */
13
14
  const ALLOWED_SUB_AGENT_TOOLS = SUBAGENT_TOOL_NAMES;
14
15
  const DEFAULT_SUB_AGENT_TOOLS = ["read", "bash"];
@@ -25,7 +26,7 @@ const ALLOWED_MEMORY_MODES = ["none", "index"];
25
26
  // "max" is a real SDK ThinkingLevel; pipiclaw's own whitelist previously omitted it (spec 040, D4).
26
27
  const ALLOWED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
27
28
  const ALLOWED_RUNTIMES = ["internal", "external"];
28
- const ALLOWED_HARNESSES = ["claude-code", "codex-cli", "exec"];
29
+ const ALLOWED_HARNESSES = ["claude-code", "codex-cli", "cursor-cli", "exec"];
29
30
  const ALLOWED_WORKLOADS = ["light", "heavy"];
30
31
  const ALLOWED_MUTATES = ["read", "write"];
31
32
  /**
@@ -468,9 +469,6 @@ function parseExternalAgent(entryName, filePath, frontmatter, body, name, descri
468
469
  const memoryMode = parseMemoryMode(frontmatter.memory, "none");
469
470
  if (memoryMode.error)
470
471
  return { warning: `${entryName}: ${memoryMode.error}` };
471
- const memoryDisclosureWarning = memoryMode.value !== "none"
472
- ? `${entryName}: memory: ${memoryMode.value} sends the channel memory index / journal content to this external process`
473
- : undefined;
474
472
  const maxWallTimeSec = parsePositiveInteger(frontmatter.maxWallTimeSec, DEFAULT_EXTERNAL_MAX_WALL_TIME_SEC);
475
473
  // An empty body is a legitimate declaration for an external role, not a defect: a capability
476
474
  // entry ("this agent, this model, this reasoning level") deliberately carries no standing
@@ -488,18 +486,14 @@ function parseExternalAgent(entryName, filePath, frontmatter, body, name, descri
488
486
  ? `executable "${executable}" was not found on PATH; install it or fix "command" in ${filePath}`
489
487
  : undefined;
490
488
  const externalModelRef = readOptionalTrimmedString(frontmatter.model);
491
- // Spec 042 D10: a role's `model:` can only ever come from its own frontmatter (external `model`
492
- // is never taken from the invocation) — so if `command` references `$MODEL` and none is
493
- // configured here, every dispatch of this role will silently drop that argv token. Surface it
494
- // at discovery time, where the fix (add `model:`) is obvious, instead of only as a per-run
495
- // warning after the fact. `$EFFORT` gets no equivalent check: `thinkingLevel` can be supplied
496
- // per invocation, so an unset frontmatter value does not mean "no value ever".
497
- const modelPlaceholderWarning = command.includes("$MODEL") && !externalModelRef
498
- ? `${entryName}: command references $MODEL but no "model" is configured; that argv token will be dropped on every dispatch`
499
- : undefined;
500
- // All non-fatal (the role still loads); joined rather than picking one so an unlucky
501
- // combination never silently loses one of them.
502
- const combinedWarning = [memoryDisclosureWarning, modelPlaceholderWarning].filter(Boolean).join("; ") || undefined;
489
+ const combinedWarning = externalRoleWarning({
490
+ entryName,
491
+ harness: harness.value,
492
+ command,
493
+ mutates: mutates.value,
494
+ memory: memoryMode.value ?? "none",
495
+ modelConfigured: Boolean(externalModelRef),
496
+ });
503
497
  return {
504
498
  warning: combinedWarning,
505
499
  agent: {
@@ -1,16 +1,6 @@
1
1
  import type { Api, Model } from "@earendil-works/pi-ai";
2
2
  import type { ResolvedSubAgentConfig } from "./discovery.js";
3
3
  import type { DelegationParams, DelegationResult, SubAgentToolFields, SubAgentToolOptions } from "./types.js";
4
- /**
5
- * D6.2's boundary check, hardened against symlinks (review 2026-08-23 §2.3): a plain
6
- * `resolve()` + string-prefix comparison only judges the *requested* path, so `<projectRoot
7
- * >/link -> /somewhere/else` passes the check and then everything downstream — the internal
8
- * agent's own `securityContext.projectRoot`, an external process's `cwd` (which bypasses the
9
- * path guard entirely) — trusts that escaped target. Comparing realpaths closes it, matching
10
- * `project-scope.ts` and `workspaceLeaseKey`, the two other places in the tree that already do
11
- * this.
12
- */
13
- export declare function assertWithinProjectBoundary(target: string, base: string, requested: string): void;
14
4
  /**
15
5
  * A run's lifecycle is deliberately unlinked from the tool call's `AbortSignal` (spec 040, D2):
16
6
  * `/stop` ends the current turn but no longer kills an in-flight delegation, matching background