@gea-ai/agent-sdk 0.1.260909-alpha.0 → 0.1.260910-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +3 -1154
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/dist/agent-channel-author-runtime.d.ts +79 -0
  4. package/dist/agent-channel-author-runtime.d.ts.map +1 -0
  5. package/dist/agent-channel-author-runtime.js +511 -0
  6. package/dist/agent-channel-author-runtime.js.map +1 -0
  7. package/dist/agent-channel-receiver.d.ts +46 -0
  8. package/dist/agent-channel-receiver.d.ts.map +1 -0
  9. package/dist/agent-channel-receiver.js +356 -0
  10. package/dist/agent-channel-receiver.js.map +1 -0
  11. package/dist/agent-channel-runtime.d.ts +6 -0
  12. package/dist/agent-channel-runtime.d.ts.map +1 -0
  13. package/dist/agent-channel-runtime.js +623 -0
  14. package/dist/agent-channel-runtime.js.map +1 -0
  15. package/dist/agent-channel-worker.d.ts +22 -0
  16. package/dist/agent-channel-worker.d.ts.map +1 -0
  17. package/dist/agent-channel-worker.js +335 -0
  18. package/dist/agent-channel-worker.js.map +1 -0
  19. package/dist/agent-core-engine.d.ts +29 -0
  20. package/dist/agent-core-engine.d.ts.map +1 -0
  21. package/dist/agent-core-engine.js +2 -0
  22. package/dist/agent-core-engine.js.map +1 -0
  23. package/dist/agent-core-output.d.ts +6 -0
  24. package/dist/agent-core-output.d.ts.map +1 -0
  25. package/dist/agent-core-output.js +36 -0
  26. package/dist/agent-core-output.js.map +1 -0
  27. package/dist/agent-core.d.ts +12 -0
  28. package/dist/agent-core.d.ts.map +1 -0
  29. package/dist/agent-core.js +18 -0
  30. package/dist/agent-core.js.map +1 -0
  31. package/dist/agent-core.wasm +0 -0
  32. package/dist/agent-session.d.ts.map +1 -1
  33. package/dist/agent-session.js +177 -4
  34. package/dist/agent-session.js.map +1 -1
  35. package/dist/agent-worker.d.ts +28 -1
  36. package/dist/agent-worker.d.ts.map +1 -1
  37. package/dist/agent-worker.js +1511 -241
  38. package/dist/agent-worker.js.map +1 -1
  39. package/dist/channels/feishu-codec.d.ts +18 -0
  40. package/dist/channels/feishu-codec.d.ts.map +1 -0
  41. package/dist/channels/feishu-codec.js +109 -0
  42. package/dist/channels/feishu-codec.js.map +1 -0
  43. package/dist/channels/feishu-inbound.d.ts +35 -0
  44. package/dist/channels/feishu-inbound.d.ts.map +1 -0
  45. package/dist/channels/feishu-inbound.js +136 -0
  46. package/dist/channels/feishu-inbound.js.map +1 -0
  47. package/dist/channels/feishu-websocket.d.ts +5 -0
  48. package/dist/channels/feishu-websocket.d.ts.map +1 -0
  49. package/dist/channels/feishu-websocket.js +424 -0
  50. package/dist/channels/feishu-websocket.js.map +1 -0
  51. package/dist/channels/feishu.d.ts +32 -0
  52. package/dist/channels/feishu.d.ts.map +1 -0
  53. package/dist/channels/feishu.js +233 -0
  54. package/dist/channels/feishu.js.map +1 -0
  55. package/dist/channels/index.d.ts +180 -0
  56. package/dist/channels/index.d.ts.map +1 -0
  57. package/dist/channels/index.js +93 -0
  58. package/dist/channels/index.js.map +1 -0
  59. package/dist/experimental/agent-core-messages.d.ts +27 -0
  60. package/dist/experimental/agent-core-messages.d.ts.map +1 -0
  61. package/dist/experimental/agent-core-messages.js +291 -0
  62. package/dist/experimental/agent-core-messages.js.map +1 -0
  63. package/dist/experimental/agent-core-options.d.ts +4 -0
  64. package/dist/experimental/agent-core-options.d.ts.map +1 -0
  65. package/dist/experimental/agent-core-options.js +45 -0
  66. package/dist/experimental/agent-core-options.js.map +1 -0
  67. package/dist/experimental/agent-core-ui.d.ts +21 -0
  68. package/dist/experimental/agent-core-ui.d.ts.map +1 -0
  69. package/dist/experimental/agent-core-ui.js +311 -0
  70. package/dist/experimental/agent-core-ui.js.map +1 -0
  71. package/dist/experimental/agent-core-worker-tools.d.ts +25 -0
  72. package/dist/experimental/agent-core-worker-tools.d.ts.map +1 -0
  73. package/dist/experimental/agent-core-worker-tools.js +131 -0
  74. package/dist/experimental/agent-core-worker-tools.js.map +1 -0
  75. package/dist/experimental/agent-core.d.ts +53 -0
  76. package/dist/experimental/agent-core.d.ts.map +1 -0
  77. package/dist/experimental/agent-core.js +473 -0
  78. package/dist/experimental/agent-core.js.map +1 -0
  79. package/dist/index.d.ts +19 -0
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +39 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/studio-client.d.ts +3 -0
  84. package/dist/studio-client.d.ts.map +1 -1
  85. package/dist/studio-client.js +7 -0
  86. package/dist/studio-client.js.map +1 -1
  87. package/dist/studio-stream-replay.d.ts +5 -0
  88. package/dist/studio-stream-replay.d.ts.map +1 -0
  89. package/dist/studio-stream-replay.js +63 -0
  90. package/dist/studio-stream-replay.js.map +1 -0
  91. package/dist/vendor/ai-ui/json-to-sse-transform-stream.d.ts +9 -0
  92. package/dist/vendor/ai-ui/json-to-sse-transform-stream.d.ts.map +1 -0
  93. package/dist/vendor/ai-ui/json-to-sse-transform-stream.js +20 -0
  94. package/dist/vendor/ai-ui/json-to-sse-transform-stream.js.map +1 -0
  95. package/dist/vendor/ai-ui/to-ui-message-chunk.d.ts +4 -0
  96. package/dist/vendor/ai-ui/to-ui-message-chunk.d.ts.map +1 -0
  97. package/dist/vendor/ai-ui/to-ui-message-chunk.js +301 -0
  98. package/dist/vendor/ai-ui/to-ui-message-chunk.js.map +1 -0
  99. package/dist/vendor/ai-ui/ui-message-stream-headers.d.ts +8 -0
  100. package/dist/vendor/ai-ui/ui-message-stream-headers.d.ts.map +1 -0
  101. package/dist/vendor/ai-ui/ui-message-stream-headers.js +10 -0
  102. package/dist/vendor/ai-ui/ui-message-stream-headers.js.map +1 -0
  103. package/package.json +24 -4
  104. package/src/channels/README.md +298 -0
  105. package/src/channels/feishu.ts +295 -0
  106. package/third-party/agent-core/NOTICE +81 -0
  107. package/third-party/agent-core/ahash-0.8.12/LICENSE-APACHE +201 -0
  108. package/third-party/agent-core/ahash-0.8.12/LICENSE-MIT +25 -0
  109. package/third-party/agent-core/aho-corasick-1.1.5/COPYING +3 -0
  110. package/third-party/agent-core/aho-corasick-1.1.5/LICENSE-MIT +21 -0
  111. package/third-party/agent-core/allocator-api2-0.2.21/LICENSE-APACHE +176 -0
  112. package/third-party/agent-core/allocator-api2-0.2.21/LICENSE-MIT +23 -0
  113. package/third-party/agent-core/autocfg-1.5.1/LICENSE-APACHE +201 -0
  114. package/third-party/agent-core/autocfg-1.5.1/LICENSE-MIT +25 -0
  115. package/third-party/agent-core/bit-set-0.8.0/LICENSE-APACHE +201 -0
  116. package/third-party/agent-core/bit-set-0.8.0/LICENSE-MIT +25 -0
  117. package/third-party/agent-core/bit-vec-0.8.0/LICENSE-APACHE +201 -0
  118. package/third-party/agent-core/bit-vec-0.8.0/LICENSE-MIT +25 -0
  119. package/third-party/agent-core/borrow-or-share-0.2.4/LICENSE +18 -0
  120. package/third-party/agent-core/bumpalo-3.20.3/LICENSE-APACHE +201 -0
  121. package/third-party/agent-core/bumpalo-3.20.3/LICENSE-MIT +25 -0
  122. package/third-party/agent-core/bytecount-0.6.9/LICENSE.Apache2 +201 -0
  123. package/third-party/agent-core/bytecount-0.6.9/LICENSE.MIT +19 -0
  124. package/third-party/agent-core/cfg-if-1.0.4/LICENSE-APACHE +201 -0
  125. package/third-party/agent-core/cfg-if-1.0.4/LICENSE-MIT +25 -0
  126. package/third-party/agent-core/data-encoding-2.11.1/LICENSE +22 -0
  127. package/third-party/agent-core/email_address-0.2.9/LICENSE +21 -0
  128. package/third-party/agent-core/equivalent-1.0.2/LICENSE-APACHE +201 -0
  129. package/third-party/agent-core/equivalent-1.0.2/LICENSE-MIT +25 -0
  130. package/third-party/agent-core/fancy-regex-0.19.1/LICENSE +21 -0
  131. package/third-party/agent-core/fluent-uri-0.4.1/LICENSE +21 -0
  132. package/third-party/agent-core/foldhash-0.2.0/LICENSE +19 -0
  133. package/third-party/agent-core/fraction-0.17.0/LICENSE-APACHE +201 -0
  134. package/third-party/agent-core/fraction-0.17.0/LICENSE-MIT +25 -0
  135. package/third-party/agent-core/getrandom-0.3.4/LICENSE-APACHE +201 -0
  136. package/third-party/agent-core/getrandom-0.3.4/LICENSE-MIT +26 -0
  137. package/third-party/agent-core/hashbrown-0.17.1/LICENSE-APACHE +201 -0
  138. package/third-party/agent-core/hashbrown-0.17.1/LICENSE-MIT +25 -0
  139. package/third-party/agent-core/heck-0.5.0/LICENSE-APACHE +201 -0
  140. package/third-party/agent-core/heck-0.5.0/LICENSE-MIT +25 -0
  141. package/third-party/agent-core/httpdate-1.0.3/LICENSE-APACHE +201 -0
  142. package/third-party/agent-core/httpdate-1.0.3/LICENSE-MIT +19 -0
  143. package/third-party/agent-core/itoa-1.0.18/LICENSE-APACHE +176 -0
  144. package/third-party/agent-core/itoa-1.0.18/LICENSE-MIT +23 -0
  145. package/third-party/agent-core/jsonschema-0.55.1/LICENSE +21 -0
  146. package/third-party/agent-core/jsonschema-regex-0.55.1/LICENSE +21 -0
  147. package/third-party/agent-core/jsonschema-regex-0.55.1/PROVENANCE +2 -0
  148. package/third-party/agent-core/jsonschema-value-0.55.1/LICENSE +21 -0
  149. package/third-party/agent-core/jsonschema-value-0.55.1/PROVENANCE +2 -0
  150. package/third-party/agent-core/lock_api-0.4.14/LICENSE-APACHE +201 -0
  151. package/third-party/agent-core/lock_api-0.4.14/LICENSE-MIT +25 -0
  152. package/third-party/agent-core/memchr-2.8.3/COPYING +3 -0
  153. package/third-party/agent-core/memchr-2.8.3/LICENSE-MIT +21 -0
  154. package/third-party/agent-core/micromap-0.3.0/LICENSE.txt +19 -0
  155. package/third-party/agent-core/num-0.4.3/LICENSE-APACHE +201 -0
  156. package/third-party/agent-core/num-0.4.3/LICENSE-MIT +25 -0
  157. package/third-party/agent-core/num-bigint-0.4.8/LICENSE-APACHE +201 -0
  158. package/third-party/agent-core/num-bigint-0.4.8/LICENSE-MIT +25 -0
  159. package/third-party/agent-core/num-cmp-0.1.0/LICENSE.txt +390 -0
  160. package/third-party/agent-core/num-complex-0.4.6/LICENSE-APACHE +201 -0
  161. package/third-party/agent-core/num-complex-0.4.6/LICENSE-MIT +25 -0
  162. package/third-party/agent-core/num-integer-0.1.47/LICENSE-APACHE +201 -0
  163. package/third-party/agent-core/num-integer-0.1.47/LICENSE-MIT +25 -0
  164. package/third-party/agent-core/num-iter-0.1.46/LICENSE-APACHE +201 -0
  165. package/third-party/agent-core/num-iter-0.1.46/LICENSE-MIT +25 -0
  166. package/third-party/agent-core/num-rational-0.4.2/LICENSE-APACHE +201 -0
  167. package/third-party/agent-core/num-rational-0.4.2/LICENSE-MIT +25 -0
  168. package/third-party/agent-core/num-traits-0.2.19/LICENSE-APACHE +201 -0
  169. package/third-party/agent-core/num-traits-0.2.19/LICENSE-MIT +25 -0
  170. package/third-party/agent-core/once_cell-1.21.4/LICENSE-APACHE +201 -0
  171. package/third-party/agent-core/once_cell-1.21.4/LICENSE-MIT +23 -0
  172. package/third-party/agent-core/outref-0.5.2/LICENSE +21 -0
  173. package/third-party/agent-core/parking_lot-0.12.5/LICENSE-APACHE +201 -0
  174. package/third-party/agent-core/parking_lot-0.12.5/LICENSE-MIT +25 -0
  175. package/third-party/agent-core/parking_lot_core-0.9.12/LICENSE-APACHE +201 -0
  176. package/third-party/agent-core/parking_lot_core-0.9.12/LICENSE-MIT +25 -0
  177. package/third-party/agent-core/percent-encoding-2.3.2/LICENSE-APACHE +201 -0
  178. package/third-party/agent-core/percent-encoding-2.3.2/LICENSE-MIT +25 -0
  179. package/third-party/agent-core/proc-macro2-1.0.107/LICENSE-APACHE +176 -0
  180. package/third-party/agent-core/proc-macro2-1.0.107/LICENSE-MIT +23 -0
  181. package/third-party/agent-core/quote-1.0.47/LICENSE-APACHE +176 -0
  182. package/third-party/agent-core/quote-1.0.47/LICENSE-MIT +23 -0
  183. package/third-party/agent-core/ref-cast-1.0.27/LICENSE-APACHE +176 -0
  184. package/third-party/agent-core/ref-cast-1.0.27/LICENSE-MIT +23 -0
  185. package/third-party/agent-core/ref-cast-impl-1.0.27/LICENSE-APACHE +176 -0
  186. package/third-party/agent-core/ref-cast-impl-1.0.27/LICENSE-MIT +23 -0
  187. package/third-party/agent-core/referencing-0.55.1/LICENSE +21 -0
  188. package/third-party/agent-core/regex-1.13.1/LICENSE-APACHE +201 -0
  189. package/third-party/agent-core/regex-1.13.1/LICENSE-MIT +25 -0
  190. package/third-party/agent-core/regex-automata-0.4.18/LICENSE-APACHE +201 -0
  191. package/third-party/agent-core/regex-automata-0.4.18/LICENSE-MIT +25 -0
  192. package/third-party/agent-core/regex-syntax-0.8.11/LICENSE-APACHE +201 -0
  193. package/third-party/agent-core/regex-syntax-0.8.11/LICENSE-MIT +25 -0
  194. package/third-party/agent-core/rustversion-1.0.23/LICENSE-APACHE +176 -0
  195. package/third-party/agent-core/rustversion-1.0.23/LICENSE-MIT +23 -0
  196. package/third-party/agent-core/scopeguard-1.2.0/LICENSE-APACHE +201 -0
  197. package/third-party/agent-core/scopeguard-1.2.0/LICENSE-MIT +25 -0
  198. package/third-party/agent-core/serde-1.0.229/LICENSE-APACHE +176 -0
  199. package/third-party/agent-core/serde-1.0.229/LICENSE-MIT +23 -0
  200. package/third-party/agent-core/serde_core-1.0.229/LICENSE-APACHE +176 -0
  201. package/third-party/agent-core/serde_core-1.0.229/LICENSE-MIT +23 -0
  202. package/third-party/agent-core/serde_derive-1.0.229/LICENSE-APACHE +176 -0
  203. package/third-party/agent-core/serde_derive-1.0.229/LICENSE-MIT +23 -0
  204. package/third-party/agent-core/serde_json-1.0.151/LICENSE-APACHE +176 -0
  205. package/third-party/agent-core/serde_json-1.0.151/LICENSE-MIT +23 -0
  206. package/third-party/agent-core/smallvec-1.16.0/LICENSE-APACHE +201 -0
  207. package/third-party/agent-core/smallvec-1.16.0/LICENSE-MIT +25 -0
  208. package/third-party/agent-core/strum-0.28.0/LICENSE +21 -0
  209. package/third-party/agent-core/strum_macros-0.28.0/LICENSE +21 -0
  210. package/third-party/agent-core/syn-2.0.119/LICENSE-APACHE +176 -0
  211. package/third-party/agent-core/syn-2.0.119/LICENSE-MIT +23 -0
  212. package/third-party/agent-core/syn-3.0.5/LICENSE-APACHE +176 -0
  213. package/third-party/agent-core/syn-3.0.5/LICENSE-MIT +23 -0
  214. package/third-party/agent-core/unicode-general-category-1.1.0/LICENSE +201 -0
  215. package/third-party/agent-core/unicode-ident-1.0.24/LICENSE-APACHE +176 -0
  216. package/third-party/agent-core/unicode-ident-1.0.24/LICENSE-MIT +23 -0
  217. package/third-party/agent-core/unicode-ident-1.0.24/LICENSE-UNICODE +39 -0
  218. package/third-party/agent-core/uuid-simd-0.8.0/LICENSE +21 -0
  219. package/third-party/agent-core/uuid-simd-0.8.0/PROVENANCE +2 -0
  220. package/third-party/agent-core/version_check-0.9.5/LICENSE-APACHE +201 -0
  221. package/third-party/agent-core/version_check-0.9.5/LICENSE-MIT +19 -0
  222. package/third-party/agent-core/vsimd-0.8.0/LICENSE +21 -0
  223. package/third-party/agent-core/vsimd-0.8.0/PROVENANCE +2 -0
  224. package/third-party/agent-core/wasm-bindgen-0.2.128/LICENSE-APACHE +201 -0
  225. package/third-party/agent-core/wasm-bindgen-0.2.128/LICENSE-MIT +25 -0
  226. package/third-party/agent-core/wasm-bindgen-macro-0.2.128/LICENSE-APACHE +201 -0
  227. package/third-party/agent-core/wasm-bindgen-macro-0.2.128/LICENSE-MIT +25 -0
  228. package/third-party/agent-core/wasm-bindgen-macro-support-0.2.128/LICENSE-APACHE +201 -0
  229. package/third-party/agent-core/wasm-bindgen-macro-support-0.2.128/LICENSE-MIT +25 -0
  230. package/third-party/agent-core/wasm-bindgen-shared-0.2.128/LICENSE-APACHE +201 -0
  231. package/third-party/agent-core/wasm-bindgen-shared-0.2.128/LICENSE-MIT +25 -0
  232. package/third-party/agent-core/zerocopy-0.8.57/LICENSE-APACHE +202 -0
  233. package/third-party/agent-core/zerocopy-0.8.57/LICENSE-BSD +24 -0
  234. package/third-party/agent-core/zerocopy-0.8.57/LICENSE-MIT +26 -0
  235. package/third-party/agent-core/zmij-1.0.23/LICENSE-MIT +23 -0
  236. package/third-party/ai-ui/LICENSE-APACHE +201 -0
  237. package/third-party/ai-ui/NOTICE +15 -0
