@ai-agent-forge/agent-forge 0.88.1 → 0.88.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/bundled-plugins/agent-loop-policy/agent-forge.json +1 -1
  3. package/bundled-plugins/agent-loop-policy/plugin.json +1 -1
  4. package/bundled-plugins/coding-tools/agent-forge.json +1 -1
  5. package/bundled-plugins/coding-tools/plugin.json +1 -1
  6. package/bundled-plugins/compaction-policy/agent-forge.json +1 -1
  7. package/bundled-plugins/compaction-policy/plugin.json +1 -1
  8. package/bundled-plugins/overflow-policy/agent-forge.json +1 -1
  9. package/bundled-plugins/overflow-policy/plugin.json +1 -1
  10. package/bundled-plugins/provider-failover/agent-forge.json +1 -1
  11. package/bundled-plugins/provider-failover/plugin.json +1 -1
  12. package/bundled-plugins/retry-policy/agent-forge.json +1 -1
  13. package/bundled-plugins/retry-policy/plugin.json +1 -1
  14. package/dist/bundle/.build-manifest.json +68 -58
  15. package/dist/bundle/chunks/{chunk-D3ARGZFR.js → chunk-44I47ACN.js} +3 -3
  16. package/dist/bundle/chunks/{chunk-Z72JWUZ4.js → chunk-6F5JWGKE.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-LZOEQITZ.js → chunk-HTC5K5SM.js} +56 -45
  18. package/dist/bundle/chunks/{chunk-AQLNTW2B.js → chunk-LSP24WNH.js} +8 -7
  19. package/dist/bundle/chunks/image-resize-worker.js +3 -3
  20. package/dist/bundle/chunks/{virtual-modules-WF6WRHP7.js → virtual-modules-MRXD3RWG.js} +1 -1
  21. package/dist/bundle/cli.js +1 -1
  22. package/dist/bundle/client.js +1 -1
  23. package/dist/bundle/index.js +1 -1
  24. package/dist/bundle/rpc-entry.js +1 -1
  25. package/dist/cli/plugin-command.d.ts.map +1 -1
  26. package/dist/cli/plugin-command.js +8 -2
  27. package/dist/cli/plugin-command.js.map +1 -1
  28. package/dist/core/agent-session-internal.d.ts +2 -0
  29. package/dist/core/agent-session-internal.d.ts.map +1 -1
  30. package/dist/core/agent-session-internal.js.map +1 -1
  31. package/dist/core/agent-session-services.d.ts +2 -0
  32. package/dist/core/agent-session-services.d.ts.map +1 -1
  33. package/dist/core/agent-session-services.js +1 -0
  34. package/dist/core/agent-session-services.js.map +1 -1
  35. package/dist/core/agent-session-store.d.ts.map +1 -1
  36. package/dist/core/agent-session-store.js +6 -1
  37. package/dist/core/agent-session-store.js.map +1 -1
  38. package/dist/core/agent-session-tools.d.ts.map +1 -1
  39. package/dist/core/agent-session-tools.js +13 -0
  40. package/dist/core/agent-session-tools.js.map +1 -1
  41. package/dist/core/agent-session.d.ts +24 -0
  42. package/dist/core/agent-session.d.ts.map +1 -1
  43. package/dist/core/agent-session.js +58 -4
  44. package/dist/core/agent-session.js.map +1 -1
  45. package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -1
  46. package/dist/core/i18n/locales/zh-cn/cli.js +2 -0
  47. package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
  48. package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -1
  49. package/dist/core/i18n/locales/zh-cn/index.js +2 -0
  50. package/dist/core/i18n/locales/zh-cn/index.js.map +1 -1
  51. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
  52. package/dist/core/i18n/locales/zh-cn/interactive-mode.js +5 -0
  53. package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
  54. package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts +7 -0
  55. package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts.map +1 -0
  56. package/dist/core/i18n/locales/zh-cn/session-cleanup.js +15 -0
  57. package/dist/core/i18n/locales/zh-cn/session-cleanup.js.map +1 -0
  58. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -1
  59. package/dist/core/i18n/locales/zh-cn/slash-commands.js +1 -0
  60. package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -1
  61. package/dist/core/sdk.d.ts.map +1 -1
  62. package/dist/core/sdk.js +24 -1
  63. package/dist/core/sdk.js.map +1 -1
  64. package/dist/core/session-cleanup.d.ts +49 -0
  65. package/dist/core/session-cleanup.d.ts.map +1 -0
  66. package/dist/core/session-cleanup.js +159 -0
  67. package/dist/core/session-cleanup.js.map +1 -0
  68. package/dist/core/session-index.d.ts +75 -0
  69. package/dist/core/session-index.d.ts.map +1 -0
  70. package/dist/core/session-index.js +455 -0
  71. package/dist/core/session-index.js.map +1 -0
  72. package/dist/core/session-manager.d.ts +9 -0
  73. package/dist/core/session-manager.d.ts.map +1 -1
  74. package/dist/core/session-manager.js +202 -47
  75. package/dist/core/session-manager.js.map +1 -1
  76. package/dist/core/slash-commands.d.ts.map +1 -1
  77. package/dist/core/slash-commands.js +5 -0
  78. package/dist/core/slash-commands.js.map +1 -1
  79. package/dist/core/system-prompt.d.ts.map +1 -1
  80. package/dist/core/system-prompt.js +12 -1
  81. package/dist/core/system-prompt.js.map +1 -1
  82. package/dist/core/tools/capability-mount.d.ts +40 -0
  83. package/dist/core/tools/capability-mount.d.ts.map +1 -0
  84. package/dist/core/tools/capability-mount.js +112 -0
  85. package/dist/core/tools/capability-mount.js.map +1 -0
  86. package/dist/main.d.ts.map +1 -1
  87. package/dist/main.js +1 -0
  88. package/dist/main.js.map +1 -1
  89. package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
  90. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/assistant-message.js +27 -5
  92. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  93. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  94. package/dist/modes/interactive/components/session-selector-search.js +5 -1
  95. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  96. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  97. package/dist/modes/interactive/components/session-selector.js +9 -0
  98. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  99. package/dist/modes/interactive/components/tool-execution.d.ts +17 -0
  100. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  101. package/dist/modes/interactive/components/tool-execution.js +43 -0
  102. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  103. package/dist/modes/interactive/components/tool-run-group.d.ts +44 -0
  104. package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -0
  105. package/dist/modes/interactive/components/tool-run-group.js +121 -0
  106. package/dist/modes/interactive/components/tool-run-group.js.map +1 -0
  107. package/dist/modes/interactive/interactive-commands.d.ts +2 -0
  108. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  109. package/dist/modes/interactive/interactive-commands.js +7 -0
  110. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  111. package/dist/modes/interactive/interactive-mode.d.ts +18 -0
  112. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  113. package/dist/modes/interactive/interactive-mode.js +85 -3
  114. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  115. package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
  116. package/dist/plugins/ecosystem/cli.js +6 -3
  117. package/dist/plugins/ecosystem/cli.js.map +1 -1
  118. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +7 -1
  119. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
  120. package/dist/plugins/ecosystem/node-plugin-bootstrap.js +50 -3
  121. package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
  122. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +28 -16
  123. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
  124. package/dist/plugins/ecosystem/plugin-bootstrap.js +35 -33
  125. package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
  126. package/dist/profile/plugin-profiles.d.ts +1 -1
  127. package/dist/profile/plugin-profiles.d.ts.map +1 -1
  128. package/dist/profile/plugin-profiles.js +18 -0
  129. package/dist/profile/plugin-profiles.js.map +1 -1
  130. package/dist/profiles/builtin-suites.d.ts +14 -4
  131. package/dist/profiles/builtin-suites.d.ts.map +1 -1
  132. package/dist/profiles/builtin-suites.js +20 -5
  133. package/dist/profiles/builtin-suites.js.map +1 -1
  134. package/docs/settings.md +354 -354
  135. package/docs/usage.md +292 -292
  136. package/examples/extensions/with-deps/package-lock.json +2 -2
  137. package/examples/extensions/with-deps/package.json +1 -1
  138. package/examples/extensions/with-deps/plugin.json +1 -1
  139. package/package.json +1 -1
  140. package/examples/extensions/mcp-stdio/index.d.ts +0 -64
  141. package/examples/extensions/mcp-stdio/index.d.ts.map +0 -1
  142. package/examples/extensions/mcp-stdio/index.js +0 -292
  143. package/examples/extensions/mcp-stdio/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-command.d.ts","sourceRoot":"","sources":["../../src/cli/plugin-command.ts"],"names":[],"mappings":"AAQA,OAAO,EAKN,KAAK,oBAAoB,EACzB,KAAK,+BAA+B,EAIpC,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAEvB,MAAM,+BAA+B,CAAC;AAOvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAGhF,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE;QACf,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,SAAS;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACjF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B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RAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"../plugins/ecosystem/bootstrap-factory-manifest.ts\";\nimport { defaultPluginHostFactsV1, projectPluginScopeRefV1 } from \"../plugins/ecosystem/default-active-bindings.ts\";\nimport {\n\tcreateDefaultPluginMarketWiringV1,\n\ttype DefaultPluginMarketWiringV1,\n} from \"../plugins/ecosystem/default-plugin-market.ts\";\nimport {\n\tcreatePluginEcosystemCliV1,\n\tcreatePluginSelectionStoreV1,\n\tcreatePluginStateStoreV1,\n\tPLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\ttype PluginDistributionV1,\n\ttype PluginEcosystemCliAcquisitionV1,\n\ttype PluginEcosystemCliParsedCommandV1,\n\ttype PluginEcosystemCliResponseV1,\n\ttype PluginEcosystemCliV1,\n\ttype PluginEcosystemRegistryV1,\n\ttype PluginInstallerV1,\n\ttype PluginSelectionStoreV1,\n\ttype PluginStateStoreV1,\n\tparsePluginEcosystemCliCommandV1,\n} from \"../plugins/ecosystem/index.ts\";\nimport { selectNpmPackageVersionV1 } from \"../plugins/ecosystem/node-npm-registry-source.ts\";\nimport {\n\tisBuiltinPluginProfileIdV1,\n\tlistBuiltinPluginManifestsV1,\n\tlistBuiltinPluginProfilesV1,\n} from \"../profile/plugin-profiles.ts\";\nimport type { PluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\nimport { createPluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\n\nexport interface PluginCommandOptionsV1 {\n\treadonly agentDir?: string;\n\t/** Working directory used for the project-local selection store. */\n\treadonly cwd?: string;\n\treadonly host?: {\n\t\treadonly os: string;\n\t\treadonly arch: string;\n\t\treadonly runtime: readonly { readonly name: string; readonly version: string }[];\n\t\treadonly apiVersion: string;\n\t\treadonly hostFeatures: readonly string[];\n\t};\n\t/** Optional host-owned boundaries used by install/update/remove commands. */\n\treadonly registry?: PluginEcosystemRegistryV1;\n\treadonly installer?: PluginInstallerV1;\n\t/** Optional host-owned multi-source package resolution used by install/update. */\n\treadonly acquisition?: PluginEcosystemCliAcquisitionV1;\n\t/** Optional host-owned package download boundary used by install/update. */\n\treadonly distribution?: PluginDistributionV1;\n\t/** Override persistence in tests or an embedding host; defaults remain agentDir files. */\n\treadonly stateStore?: PluginStateStoreV1;\n\t/** Override the project-local persistence boundary in tests or an embedding host. */\n\treadonly projectStateStore?: PluginStateStoreV1;\n\treadonly selectionStore?: PluginSelectionStoreV1;\n\treadonly projectSelectionStore?: PluginSelectionStoreV1;\n\treadonly write?: (line: string) => void;\n}\n\nfunction printResponse(response: PluginEcosystemCliResponseV1, write: (line: string) => void): void {\n\twrite(response.text);\n\tif (response.status !== \"succeeded\") process.exitCode = 1;\n}\n\n/**\n * The parsed `selection set` command, or undefined for every other command\n * and for argv the ecosystem parser rejects (the ecosystem CLI reports those\n * with its own invalid-command diagnostic). Parsing through the shared\n * grammar keeps option positions (`--scope`, `--json`) from displacing the\n * profile token this boundary validates.\n */\nfunction parseSelectionSetCommand(argv: readonly string[]): PluginEcosystemCliParsedCommandV1 | undefined {\n\ttry {\n\t\tconst parsed = parsePluginEcosystemCliCommandV1(argv);\n\t\treturn parsed.command === \"selection-set\" ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ninterface MarketCliOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\treadonly market?: DefaultPluginMarketWiringV1;\n\treadonly overrides?: PluginCommandOptionsV1;\n}\n\nfunction buildMarketCli(options: MarketCliOptionsV1): PluginEcosystemCliV1 {\n\tconst { market, overrides } = options;\n\treturn createPluginEcosystemCliV1({\n\t\thost: overrides?.host ?? defaultPluginHostFactsV1(),\n\t\tmanifests: listBuiltinPluginManifestsV1(),\n\t\tregistry: overrides?.registry ?? market?.cliRegistry,\n\t\t// Multi-source acquisition (`plugin install <ref>`) rides along with the\n\t\t// default market wiring; a fully host-injected stack replaces it wholesale.\n\t\t...(overrides?.acquisition === undefined && market?.acquisition === undefined\n\t\t\t? {}\n\t\t\t: { acquisition: overrides?.acquisition ?? market?.acquisition }),\n\t\tinstaller: overrides?.installer ?? market?.installer,\n\t\t...(overrides?.distribution !== undefined || market?.distribution !== undefined\n\t\t\t? { distribution: overrides?.distribution ?? market!.distribution }\n\t\t\t: {}),\n\t\tstateStore:\n\t\t\toverrides?.stateStore ??\n\t\t\tmarket?.stateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.agentDir, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectStateStore:\n\t\t\toverrides?.projectStateStore ??\n\t\t\tmarket?.projectStateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectScopeRef: projectPluginScopeRefV1(options.cwd),\n\t\tselectionStore:\n\t\t\toverrides?.selectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.agentDir, \".plugin-selection.json\") }),\n\t\tprojectSelectionStore:\n\t\t\toverrides?.projectSelectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, \".plugin-selection.json\") }),\n\t});\n}\n\n/**\n * Default TUI manager controller over the default marketplace wiring. The\n * controller reads the global or project state store per scope; callers must\n * invoke `close` after the config screen closes.\n */\nexport async function createDefaultPluginManagerControllerV1(options: {\n\treadonly agentDir?: string;\n\treadonly cwd?: string;\n\treadonly scope: \"global\" | \"project\";\n}): Promise<{ readonly controller: PluginManagerControllerV1; readonly close: () => Promise<void> }> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market = await createDefaultPluginMarketWiringV1({ agentDir, cwd });\n\tconst cli = buildMarketCli({ agentDir, cwd, market });\n\tconst controller = createPluginManagerControllerV1({\n\t\tregistry: market.registry,\n\t\tstateStore: options.scope === \"project\" ? market.projectStateStore : market.stateStore,\n\t\tcli,\n\t});\n\treturn { controller, close: market.close };\n}\n\n/**\n * Handle the independent ecosystem command namespace before legacy package\n * commands. Install/update/remove default to the disk install store plus an\n * optional configured marketplace origin; host injection of registry and\n * installer still wins entirely.\n */\nexport async function handlePluginEcosystemCommand(\n\targs: readonly string[],\n\toptions: PluginCommandOptionsV1 = {},\n): Promise<boolean> {\n\tif (args[0] !== \"plugin\") return false;\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\t// Batch update convenience (0.85.7 user seat finding: a factory range bump\n\t// left seven plugins outdated and the per-plugin hint meant seven manual\n\t// commands). The ecosystem CLI protocol is unchanged — this outer layer\n\t// composes `state list` + one `update` per active plugin.\n\tif (args[1] === \"update\" && args[2] === \"--all\") {\n\t\tawait runBatchUpdate(args.slice(3), options, write);\n\t\treturn true;\n\t}\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\t// 2026-10-01 dogfood finding: `selection set` accepted any profile id — a\n\t// suite id like \"assistant\" persisted fine while the ordinary run resolves\n\t// only builtin plugin profile ids, so the stored selection could never be\n\t// read back. Unknown ids are rejected here at the CLI command boundary;\n\t// the selection store itself stays host-agnostic.\n\tconst selectionSet = parseSelectionSetCommand(args.slice(1));\n\tif (selectionSet !== undefined && !isBuiltinPluginProfileIdV1(selectionSet.profileId as string)) {\n\t\tconst validProfileIds = listBuiltinPluginProfilesV1()\n\t\t\t.map((profile) => profile.id)\n\t\t\t.join(\", \");\n\t\tconst message = `unknown plugin profile \"${selectionSet.profileId}\"; selection set accepts builtin plugin profile ids only: ${validProfileIds}`;\n\t\tconst base = {\n\t\t\tversion: PLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\t\t\tcommand: \"selection-set\" as const,\n\t\t\tformat: selectionSet.format,\n\t\t\tstatus: \"failed\" as const,\n\t\t\terror: { code: \"invalid_command\" as const, message },\n\t\t};\n\t\tprintResponse(\n\t\t\t{\n\t\t\t\t...base,\n\t\t\t\ttext: selectionSet.format === \"json\" ? JSON.stringify(base) : `failed: ${message}`,\n\t\t\t},\n\t\t\twrite,\n\t\t);\n\t\treturn true;\n\t}\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst response = await cli.execute({ argv: args.slice(1) });\n\t\tprintResponse(response, write);\n\t\t// CRM seat finding F3, corrected by the 2026-10-01 dogfood: installing\n\t\t// a plugin activates nothing, and the old hint pointed at `plugin\n\t\t// selection set` — a store no ordinary run reads, so suite users were\n\t\t// sent down a dead end. The real activation path is the suite's\n\t\t// capabilities list in suite.json.\n\t\tif (response.status === \"succeeded\" && response.command === \"install\") {\n\t\t\tconst pluginId = response.data?.pluginId;\n\t\t\tif (typeof pluginId === \"string\") {\n\t\t\t\twrite(\n\t\t\t\t\t`note: this plugin is installed but not yet active; to activate its tools add \"${pluginId}\" to the capabilities list in <agentDir>/suites/<suite>/suite.json and restart`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n\ninterface BatchUpdateEntry {\n\treadonly pluginId: string;\n\treadonly pluginVersion?: string;\n\treadonly scope: string;\n\treadonly lifecycle: string;\n}\n\nasync function runBatchUpdate(\n\trestArgs: readonly string[],\n\toptions: PluginCommandOptionsV1,\n\twrite: (line: string) => void,\n): Promise<void> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst scopeIndex = restArgs.indexOf(\"--scope\");\n\tconst scope = scopeIndex !== -1 && restArgs[scopeIndex + 1] === \"project\" ? \"project\" : \"global\";\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst listResponse = await cli.execute({ argv: [\"state\", \"list\", \"--scope\", scope] });\n\t\tif (listResponse.status !== \"succeeded\") {\n\t\t\tprintResponse(listResponse, write);\n\t\t\treturn;\n\t\t}\n\t\tconst entries = ((listResponse.data?.entries ?? []) as readonly BatchUpdateEntry[]).filter(\n\t\t\t(entry) => entry.lifecycle === \"active\" && entry.scope === scope,\n\t\t);\n\t\tif (entries.length === 0) {\n\t\t\twrite(\"No active plugins to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst updated: string[] = [];\n\t\tconst current: string[] = [];\n\t\tconst failed: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\t// Factory-listed first-party plugins upgrade through the npm range the\n\t\t\t// bootstrap warnings name (`install <npmName>@^range`): the default disk\n\t\t\t// registry only resolves already-installed versions, so a bare `update`\n\t\t\t// there re-resolves the current version and reports nothing to do.\n\t\t\t// Non-factory plugins keep the bare `update` registry semantics.\n\t\t\tconst factoryEntry = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.find((item) => item.pluginId === entry.pluginId);\n\t\t\t// Offline satisfiability pre-check: when the recorded version already\n\t\t\t// satisfies the factory range, classifying as current must not touch the\n\t\t\t// network — acquisition downloads before its already_installed check, so\n\t\t\t// satisfied entries re-downloaded every run and one network blip failed\n\t\t\t// them. `latest`/absent ranges stay online-only (satisfiability is not\n\t\t\t// decidable offline); the check reuses the npm range selector.\n\t\t\tconst range = factoryEntry?.range;\n\t\t\tif (\n\t\t\t\tfactoryEntry !== undefined &&\n\t\t\t\trange !== undefined &&\n\t\t\t\trange !== \"latest\" &&\n\t\t\t\tentry.pluginVersion !== undefined &&\n\t\t\t\tselectNpmPackageVersionV1([entry.pluginVersion], range) === entry.pluginVersion\n\t\t\t) {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst argv = factoryEntry\n\t\t\t\t? [\"install\", `${factoryEntry.npmName}@${range ?? \"latest\"}`, \"--scope\", scope]\n\t\t\t\t: [\"update\", entry.pluginId, \"--scope\", scope];\n\t\t\tconst response = await cli.execute({ argv });\n\t\t\tif (response.status === \"succeeded\") {\n\t\t\t\tupdated.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t} else if (response.error?.code === \"already_installed\") {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t} else {\n\t\t\t\tfailed.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t}\n\t\t}\n\t\tconst summary = [\n\t\t\t`updated ${updated.length}${updated.length > 0 ? ` (${updated.join(\", \")})` : \"\"}`,\n\t\t\t`already up to date ${current.length}${current.length > 0 ? ` (${current.join(\", \")})` : \"\"}`,\n\t\t\t`failed ${failed.length}${failed.length > 0 ? ` (${failed.join(\", \")})` : \"\"}`,\n\t\t].join(\"; \");\n\t\twrite(`plugin update --all [${scope}]: ${summary}`);\n\t\tif (failed.length > 0) process.exitCode = 1;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n"]}
