@electric-ax/agents 0.2.3 → 0.2.4
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/dist/entrypoint.js +40 -12
- package/dist/index.cjs +40 -12
- package/dist/index.js +40 -12
- package/docs/entities/agents/coder.md +99 -0
- package/docs/entities/agents/horton.md +16 -13
- package/docs/entities/agents/worker.md +18 -18
- package/docs/entities/patterns/blackboard.md +6 -6
- package/docs/entities/patterns/dispatcher.md +1 -1
- package/docs/entities/patterns/manager-worker.md +1 -1
- package/docs/entities/patterns/map-reduce.md +1 -1
- package/docs/entities/patterns/pipeline.md +1 -1
- package/docs/entities/patterns/reactive-observers.md +2 -2
- package/docs/examples/playground.md +42 -26
- package/docs/index.md +23 -23
- package/docs/quickstart.md +13 -13
- package/docs/reference/agent-config.md +20 -12
- package/docs/reference/agent-tool.md +1 -1
- package/docs/reference/built-in-collections.md +21 -21
- package/docs/reference/cli.md +39 -30
- package/docs/reference/entity-definition.md +9 -9
- package/docs/reference/entity-handle.md +2 -2
- package/docs/reference/entity-registry.md +1 -1
- package/docs/reference/handler-context.md +69 -18
- package/docs/reference/runtime-handler.md +25 -23
- package/docs/reference/shared-state-handle.md +7 -7
- package/docs/reference/state-collection-proxy.md +1 -1
- package/docs/reference/wake-event.md +23 -23
- package/docs/usage/app-setup.md +24 -23
- package/docs/usage/clients-and-react.md +44 -36
- package/docs/usage/configuring-the-agent.md +25 -19
- package/docs/usage/context-composition.md +12 -12
- package/docs/usage/defining-entities.md +36 -36
- package/docs/usage/defining-tools.md +45 -45
- package/docs/usage/embedded-builtins.md +48 -47
- package/docs/usage/managing-state.md +12 -12
- package/docs/usage/overview.md +52 -45
- package/docs/usage/programmatic-runtime-client.md +50 -47
- package/docs/usage/shared-state.md +32 -32
- package/docs/usage/spawning-and-coordinating.md +9 -9
- package/docs/usage/testing.md +14 -14
- package/docs/usage/waking-entities.md +13 -13
- package/docs/usage/writing-handlers.md +57 -26
- package/package.json +4 -1
- package/scripts/sync-docs.mjs +42 -0
- package/docs/examples/mega-draw.md +0 -106
|
@@ -1,46 +1,62 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
titleTemplate:
|
|
2
|
+
title: Playground
|
|
3
|
+
titleTemplate: "... - Electric Agents"
|
|
4
4
|
description: >-
|
|
5
|
-
|
|
5
|
+
Technical examples for experimenting with Electric Agents coordination patterns.
|
|
6
6
|
outline: [2, 3]
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
#
|
|
9
|
+
# Playground
|
|
10
10
|
|
|
11
|
-
Electric Agents
|
|
11
|
+
The [Electric Agents Playground](https://github.com/electric-sql/electric/tree/main/examples/agents-playground) is a collection of technical examples for trying coordination patterns against a local Electric Agents server.
|
|
12
12
|
|
|
13
13
|
## What it includes
|
|
14
14
|
|
|
15
|
-
The
|
|
15
|
+
The playground currently includes two entity patterns.
|
|
16
16
|
|
|
17
|
-
###
|
|
17
|
+
### Perspectives
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
Perspectives is a manager-worker example. A manager agent spawns an optimist and a critic to examine the same question from different viewpoints, then synthesizes their responses into a balanced analysis.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
It demonstrates:
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
23
|
+
- Spawning child agents from a custom tool.
|
|
24
|
+
- Waking the manager when child runs finish.
|
|
25
|
+
- Tracking child entity URLs in state.
|
|
26
|
+
- Synthesizing worker outputs into a final response.
|
|
27
27
|
|
|
28
|
-
###
|
|
28
|
+
### Researcher
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Researcher is a coordinator example. It decomposes complex research questions into specialist sub-questions, spawns workers for each slice, and synthesizes the findings into a comprehensive answer with citations.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
It demonstrates:
|
|
33
33
|
|
|
34
|
-
-
|
|
34
|
+
- Dynamic fan-out based on the shape of the user's question.
|
|
35
|
+
- Specialist worker agents focused on distinct research tasks.
|
|
36
|
+
- Wake-on-finish coordination between coordinator and workers.
|
|
37
|
+
- Final synthesis from multiple child reports.
|
|
35
38
|
|
|
36
|
-
##
|
|
39
|
+
## Run it
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
- [`manager-worker`](https://github.com/electric-sql/electric/blob/main/packages/agents-runtime/skills/designing-entities/references/patterns/manager-worker.md)
|
|
40
|
-
- [`dispatcher`](https://github.com/electric-sql/electric/blob/main/packages/agents-runtime/skills/designing-entities/references/patterns/dispatcher.md)
|
|
41
|
-
- [`pipeline`](https://github.com/electric-sql/electric/blob/main/packages/agents-runtime/skills/designing-entities/references/patterns/pipeline.md)
|
|
42
|
-
- [`map-reduce`](https://github.com/electric-sql/electric/blob/main/packages/agents-runtime/skills/designing-entities/references/patterns/map-reduce.md)
|
|
43
|
-
- [`blackboard`](https://github.com/electric-sql/electric/blob/main/packages/agents-runtime/skills/designing-entities/references/patterns/blackboard.md)
|
|
44
|
-
- [`reactive-observers`](https://github.com/electric-sql/electric/blob/main/packages/agents-runtime/skills/designing-entities/references/patterns/reactive-observers.md)
|
|
41
|
+
Start the local agents infrastructure from the monorepo root:
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
```bash
|
|
44
|
+
npx electric-ax agents start
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then configure and run the playground:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cd examples/agents-playground
|
|
51
|
+
cp .env.example .env
|
|
52
|
+
pnpm install
|
|
53
|
+
pnpm dev
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The app server starts on port `3000` and registers entity types with the agent server on port `4437`.
|
|
57
|
+
|
|
58
|
+
## Source
|
|
59
|
+
|
|
60
|
+
The source code is in [`examples/agents-playground`](https://github.com/electric-sql/electric/tree/main/examples/agents-playground).
|
|
61
|
+
|
|
62
|
+
See [spawning & coordinating](../usage/spawning-and-coordinating.md) for the underlying coordination concepts.
|
package/docs/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Electric Agents
|
|
3
|
-
titleTemplate:
|
|
3
|
+
titleTemplate: "... - Electric Agents"
|
|
4
4
|
description: >-
|
|
5
5
|
The durable runtime for long-lived agents — entities, handlers, wakes, agent loops, and coordination, built on Electric Streams, TanStack DB, and pi.
|
|
6
6
|
outline: [2, 3]
|
|
@@ -22,7 +22,7 @@ Every step — runs, tool calls, text deltas, state changes — is appended to t
|
|
|
22
22
|
|
|
23
23
|
<EntityOverviewDiagram />
|
|
24
24
|
|
|
25
|
-
Start with the [Quickstart](/docs/agents/quickstart) to run the built-in `horton`
|
|
25
|
+
Start with the [Quickstart](/docs/agents/quickstart) to run the built-in `horton`, `worker`, and `coder` entities and connect your own app in a few minutes. The [Usage overview](/docs/agents/usage/overview) summarises the full developer surface in a single page.
|
|
26
26
|
|
|
27
27
|
## How it works
|
|
28
28
|
|
|
@@ -45,8 +45,8 @@ Use entities to model anything long-lived and addressable — an agent session,
|
|
|
45
45
|
```ts
|
|
46
46
|
const registry = createEntityRegistry()
|
|
47
47
|
|
|
48
|
-
registry.define(
|
|
49
|
-
description:
|
|
48
|
+
registry.define("assistant", {
|
|
49
|
+
description: "A general-purpose AI assistant",
|
|
50
50
|
async handler(ctx) {
|
|
51
51
|
// ...
|
|
52
52
|
},
|
|
@@ -58,12 +58,12 @@ registry.define('assistant', {
|
|
|
58
58
|
The function that runs when an entity wakes. Receives a [`HandlerContext`](/docs/agents/reference/handler-context) (`ctx`) and a [`WakeEvent`](/docs/agents/reference/wake-event) (`wake`). The handler decides how to respond: configure an agent, update state, spawn children, or any combination. See [Writing handlers](/docs/agents/usage/writing-handlers).
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
registry.define(
|
|
61
|
+
registry.define("support", {
|
|
62
62
|
async handler(ctx, wake) {
|
|
63
|
-
if (wake.type ===
|
|
63
|
+
if (wake.type === "message_received") {
|
|
64
64
|
ctx.useAgent({
|
|
65
|
-
systemPrompt:
|
|
66
|
-
model:
|
|
65
|
+
systemPrompt: "You are a support agent.",
|
|
66
|
+
model: "claude-sonnet-4-5-20250929",
|
|
67
67
|
tools: [...ctx.electricTools, searchKbTool],
|
|
68
68
|
})
|
|
69
69
|
await ctx.agent.run()
|
|
@@ -94,7 +94,7 @@ async handler(ctx, wake) {
|
|
|
94
94
|
Custom persistent collections on the entity. Defined as part of the [entity definition](/docs/agents/reference/entity-definition) and accessed through `ctx.db` alongside the [built-in collections](#built-in-collections). State is local to the entity, typed, and survives restarts. Use it for things that belong to the entity but aren't part of the agent's event stream — an order's items, a research job's findings, a chat session's TODOs. See [Managing state](/docs/agents/usage/managing-state).
|
|
95
95
|
|
|
96
96
|
```ts
|
|
97
|
-
registry.define(
|
|
97
|
+
registry.define("tracker", {
|
|
98
98
|
state: {
|
|
99
99
|
items: {
|
|
100
100
|
schema: z.object({
|
|
@@ -102,16 +102,16 @@ registry.define('tracker', {
|
|
|
102
102
|
name: z.string(),
|
|
103
103
|
done: z.boolean(),
|
|
104
104
|
}),
|
|
105
|
-
primaryKey:
|
|
105
|
+
primaryKey: "key",
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
108
|
async handler(ctx) {
|
|
109
109
|
// read
|
|
110
|
-
const item = ctx.db.collections.items.get(
|
|
110
|
+
const item = ctx.db.collections.items.get("item-1")
|
|
111
111
|
|
|
112
112
|
// write
|
|
113
113
|
ctx.db.actions.items_insert({
|
|
114
|
-
row: { key:
|
|
114
|
+
row: { key: "item-2", name: "New", done: false },
|
|
115
115
|
})
|
|
116
116
|
},
|
|
117
117
|
})
|
|
@@ -123,8 +123,8 @@ The core pattern is [`ctx.useAgent()`](/docs/agents/reference/agent-config) foll
|
|
|
123
123
|
|
|
124
124
|
```ts
|
|
125
125
|
ctx.useAgent({
|
|
126
|
-
systemPrompt:
|
|
127
|
-
model:
|
|
126
|
+
systemPrompt: "You are a helpful assistant.",
|
|
127
|
+
model: "claude-sonnet-4-5-20250929",
|
|
128
128
|
tools: [...ctx.electricTools, myCustomTool],
|
|
129
129
|
})
|
|
130
130
|
|
|
@@ -137,17 +137,17 @@ Functions the LLM can call during the agent loop. Each tool has a name, descript
|
|
|
137
137
|
|
|
138
138
|
```ts
|
|
139
139
|
const searchKbTool: AgentTool = {
|
|
140
|
-
name:
|
|
141
|
-
label:
|
|
142
|
-
description:
|
|
140
|
+
name: "search_kb",
|
|
141
|
+
label: "Search knowledge base",
|
|
142
|
+
description: "Search the knowledge base",
|
|
143
143
|
parameters: Type.Object({
|
|
144
|
-
query: Type.String({ description:
|
|
144
|
+
query: Type.String({ description: "Search query" }),
|
|
145
145
|
}),
|
|
146
146
|
execute: async (_toolCallId, params) => {
|
|
147
147
|
const { query } = params as { query: string }
|
|
148
148
|
const results = await searchKnowledgeBase(query)
|
|
149
149
|
return {
|
|
150
|
-
content: [{ type:
|
|
150
|
+
content: [{ type: "text", text: JSON.stringify(results) }],
|
|
151
151
|
details: {},
|
|
152
152
|
}
|
|
153
153
|
},
|
|
@@ -191,18 +191,18 @@ const allRuns = ctx.db.collections.runs.toArray
|
|
|
191
191
|
const lastError = ctx.db.collections.errors.toArray.at(-1)
|
|
192
192
|
|
|
193
193
|
// from outside — load an entity's stream into a local DB
|
|
194
|
-
const client = createAgentsClient({ baseUrl:
|
|
195
|
-
const db = await client.observe(entity(
|
|
194
|
+
const client = createAgentsClient({ baseUrl: "http://localhost:4437" })
|
|
195
|
+
const db = await client.observe(entity("/support/ticket-42"))
|
|
196
196
|
console.log(db.collections.texts.toArray)
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
## Next steps
|
|
200
200
|
|
|
201
|
-
- [Quickstart](/docs/agents/quickstart) — run the built-in `horton`
|
|
201
|
+
- [Quickstart](/docs/agents/quickstart) — run the built-in `horton`, `worker`, and `coder` entities and connect your own app.
|
|
202
202
|
- [Usage overview](/docs/agents/usage/overview) — the full developer surface on one page.
|
|
203
203
|
- [Defining entities](/docs/agents/usage/defining-entities) — entity types, schemas, and configuration.
|
|
204
204
|
- [Writing handlers](/docs/agents/usage/writing-handlers) — handler lifecycle and the `ctx` API.
|
|
205
205
|
- [Configuring the agent](/docs/agents/usage/configuring-the-agent) — `useAgent`, models, tools, and streaming.
|
|
206
206
|
- [Spawning & coordinating](/docs/agents/usage/spawning-and-coordinating) — multi-entity topologies and shared state.
|
|
207
|
-
- [Built-in agents](/docs/agents/entities/agents/horton) — Horton and
|
|
207
|
+
- [Built-in agents](/docs/agents/entities/agents/horton) — Horton, Worker, and Coder, the agents that ship with the runtime.
|
|
208
208
|
- [Examples](/docs/agents/examples/playground) — pattern walkthroughs and demo apps.
|
package/docs/quickstart.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Quickstart
|
|
3
|
-
titleTemplate:
|
|
3
|
+
titleTemplate: "... - Electric Agents"
|
|
4
4
|
description: >-
|
|
5
5
|
Run the Electric Agents runtime and the built-in Horton assistant with a single CLI command, then connect from the web UI or define your own entities.
|
|
6
6
|
outline: [2, 3]
|
|
@@ -19,7 +19,7 @@ npx electric-ax agents quickstart
|
|
|
19
19
|
- **Node.js 18+**.
|
|
20
20
|
- **[Docker](https://docs.docker.com/get-docker/)**. The runtime server, Postgres, and Electric run as containers.
|
|
21
21
|
- **An [Anthropic API key](https://console.anthropic.com/settings/keys)**. Used by the built-in Horton agent.
|
|
22
|
-
-
|
|
22
|
+
- *(Optional)* A **[Brave Search API key](https://brave.com/search/api/)** if you want Horton to be able to search the web.
|
|
23
23
|
|
|
24
24
|
## Set your API key
|
|
25
25
|
|
|
@@ -49,7 +49,7 @@ npx electric-ax agents quickstart
|
|
|
49
49
|
This:
|
|
50
50
|
|
|
51
51
|
1. Starts Postgres, Electric, and the Electric Agents runtime server in Docker (the runtime serves both the API and the web UI on `http://localhost:4437`).
|
|
52
|
-
2. Starts a built-in **Horton** runtime in the foreground that registers the `horton` and `
|
|
52
|
+
2. Starts a built-in **Horton** runtime in the foreground that registers the `horton`, `worker`, and `coder` entity types.
|
|
53
53
|
3. Prints onboarding commands you can copy into a second terminal.
|
|
54
54
|
|
|
55
55
|
Leave this terminal running. Press `Ctrl-C` to stop the built-in Horton runtime — the runtime server containers keep running in the background until you call [`electric agents stop`](#stop-the-dev-environment).
|
|
@@ -94,25 +94,25 @@ npm install --save-dev tsx
|
|
|
94
94
|
Create `server.ts`:
|
|
95
95
|
|
|
96
96
|
```ts
|
|
97
|
-
import http from
|
|
97
|
+
import http from "node:http"
|
|
98
98
|
import {
|
|
99
99
|
createEntityRegistry,
|
|
100
100
|
createRuntimeHandler,
|
|
101
|
-
} from
|
|
101
|
+
} from "@electric-ax/agents-runtime"
|
|
102
102
|
|
|
103
103
|
const ELECTRIC_AGENTS_URL =
|
|
104
|
-
process.env.ELECTRIC_AGENTS_URL ??
|
|
104
|
+
process.env.ELECTRIC_AGENTS_URL ?? "http://localhost:4437"
|
|
105
105
|
const PORT = Number(process.env.PORT ?? 3000)
|
|
106
106
|
const SERVE_URL = process.env.SERVE_URL ?? `http://localhost:${PORT}`
|
|
107
107
|
|
|
108
108
|
const registry = createEntityRegistry()
|
|
109
109
|
|
|
110
|
-
registry.define(
|
|
111
|
-
description:
|
|
110
|
+
registry.define("assistant", {
|
|
111
|
+
description: "A general-purpose AI assistant",
|
|
112
112
|
async handler(ctx) {
|
|
113
113
|
ctx.useAgent({
|
|
114
|
-
systemPrompt:
|
|
115
|
-
model:
|
|
114
|
+
systemPrompt: "You are a helpful assistant.",
|
|
115
|
+
model: "claude-sonnet-4-5-20250929",
|
|
116
116
|
tools: [...ctx.electricTools],
|
|
117
117
|
})
|
|
118
118
|
await ctx.agent.run()
|
|
@@ -126,7 +126,7 @@ const runtime = createRuntimeHandler({
|
|
|
126
126
|
})
|
|
127
127
|
|
|
128
128
|
const server = http.createServer(async (req, res) => {
|
|
129
|
-
if (req.url ===
|
|
129
|
+
if (req.url === "/webhook" && req.method === "POST") {
|
|
130
130
|
await runtime.onEnter(req, res)
|
|
131
131
|
return
|
|
132
132
|
}
|
|
@@ -186,7 +186,7 @@ npx electric-ax agents stop --remove-volumes # stop containers and wipe data
|
|
|
186
186
|
|
|
187
187
|
```sh
|
|
188
188
|
npx electric-ax agents start # runtime server + UI (background, Docker)
|
|
189
|
-
npx electric-ax agents start-builtin # built-in Horton
|
|
189
|
+
npx electric-ax agents start-builtin # built-in Horton, worker, and coder (foreground)
|
|
190
190
|
```
|
|
191
191
|
|
|
192
192
|
See the [CLI reference](./reference/cli#start) for the full set of commands.
|
|
@@ -198,4 +198,4 @@ See the [CLI reference](./reference/cli#start) for the full set of commands.
|
|
|
198
198
|
- [Defining entities](./usage/defining-entities) — entity types, schemas, and configuration.
|
|
199
199
|
- [Writing handlers](./usage/writing-handlers) — handler lifecycle and the `ctx` API.
|
|
200
200
|
- [Configuring the agent](./usage/configuring-the-agent) — `useAgent`, models, tools, and streaming.
|
|
201
|
-
- [Built-in agents](./entities/agents/horton) — Horton and
|
|
201
|
+
- [Built-in agents](./entities/agents/horton) — Horton, Worker, and Coder, the agents that ship with the runtime.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: AgentConfig
|
|
3
|
-
titleTemplate:
|
|
3
|
+
titleTemplate: "... - Electric Agents"
|
|
4
4
|
description: >-
|
|
5
5
|
API reference for AgentConfig: system prompt, model, tools, streaming, and test responses.
|
|
6
6
|
outline: [2, 3]
|
|
@@ -19,20 +19,26 @@ interface AgentConfig {
|
|
|
19
19
|
provider?: KnownProvider
|
|
20
20
|
tools: AgentTool[]
|
|
21
21
|
streamFn?: StreamFn
|
|
22
|
+
getApiKey?: (
|
|
23
|
+
provider: string
|
|
24
|
+
) => Promise<string | undefined> | string | undefined
|
|
25
|
+
onPayload?: SimpleStreamOptions["onPayload"]
|
|
22
26
|
testResponses?: string[] | TestResponseFn
|
|
23
27
|
}
|
|
24
28
|
```
|
|
25
29
|
|
|
26
30
|
## Fields
|
|
27
31
|
|
|
28
|
-
| Field | Type | Required | Description
|
|
29
|
-
| --------------- | ---------------------------- | -------- |
|
|
30
|
-
| `systemPrompt` | `string` | Yes | System prompt sent to the LLM on each step.
|
|
31
|
-
| `model` | `string \| Model<any>` | Yes | Model identifier (e.g. `"claude-sonnet-4-5-20250929"`) or a resolved model object.
|
|
32
|
-
| `provider` | `KnownProvider` | No | Provider to use when `model` is a string. Defaults to `"anthropic"`.
|
|
32
|
+
| Field | Type | Required | Description |
|
|
33
|
+
| --------------- | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| `systemPrompt` | `string` | Yes | System prompt sent to the LLM on each step. |
|
|
35
|
+
| `model` | `string \| Model<any>` | Yes | Model identifier (e.g. `"claude-sonnet-4-5-20250929"`) or a resolved model object. |
|
|
36
|
+
| `provider` | `KnownProvider` | No | Provider to use when `model` is a string. Defaults to `"anthropic"`. |
|
|
33
37
|
| `tools` | `AgentTool[]` | Yes | Tools available to the LLM. Spread `ctx.electricTools` when your runtime host provides runtime-level tools. See [`AgentTool`](./agent-tool). |
|
|
34
|
-
| `streamFn` | `StreamFn` | No | Optional streaming callback passed to the underlying agent.
|
|
35
|
-
| `
|
|
38
|
+
| `streamFn` | `StreamFn` | No | Optional streaming callback passed to the underlying agent. |
|
|
39
|
+
| `getApiKey` | `(provider) => string \| Promise<string> \| undefined` | No | Optional API-key resolver passed through to the model layer. |
|
|
40
|
+
| `onPayload` | `SimpleStreamOptions["onPayload"]` | No | Optional callback for raw streaming payloads from the model layer. |
|
|
41
|
+
| `testResponses` | `string[] \| TestResponseFn` | No | Mock LLM responses for testing. When set, no real LLM calls are made. |
|
|
36
42
|
|
|
37
43
|
## TestResponseFn
|
|
38
44
|
|
|
@@ -69,14 +75,16 @@ interface AgentHandle {
|
|
|
69
75
|
|
|
70
76
|
```ts
|
|
71
77
|
interface AgentRunResult {
|
|
78
|
+
result?: unknown
|
|
72
79
|
writes: ChangeEvent[]
|
|
73
80
|
toolCalls: Array<{ name: string; args: unknown; result: unknown }>
|
|
74
81
|
usage: { tokens: number; duration: number }
|
|
75
82
|
}
|
|
76
83
|
```
|
|
77
84
|
|
|
78
|
-
| Field | Type | Description
|
|
79
|
-
| ----------- | -------------------------------------- |
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
85
|
+
| Field | Type | Description |
|
|
86
|
+
| ----------- | -------------------------------------- | --------------------------------------------------------------------------- |
|
|
87
|
+
| `result` | `unknown` | Optional final result from the underlying agent adapter. |
|
|
88
|
+
| `writes` | `ChangeEvent[]` | Currently returned as an empty array placeholder. |
|
|
89
|
+
| `toolCalls` | `Array<{ name, args, result }>` | Currently returned as an empty array placeholder. |
|
|
82
90
|
| `usage` | `{ tokens: number; duration: number }` | Currently returned as `{ tokens: 0, duration: 0 }` until usage aggregation is wired in. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Built-in collections
|
|
3
|
-
titleTemplate:
|
|
3
|
+
titleTemplate: "... - Electric Agents"
|
|
4
4
|
description: >-
|
|
5
5
|
Reference for the 17 runtime-managed collections: runs, steps, texts, toolCalls, inbox, errors, and more.
|
|
6
6
|
outline: [2, 3]
|
|
@@ -43,7 +43,7 @@ All collections use `key` as the primary key.
|
|
|
43
43
|
```ts
|
|
44
44
|
interface Run {
|
|
45
45
|
key: string
|
|
46
|
-
status:
|
|
46
|
+
status: "started" | "completed" | "failed"
|
|
47
47
|
finish_reason?: string
|
|
48
48
|
}
|
|
49
49
|
```
|
|
@@ -55,7 +55,7 @@ interface Step {
|
|
|
55
55
|
key: string
|
|
56
56
|
run_id?: string
|
|
57
57
|
step_number: number
|
|
58
|
-
status:
|
|
58
|
+
status: "started" | "completed"
|
|
59
59
|
finish_reason?: string
|
|
60
60
|
model_provider?: string
|
|
61
61
|
model_id?: string
|
|
@@ -69,7 +69,7 @@ interface Step {
|
|
|
69
69
|
interface Text {
|
|
70
70
|
key: string
|
|
71
71
|
run_id?: string
|
|
72
|
-
status:
|
|
72
|
+
status: "streaming" | "completed"
|
|
73
73
|
}
|
|
74
74
|
```
|
|
75
75
|
|
|
@@ -91,7 +91,7 @@ interface ToolCall {
|
|
|
91
91
|
key: string
|
|
92
92
|
run_id?: string
|
|
93
93
|
tool_name: string
|
|
94
|
-
status:
|
|
94
|
+
status: "started" | "args_complete" | "executing" | "completed" | "failed"
|
|
95
95
|
args?: unknown
|
|
96
96
|
result?: unknown
|
|
97
97
|
error?: string
|
|
@@ -104,7 +104,7 @@ interface ToolCall {
|
|
|
104
104
|
```ts
|
|
105
105
|
interface Reasoning {
|
|
106
106
|
key: string
|
|
107
|
-
status:
|
|
107
|
+
status: "streaming" | "completed"
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
@@ -148,14 +148,14 @@ interface WakeEntry {
|
|
|
148
148
|
|
|
149
149
|
interface WakeChangeEntry {
|
|
150
150
|
collection: string
|
|
151
|
-
kind:
|
|
151
|
+
kind: "insert" | "update" | "delete"
|
|
152
152
|
key: string
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
interface WakeFinishedChildEntry {
|
|
156
156
|
url: string
|
|
157
157
|
type: string
|
|
158
|
-
run_status:
|
|
158
|
+
run_status: "completed" | "failed"
|
|
159
159
|
response?: string // concatenated text deltas from the finished run
|
|
160
160
|
error?: string // error message(s) if run_status is "failed"
|
|
161
161
|
}
|
|
@@ -163,7 +163,7 @@ interface WakeFinishedChildEntry {
|
|
|
163
163
|
interface WakeOtherChildEntry {
|
|
164
164
|
url: string
|
|
165
165
|
type: string
|
|
166
|
-
status:
|
|
166
|
+
status: "spawning" | "running" | "idle" | "stopped"
|
|
167
167
|
}
|
|
168
168
|
```
|
|
169
169
|
|
|
@@ -196,7 +196,7 @@ interface ChildStatusEntry {
|
|
|
196
196
|
key: string
|
|
197
197
|
entity_url: string
|
|
198
198
|
entity_type: string
|
|
199
|
-
status:
|
|
199
|
+
status: "spawning" | "running" | "idle" | "stopped"
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
@@ -249,7 +249,7 @@ type Manifest =
|
|
|
249
249
|
|
|
250
250
|
interface ManifestChildEntry {
|
|
251
251
|
key: string
|
|
252
|
-
kind:
|
|
252
|
+
kind: "child"
|
|
253
253
|
id: string
|
|
254
254
|
entity_type: string
|
|
255
255
|
entity_url: string
|
|
@@ -259,7 +259,7 @@ interface ManifestChildEntry {
|
|
|
259
259
|
|
|
260
260
|
interface ManifestSourceEntry {
|
|
261
261
|
key: string
|
|
262
|
-
kind:
|
|
262
|
+
kind: "source"
|
|
263
263
|
sourceType: string
|
|
264
264
|
sourceRef: string
|
|
265
265
|
wake?: WakeConfig
|
|
@@ -268,16 +268,16 @@ interface ManifestSourceEntry {
|
|
|
268
268
|
|
|
269
269
|
interface ManifestSharedStateEntry {
|
|
270
270
|
key: string
|
|
271
|
-
kind:
|
|
271
|
+
kind: "shared-state"
|
|
272
272
|
id: string
|
|
273
|
-
mode:
|
|
273
|
+
mode: "create" | "connect"
|
|
274
274
|
collections: Record<string, { type: string; primaryKey: string }>
|
|
275
275
|
wake?: WakeConfig
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
interface ManifestEffectEntry {
|
|
279
279
|
key: string
|
|
280
|
-
kind:
|
|
280
|
+
kind: "effect"
|
|
281
281
|
id: string
|
|
282
282
|
function_ref: string
|
|
283
283
|
config: unknown
|
|
@@ -285,7 +285,7 @@ interface ManifestEffectEntry {
|
|
|
285
285
|
|
|
286
286
|
interface ManifestContextEntry {
|
|
287
287
|
key: string
|
|
288
|
-
kind:
|
|
288
|
+
kind: "context"
|
|
289
289
|
id: string
|
|
290
290
|
name: string
|
|
291
291
|
attrs: Record<string, string | number | boolean>
|
|
@@ -295,9 +295,9 @@ interface ManifestContextEntry {
|
|
|
295
295
|
|
|
296
296
|
interface ManifestCronScheduleEntry {
|
|
297
297
|
key: string
|
|
298
|
-
kind:
|
|
298
|
+
kind: "schedule"
|
|
299
299
|
id: string
|
|
300
|
-
scheduleType:
|
|
300
|
+
scheduleType: "cron"
|
|
301
301
|
expression: string
|
|
302
302
|
timezone?: string
|
|
303
303
|
payload?: unknown
|
|
@@ -306,16 +306,16 @@ interface ManifestCronScheduleEntry {
|
|
|
306
306
|
|
|
307
307
|
interface ManifestFutureSendScheduleEntry {
|
|
308
308
|
key: string
|
|
309
|
-
kind:
|
|
309
|
+
kind: "schedule"
|
|
310
310
|
id: string
|
|
311
|
-
scheduleType:
|
|
311
|
+
scheduleType: "future_send"
|
|
312
312
|
fireAt: string
|
|
313
313
|
targetUrl: string
|
|
314
314
|
payload: unknown
|
|
315
315
|
producerId: string
|
|
316
316
|
from?: string
|
|
317
317
|
messageType?: string
|
|
318
|
-
status?:
|
|
318
|
+
status?: "pending" | "sent" | "failed"
|
|
319
319
|
sentAt?: string
|
|
320
320
|
failedAt?: string
|
|
321
321
|
lastError?: string
|