@di-code/coding-agent 0.1.9 → 0.2.2

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 (106) hide show
  1. package/README.md +7 -0
  2. package/compositions/base.yml +3 -0
  3. package/dist/compositions.d.ts.map +1 -1
  4. package/dist/compositions.js +2 -0
  5. package/dist/compositions.js.map +1 -1
  6. package/dist/core/image-input.d.ts +1 -1
  7. package/dist/core/image-input.d.ts.map +1 -1
  8. package/dist/core/image-input.js +15 -4
  9. package/dist/core/image-input.js.map +1 -1
  10. package/dist/core/session/session-manager.d.ts +18 -1
  11. package/dist/core/session/session-manager.d.ts.map +1 -1
  12. package/dist/core/session/session-manager.js +90 -1
  13. package/dist/core/session/session-manager.js.map +1 -1
  14. package/dist/core/session/session-storage.d.ts +2 -0
  15. package/dist/core/session/session-storage.d.ts.map +1 -1
  16. package/dist/core/session/session-storage.js +34 -2
  17. package/dist/core/session/session-storage.js.map +1 -1
  18. package/dist/core/session/types.d.ts +16 -1
  19. package/dist/core/session/types.d.ts.map +1 -1
  20. package/dist/core/session/types.js.map +1 -1
  21. package/dist/core/session.d.ts +27 -2
  22. package/dist/core/session.d.ts.map +1 -1
  23. package/dist/core/session.js +59 -0
  24. package/dist/core/session.js.map +1 -1
  25. package/dist/entry.js +1 -1
  26. package/dist/entry.js.map +1 -1
  27. package/dist/i18n.js +4 -4
  28. package/dist/i18n.js.map +1 -1
  29. package/dist/interactive-host-entry.d.ts.map +1 -1
  30. package/dist/interactive-host-entry.js +107 -12
  31. package/dist/interactive-host-entry.js.map +1 -1
  32. package/dist/main.d.ts.map +1 -1
  33. package/dist/main.js +8 -1
  34. package/dist/main.js.map +1 -1
  35. package/dist/mcp/config.d.ts.map +1 -1
  36. package/dist/mcp/config.js +19 -0
  37. package/dist/mcp/config.js.map +1 -1
  38. package/dist/mcp-command-entry.d.ts +8 -0
  39. package/dist/mcp-command-entry.d.ts.map +1 -0
  40. package/dist/mcp-command-entry.js +56 -0
  41. package/dist/mcp-command-entry.js.map +1 -0
  42. package/dist/modes/interactive-components.d.ts +8 -0
  43. package/dist/modes/interactive-components.d.ts.map +1 -1
  44. package/dist/modes/interactive-components.js +7 -2
  45. package/dist/modes/interactive-components.js.map +1 -1
  46. package/dist/modes/interactive-state.d.ts.map +1 -1
  47. package/dist/modes/interactive-state.js +1 -4
  48. package/dist/modes/interactive-state.js.map +1 -1
  49. package/dist/modes/interactive.d.ts +4 -0
  50. package/dist/modes/interactive.d.ts.map +1 -1
  51. package/dist/modes/interactive.js +69 -0
  52. package/dist/modes/interactive.js.map +1 -1
  53. package/dist/modes/tree-selector.d.ts.map +1 -1
  54. package/dist/modes/tree-selector.js +5 -4
  55. package/dist/modes/tree-selector.js.map +1 -1
  56. package/dist/rpc/client.d.ts +2 -0
  57. package/dist/rpc/client.d.ts.map +1 -1
  58. package/dist/rpc/client.js +3 -0
  59. package/dist/rpc/client.js.map +1 -1
  60. package/dist/rpc/dispatcher.d.ts +14 -0
  61. package/dist/rpc/dispatcher.d.ts.map +1 -1
  62. package/dist/rpc/dispatcher.js +222 -7
  63. package/dist/rpc/dispatcher.js.map +1 -1
  64. package/dist/rpc/protocol.d.ts +12 -5
  65. package/dist/rpc/protocol.d.ts.map +1 -1
  66. package/dist/rpc/protocol.js +56 -0
  67. package/dist/rpc/protocol.js.map +1 -1
  68. package/dist/rpc/server.d.ts +5 -0
  69. package/dist/rpc/server.d.ts.map +1 -1
  70. package/dist/rpc/server.js +4 -0
  71. package/dist/rpc/server.js.map +1 -1
  72. package/dist/rpc-server-entry.d.ts.map +1 -1
  73. package/dist/rpc-server-entry.js +15 -1
  74. package/dist/rpc-server-entry.js.map +1 -1
  75. package/dist/runtime/product-host.d.ts +7 -0
  76. package/dist/runtime/product-host.d.ts.map +1 -1
  77. package/dist/runtime/product-host.js +29 -9
  78. package/dist/runtime/product-host.js.map +1 -1
  79. package/dist/runtime/session-factory.d.ts +18 -2
  80. package/dist/runtime/session-factory.d.ts.map +1 -1
  81. package/dist/runtime/session-factory.js +286 -23
  82. package/dist/runtime/session-factory.js.map +1 -1
  83. package/dist/runtime/session-host.d.ts +46 -1
  84. package/dist/runtime/session-host.d.ts.map +1 -1
  85. package/dist/runtime/session-host.js +38 -6
  86. package/dist/runtime/session-host.js.map +1 -1
  87. package/dist/ui-host.d.ts.map +1 -1
  88. package/dist/ui-host.js +3 -0
  89. package/dist/ui-host.js.map +1 -1
  90. package/dist/web/assets/index-C2SOU925.css +1 -0
  91. package/dist/web/assets/index-knXkInvO.js +41 -0
  92. package/dist/web/assets/index-knXkInvO.js.map +1 -0
  93. package/dist/web/index.html +2 -2
  94. package/dist/web-command.d.ts.map +1 -1
  95. package/dist/web-command.js +8 -1
  96. package/dist/web-command.js.map +1 -1
  97. package/dist/webui-entry.js +9 -1
  98. package/dist/webui-entry.js.map +1 -1
  99. package/dist/webui.d.ts +10 -0
  100. package/dist/webui.d.ts.map +1 -1
  101. package/dist/webui.js +21 -0
  102. package/dist/webui.js.map +1 -1
  103. package/package.json +11 -9
  104. package/dist/web/assets/index-BwfuGMvv.css +0 -1
  105. package/dist/web/assets/index-DPUaJqFJ.js +0 -41
  106. package/dist/web/assets/index-DPUaJqFJ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACN,KAAK,EAGL,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GACb,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAqB,MAAM,iBAAiB,CAAC;AAuEhG,SAAS,oBAAoB,CAAC,KAAY;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE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entTool, AgentToolResult } from \"@di-code/agent\";\nimport {\n\tAgent,\n\ttype AgentListener,\n\ttype ContextBudget,\n\testimateContextTokens,\n\tgenerateCompactionSummary,\n\tprepareCompaction,\n\tresolveContextBudget,\n\tshouldCompact,\n} from \"@di-code/agent\";\nimport type {\n\tAssistantMessage,\n\tImageContent,\n\tMessage,\n\tModel,\n\tProvider,\n\tThinkingLevel,\n\tTSchema,\n\tUsage,\n\tUserContent,\n} from \"@di-code/ai\";\nimport { createSkillCatalog, resolveSkillInvocation, type SkillCatalog } from \"@di-code/skills\";\nimport type { SkillResource } from \"./resources/types.ts\";\nimport type { SessionManager } from \"./session/session-manager.ts\";\nimport type { SessionDiagnostic, SessionEntry, SessionTreeNode } from \"./session/types.ts\";\n\nexport interface AgentSessionCompactionOptions {\n\treadonly enabled?: boolean;\n\treadonly keepRecentTokens?: number;\n\t/** Optional registry-owned message transform applied before compaction cut selection. */\n\treadonly prepareMessages?: (\n\t\tmessages: readonly Message[],\n\t\tsignal?: AbortSignal,\n\t) => readonly Message[] | Promise<readonly Message[]>;\n}\n\nexport type AgentSessionTool = AgentTool<TSchema, AgentToolResult>;\n\nexport interface SessionUsage {\n\treadonly requestCount: number;\n\treadonly inputTokens: number;\n\treadonly outputTokens: number;\n\treadonly cacheReadTokens: number;\n\treadonly cacheWriteTokens: number;\n\treadonly totalTokens: number;\n\treadonly cost: Usage[\"cost\"];\n\treadonly estimatedContextTokens: number;\n\treadonly contextWindow: number;\n\treadonly reserveTokens: number;\n\treadonly triggerTokens: number;\n}\n\nexport interface AgentSessionOptions {\n\treadonly allowedRoot: string;\n\treadonly provider: Provider;\n\treadonly model: Model;\n\t/** Immutable tool snapshot selected by the owning SessionFactory. */\n\treadonly tools: readonly AgentSessionTool[];\n\t/** Valid initial override for the selected model's thinking level. */\n\treadonly thinkingLevel?: ThinkingLevel;\n\treadonly systemPrompt?: string;\n\treadonly skills?: readonly SkillResource[];\n\treadonly now?: () => number;\n\treadonly sessionManager?: SessionManager;\n\treadonly compaction?: AgentSessionCompactionOptions;\n\t/** Called once when the owning product host releases this session scope. */\n\treadonly onDispose?: () => void | Promise<void>;\n}\n\nexport type AgentSessionEvent =\n\t| import(\"@di-code/agent\").AgentEvent\n\t| { type: \"compaction_start\"; reason: \"threshold\" | \"manual\" }\n\t| { type: \"compaction_end\"; reason: \"threshold\" | \"manual\"; success: boolean; errorMessage?: string }\n\t| { type: \"queue_update\"; steering: readonly string[] }\n\t| { type: \"usage_update\"; usage: SessionUsage }\n\t| {\n\t\t\ttype: \"tree_navigated\";\n\t\t\toldLeafId: string;\n\t\t\tnewLeafId: string;\n\t\t\tselectedEntryId: string;\n\t\t\trestoredEditorText: boolean;\n\t };\n\nexport interface TreeNavigationResult {\n\treadonly editorText?: string;\n\treadonly selectedEntryId: string;\n\treadonly leafId: string;\n\treadonly imagesOmitted: boolean;\n}\n\nexport type AgentSessionListener = (event: AgentSessionEvent) => void | Promise<void>;\n\nfunction defaultThinkingLevel(model: Model): ThinkingLevel | undefined {\n\tconst efforts = model.reasoningEfforts;\n\tif (!efforts || efforts.length === 0) return undefined;\n\treturn (\n\t\tmodel.defaultReasoningEffort ??\n\t\t(efforts.includes(\"medium\") ? \"medium\" : efforts.includes(\"high\") ? \"high\" : efforts[0])\n\t);\n}\n\nfunction textFromUserMessage(message: Extract<Message, { role: \"user\" }>): string {\n\treturn message.content\n\t\t.filter((content): content is Extract<UserContent, { type: \"text\" }> => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\");\n}\n\nexport class AgentSession {\n\tprivate readonly agent: Agent;\n\tprivate readonly allowedRootValue: string;\n\tprivate readonly sessionManager?: SessionManager;\n\tprivate provider: Provider;\n\tprivate readonly skills: readonly SkillResource[];\n\tprivate readonly skillCatalog: SkillCatalog;\n\tprivate model: Model;\n\tprivate thinkingLevelValue?: ThinkingLevel;\n\tprivate readonly sessionIdValue: string;\n\tprivate readonly now: () => number;\n\tprivate compactionEnabledValue: boolean;\n\tprivate readonly compactionTransform?: AgentSessionCompactionOptions[\"prepareMessages\"];\n\tprivate contextBudget: ContextBudget;\n\tprivate keepRecentTokens: number;\n\tprivate usageTotals: Omit<\n\t\tSessionUsage,\n\t\t\"estimatedContextTokens\" | \"contextWindow\" | \"reserveTokens\" | \"triggerTokens\"\n\t>;\n\tprivate persistenceError?: unknown;\n\tprivate promptActive = false;\n\tprivate readonly steeringMessages: Array<{ displayText: string; deliveredText: string }> = [];\n\tprivate readonly sessionListeners = new Set<AgentSessionListener>();\n\tprivate readonly agentUnsubscribers: Array<() => void> = [];\n\tprivate readonly onDispose?: AgentSessionOptions[\"onDispose\"];\n\tprivate disposed = false;\n\n\tconstructor(options: AgentSessionOptions) {\n\t\tthis.allowedRootValue = options.allowedRoot;\n\t\tthis.onDispose = options.onDispose;\n\t\tthis.sessionManager = options.sessionManager;\n\t\tthis.provider = options.provider;\n\t\tthis.skills = structuredClone(\n\t\t\t[...(options.skills ?? [])].map((skill) => ({\n\t\t\t\t...skill,\n\t\t\t\tsource:\n\t\t\t\t\tskill.source ?? (skill.scope === \"explicit\" ? \"explicit\" : skill.scope === \"project\" ? \"project\" : \"user\"),\n\t\t\t\tuserInvocable: skill.userInvocable ?? true,\n\t\t\t})),\n\t\t);\n\t\tthis.skillCatalog = createSkillCatalog(\n\t\t\tthis.skills.map((skill) => ({\n\t\t\t\tskill: {\n\t\t\t\t\t...skill,\n\t\t\t\t\tsource:\n\t\t\t\t\t\tskill.source ?? (skill.scope === \"explicit\" ? \"explicit\" : skill.scope === \"project\" ? \"project\" : \"user\"),\n\t\t\t\t\tuserInvocable: skill.userInvocable ?? true,\n\t\t\t\t},\n\t\t\t\tdiagnostics: [],\n\t\t\t})),\n\t\t);\n\t\tthis.model = options.model;\n\t\tthis.thinkingLevelValue =\n\t\t\toptions.thinkingLevel !== undefined && this.model.reasoningEfforts?.includes(options.thinkingLevel)\n\t\t\t\t? options.thinkingLevel\n\t\t\t\t: defaultThinkingLevel(this.model);\n\t\tthis.sessionIdValue = options.sessionManager?.header.id ?? randomUUID();\n\t\tthis.now = options.now ?? Date.now;\n\t\tthis.contextBudget = resolveContextBudget(options.model);\n\t\tif (options.compaction?.enabled !== undefined && typeof options.compaction.enabled !== \"boolean\") {\n\t\t\tthrow new TypeError(\"compaction.enabled must be a boolean\");\n\t\t}\n\t\tthis.compactionEnabledValue = options.sessionManager !== undefined && options.compaction?.enabled !== false;\n\t\tthis.compactionTransform = options.compaction?.prepareMessages;\n\t\tconst defaultKeepRecentTokens = Math.max(1, Math.min(20_000, Math.floor(this.contextBudget.triggerTokens / 2)));\n\t\tthis.keepRecentTokens = options.compaction?.keepRecentTokens ?? defaultKeepRecentTokens;\n\t\tif (!Number.isInteger(this.keepRecentTokens) || this.keepRecentTokens <= 0) {\n\t\t\tthrow new RangeError(\"compaction.keepRecentTokens must be a positive integer\");\n\t\t}\n\t\tthis.usageTotals = {\n\t\t\trequestCount: 0,\n\t\t\tinputTokens: 0,\n\t\t\toutputTokens: 0,\n\t\t\tcacheReadTokens: 0,\n\t\t\tcacheWriteTokens: 0,\n\t\t\ttotalTokens: 0,\n\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t};\n\t\tfor (const message of options.sessionManager?.messages ?? []) {\n\t\t\tif (message.role === \"assistant\") this.addUsage(message.usage);\n\t\t}\n\t\tconst initialContext = options.sessionManager?.buildContext();\n\t\tthis.agent = new Agent({\n\t\t\tprovider: options.provider,\n\t\t\tmodel: options.model,\n\t\t\tthinkingLevel: this.thinkingLevelValue,\n\t\t\tsystemPrompt: options.systemPrompt,\n\t\t\tsessionId: this.sessionIdValue,\n\t\t\ttools: Object.freeze([...options.tools]),\n\t\t\tnow: this.now,\n\t\t\tinitialMessages: options.sessionManager?.messages,\n\t\t\tinitialContextMessages: initialContext?.messages,\n\t\t});\n\t\tthis.agentUnsubscribers.push(\n\t\t\tthis.agent.subscribe(async (event) => {\n\t\t\t\tif (event.type !== \"message_end\" || this.sessionManager === undefined || this.persistenceError !== undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait this.sessionManager.appendMessage(event.message);\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tthis.persistenceError = cause;\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tthis.agentUnsubscribers.push(\n\t\t\tthis.agent.subscribe(async (event) => {\n\t\t\t\tif (event.type !== \"message_end\" || event.message.role !== \"assistant\") return;\n\t\t\t\tthis.addUsage(event.message.usage);\n\t\t\t\tawait this.emitSession({ type: \"usage_update\", usage: this.usage });\n\t\t\t}),\n\t\t);\n\t\tthis.agentUnsubscribers.push(\n\t\t\tthis.agent.subscribe(async (event, _signal) => {\n\t\t\t\tif (event.type === \"message_end\" && event.message.role === \"user\") {\n\t\t\t\t\tconst queued = this.steeringMessages[0];\n\t\t\t\t\tif (queued && textFromUserMessage(event.message) === queued.deliveredText) {\n\t\t\t\t\t\tthis.steeringMessages.shift();\n\t\t\t\t\t\tawait this.emitQueueUpdate();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.emitSession(event);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Releases listeners and the isolated product scope. Repeated calls are harmless. */\n\tasync dispose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const unsubscribe of this.agentUnsubscribers.splice(0)) unsubscribe();\n\t\tthis.sessionListeners.clear();\n\t\tawait this.onDispose?.();\n\t}\n\n\tprivate assertNotDisposed(): void {\n\t\tif (this.disposed) throw new Error(\"AgentSession has been disposed.\");\n\t}\n\n\tget transcript(): readonly Message[] {\n\t\tif (!this.sessionManager) return this.agent.transcript;\n\t\treturn this.sessionManager\n\t\t\t.getBranch()\n\t\t\t.filter((entry): entry is Extract<SessionEntry, { type: \"message\" }> => entry.type === \"message\")\n\t\t\t.map((entry) => structuredClone(entry.message));\n\t}\n\n\tget isStreaming(): boolean {\n\t\treturn this.promptActive;\n\t}\n\n\tget sessionId(): string {\n\t\treturn this.sessionIdValue;\n\t}\n\n\tget modelId(): string {\n\t\treturn this.model.id;\n\t}\n\n\tget providerId(): string {\n\t\treturn this.provider.id;\n\t}\n\n\tget thinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this.thinkingLevelValue;\n\t}\n\n\tget allowedRoot(): string {\n\t\treturn this.allowedRootValue;\n\t}\n\n\tget availableModels(): readonly Model[] {\n\t\treturn structuredClone(this.provider.models);\n\t}\n\n\tget availableSkills(): readonly SkillResource[] {\n\t\treturn structuredClone(this.skills.filter((skill) => skill.userInvocable !== false));\n\t}\n\n\tsetModel(modelId: string): Model {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change model while AgentSession is processing a prompt.\");\n\t\tconst next = this.provider.models.find((model) => model.id === modelId);\n\t\tif (!next) throw new Error(`Unknown model \"${modelId}\" for provider \"${this.provider.id}\".`);\n\t\tthis.model = structuredClone(next);\n\t\tthis.thinkingLevelValue =\n\t\t\tthis.thinkingLevelValue !== undefined && this.model.reasoningEfforts?.includes(this.thinkingLevelValue)\n\t\t\t\t? this.thinkingLevelValue\n\t\t\t\t: defaultThinkingLevel(this.model);\n\t\tthis.agent.setModel(this.model);\n\t\tthis.agent.setThinkingLevel(this.thinkingLevelValue);\n\t\tthis.contextBudget = resolveContextBudget(this.model);\n\t\tthis.keepRecentTokens = Math.min(\n\t\t\tthis.keepRecentTokens,\n\t\t\tMath.max(1, Math.min(20_000, Math.floor(this.contextBudget.triggerTokens / 2))),\n\t\t);\n\t\treturn structuredClone(this.model);\n\t}\n\n\tsetRuntime(provider: Provider, model: Model): Model {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change runtime while AgentSession is processing a prompt.\");\n\t\tconst configuredModel = provider.models.find((candidate) => candidate.id === model.id);\n\t\tif (!configuredModel || configuredModel.provider !== provider.id || model.provider !== provider.id) {\n\t\t\tthrow new Error(`Model \"${model.id}\" does not belong to provider \"${provider.id}\".`);\n\t\t}\n\t\tthis.provider = provider;\n\t\tthis.model = structuredClone(configuredModel);\n\t\tthis.thinkingLevelValue = defaultThinkingLevel(this.model);\n\t\tthis.agent.setRuntime(provider, this.model);\n\t\tthis.agent.setThinkingLevel(this.thinkingLevelValue);\n\t\tthis.contextBudget = resolveContextBudget(this.model);\n\t\tthis.keepRecentTokens = Math.min(\n\t\t\tthis.keepRecentTokens,\n\t\t\tMath.max(1, Math.min(20_000, Math.floor(this.contextBudget.triggerTokens / 2))),\n\t\t);\n\t\treturn structuredClone(this.model);\n\t}\n\n\tcycleThinkingLevel(): ThinkingLevel | undefined {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change thinking level while AgentSession is processing a prompt.\");\n\t\tconst efforts = this.model.reasoningEfforts;\n\t\tif (!efforts || efforts.length === 0) return undefined;\n\t\tconst currentIndex = this.thinkingLevelValue === undefined ? -1 : efforts.indexOf(this.thinkingLevelValue);\n\t\tthis.thinkingLevelValue = efforts[(currentIndex + 1) % efforts.length];\n\t\tthis.agent.setThinkingLevel(this.thinkingLevelValue);\n\t\treturn this.thinkingLevelValue;\n\t}\n\n\tsetThinkingLevel(level: ThinkingLevel): ThinkingLevel {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change thinking level while AgentSession is processing a prompt.\");\n\t\tif (!this.model.reasoningEfforts?.includes(level)) {\n\t\t\tthrow new Error(`Thinking level \"${level}\" is not supported by model \"${this.model.id}\".`);\n\t\t}\n\t\tthis.thinkingLevelValue = level;\n\t\tthis.agent.setThinkingLevel(level);\n\t\treturn level;\n\t}\n\n\tget compactionEnabled(): boolean {\n\t\treturn this.compactionEnabledValue;\n\t}\n\n\tsetCompactionEnabled(enabled: boolean): boolean {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change compaction while AgentSession is processing a prompt.\");\n\t\tthis.compactionEnabledValue = enabled && this.sessionManager !== undefined;\n\t\treturn this.compactionEnabledValue;\n\t}\n\n\tget sessionFile(): string | undefined {\n\t\treturn this.sessionManager?.filePath;\n\t}\n\n\tget sessionDiagnostics(): readonly SessionDiagnostic[] {\n\t\treturn this.sessionManager?.diagnostics ?? [];\n\t}\n\n\tget sessionTree(): readonly SessionTreeNode[] {\n\t\treturn this.sessionManager?.getTree() ?? [];\n\t}\n\n\tget sessionLeafId(): string | undefined {\n\t\treturn this.sessionManager?.leafId;\n\t}\n\n\tget usage(): SessionUsage {\n\t\treturn {\n\t\t\t...this.usageTotals,\n\t\t\tcost: { ...this.usageTotals.cost },\n\t\t\testimatedContextTokens: estimateContextTokens(this.agent.contextMessages),\n\t\t\tcontextWindow: this.contextBudget.contextWindow,\n\t\t\treserveTokens: this.contextBudget.reserveTokens,\n\t\t\ttriggerTokens: this.contextBudget.triggerTokens,\n\t\t};\n\t}\n\n\tasync prompt(text: string, signal?: AbortSignal): Promise<AssistantMessage> {\n\t\treturn this.promptWithImages(text, [], signal);\n\t}\n\n\t/** Queues an instruction for the next provider request while this Session is running. */\n\tasync steer(text: string, signal?: AbortSignal): Promise<void> {\n\t\tawait this.steerWithImages(text, [], signal);\n\t}\n\n\t/** Queues provider-neutral text and image content for the active Agent run. */\n\tasync steerWithImages(text: string, images: readonly ImageContent[], signal?: AbortSignal): Promise<void> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.persistenceError !== undefined) throw this.persistenceError;\n\t\tif (!this.promptActive) throw new Error(\"AgentSession is not processing a prompt.\");\n\t\tif (images.length > 0 && !this.model.input.includes(\"image\")) {\n\t\t\tthrow new Error(`Model \"${this.model.id}\" does not support image input.`);\n\t\t}\n\t\tconst prompt = await resolveSkillInvocation(text, this.skillCatalog, signal);\n\t\tconst content: UserContent[] = [{ type: \"text\", text: prompt }, ...structuredClone([...images])];\n\t\tthis.agent.steerWithContent(content);\n\t\tthis.steeringMessages.push({ displayText: text, deliveredText: prompt });\n\t\tawait this.emitQueueUpdate();\n\t}\n\n\t/** Sends one text prompt with explicitly supplied image attachments. */\n\tasync promptWithImages(\n\t\ttext: string,\n\t\timages: readonly ImageContent[],\n\t\tsignal?: AbortSignal,\n\t): Promise<AssistantMessage> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.persistenceError !== undefined) {\n\t\t\tthrow this.persistenceError;\n\t\t}\n\t\tif (this.promptActive) {\n\t\t\tthrow new Error(\"AgentSession is already processing a prompt.\");\n\t\t}\n\n\t\tthis.promptActive = true;\n\t\ttry {\n\t\t\tif (images.length > 0 && !this.model.input.includes(\"image\")) {\n\t\t\t\tthrow new Error(`Model \"${this.model.id}\" does not support image input.`);\n\t\t\t}\n\t\t\tconst prompt = await resolveSkillInvocation(text, this.skillCatalog, signal);\n\t\t\tconst content: UserContent[] = [{ type: \"text\", text: prompt }, ...structuredClone([...images])];\n\t\t\tawait this.compactIfNeeded(content, signal);\n\t\t\treturn await this.agent.promptWithContent(content, signal);\n\t\t} finally {\n\t\t\tthis.promptActive = false;\n\t\t}\n\t}\n\n\tasync compact(signal?: AbortSignal): Promise<void> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"AgentSession is already processing a prompt.\");\n\t\tif (!this.sessionManager) throw new Error(\"Cannot compact without a persisted session.\");\n\t\tthis.promptActive = true;\n\t\ttry {\n\t\t\tawait this.compactNow(signal, \"manual\");\n\t\t} finally {\n\t\t\tthis.promptActive = false;\n\t\t}\n\t}\n\n\t/** Changes the active persisted branch and replaces the next-request model context. */\n\tasync navigateTree(entryId: string): Promise<TreeNavigationResult> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive)\n\t\t\tthrow new Error(\"Cannot navigate the session tree while AgentSession is processing a prompt.\");\n\t\tif (!this.sessionManager) throw new Error(\"Cannot navigate an in-memory session.\");\n\t\tconst entry = this.sessionManager.getEntry(entryId);\n\t\tif (!entry) throw new Error(`Unknown session tree entry \"${entryId}\".`);\n\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\" && entry.message.stopReason === \"tool_use\") {\n\t\t\tthrow new Error(\"Select the final tool result for an assistant message with tool calls.\");\n\t\t}\n\n\t\tconst oldLeafId = this.sessionManager.leafId;\n\t\tlet editorText: string | undefined;\n\t\tlet imagesOmitted = false;\n\t\tif (entry.type === \"message\" && entry.message.role === \"user\") {\n\t\t\teditorText = textFromUserMessage(entry.message);\n\t\t\timagesOmitted = entry.message.content.some((content) => content.type === \"image\");\n\t\t\tthis.sessionManager.setLeaf(entry.parentId);\n\t\t} else {\n\t\t\tthis.sessionManager.setLeaf(entry.id);\n\t\t}\n\n\t\ttry {\n\t\t\tthis.agent.replaceContext(this.sessionManager.buildContext().messages);\n\t\t} catch (cause) {\n\t\t\tthis.sessionManager.setLeaf(oldLeafId);\n\t\t\tthrow cause;\n\t\t}\n\t\tawait this.emitSession({\n\t\t\ttype: \"tree_navigated\",\n\t\t\toldLeafId,\n\t\t\tnewLeafId: this.sessionManager.leafId,\n\t\t\tselectedEntryId: entry.id,\n\t\t\trestoredEditorText: editorText !== undefined,\n\t\t});\n\t\treturn { editorText, selectedEntryId: entry.id, leafId: this.sessionManager.leafId, imagesOmitted };\n\t}\n\n\tsubscribe(listener: AgentListener): () => void {\n\t\treturn this.agent.subscribe(listener);\n\t}\n\n\tsubscribeSession(listener: AgentSessionListener): () => void {\n\t\tthis.sessionListeners.add(listener);\n\t\treturn () => this.sessionListeners.delete(listener);\n\t}\n\n\tprivate async emitSession(event: AgentSessionEvent): Promise<void> {\n\t\tfor (const listener of this.sessionListeners) await listener(structuredClone(event));\n\t}\n\n\tprivate async emitQueueUpdate(): Promise<void> {\n\t\tawait this.emitSession({\n\t\t\ttype: \"queue_update\",\n\t\t\tsteering: this.steeringMessages.map((message) => message.displayText),\n\t\t});\n\t}\n\n\tprivate addUsage(usage: Usage): void {\n\t\tthis.usageTotals = {\n\t\t\trequestCount: this.usageTotals.requestCount + 1,\n\t\t\tinputTokens: this.usageTotals.inputTokens + usage.input,\n\t\t\toutputTokens: this.usageTotals.outputTokens + usage.output,\n\t\t\tcacheReadTokens: this.usageTotals.cacheReadTokens + usage.cacheRead,\n\t\t\tcacheWriteTokens: this.usageTotals.cacheWriteTokens + usage.cacheWrite,\n\t\t\ttotalTokens: this.usageTotals.totalTokens + usage.totalTokens,\n\t\t\tcost: {\n\t\t\t\tinput: this.usageTotals.cost.input + usage.cost.input,\n\t\t\t\toutput: this.usageTotals.cost.output + usage.cost.output,\n\t\t\t\tcacheRead: this.usageTotals.cost.cacheRead + usage.cost.cacheRead,\n\t\t\t\tcacheWrite: this.usageTotals.cost.cacheWrite + usage.cost.cacheWrite,\n\t\t\t\ttotal: this.usageTotals.cost.total + usage.cost.total,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async compactIfNeeded(content: readonly UserContent[], signal?: AbortSignal): Promise<void> {\n\t\tif (!this.compactionEnabledValue || !this.sessionManager) return;\n\n\t\tconst context = this.sessionManager.buildContext();\n\t\tconst pendingUser: Message = {\n\t\t\trole: \"user\",\n\t\t\tcontent: structuredClone([...content]),\n\t\t\ttimestamp: 0,\n\t\t};\n\t\tconst estimatedTokens = estimateContextTokens([...context.messages, pendingUser]);\n\t\tif (!shouldCompact(estimatedTokens, this.contextBudget)) return;\n\n\t\tawait this.compactNow(signal, \"threshold\");\n\t}\n\n\tprivate async compactNow(signal: AbortSignal | undefined, reason: \"threshold\" | \"manual\"): Promise<void> {\n\t\tif (!this.sessionManager) throw new Error(\"Cannot compact without a persisted session.\");\n\t\tconst context = this.sessionManager.buildContext();\n\t\tawait this.emitSession({ type: \"compaction_start\", reason });\n\t\tlet messages: readonly Message[];\n\t\ttry {\n\t\t\tmessages = this.compactionTransform ? await this.compactionTransform(context.messages, signal) : context.messages;\n\t\t} catch (cause) {\n\t\t\tconst errorMessage = cause instanceof Error ? cause.message : String(cause);\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow cause;\n\t\t}\n\t\tif (messages.length !== context.messages.length) {\n\t\t\tconst error = new Error(\"Compaction message transform must preserve message count.\");\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage: error.message });\n\t\t\tthrow error;\n\t\t}\n\t\tconst preparation =\n\t\t\tprepareCompaction(messages, this.keepRecentTokens) ??\n\t\t\t(reason === \"manual\" ? this.prepareManualCompaction(messages) : undefined);\n\t\tconst firstKeptEntryId = preparation ? context.sourceEntryIds[preparation.firstKeptMessageIndex] : undefined;\n\t\tif (!preparation || typeof firstKeptEntryId !== \"string\") {\n\t\t\tconst errorMessage =\n\t\t\t\treason === \"manual\"\n\t\t\t\t\t? \"No valid compaction cut point was found for the current session.\"\n\t\t\t\t\t: \"Context limit reached but no valid compaction cut point was found.\";\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\tlet summary: string;\n\t\ttry {\n\t\t\tsummary = await generateCompactionSummary(preparation, this.provider, this.model, {\n\t\t\t\treserveTokens: this.contextBudget.reserveTokens,\n\t\t\t\tsignal,\n\t\t\t\tnow: this.now,\n\t\t\t\tonUsage: (usage) => this.addUsage(usage),\n\t\t\t});\n\t\t\tawait this.emitSession({ type: \"usage_update\", usage: this.usage });\n\t\t} catch (cause) {\n\t\t\tconst errorMessage = cause instanceof Error ? cause.message : String(cause);\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow cause;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.sessionManager.appendSummary({\n\t\t\t\tsummary,\n\t\t\t\tfirstKeptEntryId,\n\t\t\t\ttokensBefore: preparation.tokensBefore,\n\t\t\t});\n\t\t} catch (cause) {\n\t\t\tthis.persistenceError = cause;\n\t\t\tconst errorMessage = cause instanceof Error ? cause.message : String(cause);\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow cause;\n\t\t}\n\n\t\tthis.agent.replaceContext(this.sessionManager.buildContext().messages);\n\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: true });\n\t}\n\n\t/** A manual request may retain only the newest complete user turn when the configured suffix is larger than history. */\n\tprivate prepareManualCompaction(messages: readonly Message[]) {\n\t\tfor (let index = messages.length - 1; index > 0; index--) {\n\t\t\tif (messages[index]?.role !== \"user\") continue;\n\t\t\treturn prepareCompaction(messages, estimateContextTokens(messages.slice(index)));\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACN,KAAK,EAGL,qBAAqB,EACrB,yBAAyB,EAEzB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GACb,MAAM,gBAAgB,CAAC;AAexB,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAqB,MAAM,iBAAiB,CAAC;AA+EhG,SAAS,oBAAoB,CAAC,KAAY;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACvC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACvD,OAAO,CACN,KAAK,CAAC,sBAAsB;QAC5B,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACxF,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,OAA2C;IACvE,OAAO,OAAO,CAAC,OAAO;SACpB,MAAM,CAAC,CAAC,OAAO,EAAqD,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;SAC/F,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IA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AE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,wHAAwH;IAChH,uBAAuB,CAAC,QAA4B;QAC3D,KAAK,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YAC1D,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,MAAM;gBAAE,SAAS;YAC/C,OAAO,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAClF,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentHookRegistration, AgentTool, AgentToolResult } from \"@di-code/agent\";\nimport {\n\tAgent,\n\ttype AgentListener,\n\ttype ContextBudget,\n\testimateContextTokens,\n\tgenerateCompactionSummary,\n\ttype PromptSectionRegistry,\n\tprepareCompaction,\n\tresolveContextBudget,\n\tshouldCompact,\n} from \"@di-code/agent\";\nimport type {\n\tAssistantMessage,\n\tImageContent,\n\tMessage,\n\tModel,\n\tProvider,\n\tThinkingLevel,\n\tTSchema,\n\tUsage,\n\tUserContent,\n} from \"@di-code/ai\";\nimport type { ToolPolicyCapability, ToolPolicyMode, ToolPolicySnapshot } from \"@di-code/builtins\";\nimport type { PlanModeController, PlanModeProjection } from \"@di-code/plan-mode\";\nimport type { SessionExtensionFacade, SessionProjectionRegistry } from \"@di-code/plugin-sdk\";\nimport { createSkillCatalog, resolveSkillInvocation, type SkillCatalog } from \"@di-code/skills\";\nimport type { SkillResource } from \"./resources/types.ts\";\nimport type { SessionManager } from \"./session/session-manager.ts\";\nimport type { SessionDiagnostic, SessionEntry, SessionTreeNode } from \"./session/types.ts\";\n\nexport interface AgentSessionCompactionOptions {\n\treadonly enabled?: boolean;\n\treadonly keepRecentTokens?: number;\n\t/** Optional registry-owned message transform applied before compaction cut selection. */\n\treadonly prepareMessages?: (\n\t\tmessages: readonly Message[],\n\t\tsignal?: AbortSignal,\n\t) => readonly Message[] | Promise<readonly Message[]>;\n}\n\nexport type AgentSessionTool = AgentTool<TSchema, AgentToolResult>;\n\nexport interface SessionUsage {\n\treadonly requestCount: number;\n\treadonly inputTokens: number;\n\treadonly outputTokens: number;\n\treadonly cacheReadTokens: number;\n\treadonly cacheWriteTokens: number;\n\treadonly totalTokens: number;\n\treadonly cost: Usage[\"cost\"];\n\treadonly estimatedContextTokens: number;\n\treadonly contextWindow: number;\n\treadonly reserveTokens: number;\n\treadonly triggerTokens: number;\n}\n\nexport interface AgentSessionOptions {\n\treadonly allowedRoot: string;\n\treadonly provider: Provider;\n\treadonly model: Model;\n\t/** Immutable tool snapshot selected by the owning SessionFactory. */\n\treadonly tools: readonly AgentSessionTool[];\n\t/** Valid initial override for the selected model's thinking level. */\n\treadonly thinkingLevel?: ThinkingLevel;\n\treadonly systemPrompt?: string;\n\treadonly promptSections?: PromptSectionRegistry;\n\t/** Returns an immutable, session-owned snapshot for dynamic prompt generators. */\n\treadonly getPromptSnapshot?: () => unknown;\n\treadonly skills?: readonly SkillResource[];\n\treadonly now?: () => number;\n\treadonly sessionManager?: SessionManager;\n\treadonly compaction?: AgentSessionCompactionOptions;\n\treadonly toolPolicy?: ToolPolicyCapability;\n\treadonly hooks?: readonly AgentHookRegistration[];\n\treadonly planMode?: PlanModeController;\n\treadonly projectionRegistry?: SessionProjectionRegistry;\n\treadonly extensionFacade?: SessionExtensionFacade;\n\t/** Called once when the owning product host releases this session scope. */\n\treadonly onDispose?: () => void | Promise<void>;\n}\n\nexport type AgentSessionEvent =\n\t| import(\"@di-code/agent\").AgentEvent\n\t| { type: \"compaction_start\"; reason: \"threshold\" | \"manual\" }\n\t| { type: \"compaction_end\"; reason: \"threshold\" | \"manual\"; success: boolean; errorMessage?: string }\n\t| { type: \"queue_update\"; steering: readonly string[] }\n\t| { type: \"usage_update\"; usage: SessionUsage }\n\t| {\n\t\t\ttype: \"tree_navigated\";\n\t\t\toldLeafId: string;\n\t\t\tnewLeafId: string;\n\t\t\tselectedEntryId: string;\n\t\t\trestoredEditorText: boolean;\n\t };\n\nexport interface TreeNavigationResult {\n\treadonly editorText?: string;\n\treadonly selectedEntryId: string;\n\treadonly leafId: string;\n\treadonly imagesOmitted: boolean;\n}\n\nexport type AgentSessionListener = (event: AgentSessionEvent) => void | Promise<void>;\n\nfunction defaultThinkingLevel(model: Model): ThinkingLevel | undefined {\n\tconst efforts = model.reasoningEfforts;\n\tif (!efforts || efforts.length === 0) return undefined;\n\treturn (\n\t\tmodel.defaultReasoningEffort ??\n\t\t(efforts.includes(\"medium\") ? \"medium\" : efforts.includes(\"high\") ? \"high\" : efforts[0])\n\t);\n}\n\nfunction textFromUserMessage(message: Extract<Message, { role: \"user\" }>): string {\n\treturn message.content\n\t\t.filter((content): content is Extract<UserContent, { type: \"text\" }> => content.type === \"text\")\n\t\t.map((content) => content.text)\n\t\t.join(\"\");\n}\n\nexport class AgentSession {\n\tprivate readonly agent: Agent;\n\tprivate readonly allowedRootValue: string;\n\tprivate readonly sessionManager?: SessionManager;\n\tprivate provider: Provider;\n\tprivate readonly skills: readonly SkillResource[];\n\tprivate readonly skillCatalog: SkillCatalog;\n\tprivate model: Model;\n\tprivate thinkingLevelValue?: ThinkingLevel;\n\tprivate readonly sessionIdValue: string;\n\tprivate readonly now: () => number;\n\tprivate compactionEnabledValue: boolean;\n\tprivate readonly compactionTransform?: AgentSessionCompactionOptions[\"prepareMessages\"];\n\tprivate contextBudget: ContextBudget;\n\tprivate keepRecentTokens: number;\n\tprivate usageTotals: Omit<\n\t\tSessionUsage,\n\t\t\"estimatedContextTokens\" | \"contextWindow\" | \"reserveTokens\" | \"triggerTokens\"\n\t>;\n\tprivate persistenceError?: unknown;\n\tprivate promptActive = false;\n\tprivate readonly steeringMessages: Array<{ displayText: string; deliveredText: string }> = [];\n\tprivate readonly sessionListeners = new Set<AgentSessionListener>();\n\tprivate readonly agentUnsubscribers: Array<() => void> = [];\n\tprivate readonly onDispose?: AgentSessionOptions[\"onDispose\"];\n\tprivate readonly toolPolicy?: ToolPolicyCapability;\n\tprivate readonly planModeController?: PlanModeController;\n\tprivate readonly projectionRegistry?: SessionProjectionRegistry;\n\tprivate readonly extensionFacade?: SessionExtensionFacade;\n\tprivate disposed = false;\n\n\tconstructor(options: AgentSessionOptions) {\n\t\tthis.allowedRootValue = options.allowedRoot;\n\t\tthis.onDispose = options.onDispose;\n\t\tthis.toolPolicy = options.toolPolicy;\n\t\tthis.planModeController = options.planMode;\n\t\tthis.projectionRegistry = options.projectionRegistry;\n\t\tthis.extensionFacade = options.extensionFacade;\n\t\tthis.sessionManager = options.sessionManager;\n\t\tthis.provider = options.provider;\n\t\tthis.skills = structuredClone(\n\t\t\t[...(options.skills ?? [])].map((skill) => ({\n\t\t\t\t...skill,\n\t\t\t\tsource:\n\t\t\t\t\tskill.source ?? (skill.scope === \"explicit\" ? \"explicit\" : skill.scope === \"project\" ? \"project\" : \"user\"),\n\t\t\t\tuserInvocable: skill.userInvocable ?? true,\n\t\t\t})),\n\t\t);\n\t\tthis.skillCatalog = createSkillCatalog(\n\t\t\tthis.skills.map((skill) => ({\n\t\t\t\tskill: {\n\t\t\t\t\t...skill,\n\t\t\t\t\tsource:\n\t\t\t\t\t\tskill.source ?? (skill.scope === \"explicit\" ? \"explicit\" : skill.scope === \"project\" ? \"project\" : \"user\"),\n\t\t\t\t\tuserInvocable: skill.userInvocable ?? true,\n\t\t\t\t},\n\t\t\t\tdiagnostics: [],\n\t\t\t})),\n\t\t);\n\t\tthis.model = options.model;\n\t\tthis.thinkingLevelValue =\n\t\t\toptions.thinkingLevel !== undefined && this.model.reasoningEfforts?.includes(options.thinkingLevel)\n\t\t\t\t? options.thinkingLevel\n\t\t\t\t: defaultThinkingLevel(this.model);\n\t\tthis.sessionIdValue = options.sessionManager?.header.id ?? randomUUID();\n\t\tthis.now = options.now ?? Date.now;\n\t\tthis.contextBudget = resolveContextBudget(options.model);\n\t\tif (options.compaction?.enabled !== undefined && typeof options.compaction.enabled !== \"boolean\") {\n\t\t\tthrow new TypeError(\"compaction.enabled must be a boolean\");\n\t\t}\n\t\tthis.compactionEnabledValue = options.sessionManager !== undefined && options.compaction?.enabled !== false;\n\t\tthis.compactionTransform = options.compaction?.prepareMessages;\n\t\tconst defaultKeepRecentTokens = Math.max(1, Math.min(20_000, Math.floor(this.contextBudget.triggerTokens / 2)));\n\t\tthis.keepRecentTokens = options.compaction?.keepRecentTokens ?? defaultKeepRecentTokens;\n\t\tif (!Number.isInteger(this.keepRecentTokens) || this.keepRecentTokens <= 0) {\n\t\t\tthrow new RangeError(\"compaction.keepRecentTokens must be a positive integer\");\n\t\t}\n\t\tthis.usageTotals = {\n\t\t\trequestCount: 0,\n\t\t\tinputTokens: 0,\n\t\t\toutputTokens: 0,\n\t\t\tcacheReadTokens: 0,\n\t\t\tcacheWriteTokens: 0,\n\t\t\ttotalTokens: 0,\n\t\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },\n\t\t};\n\t\tfor (const message of options.sessionManager?.messages ?? []) {\n\t\t\tif (message.role === \"assistant\") this.addUsage(message.usage);\n\t\t}\n\t\tconst initialContext = options.sessionManager?.buildContext();\n\t\tthis.agent = new Agent({\n\t\t\tprovider: options.provider,\n\t\t\tmodel: options.model,\n\t\t\tthinkingLevel: this.thinkingLevelValue,\n\t\t\tsystemPrompt: options.systemPrompt,\n\t\t\tsessionId: this.sessionIdValue,\n\t\t\ttools: Object.freeze([...options.tools]),\n\t\t\tnow: this.now,\n\t\t\tinitialMessages: options.sessionManager?.messages,\n\t\t\tinitialContextMessages: initialContext?.messages,\n\t\t\tpromptSections: options.promptSections,\n\t\t\tgetPromptSnapshot: options.getPromptSnapshot,\n\t\t\thooks: options.hooks,\n\t\t});\n\t\tthis.agentUnsubscribers.push(\n\t\t\tthis.agent.subscribe(async (event) => {\n\t\t\t\tif (event.type !== \"message_end\" || this.sessionManager === undefined || this.persistenceError !== undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tawait this.sessionManager.appendMessage(event.message);\n\t\t\t\t} catch (cause) {\n\t\t\t\t\tthis.persistenceError = cause;\n\t\t\t\t\tthrow cause;\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tthis.agentUnsubscribers.push(\n\t\t\tthis.agent.subscribe(async (event) => {\n\t\t\t\tif (event.type !== \"message_end\" || event.message.role !== \"assistant\") return;\n\t\t\t\tthis.addUsage(event.message.usage);\n\t\t\t\tawait this.emitSession({ type: \"usage_update\", usage: this.usage });\n\t\t\t}),\n\t\t);\n\t\tthis.agentUnsubscribers.push(\n\t\t\tthis.agent.subscribe(async (event, _signal) => {\n\t\t\t\tif (event.type === \"message_end\" && event.message.role === \"user\") {\n\t\t\t\t\tconst queued = this.steeringMessages[0];\n\t\t\t\t\tif (queued && textFromUserMessage(event.message) === queued.deliveredText) {\n\t\t\t\t\t\tthis.steeringMessages.shift();\n\t\t\t\t\t\tawait this.emitQueueUpdate();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait this.emitSession(event);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** Releases listeners and the isolated product scope. Repeated calls are harmless. */\n\tasync dispose(): Promise<void> {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.toolPolicy?.dispose?.();\n\t\tawait this.planModeController?.dispose();\n\t\tfor (const unsubscribe of this.agentUnsubscribers.splice(0)) unsubscribe();\n\t\tthis.sessionListeners.clear();\n\t\tawait this.onDispose?.();\n\t}\n\n\tprivate assertNotDisposed(): void {\n\t\tif (this.disposed) throw new Error(\"AgentSession has been disposed.\");\n\t}\n\n\tget transcript(): readonly Message[] {\n\t\tif (!this.sessionManager) return this.agent.transcript;\n\t\treturn this.sessionManager\n\t\t\t.getBranch()\n\t\t\t.filter((entry): entry is Extract<SessionEntry, { type: \"message\" }> => entry.type === \"message\")\n\t\t\t.map((entry) => structuredClone(entry.message));\n\t}\n\n\tget isStreaming(): boolean {\n\t\treturn this.promptActive;\n\t}\n\n\tget sessionId(): string {\n\t\treturn this.sessionIdValue;\n\t}\n\n\tget modelId(): string {\n\t\treturn this.model.id;\n\t}\n\n\tget providerId(): string {\n\t\treturn this.provider.id;\n\t}\n\n\tget thinkingLevel(): ThinkingLevel | undefined {\n\t\treturn this.thinkingLevelValue;\n\t}\n\n\tget allowedRoot(): string {\n\t\treturn this.allowedRootValue;\n\t}\n\n\tget availableModels(): readonly Model[] {\n\t\treturn structuredClone(this.provider.models);\n\t}\n\n\tget availableSkills(): readonly SkillResource[] {\n\t\treturn structuredClone(this.skills.filter((skill) => skill.userInvocable !== false));\n\t}\n\n\tsetModel(modelId: string): Model {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change model while AgentSession is processing a prompt.\");\n\t\tconst next = this.provider.models.find((model) => model.id === modelId);\n\t\tif (!next) throw new Error(`Unknown model \"${modelId}\" for provider \"${this.provider.id}\".`);\n\t\tthis.model = structuredClone(next);\n\t\tthis.thinkingLevelValue =\n\t\t\tthis.thinkingLevelValue !== undefined && this.model.reasoningEfforts?.includes(this.thinkingLevelValue)\n\t\t\t\t? this.thinkingLevelValue\n\t\t\t\t: defaultThinkingLevel(this.model);\n\t\tthis.agent.setModel(this.model);\n\t\tthis.agent.setThinkingLevel(this.thinkingLevelValue);\n\t\tthis.contextBudget = resolveContextBudget(this.model);\n\t\tthis.keepRecentTokens = Math.min(\n\t\t\tthis.keepRecentTokens,\n\t\t\tMath.max(1, Math.min(20_000, Math.floor(this.contextBudget.triggerTokens / 2))),\n\t\t);\n\t\treturn structuredClone(this.model);\n\t}\n\n\tsetRuntime(provider: Provider, model: Model): Model {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change runtime while AgentSession is processing a prompt.\");\n\t\tconst configuredModel = provider.models.find((candidate) => candidate.id === model.id);\n\t\tif (!configuredModel || configuredModel.provider !== provider.id || model.provider !== provider.id) {\n\t\t\tthrow new Error(`Model \"${model.id}\" does not belong to provider \"${provider.id}\".`);\n\t\t}\n\t\tthis.provider = provider;\n\t\tthis.model = structuredClone(configuredModel);\n\t\tthis.thinkingLevelValue = defaultThinkingLevel(this.model);\n\t\tthis.agent.setRuntime(provider, this.model);\n\t\tthis.agent.setThinkingLevel(this.thinkingLevelValue);\n\t\tthis.contextBudget = resolveContextBudget(this.model);\n\t\tthis.keepRecentTokens = Math.min(\n\t\t\tthis.keepRecentTokens,\n\t\t\tMath.max(1, Math.min(20_000, Math.floor(this.contextBudget.triggerTokens / 2))),\n\t\t);\n\t\treturn structuredClone(this.model);\n\t}\n\n\tcycleThinkingLevel(): ThinkingLevel | undefined {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change thinking level while AgentSession is processing a prompt.\");\n\t\tconst efforts = this.model.reasoningEfforts;\n\t\tif (!efforts || efforts.length === 0) return undefined;\n\t\tconst currentIndex = this.thinkingLevelValue === undefined ? -1 : efforts.indexOf(this.thinkingLevelValue);\n\t\tthis.thinkingLevelValue = efforts[(currentIndex + 1) % efforts.length];\n\t\tthis.agent.setThinkingLevel(this.thinkingLevelValue);\n\t\treturn this.thinkingLevelValue;\n\t}\n\n\tsetThinkingLevel(level: ThinkingLevel): ThinkingLevel {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change thinking level while AgentSession is processing a prompt.\");\n\t\tif (!this.model.reasoningEfforts?.includes(level)) {\n\t\t\tthrow new Error(`Thinking level \"${level}\" is not supported by model \"${this.model.id}\".`);\n\t\t}\n\t\tthis.thinkingLevelValue = level;\n\t\tthis.agent.setThinkingLevel(level);\n\t\treturn level;\n\t}\n\n\tget compactionEnabled(): boolean {\n\t\treturn this.compactionEnabledValue;\n\t}\n\n\tsetCompactionEnabled(enabled: boolean): boolean {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"Cannot change compaction while AgentSession is processing a prompt.\");\n\t\tthis.compactionEnabledValue = enabled && this.sessionManager !== undefined;\n\t\treturn this.compactionEnabledValue;\n\t}\n\n\tget sessionFile(): string | undefined {\n\t\treturn this.sessionManager?.filePath;\n\t}\n\n\tget sessionDiagnostics(): readonly SessionDiagnostic[] {\n\t\treturn this.sessionManager?.diagnostics ?? [];\n\t}\n\n\tget sessionTree(): readonly SessionTreeNode[] {\n\t\treturn this.sessionManager?.getTree() ?? [];\n\t}\n\n\tget sessionLeafId(): string | undefined {\n\t\treturn this.sessionManager?.leafId;\n\t}\n\n\tget toolPolicySnapshot(): ToolPolicySnapshot | undefined {\n\t\treturn this.toolPolicy?.snapshot?.();\n\t}\n\n\tget planModeProjection(): PlanModeProjection | undefined {\n\t\treturn this.planModeController?.get();\n\t}\n\n\tplanModeCommand(args: string): Promise<string> {\n\t\tif (!this.planModeController) return Promise.reject(new Error(\"Plan mode is unavailable.\"));\n\t\treturn this.planModeController.command(args, async (message) => {\n\t\t\tif (this.promptActive) {\n\t\t\t\tawait this.steer(message);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait this.prompt(message);\n\t\t});\n\t}\n\n\tplanCommand(args: string): Promise<string> {\n\t\treturn this.planModeCommand(args);\n\t}\n\n\tplanMode(): PlanModeProjection | undefined {\n\t\treturn this.planModeProjection;\n\t}\n\n\tprojections(): readonly import(\"@di-code/plugin-sdk\").SessionProjectionSnapshot[] {\n\t\tif (!this.projectionRegistry || !this.sessionManager) return [];\n\t\treturn this.projectionRegistry.replay(\n\t\t\tthis.sessionManager.events.map((event) => ({\n\t\t\t\tnamespace: event.namespace,\n\t\t\t\teventName: event.eventName,\n\t\t\t\tschemaVersion: event.schemaVersion,\n\t\t\t\tpayload: event.payload,\n\t\t\t})),\n\t\t);\n\t}\n\n\textensions(): SessionExtensionFacade | undefined {\n\t\treturn this.extensionFacade;\n\t}\n\n\tasync setToolPolicyMode(mode: ToolPolicyMode, signal?: AbortSignal): Promise<ToolPolicySnapshot> {\n\t\tthis.assertNotDisposed();\n\t\tif (!this.toolPolicy?.setMode) throw new Error(\"Session tool policy is not dynamic.\");\n\t\treturn await this.toolPolicy.setMode(mode, signal);\n\t}\n\n\tget usage(): SessionUsage {\n\t\treturn {\n\t\t\t...this.usageTotals,\n\t\t\tcost: { ...this.usageTotals.cost },\n\t\t\testimatedContextTokens: estimateContextTokens(this.agent.contextMessages),\n\t\t\tcontextWindow: this.contextBudget.contextWindow,\n\t\t\treserveTokens: this.contextBudget.reserveTokens,\n\t\t\ttriggerTokens: this.contextBudget.triggerTokens,\n\t\t};\n\t}\n\n\tasync prompt(text: string, signal?: AbortSignal): Promise<AssistantMessage> {\n\t\treturn this.promptWithImages(text, [], signal);\n\t}\n\n\t/** Queues an instruction for the next provider request while this Session is running. */\n\tasync steer(text: string, signal?: AbortSignal): Promise<void> {\n\t\tawait this.steerWithImages(text, [], signal);\n\t}\n\n\t/** Queues provider-neutral text and image content for the active Agent run. */\n\tasync steerWithImages(text: string, images: readonly ImageContent[], signal?: AbortSignal): Promise<void> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.persistenceError !== undefined) throw this.persistenceError;\n\t\tif (!this.promptActive) throw new Error(\"AgentSession is not processing a prompt.\");\n\t\tif (images.length > 0 && !this.model.input.includes(\"image\")) {\n\t\t\tthrow new Error(`Model \"${this.model.id}\" does not support image input.`);\n\t\t}\n\t\tconst prompt = await resolveSkillInvocation(text, this.skillCatalog, signal);\n\t\tconst content: UserContent[] = [{ type: \"text\", text: prompt }, ...structuredClone([...images])];\n\t\tthis.agent.steerWithContent(content);\n\t\tthis.steeringMessages.push({ displayText: text, deliveredText: prompt });\n\t\tawait this.emitQueueUpdate();\n\t}\n\n\t/** Sends one text prompt with explicitly supplied image attachments. */\n\tasync promptWithImages(\n\t\ttext: string,\n\t\timages: readonly ImageContent[],\n\t\tsignal?: AbortSignal,\n\t): Promise<AssistantMessage> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.persistenceError !== undefined) {\n\t\t\tthrow this.persistenceError;\n\t\t}\n\t\tif (this.promptActive) {\n\t\t\tthrow new Error(\"AgentSession is already processing a prompt.\");\n\t\t}\n\n\t\tthis.promptActive = true;\n\t\ttry {\n\t\t\tif (images.length > 0 && !this.model.input.includes(\"image\")) {\n\t\t\t\tthrow new Error(`Model \"${this.model.id}\" does not support image input.`);\n\t\t\t}\n\t\t\tconst prompt = await resolveSkillInvocation(text, this.skillCatalog, signal);\n\t\t\tconst content: UserContent[] = [{ type: \"text\", text: prompt }, ...structuredClone([...images])];\n\t\t\tawait this.compactIfNeeded(content, signal);\n\t\t\treturn await this.agent.promptWithContent(content, signal);\n\t\t} finally {\n\t\t\tthis.promptActive = false;\n\t\t}\n\t}\n\n\tasync compact(signal?: AbortSignal): Promise<void> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive) throw new Error(\"AgentSession is already processing a prompt.\");\n\t\tif (!this.sessionManager) throw new Error(\"Cannot compact without a persisted session.\");\n\t\tthis.promptActive = true;\n\t\ttry {\n\t\t\tawait this.compactNow(signal, \"manual\");\n\t\t} finally {\n\t\t\tthis.promptActive = false;\n\t\t}\n\t}\n\n\t/** Changes the active persisted branch and replaces the next-request model context. */\n\tasync navigateTree(entryId: string): Promise<TreeNavigationResult> {\n\t\tthis.assertNotDisposed();\n\t\tif (this.promptActive)\n\t\t\tthrow new Error(\"Cannot navigate the session tree while AgentSession is processing a prompt.\");\n\t\tif (!this.sessionManager) throw new Error(\"Cannot navigate an in-memory session.\");\n\t\tconst entry = this.sessionManager.getEntry(entryId);\n\t\tif (!entry) throw new Error(`Unknown session tree entry \"${entryId}\".`);\n\t\tif (entry.type === \"message\" && entry.message.role === \"assistant\" && entry.message.stopReason === \"tool_use\") {\n\t\t\tthrow new Error(\"Select the final tool result for an assistant message with tool calls.\");\n\t\t}\n\n\t\tconst oldLeafId = this.sessionManager.leafId;\n\t\tlet editorText: string | undefined;\n\t\tlet imagesOmitted = false;\n\t\tif (entry.type === \"message\" && entry.message.role === \"user\") {\n\t\t\teditorText = textFromUserMessage(entry.message);\n\t\t\timagesOmitted = entry.message.content.some((content) => content.type === \"image\");\n\t\t\tthis.sessionManager.setLeaf(entry.parentId);\n\t\t} else {\n\t\t\tthis.sessionManager.setLeaf(entry.id);\n\t\t}\n\n\t\ttry {\n\t\t\tthis.agent.replaceContext(this.sessionManager.buildContext().messages);\n\t\t} catch (cause) {\n\t\t\tthis.sessionManager.setLeaf(oldLeafId);\n\t\t\tthrow cause;\n\t\t}\n\t\tawait this.emitSession({\n\t\t\ttype: \"tree_navigated\",\n\t\t\toldLeafId,\n\t\t\tnewLeafId: this.sessionManager.leafId,\n\t\t\tselectedEntryId: entry.id,\n\t\t\trestoredEditorText: editorText !== undefined,\n\t\t});\n\t\treturn { editorText, selectedEntryId: entry.id, leafId: this.sessionManager.leafId, imagesOmitted };\n\t}\n\n\tsubscribe(listener: AgentListener): () => void {\n\t\treturn this.agent.subscribe(listener);\n\t}\n\n\t/** Adds a lifecycle hook to the live Agent and returns an idempotent disposer. */\n\taddHook(hook: AgentHookRegistration): () => void {\n\t\treturn this.agent.addHook(hook);\n\t}\n\n\tsubscribeSession(listener: AgentSessionListener): () => void {\n\t\tthis.sessionListeners.add(listener);\n\t\treturn () => this.sessionListeners.delete(listener);\n\t}\n\n\tprivate async emitSession(event: AgentSessionEvent): Promise<void> {\n\t\tfor (const listener of this.sessionListeners) await listener(structuredClone(event));\n\t}\n\n\tprivate async emitQueueUpdate(): Promise<void> {\n\t\tawait this.emitSession({\n\t\t\ttype: \"queue_update\",\n\t\t\tsteering: this.steeringMessages.map((message) => message.displayText),\n\t\t});\n\t}\n\n\tprivate addUsage(usage: Usage): void {\n\t\tthis.usageTotals = {\n\t\t\trequestCount: this.usageTotals.requestCount + 1,\n\t\t\tinputTokens: this.usageTotals.inputTokens + usage.input,\n\t\t\toutputTokens: this.usageTotals.outputTokens + usage.output,\n\t\t\tcacheReadTokens: this.usageTotals.cacheReadTokens + usage.cacheRead,\n\t\t\tcacheWriteTokens: this.usageTotals.cacheWriteTokens + usage.cacheWrite,\n\t\t\ttotalTokens: this.usageTotals.totalTokens + usage.totalTokens,\n\t\t\tcost: {\n\t\t\t\tinput: this.usageTotals.cost.input + usage.cost.input,\n\t\t\t\toutput: this.usageTotals.cost.output + usage.cost.output,\n\t\t\t\tcacheRead: this.usageTotals.cost.cacheRead + usage.cost.cacheRead,\n\t\t\t\tcacheWrite: this.usageTotals.cost.cacheWrite + usage.cost.cacheWrite,\n\t\t\t\ttotal: this.usageTotals.cost.total + usage.cost.total,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate async compactIfNeeded(content: readonly UserContent[], signal?: AbortSignal): Promise<void> {\n\t\tif (!this.compactionEnabledValue || !this.sessionManager) return;\n\n\t\tconst context = this.sessionManager.buildContext();\n\t\tconst pendingUser: Message = {\n\t\t\trole: \"user\",\n\t\t\tcontent: structuredClone([...content]),\n\t\t\ttimestamp: 0,\n\t\t};\n\t\tconst estimatedTokens = estimateContextTokens([...context.messages, pendingUser]);\n\t\tif (!shouldCompact(estimatedTokens, this.contextBudget)) return;\n\n\t\tawait this.compactNow(signal, \"threshold\");\n\t}\n\n\tprivate async compactNow(signal: AbortSignal | undefined, reason: \"threshold\" | \"manual\"): Promise<void> {\n\t\tif (!this.sessionManager) throw new Error(\"Cannot compact without a persisted session.\");\n\t\tconst context = this.sessionManager.buildContext();\n\t\tawait this.emitSession({ type: \"compaction_start\", reason });\n\t\tlet messages: readonly Message[];\n\t\ttry {\n\t\t\tmessages = this.compactionTransform ? await this.compactionTransform(context.messages, signal) : context.messages;\n\t\t} catch (cause) {\n\t\t\tconst errorMessage = cause instanceof Error ? cause.message : String(cause);\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow cause;\n\t\t}\n\t\tif (messages.length !== context.messages.length) {\n\t\t\tconst error = new Error(\"Compaction message transform must preserve message count.\");\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage: error.message });\n\t\t\tthrow error;\n\t\t}\n\t\tconst preparation =\n\t\t\tprepareCompaction(messages, this.keepRecentTokens) ??\n\t\t\t(reason === \"manual\" ? this.prepareManualCompaction(messages) : undefined);\n\t\tconst firstKeptEntryId = preparation ? context.sourceEntryIds[preparation.firstKeptMessageIndex] : undefined;\n\t\tif (!preparation || typeof firstKeptEntryId !== \"string\") {\n\t\t\tconst errorMessage =\n\t\t\t\treason === \"manual\"\n\t\t\t\t\t? \"No valid compaction cut point was found for the current session.\"\n\t\t\t\t\t: \"Context limit reached but no valid compaction cut point was found.\";\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\n\t\tlet summary: string;\n\t\ttry {\n\t\t\tsummary = await generateCompactionSummary(preparation, this.provider, this.model, {\n\t\t\t\treserveTokens: this.contextBudget.reserveTokens,\n\t\t\t\tsignal,\n\t\t\t\tnow: this.now,\n\t\t\t\tonUsage: (usage) => this.addUsage(usage),\n\t\t\t});\n\t\t\tawait this.emitSession({ type: \"usage_update\", usage: this.usage });\n\t\t} catch (cause) {\n\t\t\tconst errorMessage = cause instanceof Error ? cause.message : String(cause);\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow cause;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.sessionManager.appendSummary({\n\t\t\t\tsummary,\n\t\t\t\tfirstKeptEntryId,\n\t\t\t\ttokensBefore: preparation.tokensBefore,\n\t\t\t});\n\t\t} catch (cause) {\n\t\t\tthis.persistenceError = cause;\n\t\t\tconst errorMessage = cause instanceof Error ? cause.message : String(cause);\n\t\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: false, errorMessage });\n\t\t\tthrow cause;\n\t\t}\n\n\t\tthis.agent.replaceContext(this.sessionManager.buildContext().messages);\n\t\tawait this.emitSession({ type: \"compaction_end\", reason, success: true });\n\t}\n\n\t/** A manual request may retain only the newest complete user turn when the configured suffix is larger than history. */\n\tprivate prepareManualCompaction(messages: readonly Message[]) {\n\t\tfor (let index = messages.length - 1; index > 0; index--) {\n\t\t\tif (messages[index]?.role !== \"user\") continue;\n\t\t\treturn prepareCompaction(messages, estimateContextTokens(messages.slice(index)));\n\t\t}\n\t\treturn undefined;\n\t}\n}\n"]}