package/README.md CHANGED
@@ -1,1160 +1,9 @@
1
1
  # `@gea-ai/agent-sdk`
2
2
 
3
- `@gea-ai/agent-sdk` is the code-first authoring SDK for GEA Agent
4
- applications. It defines main Agents, package-local executable Tools, Skill
5
- references, Agent-owned Durable Objects, and secret-free Connector definitions
6
- and requirements.
7
-
8
- The SDK retains executable handlers for Worker runtime use.
9
- `createAgentPackageSnapshot()` produces deterministic JSON-compatible metadata
10
- for validation, Studio display, and exact-version execution. Snapshots never
11
- contain handler functions, credentials, Connector Connections, tenant identity,
12
- provider configuration, or environment values.
13
-
14
- ## Agent Authoring Shapes
15
-
16
- A single-main application starts with root `agent.ts` and `AGENTS.md`:
17
-
18
- ```ts
19
- import { defineAgent } from "@gea-ai/agent-sdk";
20
-
21
- export default defineAgent({
22
- model: "gea-model-1",
23
- name: "research-agent",
24
- slug: "research-agent",
25
- });
26
- ```
27
-
28
- An Agent may instead declare capability thresholds for the SDK's first-party
29
- Creative Reasoning router:
30
-
31
- ```ts
32
- export default defineAgent({
33
- model: "auto",
34
- modelRequirements: {
35
- agentic: 0.8,
36
- copywriting: 0.6,
37
- multimodal: 0.4,
38
- speed: 0.7,
39
- },
40
- name: "research-agent",
41
- slug: "research-agent",
42
- });
43
- ```
44
-
45
- Each requirement is an optional minimum score from `0` to `1`; omitted
46
- dimensions do not constrain selection. `modelRequirements` is required for
47
- `model: "auto"` and rejected for a concrete model. The SDK filters its curated
48
- Creative Reasoning capability table and selects the eligible model with the
49
- lowest configured cost rank. It writes only the selected concrete CR gateway
50
- model ID into the package snapshot, so runtime model selection does not change
51
- when a later SDK updates the table.
52
-
53
- This table is maintained in the SDK; it does not query CR model discovery,
54
- verify API-key access, or read the deployment's model catalog or prices.
55
- Capability scores and cost ranks are provisional routing parameters rather
56
- than official platform measurements or actual catalog prices. The following
57
- candidate IDs and upstream mappings were supplied by the platform owner on
58
- 2026-09-05; authenticated access still needs verification for each deployment.
59
- The mapping is developer information and is not a product display label.
60
-
61
- | CR gateway model ID | Upstream mapping | Cost rank | Agentic | Copywriting | Multimodal | Speed |
62
- | ------------------------ | ----------------- | --------- | ------- | ----------- | ---------- | ----- |
63
- | `deepseek-v4-flash` | DeepSeek V4 Flash | 1 | 0.5 | 0.5 | 0 | 1 |
64
- | `crr-q-flash-20260826` | Qwen3.8 Flash | 2 | 0.55 | 0.6 | 0 | 1 |
65
- | `crr-o-mini-20260710` | gpt-5.6-luna | 3 | 0.55 | 0.45 | 0.55 | 1 |
66
- | `deepseek-v4-pro` | DeepSeek V4 Pro | 4 | 0.8 | 0.75 | 0 | 0.65 |
67
- | `crr-q-pro-20260804` | Qwen3.8 Max | 5 | 0.85 | 0.8 | 0 | 0.6 |
68
- | `crr-o-20260710` | gpt-5.6-terra | 6 | 0.8 | 0.7 | 0.75 | 0.7 |
69
- | `creative-reasoning-1.5` | Claude Sonnet 5 | 7 | 0.8 | 0.9 | 0.7 | 0.65 |
70
- | `crr-o-pro-20260710` | gpt-5.6-sol | 8 | 0.95 | 0.82 | 0.85 | 0.45 |
71
- | `crr-a-pro-20260724` | Claude Opus 5 | 9 | 1 | 1 | 0.85 | 0.35 |
72
-
73
- Qwen and DeepSeek currently have a zero multimodal routing score until their
74
- gateway support is verified; any positive multimodal requirement excludes
75
- them. Existing GPT and Claude routing thresholds are retained. With this
76
- candidate set, `multimodal: 0.9` or `{ multimodal: 0.8, speed: 0.9 }` has no
77
- eligible model and fails during Agent definition. Removing an auto candidate
78
- does not invalidate an explicit model declaration or an existing snapshot.
79
-
80
- For hosted execution, register these nine IDs in
81
- `LLM_MODEL_CATALOG_JSON.models`, using `creative-reasoning/<gateway-model-id>`
82
- targets and actual target-keyed prices. Keep the existing `gea-fast` and
83
- `gea-pro` aliases and set `selectableModels: ["gea-fast", "gea-pro"]` so normal
84
- product selectors show only those aliases. Studio developers can inspect the
85
- immutable version's model but cannot override it in Playground.
86
-
87
- `defineAgent({ model: "auto", ... })` provides contextual field completion for
88
- all four requirements. Standalone input annotations require a model type:
89
- `DefineAgentInput<"auto">` requires the capability fields, while
90
- `DefineAgentInput<"crr-a-pro-20260724">` forbids them. There is no implicit
91
- `string` model parameter, because it would also accept `"auto"` without its
92
- requirements. Direct `defineAgent(...)` calls infer the model type.
93
-
94
- A concrete first-party model may use any unqualified public ID, such as
95
- `crr-a-pro-20260724`, `creative-reasoning-1.5`, or
96
- `creative-reasoning-1.5-flash`. An explicit Creative Reasoning provider ID such
97
- as `creative-reasoning/kimi-k3` is also supported. The snapshot preserves the
98
- declared concrete ID.
99
-
100
- Tools, Connectors, Hooks, referenced Skills, and local Skills are discovered
101
- from conventional sibling directories. The required `slug` is the Agent's
102
- stable identity inside this Worker application. It becomes the manifest and
103
- runtime `agentKey`; `name` remains display metadata.
104
-
105
- A root Agent may stay in place when the application adds more main Agents under
106
- `agents/<slug>/agent.ts`. This preserves the original Agent's identity and
107
- root `benchmarks/`. A directory Agent's declared slug must match its directory
108
- name. Applications without a root Agent may use `agents/default/` as the
109
- default source alias; that Agent still declares a real non-reserved slug. If
110
- there is no root or `agents/default/`, the lexically first directory Agent owns
111
- the default route. `default`, `run`, and `sessions` are reserved protocol
112
- segments and cannot be Agent slugs.
113
-
114
- ```text
115
- agents/default/agent.ts
116
- agents/default/AGENTS.md
117
- agents/support/agent.ts
118
- agents/support/AGENTS.md
119
- ```
120
-
121
- Add root `worker.ts` only when the same Worker also serves UI, business APIs,
122
- assets, or application Durable Objects. The CLI generates Agent assembly and
123
- prepends it to the application handler. Developers do not list Tools, Skills,
124
- or Connectors again in `worker.ts`.
125
-
126
- Generated code uses `createAgentApplicationFetch()`, which owns:
127
-
128
- ```text
129
- /gea/agents/run
130
- /gea/agents/<agentKey>/run
131
- /gea/agents[/<agentKey>]/sessions/<sessionId>/v1/<operation>
132
- ```
133
-
134
- Hosted Agent HTTP handlers require a Project API Key by default. This applies
135
- to the Agent routes, while ordinary routes in `worker.ts` remain public.
136
-
137
- ```ts
138
- // Inside defineAgent(...):
139
- http: {
140
- auth: false;
141
- } // Explicit public access to this Agent's HTTP API.
142
- ```
143
-
144
- An application can replace the default with its own Session authenticator:
145
-
146
- ```ts
147
- http: {
148
- auth: async (request, { environment }) => {
149
- const session = await getSession(request, environment); // Your verified session.
150
- return session
151
- ? { principalType: "user", principalId: session.userId }
152
- : null;
153
- },
154
- }
155
- ```
156
-
157
- The callback returns an external user, a `Response`, or `null` (401). It may
158
- also return the result of `projectKeyAuth()` to explicitly compose key auth.
159
- There is no implicit fallback after a custom authenticator rejects. Project
160
- Keys stay on the backend; they never represent the creator's GEA user.
161
- `authenticateProjectKey(request, environment.PROJECT)` also works in ordinary
162
- Worker routes with a declared Project binding and a Project attachment.
163
-
164
- Application pages and browser Sessions require the operator's isolated
165
- `WORKER_APP_BASE_URL`. GEA-domain and path ingress preserve API access but strip
166
- platform cookies and force CSP sandbox plus `nosniff`; Worker pages cannot run
167
- scripts there. Application-domain pages retain their own CSP. Local `gea agent dev` uses its
168
- existing trusted development identity. Raw AgentSession and Connector auth
169
- operations remain private regardless of `http.auth`. Rebuild and republish old
170
- Agent packages with the matching SDK/CLI to enable the new hosted handler.
171
-
172
- The public run request is intentionally small:
173
-
174
- ```json
175
- { "chatId": "optional-continuation-id", "message": "Hello" }
176
- ```
177
-
178
- If `chatId` is absent, the hosted managed API creates a Chat and Run and returns
179
- their IDs in response headers. Local execution creates its local Session identity.
180
- Callers cannot supply model-loop messages, instructions, provider options, or
181
- platform-owned Run/message IDs. Each main Agent's exact `AGENTS.md` text is
182
- compiled into the Worker and is never accepted from the run request.
183
-
184
- `composeFetch()` delegates unclaimed requests to the optional application
185
- Worker. Worker Runtime remains route-agnostic.
186
-
187
- Every main Agent declares one concrete public GEA model ID or the SDK-owned
188
- `auto` selector above. GEA resolves the concrete snapshot model through the
189
- active Model Gateway catalog; source and artifacts contain no provider
190
- credential or target configuration.
191
-
192
- ## Context strategies
193
-
194
- Agents use the existing tool-output offload and rolling summary by default.
195
- Configure that recipe with `defaultContext`, replace it with a custom strategy,
196
- or set `context: false` to disable automatic summaries, file writes and tool-result
197
- replacement. Disabling compression preserves already committed summaries and
198
- continues normal message persistence.
199
-
200
- ```ts
201
- import { defineAgent } from "@gea-ai/agent-sdk";
202
- import { defaultContext } from "@gea-ai/agent-sdk/context";
203
-
204
- export default defineAgent({
205
- name: "assistant",
206
- slug: "assistant",
207
- model: "gea-model-1",
208
- context: defaultContext({
209
- toolOutput: { offloadAtCharacters: 4_000, replaceAtCharacters: 8_000 },
210
- preserveRecentGroups: 5,
211
- summarization: {
212
- triggerAtTotalTokens: 64_000,
213
- // Optional: model, instructions, maxOutputTokens.
214
- },
215
- }),
216
- });
217
- ```
218
-
219
- `toolOutput: false` and `summarization: false` independently disable the two
220
- parts of the default recipe. Thresholds use model-visible characters and the
221
- last provider-reported `usage.totalTokens`; the SDK does not estimate tokens.
222
- Recent groups keep tool calls and their results together. Without Computer
223
- storage, the default recipe skips offload but can still summarize.
224
-
225
- A custom strategy is an object with optional `prepareStep`, `onStepEnd` and
226
- `onEnd` callbacks, using the AI SDK 7 names. These callbacks replace the default
227
- recipe. `prepareStep` receives durable `messages`, `contextSize`, `stepNumber`
228
- and `runtimeContext`; returning `{ messages }` replaces the active projection
229
- for subsequent steps and Runs. Returning nothing keeps it. `onStepEnd` also
230
- receives that step's `usage` and `finishReason`; `onEnd` receives the main loop's
231
- `totalUsage` and `finishReason`.
232
-
233
- ```ts
234
- const context = {
235
- async prepareStep({ messages, runtimeContext }) {
236
- const memory = await loadCommittedMemory(runtimeContext);
237
- return { messages: applyMemoryToCoveredPrefix(messages, memory) };
238
- },
239
- async onStepEnd({ messages, runtimeContext }) {
240
- runtimeContext.waitUntil(precomputeMemory(messages, runtimeContext));
241
- },
242
- };
243
- ```
244
-
245
- The functions in this short sketch are application-owned.
246
-
247
- `runtimeContext` provides trusted `identity`, `auth`, declared `env`, execution
248
- `environment`, typed `durableObjects`, `signal`, and the main public `modelId`.
249
- Call `model(modelId?)` to resolve a model through the existing Host, then use AI
250
- SDK `generateText` or `streamText` with that model and the cancellation signal.
251
- Register each auxiliary call's `{ model, usage, label?, status? }` through
252
- `recordUsage`. Status defaults to `completed`; use `failed` or `aborted` with
253
- `usage: null` when the provider did not return usage. Register a successful call
254
- before validating its text or committing memory, since those operations can fail
255
- after the model has consumed tokens. The SDK assigns the call id and tracks its
256
- Session write automatically.
257
- `writeToolOutput` is a writer returning `{ artifactUri }`, or `null` if storage
258
- is unavailable. Its input is `{ content, sha256, toolCallId, toolName }`.
259
-
260
- `runtimeContext.updateMessages(messages)` persists a replacement from an awaited
261
- foreground callback, including the final step or `onEnd`. Background work stores
262
- candidate memory in a DO; a later foreground callback applies it. The Worker
263
- waits for registered work before publishing its final success and usage, including
264
- when Computer is disabled. `metadata.modelCalls` records each main-model step and
265
- auxiliary call with a stable call id, Run id, model, source, optional label, status,
266
- completion time and usage. `metadata.totalUsage` is their known usage sum;
267
- `metadata.contextUsage` retains the auxiliary view. Hosted settlement prices each
268
- call using its own catalog target and writes a separate idempotent usage event.
269
- A completed model call stays completed even if the containing Run later fails.
270
- Unhandled callback or background errors fail the Run; completed model messages
271
- and registered usage survive that failure. Pass `signal` into external work so cancellation can finish promptly.
272
-
273
- AgentSession owns the active projection and separate transcript. Custom
274
- observations, reflection and coverage state belong in the application's chat DO.
275
- Commit memory and coverage together before removing the covered message prefix.
276
- Existing summary metadata is included when a custom callback reads messages, and
277
- is no longer separately injected after that callback replaces the projection.
278
- `stepNumber` is local to a Run, not a durable chat cursor.
279
-
280
- Context callbacks execute in the Agent bundle; snapshots contain only serializable
281
- descriptors and default recipe options. Ordinary imported modules are sufficient.
282
- Upgrade the SDK and rebuild/publish existing Agents to use the API. `waitUntil`
283
- covers the current invocation; it does not schedule future Runs or replay a model
284
- call after a crash.
285
-
286
- ## CLI Workflow
287
-
288
- Local validation, development, and packing need no hosted Agent record:
3
+ The TypeScript SDK for building GEA Agent applications.
289
4
 
