@lotagate/cli 0.1.23 → 0.1.25

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 (607) hide show
  1. package/README.md +70 -3
  2. package/SECURITY.md +2 -0
  3. package/dist/application/agent/agent-history.d.ts +3 -0
  4. package/dist/application/agent/agent-history.js +5 -0
  5. package/dist/application/agent/agent-input-context.d.ts +12 -0
  6. package/dist/application/agent/agent-input-context.js +5 -0
  7. package/dist/application/agent/agent-limit.d.ts +3 -0
  8. package/dist/application/agent/agent-limit.js +1 -0
  9. package/dist/application/agent/agent-run-tracker.d.ts +30 -0
  10. package/dist/application/agent/agent-run-tracker.js +1 -0
  11. package/dist/application/agent/agent-runtime-context.d.ts +22 -0
  12. package/dist/application/agent/agent-runtime-context.js +1 -0
  13. package/dist/application/agent/agent-session-store.d.ts +19 -0
  14. package/dist/application/agent/agent-session-store.js +6 -0
  15. package/dist/application/agent/capability-profile.d.ts +55 -0
  16. package/dist/application/agent/capability-profile.js +1 -0
  17. package/dist/application/agent/cli-agent-execution-service.d.ts +110 -0
  18. package/dist/application/agent/cli-agent-execution-service.js +1 -0
  19. package/dist/application/agent/cli-agent-run-request.d.ts +12 -0
  20. package/dist/application/agent/cli-agent-run-request.js +0 -0
  21. package/dist/application/agent/context-compaction-persistence.d.ts +8 -0
  22. package/dist/application/agent/context-compaction-persistence.js +1 -0
  23. package/dist/application/agent/context-compaction.d.ts +21 -0
  24. package/dist/application/agent/context-compaction.js +7 -0
  25. package/dist/application/agent/interactive-agent-guidance.d.ts +5 -0
  26. package/dist/application/agent/interactive-agent-guidance.js +2 -0
  27. package/dist/application/agent/prompt-data-safety.d.ts +14 -0
  28. package/dist/application/agent/prompt-data-safety.js +4 -0
  29. package/dist/application/agent/scoped-tool-executor.d.ts +13 -0
  30. package/dist/application/agent/scoped-tool-executor.js +1 -0
  31. package/dist/application/agent/tool-catalog.d.ts +14 -0
  32. package/dist/application/agent/tool-catalog.js +1 -0
  33. package/dist/application/agent/tool-display.d.ts +7 -0
  34. package/dist/application/agent/tool-display.js +1 -0
  35. package/dist/application/agent/tool-hook-lifecycle.d.ts +19 -0
  36. package/dist/application/agent/tool-hook-lifecycle.js +1 -0
  37. package/dist/application/auth/authentication-service.d.ts +20 -0
  38. package/dist/application/auth/authentication-service.js +1 -0
  39. package/dist/application/chat/chat-service.d.ts +12 -0
  40. package/dist/application/chat/chat-service.js +1 -0
  41. package/dist/application/chat/pending-attachment-store.d.ts +12 -0
  42. package/dist/application/chat/pending-attachment-store.js +1 -0
  43. package/dist/application/commands/application-command-executor.d.ts +23 -0
  44. package/dist/application/commands/application-command-executor.js +3 -0
  45. package/dist/application/commands/cli-args.d.ts +6 -0
  46. package/dist/application/commands/cli-args.js +1 -0
  47. package/dist/application/commands/cli-command-services.d.ts +17 -0
  48. package/dist/application/commands/cli-command-services.js +33 -0
  49. package/dist/application/commands/command-cancellation.d.ts +6 -0
  50. package/dist/application/commands/command-cancellation.js +1 -0
  51. package/dist/application/commands/command-catalog.d.ts +6 -0
  52. package/dist/application/commands/command-catalog.js +1 -0
  53. package/dist/application/commands/command-contract.d.ts +60 -0
  54. package/dist/application/commands/command-contract.js +0 -0
  55. package/dist/application/commands/command-hints.d.ts +9 -0
  56. package/dist/application/commands/command-hints.js +1 -0
  57. package/dist/application/commands/command-output.d.ts +4 -0
  58. package/dist/application/commands/command-output.js +0 -0
  59. package/dist/application/commands/command-parser.d.ts +10 -0
  60. package/dist/application/commands/command-parser.js +1 -0
  61. package/dist/application/commands/command-presentation.d.ts +7 -0
  62. package/dist/application/commands/command-presentation.js +3 -0
  63. package/dist/application/commands/command-registry.d.ts +11 -0
  64. package/dist/application/commands/command-registry.js +1 -0
  65. package/dist/application/commands/command-runtime.d.ts +2 -0
  66. package/dist/application/commands/command-runtime.js +1 -0
  67. package/dist/application/commands/goal-command-handlers.d.ts +3 -0
  68. package/dist/application/commands/goal-command-handlers.js +7 -0
  69. package/dist/application/commands/media-command-handlers.d.ts +9 -0
  70. package/dist/application/commands/media-command-handlers.js +8 -0
  71. package/dist/application/commands/media-command-output.d.ts +11 -0
  72. package/dist/application/commands/media-command-output.js +1 -0
  73. package/dist/application/commands/memory-command-handler.d.ts +29 -0
  74. package/dist/application/commands/memory-command-handler.js +12 -0
  75. package/dist/application/commands/runtime-command-handlers.d.ts +7 -0
  76. package/dist/application/commands/runtime-command-handlers.js +14 -0
  77. package/dist/application/commands/stream-output.d.ts +4 -0
  78. package/dist/application/commands/stream-output.js +1 -0
  79. package/dist/application/commands/utility-commands.d.ts +6 -0
  80. package/dist/application/commands/utility-commands.js +10 -0
  81. package/dist/application/config/execution-config.d.ts +4 -0
  82. package/dist/application/config/execution-config.js +1 -0
  83. package/dist/application/extensions/extension-list-contract.d.ts +18 -0
  84. package/dist/application/extensions/extension-list-contract.js +0 -0
  85. package/dist/application/extensions/extension-list-formatters.d.ts +38 -0
  86. package/dist/application/extensions/extension-list-formatters.js +1 -0
  87. package/dist/application/extensions/extension-list-output.d.ts +3 -0
  88. package/dist/application/extensions/extension-list-output.js +3 -0
  89. package/dist/application/extensions/plugin-contribution-registry.d.ts +31 -0
  90. package/dist/application/extensions/plugin-contribution-registry.js +1 -0
  91. package/dist/application/extensions/plugin-detail-contract.d.ts +25 -0
  92. package/dist/application/extensions/plugin-detail-contract.js +0 -0
  93. package/dist/application/extensions/plugin-detail-service.d.ts +3 -0
  94. package/dist/application/extensions/plugin-detail-service.js +1 -0
  95. package/dist/application/extensions/skill-scope-store.d.ts +23 -0
  96. package/dist/application/extensions/skill-scope-store.js +1 -0
  97. package/dist/application/formatting/compact-number.d.ts +2 -0
  98. package/dist/application/formatting/compact-number.js +1 -0
  99. package/dist/application/formatting/compact-table.d.ts +22 -0
  100. package/dist/application/formatting/compact-table.js +2 -0
  101. package/dist/application/intent/completion-gate.d.ts +6 -0
  102. package/dist/application/intent/completion-gate.js +1 -0
  103. package/dist/application/intent/evidence-ledger.d.ts +21 -0
  104. package/dist/application/intent/evidence-ledger.js +1 -0
  105. package/dist/application/intent/evidence-recording-tool-executor.d.ts +16 -0
  106. package/dist/application/intent/evidence-recording-tool-executor.js +1 -0
  107. package/dist/application/intent/intent-compiler.d.ts +11 -0
  108. package/dist/application/intent/intent-compiler.js +2 -0
  109. package/dist/application/intent/intent-execution-gate.d.ts +11 -0
  110. package/dist/application/intent/intent-execution-gate.js +1 -0
  111. package/dist/application/intent/intent-host-context.d.ts +6 -0
  112. package/dist/application/intent/intent-host-context.js +1 -0
  113. package/dist/application/intent/intent-run-controller.d.ts +56 -0
  114. package/dist/application/intent/intent-run-controller.js +3 -0
  115. package/dist/application/intent/project-policy.d.ts +16 -0
  116. package/dist/application/intent/project-policy.js +1 -0
  117. package/dist/application/media/video-operation-poller.d.ts +5 -0
  118. package/dist/application/media/video-operation-poller.js +1 -0
  119. package/dist/application/memory/memory-capture-policy.d.ts +10 -0
  120. package/dist/application/memory/memory-capture-policy.js +1 -0
  121. package/dist/application/memory/memory-consolidation-service.d.ts +12 -0
  122. package/dist/application/memory/memory-consolidation-service.js +1 -0
  123. package/dist/application/memory/memory-context-assembler.d.ts +24 -0
  124. package/dist/application/memory/memory-context-assembler.js +1 -0
  125. package/dist/application/memory/memory-extractor.d.ts +21 -0
  126. package/dist/application/memory/memory-extractor.js +2 -0
  127. package/dist/application/memory/memory-service.d.ts +34 -0
  128. package/dist/application/memory/memory-service.js +1 -0
  129. package/dist/application/model/cached-model-catalog.d.ts +13 -0
  130. package/dist/application/model/cached-model-catalog.js +1 -0
  131. package/dist/application/model/initial-model-selection.d.ts +10 -0
  132. package/dist/application/model/initial-model-selection.js +1 -0
  133. package/dist/application/model/model-catalog-service.d.ts +6 -0
  134. package/dist/application/model/model-catalog-service.js +1 -0
  135. package/dist/application/model/model-context-window.d.ts +3 -0
  136. package/dist/application/model/model-context-window.js +1 -0
  137. package/dist/application/model/model-response-retry.d.ts +9 -0
  138. package/dist/application/model/model-response-retry.js +1 -0
  139. package/dist/application/orchestration/abortable-wait.d.ts +2 -0
  140. package/dist/application/orchestration/abortable-wait.js +1 -0
  141. package/dist/application/orchestration/cli-subagent-service.d.ts +73 -0
  142. package/dist/application/orchestration/cli-subagent-service.js +13 -0
  143. package/dist/application/orchestration/cli-turn-event-projector.d.ts +15 -0
  144. package/dist/application/orchestration/cli-turn-event-projector.js +1 -0
  145. package/dist/application/orchestration/cli-turn-events.d.ts +83 -0
  146. package/dist/application/orchestration/cli-turn-events.js +1 -0
  147. package/dist/application/orchestration/cli-turn-persistence.d.ts +6 -0
  148. package/dist/application/orchestration/cli-turn-persistence.js +1 -0
  149. package/dist/application/orchestration/goal-evaluator.d.ts +18 -0
  150. package/dist/application/orchestration/goal-evaluator.js +3 -0
  151. package/dist/application/orchestration/goal-input.d.ts +3 -0
  152. package/dist/application/orchestration/goal-input.js +1 -0
  153. package/dist/application/orchestration/goal-output.d.ts +2 -0
  154. package/dist/application/orchestration/goal-output.js +2 -0
  155. package/dist/application/orchestration/goal-runner.d.ts +22 -0
  156. package/dist/application/orchestration/goal-runner.js +10 -0
  157. package/dist/application/orchestration/goal-usage.d.ts +9 -0
  158. package/dist/application/orchestration/goal-usage.js +1 -0
  159. package/dist/application/orchestration/headless-agent-turn.d.ts +35 -0
  160. package/dist/application/orchestration/headless-agent-turn.js +4 -0
  161. package/dist/application/orchestration/subagent-coordinator.d.ts +41 -0
  162. package/dist/application/orchestration/subagent-coordinator.js +1 -0
  163. package/dist/application/orchestration/subagent-handoff.d.ts +3 -0
  164. package/dist/application/orchestration/subagent-handoff.js +3 -0
  165. package/dist/application/orchestration/subagent-tool-executor.d.ts +12 -0
  166. package/dist/application/orchestration/subagent-tool-executor.js +1 -0
  167. package/dist/application/orchestration/task-graph.d.ts +13 -0
  168. package/dist/application/orchestration/task-graph.js +1 -0
  169. package/dist/application/orchestration/task-scheduler.d.ts +18 -0
  170. package/dist/application/orchestration/task-scheduler.js +1 -0
  171. package/dist/application/project/project-trust-service.d.ts +13 -0
  172. package/dist/application/project/project-trust-service.js +1 -0
  173. package/dist/application/project-intelligence/project-intelligence-service.d.ts +14 -0
  174. package/dist/application/project-intelligence/project-intelligence-service.js +1 -0
  175. package/dist/application/protocol/browser-host-tool-executor.d.ts +41 -0
  176. package/dist/application/protocol/browser-host-tool-executor.js +2 -0
  177. package/dist/application/protocol/computer-host-tool-executor.d.ts +42 -0
  178. package/dist/application/protocol/computer-host-tool-executor.js +2 -0
  179. package/dist/application/protocol/desktop-agent-command.d.ts +9 -0
  180. package/dist/application/protocol/desktop-agent-command.js +3 -0
  181. package/dist/application/protocol/desktop-agent-request-parser.d.ts +186 -0
  182. package/dist/application/protocol/desktop-agent-request-parser.js +1 -0
  183. package/dist/application/protocol/desktop-approval-broker.d.ts +16 -0
  184. package/dist/application/protocol/desktop-approval-broker.js +1 -0
  185. package/dist/application/protocol/desktop-attachment-store.d.ts +16 -0
  186. package/dist/application/protocol/desktop-attachment-store.js +1 -0
  187. package/dist/application/protocol/desktop-command-catalog.d.ts +2 -0
  188. package/dist/application/protocol/desktop-command-catalog.js +1 -0
  189. package/dist/application/protocol/desktop-command-contract.d.ts +26 -0
  190. package/dist/application/protocol/desktop-command-contract.js +1 -0
  191. package/dist/application/protocol/desktop-command-executor.d.ts +17 -0
  192. package/dist/application/protocol/desktop-command-executor.js +1 -0
  193. package/dist/application/protocol/desktop-command-output.d.ts +15 -0
  194. package/dist/application/protocol/desktop-command-output.js +1 -0
  195. package/dist/application/protocol/desktop-execution-policy.d.ts +17 -0
  196. package/dist/application/protocol/desktop-execution-policy.js +1 -0
  197. package/dist/application/protocol/desktop-extension-request-handler.d.ts +14 -0
  198. package/dist/application/protocol/desktop-extension-request-handler.js +1 -0
  199. package/dist/application/protocol/desktop-extension-service.d.ts +44 -0
  200. package/dist/application/protocol/desktop-extension-service.js +3 -0
  201. package/dist/application/protocol/desktop-host-tool-executor.d.ts +63 -0
  202. package/dist/application/protocol/desktop-host-tool-executor.js +2 -0
  203. package/dist/application/protocol/desktop-intent-event-writer.d.ts +20 -0
  204. package/dist/application/protocol/desktop-intent-event-writer.js +1 -0
  205. package/dist/application/protocol/desktop-mcp-events.d.ts +10 -0
  206. package/dist/application/protocol/desktop-mcp-events.js +1 -0
  207. package/dist/application/protocol/desktop-orchestration-events.d.ts +2 -0
  208. package/dist/application/protocol/desktop-orchestration-events.js +2 -0
  209. package/dist/application/protocol/desktop-protocol-helpers.d.ts +13 -0
  210. package/dist/application/protocol/desktop-protocol-helpers.js +1 -0
  211. package/dist/application/protocol/document-host-tool-definitions.d.ts +4 -0
  212. package/dist/application/protocol/document-host-tool-definitions.js +1 -0
  213. package/dist/application/protocol/document-host-tool-executor.d.ts +49 -0
  214. package/dist/application/protocol/document-host-tool-executor.js +2 -0
  215. package/dist/application/protocol/json-line-writer.d.ts +9 -0
  216. package/dist/application/protocol/json-line-writer.js +2 -0
  217. package/dist/application/protocol/jsonl-agent-command.d.ts +3 -0
  218. package/dist/application/protocol/jsonl-agent-command.js +3 -0
  219. package/dist/application/protocol/jsonl-protocol.d.ts +82 -0
  220. package/dist/application/protocol/jsonl-protocol.js +2 -0
  221. package/dist/application/protocol/tool-image-content.d.ts +4 -0
  222. package/dist/application/protocol/tool-image-content.js +1 -0
  223. package/dist/application/security/delegated-worker-policy.d.ts +3 -0
  224. package/dist/application/security/delegated-worker-policy.js +1 -0
  225. package/dist/application/security/desktop-tool-scope-policy.d.ts +4 -0
  226. package/dist/application/security/desktop-tool-scope-policy.js +1 -0
  227. package/dist/application/security/tool-action-risk-analyzer.d.ts +13 -0
  228. package/dist/application/security/tool-action-risk-analyzer.js +1 -0
  229. package/dist/application/security/tool-approval-service.d.ts +37 -0
  230. package/dist/application/security/tool-approval-service.js +1 -0
  231. package/dist/application/security/tool-risk-classifier.d.ts +18 -0
  232. package/dist/application/security/tool-risk-classifier.js +1 -0
  233. package/dist/application/security/workspace-permission-policy.d.ts +10 -0
  234. package/dist/application/security/workspace-permission-policy.js +1 -0
  235. package/dist/application/session/project-session-access.d.ts +8 -0
  236. package/dist/application/session/project-session-access.js +1 -0
  237. package/dist/application/session/session-compaction-service.d.ts +10 -0
  238. package/dist/application/session/session-compaction-service.js +1 -0
  239. package/dist/application/session/session-turn-lifecycle.d.ts +5 -0
  240. package/dist/application/session/session-turn-lifecycle.js +1 -0
  241. package/dist/application/workspace/session-execution-workspace.d.ts +59 -0
  242. package/dist/application/workspace/session-execution-workspace.js +3 -0
  243. package/dist/application/workspace/workspace-file-index.d.ts +15 -0
  244. package/dist/application/workspace/workspace-file-index.js +1 -0
  245. package/dist/application/workspace/workspace-file-reference-resolver.d.ts +20 -0
  246. package/dist/application/workspace/workspace-file-reference-resolver.js +17 -0
  247. package/dist/application/workspace/workspace-instruction-loader.d.ts +8 -0
  248. package/dist/application/workspace/workspace-instruction-loader.js +1 -0
  249. package/dist/bootstrap/composition-root.d.ts +6 -0
  250. package/dist/bootstrap/composition-root.js +1 -0
  251. package/dist/bootstrap/global-cli-options.d.ts +6 -0
  252. package/dist/bootstrap/global-cli-options.js +1 -0
  253. package/dist/bootstrap/native-devtools-stub.d.ts +10 -0
  254. package/dist/bootstrap/native-devtools-stub.js +1 -0
  255. package/dist/bootstrap/native-entry.d.ts +1 -0
  256. package/dist/bootstrap/native-entry.js +2 -0
  257. package/dist/bootstrap/native-tiktoken.d.ts +4 -0
  258. package/dist/bootstrap/native-tiktoken.js +1 -0
  259. package/dist/bootstrap/runtime-factory.d.ts +41 -0
  260. package/dist/bootstrap/runtime-factory.js +1 -0
  261. package/dist/bootstrap/shutdown-manager.d.ts +11 -0
  262. package/dist/bootstrap/shutdown-manager.js +1 -0
  263. package/dist/bootstrap/startup-sequence.d.ts +5 -0
  264. package/dist/bootstrap/startup-sequence.js +1 -0
  265. package/dist/domain/auth/auth-profile.d.ts +14 -0
  266. package/dist/domain/auth/auth-profile.js +1 -0
  267. package/dist/domain/config/config-schema.d.ts +24 -0
  268. package/dist/domain/config/config-schema.js +1 -0
  269. package/dist/domain/errors/cli-command-hint.d.ts +5 -0
  270. package/dist/domain/errors/cli-command-hint.js +0 -0
  271. package/dist/domain/errors/cli-error.d.ts +35 -0
  272. package/dist/domain/errors/cli-error.js +1 -0
  273. package/dist/domain/errors/error-codes.d.ts +51 -0
  274. package/dist/domain/errors/error-codes.js +1 -0
  275. package/dist/domain/extensions/extension-scope.d.ts +3 -0
  276. package/dist/domain/extensions/extension-scope.js +1 -0
  277. package/dist/domain/extensions/extension-state.d.ts +5 -0
  278. package/dist/domain/extensions/extension-state.js +1 -0
  279. package/dist/domain/extensions/hook-manifest.d.ts +13 -0
  280. package/dist/domain/extensions/hook-manifest.js +1 -0
  281. package/dist/domain/extensions/host-tool-plugin-ids.d.ts +9 -0
  282. package/dist/domain/extensions/host-tool-plugin-ids.js +1 -0
  283. package/dist/domain/extensions/mcp-config.d.ts +35 -0
  284. package/dist/domain/extensions/mcp-config.js +1 -0
  285. package/dist/domain/extensions/plugin-agent-manifest.d.ts +8 -0
  286. package/dist/domain/extensions/plugin-agent-manifest.js +1 -0
  287. package/dist/domain/extensions/plugin-manifest.d.ts +23 -0
  288. package/dist/domain/extensions/plugin-manifest.js +1 -0
  289. package/dist/domain/extensions/skill-manifest.d.ts +10 -0
  290. package/dist/domain/extensions/skill-manifest.js +3 -0
  291. package/dist/domain/extensions/yaml-subset.d.ts +9 -0
  292. package/dist/domain/extensions/yaml-subset.js +2 -0
  293. package/dist/domain/filesystem/file-change-diff.d.ts +21 -0
  294. package/dist/domain/filesystem/file-change-diff.js +3 -0
  295. package/dist/domain/intent/intent-contract.d.ts +41 -0
  296. package/dist/domain/intent/intent-contract.js +1 -0
  297. package/dist/domain/media/gateway-media-contract.d.ts +23 -0
  298. package/dist/domain/media/gateway-media-contract.js +1 -0
  299. package/dist/domain/media/media-contract.d.ts +28 -0
  300. package/dist/domain/media/media-contract.js +0 -0
  301. package/dist/domain/media/media-execution-policy.d.ts +9 -0
  302. package/dist/domain/media/media-execution-policy.js +1 -0
  303. package/dist/domain/memory/memory-kinds.d.ts +15 -0
  304. package/dist/domain/memory/memory-kinds.js +1 -0
  305. package/dist/domain/memory/memory-retrieval-policy.d.ts +3 -0
  306. package/dist/domain/memory/memory-retrieval-policy.js +1 -0
  307. package/dist/domain/memory/memory-search.d.ts +33 -0
  308. package/dist/domain/memory/memory-search.js +2 -0
  309. package/dist/domain/memory/memory.d.ts +48 -0
  310. package/dist/domain/memory/memory.js +1 -0
  311. package/dist/domain/orchestration/goal.d.ts +58 -0
  312. package/dist/domain/orchestration/goal.js +1 -0
  313. package/dist/domain/orchestration/subagent-identity.d.ts +2 -0
  314. package/dist/domain/orchestration/subagent-identity.js +1 -0
  315. package/dist/domain/orchestration/subagent.d.ts +33 -0
  316. package/dist/domain/orchestration/subagent.js +0 -0
  317. package/dist/domain/orchestration/work-plan.d.ts +77 -0
  318. package/dist/domain/orchestration/work-plan.js +1 -0
  319. package/dist/domain/project/project-identity.d.ts +6 -0
  320. package/dist/domain/project/project-identity.js +1 -0
  321. package/dist/domain/runtime/assistant-delta-normalizer.d.ts +11 -0
  322. package/dist/domain/runtime/assistant-delta-normalizer.js +1 -0
  323. package/dist/domain/runtime/resource-limits.d.ts +75 -0
  324. package/dist/domain/runtime/resource-limits.js +1 -0
  325. package/dist/domain/session/attachment.d.ts +13 -0
  326. package/dist/domain/session/attachment.js +0 -0
  327. package/dist/domain/session/session-schema.d.ts +6 -0
  328. package/dist/domain/session/session-schema.js +1 -0
  329. package/dist/domain/session/session.d.ts +27 -0
  330. package/dist/domain/session/session.js +0 -0
  331. package/dist/domain/settings/settings-document.d.ts +8 -0
  332. package/dist/domain/settings/settings-document.js +1 -0
  333. package/dist/domain/validation/record-schema.d.ts +4 -0
  334. package/dist/domain/validation/record-schema.js +1 -0
  335. package/dist/domain/workspace/workspace-settings.d.ts +12 -0
  336. package/dist/domain/workspace/workspace-settings.js +1 -0
  337. package/dist/infrastructure/agent-sdk/agent-instance-factory.d.ts +22 -0
  338. package/dist/infrastructure/agent-sdk/agent-instance-factory.js +1 -0
  339. package/dist/infrastructure/agent-sdk/model-tool-name-mapper.d.ts +13 -0
  340. package/dist/infrastructure/agent-sdk/model-tool-name-mapper.js +1 -0
  341. package/dist/infrastructure/agent-sdk/tool-calling-completion-client.d.ts +4 -0
  342. package/dist/infrastructure/agent-sdk/tool-calling-completion-client.js +1 -0
  343. package/dist/infrastructure/agent-sdk/tool-calling-model-client.d.ts +11 -0
  344. package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +1 -0
  345. package/dist/infrastructure/cache/cache-policy.d.ts +7 -0
  346. package/dist/infrastructure/cache/cache-policy.js +1 -0
  347. package/dist/infrastructure/cache/file-cache-store.d.ts +17 -0
  348. package/dist/infrastructure/cache/file-cache-store.js +2 -0
  349. package/dist/infrastructure/clipboard/clipboard-adapter-factory.d.ts +11 -0
  350. package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +1 -0
  351. package/dist/infrastructure/clipboard/clipboard-policy.d.ts +8 -0
  352. package/dist/infrastructure/clipboard/clipboard-policy.js +1 -0
  353. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.d.ts +10 -0
  354. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +1 -0
  355. package/dist/infrastructure/clipboard/image-normalizer.d.ts +12 -0
  356. package/dist/infrastructure/clipboard/image-normalizer.js +1 -0
  357. package/dist/infrastructure/clipboard/windows-clipboard-adapter.d.ts +7 -0
  358. package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +1 -0
  359. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.d.ts +7 -0
  360. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +1 -0
  361. package/dist/infrastructure/config/config-loader.d.ts +19 -0
  362. package/dist/infrastructure/config/config-loader.js +2 -0
  363. package/dist/infrastructure/config/environment-values.d.ts +2 -0
  364. package/dist/infrastructure/config/environment-values.js +1 -0
  365. package/dist/infrastructure/credentials/composite-credential-store.d.ts +11 -0
  366. package/dist/infrastructure/credentials/composite-credential-store.js +1 -0
  367. package/dist/infrastructure/credentials/encrypted-file-credential-store.d.ts +17 -0
  368. package/dist/infrastructure/credentials/encrypted-file-credential-store.js +3 -0
  369. package/dist/infrastructure/credentials/environment-credential-store.d.ts +11 -0
  370. package/dist/infrastructure/credentials/environment-credential-store.js +1 -0
  371. package/dist/infrastructure/credentials/secret-input.d.ts +7 -0
  372. package/dist/infrastructure/credentials/secret-input.js +3 -0
  373. package/dist/infrastructure/extensions/composite-mcp-config-store.d.ts +9 -0
  374. package/dist/infrastructure/extensions/composite-mcp-config-store.js +1 -0
  375. package/dist/infrastructure/extensions/extension-directory-reader.d.ts +2 -0
  376. package/dist/infrastructure/extensions/extension-directory-reader.js +1 -0
  377. package/dist/infrastructure/extensions/extension-integrity.d.ts +7 -0
  378. package/dist/infrastructure/extensions/extension-integrity.js +1 -0
  379. package/dist/infrastructure/extensions/extension-source-resolver.d.ts +6 -0
  380. package/dist/infrastructure/extensions/extension-source-resolver.js +1 -0
  381. package/dist/infrastructure/extensions/file-mcp-config-store.d.ts +15 -0
  382. package/dist/infrastructure/extensions/file-mcp-config-store.js +2 -0
  383. package/dist/infrastructure/extensions/hook-runtime.d.ts +18 -0
  384. package/dist/infrastructure/extensions/hook-runtime.js +1 -0
  385. package/dist/infrastructure/extensions/mcp-runtime.d.ts +51 -0
  386. package/dist/infrastructure/extensions/mcp-runtime.js +1 -0
  387. package/dist/infrastructure/extensions/plugin-agent-discovery.d.ts +4 -0
  388. package/dist/infrastructure/extensions/plugin-agent-discovery.js +1 -0
  389. package/dist/infrastructure/extensions/plugin-discovery.d.ts +5 -0
  390. package/dist/infrastructure/extensions/plugin-discovery.js +1 -0
  391. package/dist/infrastructure/extensions/plugin-manager.d.ts +23 -0
  392. package/dist/infrastructure/extensions/plugin-manager.js +2 -0
  393. package/dist/infrastructure/extensions/skill-discovery.d.ts +4 -0
  394. package/dist/infrastructure/extensions/skill-discovery.js +1 -0
  395. package/dist/infrastructure/extensions/skill-installer.d.ts +9 -0
  396. package/dist/infrastructure/extensions/skill-installer.js +1 -0
  397. package/dist/infrastructure/extensions/skill-manager.d.ts +22 -0
  398. package/dist/infrastructure/extensions/skill-manager.js +2 -0
  399. package/dist/infrastructure/extensions/skill-roots.d.ts +19 -0
  400. package/dist/infrastructure/extensions/skill-roots.js +1 -0
  401. package/dist/infrastructure/extensions/skill-tool-executor.d.ts +18 -0
  402. package/dist/infrastructure/extensions/skill-tool-executor.js +2 -0
  403. package/dist/infrastructure/filesystem/atomic-file-store.d.ts +17 -0
  404. package/dist/infrastructure/filesystem/atomic-file-store.js +1 -0
  405. package/dist/infrastructure/filesystem/bounded-file-reader.d.ts +6 -0
  406. package/dist/infrastructure/filesystem/bounded-file-reader.js +1 -0
  407. package/dist/infrastructure/filesystem/bounded-json-reader.d.ts +1 -0
  408. package/dist/infrastructure/filesystem/bounded-json-reader.js +1 -0
  409. package/dist/infrastructure/filesystem/fs-errors.d.ts +2 -0
  410. package/dist/infrastructure/filesystem/fs-errors.js +1 -0
  411. package/dist/infrastructure/filesystem/gateway-media-input-reader.d.ts +12 -0
  412. package/dist/infrastructure/filesystem/gateway-media-input-reader.js +1 -0
  413. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +22 -0
  414. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +3 -0
  415. package/dist/infrastructure/filesystem/path-resolver.d.ts +20 -0
  416. package/dist/infrastructure/filesystem/path-resolver.js +1 -0
  417. package/dist/infrastructure/filesystem/workspace-media-artifact-store.d.ts +13 -0
  418. package/dist/infrastructure/filesystem/workspace-media-artifact-store.js +1 -0
  419. package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +26 -0
  420. package/dist/infrastructure/logging/daily-rotating-file-writer.js +2 -0
  421. package/dist/infrastructure/logging/log-redactor.d.ts +2 -0
  422. package/dist/infrastructure/logging/log-redactor.js +1 -0
  423. package/dist/infrastructure/logging/logging-policy.d.ts +6 -0
  424. package/dist/infrastructure/logging/logging-policy.js +1 -0
  425. package/dist/infrastructure/logging/structured-logger.d.ts +24 -0
  426. package/dist/infrastructure/logging/structured-logger.js +4 -0
  427. package/dist/infrastructure/memory/file-memory-store.d.ts +37 -0
  428. package/dist/infrastructure/memory/file-memory-store.js +11 -0
  429. package/dist/infrastructure/network/safe-media-downloader.d.ts +23 -0
  430. package/dist/infrastructure/network/safe-media-downloader.js +1 -0
  431. package/dist/infrastructure/platform/host-platform.d.ts +14 -0
  432. package/dist/infrastructure/platform/host-platform.js +1 -0
  433. package/dist/infrastructure/platform/host-process.d.ts +29 -0
  434. package/dist/infrastructure/platform/host-process.js +1 -0
  435. package/dist/infrastructure/platform/platform-paths.d.ts +25 -0
  436. package/dist/infrastructure/platform/platform-paths.js +1 -0
  437. package/dist/infrastructure/platform/process-termination.d.ts +4 -0
  438. package/dist/infrastructure/platform/process-termination.js +1 -0
  439. package/dist/infrastructure/platform/read-only-executable.d.ts +3 -0
  440. package/dist/infrastructure/platform/read-only-executable.js +1 -0
  441. package/dist/infrastructure/project/file-project-trust-store.d.ts +12 -0
  442. package/dist/infrastructure/project/file-project-trust-store.js +2 -0
  443. package/dist/infrastructure/sdk/chat-completion-adapter.d.ts +8 -0
  444. package/dist/infrastructure/sdk/chat-completion-adapter.js +1 -0
  445. package/dist/infrastructure/sdk/lotagate-client-factory.d.ts +3 -0
  446. package/dist/infrastructure/sdk/lotagate-client-factory.js +1 -0
  447. package/dist/infrastructure/sdk/model-catalog-adapter.d.ts +19 -0
  448. package/dist/infrastructure/sdk/model-catalog-adapter.js +1 -0
  449. package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +20 -0
  450. package/dist/infrastructure/sdk/sdk-media-gateway-client.js +1 -0
  451. package/dist/infrastructure/sessions/file-goal-store.d.ts +21 -0
  452. package/dist/infrastructure/sessions/file-goal-store.js +1 -0
  453. package/dist/infrastructure/sessions/file-session-store.d.ts +47 -0
  454. package/dist/infrastructure/sessions/file-session-store.js +4 -0
  455. package/dist/infrastructure/sessions/project-session-paths.d.ts +17 -0
  456. package/dist/infrastructure/sessions/project-session-paths.js +1 -0
  457. package/dist/infrastructure/sessions/session-index.d.ts +16 -0
  458. package/dist/infrastructure/sessions/session-index.js +3 -0
  459. package/dist/infrastructure/sessions/session-journal.d.ts +22 -0
  460. package/dist/infrastructure/sessions/session-journal.js +6 -0
  461. package/dist/infrastructure/sessions/subagent-journal-store.d.ts +28 -0
  462. package/dist/infrastructure/sessions/subagent-journal-store.js +2 -0
  463. package/dist/infrastructure/shell/shell-tool-executor.d.ts +17 -0
  464. package/dist/infrastructure/shell/shell-tool-executor.js +2 -0
  465. package/dist/infrastructure/tokens/tiktoken-token-estimator.d.ts +18 -0
  466. package/dist/infrastructure/tokens/tiktoken-token-estimator.js +1 -0
  467. package/dist/infrastructure/workspace/workspace-settings-store.d.ts +9 -0
  468. package/dist/infrastructure/workspace/workspace-settings-store.js +4 -0
  469. package/dist/main.d.ts +7 -0
  470. package/dist/main.js +3 -0
  471. package/dist/ports/cache-store.d.ts +10 -0
  472. package/dist/ports/cache-store.js +0 -0
  473. package/dist/ports/chat-model.d.ts +30 -0
  474. package/dist/ports/chat-model.js +0 -0
  475. package/dist/ports/clipboard-adapter.d.ts +7 -0
  476. package/dist/ports/clipboard-adapter.js +0 -0
  477. package/dist/ports/clipboard-text-adapter.d.ts +3 -0
  478. package/dist/ports/clipboard-text-adapter.js +0 -0
  479. package/dist/ports/credential-store.d.ts +7 -0
  480. package/dist/ports/credential-store.js +0 -0
  481. package/dist/ports/goal-store.d.ts +12 -0
  482. package/dist/ports/goal-store.js +0 -0
  483. package/dist/ports/logger.d.ts +8 -0
  484. package/dist/ports/logger.js +0 -0
  485. package/dist/ports/media-gateway-client.d.ts +54 -0
  486. package/dist/ports/media-gateway-client.js +0 -0
  487. package/dist/ports/memory-store.d.ts +26 -0
  488. package/dist/ports/memory-store.js +0 -0
  489. package/dist/ports/model-completion-client.d.ts +8 -0
  490. package/dist/ports/model-completion-client.js +0 -0
  491. package/dist/ports/model-diagnostics.d.ts +17 -0
  492. package/dist/ports/model-diagnostics.js +0 -0
  493. package/dist/ports/project-trust-store.d.ts +12 -0
  494. package/dist/ports/project-trust-store.js +0 -0
  495. package/dist/ports/session-store.d.ts +58 -0
  496. package/dist/ports/session-store.js +0 -0
  497. package/dist/ports/subagent-lifecycle.d.ts +31 -0
  498. package/dist/ports/subagent-lifecycle.js +0 -0
  499. package/dist/ports/tool-activity.d.ts +13 -0
  500. package/dist/ports/tool-activity.js +0 -0
  501. package/dist/presentation/themes/theme.d.ts +19 -0
  502. package/dist/presentation/themes/theme.js +1 -0
  503. package/dist/presentation/tui/agent-initialization-renderer.d.ts +4 -0
  504. package/dist/presentation/tui/agent-initialization-renderer.js +1 -0
  505. package/dist/presentation/tui/context-display.d.ts +21 -0
  506. package/dist/presentation/tui/context-display.js +2 -0
  507. package/dist/presentation/tui/formatters.d.ts +6 -0
  508. package/dist/presentation/tui/formatters.js +1 -0
  509. package/dist/presentation/tui/ink/choice-window.d.ts +5 -0
  510. package/dist/presentation/tui/ink/choice-window.js +1 -0
  511. package/dist/presentation/tui/ink/components/activity-animation.d.ts +3 -0
  512. package/dist/presentation/tui/ink/components/activity-animation.js +1 -0
  513. package/dist/presentation/tui/ink/components/activity-entry.d.ts +6 -0
  514. package/dist/presentation/tui/ink/components/activity-entry.js +1 -0
  515. package/dist/presentation/tui/ink/components/activity-status.d.ts +10 -0
  516. package/dist/presentation/tui/ink/components/activity-status.js +1 -0
  517. package/dist/presentation/tui/ink/components/choice-modal.d.ts +11 -0
  518. package/dist/presentation/tui/ink/components/choice-modal.js +1 -0
  519. package/dist/presentation/tui/ink/components/composer.d.ts +40 -0
  520. package/dist/presentation/tui/ink/components/composer.js +8 -0
  521. package/dist/presentation/tui/ink/components/file-diff.d.ts +6 -0
  522. package/dist/presentation/tui/ink/components/file-diff.js +1 -0
  523. package/dist/presentation/tui/ink/components/modal.d.ts +8 -0
  524. package/dist/presentation/tui/ink/components/modal.js +2 -0
  525. package/dist/presentation/tui/ink/components/shimmer-text.d.ts +8 -0
  526. package/dist/presentation/tui/ink/components/shimmer-text.js +1 -0
  527. package/dist/presentation/tui/ink/components/subagent-activity.d.ts +11 -0
  528. package/dist/presentation/tui/ink/components/subagent-activity.js +1 -0
  529. package/dist/presentation/tui/ink/components/transcript.d.ts +39 -0
  530. package/dist/presentation/tui/ink/components/transcript.js +5 -0
  531. package/dist/presentation/tui/ink/components/welcome-panel.d.ts +6 -0
  532. package/dist/presentation/tui/ink/components/welcome-panel.js +1 -0
  533. package/dist/presentation/tui/ink/lotagate-tui.d.ts +6 -0
  534. package/dist/presentation/tui/ink/lotagate-tui.js +2 -0
  535. package/dist/presentation/tui/ink/markdown-inline-renderer.d.ts +4 -0
  536. package/dist/presentation/tui/ink/markdown-inline-renderer.js +1 -0
  537. package/dist/presentation/tui/ink/markdown-inline.d.ts +13 -0
  538. package/dist/presentation/tui/ink/markdown-inline.js +1 -0
  539. package/dist/presentation/tui/ink/markdown-message.d.ts +6 -0
  540. package/dist/presentation/tui/ink/markdown-message.js +2 -0
  541. package/dist/presentation/tui/ink/markdown-table.d.ts +16 -0
  542. package/dist/presentation/tui/ink/markdown-table.js +1 -0
  543. package/dist/presentation/tui/ink/tui-bridge.d.ts +193 -0
  544. package/dist/presentation/tui/ink/tui-bridge.js +1 -0
  545. package/dist/presentation/tui/terminal-capabilities.d.ts +15 -0
  546. package/dist/presentation/tui/terminal-capabilities.js +1 -0
  547. package/dist/presentation/tui/terminal-mouse.d.ts +5 -0
  548. package/dist/presentation/tui/terminal-mouse.js +1 -0
  549. package/dist/presentation/tui/terminal-screen.d.ts +10 -0
  550. package/dist/presentation/tui/terminal-screen.js +1 -0
  551. package/dist/presentation/tui/tui-agent-event-runner.d.ts +29 -0
  552. package/dist/presentation/tui/tui-agent-event-runner.js +1 -0
  553. package/dist/presentation/tui/tui-application-contract.d.ts +10 -0
  554. package/dist/presentation/tui/tui-application-contract.js +1 -0
  555. package/dist/presentation/tui/tui-application.d.ts +64 -0
  556. package/dist/presentation/tui/tui-application.js +3 -0
  557. package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +11 -0
  558. package/dist/presentation/tui/tui-clipboard-paste-handlers.js +1 -0
  559. package/dist/presentation/tui/tui-command-context.d.ts +3 -0
  560. package/dist/presentation/tui/tui-command-context.js +0 -0
  561. package/dist/presentation/tui/tui-command-executor.d.ts +38 -0
  562. package/dist/presentation/tui/tui-command-executor.js +4 -0
  563. package/dist/presentation/tui/tui-command-host-factory.d.ts +40 -0
  564. package/dist/presentation/tui/tui-command-host-factory.js +1 -0
  565. package/dist/presentation/tui/tui-context-compaction.d.ts +5 -0
  566. package/dist/presentation/tui/tui-context-compaction.js +1 -0
  567. package/dist/presentation/tui/tui-context-service.d.ts +34 -0
  568. package/dist/presentation/tui/tui-context-service.js +2 -0
  569. package/dist/presentation/tui/tui-extension-loader.d.ts +21 -0
  570. package/dist/presentation/tui/tui-extension-loader.js +1 -0
  571. package/dist/presentation/tui/tui-file-suggestions.d.ts +3 -0
  572. package/dist/presentation/tui/tui-file-suggestions.js +1 -0
  573. package/dist/presentation/tui/tui-goal-controller.d.ts +14 -0
  574. package/dist/presentation/tui/tui-goal-controller.js +1 -0
  575. package/dist/presentation/tui/tui-initial-model.d.ts +3 -0
  576. package/dist/presentation/tui/tui-initial-model.js +1 -0
  577. package/dist/presentation/tui/tui-lifecycle-actions.d.ts +13 -0
  578. package/dist/presentation/tui/tui-lifecycle-actions.js +1 -0
  579. package/dist/presentation/tui/tui-manual-compaction.d.ts +18 -0
  580. package/dist/presentation/tui/tui-manual-compaction.js +1 -0
  581. package/dist/presentation/tui/tui-media-model-selection.d.ts +12 -0
  582. package/dist/presentation/tui/tui-media-model-selection.js +1 -0
  583. package/dist/presentation/tui/tui-prompt-dispatcher.d.ts +16 -0
  584. package/dist/presentation/tui/tui-prompt-dispatcher.js +1 -0
  585. package/dist/presentation/tui/tui-skill-controller.d.ts +11 -0
  586. package/dist/presentation/tui/tui-skill-controller.js +3 -0
  587. package/dist/presentation/tui/tui-tool-approval.d.ts +22 -0
  588. package/dist/presentation/tui/tui-tool-approval.js +1 -0
  589. package/dist/version.d.ts +1 -0
  590. package/dist/version.js +1 -0
  591. package/package.json +12 -10
  592. package/skills/architecture-review/SKILL.md +41 -14
  593. package/skills/code-review/SKILL.md +41 -12
  594. package/skills/debugging/SKILL.md +49 -12
  595. package/skills/documentation/SKILL.md +43 -9
  596. package/skills/feature-implementation/SKILL.md +58 -19
  597. package/skills/api-contract-review/SKILL.md +0 -17
  598. package/skills/database-review/SKILL.md +0 -17
  599. package/skills/dependency-review/SKILL.md +0 -16
  600. package/skills/frontend-review/SKILL.md +0 -18
  601. package/skills/incident-response/SKILL.md +0 -18
  602. package/skills/performance-review/SKILL.md +0 -17
  603. package/skills/refactor/SKILL.md +0 -23
  604. package/skills/release-readiness/SKILL.md +0 -16
  605. package/skills/security-review/SKILL.md +0 -16
  606. package/skills/test-plan/SKILL.md +0 -22
  607. package/skills/verify/SKILL.md +0 -13
