@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,11 @@
1
+ import type { ClipboardAdapter, ClipboardImage } from '../../ports/clipboard-adapter.js';
2
+ import { type HostPlatformContext } from '../platform/host-platform.js';
3
+ export declare function createClipboardAdapter(platform?: HostPlatformContext): ClipboardAdapter;
4
+ export declare class ProcessClipboardAdapter implements ClipboardAdapter {
5
+ private readonly command;
6
+ private readonly args;
7
+ private readonly mimeType;
8
+ private readonly platform;
9
+ constructor(command: string, args: readonly string[], mimeType: string, platform?: HostPlatformContext);
10
+ readImage(): Promise<ClipboardImage | undefined>;
11
+ }
@@ -0,0 +1 @@
1
+ import{CliError as f}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as b}from"../../domain/errors/error-codes.js";import{WindowsClipboardAdapter as h}from"./windows-clipboard-adapter.js";import{detectHostPlatform as c}from"../platform/host-platform.js";import{spawnPlatformProcess as w}from"../platform/host-process.js";import{CLIPBOARD_POLICY as d,clipboardUnavailableError as m,isClipboardUnavailableError as C}from"./clipboard-policy.js";function O(r=c()){return r.id==="windows"?new h(r):r.id==="macos"?new u([new p("pbpaste",["-Prefer","png"],"image/png",r)]):r.id==="linux"||r.id==="bsd"?new u([new p("wl-paste",["--no-newline","--type","image/png"],"image/png",r),new p("xclip",["-selection","clipboard","-target","image/png","-out"],"image/png",r)]):new y}class p{command;args;mimeType;platform;constructor(t,i,e,o=c()){this.command=t,this.args=i,this.mimeType=e,this.platform=o}async readImage(){return new Promise((t,i)=>{const e=w(this.command,this.args,this.platform,{stdio:["ignore","pipe","pipe"]}),o=[];let l=0,n=!1;const s=a=>{n||(n=!0,clearTimeout(g),a())},g=setTimeout(()=>{e.kill(),s(()=>i(m(`Clipboard image read timed out after ${d.timeoutMs}ms.`)))},d.timeoutMs);e.stdout?.on("data",a=>{if(!n){if(l+=a.byteLength,l>d.maxImageBytes){e.kill(),s(()=>i(new f(b.ATTACHMENT_TOO_LARGE,"Clipboard image is too large.",{category:"attachment",userMessage:"Clipboard image exceeds the maximum allowed size."})));return}o.push(a)}}),e.once("error",()=>s(()=>t(void 0))),e.once("close",a=>{s(()=>{a!==0||o.length===0?t(void 0):t({bytes:Buffer.concat(o),mimeType:this.mimeType})})})})}}class u{adapters;constructor(t){this.adapters=t}async readImage(){let t;for(const i of this.adapters)try{const e=await i.readImage();if(e!==void 0)return e}catch(e){if(!C(e))throw e;t=e}throw t??m("No supported clipboard image provider was found.")}}class y{async readImage(){throw m("Clipboard image support is unavailable on this platform.")}}export{p as ProcessClipboardAdapter,O as createClipboardAdapter};
@@ -0,0 +1,8 @@
1
+ import { CliError } from '../../domain/errors/cli-error.js';
2
+ export declare const CLIPBOARD_POLICY: {
3
+ readonly maxImageBytes: number;
4
+ readonly maxTextBytes: number;
5
+ readonly timeoutMs: 15000;
6
+ };
7
+ export declare function clipboardUnavailableError(message: string, cause?: unknown): CliError;
8
+ export declare function isClipboardUnavailableError(error: unknown): error is CliError;
@@ -0,0 +1 @@
1
+ import{CliError as o}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as a}from"../../domain/errors/error-codes.js";import{RESOURCE_LIMITS as e}from"../../domain/runtime/resource-limits.js";const A={maxImageBytes:e.maxAttachmentBytes,maxTextBytes:e.clipboardTextBytes,timeoutMs:e.clipboardTimeoutMs};function c(t,r){return new o(a.ATTACHMENT_CLIPBOARD_UNAVAILABLE,t,{category:"attachment",userMessage:"Unable to read from the clipboard. Copy the content again and retry.",retryable:!0,...r===void 0?{}:{cause:r}})}function l(t){return t instanceof o&&t.code===a.ATTACHMENT_CLIPBOARD_UNAVAILABLE}export{A as CLIPBOARD_POLICY,c as clipboardUnavailableError,l as isClipboardUnavailableError};
@@ -0,0 +1,10 @@
1
+ import type { ClipboardTextAdapter } from '../../ports/clipboard-text-adapter.js';
2
+ import { type HostPlatformContext } from '../platform/host-platform.js';
3
+ export declare function createClipboardTextAdapter(platform?: HostPlatformContext): ClipboardTextAdapter;
4
+ export declare class ProcessClipboardTextAdapter implements ClipboardTextAdapter {
5
+ private readonly command;
6
+ private readonly args;
7
+ private readonly platform;
8
+ constructor(command: string, args: readonly string[], platform?: HostPlatformContext);
9
+ readText(): Promise<string | undefined>;
10
+ }
@@ -0,0 +1 @@
1
+ import{CliError as f}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as x}from"../../domain/errors/error-codes.js";import{WindowsClipboardTextAdapter as b}from"./windows-clipboard-text-adapter.js";import{detectHostPlatform as u}from"../platform/host-platform.js";import{spawnPlatformProcess as h}from"../platform/host-process.js";import{CLIPBOARD_POLICY as d,clipboardUnavailableError as l,isClipboardUnavailableError as w}from"./clipboard-policy.js";function L(e=u()){return e.id==="windows"?new b(e):e.id==="macos"?new p("pbpaste",[],e):e.id==="linux"||e.id==="bsd"?new C([new p("wl-paste",["--no-newline"],e),new p("xclip",["-selection","clipboard","-out"],e)]):new T}class p{command;args;platform;constructor(r,o,t=u()){this.command=r,this.args=o,this.platform=t}async readText(){return new Promise((r,o)=>{const t=h(this.command,this.args,this.platform,{stdio:["ignore","pipe","pipe"]}),s=[];let c=0,n=!1;const a=i=>{n||(n=!0,clearTimeout(m),i())},m=setTimeout(()=>{t.kill(),a(()=>o(l(`Clipboard text read timed out after ${d.timeoutMs}ms.`)))},d.timeoutMs);t.stdout?.on("data",i=>{if(!n){if(c+=i.byteLength,c>d.maxTextBytes){t.kill(),a(()=>o(new f(x.ATTACHMENT_TOO_LARGE,"Clipboard text is too large.",{category:"attachment",userMessage:"Clipboard text exceeds the maximum allowed size."})));return}s.push(i)}}),t.once("error",()=>a(()=>r(void 0))),t.once("close",i=>a(()=>{i!==0||s.length===0?r(void 0):r(Buffer.concat(s).toString("utf8"))}))})}}class C{adapters;constructor(r){this.adapters=r}async readText(){let r;for(const o of this.adapters)try{const t=await o.readText();if(t!==void 0)return t}catch(t){if(!w(t))throw t;r=t}throw r??l("No supported clipboard text provider was found.")}}class T{async readText(){throw l("Clipboard text support is unavailable on this platform.")}}export{p as ProcessClipboardTextAdapter,L as createClipboardTextAdapter};
@@ -0,0 +1,12 @@
1
+ import type { Attachment, AttachmentPayload, AttachmentSource } from '../../domain/session/attachment.js';
2
+ import type { TextFileContentPart, TextImageContentPart, TextMessage } from '@lotagate/sdk';
3
+ export declare const DEFAULT_MAX_IMAGE_BYTES: number;
4
+ export interface NormalizedImage {
5
+ bytes: Buffer;
6
+ mimeType: string;
7
+ }
8
+ export declare function normalizeImage(bytes: Uint8Array, declaredMimeType?: string, maxBytes?: number): NormalizedImage;
9
+ export declare function createImageAttachment(image: NormalizedImage, source: AttachmentSource, id: string, storagePath?: string): Attachment;
10
+ export declare function toImageContentPart(payload: AttachmentPayload): TextImageContentPart;
11
+ export declare function toAttachmentContentPart(payload: AttachmentPayload): TextImageContentPart | TextFileContentPart;
12
+ export declare function buildUserMessage(prompt: string, attachments?: readonly AttachmentPayload[]): TextMessage;
@@ -0,0 +1 @@
1
+ import{CliError as a}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as o}from"../../domain/errors/error-codes.js";import{RESOURCE_LIMITS as m}from"../../domain/runtime/resource-limits.js";const s=m.maxAttachmentBytes,f=new Map([["89504e470d0a1a0a","image/png"],["ffd8ff","image/jpeg"],["47494638","image/gif"],["424d","image/bmp"]]);function d(e,t,n=s){if(e.byteLength===0||e.byteLength>n)throw new a(o.ATTACHMENT_TOO_LARGE,"Image size is outside the allowed range.",{category:"attachment",userMessage:`Image size must be between 1 byte and ${n} bytes.`});const r=g(e),i=r??t;if(i===void 0||!i.startsWith("image/"))throw new a(o.ATTACHMENT_FORMAT_UNSUPPORTED,"Clipboard content is not a supported image.",{category:"attachment",userMessage:"The clipboard does not contain a supported image format."});if(r!==void 0&&t!==void 0&&t!==r)throw new a(o.ATTACHMENT_INVALID_IMAGE,"Declared image type does not match its bytes.",{category:"attachment",userMessage:"The image format does not match its actual content."});return{bytes:Buffer.from(e),mimeType:i}}function A(e,t,n,r){const i=n.trim();if(i.length===0)throw new a(o.ATTACHMENT_INVALID_IMAGE,"Attachment id is required.",{category:"attachment"});return{id:i,name:i,mimeType:e.mimeType,sizeBytes:e.bytes.byteLength,source:t,...r===void 0?{}:{storagePath:r}}}function c(e){const t=Buffer.from(e.bytes).toString("base64");return{type:"image_url",image_url:{url:`data:${e.attachment.mimeType};base64,${t}`,detail:"auto"}}}function u(e){if(e.attachment.mimeType.startsWith("image/"))return c(e);const t=Buffer.from(e.bytes).toString("base64");return{type:"input_file",file_data:`data:${e.attachment.mimeType};base64,${t}`,filename:e.attachment.name,media_type:e.attachment.mimeType}}function _(e,t=[]){return t.length===0?{role:"user",content:e}:{role:"user",content:[{type:"text",text:e},...t.map(u)]}}function g(e){const t=[...e.slice(0,8)].map(n=>n.toString(16).padStart(2,"0")).join("");for(const[n,r]of f)if(t.startsWith(n))return r;if(e.length>=12&&Buffer.from(e.slice(0,12)).toString("ascii",0,4)==="RIFF"&&Buffer.from(e.slice(8,12)).toString("ascii")==="WEBP")return"image/webp"}export{s as DEFAULT_MAX_IMAGE_BYTES,_ as buildUserMessage,A as createImageAttachment,d as normalizeImage,u as toAttachmentContentPart,c as toImageContentPart};
@@ -0,0 +1,7 @@
1
+ import type { ClipboardAdapter, ClipboardImage } from '../../ports/clipboard-adapter.js';
2
+ import { type HostPlatformContext } from '../platform/host-platform.js';
3
+ export declare class WindowsClipboardAdapter implements ClipboardAdapter {
4
+ private readonly platform;
5
+ constructor(platform?: HostPlatformContext);
6
+ readImage(): Promise<ClipboardImage | undefined>;
7
+ }
@@ -0,0 +1 @@
1
+ import g from"node:crypto";import u from"node:fs/promises";import h from"node:os";import w from"node:path";import{CliError as l}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as T}from"../../domain/errors/error-codes.js";import{DEFAULT_MAX_IMAGE_BYTES as P}from"./image-normalizer.js";import{readFileBounded as A}from"../filesystem/bounded-file-reader.js";import{detectHostPlatform as b}from"../platform/host-platform.js";import{spawnPlatformProcess as C}from"../platform/host-process.js";import{CLIPBOARD_POLICY as c,clipboardUnavailableError as m}from"./clipboard-policy.js";class B{platform;constructor(o=b()){this.platform=o}async readImage(){if(!this.platform.isWindows)throw m("Windows clipboard image adapter cannot run on this platform.");const o=w.join(h.tmpdir(),`lotagate-clipboard-${process.pid}-${g.randomUUID()}.png`);try{await E(o,this.platform);const r=await A(o,P);if(r.truncated)throw new l(T.ATTACHMENT_TOO_LARGE,"Clipboard image exceeds the configured size limit.",{category:"attachment",userMessage:"The clipboard image is too large to attach."});return{bytes:r.bytes,mimeType:"image/png"}}catch(r){throw r instanceof l?r:m("Unable to read an image from the clipboard.",r)}finally{await u.rm(o,{force:!0})}}}function E(n,o){const r="$ErrorActionPreference='Stop'; $image=Get-Clipboard -Format Image; if ($null -eq $image) { exit 3 }; $image.Save($env:LOTAGATE_CLIPBOARD_OUTPUT, [System.Drawing.Imaging.ImageFormat]::Png)";return new Promise((f,i)=>{const e=C("powershell.exe",["-NoProfile","-NonInteractive","-Command",r],o,{env:{...process.env,LOTAGATE_CLIPBOARD_OUTPUT:n},stdio:["ignore","ignore","pipe"]}),s=[];let p=!1;const a=t=>{p||(p=!0,clearTimeout(d),t())},d=setTimeout(()=>{e.kill(),a(()=>i(m(`Clipboard image read timed out after ${c.timeoutMs}ms.`)))},c.timeoutMs);e.stderr?.on("data",t=>s.push(t)),e.once("error",t=>a(()=>i(t))),e.once("close",t=>a(()=>t===0?f():i(new Error(Buffer.concat(s).toString("utf8").trim()||`PowerShell exited with code ${String(t)}.`))))})}export{B as WindowsClipboardAdapter};
@@ -0,0 +1,7 @@
1
+ import type { ClipboardTextAdapter } from '../../ports/clipboard-text-adapter.js';
2
+ import { type HostPlatformContext } from '../platform/host-platform.js';
3
+ export declare class WindowsClipboardTextAdapter implements ClipboardTextAdapter {
4
+ private readonly platform;
5
+ constructor(platform?: HostPlatformContext);
6
+ readText(): Promise<string | undefined>;
7
+ }
@@ -0,0 +1 @@
1
+ import{CliError as p}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as h}from"../../domain/errors/error-codes.js";import{detectHostPlatform as x}from"../platform/host-platform.js";import{spawnPlatformProcess as w}from"../platform/host-process.js";import{CLIPBOARD_POLICY as a,clipboardUnavailableError as s}from"./clipboard-policy.js";class O{platform;constructor(e=x()){this.platform=e}async readText(){if(!this.platform.isWindows)throw s("Windows clipboard text adapter cannot run on this platform.");try{return await C(this.platform)}catch(e){throw e instanceof p?e:s("Unable to read text from the clipboard.",e)}}}function C(l){const e="$ErrorActionPreference='Stop'; [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; $text=Get-Clipboard -Raw; if ($null -eq $text) { exit 3 }; [Console]::Out.Write($text)";return new Promise((f,o)=>{const r=w("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],l,{stdio:["ignore","pipe","pipe"]}),m=[];let c=0,n=!1;const i=t=>{n||(n=!0,clearTimeout(u),t())},u=setTimeout(()=>{r.kill(),i(()=>o(s(`Clipboard text read timed out after ${a.timeoutMs}ms.`)))},a.timeoutMs);r.stdout?.on("data",t=>{if(!n){if(c+=t.byteLength,c>a.maxTextBytes){r.kill(),i(()=>o(new p(h.ATTACHMENT_TOO_LARGE,"Clipboard text is too large.",{category:"attachment",userMessage:"Clipboard text exceeds the maximum allowed size."})));return}m.push(t)}});const d=[];r.stderr?.on("data",t=>d.push(t)),r.once("error",t=>i(()=>o(t))),r.once("close",t=>i(()=>{t===3?f(void 0):t!==0?o(new Error(Buffer.concat(d).toString("utf8").trim()||`PowerShell exited with code ${String(t)}.`)):f(Buffer.concat(m).toString("utf8"))}))})}export{O as WindowsClipboardTextAdapter};
@@ -0,0 +1,19 @@
1
+ import { type CliConfig, type ConfigurableKey } from '../../domain/config/config-schema.js';
2
+ import type { Logger } from '../../ports/logger.js';
3
+ import { type PlatformPaths } from '../platform/platform-paths.js';
4
+ export interface ConfigLoadResult {
5
+ config: CliConfig;
6
+ sources: readonly string[];
7
+ }
8
+ export declare class ConfigLoader {
9
+ private readonly logger;
10
+ private readonly paths;
11
+ constructor(logger: Logger, paths?: PlatformPaths);
12
+ get platformPaths(): PlatformPaths;
13
+ load(cwd: string, options?: {
14
+ includeProject?: boolean;
15
+ }): Promise<ConfigLoadResult>;
16
+ setGlobal(key: ConfigurableKey, value: unknown): Promise<void>;
17
+ private readOptional;
18
+ private readDocumentOptional;
19
+ }
@@ -0,0 +1,2 @@
1
+ import{CliError as n}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as s}from"../../domain/errors/error-codes.js";import{DEFAULT_CONFIG as g,mergeConfig as h}from"../../domain/config/config-schema.js";import{resolvePlatformPaths as m,resolveProjectConfigPaths as c}from"../platform/platform-paths.js";import{atomicWriteFile as p,withFileLock as d}from"../filesystem/atomic-file-store.js";import{isFileNotFound as u}from"../filesystem/fs-errors.js";import{readJsonFileBounded as O}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as F}from"../../domain/runtime/resource-limits.js";import{validateSettingsDocument as l}from"../../domain/settings/settings-document.js";class L{logger;paths;constructor(o,t=m()){this.logger=o,this.paths=t}get platformPaths(){return this.paths}async load(o,t={}){const i=[],e=[],f=t.includeProject===!1?[this.paths.globalConfigFile]:[this.paths.globalConfigFile,c(o).settings,c(o).localSettings];for(const a of f){const r=await this.readOptional(a);r!==void 0&&(i.push(r),e.push(a))}return{config:h(g,...i),sources:e}}async setGlobal(o,t){await d(this.paths.globalConfigFile,async()=>{const i=await this.readDocumentOptional(this.paths.globalConfigFile),e={...i?.config??{},...i?.permissions===void 0?{}:{permissions:i.permissions},[o]:t,schemaVersion:1};l(e),await p(this.paths.globalConfigFile,`${JSON.stringify(e,null,2)}
2
+ `)}),this.logger.info("Global configuration updated.",{key:o})}async readOptional(o){return(await this.readDocumentOptional(o))?.config}async readDocumentOptional(o){try{try{return l(await O(o,F.configFileBytes))}catch(t){if(u(t))return;throw t instanceof n?t:new n(s.CONFIG_INVALID_JSON,`Invalid JSON in ${o}.`,{category:"config",userMessage:`Unable to parse JSON in ${o}.`,cause:t})}}catch(t){throw t instanceof n?t:new n(s.CONFIG_NOT_FOUND,`Unable to read config ${o}.`,{category:"config",userMessage:`Unable to read configuration file ${o}.`,cause:t})}}}export{L as ConfigLoader};
@@ -0,0 +1,2 @@
1
+ /** Reads an integer environment value without allowing invalid settings to disable a safe default. */
2
+ export declare function readBoundedEnvironmentInteger(value: string | undefined, fallback: number, minimum: number, maximum: number): number;
@@ -0,0 +1 @@
1
+ function u(n,r,t,d){if(n===void 0)return r;const e=Number(n);return Number.isSafeInteger(e)&&e>=t&&e<=d?e:r}export{u as readBoundedEnvironmentInteger};
@@ -0,0 +1,11 @@
1
+ import type { AuthProfile, StoredCredential } from '../../domain/auth/auth-profile.js';
2
+ import type { CredentialStore } from '../../ports/credential-store.js';
3
+ export declare class CompositeCredentialStore implements CredentialStore {
4
+ private readonly stores;
5
+ private readonly writableStore;
6
+ constructor(stores: readonly CredentialStore[], writableStore: CredentialStore);
7
+ list(): Promise<readonly AuthProfile[]>;
8
+ get(profileName: string): Promise<StoredCredential | undefined>;
9
+ set(credential: StoredCredential): Promise<void>;
10
+ delete(profileName: string): Promise<boolean>;
11
+ }
@@ -0,0 +1 @@
1
+ class r{stores;writableStore;constructor(t,e){this.stores=t,this.writableStore=e}async list(){const t=new Map;for(const e of this.stores)for(const s of await e.list())t.set(s.name,s);return[...t.values()].sort((e,s)=>e.name.localeCompare(s.name))}async get(t){for(const e of this.stores){const s=await e.get(t);if(s!==void 0)return s}}async set(t){await this.writableStore.set(t)}async delete(t){let e=!1;for(const s of this.stores)e=await s.delete(t)||e;return e}}export{r as CompositeCredentialStore};
@@ -0,0 +1,17 @@
1
+ import { type AuthProfile, type StoredCredential } from '../../domain/auth/auth-profile.js';
2
+ import type { CredentialStore } from '../../ports/credential-store.js';
3
+ import type { PlatformPaths } from '../platform/platform-paths.js';
4
+ export declare class EncryptedFileCredentialStore implements CredentialStore {
5
+ private readonly paths;
6
+ private readonly secret;
7
+ constructor(paths: PlatformPaths, secret?: string | undefined);
8
+ list(): Promise<readonly AuthProfile[]>;
9
+ get(profileName: string): Promise<StoredCredential | undefined>;
10
+ set(credential: StoredCredential): Promise<void>;
11
+ delete(profileName: string): Promise<boolean>;
12
+ private readPayload;
13
+ private writePayload;
14
+ private readFile;
15
+ private deriveKey;
16
+ private resolveSecret;
17
+ }
@@ -0,0 +1,3 @@
1
+ import o from"node:crypto";import n from"node:fs/promises";import g from"node:path";import{CliError as s}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as l}from"../../domain/errors/error-codes.js";import{validateApiKey as w,validateBaseUrl as E,validateProfileName as d}from"../../domain/auth/auth-profile.js";import{withFileLock as f}from"../filesystem/atomic-file-store.js";import{isAlreadyExists as m,isFileNotFound as y}from"../filesystem/fs-errors.js";class R{paths;secret;constructor(e,t=process.env.LOTAGATE_CREDENTIAL_SECRET){this.paths=e,this.secret=t}async list(){return(await this.readPayload()).credentials.map(({profile:t})=>t)}async get(e){const t=d(e);return(await this.readPayload()).credentials.find(a=>a.profile.name===t)}async set(e){const t={profile:{...e.profile,name:d(e.profile.name),baseUrl:E(e.profile.baseUrl),credentialRef:`file:${d(e.profile.name)}`},apiKey:w(e.apiKey)};await f(this.paths.credentialsFile,async()=>{const a=(await this.readPayload()).credentials.filter(({profile:i})=>i.name!==t.profile.name);a.push(t),await this.writePayload({version:1,credentials:a})})}async delete(e){const t=d(e);return f(this.paths.credentialsFile,async()=>{const r=await this.readPayload(),a=r.credentials.filter(({profile:i})=>i.name!==t);return a.length===r.credentials.length?!1:(await this.writePayload({version:1,credentials:a}),!0)})}async readPayload(){const e=await this.readFile();if(e===void 0)return{version:1,credentials:[]};const t=await this.deriveKey(e.salt);try{const r=o.createDecipheriv("aes-256-gcm",t,Buffer.from(e.iv,"base64"));r.setAuthTag(Buffer.from(e.authTag,"base64"));const a=Buffer.concat([r.update(Buffer.from(e.ciphertext,"base64")),r.final()]).toString("utf8"),i=JSON.parse(a);if(!T(i))throw new Error("Invalid credential payload.");return i}catch(r){throw new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential file cannot be decrypted.",{category:"auth",userMessage:"Unable to decrypt the credential store. Check LOTAGATE_CREDENTIAL_SECRET.",cause:r})}}async writePayload(e){const t=o.randomBytes(16),r=o.randomBytes(12),a=await this.deriveKey(t.toString("base64")),i=o.createCipheriv("aes-256-gcm",a,r),u=Buffer.concat([i.update(JSON.stringify(e),"utf8"),i.final()]),p={version:1,salt:t.toString("base64"),iv:r.toString("base64"),authTag:i.getAuthTag().toString("base64"),ciphertext:u.toString("base64")};await n.mkdir(this.paths.globalConfigDir,{recursive:!0});const h=g.join(this.paths.globalConfigDir,`.credentials.${process.pid}.${o.randomUUID()}.tmp`);try{await n.writeFile(h,`${JSON.stringify(p,null,2)}
2
+ `,{encoding:"utf8",mode:384}),await n.rename(h,this.paths.credentialsFile)}finally{await n.rm(h,{force:!0})}}async readFile(){try{return A(await n.readFile(this.paths.credentialsFile,"utf8"))}catch(e){if(y(e))return;throw e instanceof s?e:new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential file cannot be read.",{category:"auth",userMessage:"Unable to read the credential store.",cause:e})}}async deriveKey(e){return o.scryptSync(await this.resolveSecret(),e,32)}async resolveSecret(){if(this.secret!==void 0&&this.secret.length>=16)return this.secret;await n.mkdir(this.paths.globalConfigDir,{recursive:!0});try{const t=(await n.readFile(this.paths.credentialKeyFile,"utf8")).trim();if(t.length>=16)return t;throw new Error("Credential key file is invalid.")}catch(t){if(!y(t))throw new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential key cannot be read.",{category:"auth",userMessage:"Unable to read the local credential key.",cause:t})}const e=o.randomBytes(32).toString("base64url");try{return await n.writeFile(this.paths.credentialKeyFile,`${e}
3
+ `,{encoding:"utf8",mode:384,flag:"wx"}),e}catch(t){if(!m(t))throw new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential key cannot be created.",{category:"auth",userMessage:"Unable to initialize secure local credential storage.",cause:t});try{const r=(await n.readFile(this.paths.credentialKeyFile,"utf8")).trim();if(r.length>=16)return r}catch(r){throw new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential key cannot be read after initialization.",{category:"auth",userMessage:"Unable to initialize secure local credential storage.",cause:r})}throw new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential key file is invalid.",{category:"auth",userMessage:"Unable to initialize secure local credential storage."})}}}function A(c){try{const e=JSON.parse(c);if(typeof e!="object"||e===null)throw new Error("Expected object.");const t=e;if(t.version!==1||typeof t.salt!="string"||typeof t.iv!="string"||typeof t.authTag!="string"||typeof t.ciphertext!="string")throw new Error("Invalid encrypted credential file.");return{version:1,salt:t.salt,iv:t.iv,authTag:t.authTag,ciphertext:t.ciphertext}}catch(e){throw e instanceof s?e:new s(l.AUTH_CREDENTIAL_STORE_UNAVAILABLE,"Credential file is invalid.",{category:"auth",userMessage:"Credential store is corrupted or has an invalid format.",cause:e})}}function T(c){if(typeof c!="object"||c===null)return!1;const e=c;return e.version===1&&Array.isArray(e.credentials)}export{R as EncryptedFileCredentialStore};
@@ -0,0 +1,11 @@
1
+ import { type AuthProfile, type StoredCredential } from '../../domain/auth/auth-profile.js';
2
+ import type { CredentialStore } from '../../ports/credential-store.js';
3
+ export declare class EnvironmentCredentialStore implements CredentialStore {
4
+ private readonly env;
5
+ constructor(env?: Readonly<Record<string, string | undefined>>);
6
+ list(): Promise<readonly AuthProfile[]>;
7
+ get(profileName: string): Promise<StoredCredential | undefined>;
8
+ set(): Promise<void>;
9
+ delete(): Promise<boolean>;
10
+ private read;
11
+ }
@@ -0,0 +1 @@
1
+ import{DEFAULT_CONFIG as a}from"../../domain/config/config-schema.js";import{validateApiKey as i,validateBaseUrl as s,validateProfileName as r}from"../../domain/auth/auth-profile.js";class c{env;constructor(e=process.env){this.env=e}async list(){const e=this.read();return e===void 0?[]:[e.profile]}async get(e){const n=this.read();return n?.profile.name===r(e)?n:void 0}async set(){throw new Error("Environment credentials are read-only.")}async delete(){return!1}read(){const e=this.env.LOTAGATE_API_KEY;if(e===void 0||e.trim().length===0)return;const n=r(this.env.LOTAGATE_PROFILE??"default"),t=new Date().toISOString();return{apiKey:i(e),profile:{name:n,baseUrl:s(this.env.LOTAGATE_BASE_URL??a.baseUrl),credentialRef:"env:LOTAGATE_API_KEY",createdAt:t,updatedAt:t}}}}export{c as EnvironmentCredentialStore};
@@ -0,0 +1,7 @@
1
+ import type { Readable, Writable } from 'node:stream';
2
+ interface RawInput extends Readable {
3
+ isTTY?: boolean;
4
+ setRawMode?: (mode: boolean) => void;
5
+ }
6
+ export declare function readSecret(prompt: string, input?: RawInput, output?: Writable): Promise<string>;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ async function l(o,e=process.stdin,r=process.stderr){if(e.isTTY!==!0||e.setRawMode===void 0)return w(e);const s=e.setRawMode;return new Promise((c,u)=>{let n="";const f=i=>{const d=i.toString("utf8");for(const t of d){if(t===""){a(),u(new Error("Input interrupted."));return}if(t==="\r"||t===`
2
+ `){a(),r.write(`
3
+ `),c(n);return}if(t==="\b"||t==="\x7F"){n=n.slice(0,-1);continue}n+=t}},a=()=>{s(!1),e.pause(),e.off("data",f)};r.write(o),s(!0),e.resume(),e.on("data",f)})}async function w(o){const e=[];for await(const r of o)e.push(Buffer.isBuffer(r)?r:Buffer.from(String(r)));return Buffer.concat(e).toString("utf8").trim()}export{l as readSecret};
@@ -0,0 +1,9 @@
1
+ import type { CliMcpConfig } from '../../domain/extensions/mcp-config.js';
2
+ export interface McpConfigReader {
3
+ list(): Promise<CliMcpConfig>;
4
+ }
5
+ export declare class CompositeMcpConfigStore implements McpConfigReader {
6
+ private readonly stores;
7
+ constructor(stores: readonly McpConfigReader[]);
8
+ list(): Promise<CliMcpConfig>;
9
+ }
@@ -0,0 +1 @@
1
+ import{mergeMcpConfigsWithOverride as t}from"../../domain/extensions/mcp-config.js";class e{stores;constructor(s){this.stores=s}async list(){return t(...await Promise.all(this.stores.map(s=>s.list())))}}export{e as CompositeMcpConfigStore};
@@ -0,0 +1,2 @@
1
+ /** Lists direct extension directories while keeping missing optional roots harmless. */
2
+ export declare function listExtensionDirectories(root: string): Promise<readonly string[]>;
@@ -0,0 +1 @@
1
+ import e from"node:fs/promises";import o from"node:path";import{isFileNotFound as n}from"../filesystem/fs-errors.js";async function c(i){try{return(await e.readdir(i,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>o.join(i,t.name))}catch(r){if(n(r))return[];throw r}}export{c as listExtensionDirectories};
@@ -0,0 +1,7 @@
1
+ export interface ExtensionIntegrityOptions {
2
+ sha256?: string;
3
+ signature?: string;
4
+ publicKeyPem?: string;
5
+ }
6
+ /** Verifies the caller's authenticity constraints before installing any extension. */
7
+ export declare function verifyExtensionIntegrity(integrity: string, options: ExtensionIntegrityOptions, invalid: (message: string) => Error): void;
@@ -0,0 +1 @@
1
+ import f from"node:crypto";function n(u,e,r){if(e.sha256!==void 0&&e.sha256.trim().toLowerCase().replace(/^sha256[:-]/u,"")!==u)throw r("Extension checksum does not match --sha256.");if(!(e.signature===void 0&&e.publicKeyPem===void 0)){if(e.signature===void 0||e.publicKeyPem===void 0)throw r("Signature verification requires both --signature and --public-key.");if(!f.verify(null,Buffer.from(u,"utf8"),e.publicKeyPem,Buffer.from(e.signature,"base64")))throw r("Extension signature verification failed.")}}export{n as verifyExtensionIntegrity};
@@ -0,0 +1,6 @@
1
+ import { type HostPlatformContext } from '../platform/host-platform.js';
2
+ export interface ResolvedExtensionSource {
3
+ directory: string;
4
+ cleanup(): Promise<void>;
5
+ }
6
+ export declare function resolveExtensionSource(source: string, platform?: HostPlatformContext, signal?: AbortSignal): Promise<ResolvedExtensionSource>;
@@ -0,0 +1 @@
1
+ import n from"node:fs/promises";import p from"node:os";import a from"node:path";import{fileURLToPath as w}from"node:url";import{CliError as l}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as g}from"../../domain/errors/error-codes.js";import{isFileNotFound as f}from"../filesystem/fs-errors.js";import{detectHostPlatform as S}from"../platform/host-platform.js";import{execPlatformCommand as d}from"../platform/host-process.js";import{RESOURCE_LIMITS as m}from"../../domain/runtime/resource-limits.js";async function G(t,r=S(),o){const e=await v(t);if(e!==void 0)return{directory:e,cleanup:async()=>{}};if(j(t))return x(t,r,o);if(z(t))return k(t,r,o);throw c("Source must be a local directory, HTTPS Git repository, or npm package.")}async function v(t){const r=t.startsWith("file://")?w(t):a.resolve(t);try{if(!(await n.stat(r)).isDirectory())throw c("Extension source must be a directory.");return r}catch(o){if(o instanceof l||!f(o))throw o;return}}async function x(t,r,o){const e=await n.mkdtemp(a.join(p.tmpdir(),"lotagate-extension-git-")),i=a.join(e,"source");try{return await d("git",["clone","--depth","1",t,i],r,{maxBufferBytes:m.internalProcessOutputBytes,timeoutMs:m.internalProcessTimeoutMs,...o===void 0?{}:{signal:o}}),await n.rm(a.join(i,".git"),{recursive:!0,force:!0}),{directory:i,cleanup:()=>n.rm(e,{recursive:!0,force:!0})}}catch(s){throw await n.rm(e,{recursive:!0,force:!0}),c(`Unable to clone Git source: ${s instanceof Error?s.message:String(s)}`)}}async function k(t,r,o){const e=await n.mkdtemp(a.join(p.tmpdir(),"lotagate-extension-npm-"));try{await d("npm",["install","--ignore-scripts","--no-package-lock","--no-save","--prefix",e,t],r,{maxBufferBytes:m.internalProcessOutputBytes,timeoutMs:m.internalProcessTimeoutMs,...o===void 0?{}:{signal:o}});const i=await E(a.join(e,"node_modules"));if(i===void 0)throw c("npm package does not contain a LotaGate plugin or skill.");return{directory:i,cleanup:()=>n.rm(e,{recursive:!0,force:!0})}}catch(i){throw await n.rm(e,{recursive:!0,force:!0}),i instanceof l?i:c(`Unable to install npm source: ${i instanceof Error?i.message:String(i)}`)}}async function E(t){let r;try{r=await n.readdir(t,{withFileTypes:!0})}catch(e){if(f(e))return;throw e}const o=[];for(const e of r){if(!e.isDirectory()||e.name.startsWith("."))continue;const i=a.join(t,e.name);if(await h(i)&&o.push(i),e.name.startsWith("@")){let s;try{s=await n.readdir(i,{withFileTypes:!0})}catch{s=[]}for(const y of s.filter(u=>u.isDirectory())){const u=a.join(i,y.name);await h(u)&&o.push(u)}}}if(o.length>1)throw c("npm package contains multiple extension roots.");return o[0]}async function h(t){try{return await n.stat(a.join(t,".lotagate-plugin","plugin.json")),!0}catch(r){if(!f(r))throw r}try{return await n.stat(a.join(t,"SKILL.md")),!0}catch(r){if(!f(r))throw r;return!1}}function j(t){return/^https:\/\//u.test(t)&&(t.endsWith(".git")||/^https:\/\/github\.com\/[^/]+\/[^/]+\/?$/u.test(t))}function z(t){return/^@?[a-z0-9][a-z0-9._/-]*(?:@[a-z0-9][a-z0-9._-]*)?$/iu.test(t)&&!t.includes("/")||/^@[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9._-]*(?:@[a-z0-9][a-z0-9._-]*)?$/iu.test(t)}function c(t){return new l(g.PLUGIN_MANIFEST_INVALID,t,{category:"extension",userMessage:`Unable to resolve extension source: ${t}`})}export{G as resolveExtensionSource};
@@ -0,0 +1,15 @@
1
+ import { type CliMcpConfig, type CliMcpServerConfig } from '../../domain/extensions/mcp-config.js';
2
+ import type { ExtensionScope } from '../../domain/extensions/extension-scope.js';
3
+ export declare class FileMcpConfigStore {
4
+ private readonly filePath;
5
+ constructor(location: string, scope?: ExtensionScope);
6
+ static forScope(cwd: string, globalConfigDir: string, scope: ExtensionScope): FileMcpConfigStore;
7
+ get path(): string;
8
+ list(): Promise<CliMcpConfig>;
9
+ get(name: string): Promise<import("../../domain/extensions/mcp-config.js").CliMcpServerEntry | undefined>;
10
+ add(name: string, config: CliMcpServerConfig): Promise<void>;
11
+ remove(name: string): Promise<boolean>;
12
+ setEnabled(name: string, enabled: boolean): Promise<void>;
13
+ private readRaw;
14
+ private write;
15
+ }
@@ -0,0 +1,2 @@
1
+ import a from"node:path";import{validateMcpConfig as c,validateMcpName as n}from"../../domain/extensions/mcp-config.js";import{CliError as h}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as f}from"../../domain/errors/error-codes.js";import{atomicWriteFile as m,withFileLock as s}from"../filesystem/atomic-file-store.js";import{isFileNotFound as u}from"../filesystem/fs-errors.js";import{readJsonFileBounded as d}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as w}from"../../domain/runtime/resource-limits.js";class l{filePath;constructor(t,e="project"){this.filePath=e==="user"?a.join(a.resolve(t),"mcp.json"):a.join(a.resolve(t),".lotagate","mcp.json")}static forScope(t,e,r){return new l(r==="user"?e:t,r)}get path(){return this.filePath}async list(){return c(await this.readRaw())}async get(t){return(await this.list())[n(t)]}async add(t,e){const r=n(t);await s(this.filePath,async()=>{const i=await this.list();i[r]={enabled:!0,config:e},await this.write(i)})}async remove(t){const e=n(t);return s(this.filePath,async()=>{const r=await this.list();return r[e]===void 0?!1:(delete r[e],await this.write(r),!0)})}async setEnabled(t,e){const r=n(t);await s(this.filePath,async()=>{const i=await this.list(),o=i[r];if(o===void 0)throw new h(f.MCP_SERVER_NOT_FOUND,`MCP server not found: ${r}`,{category:"mcp",userMessage:`MCP server not found: ${r}.`});i[r]={...o,enabled:e},await this.write(i)})}async readRaw(){try{return await d(this.filePath,w.mcpConfigBytes)}catch(t){if(u(t))return{};throw t}}async write(t){const e=c(t);await m(this.filePath,`${JSON.stringify(e,null,2)}
2
+ `)}}export{l as FileMcpConfigStore};
@@ -0,0 +1,18 @@
1
+ import type { ToolExecutionContext, ToolExecutor, ToolPolicy } from '@lotagate/agent-sdk';
2
+ import { type HookDefinition, type HookEvent } from '../../domain/extensions/hook-manifest.js';
3
+ import { type PluginManifest } from '../../domain/extensions/plugin-manifest.js';
4
+ export interface HookRuntimePolicy {
5
+ trustedProject: boolean;
6
+ enabled: boolean;
7
+ toolPolicy: ToolPolicy;
8
+ }
9
+ export declare class HookRuntime {
10
+ private readonly executor;
11
+ private readonly policy;
12
+ constructor(executor: ToolExecutor, policy: HookRuntimePolicy);
13
+ load(plugin: PluginManifest): Promise<readonly HookDefinition[]>;
14
+ loadProject(cwd: string): Promise<readonly HookDefinition[]>;
15
+ run(hook: HookDefinition, context: ToolExecutionContext): Promise<boolean>;
16
+ runEvent(hooks: readonly HookDefinition[], event: HookEvent, context: ToolExecutionContext): Promise<number>;
17
+ }
18
+ export declare function discoverHooks(root: string): Promise<readonly HookDefinition[]>;
@@ -0,0 +1 @@
1
+ import l from"node:fs/promises";import i from"node:path";import{ToolExecutionError as m}from"@lotagate/agent-sdk";import{parseHookDefinition as u}from"../../domain/extensions/hook-manifest.js";import{PLUGIN_LAYOUT as f}from"../../domain/extensions/plugin-manifest.js";import{isFileNotFound as d}from"../filesystem/fs-errors.js";import{readJsonFileBounded as p}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as h}from"../../domain/runtime/resource-limits.js";class v{executor;policy;constructor(o,t){this.executor=o,this.policy=t}async load(o){const t=i.resolve(o.directory,f.hooksDirectory);return(await c(t)).map(e=>({...e,id:`${o.name}:${e.id}`,scope:"plugin",pluginName:o.name,sourceName:e.id}))}async loadProject(o){return(await c(i.join(i.resolve(o),".lotagate","hooks"))).map(t=>({...t,scope:"project",sourceName:t.id}))}async run(o,t){if(!this.policy.enabled||!this.policy.trustedProject)return!1;const e={command:o.command,args:[...o.args],cwd:".",timeoutMs:o.timeoutMs},r=this.executor.getToolInfo?.("shell.exec");try{await this.policy.toolPolicy.assertAllowed({toolName:"shell.exec",input:e,context:t,...r===void 0?{}:{toolInfo:r}})}catch(a){if(a instanceof m)return!1;throw a}if((await this.executor.execute("shell.exec",e,t)).isError)throw new Error(`Hook failed: ${o.id}`);return!0}async runEvent(o,t,e){let r=0;for(const n of o)n.event===t&&await this.run(n,e)&&(r+=1);return r}}async function c(s){let o;try{o=(await l.readdir(s,{withFileTypes:!0})).filter(e=>e.isFile()&&e.name.endsWith(".json")).map(e=>i.join(s,e.name))}catch(e){if(d(e))return[];throw e}const t=[];for(const e of o.sort())t.push(u(await p(e,h.configFileBytes),s,i.basename(e,".json")));return t}export{v as HookRuntime,c as discoverHooks};
@@ -0,0 +1,51 @@
1
+ import { McpToolExecutor, type McpConnectionSummary, type McpServerConfigMap } from '@lotagate/agent-sdk';
2
+ import type { CliMcpConfig } from '../../domain/extensions/mcp-config.js';
3
+ import type { McpConfigReader } from './composite-mcp-config-store.js';
4
+ import type { Logger } from '../../ports/logger.js';
5
+ export interface McpRuntimePolicy {
6
+ readonly connectTimeoutMs: number;
7
+ readonly disconnectTimeoutMs?: number;
8
+ readonly idleTtlMs: number;
9
+ readonly startupConcurrency?: number;
10
+ readonly probeTimeoutMs?: number;
11
+ readonly probeMaxRetries?: number;
12
+ readonly reconnectMaxAttempts?: number;
13
+ readonly healthCheckIntervalMs?: number;
14
+ readonly healthCheckTimeoutMs?: number;
15
+ }
16
+ export type McpRuntimeEvent = {
17
+ type: 'mcp.server.status';
18
+ summary: McpConnectionSummary & {
19
+ latencyMs?: number;
20
+ };
21
+ } | {
22
+ type: 'mcp.tool.catalog.updated';
23
+ serverId: string;
24
+ toolCount: number;
25
+ error?: Error;
26
+ };
27
+ export type McpRuntimeEventListener = (event: McpRuntimeEvent) => void | Promise<void>;
28
+ export interface McpRuntimeLease {
29
+ readonly executor: McpToolExecutor;
30
+ release(): void;
31
+ }
32
+ export declare function resolveMcpRuntimePolicy(env?: Readonly<Record<string, string | undefined>>): McpRuntimePolicy;
33
+ export declare class McpRuntime {
34
+ private readonly storeFactory;
35
+ private readonly policy;
36
+ private readonly logger?;
37
+ private readonly now;
38
+ private readonly environment;
39
+ private readonly runtimes;
40
+ constructor(storeFactory?: (cwd: string) => McpConfigReader, policy?: McpRuntimePolicy, logger?: Logger | undefined, now?: () => number, environment?: Readonly<Record<string, string | undefined>>);
41
+ ensure(cwd: string, config: CliMcpConfig, trusted: boolean, options?: {
42
+ onEvent?: McpRuntimeEventListener;
43
+ reconnect?: boolean;
44
+ }): Promise<McpRuntimeLease>;
45
+ connectConfigured(cwd: string, trusted: boolean): Promise<readonly McpConnectionSummary[]>;
46
+ invalidate(cwd: string): Promise<void>;
47
+ close(): Promise<void>;
48
+ private scheduleIdleInvalidation;
49
+ private connectAndDiscover;
50
+ }
51
+ export declare function toAgentMcpConfig(config: CliMcpConfig, environment?: Readonly<Record<string, string | undefined>>): McpServerConfigMap;
@@ -0,0 +1 @@
1
+ import D from"node:crypto";import M from"node:path";import{AgentSdkError as S,AgentSdkErrorCode as j,DEFAULT_MCP_STARTUP_CONCURRENCY as C,mapWithMcpConcurrency as k,McpClientManager as G,McpToolExecutor as F}from"@lotagate/agent-sdk";import{CliError as P}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as v}from"../../domain/errors/error-codes.js";import{FileMcpConfigStore as $}from"./file-mcp-config-store.js";import{readBoundedEnvironmentInteger as f}from"../config/environment-values.js";import{redactLogText as O}from"../logging/log-redactor.js";const H=3e4,g=5e3;function J(t=process.env){return{connectTimeoutMs:f(t.LOTAGATE_MCP_CONNECT_TIMEOUT_MS,H,500,12e4),disconnectTimeoutMs:f(t.LOTAGATE_MCP_DISCONNECT_TIMEOUT_MS,g,500,12e4),idleTtlMs:f(t.LOTAGATE_MCP_RUNTIME_TTL_SECONDS,300,1,86400)*1e3,startupConcurrency:f(t.LOTAGATE_MCP_STARTUP_CONCURRENCY,C,1,32),probeTimeoutMs:f(t.LOTAGATE_MCP_PROBE_TIMEOUT_MS,5e3,500,12e4),probeMaxRetries:f(t.LOTAGATE_MCP_PROBE_MAX_RETRIES,1,0,5),reconnectMaxAttempts:f(t.LOTAGATE_MCP_RECONNECT_MAX_ATTEMPTS,3,0,10),healthCheckIntervalMs:f(t.LOTAGATE_MCP_HEALTH_CHECK_INTERVAL_SECONDS,30,5,3600)*1e3,healthCheckTimeoutMs:f(t.LOTAGATE_MCP_HEALTH_CHECK_TIMEOUT_MS,5e3,500,12e4)}}class ne{storeFactory;policy;logger;now;environment;runtimes=new Map;constructor(e=a=>new $(a),n=J(),i,o=Date.now,s=process.env){this.storeFactory=e,this.policy=n,this.logger=i,this.now=o,this.environment=s}async ensure(e,n,i,o={}){if(!i)throw new P(v.PROJECT_TRUST_REQUIRED,"MCP connections require project trust.",{category:"project",userMessage:"Trust the project before connecting to MCP servers."});const s=M.resolve(e),a=V(n),r=this.runtimes.get(s);if(r?.failed&&r.fingerprint===a&&r.leases>0)return T(r),r.lastUsedAt=this.now(),r.leases+=1,_(r,o.onEvent),await r.ready,E(r,this.now,o.onEvent,()=>this.scheduleIdleInvalidation(s,r));if(r!==void 0&&!r.failed&&r.fingerprint===a&&(r.leases>0||this.now()-r.lastUsedAt<=this.policy.idleTtlMs)){T(r);const h=r.leases===0;r.lastUsedAt=this.now(),r.leases+=1,_(r,o.onEvent),await r.ready;const w=E(r,this.now,o.onEvent,()=>this.scheduleIdleInvalidation(s,r));return h&&!r.failed&&B(r.manager)?(w.release(),await this.invalidate(s),this.ensure(s,n,i,o)):w}r!==void 0&&await this.invalidate(s);const c=new Set;_(c,o.onEvent);const u=b(I(n,this.environment),this.policy,c,o.reconnect??!0),l={cwd:s,fingerprint:a,manager:u.manager,executor:u.executor,ready:this.connectAndDiscover(s,u.manager,u.executor,c),listeners:c,failed:!1,lastUsedAt:this.now(),leases:1,idleTimer:void 0};this.runtimes.set(s,l);const d=await l.ready;return l.failed=d.some(h=>h.status==="failed"),E(l,this.now,o.onEvent,()=>this.scheduleIdleInvalidation(s,l))}async connectConfigured(e,n){if(!n)throw new P(v.PROJECT_TRUST_REQUIRED,"MCP connections require project trust.",{category:"project",userMessage:"Trust the project before connecting to MCP servers."});const i=await this.storeFactory(e).list(),o=b(I(i,this.environment),this.policy,new Set);try{return await this.connectAndDiscover(M.resolve(e),o.manager,o.executor,new Set)}finally{await y(o.manager,this.policy.disconnectTimeoutMs??g,this.logger,M.resolve(e))}}async invalidate(e){const n=M.resolve(e),i=this.runtimes.get(n);i!==void 0&&(this.runtimes.delete(n),T(i),i.listeners.clear(),await y(i.manager,this.policy.disconnectTimeoutMs??g,this.logger,n),this.logger?.info("MCP runtime invalidated.",{cwd:n}))}async close(){const e=[...this.runtimes.values()];this.runtimes.clear();for(const n of e)T(n);await Promise.allSettled(e.map(n=>y(n.manager,this.policy.disconnectTimeoutMs??g,this.logger,n.cwd)))}scheduleIdleInvalidation(e,n){T(n),n.idleTimer=setTimeout(()=>{if(n.idleTimer=void 0,!(this.runtimes.get(e)!==n||n.leases>0)){if(this.now()-n.lastUsedAt<this.policy.idleTtlMs){this.scheduleIdleInvalidation(e,n);return}this.invalidate(e)}},this.policy.idleTtlMs),n.idleTimer.unref?.()}async connectAndDiscover(e,n,i,o){const s=performance.now();this.logger?.debug("MCP runtime startup started.",{cwd:e,serverCount:n.configuredServerIds.length,startupConcurrency:this.policy.startupConcurrency??C});const a=await k(n.configuredServerIds,async r=>{const c=performance.now();try{p(o,{type:"mcp.server.status",summary:{serverId:r,status:"connecting"}});const u=await R(n.connect(r),this.policy.connectTimeoutMs,()=>n.disconnect(r),"connection");if(p(o,{type:"mcp.server.status",summary:{...u,latencyMs:m(c)}}),this.logger?.debug("MCP server connected.",{cwd:e,serverId:r,durationMs:m(c),protocolEra:u.protocolEra,protocolVersion:u.protocolVersion}),u.status!=="connected")return u;try{const l=performance.now(),d=await R(n.listTools(r),this.policy.connectTimeoutMs,()=>n.disconnect(r),"tool discovery");i.replaceServerTools(r,d.tools),p(o,{type:"mcp.tool.catalog.updated",serverId:r,toolCount:d.tools.length}),this.logger?.debug("MCP tools discovered.",{cwd:e,serverId:r,toolCount:d.tools.length,durationMs:m(l),totalDurationMs:m(c)})}catch(l){const d=U(l,r);return p(o,{type:"mcp.server.status",summary:{...u,status:"failed",error:d,latencyMs:m(c)}}),p(o,{type:"mcp.tool.catalog.updated",serverId:r,toolCount:0,error:d}),this.logger?.warn("MCP tool discovery failed.",{cwd:e,serverId:r,durationMs:m(c),reason:d.message,...x(l)}),{...u,status:"failed",error:d}}return u}catch(u){const l=U(u,r);return p(o,{type:"mcp.server.status",summary:{serverId:r,status:"failed",error:l,latencyMs:m(c)}}),this.logger?.warn("MCP server connection failed.",{cwd:e,serverId:r,durationMs:m(c),reason:l.message,...x(u)}),{serverId:r,status:"failed",error:l}}},this.policy.startupConcurrency??C);return this.logger?.info("MCP runtime startup completed.",{cwd:e,serverCount:a.length,connectedCount:a.filter(r=>r.status==="connected").length,failedCount:a.filter(r=>r.status==="failed").length,durationMs:m(s)}),a}}function b(t,e,n,i=!0){let o;const s=new G(t,{protocol:{mode:"auto",...e.probeTimeoutMs===void 0?{}:{probeTimeoutMs:e.probeTimeoutMs},...e.probeMaxRetries===void 0?{}:{probeMaxRetries:e.probeMaxRetries}},reconnect:{enabled:i,...e.reconnectMaxAttempts===void 0?{}:{maxAttempts:e.reconnectMaxAttempts},...e.healthCheckIntervalMs===void 0?{}:{healthCheckIntervalMs:e.healthCheckIntervalMs},...e.healthCheckTimeoutMs===void 0?{}:{healthCheckTimeoutMs:e.healthCheckTimeoutMs}},onToolsChanged:a=>{o!==void 0&&(a.tools===null||a.error!==null?o.removeServerTools(a.serverId):o.replaceServerTools(a.serverId,a.tools),p(n,{type:"mcp.tool.catalog.updated",serverId:a.serverId,toolCount:a.tools?.length??0,...a.error===null?{}:{error:a.error}}))},onServerChanged:a=>{a.type==="removed"&&o?.removeServerTools(a.serverId)}});return o=new F(s),{manager:s,executor:o}}async function y(t,e,n,i){let o,s=!1;const a=t.disconnectAll(),r=new Promise(c=>{o=setTimeout(()=>{s=!0,c()},e)});try{await Promise.race([a,r])}finally{o!==void 0&&clearTimeout(o),a.catch(c=>{s||n?.warn("MCP runtime disconnect failed.",{cwd:i,reason:c instanceof Error?c.message:String(c)})})}s&&n?.warn("MCP runtime disconnect timed out.",{cwd:i,timeoutMs:e})}function E(t,e,n,i){let o=!1;return{executor:t.executor,release:()=>{o||(o=!0,t.leases=Math.max(0,t.leases-1),t.lastUsedAt=e(),z(t,n),t.leases===0&&i?.())}}}function T(t){t.idleTimer!==void 0&&clearTimeout(t.idleTimer),t.idleTimer=void 0}function _(t,e){if(e!==void 0){if(t instanceof Set){t.add(e);return}t.listeners.add(e)}}function z(t,e){e!==void 0&&t.listeners.delete(e)}function p(t,e){for(const n of t)Promise.resolve(n(e)).catch(()=>{})}function B(t){const e=t.connectionSummaries;return e.length>0&&e.some(n=>n.status!=="connected")}function V(t){return D.createHash("sha256").update(A(t)).digest("hex")}function A(t){return Array.isArray(t)?`[${t.map(A).join(",")}]`:typeof t!="object"||t===null?JSON.stringify(t):`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${A(t[e])}`).join(",")}}`}async function R(t,e,n,i){let o,s=!1;const a=new Promise((r,c)=>{o=setTimeout(()=>{s||(s=!0,c(new Error(`MCP ${i} timed out after ${e}ms.`)),Promise.resolve(n()).catch(()=>{}))},e)});try{return await Promise.race([t.then(c=>(s=!0,c)),a])}finally{o!==void 0&&clearTimeout(o),t.catch(()=>{})}}function m(t){return Math.max(0,Math.round(performance.now()-t))}function U(t,e){return t instanceof S?t:new S(j.McpConnectionFailed,"MCP server connection failed.",{cause:t,details:{serverId:e}})}function x(t){const e=[],n=[],i=[],o=[];let s=t;for(let a=0;a<4&&s!==void 0&&s!==null;a+=1){if(s instanceof Error){e.push(O(s.message)),n.push(s.name),s=s.cause;continue}if(typeof s!="object")break;const r=s,c=r.message;typeof c=="string"&&e.push(O(c));const u=r.name;typeof u=="string"&&n.push(u);const l=r.code;typeof l=="string"&&i.push(l);for(const d of["status","statusCode","httpStatus"]){const h=r[d];typeof h=="number"&&Number.isInteger(h)&&o.push(h)}s=r.cause}return{...e.length===0?{}:{errorMessages:e},...n.length===0?{}:{errorTypes:n},...i.length===0?{}:{errorCodes:i},...o.length===0?{}:{httpStatuses:o}}}function I(t,e=process.env){const n={};for(const[i,o]of Object.entries(t))o.enabled&&(n[i]=q(o.config,e));return n}function q(t,e){if(t.type==="stdio"){const{env:s,...a}=t;return{...a,...t.args===void 0?{}:{args:[...t.args]},...s===void 0?{}:{env:L(s,e)}}}const{headers:n,auth:i,...o}=t;return{...o,...n===void 0?{}:{headers:L(n,e)},...i?.type==="bearer"?{auth:{type:"bearer",token:N(i.token,e,"MCP bearer token")}}:{}}}function L(t,e){return Object.fromEntries(Object.entries(t).map(([n,i])=>[n,N(i,e,`MCP secret ${n}`)]))}function N(t,e,n){if(typeof t=="string")return t;const i=e[t.name];if(i===void 0||i.length===0)throw new Error(`${n} environment variable is not set.`);return i}export{ne as McpRuntime,J as resolveMcpRuntimePolicy,I as toAgentMcpConfig};
@@ -0,0 +1,4 @@
1
+ import { type PluginAgentDefinition } from '../../domain/extensions/plugin-agent-manifest.js';
2
+ export declare class PluginAgentDiscovery {
3
+ discover(root: string): Promise<readonly PluginAgentDefinition[]>;
4
+ }
@@ -0,0 +1 @@
1
+ import c from"node:fs/promises";import u from"node:path";import{parsePluginAgentDocument as f}from"../../domain/extensions/plugin-agent-manifest.js";import{CliError as p}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as g}from"../../domain/errors/error-codes.js";import{isFileNotFound as d}from"../filesystem/fs-errors.js";import{readFileBounded as h}from"../filesystem/bounded-file-reader.js";import{RESOURCE_LIMITS as y}from"../../domain/runtime/resource-limits.js";class C{async discover(r){let a;try{a=await c.readdir(r,{withFileTypes:!0})}catch(t){if(d(t))return[];throw t}const s=[];for(const t of a.filter(e=>e.isFile()&&e.name.endsWith(".yaml")).sort((e,n)=>e.name.localeCompare(n.name))){const e=t.name.slice(0,-5);if(!/^[a-z0-9][a-z0-9-]{0,63}$/u.test(e))throw i(`Invalid plugin agent file name: ${t.name}`);const n=u.join(r,t.name);if((await c.lstat(n)).isSymbolicLink())throw i(`Plugin agent must not be a symbolic link: ${t.name}`);const m=await h(n,y.skillDocumentBytes);if(m.truncated)throw i(`Plugin agent exceeds the supported size: ${t.name}`);const l=f(m.bytes.toString("utf8"),r);if(l.name!==e)throw i(`Plugin agent name must match its file name: ${t.name}`);s.push(l)}return s}}function i(o){return new p(g.PLUGIN_MANIFEST_INVALID,o,{category:"extension",userMessage:`Invalid plugin agent: ${o}`})}export{C as PluginAgentDiscovery};
@@ -0,0 +1,5 @@
1
+ import { type PluginManifest } from '../../domain/extensions/plugin-manifest.js';
2
+ export declare class PluginDiscovery {
3
+ discover(roots: readonly string[]): Promise<readonly PluginManifest[]>;
4
+ }
5
+ export declare function validatePluginManifest(manifest: PluginManifest): Promise<void>;
@@ -0,0 +1 @@
1
+ import s from"node:fs/promises";import a from"node:path";import{parsePluginManifest as y,PLUGIN_LAYOUT as o}from"../../domain/extensions/plugin-manifest.js";import{CliError as c}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as l}from"../../domain/errors/error-codes.js";import{isFileNotFound as p}from"../filesystem/fs-errors.js";import{readJsonFileBounded as h}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as w}from"../../domain/runtime/resource-limits.js";import{listExtensionDirectories as d}from"./extension-directory-reader.js";class k{async discover(t){const i=[];for(const e of t)for(const r of await d(e)){const f=a.join(r,o.markerDirectory,o.manifestFile);try{const u=y(await h(f,w.pluginManifestBytes),r);await L(u),i.push(u)}catch(u){if(!p(u))throw u;if(await I(r))throw P()}}return i.sort((e,r)=>e.name.localeCompare(r.name))}}async function I(n){try{return await s.stat(a.join(n,".codex-plugin","plugin.json")),!0}catch(t){if(p(t))return!1;throw t}}function P(){return new c(l.PLUGIN_MANIFEST_INVALID,"Only the .lotagate-plugin/plugin.json plugin format is supported.",{category:"extension",userMessage:"This plugin uses an unsupported format. Reinstall it using the LotaGate plugin structure."})}async function L(n){const t=await s.realpath(n.directory);await D(t,o.skillsDirectory),await m(t,o.readmeFile),await m(t,o.licenseFile);for(const i of[o.markerDirectory,o.skillsDirectory,o.agentsDirectory,o.hooksDirectory,o.mcpDirectory]){const e=a.resolve(t,i);if(e!==t&&!e.startsWith(`${t}${a.sep}`))throw g(i);try{if((await s.lstat(e)).isSymbolicLink())throw g(i);const f=await s.realpath(e);if(f!==t&&!f.startsWith(`${t}${a.sep}`))throw g(i)}catch(r){if(r instanceof c)throw r;if(p(r))continue;throw new c(l.PLUGIN_MANIFEST_INVALID,`Plugin path is not contained in the plugin directory: ${i}`,{category:"extension",userMessage:"Plugin contains an unsafe path.",cause:r})}}}async function D(n,t){try{const i=await s.lstat(a.join(n,t));if(!i.isDirectory()||i.isSymbolicLink())throw new Error("invalid-directory")}catch(i){throw new c(l.PLUGIN_MANIFEST_INVALID,`Plugin directory is missing or invalid: ${t}`,{category:"extension",userMessage:`Plugin must contain the ${t}/ directory.`,cause:i})}}async function m(n,t){try{const i=await s.lstat(a.join(n,t));if(!i.isFile()||i.isSymbolicLink())throw new Error("invalid-file")}catch(i){throw new c(l.PLUGIN_MANIFEST_INVALID,`Plugin file is missing or invalid: ${t}`,{category:"extension",userMessage:`Plugin must contain ${t}.`,cause:i})}}function g(n){return new c(l.PLUGIN_MANIFEST_INVALID,`Plugin path is not contained in the plugin directory: ${n}`,{category:"extension",userMessage:"Plugin contains an unsafe path."})}export{k as PluginDiscovery,L as validatePluginManifest};
@@ -0,0 +1,23 @@
1
+ import { type ExtensionIntegrityOptions } from './extension-integrity.js';
2
+ import { type PluginManifest } from '../../domain/extensions/plugin-manifest.js';
3
+ export interface InstalledPlugin {
4
+ manifest: PluginManifest;
5
+ enabled: boolean;
6
+ integrity?: string;
7
+ }
8
+ export type PluginInstallOptions = ExtensionIntegrityOptions;
9
+ export interface PluginListOptions {
10
+ verifyIntegrity?: boolean;
11
+ }
12
+ export declare class PluginManager {
13
+ private readonly root;
14
+ private readonly statePath;
15
+ constructor(root: string);
16
+ list(roots?: readonly string[], options?: PluginListOptions): Promise<readonly InstalledPlugin[]>;
17
+ install(source: string, options?: PluginInstallOptions): Promise<InstalledPlugin>;
18
+ uninstall(name: string): Promise<boolean>;
19
+ setEnabled(name: string, enabled: boolean): Promise<void>;
20
+ private readState;
21
+ private writeState;
22
+ }
23
+ export declare function hashDirectory(directory: string): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import g from"node:crypto";import{verifyExtensionIntegrity as M}from"./extension-integrity.js";import c from"node:fs/promises";import o from"node:path";import{parsePluginManifest as b,PLUGIN_LAYOUT as d}from"../../domain/extensions/plugin-manifest.js";import{CliError as P}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as j}from"../../domain/errors/error-codes.js";import{PluginDiscovery as x,validatePluginManifest as I}from"./plugin-discovery.js";import{atomicWriteFile as D,replaceDirectoryWithRollback as N,withFileLock as y}from"../filesystem/atomic-file-store.js";import{isFileNotFound as S}from"../filesystem/fs-errors.js";import{readJsonFileBounded as E}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as _}from"../../domain/runtime/resource-limits.js";import{parseExtensionState as U}from"../../domain/extensions/extension-state.js";class K{root;statePath;constructor(t){this.root=t,this.statePath=o.join(t,"state.json")}async list(t=[this.root],a={}){const i=await this.readState(),e=await new x().discover(t),r=[];for(const s of e){const f=a.verifyIntegrity===!1?void 0:await p(s.directory);r.push({manifest:s,enabled:i[s.name]?.enabled!==!1,...f===void 0?{}:{integrity:f}})}return r}async install(t,a={}){const i=o.resolve(t),e=o.join(i,d.markerDirectory,d.manifestFile);let r;try{r=await E(e,_.pluginManifestBytes)}catch(h){if(S(h)){const F=o.join(i,".codex-plugin","plugin.json");try{throw await c.stat(F),l("Only the .lotagate-plugin/plugin.json format is supported.")}catch(w){if(w instanceof P)throw w}}throw l("Plugin source must contain .lotagate-plugin/plugin.json.")}const s=b(r,i);await I(s);const f=await p(i);M(f,a,l),await c.mkdir(this.root,{recursive:!0});const m=o.join(this.root,L(s.name)),u=`${m}.tmp-${g.randomUUID()}`;return y(`${m}.install`,async()=>{try{await c.cp(i,u,{recursive:!0,force:!1,errorOnExist:!0}),await I({...s,directory:u});const h=await p(u);if(h!==f)throw l("Plugin changed while it was being installed.");return await N(u,m),await this.setEnabled(s.name,!0),{manifest:{...s,directory:m},enabled:!0,integrity:h}}finally{await c.rm(u,{recursive:!0,force:!0})}})}async uninstall(t){const a=o.join(this.root,L(t));return y(`${a}.install`,async()=>{const i=(await this.list([this.root],{verifyIntegrity:!1})).find(e=>e.manifest.name===t);return i===void 0?!1:(await c.rm(i.manifest.directory,{recursive:!0,force:!0}),await y(this.statePath,async()=>{const e=await this.readState();delete e[t],await this.writeState(e)}),!0)})}async setEnabled(t,a){await y(this.statePath,async()=>{const i=await this.readState();i[t]={enabled:a},await this.writeState(i)})}async readState(){try{return U(await E(this.statePath,_.workspaceSettingsBytes))}catch(t){if(S(t))return{};throw t}}async writeState(t){await D(this.statePath,`${JSON.stringify(t,null,2)}
2
+ `)}}async function p(n){const t=g.createHash("sha256");let a=0;for(const i of await v(n)){const e=o.relative(n,i).split(o.sep).join("/"),r=await c.stat(i);if(r.size>k)throw l("Plugin file exceeds the integrity scan limit.");if(a+=r.size,a>A)throw l("Plugin exceeds the total integrity scan limit.");t.update(e),t.update("\0"),t.update(await c.readFile(i)),t.update("\0")}return t.digest("hex")}const T=5e3,k=10*1024*1024,A=50*1024*1024,O=32;async function v(n,t=0,a={files:0}){if(t>O)throw l("Plugin directory nesting exceeds the integrity scan limit.");const i=[];for(const e of(await c.readdir(n,{withFileTypes:!0})).sort((r,s)=>r.name.localeCompare(s.name))){const r=o.join(n,e.name);if(e.isSymbolicLink())throw l("Plugin packages must not contain symbolic links.");if(e.isDirectory())i.push(...await v(r,t+1,a));else if(e.isFile()&&(i.push(r),a.files+=1,a.files>T))throw l("Plugin contains too many files for the integrity scan.")}return i}function L(n){return`plugin-${Buffer.from(n,"utf8").toString("base64url")}`}function l(n){return new P(j.PLUGIN_MANIFEST_INVALID,n,{category:"extension",userMessage:`Unable to install plugin: ${n}`})}export{K as PluginManager,p as hashDirectory};
@@ -0,0 +1,4 @@
1
+ import { type SkillManifest } from '../../domain/extensions/skill-manifest.js';
2
+ export declare class SkillDiscovery {
3
+ discover(roots: readonly string[]): Promise<readonly SkillManifest[]>;
4
+ }
@@ -0,0 +1 @@
1
+ import m from"node:path";import{parseSkillDocument as c}from"../../domain/extensions/skill-manifest.js";import{CliError as a}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as f}from"../../domain/errors/error-codes.js";import{isFileNotFound as p}from"../filesystem/fs-errors.js";import{readFileBounded as u}from"../filesystem/bounded-file-reader.js";import{RESOURCE_LIMITS as d}from"../../domain/runtime/resource-limits.js";import{listExtensionDirectories as S}from"./extension-directory-reader.js";class _{async discover(s){const i=new Map;for(const e of s)for(const t of await S(e)){const l=m.join(t,"SKILL.md");try{const o=await u(l,d.skillDocumentBytes);if(o.truncated)continue;const n=c(o.bytes.toString("utf8"),t);i.has(n.name)||i.set(n.name,n)}catch(o){if(!p(o)&&!I(o))throw o}}return[...i.values()].sort((e,t)=>e.name.localeCompare(t.name))}}function I(r){return r instanceof a&&r.code===f.SKILL_FRONTMATTER_INVALID}export{_ as SkillDiscovery};
@@ -0,0 +1,9 @@
1
+ import { type ExtensionIntegrityOptions } from './extension-integrity.js';
2
+ import { type SkillManifest } from '../../domain/extensions/skill-manifest.js';
3
+ export interface InstalledSkill {
4
+ manifest: SkillManifest;
5
+ integrity: string;
6
+ }
7
+ export declare class SkillInstaller {
8
+ install(source: string, root: string, options?: ExtensionIntegrityOptions): Promise<InstalledSkill | undefined>;
9
+ }
@@ -0,0 +1 @@
1
+ import n from"node:fs/promises";import{verifyExtensionIntegrity as w}from"./extension-integrity.js";import h from"node:crypto";import o from"node:path";import{parseSkillDocument as S}from"../../domain/extensions/skill-manifest.js";import{CliError as k}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as I}from"../../domain/errors/error-codes.js";import{hashDirectory as p}from"./plugin-manager.js";import{isFileNotFound as c}from"../filesystem/fs-errors.js";import{readFileBounded as g}from"../filesystem/bounded-file-reader.js";import{RESOURCE_LIMITS as L}from"../../domain/runtime/resource-limits.js";import{replaceDirectoryWithRollback as D,withFileLock as F}from"../filesystem/atomic-file-store.js";class N{async install(e,a,r={}){if(await E(e))return;const i=await v(o.resolve(e));if(i===void 0)return;const m=await g(o.join(i,"SKILL.md"),L.skillDocumentBytes);if(m.truncated)throw f("Skill document exceeds the supported size.");const u=S(m.bytes.toString("utf8"),i),d=await p(i);w(d,r,f),await n.mkdir(a,{recursive:!0});const s=o.join(a,u.name),l=`${s}.tmp-${h.randomUUID()}`;return F(`${s}.install`,async()=>{try{await n.cp(i,l,{recursive:!0,force:!1,errorOnExist:!0});const y=await p(l);if(y!==d)throw new Error("Skill changed while it was being installed.");return await D(l,s),{manifest:{...u,directory:s},integrity:y}}finally{await n.rm(l,{recursive:!0,force:!0})}})}}async function E(t){try{return(await n.stat(o.join(t,".lotagate-plugin","plugin.json"))).isFile()}catch(e){if(!c(e))throw e;return!1}}async function v(t){try{if((await n.stat(o.join(t,"SKILL.md"))).isFile())return t}catch(r){if(!c(r))throw r}let e;try{e=await n.readdir(t,{withFileTypes:!0})}catch(r){if(c(r))return;throw r}const a=[];for(const r of e.filter(i=>i.isDirectory()))try{(await n.stat(o.join(t,r.name,"SKILL.md"))).isFile()&&a.push(o.join(t,r.name))}catch(i){if(!c(i))throw i}if(a.length>1)throw f("Source contains multiple skills. Pass the individual skill directory.");return a[0]}function f(t){return new k(I.SKILL_FRONTMATTER_INVALID,t,{category:"extension",userMessage:`Unable to install skill: ${t}`})}export{N as SkillInstaller};
@@ -0,0 +1,22 @@
1
+ import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
2
+ import type { SkillRootScope } from './skill-roots.js';
3
+ export type ScopedSkill = SkillManifest & {
4
+ skillKey: string;
5
+ enabled: boolean;
6
+ scope: SkillRootScope['scope'];
7
+ root: string;
8
+ statePath: string;
9
+ pluginName?: string;
10
+ };
11
+ export interface ScopedSkillListOptions {
12
+ includeShadowed?: boolean;
13
+ }
14
+ export declare class SkillManager {
15
+ private readonly statePath;
16
+ constructor(statePath: string);
17
+ listScoped(scopes: readonly SkillRootScope[], options?: ScopedSkillListOptions): Promise<readonly ScopedSkill[]>;
18
+ setEnabled(name: string, enabled: boolean, statePath?: string): Promise<void>;
19
+ remove(name: string, root: string, statePath?: string): Promise<boolean>;
20
+ private readState;
21
+ private writeState;
22
+ }
@@ -0,0 +1,2 @@
1
+ import p from"node:fs/promises";import{SkillDiscovery as d}from"./skill-discovery.js";import{atomicWriteFile as f,withFileLock as u}from"../filesystem/atomic-file-store.js";import{isFileNotFound as w}from"../filesystem/fs-errors.js";import{readJsonFileBounded as S}from"../filesystem/bounded-json-reader.js";import{RESOURCE_LIMITS as y}from"../../domain/runtime/resource-limits.js";import{parseExtensionState as g}from"../../domain/extensions/extension-state.js";class M{statePath;constructor(e){this.statePath=e}async listScoped(e,s={}){const a=new Map,i=[],n=new Set,c=new Set;for(const t of e){a.has(t.statePath)||a.set(t.statePath,await this.readState(t.statePath));const m=a.get(t.statePath);for(const o of await new d().discover([t.root])){const r=t.scope==="plugin",h=n.has(o.name)||!r&&t.scope==="builtin"&&c.has(o.name);if(s.includeShadowed!==!0&&h)continue;r?c.add(o.name):t.scope!=="builtin"&&n.add(o.name);const l=r?`${t.pluginName??"plugin"}:${o.name}`:o.name;i.push({...o,skillKey:l,enabled:m[l]?.enabled!==!1,scope:t.scope,root:t.root,statePath:t.statePath,...t.pluginName===void 0?{}:{pluginName:t.pluginName}})}}return i}async setEnabled(e,s,a=this.statePath){await u(a,async()=>{const i=await this.readState(a);i[e]={enabled:s},await this.writeState(i,a)})}async remove(e,s,a=this.statePath){const i=(await new d().discover([s])).find(n=>n.name===e||`${n.name}`===e);return i===void 0?!1:(await p.rm(i.directory,{recursive:!0,force:!0}),await u(a,async()=>{const n=await this.readState(a);delete n[e],await this.writeState(n,a)}),!0)}async readState(e=this.statePath){try{return g(await S(e,y.workspaceSettingsBytes))}catch(s){if(w(s))return{};throw s}}async writeState(e,s=this.statePath){await f(s,`${JSON.stringify(e,null,2)}
2
+ `)}}export{M as SkillManager};
@@ -0,0 +1,19 @@
1
+ import type { ExtensionScope } from '../../domain/extensions/extension-scope.js';
2
+ export interface SkillRootScope {
3
+ scope: ExtensionScope | 'plugin' | 'builtin';
4
+ root: string;
5
+ statePath: string;
6
+ pluginName?: string;
7
+ }
8
+ export interface PluginSkillRoot {
9
+ root: string;
10
+ pluginName: string;
11
+ }
12
+ /**
13
+ * Returns skill roots in precedence order: project, user, enabled plugins,
14
+ * then immutable package-provided skills. SkillManager keeps project/user
15
+ * definitions authoritative while qualifying plugin identities so independent
16
+ * plugins can expose the same raw skill name safely.
17
+ */
18
+ export declare function resolveSkillRootScopes(cwd: string, globalConfigDir: string, pluginSkillRoots?: readonly PluginSkillRoot[]): readonly SkillRootScope[];
19
+ export declare function builtinSkillsDirectory(executablePath?: string): string;
@@ -0,0 +1 @@
1
+ import t from"node:path";import{existsSync as a}from"node:fs";import{fileURLToPath as p}from"node:url";function h(s,o,i=[]){const r=t.join(s,".lotagate","skills"),e=t.join(o,"skills-state.json");return[{scope:"project",root:r,statePath:t.join(s,".lotagate","skills-state.json")},{scope:"user",root:t.join(o,"skills"),statePath:e},...i.map(({root:l,pluginName:n})=>({scope:"plugin",root:l,pluginName:n,statePath:e})),{scope:"builtin",root:c(),statePath:e}]}function c(s=process.execPath){const o=t.resolve(t.dirname(s),"..","skills");return a(o)?o:p(new URL("../../../skills/",import.meta.url))}export{c as builtinSkillsDirectory,h as resolveSkillRootScopes};
@@ -0,0 +1,18 @@
1
+ import type { ToolDefinition } from '@lotagate/sdk';
2
+ import type { ToolExecutionContext, ToolExecutor, ToolInfo, ToolResult } from '@lotagate/agent-sdk';
3
+ import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
4
+ import type { SkillScopeStore } from '../../application/extensions/skill-scope-store.js';
5
+ /** Exposes the same skill capability definitions to runtime and context accounting. */
6
+ export declare function skillToolDefinitions(): readonly ToolDefinition[];
7
+ /** Presents validated, model-invocable skills as lazy agent tools. */
8
+ export declare class SkillToolExecutor implements ToolExecutor {
9
+ private readonly scopes;
10
+ private readonly skills;
11
+ constructor(skills: readonly (SkillManifest & {
12
+ enabled: boolean;
13
+ skillKey?: string;
14
+ })[], scopes: SkillScopeStore);
15
+ listTools(): readonly ToolDefinition[];
16
+ getToolInfo(toolName: string): ToolInfo | undefined;
17
+ execute(toolName: string, input: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
18
+ }