glove-foundry 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -4
- package/dist/chunk-CYOIHSUX.js +1365 -0
- package/dist/{chunk-X6EWEWWM.js → chunk-DTFCEX67.js} +2003 -200
- package/dist/{chunk-OBTOFA7W.js → chunk-EUGKVW3J.js} +470 -638
- package/dist/{chunk-B36BGF5R.js → chunk-J6NHL4SM.js} +370 -74
- package/dist/{chunk-7F7QVO6I.js → chunk-L5JQVTHD.js} +30 -0
- package/dist/{chunk-RSU7NEDK.js → chunk-X3HZYVZS.js} +36 -1
- package/dist/cli.js +4 -4
- package/dist/{client-DWPYe_Nc.d.ts → client-CekanYLW.d.ts} +252 -161
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/{definition-A8o11aez.d.ts → event-delivery-CNCsVqi8.d.ts} +1380 -871
- package/dist/execution-agent.d.ts +0 -1
- package/dist/execution-agent.js +3 -14
- package/dist/execution-daemon.js +10 -5
- package/dist/execution-loader.js +1171 -8
- package/dist/index.d.ts +21 -6
- package/dist/index.js +178 -32
- package/dist/voice.d.ts +12 -8
- package/dist/voice.js +51 -10
- package/docs/README.md +1 -1
- package/docs/architecture.md +8 -0
- package/docs/building-with-foundry.md +137 -5
- package/docs/durable-subagents.md +337 -0
- package/docs/execution.md +4 -0
- package/docs/inspector.md +137 -29
- package/package.json +12 -11
- package/templates/travel-concierge/README.md +1 -1
- package/dist/chunk-K2EU63MB.js +0 -468
- package/dist/chunk-TFGETZYH.js +0 -917
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# Durable subagents
|
|
2
|
+
|
|
3
|
+
A durable subagent is an agent instance owned by another agent instance. Declare a
|
|
4
|
+
named worker in `defineAgent`; Foundry creates it on first use and keeps its identity,
|
|
5
|
+
conversations and owned data available for future work.
|
|
6
|
+
|
|
7
|
+
Use durable subagents when one agent needs several intelligent workers with separate
|
|
8
|
+
responsibilities. Each can have its own model, instructions, tools, memory access and
|
|
9
|
+
run budget, handle many tasks over time, receive events independently, and own further
|
|
10
|
+
workers. The parent can keep serving requests while that work proceeds. This applies
|
|
11
|
+
to chat agents, background services, scheduled work and systems with no conversational
|
|
12
|
+
front. A realtime front is one possible consumer of the same primitives.
|
|
13
|
+
|
|
14
|
+
## What exists in code and storage
|
|
15
|
+
|
|
16
|
+
| Concept | Meaning |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| Worker definition | A normal `defineAgent` value describing a model, instructions and capabilities. Several slots or parents can reuse it. |
|
|
19
|
+
| Named slot | A key in `durableSubagents`, with a worker definition, inheritance selections and delivery defaults. |
|
|
20
|
+
| Owned worker instance | One persisted agent for a particular parent instance and slot name, with its own instance ID in the parent's workspace. |
|
|
21
|
+
| Conversation | A context owned by that worker. Its default event conversation and individual delegated-task conversations are separate. |
|
|
22
|
+
| Run | An execution assembled to process work in a conversation. The same worker instance can be used by many runs. |
|
|
23
|
+
|
|
24
|
+
Two parent instances using the same definition get different workers. Two slots on
|
|
25
|
+
one parent get different workers even when they reuse the same definition. Reusing a
|
|
26
|
+
definition does not adopt an unrelated existing instance.
|
|
27
|
+
|
|
28
|
+
The identity and stored state are durable. A worker does not need a continuously
|
|
29
|
+
running JavaScript process or model session. Foundry assembles it again for each run;
|
|
30
|
+
an idle worker does not occupy an execution slot just to exist.
|
|
31
|
+
|
|
32
|
+
## Declare the relationship
|
|
33
|
+
|
|
34
|
+
Keep workers as ordinary agent definitions, then select them in the parent. An inline
|
|
35
|
+
`defineAgent` value works too. Models and persistence adapters use normal Foundry
|
|
36
|
+
configuration; there is no separate worker harness to construct.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { defineAgent, restrictApp } from "glove-foundry";
|
|
40
|
+
import worker from "../worker/agent.js";
|
|
41
|
+
import knowledgeBase from "./apps/knowledge-base.app.js";
|
|
42
|
+
import { components } from "./composition.js";
|
|
43
|
+
|
|
44
|
+
export default defineAgent({
|
|
45
|
+
description: "Coordinate requests and independent workers",
|
|
46
|
+
model: fastModel,
|
|
47
|
+
systemPrompt: "Help the user and coordinate your workers.",
|
|
48
|
+
components,
|
|
49
|
+
durableSubagents: {
|
|
50
|
+
analysis: {
|
|
51
|
+
agent: worker,
|
|
52
|
+
eventDelivery: { whenIdle: "wake" },
|
|
53
|
+
inherit: {
|
|
54
|
+
context: true,
|
|
55
|
+
tools: ["search_documents"],
|
|
56
|
+
memory: { scope: "shared", access: "reader", profiles: ["personal"] },
|
|
57
|
+
apps: [restrictApp(knowledgeBase, {
|
|
58
|
+
tools: ["search", "read_document"],
|
|
59
|
+
operations: ["documents.read"],
|
|
60
|
+
})],
|
|
61
|
+
},
|
|
62
|
+
cleanup: async ({ agent, conversationIds }) => {
|
|
63
|
+
// Application-owned adapters: delete only this worker's private data.
|
|
64
|
+
await privateMemory.deleteNamespace(agent.id);
|
|
65
|
+
await transcripts.deleteConversations(conversationIds);
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
planner: {
|
|
69
|
+
agent: defineAgent({
|
|
70
|
+
description: "Long-term planning",
|
|
71
|
+
model: thoroughModel,
|
|
72
|
+
systemPrompt: "Maintain long-term plans.",
|
|
73
|
+
runTimeoutMs: 4 * 60 * 60 * 1000,
|
|
74
|
+
maxConcurrentRuns: 1,
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Imported definitions and inline `defineAgent` values work, including nested workers.
|
|
82
|
+
Definitions remain immutable. Discovery derives a route such as
|
|
83
|
+
`coordinator/workers/analysis`; `workers` inside a route is reserved for this purpose.
|
|
84
|
+
Names must be lowercase slugs; `parent` is reserved. Cycles and route collisions fail
|
|
85
|
+
discovery. Declare these relationships statically; ordinary assembly fields remain lazy.
|
|
86
|
+
|
|
87
|
+
## Provisioning and reuse
|
|
88
|
+
|
|
89
|
+
Declaring a slot makes a worker available; it does not create every possible instance
|
|
90
|
+
at startup. A first message or delegated task atomically provisions the owned worker.
|
|
91
|
+
An application can also ensure one explicitly:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { createFoundryClient } from "glove-foundry/client";
|
|
95
|
+
|
|
96
|
+
const client = createFoundryClient({ baseUrl: process.env.FOUNDRY_URL! });
|
|
97
|
+
const parent = await client.agent("coordinator").create({ workspaceId: "workspace-a" });
|
|
98
|
+
const worker = client.subagent(parent.id, "analysis"); // handle only; no request yet
|
|
99
|
+
const instance = await worker.ensure(); // create once or return the existing instance
|
|
100
|
+
await worker.send("Review the current plan."); // also ensures the worker if needed
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The ownership key is the parent instance ID plus the slot name. New messages, tasks
|
|
104
|
+
and controller restarts reuse that instance when the data adapter is persistent.
|
|
105
|
+
Ensuring a worker does not start a model run. Listing and inspection do not provision
|
|
106
|
+
or reactivate workers. A new parent gets new workers; changing a slot name identifies
|
|
107
|
+
a different worker rather than renaming its stored instance.
|
|
108
|
+
|
|
109
|
+
## Direct messages and task delegation
|
|
110
|
+
|
|
111
|
+
A durable worker is a place to send work over time. Task delegation adds an assignment,
|
|
112
|
+
clarification questions, task status and a correlated final result to that independent
|
|
113
|
+
lifetime. Direct messages communicate facts, priority changes or spontaneous findings
|
|
114
|
+
without creating a tracked task. Both use the same addressed event-delivery layer.
|
|
115
|
+
|
|
116
|
+
Calls to
|
|
117
|
+
`glove_foundry_delegate({ to: "analysis", task: "Write a report" })` use the owned
|
|
118
|
+
worker. Existing `delegates` continue to work. A durable name takes precedence
|
|
119
|
+
when it also names a sibling delegate. Each task gets a separate conversation;
|
|
120
|
+
its final result and questions return to the originating parent conversation.
|
|
121
|
+
|
|
122
|
+
`glove_foundry_message({ to: "analysis", message: "Watch this competitor" })`
|
|
123
|
+
sends a spontaneous message without creating a task. The worker can send
|
|
124
|
+
`glove_foundry_message({ to: "parent", message: "Something changed" })` at any time.
|
|
125
|
+
An instance ID identifies the worker; a conversation ID identifies the particular
|
|
126
|
+
context in which it processes an event. By default messages address a stable event
|
|
127
|
+
conversation belonging to the recipient. They do not automatically enter an active
|
|
128
|
+
task or the latest parent chat. Supply
|
|
129
|
+
`delivery.conversationId` to address an existing conversation explicitly. Foundry
|
|
130
|
+
validates that it belongs to the recipient and shares its workspace; it never guesses
|
|
131
|
+
the latest chat. The model tool accepts only declared children and the actual parent.
|
|
132
|
+
It cannot address arbitrary instance IDs. Events sent by the tool include a
|
|
133
|
+
`metadata.replyTo` agent/conversation address, which a worker can use to target its
|
|
134
|
+
reply. There is no automatic reply loop.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
await worker.send("Include these three companies.", {
|
|
138
|
+
id: "analysis-update-42", // stable across retries
|
|
139
|
+
conversationId: reportConversationId,
|
|
140
|
+
whenIdle: "defer", // join the next turn
|
|
141
|
+
deferTimeoutMs: 30_000, // or wake after 30 seconds
|
|
142
|
+
expiresAt: "2027-01-01T00:00:00Z",
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// The same layer supports direct addressed events from an application.
|
|
146
|
+
await client.emitEvent(
|
|
147
|
+
{ agentId: workerId, conversationId: reportConversationId },
|
|
148
|
+
{ id: "source-change-42", source: "app:watcher", kind: "source.changed", content: "The source changed." },
|
|
149
|
+
{ whenIdle: "wake" },
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// From the worker, target the parent conversation explicitly.
|
|
153
|
+
await messageTool.run({
|
|
154
|
+
to: "parent", message: "A finding needs your attention.",
|
|
155
|
+
delivery: { conversationId: parentConversationId, whenIdle: "wake" },
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Delivery policies
|
|
160
|
+
|
|
161
|
+
`defineAgent({ eventDelivery })` sets the recipient's default policy; a durable slot
|
|
162
|
+
can replace that default object with `durableSubagents.analysis.eventDelivery`. Each
|
|
163
|
+
send can override fields of the effective policy. The default is `whenIdle: "wake"`.
|
|
164
|
+
`defer` with no effective timeout waits
|
|
165
|
+
for another turn; with `deferTimeoutMs`, the original acceptance time determines the
|
|
166
|
+
wake deadline, including across restarts. `expiresAt` discards stale events before
|
|
167
|
+
injection. Policies affect idle conversations; events sent to a conversation with a
|
|
168
|
+
live run join its next native event boundary. Different conversations can run
|
|
169
|
+
independently within execution limits. A waking event can carry other deferred events into the same
|
|
170
|
+
turn. These are deterministic controller policies; they do not infer user presence.
|
|
171
|
+
|
|
172
|
+
The message tool waits for durable acceptance, not for the recipient's answer.
|
|
173
|
+
Receipts contain `messageId`, `agentId`, `conversationId`, and a `runId` when one is
|
|
174
|
+
handling the event. A receipt is not a completion notification. IDs are scoped to
|
|
175
|
+
the exact target. Reusing an ID with different content or policy fails.
|
|
176
|
+
|
|
177
|
+
## Shared durable runtime events
|
|
178
|
+
|
|
179
|
+
Direct messages, initial delegated tasks, results, questions, replies, and inbound
|
|
180
|
+
transmissions use the same adapter-backed event journal. Each record stores its
|
|
181
|
+
explicit target, stable native event ID, policy, pending/acknowledged/expired state,
|
|
182
|
+
and handling run. Delegation retains its task status and correlation semantics on
|
|
183
|
+
top of that transport. Its results still return to the originating conversation.
|
|
184
|
+
|
|
185
|
+
A live run receives native `AgentEvent` values through `emitEvent`: during a tool
|
|
186
|
+
loop they join the next boundary; a realtime runtime can receive them through
|
|
187
|
+
`holdTurns({ onEvent })` and `takeEvents()`. Open tasks remain live runtime-context
|
|
188
|
+
snapshots. Event-triggered model turns use `processEvents()` and native event
|
|
189
|
+
framing, with no synthetic user request. Deferred events are seeded before a new
|
|
190
|
+
request's first model call. Custom Foundry handlers can inspect `ctx.events`; a
|
|
191
|
+
successful return acknowledges the events that started their run.
|
|
192
|
+
|
|
193
|
+
The filesystem handoff to a live process is only a transport. It is not the source
|
|
194
|
+
of durability, and no mesh adapter, mesh inbox, or inbox-capable Glove store is
|
|
195
|
+
required. Setting `delivery: "events"` on an existing mesh configuration uses native live events too; raw
|
|
196
|
+
mesh transport and direct `glove.emitEvent` calls do not themselves create Foundry
|
|
197
|
+
journal records. Use `runtime.emitEvent`/`client.emitEvent` or the messaging tool
|
|
198
|
+
when delivery must survive the absence of a running process. Legacy mesh inbox mode
|
|
199
|
+
is the default; select native live delivery explicitly on your transport, for example
|
|
200
|
+
`mesh: { adapter: meshAdapter, delivery: "events" }`, where `meshAdapter` implements `MeshAdapter`.
|
|
201
|
+
|
|
202
|
+
Foundry acknowledges events only after a successful receiving run reports that it
|
|
203
|
+
consumed them. Unread events stay pending; shutdown, failures and archival retain
|
|
204
|
+
unfinished delivery. Startup reconciles completed run receipts before replaying
|
|
205
|
+
pending events. Delivery is **at least once**, including a crash after an external
|
|
206
|
+
side effect but before acknowledgment. Make external effects idempotent using event
|
|
207
|
+
IDs. Completed and expired IDs remain in the journal to suppress duplicate retries;
|
|
208
|
+
worker purge removes this owned journal data. Native transcript persistence and event
|
|
209
|
+
acknowledgment are separate transactions, so a crash can also replay an event already
|
|
210
|
+
present in history.
|
|
211
|
+
|
|
212
|
+
Persistent adapters implement atomic `claimEvent` (insert-if-absent), `putEvent`, and
|
|
213
|
+
`listEvents`; messaging fails explicitly when these methods are absent. The bundled
|
|
214
|
+
memory adapter is process-local; the file adapter persists the journal and receipts.
|
|
215
|
+
The execution controller owns idle timers so a worker process need not stay alive
|
|
216
|
+
while deferred work waits. Use one active controller per execution deployment.
|
|
217
|
+
|
|
218
|
+
Use `FileFoundryDataAdapter` or a persistent transactional adapter, and configure an
|
|
219
|
+
application `conversationStore` (or worker `store`) for transcripts. Instance and
|
|
220
|
+
message persistence does not itself persist native Glove transcripts, memory, or
|
|
221
|
+
external files. These keep their existing Foundry persistence boundaries.
|
|
222
|
+
|
|
223
|
+
## Execution budgets and responsiveness
|
|
224
|
+
|
|
225
|
+
A worker's run is independent of the run that delegated to it. A parent can finish a
|
|
226
|
+
request while the worker continues; a question or result can later wake the originating
|
|
227
|
+
parent conversation. Models and run budgets can be chosen separately for each role.
|
|
228
|
+
|
|
229
|
+
`runTimeoutMs` sets a definition's run deadline; the existing default remains five
|
|
230
|
+
minutes. `maxConcurrentRuns` limits that definition's simultaneous runs. Set runtime
|
|
231
|
+
`execution.maxConcurrent` above the combined background limits to leave slots for
|
|
232
|
+
responsive agents. This is capacity control, not preemption or a latency guarantee.
|
|
233
|
+
|
|
234
|
+
## Inheritance and permissions
|
|
235
|
+
|
|
236
|
+
Nothing is inherited implicitly: no transcript, context, tools, applications, MCP,
|
|
237
|
+
playbooks, schedules, or memory. A reused definition retains its own explicit abilities.
|
|
238
|
+
|
|
239
|
+
- `context: true` copies instance context **once when provisioned**. Later parent
|
|
240
|
+
edits do not overwrite worker state.
|
|
241
|
+
- `tools` selects always-on tools from the parent's `tools` resolver by exact name.
|
|
242
|
+
They resolve in the child's context. Approval requirements remain intact. Installed
|
|
243
|
+
shared tools are not copied by this selector; declare them on the worker or expose
|
|
244
|
+
them through a restricted app.
|
|
245
|
+
- `memory: "shared"` reuses selected parent profiles with parent **agent-scoped**
|
|
246
|
+
adapter identity and read-only tools. `"isolated"` uses the child's identity with the
|
|
247
|
+
same profile definitions. Omit memory inheritance to retain only the worker's own
|
|
248
|
+
profiles. Adapter factories must actually namespace storage by the supplied identity;
|
|
249
|
+
a factory that ignores it cannot be isolated by Foundry.
|
|
250
|
+
- Memory objects can choose `profiles` and request `access: "curator"`; this never
|
|
251
|
+
upgrades a parent reader surface. Read-only inheritance also removes ambient-context
|
|
252
|
+
mutation tools. Custom `mount` profiles cannot be safely inspected and are rejected
|
|
253
|
+
for inheritance. Shared memory is agent-scoped, not a copy of a parent conversation;
|
|
254
|
+
its stable conversation scope is the parent's stable agent event conversation.
|
|
255
|
+
- `apps` borrows only currently installed parent applications, including their selected
|
|
256
|
+
account and configuration. It is recomputed for each run, not copied into worker
|
|
257
|
+
desired state. Removing the parent's installation revokes it. The persistent
|
|
258
|
+
application data adapter is rechecked before borrowed app tool and account-session
|
|
259
|
+
operations, including long-running workers. Already-running external effects cannot
|
|
260
|
+
be undone by revocation.
|
|
261
|
+
|
|
262
|
+
`restrictApp(app, { tools, operations, transmissions })` is a restricted view of an
|
|
263
|
+
app's existing identity. Every list is an exact allowlist; omitted lists grant
|
|
264
|
+
nothing. Chaining modifiers intersects permissions. `tools` filters contributed tools;
|
|
265
|
+
`operations` gates `withAccountSession`; `transmissions` gates generated transmission
|
|
266
|
+
tools, inbound connections and outbound dispatch. Raw strings/unmodified apps in
|
|
267
|
+
`inherit.apps` grant none of these operations until restricted explicitly. Duplicate
|
|
268
|
+
child/inherited catalogue identities fail rather than letting an unrestricted entry
|
|
269
|
+
shadow a restricted one.
|
|
270
|
+
|
|
271
|
+
Outbound route grants/bindings remain separately required and are **not inherited**.
|
|
272
|
+
App modifiers cannot grant a route, acquire credentials, or disable tool approval.
|
|
273
|
+
The HTTP API remains protected by the application request-authorization adapter.
|
|
274
|
+
|
|
275
|
+
These are model capability boundaries, not a sandbox for hostile application code.
|
|
276
|
+
App installers, tool implementations, memory factories, `configure`, and cleanup hooks
|
|
277
|
+
are trusted code. For example, an app should use its supplied account-session adapter
|
|
278
|
+
instead of bypassing it with process-global credentials.
|
|
279
|
+
|
|
280
|
+
## Management and retention
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
const worker = client.subagent(parentId, "analysis");
|
|
284
|
+
const instance = await worker.ensure();
|
|
285
|
+
await worker.send("Include these three companies.");
|
|
286
|
+
const state = await worker.data();
|
|
287
|
+
const children = await client.subagents(parentId);
|
|
288
|
+
await worker.archive();
|
|
289
|
+
await worker.resume();
|
|
290
|
+
await worker.archive();
|
|
291
|
+
await worker.purge();
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
`data()` lists the instance, conversations, children, activations, pending messages, event journal records,
|
|
295
|
+
owned tasks and inbox items. Normal transcript and environment APIs work with its
|
|
296
|
+
instance/conversation IDs. Listing and inspection do not provision or reactivate it.
|
|
297
|
+
|
|
298
|
+
Archival marks the worker inactive first, archives existing descendants, disarms
|
|
299
|
+
schedules, and stops queued/running work. Its data and unfinished events remain. New
|
|
300
|
+
messages, delegation and direct runs fail while archived. Resume activates only the
|
|
301
|
+
selected worker and replays pending events. Descendants and paused schedules require
|
|
302
|
+
explicit resumption. Removing a declaration detaches existing workers; it does not
|
|
303
|
+
delete their records or prevent inspection/archival.
|
|
304
|
+
|
|
305
|
+
Purge requires archival, no running work, all descendants already purged, adapter
|
|
306
|
+
support, and an explicit idempotent `cleanup` hook for application-owned private
|
|
307
|
+
memory, transcripts and external files. Keep the declaration until cleanup finishes.
|
|
308
|
+
Use a no-op hook only when the application has no external worker data. Hook failure
|
|
309
|
+
preserves the archived records so cleanup can be retried.
|
|
310
|
+
|
|
311
|
+
The bundled adapters atomically remove owned conversations, pending deliveries, event records and deduplication receipts,
|
|
312
|
+
activations, VFS snapshots, tasks, inbox items and scoped environment data. Shared
|
|
313
|
+
workspace entries, parent memory and app accounts are never purged. A minimal instance
|
|
314
|
+
tombstone retains ownership and provisioning identity, preventing an old message or
|
|
315
|
+
retry from silently recreating the worker. Use a new name for a replacement. Execution
|
|
316
|
+
history and observability have their own retention; purge does not erase those logs
|
|
317
|
+
or third-party records.
|
|
318
|
+
|
|
319
|
+
The REST equivalents live under
|
|
320
|
+
`/api/agent-instances/:parent/subagents`: `GET` lists workers;
|
|
321
|
+
`POST /:name` ensures one; `POST /:name/messages` accepts `{ message, delivery? }`;
|
|
322
|
+
`GET /:name/data` inspects it; `POST /:name/archive`, `/resume`, and `/purge`
|
|
323
|
+
manage its lifecycle. The runtime exposes matching `subagent`, `listSubagents`,
|
|
324
|
+
`messageSubagent`, `subagentData`, `archiveSubagent`, `resumeSubagent`, and
|
|
325
|
+
`purgeSubagent` methods.
|
|
326
|
+
|
|
327
|
+
`POST /api/events` accepts `{ target: { agentId, conversationId }, event, policy? }`,
|
|
328
|
+
matching `runtime.emitEvent` and `client.emitEvent`. It uses the same application
|
|
329
|
+
request authorization as the rest of the HTTP API.
|
|
330
|
+
|
|
331
|
+
## Complete worked example
|
|
332
|
+
|
|
333
|
+
The [realtime front and durable researcher walkthrough](https://glove.dterminal.net/foundry/docs/durable-subagents/realtime-example)
|
|
334
|
+
applies these primitives in a runnable project with persistent stores, memory/app
|
|
335
|
+
inheritance, direct messages, task delegation, delivery policies and restart checks.
|
|
336
|
+
Source: `examples/foundry-durable-research`. The ownership and delivery model above
|
|
337
|
+
applies regardless of how the agents receive work.
|
package/docs/execution.md
CHANGED
|
@@ -61,6 +61,10 @@ Foundry stops Station and its resource adapters on shutdown, and cleans up on fa
|
|
|
61
61
|
|
|
62
62
|
Programmatic `FoundryRuntime.discover` calls using a daemon adapter must supply `applicationFilePath`; closures are loaded in the child process, never serialized from the parent. Each Foundry runtime owns its Station instance. A fixed port must be unique per instance; omitting it avoids manual port allocation.
|
|
63
63
|
|
|
64
|
+
## Kuiper's browsers and sandboxes, without a daemon
|
|
65
|
+
|
|
66
|
+
On [Kuiper](https://kuiper.sh), `glove-execution/kuiper` mounts Kuiper's browsers (real Chrome) and sandboxes through `@kuiper-sh/sdk`: `kuiperBrowser({ browsers: kuiper.browsers, … })` and `kuiperSandbox({ sandboxes: kuiper.sandboxes, … })`. They need no `stationDaemon`. A Kuiper session or sandbox belongs to the project rather than the process, so each run mounts it in `configure`, and the next run reconnects by the IDs the application kept, usually on the agent instance. The browser adapter takes a `guard` that sees every request the browser makes, and an `onHandOff` that gives a person Kuiper's live view for a sign-in. See the [glove-execution README](../../glove-execution/README.md#kuiper) and the personal-agent example.
|
|
67
|
+
|
|
64
68
|
## Optional capability mounts
|
|
65
69
|
|
|
66
70
|
Browser and sandbox support is opt-in through `glove-execution`. Neither `glove-core` nor Foundry depends on that package. Use the same explicit mounting pattern as other Glove extensions, inside Foundry's existing `configure` hook:
|
package/docs/inspector.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Foundry inspector
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
custom context providers are mounted. It shows the latest observed progress,
|
|
5
|
-
fact/claim counts and pending form effects, not a live database query. Answer
|
|
6
|
-
values and fact bodies are excluded from this summary. See [guidance](./guidance.md).
|
|
3
|
+
The development server includes a runtime inspector. Most pages follow Foundry's ownership boundaries: definitions, instances, conversations, automations, integrations and workspaces. A run opens as a workbench modelled on a browser's DevTools:
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
- **Network** lists every model request and tool call.
|
|
6
|
+
- **Console** is the run's log.
|
|
7
|
+
- **Context** shows what the agent had to work with.
|
|
8
|
+
- **Summary** gives the outcome.
|
|
9
9
|
|
|
10
10
|
## Navigation
|
|
11
11
|
|
|
@@ -17,18 +17,137 @@ The development server includes a read-oriented runtime inspector. It is organiz
|
|
|
17
17
|
| Agent instance | Which context, installations, playbooks, conversations, and runs belong to this persisted identity? |
|
|
18
18
|
| Chat | What has this exact instance/conversation said, and how can I continue, stop, or redirect it? |
|
|
19
19
|
| Runs | Which invocations occurred and what status, source, and attempt count did each have? |
|
|
20
|
-
| Run
|
|
20
|
+
| Run | What did the model see and do at each step: requests, tool calls, log, context and outcome? |
|
|
21
21
|
| Automations | Which schedules, sleeping runs, playbook listeners, and inbound application workers exist? |
|
|
22
22
|
| Integrations | Which transmissions, safe account references, routes, and agent bindings form the external topology? |
|
|
23
23
|
| Workspaces | Which shared entries, inbox items, tasks, and non-secret environment values are available? |
|
|
24
24
|
|
|
25
|
-
Every
|
|
25
|
+
Every view has a real URL that can be bookmarked or opened directly, for example:
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
- `/agents/support-lead`
|
|
28
|
+
- `/instances/<agent-id>`
|
|
29
|
+
- `/chat/<conversation-id>?agent=<agent-id>`
|
|
30
|
+
- `/runs/<run-id>?item=<request>&pane=context`
|
|
31
|
+
|
|
32
|
+
The Foundry server returns the inspector shell for every path outside the API.
|
|
33
|
+
|
|
34
|
+
The inspector and APIs share one authorization boundary:
|
|
35
|
+
|
|
36
|
+
- Loopback remains the development default.
|
|
37
|
+
- Foundry refuses a non-loopback bind without the application's `requestAuthorization` adapter.
|
|
38
|
+
- When that adapter is configured, every HTML, API, health and event stream request must pass it.
|
|
39
|
+
- The adapter owns credential and session validation and the browser challenge. Foundry keeps credential values out of state and traces.
|
|
40
|
+
|
|
41
|
+
## Following a run
|
|
42
|
+
|
|
43
|
+
Open **Runs**, then a run. A strip at the top gives its status, duration, number of model requests and tool calls, tokens and agent instance. Below it are four views:
|
|
44
|
+
|
|
45
|
+
- Switch between them with `1`–`4`.
|
|
46
|
+
- The view, the open request and its pane are all in the URL, so a link opens someone else on the same step.
|
|
47
|
+
|
|
48
|
+
The screenshots below are runs of Meta Muse, the [personal agent example](../../../examples/foundry-personal-agent), on Claude Sonnet 5.5 through OpenRouter. They use the example's sample accounts and its offline stand-in for Kuiper's browsers.
|
|
49
|
+
|
|
50
|
+
### Network
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
In this run Muse tries to book a restaurant:
|
|
55
|
+
|
|
56
|
+
1. The Sentinel blocks a site Rosa hasn't allowed (the first red row).
|
|
57
|
+
2. Rosa allows it with `request_access`.
|
|
58
|
+
3. The page still fails to load. The model asked for HTTPS, and the offline demo serves its sample sites over plain HTTP.
|
|
59
|
+
4. Midway, at #5, Glove compacts the conversation.
|
|
60
|
+
5. The calls a REPL program makes sit under the `execute_js` call that ran them.
|
|
61
|
+
|
|
62
|
+
Each row is one model request (a square), one tool call (a circle), or a subagent. The columns:
|
|
63
|
+
|
|
64
|
+
| Column | Meaning |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| Name | `#1 request`, `#2 request`, … or the tool's name, with the model and message count, or the tool's input, underneath. |
|
|
67
|
+
| Type | `model`, `compaction`, `tool`, `repl call` (a tool called from inside a REPL program) or `subagent`. |
|
|
68
|
+
| Status | `ok`, `error`, `aborted`, `denied`, `pending`, or `approval` while a person hasn't decided. |
|
|
69
|
+
| Initiator | What led to the row. A request follows `run input` or the tools of the previous request (`after search`). A tool call comes from the request whose response asked for it. Click it to jump there. |
|
|
70
|
+
| Size | Tokens in → out for a model request; the size of the result for a tool. |
|
|
71
|
+
| Time and Waterfall | How long it took, and when, across the whole run. |
|
|
72
|
+
|
|
73
|
+
Filter rows by text (name, input, result or reply) and by **All**, **Model**, **Tools** or **Errors**. The footer totals requests, tool calls, tokens (and cache reads), and the time spent in the model and in tools.
|
|
74
|
+
|
|
75
|
+
Click a row, or walk them with `j` and `k`, to open it beside the list. `Esc` closes it. A model request has these panes:
|
|
76
|
+
|
|
77
|
+
| Pane | What it shows |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| Overview | Request id, model, status, start, duration, tokens and cache, stop reason, initiator, sizes, and links to the tool calls in its response. |
|
|
80
|
+
| Prompt | The system prompt this request was sent. |
|
|
81
|
+
| Messages | The conversation as this request sent it. Messages already sent earlier fold away, so what's new sits at the end. Tool calls and results show their JSON, and each links to its tool row. |
|
|
82
|
+
| Context | The runtime context added at the end of this request: memory, goals, forms, or any context provider. Each entry is marked new, changed or the same as the previous request. |
|
|
83
|
+
| Tools | Each tool the model was offered, with its description and input schema. |
|
|
84
|
+
| Response | What the model sent back, its stop reason and tokens, or the error that ended the request. |
|
|
85
|
+
| Raw | The recorded events. |
|
|
86
|
+
|
|
87
|
+
**Copy request** copies the request as JSON: model, system prompt, messages, runtime context and tools. Use it to replay a step against a model, or to attach it to an issue.
|
|
88
|
+
|
|
89
|
+

|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
A tool call has these panes:
|
|
94
|
+
|
|
95
|
+
- **Overview**: call id, duration, the request that made it, and its approval (who decided, and when).
|
|
96
|
+
- **Input**: what the model passed.
|
|
97
|
+
- **Result**: status, message and data. JSON held inside a string opens as a tree.
|
|
98
|
+
- **Raw**: the recorded events.
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
### Console
|
|
103
|
+
|
|
104
|
+

|
|
105
|
+
|
|
106
|
+
The run as a log, one line per event:
|
|
107
|
+
|
|
108
|
+
- **Levels.** Errors and warnings are coloured: a failed tool, a run that failed or retried, stderr, an approval being waited on. **Default levels** hides verbose detail, such as assembly steps and streamed text. **All levels** shows it. You can also show only warnings and errors, or only errors.
|
|
109
|
+
- **Streamed text.** A streamed reply is one line, not one line per chunk.
|
|
110
|
+
- **Filters.** Filter by text and by source (`run`, `model`, `tool`, `stdout`, `stderr`, `assembly`, …).
|
|
111
|
+
- **Expanding a line.** Click a line to see its data as a tree and to copy it. Lines about a request or tool call have **Open in Network**.
|
|
112
|
+
- **Live runs.** While the run is live, the console stays at the bottom unless you have scrolled up.
|
|
113
|
+
|
|
114
|
+
### Context
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
Like DevTools' Application panel, a tree on the left and the selected item on the right:
|
|
119
|
+
|
|
120
|
+
| Group | Items |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| Model request | System prompt, runtime context, tools and messages. **As of** chooses which request; the latest is the default. When the run used more than one system prompt (a subagent has its own), each is listed with the requests that used it. |
|
|
123
|
+
| Run | The input it was given, and its output or error. |
|
|
124
|
+
| Agent | The instance's stored context, installations and playbooks, with links to the instance, workspace and conversation. |
|
|
125
|
+
| Memory | Goals, facts and forms (see [guidance](./guidance.md)), and the memory events the run recorded. What memory put in front of the model is in each request's runtime context. |
|
|
126
|
+
|
|
127
|
+
### Summary
|
|
128
|
+
|
|
129
|
+
The run's phases (accepted, assembled, agent work, outcome), its recorded output and input, the slowest steps and every failed request or tool call, each linking to its row in Network. A failed run states its error at the top of the page, and pending approvals show there with their exact input. **Export trace** downloads the run and every event as JSON. **Run again** reopens the run drawer with the same instance and message.
|
|
130
|
+
|
|
131
|
+
The inspector shows what was observable: what was sent, called and returned. It doesn't show a model's hidden reasoning, and reasoning a provider asks to have echoed back isn't recorded.
|
|
132
|
+
|
|
133
|
+
### What each model request records
|
|
134
|
+
|
|
135
|
+
Glove reports every model call to subscribers that ask for it, as `model_request` and `model_request_end` events. These carry the system prompt, messages, tools, outcome, response and tokens. A run records them compactly, because a long conversation would otherwise be copied into every request:
|
|
136
|
+
|
|
137
|
+
- The system prompt and the tool list are recorded in full the first time a run sends them, then by hash.
|
|
138
|
+
- Messages are recorded as a change against the previous request with the same system prompt: how many leading messages were kept, then the rest. The inspector puts each request's full list back together.
|
|
139
|
+
- Runtime context is recorded with every request, since it is worked out again each time.
|
|
140
|
+
- Text is cut at 16,000 characters and JSON at 16,000 characters; the system prompt is cut at 64,000.
|
|
141
|
+
- Images, video and documents become a placeholder with their type and name. A request records at most about 400 KB of messages, newest first; older ones are counted.
|
|
142
|
+
- `renderData` (which the model never sees) and echoed provider reasoning are left out.
|
|
143
|
+
|
|
144
|
+
Events are kept in memory, 10,000 by default (`observability.maxEvents`). A message whose request has aged out shows as *not retained*. To keep model requests out of the event stream entirely, set this in `foundry.config.ts`:
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
export default defineConfig({ observability: { modelRequests: false } });
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Runs recorded before this, or with model requests off, still list their tool calls, model responses and log.
|
|
32
151
|
|
|
33
152
|
## Talking to an agent
|
|
34
153
|
|
|
@@ -53,19 +172,6 @@ is explicit in the URL, and every refresh reloads history from the server. New
|
|
|
53
172
|
conversations take the first text turn as their initial title and can be renamed
|
|
54
173
|
later without changing their stable conversation identity.
|
|
55
174
|
|
|
56
|
-
## Following a run
|
|
57
|
-
|
|
58
|
-
Open **Runs**, then choose one invocation. The run detail starts with a four-phase spine:
|
|
59
|
-
|
|
60
|
-
1. Accepted: Foundry persisted the invocation and its source.
|
|
61
|
-
2. Assembled: context-dependent agent components were resolved and mounted.
|
|
62
|
-
3. Agent work: observable model and tool work occurred.
|
|
63
|
-
4. Completed, failed, cancelled, or still in progress.
|
|
64
|
-
|
|
65
|
-
The event trace below the spine is collapsed by default. Each row carries its wall-clock time and its offset from the start of the run, so a slow phase is visible without arithmetic. Filter the trace by event category, expand an event when you need its adapter payload, and copy a payload straight from the expanded row. The inspector shows observable intent, actions, and outcomes; it does not expose a model's private hidden chain-of-thought.
|
|
66
|
-
|
|
67
|
-
A failed run states its error above the spine rather than only inside the recorded output. A run that is still going says so and keeps a running duration. **Run again** reopens the run drawer with the same instance and message.
|
|
68
|
-
|
|
69
175
|
## Starting work
|
|
70
176
|
|
|
71
177
|
Use **New run** from any page. Select a definition and either:
|
|
@@ -91,7 +197,7 @@ The **Runs** page keeps its filters in the query string, so any view is a link y
|
|
|
91
197
|
|
|
92
198
|
The inspector subscribes to `/api/events` with server-sent events and also performs a low-frequency reconciliation. A busy run emits many events, so they are coalesced into one refresh rather than one repaint each.
|
|
93
199
|
|
|
94
|
-
A refresh preserves what you are doing: scroll position
|
|
200
|
+
A refresh preserves what you are doing: scroll position (including each pane of a run), expanded and collapsed sections, and the text and caret in a filter box all survive it. A run's page fetches that run's own events, then only the new ones (`/api/runs/:id/events?after=<sequence>`), so a long run isn't cut short by the global event list. Relative timestamps and the duration of an in-flight run tick every second without a repaint.
|
|
95
201
|
|
|
96
202
|
Press `Command-K` or `Control-K` to search pages, definitions, instances, and retained runs.
|
|
97
203
|
|
|
@@ -99,13 +205,14 @@ Press `Command-K` or `Control-K` to search pages, definitions, instances, and re
|
|
|
99
205
|
|
|
100
206
|
| Key | Action |
|
|
101
207
|
| --- | --- |
|
|
102
|
-
| `j` / `k` | Move down and up the current list |
|
|
208
|
+
| `j` / `k` | Move down and up the current list; on a run's Network view, open the next or previous request |
|
|
209
|
+
| `1`–`4` | On a run: Summary, Network, Console, Context |
|
|
103
210
|
| `Enter` or `o` | Open the highlighted row |
|
|
104
|
-
| `/` | Focus the
|
|
211
|
+
| `/` | Focus the filter (runs, Network, Console), or open search elsewhere |
|
|
105
212
|
| `c` | Start a run |
|
|
106
213
|
| `r` | Refresh runtime data |
|
|
107
214
|
| `Command-K` / `Control-K` | Search |
|
|
108
|
-
| `Escape` | Close the drawer or search |
|
|
215
|
+
| `Escape` | Close the drawer or search; on a run, close the open request, or leave a filter box |
|
|
109
216
|
| `Command-Enter` | Submit the run drawer |
|
|
110
217
|
|
|
111
218
|
Every truncated identifier in the inspector has a copy button, so the full run, instance, or conversation id is always retrievable.
|
|
@@ -119,6 +226,7 @@ The inspector is an API client and adds no hidden runtime state. Its primary rea
|
|
|
119
226
|
- `POST /api/conversations/:id/messages` and `/api/runs/:id/cancel|steer`
|
|
120
227
|
- `PATCH /api/conversations/:id` for an instance-owned title or context update
|
|
121
228
|
- `/api/runs`, `/api/runs/:id`, and `/api/events`
|
|
229
|
+
- `/api/runs/:id/events`, with `?after=<sequence>` for only what's new, for one run's trace
|
|
122
230
|
- `/api/activations` and `/api/playbook-subscriptions`
|
|
123
231
|
- `/api/application-connections`
|
|
124
232
|
- `/api/transmissions`, `/api/accounts`, `/api/routes`, and `/api/bindings`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glove-foundry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "An Effect-native, file-routed framework for typed, observable Glove agent applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,18 +77,19 @@
|
|
|
77
77
|
"station-client": "^3.0.0",
|
|
78
78
|
"station-beacon": "^3.0.0",
|
|
79
79
|
"station-broadcast": "^3.0.0",
|
|
80
|
-
"glove-core": "4.
|
|
81
|
-
"glove-js": "0.5.
|
|
82
|
-
"glove-
|
|
83
|
-
"glove-
|
|
84
|
-
"glove-
|
|
85
|
-
"glove-
|
|
86
|
-
"glove-
|
|
87
|
-
"glove-
|
|
88
|
-
"glove-
|
|
89
|
-
"glove-
|
|
80
|
+
"glove-core": "4.7.0",
|
|
81
|
+
"glove-js": "0.5.6",
|
|
82
|
+
"glove-facts": "0.1.8",
|
|
83
|
+
"glove-memory": "2.3.3",
|
|
84
|
+
"glove-mcp": "1.2.6",
|
|
85
|
+
"glove-lisp": "0.5.6",
|
|
86
|
+
"glove-python": "0.4.6",
|
|
87
|
+
"glove-mesh": "0.2.3",
|
|
88
|
+
"glove-voice-s2s": "0.4.6",
|
|
89
|
+
"glove-working-environment": "0.7.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
92
93
|
"@types/node": "^25.2.3",
|
|
93
94
|
"@types/ws": "8.18.1",
|
|
94
95
|
"tsup": "^8.5.1",
|
|
@@ -213,7 +213,7 @@ console.log((await run.wait()).output);
|
|
|
213
213
|
| Overview | Is the runtime healthy, what is running, what needs attention |
|
|
214
214
|
| Agents | Which definitions exist and which instances were provisioned |
|
|
215
215
|
| Runs | Every invocation, with status, duration, and source |
|
|
216
|
-
| Run
|
|
216
|
+
| Run | Each model request (system prompt, messages, memory, tools) and tool call, the log, and the outcome |
|
|
217
217
|
| Automations | Schedules, sleeping runs, playbook listeners, inbound workers |
|
|
218
218
|
| Integrations | Transmissions, accounts, routes, and bindings |
|
|
219
219
|
| Workspaces | Shared entries, inbox, tasks, and non-secret environment values |
|