glove-foundry 0.8.0 → 0.10.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/dist/index.js CHANGED
@@ -43,12 +43,12 @@ import {
43
43
  memoryTopologyStore,
44
44
  serializeInboundTransmissionXml,
45
45
  writeGeneratedTypes
46
- } from "./chunk-DTFCEX67.js";
46
+ } from "./chunk-PMNRLJIQ.js";
47
47
  import {
48
48
  FoundryClient,
49
49
  FoundryRunHandle,
50
50
  createFoundryClient
51
- } from "./chunk-L5JQVTHD.js";
51
+ } from "./chunk-N2GVJ257.js";
52
52
  import {
53
53
  defineConfig
54
54
  } from "./chunk-ZFNMFE3T.js";
@@ -81,6 +81,9 @@ import {
81
81
  FOUNDRY_TRANSMISSION_PREDICATE_BRAND,
82
82
  FoundryApprovalDisplayManager,
83
83
  MemoryFoundryDataAdapter,
84
+ activationScheduleRevision,
85
+ assertScheduleOccurrence,
86
+ compareOccurrences,
84
87
  composeAgent,
85
88
  composePlaybook,
86
89
  createAgentInstance,
@@ -105,16 +108,19 @@ import {
105
108
  isFoundrySchedule,
106
109
  isFoundryTransmission,
107
110
  listFoundryApprovals,
111
+ matchesOccurrenceFilter,
112
+ prunableOccurrences,
108
113
  reconstructAgentInstance,
109
114
  reconstructPlaybook,
110
115
  reconstructPlaybookSubscription,
111
116
  resolveFoundryApproval,
112
117
  routeFromAgentFile,
118
+ scheduleOccurrenceId,
113
119
  toGloveMessage,
114
120
  toGloveRequestInput,
115
121
  transmissionPredicate,
116
122
  withFoundryPermissions
117
- } from "./chunk-EUGKVW3J.js";
123
+ } from "./chunk-T6YLIGER.js";
118
124
  import {
119
125
  meshIdentity
120
126
  } from "./chunk-J6NHL4SM.js";
