@bastani/atomic 0.9.19-alpha.3 → 0.9.19-alpha.5

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 (164) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +8 -0
  3. package/dist/builtin/intercom/index.bundle.mjs +117 -26
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +18 -0
  7. package/dist/builtin/subagents/README.md +15 -15
  8. package/dist/builtin/subagents/agents/debugger.md +2 -2
  9. package/dist/builtin/subagents/package.json +1 -1
  10. package/dist/builtin/subagents/skills/subagent/SKILL.md +26 -26
  11. package/dist/builtin/subagents/src/extension/index.bundle.mjs +140 -58
  12. package/dist/builtin/web-access/package.json +1 -1
  13. package/dist/builtin/workflows/CHANGELOG.md +27 -0
  14. package/dist/builtin/workflows/README.md +14 -15
  15. package/dist/builtin/workflows/builtin/{chunk-mygmtz6e.js → chunk-1nbq96fh.js} +19 -19
  16. package/dist/builtin/workflows/builtin/{chunk-zggjyg5z.js → chunk-n8zysf1t.js} +1 -1
  17. package/dist/builtin/workflows/builtin/{chunk-r9qq7xfj.js → chunk-vhmnzdj9.js} +37 -37
  18. package/dist/builtin/workflows/builtin/{chunk-62v3gg9f.js → chunk-yeee2jrc.js} +11 -11
  19. package/dist/builtin/workflows/builtin/goal.js +2 -2
  20. package/dist/builtin/workflows/builtin/index.js +4 -4
  21. package/dist/builtin/workflows/builtin/open-claude-design.js +1 -1
  22. package/dist/builtin/workflows/builtin/ralph.js +2 -2
  23. package/dist/builtin/workflows/package.json +5 -5
  24. package/dist/builtin/workflows/src/extension/index.bundle.mjs +180 -239
  25. package/dist/builtin/workflows/src/index.js +19 -2
  26. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +2 -1
  27. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +1 -1
  28. package/dist/core/agent-session-auto-compaction.js +1 -1
  29. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  30. package/dist/core/agent-session-compaction.js +1 -1
  31. package/dist/core/agent-session-compaction.js.map +1 -1
  32. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  33. package/dist/core/agent-session-custom-message-commit.js +33 -2
  34. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  35. package/dist/core/agent-session-message-queue.d.ts +1 -1
  36. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  37. package/dist/core/agent-session-message-queue.js +20 -6
  38. package/dist/core/agent-session-message-queue.js.map +1 -1
  39. package/dist/core/agent-session-methods.d.ts +4 -1
  40. package/dist/core/agent-session-methods.d.ts.map +1 -1
  41. package/dist/core/agent-session-methods.js.map +1 -1
  42. package/dist/core/agent-session-persistent-custom-messages.d.ts +1 -1
  43. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  44. package/dist/core/agent-session-persistent-custom-messages.js +13 -3
  45. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  46. package/dist/core/agent-session-post-tool-compaction.js +1 -1
  47. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  48. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  49. package/dist/core/agent-session-prompt.js +83 -0
  50. package/dist/core/agent-session-prompt.js.map +1 -1
  51. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  52. package/dist/core/agent-session-queue-pause.js +11 -0
  53. package/dist/core/agent-session-queue-pause.js.map +1 -1
  54. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  55. package/dist/core/agent-session-tool-hooks.js +2 -0
  56. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  57. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  58. package/dist/core/agent-session-tool-registry.js +12 -0
  59. package/dist/core/agent-session-tool-registry.js.map +1 -1
  60. package/dist/core/agent-session-transfer.d.ts.map +1 -1
  61. package/dist/core/agent-session-transfer.js +7 -0
  62. package/dist/core/agent-session-transfer.js.map +1 -1
  63. package/dist/core/agent-session-types.d.ts +2 -0
  64. package/dist/core/agent-session-types.d.ts.map +1 -1
  65. package/dist/core/agent-session-types.js +2 -0
  66. package/dist/core/agent-session-types.js.map +1 -1
  67. package/dist/core/agent-session.d.ts +4 -0
  68. package/dist/core/agent-session.d.ts.map +1 -1
  69. package/dist/core/agent-session.js +22 -0
  70. package/dist/core/agent-session.js.map +1 -1
  71. package/dist/core/extensions/context-types.d.ts +6 -0
  72. package/dist/core/extensions/context-types.d.ts.map +1 -1
  73. package/dist/core/extensions/context-types.js.map +1 -1
  74. package/dist/core/extensions/loader-virtual-modules.js +3 -3
  75. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  76. package/dist/core/extensions/runner-context.d.ts +1 -1
  77. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  78. package/dist/core/extensions/runner-context.js +9 -3
  79. package/dist/core/extensions/runner-context.js.map +1 -1
  80. package/dist/core/extensions/runner.js +1 -1
  81. package/dist/core/extensions/runner.js.map +1 -1
  82. package/dist/core/extensions/workflow-events.d.ts +1 -1
  83. package/dist/core/extensions/workflow-events.d.ts.map +1 -1
  84. package/dist/core/extensions/workflow-events.js.map +1 -1
  85. package/dist/core/sdk-exports.d.ts +1 -1
  86. package/dist/core/sdk-exports.d.ts.map +1 -1
  87. package/dist/core/sdk-exports.js +1 -1
  88. package/dist/core/sdk-exports.js.map +1 -1
  89. package/dist/core/settings-manager-basic-accessors.d.ts +5 -3
  90. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  91. package/dist/core/settings-manager-basic-accessors.js +23 -8
  92. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  93. package/dist/core/settings-manager.d.ts +1 -1
  94. package/dist/core/settings-manager.d.ts.map +1 -1
  95. package/dist/core/settings-manager.js.map +1 -1
  96. package/dist/core/settings-types.d.ts +5 -0
  97. package/dist/core/settings-types.d.ts.map +1 -1
  98. package/dist/core/settings-types.js.map +1 -1
  99. package/dist/core/slash-commands.d.ts.map +1 -1
  100. package/dist/core/slash-commands.js +4 -5
  101. package/dist/core/slash-commands.js.map +1 -1
  102. package/dist/core/tasks/agent-adapter.d.ts +5 -2
  103. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  104. package/dist/core/tasks/agent-adapter.js +10 -3
  105. package/dist/core/tasks/agent-adapter.js.map +1 -1
  106. package/dist/core/tasks/completion.d.ts.map +1 -1
  107. package/dist/core/tasks/completion.js +5 -1
  108. package/dist/core/tasks/completion.js.map +1 -1
  109. package/dist/core/tools/bash-pty-native.d.ts +16 -2
  110. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  111. package/dist/core/tools/bash-pty-native.js +82 -0
  112. package/dist/core/tools/bash-pty-native.js.map +1 -1
  113. package/dist/core/tools/bash.d.ts +13 -2
  114. package/dist/core/tools/bash.d.ts.map +1 -1
  115. package/dist/core/tools/bash.js +48 -3
  116. package/dist/core/tools/bash.js.map +1 -1
  117. package/dist/core/tools/index.d.ts +4 -1
  118. package/dist/core/tools/index.d.ts.map +1 -1
  119. package/dist/core/tools/index.js +12 -0
  120. package/dist/core/tools/index.js.map +1 -1
  121. package/dist/core/tools/kill.d.ts +17 -0
  122. package/dist/core/tools/kill.d.ts.map +1 -0
  123. package/dist/core/tools/kill.js +49 -0
  124. package/dist/core/tools/kill.js.map +1 -0
  125. package/dist/core/tools/powershell.d.ts +84 -28
  126. package/dist/core/tools/powershell.d.ts.map +1 -1
  127. package/dist/core/tools/powershell.js +10 -3
  128. package/dist/core/tools/powershell.js.map +1 -1
  129. package/dist/core/workflow-stage-admission.d.ts +14 -0
  130. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  131. package/dist/core/workflow-stage-admission.js +63 -3
  132. package/dist/core/workflow-stage-admission.js.map +1 -1
  133. package/dist/index.d.ts +2 -2
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +1 -1
  136. package/dist/index.js.map +1 -1
  137. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  138. package/dist/modes/interactive/components/task-row.js +8 -1
  139. package/dist/modes/interactive/components/task-row.js.map +1 -1
  140. package/docs/background-tasks.md +24 -1
  141. package/docs/compaction.md +20 -0
  142. package/docs/computer-use.md +390 -0
  143. package/docs/docs.json +1 -0
  144. package/docs/extensions.md +11 -1
  145. package/docs/herdr.md +2 -0
  146. package/docs/index.md +1 -0
  147. package/docs/intercom.md +10 -2
  148. package/docs/providers.md +1 -1
  149. package/docs/quickstart.md +1 -1
  150. package/docs/sdk.md +11 -1
  151. package/docs/settings.md +20 -0
  152. package/docs/subagents.md +8 -6
  153. package/docs/tmux.md +2 -0
  154. package/docs/tools.md +7 -1
  155. package/docs/usage.md +1 -1
  156. package/docs/workflows/api-reference.md +4 -3
  157. package/docs/workflows/authoring.md +3 -3
  158. package/docs/workflows/builtins.md +9 -6
  159. package/docs/workflows/operations.md +36 -30
  160. package/docs/workflows/reliable-design.md +3 -3
  161. package/docs/workflows/verification.md +99 -40
  162. package/docs/workflows.md +4 -2
  163. package/npm-shrinkwrap.json +32 -32
  164. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"runner-context.js","sourceRoot":"","sources":["../../../src/core/extensions/runner-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAwD1F;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAI,KAAQ;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAM,CAAC;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAY,MAAM,CAAC,cAAc,CAAC,KAA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F,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;QACrB,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport { createArtifactRouter, registerArtifactDir } from \"../tools/artifact-protocol.ts\";\nimport type {\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nimport type {\n\tCompactOptions,\n\tContextUsage,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionMode,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tSubagentChildPolicy,\n} from \"./types.ts\";\nexport interface ExtensionContextSource {\n\tobserveWorkflowActivity: ExtensionContext[\"observeWorkflowActivity\"];\n\tgetExtensionPaths?(): string[];\n\tassertActive(): void;\n\tgetUIContext(): ExtensionUIContext;\n\tgetMode(): ExtensionMode;\n\thasUI(): boolean;\n\tgetCwd(): string;\n\tgetSessionManager(): SessionManager;\n\tgetModelRegistry(): ModelRegistry;\n\tgetModel(): Model<Api> | undefined;\n\tgetScopedModels(): readonly ScopedModel[];\n\tgetThinkingLevel(): ThinkingLevel | undefined;\n\tgetOrchestrationContext(): OrchestrationContext | undefined;\n\tgetSubagentPolicy(): SubagentChildPolicy | undefined;\n\tisIdle(): boolean;\n\tisProjectTrusted(): boolean;\n\tgetSignal(): AbortSignal | undefined;\n\tabort(): void;\n\thasPendingMessages(): boolean;\n\tshutdown(): void;\n\tgetContextUsage(): ContextUsage | undefined;\n\tcompact(options?: CompactOptions): void;\n\tgetSystemPrompt(): string;\n\tgetSkillCatalog?(): SkillCatalog;\n\tgetAgentTaskHost?(): import(\"../tasks/agent-adapter.js\").AgentTaskHost;\n}\n\nexport interface ExtensionCommandContextSource extends ExtensionContextSource {\n\tgetSystemPromptOptions(): BuildSystemPromptOptions;\n\twaitForIdle(): Promise<void>;\n\tnewSession: NewSessionHandler;\n\tfork: ForkHandler;\n\tnavigateTree: NavigateTreeHandler;\n\tswitchSession: SwitchSessionHandler;\n\treload: ReloadHandler;\n}\n\n/**\n * A copy of `value` that shares no mutable structure with it, frozen through.\n *\n * Arrays and plain objects are rebuilt; everything else — primitives, and any\n * value carrying a prototype this does not own, such as a function or a class\n * instance — is passed through untouched rather than mangled into a plain\n * object. A `Model` is plain data (`input`, `cost.tiers`, `headers`,\n * `thinkingLevelMap`, `compat`), so the whole of one is rebuilt.\n */\nfunction deepFrozenCopy<T>(value: T): T {\n\tif (Array.isArray(value)) return Object.freeze(value.map(deepFrozenCopy)) as T;\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst prototype: unknown = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) return value;\n\tconst copied: Record<string, unknown> = {};\n\tfor (const [key, nested] of Object.entries(value)) copied[key] = deepFrozenCopy(nested);\n\treturn Object.freeze(copied) as T;\n}\n\n/**\n * A defensive copy of the model scope, entries included.\n *\n * `readonly ScopedModel[]` is a compile-time claim only, so the array is\n * copied: a JavaScript extension, or one asserting the `readonly` away, could\n * otherwise push onto the session's own array and have `cycleModel()` treat the\n * entry as in scope.\n *\n * Copying the array alone is not enough. The entries are the session's objects,\n * so mutating `entry.model` or `entry.thinkingLevel` in place reaches the very\n * array `cycleModel()` reads, and swaps the model it selects without ever\n * touching the array.\n *\n * Nor is copying the entry and its model one level deep. `Object.freeze` and a\n * spread both stop at the first level, so `model.headers`, `model.input`,\n * `model.cost.tiers`, `model.thinkingLevelMap` and `model.compat` stayed the\n * session's own objects: writing through any of them changed the model used for\n * selection and request composition, and the freeze reported nothing. The copy\n * goes all the way down, and freezes all the way down with it, so an attempt\n * fails loudly under strict mode instead of silently succeeding.\n *\n * The accessor reports the scope; it must not be a way to change it.\n */\nexport function copyScopedModels(scoped: readonly ScopedModel[]): readonly ScopedModel[] {\n\treturn Object.freeze(scoped.map((entry) => deepFrozenCopy(entry)));\n}\n\nconst contextOwners = new WeakMap<ExtensionContext, object>();\n\n/** Internal lifecycle identity; contexts themselves are recreated for every dispatch. */\nexport function getExtensionContextOwner(context: ExtensionContext): object {\n\treturn contextOwners.get(context) ?? context;\n}\n\ntype ContextEffect = () => void | Promise<void>;\nconst contextPublications = new WeakMap<object, (effect: ContextEffect) => void>();\n\n/** Keep builtin lifecycle effects behind the host's transactional publication boundary. */\nexport function bindExtensionContextPublication(\n\tcontext: ExtensionContext,\n\tstage: ((effect: ContextEffect) => void) | undefined,\n): void {\n\tconst owner = getExtensionContextOwner(context);\n\tif (stage) contextPublications.set(owner, stage);\n\telse contextPublications.delete(owner);\n}\n\nexport async function publishExtensionContextEffect(context: ExtensionContext, effect: ContextEffect): Promise<void> {\n\tconst stage = contextPublications.get(getExtensionContextOwner(context));\n\tif (stage) stage(effect);\n\telse await effect();\n}\n\n/**\n * Create an ExtensionContext for use in event handlers and tool execution.\n * Context values are resolved at call time, so host changes are reflected.\n */\nexport function createExtensionContext(source: ExtensionContextSource, owner: object = source): ExtensionContext {\n\tconst context: ExtensionContext = {\n\t\tgetExtensionPaths: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getExtensionPaths?.() ?? [];\n\t\t},\n\t\t...(source.getAgentTaskHost\n\t\t\t? {\n\t\t\t\t\tgetAgentTaskHost: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getAgentTaskHost!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tget ui() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getUIContext();\n\t\t},\n\t\tget mode() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getMode();\n\t\t},\n\t\tobserveWorkflowActivity: (observer) => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.observeWorkflowActivity(observer);\n\t\t},\n\t\tget hasUI() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasUI();\n\t\t},\n\t\tget cwd() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getCwd();\n\t\t},\n\t\tget sessionManager() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSessionManager();\n\t\t},\n\t\tget modelRegistry() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModelRegistry();\n\t\t},\n\t\tget model() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModel();\n\t\t},\n\t\tget scopedModels() {\n\t\t\tsource.assertActive();\n\t\t\treturn copyScopedModels(source.getScopedModels());\n\t\t},\n\t\tget thinkingLevel() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getThinkingLevel();\n\t\t},\n\t\tget internalResourceRouter() {\n\t\t\tsource.assertActive();\n\t\t\tconst sessionDir = source.getSessionManager().getSessionDir();\n\t\t\tif (!sessionDir) return undefined;\n\t\t\tconst artifactsDir = join(sessionDir, \"artifacts\");\n\t\t\tregisterArtifactDir(artifactsDir);\n\t\t\treturn createArtifactRouter(() => [artifactsDir]);\n\t\t},\n\t\tget orchestrationContext() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getOrchestrationContext();\n\t\t},\n\t\tget subagentPolicy() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSubagentPolicy();\n\t\t},\n\t\tisIdle: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isIdle();\n\t\t},\n\t\tisProjectTrusted: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isProjectTrusted();\n\t\t},\n\t\tget signal() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSignal();\n\t\t},\n\t\tabort: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.abort();\n\t\t},\n\t\thasPendingMessages: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasPendingMessages();\n\t\t},\n\t\tshutdown: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.shutdown();\n\t\t},\n\t\tgetContextUsage: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getContextUsage();\n\t\t},\n\t\tcompact: (options) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.compact(options);\n\t\t},\n\t\tgetSystemPrompt: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSystemPrompt();\n\t\t},\n\t\t...(source.getSkillCatalog\n\t\t\t? {\n\t\t\t\t\tgetSkillCatalog: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getSkillCatalog!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n\nexport function createExtensionCommandContext(source: ExtensionCommandContextSource): ExtensionCommandContext {\n\t// Use property descriptors instead of object spread so the guarded getters from\n\t// createExtensionContext() stay lazy. A spread would eagerly read them once and\n\t// freeze old values into the returned object, bypassing stale-instance checks.\n\tconst context = Object.defineProperties(\n\t\t{},\n\t\tObject.getOwnPropertyDescriptors(createExtensionContext(source)),\n\t) as ExtensionCommandContext;\n\tcontext.getSystemPromptOptions = () => {\n\t\tsource.assertActive();\n\t\treturn source.getSystemPromptOptions();\n\t};\n\tcontext.waitForIdle = () => {\n\t\tsource.assertActive();\n\t\treturn source.waitForIdle();\n\t};\n\tcontext.newSession = (options) => {\n\t\tsource.assertActive();\n\t\treturn source.newSession(options);\n\t};\n\tcontext.fork = (entryId, options) => {\n\t\tsource.assertActive();\n\t\treturn source.fork(entryId, options);\n\t};\n\tcontext.navigateTree = (targetId, options) => {\n\t\tsource.assertActive();\n\t\treturn source.navigateTree(targetId, options);\n\t};\n\tcontext.switchSession = (sessionPath, options) => {\n\t\tsource.assertActive();\n\t\treturn source.switchSession(sessionPath, options);\n\t};\n\tcontext.reload = () => {\n\t\tsource.assertActive();\n\t\treturn source.reload();\n\t};\n\treturn context;\n}\n"]}
