@lotagate/cli 0.1.25 → 0.1.27

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 (256) hide show
  1. package/README.md +5 -4
  2. package/bin/lotagate.mjs +50 -8
  3. package/dist/application/agent/agent-constants.d.ts +6 -0
  4. package/dist/application/agent/agent-constants.js +1 -0
  5. package/dist/application/agent/agent-session-store-registry.d.ts +16 -0
  6. package/dist/application/agent/agent-session-store-registry.js +1 -0
  7. package/dist/application/agent/agent-session-store.d.ts +4 -0
  8. package/dist/application/agent/agent-session-store.js +5 -5
  9. package/dist/application/agent/bounded-text-accumulator.d.ts +15 -0
  10. package/dist/application/agent/bounded-text-accumulator.js +1 -0
  11. package/dist/application/agent/capability-profile.d.ts +0 -38
  12. package/dist/application/agent/capability-profile.js +0 -1
  13. package/dist/application/agent/cli-agent-execution-service.d.ts +23 -13
  14. package/dist/application/agent/cli-agent-execution-service.js +1 -1
  15. package/dist/application/agent/cli-agent-preparation-cache.d.ts +39 -0
  16. package/dist/application/agent/cli-agent-preparation-cache.js +1 -0
  17. package/dist/application/agent/context-compaction.d.ts +1 -0
  18. package/dist/application/agent/context-compaction.js +7 -6
  19. package/dist/application/agent/context-token-cache.d.ts +21 -0
  20. package/dist/application/agent/context-token-cache.js +4 -0
  21. package/dist/application/agent/context-usage-service.d.ts +52 -0
  22. package/dist/application/agent/context-usage-service.js +1 -0
  23. package/dist/application/agent/continuation-checkpoint.d.ts +15 -0
  24. package/dist/application/agent/continuation-checkpoint.js +2 -0
  25. package/dist/application/agent/interactive-agent-guidance.d.ts +3 -3
  26. package/dist/application/agent/interactive-agent-guidance.js +2 -2
  27. package/dist/application/chat/pending-attachment-store.d.ts +5 -2
  28. package/dist/application/chat/pending-attachment-store.js +1 -1
  29. package/dist/application/commands/application-command-executor.js +2 -2
  30. package/dist/application/commands/cli-command-services.d.ts +1 -1
  31. package/dist/application/commands/cli-command-services.js +31 -31
  32. package/dist/application/commands/command-catalog.js +1 -1
  33. package/dist/application/commands/goal-command-handlers.js +6 -6
  34. package/dist/application/commands/media-command-handlers.js +7 -6
  35. package/dist/application/commands/memory-command-handler.d.ts +1 -1
  36. package/dist/application/commands/memory-command-handler.js +11 -11
  37. package/dist/application/commands/runtime-command-handlers.js +11 -11
  38. package/dist/application/extensions/plugin-contribution-registry.js +1 -1
  39. package/dist/application/intent/completion-gate.d.ts +2 -5
  40. package/dist/application/intent/completion-gate.js +1 -1
  41. package/dist/application/intent/evidence-ledger.d.ts +2 -1
  42. package/dist/application/intent/evidence-recording-tool-executor.js +1 -1
  43. package/dist/application/intent/intent-compiler.js +2 -2
  44. package/dist/application/lifecycle/operation-registry.d.ts +11 -0
  45. package/dist/application/lifecycle/operation-registry.js +1 -0
  46. package/dist/application/memory/memory-extractor.js +2 -2
  47. package/dist/application/model/cached-model-catalog.d.ts +7 -1
  48. package/dist/application/model/cached-model-catalog.js +1 -1
  49. package/dist/application/model/model-catalog-service.js +1 -1
  50. package/dist/application/model/model-context-window.js +1 -1
  51. package/dist/application/model/model-response-retry.d.ts +7 -1
  52. package/dist/application/model/model-response-retry.js +1 -1
  53. package/dist/application/orchestration/cli-subagent-service.d.ts +4 -0
  54. package/dist/application/orchestration/cli-subagent-service.js +3 -3
  55. package/dist/application/orchestration/cli-turn-event-projector.js +1 -1
  56. package/dist/application/orchestration/cli-turn-events.d.ts +0 -7
  57. package/dist/application/orchestration/goal-input.d.ts +1 -1
  58. package/dist/application/orchestration/goal-input.js +1 -1
  59. package/dist/application/orchestration/headless-agent-turn.d.ts +1 -0
  60. package/dist/application/orchestration/headless-agent-turn.js +3 -3
  61. package/dist/application/orchestration/orchestration-constants.d.ts +3 -0
  62. package/dist/application/orchestration/orchestration-constants.js +1 -0
  63. package/dist/application/orchestration/subagent-handoff.js +3 -3
  64. package/dist/application/project-intelligence/project-intelligence-constants.d.ts +56 -0
  65. package/dist/application/project-intelligence/project-intelligence-constants.js +1 -0
  66. package/dist/application/project-intelligence/project-intelligence-service.js +1 -1
  67. package/dist/application/protocol/browser-host-tool-executor.d.ts +13 -3
  68. package/dist/application/protocol/browser-host-tool-executor.js +2 -2
  69. package/dist/application/protocol/computer-host-tool-executor.d.ts +3 -0
  70. package/dist/application/protocol/computer-host-tool-executor.js +2 -2
  71. package/dist/application/protocol/desktop-agent-command.d.ts +2 -2
  72. package/dist/application/protocol/desktop-agent-command.js +1 -3
  73. package/dist/application/protocol/desktop-agent-contracts.d.ts +34 -0
  74. package/dist/application/protocol/desktop-agent-contracts.js +1 -0
  75. package/dist/application/protocol/desktop-agent-helpers.d.ts +5 -0
  76. package/dist/application/protocol/desktop-agent-helpers.js +1 -0
  77. package/dist/application/protocol/desktop-agent-request-parser.d.ts +31 -6
  78. package/dist/application/protocol/desktop-agent-request-parser.js +1 -1
  79. package/dist/application/protocol/desktop-approval-broker.d.ts +14 -4
  80. package/dist/application/protocol/desktop-approval-broker.js +1 -1
  81. package/dist/application/protocol/desktop-attachment-store.d.ts +19 -2
  82. package/dist/application/protocol/desktop-attachment-store.js +1 -1
  83. package/dist/application/protocol/desktop-execution-policy.d.ts +2 -0
  84. package/dist/application/protocol/desktop-execution-policy.js +1 -1
  85. package/dist/application/protocol/desktop-host-bridge.d.ts +33 -0
  86. package/dist/application/protocol/desktop-host-bridge.js +1 -0
  87. package/dist/application/protocol/desktop-host-capabilities.d.ts +12 -0
  88. package/dist/application/protocol/desktop-host-capabilities.js +1 -0
  89. package/dist/application/protocol/desktop-host-tool-executor.d.ts +15 -2
  90. package/dist/application/protocol/desktop-host-tool-executor.js +2 -2
  91. package/dist/application/protocol/desktop-intent-event-writer.js +1 -1
  92. package/dist/application/protocol/desktop-protocol-helpers.js +1 -1
  93. package/dist/application/protocol/desktop-title-generator.d.ts +5 -0
  94. package/dist/application/protocol/desktop-title-generator.js +3 -0
  95. package/dist/application/protocol/json-line-writer.d.ts +24 -2
  96. package/dist/application/protocol/json-line-writer.js +2 -2
  97. package/dist/application/protocol/jsonl-agent-command.d.ts +1 -1
  98. package/dist/application/protocol/jsonl-agent-command.js +2 -2
  99. package/dist/application/protocol/jsonl-protocol.d.ts +1 -1
  100. package/dist/application/protocol/jsonl-protocol.js +2 -2
  101. package/dist/application/security/desktop-tool-scope-policy.js +1 -1
  102. package/dist/application/security/tool-action-risk-analyzer.js +1 -1
  103. package/dist/application/security/tool-approval-service.d.ts +9 -3
  104. package/dist/application/security/tool-approval-service.js +1 -1
  105. package/dist/application/security/tool-policy-registry.d.ts +20 -0
  106. package/dist/application/security/tool-policy-registry.js +1 -0
  107. package/dist/application/security/tool-risk-classifier.d.ts +2 -1
  108. package/dist/application/security/tool-risk-classifier.js +1 -1
  109. package/dist/application/security/workspace-permission-policy.js +1 -1
  110. package/dist/application/workspace/session-execution-workspace.d.ts +2 -2
  111. package/dist/application/workspace/session-execution-workspace.js +3 -3
  112. package/dist/application/workspace/workspace-constants.d.ts +17 -0
  113. package/dist/application/workspace/workspace-constants.js +1 -0
  114. package/dist/application/workspace/workspace-file-index.d.ts +2 -3
  115. package/dist/application/workspace/workspace-file-index.js +1 -1
  116. package/dist/application/workspace/workspace-instruction-loader.js +1 -1
  117. package/dist/bootstrap/composition-root.d.ts +1 -0
  118. package/dist/bootstrap/runtime-factory.d.ts +5 -0
  119. package/dist/bootstrap/runtime-factory.js +1 -1
  120. package/dist/domain/auth/auth-profile.d.ts +1 -0
  121. package/dist/domain/auth/auth-profile.js +1 -1
  122. package/dist/domain/errors/cli-error.js +1 -1
  123. package/dist/domain/extensions/extension-constants.d.ts +1 -0
  124. package/dist/domain/extensions/extension-constants.js +1 -0
  125. package/dist/domain/extensions/host-tool-plugin-ids.d.ts +0 -4
  126. package/dist/domain/extensions/host-tool-plugin-ids.js +1 -1
  127. package/dist/domain/extensions/plugin-manifest.js +1 -1
  128. package/dist/domain/intent/intent-contract.d.ts +0 -8
  129. package/dist/domain/intent/intent-contract.js +1 -1
  130. package/dist/domain/media/gateway-media-contract.js +1 -1
  131. package/dist/domain/media/media-constants.d.ts +3 -0
  132. package/dist/domain/media/media-constants.js +1 -0
  133. package/dist/domain/media/media-execution-policy.js +1 -1
  134. package/dist/domain/memory/memory-constants.d.ts +3 -0
  135. package/dist/domain/memory/memory-constants.js +1 -0
  136. package/dist/domain/memory/memory-search.js +2 -2
  137. package/dist/domain/orchestration/goal.d.ts +0 -1
  138. package/dist/domain/orchestration/goal.js +1 -1
  139. package/dist/domain/orchestration/work-plan.d.ts +0 -62
  140. package/dist/domain/orchestration/work-plan.js +0 -1
  141. package/dist/domain/runtime/assistant-stream-text.d.ts +11 -0
  142. package/dist/domain/runtime/assistant-stream-text.js +1 -0
  143. package/dist/domain/runtime/gateway-request-budget.d.ts +19 -0
  144. package/dist/domain/runtime/gateway-request-budget.js +1 -0
  145. package/dist/domain/runtime/resource-limits.d.ts +26 -0
  146. package/dist/domain/runtime/resource-limits.js +1 -1
  147. package/dist/domain/session/attachment.d.ts +2 -0
  148. package/dist/domain/workspace/workspace-settings.d.ts +2 -0
  149. package/dist/domain/workspace/workspace-settings.js +1 -1
  150. package/dist/infrastructure/agent-sdk/model-response-metrics.d.ts +7 -0
  151. package/dist/infrastructure/agent-sdk/model-response-metrics.js +1 -0
  152. package/dist/infrastructure/agent-sdk/model-tool-name-mapper.js +1 -1
  153. package/dist/infrastructure/agent-sdk/sdk-constants.d.ts +2 -0
  154. package/dist/infrastructure/agent-sdk/sdk-constants.js +1 -0
  155. package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +1 -1
  156. package/dist/infrastructure/cache/cache-policy.d.ts +2 -0
  157. package/dist/infrastructure/cache/cache-policy.js +1 -1
  158. package/dist/infrastructure/cache/file-cache-store.d.ts +13 -0
  159. package/dist/infrastructure/cache/file-cache-store.js +2 -2
  160. package/dist/infrastructure/clipboard/clipboard-adapter-factory.js +1 -1
  161. package/dist/infrastructure/clipboard/clipboard-constants.d.ts +1 -0
  162. package/dist/infrastructure/clipboard/clipboard-constants.js +1 -0
  163. package/dist/infrastructure/clipboard/clipboard-process.d.ts +20 -0
  164. package/dist/infrastructure/clipboard/clipboard-process.js +1 -0
  165. package/dist/infrastructure/clipboard/clipboard-text-adapter-factory.js +1 -1
  166. package/dist/infrastructure/clipboard/image-normalizer.js +1 -1
  167. package/dist/infrastructure/clipboard/windows-clipboard-adapter.js +1 -1
  168. package/dist/infrastructure/clipboard/windows-clipboard-text-adapter.js +1 -1
  169. package/dist/infrastructure/credentials/encrypted-file-credential-store.js +2 -2
  170. package/dist/infrastructure/credentials/secret-input.d.ts +1 -1
  171. package/dist/infrastructure/credentials/secret-input.js +3 -3
  172. package/dist/infrastructure/extensions/extensions-constants.d.ts +6 -0
  173. package/dist/infrastructure/extensions/extensions-constants.js +1 -0
  174. package/dist/infrastructure/extensions/mcp-runtime.d.ts +9 -0
  175. package/dist/infrastructure/extensions/mcp-runtime.js +1 -1
  176. package/dist/infrastructure/extensions/plugin-agent-discovery.d.ts +3 -1
  177. package/dist/infrastructure/extensions/plugin-agent-discovery.js +1 -1
  178. package/dist/infrastructure/extensions/plugin-manager.js +2 -2
  179. package/dist/infrastructure/extensions/skill-manager.js +2 -2
  180. package/dist/infrastructure/extensions/skill-tool-executor.d.ts +3 -1
  181. package/dist/infrastructure/extensions/skill-tool-executor.js +2 -2
  182. package/dist/infrastructure/filesystem/atomic-file-store.d.ts +11 -0
  183. package/dist/infrastructure/filesystem/atomic-file-store.js +1 -1
  184. package/dist/infrastructure/filesystem/filesystem-constants.d.ts +8 -0
  185. package/dist/infrastructure/filesystem/filesystem-constants.js +1 -0
  186. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +3 -0
  187. package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +3 -3
  188. package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +1 -1
  189. package/dist/infrastructure/logging/daily-rotating-file-writer.js +2 -2
  190. package/dist/infrastructure/logging/log-redactor.js +1 -1
  191. package/dist/infrastructure/logging/logging-constants.d.ts +3 -0
  192. package/dist/infrastructure/logging/logging-constants.js +1 -0
  193. package/dist/infrastructure/logging/structured-logger.d.ts +1 -1
  194. package/dist/infrastructure/logging/structured-logger.js +2 -2
  195. package/dist/infrastructure/observability/tool-execution-logger.d.ts +11 -0
  196. package/dist/infrastructure/observability/tool-execution-logger.js +1 -0
  197. package/dist/infrastructure/platform/host-platform.d.ts +2 -0
  198. package/dist/infrastructure/platform/host-platform.js +1 -1
  199. package/dist/infrastructure/platform/host-process.d.ts +3 -1
  200. package/dist/infrastructure/platform/host-process.js +1 -1
  201. package/dist/infrastructure/platform/platform-constants.d.ts +4 -0
  202. package/dist/infrastructure/platform/platform-constants.js +1 -0
  203. package/dist/infrastructure/platform/process-identity.d.ts +8 -0
  204. package/dist/infrastructure/platform/process-identity.js +1 -0
  205. package/dist/infrastructure/platform/read-only-executable.d.ts +2 -1
  206. package/dist/infrastructure/platform/read-only-executable.js +1 -1
  207. package/dist/infrastructure/sdk/lotagate-client-factory.js +1 -1
  208. package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +4 -0
  209. package/dist/infrastructure/sdk/sdk-media-gateway-client.js +1 -1
  210. package/dist/infrastructure/sessions/file-session-store.d.ts +11 -0
  211. package/dist/infrastructure/sessions/file-session-store.js +4 -4
  212. package/dist/infrastructure/sessions/session-constants.d.ts +3 -0
  213. package/dist/infrastructure/sessions/session-constants.js +1 -0
  214. package/dist/infrastructure/sessions/session-index.js +3 -3
  215. package/dist/infrastructure/sessions/session-journal-health.d.ts +7 -0
  216. package/dist/infrastructure/sessions/session-journal-health.js +1 -0
  217. package/dist/infrastructure/shell/shell-tool-executor.d.ts +5 -1
  218. package/dist/infrastructure/shell/shell-tool-executor.js +2 -2
  219. package/dist/infrastructure/tokens/tiktoken-token-estimator.js +1 -1
  220. package/dist/infrastructure/tokens/token-constants.d.ts +1 -0
  221. package/dist/infrastructure/tokens/token-constants.js +1 -0
  222. package/dist/infrastructure/workspace/workspace-settings-store.d.ts +1 -0
  223. package/dist/infrastructure/workspace/workspace-settings-store.js +4 -4
  224. package/dist/main.js +3 -3
  225. package/dist/ports/media-gateway-client.d.ts +6 -0
  226. package/dist/ports/session-store.d.ts +1 -0
  227. package/dist/presentation/tui/ink/components/composer.js +4 -4
  228. package/dist/presentation/tui/ink/components/transcript.d.ts +1 -0
  229. package/dist/presentation/tui/ink/components/transcript.js +5 -5
  230. package/dist/presentation/tui/ink/tui-bridge.d.ts +2 -2
  231. package/dist/presentation/tui/ink/tui-bridge.js +1 -1
  232. package/dist/presentation/tui/tui-agent-turn-controller.d.ts +45 -0
  233. package/dist/presentation/tui/tui-agent-turn-controller.js +1 -0
  234. package/dist/presentation/tui/tui-application-contract.d.ts +1 -0
  235. package/dist/presentation/tui/tui-application.d.ts +3 -4
  236. package/dist/presentation/tui/tui-application.js +3 -3
  237. package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +2 -2
  238. package/dist/presentation/tui/tui-clipboard-paste-handlers.js +1 -1
  239. package/dist/presentation/tui/tui-command-executor.js +3 -3
  240. package/dist/presentation/tui/tui-context-compaction.d.ts +4 -1
  241. package/dist/presentation/tui/tui-context-compaction.js +1 -1
  242. package/dist/presentation/tui/tui-context-service.d.ts +2 -34
  243. package/dist/presentation/tui/tui-context-service.js +1 -2
  244. package/dist/presentation/tui/tui-initial-model.js +1 -1
  245. package/dist/presentation/tui/tui-tool-approval.d.ts +1 -1
  246. package/dist/presentation/tui/tui-tool-approval.js +1 -1
  247. package/dist/version.d.ts +1 -1
  248. package/dist/version.js +1 -1
  249. package/native-targets.mjs +1 -1
  250. package/package.json +9 -10
  251. package/scripts/install-native.mjs +5 -13
  252. package/bin/lotagate.exe +0 -1
  253. package/dist/application/protocol/document-host-tool-definitions.d.ts +0 -4
  254. package/dist/application/protocol/document-host-tool-definitions.js +0 -1
  255. package/dist/application/protocol/document-host-tool-executor.d.ts +0 -49
  256. package/dist/application/protocol/document-host-tool-executor.js +0 -2
