@lotagate/cli 0.1.24 → 0.1.26

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 (671) hide show
  1. package/README.md +75 -7
  2. package/SECURITY.md +2 -0
  3. package/bin/lotagate.mjs +50 -8
  4. package/dist/application/agent/agent-constants.d.ts +6 -0
  5. package/dist/application/agent/agent-constants.js +1 -0
  6. package/dist/application/agent/agent-history.d.ts +3 -0
  7. package/dist/application/agent/agent-history.js +5 -0
  8. package/dist/application/agent/agent-input-context.d.ts +12 -0
  9. package/dist/application/agent/agent-input-context.js +5 -0
  10. package/dist/application/agent/agent-limit.d.ts +3 -0
  11. package/dist/application/agent/agent-limit.js +1 -0
  12. package/dist/application/agent/agent-run-tracker.d.ts +30 -0
  13. package/dist/application/agent/agent-run-tracker.js +1 -0
  14. package/dist/application/agent/agent-runtime-context.d.ts +22 -0
  15. package/dist/application/agent/agent-runtime-context.js +1 -0
  16. package/dist/application/agent/agent-session-store-registry.d.ts +16 -0
  17. package/dist/application/agent/agent-session-store-registry.js +1 -0
  18. package/dist/application/agent/agent-session-store.d.ts +23 -0
  19. package/dist/application/agent/agent-session-store.js +6 -0
  20. package/dist/application/agent/capability-profile.d.ts +17 -0
  21. package/dist/application/agent/capability-profile.js +0 -0
  22. package/dist/application/agent/cli-agent-execution-service.d.ts +120 -0
  23. package/dist/application/agent/cli-agent-execution-service.js +1 -0
  24. package/dist/application/agent/cli-agent-preparation-cache.d.ts +39 -0
  25. package/dist/application/agent/cli-agent-preparation-cache.js +1 -0
  26. package/dist/application/agent/cli-agent-run-request.d.ts +12 -0
  27. package/dist/application/agent/cli-agent-run-request.js +0 -0
  28. package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
  29. package/dist/application/agent/context-compaction-persistence.js +1 -0
  30. package/dist/application/agent/context-compaction.d.ts +22 -0
  31. package/dist/application/agent/context-compaction.js +8 -0
  32. package/dist/application/agent/context-token-cache.d.ts +21 -0
  33. package/dist/application/agent/context-token-cache.js +4 -0
  34. package/dist/application/agent/context-usage-service.d.ts +52 -0
  35. package/dist/application/agent/context-usage-service.js +1 -0
  36. package/dist/application/agent/continuation-checkpoint.d.ts +15 -0
  37. package/dist/application/agent/continuation-checkpoint.js +2 -0
  38. package/dist/application/agent/interactive-agent-guidance.d.ts +5 -0
  39. package/dist/application/agent/interactive-agent-guidance.js +2 -0
  40. package/dist/application/agent/prompt-data-safety.d.ts +14 -0
  41. package/dist/application/agent/prompt-data-safety.js +4 -0
  42. package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
  43. package/dist/application/agent/scoped-tool-executor.js +1 -0
  44. package/dist/application/agent/tool-catalog.d.ts +14 -0
  45. package/dist/application/agent/tool-catalog.js +1 -0
  46. package/dist/application/agent/tool-display.d.ts +7 -0
  47. package/dist/application/agent/tool-display.js +1 -0
  48. package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
  49. package/dist/application/agent/tool-hook-lifecycle.js +1 -0
  50. package/dist/application/auth/authentication-service.d.ts +20 -0
  51. package/dist/application/auth/authentication-service.js +1 -0
  52. package/dist/application/chat/chat-service.d.ts +12 -0
  53. package/dist/application/chat/chat-service.js +1 -0
  54. package/dist/application/chat/pending-attachment-store.d.ts +15 -0
  55. package/dist/application/chat/pending-attachment-store.js +1 -0
  56. package/dist/application/commands/application-command-executor.d.ts +23 -0
  57. package/dist/application/commands/application-command-executor.js +3 -0
  58. package/dist/application/commands/cli-args.d.ts +6 -0
  59. package/dist/application/commands/cli-args.js +1 -0
  60. package/dist/application/commands/cli-command-services.d.ts +17 -0
  61. package/dist/application/commands/cli-command-services.js +33 -0
  62. package/dist/application/commands/command-cancellation.d.ts +6 -0
  63. package/dist/application/commands/command-cancellation.js +1 -0
  64. package/dist/application/commands/command-catalog.d.ts +6 -0
  65. package/dist/application/commands/command-catalog.js +1 -0
  66. package/dist/application/commands/command-contract.d.ts +60 -0
  67. package/dist/application/commands/command-contract.js +0 -0
  68. package/dist/application/commands/command-hints.d.ts +9 -0
  69. package/dist/application/commands/command-hints.js +1 -0
  70. package/dist/application/commands/command-output.d.ts +4 -0
  71. package/dist/application/commands/command-output.js +0 -0
  72. package/dist/application/commands/command-parser.d.ts +10 -0
  73. package/dist/application/commands/command-parser.js +1 -0
  74. package/dist/application/commands/command-presentation.d.ts +7 -0
  75. package/dist/application/commands/command-presentation.js +3 -0
  76. package/dist/application/commands/command-registry.d.ts +11 -0
  77. package/dist/application/commands/command-registry.js +1 -0
  78. package/dist/application/commands/command-runtime.d.ts +2 -0
  79. package/dist/application/commands/command-runtime.js +1 -0
  80. package/dist/application/commands/goal-command-handlers.d.ts +3 -0
  81. package/dist/application/commands/goal-command-handlers.js +7 -0
  82. package/dist/application/commands/media-command-handlers.d.ts +9 -0
  83. package/dist/application/commands/media-command-handlers.js +9 -0
  84. package/dist/application/commands/media-command-output.d.ts +11 -0
  85. package/dist/application/commands/media-command-output.js +1 -0
  86. package/dist/application/commands/memory-command-handler.d.ts +29 -0
  87. package/dist/application/commands/memory-command-handler.js +12 -0
  88. package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
  89. package/dist/application/commands/runtime-command-handlers.js +14 -0
  90. package/dist/application/commands/stream-output.d.ts +4 -0
  91. package/dist/application/commands/stream-output.js +1 -0
  92. package/dist/application/commands/utility-commands.d.ts +6 -0
  93. package/dist/application/commands/utility-commands.js +10 -0
  94. package/dist/application/config/execution-config.d.ts +4 -0
  95. package/dist/application/config/execution-config.js +1 -0
  96. package/dist/application/extensions/extension-list-contract.d.ts +18 -0
  97. package/dist/application/extensions/extension-list-contract.js +0 -0
  98. package/dist/application/extensions/extension-list-formatters.d.ts +38 -0
  99. package/dist/application/extensions/extension-list-formatters.js +1 -0
  100. package/dist/application/extensions/extension-list-output.d.ts +3 -0
  101. package/dist/application/extensions/extension-list-output.js +3 -0
  102. package/dist/application/extensions/plugin-contribution-registry.d.ts +31 -0
  103. package/dist/application/extensions/plugin-contribution-registry.js +1 -0
  104. package/dist/application/extensions/plugin-detail-contract.d.ts +25 -0
  105. package/dist/application/extensions/plugin-detail-contract.js +0 -0
  106. package/dist/application/extensions/plugin-detail-service.d.ts +3 -0
  107. package/dist/application/extensions/plugin-detail-service.js +1 -0
  108. package/dist/application/extensions/skill-scope-store.d.ts +23 -0
  109. package/dist/application/extensions/skill-scope-store.js +1 -0
  110. package/dist/application/formatting/compact-number.d.ts +2 -0
  111. package/dist/application/formatting/compact-number.js +1 -0
  112. package/dist/application/formatting/compact-table.d.ts +22 -0
  113. package/dist/application/formatting/compact-table.js +2 -0
  114. package/dist/application/intent/completion-gate.d.ts +3 -0
  115. package/dist/application/intent/completion-gate.js +1 -0
  116. package/dist/application/intent/evidence-ledger.d.ts +22 -0
  117. package/dist/application/intent/evidence-ledger.js +1 -0
  118. package/dist/application/intent/evidence-recording-tool-executor.d.ts +16 -0
  119. package/dist/application/intent/evidence-recording-tool-executor.js +1 -0
  120. package/dist/application/intent/intent-compiler.d.ts +11 -0
  121. package/dist/application/intent/intent-compiler.js +2 -0
  122. package/dist/application/intent/intent-execution-gate.d.ts +11 -0
  123. package/dist/application/intent/intent-execution-gate.js +1 -0
  124. package/dist/application/intent/intent-host-context.d.ts +6 -0
  125. package/dist/application/intent/intent-host-context.js +1 -0
  126. package/dist/application/intent/intent-run-controller.d.ts +56 -0
  127. package/dist/application/intent/intent-run-controller.js +3 -0
  128. package/dist/application/intent/project-policy.d.ts +16 -0
  129. package/dist/application/intent/project-policy.js +1 -0
  130. package/dist/application/media/video-operation-poller.d.ts +5 -0
  131. package/dist/application/media/video-operation-poller.js +1 -0
  132. package/dist/application/memory/memory-capture-policy.d.ts +10 -0
  133. package/dist/application/memory/memory-capture-policy.js +1 -0
  134. package/dist/application/memory/memory-consolidation-service.d.ts +12 -0
  135. package/dist/application/memory/memory-consolidation-service.js +1 -0
  136. package/dist/application/memory/memory-context-assembler.d.ts +24 -0
  137. package/dist/application/memory/memory-context-assembler.js +1 -0
  138. package/dist/application/memory/memory-extractor.d.ts +21 -0
  139. package/dist/application/memory/memory-extractor.js +2 -0
  140. package/dist/application/memory/memory-service.d.ts +34 -0
  141. package/dist/application/memory/memory-service.js +1 -0
  142. package/dist/application/model/cached-model-catalog.d.ts +19 -0
  143. package/dist/application/model/cached-model-catalog.js +1 -0
  144. package/dist/application/model/initial-model-selection.d.ts +10 -0
  145. package/dist/application/model/initial-model-selection.js +1 -0
  146. package/dist/application/model/model-catalog-service.d.ts +6 -0
  147. package/dist/application/model/model-catalog-service.js +1 -0
  148. package/dist/application/model/model-context-window.d.ts +3 -0
  149. package/dist/application/model/model-context-window.js +1 -0
  150. package/dist/application/model/model-response-retry.d.ts +15 -0
  151. package/dist/application/model/model-response-retry.js +1 -0
  152. package/dist/application/orchestration/abortable-wait.d.ts +2 -0
  153. package/dist/application/orchestration/abortable-wait.js +1 -0
  154. package/dist/application/orchestration/cli-subagent-service.d.ts +77 -0
  155. package/dist/application/orchestration/cli-subagent-service.js +13 -0
  156. package/dist/application/orchestration/cli-turn-event-projector.d.ts +15 -0
  157. package/dist/application/orchestration/cli-turn-event-projector.js +1 -0
  158. package/dist/application/orchestration/cli-turn-events.d.ts +76 -0
  159. package/dist/application/orchestration/cli-turn-events.js +1 -0
  160. package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
  161. package/dist/application/orchestration/cli-turn-persistence.js +1 -0
  162. package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
  163. package/dist/application/orchestration/goal-evaluator.js +3 -0
  164. package/dist/application/orchestration/goal-input.d.ts +3 -0
  165. package/dist/application/orchestration/goal-input.js +1 -0
  166. package/dist/application/orchestration/goal-output.d.ts +2 -0
  167. package/dist/application/orchestration/goal-output.js +2 -0
  168. package/dist/application/orchestration/goal-runner.d.ts +22 -0
  169. package/dist/application/orchestration/goal-runner.js +10 -0
  170. package/dist/application/orchestration/goal-usage.d.ts +9 -0
  171. package/dist/application/orchestration/goal-usage.js +1 -0
  172. package/dist/application/orchestration/headless-agent-turn.d.ts +36 -0
  173. package/dist/application/orchestration/headless-agent-turn.js +4 -0
  174. package/dist/application/orchestration/orchestration-constants.d.ts +3 -0
  175. package/dist/application/orchestration/orchestration-constants.js +1 -0
  176. package/dist/application/orchestration/subagent-coordinator.d.ts +41 -0
  177. package/dist/application/orchestration/subagent-coordinator.js +1 -0
  178. package/dist/application/orchestration/subagent-handoff.d.ts +3 -0
  179. package/dist/application/orchestration/subagent-handoff.js +3 -0
  180. package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
  181. package/dist/application/orchestration/subagent-tool-executor.js +1 -0
  182. package/dist/application/orchestration/task-graph.d.ts +13 -0
  183. package/dist/application/orchestration/task-graph.js +1 -0
  184. package/dist/application/orchestration/task-scheduler.d.ts +18 -0
  185. package/dist/application/orchestration/task-scheduler.js +1 -0
  186. package/dist/application/project/project-trust-service.d.ts +13 -0
  187. package/dist/application/project/project-trust-service.js +1 -0
  188. package/dist/application/project-intelligence/project-intelligence-constants.d.ts +56 -0
  189. package/dist/application/project-intelligence/project-intelligence-constants.js +1 -0
  190. package/dist/application/project-intelligence/project-intelligence-service.d.ts +14 -0
  191. package/dist/application/project-intelligence/project-intelligence-service.js +1 -0
  192. package/dist/application/protocol/browser-host-tool-executor.d.ts +51 -0
  193. package/dist/application/protocol/browser-host-tool-executor.js +2 -0
  194. package/dist/application/protocol/computer-host-tool-executor.d.ts +45 -0
  195. package/dist/application/protocol/computer-host-tool-executor.js +2 -0
  196. package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
  197. package/dist/application/protocol/desktop-agent-command.js +3 -0
  198. package/dist/application/protocol/desktop-agent-contracts.d.ts +34 -0
  199. package/dist/application/protocol/desktop-agent-contracts.js +1 -0
  200. package/dist/application/protocol/desktop-agent-helpers.d.ts +5 -0
  201. package/dist/application/protocol/desktop-agent-helpers.js +1 -0
  202. package/dist/application/protocol/desktop-agent-request-parser.d.ts +211 -0
  203. package/dist/application/protocol/desktop-agent-request-parser.js +1 -0
  204. package/dist/application/protocol/desktop-approval-broker.d.ts +26 -0
  205. package/dist/application/protocol/desktop-approval-broker.js +1 -0
  206. package/dist/application/protocol/desktop-attachment-store.d.ts +33 -0
  207. package/dist/application/protocol/desktop-attachment-store.js +1 -0
  208. package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
  209. package/dist/application/protocol/desktop-command-catalog.js +1 -0
  210. package/dist/application/protocol/desktop-command-contract.d.ts +26 -0
  211. package/dist/application/protocol/desktop-command-contract.js +1 -0
  212. package/dist/application/protocol/desktop-command-executor.d.ts +17 -0
  213. package/dist/application/protocol/desktop-command-executor.js +1 -0
  214. package/dist/application/protocol/desktop-command-output.d.ts +15 -0
  215. package/dist/application/protocol/desktop-command-output.js +1 -0
  216. package/dist/application/protocol/desktop-execution-policy.d.ts +19 -0
  217. package/dist/application/protocol/desktop-execution-policy.js +1 -0
  218. package/dist/application/protocol/desktop-extension-request-handler.d.ts +14 -0
  219. package/dist/application/protocol/desktop-extension-request-handler.js +1 -0
  220. package/dist/application/protocol/desktop-extension-service.d.ts +44 -0
  221. package/dist/application/protocol/desktop-extension-service.js +3 -0
  222. package/dist/application/protocol/desktop-host-bridge.d.ts +33 -0
  223. package/dist/application/protocol/desktop-host-bridge.js +1 -0
  224. package/dist/application/protocol/desktop-host-capabilities.d.ts +12 -0
  225. package/dist/application/protocol/desktop-host-capabilities.js +1 -0
  226. package/dist/application/protocol/desktop-host-tool-executor.d.ts +76 -0
  227. package/dist/application/protocol/desktop-host-tool-executor.js +2 -0
  228. package/dist/application/protocol/desktop-intent-event-writer.d.ts +20 -0
  229. package/dist/application/protocol/desktop-intent-event-writer.js +1 -0
  230. package/dist/application/protocol/desktop-mcp-events.d.ts +10 -0
  231. package/dist/application/protocol/desktop-mcp-events.js +1 -0
  232. package/dist/application/protocol/desktop-orchestration-events.d.ts +2 -0
  233. package/dist/application/protocol/desktop-orchestration-events.js +2 -0
  234. package/dist/application/protocol/desktop-protocol-helpers.d.ts +13 -0
  235. package/dist/application/protocol/desktop-protocol-helpers.js +1 -0
  236. package/dist/application/protocol/json-line-writer.d.ts +31 -0
  237. package/dist/application/protocol/json-line-writer.js +2 -0
  238. package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
  239. package/dist/application/protocol/jsonl-agent-command.js +3 -0
  240. package/dist/application/protocol/jsonl-protocol.d.ts +82 -0
  241. package/dist/application/protocol/jsonl-protocol.js +2 -0
  242. package/dist/application/protocol/tool-image-content.d.ts +4 -0
  243. package/dist/application/protocol/tool-image-content.js +1 -0
  244. package/dist/application/security/delegated-worker-policy.d.ts +3 -0
  245. package/dist/application/security/delegated-worker-policy.js +1 -0
  246. package/dist/application/security/desktop-tool-scope-policy.d.ts +4 -0
  247. package/dist/application/security/desktop-tool-scope-policy.js +1 -0
  248. package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
  249. package/dist/application/security/tool-action-risk-analyzer.js +1 -0
  250. package/dist/application/security/tool-approval-service.d.ts +43 -0
  251. package/dist/application/security/tool-approval-service.js +1 -0
  252. package/dist/application/security/tool-policy-registry.d.ts +20 -0
  253. package/dist/application/security/tool-policy-registry.js +1 -0
  254. package/dist/application/security/tool-risk-classifier.d.ts +19 -0
  255. package/dist/application/security/tool-risk-classifier.js +1 -0
  256. package/dist/application/security/workspace-permission-policy.d.ts +10 -0
  257. package/dist/application/security/workspace-permission-policy.js +1 -0
  258. package/dist/application/session/project-session-access.d.ts +8 -0
  259. package/dist/application/session/project-session-access.js +1 -0
  260. package/dist/application/session/session-compaction-service.d.ts +10 -0
  261. package/dist/application/session/session-compaction-service.js +1 -0
  262. package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
  263. package/dist/application/session/session-turn-lifecycle.js +1 -0
  264. package/dist/application/workspace/session-execution-workspace.d.ts +59 -0
  265. package/dist/application/workspace/session-execution-workspace.js +3 -0
  266. package/dist/application/workspace/workspace-constants.d.ts +17 -0
  267. package/dist/application/workspace/workspace-constants.js +1 -0
  268. package/dist/application/workspace/workspace-file-index.d.ts +14 -0
  269. package/dist/application/workspace/workspace-file-index.js +1 -0
  270. package/dist/application/workspace/workspace-file-reference-resolver.d.ts +20 -0
  271. package/dist/application/workspace/workspace-file-reference-resolver.js +17 -0
  272. package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
  273. package/dist/application/workspace/workspace-instruction-loader.js +1 -0
  274. package/dist/bootstrap/composition-root.d.ts +7 -0
  275. package/dist/bootstrap/composition-root.js +1 -0
  276. package/dist/bootstrap/global-cli-options.d.ts +6 -0
  277. package/dist/bootstrap/global-cli-options.js +1 -0
  278. package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
  279. package/dist/bootstrap/native-devtools-stub.js +1 -0
  280. package/dist/bootstrap/native-entry.d.ts +1 -0
  281. package/dist/bootstrap/native-entry.js +2 -0
  282. package/dist/bootstrap/native-tiktoken.d.ts +4 -0
  283. package/dist/bootstrap/native-tiktoken.js +1 -0
  284. package/dist/bootstrap/runtime-factory.d.ts +46 -0
  285. package/dist/bootstrap/runtime-factory.js +1 -0
  286. package/dist/bootstrap/shutdown-manager.d.ts +11 -0
  287. package/dist/bootstrap/shutdown-manager.js +1 -0
  288. package/dist/bootstrap/startup-sequence.d.ts +5 -0
  289. package/dist/bootstrap/startup-sequence.js +1 -0
  290. package/dist/domain/auth/auth-profile.d.ts +14 -0
  291. package/dist/domain/auth/auth-profile.js +1 -0
  292. package/dist/domain/config/config-schema.d.ts +24 -0
  293. package/dist/domain/config/config-schema.js +1 -0
  294. package/dist/domain/errors/cli-command-hint.d.ts +5 -0
  295. package/dist/domain/errors/cli-command-hint.js +0 -0
  296. package/dist/domain/errors/cli-error.d.ts +35 -0
  297. package/dist/domain/errors/cli-error.js +1 -0
  298. package/dist/domain/errors/error-codes.d.ts +51 -0
  299. package/dist/domain/errors/error-codes.js +1 -0
  300. package/dist/domain/extensions/extension-constants.d.ts +1 -0
  301. package/dist/domain/extensions/extension-constants.js +1 -0
  302. package/dist/domain/extensions/extension-scope.d.ts +3 -0
  303. package/dist/domain/extensions/extension-scope.js +1 -0
  304. package/dist/domain/extensions/extension-state.d.ts +5 -0
  305. package/dist/domain/extensions/extension-state.js +1 -0
  306. package/dist/domain/extensions/hook-manifest.d.ts +13 -0
  307. package/dist/domain/extensions/hook-manifest.js +1 -0
  308. package/dist/domain/extensions/host-tool-plugin-ids.d.ts +5 -0
  309. package/dist/domain/extensions/host-tool-plugin-ids.js +1 -0
  310. package/dist/domain/extensions/mcp-config.d.ts +35 -0
  311. package/dist/domain/extensions/mcp-config.js +1 -0
  312. package/dist/domain/extensions/plugin-agent-manifest.d.ts +8 -0
  313. package/dist/domain/extensions/plugin-agent-manifest.js +1 -0
  314. package/dist/domain/extensions/plugin-manifest.d.ts +23 -0
  315. package/dist/domain/extensions/plugin-manifest.js +1 -0
  316. package/dist/domain/extensions/skill-manifest.d.ts +10 -0
  317. package/dist/domain/extensions/skill-manifest.js +3 -0
  318. package/dist/domain/extensions/yaml-subset.d.ts +9 -0
  319. package/dist/domain/extensions/yaml-subset.js +2 -0
  320. package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
  321. package/dist/domain/filesystem/file-change-diff.js +3 -0
  322. package/dist/domain/intent/intent-contract.d.ts +33 -0
  323. package/dist/domain/intent/intent-contract.js +1 -0
  324. package/dist/domain/media/gateway-media-contract.d.ts +23 -0
  325. package/dist/domain/media/gateway-media-contract.js +1 -0
  326. package/dist/domain/media/media-constants.d.ts +3 -0
  327. package/dist/domain/media/media-constants.js +1 -0
  328. package/dist/domain/media/media-contract.d.ts +28 -0
  329. package/dist/domain/media/media-contract.js +0 -0
  330. package/dist/domain/media/media-execution-policy.d.ts +9 -0
  331. package/dist/domain/media/media-execution-policy.js +1 -0
  332. package/dist/domain/memory/memory-constants.d.ts +3 -0
  333. package/dist/domain/memory/memory-constants.js +1 -0
  334. package/dist/domain/memory/memory-kinds.d.ts +15 -0
  335. package/dist/domain/memory/memory-kinds.js +1 -0
  336. package/dist/domain/memory/memory-retrieval-policy.d.ts +3 -0
  337. package/dist/domain/memory/memory-retrieval-policy.js +1 -0
  338. package/dist/domain/memory/memory-search.d.ts +33 -0
  339. package/dist/domain/memory/memory-search.js +2 -0
  340. package/dist/domain/memory/memory.d.ts +48 -0
  341. package/dist/domain/memory/memory.js +1 -0
  342. package/dist/domain/orchestration/goal.d.ts +57 -0
  343. package/dist/domain/orchestration/goal.js +1 -0
  344. package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
  345. package/dist/domain/orchestration/subagent-identity.js +1 -0
  346. package/dist/domain/orchestration/subagent.d.ts +33 -0
  347. package/dist/domain/orchestration/subagent.js +0 -0
  348. package/dist/domain/orchestration/work-plan.d.ts +15 -0
  349. package/dist/domain/orchestration/work-plan.js +0 -0
  350. package/dist/domain/project/project-identity.d.ts +6 -0
  351. package/dist/domain/project/project-identity.js +1 -0
  352. package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
  353. package/dist/domain/runtime/assistant-delta-normalizer.js +1 -0
  354. package/dist/domain/runtime/assistant-stream-text.d.ts +11 -0
  355. package/dist/domain/runtime/assistant-stream-text.js +1 -0
  356. package/dist/domain/runtime/gateway-request-budget.d.ts +19 -0
  357. package/dist/domain/runtime/gateway-request-budget.js +1 -0
  358. package/dist/domain/runtime/resource-limits.d.ts +92 -0
  359. package/dist/domain/runtime/resource-limits.js +1 -0
  360. package/dist/domain/session/attachment.d.ts +15 -0
  361. package/dist/domain/session/attachment.js +0 -0
  362. package/dist/domain/session/session-schema.d.ts +6 -0
  363. package/dist/domain/session/session-schema.js +1 -0
  364. package/dist/domain/session/session.d.ts +27 -0
  365. package/dist/domain/session/session.js +0 -0
  366. package/dist/domain/settings/settings-document.d.ts +8 -0
  367. package/dist/domain/settings/settings-document.js +1 -0
  368. package/dist/domain/validation/record-schema.d.ts +4 -0
  369. package/dist/domain/validation/record-schema.js +1 -0
  370. package/dist/domain/workspace/workspace-settings.d.ts +14 -0
  371. package/dist/domain/workspace/workspace-settings.js +1 -0
  372. package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
  373. package/dist/infrastructure/agent-sdk/agent-instance-factory.js +1 -0
  374. package/dist/infrastructure/agent-sdk/model-response-metrics.d.ts +7 -0
  375. package/dist/infrastructure/agent-sdk/model-response-metrics.js +1 -0
  376. package/dist/infrastructure/agent-sdk/model-tool-name-mapper.d.ts +13 -0
  377. package/dist/infrastructure/agent-sdk/model-tool-name-mapper.js +1 -0
  378. package/dist/infrastructure/agent-sdk/sdk-constants.d.ts +2 -0
  379. package/dist/infrastructure/agent-sdk/sdk-constants.js +1 -0
  380. package/dist/infrastructure/agent-sdk/tool-calling-completion-client.d.ts +4 -0
  381. package/dist/infrastructure/agent-sdk/tool-calling-completion-client.js +1 -0
  382. package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
  383. package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +1 -0
  384. package/dist/infrastructure/cache/cache-policy.d.ts +9 -0
  385. package/dist/infrastructure/cache/cache-policy.js +1 -0
  386. package/dist/infrastructure/cache/file-cache-store.d.ts +25 -0
  387. package/dist/infrastructure/cache/file-cache-store.js +2 -0
  388. package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
  389. package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +1 -0
  390. package/dist/infrastructure/clipboard/clipboard-constants.d.ts +1 -0
  391. package/dist/infrastructure/clipboard/clipboard-constants.js +1 -0
  392. package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
  393. package/dist/infrastructure/clipboard/clipboard-policy.js +1 -0
  394. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
  395. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +1 -0
  396. package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
  397. package/dist/infrastructure/clipboard/image-normalizer.js +1 -0
  398. package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
  399. package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +1 -0
  400. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
  401. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +1 -0
  402. package/dist/infrastructure/config/config-loader.d.ts +19 -0
  403. package/dist/infrastructure/config/config-loader.js +2 -0
  404. package/dist/infrastructure/config/environment-values.d.ts +2 -0
  405. package/dist/infrastructure/config/environment-values.js +1 -0
  406. package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
  407. package/dist/infrastructure/credentials/composite-credential-store.js +1 -0
  408. package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
  409. package/dist/infrastructure/credentials/encrypted-file-credential-store.js +3 -0
  410. package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
  411. package/dist/infrastructure/credentials/environment-credential-store.js +1 -0
  412. package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
  413. package/dist/infrastructure/credentials/secret-input.js +3 -0
  414. package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
  415. package/dist/infrastructure/extensions/composite-mcp-config-store.js +1 -0
  416. package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
  417. package/dist/infrastructure/extensions/extension-directory-reader.js +1 -0
  418. package/dist/infrastructure/extensions/extension-integrity.d.ts +7 -0
  419. package/dist/infrastructure/extensions/extension-integrity.js +1 -0
  420. package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
  421. package/dist/infrastructure/extensions/extension-source-resolver.js +1 -0
  422. package/dist/infrastructure/extensions/extensions-constants.d.ts +6 -0
  423. package/dist/infrastructure/extensions/extensions-constants.js +1 -0
  424. package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
  425. package/dist/infrastructure/extensions/file-mcp-config-store.js +2 -0
  426. package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
  427. package/dist/infrastructure/extensions/hook-runtime.js +1 -0
  428. package/dist/infrastructure/extensions/mcp-runtime.d.ts +58 -0
  429. package/dist/infrastructure/extensions/mcp-runtime.js +1 -0
  430. package/dist/infrastructure/extensions/plugin-agent-discovery.d.ts +4 -0
  431. package/dist/infrastructure/extensions/plugin-agent-discovery.js +1 -0
  432. package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
  433. package/dist/infrastructure/extensions/plugin-discovery.js +1 -0
  434. package/dist/infrastructure/extensions/plugin-manager.d.ts +23 -0
  435. package/dist/infrastructure/extensions/plugin-manager.js +2 -0
  436. package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
  437. package/dist/infrastructure/extensions/skill-discovery.js +1 -0
  438. package/dist/infrastructure/extensions/skill-installer.d.ts +9 -0
  439. package/dist/infrastructure/extensions/skill-installer.js +1 -0
  440. package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
  441. package/dist/infrastructure/extensions/skill-manager.js +2 -0
  442. package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
  443. package/dist/infrastructure/extensions/skill-roots.js +1 -0
  444. package/dist/infrastructure/extensions/skill-tool-executor.d.ts +20 -0
  445. package/dist/infrastructure/extensions/skill-tool-executor.js +2 -0
  446. package/dist/infrastructure/filesystem/atomic-file-store.d.ts +28 -0
  447. package/dist/infrastructure/filesystem/atomic-file-store.js +1 -0
  448. package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
  449. package/dist/infrastructure/filesystem/bounded-file-reader.js +1 -0
  450. package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
  451. package/dist/infrastructure/filesystem/bounded-json-reader.js +1 -0
  452. package/dist/infrastructure/filesystem/filesystem-constants.d.ts +8 -0
  453. package/dist/infrastructure/filesystem/filesystem-constants.js +1 -0
  454. package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
  455. package/dist/infrastructure/filesystem/fs-errors.js +1 -0
  456. package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
  457. package/dist/infrastructure/filesystem/gateway-media-input-reader.js +1 -0
  458. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +25 -0
  459. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +3 -0
  460. package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
  461. package/dist/infrastructure/filesystem/path-resolver.js +1 -0
  462. package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
  463. package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +1 -0
  464. package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +26 -0
  465. package/dist/infrastructure/logging/daily-rotating-file-writer.js +2 -0
  466. package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
  467. package/dist/infrastructure/logging/log-redactor.js +1 -0
  468. package/dist/infrastructure/logging/logging-constants.d.ts +3 -0
  469. package/dist/infrastructure/logging/logging-constants.js +1 -0
  470. package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
  471. package/dist/infrastructure/logging/logging-policy.js +1 -0
  472. package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
  473. package/dist/infrastructure/logging/structured-logger.js +4 -0
  474. package/dist/infrastructure/memory/file-memory-store.d.ts +37 -0
  475. package/dist/infrastructure/memory/file-memory-store.js +11 -0
  476. package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
  477. package/dist/infrastructure/network/safe-media-downloader.js +1 -0
  478. package/dist/infrastructure/observability/tool-execution-logger.d.ts +11 -0
  479. package/dist/infrastructure/observability/tool-execution-logger.js +1 -0
  480. package/dist/infrastructure/platform/host-platform.d.ts +16 -0
  481. package/dist/infrastructure/platform/host-platform.js +1 -0
  482. package/dist/infrastructure/platform/host-process.d.ts +31 -0
  483. package/dist/infrastructure/platform/host-process.js +1 -0
  484. package/dist/infrastructure/platform/platform-constants.d.ts +4 -0
  485. package/dist/infrastructure/platform/platform-constants.js +1 -0
  486. package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
  487. package/dist/infrastructure/platform/platform-paths.js +1 -0
  488. package/dist/infrastructure/platform/process-identity.d.ts +8 -0
  489. package/dist/infrastructure/platform/process-identity.js +1 -0
  490. package/dist/infrastructure/platform/process-termination.d.ts +4 -0
  491. package/dist/infrastructure/platform/process-termination.js +1 -0
  492. package/dist/infrastructure/platform/read-only-executable.d.ts +4 -0
  493. package/dist/infrastructure/platform/read-only-executable.js +1 -0
  494. package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
  495. package/dist/infrastructure/project/file-project-trust-store.js +2 -0
  496. package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
  497. package/dist/infrastructure/sdk/chat-completion-adapter.js +1 -0
  498. package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
  499. package/dist/infrastructure/sdk/lotagate-client-factory.js +1 -0
  500. package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
  501. package/dist/infrastructure/sdk/model-catalog-adapter.js +1 -0
  502. package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +24 -0
  503. package/dist/infrastructure/sdk/sdk-media-gateway-client.js +1 -0
  504. package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
  505. package/dist/infrastructure/sessions/file-goal-store.js +1 -0
  506. package/dist/infrastructure/sessions/file-session-store.d.ts +50 -0
  507. package/dist/infrastructure/sessions/file-session-store.js +4 -0
  508. package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
  509. package/dist/infrastructure/sessions/project-session-paths.js +1 -0
  510. package/dist/infrastructure/sessions/session-constants.d.ts +3 -0
  511. package/dist/infrastructure/sessions/session-constants.js +1 -0
  512. package/dist/infrastructure/sessions/session-index.d.ts +16 -0
  513. package/dist/infrastructure/sessions/session-index.js +3 -0
  514. package/dist/infrastructure/sessions/session-journal-health.d.ts +7 -0
  515. package/dist/infrastructure/sessions/session-journal-health.js +1 -0
  516. package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
  517. package/dist/infrastructure/sessions/session-journal.js +6 -0
  518. package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
  519. package/dist/infrastructure/sessions/subagent-journal-store.js +2 -0
  520. package/dist/infrastructure/shell/shell-tool-executor.d.ts +21 -0
  521. package/dist/infrastructure/shell/shell-tool-executor.js +2 -0
  522. package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
  523. package/dist/infrastructure/tokens/tiktoken-token-estimator.js +1 -0
  524. package/dist/infrastructure/tokens/token-constants.d.ts +1 -0
  525. package/dist/infrastructure/tokens/token-constants.js +1 -0
  526. package/dist/infrastructure/workspace/workspace-settings-store.d.ts +10 -0
  527. package/dist/infrastructure/workspace/workspace-settings-store.js +4 -0
  528. package/dist/main.d.ts +7 -0
  529. package/dist/main.js +3 -0
  530. package/dist/ports/cache-store.d.ts +10 -0
  531. package/dist/ports/cache-store.js +0 -0
  532. package/dist/ports/chat-model.d.ts +30 -0
  533. package/dist/ports/chat-model.js +0 -0
  534. package/dist/ports/clipboard-adapter.d.ts +7 -0
  535. package/dist/ports/clipboard-adapter.js +0 -0
  536. package/dist/ports/clipboard-text-adapter.d.ts +3 -0
  537. package/dist/ports/clipboard-text-adapter.js +0 -0
  538. package/dist/ports/credential-store.d.ts +7 -0
  539. package/dist/ports/credential-store.js +0 -0
  540. package/dist/ports/goal-store.d.ts +12 -0
  541. package/dist/ports/goal-store.js +0 -0
  542. package/dist/ports/logger.d.ts +8 -0
  543. package/dist/ports/logger.js +0 -0
  544. package/dist/ports/media-gateway-client.d.ts +60 -0
  545. package/dist/ports/media-gateway-client.js +0 -0
  546. package/dist/ports/memory-store.d.ts +26 -0
  547. package/dist/ports/memory-store.js +0 -0
  548. package/dist/ports/model-completion-client.d.ts +8 -0
  549. package/dist/ports/model-completion-client.js +0 -0
  550. package/dist/ports/model-diagnostics.d.ts +17 -0
  551. package/dist/ports/model-diagnostics.js +0 -0
  552. package/dist/ports/project-trust-store.d.ts +12 -0
  553. package/dist/ports/project-trust-store.js +0 -0
  554. package/dist/ports/session-store.d.ts +59 -0
  555. package/dist/ports/session-store.js +0 -0
  556. package/dist/ports/subagent-lifecycle.d.ts +31 -0
  557. package/dist/ports/subagent-lifecycle.js +0 -0
  558. package/dist/ports/tool-activity.d.ts +13 -0
  559. package/dist/ports/tool-activity.js +0 -0
  560. package/dist/presentation/themes/theme.d.ts +19 -0
  561. package/dist/presentation/themes/theme.js +1 -0
  562. package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
  563. package/dist/presentation/tui/agent-initialization-renderer.js +1 -0
  564. package/dist/presentation/tui/context-display.d.ts +21 -0
  565. package/dist/presentation/tui/context-display.js +2 -0
  566. package/dist/presentation/tui/formatters.d.ts +6 -0
  567. package/dist/presentation/tui/formatters.js +1 -0
  568. package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
  569. package/dist/presentation/tui/ink/choice-window.js +1 -0
  570. package/dist/presentation/tui/ink/components/activity-animation.d.ts +3 -0
  571. package/dist/presentation/tui/ink/components/activity-animation.js +1 -0
  572. package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
  573. package/dist/presentation/tui/ink/components/activity-entry.js +1 -0
  574. package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
  575. package/dist/presentation/tui/ink/components/activity-status.js +1 -0
  576. package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
  577. package/dist/presentation/tui/ink/components/choice-modal.js +1 -0
  578. package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
  579. package/dist/presentation/tui/ink/components/composer.js +8 -0
  580. package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
  581. package/dist/presentation/tui/ink/components/file-diff.js +1 -0
  582. package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
  583. package/dist/presentation/tui/ink/components/modal.js +2 -0
  584. package/dist/presentation/tui/ink/components/shimmer-text.d.ts +8 -0
  585. package/dist/presentation/tui/ink/components/shimmer-text.js +1 -0
  586. package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
  587. package/dist/presentation/tui/ink/components/subagent-activity.js +1 -0
  588. package/dist/presentation/tui/ink/components/transcript.d.ts +40 -0
  589. package/dist/presentation/tui/ink/components/transcript.js +5 -0
  590. package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
  591. package/dist/presentation/tui/ink/components/welcome-panel.js +1 -0
  592. package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
  593. package/dist/presentation/tui/ink/lotagate-tui.js +2 -0
  594. package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
  595. package/dist/presentation/tui/ink/markdown-inline-renderer.js +1 -0
  596. package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
  597. package/dist/presentation/tui/ink/markdown-inline.js +1 -0
  598. package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
  599. package/dist/presentation/tui/ink/markdown-message.js +2 -0
  600. package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
  601. package/dist/presentation/tui/ink/markdown-table.js +1 -0
  602. package/dist/presentation/tui/ink/tui-bridge.d.ts +193 -0
  603. package/dist/presentation/tui/ink/tui-bridge.js +1 -0
  604. package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
  605. package/dist/presentation/tui/terminal-capabilities.js +1 -0
  606. package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
  607. package/dist/presentation/tui/terminal-mouse.js +1 -0
  608. package/dist/presentation/tui/terminal-screen.d.ts +10 -0
  609. package/dist/presentation/tui/terminal-screen.js +1 -0
  610. package/dist/presentation/tui/tui-agent-event-runner.d.ts +29 -0
  611. package/dist/presentation/tui/tui-agent-event-runner.js +1 -0
  612. package/dist/presentation/tui/tui-agent-turn-controller.d.ts +45 -0
  613. package/dist/presentation/tui/tui-agent-turn-controller.js +1 -0
  614. package/dist/presentation/tui/tui-application-contract.d.ts +11 -0
  615. package/dist/presentation/tui/tui-application-contract.js +1 -0
  616. package/dist/presentation/tui/tui-application.d.ts +61 -0
  617. package/dist/presentation/tui/tui-application.js +3 -0
  618. package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
  619. package/dist/presentation/tui/tui-clipboard-paste-handlers.js +1 -0
  620. package/dist/presentation/tui/tui-command-context.d.ts +3 -0
  621. package/dist/presentation/tui/tui-command-context.js +0 -0
  622. package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
  623. package/dist/presentation/tui/tui-command-executor.js +4 -0
  624. package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
  625. package/dist/presentation/tui/tui-command-host-factory.js +1 -0
  626. package/dist/presentation/tui/tui-context-compaction.d.ts +8 -0
  627. package/dist/presentation/tui/tui-context-compaction.js +1 -0
  628. package/dist/presentation/tui/tui-context-service.d.ts +2 -0
  629. package/dist/presentation/tui/tui-context-service.js +1 -0
  630. package/dist/presentation/tui/tui-extension-loader.d.ts +21 -0
  631. package/dist/presentation/tui/tui-extension-loader.js +1 -0
  632. package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
  633. package/dist/presentation/tui/tui-file-suggestions.js +1 -0
  634. package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
  635. package/dist/presentation/tui/tui-goal-controller.js +1 -0
  636. package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
  637. package/dist/presentation/tui/tui-initial-model.js +1 -0
  638. package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
  639. package/dist/presentation/tui/tui-lifecycle-actions.js +1 -0
  640. package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
  641. package/dist/presentation/tui/tui-manual-compaction.js +1 -0
  642. package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
  643. package/dist/presentation/tui/tui-media-model-selection.js +1 -0
  644. package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
  645. package/dist/presentation/tui/tui-prompt-dispatcher.js +1 -0
  646. package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
  647. package/dist/presentation/tui/tui-skill-controller.js +3 -0
  648. package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
  649. package/dist/presentation/tui/tui-tool-approval.js +1 -0
  650. package/dist/version.d.ts +1 -0
  651. package/dist/version.js +1 -0
  652. package/native-targets.mjs +1 -1
  653. package/package.json +13 -12
  654. package/scripts/install-native.mjs +5 -13
  655. package/skills/architecture-review/SKILL.md +41 -14
  656. package/skills/code-review/SKILL.md +41 -12
  657. package/skills/debugging/SKILL.md +49 -12
  658. package/skills/documentation/SKILL.md +43 -9
  659. package/skills/feature-implementation/SKILL.md +58 -19
  660. package/bin/lotagate.exe +0 -1
  661. package/skills/api-contract-review/SKILL.md +0 -17
  662. package/skills/database-review/SKILL.md +0 -17
  663. package/skills/dependency-review/SKILL.md +0 -16
  664. package/skills/frontend-review/SKILL.md +0 -18
  665. package/skills/incident-response/SKILL.md +0 -18
  666. package/skills/performance-review/SKILL.md +0 -17
  667. package/skills/refactor/SKILL.md +0 -23
  668. package/skills/release-readiness/SKILL.md +0 -16
  669. package/skills/security-review/SKILL.md +0 -16
  670. package/skills/test-plan/SKILL.md +0 -22
  671. package/skills/verify/SKILL.md +0 -13