1
+ {"version":3,"file":"runner-context.js","sourceRoot":"","sources":["../../../src/core/extensions/runner-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAwD1F;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAI,KAAQ;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAM,CAAC;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,SAAS,GAAY,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACvE,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACxF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAM,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA8B;IAC9D,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,gF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AC;IACxC,CAAC,CAAC;IACF,OAAO,CAAC,WAAW,GAAG,GAAG,EAAE;QAC1B,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC,CAAC;IACF,OAAO,CAAC,UAAU,GAAG,CAAC,OAAO,EAAE,EAAE;QAChC,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACnC,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IACF,OAAO,CAAC,YAAY,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE;QAC5C,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC,CAAC;IACF,OAAO,CAAC,aAAa,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE;QAChD,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC,CAAC;IACF,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;QACrB,MAAM,CAAC,YAAY,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,aAAa,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { SkillCatalog } from \"../skill-catalog.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport { createArtifactRouter, registerArtifactDir } from \"../tools/artifact-protocol.ts\";\nimport type {\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nimport type {\n\tCompactOptions,\n\tContextUsage,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionMode,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tSubagentChildPolicy,\n} from \"./types.ts\";\nexport interface ExtensionContextSource {\n\tobserveWorkflowActivity: ExtensionContext[\"observeWorkflowActivity\"];\n\tgetExtensionPaths?(): string[];\n\tassertActive(): void;\n\tgetUIContext(): ExtensionUIContext;\n\tgetMode(): ExtensionMode;\n\thasUI(): boolean;\n\tgetCwd(): string;\n\tgetSessionManager(): SessionManager;\n\tgetModelRegistry(): ModelRegistry;\n\tgetModel(): Model<Api> | undefined;\n\tgetScopedModels(): readonly ScopedModel[];\n\tgetThinkingLevel(): ThinkingLevel | undefined;\n\tgetOrchestrationContext(): OrchestrationContext | undefined;\n\tgetSubagentPolicy(): SubagentChildPolicy | undefined;\n\tisIdle(): boolean;\n\tisProjectTrusted(): boolean;\n\tgetSignal(): AbortSignal | undefined;\n\tabort(): void;\n\thasPendingMessages(): boolean;\n\tshutdown(): void;\n\tgetContextUsage(): ContextUsage | undefined;\n\tcompact(options?: CompactOptions): void;\n\tgetSystemPrompt(): string;\n\tgetSkillCatalog?(): SkillCatalog;\n\tgetAgentTaskHost?(): import(\"../tasks/agent-adapter.js\").AgentTaskHost;\n}\n\nexport interface ExtensionCommandContextSource extends ExtensionContextSource {\n\tgetSystemPromptOptions(): BuildSystemPromptOptions;\n\twaitForIdle(): Promise<void>;\n\tnewSession: NewSessionHandler;\n\tfork: ForkHandler;\n\tnavigateTree: NavigateTreeHandler;\n\tswitchSession: SwitchSessionHandler;\n\treload: ReloadHandler;\n}\n\n/**\n * A copy of `value` that shares no mutable structure with it, frozen through.\n *\n * Arrays and plain objects are rebuilt; everything else — primitives, and any\n * value carrying a prototype this does not own, such as a function or a class\n * instance — is passed through untouched rather than mangled into a plain\n * object. A `Model` is plain data (`input`, `cost.tiers`, `headers`,\n * `thinkingLevelMap`, `compat`), so the whole of one is rebuilt.\n */\nfunction deepFrozenCopy<T>(value: T): T {\n\tif (Array.isArray(value)) return Object.freeze(value.map(deepFrozenCopy)) as T;\n\tif (typeof value !== \"object\" || value === null) return value;\n\tconst prototype: unknown = Object.getPrototypeOf(value);\n\tif (prototype !== Object.prototype && prototype !== null) return value;\n\tconst copied: Record<string, unknown> = {};\n\tfor (const [key, nested] of Object.entries(value)) copied[key] = deepFrozenCopy(nested);\n\treturn Object.freeze(copied) as T;\n}\n\n/**\n * A defensive copy of the model scope, entries included.\n *\n * `readonly ScopedModel[]` is a compile-time claim only, so the array is\n * copied: a JavaScript extension, or one asserting the `readonly` away, could\n * otherwise push onto the session's own array and have `cycleModel()` treat the\n * entry as in scope.\n *\n * Copying the array alone is not enough. The entries are the session's objects,\n * so mutating `entry.model` or `entry.thinkingLevel` in place reaches the very\n * array `cycleModel()` reads, and swaps the model it selects without ever\n * touching the array.\n *\n * Nor is copying the entry and its model one level deep. `Object.freeze` and a\n * spread both stop at the first level, so `model.headers`, `model.input`,\n * `model.cost.tiers`, `model.thinkingLevelMap` and `model.compat` stayed the\n * session's own objects: writing through any of them changed the model used for\n * selection and request composition, and the freeze reported nothing. The copy\n * goes all the way down, and freezes all the way down with it, so an attempt\n * fails loudly under strict mode instead of silently succeeding.\n *\n * The accessor reports the scope; it must not be a way to change it.\n */\nexport function copyScopedModels(scoped: readonly ScopedModel[]): readonly ScopedModel[] {\n\treturn Object.freeze(scoped.map((entry) => deepFrozenCopy(entry)));\n}\n\n// Private host/builtin bridge, also read by intercom/context-owner.ts. Separate\n// bundles share identity without exposing guarded capabilities or retaining UI.\nconst CONTEXT_OWNERS_KEY = Symbol.for(\"atomic-coding-agent/extension-context-owners@1\");\nconst contextOwnerBag = globalThis as typeof globalThis & { [CONTEXT_OWNERS_KEY]?: WeakMap<ExtensionContext, object> };\ncontextOwnerBag[CONTEXT_OWNERS_KEY] ??= new WeakMap<ExtensionContext, object>();\nconst contextOwners = contextOwnerBag[CONTEXT_OWNERS_KEY];\n\n/** Internal lifecycle identity; contexts themselves are recreated for every dispatch. */\nexport function getExtensionContextOwner(context: ExtensionContext): object {\n\treturn contextOwners.get(context) ?? context;\n}\n\ntype ContextEffect = () => void | Promise<void>;\nconst contextPublications = new WeakMap<object, (effect: ContextEffect) => void>();\n\n/** Keep builtin lifecycle effects behind the host's transactional publication boundary. */\nexport function bindExtensionContextPublication(\n\tcontext: ExtensionContext,\n\tstage: ((effect: ContextEffect) => void) | undefined,\n): void {\n\tconst owner = getExtensionContextOwner(context);\n\tif (stage) contextPublications.set(owner, stage);\n\telse contextPublications.delete(owner);\n}\n\nexport async function publishExtensionContextEffect(context: ExtensionContext, effect: ContextEffect): Promise<void> {\n\tconst stage = contextPublications.get(getExtensionContextOwner(context));\n\tif (stage) stage(effect);\n\telse await effect();\n}\n\n/**\n * Create an ExtensionContext for use in event handlers and tool execution.\n * Context values are resolved at call time, so host changes are reflected.\n */\nexport function createExtensionContext(source: ExtensionContextSource, owner: object = source): ExtensionContext {\n\tconst context: ExtensionContext = {\n\t\tgetExtensionPaths: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getExtensionPaths?.() ?? [];\n\t\t},\n\t\t...(source.getAgentTaskHost\n\t\t\t? {\n\t\t\t\t\tgetAgentTaskHost: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getAgentTaskHost!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t\tget ui() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getUIContext();\n\t\t},\n\t\tget mode() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getMode();\n\t\t},\n\t\tobserveWorkflowActivity: (observer) => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.observeWorkflowActivity(observer);\n\t\t},\n\t\tget hasUI() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasUI();\n\t\t},\n\t\tget cwd() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getCwd();\n\t\t},\n\t\tget sessionManager() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSessionManager();\n\t\t},\n\t\tget modelRegistry() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModelRegistry();\n\t\t},\n\t\tget model() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getModel();\n\t\t},\n\t\tget scopedModels() {\n\t\t\tsource.assertActive();\n\t\t\treturn copyScopedModels(source.getScopedModels());\n\t\t},\n\t\tget thinkingLevel() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getThinkingLevel();\n\t\t},\n\t\tget internalResourceRouter() {\n\t\t\tsource.assertActive();\n\t\t\tconst sessionDir = source.getSessionManager().getSessionDir();\n\t\t\tif (!sessionDir) return undefined;\n\t\t\tconst artifactsDir = join(sessionDir, \"artifacts\");\n\t\t\tregisterArtifactDir(artifactsDir);\n\t\t\treturn createArtifactRouter(() => [artifactsDir]);\n\t\t},\n\t\tget orchestrationContext() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getOrchestrationContext();\n\t\t},\n\t\tget subagentPolicy() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSubagentPolicy();\n\t\t},\n\t\tisIdle: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isIdle();\n\t\t},\n\t\tisProjectTrusted: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.isProjectTrusted();\n\t\t},\n\t\tget signal() {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSignal();\n\t\t},\n\t\tabort: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.abort();\n\t\t},\n\t\thasPendingMessages: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.hasPendingMessages();\n\t\t},\n\t\tshutdown: () => {\n\t\t\tsource.assertActive();\n\t\t\tsource.shutdown();\n\t\t},\n\t\tgetContextUsage: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getContextUsage();\n\t\t},\n\t\tcompact: (options) => {\n\t\t\tsource.assertActive();\n\t\t\tsource.compact(options);\n\t\t},\n\t\tgetSystemPrompt: () => {\n\t\t\tsource.assertActive();\n\t\t\treturn source.getSystemPrompt();\n\t\t},\n\t\t...(source.getSkillCatalog\n\t\t\t? {\n\t\t\t\t\tgetSkillCatalog: () => {\n\t\t\t\t\t\tsource.assertActive();\n\t\t\t\t\t\treturn source.getSkillCatalog!();\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: {}),\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n\nexport function createExtensionCommandContext(\n\tsource: ExtensionCommandContextSource,\n\towner: object = source,\n): ExtensionCommandContext {\n\t// Use property descriptors instead of object spread so the guarded getters from\n\t// createExtensionContext() stay lazy. A spread would eagerly read them once and\n\t// freeze old values into the returned object, bypassing stale-instance checks.\n\tconst context = Object.defineProperties(\n\t\t{},\n\t\tObject.getOwnPropertyDescriptors(createExtensionContext(source, owner)),\n\t) as ExtensionCommandContext;\n\tcontext.getSystemPromptOptions = () => {\n\t\tsource.assertActive();\n\t\treturn source.getSystemPromptOptions();\n\t};\n\tcontext.waitForIdle = () => {\n\t\tsource.assertActive();\n\t\treturn source.waitForIdle();\n\t};\n\tcontext.newSession = (options) => {\n\t\tsource.assertActive();\n\t\treturn source.newSession(options);\n\t};\n\tcontext.fork = (entryId, options) => {\n\t\tsource.assertActive();\n\t\treturn source.fork(entryId, options);\n\t};\n\tcontext.navigateTree = (targetId, options) => {\n\t\tsource.assertActive();\n\t\treturn source.navigateTree(targetId, options);\n\t};\n\tcontext.switchSession = (sessionPath, options) => {\n\t\tsource.assertActive();\n\t\treturn source.switchSession(sessionPath, options);\n\t};\n\tcontext.reload = () => {\n\t\tsource.assertActive();\n\t\treturn source.reload();\n\t};\n\tcontextOwners.set(context, owner);\n\treturn context;\n}\n"]}
@@ -347,7 +347,7 @@ export class ExtensionRunner {
347
347
  return createExtensionContext(this.createContextSource(), this.contextOwner);
348
348
  }