290
5
  ```bash
291
- gea agent validate --json '{"cwd":"."}'
292
- gea agent dev --json '{"cwd":"."}'
293
- gea agent eval --json '{"cwd":".","judgeModel":"gea-model-1"}'
294
- gea agent pack --json '{"cwd":"."}'
295
- ```
296
-
297
- `gea agent dev` treats every unqualified model ID, plus explicit
298
- `creative-reasoning/<model>` IDs, as first-party Creative Reasoning models. It
299
- calls Creative Reasoning directly when `CREATIVE_REASONING_API_KEY` is present;
300
- when the key is absent it falls back to the hosted web model proxy and the
301
- current `gea login` Workspace. An explicit `{"modelSource":"hosted"}` keeps
302
- hosted routing. `{"modelSource":"local"}` forces local routing and therefore
303
- requires the Creative Reasoning key for first-party models; other qualified
304
- local providers continue to use their configured local catalog.
305
- `gea agent eval` applies the same decision to both Agent models and the active
306
- `judgeModel`, so a direct evaluation catalog contains every model the run uses.
307
-
308
- Native Anthropic calls, including `crr-a-*` and `creative-reasoning-1.5`, apply
309
- the SDK's shared rolling prompt-cache policy before provider serialization.
310
- System prompts, conversation prefixes, and eligible Tool definitions retain
311
- cache markers across model steps and turns. Markers belong only to outbound
312
- requests and never enter the stored AgentSession context. Hosted calls retain
313
- their existing proxy-owned cache policy.
314
-
315
- `gea agent eval` discovers Cases and inherited Judges from the Benchmark next
316
- to each main Agent's `tools/`: root `benchmarks/` for the root Agent, including
317
- after additional main Agents are added, and `agents/<slug>/benchmarks/` for
318
- directory Agents. It runs each Case through that main Agent's stable slug route
319
- and writes results under `.gea/evals`. Use `{"agentKey":"support"}` to select
320
- one main Agent. A Case's optional
321
- `expected` value enables the built-in Autoeval Judge. Author semantic rubrics
322
- as `*.judge.md`; author deterministic trajectory checks as `*.judge.ts` with
323
- the `./evals` SDK export. Autoeval may query bounded run evidence across
324
- multiple model steps and finishes by calling a structured result Tool; it does
325
- not require the model's text response to be JSON:
326
-
327
- ```ts
328
- import { defineJudge } from "@gea-ai/agent-sdk/evals";
329
-
330
- export default defineJudge(({ messages }) => {
331
- const usedSearch = messages.some((message) =>
332
- message.parts.some((part) => part.type === "tool-search"),
333
- );
334
- return {
335
- reason: usedSearch ? "Search was used." : "Search was not used.",
336
- score: usedSearch ? 1 : 0,
337
- };
338
- });
339
- ```
340
-
341
- `gea agent dev` and `gea agent eval` generate `.gea/bindings.d.ts` from the
342
- owning main Agent's `tools/` and snapshot-known runtime Tool names. This
343
- registers the canonical root SDK types:
344
-
345
- ```ts
346
- import agent from "./agent";
347
- import type {
348
- AgentMessage,
349
- AgentMessageFor,
350
- InferAgentMessage,
351
- } from "@gea-ai/agent-sdk";
352
-
353
- type DefaultMessage = AgentMessage;
354
- type SupportMessage = AgentMessageFor<"support">;
355
- type ThisAgentMessage = InferAgentMessage<typeof agent>;
356
- ```
357
-
358
- All three are ordinary AI SDK `UIMessage` types. Static custom `tool-*` parts
359
- preserve Tool names, Zod input types, and return types. Snapshot-known Computer
360
- and Connector Tools preserve their concrete `tool-*` names with generic input
361
- and output. MCP Tool parts use the qualified template
362
- `tool-<alias>__${string}` because their catalog is runtime-discovered; truly
363
- unqualified runtime Tools remain `dynamic-tool` parts. SDK-first Agent Workers
364
- currently emit no custom `data-*` parts, so Legacy chat data parts are not
365
- included. Code Judges consume the same types rather than defining an
366
- Eval-specific message model.
367
- `InferAgentMessage<typeof agent>` resolves to `never` when the generated
368
- registry is absent or its Agent slug does not match, rather than silently
369
- falling back to an unrelated Tool catalog.
370
-
371
- Studio also runs `defineApiConnector`, `defineMcpConnector`, and deployment-enabled
372
- built-in `geaConnect` providers through the managed Host. All use existing
373
- Project/Agent Connections, isolated by Preview/Production and application
374
- principal. No database migration or personal credential inheritance is involved.
375
- API keys default to `connection: { principalType: "agent" }`; OAuth and
376
- `geaConnect` default to `"user"`. All three helpers accept an explicit
377
- `connection: { principalType: "agent" | "user" }`. No-auth API/MCP endpoints
378
- need no Connection. Custom executable `defineConnector` ownership stays unchanged.
379
-
380
- Configure Agent-owned credentials in Project Connections or an Agent override.
381
- User-owned authorization links bind the application's supplied principal; missing
382
- user identity returns `principal_required`. OAuth client variables come from the
383
- selected environment. Register `${APP_BASE_URL}/api/agent-connectors/oauth/callback`
384
- for hosted OAuth, including the deployment Google OAuth client used by Google Drive.
385
- API keys are submitted on a public, state-bound setup page; OAuth uses PKCE;
386
- Feishu uses the host's isolated managed CLI. Credentials and refresh state remain
387
- encrypted in the original Connection scope and never enter Worker code.
388
-
389
- Rebuild old `geaConnect` snapshots to declare Studio ownership. Supported native
390
- providers are Google Drive, Feishu, Social Search, and WeChat Official Account,
391
- subject to deployment availability. Other platform resource references should
392
- use `defineApiConnector` or `defineMcpConnector` with an explicit endpoint.
393
- CLI upload preparation rejects old personal-authorization declarations and GEA
394
- user identity injection with the Connector alias, key, runtime, and reason.
395
- The server additionally checks native provider availability before publication.
396
-
397
- Configure a package-local API or MCP Connector without uploading its
398
- credential:
399
-
400
- ```bash
401
- gea agent connect exa-market-intelligence
402
- ```
403
-
404
- An MCP Connector declares only its stable server and authentication boundary:
405
-
406
- ```ts
407
- import { defineMcpConnector, noAuth } from "@gea-ai/agent-sdk";
408
-
409
- export default defineMcpConnector({
410
- auth: noAuth(),
411
- key: "product-docs",
412
- name: "Product Docs",
413
- serverUrl: "https://mcp.example.com/mcp",
414
- }).require();
415
- ```
416
-
417
- Its current Tools and schemas are discovered at the start of every run and
418
- exposed as `product-docs__<tool>`. They are not persisted in the Agent Package.
419
-
420
- API-key input is hidden. OAuth uses Authorization Code plus S256 PKCE through
421
- `http://127.0.0.1:8788/oauth/callback`. Credentials stay under `~/.gea`,
422
- scoped to canonical project path and Connector definition, and are reread for
423
- each local Tool call.
424
-
425
- Platform Connectors declared with `geaConnect(...)` are called through the
426
- Workspace selected by `gea login` and `gea workspace use`; their platform-owned
427
- credentials are never copied into the local project. This same local Connector
428
- Host behavior is used by both `gea agent dev` and `gea agent eval`.
429
-
430
- After `gea workspace use`, publish the complete Worker application:
431
-
432
- ```bash
433
- gea agent push --json '{"cwd":".","slug":"product-worker"}'
434
- ```
435
-
436
- The command uploads one generic Worker deployment and registers every main
437
- Agent in Studio by Worker plus Agent key. The new deployment becomes Preview.
438
- It never creates or updates Legacy `app_resource` or resource-package rows.
439
- Preview and Production promotion are Worker-wide.
440
-
441
- Use a Studio Agent ID to start its selected environment:
442
-
443
- ```bash
444
- gea agent run --json '{"agentId":"<studio-agent-id>","prompt":"Inspect the project"}'
445
- ```
446
-
447
- The server pins the exact Studio Agent version, Agent key, Worker ID, and Worker
448
- deployment to the Run. Recovery never follows a later environment target or
449
- falls back to Legacy.
450
-
451
- Custom Tools may omit `execute` to delegate execution to the calling application.
452
- These Tools are recorded as `execution: "client"` in the package snapshot and
453
- pause with an `input-available` Tool part. The application returns the result
454
- through AI SDK `addToolOutput`. Studio Tool approvals and client outputs use the
455
- existing `/run` endpoint with the server's assistant message ID.
456
- This capability requires updated SDK, Web/ORPC and Agent deployments.
457
-
458
- Package Tools may declare a static or input-dependent approval policy. A
459
- `user-approval` decision pauses before execution and can be resumed from any
460
- supported Chat client. For example:
461
-
462
- ```ts
463
- import { defineTool } from "@gea-ai/agent-sdk";
464
- import { z } from "zod";
465
-
466
- export default defineTool({
467
- approval: ({ amount }) => (amount > 100 ? "user-approval" : "not-applicable"),
468
- description: "Transfer credits after any required user approval.",
469
- execute: async ({ amount }) => ({ transferred: amount }),
470
- input: z.object({ amount: z.number().positive() }),
471
- name: "transfer_credits",
472
- });
473
- ```
474
-
475
- ```text
476
- coding-agent/
477
- agent.ts
478
- AGENTS.md
479
- connectors/github.ts
480
- hooks/before-turn.ts
481
- durable-objects/agent-counter.ts
482
- skills/project-conventions/SKILL.md
483
- tools/agent.ts
484
- tools/search-github.ts
485
- tools/chat-list.ts
486
- tools/chat-read.ts
487
- tools/chat-send.ts
488
- tools/computer.ts
489
- tools/web-search.ts
490
- ```
491
-
492
- ```ts
493
- // agent.ts
494
- import { DurableObject } from "cloudflare:workers";
495
- import { defineAgent } from "@gea-ai/agent-sdk";
496
- import { AgentCounter } from "./durable-objects/agent-counter";
497
-
498
- export { AgentCounter };
499
-
500
- export default defineAgent({
501
- computer: {
502
- enabled: true,
503
- filesystem: { durability: "durable", scope: "user" },
504
- },
505
- durableObjects: { COUNTER: AgentCounter },
506
- model: "gea-model-1",
507
- name: "coding-agent",
508
- slug: "coding-agent",
509
- });
510
- ```
511
-
512
- ```ts
513
- // hooks/before-turn.ts
514
- import { defineHook } from "@gea-ai/agent-sdk";
515
-
516
- export default defineHook({
517
- event: "beforeTurn",
518
- run: ({ identity, now }) => ({
519
- prepend: [
520
- `Current time: ${now.toISOString()}`,
521
- `Act only for workspace ${identity.workspace.id}.`,
522
- ].join("\n"),
523
- }),
524
- });
525
- ```
526
-
527
- Durable Object implementations declared by `defineAgent()` must be named
528
- exports from `agent.ts` in a headless project, or from `worker.ts` when an
529
- explicit application Worker exists. Keep the same exported class name,
530
- binding, and object ID to retain state across releases. Install
531
- `@cloudflare/workers-types` for Cloudflare-compatible authoring types.
532
-
533
- Public methods on the class are native typed RPC methods. The generated
534
- `.gea/bindings.d.ts` connects the binding to the exported class, so separate
535
- Tool files get method, input, and result autocomplete without internal URLs or
536
- a second contract definition:
537
-
538
- ```ts
539
- // durable-objects/agent-counter.ts
540
- import { DurableObject } from "cloudflare:workers";
541
-
542
- export class AgentCounter extends DurableObject {
543
- async increment({ by }: { by: number }) {
544
- const value = ((await this.ctx.storage.get<number>("value")) ?? 0) + by;
545
- await this.ctx.storage.put("value", value);
546
- return { value };
547
- }
548
- }
6
+ npm install @gea-ai/agent-sdk
549
7
  ```
