opensquid 0.5.441 → 0.5.447

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 (380) 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/runtime/bootstrap.d.ts.map +1 -1
  11. package/dist/runtime/bootstrap.js +2 -0
  12. package/dist/runtime/bootstrap.js.map +1 -1
  13. package/dist/runtime/handoff/render.d.ts +5 -4
  14. package/dist/runtime/handoff/render.d.ts.map +1 -1
  15. package/dist/runtime/handoff/render.js +7 -7
  16. package/dist/runtime/handoff/render.js.map +1 -1
  17. package/dist/runtime/hooks/active_task_mirror.js +0 -0
  18. package/dist/runtime/hooks/apply_patch.js +0 -0
  19. package/dist/runtime/hooks/dispatch.js +0 -0
  20. package/dist/runtime/hooks/hook_output.js +0 -0
  21. package/dist/runtime/hooks/memory_reconcile.js +0 -0
  22. package/dist/runtime/hooks/new_project_detect.js +0 -0
  23. package/dist/runtime/hooks/profession_resolver.js +0 -0
  24. package/dist/runtime/hooks/scope_intent.js +0 -0
  25. package/dist/runtime/hooks/session_id.js +0 -0
  26. package/dist/runtime/hooks/session_liveness.js +0 -0
  27. package/dist/runtime/hooks/stop_drive.js +0 -0
  28. package/dist/runtime/hooks/stop_stream.js +0 -0
  29. package/dist/runtime/hooks/subagent_guard.js +0 -0
  30. package/dist/runtime/hooks/transcript.js +0 -0
  31. package/dist/runtime/hooks/transcript_tasks.js +0 -0
  32. package/dist/runtime/ralph/orchestrator.d.ts.map +1 -1
  33. package/dist/runtime/ralph/orchestrator.js +2 -1
  34. package/dist/runtime/ralph/orchestrator.js.map +1 -1
  35. package/dist/setup/cli/limits_state.d.ts.map +1 -1
  36. package/dist/setup/cli/limits_state.js +6 -40
  37. package/dist/setup/cli/limits_state.js.map +1 -1
  38. package/dist/setup/cli/pack_walk.d.ts +32 -0
  39. package/dist/setup/cli/pack_walk.d.ts.map +1 -0
  40. package/dist/setup/cli/pack_walk.js +76 -0
  41. package/dist/setup/cli/pack_walk.js.map +1 -0
  42. package/dist/setup/cli/permissions_state.d.ts.map +1 -1
  43. package/dist/setup/cli/permissions_state.js +6 -37
  44. package/dist/setup/cli/permissions_state.js.map +1 -1
  45. package/dist/setup/cli/triggers_state.d.ts.map +1 -1
  46. package/dist/setup/cli/triggers_state.js +3 -29
  47. package/dist/setup/cli/triggers_state.js.map +1 -1
  48. package/dist/workgraph/events.d.ts.map +1 -1
  49. package/dist/workgraph/events.js +10 -0
  50. package/dist/workgraph/events.js.map +1 -1
  51. package/dist/workgraph/store.d.ts.map +1 -1
  52. package/dist/workgraph/store.js +5 -0
  53. package/dist/workgraph/store.js.map +1 -1
  54. package/dist/workgraph/types.d.ts +2 -1
  55. package/dist/workgraph/types.d.ts.map +1 -1
  56. package/docs/ARCHITECTURE.md +268 -0
  57. package/package.json +5 -3
  58. package/packs/builtin/coding-flow/skills/entry-and-handoffs/skill.yaml +13 -17
  59. package/dist/anti-drift/evaluator.d.ts +0 -88
  60. package/dist/anti-drift/evaluator.d.ts.map +0 -1
  61. package/dist/anti-drift/evaluator.js +0 -417
  62. package/dist/anti-drift/evaluator.js.map +0 -1
  63. package/dist/anti-drift/evaluator.test.js +0 -78
  64. package/dist/anti-drift/rules.d.ts +0 -80
  65. package/dist/anti-drift/rules.d.ts.map +0 -1
  66. package/dist/anti-drift/rules.js +0 -368
  67. package/dist/anti-drift/rules.js.map +0 -1
  68. package/dist/anti-drift/rules.test.js +0 -213
  69. package/dist/anti-drift/state.d.ts +0 -107
  70. package/dist/anti-drift/state.d.ts.map +0 -1
  71. package/dist/anti-drift/state.js +0 -177
  72. package/dist/anti-drift/state.js.map +0 -1
  73. package/dist/anti-drift/state.test.js +0 -120
  74. package/dist/chat/adapters/discord.d.ts +0 -41
  75. package/dist/chat/adapters/discord.d.ts.map +0 -1
  76. package/dist/chat/adapters/discord.js +0 -176
  77. package/dist/chat/adapters/discord.js.map +0 -1
  78. package/dist/chat/adapters/discord.test.js +0 -25
  79. package/dist/chat/adapters/slack.d.ts +0 -43
  80. package/dist/chat/adapters/slack.d.ts.map +0 -1
  81. package/dist/chat/adapters/slack.js +0 -172
  82. package/dist/chat/adapters/slack.js.map +0 -1
  83. package/dist/chat/adapters/slack.test.js +0 -30
  84. package/dist/chat/adapters/telegram.d.ts +0 -148
  85. package/dist/chat/adapters/telegram.d.ts.map +0 -1
  86. package/dist/chat/adapters/telegram.js +0 -498
  87. package/dist/chat/adapters/telegram.js.map +0 -1
  88. package/dist/chat/adapters/telegram.test.js +0 -94
  89. package/dist/chat/config.d.ts +0 -98
  90. package/dist/chat/config.d.ts.map +0 -1
  91. package/dist/chat/config.js +0 -185
  92. package/dist/chat/config.js.map +0 -1
  93. package/dist/chat/daemon/active-project.d.ts +0 -17
  94. package/dist/chat/daemon/active-project.d.ts.map +0 -1
  95. package/dist/chat/daemon/active-project.js +0 -23
  96. package/dist/chat/daemon/active-project.js.map +0 -1
  97. package/dist/chat/daemon/autospawn.d.ts +0 -40
  98. package/dist/chat/daemon/autospawn.d.ts.map +0 -1
  99. package/dist/chat/daemon/autospawn.js +0 -129
  100. package/dist/chat/daemon/autospawn.js.map +0 -1
  101. package/dist/chat/daemon/autospawn.test.js +0 -112
  102. package/dist/chat/daemon/cli.d.ts +0 -18
  103. package/dist/chat/daemon/cli.d.ts.map +0 -1
  104. package/dist/chat/daemon/cli.js +0 -71
  105. package/dist/chat/daemon/cli.js.map +0 -1
  106. package/dist/chat/daemon/collisions.js +0 -384
  107. package/dist/chat/daemon/health-check.d.ts +0 -69
  108. package/dist/chat/daemon/health-check.d.ts.map +0 -1
  109. package/dist/chat/daemon/health-check.js +0 -112
  110. package/dist/chat/daemon/health-check.js.map +0 -1
  111. package/dist/chat/daemon/inbox-read.d.ts +0 -35
  112. package/dist/chat/daemon/inbox-read.d.ts.map +0 -1
  113. package/dist/chat/daemon/inbox-read.js +0 -75
  114. package/dist/chat/daemon/inbox-read.js.map +0 -1
  115. package/dist/chat/daemon/inbox-read.test.js +0 -97
  116. package/dist/chat/daemon/inbox.d.ts +0 -63
  117. package/dist/chat/daemon/inbox.d.ts.map +0 -1
  118. package/dist/chat/daemon/inbox.js +0 -56
  119. package/dist/chat/daemon/inbox.js.map +0 -1
  120. package/dist/chat/daemon/inbox.test.js +0 -110
  121. package/dist/chat/daemon/lifecycle.d.ts +0 -71
  122. package/dist/chat/daemon/lifecycle.d.ts.map +0 -1
  123. package/dist/chat/daemon/lifecycle.js +0 -221
  124. package/dist/chat/daemon/lifecycle.js.map +0 -1
  125. package/dist/chat/daemon/lifecycle.test.js +0 -163
  126. package/dist/chat/daemon/protocol.d.ts +0 -107
  127. package/dist/chat/daemon/protocol.d.ts.map +0 -1
  128. package/dist/chat/daemon/protocol.js +0 -54
  129. package/dist/chat/daemon/protocol.js.map +0 -1
  130. package/dist/chat/daemon/routing.d.ts +0 -140
  131. package/dist/chat/daemon/routing.d.ts.map +0 -1
  132. package/dist/chat/daemon/routing.js +0 -198
  133. package/dist/chat/daemon/routing.js.map +0 -1
  134. package/dist/chat/daemon/routing.test.js +0 -259
  135. package/dist/chat/daemon/rpc-client.d.ts +0 -45
  136. package/dist/chat/daemon/rpc-client.d.ts.map +0 -1
  137. package/dist/chat/daemon/rpc-client.js +0 -133
  138. package/dist/chat/daemon/rpc-client.js.map +0 -1
  139. package/dist/chat/daemon/rpc-server.d.ts +0 -39
  140. package/dist/chat/daemon/rpc-server.d.ts.map +0 -1
  141. package/dist/chat/daemon/rpc-server.js +0 -385
  142. package/dist/chat/daemon/rpc-server.js.map +0 -1
  143. package/dist/chat/daemon/rpc.test.js +0 -177
  144. package/dist/chat/daemon/subscribers.js +0 -257
  145. package/dist/chat/daemon/worker.d.ts +0 -27
  146. package/dist/chat/daemon/worker.d.ts.map +0 -1
  147. package/dist/chat/daemon/worker.js +0 -313
  148. package/dist/chat/daemon/worker.js.map +0 -1
  149. package/dist/chat/daemon/workspace-topic.js +0 -324
  150. package/dist/chat/env-token.d.ts +0 -60
  151. package/dist/chat/env-token.d.ts.map +0 -1
  152. package/dist/chat/env-token.js +0 -137
  153. package/dist/chat/env-token.js.map +0 -1
  154. package/dist/chat/env-token.test.js +0 -160
  155. package/dist/chat/factory.d.ts +0 -30
  156. package/dist/chat/factory.d.ts.map +0 -1
  157. package/dist/chat/factory.js +0 -50
  158. package/dist/chat/factory.js.map +0 -1
  159. package/dist/chat/factory.test.js +0 -55
  160. package/dist/chat/gateway.d.ts +0 -176
  161. package/dist/chat/gateway.d.ts.map +0 -1
  162. package/dist/chat/gateway.js +0 -146
  163. package/dist/chat/gateway.js.map +0 -1
  164. package/dist/chat/gateway.test.js +0 -192
  165. package/dist/claude-md.d.ts +0 -39
  166. package/dist/claude-md.d.ts.map +0 -1
  167. package/dist/claude-md.js +0 -113
  168. package/dist/claude-md.js.map +0 -1
  169. package/dist/claude-md.test.js +0 -91
  170. package/dist/codex/activate.d.ts +0 -66
  171. package/dist/codex/activate.d.ts.map +0 -1
  172. package/dist/codex/activate.js +0 -329
  173. package/dist/codex/activate.js.map +0 -1
  174. package/dist/codex/activate.test.js +0 -229
  175. package/dist/codex/bundled-default/bundled-default.test.js +0 -161
  176. package/dist/codex/cli-publish.test.js +0 -133
  177. package/dist/codex/cli.d.ts +0 -35
  178. package/dist/codex/cli.d.ts.map +0 -1
  179. package/dist/codex/cli.js +0 -554
  180. package/dist/codex/cli.js.map +0 -1
  181. package/dist/codex/cli.test.js +0 -277
  182. package/dist/codex/import-skill-md.d.ts +0 -53
  183. package/dist/codex/import-skill-md.d.ts.map +0 -1
  184. package/dist/codex/import-skill-md.js +0 -236
  185. package/dist/codex/import-skill-md.js.map +0 -1
  186. package/dist/codex/import-skill-md.test.js +0 -225
  187. package/dist/codex/loader.d.ts +0 -27
  188. package/dist/codex/loader.d.ts.map +0 -1
  189. package/dist/codex/loader.js +0 -86
  190. package/dist/codex/loader.js.map +0 -1
  191. package/dist/codex/loader.test.js +0 -75
  192. package/dist/codex/parse.d.ts +0 -28
  193. package/dist/codex/parse.d.ts.map +0 -1
  194. package/dist/codex/parse.js +0 -309
  195. package/dist/codex/parse.js.map +0 -1
  196. package/dist/codex/parse.test.js +0 -241
  197. package/dist/codex/store.d.ts +0 -87
  198. package/dist/codex/store.d.ts.map +0 -1
  199. package/dist/codex/store.js +0 -205
  200. package/dist/codex/store.js.map +0 -1
  201. package/dist/codex/store.test.js +0 -242
  202. package/dist/codex/types.d.ts +0 -398
  203. package/dist/codex/types.d.ts.map +0 -1
  204. package/dist/codex/types.js +0 -21
  205. package/dist/codex/types.js.map +0 -1
  206. package/dist/config.d.ts +0 -53
  207. package/dist/config.d.ts.map +0 -1
  208. package/dist/config.js +0 -202
  209. package/dist/config.js.map +0 -1
  210. package/dist/config.test.js +0 -117
  211. package/dist/engine/cli.d.ts +0 -14
  212. package/dist/engine/cli.d.ts.map +0 -1
  213. package/dist/engine/cli.js +0 -171
  214. package/dist/engine/cli.js.map +0 -1
  215. package/dist/engine/client.d.ts +0 -219
  216. package/dist/engine/client.d.ts.map +0 -1
  217. package/dist/engine/client.js +0 -312
  218. package/dist/engine/client.js.map +0 -1
  219. package/dist/engine/config.d.ts +0 -62
  220. package/dist/engine/config.d.ts.map +0 -1
  221. package/dist/engine/config.js +0 -223
  222. package/dist/engine/config.js.map +0 -1
  223. package/dist/engine/index.d.ts +0 -17
  224. package/dist/engine/index.d.ts.map +0 -1
  225. package/dist/engine/index.js +0 -16
  226. package/dist/engine/index.js.map +0 -1
  227. package/dist/engine/resolver.d.ts +0 -62
  228. package/dist/engine/resolver.d.ts.map +0 -1
  229. package/dist/engine/resolver.js +0 -103
  230. package/dist/engine/resolver.js.map +0 -1
  231. package/dist/engine/singleton.d.ts +0 -95
  232. package/dist/engine/singleton.d.ts.map +0 -1
  233. package/dist/engine/singleton.js +0 -325
  234. package/dist/engine/singleton.js.map +0 -1
  235. package/dist/engine/types.d.ts +0 -402
  236. package/dist/engine/types.d.ts.map +0 -1
  237. package/dist/engine/types.js +0 -22
  238. package/dist/engine/types.js.map +0 -1
  239. package/dist/engine-binary-resolver.js +0 -110
  240. package/dist/engine-binary-resolver.test.js +0 -61
  241. package/dist/engine-cli.js +0 -60
  242. package/dist/engine-client.js +0 -301
  243. package/dist/engine-client.test.js +0 -118
  244. package/dist/functions/chain_state.d.ts +0 -51
  245. package/dist/functions/chain_state.d.ts.map +0 -1
  246. package/dist/functions/chain_state.js +0 -59
  247. package/dist/functions/chain_state.js.map +0 -1
  248. package/dist/hooks/drift-catalog.d.ts +0 -68
  249. package/dist/hooks/drift-catalog.d.ts.map +0 -1
  250. package/dist/hooks/drift-catalog.js +0 -184
  251. package/dist/hooks/drift-catalog.js.map +0 -1
  252. package/dist/hooks/drift-catalog.test.js +0 -154
  253. package/dist/hooks/drift-patterns.d.ts +0 -110
  254. package/dist/hooks/drift-patterns.d.ts.map +0 -1
  255. package/dist/hooks/drift-patterns.js +0 -289
  256. package/dist/hooks/drift-patterns.js.map +0 -1
  257. package/dist/hooks/drift-patterns.test.js +0 -325
  258. package/dist/hooks/engine-vocab-gate.d.ts +0 -108
  259. package/dist/hooks/engine-vocab-gate.d.ts.map +0 -1
  260. package/dist/hooks/engine-vocab-gate.js +0 -225
  261. package/dist/hooks/engine-vocab-gate.js.map +0 -1
  262. package/dist/hooks/engine-vocab-gate.test.js +0 -170
  263. package/dist/hooks/heartbeat.d.ts +0 -107
  264. package/dist/hooks/heartbeat.d.ts.map +0 -1
  265. package/dist/hooks/heartbeat.js +0 -316
  266. package/dist/hooks/heartbeat.js.map +0 -1
  267. package/dist/hooks/heartbeat.test.js +0 -393
  268. package/dist/hooks/honesty-ledger-session-scope.test.js +0 -100
  269. package/dist/hooks/honesty-ledger.d.ts +0 -123
  270. package/dist/hooks/honesty-ledger.d.ts.map +0 -1
  271. package/dist/hooks/honesty-ledger.js +0 -226
  272. package/dist/hooks/honesty-ledger.js.map +0 -1
  273. package/dist/hooks/honesty-ledger.test.js +0 -466
  274. package/dist/hooks/inline-report-check.d.ts +0 -63
  275. package/dist/hooks/inline-report-check.d.ts.map +0 -1
  276. package/dist/hooks/inline-report-check.js +0 -88
  277. package/dist/hooks/inline-report-check.js.map +0 -1
  278. package/dist/hooks/inline-report-check.test.js +0 -96
  279. package/dist/hooks/pre-tool-use.d.ts +0 -62
  280. package/dist/hooks/pre-tool-use.d.ts.map +0 -1
  281. package/dist/hooks/pre-tool-use.js +0 -342
  282. package/dist/hooks/pre-tool-use.js.map +0 -1
  283. package/dist/hooks/pre-tool-use.test.js +0 -134
  284. package/dist/hooks/session-end.d.ts +0 -15
  285. package/dist/hooks/session-end.d.ts.map +0 -1
  286. package/dist/hooks/session-end.js +0 -60
  287. package/dist/hooks/session-end.js.map +0 -1
  288. package/dist/hooks/session-end.test.js +0 -52
  289. package/dist/hooks/stop.d.ts +0 -35
  290. package/dist/hooks/stop.d.ts.map +0 -1
  291. package/dist/hooks/stop.js +0 -136
  292. package/dist/hooks/stop.js.map +0 -1
  293. package/dist/hooks/transcript-active-task.test.js +0 -342
  294. package/dist/hooks/transcript.d.ts +0 -26
  295. package/dist/hooks/transcript.d.ts.map +0 -1
  296. package/dist/hooks/transcript.js +0 -266
  297. package/dist/hooks/transcript.js.map +0 -1
  298. package/dist/hooks/transcript.test.js +0 -103
  299. package/dist/hooks/user-prompt-submit.d.ts +0 -74
  300. package/dist/hooks/user-prompt-submit.d.ts.map +0 -1
  301. package/dist/hooks/user-prompt-submit.js +0 -256
  302. package/dist/hooks/user-prompt-submit.js.map +0 -1
  303. package/dist/hooks/user-prompt-submit.test.js +0 -118
  304. package/dist/hooks/versioning-gate.d.ts +0 -101
  305. package/dist/hooks/versioning-gate.d.ts.map +0 -1
  306. package/dist/hooks/versioning-gate.js +0 -245
  307. package/dist/hooks/versioning-gate.js.map +0 -1
  308. package/dist/hooks/versioning-gate.test.js +0 -368
  309. package/dist/hooks/workflow-gate.d.ts +0 -64
  310. package/dist/hooks/workflow-gate.d.ts.map +0 -1
  311. package/dist/hooks/workflow-gate.js +0 -152
  312. package/dist/hooks/workflow-gate.js.map +0 -1
  313. package/dist/hooks/workflow-gate.test.js +0 -197
  314. package/dist/hooks-cli.d.ts +0 -25
  315. package/dist/hooks-cli.d.ts.map +0 -1
  316. package/dist/hooks-cli.js +0 -286
  317. package/dist/hooks-cli.js.map +0 -1
  318. package/dist/hooks-cli.test.js +0 -148
  319. package/dist/origin.d.ts +0 -16
  320. package/dist/origin.d.ts.map +0 -1
  321. package/dist/origin.js +0 -92
  322. package/dist/origin.js.map +0 -1
  323. package/dist/packs/seed_lessons_ingest.d.ts +0 -30
  324. package/dist/packs/seed_lessons_ingest.d.ts.map +0 -1
  325. package/dist/packs/seed_lessons_ingest.js +0 -107
  326. package/dist/packs/seed_lessons_ingest.js.map +0 -1
  327. package/dist/project-cli.d.ts +0 -7
  328. package/dist/project-cli.d.ts.map +0 -1
  329. package/dist/project-cli.js +0 -145
  330. package/dist/project-cli.js.map +0 -1
  331. package/dist/project.d.ts +0 -127
  332. package/dist/project.d.ts.map +0 -1
  333. package/dist/project.js +0 -281
  334. package/dist/project.js.map +0 -1
  335. package/dist/project.test.js +0 -287
  336. package/dist/rag/backends/loop_engine.d.ts +0 -61
  337. package/dist/rag/backends/loop_engine.d.ts.map +0 -1
  338. package/dist/rag/backends/loop_engine.js +0 -160
  339. package/dist/rag/backends/loop_engine.js.map +0 -1
  340. package/dist/recall.d.ts +0 -82
  341. package/dist/recall.d.ts.map +0 -1
  342. package/dist/recall.js +0 -81
  343. package/dist/recall.js.map +0 -1
  344. package/dist/runtime/agent_bridge/autospawn.d.ts +0 -131
  345. package/dist/runtime/agent_bridge/autospawn.d.ts.map +0 -1
  346. package/dist/runtime/agent_bridge/autospawn.js +0 -251
  347. package/dist/runtime/agent_bridge/autospawn.js.map +0 -1
  348. package/dist/runtime/chain_state.d.ts +0 -124
  349. package/dist/runtime/chain_state.d.ts.map +0 -1
  350. package/dist/runtime/chain_state.js +0 -189
  351. package/dist/runtime/chain_state.js.map +0 -1
  352. package/dist/runtime/hooks/permission_decision.d.ts +0 -34
  353. package/dist/runtime/hooks/permission_decision.d.ts.map +0 -1
  354. package/dist/runtime/hooks/permission_decision.js +0 -39
  355. package/dist/runtime/hooks/permission_decision.js.map +0 -1
  356. package/dist/runtime/workflow_fsm.d.ts +0 -21
  357. package/dist/runtime/workflow_fsm.d.ts.map +0 -1
  358. package/dist/runtime/workflow_fsm.js +0 -25
  359. package/dist/runtime/workflow_fsm.js.map +0 -1
  360. package/dist/runtime/workflow_map.d.ts +0 -26
  361. package/dist/runtime/workflow_map.d.ts.map +0 -1
  362. package/dist/runtime/workflow_map.js +0 -38
  363. package/dist/runtime/workflow_map.js.map +0 -1
  364. package/dist/scope.d.ts +0 -48
  365. package/dist/scope.d.ts.map +0 -1
  366. package/dist/scope.js +0 -111
  367. package/dist/scope.js.map +0 -1
  368. package/dist/setup/cli/topic_create_step.d.ts +0 -84
  369. package/dist/setup/cli/topic_create_step.d.ts.map +0 -1
  370. package/dist/setup/cli/topic_create_step.js +0 -213
  371. package/dist/setup/cli/topic_create_step.js.map +0 -1
  372. package/dist/system-export.d.ts +0 -65
  373. package/dist/system-export.d.ts.map +0 -1
  374. package/dist/system-export.js +0 -194
  375. package/dist/system-export.js.map +0 -1
  376. package/dist/utterance/classifier.d.ts +0 -53
  377. package/dist/utterance/classifier.d.ts.map +0 -1
  378. package/dist/utterance/classifier.js +0 -184
  379. package/dist/utterance/classifier.js.map +0 -1
  380. package/dist/utterance/classifier.test.js +0 -147