349
349
  createCommandContext() {
350
- return createExtensionCommandContext(this.createContextSource());
350
+ return createExtensionCommandContext(this.createContextSource(), this.contextOwner);
351
351
  }
352
352
  createContextSource() {
353
353
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/core/extensions/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,GAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKN,2BAA2B,EAC3B,gCAAgC,EAChC,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAU5B,OAAO,EACN,YAAY,EACZ,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAC;AA+CrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC7C,eAAgC,EAChC,KAA2B;IAE3B,IAAI,eAAe,C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M,EAAE,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC1G,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CACrB,CACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/**\n * Extension runner - executes extensions and manages their lifecycle.\n */\n\nimport type { Provider, ProviderHeaders } from \"@bastani/pi-ai\";\nimport type { Api, ImageContent, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { KeyId } from \"@earendil-works/pi-tui\";\nimport type { ResourceDiagnostic } from \"../diagnostics.ts\";\nimport type { KeybindingsConfig } from \"../keybindings.ts\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport { runResourceRegistrationBatch } from \"./loader-runtime.ts\";\nimport {\n\tcreateExtensionCommandContext,\n\tcreateExtensionContext,\n\ttype ExtensionCommandContextSource,\n} from \"./runner-context.ts\";\nimport {\n\ttype BeforeAgentStartCombinedResult,\n\ttype ResourcesDiscoverCombinedResult,\n\ttype RunnerEmitEvent,\n\ttype RunnerEmitResult,\n\trunBeforeAgentStartHandlers,\n\trunBeforeProviderRequestHandlers,\n\trunContextHandlers,\n\trunGenericHandlers,\n\trunInputHandlers,\n\trunMessageEndHandlers,\n\trunResourcesDiscoverHandlers,\n\trunToolCallHandlers,\n\trunToolResultHandlers,\n\trunUserBashHandlers,\n} from \"./runner-events.ts\";\nimport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nimport {\n\tcollectFlags,\n\tcollectMarkdownTransformers,\n\tcollectRegisteredTools,\n\tfindEntryRenderer,\n\tfindMessageRenderer,\n\tfindToolDefinition,\n\thasExtensionHandlers,\n\tresolveRegisteredCommands,\n} from \"./runner-registries.ts\";\nimport { resolveExtensionShortcuts } from \"./runner-shortcuts.ts\";\nimport { noOpUIContext } from \"./runner-ui.ts\";\nimport { STALE_EXTENSION_CONTEXT_MESSAGE } from \"./stale-context.ts\";\nimport type {\n\tCompactOptions,\n\tContextUsage,\n\tEntryRenderer,\n\tExtension,\n\tExtensionActions,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionFlag,\n\tExtensionMode,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tInputEventResult,\n\tInputSource,\n\tMarkdownTransformer,\n\tMessageEndEvent,\n\tMessageRenderer,\n\tOrchestrationContext,\n\tProviderConfig,\n\tRegisteredTool,\n\tResolvedCommand,\n\tResourcesDiscoverEvent,\n\tSessionShutdownEvent,\n\tSubagentChildPolicy,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolResultEvent,\n\tToolResultEventResult,\n\tUIPromptKind,\n\tUserBashEvent,\n\tUserBashEventResult,\n} from \"./types.ts\";\n\nexport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nexport { emitProjectTrustEvent } from \"./runner-project-trust.ts\";\n\n/**\n * Helper function to emit session_shutdown event to extensions.\n * Returns true if the event was emitted, false if there were no handlers.\n */\nexport async function emitSessionShutdownEvent(\n\textensionRunner: ExtensionRunner,\n\tevent: SessionShutdownEvent,\n): Promise<boolean> {\n\tif (extensionRunner.hasHandlers(\"session_shutdown\")) {\n\t\tawait extensionRunner.emit(event);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport class ExtensionRunner {\n\tprivate extensions: Extension[];\n\tprivate runtime: ExtensionRuntime;\n\tprivate uiContext: ExtensionUIContext;\n\tprivate mode: ExtensionMode = \"print\";\n\tprivate cwd: string;\n\tprivate sessionManager: SessionManager;\n\tprivate modelRegistry: ModelRegistry;\n\tprivate orchestrationContext: OrchestrationContext | undefined;\n\tprivate subagentPolicy: SubagentChildPolicy | undefined;\n\tprivate taskHostBinding: (() => import(\"../tasks/agent-adapter.js\").AgentTaskHost) | undefined;\n\tbindTaskHost(binding: () => import(\"../tasks/agent-adapter.js\").AgentTaskHost): void {\n\t\tthis.taskHostBinding = binding;\n\t}\n\tprivate errorListeners: Set<ExtensionErrorListener> = new Set();\n\tprivate getModel: () => Model<Api> | undefined = () => undefined;\n\tprivate getScopedModels: () => readonly ScopedModel[] = () => [];\n\tprivate isIdleFn: () => boolean = () => true;\n\tprivate isProjectTrustedFn: () => boolean = () => true;\n\tprivate getSignalFn: () => AbortSignal | undefined = () => undefined;\n\tprivate waitForIdleFn: () => Promise<void> = async () => {};\n\tprivate abortFn: () => void = () => {};\n\tprivate hasPendingMessagesFn: () => boolean = () => false;\n\tprivate getContextUsageFn: () => ContextUsage | undefined = () => undefined;\n\tprivate compactFn: (options?: CompactOptions) => void = () => {};\n\tprivate getSystemPromptFn: () => string = () => \"\";\n\tprivate getSystemPromptOptionsFn: () => BuildSystemPromptOptions = () => ({ cwd: this.cwd });\n\tprivate getSkillCatalogFn: ExtensionContextActions[\"getSkillCatalog\"] = undefined;\n\tprivate newSessionHandler: NewSessionHandler = async () => ({ cancelled: false });\n\tprivate forkHandler: ForkHandler = async () => ({ cancelled: false });\n\tprivate navigateTreeHandler: NavigateTreeHandler = async () => ({ cancelled: false });\n\tprivate switchSessionHandler: SwitchSessionHandler = async () => ({ cancelled: false });\n\tprivate reloadHandler: ReloadHandler = async () => {};\n\tprivate shutdownHandler: ShutdownHandler = () => {};\n\tprivate shortcutDiagnostics: ResourceDiagnostic[] = [];\n\tprivate commandDiagnostics: ResourceDiagnostic[] = [];\n\tprivate staleMessage: string | undefined;\n\tprivate readonly contextOwner = {};\n\tprivate uiPromptBinding = 0;\n\tprivate activeUIPrompt:\n\t\t| { depth: number; reason: \"ui_prompt\" | \"project_trust\"; kind: UIPromptKind; title: string | undefined }\n\t\t| undefined;\n\n\tconstructor(\n\t\textensions: Extension[],\n\t\truntime: ExtensionRuntime,\n\t\tcwd: string,\n\t\tsessionManager: SessionManager,\n\t\tmodelRegistry: ModelRegistry,\n\t\torchestrationContext?: OrchestrationContext,\n\t\tsubagentPolicy?: SubagentChildPolicy,\n\t) {\n\t\tthis.extensions = extensions;\n\t\tthis.runtime = runtime;\n\t\tthis.runtime.workflowActivityHub.bindDispatcher((event, isCurrent) => this.emit(event, isCurrent));\n\t\tthis.uiContext = noOpUIContext;\n\t\tthis.cwd = cwd;\n\t\tthis.sessionManager = sessionManager;\n\t\tthis.modelRegistry = modelRegistry;\n\t\tthis.orchestrationContext = orchestrationContext;\n\t\tthis.subagentPolicy = subagentPolicy;\n\t}\n\n\tbindCore(\n\t\tactions: ExtensionActions,\n\t\tcontextActions: ExtensionContextActions,\n\t\tproviderActions?: {\n\t\t\tregisterProvider?: (providerOrName: Provider | string, config?: ProviderConfig) => void;\n\t\t\tunregisterProvider?: (name: string) => void;\n\t\t},\n\t): void {\n\t\t// Copy actions into the shared runtime (all extension APIs reference this)\n\t\tthis.runtime.sendMessage = actions.sendMessage;\n\t\tthis.runtime.sendMessages = actions.sendMessages;\n\t\tthis.runtime.sendUserMessage = actions.sendUserMessage;\n\t\tthis.runtime.appendEntry = actions.appendEntry;\n\t\tthis.runtime.setSessionName = actions.setSessionName;\n\t\tthis.runtime.getSessionName = actions.getSessionName;\n\t\tthis.runtime.setLabel = actions.setLabel;\n\t\tthis.runtime.getActiveTools = actions.getActiveTools;\n\t\tthis.runtime.getAllTools = actions.getAllTools;\n\t\tthis.runtime.setActiveTools = actions.setActiveTools;\n\t\tthis.runtime.refreshTools = actions.refreshTools;\n\t\tthis.runtime.getCommands = actions.getCommands;\n\t\tthis.runtime.setModel = actions.setModel;\n\t\tthis.runtime.getThinkingLevel = actions.getThinkingLevel;\n\t\tthis.runtime.setThinkingLevel = actions.setThinkingLevel;\n\n\t\t// Context actions (required)\n\t\tthis.getModel = contextActions.getModel;\n\t\tthis.getScopedModels = contextActions.getScopedModels;\n\t\tthis.isIdleFn = contextActions.isIdle;\n\t\tthis.isProjectTrustedFn = contextActions.isProjectTrusted;\n\t\tthis.getSignalFn = contextActions.getSignal;\n\t\tthis.abortFn = contextActions.abort;\n\t\tthis.hasPendingMessagesFn = contextActions.hasPendingMessages;\n\t\tthis.shutdownHandler = contextActions.shutdown;\n\t\tthis.getContextUsageFn = contextActions.getContextUsage;\n\t\tthis.compactFn = contextActions.compact;\n\t\tthis.getSystemPromptFn = contextActions.getSystemPrompt;\n\t\tthis.getSystemPromptOptionsFn = contextActions.getSystemPromptOptions ?? (() => ({ cwd: this.cwd }));\n\t\tthis.getSkillCatalogFn = contextActions.getSkillCatalog;\n\n\t\t// Flush provider registrations queued during extension loading.\n\t\tfor (const registration of this.runtime.pendingProviderRegistrations) {\n\t\t\ttry {\n\t\t\t\tif (\"provider\" in registration) {\n\t\t\t\t\t(\n\t\t\t\t\t\tproviderActions?.registerProvider ??\n\t\t\t\t\t\t((provider: Provider) => this.modelRegistry.registerProvider(provider))\n\t\t\t\t\t)(registration.provider);\n\t\t\t\t} else {\n\t\t\t\t\t(\n\t\t\t\t\t\tproviderActions?.registerProvider ??\n\t\t\t\t\t\t((name: string, config?: ProviderConfig) => this.modelRegistry.registerProvider(name, config!))\n\t\t\t\t\t)(registration.name, registration.config);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.emitError({\n\t\t\t\t\textensionPath: registration.extensionPath,\n\t\t\t\t\tevent: \"register_provider\",\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis.runtime.pendingProviderRegistrations = [];\n\n\t\t// From this point on, provider registration/unregistration takes effect immediately\n\t\t// without requiring a /reload.\n\t\tthis.runtime.registerProvider = ((providerOrName: Provider | string, configOrPath?: ProviderConfig | string) => {\n\t\t\tif (typeof providerOrName === \"string\") {\n\t\t\t\tconst config = configOrPath as ProviderConfig;\n\t\t\t\tif (providerActions?.registerProvider) providerActions.registerProvider(providerOrName, config);\n\t\t\t\telse this.modelRegistry.registerProvider(providerOrName, config);\n\t\t\t} else if (providerActions?.registerProvider) providerActions.registerProvider(providerOrName);\n\t\t\telse this.modelRegistry.registerProvider(providerOrName);\n\t\t}) as ExtensionRuntime[\"registerProvider\"];\n\t\tthis.runtime.unregisterProvider = (name) => {\n\t\t\tif (providerActions?.unregisterProvider) {\n\t\t\t\tproviderActions.unregisterProvider(name);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.modelRegistry.unregisterProvider(name);\n\t\t};\n\t}\n\n\tbindCommandContext(actions?: ExtensionCommandContextActions): void {\n\t\tif (actions) {\n\t\t\tthis.waitForIdleFn = actions.waitForIdle;\n\t\t\tthis.newSessionHandler = actions.newSession;\n\t\t\tthis.forkHandler = actions.fork;\n\t\t\tthis.navigateTreeHandler = actions.navigateTree;\n\t\t\tthis.switchSessionHandler = actions.switchSession;\n\t\t\tthis.reloadHandler = actions.reload;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.waitForIdleFn = async () => {};\n\t\tthis.newSessionHandler = async () => ({ cancelled: false });\n\t\tthis.forkHandler = async () => ({ cancelled: false });\n\t\tthis.navigateTreeHandler = async () => ({ cancelled: false });\n\t\tthis.switchSessionHandler = async () => ({ cancelled: false });\n\t\tthis.reloadHandler = async () => {};\n\t}\n\n\tsetUIContext(uiContext?: ExtensionUIContext, mode: ExtensionMode = \"print\"): void {\n\t\tthis.endActiveUIPrompt();\n\t\tconst binding = ++this.uiPromptBinding;\n\t\tthis.uiContext = uiContext ? this.wrapUIPromptContext(uiContext, binding) : noOpUIContext;\n\t\tthis.mode = mode;\n\t}\n\n\tprivate wrapUIPromptContext(ui: ExtensionUIContext, binding: number): ExtensionUIContext {\n\t\treturn {\n\t\t\t...ui,\n\t\t\tselect: (title, options, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"select\", title, () => ui.select(title, options, opts)),\n\t\t\tconfirm: (title, message, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"confirm\", title, () => ui.confirm(title, message, opts)),\n\t\t\tinput: (title, placeholder, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"input\", title, () => ui.input(title, placeholder, opts)),\n\t\t\teditor: (title, prefill, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"editor\", title, () => ui.editor(title, prefill, opts)),\n\t\t\tcustom: (factory, options) =>\n\t\t\t\toptions?.purpose === \"navigation\"\n\t\t\t\t\t? ui.custom(factory, options)\n\t\t\t\t\t: this.withUIPrompt(binding, \"custom\", undefined, () => ui.custom(factory, options)),\n\t\t};\n\t}\n\n\t/** Track a host-owned trust dialog using the current session's prompt lifecycle. */\n\twithProjectTrustPrompt<T>(kind: UIPromptKind, title: string, run: () => Promise<T>): Promise<T> {\n\t\treturn this.withUIPrompt(this.uiPromptBinding, kind, title, run, \"project_trust\");\n\t}\n\n\t/** Begin a host-owned trust span whose end arrives as a separate control frame. */\n\tbeginProjectTrustPrompt(kind: UIPromptKind, title: string): () => void {\n\t\treturn this.beginUIPrompt(kind, title, \"project_trust\");\n\t}\n\n\tprivate withUIPrompt<T>(\n\t\tbinding: number,\n\t\tkind: UIPromptKind,\n\t\ttitle: string | undefined,\n\t\trun: () => Promise<T>,\n\t\treason: \"ui_prompt\" | \"project_trust\" = \"ui_prompt\",\n\t): Promise<T> {\n\t\tif (binding !== this.uiPromptBinding) return run();\n\t\tconst finish = this.beginUIPrompt(kind, title, reason);\n\t\ttry {\n\t\t\treturn run().finally(finish);\n\t\t} catch (error) {\n\t\t\tfinish();\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate beginUIPrompt(\n\t\tkind: UIPromptKind,\n\t\ttitle: string | undefined,\n\t\treason: \"ui_prompt\" | \"project_trust\",\n\t): () => void {\n\t\tlet prompt = this.activeUIPrompt;\n\t\tif (!prompt) {\n\t\t\tprompt = { depth: 0, reason, kind, title };\n\t\t\tthis.activeUIPrompt = prompt;\n\t\t\tthis.emitUIPromptEvent({\n\t\t\t\ttype: \"ui_prompt_start\",\n\t\t\t\treason,\n\t\t\t\tkind,\n\t\t\t\t...(title === undefined ? {} : { title }),\n\t\t\t});\n\t\t}\n\t\tprompt.depth += 1;\n\n\t\tlet finished = false;\n\t\treturn () => {\n\t\t\tif (finished) return;\n\t\t\tfinished = true;\n\t\t\tif (this.activeUIPrompt !== prompt) return;\n\n\t\t\tprompt.depth -= 1;\n\t\t\tif (prompt.depth === 0) this.endActiveUIPrompt(prompt);\n\t\t};\n\t}\n\n\tprivate endActiveUIPrompt(prompt = this.activeUIPrompt): void {\n\t\tif (!prompt || this.activeUIPrompt !== prompt) return;\n\t\tthis.activeUIPrompt = undefined;\n\t\tprompt.depth = 0;\n\t\tthis.emitUIPromptEvent({\n\t\t\ttype: \"ui_prompt_end\",\n\t\t\treason: prompt.reason,\n\t\t\tkind: prompt.kind,\n\t\t\t...(prompt.title === undefined ? {} : { title: prompt.title }),\n\t\t});\n\t}\n\n\tprivate readonly pendingUIPromptNotifications = new Set<Promise<void>>();\n\n\tprivate emitUIPromptEvent(event: Extract<RunnerEmitEvent, { type: \"ui_prompt_start\" | \"ui_prompt_end\" }>): void {\n\t\tconst delivery = Promise.resolve().then(async () => {\n\t\t\tawait this.emit(event);\n\t\t});\n\t\tthis.pendingUIPromptNotifications.add(delivery);\n\t\tvoid delivery.finally(() => this.pendingUIPromptNotifications.delete(delivery)).catch(() => {});\n\t}\n\n\t/** Settle only the deliveries pending at this boundary, without delaying prompt UI. */\n\tasync flushUIPromptNotifications(timeoutMs: number): Promise<{ timedOut: boolean }> {\n\t\tconst pending = [...this.pendingUIPromptNotifications];\n\t\tif (pending.length === 0) return { timedOut: false };\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\treturn await Promise.race([\n\t\t\t\tPromise.allSettled(pending).then(() => ({ timedOut: false })),\n\t\t\t\tnew Promise<{ timedOut: boolean }>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => resolve({ timedOut: true }), timeoutMs);\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n\n\tgetUIContext(): ExtensionUIContext {\n\t\treturn this.uiContext;\n\t}\n\n\thasUI(): boolean {\n\t\treturn this.uiContext !== noOpUIContext;\n\t}\n\n\tgetExtensionPaths(): string[] {\n\t\treturn this.extensions.map((extension) => extension.path);\n\t}\n\n\t/** Get all registered tools from all extensions (first registration per name wins). */\n\tgetAllRegisteredTools(): RegisteredTool[] {\n\t\treturn collectRegisteredTools(this.extensions);\n\t}\n\n\t/** Get a tool definition by name. Returns undefined if not found. */\n\tgetToolDefinition(toolName: string): RegisteredTool[\"definition\"] | undefined {\n\t\treturn findToolDefinition(this.extensions, toolName);\n\t}\n\n\tgetFlags(): Map<string, ExtensionFlag> {\n\t\treturn collectFlags(this.extensions);\n\t}\n\n\tsetFlagValue(name: string, value: boolean | string): void {\n\t\tthis.runtime.flagValues.set(name, value);\n\t\tthis.runtime.explicitFlagNames ??= new Set();\n\t\tthis.runtime.explicitFlagNames.add(name);\n\t}\n\n\tgetFlagValues(): Map<string, boolean | string> {\n\t\treturn new Map(this.runtime.flagValues);\n\t}\n\n\tgetExplicitFlagValues(): Map<string, boolean | string> {\n\t\tconst explicitFlagNames = this.runtime.explicitFlagNames ?? new Set<string>();\n\t\treturn new Map([...this.runtime.flagValues].filter(([name]) => explicitFlagNames.has(name)));\n\t}\n\n\tgetShortcuts(resolvedKeybindings: KeybindingsConfig): Map<KeyId, ExtensionShortcut> {\n\t\tconst resolution = resolveExtensionShortcuts(this.extensions, resolvedKeybindings, this.hasUI());\n\t\tthis.shortcutDiagnostics = resolution.diagnostics;\n\t\treturn resolution.shortcuts;\n\t}\n\n\tgetShortcutDiagnostics(): ResourceDiagnostic[] {\n\t\treturn this.shortcutDiagnostics;\n\t}\n\n\tinvalidate(message = STALE_EXTENSION_CONTEXT_MESSAGE): void {\n\t\tif (!this.staleMessage) {\n\t\t\tthis.staleMessage = message;\n\t\t\tthis.runtime.invalidate(message);\n\t\t}\n\t}\n\n\tprivate assertActive(): void {\n\t\tif (this.staleMessage) {\n\t\t\tthrow new Error(this.staleMessage);\n\t\t}\n\t}\n\n\tonError(listener: ExtensionErrorListener): () => void {\n\t\tthis.errorListeners.add(listener);\n\t\treturn () => this.errorListeners.delete(listener);\n\t}\n\n\temitError(error: ExtensionError): void {\n\t\tfor (const listener of this.errorListeners) {\n\t\t\tlistener(error);\n\t\t}\n\t}\n\n\thasHandlers(eventType: string): boolean {\n\t\treturn hasExtensionHandlers(this.extensions, eventType);\n\t}\n\n\tgetMessageRenderer(customType: string): MessageRenderer | undefined {\n\t\treturn findMessageRenderer(this.extensions, customType);\n\t}\n\n\tgetMarkdownTransformers(): MarkdownTransformer[] {\n\t\treturn collectMarkdownTransformers(this.extensions);\n\t}\n\n\tgetEntryRenderer(customType: string): EntryRenderer | undefined {\n\t\treturn findEntryRenderer(this.extensions, customType);\n\t}\n\n\tgetRegisteredCommands(): ResolvedCommand[] {\n\t\tthis.commandDiagnostics = [];\n\t\treturn resolveRegisteredCommands(this.extensions);\n\t}\n\n\tgetCommandDiagnostics(): ResourceDiagnostic[] {\n\t\treturn this.commandDiagnostics;\n\t}\n\n\tgetCommand(name: string): ResolvedCommand | undefined {\n\t\treturn resolveRegisteredCommands(this.extensions).find((command) => command.invocationName === name);\n\t}\n\n\t/**\n\t * Request a graceful shutdown. Called by extension tools and event handlers.\n\t * The actual shutdown behavior is provided by the mode via bindExtensions().\n\t */\n\tshutdown(): void {\n\t\tthis.shutdownHandler();\n\t}\n\n\tcreateContext(): ExtensionContext {\n\t\treturn createExtensionContext(this.createContextSource(), this.contextOwner);\n\t}\n\n\tcreateCommandContext(): ExtensionCommandContext {\n\t\treturn createExtensionCommandContext(this.createContextSource());\n\t}\n\n\tprivate createContextSource(): ExtensionCommandContextSource {\n\t\treturn {\n\t\t\tassertActive: () => this.assertActive(),\n\t\t\tgetExtensionPaths: () => this.getExtensionPaths(),\n\t\t\tobserveWorkflowActivity: (observer) => this.runtime.workflowActivityHub.observeWorkflowActivity(observer),\n\t\t\t...(this.taskHostBinding ? { getAgentTaskHost: this.taskHostBinding } : {}),\n\t\t\tgetUIContext: () => this.uiContext,\n\t\t\tgetMode: () => this.mode,\n\t\t\thasUI: () => this.hasUI(),\n\t\t\tgetCwd: () => this.cwd,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetModelRegistry: () => this.modelRegistry,\n\t\t\tgetModel: () => this.getModel(),\n\t\t\tgetSubagentPolicy: () => this.subagentPolicy,\n\t\t\tgetScopedModels: () => this.getScopedModels(),\n\t\t\tgetThinkingLevel: () => this.runtime.getThinkingLevel(),\n\t\t\tgetOrchestrationContext: () => this.orchestrationContext,\n\t\t\tisIdle: () => this.isIdleFn(),\n\t\t\tisProjectTrusted: () => this.isProjectTrustedFn(),\n\t\t\tgetSignal: () => this.getSignalFn(),\n\t\t\tabort: () => this.abortFn(),\n\t\t\thasPendingMessages: () => this.hasPendingMessagesFn(),\n\t\t\tshutdown: () => this.shutdownHandler(),\n\t\t\tgetContextUsage: () => this.getContextUsageFn(),\n\t\t\tcompact: (options) => this.compactFn(options),\n\t\t\tgetSystemPrompt: () => this.getSystemPromptFn(),\n\t\t\t...(this.getSkillCatalogFn ? { getSkillCatalog: () => this.getSkillCatalogFn!() } : {}),\n\t\t\tgetSystemPromptOptions: () => this.getSystemPromptOptionsFn(),\n\t\t\twaitForIdle: () => this.waitForIdleFn(),\n\t\t\tnewSession: (options) => this.newSessionHandler(options),\n\t\t\tfork: (entryId, options) => this.forkHandler(entryId, options),\n\t\t\tnavigateTree: (targetId, options) => this.navigateTreeHandler(targetId, options),\n\t\t\tswitchSession: (sessionPath, options) => this.switchSessionHandler(sessionPath, options),\n\t\t\treload: () => this.reloadHandler(),\n\t\t};\n\t}\n\n\t/** Keep startup reporters bound while adding the now-authorized extension set. */\n\tattachStartupExtensions(extensions: Extension[]): () => Promise<void> {\n\t\tconst newcomers = extensions.filter((extension) => !this.extensions.includes(extension));\n\t\tthis.extensions = [...this.extensions, ...newcomers];\n\t\treturn async () => {\n\t\t\tawait runResourceRegistrationBatch(this.runtime, () =>\n\t\t\t\trunGenericHandlers(\n\t\t\t\t\tthis.extensions.filter((extension) => newcomers.includes(extension)),\n\t\t\t\t\tthis.createContext(),\n\t\t\t\t\t{ type: \"session_start\", reason: \"startup\" },\n\t\t\t\t\t(error) => this.emitError(error),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t}\n\n\tasync emit<TEvent extends RunnerEmitEvent>(\n\t\tevent: TEvent,\n\t\tisCurrent?: () => boolean,\n\t): Promise<RunnerEmitResult<TEvent>> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunGenericHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error), isCurrent),\n\t\t);\n\t}\n\n\tasync emitMessageEnd(event: MessageEndEvent): Promise<AgentMessage | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunMessageEndHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\tasync emitToolResult(event: ToolResultEvent): Promise<ToolResultEventResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunToolResultHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\tasync emitToolCall(event: ToolCallEvent): Promise<ToolCallEventResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunToolCallHandlers(this.extensions, this.createContext(), event),\n\t\t);\n\t}\n\n\tasync emitUserBash(event: UserBashEvent): Promise<UserBashEventResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunUserBashHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\tasync emitContext(messages: AgentMessage[]): Promise<AgentMessage[]> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunContextHandlers(this.extensions, this.createContext(), messages, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\temitBeforeProviderRequest(payload: unknown): Promise<unknown> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunBeforeProviderRequestHandlers(this.extensions, this.createContext(), payload, (error) =>\n\t\t\t\tthis.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n\n\tasync emitBeforeProviderHeaders(headers: ProviderHeaders): Promise<ProviderHeaders> {\n\t\treturn runResourceRegistrationBatch(this.runtime, async () => {\n\t\t\tfor (const extension of this.extensions) {\n\t\t\t\tfor (const handler of extension.handlers.get(\"before_provider_headers\") ?? []) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait handler({ type: \"before_provider_headers\", headers }, this.createContext());\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.emitError({\n\t\t\t\t\t\t\textensionPath: extension.path,\n\t\t\t\t\t\t\tevent: \"before_provider_headers\",\n\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn headers;\n\t\t});\n\t}\n\n\temitBeforeAgentStart(\n\t\tprompt: string,\n\t\timages: ImageContent[] | undefined,\n\t\tsystemPrompt: string,\n\t\tsystemPromptOptions: BuildSystemPromptOptions,\n\t): Promise<BeforeAgentStartCombinedResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunBeforeAgentStartHandlers(\n\t\t\t\tthis.extensions,\n\t\t\t\tthis.createContext(),\n\t\t\t\t() => this.assertActive(),\n\t\t\t\tprompt,\n\t\t\t\timages,\n\t\t\t\tsystemPrompt,\n\t\t\t\tsystemPromptOptions,\n\t\t\t\t(error) => this.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n\n\temitResourcesDiscover(\n\t\tcwd: string,\n\t\treason: ResourcesDiscoverEvent[\"reason\"],\n\t): Promise<ResourcesDiscoverCombinedResult> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunResourcesDiscoverHandlers(this.extensions, this.createContext(), cwd, reason, (error) =>\n\t\t\t\tthis.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n\n\t/** Emit input event. Transforms chain, \"handled\" short-circuits. */\n\temitInput(\n\t\ttext: string,\n\t\timages: ImageContent[] | undefined,\n\t\tsource: InputSource,\n\t\tstreamingBehavior?: \"steer\" | \"followUp\",\n\t): Promise<InputEventResult> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunInputHandlers(this.extensions, this.createContext(), text, images, source, streamingBehavior, (error) =>\n\t\t\t\tthis.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/core/extensions/runner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,GAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKN,2BAA2B,EAC3B,gCAAgC,EAChC,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAU5B,OAAO,EACN,YAAY,EACZ,2BAA2B,EAC3B,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAA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,CAAC,SAAS,CAAC,KAAK,CAAC,CACrB,CACD,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,SAAS,CACR,IAAY,EACZ,MAAkC,EAClC,MAAmB,EACnB,iBAAwC;QAExC,OAAO,4BAA4B,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CACtD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC1G,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CACrB,CACD,CAAC;IACH,CAAC;CACD","sourcesContent":["/**\n * Extension runner - executes extensions and manages their lifecycle.\n */\n\nimport type { Provider, ProviderHeaders } from \"@bastani/pi-ai\";\nimport type { Api, ImageContent, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { KeyId } from \"@earendil-works/pi-tui\";\nimport type { ResourceDiagnostic } from \"../diagnostics.ts\";\nimport type { KeybindingsConfig } from \"../keybindings.ts\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type { ScopedModel } from \"../model-resolver.ts\";\nimport type { SessionManager } from \"../session-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"../system-prompt.ts\";\nimport { runResourceRegistrationBatch } from \"./loader-runtime.ts\";\nimport {\n\tcreateExtensionCommandContext,\n\tcreateExtensionContext,\n\ttype ExtensionCommandContextSource,\n} from \"./runner-context.ts\";\nimport {\n\ttype BeforeAgentStartCombinedResult,\n\ttype ResourcesDiscoverCombinedResult,\n\ttype RunnerEmitEvent,\n\ttype RunnerEmitResult,\n\trunBeforeAgentStartHandlers,\n\trunBeforeProviderRequestHandlers,\n\trunContextHandlers,\n\trunGenericHandlers,\n\trunInputHandlers,\n\trunMessageEndHandlers,\n\trunResourcesDiscoverHandlers,\n\trunToolCallHandlers,\n\trunToolResultHandlers,\n\trunUserBashHandlers,\n} from \"./runner-events.ts\";\nimport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nimport {\n\tcollectFlags,\n\tcollectMarkdownTransformers,\n\tcollectRegisteredTools,\n\tfindEntryRenderer,\n\tfindMessageRenderer,\n\tfindToolDefinition,\n\thasExtensionHandlers,\n\tresolveRegisteredCommands,\n} from \"./runner-registries.ts\";\nimport { resolveExtensionShortcuts } from \"./runner-shortcuts.ts\";\nimport { noOpUIContext } from \"./runner-ui.ts\";\nimport { STALE_EXTENSION_CONTEXT_MESSAGE } from \"./stale-context.ts\";\nimport type {\n\tCompactOptions,\n\tContextUsage,\n\tEntryRenderer,\n\tExtension,\n\tExtensionActions,\n\tExtensionCommandContext,\n\tExtensionCommandContextActions,\n\tExtensionContext,\n\tExtensionContextActions,\n\tExtensionError,\n\tExtensionFlag,\n\tExtensionMode,\n\tExtensionRuntime,\n\tExtensionShortcut,\n\tExtensionUIContext,\n\tInputEventResult,\n\tInputSource,\n\tMarkdownTransformer,\n\tMessageEndEvent,\n\tMessageRenderer,\n\tOrchestrationContext,\n\tProviderConfig,\n\tRegisteredTool,\n\tResolvedCommand,\n\tResourcesDiscoverEvent,\n\tSessionShutdownEvent,\n\tSubagentChildPolicy,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolResultEvent,\n\tToolResultEventResult,\n\tUIPromptKind,\n\tUserBashEvent,\n\tUserBashEventResult,\n} from \"./types.ts\";\n\nexport type {\n\tExtensionErrorListener,\n\tForkHandler,\n\tNavigateTreeHandler,\n\tNewSessionHandler,\n\tReloadHandler,\n\tShutdownHandler,\n\tSwitchSessionHandler,\n} from \"./runner-handlers.ts\";\nexport { emitProjectTrustEvent } from \"./runner-project-trust.ts\";\n\n/**\n * Helper function to emit session_shutdown event to extensions.\n * Returns true if the event was emitted, false if there were no handlers.\n */\nexport async function emitSessionShutdownEvent(\n\textensionRunner: ExtensionRunner,\n\tevent: SessionShutdownEvent,\n): Promise<boolean> {\n\tif (extensionRunner.hasHandlers(\"session_shutdown\")) {\n\t\tawait extensionRunner.emit(event);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nexport class ExtensionRunner {\n\tprivate extensions: Extension[];\n\tprivate runtime: ExtensionRuntime;\n\tprivate uiContext: ExtensionUIContext;\n\tprivate mode: ExtensionMode = \"print\";\n\tprivate cwd: string;\n\tprivate sessionManager: SessionManager;\n\tprivate modelRegistry: ModelRegistry;\n\tprivate orchestrationContext: OrchestrationContext | undefined;\n\tprivate subagentPolicy: SubagentChildPolicy | undefined;\n\tprivate taskHostBinding: (() => import(\"../tasks/agent-adapter.js\").AgentTaskHost) | undefined;\n\tbindTaskHost(binding: () => import(\"../tasks/agent-adapter.js\").AgentTaskHost): void {\n\t\tthis.taskHostBinding = binding;\n\t}\n\tprivate errorListeners: Set<ExtensionErrorListener> = new Set();\n\tprivate getModel: () => Model<Api> | undefined = () => undefined;\n\tprivate getScopedModels: () => readonly ScopedModel[] = () => [];\n\tprivate isIdleFn: () => boolean = () => true;\n\tprivate isProjectTrustedFn: () => boolean = () => true;\n\tprivate getSignalFn: () => AbortSignal | undefined = () => undefined;\n\tprivate waitForIdleFn: () => Promise<void> = async () => {};\n\tprivate abortFn: () => void = () => {};\n\tprivate hasPendingMessagesFn: () => boolean = () => false;\n\tprivate getContextUsageFn: () => ContextUsage | undefined = () => undefined;\n\tprivate compactFn: (options?: CompactOptions) => void = () => {};\n\tprivate getSystemPromptFn: () => string = () => \"\";\n\tprivate getSystemPromptOptionsFn: () => BuildSystemPromptOptions = () => ({ cwd: this.cwd });\n\tprivate getSkillCatalogFn: ExtensionContextActions[\"getSkillCatalog\"] = undefined;\n\tprivate newSessionHandler: NewSessionHandler = async () => ({ cancelled: false });\n\tprivate forkHandler: ForkHandler = async () => ({ cancelled: false });\n\tprivate navigateTreeHandler: NavigateTreeHandler = async () => ({ cancelled: false });\n\tprivate switchSessionHandler: SwitchSessionHandler = async () => ({ cancelled: false });\n\tprivate reloadHandler: ReloadHandler = async () => {};\n\tprivate shutdownHandler: ShutdownHandler = () => {};\n\tprivate shortcutDiagnostics: ResourceDiagnostic[] = [];\n\tprivate commandDiagnostics: ResourceDiagnostic[] = [];\n\tprivate staleMessage: string | undefined;\n\tprivate readonly contextOwner = {};\n\tprivate uiPromptBinding = 0;\n\tprivate activeUIPrompt:\n\t\t| { depth: number; reason: \"ui_prompt\" | \"project_trust\"; kind: UIPromptKind; title: string | undefined }\n\t\t| undefined;\n\n\tconstructor(\n\t\textensions: Extension[],\n\t\truntime: ExtensionRuntime,\n\t\tcwd: string,\n\t\tsessionManager: SessionManager,\n\t\tmodelRegistry: ModelRegistry,\n\t\torchestrationContext?: OrchestrationContext,\n\t\tsubagentPolicy?: SubagentChildPolicy,\n\t) {\n\t\tthis.extensions = extensions;\n\t\tthis.runtime = runtime;\n\t\tthis.runtime.workflowActivityHub.bindDispatcher((event, isCurrent) => this.emit(event, isCurrent));\n\t\tthis.uiContext = noOpUIContext;\n\t\tthis.cwd = cwd;\n\t\tthis.sessionManager = sessionManager;\n\t\tthis.modelRegistry = modelRegistry;\n\t\tthis.orchestrationContext = orchestrationContext;\n\t\tthis.subagentPolicy = subagentPolicy;\n\t}\n\n\tbindCore(\n\t\tactions: ExtensionActions,\n\t\tcontextActions: ExtensionContextActions,\n\t\tproviderActions?: {\n\t\t\tregisterProvider?: (providerOrName: Provider | string, config?: ProviderConfig) => void;\n\t\t\tunregisterProvider?: (name: string) => void;\n\t\t},\n\t): void {\n\t\t// Copy actions into the shared runtime (all extension APIs reference this)\n\t\tthis.runtime.sendMessage = actions.sendMessage;\n\t\tthis.runtime.sendMessages = actions.sendMessages;\n\t\tthis.runtime.sendUserMessage = actions.sendUserMessage;\n\t\tthis.runtime.appendEntry = actions.appendEntry;\n\t\tthis.runtime.setSessionName = actions.setSessionName;\n\t\tthis.runtime.getSessionName = actions.getSessionName;\n\t\tthis.runtime.setLabel = actions.setLabel;\n\t\tthis.runtime.getActiveTools = actions.getActiveTools;\n\t\tthis.runtime.getAllTools = actions.getAllTools;\n\t\tthis.runtime.setActiveTools = actions.setActiveTools;\n\t\tthis.runtime.refreshTools = actions.refreshTools;\n\t\tthis.runtime.getCommands = actions.getCommands;\n\t\tthis.runtime.setModel = actions.setModel;\n\t\tthis.runtime.getThinkingLevel = actions.getThinkingLevel;\n\t\tthis.runtime.setThinkingLevel = actions.setThinkingLevel;\n\n\t\t// Context actions (required)\n\t\tthis.getModel = contextActions.getModel;\n\t\tthis.getScopedModels = contextActions.getScopedModels;\n\t\tthis.isIdleFn = contextActions.isIdle;\n\t\tthis.isProjectTrustedFn = contextActions.isProjectTrusted;\n\t\tthis.getSignalFn = contextActions.getSignal;\n\t\tthis.abortFn = contextActions.abort;\n\t\tthis.hasPendingMessagesFn = contextActions.hasPendingMessages;\n\t\tthis.shutdownHandler = contextActions.shutdown;\n\t\tthis.getContextUsageFn = contextActions.getContextUsage;\n\t\tthis.compactFn = contextActions.compact;\n\t\tthis.getSystemPromptFn = contextActions.getSystemPrompt;\n\t\tthis.getSystemPromptOptionsFn = contextActions.getSystemPromptOptions ?? (() => ({ cwd: this.cwd }));\n\t\tthis.getSkillCatalogFn = contextActions.getSkillCatalog;\n\n\t\t// Flush provider registrations queued during extension loading.\n\t\tfor (const registration of this.runtime.pendingProviderRegistrations) {\n\t\t\ttry {\n\t\t\t\tif (\"provider\" in registration) {\n\t\t\t\t\t(\n\t\t\t\t\t\tproviderActions?.registerProvider ??\n\t\t\t\t\t\t((provider: Provider) => this.modelRegistry.registerProvider(provider))\n\t\t\t\t\t)(registration.provider);\n\t\t\t\t} else {\n\t\t\t\t\t(\n\t\t\t\t\t\tproviderActions?.registerProvider ??\n\t\t\t\t\t\t((name: string, config?: ProviderConfig) => this.modelRegistry.registerProvider(name, config!))\n\t\t\t\t\t)(registration.name, registration.config);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tthis.emitError({\n\t\t\t\t\textensionPath: registration.extensionPath,\n\t\t\t\t\tevent: \"register_provider\",\n\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis.runtime.pendingProviderRegistrations = [];\n\n\t\t// From this point on, provider registration/unregistration takes effect immediately\n\t\t// without requiring a /reload.\n\t\tthis.runtime.registerProvider = ((providerOrName: Provider | string, configOrPath?: ProviderConfig | string) => {\n\t\t\tif (typeof providerOrName === \"string\") {\n\t\t\t\tconst config = configOrPath as ProviderConfig;\n\t\t\t\tif (providerActions?.registerProvider) providerActions.registerProvider(providerOrName, config);\n\t\t\t\telse this.modelRegistry.registerProvider(providerOrName, config);\n\t\t\t} else if (providerActions?.registerProvider) providerActions.registerProvider(providerOrName);\n\t\t\telse this.modelRegistry.registerProvider(providerOrName);\n\t\t}) as ExtensionRuntime[\"registerProvider\"];\n\t\tthis.runtime.unregisterProvider = (name) => {\n\t\t\tif (providerActions?.unregisterProvider) {\n\t\t\t\tproviderActions.unregisterProvider(name);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.modelRegistry.unregisterProvider(name);\n\t\t};\n\t}\n\n\tbindCommandContext(actions?: ExtensionCommandContextActions): void {\n\t\tif (actions) {\n\t\t\tthis.waitForIdleFn = actions.waitForIdle;\n\t\t\tthis.newSessionHandler = actions.newSession;\n\t\t\tthis.forkHandler = actions.fork;\n\t\t\tthis.navigateTreeHandler = actions.navigateTree;\n\t\t\tthis.switchSessionHandler = actions.switchSession;\n\t\t\tthis.reloadHandler = actions.reload;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.waitForIdleFn = async () => {};\n\t\tthis.newSessionHandler = async () => ({ cancelled: false });\n\t\tthis.forkHandler = async () => ({ cancelled: false });\n\t\tthis.navigateTreeHandler = async () => ({ cancelled: false });\n\t\tthis.switchSessionHandler = async () => ({ cancelled: false });\n\t\tthis.reloadHandler = async () => {};\n\t}\n\n\tsetUIContext(uiContext?: ExtensionUIContext, mode: ExtensionMode = \"print\"): void {\n\t\tthis.endActiveUIPrompt();\n\t\tconst binding = ++this.uiPromptBinding;\n\t\tthis.uiContext = uiContext ? this.wrapUIPromptContext(uiContext, binding) : noOpUIContext;\n\t\tthis.mode = mode;\n\t}\n\n\tprivate wrapUIPromptContext(ui: ExtensionUIContext, binding: number): ExtensionUIContext {\n\t\treturn {\n\t\t\t...ui,\n\t\t\tselect: (title, options, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"select\", title, () => ui.select(title, options, opts)),\n\t\t\tconfirm: (title, message, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"confirm\", title, () => ui.confirm(title, message, opts)),\n\t\t\tinput: (title, placeholder, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"input\", title, () => ui.input(title, placeholder, opts)),\n\t\t\teditor: (title, prefill, opts) =>\n\t\t\t\tthis.withUIPrompt(binding, \"editor\", title, () => ui.editor(title, prefill, opts)),\n\t\t\tcustom: (factory, options) =>\n\t\t\t\toptions?.purpose === \"navigation\"\n\t\t\t\t\t? ui.custom(factory, options)\n\t\t\t\t\t: this.withUIPrompt(binding, \"custom\", undefined, () => ui.custom(factory, options)),\n\t\t};\n\t}\n\n\t/** Track a host-owned trust dialog using the current session's prompt lifecycle. */\n\twithProjectTrustPrompt<T>(kind: UIPromptKind, title: string, run: () => Promise<T>): Promise<T> {\n\t\treturn this.withUIPrompt(this.uiPromptBinding, kind, title, run, \"project_trust\");\n\t}\n\n\t/** Begin a host-owned trust span whose end arrives as a separate control frame. */\n\tbeginProjectTrustPrompt(kind: UIPromptKind, title: string): () => void {\n\t\treturn this.beginUIPrompt(kind, title, \"project_trust\");\n\t}\n\n\tprivate withUIPrompt<T>(\n\t\tbinding: number,\n\t\tkind: UIPromptKind,\n\t\ttitle: string | undefined,\n\t\trun: () => Promise<T>,\n\t\treason: \"ui_prompt\" | \"project_trust\" = \"ui_prompt\",\n\t): Promise<T> {\n\t\tif (binding !== this.uiPromptBinding) return run();\n\t\tconst finish = this.beginUIPrompt(kind, title, reason);\n\t\ttry {\n\t\t\treturn run().finally(finish);\n\t\t} catch (error) {\n\t\t\tfinish();\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate beginUIPrompt(\n\t\tkind: UIPromptKind,\n\t\ttitle: string | undefined,\n\t\treason: \"ui_prompt\" | \"project_trust\",\n\t): () => void {\n\t\tlet prompt = this.activeUIPrompt;\n\t\tif (!prompt) {\n\t\t\tprompt = { depth: 0, reason, kind, title };\n\t\t\tthis.activeUIPrompt = prompt;\n\t\t\tthis.emitUIPromptEvent({\n\t\t\t\ttype: \"ui_prompt_start\",\n\t\t\t\treason,\n\t\t\t\tkind,\n\t\t\t\t...(title === undefined ? {} : { title }),\n\t\t\t});\n\t\t}\n\t\tprompt.depth += 1;\n\n\t\tlet finished = false;\n\t\treturn () => {\n\t\t\tif (finished) return;\n\t\t\tfinished = true;\n\t\t\tif (this.activeUIPrompt !== prompt) return;\n\n\t\t\tprompt.depth -= 1;\n\t\t\tif (prompt.depth === 0) this.endActiveUIPrompt(prompt);\n\t\t};\n\t}\n\n\tprivate endActiveUIPrompt(prompt = this.activeUIPrompt): void {\n\t\tif (!prompt || this.activeUIPrompt !== prompt) return;\n\t\tthis.activeUIPrompt = undefined;\n\t\tprompt.depth = 0;\n\t\tthis.emitUIPromptEvent({\n\t\t\ttype: \"ui_prompt_end\",\n\t\t\treason: prompt.reason,\n\t\t\tkind: prompt.kind,\n\t\t\t...(prompt.title === undefined ? {} : { title: prompt.title }),\n\t\t});\n\t}\n\n\tprivate readonly pendingUIPromptNotifications = new Set<Promise<void>>();\n\n\tprivate emitUIPromptEvent(event: Extract<RunnerEmitEvent, { type: \"ui_prompt_start\" | \"ui_prompt_end\" }>): void {\n\t\tconst delivery = Promise.resolve().then(async () => {\n\t\t\tawait this.emit(event);\n\t\t});\n\t\tthis.pendingUIPromptNotifications.add(delivery);\n\t\tvoid delivery.finally(() => this.pendingUIPromptNotifications.delete(delivery)).catch(() => {});\n\t}\n\n\t/** Settle only the deliveries pending at this boundary, without delaying prompt UI. */\n\tasync flushUIPromptNotifications(timeoutMs: number): Promise<{ timedOut: boolean }> {\n\t\tconst pending = [...this.pendingUIPromptNotifications];\n\t\tif (pending.length === 0) return { timedOut: false };\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\treturn await Promise.race([\n\t\t\t\tPromise.allSettled(pending).then(() => ({ timedOut: false })),\n\t\t\t\tnew Promise<{ timedOut: boolean }>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => resolve({ timedOut: true }), timeoutMs);\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t}\n\t}\n\n\tgetUIContext(): ExtensionUIContext {\n\t\treturn this.uiContext;\n\t}\n\n\thasUI(): boolean {\n\t\treturn this.uiContext !== noOpUIContext;\n\t}\n\n\tgetExtensionPaths(): string[] {\n\t\treturn this.extensions.map((extension) => extension.path);\n\t}\n\n\t/** Get all registered tools from all extensions (first registration per name wins). */\n\tgetAllRegisteredTools(): RegisteredTool[] {\n\t\treturn collectRegisteredTools(this.extensions);\n\t}\n\n\t/** Get a tool definition by name. Returns undefined if not found. */\n\tgetToolDefinition(toolName: string): RegisteredTool[\"definition\"] | undefined {\n\t\treturn findToolDefinition(this.extensions, toolName);\n\t}\n\n\tgetFlags(): Map<string, ExtensionFlag> {\n\t\treturn collectFlags(this.extensions);\n\t}\n\n\tsetFlagValue(name: string, value: boolean | string): void {\n\t\tthis.runtime.flagValues.set(name, value);\n\t\tthis.runtime.explicitFlagNames ??= new Set();\n\t\tthis.runtime.explicitFlagNames.add(name);\n\t}\n\n\tgetFlagValues(): Map<string, boolean | string> {\n\t\treturn new Map(this.runtime.flagValues);\n\t}\n\n\tgetExplicitFlagValues(): Map<string, boolean | string> {\n\t\tconst explicitFlagNames = this.runtime.explicitFlagNames ?? new Set<string>();\n\t\treturn new Map([...this.runtime.flagValues].filter(([name]) => explicitFlagNames.has(name)));\n\t}\n\n\tgetShortcuts(resolvedKeybindings: KeybindingsConfig): Map<KeyId, ExtensionShortcut> {\n\t\tconst resolution = resolveExtensionShortcuts(this.extensions, resolvedKeybindings, this.hasUI());\n\t\tthis.shortcutDiagnostics = resolution.diagnostics;\n\t\treturn resolution.shortcuts;\n\t}\n\n\tgetShortcutDiagnostics(): ResourceDiagnostic[] {\n\t\treturn this.shortcutDiagnostics;\n\t}\n\n\tinvalidate(message = STALE_EXTENSION_CONTEXT_MESSAGE): void {\n\t\tif (!this.staleMessage) {\n\t\t\tthis.staleMessage = message;\n\t\t\tthis.runtime.invalidate(message);\n\t\t}\n\t}\n\n\tprivate assertActive(): void {\n\t\tif (this.staleMessage) {\n\t\t\tthrow new Error(this.staleMessage);\n\t\t}\n\t}\n\n\tonError(listener: ExtensionErrorListener): () => void {\n\t\tthis.errorListeners.add(listener);\n\t\treturn () => this.errorListeners.delete(listener);\n\t}\n\n\temitError(error: ExtensionError): void {\n\t\tfor (const listener of this.errorListeners) {\n\t\t\tlistener(error);\n\t\t}\n\t}\n\n\thasHandlers(eventType: string): boolean {\n\t\treturn hasExtensionHandlers(this.extensions, eventType);\n\t}\n\n\tgetMessageRenderer(customType: string): MessageRenderer | undefined {\n\t\treturn findMessageRenderer(this.extensions, customType);\n\t}\n\n\tgetMarkdownTransformers(): MarkdownTransformer[] {\n\t\treturn collectMarkdownTransformers(this.extensions);\n\t}\n\n\tgetEntryRenderer(customType: string): EntryRenderer | undefined {\n\t\treturn findEntryRenderer(this.extensions, customType);\n\t}\n\n\tgetRegisteredCommands(): ResolvedCommand[] {\n\t\tthis.commandDiagnostics = [];\n\t\treturn resolveRegisteredCommands(this.extensions);\n\t}\n\n\tgetCommandDiagnostics(): ResourceDiagnostic[] {\n\t\treturn this.commandDiagnostics;\n\t}\n\n\tgetCommand(name: string): ResolvedCommand | undefined {\n\t\treturn resolveRegisteredCommands(this.extensions).find((command) => command.invocationName === name);\n\t}\n\n\t/**\n\t * Request a graceful shutdown. Called by extension tools and event handlers.\n\t * The actual shutdown behavior is provided by the mode via bindExtensions().\n\t */\n\tshutdown(): void {\n\t\tthis.shutdownHandler();\n\t}\n\n\tcreateContext(): ExtensionContext {\n\t\treturn createExtensionContext(this.createContextSource(), this.contextOwner);\n\t}\n\n\tcreateCommandContext(): ExtensionCommandContext {\n\t\treturn createExtensionCommandContext(this.createContextSource(), this.contextOwner);\n\t}\n\n\tprivate createContextSource(): ExtensionCommandContextSource {\n\t\treturn {\n\t\t\tassertActive: () => this.assertActive(),\n\t\t\tgetExtensionPaths: () => this.getExtensionPaths(),\n\t\t\tobserveWorkflowActivity: (observer) => this.runtime.workflowActivityHub.observeWorkflowActivity(observer),\n\t\t\t...(this.taskHostBinding ? { getAgentTaskHost: this.taskHostBinding } : {}),\n\t\t\tgetUIContext: () => this.uiContext,\n\t\t\tgetMode: () => this.mode,\n\t\t\thasUI: () => this.hasUI(),\n\t\t\tgetCwd: () => this.cwd,\n\t\t\tgetSessionManager: () => this.sessionManager,\n\t\t\tgetModelRegistry: () => this.modelRegistry,\n\t\t\tgetModel: () => this.getModel(),\n\t\t\tgetSubagentPolicy: () => this.subagentPolicy,\n\t\t\tgetScopedModels: () => this.getScopedModels(),\n\t\t\tgetThinkingLevel: () => this.runtime.getThinkingLevel(),\n\t\t\tgetOrchestrationContext: () => this.orchestrationContext,\n\t\t\tisIdle: () => this.isIdleFn(),\n\t\t\tisProjectTrusted: () => this.isProjectTrustedFn(),\n\t\t\tgetSignal: () => this.getSignalFn(),\n\t\t\tabort: () => this.abortFn(),\n\t\t\thasPendingMessages: () => this.hasPendingMessagesFn(),\n\t\t\tshutdown: () => this.shutdownHandler(),\n\t\t\tgetContextUsage: () => this.getContextUsageFn(),\n\t\t\tcompact: (options) => this.compactFn(options),\n\t\t\tgetSystemPrompt: () => this.getSystemPromptFn(),\n\t\t\t...(this.getSkillCatalogFn ? { getSkillCatalog: () => this.getSkillCatalogFn!() } : {}),\n\t\t\tgetSystemPromptOptions: () => this.getSystemPromptOptionsFn(),\n\t\t\twaitForIdle: () => this.waitForIdleFn(),\n\t\t\tnewSession: (options) => this.newSessionHandler(options),\n\t\t\tfork: (entryId, options) => this.forkHandler(entryId, options),\n\t\t\tnavigateTree: (targetId, options) => this.navigateTreeHandler(targetId, options),\n\t\t\tswitchSession: (sessionPath, options) => this.switchSessionHandler(sessionPath, options),\n\t\t\treload: () => this.reloadHandler(),\n\t\t};\n\t}\n\n\t/** Keep startup reporters bound while adding the now-authorized extension set. */\n\tattachStartupExtensions(extensions: Extension[]): () => Promise<void> {\n\t\tconst newcomers = extensions.filter((extension) => !this.extensions.includes(extension));\n\t\tthis.extensions = [...this.extensions, ...newcomers];\n\t\treturn async () => {\n\t\t\tawait runResourceRegistrationBatch(this.runtime, () =>\n\t\t\t\trunGenericHandlers(\n\t\t\t\t\tthis.extensions.filter((extension) => newcomers.includes(extension)),\n\t\t\t\t\tthis.createContext(),\n\t\t\t\t\t{ type: \"session_start\", reason: \"startup\" },\n\t\t\t\t\t(error) => this.emitError(error),\n\t\t\t\t),\n\t\t\t);\n\t\t};\n\t}\n\n\tasync emit<TEvent extends RunnerEmitEvent>(\n\t\tevent: TEvent,\n\t\tisCurrent?: () => boolean,\n\t): Promise<RunnerEmitResult<TEvent>> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunGenericHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error), isCurrent),\n\t\t);\n\t}\n\n\tasync emitMessageEnd(event: MessageEndEvent): Promise<AgentMessage | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunMessageEndHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\tasync emitToolResult(event: ToolResultEvent): Promise<ToolResultEventResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunToolResultHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\tasync emitToolCall(event: ToolCallEvent): Promise<ToolCallEventResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunToolCallHandlers(this.extensions, this.createContext(), event),\n\t\t);\n\t}\n\n\tasync emitUserBash(event: UserBashEvent): Promise<UserBashEventResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunUserBashHandlers(this.extensions, this.createContext(), event, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\tasync emitContext(messages: AgentMessage[]): Promise<AgentMessage[]> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunContextHandlers(this.extensions, this.createContext(), messages, (error) => this.emitError(error)),\n\t\t);\n\t}\n\n\temitBeforeProviderRequest(payload: unknown): Promise<unknown> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunBeforeProviderRequestHandlers(this.extensions, this.createContext(), payload, (error) =>\n\t\t\t\tthis.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n\n\tasync emitBeforeProviderHeaders(headers: ProviderHeaders): Promise<ProviderHeaders> {\n\t\treturn runResourceRegistrationBatch(this.runtime, async () => {\n\t\t\tfor (const extension of this.extensions) {\n\t\t\t\tfor (const handler of extension.handlers.get(\"before_provider_headers\") ?? []) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait handler({ type: \"before_provider_headers\", headers }, this.createContext());\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.emitError({\n\t\t\t\t\t\t\textensionPath: extension.path,\n\t\t\t\t\t\t\tevent: \"before_provider_headers\",\n\t\t\t\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\t\tstack: error instanceof Error ? error.stack : undefined,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn headers;\n\t\t});\n\t}\n\n\temitBeforeAgentStart(\n\t\tprompt: string,\n\t\timages: ImageContent[] | undefined,\n\t\tsystemPrompt: string,\n\t\tsystemPromptOptions: BuildSystemPromptOptions,\n\t): Promise<BeforeAgentStartCombinedResult | undefined> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunBeforeAgentStartHandlers(\n\t\t\t\tthis.extensions,\n\t\t\t\tthis.createContext(),\n\t\t\t\t() => this.assertActive(),\n\t\t\t\tprompt,\n\t\t\t\timages,\n\t\t\t\tsystemPrompt,\n\t\t\t\tsystemPromptOptions,\n\t\t\t\t(error) => this.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n\n\temitResourcesDiscover(\n\t\tcwd: string,\n\t\treason: ResourcesDiscoverEvent[\"reason\"],\n\t): Promise<ResourcesDiscoverCombinedResult> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunResourcesDiscoverHandlers(this.extensions, this.createContext(), cwd, reason, (error) =>\n\t\t\t\tthis.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n\n\t/** Emit input event. Transforms chain, \"handled\" short-circuits. */\n\temitInput(\n\t\ttext: string,\n\t\timages: ImageContent[] | undefined,\n\t\tsource: InputSource,\n\t\tstreamingBehavior?: \"steer\" | \"followUp\",\n\t): Promise<InputEventResult> {\n\t\treturn runResourceRegistrationBatch(this.runtime, () =>\n\t\t\trunInputHandlers(this.extensions, this.createContext(), text, images, source, streamingBehavior, (error) =>\n\t\t\t\tthis.emitError(error),\n\t\t\t),\n\t\t);\n\t}\n}\n"]}
@@ -3,7 +3,7 @@ export type WorkflowActivityReason = "executing" | "automatic_continuation" | "r
3
3
  export type WorkflowRunStatus = "pending" | "running" | "paused" | "completed" | "skipped" | "cancelled" | "blocked" | "failed" | "killed";
