@lotagate/cli 0.1.21 → 0.1.22

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 (490) hide show
  1. package/dist/application/agent/agent-history.d.ts +3 -0
  2. package/dist/application/agent/agent-history.js +81 -0
  3. package/dist/application/agent/agent-input-context.d.ts +9 -0
  4. package/dist/application/agent/agent-input-context.js +12 -0
  5. package/dist/application/agent/agent-limit.d.ts +3 -0
  6. package/dist/application/agent/agent-limit.js +12 -0
  7. package/dist/application/agent/agent-run-tracker.d.ts +30 -0
  8. package/dist/application/agent/agent-run-tracker.js +68 -0
  9. package/dist/application/agent/agent-session-store.d.ts +19 -0
  10. package/dist/application/agent/agent-session-store.js +74 -0
  11. package/dist/application/agent/capability-profile.d.ts +37 -0
  12. package/dist/application/agent/capability-profile.js +13 -0
  13. package/dist/application/agent/cli-agent-execution-service.d.ts +81 -0
  14. package/dist/application/agent/cli-agent-execution-service.js +279 -0
  15. package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
  16. package/dist/application/agent/context-compaction-persistence.js +27 -0
  17. package/dist/application/agent/context-compaction.d.ts +20 -0
  18. package/dist/application/agent/context-compaction.js +114 -0
  19. package/dist/application/agent/prompt-data-safety.d.ts +14 -0
  20. package/dist/application/agent/prompt-data-safety.js +38 -0
  21. package/dist/application/agent/safe-system-prompt.d.ts +3 -0
  22. package/dist/application/agent/safe-system-prompt.js +19 -0
  23. package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
  24. package/dist/application/agent/scoped-tool-executor.js +32 -0
  25. package/dist/application/agent/system-prompt-builder.d.ts +14 -0
  26. package/dist/application/agent/system-prompt-builder.js +199 -0
  27. package/dist/application/agent/tool-catalog.d.ts +14 -0
  28. package/dist/application/agent/tool-catalog.js +30 -0
  29. package/dist/application/agent/tool-display.d.ts +6 -0
  30. package/dist/application/agent/tool-display.js +59 -0
  31. package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
  32. package/dist/application/agent/tool-hook-lifecycle.js +85 -0
  33. package/dist/application/auth/authentication-service.d.ts +20 -0
  34. package/dist/application/auth/authentication-service.js +44 -0
  35. package/dist/application/chat/chat-service.d.ts +12 -0
  36. package/dist/application/chat/chat-service.js +19 -0
  37. package/dist/application/chat/pending-attachment-store.d.ts +12 -0
  38. package/dist/application/chat/pending-attachment-store.js +28 -0
  39. package/dist/application/commands/application-command-executor.d.ts +20 -0
  40. package/dist/application/commands/application-command-executor.js +66 -0
  41. package/dist/application/commands/cli-args.d.ts +6 -0
  42. package/dist/application/commands/cli-args.js +43 -0
  43. package/dist/application/commands/cli-command-services.d.ts +16 -0
  44. package/dist/application/commands/cli-command-services.js +405 -0
  45. package/dist/application/commands/command-catalog.d.ts +6 -0
  46. package/dist/application/commands/command-catalog.js +159 -0
  47. package/dist/application/commands/command-contract.d.ts +58 -0
  48. package/dist/application/commands/command-contract.js +1 -0
  49. package/dist/application/commands/command-hints.d.ts +9 -0
  50. package/dist/application/commands/command-hints.js +17 -0
  51. package/dist/application/commands/command-output.d.ts +4 -0
  52. package/dist/application/commands/command-output.js +1 -0
  53. package/dist/application/commands/command-parser.d.ts +10 -0
  54. package/dist/application/commands/command-parser.js +155 -0
  55. package/dist/application/commands/command-presentation.d.ts +7 -0
  56. package/dist/application/commands/command-presentation.js +131 -0
  57. package/dist/application/commands/command-registry.d.ts +11 -0
  58. package/dist/application/commands/command-registry.js +64 -0
  59. package/dist/application/commands/command-runtime.d.ts +2 -0
  60. package/dist/application/commands/command-runtime.js +3 -0
  61. package/dist/application/commands/goal-command-handlers.d.ts +3 -0
  62. package/dist/application/commands/goal-command-handlers.js +120 -0
  63. package/dist/application/commands/media-command-handlers.d.ts +9 -0
  64. package/dist/application/commands/media-command-handlers.js +307 -0
  65. package/dist/application/commands/media-command-output.d.ts +11 -0
  66. package/dist/application/commands/media-command-output.js +8 -0
  67. package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
  68. package/dist/application/commands/runtime-command-handlers.js +177 -0
  69. package/dist/application/commands/stream-output.d.ts +4 -0
  70. package/dist/application/commands/stream-output.js +10 -0
  71. package/dist/application/commands/utility-commands.d.ts +6 -0
  72. package/dist/application/commands/utility-commands.js +81 -0
  73. package/dist/application/config/execution-config.d.ts +4 -0
  74. package/dist/application/config/execution-config.js +6 -0
  75. package/dist/application/extensions/extension-list-contract.d.ts +13 -0
  76. package/dist/application/extensions/extension-list-contract.js +1 -0
  77. package/dist/application/extensions/extension-list-formatters.d.ts +31 -0
  78. package/dist/application/extensions/extension-list-formatters.js +98 -0
  79. package/dist/application/extensions/extension-list-output.d.ts +3 -0
  80. package/dist/application/extensions/extension-list-output.js +7 -0
  81. package/dist/application/extensions/plugin-contribution-registry.d.ts +15 -0
  82. package/dist/application/extensions/plugin-contribution-registry.js +80 -0
  83. package/dist/application/extensions/skill-scope-store.d.ts +23 -0
  84. package/dist/application/extensions/skill-scope-store.js +33 -0
  85. package/dist/application/formatting/compact-number.d.ts +2 -0
  86. package/dist/application/formatting/compact-number.js +18 -0
  87. package/dist/application/formatting/compact-table.d.ts +22 -0
  88. package/dist/application/formatting/compact-table.js +49 -0
  89. package/dist/application/media/video-operation-poller.d.ts +5 -0
  90. package/dist/application/media/video-operation-poller.js +42 -0
  91. package/dist/application/model/cached-model-catalog.d.ts +13 -0
  92. package/dist/application/model/cached-model-catalog.js +31 -0
  93. package/dist/application/model/initial-model-selection.d.ts +10 -0
  94. package/dist/application/model/initial-model-selection.js +11 -0
  95. package/dist/application/model/model-catalog-service.d.ts +6 -0
  96. package/dist/application/model/model-catalog-service.js +13 -0
  97. package/dist/application/model/model-context-window.d.ts +3 -0
  98. package/dist/application/model/model-context-window.js +23 -0
  99. package/dist/application/orchestration/cli-subagent-service.d.ts +70 -0
  100. package/dist/application/orchestration/cli-subagent-service.js +328 -0
  101. package/dist/application/orchestration/cli-turn-event-projector.d.ts +12 -0
  102. package/dist/application/orchestration/cli-turn-event-projector.js +81 -0
  103. package/dist/application/orchestration/cli-turn-events.d.ts +76 -0
  104. package/dist/application/orchestration/cli-turn-events.js +39 -0
  105. package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
  106. package/dist/application/orchestration/cli-turn-persistence.js +14 -0
  107. package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
  108. package/dist/application/orchestration/goal-evaluator.js +88 -0
  109. package/dist/application/orchestration/goal-input.d.ts +3 -0
  110. package/dist/application/orchestration/goal-input.js +19 -0
  111. package/dist/application/orchestration/goal-output.d.ts +2 -0
  112. package/dist/application/orchestration/goal-output.js +11 -0
  113. package/dist/application/orchestration/goal-runner.d.ts +22 -0
  114. package/dist/application/orchestration/goal-runner.js +153 -0
  115. package/dist/application/orchestration/goal-usage.d.ts +9 -0
  116. package/dist/application/orchestration/goal-usage.js +19 -0
  117. package/dist/application/orchestration/headless-agent-turn.d.ts +32 -0
  118. package/dist/application/orchestration/headless-agent-turn.js +82 -0
  119. package/dist/application/orchestration/plan-generator.d.ts +7 -0
  120. package/dist/application/orchestration/plan-generator.js +34 -0
  121. package/dist/application/orchestration/subagent-coordinator.d.ts +33 -0
  122. package/dist/application/orchestration/subagent-coordinator.js +28 -0
  123. package/dist/application/orchestration/subagent-handoff.d.ts +2 -0
  124. package/dist/application/orchestration/subagent-handoff.js +68 -0
  125. package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
  126. package/dist/application/orchestration/subagent-tool-executor.js +93 -0
  127. package/dist/application/orchestration/task-assessment.d.ts +4 -0
  128. package/dist/application/orchestration/task-assessment.js +35 -0
  129. package/dist/application/orchestration/task-graph.d.ts +13 -0
  130. package/dist/application/orchestration/task-graph.js +56 -0
  131. package/dist/application/orchestration/task-scheduler.d.ts +18 -0
  132. package/dist/application/orchestration/task-scheduler.js +88 -0
  133. package/dist/application/project/project-trust-service.d.ts +13 -0
  134. package/dist/application/project/project-trust-service.js +74 -0
  135. package/dist/application/protocol/browser-host-tool-executor.d.ts +41 -0
  136. package/dist/application/protocol/browser-host-tool-executor.js +88 -0
  137. package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
  138. package/dist/application/protocol/desktop-agent-command.js +663 -0
  139. package/dist/application/protocol/desktop-attachment-store.d.ts +16 -0
  140. package/dist/application/protocol/desktop-attachment-store.js +82 -0
  141. package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
  142. package/dist/application/protocol/desktop-command-catalog.js +19 -0
  143. package/dist/application/protocol/desktop-command-contract.d.ts +22 -0
  144. package/dist/application/protocol/desktop-command-contract.js +3 -0
  145. package/dist/application/protocol/desktop-command-executor.d.ts +16 -0
  146. package/dist/application/protocol/desktop-command-executor.js +47 -0
  147. package/dist/application/protocol/desktop-command-output.d.ts +15 -0
  148. package/dist/application/protocol/desktop-command-output.js +24 -0
  149. package/dist/application/protocol/desktop-execution-policy.d.ts +17 -0
  150. package/dist/application/protocol/desktop-execution-policy.js +49 -0
  151. package/dist/application/protocol/desktop-host-tool-executor.d.ts +57 -0
  152. package/dist/application/protocol/desktop-host-tool-executor.js +53 -0
  153. package/dist/application/protocol/desktop-orchestration-events.d.ts +5 -0
  154. package/dist/application/protocol/desktop-orchestration-events.js +37 -0
  155. package/dist/application/protocol/json-line-writer.d.ts +9 -0
  156. package/dist/application/protocol/json-line-writer.js +19 -0
  157. package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
  158. package/dist/application/protocol/jsonl-agent-command.js +97 -0
  159. package/dist/application/protocol/jsonl-protocol.d.ts +52 -0
  160. package/dist/application/protocol/jsonl-protocol.js +170 -0
  161. package/dist/application/security/desktop-tool-scope-policy.d.ts +3 -0
  162. package/dist/application/security/desktop-tool-scope-policy.js +52 -0
  163. package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
  164. package/dist/application/security/tool-action-risk-analyzer.js +64 -0
  165. package/dist/application/security/tool-approval-service.d.ts +35 -0
  166. package/dist/application/security/tool-approval-service.js +97 -0
  167. package/dist/application/security/tool-risk-classifier.d.ts +11 -0
  168. package/dist/application/security/tool-risk-classifier.js +65 -0
  169. package/dist/application/security/workspace-permission-policy.d.ts +10 -0
  170. package/dist/application/security/workspace-permission-policy.js +50 -0
  171. package/dist/application/session/project-session-access.d.ts +8 -0
  172. package/dist/application/session/project-session-access.js +19 -0
  173. package/dist/application/session/session-compaction-service.d.ts +10 -0
  174. package/dist/application/session/session-compaction-service.js +43 -0
  175. package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
  176. package/dist/application/session/session-turn-lifecycle.js +31 -0
  177. package/dist/application/workspace/workspace-file-index.d.ts +15 -0
  178. package/dist/application/workspace/workspace-file-index.js +60 -0
  179. package/dist/application/workspace/workspace-file-reference-resolver.d.ts +14 -0
  180. package/dist/application/workspace/workspace-file-reference-resolver.js +123 -0
  181. package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
  182. package/dist/application/workspace/workspace-instruction-loader.js +55 -0
  183. package/dist/bootstrap/composition-root.d.ts +6 -0
  184. package/dist/bootstrap/composition-root.js +4 -0
  185. package/dist/bootstrap/global-cli-options.d.ts +6 -0
  186. package/dist/bootstrap/global-cli-options.js +29 -0
  187. package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
  188. package/dist/bootstrap/native-devtools-stub.js +10 -0
  189. package/dist/bootstrap/native-entry.d.ts +1 -0
  190. package/dist/bootstrap/native-entry.js +6 -0
  191. package/dist/bootstrap/native-tiktoken.d.ts +4 -0
  192. package/dist/bootstrap/native-tiktoken.js +5 -0
  193. package/dist/bootstrap/runtime-factory.d.ts +35 -0
  194. package/dist/bootstrap/runtime-factory.js +44 -0
  195. package/dist/bootstrap/shutdown-manager.d.ts +10 -0
  196. package/dist/bootstrap/shutdown-manager.js +14 -0
  197. package/dist/bootstrap/startup-sequence.d.ts +5 -0
  198. package/dist/bootstrap/startup-sequence.js +10 -0
  199. package/dist/domain/auth/auth-profile.d.ts +14 -0
  200. package/dist/domain/auth/auth-profile.js +39 -0
  201. package/dist/domain/config/config-schema.d.ts +17 -0
  202. package/dist/domain/config/config-schema.js +105 -0
  203. package/dist/domain/errors/cli-command-hint.d.ts +5 -0
  204. package/dist/domain/errors/cli-command-hint.js +1 -0
  205. package/dist/domain/errors/cli-error.d.ts +35 -0
  206. package/dist/domain/errors/cli-error.js +129 -0
  207. package/dist/domain/errors/error-codes.d.ts +46 -0
  208. package/dist/domain/errors/error-codes.js +45 -0
  209. package/dist/domain/extensions/extension-scope.d.ts +3 -0
  210. package/dist/domain/extensions/extension-scope.js +23 -0
  211. package/dist/domain/extensions/extension-state.d.ts +5 -0
  212. package/dist/domain/extensions/extension-state.js +11 -0
  213. package/dist/domain/extensions/hook-manifest.d.ts +10 -0
  214. package/dist/domain/extensions/hook-manifest.js +23 -0
  215. package/dist/domain/extensions/mcp-config.d.ts +18 -0
  216. package/dist/domain/extensions/mcp-config.js +111 -0
  217. package/dist/domain/extensions/plugin-manifest.d.ts +11 -0
  218. package/dist/domain/extensions/plugin-manifest.js +43 -0
  219. package/dist/domain/extensions/skill-manifest.d.ts +10 -0
  220. package/dist/domain/extensions/skill-manifest.js +51 -0
  221. package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
  222. package/dist/domain/filesystem/file-change-diff.js +60 -0
  223. package/dist/domain/media/gateway-media-contract.d.ts +23 -0
  224. package/dist/domain/media/gateway-media-contract.js +163 -0
  225. package/dist/domain/media/media-contract.d.ts +28 -0
  226. package/dist/domain/media/media-contract.js +1 -0
  227. package/dist/domain/media/media-execution-policy.d.ts +9 -0
  228. package/dist/domain/media/media-execution-policy.js +31 -0
  229. package/dist/domain/orchestration/goal.d.ts +58 -0
  230. package/dist/domain/orchestration/goal.js +113 -0
  231. package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
  232. package/dist/domain/orchestration/subagent-identity.js +8 -0
  233. package/dist/domain/orchestration/subagent.d.ts +33 -0
  234. package/dist/domain/orchestration/subagent.js +1 -0
  235. package/dist/domain/orchestration/task.d.ts +31 -0
  236. package/dist/domain/orchestration/task.js +1 -0
  237. package/dist/domain/project/project-identity.d.ts +6 -0
  238. package/dist/domain/project/project-identity.js +4 -0
  239. package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
  240. package/dist/domain/runtime/assistant-delta-normalizer.js +19 -0
  241. package/dist/domain/runtime/resource-limits.d.ts +60 -0
  242. package/dist/domain/runtime/resource-limits.js +60 -0
  243. package/dist/domain/session/attachment.d.ts +13 -0
  244. package/dist/domain/session/attachment.js +1 -0
  245. package/dist/domain/session/session-schema.d.ts +6 -0
  246. package/dist/domain/session/session-schema.js +28 -0
  247. package/dist/domain/session/session.d.ts +27 -0
  248. package/dist/domain/session/session.js +1 -0
  249. package/dist/domain/settings/settings-document.d.ts +8 -0
  250. package/dist/domain/settings/settings-document.js +36 -0
  251. package/dist/domain/validation/record-schema.d.ts +4 -0
  252. package/dist/domain/validation/record-schema.js +9 -0
  253. package/dist/domain/workspace/workspace-settings.d.ts +12 -0
  254. package/dist/domain/workspace/workspace-settings.js +44 -0
  255. package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
  256. package/dist/infrastructure/agent-sdk/agent-instance-factory.js +31 -0
  257. package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
  258. package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +447 -0
  259. package/dist/infrastructure/cache/cache-policy.d.ts +7 -0
  260. package/dist/infrastructure/cache/cache-policy.js +18 -0
  261. package/dist/infrastructure/cache/file-cache-store.d.ts +17 -0
  262. package/dist/infrastructure/cache/file-cache-store.js +121 -0
  263. package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
  264. package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +98 -0
  265. package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
  266. package/dist/infrastructure/clipboard/clipboard-policy.js +19 -0
  267. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
  268. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +94 -0
  269. package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
  270. package/dist/infrastructure/clipboard/image-normalizer.js +78 -0
  271. package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
  272. package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +66 -0
  273. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
  274. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +70 -0
  275. package/dist/infrastructure/config/config-loader.d.ts +19 -0
  276. package/dist/infrastructure/config/config-loader.js +76 -0
  277. package/dist/infrastructure/config/environment-values.d.ts +2 -0
  278. package/dist/infrastructure/config/environment-values.js +7 -0
  279. package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
  280. package/dist/infrastructure/credentials/composite-credential-store.js +32 -0
  281. package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
  282. package/dist/infrastructure/credentials/encrypted-file-credential-store.js +181 -0
  283. package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
  284. package/dist/infrastructure/credentials/environment-credential-store.js +37 -0
  285. package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
  286. package/dist/infrastructure/credentials/secret-input.js +44 -0
  287. package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
  288. package/dist/infrastructure/extensions/composite-mcp-config-store.js +10 -0
  289. package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
  290. package/dist/infrastructure/extensions/extension-directory-reader.js +15 -0
  291. package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
  292. package/dist/infrastructure/extensions/extension-source-resolver.js +126 -0
  293. package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
  294. package/dist/infrastructure/extensions/file-mcp-config-store.js +66 -0
  295. package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
  296. package/dist/infrastructure/extensions/hook-runtime.js +66 -0
  297. package/dist/infrastructure/extensions/mcp-runtime.d.ts +12 -0
  298. package/dist/infrastructure/extensions/mcp-runtime.js +52 -0
  299. package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
  300. package/dist/infrastructure/extensions/plugin-discovery.js +52 -0
  301. package/dist/infrastructure/extensions/plugin-manager.d.ts +26 -0
  302. package/dist/infrastructure/extensions/plugin-manager.js +139 -0
  303. package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
  304. package/dist/infrastructure/extensions/skill-discovery.js +29 -0
  305. package/dist/infrastructure/extensions/skill-installer.d.ts +8 -0
  306. package/dist/infrastructure/extensions/skill-installer.js +88 -0
  307. package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
  308. package/dist/infrastructure/extensions/skill-manager.js +67 -0
  309. package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
  310. package/dist/infrastructure/extensions/skill-roots.js +25 -0
  311. package/dist/infrastructure/extensions/skill-tool-executor.d.ts +18 -0
  312. package/dist/infrastructure/extensions/skill-tool-executor.js +53 -0
  313. package/dist/infrastructure/filesystem/atomic-file-store.d.ts +12 -0
  314. package/dist/infrastructure/filesystem/atomic-file-store.js +106 -0
  315. package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
  316. package/dist/infrastructure/filesystem/bounded-file-reader.js +24 -0
  317. package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
  318. package/dist/infrastructure/filesystem/bounded-json-reader.js +7 -0
  319. package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
  320. package/dist/infrastructure/filesystem/fs-errors.js +6 -0
  321. package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
  322. package/dist/infrastructure/filesystem/gateway-media-input-reader.js +49 -0
  323. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +21 -0
  324. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +176 -0
  325. package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
  326. package/dist/infrastructure/filesystem/path-resolver.js +119 -0
  327. package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
  328. package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +152 -0
  329. package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +20 -0
  330. package/dist/infrastructure/logging/daily-rotating-file-writer.js +75 -0
  331. package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
  332. package/dist/infrastructure/logging/log-redactor.js +26 -0
  333. package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
  334. package/dist/infrastructure/logging/logging-policy.js +6 -0
  335. package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
  336. package/dist/infrastructure/logging/structured-logger.js +40 -0
  337. package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
  338. package/dist/infrastructure/network/safe-media-downloader.js +239 -0
  339. package/dist/infrastructure/platform/host-platform.d.ts +14 -0
  340. package/dist/infrastructure/platform/host-platform.js +23 -0
  341. package/dist/infrastructure/platform/host-process.d.ts +17 -0
  342. package/dist/infrastructure/platform/host-process.js +116 -0
  343. package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
  344. package/dist/infrastructure/platform/platform-paths.js +33 -0
  345. package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
  346. package/dist/infrastructure/project/file-project-trust-store.js +59 -0
  347. package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
  348. package/dist/infrastructure/sdk/chat-completion-adapter.js +115 -0
  349. package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
  350. package/dist/infrastructure/sdk/lotagate-client-factory.js +8 -0
  351. package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
  352. package/dist/infrastructure/sdk/model-catalog-adapter.js +28 -0
  353. package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +20 -0
  354. package/dist/infrastructure/sdk/sdk-media-gateway-client.js +97 -0
  355. package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
  356. package/dist/infrastructure/sessions/file-goal-store.js +160 -0
  357. package/dist/infrastructure/sessions/file-session-store.d.ts +48 -0
  358. package/dist/infrastructure/sessions/file-session-store.js +525 -0
  359. package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
  360. package/dist/infrastructure/sessions/project-session-paths.js +41 -0
  361. package/dist/infrastructure/sessions/session-index.d.ts +16 -0
  362. package/dist/infrastructure/sessions/session-index.js +84 -0
  363. package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
  364. package/dist/infrastructure/sessions/session-journal.js +137 -0
  365. package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
  366. package/dist/infrastructure/sessions/subagent-journal-store.js +30 -0
  367. package/dist/infrastructure/shell/shell-tool-executor.d.ts +17 -0
  368. package/dist/infrastructure/shell/shell-tool-executor.js +115 -0
  369. package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
  370. package/dist/infrastructure/tokens/tiktoken-token-estimator.js +48 -0
  371. package/dist/infrastructure/workspace/workspace-settings-store.d.ts +9 -0
  372. package/dist/infrastructure/workspace/workspace-settings-store.js +75 -0
  373. package/dist/main.d.ts +7 -0
  374. package/dist/main.js +66 -0
  375. package/dist/ports/cache-store.d.ts +10 -0
  376. package/dist/ports/cache-store.js +1 -0
  377. package/dist/ports/chat-model.d.ts +30 -0
  378. package/dist/ports/chat-model.js +1 -0
  379. package/dist/ports/clipboard-adapter.d.ts +7 -0
  380. package/dist/ports/clipboard-adapter.js +1 -0
  381. package/dist/ports/clipboard-text-adapter.d.ts +3 -0
  382. package/dist/ports/clipboard-text-adapter.js +1 -0
  383. package/dist/ports/credential-store.d.ts +7 -0
  384. package/dist/ports/credential-store.js +1 -0
  385. package/dist/ports/goal-store.d.ts +12 -0
  386. package/dist/ports/goal-store.js +1 -0
  387. package/dist/ports/logger.d.ts +8 -0
  388. package/dist/ports/logger.js +1 -0
  389. package/dist/ports/media-gateway-client.d.ts +54 -0
  390. package/dist/ports/media-gateway-client.js +1 -0
  391. package/dist/ports/model-diagnostics.d.ts +17 -0
  392. package/dist/ports/model-diagnostics.js +1 -0
  393. package/dist/ports/project-trust-store.d.ts +12 -0
  394. package/dist/ports/project-trust-store.js +1 -0
  395. package/dist/ports/session-store.d.ts +58 -0
  396. package/dist/ports/session-store.js +1 -0
  397. package/dist/ports/subagent-lifecycle.d.ts +31 -0
  398. package/dist/ports/subagent-lifecycle.js +1 -0
  399. package/dist/ports/tool-activity.d.ts +13 -0
  400. package/dist/ports/tool-activity.js +1 -0
  401. package/dist/presentation/themes/theme.d.ts +19 -0
  402. package/dist/presentation/themes/theme.js +8 -0
  403. package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
  404. package/dist/presentation/tui/agent-initialization-renderer.js +37 -0
  405. package/dist/presentation/tui/context-display.d.ts +21 -0
  406. package/dist/presentation/tui/context-display.js +33 -0
  407. package/dist/presentation/tui/formatters.d.ts +6 -0
  408. package/dist/presentation/tui/formatters.js +60 -0
  409. package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
  410. package/dist/presentation/tui/ink/choice-window.js +5 -0
  411. package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
  412. package/dist/presentation/tui/ink/components/activity-entry.js +16 -0
  413. package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
  414. package/dist/presentation/tui/ink/components/activity-status.js +21 -0
  415. package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
  416. package/dist/presentation/tui/ink/components/choice-modal.js +29 -0
  417. package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
  418. package/dist/presentation/tui/ink/components/composer.js +271 -0
  419. package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
  420. package/dist/presentation/tui/ink/components/file-diff.js +34 -0
  421. package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
  422. package/dist/presentation/tui/ink/components/modal.js +110 -0
  423. package/dist/presentation/tui/ink/components/shimmer-text.d.ts +6 -0
  424. package/dist/presentation/tui/ink/components/shimmer-text.js +9 -0
  425. package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
  426. package/dist/presentation/tui/ink/components/subagent-activity.js +61 -0
  427. package/dist/presentation/tui/ink/components/transcript.d.ts +39 -0
  428. package/dist/presentation/tui/ink/components/transcript.js +121 -0
  429. package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
  430. package/dist/presentation/tui/ink/components/welcome-panel.js +20 -0
  431. package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
  432. package/dist/presentation/tui/ink/lotagate-tui.js +136 -0
  433. package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
  434. package/dist/presentation/tui/ink/markdown-inline-renderer.js +20 -0
  435. package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
  436. package/dist/presentation/tui/ink/markdown-inline.js +91 -0
  437. package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
  438. package/dist/presentation/tui/ink/markdown-message.js +66 -0
  439. package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
  440. package/dist/presentation/tui/ink/markdown-table.js +77 -0
  441. package/dist/presentation/tui/ink/tui-bridge.d.ts +195 -0
  442. package/dist/presentation/tui/ink/tui-bridge.js +289 -0
  443. package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
  444. package/dist/presentation/tui/terminal-capabilities.js +7 -0
  445. package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
  446. package/dist/presentation/tui/terminal-mouse.js +19 -0
  447. package/dist/presentation/tui/terminal-screen.d.ts +10 -0
  448. package/dist/presentation/tui/terminal-screen.js +23 -0
  449. package/dist/presentation/tui/tui-agent-event-runner.d.ts +24 -0
  450. package/dist/presentation/tui/tui-agent-event-runner.js +69 -0
  451. package/dist/presentation/tui/tui-application-contract.d.ts +10 -0
  452. package/dist/presentation/tui/tui-application-contract.js +8 -0
  453. package/dist/presentation/tui/tui-application.d.ts +62 -0
  454. package/dist/presentation/tui/tui-application.js +675 -0
  455. package/dist/presentation/tui/tui-attachment-input.d.ts +2 -0
  456. package/dist/presentation/tui/tui-attachment-input.js +5 -0
  457. package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
  458. package/dist/presentation/tui/tui-clipboard-paste-handlers.js +25 -0
  459. package/dist/presentation/tui/tui-command-context.d.ts +3 -0
  460. package/dist/presentation/tui/tui-command-context.js +1 -0
  461. package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
  462. package/dist/presentation/tui/tui-command-executor.js +214 -0
  463. package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
  464. package/dist/presentation/tui/tui-command-host-factory.js +23 -0
  465. package/dist/presentation/tui/tui-context-compaction.d.ts +5 -0
  466. package/dist/presentation/tui/tui-context-compaction.js +22 -0
  467. package/dist/presentation/tui/tui-context-service.d.ts +34 -0
  468. package/dist/presentation/tui/tui-context-service.js +126 -0
  469. package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
  470. package/dist/presentation/tui/tui-file-suggestions.js +8 -0
  471. package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
  472. package/dist/presentation/tui/tui-goal-controller.js +52 -0
  473. package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
  474. package/dist/presentation/tui/tui-initial-model.js +28 -0
  475. package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
  476. package/dist/presentation/tui/tui-lifecycle-actions.js +45 -0
  477. package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
  478. package/dist/presentation/tui/tui-manual-compaction.js +31 -0
  479. package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
  480. package/dist/presentation/tui/tui-media-model-selection.js +38 -0
  481. package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
  482. package/dist/presentation/tui/tui-prompt-dispatcher.js +38 -0
  483. package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
  484. package/dist/presentation/tui/tui-skill-controller.js +13 -0
  485. package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
  486. package/dist/presentation/tui/tui-tool-approval.js +73 -0
  487. package/dist/version.d.ts +1 -0
  488. package/dist/version.js +1 -0
  489. package/package.json +8 -7
  490. package/scripts/install-native.mjs +11 -11