@@ -0,0 +1,52 @@
1
+ import type { CliRuntime } from '../../bootstrap/runtime-factory.js';
2
+ import type { SkillManifest } from '../../domain/extensions/skill-manifest.js';
3
+ import { type CliMcpConfig } from '../../domain/extensions/mcp-config.js';
4
+ import type { SkillRootScope } from '../../infrastructure/extensions/skill-roots.js';
5
+ import type { SessionStore as AgentSessionStore } from '@lotagate/agent-sdk';
6
+ import type { AgentGoalSummary } from './capability-profile.js';
7
+ export interface ContextUsageSnapshot {
8
+ model: string | null;
9
+ contextWindow?: number;
10
+ usedTokens: number;
11
+ systemPromptTokens: number;
12
+ conversationTokens: number;
13
+ inputTokens?: number;
14
+ outputTokens?: number;
15
+ otherTokens?: number;
16
+ transcriptEntries: number;
17
+ userMessages: number;
18
+ assistantMessages: number;
19
+ toolCalls: number;
20
+ compactions: number;
21
+ pendingAttachments: number;
22
+ toolNames: readonly string[];
23
+ mcpServers: number;
24
+ memoryFiles: number;
25
+ }
26
+ export interface ContextUsageServiceInput {
27
+ sessionId?: string;
28
+ model: string | null;
29
+ profileName?: string | null;
30
+ trusted: boolean;
31
+ skills: readonly (SkillManifest & {
32
+ enabled: boolean;
33
+ })[];
34
+ pluginNames: readonly string[];
35
+ pluginMcpConfig?: CliMcpConfig;
36
+ pendingAttachments: number;
37
+ skillRootScopes?: readonly SkillRootScope[];
38
+ agentSessionStore?: AgentSessionStore;
39
+ goal?: AgentGoalSummary;
40
+ }
41
+ export declare class ContextUsageService {
42
+ private readonly runtime;
43
+ private readonly cwd;
44
+ private contextWindow;
45
+ private contextWindowModel;
46
+ private readonly tokenCache;
47
+ constructor(runtime: CliRuntime, cwd: string);
48
+ buildForProject(input: Omit<ContextUsageServiceInput, 'trusted' | 'skills'>): Promise<ContextUsageSnapshot>;
49
+ build(input: ContextUsageServiceInput): Promise<ContextUsageSnapshot>;
50
+ getModelContextWindow(model: string | null, profileName?: string | null): Promise<number | undefined>;
51
+ private resolveContextWindow;
52
+ }
@@ -0,0 +1 @@
1
+ import k from"node:path";import{resolveModelContextWindow as C}from"../model/model-context-window.js";import{buildToolCatalogFromDefinitions as T}from"./tool-catalog.js";import{filesystemToolDefinitions as v}from"../../infrastructure/filesystem/local-filesystem-tool-executor.js";import{shellToolDefinitions as M}from"../../infrastructure/shell/shell-tool-executor.js";import{skillToolDefinitions as W}from"../../infrastructure/extensions/skill-tool-executor.js";import{subagentToolDefinitions as b}from"../orchestration/subagent-tool-executor.js";import{FileMcpConfigStore as p}from"../../infrastructure/extensions/file-mcp-config-store.js";import{mergeMcpConfigsWithOverride as S}from"../../domain/extensions/mcp-config.js";import{SkillManager as j}from"../../infrastructure/extensions/skill-manager.js";import{retainLatestCompaction as D}from"./agent-session-store.js";import{buildAgentHistory as A}from"./agent-history.js";import{createAgentGuidance as I}from"./interactive-agent-guidance.js";import{ContextTokenCache as P}from"./context-token-cache.js";class V{runtime;cwd;contextWindow;contextWindowModel;tokenCache=new P;constructor(t,e){this.runtime=t,this.cwd=e}async buildForProject(t){const e=await this.runtime.projectTrust.inspect(this.cwd),s=await this.runtime.projectTrust.isTrusted(e),r=s&&t.skillRootScopes!==void 0?await new j(k.join(this.runtime.paths.globalConfigDir,"skills-state.json")).listScoped(t.skillRootScopes):[];return this.build({...t,trusted:s,skills:r})}async build(t){const e=await this.resolveContextWindow(t.model,t.profileName),[s,r]=await Promise.all([t.sessionId===void 0?Promise.resolve({transcript:[],events:[]}):this.runtime.sessionStore.readHistory(t.sessionId),Promise.all([p.forScope(this.cwd,this.runtime.paths.globalConfigDir,"user").list(),p.forScope(this.cwd,this.runtime.paths.globalConfigDir,"project").list()]).then(([o,y])=>S(o,y,t.pluginMcpConfig??{}))]),i=D(A(s.transcript,s.events)),w=(t.trusted?T([...v(),...M(),...W(),...b()]):void 0)?.names??[],d=t.model??"o200k_base",l=t.sessionId===void 0?void 0:await t.agentSessionStore?.get(t.sessionId),c=l?.messages?.[0]?.role==="system"?l.messages.slice(1):l?.messages,x=c===void 0||c.length===0?i:c.map(F),a=this.tokenCache.estimate(t.sessionId??"no-session",d,x),m=a.inputTokens,f=a.outputTokens,h=a.otherTokens,u=m+f+h,g=this.tokenCache.system(d,I(t.trusted?"interactive-trusted":"interactive-untrusted"));return{model:t.model,...e===void 0?{}:{contextWindow:e},usedTokens:u+g,systemPromptTokens:g,conversationTokens:u,inputTokens:m,outputTokens:f,otherTokens:h,transcriptEntries:i.length,userMessages:i.filter(o=>o.type==="user").length,assistantMessages:i.filter(o=>o.type==="assistant").length,toolCalls:s.events.filter(o=>o.type==="tool.called").length,compactions:s.events.filter(o=>o.type==="context.compacted").length,pendingAttachments:t.pendingAttachments,toolNames:w,mcpServers:Object.values(r).filter(o=>o.enabled).length,memoryFiles:0}}async getModelContextWindow(t,e){return this.resolveContextWindow(t,e)}async resolveContextWindow(t,e){if(t===null||t.trim().length===0){this.contextWindow=void 0,this.contextWindowModel=void 0;return}const s=`${e??""}\0${t}`;return this.contextWindowModel===s?this.contextWindow:(this.contextWindowModel=s,this.contextWindow=await C(this.runtime,t,e),this.contextWindow)}}function F(n){return{type:n.role,content:H(n.content)}}function H(n){return typeof n=="string"?n:Array.isArray(n)?n.map(t=>typeof t=="object"&&t!==null&&"text"in t&&typeof t.text=="string"?t.text:"").join(""):""}export{V as ContextUsageService};
@@ -0,0 +1,15 @@
1
+ import type { AgentGoalSummary } from './capability-profile.js';
2
+ import type { AgentRunSnapshot } from './agent-run-tracker.js';
3
+ export interface ContinuationCheckpointInput {
4
+ snapshot: AgentRunSnapshot;
5
+ goal?: ContinuationGoal;
6
+ }
7
+ export interface ContinuationGoal extends Pick<AgentGoalSummary, 'objective' | 'status' | 'turns' | 'evaluatorRuns'> {
8
+ tokensUsed?: number;
9
+ usage?: {
10
+ totalTokens: number;
11
+ };
12
+ tokenBudget?: number;
13
+ }
14
+ /** Formats bounded live telemetry for the untrusted compaction summarizer. */
15
+ export declare function formatContinuationCheckpoint(input: ContinuationCheckpointInput): string;
@@ -0,0 +1,2 @@
1
+ function i(t){const{snapshot:e,goal:o}=t,s=o?.tokensUsed??o?.usage?.totalTokens,n=["## Live continuation checkpoint","This checkpoint is host telemetry, not proof of completion. Continue from the retained conversation and verify outcomes.",`- [observed] Agent lifecycle state: ${e.state}`,`- [observed] Model turns completed: ${e.modelTurns}`,`- [observed] Tool calls: ${e.toolCalls}; completed: ${e.toolCompletions}; failures: ${e.toolFailures}`,`- [observed] Tools used: ${e.toolNames.join(", ")||"none"}`];return o!==void 0&&(n.push(`- [user-stated] Active goal: ${u(o.objective,2048)}`),n.push(`- [observed] Goal status: ${o.status}; goal turns: ${o.turns}; evaluator runs: ${o.evaluatorRuns}`),s!==void 0&&n.push(`- [observed] Goal tokens used: ${s}`),o.tokenBudget!==void 0&&n.push(`- [user-stated] Goal token budget: ${o.tokenBudget}`)),n.join(`
2
+ `)}function u(t,e){return t.length<=e?t:`${t.slice(0,e-3)}...`}export{i as formatContinuationCheckpoint};
@@ -1,5 +1,5 @@
1
1
  import type { AgentCapabilityProfile } from './capability-profile.js';
2
2
  /** Builds the shared, concise guidance used by every model-driven CLI agent. */
3
- export declare function createAgentGuidance(profile: AgentCapabilityProfile): string;
4
- /** Compatibility name for callers that specifically render the interactive profile. */
5
- export declare const INTERACTIVE_AGENT_GUIDANCE: string;
3
+ export declare function createAgentGuidance(profile: AgentCapabilityProfile, options?: {
4
+ executionBoundary?: 'sandbox' | 'host';
5
+ }): string;
@@ -1,2 +1,2 @@
1
- const t=["## Agent execution contract","Work in an understand, act, observe, decide loop.","When a tool is needed, call exactly one tool in this response and wait for its result before taking the next action.","When calling a tool, use valid JSON arguments that match the supplied tool schema exactly; do not add undocumented fields.","Inspect the actual result, including returned data, stdout, stderr, exit code, file changes, and errors. Never assume success.","After observing the result, continue with one tool, report a meaningful finding, ask for clarification or approval, or finish with a verified answer."],n=["","## Narration policy","Narration is optional for routine, low-risk, read-only checks. Invoke the next routine tool directly when explanation adds no value.","Speak briefly before or after destructive, consequential, external, expensive, or risky actions, and when a result changes the plan, an error needs handling, an important finding is discovered, a milestone is reached, approval is needed, or the task is complete.","Do not narrate every internal step, repeat the same plan, or expose private chain-of-thought. Report only concise purpose, progress, findings, decisions, and results.","Use the same language as the user's request for narration, plan steps, tool explanations, and the final answer, unless the user explicitly asks for another language."],r=["","## Shell selection","Follow the structured runtime context for the current host.","Use runtime.executionCwd (the session worktree) for tool paths and execution; use runtime.projectRoot for user-facing project paths and changed-file reporting.","On Windows, prefer powershell.exe with the script field for operating-system, filesystem, process, service, environment, network, pipeline, and PowerShell-specific work.","Use direct command and args for project executables such as node, npm, npx, pnpm, yarn, git, rg, compilers, and test runners. Put the executable in command and each argument in args; do not combine them into one command string. Do not wrap every command in PowerShell.","Do not use cmd.exe, bash, or Git Bash unless explicitly required or the preferred host shell is unsuitable."],o=["","## Completion","Before finishing, verify the requested outcome when the task calls for verification, account for errors or incomplete work, and summarize only checks actually performed.","Structure the final answer in the user's language: always include a concise summary of what was done; include a main-files section only when files or other project artifacts were actually changed; include a verification section only when checks, tests, or other verification were actually run and report their real results. Do not output empty sections or claim work or verification that did not happen.","When an action changes file content, include a \u201CChanged files\u201D list with at most five primary files, each as an absolute path rooted at runtime.projectRoot. Never report runtime.executionCwd paths from the session worktree in that list.","Never quote, paste, enumerate, or reproduce detailed file contents in the response. After reading a file for inspection or verification, report only a concise high-level result such as status, size, line count, or whether the requested change is present. This rule is absolute unless the user explicitly requests the file content or a specific excerpt."];function i(e){return e==="title-generator"?"":[...t,...n,...r,...o].join(`
2
- `)}const s=i("interactive-trusted");export{s as INTERACTIVE_AGENT_GUIDANCE,i as createAgentGuidance};
1
+ const r=["## Agent execution contract","Work in an understand, act, observe, decide loop.","When a tool is needed, call exactly one tool in this response and wait for its result before taking the next action.","When calling a tool, use valid JSON arguments that match the supplied tool schema exactly; do not add undocumented fields.","When the request matches an enabled skill or the user explicitly selects one, first call skill.load with the exact skill name and follow the loaded instructions before using any other tool or taking action. Do not infer or recreate a skill's instructions from its description alone.","Inspect the actual result, including returned data, stdout, stderr, exit code, file changes, and errors. Never assume success.","After observing the result, continue with one tool, report a meaningful finding, ask for clarification or approval, or finish with a verified answer."],i=["","## Human-facing narration","Act as a concise, calm, friendly, and approachable engineering collaborator. Keep the user oriented about observable work without exposing private chain-of-thought.","For a routine, low-risk, read-only action whose next step is obvious, invoke the tool directly without narration.","Before a consequential, destructive, external, expensive, or long-running action, say in one short sentence what you are about to do, why it is needed, and the relevant scope or consequence. Do not imply that the action has already completed.","After a meaningful tool result, report the observed outcome and relevant evidence before choosing the next step. Mention a path, status, exit code, or key result when useful.","When you discover something important, state what you found, why it matters, and how it changes the plan.","When an action fails or is partial, state what failed, what remains unknown or incomplete, and whether you will retry, use a safe alternative, or ask the user.","Before requesting approval or clarification, explain the exact action or decision needed and why it blocks progress.","At completion, distinguish completed, partially completed, blocked, and not verified. Report only evidence that was actually observed.","Keep narration short, specific, and natural. Do not narrate every trivial tool call, repeat the same plan, invent progress, reveal secrets, or paste raw tool output.","Use the same language as the user's request for narration, plan steps, tool explanations, and the final answer, unless the user explicitly asks for another language.","Prefer direct wording over canned status messages. Use this shape naturally when useful: before action (what and why), after result (what happened and evidence), next step (what follows from the result)."],s=["","## Subagent handoff narration","Do not narrate routine tool calls to the end user. Report briefly to the parent agent when you discover an important finding, hit an error, need approval, complete a meaningful milestone, or become blocked.","State the observed result, relevant evidence, remaining uncertainty, and the next action or handoff. Never claim completion without evidence."],l=["","## Subagent completion","Follow the handoff contract supplied in the task input. Return exactly one JSON object with the required handoff fields and no Markdown, code fences, or explanatory text outside that object.","Populate the handoff from observed work and tool evidence. Keep unverified claims in warnings or unresolved details, and never claim completion without evidence."],c=["","## Non-interactive output","Do not produce human-facing progress narration for routine operations. Keep output concise and machine-safe; report only meaningful findings, errors, decisions, required input, and verified results."],d=["","## Shell selection","Follow the structured runtime context for the current host.","Use runtime.executionCwd (the session worktree) for tool paths and execution; use runtime.projectRoot for user-facing project paths and changed-file reporting.","On Windows, prefer powershell.exe with the script field for operating-system, filesystem, process, service, environment, network, pipeline, and PowerShell-specific work.","Use direct command and args for project executables such as node, npm, npx, pnpm, yarn, git, rg, compilers, and test runners. Put the executable in command and each argument in args; do not combine them into one command string. Do not wrap every project command in PowerShell.","The Windows PowerShell preference applies only when the runtime platform is Windows. On other platforms, follow the runtime shell and executable availability instead of assuming Windows tools.","Use the script field only with powershell.exe or pwsh.exe, and do not send args together with script. Keep user and path data structured or safely quoted; use literal path handling when the selected operation supports it.","For scripts with multiple operations, make failures observable, inspect stdout, stderr, exit code, and returned data, and verify the intended postcondition. Prefer a dedicated filesystem or host tool when it expresses the operation directly.","On Windows, avoid cmd.exe, bash, or Git Bash unless the runtime context or project explicitly requires one or PowerShell is unsuitable. On other platforms, use the supported host shell and project tools."],u=["","## Isolated guest shell","The current Desktop execution boundary is an isolated guest sandbox. Shell, filesystem, and git operations cross into that boundary; they do not run on the host outside it.","Use the guest runtime executables and workspace-relative POSIX paths. Do not invoke powershell.exe, pwsh.exe, cmd.exe, wsl.exe, Windows paths, or host interop. The PowerShell script field is unavailable in this guest; use direct commands with structured args.",'Use direct command and args for project executables. For multiple shell operations, use bash with args ["-lc", "..."] only when a shell script is necessary; keep user and path data safely quoted.',"Inspect stdout, stderr, exit code, and returned data before continuing. If the guest reports that a dependency or runtime is unavailable, follow the configured host-fallback policy instead of executing an unapproved host command."],h=["","## Completion","Before finishing, compare the actual result with every user requirement and acceptance condition. Choose verification from the project metadata, runtime context, available tools, and the behavior that changed; do not assume a particular language, package manager, build system, or test runner.","Verify both that an operation ran and that its intended result is correct. Inspect direct host or tool evidence such as returned data, file state, process status, exit code, test result, or external response. A successful command alone does not prove the requested outcome.","If verification is unavailable, fails, is partial, or leaves uncertainty, state exactly what remains unverified and why. If a safe, in-scope verification or corrective action is still possible, continue before finishing.","Structure the final answer in the user's language: always include a concise summary of what was done; include a main-files section only when files or other project artifacts were actually changed; include a verification section only when checks, tests, or other verification were actually run and report their real results. Do not output empty sections or claim work or verification that did not happen.","When an action changes file content, report the primary changed files using only their canonical absolute paths under runtime.projectRoot. Never expose, output, or mention the internal execution workspace or runtime.executionCwd path to the user; the execution workspace is strictly internal and must never appear in final answers or changed-file lists. Do not invent, reconstruct, or guess absolute paths from relative names; if the host did not confirm an absolute path under runtime.projectRoot, state that limitation. Do not claim that changes were synchronized when that was not verified. Provide the full changed-file inventory when the user asks for it.","Do not dump complete files or raw command output. Use a concise summary by default, but include a short, relevant excerpt when it is necessary to answer the user, explain a defect, or provide evidence. Redact credentials, tokens, private keys, passwords, and other sensitive values; never expose them through an excerpt."];function p(e,t={}){if(e==="title-generator")return"";const n=e==="interactive-trusted"||e==="interactive-untrusted"?i:e==="subagent"?s:c,o=e==="subagent"?l:h,a=t.executionBoundary==="sandbox"?u:d;return[...r,...n,...a,...o].join(`
2
+ `)}export{p as createAgentGuidance};
@@ -1,12 +1,15 @@
1
1
  import type { AttachmentPayload } from '../../domain/session/attachment.js';