4
4
  export type WorkflowStageStatus = "pending" | "running" | "awaiting_input" | "paused" | "blocked" | "completed" | "failed" | "skipped";
5
5
  export type WorkflowToolNodeStatus = "pending" | "running" | "completed" | "failed" | "cached" | "cancelled";
6
- export type WorkflowControlAction = "interrupt" | "quit" | "kill" | "pause" | "resume";
6
+ export type WorkflowControlAction = "quit" | "kill" | "pause" | "resume";
7
7
  export interface WorkflowRootActivity {
8
8
  rootRunId: string;
9
9
  ownerSessionId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-events.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAC/B,WAAW,GACX,wBAAwB,GACxB,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,qBAAqB,GACrB,QAAQ,GACR,WAAW,CAAC;AAGf,MAAM,MAAM,iBAAiB,GAC1B,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,GACX,SAAS,GACT,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,CAAC;AACZ,MAAM,MAAM,mBAAmB,GAC5B,SAAS,GACT,SAAS,GACT,gBAAgB,GAChB,QAAQ,GACR,SAAS,GACT,WAAW,GACX,QAAQ,GACR,SAAS,CAAC;AACb,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC7G,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvF,MAAM,WAAW,oBAAoB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CACxB;AACD,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,MAAM,CAA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AW,sBAAsB;IACtC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACxB;AACD,MAAM,MAAM,aAAa,GACtB,sBAAsB,GACtB,2BAA2B,GAC3B,4BAA4B,GAC5B,sBAAsB,CAAC;AAC1B,MAAM,WAAW,yBAAyB;IACzC,eAAe,CAAC,KAAK,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC5D,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACjD,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IACtE,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;CAChB;AACD,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EACD,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,GACnB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,CAAC;IACrB,MAAM,EAAE,yBAAyB,CAAC;CAClC"}
1
+ {"version":3,"file":"workflow-events.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAC/B,WAAW,GACX,wBAAwB,GACxB,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,qBAAqB,GACrB,QAAQ,GACR,WAAW,CAAC;AAGf,MAAM,MAAM,iBAAiB,GAC1B,SAAS,GACT,SAAS,GACT,QAAQ,GACR,WAAW,GACX,SAAS,GACT,WAAW,GACX,SAA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AAC;IACtE,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACtD,OAAO,IAAI,IAAI,CAAC;CAChB;AACD,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EACD,kBAAkB,GAClB,kBAAkB,GAClB,mBAAmB,GACnB,wBAAwB,GACxB,kBAAkB,GAClB,iBAAiB,CAAC;IACrB,MAAM,EAAE,yBAAyB,CAAC;CAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-events.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"","sourcesContent":["export type WorkflowActivityState = \"working\" | \"idle\" | \"blocked\";\nexport type WorkflowActivityReason =\n\t| \"executing\"\n\t| \"automatic_continuation\"\n\t| \"retrying\"\n\t| \"stopping\"\n\t| \"awaiting_input\"\n\t| \"manual_intervention\"\n\t| \"paused\"\n\t| \"quiescent\";\n\n// Kept in sync with workflows/shared/store-types without a host runtime dependency.\nexport type WorkflowRunStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"paused\"\n\t| \"completed\"\n\t| \"skipped\"\n\t| \"cancelled\"\n\t| \"blocked\"\n\t| \"failed\"\n\t| \"killed\";\nexport type WorkflowStageStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"awaiting_input\"\n\t| \"paused\"\n\t| \"blocked\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"skipped\";\nexport type WorkflowToolNodeStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"cached\" | \"cancelled\";\nexport type WorkflowControlAction = \"interrupt\" | \"quit\" | \"kill\" | \"pause\" | \"resume\";\n\nexport interface WorkflowRootActivity {\n\trootRunId: string;\n\townerSessionId: string;\n\tstate: WorkflowActivityState;\n\treason: WorkflowActivityReason;\n\tactiveExecutionCount: number;\n\tactionableBlockCount: number;\n\tneedsAttention: boolean;\n}\nexport interface WorkflowObservationCursor {\n\tepoch: string;\n\trevision: number;\n}\nexport type WorkflowActivitySnapshotInput =\n\t| { availability: \"ready\"; roots: readonly WorkflowRootActivity[] }\n\t| { availability: \"recovering\" | \"unavailable\" };\nexport type WorkflowActivitySnapshotFrame = WorkflowActivitySnapshotInput & {\n\tkind: \"snapshot\";\n\tcursor: WorkflowObservationCursor;\n};\nexport type WorkflowActivityFrame =\n\t| WorkflowActivitySnapshotFrame\n\t| { kind: \"changed\"; cursor: WorkflowObservationCursor; root: WorkflowRootActivity }\n\t| { kind: \"removed\"; cursor: WorkflowObservationCursor; rootRunId: string };\nexport type WorkflowActivityObserver = (frame: WorkflowActivityFrame) => void | Promise<void>;\nexport interface WorkflowActivitySubscription {\n\tdispose(): void;\n}\nexport type WorkflowLifecycleDelivery = \"live\" | \"replay\";\nexport type WorkflowLifecycleTarget =\n\t| {\n\t\t\tkind: \"run\";\n\t\t\trunId: string;\n\t\t\tpreviousStatus?: WorkflowRunStatus;\n\t\t\tstatus: WorkflowRunStatus;\n\t\t\taction?: WorkflowControlAction;\n\t }\n\t| {\n\t\t\tkind: \"stage\";\n\t\t\trunId: string;\n\t\t\tstageId: string;\n\t\t\tstageName: string;\n\t\t\tpreviousStatus?: WorkflowStageStatus;\n\t\t\tstatus: WorkflowStageStatus;\n\t }\n\t| {\n\t\t\tkind: \"tool\";\n\t\t\trunId: string;\n\t\t\ttoolNodeId: string;\n\t\t\ttoolName: string;\n\t\t\tpreviousStatus?: WorkflowToolNodeStatus;\n\t\t\tstatus: WorkflowToolNodeStatus;\n\t }\n\t| { kind: \"prompt\"; runId: string; stageId?: string; promptId: string; status: \"opened\" | \"answered\" | \"cancelled\" };\nexport interface WorkflowLifecycleEvent {\n\ttype: \"workflow_lifecycle\";\n\teventId: string;\n\tcursor: WorkflowObservationCursor;\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\toccurredAt: number;\n\tobservedAt: number;\n\tdelivery: WorkflowLifecycleDelivery;\n\ttarget: WorkflowLifecycleTarget;\n\tattribution?: \"user\" | \"agent\" | \"scheduler\" | \"recovery\" | \"unknown\";\n}\nexport interface WorkflowStageCompletedEvent extends Omit<WorkflowLifecycleEvent, \"type\" | \"target\"> {\n\ttype: \"workflow_stage_completed\";\n\ttarget: Extract<WorkflowLifecycleTarget, { kind: \"stage\" }> & { status: \"completed\" };\n}\nexport interface WorkflowActivityChangedEvent {\n\ttype: \"workflow_activity_changed\";\n\tcursor: WorkflowObservationCursor;\n\troot: WorkflowRootActivity;\n}\nexport interface WorkflowHeartbeatEvent {\n\ttype: \"workflow_heartbeat\";\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\tscheduledAt: number;\n\tintervalMinutes: number;\n}\nexport type WorkflowEvent =\n\t| WorkflowLifecycleEvent\n\t| WorkflowStageCompletedEvent\n\t| WorkflowActivityChangedEvent\n\t| WorkflowHeartbeatEvent;\nexport interface WorkflowActivityPublisher {\n\tpublishSnapshot(input: WorkflowActivitySnapshotInput): void;\n\tpublishChanged(root: WorkflowRootActivity): void;\n\tpublishRemoved(rootRunId: string): void;\n\tpublishLifecycle(event: Omit<WorkflowLifecycleEvent, \"cursor\">): void;\n\tpublishHeartbeat(event: WorkflowHeartbeatEvent): void;\n\tdispose(): void;\n}\nexport interface WorkflowObservationDiagnostic {\n\tkind:\n\t\t| \"ObserverDisposed\"\n\t\t| \"SourceRecovering\"\n\t\t| \"SourceUnavailable\"\n\t\t| \"ObserverDeliveryFailed\"\n\t\t| \"ObserverOverflow\"\n\t\t| \"PublisherFenced\";\n\tcursor: WorkflowObservationCursor;\n}\n"]}
1
+ {"version":3,"file":"workflow-events.js","sourceRoot":"","sources":["../../../src/core/extensions/workflow-events.ts"],"names":[],"mappings":"","sourcesContent":["export type WorkflowActivityState = \"working\" | \"idle\" | \"blocked\";\nexport type WorkflowActivityReason =\n\t| \"executing\"\n\t| \"automatic_continuation\"\n\t| \"retrying\"\n\t| \"stopping\"\n\t| \"awaiting_input\"\n\t| \"manual_intervention\"\n\t| \"paused\"\n\t| \"quiescent\";\n\n// Kept in sync with workflows/shared/store-types without a host runtime dependency.\nexport type WorkflowRunStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"paused\"\n\t| \"completed\"\n\t| \"skipped\"\n\t| \"cancelled\"\n\t| \"blocked\"\n\t| \"failed\"\n\t| \"killed\";\nexport type WorkflowStageStatus =\n\t| \"pending\"\n\t| \"running\"\n\t| \"awaiting_input\"\n\t| \"paused\"\n\t| \"blocked\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"skipped\";\nexport type WorkflowToolNodeStatus = \"pending\" | \"running\" | \"completed\" | \"failed\" | \"cached\" | \"cancelled\";\nexport type WorkflowControlAction = \"quit\" | \"kill\" | \"pause\" | \"resume\";\n\nexport interface WorkflowRootActivity {\n\trootRunId: string;\n\townerSessionId: string;\n\tstate: WorkflowActivityState;\n\treason: WorkflowActivityReason;\n\tactiveExecutionCount: number;\n\tactionableBlockCount: number;\n\tneedsAttention: boolean;\n}\nexport interface WorkflowObservationCursor {\n\tepoch: string;\n\trevision: number;\n}\nexport type WorkflowActivitySnapshotInput =\n\t| { availability: \"ready\"; roots: readonly WorkflowRootActivity[] }\n\t| { availability: \"recovering\" | \"unavailable\" };\nexport type WorkflowActivitySnapshotFrame = WorkflowActivitySnapshotInput & {\n\tkind: \"snapshot\";\n\tcursor: WorkflowObservationCursor;\n};\nexport type WorkflowActivityFrame =\n\t| WorkflowActivitySnapshotFrame\n\t| { kind: \"changed\"; cursor: WorkflowObservationCursor; root: WorkflowRootActivity }\n\t| { kind: \"removed\"; cursor: WorkflowObservationCursor; rootRunId: string };\nexport type WorkflowActivityObserver = (frame: WorkflowActivityFrame) => void | Promise<void>;\nexport interface WorkflowActivitySubscription {\n\tdispose(): void;\n}\nexport type WorkflowLifecycleDelivery = \"live\" | \"replay\";\nexport type WorkflowLifecycleTarget =\n\t| {\n\t\t\tkind: \"run\";\n\t\t\trunId: string;\n\t\t\tpreviousStatus?: WorkflowRunStatus;\n\t\t\tstatus: WorkflowRunStatus;\n\t\t\taction?: WorkflowControlAction;\n\t }\n\t| {\n\t\t\tkind: \"stage\";\n\t\t\trunId: string;\n\t\t\tstageId: string;\n\t\t\tstageName: string;\n\t\t\tpreviousStatus?: WorkflowStageStatus;\n\t\t\tstatus: WorkflowStageStatus;\n\t }\n\t| {\n\t\t\tkind: \"tool\";\n\t\t\trunId: string;\n\t\t\ttoolNodeId: string;\n\t\t\ttoolName: string;\n\t\t\tpreviousStatus?: WorkflowToolNodeStatus;\n\t\t\tstatus: WorkflowToolNodeStatus;\n\t }\n\t| { kind: \"prompt\"; runId: string; stageId?: string; promptId: string; status: \"opened\" | \"answered\" | \"cancelled\" };\nexport interface WorkflowLifecycleEvent {\n\ttype: \"workflow_lifecycle\";\n\teventId: string;\n\tcursor: WorkflowObservationCursor;\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\toccurredAt: number;\n\tobservedAt: number;\n\tdelivery: WorkflowLifecycleDelivery;\n\ttarget: WorkflowLifecycleTarget;\n\tattribution?: \"user\" | \"agent\" | \"scheduler\" | \"recovery\" | \"unknown\";\n}\nexport interface WorkflowStageCompletedEvent extends Omit<WorkflowLifecycleEvent, \"type\" | \"target\"> {\n\ttype: \"workflow_stage_completed\";\n\ttarget: Extract<WorkflowLifecycleTarget, { kind: \"stage\" }> & { status: \"completed\" };\n}\nexport interface WorkflowActivityChangedEvent {\n\ttype: \"workflow_activity_changed\";\n\tcursor: WorkflowObservationCursor;\n\troot: WorkflowRootActivity;\n}\nexport interface WorkflowHeartbeatEvent {\n\ttype: \"workflow_heartbeat\";\n\trunId: string;\n\trootRunId: string;\n\townerSessionId: string;\n\tscheduledAt: number;\n\tintervalMinutes: number;\n}\nexport type WorkflowEvent =\n\t| WorkflowLifecycleEvent\n\t| WorkflowStageCompletedEvent\n\t| WorkflowActivityChangedEvent\n\t| WorkflowHeartbeatEvent;\nexport interface WorkflowActivityPublisher {\n\tpublishSnapshot(input: WorkflowActivitySnapshotInput): void;\n\tpublishChanged(root: WorkflowRootActivity): void;\n\tpublishRemoved(rootRunId: string): void;\n\tpublishLifecycle(event: Omit<WorkflowLifecycleEvent, \"cursor\">): void;\n\tpublishHeartbeat(event: WorkflowHeartbeatEvent): void;\n\tdispose(): void;\n}\nexport interface WorkflowObservationDiagnostic {\n\tkind:\n\t\t| \"ObserverDisposed\"\n\t\t| \"SourceRecovering\"\n\t\t| \"SourceUnavailable\"\n\t\t| \"ObserverDeliveryFailed\"\n\t\t| \"ObserverOverflow\"\n\t\t| \"PublisherFenced\";\n\tcursor: WorkflowObservationCursor;\n}\n"]}
@@ -5,5 +5,5 @@ export { isPowerShellToolResult } from "./extensions/index.js";
5
5
  export type { PromptTemplate } from "./prompt-templates.ts";