package/dist/entry.js CHANGED
@@ -9,7 +9,7 @@ import { runWebCommand } from "./web-command.js";
9
9
  async function promptProjectTrust(cwd) {
10
10
  const readline = createInterface({ input: process.stdin, output: process.stdout });
11
11
  try {
12
- const answer = await readline.question(`Trust project-local Skills and MCP configuration in ${cwd}? [y/N] `);
12
+ const answer = await readline.question(`Trust project-local plugins, Skills, and MCP configuration in ${cwd}? [y/N] `);
13
13
  return /^(?:y|yes)$/i.test(answer.trim());
14
14
  }
15
15
  finally {
package/dist/entry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,Q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AC;YACnG,CAAC;YACD,iBAAiB,EAAE,GAAG,EAAE;gBACvB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,GAAG;oBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACrG,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;IACtG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { createInterface } from \"node:readline/promises\";\nimport { redactSensitiveText } from \"@di-code/plugin-runtime\";\nimport packageMetadata from \"../package.json\" with { type: \"json\" };\nimport { parseCliArgs } from \"./cli.ts\";\nimport { runMinimalProfile } from \"./main.ts\";\nimport { resolveStartupArgs } from \"./startup.ts\";\nimport { runWebCommand } from \"./web-command.ts\";\n\nasync function promptProjectTrust(cwd: string): Promise<boolean> {\n\tconst readline = createInterface({ input: process.stdin, output: process.stdout });\n\ttry {\n\t\tconst answer = await readline.question(`Trust project-local Skills and MCP configuration in ${cwd}? [y/N] `);\n\t\treturn /^(?:y|yes)$/i.test(answer.trim());\n\t} finally {\n\t\treadline.close();\n\t}\n}\n\ntry {\n\tconst rawArgs = process.argv.slice(2);\n\tconst args = resolveStartupArgs(rawArgs);\n\tconst command = parseCliArgs(args);\n\tif (command.kind === \"web\") {\n\t\tprocess.exitCode = await runWebCommand(command);\n\t} else {\n\t\tconst isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);\n\t\tprocess.exitCode = await runMinimalProfile(args, {\n\t\t\tversion: packageMetadata.version,\n\t\t\tstdout: (text) => process.stdout.write(text),\n\t\t\tstderr: (text) => process.stderr.write(text),\n\t\t\tinteractive: { isInteractiveTerminal, promptProjectTrust },\n\t\t\tonRuntimeEvent: (event) => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write(`${JSON.stringify(event)}\\n`);\n\t\t\t},\n\t\t\tonSessionDisposed: () => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write('{\"type\":\"session_dispose\"}\\n');\n\t\t\t},\n\t\t});\n\t}\n} catch (cause) {\n\tconst message = redactSensitiveText(cause instanceof Error ? cause.message : \"Unknown startup error\");\n\tprocess.stderr.write(`${message}\\n`);\n\tprocess.exitCode = 1;\n}\n"]}
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,KAAK,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,QAAQ,CACrC,iEAAiE,GAAG,UAAU,CAC9E,CAAC;QACF,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAA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,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACrG,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;IACtG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { createInterface } from \"node:readline/promises\";\nimport { redactSensitiveText } from \"@di-code/plugin-runtime\";\nimport packageMetadata from \"../package.json\" with { type: \"json\" };\nimport { parseCliArgs } from \"./cli.ts\";\nimport { runMinimalProfile } from \"./main.ts\";\nimport { resolveStartupArgs } from \"./startup.ts\";\nimport { runWebCommand } from \"./web-command.ts\";\n\nasync function promptProjectTrust(cwd: string): Promise<boolean> {\n\tconst readline = createInterface({ input: process.stdin, output: process.stdout });\n\ttry {\n\t\tconst answer = await readline.question(\n\t\t\t`Trust project-local plugins, Skills, and MCP configuration in ${cwd}? [y/N] `,\n\t\t);\n\t\treturn /^(?:y|yes)$/i.test(answer.trim());\n\t} finally {\n\t\treadline.close();\n\t}\n}\n\ntry {\n\tconst rawArgs = process.argv.slice(2);\n\tconst args = resolveStartupArgs(rawArgs);\n\tconst command = parseCliArgs(args);\n\tif (command.kind === \"web\") {\n\t\tprocess.exitCode = await runWebCommand(command);\n\t} else {\n\t\tconst isInteractiveTerminal = Boolean(process.stdin.isTTY && process.stdout.isTTY);\n\t\tprocess.exitCode = await runMinimalProfile(args, {\n\t\t\tversion: packageMetadata.version,\n\t\t\tstdout: (text) => process.stdout.write(text),\n\t\t\tstderr: (text) => process.stderr.write(text),\n\t\t\tinteractive: { isInteractiveTerminal, promptProjectTrust },\n\t\t\tonRuntimeEvent: (event) => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write(`${JSON.stringify(event)}\\n`);\n\t\t\t},\n\t\t\tonSessionDisposed: () => {\n\t\t\t\tif (process.env.DI_CODE_TRACE_PLUGINS === \"1\") process.stderr.write('{\"type\":\"session_dispose\"}\\n');\n\t\t\t},\n\t\t});\n\t}\n} catch (cause) {\n\tconst message = redactSensitiveText(cause instanceof Error ? cause.message : \"Unknown startup error\");\n\tprocess.stderr.write(`${message}\\n`);\n\tprocess.exitCode = 1;\n}\n"]}
package/dist/i18n.js CHANGED
@@ -12,8 +12,8 @@ const MESSAGES = {
12
12
  skill: "Add a SKILL.md file or skill directory (repeatable)",
13
13
  noSkills: "Disable all Skill loading",
14
14
  noContextFiles: "Disable AGENTS.md discovery and loading",
15
- trustProject: "Persist trust for project-local Skill discovery",
16
- untrustProject: "Persist denial for project-local Skill discovery",
15
+ trustProject: "Persist trust for project-local plugins, Skills, and MCP configuration",
16
+ untrustProject: "Persist denial for project-local plugins, Skills, and MCP configuration",
17
17
  plugin: "Install, list, enable, disable, update, or remove a plugin",
18
18
  mcp: "Manage MCP configuration (add <id> -- <command> defaults to local stdio)",
19
19
  help: "Show help",
@@ -119,8 +119,8 @@ const MESSAGES = {
119
119
  skill: "加载一个 SKILL.md 文件或技能目录(可重复)",
120
120
  noSkills: "禁用所有 Skill 加载",
121
121
  noContextFiles: "禁用 AGENTS.md 发现和加载",
122
- trustProject: "保存对项目本地 Skill 的信任",
123
- untrustProject: "保存对项目本地 Skill 的拒绝",
122
+ trustProject: "保存对项目本地插件、Skill 和 MCP 配置的信任",
123
+ untrustProject: "保存对项目本地插件、Skill 和 MCP 配置的拒绝",
124
124
  plugin: "安装、列出、启用、禁用、更新或移除插件",
125
125
  mcp: "管理 MCP 配置(add <id> -- <command> 默认为本地 stdio)",
126
126
  help: "显示帮助",
package/dist/i18n.js.map CHANGED
@@ -1 +1 @@
1
- {"version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;AAED,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,GAAW,EAAE,GAAG,MAAgB;IACzE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAC9E,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACrE,CAAC","sourcesContent":["export type Locale = \"en\" | \"zh-CN\";\n\nexport const DEFAULT_LOCALE: Locale = \"en\";\n\ntype Message = string | ((...values: string[]) => string);\n\nconst MESSAGES: Record<Locale, Record<string, Message>> = {\n\ten: {\n\t\tusage: \"Usage: di-code [options] <prompt>\",\n\t\toptions: \"Options:\",\n\t\tprint: \"Print only the final assistant text (default)\",\n\t\tmode: \"Output mode: print, json, or interactive\",\n\t\tinteractive: \"Start interactive terminal mode\",\n\t\tcontinueSession: \"Continue the most recently modified session\",\n\t\tsession: \"Create or resume a JSONL session (relative to the work root)\",\n\t\timage: \"Attach a local PNG, JPEG, WebP, or GIF image (repeatable)\",\n\t\tskill: \"Add a SKILL.md file or skill directory (repeatable)\",\n\t\tnoSkills: \"Disable all Skill loading\",\n\t\tnoContextFiles: \"Disable AGENTS.md discovery and loading\",\n\t\ttrustProject: \"Persist trust for project-local Skill discovery\",\n\t\tuntrustProject: \"Persist denial for project-local Skill discovery\",\n\t\tplugin: \"Install, list, enable, disable, update, or remove a plugin\",\n\t\tmcp: \"Manage MCP configuration (add <id> -- <command> defaults to local stdio)\",\n\t\thelp: \"Show help\",\n\t\tversion: \"Show version\",\n\t\tcommands: \"commands\",\n\t\tcomplete: \"complete\",\n\t\tworking: \"WORKING\",\n\t\tready: \"READY\",\n\t\terror: \"ERROR\",\n\t\tcompacting: \"COMPACTING\",\n\t\tretrying: \"RETRYING\",\n\t\tthinking: \"Thinking\",\n\t\tactivity: \"Activity\",\n\t\tqueue: (count) => `Queue (${count})`,\n\t\terrorPrefix: \"Error\",\n\t\tedited: \"Edited\",\n\t\twrote: \"Wrote\",\n\t\tearlierToolUpdates: (count) => `${count} earlier tool updates`,\n\t\tmessages: (count) => `${count} messages`,\n\t\tcontext: \"ctx\",\n\t\ttotal: \"total\",\n\t\ttokens: \"tok\",\n\t\tsend: \"send\",\n\t\tpasteImage: \"paste image\",\n\t\tthinkingShortcut: \"thinking\",\n\t\tcancel: \"cancel\",\n\t\tcancelled: \"Cancelled\",\n\t\tmodel: \"model\",\n\t\timageShortcut: \"image\",\n\t\tlanguage: \"Language\",\n\t\tsettings: \"Settings\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"Context compaction\",\n\t\ton: \"on\",\n\t\toff: \"off\",\n\t\tcompactionUnavailable: \"compaction unavailable without a persisted session\",\n\t\tvisibleMessagesCleared: \"visible messages cleared\",\n\t\tnothingToRetry: \"nothing to retry\",\n\t\tmanualCompactionStarting: \"starting manual compaction\",\n\t\tmanualCompactionComplete: \"manual compaction complete\",\n\t\tcurrentSession: \"Current session\",\n\t\tinMemorySession: \"In-memory session\",\n\t\tnewSession: \"New session\",\n\t\tnewSessionDescription: \"Start a new persistent conversation.\",\n\t\tdark: \"Dark\",\n\t\tlight: \"Light\",\n\t\tdarkTheme: \"Dark terminal theme\",\n\t\tlightTheme: \"Light terminal theme\",\n\t\topenModelSelector: \"Open the model selector\",\n\t\topenSessionSelector: \"Open the session selector\",\n\t\topenTreeSelector: \"Browse the current session tree\",\n\t\ttreeTitle: \"Branch tree\",\n\t\ttreeNodes: \"Branches\",\n\t\ttreePreview: \"Preview\",\n\t\ttreeEmpty: \"The current session has no history nodes.\",\n\t\ttreeActiveLeaf: \"active leaf\",\n\t\ttreeBranchNode: \"branch node\",\n\t\ttreeImagesOmitted: \"Images are not restored when editing this prompt.\",\n\t\ttreeContinue: \"Continue\",\n\t\ttreeEdit: \"Edit prompt\",\n\t\ttreeSummarize: \"Summarize + branch\",\n\t\ttreeCancel: \"Cancel\",\n\t\topenThemeSelector: \"Open the theme selector\",\n\t\topenSettingsSelector: \"Open the settings selector\",\n\t\tshowInteractiveCommands: \"Show interactive commands\",\n\t\tclearVisibleMessages: \"Clear visible messages\",\n\t\tchooseProvider: \"Choose a Provider and save its global API key\",\n\t\tremoveProviderKey: \"Remove the current Provider global API key\",\n\t\tcompactContext: \"Compact the persisted context now\",\n\t\tshowUsage: \"Show token and cost usage\",\n\t\tretryPrompt: \"Retry the last failed prompt\",\n\t\tsteerAgent: \"Steer the running agent\",\n\t\tproviderSetup: \"di-code provider setup\",\n\t\tlogin: \"di-code login\",\n\t\tselectProvider: \"Select a provider:\",\n\t\tselectProviderModel: (provider) => `Select a ${provider} model:`,\n\t\tenterApiKey: (name) => `Enter ${name} (input is hidden):`,\n\t\tapiKeyRequired: \"API key cannot be empty. Press Escape to cancel.\",\n\t\tproviderSetupCancelled: \"Provider setup cancelled.\",\n\t\tproviderConfigured: \"Provider configured for this run.\",\n\t\tproviderSetupFailed: \"Provider setup failed.\",\n\t\treasoning: \"reasoning\",\n\t\tfauxProvider: \"Deterministic local provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"Configure a compatible gateway or private endpoint\",\n\t\tselectCustomApi: \"Select an API protocol:\",\n\t\tenterCustomBaseUrl: \"Enter the API base URL (for example, https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"Enter API key (input is hidden):\",\n\t\tenterCustomModelId: \"Enter model ID:\",\n\t\tmodelIdRequired: \"Model ID cannot be empty. Press Escape to cancel.\",\n\t\tcustomBaseUrlInvalid: \"Base URL is invalid.\",\n\t},\n\t\"zh-CN\": {\n\t\tusage: \"用法:di-code [选项] <提示词>\",\n\t\toptions: \"选项:\",\n\t\tprint: \"只输出最终 assistant 文本(默认)\",\n\t\tmode: \"输出模式:print、json 或 interactive\",\n\t\tinteractive: \"启动交互式终端模式\",\n\t\tcontinueSession: \"继续最近修改的会话\",\n\t\tsession: \"创建或恢复 JSONL 会话(相对工作根目录)\",\n\t\timage: \"附加本地 PNG、JPEG、WebP 或 GIF 图片(可重复)\",\n\t\tskill: \"加载一个 SKILL.md 文件或技能目录(可重复)\",\n\t\tnoSkills: \"禁用所有 Skill 加载\",\n\t\tnoContextFiles: \"禁用 AGENTS.md 发现和加载\",\n\t\ttrustProject: \"保存对项目本地 Skill 的信任\",\n\t\tuntrustProject: \"保存对项目本地 Skill 的拒绝\",\n\t\tplugin: \"安装、列出、启用、禁用、更新或移除插件\",\n\t\tmcp: \"管理 MCP 配置(add <id> -- <command> 默认为本地 stdio)\",\n\t\thelp: \"显示帮助\",\n\t\tversion: \"显示版本\",\n\t\tcommands: \"命令\",\n\t\tcomplete: \"补全\",\n\t\tworking: \"工作中\",\n\t\tready: \"就绪\",\n\t\terror: \"错误\",\n\t\tcompacting: \"压缩中\",\n\t\tretrying: \"重试中\",\n\t\tthinking: \"思考中\",\n\t\tactivity: \"活动\",\n\t\tqueue: (count) => `队列(${count})`,\n\t\terrorPrefix: \"错误\",\n\t\tedited: \"已编辑\",\n\t\twrote: \"已写入\",\n\t\tearlierToolUpdates: (count) => `之前还有 ${count} 条工具更新`,\n\t\tmessages: (count) => `${count} 条消息`,\n\t\tcontext: \"上下文\",\n\t\ttotal: \"总计\",\n\t\ttokens: \"token\",\n\t\tsend: \"发送\",\n\t\tpasteImage: \"粘贴图片\",\n\t\tthinkingShortcut: \"思考\",\n\t\tcancel: \"取消\",\n\t\tcancelled: \"已取消\",\n\t\tmodel: \"模型\",\n\t\timageShortcut: \"图片\",\n\t\tlanguage: \"语言\",\n\t\tsettings: \"设置\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"上下文压缩\",\n\t\ton: \"开\",\n\t\toff: \"关\",\n\t\tcompactionUnavailable: \"没有持久化会话,无法进行上下文压缩\",\n\t\tvisibleMessagesCleared: \"已清除可见消息\",\n\t\tnothingToRetry: \"没有可重试的内容\",\n\t\tmanualCompactionStarting: \"开始手动压缩\",\n\t\tmanualCompactionComplete: \"手动压缩完成\",\n\t\tcurrentSession: \"当前会话\",\n\t\tinMemorySession: \"内存会话\",\n\t\tnewSession: \"新建会话\",\n\t\tnewSessionDescription: \"开始新的持久化对话。\",\n\t\tdark: \"深色\",\n\t\tlight: \"浅色\",\n\t\tdarkTheme: \"深色终端主题\",\n\t\tlightTheme: \"浅色终端主题\",\n\t\topenModelSelector: \"打开模型选择器\",\n\t\topenSessionSelector: \"打开会话选择器\",\n\t\topenTreeSelector: \"浏览当前会话树\",\n\t\ttreeTitle: \"分支树\",\n\t\ttreeNodes: \"分支\",\n\t\ttreePreview: \"预览\",\n\t\ttreeEmpty: \"当前会话还没有历史节点。\",\n\t\ttreeActiveLeaf: \"当前叶节点\",\n\t\ttreeBranchNode: \"分支节点\",\n\t\ttreeImagesOmitted: \"编辑此提示词时不会恢复图片。\",\n\t\ttreeContinue: \"从此处继续\",\n\t\ttreeEdit: \"编辑提示词\",\n\t\ttreeSummarize: \"摘要后分支\",\n\t\ttreeCancel: \"取消\",\n\t\topenThemeSelector: \"打开主题选择器\",\n\t\topenSettingsSelector: \"打开设置选择器\",\n\t\tshowInteractiveCommands: \"显示交互命令\",\n\t\tclearVisibleMessages: \"清除可见消息\",\n\t\tchooseProvider: \"选择 Provider 并保存全局 API key\",\n\t\tremoveProviderKey: \"移除当前 Provider 的全局 API key\",\n\t\tcompactContext: \"立即压缩持久化上下文\",\n\t\tshowUsage: \"显示 token 和费用用量\",\n\t\tretryPrompt: \"重试上次失败的提示词\",\n\t\tsteerAgent: \"调整运行中的 Agent\",\n\t\tproviderSetup: \"di-code Provider 设置\",\n\t\tlogin: \"di-code 登录\",\n\t\tselectProvider: \"选择 Provider:\",\n\t\tselectProviderModel: (provider) => `选择 ${provider} 模型:`,\n\t\tenterApiKey: (name) => `输入 ${name}(输入内容会隐藏):`,\n\t\tapiKeyRequired: \"API key 不能为空。按 Escape 取消。\",\n\t\tproviderSetupCancelled: \"已取消 Provider 设置。\",\n\t\tproviderConfigured: \"已为本次运行配置 Provider。\",\n\t\tproviderSetupFailed: \"Provider 设置失败。\",\n\t\treasoning: \"推理\",\n\t\tfauxProvider: \"确定性的本地 Provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"配置兼容网关或私有 endpoint\",\n\t\tselectCustomApi: \"选择 API 协议:\",\n\t\tenterCustomBaseUrl: \"输入 API 根地址(例如 https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"输入 API key(输入内容会隐藏):\",\n\t\tenterCustomModelId: \"输入模型 ID:\",\n\t\tmodelIdRequired: \"模型 ID 不能为空。按 Escape 取消。\",\n\t\tcustomBaseUrlInvalid: \"Base URL 无效。\",\n\t},\n};\n\nexport function isLocale(value: unknown): value is Locale {\n\treturn value === \"en\" || value === \"zh-CN\";\n}\n\nexport function translate(locale: Locale, key: string, ...values: string[]): string {\n\tconst message = MESSAGES[locale][key] ?? MESSAGES[DEFAULT_LOCALE][key] ?? key;\n\treturn typeof message === \"function\" ? message(...values) : message;\n}\n"]}
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAW,IAAI,CAAC;AAI3C,MAAM,QAAQ,GAA4C;IACzD,EAAE,EAAE;QACH,KAAK,EAAE,mCAAmC;QAC1C,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,+CAA+C;QACtD,IAAI,EAAE,0CAA0C;QAChD,WAAW,EAAE,iCAAiC;QAC9C,eAAe,EAAE,6CAA6C;QAC9D,OAAO,EAAE,8DAA8D;QACvE,KAAK,EAAE,2DAA2D;QAClE,KAAK,EAAE,qDAAqD;QAC5D,QAAQ,EAAE,2BAA2B;QACrC,cAAc,EAAE,yCAAyC;QACzD,YAAY,EAAE,wEAAwE;QACtF,cAAc,EAAE,yEAAyE;QACzF,MAAM,EAAE,4DAA4D;QACpE,GAA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ACpC,KAAK,EAAE,YAAY;QACnB,cAAc,EAAE,cAAc;QAC9B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,QAAQ,MAAM;QACvD,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,YAAY;QAC7C,cAAc,EAAE,2BAA2B;QAC3C,sBAAsB,EAAE,kBAAkB;QAC1C,kBAAkB,EAAE,oBAAoB;QACxC,mBAAmB,EAAE,gBAAgB;QACrC,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,QAAQ;QACxB,yBAAyB,EAAE,oBAAoB;QAC/C,eAAe,EAAE,YAAY;QAC7B,kBAAkB,EAAE,gDAAgD;QACpE,iBAAiB,EAAE,sBAAsB;QACzC,kBAAkB,EAAE,UAAU;QAC9B,eAAe,EAAE,yBAAyB;QAC1C,oBAAoB,EAAE,cAAc;KACpC;CACD,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,KAAc;IACtC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,OAAO,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,GAAW,EAAE,GAAG,MAAgB;IACzE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAC9E,OAAO,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACrE,CAAC","sourcesContent":["export type Locale = \"en\" | \"zh-CN\";\n\nexport const DEFAULT_LOCALE: Locale = \"en\";\n\ntype Message = string | ((...values: string[]) => string);\n\nconst MESSAGES: Record<Locale, Record<string, Message>> = {\n\ten: {\n\t\tusage: \"Usage: di-code [options] <prompt>\",\n\t\toptions: \"Options:\",\n\t\tprint: \"Print only the final assistant text (default)\",\n\t\tmode: \"Output mode: print, json, or interactive\",\n\t\tinteractive: \"Start interactive terminal mode\",\n\t\tcontinueSession: \"Continue the most recently modified session\",\n\t\tsession: \"Create or resume a JSONL session (relative to the work root)\",\n\t\timage: \"Attach a local PNG, JPEG, WebP, or GIF image (repeatable)\",\n\t\tskill: \"Add a SKILL.md file or skill directory (repeatable)\",\n\t\tnoSkills: \"Disable all Skill loading\",\n\t\tnoContextFiles: \"Disable AGENTS.md discovery and loading\",\n\t\ttrustProject: \"Persist trust for project-local plugins, Skills, and MCP configuration\",\n\t\tuntrustProject: \"Persist denial for project-local plugins, Skills, and MCP configuration\",\n\t\tplugin: \"Install, list, enable, disable, update, or remove a plugin\",\n\t\tmcp: \"Manage MCP configuration (add <id> -- <command> defaults to local stdio)\",\n\t\thelp: \"Show help\",\n\t\tversion: \"Show version\",\n\t\tcommands: \"commands\",\n\t\tcomplete: \"complete\",\n\t\tworking: \"WORKING\",\n\t\tready: \"READY\",\n\t\terror: \"ERROR\",\n\t\tcompacting: \"COMPACTING\",\n\t\tretrying: \"RETRYING\",\n\t\tthinking: \"Thinking\",\n\t\tactivity: \"Activity\",\n\t\tqueue: (count) => `Queue (${count})`,\n\t\terrorPrefix: \"Error\",\n\t\tedited: \"Edited\",\n\t\twrote: \"Wrote\",\n\t\tearlierToolUpdates: (count) => `${count} earlier tool updates`,\n\t\tmessages: (count) => `${count} messages`,\n\t\tcontext: \"ctx\",\n\t\ttotal: \"total\",\n\t\ttokens: \"tok\",\n\t\tsend: \"send\",\n\t\tpasteImage: \"paste image\",\n\t\tthinkingShortcut: \"thinking\",\n\t\tcancel: \"cancel\",\n\t\tcancelled: \"Cancelled\",\n\t\tmodel: \"model\",\n\t\timageShortcut: \"image\",\n\t\tlanguage: \"Language\",\n\t\tsettings: \"Settings\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"Context compaction\",\n\t\ton: \"on\",\n\t\toff: \"off\",\n\t\tcompactionUnavailable: \"compaction unavailable without a persisted session\",\n\t\tvisibleMessagesCleared: \"visible messages cleared\",\n\t\tnothingToRetry: \"nothing to retry\",\n\t\tmanualCompactionStarting: \"starting manual compaction\",\n\t\tmanualCompactionComplete: \"manual compaction complete\",\n\t\tcurrentSession: \"Current session\",\n\t\tinMemorySession: \"In-memory session\",\n\t\tnewSession: \"New session\",\n\t\tnewSessionDescription: \"Start a new persistent conversation.\",\n\t\tdark: \"Dark\",\n\t\tlight: \"Light\",\n\t\tdarkTheme: \"Dark terminal theme\",\n\t\tlightTheme: \"Light terminal theme\",\n\t\topenModelSelector: \"Open the model selector\",\n\t\topenSessionSelector: \"Open the session selector\",\n\t\topenTreeSelector: \"Browse the current session tree\",\n\t\ttreeTitle: \"Branch tree\",\n\t\ttreeNodes: \"Branches\",\n\t\ttreePreview: \"Preview\",\n\t\ttreeEmpty: \"The current session has no history nodes.\",\n\t\ttreeActiveLeaf: \"active leaf\",\n\t\ttreeBranchNode: \"branch node\",\n\t\ttreeImagesOmitted: \"Images are not restored when editing this prompt.\",\n\t\ttreeContinue: \"Continue\",\n\t\ttreeEdit: \"Edit prompt\",\n\t\ttreeSummarize: \"Summarize + branch\",\n\t\ttreeCancel: \"Cancel\",\n\t\topenThemeSelector: \"Open the theme selector\",\n\t\topenSettingsSelector: \"Open the settings selector\",\n\t\tshowInteractiveCommands: \"Show interactive commands\",\n\t\tclearVisibleMessages: \"Clear visible messages\",\n\t\tchooseProvider: \"Choose a Provider and save its global API key\",\n\t\tremoveProviderKey: \"Remove the current Provider global API key\",\n\t\tcompactContext: \"Compact the persisted context now\",\n\t\tshowUsage: \"Show token and cost usage\",\n\t\tretryPrompt: \"Retry the last failed prompt\",\n\t\tsteerAgent: \"Steer the running agent\",\n\t\tproviderSetup: \"di-code provider setup\",\n\t\tlogin: \"di-code login\",\n\t\tselectProvider: \"Select a provider:\",\n\t\tselectProviderModel: (provider) => `Select a ${provider} model:`,\n\t\tenterApiKey: (name) => `Enter ${name} (input is hidden):`,\n\t\tapiKeyRequired: \"API key cannot be empty. Press Escape to cancel.\",\n\t\tproviderSetupCancelled: \"Provider setup cancelled.\",\n\t\tproviderConfigured: \"Provider configured for this run.\",\n\t\tproviderSetupFailed: \"Provider setup failed.\",\n\t\treasoning: \"reasoning\",\n\t\tfauxProvider: \"Deterministic local provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"Configure a compatible gateway or private endpoint\",\n\t\tselectCustomApi: \"Select an API protocol:\",\n\t\tenterCustomBaseUrl: \"Enter the API base URL (for example, https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"Enter API key (input is hidden):\",\n\t\tenterCustomModelId: \"Enter model ID:\",\n\t\tmodelIdRequired: \"Model ID cannot be empty. Press Escape to cancel.\",\n\t\tcustomBaseUrlInvalid: \"Base URL is invalid.\",\n\t},\n\t\"zh-CN\": {\n\t\tusage: \"用法:di-code [选项] <提示词>\",\n\t\toptions: \"选项:\",\n\t\tprint: \"只输出最终 assistant 文本(默认)\",\n\t\tmode: \"输出模式:print、json 或 interactive\",\n\t\tinteractive: \"启动交互式终端模式\",\n\t\tcontinueSession: \"继续最近修改的会话\",\n\t\tsession: \"创建或恢复 JSONL 会话(相对工作根目录)\",\n\t\timage: \"附加本地 PNG、JPEG、WebP 或 GIF 图片(可重复)\",\n\t\tskill: \"加载一个 SKILL.md 文件或技能目录(可重复)\",\n\t\tnoSkills: \"禁用所有 Skill 加载\",\n\t\tnoContextFiles: \"禁用 AGENTS.md 发现和加载\",\n\t\ttrustProject: \"保存对项目本地插件、Skill 和 MCP 配置的信任\",\n\t\tuntrustProject: \"保存对项目本地插件、Skill 和 MCP 配置的拒绝\",\n\t\tplugin: \"安装、列出、启用、禁用、更新或移除插件\",\n\t\tmcp: \"管理 MCP 配置(add <id> -- <command> 默认为本地 stdio)\",\n\t\thelp: \"显示帮助\",\n\t\tversion: \"显示版本\",\n\t\tcommands: \"命令\",\n\t\tcomplete: \"补全\",\n\t\tworking: \"工作中\",\n\t\tready: \"就绪\",\n\t\terror: \"错误\",\n\t\tcompacting: \"压缩中\",\n\t\tretrying: \"重试中\",\n\t\tthinking: \"思考中\",\n\t\tactivity: \"活动\",\n\t\tqueue: (count) => `队列(${count})`,\n\t\terrorPrefix: \"错误\",\n\t\tedited: \"已编辑\",\n\t\twrote: \"已写入\",\n\t\tearlierToolUpdates: (count) => `之前还有 ${count} 条工具更新`,\n\t\tmessages: (count) => `${count} 条消息`,\n\t\tcontext: \"上下文\",\n\t\ttotal: \"总计\",\n\t\ttokens: \"token\",\n\t\tsend: \"发送\",\n\t\tpasteImage: \"粘贴图片\",\n\t\tthinkingShortcut: \"思考\",\n\t\tcancel: \"取消\",\n\t\tcancelled: \"已取消\",\n\t\tmodel: \"模型\",\n\t\timageShortcut: \"图片\",\n\t\tlanguage: \"语言\",\n\t\tsettings: \"设置\",\n\t\tenglish: \"English\",\n\t\tchinese: \"中文\",\n\t\tcontextCompaction: \"上下文压缩\",\n\t\ton: \"开\",\n\t\toff: \"关\",\n\t\tcompactionUnavailable: \"没有持久化会话,无法进行上下文压缩\",\n\t\tvisibleMessagesCleared: \"已清除可见消息\",\n\t\tnothingToRetry: \"没有可重试的内容\",\n\t\tmanualCompactionStarting: \"开始手动压缩\",\n\t\tmanualCompactionComplete: \"手动压缩完成\",\n\t\tcurrentSession: \"当前会话\",\n\t\tinMemorySession: \"内存会话\",\n\t\tnewSession: \"新建会话\",\n\t\tnewSessionDescription: \"开始新的持久化对话。\",\n\t\tdark: \"深色\",\n\t\tlight: \"浅色\",\n\t\tdarkTheme: \"深色终端主题\",\n\t\tlightTheme: \"浅色终端主题\",\n\t\topenModelSelector: \"打开模型选择器\",\n\t\topenSessionSelector: \"打开会话选择器\",\n\t\topenTreeSelector: \"浏览当前会话树\",\n\t\ttreeTitle: \"分支树\",\n\t\ttreeNodes: \"分支\",\n\t\ttreePreview: \"预览\",\n\t\ttreeEmpty: \"当前会话还没有历史节点。\",\n\t\ttreeActiveLeaf: \"当前叶节点\",\n\t\ttreeBranchNode: \"分支节点\",\n\t\ttreeImagesOmitted: \"编辑此提示词时不会恢复图片。\",\n\t\ttreeContinue: \"从此处继续\",\n\t\ttreeEdit: \"编辑提示词\",\n\t\ttreeSummarize: \"摘要后分支\",\n\t\ttreeCancel: \"取消\",\n\t\topenThemeSelector: \"打开主题选择器\",\n\t\topenSettingsSelector: \"打开设置选择器\",\n\t\tshowInteractiveCommands: \"显示交互命令\",\n\t\tclearVisibleMessages: \"清除可见消息\",\n\t\tchooseProvider: \"选择 Provider 并保存全局 API key\",\n\t\tremoveProviderKey: \"移除当前 Provider 的全局 API key\",\n\t\tcompactContext: \"立即压缩持久化上下文\",\n\t\tshowUsage: \"显示 token 和费用用量\",\n\t\tretryPrompt: \"重试上次失败的提示词\",\n\t\tsteerAgent: \"调整运行中的 Agent\",\n\t\tproviderSetup: \"di-code Provider 设置\",\n\t\tlogin: \"di-code 登录\",\n\t\tselectProvider: \"选择 Provider:\",\n\t\tselectProviderModel: (provider) => `选择 ${provider} 模型:`,\n\t\tenterApiKey: (name) => `输入 ${name}(输入内容会隐藏):`,\n\t\tapiKeyRequired: \"API key 不能为空。按 Escape 取消。\",\n\t\tproviderSetupCancelled: \"已取消 Provider 设置。\",\n\t\tproviderConfigured: \"已为本次运行配置 Provider。\",\n\t\tproviderSetupFailed: \"Provider 设置失败。\",\n\t\treasoning: \"推理\",\n\t\tfauxProvider: \"确定性的本地 Provider\",\n\t\tcustomProvider: \"Custom\",\n\t\tcustomProviderDescription: \"配置兼容网关或私有 endpoint\",\n\t\tselectCustomApi: \"选择 API 协议:\",\n\t\tenterCustomBaseUrl: \"输入 API 根地址(例如 https://gateway.example.com/v1):\",\n\t\tenterCustomApiKey: \"输入 API key(输入内容会隐藏):\",\n\t\tenterCustomModelId: \"输入模型 ID:\",\n\t\tmodelIdRequired: \"模型 ID 不能为空。按 Escape 取消。\",\n\t\tcustomBaseUrlInvalid: \"Base URL 无效。\",\n\t},\n};\n\nexport function isLocale(value: unknown): value is Locale {\n\treturn value === \"en\" || value === \"zh-CN\";\n}\n\nexport function translate(locale: Locale, key: string, ...values: string[]): string {\n\tconst message = MESSAGES[locale][key] ?? MESSAGES[DEFAULT_LOCALE][key] ?? key;\n\treturn typeof message === \"function\" ? message(...values) : message;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-host-entry.d.ts","sourceRoot":"","sources":["../src/interactive-host-entry.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA6BhE,+FAA+F;AAC/F,eAAO,MAAM,UAAU,EAAG,CAAU,CAAC;AACrC,eAAO,MAAM,IAAI,qBAAqB,CAAC;AACvC,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,KAAK,EAAE,gBAAgB,CAAC,OAAO,CA6F3C,CAAC"}
1
+ {"version":3,"file":"interactive-host-entry.d.ts","sourceRoot":"","sources":["../src/interactive-host-entry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAyGhE,+FAA+F;AAC/F,eAAO,MAAM,UAAU,EAAG,CAAU,CAAC;AACrC,eAAO,MAAM,IAAI,qBAAqB,CAAC;AACvC,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,KAAK,EAAE,gBAAgB,CAAC,OAAO,CA+H3C,CAAC"}
@@ -1,11 +1,71 @@
1
1
  import { basename, extname, resolve } from "node:path";
2
2
  import { commandRegistryKey, hostCommandRegistryKey, interactiveContextKey, keybindingRegistryKey, modeRegistryKey, } from "@di-code/builtins";
3
+ import { redactSensitiveText } from "@di-code/plugin-runtime";
4
+ import { createUserInteraction } from "@di-code/plugin-sdk";
3
5
  import { ProcessTerminal } from "@di-code/tui";
4
6
  import { DEFAULT_LOCALE, translate } from "./i18n.js";
5
7
  import { runInteractiveMode } from "./modes/interactive-entry.js";
6
8
  import { runProviderOnboarding, shouldStartProviderOnboarding } from "./provider-onboarding.js";
9
+ import { pluginInventoryKey } from "./runtime/plugin-inventory-service.js";
7
10
  import { createSessionHost } from "./runtime/session-host.js";
8
11
  import { loadStartupConfiguration, resolveStartupRuntime } from "./startup.js";
12
+ const ANSI = {
13
+ reset: "\u001b[0m",
14
+ bold: "\u001b[1m",
15
+ dim: "\u001b[2m",
16
+ cyan: "\u001b[36m",
17
+ blue: "\u001b[34m",
18
+ green: "\u001b[32m",
19
+ yellow: "\u001b[33m",
20
+ red: "\u001b[31m",
21
+ gray: "\u001b[90m",
22
+ magenta: "\u001b[35m",
23
+ };
24
+ function paint(value, color) {
25
+ return `${ANSI[color]}${value}${ANSI.reset}`;
26
+ }
27
+ function paintStatus(status) {
28
+ const color = status === "active" || status === "connected"
29
+ ? "green"
30
+ : status === "failed"
31
+ ? "red"
32
+ : status === "disabled"
33
+ ? "gray"
34
+ : "yellow";
35
+ return paint(status, color);
36
+ }
37
+ function printStartupResources(request, inventory, startup) {
38
+ const projectEntries = inventory?.entries.filter((record) => record.entry.projectLocal || record.entry.id.startsWith("managed.") || record.status === "failed") ?? [];
39
+ const hasDetails = projectEntries.length > 0 ||
40
+ startup.skills.length > 0 ||
41
+ startup.resourceDiagnostics.length > 0 ||
42
+ startup.mcpServers.length > 0 ||
43
+ startup.mcpDiagnostics.length > 0;
44
+ if (!hasDetails)
45
+ return;
46
+ const lines = ["", `${paint("di-code startup resources", "bold")}:`, ` ${paint("Plugins", "cyan")}:`];
47
+ if (projectEntries.length === 0)
48
+ lines.push(` ${paint("- none", "dim")}`);
49
+ for (const record of projectEntries) {
50
+ const reason = record.error ? `: ${redactSensitiveText(record.error.message)}` : "";
51
+ lines.push(` - ${record.entry.id}: ${paintStatus(record.status)}${reason}`);
52
+ }
53
+ lines.push(` ${paint("Skills", "magenta")}:`);
54
+ if (startup.skills.length === 0)
55
+ lines.push(` ${paint("- none", "dim")}`);
56
+ for (const skill of startup.skills)
57
+ lines.push(` - ${paint(skill.name, "magenta")} ${paint(`(${skill.scope})`, "dim")}`);
58
+ for (const diagnostic of startup.resourceDiagnostics)
59
+ lines.push(` - ${paint(`${diagnostic.kind} ${diagnostic.severity}`, diagnostic.severity === "error" ? "red" : "yellow")}: ${diagnostic.path}: ${diagnostic.message}`);
60
+ lines.push(` ${paint("MCP", "blue")}:`);
61
+ if (startup.mcpServers.length === 0 && startup.mcpDiagnostics.length === 0)
62
+ lines.push(` ${paint("- none", "dim")}`);
63
+ for (const server of startup.mcpServers)
64
+ lines.push(` - ${server.id}: ${paintStatus("connected")} ${paint(`(tools ${server.tools}, resources ${server.resources}, prompts ${server.prompts})`, "dim")}`);
65
+ for (const diagnostic of startup.mcpDiagnostics)
66
+ lines.push(` - ${diagnostic.serverId}: ${paintStatus("failed")} (${diagnostic.stage}): ${redactSensitiveText(diagnostic.message)}`);
67
+ request.stderr(`${lines.join("\n")}\n\n`);
68
+ }
9
69
  function isInteractiveHostRequest(value) {
10
70
  return (typeof value === "object" &&
11
71
  value !== null &&
@@ -39,21 +99,56 @@ export const apply = (context, _config, fiber) => {
39
99
  : resolveStartupRuntime(configuration.environment, configuration.providers, configuration.defaults);
40
100
  if (!runtime)
41
101
  return 0;
42
- const host = await createSessionHost(context, {
43
- cwd: request.cwd,
44
- agentDir: request.agentDir,
45
- projectTrusted: request.projectTrusted,
46
- noSkills: request.command.noSkills,
47
- noContextFiles: request.command.noContextFiles,
48
- skillPaths: request.command.skillPaths,
49
- provider: runtime.provider,
50
- model: runtime.model,
51
- signal,
52
- ...(request.command.sessionPath ? { initialSessionPath: resolve(request.cwd, request.command.sessionPath) } : {}),
102
+ let mode;
103
+ const interaction = createUserInteraction({
104
+ request: (input, interactionSignal) => {
105
+ if (!mode)
106
+ throw new Error("Interactive mode is not ready.");
107
+ return mode.requestInteraction(input, interactionSignal);
108
+ },
53
109
  });
110
+ let host;
111
+ try {
112
+ host = await createSessionHost(context, {
113
+ cwd: request.cwd,
114
+ agentDir: request.agentDir,
115
+ projectTrusted: request.projectTrusted,
116
+ noSkills: request.command.noSkills,
117
+ noContextFiles: request.command.noContextFiles,
118
+ skillPaths: request.command.skillPaths,
119
+ provider: runtime.provider,
120
+ model: runtime.model,
121
+ signal,
122
+ planMode: {
123
+ section: "You are in plan mode. Explore and design before presenting the complete plan through exit_plan_mode.",
124
+ },
125
+ interaction,
126
+ ...(request.command.sessionPath
127
+ ? { initialSessionPath: resolve(request.cwd, request.command.sessionPath) }
128
+ : {}),
129
+ });
130
+ }
131
+ catch (cause) {
132
+ printStartupResources(request, context.get(pluginInventoryKey)?.snapshot(), {
133
+ skills: [],
134
+ resourceDiagnostics: [
135
+ {
136
+ path: request.cwd,
137
+ kind: "startup",
138
+ stage: "load",
139
+ severity: "error",
140
+ message: redactSensitiveText(cause instanceof Error ? cause.message : String(cause)),
141
+ },
142
+ ],
143
+ mcpServers: [],
144
+ mcpDiagnostics: [],
145
+ });
146
+ throw cause;
147
+ }
54
148
  if (!host.state().activeSession)
55
149
  await host.createSession();
56
150
  const ui = host.ui();
151
+ printStartupResources(request, context.get(pluginInventoryKey)?.snapshot(), host.startupStatus());
57
152
  const sessions = await host.listSessions();
58
153
  const activeId = host.state().activeSession?.id;
59
154
  const sessionChoices = [
@@ -78,7 +173,6 @@ export const apply = (context, _config, fiber) => {
78
173
  },
79
174
  })),
80
175
  ];
81
- let mode;
82
176
  let selectedTheme = "dark";
83
177
  const unbind = context.require(interactiveContextKey).bind({
84
178
  sessionChoices: () => sessionChoices,
@@ -115,6 +209,7 @@ export const apply = (context, _config, fiber) => {
115
209
  }
116
210
  finally {
117
211
  unbind();
212
+ await interaction.dispose();
118
213
  await host.dispose();
119
214
  }
120
215
  };
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-host-entry.js","sourceRoot":"","sources":["../src/interactive-host-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EACN,kBAAkB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,CAAC;oBACpD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC;oBAC/C,kBAAkB,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;oBACjE,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM;oBACrC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;wBACtB,IAAI,GAAG,OAAO,CAAC;oBAChB,CAAC;oBACD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE;iBACxB,CAAC;aACH,EACD,MAAM,CACN,CAAC;YACF,MAAM,QAAQ,CAAC;YACf,OAAO,CAAC,CAAC;QACV,CAAC;gBAAS,CAAC;YACV,MAAM,EAAE,CAAC;YACT,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC;IACF,CAAC,CAAC;IACF,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["import { basename, extname, resolve } from \"node:path\";\nimport {\n\tcommandRegistryKey,\n\thostCommandRegistryKey,\n\tinteractiveContextKey,\n\tkeybindingRegistryKey,\n\tmodeRegistryKey,\n} from \"@di-code/builtins\";\nimport type { PluginDefinition } from \"@di-code/plugin-runtime\";\nimport { ProcessTerminal } from \"@di-code/tui\";\nimport { DEFAULT_LOCALE, translate } from \"./i18n.ts\";\nimport { runInteractiveMode } from \"./modes/interactive-entry.ts\";\nimport { runProviderOnboarding, shouldStartProviderOnboarding } from \"./provider-onboarding.ts\";\nimport type { InteractiveHostRequest } from \"./runtime/interactive-host-service.ts\";\nimport { createSessionHost } from \"./runtime/session-host.ts\";\nimport { loadStartupConfiguration, resolveStartupRuntime } from \"./startup.ts\";\n\nfunction isInteractiveHostRequest(value: unknown): value is InteractiveHostRequest {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"command\" in value &&\n\t\ttypeof value.command === \"object\" &&\n\t\tvalue.command !== null &&\n\t\t\"mode\" in value.command &&\n\t\tvalue.command.mode === \"interactive\" &&\n\t\t\"cwd\" in value &&\n\t\ttypeof value.cwd === \"string\" &&\n\t\t\"agentDir\" in value &&\n\t\ttypeof value.agentDir === \"string\" &&\n\t\t\"projectTrusted\" in value &&\n\t\ttypeof value.projectTrusted === \"boolean\" &&\n\t\t\"stderr\" in value &&\n\t\ttypeof value.stderr === \"function\"\n\t);\n}\n\n/** Owns the interactive ProductHost and gives the presentation mode only its UiHost facade. */\nexport const apiVersion = 1 as const;\nexport const name = \"interactive-host\";\nexport const version = \"0.1.7\";\nexport const apply: PluginDefinition[\"apply\"] = (context, _config, fiber) => {\n\tconst registry = context.require(hostCommandRegistryKey);\n\tconst run = async (input: unknown, signal?: AbortSignal): Promise<number> => {\n\t\tif (!isInteractiveHostRequest(input)) throw new TypeError(\"Interactive host request is invalid\");\n\t\tconst request = input;\n\t\tconst configuration = await loadStartupConfiguration(request.cwd, process.env, request.agentDir);\n\t\tconst runtime = shouldStartProviderOnboarding(request.command, true, configuration)\n\t\t\t? await runProviderOnboarding({ configuration, terminal: new ProcessTerminal(), agentDir: request.agentDir })\n\t\t\t: resolveStartupRuntime(configuration.environment, configuration.providers, configuration.defaults);\n\t\tif (!runtime) return 0;\n\t\tconst host = await createSessionHost(context, {\n\t\t\tcwd: request.cwd,\n\t\t\tagentDir: request.agentDir,\n\t\t\tprojectTrusted: request.projectTrusted,\n\t\t\tnoSkills: request.command.noSkills,\n\t\t\tnoContextFiles: request.command.noContextFiles,\n\t\t\tskillPaths: request.command.skillPaths,\n\t\t\tprovider: runtime.provider,\n\t\t\tmodel: runtime.model,\n\t\t\tsignal,\n\t\t\t...(request.command.sessionPath ? { initialSessionPath: resolve(request.cwd, request.command.sessionPath) } : {}),\n\t\t});\n\t\tif (!host.state().activeSession) await host.createSession();\n\t\tconst ui = host.ui();\n\t\tconst sessions = await host.listSessions();\n\t\tconst activeId = host.state().activeSession?.id;\n\t\tconst sessionChoices = [\n\t\t\t{\n\t\t\t\tid: \"new-session\",\n\t\t\t\tlabel: translate(configuration.locale ?? DEFAULT_LOCALE, \"newSession\"),\n\t\t\t\tdescription: translate(configuration.locale ?? DEFAULT_LOCALE, \"newSessionDescription\"),\n\t\t\t\topen: async () => {\n\t\t\t\t\tawait host.createSession();\n\t\t\t\t\treturn host.ui();\n\t\t\t\t},\n\t\t\t},\n\t\t\t...sessions\n\t\t\t\t.filter((item) => item.id !== activeId)\n\t\t\t\t.map((item) => ({\n\t\t\t\t\tid: item.displayId ?? item.id,\n\t\t\t\t\tlabel: item.label || basename(item.id, extname(item.id)),\n\t\t\t\t\tdescription: item.cwd,\n\t\t\t\t\topen: async () => {\n\t\t\t\t\t\tawait host.openSession(item.id);\n\t\t\t\t\t\treturn host.ui();\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t];\n\t\tlet mode: import(\"./modes/interactive.ts\").InteractiveMode | undefined;\n\t\tlet selectedTheme = \"dark\";\n\t\tconst unbind = context.require(interactiveContextKey).bind({\n\t\t\tsessionChoices: () => sessionChoices,\n\t\t\tcancel: () => mode?.cancelActivePrompt(),\n\t\t\tretry: () => mode?.retryLastPrompt(),\n\t\t\ttheme: () => selectedTheme,\n\t\t\tsetTheme: (theme) => {\n\t\t\t\tselectedTheme = theme;\n\t\t\t},\n\t\t\tkeybindings: () => context.get(keybindingRegistryKey)?.snapshot(),\n\t\t});\n\t\ttry {\n\t\t\tlet finish: (() => void) | undefined;\n\t\t\tconst finished = new Promise<void>((resolveFinish) => {\n\t\t\t\tfinish = resolveFinish;\n\t\t\t});\n\t\t\tawait context.require(modeRegistryKey).execute(\n\t\t\t\t\"interactive\",\n\t\t\t\t{\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\t(request.startInteractiveMode ?? runInteractiveMode)({\n\t\t\t\t\t\t\tsession: ui,\n\t\t\t\t\t\t\tagentDir: request.agentDir,\n\t\t\t\t\t\t\tlocale: configuration.locale ?? DEFAULT_LOCALE,\n\t\t\t\t\t\t\tcommandRegistry: context.require(commandRegistryKey),\n\t\t\t\t\t\t\tcontext: context.require(interactiveContextKey),\n\t\t\t\t\t\t\tproviderOnboarding: { configuration, agentDir: request.agentDir },\n\t\t\t\t\t\t\tinitialPrompt: request.command.prompt,\n\t\t\t\t\t\t\tonCreated: (created) => {\n\t\t\t\t\t\t\t\tmode = created;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonExit: () => finish?.(),\n\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tawait finished;\n\t\t\treturn 0;\n\t\t} finally {\n\t\t\tunbind();\n\t\t\tawait host.dispose();\n\t\t}\n\t};\n\tfiber.addDisposer(registry.register(\"interactive\", run));\n};\n"]}
1
+ {"version":3,"file":"interactive-host-entry.js","sourceRoot":"","sources":["../src/interactive-host-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,GACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAA6B,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,w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AAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["import { basename, extname, resolve } from \"node:path\";\nimport {\n\tcommandRegistryKey,\n\thostCommandRegistryKey,\n\tinteractiveContextKey,\n\tkeybindingRegistryKey,\n\tmodeRegistryKey,\n} from \"@di-code/builtins\";\nimport type { PluginInventory } from \"@di-code/plugin-loader\";\nimport type { PluginDefinition } from \"@di-code/plugin-runtime\";\nimport { redactSensitiveText } from \"@di-code/plugin-runtime\";\nimport { createUserInteraction } from \"@di-code/plugin-sdk\";\nimport { ProcessTerminal } from \"@di-code/tui\";\nimport { DEFAULT_LOCALE, translate } from \"./i18n.ts\";\nimport { runInteractiveMode } from \"./modes/interactive-entry.ts\";\nimport { runProviderOnboarding, shouldStartProviderOnboarding } from \"./provider-onboarding.ts\";\nimport type { InteractiveHostRequest } from \"./runtime/interactive-host-service.ts\";\nimport { pluginInventoryKey } from \"./runtime/plugin-inventory-service.ts\";\nimport { createSessionHost, type SessionStartupStatus } from \"./runtime/session-host.ts\";\nimport { loadStartupConfiguration, resolveStartupRuntime } from \"./startup.ts\";\n\nconst ANSI = {\n\treset: \"\\u001b[0m\",\n\tbold: \"\\u001b[1m\",\n\tdim: \"\\u001b[2m\",\n\tcyan: \"\\u001b[36m\",\n\tblue: \"\\u001b[34m\",\n\tgreen: \"\\u001b[32m\",\n\tyellow: \"\\u001b[33m\",\n\tred: \"\\u001b[31m\",\n\tgray: \"\\u001b[90m\",\n\tmagenta: \"\\u001b[35m\",\n} as const;\n\nfunction paint(value: string, color: keyof typeof ANSI): string {\n\treturn `${ANSI[color]}${value}${ANSI.reset}`;\n}\n\nfunction paintStatus(status: string): string {\n\tconst color =\n\t\tstatus === \"active\" || status === \"connected\"\n\t\t\t? \"green\"\n\t\t\t: status === \"failed\"\n\t\t\t\t? \"red\"\n\t\t\t\t: status === \"disabled\"\n\t\t\t\t\t? \"gray\"\n\t\t\t\t\t: \"yellow\";\n\treturn paint(status, color);\n}\n\nfunction printStartupResources(\n\trequest: InteractiveHostRequest,\n\tinventory: PluginInventory | undefined,\n\tstartup: SessionStartupStatus,\n): void {\n\tconst projectEntries =\n\t\tinventory?.entries.filter(\n\t\t\t(record) => record.entry.projectLocal || record.entry.id.startsWith(\"managed.\") || record.status === \"failed\",\n\t\t) ?? [];\n\tconst hasDetails =\n\t\tprojectEntries.length > 0 ||\n\t\tstartup.skills.length > 0 ||\n\t\tstartup.resourceDiagnostics.length > 0 ||\n\t\tstartup.mcpServers.length > 0 ||\n\t\tstartup.mcpDiagnostics.length > 0;\n\tif (!hasDetails) return;\n\tconst lines = [\"\", `${paint(\"di-code startup resources\", \"bold\")}:`, ` ${paint(\"Plugins\", \"cyan\")}:`];\n\tif (projectEntries.length === 0) lines.push(` ${paint(\"- none\", \"dim\")}`);\n\tfor (const record of projectEntries) {\n\t\tconst reason = record.error ? `: ${redactSensitiveText(record.error.message)}` : \"\";\n\t\tlines.push(` - ${record.entry.id}: ${paintStatus(record.status)}${reason}`);\n\t}\n\tlines.push(` ${paint(\"Skills\", \"magenta\")}:`);\n\tif (startup.skills.length === 0) lines.push(` ${paint(\"- none\", \"dim\")}`);\n\tfor (const skill of startup.skills)\n\t\tlines.push(` - ${paint(skill.name, \"magenta\")} ${paint(`(${skill.scope})`, \"dim\")}`);\n\tfor (const diagnostic of startup.resourceDiagnostics)\n\t\tlines.push(\n\t\t\t` - ${paint(`${diagnostic.kind} ${diagnostic.severity}`, diagnostic.severity === \"error\" ? \"red\" : \"yellow\")}: ${diagnostic.path}: ${diagnostic.message}`,\n\t\t);\n\tlines.push(` ${paint(\"MCP\", \"blue\")}:`);\n\tif (startup.mcpServers.length === 0 && startup.mcpDiagnostics.length === 0)\n\t\tlines.push(` ${paint(\"- none\", \"dim\")}`);\n\tfor (const server of startup.mcpServers)\n\t\tlines.push(\n\t\t\t` - ${server.id}: ${paintStatus(\"connected\")} ${paint(`(tools ${server.tools}, resources ${server.resources}, prompts ${server.prompts})`, \"dim\")}`,\n\t\t);\n\tfor (const diagnostic of startup.mcpDiagnostics)\n\t\tlines.push(\n\t\t\t` - ${diagnostic.serverId}: ${paintStatus(\"failed\")} (${diagnostic.stage}): ${redactSensitiveText(diagnostic.message)}`,\n\t\t);\n\trequest.stderr(`${lines.join(\"\\n\")}\\n\\n`);\n}\n\nfunction isInteractiveHostRequest(value: unknown): value is InteractiveHostRequest {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"command\" in value &&\n\t\ttypeof value.command === \"object\" &&\n\t\tvalue.command !== null &&\n\t\t\"mode\" in value.command &&\n\t\tvalue.command.mode === \"interactive\" &&\n\t\t\"cwd\" in value &&\n\t\ttypeof value.cwd === \"string\" &&\n\t\t\"agentDir\" in value &&\n\t\ttypeof value.agentDir === \"string\" &&\n\t\t\"projectTrusted\" in value &&\n\t\ttypeof value.projectTrusted === \"boolean\" &&\n\t\t\"stderr\" in value &&\n\t\ttypeof value.stderr === \"function\"\n\t);\n}\n\n/** Owns the interactive ProductHost and gives the presentation mode only its UiHost facade. */\nexport const apiVersion = 1 as const;\nexport const name = \"interactive-host\";\nexport const version = \"0.1.7\";\nexport const apply: PluginDefinition[\"apply\"] = (context, _config, fiber) => {\n\tconst registry = context.require(hostCommandRegistryKey);\n\tconst run = async (input: unknown, signal?: AbortSignal): Promise<number> => {\n\t\tif (!isInteractiveHostRequest(input)) throw new TypeError(\"Interactive host request is invalid\");\n\t\tconst request = input;\n\t\tconst configuration = await loadStartupConfiguration(request.cwd, process.env, request.agentDir);\n\t\tconst runtime = shouldStartProviderOnboarding(request.command, true, configuration)\n\t\t\t? await runProviderOnboarding({ configuration, terminal: new ProcessTerminal(), agentDir: request.agentDir })\n\t\t\t: resolveStartupRuntime(configuration.environment, configuration.providers, configuration.defaults);\n\t\tif (!runtime) return 0;\n\t\tlet mode: import(\"./modes/interactive.ts\").InteractiveMode | undefined;\n\t\tconst interaction = createUserInteraction({\n\t\t\trequest: (input, interactionSignal) => {\n\t\t\t\tif (!mode) throw new Error(\"Interactive mode is not ready.\");\n\t\t\t\treturn mode.requestInteraction(input, interactionSignal);\n\t\t\t},\n\t\t});\n\t\tlet host: Awaited<ReturnType<typeof createSessionHost>>;\n\t\ttry {\n\t\t\thost = await createSessionHost(context, {\n\t\t\t\tcwd: request.cwd,\n\t\t\t\tagentDir: request.agentDir,\n\t\t\t\tprojectTrusted: request.projectTrusted,\n\t\t\t\tnoSkills: request.command.noSkills,\n\t\t\t\tnoContextFiles: request.command.noContextFiles,\n\t\t\t\tskillPaths: request.command.skillPaths,\n\t\t\t\tprovider: runtime.provider,\n\t\t\t\tmodel: runtime.model,\n\t\t\t\tsignal,\n\t\t\t\tplanMode: {\n\t\t\t\t\tsection:\n\t\t\t\t\t\t\"You are in plan mode. Explore and design before presenting the complete plan through exit_plan_mode.\",\n\t\t\t\t},\n\t\t\t\tinteraction,\n\t\t\t\t...(request.command.sessionPath\n\t\t\t\t\t? { initialSessionPath: resolve(request.cwd, request.command.sessionPath) }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t} catch (cause) {\n\t\t\tprintStartupResources(request, context.get(pluginInventoryKey)?.snapshot(), {\n\t\t\t\tskills: [],\n\t\t\t\tresourceDiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\tpath: request.cwd,\n\t\t\t\t\t\tkind: \"startup\",\n\t\t\t\t\t\tstage: \"load\",\n\t\t\t\t\t\tseverity: \"error\",\n\t\t\t\t\t\tmessage: redactSensitiveText(cause instanceof Error ? cause.message : String(cause)),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tmcpServers: [],\n\t\t\t\tmcpDiagnostics: [],\n\t\t\t});\n\t\t\tthrow cause;\n\t\t}\n\t\tif (!host.state().activeSession) await host.createSession();\n\t\tconst ui = host.ui();\n\t\tprintStartupResources(request, context.get(pluginInventoryKey)?.snapshot(), host.startupStatus());\n\t\tconst sessions = await host.listSessions();\n\t\tconst activeId = host.state().activeSession?.id;\n\t\tconst sessionChoices = [\n\t\t\t{\n\t\t\t\tid: \"new-session\",\n\t\t\t\tlabel: translate(configuration.locale ?? DEFAULT_LOCALE, \"newSession\"),\n\t\t\t\tdescription: translate(configuration.locale ?? DEFAULT_LOCALE, \"newSessionDescription\"),\n\t\t\t\topen: async () => {\n\t\t\t\t\tawait host.createSession();\n\t\t\t\t\treturn host.ui();\n\t\t\t\t},\n\t\t\t},\n\t\t\t...sessions\n\t\t\t\t.filter((item) => item.id !== activeId)\n\t\t\t\t.map((item) => ({\n\t\t\t\t\tid: item.displayId ?? item.id,\n\t\t\t\t\tlabel: item.label || basename(item.id, extname(item.id)),\n\t\t\t\t\tdescription: item.cwd,\n\t\t\t\t\topen: async () => {\n\t\t\t\t\t\tawait host.openSession(item.id);\n\t\t\t\t\t\treturn host.ui();\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t];\n\t\tlet selectedTheme = \"dark\";\n\t\tconst unbind = context.require(interactiveContextKey).bind({\n\t\t\tsessionChoices: () => sessionChoices,\n\t\t\tcancel: () => mode?.cancelActivePrompt(),\n\t\t\tretry: () => mode?.retryLastPrompt(),\n\t\t\ttheme: () => selectedTheme,\n\t\t\tsetTheme: (theme) => {\n\t\t\t\tselectedTheme = theme;\n\t\t\t},\n\t\t\tkeybindings: () => context.get(keybindingRegistryKey)?.snapshot(),\n\t\t});\n\t\ttry {\n\t\t\tlet finish: (() => void) | undefined;\n\t\t\tconst finished = new Promise<void>((resolveFinish) => {\n\t\t\t\tfinish = resolveFinish;\n\t\t\t});\n\t\t\tawait context.require(modeRegistryKey).execute(\n\t\t\t\t\"interactive\",\n\t\t\t\t{\n\t\t\t\t\trun: () =>\n\t\t\t\t\t\t(request.startInteractiveMode ?? runInteractiveMode)({\n\t\t\t\t\t\t\tsession: ui,\n\t\t\t\t\t\t\tagentDir: request.agentDir,\n\t\t\t\t\t\t\tlocale: configuration.locale ?? DEFAULT_LOCALE,\n\t\t\t\t\t\t\tcommandRegistry: context.require(commandRegistryKey),\n\t\t\t\t\t\t\tcontext: context.require(interactiveContextKey),\n\t\t\t\t\t\t\tproviderOnboarding: { configuration, agentDir: request.agentDir },\n\t\t\t\t\t\t\tinitialPrompt: request.command.prompt,\n\t\t\t\t\t\t\tonCreated: (created) => {\n\t\t\t\t\t\t\t\tmode = created;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonExit: () => finish?.(),\n\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tawait finished;\n\t\t\treturn 0;\n\t\t} finally {\n\t\t\tunbind();\n\t\t\tawait interaction.dispose();\n\t\t\tawait host.dispose();\n\t\t}\n\t};\n\tfiber.addDisposer(registry.register(\"interactive\", run));\n};\n"]}