@@ -0,0 +1,2 @@
1
+ const a=[u("skill.list","List enabled skills available to the agent.",{type:"object",properties:{},additionalProperties:!1}),u("skill.load","Load instructions for one enabled skill by name when its description matches the task.",{type:"object",properties:{name:{type:"string",description:"Enabled skill name."}},required:["name"],additionalProperties:!1})];function f(){return a}class p{scopes;skills;constructor(e,n){this.scopes=n,this.skills=e.filter(s=>s.enabled&&s.modelInvocable)}listTools(){return f()}getToolInfo(e){return a.some(n=>d(n)===e)?{toolName:e,source:"custom",executorId:"skill-catalog",metadata:{category:"skill",risk:"read"}}:void 0}async execute(e,n,s){if(e==="skill.list")return c(JSON.stringify(this.skills.map(i=>({name:i.skillKey??i.name,description:i.description}))));if(e!=="skill.load")return o(`Unknown skill tool: ${e}`);const r=n.name;if(typeof r!="string")return o("skill.load requires a skill name.");const l=this.skills.find(i=>(i.skillKey??i.name)===r);return l===void 0?o(`Skill is unavailable: ${r}`):(this.scopes.activate(s.runId,l),c(k(l.body,s.maxResultBytes)))}}function u(t,e,n){return{type:"function",function:{name:t,description:e,parameters:n}}}function d(t){return"function"in t?t.function.name:void 0}function c(t){return{content:t,isError:!1}}function o(t){return{content:t,isError:!0}}function k(t,e){const n=Buffer.from(t,"utf8");return n.byteLength<=e?t:`${n.subarray(0,e).toString("utf8")}
2
+ [truncated]`}export{p as SkillToolExecutor,f as skillToolDefinitions};
@@ -0,0 +1,17 @@
1
+ import fs from 'node:fs/promises';
2
+ /** Writes a file through a same-directory temporary file and rename. */
3
+ export declare function atomicWriteFile(filePath: string, data: string | Uint8Array, mode?: number): Promise<void>;
4
+ /** Replaces a directory under an advisory lock with rollback if the commit fails. */
5
+ export declare function replaceDirectoryWithRollback(temporary: string, destination: string): Promise<void>;
6
+ /** Creates an advisory lock and removes it again when lock metadata cannot be persisted. */
7
+ export declare function acquireAdvisoryFileLock(lockPath: string): Promise<fs.FileHandle>;
8
+ /** Handles Windows reporting an existing, exclusively opened lock as EPERM/EACCES. */
9
+ export declare function isAdvisoryLockContention(error: unknown, lockPath: string): Promise<boolean>;
10
+ /** Closes an advisory lock handle and removes its lock file even when close fails. */
11
+ export declare function releaseAdvisoryFileLock(handle: fs.FileHandle, lockPath: string): Promise<void>;
12
+ /** Serializes mutations across CLI processes using an advisory lock file. */
13
+ export declare function withFileLock<T>(filePath: string, operation: () => Promise<T>, options?: {
14
+ timeoutMs?: number;
15
+ staleMs?: number;
16
+ userMessage?: string;
17
+ }): Promise<T>;
@@ -0,0 +1 @@
1
+ import l from"node:crypto";import i from"node:fs/promises";import f from"node:path";import{CliError as p}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as d}from"../../domain/errors/error-codes.js";import{isAlreadyExists as E,isFileNotFound as w}from"./fs-errors.js";const h=5e3,g=900*1e3,v=25;async function $(r,e,t=384){await i.mkdir(f.dirname(r),{recursive:!0});const a=`${r}.tmp-${process.pid}-${l.randomUUID()}`;try{await i.writeFile(a,e,{mode:t}),await i.rename(a,r)}finally{await i.rm(a,{force:!0})}}async function T(r,e){const t=`${e}.backup-${process.pid}-${l.randomUUID()}`;let a=!1,o=!1;try{try{await i.rename(e,t),a=!0}catch(n){if(!w(n))throw n}try{await i.rename(r,e)}catch(n){if(a)try{await i.rename(t,e)}catch(c){throw o=!0,new AggregateError([n,c],`Installation and recovery failed. Previous contents are preserved at ${t}.`)}throw n}}finally{o||await i.rm(t,{recursive:!0,force:!0})}}async function C(r){const e=await i.open(r,"wx",384);try{return await e.writeFile(JSON.stringify({pid:process.pid,createdAt:new Date().toISOString()})),e}catch(t){throw await y(e,r),t}}async function L(r,e){if(E(r))return!0;if(!_(r))return!1;try{return await i.stat(e),!0}catch{return!1}}async function y(r,e){try{await r.close()}finally{await i.rm(e,{force:!0})}}async function I(r,e,t={}){const a=`${r}.lock`,o=t.timeoutMs??h,n=t.staleMs??g;await i.mkdir(f.dirname(r),{recursive:!0});const c=Date.now()+o;let s;for(;s===void 0;)try{s=await C(a)}catch(u){if(!await L(u,a))throw u;if(await k(a,n))continue;if(Date.now()>=c)throw new p(d.CONFIG_LOCKED,`Configuration file is locked: ${r}`,{category:"config",userMessage:t.userMessage??"A configuration update is already in progress. Try again shortly.",retryable:!0});await new Promise(m=>setTimeout(m,v))}try{return await e()}finally{await y(s,a)}}function _(r){return typeof r=="object"&&r!==null&&"code"in r&&(r.code==="EPERM"||r.code==="EACCES")}async function k(r,e){let t;try{t=await i.stat(r)}catch(o){return w(o)}if(Date.now()-t.mtimeMs<e)return!1;let a;try{const o=JSON.parse(await i.readFile(r,"utf8"));a=typeof o.pid=="number"?o.pid:void 0}catch{}return a!==void 0&&A(a)?!1:(await i.rm(r,{force:!0}),!0)}function A(r){if(r===process.pid)return!0;try{return process.kill(r,0),!0}catch{return!1}}export{C as acquireAdvisoryFileLock,$ as atomicWriteFile,L as isAdvisoryLockContention,y as releaseAdvisoryFileLock,T as replaceDirectoryWithRollback,I as withFileLock};
@@ -0,0 +1,6 @@
1
+ export interface BoundedFileRead {
2
+ bytes: Buffer;
3
+ truncated: boolean;
4
+ }
5
+ /** Reads at most maxBytes and never loads an entire untrusted file into memory. */
6
+ export declare function readFileBounded(filePath: string, maxBytes: number): Promise<BoundedFileRead>;
@@ -0,0 +1 @@
1
+ import i from"node:fs/promises";async function y(l,f){const t=Math.max(0,Math.floor(f)),r=await i.open(l,"r");try{const o=[];let a=0;const s=t+1;for(;a<s;){const e=Buffer.alloc(Math.min(65536,s-a)),{bytesRead:n}=await r.read(e,0,e.byteLength,null);if(n===0)break;o.push(e.subarray(0,n)),a+=n}const c=Buffer.concat(o);return{bytes:c.subarray(0,t),truncated:c.byteLength>t}}finally{await r.close()}}export{y as readFileBounded};
@@ -0,0 +1 @@
1
+ export declare function readJsonFileBounded(filePath: string, maxBytes: number): Promise<unknown>;
@@ -0,0 +1 @@
1
+ import{readFileBounded as o}from"./bounded-file-reader.js";async function d(e,t){const r=await o(e,t);if(r.truncated)throw new Error(`File exceeds the maximum supported size: ${e}`);return JSON.parse(r.bytes.toString("utf8"))}export{d as readJsonFileBounded};
@@ -0,0 +1,2 @@
1
+ export declare function isFileNotFound(error: unknown): boolean;
2
+ export declare function isAlreadyExists(error: unknown): boolean;
@@ -0,0 +1 @@
1
+ function n(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="ENOENT"}function c(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EEXIST"}export{c as isAlreadyExists,n as isFileNotFound};
@@ -0,0 +1,12 @@
1
+ export interface GatewayImageEditInput {
2
+ readonly images: readonly Uint8Array[];
3
+ readonly mask: Uint8Array | undefined;
4
+ }
5
+ export interface GatewayAudioInput {
6
+ readonly bytes: Uint8Array;
7
+ readonly filename: string;
8
+ readonly sourceName: string;
9
+ }
10
+ /** Reads local upload inputs sequentially and enforces the gateway's published limits. */
11
+ export declare function readGatewayImageEditInput(imageValue: string, maskValue: string | undefined, cwd: string): Promise<GatewayImageEditInput>;
12
+ export declare function readGatewayAudioInput(source: string, cwd: string): Promise<GatewayAudioInput>;
@@ -0,0 +1 @@
1
+ import p from"node:path";import{GATEWAY_MEDIA_LIMITS as n,validateImageEditInputCount as l,validateImageEditTotalSize as u,validateUploadSize as m}from"../../domain/media/gateway-media-contract.js";import{CliError as E}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as I}from"../../domain/errors/error-codes.js";import{normalizeImage as b}from"../clipboard/image-normalizer.js";import{readFileBounded as g}from"./bounded-file-reader.js";import{resolveExternalPath as y}from"./path-resolver.js";async function v(r,o,e){const t=r.split(",").map(a=>a.trim()).filter(Boolean);l(t);const s=[];let d=0;for(const a of t){const f=await c(a,e,n.imageEditFileBytes,"Image",["image/png","image/jpeg","image/webp"]);d+=f.byteLength,u(d),s.push(f)}const i=o===void 0?void 0:await c(o,e,n.imageEditMaskBytes,"Mask",["image/png"]);return i!==void 0&&u(d+i.byteLength),{images:s,mask:i}}async function M(r,o){const e=await y(r,{cwd:o}),t=await g(e,n.audioUploadBytes);return t.truncated&&m(n.audioUploadBytes+1,n.audioUploadBytes,"Audio file"),m(t.bytes.byteLength,n.audioUploadBytes,"Audio file"),{bytes:t.bytes,filename:p.basename(e),sourceName:p.parse(p.basename(e)).name}}async function c(r,o,e,t,s){const d=await y(r,{cwd:o}),i=await g(d,e);i.truncated&&m(e+1,e,t);const a=b(i.bytes,void 0,e);if(!s.includes(a.mimeType))throw new E(I.ATTACHMENT_FORMAT_UNSUPPORTED,`${t} format is not accepted by the gateway.`,{category:"media",userMessage:`${t} must use one of: ${s.join(", ")}.`});return m(a.bytes.byteLength,e,t),a.bytes}export{M as readGatewayAudioInput,v as readGatewayImageEditInput};
@@ -0,0 +1,22 @@
1
+ import type { ToolDefinition } from '@lotagate/sdk';
2
+ import type { ToolExecutionContext, ToolExecutor, ToolInfo, ToolResult } from '@lotagate/agent-sdk';
3
+ import { type FileChangeDiff } from '../../domain/filesystem/file-change-diff.js';
4
+ import type { ToolActivityObserver } from '../../ports/tool-activity.js';
5
+ /** Exposes the same filesystem capability definitions to runtime and context accounting. */
6
+ export declare function filesystemToolDefinitions(): readonly ToolDefinition[];
7
+ export declare class LocalFilesystemToolExecutor implements ToolExecutor {
8
+ private readonly options;
9
+ constructor(options?: {
10
+ onWrite?: (change: FileChangeDiff) => void | Promise<void>;
11
+ onActivity?: ToolActivityObserver;
12
+ writeScope?: readonly string[];
13
+ });
14
+ listTools(): readonly ToolDefinition[];
15
+ getToolInfo(toolName: string): ToolInfo | undefined;
16
+ execute(toolName: string, input: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
17
+ private read;
18
+ private list;
19
+ private write;
20
+ private exists;
21
+ }
22
+ export declare function isWithinWriteScope(filePath: string, context: ToolExecutionContext, scopes: readonly string[]): Promise<boolean>;
@@ -0,0 +1,3 @@
1
+ import d from"node:fs/promises";import o from"node:path";import{createFileChangeDiff as g}from"../../domain/filesystem/file-change-diff.js";import{assertWorkspaceWriteTarget as h,resolveWorkspacePath as u}from"./path-resolver.js";import{readFileBounded as y}from"./bounded-file-reader.js";import{isFileNotFound as m}from"./fs-errors.js";import{atomicWriteFile as k}from"./atomic-file-store.js";import{formatFilesystemActivityName as F}from"../../application/agent/tool-display.js";const w=[p("filesystem.read","Read a UTF-8 text file inside the trusted workspace for inspection. Never reproduce detailed file contents in the final response unless the user explicitly requests them.",{path:{type:"string",description:"Workspace-relative file path."}},["path"]),p("filesystem.list","List entries inside a trusted workspace directory.",{path:{type:"string",description:"Optional workspace-relative directory path. Defaults to the workspace root."}},[]),p("filesystem.write","Write UTF-8 text to a file inside the trusted workspace.",{path:{type:"string",description:"Workspace-relative file path."},content:{type:"string",description:"UTF-8 file content."}},["path","content"]),p("filesystem.exists","Check whether a workspace-relative path exists.",{path:{type:"string",description:"Workspace-relative path."}},["path"])],b=64*1024,v=400,S=240;function T(){return w}class U{options;constructor(t={}){this.options=t}listTools(){return T()}getToolInfo(t){return w.some(e=>L(e)===t)?{toolName:t,source:"filesystem",executorId:"local-filesystem",metadata:{risk:t==="filesystem.write"?"write":"read"}}:void 0}async execute(t,e,r){const s=this.options.onActivity?.start({key:`${r.runId}:${t}`,toolName:t,source:"filesystem",label:x(t,e.path)});let a;try{switch(t){case"filesystem.read":a=await this.read(e,r);break;case"filesystem.list":a=await this.list(e,r);break;case"filesystem.write":a=await this.write(e,r);break;case"filesystem.exists":a=await this.exists(e,r);break;default:a=l(`Unknown filesystem tool: ${t}`);break}}catch(n){a=l(n instanceof Error?n.message:String(n))}return s?.complete(a.isError===!0,a.metadata),a}async read(t,e){const r=await u(t.path,e),s=await y(r,e.maxResultBytes);return c(`${s.bytes.toString("utf8")}${s.truncated?`
2
+ [truncated]`:""}`)}async list(t,e){const r=await u(t.path===void 0||typeof t.path=="string"&&t.path.trim().length===0?".":t.path,e),s=[],a=Math.max(1,Math.floor(e.maxResultBytes/64)),n=await d.opendir(r);try{for(let f=await n.read();f!==null&&(s.push({name:f.name,kind:f.isDirectory()?"directory":"file"}),!(s.length>=a));f=await n.read());}finally{await n.close()}return c(W(Buffer.from(JSON.stringify(s)),e.maxResultBytes))}async write(t,e){if(typeof t.content!="string")return l("filesystem.write requires string content.");const r=await u(t.path,e,!0);if(this.options.writeScope!==void 0&&!await E(r,e,this.options.writeScope))return l("filesystem.write path is outside the delegated worker write scope.");const s=Buffer.from(t.content,"utf8");if(s.byteLength>e.maxResultBytes)return l("filesystem.write content exceeds the configured limit.");const a=await I(r);await d.mkdir(o.dirname(r),{recursive:!0}),await h(r,e),await k(r,s),await h(r,e);const n=g(String(t.path),a.content,t.content,{maxInputLines:v,maxLines:S,truncated:a.truncated});try{await this.options.onWrite?.(n)}catch{}return{...c(`Wrote ${s.byteLength} bytes.`),metadata:{fileChange:{path:n.path,additions:n.additions,deletions:n.deletions}}}}async exists(t,e){try{return await u(t.path,e),c("true")}catch(r){if(m(r))return c("false");throw r}}}async function E(i,t,e){const r=await d.realpath(o.resolve(t.workspaceRoot??t.cwd??process.cwd())),s=o.relative(r,o.resolve(i));return s.startsWith("..")||o.isAbsolute(s)?!1:e.some(a=>{const n=o.normalize(a).replace(/[\\/]$/u,"");return n==="."?!0:s===n||s.startsWith(`${n}${o.sep}`)})}async function I(i){try{const t=await y(i,b);return{content:t.bytes.toString("utf8"),truncated:t.truncated}}catch(t){return m(t)?{content:"",truncated:!1}:{content:"",truncated:!0}}}function p(i,t,e,r){return{type:"function",function:{name:i,description:t,parameters:{type:"object",properties:e,required:r,additionalProperties:!1}}}}function L(i){return"function"in i?i.function.name:void 0}function c(i){return{content:i,isError:!1}}function l(i){return{content:i,isError:!0}}function W(i,t){return i.byteLength<=t?i.toString("utf8"):`${i.subarray(0,t).toString("utf8")}
3
+ [truncated]`}function x(i,t){return F(i,t)}export{U as LocalFilesystemToolExecutor,T as filesystemToolDefinitions,E as isWithinWriteScope};
@@ -0,0 +1,20 @@
1
+ export declare function resolveWorkspacePath(input: unknown, context: {
2
+ cwd?: string;
3
+ workspaceRoot?: string;
4
+ }, allowMissing?: boolean): Promise<string>;
5
+ /** Resolves an explicitly supplied local path without applying workspace containment. */
6
+ export declare function resolveExternalPath(input: unknown, context: {
7
+ cwd?: string;
8
+ }, allowMissing?: boolean): Promise<string>;
9
+ /** Resolves an output path while refusing a final symlink target. */
10
+ export declare function resolveExternalOutputPath(input: unknown, context: {
11
+ cwd?: string;
12
+ }): Promise<string>;
13
+ /** Revalidates a write target immediately at the filesystem mutation boundary. */
14
+ export declare function assertWorkspaceWriteTarget(filePath: string, context: {
15
+ cwd?: string;
16
+ workspaceRoot?: string;
17
+ }): Promise<void>;
18
+ /** Revalidates an explicitly selected external output without following the final path component. */
19
+ export declare function assertExternalWriteTarget(filePath: string): Promise<void>;
20
+ export declare function assertInside(root: string, candidate: string): void;
@@ -0,0 +1 @@
1
+ import n from"node:fs/promises";import s from"node:path";import{CliError as h}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as w}from"../../domain/errors/error-codes.js";import{isFileNotFound as l}from"./fs-errors.js";async function A(t,e,o=!1){if(typeof t!="string"||t.trim().length===0)throw new h(w.TOOL_ARGUMENT_INVALID,"A relative workspace path is required.",{category:"tool",userMessage:"The filesystem tool requires a non-empty path."});const a=await n.realpath(s.resolve(e.workspaceRoot??e.cwd??process.cwd())),r=await n.realpath(s.resolve(e.cwd??a));p(a,r);const i=s.resolve(r,t);try{const c=await n.realpath(i);return p(a,c),c}catch(c){if(!o||!l(c))throw c;return y(i,a)}}async function m(t,e,o=!1){const a=d(t,e.cwd);try{return await n.realpath(a)}catch(r){if(!o||!l(r))throw r;return u(a)}}async function M(t,e){const o=d(t,e.cwd),a=await m(s.dirname(o),e,!0),r=s.join(a,s.basename(o));return await f(r),r}async function y(t,e){return u(t,e)}async function u(t,e){const o=[];let a=t;for(;;)try{const r=await n.realpath(a);return e!==void 0&&p(e,r),s.join(r,...o)}catch(r){if(!l(r))throw r;const i=s.dirname(a);if(i===a)throw r;o.unshift(s.basename(a)),a=i}}function d(t,e=process.cwd()){if(typeof t!="string"||t.trim().length===0)throw new h(w.INVALID_ARGUMENT,"A non-empty local path is required.",{category:"path",userMessage:"A non-empty local path is required."});return s.resolve(e,t)}async function f(t){try{if((await n.lstat(t)).isSymbolicLink())throw new h(w.INVALID_ARGUMENT,"Output paths cannot be symbolic links.",{category:"path",userMessage:"The output path cannot be a symbolic link."})}catch(e){if(!l(e))throw e}}async function T(t,e){const o=await n.realpath(s.resolve(e.workspaceRoot??e.cwd??process.cwd())),a=await n.realpath(s.dirname(t));p(o,a);try{const r=await n.realpath(t);p(o,r)}catch(r){if(!l(r))throw r}}async function I(t){await n.realpath(s.dirname(t)),await f(t)}function p(t,e){const o=s.relative(t,e);if(o===".."||o.startsWith(`..${s.sep}`)||s.isAbsolute(o))throw new h(w.PROJECT_SYMLINK_ESCAPE,"Path escapes the trusted workspace.",{category:"project",userMessage:"Tool access was denied because the path is outside the trusted workspace."})}export{I as assertExternalWriteTarget,p as assertInside,T as assertWorkspaceWriteTarget,M as resolveExternalOutputPath,m as resolveExternalPath,A as resolveWorkspacePath};
@@ -0,0 +1,13 @@
1
+ import type { MediaArtifactRequest, StoredMediaArtifact } from '../../domain/media/media-contract.js';
2
+ import type { Logger } from '../../ports/logger.js';
3
+ /** Persists generated media below the workspace by default or in an explicitly supplied local directory. */
4
+ export declare class WorkspaceMediaArtifactStore {
5
+ private readonly cwd;
6
+ private readonly logger?;
7
+ constructor(cwd: string, logger?: Logger | undefined);
8
+ writeMany(request: MediaArtifactRequest, artifacts: readonly Uint8Array[]): Promise<readonly StoredMediaArtifact[]>;
9
+ private resolveDirectory;
10
+ private resolveTarget;
11
+ private resolveOutputPath;
12
+ private context;
13
+ }
@@ -0,0 +1 @@
1
+ import h from"node:fs/promises";import a from"node:path";import{CliError as T}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as v}from"../../domain/errors/error-codes.js";import{atomicWriteFile as x}from"./atomic-file-store.js";import{assertExternalWriteTarget as E,assertWorkspaceWriteTarget as D,resolveExternalOutputPath as $,resolveExternalPath as A,resolveWorkspacePath as m}from"./path-resolver.js";const P=1e4,k={image:a.join("tmp","images"),speech:a.join("tmp","speechs"),transcription:a.join("tmp","transcribes"),translation:a.join("tmp","translates"),video:a.join("tmp","videos")};class L{cwd;logger;constructor(t,r){this.cwd=t,this.logger=r}async writeMany(t,r){if(r.length===0)throw l("The provider returned no media artifacts.");if(t.out!==void 0&&r.length!==1)throw l("--out can only be used when exactly one artifact is returned. Use --out-dir instead.");const o=await this.resolveDirectory(t),i=t.outDir!==void 0,n=[];for(const[s,d]of r.entries()){const w=await this.resolveTarget(t,o,s,r.length),p=t.out===void 0,c=p?await _(w,this.context(),i):w;let f=p;try{await h.mkdir(a.dirname(c),{recursive:!0}),await u(c,this.context(),i),f||(f=await O(c,t.force,this.context(),i)),await x(c,d),await u(c,this.context(),i)}catch(y){throw f&&await b(c,this.context(),i),y}n.push({path:c,bytes:d.byteLength})}return this.logger?.info("Media artifacts stored.",{kind:t.kind,artifactCount:n.length,artifactBytes:n.reduce((s,d)=>s+d.bytes,0)}),n}async resolveDirectory(t){const r=t.outDir??k[t.kind];return t.outDir===void 0?m(r,this.context(),!0):A(r,{cwd:this.cwd},!0)}async resolveTarget(t,r,o,i){if(t.out!==void 0){R(t.out);const d=i>1?`-${o+1}`:"";return this.resolveOutputPath(a.join(r,`${t.out}${d}.${t.extension}`),t.outDir!==void 0)}const n=i>1?`-${o+1}`:"",s=a.join(r,`${j(t.source)}${n}.${t.extension}`);return this.resolveOutputPath(s,t.outDir!==void 0)}resolveOutputPath(t,r){return r?$(t,{cwd:this.cwd}):m(t,this.context(),!0)}context(){return{cwd:this.cwd,workspaceRoot:this.cwd}}}async function u(e,t,r){r?await E(e):await D(e,t)}async function O(e,t,r,o){if(t)return!1;try{return await h.mkdir(a.dirname(e),{recursive:!0}),await u(e,r,o),await(await h.open(e,"wx",384)).close(),await u(e,r,o),!0}catch(i){throw g(i)?l(`Refusing to overwrite an existing file: ${e}. Use --force with --out to replace it.`):i}}async function _(e,t,r){const o=a.parse(e);for(let i=0;i<P;i+=1){const n=i===0?e:a.join(o.dir,`${o.name}-${i+1}${o.ext}`);try{return await h.mkdir(o.dir,{recursive:!0}),await u(n,t,r),await(await h.open(n,"wx",384)).close(),await u(n,t,r),n}catch(s){if(!g(s))throw s}}throw l(`Unable to allocate a unique output path near: ${e}.`)}async function b(e,t,r){try{await u(e,t,r),await h.rm(e,{force:!0})}catch{}}function j(e){const t=e.normalize("NFKD").replace(/[^a-zA-Z0-9]+/gu,"-").replace(/^-+|-+$/gu,"").toLowerCase().slice(0,72);return t.length===0?"media":t}function R(e){const t=[...e].some(r=>{const o=r.codePointAt(0)??0;return o<32||o===127});if(e.length===0||e==="."||e===".."||e.includes("/")||e.includes("\\")||t)throw l("--out must be a filename without path separators or control characters.")}function g(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}function l(e){return new T(v.INVALID_ARGUMENT,e,{category:"media",userMessage:e})}export{L as WorkspaceMediaArtifactStore};
@@ -0,0 +1,26 @@
1
+ export interface DailyRotatingFileWriterOptions {
2
+ retentionDays: number;
3
+ now?: () => number;
4
+ }
5
+ export declare class DailyRotatingFileWriter {
6
+ private readonly directory;
7
+ private readonly options;
8
+ private readonly now;
9
+ private queue;
10
+ private queueBytes;
11
+ private dropped;
12
+ private drainPromise;
13
+ private closed;
14
+ private lastPrunedDate;
15
+ private lastError;
16
+ constructor(directory: string, options: DailyRotatingFileWriterOptions);
17
+ get health(): Readonly<{
18
+ dropped: number;
19
+ lastError?: Error;
20
+ }>;
21
+ write(line: string): void;
22
+ flush(): Promise<void>;
23
+ close(): Promise<void>;
24
+ private drain;
25
+ private prune;
26
+ }
@@ -0,0 +1,2 @@
1
+ import a from"node:fs";import d from"node:fs/promises";import u from"node:path";import{RESOURCE_LIMITS as l}from"../../domain/runtime/resource-limits.js";class y{directory;options;now;queue=[];queueBytes=0;dropped=0;drainPromise=Promise.resolve();closed=!1;lastPrunedDate;lastError;constructor(t,i){this.directory=t,this.options=i,this.now=i.now??Date.now,a.mkdirSync(t,{recursive:!0,mode:448}),this.lastPrunedDate=o(this.now()),this.prune()||(this.lastPrunedDate="")}get health(){return{dropped:this.dropped,...this.lastError===void 0?{}:{lastError:this.lastError}}}write(t){if(this.closed)return;const i=o(this.now());i!==this.lastPrunedDate&&this.prune()&&(this.lastPrunedDate=i);const r=Buffer.byteLength(t,"utf8");if(this.queue.length>=l.logQueueEntries||this.queueBytes+r>l.logQueueBytes){this.dropped+=1;return}this.queue.push({filePath:u.join(this.directory,`lotagate-${o(this.now())}.jsonl`),line:t}),this.queueBytes+=r,this.drainPromise=this.drainPromise.then(()=>this.drain()).catch(e=>{this.lastError=e instanceof Error?e:new Error(String(e))})}async flush(){await this.drainPromise,this.queue.length>0&&(this.drainPromise=this.drainPromise.then(()=>this.drain()).catch(t=>{this.lastError=t instanceof Error?t:new Error(String(t))}),await this.drainPromise)}async close(){this.closed=!0,await this.flush()}async drain(){if(this.queue.length===0)return;const t=this.queue.splice(0,this.queue.length);this.queueBytes=0;const i=this.dropped;i>0&&t.push({filePath:u.join(this.directory,`lotagate-${o(this.now())}.jsonl`),line:`${JSON.stringify({timestamp:new Date(this.now()).toISOString(),level:"warn",message:"Log entries dropped because the file writer queue was full.",dropped:i})}
2
+ `});const r=new Map;for(const e of t)r.set(e.filePath,[...r.get(e.filePath)??[],e.line]);try{for(const[e,s]of r)await d.appendFile(e,s.join(""),{encoding:"utf8",mode:384});this.dropped=0,this.lastError=void 0}catch(e){const s=[...t.filter(n=>!n.line.includes("Log entries dropped because the file writer queue was full.")),...this.queue];throw this.queue=s,this.queueBytes=s.reduce((n,c)=>n+Buffer.byteLength(c.line,"utf8"),0),this.lastError=e instanceof Error?e:new Error(String(e)),e}}prune(){const t=this.now()-this.options.retentionDays*24*60*60*1e3;let i=!0;try{for(const r of a.readdirSync(this.directory,{withFileTypes:!0})){if(!r.isFile())continue;const e=/^lotagate-(\d{4}-\d{2}-\d{2})\.jsonl$/u.exec(r.name);if(e===null||e[1]===void 0)continue;const s=Date.parse(`${e[1]}T00:00:00.000Z`);if(Number.isFinite(s)&&s<t)try{a.rmSync(u.join(this.directory,r.name),{force:!0})}catch(n){i=!1,this.lastError=n instanceof Error?n:new Error(String(n))}}}catch(r){i=!1,this.lastError=r instanceof Error?r:new Error(String(r))}return i}}function o(h){return new Date(h).toISOString().slice(0,10)}export{y as DailyRotatingFileWriter};
@@ -0,0 +1,2 @@
1
+ export declare function redactLogDetails(details: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
2
+ export declare function redactLogText(value: string): string;
@@ -0,0 +1 @@
1
+ const s=/(api.?key|authorization|credential|password|private.?key|secret|token)/iu;function i(r){if(r!==void 0)return t(r)}function t(r){return Object.fromEntries(Object.entries(r).map(([e,o])=>[e,s.test(e)?"[REDACTED]":c(o)]))}function c(r){return typeof r=="string"?n(r):Array.isArray(r)?r.map(e=>e!==null&&typeof e=="object"?t(e):typeof e=="string"?n(e):e):r!==null&&typeof r=="object"?t(r):r}function a(r){return n(r)}function n(r){return r.replace(/Bearer\s+[^\s]+/giu,"Bearer [REDACTED]").replace(/sk-[A-Za-z0-9_-]{8,}/gu,"[REDACTED]").replace(/((?:api[_-]?key|password|secret|token|authorization)\s*[:=]\s*)[^\s,]+/giu,"$1[REDACTED]").replace(/([?&][^=&#\s]*(?:key|token|secret|password|auth)[^=&#\s]*=)[^&#\s]+/giu,"$1[REDACTED]")}export{i as redactLogDetails,a as redactLogText};
@@ -0,0 +1,6 @@
1
+ import type { LogLevel } from '../../ports/logger.js';
2
+ export interface LoggingPolicy {
3
+ level: LogLevel;
4
+ retentionDays: number;
5
+ }
6
+ export declare function resolveLoggingPolicy(env?: Readonly<Record<string, string | undefined>>): LoggingPolicy;
@@ -0,0 +1 @@
1
+ import{readBoundedEnvironmentInteger as o}from"../config/environment-values.js";function L(r=process.env){const e=r.LOTAGATE_LOG_LEVEL?.trim().toLowerCase();return{level:e==="error"||e==="warn"||e==="debug"||e==="trace"?e:"info",retentionDays:o(r.LOTAGATE_LOG_RETENTION_DAYS,14,1,365)}}export{L as resolveLoggingPolicy};
@@ -0,0 +1,24 @@
1
+ import type { Logger, LogLevel } from '../../ports/logger.js';
2
+ import type { Writable } from 'node:stream';
3
+ import type { DailyRotatingFileWriter } from './daily-rotating-file-writer.js';
4
+ export interface StructuredLoggerOptions {
5
+ level?: LogLevel;
6
+ consoleLevel?: LogLevel;
7
+ json?: boolean;
8
+ output?: Writable;
9
+ file?: DailyRotatingFileWriter;
10
+ }
11
+ export declare class StructuredLogger implements Logger {
12
+ private readonly minimumPriority;
13
+ private readonly consoleMinimumPriority;
14
+ private readonly output;
15
+ private readonly json;
16
+ private readonly file;
17
+ constructor(options?: StructuredLoggerOptions);
18
+ error(message: string, details?: Record<string, unknown>): void;
19
+ warn(message: string, details?: Record<string, unknown>): void;
20
+ info(message: string, details?: Record<string, unknown>): void;
21
+ debug(message: string, details?: Record<string, unknown>): void;
22
+ trace(message: string, details?: Record<string, unknown>): void;
23
+ private write;
24
+ }
@@ -0,0 +1,4 @@
1
+ import{redactLogDetails as u,redactLogText as c}from"./log-redactor.js";const r={error:0,warn:1,info:2,debug:3,trace:4};class f{minimumPriority;consoleMinimumPriority;output;json;file;constructor(i={}){this.minimumPriority=r[i.level??"info"],this.consoleMinimumPriority=r[i.consoleLevel??i.level??"info"],this.output=i.output??process.stderr,this.json=i.json??!1,this.file=i.file}error(i,t){this.write("error",i,t)}warn(i,t){this.write("warn",i,t)}info(i,t){this.write("info",i,t)}debug(i,t){this.write("debug",i,t)}trace(i,t){this.write("trace",i,t)}write(i,t,o){if(r[i]>this.minimumPriority)return;const n=u(o),e=c(t),s={timestamp:new Date().toISOString(),level:i,message:e,...n??{}};r[i]<=this.consoleMinimumPriority&&this.output.write(this.json?`${JSON.stringify(s)}
2
+ `:`[${i}] ${e}
3
+ `);try{this.file?.write(`${JSON.stringify(s)}
4
+ `)}catch{}}}export{f as StructuredLogger};
@@ -0,0 +1,37 @@
1
+ import type { MemoryBundle, MemoryDraft, MemoryRecord } from '../../domain/memory/memory.js';
2
+ import { type MemorySearchHit, type MemorySearchQuery, type MemorySemanticHit } from '../../domain/memory/memory-search.js';
3
+ import type { MemoryListOptions, MemoryStore } from '../../ports/memory-store.js';
4
+ import type { PlatformPaths } from '../platform/platform-paths.js';
5
+ import type { Logger } from '../../ports/logger.js';
6
+ /** Local project memory. Journal writes are authoritative; index reads are the fast path. */
7
+ export declare class FileMemoryStore implements MemoryStore {
8
+ private readonly paths;
9
+ private readonly logger?;
10
+ constructor(paths: PlatformPaths, logger?: Logger | undefined);
11
+ list(cwd: string, options?: MemoryListOptions): Promise<readonly MemoryRecord[]>;
12
+ search(cwd: string, query: MemorySearchQuery): Promise<readonly MemorySearchHit[]>;
13
+ ensureSemanticIndex(cwd: string, model: string, embed: (texts: readonly string[], signal?: AbortSignal) => Promise<readonly number[][]>, signal?: AbortSignal): Promise<void>;
14
+ semanticSearch(cwd: string, model: string, vector: readonly number[], maximum: number): Promise<readonly MemorySemanticHit[]>;
15
+ get(cwd: string, id: string): Promise<MemoryRecord | undefined>;
16
+ consolidate(cwd: string, draft: MemoryDraft): Promise<{
17
+ record: MemoryRecord;
18
+ action: 'insert' | 'merge' | 'supersede' | 'ignore';
19
+ }>;
20
+ forget(cwd: string, id: string): Promise<boolean>;
21
+ clear(cwd: string): Promise<number>;
22
+ markRetrieved(cwd: string, ids: readonly string[]): Promise<void>;
23
+ export(cwd: string): Promise<MemoryBundle>;
24
+ import(cwd: string, bundle: MemoryBundle): Promise<{
25
+ imported: number;
26
+ skipped: number;
27
+ }>;
28
+ private resolvePaths;
29
+ private readRecords;
30
+ private readSearchIndex;
31
+ private readIndex;
32
+ private readJournal;
33
+ private append;
34
+ private replaceJournal;
35
+ private writeIndex;
36
+ private pruneSemanticIndex;
37
+ }
@@ -0,0 +1,11 @@
1
+ import V from"node:crypto";import j from"node:fs/promises";import S from"node:path";import{effectiveMemoryRecord as M,MEMORY_SCHEMA_VERSION as m,memoryRecordFromDraft as L,normalizeMemoryBundle as D,normalizeMemoryRecord as B}from"../../domain/memory/memory.js";import{buildMemorySearchIndex as z,isMemoryRetrievable as K,searchMemoryIndex as _}from"../../domain/memory/memory-search.js";import{memoryKindDefinition as U,MEMORY_KINDS as T}from"../../domain/memory/memory-kinds.js";import{RESOURCE_LIMITS as h}from"../../domain/runtime/resource-limits.js";import{atomicWriteFile as E,withFileLock as y}from"../filesystem/atomic-file-store.js";import{readJsonFileBounded as k}from"../filesystem/bounded-json-reader.js";import{isFileNotFound as O}from"../filesystem/fs-errors.js";import{createProjectKey as W}from"../sessions/project-session-paths.js";class pe{paths;logger;constructor(e,t){this.paths=e,this.logger=t}async list(e,t={}){return(await this.readRecords(this.resolvePaths(e))).map(i=>M(i)).filter(i=>t.kind===void 0||i.kind===t.kind).filter(i=>t.state===void 0||i.state===t.state).sort((i,n)=>n.updatedAt.localeCompare(i.updatedAt)||i.id.localeCompare(n.id))}async search(e,t){const r=this.resolvePaths(e),i=await this.readRecords(r),n=Object.fromEntries(i.map(a=>[a.id,M(a)])),o=await this.readSearchIndex(r,i);return _(n,o,t)}async ensureSemanticIndex(e,t,r,i){const n=this.resolvePaths(e),o=await this.readRecords(n),a=await J(n.semanticIndexFile),p=a?.model===t?a.entries:{},c=o.filter(d=>p[d.id]?.contentHash!==f(d));if(c.length===0)return;const l=await r(c.map(d=>`${d.statement}
2
+ ${d.rationale??""}
3
+ ${d.topics.join(" ")}`),i);if(l.length!==c.length)throw new Error("Embedding provider returned an unexpected number of vectors.");await y(n.journalFile,async()=>{const d=await this.readRecords(n,!0),g=await J(n.semanticIndexFile),v=g?.model===t?{...g.entries}:{};for(const[u,x]of c.entries()){const R=d.find(H=>H.id===x.id),F=l[u];R===void 0||F===void 0||f(R)!==f(x)||(P(F),v[x.id]={contentHash:f(x),vector:[...F]})}const A={schemaVersion:m,model:t,entries:v,updatedAt:I()},b=`${JSON.stringify(A)}
4
+ `;if(Buffer.byteLength(b,"utf8")>h.memoryIndexBytes)throw new Error("Memory semantic index exceeds the supported size limit.");await E(n.semanticIndexFile,b)},w())}async semanticSearch(e,t,r,i){if(i<=0)return[];P(r);const n=this.resolvePaths(e);return y(n.journalFile,async()=>{const o=await this.readRecords(n,!0),a=await J(n.semanticIndexFile);if(a?.model!==t)return[];const p=new Map(o.map(c=>[c.id,M(c)]));return Object.keys(a.entries).flatMap(c=>{const l=a.entries[c];if(l===void 0)return[];const d=p.get(c);return d===void 0||!K(d)?[]:[{record:d,similarity:G(r,l.vector),rank:0}]}).sort((c,l)=>l.similarity-c.similarity||c.record.id.localeCompare(l.record.id)).slice(0,i).map((c,l)=>({...c,rank:l+1}))},w())}async get(e,t){const r=this.resolvePaths(e);return(await this.readRecords(r)).map(n=>M(n)).find(n=>n.id===t)}async consolidate(e,t){const r=this.resolvePaths(e);return y(r.journalFile,async()=>{const i=I(),n=L(V.randomUUID(),t,i),o=await this.readRecords(r,!0),a=o.find(u=>f(u)===f(n));if(a!==void 0){const u={...a,...n.rationale===void 0&&a.rationale===void 0?{}:{rationale:n.rationale??a.rationale},topics:[...new Set([...a.topics,...n.topics])].sort(),evidenceRefs:[...new Set([...a.evidenceRefs,...n.evidenceRefs])],updatedAt:i};if(!(JSON.stringify(u)!==JSON.stringify(a)))return{record:a,action:"ignore"};const R=o.map(F=>F.id===a.id?u:F);return await this.append(r,[{schemaVersion:m,type:"upsert",record:u}]),await this.writeIndex(r,R),{record:u,action:"merge"}}const p=new Set(n.supersedes),c=o.filter(u=>u.state==="active"&&p.has(u.id)),l=o.find(u=>u.state==="active"&&u.kind===n.kind&&ee(n.kind)&&te(u,n));if(l!==void 0&&c.length===0)return{record:l,action:"ignore"};const d=n,g=c.map(u=>u.id),v=o.map(u=>g.includes(u.id)?{...u,state:"superseded",updatedAt:i}:u),A=[...v,d],b=[...v.filter((u,x)=>u!==o[x]).map(u=>({schemaVersion:m,type:"upsert",record:u})),{schemaVersion:m,type:"upsert",record:d}];if(A.length>h.memoryRecords)throw new Error("Memory capacity reached. Forget or clear memories before adding more.");return await this.append(r,b),await this.writeIndex(r,A),{record:d,action:g.length>0?"supersede":"insert"}},w())}async forget(e,t){const r=this.resolvePaths(e);return y(r.journalFile,async()=>{const i=await this.readRecords(r,!0),n=i.filter(o=>o.id!==t);return n.length===i.length?!1:(await this.replaceJournal(r,n),await this.writeIndex(r,n),await this.pruneSemanticIndex(r,n),!0)},w())}async clear(e){const t=this.resolvePaths(e);return y(t.journalFile,async()=>{const r=await this.readRecords(t,!0);return r.length===0?0:(await this.replaceJournal(t,[]),await this.writeIndex(t,[]),await this.pruneSemanticIndex(t,[]),r.length)},w())}async markRetrieved(e,t){if(t.length===0)return;const r=this.resolvePaths(e);await y(r.journalFile,async()=>{const i=new Set(t),n=I(),o=await this.readRecords(r,!0),a=o.map(c=>i.has(c.id)?{...c,retrievalCount:c.retrievalCount+1,lastRetrievedAt:n,updatedAt:n}:c),p=a.filter((c,l)=>c!==o[l]).map(c=>({schemaVersion:m,type:"upsert",record:c}));p.length!==0&&(await this.append(r,p),await this.writeIndex(r,a))},w())}async export(e){return{schemaVersion:m,exportedAt:I(),records:await this.list(e)}}async import(e,t){const r=D(t),i=this.resolvePaths(e);return y(i.journalFile,async()=>{const n=await this.readRecords(i,!0),o=new Set(n.map(d=>d.id)),a=new Set(n.map(f)),p=r.records.filter(d=>!o.has(d.id)&&!a.has(f(d)));if(n.length+p.length>h.memoryRecords)throw new Error("Import exceeds the local memory capacity.");const c=I(),l=p.map(d=>({...d,source:"imported",state:"active",updatedAt:c}));if(l.length>0){const d=[...n,...l];await this.append(i,l.map(g=>({schemaVersion:m,type:"upsert",record:g}))),await this.writeIndex(i,d)}return{imported:l.length,skipped:r.records.length-l.length}},w())}resolvePaths(e){const t=S.join(this.paths.projectsDir,W(e,this.paths.platform),"memory");return{directory:t,journalFile:S.join(t,"journal.jsonl"),indexFile:S.join(t,"index.json"),semanticIndexFile:S.join(t,"semantic-index.json")}}async readRecords(e,t=!1){if(!t)return y(e.journalFile,()=>this.readRecords(e,!0),w());const r=await C(e.journalFile),i=await this.readIndex(e.indexFile);if(i?.journalFingerprint===r)return i.records;const n=Q(await this.readJournal(e.journalFile));return await this.writeIndex(e,n),this.logger?.info("memory.index.rebuilt",{projectKey:Z(e.directory),count:n.length}),n}async readSearchIndex(e,t){const r=await this.readIndex(e.indexFile);return r!==void 0&&r.records.length===t.length&&r.records.every((n,o)=>n.id===t[o]?.id&&n.updatedAt===t[o]?.updatedAt)?r.search:z(t)}async readIndex(e){try{const t=await k(e,h.memoryIndexBytes);return q(t)}catch(t){return O(t),void 0}}async readJournal(e){let t;try{if((await j.stat(e)).size>h.memoryJournalBytes)throw new Error("Memory journal exceeds the supported size limit. Export and clear memory before continuing.");t=await j.readFile(e,"utf8")}catch(r){if(O(r))return[];throw r}try{return N(t)}catch(r){if(!t.endsWith(`
5
+ `))return await new Promise(i=>setImmediate(i)),N(await j.readFile(e,"utf8"));throw r}}async append(e,t){if(t.length===0)return;await j.mkdir(e.directory,{recursive:!0});const r=t.map(n=>JSON.stringify(n)).join(`
6
+ `).concat(`
7
+ `);if(await X(e.journalFile)+Buffer.byteLength(r,"utf8")>h.memoryJournalBytes)throw new Error("Memory journal exceeds the supported size limit. Export and clear memory before continuing.");await j.appendFile(e.journalFile,r,{encoding:"utf8",mode:384})}async replaceJournal(e,t){const r=t.map(n=>({schemaVersion:m,type:"upsert",record:n})),i=r.length===0?"":`${r.map(n=>JSON.stringify(n)).join(`
8
+ `)}
9
+ `;if(Buffer.byteLength(i,"utf8")>h.memoryJournalBytes)throw new Error("Memory journal exceeds the supported size limit.");await E(e.journalFile,i)}async writeIndex(e,t,r=z(t)){const i={schemaVersion:m,journalFingerprint:await C(e.journalFile),records:t,search:r,...$(t),updatedAt:I()},n=`${JSON.stringify(i,null,2)}
10
+ `;if(Buffer.byteLength(n,"utf8")>h.memoryIndexBytes)throw new Error("Memory index exceeds the supported size limit.");await E(e.indexFile,n)}async pruneSemanticIndex(e,t){const r=await J(e.semanticIndexFile);if(r===void 0)return;const i=new Map(t.map(o=>[o.id,o])),n=Object.fromEntries(Object.entries(r.entries).filter(([o,a])=>i.get(o)!==void 0&&f(i.get(o))===a.contentHash));await E(e.semanticIndexFile,`${JSON.stringify({...r,entries:n,updatedAt:I()})}
11
+ `)}}function N(s){return s.split(/\r?\n/u).filter(Boolean).map(e=>Y(JSON.parse(e)))}function Y(s){if(typeof s!="object"||s===null||Array.isArray(s))throw new Error("Invalid memory journal entry.");const e=s;if(e.schemaVersion!==m||e.type!=="upsert")throw new Error("Unsupported memory journal entry.");return{schemaVersion:m,type:"upsert",record:B(e.record)}}function q(s){if(typeof s!="object"||s===null||Array.isArray(s))return;const e=s;if(!(e.schemaVersion!==m||typeof e.journalFingerprint!="string"||typeof e.updatedAt!="string"||!Array.isArray(e.records)))try{const t=e.records.map(i=>B(i)),r=z(t);return{schemaVersion:m,journalFingerprint:e.journalFingerprint,records:t,search:r,...$(t),updatedAt:e.updatedAt}}catch{return}}async function J(s){try{const e=await k(s,h.memoryIndexBytes);if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(t.schemaVersion!==m||typeof t.model!="string"||typeof t.updatedAt!="string"||typeof t.entries!="object"||t.entries===null||Array.isArray(t.entries))return;const r={};for(const[i,n]of Object.entries(t.entries)){if(typeof n!="object"||n===null||Array.isArray(n))return;const o=n;if(typeof o.contentHash!="string"||!Array.isArray(o.vector)||o.vector.some(a=>typeof a!="number"||!Number.isFinite(a)))return;r[i]={contentHash:o.contentHash,vector:o.vector}}return{schemaVersion:m,model:t.model,entries:r,updatedAt:t.updatedAt}}catch{return}}function P(s){if(s.length===0||s.length>4096||s.some(e=>!Number.isFinite(e)))throw new Error("Embedding vector is invalid.")}function G(s,e){if(s.length!==e.length)return-1;let t=0,r=0,i=0;for(let n=0;n<s.length;n+=1)t+=s[n]*e[n],r+=s[n]**2,i+=e[n]**2;return r===0||i===0?0:t/Math.sqrt(r*i)}function Q(s){const e=new Map;for(const t of s)e.set(t.record.id,t.record);return[...e.values()]}function $(s){const e=Object.fromEntries(T.map(r=>[r,s.filter(i=>i.kind===r).map(i=>i.id)])),t=Object.fromEntries(["active","superseded","expired"].map(r=>[r,s.filter(i=>i.state===r).map(i=>i.id)]));return{activeIds:s.filter(r=>r.state==="active").map(r=>r.id),kindIds:e,stateIds:t}}async function X(s){try{return(await j.stat(s)).size}catch(e){if(O(e))return 0;throw e}}async function C(s){try{const e=await j.stat(s);return`${e.size}:${e.mtimeMs}`}catch(e){if(O(e))return"missing";throw e}}function f(s){return V.createHash("sha256").update(`${s.kind}\0${s.statement.trim().toLocaleLowerCase()}\0${s.topics.join("\0")}`,"utf8").digest("hex")}function Z(s){return V.createHash("sha256").update(s,"utf8").digest("hex").slice(0,16)}function ee(s){return U(s).consolidationPolicy==="retain-on-conflict"}function te(s,e){if(s.topics.length===0||e.topics.length===0)return!1;const t=new Set(s.topics);return e.topics.some(r=>t.has(r))}function w(){return{userMessage:"Memory is being updated by another LotaGate process. Try again shortly."}}function I(){return new Date().toISOString()}export{pe as FileMemoryStore};
@@ -0,0 +1,23 @@
1
+ import https from 'node:https';
2
+ export interface DownloadedMedia {
3
+ readonly bytes: Uint8Array;
4
+ readonly contentType: string | undefined;
5
+ }
6
+ export interface PublicMediaAddress {
7
+ readonly address: string;
8
+ readonly family: 4 | 6;
9
+ }
10
+ export interface PublicMediaDownloaderDependencies {
11
+ resolveAddresses?: (hostname: string) => Promise<readonly PublicMediaAddress[]>;
12
+ request?: typeof https.request;
13
+ }
14
+ interface DownloadOptions {
15
+ readonly maxBytes: number;
16
+ readonly timeoutMs: number;
17
+ readonly signal?: AbortSignal | undefined;
18
+ }
19
+ /** Downloads a generated artifact only through a verified public HTTPS address. */
20
+ export declare function downloadPublicMedia(rawUrl: string | undefined, options: DownloadOptions): Promise<DownloadedMedia>;
21
+ /** Creates an isolated downloader for CLI infrastructure tests and alternate Node transports. */
22
+ export declare function createPublicMediaDownloader(dependencies?: PublicMediaDownloaderDependencies): (rawUrl: string | undefined, options: DownloadOptions) => Promise<DownloadedMedia>;
23
+ export {};
@@ -0,0 +1 @@
1
+ import{lookup as v}from"node:dns/promises";import E from"node:https";import{isIP as L}from"node:net";import{CliError as h}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as b}from"../../domain/errors/error-codes.js";async function H(e,t){return I()(e,t)}function I(e={}){const t=e.resolveAddresses??P,r=e.request??E.request;return async(o,n)=>{const s=g(o);return D(n,async d=>{const l=await R(s.hostname,t,d,n.signal),i=await A(s,l,r,d,n.signal);if(i.statusCode===void 0||i.statusCode<200||i.statusCode>=300)throw i.destroy(),f(`Image download failed with HTTP ${i.statusCode??"unknown"}.`);const a=i.headers["content-length"],c=Array.isArray(a)?a[0]:a;if(c!==void 0&&(!/^\d+$/u.test(c)||Number(c)>n.maxBytes))throw i.destroy(),f("Downloaded image exceeds the supported output limit.");return{bytes:await C(i,n.maxBytes,d,n.signal),contentType:$(i.headers["content-type"])}})}}function g(e){if(e===void 0)throw f("The provider returned an image without Base64 data or a download URL.");let t;try{t=new URL(e)}catch{throw f("The provider returned an invalid image download URL.")}if(t.protocol!=="https:"||t.username||t.password||t.port!==""&&t.port!=="443")throw f("Image download URLs must use public HTTPS on port 443.");return t}async function R(e,t,r,o){if(e.toLowerCase()==="localhost")throw f("Image download URL must not target localhost.");const n=await U(t(e),r,o);if(n.length===0||n.some(s=>!B(s.address)))throw f("Image download URL must resolve only to public network addresses.");return n}async function P(e){return(await v(e,{all:!0,verbatim:!0})).map(r=>({address:r.address,family:r.family===6?6:4}))}async function A(e,t,r,o,n){let s;for(const l of t)try{return await T(e,l,r,o,n)}catch(i){if(o.aborted)throw m(n);s=i}const d=s instanceof Error&&s.message.length>0?`: ${s.message}`:"";throw f(`Image download failed${d}`)}function T(e,t,r,o,n){return new Promise((s,d)=>{let l=!1,i;const a=u=>{l||(l=!0,o.removeEventListener("abort",c),u())},c=()=>{const u=m(n);i?.destroy(u),a(()=>d(u))};try{i=r({protocol:"https:",hostname:e.hostname,port:443,path:`${e.pathname}${e.search}`,method:"GET",servername:e.hostname,lookup:(u,p,w)=>{p.all===!0?w(null,[{address:t.address,family:t.family}]):w(null,t.address,t.family)}},u=>a(()=>s(u))),i.once("error",u=>a(()=>d(u))),o.aborted?c():o.addEventListener("abort",c,{once:!0}),i.end()}catch(u){a(()=>d(u))}})}async function C(e,t,r,o){const n=[];let s=0;const d=()=>{e.destroy()};r.aborted?d():r.addEventListener("abort",d,{once:!0});try{for await(const a of e){if(r.aborted)throw m(o);const c=Buffer.isBuffer(a)?a:Buffer.from(a);if(s+=c.byteLength,s>t)throw e.destroy(),f("Downloaded image exceeds the supported output limit.");n.push(c)}}catch(a){throw r.aborted?m(o):a instanceof h?a:f(a instanceof Error?`Image download failed: ${a.message}`:"Image download failed.")}finally{r.removeEventListener("abort",d)}if(r.aborted)throw m(o);const l=new Uint8Array(s);let i=0;for(const a of n)l.set(a,i),i+=a.byteLength;return l}async function D(e,t){const r=new AbortController,o=setTimeout(()=>r.abort(new Error("Image download timed out.")),e.timeoutMs),n=()=>r.abort(e.signal?.reason);e.signal?.aborted?n():e.signal?.addEventListener("abort",n,{once:!0});try{return await t(r.signal)}finally{clearTimeout(o),e.signal?.removeEventListener("abort",n)}}async function U(e,t,r){if(t.aborted)throw m(r);return new Promise((o,n)=>{const s=()=>{t.removeEventListener("abort",s),n(m(r))};t.addEventListener("abort",s,{once:!0}),e.then(d=>{t.removeEventListener("abort",s),o(d)},d=>{t.removeEventListener("abort",s),n(d)})})}function $(e){return(Array.isArray(e)?e[0]:e)?.split(";",1)[0]?.trim()||void 0}function B(e){const t=L(e);return t===4?y(e):t===6?k(e):!1}function y(e){const t=e.split(".").map(Number),[r,o]=t;return!(r===void 0||o===void 0||r===0||r===10||r===127||r>=224||r===100&&o>=64&&o<=127||r===169&&o===254||r===172&&o>=16&&o<=31||r===192&&o===168||r===198&&(o===18||o===19))}function k(e){const t=e.toLowerCase();if(t==="::"||t==="::1"||t.startsWith("fe80:")||t.startsWith("fc")||t.startsWith("fd"))return!1;const r=t.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/u);return r===null||y(r[1])}function m(e){return e?.aborted?q(e.reason):f("Image download timed out.")}function q(e){return new h(b.INTERRUPTED,"Media command interrupted.",{category:"media",userMessage:"Media command interrupted.",retryable:!0,cause:e})}function f(e){return new h(b.INVALID_ARGUMENT,e,{category:"media",userMessage:e})}export{I as createPublicMediaDownloader,H as downloadPublicMedia};
@@ -0,0 +1,14 @@
1
+ export type HostPlatformId = 'windows' | 'linux' | 'macos' | 'bsd' | 'unsupported';
2
+ export type HostNodePlatform = typeof process.platform;
3
+ export interface HostPlatformContext {
4
+ readonly id: HostPlatformId;
5
+ readonly nodePlatform: HostNodePlatform;
6
+ readonly isWindows: boolean;
7
+ readonly supportsProcessGroups: boolean;
8
+ readonly env: Readonly<Record<string, string | undefined>>;
9
+ }
10
+ export interface HostPlatformInput {
11
+ nodePlatform?: HostNodePlatform;
12
+ env?: Readonly<Record<string, string | undefined>>;
13
+ }
14
+ export declare function detectHostPlatform(input?: HostPlatformInput): HostPlatformContext;
@@ -0,0 +1 @@
1
+ function i(n={}){const e=n.nodePlatform??process.platform,s=o(e),r=s==="windows";return{id:s,nodePlatform:e,isWindows:r,supportsProcessGroups:!r,env:n.env??process.env}}function o(n){return n==="win32"||n==="cygwin"?"windows":n==="linux"||n==="android"?"linux":n==="darwin"?"macos":n==="freebsd"||n==="openbsd"||n==="netbsd"?"bsd":"unsupported"}export{i as detectHostPlatform};
@@ -0,0 +1,29 @@
1
+ import { type ChildProcess, type SpawnOptions } from 'node:child_process';
2
+ import type { HostPlatformContext } from './host-platform.js';
3
+ export { terminatePlatformProcess } from './process-termination.js';
4
+ export interface PreparedPlatformCommand {
5
+ command: string;
6
+ args: readonly string[];
7
+ windowsVerbatimArguments: boolean;
8
+ }
9
+ /** Normalizes the structured shell contract for a complete PowerShell script. */
10
+ export declare function normalizePowerShellScriptInput(input: Record<string, unknown>, platform: HostPlatformContext): Record<string, unknown>;
11
+ export declare function preparePowerShellScript(command: string, script: string): PreparedPlatformCommand;
12
+ export declare function isPowerShellExecutable(command: string): boolean;
13
+ export interface PlatformExecOptions {
14
+ cwd?: string;
15
+ env?: NonNullable<SpawnOptions['env']>;
16
+ maxBufferBytes?: number;
17
+ timeoutMs?: number;
18
+ signal?: AbortSignal;
19
+ rejectOnNonZero?: boolean;
20
+ }
21
+ export interface PlatformExecResult {
22
+ stdout: string;
23
+ stderr: string;
24
+ exitCode: number | null;
25
+ }
26
+ export declare function spawnPlatformProcess(command: string, args: readonly string[], platform: HostPlatformContext, options?: SpawnOptions): ChildProcess;
27
+ export declare function execPlatformCommand(command: string, args: readonly string[], platform: HostPlatformContext, options?: PlatformExecOptions): Promise<PlatformExecResult>;
28
+ export declare function createSafeChildEnvironment(platform: HostPlatformContext): NonNullable<SpawnOptions['env']>;
29
+ export declare function preparePlatformCommand(command: string, args: readonly string[], platform: HostPlatformContext): PreparedPlatformCommand;
@@ -0,0 +1 @@
1
+ import T from"node:path";import{spawn as b}from"node:child_process";import{RESOURCE_LIMITS as L}from"../../domain/runtime/resource-limits.js";import{terminatePlatformProcess as M}from"./process-termination.js";import{terminatePlatformProcess as z}from"./process-termination.js";const _=2*1024*1024,h=/([()\][%!^"`<>&|;, *?])/gu,$=/\.(?:com|exe)$/iu,v=/node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/iu;function F(e,n){const r=e.script;if(r===void 0)return e;if(typeof r!="string"||r.trim().length===0)throw new Error("shell.exec script must be a non-empty string.");if(Buffer.byteLength(r,"utf8")>L.sessionTextBytes)throw new Error("shell.exec script exceeds the configured limit.");const t=e.command;if(typeof t!="string"||!I(t))throw new Error("shell.exec script requires powershell.exe or pwsh.exe as the command.");const o=e.args;if(o!==void 0&&(!Array.isArray(o)||o.length>0||o.some(i=>typeof i!="string")))throw new Error("shell.exec script cannot be combined with args.");const a=y(t,r),u={...e};return delete u.script,{...u,command:a.command,args:[...a.args]}}function y(e,n){return{command:e,args:["-NoProfile","-NonInteractive","-Command",n],windowsVerbatimArguments:!1}}function I(e){const n=e.replace(/^.*[\\/]/u,"").toLowerCase();return n==="powershell"||n==="powershell.exe"||n==="pwsh"||n==="pwsh.exe"}function D(e,n,r,t={}){const o=O(e,n,r);return b(o.command,[...o.args],{...t,shell:!1,windowsHide:!0,...o.windowsVerbatimArguments?{windowsVerbatimArguments:!0}:{}})}function G(e,n,r,t={}){if(t.signal?.aborted)return Promise.reject(new Error("Process cancelled."));const o=t.maxBufferBytes??_,a=t.timeoutMs??L.internalProcessTimeoutMs;return new Promise((u,i)=>{const d=D(e,n,r,{...t.cwd===void 0?{}:{cwd:t.cwd},env:t.env??B(r),detached:r.supportsProcessGroups,stdio:["ignore","pipe","pipe"]}),A=[],p=[];let w=0,c=!1,l=!1,x=!1,S=!1,g;const m=()=>{g!==void 0&&clearTimeout(g),t.signal?.removeEventListener("abort",P)},P=()=>{S=!0,E(new Error("Process cancelled."))},E=s=>{l||c||(l=!0,M(d,r).then(()=>{c||(c=!0,m(),i(s))},f=>{c||(c=!0,m(),i(new AggregateError([s,f],`${s.message} Termination could not be confirmed.`)))}))},C=(s,f)=>{if(!(c||l)){if(w+=f.byteLength,w>o){E(new Error("Process output exceeded the configured limit."));return}s.push(f)}};d.stdout?.on("data",s=>C(A,s)),d.stderr?.on("data",s=>C(p,s)),d.once("error",s=>{c||l||(c=!0,m(),i(s))}),d.once("close",s=>{c||(c=!0,m(),S?i(new Error("Process cancelled.")):x?i(new Error(`Process timed out after ${a}ms.`)):w>o?i(new Error("Process output exceeded the configured limit.")):s===0||t.rejectOnNonZero===!1?u({stdout:Buffer.concat(A).toString("utf8"),stderr:Buffer.concat(p).toString("utf8"),exitCode:s}):i(new Error(Buffer.concat(p).toString("utf8").trim()||`Process exited with code ${String(s)}.`)))}),g=setTimeout(()=>{x=!0,E(new Error(`Process timed out after ${a}ms.`))},a),t.signal?.aborted===!0?P():t.signal?.addEventListener("abort",P,{once:!0})})}function B(e){const n=e.isWindows?["PATHEXT","SystemRoot","ComSpec","COMSPEC","TEMP","TMP","HOME","USERPROFILE","APPDATA","LOCALAPPDATA","LANG","LC_ALL"]:["PATH","HOME","TMPDIR","TEMP","LANG","LC_ALL","XDG_RUNTIME_DIR","WAYLAND_DISPLAY","DISPLAY"],r={};if(e.isWindows){const t=e.env.Path??e.env.PATH;t!==void 0&&(r.Path=t)}for(const t of n){const o=e.env[t];o!==void 0&&(r[t]=o)}return r}function O(e,n,r){if(!r.isWindows||$.test(e))return{command:e,args:n,windowsVerbatimArguments:!1};const t=T.win32.normalize(e),o=v.test(t),a=W(t),u=n.map(i=>R(i,o));return{command:r.env.ComSpec??r.env.COMSPEC??"cmd.exe",args:["/d","/s","/c",`"${[a,...u].join(" ")}"`],windowsVerbatimArguments:!0}}function W(e){return e.replace(h,"^$1")}function R(e,n){let r=e.replace(/(?=(\\+?)?)\1"/gu,'$1$1\\"').replace(/(?=(\\+?)?)\1$/gu,"$1$1");return r=`"${r}"`.replace(h,"^$1"),n?r.replace(h,"^$1"):r}export{B as createSafeChildEnvironment,G as execPlatformCommand,I as isPowerShellExecutable,F as normalizePowerShellScriptInput,O as preparePlatformCommand,y as preparePowerShellScript,D as spawnPlatformProcess,z as terminatePlatformProcess};
@@ -0,0 +1,25 @@
1
+ import { type HostPlatformContext } from './host-platform.js';
2
+ export interface PlatformPaths {
3
+ platform: HostPlatformContext;
4
+ home: string;
5
+ globalConfigDir: string;
6
+ globalConfigFile: string;
7
+ credentialsFile: string;
8
+ credentialKeyFile: string;
9
+ projectsDir: string;
10
+ cacheDir: string;
11
+ logsDir: string;
12
+ skillsDir: string;
13
+ pluginsDir: string;
14
+ mcpConfigFile: string;
15
+ }
16
+ export declare function resolvePlatformPaths(env?: Readonly<Record<string, string | undefined>>, platform?: HostPlatformContext): PlatformPaths;
17
+ export declare function resolveProjectConfigPaths(cwd: string): {
18
+ directory: string;
19
+ settings: string;
20
+ localSettings: string;
21
+ skillsDir: string;
22
+ pluginsDir: string;
23
+ hooksDir: string;
24
+ mcpConfigFile: string;
25
+ };
@@ -0,0 +1 @@
1
+ import e from"node:os";import o from"node:path";import{detectHostPlatform as r}from"./host-platform.js";function g(s=process.env,n=r({env:s})){const t=s.LOTAGATE_HOME?.trim()||e.homedir(),i=o.join(t,".lotagate");return{platform:n,home:t,globalConfigDir:i,globalConfigFile:o.join(i,"settings.json"),credentialsFile:o.join(i,"credentials.enc.json"),credentialKeyFile:o.join(i,"credentials.key"),projectsDir:o.join(i,"projects"),cacheDir:o.join(i,"cache"),logsDir:o.join(i,"logs"),skillsDir:o.join(i,"skills"),pluginsDir:o.join(i,"plugins"),mcpConfigFile:o.join(i,"mcp.json")}}function a(s){const n=o.join(s,".lotagate");return{directory:n,settings:o.join(n,"settings.json"),localSettings:o.join(n,"settings.local.json"),skillsDir:o.join(n,"skills"),pluginsDir:o.join(n,"plugins"),hooksDir:o.join(n,"hooks"),mcpConfigFile:o.join(n,"mcp.json")}}export{g as resolvePlatformPaths,a as resolveProjectConfigPaths};
@@ -0,0 +1,4 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ import type { HostPlatformContext } from './host-platform.js';
3
+ /** Requests termination, escalates, and observes close within a bounded deadline. */
4
+ export declare function terminatePlatformProcess(child: ChildProcess, platform: HostPlatformContext): Promise<void>;
@@ -0,0 +1 @@
1
+ import{spawn as T}from"node:child_process";import{RESOURCE_LIMITS as p}from"../../domain/runtime/resource-limits.js";const d=new WeakMap;function k(e,s){const u=d.get(e);if(u!==void 0)return u;if(e.pid===void 0||e.exitCode!==null||e.signalCode!==null)return Promise.resolve();const a=new Promise((f,l)=>{let t,r;const i=()=>{if(clearTimeout(g),t!==void 0&&clearTimeout(t),e.removeListener("close",c),e.removeListener("error",m),r!==void 0&&r.exitCode===null&&r.signalCode===null)try{r.kill()}catch{}},c=()=>{i(),f()},m=n=>{i(),l(n)},o=n=>{if(s.supportsProcessGroups)try{process.kill(-e.pid,n?"SIGKILL":"SIGTERM");return}catch{}try{e.kill(n?"SIGKILL":"SIGTERM")}catch{}},g=setTimeout(()=>{o(!0),i(),l(new Error(`Process ${String(e.pid)} did not close after forced termination.`))},p.processTerminationTimeoutMs);e.once("close",c),e.once("error",m),s.isWindows?(r=T("taskkill",["/pid",String(e.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}),r.once("error",()=>o(!0)),r.once("exit",n=>{n!==0&&o(!0)})):(o(!1),t=setTimeout(()=>o(!0),p.processTerminationGraceMs))});return d.set(e,a),a}export{k as terminatePlatformProcess};
@@ -0,0 +1,3 @@
1
+ /** Resolves user-installed host binaries from PATH, never from the workspace. */
2
+ export declare function resolveReadOnlyExecutable(command: string, root: string): Promise<string | undefined>;
3
+ export declare function readOnlyArguments(command: string, args: readonly string[]): string[];
@@ -0,0 +1 @@
1
+ import f from"node:fs/promises";import{constants as p}from"node:fs";import t from"node:path";async function m(o,e){if(/[\\/:]/u.test(o)||/\.(?:cmd|bat|ps1)$/iu.test(o))return;let n;try{n=await f.realpath(e)}catch{return}const s=process.platform==="win32"&&!/\.(?:exe|com)$/iu.test(o)?[".exe",".com"]:[""];for(const i of(process.env.PATH??process.env.Path??"").split(t.delimiter))if(t.isAbsolute(i))for(const l of s){const u=t.join(i,`${o}${l}`),r=t.relative(n,u);if(!(r===""||!r.startsWith(`..${t.sep}`)&&r!==".."&&!t.isAbsolute(r)))try{const c=await f.realpath(u),a=t.relative(n,c);if(a===""||!a.startsWith(`..${t.sep}`)&&a!==".."&&!t.isAbsolute(a)||!(await f.stat(c)).isFile())continue;return await f.access(c,process.platform==="win32"?p.F_OK:p.X_OK),c}catch{}}}function v(o,e){if(o.toLowerCase().replace(/\.exe$/u,"")!=="git")return[...e];const n=e.find(l=>!l.startsWith("-")),s=["--no-pager","--no-optional-locks","-c","core.fsmonitor=false",...["diff","log","show"].includes(n??"")?["--no-ext-diff","--no-textconv"]:[]],i=e.indexOf("--");return i<0?[...s,...e]:[...s,...e.slice(0,i),...e.slice(i)]}export{v as readOnlyArguments,m as resolveReadOnlyExecutable};
@@ -0,0 +1,12 @@
1
+ import type { ProjectTrustStore, TrustedProject } from '../../ports/project-trust-store.js';
2
+ import type { PlatformPaths } from '../platform/platform-paths.js';
3
+ export declare class FileProjectTrustStore implements ProjectTrustStore {
4
+ private readonly filePath;
5
+ constructor(paths: PlatformPaths);
6
+ list(): Promise<readonly TrustedProject[]>;
7
+ get(fingerprint: string): Promise<TrustedProject | undefined>;
8
+ grant(project: TrustedProject): Promise<void>;
9
+ revoke(fingerprint: string): Promise<boolean>;
10
+ private read;
11
+ private write;
12
+ }
@@ -0,0 +1,2 @@
1
+ import a from"node:fs/promises";import n from"node:path";import{isFileNotFound as c}from"../filesystem/fs-errors.js";import{atomicWriteFile as f,withFileLock as o}from"../filesystem/atomic-file-store.js";import{readJsonFileBounded as l}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as h}from"../../domain/runtime/resource-limits.js";class g{filePath;constructor(t){this.filePath=n.join(t.globalConfigDir,"trusted-projects.json")}async list(){return(await this.read()).projects}async get(t){return(await this.read()).projects.find(r=>r.fingerprint===t)}async grant(t){await o(this.filePath,async()=>{const i=(await this.read()).projects.filter(s=>s.fingerprint!==t.fingerprint);i.push(t),await this.write({version:1,projects:i})})}async revoke(t){return o(this.filePath,async()=>{const r=await this.read(),i=r.projects.filter(s=>s.fingerprint!==t);return i.length===r.projects.length?!1:(await this.write({version:1,projects:i}),!0)})}async read(){try{const t=await l(this.filePath,h.configFileBytes);if(!p(t))throw new Error("Invalid trust file.");return t}catch(t){if(c(t))return{version:1,projects:[]};throw t}}async write(t){await a.mkdir(n.dirname(this.filePath),{recursive:!0}),await f(this.filePath,`${JSON.stringify(t,null,2)}
2
+ `)}}function p(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version===1&&Array.isArray(t.projects)}export{g as FileProjectTrustStore};
@@ -0,0 +1,8 @@
1
+ import { type LotaGate } from '@lotagate/sdk';
2
+ import type { ChatModelPort, ChatModelRequest, ChatModelEvent } from '../../ports/chat-model.js';
3
+ export declare class SdkChatCompletionAdapter implements ChatModelPort {
4
+ private readonly client;
5
+ constructor(client: LotaGate);
6
+ stream(request: ChatModelRequest): AsyncIterable<ChatModelEvent>;
7
+ private fallbackToBufferedCompletion;
8
+ }
@@ -0,0 +1 @@
1
+ import{SdkErrorCode as m}from"@lotagate/sdk";import{CliError as l}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as c}from"../../domain/errors/error-codes.js";import{buildUserMessage as p}from"../clipboard/image-normalizer.js";import{retryModelStream as y}from"../../application/model/model-response-retry.js";class w{client;constructor(e){this.client=e}async*stream(e){const n=[p(e.prompt,e.attachments)],i=e.signal===void 0?void 0:{signal:e.signal};let o=!1;try{yield{type:"activity",state:"connecting"};const a=y({create:async()=>await this.client.chat.completions.create({model:e.model,messages:n,...e.reasoningEffort===void 0?{}:{reasoning_effort:e.reasoningEffort},stream:!0},i),isObservable:r=>typeof r.choices[0]?.delta.content=="string"&&r.choices[0].delta.content.length>0,...e.signal===void 0?{}:{signal:e.signal}});yield{type:"activity",state:"thinking"};for await(const r of a){r.usage!==void 0&&(yield{type:"usage",usage:f(r.usage)});const s=r.choices[0]?.delta.content;typeof s=="string"&&s.length>0&&(o=!0,yield{type:"activity",state:"writing"},yield{type:"delta",content:s})}yield{type:"activity",state:"completed"},yield{type:"completed"}}catch(a){if(e.signal?.aborted===!0)throw e.signal.reason??d();if(!o&&g(a)){yield*this.fallbackToBufferedCompletion(e,n,i);return}throw new l(c.MODEL_STREAM_FAILED,"Chat completion stream failed.",{category:"model",userMessage:"Unable to read the model stream. The gateway may have returned an invalid SSE payload. Check the model, authentication and base URL.",retryable:!0,cause:a})}}async*fallbackToBufferedCompletion(e,n,i){try{const o=await this.client.chat.completions.create({model:e.model,messages:[...n],...e.reasoningEffort===void 0?{}:{reasoning_effort:e.reasoningEffort},stream:!1},i);o.usage!==void 0&&(yield{type:"usage",usage:f(o.usage)});const a=h(o.choices[0]?.message.content);a.length>0&&(yield{type:"activity",state:"writing"},yield{type:"delta",content:a}),yield{type:"activity",state:"completed"},yield{type:"completed"}}catch(o){throw e.signal?.aborted===!0?e.signal.reason??d():new l(c.MODEL_STREAM_FAILED,"Chat completion fallback failed.",{category:"model",userMessage:"Unable to read the model response. Check the model, authentication and base URL.",retryable:!0,cause:o})}}}function d(){const t=new Error("The operation was aborted.");return t.name="AbortError",t}function f(t){return{...typeof t.prompt_tokens=="number"?{promptTokens:t.prompt_tokens}:{},...typeof t.completion_tokens=="number"?{completionTokens:t.completion_tokens}:{},...typeof t.total_tokens=="number"?{totalTokens:t.total_tokens}:{}}}function g(t){return typeof t=="object"&&t!==null&&"errorCode"in t&&t.errorCode===m.ResponseParseError}function h(t){return typeof t=="string"?t:Array.isArray(t)?t.map(e=>{if(typeof e!="object"||e===null||!("text"in e))return"";const n=e.text;return typeof n=="string"?n:""}).join(""):""}export{w as SdkChatCompletionAdapter};
@@ -0,0 +1,3 @@
1
+ import { LotaGate } from '@lotagate/sdk';
2
+ import type { AuthProfile } from '../../domain/auth/auth-profile.js';
3
+ export declare function createLotaGateClient(profile: AuthProfile, apiKey: string): LotaGate;
@@ -0,0 +1 @@
1
+ import{LotaGate as a}from"@lotagate/sdk";function r(t,e){const o={apiKey:e,baseURL:t.baseUrl};return new a(o)}export{r as createLotaGateClient};
@@ -0,0 +1,19 @@
1
+ import type { ModelListResponse, ModelSummary } from '@lotagate/sdk';
2
+ export interface ModelCatalogClient {
3
+ models: {
4
+ list(): Promise<ModelListResponse>;
5
+ retrieve(model: string): Promise<ModelSummary>;
6
+ };
7
+ }
8
+ export declare class ModelCatalogAdapter {
9
+ private readonly client;
10
+ constructor(client: ModelCatalogClient);
11
+ /** Lists every selectable gateway model while excluding embeddings from interactive selection. */
12
+ listModels(): Promise<{
13
+ data: ModelSummary[];
14
+ object: "list" | string;
15
+ }>;
16
+ get(model: string): Promise<ModelSummary>;
17
+ }
18
+ /** Reads the optional gateway metadata without coupling the CLI to SDK internals. */
19
+ export declare function getModelContextWindow(model: ModelSummary): number | undefined;
@@ -0,0 +1 @@
1
+ class r{client;constructor(e){this.client=e}async listModels(){const e=await this.client.models.list();return{...e,data:e.data.filter(t=>t.model_category!=="embedding")}}async get(e){return this.client.models.retrieve(e)}}function i(n){const e=n.context_window;if(typeof e=="number"&&Number.isInteger(e)&&e>0)return e;if(typeof e=="string"&&/^\d+$/u.test(e)){const t=Number(e);return Number.isSafeInteger(t)&&t>0?t:void 0}}export{r as ModelCatalogAdapter,i as getModelContextWindow};
@@ -0,0 +1,20 @@
1
+ import type { LotaGate } from '@lotagate/sdk';
2
+ import type { MediaGatewayClient, AudioUploadInput, ImageEditInput, ImageGenerationInput, MediaRequestOptions, SpeechInput } from '../../ports/media-gateway-client.js';
3
+ import type { GeneratedImage, MediaBinary, VideoOperation } from '../../domain/media/media-contract.js';
4
+ /** SDK boundary adapter. Application code only sees CLI-owned media contracts. */
5
+ export declare class SdkMediaGatewayClient implements MediaGatewayClient {
6
+ private readonly client;
7
+ constructor(client: LotaGate);
8
+ generateImage(input: ImageGenerationInput, options?: MediaRequestOptions): Promise<readonly GeneratedImage[]>;
9
+ editImage(input: ImageEditInput, options?: MediaRequestOptions): Promise<readonly GeneratedImage[]>;
10
+ createSpeech(input: SpeechInput, options?: MediaRequestOptions): Promise<MediaBinary>;
11
+ transcribe(input: AudioUploadInput, options?: MediaRequestOptions): Promise<string>;
12
+ translate(input: AudioUploadInput, options?: MediaRequestOptions): Promise<string>;
13
+ createVideo(input: {
14
+ model: string;
15
+ prompt: string;
16
+ parameters?: Record<string, unknown>;
17
+ }, options?: MediaRequestOptions): Promise<VideoOperation>;
18
+ getVideoOperation(id: string, options?: MediaRequestOptions): Promise<VideoOperation>;
19
+ downloadVideo(id: string, options?: MediaRequestOptions): Promise<MediaBinary>;
20
+ }