6
6
  export type { Skill } from "./skills.ts";
7
7
  export type { JsonObject, JsonPrimitive, JsonValue, PowerShellOperations, PowerShellSpawnContext, PowerShellSpawnHook, PowerShellToolDetails, PowerShellToolInput, PowerShellToolOptions, ShellToolPresentation, StructuredOutputCapture, StructuredOutputFileCapture, StructuredOutputToolOptions, Tool, } from "./tools/index.ts";
8
- export { BASH_SHELL_PRESENTATION, createBashTool, createCodingTools, createEditTool, createFindTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.ts";
8
+ export { BASH_SHELL_PRESENTATION, createBashTool, createCodingTools, createEditTool, createFindTool, createKillTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.ts";
9
9
  //# sourceMappingURL=sdk-exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-exports.d.ts","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,IAAI,GACJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,cAAc,EAEd,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"sdk-exports.d.ts","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EACX,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EACX,UAAU,EACV,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,IAAI,GACJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,cAAc,EAEd,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC"}
@@ -3,5 +3,5 @@ export * from "./agent-session-runtime.js";
3
3
  export { isPowerShellToolResult } from "./extensions/index.js";
4
4
  export { BASH_SHELL_PRESENTATION, createBashTool,
5
5
  // Tool factories (for custom cwd)
6
- createCodingTools, createEditTool, createFindTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.js";
6
+ createCodingTools, createEditTool, createFindTool, createKillTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.js";
7
7
  //# sourceMappingURL=sdk-exports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,EACN,uBAAuB,EACvB,cAAc;AACd,kCAAkC;AAClC,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC","sourcesContent":["export { getPowerShellConfig } from \"../utils/shell.ts\";\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tAgentSettledEvent,\n\tBeforeProviderHeadersEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tInlineExtension,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tPowerShellToolCallEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n} from \"./extensions/index.js\";\nexport { isPowerShellToolResult } from \"./extensions/index.js\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tPowerShellOperations,\n\tPowerShellSpawnContext,\n\tPowerShellSpawnHook,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tPowerShellToolOptions,\n\tShellToolPresentation,\n\tStructuredOutputCapture,\n\tStructuredOutputFileCapture,\n\tStructuredOutputToolOptions,\n\tTool,\n} from \"./tools/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateLocalPowerShellOperations,\n\tcreateLsTool,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateSearchTool,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\tcreateWriteTool,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\twithFileMutationQueue,\n} from \"./tools/index.ts\";\n"]}
1
+ {"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,EACN,uBAAuB,EACvB,cAAc;AACd,kCAAkC;AAClC,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC","sourcesContent":["export { getPowerShellConfig } from \"../utils/shell.ts\";\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tAgentSettledEvent,\n\tBeforeProviderHeadersEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tInlineExtension,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tPowerShellToolCallEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n} from \"./extensions/index.js\";\nexport { isPowerShellToolResult } from \"./extensions/index.js\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tPowerShellOperations,\n\tPowerShellSpawnContext,\n\tPowerShellSpawnHook,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tPowerShellToolOptions,\n\tShellToolPresentation,\n\tStructuredOutputCapture,\n\tStructuredOutputFileCapture,\n\tStructuredOutputToolOptions,\n\tTool,\n} from \"./tools/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateKillTool,\n\tcreateLocalPowerShellOperations,\n\tcreateLsTool,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateSearchTool,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\tcreateWriteTool,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\twithFileMutationQueue,\n} from \"./tools/index.ts\";\n"]}
@@ -1,4 +1,6 @@
1
+ import { type Model } from "@bastani/pi-ai";
1
2
  import type { TransportSetting } from "./settings-types.ts";
3
+ type CompactionModel = Pick<Model<string>, "provider" | "id">;
2
4
  interface SettingsManagerBasicAccessors {
3
5
  getLastChangelogVersion(): string | undefined;
4
6
  setLastChangelogVersion(version: string): void;
@@ -36,11 +38,11 @@ interface SettingsManagerBasicAccessors {
36
38
  setTransport(transport: TransportSetting): void;
37
39
  getCompactionEnabled(): boolean;
38
40
  setCompactionEnabled(enabled: boolean): void;
39
- getCompactionReserveTokens(): number;
41
+ getCompactionReserveTokens(model?: CompactionModel): number;
40
42
  getCompactionCompressionRatio(): number;
41
- getCompactionPreserveRecent(): number;
43
+ getCompactionPreserveRecent(model?: CompactionModel): number;
42
44
  getCompactionQuery(): string | undefined;
43
- getCompactionSettings(): {
45
+ getCompactionSettings(model?: CompactionModel): {
44
46
  enabled: boolean;
45
47
  reserveTokens: number;
46
48
  compression_ratio: number;
@@ -1 +1 @@
1
- {"version":3,"file":"settings-manager-basic-accessors.d.ts","sourceRoot":"","sources":["../../src/core/settings-manager-basic-accessors.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,UAAU,6BAA6B;IACtC,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC9C,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,mCAAmC,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1D,mCAAmC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3D,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,aAAa,IAAI,MAAM,GAAG,SAAS,CAAC;IACpC,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAAC;IACzC,eAAe,IAAI,MAAM,GAAG,SAAS,CAAC;IACtC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,0BAA0B,CAAC,QAAQ,EAAE,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AC3E,0BAA0B,IAAI,OAAO,CAAC;IACtC,yBAAyB,IAAI;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,eAAe,IAAI,OAAO,CAAC;IAC3B,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,gBAAgB,IAAI;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3G,YAAY,IAAI,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC9C,oBAAoB,IAAI,MAAM,CAAC;IAC/B,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,4BAA4B,IAAI,MAAM,GAAG,SAAS,CAAC;IACnD,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1C,wBAAwB,IAAI;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;CACjG;AAED,OAAO,QAAQ,4BAA4B,CAAC;IAC3C,UAAU,eAAgB,SAAQ,6BAA6B;KAAG;CAClE"}
@@ -4,6 +4,22 @@ import { normalizePath } from "../utils/paths.js";
4
4
  import { DEFAULT_HTTP_IDLE_TIMEOUT_MS, parseHttpIdleTimeoutMs } from "./http-dispatcher.js";
5
5
  import { SettingsManager } from "./settings-manager-core.js";
6
6
  import { settingsInternals } from "./settings-manager-internals.js";
7
+ function resolveCompactionSetting(compaction, field, model) {
8
+ const ordinary = compaction?.[field];
9
+ if (ordinary !== undefined && (typeof ordinary !== "number" || !Number.isSafeInteger(ordinary) || ordinary < 0)) {
10
+ throw new Error(`Invalid compaction.${field} setting: ${String(ordinary)}. Expected a non-negative safe integer.`);
11
+ }
12
+ const modelKey = model ? `${model.provider}/${model.id}` : undefined;
13
+ const entry = modelKey === undefined ? undefined : compaction?.modelOverrides?.[modelKey];
14
+ if (entry !== undefined && (entry === null || typeof entry !== "object" || Array.isArray(entry))) {
15
+ throw new Error(`Invalid compaction.modelOverrides["${modelKey}"] setting: ${String(entry)}. Expected an object.`);
16
+ }
17
+ const override = entry?.[field];
18
+ if (override !== undefined && (typeof override !== "number" || !Number.isSafeInteger(override) || override < 0)) {
19
+ throw new Error(`Invalid compaction.modelOverrides["${modelKey}"].${field} setting: ${String(override)}. Expected a non-negative safe integer.`);
20
+ }
21
+ return override ?? ordinary ?? (field === "reserveTokens" ? 16384 : 2);
22
+ }
7
23
  const basicAccessors = {
8
24
  getLastChangelogVersion() {
9
25
  return settingsInternals(this).settings.lastChangelogVersion;
@@ -188,28 +204,27 @@ const basicAccessors = {
188
204
  state.markModified("compaction", "enabled");
189
205
  state.save();
190
206
  },
191
- getCompactionReserveTokens() {
192
- return settingsInternals(this).settings.compaction?.reserveTokens ?? 16384;
207
+ getCompactionReserveTokens(model) {
208
+ return resolveCompactionSetting(settingsInternals(this).settings.compaction, "reserveTokens", model);
193
209
  },
194
210
  getCompactionCompressionRatio() {
195
211
  const value = settingsInternals(this).settings.compaction?.compression_ratio;
196
212
  return typeof value === "number" && Number.isFinite(value) && value > 0 && value < 1 ? value : 0.5;
197
213
  },
198
- getCompactionPreserveRecent() {
199
- const value = settingsInternals(this).settings.compaction?.preserve_recent;
200
- return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 2;
214
+ getCompactionPreserveRecent(model) {
215
+ return resolveCompactionSetting(settingsInternals(this).settings.compaction, "preserve_recent", model);
201
216
  },
202
217
  getCompactionQuery() {
203
218
  const query = settingsInternals(this).settings.compaction?.query?.trim();
204
219
  return query && query.length > 0 ? query : undefined;
205
220
  },
206
- getCompactionSettings() {
221
+ getCompactionSettings(model) {
207
222
  const query = this.getCompactionQuery();
208
223
  return {
209
224
  enabled: this.getCompactionEnabled(),
210
- reserveTokens: this.getCompactionReserveTokens(),
225
+ reserveTokens: this.getCompactionReserveTokens(model),
211
226
  compression_ratio: this.getCompactionCompressionRatio(),
212
- preserve_recent: this.getCompactionPreserveRecent(),
227
+ preserve_recent: this.getCompactionPreserveRecent(model),
213
228
  ...(query === undefined ? {} : { query }),
214
229
  };
215
230
  },