@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
@@ -13,6 +13,7 @@
13
13
  * Modes use this class and add their own I/O layer on top.
14
14
  */
15
15
  import { readFileSync } from "node:fs";
16
+ import { readFile as readFileUtf8 } from "node:fs/promises";
16
17
  import { resolve } from "node:path";
17
18
  import { contentText } from "@agent-forge/ai";
18
19
  import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, streamSimple, } from "@agent-forge/ai/compat";
@@ -36,6 +37,7 @@ import { BOOTSTRAP_AGENT_LOOP_PLUGIN_ID, BOOTSTRAP_LIFECYCLE_PLUGIN_ID, BOOTSTRA
36
37
  import { t } from "./i18n/index.js";
37
38
  import { expandPromptTemplate } from "./prompt-templates.js";
38
39
  import { createSessionJsonlArtifact } from "./session-export.js";
40
+ import { createCapabilityMountTools } from "./tools/capability-mount.js";
39
41
  import { createToolSearchTool } from "./tools/tool-search.js";
40
42
  /**
41
43
  * Parse a skill block from message text.
@@ -151,6 +153,8 @@ export class AgentSession {
151
153
  _resourceLoader;
152
154
  _customTools;
153
155
  _deferredToolPluginIds;
156
+ _deferredCapabilityCards = [];
157
+ _capabilityMountToolsRegistered = false;
154
158
  /** Abort reason supplied to the in-flight abort(); consumed by the interruption marker. */
155
159
  _pendingAbortReason;
156
160
  /** Set when the in-flight prompt run produced an aborted terminal assistant turn. */
@@ -283,6 +287,7 @@ export class AgentSession {
283
287
  this._resourceLoader = config.resourceLoader;
284
288
  this._customTools = config.customTools ?? [];
285
289
  this._deferredToolPluginIds = new Set(config.deferredToolPluginIds ?? []);
290
+ this._deferredCapabilityCards = [...(config.deferredCapabilityCards ?? [])];
286
291
  if (this._deferredToolPluginIds.size > 0) {
287
292
  this._customTools.push(createToolSearchTool({
288
293
  listAllToolNames: () => Array.from(this._toolRegistry.keys()),
@@ -294,6 +299,10 @@ export class AgentSession {
294
299
  setActiveToolsByName: (toolNames) => this.setActiveToolsByName(toolNames),
295
300
  }));
296
301
  }
302
+ if (this._deferredCapabilityCards.length > 0) {
303
+ this._capabilityMountToolsRegistered = true;
304
+ this._customTools.push(...this._createCapabilityMountTools());
305
+ }
297
306
  this._cwd = config.cwd;
298
307
  this._modelRuntime = config.modelRuntime;
299
308
  this._initialActiveToolNames = config.initialActiveToolNames;
@@ -1010,10 +1019,11 @@ export class AgentSession {
1010
1019
  (!tool.source.startsWith("agent-forge.builtin.") && !tool.source.startsWith("agent-forge.plugin.")) ||
1011
1020
  tool.readonlySafe === true)
1012
1021
  // Deferred plugin tools register but stay out of the active set on
1013
- // this explicit-activation path too, until tool_search or
1014
- // setActiveTools names them (same contract as the default path in
1015
- // agent-session-tools.ts).
1016
- .filter((tool) => !this._deferredToolPluginIds.has(tool.source))
1022
+ // this explicit-activation path too, until tool_search /
1023
+ // capability_mount or setActiveTools names them (same contract as the
1024
+ // default path in agent-session-tools.ts).
1025
+ .filter((tool) => !this._deferredToolPluginIds.has(tool.source) &&
1026
+ !this._deferredCapabilityCards.some((card) => card.pluginId === tool.source))
1017
1027
  .map((tool) => tool.name)
1018
1028
  .filter((name) => !previousToolNames.has(name));
1019
1029
  this._refreshToolRegistry({
@@ -2042,6 +2052,50 @@ export class AgentSession {
2042
2052
  _refreshToolRegistry(options) {
2043
2053
  refreshToolRegistry(this._internal, options);
2044
2054
  }
2055
+ /** Registry tool names whose owning capability plugin is `pluginId`. */
2056
+ _toolNamesForPlugin(pluginId) {
2057
+ return Array.from(this._toolDefinitions.entries())
2058
+ .filter(([, entry]) => entry.sourceInfo.source === pluginId)
2059
+ .map(([name]) => name);
2060
+ }
2061
+ _readManual(manualPath) {
2062
+ return readFileUtf8(manualPath, "utf8");
2063
+ }
2064
+ _createCapabilityMountTools() {
2065
+ return createCapabilityMountTools({
2066
+ getCards: () => this._deferredCapabilityCards,
2067
+ toolNamesForPlugin: (pluginId) => {
2068
+ const names = this._toolNamesForPlugin(pluginId);
2069
+ // readonly narrowing (宪法 §6): the registry keeps non-readonlySafe
2070
+ // tools even in readonly sessions (the normal load path filters them
2071
+ // at activation); mount must not smuggle them past that gate.
2072
+ if (this._capabilityMode !== "readonly")
2073
+ return names;
2074
+ const readonlySafe = new Set((this._capabilityRuntime?.listTools() ?? [])
2075
+ .filter((tool) => tool.source === pluginId)
2076
+ .filter((tool) => tool.readonlySafe === true)
2077
+ .map((tool) => tool.name));
2078
+ return names.filter((name) => readonlySafe.has(name));
2079
+ },
2080
+ getActiveToolNames: () => this.getActiveToolNames(),
2081
+ setActiveToolsByName: (toolNames) => this.setActiveToolsByName(toolNames),
2082
+ readManual: (manualPath) => this._readManual(manualPath),
2083
+ });
2084
+ }
2085
+ /**
2086
+ * Register on-demand capability cards after construction (插件按需挂载与能力手册设计 §4).
2087
+ * The sdk assembly calls this once the plugin pool settles, before loading;
2088
+ * first call also injects the capability_mount / capability_unmount pair.
2089
+ * Idempotent: later calls replace the card set.
2090
+ */
2091
+ registerDeferredCapabilityCards(cards) {
2092
+ this._deferredCapabilityCards = [...cards];
2093
+ if (this._deferredCapabilityCards.length === 0 || this._capabilityMountToolsRegistered)
2094
+ return;
2095
+ this._capabilityMountToolsRegistered = true;
2096
+ this._customTools.push(...this._createCapabilityMountTools());
2097
+ this._refreshToolRegistry();
2098
+ }
2045
2099
  _syncCapabilityTools() {
2046
2100
  syncCapabilityTools(this._internal);
2047
2101
  }