@@ -0,0 +1,11 @@
1
+ import type { ToolExecutionContext, ToolResult } from '@lotagate/agent-sdk';
2
+ import type { Logger } from '../../ports/logger.js';
3
+ interface ToolExecutionLogOptions {
4
+ toolName: string;
5
+ source: string;
6
+ context: ToolExecutionContext;
7
+ details?: Record<string, unknown>;
8
+ }
9
+ /** Adds consistent lifecycle logs without recording tool payloads or result content. */
10
+ export declare function withToolExecutionLogging<T extends ToolResult>(logger: Logger | undefined, options: ToolExecutionLogOptions, action: () => Promise<T>): Promise<T>;
11
+ export {};
@@ -0,0 +1 @@
1
+ async function u(t,e,s){const r=Date.now(),n={toolName:e.toolName,source:e.source,sessionId:e.context.sessionId,runId:e.context.runId,iteration:e.context.iteration,...e.details??{}};t?.info("tool.execution.started",n);try{const o=await s(),i={...n,durationMs:Date.now()-r,outcome:o.isError?"error":"success",...c(o)};return o.isError?t?.warn("tool.execution.failed",i):t?.info("tool.execution.completed",i),o}catch(o){const i=a(o);throw t?.error("tool.execution.failed",{...n,durationMs:Date.now()-r,outcome:"exception",error:o instanceof Error?o.message:String(o),...i===void 0?{}:{errorCode:i}}),o}}function c(t){const e=t.metadata;if(e===void 0)return{};const s={};for(const r of["errorCode","exitCode","timedOut"]){const n=e[r];(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&(s[r]=n)}return s}function a(t){if(t===null||typeof t!="object"||!("code"in t))return;const e=t.code;return typeof e=="string"&&e.length>0?e:void 0}export{u as withToolExecutionLogging};
@@ -0,0 +1,16 @@
1
+ export type HostPlatformId = 'windows' | 'linux' | 'macos' | 'bsd' | 'unsupported';
2
+ export type HostNodePlatform = typeof process.platform;
3
+ export interface HostPlatformContext {
4
+ readonly id: HostPlatformId;
5
+ readonly nodePlatform: HostNodePlatform;
6
+ readonly isWindows: boolean;
7
+ readonly supportsProcessGroups: boolean;
8
+ readonly env: Readonly<Record<string, string | undefined>>;
9
+ }
10
+ export interface HostPlatformInput {
11
+ nodePlatform?: HostNodePlatform;
12
+ env?: Readonly<Record<string, string | undefined>>;
13
+ }
14
+ export declare function detectHostPlatform(input?: HostPlatformInput): HostPlatformContext;
15
+ /** Describes the POSIX userspace contract used by Desktop's isolated guest boundary. */
16
+ export declare function createIsolatedGuestPlatform(): HostPlatformContext;
@@ -0,0 +1 @@
1
+ function s(n={}){const e=n.nodePlatform??process.platform,r=t(e),o=r==="windows";return{id:r,nodePlatform:e,isWindows:o,supportsProcessGroups:!o,env:n.env??process.env}}function i(){return s({nodePlatform:"linux",env:{}})}function t(n){return n==="win32"||n==="cygwin"?"windows":n==="linux"||n==="android"?"linux":n==="darwin"?"macos":n==="freebsd"||n==="openbsd"||n==="netbsd"?"bsd":"unsupported"}export{i as createIsolatedGuestPlatform,s as detectHostPlatform};
@@ -0,0 +1,31 @@
1
+ import { type ChildProcess, type SpawnOptions } from 'node:child_process';
2
+ import type { HostPlatformContext } from './host-platform.js';
3
+ export { terminatePlatformProcess } from './process-termination.js';
4
+ export interface PreparedPlatformCommand {
5
+ command: string;
6
+ args: readonly string[];
7
+ windowsVerbatimArguments: boolean;
8
+ }
9
+ /** Normalizes the structured shell contract for a complete PowerShell script. */
10
+ export declare function normalizePowerShellScriptInput(input: Record<string, unknown>, platform: HostPlatformContext, options?: {
11
+ readonly allowNonWindows?: boolean;
12
+ }): Record<string, unknown>;
13
+ export declare function preparePowerShellScript(command: string, script: string): PreparedPlatformCommand;
14
+ export declare function isPowerShellExecutable(command: string): boolean;
15
+ export interface PlatformExecOptions {
16
+ cwd?: string;
17
+ env?: NonNullable<SpawnOptions['env']>;
18
+ maxBufferBytes?: number;
19
+ timeoutMs?: number;
20
+ signal?: AbortSignal;
21
+ rejectOnNonZero?: boolean;
22
+ }
23
+ export interface PlatformExecResult {
24
+ stdout: string;
25
+ stderr: string;
26
+ exitCode: number | null;
27
+ }
28
+ export declare function spawnPlatformProcess(command: string, args: readonly string[], platform: HostPlatformContext, options?: SpawnOptions): ChildProcess;
29
+ export declare function execPlatformCommand(command: string, args: readonly string[], platform: HostPlatformContext, options?: PlatformExecOptions): Promise<PlatformExecResult>;
30
+ export declare function createSafeChildEnvironment(platform: HostPlatformContext): NonNullable<SpawnOptions['env']>;
31
+ export declare function preparePlatformCommand(command: string, args: readonly string[], platform: HostPlatformContext): PreparedPlatformCommand;
@@ -0,0 +1 @@
1
+ import $ from"node:path";import{spawn as B}from"node:child_process";import{RESOURCE_LIMITS as A}from"../../domain/runtime/resource-limits.js";import{terminatePlatformProcess as T}from"./process-termination.js";import{terminatePlatformProcess as Y}from"./process-termination.js";import{DEFAULT_EXEC_BUFFER_BYTES as v,WINDOWS_CMD_SHIM as y,WINDOWS_DIRECT_EXECUTABLE as W,WINDOWS_META_CHARS as P}from"./platform-constants.js";function F(e,r,t={}){const n=e.script;if(n===void 0)return e;if(typeof n!="string"||n.trim().length===0)throw new Error("shell.exec script must be a non-empty string.");if(Buffer.byteLength(n,"utf8")>A.sessionTextBytes)throw new Error("shell.exec script exceeds the configured limit.");if(!r.isWindows&&t.allowNonWindows!==!0)throw new Error("shell.exec PowerShell scripts are unavailable in the isolated guest sandbox; use the supported host command with structured args.");const o=e.command;if(typeof o!="string"||!I(o))throw new Error("shell.exec script requires powershell.exe or pwsh.exe as the command.");const c=e.args;if(c!==void 0&&(!Array.isArray(c)||c.length>0||c.some(u=>typeof u!="string")))throw new Error("shell.exec script cannot be combined with args.");const d=_(o,n),i={...e};return delete i.script,{...i,command:d.command,args:[...d.args]}}function _(e,r){return{command:e,args:["-NoProfile","-NonInteractive","-Command",r],windowsVerbatimArguments:!1}}function I(e){const r=e.replace(/^.*[\\/]/u,"").toLowerCase();return r==="powershell"||r==="powershell.exe"||r==="pwsh"||r==="pwsh.exe"}function O(e,r,t,n={}){const o=M(e,r,t);return B(o.command,[...o.args],{...n,shell:!1,windowsHide:!0,...o.windowsVerbatimArguments?{windowsVerbatimArguments:!0}:{}})}function X(e,r,t,n={}){if(n.signal?.aborted)return Promise.reject(new Error("Process cancelled."));const o=n.maxBufferBytes??v,c=n.timeoutMs??A.internalProcessTimeoutMs;return new Promise((d,i)=>{const u=O(e,r,t,{...n.cwd===void 0?{}:{cwd:n.cwd},env:n.env??L(t),detached:t.supportsProcessGroups,stdio:["ignore","pipe","pipe"]}),x=[],p=[];let w=0,a=!1,l=!1,b=!1,S=!1,h;const m=()=>{h!==void 0&&clearTimeout(h),n.signal?.removeEventListener("abort",g)},g=()=>{S=!0,E(new Error("Process cancelled."))},E=s=>{l||a||(l=!0,T(u,t).then(()=>{a||(a=!0,m(),i(s))},f=>{a||(a=!0,m(),i(new AggregateError([s,f],`${s.message} Termination could not be confirmed.`)))}))},C=(s,f)=>{if(!(a||l)){if(w+=f.byteLength,w>o){E(new Error("Process output exceeded the configured limit."));return}s.push(f)}};u.stdout?.on("data",s=>C(x,s)),u.stderr?.on("data",s=>C(p,s)),u.once("error",s=>{a||l||(a=!0,m(),i(s))}),u.once("close",s=>{a||(a=!0,m(),S?i(new Error("Process cancelled.")):b?i(new Error(`Process timed out after ${c}ms.`)):w>o?i(new Error("Process output exceeded the configured limit.")):s===0||n.rejectOnNonZero===!1?d({stdout:Buffer.concat(x).toString("utf8"),stderr:Buffer.concat(p).toString("utf8"),exitCode:s}):i(new Error(Buffer.concat(p).toString("utf8").trim()||`Process exited with code ${String(s)}.`)))}),h=setTimeout(()=>{b=!0,E(new Error(`Process timed out after ${c}ms.`))},c),n.signal?.aborted===!0?g():n.signal?.addEventListener("abort",g,{once:!0})})}function L(e){const r=Object.fromEntries(Object.entries(e.env).filter(t=>t[1]!==void 0));if(e.isWindows){const t=r.Path??r.PATH;t!==void 0&&(delete r.Path,delete r.PATH,r.Path=t)}return r}function M(e,r,t){if(!t.isWindows||W.test(e))return{command:e,args:r,windowsVerbatimArguments:!1};const n=$.win32.normalize(e),o=y.test(n),c=N(n),d=r.map(i=>D(i,o));return{command:t.env.ComSpec??t.env.COMSPEC??"cmd.exe",args:["/d","/s","/c",`"${[c,...d].join(" ")}"`],windowsVerbatimArguments:!0}}function N(e){return e.replace(P,"^$1")}function D(e,r){let t=e.replace(/(?=(\\+?)?)\1"/gu,'$1$1\\"').replace(/(?=(\\+?)?)\1$/gu,"$1$1");return t=`"${t}"`.replace(P,"^$1"),r?t.replace(P,"^$1"):t}export{L as createSafeChildEnvironment,X as execPlatformCommand,I as isPowerShellExecutable,F as normalizePowerShellScriptInput,M as preparePlatformCommand,_ as preparePowerShellScript,O as spawnPlatformProcess,Y as terminatePlatformProcess};
@@ -0,0 +1,4 @@
1
+ export declare const DEFAULT_EXEC_BUFFER_BYTES: number;
2
+ export declare const WINDOWS_META_CHARS: RegExp;
3
+ export declare const WINDOWS_DIRECT_EXECUTABLE: RegExp;
4
+ export declare const WINDOWS_CMD_SHIM: RegExp;
@@ -0,0 +1 @@
1
+ const o=2097152,E=/([()\][%!^"`<>&|;, *?])/gu,_=/\.(?:com|exe)$/iu,e=/node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/iu;export{o as DEFAULT_EXEC_BUFFER_BYTES,e as WINDOWS_CMD_SHIM,_ as WINDOWS_DIRECT_EXECUTABLE,E as WINDOWS_META_CHARS};
@@ -0,0 +1,25 @@
1
+ import { type HostPlatformContext } from './host-platform.js';
2
+ export interface PlatformPaths {
3
+ platform: HostPlatformContext;
4
+ home: string;
5
+ globalConfigDir: string;
6
+ globalConfigFile: string;
7
+ credentialsFile: string;
8
+ credentialKeyFile: string;
9
+ projectsDir: string;
10
+ cacheDir: string;
11
+ logsDir: string;
12
+ skillsDir: string;
13
+ pluginsDir: string;
14
+ mcpConfigFile: string;
15
+ }
16
+ export declare function resolvePlatformPaths(env?: Readonly<Record<string, string | undefined>>, platform?: HostPlatformContext): PlatformPaths;
17
+ export declare function resolveProjectConfigPaths(cwd: string): {
18
+ directory: string;
19
+ settings: string;
20
+ localSettings: string;
21
+ skillsDir: string;
22
+ pluginsDir: string;
23
+ hooksDir: string;
24
+ mcpConfigFile: string;
25
+ };
@@ -0,0 +1 @@
1
+ import e from"node:os";import o from"node:path";import{detectHostPlatform as r}from"./host-platform.js";function g(s=process.env,n=r({env:s})){const t=s.LOTAGATE_HOME?.trim()||e.homedir(),i=o.join(t,".lotagate");return{platform:n,home:t,globalConfigDir:i,globalConfigFile:o.join(i,"settings.json"),credentialsFile:o.join(i,"credentials.enc.json"),credentialKeyFile:o.join(i,"credentials.key"),projectsDir:o.join(i,"projects"),cacheDir:o.join(i,"cache"),logsDir:o.join(i,"logs"),skillsDir:o.join(i,"skills"),pluginsDir:o.join(i,"plugins"),mcpConfigFile:o.join(i,"mcp.json")}}function a(s){const n=o.join(s,".lotagate");return{directory:n,settings:o.join(n,"settings.json"),localSettings:o.join(n,"settings.local.json"),skillsDir:o.join(n,"skills"),pluginsDir:o.join(n,"plugins"),hooksDir:o.join(n,"hooks"),mcpConfigFile:o.join(n,"mcp.json")}}export{g as resolvePlatformPaths,a as resolveProjectConfigPaths};
@@ -0,0 +1,8 @@
1
+ /** Returns a stable-enough epoch timestamp for the current Node process. */
2
+ export declare function currentProcessStartTimeMs(): number;
3
+ /**
4
+ * Reads another process' creation time where the host exposes a safe native
5
+ * query. Unknown platforms deliberately return undefined so lock recovery can
6
+ * fail closed and retain a lock when liveness cannot be verified.
7
+ */
8
+ export declare function readProcessStartTimeMs(pid: number): Promise<number | undefined>;
@@ -0,0 +1 @@
1
+ import{execFile as i}from"node:child_process";import{promisify as n}from"node:util";const s=n(i);function c(){return Math.floor(Date.now()-process.uptime()*1e3)}async function f(e){if(!(!Number.isSafeInteger(e)||e<1)){if(e===process.pid)return c();if(process.platform==="win32")try{const t=`$process = Get-Process -Id ${e} -ErrorAction Stop; ([DateTimeOffset]$process.StartTime.ToUniversalTime()).ToUnixTimeMilliseconds()`,o=await s("powershell.exe",["-NoLogo","-NoProfile","-NonInteractive","-Command",t],{windowsHide:!0,timeout:1e3,maxBuffer:4*1024}),r=Number(o.stdout.trim());return Number.isFinite(r)?r:void 0}catch{return}}}export{c as currentProcessStartTimeMs,f as readProcessStartTimeMs};
@@ -0,0 +1,4 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ import type { HostPlatformContext } from './host-platform.js';
3
+ /** Requests termination, escalates, and observes close within a bounded deadline. */
4
+ export declare function terminatePlatformProcess(child: ChildProcess, platform: HostPlatformContext): Promise<void>;
@@ -0,0 +1 @@
1
+ import{spawn as T}from"node:child_process";import{RESOURCE_LIMITS as p}from"../../domain/runtime/resource-limits.js";const d=new WeakMap;function k(e,s){const u=d.get(e);if(u!==void 0)return u;if(e.pid===void 0||e.exitCode!==null||e.signalCode!==null)return Promise.resolve();const a=new Promise((f,l)=>{let t,r;const i=()=>{if(clearTimeout(g),t!==void 0&&clearTimeout(t),e.removeListener("close",c),e.removeListener("error",m),r!==void 0&&r.exitCode===null&&r.signalCode===null)try{r.kill()}catch{}},c=()=>{i(),f()},m=n=>{i(),l(n)},o=n=>{if(s.supportsProcessGroups)try{process.kill(-e.pid,n?"SIGKILL":"SIGTERM");return}catch{}try{e.kill(n?"SIGKILL":"SIGTERM")}catch{}},g=setTimeout(()=>{o(!0),i(),l(new Error(`Process ${String(e.pid)} did not close after forced termination.`))},p.processTerminationTimeoutMs);e.once("close",c),e.once("error",m),s.isWindows?(r=T("taskkill",["/pid",String(e.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}),r.once("error",()=>o(!0)),r.once("exit",n=>{n!==0&&o(!0)})):(o(!1),t=setTimeout(()=>o(!0),p.processTerminationGraceMs))});return d.set(e,a),a}export{k as terminatePlatformProcess};
@@ -0,0 +1,4 @@
1
+ import type { HostPlatformContext } from './host-platform.js';
2
+ /** Resolves user-installed host binaries from PATH, never from the workspace. */
3
+ export declare function resolveReadOnlyExecutable(command: string, root: string, platform?: HostPlatformContext): Promise<string | undefined>;
4
+ export declare function readOnlyArguments(command: string, args: readonly string[]): string[];
@@ -0,0 +1 @@
1
+ import l from"node:fs/promises";import{constants as p}from"node:fs";import t from"node:path";async function b(n,e,i){if(/[\\/:]/u.test(n)||/\.(?:cmd|bat|ps1)$/iu.test(n))return;if(i?.isWindows===!1)return n;let o;try{o=await l.realpath(e)}catch{return}const r=process.platform==="win32"&&!/\.(?:exe|com)$/iu.test(n)?[".exe",".com"]:[""];for(const s of(process.env.PATH??process.env.Path??"").split(t.delimiter))if(t.isAbsolute(s))for(const u of r){const d=t.join(s,`${n}${u}`),c=t.relative(o,d);if(!(c===""||!c.startsWith(`..${t.sep}`)&&c!==".."&&!t.isAbsolute(c)))try{const a=await l.realpath(d),f=t.relative(o,a);if(f===""||!f.startsWith(`..${t.sep}`)&&f!==".."&&!t.isAbsolute(f)||!(await l.stat(a)).isFile())continue;return await l.access(a,process.platform==="win32"?p.F_OK:p.X_OK),a}catch{}}}function w(n,e){if(n.toLowerCase().replace(/\.exe$/u,"")!=="git")return[...e];const i=e.findIndex(u=>!u.startsWith("-")),o=i<0?void 0:e[i],r=["--no-pager","--no-optional-locks","-c","core.fsmonitor=false"],s=["diff","log","show"].includes(o??"")?["--no-ext-diff","--no-textconv"]:[];return i<0||s.length===0?[...r,...e]:[...r,...e.slice(0,i+1),...s,...e.slice(i+1)]}export{w as readOnlyArguments,b as resolveReadOnlyExecutable};
@@ -0,0 +1,12 @@
1
+ import type { ProjectTrustStore, TrustedProject } from '../../ports/project-trust-store.js';
2
+ import type { PlatformPaths } from '../platform/platform-paths.js';
3
+ export declare class FileProjectTrustStore implements ProjectTrustStore {
4
+ private readonly filePath;
5
+ constructor(paths: PlatformPaths);
6
+ list(): Promise<readonly TrustedProject[]>;
7
+ get(fingerprint: string): Promise<TrustedProject | undefined>;
8
+ grant(project: TrustedProject): Promise<void>;
9
+ revoke(fingerprint: string): Promise<boolean>;
10
+ private read;
11
+ private write;
12
+ }
@@ -0,0 +1,2 @@
1
+ import a from"node:fs/promises";import n from"node:path";import{isFileNotFound as c}from"../filesystem/fs-errors.js";import{atomicWriteFile as f,withFileLock as o}from"../filesystem/atomic-file-store.js";import{readJsonFileBounded as l}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as h}from"../../domain/runtime/resource-limits.js";class g{filePath;constructor(t){this.filePath=n.join(t.globalConfigDir,"trusted-projects.json")}async list(){return(await this.read()).projects}async get(t){return(await this.read()).projects.find(r=>r.fingerprint===t)}async grant(t){await o(this.filePath,async()=>{const i=(await this.read()).projects.filter(s=>s.fingerprint!==t.fingerprint);i.push(t),await this.write({version:1,projects:i})})}async revoke(t){return o(this.filePath,async()=>{const r=await this.read(),i=r.projects.filter(s=>s.fingerprint!==t);return i.length===r.projects.length?!1:(await this.write({version:1,projects:i}),!0)})}async read(){try{const t=await l(this.filePath,h.configFileBytes);if(!p(t))throw new Error("Invalid trust file.");return t}catch(t){if(c(t))return{version:1,projects:[]};throw t}}async write(t){await a.mkdir(n.dirname(this.filePath),{recursive:!0}),await f(this.filePath,`${JSON.stringify(t,null,2)}
2
+ `)}}function p(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version===1&&Array.isArray(t.projects)}export{g as FileProjectTrustStore};
@@ -0,0 +1,8 @@
1
+ import { type LotaGate } from '@lotagate/sdk';
2
+ import type { ChatModelPort, ChatModelRequest, ChatModelEvent } from '../../ports/chat-model.js';
3
+ export declare class SdkChatCompletionAdapter implements ChatModelPort {
4
+ private readonly client;
5
+ constructor(client: LotaGate);
6
+ stream(request: ChatModelRequest): AsyncIterable<ChatModelEvent>;
7
+ private fallbackToBufferedCompletion;
8
+ }
@@ -0,0 +1 @@
1
+ import{SdkErrorCode as m}from"@lotagate/sdk";import{CliError as l}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as c}from"../../domain/errors/error-codes.js";import{buildUserMessage as p}from"../clipboard/image-normalizer.js";import{retryModelStream as y}from"../../application/model/model-response-retry.js";class w{client;constructor(e){this.client=e}async*stream(e){const n=[p(e.prompt,e.attachments)],i=e.signal===void 0?void 0:{signal:e.signal};let o=!1;try{yield{type:"activity",state:"connecting"};const a=y({create:async()=>await this.client.chat.completions.create({model:e.model,messages:n,...e.reasoningEffort===void 0?{}:{reasoning_effort:e.reasoningEffort},stream:!0},i),isObservable:r=>typeof r.choices[0]?.delta.content=="string"&&r.choices[0].delta.content.length>0,...e.signal===void 0?{}:{signal:e.signal}});yield{type:"activity",state:"thinking"};for await(const r of a){r.usage!==void 0&&(yield{type:"usage",usage:f(r.usage)});const s=r.choices[0]?.delta.content;typeof s=="string"&&s.length>0&&(o=!0,yield{type:"activity",state:"writing"},yield{type:"delta",content:s})}yield{type:"activity",state:"completed"},yield{type:"completed"}}catch(a){if(e.signal?.aborted===!0)throw e.signal.reason??d();if(!o&&g(a)){yield*this.fallbackToBufferedCompletion(e,n,i);return}throw new l(c.MODEL_STREAM_FAILED,"Chat completion stream failed.",{category:"model",userMessage:"Unable to read the model stream. The gateway may have returned an invalid SSE payload. Check the model, authentication and base URL.",retryable:!0,cause:a})}}async*fallbackToBufferedCompletion(e,n,i){try{const o=await this.client.chat.completions.create({model:e.model,messages:[...n],...e.reasoningEffort===void 0?{}:{reasoning_effort:e.reasoningEffort},stream:!1},i);o.usage!==void 0&&(yield{type:"usage",usage:f(o.usage)});const a=h(o.choices[0]?.message.content);a.length>0&&(yield{type:"activity",state:"writing"},yield{type:"delta",content:a}),yield{type:"activity",state:"completed"},yield{type:"completed"}}catch(o){throw e.signal?.aborted===!0?e.signal.reason??d():new l(c.MODEL_STREAM_FAILED,"Chat completion fallback failed.",{category:"model",userMessage:"Unable to read the model response. Check the model, authentication and base URL.",retryable:!0,cause:o})}}}function d(){const t=new Error("The operation was aborted.");return t.name="AbortError",t}function f(t){return{...typeof t.prompt_tokens=="number"?{promptTokens:t.prompt_tokens}:{},...typeof t.completion_tokens=="number"?{completionTokens:t.completion_tokens}:{},...typeof t.total_tokens=="number"?{totalTokens:t.total_tokens}:{}}}function g(t){return typeof t=="object"&&t!==null&&"errorCode"in t&&t.errorCode===m.ResponseParseError}function h(t){return typeof t=="string"?t:Array.isArray(t)?t.map(e=>{if(typeof e!="object"||e===null||!("text"in e))return"";const n=e.text;return typeof n=="string"?n:""}).join(""):""}export{w as SdkChatCompletionAdapter};
@@ -0,0 +1,3 @@
1
+ import { LotaGate } from '@lotagate/sdk';
2
+ import type { AuthProfile } from '../../domain/auth/auth-profile.js';
3
+ export declare function createLotaGateClient(profile: AuthProfile, apiKey: string): LotaGate;
@@ -0,0 +1 @@
1
+ import{LotaGate as a}from"@lotagate/sdk";function o(e,t){return new a({apiKey:t,baseURL:e.baseUrl})}export{o as createLotaGateClient};
@@ -0,0 +1,19 @@
1
+ import type { ModelListResponse, ModelSummary } from '@lotagate/sdk';
2
+ export interface ModelCatalogClient {
3
+ models: {
4
+ list(): Promise<ModelListResponse>;
5
+ retrieve(model: string): Promise<ModelSummary>;
6
+ };
7
+ }
8
+ export declare class ModelCatalogAdapter {
9
+ private readonly client;
10
+ constructor(client: ModelCatalogClient);
11
+ /** Lists every selectable gateway model while excluding embeddings from interactive selection. */
12
+ listModels(): Promise<{
13
+ data: ModelSummary[];
14
+ object: "list" | string;
15
+ }>;
16
+ get(model: string): Promise<ModelSummary>;
17
+ }
18
+ /** Reads the optional gateway metadata without coupling the CLI to SDK internals. */
19
+ export declare function getModelContextWindow(model: ModelSummary): number | undefined;
@@ -0,0 +1 @@
1
+ class r{client;constructor(e){this.client=e}async listModels(){const e=await this.client.models.list();return{...e,data:e.data.filter(t=>t.model_category!=="embedding")}}async get(e){return this.client.models.retrieve(e)}}function i(n){const e=n.context_window;if(typeof e=="number"&&Number.isInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d+$/u.test(e)){const t=Number(e);return Number.isSafeInteger(t)&&t>0?t:void 0}}export{r as ModelCatalogAdapter,i as getModelContextWindow};
@@ -0,0 +1,24 @@
1
+ import type { LotaGate } from '@lotagate/sdk';
2
+ import type { AudioSpeechStreamEvent } from '@lotagate/sdk';
3
+ import type { MediaGatewayClient, AudioUploadInput, ImageEditInput, ImageGenerationInput, MediaRequestOptions, SpeechInput } from '../../ports/media-gateway-client.js';
4
+ import type { GeneratedImage, MediaBinary, VideoOperation } from '../../domain/media/media-contract.js';
5
+ /** SDK boundary adapter. Application code only sees CLI-owned media contracts. */
6
+ export declare class SdkMediaGatewayClient implements MediaGatewayClient {
7
+ private readonly client;
8
+ constructor(client: LotaGate);
9
+ generateImage(input: ImageGenerationInput, options?: MediaRequestOptions): Promise<readonly GeneratedImage[]>;
10
+ editImage(input: ImageEditInput, options?: MediaRequestOptions): Promise<readonly GeneratedImage[]>;
11
+ createSpeech(input: SpeechInput, options?: MediaRequestOptions): Promise<MediaBinary>;
12
+ createSpeechStream(input: SpeechInput & {
13
+ readonly streamFormat: 'sse';
14
+ }, options?: MediaRequestOptions): AsyncIterable<AudioSpeechStreamEvent>;
15
+ transcribe(input: AudioUploadInput, options?: MediaRequestOptions): Promise<string>;
16
+ translate(input: AudioUploadInput, options?: MediaRequestOptions): Promise<string>;
17
+ createVideo(input: {
18
+ model: string;
19
+ prompt: string;
20
+ parameters?: Record<string, unknown>;
21
+ }, options?: MediaRequestOptions): Promise<VideoOperation>;
22
+ getVideoOperation(id: string, options?: MediaRequestOptions): Promise<VideoOperation>;
23
+ downloadVideo(id: string, options?: MediaRequestOptions): Promise<MediaBinary>;
24
+ }
@@ -0,0 +1 @@
1
+ class f{client;constructor(e){this.client=e}async generateImage(e,s){return(await this.client.images.generations.create(a(e),s)).data.map(t=>({...typeof t.b64_json=="string"?{base64:t.b64_json}:{},...typeof t.url=="string"?{url:t.url}:{},...typeof t.revised_prompt=="string"?{revisedPrompt:t.revised_prompt}:{}}))}async editImage(e,s){const o={...a(e),image:e.images,...e.mask===void 0?{}:{mask:e.mask},...e.inputFidelity===void 0?{}:{input_fidelity:e.inputFidelity}};return(await this.client.images.edits.create(o,s)).data.map(n=>({...typeof n.b64_json=="string"?{base64:n.b64_json}:{},...typeof n.url=="string"?{url:n.url}:{},...typeof n.revised_prompt=="string"?{revisedPrompt:n.revised_prompt}:{}}))}async createSpeech(e,s){if(e.streamFormat==="sse")throw new Error("Use createSpeechStream for SSE speech responses.");const o=e.streamFormat??"audio",t=await this.client.audio.speech.create({model:e.model,input:e.input,voice:e.voice,...e.instructions===void 0?{}:{instructions:e.instructions},...e.responseFormat===void 0?{}:{response_format:e.responseFormat},...e.speed===void 0?{}:{speed:e.speed},stream_format:o},s);return d(t)}createSpeechStream(e,s){return this.client.audio.speech.create({model:e.model,input:e.input,voice:e.voice,...e.instructions===void 0?{}:{instructions:e.instructions},...e.responseFormat===void 0?{}:{response_format:e.responseFormat},...e.speed===void 0?{}:{speed:e.speed},stream_format:"sse"},s)}async transcribe(e,s){return(await this.client.audio.transcriptions.create(m(e),s)).text}async translate(e,s){return(await this.client.audio.translations.create(c(e),s)).text}async createVideo(e,s){const o={model:e.model,instances:[{prompt:e.prompt}],...e.parameters===void 0?{}:{parameters:e.parameters}};return i(await this.client.video.generations.create(o,s))}async getVideoOperation(e,s){return i(await this.client.video.operations.retrieve(e,s))}async downloadVideo(e,s){return d(await this.client.video.operations.download(e,s))}}function a(r){return{model:r.model,prompt:r.prompt,...r.n===void 0?{}:{n:r.n},...r.size===void 0?{}:{size:r.size},...r.quality===void 0?{}:{quality:r.quality},...r.background===void 0?{}:{background:r.background},...r.outputFormat===void 0?{}:{output_format:r.outputFormat},...r.outputCompression===void 0?{}:{output_compression:r.outputCompression},...r.moderation===void 0?{}:{moderation:r.moderation},...r.user===void 0?{}:{user:r.user}}}function m(r){const e={model:r.model,file:r.file,filename:r.filename};return r.prompt!==void 0&&(e.prompt=r.prompt),r.temperature!==void 0&&(e.temperature=r.temperature),r.responseFormat!==void 0&&(e.response_format=r.responseFormat),r.language!==void 0&&(e.language=r.language),r.timestampGranularities!==void 0&&(e.timestamp_granularities=[...r.timestampGranularities]),r.include!==void 0&&(e.include=[...r.include]),e}function c(r){const e={model:r.model,file:r.file,filename:r.filename};return r.prompt!==void 0&&(e.prompt=r.prompt),r.temperature!==void 0&&(e.temperature=r.temperature),r.responseFormat!==void 0&&(e.response_format=r.responseFormat),e}function d(r){const e=r.headers.get("content-type")?.split(";",1)[0]?.trim();return{bytes:new Uint8Array(r.data),...e===void 0||e.length===0?{}:{contentType:e}}}function i(r){return{id:r.name,done:r.done===!0,...typeof r.error?.message=="string"?{errorMessage:r.error.message}:{}}}export{f as SdkMediaGatewayClient};
@@ -0,0 +1,21 @@
1
+ import { type CreateGoalInput, type GoalEvaluation, type GoalState, type GoalUsageDelta } from '../../domain/orchestration/goal.js';
2
+ import type { GoalStore } from '../../ports/goal-store.js';
3
+ import type { SessionStore } from '../../ports/session-store.js';
4
+ export declare class FileGoalStore implements GoalStore {
5
+ private readonly sessions;
6
+ constructor(sessions: SessionStore);
7
+ get(sessionId: string): Promise<GoalState | undefined>;
8
+ create(sessionId: string, input: CreateGoalInput): Promise<GoalState>;
9
+ replace(sessionId: string, input: CreateGoalInput): Promise<GoalState>;
10
+ pause(sessionId: string, reason?: string): Promise<GoalState>;
11
+ resume(sessionId: string): Promise<GoalState>;
12
+ recordTurn(sessionId: string): Promise<GoalState>;
13
+ recordUsage(sessionId: string, delta: GoalUsageDelta): Promise<GoalState>;
14
+ recordEvaluation(sessionId: string, evaluation: GoalEvaluation): Promise<GoalState>;
15
+ clear(sessionId: string, reason?: string): Promise<void>;
16
+ private requireActiveUnlocked;
17
+ private getOrThrowUnlocked;
18
+ private invalidState;
19
+ private appendState;
20
+ private append;
21
+ }
@@ -0,0 +1 @@
1
+ import v from"node:crypto";import{CliError as l}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as p}from"../../domain/errors/error-codes.js";import{RESOURCE_LIMITS as i}from"../../domain/runtime/resource-limits.js";import{addGoalUsage as w,EMPTY_GOAL_USAGE as m,isGoalEvaluation as h,isGoalEventType as y,isGoalState as E,validateGoalInput as g}from"../../domain/orchestration/goal.js";class T{sessions;constructor(t){this.sessions=t}async get(t){return c(await this.sessions.readEvents(t))}async create(t,e){return this.sessions.withLock(t,async()=>{const s=g(e),n=c(await this.sessions.readEvents(t));return n?.status==="active"||n?.status==="paused"?this.appendState(n,s,"goal.replaced"):this.appendState(void 0,s,"goal.created",t)})}async replace(t,e){return this.sessions.withLock(t,async()=>this.appendState(void 0,g(e),"goal.replaced",t))}async pause(t,e="Paused by user."){return this.sessions.withLock(t,async()=>{const n={...await this.requireActiveUnlocked(t),status:"paused",updatedAt:r(),lastError:o(e,i.goalReasonBytes)};return await this.append(n,"goal.paused",{reason:n.lastError},!0),n})}async resume(t){return this.sessions.withLock(t,async()=>{const e=await this.getOrThrowUnlocked(t);if(e.status!=="paused")throw this.invalidState(`Goal cannot be resumed from ${e.status}.`);const s=r(),n=f({...e,status:"active",startedAt:s,updatedAt:s});return await this.append(n,"goal.resumed",{},!0),n})}async recordTurn(t){return this.sessions.withLock(t,async()=>{const e=await this.requireActiveUnlocked(t),s={...e,turns:e.turns+1,updatedAt:r()};return await this.append(s,"goal.turn.started",{},!0),s})}async recordUsage(t,e){return this.sessions.withLock(t,async()=>{const s=await this.requireActiveUnlocked(t),n={...s,usage:w(s.usage,e),updatedAt:r()};return await this.append(n,"goal.usage_recorded",{},!0),n})}async recordEvaluation(t,e){return this.sessions.withLock(t,async()=>{const s=await this.requireActiveUnlocked(t);if(!h(e))throw this.invalidState("Goal evaluation is invalid.");const n=k(e.decision),u=S(e),d=f({...s,status:n,evaluatorRuns:s.evaluatorRuns+1,updatedAt:r(),lastEvaluation:u});return await this.append(d,n==="active"?"goal.evaluated":`goal.${n}`,{evaluation:u},!0),d})}async clear(t,e="Cleared by user."){await this.sessions.withLock(t,async()=>{const s=c(await this.sessions.readEvents(t));s!==void 0&&await this.append(s,"goal.cleared",{reason:o(e,i.goalReasonBytes)},!0)})}async requireActiveUnlocked(t){const e=await this.getOrThrowUnlocked(t);if(e.status!=="active")throw this.invalidState(`Goal is not active: ${e.status}.`);return e}async getOrThrowUnlocked(t){const e=c(await this.sessions.readEvents(t));if(e===void 0)throw new l(p.GOAL_NOT_FOUND,`Goal not found for session: ${t}`,{category:"goal",userMessage:"No goal is configured for this session."});return e}invalidState(t){return new l(p.GOAL_INVALID_STATE,t,{category:"goal",userMessage:t})}async appendState(t,e,s,n){const u=t?.sessionId??n;if(u===void 0)throw this.invalidState("A session id is required to create a goal.");const d=A(u,e);return await this.append(d,s,{},!0),d}async append(t,e,s,n){await this.sessions.appendEvent({type:e,timestamp:r(),sessionId:t.sessionId,data:{goal:G(t),...s}},{locked:n})}}function A(a,t){const e=r();return{id:v.randomUUID(),sessionId:a,objective:t.objective,status:"active",createdAt:e,updatedAt:e,startedAt:e,turns:0,evaluatorRuns:0,usage:{...m},...t.tokenBudget===void 0?{}:{tokenBudget:t.tokenBudget},...t.maxTurns===void 0?{}:{maxTurns:t.maxTurns},...t.maxDurationMs===void 0?{}:{maxDurationMs:t.maxDurationMs}}}function c(a){let t;for(const e of a){if(!y(e.type))continue;if(e.type==="goal.cleared"){t=void 0;continue}const s=e.data?.goal;E(s)&&(t=s,e.type==="goal.evaluated"&&e.data?.evaluation!==void 0&&h(e.data.evaluation)&&(t={...t,lastEvaluation:e.data.evaluation}))}return t}function k(a){return a==="complete"?"completed":a==="blocked"?"blocked":a==="budget_limited"?"budget_limited":a==="usage_limited"?"usage_limited":"active"}function S(a){return{decision:a.decision,reason:o(a.reason,i.goalReasonBytes),evidence:a.evidence.slice(0,i.goalEvidenceItems).map(t=>o(t,i.goalEvidenceBytes)),timestamp:a.timestamp,...a.evaluatorModel===void 0?{}:{evaluatorModel:o(a.evaluatorModel,256)}}}function G(a){return{...a,objective:o(a.objective,i.goalObjectiveBytes)}}function o(a,t){return a.length<=t?a:`${a.slice(0,t-3)}...`}function r(){return new Date().toISOString()}function f(a){return delete a.lastError,a}export{T as FileGoalStore};
@@ -0,0 +1,50 @@
1
+ import type { SessionEvent, SessionMetadata, TranscriptEntry } from '../../domain/session/session.js';
2
+ import type { Attachment } from '../../domain/session/attachment.js';
3
+ import type { SessionStore, SessionBundle, SessionHistory, SessionJournalAppend, SessionRepairResult } from '../../ports/session-store.js';
4
+ import type { PlatformPaths } from '../platform/platform-paths.js';
5
+ export declare class FileSessionStore implements SessionStore {
6
+ private readonly paths;
7
+ private readonly journalHealth;
8
+ constructor(paths: PlatformPaths);
9
+ create(input: Omit<SessionMetadata, 'id' | 'createdAt' | 'updatedAt'>): Promise<SessionMetadata>;
10
+ get(sessionId: string): Promise<SessionMetadata | undefined>;
11
+ list(projectFingerprint?: string): Promise<readonly SessionMetadata[]>;
12
+ updateStatus(sessionId: string, status: SessionMetadata['status']): Promise<SessionMetadata>;
13
+ rename(sessionId: string, name: string): Promise<SessionMetadata>;
14
+ appendEvent(event: SessionEvent, options?: {
15
+ locked?: boolean;
16
+ }): Promise<void>;
17
+ appendTranscript(sessionId: string, entry: TranscriptEntry): Promise<void>;
18
+ appendJournal(sessionId: string, records: readonly SessionJournalAppend[]): Promise<void>;
19
+ readEvents(sessionId: string): Promise<readonly SessionEvent[]>;
20
+ readTranscript(sessionId: string): Promise<readonly TranscriptEntry[]>;
21
+ readHistory(sessionId: string): Promise<SessionHistory>;
22
+ delete(sessionId: string): Promise<boolean>;
23
+ fork(sessionId: string, overrides?: Partial<Pick<SessionMetadata, 'model' | 'profile'>>): Promise<SessionMetadata>;
24
+ compact(sessionId: string, summary: string, options?: {
25
+ turnId?: string;
26
+ }): Promise<void>;
27
+ export(sessionId: string): Promise<SessionBundle>;
28
+ import(bundle: SessionBundle, projectFingerprint: string, cwd: string): Promise<SessionMetadata>;
29
+ saveAttachment(sessionId: string, attachment: Attachment, bytes: Uint8Array): Promise<Attachment>;
30
+ private persistAttachment;
31
+ readAttachment(sessionId: string, attachmentId: string): Promise<Uint8Array | undefined>;
32
+ deleteAttachment(sessionId: string, attachmentId: string): Promise<boolean>;
33
+ recoverStaleLock(sessionId: string): Promise<boolean>;
34
+ repair(sessionId: string): Promise<SessionRepairResult>;
35
+ withLock<T>(sessionId: string, action: () => Promise<T>): Promise<T>;
36
+ private require;
37
+ private requirePaths;
38
+ private locate;
39
+ private locateByScan;
40
+ private projectKeys;
41
+ private readOrRebuildIndex;
42
+ private indexMatchesJournals;
43
+ private projectJournalIds;
44
+ private rebuildProjectIndex;
45
+ private readSnapshot;
46
+ private appendJournalLocked;
47
+ private readSessionJournal;
48
+ private readAttachmentMetadata;
49
+ private corrupt;
50
+ }
@@ -0,0 +1,4 @@
1
+ import J from"node:crypto";import d from"node:fs/promises";import h from"node:path";import{CliError as u}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as l}from"../../domain/errors/error-codes.js";import{isRecord as x,isSessionEvent as I,isSessionMetadata as z,isTranscriptEntry as C}from"../../domain/session/session-schema.js";import{isGoalEventType as q,isPersistedGoalEventData as H}from"../../domain/orchestration/goal.js";import{isAlreadyExists as $,isFileNotFound as w}from"../filesystem/fs-errors.js";import{acquireAdvisoryFileLock as G,atomicWriteFile as O,isAdvisoryLockContention as V,recoverStaleAdvisoryLock as U,releaseAdvisoryFileLock as K}from"../filesystem/atomic-file-store.js";import{isSafeProjectKey as L,resolveProjectSessionPaths as W,resolveProjectSessionPathsForKey as v}from"./project-session-paths.js";import{appendJournalRecord as y,appendJournalRecords as Z,eventRecord as D,journalEvents as E,journalTranscript as P,latestMetadata as M,metadataRecord as T,readJournal as N,repairJournal as Q,transcriptRecord as B}from"./session-journal.js";import{indexProjectSession as j,readProjectSessionIndex as X,readSessionLocator as Y,removeIndexedSession as tt}from"./session-index.js";import{RESOURCE_LIMITS as f}from"../../domain/runtime/resource-limits.js";import{readJsonFileBounded as et}from"../filesystem/bounded-json-reader.js";import{SessionJournalHealth as at}from"./session-journal-health.js";import{ATTACHMENT_ID_PATTERN as S,SESSION_ID_PATTERN as _,SESSION_LOCK_STALE_MS as rt}from"./session-constants.js";class kt{paths;journalHealth=new at;constructor(t){this.paths=t}async create(t){const a=new Date().toISOString(),e={...t,id:J.randomUUID(),createdAt:a,updatedAt:a},r=W(this.paths,e.cwd,e.id);return await d.mkdir(r.attachmentsDirectory,{recursive:!0}),await y(r.journalFile,T(e)),await this.journalHealth.markValid(r.journalFile),await j(this.paths,e,r.projectKey),e}async get(t){const a=await this.locate(t);if(a===void 0)return;const e=(await this.readSessionJournal(t,a)).metadata;if(e===void 0)throw this.corrupt(t,new Error("Session metadata is missing."));return e}async list(t){const a=[];for(const e of await this.projectKeys()){const r=v(this.paths,e,"00000000-0000-4000-8000-000000000000"),n=await this.readOrRebuildIndex(r.projectIndexFile,e);for(const s of Object.values(n))(t===void 0||s.projectFingerprint===t)&&a.push(s)}return a.sort((e,r)=>r.updatedAt.localeCompare(e.updatedAt))}async updateStatus(t,a){return this.withLock(t,async()=>{const r={...await this.require(t),status:a,updatedAt:new Date().toISOString()},n=await this.requirePaths(t);return await y(n.journalFile,T(r)),await this.journalHealth.markValid(n.journalFile),await j(this.paths,r,n.projectKey),r})}async rename(t,a){const e=a.trim().replace(/\s+/gu," ");if(e.length===0||e.length>120||/[\r\n]/u.test(e)||e.includes("\0"))throw new u(l.INVALID_ARGUMENT,"Session name is invalid.",{category:"session",userMessage:"Session name must be between 1 and 120 printable characters."});return this.withLock(t,async()=>{const n={...await this.require(t),name:e,updatedAt:new Date().toISOString()},s=await this.requirePaths(t);return await y(s.journalFile,T(n)),await this.journalHealth.markValid(s.journalFile),await j(this.paths,n,s.projectKey),n})}async appendEvent(t,a={}){const e=[{kind:"event",event:t}];a.locked===!0?await this.appendJournalLocked(t.sessionId,e):await this.appendJournal(t.sessionId,e)}async appendTranscript(t,a){await this.appendJournal(t,[{kind:"transcript",entry:a}])}async appendJournal(t,a){a.length!==0&&await this.withLock(t,()=>this.appendJournalLocked(t,a))}async readEvents(t){const a=await this.readSessionJournal(t);if(a.metadata===void 0)throw this.corrupt(t,new Error("Session metadata is missing."));return E(a.records)}async readTranscript(t){const a=await this.readSessionJournal(t);if(a.metadata===void 0)throw this.corrupt(t,new Error("Session metadata is missing."));return P(a.records)}async readHistory(t){return this.withLock(t,async()=>{const a=await this.readSessionJournal(t);if(a.metadata===void 0)throw this.corrupt(t,new Error("Session metadata is missing."));const e=a.records;return{events:E(e),transcript:P(e)}})}async delete(t){const a=await this.get(t);return a===void 0?!1:(await this.withLock(t,async()=>{const e=await this.requirePaths(t);await d.rm(e.journalFile,{force:!0}),await d.rm(e.sessionDirectory,{recursive:!0,force:!0}),this.journalHealth.forget(e.journalFile),await tt(this.paths,a,e.projectKey)}),!0)}async fork(t,a={}){const e=await this.readSnapshot(t),r=e.metadata,n=await this.create({projectFingerprint:r.projectFingerprint,cwd:r.cwd,model:a.model??r.model,profile:a.profile??r.profile,status:"active"});try{return await this.withLock(n.id,async()=>{const s=await this.requirePaths(n.id);for(const o of e.events){const c=nt(o.data);await y(s.journalFile,D({...o,sessionId:n.id,...c===void 0?{}:{data:c}}))}for(const o of e.transcript)await y(s.journalFile,B(o));await this.journalHealth.markValid(s.journalFile);for(const[o,c]of e.attachments)c.attachment!==void 0&&await this.persistAttachment(n.id,{...c.attachment,id:o},c.bytes)}),n}catch(s){try{await this.delete(n.id)}catch(o){throw new AggregateError([s,o],"Session fork failed and cleanup was incomplete.")}throw s}}async compact(t,a,e={}){const r=a.trim();if(r.length===0)throw new u(l.SESSION_CORRUPTED,"Compaction summary cannot be empty.",{category:"session",userMessage:"Compaction summary cannot be empty."});const n=new Date().toISOString();await this.appendJournal(t,[{kind:"transcript",entry:{type:"system",timestamp:n,content:`[Compacted context]
2
+ ${r}`,...e.turnId===void 0?{}:{turnId:e.turnId}}},{kind:"event",event:{type:"context.compacted",timestamp:n,sessionId:t,...e.turnId===void 0?{}:{turnId:e.turnId},data:{summary:r}}}])}async export(t){const a=await this.readSnapshot(t),e=[];for(const r of a.transcript)for(const n of r.attachmentIds??[]){if(e.some(c=>c.attachment.id===n))continue;const s=a.attachments.get(n);if(s===void 0)continue;const o=s.attachment??{id:n,name:n,mimeType:"application/octet-stream",sizeBytes:s.bytes.byteLength,source:"file"};e.push({attachment:o,dataBase64:Buffer.from(s.bytes).toString("base64")})}return{metadata:a.metadata,events:a.events,transcript:a.transcript,attachments:e}}async import(t,a,e){ot(t);const r=await this.create({projectFingerprint:a,cwd:e,model:t.metadata.model,profile:t.metadata.profile,status:"active"});try{for(const n of t.events){const s=st(n.data);await this.appendEvent({...n,sessionId:r.id,...s===void 0?{}:{data:s}})}for(const n of t.transcript)await this.appendTranscript(r.id,n);for(const n of t.attachments)await this.saveAttachment(r.id,n.attachment,Buffer.from(n.dataBase64,"base64"));return r}catch(n){try{await this.delete(r.id)}catch(s){throw new AggregateError([n,s],"Session import failed and cleanup was incomplete.")}throw n}}async saveAttachment(t,a,e){if(!S.test(a.id))throw new u(l.ATTACHMENT_INVALID_IMAGE,"Attachment id is invalid.",{category:"attachment",userMessage:"Attachment name is invalid."});if(a.sizeBytes<0||a.sizeBytes>f.maxAttachmentBytes)throw new u(l.ATTACHMENT_TOO_LARGE,"Attachment exceeds the allowed size.",{category:"attachment",userMessage:"Attachment exceeds the allowed size."});if(e.byteLength!==a.sizeBytes)throw new u(l.ATTACHMENT_INVALID_IMAGE,"Attachment size does not match metadata.",{category:"attachment",userMessage:"Attachment size does not match its metadata."});return this.withLock(t,()=>this.persistAttachment(t,a,e))}async persistAttachment(t,a,e){const r=await this.requirePaths(t);await this.require(t),await d.mkdir(r.attachmentsDirectory,{recursive:!0});const n=await this.readAttachmentMetadata(r,a.id),s=n?.storagePath===void 0?await it(r.attachmentsDirectory,a.storageName,a.id):h.basename(n.storagePath),o=h.join(r.attachmentsDirectory,s);await d.writeFile(o,e,{flag:"wx",mode:384}).catch(async p=>{if(!$(p))throw p;await d.writeFile(o,e,{mode:384})});const c={...a,storagePath:h.posix.join("attachments",s)};return await O(h.join(r.attachmentsDirectory,`${a.id}.json`),`${JSON.stringify(c,null,2)}
3
+ `),c}async readAttachment(t,a){const e=await this.requirePaths(t);if(await this.require(t),!S.test(a))return;const r=await this.readAttachmentMetadata(e,a),n=h.join(e.attachmentsDirectory,R(r,a));try{if((await d.stat(n)).size>f.maxAttachmentBytes)throw new u(l.ATTACHMENT_TOO_LARGE,"Stored attachment exceeds the allowed size.",{category:"attachment",userMessage:"Stored attachment exceeds the allowed size."});return await d.readFile(n)}catch(s){if(w(s))return;throw s}}async deleteAttachment(t,a){return S.test(a)?this.withLock(t,async()=>{const e=await this.requirePaths(t);await this.require(t);const r=await this.readAttachmentMetadata(e,a),n=h.join(e.attachmentsDirectory,R(r,a)),s=h.join(e.attachmentsDirectory,`${a}.json`);let o=!1;for(const c of[n,s])try{await d.unlink(c),o=!0}catch(p){if(!w(p))throw p}return o}):!1}async recoverStaleLock(t){const a=await this.locate(t);return a===void 0?!1:U(a.lockFile,rt)}async repair(t){const a=await this.requirePaths(t),e=await this.withLock(t,()=>Q(a.journalFile));return await this.journalHealth.markValid(a.journalFile),{eventsRemoved:e,transcriptRemoved:0}}async withLock(t,a){const e=await this.requirePaths(t);await d.mkdir(e.sessionDirectory,{recursive:!0});let r;try{r=await G(e.lockFile)}catch(n){const s=await V(n,e.lockFile);if(s&&await this.recoverStaleLock(t))return this.withLock(t,a);throw s?new u(l.SESSION_LOCKED,`Session is locked: ${t}`,{category:"session",userMessage:"The session is being used by another process. Try again later.",retryable:!0}):n}try{return await a()}finally{await K(r,e.lockFile)}}async require(t){const a=await this.get(t);if(a===void 0)throw new u(l.SESSION_NOT_FOUND,`Session not found: ${t}`,{category:"session",userMessage:`Session not found: ${t}.`});return a}async requirePaths(t){const a=await this.locate(t);if(a===void 0)throw new u(l.SESSION_NOT_FOUND,`Session not found: ${t}`,{category:"session",userMessage:`Session not found: ${t}.`});return a}async locate(t){if(!_.test(t))return;const e=(await Y(this.paths)).sessions[t];if(typeof e=="string"&&L(e)){const r=v(this.paths,e,t);if(await k(r.journalFile))return r}return this.locateByScan(t)}async locateByScan(t){for(const a of await this.projectKeys()){const e=v(this.paths,a,t);if(await k(e.journalFile))return e}}async projectKeys(){try{return(await d.readdir(this.paths.projectsDir,{withFileTypes:!0})).filter(t=>t.isDirectory()&&L(t.name)).map(t=>t.name)}catch(t){if(w(t))return[];throw t}}async readOrRebuildIndex(t,a){try{const e=(await X(t,a)).sessions;return await this.indexMatchesJournals(a,e)?e:this.rebuildProjectIndex(a)}catch{return this.rebuildProjectIndex(a)}}async indexMatchesJournals(t,a){const e=await this.projectJournalIds(t),r=Object.keys(a);return e.length===r.length&&e.every(n=>a[n]!==void 0)}async projectJournalIds(t){const a=h.join(this.paths.projectsDir,t);try{return(await d.readdir(a,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(".jsonl")).map(e=>e.name.slice(0,-6)).filter(e=>_.test(e))}catch(e){if(w(e))return[];throw e}}async rebuildProjectIndex(t){const a={},e=h.join(this.paths.projectsDir,t);for(const n of await d.readdir(e,{withFileTypes:!0}))if(!(!n.isFile()||!n.name.endsWith(".jsonl")))try{const s=M(await N(h.join(e,n.name)));s!==void 0&&(a[s.id]=s)}catch{}const r=h.join(e,"index.json");await d.mkdir(e,{recursive:!0}),await O(r,`${JSON.stringify({projectKey:t,sessions:a},null,2)}
4
+ `);for(const n of Object.values(a))await j(this.paths,n,t);return a}async readSnapshot(t){return this.withLock(t,async()=>{const a=await this.readSessionJournal(t),e=a.metadata;if(e===void 0)throw this.corrupt(t,new Error("Session metadata is missing."));const r=a.sessionPaths,n=a.records,s=E(n),o=P(n),c=new Map;for(const p of o)for(const g of p.attachmentIds??[]){if(c.has(g))continue;const F=await this.readAttachment(t,g);F!==void 0&&c.set(g,{bytes:F,attachment:await this.readAttachmentMetadata(r,g)})}return{metadata:e,events:s,transcript:o,attachments:c}})}async appendJournalLocked(t,a){const e=await this.requirePaths(t);try{if(!await this.journalHealth.ensureValid(e.journalFile))throw new Error("Session metadata is missing.")}catch(n){throw this.corrupt(t,n)}const r=a.map(n=>{if(n.kind==="event"&&n.event.sessionId!==t)throw new u(l.SESSION_CORRUPTED,"Cannot append an event to a different session.",{category:"session",userMessage:"Session event data is invalid."});return n.kind==="event"?D(n.event):B(n.entry)});await Z(e.journalFile,r),await this.journalHealth.markValid(e.journalFile)}async readSessionJournal(t,a){const e=a??await this.requirePaths(t);try{const r=await N(e.journalFile),n=M(r);return await this.journalHealth.markValid(e.journalFile,n!==void 0),{sessionPaths:e,records:r,metadata:n}}catch(r){throw this.corrupt(t,r)}}async readAttachmentMetadata(t,a){try{return ht(await et(h.join(t.attachmentsDirectory,`${a}.json`),f.configFileBytes))}catch(e){if(w(e))return;throw e}}corrupt(t,a){return new u(l.SESSION_CORRUPTED,`Session metadata is corrupted: ${t}`,{category:"session",userMessage:"Session is corrupted and its metadata cannot be read.",cause:a})}}function nt(i){return b(i)}function st(i){return b(i)}function b(i){if(i===void 0||typeof i.goal!="object"||i.goal===null)return i;const t=i.goal;return t.status!=="active"?i:{...i,goal:{...t,status:"paused",updatedAt:new Date().toISOString()},reason:"Explicit resume is required after fork or import."}}async function k(i){try{return await d.access(i),!0}catch(t){if(w(t))return!1;throw t}}function R(i,t){const a=i?.storagePath;if(typeof a=="string"&&a.startsWith("attachments/")){const e=h.basename(a);if(e.length>0&&e!=="."&&e!=="..")return e}return`${t}.bin`}async function it(i,t,a){if(t===void 0)return`${a}.bin`;const e=h.basename(t).replace(/[^A-Za-z0-9._-]/gu,"_").slice(0,120)||`${a}.bin`,r=h.extname(e),n=r.length===0?e:e.slice(0,-r.length);for(let s=0;s<1e4;s+=1){const o=s===0?e:`${n}-${s}${r}`;if(!await k(h.join(i,o)))return o}throw new u(l.ATTACHMENT_TOO_LARGE,"Too many attachments share the same filename.",{category:"attachment",userMessage:"Too many attachments share the same filename."})}function ot(i){if(!z(i.metadata)||!Array.isArray(i.events)||!Array.isArray(i.transcript)||!Array.isArray(i.attachments))throw m("Session export file is invalid.");if(i.events.length>f.sessionEvents||i.transcript.length>f.sessionTranscriptEntries||i.attachments.length>f.sessionAttachments)throw m("Session export exceeds the supported entry limits.");for(const e of i.events){if(!I(e))throw m("Session export contains an invalid event.");if(q(e.type)&&!H(e.data))throw m("Session export contains an invalid goal event.");if(A(e.type)>256||A(e.timestamp)>128||A(e.sessionId)>128)throw m("Session event metadata is too large.")}const t=new Set;let a=0;for(const e of i.transcript){if(!C(e)||A(e.content)>f.sessionTextBytes)throw m("Session export contains an invalid transcript entry.");if(e.attachmentIds!==void 0&&(!Array.isArray(e.attachmentIds)||e.attachmentIds.some(r=>typeof r!="string"||!S.test(r))))throw m("Session transcript contains invalid attachment references.")}for(const e of i.attachments){if(!ct(e))throw m("Session export contains an invalid attachment.");const r=e.attachment;if(typeof r.id!="string"||!S.test(r.id)||t.has(r.id)||typeof r.name!="string"||typeof r.mimeType!="string"||typeof r.sizeBytes!="number"||!Number.isSafeInteger(r.sizeBytes)||r.sizeBytes<0||r.sizeBytes>f.maxAttachmentBytes||r.source!=="clipboard"&&r.source!=="file")throw m("Session export contains invalid attachment metadata.");const n=Buffer.from(e.dataBase64,"base64");if(n.toString("base64")!==e.dataBase64||n.byteLength!==r.sizeBytes)throw m("Session export contains an invalid attachment payload.");if(a+=n.byteLength,a>f.sessionAttachmentTotalBytes)throw m("Session export exceeds the total attachment limit.");t.add(r.id)}}function ct(i){if(!x(i)||!x(i.attachment)||typeof i.dataBase64!="string")return!1;const t=i.attachment;return typeof t.id=="string"&&typeof t.name=="string"&&typeof t.mimeType=="string"&&typeof t.sizeBytes=="number"&&Number.isSafeInteger(t.sizeBytes)&&(t.source==="clipboard"||t.source==="file")}function A(i){return Buffer.byteLength(i,"utf8")}function m(i){return new u(l.SESSION_CORRUPTED,i,{category:"session",userMessage:i})}function ht(i){if(typeof i!="object"||i===null)throw new Error("Invalid attachment metadata.");const t=i;if(typeof t.id!="string"||typeof t.name!="string"||typeof t.mimeType!="string"||typeof t.sizeBytes!="number"||t.source!=="clipboard"&&t.source!=="file")throw new Error("Invalid attachment metadata.");return i}export{kt as FileSessionStore};
@@ -0,0 +1,17 @@
1
+ import type { PlatformPaths } from '../platform/platform-paths.js';
2
+ import { type HostPlatformContext } from '../platform/host-platform.js';
3
+ export interface ProjectSessionPaths {
4
+ projectKey: string;
5
+ projectDirectory: string;
6
+ projectIndexFile: string;
7
+ sessionId: string;
8
+ journalFile: string;
9
+ sessionDirectory: string;
10
+ attachmentsDirectory: string;
11
+ subagentsDirectory: string;
12
+ lockFile: string;
13
+ }
14
+ export declare function isSafeProjectKey(value: string): boolean;
15
+ export declare function createProjectKey(cwd: string, platform?: HostPlatformContext): string;
16
+ export declare function resolveProjectSessionPaths(paths: PlatformPaths, cwd: string, sessionId: string): ProjectSessionPaths;
17
+ export declare function resolveProjectSessionPathsForKey(paths: PlatformPaths, projectKey: string, sessionId: string): ProjectSessionPaths;
@@ -0,0 +1 @@
1
+ import s from"node:crypto";import r from"node:path";import{detectHostPlatform as i}from"../platform/host-platform.js";function a(o){return/^[A-Za-z0-9._-]+--[0-9a-f]{12}$/u.test(o)}function l(o,n=i()){const e=r.resolve(o),t=n.isWindows?e.toLowerCase():e,c=s.createHash("sha256").update(t,"utf8").digest("hex").slice(0,12);return`${e.replaceAll("\\","-").replaceAll("/","-").replaceAll(":","-").replace(/[^A-Za-z0-9._-]+/gu,"-").replace(/-+/gu,"-").replace(/^-|-$/gu,"").slice(0,120)||"project"}--${c}`}function h(o,n,e){const t=l(n,o.platform);return p(o,t,e)}function p(o,n,e){if(!a(n))throw new Error("Invalid project session key.");const t=r.join(o.projectsDir,n),c=r.join(t,e);return{projectKey:n,projectDirectory:t,projectIndexFile:r.join(t,"index.json"),sessionId:e,journalFile:r.join(t,`${e}.jsonl`),sessionDirectory:c,attachmentsDirectory:r.join(c,"attachments"),subagentsDirectory:r.join(c,"subagents"),lockFile:r.join(c,"lock")}}export{l as createProjectKey,a as isSafeProjectKey,h as resolveProjectSessionPaths,p as resolveProjectSessionPathsForKey};
@@ -0,0 +1,3 @@
1
+ export declare const SESSION_ID_PATTERN: RegExp;
2
+ export declare const ATTACHMENT_ID_PATTERN: RegExp;
3
+ export declare const SESSION_LOCK_STALE_MS: number;
@@ -0,0 +1 @@
1
+ const a=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,S=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,T=3e5;export{S as ATTACHMENT_ID_PATTERN,a as SESSION_ID_PATTERN,T as SESSION_LOCK_STALE_MS};
@@ -0,0 +1,16 @@
1
+ import type { SessionMetadata } from '../../domain/session/session.js';
2
+ import type { PlatformPaths } from '../platform/platform-paths.js';
3
+ interface ProjectSessionIndex {
4
+ projectKey: string;
5
+ sessions: Record<string, SessionMetadata>;
6
+ }
7
+ interface SessionLocatorIndex {
8
+ sessions: Record<string, string>;
9
+ }
10
+ export declare function readProjectSessionIndex(filePath: string, projectKey: string): Promise<ProjectSessionIndex>;
11
+ export declare function writeProjectSessionIndex(filePath: string, projectKey: string, sessions: Readonly<Record<string, SessionMetadata>>): Promise<void>;
12
+ export declare function readSessionLocator(paths: PlatformPaths): Promise<SessionLocatorIndex>;
13
+ export declare function writeSessionLocator(paths: PlatformPaths, sessions: Readonly<Record<string, string>>): Promise<void>;
14
+ export declare function indexProjectSession(paths: PlatformPaths, metadata: SessionMetadata, projectKey: string): Promise<void>;
15
+ export declare function removeIndexedSession(paths: PlatformPaths, metadata: SessionMetadata, projectKey: string): Promise<void>;
16
+ export {};
@@ -0,0 +1,3 @@
1
+ import c from"node:path";import{atomicWriteFile as p,withFileLock as a}from"../filesystem/atomic-file-store.js";import{isFileNotFound as l}from"../filesystem/fs-errors.js";import{resolveProjectSessionPathsForKey as w}from"./project-session-paths.js";import{readJsonFileBounded as x}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as d}from"../../domain/runtime/resource-limits.js";async function j(o,s){try{return m(await x(o,d.sessionIndexBytes),s)}catch(t){if(l(t))return{projectKey:s,sessions:{}};throw t}}async function y(o,s,t){const e=`${JSON.stringify({projectKey:s,sessions:t},null,2)}
2
+ `;if(Buffer.byteLength(e,"utf8")>d.sessionIndexBytes)throw new Error("The project session index exceeds the supported size limit.");await p(o,e)}async function I(o){const s=c.join(o.projectsDir,"locator.json");try{return h(await x(s,d.sessionIndexBytes))}catch(t){if(l(t))return{sessions:{}};throw t}}function m(o,s){if(!r(o)||o.projectKey!==s||!r(o.sessions))throw new Error("Invalid project session index.");for(const t of Object.values(o.sessions))if(!F(t))throw new Error("Invalid project session metadata.");return{projectKey:s,sessions:o.sessions}}function h(o){if(!r(o)||!r(o.sessions)||Object.values(o.sessions).some(s=>typeof s!="string"))throw new Error("Invalid session locator index.");return{sessions:o.sessions}}function F(o){return r(o)?typeof o.id=="string"&&typeof o.projectFingerprint=="string"&&typeof o.cwd=="string"&&(typeof o.model=="string"||o.model===null)&&(typeof o.profile=="string"||o.profile===null)&&(o.status==="active"||o.status==="completed"||o.status==="failed"||o.status==="cancelled")&&typeof o.createdAt=="string"&&typeof o.updatedAt=="string":!1}function r(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}async function u(o,s){const t=`${JSON.stringify({sessions:s},null,2)}
3
+ `;if(Buffer.byteLength(t,"utf8")>d.sessionIndexBytes)throw new Error("The session locator exceeds the supported size limit.");await p(c.join(o.projectsDir,"locator.json"),t)}async function b(o,s,t){const e=w(o,t,s.id);await a(e.projectIndexFile,async()=>{const n=await j(e.projectIndexFile,t);await y(e.projectIndexFile,t,{...n.sessions,[s.id]:s})});const f=c.join(o.projectsDir,"locator.json");await a(f,async()=>{const n=await I(o);await u(o,{...n.sessions,[s.id]:t})})}async function O(o,s,t){const e=w(o,t,s.id);await a(e.projectIndexFile,async()=>{const i={...(await j(e.projectIndexFile,t)).sessions};delete i[s.id],await y(e.projectIndexFile,t,i)});const f=c.join(o.projectsDir,"locator.json");await a(f,async()=>{const i={...(await I(o)).sessions};delete i[s.id],await u(o,i)})}export{b as indexProjectSession,j as readProjectSessionIndex,I as readSessionLocator,O as removeIndexedSession,y as writeProjectSessionIndex,u as writeSessionLocator};
@@ -0,0 +1,7 @@
1
+ /** Avoids reparsing an unchanged journal on every append while detecting external writes. */
2
+ export declare class SessionJournalHealth {
3
+ private readonly entries;
4
+ ensureValid(filePath: string): Promise<boolean>;
5
+ markValid(filePath: string, hasMetadata?: boolean): Promise<void>;
6
+ forget(filePath: string): void;
7
+ }
@@ -0,0 +1 @@
1
+ import c from"node:fs/promises";import{latestMetadata as m,readJournal as u}from"./session-journal.js";class g{entries=new Map;async ensureValid(e){const s=await n(e),a=this.entries.get(e);if(a!==void 0&&o(a.signature,s))return a.hasMetadata;const r=await u(e),i=m(r)!==void 0;return this.entries.set(e,{signature:await n(e),hasMetadata:i}),i}async markValid(e,s=!0){this.entries.set(e,{signature:await n(e),hasMetadata:s})}forget(e){this.entries.delete(e)}}async function n(t){const e=await c.stat(t);return{size:e.size,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs}}function o(t,e){return t.size===e.size&&t.mtimeMs===e.mtimeMs&&t.ctimeMs===e.ctimeMs}export{g as SessionJournalHealth};
@@ -0,0 +1,22 @@
1
+ import type { SessionEvent, SessionMetadata, TranscriptEntry } from '../../domain/session/session.js';
2
+ export type SessionJournalRecord = {
3
+ recordType: 'metadata';
4
+ metadata: SessionMetadata;
5
+ } | {
6
+ recordType: 'event';
7
+ event: SessionEvent;
8
+ } | {
9
+ recordType: 'transcript';
10
+ entry: TranscriptEntry;
11
+ };
12
+ export declare function metadataRecord(metadata: SessionMetadata): SessionJournalRecord;
13
+ export declare function eventRecord(event: SessionEvent): SessionJournalRecord;
14
+ export declare function transcriptRecord(entry: TranscriptEntry): SessionJournalRecord;
15
+ export declare function appendJournalRecord(filePath: string, record: SessionJournalRecord): Promise<void>;
16
+ /** Appends one crash-consistent physical JSONL record for an ordered logical batch. */
17
+ export declare function appendJournalRecords(filePath: string, records: readonly SessionJournalRecord[]): Promise<void>;
18
+ export declare function readJournal(filePath: string): Promise<readonly SessionJournalRecord[]>;
19
+ export declare function latestMetadata(records: readonly SessionJournalRecord[]): SessionMetadata | undefined;
20
+ export declare function journalEvents(records: readonly SessionJournalRecord[]): readonly SessionEvent[];
21
+ export declare function journalTranscript(records: readonly SessionJournalRecord[]): readonly TranscriptEntry[];
22
+ export declare function repairJournal(filePath: string): Promise<number>;
@@ -0,0 +1,6 @@
1
+ import a from"node:fs/promises";import T from"node:path";import{isFileNotFound as s}from"../filesystem/fs-errors.js";import{atomicWriteFile as g}from"../filesystem/atomic-file-store.js";import{isRecord as u,isSessionEvent as x,isSessionMetadata as J,isTranscriptEntry as v}from"../../domain/session/session-schema.js";import{RESOURCE_LIMITS as p}from"../../domain/runtime/resource-limits.js";function L(e){return{recordType:"metadata",metadata:e}}function M(e){return{recordType:"event",event:e}}function N(e){return{recordType:"transcript",entry:e}}async function O(e,r){await f(e,r)}async function A(e,r){r.length!==0&&await f(e,r.length===1?r[0]:{recordType:"batch",records:r})}async function f(e,r){await a.mkdir(T.dirname(e),{recursive:!0});const t=`${JSON.stringify(r)}
2
+ `;await E(e,Buffer.byteLength(t,"utf8")),await a.appendFile(e,t,{encoding:"utf8",mode:384})}async function U(e){let r;try{await z(e),r=await a.readFile(e,"utf8")}catch(t){if(s(t))return[];throw t}try{return l(r)}catch(t){if(!R(r))throw t;return await new Promise(o=>setImmediate(o)),l(await a.readFile(e,"utf8"))}}function l(e){return e.split(/\r?\n/u).filter(Boolean).flatMap(r=>m(JSON.parse(r)))}function R(e){const r=e.replace(/\r\n/gu,`
3
+ `);return r.length>0&&!r.endsWith(`
4
+ `)}async function z(e){if((await a.stat(e)).size>p.sessionJournalBytes)throw new Error("Session journal exceeds the supported size limit. Repair or export the session before resuming it.")}async function E(e,r){let t=0;try{t=(await a.stat(e)).size}catch(o){if(!s(o))throw o}if(t+r>p.sessionJournalBytes)throw new Error("Session journal exceeds the supported size limit. Compact or export the session before adding more data.")}function W(e){return e.filter(r=>r.recordType==="metadata").at(-1)?.metadata}function $(e){return e.filter(r=>r.recordType==="event").map(r=>r.event)}function k(e){return e.filter(r=>r.recordType==="transcript").map(r=>r.entry)}async function _(e){const r=await a.stat(e).catch(n=>{if(!s(n))throw n});if(r===void 0)return 0;if(r.size>p.sessionJournalBytes)throw new Error("Session journal exceeds the supported size limit. Repair cannot process an oversized journal.");let t;try{t=await a.readFile(e,"utf8")}catch(n){if(s(n))return 0;throw n}const o=t.split(/\r?\n/u),c=[];let d=0;for(let n=0;n<o.length;n+=1){const i=o[n]?.trim();if(!(i===void 0||i.length===0))try{m(JSON.parse(i)),c.push(i)}catch(w){if(!o.slice(n+1).every(h=>h.trim().length===0))throw w;d+=1}}return d>0&&await g(e,c.length===0?"":`${c.join(`
5
+ `)}
6
+ `),d}function m(e){if(u(e)&&e.recordType==="batch"){const r=e.records;if(!Array.isArray(r)||r.length===0)throw new Error("Invalid session journal batch.");return r.map(y)}return[y(e)]}function y(e){if(!u(e))throw new Error("Invalid session journal record.");const r=e;if(r.recordType==="metadata"&&J(r.metadata))return{recordType:"metadata",metadata:r.metadata};if(r.recordType==="event"&&x(r.event))return{recordType:"event",event:r.event};if(r.recordType==="transcript"&&v(r.entry))return{recordType:"transcript",entry:r.entry};throw new Error("Unsupported or malformed session journal record.")}export{O as appendJournalRecord,A as appendJournalRecords,M as eventRecord,$ as journalEvents,k as journalTranscript,W as latestMetadata,L as metadataRecord,U as readJournal,_ as repairJournal,N as transcriptRecord};
@@ -0,0 +1,28 @@
1
+ import type { PlatformPaths } from '../platform/platform-paths.js';
2
+ import type { SubagentResult } from '../../domain/orchestration/subagent.js';
3
+ export type SubagentJournalRecord = {
4
+ recordType: 'created';
5
+ id: string;
6
+ displayName: string;
7
+ task: string;
8
+ mode: 'research' | 'worker';
9
+ model: string;
10
+ timestamp: string;
11
+ } | {
12
+ recordType: 'started';
13
+ id: string;
14
+ displayName: string;
15
+ mode: 'research' | 'worker';
16
+ model: string;
17
+ timestamp: string;
18
+ } | {
19
+ recordType: 'completed' | 'completed_with_warning' | 'failed' | 'cancelled';
20
+ result: SubagentResult;
21
+ timestamp: string;
22
+ };
23
+ /** Persists bounded child-agent lifecycle records beside the parent session. */
24
+ export declare class SubagentJournalStore {
25
+ private readonly paths;
26
+ constructor(paths: PlatformPaths);
27
+ append(parentSessionId: string, cwd: string, record: SubagentJournalRecord): Promise<void>;
28
+ }
@@ -0,0 +1,2 @@
1
+ import s from"node:fs/promises";import a from"node:path";import{resolveProjectSessionPaths as u}from"./project-session-paths.js";class m{paths;constructor(e){this.paths=e}async append(e,r,o){c(e);const n=u(this.paths,r,e),i=a.join(n.subagentsDirectory,`${f(o)}.jsonl`);await s.mkdir(n.subagentsDirectory,{recursive:!0,mode:448}),await d(i,o)}}function c(t){if(!/^[A-Za-z0-9._-]{1,128}$/u.test(t))throw new Error("Invalid parent session id for subagent journal.")}async function d(t,e){const r=`${JSON.stringify(e)}
2
+ `;if(Buffer.byteLength(r,"utf8")>32*1024)throw new Error("Subagent journal record exceeds the configured limit.");await s.appendFile(t,r,{encoding:"utf8",mode:384})}function f(t){return t.recordType==="created"||t.recordType==="started"?t.id:t.result.id}export{m as SubagentJournalStore};
@@ -0,0 +1,21 @@
1
+ import type { ToolDefinition } from '@lotagate/sdk';
2
+ import type { ToolExecutionContext, ToolExecutor, ToolInfo, ToolResult } from '@lotagate/agent-sdk';
3
+ import type { ToolActivityObserver } from '../../ports/tool-activity.js';
4
+ import { type HostPlatformContext } from '../platform/host-platform.js';
5
+ import type { Logger } from '../../ports/logger.js';
6
+ export type ShellToolEnvironment = 'host' | 'linux-guest';
7
+ /** Exposes the same shell capability definitions to runtime and context accounting. */
8
+ export declare function shellToolDefinitions(environment?: ShellToolEnvironment): readonly ToolDefinition[];
9
+ export declare class ShellToolExecutor implements ToolExecutor {
10
+ private readonly options;
11
+ constructor(options?: {
12
+ onActivity?: ToolActivityObserver;
13
+ readOnly?: boolean;
14
+ platform?: HostPlatformContext;
15
+ logger?: Logger;
16
+ toolEnvironment?: ShellToolEnvironment;
17
+ });
18
+ listTools(): readonly ToolDefinition[];
19
+ getToolInfo(toolName: string): ToolInfo | undefined;
20
+ execute(toolName: string, input: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
21
+ }
@@ -0,0 +1,2 @@
1
+ import{resolveReadOnlyExecutable as y,readOnlyArguments as E}from"../platform/read-only-executable.js";import{resolveWorkspacePath as p}from"../filesystem/path-resolver.js";import{isReadOnlyShellRequest as b}from"../../application/security/tool-risk-classifier.js";import{detectHostPlatform as S}from"../platform/host-platform.js";import{normalizePowerShellScriptInput as T,execPlatformCommand as v}from"../platform/host-process.js";import{formatShellCommandForDisplay as P}from"../../application/agent/tool-display.js";import{withToolExecutionLogging as C}from"../observability/tool-execution-logger.js";import{RESOURCE_LIMITS as c}from"../../domain/runtime/resource-limits.js";const h=[{type:"function",function:{name:"shell.exec",description:"Execute one program with structured arguments inside the trusted workspace. Shell interpretation is disabled. When the runtime platform is Windows, prefer powershell.exe with script for operating-system work; use direct command and args for project executables. On other platforms, follow the runtime shell and executable availability. Keep the executable in command and pass arguments separately in args (for example, git status --short means command git and args [status, --short]). The script field is a complete PowerShell script, is valid only with powershell.exe or pwsh.exe, and cannot be combined with args. Inspect stdout, stderr, exit code, and the resulting state before reporting success.",parameters:{type:"object",properties:{command:{type:"string",description:"Executable name or path."},args:{type:"array",items:{type:"string"},description:"Structured process arguments."},script:{type:"string",description:"Optional complete PowerShell script. Use only with powershell.exe or pwsh.exe; passed as one -Command argument."},cwd:{type:"string",description:"Optional workspace-relative working directory."},timeoutMs:{type:"number",description:"Timeout between 100 milliseconds and the configured runtime maximum."}},required:["command"],additionalProperties:!1}}}],k="Process completed successfully with no output.";function O(o="host"){return o==="host"?h:h.map(t=>"function"in t?{...t,function:{...t.function,description:'Execute one Linux program with structured arguments inside the isolated Desktop WSL2 guest. Use Linux executables and workspace-relative paths; never invoke powershell.exe, cmd.exe, wsl.exe, Windows paths, or host interop. Keep command and args separate. For multiple shell operations, use bash with args ["-lc", "..."] only when a shell script is necessary. Inspect stdout, stderr, exit code, and returned data before continuing.'}}:t)}class B{options;constructor(t={}){this.options=t}listTools(){return O(this.options.toolEnvironment)}getToolInfo(t){return t==="shell.exec"?{toolName:t,source:"shell",executorId:"local-shell"}:void 0}async execute(t,l,i){return t!=="shell.exec"?{content:`Unknown shell tool: ${t}`,isError:!0}:C(this.options.logger,{toolName:t,source:"shell",context:i},async()=>{if(typeof l.command!="string"||l.command.trim().length===0)return{content:"shell.exec requires a command.",isError:!0};const a=this.options.platform??S();let r;try{r=T(l,a,{allowNonWindows:this.options.toolEnvironment!=="linux-guest"})}catch(n){return{content:n instanceof Error?n.message:"Invalid shell.exec PowerShell script.",isError:!0}}const e=r.args===void 0?[]:r.args;if(!Array.isArray(e)||e.some(n=>typeof n!="string"))return{content:"shell.exec args must be an array of strings.",isError:!0};const s=await b(r.command,e,i,p,r.cwd,a);if(this.options.readOnly&&!s)return{content:"This subagent is limited to read-only shell commands inside the trusted workspace.",isError:!0};const g=this.options.toolEnvironment==="linux-guest"?c.guestShellTimeoutMs:c.hostShellTimeoutMs,w=typeof r.timeoutMs=="number"?Math.min(Math.max(r.timeoutMs,100),g):c.defaultShellTimeoutMs,u=await p(r.cwd??".",i),m=s?await y(r.command,i.workspaceRoot??u,a):void 0;if(s&&m===void 0)return{content:"Read-only executable is no longer available.",isError:!0};const x=P(r.command,e),d=this.options.onActivity?.start({key:`${i.runId}:shell.exec`,toolName:"shell.exec",source:"shell",label:x});try{const n=await M(m??r.command,s?E(r.command,e):e,u,w,i,a);return d?.complete(n.isError===!0),n}catch(n){throw d?.complete(!0),n}})}}async function M(o,t,l,i,a,r){try{const e=await v(o,t,r,{cwd:l,timeoutMs:i,maxBufferBytes:a.maxResultBytes,rejectOnNonZero:!1,...a.signal===void 0?{}:{signal:a.signal}}),s=`${e.stdout}${e.stderr}${e.exitCode===0?"":`
2
+ Process exited with code ${String(e.exitCode)}.`}`;return{content:f(s||k),isError:e.exitCode!==0,metadata:{exitCode:e.exitCode}}}catch(e){const s=e instanceof Error?e.message:"Process execution failed.";return{content:f(s),isError:!0,metadata:{errorCode:I(s)}}}}function I(o){return/timed out/iu.test(o)?"timeout":/cancelled/iu.test(o)?"cancelled":/output exceeded/iu.test(o)?"output_limit":"process_failure"}function f(o){return o.replace(/Bearer\s+[^\s]+/gi,"Bearer [REDACTED]").replace(/sk-[A-Za-z0-9_-]{8,}/g,"[REDACTED]")}export{B as ShellToolExecutor,O as shellToolDefinitions};