@gea-ai/agent-sdk 0.1.261006-alpha.0 → 0.1.261008-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.
Files changed (48) hide show
  1. package/dist/agent-call.d.ts +9 -1
  2. package/dist/agent-channel-api.d.ts +1 -1
  3. package/dist/agent-channel-author-runtime.d.ts +2 -2
  4. package/dist/agent-channel-receiver.d.ts +3 -3
  5. package/dist/agent-channel-runtime.d.ts +1 -1
  6. package/dist/agent-computer-http.d.ts +2 -2
  7. package/dist/agent-computer-scope.d.ts +2 -2
  8. package/dist/agent-computer-session.d.ts +1 -1
  9. package/dist/agent-core-engine.d.ts +2 -2
  10. package/dist/agent-core.d.ts +5 -5
  11. package/dist/agent-media-read.d.ts +13 -0
  12. package/dist/agent-media-read.js +29 -0
  13. package/dist/agent-run-host.d.ts +4 -4
  14. package/dist/agent-session-child-store.d.ts +1 -1
  15. package/dist/agent-session-children.d.ts +1 -1
  16. package/dist/agent-session-children.js +9 -4
  17. package/dist/agent-session-computer.d.ts +1 -1
  18. package/dist/agent-session-execution.d.ts +1 -1
  19. package/dist/agent-session-inbox.d.ts +1 -1
  20. package/dist/agent-session-payload.d.ts +1 -1
  21. package/dist/agent-worker.d.ts +11 -11
  22. package/dist/agent-worker.js +24 -11
  23. package/dist/catalog-language-model.d.ts +1 -1
  24. package/dist/channels/feishu-inbound.d.ts +2 -2
  25. package/dist/channels/feishu-output.d.ts +2 -2
  26. package/dist/channels/feishu-websocket.d.ts +2 -2
  27. package/dist/channels/feishu.d.ts +4 -4
  28. package/dist/channels/index.d.ts +2 -2
  29. package/dist/code-mode.d.ts +7 -3
  30. package/dist/computer/just-bash.d.ts +1 -1
  31. package/dist/context-runtime.d.ts +2 -2
  32. package/dist/context.d.ts +1 -1
  33. package/dist/evals.d.ts +2 -2
  34. package/dist/experimental/agent-core-language-model.d.ts +1 -1
  35. package/dist/experimental/agent-core-model.d.ts +1 -1
  36. package/dist/experimental/agent-core-tools.d.ts +3 -3
  37. package/dist/experimental/agent-core-ui.d.ts +1 -1
  38. package/dist/experimental/agent-core-worker-tools.d.ts +2 -2
  39. package/dist/gea-ai.d.ts +1 -1
  40. package/dist/index.d.ts +42 -29
  41. package/dist/index.js +6 -4
  42. package/dist/script-source.d.ts +1 -1
  43. package/dist/script-tools.d.ts +1 -1
  44. package/dist/tool-model-output.js +3 -4
  45. package/dist/version.d.ts +1 -1
  46. package/dist/version.js +1 -1
  47. package/dist/worker.d.ts +2 -2
  48. package/package.json +11 -12
@@ -1,5 +1,5 @@
1
1
  import { type AgentWorkerToolInitialization } from "@gea-ai/contract/agent-worker-tools";
2
- import type { AgentHostBinding } from "./agent-worker";
2
+ import type { AgentHostBinding } from "./agent-worker.js";
3
3
  import type { StudioArtifactScope } from "@gea-ai/contract/studio-artifacts";
4
4
  /** The host opens a fresh Worker invocation; only its visible answer returns to the caller. */
