opensquid 0.5.441 → 0.5.449

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 (391) hide show
  1. package/README.md +1 -0
  2. package/dist/functions/arm_scope.d.ts +27 -0
  3. package/dist/functions/arm_scope.d.ts.map +1 -0
  4. package/dist/functions/arm_scope.js +52 -0
  5. package/dist/functions/arm_scope.js.map +1 -0
  6. package/dist/functions/index.d.ts +1 -0
  7. package/dist/functions/index.d.ts.map +1 -1
  8. package/dist/functions/index.js +1 -0
  9. package/dist/functions/index.js.map +1 -1
  10. package/dist/functions/recall_pre_inject.d.ts.map +1 -1
  11. package/dist/functions/recall_pre_inject.js +12 -0
  12. package/dist/functions/recall_pre_inject.js.map +1 -1
  13. package/dist/rag/store_git.d.ts +23 -0
  14. package/dist/rag/store_git.d.ts.map +1 -0
  15. package/dist/rag/store_git.js +57 -0
  16. package/dist/rag/store_git.js.map +1 -0
  17. package/dist/runtime/bootstrap.d.ts.map +1 -1
  18. package/dist/runtime/bootstrap.js +2 -0
  19. package/dist/runtime/bootstrap.js.map +1 -1
  20. package/dist/runtime/handoff/render.d.ts +5 -4
  21. package/dist/runtime/handoff/render.d.ts.map +1 -1
  22. package/dist/runtime/handoff/render.js +7 -7
  23. package/dist/runtime/handoff/render.js.map +1 -1
  24. package/dist/runtime/hooks/active_task_mirror.js +0 -0
  25. package/dist/runtime/hooks/apply_patch.js +0 -0
  26. package/dist/runtime/hooks/dispatch.js +0 -0
  27. package/dist/runtime/hooks/hook_output.js +0 -0
  28. package/dist/runtime/hooks/memory_reconcile.js +0 -0
  29. package/dist/runtime/hooks/new_project_detect.js +0 -0
  30. package/dist/runtime/hooks/profession_resolver.js +0 -0
  31. package/dist/runtime/hooks/scope_intent.js +0 -0
  32. package/dist/runtime/hooks/session-end.js +11 -0
  33. package/dist/runtime/hooks/session-end.js.map +1 -1
  34. package/dist/runtime/hooks/session_id.js +0 -0
  35. package/dist/runtime/hooks/session_liveness.js +0 -0
  36. package/dist/runtime/hooks/stop_drive.js +0 -0
  37. package/dist/runtime/hooks/stop_stream.js +0 -0
  38. package/dist/runtime/hooks/subagent_guard.js +0 -0
  39. package/dist/runtime/hooks/transcript.js +0 -0
  40. package/dist/runtime/hooks/transcript_tasks.js +0 -0
  41. package/dist/runtime/ralph/orchestrator.d.ts.map +1 -1
  42. package/dist/runtime/ralph/orchestrator.js +2 -1
  43. package/dist/runtime/ralph/orchestrator.js.map +1 -1
  44. package/dist/setup/cli/limits_state.d.ts.map +1 -1
  45. package/dist/setup/cli/limits_state.js +6 -40
  46. package/dist/setup/cli/limits_state.js.map +1 -1
  47. package/dist/setup/cli/pack_walk.d.ts +32 -0
  48. package/dist/setup/cli/pack_walk.d.ts.map +1 -0
  49. package/dist/setup/cli/pack_walk.js +76 -0
  50. package/dist/setup/cli/pack_walk.js.map +1 -0
  51. package/dist/setup/cli/permissions_state.d.ts.map +1 -1
  52. package/dist/setup/cli/permissions_state.js +6 -37
  53. package/dist/setup/cli/permissions_state.js.map +1 -1
  54. package/dist/setup/cli/triggers_state.d.ts.map +1 -1
  55. package/dist/setup/cli/triggers_state.js +3 -29
  56. package/dist/setup/cli/triggers_state.js.map +1 -1
  57. package/dist/workgraph/events.d.ts.map +1 -1
  58. package/dist/workgraph/events.js +10 -0
  59. package/dist/workgraph/events.js.map +1 -1
  60. package/dist/workgraph/store.d.ts.map +1 -1
  61. package/dist/workgraph/store.js +5 -0
  62. package/dist/workgraph/store.js.map +1 -1
  63. package/dist/workgraph/types.d.ts +2 -1
  64. package/dist/workgraph/types.d.ts.map +1 -1
  65. package/docs/ARCHITECTURE.md +268 -0
  66. package/docs/pack-runtime.md +15 -12
  67. package/docs/skill-grammar-guide.md +4 -4
  68. package/package.json +5 -3
  69. package/packs/builtin/coding-flow/skills/entry-and-handoffs/skill.yaml +13 -17
  70. package/dist/anti-drift/evaluator.d.ts +0 -88
  71. package/dist/anti-drift/evaluator.d.ts.map +0 -1
  72. package/dist/anti-drift/evaluator.js +0 -417
  73. package/dist/anti-drift/evaluator.js.map +0 -1
  74. package/dist/anti-drift/evaluator.test.js +0 -78
  75. package/dist/anti-drift/rules.d.ts +0 -80
  76. package/dist/anti-drift/rules.d.ts.map +0 -1
  77. package/dist/anti-drift/rules.js +0 -368
  78. package/dist/anti-drift/rules.js.map +0 -1
  79. package/dist/anti-drift/rules.test.js +0 -213
  80. package/dist/anti-drift/state.d.ts +0 -107
  81. package/dist/anti-drift/state.d.ts.map +0 -1
  82. package/dist/anti-drift/state.js +0 -177
  83. package/dist/anti-drift/state.js.map +0 -1
  84. package/dist/anti-drift/state.test.js +0 -120
  85. package/dist/chat/adapters/discord.d.ts +0 -41
  86. package/dist/chat/adapters/discord.d.ts.map +0 -1
  87. package/dist/chat/adapters/discord.js +0 -176
  88. package/dist/chat/adapters/discord.js.map +0 -1
  89. package/dist/chat/adapters/discord.test.js +0 -25
  90. package/dist/chat/adapters/slack.d.ts +0 -43
  91. package/dist/chat/adapters/slack.d.ts.map +0 -1
  92. package/dist/chat/adapters/slack.js +0 -172
  93. package/dist/chat/adapters/slack.js.map +0 -1
  94. package/dist/chat/adapters/slack.test.js +0 -30
  95. package/dist/chat/adapters/telegram.d.ts +0 -148
  96. package/dist/chat/adapters/telegram.d.ts.map +0 -1
  97. package/dist/chat/adapters/telegram.js +0 -498
  98. package/dist/chat/adapters/telegram.js.map +0 -1
  99. package/dist/chat/adapters/telegram.test.js +0 -94
  100. package/dist/chat/config.d.ts +0 -98
  101. package/dist/chat/config.d.ts.map +0 -1
  102. package/dist/chat/config.js +0 -185
  103. package/dist/chat/config.js.map +0 -1
  104. package/dist/chat/daemon/active-project.d.ts +0 -17
  105. package/dist/chat/daemon/active-project.d.ts.map +0 -1
  106. package/dist/chat/daemon/active-project.js +0 -23
  107. package/dist/chat/daemon/active-project.js.map +0 -1
  108. package/dist/chat/daemon/autospawn.d.ts +0 -40
  109. package/dist/chat/daemon/autospawn.d.ts.map +0 -1
  110. package/dist/chat/daemon/autospawn.js +0 -129
  111. package/dist/chat/daemon/autospawn.js.map +0 -1
  112. package/dist/chat/daemon/autospawn.test.js +0 -112
  113. package/dist/chat/daemon/cli.d.ts +0 -18
  114. package/dist/chat/daemon/cli.d.ts.map +0 -1
  115. package/dist/chat/daemon/cli.js +0 -71
  116. package/dist/chat/daemon/cli.js.map +0 -1
  117. package/dist/chat/daemon/collisions.js +0 -384
  118. package/dist/chat/daemon/health-check.d.ts +0 -69
  119. package/dist/chat/daemon/health-check.d.ts.map +0 -1
  120. package/dist/chat/daemon/health-check.js +0 -112
  121. package/dist/chat/daemon/health-check.js.map +0 -1
  122. package/dist/chat/daemon/inbox-read.d.ts +0 -35
  123. package/dist/chat/daemon/inbox-read.d.ts.map +0 -1
  124. package/dist/chat/daemon/inbox-read.js +0 -75
  125. package/dist/chat/daemon/inbox-read.js.map +0 -1
  126. package/dist/chat/daemon/inbox-read.test.js +0 -97
  127. package/dist/chat/daemon/inbox.d.ts +0 -63
  128. package/dist/chat/daemon/inbox.d.ts.map +0 -1
  129. package/dist/chat/daemon/inbox.js +0 -56
  130. package/dist/chat/daemon/inbox.js.map +0 -1
  131. package/dist/chat/daemon/inbox.test.js +0 -110
  132. package/dist/chat/daemon/lifecycle.d.ts +0 -71
  133. package/dist/chat/daemon/lifecycle.d.ts.map +0 -1
  134. package/dist/chat/daemon/lifecycle.js +0 -221
  135. package/dist/chat/daemon/lifecycle.js.map +0 -1
  136. package/dist/chat/daemon/lifecycle.test.js +0 -163
  137. package/dist/chat/daemon/protocol.d.ts +0 -107
  138. package/dist/chat/daemon/protocol.d.ts.map +0 -1
  139. package/dist/chat/daemon/protocol.js +0 -54
  140. package/dist/chat/daemon/protocol.js.map +0 -1
  141. package/dist/chat/daemon/routing.d.ts +0 -140
  142. package/dist/chat/daemon/routing.d.ts.map +0 -1
  143. package/dist/chat/daemon/routing.js +0 -198
  144. package/dist/chat/daemon/routing.js.map +0 -1
  145. package/dist/chat/daemon/routing.test.js +0 -259
  146. package/dist/chat/daemon/rpc-client.d.ts +0 -45
  147. package/dist/chat/daemon/rpc-client.d.ts.map +0 -1
  148. package/dist/chat/daemon/rpc-client.js +0 -133
  149. package/dist/chat/daemon/rpc-client.js.map +0 -1
  150. package/dist/chat/daemon/rpc-server.d.ts +0 -39
  151. package/dist/chat/daemon/rpc-server.d.ts.map +0 -1
  152. package/dist/chat/daemon/rpc-server.js +0 -385
  153. package/dist/chat/daemon/rpc-server.js.map +0 -1
  154. package/dist/chat/daemon/rpc.test.js +0 -177
  155. package/dist/chat/daemon/subscribers.js +0 -257
  156. package/dist/chat/daemon/worker.d.ts +0 -27
  157. package/dist/chat/daemon/worker.d.ts.map +0 -1
  158. package/dist/chat/daemon/worker.js +0 -313
  159. package/dist/chat/daemon/worker.js.map +0 -1
  160. package/dist/chat/daemon/workspace-topic.js +0 -324
  161. package/dist/chat/env-token.d.ts +0 -60
  162. package/dist/chat/env-token.d.ts.map +0 -1
  163. package/dist/chat/env-token.js +0 -137
  164. package/dist/chat/env-token.js.map +0 -1
  165. package/dist/chat/env-token.test.js +0 -160
  166. package/dist/chat/factory.d.ts +0 -30
  167. package/dist/chat/factory.d.ts.map +0 -1
  168. package/dist/chat/factory.js +0 -50
  169. package/dist/chat/factory.js.map +0 -1
  170. package/dist/chat/factory.test.js +0 -55
  171. package/dist/chat/gateway.d.ts +0 -176
  172. package/dist/chat/gateway.d.ts.map +0 -1
  173. package/dist/chat/gateway.js +0 -146
  174. package/dist/chat/gateway.js.map +0 -1
  175. package/dist/chat/gateway.test.js +0 -192
  176. package/dist/claude-md.d.ts +0 -39
  177. package/dist/claude-md.d.ts.map +0 -1
  178. package/dist/claude-md.js +0 -113
  179. package/dist/claude-md.js.map +0 -1
  180. package/dist/claude-md.test.js +0 -91
  181. package/dist/codex/activate.d.ts +0 -66
  182. package/dist/codex/activate.d.ts.map +0 -1
  183. package/dist/codex/activate.js +0 -329
  184. package/dist/codex/activate.js.map +0 -1
  185. package/dist/codex/activate.test.js +0 -229
  186. package/dist/codex/bundled-default/bundled-default.test.js +0 -161
  187. package/dist/codex/cli-publish.test.js +0 -133
  188. package/dist/codex/cli.d.ts +0 -35
  189. package/dist/codex/cli.d.ts.map +0 -1
  190. package/dist/codex/cli.js +0 -554
  191. package/dist/codex/cli.js.map +0 -1
  192. package/dist/codex/cli.test.js +0 -277
  193. package/dist/codex/import-skill-md.d.ts +0 -53
  194. package/dist/codex/import-skill-md.d.ts.map +0 -1
  195. package/dist/codex/import-skill-md.js +0 -236
  196. package/dist/codex/import-skill-md.js.map +0 -1
  197. package/dist/codex/import-skill-md.test.js +0 -225
  198. package/dist/codex/loader.d.ts +0 -27
  199. package/dist/codex/loader.d.ts.map +0 -1
  200. package/dist/codex/loader.js +0 -86
  201. package/dist/codex/loader.js.map +0 -1
  202. package/dist/codex/loader.test.js +0 -75
  203. package/dist/codex/parse.d.ts +0 -28
  204. package/dist/codex/parse.d.ts.map +0 -1
  205. package/dist/codex/parse.js +0 -309
  206. package/dist/codex/parse.js.map +0 -1
  207. package/dist/codex/parse.test.js +0 -241
  208. package/dist/codex/store.d.ts +0 -87
  209. package/dist/codex/store.d.ts.map +0 -1
  210. package/dist/codex/store.js +0 -205
  211. package/dist/codex/store.js.map +0 -1
  212. package/dist/codex/store.test.js +0 -242
  213. package/dist/codex/types.d.ts +0 -398
  214. package/dist/codex/types.d.ts.map +0 -1
  215. package/dist/codex/types.js +0 -21
  216. package/dist/codex/types.js.map +0 -1
  217. package/dist/config.d.ts +0 -53
  218. package/dist/config.d.ts.map +0 -1
  219. package/dist/config.js +0 -202
  220. package/dist/config.js.map +0 -1
  221. package/dist/config.test.js +0 -117
  222. package/dist/engine/cli.d.ts +0 -14
  223. package/dist/engine/cli.d.ts.map +0 -1
  224. package/dist/engine/cli.js +0 -171
  225. package/dist/engine/cli.js.map +0 -1
  226. package/dist/engine/client.d.ts +0 -219
  227. package/dist/engine/client.d.ts.map +0 -1
  228. package/dist/engine/client.js +0 -312
  229. package/dist/engine/client.js.map +0 -1
  230. package/dist/engine/config.d.ts +0 -62
  231. package/dist/engine/config.d.ts.map +0 -1
  232. package/dist/engine/config.js +0 -223
  233. package/dist/engine/config.js.map +0 -1
  234. package/dist/engine/index.d.ts +0 -17
  235. package/dist/engine/index.d.ts.map +0 -1
  236. package/dist/engine/index.js +0 -16
  237. package/dist/engine/index.js.map +0 -1
  238. package/dist/engine/resolver.d.ts +0 -62
  239. package/dist/engine/resolver.d.ts.map +0 -1
  240. package/dist/engine/resolver.js +0 -103
  241. package/dist/engine/resolver.js.map +0 -1
  242. package/dist/engine/singleton.d.ts +0 -95
  243. package/dist/engine/singleton.d.ts.map +0 -1
  244. package/dist/engine/singleton.js +0 -325
  245. package/dist/engine/singleton.js.map +0 -1
  246. package/dist/engine/types.d.ts +0 -402
  247. package/dist/engine/types.d.ts.map +0 -1
  248. package/dist/engine/types.js +0 -22
  249. package/dist/engine/types.js.map +0 -1
  250. package/dist/engine-binary-resolver.js +0 -110
  251. package/dist/engine-binary-resolver.test.js +0 -61
  252. package/dist/engine-cli.js +0 -60
  253. package/dist/engine-client.js +0 -301
  254. package/dist/engine-client.test.js +0 -118
  255. package/dist/functions/chain_state.d.ts +0 -51
  256. package/dist/functions/chain_state.d.ts.map +0 -1
  257. package/dist/functions/chain_state.js +0 -59
  258. package/dist/functions/chain_state.js.map +0 -1
  259. package/dist/hooks/drift-catalog.d.ts +0 -68
  260. package/dist/hooks/drift-catalog.d.ts.map +0 -1
  261. package/dist/hooks/drift-catalog.js +0 -184
  262. package/dist/hooks/drift-catalog.js.map +0 -1
  263. package/dist/hooks/drift-catalog.test.js +0 -154
  264. package/dist/hooks/drift-patterns.d.ts +0 -110
  265. package/dist/hooks/drift-patterns.d.ts.map +0 -1
  266. package/dist/hooks/drift-patterns.js +0 -289
  267. package/dist/hooks/drift-patterns.js.map +0 -1
  268. package/dist/hooks/drift-patterns.test.js +0 -325
  269. package/dist/hooks/engine-vocab-gate.d.ts +0 -108
  270. package/dist/hooks/engine-vocab-gate.d.ts.map +0 -1
  271. package/dist/hooks/engine-vocab-gate.js +0 -225
  272. package/dist/hooks/engine-vocab-gate.js.map +0 -1
  273. package/dist/hooks/engine-vocab-gate.test.js +0 -170
  274. package/dist/hooks/heartbeat.d.ts +0 -107
  275. package/dist/hooks/heartbeat.d.ts.map +0 -1
  276. package/dist/hooks/heartbeat.js +0 -316
  277. package/dist/hooks/heartbeat.js.map +0 -1
  278. package/dist/hooks/heartbeat.test.js +0 -393
  279. package/dist/hooks/honesty-ledger-session-scope.test.js +0 -100
  280. package/dist/hooks/honesty-ledger.d.ts +0 -123
  281. package/dist/hooks/honesty-ledger.d.ts.map +0 -1
  282. package/dist/hooks/honesty-ledger.js +0 -226
  283. package/dist/hooks/honesty-ledger.js.map +0 -1
  284. package/dist/hooks/honesty-ledger.test.js +0 -466
  285. package/dist/hooks/inline-report-check.d.ts +0 -63
  286. package/dist/hooks/inline-report-check.d.ts.map +0 -1
  287. package/dist/hooks/inline-report-check.js +0 -88
  288. package/dist/hooks/inline-report-check.js.map +0 -1
  289. package/dist/hooks/inline-report-check.test.js +0 -96
  290. package/dist/hooks/pre-tool-use.d.ts +0 -62
  291. package/dist/hooks/pre-tool-use.d.ts.map +0 -1
  292. package/dist/hooks/pre-tool-use.js +0 -342
  293. package/dist/hooks/pre-tool-use.js.map +0 -1
  294. package/dist/hooks/pre-tool-use.test.js +0 -134
  295. package/dist/hooks/session-end.d.ts +0 -15
  296. package/dist/hooks/session-end.d.ts.map +0 -1
  297. package/dist/hooks/session-end.js +0 -60
  298. package/dist/hooks/session-end.js.map +0 -1
  299. package/dist/hooks/session-end.test.js +0 -52
  300. package/dist/hooks/stop.d.ts +0 -35
  301. package/dist/hooks/stop.d.ts.map +0 -1
  302. package/dist/hooks/stop.js +0 -136
  303. package/dist/hooks/stop.js.map +0 -1
  304. package/dist/hooks/transcript-active-task.test.js +0 -342
  305. package/dist/hooks/transcript.d.ts +0 -26
  306. package/dist/hooks/transcript.d.ts.map +0 -1
  307. package/dist/hooks/transcript.js +0 -266
  308. package/dist/hooks/transcript.js.map +0 -1
  309. package/dist/hooks/transcript.test.js +0 -103
  310. package/dist/hooks/user-prompt-submit.d.ts +0 -74
  311. package/dist/hooks/user-prompt-submit.d.ts.map +0 -1
  312. package/dist/hooks/user-prompt-submit.js +0 -256
  313. package/dist/hooks/user-prompt-submit.js.map +0 -1
  314. package/dist/hooks/user-prompt-submit.test.js +0 -118
  315. package/dist/hooks/versioning-gate.d.ts +0 -101
  316. package/dist/hooks/versioning-gate.d.ts.map +0 -1
  317. package/dist/hooks/versioning-gate.js +0 -245
  318. package/dist/hooks/versioning-gate.js.map +0 -1
  319. package/dist/hooks/versioning-gate.test.js +0 -368
  320. package/dist/hooks/workflow-gate.d.ts +0 -64
  321. package/dist/hooks/workflow-gate.d.ts.map +0 -1
  322. package/dist/hooks/workflow-gate.js +0 -152
  323. package/dist/hooks/workflow-gate.js.map +0 -1
  324. package/dist/hooks/workflow-gate.test.js +0 -197
  325. package/dist/hooks-cli.d.ts +0 -25
  326. package/dist/hooks-cli.d.ts.map +0 -1
  327. package/dist/hooks-cli.js +0 -286
  328. package/dist/hooks-cli.js.map +0 -1
  329. package/dist/hooks-cli.test.js +0 -148
  330. package/dist/origin.d.ts +0 -16
  331. package/dist/origin.d.ts.map +0 -1
  332. package/dist/origin.js +0 -92
  333. package/dist/origin.js.map +0 -1
  334. package/dist/packs/seed_lessons_ingest.d.ts +0 -30
  335. package/dist/packs/seed_lessons_ingest.d.ts.map +0 -1
  336. package/dist/packs/seed_lessons_ingest.js +0 -107
  337. package/dist/packs/seed_lessons_ingest.js.map +0 -1
  338. package/dist/project-cli.d.ts +0 -7
  339. package/dist/project-cli.d.ts.map +0 -1
  340. package/dist/project-cli.js +0 -145
  341. package/dist/project-cli.js.map +0 -1
  342. package/dist/project.d.ts +0 -127
  343. package/dist/project.d.ts.map +0 -1
  344. package/dist/project.js +0 -281
  345. package/dist/project.js.map +0 -1
  346. package/dist/project.test.js +0 -287
  347. package/dist/rag/backends/loop_engine.d.ts +0 -61
  348. package/dist/rag/backends/loop_engine.d.ts.map +0 -1
  349. package/dist/rag/backends/loop_engine.js +0 -160
  350. package/dist/rag/backends/loop_engine.js.map +0 -1
  351. package/dist/recall.d.ts +0 -82
  352. package/dist/recall.d.ts.map +0 -1
  353. package/dist/recall.js +0 -81
  354. package/dist/recall.js.map +0 -1
  355. package/dist/runtime/agent_bridge/autospawn.d.ts +0 -131
  356. package/dist/runtime/agent_bridge/autospawn.d.ts.map +0 -1
  357. package/dist/runtime/agent_bridge/autospawn.js +0 -251
  358. package/dist/runtime/agent_bridge/autospawn.js.map +0 -1
  359. package/dist/runtime/chain_state.d.ts +0 -124
  360. package/dist/runtime/chain_state.d.ts.map +0 -1
  361. package/dist/runtime/chain_state.js +0 -189
  362. package/dist/runtime/chain_state.js.map +0 -1
  363. package/dist/runtime/hooks/permission_decision.d.ts +0 -34
  364. package/dist/runtime/hooks/permission_decision.d.ts.map +0 -1
  365. package/dist/runtime/hooks/permission_decision.js +0 -39
  366. package/dist/runtime/hooks/permission_decision.js.map +0 -1
  367. package/dist/runtime/workflow_fsm.d.ts +0 -21
  368. package/dist/runtime/workflow_fsm.d.ts.map +0 -1
  369. package/dist/runtime/workflow_fsm.js +0 -25
  370. package/dist/runtime/workflow_fsm.js.map +0 -1
  371. package/dist/runtime/workflow_map.d.ts +0 -26
  372. package/dist/runtime/workflow_map.d.ts.map +0 -1
  373. package/dist/runtime/workflow_map.js +0 -38
  374. package/dist/runtime/workflow_map.js.map +0 -1
  375. package/dist/scope.d.ts +0 -48
  376. package/dist/scope.d.ts.map +0 -1
  377. package/dist/scope.js +0 -111
  378. package/dist/scope.js.map +0 -1
  379. package/dist/setup/cli/topic_create_step.d.ts +0 -84
  380. package/dist/setup/cli/topic_create_step.d.ts.map +0 -1
  381. package/dist/setup/cli/topic_create_step.js +0 -213
  382. package/dist/setup/cli/topic_create_step.js.map +0 -1
  383. package/dist/system-export.d.ts +0 -65
  384. package/dist/system-export.d.ts.map +0 -1
  385. package/dist/system-export.js +0 -194
  386. package/dist/system-export.js.map +0 -1
  387. package/dist/utterance/classifier.d.ts +0 -53
  388. package/dist/utterance/classifier.d.ts.map +0 -1
  389. package/dist/utterance/classifier.js +0 -184
  390. package/dist/utterance/classifier.js.map +0 -1
  391. package/dist/utterance/classifier.test.js +0 -147
