@agent-native/core 0.35.0 → 0.35.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/README.md +1 -1
- package/dist/cli/context-xray-local.d.ts +2 -2
- package/dist/cli/context-xray-local.d.ts.map +1 -1
- package/dist/cli/context-xray-local.js +1449 -53
- package/dist/cli/context-xray-local.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +1 -0
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +226 -78
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +8 -4
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +5 -11
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +6 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +33 -5
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +63 -3
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat.d.ts +39 -3
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +168 -33
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/application-state.d.ts +13 -0
- package/dist/client/application-state.d.ts.map +1 -0
- package/dist/client/application-state.js +99 -0
- package/dist/client/application-state.js.map +1 -0
- package/dist/client/frame-protocol.d.ts +11 -3
- package/dist/client/frame-protocol.d.ts.map +1 -1
- package/dist/client/frame-protocol.js.map +1 -1
- package/dist/client/index.d.ts +4 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts +1 -0
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +50 -16
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/use-action.d.ts +12 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +14 -2
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-agent-chat-context.d.ts +15 -0
- package/dist/client/use-agent-chat-context.d.ts.map +1 -0
- package/dist/client/use-agent-chat-context.js +32 -0
- package/dist/client/use-agent-chat-context.js.map +1 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +1 -2
- package/dist/deploy/build.js.map +1 -1
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +4 -2
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +33 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +14 -6
- package/dist/provider-api/index.js.map +1 -1
- package/dist/server/agent-teams.d.ts +4 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +104 -28
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +21 -11
- package/dist/server/auth.js.map +1 -1
- package/dist/server/request-context.d.ts +3 -4
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/self-dispatch.d.ts.map +1 -1
- package/dist/server/self-dispatch.js +17 -1
- package/dist/server/self-dispatch.js.map +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +9 -18
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/templates/default/AGENTS.md +1 -1
- package/dist/templates/default/DEVELOPING.md +7 -13
- package/dist/templates/default/package.json +3 -3
- package/dist/templates/workspace-core/AGENTS.md +6 -4
- package/dist/templates/workspace-root/AGENTS.md +6 -4
- package/docs/content/actions.md +5 -7
- package/docs/content/client.md +49 -44
- package/docs/content/context-awareness.md +20 -33
- package/docs/content/creating-templates.md +2 -2
- package/docs/content/key-concepts.md +3 -3
- package/docs/content/sharing.md +1 -1
- package/docs/content/template-mail.md +1 -1
- package/docs/content/voice-input.md +1 -1
- package/package.json +11 -7
- package/src/templates/default/AGENTS.md +1 -1
- package/src/templates/default/DEVELOPING.md +7 -13
- package/src/templates/default/package.json +3 -3
- package/src/templates/workspace-core/AGENTS.md +6 -4
- package/src/templates/workspace-root/AGENTS.md +6 -4
|
@@ -240,6 +240,11 @@ async function failReconciledTask(task, ownerEmail, message, progressStatus = "f
|
|
|
240
240
|
await completeAgentTeamRun(task.taskId, "failed").catch(() => { });
|
|
241
241
|
return task;
|
|
242
242
|
}
|
|
243
|
+
function subAgentDispatchFailureMessage(err) {
|
|
244
|
+
return err instanceof Error
|
|
245
|
+
? `Failed to start sub-agent: ${err.message}`
|
|
246
|
+
: "Failed to start sub-agent.";
|
|
247
|
+
}
|
|
243
248
|
/**
|
|
244
249
|
* Re-fire a dropped self-dispatch. When the queue row is still queued/running
|
|
245
250
|
* but its heartbeat has gone stale (the self-fire never landed, or the
|
|
@@ -262,8 +267,8 @@ async function refireStuckAgentTeamRunIfNeeded(task, dispatch, event) {
|
|
|
262
267
|
body: { mode: dispatch.continuationCount > 0 ? "continue" : "start" },
|
|
263
268
|
});
|
|
264
269
|
}
|
|
265
|
-
catch {
|
|
266
|
-
|
|
270
|
+
catch (err) {
|
|
271
|
+
await failReconciledTask(task, dispatch.ownerEmail, subAgentDispatchFailureMessage(err));
|
|
267
272
|
}
|
|
268
273
|
}
|
|
269
274
|
/**
|
|
@@ -362,10 +367,42 @@ function generateTaskId() {
|
|
|
362
367
|
function taskRunId(taskId) {
|
|
363
368
|
return `run-task-${taskId}`;
|
|
364
369
|
}
|
|
370
|
+
function taskRunChunkId(taskId, chunk) {
|
|
371
|
+
return `${taskRunId(taskId)}-c${chunk}`;
|
|
372
|
+
}
|
|
365
373
|
function taskIdFromBackgroundRunId(runId) {
|
|
366
|
-
|
|
374
|
+
const taskId = runId.startsWith("run-task-")
|
|
367
375
|
? runId.slice("run-task-".length)
|
|
368
376
|
: runId;
|
|
377
|
+
const chunkTaskId = taskId.match(/^(.*)-c\d+$/)?.[1];
|
|
378
|
+
// Public background run ids are stable base ids. Only strip a chunk suffix
|
|
379
|
+
// when the caller passed a live run-manager chunk id.
|
|
380
|
+
return chunkTaskId && getRun(runId)?.status === "running"
|
|
381
|
+
? chunkTaskId
|
|
382
|
+
: taskId;
|
|
383
|
+
}
|
|
384
|
+
function runningInMemoryTaskRunId(taskId) {
|
|
385
|
+
const baseRunId = taskRunId(taskId);
|
|
386
|
+
for (let i = MAX_AGENT_TEAM_CONTINUATIONS; i >= 0; i -= 1) {
|
|
387
|
+
const chunkRunId = taskRunChunkId(taskId, i);
|
|
388
|
+
if (getRun(chunkRunId)?.status === "running")
|
|
389
|
+
return chunkRunId;
|
|
390
|
+
}
|
|
391
|
+
if (getRun(baseRunId)?.status === "running")
|
|
392
|
+
return baseRunId;
|
|
393
|
+
return baseRunId;
|
|
394
|
+
}
|
|
395
|
+
async function durableActiveTaskRunId(taskId) {
|
|
396
|
+
try {
|
|
397
|
+
const dispatch = await getAgentTeamRunDispatchState(taskId);
|
|
398
|
+
if (dispatch?.status === "queued" || dispatch?.status === "running") {
|
|
399
|
+
return taskRunChunkId(taskId, dispatch.continuationCount);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
// Fall back to in-memory state if queue state is temporarily unavailable.
|
|
404
|
+
}
|
|
405
|
+
return runningInMemoryTaskRunId(taskId);
|
|
369
406
|
}
|
|
370
407
|
function mapTaskStatusToBackgroundStatus(status) {
|
|
371
408
|
return status;
|
|
@@ -620,24 +657,33 @@ function summarizeAgentChatEvent(event) {
|
|
|
620
657
|
return null;
|
|
621
658
|
}
|
|
622
659
|
}
|
|
623
|
-
export function toAgentTaskBackgroundTranscriptEvent(runId, event) {
|
|
660
|
+
export function toAgentTaskBackgroundTranscriptEvent(runId, event, options = {}) {
|
|
624
661
|
const summary = summarizeAgentChatEvent(event);
|
|
625
662
|
if (!summary)
|
|
626
663
|
return null;
|
|
664
|
+
const sourceRunId = options.sourceRunId ?? runId;
|
|
665
|
+
const eventId = `${sourceRunId}:${event.seq}`;
|
|
666
|
+
const seq = options.seq ?? event.seq;
|
|
667
|
+
const metadata = {
|
|
668
|
+
...(summary.metadata ?? {}),
|
|
669
|
+
seq,
|
|
670
|
+
sourceSeq: event.seq,
|
|
671
|
+
...(sourceRunId === runId ? {} : { sourceRunId }),
|
|
672
|
+
};
|
|
627
673
|
return {
|
|
628
674
|
schemaVersion: 1,
|
|
629
|
-
id:
|
|
675
|
+
id: eventId,
|
|
630
676
|
runId,
|
|
631
677
|
kind: summary.kind,
|
|
632
678
|
source: "hosted-agent-team",
|
|
633
679
|
sourceRecord: {
|
|
634
680
|
type: "agent-team-run-event",
|
|
635
|
-
id:
|
|
636
|
-
seq
|
|
681
|
+
id: eventId,
|
|
682
|
+
seq,
|
|
637
683
|
},
|
|
638
684
|
message: summary.message,
|
|
639
685
|
createdAt: new Date().toISOString(),
|
|
640
|
-
metadata
|
|
686
|
+
metadata,
|
|
641
687
|
};
|
|
642
688
|
}
|
|
643
689
|
/**
|
|
@@ -749,10 +795,7 @@ export async function spawnTask(opts) {
|
|
|
749
795
|
// Enqueue/dispatch failed outright — surface as an errored task rather
|
|
750
796
|
// than a ghost "running" one. (A dropped self-fire that still enqueued is
|
|
751
797
|
// recovered by the reconcile stuck-refire path.)
|
|
752
|
-
|
|
753
|
-
? `Failed to start sub-agent: ${err.message}`
|
|
754
|
-
: "Failed to start sub-agent.";
|
|
755
|
-
await failReconciledTask(task, opts.ownerEmail, message);
|
|
798
|
+
await failReconciledTask(task, opts.ownerEmail, subAgentDispatchFailureMessage(err));
|
|
756
799
|
}
|
|
757
800
|
return task;
|
|
758
801
|
}
|
|
@@ -998,12 +1041,17 @@ export async function processAgentTeamRun(opts) {
|
|
|
998
1041
|
await saveTask(task);
|
|
999
1042
|
if (ownerEmail)
|
|
1000
1043
|
await updateTaskProgressRun(task, ownerEmail);
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1044
|
+
try {
|
|
1045
|
+
await fireInternalDispatch({
|
|
1046
|
+
event: opts.event,
|
|
1047
|
+
path: AGENT_TEAM_PROCESS_RUN_PATH,
|
|
1048
|
+
taskId: opts.taskId,
|
|
1049
|
+
body: { mode: "continue" },
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
catch (err) {
|
|
1053
|
+
await failReconciledTask(task, ownerEmail || null, subAgentDispatchFailureMessage(err));
|
|
1054
|
+
}
|
|
1007
1055
|
return;
|
|
1008
1056
|
}
|
|
1009
1057
|
// Hit the cap — finalize with whatever was produced.
|
|
@@ -1046,17 +1094,44 @@ export async function getAgentTeamBackgroundRun(runId) {
|
|
|
1046
1094
|
: null;
|
|
1047
1095
|
}
|
|
1048
1096
|
export async function listAgentTeamBackgroundTranscriptEvents(runId) {
|
|
1049
|
-
const
|
|
1050
|
-
const
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1097
|
+
const taskId = taskIdFromBackgroundRunId(runId);
|
|
1098
|
+
const normalizedRunId = taskRunId(taskId);
|
|
1099
|
+
const runIds = await transcriptRunIdsForTask(taskId);
|
|
1100
|
+
const output = [];
|
|
1101
|
+
let seq = 0;
|
|
1102
|
+
for (const sourceRunId of runIds) {
|
|
1103
|
+
const activeRun = getRun(sourceRunId);
|
|
1104
|
+
const events = activeRun
|
|
1105
|
+
? activeRun.events
|
|
1106
|
+
: await getPersistedRunEvents(sourceRunId);
|
|
1107
|
+
for (const event of events) {
|
|
1108
|
+
const transcriptEvent = toAgentTaskBackgroundTranscriptEvent(normalizedRunId, event, { seq, sourceRunId });
|
|
1109
|
+
if (transcriptEvent) {
|
|
1110
|
+
output.push(transcriptEvent);
|
|
1111
|
+
seq += 1;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return output;
|
|
1057
1116
|
}
|
|
1058
1117
|
export function subscribeToAgentTeamBackgroundRun(runId, fromSeq = 0) {
|
|
1059
|
-
return subscribeToRun(
|
|
1118
|
+
return subscribeToRun(runningInMemoryTaskRunId(taskIdFromBackgroundRunId(runId)), fromSeq);
|
|
1119
|
+
}
|
|
1120
|
+
async function transcriptRunIdsForTask(taskId) {
|
|
1121
|
+
const baseRunId = taskRunId(taskId);
|
|
1122
|
+
let continuationCount = 0;
|
|
1123
|
+
try {
|
|
1124
|
+
continuationCount =
|
|
1125
|
+
(await getAgentTeamRunDispatchState(taskId))?.continuationCount ?? 0;
|
|
1126
|
+
}
|
|
1127
|
+
catch {
|
|
1128
|
+
continuationCount = 0;
|
|
1129
|
+
}
|
|
1130
|
+
const ids = [baseRunId];
|
|
1131
|
+
for (let i = 0; i <= continuationCount; i += 1) {
|
|
1132
|
+
ids.push(taskRunChunkId(taskId, i));
|
|
1133
|
+
}
|
|
1134
|
+
return ids;
|
|
1060
1135
|
}
|
|
1061
1136
|
async function getPersistedRunEvents(runId) {
|
|
1062
1137
|
const rows = await getRunEventsSince(runId, 0);
|
|
@@ -1149,7 +1224,7 @@ export async function stopAgentTeamBackgroundRun(runId, reason = "user") {
|
|
|
1149
1224
|
if (task.status !== "running") {
|
|
1150
1225
|
return { ok: false, error: "Task is not running" };
|
|
1151
1226
|
}
|
|
1152
|
-
abortRun(
|
|
1227
|
+
abortRun(await durableActiveTaskRunId(taskId), reason);
|
|
1153
1228
|
task.status = "errored";
|
|
1154
1229
|
task.summary =
|
|
1155
1230
|
reason === "user" ? "Task stopped." : `Task stopped: ${reason}`;
|
|
@@ -1161,6 +1236,7 @@ export async function stopAgentTeamBackgroundRun(runId, reason = "user") {
|
|
|
1161
1236
|
if (ownerEmail) {
|
|
1162
1237
|
await completeTaskProgressRun(task, ownerEmail, "cancelled", task.summary);
|
|
1163
1238
|
}
|
|
1239
|
+
await completeAgentTeamRun(task.taskId, "failed");
|
|
1164
1240
|
return { ok: true };
|
|
1165
1241
|
}
|
|
1166
1242
|
/** Mark a task as errored */
|