5
5
  export declare function createWorkerAgentTool(input: {
@@ -8,6 +8,7 @@ export declare function createWorkerAgentTool(input: {
8
8
  canCopy?: boolean;
9
9
  artifactScope?: StudioArtifactScope;
10
10
  }): ({
11
+ deferLoading?: boolean;
11
12
  title?: string;
12
13
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
13
14
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -256,6 +257,7 @@ export declare function createWorkerAgentTool(input: {
256
257
  message: string;
257
258
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
258
259
  }) | ({
260
+ deferLoading?: boolean;
259
261
  title?: string;
260
262
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
261
263
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -504,6 +506,7 @@ export declare function createWorkerAgentTool(input: {
504
506
  message: string;
505
507
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
506
508
  }) | ({
509
+ deferLoading?: boolean;
507
510
  title?: string;
508
511
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
509
512
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -728,6 +731,7 @@ export declare function createWorkerAgentTool(input: {
728
731
  message: string;
729
732
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
730
733
  }) | ({
734
+ deferLoading?: boolean;
731
735
  title?: string;
732
736
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
733
737
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -955,6 +959,7 @@ export declare function createWorkerAgentTool(input: {
955
959
  export declare function createWorkerRunCancelTool({ host, }: {
956
960
  host: AgentHostBinding;
957
961
  }): ({
962
+ deferLoading?: boolean;
958
963
  title?: string;
959
964
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
960
965
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -1024,6 +1029,7 @@ export declare function createWorkerRunCancelTool({ host, }: {
1024
1029
  status: "abort_requested" | "not_running";
1025
1030
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
1026
1031
  }) | ({
1032
+ deferLoading?: boolean;
1027
1033
  title?: string;
1028
1034
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
1029
1035
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -1093,6 +1099,7 @@ export declare function createWorkerRunCancelTool({ host, }: {
1093
1099
  status: "abort_requested" | "not_running";
1094
1100
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
1095
1101
  }) | ({
1102
+ deferLoading?: boolean;
1096
1103
  title?: string;
1097
1104
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
1098
1105
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -1155,6 +1162,7 @@ export declare function createWorkerRunCancelTool({ host, }: {
1155
1162
  status: "abort_requested" | "not_running";
1156
1163
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
1157
1164
  }) | ({
1165
+ deferLoading?: boolean;
1158
1166
  title?: string;
1159
1167
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
1160
1168
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -1,4 +1,4 @@
1
- import type { AgentHostBinding } from "./agent-worker";
1
+ import type { AgentHostBinding } from "./agent-worker.js";
2
2
  import type { AgentChannelRunTerminal } from "@gea-ai/contract/agent-channels";
3
3
  export declare function extractChannelReply(messageValue: unknown, responseMessageId: string): {
4
4
  messageId: string;
@@ -1,7 +1,7 @@
1
1
  import { type AgentChannelInvocationContext } from "@gea-ai/contract/agent-channels";
2
2
  import { type AgentChannelRuntimeCommand, type AgentChannelRuntimeStart, type AgentChannelJson } from "@gea-ai/contract/agent-channel-runtime";
3
- import type { AgentChannelFetchEnvironment } from "./agent-worker";
4
- import type { AnyDefinedChannel, ChannelCapabilities, ChannelInputContext, ChannelRouteContext, ChannelWebSocketRoute } from "./channels";
3
+ import type { AgentChannelFetchEnvironment } from "./agent-worker.js";
4
+ import type { AnyDefinedChannel, ChannelCapabilities, ChannelInputContext, ChannelRouteContext, ChannelWebSocketRoute } from "./channels/index.js";
5
5
  export declare function createChannelCapabilities(environment: AgentChannelFetchEnvironment, signal: AbortSignal): Promise<ChannelCapabilities>;
6
6
  export declare function createChannelInputContext(input: {
7
7
  definition: AnyDefinedChannel;
@@ -1,6 +1,6 @@
1
- import { type DefinedAgent } from "./index";
2
- import type { AgentChannelAddressStorage } from "./agent-channel-worker";
3
- import type { AgentChannelFetchEnvironment } from "./agent-worker";
1
+ import { type DefinedAgent } from "./index.js";
2
+ import type { AgentChannelAddressStorage } from "./agent-channel-worker.js";
3
+ import type { AgentChannelFetchEnvironment } from "./agent-worker.js";
4
4
  export type AgentChannelReceiverEnvironment = AgentChannelFetchEnvironment & {
5
5
  CHANNEL: AgentChannelFetchEnvironment["CHANNEL"] & {
6
6
  connectWebSocket(url: string, options: {
@@ -1,4 +1,4 @@
1
- import type { AgentChannelAddressStorage, AgentChannelAddressEnvironment } from "./agent-channel-worker";
1
+ import type { AgentChannelAddressStorage, AgentChannelAddressEnvironment } from "./agent-channel-worker.js";
2
2
  /** An accepted operation owns its code target; the address owns only stable session state. */
3
3
  export declare function handleCustomChannelAddressRequest(request: Request, storage: AgentChannelAddressStorage, _environment?: AgentChannelAddressEnvironment): Promise<Response>;
4
4
  /** Input execution, event projection, and delivery advance independently on durable alarms. */
@@ -1,7 +1,7 @@
1
1
  import { type AgentPackageSnapshot } from "@gea-ai/contract/agent-packages";
2
2
  import type { ComputerSessionInitializer } from "@gea-ai/contract/agent-computer";
3
- import type { AgentComputerScopeResolver } from "./index";
4
- import type { AgentSessionNamespace, AgentWorkerPlatformBindings, AgentWorkerSkillMount } from "./agent-worker";
3
+ import type { AgentComputerScopeResolver } from "./index.js";
4
+ import type { AgentSessionNamespace, AgentWorkerPlatformBindings, AgentWorkerSkillMount } from "./agent-worker.js";
5
5
  export declare function readSessionComputer(namespace: AgentSessionNamespace, chatId: string): Promise<{
6
6
  reference: {
7
7
  generation: string;
@@ -1,7 +1,7 @@
1
1
  import { type AgentComputerScope, type AgentRuntimePrincipal } from "@gea-ai/contract/agent-packages";
2
2
  import type { JsonValue } from "@gea-ai/contract";
3
- import type { AgentComputerScopeResolver } from "./index";
4
- import type { AgentSessionNamespace, AgentWorkerPlatformBindings } from "./agent-worker";
3
+ import type { AgentComputerScopeResolver } from "./index.js";
4
+ import type { AgentSessionNamespace, AgentWorkerPlatformBindings } from "./agent-worker.js";
5
5
  export declare function resolveAgentComputerScope(input: {
6
6
  namespace: AgentSessionNamespace;
7
7
  chatId: string;
@@ -1,5 +1,5 @@
1
1
  import { type Computer, type ComputerSessionFactory, type ComputerCapability, type ComputerRoots, type ComputerSessionContext, type ComputerSessionInitializer } from "@gea-ai/contract/agent-computer";
2
- import type { AgentWorkerComputerOptions, AgentWorkerPlatformBindings, AgentWorkerSkillMount } from "./agent-worker";
2
+ import type { AgentWorkerComputerOptions, AgentWorkerPlatformBindings, AgentWorkerSkillMount } from "./agent-worker.js";
3
3
  export declare const defaultComputerRoots: ComputerRoots;
4
4
  /** Translate the native session protocol into the developer's Computer lifecycle callback. */
5
5
  export declare function createAgentComputerSession(input: {
@@ -2,8 +2,8 @@ import type { AgentTracing } from "@gea-ai/contract/agent-tracing";
2
2
  import type { AgentCorePolicyContext, AgentCoreStepSettings, AgentCoreOutput } from "@gea-ai/contract/agent-core";
3
3
  import type { AgentCoreToolCall } from "@gea-ai/contract/agent-core";
4
4
  import type { AgentCoreExecutionOptions } from "@gea-ai/contract/agent-core";
5
- import type { AgentCoreError } from "./experimental/agent-core";
6
- import type { AgentToolApprovalDecision, AgentToolRuntimeSdk } from "./index";
5
+ import type { AgentCoreError } from "./experimental/agent-core.js";
6
+ import type { AgentToolApprovalDecision, AgentToolRuntimeSdk } from "./index.js";
7
7
  export type AgentCoreGuardrail = (input: {
8
8
  call: AgentCoreToolCall;
9
9
  sdk: Pick<AgentToolRuntimeSdk, "auth" | "env" | "environment" | "identity" | "signal" | "tracing">;
@@ -1,9 +1,9 @@
1
- import { type AgentCoreOutputSchema } from "./agent-core-output";
2
- export type { AgentCoreOutputSchema } from "./agent-core-output";
3
- import type { AgentCoreEngine } from "./agent-core-engine";
4
- export type { AgentCoreEngine, AgentCoreGuardrail } from "./agent-core-engine";
1
+ import { type AgentCoreOutputSchema } from "./agent-core-output.js";
2
+ export type { AgentCoreOutputSchema } from "./agent-core-output.js";
3
+ import type { AgentCoreEngine } from "./agent-core-engine.js";
4
+ export type { AgentCoreEngine, AgentCoreGuardrail } from "./agent-core-engine.js";
5
5
  export type { AgentCorePolicyContext, AgentCoreStepSettings, } from "@gea-ai/contract/agent-core";
6
- export { AgentCoreError } from "./experimental/agent-core";
6
+ export { AgentCoreError } from "./experimental/agent-core.js";
7
7
  /** Select the Rust/WASM loop for this Agent, retaining its existing Worker host. */
8
8
  export declare function agentCore(options?: Omit<AgentCoreEngine, "kind" | "module" | "maxToolConcurrency" | "output"> & {
9
9
  maxToolConcurrency?: number;
@@ -0,0 +1,13 @@
1
+ declare const AgentMediaReadError_base: import("better-result").TaggedErrorClass<"AgentMediaReadError", {
2
+ message: string;
3
+ operation: "download Tool output media" | "read Artifact image";
4
+ status?: number;
5
+ }>;
6
+ export declare class AgentMediaReadError extends AgentMediaReadError_base {
7
+ }
8
+ /** Translate Fetch failures at the Tool/model media boundary, without signed URLs. */
9
+ export declare function readAgentMedia(request: () => Promise<Response>, operation: "download Tool output media" | "read Artifact image", signal?: AbortSignal): Promise<{
10
+ data: ArrayBuffer;
11
+ mediaType: string | null;
12
+ }>;
13
+ export {};
@@ -0,0 +1,29 @@
1
+ import { TaggedError } from "better-result";
2
+ export class AgentMediaReadError extends TaggedError("AgentMediaReadError")() {
3
+ }
4
+ /** Translate Fetch failures at the Tool/model media boundary, without signed URLs. */
5
+ export async function readAgentMedia(request, operation, signal) {
6
+ try {
7
+ signal?.throwIfAborted();
8
+ const response = await request();
9
+ if (!response.ok)
10
+ throw new AgentMediaReadError({
11
+ operation,
12
+ status: response.status,
13
+ message: `Could not ${operation} (HTTP ${response.status}).`,
14
+ });
15
+ const data = await response.arrayBuffer();
16
+ return { data, mediaType: response.headers.get("content-type") };
17
+ }
18
+ catch (error) {
19
+ signal?.throwIfAborted();
20
+ if (AgentMediaReadError.is(error))
21
+ throw error;
22
+ // Fetch/body exceptions may contain credentials or signed URLs. These errors
23
+ // enter model feedback and traces, so retain the operation, not the raw cause.
24
+ throw new AgentMediaReadError({
25
+ operation,
26
+ message: `Could not ${operation} (network or response-body failure).`,
27
+ });
28
+ }
29
+ }
@@ -1,11 +1,11 @@
1
- import { type RemoteRunDestination, type RemoteInputFiles, type RemoteFileMapping } from "./agent-remote-run";
1
+ import { type RemoteRunDestination, type RemoteInputFiles, type RemoteFileMapping } from "./agent-remote-run.js";
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
5
  import type { StudioArtifactScope, StudioArtifactInputFile } from "@gea-ai/contract/studio-artifacts";
6
- export type { RemoteRunFetch, RemoteRunDestination, RemoteInputFiles, RemoteFileMapping, } from "./agent-remote-run";
7
- export { readWorkerAgentResponse } from "./agent-call";
8
- export { streamManagedAgentSessionRun } from "./agent-session-stream";
6
+ export type { RemoteRunFetch, RemoteRunDestination, RemoteInputFiles, RemoteFileMapping, } from "./agent-remote-run.js";
7
+ export { readWorkerAgentResponse } from "./agent-call.js";
8
+ export { streamManagedAgentSessionRun } from "./agent-session-stream.js";
9
9
  export type AgentChildRunSession = (operation: string, body: unknown, traceContext?: TraceContext) => Promise<Response>;
10
10
  /** Invocation transport only. SDK Sessions own Run state, waits, completion and wakeups. */
11
11
  export declare class AgentRunHost {
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { type AgentChildRun } from "@gea-ai/contract/agent-worker-tools";
3
- import type { AgentSessionTransactionStorage } from "./agent-session";
3
+ import type { AgentSessionTransactionStorage } from "./agent-session.js";
4
4
  declare const indexSchema: z.ZodObject<{
5
5
  sequence: z.ZodNumber;
6
6
  activeRunIds: z.ZodArray<z.ZodUUID>;
@@ -1,3 +1,3 @@
1
- import type { AgentSessionStorage } from "./agent-session";
1
+ import type { AgentSessionStorage } from "./agent-session.js";
2
2
  /** Admission and immutable receipts share the parent inbox's transaction. */
3
3
  export declare function handleAgentSessionChildren(request: Request, storage: AgentSessionStorage): Promise<Response | undefined>;
@@ -242,13 +242,16 @@ export async function handleAgentSessionChildren(request, storage) {
242
242
  }
243
243
  case "cancel-all": {
244
244
  z.strictObject({}).parse(value);
245
+ let changed = false;
245
246
  for (const run of await readChildRuns(tx)) {
246
- if (!run.outcome) {
247
+ if (!run.outcome && !run.cancelRequested) {
247
248
  run.cancelRequested = true;
248
249
  await putChildRun(tx, run);
250
+ changed = true;
249
251
  }
250
252
  }
251
- await scheduleAgentSessionChildRunChanges(tx);
253
+ if (changed)
254
+ await scheduleAgentSessionChildRunChanges(tx);
252
255
  return Response.json({ stored: true });
253
256
  }
254
257
  case "cancel": {
@@ -256,11 +259,13 @@ export async function handleAgentSessionChildren(request, storage) {
256
259
  const run = await getChildRun(tx, runId);
257
260
  if (!run)
258
261
  return Response.json({ error: "unknown_run" }, { status: 404 });
259
- if (!run.outcome) {
262
+ if (!run.outcome && !run.cancelRequested) {
260
263
  run.cancelRequested = true;
261
264
  await putChildRun(tx, run);
265
+ // Host retries repeat this command. Preserve the existing retry alarm
266
+ // when cancellation intent has already been recorded.
267
+ await scheduleAgentSessionChildRunChanges(tx);
262
268
  }
263
- await scheduleAgentSessionChildRunChanges(tx);
264
269
  return Response.json({ run });
265
270
  }
266
271
  case "complete": {
@@ -1,4 +1,4 @@
1
- import type { AgentSessionTransactionStorage } from "./agent-session";
1
+ import type { AgentSessionTransactionStorage } from "./agent-session.js";
2
2
  /** Shared by managed turns, standalone turns and inbox admission in their transaction. */
3
3
  export declare function activeComputerOperation(tx: AgentSessionTransactionStorage): Promise<{
4
4
  id: string;
@@ -1,2 +1,2 @@
1
- import type { AgentSessionStorage } from "./agent-session";
1
+ import type { AgentSessionStorage } from "./agent-session.js";
2
2
  export declare function handleAgentSessionExecutionRequest(request: Request, storage: AgentSessionStorage): Promise<Response>;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { agentSessionInboxFinishSchema } from "@gea-ai/contract/agent-session-inbox";
3
3
  import type { AgentChildRun } from "@gea-ai/contract/agent-worker-tools";
4
- import type { AgentSessionStorage, AgentSessionTransactionStorage } from "./agent-session";
4
+ import type { AgentSessionStorage, AgentSessionTransactionStorage } from "./agent-session.js";
5
5
  /** Only private definitions/self copies share the owning Agent's business context. */
6
6
  export declare function inheritedAgentSessionMetadata(tx: AgentSessionTransactionStorage, destination: AgentChildRun["destination"]): Promise<Record<string, z.util.JSONType> | undefined>;
7
7
  /** Atomically supersede only an idle input wait, never a running invocation. */
@@ -1,4 +1,4 @@
1
- import type { AgentSessionTransactionStorage } from "./agent-session";
1
+ import type { AgentSessionTransactionStorage } from "./agent-session.js";
2
2
  /** Call within the same transaction as the owning record's indexes/revision. */
3
3
  export declare function putSessionPayload(tx: AgentSessionTransactionStorage, key: string, value: unknown): Promise<void>;
4
4
  /** Legacy inline records remain readable. A partial payload is corruption, not absence. */
@@ -1,25 +1,25 @@
1
1
  import type { WorkerAI } from "@gea-ai/contract/worker-ai";
2
- export { createGeaAI } from "./gea-ai";
3
- export { extractChannelReply } from "./agent-channel-api";
2
+ export { createGeaAI } from "./gea-ai.js";
3
+ export { extractChannelReply } from "./agent-channel-api.js";
4
4
  import { type AgentInteractionPolicy } from "@gea-ai/contract";
5
5
  import type { AgentTracing } from "@gea-ai/contract/agent-tracing";
6
- import type { AgentContextStrategy } from "./context";
6
+ import type { AgentContextStrategy } from "./context.js";
7
7
  import { type AgentSessionInboxExecution } from "@gea-ai/contract/agent-session-inbox";
8
8
  import type { AgentWorkerToolInitialization } from "@gea-ai/contract/agent-worker-tools";
9
9
  import { type ComputerProcessOperation } from "@gea-ai/contract/computer-commands";
10
10
  import type { AgentArtifactScopeResolver } from "@gea-ai/contract/studio-artifacts";
11
11
  import type { ComputerSessionFactory, ComputerCreateResponse, ComputerSessionInitializer } from "@gea-ai/contract/agent-computer";
12
12
  import type { AgentComputerScope } from "@gea-ai/contract/agent-packages";
13
- import type { AgentComputerScopeResolver } from "./index";
13
+ import type { AgentComputerScopeResolver } from "./index.js";
14
14
  import type { ComputerOperationReceipt } from "@gea-ai/contract/agent-worker-tools";
15
15
  import { type UserModelMessage } from "ai";
16
16
  import { type AgentExecutionEnvironment, type AgentPackageSnapshot, type AgentRuntimeAuth } from "@gea-ai/contract/agent-packages";
17
17
  import { z } from "zod";
18
- export { AgentChannelReceiver } from "./agent-channel-receiver";
18
+ export { AgentChannelReceiver } from "./agent-channel-receiver.js";
19
19
  import { type AgentChannelJournalAppend } from "@gea-ai/contract/agent-channel-runtime";
20
- import { type AgentDurableObjectNamespace, type AgentToolApprovalDecision, type AgentToolIdentity, type AgentToolRuntimeSdk, type DefinedAgent } from "./index";
21
- import { type AgentChannelAddressEnvironment } from "./agent-channel-worker";
22
- export { handleAgentChannelAddressAlarm, handleAgentChannelAddressRequest, type AgentChannelAddressEnvironment, type AgentChannelAddressStorage, type AgentChannelAddressTransactionStorage, } from "./agent-channel-worker";
20
+ import { type AgentDurableObjectNamespace, type AgentToolApprovalDecision, type AgentToolIdentity, type AgentToolRuntimeSdk, type DefinedAgent } from "./index.js";
21
+ import { type AgentChannelAddressEnvironment } from "./agent-channel-worker.js";
22
+ export { handleAgentChannelAddressAlarm, handleAgentChannelAddressRequest, type AgentChannelAddressEnvironment, type AgentChannelAddressStorage, type AgentChannelAddressTransactionStorage, } from "./agent-channel-worker.js";
23
23
  export type AgentHostBinding = Partial<WorkerAI> & {
24
24
  fetch(path: string, init?: RequestInit): Promise<Response>;
25
25
  };
@@ -135,9 +135,9 @@ export type AgentToolRuntimeDefinition = {
135
135
  input: unknown;
136
136
  sdk: AgentToolRuntimeSdk;
137
137
  }): Promise<unknown>;
138
- scriptRuntime?: ReturnType<typeof import("./script-tools").getScriptToolRuntime>;
138
+ scriptRuntime?: ReturnType<typeof import("./script-tools.js").getScriptToolRuntime>;
139
139
  inputSchema: z.ZodType;
140
- toModelOutput?: import("./index").DefinedCustomTool["toModelOutput"];
140
+ toModelOutput?: import("./index.js").DefinedCustomTool["toModelOutput"];
141
141
  }>;
142
142
  connectors?: Record<string, {
143
143
  authorization?: {
@@ -196,7 +196,7 @@ export declare function runAgentWorkerRequest(input: {
196
196
  inboxExecution?: AgentSessionInboxExecution;
197
197
  parentRunId?: string;
198
198
  onSessionFinished?: () => Promise<void>;
199
- engine?: import("./agent-core-engine").AgentEngine;
199
+ engine?: import("./agent-core-engine.js").AgentEngine;
200
200
  context?: false | AgentContextStrategy;
201
201
  scopeResolver?: AgentComputerScopeResolver;
202
202
  artifactScopeResolver?: "principal" | AgentArtifactScopeResolver;
@@ -15,6 +15,7 @@ import { decodeAgentModelProxyValue, encodeAgentModelProxyValue, } from "@gea-ai
15
15
  import { createGeaAI, modelDescriptorSchema } from "./gea-ai.js";
16
16
  import { storeToolModelOutput, resolveToolArtifacts, } from "./tool-model-output.js";
17
17
  import { mcpToolModelOutput } from "./mcp-tool-output.js";
18
+ import { AgentMediaReadError, readAgentMedia } from "./agent-media-read.js";
18
19
  export { createGeaAI } from "./gea-ai.js";
19
20
  import { mergeLlmJson, llmRuntimeRequestOptionsSchema, } from "@gea-ai/contract/llm-catalog";
20
21
  import { executeChannelAgentRun, uploadChannelInput, } from "./agent-channel-api.js";
@@ -3802,7 +3803,7 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
3802
3803
  const readImage = async (file) => {
3803
3804
  if (!artifactScope)
3804
3805
  throw new Error("Images require Agent Artifacts.");
3805
- const response = await host.fetch(`${HOST_PATH}/tools/attachments/read`, {
3806
+ const image = await readAgentMedia(() => host.fetch(`${HOST_PATH}/tools/attachments/read`, {
3806
3807
  method: "POST",
3807
3808
  headers: { "content-type": "application/json" },
3808
3809
  body: JSON.stringify({
@@ -3810,16 +3811,14 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
3810
3811
  ...(file.id ? { id: file.id } : { key: file.key }),
3811
3812
  }),
3812
3813
  signal: input.request.signal,
3813
- });
3814
- if (!response.ok)
3815
- throw new Error(`Could not read Artifact image (${response.status}).`);
3816
- const bytes = new Uint8Array(await response.arrayBuffer());
3814
+ }), "read Artifact image", input.request.signal);
3815
+ const bytes = new Uint8Array(image.data);
3817
3816
  if (bytes.byteLength > MAX_AGENT_ARTIFACT_IMAGE_BYTES)
3818
3817
  throw new Error("Prepared image exceeds the model image limit.");
3819
3818
  return {
3820
3819
  type: "file",
3821
3820
  data: { type: "data", data: bytes },
3822
- mediaType: response.headers.get("content-type") ?? file.mediaType,
3821
+ mediaType: image.mediaType ?? file.mediaType,
3823
3822
  };
3824
3823
  };
3825
3824
  const addImage = async (file) => {
@@ -4115,6 +4114,12 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4115
4114
  const initialPrompt = await startupTracing.withSpan("agent.startup.prompt", () => preparePrompt(withTurnImages(assembleAgentWorkerContext({ context, runtimeContext }), turnImages)));
4116
4115
  const modelCancellation = new AbortController();
4117
4116
  let failure;
4117
+ const executionErrorText = (error, fallback = "Agent execution failed.") => {
4118
+ const original = failure?.error ?? error;
4119
+ return original instanceof AgentMediaReadError
4120
+ ? original.message
4121
+ : fallback;
4122
+ };
4118
4123
  let pendingMainCall;
4119
4124
  let pendingMainModel = configuredModel;
4120
4125
  let lastStepNumber = 0;
@@ -4129,7 +4134,7 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4129
4134
  // the execution's original failure before publishing that chunk.
4130
4135
  ownSessionOutcome({
4131
4136
  status: input.request.signal.aborted ? "cancelled" : "failed",
4132
- text: "Agent execution failed.",
4137
+ text: executionErrorText(error),
4133
4138
  });
4134
4139
  recordExecutionFailure(error);
4135
4140
  };
@@ -4267,9 +4272,9 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4267
4272
  // both the error and final usage from clients.
4268
4273
  ownSessionOutcome({
4269
4274
  status: input.request.signal.aborted ? "cancelled" : "failed",
4270
- text: responseMessage.parts
4275
+ text: executionErrorText(failure.error, responseMessage.parts
4271
4276
  .flatMap((part) => (part.type === "text" ? [part.text] : []))
4272
- .join(""),
4277
+ .join("")),
4273
4278
  });
4274
4279
  return;
4275
4280
  }
@@ -4645,7 +4650,13 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4645
4650
  throw failure.error;
4646
4651
  },
4647
4652
  async prepareModel(request) {
4648
- const prepared = await preparePrompt(withTurnImages(assembleAgentWorkerContext({ context, runtimeContext }), turnImages));
4653
+ const prepared = await preparePrompt(withTurnImages(assembleAgentWorkerContext({ context, runtimeContext }), turnImages)).catch((error) => {
4654
+ // Core serializes host exceptions through WASM. Preserve this safe,
4655
+ // typed media failure before that boundary loses its identity.
4656
+ if (error instanceof AgentMediaReadError)
4657
+ fail(error);
4658
+ throw error;
4659
+ });
4649
4660
  const prompt = [...prepared.instructions, ...prepared.messages];
4650
4661
  modelPrompt = prompt;
4651
4662
  const decoratedTools = addCacheControlToToolList(request.tools.map((tool) => ({
@@ -4742,6 +4753,7 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4742
4753
  async execute({ writer }) {
4743
4754
  for await (const chunk of projectAgentCoreEvents(tracked, {
4744
4755
  messageId,
4756
+ onError: executionErrorText,
4745
4757
  approvals: pending?.pendingStep.approvals,
4746
4758
  tools,
4747
4759
  messageMetadata: {
@@ -4842,6 +4854,7 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4842
4854
  : stepCountIs(Number.POSITIVE_INFINITY),
4843
4855
  });
4844
4856
  stream = result.toUIMessageStream({
4857
+ onError: (error) => executionErrorText(error, "An error occurred."),
4845
4858
  generateMessageId: () => payload.responseMessageId,
4846
4859
  originalMessages: payload.originalMessages,
4847
4860
  sendReasoning: true,
@@ -4948,7 +4961,7 @@ async function executeAgentWorkerRequest(input, waitUntil, ownComputer, ownSessi
4948
4961
  !input.request.signal.aborted) {
4949
4962
  events.push({
4950
4963
  type: "error",
4951
- errorText: "Agent execution failed.",
4964
+ errorText: executionErrorText(failure?.error),
4952
4965
  });
4953
4966
  streamedError = true;
4954
4967
  }
@@ -1,4 +1,4 @@
1
- export { moveOpenAICompatibleCacheControlToMessageContent } from "./openai-compatible-cache-control";
1
+ export { moveOpenAICompatibleCacheControlToMessageContent } from "./openai-compatible-cache-control.js";
2
2
  import { type LlmModelFormat } from "@gea-ai/contract/llm-catalog";
3
3
  import { z } from "zod";
4
4
  declare const object: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
@@ -1,7 +1,7 @@
1
1
  import { Result } from "better-result";
2
2
  import { z } from "zod";
3
- import type { ChannelInputContext } from "./index";
4
- import type { FeishuChannelConfiguration } from "./feishu";
3
+ import type { ChannelInputContext } from "./index.js";
4
+ import type { FeishuChannelConfiguration } from "./feishu.js";
5
5
  export declare const feishuSenderSchema: z.ZodObject<{
6
6
  tenantKey: z.ZodString;
7
7
  openId: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import type { AgentChannelEvent, AgentChannelOutboundResult, ChannelCapabilities, ChannelEventContext, AgentChannelDelivery } from "./index";
3
- import type { FeishuChannelOptions } from "./feishu";
2
+ import type { AgentChannelEvent, AgentChannelOutboundResult, ChannelCapabilities, ChannelEventContext, AgentChannelDelivery } from "./index.js";
3
+ import type { FeishuChannelOptions } from "./feishu.js";
4
4
  declare const stateSchema: z.ZodObject<{
5
5
  replies: z.ZodNumber;
6
6
  outputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -1,4 +1,4 @@
1
- import type { FeishuChannelConfiguration } from "./feishu";
2
- import type { ChannelReceiver, ChannelCapabilities } from "./index";
1
+ import type { FeishuChannelConfiguration } from "./feishu.js";
2
+ import type { ChannelReceiver, ChannelCapabilities } from "./index.js";
3
3
  /** One protocol instance per active socket; framework owns reconnection and capability lifetime. */
4
4
  export declare function createFeishuReceiver(configure: (context: ChannelCapabilities) => FeishuChannelConfiguration): ChannelReceiver;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
- import type { AgentEnvironmentRequirement } from "../index";
3
- import { type ChannelCapabilities } from "./index";
4
- import { feishuSenderSchema } from "./feishu-inbound";
2
+ import type { AgentEnvironmentRequirement } from "../index.js";
3
+ import { type ChannelCapabilities } from "./index.js";
4
+ import { feishuSenderSchema } from "./feishu-inbound.js";
5
5
  export type FeishuChannelConfiguration = {
6
6
  appId: string | undefined;
7
7
  appSecret: string | undefined;
@@ -21,7 +21,7 @@ export type FeishuChannelOptions<TEnv extends string = string> = {
21
21
  }): FeishuChannelConfiguration;
22
22
  };
23
23
  /** The built-in adapter is an ordinary public Channel definition; it has no host-specific privileges. */
24
- export declare function feishuChannel<TEnv extends string>(options: FeishuChannelOptions<TEnv>): import("./index").DefinedChannel<{
24
+ export declare function feishuChannel<TEnv extends string>(options: FeishuChannelOptions<TEnv>): import("./index.js").DefinedChannel<{
25
25
  replies: number;
26
26
  outputs: Record<string, {
27
27
  messageId: string;
@@ -3,9 +3,9 @@ import { z } from "zod";
3
3
  import type { AgentChannelReceiverHandshakeError } from "@gea-ai/contract/agent-channel-receivers";
4
4
  import { type AgentChannelUserIdentity, type AgentCustomChannelDefinition, type AgentChannelExecutionTarget, type AgentChannelRoute } from "@gea-ai/contract/agent-channels";
5
5
  import { type AgentChannelJson, type AgentChannelUserMessage, type AgentChannelEvent, type AgentChannelDelivery, type AgentChannelOutboundResult } from "@gea-ai/contract/agent-channel-runtime";
6
- import type { AgentEnvironmentRequirement } from "../index";
6
+ import type { AgentEnvironmentRequirement } from "../index.js";
7
7
  import type { UIMessage } from "ai";
8
- export { httpChannel } from "../index";
8
+ export { httpChannel } from "../index.js";
9
9
  export type { AgentChannelUserMessage, AgentChannelEvent, AgentChannelDelivery, AgentChannelOutboundResult, } from "@gea-ai/contract/agent-channel-runtime";
10
10
  export type ChannelSendOptions = {
11
11
  operationId: string;
@@ -1,9 +1,9 @@
1
- import type { AgentToolContext } from "./index";
2
- import type { getScriptToolRuntime } from "./script-tools";
1
+ import type { AgentToolContext } from "./index.js";
2
+ import type { getScriptToolRuntime } from "./script-tools.js";
3
3
  import { type ToolSet } from "ai";
4
4
  import { z } from "zod";
5
5
  import type { AgentPackageSnapshot, AgentAllowedCallers } from "@gea-ai/contract/agent-packages";
6
- import { createCoreWorkerTools } from "./experimental/agent-core-worker-tools";
6
+ import { createCoreWorkerTools } from "./experimental/agent-core-worker-tools.js";
7
7
  type CoreOptions = Parameters<typeof createCoreWorkerTools>[0];
8
8
  /** Resolve old snapshots by effective behavior; authoring only uses allowedCallers. */
9
9
  export declare function resolveToolAllowedCallers(snapshot: AgentPackageSnapshot, name: string, eligible: boolean): AgentAllowedCallers;
@@ -16,6 +16,7 @@ export declare function createCodeMode(options: CoreOptions & {
16
16
  }): Promise<{
17
17
  tools: ToolSet | {
18
18
  executeJavaScript: ({
19
+ deferLoading?: boolean;
19
20
  title?: string;
20
21
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
21
22
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -154,6 +155,7 @@ export declare function createCodeMode(options: CoreOptions & {
154
155
  truncated: boolean;
155
156
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
156
157
  }) | ({
158
+ deferLoading?: boolean;
157
159
  title?: string;
158
160
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
159
161
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -292,6 +294,7 @@ export declare function createCodeMode(options: CoreOptions & {
292
294
  truncated: boolean;
293
295
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
294
296
  }) | ({
297
+ deferLoading?: boolean;
295
298
  title?: string;
296
299
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
297
300
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -416,6 +419,7 @@ export declare function createCodeMode(options: CoreOptions & {
416
419
  truncated: boolean;
417
420
  }, NoInfer<import("@ai-sdk/provider-utils").Context>>;
418
421
  }) | ({
422
+ deferLoading?: boolean;
419
423
  title?: string;
420
424
  providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
421
425
  metadata?: import("@ai-sdk/provider").JSONObject;
@@ -1,5 +1,5 @@
1
1
  import type { WorkerComputerSession } from "@gea-ai/contract/agent-computer";
2
- import { type ComputerOptions, type EphemeralComputerFilesystem } from "../computer";
2
+ import { type ComputerOptions, type EphemeralComputerFilesystem } from "../computer.js";
3
3
  export declare function justbash(input?: ComputerOptions & {
4
4
  filesystem?: EphemeralComputerFilesystem;
5
5
  }): {
@@ -1,8 +1,8 @@
1
1
  import type { WorkerAI } from "@gea-ai/contract/worker-ai";
2
2
  import { type AgentToolOutputOffload, type AgentContextDescriptor, type AgentContextUsage } from "@gea-ai/contract/agent-context";
3
3
  import type { FinishReason, LanguageModelUsage } from "ai";
4
- import { type AgentWorkerContextState } from "./agent-worker-context";
5
- import { type AgentContextRuntime, type AgentContextStrategy } from "./context";
4
+ import { type AgentWorkerContextState } from "./agent-worker-context.js";
5
+ import { type AgentContextRuntime, type AgentContextStrategy } from "./context.js";
6
6
  /** Owns context callback ordering and its invocation-scoped work, not a second Run. */
7
7
  export declare function createAgentContextRuntime(input: {
8
8
  strategy?: false | AgentContextStrategy;
package/dist/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type AgentContextDescriptor, type DefaultAgentContextOptions, type AgentContextStrategy as ContextStrategy, type AgentContextRuntime as ContextRuntime, type AgentContextPrepareStepEvent as PrepareStepEvent, type AgentContextStepEndEvent as StepEndEvent, type AgentContextEndEvent as EndEvent } from "@gea-ai/contract/agent-context";
2
- import type { AgentDurableObjectBindings } from "./index";
2
+ import type { AgentDurableObjectBindings } from "./index.js";
3
3
  export type { AgentAI, AgentAIOptions, DefaultAgentContextOptions, AgentContextUpdate, AgentContextUsage, } from "@gea-ai/contract/agent-context";
4
4
  export type AgentContextStrategy = ContextStrategy<AgentDurableObjectBindings>;
5
5
  export type AgentContextRuntime = ContextRuntime<AgentDurableObjectBindings>;
package/dist/evals.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { AgentEvalEvidenceReference, AgentBenchmarkCaseMetadata, AgentEvalMetric } from "@gea-ai/contract";
2
2
  import { type UITools } from "ai";
3
3
  import { z } from "zod";
4
- import type { AgentHostBinding } from "./agent-worker";
5
- import type { AgentMessage, AgentMessageForTools } from "./index";
4
+ import type { AgentHostBinding } from "./agent-worker.js";
5
+ import type { AgentMessage, AgentMessageForTools } from "./index.js";
6
6
  type AgentEvalRuntimeMessage = AgentMessageForTools<UITools>;
7
7
  export type AgentEvalJudgeContext<TMessage extends AgentEvalRuntimeMessage = AgentMessage> = {
8
8
  caseId?: string;
@@ -1,6 +1,6 @@
1
1
  import type { LanguageModelV4, LanguageModelV4Usage } from "@ai-sdk/provider";
2
2
  import { type AgentCoreProviderConfig } from "@gea-ai/contract/agent-core";
3
- import { type AgentRuntimeCacheControlProvider } from "../cache-control";
3
+ import { type AgentRuntimeCacheControlProvider } from "../cache-control.js";
4
4
  export declare function toCoreLanguageModelUsage(value: unknown): LanguageModelV4Usage;
5
5
  /** AI SDK facade over a single Rust model call. No provider SDK or tool execution. */
6
6
  export declare function createAgentCoreLanguageModel(input: {
@@ -1,4 +1,4 @@
1
1
  import type { LanguageModelV3, LanguageModelV4, LanguageModelV4CallOptions } from "@ai-sdk/provider";
2
- import type { AgentCoreHost } from "./agent-core";
2
+ import type { AgentCoreHost } from "./agent-core.js";
3
3
  /** Bind an already-resolved model. Only doStream runs here; Rust owns every step. */
4
4
  export declare function createAgentCoreModel(model: LanguageModelV3 | LanguageModelV4, options?: Pick<LanguageModelV4CallOptions, "maxOutputTokens" | "temperature" | "providerOptions" | "headers" | "reasoning">): NonNullable<AgentCoreHost["model"]>;
@@ -1,7 +1,7 @@
1
1
  import type { AgentCoreToolCall } from "@gea-ai/contract/agent-core";
2
- import type { AgentToolApprovalDecision, AgentToolRuntimeSdk } from "../index";
3
- import type { AgentToolRuntimeDefinition } from "../agent-worker";
4
- import type { AgentCoreHost } from "./agent-core";
2
+ import type { AgentToolApprovalDecision, AgentToolRuntimeSdk } from "../index.js";
3
+ import type { AgentToolRuntimeDefinition } from "../agent-worker.js";
4
+ import type { AgentCoreHost } from "./agent-core.js";
5
5
  /** Host policies use the existing SDK approval decisions. Core owns scheduling. */
6
6
  export declare function createAgentCoreTools(options: {
7
7
  actions: AgentToolRuntimeDefinition["actions"];
@@ -1,7 +1,7 @@
1
1
  import type { UIMessageChunk } from "ai";
2
2
  import type { ToolSet } from "@ai-sdk/provider-utils";
3
3
  import type { AgentCoreEvent, AgentCoreInput, AgentCoreOutcome } from "@gea-ai/contract/agent-core";
4
- import { type AgentCoreHost, type createAgentCore } from "./agent-core";
4
+ import { type AgentCoreHost, type createAgentCore } from "./agent-core.js";
5
5
  /** Project facts from Core. Step completion and terminal success remain Core-owned. */
6
6
  export declare function projectAgentCoreEvents(turn: AsyncGenerator<AgentCoreEvent, AgentCoreOutcome>, options: {
7
7
  messageId: string;
@@ -1,6 +1,6 @@
1
1
  import type { ModelMessage, ToolSet } from "ai";
2
- import type { AgentToolApprovalDecision } from "../index";
3
- import type { AgentCoreGuardrail } from "../agent-core-engine";
2
+ import type { AgentToolApprovalDecision } from "../index.js";
3
+ import type { AgentCoreGuardrail } from "../agent-core-engine.js";
4
4
  import { z } from "zod";
5
5
  /** Reuse the Worker-constructed tools, including Computer locks and capabilities. */
6
6
  export declare function createCoreWorkerTools(options: {
package/dist/gea-ai.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { type AgentModelProxyClient } from "@gea-ai/contract/agent-model-proxy";
2
2
  import { type LanguageModel } from "ai";
3
3
  import { z } from "zod";
4
- import type { AgentHostBinding } from "./agent-worker";
4
+ import type { AgentHostBinding } from "./agent-worker.js";
5
5
  declare const jsonObjectSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
6
6
  export declare const modelDescriptorSchema: z.ZodUnion<readonly [z.ZodObject<{
7
7
  providerType: z.ZodEnum<{
package/dist/index.d.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  import type { ScriptSkillSource } from "@gea-ai/contract/script-execution";
2
- import { getScriptToolRuntime } from "./script-tools";
2
+ import { getScriptToolRuntime } from "./script-tools.js";
3
3
  import type { AgentAllowedCallers, AgentProgrammaticToolCalling, AgentConnectorToolOverrides, AgentToolNamespace } from "@gea-ai/contract/agent-packages";
4
4
  export type { AgentAllowedCallers, AgentProgrammaticToolCalling, AgentConnectorToolOverrides, AgentToolNamespace, } from "@gea-ai/contract/agent-packages";
5
5
  import { type AgentToolOutputOffloadOptions } from "@gea-ai/contract/agent-context";
6
6
  export type { AgentToolOutputOffloadOptions } from "@gea-ai/contract/agent-context";
7
7
  import { type ModelGenerationOptions, type ModelSelection } from "@gea-ai/contract/model-options";
8
- export { aiSdk } from "./ai-sdk";
9
- export type { AgentEngine } from "./agent-core-engine";
8
+ export { aiSdk } from "./ai-sdk.js";
9
+ export type { AgentEngine } from "./agent-core-engine.js";
10
10
  import type { AgentTracing } from "@gea-ai/contract/agent-tracing";
11
11
  export type { AgentTracing, AgentTraceSpan, } from "@gea-ai/contract/agent-tracing";
12
- import { type AgentContextStrategy } from "./context";
13
- import { remoteAgentDeclarationSchema, type AgentReference } from "@gea-ai/contract/agent-references";
14
- export type { AgentContextStrategy, AgentContextRuntime, AgentContextPrepareStepEvent, AgentContextStepEndEvent, AgentContextEndEvent, } from "./context";
12
+ import { type AgentContextStrategy } from "./context.js";
13
+ import { workerAgentReferenceSchema, remoteAgentDeclarationSchema, type AgentReference } from "@gea-ai/contract/agent-references";
14
+ export type { AgentContextStrategy, AgentContextRuntime, AgentContextPrepareStepEvent, AgentContextStepEndEvent, AgentContextEndEvent, } from "./context.js";
15
15
  import type { ComputerCommands } from "@gea-ai/contract/computer-commands";
16
16
  import type { AgentArtifacts, AgentArtifactScopeResolver } from "@gea-ai/contract/studio-artifacts";
17
17
  export type { AgentArtifacts, AgentArtifactScopeContext, AgentArtifactScopeResolver, StudioArtifact, StudioArtifactPage, StudioArtifactDownload, StudioArtifactScope, } from "@gea-ai/contract/studio-artifacts";
18
- import type { DefinedComputer } from "./computer";
18
+ import type { DefinedComputer } from "./computer.js";
19
19
  import { agentManagedToolNames, type AgentComputerScopeResolver, type AgentConnectorAuth, type AgentConnectorDefinition, type AgentConnectorRequestInjection, type AgentConnectorRuntime, type AgentEnvironmentVariable, type AgentExecutionEnvironment, type AgentExtensionMount, type AgentPackageSnapshot, type AgentRuntimeAuth, type AgentSkill, type AgentToolIdentity, type AgentToolPermissions, GEA_AGENT_PACKAGE_SCHEMA_VERSION } from "@gea-ai/contract/agent-packages";
20
20
  import { type AgentChannelDefinition, type AgentChannelTurnPolicy } from "@gea-ai/contract/agent-channels";
21
21
  import type { MessageMetadata } from "@gea-ai/contract";
@@ -23,16 +23,16 @@ import { z } from "zod";
23
23
  import type { UIMessage, UITool, UITools, UserModelMessage } from "ai";
24
24
  import type { AgentToolModelOutput } from "@gea-ai/contract/studio-artifacts";
25
25
  export type { AgentToolModelOutput } from "@gea-ai/contract/studio-artifacts";
26
- import type { DefinedComputerTool } from "./computer-tools";
27
- export { createAgentSkillTool } from "./skill-tool";
28
- import { type AutoModelRequirements } from "./creative-reasoning-auto";
29
- import type { AnyDefinedChannel } from "./channels/index";
30
- export { defineChannel, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, WS, } from "./channels/index";
26
+ import type { DefinedComputerTool } from "./computer-tools.js";
27
+ export { createAgentSkillTool } from "./skill-tool.js";
28
+ import { type AutoModelRequirements } from "./creative-reasoning-auto.js";
29
+ import type { AnyDefinedChannel } from "./channels/index.js";
30
+ export { defineChannel, GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, WS, } from "./channels/index.js";
31
31
  export type { AgentWorkerRouteDeclaration } from "@gea-ai/contract/agent-channels";
32
- export { applyPatch, bash, editFile, findFiles, listDirectory, readFile, searchText, writeFile, } from "./computer-tools";
33
- export type { DefineComputerToolInput, DefinedComputerTool, } from "./computer-tools";
34
- export type { AutoModelRequirements } from "./creative-reasoning-auto";
35
- export { handleAgentSessionRequest, type AgentSessionStorage, type AgentSessionTransactionStorage, } from "./agent-session";
32
+ export { applyPatch, bash, editFile, findFiles, listDirectory, readFile, searchText, writeFile, } from "./computer-tools.js";
33
+ export type { DefineComputerToolInput, DefinedComputerTool, } from "./computer-tools.js";
34
+ export type { AutoModelRequirements } from "./creative-reasoning-auto.js";
35
+ export { handleAgentSessionRequest, type AgentSessionStorage, type AgentSessionTransactionStorage, } from "./agent-session.js";
36
36
  export type AgentConnectorCapability<TOperation extends string = string> = {
37
37
  invoke(operation: TOperation, input: unknown): Promise<unknown>;
38
38
  };
@@ -439,7 +439,7 @@ export declare function agentTool(): DefinedManagedTool<"agent">;
439
439
  export interface WorkerAgentRegistry {
440
440
  }
441
441
  export type WorkerAgentSlug = keyof WorkerAgentRegistry extends never ? string : Extract<keyof WorkerAgentRegistry, string>;
442
- /** Explicitly makes a main Agent in the same Worker available to the owning Agent. */
442
+ /** @deprecated Use defineRemoteAgent({ slug, description }) instead. */
443
443
  export declare function defineAgentReference<const TSlug extends WorkerAgentSlug>(input: {
444
444
  slug: TSlug;
445
445
  description: string;
@@ -448,15 +448,28 @@ export declare function defineAgentReference<const TSlug extends WorkerAgentSlug
448
448
  description: string;
449
449
  slug: TSlug;
450
450
  };
451
- export type DefineRemoteAgentInput = Omit<z.input<typeof remoteAgentDeclarationSchema>, "type">;
452
- /** Invoke a fixed Agent ID. Omitted invocationAuthority uses a protected Project key; oauth requires an existing target installation. Environment defaults to the Host environment. */
453
- export declare function defineRemoteAgent(input: DefineRemoteAgentInput): {
454
- type: "remote";
455
- agentId: string;
456
- invocationAuthority?: "oauth" | "project_key" | undefined;
457
- environment?: "local" | "preview" | "production" | undefined;
451
+ export type DefineRemoteAgentInput = {
452
+ slug: WorkerAgentSlug;
458
453
  description: string;
454
+ agentId?: never;
455
+ environment?: never;
456
+ invocationAuthority?: never;
457
+ } | (Omit<z.input<typeof remoteAgentDeclarationSchema>, "type"> & {
458
+ slug?: never;
459
+ });
460
+ /** Reference a same-Worker entry by slug, or an independently admitted Agent by ID. */
461
+ export declare function defineRemoteAgent<const TSlug extends WorkerAgentSlug>(input: {
462
+ slug: TSlug;
463
+ description: string;
464
+ agentId?: never;
465
+ environment?: never;
466
+ invocationAuthority?: never;
467
+ }): Omit<z.output<typeof workerAgentReferenceSchema>, "slug"> & {
468
+ slug: TSlug;
459
469
  };
470
+ export declare function defineRemoteAgent(input: Omit<z.input<typeof remoteAgentDeclarationSchema>, "type"> & {
471
+ slug?: never;
472
+ }): z.output<typeof remoteAgentDeclarationSchema>;
460
473
  /** @deprecated Enable defineAgent({ sessionTools: true }) instead. */
461
474
  export declare function chatList(): DefinedManagedTool<"chat_list">;
462
475
  /** @deprecated Enable defineAgent({ sessionTools: true }) instead. */
@@ -639,7 +652,7 @@ type AgentComputerInput = DefinedComputer | {
639
652
  };
640
653
  };
641
654
  type DefineAgentBaseInput = ModelGenerationOptions & {
642
- engine?: import("./agent-core-engine").AgentEngine;
655
+ engine?: import("./agent-core-engine.js").AgentEngine;
643
656
  context?: false | AgentContextStrategy;
644
657
  /** Large tool results are stored in the Session and read with readToolOutput. Defaults to enabled. */
645
658
  toolOutputOffload?: boolean | AgentToolOutputOffloadOptions;
@@ -728,9 +741,9 @@ export declare function createAgentToolRuntimeDefinition(input: DefinedAgent): {
728
741
  input: unknown;
729
742
  sdk: AgentToolRuntimeSdk;
730
743
  }): Promise<unknown>;
731
- scriptRuntime?: ReturnType<typeof import("./script-tools").getScriptToolRuntime>;
744
+ scriptRuntime?: ReturnType<typeof import("./script-tools.js").getScriptToolRuntime>;
732
745
  inputSchema: z.ZodType;
733
- toModelOutput?: import(".").DefinedCustomTool["toModelOutput"];
746
+ toModelOutput?: import("./index.js").DefinedCustomTool["toModelOutput"];
734
747
  };
735
748
  };
736
749
  connectors: {
@@ -769,6 +782,6 @@ export declare function createAgentHookRuntimeDefinition(input: DefinedAgent): {
769
782
  };
770
783
  export type { AgentConnectorAuth, AgentConnectorDefinition, AgentConnectorRuntime, AgentPackageSnapshot, AgentSkill, AgentToolIdentity, AgentToolPermissions, };
771
784
  export { WORKER_AGENT_HTTP_VERSION } from "@gea-ai/contract";
772
- export { handleAgentSessionAlarm } from "./agent-session-inbox";
773
- export { executeJavaScript, executePython } from "./script-tools";
785
+ export { handleAgentSessionAlarm } from "./agent-session-inbox.js";
786
+ export { executeJavaScript, executePython } from "./script-tools.js";
774
787
  export type { ScriptWorkerBundle } from "@gea-ai/contract/script-execution";
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { agentToolOutputOffloadOptionsSchema, } from "@gea-ai/contract/agent-con
3
3
  import { resolveModelOptions, } from "@gea-ai/contract/model-options";
4
4
  export { aiSdk } from "./ai-sdk.js";
5
5
  import { describeAgentContext } from "./context.js";
6
- import { workerAgentReferenceSchema, remoteAgentDeclarationSchema, } from "@gea-ai/contract/agent-references";
6
+ import { workerAgentReferenceSchema, remoteAgentDeclarationSchema, remoteAgentInputSchema, } from "@gea-ai/contract/agent-references";
7
7
  import { agentConnectorAuthSchema, agentConnectorDefinitionSchema, agentConnectorGrantSchema, agentConnectorRuntimeSchema, agentEnvironmentVariableSchema, getAgentConnectorPrincipalType, agentPackageSnapshotSchema, agentSlugSchema, agentSkillSchema, agentToolSchema, GEA_AGENT_PACKAGE_SCHEMA_VERSION, } from "@gea-ai/contract/agent-packages";
8
8
  import { agentChannelKeySchema, agentChannelPathSchema, agentCustomChannelDefinitionSchema, agentHttpChannelDefinitionSchema, canonicalAgentChannelJson, } from "@gea-ai/contract/agent-channels";
9
9
  import { z } from "zod";
@@ -339,7 +339,7 @@ const agentToolConnectorAliases = Symbol("agentToolConnectorAliases");
339
339
  export function agentTool() {
340
340
  return { id: "agent", type: "managed" };
341
341
  }
342
- /** Explicitly makes a main Agent in the same Worker available to the owning Agent. */
342
+ /** @deprecated Use defineRemoteAgent({ slug, description }) instead. */
343
343
  export function defineAgentReference(input) {
344
344
  const reference = workerAgentReferenceSchema.parse({
345
345
  ...input,
@@ -347,9 +347,11 @@ export function defineAgentReference(input) {
347
347
  });
348
348
  return { ...reference, slug: input.slug };
349
349
  }
350
- /** Invoke a fixed Agent ID. Omitted invocationAuthority uses a protected Project key; oauth requires an existing target installation. Environment defaults to the Host environment. */
351
350
  export function defineRemoteAgent(input) {
352
- return remoteAgentDeclarationSchema.parse({ ...input, type: "remote" });
351
+ const reference = remoteAgentInputSchema.parse(input);
352
+ return "slug" in reference
353
+ ? workerAgentReferenceSchema.parse({ ...reference, type: "worker" })
354
+ : remoteAgentDeclarationSchema.parse({ ...reference, type: "remote" });
353
355
  }
354
356
  /** @deprecated Enable defineAgent({ sessionTools: true }) instead. */
355
357
  export function chatList() {
@@ -1,5 +1,5 @@
1
1
  import { type ScriptExecutionInput } from "@gea-ai/contract/script-execution";
2
- import type { AgentToolContext } from "./index";
2
+ import type { AgentToolContext } from "./index.js";
3
3
  /** Resolve source in the parent; only validated code and JSON input reach the child. */
4
4
  export declare function resolveScriptSource(value: unknown, context: Pick<AgentToolContext<Record<never, never>>, "signal" | "skills"> & {
5
5
  artifacts?: {
@@ -1,5 +1,5 @@
1
1
  import { scriptExecutionInputSchema, type ScriptExecutionResult, type ScriptWorkerBundle } from "@gea-ai/contract/script-execution";
2
- import { type DefinedCustomTool } from "./index";
2
+ import { type DefinedCustomTool } from "./index.js";
3
3
  type ScriptRuntime = {
4
4
  bundle?: ScriptWorkerBundle;
5
5
  language: "javascript" | "python";
@@ -1,5 +1,6 @@
1
1
  import { convertInlineFileDataToUint8Array } from "@ai-sdk/provider-utils";
2
2
  import { z } from "zod";
3
+ import { readAgentMedia } from "./agent-media-read.js";
3
4
  const uploadResultSchema = z.object({ id: z.uuid() });
4
5
  /** Persist only immutable references in the model context, never signed URLs or bytes. */
5
6
  export async function storeToolModelOutput(output, artifacts, signal) {
@@ -29,10 +30,8 @@ export async function storeToolModelOutput(output, artifacts, signal) {
29
30
  });
30
31
  let body;
31
32
  if (part.data.type === "url") {
32
- const response = await fetch(part.data.url, { signal });
33
- if (!response.ok)
34
- throw new Error(`Tool file download failed (${response.status}).`);
35
- body = await response.arrayBuffer();
33
+ const url = part.data.url;
34
+ body = (await readAgentMedia(() => fetch(url, { signal }), "download Tool output media", signal)).data;
36
35
  }
37
36
  else {
38
37
  const bytes = convertInlineFileDataToUint8Array(part.data);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const agentSdkVersion = "0.1.261006-alpha.0";
1
+ export declare const agentSdkVersion = "0.1.261008-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.261006-alpha.0";
2
+ export const agentSdkVersion = "0.1.261008-alpha.0";
package/dist/worker.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type AgentApplicationDefinition, type AgentChannelFetchEnvironment } from "./agent-worker";
2
- import { type DefinedAgent } from "./index";
1
+ import { type AgentApplicationDefinition, type AgentChannelFetchEnvironment } from "./agent-worker.js";
2
+ import { type DefinedAgent } from "./index.js";
3
3
  /** Agents are platform execution targets, not public HTTP endpoints. */
4
4
  export declare function defineWorker<TEnvironment extends AgentChannelFetchEnvironment = AgentChannelFetchEnvironment, TContext = unknown>(input: {
5
5
  agents: Record<string, DefinedAgent>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gea-ai/agent-sdk",
3
- "version": "0.1.261006-alpha.0",
3
+ "version": "0.1.261008-alpha.0",
4
4
  "private": false,
5
5
  "homepage": "https://musegea.com/developers",
6
6
  "license": "Apache-2.0",
@@ -113,13 +113,13 @@
113
113
  "access": "public"
114
114
  },
115
115
  "dependencies": {
116
- "@ai-sdk/anthropic": "4.0.37",
117
- "@ai-sdk/openai": "4.0.4",
118
- "@ai-sdk/openai-compatible": "3.0.2",
119
- "@ai-sdk/otel": "1.0.9",
120
- "@ai-sdk/provider": "4.0.1",
121
- "@ai-sdk/provider-utils": "5.0.2",
122
- "@gea-ai/contract": "0.1.261006-alpha.0",
116
+ "@ai-sdk/anthropic": "4.0.67",
117
+ "@ai-sdk/openai": "4.0.79",
118
+ "@ai-sdk/openai-compatible": "3.0.58",
119
+ "@ai-sdk/otel": "1.0.119",
120
+ "@ai-sdk/provider": "4.0.19",
121
+ "@ai-sdk/provider-utils": "5.0.50",
122
+ "@gea-ai/contract": "0.1.261008-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",
@@ -128,7 +128,7 @@
128
128
  "@opentelemetry/sdk-trace-base": "2.10.0",
129
129
  "@standard-schema/spec": "1.1.0",
130
130
  "@workflow/serde": "4.1.0",
131
- "ai": "7.0.9",
131
+ "ai": "7.0.119",
132
132
  "better-result": "2.8.1",
133
133
  "eventsource-parser": "3.0.8",
134
134
  "just-bash": "3.0.1",
@@ -138,13 +138,12 @@
138
138
  "zod": "4.3.6"
139
139
  },
140
140
  "devDependencies": {
141
- "@ai-sdk/react": "4.0.10",
141
+ "@ai-sdk/react": "4.0.122",
142
142
  "@types/node": "^24",
143
143
  "esbuild": "0.28.0",
144
144
  "pyodide": "0.29.3",
145
145
  "typescript": "7.0.2",
146
- "vite-plus": "0.2.1",
147
- "vitest": "4.1.9"
146
+ "vite-plus": "1.0.0"
148
147
  },
149
148
  "peerDependencies": {
150
149
  "esbuild": "^0.28.0"