@ai-agent-forge/agent-forge 0.86.2 → 0.86.3
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.
- package/CHANGELOG.md +29 -0
- package/dist/bundle/.build-manifest.json +151 -145
- package/dist/bundle/chunks/{anthropic-messages-RJYU4TCY.js → anthropic-messages-EVFQ6MLR.js} +3 -3
- package/dist/bundle/chunks/{azure-openai-responses-LESTCUL7.js → azure-openai-responses-WQCZWFAH.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/{chunk-MDOTREMR.js → chunk-3WE3W52L.js} +2 -2
- package/dist/bundle/chunks/chunk-F6SBZUJG.js +141 -0
- package/dist/bundle/chunks/{chunk-SER2HCLE.js → chunk-N6BQJSGH.js} +1 -1
- package/dist/bundle/chunks/chunk-RK2X2KU2.js +1442 -0
- package/dist/bundle/chunks/chunk-TBPTHASB.js +2 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-NZ66X6K7.js → google-generative-ai-ISTTUZMW.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-2ZZOFBNQ.js → google-vertex-NS7ZF7DK.js} +1 -1
- package/dist/bundle/chunks/jiti-static-loader-CDSTNEDU.js +2 -0
- package/dist/bundle/chunks/{mistral-conversations-B6DZRMEK.js → mistral-conversations-GINO6Z4I.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-UFH6O5K6.js → openai-codex-responses-YDJSZOIH.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-A55GHA4O.js → openai-completions-UPRWTQPT.js} +3 -3
- package/dist/bundle/chunks/openai-responses-O63W6HQ3.js +2 -0
- package/dist/bundle/chunks/virtual-modules-O72ICTMQ.js +2 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +14 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +8 -2
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +2 -2
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +120 -44
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +1 -1
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +13 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +91 -93
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +15 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +50 -17
- package/dist/core/extensions/capability-plugin.d.ts.map +1 -1
- package/dist/core/extensions/capability-plugin.js +25 -30
- package/dist/core/extensions/capability-plugin.js.map +1 -1
- package/dist/core/extensions/jiti-static-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-static-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +5 -0
- package/dist/core/extensions/jiti-static-loader.js.map +1 -0
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +32 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/facade/coding-agent-facade.d.ts +3 -3
- package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-facade.js.map +1 -1
- package/dist/core/facade/coding-agent-runtime-facade.d.ts +2 -2
- package/dist/core/facade/coding-agent-runtime-facade.d.ts.map +1 -1
- package/dist/core/facade/coding-agent-runtime-facade.js +4 -4
- package/dist/core/facade/coding-agent-runtime-facade.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-install-host.d.ts +1 -1
- package/dist/core/package-install-host.d.ts.map +1 -1
- package/dist/core/package-install-host.js +4 -3
- package/dist/core/package-install-host.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +61 -35
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +6 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/session-manager.d.ts +23 -4
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +146 -108
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +18 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -7
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +74 -50
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +18 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +35 -32
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +14 -6
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +47 -10
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +9 -10
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +10 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/remote/server-assembly.d.ts.map +1 -1
- package/dist/remote/server-assembly.js +1 -1
- package/dist/remote/server-assembly.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +1 -12
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +88 -13
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/docs/rpc.md +7 -5
- package/docs/sdk.md +9 -8
- package/package.json +1 -1
- package/dist/bundle/chunks/chunk-JR3Q27QP.js +0 -1581
- package/dist/bundle/chunks/chunk-KQEGUM34.js +0 -2
- package/dist/bundle/chunks/openai-responses-TJLXRAXR.js +0 -2
|
@@ -799,7 +799,8 @@ export class AgentSession {
|
|
|
799
799
|
getMessages: () => detachedSessionSnapshot(this.agent.state.messages),
|
|
800
800
|
isIdle: () => this.isIdle,
|
|
801
801
|
prompt: (text) => this.prompt(text),
|
|
802
|
-
|
|
802
|
+
// SessionAPI 契约固定 Promise<void>;disposition("queued"/"handled")不外泄到该面。
|
|
803
|
+
steer: (text) => this.steer(text).then(() => undefined),
|
|
803
804
|
queueFollowUp: (text) => this.sendUserMessage(text, { deliverAs: "followUp" }),
|
|
804
805
|
abort: () => this.abort(),
|
|
805
806
|
waitForIdle: () => this.waitForIdle(),
|
|
@@ -1192,107 +1193,101 @@ export class AgentSession {
|
|
|
1192
1193
|
const expandPromptTemplates = options?.expandPromptTemplates ?? true;
|
|
1193
1194
|
const preflightResult = options?.preflightResult;
|
|
1194
1195
|
let messages;
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
preflightResult?.(true);
|
|
1202
|
-
return { status: "done" };
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
if (this._compactionAbortController !== undefined) {
|
|
1206
|
-
throw new Error("Cannot submit a prompt while compaction is in progress. Wait for compaction to finish and retry.");
|
|
1207
|
-
}
|
|
1208
|
-
// Dispatch the input.gate chain, then the input.received facts (both
|
|
1209
|
-
// before skill/template expansion)
|
|
1210
|
-
const { text: currentText, images: currentImages } = await this._runInputHandlers(text, options?.images, options?.source ?? "interactive");
|
|
1211
|
-
// Expand skill commands (/skill:name args) and prompt templates (/template args)
|
|
1212
|
-
let expandedText = currentText;
|
|
1213
|
-
if (expandPromptTemplates) {
|
|
1214
|
-
expandedText = this._expandSkillCommand(expandedText);
|
|
1215
|
-
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
|
|
1216
|
-
}
|
|
1217
|
-
// If streaming, queue via steer() or followUp() based on option
|
|
1218
|
-
if (this.isStreaming) {
|
|
1219
|
-
if (!options?.streamingBehavior) {
|
|
1220
|
-
throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
|
|
1221
|
-
}
|
|
1222
|
-
if (options.streamingBehavior === "followUp") {
|
|
1223
|
-
await this._queueFollowUp(expandedText, currentImages);
|
|
1224
|
-
}
|
|
1225
|
-
else {
|
|
1226
|
-
await this._queueSteer(expandedText, currentImages);
|
|
1227
|
-
}
|
|
1228
|
-
preflightResult?.(true);
|
|
1196
|
+
// Handle plugin commands first (execute immediately, even during streaming).
|
|
1197
|
+
if (expandPromptTemplates && text.startsWith("/")) {
|
|
1198
|
+
const handled = await this._tryExecuteExtensionCommand(text);
|
|
1199
|
+
if (handled) {
|
|
1200
|
+
// Extension command executed, no prompt to send
|
|
1201
|
+
preflightResult?.("handled");
|
|
1229
1202
|
return { status: "done" };
|
|
1230
1203
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
|
|
1249
|
-
}
|
|
1250
|
-
// Check if we need to compact before sending (catches aborted responses).
|
|
1251
|
-
// The user's new prompt is sent below, so do not call agent.continue() here.
|
|
1252
|
-
const lastAssistant = this._findLastAssistantMessage();
|
|
1253
|
-
if (lastAssistant) {
|
|
1254
|
-
await this._checkCompaction(lastAssistant, false);
|
|
1255
|
-
}
|
|
1256
|
-
// Build messages array (custom message if any, then user message)
|
|
1257
|
-
messages = [];
|
|
1258
|
-
// Add user message
|
|
1259
|
-
const userContent = [{ type: "text", text: expandedText }];
|
|
1260
|
-
if (currentImages) {
|
|
1261
|
-
userContent.push(...currentImages);
|
|
1204
|
+
}
|
|
1205
|
+
if (this._compactionAbortController !== undefined) {
|
|
1206
|
+
throw new Error("Cannot submit a prompt while compaction is in progress. Wait for compaction to finish and retry.");
|
|
1207
|
+
}
|
|
1208
|
+
// Dispatch the input.gate chain, then the input.received facts (both
|
|
1209
|
+
// before skill/template expansion)
|
|
1210
|
+
const { text: currentText, images: currentImages } = await this._runInputHandlers(text, options?.images, options?.source ?? "interactive");
|
|
1211
|
+
// Expand skill commands (/skill:name args) and prompt templates (/template args)
|
|
1212
|
+
let expandedText = currentText;
|
|
1213
|
+
if (expandPromptTemplates) {
|
|
1214
|
+
expandedText = this._expandSkillCommand(expandedText);
|
|
1215
|
+
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
|
|
1216
|
+
}
|
|
1217
|
+
// If streaming, queue via steer() or followUp() based on option
|
|
1218
|
+
if (this.isStreaming) {
|
|
1219
|
+
if (!options?.streamingBehavior) {
|
|
1220
|
+
throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
|
|
1262
1221
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
content: userContent,
|
|
1266
|
-
timestamp: Date.now(),
|
|
1267
|
-
});
|
|
1268
|
-
// Inject any pending "nextTurn" messages as context alongside the user message
|
|
1269
|
-
for (const msg of this._pendingNextTurnMessages) {
|
|
1270
|
-
messages.push(msg);
|
|
1222
|
+
if (options.streamingBehavior === "followUp") {
|
|
1223
|
+
await this._queueFollowUp(expandedText, currentImages);
|
|
1271
1224
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
// Reset to the base prompt (in case a previous turn had an override),
|
|
1275
|
-
// then apply the before.agent.start@2 candidate transform (capability
|
|
1276
|
-
// channel). A transform yielding a different systemPrompt is the later
|
|
1277
|
-
// writer and wins; a missing registration, a verbatim result, or a
|
|
1278
|
-
// failed delivery keeps the base prompt.
|
|
1279
|
-
this._systemPromptOverride = undefined;
|
|
1280
|
-
this.agent.state.systemPrompt = this._baseSystemPrompt;
|
|
1281
|
-
const capabilitySystemPrompt = await dispatchBeforeAgentStartV2Lifecycle(this._internal, this._baseSystemPrompt, this._baseSystemPromptOptions);
|
|
1282
|
-
if (capabilitySystemPrompt !== undefined) {
|
|
1283
|
-
this._systemPromptOverride = capabilitySystemPrompt;
|
|
1284
|
-
this.agent.state.systemPrompt = capabilitySystemPrompt;
|
|
1225
|
+
else {
|
|
1226
|
+
await this._queueSteer(expandedText, currentImages);
|
|
1285
1227
|
}
|
|
1228
|
+
preflightResult?.("queued");
|
|
1229
|
+
return { status: "done" };
|
|
1286
1230
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1231
|
+
// Flush any pending bash and custom messages before the new prompt
|
|
1232
|
+
this._flushPendingBashMessages();
|
|
1233
|
+
this._flushPendingCustomMessages();
|
|
1234
|
+
// Validate model
|
|
1235
|
+
if (!this.model) {
|
|
1236
|
+
throw new Error(formatNoModelSelectedMessage());
|
|
1237
|
+
}
|
|
1238
|
+
const hasConfiguredAuth = this.agent.streamFunction !== streamSimple ||
|
|
1239
|
+
this._modelRuntime.hasConfiguredAuth(this.model.provider) ||
|
|
1240
|
+
(await this._modelRuntime.checkAuth(this.model.provider)) !== undefined;
|
|
1241
|
+
if (!hasConfiguredAuth) {
|
|
1242
|
+
const isOAuth = this._modelRuntime.isUsingOAuth(this.model.provider);
|
|
1243
|
+
if (isOAuth) {
|
|
1244
|
+
throw new Error(`Authentication failed for "${this.model.provider}". ` +
|
|
1245
|
+
`Credentials may have expired or network is unavailable. ` +
|
|
1246
|
+
`Run '/login ${this.model.provider}' to re-authenticate.`);
|
|
1247
|
+
}
|
|
1248
|
+
throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
|
|
1249
|
+
}
|
|
1250
|
+
// Check if we need to compact before sending (catches aborted responses).
|
|
1251
|
+
// The user's new prompt is sent below, so do not call agent.continue() here.
|
|
1252
|
+
const lastAssistant = this._findLastAssistantMessage();
|
|
1253
|
+
if (lastAssistant) {
|
|
1254
|
+
await this._checkCompaction(lastAssistant, false);
|
|
1255
|
+
}
|
|
1256
|
+
// Build messages array (custom message if any, then user message)
|
|
1257
|
+
messages = [];
|
|
1258
|
+
// Add user message
|
|
1259
|
+
const userContent = [{ type: "text", text: expandedText }];
|
|
1260
|
+
if (currentImages) {
|
|
1261
|
+
userContent.push(...currentImages);
|
|
1262
|
+
}
|
|
1263
|
+
messages.push({
|
|
1264
|
+
role: "user",
|
|
1265
|
+
content: userContent,
|
|
1266
|
+
timestamp: Date.now(),
|
|
1267
|
+
});
|
|
1268
|
+
// Inject any pending "nextTurn" messages as context alongside the user message
|
|
1269
|
+
for (const msg of this._pendingNextTurnMessages) {
|
|
1270
|
+
messages.push(msg);
|
|
1271
|
+
}
|
|
1272
|
+
this._pendingNextTurnMessages = [];
|
|
1273
|
+
await dispatchBeforeAgentStartLifecycle(this._internal, (currentImages?.length ?? 0) > 0);
|
|
1274
|
+
// Reset to the base prompt (in case a previous turn had an override),
|
|
1275
|
+
// then apply the before.agent.start@2 candidate transform (capability
|
|
1276
|
+
// channel). A transform yielding a different systemPrompt is the later
|
|
1277
|
+
// writer and wins; a missing registration, a verbatim result, or a
|
|
1278
|
+
// failed delivery keeps the base prompt.
|
|
1279
|
+
this._systemPromptOverride = undefined;
|
|
1280
|
+
this.agent.state.systemPrompt = this._baseSystemPrompt;
|
|
1281
|
+
const capabilitySystemPrompt = await dispatchBeforeAgentStartV2Lifecycle(this._internal, this._baseSystemPrompt, this._baseSystemPromptOptions);
|
|
1282
|
+
if (capabilitySystemPrompt !== undefined) {
|
|
1283
|
+
this._systemPromptOverride = capabilitySystemPrompt;
|
|
1284
|
+
this.agent.state.systemPrompt = capabilitySystemPrompt;
|
|
1290
1285
|
}
|
|
1291
1286
|
// v8 ignore next -- try 块内所有不发送路径均已提前 return,messages 必然已赋值
|
|
1292
1287
|
if (!messages) {
|
|
1293
1288
|
return { status: "done" };
|
|
1294
1289
|
}
|
|
1295
|
-
preflightResult?.(
|
|
1290
|
+
preflightResult?.("started");
|
|
1296
1291
|
return this._runAgentPrompt(messages);
|
|
1297
1292
|
}
|
|
1298
1293
|
/**
|
|
@@ -1387,6 +1382,7 @@ export class AgentSession {
|
|
|
1387
1382
|
else {
|
|
1388
1383
|
await this._queueFollowUp(expandedText, processedInput.images);
|
|
1389
1384
|
}
|
|
1385
|
+
return "queued";
|
|
1390
1386
|
}
|
|
1391
1387
|
/**
|
|
1392
1388
|
* Queue a steering message while the agent is running.
|
|
@@ -1395,10 +1391,11 @@ export class AgentSession {
|
|
|
1395
1391
|
* Expands skill commands and prompt templates. Errors on extension commands.
|
|
1396
1392
|
* @param images Optional image attachments to include with the message
|
|
1397
1393
|
* @param options Input source; defaults to interactive
|
|
1394
|
+
* @returns How the input was dispatched ("queued"; "handled" if a handler consumed it)
|
|
1398
1395
|
* @throws Error if text is an extension command
|
|
1399
1396
|
*/
|
|
1400
1397
|
async steer(text, images, options) {
|
|
1401
|
-
|
|
1398
|
+
return this._queueUserInput(text, images, "steer", options?.source ?? "interactive");
|
|
1402
1399
|
}
|
|
1403
1400
|
/**
|
|
1404
1401
|
* Queue a follow-up message to be processed after the agent finishes.
|
|
@@ -1406,10 +1403,11 @@ export class AgentSession {
|
|
|
1406
1403
|
* Expands skill commands and prompt templates. Errors on extension commands.
|
|
1407
1404
|
* @param images Optional image attachments to include with the message
|
|
1408
1405
|
* @param options Input source; defaults to interactive
|
|
1406
|
+
* @returns How the input was dispatched ("queued"; "handled" if a handler consumed it)
|
|
1409
1407
|
* @throws Error if text is an extension command
|
|
1410
1408
|
*/
|
|
1411
1409
|
async followUp(text, images, options) {
|
|
1412
|
-
|
|
1410
|
+
return this._queueUserInput(text, images, "followUp", options?.source ?? "interactive");
|
|
1413
1411
|
}
|
|
1414
1412
|
/**
|
|
1415
1413
|
* Internal: Queue a steering message (already expanded, no extension command check).
|