@gea-ai/agent-sdk 0.1.260917-alpha.2 → 0.1.260920-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 (54) hide show
  1. package/README.md +285 -109
  2. package/dist/agent-call.d.ts +133 -170
  3. package/dist/agent-call.js +26 -38
  4. package/dist/agent-channel-api.d.ts +56 -0
  5. package/dist/agent-channel-api.js +205 -0
  6. package/dist/agent-channel-author-runtime.d.ts +21 -14
  7. package/dist/agent-channel-author-runtime.js +36 -35
  8. package/dist/agent-channel-receiver.js +8 -1
  9. package/dist/agent-core.wasm +0 -0
  10. package/dist/agent-http.d.ts +4 -30
  11. package/dist/agent-http.js +4 -90
  12. package/dist/agent-remote-run.d.ts +16 -0
  13. package/dist/agent-remote-run.js +78 -0
  14. package/dist/agent-run-host.d.ts +55 -0
  15. package/dist/agent-run-host.js +234 -0
  16. package/dist/agent-session-children.d.ts +3 -0
  17. package/dist/agent-session-children.js +144 -0
  18. package/dist/agent-session-execution.js +107 -10
  19. package/dist/agent-session-inbox.d.ts +40 -6
  20. package/dist/agent-session-inbox.js +305 -144
  21. package/dist/agent-session-runner.d.ts +8 -10
  22. package/dist/agent-session-runner.js +16 -7
  23. package/dist/agent-session-stream.js +1 -1
  24. package/dist/agent-session.js +9 -6
  25. package/dist/agent-worker-context.d.ts +1 -0
  26. package/dist/agent-worker-context.js +19 -8
  27. package/dist/agent-worker.d.ts +4 -5
  28. package/dist/agent-worker.js +244 -254
  29. package/dist/catalog-language-model.d.ts +1 -0
  30. package/dist/catalog-language-model.js +46 -4
  31. package/dist/channels/index.d.ts +7 -9
  32. package/dist/context-runtime.d.ts +2 -1
  33. package/dist/context-runtime.js +15 -4
  34. package/dist/experimental/agent-core-messages.js +4 -4
  35. package/dist/experimental/agent-core-model.js +3 -0
  36. package/dist/experimental/agent-core-tools.js +11 -0
  37. package/dist/gea-ai.d.ts +1 -0
  38. package/dist/gea-ai.js +26 -17
  39. package/dist/index.d.ts +41 -18
  40. package/dist/index.js +54 -3
  41. package/dist/session-authority.d.ts +8 -9
  42. package/dist/tool-model-output.d.ts +7 -0
  43. package/dist/tool-model-output.js +99 -0
  44. package/dist/tool-output-protocol.d.ts +5 -0
  45. package/dist/tool-output-protocol.js +94 -0
  46. package/dist/trace-context.d.ts +1 -1
  47. package/dist/trace-context.js +1 -1
  48. package/package.json +5 -9
  49. package/dist/agent-session-tasks.d.ts +0 -3
  50. package/dist/agent-session-tasks.js +0 -198
  51. package/dist/agent-task-host.d.ts +0 -64
  52. package/dist/agent-task-host.js +0 -331
  53. package/dist/remote-agent.d.ts +0 -22
  54. package/dist/remote-agent.js +0 -149
package/README.md CHANGED
@@ -13,7 +13,167 @@ for validation, Studio display, and exact-version execution. Snapshots never
13
13
  contain handler functions, credentials, Connector Connections, tenant identity,
14
14
  provider configuration, or environment values.
15
15
 