2
+ import { type GatewayAttachmentBudgetInput, type GatewayRequestBudget } from '../../domain/runtime/gateway-request-budget.js';
2
3
  export declare class PendingAttachmentStore {
3
4
  private readonly items;
4
5
  private sequence;
5
6
  list(): readonly AttachmentPayload[];
6
7
  get size(): number;
7
8
  nextId(prefix?: string): string;
8
- assertCanAdd(byteLength: number): void;
9
- add(payload: AttachmentPayload): void;
9
+ assertCanAdd(byteLength: number, prompt?: string, candidate?: GatewayAttachmentBudgetInput): void;
10
+ add(payload: AttachmentPayload, prompt?: string): void;
11
+ assertPromptFits(prompt: string, attachments?: readonly AttachmentPayload[]): GatewayRequestBudget;
10
12
  remove(id: string): boolean;
11
13
  clear(): void;
14
+ private assertBudget;
12
15
  }
@@ -1 +1 @@
1
- import{CliError as r}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as m}from"../../domain/errors/error-codes.js";import{RESOURCE_LIMITS as i}from"../../domain/runtime/resource-limits.js";class d{items=[];sequence=0;list(){return this.items}get size(){return this.items.length}nextId(e="image"){return this.sequence+=1,`${e}-${this.sequence}`}assertCanAdd(e){const t=this.items.reduce((s,n)=>s+n.bytes.byteLength,0);if(this.items.length>=i.pendingAttachments||t+e>i.pendingAttachmentTotalBytes)throw new r(m.ATTACHMENT_TOO_LARGE,"Pending attachment limits exceeded.",{category:"attachment",userMessage:"Too many or too-large attachments are pending. Remove an attachment and retry."})}add(e){this.assertCanAdd(e.bytes.byteLength),this.items.push(e)}remove(e){const t=this.items.findIndex(({attachment:s})=>s.id===e);return t<0?!1:(this.items.splice(t,1),!0)}clear(){this.items.splice(0,this.items.length)}}export{d as PendingAttachmentStore};
1
+ import{CliError as m}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as h}from"../../domain/errors/error-codes.js";import{RESOURCE_LIMITS as d}from"../../domain/runtime/resource-limits.js";import{evaluateGatewayRequestBudget as c}from"../../domain/runtime/gateway-request-budget.js";class f{items=[];sequence=0;list(){return this.items}get size(){return this.items.length}nextId(e="image"){return this.sequence+=1,`${e}-${this.sequence}`}assertCanAdd(e,t,s){const i=this.items.reduce((a,o)=>a+o.bytes.byteLength,0);if(this.items.length>=d.pendingAttachments||i+e>d.pendingAttachmentTotalBytes)throw new m(h.ATTACHMENT_TOO_LARGE,"Pending attachment limits exceeded.",{category:"attachment",userMessage:"Too many or too-large attachments are pending. Remove an attachment and retry."});t!==void 0&&s!==void 0&&this.assertBudget(t,[...this.items.map(r),s],!0)}add(e,t){this.assertCanAdd(e.bytes.byteLength,t,t===void 0?void 0:r(e)),this.items.push(e)}assertPromptFits(e,t=this.items){return this.assertBudget(e,t.map(r))}remove(e){const t=this.items.findIndex(({attachment:s})=>s.id===e);return t<0?!1:(this.items.splice(t,1),!0)}clear(){this.items.splice(0,this.items.length)}assertBudget(e,t,s=!1){const i=c(e,t);if(!i.isWithinLimit||s&&i.isNearLimit){const a=i.isWithinLimit?`would reach the ${i.limitBytes*.8/1e6} MB decimal Gateway JSON admission threshold`:`exceed the ${i.limitBytes/1e6} MB decimal Gateway JSON limit`;throw new m(h.ATTACHMENT_TOO_LARGE,`This attachment ${a}.`,{category:"attachment",userMessage:`This attachment ${a}. Send the current prompt or remove an attachment before adding another.`,details:{kind:"gateway-json-body",maxBytes:i.limitBytes,projectedBytes:i.projectedBytes}})}return i}}function r(n){return{byteLength:n.bytes.byteLength,mimeType:n.attachment.mimeType,name:n.attachment.name}}export{f as PendingAttachmentStore};
@@ -1,3 +1,3 @@
1
- import{runAgentCommand as a}from"../protocol/jsonl-agent-command.js";import{runAuthCommand as t,runConfigCommand as o,runEffortCommand as m,runHookCommand as d,runMcpCommand as c,runModelCommand as l,runPluginCommand as p,runSkillCommand as s,runTrustCommand as f}from"./cli-command-services.js";import{formatCommandHelp as w}from"./command-presentation.js";import{COMMAND_REGISTRY as C}from"./command-runtime.js";import{runGoalCommand as y}from"./goal-command-handlers.js";import{runChatCommand as P,runExecCommand as g,runSessionCommand as x}from"./runtime-command-handlers.js";import{runMediaCommand as E}from"./media-command-handlers.js";import{runCompletionsCommand as S,runDoctorCommand as I,runInspectCommand as O,runUpdateCommand as b}from"./utility-commands.js";import{runMemoryCommand as M}from"./memory-command-handler.js";import{CLI_VERSION as $}from"../../version.js";const k={help:async(r,n)=>i(r,n.output),version:async(r,n)=>i(r,n.output),config:async(r,n)=>o(r.handlerPositionals,n.runtime.configLoader,n.cwd,n.output),auth:async(r,n)=>t(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.secrets?.apiKey),trust:async(r,n)=>f(r.handlerPositionals,n.runtime,n.cwd,n.output),inspect:async(r,n)=>O(n.runtime,n.cwd,n.output),hook:async(r,n)=>d(r.handlerPositionals,n.runtime,n.cwd,n.output),model:async(r,n)=>l(r.handlerPositionals,n.runtime,n.cwd,n.output),effort:async(r,n)=>m(r.handlerPositionals,n.runtime,n.cwd,n.output),mcp:async(r,n)=>c(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,u(n),n.signal),plugin:async(r,n)=>p(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,u(n),n.signal),skill:async(r,n)=>s(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,u(n),n.signal),session:async(r,n)=>x(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.resumeInteractive,n.signal),goal:async(r,n)=>{if(n.writableOutput===void 0)throw new Error("Goal commands require a writable terminal output.");return y(r.handlerPositionals,r.options,n.runtime,n.cwd,n.writableOutput,n.signal)},memory:async(r,n)=>M(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output),doctor:async(r,n)=>I(n.runtime,n.cwd,n.output),chat:async(r,n)=>P(r.handlerPositionals,n.runtime,n.cwd,n.output,n.signal),exec:async(r,n)=>g(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.signal),media:async(r,n)=>E(r,n.runtime,n.cwd,n.output,n.activity,n.signal),agent:async(r,n)=>{if(n.stdin===void 0||n.writableOutput===void 0)throw new Error("The JSONL agent protocol requires stdin and a writable terminal output.");return a(r.handlerPositionals,n.runtime,n.cwd,n.stdin,n.writableOutput)},completions:async(r,n)=>S(r.handlerPositionals,n.output),update:async(r,n)=>b(r.handlerPositionals,n.runtime,n.cwd,n.output)};async function J(r,n){const e=k[r.action.executor];if(e===void 0)throw new Error(`Command ${r.action.id} requires a ${r.surface}-specific executor.`);return e(r,n)}function q(r,n){if(r.action.executor==="help")return n.write(`${w(C,r.surface)}
1
+ import{runAgentCommand as a}from"../protocol/jsonl-agent-command.js";import{runAuthCommand as t,runConfigCommand as m,runEffortCommand as o,runHookCommand as d,runMcpCommand as c,runModelCommand as l,runPluginCommand as p,runSkillCommand as s,runTrustCommand as f}from"./cli-command-services.js";import{formatCommandHelp as w}from"./command-presentation.js";import{COMMAND_REGISTRY as C}from"./command-runtime.js";import{runGoalCommand as y}from"./goal-command-handlers.js";import{runChatCommand as g,runExecCommand as P,runSessionCommand as x}from"./runtime-command-handlers.js";import{runMediaCommand as E}from"./media-command-handlers.js";import{runCompletionsCommand as S,runDoctorCommand as I,runInspectCommand as O,runUpdateCommand as b}from"./utility-commands.js";import{runMemoryCommand as M}from"./memory-command-handler.js";import{CLI_VERSION as $}from"../../version.js";const k={help:async(r,n)=>u(r,n.output),version:async(r,n)=>u(r,n.output),config:async(r,n)=>m(r.handlerPositionals,n.runtime.configLoader,n.cwd,n.output),auth:async(r,n)=>t(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.secrets?.apiKey,n.signal),trust:async(r,n)=>f(r.handlerPositionals,n.runtime,n.cwd,n.output),inspect:async(r,n)=>O(n.runtime,n.cwd,n.output),hook:async(r,n)=>d(r.handlerPositionals,n.runtime,n.cwd,n.output),model:async(r,n)=>l(r.handlerPositionals,n.runtime,n.cwd,n.output),effort:async(r,n)=>o(r.handlerPositionals,n.runtime,n.cwd,n.output),mcp:async(r,n)=>c(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,i(n),n.signal),plugin:async(r,n)=>p(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,i(n),n.signal),skill:async(r,n)=>s(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,i(n),n.signal),session:async(r,n)=>x(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.resumeInteractive,n.signal),goal:async(r,n)=>{if(n.writableOutput===void 0)throw new Error("Goal commands require a writable terminal output.");return y(r.handlerPositionals,r.options,n.runtime,n.cwd,n.writableOutput,n.signal)},memory:async(r,n)=>M(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.signal),doctor:async(r,n)=>I(n.runtime,n.cwd,n.output),chat:async(r,n)=>g(r.handlerPositionals,n.runtime,n.cwd,n.output,n.signal),exec:async(r,n)=>P(r.handlerPositionals,r.options,n.runtime,n.cwd,n.output,n.signal),media:async(r,n)=>E(r,n.runtime,n.cwd,n.output,n.activity,n.signal),agent:async(r,n)=>{if(n.stdin===void 0||n.writableOutput===void 0)throw new Error("The JSONL agent protocol requires stdin and a writable terminal output.");return a(r.handlerPositionals,n.runtime,n.cwd,n.stdin,n.writableOutput,n.signal)},completions:async(r,n)=>S(r.handlerPositionals,n.output),update:async(r,n)=>b(r.handlerPositionals,n.runtime,n.cwd,n.output)};async function J(r,n){const e=k[r.action.executor];if(e===void 0)throw new Error(`Command ${r.action.id} requires a ${r.surface}-specific executor.`);return e(r,n)}function q(r,n){if(r.action.executor==="help")return n.write(`${w(C,r.surface)}
2
2
  `),0;if(r.action.executor==="version")return n.write(`${$}
3
- `),0}function i(r,n){const e=q(r,n);if(e===void 0)throw new Error(`Command ${r.action.id} is not informational.`);return e}function u(r){return r.selectScope===void 0?{}:{selectScope:r.selectScope}}export{J as executeApplicationCommand,q as executeInformationalCommand};
3
+ `),0}function u(r,n){const e=q(r,n);if(e===void 0)throw new Error(`Command ${r.action.id} is not informational.`);return e}function i(r){return r.selectScope===void 0?{}:{selectScope:r.selectScope}}export{J as executeApplicationCommand,q as executeInformationalCommand};
@@ -7,7 +7,7 @@ export interface CommandInteraction {
7
7
  selectScope?: (title: string) => Promise<ExtensionScope | undefined>;
8
8
  }
9
9
  export declare function runConfigCommand(positionals: readonly string[], loader: ConfigLoader, cwd: string, output: CommandOutput): Promise<number>;
10
- export declare function runAuthCommand(positionals: readonly string[], flags: ReadonlyMap<string, string | boolean>, runtime: CliRuntime, cwd: string, output: CommandOutput, desktopApiKey?: string): Promise<number>;
10
+ export declare function runAuthCommand(positionals: readonly string[], flags: ReadonlyMap<string, string | boolean>, runtime: CliRuntime, cwd: string, output: CommandOutput, desktopApiKey?: string, signal?: AbortSignal): Promise<number>;
11
11
  export declare function runTrustCommand(positionals: readonly string[], runtime: CliRuntime, cwd: string, output: CommandOutput): Promise<number>;
12
12
  export declare function runModelCommand(positionals: readonly string[], runtime: CliRuntime, cwd: string, output: CommandOutput): Promise<number>;
13
13
  export declare function runEffortCommand(positionals: readonly string[], runtime: CliRuntime, cwd: string, output: CommandOutput): Promise<number>;
