@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,43 @@
1
+ import { CliError } from '../errors/cli-error.js';
2
+ import { CLI_ERROR_CODES } from '../errors/error-codes.js';
3
+ import { findUnexpectedRecordKey, isRecord } from '../validation/record-schema.js';
4
+ export function parsePluginManifest(value, directory) {
5
+ if (!isRecord(value))
6
+ throw invalidPlugin('Manifest must be a JSON object.');
7
+ const record = value;
8
+ const unexpectedKey = findUnexpectedRecordKey(record, ['name', 'version', 'description', 'skills', 'agents', 'hooks', 'mcp']);
9
+ if (unexpectedKey !== undefined)
10
+ throw invalidPlugin(`Unsupported manifest field: \`${unexpectedKey}\`.`);
11
+ const name = record['name'];
12
+ const version = record['version'];
13
+ const description = optionalString(record, 'description');
14
+ const skillsDirectory = optionalString(record, 'skills');
15
+ const agentsDirectory = optionalString(record, 'agents');
16
+ const hooksDirectory = optionalString(record, 'hooks');
17
+ const mcpConfig = optionalString(record, 'mcp');
18
+ if (typeof name !== 'string' || !/^@[a-z0-9][a-z0-9-]{0,31}\/[a-z0-9][a-z0-9-]{0,63}$/.test(name))
19
+ throw invalidPlugin('Plugin name must use a lowercase namespace/name.');
20
+ if (typeof version !== 'string' || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version))
21
+ throw invalidPlugin('Plugin version must be semver-like.');
22
+ return {
23
+ name,
24
+ version,
25
+ ...(description === undefined ? {} : { description }),
26
+ directory,
27
+ ...(skillsDirectory === undefined ? {} : { skillsDirectory }),
28
+ ...(agentsDirectory === undefined ? {} : { agentsDirectory }),
29
+ ...(hooksDirectory === undefined ? {} : { hooksDirectory }),
30
+ ...(mcpConfig === undefined ? {} : { mcpConfig }),
31
+ };
32
+ }
33
+ function optionalString(record, field) {
34
+ const value = record[field];
35
+ if (value === undefined)
36
+ return undefined;
37
+ if (typeof value !== 'string')
38
+ throw invalidPlugin(`Manifest field \`${field}\` must be a string.`);
39
+ return value;
40
+ }
41
+ function invalidPlugin(message) {
42
+ return new CliError(CLI_ERROR_CODES.PLUGIN_MANIFEST_INVALID, message, { category: 'extension', userMessage: `Invalid plugin: ${message}` });
43
+ }
@@ -0,0 +1,10 @@
1
+ export interface SkillManifest {
2
+ name: string;
3
+ description: string;
4
+ userInvocable: boolean;
5
+ modelInvocable: boolean;
6
+ allowedTools: readonly string[];
7
+ directory: string;
8
+ body: string;
9
+ }
10
+ export declare function parseSkillDocument(raw: string, directory: string): SkillManifest;
@@ -0,0 +1,51 @@
1
+ import { CliError } from '../errors/cli-error.js';
2
+ import { CLI_ERROR_CODES } from '../errors/error-codes.js';
3
+ export function parseSkillDocument(raw, directory) {
4
+ const normalized = raw.replace(/^\uFEFF/, '');
5
+ if (!normalized.startsWith('---\n') && !normalized.startsWith('---\r\n'))
6
+ throw invalidSkill('Skill must start with YAML frontmatter.');
7
+ const match = normalized.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
8
+ if (match === null)
9
+ throw invalidSkill('Skill frontmatter is not closed.');
10
+ const frontmatter = match[1];
11
+ const body = match[2];
12
+ if (frontmatter === undefined || body === undefined)
13
+ throw invalidSkill('Skill document is incomplete.');
14
+ const fields = parseSimpleFrontmatter(frontmatter);
15
+ const name = fields['name'];
16
+ const description = fields['description'];
17
+ if (name === undefined || description === undefined)
18
+ throw invalidSkill('Skill requires name and description.');
19
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(name))
20
+ throw invalidSkill('Skill name must be lowercase kebab-case.');
21
+ return {
22
+ name,
23
+ description,
24
+ userInvocable: fields['user-invocable'] !== 'false',
25
+ modelInvocable: fields['model-invocable'] !== 'false',
26
+ allowedTools: parseList(fields['allowed-tools']),
27
+ directory,
28
+ body: body.trim(),
29
+ };
30
+ }
31
+ function parseSimpleFrontmatter(raw) {
32
+ const result = {};
33
+ for (const line of raw.split(/\r?\n/)) {
34
+ const separator = line.indexOf(':');
35
+ if (separator <= 0)
36
+ continue;
37
+ const key = line.slice(0, separator).trim().toLowerCase();
38
+ const value = line.slice(separator + 1).trim().replace(/^['"]|['"]$/g, '');
39
+ result[key] = value;
40
+ }
41
+ return result;
42
+ }
43
+ function parseList(value) {
44
+ if (value === undefined || value.trim().length === 0)
45
+ return [];
46
+ const normalized = value.trim().replace(/^\[|\]$/g, '');
47
+ return normalized.split(',').map((item) => item.trim().replace(/^['"]|['"]$/g, '')).filter(Boolean);
48
+ }
49
+ function invalidSkill(message) {
50
+ return new CliError(CLI_ERROR_CODES.SKILL_FRONTMATTER_INVALID, message, { category: 'extension', userMessage: `Invalid skill: ${message}` });
51
+ }
@@ -0,0 +1,21 @@
1
+ export type FileDiffLineKind = 'context' | 'addition' | 'deletion';
2
+ export interface FileDiffLine {
3
+ readonly kind: FileDiffLineKind;
4
+ readonly text: string;
5
+ readonly oldLine?: number;
6
+ readonly newLine?: number;
7
+ }
8
+ export interface FileChangeDiff {
9
+ readonly path: string;
10
+ readonly lines: readonly FileDiffLine[];
11
+ readonly additions: number;
12
+ readonly deletions: number;
13
+ readonly truncated: boolean;
14
+ }
15
+ export interface FileDiffOptions {
16
+ maxLines?: number;
17
+ maxInputLines?: number;
18
+ truncated?: boolean;
19
+ }
20
+ /** Creates a bounded, deterministic line diff suitable for terminal rendering. */
21
+ export declare function createFileChangeDiff(path: string, before: string, after: string, options?: FileDiffOptions): FileChangeDiff;
@@ -0,0 +1,60 @@
1
+ /** Creates a bounded, deterministic line diff suitable for terminal rendering. */
2
+ export function createFileChangeDiff(path, before, after, options = {}) {
3
+ const maxInputLines = options.maxInputLines ?? 400;
4
+ const maxLines = options.maxLines ?? 240;
5
+ const oldLines = splitLines(before);
6
+ const newLines = splitLines(after);
7
+ const inputTruncated = oldLines.length > maxInputLines || newLines.length > maxInputLines;
8
+ const boundedOld = oldLines.slice(0, maxInputLines);
9
+ const boundedNew = newLines.slice(0, maxInputLines);
10
+ const matrix = buildLcsMatrix(boundedOld, boundedNew);
11
+ const lines = [];
12
+ let oldLine = 1;
13
+ let newLine = 1;
14
+ let oldIndex = 0;
15
+ let newIndex = 0;
16
+ while (oldIndex < boundedOld.length || newIndex < boundedNew.length) {
17
+ if (oldIndex < boundedOld.length && newIndex < boundedNew.length && boundedOld[oldIndex] === boundedNew[newIndex]) {
18
+ lines.push({ kind: 'context', text: boundedOld[oldIndex] ?? '', oldLine, newLine });
19
+ oldIndex += 1;
20
+ newIndex += 1;
21
+ oldLine += 1;
22
+ newLine += 1;
23
+ }
24
+ else if (newIndex < boundedNew.length && (oldIndex === boundedOld.length || (matrix[oldIndex + 1]?.[newIndex] ?? 0) < (matrix[oldIndex]?.[newIndex + 1] ?? 0))) {
25
+ lines.push({ kind: 'addition', text: boundedNew[newIndex] ?? '', newLine });
26
+ newIndex += 1;
27
+ newLine += 1;
28
+ }
29
+ else {
30
+ lines.push({ kind: 'deletion', text: boundedOld[oldIndex] ?? '', oldLine });
31
+ oldIndex += 1;
32
+ oldLine += 1;
33
+ }
34
+ }
35
+ const truncated = options.truncated === true || inputTruncated || lines.length > maxLines;
36
+ const visibleLines = lines.slice(0, maxLines);
37
+ return {
38
+ path,
39
+ lines: visibleLines,
40
+ additions: visibleLines.filter((line) => line.kind === 'addition').length,
41
+ deletions: visibleLines.filter((line) => line.kind === 'deletion').length,
42
+ truncated,
43
+ };
44
+ }
45
+ function splitLines(value) {
46
+ if (value.length === 0)
47
+ return [];
48
+ return value.replace(/\r\n/gu, '\n').split('\n');
49
+ }
50
+ function buildLcsMatrix(oldLines, newLines) {
51
+ const matrix = Array.from({ length: oldLines.length + 1 }, () => Array(newLines.length + 1).fill(0));
52
+ for (let oldIndex = oldLines.length - 1; oldIndex >= 0; oldIndex -= 1) {
53
+ for (let newIndex = newLines.length - 1; newIndex >= 0; newIndex -= 1) {
54
+ matrix[oldIndex][newIndex] = oldLines[oldIndex] === newLines[newIndex]
55
+ ? (matrix[oldIndex + 1]?.[newIndex + 1] ?? 0) + 1
56
+ : Math.max(matrix[oldIndex + 1]?.[newIndex] ?? 0, matrix[oldIndex]?.[newIndex + 1] ?? 0);
57
+ }
58
+ }
59
+ return matrix;
60
+ }
@@ -0,0 +1,23 @@
1
+ /** Mirrors the gateway's public media validation contract. The gateway remains authoritative. */
2
+ export declare const GATEWAY_MEDIA_LIMITS: {
3
+ readonly imagePromptCharacters: 32000;
4
+ readonly imageCount: 16;
5
+ readonly imageEditFileBytes: number;
6
+ readonly imageEditMaskBytes: number;
7
+ readonly imageEditTotalBytes: number;
8
+ readonly audioUploadBytes: number;
9
+ readonly speechInputCharacters: 4096;
10
+ readonly speechInstructionsCharacters: 4096;
11
+ readonly speechVoiceCharacters: 64;
12
+ readonly audioPromptCharacters: 4096;
13
+ readonly transcriptionLanguageCharacters: 10;
14
+ };
15
+ /** The installed SDK buffers binary media responses to this exact upper bound. */
16
+ export declare const SDK_BINARY_MEDIA_RESPONSE_BYTES: number;
17
+ type Flags = ReadonlyMap<string, string | boolean>;
18
+ export declare function validateMediaCommandOptions(action: string, positionals: readonly string[], flags: Flags): void;
19
+ export declare function validateImageEditInputCount(paths: readonly string[]): void;
20
+ export declare function validateUploadSize(bytes: number, maximum: number, label: string): void;
21
+ export declare function validateImageEditTotalSize(bytes: number): void;
22
+ export declare function formatByteLimit(bytes: number): string;
23
+ export {};
@@ -0,0 +1,163 @@
1
+ import { CliError } from '../errors/cli-error.js';
2
+ import { CLI_ERROR_CODES } from '../errors/error-codes.js';
3
+ const KILOBYTE = 1_000;
4
+ const MEGABYTE = 1_000_000;
5
+ /** Mirrors the gateway's public media validation contract. The gateway remains authoritative. */
6
+ export const GATEWAY_MEDIA_LIMITS = {
7
+ imagePromptCharacters: 32_000,
8
+ imageCount: 16,
9
+ imageEditFileBytes: 47 * MEGABYTE,
10
+ imageEditMaskBytes: 4 * MEGABYTE,
11
+ imageEditTotalBytes: 128 * MEGABYTE,
12
+ audioUploadBytes: 50 * MEGABYTE,
13
+ speechInputCharacters: 4_096,
14
+ speechInstructionsCharacters: 4_096,
15
+ speechVoiceCharacters: 64,
16
+ audioPromptCharacters: 4_096,
17
+ transcriptionLanguageCharacters: 10,
18
+ };
19
+ /** The installed SDK buffers binary media responses to this exact upper bound. */
20
+ export const SDK_BINARY_MEDIA_RESPONSE_BYTES = 50 * 1024 * 1024;
21
+ export function validateMediaCommandOptions(action, positionals, flags) {
22
+ validateOutputOptions(flags);
23
+ if (action === 'image.generate' || action === 'image.edit')
24
+ validateImageOptions(positionals, flags);
25
+ if (action === 'image.edit')
26
+ validateImageEditOptions(flags);
27
+ if (action === 'audio.speech')
28
+ validateSpeechOptions(positionals, flags);
29
+ if (action === 'audio.transcribe')
30
+ validateAudioUploadOptions(flags, true);
31
+ if (action === 'audio.translate')
32
+ validateAudioUploadOptions(flags, false);
33
+ if (action === 'video.generate')
34
+ validateVideoOptions(flags);
35
+ }
36
+ export function validateImageEditInputCount(paths) {
37
+ if (paths.length === 0)
38
+ throw invalid('`--image` requires at least one workspace image path.');
39
+ if (paths.length > GATEWAY_MEDIA_LIMITS.imageCount)
40
+ throw invalid(`Image edits support at most ${GATEWAY_MEDIA_LIMITS.imageCount} input images.`);
41
+ }
42
+ export function validateUploadSize(bytes, maximum, label) {
43
+ if (bytes > 0 && bytes <= maximum)
44
+ return;
45
+ throw invalid(`${label} must be between 1 byte and ${formatByteLimit(maximum)}.`);
46
+ }
47
+ export function validateImageEditTotalSize(bytes) {
48
+ if (bytes <= GATEWAY_MEDIA_LIMITS.imageEditTotalBytes)
49
+ return;
50
+ throw invalid(`Image edit uploads must not exceed ${formatByteLimit(GATEWAY_MEDIA_LIMITS.imageEditTotalBytes)} in total.`);
51
+ }
52
+ export function formatByteLimit(bytes) {
53
+ if (bytes >= MEGABYTE)
54
+ return `${bytes / MEGABYTE} MB`;
55
+ if (bytes >= KILOBYTE)
56
+ return `${bytes / KILOBYTE} KB`;
57
+ return `${bytes} bytes`;
58
+ }
59
+ function validateOutputOptions(flags) {
60
+ const out = value(flags, 'out');
61
+ if (enabled(flags, 'force') && out === undefined)
62
+ throw invalid('`--force` is only valid with `--out`.');
63
+ }
64
+ function validateImageOptions(positionals, flags) {
65
+ validateLength(requiredPrompt(positionals, 'image'), GATEWAY_MEDIA_LIMITS.imagePromptCharacters, 'Image prompt');
66
+ const count = integer(flags, 'n');
67
+ if (count !== undefined && (count < 1 || count > GATEWAY_MEDIA_LIMITS.imageCount))
68
+ throw invalid(`--n must be an integer between 1 and ${GATEWAY_MEDIA_LIMITS.imageCount}.`);
69
+ if (count !== undefined && count > 1 && value(flags, 'out') !== undefined)
70
+ throw invalid('--out can only be used when exactly one image artifact is requested. Use --out-dir instead.');
71
+ const size = value(flags, 'size');
72
+ if (size !== undefined && size !== 'auto' && !/^\d{2,4}x\d{2,4}$/u.test(size))
73
+ throw invalid('--size must be `auto` or WIDTHxHEIGHT.');
74
+ if (size !== undefined && size !== 'auto')
75
+ validateImageDimensions(size);
76
+ const format = value(flags, 'output-format');
77
+ const compression = integer(flags, 'output-compression');
78
+ if (compression !== undefined && (compression < 0 || compression > 100))
79
+ throw invalid('--output-compression must be an integer between 0 and 100.');
80
+ if (compression !== undefined && format !== 'jpeg' && format !== 'webp')
81
+ throw invalid('--output-compression requires --output-format jpeg or webp.');
82
+ validateLength(value(flags, 'moderation'), 64, 'Moderation value');
83
+ validateLength(value(flags, 'user'), 255, 'User value');
84
+ }
85
+ function validateImageEditOptions(flags) {
86
+ if (value(flags, 'image') === undefined)
87
+ throw invalid('Missing required option --image.');
88
+ }
89
+ function validateSpeechOptions(positionals, flags) {
90
+ validateLength(requiredPrompt(positionals, 'speech'), GATEWAY_MEDIA_LIMITS.speechInputCharacters, 'Speech input');
91
+ validateLength(required(flags, 'voice'), GATEWAY_MEDIA_LIMITS.speechVoiceCharacters, 'Voice');
92
+ validateLength(value(flags, 'instructions'), GATEWAY_MEDIA_LIMITS.speechInstructionsCharacters, 'Speech instructions');
93
+ const speed = number(flags, 'speed');
94
+ if (speed !== undefined && (speed < 0.25 || speed > 4))
95
+ throw invalid('--speed must be between 0.25 and 4.');
96
+ }
97
+ function validateAudioUploadOptions(flags, transcription) {
98
+ validateLength(value(flags, 'prompt'), GATEWAY_MEDIA_LIMITS.audioPromptCharacters, 'Audio prompt');
99
+ const temperature = number(flags, 'temperature');
100
+ if (temperature !== undefined && (temperature < 0 || temperature > 1))
101
+ throw invalid('--temperature must be between 0 and 1.');
102
+ if (!transcription)
103
+ return;
104
+ validateLength(value(flags, 'language'), GATEWAY_MEDIA_LIMITS.transcriptionLanguageCharacters, 'Language code');
105
+ if (value(flags, 'timestamp-granularities') !== undefined && value(flags, 'response-format') !== 'verbose_json')
106
+ throw invalid('--timestamp-granularities requires --response-format verbose_json.');
107
+ }
108
+ function validateVideoOptions(flags) {
109
+ if (enabled(flags, 'no-wait') && (value(flags, 'out') !== undefined || value(flags, 'out-dir') !== undefined || enabled(flags, 'force'))) {
110
+ throw invalid('--no-wait cannot be combined with output options. Use video download after the operation completes.');
111
+ }
112
+ }
113
+ function validateImageDimensions(value) {
114
+ const [widthRaw, heightRaw] = value.split('x');
115
+ const width = Number(widthRaw);
116
+ const height = Number(heightRaw);
117
+ if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1 || width > 4_096 || height > 4_096 || Math.max(width, height) / Math.min(width, height) > 3 || width % 16 !== 0 || height % 16 !== 0) {
118
+ throw invalid('--size must use positive dimensions up to 4096px, a maximum 3:1 aspect ratio, and multiples of 16.');
119
+ }
120
+ }
121
+ function requiredPrompt(positionals, label) {
122
+ const prompt = positionals.join(' ').trim();
123
+ if (prompt.length === 0)
124
+ throw invalid(`A prompt is required for ${label}.`);
125
+ return prompt;
126
+ }
127
+ function required(flags, name) {
128
+ const result = value(flags, name);
129
+ if (result === undefined)
130
+ throw invalid(`Missing required option --${name}.`);
131
+ return result;
132
+ }
133
+ function validateLength(text, maximum, label) {
134
+ if (text !== undefined && text.length > maximum)
135
+ throw invalid(`${label} must not exceed ${maximum} characters.`);
136
+ }
137
+ function integer(flags, name) {
138
+ const raw = value(flags, name);
139
+ if (raw === undefined)
140
+ return undefined;
141
+ if (!/^\d+$/u.test(raw) || !Number.isSafeInteger(Number(raw)))
142
+ throw invalid(`--${name} must be an integer.`);
143
+ return Number(raw);
144
+ }
145
+ function number(flags, name) {
146
+ const raw = value(flags, name);
147
+ if (raw === undefined)
148
+ return undefined;
149
+ const result = Number(raw);
150
+ if (!Number.isFinite(result))
151
+ throw invalid(`--${name} must be a finite number.`);
152
+ return result;
153
+ }
154
+ function value(flags, name) {
155
+ const candidate = flags.get(name);
156
+ return typeof candidate === 'string' && candidate.trim().length > 0 ? candidate.trim() : undefined;
157
+ }
158
+ function enabled(flags, name) {
159
+ return flags.get(name) === true || flags.get(name) === 'true';
160
+ }
161
+ function invalid(userMessage) {
162
+ return new CliError(CLI_ERROR_CODES.INVALID_ARGUMENT, userMessage, { category: 'media', userMessage });
163
+ }
@@ -0,0 +1,28 @@
1
+ export type MediaArtifactKind = 'image' | 'speech' | 'transcription' | 'translation' | 'video';
2
+ export interface MediaBinary {
3
+ readonly bytes: Uint8Array;
4
+ readonly contentType?: string;
5
+ }
6
+ export interface GeneratedImage {
7
+ readonly base64?: string;
8
+ readonly url?: string;
9
+ readonly revisedPrompt?: string;
10
+ }
11
+ export interface VideoOperation {
12
+ readonly id: string;
13
+ readonly done: boolean;
14
+ readonly errorMessage?: string;
15
+ }
16
+ export interface MediaArtifactRequest {
17
+ readonly kind: MediaArtifactKind;
18
+ readonly source: string;
19
+ readonly extension: string;
20
+ /** Filename stem without extension; the artifact store appends extension. */
21
+ readonly out?: string;
22
+ readonly outDir?: string;
23
+ readonly force: boolean;
24
+ }
25
+ export interface StoredMediaArtifact {
26
+ readonly path: string;
27
+ readonly bytes: number;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export interface MediaExecutionPolicy {
2
+ readonly videoPollIntervalMs: number;
3
+ readonly videoWaitTimeoutMs: number;
4
+ readonly downloadTimeoutMs: number;
5
+ }
6
+ type Environment = Readonly<Record<string, string | undefined>>;
7
+ /** CLI-owned local resource policy. It does not alter gateway or SDK contracts. */
8
+ export declare function resolveMediaExecutionPolicy(environment?: Environment): MediaExecutionPolicy;
9
+ export {};
@@ -0,0 +1,31 @@
1
+ import { CliError } from '../errors/cli-error.js';
2
+ import { CLI_ERROR_CODES } from '../errors/error-codes.js';
3
+ const DEFAULT_VIDEO_POLL_INTERVAL_MS = 5_000;
4
+ const DEFAULT_VIDEO_WAIT_TIMEOUT_MS = 20 * 60 * 1_000;
5
+ const DEFAULT_MEDIA_DOWNLOAD_TIMEOUT_MS = 60_000;
6
+ /** CLI-owned local resource policy. It does not alter gateway or SDK contracts. */
7
+ export function resolveMediaExecutionPolicy(environment = process.env) {
8
+ const videoPollIntervalMs = readPositiveInteger(environment, 'LOTAGATE_VIDEO_POLL_INTERVAL_MS', DEFAULT_VIDEO_POLL_INTERVAL_MS);
9
+ const videoWaitTimeoutMs = readPositiveInteger(environment, 'LOTAGATE_VIDEO_WAIT_TIMEOUT_MS', DEFAULT_VIDEO_WAIT_TIMEOUT_MS);
10
+ if (videoWaitTimeoutMs < videoPollIntervalMs)
11
+ throw invalidPolicy('LOTAGATE_VIDEO_WAIT_TIMEOUT_MS must not be smaller than LOTAGATE_VIDEO_POLL_INTERVAL_MS.');
12
+ return {
13
+ videoPollIntervalMs,
14
+ videoWaitTimeoutMs,
15
+ downloadTimeoutMs: readPositiveInteger(environment, 'LOTAGATE_MEDIA_DOWNLOAD_TIMEOUT_MS', DEFAULT_MEDIA_DOWNLOAD_TIMEOUT_MS),
16
+ };
17
+ }
18
+ function readPositiveInteger(environment, name, fallback) {
19
+ const raw = environment[name];
20
+ if (raw === undefined || raw.trim().length === 0)
21
+ return fallback;
22
+ if (!/^\d+$/u.test(raw))
23
+ throw invalidPolicy(`${name} must be a positive integer.`);
24
+ const value = Number(raw);
25
+ if (!Number.isSafeInteger(value) || value <= 0)
26
+ throw invalidPolicy(`${name} must be a positive integer.`);
27
+ return value;
28
+ }
29
+ function invalidPolicy(userMessage) {
30
+ return new CliError(CLI_ERROR_CODES.CONFIG_SCHEMA_INVALID, userMessage, { category: 'config', userMessage });
31
+ }
@@ -0,0 +1,58 @@
1
+ export type GoalStatus = 'active' | 'paused' | 'completed' | 'blocked' | 'budget_limited' | 'usage_limited';
2
+ export type GoalDecision = 'continue' | 'complete' | 'blocked' | 'budget_limited' | 'usage_limited';
3
+ export interface GoalEvaluation {
4
+ decision: GoalDecision;
5
+ reason: string;
6
+ evidence: readonly string[];
7
+ timestamp: string;
8
+ evaluatorModel?: string;
9
+ }
10
+ export interface GoalUsage {
11
+ inputTokens: number;
12
+ outputTokens: number;
13
+ totalTokens: number;
14
+ modelCalls: number;
15
+ estimated: boolean;
16
+ }
17
+ export interface GoalUsageDelta {
18
+ inputTokens?: number;
19
+ outputTokens?: number;
20
+ totalTokens?: number;
21
+ modelCalls?: number;
22
+ estimated?: boolean;
23
+ }
24
+ export interface GoalState {
25
+ id: string;
26
+ sessionId: string;
27
+ objective: string;
28
+ status: GoalStatus;
29
+ createdAt: string;
30
+ updatedAt: string;
31
+ startedAt: string;
32
+ turns: number;
33
+ evaluatorRuns: number;
34
+ usage: GoalUsage;
35
+ tokenBudget?: number;
36
+ maxTurns?: number;
37
+ maxDurationMs?: number;
38
+ lastEvaluation?: GoalEvaluation;
39
+ lastError?: string;
40
+ }
41
+ export interface CreateGoalInput {
42
+ objective: string;
43
+ tokenBudget?: number;
44
+ maxTurns?: number;
45
+ maxDurationMs?: number;
46
+ }
47
+ export declare function validateGoalInput(input: CreateGoalInput): CreateGoalInput;
48
+ /** Identifies journal events that must carry a complete goal snapshot. */
49
+ export declare function isGoalEventType(value: string): boolean;
50
+ /** Validates the complete durable goal state before it controls execution limits. */
51
+ export declare function isGoalState(value: unknown): value is GoalState;
52
+ /** Validates the durable evaluator result embedded in a goal snapshot. */
53
+ export declare function isGoalEvaluation(value: unknown): value is GoalEvaluation;
54
+ /** Validates the data payload written by a durable goal lifecycle event. */
55
+ export declare function isPersistedGoalEventData(value: unknown): boolean;
56
+ export declare function transitionGoal(state: GoalState, status: GoalStatus): GoalState;
57
+ export declare function addGoalUsage(current: GoalUsage, delta: GoalUsageDelta): GoalUsage;
58
+ export declare const EMPTY_GOAL_USAGE: GoalUsage;
@@ -0,0 +1,113 @@
1
+ import { RESOURCE_LIMITS } from '../runtime/resource-limits.js';
2
+ const GOAL_EVENT_TYPES = new Set([
3
+ 'goal.created', 'goal.replaced', 'goal.paused', 'goal.resumed', 'goal.evaluated',
4
+ 'goal.completed', 'goal.blocked', 'goal.budget_limited', 'goal.usage_limited',
5
+ 'goal.usage_recorded', 'goal.cleared', 'goal.turn.started',
6
+ ]);
7
+ export function validateGoalInput(input) {
8
+ const objective = input.objective.trim();
9
+ if (objective.length === 0 || objective.length > 16_384 || /[\0\r\n]/u.test(objective)) {
10
+ throw new Error('Goal objective must contain between 1 and 16384 printable characters.');
11
+ }
12
+ for (const [name, value] of Object.entries(input)) {
13
+ if (name === 'objective' || value === undefined)
14
+ continue;
15
+ if (!Number.isSafeInteger(value) || value <= 0)
16
+ throw new Error(`Goal limit ${name} must be a positive integer.`);
17
+ }
18
+ if (input.maxDurationMs !== undefined && input.maxDurationMs > RESOURCE_LIMITS.goalMaximumMaxDurationMs) {
19
+ throw new Error('Goal maxDurationMs cannot exceed 8 hours.');
20
+ }
21
+ return { objective, ...(input.tokenBudget === undefined ? {} : { tokenBudget: input.tokenBudget }), ...(input.maxTurns === undefined ? {} : { maxTurns: input.maxTurns }), ...(input.maxDurationMs === undefined ? {} : { maxDurationMs: input.maxDurationMs }) };
22
+ }
23
+ /** Identifies journal events that must carry a complete goal snapshot. */
24
+ export function isGoalEventType(value) {
25
+ return GOAL_EVENT_TYPES.has(value);
26
+ }
27
+ /** Validates the complete durable goal state before it controls execution limits. */
28
+ export function isGoalState(value) {
29
+ if (!isRecord(value))
30
+ return false;
31
+ return typeof value['id'] === 'string' && typeof value['sessionId'] === 'string' && isValidGoalObjective(value['objective'])
32
+ && isGoalStatus(value['status']) && isTimestamp(value['createdAt']) && isTimestamp(value['updatedAt']) && isTimestamp(value['startedAt'])
33
+ && isNonNegativeSafeInteger(value['turns']) && isNonNegativeSafeInteger(value['evaluatorRuns']) && isGoalUsage(value['usage'])
34
+ && isOptionalPositiveSafeInteger(value['tokenBudget']) && isOptionalPositiveSafeInteger(value['maxTurns'])
35
+ && isOptionalDuration(value['maxDurationMs']) && isOptionalGoalEvaluation(value['lastEvaluation'])
36
+ && (value['lastError'] === undefined || (typeof value['lastError'] === 'string' && Buffer.byteLength(value['lastError'], 'utf8') <= RESOURCE_LIMITS.goalReasonBytes));
37
+ }
38
+ /** Validates the durable evaluator result embedded in a goal snapshot. */
39
+ export function isGoalEvaluation(value) {
40
+ if (!isRecord(value))
41
+ return false;
42
+ return isGoalDecision(value['decision']) && typeof value['reason'] === 'string' && Buffer.byteLength(value['reason'], 'utf8') <= RESOURCE_LIMITS.goalReasonBytes
43
+ && Array.isArray(value['evidence']) && value['evidence'].length <= RESOURCE_LIMITS.goalEvidenceItems
44
+ && value['evidence'].every((item) => typeof item === 'string' && Buffer.byteLength(item, 'utf8') <= RESOURCE_LIMITS.goalEvidenceBytes)
45
+ && isTimestamp(value['timestamp'])
46
+ && (value['evaluatorModel'] === undefined || typeof value['evaluatorModel'] === 'string');
47
+ }
48
+ /** Validates the data payload written by a durable goal lifecycle event. */
49
+ export function isPersistedGoalEventData(value) {
50
+ if (!isRecord(value) || !isGoalState(value['goal']))
51
+ return false;
52
+ return value['evaluation'] === undefined || isGoalEvaluation(value['evaluation']);
53
+ }
54
+ export function transitionGoal(state, status) {
55
+ if (state.status === 'completed' || state.status === 'blocked' || state.status === 'budget_limited' || state.status === 'usage_limited') {
56
+ throw new Error(`Cannot transition a terminal goal from ${state.status}.`);
57
+ }
58
+ if (status === 'active' && state.status !== 'paused')
59
+ throw new Error(`Cannot resume a goal from ${state.status}.`);
60
+ if (status === 'paused' && state.status !== 'active')
61
+ throw new Error(`Cannot pause a goal from ${state.status}.`);
62
+ return { ...state, status, updatedAt: new Date().toISOString() };
63
+ }
64
+ export function addGoalUsage(current, delta) {
65
+ const inputTokens = nonNegative(current.inputTokens + (delta.inputTokens ?? 0));
66
+ const outputTokens = nonNegative(current.outputTokens + (delta.outputTokens ?? 0));
67
+ const totalTokens = nonNegative(current.totalTokens + (delta.totalTokens ?? (delta.inputTokens ?? 0) + (delta.outputTokens ?? 0)));
68
+ return {
69
+ inputTokens,
70
+ outputTokens,
71
+ totalTokens,
72
+ modelCalls: nonNegative(current.modelCalls + (delta.modelCalls ?? 0)),
73
+ estimated: current.estimated || delta.estimated === true,
74
+ };
75
+ }
76
+ export const EMPTY_GOAL_USAGE = Object.freeze({ inputTokens: 0, outputTokens: 0, totalTokens: 0, modelCalls: 0, estimated: false });
77
+ function nonNegative(value) {
78
+ return Number.isSafeInteger(value) && value >= 0 ? value : Number.MAX_SAFE_INTEGER;
79
+ }
80
+ function isRecord(value) {
81
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
82
+ }
83
+ function isGoalStatus(value) {
84
+ return value === 'active' || value === 'paused' || value === 'completed' || value === 'blocked' || value === 'budget_limited' || value === 'usage_limited';
85
+ }
86
+ function isGoalDecision(value) {
87
+ return value === 'continue' || value === 'complete' || value === 'blocked' || value === 'budget_limited' || value === 'usage_limited';
88
+ }
89
+ function isGoalUsage(value) {
90
+ if (!isRecord(value))
91
+ return false;
92
+ return isNonNegativeSafeInteger(value['inputTokens']) && isNonNegativeSafeInteger(value['outputTokens'])
93
+ && isNonNegativeSafeInteger(value['totalTokens']) && isNonNegativeSafeInteger(value['modelCalls'])
94
+ && typeof value['estimated'] === 'boolean';
95
+ }
96
+ function isOptionalGoalEvaluation(value) {
97
+ return value === undefined || isGoalEvaluation(value);
98
+ }
99
+ function isOptionalPositiveSafeInteger(value) {
100
+ return value === undefined || (typeof value === 'number' && Number.isSafeInteger(value) && value > 0);
101
+ }
102
+ function isOptionalDuration(value) {
103
+ return value === undefined || (typeof value === 'number' && Number.isSafeInteger(value) && value > 0 && value <= RESOURCE_LIMITS.goalMaximumMaxDurationMs);
104
+ }
105
+ function isNonNegativeSafeInteger(value) {
106
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
107
+ }
108
+ function isTimestamp(value) {
109
+ return typeof value === 'string' && Number.isFinite(Date.parse(value));
110
+ }
111
+ function isValidGoalObjective(value) {
112
+ return typeof value === 'string' && value.trim().length > 0 && value.length <= RESOURCE_LIMITS.goalObjectiveBytes && !/[\0\r\n]/u.test(value);
113
+ }
@@ -0,0 +1,2 @@
1
+ /** Returns a concise, stable display identity for one parent-session subagent. */
2
+ export declare function subagentDisplayName(sequence: number): string;
@@ -0,0 +1,8 @@
1
+ const DISPLAY_NAMES = ['Atlas', 'Nova', 'Orion', 'Sage', 'Lyra', 'Ember', 'Aster', 'Coda'];
2
+ /** Returns a concise, stable display identity for one parent-session subagent. */
3
+ export function subagentDisplayName(sequence) {
4
+ const normalized = Math.max(0, Math.floor(sequence));
5
+ const base = DISPLAY_NAMES[normalized % DISPLAY_NAMES.length] ?? 'Agent';
6
+ const generation = Math.floor(normalized / DISPLAY_NAMES.length) + 1;
7
+ return generation === 1 ? base : `${base} ${generation}`;
8
+ }