1
+ {"version":3,"file":"plugin-command.d.ts","sourceRoot":"","sources":["../../src/cli/plugin-command.ts"],"names":[],"mappings":"AAQA,OAAO,EAKN,KAAK,oBAAoB,EACzB,KAAK,+BAA+B,EAIpC,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAEvB,MAAM,+BAA+B,CAAC;AAOvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAGhF,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE;QACf,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,SAAS;YAAE,QAAQ,CAAC,IAAI,EAAE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AA2B,GAClC,OAAO,CAAC,OAAO,CAAC,CAuElB","sourcesContent":["import { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"../plugins/ecosystem/bootstrap-factory-manifest.ts\";\nimport { defaultPluginHostFactsV1, projectPluginScopeRefV1 } from \"../plugins/ecosystem/default-active-bindings.ts\";\nimport {\n\tcreateDefaultPluginMarketWiringV1,\n\ttype DefaultPluginMarketWiringV1,\n} from \"../plugins/ecosystem/default-plugin-market.ts\";\nimport {\n\tcreatePluginEcosystemCliV1,\n\tcreatePluginSelectionStoreV1,\n\tcreatePluginStateStoreV1,\n\tPLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\ttype PluginDistributionV1,\n\ttype PluginEcosystemCliAcquisitionV1,\n\ttype PluginEcosystemCliParsedCommandV1,\n\ttype PluginEcosystemCliResponseV1,\n\ttype PluginEcosystemCliV1,\n\ttype PluginEcosystemRegistryV1,\n\ttype PluginInstallerV1,\n\ttype PluginSelectionStoreV1,\n\ttype PluginStateStoreV1,\n\tparsePluginEcosystemCliCommandV1,\n} from \"../plugins/ecosystem/index.ts\";\nimport { selectNpmPackageVersionV1 } from \"../plugins/ecosystem/node-npm-registry-source.ts\";\nimport {\n\tisBuiltinPluginProfileIdV1,\n\tlistBuiltinPluginManifestsV1,\n\tlistBuiltinPluginProfilesV1,\n} from \"../profile/plugin-profiles.ts\";\nimport type { PluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\nimport { createPluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\n\nexport interface PluginCommandOptionsV1 {\n\treadonly agentDir?: string;\n\t/** Working directory used for the project-local selection store. */\n\treadonly cwd?: string;\n\treadonly host?: {\n\t\treadonly os: string;\n\t\treadonly arch: string;\n\t\treadonly runtime: readonly { readonly name: string; readonly version: string }[];\n\t\treadonly apiVersion: string;\n\t\treadonly hostFeatures: readonly string[];\n\t};\n\t/** Optional host-owned boundaries used by install/update/remove commands. */\n\treadonly registry?: PluginEcosystemRegistryV1;\n\treadonly installer?: PluginInstallerV1;\n\t/** Optional host-owned multi-source package resolution used by install/update. */\n\treadonly acquisition?: PluginEcosystemCliAcquisitionV1;\n\t/** Optional host-owned package download boundary used by install/update. */\n\treadonly distribution?: PluginDistributionV1;\n\t/** Override persistence in tests or an embedding host; defaults remain agentDir files. */\n\treadonly stateStore?: PluginStateStoreV1;\n\t/** Override the project-local persistence boundary in tests or an embedding host. */\n\treadonly projectStateStore?: PluginStateStoreV1;\n\treadonly selectionStore?: PluginSelectionStoreV1;\n\treadonly projectSelectionStore?: PluginSelectionStoreV1;\n\treadonly write?: (line: string) => void;\n}\n\nfunction printResponse(response: PluginEcosystemCliResponseV1, write: (line: string) => void): void {\n\twrite(response.text);\n\tif (response.status !== \"succeeded\") process.exitCode = 1;\n}\n\n/**\n * The parsed `selection set` command, or undefined for every other command\n * and for argv the ecosystem parser rejects (the ecosystem CLI reports those\n * with its own invalid-command diagnostic). Parsing through the shared\n * grammar keeps option positions (`--scope`, `--json`) from displacing the\n * profile token this boundary validates.\n */\nfunction parseSelectionSetCommand(argv: readonly string[]): PluginEcosystemCliParsedCommandV1 | undefined {\n\ttry {\n\t\tconst parsed = parsePluginEcosystemCliCommandV1(argv);\n\t\treturn parsed.command === \"selection-set\" ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ninterface MarketCliOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\treadonly market?: DefaultPluginMarketWiringV1;\n\treadonly overrides?: PluginCommandOptionsV1;\n}\n\nfunction buildMarketCli(options: MarketCliOptionsV1): PluginEcosystemCliV1 {\n\tconst { market, overrides } = options;\n\treturn createPluginEcosystemCliV1({\n\t\thost: overrides?.host ?? defaultPluginHostFactsV1(),\n\t\tmanifests: listBuiltinPluginManifestsV1(),\n\t\tregistry: overrides?.registry ?? market?.cliRegistry,\n\t\t// Multi-source acquisition (`plugin install <ref>`) rides along with the\n\t\t// default market wiring; a fully host-injected stack replaces it wholesale.\n\t\t...(overrides?.acquisition === undefined && market?.acquisition === undefined\n\t\t\t? {}\n\t\t\t: { acquisition: overrides?.acquisition ?? market?.acquisition }),\n\t\tinstaller: overrides?.installer ?? market?.installer,\n\t\t...(overrides?.distribution !== undefined || market?.distribution !== undefined\n\t\t\t? { distribution: overrides?.distribution ?? market!.distribution }\n\t\t\t: {}),\n\t\tstateStore:\n\t\t\toverrides?.stateStore ??\n\t\t\tmarket?.stateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.agentDir, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectStateStore:\n\t\t\toverrides?.projectStateStore ??\n\t\t\tmarket?.projectStateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectScopeRef: projectPluginScopeRefV1(options.cwd),\n\t\tselectionStore:\n\t\t\toverrides?.selectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.agentDir, \".plugin-selection.json\") }),\n\t\tprojectSelectionStore:\n\t\t\toverrides?.projectSelectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, \".plugin-selection.json\") }),\n\t});\n}\n\n/**\n * Default TUI manager controller over the default marketplace wiring. The\n * controller reads the global or project state store per scope; callers must\n * invoke `close` after the config screen closes.\n */\nexport async function createDefaultPluginManagerControllerV1(options: {\n\treadonly agentDir?: string;\n\treadonly cwd?: string;\n\treadonly scope: \"global\" | \"project\";\n}): Promise<{ readonly controller: PluginManagerControllerV1; readonly close: () => Promise<void> }> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market = await createDefaultPluginMarketWiringV1({ agentDir, cwd });\n\tconst cli = buildMarketCli({ agentDir, cwd, market });\n\tconst controller = createPluginManagerControllerV1({\n\t\tregistry: market.registry,\n\t\tstateStore: options.scope === \"project\" ? market.projectStateStore : market.stateStore,\n\t\tcli,\n\t});\n\treturn { controller, close: market.close };\n}\n\n/**\n * Handle the independent ecosystem command namespace before legacy package\n * commands. Install/update/remove default to the disk install store plus an\n * optional configured marketplace origin; host injection of registry and\n * installer still wins entirely.\n */\nexport async function handlePluginEcosystemCommand(\n\targs: readonly string[],\n\toptions: PluginCommandOptionsV1 = {},\n): Promise<boolean> {\n\tif (args[0] !== \"plugin\") return false;\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\t// Batch update convenience (0.85.7 user seat finding: a factory range bump\n\t// left seven plugins outdated and the per-plugin hint meant seven manual\n\t// commands). The ecosystem CLI protocol is unchanged — this outer layer\n\t// composes `state list` + one `update` per active plugin.\n\tif (args[1] === \"update\" && args[2] === \"--all\") {\n\t\tawait runBatchUpdate(args.slice(3), options, write);\n\t\treturn true;\n\t}\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\t// 2026-10-01 dogfood finding: `selection set` accepted any profile id — a\n\t// suite id like \"assistant\" persisted fine while the ordinary run resolves\n\t// only builtin plugin profile ids, so the stored selection could never be\n\t// read back. Unknown ids are rejected here at the CLI command boundary;\n\t// the selection store itself stays host-agnostic.\n\tconst selectionSet = parseSelectionSetCommand(args.slice(1));\n\tif (selectionSet !== undefined && !isBuiltinPluginProfileIdV1(selectionSet.profileId as string)) {\n\t\tconst validProfileIds = listBuiltinPluginProfilesV1()\n\t\t\t.map((profile) => profile.id)\n\t\t\t.join(\", \");\n\t\tconst message = `unknown plugin profile \"${selectionSet.profileId}\"; selection set accepts builtin plugin profile ids only: ${validProfileIds}`;\n\t\tconst base = {\n\t\t\tversion: PLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\t\t\tcommand: \"selection-set\" as const,\n\t\t\tformat: selectionSet.format,\n\t\t\tstatus: \"failed\" as const,\n\t\t\terror: { code: \"invalid_command\" as const, message },\n\t\t};\n\t\tprintResponse(\n\t\t\t{\n\t\t\t\t...base,\n\t\t\t\ttext: selectionSet.format === \"json\" ? JSON.stringify(base) : `failed: ${message}`,\n\t\t\t},\n\t\t\twrite,\n\t\t);\n\t\treturn true;\n\t}\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst response = await cli.execute({ argv: args.slice(1) });\n\t\tprintResponse(response, write);\n\t\t// CRM seat finding F3, corrected by the 2026-10-01 dogfood: installing\n\t\t// a plugin activates nothing, and the old hint pointed at `plugin\n\t\t// selection set` — a store no ordinary run reads, so suite users were\n\t\t// sent down a dead end. The real activation path is the suite's\n\t\t// capabilities list in suite.json. 2026-10-04 install-and-use finding:\n\t\t// factory plugins resolve through the suite's builtin.* capability\n\t\t// aliases that default suites already declare, so the suite.json hint\n\t\t// was wrong for them — a restart is all they need.\n\t\tif (response.status === \"succeeded\" && response.command === \"install\") {\n\t\t\tconst pluginId = response.data?.pluginId;\n\t\t\tif (typeof pluginId === \"string\") {\n\t\t\t\tconst factory = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.some((entry) => entry.pluginId === pluginId);\n\t\t\t\twrite(\n\t\t\t\t\tfactory\n\t\t\t\t\t\t? `note: ${pluginId} installed — restart agent-forge to load it`\n\t\t\t\t\t\t: `note: this plugin is installed but not yet active; to activate its tools add \"${pluginId}\" to the capabilities list in <agentDir>/suites/<suite>/suite.json and restart`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n\ninterface BatchUpdateEntry {\n\treadonly pluginId: string;\n\treadonly pluginVersion?: string;\n\treadonly scope: string;\n\treadonly lifecycle: string;\n}\n\nasync function runBatchUpdate(\n\trestArgs: readonly string[],\n\toptions: PluginCommandOptionsV1,\n\twrite: (line: string) => void,\n): Promise<void> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst scopeIndex = restArgs.indexOf(\"--scope\");\n\tconst scope = scopeIndex !== -1 && restArgs[scopeIndex + 1] === \"project\" ? \"project\" : \"global\";\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst listResponse = await cli.execute({ argv: [\"state\", \"list\", \"--scope\", scope] });\n\t\tif (listResponse.status !== \"succeeded\") {\n\t\t\tprintResponse(listResponse, write);\n\t\t\treturn;\n\t\t}\n\t\tconst entries = ((listResponse.data?.entries ?? []) as readonly BatchUpdateEntry[]).filter(\n\t\t\t(entry) => entry.lifecycle === \"active\" && entry.scope === scope,\n\t\t);\n\t\tif (entries.length === 0) {\n\t\t\twrite(\"No active plugins to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst updated: string[] = [];\n\t\tconst current: string[] = [];\n\t\tconst failed: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\t// Factory-listed first-party plugins upgrade through the npm range the\n\t\t\t// bootstrap warnings name (`install <npmName>@^range`): the default disk\n\t\t\t// registry only resolves already-installed versions, so a bare `update`\n\t\t\t// there re-resolves the current version and reports nothing to do.\n\t\t\t// Non-factory plugins keep the bare `update` registry semantics.\n\t\t\tconst factoryEntry = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.find((item) => item.pluginId === entry.pluginId);\n\t\t\t// Offline satisfiability pre-check: when the recorded version already\n\t\t\t// satisfies the factory range, classifying as current must not touch the\n\t\t\t// network — acquisition downloads before its already_installed check, so\n\t\t\t// satisfied entries re-downloaded every run and one network blip failed\n\t\t\t// them. `latest`/absent ranges stay online-only (satisfiability is not\n\t\t\t// decidable offline); the check reuses the npm range selector.\n\t\t\tconst range = factoryEntry?.range;\n\t\t\tif (\n\t\t\t\tfactoryEntry !== undefined &&\n\t\t\t\trange !== undefined &&\n\t\t\t\trange !== \"latest\" &&\n\t\t\t\tentry.pluginVersion !== undefined &&\n\t\t\t\tselectNpmPackageVersionV1([entry.pluginVersion], range) === entry.pluginVersion\n\t\t\t) {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst argv = factoryEntry\n\t\t\t\t? [\"install\", `${factoryEntry.npmName}@${range ?? \"latest\"}`, \"--scope\", scope]\n\t\t\t\t: [\"update\", entry.pluginId, \"--scope\", scope];\n\t\t\tconst response = await cli.execute({ argv });\n\t\t\tif (response.status === \"succeeded\") {\n\t\t\t\tupdated.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t} else if (response.error?.code === \"already_installed\") {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t} else {\n\t\t\t\tfailed.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t}\n\t\t}\n\t\tconst summary = [\n\t\t\t`updated ${updated.length}${updated.length > 0 ? ` (${updated.join(\", \")})` : \"\"}`,\n\t\t\t`already up to date ${current.length}${current.length > 0 ? ` (${current.join(\", \")})` : \"\"}`,\n\t\t\t`failed ${failed.length}${failed.length > 0 ? ` (${failed.join(\", \")})` : \"\"}`,\n\t\t].join(\"; \");\n\t\twrite(`plugin update --all [${scope}]: ${summary}`);\n\t\tif (failed.length > 0) process.exitCode = 1;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n"]}
@@ -132,11 +132,17 @@ export async function handlePluginEcosystemCommand(args, options = {}) {
132
132
  // a plugin activates nothing, and the old hint pointed at `plugin
133
133
  // selection set` — a store no ordinary run reads, so suite users were
134
134
  // sent down a dead end. The real activation path is the suite's
135
- // capabilities list in suite.json.
135
+ // capabilities list in suite.json. 2026-10-04 install-and-use finding:
136
+ // factory plugins resolve through the suite's builtin.* capability
137
+ // aliases that default suites already declare, so the suite.json hint
138
+ // was wrong for them — a restart is all they need.
136
139
  if (response.status === "succeeded" && response.command === "install") {
137
140
  const pluginId = response.data?.pluginId;
138
141
  if (typeof pluginId === "string") {
139
- write(`note: this plugin is installed but not yet active; to activate its tools add "${pluginId}" to the capabilities list in <agentDir>/suites/<suite>/suite.json and restart`);
142
+ const factory = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.some((entry) => entry.pluginId === pluginId);
143
+ write(factory
144
+ ? `note: ${pluginId} installed — restart agent-forge to load it`
145
+ : `note: this plugin is installed but not yet active; to activate its tools add "${pluginId}" to the capabilities list in <agentDir>/suites/<suite>/suite.json and restart`);
140
146
  }
141
147
  }
142
148
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-command.js","sourceRoot":"","sources":["../../src/cli/plugin-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,oCAAoC,EAAE,MAAM,oDAAoD,CAAC;AAC1G,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AACpH,OAAO,EACN,iCAAiC,GAEjC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,wBAAwB,EACxB,+BAA+B,EAU/B,gCAAgC,GAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EACN,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC3B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AA6BjF,SAAS,aAAa,CAAC,QAAsC,EAAE,KAA6B,EAAQ;IACnG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrB,IAAI,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AAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;SAC9E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,KAAK,CAAC,wBAAwB,KAAK,MAAM,OAAO,EAAE,CAAC,CAAC;QACpD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC7C,CAAC;YAAS,CAAC;QACV,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC;IACvB,CAAC;AAAA,CACD","sourcesContent":["import { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"../plugins/ecosystem/bootstrap-factory-manifest.ts\";\nimport { defaultPluginHostFactsV1, projectPluginScopeRefV1 } from \"../plugins/ecosystem/default-active-bindings.ts\";\nimport {\n\tcreateDefaultPluginMarketWiringV1,\n\ttype DefaultPluginMarketWiringV1,\n} from \"../plugins/ecosystem/default-plugin-market.ts\";\nimport {\n\tcreatePluginEcosystemCliV1,\n\tcreatePluginSelectionStoreV1,\n\tcreatePluginStateStoreV1,\n\tPLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\ttype PluginDistributionV1,\n\ttype PluginEcosystemCliAcquisitionV1,\n\ttype PluginEcosystemCliParsedCommandV1,\n\ttype PluginEcosystemCliResponseV1,\n\ttype PluginEcosystemCliV1,\n\ttype PluginEcosystemRegistryV1,\n\ttype PluginInstallerV1,\n\ttype PluginSelectionStoreV1,\n\ttype PluginStateStoreV1,\n\tparsePluginEcosystemCliCommandV1,\n} from \"../plugins/ecosystem/index.ts\";\nimport { selectNpmPackageVersionV1 } from \"../plugins/ecosystem/node-npm-registry-source.ts\";\nimport {\n\tisBuiltinPluginProfileIdV1,\n\tlistBuiltinPluginManifestsV1,\n\tlistBuiltinPluginProfilesV1,\n} from \"../profile/plugin-profiles.ts\";\nimport type { PluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\nimport { createPluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\n\nexport interface PluginCommandOptionsV1 {\n\treadonly agentDir?: string;\n\t/** Working directory used for the project-local selection store. */\n\treadonly cwd?: string;\n\treadonly host?: {\n\t\treadonly os: string;\n\t\treadonly arch: string;\n\t\treadonly runtime: readonly { readonly name: string; readonly version: string }[];\n\t\treadonly apiVersion: string;\n\t\treadonly hostFeatures: readonly string[];\n\t};\n\t/** Optional host-owned boundaries used by install/update/remove commands. */\n\treadonly registry?: PluginEcosystemRegistryV1;\n\treadonly installer?: PluginInstallerV1;\n\t/** Optional host-owned multi-source package resolution used by install/update. */\n\treadonly acquisition?: PluginEcosystemCliAcquisitionV1;\n\t/** Optional host-owned package download boundary used by install/update. */\n\treadonly distribution?: PluginDistributionV1;\n\t/** Override persistence in tests or an embedding host; defaults remain agentDir files. */\n\treadonly stateStore?: PluginStateStoreV1;\n\t/** Override the project-local persistence boundary in tests or an embedding host. */\n\treadonly projectStateStore?: PluginStateStoreV1;\n\treadonly selectionStore?: PluginSelectionStoreV1;\n\treadonly projectSelectionStore?: PluginSelectionStoreV1;\n\treadonly write?: (line: string) => void;\n}\n\nfunction printResponse(response: PluginEcosystemCliResponseV1, write: (line: string) => void): void {\n\twrite(response.text);\n\tif (response.status !== \"succeeded\") process.exitCode = 1;\n}\n\n/**\n * The parsed `selection set` command, or undefined for every other command\n * and for argv the ecosystem parser rejects (the ecosystem CLI reports those\n * with its own invalid-command diagnostic). Parsing through the shared\n * grammar keeps option positions (`--scope`, `--json`) from displacing the\n * profile token this boundary validates.\n */\nfunction parseSelectionSetCommand(argv: readonly string[]): PluginEcosystemCliParsedCommandV1 | undefined {\n\ttry {\n\t\tconst parsed = parsePluginEcosystemCliCommandV1(argv);\n\t\treturn parsed.command === \"selection-set\" ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ninterface MarketCliOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\treadonly market?: DefaultPluginMarketWiringV1;\n\treadonly overrides?: PluginCommandOptionsV1;\n}\n\nfunction buildMarketCli(options: MarketCliOptionsV1): PluginEcosystemCliV1 {\n\tconst { market, overrides } = options;\n\treturn createPluginEcosystemCliV1({\n\t\thost: overrides?.host ?? defaultPluginHostFactsV1(),\n\t\tmanifests: listBuiltinPluginManifestsV1(),\n\t\tregistry: overrides?.registry ?? market?.cliRegistry,\n\t\t// Multi-source acquisition (`plugin install <ref>`) rides along with the\n\t\t// default market wiring; a fully host-injected stack replaces it wholesale.\n\t\t...(overrides?.acquisition === undefined && market?.acquisition === undefined\n\t\t\t? {}\n\t\t\t: { acquisition: overrides?.acquisition ?? market?.acquisition }),\n\t\tinstaller: overrides?.installer ?? market?.installer,\n\t\t...(overrides?.distribution !== undefined || market?.distribution !== undefined\n\t\t\t? { distribution: overrides?.distribution ?? market!.distribution }\n\t\t\t: {}),\n\t\tstateStore:\n\t\t\toverrides?.stateStore ??\n\t\t\tmarket?.stateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.agentDir, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectStateStore:\n\t\t\toverrides?.projectStateStore ??\n\t\t\tmarket?.projectStateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectScopeRef: projectPluginScopeRefV1(options.cwd),\n\t\tselectionStore:\n\t\t\toverrides?.selectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.agentDir, \".plugin-selection.json\") }),\n\t\tprojectSelectionStore:\n\t\t\toverrides?.projectSelectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, \".plugin-selection.json\") }),\n\t});\n}\n\n/**\n * Default TUI manager controller over the default marketplace wiring. The\n * controller reads the global or project state store per scope; callers must\n * invoke `close` after the config screen closes.\n */\nexport async function createDefaultPluginManagerControllerV1(options: {\n\treadonly agentDir?: string;\n\treadonly cwd?: string;\n\treadonly scope: \"global\" | \"project\";\n}): Promise<{ readonly controller: PluginManagerControllerV1; readonly close: () => Promise<void> }> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market = await createDefaultPluginMarketWiringV1({ agentDir, cwd });\n\tconst cli = buildMarketCli({ agentDir, cwd, market });\n\tconst controller = createPluginManagerControllerV1({\n\t\tregistry: market.registry,\n\t\tstateStore: options.scope === \"project\" ? market.projectStateStore : market.stateStore,\n\t\tcli,\n\t});\n\treturn { controller, close: market.close };\n}\n\n/**\n * Handle the independent ecosystem command namespace before legacy package\n * commands. Install/update/remove default to the disk install store plus an\n * optional configured marketplace origin; host injection of registry and\n * installer still wins entirely.\n */\nexport async function handlePluginEcosystemCommand(\n\targs: readonly string[],\n\toptions: PluginCommandOptionsV1 = {},\n): Promise<boolean> {\n\tif (args[0] !== \"plugin\") return false;\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\t// Batch update convenience (0.85.7 user seat finding: a factory range bump\n\t// left seven plugins outdated and the per-plugin hint meant seven manual\n\t// commands). The ecosystem CLI protocol is unchanged — this outer layer\n\t// composes `state list` + one `update` per active plugin.\n\tif (args[1] === \"update\" && args[2] === \"--all\") {\n\t\tawait runBatchUpdate(args.slice(3), options, write);\n\t\treturn true;\n\t}\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\t// 2026-10-01 dogfood finding: `selection set` accepted any profile id — a\n\t// suite id like \"assistant\" persisted fine while the ordinary run resolves\n\t// only builtin plugin profile ids, so the stored selection could never be\n\t// read back. Unknown ids are rejected here at the CLI command boundary;\n\t// the selection store itself stays host-agnostic.\n\tconst selectionSet = parseSelectionSetCommand(args.slice(1));\n\tif (selectionSet !== undefined && !isBuiltinPluginProfileIdV1(selectionSet.profileId as string)) {\n\t\tconst validProfileIds = listBuiltinPluginProfilesV1()\n\t\t\t.map((profile) => profile.id)\n\t\t\t.join(\", \");\n\t\tconst message = `unknown plugin profile \"${selectionSet.profileId}\"; selection set accepts builtin plugin profile ids only: ${validProfileIds}`;\n\t\tconst base = {\n\t\t\tversion: PLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\t\t\tcommand: \"selection-set\" as const,\n\t\t\tformat: selectionSet.format,\n\t\t\tstatus: \"failed\" as const,\n\t\t\terror: { code: \"invalid_command\" as const, message },\n\t\t};\n\t\tprintResponse(\n\t\t\t{\n\t\t\t\t...base,\n\t\t\t\ttext: selectionSet.format === \"json\" ? JSON.stringify(base) : `failed: ${message}`,\n\t\t\t},\n\t\t\twrite,\n\t\t);\n\t\treturn true;\n\t}\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst response = await cli.execute({ argv: args.slice(1) });\n\t\tprintResponse(response, write);\n\t\t// CRM seat finding F3, corrected by the 2026-10-01 dogfood: installing\n\t\t// a plugin activates nothing, and the old hint pointed at `plugin\n\t\t// selection set` — a store no ordinary run reads, so suite users were\n\t\t// sent down a dead end. The real activation path is the suite's\n\t\t// capabilities list in suite.json.\n\t\tif (response.status === \"succeeded\" && response.command === \"install\") {\n\t\t\tconst pluginId = response.data?.pluginId;\n\t\t\tif (typeof pluginId === \"string\") {\n\t\t\t\twrite(\n\t\t\t\t\t`note: this plugin is installed but not yet active; to activate its tools add \"${pluginId}\" to the capabilities list in <agentDir>/suites/<suite>/suite.json and restart`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n\ninterface BatchUpdateEntry {\n\treadonly pluginId: string;\n\treadonly pluginVersion?: string;\n\treadonly scope: string;\n\treadonly lifecycle: string;\n}\n\nasync function runBatchUpdate(\n\trestArgs: readonly string[],\n\toptions: PluginCommandOptionsV1,\n\twrite: (line: string) => void,\n): Promise<void> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst scopeIndex = restArgs.indexOf(\"--scope\");\n\tconst scope = scopeIndex !== -1 && restArgs[scopeIndex + 1] === \"project\" ? \"project\" : \"global\";\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst listResponse = await cli.execute({ argv: [\"state\", \"list\", \"--scope\", scope] });\n\t\tif (listResponse.status !== \"succeeded\") {\n\t\t\tprintResponse(listResponse, write);\n\t\t\treturn;\n\t\t}\n\t\tconst entries = ((listResponse.data?.entries ?? []) as readonly BatchUpdateEntry[]).filter(\n\t\t\t(entry) => entry.lifecycle === \"active\" && entry.scope === scope,\n\t\t);\n\t\tif (entries.length === 0) {\n\t\t\twrite(\"No active plugins to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst updated: string[] = [];\n\t\tconst current: string[] = [];\n\t\tconst failed: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\t// Factory-listed first-party plugins upgrade through the npm range the\n\t\t\t// bootstrap warnings name (`install <npmName>@^range`): the default disk\n\t\t\t// registry only resolves already-installed versions, so a bare `update`\n\t\t\t// there re-resolves the current version and reports nothing to do.\n\t\t\t// Non-factory plugins keep the bare `update` registry semantics.\n\t\t\tconst factoryEntry = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.find((item) => item.pluginId === entry.pluginId);\n\t\t\t// Offline satisfiability pre-check: when the recorded version already\n\t\t\t// satisfies the factory range, classifying as current must not touch the\n\t\t\t// network — acquisition downloads before its already_installed check, so\n\t\t\t// satisfied entries re-downloaded every run and one network blip failed\n\t\t\t// them. `latest`/absent ranges stay online-only (satisfiability is not\n\t\t\t// decidable offline); the check reuses the npm range selector.\n\t\t\tconst range = factoryEntry?.range;\n\t\t\tif (\n\t\t\t\tfactoryEntry !== undefined &&\n\t\t\t\trange !== undefined &&\n\t\t\t\trange !== \"latest\" &&\n\t\t\t\tentry.pluginVersion !== undefined &&\n\t\t\t\tselectNpmPackageVersionV1([entry.pluginVersion], range) === entry.pluginVersion\n\t\t\t) {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst argv = factoryEntry\n\t\t\t\t? [\"install\", `${factoryEntry.npmName}@${range ?? \"latest\"}`, \"--scope\", scope]\n\t\t\t\t: [\"update\", entry.pluginId, \"--scope\", scope];\n\t\t\tconst response = await cli.execute({ argv });\n\t\t\tif (response.status === \"succeeded\") {\n\t\t\t\tupdated.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t} else if (response.error?.code === \"already_installed\") {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t} else {\n\t\t\t\tfailed.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t}\n\t\t}\n\t\tconst summary = [\n\t\t\t`updated ${updated.length}${updated.length > 0 ? ` (${updated.join(\", \")})` : \"\"}`,\n\t\t\t`already up to date ${current.length}${current.length > 0 ? ` (${current.join(\", \")})` : \"\"}`,\n\t\t\t`failed ${failed.length}${failed.length > 0 ? ` (${failed.join(\", \")})` : \"\"}`,\n\t\t].join(\"; \");\n\t\twrite(`plugin update --all [${scope}]: ${summary}`);\n\t\tif (failed.length > 0) process.exitCode = 1;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n"]}
1
+ {"version":3,"file":"plugin-command.js","sourceRoot":"","sources":["../../src/cli/plugin-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,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EAAE,CAAC;IACvB,CAAC;AAAA,CACD","sourcesContent":["import { join } from \"node:path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1 } from \"../plugins/ecosystem/bootstrap-factory-manifest.ts\";\nimport { defaultPluginHostFactsV1, projectPluginScopeRefV1 } from \"../plugins/ecosystem/default-active-bindings.ts\";\nimport {\n\tcreateDefaultPluginMarketWiringV1,\n\ttype DefaultPluginMarketWiringV1,\n} from \"../plugins/ecosystem/default-plugin-market.ts\";\nimport {\n\tcreatePluginEcosystemCliV1,\n\tcreatePluginSelectionStoreV1,\n\tcreatePluginStateStoreV1,\n\tPLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\ttype PluginDistributionV1,\n\ttype PluginEcosystemCliAcquisitionV1,\n\ttype PluginEcosystemCliParsedCommandV1,\n\ttype PluginEcosystemCliResponseV1,\n\ttype PluginEcosystemCliV1,\n\ttype PluginEcosystemRegistryV1,\n\ttype PluginInstallerV1,\n\ttype PluginSelectionStoreV1,\n\ttype PluginStateStoreV1,\n\tparsePluginEcosystemCliCommandV1,\n} from \"../plugins/ecosystem/index.ts\";\nimport { selectNpmPackageVersionV1 } from \"../plugins/ecosystem/node-npm-registry-source.ts\";\nimport {\n\tisBuiltinPluginProfileIdV1,\n\tlistBuiltinPluginManifestsV1,\n\tlistBuiltinPluginProfilesV1,\n} from \"../profile/plugin-profiles.ts\";\nimport type { PluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\nimport { createPluginManagerControllerV1 } from \"./plugin-manager-controller.ts\";\n\nexport interface PluginCommandOptionsV1 {\n\treadonly agentDir?: string;\n\t/** Working directory used for the project-local selection store. */\n\treadonly cwd?: string;\n\treadonly host?: {\n\t\treadonly os: string;\n\t\treadonly arch: string;\n\t\treadonly runtime: readonly { readonly name: string; readonly version: string }[];\n\t\treadonly apiVersion: string;\n\t\treadonly hostFeatures: readonly string[];\n\t};\n\t/** Optional host-owned boundaries used by install/update/remove commands. */\n\treadonly registry?: PluginEcosystemRegistryV1;\n\treadonly installer?: PluginInstallerV1;\n\t/** Optional host-owned multi-source package resolution used by install/update. */\n\treadonly acquisition?: PluginEcosystemCliAcquisitionV1;\n\t/** Optional host-owned package download boundary used by install/update. */\n\treadonly distribution?: PluginDistributionV1;\n\t/** Override persistence in tests or an embedding host; defaults remain agentDir files. */\n\treadonly stateStore?: PluginStateStoreV1;\n\t/** Override the project-local persistence boundary in tests or an embedding host. */\n\treadonly projectStateStore?: PluginStateStoreV1;\n\treadonly selectionStore?: PluginSelectionStoreV1;\n\treadonly projectSelectionStore?: PluginSelectionStoreV1;\n\treadonly write?: (line: string) => void;\n}\n\nfunction printResponse(response: PluginEcosystemCliResponseV1, write: (line: string) => void): void {\n\twrite(response.text);\n\tif (response.status !== \"succeeded\") process.exitCode = 1;\n}\n\n/**\n * The parsed `selection set` command, or undefined for every other command\n * and for argv the ecosystem parser rejects (the ecosystem CLI reports those\n * with its own invalid-command diagnostic). Parsing through the shared\n * grammar keeps option positions (`--scope`, `--json`) from displacing the\n * profile token this boundary validates.\n */\nfunction parseSelectionSetCommand(argv: readonly string[]): PluginEcosystemCliParsedCommandV1 | undefined {\n\ttry {\n\t\tconst parsed = parsePluginEcosystemCliCommandV1(argv);\n\t\treturn parsed.command === \"selection-set\" ? parsed : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\ninterface MarketCliOptionsV1 {\n\treadonly agentDir: string;\n\treadonly cwd: string;\n\treadonly market?: DefaultPluginMarketWiringV1;\n\treadonly overrides?: PluginCommandOptionsV1;\n}\n\nfunction buildMarketCli(options: MarketCliOptionsV1): PluginEcosystemCliV1 {\n\tconst { market, overrides } = options;\n\treturn createPluginEcosystemCliV1({\n\t\thost: overrides?.host ?? defaultPluginHostFactsV1(),\n\t\tmanifests: listBuiltinPluginManifestsV1(),\n\t\tregistry: overrides?.registry ?? market?.cliRegistry,\n\t\t// Multi-source acquisition (`plugin install <ref>`) rides along with the\n\t\t// default market wiring; a fully host-injected stack replaces it wholesale.\n\t\t...(overrides?.acquisition === undefined && market?.acquisition === undefined\n\t\t\t? {}\n\t\t\t: { acquisition: overrides?.acquisition ?? market?.acquisition }),\n\t\tinstaller: overrides?.installer ?? market?.installer,\n\t\t...(overrides?.distribution !== undefined || market?.distribution !== undefined\n\t\t\t? { distribution: overrides?.distribution ?? market!.distribution }\n\t\t\t: {}),\n\t\tstateStore:\n\t\t\toverrides?.stateStore ??\n\t\t\tmarket?.stateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.agentDir, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectStateStore:\n\t\t\toverrides?.projectStateStore ??\n\t\t\tmarket?.projectStateStore ??\n\t\t\tcreatePluginStateStoreV1({\n\t\t\t\tfilePath: join(options.cwd, CONFIG_DIR_NAME, \"plugin-state.json\"),\n\t\t\t}),\n\t\tprojectScopeRef: projectPluginScopeRefV1(options.cwd),\n\t\tselectionStore:\n\t\t\toverrides?.selectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.agentDir, \".plugin-selection.json\") }),\n\t\tprojectSelectionStore:\n\t\t\toverrides?.projectSelectionStore ??\n\t\t\tcreatePluginSelectionStoreV1({ filePath: join(options.cwd, CONFIG_DIR_NAME, \".plugin-selection.json\") }),\n\t});\n}\n\n/**\n * Default TUI manager controller over the default marketplace wiring. The\n * controller reads the global or project state store per scope; callers must\n * invoke `close` after the config screen closes.\n */\nexport async function createDefaultPluginManagerControllerV1(options: {\n\treadonly agentDir?: string;\n\treadonly cwd?: string;\n\treadonly scope: \"global\" | \"project\";\n}): Promise<{ readonly controller: PluginManagerControllerV1; readonly close: () => Promise<void> }> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst market = await createDefaultPluginMarketWiringV1({ agentDir, cwd });\n\tconst cli = buildMarketCli({ agentDir, cwd, market });\n\tconst controller = createPluginManagerControllerV1({\n\t\tregistry: market.registry,\n\t\tstateStore: options.scope === \"project\" ? market.projectStateStore : market.stateStore,\n\t\tcli,\n\t});\n\treturn { controller, close: market.close };\n}\n\n/**\n * Handle the independent ecosystem command namespace before legacy package\n * commands. Install/update/remove default to the disk install store plus an\n * optional configured marketplace origin; host injection of registry and\n * installer still wins entirely.\n */\nexport async function handlePluginEcosystemCommand(\n\targs: readonly string[],\n\toptions: PluginCommandOptionsV1 = {},\n): Promise<boolean> {\n\tif (args[0] !== \"plugin\") return false;\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\t// Batch update convenience (0.85.7 user seat finding: a factory range bump\n\t// left seven plugins outdated and the per-plugin hint meant seven manual\n\t// commands). The ecosystem CLI protocol is unchanged — this outer layer\n\t// composes `state list` + one `update` per active plugin.\n\tif (args[1] === \"update\" && args[2] === \"--all\") {\n\t\tawait runBatchUpdate(args.slice(3), options, write);\n\t\treturn true;\n\t}\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\t// 2026-10-01 dogfood finding: `selection set` accepted any profile id — a\n\t// suite id like \"assistant\" persisted fine while the ordinary run resolves\n\t// only builtin plugin profile ids, so the stored selection could never be\n\t// read back. Unknown ids are rejected here at the CLI command boundary;\n\t// the selection store itself stays host-agnostic.\n\tconst selectionSet = parseSelectionSetCommand(args.slice(1));\n\tif (selectionSet !== undefined && !isBuiltinPluginProfileIdV1(selectionSet.profileId as string)) {\n\t\tconst validProfileIds = listBuiltinPluginProfilesV1()\n\t\t\t.map((profile) => profile.id)\n\t\t\t.join(\", \");\n\t\tconst message = `unknown plugin profile \"${selectionSet.profileId}\"; selection set accepts builtin plugin profile ids only: ${validProfileIds}`;\n\t\tconst base = {\n\t\t\tversion: PLUGIN_ECOSYSTEM_CLI_VERSION_V1,\n\t\t\tcommand: \"selection-set\" as const,\n\t\t\tformat: selectionSet.format,\n\t\t\tstatus: \"failed\" as const,\n\t\t\terror: { code: \"invalid_command\" as const, message },\n\t\t};\n\t\tprintResponse(\n\t\t\t{\n\t\t\t\t...base,\n\t\t\t\ttext: selectionSet.format === \"json\" ? JSON.stringify(base) : `failed: ${message}`,\n\t\t\t},\n\t\t\twrite,\n\t\t);\n\t\treturn true;\n\t}\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst response = await cli.execute({ argv: args.slice(1) });\n\t\tprintResponse(response, write);\n\t\t// CRM seat finding F3, corrected by the 2026-10-01 dogfood: installing\n\t\t// a plugin activates nothing, and the old hint pointed at `plugin\n\t\t// selection set` — a store no ordinary run reads, so suite users were\n\t\t// sent down a dead end. The real activation path is the suite's\n\t\t// capabilities list in suite.json. 2026-10-04 install-and-use finding:\n\t\t// factory plugins resolve through the suite's builtin.* capability\n\t\t// aliases that default suites already declare, so the suite.json hint\n\t\t// was wrong for them — a restart is all they need.\n\t\tif (response.status === \"succeeded\" && response.command === \"install\") {\n\t\t\tconst pluginId = response.data?.pluginId;\n\t\t\tif (typeof pluginId === \"string\") {\n\t\t\t\tconst factory = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.some((entry) => entry.pluginId === pluginId);\n\t\t\t\twrite(\n\t\t\t\t\tfactory\n\t\t\t\t\t\t? `note: ${pluginId} installed — restart agent-forge to load it`\n\t\t\t\t\t\t: `note: this plugin is installed but not yet active; to activate its tools add \"${pluginId}\" to the capabilities list in <agentDir>/suites/<suite>/suite.json and restart`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n\ninterface BatchUpdateEntry {\n\treadonly pluginId: string;\n\treadonly pluginVersion?: string;\n\treadonly scope: string;\n\treadonly lifecycle: string;\n}\n\nasync function runBatchUpdate(\n\trestArgs: readonly string[],\n\toptions: PluginCommandOptionsV1,\n\twrite: (line: string) => void,\n): Promise<void> {\n\tconst agentDir = options.agentDir ?? getAgentDir();\n\tconst cwd = options.cwd ?? process.cwd();\n\tconst scopeIndex = restArgs.indexOf(\"--scope\");\n\tconst scope = scopeIndex !== -1 && restArgs[scopeIndex + 1] === \"project\" ? \"project\" : \"global\";\n\tconst market =\n\t\toptions.registry === undefined && options.installer === undefined\n\t\t\t? await createDefaultPluginMarketWiringV1({ agentDir, cwd })\n\t\t\t: undefined;\n\ttry {\n\t\tconst cli = buildMarketCli({ agentDir, cwd, market, overrides: options });\n\t\tconst listResponse = await cli.execute({ argv: [\"state\", \"list\", \"--scope\", scope] });\n\t\tif (listResponse.status !== \"succeeded\") {\n\t\t\tprintResponse(listResponse, write);\n\t\t\treturn;\n\t\t}\n\t\tconst entries = ((listResponse.data?.entries ?? []) as readonly BatchUpdateEntry[]).filter(\n\t\t\t(entry) => entry.lifecycle === \"active\" && entry.scope === scope,\n\t\t);\n\t\tif (entries.length === 0) {\n\t\t\twrite(\"No active plugins to update.\");\n\t\t\treturn;\n\t\t}\n\t\tconst updated: string[] = [];\n\t\tconst current: string[] = [];\n\t\tconst failed: string[] = [];\n\t\tfor (const entry of entries) {\n\t\t\t// Factory-listed first-party plugins upgrade through the npm range the\n\t\t\t// bootstrap warnings name (`install <npmName>@^range`): the default disk\n\t\t\t// registry only resolves already-installed versions, so a bare `update`\n\t\t\t// there re-resolves the current version and reports nothing to do.\n\t\t\t// Non-factory plugins keep the bare `update` registry semantics.\n\t\t\tconst factoryEntry = BOOTSTRAP_FACTORY_PLUGIN_MANIFEST_V1.find((item) => item.pluginId === entry.pluginId);\n\t\t\t// Offline satisfiability pre-check: when the recorded version already\n\t\t\t// satisfies the factory range, classifying as current must not touch the\n\t\t\t// network — acquisition downloads before its already_installed check, so\n\t\t\t// satisfied entries re-downloaded every run and one network blip failed\n\t\t\t// them. `latest`/absent ranges stay online-only (satisfiability is not\n\t\t\t// decidable offline); the check reuses the npm range selector.\n\t\t\tconst range = factoryEntry?.range;\n\t\t\tif (\n\t\t\t\tfactoryEntry !== undefined &&\n\t\t\t\trange !== undefined &&\n\t\t\t\trange !== \"latest\" &&\n\t\t\t\tentry.pluginVersion !== undefined &&\n\t\t\t\tselectNpmPackageVersionV1([entry.pluginVersion], range) === entry.pluginVersion\n\t\t\t) {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst argv = factoryEntry\n\t\t\t\t? [\"install\", `${factoryEntry.npmName}@${range ?? \"latest\"}`, \"--scope\", scope]\n\t\t\t\t: [\"update\", entry.pluginId, \"--scope\", scope];\n\t\t\tconst response = await cli.execute({ argv });\n\t\t\tif (response.status === \"succeeded\") {\n\t\t\t\tupdated.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t} else if (response.error?.code === \"already_installed\") {\n\t\t\t\tcurrent.push(entry.pluginId);\n\t\t\t} else {\n\t\t\t\tfailed.push(entry.pluginId);\n\t\t\t\twrite(response.text);\n\t\t\t}\n\t\t}\n\t\tconst summary = [\n\t\t\t`updated ${updated.length}${updated.length > 0 ? ` (${updated.join(\", \")})` : \"\"}`,\n\t\t\t`already up to date ${current.length}${current.length > 0 ? ` (${current.join(\", \")})` : \"\"}`,\n\t\t\t`failed ${failed.length}${failed.length > 0 ? ` (${failed.join(\", \")})` : \"\"}`,\n\t\t].join(\"; \");\n\t\twrite(`plugin update --all [${scope}]: ${summary}`);\n\t\tif (failed.length > 0) process.exitCode = 1;\n\t} finally {\n\t\tawait market?.close();\n\t}\n}\n"]}
@@ -32,6 +32,7 @@ import type { Skill } from "./skills.ts";
32
32
  import type { SourceInfo } from "./source-info.ts";
33
33
  import type { BuildSystemPromptOptions } from "./system-prompt.ts";
34
34
  import type { BashOperations } from "./tools/bash-operations.ts";
35
+ import type { DeferredCapabilityCardV1 } from "./tools/capability-mount.ts";
35
36
  import type { ToolDefinition, ToolInfo } from "./tools/tool-definition.ts";
36
37
  /** Registry entry for one tool definition with its source metadata. */
37
38
  export interface ToolDefinitionEntry {
@@ -219,6 +220,7 @@ export interface AgentSessionInternals {
219
220
  _resourceLoader: ResourceLoader;
220
221
  _customTools: ToolDefinition[];
221
222
  _deferredToolPluginIds: ReadonlySet<string>;
223
+ _deferredCapabilityCards: DeferredCapabilityCardV1[];
222
224
  _baseToolDefinitions: Map<string, ToolDefinition>;
223
225
  _baseToolSources: Map<string, SourceInfo>;
224
226
  _toolRegistry: Map<string, AgentTool>;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-internal.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACX,KAAK,EACL,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,aAAa,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO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C;KACxF,CAAC,CAAC;IACH,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAGvD,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC5B,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,EACjF,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,CAAA;KAAE,GAChF,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,eAAe,CACd,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;QAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7E,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,OAAO,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,yBAAyB,CAAC,CAAC;CAC5F","sourcesContent":["/**\n * Shared internal contract and snapshot helpers for the agent-session\n * submodules (agent-session-bash.ts, agent-session-compaction.ts,\n * agent-session-context.ts, agent-session-lifecycle.ts, agent-session-loop.ts,\n * agent-session-retry.ts, agent-session-tools.ts, agent-session-model.ts;\n * agent-session-runtime.ts consumes the class directly).\n *\n * `AgentSession` satisfies {@link AgentSessionInternals} structurally through a\n * single internal cast; members mirror the private state and helpers that moved\n * into the submodules. Same-name delegates stay on the class so call sites,\n * dynamic dispatch, and test spies keep working unchanged.\n */\n\nimport type {\n\tAgent,\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopTurnUpdate,\n\tAgentMessage,\n\tAgentTool,\n\tPrepareNextTurnContext,\n\tThinkingLevel,\n} from \"@agent-forge/agent-core\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tImageContent,\n\tModel,\n\tTextContent,\n\tToolResultMessage,\n} from \"@agent-forge/ai/compat\";\nimport type {\n\tAgentSessionEvent,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tSessionStats,\n\tTurnAbortReason,\n} from \"./agent-session.ts\";\nimport type { CompactionCancelledResult } from \"./agent-session-compaction.ts\";\nimport type { LoopExecutor } from \"./agent-session-loop-runner.ts\";\nimport type { ForkableUserMessage } from \"./agent-session-projection.ts\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { CompactionResult } from \"./compaction/index.ts\";\nimport type { CapabilityPluginHandle, CapabilityRuntime, ContextOperationOptions } from \"./extensions/index.ts\";\nimport type { ModelStreamEventDataV1 } from \"./extensions/lifecycle-catalog.ts\";\nimport type { ContextUsage, ExecutionFactsV1 } from \"./extensions/public-api.ts\";\nimport type { HostLogger } from \"./logger.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { Skill } from \"./skills.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash-operations.ts\";\nimport type { ToolDefinition, ToolInfo } from \"./tools/tool-definition.ts\";\n\n/** Registry entry for one tool definition with its source metadata. */\nexport interface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\n/**\n * A session operation was cancelled by user intent (abort, reload barrier) — a\n * normal outcome, never a failure. Host boundaries resolve with structured\n * cancelled results instead of surfacing this as an error.\n */\nexport class SessionCancelledError extends Error {\n\treadonly reason: \"reload\" | \"signal\";\n\n\tconstructor(reason: SessionCancelledError[\"reason\"]) {\n\t\tsuper(`Session operation cancelled: ${reason}`);\n\t\tthis.name = \"SessionCancelledError\";\n\t\tthis.reason = reason;\n\t}\n}\n\n/**\n * Deep-clone a session value and freeze the clone so lifecycle payloads cannot\n * be mutated in place. The implementation lives on the public extension face\n * (`./extensions/public-api.ts`) so first-party and third-party plugins share\n * the same payload-projection contract; re-exported here for the host-internal\n * session submodules.\n */\nexport { detachedSessionSnapshot } from \"./extensions/public-api.ts\";\n\n/** JSON-safe clone for lifecycle payloads that must survive structured clone failures. */\nexport function jsonSafeSessionSnapshot<T>(value: T): T {\n\tconst serialized = JSON.stringify(value);\n\t// v8 ignore next -- 对象消息序列化永远返回字符串,undefined 分支不可达\n\treturn serialized === undefined ? (null as T) : (JSON.parse(serialized) as T);\n}\n\nexport interface AgentSessionInternals {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\treadonly _modelRuntime: ModelRuntime;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly sessionId: string;\n\treadonly isStreaming: boolean;\n\t/** Idle gate for public context operations (compile-time private getter on AgentSession). */\n\treadonly isIdle: boolean;\n\n\t// Internal session state (compile-time private on AgentSession)\n\t_compactionQueue: Promise<void>;\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t/** 已完成的溢出裁剪级数(0 = 未裁剪);与 `_overflowRecoveryAttempted` 同点位复位。 */\n\t_overflowTrimStage: number;\n\t_activeCompactionPromise: Promise<unknown> | undefined;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_branchSummaryPromise: Promise<unknown> | undefined;\n\t_resolveBranchSummaryPromise: (() => void) | undefined;\n\t_reloadInProgress: boolean;\n\t_policyDecisionAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_pendingRetryDecision:\n\t\t| { message: AssistantMessage; decision: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>> }\n\t\t| undefined;\n\t_isAgentRunActive: boolean;\n\t_currentRunAborted: boolean;\n\t_lastAbortReason: TurnAbortReason | undefined;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\n\t// Lifecycle dispatch state (compile-time private on AgentSession)\n\treadonly _modelStreamState: { streamId: string; sequence: number } | undefined;\n\t/** Correlation id for the active prompt run's lifecycle dispatches; written by the loop-runner via this facade. */\n\t_turnCorrelationId: string | undefined;\n\t_turnCorrelationCounter: number;\n\t/**\n\t * Host-process logger seam (会话轨迹第 2 期,设计 §5.2): one-line process log\n\t * beside lifecycle dispatches that report genuine failures (compaction\n\t * failed). Undefined when no hostLogger was configured; call sites treat it\n\t * as a no-op.\n\t */\n\treadonly _hostLogger?: HostLogger;\n\n\t// Bash execution state (compile-time private on AgentSession)\n\treadonly _bashAbortControllers: Set<AbortController>;\n\treadonly _activeBashPromises: Set<Promise<unknown>>;\n\t_bashEpoch: number;\n\t_pendingBashMessages: BashExecutionMessage[];\n\treadonly isDisposed: boolean;\n\n\t_capabilityRuntime: CapabilityRuntime | undefined;\n\t_compactionPolicyName: string;\n\t_overflowPolicyName: string;\n\t_branchSummaryPolicyName: string;\n\t_retryPolicyName: string;\n\t_runLoopStrategyName: string;\n\t/** Internal loop-executor seam (D-043 G3): set to replace the default prompt/continue drive. No public config; distinct from `_runLoopStrategyName` (a per-continuation veto policy). */\n\t_loopExecutor: LoopExecutor | undefined;\n\n\t// Helpers that remain on AgentSession\n\t_emit(event: AgentSessionEvent): void;\n\t_resolveIdleWaitIfIdle(): void;\n\t_flushPendingCustomMessages(): void;\n\t_emitAgentSettled(): Promise<void>;\n\t_observeLifecycleDeliveryError(error: unknown, extensionPath: string, event: string): void;\n\tabort(): Promise<void>;\n\t_abortInternal(): Promise<void>;\n\n\t// Context-transition state and delegates forwarding to agent-session-context.ts\n\t/** Generation fence for context projections that may outlive a runtime replacement. */\n\t_contextEpoch: number;\n\t_contextTransitionAbortController: AbortController;\n\t/** Serializes context transitions and lets reload/dispose drain them before teardown. */\n\t_activeContextTransition: Promise<unknown> | undefined;\n\t/** Monotonic revision for the public context snapshot/commit facade. */\n\t_contextRevision: number;\n\t/** Serializes public context commits so expectedRevision is a real CAS fence. */\n\t_contextCommitQueue: Promise<void>;\n\t/** Configured external context strategy name, written only by the constructor. */\n\treadonly _contextStrategyName: string | undefined;\n\t_requireContextStrategy(): { runtime: CapabilityRuntime; name: string };\n\t_requireIdleContextOperation(operation: string): void;\n\t_beginContextTransitionFence(): void;\n\t_isContextTransitionCurrent(epoch: number, allowReload: boolean): boolean;\n\t_assertContextTransitionCurrent(epoch: number, allowReload: boolean): void;\n\t_enqueueContextTransition<T>(\n\t\toperation: (epoch: number, signal: AbortSignal) => Promise<T>,\n\t\toptions?: { signal?: AbortSignal; allowReload?: boolean },\n\t): Promise<T>;\n\t_copyContextMessages(value: unknown, strategyName: string, direction: \"input\" | \"result\"): AgentMessage[];\n\t_applyContextTransition(\n\t\tmessages: AgentMessage[],\n\t\treason?: ContextOperationOptions[\"reason\"],\n\t\tsignal?: AbortSignal,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\t_restoreContextTransition(\n\t\tsnapshot: unknown,\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\tsnapshotContext(): Promise<unknown>;\n\trestoreContext(snapshot: unknown): Promise<AgentMessage[]>;\n\treplaceContext(context: AgentMessage[]): Promise<AgentMessage[]>;\n\n\t// Model-scope state and delegates forwarding to agent-session-model.ts\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Public scoped-models getter (Legacy 迁移 R1): submodules read via this instead of the private field. */\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t_emitModelSelect(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\",\n\t): Promise<void>;\n\t_addPersistedDefaultToNonEmptyScope(model: Model<Api>): void;\n\t_getThinkingLevelForModelSwitch(targetModel?: Model<Api>, explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_cycleScopedModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\n\t// Run-loop wiring state and delegates forwarding to agent-session-loop.ts\n\t/** The agent's construction-time prepare adapter, captured once by the loop wiring install. */\n\t_initialPrepareNextTurn:\n\t\t| ((\n\t\t\t\tcontext: PrepareNextTurnContext,\n\t\t\t\tsignal?: AbortSignal,\n\t\t ) => Promise<AgentLoopTurnUpdate | undefined> | AgentLoopTurnUpdate | undefined)\n\t\t| undefined;\n\n\t// Delegates forwarding to the submodule functions\n\t_compactBeforeNextAssistantResponse(context: AgentContext, signal?: AbortSignal): Promise<AgentContext>;\n\t_enqueueCompaction<T>(operation: () => Promise<T>): Promise<T>;\n\t_compactInternal(customInstructions?: string): Promise<CompactionResult>;\n\t_checkCompaction(\n\t\tassistantMessage: AssistantMessage,\n\t\tskipAbortedCheck?: boolean,\n\t\tsignal?: AbortSignal,\n\t): Promise<boolean>;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<boolean>;\n\t_willRetryAfterAgentEnd(event: Extract<AgentEvent, { type: \"agent_end\" }>, signal?: AbortSignal): Promise<boolean>;\n\t_isRetryableError(message: AssistantMessage, execution?: ExecutionFactsV1, signal?: AbortSignal): Promise<boolean>;\n\t_prepareRetry(\n\t\tmessage: AssistantMessage,\n\t\tprecomputedDecision?: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>>,\n\t): Promise<boolean>;\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\n\t// Lifecycle delegates forwarding to agent-session-lifecycle.ts\n\t_dispatchModelStreamLifecycle(\n\t\tmessage: AgentMessage,\n\t\teventName: ModelStreamEventDataV1[\"event\"],\n\t\tphase: ModelStreamEventDataV1[\"phase\"],\n\t): Promise<void>;\n\t_dispatchContextReplacedLifecycle(\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\tstrategyName?: string,\n\t): Promise<void>;\n\t_dispatchModelResponseLifecycle(message: AssistantMessage, entryId: string): Promise<void>;\n\t_dispatchToolCommitLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchToolResultLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchSessionReloadLifecycle(generation: number): Promise<void>;\n\n\t// Bash delegates forwarding to agent-session-bash.ts\n\tcaptureBashEpoch(): number;\n\tisBashEpochCurrent(epoch: number): boolean;\n\temitUserBash(excludeFromContext: boolean): void;\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\t// Tool registry state (compile-time private on AgentSession)\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_deferredToolPluginIds: ReadonlySet<string>;\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_baseToolSources: Map<string, SourceInfo>;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_allowedToolNames: Set<string> | undefined;\n\t_excludedToolNames: Set<string> | undefined;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride: string | undefined;\n\t_orientationPrompt: string | undefined;\n\t_preferenceCard: string | undefined;\n\t_capabilitySkillsFilter: ((skills: Skill[]) => Skill[]) | undefined;\n\t_bootstrapSkillsHandle: CapabilityPluginHandle | undefined;\n\t_cwd: string;\n\n\tgetActiveToolNames(): string[];\n\n\t// Tool registry delegates forwarding to agent-session-tools.ts\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_syncCapabilityTools(): void;\n\t_getCapabilitySkills(): Skill[];\n\t_getAvailableSkills(): Skill[];\n\t_validateCapabilitySkillConflicts(): void;\n\t_refreshBootstrapSkills(): Promise<void>;\n\n\t// Read-only projections and delegates forwarding to agent-session-projection.ts\n\treadonly sessionFile: string | undefined;\n\treadonly messages: AgentMessage[];\n\treadonly systemPrompt: string;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\n\t// Resource-discovery delegates forwarding to agent-session-extensions.ts\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: Array<{ path: string; extensionPath: string }>): Array<{\n\t\tpath: string;\n\t\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n\t}>;\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\n\t// Prompt/queue surface consumed by the extension binding closures\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n\tsetSessionName(name: string): void;\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n}\n"]}
1
+ {"version":3,"file":"agent-session-internal.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACX,KAAK,EACL,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,sBAAsB,EACtB,aAAa,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACX,GAAG,EACH,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACX,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,UA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AO,CAAC,IAAI,CAAC,CAAC;IAC3E,2BAA2B,CAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,KAAK,CAAC;QAC3F,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,WAAW,CAAC;YAAC,MAAM,EAAE,WAAW,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KACxF,CAAC,CAAC;IACH,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAGvD,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAC5B,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,EACjF,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,CAAA;KAAE,GAChF,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,eAAe,CACd,OAAO,EAAE,MAAM,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,EAChD,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;QAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC7E,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,OAAO,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,yBAAyB,CAAC,CAAC;CAC5F","sourcesContent":["/**\n * Shared internal contract and snapshot helpers for the agent-session\n * submodules (agent-session-bash.ts, agent-session-compaction.ts,\n * agent-session-context.ts, agent-session-lifecycle.ts, agent-session-loop.ts,\n * agent-session-retry.ts, agent-session-tools.ts, agent-session-model.ts;\n * agent-session-runtime.ts consumes the class directly).\n *\n * `AgentSession` satisfies {@link AgentSessionInternals} structurally through a\n * single internal cast; members mirror the private state and helpers that moved\n * into the submodules. Same-name delegates stay on the class so call sites,\n * dynamic dispatch, and test spies keep working unchanged.\n */\n\nimport type {\n\tAgent,\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopTurnUpdate,\n\tAgentMessage,\n\tAgentTool,\n\tPrepareNextTurnContext,\n\tThinkingLevel,\n} from \"@agent-forge/agent-core\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tImageContent,\n\tModel,\n\tTextContent,\n\tToolResultMessage,\n} from \"@agent-forge/ai/compat\";\nimport type {\n\tAgentSessionEvent,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tSessionStats,\n\tTurnAbortReason,\n} from \"./agent-session.ts\";\nimport type { CompactionCancelledResult } from \"./agent-session-compaction.ts\";\nimport type { LoopExecutor } from \"./agent-session-loop-runner.ts\";\nimport type { ForkableUserMessage } from \"./agent-session-projection.ts\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { CompactionResult } from \"./compaction/index.ts\";\nimport type { CapabilityPluginHandle, CapabilityRuntime, ContextOperationOptions } from \"./extensions/index.ts\";\nimport type { ModelStreamEventDataV1 } from \"./extensions/lifecycle-catalog.ts\";\nimport type { ContextUsage, ExecutionFactsV1 } from \"./extensions/public-api.ts\";\nimport type { HostLogger } from \"./logger.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { Skill } from \"./skills.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash-operations.ts\";\nimport type { DeferredCapabilityCardV1 } from \"./tools/capability-mount.ts\";\nimport type { ToolDefinition, ToolInfo } from \"./tools/tool-definition.ts\";\n\n/** Registry entry for one tool definition with its source metadata. */\nexport interface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\n/**\n * A session operation was cancelled by user intent (abort, reload barrier) — a\n * normal outcome, never a failure. Host boundaries resolve with structured\n * cancelled results instead of surfacing this as an error.\n */\nexport class SessionCancelledError extends Error {\n\treadonly reason: \"reload\" | \"signal\";\n\n\tconstructor(reason: SessionCancelledError[\"reason\"]) {\n\t\tsuper(`Session operation cancelled: ${reason}`);\n\t\tthis.name = \"SessionCancelledError\";\n\t\tthis.reason = reason;\n\t}\n}\n\n/**\n * Deep-clone a session value and freeze the clone so lifecycle payloads cannot\n * be mutated in place. The implementation lives on the public extension face\n * (`./extensions/public-api.ts`) so first-party and third-party plugins share\n * the same payload-projection contract; re-exported here for the host-internal\n * session submodules.\n */\nexport { detachedSessionSnapshot } from \"./extensions/public-api.ts\";\n\n/** JSON-safe clone for lifecycle payloads that must survive structured clone failures. */\nexport function jsonSafeSessionSnapshot<T>(value: T): T {\n\tconst serialized = JSON.stringify(value);\n\t// v8 ignore next -- 对象消息序列化永远返回字符串,undefined 分支不可达\n\treturn serialized === undefined ? (null as T) : (JSON.parse(serialized) as T);\n}\n\nexport interface AgentSessionInternals {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\treadonly _modelRuntime: ModelRuntime;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly sessionId: string;\n\treadonly isStreaming: boolean;\n\t/** Idle gate for public context operations (compile-time private getter on AgentSession). */\n\treadonly isIdle: boolean;\n\n\t// Internal session state (compile-time private on AgentSession)\n\t_compactionQueue: Promise<void>;\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t/** 已完成的溢出裁剪级数(0 = 未裁剪);与 `_overflowRecoveryAttempted` 同点位复位。 */\n\t_overflowTrimStage: number;\n\t_activeCompactionPromise: Promise<unknown> | undefined;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_branchSummaryPromise: Promise<unknown> | undefined;\n\t_resolveBranchSummaryPromise: (() => void) | undefined;\n\t_reloadInProgress: boolean;\n\t_policyDecisionAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_pendingRetryDecision:\n\t\t| { message: AssistantMessage; decision: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>> }\n\t\t| undefined;\n\t_isAgentRunActive: boolean;\n\t_currentRunAborted: boolean;\n\t_lastAbortReason: TurnAbortReason | undefined;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\n\t// Lifecycle dispatch state (compile-time private on AgentSession)\n\treadonly _modelStreamState: { streamId: string; sequence: number } | undefined;\n\t/** Correlation id for the active prompt run's lifecycle dispatches; written by the loop-runner via this facade. */\n\t_turnCorrelationId: string | undefined;\n\t_turnCorrelationCounter: number;\n\t/**\n\t * Host-process logger seam (会话轨迹第 2 期,设计 §5.2): one-line process log\n\t * beside lifecycle dispatches that report genuine failures (compaction\n\t * failed). Undefined when no hostLogger was configured; call sites treat it\n\t * as a no-op.\n\t */\n\treadonly _hostLogger?: HostLogger;\n\n\t// Bash execution state (compile-time private on AgentSession)\n\treadonly _bashAbortControllers: Set<AbortController>;\n\treadonly _activeBashPromises: Set<Promise<unknown>>;\n\t_bashEpoch: number;\n\t_pendingBashMessages: BashExecutionMessage[];\n\treadonly isDisposed: boolean;\n\n\t_capabilityRuntime: CapabilityRuntime | undefined;\n\t_compactionPolicyName: string;\n\t_overflowPolicyName: string;\n\t_branchSummaryPolicyName: string;\n\t_retryPolicyName: string;\n\t_runLoopStrategyName: string;\n\t/** Internal loop-executor seam (D-043 G3): set to replace the default prompt/continue drive. No public config; distinct from `_runLoopStrategyName` (a per-continuation veto policy). */\n\t_loopExecutor: LoopExecutor | undefined;\n\n\t// Helpers that remain on AgentSession\n\t_emit(event: AgentSessionEvent): void;\n\t_resolveIdleWaitIfIdle(): void;\n\t_flushPendingCustomMessages(): void;\n\t_emitAgentSettled(): Promise<void>;\n\t_observeLifecycleDeliveryError(error: unknown, extensionPath: string, event: string): void;\n\tabort(): Promise<void>;\n\t_abortInternal(): Promise<void>;\n\n\t// Context-transition state and delegates forwarding to agent-session-context.ts\n\t/** Generation fence for context projections that may outlive a runtime replacement. */\n\t_contextEpoch: number;\n\t_contextTransitionAbortController: AbortController;\n\t/** Serializes context transitions and lets reload/dispose drain them before teardown. */\n\t_activeContextTransition: Promise<unknown> | undefined;\n\t/** Monotonic revision for the public context snapshot/commit facade. */\n\t_contextRevision: number;\n\t/** Serializes public context commits so expectedRevision is a real CAS fence. */\n\t_contextCommitQueue: Promise<void>;\n\t/** Configured external context strategy name, written only by the constructor. */\n\treadonly _contextStrategyName: string | undefined;\n\t_requireContextStrategy(): { runtime: CapabilityRuntime; name: string };\n\t_requireIdleContextOperation(operation: string): void;\n\t_beginContextTransitionFence(): void;\n\t_isContextTransitionCurrent(epoch: number, allowReload: boolean): boolean;\n\t_assertContextTransitionCurrent(epoch: number, allowReload: boolean): void;\n\t_enqueueContextTransition<T>(\n\t\toperation: (epoch: number, signal: AbortSignal) => Promise<T>,\n\t\toptions?: { signal?: AbortSignal; allowReload?: boolean },\n\t): Promise<T>;\n\t_copyContextMessages(value: unknown, strategyName: string, direction: \"input\" | \"result\"): AgentMessage[];\n\t_applyContextTransition(\n\t\tmessages: AgentMessage[],\n\t\treason?: ContextOperationOptions[\"reason\"],\n\t\tsignal?: AbortSignal,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\t_restoreContextTransition(\n\t\tsnapshot: unknown,\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\tsnapshotContext(): Promise<unknown>;\n\trestoreContext(snapshot: unknown): Promise<AgentMessage[]>;\n\treplaceContext(context: AgentMessage[]): Promise<AgentMessage[]>;\n\n\t// Model-scope state and delegates forwarding to agent-session-model.ts\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Public scoped-models getter (Legacy 迁移 R1): submodules read via this instead of the private field. */\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t_emitModelSelect(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\",\n\t): Promise<void>;\n\t_addPersistedDefaultToNonEmptyScope(model: Model<Api>): void;\n\t_getThinkingLevelForModelSwitch(targetModel?: Model<Api>, explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_cycleScopedModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\n\t// Run-loop wiring state and delegates forwarding to agent-session-loop.ts\n\t/** The agent's construction-time prepare adapter, captured once by the loop wiring install. */\n\t_initialPrepareNextTurn:\n\t\t| ((\n\t\t\t\tcontext: PrepareNextTurnContext,\n\t\t\t\tsignal?: AbortSignal,\n\t\t ) => Promise<AgentLoopTurnUpdate | undefined> | AgentLoopTurnUpdate | undefined)\n\t\t| undefined;\n\n\t// Delegates forwarding to the submodule functions\n\t_compactBeforeNextAssistantResponse(context: AgentContext, signal?: AbortSignal): Promise<AgentContext>;\n\t_enqueueCompaction<T>(operation: () => Promise<T>): Promise<T>;\n\t_compactInternal(customInstructions?: string): Promise<CompactionResult>;\n\t_checkCompaction(\n\t\tassistantMessage: AssistantMessage,\n\t\tskipAbortedCheck?: boolean,\n\t\tsignal?: AbortSignal,\n\t): Promise<boolean>;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<boolean>;\n\t_willRetryAfterAgentEnd(event: Extract<AgentEvent, { type: \"agent_end\" }>, signal?: AbortSignal): Promise<boolean>;\n\t_isRetryableError(message: AssistantMessage, execution?: ExecutionFactsV1, signal?: AbortSignal): Promise<boolean>;\n\t_prepareRetry(\n\t\tmessage: AssistantMessage,\n\t\tprecomputedDecision?: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>>,\n\t): Promise<boolean>;\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\n\t// Lifecycle delegates forwarding to agent-session-lifecycle.ts\n\t_dispatchModelStreamLifecycle(\n\t\tmessage: AgentMessage,\n\t\teventName: ModelStreamEventDataV1[\"event\"],\n\t\tphase: ModelStreamEventDataV1[\"phase\"],\n\t): Promise<void>;\n\t_dispatchContextReplacedLifecycle(\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\tstrategyName?: string,\n\t): Promise<void>;\n\t_dispatchModelResponseLifecycle(message: AssistantMessage, entryId: string): Promise<void>;\n\t_dispatchToolCommitLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchToolResultLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchSessionReloadLifecycle(generation: number): Promise<void>;\n\n\t// Bash delegates forwarding to agent-session-bash.ts\n\tcaptureBashEpoch(): number;\n\tisBashEpochCurrent(epoch: number): boolean;\n\temitUserBash(excludeFromContext: boolean): void;\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\t// Tool registry state (compile-time private on AgentSession)\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_deferredToolPluginIds: ReadonlySet<string>;\n\t_deferredCapabilityCards: DeferredCapabilityCardV1[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_baseToolSources: Map<string, SourceInfo>;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_allowedToolNames: Set<string> | undefined;\n\t_excludedToolNames: Set<string> | undefined;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride: string | undefined;\n\t_orientationPrompt: string | undefined;\n\t_preferenceCard: string | undefined;\n\t_capabilitySkillsFilter: ((skills: Skill[]) => Skill[]) | undefined;\n\t_bootstrapSkillsHandle: CapabilityPluginHandle | undefined;\n\t_cwd: string;\n\n\tgetActiveToolNames(): string[];\n\n\t// Tool registry delegates forwarding to agent-session-tools.ts\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_syncCapabilityTools(): void;\n\t_getCapabilitySkills(): Skill[];\n\t_getAvailableSkills(): Skill[];\n\t_validateCapabilitySkillConflicts(): void;\n\t_refreshBootstrapSkills(): Promise<void>;\n\n\t// Read-only projections and delegates forwarding to agent-session-projection.ts\n\treadonly sessionFile: string | undefined;\n\treadonly messages: AgentMessage[];\n\treadonly systemPrompt: string;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\n\t// Resource-discovery delegates forwarding to agent-session-extensions.ts\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: Array<{ path: string; extensionPath: string }>): Array<{\n\t\tpath: string;\n\t\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n\t}>;\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\n\t// Prompt/queue surface consumed by the extension binding closures\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n\tsetSessionName(name: string): void;\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-internal.js","sourceRoot":"","sources":["../../src/core/agent-session-internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAsDH;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACtC,MAAM,CAAsB;IAErC,YAAY,MAAuC,EAAE;QACpD,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAAA,CACrB;CACD;AAED;;;;;;GAMG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB,CAAI,KAAQ,EAAK;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzC,2FAAmD;IACnD,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAE,IAAU,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAO,CAAC;AAAA,CAC9E","sourcesContent":["/**\n * Shared internal contract and snapshot helpers for the agent-session\n * submodules (agent-session-bash.ts, agent-session-compaction.ts,\n * agent-session-context.ts, agent-session-lifecycle.ts, agent-session-loop.ts,\n * agent-session-retry.ts, agent-session-tools.ts, agent-session-model.ts;\n * agent-session-runtime.ts consumes the class directly).\n *\n * `AgentSession` satisfies {@link AgentSessionInternals} structurally through a\n * single internal cast; members mirror the private state and helpers that moved\n * into the submodules. Same-name delegates stay on the class so call sites,\n * dynamic dispatch, and test spies keep working unchanged.\n */\n\nimport type {\n\tAgent,\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopTurnUpdate,\n\tAgentMessage,\n\tAgentTool,\n\tPrepareNextTurnContext,\n\tThinkingLevel,\n} from \"@agent-forge/agent-core\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tImageContent,\n\tModel,\n\tTextContent,\n\tToolResultMessage,\n} from \"@agent-forge/ai/compat\";\nimport type {\n\tAgentSessionEvent,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tSessionStats,\n\tTurnAbortReason,\n} from \"./agent-session.ts\";\nimport type { CompactionCancelledResult } from \"./agent-session-compaction.ts\";\nimport type { LoopExecutor } from \"./agent-session-loop-runner.ts\";\nimport type { ForkableUserMessage } from \"./agent-session-projection.ts\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { CompactionResult } from \"./compaction/index.ts\";\nimport type { CapabilityPluginHandle, CapabilityRuntime, ContextOperationOptions } from \"./extensions/index.ts\";\nimport type { ModelStreamEventDataV1 } from \"./extensions/lifecycle-catalog.ts\";\nimport type { ContextUsage, ExecutionFactsV1 } from \"./extensions/public-api.ts\";\nimport type { HostLogger } from \"./logger.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { Skill } from \"./skills.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash-operations.ts\";\nimport type { ToolDefinition, ToolInfo } from \"./tools/tool-definition.ts\";\n\n/** Registry entry for one tool definition with its source metadata. */\nexport interface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\n/**\n * A session operation was cancelled by user intent (abort, reload barrier) — a\n * normal outcome, never a failure. Host boundaries resolve with structured\n * cancelled results instead of surfacing this as an error.\n */\nexport class SessionCancelledError extends Error {\n\treadonly reason: \"reload\" | \"signal\";\n\n\tconstructor(reason: SessionCancelledError[\"reason\"]) {\n\t\tsuper(`Session operation cancelled: ${reason}`);\n\t\tthis.name = \"SessionCancelledError\";\n\t\tthis.reason = reason;\n\t}\n}\n\n/**\n * Deep-clone a session value and freeze the clone so lifecycle payloads cannot\n * be mutated in place. The implementation lives on the public extension face\n * (`./extensions/public-api.ts`) so first-party and third-party plugins share\n * the same payload-projection contract; re-exported here for the host-internal\n * session submodules.\n */\nexport { detachedSessionSnapshot } from \"./extensions/public-api.ts\";\n\n/** JSON-safe clone for lifecycle payloads that must survive structured clone failures. */\nexport function jsonSafeSessionSnapshot<T>(value: T): T {\n\tconst serialized = JSON.stringify(value);\n\t// v8 ignore next -- 对象消息序列化永远返回字符串,undefined 分支不可达\n\treturn serialized === undefined ? (null as T) : (JSON.parse(serialized) as T);\n}\n\nexport interface AgentSessionInternals {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\treadonly _modelRuntime: ModelRuntime;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly sessionId: string;\n\treadonly isStreaming: boolean;\n\t/** Idle gate for public context operations (compile-time private getter on AgentSession). */\n\treadonly isIdle: boolean;\n\n\t// Internal session state (compile-time private on AgentSession)\n\t_compactionQueue: Promise<void>;\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t/** 已完成的溢出裁剪级数(0 = 未裁剪);与 `_overflowRecoveryAttempted` 同点位复位。 */\n\t_overflowTrimStage: number;\n\t_activeCompactionPromise: Promise<unknown> | undefined;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_branchSummaryPromise: Promise<unknown> | undefined;\n\t_resolveBranchSummaryPromise: (() => void) | undefined;\n\t_reloadInProgress: boolean;\n\t_policyDecisionAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_pendingRetryDecision:\n\t\t| { message: AssistantMessage; decision: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>> }\n\t\t| undefined;\n\t_isAgentRunActive: boolean;\n\t_currentRunAborted: boolean;\n\t_lastAbortReason: TurnAbortReason | undefined;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\n\t// Lifecycle dispatch state (compile-time private on AgentSession)\n\treadonly _modelStreamState: { streamId: string; sequence: number } | undefined;\n\t/** Correlation id for the active prompt run's lifecycle dispatches; written by the loop-runner via this facade. */\n\t_turnCorrelationId: string | undefined;\n\t_turnCorrelationCounter: number;\n\t/**\n\t * Host-process logger seam (会话轨迹第 2 期,设计 §5.2): one-line process log\n\t * beside lifecycle dispatches that report genuine failures (compaction\n\t * failed). Undefined when no hostLogger was configured; call sites treat it\n\t * as a no-op.\n\t */\n\treadonly _hostLogger?: HostLogger;\n\n\t// Bash execution state (compile-time private on AgentSession)\n\treadonly _bashAbortControllers: Set<AbortController>;\n\treadonly _activeBashPromises: Set<Promise<unknown>>;\n\t_bashEpoch: number;\n\t_pendingBashMessages: BashExecutionMessage[];\n\treadonly isDisposed: boolean;\n\n\t_capabilityRuntime: CapabilityRuntime | undefined;\n\t_compactionPolicyName: string;\n\t_overflowPolicyName: string;\n\t_branchSummaryPolicyName: string;\n\t_retryPolicyName: string;\n\t_runLoopStrategyName: string;\n\t/** Internal loop-executor seam (D-043 G3): set to replace the default prompt/continue drive. No public config; distinct from `_runLoopStrategyName` (a per-continuation veto policy). */\n\t_loopExecutor: LoopExecutor | undefined;\n\n\t// Helpers that remain on AgentSession\n\t_emit(event: AgentSessionEvent): void;\n\t_resolveIdleWaitIfIdle(): void;\n\t_flushPendingCustomMessages(): void;\n\t_emitAgentSettled(): Promise<void>;\n\t_observeLifecycleDeliveryError(error: unknown, extensionPath: string, event: string): void;\n\tabort(): Promise<void>;\n\t_abortInternal(): Promise<void>;\n\n\t// Context-transition state and delegates forwarding to agent-session-context.ts\n\t/** Generation fence for context projections that may outlive a runtime replacement. */\n\t_contextEpoch: number;\n\t_contextTransitionAbortController: AbortController;\n\t/** Serializes context transitions and lets reload/dispose drain them before teardown. */\n\t_activeContextTransition: Promise<unknown> | undefined;\n\t/** Monotonic revision for the public context snapshot/commit facade. */\n\t_contextRevision: number;\n\t/** Serializes public context commits so expectedRevision is a real CAS fence. */\n\t_contextCommitQueue: Promise<void>;\n\t/** Configured external context strategy name, written only by the constructor. */\n\treadonly _contextStrategyName: string | undefined;\n\t_requireContextStrategy(): { runtime: CapabilityRuntime; name: string };\n\t_requireIdleContextOperation(operation: string): void;\n\t_beginContextTransitionFence(): void;\n\t_isContextTransitionCurrent(epoch: number, allowReload: boolean): boolean;\n\t_assertContextTransitionCurrent(epoch: number, allowReload: boolean): void;\n\t_enqueueContextTransition<T>(\n\t\toperation: (epoch: number, signal: AbortSignal) => Promise<T>,\n\t\toptions?: { signal?: AbortSignal; allowReload?: boolean },\n\t): Promise<T>;\n\t_copyContextMessages(value: unknown, strategyName: string, direction: \"input\" | \"result\"): AgentMessage[];\n\t_applyContextTransition(\n\t\tmessages: AgentMessage[],\n\t\treason?: ContextOperationOptions[\"reason\"],\n\t\tsignal?: AbortSignal,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\t_restoreContextTransition(\n\t\tsnapshot: unknown,\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\tsnapshotContext(): Promise<unknown>;\n\trestoreContext(snapshot: unknown): Promise<AgentMessage[]>;\n\treplaceContext(context: AgentMessage[]): Promise<AgentMessage[]>;\n\n\t// Model-scope state and delegates forwarding to agent-session-model.ts\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Public scoped-models getter (Legacy 迁移 R1): submodules read via this instead of the private field. */\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t_emitModelSelect(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\",\n\t): Promise<void>;\n\t_addPersistedDefaultToNonEmptyScope(model: Model<Api>): void;\n\t_getThinkingLevelForModelSwitch(targetModel?: Model<Api>, explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_cycleScopedModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\n\t// Run-loop wiring state and delegates forwarding to agent-session-loop.ts\n\t/** The agent's construction-time prepare adapter, captured once by the loop wiring install. */\n\t_initialPrepareNextTurn:\n\t\t| ((\n\t\t\t\tcontext: PrepareNextTurnContext,\n\t\t\t\tsignal?: AbortSignal,\n\t\t ) => Promise<AgentLoopTurnUpdate | undefined> | AgentLoopTurnUpdate | undefined)\n\t\t| undefined;\n\n\t// Delegates forwarding to the submodule functions\n\t_compactBeforeNextAssistantResponse(context: AgentContext, signal?: AbortSignal): Promise<AgentContext>;\n\t_enqueueCompaction<T>(operation: () => Promise<T>): Promise<T>;\n\t_compactInternal(customInstructions?: string): Promise<CompactionResult>;\n\t_checkCompaction(\n\t\tassistantMessage: AssistantMessage,\n\t\tskipAbortedCheck?: boolean,\n\t\tsignal?: AbortSignal,\n\t): Promise<boolean>;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<boolean>;\n\t_willRetryAfterAgentEnd(event: Extract<AgentEvent, { type: \"agent_end\" }>, signal?: AbortSignal): Promise<boolean>;\n\t_isRetryableError(message: AssistantMessage, execution?: ExecutionFactsV1, signal?: AbortSignal): Promise<boolean>;\n\t_prepareRetry(\n\t\tmessage: AssistantMessage,\n\t\tprecomputedDecision?: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>>,\n\t): Promise<boolean>;\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\n\t// Lifecycle delegates forwarding to agent-session-lifecycle.ts\n\t_dispatchModelStreamLifecycle(\n\t\tmessage: AgentMessage,\n\t\teventName: ModelStreamEventDataV1[\"event\"],\n\t\tphase: ModelStreamEventDataV1[\"phase\"],\n\t): Promise<void>;\n\t_dispatchContextReplacedLifecycle(\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\tstrategyName?: string,\n\t): Promise<void>;\n\t_dispatchModelResponseLifecycle(message: AssistantMessage, entryId: string): Promise<void>;\n\t_dispatchToolCommitLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchToolResultLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchSessionReloadLifecycle(generation: number): Promise<void>;\n\n\t// Bash delegates forwarding to agent-session-bash.ts\n\tcaptureBashEpoch(): number;\n\tisBashEpochCurrent(epoch: number): boolean;\n\temitUserBash(excludeFromContext: boolean): void;\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\t// Tool registry state (compile-time private on AgentSession)\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_deferredToolPluginIds: ReadonlySet<string>;\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_baseToolSources: Map<string, SourceInfo>;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_allowedToolNames: Set<string> | undefined;\n\t_excludedToolNames: Set<string> | undefined;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride: string | undefined;\n\t_orientationPrompt: string | undefined;\n\t_preferenceCard: string | undefined;\n\t_capabilitySkillsFilter: ((skills: Skill[]) => Skill[]) | undefined;\n\t_bootstrapSkillsHandle: CapabilityPluginHandle | undefined;\n\t_cwd: string;\n\n\tgetActiveToolNames(): string[];\n\n\t// Tool registry delegates forwarding to agent-session-tools.ts\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_syncCapabilityTools(): void;\n\t_getCapabilitySkills(): Skill[];\n\t_getAvailableSkills(): Skill[];\n\t_validateCapabilitySkillConflicts(): void;\n\t_refreshBootstrapSkills(): Promise<void>;\n\n\t// Read-only projections and delegates forwarding to agent-session-projection.ts\n\treadonly sessionFile: string | undefined;\n\treadonly messages: AgentMessage[];\n\treadonly systemPrompt: string;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\n\t// Resource-discovery delegates forwarding to agent-session-extensions.ts\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: Array<{ path: string; extensionPath: string }>): Array<{\n\t\tpath: string;\n\t\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n\t}>;\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\n\t// Prompt/queue surface consumed by the extension binding closures\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n\tsetSessionName(name: string): void;\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n}\n"]}
1
+ {"version":3,"file":"agent-session-internal.js","sourceRoot":"","sources":["../../src/core/agent-session-internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAuDH;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACtC,MAAM,CAAsB;IAErC,YAAY,MAAuC,EAAE;QACpD,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAAA,CACrB;CACD;AAED;;;;;;GAMG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB,CAAI,KAAQ,EAAK;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzC,2FAAmD;IACnD,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAE,IAAU,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAO,CAAC;AAAA,CAC9E","sourcesContent":["/**\n * Shared internal contract and snapshot helpers for the agent-session\n * submodules (agent-session-bash.ts, agent-session-compaction.ts,\n * agent-session-context.ts, agent-session-lifecycle.ts, agent-session-loop.ts,\n * agent-session-retry.ts, agent-session-tools.ts, agent-session-model.ts;\n * agent-session-runtime.ts consumes the class directly).\n *\n * `AgentSession` satisfies {@link AgentSessionInternals} structurally through a\n * single internal cast; members mirror the private state and helpers that moved\n * into the submodules. Same-name delegates stay on the class so call sites,\n * dynamic dispatch, and test spies keep working unchanged.\n */\n\nimport type {\n\tAgent,\n\tAgentContext,\n\tAgentEvent,\n\tAgentLoopTurnUpdate,\n\tAgentMessage,\n\tAgentTool,\n\tPrepareNextTurnContext,\n\tThinkingLevel,\n} from \"@agent-forge/agent-core\";\nimport type {\n\tApi,\n\tAssistantMessage,\n\tImageContent,\n\tModel,\n\tTextContent,\n\tToolResultMessage,\n} from \"@agent-forge/ai/compat\";\nimport type {\n\tAgentSessionEvent,\n\tModelCycleResult,\n\tModelMutationOptions,\n\tSessionStats,\n\tTurnAbortReason,\n} from \"./agent-session.ts\";\nimport type { CompactionCancelledResult } from \"./agent-session-compaction.ts\";\nimport type { LoopExecutor } from \"./agent-session-loop-runner.ts\";\nimport type { ForkableUserMessage } from \"./agent-session-projection.ts\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type { CompactionResult } from \"./compaction/index.ts\";\nimport type { CapabilityPluginHandle, CapabilityRuntime, ContextOperationOptions } from \"./extensions/index.ts\";\nimport type { ModelStreamEventDataV1 } from \"./extensions/lifecycle-catalog.ts\";\nimport type { ContextUsage, ExecutionFactsV1 } from \"./extensions/public-api.ts\";\nimport type { HostLogger } from \"./logger.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRuntime } from \"./model-runtime.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { Skill } from \"./skills.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash-operations.ts\";\nimport type { DeferredCapabilityCardV1 } from \"./tools/capability-mount.ts\";\nimport type { ToolDefinition, ToolInfo } from \"./tools/tool-definition.ts\";\n\n/** Registry entry for one tool definition with its source metadata. */\nexport interface ToolDefinitionEntry {\n\tdefinition: ToolDefinition;\n\tsourceInfo: SourceInfo;\n}\n\n/**\n * A session operation was cancelled by user intent (abort, reload barrier) — a\n * normal outcome, never a failure. Host boundaries resolve with structured\n * cancelled results instead of surfacing this as an error.\n */\nexport class SessionCancelledError extends Error {\n\treadonly reason: \"reload\" | \"signal\";\n\n\tconstructor(reason: SessionCancelledError[\"reason\"]) {\n\t\tsuper(`Session operation cancelled: ${reason}`);\n\t\tthis.name = \"SessionCancelledError\";\n\t\tthis.reason = reason;\n\t}\n}\n\n/**\n * Deep-clone a session value and freeze the clone so lifecycle payloads cannot\n * be mutated in place. The implementation lives on the public extension face\n * (`./extensions/public-api.ts`) so first-party and third-party plugins share\n * the same payload-projection contract; re-exported here for the host-internal\n * session submodules.\n */\nexport { detachedSessionSnapshot } from \"./extensions/public-api.ts\";\n\n/** JSON-safe clone for lifecycle payloads that must survive structured clone failures. */\nexport function jsonSafeSessionSnapshot<T>(value: T): T {\n\tconst serialized = JSON.stringify(value);\n\t// v8 ignore next -- 对象消息序列化永远返回字符串,undefined 分支不可达\n\treturn serialized === undefined ? (null as T) : (JSON.parse(serialized) as T);\n}\n\nexport interface AgentSessionInternals {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n\treadonly _modelRuntime: ModelRuntime;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly sessionId: string;\n\treadonly isStreaming: boolean;\n\t/** Idle gate for public context operations (compile-time private getter on AgentSession). */\n\treadonly isIdle: boolean;\n\n\t// Internal session state (compile-time private on AgentSession)\n\t_compactionQueue: Promise<void>;\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t/** 已完成的溢出裁剪级数(0 = 未裁剪);与 `_overflowRecoveryAttempted` 同点位复位。 */\n\t_overflowTrimStage: number;\n\t_activeCompactionPromise: Promise<unknown> | undefined;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_branchSummaryPromise: Promise<unknown> | undefined;\n\t_resolveBranchSummaryPromise: (() => void) | undefined;\n\t_reloadInProgress: boolean;\n\t_policyDecisionAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_pendingRetryDecision:\n\t\t| { message: AssistantMessage; decision: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>> }\n\t\t| undefined;\n\t_isAgentRunActive: boolean;\n\t_currentRunAborted: boolean;\n\t_lastAbortReason: TurnAbortReason | undefined;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n\n\t// Lifecycle dispatch state (compile-time private on AgentSession)\n\treadonly _modelStreamState: { streamId: string; sequence: number } | undefined;\n\t/** Correlation id for the active prompt run's lifecycle dispatches; written by the loop-runner via this facade. */\n\t_turnCorrelationId: string | undefined;\n\t_turnCorrelationCounter: number;\n\t/**\n\t * Host-process logger seam (会话轨迹第 2 期,设计 §5.2): one-line process log\n\t * beside lifecycle dispatches that report genuine failures (compaction\n\t * failed). Undefined when no hostLogger was configured; call sites treat it\n\t * as a no-op.\n\t */\n\treadonly _hostLogger?: HostLogger;\n\n\t// Bash execution state (compile-time private on AgentSession)\n\treadonly _bashAbortControllers: Set<AbortController>;\n\treadonly _activeBashPromises: Set<Promise<unknown>>;\n\t_bashEpoch: number;\n\t_pendingBashMessages: BashExecutionMessage[];\n\treadonly isDisposed: boolean;\n\n\t_capabilityRuntime: CapabilityRuntime | undefined;\n\t_compactionPolicyName: string;\n\t_overflowPolicyName: string;\n\t_branchSummaryPolicyName: string;\n\t_retryPolicyName: string;\n\t_runLoopStrategyName: string;\n\t/** Internal loop-executor seam (D-043 G3): set to replace the default prompt/continue drive. No public config; distinct from `_runLoopStrategyName` (a per-continuation veto policy). */\n\t_loopExecutor: LoopExecutor | undefined;\n\n\t// Helpers that remain on AgentSession\n\t_emit(event: AgentSessionEvent): void;\n\t_resolveIdleWaitIfIdle(): void;\n\t_flushPendingCustomMessages(): void;\n\t_emitAgentSettled(): Promise<void>;\n\t_observeLifecycleDeliveryError(error: unknown, extensionPath: string, event: string): void;\n\tabort(): Promise<void>;\n\t_abortInternal(): Promise<void>;\n\n\t// Context-transition state and delegates forwarding to agent-session-context.ts\n\t/** Generation fence for context projections that may outlive a runtime replacement. */\n\t_contextEpoch: number;\n\t_contextTransitionAbortController: AbortController;\n\t/** Serializes context transitions and lets reload/dispose drain them before teardown. */\n\t_activeContextTransition: Promise<unknown> | undefined;\n\t/** Monotonic revision for the public context snapshot/commit facade. */\n\t_contextRevision: number;\n\t/** Serializes public context commits so expectedRevision is a real CAS fence. */\n\t_contextCommitQueue: Promise<void>;\n\t/** Configured external context strategy name, written only by the constructor. */\n\treadonly _contextStrategyName: string | undefined;\n\t_requireContextStrategy(): { runtime: CapabilityRuntime; name: string };\n\t_requireIdleContextOperation(operation: string): void;\n\t_beginContextTransitionFence(): void;\n\t_isContextTransitionCurrent(epoch: number, allowReload: boolean): boolean;\n\t_assertContextTransitionCurrent(epoch: number, allowReload: boolean): void;\n\t_enqueueContextTransition<T>(\n\t\toperation: (epoch: number, signal: AbortSignal) => Promise<T>,\n\t\toptions?: { signal?: AbortSignal; allowReload?: boolean },\n\t): Promise<T>;\n\t_copyContextMessages(value: unknown, strategyName: string, direction: \"input\" | \"result\"): AgentMessage[];\n\t_applyContextTransition(\n\t\tmessages: AgentMessage[],\n\t\treason?: ContextOperationOptions[\"reason\"],\n\t\tsignal?: AbortSignal,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\t_restoreContextTransition(\n\t\tsnapshot: unknown,\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\toptions?: { allowReload?: boolean },\n\t): Promise<AgentMessage[]>;\n\tsnapshotContext(): Promise<unknown>;\n\trestoreContext(snapshot: unknown): Promise<AgentMessage[]>;\n\treplaceContext(context: AgentMessage[]): Promise<AgentMessage[]>;\n\n\t// Model-scope state and delegates forwarding to agent-session-model.ts\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t/** Public scoped-models getter (Legacy 迁移 R1): submodules read via this instead of the private field. */\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\tsetModel(model: Model<Api>, options?: ModelMutationOptions): Promise<void>;\n\tsetThinkingLevel(level: ThinkingLevel, options?: ModelMutationOptions): void;\n\t_emitModelSelect(\n\t\tnextModel: Model<Api>,\n\t\tpreviousModel: Model<Api> | undefined,\n\t\tsource: \"set\" | \"cycle\" | \"restore\",\n\t): Promise<void>;\n\t_addPersistedDefaultToNonEmptyScope(model: Model<Api>): void;\n\t_getThinkingLevelForModelSwitch(targetModel?: Model<Api>, explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_cycleScopedModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(\n\t\tdirection: \"forward\" | \"backward\",\n\t\toptions: ModelMutationOptions,\n\t): Promise<ModelCycleResult | undefined>;\n\n\t// Run-loop wiring state and delegates forwarding to agent-session-loop.ts\n\t/** The agent's construction-time prepare adapter, captured once by the loop wiring install. */\n\t_initialPrepareNextTurn:\n\t\t| ((\n\t\t\t\tcontext: PrepareNextTurnContext,\n\t\t\t\tsignal?: AbortSignal,\n\t\t ) => Promise<AgentLoopTurnUpdate | undefined> | AgentLoopTurnUpdate | undefined)\n\t\t| undefined;\n\n\t// Delegates forwarding to the submodule functions\n\t_compactBeforeNextAssistantResponse(context: AgentContext, signal?: AbortSignal): Promise<AgentContext>;\n\t_enqueueCompaction<T>(operation: () => Promise<T>): Promise<T>;\n\t_compactInternal(customInstructions?: string): Promise<CompactionResult>;\n\t_checkCompaction(\n\t\tassistantMessage: AssistantMessage,\n\t\tskipAbortedCheck?: boolean,\n\t\tsignal?: AbortSignal,\n\t): Promise<boolean>;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<boolean>;\n\t_willRetryAfterAgentEnd(event: Extract<AgentEvent, { type: \"agent_end\" }>, signal?: AbortSignal): Promise<boolean>;\n\t_isRetryableError(message: AssistantMessage, execution?: ExecutionFactsV1, signal?: AbortSignal): Promise<boolean>;\n\t_prepareRetry(\n\t\tmessage: AssistantMessage,\n\t\tprecomputedDecision?: Awaited<ReturnType<CapabilityRuntime[\"decideRetry\"]>>,\n\t): Promise<boolean>;\n\tnavigateTree(\n\t\ttargetId: string,\n\t\toptions?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },\n\t): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\n\t// Lifecycle delegates forwarding to agent-session-lifecycle.ts\n\t_dispatchModelStreamLifecycle(\n\t\tmessage: AgentMessage,\n\t\teventName: ModelStreamEventDataV1[\"event\"],\n\t\tphase: ModelStreamEventDataV1[\"phase\"],\n\t): Promise<void>;\n\t_dispatchContextReplacedLifecycle(\n\t\treason: NonNullable<ContextOperationOptions[\"reason\"]>,\n\t\tstrategyName?: string,\n\t): Promise<void>;\n\t_dispatchModelResponseLifecycle(message: AssistantMessage, entryId: string): Promise<void>;\n\t_dispatchToolCommitLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchToolResultLifecycle(message: ToolResultMessage, entryId: string): Promise<void>;\n\t_dispatchSessionReloadLifecycle(generation: number): Promise<void>;\n\n\t// Bash delegates forwarding to agent-session-bash.ts\n\tcaptureBashEpoch(): number;\n\tisBashEpochCurrent(epoch: number): boolean;\n\temitUserBash(excludeFromContext: boolean): void;\n\texecuteBash(\n\t\tcommand: string,\n\t\tonChunk?: (chunk: string) => void,\n\t\toptions?: { excludeFromContext?: boolean; id?: string; operations?: BashOperations },\n\t): Promise<BashResult>;\n\trecordBashResult(\n\t\tcommand: string,\n\t\tresult: BashResult,\n\t\toptions?: { excludeFromContext?: boolean; epoch?: number },\n\t): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\t// Tool registry state (compile-time private on AgentSession)\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_deferredToolPluginIds: ReadonlySet<string>;\n\t_deferredCapabilityCards: DeferredCapabilityCardV1[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_baseToolSources: Map<string, SourceInfo>;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_allowedToolNames: Set<string> | undefined;\n\t_excludedToolNames: Set<string> | undefined;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_systemPromptOverride: string | undefined;\n\t_orientationPrompt: string | undefined;\n\t_preferenceCard: string | undefined;\n\t_capabilitySkillsFilter: ((skills: Skill[]) => Skill[]) | undefined;\n\t_bootstrapSkillsHandle: CapabilityPluginHandle | undefined;\n\t_cwd: string;\n\n\tgetActiveToolNames(): string[];\n\n\t// Tool registry delegates forwarding to agent-session-tools.ts\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_syncCapabilityTools(): void;\n\t_getCapabilitySkills(): Skill[];\n\t_getAvailableSkills(): Skill[];\n\t_validateCapabilitySkillConflicts(): void;\n\t_refreshBootstrapSkills(): Promise<void>;\n\n\t// Read-only projections and delegates forwarding to agent-session-projection.ts\n\treadonly sessionFile: string | undefined;\n\treadonly messages: AgentMessage[];\n\treadonly systemPrompt: string;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\tgetUserMessagesForForking(): ForkableUserMessage[];\n\texportToHtml(outputPath?: string, options?: { themeName?: string }): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\n\t// Resource-discovery delegates forwarding to agent-session-extensions.ts\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: Array<{ path: string; extensionPath: string }>): Array<{\n\t\tpath: string;\n\t\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n\t}>;\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\n\t// Prompt/queue surface consumed by the extension binding closures\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\"; expandPromptTemplates?: boolean },\n\t): Promise<void>;\n\tsetSessionName(name: string): void;\n\tcompact(customInstructions?: string): Promise<CompactionResult | CompactionCancelledResult>;\n}\n"]}
@@ -92,6 +92,8 @@ export interface CreateAgentSessionFromServicesOptions {
92
92
  services: AgentSessionServices;
93
93
  sessionManager: SessionManager;
94
94
  sessionStartEvent?: SessionStartMetadata;
95
+ /** --rebind-suite: adopt a drifted suite binding on resume (forwarded to createAgentSession). */
96
+ allowSuiteRebind?: boolean;
95
97
  model?: Model<Api>;
96
98
  streamFn?: CreateAgentSessionOptions["streamFn"];
97
99
  thinkingLevel?: ThinkingLevel;