@@ -1,33 +1,33 @@
1
- import j from"node:path";import{AuthenticationService as D}from"../auth/authentication-service.js";import{CONFIGURABLE_KEYS as V,DEFAULT_CONFIG as B,REASONING_EFFORTS as H}from"../../domain/config/config-schema.js";import{requirePositional as S,getFlag as $,requireStringFlag as _}from"./cli-args.js";import{readSecret as Y}from"../../infrastructure/credentials/secret-input.js";import{getModelContextWindow as z}from"../../infrastructure/sdk/model-catalog-adapter.js";import{FileMcpConfigStore as F}from"../../infrastructure/extensions/file-mcp-config-store.js";import{McpRuntime as Q}from"../../infrastructure/extensions/mcp-runtime.js";import{PluginManager as G}from"../../infrastructure/extensions/plugin-manager.js";import{SkillManager as X}from"../../infrastructure/extensions/skill-manager.js";import{SkillInstaller as Z}from"../../infrastructure/extensions/skill-installer.js";import{resolveExtensionSource as ee}from"../../infrastructure/extensions/extension-source-resolver.js";import{resolveSkillRootScopes as te}from"../../infrastructure/extensions/skill-roots.js";import{CompositeMcpConfigStore as oe}from"../../infrastructure/extensions/composite-mcp-config-store.js";import{PluginContributionRegistry as x}from"../extensions/plugin-contribution-registry.js";import{parseExtensionScope as ne,requireExtensionScope as re}from"../../domain/extensions/extension-scope.js";import{CliError as P}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as C}from"../../domain/errors/error-codes.js";import{createHookListResult as J,createMcpListResult as ie,createPluginListResult as ae,createSkillListResult as se,formatExtensionList as v}from"../extensions/extension-list-formatters.js";import{writeExtensionListResult as E}from"../extensions/extension-list-output.js";import{HookRuntime as le}from"../../infrastructure/extensions/hook-runtime.js";import{ShellToolExecutor as ce}from"../../infrastructure/shell/shell-tool-executor.js";import{ToolPolicy as fe}from"@lotagate/agent-sdk";import{formatMcpDetails as de}from"../extensions/extension-list-formatters.js";import{loadExecutionConfig as W}from"../config/execution-config.js";import{redactLogText as K}from"../../infrastructure/logging/log-redactor.js";import{formatCompactTable as R}from"../formatting/compact-table.js";import{formatCompactNumber as pe}from"../formatting/compact-number.js";import{loadModelCatalog as ue}from"../model/model-catalog-service.js";import{describeInstalledPlugin as ge}from"../extensions/plugin-detail-service.js";import{throwIfCommandAborted as w}from"./command-cancellation.js";const we={empty:"No models are available.",maxWidth:160,columns:[{key:"name",header:"Name",width:52,minWidth:16},{key:"category",header:"Model category",width:16,minWidth:8},{key:"contextWindow",header:"Context window",width:14,minWidth:8},{key:"status",header:"Status",width:12,minWidth:6},{key:"detail",header:"Detail",minWidth:6}]};async function ze(s,r,e,o){const t=s[0]??"get";if(t==="path")return o.write(`${JSON.stringify({global:r.platformPaths.globalConfigFile,project:j.join(e,".lotagate")},null,2)}
2
- `),0;if(t==="get"){const l=await r.load(e),n=s[1];return o.write(`${JSON.stringify(n===void 0?l.config:l.config[n]??null,null,2)}
3
- `),0}if(t==="set"){const l=S(s,1,"config key");if(!V.includes(l))throw new P(C.INVALID_ARGUMENT,`Unsupported config key: ${l}`,{category:"arguments",userMessage:`Unsupported configuration key: ${l}.`});return await r.setGlobal(l,ye(S(s,2,"config value"))),0}throw new Error(`Unsupported config action: ${t}`)}async function Qe(s,r,e,o,t,l){const n=s[0]??"status",p=await e.configLoader.load(o,{includeProject:!1}),g=p.config.profile??D.defaultProfileName();if(n==="login"){const i=String($(r,"profile")??g),a=String($(r,"base-url")??p.config.baseUrl??B.baseUrl),d=await e.auth.login({profileName:i,baseUrl:a,apiKey:l??await Y("LotaGate API key: ")});return await e.configLoader.setGlobal("profile",d.name),t.write(`Logged in profile: ${d.name}
4
- `),0}if(n==="list"){const i=await e.auth.list();return t.write(`${R(i.map(a=>({name:a.name,status:a.name===g?"ACTIVE":"READY",detail:K(a.baseUrl)})),{empty:"No authentication profiles."})}
5
- `),0}if(n==="status"){const i=await e.credentialStore.get(g);return t.write(`${JSON.stringify(i===void 0?{authenticated:!1,profile:g}:{authenticated:!0,profile:i.profile.name,baseUrl:i.profile.baseUrl,credentialRef:i.profile.credentialRef},null,2)}
6
- `),0}if(n==="logout"){const i=s[1]??g,a=await e.auth.logout(i);return t.write(`${a?`Logged out profile: ${i}`:`Profile not found: ${i}`}
7
- `),a?0:1}if(n==="use"){const i=S(s,1,"profile name");return await e.auth.requireCredential(i),await e.configLoader.setGlobal("profile",i),t.write(`Active profile: ${i}
8
- `),0}throw new Error(`Unsupported auth action: ${n}`)}async function Xe(s,r,e,o){const t=s[0]??"status";if(t==="list")return o.write(`${R((await r.projectTrust.list()).map(n=>({name:n.canonicalPath,status:"TRUSTED",detail:n.fingerprint})),{empty:"No trusted projects."})}
9
- `),0;const l=await r.projectTrust.inspect(e);if(t==="status")return o.write(`${JSON.stringify({...l,trusted:await r.projectTrust.isTrusted(l)},null,2)}
10
- `),0;if(t==="grant")return await r.projectTrust.grant(l),await r.workspaceSettings.ensureInitialized(l.canonicalPath),o.write(`Trusted project: ${l.canonicalPath}
11
- `),0;if(t==="revoke"){const n=await r.projectTrust.revoke(l);return o.write(`${n?`Revoked project: ${l.canonicalPath}`:"Project was not trusted."}
12
- `),n?0:1}throw new Error(`Unsupported trust action: ${t}`)}async function Ze(s,r,e,o){const t=s[0]??"current",l=await W(r,e);if(t==="current")return o.write(`${JSON.stringify({model:l.config.model,profile:l.config.profile},null,2)}
13
- `),0;if(t==="use"){const n=S(s,1,"model id");return await r.configLoader.setGlobal("model",n),o.write(`Active model: ${n}
14
- `),0}if(t==="list"||t==="refresh"){const n=await ue(r,e,t==="refresh");return o.write(`${R(n.data.map(p=>({name:typeof p.display_name=="string"?p.display_name:p.id,status:p.id===l.config.model?"ACTIVE":"AVAILABLE",...typeof p.owned_by=="string"?{detail:p.owned_by}:{},values:{category:typeof p.model_category=="string"?p.model_category:"-",contextWindow:me(p)}})),we)}
15
- `),0}if(t==="doctor"){const n=l.config.profile??D.defaultProfileName(),p=await r.auth.status(n);return o.write(`${JSON.stringify({profile:n,authenticated:p!==void 0,model:l.config.model,baseUrl:p?.baseUrl??l.config.baseUrl},null,2)}
16
- `),0}throw new Error(`Unsupported model action: ${t}`)}async function et(s,r,e,o){const t=s[0]??"current",l=await W(r,e);if(t==="current")return o.write(`${JSON.stringify({effort:l.config.effort},null,2)}
17
- `),0;if(t==="use"){const n=S(s,1,"effort");if(!H.includes(n))throw new Error(`Unsupported reasoning effort: ${n}`);return await r.configLoader.setGlobal("effort",n),o.write(`Active effort: ${n}
18
- `),0}throw new Error(`Unsupported effort action: ${t}`)}function me(s){const r=z(s);return r===void 0?"-":pe(r)}async function tt(s,r,e,o,t,l={},n){w(n);const p=F.forScope(o,e.paths.globalConfigDir,"project"),g=F.forScope(o,e.paths.globalConfigDir,"user"),i=s[0]??"list";if(i==="list"){const c=await e.projectTrust.inspect(o),h=await e.projectTrust.isTrusted(c),f=await new x(e.paths.globalConfigDir).resolve(o,h),m=ie([{scope:"user",config:await g.list()},{scope:"project",config:await p.list()},...h&&Object.keys(f.mcpConfig).length>0?[{scope:"plugin",config:f.mcpConfig,sourceNames:Object.fromEntries(f.mcpContributions.map(b=>[b.qualifiedName,b.sourceName])),pluginNames:Object.fromEntries(f.mcpContributions.map(b=>[b.qualifiedName,b.pluginName]))}]:[]]);return E(t,m,v(m)),0}if(i==="reload"||i==="doctor"){w(n),i==="reload"&&await e.mcpRuntime.invalidate(o);const c=new Q(()=>new oe([g,p]));try{const h=await e.projectTrust.inspect(o),f=await c.connectConfigured(o,await e.projectTrust.isTrusted(h));return w(n),t.write(`${R(f.map(({serverId:m,status:b,protocolEra:T,protocolVersion:N,error:M})=>({name:m,status:b==="connected"?"OK":b.toUpperCase(),detail:M===void 0?[T,N].filter(Boolean).join(" \xB7 "):K(M.message)})),{empty:"No MCP servers configured."})}
19
- `),f.some(m=>m.status==="failed")?1:0}finally{await c.close()}}const a=S(s,1,"MCP server name"),d=await U(r,l,"MCP server scope",!0);if(d===void 0)throw new Error("MCP server scope was not selected.");const u={store:d==="project"?p:g,scope:d},y=u.store;if(i==="get"){const c=await y.get(a);return t.write(`${de(a,u.scope,c)}
20
- `),0}if(i==="remove"){w(n),await k(e,o,u.scope);const c=await y.remove(a);return c&&await e.mcpRuntime.invalidate(o),e.logger.info("MCP server removal completed.",{name:a,scope:u.scope,removed:c}),t.write(`${c?`Removed MCP server: ${a}`:`MCP server not found: ${a}`}
21
- `),c?0:1}if(i==="enable"||i==="disable")return w(n),await k(e,o,u.scope),await y.setEnabled(a,i==="enable"),await e.mcpRuntime.invalidate(o),e.logger.info("MCP server state changed.",{name:a,scope:u.scope,enabled:i==="enable"}),t.write(`${i==="enable"?"Enabled":"Disabled"} MCP server: ${a}
22
- `),0;if(i==="add"){w(n),await k(e,o,d??"project");const c=String($(r,"type")??"stdio");if(c==="stdio"){const h=_(r,"command"),f=$(r,"args");await y.add(a,{type:"stdio",command:h,...typeof f=="string"?{args:f.split(",").map(m=>m.trim()).filter(Boolean)}:{}})}else if(c==="http"||c==="sse")await y.add(a,{type:c,url:_(r,"url")});else throw new P(C.INVALID_ARGUMENT,`Unsupported MCP type: ${c}`,{category:"arguments",userMessage:"MCP type must be stdio, http, or sse."});return w(n),await e.mcpRuntime.invalidate(o),e.logger.info("MCP server added.",{name:a,scope:d??"project",type:c}),t.write(`Added MCP server successfully: ${a}
23
- `),0}throw new Error(`Unsupported MCP action: ${i}`)}async function ot(s,r,e,o,t,l={},n){w(n);const p=new G(e.paths.pluginsDir),g=new G(j.join(j.resolve(o),".lotagate","plugins")),i=s[0]??"list";if(i==="list"){const f=ae([{scope:"user",plugins:await p.list(void 0,{verifyIntegrity:!1})},{scope:"project",plugins:await g.list(void 0,{verifyIntegrity:!1})}]);return E(t,f,v(f)),0}if(i==="install"){const f=S(s,1,"plugin or skill source"),m=await U(r,l,"Plugin installation scope",!0);if(m===void 0)throw new Error("Plugin installation scope was not selected.");await k(e,o,m);const b=$(r,"sha256"),T=$(r,"signature"),N=$(r,"public-key"),M=m==="project"?g:p,q=m==="project"?j.join(j.resolve(o),".lotagate","skills"):e.paths.skillsDir,O=await ee(f,e.platform,n);try{w(n);const A={...typeof b=="string"?{sha256:b}:{},...typeof T=="string"?{signature:T}:{},...typeof N=="string"?{publicKeyPem:N}:{}},L=await new Z().install(O.directory,q,A);if(L!==void 0)return w(n),e.logger.info("Skill installed.",{name:L.manifest.name,scope:m}),t.write(`Added skill successfully: ${L.manifest.name}
24
- `),0;const I=await M.install(O.directory,A);return w(n),e.logger.info("Plugin installed.",{name:I.manifest.name,scope:m}),t.write(`Added plugin successfully: ${I.manifest.name}
25
- `),0}finally{await O.cleanup()}}const a=S(s,1,"plugin name"),d=await U(r,l,"Plugin scope",!0);if(d===void 0)throw new Error("Plugin scope was not selected.");const u={manager:d==="project"?g:p,scope:d},y=u.manager,h=(await y.list(void 0,{verifyIntegrity:!1})).find(f=>f.manifest.name===a);if(h===void 0)throw new P(C.PLUGIN_NOT_FOUND,`Plugin not found: ${a}`,{category:"extension",userMessage:`Plugin not found: ${a}.`});if(i==="info"){const f=await ge(h,d);return t.writeStructured===void 0?t.write(`${JSON.stringify(f,null,2)}
1
+ import j from"node:path";import{AuthenticationService as D}from"../auth/authentication-service.js";import{CONFIGURABLE_KEYS as V,DEFAULT_CONFIG as B,REASONING_EFFORTS as H}from"../../domain/config/config-schema.js";import{requirePositional as S,getFlag as $,requireStringFlag as _}from"./cli-args.js";import{readSecret as Y}from"../../infrastructure/credentials/secret-input.js";import{getModelContextWindow as z}from"../../infrastructure/sdk/model-catalog-adapter.js";import{FileMcpConfigStore as F}from"../../infrastructure/extensions/file-mcp-config-store.js";import{McpRuntime as Q}from"../../infrastructure/extensions/mcp-runtime.js";import{PluginManager as G}from"../../infrastructure/extensions/plugin-manager.js";import{SkillManager as X}from"../../infrastructure/extensions/skill-manager.js";import{SkillInstaller as Z}from"../../infrastructure/extensions/skill-installer.js";import{resolveExtensionSource as ee}from"../../infrastructure/extensions/extension-source-resolver.js";import{resolveSkillRootScopes as te}from"../../infrastructure/extensions/skill-roots.js";import{CompositeMcpConfigStore as oe}from"../../infrastructure/extensions/composite-mcp-config-store.js";import{PluginContributionRegistry as x}from"../extensions/plugin-contribution-registry.js";import{parseExtensionScope as ne,requireExtensionScope as re}from"../../domain/extensions/extension-scope.js";import{CliError as P}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as C}from"../../domain/errors/error-codes.js";import{createHookListResult as J,createMcpListResult as ie,createPluginListResult as ae,createSkillListResult as se,formatExtensionList as v}from"../extensions/extension-list-formatters.js";import{writeExtensionListResult as E}from"../extensions/extension-list-output.js";import{HookRuntime as le}from"../../infrastructure/extensions/hook-runtime.js";import{ShellToolExecutor as ce}from"../../infrastructure/shell/shell-tool-executor.js";import{ToolPolicy as fe}from"@lotagate/agent-sdk";import{formatMcpDetails as de}from"../extensions/extension-list-formatters.js";import{loadExecutionConfig as W}from"../config/execution-config.js";import{redactLogText as K}from"../../infrastructure/logging/log-redactor.js";import{formatCompactTable as R}from"../formatting/compact-table.js";import{formatCompactNumber as pe}from"../formatting/compact-number.js";import{loadModelCatalog as ue}from"../model/model-catalog-service.js";import{describeInstalledPlugin as ge}from"../extensions/plugin-detail-service.js";import{throwIfCommandAborted as g}from"./command-cancellation.js";const we={empty:"No models are available.",maxWidth:160,columns:[{key:"name",header:"Name",width:52,minWidth:16},{key:"category",header:"Model category",width:16,minWidth:8},{key:"contextWindow",header:"Context window",width:14,minWidth:8},{key:"status",header:"Status",width:12,minWidth:6},{key:"detail",header:"Detail",minWidth:6}]};async function ze(a,r,e,o){const t=a[0]??"get";if(t==="path")return o.write(`${JSON.stringify({global:r.platformPaths.globalConfigFile,project:j.join(e,".lotagate")},null,2)}
2
+ `),0;if(t==="get"){const s=await r.load(e),i=a[1];return o.write(`${JSON.stringify(i===void 0?s.config:s.config[i]??null,null,2)}
3
+ `),0}if(t==="set"){const s=S(a,1,"config key");if(!V.includes(s))throw new P(C.INVALID_ARGUMENT,`Unsupported config key: ${s}`,{category:"arguments",userMessage:`Unsupported configuration key: ${s}.`});return await r.setGlobal(s,ye(S(a,2,"config value"))),0}throw new Error(`Unsupported config action: ${t}`)}async function Qe(a,r,e,o,t,s,i){g(i);const p=a[0]??"status",w=await e.configLoader.load(o,{includeProject:!1}),l=w.config.profile??D.defaultProfileName();if(p==="login"){const n=String($(r,"profile")??l),d=String($(r,"base-url")??w.config.baseUrl??B.baseUrl),u=await e.auth.login({profileName:n,baseUrl:d,apiKey:s??await Y("LotaGate API key: ",process.stdin,process.stderr,i)});return await e.configLoader.setGlobal("profile",u.name),t.write(`Logged in profile: ${u.name}
4
+ `),0}if(p==="list"){const n=await e.auth.list();return t.write(`${R(n.map(d=>({name:d.name,status:d.name===l?"ACTIVE":"READY",detail:K(d.baseUrl)})),{empty:"No authentication profiles."})}
5
+ `),0}if(p==="status"){const n=await e.credentialStore.get(l);return t.write(`${JSON.stringify(n===void 0?{authenticated:!1,profile:l}:{authenticated:!0,profile:n.profile.name,baseUrl:n.profile.baseUrl,credentialRef:n.profile.credentialRef},null,2)}
6
+ `),0}if(p==="logout"){const n=a[1]??l,d=await e.auth.logout(n);return t.write(`${d?`Logged out profile: ${n}`:`Profile not found: ${n}`}
7
+ `),d?0:1}if(p==="use"){const n=S(a,1,"profile name");return await e.auth.requireCredential(n),await e.configLoader.setGlobal("profile",n),t.write(`Active profile: ${n}
8
+ `),0}throw new Error(`Unsupported auth action: ${p}`)}async function Xe(a,r,e,o){const t=a[0]??"status";if(t==="list")return o.write(`${R((await r.projectTrust.list()).map(i=>({name:i.canonicalPath,status:"TRUSTED",detail:i.fingerprint})),{empty:"No trusted projects."})}
9
+ `),0;const s=await r.projectTrust.inspect(e);if(t==="status")return o.write(`${JSON.stringify({...s,trusted:await r.projectTrust.isTrusted(s)},null,2)}
10
+ `),0;if(t==="grant")return await r.projectTrust.grant(s),await r.workspaceSettings.ensureInitialized(s.canonicalPath),o.write(`Trusted project: ${s.canonicalPath}
11
+ `),0;if(t==="revoke"){const i=await r.projectTrust.revoke(s);return o.write(`${i?`Revoked project: ${s.canonicalPath}`:"Project was not trusted."}
12
+ `),i?0:1}throw new Error(`Unsupported trust action: ${t}`)}async function Ze(a,r,e,o){const t=a[0]??"current",s=await W(r,e);if(t==="current")return o.write(`${JSON.stringify({model:s.config.model,profile:s.config.profile},null,2)}
13
+ `),0;if(t==="use"){const i=S(a,1,"model id");return await r.configLoader.setGlobal("model",i),o.write(`Active model: ${i}
14
+ `),0}if(t==="list"||t==="refresh"){const i=await ue(r,e,t==="refresh");return o.write(`${R(i.data.map(p=>({name:typeof p.display_name=="string"?p.display_name:p.id,status:p.id===s.config.model?"ACTIVE":"AVAILABLE",...typeof p.owned_by=="string"?{detail:p.owned_by}:{},values:{category:typeof p.model_category=="string"?p.model_category:"-",contextWindow:me(p)}})),we)}
15
+ `),0}if(t==="doctor"){const i=s.config.profile??D.defaultProfileName(),p=await r.auth.status(i);return o.write(`${JSON.stringify({profile:i,authenticated:p!==void 0,model:s.config.model,baseUrl:p?.baseUrl??s.config.baseUrl},null,2)}
16
+ `),0}throw new Error(`Unsupported model action: ${t}`)}async function et(a,r,e,o){const t=a[0]??"current",s=await W(r,e);if(t==="current")return o.write(`${JSON.stringify({effort:s.config.effort},null,2)}
17
+ `),0;if(t==="use"){const i=S(a,1,"effort");if(!H.includes(i))throw new Error(`Unsupported reasoning effort: ${i}`);return await r.configLoader.setGlobal("effort",i),o.write(`Active effort: ${i}
18
+ `),0}throw new Error(`Unsupported effort action: ${t}`)}function me(a){const r=z(a);return r===void 0?"-":pe(r)}async function tt(a,r,e,o,t,s={},i){g(i);const p=F.forScope(o,e.paths.globalConfigDir,"project"),w=F.forScope(o,e.paths.globalConfigDir,"user"),l=a[0]??"list";if(l==="list"){const c=await e.projectTrust.inspect(o),h=await e.projectTrust.isTrusted(c),f=await new x(e.paths.globalConfigDir).resolve(o,h),m=ie([{scope:"user",config:await w.list()},{scope:"project",config:await p.list()},...h&&Object.keys(f.mcpConfig).length>0?[{scope:"plugin",config:f.mcpConfig,sourceNames:Object.fromEntries(f.mcpContributions.map(b=>[b.qualifiedName,b.sourceName])),pluginNames:Object.fromEntries(f.mcpContributions.map(b=>[b.qualifiedName,b.pluginName]))}]:[]]);return E(t,m,v(m)),0}if(l==="reload"||l==="doctor"){g(i),l==="reload"&&await e.mcpRuntime.invalidate(o);const c=new Q(()=>new oe([w,p]));try{const h=await e.projectTrust.inspect(o),f=await c.connectConfigured(o,await e.projectTrust.isTrusted(h));return g(i),t.write(`${R(f.map(({serverId:m,status:b,protocolEra:T,protocolVersion:N,error:M})=>({name:m,status:b==="connected"?"OK":b.toUpperCase(),detail:M===void 0?[T,N].filter(Boolean).join(" \xB7 "):K(M.message)})),{empty:"No MCP servers configured."})}
19
+ `),f.some(m=>m.status==="failed")?1:0}finally{await c.close()}}const n=S(a,1,"MCP server name"),d=await U(r,s,"MCP server scope",!0);if(d===void 0)throw new Error("MCP server scope was not selected.");const u={store:d==="project"?p:w,scope:d},y=u.store;if(l==="get"){const c=await y.get(n);return t.write(`${de(n,u.scope,c)}
20
+ `),0}if(l==="remove"){g(i),await k(e,o,u.scope);const c=await y.remove(n);return c&&await e.mcpRuntime.invalidate(o),e.logger.info("MCP server removal completed.",{name:n,scope:u.scope,removed:c}),t.write(`${c?`Removed MCP server: ${n}`:`MCP server not found: ${n}`}
21
+ `),c?0:1}if(l==="enable"||l==="disable")return g(i),await k(e,o,u.scope),await y.setEnabled(n,l==="enable"),await e.mcpRuntime.invalidate(o),e.logger.info("MCP server state changed.",{name:n,scope:u.scope,enabled:l==="enable"}),t.write(`${l==="enable"?"Enabled":"Disabled"} MCP server: ${n}
22
+ `),0;if(l==="add"){g(i),await k(e,o,d??"project");const c=String($(r,"type")??"stdio");if(c==="stdio"){const h=_(r,"command"),f=$(r,"args");await y.add(n,{type:"stdio",command:h,...typeof f=="string"?{args:f.split(",").map(m=>m.trim()).filter(Boolean)}:{}})}else if(c==="http"||c==="sse")await y.add(n,{type:c,url:_(r,"url")});else throw new P(C.INVALID_ARGUMENT,`Unsupported MCP type: ${c}`,{category:"arguments",userMessage:"MCP type must be stdio, http, or sse."});return g(i),await e.mcpRuntime.invalidate(o),e.logger.info("MCP server added.",{name:n,scope:d??"project",type:c}),t.write(`Added MCP server successfully: ${n}
23
+ `),0}throw new Error(`Unsupported MCP action: ${l}`)}async function ot(a,r,e,o,t,s={},i){g(i);const p=new G(e.paths.pluginsDir),w=new G(j.join(j.resolve(o),".lotagate","plugins")),l=a[0]??"list";if(l==="list"){const f=ae([{scope:"user",plugins:await p.list(void 0,{verifyIntegrity:!1})},{scope:"project",plugins:await w.list(void 0,{verifyIntegrity:!1})}]);return E(t,f,v(f)),0}if(l==="install"){const f=S(a,1,"plugin or skill source"),m=await U(r,s,"Plugin installation scope",!0);if(m===void 0)throw new Error("Plugin installation scope was not selected.");await k(e,o,m);const b=$(r,"sha256"),T=$(r,"signature"),N=$(r,"public-key"),M=m==="project"?w:p,q=m==="project"?j.join(j.resolve(o),".lotagate","skills"):e.paths.skillsDir,O=await ee(f,e.platform,i);try{g(i);const A={...typeof b=="string"?{sha256:b}:{},...typeof T=="string"?{signature:T}:{},...typeof N=="string"?{publicKeyPem:N}:{}},L=await new Z().install(O.directory,q,A);if(L!==void 0)return g(i),e.logger.info("Skill installed.",{name:L.manifest.name,scope:m}),t.write(`Added skill successfully: ${L.manifest.name}
24
+ `),0;const I=await M.install(O.directory,A);return g(i),e.logger.info("Plugin installed.",{name:I.manifest.name,scope:m}),t.write(`Added plugin successfully: ${I.manifest.name}
25
+ `),0}finally{await O.cleanup()}}const n=S(a,1,"plugin name"),d=await U(r,s,"Plugin scope",!0);if(d===void 0)throw new Error("Plugin scope was not selected.");const u={manager:d==="project"?w:p,scope:d},y=u.manager,h=(await y.list(void 0,{verifyIntegrity:!1})).find(f=>f.manifest.name===n);if(h===void 0)throw new P(C.PLUGIN_NOT_FOUND,`Plugin not found: ${n}`,{category:"extension",userMessage:`Plugin not found: ${n}.`});if(l==="info"){const f=await ge(h,d);return t.writeStructured===void 0?t.write(`${JSON.stringify(f,null,2)}
26
26
  `):t.writeStructured(f,`${JSON.stringify(f,null,2)}
27
- `),0}if(i==="enable"||i==="disable")return w(n),await k(e,o,u.scope),await y.setEnabled(a,i==="enable"),e.logger.info("Plugin state changed.",{name:a,scope:u.scope,enabled:i==="enable"}),t.write(`${i==="enable"?"Enabled":"Disabled"} plugin: ${a}
28
- `),0;if(i==="uninstall"){w(n),await k(e,o,u.scope);const f=await y.uninstall(a);return e.logger.info("Plugin uninstallation completed.",{name:a,scope:u.scope,removed:f}),t.write(`${f?`Uninstalled plugin: ${a}`:`Plugin not found: ${a}`}
29
- `),f?0:1}throw new Error(`Unsupported plugin action: ${i}`)}async function U(s,r,e,o){const t=ne($(s,"scope"));if(t!==void 0)return t;const l=r.selectScope===void 0?void 0:await r.selectScope(e);return l!==void 0?l:o?re(void 0):void 0}async function k(s,r,e){if(e!=="project")return;const o=await s.projectTrust.inspect(r);if(!await s.projectTrust.isTrusted(o))throw new P(C.PROJECT_TRUST_REQUIRED,"Project scope requires trust.",{category:"project",userMessage:"Trust the project before writing project-scoped extensions."})}async function nt(s,r,e,o,t,l={},n){w(n);const p=await e.projectTrust.inspect(o),g=await new x(e.paths.globalConfigDir).resolve(o,await e.projectTrust.isTrusted(p)),i=te(o,e.paths.globalConfigDir,g.skillRoots),a=new X(j.join(e.paths.globalConfigDir,"skills-state.json")),d=s[0]??"list";if(d==="list"){const f=se(await a.listScoped(i,{includeShadowed:!0}));return E(t,f,v(f)),0}const u=S(s,1,"skill name"),y=await U(r,l,"Skill scope",!0);if(y===void 0)throw new Error("Skill scope was not selected.");const c=(await a.listScoped(i,{includeShadowed:!0})).find(f=>f.skillKey===u&&f.scope===y);if(c===void 0)throw new P(C.SKILL_NOT_FOUND,`Skill not found: ${u}`,{category:"extension",userMessage:`Skill not found: ${u}.`});if(d==="remove"&&c.scope!=="user"&&c.scope!=="project")throw new P(C.INVALID_ARGUMENT,`Skill cannot be removed from the ${c.scope} scope: ${u}`,{category:"arguments",userMessage:"Only user- and project-scoped skills can be removed."});const h=c.scope==="project";if((d==="remove"||d==="enable"||d==="disable")&&await k(e,o,h?"project":"user"),d==="info")return t.write(`${JSON.stringify(he(c),null,2)}
30
- `),0;if(d==="enable"||d==="disable")return w(n),await a.setEnabled(c.skillKey,d==="enable",c.statePath),e.logger.info("Skill state changed.",{name:u,scope:c.scope,enabled:d==="enable"}),t.write(`${d==="enable"?"Enabled":"Disabled"} skill: ${u}
31
- `),0;if(d==="remove"){w(n);const f=await a.remove(c.skillKey,c.root,c.statePath);return e.logger.info("Skill removal completed.",{name:u,scope:c.scope,removed:f}),t.write(`${f?`Removed skill: ${u}`:`Skill not found: ${u}`}
27
+ `),0}if(l==="enable"||l==="disable")return g(i),await k(e,o,u.scope),await y.setEnabled(n,l==="enable"),e.logger.info("Plugin state changed.",{name:n,scope:u.scope,enabled:l==="enable"}),t.write(`${l==="enable"?"Enabled":"Disabled"} plugin: ${n}
28
+ `),0;if(l==="uninstall"){g(i),await k(e,o,u.scope);const f=await y.uninstall(n);return e.logger.info("Plugin uninstallation completed.",{name:n,scope:u.scope,removed:f}),t.write(`${f?`Uninstalled plugin: ${n}`:`Plugin not found: ${n}`}
29
+ `),f?0:1}throw new Error(`Unsupported plugin action: ${l}`)}async function U(a,r,e,o){const t=ne($(a,"scope"));if(t!==void 0)return t;const s=r.selectScope===void 0?void 0:await r.selectScope(e);return s!==void 0?s:o?re(void 0):void 0}async function k(a,r,e){if(e!=="project")return;const o=await a.projectTrust.inspect(r);if(!await a.projectTrust.isTrusted(o))throw new P(C.PROJECT_TRUST_REQUIRED,"Project scope requires trust.",{category:"project",userMessage:"Trust the project before writing project-scoped extensions."})}async function nt(a,r,e,o,t,s={},i){g(i);const p=await e.projectTrust.inspect(o),w=await new x(e.paths.globalConfigDir).resolve(o,await e.projectTrust.isTrusted(p)),l=te(o,e.paths.globalConfigDir,w.skillRoots),n=new X(j.join(e.paths.globalConfigDir,"skills-state.json")),d=a[0]??"list";if(d==="list"){const f=se(await n.listScoped(l,{includeShadowed:!0}));return E(t,f,v(f)),0}const u=S(a,1,"skill name"),y=await U(r,s,"Skill scope",!0);if(y===void 0)throw new Error("Skill scope was not selected.");const c=(await n.listScoped(l,{includeShadowed:!0})).find(f=>f.skillKey===u&&f.scope===y);if(c===void 0)throw new P(C.SKILL_NOT_FOUND,`Skill not found: ${u}`,{category:"extension",userMessage:`Skill not found: ${u}.`});if(d==="remove"&&c.scope!=="user"&&c.scope!=="project")throw new P(C.INVALID_ARGUMENT,`Skill cannot be removed from the ${c.scope} scope: ${u}`,{category:"arguments",userMessage:"Only user- and project-scoped skills can be removed."});const h=c.scope==="project";if((d==="remove"||d==="enable"||d==="disable")&&await k(e,o,h?"project":"user"),d==="info")return t.write(`${JSON.stringify(he(c),null,2)}
30
+ `),0;if(d==="enable"||d==="disable")return g(i),await n.setEnabled(c.skillKey,d==="enable",c.statePath),e.logger.info("Skill state changed.",{name:u,scope:c.scope,enabled:d==="enable"}),t.write(`${d==="enable"?"Enabled":"Disabled"} skill: ${u}
31
+ `),0;if(d==="remove"){g(i);const f=await n.remove(c.skillKey,c.root,c.statePath);return e.logger.info("Skill removal completed.",{name:u,scope:c.scope,removed:f}),t.write(`${f?`Removed skill: ${u}`:`Skill not found: ${u}`}
32
32
  `),f?0:1}if(d==="run"){if(!c.enabled)throw new P(C.SKILL_NOT_FOUND,`Skill is disabled: ${u}`,{category:"extension",userMessage:`Skill is disabled: ${u}.`});return t.write(`${c.body}
33
- `),0}throw new Error(`Unsupported skill action: ${d}`)}async function rt(s,r,e,o){const t=s[0]??"list";if(t!=="list")throw new Error(`Unsupported hook action: ${t}`);const l=await r.projectTrust.inspect(e);if(!await r.projectTrust.isTrusted(l)){const a=J([]);return E(o,a,v(a)),0}const n=new le(new ce({platform:r.platform}),{trustedProject:!0,enabled:!0,toolPolicy:new fe}),p=await new x(r.paths.globalConfigDir).resolve(e,!0),g=[...await n.loadProject(l.canonicalPath)];for(const a of p.plugins)g.push(...await n.load(a));const i=J(g);return E(o,i,v(i)),0}function ye(s){return s==="true"?!0:s==="false"?!1:s==="null"?null:s}function he(s){const{root:r,statePath:e,...o}=s;return o}export{Qe as runAuthCommand,ze as runConfigCommand,et as runEffortCommand,rt as runHookCommand,tt as runMcpCommand,Ze as runModelCommand,ot as runPluginCommand,nt as runSkillCommand,Xe as runTrustCommand};
33
+ `),0}throw new Error(`Unsupported skill action: ${d}`)}async function rt(a,r,e,o){const t=a[0]??"list";if(t!=="list")throw new Error(`Unsupported hook action: ${t}`);const s=await r.projectTrust.inspect(e);if(!await r.projectTrust.isTrusted(s)){const n=J([]);return E(o,n,v(n)),0}const i=new le(new ce({platform:r.platform}),{trustedProject:!0,enabled:!0,toolPolicy:new fe}),p=await new x(r.paths.globalConfigDir).resolve(e,!0),w=[...await i.loadProject(s.canonicalPath)];for(const n of p.plugins)w.push(...await i.load(n));const l=J(w);return E(o,l,v(l)),0}function ye(a){return a==="true"?!0:a==="false"?!1:a==="null"?null:a}function he(a){const{root:r,statePath:e,...o}=a;return o}export{Qe as runAuthCommand,ze as runConfigCommand,et as runEffortCommand,rt as runHookCommand,tt as runMcpCommand,Ze as runModelCommand,ot as runPluginCommand,nt as runSkillCommand,Xe as runTrustCommand};
@@ -1 +1 @@
1
- const e=["direct","tui"],r=["direct"],a=["tui"],s={name:"scope",valueName:"<user|project>",description:"Extension scope",allowedValues:["user","project"],requiredOn:r},u=[{name:"token-budget",valueName:"<n>",description:"Maximum token budget"},{name:"max-turns",valueName:"<n>",description:"Maximum goal turns"},{name:"max-duration-ms",valueName:"<n>",description:"Maximum goal duration"}],o={name:"model",valueName:"<model-id>",description:"Use this model for this request only"},i=[{name:"out",valueName:"<filename>",description:"Output filename without extension"},{name:"out-dir",valueName:"<directory>",description:"Local output directory, inside or outside the workspace"},{name:"force",description:"Allow --out to replace an existing generated file"}],n=[o,{name:"n",valueName:"<count>",description:"Number of images"},{name:"size",valueName:"<size>",description:"Requested image size"},{name:"quality",valueName:"<low|medium|high|auto>",description:"Image quality",allowedValues:["low","medium","high","auto"]},{name:"background",valueName:"<transparent|opaque|auto>",description:"Image background",allowedValues:["transparent","opaque","auto"]},{name:"output-format",valueName:"<png|jpeg|webp>",description:"Image output format",allowedValues:["png","jpeg","webp"]},{name:"output-compression",valueName:"<0-100>",description:"Image output compression"},{name:"moderation",valueName:"<mode>",description:"Image moderation mode"},{name:"user",valueName:"<id>",description:"End-user identifier"},...i],m={name:"kind",valueName:"<kind>",description:"Memory kind"};function d(t){return t}const c=[{id:"help",path:["help"],surfaces:e,summary:"Show available commands",executor:"help"},{id:"version",path:["version"],surfaces:e,summary:"Show the CLI version",executor:"version"},{id:"config.get.default",path:["config"],handlerPath:["get"],surfaces:e,summary:"Read effective configuration",arguments:[{name:"key",required:!1}],executor:"config",defaultAction:!0,hiddenFromHelp:!0},{id:"config.get",path:["config","get"],handlerPath:["get"],surfaces:e,summary:"Read effective configuration",arguments:[{name:"key",required:!1}],executor:"config"},{id:"config.set",path:["config","set"],handlerPath:["set"],surfaces:e,summary:"Update global configuration",arguments:[{name:"key",required:!0},{name:"value",required:!0}],executor:"config"},{id:"config.path",path:["config","path"],handlerPath:["path"],surfaces:e,summary:"Show configuration paths",executor:"config"},{id:"auth.status.default",path:["auth"],handlerPath:["status"],surfaces:e,summary:"Show authentication status",executor:"auth",defaultAction:!0,hiddenFromHelp:!0},{id:"auth.login.direct",path:["auth","login"],handlerPath:["login"],surfaces:r,summary:"Save an API-key profile",options:[{name:"profile",valueName:"<name>",description:"Profile name"},{name:"base-url",valueName:"<url>",description:"Provider base URL"}],executor:"auth",desktop:{exposed:!0}},{id:"auth.login.tui",path:["auth","login"],handlerPath:["login"],surfaces:a,summary:"Save an API-key profile",options:[{name:"profile",valueName:"<name>",description:"Profile name"},{name:"base-url",valueName:"<url>",description:"Provider base URL"}],executor:"tui-auth-login"},{id:"auth.logout",path:["auth","logout"],handlerPath:["logout"],surfaces:e,summary:"Remove an API-key profile",arguments:[{name:"profile",required:!1}],executor:"auth"},{id:"auth.list",path:["auth","list"],handlerPath:["list"],surfaces:e,summary:"List authentication profiles",executor:"auth"},{id:"auth.status",path:["auth","status"],handlerPath:["status"],surfaces:e,summary:"Show authentication status",executor:"auth"},{id:"auth.use",path:["auth","use"],handlerPath:["use"],surfaces:e,summary:"Select an authentication profile",arguments:[{name:"profile",required:!0}],executor:"auth"},{id:"model.current.direct",path:["model"],handlerPath:["current"],surfaces:r,summary:"Show the selected model",executor:"model",defaultAction:!0,hiddenFromHelp:!0},{id:"model.select.tui",path:["model"],surfaces:a,summary:"Select a model",executor:"tui-model-select",defaultAction:!0,hiddenFromHelp:!0},{id:"model.current",path:["model","current"],handlerPath:["current"],surfaces:e,summary:"Show the selected model",executor:"model"},{id:"model.use",path:["model","use"],handlerPath:["use"],surfaces:e,summary:"Select a model",arguments:[{name:"model",required:!0}],executor:"model"},{id:"model.list",path:["model","list"],handlerPath:["list"],surfaces:e,summary:"Fetch the model catalog",executor:"model"},{id:"model.refresh",path:["model","refresh"],handlerPath:["refresh"],surfaces:e,summary:"Refresh the model catalog",executor:"model"},{id:"model.doctor",path:["model","doctor"],handlerPath:["doctor"],surfaces:e,summary:"Inspect model configuration",executor:"model"},{id:"effort.current.direct",path:["effort"],handlerPath:["current"],surfaces:r,summary:"Show the selected reasoning effort",executor:"effort",defaultAction:!0,hiddenFromHelp:!0},{id:"effort.select.tui",path:["effort"],surfaces:a,summary:"Select a reasoning effort",executor:"tui-effort-select",defaultAction:!0,hiddenFromHelp:!0},{id:"effort.current",path:["effort","current"],handlerPath:["current"],surfaces:e,summary:"Show the selected reasoning effort",executor:"effort"},{id:"effort.use",path:["effort","use"],handlerPath:["use"],surfaces:e,summary:"Select a reasoning effort",arguments:[{name:"effort",required:!0}],executor:"effort"},{id:"trust.status.default",path:["trust"],handlerPath:["status"],surfaces:e,summary:"Show current project trust",executor:"trust",defaultAction:!0,hiddenFromHelp:!0},{id:"trust.status",path:["trust","status"],handlerPath:["status"],surfaces:e,summary:"Show current project trust",executor:"trust"},{id:"trust.list",path:["trust","list"],handlerPath:["list"],surfaces:e,summary:"List trusted projects",executor:"trust"},{id:"trust.grant",path:["trust","grant"],handlerPath:["grant"],surfaces:e,summary:"Trust the current project",executor:"trust"},{id:"trust.revoke",path:["trust","revoke"],handlerPath:["revoke"],surfaces:e,summary:"Revoke current project trust",executor:"trust"},{id:"inspect",path:["inspect"],surfaces:e,summary:"Inspect current project identity",executor:"inspect"},{id:"hook.list.default",path:["hook"],handlerPath:["list"],surfaces:e,summary:"List project and plugin hooks",executor:"hook",defaultAction:!0,hiddenFromHelp:!0},{id:"hook.list",path:["hook","list"],handlerPath:["list"],surfaces:e,summary:"List project and plugin hooks",executor:"hook"},{id:"mcp.list.default",path:["mcp"],surfaces:e,summary:"List configured MCP servers",executor:"mcp",defaultAction:!0,hiddenFromHelp:!0},{id:"mcp.list",path:["mcp","list"],handlerPath:["list"],surfaces:e,summary:"List configured MCP servers",executor:"mcp"},{id:"mcp.get",path:["mcp","get"],handlerPath:["get"],surfaces:e,summary:"Inspect an MCP server",arguments:[{name:"name",required:!0}],options:[s],executor:"mcp"},{id:"mcp.add",path:["mcp","add"],handlerPath:["add"],surfaces:e,summary:"Add an MCP server",arguments:[{name:"name",required:!0}],options:[{name:"type",valueName:"<stdio|http|sse>",description:"MCP transport type (defaults to stdio)",allowedValues:["stdio","http","sse"]},{name:"command",valueName:"<command>",description:"stdio command",requiredWhen:{option:"type",values:["stdio"],absent:!0}},{name:"url",valueName:"<url>",description:"HTTP or SSE URL",requiredWhen:{option:"type",values:["http","sse"]}},{name:"args",valueName:"<a,b>",description:"Comma-separated stdio arguments"},s],executor:"mcp",desktop:{mutationKey:"mcp"}},{id:"mcp.reload",path:["mcp","reload"],handlerPath:["reload"],surfaces:e,summary:"Reconnect configured MCP servers",executor:"mcp",desktop:{mutationKey:"mcp"}},{id:"mcp.doctor",path:["mcp","doctor"],handlerPath:["doctor"],surfaces:e,summary:"Validate MCP servers",executor:"mcp"},...["enable","disable","remove"].map(t=>({id:`mcp.${t}`,path:["mcp",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} an MCP server`,arguments:[{name:"name",required:!0}],options:[s],executor:"mcp",desktop:{mutationKey:"mcp"}})),{id:"plugin.list.default",path:["plugin"],surfaces:e,summary:"List installed plugins",executor:"plugin",defaultAction:!0,hiddenFromHelp:!0},{id:"plugin.list",path:["plugin","list"],handlerPath:["list"],surfaces:e,summary:"List installed plugins",executor:"plugin"},{id:"plugin.info",path:["plugin","info"],handlerPath:["info"],surfaces:e,summary:"Inspect a plugin and its contributions",executor:"plugin",arguments:[{name:"name",required:!0}],options:[s]},{id:"plugin.install",path:["plugin","install"],handlerPath:["install"],surfaces:e,summary:"Install a plugin or standalone skill",arguments:[{name:"source",required:!0}],options:[s,{name:"sha256",valueName:"<hex>",description:"Expected archive checksum"},{name:"signature",valueName:"<base64>",description:"Archive signature"},{name:"public-key",valueName:"<pem>",description:"Signature public key"}],executor:"plugin",desktop:{mutationKey:"extensions"}},...["enable","disable","uninstall"].map(t=>({id:`plugin.${t}`,path:["plugin",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} a plugin`,arguments:[{name:"name",required:!0}],options:[s],executor:"plugin",desktop:{mutationKey:"extensions"}})),{id:"skill.list.default",path:["skill"],surfaces:e,summary:"List available skills",executor:"skill",defaultAction:!0,hiddenFromHelp:!0},{id:"skill.list",path:["skill","list"],handlerPath:["list"],surfaces:e,summary:"List available skills",executor:"skill"},...["info","enable","disable","remove"].map(t=>({id:`skill.${t}`,path:["skill",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} a skill`,arguments:[{name:"name",required:!0}],options:[s],executor:"skill",...t==="info"?{}:{desktop:{mutationKey:"extensions"}}})),{id:"skill.run.direct",path:["skill","run"],handlerPath:["run"],surfaces:r,summary:"Print an enabled skill prompt",arguments:[{name:"name",required:!0}],options:[s],executor:"skill"},{id:"skill.run.tui",path:["skill","run"],surfaces:a,summary:"Run an enabled skill",arguments:[{name:"name",required:!0},{name:"arguments",required:!1,variadic:!0}],options:[s],executor:"tui-skill-run"},{id:"session.list.default",path:["session"],surfaces:e,summary:"List durable sessions",executor:"session",defaultAction:!0,hiddenFromHelp:!0},{id:"session.list",path:["session","list"],handlerPath:["list"],surfaces:e,summary:"List durable sessions",executor:"session"},{id:"session.show",path:["session","show"],handlerPath:["show"],surfaces:e,summary:"Show a session transcript",arguments:[{name:"id",required:!0}],executor:"session"},{id:"session.import",path:["session","import"],handlerPath:["import"],surfaces:e,summary:"Import a session bundle",options:[{name:"file",valueName:"<path>",description:"Session bundle path",required:!0}],executor:"session"},{id:"session.resume.direct",path:["session","resume"],handlerPath:["resume"],surfaces:r,summary:"Inspect or resume a session",arguments:[{name:"id",required:!0}],options:[{name:"interactive",description:"Open the session in the TUI"}],executor:"session"},{id:"session.resume.tui",path:["session","resume"],surfaces:a,summary:"Resume a session in this TUI",arguments:[{name:"id",required:!0}],executor:"tui-session-resume"},{id:"session.fork",path:["session","fork"],handlerPath:["fork"],surfaces:e,summary:"Fork a session",arguments:[{name:"id",required:!0}],executor:"session"},{id:"session.compact.direct",path:["session","compact"],handlerPath:["compact"],surfaces:r,summary:"Compact a session",arguments:[{name:"id",required:!0}],executor:"session"},{id:"session.compact.tui",path:["session","compact"],surfaces:a,summary:"Compact the active session",executor:"tui-session-compact"},{id:"session.export",path:["session","export"],handlerPath:["export"],surfaces:e,summary:"Export a session bundle",arguments:[{name:"id",required:!0}],options:[{name:"out",valueName:"<path>",description:"Output path"}],executor:"session"},...["recover","repair","delete"].map(t=>({id:`session.${t}`,path:["session",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} a session`,arguments:[{name:"id",required:!0}],executor:"session",...t==="delete"?{desktop:{mutationKey:"session"}}:{}})),{id:"session.rename",path:["session","rename"],surfaces:a,summary:"Rename the active session",arguments:[{name:"name",required:!0,variadic:!0}],executor:"tui-session-rename"},{id:"memory.list.default",path:["memory"],handlerPath:["list"],surfaces:e,summary:"List project memories",options:[m,{name:"state",valueName:"<active|superseded|expired>",description:"Memory lifecycle state",allowedValues:["active","superseded","expired"]}],executor:"memory",defaultAction:!0,hiddenFromHelp:!0},{id:"memory.list",path:["memory","list"],handlerPath:["list"],surfaces:e,summary:"List project memories",options:[m,{name:"state",valueName:"<active|superseded|expired>",description:"Memory lifecycle state",allowedValues:["active","superseded","expired"]}],executor:"memory"},{id:"memory.show",path:["memory","show"],handlerPath:["show"],surfaces:e,summary:"Show a project memory",arguments:[{name:"id",required:!0}],executor:"memory"},{id:"memory.forget",path:["memory","forget"],handlerPath:["forget"],surfaces:e,summary:"Forget a project memory",arguments:[{name:"id",required:!0}],executor:"memory"},{id:"memory.clear",path:["memory","clear"],handlerPath:["clear"],surfaces:e,summary:"Clear project memory",executor:"memory"},{id:"memory.export",path:["memory","export"],handlerPath:["export"],surfaces:e,summary:"Export project memory",options:[{name:"out",valueName:"<path>",description:"Output bundle path"}],executor:"memory"},{id:"memory.import",path:["memory","import"],handlerPath:["import"],surfaces:e,summary:"Validate or import a project memory bundle",options:[{name:"file",valueName:"<path>",description:"Memory bundle path",required:!0},{name:"apply",description:"Apply the validated import"}],executor:"memory"},{id:"goal.status.direct",path:["goal","status"],handlerPath:["status"],surfaces:r,summary:"Show a session goal",arguments:[{name:"id",required:!0}],options:[{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.set",path:["goal","set"],handlerPath:["set"],surfaces:r,summary:"Set a session goal",arguments:[{name:"id",required:!0},{name:"objective",required:!0,variadic:!0}],options:[...u,{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.pause.direct",path:["goal","pause"],handlerPath:["pause"],surfaces:r,summary:"Pause a session goal",arguments:[{name:"id",required:!0}],options:[{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.resume.direct",path:["goal","resume"],handlerPath:["resume"],surfaces:r,summary:"Resume a session goal",arguments:[{name:"id",required:!0}],options:[...u,{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.clear.direct",path:["goal","clear"],handlerPath:["clear"],surfaces:r,summary:"Clear a session goal",arguments:[{name:"id",required:!0}],executor:"goal"},{id:"goal.run",path:["goal","run"],handlerPath:["run"],surfaces:r,summary:"Run a durable multi-turn goal",arguments:[{name:"objective",required:!0,variadic:!0}],options:u,executor:"goal"},...["status","pause","resume","clear"].map(t=>({id:`goal.${t}.tui`,path:["goal",t],surfaces:a,summary:`${t[0].toUpperCase()}${t.slice(1)} the active goal`,executor:"tui-goal"})),{id:"goal.start.tui",path:["goal"],surfaces:a,summary:"Start a goal for the active session",arguments:[{name:"objective",required:!0,variadic:!0}],options:u,executor:"tui-goal",defaultAction:!0,hiddenFromHelp:!0},{id:"doctor",path:["doctor"],surfaces:e,summary:"Run local diagnostics",executor:"doctor"},{id:"chat.direct",path:["chat"],surfaces:r,summary:"Stream a chat completion",arguments:[{name:"prompt",required:!1,variadic:!0}],executor:"chat"},{id:"chat.tui",path:["chat"],surfaces:a,summary:"Send an interactive chat prompt",arguments:[{name:"prompt",required:!0,variadic:!0}],executor:"tui-prompt"},{id:"image.generate",path:["image"],surfaces:e,summary:"Generate image artifacts",arguments:[{name:"prompt",required:!0,variadic:!0}],options:n,executor:"media"},{id:"image.edit",path:["image","edit"],handlerPath:["edit"],surfaces:e,summary:"Edit image artifacts",arguments:[{name:"prompt",required:!0,variadic:!0}],options:[...n,{name:"image",valueName:"<path[,path]>",description:"Source local image files",required:!0},{name:"mask",valueName:"<path>",description:"Optional local mask image"},{name:"input-fidelity",valueName:"<low|high>",description:"Input image fidelity",allowedValues:["low","high"]}],executor:"media"},{id:"audio.speech",path:["audio","speech"],handlerPath:["speech"],surfaces:e,summary:"Generate speech audio",arguments:[{name:"input",required:!0,variadic:!0}],options:[o,{name:"voice",valueName:"<voice>",description:"Voice identifier",required:!0},{name:"instructions",valueName:"<text>",description:"Voice instructions"},{name:"response-format",valueName:"<mp3|opus|aac|flac|wav|pcm>",description:"Audio output format",allowedValues:["mp3","opus","aac","flac","wav","pcm"]},{name:"speed",valueName:"<number>",description:"Speech speed"},...i],executor:"media"},{id:"audio.transcribe",path:["audio","transcribe"],handlerPath:["transcribe"],surfaces:e,summary:"Transcribe an audio file",options:[o,{name:"file",valueName:"<path>",description:"Local audio file",required:!0},{name:"language",valueName:"<code>",description:"Input language code"},{name:"prompt",valueName:"<text>",description:"Transcript prompt"},{name:"response-format",valueName:"<json|text|srt|verbose_json|vtt|diarized_json>",description:"Transcript format",allowedValues:["json","text","srt","verbose_json","vtt","diarized_json"]},{name:"temperature",valueName:"<number>",description:"Sampling temperature"},{name:"timestamp-granularities",valueName:"<word,segment>",description:"Timestamp granularities"},{name:"include",valueName:"<value[,value]>",description:"Provider response fields"},...i],executor:"media"},{id:"audio.translate",path:["audio","translate"],handlerPath:["translate"],surfaces:e,summary:"Translate an audio file",options:[o,{name:"file",valueName:"<path>",description:"Local audio file",required:!0},{name:"prompt",valueName:"<text>",description:"Translation prompt"},{name:"response-format",valueName:"<json|text|srt|verbose_json|vtt>",description:"Translation format",allowedValues:["json","text","srt","verbose_json","vtt"]},{name:"temperature",valueName:"<number>",description:"Sampling temperature"},...i],executor:"media"},{id:"video.generate",path:["video"],surfaces:e,summary:"Create and retrieve a video artifact",arguments:[{name:"prompt",required:!0,variadic:!0}],options:[o,{name:"parameters",valueName:"<json>",description:"Provider video parameter object"},{name:"no-wait",description:"Return the operation id without waiting"},...i],executor:"media"},{id:"video.status",path:["video","status"],handlerPath:["status"],surfaces:e,summary:"Show a video operation status",arguments:[{name:"operation-id",required:!0}],executor:"media"},{id:"video.download",path:["video","download"],handlerPath:["download"],surfaces:e,summary:"Download a completed video artifact",arguments:[{name:"operation-id",required:!0}],options:i,executor:"media"},{id:"exec.direct",path:["exec"],surfaces:r,summary:"Run a headless agent prompt",arguments:[{name:"prompt",required:!0,variadic:!0}],options:[{name:"image",valueName:"<path[,path]>",description:"Image attachments"},{name:"json",description:"Use JSON events"},{name:"jsonl",description:"Use JSONL events"}],executor:"exec",desktop:{exposed:!1}},{id:"exec.tui",path:["exec"],surfaces:a,summary:"Run an interactive agent prompt",arguments:[{name:"prompt",required:!0,variadic:!0}],executor:"tui-prompt"},{id:"agent.stdio",path:["agent","stdio"],handlerPath:["stdio"],surfaces:r,summary:"Run the JSONL agent protocol",executor:"agent",desktop:{exposed:!1}},{id:"agent.desktop",path:["agent","desktop"],handlerPath:["desktop"],surfaces:r,summary:"Run the desktop application protocol",executor:"agent",desktop:{exposed:!1}},{id:"agent.info",path:["agent"],surfaces:a,summary:"Explain the direct JSONL agent protocol",executor:"tui-agent-info"},...["bash","zsh","powershell"].map(t=>({id:`completions.${t}`,path:["completions",t],handlerPath:[t],surfaces:e,summary:`Print ${t} completion definitions`,executor:"completions",desktop:{exposed:!1}})),{id:"completions.default",path:["completions"],surfaces:e,summary:"Print PowerShell completion definitions",executor:"completions",defaultAction:!0,hiddenFromHelp:!0,desktop:{exposed:!1}},{id:"update.check.default",path:["update"],handlerPath:["check"],surfaces:e,summary:"Check update policy",executor:"update",defaultAction:!0,hiddenFromHelp:!0},{id:"update.check",path:["update","check"],handlerPath:["check"],surfaces:e,summary:"Check update policy",executor:"update"},{id:"tui.clear",path:["clear"],surfaces:a,summary:"Clear the current transcript view",executor:"tui-clear"},{id:"tui.stop",path:["stop"],surfaces:a,summary:"Stop the active response",executor:"tui-stop"},{id:"tui.context",path:["context"],surfaces:a,summary:"Show context usage and session composition",executor:"tui-context"},{id:"tui.details",path:["details"],surfaces:a,summary:"Toggle tool execution details",executor:"tui-details"},{id:"tui.exit",path:["exit"],surfaces:a,summary:"Exit the interactive session",executor:"tui-exit"},{id:"attachments.list.default",path:["attachments"],surfaces:a,summary:"List pending attachments",executor:"tui-attachments",defaultAction:!0,hiddenFromHelp:!0},{id:"attachments.list",path:["attachments","list"],surfaces:a,summary:"List pending attachments",executor:"tui-attachments"},{id:"attachments.paste",path:["attachments","paste"],surfaces:a,summary:"Add an image from the clipboard",executor:"tui-attachments"},{id:"attachments.remove",path:["attachments","remove"],surfaces:a,summary:"Remove a pending attachment",arguments:[{name:"id",required:!0}],executor:"tui-attachments"}];export{c as COMMAND_ACTIONS};
1
+ const e=["direct","tui"],r=["direct"],a=["tui"],s={name:"scope",valueName:"<user|project>",description:"Extension scope",allowedValues:["user","project"],requiredOn:r},u=[{name:"token-budget",valueName:"<n>",description:"Maximum token budget"},{name:"max-turns",valueName:"<n>",description:"Maximum goal turns"},{name:"max-duration-ms",valueName:"<n>",description:"Maximum goal duration"}],o={name:"model",valueName:"<model-id>",description:"Use this model for this request only"},i=[{name:"out",valueName:"<filename>",description:"Output filename without extension"},{name:"out-dir",valueName:"<directory>",description:"Local output directory, inside or outside the workspace"},{name:"force",description:"Allow --out to replace an existing generated file"}],n=[o,{name:"n",valueName:"<count>",description:"Number of images"},{name:"size",valueName:"<size>",description:"Requested image size"},{name:"quality",valueName:"<low|medium|high|auto>",description:"Image quality",allowedValues:["low","medium","high","auto"]},{name:"background",valueName:"<transparent|opaque|auto>",description:"Image background",allowedValues:["transparent","opaque","auto"]},{name:"output-format",valueName:"<png|jpeg|webp>",description:"Image output format",allowedValues:["png","jpeg","webp"]},{name:"output-compression",valueName:"<0-100>",description:"Image output compression"},{name:"moderation",valueName:"<mode>",description:"Image moderation mode"},{name:"user",valueName:"<id>",description:"End-user identifier"},...i],m={name:"kind",valueName:"<kind>",description:"Memory kind"};function d(t){return t}const c=[{id:"help",path:["help"],surfaces:e,summary:"Show available commands",executor:"help"},{id:"version",path:["version"],surfaces:e,summary:"Show the CLI version",executor:"version"},{id:"config.get.default",path:["config"],handlerPath:["get"],surfaces:e,summary:"Read effective configuration",arguments:[{name:"key",required:!1}],executor:"config",defaultAction:!0,hiddenFromHelp:!0},{id:"config.get",path:["config","get"],handlerPath:["get"],surfaces:e,summary:"Read effective configuration",arguments:[{name:"key",required:!1}],executor:"config"},{id:"config.set",path:["config","set"],handlerPath:["set"],surfaces:e,summary:"Update global configuration",arguments:[{name:"key",required:!0},{name:"value",required:!0}],executor:"config"},{id:"config.path",path:["config","path"],handlerPath:["path"],surfaces:e,summary:"Show configuration paths",executor:"config"},{id:"auth.status.default",path:["auth"],handlerPath:["status"],surfaces:e,summary:"Show authentication status",executor:"auth",defaultAction:!0,hiddenFromHelp:!0},{id:"auth.login.direct",path:["auth","login"],handlerPath:["login"],surfaces:r,summary:"Save an API-key profile",options:[{name:"profile",valueName:"<name>",description:"Profile name"},{name:"base-url",valueName:"<url>",description:"Provider base URL"}],executor:"auth",desktop:{exposed:!0}},{id:"auth.login.tui",path:["auth","login"],handlerPath:["login"],surfaces:a,summary:"Save an API-key profile",options:[{name:"profile",valueName:"<name>",description:"Profile name"},{name:"base-url",valueName:"<url>",description:"Provider base URL"}],executor:"tui-auth-login"},{id:"auth.logout",path:["auth","logout"],handlerPath:["logout"],surfaces:e,summary:"Remove an API-key profile",arguments:[{name:"profile",required:!1}],executor:"auth"},{id:"auth.list",path:["auth","list"],handlerPath:["list"],surfaces:e,summary:"List authentication profiles",executor:"auth"},{id:"auth.status",path:["auth","status"],handlerPath:["status"],surfaces:e,summary:"Show authentication status",executor:"auth"},{id:"auth.use",path:["auth","use"],handlerPath:["use"],surfaces:e,summary:"Select an authentication profile",arguments:[{name:"profile",required:!0}],executor:"auth"},{id:"model.current.direct",path:["model"],handlerPath:["current"],surfaces:r,summary:"Show the selected model",executor:"model",defaultAction:!0,hiddenFromHelp:!0},{id:"model.select.tui",path:["model"],surfaces:a,summary:"Select a model",executor:"tui-model-select",defaultAction:!0,hiddenFromHelp:!0},{id:"model.current",path:["model","current"],handlerPath:["current"],surfaces:e,summary:"Show the selected model",executor:"model"},{id:"model.use",path:["model","use"],handlerPath:["use"],surfaces:e,summary:"Select a model",arguments:[{name:"model",required:!0}],executor:"model"},{id:"model.list",path:["model","list"],handlerPath:["list"],surfaces:e,summary:"Fetch the model catalog",executor:"model"},{id:"model.refresh",path:["model","refresh"],handlerPath:["refresh"],surfaces:e,summary:"Refresh the model catalog",executor:"model"},{id:"model.doctor",path:["model","doctor"],handlerPath:["doctor"],surfaces:e,summary:"Inspect model configuration",executor:"model"},{id:"effort.current.direct",path:["effort"],handlerPath:["current"],surfaces:r,summary:"Show the selected reasoning effort",executor:"effort",defaultAction:!0,hiddenFromHelp:!0},{id:"effort.select.tui",path:["effort"],surfaces:a,summary:"Select a reasoning effort",executor:"tui-effort-select",defaultAction:!0,hiddenFromHelp:!0},{id:"effort.current",path:["effort","current"],handlerPath:["current"],surfaces:e,summary:"Show the selected reasoning effort",executor:"effort"},{id:"effort.use",path:["effort","use"],handlerPath:["use"],surfaces:e,summary:"Select a reasoning effort",arguments:[{name:"effort",required:!0}],executor:"effort"},{id:"trust.status.default",path:["trust"],handlerPath:["status"],surfaces:e,summary:"Show current project trust",executor:"trust",defaultAction:!0,hiddenFromHelp:!0},{id:"trust.status",path:["trust","status"],handlerPath:["status"],surfaces:e,summary:"Show current project trust",executor:"trust"},{id:"trust.list",path:["trust","list"],handlerPath:["list"],surfaces:e,summary:"List trusted projects",executor:"trust"},{id:"trust.grant",path:["trust","grant"],handlerPath:["grant"],surfaces:e,summary:"Trust the current project",executor:"trust"},{id:"trust.revoke",path:["trust","revoke"],handlerPath:["revoke"],surfaces:e,summary:"Revoke current project trust",executor:"trust"},{id:"inspect",path:["inspect"],surfaces:e,summary:"Inspect current project identity",executor:"inspect"},{id:"hook.list.default",path:["hook"],handlerPath:["list"],surfaces:e,summary:"List project and plugin hooks",executor:"hook",defaultAction:!0,hiddenFromHelp:!0},{id:"hook.list",path:["hook","list"],handlerPath:["list"],surfaces:e,summary:"List project and plugin hooks",executor:"hook"},{id:"mcp.list.default",path:["mcp"],surfaces:e,summary:"List configured MCP servers",executor:"mcp",defaultAction:!0,hiddenFromHelp:!0},{id:"mcp.list",path:["mcp","list"],handlerPath:["list"],surfaces:e,summary:"List configured MCP servers",executor:"mcp"},{id:"mcp.get",path:["mcp","get"],handlerPath:["get"],surfaces:e,summary:"Inspect an MCP server",arguments:[{name:"name",required:!0}],options:[s],executor:"mcp"},{id:"mcp.add",path:["mcp","add"],handlerPath:["add"],surfaces:e,summary:"Add an MCP server",arguments:[{name:"name",required:!0}],options:[{name:"type",valueName:"<stdio|http|sse>",description:"MCP transport type (defaults to stdio)",allowedValues:["stdio","http","sse"]},{name:"command",valueName:"<command>",description:"stdio command",requiredWhen:{option:"type",values:["stdio"],absent:!0}},{name:"url",valueName:"<url>",description:"HTTP or SSE URL",requiredWhen:{option:"type",values:["http","sse"]}},{name:"args",valueName:"<a,b>",description:"Comma-separated stdio arguments"},s],executor:"mcp",desktop:{mutationKey:"mcp"}},{id:"mcp.reload",path:["mcp","reload"],handlerPath:["reload"],surfaces:e,summary:"Reconnect configured MCP servers",executor:"mcp",desktop:{mutationKey:"mcp"}},{id:"mcp.doctor",path:["mcp","doctor"],handlerPath:["doctor"],surfaces:e,summary:"Validate MCP servers",executor:"mcp"},...["enable","disable","remove"].map(t=>({id:`mcp.${t}`,path:["mcp",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} an MCP server`,arguments:[{name:"name",required:!0}],options:[s],executor:"mcp",desktop:{mutationKey:"mcp"}})),{id:"plugin.list.default",path:["plugin"],surfaces:e,summary:"List installed plugins",executor:"plugin",defaultAction:!0,hiddenFromHelp:!0},{id:"plugin.list",path:["plugin","list"],handlerPath:["list"],surfaces:e,summary:"List installed plugins",executor:"plugin"},{id:"plugin.info",path:["plugin","info"],handlerPath:["info"],surfaces:e,summary:"Inspect a plugin and its contributions",executor:"plugin",arguments:[{name:"name",required:!0}],options:[s]},{id:"plugin.install",path:["plugin","install"],handlerPath:["install"],surfaces:e,summary:"Install a plugin or standalone skill",arguments:[{name:"source",required:!0}],options:[s,{name:"sha256",valueName:"<hex>",description:"Expected archive checksum"},{name:"signature",valueName:"<base64>",description:"Archive signature"},{name:"public-key",valueName:"<pem>",description:"Signature public key"}],executor:"plugin",desktop:{mutationKey:"extensions"}},...["enable","disable","uninstall"].map(t=>({id:`plugin.${t}`,path:["plugin",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} a plugin`,arguments:[{name:"name",required:!0}],options:[s],executor:"plugin",desktop:{mutationKey:"extensions"}})),{id:"skill.list.default",path:["skill"],surfaces:e,summary:"List available skills",executor:"skill",defaultAction:!0,hiddenFromHelp:!0},{id:"skill.list",path:["skill","list"],handlerPath:["list"],surfaces:e,summary:"List available skills",executor:"skill"},...["info","enable","disable","remove"].map(t=>({id:`skill.${t}`,path:["skill",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} a skill`,arguments:[{name:"name",required:!0}],options:[s],executor:"skill",...t==="info"?{}:{desktop:{mutationKey:"extensions"}}})),{id:"skill.run.direct",path:["skill","run"],handlerPath:["run"],surfaces:r,summary:"Print an enabled skill prompt",arguments:[{name:"name",required:!0}],options:[s],executor:"skill"},{id:"skill.run.tui",path:["skill","run"],surfaces:a,summary:"Run an enabled skill",arguments:[{name:"name",required:!0},{name:"arguments",required:!1,variadic:!0}],options:[s],executor:"tui-skill-run"},{id:"session.list.default",path:["session"],surfaces:e,summary:"List durable sessions",executor:"session",defaultAction:!0,hiddenFromHelp:!0},{id:"session.list",path:["session","list"],handlerPath:["list"],surfaces:e,summary:"List durable sessions",executor:"session"},{id:"session.show",path:["session","show"],handlerPath:["show"],surfaces:e,summary:"Show a session transcript",arguments:[{name:"id",required:!0}],executor:"session"},{id:"session.import",path:["session","import"],handlerPath:["import"],surfaces:e,summary:"Import a session bundle",options:[{name:"file",valueName:"<path>",description:"Session bundle path",required:!0}],executor:"session"},{id:"session.resume.direct",path:["session","resume"],handlerPath:["resume"],surfaces:r,summary:"Inspect or resume a session",arguments:[{name:"id",required:!0}],options:[{name:"interactive",description:"Open the session in the TUI"}],executor:"session"},{id:"session.resume.tui",path:["session","resume"],surfaces:a,summary:"Resume a session in this TUI",arguments:[{name:"id",required:!0}],executor:"tui-session-resume"},{id:"session.fork",path:["session","fork"],handlerPath:["fork"],surfaces:e,summary:"Fork a session",arguments:[{name:"id",required:!0}],executor:"session"},{id:"session.compact.direct",path:["session","compact"],handlerPath:["compact"],surfaces:r,summary:"Compact a session",arguments:[{name:"id",required:!0}],executor:"session"},{id:"session.compact.tui",path:["session","compact"],surfaces:a,summary:"Compact the active session",executor:"tui-session-compact"},{id:"session.export",path:["session","export"],handlerPath:["export"],surfaces:e,summary:"Export a session bundle",arguments:[{name:"id",required:!0}],options:[{name:"out",valueName:"<path>",description:"Output path"}],executor:"session"},...["recover","repair","delete"].map(t=>({id:`session.${t}`,path:["session",t],handlerPath:[t],surfaces:e,summary:`${t[0].toUpperCase()}${t.slice(1)} a session`,arguments:[{name:"id",required:!0}],executor:"session",...t==="delete"?{desktop:{mutationKey:"session"}}:{}})),{id:"session.rename",path:["session","rename"],surfaces:a,summary:"Rename the active session",arguments:[{name:"name",required:!0,variadic:!0}],executor:"tui-session-rename"},{id:"memory.list.default",path:["memory"],handlerPath:["list"],surfaces:e,summary:"List project memories",options:[m,{name:"state",valueName:"<active|superseded|expired>",description:"Memory lifecycle state",allowedValues:["active","superseded","expired"]}],executor:"memory",defaultAction:!0,hiddenFromHelp:!0},{id:"memory.list",path:["memory","list"],handlerPath:["list"],surfaces:e,summary:"List project memories",options:[m,{name:"state",valueName:"<active|superseded|expired>",description:"Memory lifecycle state",allowedValues:["active","superseded","expired"]}],executor:"memory"},{id:"memory.show",path:["memory","show"],handlerPath:["show"],surfaces:e,summary:"Show a project memory",arguments:[{name:"id",required:!0}],executor:"memory"},{id:"memory.forget",path:["memory","forget"],handlerPath:["forget"],surfaces:e,summary:"Forget a project memory",arguments:[{name:"id",required:!0}],executor:"memory"},{id:"memory.clear",path:["memory","clear"],handlerPath:["clear"],surfaces:e,summary:"Clear project memory",executor:"memory"},{id:"memory.export",path:["memory","export"],handlerPath:["export"],surfaces:e,summary:"Export project memory",options:[{name:"out",valueName:"<path>",description:"Output bundle path"}],executor:"memory"},{id:"memory.import",path:["memory","import"],handlerPath:["import"],surfaces:e,summary:"Validate or import a project memory bundle",options:[{name:"file",valueName:"<path>",description:"Memory bundle path",required:!0},{name:"apply",description:"Apply the validated import"}],executor:"memory"},{id:"goal.status.direct",path:["goal","status"],handlerPath:["status"],surfaces:r,summary:"Show a session goal",arguments:[{name:"id",required:!0}],options:[{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.set",path:["goal","set"],handlerPath:["set"],surfaces:r,summary:"Set a session goal",arguments:[{name:"id",required:!0},{name:"objective",required:!0,variadic:!0}],options:[...u,{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.pause.direct",path:["goal","pause"],handlerPath:["pause"],surfaces:r,summary:"Pause a session goal",arguments:[{name:"id",required:!0}],options:[{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.resume.direct",path:["goal","resume"],handlerPath:["resume"],surfaces:r,summary:"Resume a session goal",arguments:[{name:"id",required:!0}],options:[...u,{name:"json",description:"Use JSON output"}],executor:"goal"},{id:"goal.clear.direct",path:["goal","clear"],handlerPath:["clear"],surfaces:r,summary:"Clear a session goal",arguments:[{name:"id",required:!0}],executor:"goal"},{id:"goal.run",path:["goal","run"],handlerPath:["run"],surfaces:r,summary:"Run a durable multi-turn goal",arguments:[{name:"objective",required:!0,variadic:!0}],options:u,executor:"goal"},...["status","pause","resume","clear"].map(t=>({id:`goal.${t}.tui`,path:["goal",t],surfaces:a,summary:`${t[0].toUpperCase()}${t.slice(1)} the active goal`,executor:"tui-goal"})),{id:"goal.start.tui",path:["goal"],surfaces:a,summary:"Start a goal for the active session",arguments:[{name:"objective",required:!0,variadic:!0}],options:u,executor:"tui-goal",defaultAction:!0,hiddenFromHelp:!0},{id:"doctor",path:["doctor"],surfaces:e,summary:"Run local diagnostics",executor:"doctor"},{id:"chat.direct",path:["chat"],surfaces:r,summary:"Stream a chat completion",arguments:[{name:"prompt",required:!1,variadic:!0}],executor:"chat"},{id:"chat.tui",path:["chat"],surfaces:a,summary:"Send an interactive chat prompt",arguments:[{name:"prompt",required:!0,variadic:!0}],executor:"tui-prompt"},{id:"image.generate",path:["image"],surfaces:e,summary:"Generate image artifacts",arguments:[{name:"prompt",required:!0,variadic:!0}],options:n,executor:"media"},{id:"image.edit",path:["image","edit"],handlerPath:["edit"],surfaces:e,summary:"Edit image artifacts",arguments:[{name:"prompt",required:!0,variadic:!0}],options:[...n,{name:"image",valueName:"<path[,path]>",description:"Source local image files",required:!0},{name:"mask",valueName:"<path>",description:"Optional local mask image"},{name:"input-fidelity",valueName:"<low|high>",description:"Input image fidelity",allowedValues:["low","high"]}],executor:"media"},{id:"audio.speech",path:["audio","speech"],handlerPath:["speech"],surfaces:e,summary:"Generate speech audio",arguments:[{name:"input",required:!0,variadic:!0}],options:[o,{name:"voice",valueName:"<voice>",description:"Voice identifier",required:!0},{name:"instructions",valueName:"<text>",description:"Voice instructions"},{name:"response-format",valueName:"<mp3|opus|aac|flac|wav|pcm>",description:"Audio output format",allowedValues:["mp3","opus","aac","flac","wav","pcm"]},{name:"stream-format",valueName:"<audio|sse>",description:"Speech response transport format",allowedValues:["audio","sse"]},{name:"speed",valueName:"<number>",description:"Speech speed"},...i],executor:"media"},{id:"audio.transcribe",path:["audio","transcribe"],handlerPath:["transcribe"],surfaces:e,summary:"Transcribe an audio file",options:[o,{name:"file",valueName:"<path>",description:"Local audio file",required:!0},{name:"language",valueName:"<code>",description:"Input language code"},{name:"prompt",valueName:"<text>",description:"Transcript prompt"},{name:"response-format",valueName:"<json|text|srt|verbose_json|vtt|diarized_json>",description:"Transcript format",allowedValues:["json","text","srt","verbose_json","vtt","diarized_json"]},{name:"temperature",valueName:"<number>",description:"Sampling temperature"},{name:"timestamp-granularities",valueName:"<word,segment>",description:"Timestamp granularities"},{name:"include",valueName:"<value[,value]>",description:"Provider response fields"},...i],executor:"media"},{id:"audio.translate",path:["audio","translate"],handlerPath:["translate"],surfaces:e,summary:"Translate an audio file",options:[o,{name:"file",valueName:"<path>",description:"Local audio file",required:!0},{name:"prompt",valueName:"<text>",description:"Translation prompt"},{name:"response-format",valueName:"<json|text|srt|verbose_json|vtt>",description:"Translation format",allowedValues:["json","text","srt","verbose_json","vtt"]},{name:"temperature",valueName:"<number>",description:"Sampling temperature"},...i],executor:"media"},{id:"video.generate",path:["video"],surfaces:e,summary:"Create and retrieve a video artifact",arguments:[{name:"prompt",required:!0,variadic:!0}],options:[o,{name:"parameters",valueName:"<json>",description:"Provider video parameter object"},{name:"no-wait",description:"Return the operation id without waiting"},...i],executor:"media"},{id:"video.status",path:["video","status"],handlerPath:["status"],surfaces:e,summary:"Show a video operation status",arguments:[{name:"operation-id",required:!0}],executor:"media"},{id:"video.download",path:["video","download"],handlerPath:["download"],surfaces:e,summary:"Download a completed video artifact",arguments:[{name:"operation-id",required:!0}],options:i,executor:"media"},{id:"exec.direct",path:["exec"],surfaces:r,summary:"Run a headless agent prompt",arguments:[{name:"prompt",required:!0,variadic:!0}],options:[{name:"image",valueName:"<path[,path]>",description:"Image attachments"},{name:"json",description:"Use JSON events"},{name:"jsonl",description:"Use JSONL events"}],executor:"exec",desktop:{exposed:!1}},{id:"exec.tui",path:["exec"],surfaces:a,summary:"Run an interactive agent prompt",arguments:[{name:"prompt",required:!0,variadic:!0}],executor:"tui-prompt"},{id:"agent.stdio",path:["agent","stdio"],handlerPath:["stdio"],surfaces:r,summary:"Run the JSONL agent protocol",executor:"agent",desktop:{exposed:!1}},{id:"agent.desktop",path:["agent","desktop"],handlerPath:["desktop"],surfaces:r,summary:"Run the desktop application protocol",executor:"agent",desktop:{exposed:!1}},{id:"agent.info",path:["agent"],surfaces:a,summary:"Explain the direct JSONL agent protocol",executor:"tui-agent-info"},...["bash","zsh","powershell"].map(t=>({id:`completions.${t}`,path:["completions",t],handlerPath:[t],surfaces:e,summary:`Print ${t} completion definitions`,executor:"completions",desktop:{exposed:!1}})),{id:"completions.default",path:["completions"],surfaces:e,summary:"Print PowerShell completion definitions",executor:"completions",defaultAction:!0,hiddenFromHelp:!0,desktop:{exposed:!1}},{id:"update.check.default",path:["update"],handlerPath:["check"],surfaces:e,summary:"Check update policy",executor:"update",defaultAction:!0,hiddenFromHelp:!0},{id:"update.check",path:["update","check"],handlerPath:["check"],surfaces:e,summary:"Check update policy",executor:"update"},{id:"tui.clear",path:["clear"],surfaces:a,summary:"Clear the current transcript view",executor:"tui-clear"},{id:"tui.stop",path:["stop"],surfaces:a,summary:"Stop the active response",executor:"tui-stop"},{id:"tui.context",path:["context"],surfaces:a,summary:"Show context usage and session composition",executor:"tui-context"},{id:"tui.details",path:["details"],surfaces:a,summary:"Toggle tool execution details",executor:"tui-details"},{id:"tui.exit",path:["exit"],surfaces:a,summary:"Exit the interactive session",executor:"tui-exit"},{id:"attachments.list.default",path:["attachments"],surfaces:a,summary:"List pending attachments",executor:"tui-attachments",defaultAction:!0,hiddenFromHelp:!0},{id:"attachments.list",path:["attachments","list"],surfaces:a,summary:"List pending attachments",executor:"tui-attachments"},{id:"attachments.paste",path:["attachments","paste"],surfaces:a,summary:"Add an image from the clipboard",executor:"tui-attachments"},{id:"attachments.remove",path:["attachments","remove"],surfaces:a,summary:"Remove a pending attachment",arguments:[{name:"id",required:!0}],executor:"tui-attachments"}];export{c as COMMAND_ACTIONS};
@@ -1,7 +1,7 @@
1
- import{isFlagEnabled as E,requirePositional as _}from"./cli-args.js";import{ProjectSessionAccess as A}from"../session/project-session-access.js";import{AuthenticationService as D}from"../auth/authentication-service.js";import{loadExecutionConfig as L}from"../config/execution-config.js";import{createLotaGateClient as P}from"../../infrastructure/sdk/lotagate-client-factory.js";import{runHeadlessAgentTurn as x}from"../orchestration/headless-agent-turn.js";import{runGoalLoop as F}from"../orchestration/goal-runner.js";import{CliAgentSessionStore as q}from"../agent/agent-session-store.js";import{formatGoalStatus as $}from"../orchestration/goal-output.js";import{parseGoalInput as k}from"../orchestration/goal-input.js";import{CliError as p}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as g}from"../../domain/errors/error-codes.js";import{MODEL_SELECT_HINT as B,TRUST_GRANT_HINT as H}from"./command-hints.js";import{createTurnId as J,recordTurnCompletion as K,recordTurnFailure as Q,recordTurnStart as W}from"../session/session-turn-lifecycle.js";import{createCommandAbortController as z,throwIfCommandAborted as v}from"./command-cancellation.js";async function de(r,t,e,l,s,c){const i=r[0]??"status";if(i==="run")return O(r.slice(1).join(" ").trim(),t,e,l,s,void 0,c);v(c);const n=_(r,1,"session id"),d=await e.projectTrust.inspect(l);if(await new A(e.sessionStore).require(n,d.fingerprint),i==="status")return G(s,await e.goalStore.get(n),E(t,"json"));if(i==="set"){const u=_([r.slice(2).join(" ")],0,"goal objective"),w=await e.goalStore.replace(n,M(u,t));return G(s,w,E(t,"json"))}if(i==="pause"){const u=await e.goalStore.pause(n);return G(s,u,E(t,"json"))}if(i==="resume"){const u=await e.goalStore.get(n);if(u===void 0)throw new p(g.GOAL_NOT_FOUND,"Goal not found.",{category:"goal",userMessage:"Goal was not found."});return O(u.objective,t,e,l,s,n,c)}if(i==="clear")return await e.goalStore.clear(n),s.write(`Goal cleared.
2
- `),0;throw new Error(`Unsupported goal action: ${i}`)}async function O(r,t,e,l,s,c,i){if(v(i),r.length===0)throw new p(g.MISSING_ARGUMENT,"Missing goal objective.",{category:"arguments",userMessage:"A goal objective is required."});const n=await e.projectTrust.inspect(l);if(!await e.projectTrust.isTrusted(n))throw new p(g.PROJECT_TRUST_REQUIRED,"Project trust is required for goals.",{category:"project",userMessage:"Project is not trusted.",hint:H});const d=await L(e,l);if(d.config.model===null)throw new p(g.MODEL_NOT_FOUND,"No model is selected.",{category:"model",userMessage:"No model is selected.",hint:B});const u=d.config.model,w=d.config.profile??D.defaultProfileName(),y=await e.auth.requireCredential(w),a=c===void 0?await e.sessionStore.create({projectFingerprint:n.fingerprint,cwd:n.canonicalPath,model:d.config.model,profile:w,status:"active"}):await e.sessionStore.get(c);if(a===void 0)throw new p(g.SESSION_NOT_FOUND,"Goal session not found.",{category:"session",userMessage:"Goal session was not found."});c===void 0?await e.goalStore.create(a.id,M(r,t)):await e.goalStore.resume(a.id);const N=P(y.profile,y.apiKey),U=new q,h=z(i),T=h.controller,j=()=>T.abort(new Error("Goal interrupted by user."));process.once("SIGINT",j);try{const f=await F({runtime:e,sessionId:a.id,objective:r,model:u,client:N,signal:T.signal,runTurn:async(I,m,b)=>{const S=J();await W(e.sessionStore,a.id,S,I);try{const o=await e.goalStore.get(a.id),C=await x({runtime:e,cwd:l,model:u,client:N,prompt:I,output:s,sessionId:a.id,agentSessionStore:U,signal:b,turnId:S,...o===void 0?{}:{goal:{objective:o.objective,status:o.status,turns:o.turns,evaluatorRuns:o.evaluatorRuns,tokensUsed:o.usage.totalTokens,...o.tokenBudget===void 0?{}:{tokenBudget:o.tokenBudget},...o.maxTurns===void 0?{}:{maxTurns:o.maxTurns},...o.maxDurationMs===void 0?{}:{maxDurationMs:o.maxDurationMs},...o.lastError===void 0?{}:{lastError:o.lastError},...o.lastEvaluation===void 0?{}:{lastEvaluation:o.lastEvaluation.reason}}},onUsage:m.onUsage,onSubagentUsage:m.onUsage,onSnapshot:m.onSnapshot});return s.write(`
3
- `),await K(e.sessionStore,a.id,S,C),C}catch(o){throw m.onError(o),await Q(e.sessionStore,a.id,S,o,T.signal.aborted),o}}});await e.sessionStore.updateStatus(a.id,f?.status==="completed"?"completed":f?.status==="paused"?"active":"failed"),s.write(`Goal session: ${a.id}
4
- `);const R=f?.status==="paused"&&f.lastError?.startsWith("Goal paused by safety limit:")===!0;return f?.status==="completed"||R?0:1}finally{process.off("SIGINT",j),h.dispose()}}function M(r,t){return k(r,t)}function G(r,t,e){return e?(r.write(`${JSON.stringify(t??null)}
1
+ import{isFlagEnabled as G,requirePositional as O}from"./cli-args.js";import{ProjectSessionAccess as L}from"../session/project-session-access.js";import{AuthenticationService as P}from"../auth/authentication-service.js";import{loadExecutionConfig as x}from"../config/execution-config.js";import{createLotaGateClient as F}from"../../infrastructure/sdk/lotagate-client-factory.js";import{runHeadlessAgentTurn as q}from"../orchestration/headless-agent-turn.js";import{runGoalLoop as $}from"../orchestration/goal-runner.js";import{CliAgentSessionStore as B}from"../agent/agent-session-store.js";import{formatGoalStatus as H}from"../orchestration/goal-output.js";import{parseGoalInput as k}from"../orchestration/goal-input.js";import{CliError as p}from"../../domain/errors/cli-error.js";import{CLI_ERROR_CODES as g}from"../../domain/errors/error-codes.js";import{MODEL_SELECT_HINT as J,TRUST_GRANT_HINT as K}from"./command-hints.js";import{createTurnId as Q,recordTurnCompletion as W,recordTurnFailure as z,recordTurnStart as V}from"../session/session-turn-lifecycle.js";import{createCommandAbortController as X,throwIfCommandAborted as M}from"./command-cancellation.js";async function pe(r,t,e,d,i,c){const n=r[0]??"status";if(n==="run")return U(r.slice(1).join(" ").trim(),t,e,d,i,void 0,c);M(c);const u=O(r,1,"session id"),l=await e.projectTrust.inspect(d);if(await new L(e.sessionStore).require(u,l.fingerprint),n==="status")return N(i,await e.goalStore.get(u),G(t,"json"));if(n==="set"){const a=O([r.slice(2).join(" ")],0,"goal objective"),w=await e.goalStore.replace(u,b(a,t));return N(i,w,G(t,"json"))}if(n==="pause"){const a=await e.goalStore.pause(u);return N(i,a,G(t,"json"))}if(n==="resume"){const a=await e.goalStore.get(u);if(a===void 0)throw new p(g.GOAL_NOT_FOUND,"Goal not found.",{category:"goal",userMessage:"Goal was not found."});return U(a.objective,t,e,d,i,u,c)}if(n==="clear")return await e.goalStore.clear(u),i.write(`Goal cleared.
2
+ `),0;throw new Error(`Unsupported goal action: ${n}`)}async function U(r,t,e,d,i,c,n){if(M(n),r.length===0)throw new p(g.MISSING_ARGUMENT,"Missing goal objective.",{category:"arguments",userMessage:"A goal objective is required."});const u=b(r,t),l=await e.projectTrust.inspect(d);if(!await e.projectTrust.isTrusted(l))throw new p(g.PROJECT_TRUST_REQUIRED,"Project trust is required for goals.",{category:"project",userMessage:"Project is not trusted.",hint:K});const a=await x(e,d);if(a.config.model===null)throw new p(g.MODEL_NOT_FOUND,"No model is selected.",{category:"model",userMessage:"No model is selected.",hint:J});const w=a.config.model,E=a.config.profile??P.defaultProfileName(),y=await e.auth.requireCredential(E),s=c===void 0?await e.sessionStore.create({projectFingerprint:l.fingerprint,cwd:l.canonicalPath,model:a.config.model,profile:E,status:"active"}):await e.sessionStore.get(c);if(s===void 0)throw new p(g.SESSION_NOT_FOUND,"Goal session not found.",{category:"session",userMessage:"Goal session was not found."});c===void 0?await e.goalStore.create(s.id,u):await e.goalStore.resume(s.id);const I=F(y.profile,y.apiKey),R=new B,m=n===void 0?X():void 0,h=m?.controller,A=n??h.signal,j=()=>h?.abort(new Error("Goal interrupted by user."));m!==void 0&&process.once("SIGINT",j);try{const f=await $({runtime:e,sessionId:s.id,objective:r,model:w,client:I,signal:A,runTurn:async(C,S,_)=>{const T=Q();await V(e.sessionStore,s.id,T,C);try{const o=await e.goalStore.get(s.id),v=await q({runtime:e,cwd:d,model:w,profileName:E,client:I,prompt:C,output:i,sessionId:s.id,agentSessionStore:R,signal:_,turnId:T,...o===void 0?{}:{goal:{objective:o.objective,status:o.status,turns:o.turns,evaluatorRuns:o.evaluatorRuns,tokensUsed:o.usage.totalTokens,...o.tokenBudget===void 0?{}:{tokenBudget:o.tokenBudget},...o.maxTurns===void 0?{}:{maxTurns:o.maxTurns},...o.maxDurationMs===void 0?{}:{maxDurationMs:o.maxDurationMs},...o.lastError===void 0?{}:{lastError:o.lastError},...o.lastEvaluation===void 0?{}:{lastEvaluation:o.lastEvaluation.reason}}},onUsage:S.onUsage,onSubagentUsage:S.onUsage,onSnapshot:S.onSnapshot});return i.write(`
3
+ `),await W(e.sessionStore,s.id,T,v),v}catch(o){throw S.onError(o),await z(e.sessionStore,s.id,T,o,_.aborted),o}}});await e.sessionStore.updateStatus(s.id,f?.status==="completed"?"completed":f?.status==="paused"?"active":"failed"),i.write(`Goal session: ${s.id}
4
+ `);const D=f?.status==="paused"&&f.lastError?.startsWith("Goal paused by safety limit:")===!0;return f?.status==="completed"||D?0:1}finally{m!==void 0&&process.off("SIGINT",j),m?.dispose()}}function b(r,t){return k(r,t)}function N(r,t,e){return e?(r.write(`${JSON.stringify(t??null)}
5
5
  `),t===void 0?1:0):t===void 0?(r.write(`No active goal.
6
- `),1):(r.write(`${$(t)}
7
- `),0)}export{de as runGoalCommand};
6
+ `),1):(r.write(`${H(t)}
7
+ `),0)}export{pe as runGoalCommand};