@gea-ai/agent-sdk 0.1.261003-alpha.1 → 0.1.261004-alpha.0
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-call.d.ts +16 -16
- package/dist/agent-call.js +11 -2
- package/dist/agent-remote-run.d.ts +7 -1
- package/dist/agent-remote-run.js +35 -3
- package/dist/agent-run-host.d.ts +9 -2
- package/dist/agent-run-host.js +21 -5
- package/dist/index.d.ts +9 -6
- package/dist/index.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/agent-call.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
117
117
|
sessionId?: string | undefined;
|
|
118
118
|
message: string;
|
|
119
119
|
} | {
|
|
120
|
-
error:
|
|
120
|
+
error: string;
|
|
121
121
|
message: string;
|
|
122
122
|
}>;
|
|
123
123
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
@@ -139,7 +139,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
139
139
|
sessionId?: string | undefined;
|
|
140
140
|
message: string;
|
|
141
141
|
} | {
|
|
142
|
-
error:
|
|
142
|
+
error: string;
|
|
143
143
|
message: string;
|
|
144
144
|
}> | undefined;
|
|
145
145
|
execute: import("ai").ToolExecuteFunction<{
|
|
@@ -178,7 +178,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
178
178
|
sessionId?: string | undefined;
|
|
179
179
|
message: string;
|
|
180
180
|
} | {
|
|
181
|
-
error:
|
|
181
|
+
error: string;
|
|
182
182
|
message: string;
|
|
183
183
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
184
184
|
} & {
|
|
@@ -252,7 +252,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
252
252
|
sessionId?: string | undefined;
|
|
253
253
|
message: string;
|
|
254
254
|
} | {
|
|
255
|
-
error:
|
|
255
|
+
error: string;
|
|
256
256
|
message: string;
|
|
257
257
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
258
258
|
}) | ({
|
|
@@ -365,7 +365,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
365
365
|
sessionId?: string | undefined;
|
|
366
366
|
message: string;
|
|
367
367
|
} | {
|
|
368
|
-
error:
|
|
368
|
+
error: string;
|
|
369
369
|
message: string;
|
|
370
370
|
}>;
|
|
371
371
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
@@ -387,7 +387,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
387
387
|
sessionId?: string | undefined;
|
|
388
388
|
message: string;
|
|
389
389
|
} | {
|
|
390
|
-
error:
|
|
390
|
+
error: string;
|
|
391
391
|
message: string;
|
|
392
392
|
}> | undefined;
|
|
393
393
|
execute: import("ai").ToolExecuteFunction<{
|
|
@@ -426,7 +426,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
426
426
|
sessionId?: string | undefined;
|
|
427
427
|
message: string;
|
|
428
428
|
} | {
|
|
429
|
-
error:
|
|
429
|
+
error: string;
|
|
430
430
|
message: string;
|
|
431
431
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
432
432
|
} & {
|
|
@@ -500,7 +500,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
500
500
|
sessionId?: string | undefined;
|
|
501
501
|
message: string;
|
|
502
502
|
} | {
|
|
503
|
-
error:
|
|
503
|
+
error: string;
|
|
504
504
|
message: string;
|
|
505
505
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
506
506
|
}) | ({
|
|
@@ -613,7 +613,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
613
613
|
sessionId?: string | undefined;
|
|
614
614
|
message: string;
|
|
615
615
|
} | {
|
|
616
|
-
error:
|
|
616
|
+
error: string;
|
|
617
617
|
message: string;
|
|
618
618
|
}>;
|
|
619
619
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
@@ -635,7 +635,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
635
635
|
sessionId?: string | undefined;
|
|
636
636
|
message: string;
|
|
637
637
|
} | {
|
|
638
|
-
error:
|
|
638
|
+
error: string;
|
|
639
639
|
message: string;
|
|
640
640
|
}> | undefined;
|
|
641
641
|
execute: import("ai").ToolExecuteFunction<{
|
|
@@ -674,7 +674,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
674
674
|
sessionId?: string | undefined;
|
|
675
675
|
message: string;
|
|
676
676
|
} | {
|
|
677
|
-
error:
|
|
677
|
+
error: string;
|
|
678
678
|
message: string;
|
|
679
679
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
680
680
|
} & {
|
|
@@ -724,7 +724,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
724
724
|
sessionId?: string | undefined;
|
|
725
725
|
message: string;
|
|
726
726
|
} | {
|
|
727
|
-
error:
|
|
727
|
+
error: string;
|
|
728
728
|
message: string;
|
|
729
729
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
730
730
|
}) | ({
|
|
@@ -837,7 +837,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
837
837
|
sessionId?: string | undefined;
|
|
838
838
|
message: string;
|
|
839
839
|
} | {
|
|
840
|
-
error:
|
|
840
|
+
error: string;
|
|
841
841
|
message: string;
|
|
842
842
|
}>;
|
|
843
843
|
}) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
|
|
@@ -859,7 +859,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
859
859
|
sessionId?: string | undefined;
|
|
860
860
|
message: string;
|
|
861
861
|
} | {
|
|
862
|
-
error:
|
|
862
|
+
error: string;
|
|
863
863
|
message: string;
|
|
864
864
|
}> | undefined;
|
|
865
865
|
execute: import("ai").ToolExecuteFunction<{
|
|
@@ -898,7 +898,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
898
898
|
sessionId?: string | undefined;
|
|
899
899
|
message: string;
|
|
900
900
|
} | {
|
|
901
|
-
error:
|
|
901
|
+
error: string;
|
|
902
902
|
message: string;
|
|
903
903
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
904
904
|
} & {
|
|
@@ -948,7 +948,7 @@ export declare function createWorkerAgentTool(input: {
|
|
|
948
948
|
sessionId?: string | undefined;
|
|
949
949
|
message: string;
|
|
950
950
|
} | {
|
|
951
|
-
error:
|
|
951
|
+
error: string;
|
|
952
952
|
message: string;
|
|
953
953
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
954
954
|
});
|
package/dist/agent-call.js
CHANGED
|
@@ -8,7 +8,7 @@ import { captureTraceContext } from "./trace-context.js";
|
|
|
8
8
|
/** The host opens a fresh Worker invocation; only its visible answer returns to the caller. */
|
|
9
9
|
export function createWorkerAgentTool(input) {
|
|
10
10
|
return tool({
|
|
11
|
-
description: `Start an Agent Run in a new or idle child Session. Use runWait with returned runIds and runCancel to cancel. Use sessionId to continue the same Session. ${input.canCopy ? "Omit target to create a copy of yourself." : "Select a declared target."} Available targets: ${JSON.stringify(input.agents)}. Supply context in message.${input.artifactScope ? " To send files, use
|
|
11
|
+
description: `Start an Agent Run in a new or idle child Session. Use runWait with returned runIds and runCancel to cancel. Use sessionId to continue the same Session. ${input.canCopy ? "Omit target to create a copy of yourself." : "Select a declared target."} Available targets: ${JSON.stringify(input.agents)}. Supply context in message.${input.artifactScope ? " To send selected files, use a user message with file parts containing immutable Artifact file_id values. Refer to attachments by filename or order in task text; remote transfer may assign new IDs, exposed to the child in Attached Artifact metadata. IDs hardcoded in text are not rewritten." : ""}`,
|
|
12
12
|
inputSchema: agentCallInputSchema.extend({
|
|
13
13
|
target: input.agents.length
|
|
14
14
|
? input.canCopy
|
|
@@ -50,9 +50,18 @@ export function createWorkerAgentTool(input) {
|
|
|
50
50
|
return {
|
|
51
51
|
...remote.data,
|
|
52
52
|
message: remote.data.error === "remote_run_rejected"
|
|
53
|
-
? "The remote Run was not admitted.
|
|
53
|
+
? "The remote Run was not admitted. Check Artifact transfer and remote service diagnostics before retrying. Local Hosts support files only through the implicit same-Project binding. An unconfirmed upload may have left an orphan copy."
|
|
54
54
|
: "Remote Run admission is uncertain and its capacity is retained. Do not resubmit; reconcile the reservation with the remote service first.",
|
|
55
55
|
};
|
|
56
|
+
if (z
|
|
57
|
+
.object({
|
|
58
|
+
error: z.literal("remote_artifact_transfer_unsupported"),
|
|
59
|
+
})
|
|
60
|
+
.safeParse(value).success)
|
|
61
|
+
return {
|
|
62
|
+
error: "remote_artifact_transfer_unsupported",
|
|
63
|
+
message: "This Host cannot transfer files to remote Agents. Use a Host with Artifact transfer support.",
|
|
64
|
+
};
|
|
56
65
|
const busy = z
|
|
57
66
|
.object({ error: z.literal("child_busy") })
|
|
58
67
|
.safeParse(value);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Result } from "better-result";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { agentApplicationAssistantMessageSchema } from "@gea-ai/contract/agent-applications";
|
|
4
|
-
import type { AgentCallMessage, AgentChildRun, AgentChildRunDestination, AgentChildRunOutcome } from "@gea-ai/contract/agent-worker-tools";
|
|
4
|
+
import type { AgentRemoteFileMapping, AgentCallMessage, AgentChildRun, AgentChildRunDestination, AgentChildRunOutcome } from "@gea-ai/contract/agent-worker-tools";
|
|
5
5
|
import type { StudioArtifactInputFile } from "@gea-ai/contract/studio-artifacts";
|
|
6
6
|
/** Internal transport shared by hosted and local Run dispatch; not a public API client. */
|
|
7
7
|
export type RemoteRunFetch = (path: string, init?: RequestInit) => Promise<Response>;
|
|
8
8
|
export type RemoteRunDestination = Extract<AgentChildRunDestination, {
|
|
9
9
|
type: "remote";
|
|
10
10
|
}>;
|
|
11
|
+
export type RemoteInputFiles = NonNullable<AgentChildRun["artifacts"]>;
|
|
12
|
+
export type RemoteFileMapping = AgentRemoteFileMapping;
|
|
13
|
+
export type RemoteInputTransfer = (files: RemoteInputFiles, signal: AbortSignal) => Promise<RemoteFileMapping>;
|
|
11
14
|
declare const RemoteRunAdmissionError_base: import("better-result").TaggedErrorClass<"RemoteRunAdmissionError", {
|
|
12
15
|
message: string;
|
|
13
16
|
cause: unknown;
|
|
@@ -23,6 +26,9 @@ export declare function submitRemoteRun(fetch: RemoteRunFetch, input: {
|
|
|
23
26
|
artifacts?: Array<StudioArtifactInputFile & {
|
|
24
27
|
id: string;
|
|
25
28
|
}>;
|
|
29
|
+
}, options?: {
|
|
30
|
+
transferFiles?: RemoteInputTransfer;
|
|
31
|
+
signal?: AbortSignal;
|
|
26
32
|
}): Promise<Result<{
|
|
27
33
|
runId: string;
|
|
28
34
|
sessionId: string;
|
package/dist/agent-remote-run.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Result, TaggedError } from "better-result";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { agentApplicationAssistantMessageSchema, agentInputRequestKey, } from "@gea-ai/contract/agent-applications";
|
|
4
4
|
import { agentHttpRunSchema, agentHttpMessageResourceSchema, } from "@gea-ai/contract/agent-http-api";
|
|
5
|
+
import { getAgentCallFileIds, agentRemoteFileMappingSchema, } from "@gea-ai/contract/agent-worker-tools";
|
|
5
6
|
const sessionSchema = z.object({ id: z.uuid() });
|
|
6
7
|
const messagesSchema = z.object({
|
|
7
8
|
items: z.array(agentHttpMessageResourceSchema.extend({ run_id: z.uuid().nullable() })),
|
|
@@ -16,26 +17,57 @@ async function responseJson(response) {
|
|
|
16
17
|
}
|
|
17
18
|
class RemoteRunAdmissionError extends TaggedError("RemoteRunAdmissionError")() {
|
|
18
19
|
}
|
|
19
|
-
export async function submitRemoteRun(fetch, input) {
|
|
20
|
+
export async function submitRemoteRun(fetch, input, options = {}) {
|
|
20
21
|
let sessionId = input.sessionId;
|
|
21
22
|
let submitting = false;
|
|
22
23
|
let rejected = false;
|
|
23
24
|
return Result.tryPromise({
|
|
24
25
|
try: async () => {
|
|
26
|
+
const signal = options.signal ?? AbortSignal.timeout(120_000);
|
|
27
|
+
signal.throwIfAborted();
|
|
28
|
+
let message = input.message;
|
|
29
|
+
const ids = [...new Set(getAgentCallFileIds(message))];
|
|
30
|
+
if (ids.length) {
|
|
31
|
+
if (!options.transferFiles)
|
|
32
|
+
throw new Error("This Host does not support remote Artifact transfer.");
|
|
33
|
+
const files = ids.map((id) => {
|
|
34
|
+
const file = input.artifacts?.find((file) => file.id === id);
|
|
35
|
+
if (!file)
|
|
36
|
+
throw new Error("Selected Artifact was not authorized by the Host.");
|
|
37
|
+
return file;
|
|
38
|
+
});
|
|
39
|
+
const copies = agentRemoteFileMappingSchema.parse(await options.transferFiles(files, signal));
|
|
40
|
+
const mapping = new Map(copies.map((copy) => [copy.sourceId, copy.id]));
|
|
41
|
+
if (copies.length !== ids.length ||
|
|
42
|
+
mapping.size !== ids.length ||
|
|
43
|
+
ids.some((id) => !mapping.has(id)))
|
|
44
|
+
throw new Error("Remote Artifact transfer receipt is incomplete.");
|
|
45
|
+
if (typeof message !== "string")
|
|
46
|
+
message = {
|
|
47
|
+
...message,
|
|
48
|
+
parts: message.parts.map((part) => part.type === "file"
|
|
49
|
+
? { ...part, file_id: mapping.get(part.file_id) }
|
|
50
|
+
: part),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
signal.throwIfAborted();
|
|
25
54
|
sessionId ??= sessionSchema.parse(await responseJson(await fetch("/sessions", {
|
|
26
55
|
method: "POST",
|
|
56
|
+
signal,
|
|
27
57
|
headers: { "content-type": "application/json" },
|
|
28
58
|
body: JSON.stringify({
|
|
29
59
|
agent_id: input.destination.agentId,
|
|
30
60
|
environment: input.destination.environment,
|
|
31
61
|
}),
|
|
32
62
|
}))).id;
|
|
63
|
+
signal.throwIfAborted();
|
|
33
64
|
submitting = true;
|
|
34
65
|
// No automatic replay: a lost response does not prove Run admission failed.
|
|
35
66
|
const response = await fetch(`/sessions/${sessionId}/runs`, {
|
|
36
67
|
method: "POST",
|
|
37
68
|
headers: { "content-type": "application/json" },
|
|
38
|
-
|
|
69
|
+
signal,
|
|
70
|
+
body: JSON.stringify({ input: message, stream: false }),
|
|
39
71
|
});
|
|
40
72
|
rejected = [400, 401, 403, 404, 405, 409, 413, 415, 422, 429].includes(response.status);
|
|
41
73
|
const run = agentHttpRunSchema.parse(await responseJson(response));
|
|
@@ -48,7 +80,7 @@ export async function submitRemoteRun(fetch, input) {
|
|
|
48
80
|
sessionId,
|
|
49
81
|
definitive: !submitting || rejected,
|
|
50
82
|
message: !submitting || rejected
|
|
51
|
-
? "Remote Run was not admitted."
|
|
83
|
+
? "Remote Run was not admitted. Artifact preparation or admission failed; inspect Host diagnostics before retrying. An unconfirmed upload may leave an orphan copy."
|
|
52
84
|
: "Remote Run admission is unknown; do not resubmit.",
|
|
53
85
|
}),
|
|
54
86
|
});
|
package/dist/agent-run-host.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type RemoteRunDestination } from "./agent-remote-run";
|
|
1
|
+
import { type RemoteRunDestination, type RemoteInputFiles, type RemoteFileMapping } from "./agent-remote-run";
|
|
2
2
|
import { type AgentCallMessage, type AgentChildRun, type AgentChildRunDestination, type AgentChildRunHostEvent } from "@gea-ai/contract/agent-worker-tools";
|
|
3
3
|
import type { TraceContext, TraceContinuation } from "@gea-ai/contract/traces";
|
|
4
4
|
import type { AgentSessionInboxExecution } from "@gea-ai/contract/agent-session-inbox";
|
|
5
|
-
import type { StudioArtifactInputFile } from "@gea-ai/contract/studio-artifacts";
|
|
5
|
+
import type { StudioArtifactScope, StudioArtifactInputFile } from "@gea-ai/contract/studio-artifacts";
|
|
6
|
+
export type { RemoteRunFetch, RemoteRunDestination, RemoteInputFiles, RemoteFileMapping, } from "./agent-remote-run";
|
|
6
7
|
export { readWorkerAgentResponse } from "./agent-call";
|
|
7
8
|
export { streamManagedAgentSessionRun } from "./agent-session-stream";
|
|
8
9
|
export type AgentChildRunSession = (operation: string, body: unknown, traceContext?: TraceContext) => Promise<Response>;
|
|
@@ -12,9 +13,11 @@ export declare class AgentRunHost {
|
|
|
12
13
|
private readonly executions;
|
|
13
14
|
private readonly work;
|
|
14
15
|
private closed;
|
|
16
|
+
private readonly shutdown;
|
|
15
17
|
constructor(host: {
|
|
16
18
|
session: AgentChildRunSession;
|
|
17
19
|
remoteFetch?(destination: RemoteRunDestination, path: string, init?: RequestInit): Promise<Response>;
|
|
20
|
+
transferRemoteInputs?(destination: RemoteRunDestination, files: RemoteInputFiles, scope: StudioArtifactScope | undefined, signal: AbortSignal): Promise<RemoteFileMapping>;
|
|
18
21
|
register(run: AgentChildRun): Promise<string>;
|
|
19
22
|
invoke(run: AgentChildRun, signal: AbortSignal, continuation?: TraceContinuation, inboxExecution?: AgentSessionInboxExecution): Promise<{
|
|
20
23
|
response: Response;
|
|
@@ -44,6 +47,8 @@ export declare class AgentRunHost {
|
|
|
44
47
|
artifacts?: Array<StudioArtifactInputFile & {
|
|
45
48
|
id: string;
|
|
46
49
|
}>;
|
|
50
|
+
artifactScope?: StudioArtifactScope;
|
|
51
|
+
signal?: AbortSignal;
|
|
47
52
|
traceContext?: TraceContext;
|
|
48
53
|
}): Promise<Response>;
|
|
49
54
|
startRemote(input: {
|
|
@@ -54,6 +59,8 @@ export declare class AgentRunHost {
|
|
|
54
59
|
artifacts?: Array<StudioArtifactInputFile & {
|
|
55
60
|
id: string;
|
|
56
61
|
}>;
|
|
62
|
+
artifactScope?: StudioArtifactScope;
|
|
63
|
+
signal?: AbortSignal;
|
|
57
64
|
traceContext?: TraceContext;
|
|
58
65
|
}): Promise<Response>;
|
|
59
66
|
dispatch(run: AgentChildRun, inboxExecution?: AgentSessionInboxExecution): void;
|
package/dist/agent-run-host.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { submitRemoteRun, observeRemoteRun, cancelRemoteRun, } from "./agent-remote-run.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { Result } from "better-result";
|
|
4
|
-
import { agentChildRunSchema, agentChildRunListResultSchema, agentChildRunStartResultSchema, } from "@gea-ai/contract/agent-worker-tools";
|
|
4
|
+
import { agentChildRunSchema, getAgentCallFileIds, agentChildRunListResultSchema, agentChildRunStartResultSchema, } from "@gea-ai/contract/agent-worker-tools";
|
|
5
5
|
import { readWorkerAgentResponse } from "./agent-call.js";
|
|
6
6
|
export { readWorkerAgentResponse } from "./agent-call.js";
|
|
7
7
|
export { streamManagedAgentSessionRun } from "./agent-session-stream.js";
|
|
@@ -11,6 +11,7 @@ export class AgentRunHost {
|
|
|
11
11
|
executions = new Map();
|
|
12
12
|
work = new Set();
|
|
13
13
|
closed = false;
|
|
14
|
+
shutdown = new AbortController();
|
|
14
15
|
constructor(host) {
|
|
15
16
|
this.host = host;
|
|
16
17
|
}
|
|
@@ -54,7 +55,8 @@ export class AgentRunHost {
|
|
|
54
55
|
}
|
|
55
56
|
if (this.closed)
|
|
56
57
|
return new Response("Run dispatcher is stopping", { status: 503 });
|
|
57
|
-
const
|
|
58
|
+
const { artifactScope: _artifactScope, signal: _signal, ...sessionInput } = input;
|
|
59
|
+
const response = await this.host.session("start", sessionInput);
|
|
58
60
|
if (!response.ok)
|
|
59
61
|
return response;
|
|
60
62
|
const { run, scheduled } = agentChildRunStartResultSchema.parse(await response.json());
|
|
@@ -67,6 +69,10 @@ export class AgentRunHost {
|
|
|
67
69
|
async startRemote(input) {
|
|
68
70
|
if (this.closed || !this.host.remoteFetch)
|
|
69
71
|
return new Response("Remote Agents API unavailable", { status: 503 });
|
|
72
|
+
if (getAgentCallFileIds(input.message).length &&
|
|
73
|
+
!this.host.transferRemoteInputs)
|
|
74
|
+
return Response.json({ error: "remote_artifact_transfer_unsupported" }, { status: 501 });
|
|
75
|
+
const { artifactScope: _artifactScope, signal: _signal, ...sessionInput } = input;
|
|
70
76
|
const listed = await this.host.session("list", {});
|
|
71
77
|
if (!listed.ok)
|
|
72
78
|
return listed;
|
|
@@ -74,7 +80,7 @@ export class AgentRunHost {
|
|
|
74
80
|
let reservationId;
|
|
75
81
|
if (subagentConcurrencyVersion) {
|
|
76
82
|
const reserved = await this.host.session("reserve", {
|
|
77
|
-
...
|
|
83
|
+
...sessionInput,
|
|
78
84
|
agentKey: input.destination.agentId,
|
|
79
85
|
});
|
|
80
86
|
if (!reserved.ok)
|
|
@@ -99,7 +105,16 @@ export class AgentRunHost {
|
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
const fetch = (path, init) => this.host.remoteFetch(input.destination, path, init);
|
|
102
|
-
const admission = await submitRemoteRun(fetch, input
|
|
108
|
+
const admission = await submitRemoteRun(fetch, input, {
|
|
109
|
+
signal: AbortSignal.any([
|
|
110
|
+
this.shutdown.signal,
|
|
111
|
+
AbortSignal.timeout(120_000),
|
|
112
|
+
...(input.signal ? [input.signal] : []),
|
|
113
|
+
]),
|
|
114
|
+
transferFiles: this.host.transferRemoteInputs
|
|
115
|
+
? (files, signal) => this.host.transferRemoteInputs(input.destination, files, input.artifactScope, signal)
|
|
116
|
+
: undefined,
|
|
117
|
+
});
|
|
103
118
|
return admission.match({
|
|
104
119
|
err: async (error) => {
|
|
105
120
|
if (reservationId && error.definitive) {
|
|
@@ -130,7 +145,7 @@ export class AgentRunHost {
|
|
|
130
145
|
traceContext: input.traceContext,
|
|
131
146
|
}
|
|
132
147
|
: {
|
|
133
|
-
...
|
|
148
|
+
...sessionInput,
|
|
134
149
|
id: receipt.runId,
|
|
135
150
|
sessionId: receipt.sessionId,
|
|
136
151
|
agentKey: input.destination.agentId,
|
|
@@ -305,6 +320,7 @@ export class AgentRunHost {
|
|
|
305
320
|
}
|
|
306
321
|
async close() {
|
|
307
322
|
this.closed = true;
|
|
323
|
+
this.shutdown.abort();
|
|
308
324
|
for (const cancellation of this.executions.values())
|
|
309
325
|
cancellation.abort();
|
|
310
326
|
while (this.work.size)
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { AgentEngine } from "./agent-core-engine";
|
|
|
10
10
|
import type { AgentTracing } from "@gea-ai/contract/agent-tracing";
|
|
11
11
|
export type { AgentTracing, AgentTraceSpan, } from "@gea-ai/contract/agent-tracing";
|
|
12
12
|
import { type AgentContextStrategy } from "./context";
|
|
13
|
-
import { type AgentReference } from "@gea-ai/contract/agent-references";
|
|
13
|
+
import { remoteAgentDeclarationSchema, type AgentReference } from "@gea-ai/contract/agent-references";
|
|
14
14
|
export type { AgentContextStrategy, AgentContextRuntime, AgentContextPrepareStepEvent, AgentContextStepEndEvent, AgentContextEndEvent, } from "./context";
|
|
15
15
|
import type { ComputerCommands } from "@gea-ai/contract/computer-commands";
|
|
16
16
|
import type { AgentArtifacts, AgentArtifactScopeResolver } from "@gea-ai/contract/studio-artifacts";
|
|
@@ -447,15 +447,18 @@ export declare function defineAgentReference<const TSlug extends WorkerAgentSlug
|
|
|
447
447
|
description: string;
|
|
448
448
|
slug: TSlug;
|
|
449
449
|
};
|
|
450
|
-
export type DefineRemoteAgentInput =
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
};
|
|
454
|
-
/** Invoke an exported Agent in the current Project using the caller's authority and environment. */
|
|
450
|
+
export type DefineRemoteAgentInput = Omit<z.input<typeof remoteAgentDeclarationSchema>, "type">;
|
|
451
|
+
/** Invoke a fixed Agent ID. Omitted transport options inherit the Host binding;
|
|
452
|
+
* auth.bearerTokenEnv names a Host-only credential for explicit remote authority. */
|
|
455
453
|
export declare function defineRemoteAgent(input: DefineRemoteAgentInput): {
|
|
456
454
|
type: "remote";
|
|
457
455
|
agentId: string;
|
|
456
|
+
url?: string | undefined;
|
|
457
|
+
environment?: "local" | "preview" | "production" | undefined;
|
|
458
458
|
description: string;
|
|
459
|
+
auth?: {
|
|
460
|
+
bearerTokenEnv: string;
|
|
461
|
+
} | undefined;
|
|
459
462
|
};
|
|
460
463
|
/** @deprecated Enable defineAgent({ sessionTools: true }) instead. */
|
|
461
464
|
export declare function chatList(): DefinedManagedTool<"chat_list">;
|
package/dist/index.js
CHANGED
|
@@ -340,7 +340,8 @@ export function defineAgentReference(input) {
|
|
|
340
340
|
});
|
|
341
341
|
return { ...reference, slug: input.slug };
|
|
342
342
|
}
|
|
343
|
-
/** Invoke
|
|
343
|
+
/** Invoke a fixed Agent ID. Omitted transport options inherit the Host binding;
|
|
344
|
+
* auth.bearerTokenEnv names a Host-only credential for explicit remote authority. */
|
|
344
345
|
export function defineRemoteAgent(input) {
|
|
345
346
|
return remoteAgentDeclarationSchema.parse({ ...input, type: "remote" });
|
|
346
347
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const agentSdkVersion = "0.1.
|
|
1
|
+
export declare const agentSdkVersion = "0.1.261004-alpha.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by scripts/build-sdk-version.mjs from package.json.
|
|
2
|
-
export const agentSdkVersion = "0.1.
|
|
2
|
+
export const agentSdkVersion = "0.1.261004-alpha.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gea-ai/agent-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.261004-alpha.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"homepage": "https://musegea.com/developers",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@ai-sdk/otel": "1.0.9",
|
|
120
120
|
"@ai-sdk/provider": "4.0.1",
|
|
121
121
|
"@ai-sdk/provider-utils": "5.0.2",
|
|
122
|
-
"@gea-ai/contract": "0.1.
|
|
122
|
+
"@gea-ai/contract": "0.1.261004-alpha.0",
|
|
123
123
|
"@opentelemetry/api": "1.9.1",
|
|
124
124
|
"@opentelemetry/context-async-hooks": "2.10.0",
|
|
125
125
|
"@opentelemetry/core": "2.10.0",
|