@@ -1,223 +0,0 @@
1
- /**
2
- * Engine binary discovery + persisted-path management.
3
- *
4
- * Resolution chain (per T.1 audit §J + src.legacy precedent):
5
- * 1. `OPENSQUID_ENGINE_BIN` env var — explicit override, always wins
6
- * 2. `~/.opensquid/engine-config.json` `engine_bin` field — persisted choice
7
- * 3. Bundled npm optional dep (`opensquid-engine-<platform>-<arch>`)
8
- * — returns `null` until npm stubs ship (follow-up track)
9
- * 4. Auto-search dev paths under `~/projects/*` and `~/work/*`
10
- * 5. `loop-engine` on `$PATH`
11
- * 6. `null` — caller surfaces a helpful error
12
- *
13
- * First successful resolution from (4) or (5) is persisted to
14
- * `~/.opensquid/engine-config.json` so the next session skips the search.
15
- * Bundled-binary hits (3) are NOT persisted because the path is
16
- * deterministic from the npm install layout and persisting it would
17
- * point at a stale `node_modules/` path after upgrades.
18
- *
19
- * The persisted file is engine-specific so it doesn't collide with the
20
- * existing `~/.opensquid/config.json` written by the chat-daemon stack.
21
- *
22
- * Imports `OPENSQUID_HOME` from `runtime/paths.ts` so the data root
23
- * honors the `OPENSQUID_HOME` env override (tests + relocatable installs).
24
- */
25
- import { promises as fs } from 'node:fs';
26
- import * as os from 'node:os';
27
- import * as path from 'node:path';
28
- import { OPENSQUID_HOME } from '../runtime/paths.js';
29
- import { resolveBundledEngineBin } from './resolver.js';
30
- const ENGINE_BIN_NAME = 'loop-engine';
31
- const ENGINE_CONFIG_FILE = 'engine-config.json';
32
- const DEFAULT_CONFIG = { version: 1 };
33
- function engineConfigPath() {
34
- return path.join(OPENSQUID_HOME(), ENGINE_CONFIG_FILE);
35
- }
36
- export async function loadEngineConfig() {
37
- let raw;
38
- try {
39
- raw = await fs.readFile(engineConfigPath(), 'utf8');
40
- }
41
- catch (e) {
42
- // Missing file is the common-case (no persisted choice yet) —
43
- // silent. Other read errors (EACCES, EIO) are unusual — warn so
44
- // users know why their persisted engine_bin isn't being picked up.
45
- const code = e.code;
46
- if (code !== 'ENOENT') {
47
- process.stderr.write(`[opensquid] engine-config read failed at ${engineConfigPath()} (${String(e)}); ` +
48
- `using defaults.\n`);
49
- }
50
- return { ...DEFAULT_CONFIG };
51
- }
52
- try {
53
- const parsed = JSON.parse(raw);
54
- if (parsed.version === 1)
55
- return parsed;
56
- // Wrong version — treat as malformed for the warning path below.
57
- process.stderr.write(`[opensquid] engine-config at ${engineConfigPath()} has unexpected version=${String(parsed.version)} (want 1); using defaults.\n`);
58
- }
59
- catch (e) {
60
- // Parse-error path is loud — a typo silently dropping the persisted
61
- // engine_bin was the bug A.05 addresses. Return default to keep boot
62
- // resilient but surface the cause so users can fix the file.
63
- process.stderr.write(`[opensquid] engine-config parse failed at ${engineConfigPath()} (${String(e)}); ` +
64
- `using defaults — fix or delete the file to silence this warning.\n`);
65
- }
66
- return { ...DEFAULT_CONFIG };
67
- }
68
- export async function saveEngineConfig(config) {
69
- const p = engineConfigPath();
70
- await fs.mkdir(path.dirname(p), { recursive: true });
71
- await fs.writeFile(p, JSON.stringify(config, null, 2) + '\n', 'utf8');
72
- }
73
- /**
74
- * Resolve the engine binary path using the priority chain above. Writes
75
- * the resolved path back to config when discovered via search so the
76
- * next session is instant. Returns `null` if no working binary could be
77
- * located.
78
- *
79
- * **Re-resolution on every start** (T.7 / T.1.P): a persisted
80
- * `engine_bin` that no longer points at an executable file is cleared
81
- * from the config and the resolver falls through to bundled → dev →
82
- * `$PATH`. This adds ~10-100ms (one extra `fs.stat`) but means a
83
- * deleted / moved / freshly-rebuilt binary silently self-heals on the
84
- * next start instead of failing loudly with `ENOENT`. Bundled hits
85
- * are NOT persisted (deterministic from npm layout); dev-path + `$PATH`
86
- * hits ARE persisted so subsequent sessions skip the search.
87
- */
88
- export async function resolveEngineBin() {
89
- const fromEnv = process.env.OPENSQUID_ENGINE_BIN?.trim();
90
- if (fromEnv)
91
- return fromEnv;
92
- let config = await loadEngineConfig();
93
- if (config.engine_bin) {
94
- if (await isExecutable(config.engine_bin)) {
95
- return config.engine_bin;
96
- }
97
- // Stale persisted path (binary deleted / moved / chmod -x).
98
- // Clear + persist so subsequent calls don't repeat the stat.
99
- delete config.engine_bin;
100
- delete config.engine_bin_resolved_at;
101
- await saveEngineConfig(config);
102
- // Reload so the in-memory `config` matches what's on disk before
103
- // the success-branch writes below mutate + save again.
104
- config = await loadEngineConfig();
105
- }
106
- const bundled = resolveBundledEngineBin();
107
- if (bundled && (await isExecutable(bundled))) {
108
- // Do NOT persist — the npm layout determines this deterministically
109
- // and persisting a `node_modules/` path makes upgrades hostile.
110
- return bundled;
111
- }
112
- const found = await searchCommonPaths();
113
- if (found) {
114
- config.engine_bin = found;
115
- config.engine_bin_resolved_at = new Date().toISOString();
116
- await saveEngineConfig(config);
117
- return found;
118
- }
119
- const onPath = await whichBinary(ENGINE_BIN_NAME);
120
- if (onPath) {
121
- config.engine_bin = onPath;
122
- config.engine_bin_resolved_at = new Date().toISOString();
123
- await saveEngineConfig(config);
124
- return onPath;
125
- }
126
- return null;
127
- }
128
- /**
129
- * Set the engine binary path explicitly and persist. Validates that the
130
- * path points at an executable file before writing.
131
- */
132
- export async function setEngineBin(binPath) {
133
- const abs = path.resolve(binPath);
134
- if (!(await isExecutable(abs))) {
135
- throw new Error(`not an executable file: ${abs}`);
136
- }
137
- const config = await loadEngineConfig();
138
- config.engine_bin = abs;
139
- config.engine_bin_resolved_at = new Date().toISOString();
140
- await saveEngineConfig(config);
141
- return { resolved: abs };
142
- }
143
- /**
144
- * Forget the persisted engine binary path. Forces re-discovery on the
145
- * next `resolveEngineBin` call.
146
- */
147
- export async function forgetEngineBin() {
148
- const config = await loadEngineConfig();
149
- delete config.engine_bin;
150
- delete config.engine_bin_resolved_at;
151
- await saveEngineConfig(config);
152
- }
153
- async function isExecutable(p) {
154
- try {
155
- const stat = await fs.stat(p);
156
- if (!stat.isFile())
157
- return false;
158
- return (stat.mode & 0o111) !== 0;
159
- }
160
- catch {
161
- return false;
162
- }
163
- }
164
- /**
165
- * Walk common dev-machine layouts looking for a release binary.
166
- * Conservative — only checks paths that look like sibling projects of
167
- * the user's `$HOME`. Returns the first hit.
168
- *
169
- * Covered layouts:
170
- * ~/projects/<*>/engine/target/release/loop-engine (loop workspace)
171
- * ~/projects/<*>/target/release/loop-engine (standalone engine repo)
172
- * ~/work/<*>/{engine,}/target/release/loop-engine (alt convention)
173
- */
174
- async function searchCommonPaths() {
175
- const home = os.homedir();
176
- const candidates = [];
177
- const projectsRoot = path.join(home, 'projects');
178
- try {
179
- const dirs = await fs.readdir(projectsRoot, { withFileTypes: true });
180
- for (const entry of dirs) {
181
- if (!entry.isDirectory())
182
- continue;
183
- candidates.push(path.join(projectsRoot, entry.name, 'engine', 'target', 'release', ENGINE_BIN_NAME), path.join(projectsRoot, entry.name, 'target', 'release', ENGINE_BIN_NAME));
184
- }
185
- }
186
- catch {
187
- // ~/projects doesn't exist — skip.
188
- }
189
- const workRoot = path.join(home, 'work');
190
- try {
191
- const dirs = await fs.readdir(workRoot, { withFileTypes: true });
192
- for (const entry of dirs) {
193
- if (!entry.isDirectory())
194
- continue;
195
- candidates.push(path.join(workRoot, entry.name, 'engine', 'target', 'release', ENGINE_BIN_NAME), path.join(workRoot, entry.name, 'target', 'release', ENGINE_BIN_NAME));
196
- }
197
- }
198
- catch {
199
- // ~/work doesn't exist — skip.
200
- }
201
- for (const cand of candidates) {
202
- if (await isExecutable(cand))
203
- return cand;
204
- }
205
- return null;
206
- }
207
- /**
208
- * Cross-platform `which` — search $PATH for an executable named `bin`.
209
- * Returns absolute path or null.
210
- */
211
- async function whichBinary(bin) {
212
- const pathEnv = process.env.PATH ?? '';
213
- const sep = process.platform === 'win32' ? ';' : ':';
214
- for (const dir of pathEnv.split(sep)) {
215
- if (!dir)
216
- continue;
217
- const candidate = path.join(dir, bin);
218
- if (await isExecutable(candidate))
219
- return candidate;
220
- }
221
- return null;
222
- }
223
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/engine/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EA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,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IACrD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACtC,IAAI,MAAM,YAAY,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IACtD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * Barrel re-export for `opensquid` engine integration.
3
- *
4
- * Public surface:
5
- * - EngineClient + RpcError + ENGINE_ERROR (`./client.js`)
6
- * - resolveEngineBin / setEngineBin / forgetEngineBin / loadEngineConfig
7
- * (`./config.js`)
8
- * - resolveBundledEngineBin + platform probe helpers (`./resolver.js`)
9
- * - registerEngineCli + EngineCliError (`./cli.js`)
10
- * - All wire-shape types (`./types.js`)
11
- */
12
- export { EngineClient, ENGINE_ERROR, RpcError } from './client.js';
13
- export { forgetEngineBin, loadEngineConfig, resolveEngineBin, saveEngineConfig, setEngineBin, type EngineConfig, } from './config.js';
14
- export { binaryNameForPlatform, currentPlatform, packageForPlatform, resolveBundledEngineBin, type PlatformProbe, } from './resolver.js';
15
- export { EngineCliError, registerEngineCli } from './cli.js';
16
- export type { CreateMemoryResult, GetMemoryResult, LessonCaptureFeedbackResult, LessonCreateParams, LessonCreateResult, LessonDiscardResult, LessonListResult, LessonListRow, LessonPromoteResult, LessonRecallHit, LessonRecallResult, LessonSupersedeResult, ManifestActiveLesson, ManifestAssembleParams, ManifestAssembleResult, ManifestMemory, MemoryDeleteResult, MemoryListResult, MemoryListRow, MemoryOrigin, MemoryScope, MemorySearchHit, MemorySearchParams, MemorySearchResult, MemoryUpdateResult, ScopeFilterWire, TaskGetLedgerResult, TaskLogPhaseResult, } from './types.js';
17
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7D,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Barrel re-export for `opensquid` engine integration.
3
- *
4
- * Public surface:
5
- * - EngineClient + RpcError + ENGINE_ERROR (`./client.js`)
6
- * - resolveEngineBin / setEngineBin / forgetEngineBin / loadEngineConfig
7
- * (`./config.js`)
8
- * - resolveBundledEngineBin + platform probe helpers (`./resolver.js`)
9
- * - registerEngineCli + EngineCliError (`./cli.js`)
10
- * - All wire-shape types (`./types.js`)
11
- */
12
- export { EngineClient, ENGINE_ERROR, RpcError } from './client.js';
13
- export { forgetEngineBin, loadEngineConfig, resolveEngineBin, saveEngineConfig, setEngineBin, } from './config.js';
14
- export { binaryNameForPlatform, currentPlatform, packageForPlatform, resolveBundledEngineBin, } from './resolver.js';
15
- export { EngineCliError, registerEngineCli } from './cli.js';
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GAEb,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,GAExB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Bundled-binary resolver for the loop-engine subprocess.
3
- *
4
- * Pattern: esbuild / biomejs / swc — main opensquid package would declare
5
- * 6 platform-specific packages as `optionalDependencies`; each one ships
6
- * a single binary at `bin/loop-engine` (or `.exe` on Windows). npm's
7
- * `os`/`cpu` fields cause wrong-platform packages to skip install, so on
8
- * any given host exactly one optional dep is present and provides the
9
- * right binary.
10
- *
11
- * NOTE: opensquid 0.5.108 ships LOCAL-BUILD ONLY (per T.1.J §10). The
12
- * `optionalDependencies` block is not yet declared in package.json — npm
13
- * stubs land in a follow-up track. This resolver returns `null` on every
14
- * call until then, and callers fall through to `config.ts` dev-path +
15
- * `$PATH` discovery. The mapping table is kept now so the wiring is
16
- * already correct when stubs land.
17
- *
18
- * Runtime path:
19
- * 1. Map `(process.platform, process.arch)` → optional-dep name.
20
- * 2. Try `createRequire(import.meta.url).resolve(...)` on that
21
- * package's package.json. Returns `<dir>/bin/<name>` if installed.
22
- * 3. If not installed (npm `--no-optional`, wrong-platform install,
23
- * local pre-publish dev), return `null`. Caller falls back to the
24
- * dev-path + $PATH chain in `config.ts`.
25
- *
26
- * Resolution is synchronous + side-effect-free.
27
- */
28
- export interface PlatformProbe {
29
- platform: NodeJS.Platform;
30
- arch: string;
31
- }
32
- /**
33
- * Compute the (platform, arch) tuple for the current process. Wrapped
34
- * for unit testability — tests inject a synthetic probe.
35
- */
36
- export declare function currentPlatform(): PlatformProbe;
37
- /**
38
- * Look up the optional-dep package name for a given platform. Returns
39
- * `null` when the (platform, arch) pair isn't in the supported matrix.
40
- */
41
- export declare function packageForPlatform(probe: PlatformProbe): string | null;
42
- /**
43
- * Look up the binary filename for a given platform (`.exe` on Windows).
44
- */
45
- export declare function binaryNameForPlatform(probe: PlatformProbe): string | null;
46
- /**
47
- * Resolve the bundled binary path via the optional-dep mechanism.
48
- *
49
- * Returns `null` when:
50
- * - the current (platform, arch) isn't in the supported matrix,
51
- * - the optional dep isn't installed (pre-publish dev, npm
52
- * `--no-optional`, wrong-platform install), or
53
- * - the dep is installed but the expected `bin/<name>` file is missing
54
- * (broken publish — diagnostic-only; caller falls through).
55
- *
56
- * v0.6c audit fix: use `path.dirname + path.join` not string slice — on
57
- * Windows `require.resolve` returns `\` separators; slicing on the
58
- * `"/package.json".length` suffix would silently mis-strip and the
59
- * concatenation would mix separators.
60
- */
61
- export declare function resolveBundledEngineBin(probe?: PlatformProbe): string | null;
62
- //# sourceMappingURL=resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/engine/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAoCH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,aAAa,CAE/C;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAGtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAGzE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,GAAE,aAAiC,GAAG,MAAM,GAAG,IAAI,CAa/F"}
@@ -1,103 +0,0 @@
1
- /**
2
- * Bundled-binary resolver for the loop-engine subprocess.
3
- *
4
- * Pattern: esbuild / biomejs / swc — main opensquid package would declare
5
- * 6 platform-specific packages as `optionalDependencies`; each one ships
6
- * a single binary at `bin/loop-engine` (or `.exe` on Windows). npm's
7
- * `os`/`cpu` fields cause wrong-platform packages to skip install, so on
8
- * any given host exactly one optional dep is present and provides the
9
- * right binary.
10
- *
11
- * NOTE: opensquid 0.5.108 ships LOCAL-BUILD ONLY (per T.1.J §10). The
12
- * `optionalDependencies` block is not yet declared in package.json — npm
13
- * stubs land in a follow-up track. This resolver returns `null` on every
14
- * call until then, and callers fall through to `config.ts` dev-path +
15
- * `$PATH` discovery. The mapping table is kept now so the wiring is
16
- * already correct when stubs land.
17
- *
18
- * Runtime path:
19
- * 1. Map `(process.platform, process.arch)` → optional-dep name.
20
- * 2. Try `createRequire(import.meta.url).resolve(...)` on that
21
- * package's package.json. Returns `<dir>/bin/<name>` if installed.
22
- * 3. If not installed (npm `--no-optional`, wrong-platform install,
23
- * local pre-publish dev), return `null`. Caller falls back to the
24
- * dev-path + $PATH chain in `config.ts`.
25
- *
26
- * Resolution is synchronous + side-effect-free.
27
- */
28
- import { createRequire } from 'node:module';
29
- import * as path from 'node:path';
30
- /**
31
- * Supported targets and their optional-dep package names. Stays in sync
32
- * with `optionalDependencies` in package.json (when added) and with the
33
- * loop-engine release matrix. If you change any of those, change all.
34
- */
35
- const PACKAGE_FOR_PLATFORM = {
36
- 'darwin-x64': 'opensquid-engine-darwin-x64',
37
- 'darwin-arm64': 'opensquid-engine-darwin-arm64',
38
- 'linux-x64': 'opensquid-engine-linux-x64',
39
- 'linux-arm64': 'opensquid-engine-linux-arm64',
40
- 'win32-x64': 'opensquid-engine-win32-x64',
41
- 'win32-arm64': 'opensquid-engine-win32-arm64',
42
- };
43
- const BIN_NAME_FOR_PLATFORM = {
44
- 'darwin-x64': 'loop-engine',
45
- 'darwin-arm64': 'loop-engine',
46
- 'linux-x64': 'loop-engine',
47
- 'linux-arm64': 'loop-engine',
48
- 'win32-x64': 'loop-engine.exe',
49
- 'win32-arm64': 'loop-engine.exe',
50
- };
51
- /**
52
- * Compute the (platform, arch) tuple for the current process. Wrapped
53
- * for unit testability — tests inject a synthetic probe.
54
- */
55
- export function currentPlatform() {
56
- return { platform: process.platform, arch: process.arch };
57
- }
58
- /**
59
- * Look up the optional-dep package name for a given platform. Returns
60
- * `null` when the (platform, arch) pair isn't in the supported matrix.
61
- */
62
- export function packageForPlatform(probe) {
63
- const key = `${probe.platform}-${probe.arch}`;
64
- return PACKAGE_FOR_PLATFORM[key] ?? null;
65
- }
66
- /**
67
- * Look up the binary filename for a given platform (`.exe` on Windows).
68
- */
69
- export function binaryNameForPlatform(probe) {
70
- const key = `${probe.platform}-${probe.arch}`;
71
- return BIN_NAME_FOR_PLATFORM[key] ?? null;
72
- }
73
- /**
74
- * Resolve the bundled binary path via the optional-dep mechanism.
75
- *
76
- * Returns `null` when:
77
- * - the current (platform, arch) isn't in the supported matrix,
78
- * - the optional dep isn't installed (pre-publish dev, npm
79
- * `--no-optional`, wrong-platform install), or
80
- * - the dep is installed but the expected `bin/<name>` file is missing
81
- * (broken publish — diagnostic-only; caller falls through).
82
- *
83
- * v0.6c audit fix: use `path.dirname + path.join` not string slice — on
84
- * Windows `require.resolve` returns `\` separators; slicing on the
85
- * `"/package.json".length` suffix would silently mis-strip and the
86
- * concatenation would mix separators.
87
- */
88
- export function resolveBundledEngineBin(probe = currentPlatform()) {
89
- const pkg = packageForPlatform(probe);
90
- const binName = binaryNameForPlatform(probe);
91
- if (!pkg || !binName)
92
- return null;
93
- const req = createRequire(import.meta.url);
94
- try {
95
- const pkgJson = req.resolve(`${pkg}/package.json`);
96
- return path.join(path.dirname(pkgJson), 'bin', binName);
97
- }
98
- catch {
99
- // MODULE_NOT_FOUND — optional dep not installed for this host.
100
- return null;
101
- }
102
- }
103
- //# sourceMappingURL=resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/engine/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAUlC;;;;GAIG;AACH,MAAM,oBAAoB,GAAgC;IACxD,YAAY,EAAE,6BAA6B;IAC3C,cAAc,EAAE,+BAA+B;IAC/C,WAAW,EAAE,4BAA4B;IACzC,aAAa,EAAE,8BAA8B;IAC7C,WAAW,EAAE,4BAA4B;IACzC,aAAa,EAAE,8BAA8B;CAC9C,CAAC;AAEF,MAAM,qBAAqB,GAAgC;IACzD,YAAY,EAAE,aAAa;IAC3B,cAAc,EAAE,aAAa;IAC7B,WAAW,EAAE,aAAa;IAC1B,aAAa,EAAE,aAAa;IAC5B,WAAW,EAAE,iBAAiB;IAC9B,aAAa,EAAE,iBAAiB;CACjC,CAAC;AAOF;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAoB;IACrD,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAiB,CAAC;IAC7D,OAAO,oBAAoB,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAoB;IACxD,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAiB,CAAC;IAC7D,OAAO,qBAAqB,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAuB,eAAe,EAAE;IAC9E,MAAM,GAAG,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,GAAG,eAAe,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,+DAA+D;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,95 +0,0 @@
1
- /**
2
- * Daemon-singleton acquire-or-spawn for the loop-engine UDS daemon.
3
- *
4
- * One engine process per host. All opensquid hooks + sessions share
5
- * the same engine over a Unix domain socket at
6
- * `~/.opensquid/loop-engine.sock`. This is the keystone for cross-
7
- * session memory recall — session A writes a memory, session B reads
8
- * it through the same engine without per-process spawn cost.
9
- *
10
- * Flow (per spec T.4 / audit T.1.Y + T.1.Z + T.1.BB + T.1.DD):
11
- *
12
- * 1. Windows guard — UDS is Unix-only; named-pipe support is a
13
- * follow-up. Windows callers fall back to per-process stdio spawn
14
- * by setting `OPENSQUID_ENGINE_SOCKET=disable` upstream.
15
- *
16
- * 2. Path-byte guard — macOS limits UDS paths to 104 bytes (Linux
17
- * 108). `~/.opensquid/loop-engine.sock` ≈ 30 chars on typical
18
- * homes, but exotic `$HOME` values can exceed it. Refuse at 100
19
- * to leave margin.
20
- *
21
- * 3. Fast path — if the socket file exists, try to connect. Success
22
- * means an engine is already running; return the socket with
23
- * `spawnedByUs: false`. ECONNREFUSED means the file is stale (a
24
- * previous engine crashed without unlinking); unlink and fall
25
- * through to the spawn path.
26
- *
27
- * 4. Slow path (lock + spawn):
28
- * a. Touch `~/.opensquid/loop-engine.lock` so `proper-lockfile`
29
- * has a stable inode to lock against.
30
- * b. Acquire the lock with retry — serializes concurrent spawn
31
- * attempts across multiple opensquid processes.
32
- * c. RECHECK after the lock: another process may have spawned
33
- * the engine while we waited. If yes, connect + return.
34
- * d. Resolve the engine binary via existing `resolveEngineBin()`.
35
- * e. Spawn detached + `stdio: 'ignore'` so the engine outlives
36
- * the parent (true daemon semantics). `'inherit'` would hold
37
- * the parent's stdout/stderr pipes open and block parent exit
38
- * (per subprocess-lifecycle audit). Engine logs route to
39
- * /dev/null in this mode; `RUST_LOG=...` + a redirect-to-file
40
- * is the workaround if diagnostics are needed.
41
- * f. Write `~/.opensquid/loop-engine.pid` with the spawned pid
42
- * BEFORE `proc.unref()` so T.7's `engine kill` command can
43
- * find it.
44
- * g. `proc.unref()` — let the parent event loop exit without
45
- * waiting on the engine.
46
- * h. Wait for the socket file to appear (engine binds before
47
- * accept; 10s budget covers cold-start HNSW rehydrate of
48
- * ~76 memories on typical hardware).
49
- * i. Connect; return with `spawnedByUs: true`.
50
- *
51
- * 5. Always release the lock in a `finally` block.
52
- *
53
- * NOT a singleton class — exported as a plain async function so
54
- * callers can compose / inject without instance state. Concurrency
55
- * safety lives in `proper-lockfile`, not in this module.
56
- */
57
- import { type Socket } from 'node:net';
58
- /** Engine socket path. Override `OPENSQUID_HOME` to relocate. */
59
- export declare function engineSocketPath(): string;
60
- /** Lock file used to serialize concurrent spawn attempts. */
61
- export declare function engineLockPath(): string;
62
- /**
63
- * Pidfile path used by `engine kill` (T.7). Written after spawn
64
- * returns, before `unref()`. Note: the engine process itself does
65
- * NOT manage this file — opensquid owns its lifecycle since opensquid
66
- * is the one that spawned the engine. T.7 will add a startup-time
67
- * cleanup hook for the spawned-by-us case.
68
- */
69
- export declare function enginePidPath(): string;
70
- export interface EngineConnection {
71
- /** Connected socket to the engine's UDS endpoint. */
72
- socket: Socket;
73
- /**
74
- * `true` when this caller's invocation was the one that spawned the
75
- * engine process (cold start path). `false` when an existing engine
76
- * was found and connected to (warm path). Useful for telemetry +
77
- * test assertions; production callers usually ignore it.
78
- */
79
- spawnedByUs: boolean;
80
- }
81
- /**
82
- * Acquire a connection to the shared loop-engine daemon, spawning
83
- * one if none is running. Safe to call concurrently from multiple
84
- * processes — `proper-lockfile` serializes spawn attempts so only
85
- * one engine starts per `~/.opensquid/loop-engine.sock` lifetime.
86
- *
87
- * Throws on:
88
- * - Windows (UDS unsupported; use stdio mode upstream)
89
- * - socket path exceeds platform byte limit
90
- * - engine binary not resolvable
91
- * - socket never appears within `SOCKET_WAIT_TIMEOUT_MS`
92
- * - underlying spawn / connect / lock errors
93
- */
94
- export declare function acquireOrSpawnEngine(): Promise<EngineConnection>;
95
- //# sourceMappingURL=singleton.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../src/engine/singleton.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAKH,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAoChD,iEAAiE;AACjE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAcD,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAkJtE"}