550
8
 
551
- ```ts
552
- // tools/increment-counter.ts
553
- import { defineTool } from "@gea-ai/agent-sdk";
554
- import { z } from "zod";
555
-
556
- export default defineTool({
557
- description: "Increment the workspace counter.",
558
- execute: async ({ by }, context) => {
559
- const counter = context.durableObjects.COUNTER.getByName(
560
- `workspace:${context.identity.workspace.id}`,
561
- );
562
- return await counter.increment({ by });
563
- },
564
- input: z.object({ by: z.number().int() }),
565
- name: "increment_counter",
566
- });
567
- ```
568
-
569
- RPC arguments and results use structured clone. `fetch`, alarms, and WebSocket
570
- lifecycle handlers remain lifecycle methods rather than model-facing RPC.
571
- Browser code should still call an authenticated Worker API and must not receive
572
- a Durable Object namespace or choose an identity-derived object key.
573
-
574
- `AGENTS.md` is required and automatically becomes the only instruction
575
- entrypoint. Every discovered `tools/**/*.ts`, `connectors/**/*.ts`,
576
- `hooks/**/*.ts`, and direct `skills/*.ts` file must default-export its SDK
577
- definition. Local Skills are discovered from `skills/<name>/SKILL.md`. Tests,
578
- specs, and `_`-prefixed files are ignored.
579
-
580
- SDK-first Agents do not inherit legacy runtime reminders. Use the optional
581
- `beforeTurn` hook for dynamic hidden context derived from the current message,
582
- stable identity, declared environment, or current time. The runtime prepends
583
- the returned text to the active user message, stores that transformed message
584
- in AgentSession model context before calling the model, and reuses it for Tool
585
- steps, approval continuation, and same-Run recovery. It does not change the
586
- public Chat message. Keep stable instructions in `AGENTS.md` so prompt caching
587
- can reuse the system prefix.
588
-
589
- When the exact Package Version contains Skills, the runtime adds one stable
590
- `loadSkill` Tool, including when Computer is disabled. Call
591
- `loadSkill({ skill: "report" })` to read `SKILL.md`, or
592
- `loadSkill({ skill: "report", path: "references/format.md" })` to read another
593
- UTF-8 text file relative to that Skill's root. Absolute paths and traversal are
594
- rejected. Each read returns `{ skill, path, content }`, with a relative `path`,
595
- and is limited to 512 KiB. When the existing Computer initialization has prepared
596
- the mount, the result also includes `executionDirectory`, the selected Skill's
597
- read-only root in that Computer. Binary files are not a text-reading surface.
598
-
599
- Both entry instructions and supporting files come directly from the exact
600
- immutable Worker bundle; reading them never opens Computer. The Tool description
601
- lists all available Skill slugs and descriptions and explains the optional
602
- `executionDirectory`. The directory comes from the initialized session's actual
603
- roots; the description contains no physical path assumptions. Script execution
604
- uses the Agent's provided execution Tools. Skill loading does not grant execution,
605
- install interpreters, or add system instructions.
606
-
607
- The CLI uses the same SDK Tool builder as the Worker to emit
608
- `definition/skill-tools/<agentKey>.json` in each expanded dev artifact and Agent
609
- archive. Inspect `.gea/agent-dev/definition/skill-tools/<agentKey>.json` after
610
- `gea agent dev` to see the final `description` and `inputSchema`. The preview
611
- contains the complete static Skill catalog, not file contents or an additional
612
- runtime configuration. Use matching updated CLI and Agent SDK versions to build
613
- these artifacts; existing published Workers keep their bundled behavior.
614
-
615
- `createAgentSkillTool({ files, snapshot, mountedRoot? })` accepts only bundled
616
- files, the snapshot, and an optional already prepared mount root. It never creates
617
- a Computer or mounts files. Provider session initialization prepares Skills before
618
- the model runs and passes this root to the Tool builder. Legacy Computer
619
- configuration retains lazy mounting and omits `executionDirectory` when the Tool
620
- is constructed before mounting. Existing Computer capability validation still
621
- applies. `readFile` remains available for Computer filesystem access, while
622
- `loadSkill` is the portable Skill text reader.
623
-
624
- The generated Agent Worker constructs the complete model-facing Tool set inside
625
- V8 from the bundled package snapshot and Tool runtime. Web initializes only
626
- runtime capabilities, Connector state, and dynamic Connector input schemas;
627
- the run body contains no serialized AI SDK Tools. Privileged Connector,
628
- conversation, and search execution remains behind the private Tools binding.
629
-
630
- ```ts
631
- // tools/web-search.ts
632
- import { webSearch } from "@gea-ai/agent-sdk";
633
-
634
- export default webSearch();
635
- ```
636
-
637
- Conversation capabilities are selected the same way and remain independent:
638
-
639
- ```ts
640
- // tools/chat-list.ts
641
- import { chatList } from "@gea-ai/agent-sdk";
642
-
643
- export default chatList();
644
- ```
645
-
646
- Use `agentTool()` to let the model create an isolated child Agent conversation.
647
- The model-visible Tool is named `agent`; omitting its optional `agentSlug`
648
- starts the current Agent in a fresh context. The returned `chatId` is then
649
- handled by the ordinary Conversation Tools: `chatList()` discovers child
650
- conversations, `chatRead()` reads their bounded transcript, and `chatSend()`
651
- continues an idle conversation. There is no separate `subagent_*` Tool family.
652
-
653
- ```ts
654
- // tools/agent.ts
655
- import { agentTool } from "@gea-ai/agent-sdk";
656
-
657
- export default agentTool();
658
- ```
659
-
660
- Select `chatRead()` and `chatSend()` in their corresponding files only when the
661
- Agent should be able to inspect or continue conversations.
662
-
663
- One Tool module may group reusable selections without changing the serialized
664
- Agent Package contract:
665
-
666
- ```ts
667
- // tools/research.ts
668
- import { chatRead, defineToolSet, webSearch } from "@gea-ai/agent-sdk";
669
-
670
- export default defineToolSet([chatRead(), webSearch()]);
671
- ```
672
-
673
- Tool Sets may contain other Tool Sets. Their entries are flattened from left to
674
- right, and the CLI preserves that order after deterministic file discovery.
675
-
676
- Computer setup has two independent parts. First enable the runtime in
677
- `agent.ts`:
678
-
679
- ```ts
680
- // agent.ts
681
- import { defineAgent } from "@gea-ai/agent-sdk";
682
-
683
- export default defineAgent({
684
- computer: {
685
- enabled: true,
686
- filesystem: { durability: "durable", scope: "chat" },
687
- },
688
- model: "gea-model-1",
689
- name: "research-agent",
690
- slug: "research-agent",
691
- });
692
- ```
693
-
694
- New Agent code can choose its Computer provider directly:
695
-
696
- ```ts
697
- import {
698
- defaultComputer,
699
- localComputer,
700
- remoteComputer,
701
- secret,
702
- } from "@gea-ai/agent-sdk/computer";
703
- import { justbash } from "@gea-ai/agent-sdk/computer/just-bash";
704
- import { e2b } from "@gea-ai/computer-e2b";
705
-
706
- const computer = defaultComputer({
707
- filesystem: {
708
- scope: ({ principal }) => {
709
- if (!principal) throw new Error("A business principal is required");
710
- return `${principal.principalType}:${principal.principalId}`;
711
- },
712
- files: { "README.md": "Workspace initialized by this Agent." },
713
- },
714
- async onSession({ use, ctx }) {
715
- const session = await use();
716
- await session.writeTextFile({
717
- path: `${session.roots.tmp}/principal.json`,
718
- content: JSON.stringify(ctx.principal),
719
- });
720
- },
721
- });
722
-
723
- // Other choices for defineAgent({ computer: ... }):
724
- const virtual = justbash({ filesystem: { durability: "ephemeral" } });
725
- const external = e2b({
726
- apiKey: secret("E2B_API_KEY"),
727
- filesystem: { durability: "ephemeral" },
728
- });
729
- const remote = remoteComputer({
730
- url: "https://computer.example.com",
731
- token: secret("COMPUTER_TOKEN"),
732
- });
733
- const local = localComputer({
734
- mode: "sandbox",
735
- filesystem: { source: "local-project" },
736
- });
737
- ```
738
-
739
- Each factory returns one Computer with a matching filesystem. The code selects
740
- the provider and any remote endpoint. The existing COMPUTER Native binding connects
741
- directly to E2B or the developer service; just-bash is bundled into the Worker.
742
- Provider secret references are resolved only for Native Runtime. Do not separately declare those keys in the Agent's
743
- `environment` unless the Agent itself intentionally needs them.
744
-
745
- Computer file I/O follows Eve / AI SDK: `readFile/writeFile` stream bytes,
746
- `readBinaryFile/writeBinaryFile` handle Uint8Array, and text variants decode or
747
- encode strings. Options contain `abortSignal`. Reads return `null` for absent
748
- files; permission/I/O failures reject. Buffered reads are limited to 16 MiB;
749
- use streams for larger files. `stat`, `mkdir`, `rename`, `remove`, and `listFiles`
750
- operate on that same filesystem. Relative paths use `computer.roots.workspace`.
751
- Remote services use the Remote Computer HTTP v1 protocol for files and sessions.
752
-
753
- `computer.commands.run()` accepts a shell `command`, literal `args`, `env`,
754
- `cwd`, `timeoutMs` and initial text `stdin`. Simple foreground calls return
755
- `{ stdout, stderr, exitCode }`. Providers advertising `processes` also support
756
- background handles, incremental output and interactive stdin:
757
-
758
- ```ts
759
- const process = await computer.commands.run({
760
- command: "python",
761
- args: ["-u", "script.py"],
762
- env: { MODE: "test" },
763
- timeoutMs: 30_000,
764
- stdin: true,
765
- background: true,
766
- });
767
- const finished = process.wait({ onStdout: (text) => console.log(text) });
768
- await process.sendStdin("input\n", { end: true });
769
- const result = await finished;
770
- // To interrupt a running command: await process.kill().
771
- ```
772
-
773
- `wait()` starts output consumption and closes the handle when finished; repeated
774
- calls share its result and its first callbacks. Use `background: true` to supply
775
- interactive stdin, and `end: true` to close it. The command/owner signal or timeout
776
- also interrupts the process. Commands are limited to 120 seconds and collected
777
- output to 2 MiB (a provider may impose lower limits); stdin writes are at most
778
- 64 KiB. Callbacks receive decoded stdout/stderr chunks, not a terminal/PTY.
779
- E2B and local allow eight retained handles; wait for finished handles to release
780
- capacity. Hosted default uses the existing daemon's configured process limits.
781
-
782
- Hosted default, E2B and authorized local execution implement `processes`.
783
- just-bash and default dev support foreground options only and explicitly reject
784
- background/interactive/streaming requests. A remote service must implement the
785
- optional process-control protocol before advertising the `processes` capability.
786
- Every process belongs to the current invocation: Worker stop terminates unfinished
787
- processes before releasing the session or settling its filesystem. Background
788
- processes cannot outlive a completed Agent run. Normal foreground completion also
789
- cleans up redirected descendants. Local foreground/background commands share UTF-8
790
- decoding and process cleanup; the foreground API still uses one request.
791
- Execution user, PTY, listening
792
- ports, pause/resume and snapshots are not added by this API.
793
-
794
- `defaultComputer()` retains durable/chat defaults and supports a synchronous
795
- scope callback with `chatId`, `principal`, and `metadata`. Business code supplies
796
- `principal`; Computer never reads a GEA `userId`. `files` is a map of normalized
797
- relative workspace paths to strings or `Uint8Array` (2 MiB per file, 4 MiB total,
798
- 1000 files). It seeds only a new allocation. Upgrades, reconnections and deleted
799
- seed files do not reseed an existing durable workspace; legacy allocations are
800
- preserved. Ephemeral providers seed each new physical session.
801
-
802
- `onSession({ use, ctx })` runs after seeds and bundled Skills are ready, before
803
- model Tools. `use()` supplies that same session. It runs once per physical
804
- session, including replacement after confirmed expiry, and is skipped for live
805
- reconnects. Make the callback idempotent and check nonzero command exit codes;
806
- failed initialization prevents Tool execution. No unknown command is replayed.
807
-
808
- Computer lifecycle uses `create()` / `stop()`. The Worker owns it: create and
809
- initialize before tools, then stop after the model, tools, context writes and
810
- response stream have settled. Initialization/setup failures and cancellation also
811
- release the session, with a separate cleanup signal. Stop preserves durable files
812
- and the local project; ephemeral files disappear. Repeated stop is safe and must
813
- not create a new runtime or affect a newer generation. Services need their own
814
- expiry policy for Worker crashes or unreachable networks. The updated SDK requires
815
- a lifecycle-capable Worker Runtime; Native retains open/close aliases for older
816
- immutable Agent bundles. Lifecycle methods are not exposed as model Tools.
817
-
818
- `justbash()` provides virtual shell commands in Worker memory, with a 32 MiB public-write
819
- limit. It and E2B currently create ephemeral sessions per invocation; use Artifacts
820
- for retained files. No independent GEA Computer Host or additional Pod is required.
821
- Developer-owned services implement the Remote Computer HTTP v1 protocol
822
- and connect through `remoteComputer`. Developers choose their image, installed
823
- CLI tools, environment, and filesystem persistence. The URL's `filesystemId`
824
- identifies authorized storage; sessionId/invocationId/generation identify execution
825
- state. There is no Computer SDK, prescribed service framework, or base image in
826
- this release. Declared capabilities are checked against the actual session.
827
-
828
- `localComputer` requires local execution and matching explicit CLI authorization:
829
- `gea agent dev --json '{"localComputer":"sandbox","sandboxdPath":"/absolute/path/to/sandboxd"}'`.
830
- It uses the existing project, accepts no seed files, and never deletes the project
831
- on stop. Tools use returned roots and preserve literal shell commands.
832
- Trusted mode runs as the OS user and cannot enforce read-only Skills. macOS
833
- sandbox mode has native tests; Linux requires host-supplied bwrap configuration,
834
- and Windows local mode is currently unsupported. GUI operations are not exposed.
835
- Hosted Agents reject local mode. The factories do not add model-visible Tools;
836
- select them using the Tool files below.
837
-
838
- This provides the isolated Computer and makes `context.computer` available to
839
- custom Tools. `scope` declares whether the durable filesystem belongs to one
840
- chat, the current user, or a custom partition; it does not select a physical storage provider.
841
- It does not expose any built-in Computer Tool to the model.
842
-
843
- Runtime sessions and their read-only Skill mounts can be reclaimed while the
844
- durable filesystem remains. With the matching updated Worker Runtime, the SDK
845
- reconstructs the bundled Skill mount and retries a confirmed pre-execution
846
- `MOUNT_MISMATCH` once. It does not automatically replay commands after network
847
- or persistence failures. Publishing the SDK update requires updating hosted
848
- Worker Runtime first; existing immutable Agent bundles retain their old behavior.
849
-
850
- Then explicitly select the model-visible Computer Tools through the same Tool
851
- file convention. Each SDK factory fixes the Tool ID, input schema, and runtime
852
- implementation; the caller may override only its description:
853
-
854
- ```ts
855
- // tools/computer.ts
856
- import {
857
- applyPatch,
858
- bash,
859
- defineToolSet,
860
- editFile,
861
- findFiles,
862
- listDirectory,
863
- readFile,
864
- searchText,
865
- writeFile,
866
- } from "@gea-ai/agent-sdk";
867
-
868
- export default defineToolSet([
869
- readFile(),
870
- listDirectory(),
871
- findFiles(),
872
- searchText(),
873
- writeFile({
874
- description:
875
- "Write new or small complete files. Build long reports in bounded editFile steps.",
876
- }),
877
- editFile(),
878
- applyPatch(),
879
- bash(),
880
- ]);
881
- ```
882
-
883
- This array is the complete model-visible Computer Tool set and order. Only
884
- listed Computer Tools are visible: enabling Computer alone does not add
885
- `bash`, `readFile`, `writeFile`, or any other built-in Tool. Declaring no
886
- Computer Tools leaves the model with none, while custom Tools may still use
887
- `context.computer`.
888
-
889
- | Factory | Fixed Tool ID | Purpose |
890
- | ----------------- | --------------- | ------------------------------------------------------------- |
891
- | `readFile()` | `readFile` | Read bounded text from files, the Agent package, or artifacts |
892
- | `listDirectory()` | `listDirectory` | List one bounded directory |
893
- | `findFiles()` | `findFiles` | Find files with a glob |
894
- | `searchText()` | `searchText` | Search text across files |
895
- | `writeFile()` | `writeFile` | Create a file or completely write a small file |
896
- | `editFile()` | `editFile` | Prefer for exact, unique replacements in an existing file |
897
- | `applyPatch()` | `applyPatch` | Apply a Codex patch to create, update, move, or delete files |
898
- | `bash()` | `bash` | Run a Bash command from `/workspace` |
899
-
900
- The CLI discovers `tools/**/*.ts` deterministically and preserves Tool Set
901
- array order. The default `writeFile()` description tells the model to create a
902
- small skeleton for a long report and fill it with bounded `editFile()` calls
903
- instead of sending one large full-report Tool input.
904
-
905
- Prefer `editFile()` for ordinary edits to an existing file. Read the file
906
- first and provide exact, unique `oldText`/`newText` replacements; replacements
907
- are applied in order, so later edits see earlier edits in the same call.
908
-
909
- `applyPatch()` accepts **only Codex patch syntax**. It supports Add File,
910
- Delete File, Update File with optional Move to, multiple chunks, `@@` context
911
- anchors, and `*** End of File`. It uses a pinned upstream TypeScript port;
912
- see `THIRD_PARTY_NOTICES.md` included in this package. Update matching follows
913
- Codex's context and whitespace rules. Prefer enough surrounding context or a
914
- named `@@` anchor when the same text appears more than once.
915
-
916
- ```text
917
- *** Begin Patch
918
- *** Update File: notes.md
919
- @@ ## Next steps
920
- -status: pending
921
- +status: done
922
- *** Add File: notes/summary.md
923
- +Work completed.
924
- *** End Patch
925
- ```
926
-
927
- Paths are literal workspace-relative paths or absolute paths under
928
- `/workspace`; `a/` and `b/` are actual directory names. Unified diffs and
929
- Environment ID routing are not supported by this Computer Tool. All paths
930
- are validated before mutation, and file operations run in order, stopping at
931
- the first failure. A multi-file patch is not a transaction: `changedPaths`
932
- reports completed writes/deletes even on failure, `results` lists completed
933
- operations (a move uses its destination path), and `conflicts` contains the
934
- failure message. Inspect these outputs and reread changed files before retrying.
935
-
936
- This replaces the previous unified-diff input contract. Existing immutable
937
- Agent bundles retain their embedded SDK; rebuild and publish each Agent with
938
- the updated SDK to adopt the new behavior. Update custom tool descriptions
939
- and any callers that still generate unified diffs at the same time.
940
-
941
- The package tree above is the minimal starting point. Add Connector-dependent
942
- custom Tools and referenced Skills only when the Agent needs those capabilities.
943
-
944
- `gea agent dev` also generates `.gea/bindings.d.ts`. A custom Tool receives
945
- configured environment values, capability-bound stable identity, and declared
946
- Durable Object namespaces without receiving model, Connector, Computer, or
947
- Durable Object service credentials. A configured `tsconfig.json` should include
948
- `.gea/bindings.d.ts`; inferred TypeScript projects discover it automatically.
949
-
950
- ```ts
951
- const counter = context.durableObjects.COUNTER.getByName(
952
- context.identity.chat.id,
953
- );
954
- const response = await counter.fetch("https://counter.internal/increment", {
955
- method: "POST",
956
- });
957
- ```
958
-
959
- ## Call a Studio Agent with AI SDK
960
-
961
- Use `StudioAgentChatTransport` from `@gea-ai/agent-sdk/studio-client` with
962
- `useChat` from `@ai-sdk/react` in the browser, and `StudioAgentClient` from
963
- `@gea-ai/agent-sdk/studio-server` on your backend. The browser authenticates to
964
- your application; only your backend sends the Project key to GEA. The transport
965
- reads response identity headers and reuses the server Chat on later turns.
966
-
967
- ```tsx
968
- import { useChat } from "@ai-sdk/react";
969
- import { StudioAgentChatTransport } from "@gea-ai/agent-sdk/studio-client";
970
- import { useState } from "react";
971
-
972
- // Inside your component:
973
- const [transport] = useState(
974
- () =>
975
- new StudioAgentChatTransport({
976
- api: "/api/agent", // Your authenticated application path, without /run.
977
- headers: { "x-csrf-token": csrfToken }, // From your application session.
978
- onRun: ({ chatId, runId, requestId }) => {
979
- console.log({ chatId, runId, requestId });
980
- },
981
- }),
982
- );
983
- const { messages, sendMessage, resumeStream } = useChat({ transport });
984
- ```
985
-
986
- The transport sends your application's session cookies by default. It accepts
987
- only same-origin paths and sends no business metadata. Set `headers` to your
988
- application's CSRF token or user access token as appropriate.
989
-
990
- Create a key in **Project → API Key** and copy the matching URL from the
991
- Agent detail overview. Production uses `worker--<workerId>.<apex>`; preview
992
- uses `preview--worker--<workerId>.<apex>`. Both use `/gea/agents/<agentKey>/run`.
993
- Remove the trailing `/run` for the SDK `api` option, which appends operation
994
- paths itself. The key must match the URL environment.
995
-
996
- On the backend, configure the GEA destination and key from server environment:
997
-
998
- ```ts
999
- import { StudioAgentClient } from "@gea-ai/agent-sdk/studio-server";
1000
- import { env } from "./env";
1001
-
1002
- const agent = new StudioAgentClient({
1003
- api: env.GEA_AGENT_API_URL, // Agent base URL without /run.
1004
- apiKey: env.GEA_PROJECT_API_KEY,
1005
- });
1006
- // In an application route, after authentication and Chat ownership checks:
1007
- const response = await agent.run(
1008
- { chatId, message },
1009
- { signal: request.signal },
1010
- );
1011
- ```
1012
-
1013
- The backend provides new-Chat metadata from trusted application state. Do not
1014
- forward browser Cookie/Authorization headers to GEA or expose an anonymous
1015
- proxy. The server client constructs its own headers, refuses redirects, and
1016
- filters response headers while preserving the stream. Its browser export is
1017
- blocked. See the [application integration guide](https://musegea.com/developers/agent-studio-quick-start#api-invocation)
1018
- for session/CSRF integration, Chat ownership checks and reconnecting. These
1019
- entrypoints are available in `0.1.260906-alpha.0` and later.
1020
-
1021
- Applications select the user through the backend Run request's `principal`.
1022
- Computer scope callbacks receive it directly as `principal`; existing Tool and
1023
- hook contexts expose the same value through `auth.current`. GEA resource identity
1024
- is separate and must not be used to infer the application principal. The SDK
1025
- neither fabricates a GEA user nor requires principal IDs to equal GEA user IDs.
1026
-
1027
- ## Lazy Computer allocation and scope resolvers
1028
-
1029
- SDK-first Web execution passes trusted identity and caller metadata to the Worker;
1030
- it no longer allocates a filesystem before dispatch. An Agent may declare `chat`,
1031
- `user`, or a synchronous function for `computer.filesystem.scope`. The function
1032
- receives `{ chatId, principal, metadata }` and returns a non-empty string of at most
1033
- 256 characters without control characters. The Worker bundle contains the function;
1034
- the immutable snapshot records only `scope: "custom"`.
1035
-
1036
- AgentSession pins the first resolved scope. For custom resolvers, later metadata
1037
- or principal changes never recompute the key; applications must authorize Chat
1038
- access accordingly. Built-in `"user"` scope instead selects the current Run's
1039
- user partition on each allocation and rechecks that a user principal is present. The function receives business metadata
1040
- from Chat creation / first-run input; the application backend must authenticate its
1041
- users and authorize that data. Metadata never grants GEA user permissions.
1042
-
1043
- The native Computer binding requests an allocation from the existing ORPC registry
1044
- on first use. Trusted Run/version context determines ownership. Custom partitions
1045
- include Workspace, Project, Agent and environment; changing API keys preserves
1046
- storage. Runtime coalesces concurrent first operations using an invocation-owned
1047
- cache and keeps allocation IDs, provider details and credentials out of JavaScript.
1048
- Cancellation during allocation prevents Computer dispatch. No Computer use means
1049
- no allocation. Computer opening and Skill mount initialization also remain lazy.
1050
-
1051
- New SDK-first Computer filesystems use shared POSIX for every scope. Locally this
1052
- is the configured filesystem directory; production mounts the common filesystem
1053
- at `AGENT_FILESYSTEM_ROOT` on the Computer hosts. SDK, API and Studio expose scope,
1054
- not provider selection. The Legacy deployment mode does not enable new DO filesystems
1055
- for Studio. Existing allocation identities/providers remain readable without migration.
1056
- User scope requires `principalType: "user"` and uses the current Run's
1057
- `principalId`, including opaque external application identifiers. Studio user
1058
- partitions include Workspace, Project, Agent and environment. Attributes do not
1059
- change that identity. Hosted omission selects the Project service principal and
1060
- cannot reuse a previous Run's user files. The caller supplies `principal`; the
1061
- platform business adapter converts GEA session users before SDK execution.
1062
- Computer does not infer identity from `userId` or `identity.user`.
1063
-
1064
- The local CLI forwards the same selected principal to its allocation callback.
1065
- User files are partitioned by local project, Agent and principal ID; omission
1066
- selects `local-user` and preserves its existing directory. Existing non-Studio
1067
- GEA-user allocation IDs and Chat/custom allocation IDs are retained. Its just-bash
1068
- bridge is a development runtime.
1069
-
1070
- Rollout requires matching Web/ORPC and Worker Runtime, plus Agents rebuilt and
1071
- published with this SDK. No database migration or virtual user is introduced.
1072
-
1073
- ```ts
1074
- computer: {
1075
- enabled: true,
1076
- filesystem: {
1077
- durability: "durable",
1078
- scope: ({ metadata }) => {
1079
- if (typeof metadata.customerId !== "string" || !metadata.customerId)
1080
- throw new Error("customerId is required");
1081
- return `customer:${metadata.customerId}`;
1082
- },
1083
- },
1084
- }
1085
- ```
1086
-
1087
- ## Project Artifacts
1088
-
1089
- Declare `artifacts: {}` to enable `ctx.artifacts` in custom Tools. The default scope
1090
- is the runtime principal; Project and environment are always fixed by the host.
1091
- Enable `artifacts: { tools: true }` for three standard model tools:
1092
-
1093
- | Tool | Behavior |
1094
- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
1095
- | `listArtifacts({ query?, prefix?, cursor?, limit? })` | Case-insensitive filename substring search and scoped pagination. |
1096
- | `getArtifact({ key })` | Metadata and a temporary download URL, bounded text/JSON preview, and current-turn image reads. |
1097
- | `createUpload({ filename, contentType?, key? })` | A temporary HTTP upload target; optional key selects an output to replace. |
1098
-
1099
- A target includes `key`, `uploadUrl`, `method`, `headers`, `expiresAt`, and `maxBytes`.
1100
- Use every returned header and upload original bytes with an ordinary HTTP client.
1101
- For example, in a Computer with curl and network access:
1102
-
1103
- ```bash
1104
- curl --fail-with-body --silent --show-error -X PUT \
1105
- -H 'Authorization: Bearer <returned authorization>' \
1106
- -H 'Content-Type: application/pdf' \
1107
- --upload-file /workspace/report.pdf '<uploadUrl>'
1108
- ```
1109
-
1110
- The server verifies and publishes in that request; HTTP success returns the
1111
- Artifact. No completion tool is needed. To download, use the `downloadUrl` from
1112
- `getArtifact`, or share that URL directly with the user. If optional text/image
1113
- preview fails, `getArtifact` still returns metadata and the download URL together
1114
- with `previewError`; lookup/authorization failures remain Tool errors. No Computer is allocated
1115
- for Artifact metadata, image reads, or upload authorization. A network-disabled
1116
- Computer cannot use these HTTP URLs; the tools do not bypass its network policy.
1117
-
1118
- Custom Tools use `ctx.artifacts.createUpload`, `get`, `readText`, `list`, `delete`,
1119
- and bounded text `put`. For example:
1120
-
1121
- ```ts
1122
- const target = await ctx.artifacts.createUpload({
1123
- filename: "report.pdf",
1124
- contentType: "application/pdf",
1125
- });
1126
- const files = await ctx.artifacts.list({ query: "report.pdf", limit: 20 });
1127
- ```
1128
-
1129
- `put({key, content, contentType?, title?, filename?, metadata?})` stores UTF-8 text
1130
- up to 2 MiB. `readText(key)` accepts text/JSON up to 2 MiB. `getArtifact` limits its
1131
- model text preview to 8,000 characters and keeps image bytes transient. The SDK's
1132
- old Computer path-copy methods and dedicated transfer protocol have been removed.
1133
-
1134
- A developer can share a scope with trusted code:
1135
-
1136
- ```ts
1137
- artifacts: {
1138
- tools: true,
1139
- scope: ({ metadata }) => typeof metadata.customerId === "string" ? `customer:${metadata.customerId}` : null,
1140
- },
1141
- ```
1142
-
1143
- Authorize customer membership in the application before using business metadata
1144
- as a scope. Null/empty results fail closed. Matching scopes share across Agents
1145
- and Chats. An omitted upload key is `files/<uuid>/<filename>`. Explicit repeated
1146
- keys replace content while preserving Artifact ID and original creation provenance;
1147
- last committed write wins. The reserved `uploads/` namespace is immutable message
1148
- input and cannot be overwritten by Agent uploads. `createUpload` authority lasts
1149
- one hour and can be reused for its same key until expiration. After an uncertain
1150
- HTTP response, inspect the key; failure to receive a reply does not imply rollback.
1151
-
1152
- Downloads use attachment disposition, including HTML/SVG. Temporary links are
1153
- bearer access; get a fresh link from the persistent Artifact key when needed.
1154
- Hosted uploads use bounded disk staging and streaming object-store writes, with a
1155
- 1 GiB default limit (configurable up to 10 GiB); local dev supports 1 GiB and stores
1156
- files under `.gea/artifacts`. Ingress and client limits still apply. The saved copy
1157
- is independent of later Computer edits.
1158
-
1159
- For Agent authoring and local development, see the public
1160
- [Agent development guide](https://musegea.com/developers/agent-development).
9
+ [Developer documentation](https://musegea.com/developers/agent-development)