@gea-ai/agent-sdk 0.1.261016-alpha.1 → 0.1.261019-alpha.1
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-core.wasm +0 -0
- package/dist/agent-session-execution.d.ts +44 -0
- package/dist/agent-session-execution.js +18 -0
- package/dist/agent-session-inbox.d.ts +1 -0
- package/dist/agent-session-inbox.js +5 -0
- package/dist/agent-session-stale-run.d.ts +22 -0
- package/dist/agent-worker.d.ts +4 -0
- package/dist/agent-worker.js +256 -53
- package/dist/experimental/agent-core-worker-tools.js +12 -0
- package/dist/host-rejection.d.ts +23 -0
- package/dist/host-rejection.js +39 -1
- package/dist/host-tool-error.d.ts +7 -0
- package/dist/host-tool-error.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/runtime-selected-connector-tool.d.ts +34 -0
- package/dist/runtime-selected-connector-tool.js +40 -0
- package/dist/runtime-team-skill-tools.d.ts +1104 -0
- package/dist/runtime-team-skill-tools.js +31 -0
- package/dist/session-authority.d.ts +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/agent-core.wasm
CHANGED
|
Binary file
|
|
@@ -46,7 +46,29 @@ export declare function completeAgentSessionInvocation(tx: AgentSessionTransacti
|
|
|
46
46
|
status: "aborted" | "completed" | "failed";
|
|
47
47
|
occurredAt: string;
|
|
48
48
|
usage: import("ai").LanguageModelUsage | null;
|
|
49
|
+
termination?: {
|
|
50
|
+
finishReason?: "length" | "stop" | "tool_calls" | undefined;
|
|
51
|
+
provider?: {
|
|
52
|
+
format: "openai-completions";
|
|
53
|
+
reason: "length" | "stop" | "tool_calls";
|
|
54
|
+
} | {
|
|
55
|
+
format: "anthropic-messages";
|
|
56
|
+
reason: "end_turn" | "max_tokens" | "refusal" | "stop_sequence" | "tool_use";
|
|
57
|
+
} | {
|
|
58
|
+
format: "openai-responses";
|
|
59
|
+
reason: "completed" | "max_output_tokens";
|
|
60
|
+
} | undefined;
|
|
61
|
+
step?: number | undefined;
|
|
62
|
+
attempt?: number | undefined;
|
|
63
|
+
sessionAttemptId?: string | undefined;
|
|
64
|
+
requestId?: string | undefined;
|
|
65
|
+
} | undefined;
|
|
49
66
|
}[] | undefined;
|
|
67
|
+
diagnostics?: {
|
|
68
|
+
coreReason: "awaiting_approval" | "awaiting_tool_results" | "cancelled" | "completed" | "failed" | "model_limit" | "step_limit" | "stopped";
|
|
69
|
+
maxSteps?: number | undefined;
|
|
70
|
+
maxRetries?: number | undefined;
|
|
71
|
+
} | undefined;
|
|
50
72
|
attempt: number;
|
|
51
73
|
completedAt: string;
|
|
52
74
|
status: "aborted" | "error" | "finished" | "interrupted";
|
|
@@ -76,7 +98,29 @@ export declare function reclaimAgentSessionRun(tx: AgentSessionTransactionStorag
|
|
|
76
98
|
status: "aborted" | "completed" | "failed";
|
|
77
99
|
occurredAt: string;
|
|
78
100
|
usage: import("ai").LanguageModelUsage | null;
|
|
101
|
+
termination?: {
|
|
102
|
+
finishReason?: "length" | "stop" | "tool_calls" | undefined;
|
|
103
|
+
provider?: {
|
|
104
|
+
format: "openai-completions";
|
|
105
|
+
reason: "length" | "stop" | "tool_calls";
|
|
106
|
+
} | {
|
|
107
|
+
format: "anthropic-messages";
|
|
108
|
+
reason: "end_turn" | "max_tokens" | "refusal" | "stop_sequence" | "tool_use";
|
|
109
|
+
} | {
|
|
110
|
+
format: "openai-responses";
|
|
111
|
+
reason: "completed" | "max_output_tokens";
|
|
112
|
+
} | undefined;
|
|
113
|
+
step?: number | undefined;
|
|
114
|
+
attempt?: number | undefined;
|
|
115
|
+
sessionAttemptId?: string | undefined;
|
|
116
|
+
requestId?: string | undefined;
|
|
117
|
+
} | undefined;
|
|
79
118
|
}[] | undefined;
|
|
119
|
+
diagnostics?: {
|
|
120
|
+
coreReason: "awaiting_approval" | "awaiting_tool_results" | "cancelled" | "completed" | "failed" | "model_limit" | "step_limit" | "stopped";
|
|
121
|
+
maxSteps?: number | undefined;
|
|
122
|
+
maxRetries?: number | undefined;
|
|
123
|
+
} | undefined;
|
|
80
124
|
attempt: number;
|
|
81
125
|
completedAt: string;
|
|
82
126
|
status: "aborted" | "error" | "finished" | "interrupted";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { agentExecutionDiagnosticsSchema, } from "@gea-ai/contract/agent-usage";
|
|
1
2
|
import { digestAgentSessionMessage } from "./agent-session-transport.js";
|
|
2
3
|
import { getSessionPayload, putSessionPayload } from "./agent-session-payload.js";
|
|
3
4
|
import { agentModelCallsSchema, } from "@gea-ai/contract/agent-usage";
|
|
@@ -164,6 +165,8 @@ export async function appendAgentSessionInputMessages(tx, messages, runId) {
|
|
|
164
165
|
await advanceRevision(tx);
|
|
165
166
|
}
|
|
166
167
|
async function writeValues(tx, input) {
|
|
168
|
+
if (input.diagnostics !== undefined)
|
|
169
|
+
await tx.put(key(`diagnostics:${encodeURIComponent(input.runId)}:${encodeURIComponent(input.attemptId)}`), agentExecutionDiagnosticsSchema.parse(input.diagnostics));
|
|
167
170
|
for (const output of input.toolOutputs ?? [])
|
|
168
171
|
await putSessionPayload(tx, `tool-output:${output.id}`, output.content);
|
|
169
172
|
let messageSequence = (await tx.get(key("message-sequence"))) ?? 0;
|
|
@@ -352,6 +355,7 @@ export async function completeAgentSessionInvocation(tx, input) {
|
|
|
352
355
|
input.events.length === 0 &&
|
|
353
356
|
!input.context &&
|
|
354
357
|
input.modelCalls === undefined &&
|
|
358
|
+
input.diagnostics === undefined &&
|
|
355
359
|
input.toolOutputs === undefined;
|
|
356
360
|
const state = await getAgentSessionRunState(tx, input.runId);
|
|
357
361
|
if (state?.status === "draining")
|
|
@@ -375,6 +379,7 @@ export async function completeAgentSessionInvocation(tx, input) {
|
|
|
375
379
|
input.events.length === 0 &&
|
|
376
380
|
input.context === undefined &&
|
|
377
381
|
input.modelCalls === undefined &&
|
|
382
|
+
input.diagnostics === undefined &&
|
|
378
383
|
input.toolOutputs === undefined &&
|
|
379
384
|
input.accounting === undefined;
|
|
380
385
|
// Cancelling a waiting turn closes it directly: pausing already revoked its
|
|
@@ -386,6 +391,7 @@ export async function completeAgentSessionInvocation(tx, input) {
|
|
|
386
391
|
input.events.length === 0 &&
|
|
387
392
|
!input.context &&
|
|
388
393
|
input.modelCalls === undefined &&
|
|
394
|
+
input.diagnostics === undefined &&
|
|
389
395
|
input.toolOutputs === undefined;
|
|
390
396
|
const turn = state?.status === "terminal" &&
|
|
391
397
|
waiting &&
|
|
@@ -402,7 +408,11 @@ export async function completeAgentSessionInvocation(tx, input) {
|
|
|
402
408
|
const previousRevision = await readRevision(tx);
|
|
403
409
|
await writeValues(tx, input);
|
|
404
410
|
const modelCalls = await tx.get(key(`model-calls:${encodeURIComponent(input.runId)}`));
|
|
411
|
+
const diagnostics = await tx.get(key(`diagnostics:${encodeURIComponent(input.runId)}:${encodeURIComponent(input.attemptId)}`));
|
|
405
412
|
const outcome = {
|
|
413
|
+
...(diagnostics === undefined
|
|
414
|
+
? {}
|
|
415
|
+
: { diagnostics: agentExecutionDiagnosticsSchema.parse(diagnostics) }),
|
|
406
416
|
...(modelCalls === undefined
|
|
407
417
|
? {}
|
|
408
418
|
: { modelCalls: agentModelCallsSchema.parse(modelCalls) }),
|
|
@@ -918,6 +928,7 @@ export async function handleAgentSessionExecutionRequest(request, storage) {
|
|
|
918
928
|
input.events.length === 0 &&
|
|
919
929
|
!input.context &&
|
|
920
930
|
input.modelCalls === undefined &&
|
|
931
|
+
input.diagnostics === undefined &&
|
|
921
932
|
input.toolOutputs === undefined;
|
|
922
933
|
const state = await getAgentSessionRunState(tx, input.runId);
|
|
923
934
|
if (state?.status === "draining")
|
|
@@ -943,6 +954,7 @@ export async function handleAgentSessionExecutionRequest(request, storage) {
|
|
|
943
954
|
input.events.length === 0 &&
|
|
944
955
|
input.context === undefined &&
|
|
945
956
|
input.modelCalls === undefined &&
|
|
957
|
+
input.diagnostics === undefined &&
|
|
946
958
|
input.toolOutputs === undefined &&
|
|
947
959
|
input.accounting === undefined;
|
|
948
960
|
const turn = state?.status === "terminal" &&
|
|
@@ -960,7 +972,13 @@ export async function handleAgentSessionExecutionRequest(request, storage) {
|
|
|
960
972
|
const previousRevision = await readRevision(tx);
|
|
961
973
|
await writeValues(tx, stored ? { ...input, messages: [] } : input);
|
|
962
974
|
const modelCalls = await tx.get(key(`model-calls:${encodeURIComponent(input.runId)}`));
|
|
975
|
+
const diagnostics = await tx.get(key(`diagnostics:${encodeURIComponent(input.runId)}:${encodeURIComponent(input.attemptId)}`));
|
|
963
976
|
const outcome = {
|
|
977
|
+
...(diagnostics === undefined
|
|
978
|
+
? {}
|
|
979
|
+
: {
|
|
980
|
+
diagnostics: agentExecutionDiagnosticsSchema.parse(diagnostics),
|
|
981
|
+
}),
|
|
964
982
|
...(modelCalls === undefined
|
|
965
983
|
? {}
|
|
966
984
|
: { modelCalls: agentModelCallsSchema.parse(modelCalls) }),
|
|
@@ -124,6 +124,7 @@ export declare function getAppServerSessionAdmission(tx: AgentSessionTransaction
|
|
|
124
124
|
turnId: string;
|
|
125
125
|
metadata?: Record<string, z.util.JSONType> | undefined;
|
|
126
126
|
messages: {
|
|
127
|
+
runtimeResourceSourceRunId?: string | undefined;
|
|
127
128
|
id: string;
|
|
128
129
|
runId?: string | undefined;
|
|
129
130
|
sender: {
|
|
@@ -342,6 +342,11 @@ function takeMessages(state, steeringOnly) {
|
|
|
342
342
|
for (const entry of state.messages) {
|
|
343
343
|
if (steeringOnly && entry.mode !== "steering")
|
|
344
344
|
continue;
|
|
345
|
+
if (!steeringOnly &&
|
|
346
|
+
messages.length &&
|
|
347
|
+
entry.runtimeResourceSourceRunId !==
|
|
348
|
+
messages[0].runtimeResourceSourceRunId)
|
|
349
|
+
break;
|
|
345
350
|
const size = new TextEncoder().encode(JSON.stringify(entry)).byteLength;
|
|
346
351
|
const count = (typeof entry.message === "string" ? 1 : entry.message.parts.length) +
|
|
347
352
|
(entry.sender.type === "agent" ? 1 : 0);
|
|
@@ -13,7 +13,29 @@ export declare function handleStaleAgentSessionRun(storage: AgentSessionStorage,
|
|
|
13
13
|
status: "aborted" | "completed" | "failed";
|
|
14
14
|
occurredAt: string;
|
|
15
15
|
usage: import("ai").LanguageModelUsage | null;
|
|
16
|
+
termination?: {
|
|
17
|
+
finishReason?: "length" | "stop" | "tool_calls" | undefined;
|
|
18
|
+
provider?: {
|
|
19
|
+
format: "openai-completions";
|
|
20
|
+
reason: "length" | "stop" | "tool_calls";
|
|
21
|
+
} | {
|
|
22
|
+
format: "anthropic-messages";
|
|
23
|
+
reason: "end_turn" | "max_tokens" | "refusal" | "stop_sequence" | "tool_use";
|
|
24
|
+
} | {
|
|
25
|
+
format: "openai-responses";
|
|
26
|
+
reason: "completed" | "max_output_tokens";
|
|
27
|
+
} | undefined;
|
|
28
|
+
step?: number | undefined;
|
|
29
|
+
attempt?: number | undefined;
|
|
30
|
+
sessionAttemptId?: string | undefined;
|
|
31
|
+
requestId?: string | undefined;
|
|
32
|
+
} | undefined;
|
|
16
33
|
}[] | undefined;
|
|
34
|
+
diagnostics?: {
|
|
35
|
+
coreReason: "awaiting_approval" | "awaiting_tool_results" | "cancelled" | "completed" | "failed" | "model_limit" | "step_limit" | "stopped";
|
|
36
|
+
maxSteps?: number | undefined;
|
|
37
|
+
maxRetries?: number | undefined;
|
|
38
|
+
} | undefined;
|
|
17
39
|
attempt: number;
|
|
18
40
|
completedAt: string;
|
|
19
41
|
status: "aborted" | "error" | "finished" | "interrupted";
|
package/dist/agent-worker.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { extractChannelReply } from "./agent-channel-api.js";
|
|
|
7
7
|
import { type AgentInteractionPolicy } from "@gea-ai/contract";
|
|
8
8
|
import type { AgentTracing } from "@gea-ai/contract/agent-tracing";
|
|
9
9
|
import type { AgentContextStrategy } from "./context.js";
|
|
10
|
+
import { agentInitializationFailure } from "@gea-ai/contract/agent-worker-tools";
|
|
10
11
|
import { type AgentSessionInboxExecution } from "@gea-ai/contract/agent-session-inbox";
|
|
11
12
|
import type { AgentWorkerToolInitialization } from "@gea-ai/contract/agent-worker-tools";
|
|
12
13
|
import { type ComputerProcessOperation } from "@gea-ai/contract/computer-commands";
|
|
@@ -110,6 +111,9 @@ export type AgentApplicationDefinition = {
|
|
|
110
111
|
type AgentStartupTiming = {
|
|
111
112
|
startedAt: number;
|
|
112
113
|
phases: Record<string, number>;
|
|
114
|
+
failure?: ReturnType<typeof agentInitializationFailure> & {
|
|
115
|
+
phase: string;
|
|
116
|
+
};
|
|
113
117
|
};
|
|
114
118
|
export declare function composeFetch<TEnvironment, TContext>(...handlers: ReadonlyArray<ComposableFetch<TEnvironment, TContext>>): (request: Request, environment: TEnvironment, context: TContext) => Promise<Response>;
|
|
115
119
|
export declare function createAgentApplicationFetch<TEnvironment extends AgentFetchEnvironment = AgentFetchEnvironment, TContext = unknown>(input: {
|