@@ -1,39 +0,0 @@
1
- /**
2
- * PreToolUse permission-decision envelope (T-RJ-FOLLOWUPS FU.11).
3
- *
4
- * A PreToolUse hook signals a block in one of two ways:
5
- * - `exit 2` — the simple path, BUT `--dangerously-skip-permissions`
6
- * (= `bypassPermissions` mode) silently IGNORES it (proven live: a
7
- * `git commit` the gate should block ran anyway).
8
- * - a `permissionDecision: "deny"` JSON envelope on stdout (exit 0) — HONORED
9
- * even under `bypassPermissions` (proven live: the call was denied).
10
- *
11
- * So opensquid emits the JSON envelope on every block, making drift gates
12
- * enforce in BOTH normal and bypass permission modes. Pure builder so the shape
13
- * is unit-testable without spawning the hook bin.
14
- */
15
- /**
16
- * Every drift/block message opensquid emits to the user carries a leading 🦑 so
17
- * it's unmistakably opensquid speaking — NOT the agent's own prose, NOT a chat
18
- * message (chat replies via chat_send are deliberately unprefixed). Added HERE at
19
- * the hook EMIT boundary (not in the dispatcher/verdict layer) so skill YAML
20
- * `message:` fields stay clean and the dispatch internals stay emoji-free.
21
- * Idempotent; empty string passes through untouched (nothing to surface).
22
- */
23
- export const SQUID = '🦑';
24
- export function squidPrefix(message) {
25
- if (message.length === 0)
26
- return message;
27
- return message.trimStart().startsWith(SQUID) ? message : `${SQUID} ${message}`;
28
- }
29
- /** Build the deny envelope; falls back to a generic reason when none is given. */
30
- export function buildPreToolUseDeny(reason) {
31
- return {
32
- hookSpecificOutput: {
33
- hookEventName: 'PreToolUse',
34
- permissionDecision: 'deny',
35
- permissionDecisionReason: squidPrefix(reason.length > 0 ? reason : 'opensquid: blocked by a drift gate'),
36
- },
37
- };
38
- }
39
- //# sourceMappingURL=permission_decision.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"permission_decision.js","sourceRoot":"","sources":["../../../src/runtime/hooks/permission_decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;AAC1B,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC;AACjF,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,OAAO;QACL,kBAAkB,EAAE;YAClB,aAAa,EAAE,YAAY;YAC3B,kBAAkB,EAAE,MAAM;YAC1B,wBAAwB,EAAE,WAAW,CACnC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oCAAoC,CAClE;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * T-PACK-FSM-STANDARDIZATION slice A — the 7-phase workflow as a declared FSM.
3
- *
4
- * This models `chain_state.ts`'s pipeline (the same 7 stages, same forward
5
- * order) as data the generic `fsm.ts` engine runs — the preset slice A2 will
6
- * wire in to REPLACE the hardcoded `transitionChainStage` + its 5 scattered
7
- * call-sites. Two things it gains over `chain_state` immediately:
8
- *
9
- * 1. TOTALITY — `validateFsm` proves every transition lands on a real state;
10
- * the runner defines an outcome for every (state, event). `chain_state`'s
11
- * `transitionChainStage` accepts ANY target with no legality check.
12
- * 2. LOOP-BACK — `researched --guess_found--> scoping` is an explicit edge.
13
- * `chain_state` is forward-only (its `idle→scoping` writer even guards
14
- * AGAINST regression), so it structurally cannot re-enter research when an
15
- * unresolved guess is found. That backward edge is exactly what the scope
16
- * guess-prevention gate (slice C) loops on.
17
- */
18
- import type { Fsm } from './fsm.js';
19
- /** Stage order matches `chain_state.ts` CHAIN_STAGES (parity-tested). */
20
- export declare const WORKFLOW_FSM: Fsm;
21
- //# sourceMappingURL=workflow_fsm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow_fsm.d.ts","sourceRoot":"","sources":["../../src/runtime/workflow_fsm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,yEAAyE;AACzE,eAAO,MAAM,YAAY,EAAE,GAsB1B,CAAC"}
@@ -1,25 +0,0 @@
1
- /** Stage order matches `chain_state.ts` CHAIN_STAGES (parity-tested). */
2
- export const WORKFLOW_FSM = {
3
- initial: 'idle',
4
- states: [
5
- 'idle',
6
- 'scoping',
7
- 'researched',
8
- 'spec_authored',
9
- 'tasks_loaded',
10
- 'phases_in_flight',
11
- 'phases_complete',
12
- ],
13
- transitions: [
14
- { from: 'idle', on: 'scope_start', to: 'scoping' },
15
- { from: 'scoping', on: 'research_done', to: 'researched' },
16
- // The loop-back chain_state cannot express: an unresolved guess sends the
17
- // workflow back to scoping/research (slice C drives this edge).
18
- { from: 'researched', on: 'guess_found', to: 'scoping' },
19
- { from: 'researched', on: 'spec_authored', to: 'spec_authored' },
20
- { from: 'spec_authored', on: 'tasks_loaded', to: 'tasks_loaded' },
21
- { from: 'tasks_loaded', on: 'phase_started', to: 'phases_in_flight' },
22
- { from: 'phases_in_flight', on: 'phases_done', to: 'phases_complete' },
23
- ],
24
- };
25
- //# sourceMappingURL=workflow_fsm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow_fsm.js","sourceRoot":"","sources":["../../src/runtime/workflow_fsm.ts"],"names":[],"mappings":"AAmBA,yEAAyE;AACzE,MAAM,CAAC,MAAM,YAAY,GAAQ;IAC/B,OAAO,EAAE,MAAM;IACf,MAAM,EAAE;QACN,MAAM;QACN,SAAS;QACT,YAAY;QACZ,eAAe;QACf,cAAc;QACd,kBAAkB;QAClB,iBAAiB;KAClB;IACD,WAAW,EAAE;QACX,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE;QAClD,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,YAAY,EAAE;QAC1D,0EAA0E;QAC1E,gEAAgE;QAChE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE;QACxD,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,EAAE;QAChE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,EAAE;QACjE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,kBAAkB,EAAE;QACrE,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,iBAAiB,EAAE;KACvE;CACF,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * Workflow forward-map (T-FLOW-COHESION FC.2) — the SINGLE source of "given the
3
- * current chain-stage, what is the next step." When a gate blocks, the hook
4
- * folds this map into the deny message so the agent is pointed FORWARD at the
5
- * wall (current stage + next step) instead of bouncing backward through
6
- * prerequisites. Reads the chain-state FSM, which FC.1 made atomic/trustworthy,
7
- * so no degradation branch is needed — `idle` is a real, correct stage.
8
- *
9
- * `STAGE_NEXT` is the canonical stage→next-step text. The `chain-handoffs` skill
10
- * (prompt_submit reinforcement) describes the same pipeline; this is the
11
- * authoritative source — keep that skill's rationale consistent with it.
12
- *
13
- * Imports from: ./chain_state.js.
14
- * Imported by: src/runtime/hooks/pre-tool-use.ts (block path).
15
- */
16
- import { type ChainStage } from './chain_state.js';
17
- /** Canonical next step for each pipeline stage. Exhaustive over `ChainStage`
18
- * (the compiler enforces every stage has an entry). */
19
- export declare const STAGE_NEXT: Record<ChainStage, string>;
20
- /**
21
- * The compact forward map for a session's current stage: the path, where you
22
- * are, and the single next step. Fail-open: a read error resolves to `idle`
23
- * (the correct fresh-session stage), never throws.
24
- */
25
- export declare function forwardMap(sessionId: string): Promise<string>;
26
- //# sourceMappingURL=workflow_map.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow_map.d.ts","sourceRoot":"","sources":["../../src/runtime/workflow_map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAkB,MAAM,kBAAkB,CAAC;AAEnE;wDACwD;AACxD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CASjD,CAAC;AAIF;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE"}
@@ -1,38 +0,0 @@
1
- /**
2
- * Workflow forward-map (T-FLOW-COHESION FC.2) — the SINGLE source of "given the
3
- * current chain-stage, what is the next step." When a gate blocks, the hook
4
- * folds this map into the deny message so the agent is pointed FORWARD at the
5
- * wall (current stage + next step) instead of bouncing backward through
6
- * prerequisites. Reads the chain-state FSM, which FC.1 made atomic/trustworthy,
7
- * so no degradation branch is needed — `idle` is a real, correct stage.
8
- *
9
- * `STAGE_NEXT` is the canonical stage→next-step text. The `chain-handoffs` skill
10
- * (prompt_submit reinforcement) describes the same pipeline; this is the
11
- * authoritative source — keep that skill's rationale consistent with it.
12
- *
13
- * Imports from: ./chain_state.js.
14
- * Imported by: src/runtime/hooks/pre-tool-use.ts (block path).
15
- */
16
- import { readChainState } from './chain_state.js';
17
- /** Canonical next step for each pipeline stage. Exhaustive over `ChainStage`
18
- * (the compiler enforces every stage has an entry). */
19
- export const STAGE_NEXT = {
20
- idle: 'no active scope — scope it first: write the pre-research doc (docs/research/<slug>-pre-research-*.md)',
21
- scoping: 'write the pre-research doc (docs/research/<slug>-pre-research-*.md)',
22
- researched: 'author the track spec via the task-spec-author profession (consume the pre-research)',
23
- spec_authored: 'TaskCreate each "### Task" with metadata.spec = the spec\'s absolute path',
24
- tasks_loaded: 'set the task in_progress, then log_phase through the 7 phases as you work',
25
- phases_in_flight: 'resume at the next unlogged phase; log_phase as each of the 7 completes',
26
- phases_complete: 'workflow complete for the active task — the terminal action is allowed',
27
- };
28
- const PATH_LINE = 'Workflow: pre_research → spec → tasks → 7 phases → commit';
29
- /**
30
- * The compact forward map for a session's current stage: the path, where you
31
- * are, and the single next step. Fail-open: a read error resolves to `idle`
32
- * (the correct fresh-session stage), never throws.
33
- */
34
- export async function forwardMap(sessionId) {
35
- const stage = (await readChainState(sessionId).catch(() => null))?.stage ?? 'idle';
36
- return `${PATH_LINE}\nYou are at: ${stage}\nNext: ${STAGE_NEXT[stage]}`;
37
- }
38
- //# sourceMappingURL=workflow_map.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow_map.js","sourceRoot":"","sources":["../../src/runtime/workflow_map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnE;wDACwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAA+B;IACpD,IAAI,EAAE,uGAAuG;IAC7G,OAAO,EAAE,qEAAqE;IAC9E,UAAU,EACR,sFAAsF;IACxF,aAAa,EAAE,2EAA2E;IAC1F,YAAY,EAAE,2EAA2E;IACzF,gBAAgB,EAAE,yEAAyE;IAC3F,eAAe,EAAE,wEAAwE;CAC1F,CAAC;AAEF,MAAM,SAAS,GAAG,2DAA2D,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAAiB;IAChD,MAAM,KAAK,GAAe,CAAC,MAAM,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,IAAI,MAAM,CAAC;IAC/F,OAAO,GAAG,SAAS,iBAAiB,KAAK,WAAW,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1E,CAAC"}
package/dist/scope.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import type { MemoryScope } from "./engine-client.js";
2
- export interface DetectedProject {
3
- project: string;
4
- }
5
- /**
6
- * Sync detection (v0.3.1 surface). Does NOT consult the project ID
7
- * card. Use the async variant for v0.4+ behavior.
8
- */
9
- export declare function detectProjectScope(cwd?: string): DetectedProject | null;
10
- /**
11
- * v0.4: async detection that consults the project ID card first.
12
- *
13
- * Order:
14
- * 1. OPENSQUID_PROJECT env → wins
15
- * 2. .opensquid/project.json card (any ancestor of cwd) → stable id
16
- * 3. git basename → fallback
17
- * 4. null
18
- */
19
- export declare function detectProjectScopeAsync(cwd?: string): Promise<DetectedProject | null>;
20
- /**
21
- * Sync default-memorize-scope (v0.3.1 surface).
22
- */
23
- export declare function defaultMemorizeScope(cwd?: string): MemoryScope;
24
- /**
25
- * v0.4: async default-memorize-scope that consults the project ID
26
- * card. Also AUTO-CREATES the card on first call in a new project
27
- * (so the second call onward gets a stable id even if the user
28
- * renames the directory). Pass `autoCreate: false` to skip creation.
29
- */
30
- export declare function defaultMemorizeScopeAsync(cwd?: string, options?: {
31
- autoCreate?: boolean;
32
- }): Promise<MemoryScope>;
33
- /**
34
- * Sync default-recall-scope-filter (v0.3.1 surface).
35
- */
36
- export declare function defaultRecallScopeFilter(cwd?: string): {
37
- kind: "any_of";
38
- scopes: MemoryScope[];
39
- };
40
- /**
41
- * v0.4: async default-recall-scope-filter that consults the project
42
- * ID card. Does NOT auto-create a card — recall is read-only.
43
- */
44
- export declare function defaultRecallScopeFilterAsync(cwd?: string): Promise<{
45
- kind: "any_of";
46
- scopes: MemoryScope[];
47
- }>;
48
- //# sourceMappingURL=scope.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src.legacy/scope.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAsB,GAAG,eAAe,GAAG,IAAI,CAetF;AAED;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAQjC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAG9D;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,GAAE,MAAsB,EAC3B,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACrC,OAAO,CAAC,WAAW,CAAC,CAiBtB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG;IACtD,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB,CAKA;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,CAKpD"}
package/dist/scope.js DELETED
@@ -1,111 +0,0 @@
1
- /**
2
- * Project-scope auto-detection for memorize/recall defaults.
3
- *
4
- * Priority order (v0.4+ with project ID card):
5
- * 1. `OPENSQUID_PROJECT` env var — explicit override, always wins.
6
- * 2. **Project ID card** at `.opensquid/project.json` (walking up from
7
- * cwd) — stable across moves/renames. v0.4 addition.
8
- * 3. `git rev-parse --show-toplevel` basename — fallback for projects
9
- * that don't have a card yet (auto-created on first memorize).
10
- * 4. `null` — caller falls back to `MemoryScope::User`.
11
- *
12
- * The sync helpers below keep the v0.3 wire surface; the async
13
- * variants consult the ID card and are preferred for new call sites.
14
- */
15
- import { execSync } from "node:child_process";
16
- import * as path from "node:path";
17
- import { applyResolution, findProjectCard, resolveProject } from "./project.js";
18
- /**
19
- * Sync detection (v0.3.1 surface). Does NOT consult the project ID
20
- * card. Use the async variant for v0.4+ behavior.
21
- */
22
- export function detectProjectScope(cwd = process.cwd()) {
23
- const explicit = process.env.OPENSQUID_PROJECT?.trim();
24
- if (explicit)
25
- return { project: explicit };
26
- try {
27
- const root = execSync("git rev-parse --show-toplevel", {
28
- cwd,
29
- encoding: "utf8",
30
- stdio: ["ignore", "pipe", "ignore"],
31
- }).trim();
32
- if (root)
33
- return { project: path.basename(root) };
34
- }
35
- catch {
36
- // Not a git repo, or git not installed — fall through.
37
- }
38
- return null;
39
- }
40
- /**
41
- * v0.4: async detection that consults the project ID card first.
42
- *
43
- * Order:
44
- * 1. OPENSQUID_PROJECT env → wins
45
- * 2. .opensquid/project.json card (any ancestor of cwd) → stable id
46
- * 3. git basename → fallback
47
- * 4. null
48
- */
49
- export async function detectProjectScopeAsync(cwd = process.cwd()) {
50
- const explicit = process.env.OPENSQUID_PROJECT?.trim();
51
- if (explicit)
52
- return { project: explicit };
53
- const card = await findProjectCard(cwd);
54
- if (card)
55
- return { project: card.card.id };
56
- return detectProjectScope(cwd);
57
- }
58
- /**
59
- * Sync default-memorize-scope (v0.3.1 surface).
60
- */
61
- export function defaultMemorizeScope(cwd) {
62
- const detected = detectProjectScope(cwd);
63
- return detected ? { project: detected.project } : "user";
64
- }
65
- /**
66
- * v0.4: async default-memorize-scope that consults the project ID
67
- * card. Also AUTO-CREATES the card on first call in a new project
68
- * (so the second call onward gets a stable id even if the user
69
- * renames the directory). Pass `autoCreate: false` to skip creation.
70
- */
71
- export async function defaultMemorizeScopeAsync(cwd = process.cwd(), options = {}) {
72
- const explicit = process.env.OPENSQUID_PROJECT?.trim();
73
- if (explicit)
74
- return { project: explicit };
75
- const card = await findProjectCard(cwd);
76
- if (card)
77
- return { project: card.card.id };
78
- // No card yet — auto-create if allowed, otherwise fall through to
79
- // sync detection (returns git basename or "user").
80
- if (options.autoCreate !== false) {
81
- const resolved = await resolveProject(cwd);
82
- if (resolved.kind === "new") {
83
- const created = await applyResolution(cwd, resolved, { autoCreate: true });
84
- if (created)
85
- return { project: created.id };
86
- }
87
- }
88
- return defaultMemorizeScope(cwd);
89
- }
90
- /**
91
- * Sync default-recall-scope-filter (v0.3.1 surface).
92
- */
93
- export function defaultRecallScopeFilter(cwd) {
94
- const detected = detectProjectScope(cwd);
95
- const scopes = ["user"];
96
- if (detected)
97
- scopes.push({ project: detected.project });
98
- return { kind: "any_of", scopes };
99
- }
100
- /**
101
- * v0.4: async default-recall-scope-filter that consults the project
102
- * ID card. Does NOT auto-create a card — recall is read-only.
103
- */
104
- export async function defaultRecallScopeFilterAsync(cwd = process.cwd()) {
105
- const detected = await detectProjectScopeAsync(cwd);
106
- const scopes = ["user"];
107
- if (detected)
108
- scopes.push({ project: detected.project });
109
- return { kind: "any_of", scopes };
110
- }
111
- //# sourceMappingURL=scope.js.map
package/dist/scope.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../src.legacy/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMhF;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,OAAO,CAAC,GAAG,EAAE;IAC5D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,IA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AAE;IAE3B,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,MAAM,GAAkB,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,QAAQ;QAAE,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACpC,CAAC"}
@@ -1,84 +0,0 @@
1
- /**
2
- * TPS.4 — first-run topic-create step for the chat-setup wizard.
3
- *
4
- * Slots between WIZ.3 (executePlan: writes models.yaml + chat_agent.yaml)
5
- * and WIZ.4 (runChannelTestStep). When the user has a Telegram supergroup
6
- * configured, offers to auto-create a forum topic for the current
7
- * workspace + bind it via TPS.3's `resolveOrCreateTopic`. Opt-out (default
8
- * = yes). On accept, the workspace's per-project `chat-routing.json` gets
9
- * an `auto_bound` block + the new topic_id added to `inbound_topic_ids`,
10
- * so the next WIZ.4 test (and subsequent agent traffic) lands in the
11
- * freshly-bound topic.
12
- *
13
- * Why not import `resolveOrCreateTopic` statically: `src.legacy/` is
14
- * excluded from `tsconfig.json`. The whole-tree typecheck can't see legacy
15
- * exports, and `tsconfig.build.json` doesn't emit them either. We load
16
- * the legacy module at runtime via a path computed from `import.meta.url`
17
- * — the runtime location is `dist/chat/daemon/workspace-topic.js` (built
18
- * by the ad-hoc `pnpm exec tsc src.legacy/...` invocation documented in
19
- * `src.legacy/chat/adapters/telegram.ts`). Tests inject a fake
20
- * `resolveOrCreateTopic` via the `deps` interface and bypass the loader.
21
- *
22
- * Never throws past the wizard — mirrors WIZ.4's contract. Every failure
23
- * prints a recovery hint via `note()` and returns. The WIZ.3 writes are
24
- * already on disk by the time this step runs; failure here leaves the
25
- * user with a working config minus the auto-binding.
26
- */
27
- import type { ChatDaemonState } from './chat_state.js';
28
- export interface ResolveTopicArgs {
29
- workspaceUuid: string;
30
- workspacePath: string;
31
- chatId: string;
32
- mode: 'wizard' | 'auto-boot' | 'manual';
33
- dataRoot?: string;
34
- }
35
- export interface ResolveTopicResult {
36
- topicId: number;
37
- topicName: string;
38
- created: boolean;
39
- }
40
- export type ResolveOrCreateTopicFn = (args: ResolveTopicArgs) => Promise<ResolveTopicResult>;
41
- export interface TopicCreateDeps {
42
- /** WIZ.2 daemon snapshot — same source the WIZ.4 sibling uses. */
43
- daemonState: ChatDaemonState;
44
- /** Cwd-walk start (test injection). Defaults to process.cwd(). */
45
- cwd?: string;
46
- /** Env override sink (test injection). Defaults to process.env. */
47
- env?: NodeJS.ProcessEnv;
48
- /**
49
- * Override the topic-resolver (test injection). Defaults to the
50
- * runtime-loaded `resolveOrCreateTopic` from `dist/chat/daemon/
51
- * workspace-topic.js`. Tests substitute a stub here to avoid both the
52
- * dist dependency and the daemon RPC round-trip.
53
- */
54
- resolveOrCreateTopic?: ResolveOrCreateTopicFn;
55
- /**
56
- * Override the routing-read function (test injection). Defaults to
57
- * reading `~/.opensquid/projects/<uuid>/chat-routing.json`.
58
- */
59
- loadRouting?: (uuid: string) => Promise<ProjectChatRouting | null>;
60
- }
61
- export interface ProjectChatRouting {
62
- telegram?: {
63
- report_channel?: string;
64
- report_topic_id?: number;
65
- inbound_chat_ids?: string[];
66
- inbound_topic_ids?: number[];
67
- auto_bound?: {
68
- workspace_path: string;
69
- workspace_uuid: string;
70
- topic_id: number;
71
- topic_name: string;
72
- created_at: string;
73
- created_by: string;
74
- };
75
- };
76
- discord?: {
77
- report_channel?: string;
78
- };
79
- slack?: {
80
- report_channel?: string;
81
- };
82
- }
83
- export declare function runTopicCreateStep(deps: TopicCreateDeps): Promise<void>;
84
- //# sourceMappingURL=topic_create_step.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"topic_create_step.d.ts","sourceRoot":"","sources":["../../../src/setup/cli/topic_create_step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAWH,OAAO,KAAK,E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EAAE,MAAM,CAAC;SACpB,CAAC;KACH,CAAC;IACF,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,KAAK,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC;AAMD,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAwE7E"}
@@ -1,213 +0,0 @@
1
- /**
2
- * TPS.4 — first-run topic-create step for the chat-setup wizard.
3
- *
4
- * Slots between WIZ.3 (executePlan: writes models.yaml + chat_agent.yaml)
5
- * and WIZ.4 (runChannelTestStep). When the user has a Telegram supergroup
6
- * configured, offers to auto-create a forum topic for the current
7
- * workspace + bind it via TPS.3's `resolveOrCreateTopic`. Opt-out (default
8
- * = yes). On accept, the workspace's per-project `chat-routing.json` gets
9
- * an `auto_bound` block + the new topic_id added to `inbound_topic_ids`,
10
- * so the next WIZ.4 test (and subsequent agent traffic) lands in the
11
- * freshly-bound topic.
12
- *
13
- * Why not import `resolveOrCreateTopic` statically: `src.legacy/` is
14
- * excluded from `tsconfig.json`. The whole-tree typecheck can't see legacy
15
- * exports, and `tsconfig.build.json` doesn't emit them either. We load
16
- * the legacy module at runtime via a path computed from `import.meta.url`
17
- * — the runtime location is `dist/chat/daemon/workspace-topic.js` (built
18
- * by the ad-hoc `pnpm exec tsc src.legacy/...` invocation documented in
19
- * `src.legacy/chat/adapters/telegram.ts`). Tests inject a fake
20
- * `resolveOrCreateTopic` via the `deps` interface and bypass the loader.
21
- *
22
- * Never throws past the wizard — mirrors WIZ.4's contract. Every failure
23
- * prints a recovery hint via `note()` and returns. The WIZ.3 writes are
24
- * already on disk by the time this step runs; failure here leaves the
25
- * user with a working config minus the auto-binding.
26
- */
27
- import { readFile } from 'node:fs/promises';
28
- import { dirname, join, resolve } from 'node:path';
29
- import { fileURLToPath, pathToFileURL } from 'node:url';
30
- import { confirm, isCancel, note, spinner } from '@clack/prompts';
31
- import pc from 'picocolors';
32
- import { OPENSQUID_HOME, resolveProjectUuid } from '../../runtime/paths.js';
33
- // ---------------------------------------------------------------------------
34
- // runTopicCreateStep — TPS.4 entry point. Returns void; never throws.
35
- // ---------------------------------------------------------------------------
36
- export async function runTopicCreateStep(deps) {
37
- const env = deps.env ?? process.env;
38
- if (env.OPENSQUID_NO_BILLED_CALLS === '1') {
39
- note('Topic-create skipped (OPENSQUID_NO_BILLED_CALLS=1).', 'Topic');
40
- return;
41
- }
42
- // Pre-flight: daemon liveness (same snapshot WIZ.4 uses).
43
- if (!deps.daemonState.running) {
44
- note(daemonNotRunningHint(deps.daemonState.pidPath), 'Topic');
45
- return;
46
- }
47
- const workspaceUuid = await resolveProjectUuid({
48
- cwd: deps.cwd ?? process.cwd(),
49
- env,
50
- });
51
- if (workspaceUuid === null) {
52
- note(noProjectUuidHint(), 'Topic');
53
- return;
54
- }
55
- const loadRouting = deps.loadRouting ?? loadProjectChatRouting;
56
- const routing = await loadRouting(workspaceUuid);
57
- const chatId = routing?.telegram?.report_channel;
58
- if (chatId === undefined || chatId.length === 0) {
59
- note(noSupergroupHint(), 'Topic');
60
- return;
61
- }
62
- const proceed = await confirm({
63
- message: 'Create a Telegram forum topic for this workspace so its messages are isolated from other projects?',
64
- initialValue: true,
65
- });
66
- if (isCancel(proceed) || proceed !== true) {
67
- note('Topic-create skipped — workspace messages will land in the supergroup general topic.', 'Topic');
68
- return;
69
- }
70
- const workspacePath = deps.cwd ?? process.cwd();
71
- const resolver = deps.resolveOrCreateTopic ?? (await loadLegacyResolver());
72
- const s = spinner();
73
- s.start('Creating topic (or reusing existing binding)...');
74
- try {
75
- const result = await resolver({
76
- workspaceUuid,
77
- workspacePath: resolve(workspacePath),
78
- chatId,
79
- mode: 'wizard',
80
- });
81
- if (result.created) {
82
- s.stop(pc.green(`Created topic "${result.topicName}" (thread_id=${String(result.topicId)}). Bound to this workspace.`));
83
- }
84
- else {
85
- s.stop(pc.green(`Existing topic "${result.topicName}" (thread_id=${String(result.topicId)}) reused. Workspace already bound.`));
86
- }
87
- }
88
- catch (err) {
89
- s.stop(pc.red(`Topic-create failed: ${describeError(err)}`));
90
- note(recoveryHintFor(err), 'Topic');
91
- }
92
- }
93
- // ---------------------------------------------------------------------------
94
- // Default routing reader — duplicates WIZ.4's inlined reader. Same
95
- // type-poison avoidance rationale documented in chat_actions_test_step.ts.
96
- // ---------------------------------------------------------------------------
97
- async function loadProjectChatRouting(uuid) {
98
- const p = join(OPENSQUID_HOME(), 'projects', uuid, 'chat-routing.json');
99
- try {
100
- const raw = await readFile(p, 'utf8');
101
- return JSON.parse(raw);
102
- }
103
- catch (err) {
104
- if (err.code === 'ENOENT')
105
- return null;
106
- return null;
107
- }
108
- }
109
- // ---------------------------------------------------------------------------
110
- // Lazy legacy-resolver loader — resolves at first call so tests that
111
- // inject `deps.resolveOrCreateTopic` never trigger the dist read. Path
112
- // is constructed from `import.meta.url` (runtime location) rather than
113
- // a static import string so the tsconfig src.legacy exclude is honored.
114
- // ---------------------------------------------------------------------------
115
- async function loadLegacyResolver() {
116
- const here = dirname(fileURLToPath(import.meta.url));
117
- // Runtime: this file is at dist/setup/cli/topic_create_step.js;
118
- // workspace-topic.js lives at dist/chat/daemon/workspace-topic.js.
119
- const target = resolve(here, '..', '..', 'chat', 'daemon', 'workspace-topic.js');
120
- const mod = (await import(pathToFileURL(target).href));
121
- if (typeof mod.resolveOrCreateTopic !== 'function') {
122
- throw new Error(`legacy workspace-topic module at ${target} did not export resolveOrCreateTopic — rebuild dist/chat/daemon/* per the src.legacy header instructions`);
123
- }
124
- return mod.resolveOrCreateTopic;
125
- }
126
- // ---------------------------------------------------------------------------
127
- // Error classification — maps known TPS.3 failure modes to user-actionable
128
- // recovery hints. Catch-all returns a generic "see daemon logs" hint.
129
- // Detection is message-substring based (Telegram + grammy error messages
130
- // pass through resolveOrCreateTopic unchanged).
131
- // ---------------------------------------------------------------------------
132
- function describeError(err) {
133
- if (err instanceof Error)
134
- return err.message;
135
- return String(err);
136
- }
137
- function recoveryHintFor(err) {
138
- const msg = describeError(err);
139
- const lower = msg.toLowerCase();
140
- // 403 — bot lacks can_manage_topics. Telegram returns "Bad Request:
141
- // CHAT_ADMIN_REQUIRED" or "Forbidden: ...".
142
- if (lower.includes('chat_admin_required') ||
143
- lower.includes('can_manage_topics') ||
144
- msg.includes('403') ||
145
- lower.includes('forbidden')) {
146
- return [
147
- "The bot needs the 'Manage Topics' admin permission on this supergroup.",
148
- 'In Telegram: open the group → Edit → Administrators → your bot → enable Manage Topics.',
149
- 'Then re-run `opensquid setup chat` and accept the topic-create step.',
150
- ].join('\n');
151
- }
152
- // 429 — rate-limited.
153
- if (msg.includes('429') || lower.includes('too many requests') || lower.includes('retry after')) {
154
- return [
155
- 'Telegram is rate-limiting topic creation for this bot.',
156
- 'Wait a minute, then re-run `opensquid setup chat` and accept the topic-create step.',
157
- ].join('\n');
158
- }
159
- // 400 — forum topics disabled on the supergroup.
160
- if ((msg.includes('400') && (lower.includes('topic') || lower.includes('forum'))) ||
161
- lower.includes('topics_disabled') ||
162
- lower.includes('not a forum')) {
163
- return [
164
- 'Forum topics are not enabled on this supergroup.',
165
- 'In Telegram: open the group → Edit → Topics → enable Topics.',
166
- 'Then re-run `opensquid setup chat` and accept the topic-create step.',
167
- ].join('\n');
168
- }
169
- // Lockfile LOCKED — another opensquid process is binding.
170
- if (lower.includes('elocked') || lower.includes('lock')) {
171
- return [
172
- 'Another opensquid process is binding a topic for this workspace right now.',
173
- 'Wait a few seconds and re-run `opensquid setup chat`.',
174
- ].join('\n');
175
- }
176
- // Persist failed AFTER createTopic — orphan recorded.
177
- if (lower.includes('orphan') || (lower.includes('persist') && lower.includes('fail'))) {
178
- return [
179
- 'A topic was created on Telegram but the local binding write failed.',
180
- 'The orphan was logged to ~/.opensquid/orphan-topics.jsonl for manual cleanup.',
181
- 'Re-run `opensquid setup chat` after fixing the disk / permissions issue.',
182
- ].join('\n');
183
- }
184
- return [
185
- 'See `~/.opensquid/chat-daemon.log` for daemon-side detail.',
186
- 'Re-run `opensquid setup chat` to retry the topic-create step.',
187
- ].join('\n');
188
- }
189
- // ---------------------------------------------------------------------------
190
- // Static-text hints (same shape as WIZ.4 sibling)
191
- // ---------------------------------------------------------------------------
192
- function daemonNotRunningHint(pidPath) {
193
- return [
194
- `The chat-daemon is not running (pidfile: ${pidPath}).`,
195
- 'Start it with:',
196
- ' opensquid chat-daemon start',
197
- 'then re-run `opensquid setup chat` and accept the topic-create step.',
198
- ].join('\n');
199
- }
200
- function noProjectUuidHint() {
201
- return [
202
- 'Could not resolve the active project UUID.',
203
- 'Run `opensquid init` in this directory, or set OPENSQUID_PROJECT_UUID.',
204
- ].join('\n');
205
- }
206
- function noSupergroupHint() {
207
- return [
208
- 'No Telegram supergroup is configured for this workspace.',
209
- 'Set `report_channel` in ~/.opensquid/projects/<uuid>/chat-routing.json,',
210
- 'then re-run `opensquid setup chat` to bind a workspace topic.',
211
- ].join('\n');
212
- }
213
- //# sourceMappingURL=topic_create_step.js.map