16
- ## Tenant application authentication
16
+ ## Tool outputs
17
+
18
+ `defineTool` accepts `outputSchema` (Zod) and synchronous or asynchronous
19
+ `toModelOutput({ toolCallId, input, output })`, following AI SDK's separation
20
+ between the result used by the application and the result shown to the model.
21
+ Both server and client tools retain output types in `InferAgentUITools`.
22
+
23
+ `outputSchema` is a declaration/type hint. It never parses, coerces or validates
24
+ returned data, including client-supplied results. It is serialized in the Agent
25
+ snapshot and sent as each function's `output_schema` for OpenAI Responses.
26
+ Completions and Anthropic do not receive that field. This does not configure the
27
+ Agent's final structured response. When a converter changes a JSON wire output,
28
+ the author must keep the Responses output schema appropriate for that output.
29
+
30
+ For multimodal results, enable the Agent's `artifacts` capability. Both implicit
31
+ and explicit persistence use the same request-time Artifact resolution:
32
+
33
+ - Implicit: return typed `file` parts from `toModelOutput` containing a URL,
34
+ base64 string or bytes. The SDK uploads them and persists Artifact IDs.
35
+ - Explicit: save the file through `ctx.artifacts`, then return an existing ID
36
+ from `execute` and reference it in `toModelOutput`; no second upload occurs.
37
+
38
+ For example, the implicit converter can map an ordinary business result:
39
+
40
+ ```ts
41
+ toModelOutput: ({ output }) => ({
42
+ type: "content",
43
+ value: [
44
+ {
45
+ type: "file",
46
+ mediaType: "image/png",
47
+ filename: "plot.png",
48
+ data: { type: "url", url: new URL(output.url) },
49
+ // Or: data: { type: "data", data: output.base64 }
50
+ },
51
+ ],
52
+ });
53
+ ```
54
+
55
+ The explicit converter can reference a scoped Artifact:
56
+
57
+ ```ts
58
+ const viewPlot = defineTool({
59
+ name: "viewPlot",
60
+ description: "Show a saved plot to the model.",
61
+ input: z.object({ artifactId: z.string().uuid() }),
62
+ outputSchema: z.object({ artifactId: z.string().uuid() }),
63
+ execute: async ({ artifactId }, ctx) => {
64
+ const { artifact } = await ctx.artifacts!.get({ id: artifactId });
65
+ return { artifactId: artifact.id };
66
+ },
67
+ toModelOutput: ({ output }) => ({
68
+ type: "content",
69
+ value: [{ type: "artifact", artifactId: output.artifactId }],
70
+ }),
71
+ });
72
+ ```
73
+
74
+ `AgentToolModelOutput` supports AI SDK text/JSON/error outputs and content with
75
+ text, modern tagged `file` parts, or `{ type: "artifact", artifactId }` parts.
76
+ Inline or URL file parts are uploaded through the existing Artifact upload
77
+ capability; provider-specific file IDs must first be saved as GEA Artifacts.
78
+ Model context retains immutable IDs and descriptive metadata. Authorized
79
+ download URLs are resolved only when preparing a model request. Replaying saved
80
+ tool results reuses their conversion instead of uploading the same media again.
81
+ Tool calls already removed by context compaction are not reconstructed from UI
82
+ history during approval or client-tool continuation. Large-result offloading
83
+ replaces only text; the model-facing file references remain attached.
84
+ Keep the original `execute` result JSON-serializable; the converter does not
85
+ replace the UI result with its model-facing content.
86
+ Model-facing `error-text` and `error-json` remain errors in both engines without
87
+ changing the original successful UI result into an execution failure.
88
+
89
+ Media placement is a model capability, not a protocol inference. Configure
90
+ `targets["provider/model"].supportsMultimodalToolOutput` in Catalog v2: `true`
91
+ keeps supported media inside tool results; `false` or omitted keeps text/Artifact
92
+ IDs in the tool result and adds media in a user message after all results from
93
+ that tool-call batch. This applies independently of API format. The chosen
94
+ model must still support the supplied image/file media type in user messages;
95
+ fallback cannot add vision to a text-only model. The Completions native adapter
96
+ currently supports image blocks. Both the default
97
+ Agent Core engine and `aiSdk()` use these rules. Rebuild the Agent bundle to
98
+ adopt the new runtime behavior.
99
+
100
+ ## Calling the Agents HTTP API
101
+
102
+ Call the public `/api/v1` API with ordinary HTTP and a fixed Agent ID. No Agent
103
+ SDK dependency is required for API callers:
104
+
105
+ ```ts
106
+ const baseUrl = "https://<tenant-host>/api/v1";
107
+ const headers = {
108
+ authorization: `Bearer ${projectApiKey}`, // Or a user OAuth token.
109
+ "content-type": "application/json",
110
+ };
111
+ const created = await fetch(`${baseUrl}/sessions`, {
112
+ method: "POST",
113
+ headers,
114
+ credentials: "omit",
115
+ redirect: "error",
116
+ body: JSON.stringify({ agent_id: agentId, environment: "production" }),
117
+ });
118
+ if (!created.ok) throw new Error(`Session creation failed: ${created.status}`);
119
+ const session = await created.json();
120
+ const response = await fetch(`${baseUrl}/sessions/${session.id}/runs`, {
121
+ method: "POST",
122
+ headers,
123
+ credentials: "omit",
124
+ redirect: "error",
125
+ body: JSON.stringify({ input: "Hello", stream: true }),
126
+ });
127
+ if (!response.ok) throw new Error(`Run admission failed: ${response.status}`);
128
+ // Consume response.body as the API's SSE stream.
129
+ ```
130
+
131
+ Project Key access to deployed project Agents does not require OAuth or store
132
+ publication. OAuth access remains subject to user and tenant authorization.
133
+ For local development, use the CLI's separate API listener, omit authorization
134
+ and omit `environment` so the local API selects it. Shared HTTP schemas live in
135
+ `@gea-ai/contract/agent-http-api`; routes are documented by `/api/v1/openapi.json`.
136
+
137
+ Read `GET /sessions/{id}` for `active_run`, capture that Run ID, then observe
138
+ `GET /runs/{id}` or its stream. A later Run in the same Session does not change
139
+ the captured invocation. Cancellation acknowledgement is separate from final
140
+ cleanup. Aborting an HTTP request does not cancel a Run; a lost POST response
141
+ does not establish whether it was accepted, so do not automatically replay it.
142
+
143
+ The authoring SDK owns Agent execution. An Agents API client SDK is deferred.
144
+ The Worker `AGENTS.fetch` binding is an authenticated HTTP transport using the
145
+ same paths, payloads and responses. It does not introduce `agents.*`, `sessions.*`
146
+ or `runs.*` client methods. See the
147
+ [HTTP integration guide](https://musegea.com/developers/agent-api).
148
+
149
+ ## Custom Agent execution URL
150
+
151
+ ```ts
152
+ export default defineAgent({
153
+ name: "Support",
154
+ slug: "support",
155
+ model: "your-model",
156
+ http: { runPath: "/gea/support-entry" },
157
+ });
158
+ ```
159
+
160
+ `http.runPath` selects the Agent's actual Worker execution route. Omission uses
161
+ `/gea/agents/<key>/run`. The route belongs to the immutable snapshot and manifest;
162
+ changing it does not change the Agent ID. Hosts invoke the recorded version's
163
+ route, including retained child Runs. OPTIONS reports the declared route without
164
+ creating a Session. Build/upload validation probes it and rejects mismatches and
165
+ conflicting declarations. Private Session control endpoints keep their standard
166
+ protocol paths.
167
+
168
+ Agents API dispatches **to** this Worker route. The existing public authentication
169
+ adapter is still present; removing its control-plane round trip is unfinished.
170
+ This increment does not change `http.auth` behavior or add an API client SDK.
171
+
172
+ ## Existing Worker URL authentication
173
+
174
+ The following Worker URL adapter remains available while the unified Agents API
175
+ migration proceeds. `StudioAgentClient` is still used by existing Worker handlers;
176
+ it is not the fixed-ID `/api/v1` interface above.
17
177
 
18
178
  Agent HTTP accepts Project API keys and GEA user OAuth tokens by default. Push the
19
179
  Worker and associate the Agent with its app in **Studio → Applications**. Publish
@@ -34,26 +194,13 @@ approval for external test tenants and explicit environment enablement. The
34
194
  application starts standard OAuth; GEA confirms the actual user and consumer tenant
35
195
  and resolves the installation internally. Do not send an installation ID.
36
196
 
37
- ```ts
38
- import { StudioAgentClient } from "@gea-ai/agent-sdk/studio-server";
39
-
40
- const agent = new StudioAgentClient({
41
- api: copiedEnvironmentUrl, // The copied /run URL is accepted directly.
42
- token: currentUserAccessToken,
43
- });
44
- const response = await agent.run({ message: "Hello" });
45
- ```
46
-
47
- The token identifies the user, app and tenant; the URL selects the environment
48
- and Agent. Users need current consumer tenant membership and application authorization.
49
- Their configuration, Connections, Chats, files and traces belong to that environment
50
- installation. Existing Chat/Run calls retain their pinned execution version;
51
- historical Workspace-bound records still require access to that Workspace.
52
-
53
- `projectKeyAuth()` and Project API Keys retain Studio development access. `token`
54
- accepts either credential, subject to the Agent's declared auth; a Project Key does
55
- not represent a tenant user or grant cross-tenant installation access. There is no
56
- third marketplace URL. Standalone Worker OAuth publication remains future work.
197
+ Use direct HTTP against platform `/api/v1/sessions` and
198
+ `/api/v1/sessions/{sessionId}/runs`, with a Bearer Project API Key or OAuth user
199
+ token and the canonical Agent ID. Project Keys retain Project service scope;
200
+ OAuth tokens resolve the current user and tenant installation. Neither changes
201
+ the Agent's default host-context execution policy. The older `studio-server`
202
+ client targets the retired Worker credential entry and should not be used for
203
+ new integrations.
57
204
 
58
205
  ## Agent Authoring Shapes
59
206
 
@@ -175,64 +322,28 @@ Generated code uses `createAgentApplicationFetch()`, which owns:
175
322
  /gea/agents[/<agentKey>]/sessions/<sessionId>/v1/<operation>
176
323
  ```
177
324
 
178
- Hosted Agent HTTP handlers accept Project API keys and platform user tokens by
179
- default, equivalent to this explicit configuration:
325
+ Agent execution requires trusted host invocation context by default. Public
326
+ Agents API accepts Project API Keys and OAuth user tokens, checks their scope,
327
+ and admits the Session/Run before calling this Worker's configured execution URL.
328
+ The Worker does not authenticate those credentials again.
180
329
 
181
330
  ```ts
182
- import {
183
- defineAgent,
184
- projectKeyAuth,
185
- platformUserAuth,
186
- } from "@gea-ai/agent-sdk";
331
+ import { defineAgent } from "@gea-ai/agent-sdk";
187
332
 
188
333
  export default defineAgent({
189
334
  name: "support",
190
335
  slug: "support",
191
336
  model: "gea-model-1",
192
- http: { auth: [projectKeyAuth(), platformUserAuth()] },
337
+ http: { runPath: "/gea/support-entry" },
193
338
  });
194
339
  ```
195
340
 
196
- Set `auth: projectKeyAuth()` or `auth: platformUserAuth()` to accept only that
197
- credential type. Explicit configuration replaces the default; it never appends
198
- the other built-in method. Key calls retain Project ownership, while user tokens
199
- require application installation admission and keep the consumer's installation
200
- ownership. The two identities and permissions are never combined. These rules
201
- apply to Agent routes; ordinary routes in `worker.ts` retain their own authentication.
202
-
203
- ```ts
204
- // Inside defineAgent(...):
205
- http: {
206
- auth: false;
207
- } // Explicit public access to this Agent's HTTP API.
208
- ```
209
-
210
- An application can replace the default with its own Session authenticator:
211
-
212
- ```ts
213
- http: {
214
- auth: async (request, { environment }) => {
215
- const session = await getSession(request, environment); // Your verified session.
216
- return session
217
- ? { principalType: "user", principalId: session.userId }
218
- : null;
219
- },
220
- }
221
- ```
222
-
223
- An authenticator returns a verified platform authorization, an external user,
224
- a `Response`, or `null`. An array runs in order: `null` means this method does
225
- not apply, while an identity or any `Response` stops the chain. An empty array
226
- or a chain that returns only `null` rejects with 401. Exceptions stop the chain
227
- and become an HTTP 500 at the Agent boundary. Built-in methods recognize their
228
- credential prefix before validation; malformed, revoked or denied credentials
229
- and service failures never fall through to another identity. Custom methods
230
- should likewise return an error `Response` for invalid credentials, reserving
231
- `null` for a method that does not apply. A single custom authenticator returning
232
- `null` still rejects with 401. Project Keys stay on the backend; they never
233
- represent the creator's GEA user.
234
- `authenticateProjectKey(request, environment.PROJECT)` also works in ordinary
235
- Worker routes with a declared Project binding and a Project attachment.
341
+ Omit `auth` for normal hosted execution. Set `http: { auth: false }` only when
342
+ this Agent's Worker HTTP entry should also admit anonymous requests. The host
343
+ still registers their Session/Run with project-scoped anonymous ownership.
344
+ Request headers and bodies cannot supply a trusted principal or parent Run.
345
+ This setting does not disable public Agents API Key/OAuth checks or expose
346
+ private Session controls. Ordinary business routes keep their own authentication.
236
347
 
237
348
  `OPTIONS /gea/agents/<agentKey>/run` returns only the Agent key, canonical run
238
349
  path and HTTP protocol version. It runs before authentication and does not
@@ -272,11 +383,12 @@ credential or target configuration.
272
383
 
273
384
  ## Context strategies
274
385
 
275
- Agents use the existing tool-output offload and rolling summary by default.
276
- Configure that recipe with `defaultContext`, replace it with a custom strategy,
277
- or set `context: false` to disable automatic summaries, file writes and tool-result
278
- replacement. Disabling compression preserves already committed summaries and
279
- continues normal message persistence.
386
+ Tool-output offload and context summarization are independent features. Offload is
387
+ on by default, including with a custom or disabled context strategy. Configure it
388
+ on `defineAgent`, or set `toolOutputOffload: false` to keep future outputs inline.
389
+ Use `context: false` to disable automatic summaries and context callbacks; set
390
+ both switches to false to disable both features. Already committed summaries and
391
+ offload references remain readable.
280
392
 
281
393
  ```ts
282
394
  import { defineAgent } from "@gea-ai/agent-sdk";
@@ -286,30 +398,68 @@ export default defineAgent({
286
398
  name: "assistant",
287
399
  slug: "assistant",
288
400
  model: "gea-model-1",
401
+ toolOutputOffload: {
402
+ offloadAtCharacters: 4_000,
403
+ replaceAtCharacters: 8_000,
404
+ preserveRecentGroups: 5,
405
+ },
406
+ sessionTools: true,
289
407
  context: defaultContext({
290
- toolOutput: { offloadAtCharacters: 4_000, replaceAtCharacters: 8_000 },
291
408
  preserveRecentGroups: 5,
292
- summarization: {
293
- triggerAtTotalTokens: 64_000,
294
- // Optional: model, instructions, maxOutputTokens.
295
- },
409
+ summarization: { triggerAtTotalTokens: 64_000 },
296
410
  }),
297
411
  });
298
412
  ```
299
413
 
300
- `toolOutput: false` and `summarization: false` independently disable the two
301
- parts of the default recipe. Thresholds use model-visible characters and the
302
- last provider-reported `usage.totalTokens`; the SDK does not estimate tokens.
303
- Recent groups keep tool calls and their results together. Without Computer
304
- storage, tool outputs are saved in the chat's AgentSession and retrieved with
305
- `readToolOutput` using a SHA-256 id and bounded character ranges. Computer-enabled
306
- Agents retain their file-backed `readFile` retrieval. Offload runs before tool
307
- results enter a persisted model projection; complete UI messages and events
308
- remain available separately.
414
+ Offload thresholds use model-visible characters. Results at the first threshold
415
+ are stored; those at the replacement threshold are immediately stubbed. Smaller
416
+ stored results remain inline in recent message groups; `preserveRecentGroups: 0`
417
+ replaces them immediately. The default summary strategy also releases recent-group
418
+ protection under its token-pressure threshold. Summary thresholds use the last
419
+ provider-reported `usage.totalTokens`, without token estimation.
420
+
421
+ All newly offloaded results live in the AgentSession, independent of Computer.
422
+ The SDK automatically supplies `readToolOutput` with a SHA-256 id and bounded
423
+ character ranges. Its bounded output is not offloaded again. Offload happens
424
+ before model-projection persistence, while the UI transcript retains full results.
425
+ Existing file-backed references retain their original retrieval instructions.
426
+ The reader remains available when a Session has stored offloads even if future
427
+ offloading is disabled.
428
+
429
+ The old `defaultContext({ toolOutput: ... })` option remains a deprecated fallback;
430
+ an explicit `toolOutputOffload` setting takes precedence. Old snapshots without the
431
+ new field retain their context-owned policy. Rebuilding an Agent with `context:
432
+ false` now requires `toolOutputOffload: false` as well to disable both features.
433
+
434
+ ### Built-in model tools
435
+
436
+ - `sessionTools: true` adds `sessionList`, `sessionRead`, and `sessionSend`.
437
+ It defaults to false. The old `chatList()` / `chatRead()` / `chatSend()` selections
438
+ remain deprecated compatibility inputs; an explicit `sessionTools` setting
439
+ replaces them. All three tools use Agents API in hosted and local execution:
440
+ `sessionList({agentId?, cursor?, limit?})` lists accessible Sessions;
441
+ `sessionRead({sessionId, cursor?, limit?})` reads saved messages;
442
+ `sessionSend({sessionId, message, mode?})` sends inbox input (default `follow_up`).
443
+ List/read return `{items, next_cursor}`; send returns `{id, session_id, duplicate}`,
444
+ acknowledging delivery rather than Run completion. A Session needs a prior Run
445
+ before messaging. Identity and environment come from the current Run; Key service
446
+ principals do not need a workspace user and OAuth retains tenant/user isolation.
447
+ - Declaring private or referenced subagents adds `agent`, `runWait`, and
448
+ `runCancel` when the host admits those targets. The existing `agentTool()`
449
+ selection enables root self copies. Ordinary Agents do not gain Run tools just
450
+ because they run in an inbox. Implicit joins and descendant cleanup remain
451
+ runtime behavior and do not depend on model tool visibility.
452
+ - Offload adds `readToolOutput` automatically; do not declare it in `tools/`.
453
+
454
+ `gea agent validate` reports `builtinTools`, including each tool's source feature.
455
+ Generated message types include these tools. Reserved generated names are checked
456
+ during packaging. This inventory describes configured tools; host authorization
457
+ and dynamic Connector discovery are still resolved at runtime. Internal managed
458
+ operation IDs remain compatible with the existing host protocol; the model-facing
459
+ names above are camelCase.
309
460
 
310
461
  A custom strategy is an object with optional `prepareStep`, `onStepEnd` and
311
- `onEnd` callbacks, using the AI SDK 7 names. These callbacks replace the default
312
- recipe. `prepareStep` receives durable `messages`, `contextSize`, `stepNumber`
462
+ `onEnd` callbacks, using the AI SDK 7 names. These callbacks replace the summary strategy, independently of offload. `prepareStep` receives durable `messages`, `contextSize`, `stepNumber`
313
463
  and `runtimeContext`; returning `{ messages }` replaces the active projection
314
464
  for subsequent steps and Runs. Returning nothing keeps it. `onStepEnd` also
315
465
  receives that step's `usage` and `finishReason`; `onEnd` receives the main loop's
@@ -640,7 +790,7 @@ override to the public `/run` API or Studio composer. See the upstream
640
790
  [OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai) and
641
791
  [Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic) options.
642
792
 
643
- ## Background Agent tasks
793
+ ## Agent delegation through Sessions and Runs
644
794
 
645
795
  Declare private definitions in `subagents/<name>/agent.ts` with their own `AGENTS.md`, tools, skills and connectors. They run in independent Sessions and may declare further subagents. Only top-level definitions become public Worker entrypoints.
646
796
 
@@ -649,18 +799,51 @@ References are explicit default exports from `subagents/<alias>.ts`:
649
799
  ```ts
650
800
  import { defineAgentReference, defineRemoteAgent } from "@gea-ai/agent-sdk";
651
801
 
652
- // Same Worker: slug is checked against the CLI-generated WorkerAgentRegistry.
802
+ // Same Worker, checked against the generated WorkerAgentRegistry.
653
803
  const sales = defineAgentReference({
654
804
  slug: "sales",
655
805
  description: "Sales analysis",
656
806
  });
657
- // Same Project: uses the Studio Agent slug and the caller's environment.
807
+
808
+ // Same Agents API: the host revalidates the calling Run's authority.
658
809
  const legal = defineRemoteAgent({
659
- slug: "legal-advisor",
810
+ agentId: "bb141b12-6f63-43bd-8ab6-77930916d3ef",
660
811
  description: "Legal review",
812
+ });
813
+
814
+ // Another service: use its API root and canonical Agent ID.
815
+ const external = defineRemoteAgent({
816
+ agentId: "34910649-2df7-4978-8794-8d8fb72f16cd",
817
+ url: "https://legal.example.com/api/v1",
818
+ environment: "production",
819
+ description: "External legal review",
820
+ auth: { bearerTokenEnv: "LEGAL_AGENT_KEY" },
821
+ });
822
+ ```
823
+
824
+ Each reference file default-exports one reference. All targets use `agent({ target: "alias", message, sessionId? })` and return `{ status: "working", runId, sessionId }`. Callers only see their own declared aliases. Include `agentTool()` in the root's tools to allow self copies by omitting `target`; children cannot create unnamed copies.
825
+
826
+ Use `runWait({ runIds, timeoutMs? })` to wait for specific Runs and `runCancel({ runId })` to request cancellation. The SDK owns waiting, batched parent wakeups and descendant cleanup. Cancellation acceptance is not completion. A logical Run keeps its ID through normal waits and resumptions; continuing an idle child with the same target and `sessionId` creates a new Run. There is no Task resource or progress-reporting tool.
827
+
828
+ Remote references always use the canonical Agent ID, optionally with another service's API root. Their Session and Run IDs come from that API. Remote transport creates Sessions/Runs and reads status, messages and cancellation through ordinary HTTP; it never calls a Worker's `/gea/xxxx` execution URL directly. The API selects the versioned Worker route. A remote reference without `environment` inherits the invocation environment (`local` in CLI development).
829
+
830
+ Same-service calls inherit live Project Key or OAuth authority through a short-lived, host-only signed context. Studio host calls use a Project service scope isolated by Worker, environment and principal. Explicit credentials override inherited authority. Calls to another API origin use only explicitly configured credentials; they never forward the parent's bearer. Knowing an Agent ID does not grant access. Same-service parent links are registered by the host; cross-service relationships live in the parent Session and point to the actual remote IDs.
831
+
832
+ Remote observation survives parent waiting using the existing Session pending-dispatch mechanism. A transport error does not invent a terminal outcome, and accepted Run creation is never automatically replayed. Host shutdown stops observation without cancelling remote execution. General crash recovery and approval continuation remain separate lifecycle work.
833
+
834
+ Upgrade SDK, CLI, server and Worker Runtime together and rebuild immutable bundles. The physical `AGENT_TASK_SESSIONS` namespace remains to preserve existing child Session history; it no longer represents Tasks.
835
+
836
+ ## Fetch-style Agents binding
837
+
838
+ Generated Agent Workers include an `AGENTS` binding. Other Workers can declare `{ name: "AGENTS", type: "agents" }` in their bindings. It exposes the same HTTP paths and payloads, without a separate API client SDK:
661
839
 
840
+ ```ts
841
+ const response = await env.AGENTS.fetch("/api/v1/agents?limit=20");
842
+ const agents = await response.json();
662
843
  ```
663
844
 
845
+ Within a trusted Agent invocation, the host supplies signed invocation authority. An ordinary hosted Worker invocation without a source Run must provide its Project API Key or OAuth token in `Authorization`. Local development uses the local API's existing authority. The binding does not expose host signing secrets or permit arbitrary destinations. Default host authority covers Agents, Sessions and Runs; File, Connector and Computer operations require explicit credentials with their existing grants.
846
+
664
847
  ## Call a Studio Agent with AI SDK
665
848
 
666
849
  Use `StudioAgentChatTransport` from `@gea-ai/agent-sdk/studio-client` with
@@ -708,22 +891,8 @@ const agent = new StudioAgentClient({
708
891
  api: env.GEA_AGENT_API_URL, // Agent base URL without /run.
709
892
  token: env.GEA_PROJECT_API_KEY,
710
893
  });
711
- // URL: a GEA Agent protocol endpoint. The key stays in runtime environment configuration.
712
- const external = defineRemoteAgent({
713
- url: "https://legal.example.com/gea/agents/advisor",
714
- description: "Legal review",
715
- auth: { bearerTokenEnv: "LEGAL_AGENT_KEY" },
716
- });
717
894
  ```
718
895
 
719
- Each reference file default-exports one reference. All targets use `agent({ target: "alias", message, agentId? })`; callers only see their own declared aliases. Include `agentTool()` in the root's tools to additionally allow self copies by omitting `target`. Named delegation follows each node's own declarations; child invocations cannot create another unnamed copy.
720
-
721
- The tool returns `{ status: "working", taskId, agentId }`. `task_update({ message })` reports progress, and `task_cancel({ taskId })` requests cancellation. The host continues idle parent conversations when updates arrive. A child task finishes after its descendants and notification inbox settle, including any final summary turn. Continue an idle child with its returned `agentId` and the same target.
722
-
723
- URL targets implement GEA task create/status/cancel endpoints. New calls and continuations follow the deployment selected by the URL, retaining history while using its current model, instructions and tools. Accepted tasks finish on their selected version. URL credentials are explicitly configured; source credentials and principals are not forwarded. Pure local development uses URLs for cross-Worker calls because it has no hosted Project identity.
724
-
725
- This requires matching SDK, CLI, server and Worker Runtime support and rebuilding immutable bundles. Task Sessions opt into `durable-object-worker-namespace-v1`; existing ordinary Session storage is unchanged. Channel wakeups, approval relay, active-child steering and execution recovery after a host crash remain deferred.
726
-
727
896
  ### Worker build plugins
728
897
 
729
898
  The Node-only `@gea-ai/agent-sdk/worker-build-plugins` entry exports the shared
@@ -737,7 +906,7 @@ Applications call `/api/v1` using `fetch`, `curl` or another HTTP client. Payloa
737
906
  use JSON and streams use AI SDK UI-message SSE. The Agent SDK owns Agent execution;
738
907
  calling the HTTP API does not require an SDK client.
739
908
 
740
- Hosted requests use an Application user OAuth token. An independently running
909
+ Hosted requests use a Project API Key or a Project user OAuth token. An independently running
741
910
  `gea agent dev --model-source local --api-port 8788` exposes token-free local access:
742
911
 
743
912
  ```sh
@@ -759,3 +928,10 @@ read-only through the local API.
759
928
 
760
929
  See the [HTTP integration guide](https://musegea.com/developers/agent-api) and the
761
930
  running server's `/api/v1/openapi.json` for routes and payloads.
931
+
932
+ API callers use ordinary HTTP. Subagents reuse Agent/Session/Run resources,
933
+ with parent/child coordination owned by logical Runs in the SDK Session inbox.
934
+ Internal Task logic has been removed. Worker fetch bindings and remote references
935
+ use the same API, which invokes each Agent at its versioned custom or standard
936
+ Worker route. See the [HTTP integration guide](https://musegea.com/developers/agent-api)
937
+ for authentication and Session/Run operations.