@@ -181,6 +187,7 @@ function emptyState(environment) {
181
187
  pendingInbound: [],
182
188
  approvals: [],
183
189
  activations: [],
190
+ occurrences: [],
184
191
  conversations: [],
185
192
  workspaceEntries: [],
186
193
  workingEnvironments: [],
@@ -290,6 +297,7 @@ var FileFoundryDataAdapter = class {
290
297
  pendingInbound: parsed.pendingInbound ?? [],
291
298
  approvals: parsed.approvals ?? [],
292
299
  activations: parsed.activations ?? [],
300
+ occurrences: parsed.occurrences ?? [],
293
301
  conversations: parsed.conversations ?? [],
294
302
  workspaceEntries: parsed.workspaceEntries ?? [],
295
303
  workingEnvironments: parsed.workingEnvironments ?? [],
@@ -414,6 +422,7 @@ var FileFoundryDataAdapter = class {
414
422
  state.pendingInbound = state.pendingInbound.filter((item) => item.request.agentId !== agentId);
415
423
  state.approvals = state.approvals.filter((item) => item.agentId !== agentId);
416
424
  state.activations = state.activations.filter((item) => item.agentId !== agentId);
425
+ state.occurrences = state.occurrences.filter((item) => item.agentId !== agentId);
417
426
  state.conversations = state.conversations.filter((item) => item.agentId !== agentId);
418
427
  state.workingEnvironments = state.workingEnvironments.filter((item) => item.owner.agentId !== agentId);
419
428
  state.inbox = state.inbox.filter((item) => item.agentId !== agentId && !ids.has(item.conversationId ?? ""));
@@ -505,6 +514,34 @@ var FileFoundryDataAdapter = class {
505
514
  listEvents() {
506
515
  return effect(async () => structuredClone((await this.snapshot()).events));
507
516
  }
517
+ claimScheduleOccurrence(occurrence) {
518
+ return effect(async () => {
519
+ assertScheduleOccurrence(occurrence);
520
+ await this.ensureInitialized();
521
+ return this.mutate((state) => {
522
+ if (state.occurrences.some((item) => item.id === occurrence.id)) return false;
523
+ state.occurrences.push(structuredClone(occurrence));
524
+ return true;
525
+ });
526
+ });
527
+ }
528
+ putScheduleOccurrence(occurrence) {
529
+ return effect(async () => {
530
+ assertScheduleOccurrence(occurrence);
531
+ await this.ensureInitialized();
532
+ await this.mutate((state) => {
533
+ replaceById(state.occurrences, occurrence);
534
+ const drop = new Set(prunableOccurrences(state.occurrences, occurrence.activationId));
535
+ if (drop.size) state.occurrences = state.occurrences.filter((item) => !drop.has(item.id));
536
+ });
537
+ });
538
+ }
539
+ getScheduleOccurrence(id) {
540
+ return effect(async () => structuredClone((await this.snapshot()).occurrences.find((item) => item.id === id) ?? null));
541
+ }
542
+ listScheduleOccurrences(filter) {
543
+ return effect(async () => structuredClone((await this.snapshot()).occurrences.filter((item) => matchesOccurrenceFilter(item, filter)).sort(compareOccurrences)));
544
+ }
508
545
  putPendingInbound(record) {
509
546
  return effect(async () => {
510
547
  await this.ensureInitialized();
@@ -912,6 +949,7 @@ export {
912
949
  TopologyConflict,
913
950
  TopologyStore,
914
951
  TransmissionId,
952
+ activationScheduleRevision,
915
953
  compileApplicationManifest,
916
954
  composeAgent,
917
955
  composePlaybook,
@@ -991,6 +1029,7 @@ export {
991
1029
  restrictApp,
992
1030
  routeFromAgentFile,
993
1031
  routeFromInternalAgentName,
1032
+ scheduleOccurrenceId,
994
1033
  serializeInboundTransmissionXml,
995
1034
  toGloveMessage,
996
1035
  toGloveRequestInput,
package/dist/voice.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IGloveRunnable } from 'glove-core';
2
2
  import { RealtimeAgent, RealtimeAgentConfig } from 'glove-voice-s2s';
3
- import { A as AgentHandlerContext, F as FoundryDelegationUpdate, a as FoundryMeshMessage } from './event-delivery-CNCsVqi8.js';
3
+ import { A as AgentHandlerContext, F as FoundryDelegationUpdate, a as FoundryMeshMessage } from './event-delivery-a9B1Qq_u.js';
4
4
  import 'effect';
5
5
  import 'zod';
6
6
  import 'glove-mesh';
@@ -173,6 +173,24 @@ The controller owns wake/defer deadlines and conversation admission. A live proc
173
173
 
174
174
  A successful execution result carries consumed-event receipts. The controller reconciles those receipts before replaying unfinished delivery on startup. A crash can repeat work between a side effect and acknowledgment, so delivery is at least once and effects should use event IDs for idempotency. Archival retains pending events; worker purge removes the owned journal and deduplication records. See [durable subagents](./durable-subagents.md) for authoring, policy, permissions and lifecycle details.
175
175
 
176
+ ## Schedule occurrences
177
+
178
+ The controller owns every timer: one-shot schedules, sleeps and recurring schedules. Station's scheduler is not used, so no schedule state lives in the execution daemon. An activation persists `nextOccurrenceAt`, the scheduled time of the next occurrence it owes, together with `scheduleRevision`, a hash of the configuration that cursor belongs to (target, message, payload, timing). Status and timestamp writes never change the revision.
179
+
180
+ When the cursor comes due, under the activation lock, the controller:
181
+
182
+ 1. builds the occurrence: id `occurrence_<sha256(activationId, revision, scheduledFor)>`, the request with `source.occurrenceId` and `source.scheduledFor`, status `pending` (or `skipped` under `misfire: "skip"`);
183
+ 2. claims it with `claimScheduleOccurrence`, an insert-if-absent;
184
+ 3. only then writes the activation with the cursor moved to the next occurrence (journal first: a crash before this step fires the same id again, and the claim deduplicates it);
185
+ 4. admits it to the conversation gate like any other message and records `accepted` with the run id;
186
+ 5. when that run settles, records `completed`, `failed` or `cancelled`.
187
+
188
+ On startup the controller first hands over every `pending` or `accepted` occurrence whose activation is still active under the same revision (others become `cancelled` with reason `paused`, `cancelled` or `superseded`), then re-arms activations from their stored cursor. A crash after a run's side effect but before its outcome is stored delivers the occurrence again with the same id, so delivery is at least once and effects should key on `source.occurrenceId`. A run stopped by a clean shutdown is not an outcome either: the next start delivers its occurrence again.
189
+
190
+ Pause, cancel and update cancel the activation's `pending` occurrences under the same lock that fires them, so a stale configuration never fires after it was replaced; an `accepted` recurring run finishes, and a one-shot's run is cancelled with it. Resume starts the cursor again from now.
191
+
192
+ The bundled adapters keep every open occurrence and the latest 100 terminal ones per activation. A data adapter without the occurrence methods gets an in-memory journal: occurrences are visible while the process runs but a crash can lose one.
193
+
176
194
  ## Working environment and REPL boundary
177
195
 
178
196
  Foundry owns contextual selection, mounting, lifecycle, and observability. The native packages retain their own semantics:
@@ -758,7 +758,7 @@ glove_foundry_schedules({ action: "resume", activationId })
758
758
  glove_foundry_schedules({ action: "cancel", activationId })
759
759
  ```
760
760
 
761
- Schedules are agent-local composable values; Foundry has no root schedule registry or automatically discovered schedule files. Immediate spawning, future activation, recurrence, management, and suspension are separate runtime operations. Pausing disarms a trigger without losing its message, timing, payload, ownership, or definition provenance; edits made while paused remain paused until an explicit resume. Foundry stores activation state through `FoundryDataAdapter` before arming its private execution backend, so a durable adapter can reconstruct active work—and keep paused work disarmed—on startup. Sleep preserves the instance and conversation so the wake-up resumes with the same stored context.
761
+ Schedules are agent-local composable values; Foundry has no root schedule registry or automatically discovered schedule files. Immediate spawning, future activation, recurrence, management, and suspension are separate runtime operations. Pausing disarms a trigger without losing its message, timing, payload, ownership, or definition provenance; edits made while paused remain paused until an explicit resume. Foundry stores activation state through `FoundryDataAdapter` before arming it, so a durable adapter can reconstruct active work—and keep paused work disarmed—on startup. Each due occurrence is stored before the activation's cursor moves past it, so a crash between coming due and running never loses it; see [schedule occurrences](./architecture.md#schedule-occurrences). Sleep preserves the instance and conversation so the wake-up resumes with the same stored context.
762
762
 
763
763
  Schedule management reloads the owning instance's persisted activations on each
764
764
  tool call and overlays the current run's pending commands. A recurring run can
package/docs/inspector.md CHANGED
@@ -5,8 +5,53 @@ The development server includes a runtime inspector. Most pages follow Foundry's
5
5
  - **Network** lists every model request and tool call.
6
6
  - **Console** is the run's log.
7
7
  - **Context** shows what the agent had to work with.
8
+ - **Composition** shows what Foundry assembled the agent from, and which app or feature each tool came from.
9
+ - **Queues** lists everything that crossed the run's boundary, in and out.
10
+ - **Call chain** shows the runs this one came from and the runs it started.
8
11
  - **Summary** gives the outcome.
9
12
 
13
+ ## Running it
14
+
15
+ The inspector is part of the Foundry server. Start your app with:
16
+
17
+ ```bash
18
+ pnpm glove foundry dev
19
+ ```
20
+
21
+ It prints the inspector's address (the port is `server.port` in `foundry.config.ts`). Open **Chat** to send a message, or **New run** from any page; each opens or links to its run. On a run, `1`–`7` switch between the views.
22
+
23
+ ### Try it without an API key
24
+
25
+ Two examples run offline on scripted models, so every view has something to show. From the repository root, build the examples' packages, then install again so pnpm links the `glove` command (it can only link it once `glove-foundry` is built):
26
+
27
+ ```bash
28
+ pnpm install
29
+ pnpm --filter "glove-foundry-layered-assistant^..." --filter "glove-foundry-example^..." build
30
+ pnpm install
31
+ ```
32
+
33
+ **A delegation across four runs** ([layered assistant](../../../examples/foundry-layered-assistant)):
34
+
35
+ ```bash
36
+ pnpm --filter glove-foundry-layered-assistant dev
37
+ ```
38
+
39
+ Open http://127.0.0.1:4142, then **Chat**, Maya's chat, and send `Write me a slugify function, please.` Without `ANTHROPIC_API_KEY` each agent runs a scripted model. The assistant delegates to a coder, the coder asks which language, the assistant answers, and the coder reports back: four runs. Open **Runs** and look at:
40
+
41
+ - the assistant's first run: **Call chain** (delegated, asked, replied, reported back) and **Queues** (the delegation it sent, and the coder's run it started);
42
+ - the coder's run: **Queues** (the task that started it, its question, and the answer handed to it while it ran);
43
+ - any run: **Composition** (the delegates and the tools each step added).
44
+
45
+ **Apps, MCP, a working environment, schedules and playbooks** ([reference app](../../../examples/foundry-agent)):
46
+
47
+ ```bash
48
+ pnpm --filter glove-foundry-example dev
49
+ ```
50
+
51
+ Open http://127.0.0.1:4242 and start a run of `release-planner` with **New run**. Without `OPENROUTER_API_KEY` it runs a deterministic model. **Composition** lists 47 tools under the steps and installations that added them, plus the playbooks and schedules it loaded.
52
+
53
+ For the waterfall and Timing panes you need a model with real latency: set the example's key, or run your own app.
54
+
10
55
  ## Navigation
11
56
 
12
57
  | Page | Question it answers |
@@ -40,9 +85,9 @@ The inspector and APIs share one authorization boundary:
40
85
 
41
86
  ## Following a run
42
87
 
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:
88
+ 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 seven views:
44
89
 
45
- - Switch between them with `1`–`4`.
90
+ - Switch between them with `1`–`7`.
46
91
  - The view, the open request and its pane are all in the URL, so a link opens someone else on the same step.
47
92
 
48
93
  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.
@@ -51,6 +96,8 @@ The screenshots below are runs of Meta Muse, the [personal agent example](../../
51
96
 
52
97
  ![The Network view: each model request and tool call of a run, with type, status, initiator, size, time and a waterfall](../../site/public/foundry/inspector/network.webp)
53
98
 
99
+ ![A tool call's Timing pane: queued behind an earlier call, checked, then run. The researcher subagent's requests and tool call sit indented under it](../../site/public/foundry/inspector/network-timing.webp)
100
+
54
101
  In this run Muse tries to book a restaurant:
55
102
 
56
103
  1. The Sentinel blocks a site Rosa hasn't allowed (the first red row).
@@ -59,7 +106,7 @@ In this run Muse tries to book a restaurant:
59
106
  4. Midway, at #5, Glove compacts the conversation.
60
107
  5. The calls a REPL program makes sit under the `execute_js` call that ran them.
61
108
 
62
- Each row is one model request (a square), one tool call (a circle), or a subagent. The columns:
109
+ Each row is one model request (a square), one tool call (a circle), or a subagent. A subagent's own requests and tool calls sit indented under it. When a run has more than one turn (it resumed after an approval, or events woke it), a divider marks where each turn began and how it ended. The columns:
63
110
 
64
111
  | Column | Meaning |
65
112
  | --- | --- |
@@ -68,7 +115,7 @@ Each row is one model request (a square), one tool call (a circle), or a subagen
68
115
  | Status | `ok`, `error`, `aborted`, `denied`, `pending`, or `approval` while a person hasn't decided. |
69
116
  | 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
117
  | 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. |
118
+ | Time and Waterfall | How long it took, and when, across the whole run. A model request's bar is light until its first token and solid while it streams. A tool call's bar is light while its permission is checked (or a person decides) and solid while it runs; a thin line before it is the time it waited behind the calls ahead of it in the same step. |
72
119
 
73
120
  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
121
 
@@ -82,6 +129,7 @@ Click a row, or walk them with `j` and `k`, to open it beside the list. `Esc` cl
82
129
  | 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
130
  | Tools | Each tool the model was offered, with its description and input schema. |
84
131
  | Response | What the model sent back, its stop reason and tokens, or the error that ended the request. |
132
+ | Timing | Like DevTools' Timing tab: waiting for the first token, then streaming, with the text it streamed. |
85
133
  | Raw | The recorded events. |
86
134
 
87
135
  **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.
@@ -95,6 +143,7 @@ A tool call has these panes:
95
143
  - **Overview**: call id, duration, the request that made it, and its approval (who decided, and when).
96
144
  - **Input**: what the model passed.
97
145
  - **Result**: status, message and data. JSON held inside a string opens as a tree.
146
+ - **Timing**: when the model asked for the call, how long it was queued behind earlier calls, how long its permission check or approval took, and how long it ran.
98
147
  - **Raw**: the recorded events.
99
148
 
100
149
  ![A tool call that needed approval, open beside the list](../../site/public/foundry/inspector/tool-call.webp)
@@ -106,7 +155,8 @@ A tool call has these panes:
106
155
  The run as a log, one line per event:
107
156
 
108
157
  - **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.
158
+ - **Streamed text.** A streamed reply is one line per request, not one line per chunk, even when a subagent streams in between.
159
+ - **Turns and arrivals.** Lines mark each turn starting and how it ended (finished, failed, aborted, or suspended at an approval), events arriving and when they joined the conversation, and resolved inbox items joining it.
110
160
  - **Filters.** Filter by text and by source (`run`, `model`, `tool`, `stdout`, `stderr`, `assembly`, …).
111
161
  - **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
162
  - **Live runs.** While the run is live, the console stays at the bottom unless you have scrolled up.
@@ -124,6 +174,45 @@ Like DevTools' Application panel, a tree on the left and the selected item on th
124
174
  | Agent | The instance's stored context, installations and playbooks, with links to the instance, workspace and conversation. |
125
175
  | 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
176
 
177
+ ### Composition
178
+
179
+ ![The Composition view: each tool the agent had, grouped under the assembly step that added it](../../site/public/foundry/inspector/composition.webp)
180
+
181
+ What Foundry assembled the run's agent from, like DevTools' Sources panel. A tree on the left, the selected item on the right:
182
+
183
+ | Item | What it shows |
184
+ | --- | --- |
185
+ | Timeline | Each definition field resolving, then each assembly step (Foundry core tools, app transmissions, the definition's tools, delegation, mesh, working environment, guidance, calls, layers and subscribers, each installation, MCP servers, memory, `configure()`, the REPL, `build()`), with how long it took. |
186
+ | Tools by origin | Each tool the agent had, under the step that added it, with how many times it was called. Click a tool to see its calls in Network. |
187
+ | Apps and installations | What the instance has installed and the tools each installation gave this run; an app's tools that change things are marked. |
188
+ | Working environment and REPL | What the working environment and REPL mounted. |
189
+ | Playbooks | The playbooks the definition composed and the ones stored on the instance. |
190
+ | Schedules | The definition's schedules, the schedules and sleeps this run created, and the instance's activations with their next and last runs. |
191
+ | Delegates and workers | The agents this one can hand work to, its durable subagents, and, for a worker, the delegation it works on. |
192
+ | Mesh | Whether the hosted mesh or your own transport is mounted, and the open threads. |
193
+ | Memory, layers and subscribers; Hooks, skills, subagents and calls | The rest of the definition. |
194
+
195
+ A run records its assembly as one `foundry.assembly.composed` event, just before its first turn. It compares the agent's tools before and after each step, so every tool is listed under the step that folded it.
196
+
197
+ ### Queues
198
+
199
+ ![The Queues view: the delegated task that started a worker's run, its question to the delegator, and the answer handed to it while it ran](../../site/public/foundry/inspector/queues.webp)
200
+
201
+ Everything that crossed the run's boundary, like the Messages pane of a WebSocket in DevTools: one row per message, inbound (↓) or outbound (↑).
202
+
203
+ - **Inbound**: what started the run (a message, a transmission, a delegated task or result, a schedule or sleep firing, a spawn); events that arrived while it ran (transmission follow-ups, delegation updates, agent and mesh messages, approval decisions); deliveries handed to it live; and resolved inbox items.
204
+ - **Outbound**: transmissions, delegations and replies, questions to the delegator, agent and mesh messages, spawns, background runs, schedules and sleeps, inbox items posted, and approvals asked for.
205
+
206
+ **Status** follows each row: an event is queued, deferred, woke the agent or was dropped, then joined the conversation as the turn's message, before a request, or between tool steps. A command is sent, then accepted, delivered, scheduled or started. **Reached** is, for an inbound row, the model request that first saw it, and for an outbound one, the run it started. Click a row for its detail and the events behind it.
207
+
208
+ ### Call chain
209
+
210
+ ![The Call chain view: an assistant run delegates to a coder; the coder asks a question, the assistant's next run answers it, and the coder reports back](../../site/public/foundry/inspector/call-chain.webp)
211
+
212
+ The runs this one came from and the runs it started, like DevTools' initiator chain across runs. Above the run: what started its chain (a transmission, a schedule) and each run that led to it. Below: what it started, as a tree. The edges say how: delegated to a worker, the worker asked, the answer replied, the worker reported back, spawned, scheduled, woke from sleep, steered. Each run links to its own Call chain.
213
+
214
+ The chain is read from the runtime's retained events (`delegation.started`, `delegation.replied`, `core.command.accepted`, `run.steered` and the commands runs sent), so runs older than what the runtime keeps show as *not retained*.
215
+
127
216
  ### Summary
128
217
 
129
218
  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.
@@ -149,6 +238,18 @@ export default defineConfig({ observability: { modelRequests: false } });
149
238
 
150
239
  Runs recorded before this, or with model requests off, still list their tool calls, model responses and log.
151
240
 
241
+ ### What else a run records
242
+
243
+ The run's subscriber also records these Glove events, and the views above read them:
244
+
245
+ - `turn_start` and `turn_end` bracket each turn: a request, events waking the agent, or a resumed tool step, with how it ended.
246
+ - `tool_use_start` marks when a tool call starts running, after the calls ahead of it and its permission check. `tool_use` marks when the model asked for it.
247
+ - Streamed text and tool calls carry the `request_id` of the request they came from, which gives each request's time to first token.
248
+ - `subagent_invoked` and `subagent_completed` name the tool call that ran the subagent.
249
+ - `event_received` previews what arrived, and `inbox_injected` reports resolved inbox items joining the conversation.
250
+
251
+ Runs recorded before these events show a single bar per row and no turns.
252
+
152
253
  ## Talking to an agent
153
254
 
154
255
  **Chat** is a browser conversation client, not a second transcript system. Select a
@@ -206,17 +307,99 @@ Press `Command-K` or `Control-K` to search pages, definitions, instances, and re
206
307
  | Key | Action |
207
308
  | --- | --- |
208
309
  | `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 |
310
+ | `1`–`7` | On a run: Summary, Network, Console, Context, Composition, Queues, Call chain |
210
311
  | `Enter` or `o` | Open the highlighted row |
211
312
  | `/` | Focus the filter (runs, Network, Console), or open search elsewhere |
212
313
  | `c` | Start a run |
213
314
  | `r` | Refresh runtime data |
214
315
  | `Command-K` / `Control-K` | Search |
215
- | `Escape` | Close the drawer or search; on a run, close the open request, or leave a filter box |
316
+ | `Escape` | Close the drawer or search; on a run, close the open request or message, or leave a filter box |
216
317
  | `Command-Enter` | Submit the run drawer |
217
318
 
218
319
  Every truncated identifier in the inspector has a copy button, so the full run, instance, or conversation id is always retrievable.
219
320
 
321
+ ## Testing with it
322
+
323
+ ### Assert on what a run recorded
324
+
325
+ Everything the views show comes from the run's recorded events, so a test can read the same events. This passes against the layered assistant, offline:
326
+
327
+ ```ts
328
+ import assert from "node:assert/strict";
329
+
330
+ const run = await runtime.send("maya", "maya-chat", "Write me a slugify function, please.");
331
+ await runtime.waitForRun(run.id, { timeoutMs: 60_000 });
332
+ const events = runtime.observability.list({ runId: run.id });
333
+ const of = (type: string) => events.filter((event) => event.type === `agent.${type}`).map((event) => event.data as any);
334
+
335
+ // What Foundry assembled, and which step added each tool.
336
+ const [composed] = of("foundry.assembly.composed");
337
+ const attributed = new Set(composed.steps.flatMap((step: { tools: string[] }) => step.tools));
338
+ assert.deepEqual(composed.tools.filter((name: string) => !attributed.has(name)), []);
339
+ assert.ok(composed.delegates.some((delegate: { agent: string }) => delegate.agent === "coder"));
340
+
341
+ // How the turn ended, and the tool call that delegated.
342
+ assert.equal(of("turn_end").at(-1).status, "success");
343
+ assert.ok(of("tool_use_start").some((call) => call.name === "glove_foundry_delegate"));
344
+
345
+ // The delegation it started, recorded by the runtime under this run.
346
+ const started = events.find((event) => event.type === "delegation.started");
347
+ assert.equal((started?.data as { to: string }).to, "coder");
348
+ ```
349
+
350
+ Agent events are prefixed `agent.`. The runtime's own events about a run (`delegation.started`, `core.command.accepted`, `transmission.outbound.delivered`, `run.steered`) aren't. Over HTTP, the same list is `GET /api/runs/:id/events`.
351
+
352
+ ### Read the same events in your own subscriber
353
+
354
+ The Glove events the inspector reads reach any subscriber, with or without Foundry. This one logs each turn, each request's time to first token, and how long each tool call waited before it ran:
355
+
356
+ ```ts
357
+ import type { SubscriberAdapter } from "glove-core";
358
+
359
+ const sentAt = new Map<string, number>(); // request_id → when it was sent
360
+ const askedAt = new Map<string, number>(); // call id → when the model asked for it
361
+
362
+ export const timings: SubscriberAdapter = {
363
+ modelRequests: true, // also receive model_request and model_request_end
364
+ async record(type, data: any) {
365
+ const now = Date.now();
366
+ if (type === "turn_start") console.log(`turn (${data.trigger}) started`);
367
+ if (type === "turn_end") console.log(`turn ${data.status} after ${data.duration_ms}ms`);
368
+ if (type === "model_request") sentAt.set(data.request_id, now);
369
+ if ((type === "text_delta" || type === "tool_use") && sentAt.has(data.request_id)) {
370
+ console.log(`first token after ${now - sentAt.get(data.request_id)!}ms`);
371
+ sentAt.delete(data.request_id);
372
+ }
373
+ if (type === "tool_use") askedAt.set(data.id, now);
374
+ if (type === "tool_use_start") console.log(`${data.name} started ${now - (askedAt.get(data.id) ?? now)}ms after the model asked`);
375
+ if (type === "tool_use_result") console.log(`${data.name} ${data.result.status} after ${data.duration_ms}ms`);
376
+ },
377
+ };
378
+ ```
379
+
380
+ Add it with `glove.addSubscriber(timings)`, or list it in a Foundry definition's `subscribers`.
381
+
382
+ ### Test the inspector itself
383
+
384
+ The views are built by plain functions over `/api/runs/:id/events`: `buildRunTrace` and `buildConsole` in `src/dashboard-trace.ts`, and `buildComposition`, `buildQueues` and `buildRunChain` in `src/dashboard-foundry.ts`. Their tests evaluate the same source the browser runs:
385
+
386
+ ```ts
387
+ import { DASHBOARD_TRACE_SCRIPT } from "../src/dashboard-trace.js";
388
+ import { DASHBOARD_FOUNDRY_SCRIPT } from "../src/dashboard-foundry.js";
389
+
390
+ const kit = new Function(`${DASHBOARD_TRACE_SCRIPT}\n${DASHBOARD_FOUNDRY_SCRIPT}; return { buildRunTrace, buildQueues };`)();
391
+ const rows = kit.buildQueues(events, run, kit.buildRunTrace(events, run));
392
+ ```
393
+
394
+ Run them, then the integration test that checks a real run's assembly is fully attributed:
395
+
396
+ ```bash
397
+ pnpm --filter glove-foundry exec node --test --import tsx tests/dashboard-trace.test.ts tests/dashboard-foundry.test.ts
398
+ pnpm --filter glove-foundry exec node --test --import tsx tests/integration.test.ts
399
+ ```
400
+
401
+ `pnpm --filter glove-core test` covers the events themselves (`tests/observability-events.test.ts`).
402
+
220
403
  ## Operator API used by the inspector
221
404
 
222
405
  The inspector is an API client and adds no hidden runtime state. Its primary read surfaces are:
@@ -227,6 +410,7 @@ The inspector is an API client and adds no hidden runtime state. Its primary rea
227
410
  - `PATCH /api/conversations/:id` for an instance-owned title or context update
228
411
  - `/api/runs`, `/api/runs/:id`, and `/api/events`
229
412
  - `/api/runs/:id/events`, with `?after=<sequence>` for only what's new, for one run's trace
413
+ - `/api/events?category=system`, for the runs a run started or came from (Call chain)
230
414
  - `/api/activations` and `/api/playbook-subscriptions`
231
415
  - `/api/application-connections`
232
416
  - `/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.8.0",
3
+ "version": "0.10.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,15 +77,15 @@
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.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",
80
+ "glove-core": "4.8.0",
81
+ "glove-js": "0.5.7",
82
+ "glove-mcp": "1.2.7",
83
+ "glove-facts": "0.1.9",
84
+ "glove-lisp": "0.5.7",
85
+ "glove-memory": "2.3.4",
86
+ "glove-mesh": "0.2.4",
87
+ "glove-python": "0.4.7",
88
+ "glove-voice-s2s": "0.4.7",
89
89
  "glove-working-environment": "0.7.0"
90
90
  },
91
91
  "devDependencies": {