@agent-native/core 0.202.0 → 0.202.1-nightly-20261007011022
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/dist/agent/actions/list-model-providers.d.ts +2 -0
- package/dist/agent/actions/list-model-providers.js +32 -5
- package/dist/agent/actions/manage-provider-models.d.ts +1 -0
- package/dist/agent/engine/builder-engine.d.ts +1 -1
- package/dist/agent/engine/builtin.js +1 -1
- package/dist/agent/engine/index.d.ts +1 -1
- package/dist/agent/engine/index.js +1 -1
- package/dist/agent/engine/registry.d.ts +2 -0
- package/dist/agent/engine/registry.js +63 -47
- package/dist/agent/model-config.d.ts +6 -6
- package/dist/agent/model-config.js +7 -11
- package/dist/agent/model-version.d.ts +3 -0
- package/dist/agent/model-version.js +67 -0
- package/dist/agent/provider-model-selection.d.ts +6 -1
- package/dist/agent/provider-model-selection.js +131 -13
- package/dist/automation/index.d.ts +1 -1
- package/dist/cli/create.d.ts +2 -1
- package/dist/cli/create.js +17 -4
- package/dist/cli/template-sync.js +2 -1
- package/dist/cli/workspacify.d.ts +1 -0
- package/dist/cli/workspacify.js +4 -0
- package/dist/client/app-config.d.ts +1 -0
- package/dist/client/app-config.js +19 -0
- package/dist/client/chat/agentkit-protocol.js +122 -16
- package/dist/client/chat/runtime.js +943 -50
- package/dist/client/chat-model-groups.d.ts +1 -0
- package/dist/client/chat-model-groups.js +1 -0
- package/dist/client/use-chat-models.js +47 -6
- package/dist/deploy/build.js +23 -9
- package/dist/email-catalog/redact-body.js +1 -1
- package/dist/jobs/actions/manage-recurring-job.d.ts +1 -1
- package/dist/jobs/background-automation-runner.d.ts +3 -1
- package/dist/jobs/background-automation-runner.js +15 -8
- package/dist/jobs/scheduler.js +1 -1
- package/dist/mcp/build-server.d.ts +0 -1
- package/dist/mcp/build-server.js +10 -59
- package/dist/observability/routes.d.ts +6 -6
- package/dist/onboarding/app-profile-data.d.ts +10 -0
- package/dist/onboarding/app-profile-data.js +423 -0
- package/dist/onboarding/app-profile.d.ts +1 -7
- package/dist/onboarding/app-profile.js +5 -422
- package/dist/onboarding/index.d.ts +1 -0
- package/dist/onboarding/index.js +1 -0
- package/dist/org/handlers.d.ts +1 -1
- package/dist/org/index.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +2 -2
- package/dist/provider-api/actions/provider-api.d.ts +10 -10
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/scripts/agent-engines/manage-agent-engine.js +1 -1
- package/dist/scripts/agent-engines/set-agent-engine.js +1 -1
- package/dist/secrets/routes.d.ts +11 -11
- package/dist/server/action-routes.js +1 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/app-origin-config.d.ts +2 -0
- package/dist/server/app-origin-config.js +4 -0
- package/dist/server/auth.js +43 -1
- package/dist/server/better-auth-instance.js +7 -12
- package/dist/server/email-auth-links.d.ts +11 -0
- package/dist/server/email-auth-links.js +126 -0
- package/dist/server/fusion-app.js +11 -1
- package/dist/shared/agent-chat-context.d.ts +3 -3
- package/dist/shared/agent-chat-context.js +2 -2
- package/dist/shared/auth-copy.d.ts +3 -0
- package/dist/shared/auth-copy.js +33 -0
- package/dist/shared/design-system-agent-context.d.ts +5 -0
- package/dist/shared/design-system-agent-context.js +37 -8
- package/dist/shared/index.d.ts +1 -1
- package/dist/triggers/actions/manage-automation.d.ts +7 -7
- package/dist/triggers/condition-evaluator.d.ts +21 -5
- package/dist/triggers/condition-evaluator.js +113 -59
- package/dist/triggers/dispatcher.js +39 -21
- package/dist/vite/client.js +10 -0
- package/docs/content/durable-resume.mdx +9 -3
- package/package.json +5 -3
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { AGENTKIT_PROTOCOL_VERSION, AgentProtocolValidationError, approvalResponseFromResume, createCapabilityUnavailableError, createCapabilityUnsupportedError, inferAgentActivityKind, negotiateAgentKitProtocolVersion, resumeEntryFromApproval, resumeOptionId, } from "@agent-native/agentkit/protocol";
|
|
1
|
+
import { AGENT_TOOL_CALL_HISTORY_MEDIA_TYPE, AGENT_TOOL_RESULT_HISTORY_MEDIA_TYPE, AGENTKIT_PROTOCOL_VERSION, AgentProtocolValidationError, approvalResponseFromResume, createCapabilityUnavailableError, createCapabilityUnsupportedError, inferAgentActivityKind, negotiateAgentKitProtocolVersion, resumeEntryFromApproval, resumeOptionId, } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import { AUTO_CONTINUE_OF_RUN_METADATA_KEY, AUTO_CONTINUE_PROMPT, AUTO_CONTINUE_REFUSAL_CODES, } from "../../agent/auto-continue.js";
|
|
3
3
|
import { emitChatFirstOpenApp, emitChatFirstOpenBrowser, } from "../chat-first-state.js";
|
|
4
4
|
import { decideAfterStreamClosed, runOutcomeForCode, } from "./run-outcome.js";
|
|
5
5
|
function isTerminalRunStatus(status) {
|
|
6
6
|
return (status === "completed" || status === "failed" || status === "cancelled");
|
|
7
7
|
}
|
|
8
|
-
const TOOL_RESULT_MEDIA_TYPE = "application/x-agent-native-tool-result";
|
|
9
|
-
const TOOL_CALL_MEDIA_TYPE = "application/x-agent-native-tool-call";
|
|
10
8
|
const RUNTIME_PART_MEDIA_TYPE = "application/x-agent-native-runtime-part";
|
|
11
9
|
const RUNTIME_EVENT_TYPE = "x-core.runtime-event";
|
|
12
10
|
const RUNTIME_USAGE_EVENT_TYPE = "x-core.usage";
|
|
@@ -209,6 +207,16 @@ function runtimeEventMessageId(run, ...metadata) {
|
|
|
209
207
|
}
|
|
210
208
|
return run.activeMessageCompleted ? undefined : run.activeMessageId;
|
|
211
209
|
}
|
|
210
|
+
function runtimeToolMessageId(run, ...metadata) {
|
|
211
|
+
for (const value of metadata) {
|
|
212
|
+
const messageId = metadataString(value, "messageId");
|
|
213
|
+
if (messageId)
|
|
214
|
+
return messageId;
|
|
215
|
+
}
|
|
216
|
+
return run.activeMessageRole === "assistant"
|
|
217
|
+
? runtimeEventMessageId(run)
|
|
218
|
+
: undefined;
|
|
219
|
+
}
|
|
212
220
|
function runtimeAnnotationToProtocol(annotation) {
|
|
213
221
|
return {
|
|
214
222
|
id: annotation.id,
|
|
@@ -423,7 +431,7 @@ function runtimePartToProtocolPart(part, fallbackTextFormat) {
|
|
|
423
431
|
case "tool-call":
|
|
424
432
|
return {
|
|
425
433
|
type: "data",
|
|
426
|
-
mediaType:
|
|
434
|
+
mediaType: AGENT_TOOL_CALL_HISTORY_MEDIA_TYPE,
|
|
427
435
|
data: {
|
|
428
436
|
id: part.toolCallId,
|
|
429
437
|
name: part.toolName,
|
|
@@ -434,7 +442,7 @@ function runtimePartToProtocolPart(part, fallbackTextFormat) {
|
|
|
434
442
|
case "tool-result":
|
|
435
443
|
return {
|
|
436
444
|
type: "data",
|
|
437
|
-
mediaType:
|
|
445
|
+
mediaType: AGENT_TOOL_RESULT_HISTORY_MEDIA_TYPE,
|
|
438
446
|
data: {
|
|
439
447
|
id: part.toolCallId,
|
|
440
448
|
name: part.toolName,
|
|
@@ -485,6 +493,43 @@ function protocolPartToRuntimePart(part) {
|
|
|
485
493
|
mediaType: part.mediaType,
|
|
486
494
|
url: part.url,
|
|
487
495
|
};
|
|
496
|
+
case "data": {
|
|
497
|
+
const data = asRecord(part.data);
|
|
498
|
+
if (part.mediaType === AGENT_TOOL_CALL_HISTORY_MEDIA_TYPE) {
|
|
499
|
+
if (typeof data?.id !== "string" || typeof data.name !== "string") {
|
|
500
|
+
throw new AgentProtocolValidationError("message.parts.data", "tool call history requires a call id and name");
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
type: "tool-call",
|
|
504
|
+
toolCallId: data.id,
|
|
505
|
+
toolName: data.name,
|
|
506
|
+
...(data.input === undefined ? {} : { input: data.input }),
|
|
507
|
+
...(typeof data.inputText === "string"
|
|
508
|
+
? { inputText: data.inputText }
|
|
509
|
+
: {}),
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
if (part.mediaType === AGENT_TOOL_RESULT_HISTORY_MEDIA_TYPE) {
|
|
513
|
+
if (typeof data?.id !== "string") {
|
|
514
|
+
throw new AgentProtocolValidationError("message.parts.data", "tool result history requires a call id");
|
|
515
|
+
}
|
|
516
|
+
return {
|
|
517
|
+
type: "tool-result",
|
|
518
|
+
toolCallId: data.id,
|
|
519
|
+
...(typeof data.name === "string" ? { toolName: data.name } : {}),
|
|
520
|
+
...(data.result === undefined ? {} : { result: data.result }),
|
|
521
|
+
...(typeof data.resultText === "string"
|
|
522
|
+
? { resultText: data.resultText }
|
|
523
|
+
: {}),
|
|
524
|
+
...(data.isError === true ? { isError: true } : {}),
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
return {
|
|
528
|
+
type: "data",
|
|
529
|
+
data: part,
|
|
530
|
+
mediaType: "application/x-agentkit-protocol-part",
|
|
531
|
+
};
|
|
532
|
+
}
|
|
488
533
|
default:
|
|
489
534
|
return {
|
|
490
535
|
type: "data",
|
|
@@ -604,7 +649,7 @@ function actionResultFromTool(input) {
|
|
|
604
649
|
...(input.metadata ? { metadata: input.metadata } : {}),
|
|
605
650
|
};
|
|
606
651
|
}
|
|
607
|
-
function runtimeToolToProtocolTool(tool, status = "running", result, error) {
|
|
652
|
+
function runtimeToolToProtocolTool(tool, status = "running", result, error, messageId) {
|
|
608
653
|
return {
|
|
609
654
|
id: tool.id,
|
|
610
655
|
name: tool.name,
|
|
@@ -612,6 +657,7 @@ function runtimeToolToProtocolTool(tool, status = "running", result, error) {
|
|
|
612
657
|
status,
|
|
613
658
|
output: result,
|
|
614
659
|
error,
|
|
660
|
+
...(messageId ? { messageId } : {}),
|
|
615
661
|
...(tool.metadata ? { metadata: tool.metadata } : {}),
|
|
616
662
|
};
|
|
617
663
|
}
|
|
@@ -989,6 +1035,7 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
989
1035
|
pendingWidgets: new Map(),
|
|
990
1036
|
actions: new Map(),
|
|
991
1037
|
activeTools: new Map(),
|
|
1038
|
+
pendingToolMessageAssociations: new Map(),
|
|
992
1039
|
activeActivities: new Map(),
|
|
993
1040
|
terminalAppendDepth: 0,
|
|
994
1041
|
pumpPromise: null,
|
|
@@ -1283,6 +1330,7 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1283
1330
|
});
|
|
1284
1331
|
}
|
|
1285
1332
|
}
|
|
1333
|
+
run.pendingToolMessageAssociations.clear();
|
|
1286
1334
|
}
|
|
1287
1335
|
function runtimeEventToProtocolEvents(run, event) {
|
|
1288
1336
|
dispatchChatFirstOpenFromRuntimeEvent(event);
|
|
@@ -1300,9 +1348,32 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1300
1348
|
widget,
|
|
1301
1349
|
}));
|
|
1302
1350
|
};
|
|
1351
|
+
const attachPendingToolMessageAssociations = (messageId) => {
|
|
1352
|
+
const tools = [...run.pendingToolMessageAssociations.values()];
|
|
1353
|
+
run.pendingToolMessageAssociations.clear();
|
|
1354
|
+
return tools.map((toolCall) => ({
|
|
1355
|
+
type: "tool.updated",
|
|
1356
|
+
...base,
|
|
1357
|
+
toolCall: { ...toolCall, messageId },
|
|
1358
|
+
}));
|
|
1359
|
+
};
|
|
1360
|
+
const retainPendingToolMessageAssociation = (toolCall) => {
|
|
1361
|
+
run.pendingToolMessageAssociations.delete(toolCall.id);
|
|
1362
|
+
run.pendingToolMessageAssociations.set(toolCall.id, toolCall);
|
|
1363
|
+
// Pending links use the same bound as the replay log they can be attached to.
|
|
1364
|
+
while (run.pendingToolMessageAssociations.size > maxRetainedEvents) {
|
|
1365
|
+
const oldestToolCallId = run.pendingToolMessageAssociations
|
|
1366
|
+
.keys()
|
|
1367
|
+
.next().value;
|
|
1368
|
+
if (oldestToolCallId === undefined)
|
|
1369
|
+
break;
|
|
1370
|
+
run.pendingToolMessageAssociations.delete(oldestToolCallId);
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1303
1373
|
switch (event.type) {
|
|
1304
1374
|
case "message-start":
|
|
1305
1375
|
run.activeMessageId = event.message.id;
|
|
1376
|
+
run.activeMessageRole = event.message.role;
|
|
1306
1377
|
run.activeMessageCompleted = false;
|
|
1307
1378
|
return [
|
|
1308
1379
|
{
|
|
@@ -1311,8 +1382,14 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1311
1382
|
message: runtimeMessageToProtocolMessage(event.message, textFormat),
|
|
1312
1383
|
},
|
|
1313
1384
|
...attachPendingWidgets(event.message.id),
|
|
1385
|
+
...(event.message.role === "assistant"
|
|
1386
|
+
? attachPendingToolMessageAssociations(event.message.id)
|
|
1387
|
+
: []),
|
|
1314
1388
|
];
|
|
1315
1389
|
case "message-delta":
|
|
1390
|
+
if (run.activeMessageId !== event.messageId) {
|
|
1391
|
+
run.activeMessageRole = undefined;
|
|
1392
|
+
}
|
|
1316
1393
|
run.activeMessageId = event.messageId;
|
|
1317
1394
|
run.activeMessageCompleted = false;
|
|
1318
1395
|
if (event.delta.type === "text") {
|
|
@@ -1353,6 +1430,7 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1353
1430
|
];
|
|
1354
1431
|
case "message-done":
|
|
1355
1432
|
run.activeMessageId = event.message.id;
|
|
1433
|
+
run.activeMessageRole = event.message.role;
|
|
1356
1434
|
run.activeMessageCompleted = true;
|
|
1357
1435
|
return [
|
|
1358
1436
|
{
|
|
@@ -1361,18 +1439,29 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1361
1439
|
message: runtimeMessageToProtocolMessage(event.message, textFormat),
|
|
1362
1440
|
},
|
|
1363
1441
|
...attachPendingWidgets(event.message.id),
|
|
1442
|
+
...(event.message.role === "assistant"
|
|
1443
|
+
? attachPendingToolMessageAssociations(event.message.id)
|
|
1444
|
+
: []),
|
|
1364
1445
|
];
|
|
1365
1446
|
case "tool-start": {
|
|
1366
1447
|
const metadata = mergeProtocolMetadata(base.metadata, event.toolCall.metadata);
|
|
1367
1448
|
const invocation = actionInvocationFromTool(run, event.toolCall, metadata);
|
|
1368
1449
|
if (invocation)
|
|
1369
1450
|
run.actions.set(event.toolCall.id, invocation);
|
|
1451
|
+
const messageId = runtimeToolMessageId(run, event.toolCall.metadata);
|
|
1452
|
+
const toolCall = runtimeToolToProtocolTool(event.toolCall, "running", undefined, undefined, messageId);
|
|
1453
|
+
if (messageId) {
|
|
1454
|
+
run.pendingToolMessageAssociations.delete(toolCall.id);
|
|
1455
|
+
}
|
|
1456
|
+
else {
|
|
1457
|
+
retainPendingToolMessageAssociation(toolCall);
|
|
1458
|
+
}
|
|
1370
1459
|
return [
|
|
1371
1460
|
{
|
|
1372
1461
|
type: "tool.started",
|
|
1373
1462
|
...base,
|
|
1374
1463
|
metadata,
|
|
1375
|
-
toolCall
|
|
1464
|
+
toolCall,
|
|
1376
1465
|
},
|
|
1377
1466
|
...(invocation
|
|
1378
1467
|
? [
|
|
@@ -1436,20 +1525,34 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1436
1525
|
if (invocation)
|
|
1437
1526
|
run.actions.delete(event.toolCallId);
|
|
1438
1527
|
const activeTool = run.activeTools.get(event.toolCallId);
|
|
1528
|
+
const explicitMessageId = metadataString(event.metadata, "messageId");
|
|
1529
|
+
const messageId = activeTool?.messageId ??
|
|
1530
|
+
explicitMessageId ??
|
|
1531
|
+
(run.pendingToolMessageAssociations.has(event.toolCallId)
|
|
1532
|
+
? undefined
|
|
1533
|
+
: runtimeToolMessageId(run, event.metadata));
|
|
1534
|
+
const toolCall = {
|
|
1535
|
+
...activeTool,
|
|
1536
|
+
id: event.toolCallId,
|
|
1537
|
+
name: event.toolName,
|
|
1538
|
+
status,
|
|
1539
|
+
output: event.result !== undefined ? event.result : event.resultText,
|
|
1540
|
+
error,
|
|
1541
|
+
...(messageId ? { messageId } : {}),
|
|
1542
|
+
...(metadata ? { metadata } : {}),
|
|
1543
|
+
};
|
|
1544
|
+
if (messageId) {
|
|
1545
|
+
run.pendingToolMessageAssociations.delete(event.toolCallId);
|
|
1546
|
+
}
|
|
1547
|
+
else if (run.pendingToolMessageAssociations.has(event.toolCallId)) {
|
|
1548
|
+
retainPendingToolMessageAssociation(toolCall);
|
|
1549
|
+
}
|
|
1439
1550
|
return [
|
|
1440
1551
|
{
|
|
1441
1552
|
type: "tool.updated",
|
|
1442
1553
|
...base,
|
|
1443
1554
|
metadata,
|
|
1444
|
-
toolCall
|
|
1445
|
-
...activeTool,
|
|
1446
|
-
id: event.toolCallId,
|
|
1447
|
-
name: event.toolName,
|
|
1448
|
-
status,
|
|
1449
|
-
output: event.result !== undefined ? event.result : event.resultText,
|
|
1450
|
-
error,
|
|
1451
|
-
...(metadata ? { metadata } : {}),
|
|
1452
|
-
},
|
|
1555
|
+
toolCall,
|
|
1453
1556
|
},
|
|
1454
1557
|
...(actionResult
|
|
1455
1558
|
? [
|
|
@@ -2456,6 +2559,7 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
2456
2559
|
pendingWidgets: new Map(),
|
|
2457
2560
|
actions: new Map(),
|
|
2458
2561
|
activeTools: new Map(),
|
|
2562
|
+
pendingToolMessageAssociations: new Map(),
|
|
2459
2563
|
activeActivities: new Map(),
|
|
2460
2564
|
terminalAppendDepth: 0,
|
|
2461
2565
|
pumpPromise: null,
|
|
@@ -2772,10 +2876,12 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
2772
2876
|
activeReaders: 0,
|
|
2773
2877
|
metadata: replacementMetadata,
|
|
2774
2878
|
activeMessageId: run.activeMessageId,
|
|
2879
|
+
activeMessageRole: run.activeMessageRole,
|
|
2775
2880
|
activeMessageCompleted: run.activeMessageCompleted,
|
|
2776
2881
|
pendingWidgets: new Map(run.pendingWidgets),
|
|
2777
2882
|
actions: new Map(run.actions),
|
|
2778
2883
|
activeTools: new Map(run.activeTools),
|
|
2884
|
+
pendingToolMessageAssociations: new Map(run.pendingToolMessageAssociations),
|
|
2779
2885
|
activeActivities: new Map(run.activeActivities),
|
|
2780
2886
|
terminalAppendDepth: 0,
|
|
2781
2887
|
pumpPromise: null,
|