@gea-ai/agent-sdk 0.1.260920-alpha.2 → 0.1.260920-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -938
- package/dist/agent-call.d.ts +418 -26
- package/dist/agent-call.js +10 -3
- package/dist/agent-remote-run.d.ts +6 -2
- package/dist/agent-remote-run.js +4 -1
- package/dist/agent-run-host.d.ts +11 -3
- package/dist/agent-run-host.js +1 -0
- package/dist/agent-session-children.js +3 -2
- package/dist/agent-session-execution.js +22 -12
- package/dist/agent-session-inbox.js +27 -4
- package/dist/agent-session-stream.js +37 -3
- package/dist/agent-worker.js +3 -1
- package/dist/evals.d.ts +18 -3
- package/dist/evals.js +104 -17
- package/dist/tool-model-output.js +12 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,946 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The TypeScript SDK for building GEA Agent applications.
|
|
4
4
|
|
|
5
|
-
`@gea-ai/agent-sdk` is the code-first authoring SDK for GEA Agent
|
|
6
|
-
applications. It defines main Agents, package-local executable Tools, Skill
|
|
7
|
-
references, Agent-owned Durable Objects, and secret-free Connector definitions
|
|
8
|
-
and requirements.
|
|
9
|
-
|
|
10
|
-
The SDK retains executable handlers for Worker runtime use.
|
|
11
|
-
`createAgentPackageSnapshot()` produces deterministic JSON-compatible metadata
|
|
12
|
-
for validation, Studio display, and exact-version execution. Snapshots never
|
|
13
|
-
contain handler functions, credentials, Connector Connections, tenant identity,
|
|
14
|
-
provider configuration, or environment values.
|
|
15
|
-
|
|
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
|
-
Both the default Agent Core engine and `aiSdk()` support client Tools without
|
|
23
|
-
`execute`. A client Tool waits for an `output-available` or `output-error` part
|
|
24
|
-
on the original assistant message and Tool call ID. Submit all pending client
|
|
25
|
-
results/approval decisions together through the existing continuation flow.
|
|
26
|
-
Core pauses server handlers in the same batch until those interactions complete,
|
|
27
|
-
following its existing whole-batch approval behavior.
|
|
28
|
-
Tool results resume the same Run while its interaction remains pending.
|
|
29
|
-
Waiting for client input releases execution: a new user message skips the old
|
|
30
|
-
interaction and starts a new Run in the same Session, without an explicit cancel.
|
|
31
|
-
Skipped calls become errors in the transcript/model context; late results are rejected.
|
|
32
|
-
|
|
33
|
-
`outputSchema` is a declaration/type hint. It never parses, coerces or validates
|
|
34
|
-
returned data, including client-supplied results. It is serialized in the Agent
|
|
35
|
-
snapshot and sent as each function's `output_schema` for OpenAI Responses.
|
|
36
|
-
Completions and Anthropic do not receive that field. This does not configure the
|
|
37
|
-
Agent's final structured response. When a converter changes a JSON wire output,
|
|
38
|
-
the author must keep the Responses output schema appropriate for that output.
|
|
39
|
-
|
|
40
|
-
For multimodal results, enable the Agent's `artifacts` capability. Both implicit
|
|
41
|
-
and explicit persistence use the same request-time Artifact resolution:
|
|
42
|
-
|
|
43
|
-
- Implicit: return typed `file` parts from `toModelOutput` containing a URL,
|
|
44
|
-
base64 string or bytes. The SDK uploads them and persists Artifact IDs.
|
|
45
|
-
- Explicit: save the file through `ctx.artifacts`, then return an existing ID
|
|
46
|
-
from `execute` and reference it in `toModelOutput`; no second upload occurs.
|
|
47
|
-
|
|
48
|
-
For example, the implicit converter can map an ordinary business result:
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
toModelOutput: ({ output }) => ({
|
|
52
|
-
type: "content",
|
|
53
|
-
value: [
|
|
54
|
-
{
|
|
55
|
-
type: "file",
|
|
56
|
-
mediaType: "image/png",
|
|
57
|
-
filename: "plot.png",
|
|
58
|
-
data: { type: "url", url: new URL(output.url) },
|
|
59
|
-
// Or: data: { type: "data", data: output.base64 }
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
The explicit converter can reference a scoped Artifact:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
const viewPlot = defineTool({
|
|
69
|
-
name: "viewPlot",
|
|
70
|
-
description: "Show a saved plot to the model.",
|
|
71
|
-
input: z.object({ artifactId: z.string().uuid() }),
|
|
72
|
-
outputSchema: z.object({ artifactId: z.string().uuid() }),
|
|
73
|
-
execute: async ({ artifactId }, ctx) => {
|
|
74
|
-
const { artifact } = await ctx.artifacts!.get({ id: artifactId });
|
|
75
|
-
return { artifactId: artifact.id };
|
|
76
|
-
},
|
|
77
|
-
toModelOutput: ({ output }) => ({
|
|
78
|
-
type: "content",
|
|
79
|
-
value: [{ type: "artifact", artifactId: output.artifactId }],
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
`AgentToolModelOutput` supports AI SDK text/JSON/error outputs and content with
|
|
85
|
-
text, modern tagged `file` parts, or `{ type: "artifact", artifactId }` parts.
|
|
86
|
-
Inline or URL file parts are uploaded through the existing Artifact upload
|
|
87
|
-
capability; provider-specific file IDs must first be saved as GEA Artifacts.
|
|
88
|
-
Model context retains immutable IDs and descriptive metadata. Authorized
|
|
89
|
-
download URLs are resolved only when preparing a model request. Replaying saved
|
|
90
|
-
tool results reuses their conversion instead of uploading the same media again.
|
|
91
|
-
Tool calls already removed by context compaction are not reconstructed from UI
|
|
92
|
-
history during approval or client-tool continuation. Large-result offloading
|
|
93
|
-
replaces only text; the model-facing file references remain attached.
|
|
94
|
-
Keep the original `execute` result JSON-serializable; the converter does not
|
|
95
|
-
replace the UI result with its model-facing content.
|
|
96
|
-
Model-facing `error-text` and `error-json` remain errors in both engines without
|
|
97
|
-
changing the original successful UI result into an execution failure.
|
|
98
|
-
|
|
99
|
-
Media placement is a model capability, not a protocol inference. Configure
|
|
100
|
-
`targets["provider/model"].supportsMultimodalToolOutput` in Catalog v2: `true`
|
|
101
|
-
keeps supported media inside tool results; `false` or omitted keeps text/Artifact
|
|
102
|
-
IDs in the tool result and adds media in a user message after all results from
|
|
103
|
-
that tool-call batch. This applies independently of API format. The chosen
|
|
104
|
-
model must still support the supplied image/file media type in user messages;
|
|
105
|
-
fallback cannot add vision to a text-only model. The Completions native adapter
|
|
106
|
-
currently supports image blocks. Both the default
|
|
107
|
-
Agent Core engine and `aiSdk()` use these rules. Rebuild the Agent bundle to
|
|
108
|
-
adopt the new runtime behavior.
|
|
109
|
-
|
|
110
|
-
## Calling the Agents HTTP API
|
|
111
|
-
|
|
112
|
-
Call the public `/api/v1` API with ordinary HTTP and a fixed Agent ID. No Agent
|
|
113
|
-
SDK dependency is required for API callers:
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
const baseUrl = "https://<tenant-host>/api/v1";
|
|
117
|
-
const headers = {
|
|
118
|
-
authorization: `Bearer ${projectApiKey}`, // Or a user OAuth token.
|
|
119
|
-
"content-type": "application/json",
|
|
120
|
-
};
|
|
121
|
-
const created = await fetch(`${baseUrl}/sessions`, {
|
|
122
|
-
method: "POST",
|
|
123
|
-
headers,
|
|
124
|
-
credentials: "omit",
|
|
125
|
-
redirect: "error",
|
|
126
|
-
body: JSON.stringify({ agent_id: agentId, environment: "production" }),
|
|
127
|
-
});
|
|
128
|
-
if (!created.ok) throw new Error(`Session creation failed: ${created.status}`);
|
|
129
|
-
const session = await created.json();
|
|
130
|
-
const response = await fetch(`${baseUrl}/sessions/${session.id}/runs`, {
|
|
131
|
-
method: "POST",
|
|
132
|
-
headers,
|
|
133
|
-
credentials: "omit",
|
|
134
|
-
redirect: "error",
|
|
135
|
-
body: JSON.stringify({ input: "Hello", stream: true }),
|
|
136
|
-
});
|
|
137
|
-
if (!response.ok) throw new Error(`Run admission failed: ${response.status}`);
|
|
138
|
-
// Consume response.body as the API's SSE stream.
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Project Key access to deployed project Agents does not require OAuth or store
|
|
142
|
-
publication. OAuth access remains subject to user and tenant authorization.
|
|
143
|
-
For local development, use the CLI's separate API listener, omit authorization
|
|
144
|
-
and omit `environment` so the local API selects it. Shared HTTP schemas live in
|
|
145
|
-
`@gea-ai/contract/agent-http-api`; routes are documented by `/api/v1/openapi.json`.
|
|
146
|
-
|
|
147
|
-
Read `GET /sessions/{id}` for `active_run`, capture that Run ID, then observe
|
|
148
|
-
`GET /runs/{id}` or its stream. A later Run in the same Session does not change
|
|
149
|
-
the captured invocation. Cancellation acknowledgement is separate from final
|
|
150
|
-
cleanup. Aborting an HTTP request does not cancel a Run; a lost POST response
|
|
151
|
-
does not establish whether it was accepted, so do not automatically replay it.
|
|
152
|
-
|
|
153
|
-
The authoring SDK owns Agent execution. An Agents API client SDK is deferred.
|
|
154
|
-
The Worker `AGENTS.fetch` binding is an authenticated HTTP transport using the
|
|
155
|
-
same paths, payloads and responses. It does not introduce `agents.*`, `sessions.*`
|
|
156
|
-
or `runs.*` client methods. See the
|
|
157
|
-
[HTTP integration guide](https://musegea.com/developers/agent-api).
|
|
158
|
-
|
|
159
|
-
## Custom Agent execution URL
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
export default defineAgent({
|
|
163
|
-
name: "Support",
|
|
164
|
-
slug: "support",
|
|
165
|
-
model: "your-model",
|
|
166
|
-
http: { runPath: "/gea/support-entry" },
|
|
167
|
-
});
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
`http.runPath` selects the Agent's actual Worker execution route. Omission uses
|
|
171
|
-
`/gea/agents/<key>/run`. The route belongs to the immutable snapshot and manifest;
|
|
172
|
-
changing it does not change the Agent ID. Hosts invoke the recorded version's
|
|
173
|
-
route, including retained child Runs. OPTIONS reports the declared route without
|
|
174
|
-
creating a Session. Build/upload validation probes it and rejects mismatches and
|
|
175
|
-
conflicting declarations. Private Session control endpoints keep their standard
|
|
176
|
-
protocol paths.
|
|
177
|
-
|
|
178
|
-
Agents API dispatches **to** this Worker route. The existing public authentication
|
|
179
|
-
adapter is still present; removing its control-plane round trip is unfinished.
|
|
180
|
-
This increment does not change `http.auth` behavior or add an API client SDK.
|
|
181
|
-
|
|
182
|
-
## Existing Worker URL authentication
|
|
183
|
-
|
|
184
|
-
The following Worker URL adapter remains available while the unified Agents API
|
|
185
|
-
migration proceeds. `StudioAgentClient` is still used by existing Worker handlers;
|
|
186
|
-
it is not the fixed-ID `/api/v1` interface above.
|
|
187
|
-
|
|
188
|
-
Agent HTTP accepts Project API keys and GEA user OAuth tokens by default. Push the
|
|
189
|
-
Worker and associate the Agent with its app in **Studio → Applications**. Publish
|
|
190
|
-
the entry in Preview or Production from the Agent page. Subsequent pushes advance
|
|
191
|
-
Preview; one explicit Production publish updates all published entries in that
|
|
192
|
-
Worker. Unpublished sibling Agents remain unavailable to application users.
|
|
193
|
-
|
|
194
|
-
Every tenant uses the same two Worker URLs:
|
|
195
|
-
|
|
196
|
-
- Preview: `https://preview--worker--<workerId>.<apex>/gea/agents/<agentKey>/run`
|
|
197
|
-
- Production: `https://worker--<workerId>.<apex>/gea/agents/<agentKey>/run`
|
|
198
|
-
|
|
199
|
-
For store distribution, a Global Admin reviews application information, then
|
|
200
|
-
installs the approved application into a consumer tenant from **Published applications**.
|
|
201
|
-
Installation enables Production and the approved scopes, including `agents:invoke`;
|
|
202
|
-
it does not require or create a Workspace. Preview additionally requires publisher
|
|
203
|
-
approval for external test tenants and explicit environment enablement. The
|
|
204
|
-
application starts standard OAuth; GEA confirms the actual user and consumer tenant
|
|
205
|
-
and resolves the installation internally. Do not send an installation ID.
|
|
206
|
-
|
|
207
|
-
Use direct HTTP against platform `/api/v1/sessions` and
|
|
208
|
-
`/api/v1/sessions/{sessionId}/runs`, with a Bearer Project API Key or OAuth user
|
|
209
|
-
token and the canonical Agent ID. Project Keys retain Project service scope;
|
|
210
|
-
OAuth tokens resolve the current user and tenant installation. Neither changes
|
|
211
|
-
the Agent's default host-context execution policy. The older `studio-server`
|
|
212
|
-
client targets the retired Worker credential entry and should not be used for
|
|
213
|
-
new integrations.
|
|
214
|
-
|
|
215
|
-
## Agent Authoring Shapes
|
|
216
|
-
|
|
217
|
-
A single-main application starts with root `agent.ts` and `AGENTS.md`:
|
|
218
|
-
|
|
219
|
-
```ts
|
|
220
|
-
import { defineAgent } from "@gea-ai/agent-sdk";
|
|
221
|
-
|
|
222
|
-
export default defineAgent({
|
|
223
|
-
model: "gea-model-1",
|
|
224
|
-
name: "research-agent",
|
|
225
|
-
slug: "research-agent",
|
|
226
|
-
});
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
An Agent may instead declare capability thresholds for the SDK's first-party
|
|
230
|
-
Creative Reasoning router:
|
|
231
|
-
|
|
232
|
-
```ts
|
|
233
|
-
export default defineAgent({
|
|
234
|
-
model: "auto",
|
|
235
|
-
modelRequirements: {
|
|
236
|
-
agentic: 0.8,
|
|
237
|
-
copywriting: 0.6,
|
|
238
|
-
multimodal: 0.4,
|
|
239
|
-
speed: 0.7,
|
|
240
|
-
},
|
|
241
|
-
name: "research-agent",
|
|
242
|
-
slug: "research-agent",
|
|
243
|
-
});
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Each requirement is an optional minimum score from `0` to `1`; omitted
|
|
247
|
-
dimensions do not constrain selection. `modelRequirements` is required for
|
|
248
|
-
`model: "auto"` and rejected for a concrete model. The SDK filters its curated
|
|
249
|
-
Creative Reasoning capability table and selects the eligible model with the
|
|
250
|
-
lowest configured cost rank. It writes only the selected concrete CR gateway
|
|
251
|
-
model ID into the package snapshot, so runtime model selection does not change
|
|
252
|
-
when a later SDK updates the table.
|
|
253
|
-
|
|
254
|
-
This table is maintained in the SDK; it does not query CR model discovery,
|
|
255
|
-
verify API-key access, or read the deployment's model catalog or prices.
|
|
256
|
-
Capability scores and cost ranks are provisional routing parameters rather
|
|
257
|
-
than official platform measurements or actual catalog prices. The following
|
|
258
|
-
candidate IDs and upstream mappings were supplied by the platform owner on
|
|
259
|
-
2026-09-05; authenticated access still needs verification for each deployment.
|
|
260
|
-
The mapping is developer information and is not a product display label.
|
|
261
|
-
|
|
262
|
-
| CR gateway model ID | Upstream mapping | Cost rank | Agentic | Copywriting | Multimodal | Speed |
|
|
263
|
-
| ------------------------ | ----------------- | --------- | ------- | ----------- | ---------- | ----- |
|
|
264
|
-
| `deepseek-v4-flash` | DeepSeek V4 Flash | 1 | 0.5 | 0.5 | 0 | 1 |
|
|
265
|
-
| `crr-q-flash-20260826` | Qwen3.8 Flash | 2 | 0.55 | 0.6 | 0 | 1 |
|
|
266
|
-
| `crr-o-mini-20260710` | gpt-5.6-luna | 3 | 0.55 | 0.45 | 0.55 | 1 |
|
|
267
|
-
| `deepseek-v4-pro` | DeepSeek V4 Pro | 4 | 0.8 | 0.75 | 0 | 0.65 |
|
|
268
|
-
| `crr-q-pro-20260804` | Qwen3.8 Max | 5 | 0.85 | 0.8 | 0 | 0.6 |
|
|
269
|
-
| `crr-o-20260710` | gpt-5.6-terra | 6 | 0.8 | 0.7 | 0.75 | 0.7 |
|
|
270
|
-
| `creative-reasoning-1.5` | Claude Sonnet 5 | 7 | 0.8 | 0.9 | 0.7 | 0.65 |
|
|
271
|
-
| `crr-o-pro-20260710` | gpt-5.6-sol | 8 | 0.95 | 0.82 | 0.85 | 0.45 |
|
|
272
|
-
| `crr-a-pro-20260724` | Claude Opus 5 | 9 | 1 | 1 | 0.85 | 0.35 |
|
|
273
|
-
|
|
274
|
-
Qwen and DeepSeek currently have a zero multimodal routing score until their
|
|
275
|
-
gateway support is verified; any positive multimodal requirement excludes
|
|
276
|
-
them. Existing GPT and Claude routing thresholds are retained. With this
|
|
277
|
-
candidate set, `multimodal: 0.9` or `{ multimodal: 0.8, speed: 0.9 }` has no
|
|
278
|
-
eligible model and fails during Agent definition. Removing an auto candidate
|
|
279
|
-
does not invalidate an explicit model declaration or an existing snapshot.
|
|
280
|
-
|
|
281
|
-
For hosted execution, register these nine IDs in
|
|
282
|
-
`LLM_MODEL_CATALOG_JSON.models`, using `creative-reasoning/<gateway-model-id>`
|
|
283
|
-
targets and actual target-keyed prices. Keep the existing `gea-fast` and
|
|
284
|
-
`gea-pro` aliases and set `selectableModels: ["gea-fast", "gea-pro"]` so normal
|
|
285
|
-
product selectors show only those aliases. Studio developers can inspect the
|
|
286
|
-
immutable version's model but cannot override it in Playground.
|
|
287
|
-
|
|
288
|
-
`defineAgent({ model: "auto", ... })` provides contextual field completion for
|
|
289
|
-
all four requirements. Standalone input annotations require a model type:
|
|
290
|
-
`DefineAgentInput<"auto">` requires the capability fields, while
|
|
291
|
-
`DefineAgentInput<"crr-a-pro-20260724">` forbids them. There is no implicit
|
|
292
|
-
`string` model parameter, because it would also accept `"auto"` without its
|
|
293
|
-
requirements. Direct `defineAgent(...)` calls infer the model type.
|
|
294
|
-
|
|
295
|
-
A concrete first-party model may use any unqualified public ID, such as
|
|
296
|
-
`crr-a-pro-20260724`, `creative-reasoning-1.5`, or
|
|
297
|
-
`creative-reasoning-1.5-flash`. An explicit Creative Reasoning provider ID such
|
|
298
|
-
as `creative-reasoning/kimi-k3` is also supported. The snapshot preserves the
|
|
299
|
-
declared concrete ID.
|
|
300
|
-
|
|
301
|
-
Tools, Connectors, Hooks, referenced Skills, and local Skills are discovered
|
|
302
|
-
from conventional sibling directories. The required `slug` is the Agent's
|
|
303
|
-
stable identity inside this Worker application. It becomes the manifest and
|
|
304
|
-
runtime `agentKey`; `name` remains display metadata.
|
|
305
|
-
|
|
306
|
-
A root Agent may stay in place when the application adds more main Agents under
|
|
307
|
-
`agents/<slug>/agent.ts`. This preserves the original Agent's identity and
|
|
308
|
-
root `benchmarks/`. A directory Agent's declared slug must match its directory
|
|
309
|
-
name. Applications without a root Agent may use `agents/default/` as the
|
|
310
|
-
default source alias; that Agent still declares a real non-reserved slug. If
|
|
311
|
-
there is no root or `agents/default/`, the lexically first directory Agent owns
|
|
312
|
-
the default route. `default`, `run`, and `sessions` are reserved protocol
|
|
313
|
-
segments and cannot be Agent slugs.
|
|
314
|
-
|
|
315
|
-
```text
|
|
316
|
-
agents/default/agent.ts
|
|
317
|
-
agents/default/AGENTS.md
|
|
318
|
-
agents/support/agent.ts
|
|
319
|
-
agents/support/AGENTS.md
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
Add root `worker.ts` only when the same Worker also serves UI, business APIs,
|
|
323
|
-
assets, or application Durable Objects. The CLI generates Agent assembly and
|
|
324
|
-
prepends it to the application handler. Developers do not list Tools, Skills,
|
|
325
|
-
or Connectors again in `worker.ts`.
|
|
326
|
-
|
|
327
|
-
Generated code uses `createAgentApplicationFetch()`, which owns:
|
|
328
|
-
|
|
329
|
-
```text
|
|
330
|
-
/gea/agents/run
|
|
331
|
-
/gea/agents/<agentKey>/run
|
|
332
|
-
/gea/agents[/<agentKey>]/sessions/<sessionId>/v1/<operation>
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
Agent execution requires trusted host invocation context by default. Public
|
|
336
|
-
Agents API accepts Project API Keys and OAuth user tokens, checks their scope,
|
|
337
|
-
and admits the Session/Run before calling this Worker's configured execution URL.
|
|
338
|
-
The Worker does not authenticate those credentials again.
|
|
339
|
-
|
|
340
|
-
```ts
|
|
341
|
-
import { defineAgent } from "@gea-ai/agent-sdk";
|
|
342
|
-
|
|
343
|
-
export default defineAgent({
|
|
344
|
-
name: "support",
|
|
345
|
-
slug: "support",
|
|
346
|
-
model: "gea-model-1",
|
|
347
|
-
http: { runPath: "/gea/support-entry" },
|
|
348
|
-
});
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Omit `auth` for normal hosted execution. Set `http: { auth: false }` only when
|
|
352
|
-
this Agent's Worker HTTP entry should also admit anonymous requests. The host
|
|
353
|
-
still registers their Session/Run with project-scoped anonymous ownership.
|
|
354
|
-
Request headers and bodies cannot supply a trusted principal or parent Run.
|
|
355
|
-
This setting does not disable public Agents API Key/OAuth checks or expose
|
|
356
|
-
private Session controls. Ordinary business routes keep their own authentication.
|
|
357
|
-
|
|
358
|
-
`OPTIONS /gea/agents/<agentKey>/run` returns only the Agent key, canonical run
|
|
359
|
-
path and HTTP protocol version. It runs before authentication and does not
|
|
360
|
-
execute a model, create a Session or access platform bindings. Hosted push checks
|
|
361
|
-
this response in the final bundle locally, then the server checks the uploaded
|
|
362
|
-
deployment in Worker Runtime before accepting it. Missing, moved or incompatible
|
|
363
|
-
entries require an SDK update and rebuild. Ordinary Worker application paths
|
|
364
|
-
remain developer-owned; this conformance check does not grant Agent access.
|
|
365
|
-
|
|
366
|
-
Application pages and browser Sessions require the operator's isolated
|
|
367
|
-
`WORKER_APP_BASE_URL`. GEA-domain and path ingress preserve API access but strip
|
|
368
|
-
platform cookies and force CSP sandbox plus `nosniff`; Worker pages cannot run
|
|
369
|
-
scripts there. Application-domain pages retain their own CSP. Local `gea agent dev` uses its
|
|
370
|
-
existing trusted development identity. Raw AgentSession and Connector auth
|
|
371
|
-
operations remain private regardless of `http.auth`. Rebuild and republish old
|
|
372
|
-
Agent packages with the matching SDK/CLI to enable the new hosted handler.
|
|
373
|
-
|
|
374
|
-
The public run request is intentionally small:
|
|
375
|
-
|
|
376
|
-
```json
|
|
377
|
-
{ "chatId": "optional-continuation-id", "message": "Hello" }
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
If `chatId` is absent, the hosted managed API creates a Chat and Run and returns
|
|
381
|
-
their IDs in response headers. Local execution creates its local Session identity.
|
|
382
|
-
Callers cannot supply model-loop messages, instructions, provider options, or
|
|
383
|
-
platform-owned Run/message IDs. Each main Agent's exact `AGENTS.md` text is
|
|
384
|
-
compiled into the Worker and is never accepted from the run request.
|
|
385
|
-
|
|
386
|
-
`composeFetch()` delegates unclaimed requests to the optional application
|
|
387
|
-
Worker. Worker Runtime remains route-agnostic.
|
|
388
|
-
|
|
389
|
-
Every main Agent declares one concrete public GEA model ID or the SDK-owned
|
|
390
|
-
`auto` selector above. GEA resolves the concrete snapshot model through the
|
|
391
|
-
active Model Gateway catalog; source and artifacts contain no provider
|
|
392
|
-
credential or target configuration.
|
|
393
|
-
|
|
394
|
-
## Context strategies
|
|
395
|
-
|
|
396
|
-
Tool-output offload and context summarization are independent features. Offload is
|
|
397
|
-
on by default, including with a custom or disabled context strategy. Configure it
|
|
398
|
-
on `defineAgent`, or set `toolOutputOffload: false` to keep future outputs inline.
|
|
399
|
-
Use `context: false` to disable automatic summaries and context callbacks; set
|
|
400
|
-
both switches to false to disable both features. Already committed summaries and
|
|
401
|
-
offload references remain readable.
|
|
402
|
-
|
|
403
|
-
```ts
|
|
404
|
-
import { defineAgent } from "@gea-ai/agent-sdk";
|
|
405
|
-
import { defaultContext } from "@gea-ai/agent-sdk/context";
|
|
406
|
-
|
|
407
|
-
export default defineAgent({
|
|
408
|
-
name: "assistant",
|
|
409
|
-
slug: "assistant",
|
|
410
|
-
model: "gea-model-1",
|
|
411
|
-
toolOutputOffload: {
|
|
412
|
-
offloadAtCharacters: 4_000,
|
|
413
|
-
replaceAtCharacters: 8_000,
|
|
414
|
-
preserveRecentGroups: 5,
|
|
415
|
-
},
|
|
416
|
-
sessionTools: true,
|
|
417
|
-
context: defaultContext({
|
|
418
|
-
preserveRecentGroups: 5,
|
|
419
|
-
summarization: { triggerAtTotalTokens: 64_000 },
|
|
420
|
-
}),
|
|
421
|
-
});
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
Offload thresholds use model-visible characters. Results at the first threshold
|
|
425
|
-
are stored; those at the replacement threshold are immediately stubbed. Smaller
|
|
426
|
-
stored results remain inline in recent message groups; `preserveRecentGroups: 0`
|
|
427
|
-
replaces them immediately. The default summary strategy also releases recent-group
|
|
428
|
-
protection under its token-pressure threshold. Summary thresholds use the last
|
|
429
|
-
provider-reported `usage.totalTokens`, without token estimation.
|
|
430
|
-
|
|
431
|
-
All newly offloaded results live in the AgentSession, independent of Computer.
|
|
432
|
-
The SDK automatically supplies `readToolOutput` with a SHA-256 id and bounded
|
|
433
|
-
character ranges. Its bounded output is not offloaded again. Offload happens
|
|
434
|
-
before model-projection persistence, while the UI transcript retains full results.
|
|
435
|
-
Existing file-backed references retain their original retrieval instructions.
|
|
436
|
-
The reader remains available when a Session has stored offloads even if future
|
|
437
|
-
offloading is disabled.
|
|
438
|
-
|
|
439
|
-
The old `defaultContext({ toolOutput: ... })` option remains a deprecated fallback;
|
|
440
|
-
an explicit `toolOutputOffload` setting takes precedence. Old snapshots without the
|
|
441
|
-
new field retain their context-owned policy. Rebuilding an Agent with `context:
|
|
442
|
-
false` now requires `toolOutputOffload: false` as well to disable both features.
|
|
443
|
-
|
|
444
|
-
### Built-in model tools
|
|
445
|
-
|
|
446
|
-
- `sessionTools: true` adds `sessionList`, `sessionRead`, and `sessionSend`.
|
|
447
|
-
It defaults to false. The old `chatList()` / `chatRead()` / `chatSend()` selections
|
|
448
|
-
remain deprecated compatibility inputs; an explicit `sessionTools` setting
|
|
449
|
-
replaces them. All three tools use Agents API in hosted and local execution:
|
|
450
|
-
`sessionList({agentId?, cursor?, limit?})` lists accessible Sessions;
|
|
451
|
-
`sessionRead({sessionId, cursor?, limit?})` reads saved messages;
|
|
452
|
-
`sessionSend({sessionId, message, mode?})` sends inbox input (default `follow_up`).
|
|
453
|
-
List/read return `{items, next_cursor}`; send returns `{id, session_id, duplicate}`,
|
|
454
|
-
acknowledging delivery rather than Run completion. A Session needs a prior Run
|
|
455
|
-
before messaging. Identity and environment come from the current Run; Key service
|
|
456
|
-
principals do not need a workspace user and OAuth retains tenant/user isolation.
|
|
457
|
-
- Declaring private or referenced subagents adds `agent`, `runWait`, and
|
|
458
|
-
`runCancel` when the host admits those targets. The existing `agentTool()`
|
|
459
|
-
selection enables root self copies. Ordinary Agents do not gain Run tools just
|
|
460
|
-
because they run in an inbox. Implicit joins and descendant cleanup remain
|
|
461
|
-
runtime behavior and do not depend on model tool visibility.
|
|
462
|
-
- Offload adds `readToolOutput` automatically; do not declare it in `tools/`.
|
|
463
|
-
|
|
464
|
-
`gea agent validate` reports `builtinTools`, including each tool's source feature.
|
|
465
|
-
Generated message types include these tools. Reserved generated names are checked
|
|
466
|
-
during packaging. This inventory describes configured tools; host authorization
|
|
467
|
-
and dynamic Connector discovery are still resolved at runtime. Internal managed
|
|
468
|
-
operation IDs remain compatible with the existing host protocol; the model-facing
|
|
469
|
-
names above are camelCase.
|
|
470
|
-
|
|
471
|
-
A custom strategy is an object with optional `prepareStep`, `onStepEnd` and
|
|
472
|
-
`onEnd` callbacks, using the AI SDK 7 names. These callbacks replace the summary strategy, independently of offload. `prepareStep` receives durable `messages`, `contextSize`, `stepNumber`
|
|
473
|
-
and `runtimeContext`; returning `{ messages }` replaces the active projection
|
|
474
|
-
for subsequent steps and Runs. Returning nothing keeps it. `onStepEnd` also
|
|
475
|
-
receives that step's `usage` and `finishReason`; `onEnd` receives the main loop's
|
|
476
|
-
`totalUsage` and `finishReason`.
|
|
477
|
-
|
|
478
|
-
```ts
|
|
479
|
-
const context = {
|
|
480
|
-
async prepareStep({ messages, runtimeContext }) {
|
|
481
|
-
const memory = await loadCommittedMemory(runtimeContext);
|
|
482
|
-
return { messages: applyMemoryToCoveredPrefix(messages, memory) };
|
|
483
|
-
},
|
|
484
|
-
async onStepEnd({ messages, runtimeContext }) {
|
|
485
|
-
runtimeContext.waitUntil(precomputeMemory(messages, runtimeContext));
|
|
486
|
-
},
|
|
487
|
-
};
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
The functions in this short sketch are application-owned.
|
|
491
|
-
|
|
492
|
-
`runtimeContext` provides trusted `identity`, `auth`, declared `env`, execution
|
|
493
|
-
`environment`, typed `durableObjects`, `signal`, and the main public `modelId`.
|
|
494
|
-
Use `runtimeContext.ai.generateText()` or `runtimeContext.ai.streamText()` for
|
|
495
|
-
auxiliary calls. They inherit the main model and cancellation signal, attach the
|
|
496
|
-
current trace, and record the call's usage automatically before application text
|
|
497
|
-
validation or memory writes. Do not also call `recordUsage` for these calls.
|
|
498
|
-
|
|
499
|
-
For compatibility, `model(modelId?)` still resolves an AI SDK model. Calls made
|
|
500
|
-
through that model continue to require explicit `recordUsage({ model, usage,
|
|
501
|
-
label?, status? })`; unknown usage is `null`. The SDK assigns the call id and
|
|
502
|
-
tracks its Session write automatically.
|
|
503
|
-
`writeToolOutput` is a writer returning `{ artifactUri }`, or `null` if storage
|
|
504
|
-
is unavailable. Its input is `{ content, sha256, toolCallId, toolName }`.
|
|
505
|
-
|
|
506
|
-
`runtimeContext.updateMessages(messages)` persists a replacement from an awaited
|
|
507
|
-
foreground callback, including the final step or `onEnd`. Background work stores
|
|
508
|
-
candidate memory in a DO; a later foreground callback applies it. The Worker
|
|
509
|
-
waits for registered work before publishing its final success and usage, including
|
|
510
|
-
when Computer is disabled. `metadata.modelCalls` records each main-model step and
|
|
511
|
-
auxiliary call with a stable call id, Run id, model, source, optional label, status,
|
|
512
|
-
completion time and usage. `metadata.totalUsage` is their known usage sum;
|
|
513
|
-
`metadata.contextUsage` retains the auxiliary view. Hosted settlement prices each
|
|
514
|
-
call using its own catalog target and writes a separate idempotent usage event.
|
|
515
|
-
A completed model call stays completed even if the containing Run later fails.
|
|
516
|
-
Unhandled callback or background errors fail the Run; completed model messages
|
|
517
|
-
and registered usage survive that failure. Pass `signal` into external work so cancellation can finish promptly.
|
|
518
|
-
|
|
519
|
-
AgentSession owns the active projection and separate transcript. Custom
|
|
520
|
-
observations, reflection and coverage state belong in the application's chat DO.
|
|
521
|
-
Commit memory and coverage together before removing the covered message prefix.
|
|
522
|
-
Existing summary metadata is included when a custom callback reads messages, and
|
|
523
|
-
is no longer separately injected after that callback replaces the projection.
|
|
524
|
-
`stepNumber` is local to a Run, not a durable chat cursor.
|
|
525
|
-
|
|
526
|
-
Context callbacks execute in the Agent bundle; snapshots contain only serializable
|
|
527
|
-
descriptors and default recipe options. Ordinary imported modules are sufficient.
|
|
528
|
-
Upgrade the SDK and rebuild/publish existing Agents to use the API. `waitUntil`
|
|
529
|
-
covers the current invocation; it does not schedule future Runs or replay a model
|
|
530
|
-
call after a crash.
|
|
531
|
-
|
|
532
|
-
## CLI Workflow
|
|
533
|
-
|
|
534
|
-
Local validation, development, and packing need no hosted Agent record:
|
|
535
|
-
|
|
536
|
-
```bash
|
|
537
|
-
gea agent validate --json '{"cwd":"."}'
|
|
538
|
-
gea agent dev --json '{"cwd":"."}'
|
|
539
|
-
gea agent eval --json '{"cwd":".","judgeModel":"gea-model-1"}'
|
|
540
|
-
gea agent pack --json '{"cwd":"."}'
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
`gea agent dev` treats every unqualified model ID, plus explicit
|
|
544
|
-
`creative-reasoning/<model>` IDs, as first-party Creative Reasoning models. It
|
|
545
|
-
calls Creative Reasoning directly when `CREATIVE_REASONING_API_KEY` is present;
|
|
546
|
-
when the key is absent it falls back to the hosted web model proxy and the
|
|
547
|
-
current `gea login` Workspace. An explicit `{"modelSource":"hosted"}` keeps
|
|
548
|
-
hosted routing. `{"modelSource":"local"}` forces local routing and therefore
|
|
549
|
-
requires the Creative Reasoning key for first-party models; other qualified
|
|
550
|
-
local providers continue to use their configured local catalog.
|
|
551
|
-
`gea agent eval` applies the same decision to both Agent models and the active
|
|
552
|
-
`judgeModel`, so a direct evaluation catalog contains every model the run uses.
|
|
553
|
-
|
|
554
|
-
Native Anthropic calls, including `crr-a-*` and `creative-reasoning-1.5`, apply
|
|
555
|
-
the SDK's shared rolling prompt-cache policy before provider serialization.
|
|
556
|
-
System prompts, conversation prefixes, and eligible Tool definitions retain
|
|
557
|
-
cache markers across model steps and turns. Markers belong only to outbound
|
|
558
|
-
requests and never enter the stored AgentSession context. Hosted calls retain
|
|
559
|
-
their existing proxy-owned cache policy.
|
|
560
|
-
|
|
561
|
-
`gea agent eval` discovers Cases and inherited Judges from the Benchmark next
|
|
562
|
-
to each main Agent's `tools/`: root `benchmarks/` for the root Agent, including
|
|
563
|
-
after additional main Agents are added, and `agents/<slug>/benchmarks/` for
|
|
564
|
-
directory Agents. It runs each Case through that main Agent's stable slug route
|
|
565
|
-
and writes results under `.gea/evals`. Use `{"agentKey":"support"}` to select
|
|
566
|
-
one main Agent. A Case's optional
|
|
567
|
-
`expected` value enables the built-in Autoeval Judge. Author semantic rubrics
|
|
568
|
-
as `*.judge.md`; author deterministic trajectory checks as `*.judge.ts` with
|
|
569
|
-
the `./evals` SDK export. Autoeval may query bounded run evidence across
|
|
570
|
-
multiple model steps and finishes by calling a structured result Tool; it does
|
|
571
|
-
not require the model's text response to be JSON:
|
|
572
|
-
|
|
573
|
-
```ts
|
|
574
|
-
import { defineJudge } from "@gea-ai/agent-sdk/evals";
|
|
575
|
-
|
|
576
|
-
export default defineJudge(({ messages }) => {
|
|
577
|
-
const usedSearch = messages.some((message) =>
|
|
578
|
-
message.parts.some((part) => part.type === "tool-search"),
|
|
579
|
-
);
|
|
580
|
-
return {
|
|
581
|
-
reason: usedSearch ? "Search was used." : "Search was not used.",
|
|
582
|
-
score: usedSearch ? 1 : 0,
|
|
583
|
-
};
|
|
584
|
-
});
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
`gea agent dev` and `gea agent eval` generate `.gea/bindings.d.ts` from the
|
|
588
|
-
owning main Agent's `tools/` and snapshot-known runtime Tool names. This
|
|
589
|
-
registers the canonical root SDK types:
|
|
590
|
-
|
|
591
|
-
```ts
|
|
592
|
-
import agent from "./agent";
|
|
593
|
-
import type {
|
|
594
|
-
AgentMessage,
|
|
595
|
-
AgentMessageFor,
|
|
596
|
-
InferAgentMessage,
|
|
597
|
-
} from "@gea-ai/agent-sdk";
|
|
598
|
-
|
|
599
|
-
type DefaultMessage = AgentMessage;
|
|
600
|
-
type SupportMessage = AgentMessageFor<"support">;
|
|
601
|
-
type ThisAgentMessage = InferAgentMessage<typeof agent>;
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
All three are ordinary AI SDK `UIMessage` types. Static custom `tool-*` parts
|
|
605
|
-
preserve Tool names, Zod input types, and return types. Snapshot-known Computer
|
|
606
|
-
and Connector Tools preserve their concrete `tool-*` names with generic input
|
|
607
|
-
and output. MCP Tool parts use the qualified template
|
|
608
|
-
`tool-<alias>__${string}` because their catalog is runtime-discovered; truly
|
|
609
|
-
unqualified runtime Tools remain `dynamic-tool` parts. SDK-first Agent Workers
|
|
610
|
-
currently emit no custom `data-*` parts, so Legacy chat data parts are not
|
|
611
|
-
included. Code Judges consume the same types rather than defining an
|
|
612
|
-
Eval-specific message model.
|
|
613
|
-
`InferAgentMessage<typeof agent>` resolves to `never` when the generated
|
|
614
|
-
registry is absent or its Agent slug does not match, rather than silently
|
|
615
|
-
falling back to an unrelated Tool catalog.
|
|
616
|
-
|
|
617
|
-
Studio also runs `defineApiConnector`, `defineMcpConnector`, and deployment-enabled
|
|
618
|
-
built-in `geaConnect` providers through the managed Host. All use existing
|
|
619
|
-
Project/Agent Connections, isolated by Preview/Production and application
|
|
620
|
-
principal. No database migration or personal credential inheritance is involved.
|
|
621
|
-
API keys default to `connection: { principalType: "agent" }`; OAuth and
|
|
622
|
-
`geaConnect` default to `"user"`. All three helpers accept an explicit
|
|
623
|
-
`connection: { principalType: "agent" | "user" }`. No-auth API/MCP endpoints
|
|
624
|
-
need no Connection. Custom executable `defineConnector` ownership stays unchanged.
|
|
625
|
-
|
|
626
|
-
Configure Agent-owned credentials in Project Connections or an Agent override.
|
|
627
|
-
User-owned authorization links bind the application's supplied principal; missing
|
|
628
|
-
user identity returns `principal_required`. OAuth client variables come from the
|
|
629
|
-
selected environment. Register `${APP_BASE_URL}/api/agent-connectors/oauth/callback`
|
|
630
|
-
for hosted OAuth, including the deployment Google OAuth client used by Google Drive.
|
|
631
|
-
API keys are submitted on a public, state-bound setup page; OAuth uses PKCE;
|
|
632
|
-
Feishu uses the host's isolated managed CLI. Credentials and refresh state remain
|
|
633
|
-
encrypted in the original Connection scope and never enter Worker code.
|
|
634
|
-
|
|
635
|
-
Rebuild old `geaConnect` snapshots to declare Studio ownership. Supported native
|
|
636
|
-
providers are Google Drive, Feishu, Social Search, and WeChat Official Account,
|
|
637
|
-
subject to deployment availability. Other platform resource references should
|
|
638
|
-
use `defineApiConnector` or `defineMcpConnector` with an explicit endpoint.
|
|
639
|
-
CLI upload preparation rejects old personal-authorization declarations and GEA
|
|
640
|
-
user identity injection with the Connector alias, key, runtime, and reason.
|
|
641
|
-
The server additionally checks native provider availability before publication.
|
|
642
|
-
|
|
643
|
-
Configure a package-local API or MCP Connector without uploading its
|
|
644
|
-
credential:
|
|
645
|
-
|
|
646
|
-
```bash
|
|
647
|
-
gea agent connect exa-market-intelligence
|
|
648
|
-
```
|
|
649
|
-
|
|
650
|
-
An MCP Connector declares only its stable server and authentication boundary:
|
|
651
|
-
|
|
652
|
-
```ts
|
|
653
|
-
import { defineMcpConnector, noAuth } from "@gea-ai/agent-sdk";
|
|
654
|
-
|
|
655
|
-
export default defineMcpConnector({
|
|
656
|
-
auth: noAuth(),
|
|
657
|
-
key: "product-docs",
|
|
658
|
-
name: "Product Docs",
|
|
659
|
-
serverUrl: "https://mcp.example.com/mcp",
|
|
660
|
-
}).require();
|
|
661
|
-
```
|
|
662
|
-
|
|
663
|
-
Its current Tools and schemas are discovered at the start of every run and
|
|
664
|
-
exposed as `product-docs__<tool>`. They are not persisted in the Agent Package.
|
|
665
|
-
|
|
666
|
-
API-key input is hidden. OAuth uses Authorization Code plus S256 PKCE through
|
|
667
|
-
`http://127.0.0.1:8788/oauth/callback`. Credentials stay under `~/.gea`,
|
|
668
|
-
scoped to canonical project path and Connector definition, and are reread for
|
|
669
|
-
each local Tool call.
|
|
670
|
-
|
|
671
|
-
Platform Connectors declared with `geaConnect(...)` are called through the
|
|
672
|
-
Workspace selected by `gea login` and `gea workspace use`; their platform-owned
|
|
673
|
-
credentials are never copied into the local project. This same local Connector
|
|
674
|
-
Host behavior is used by both `gea agent dev` and `gea agent eval`.
|
|
675
|
-
|
|
676
|
-
After `gea workspace use`, publish the complete Worker application:
|
|
677
|
-
|
|
678
|
-
```bash
|
|
679
|
-
gea agent push --json '{"cwd":".","slug":"product-worker"}'
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
The command uploads one generic Worker deployment and registers every main
|
|
683
|
-
Agent in Studio by Worker plus Agent key. The new deployment becomes Preview.
|
|
684
|
-
It never creates or updates Legacy `app_resource` or resource-package rows.
|
|
685
|
-
Preview and Production promotion are Worker-wide.
|
|
686
|
-
|
|
687
|
-
Use a Studio Agent ID to start its selected environment:
|
|
688
|
-
|
|
689
5
|
```bash
|
|
690
6
|
npm install @gea-ai/agent-sdk
|
|
691
7
|
```
|
|
692
8
|
|
|
693
9
|
[Developer documentation](https://musegea.com/developers/agent-development)
|
|
694
|
-
|
|
695
|
-
## Model identity and output limits
|
|
696
|
-
|
|
697
|
-
Set an optional per-model-call output budget on the Agent definition:
|
|
698
|
-
|
|
699
|
-
```ts
|
|
700
|
-
import { defineAgent } from "@gea-ai/agent-sdk";
|
|
701
|
-
|
|
702
|
-
export default defineAgent({
|
|
703
|
-
name: "Research assistant",
|
|
704
|
-
slug: "research",
|
|
705
|
-
model: "creative-reasoning-1.5",
|
|
706
|
-
maxOutputTokens: 32_000,
|
|
707
|
-
});
|
|
708
|
-
```
|
|
709
|
-
|
|
710
|
-
The default engine is Rust Agent Core. Select either engine explicitly when needed:
|
|
711
|
-
|
|
712
|
-
```ts
|
|
713
|
-
import { defineAgent, aiSdk } from "@gea-ai/agent-sdk";
|
|
714
|
-
import { agentCore } from "@gea-ai/agent-sdk/agent-core";
|
|
715
|
-
|
|
716
|
-
// Omit engine for Core defaults, or configure it explicitly.
|
|
717
|
-
const agent = defineAgent({
|
|
718
|
-
name: "Assistant",
|
|
719
|
-
slug: "assistant",
|
|
720
|
-
model: "auto",
|
|
721
|
-
modelRequirements: { agentic: 1 },
|
|
722
|
-
engine: agentCore({ maxToolConcurrency: 4 }),
|
|
723
|
-
});
|
|
724
|
-
// Use engine: aiSdk() to retain the AI SDK execution contract.
|
|
725
|
-
// The string forms "agent-core" and "ai-sdk" are also accepted.
|
|
726
|
-
```
|
|
727
|
-
|
|
728
|
-
Existing deployed bundles keep their engine. Adopting this default requires an SDK
|
|
729
|
-
upgrade and rebuild. New CLI builds declare `ai-generation-v1`; update Worker
|
|
730
|
-
Runtime before deploying them. Core remains the supported GEA executor subset,
|
|
731
|
-
not the complete AI SDK callback/provider-tool API. No runtime engine fallback
|
|
732
|
-
occurs after a model request or tool effect.
|
|
733
|
-
|
|
734
|
-
Context strategies can call `runtimeContext.ai.generateText()` or
|
|
735
|
-
`runtimeContext.ai.streamText()` with a Catalog model ID (omission uses the Agent
|
|
736
|
-
model), AI SDK-shaped messages, instructions, output budget and an optional label.
|
|
737
|
-
These methods accept the same `model: "auto"` + `modelRequirements`,
|
|
738
|
-
`maxOutputTokens`, and `providerOptions` settings as `defineAgent`. Auto uses the
|
|
739
|
-
same selection policy; the selected model must exist in the deployment Catalog.
|
|
740
|
-
Only the model is inherited from the Agent. Auxiliary output budgets and provider
|
|
741
|
-
options use explicit call settings or Catalog defaults.
|
|
742
|
-
These methods inherit cancellation and trace context and automatically record
|
|
743
|
-
auxiliary usage. Do not additionally call `recordUsage()` for the same call.
|
|
744
|
-
`runtimeContext.model()` and manual accounting remain available for existing
|
|
745
|
-
strategies. Ordinary Workers have the independent `env.AI` generation binding.
|
|
746
|
-
|
|
747
|
-
`maxOutputTokens` must be a positive integer. It applies to each model call in the AI SDK engine and `agentCore`, subject to the provider's supported limits; it is not a total task budget. An Agent value overrides `LLM_MODEL_CATALOG_JSON.targets[provider/model].maxOutputTokens`, which in turn overrides the provider adapter's default. Each private or referenced Agent uses its own definition, while self copies use the source definition. Agent Core's explicit per-step `generation.max_output_tokens` may override the Agent or catalog baseline for that step.
|
|
748
|
-
|
|
749
|
-
The explicit AI SDK engine resolves Anthropic capabilities from the upstream model identity. Gateway requests retain the configured routing ID; public model IDs and usage attribution are unchanged. Deployments should set the target's `maxOutputTokens` for gateway aliases whose provider identity is intentionally hidden, so their output budget does not depend on an adapter's unknown-model fallback. Explicit Agent and AI SDK call limits still apply.
|
|
750
|
-
|
|
751
|
-
Native Workers request the catalog target and output-limit capability from the AI binding. This requires updating Worker Runtime and rebuilding the Agent with the new SDK. Existing SDK bundles retain their descriptor format because both fields are opt-in. The hosted AI SDK proxy resolves the same defaults on the server; the `agentCore` engine receives them through its existing model descriptor.
|
|
752
|
-
|
|
753
|
-
## Provider reasoning options
|
|
754
|
-
|
|
755
|
-
`defineAgent` accepts AI SDK-shaped `providerOptions`. This release exposes the
|
|
756
|
-
reasoning controls of the `openai` and `anthropic` protocols:
|
|
757
|
-
|
|
758
|
-
```ts
|
|
759
|
-
export default defineAgent({
|
|
760
|
-
name: "Research assistant",
|
|
761
|
-
slug: "research",
|
|
762
|
-
model: "creative-reasoning-1.5",
|
|
763
|
-
providerOptions: {
|
|
764
|
-
anthropic: {
|
|
765
|
-
effort: "low",
|
|
766
|
-
thinking: { type: "adaptive" },
|
|
767
|
-
},
|
|
768
|
-
},
|
|
769
|
-
});
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
For an OpenAI-compatible model, use
|
|
773
|
-
`providerOptions: { openai: { reasoningEffort: "low" } }`. The SDK maps this
|
|
774
|
-
public namespace to the existing OpenAI-compatible adapter; no gateway-specific
|
|
775
|
-
namespace, upstream URL or credential is needed. Both namespaces may be declared;
|
|
776
|
-
only the selected model's protocol consumes its options.
|
|
777
|
-
|
|
778
|
-
- `openai.reasoningEffort`: `none`, `minimal`, `low`, `medium`, `high`, or `xhigh`.
|
|
779
|
-
- `anthropic.effort`: `low`, `medium`, `high`, `xhigh`, or `max`.
|
|
780
|
-
- `anthropic.thinking`: `{ type: "adaptive", display?: "omitted" | "summarized" }`,
|
|
781
|
-
`{ type: "enabled", budgetTokens: 2048 }`, or `{ type: "disabled" }`.
|
|
782
|
-
Enabled thinking requires an explicit integer budget of at least 1,024 tokens.
|
|
783
|
-
|
|
784
|
-
Supported values depend on the actual model. The provider validates model-specific
|
|
785
|
-
support; GEA does not map effort levels to token budgets. Unknown namespaces,
|
|
786
|
-
unknown fields and invalid shapes fail at declaration/publication. Omit the
|
|
787
|
-
options to retain existing defaults. The public `AgentModelProviderOptions` type
|
|
788
|
-
is exported by the SDK and contract package.
|
|
789
|
-
|
|
790
|
-
These settings are frozen in each Agent's published snapshot and apply to its
|
|
791
|
-
main loop in both the AI SDK engine and `agentCore`, including model
|
|
792
|
-
switches and continuation. Private/referenced Agents keep their own settings;
|
|
793
|
-
self copies use the source definition. Explicit Core per-step generation settings
|
|
794
|
-
override the baseline for that step. Context strategies' auxiliary model calls
|
|
795
|
-
continue to own their call options.
|
|
796
|
-
|
|
797
|
-
Adoption requires an updated SDK, a server/CLI using the updated snapshot contract,
|
|
798
|
-
and rebuilding and publishing the immutable Agent bundle. This adds no per-request
|
|
799
|
-
override to the public `/run` API or Studio composer. See the upstream
|
|
800
|
-
[OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai) and
|
|
801
|
-
[Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic) options.
|
|
802
|
-
|
|
803
|
-
## Agent delegation through Sessions and Runs
|
|
804
|
-
|
|
805
|
-
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.
|
|
806
|
-
|
|
807
|
-
References are explicit default exports from `subagents/<alias>.ts`:
|
|
808
|
-
|
|
809
|
-
```ts
|
|
810
|
-
import { defineAgentReference, defineRemoteAgent } from "@gea-ai/agent-sdk";
|
|
811
|
-
|
|
812
|
-
// Same Worker, checked against the generated WorkerAgentRegistry.
|
|
813
|
-
const sales = defineAgentReference({
|
|
814
|
-
slug: "sales",
|
|
815
|
-
description: "Sales analysis",
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
// Same Agents API: the host revalidates the calling Run's authority.
|
|
819
|
-
const legal = defineRemoteAgent({
|
|
820
|
-
agentId: "bb141b12-6f63-43bd-8ab6-77930916d3ef",
|
|
821
|
-
description: "Legal review",
|
|
822
|
-
});
|
|
823
|
-
|
|
824
|
-
// Another service: use its API root and canonical Agent ID.
|
|
825
|
-
const external = defineRemoteAgent({
|
|
826
|
-
agentId: "34910649-2df7-4978-8794-8d8fb72f16cd",
|
|
827
|
-
url: "https://legal.example.com/api/v1",
|
|
828
|
-
environment: "production",
|
|
829
|
-
description: "External legal review",
|
|
830
|
-
auth: { bearerTokenEnv: "LEGAL_AGENT_KEY" },
|
|
831
|
-
});
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
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.
|
|
835
|
-
|
|
836
|
-
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.
|
|
837
|
-
|
|
838
|
-
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).
|
|
839
|
-
|
|
840
|
-
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.
|
|
841
|
-
|
|
842
|
-
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.
|
|
843
|
-
|
|
844
|
-
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.
|
|
845
|
-
|
|
846
|
-
## Fetch-style Agents binding
|
|
847
|
-
|
|
848
|
-
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:
|
|
849
|
-
|
|
850
|
-
```ts
|
|
851
|
-
const response = await env.AGENTS.fetch("/api/v1/agents?limit=20");
|
|
852
|
-
const agents = await response.json();
|
|
853
|
-
```
|
|
854
|
-
|
|
855
|
-
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.
|
|
856
|
-
|
|
857
|
-
## Call a Studio Agent with AI SDK
|
|
858
|
-
|
|
859
|
-
Use `StudioAgentChatTransport` from `@gea-ai/agent-sdk/studio-client` with
|
|
860
|
-
`useChat` from `@ai-sdk/react` in the browser, and `StudioAgentClient` from
|
|
861
|
-
`@gea-ai/agent-sdk/studio-server` on your backend. The browser authenticates to
|
|
862
|
-
your application; only your backend sends the Project key to GEA. The transport
|
|
863
|
-
reads response identity headers and reuses the server Chat on later turns.
|
|
864
|
-
|
|
865
|
-
```tsx
|
|
866
|
-
import { useChat } from "@ai-sdk/react";
|
|
867
|
-
import { StudioAgentChatTransport } from "@gea-ai/agent-sdk/studio-client";
|
|
868
|
-
import { useState } from "react";
|
|
869
|
-
|
|
870
|
-
// Inside your component:
|
|
871
|
-
const [transport] = useState(
|
|
872
|
-
() =>
|
|
873
|
-
new StudioAgentChatTransport({
|
|
874
|
-
api: "/api/agent", // Your authenticated application path, without /run.
|
|
875
|
-
headers: { "x-csrf-token": csrfToken }, // From your application session.
|
|
876
|
-
onRun: ({ chatId, runId, requestId }) => {
|
|
877
|
-
console.log({ chatId, runId, requestId });
|
|
878
|
-
},
|
|
879
|
-
}),
|
|
880
|
-
);
|
|
881
|
-
const { messages, sendMessage, resumeStream } = useChat({ transport });
|
|
882
|
-
```
|
|
883
|
-
|
|
884
|
-
The transport sends your application's session cookies by default. It accepts
|
|
885
|
-
only same-origin paths and sends no business metadata. Set `headers` to your
|
|
886
|
-
application's CSRF token or user access token as appropriate.
|
|
887
|
-
|
|
888
|
-
Create a key in **Project → API Key** and copy the matching URL from the
|
|
889
|
-
Agent detail overview. Production uses `worker--<workerId>.<apex>`; preview
|
|
890
|
-
uses `preview--worker--<workerId>.<apex>`. Both use `/gea/agents/<agentKey>/run`.
|
|
891
|
-
Remove the trailing `/run` for the SDK `api` option, which appends operation
|
|
892
|
-
paths itself. The key must match the URL environment.
|
|
893
|
-
|
|
894
|
-
On the backend, configure the GEA destination and key from server environment:
|
|
895
|
-
|
|
896
|
-
```ts
|
|
897
|
-
import { StudioAgentClient } from "@gea-ai/agent-sdk/studio-server";
|
|
898
|
-
import { env } from "./env";
|
|
899
|
-
|
|
900
|
-
const agent = new StudioAgentClient({
|
|
901
|
-
api: env.GEA_AGENT_API_URL, // Agent base URL without /run.
|
|
902
|
-
token: env.GEA_PROJECT_API_KEY,
|
|
903
|
-
});
|
|
904
|
-
```
|
|
905
|
-
|
|
906
|
-
### Worker build plugins
|
|
907
|
-
|
|
908
|
-
The Node-only `@gea-ai/agent-sdk/worker-build-plugins` entry exports the shared
|
|
909
|
-
esbuild plugins used by CLI Worker bundles and the hosted Judge runtime template.
|
|
910
|
-
Build tools that use this entry must install the optional `esbuild` peer. Agent
|
|
911
|
-
runtime code should use the ordinary SDK or `evals` entry instead.
|
|
912
|
-
|
|
913
|
-
## Calling the Agents HTTP API
|
|
914
|
-
|
|
915
|
-
Applications call `/api/v1` using `fetch`, `curl` or another HTTP client. Payloads
|
|
916
|
-
use JSON and streams use AI SDK UI-message SSE. The Agent SDK owns Agent execution;
|
|
917
|
-
calling the HTTP API does not require an SDK client.
|
|
918
|
-
|
|
919
|
-
Hosted requests use a Project API Key or a Project user OAuth token. An independently running
|
|
920
|
-
`gea agent dev --model-source local --api-port 8788` exposes token-free local access:
|
|
921
|
-
|
|
922
|
-
```sh
|
|
923
|
-
curl --fail-with-body http://127.0.0.1:8788/api/v1/agents
|
|
924
|
-
|
|
925
|
-
curl --fail-with-body http://127.0.0.1:8788/api/v1/files \
|
|
926
|
-
-F "file=@notes.txt;type=text/plain"
|
|
927
|
-
```
|
|
928
|
-
|
|
929
|
-
Prepare `notes.txt` before uploading; no Agent or Session is needed.
|
|
930
|
-
Send `{ type: "file", file_id: file.id }` in a Run input to use the
|
|
931
|
-
uploaded or generated file: Artifact.id is the same File ID. `artifact_id` remains
|
|
932
|
-
a compatibility alias. `/files` lists and manages both uploads and outputs. Exact IDs retain their content
|
|
933
|
-
across later saves and restart. `listArtifacts` lists only the current Session's outputs;
|
|
934
|
-
public `/artifacts` queries all Sessions for the application user.
|
|
935
|
-
Connections are managed through `/agents/{id}/connections`; follow the returned
|
|
936
|
-
`actions`, since environment credentials and externally supplied resolvers are
|
|
937
|
-
read-only through the local API.
|
|
938
|
-
|
|
939
|
-
See the [HTTP integration guide](https://musegea.com/developers/agent-api) and the
|
|
940
|
-
running server's `/api/v1/openapi.json` for routes and payloads.
|
|
941
|
-
|
|
942
|
-
API callers use ordinary HTTP. Subagents reuse Agent/Session/Run resources,
|
|
943
|
-
with parent/child coordination owned by logical Runs in the SDK Session inbox.
|
|
944
|
-
Internal Task logic has been removed. Worker fetch bindings and remote references
|
|
945
|
-
use the same API, which invokes each Agent at its versioned custom or standard
|
|
946
|
-
Worker route. See the [HTTP integration guide](https://musegea.com/developers/agent-api)
|
|
947
|
-
for authentication and Session/Run operations.
|