@gea-ai/agent-sdk 0.1.260911-alpha.2 → 0.1.260914-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +625 -0
- package/dist/agent-call.d.ts +1 -2
- package/dist/agent-call.js +44 -10
- package/dist/agent-channel-author-runtime.d.ts +13 -14
- package/dist/agent-channel-author-runtime.js +0 -1
- package/dist/agent-channel-receiver.d.ts +0 -1
- package/dist/agent-channel-receiver.js +0 -1
- package/dist/agent-channel-runtime.d.ts +0 -1
- package/dist/agent-channel-runtime.js +0 -1
- package/dist/agent-channel-worker.d.ts +0 -1
- package/dist/agent-channel-worker.js +0 -1
- package/dist/agent-computer-scope.d.ts +0 -1
- package/dist/agent-computer-scope.js +0 -1
- package/dist/agent-computer-session.d.ts +0 -1
- package/dist/agent-computer-session.js +0 -1
- package/dist/agent-core-engine.d.ts +4 -2
- package/dist/agent-core-engine.js +0 -1
- package/dist/agent-core-output.d.ts +0 -1
- package/dist/agent-core-output.js +0 -1
- package/dist/agent-core.d.ts +0 -1
- package/dist/agent-core.js +0 -1
- package/dist/agent-http.d.ts +18 -5
- package/dist/agent-http.js +51 -12
- package/dist/agent-session-execution.d.ts +0 -1
- package/dist/agent-session-execution.js +0 -1
- package/dist/agent-session-inbox.d.ts +12 -0
- package/dist/agent-session-inbox.js +610 -0
- package/dist/agent-session-runner.d.ts +34 -0
- package/dist/agent-session-runner.js +124 -0
- package/dist/agent-session-tasks.d.ts +0 -1
- package/dist/agent-session-tasks.js +18 -3
- package/dist/agent-session.d.ts +2 -1
- package/dist/agent-session.js +4 -1
- package/dist/agent-task-host.d.ts +64 -0
- package/dist/agent-task-host.js +331 -0
- package/dist/agent-worker-attachments.d.ts +0 -1
- package/dist/agent-worker-attachments.js +0 -1
- package/dist/agent-worker-context.d.ts +2 -1
- package/dist/agent-worker-context.js +155 -118
- package/dist/agent-worker.d.ts +7 -1
- package/dist/agent-worker.js +328 -87
- package/dist/artifacts.d.ts +0 -1
- package/dist/artifacts.js +0 -1
- package/dist/cache-control.d.ts +0 -1
- package/dist/cache-control.js +0 -1
- package/dist/channels/feishu-codec.d.ts +0 -1
- package/dist/channels/feishu-codec.js +0 -1
- package/dist/channels/feishu-inbound.d.ts +0 -1
- package/dist/channels/feishu-inbound.js +0 -1
- package/dist/channels/feishu-output.d.ts +72 -2
- package/dist/channels/feishu-output.js +203 -15
- package/dist/channels/feishu-websocket.d.ts +0 -1
- package/dist/channels/feishu-websocket.js +0 -1
- package/dist/channels/feishu.d.ts +16 -1
- package/dist/channels/feishu.js +0 -1
- package/dist/channels/index.d.ts +0 -1
- package/dist/channels/index.js +0 -1
- package/dist/computer/just-bash.d.ts +0 -1
- package/dist/computer/just-bash.js +0 -1
- package/dist/computer-tools.d.ts +0 -1
- package/dist/computer-tools.js +0 -1
- package/dist/computer.d.ts +0 -1
- package/dist/computer.js +0 -1
- package/dist/context-runtime.d.ts +1 -2
- package/dist/context-runtime.js +81 -24
- package/dist/context.d.ts +0 -1
- package/dist/context.js +3 -3
- package/dist/creative-reasoning-auto.d.ts +0 -1
- package/dist/creative-reasoning-auto.js +0 -1
- package/dist/evals.d.ts +1 -1
- package/dist/evals.js +10 -5
- package/dist/experimental/agent-core-language-model.d.ts +12 -0
- package/dist/experimental/agent-core-language-model.js +273 -0
- package/dist/experimental/agent-core-messages.d.ts +0 -1
- package/dist/experimental/agent-core-messages.js +0 -1
- package/dist/experimental/agent-core-model.d.ts +4 -0
- package/dist/experimental/agent-core-model.js +249 -0
- package/dist/experimental/agent-core-options.d.ts +0 -1
- package/dist/experimental/agent-core-options.js +0 -1
- package/dist/experimental/agent-core-providers.d.ts +11 -0
- package/dist/experimental/agent-core-providers.js +25 -0
- package/dist/experimental/agent-core-tools.d.ts +14 -0
- package/dist/experimental/agent-core-tools.js +79 -0
- package/dist/experimental/agent-core-ui.d.ts +0 -1
- package/dist/experimental/agent-core-ui.js +0 -1
- package/dist/experimental/agent-core-v3.d.ts +2 -0
- package/dist/experimental/agent-core-v3.js +80 -0
- package/dist/experimental/agent-core-worker-tools.d.ts +0 -1
- package/dist/experimental/agent-core-worker-tools.js +56 -40
- package/dist/experimental/agent-core.d.ts +0 -1
- package/dist/experimental/agent-core.js +0 -1
- package/dist/index.d.ts +14 -4
- package/dist/index.js +17 -8
- package/dist/remote-agent.d.ts +22 -0
- package/dist/remote-agent.js +149 -0
- package/dist/session-authority.d.ts +134 -0
- package/dist/session-authority.js +60 -0
- package/dist/skill-tool.d.ts +0 -1
- package/dist/skill-tool.js +0 -1
- package/dist/studio-client.d.ts +0 -1
- package/dist/studio-client.js +0 -1
- package/dist/studio-server.d.ts +4 -4
- package/dist/studio-server.js +12 -5
- package/dist/studio-stream-replay.d.ts +0 -1
- package/dist/studio-stream-replay.js +0 -1
- package/dist/trace-context.d.ts +3 -1
- package/dist/trace-context.js +11 -8
- package/dist/tracing.d.ts +3 -1
- package/dist/tracing.js +150 -44
- package/dist/vendor/ai-ui/json-to-sse-transform-stream.d.ts +0 -1
- package/dist/vendor/ai-ui/json-to-sse-transform-stream.js +0 -1
- package/dist/vendor/ai-ui/to-ui-message-chunk.d.ts +0 -1
- package/dist/vendor/ai-ui/to-ui-message-chunk.js +0 -1
- package/dist/vendor/ai-ui/ui-message-stream-headers.d.ts +0 -1
- package/dist/vendor/ai-ui/ui-message-stream-headers.js +0 -1
- package/dist/vendor/codex-patch/codex-whitespace.d.ts +0 -1
- package/dist/vendor/codex-patch/codex-whitespace.js +0 -1
- package/dist/vendor/codex-patch/errors.d.ts +0 -1
- package/dist/vendor/codex-patch/errors.js +0 -1
- package/dist/vendor/codex-patch/matcher.d.ts +0 -1
- package/dist/vendor/codex-patch/matcher.js +0 -1
- package/dist/vendor/codex-patch/parser.d.ts +0 -1
- package/dist/vendor/codex-patch/parser.js +0 -1
- package/dist/vendor/codex-patch/source-file.d.ts +0 -1
- package/dist/vendor/codex-patch/source-file.js +0 -1
- package/dist/vendor/codex-patch/types.d.ts +0 -1
- package/dist/vendor/codex-patch/types.js +0 -1
- package/dist/worker-build-plugins.d.ts +3 -0
- package/dist/worker-build-plugins.js +42 -0
- package/package.json +20 -7
- package/dist/agent-call.d.ts.map +0 -1
- package/dist/agent-call.js.map +0 -1
- package/dist/agent-channel-author-runtime.d.ts.map +0 -1
- package/dist/agent-channel-author-runtime.js.map +0 -1
- package/dist/agent-channel-receiver.d.ts.map +0 -1
- package/dist/agent-channel-receiver.js.map +0 -1
- package/dist/agent-channel-runtime.d.ts.map +0 -1
- package/dist/agent-channel-runtime.js.map +0 -1
- package/dist/agent-channel-worker.d.ts.map +0 -1
- package/dist/agent-channel-worker.js.map +0 -1
- package/dist/agent-computer-scope.d.ts.map +0 -1
- package/dist/agent-computer-scope.js.map +0 -1
- package/dist/agent-computer-session.d.ts.map +0 -1
- package/dist/agent-computer-session.js.map +0 -1
- package/dist/agent-core-engine.d.ts.map +0 -1
- package/dist/agent-core-engine.js.map +0 -1
- package/dist/agent-core-output.d.ts.map +0 -1
- package/dist/agent-core-output.js.map +0 -1
- package/dist/agent-core.d.ts.map +0 -1
- package/dist/agent-core.js.map +0 -1
- package/dist/agent-http.d.ts.map +0 -1
- package/dist/agent-http.js.map +0 -1
- package/dist/agent-session-execution.d.ts.map +0 -1
- package/dist/agent-session-execution.js.map +0 -1
- package/dist/agent-session-tasks.d.ts.map +0 -1
- package/dist/agent-session-tasks.js.map +0 -1
- package/dist/agent-session.d.ts.map +0 -1
- package/dist/agent-session.js.map +0 -1
- package/dist/agent-worker-attachments.d.ts.map +0 -1
- package/dist/agent-worker-attachments.js.map +0 -1
- package/dist/agent-worker-context.d.ts.map +0 -1
- package/dist/agent-worker-context.js.map +0 -1
- package/dist/agent-worker.d.ts.map +0 -1
- package/dist/agent-worker.js.map +0 -1
- package/dist/artifacts.d.ts.map +0 -1
- package/dist/artifacts.js.map +0 -1
- package/dist/cache-control.d.ts.map +0 -1
- package/dist/cache-control.js.map +0 -1
- package/dist/channels/feishu-codec.d.ts.map +0 -1
- package/dist/channels/feishu-codec.js.map +0 -1
- package/dist/channels/feishu-inbound.d.ts.map +0 -1
- package/dist/channels/feishu-inbound.js.map +0 -1
- package/dist/channels/feishu-output.d.ts.map +0 -1
- package/dist/channels/feishu-output.js.map +0 -1
- package/dist/channels/feishu-websocket.d.ts.map +0 -1
- package/dist/channels/feishu-websocket.js.map +0 -1
- package/dist/channels/feishu.d.ts.map +0 -1
- package/dist/channels/feishu.js.map +0 -1
- package/dist/channels/index.d.ts.map +0 -1
- package/dist/channels/index.js.map +0 -1
- package/dist/computer/just-bash.d.ts.map +0 -1
- package/dist/computer/just-bash.js.map +0 -1
- package/dist/computer-tools.d.ts.map +0 -1
- package/dist/computer-tools.js.map +0 -1
- package/dist/computer.d.ts.map +0 -1
- package/dist/computer.js.map +0 -1
- package/dist/context-runtime.d.ts.map +0 -1
- package/dist/context-runtime.js.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/creative-reasoning-auto.d.ts.map +0 -1
- package/dist/creative-reasoning-auto.js.map +0 -1
- package/dist/evals.d.ts.map +0 -1
- package/dist/evals.js.map +0 -1
- package/dist/experimental/agent-core-messages.d.ts.map +0 -1
- package/dist/experimental/agent-core-messages.js.map +0 -1
- package/dist/experimental/agent-core-options.d.ts.map +0 -1
- package/dist/experimental/agent-core-options.js.map +0 -1
- package/dist/experimental/agent-core-ui.d.ts.map +0 -1
- package/dist/experimental/agent-core-ui.js.map +0 -1
- package/dist/experimental/agent-core-worker-tools.d.ts.map +0 -1
- package/dist/experimental/agent-core-worker-tools.js.map +0 -1
- package/dist/experimental/agent-core.d.ts.map +0 -1
- package/dist/experimental/agent-core.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/skill-tool.d.ts.map +0 -1
- package/dist/skill-tool.js.map +0 -1
- package/dist/studio-client.d.ts.map +0 -1
- package/dist/studio-client.js.map +0 -1
- package/dist/studio-server.d.ts.map +0 -1
- package/dist/studio-server.js.map +0 -1
- package/dist/studio-stream-replay.d.ts.map +0 -1
- package/dist/studio-stream-replay.js.map +0 -1
- package/dist/trace-context.d.ts.map +0 -1
- package/dist/trace-context.js.map +0 -1
- package/dist/tracing.d.ts.map +0 -1
- package/dist/tracing.js.map +0 -1
- package/dist/vendor/ai-ui/json-to-sse-transform-stream.d.ts.map +0 -1
- package/dist/vendor/ai-ui/json-to-sse-transform-stream.js.map +0 -1
- package/dist/vendor/ai-ui/to-ui-message-chunk.d.ts.map +0 -1
- package/dist/vendor/ai-ui/to-ui-message-chunk.js.map +0 -1
- package/dist/vendor/ai-ui/ui-message-stream-headers.d.ts.map +0 -1
- package/dist/vendor/ai-ui/ui-message-stream-headers.js.map +0 -1
- package/dist/vendor/codex-patch/codex-whitespace.d.ts.map +0 -1
- package/dist/vendor/codex-patch/codex-whitespace.js.map +0 -1
- package/dist/vendor/codex-patch/errors.d.ts.map +0 -1
- package/dist/vendor/codex-patch/errors.js.map +0 -1
- package/dist/vendor/codex-patch/matcher.d.ts.map +0 -1
- package/dist/vendor/codex-patch/matcher.js.map +0 -1
- package/dist/vendor/codex-patch/parser.d.ts.map +0 -1
- package/dist/vendor/codex-patch/parser.js.map +0 -1
- package/dist/vendor/codex-patch/source-file.d.ts.map +0 -1
- package/dist/vendor/codex-patch/source-file.js.map +0 -1
- package/dist/vendor/codex-patch/types.d.ts.map +0 -1
- package/dist/vendor/codex-patch/types.js.map +0 -1
- package/src/channels/README.md +0 -319
- package/src/channels/feishu-output.md +0 -116
- package/src/channels/feishu-output.ts +0 -697
- package/src/channels/feishu.ts +0 -134
package/README.md
CHANGED
|
@@ -2,6 +2,525 @@
|
|
|
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
|
+
## Tenant application authentication
|
|
17
|
+
|
|
18
|
+
Agent HTTP accepts Project API keys and GEA user OAuth tokens by default. Push the
|
|
19
|
+
Worker and associate the Agent with its app in **Studio → Applications**. Publish
|
|
20
|
+
the entry in Preview or Production from the Agent page. Subsequent pushes advance
|
|
21
|
+
Preview; one explicit Production publish updates all published entries in that
|
|
22
|
+
Worker. Unpublished sibling Agents remain unavailable to application users.
|
|
23
|
+
|
|
24
|
+
Every tenant uses the same two Worker URLs:
|
|
25
|
+
|
|
26
|
+
- Preview: `https://preview--worker--<workerId>.<apex>/gea/agents/<agentKey>/run`
|
|
27
|
+
- Production: `https://worker--<workerId>.<apex>/gea/agents/<agentKey>/run`
|
|
28
|
+
|
|
29
|
+
For store distribution, a Global Admin reviews application information, then
|
|
30
|
+
installs the approved application into a consumer tenant from **Published applications**.
|
|
31
|
+
Installation enables Production and the approved scopes, including `agents:invoke`;
|
|
32
|
+
it does not require or create a Workspace. Preview additionally requires publisher
|
|
33
|
+
approval for external test tenants and explicit environment enablement. The
|
|
34
|
+
application starts standard OAuth; GEA confirms the actual user and consumer tenant
|
|
35
|
+
and resolves the installation internally. Do not send an installation ID.
|
|
36
|
+
|
|
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.
|
|
57
|
+
|
|
58
|
+
## Agent Authoring Shapes
|
|
59
|
+
|
|
60
|
+
A single-main application starts with root `agent.ts` and `AGENTS.md`:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { defineAgent } from "@gea-ai/agent-sdk";
|
|
64
|
+
|
|
65
|
+
export default defineAgent({
|
|
66
|
+
model: "gea-model-1",
|
|
67
|
+
name: "research-agent",
|
|
68
|
+
slug: "research-agent",
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
An Agent may instead declare capability thresholds for the SDK's first-party
|
|
73
|
+
Creative Reasoning router:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
export default defineAgent({
|
|
77
|
+
model: "auto",
|
|
78
|
+
modelRequirements: {
|
|
79
|
+
agentic: 0.8,
|
|
80
|
+
copywriting: 0.6,
|
|
81
|
+
multimodal: 0.4,
|
|
82
|
+
speed: 0.7,
|
|
83
|
+
},
|
|
84
|
+
name: "research-agent",
|
|
85
|
+
slug: "research-agent",
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Each requirement is an optional minimum score from `0` to `1`; omitted
|
|
90
|
+
dimensions do not constrain selection. `modelRequirements` is required for
|
|
91
|
+
`model: "auto"` and rejected for a concrete model. The SDK filters its curated
|
|
92
|
+
Creative Reasoning capability table and selects the eligible model with the
|
|
93
|
+
lowest configured cost rank. It writes only the selected concrete CR gateway
|
|
94
|
+
model ID into the package snapshot, so runtime model selection does not change
|
|
95
|
+
when a later SDK updates the table.
|
|
96
|
+
|
|
97
|
+
This table is maintained in the SDK; it does not query CR model discovery,
|
|
98
|
+
verify API-key access, or read the deployment's model catalog or prices.
|
|
99
|
+
Capability scores and cost ranks are provisional routing parameters rather
|
|
100
|
+
than official platform measurements or actual catalog prices. The following
|
|
101
|
+
candidate IDs and upstream mappings were supplied by the platform owner on
|
|
102
|
+
2026-09-05; authenticated access still needs verification for each deployment.
|
|
103
|
+
The mapping is developer information and is not a product display label.
|
|
104
|
+
|
|
105
|
+
| CR gateway model ID | Upstream mapping | Cost rank | Agentic | Copywriting | Multimodal | Speed |
|
|
106
|
+
| ------------------------ | ----------------- | --------- | ------- | ----------- | ---------- | ----- |
|
|
107
|
+
| `deepseek-v4-flash` | DeepSeek V4 Flash | 1 | 0.5 | 0.5 | 0 | 1 |
|
|
108
|
+
| `crr-q-flash-20260826` | Qwen3.8 Flash | 2 | 0.55 | 0.6 | 0 | 1 |
|
|
109
|
+
| `crr-o-mini-20260710` | gpt-5.6-luna | 3 | 0.55 | 0.45 | 0.55 | 1 |
|
|
110
|
+
| `deepseek-v4-pro` | DeepSeek V4 Pro | 4 | 0.8 | 0.75 | 0 | 0.65 |
|
|
111
|
+
| `crr-q-pro-20260804` | Qwen3.8 Max | 5 | 0.85 | 0.8 | 0 | 0.6 |
|
|
112
|
+
| `crr-o-20260710` | gpt-5.6-terra | 6 | 0.8 | 0.7 | 0.75 | 0.7 |
|
|
113
|
+
| `creative-reasoning-1.5` | Claude Sonnet 5 | 7 | 0.8 | 0.9 | 0.7 | 0.65 |
|
|
114
|
+
| `crr-o-pro-20260710` | gpt-5.6-sol | 8 | 0.95 | 0.82 | 0.85 | 0.45 |
|
|
115
|
+
| `crr-a-pro-20260724` | Claude Opus 5 | 9 | 1 | 1 | 0.85 | 0.35 |
|
|
116
|
+
|
|
117
|
+
Qwen and DeepSeek currently have a zero multimodal routing score until their
|
|
118
|
+
gateway support is verified; any positive multimodal requirement excludes
|
|
119
|
+
them. Existing GPT and Claude routing thresholds are retained. With this
|
|
120
|
+
candidate set, `multimodal: 0.9` or `{ multimodal: 0.8, speed: 0.9 }` has no
|
|
121
|
+
eligible model and fails during Agent definition. Removing an auto candidate
|
|
122
|
+
does not invalidate an explicit model declaration or an existing snapshot.
|
|
123
|
+
|
|
124
|
+
For hosted execution, register these nine IDs in
|
|
125
|
+
`LLM_MODEL_CATALOG_JSON.models`, using `creative-reasoning/<gateway-model-id>`
|
|
126
|
+
targets and actual target-keyed prices. Keep the existing `gea-fast` and
|
|
127
|
+
`gea-pro` aliases and set `selectableModels: ["gea-fast", "gea-pro"]` so normal
|
|
128
|
+
product selectors show only those aliases. Studio developers can inspect the
|
|
129
|
+
immutable version's model but cannot override it in Playground.
|
|
130
|
+
|
|
131
|
+
`defineAgent({ model: "auto", ... })` provides contextual field completion for
|
|
132
|
+
all four requirements. Standalone input annotations require a model type:
|
|
133
|
+
`DefineAgentInput<"auto">` requires the capability fields, while
|
|
134
|
+
`DefineAgentInput<"crr-a-pro-20260724">` forbids them. There is no implicit
|
|
135
|
+
`string` model parameter, because it would also accept `"auto"` without its
|
|
136
|
+
requirements. Direct `defineAgent(...)` calls infer the model type.
|
|
137
|
+
|
|
138
|
+
A concrete first-party model may use any unqualified public ID, such as
|
|
139
|
+
`crr-a-pro-20260724`, `creative-reasoning-1.5`, or
|
|
140
|
+
`creative-reasoning-1.5-flash`. An explicit Creative Reasoning provider ID such
|
|
141
|
+
as `creative-reasoning/kimi-k3` is also supported. The snapshot preserves the
|
|
142
|
+
declared concrete ID.
|
|
143
|
+
|
|
144
|
+
Tools, Connectors, Hooks, referenced Skills, and local Skills are discovered
|
|
145
|
+
from conventional sibling directories. The required `slug` is the Agent's
|
|
146
|
+
stable identity inside this Worker application. It becomes the manifest and
|
|
147
|
+
runtime `agentKey`; `name` remains display metadata.
|
|
148
|
+
|
|
149
|
+
A root Agent may stay in place when the application adds more main Agents under
|
|
150
|
+
`agents/<slug>/agent.ts`. This preserves the original Agent's identity and
|
|
151
|
+
root `benchmarks/`. A directory Agent's declared slug must match its directory
|
|
152
|
+
name. Applications without a root Agent may use `agents/default/` as the
|
|
153
|
+
default source alias; that Agent still declares a real non-reserved slug. If
|
|
154
|
+
there is no root or `agents/default/`, the lexically first directory Agent owns
|
|
155
|
+
the default route. `default`, `run`, and `sessions` are reserved protocol
|
|
156
|
+
segments and cannot be Agent slugs.
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
agents/default/agent.ts
|
|
160
|
+
agents/default/AGENTS.md
|
|
161
|
+
agents/support/agent.ts
|
|
162
|
+
agents/support/AGENTS.md
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Add root `worker.ts` only when the same Worker also serves UI, business APIs,
|
|
166
|
+
assets, or application Durable Objects. The CLI generates Agent assembly and
|
|
167
|
+
prepends it to the application handler. Developers do not list Tools, Skills,
|
|
168
|
+
or Connectors again in `worker.ts`.
|
|
169
|
+
|
|
170
|
+
Generated code uses `createAgentApplicationFetch()`, which owns:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
/gea/agents/run
|
|
174
|
+
/gea/agents/<agentKey>/run
|
|
175
|
+
/gea/agents[/<agentKey>]/sessions/<sessionId>/v1/<operation>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Hosted Agent HTTP handlers accept Project API keys and platform user tokens by
|
|
179
|
+
default, equivalent to this explicit configuration:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import {
|
|
183
|
+
defineAgent,
|
|
184
|
+
projectKeyAuth,
|
|
185
|
+
platformUserAuth,
|
|
186
|
+
} from "@gea-ai/agent-sdk";
|
|
187
|
+
|
|
188
|
+
export default defineAgent({
|
|
189
|
+
name: "support",
|
|
190
|
+
slug: "support",
|
|
191
|
+
model: "gea-model-1",
|
|
192
|
+
http: { auth: [projectKeyAuth(), platformUserAuth()] },
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
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.
|
|
236
|
+
|
|
237
|
+
`OPTIONS /gea/agents/<agentKey>/run` returns only the Agent key, canonical run
|
|
238
|
+
path and HTTP protocol version. It runs before authentication and does not
|
|
239
|
+
execute a model, create a Session or access platform bindings. Hosted push checks
|
|
240
|
+
this response in the final bundle locally, then the server checks the uploaded
|
|
241
|
+
deployment in Worker Runtime before accepting it. Missing, moved or incompatible
|
|
242
|
+
entries require an SDK update and rebuild. Ordinary Worker application paths
|
|
243
|
+
remain developer-owned; this conformance check does not grant Agent access.
|
|
244
|
+
|
|
245
|
+
Application pages and browser Sessions require the operator's isolated
|
|
246
|
+
`WORKER_APP_BASE_URL`. GEA-domain and path ingress preserve API access but strip
|
|
247
|
+
platform cookies and force CSP sandbox plus `nosniff`; Worker pages cannot run
|
|
248
|
+
scripts there. Application-domain pages retain their own CSP. Local `gea agent dev` uses its
|
|
249
|
+
existing trusted development identity. Raw AgentSession and Connector auth
|
|
250
|
+
operations remain private regardless of `http.auth`. Rebuild and republish old
|
|
251
|
+
Agent packages with the matching SDK/CLI to enable the new hosted handler.
|
|
252
|
+
|
|
253
|
+
The public run request is intentionally small:
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
{ "chatId": "optional-continuation-id", "message": "Hello" }
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
If `chatId` is absent, the hosted managed API creates a Chat and Run and returns
|
|
260
|
+
their IDs in response headers. Local execution creates its local Session identity.
|
|
261
|
+
Callers cannot supply model-loop messages, instructions, provider options, or
|
|
262
|
+
platform-owned Run/message IDs. Each main Agent's exact `AGENTS.md` text is
|
|
263
|
+
compiled into the Worker and is never accepted from the run request.
|
|
264
|
+
|
|
265
|
+
`composeFetch()` delegates unclaimed requests to the optional application
|
|
266
|
+
Worker. Worker Runtime remains route-agnostic.
|
|
267
|
+
|
|
268
|
+
Every main Agent declares one concrete public GEA model ID or the SDK-owned
|
|
269
|
+
`auto` selector above. GEA resolves the concrete snapshot model through the
|
|
270
|
+
active Model Gateway catalog; source and artifacts contain no provider
|
|
271
|
+
credential or target configuration.
|
|
272
|
+
|
|
273
|
+
## Context strategies
|
|
274
|
+
|
|
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.
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
import { defineAgent } from "@gea-ai/agent-sdk";
|
|
283
|
+
import { defaultContext } from "@gea-ai/agent-sdk/context";
|
|
284
|
+
|
|
285
|
+
export default defineAgent({
|
|
286
|
+
name: "assistant",
|
|
287
|
+
slug: "assistant",
|
|
288
|
+
model: "gea-model-1",
|
|
289
|
+
context: defaultContext({
|
|
290
|
+
toolOutput: { offloadAtCharacters: 4_000, replaceAtCharacters: 8_000 },
|
|
291
|
+
preserveRecentGroups: 5,
|
|
292
|
+
summarization: {
|
|
293
|
+
triggerAtTotalTokens: 64_000,
|
|
294
|
+
// Optional: model, instructions, maxOutputTokens.
|
|
295
|
+
},
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
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, the default recipe skips offload but can still summarize.
|
|
305
|
+
|
|
306
|
+
A custom strategy is an object with optional `prepareStep`, `onStepEnd` and
|
|
307
|
+
`onEnd` callbacks, using the AI SDK 7 names. These callbacks replace the default
|
|
308
|
+
recipe. `prepareStep` receives durable `messages`, `contextSize`, `stepNumber`
|
|
309
|
+
and `runtimeContext`; returning `{ messages }` replaces the active projection
|
|
310
|
+
for subsequent steps and Runs. Returning nothing keeps it. `onStepEnd` also
|
|
311
|
+
receives that step's `usage` and `finishReason`; `onEnd` receives the main loop's
|
|
312
|
+
`totalUsage` and `finishReason`.
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
const context = {
|
|
316
|
+
async prepareStep({ messages, runtimeContext }) {
|
|
317
|
+
const memory = await loadCommittedMemory(runtimeContext);
|
|
318
|
+
return { messages: applyMemoryToCoveredPrefix(messages, memory) };
|
|
319
|
+
},
|
|
320
|
+
async onStepEnd({ messages, runtimeContext }) {
|
|
321
|
+
runtimeContext.waitUntil(precomputeMemory(messages, runtimeContext));
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
The functions in this short sketch are application-owned.
|
|
327
|
+
|
|
328
|
+
`runtimeContext` provides trusted `identity`, `auth`, declared `env`, execution
|
|
329
|
+
`environment`, typed `durableObjects`, `signal`, and the main public `modelId`.
|
|
330
|
+
Call `model(modelId?)` to resolve a model through the existing Host, then use AI
|
|
331
|
+
SDK `generateText` or `streamText` with that model and the cancellation signal.
|
|
332
|
+
Register each auxiliary call's `{ model, usage, label?, status? }` through
|
|
333
|
+
`recordUsage`. Status defaults to `completed`; use `failed` or `aborted` with
|
|
334
|
+
`usage: null` when the provider did not return usage. Register a successful call
|
|
335
|
+
before validating its text or committing memory, since those operations can fail
|
|
336
|
+
after the model has consumed tokens. The SDK assigns the call id and tracks its
|
|
337
|
+
Session write automatically.
|
|
338
|
+
`writeToolOutput` is a writer returning `{ artifactUri }`, or `null` if storage
|
|
339
|
+
is unavailable. Its input is `{ content, sha256, toolCallId, toolName }`.
|
|
340
|
+
|
|
341
|
+
`runtimeContext.updateMessages(messages)` persists a replacement from an awaited
|
|
342
|
+
foreground callback, including the final step or `onEnd`. Background work stores
|
|
343
|
+
candidate memory in a DO; a later foreground callback applies it. The Worker
|
|
344
|
+
waits for registered work before publishing its final success and usage, including
|
|
345
|
+
when Computer is disabled. `metadata.modelCalls` records each main-model step and
|
|
346
|
+
auxiliary call with a stable call id, Run id, model, source, optional label, status,
|
|
347
|
+
completion time and usage. `metadata.totalUsage` is their known usage sum;
|
|
348
|
+
`metadata.contextUsage` retains the auxiliary view. Hosted settlement prices each
|
|
349
|
+
call using its own catalog target and writes a separate idempotent usage event.
|
|
350
|
+
A completed model call stays completed even if the containing Run later fails.
|
|
351
|
+
Unhandled callback or background errors fail the Run; completed model messages
|
|
352
|
+
and registered usage survive that failure. Pass `signal` into external work so cancellation can finish promptly.
|
|
353
|
+
|
|
354
|
+
AgentSession owns the active projection and separate transcript. Custom
|
|
355
|
+
observations, reflection and coverage state belong in the application's chat DO.
|
|
356
|
+
Commit memory and coverage together before removing the covered message prefix.
|
|
357
|
+
Existing summary metadata is included when a custom callback reads messages, and
|
|
358
|
+
is no longer separately injected after that callback replaces the projection.
|
|
359
|
+
`stepNumber` is local to a Run, not a durable chat cursor.
|
|
360
|
+
|
|
361
|
+
Context callbacks execute in the Agent bundle; snapshots contain only serializable
|
|
362
|
+
descriptors and default recipe options. Ordinary imported modules are sufficient.
|
|
363
|
+
Upgrade the SDK and rebuild/publish existing Agents to use the API. `waitUntil`
|
|
364
|
+
covers the current invocation; it does not schedule future Runs or replay a model
|
|
365
|
+
call after a crash.
|
|
366
|
+
|
|
367
|
+
## CLI Workflow
|
|
368
|
+
|
|
369
|
+
Local validation, development, and packing need no hosted Agent record:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
gea agent validate --json '{"cwd":"."}'
|
|
373
|
+
gea agent dev --json '{"cwd":"."}'
|
|
374
|
+
gea agent eval --json '{"cwd":".","judgeModel":"gea-model-1"}'
|
|
375
|
+
gea agent pack --json '{"cwd":"."}'
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
`gea agent dev` treats every unqualified model ID, plus explicit
|
|
379
|
+
`creative-reasoning/<model>` IDs, as first-party Creative Reasoning models. It
|
|
380
|
+
calls Creative Reasoning directly when `CREATIVE_REASONING_API_KEY` is present;
|
|
381
|
+
when the key is absent it falls back to the hosted web model proxy and the
|
|
382
|
+
current `gea login` Workspace. An explicit `{"modelSource":"hosted"}` keeps
|
|
383
|
+
hosted routing. `{"modelSource":"local"}` forces local routing and therefore
|
|
384
|
+
requires the Creative Reasoning key for first-party models; other qualified
|
|
385
|
+
local providers continue to use their configured local catalog.
|
|
386
|
+
`gea agent eval` applies the same decision to both Agent models and the active
|
|
387
|
+
`judgeModel`, so a direct evaluation catalog contains every model the run uses.
|
|
388
|
+
|
|
389
|
+
Native Anthropic calls, including `crr-a-*` and `creative-reasoning-1.5`, apply
|
|
390
|
+
the SDK's shared rolling prompt-cache policy before provider serialization.
|
|
391
|
+
System prompts, conversation prefixes, and eligible Tool definitions retain
|
|
392
|
+
cache markers across model steps and turns. Markers belong only to outbound
|
|
393
|
+
requests and never enter the stored AgentSession context. Hosted calls retain
|
|
394
|
+
their existing proxy-owned cache policy.
|
|
395
|
+
|
|
396
|
+
`gea agent eval` discovers Cases and inherited Judges from the Benchmark next
|
|
397
|
+
to each main Agent's `tools/`: root `benchmarks/` for the root Agent, including
|
|
398
|
+
after additional main Agents are added, and `agents/<slug>/benchmarks/` for
|
|
399
|
+
directory Agents. It runs each Case through that main Agent's stable slug route
|
|
400
|
+
and writes results under `.gea/evals`. Use `{"agentKey":"support"}` to select
|
|
401
|
+
one main Agent. A Case's optional
|
|
402
|
+
`expected` value enables the built-in Autoeval Judge. Author semantic rubrics
|
|
403
|
+
as `*.judge.md`; author deterministic trajectory checks as `*.judge.ts` with
|
|
404
|
+
the `./evals` SDK export. Autoeval may query bounded run evidence across
|
|
405
|
+
multiple model steps and finishes by calling a structured result Tool; it does
|
|
406
|
+
not require the model's text response to be JSON:
|
|
407
|
+
|
|
408
|
+
```ts
|
|
409
|
+
import { defineJudge } from "@gea-ai/agent-sdk/evals";
|
|
410
|
+
|
|
411
|
+
export default defineJudge(({ messages }) => {
|
|
412
|
+
const usedSearch = messages.some((message) =>
|
|
413
|
+
message.parts.some((part) => part.type === "tool-search"),
|
|
414
|
+
);
|
|
415
|
+
return {
|
|
416
|
+
reason: usedSearch ? "Search was used." : "Search was not used.",
|
|
417
|
+
score: usedSearch ? 1 : 0,
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
`gea agent dev` and `gea agent eval` generate `.gea/bindings.d.ts` from the
|
|
423
|
+
owning main Agent's `tools/` and snapshot-known runtime Tool names. This
|
|
424
|
+
registers the canonical root SDK types:
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
import agent from "./agent";
|
|
428
|
+
import type {
|
|
429
|
+
AgentMessage,
|
|
430
|
+
AgentMessageFor,
|
|
431
|
+
InferAgentMessage,
|
|
432
|
+
} from "@gea-ai/agent-sdk";
|
|
433
|
+
|
|
434
|
+
type DefaultMessage = AgentMessage;
|
|
435
|
+
type SupportMessage = AgentMessageFor<"support">;
|
|
436
|
+
type ThisAgentMessage = InferAgentMessage<typeof agent>;
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
All three are ordinary AI SDK `UIMessage` types. Static custom `tool-*` parts
|
|
440
|
+
preserve Tool names, Zod input types, and return types. Snapshot-known Computer
|
|
441
|
+
and Connector Tools preserve their concrete `tool-*` names with generic input
|
|
442
|
+
and output. MCP Tool parts use the qualified template
|
|
443
|
+
`tool-<alias>__${string}` because their catalog is runtime-discovered; truly
|
|
444
|
+
unqualified runtime Tools remain `dynamic-tool` parts. SDK-first Agent Workers
|
|
445
|
+
currently emit no custom `data-*` parts, so Legacy chat data parts are not
|
|
446
|
+
included. Code Judges consume the same types rather than defining an
|
|
447
|
+
Eval-specific message model.
|
|
448
|
+
`InferAgentMessage<typeof agent>` resolves to `never` when the generated
|
|
449
|
+
registry is absent or its Agent slug does not match, rather than silently
|
|
450
|
+
falling back to an unrelated Tool catalog.
|
|
451
|
+
|
|
452
|
+
Studio also runs `defineApiConnector`, `defineMcpConnector`, and deployment-enabled
|
|
453
|
+
built-in `geaConnect` providers through the managed Host. All use existing
|
|
454
|
+
Project/Agent Connections, isolated by Preview/Production and application
|
|
455
|
+
principal. No database migration or personal credential inheritance is involved.
|
|
456
|
+
API keys default to `connection: { principalType: "agent" }`; OAuth and
|
|
457
|
+
`geaConnect` default to `"user"`. All three helpers accept an explicit
|
|
458
|
+
`connection: { principalType: "agent" | "user" }`. No-auth API/MCP endpoints
|
|
459
|
+
need no Connection. Custom executable `defineConnector` ownership stays unchanged.
|
|
460
|
+
|
|
461
|
+
Configure Agent-owned credentials in Project Connections or an Agent override.
|
|
462
|
+
User-owned authorization links bind the application's supplied principal; missing
|
|
463
|
+
user identity returns `principal_required`. OAuth client variables come from the
|
|
464
|
+
selected environment. Register `${APP_BASE_URL}/api/agent-connectors/oauth/callback`
|
|
465
|
+
for hosted OAuth, including the deployment Google OAuth client used by Google Drive.
|
|
466
|
+
API keys are submitted on a public, state-bound setup page; OAuth uses PKCE;
|
|
467
|
+
Feishu uses the host's isolated managed CLI. Credentials and refresh state remain
|
|
468
|
+
encrypted in the original Connection scope and never enter Worker code.
|
|
469
|
+
|
|
470
|
+
Rebuild old `geaConnect` snapshots to declare Studio ownership. Supported native
|
|
471
|
+
providers are Google Drive, Feishu, Social Search, and WeChat Official Account,
|
|
472
|
+
subject to deployment availability. Other platform resource references should
|
|
473
|
+
use `defineApiConnector` or `defineMcpConnector` with an explicit endpoint.
|
|
474
|
+
CLI upload preparation rejects old personal-authorization declarations and GEA
|
|
475
|
+
user identity injection with the Connector alias, key, runtime, and reason.
|
|
476
|
+
The server additionally checks native provider availability before publication.
|
|
477
|
+
|
|
478
|
+
Configure a package-local API or MCP Connector without uploading its
|
|
479
|
+
credential:
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
gea agent connect exa-market-intelligence
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
An MCP Connector declares only its stable server and authentication boundary:
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
import { defineMcpConnector, noAuth } from "@gea-ai/agent-sdk";
|
|
489
|
+
|
|
490
|
+
export default defineMcpConnector({
|
|
491
|
+
auth: noAuth(),
|
|
492
|
+
key: "product-docs",
|
|
493
|
+
name: "Product Docs",
|
|
494
|
+
serverUrl: "https://mcp.example.com/mcp",
|
|
495
|
+
}).require();
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Its current Tools and schemas are discovered at the start of every run and
|
|
499
|
+
exposed as `product-docs__<tool>`. They are not persisted in the Agent Package.
|
|
500
|
+
|
|
501
|
+
API-key input is hidden. OAuth uses Authorization Code plus S256 PKCE through
|
|
502
|
+
`http://127.0.0.1:8788/oauth/callback`. Credentials stay under `~/.gea`,
|
|
503
|
+
scoped to canonical project path and Connector definition, and are reread for
|
|
504
|
+
each local Tool call.
|
|
505
|
+
|
|
506
|
+
Platform Connectors declared with `geaConnect(...)` are called through the
|
|
507
|
+
Workspace selected by `gea login` and `gea workspace use`; their platform-owned
|
|
508
|
+
credentials are never copied into the local project. This same local Connector
|
|
509
|
+
Host behavior is used by both `gea agent dev` and `gea agent eval`.
|
|
510
|
+
|
|
511
|
+
After `gea workspace use`, publish the complete Worker application:
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
gea agent push --json '{"cwd":".","slug":"product-worker"}'
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
The command uploads one generic Worker deployment and registers every main
|
|
518
|
+
Agent in Studio by Worker plus Agent key. The new deployment becomes Preview.
|
|
519
|
+
It never creates or updates Legacy `app_resource` or resource-package rows.
|
|
520
|
+
Preview and Production promotion are Worker-wide.
|
|
521
|
+
|
|
522
|
+
Use a Studio Agent ID to start its selected environment:
|
|
523
|
+
|
|
5
524
|
```bash
|
|
6
525
|
npm install @gea-ai/agent-sdk
|
|
7
526
|
```
|
|
@@ -29,6 +548,56 @@ The default AI SDK engine resolves Anthropic capabilities from the upstream mode
|
|
|
29
548
|
|
|
30
549
|
Native Workers request the catalog target from the AI binding, so public aliases can use the same recognition. This requires updating Worker Runtime and rebuilding the Agent with the new SDK. Existing SDK bundles retain their descriptor format. The hosted AI SDK proxy resolves target identity on the server; the optional `agentCore` engine keeps its existing protocol.
|
|
31
550
|
|
|
551
|
+
## Provider reasoning options
|
|
552
|
+
|
|
553
|
+
`defineAgent` accepts AI SDK-shaped `providerOptions`. This release exposes the
|
|
554
|
+
reasoning controls of the `openai` and `anthropic` protocols:
|
|
555
|
+
|
|
556
|
+
```ts
|
|
557
|
+
export default defineAgent({
|
|
558
|
+
name: "Research assistant",
|
|
559
|
+
slug: "research",
|
|
560
|
+
model: "creative-reasoning-1.5",
|
|
561
|
+
providerOptions: {
|
|
562
|
+
anthropic: {
|
|
563
|
+
effort: "low",
|
|
564
|
+
thinking: { type: "adaptive" },
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
For an OpenAI-compatible model, use
|
|
571
|
+
`providerOptions: { openai: { reasoningEffort: "low" } }`. The SDK maps this
|
|
572
|
+
public namespace to the existing OpenAI-compatible adapter; no gateway-specific
|
|
573
|
+
namespace, upstream URL or credential is needed. Both namespaces may be declared;
|
|
574
|
+
only the selected model's protocol consumes its options.
|
|
575
|
+
|
|
576
|
+
- `openai.reasoningEffort`: `none`, `minimal`, `low`, `medium`, `high`, or `xhigh`.
|
|
577
|
+
- `anthropic.effort`: `low`, `medium`, `high`, `xhigh`, or `max`.
|
|
578
|
+
- `anthropic.thinking`: `{ type: "adaptive", display?: "omitted" | "summarized" }`,
|
|
579
|
+
`{ type: "enabled", budgetTokens: 2048 }`, or `{ type: "disabled" }`.
|
|
580
|
+
Enabled thinking requires an explicit integer budget of at least 1,024 tokens.
|
|
581
|
+
|
|
582
|
+
Supported values depend on the actual model. The provider validates model-specific
|
|
583
|
+
support; GEA does not map effort levels to token budgets. Unknown namespaces,
|
|
584
|
+
unknown fields and invalid shapes fail at declaration/publication. Omit the
|
|
585
|
+
options to retain existing defaults. The public `AgentModelProviderOptions` type
|
|
586
|
+
is exported by the SDK and contract package.
|
|
587
|
+
|
|
588
|
+
These settings are frozen in each Agent's published snapshot and apply to its
|
|
589
|
+
main loop in both the default AI SDK engine and `agentCore`, including model
|
|
590
|
+
switches and continuation. Private/referenced Agents keep their own settings;
|
|
591
|
+
self copies use the source definition. Explicit Core per-step generation settings
|
|
592
|
+
override the baseline for that step. Context strategies' auxiliary model calls
|
|
593
|
+
continue to own their call options.
|
|
594
|
+
|
|
595
|
+
Adoption requires an updated SDK, a server/CLI using the updated snapshot contract,
|
|
596
|
+
and rebuilding and publishing the immutable Agent bundle. This adds no per-request
|
|
597
|
+
override to the public `/run` API or Studio composer. See the upstream
|
|
598
|
+
[OpenAI](https://ai-sdk.dev/providers/ai-sdk-providers/openai) and
|
|
599
|
+
[Anthropic](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic) options.
|
|
600
|
+
|
|
32
601
|
## Background Agent tasks
|
|
33
602
|
|
|
34
603
|
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.
|
|
@@ -47,6 +616,55 @@ const sales = defineAgentReference({
|
|
|
47
616
|
const legal = defineRemoteAgent({
|
|
48
617
|
slug: "legal-advisor",
|
|
49
618
|
description: "Legal review",
|
|
619
|
+
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
## Call a Studio Agent with AI SDK
|
|
623
|
+
|
|
624
|
+
Use `StudioAgentChatTransport` from `@gea-ai/agent-sdk/studio-client` with
|
|
625
|
+
`useChat` from `@ai-sdk/react` in the browser, and `StudioAgentClient` from
|
|
626
|
+
`@gea-ai/agent-sdk/studio-server` on your backend. The browser authenticates to
|
|
627
|
+
your application; only your backend sends the Project key to GEA. The transport
|
|
628
|
+
reads response identity headers and reuses the server Chat on later turns.
|
|
629
|
+
|
|
630
|
+
```tsx
|
|
631
|
+
import { useChat } from "@ai-sdk/react";
|
|
632
|
+
import { StudioAgentChatTransport } from "@gea-ai/agent-sdk/studio-client";
|
|
633
|
+
import { useState } from "react";
|
|
634
|
+
|
|
635
|
+
// Inside your component:
|
|
636
|
+
const [transport] = useState(
|
|
637
|
+
() =>
|
|
638
|
+
new StudioAgentChatTransport({
|
|
639
|
+
api: "/api/agent", // Your authenticated application path, without /run.
|
|
640
|
+
headers: { "x-csrf-token": csrfToken }, // From your application session.
|
|
641
|
+
onRun: ({ chatId, runId, requestId }) => {
|
|
642
|
+
console.log({ chatId, runId, requestId });
|
|
643
|
+
},
|
|
644
|
+
}),
|
|
645
|
+
);
|
|
646
|
+
const { messages, sendMessage, resumeStream } = useChat({ transport });
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
The transport sends your application's session cookies by default. It accepts
|
|
650
|
+
only same-origin paths and sends no business metadata. Set `headers` to your
|
|
651
|
+
application's CSRF token or user access token as appropriate.
|
|
652
|
+
|
|
653
|
+
Create a key in **Project → API Key** and copy the matching URL from the
|
|
654
|
+
Agent detail overview. Production uses `worker--<workerId>.<apex>`; preview
|
|
655
|
+
uses `preview--worker--<workerId>.<apex>`. Both use `/gea/agents/<agentKey>/run`.
|
|
656
|
+
Remove the trailing `/run` for the SDK `api` option, which appends operation
|
|
657
|
+
paths itself. The key must match the URL environment.
|
|
658
|
+
|
|
659
|
+
On the backend, configure the GEA destination and key from server environment:
|
|
660
|
+
|
|
661
|
+
```ts
|
|
662
|
+
import { StudioAgentClient } from "@gea-ai/agent-sdk/studio-server";
|
|
663
|
+
import { env } from "./env";
|
|
664
|
+
|
|
665
|
+
const agent = new StudioAgentClient({
|
|
666
|
+
api: env.GEA_AGENT_API_URL, // Agent base URL without /run.
|
|
667
|
+
token: env.GEA_PROJECT_API_KEY,
|
|
50
668
|
});
|
|
51
669
|
// URL: a GEA Agent protocol endpoint. The key stays in runtime environment configuration.
|
|
52
670
|
const external = defineRemoteAgent({
|
|
@@ -63,3 +681,10 @@ The tool returns `{ status: "working", taskId, agentId }`. `task_update({ messag
|
|
|
63
681
|
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.
|
|
64
682
|
|
|
65
683
|
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.
|
|
684
|
+
|
|
685
|
+
### Worker build plugins
|
|
686
|
+
|
|
687
|
+
The Node-only `@gea-ai/agent-sdk/worker-build-plugins` entry exports the shared
|
|
688
|
+
esbuild plugins used by CLI Worker bundles and the hosted Judge runtime template.
|
|
689
|
+
Build tools that use this entry must install the optional `esbuild` peer. Agent
|
|
690
|
+
runtime code should use the ordinary SDK or `evals` entry instead.
|
package/dist/agent-call.d.ts
CHANGED
|
@@ -607,7 +607,6 @@ export declare function createWorkerTaskTool(input: {
|
|
|
607
607
|
}, NoInfer<import("@ai-sdk/provider-utils").Context>>;
|
|
608
608
|
});
|
|
609
609
|
export declare function readWorkerAgentResponse(response: Response): Promise<{
|
|
610
|
-
status: "completed";
|
|
610
|
+
status: "completed" | "suspended";
|
|
611
611
|
text: string;
|
|
612
612
|
}>;
|
|
613
|
-
//# sourceMappingURL=agent-call.d.ts.map
|