@@ -0,0 +1,84 @@
1
+ import path from 'node:path';
2
+ import { atomicWriteFile, withFileLock } from '../filesystem/atomic-file-store.js';
3
+ import { isFileNotFound } from '../filesystem/fs-errors.js';
4
+ import { resolveProjectSessionPathsForKey } from './project-session-paths.js';
5
+ import { readJsonFileBounded } from '../filesystem/bounded-json-reader.js';
6
+ import { RESOURCE_LIMITS } from '../../domain/runtime/resource-limits.js';
7
+ export async function readProjectSessionIndex(filePath, projectKey) {
8
+ try {
9
+ const value = readProjectIndex(await readJsonFileBounded(filePath, RESOURCE_LIMITS.configFileBytes), projectKey);
10
+ return value;
11
+ }
12
+ catch (error) {
13
+ if (isFileNotFound(error))
14
+ return { projectKey, sessions: {} };
15
+ throw error;
16
+ }
17
+ }
18
+ export async function writeProjectSessionIndex(filePath, projectKey, sessions) {
19
+ await atomicWriteFile(filePath, `${JSON.stringify({ projectKey, sessions }, null, 2)}\n`);
20
+ }
21
+ export async function readSessionLocator(paths) {
22
+ const filePath = path.join(paths.projectsDir, 'locator.json');
23
+ try {
24
+ return readLocatorIndex(await readJsonFileBounded(filePath, RESOURCE_LIMITS.configFileBytes));
25
+ }
26
+ catch (error) {
27
+ if (isFileNotFound(error))
28
+ return { sessions: {} };
29
+ throw error;
30
+ }
31
+ }
32
+ function readProjectIndex(value, projectKey) {
33
+ if (!isRecord(value) || value['projectKey'] !== projectKey || !isRecord(value['sessions']))
34
+ throw new Error('Invalid project session index.');
35
+ for (const metadata of Object.values(value['sessions']))
36
+ if (!isSessionMetadata(metadata))
37
+ throw new Error('Invalid project session metadata.');
38
+ return { projectKey, sessions: value['sessions'] };
39
+ }
40
+ function readLocatorIndex(value) {
41
+ if (!isRecord(value) || !isRecord(value['sessions']) || Object.values(value['sessions']).some((projectKey) => typeof projectKey !== 'string'))
42
+ throw new Error('Invalid session locator index.');
43
+ return { sessions: value['sessions'] };
44
+ }
45
+ function isSessionMetadata(value) {
46
+ if (!isRecord(value))
47
+ return false;
48
+ return typeof value['id'] === 'string' && typeof value['projectFingerprint'] === 'string' && typeof value['cwd'] === 'string'
49
+ && (typeof value['model'] === 'string' || value['model'] === null) && (typeof value['profile'] === 'string' || value['profile'] === null)
50
+ && (value['status'] === 'active' || value['status'] === 'completed' || value['status'] === 'failed' || value['status'] === 'cancelled')
51
+ && typeof value['createdAt'] === 'string' && typeof value['updatedAt'] === 'string';
52
+ }
53
+ function isRecord(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); }
54
+ export async function writeSessionLocator(paths, sessions) {
55
+ await atomicWriteFile(path.join(paths.projectsDir, 'locator.json'), `${JSON.stringify({ sessions }, null, 2)}\n`);
56
+ }
57
+ export async function indexProjectSession(paths, metadata, projectKey) {
58
+ const projectPaths = resolveProjectSessionPathsForKey(paths, projectKey, metadata.id);
59
+ await withFileLock(projectPaths.projectIndexFile, async () => {
60
+ const projectIndex = await readProjectSessionIndex(projectPaths.projectIndexFile, projectKey);
61
+ await writeProjectSessionIndex(projectPaths.projectIndexFile, projectKey, { ...projectIndex.sessions, [metadata.id]: metadata });
62
+ });
63
+ const locatorFile = path.join(paths.projectsDir, 'locator.json');
64
+ await withFileLock(locatorFile, async () => {
65
+ const locator = await readSessionLocator(paths);
66
+ await writeSessionLocator(paths, { ...locator.sessions, [metadata.id]: projectKey });
67
+ });
68
+ }
69
+ export async function removeIndexedSession(paths, metadata, projectKey) {
70
+ const projectPaths = resolveProjectSessionPathsForKey(paths, projectKey, metadata.id);
71
+ await withFileLock(projectPaths.projectIndexFile, async () => {
72
+ const projectIndex = await readProjectSessionIndex(projectPaths.projectIndexFile, projectKey);
73
+ const sessions = { ...projectIndex.sessions };
74
+ delete sessions[metadata.id];
75
+ await writeProjectSessionIndex(projectPaths.projectIndexFile, projectKey, sessions);
76
+ });
77
+ const locatorFile = path.join(paths.projectsDir, 'locator.json');
78
+ await withFileLock(locatorFile, async () => {
79
+ const locator = await readSessionLocator(paths);
80
+ const locations = { ...locator.sessions };
81
+ delete locations[metadata.id];
82
+ await writeSessionLocator(paths, locations);
83
+ });
84
+ }
@@ -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,137 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { isFileNotFound } from '../filesystem/fs-errors.js';
4
+ import { atomicWriteFile } from '../filesystem/atomic-file-store.js';
5
+ import { isRecord, isSessionEvent, isSessionMetadata, isTranscriptEntry } from '../../domain/session/session-schema.js';
6
+ import { RESOURCE_LIMITS } from '../../domain/runtime/resource-limits.js';
7
+ export function metadataRecord(metadata) {
8
+ return { recordType: 'metadata', metadata };
9
+ }
10
+ export function eventRecord(event) {
11
+ return { recordType: 'event', event };
12
+ }
13
+ export function transcriptRecord(entry) {
14
+ return { recordType: 'transcript', entry };
15
+ }
16
+ export async function appendJournalRecord(filePath, record) {
17
+ await appendSerializedRecord(filePath, record);
18
+ }
19
+ /** Appends one crash-consistent physical JSONL record for an ordered logical batch. */
20
+ export async function appendJournalRecords(filePath, records) {
21
+ if (records.length === 0)
22
+ return;
23
+ await appendSerializedRecord(filePath, records.length === 1 ? records[0] : { recordType: 'batch', records });
24
+ }
25
+ async function appendSerializedRecord(filePath, record) {
26
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
27
+ const serialized = `${JSON.stringify(record)}\n`;
28
+ await assertJournalCanAppend(filePath, Buffer.byteLength(serialized, 'utf8'));
29
+ await fs.appendFile(filePath, serialized, { encoding: 'utf8', mode: 0o600 });
30
+ }
31
+ export async function readJournal(filePath) {
32
+ let raw;
33
+ try {
34
+ await assertJournalCanRead(filePath);
35
+ raw = await fs.readFile(filePath, 'utf8');
36
+ }
37
+ catch (error) {
38
+ if (isFileNotFound(error))
39
+ return [];
40
+ throw error;
41
+ }
42
+ try {
43
+ return parseJournal(raw);
44
+ }
45
+ catch (error) {
46
+ if (!hasIncompleteTrailingLine(raw))
47
+ throw error;
48
+ await new Promise((resolve) => setImmediate(resolve));
49
+ return parseJournal(await fs.readFile(filePath, 'utf8'));
50
+ }
51
+ }
52
+ function parseJournal(raw) {
53
+ return raw.split(/\r?\n/u).filter(Boolean).flatMap((line) => parseJournalLine(JSON.parse(line)));
54
+ }
55
+ function hasIncompleteTrailingLine(raw) {
56
+ const normalized = raw.replace(/\r\n/gu, '\n');
57
+ return normalized.length > 0 && !normalized.endsWith('\n');
58
+ }
59
+ async function assertJournalCanRead(filePath) {
60
+ const stat = await fs.stat(filePath);
61
+ if (stat.size > RESOURCE_LIMITS.sessionJournalBytes)
62
+ throw new Error('Session journal exceeds the supported size limit. Repair or export the session before resuming it.');
63
+ }
64
+ async function assertJournalCanAppend(filePath, additionalBytes) {
65
+ let size = 0;
66
+ try {
67
+ size = (await fs.stat(filePath)).size;
68
+ }
69
+ catch (error) {
70
+ if (!isFileNotFound(error))
71
+ throw error;
72
+ }
73
+ if (size + additionalBytes > RESOURCE_LIMITS.sessionJournalBytes)
74
+ throw new Error('Session journal exceeds the supported size limit. Compact or export the session before adding more data.');
75
+ }
76
+ export function latestMetadata(records) {
77
+ return records.filter((record) => record.recordType === 'metadata').at(-1)?.metadata;
78
+ }
79
+ export function journalEvents(records) {
80
+ return records.filter((record) => record.recordType === 'event').map((record) => record.event);
81
+ }
82
+ export function journalTranscript(records) {
83
+ return records.filter((record) => record.recordType === 'transcript').map((record) => record.entry);
84
+ }
85
+ export async function repairJournal(filePath) {
86
+ let raw;
87
+ try {
88
+ raw = await fs.readFile(filePath, 'utf8');
89
+ }
90
+ catch (error) {
91
+ if (isFileNotFound(error))
92
+ return 0;
93
+ throw error;
94
+ }
95
+ const lines = raw.split(/\r?\n/u);
96
+ const valid = [];
97
+ let removed = 0;
98
+ for (let index = 0; index < lines.length; index += 1) {
99
+ const line = lines[index]?.trim();
100
+ if (line === undefined || line.length === 0)
101
+ continue;
102
+ try {
103
+ parseJournalLine(JSON.parse(line));
104
+ valid.push(line);
105
+ }
106
+ catch (error) {
107
+ const trailing = lines.slice(index + 1).every((candidate) => candidate.trim().length === 0);
108
+ if (!trailing)
109
+ throw error;
110
+ removed += 1;
111
+ }
112
+ }
113
+ if (removed > 0)
114
+ await atomicWriteFile(filePath, valid.length === 0 ? '' : `${valid.join('\n')}\n`);
115
+ return removed;
116
+ }
117
+ function parseJournalLine(value) {
118
+ if (isRecord(value) && value['recordType'] === 'batch') {
119
+ const records = value['records'];
120
+ if (!Array.isArray(records) || records.length === 0)
121
+ throw new Error('Invalid session journal batch.');
122
+ return records.map(parseJournalRecord);
123
+ }
124
+ return [parseJournalRecord(value)];
125
+ }
126
+ function parseJournalRecord(value) {
127
+ if (!isRecord(value))
128
+ throw new Error('Invalid session journal record.');
129
+ const record = value;
130
+ if (record['recordType'] === 'metadata' && isSessionMetadata(record['metadata']))
131
+ return { recordType: 'metadata', metadata: record['metadata'] };
132
+ if (record['recordType'] === 'event' && isSessionEvent(record['event']))
133
+ return { recordType: 'event', event: record['event'] };
134
+ if (record['recordType'] === 'transcript' && isTranscriptEntry(record['entry']))
135
+ return { recordType: 'transcript', entry: record['entry'] };
136
+ throw new Error('Unsupported or malformed session journal record.');
137
+ }
@@ -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,30 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { resolveProjectSessionPaths } from './project-session-paths.js';
4
+ /** Persists bounded child-agent lifecycle records beside the parent session. */
5
+ export class SubagentJournalStore {
6
+ paths;
7
+ constructor(paths) {
8
+ this.paths = paths;
9
+ }
10
+ async append(parentSessionId, cwd, record) {
11
+ assertSafeSessionId(parentSessionId);
12
+ const location = resolveProjectSessionPaths(this.paths, cwd, parentSessionId);
13
+ const filePath = path.join(location.subagentsDirectory, `${recordId(record)}.jsonl`);
14
+ await fs.mkdir(location.subagentsDirectory, { recursive: true, mode: 0o700 });
15
+ await appendBoundedRecord(filePath, record);
16
+ }
17
+ }
18
+ function assertSafeSessionId(value) {
19
+ if (!/^[A-Za-z0-9._-]{1,128}$/u.test(value))
20
+ throw new Error('Invalid parent session id for subagent journal.');
21
+ }
22
+ async function appendBoundedRecord(filePath, record) {
23
+ const serialized = `${JSON.stringify(record)}\n`;
24
+ if (Buffer.byteLength(serialized, 'utf8') > 32 * 1024)
25
+ throw new Error('Subagent journal record exceeds the configured limit.');
26
+ await fs.appendFile(filePath, serialized, { encoding: 'utf8', mode: 0o600 });
27
+ }
28
+ function recordId(record) {
29
+ return record.recordType === 'created' || record.recordType === 'started' ? record.id : record.result.id;
30
+ }
@@ -0,0 +1,17 @@
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
+ /** Exposes the same shell capability definitions to runtime and context accounting. */
6
+ export declare function shellToolDefinitions(): readonly ToolDefinition[];
7
+ export declare class ShellToolExecutor implements ToolExecutor {
8
+ private readonly options;
9
+ constructor(options?: {
10
+ onActivity?: ToolActivityObserver;
11
+ readOnly?: boolean;
12
+ platform?: HostPlatformContext;
13
+ });
14
+ listTools(): readonly ToolDefinition[];
15
+ getToolInfo(toolName: string): ToolInfo | undefined;
16
+ execute(toolName: string, input: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
17
+ }
@@ -0,0 +1,115 @@
1
+ import { resolveWorkspacePath } from '../filesystem/path-resolver.js';
2
+ import { isReadOnlyShellRequest } from '../../application/security/tool-risk-classifier.js';
3
+ import { detectHostPlatform } from '../platform/host-platform.js';
4
+ import { createSafeChildEnvironment, spawnPlatformProcess, terminatePlatformProcess } from '../platform/host-process.js';
5
+ import { formatShellCommandForDisplay } from '../../application/agent/tool-display.js';
6
+ const SHELL_TOOLS = [
7
+ { type: 'function', function: {
8
+ name: 'shell.exec',
9
+ description: 'Execute one program with structured arguments inside the trusted workspace. Shell interpretation is disabled.',
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {
13
+ command: { type: 'string', description: 'Executable name or path.' },
14
+ args: { type: 'array', items: { type: 'string' }, description: 'Structured process arguments.' },
15
+ cwd: { type: 'string', description: 'Optional workspace-relative working directory.' },
16
+ timeoutMs: { type: 'number', description: 'Timeout between 100 and 120000 milliseconds.' },
17
+ },
18
+ required: ['command'],
19
+ additionalProperties: false,
20
+ },
21
+ } },
22
+ ];
23
+ /** Exposes the same shell capability definitions to runtime and context accounting. */
24
+ export function shellToolDefinitions() { return SHELL_TOOLS; }
25
+ export class ShellToolExecutor {
26
+ options;
27
+ constructor(options = {}) {
28
+ this.options = options;
29
+ }
30
+ listTools() { return shellToolDefinitions(); }
31
+ getToolInfo(toolName) {
32
+ return toolName === 'shell.exec' ? { toolName, source: 'shell', executorId: 'local-shell' } : undefined;
33
+ }
34
+ async execute(toolName, input, context) {
35
+ if (toolName !== 'shell.exec')
36
+ return { content: `Unknown shell tool: ${toolName}`, isError: true };
37
+ if (typeof input['command'] !== 'string' || input['command'].trim().length === 0)
38
+ return { content: 'shell.exec requires a command.', isError: true };
39
+ const args = input['args'] === undefined ? [] : input['args'];
40
+ if (!Array.isArray(args) || args.some((arg) => typeof arg !== 'string'))
41
+ return { content: 'shell.exec args must be an array of strings.', isError: true };
42
+ if (this.options.readOnly && !isReadOnlyShellRequest(input['command'], args))
43
+ return { content: 'This subagent is limited to read-only shell commands.', isError: true };
44
+ const timeoutMs = typeof input['timeoutMs'] === 'number' ? Math.min(Math.max(input['timeoutMs'], 100), 120_000) : 30_000;
45
+ const cwd = await resolveWorkspacePath(input['cwd'] ?? '.', context);
46
+ const command = formatShellCommandForDisplay(input['command'], args);
47
+ const activity = this.options.onActivity?.start({ key: `${context.runId}:shell.exec`, toolName: 'shell.exec', source: 'shell', label: command });
48
+ return runProcess(input['command'], args, cwd, timeoutMs, context, this.options.platform ?? detectHostPlatform()).then((result) => {
49
+ activity?.complete(result.isError === true);
50
+ return result;
51
+ });
52
+ }
53
+ }
54
+ function runProcess(command, args, cwd, timeoutMs, context, platform) {
55
+ return new Promise((resolve) => {
56
+ const child = spawnPlatformProcess(command, args, platform, {
57
+ cwd,
58
+ detached: platform.supportsProcessGroups,
59
+ env: createSafeChildEnvironment(platform),
60
+ stdio: ['ignore', 'pipe', 'pipe'],
61
+ });
62
+ const stdout = [];
63
+ const stderr = [];
64
+ let settled = false;
65
+ let timedOut = false;
66
+ let outputExceeded = false;
67
+ let outputBytes = 0;
68
+ const outputLimit = Math.max(0, Math.floor(context.maxResultBytes));
69
+ const appendOutput = (target, chunk) => {
70
+ if (outputExceeded || chunk.byteLength === 0)
71
+ return;
72
+ const remaining = outputLimit - outputBytes;
73
+ if (remaining <= 0) {
74
+ outputExceeded = true;
75
+ terminatePlatformProcess(child, platform);
76
+ return;
77
+ }
78
+ const accepted = chunk.subarray(0, remaining);
79
+ target.push(accepted);
80
+ outputBytes += accepted.byteLength;
81
+ if (accepted.byteLength < chunk.byteLength) {
82
+ outputExceeded = true;
83
+ terminatePlatformProcess(child, platform);
84
+ }
85
+ };
86
+ const finish = (result) => {
87
+ if (settled)
88
+ return;
89
+ settled = true;
90
+ clearTimeout(timer);
91
+ context.signal?.removeEventListener('abort', abort);
92
+ resolve(result);
93
+ };
94
+ const abort = () => { terminatePlatformProcess(child, platform); finish({ content: 'Process cancelled.', isError: true }); };
95
+ const timer = setTimeout(() => { timedOut = true; terminatePlatformProcess(child, platform); }, timeoutMs);
96
+ child.stdout?.on('data', (chunk) => appendOutput(stdout, chunk));
97
+ child.stderr?.on('data', (chunk) => appendOutput(stderr, chunk));
98
+ child.once('error', (error) => finish({ content: redact(error.message), isError: true }));
99
+ child.once('close', (code) => {
100
+ if (timedOut)
101
+ finish({ content: `Process timed out after ${timeoutMs}ms.`, isError: true });
102
+ else if (outputExceeded)
103
+ finish({ content: 'Process output exceeded the configured limit.', isError: true });
104
+ else
105
+ finish({ content: redact(`${Buffer.concat(stdout).toString('utf8')}${Buffer.concat(stderr).toString('utf8')}${code === 0 ? '' : `\nProcess exited with code ${String(code)}.`}`), isError: code !== 0 });
106
+ });
107
+ if (context.signal?.aborted === true)
108
+ abort();
109
+ else
110
+ context.signal?.addEventListener('abort', abort, { once: true });
111
+ });
112
+ }
113
+ function redact(value) {
114
+ return value.replace(/Bearer\s+[^\s]+/gi, 'Bearer [REDACTED]').replace(/sk-[A-Za-z0-9_-]{8,}/g, '[REDACTED]');
115
+ }
@@ -0,0 +1,18 @@
1
+ import type { ChatUsage } from '../../ports/chat-model.js';
2
+ export interface TokenEstimateInput {
3
+ model: string;
4
+ prompt: string;
5
+ response: string;
6
+ }
7
+ export interface TextTokenEstimateInput {
8
+ model: string;
9
+ text: string;
10
+ }
11
+ /**
12
+ * Estimates turn usage when an upstream provider does not include usage in the
13
+ * streaming protocol. The result is deliberately marked as estimated because
14
+ * providers may use a tokenizer different from the OpenAI tokenizer family.
15
+ */
16
+ export declare function estimateTurnUsage(input: TokenEstimateInput): ChatUsage | undefined;
17
+ /** Estimates one text payload with the same tokenizer used for turn fallback accounting. */
18
+ export declare function estimateTextTokens(input: TextTokenEstimateInput): number;
@@ -0,0 +1,48 @@
1
+ import { encoding_for_model, get_encoding } from 'tiktoken';
2
+ const FALLBACK_ENCODING = 'o200k_base';
3
+ /**
4
+ * Estimates turn usage when an upstream provider does not include usage in the
5
+ * streaming protocol. The result is deliberately marked as estimated because
6
+ * providers may use a tokenizer different from the OpenAI tokenizer family.
7
+ */
8
+ export function estimateTurnUsage(input) {
9
+ try {
10
+ const encoder = createEncoder(input.model);
11
+ try {
12
+ const promptTokens = encoder.encode(input.prompt).length;
13
+ const completionTokens = encoder.encode(input.response).length;
14
+ return { promptTokens, completionTokens, totalTokens: promptTokens + completionTokens, estimated: true };
15
+ }
16
+ finally {
17
+ encoder.free();
18
+ }
19
+ }
20
+ catch {
21
+ // Token accounting must never make a successfully streamed response fail.
22
+ return undefined;
23
+ }
24
+ }
25
+ /** Estimates one text payload with the same tokenizer used for turn fallback accounting. */
26
+ export function estimateTextTokens(input) {
27
+ try {
28
+ const encoder = createEncoder(input.model);
29
+ try {
30
+ return encoder.encode(input.text).length;
31
+ }
32
+ finally {
33
+ encoder.free();
34
+ }
35
+ }
36
+ catch {
37
+ // A byte estimate keeps context diagnostics available for unsupported models.
38
+ return Math.ceil(Buffer.byteLength(input.text, 'utf8') / 4);
39
+ }
40
+ }
41
+ function createEncoder(model) {
42
+ try {
43
+ return encoding_for_model(model);
44
+ }
45
+ catch {
46
+ return get_encoding(FALLBACK_ENCODING);
47
+ }
48
+ }
@@ -0,0 +1,9 @@
1
+ import { type WorkspaceSettings } from '../../domain/workspace/workspace-settings.js';
2
+ export declare class WorkspaceSettingsStore {
3
+ ensureInitialized(cwd: string): Promise<void>;
4
+ load(cwd: string): Promise<WorkspaceSettings>;
5
+ /** Persist a user-approved rule in the ignored local project policy. */
6
+ rememberAllow(cwd: string, rule: string): Promise<void>;
7
+ private readOptional;
8
+ private createIfMissing;
9
+ }
@@ -0,0 +1,75 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { DEFAULT_WORKSPACE_SETTINGS } from '../../domain/workspace/workspace-settings.js';
4
+ import { permissionsFromSettings, validateSettingsDocument } from '../../domain/settings/settings-document.js';
5
+ import { resolveProjectConfigPaths } from '../platform/platform-paths.js';
6
+ import { atomicWriteFile, withFileLock } from '../filesystem/atomic-file-store.js';
7
+ import { isAlreadyExists, isFileNotFound } from '../filesystem/fs-errors.js';
8
+ import { readJsonFileBounded } from '../filesystem/bounded-json-reader.js';
9
+ import { RESOURCE_LIMITS } from '../../domain/runtime/resource-limits.js';
10
+ export class WorkspaceSettingsStore {
11
+ async ensureInitialized(cwd) {
12
+ const paths = resolveProjectConfigPaths(cwd);
13
+ await fs.mkdir(paths.directory, { recursive: true });
14
+ await Promise.all([paths.skillsDir, paths.pluginsDir, paths.hooksDir].map((directory) => fs.mkdir(directory, { recursive: true })));
15
+ await this.createIfMissing(paths.settings, DEFAULT_WORKSPACE_SETTINGS);
16
+ await this.createIfMissing(paths.localSettings, DEFAULT_WORKSPACE_SETTINGS);
17
+ await this.createIfMissing(path.join(paths.directory, '.gitignore'), 'settings.local.json\n');
18
+ }
19
+ async load(cwd) {
20
+ const paths = resolveProjectConfigPaths(cwd);
21
+ const [shared, local] = await Promise.all([this.readOptional(paths.settings), this.readOptional(paths.localSettings)]);
22
+ return { schemaVersion: 1, permissions: mergePermissions(shared?.permissions, local?.permissions) };
23
+ }
24
+ /** Persist a user-approved rule in the ignored local project policy. */
25
+ async rememberAllow(cwd, rule) {
26
+ const normalizedRule = rule.trim();
27
+ if (normalizedRule.length === 0)
28
+ return;
29
+ const paths = resolveProjectConfigPaths(cwd);
30
+ await fs.mkdir(paths.directory, { recursive: true });
31
+ await withFileLock(paths.localSettings, async () => {
32
+ const current = await this.readOptional(paths.localSettings) ?? DEFAULT_WORKSPACE_SETTINGS;
33
+ if (current.permissions.allow.includes(normalizedRule))
34
+ return;
35
+ const next = {
36
+ schemaVersion: 1,
37
+ permissions: {
38
+ ...current.permissions,
39
+ allow: [...current.permissions.allow, normalizedRule],
40
+ },
41
+ };
42
+ await atomicWriteFile(paths.localSettings, `${JSON.stringify(next, null, 2)}\n`);
43
+ });
44
+ }
45
+ async readOptional(filePath) {
46
+ try {
47
+ const document = validateSettingsDocument(await readJsonFileBounded(filePath, RESOURCE_LIMITS.workspaceSettingsBytes));
48
+ return { schemaVersion: 1, permissions: permissionsFromSettings(document) };
49
+ }
50
+ catch (error) {
51
+ if (isFileNotFound(error))
52
+ return undefined;
53
+ throw error;
54
+ }
55
+ }
56
+ async createIfMissing(filePath, value) {
57
+ try {
58
+ await fs.writeFile(filePath, typeof value === 'string' ? value : `${JSON.stringify(value, null, 2)}\n`, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
59
+ }
60
+ catch (error) {
61
+ if (!isAlreadyExists(error))
62
+ throw error;
63
+ }
64
+ }
65
+ }
66
+ function mergePermissions(shared, local) {
67
+ return {
68
+ allow: mergeRules(shared?.allow, local?.allow),
69
+ ask: mergeRules(shared?.ask, local?.ask),
70
+ deny: mergeRules(shared?.deny, local?.deny),
71
+ };
72
+ }
73
+ function mergeRules(...values) {
74
+ return [...new Set(values.flatMap((items) => items ?? []))];
75
+ }
package/dist/main.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { Readable, Writable } from 'node:stream';
2
+ export { CLI_VERSION } from './version.js';
3
+ export declare function main(argv: readonly string[], io?: {
4
+ stdin?: Readable;
5
+ stdout?: Writable;
6
+ stderr?: Writable;
7
+ }): Promise<number>;