@botiverse/oar 0.1.4 → 0.2.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 +20 -7
- package/dist/contracts/records.d.ts +74 -19
- package/dist/contracts/records.d.ts.map +1 -1
- package/dist/contracts/records.js +11 -2
- package/dist/contracts/records.js.map +1 -1
- package/dist/contracts/session.d.ts +33 -7
- package/dist/contracts/session.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/observe/agent-status.d.ts +3 -3
- package/dist/observe/agent-status.d.ts.map +1 -1
- package/dist/observe/agent-status.js +9 -9
- package/dist/observe/agent-status.js.map +1 -1
- package/dist/observe/events.d.ts +29 -0
- package/dist/observe/events.d.ts.map +1 -0
- package/dist/observe/events.js +134 -0
- package/dist/observe/events.js.map +1 -0
- package/dist/observe/index.d.ts +2 -2
- package/dist/observe/index.d.ts.map +1 -1
- package/dist/observe/index.js +2 -2
- package/dist/observe/index.js.map +1 -1
- package/dist/observe/observe-agent.js +1 -1
- package/dist/observe/stall-observer.d.ts +1 -1
- package/dist/observe/stall-observer.d.ts.map +1 -1
- package/dist/observe/stall-observer.js +3 -3
- package/dist/observe/stall-observer.js.map +1 -1
- package/dist/observe/tool-activity.d.ts +2 -2
- package/dist/observe/tool-activity.d.ts.map +1 -1
- package/dist/observe/tool-activity.js +1 -1
- package/dist/observe/tool-activity.js.map +1 -1
- package/dist/observe/turns.d.ts +3 -3
- package/dist/observe/turns.d.ts.map +1 -1
- package/dist/observe/turns.js +4 -4
- package/dist/observe/turns.js.map +1 -1
- package/dist/observe/usage.d.ts +4 -4
- package/dist/observe/usage.d.ts.map +1 -1
- package/dist/observe/usage.js +12 -12
- package/dist/observe/usage.js.map +1 -1
- package/dist/runtimes/claude/projection.d.ts +6 -6
- package/dist/runtimes/claude/projection.js +10 -10
- package/dist/runtimes/claude/projection.js.map +1 -1
- package/dist/runtimes/claude/session.js +6 -6
- package/dist/runtimes/claude/session.js.map +1 -1
- package/dist/runtimes/codex/projection.d.ts +3 -3
- package/dist/runtimes/codex/projection.js +3 -3
- package/dist/runtimes/codex/projection.js.map +1 -1
- package/dist/runtimes/codex/session.js +8 -8
- package/dist/runtimes/codex/session.js.map +1 -1
- package/dist/runtimes/pi/projection.d.ts +7 -7
- package/dist/runtimes/pi/projection.js +24 -24
- package/dist/runtimes/pi/projection.js.map +1 -1
- package/dist/runtimes/pi/session.js +11 -11
- package/dist/runtimes/pi/session.js.map +1 -1
- package/dist/shared/acp/model.d.ts +1 -1
- package/dist/shared/acp/model.js +1 -1
- package/dist/shared/acp/profile.d.ts +1 -1
- package/dist/shared/acp/projection.d.ts +6 -6
- package/dist/shared/acp/projection.d.ts.map +1 -1
- package/dist/shared/acp/projection.js +12 -12
- package/dist/shared/acp/projection.js.map +1 -1
- package/dist/shared/acp/records.d.ts +2 -2
- package/dist/shared/acp/records.d.ts.map +1 -1
- package/dist/shared/acp/records.js +5 -5
- package/dist/shared/acp/records.js.map +1 -1
- package/dist/shared/acp/session.js +1 -1
- package/dist/shared/acp/turns.d.ts +2 -2
- package/dist/shared/acp/turns.js +4 -4
- package/dist/shared/acp/turns.js.map +1 -1
- package/dist/shared/acp/usage-wait.d.ts +1 -1
- package/dist/shared/acp/usage-wait.d.ts.map +1 -1
- package/dist/shared/seal-session.d.ts +4 -3
- package/dist/shared/seal-session.d.ts.map +1 -1
- package/dist/shared/seal-session.js +12 -3
- package/dist/shared/seal-session.js.map +1 -1
- package/dist/shared/session-kernel.d.ts +6 -6
- package/dist/shared/session-kernel.d.ts.map +1 -1
- package/dist/shared/session-kernel.js +2 -2
- package/dist/shared/session-kernel.js.map +1 -1
- package/dist/voyage.d.ts +4 -4
- package/dist/voyage.d.ts.map +1 -1
- package/dist/voyage.js +4 -3
- package/dist/voyage.js.map +1 -1
- package/package.json +1 -1
- package/dist/observe/aggregate-events.d.ts +0 -16
- package/dist/observe/aggregate-events.d.ts.map +0 -1
- package/dist/observe/aggregate-events.js +0 -80
- package/dist/observe/aggregate-events.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,28 +3,41 @@
|
|
|
3
3
|
Provider-independent TypeScript contracts and built-in implementations for controlling and observing Claude, Codex, Grok, Kimi, and Pi.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import { runtimes } from "@botiverse/oar";
|
|
6
|
+
import { promptAndWait, runtimes } from "@botiverse/oar";
|
|
7
7
|
|
|
8
8
|
const runtime = runtimes.require("grok");
|
|
9
9
|
const installation = await runtime.installation?.();
|
|
10
10
|
|
|
11
11
|
if (installation?.kind === "available") {
|
|
12
12
|
const session = await runtime.session(installation, { cwd: process.cwd() });
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
session.events((event) => {
|
|
14
|
+
switch (event.kind) {
|
|
15
|
+
case "text_delta": process.stdout.write(event.text); break;
|
|
16
|
+
case "tool_call_started": console.log(`[${event.tool}]`); break;
|
|
17
|
+
case "turn_ended": console.log(event.outcome.kind); break;
|
|
18
|
+
}
|
|
19
|
+
}, { coalesceText: true });
|
|
20
|
+
const run = await promptAndWait(session, "Inspect this repository");
|
|
21
|
+
console.log(run.kind === "ended" ? run.outcome : run.reason);
|
|
22
|
+
console.log(session.usage(), await runtime.accountUsage?.(installation));
|
|
18
23
|
await session.dispose();
|
|
19
24
|
}
|
|
20
25
|
```
|
|
21
26
|
|
|
27
|
+
`session.events()` delivers flat, attributed `Event`s (text, reasoning,
|
|
28
|
+
tool calls, turn start and end, usage, model, control rejections, the
|
|
29
|
+
process exit), each carrying the `seq` and `agentPath` of the record it was
|
|
30
|
+
read from. It is a projection over the record stream: `session.rawEvents()`
|
|
31
|
+
and `session.records()` expose that stream (`RawEvent`: `Frame` with the
|
|
32
|
+
native payload verbatim, `RequestRecord`, `ResponseRecord`) for consumers
|
|
33
|
+
who need the runtime's own frames.
|
|
34
|
+
|
|
22
35
|
## Public exports
|
|
23
36
|
|
|
24
37
|
The package has exactly two public entry points:
|
|
25
38
|
|
|
26
39
|
- `@botiverse/oar`: the full surface (runtime registry, adapters, and everything below). Node-only (adapters import `node:child_process` and runtime SDKs).
|
|
27
|
-
- `@botiverse/oar/observe`: browser-safe subset, the pure derivation utilities over `
|
|
40
|
+
- `@botiverse/oar/observe`: browser-safe subset, the pure derivation utilities over `RawEvent`s and `Event`s (`eventsOf`, `coalesceText`, `observeAgent`, `reduceStatus`, `observeStalls`, `classifyTool`, …) with zero Node and zero adapter imports. A browser or Electron-renderer bundle can import this subpath directly without dragging Node-only modules in. The root export re-exports the same utilities for Node consumers.
|
|
28
41
|
|
|
29
42
|
Any other deep import (`@botiverse/oar/dist/...`, source paths) is internal and may break without notice.
|
|
30
43
|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The record stream
|
|
3
|
-
*
|
|
2
|
+
* The record stream and the events read off it. Three words, three layers:
|
|
3
|
+
*
|
|
4
|
+
* - `Event`: the consumer face. One flat, attributed fact (text, a tool
|
|
5
|
+
* call, a turn end, a process exit …). What `Session.events()` delivers.
|
|
6
|
+
* - `RawEvent`: one record of the underlying stream, three kinds by
|
|
7
|
+
* obligation: `Frame` (the runtime's own words), `RequestRecord` (an
|
|
8
|
+
* action expecting an outcome), `ResponseRecord` (points at a request).
|
|
9
|
+
* What `Session.rawEvents()` / `records()` deliver.
|
|
10
|
+
* - `Frame`: a RawEvent carrying one runtime frame verbatim (`type`,
|
|
11
|
+
* `native`) plus the events oar read out of it.
|
|
12
|
+
*
|
|
4
13
|
* Semantics live in docs/spec; the session control surface that produces
|
|
5
14
|
* these records is in ./session.ts.
|
|
6
15
|
*/
|
|
@@ -21,11 +30,11 @@ export interface RecordEnvelope {
|
|
|
21
30
|
/** Unix epoch milliseconds stamped at adapter ingress: same clock as Date.now(), so fold×clock consumers (stallOf) compose directly. */
|
|
22
31
|
readonly receivedAt: number;
|
|
23
32
|
}
|
|
24
|
-
export type RecordKind = "
|
|
25
|
-
/** The runtime's own words. oar never synthesizes
|
|
26
|
-
export interface
|
|
27
|
-
readonly kind: "
|
|
28
|
-
readonly body:
|
|
33
|
+
export type RecordKind = "frame" | "request" | "response";
|
|
34
|
+
/** The runtime's own words. oar never synthesizes a frame and never drops one: whatever the runtime said enters the stream, even after a span ended. */
|
|
35
|
+
export interface Frame extends RecordEnvelope {
|
|
36
|
+
readonly kind: "frame";
|
|
37
|
+
readonly body: FrameBody;
|
|
29
38
|
}
|
|
30
39
|
export type RequestDirection = "toRuntime" | "toApp";
|
|
31
40
|
/** An action record that expects an outcome. `toRuntime`: prompt / steer / queue / abort / dispose, issued through this Session. `toApp`: the runtime asking the application something (approval, question, external tool), body verbatim. */
|
|
@@ -41,23 +50,24 @@ export interface ResponseRecord extends RecordEnvelope {
|
|
|
41
50
|
readonly requestId: string;
|
|
42
51
|
readonly body: ResponseBody;
|
|
43
52
|
}
|
|
44
|
-
|
|
53
|
+
/** One record of the stream. */
|
|
54
|
+
export type RawEvent = Frame | RequestRecord | ResponseRecord;
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
47
|
-
* of it. `native` is the source of truth; `
|
|
56
|
+
* A frame body carries the runtime's frame verbatim plus oar's typed reading
|
|
57
|
+
* of it. `native` is the source of truth; `events` is a projection for
|
|
48
58
|
* consumers that want the cross-runtime vocabulary without parsing five wire
|
|
49
59
|
* formats. One frame is one record: a claude assistant message with a
|
|
50
|
-
* thinking block, a text block and a tool_use block is ONE
|
|
51
|
-
*
|
|
52
|
-
* enters the stream, with `type` and `native` and no
|
|
60
|
+
* thinking block, a text block and a tool_use block is ONE frame with three
|
|
61
|
+
* events, in the frame's own order. A frame oar does not interpret still
|
|
62
|
+
* enters the stream, with `type` and `native` and no events.
|
|
53
63
|
*/
|
|
54
|
-
export interface
|
|
64
|
+
export interface FrameBody {
|
|
55
65
|
/** Runtime-native discriminator: claude `type[/subtype]`, codex notification method, pi event type, ACP `sessionUpdate`. */
|
|
56
66
|
readonly type: string;
|
|
57
67
|
/** The frame as the runtime sent it (JSON-safe). Never trimmed, never re-shaped. */
|
|
58
68
|
readonly native: unknown;
|
|
59
|
-
/** oar
|
|
60
|
-
readonly
|
|
69
|
+
/** What oar read out of the frame, in frame order; empty when oar read nothing. Only runtime-said kinds appear here. */
|
|
70
|
+
readonly events: readonly RuntimeEventBody[];
|
|
61
71
|
}
|
|
62
72
|
export type ReasoningContent = {
|
|
63
73
|
readonly kind: "text";
|
|
@@ -75,15 +85,21 @@ export interface TokenTotals {
|
|
|
75
85
|
/**
|
|
76
86
|
* What a usage-bearing frame says. `context` is current context fullness as
|
|
77
87
|
* the runtime reports it; `tokens` is the runtime's running total for this
|
|
78
|
-
* record's `agentPath`, already resolved by the adapter (which runtime
|
|
79
|
-
* authoritative and how overlapping
|
|
88
|
+
* record's `agentPath`, already resolved by the adapter (which runtime figure is
|
|
89
|
+
* authoritative and how overlapping events deduplicate never crosses this
|
|
80
90
|
* surface; see docs/spec/attribution.md, "usage: one constraint").
|
|
81
91
|
*/
|
|
82
92
|
export interface UsageReport {
|
|
83
93
|
readonly context?: ContextUsage;
|
|
84
94
|
readonly tokens?: TokenTotals;
|
|
85
95
|
}
|
|
86
|
-
|
|
96
|
+
/**
|
|
97
|
+
* The runtime-said event kinds: what a Frame can carry. `text_delta` is at
|
|
98
|
+
* the granularity the runtime emits (claude: a whole text block per frame;
|
|
99
|
+
* pi and codex: token-sized pieces); `Session.events({ coalesceText })`
|
|
100
|
+
* merges consecutive pieces for consumers who want blocks.
|
|
101
|
+
*/
|
|
102
|
+
export type RuntimeEventBody = {
|
|
87
103
|
readonly kind: "text_delta";
|
|
88
104
|
readonly text: string;
|
|
89
105
|
}
|
|
@@ -118,6 +134,45 @@ export type EventView = {
|
|
|
118
134
|
readonly kind: "model";
|
|
119
135
|
readonly model: string;
|
|
120
136
|
};
|
|
137
|
+
/** The toRuntime control actions a Session issues. */
|
|
138
|
+
export type ControlAction = "prompt" | "steer" | "queue" | "abort" | "dispose";
|
|
139
|
+
/**
|
|
140
|
+
* Event kinds read off request and response records, so a consumer of
|
|
141
|
+
* `Session.events()` sees the control facts that matter without handling
|
|
142
|
+
* record kinds: a turn's start (the prompt request), the process exit, and a
|
|
143
|
+
* control action the runtime or adapter refused. Never carried by a Frame.
|
|
144
|
+
*/
|
|
145
|
+
export type ControlEventBody =
|
|
146
|
+
/** A prompt request was recorded: the turn's start. `requestId` pairs it with a later `control_rejected` when the prompt did not begin a turn. */
|
|
147
|
+
{
|
|
148
|
+
readonly kind: "turn_started";
|
|
149
|
+
readonly requestId: string;
|
|
150
|
+
readonly input: string;
|
|
151
|
+
readonly lineage?: PromptLineage;
|
|
152
|
+
}
|
|
153
|
+
/** A `toRuntime` control action was rejected; the caller still owns the input. */
|
|
154
|
+
| {
|
|
155
|
+
readonly kind: "control_rejected";
|
|
156
|
+
readonly requestId: string;
|
|
157
|
+
readonly action: ControlAction;
|
|
158
|
+
readonly reason: string;
|
|
159
|
+
}
|
|
160
|
+
/** The runtime process exited (an `exited` response). */
|
|
161
|
+
| {
|
|
162
|
+
readonly kind: "exited";
|
|
163
|
+
readonly code: number | null;
|
|
164
|
+
};
|
|
165
|
+
/** Every event kind `Session.events()` can deliver. */
|
|
166
|
+
export type EventBody = RuntimeEventBody | ControlEventBody;
|
|
167
|
+
/**
|
|
168
|
+
* The consumer face of the stream: one attributed fact. An Event is an
|
|
169
|
+
* EventBody plus the envelope of the record it was read from, so it carries
|
|
170
|
+
* `seq` (several events read from one frame share it), `agentPath`,
|
|
171
|
+
* `spanId` and `receivedAt` without the consumer touching the record. Lossy
|
|
172
|
+
* by design (no `native`, no `type`), and always re-derivable from the
|
|
173
|
+
* RawEvent stream via `eventsOf`.
|
|
174
|
+
*/
|
|
175
|
+
export type Event = EventBody & RecordEnvelope;
|
|
121
176
|
export type RequestBody = {
|
|
122
177
|
readonly kind: "prompt";
|
|
123
178
|
readonly input: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/contracts/records.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/contracts/records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mRAAmR;IACnR,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6KAA6K;IAC7K,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,2IAA2I;IAC3I,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,uFAAuF;IACvF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wIAAwI;IACxI,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;AAE1D,wJAAwJ;AACxJ,MAAM,WAAW,KAAM,SAAQ,cAAc;IAC3C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,OAAO,CAAC;AAErD,8OAA8O;AAC9O,MAAM,WAAW,aAAc,SAAQ,cAAc;IACnD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;AAED,2NAA2N;AAC3N,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,Y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M,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CACxC;AAED,2FAA2F;AAC3F,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The record stream
|
|
3
|
-
*
|
|
2
|
+
* The record stream and the events read off it. Three words, three layers:
|
|
3
|
+
*
|
|
4
|
+
* - `Event`: the consumer face. One flat, attributed fact (text, a tool
|
|
5
|
+
* call, a turn end, a process exit …). What `Session.events()` delivers.
|
|
6
|
+
* - `RawEvent`: one record of the underlying stream, three kinds by
|
|
7
|
+
* obligation: `Frame` (the runtime's own words), `RequestRecord` (an
|
|
8
|
+
* action expecting an outcome), `ResponseRecord` (points at a request).
|
|
9
|
+
* What `Session.rawEvents()` / `records()` deliver.
|
|
10
|
+
* - `Frame`: a RawEvent carrying one runtime frame verbatim (`type`,
|
|
11
|
+
* `native`) plus the events oar read out of it.
|
|
12
|
+
*
|
|
4
13
|
* Semantics live in docs/spec; the session control surface that produces
|
|
5
14
|
* these records is in ./session.ts.
|
|
6
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/contracts/records.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/contracts/records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ContextUsage, Cursor, PromptLineage, RequestRecord, ResponseRecord, SessionGraph,
|
|
1
|
+
import type { ContextUsage, Cursor, Event, PromptLineage, RawEvent, RequestRecord, ResponseRecord, SessionGraph, TokenTotals } from "./records.js";
|
|
2
2
|
import type { AvailableInstallation } from "./installation.js";
|
|
3
|
-
export type { ContextUsage, Cursor, EventBody,
|
|
3
|
+
export type { ContextUsage, ControlAction, ControlEventBody, Cursor, Event, EventBody, FailureClass, Frame, FrameBody, PromptLineage, ReasoningContent, RecordEnvelope, RecordKind, RequestBody, RequestDirection, RequestRecord, ResponseBody, ResponseRecord, RuntimeEventBody, SessionEdge, SessionGraph, SessionNode, RawEvent, TokenTotals, TurnOutcome, UsageReport, } from "./records.js";
|
|
4
4
|
export interface QueryResult<T> {
|
|
5
5
|
/** The fold's current value. */
|
|
6
6
|
readonly value: T;
|
|
@@ -17,9 +17,11 @@ export interface PromptOptions {
|
|
|
17
17
|
* The external promise (docs/spec): everything the runtime said is in the
|
|
18
18
|
* stream, nothing oar didn't observe is in it, every record knows whose it
|
|
19
19
|
* is, and the stream is readable again from any position. Records split by
|
|
20
|
-
* OBLIGATION into three kinds,
|
|
20
|
+
* OBLIGATION into three kinds, frame (the runtime's own words), request (an
|
|
21
21
|
* action that expects an outcome) and response (points at a request), and
|
|
22
|
-
* travel on one channel with one monotonic `seq`.
|
|
22
|
+
* travel on one channel with one monotonic `seq`. Consumers who do not want
|
|
23
|
+
* records read the stream as flat `Event`s through `events()`; `rawEvents()`
|
|
24
|
+
* and `records()` are the stream itself. Behavior invariants live as
|
|
23
25
|
* comments on the member they constrain; each "must/never" has (or gets) a
|
|
24
26
|
* sea-trial case.
|
|
25
27
|
*
|
|
@@ -82,8 +84,24 @@ export interface SessionCapabilities {
|
|
|
82
84
|
} | null;
|
|
83
85
|
readonly attribution: AttributionTier;
|
|
84
86
|
}
|
|
85
|
-
export type
|
|
87
|
+
export type RawEventObserver = (record: RawEvent) => void;
|
|
88
|
+
export type EventObserver = (event: Event) => void;
|
|
86
89
|
export type Unsubscribe = () => void;
|
|
90
|
+
export interface EventsOptions {
|
|
91
|
+
/** Replay retained records after `afterSeq` first, then continue live (same semantics as `rawEvents`). */
|
|
92
|
+
readonly cursor?: Cursor;
|
|
93
|
+
/**
|
|
94
|
+
* Merge consecutive `text_delta` (and readable `reasoning`) events of one
|
|
95
|
+
* agent into one event instead of a token stream. A merged event carries the
|
|
96
|
+
* LAST piece's envelope. It flushes when the kind or agent changes, another
|
|
97
|
+
* event arrives, or (with `maxHoldMs`) the stream goes quiet for that long,
|
|
98
|
+
* so a stalled model pause cannot hold text hostage. Off by default: events
|
|
99
|
+
* are then synchronous and one-to-one with what was read from the stream.
|
|
100
|
+
*/
|
|
101
|
+
readonly coalesceText?: boolean | {
|
|
102
|
+
readonly maxHoldMs: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
87
105
|
/**
|
|
88
106
|
* The SPI face: what an adapter actually builds. The API face extends it
|
|
89
107
|
* with derivations sealSession computes over the stream.
|
|
@@ -95,13 +113,21 @@ export interface AdapterSession {
|
|
|
95
113
|
steer(input: string): Promise<ControlResult>;
|
|
96
114
|
queue(input: string): Promise<ControlResult>;
|
|
97
115
|
abort(): Promise<ControlResult>;
|
|
98
|
-
|
|
99
|
-
records(): readonly
|
|
116
|
+
rawEvents(observer: RawEventObserver, cursor?: Cursor): Unsubscribe;
|
|
117
|
+
records(): readonly RawEvent[];
|
|
100
118
|
graph(): SessionGraph;
|
|
101
119
|
dispose(): Promise<void>;
|
|
102
120
|
}
|
|
103
121
|
/** The API face: the SPI plus surfaces sealSession derives from the stream. */
|
|
104
122
|
export interface Session extends AdapterSession {
|
|
123
|
+
/**
|
|
124
|
+
* The consumer face of the stream: every fact oar read, flat and attributed
|
|
125
|
+
* (`eventsOf` applied to each record). One frame with three readings is
|
|
126
|
+
* three events sharing a `seq`; a record oar read nothing from yields none.
|
|
127
|
+
* Same side-tap rules as `rawEvents`. This is the surface to start with;
|
|
128
|
+
* reach for `rawEvents` / `records()` when the native frame matters.
|
|
129
|
+
*/
|
|
130
|
+
events(observer: EventObserver, options?: EventsOptions): Unsubscribe;
|
|
105
131
|
/** Latest `model` event; null until the runtime has said one. A fold, not an echo of the request. */
|
|
106
132
|
model(): QueryResult<string | null>;
|
|
107
133
|
/** THIS session's token total plus a per-agent breakdown when children reported: deduplicated, directly summable (sum = total). A derived child session (own `sessionId`, in `graph()`) is not aggregated here; its usage is in its own records. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/contracts/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,aAAa,EACb,aAAa,EACb,cAAc,EACd,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/contracts/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,KAAK,EACL,aAAa,EACb,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,YAAY,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,WAAW,EACX,WAAW,GACZ,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,oEAAoE;IACpE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,QAAQ,CAA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oP;IACpP,KAAK,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC;IACnC,mGAAmG;IACnG,YAAY,IAAI,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACjD;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC1D;AAED,MAAM,WAAW,YAAY;IAC3B,wHAAwH;IACxH,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,kEAAkE;IAClE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;KAAE,EAAE,CAAC;CACvG;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAC7D;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ export type { ProviderAuthFacade, ProviderAuthStatus, ProviderLoginEvent, Provid
|
|
|
5
5
|
export type { CatalogModel, CatalogProvider, CatalogRefreshOptions, CatalogRefreshResult, ModelCatalogFacade, } from "./contracts/model-catalog.js";
|
|
6
6
|
export type { ListModelsOptions, ListModelsResult, ModelEntry, ModelLister, } from "./contracts/list-models.js";
|
|
7
7
|
export type { Runtime } from "./contracts/runtime.js";
|
|
8
|
-
export type { AdapterSession, AttributionTier, ContextUsage, ControlResult, Cursor, EventBody,
|
|
8
|
+
export type { AdapterSession, AttributionTier, ContextUsage, ControlAction, ControlEventBody, ControlResult, Cursor, Event, EventBody, EventObserver, EventsOptions, FailureClass, Frame, FrameBody, PromptLineage, PromptOptions, QueryResult, ReasoningContent, RecordEnvelope, RecordKind, RequestBody, RequestDirection, RequestRecord, ResponseBody, ResponseRecord, RuntimeEventBody, Session, SessionCapabilities, SessionEdge, SessionGraph, SessionNode, RawEventObserver, SessionOptions, RawEvent, SessionUsage, StartSession, SteerOrQueueResult, TokenTotals, TurnOutcome, Unsubscribe, UsageReport, } from "./contracts/session.js";
|
|
9
9
|
export { defineRuntime } from "./contracts/runtime.js";
|
|
10
10
|
export { utcInstantFromDate } from "./shared/instant.js";
|
|
11
11
|
export { RuntimeRegistry, createRuntimeRegistry } from "./registry.js";
|
|
12
12
|
export { VOYAGE_FORMAT, endLine, headerLine, openVoyage, recordLine, } from "./voyage.js";
|
|
13
13
|
export type { VoyageHeader, VoyageRecorder } from "./voyage.js";
|
|
14
|
-
export {
|
|
14
|
+
export { coalesceText, controlActionsOf, eventsOf, eventsReader } from "./observe/events.js";
|
|
15
15
|
export { initialStatus, reduceStatus, stallOf, } from "./observe/agent-status.js";
|
|
16
16
|
export type { AgentStatus, RunningPhase } from "./observe/agent-status.js";
|
|
17
17
|
export { observeStalls } from "./observe/stall-observer.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOhD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,YAAY,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,EACb,MAAM,EACN,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOhD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,YAAY,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,MAAM,EAC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D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,eAAO,MAAM,QAAQ,iBAMnB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { defineRuntime } from "./contracts/runtime.js";
|
|
|
8
8
|
export { utcInstantFromDate } from "./shared/instant.js";
|
|
9
9
|
export { RuntimeRegistry, createRuntimeRegistry } from "./registry.js";
|
|
10
10
|
export { VOYAGE_FORMAT, endLine, headerLine, openVoyage, recordLine, } from "./voyage.js";
|
|
11
|
-
export {
|
|
11
|
+
export { coalesceText, controlActionsOf, eventsOf, eventsReader } from "./observe/events.js";
|
|
12
12
|
export { initialStatus, reduceStatus, stallOf, } from "./observe/agent-status.js";
|
|
13
13
|
export { observeStalls } from "./observe/stall-observer.js";
|
|
14
14
|
export { observeAgent, simpleStateOf } from "./observe/observe-agent.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAA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,WAAW;IACX,WAAW;IACX,SAAS;CACV,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RawEvent, TurnOutcome } from "../contracts/session.js";
|
|
2
2
|
/**
|
|
3
3
|
* status = fold(records). The reducer is pure (no clock, no IO), so status
|
|
4
4
|
* is replayable from any record log and snapshot-testable. Time-qualified
|
|
@@ -11,7 +11,7 @@ import type { SessionRecord, TurnOutcome } from "../contracts/session.js";
|
|
|
11
11
|
* it, every root-agent record of any session is folded (single-session
|
|
12
12
|
* streams). Phase transitions come from the root agent's own records only;
|
|
13
13
|
* `lastEventAt`, the liveness clock, refreshes on EVERY record attributable
|
|
14
|
-
* to the session (child agents, child sessions,
|
|
14
|
+
* to the session (child agents, child sessions, frames oar read nothing from), because a
|
|
15
15
|
* delegated sub-agent working is not a stalled root.
|
|
16
16
|
*
|
|
17
17
|
* Transition table:
|
|
@@ -44,7 +44,7 @@ export type AgentStatus = {
|
|
|
44
44
|
readonly lastEventAt: number;
|
|
45
45
|
};
|
|
46
46
|
export declare const initialStatus: AgentStatus;
|
|
47
|
-
export declare function reduceStatus(previous: AgentStatus, record:
|
|
47
|
+
export declare function reduceStatus(previous: AgentStatus, record: RawEvent, sessionId?: string): AgentStatus;
|
|
48
48
|
/** fold(records) × clock: how long a running status has been silent, if beyond the threshold. */
|
|
49
49
|
export declare function stallOf(status: AgentStatus, nowMs: number, thresholdMs: number): {
|
|
50
50
|
readonly sinceSeq: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-status.d.ts","sourceRoot":"","sources":["../../src/observe/agent-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"agent-status.d.ts","sourceRoot":"","sources":["../../src/observe/agent-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAoB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,MAAM,YAAY,GACpB,eAAe,GACf,UAAU,GACV,YAAY,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,CAAA;CAAE,GACjE;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,kHAAkH;IAClH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qGAAqG;IACrG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEN,eAAO,MAAM,aAAa,EAAE,WAA8B,CAAC;AAc3D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAiCrG;AAgCD,iGAAiG;AACjG,wBAAgB,OAAO,CACrB,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAMpE"}
|
|
@@ -15,8 +15,8 @@ export function reduceStatus(previous, record, sessionId) {
|
|
|
15
15
|
if (foreignSession && !belongsToSession(record, sessionId)) {
|
|
16
16
|
return previous;
|
|
17
17
|
}
|
|
18
|
-
if (foreignSession || record.agentPath.length > 0 || (record.kind === "
|
|
19
|
-
// A child agent, a child session, or a frame
|
|
18
|
+
if (foreignSession || record.agentPath.length > 0 || (record.kind === "frame" && record.body.events.length === 0)) {
|
|
19
|
+
// A child agent, a child session, or a frame oar read nothing from: the session is
|
|
20
20
|
// alive, so the clock moves, but the root agent's phase does not.
|
|
21
21
|
return previous.kind === "running" ? { ...previous, lastEventAt: record.receivedAt } : previous;
|
|
22
22
|
}
|
|
@@ -33,10 +33,10 @@ export function reduceStatus(previous, record, sessionId) {
|
|
|
33
33
|
return { kind: "idle", lastTurnOutcome: { kind: "failed", reason: "runtime exited", failure: "runtime_exited" } };
|
|
34
34
|
}
|
|
35
35
|
return previous;
|
|
36
|
-
case "
|
|
36
|
+
case "frame": {
|
|
37
37
|
let status = previous;
|
|
38
|
-
for (const
|
|
39
|
-
status =
|
|
38
|
+
for (const event of record.body.events) {
|
|
39
|
+
status = reduceEvent(status, record, event);
|
|
40
40
|
}
|
|
41
41
|
return status;
|
|
42
42
|
}
|
|
@@ -44,18 +44,18 @@ export function reduceStatus(previous, record, sessionId) {
|
|
|
44
44
|
return previous;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
switch (
|
|
47
|
+
function reduceEvent(previous, record, event) {
|
|
48
|
+
switch (event.kind) {
|
|
49
49
|
case "reasoning":
|
|
50
50
|
return running(previous, record, "thinking");
|
|
51
51
|
case "text_delta":
|
|
52
52
|
return running(previous, record, "responding");
|
|
53
53
|
case "tool_call_started":
|
|
54
|
-
return running(previous, record, { tool:
|
|
54
|
+
return running(previous, record, { tool: event.tool, callId: event.callId });
|
|
55
55
|
case "tool_call_ended":
|
|
56
56
|
return running(previous, record, "waiting_model");
|
|
57
57
|
case "turn_ended":
|
|
58
|
-
return { kind: "idle", lastTurnOutcome:
|
|
58
|
+
return { kind: "idle", lastTurnOutcome: event.outcome };
|
|
59
59
|
case "usage":
|
|
60
60
|
case "model":
|
|
61
61
|
return previous;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-status.js","sourceRoot":"","sources":["../../src/observe/agent-status.ts"],"names":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AAC;IACd,CAAC;IACD,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;IAC/C,OAAO,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ControlAction, Event, EventObserver, RawEvent, RawEventObserver } from "../contracts/session.js";
|
|
2
|
+
/**
|
|
3
|
+
* The consumer face of the stream. `eventsOf` reads the flat, attributed
|
|
4
|
+
* `Event`s out of one record: every reading of a Frame (each stamped with the
|
|
5
|
+
* frame's envelope, so events read from one frame share its `seq`), the turn
|
|
6
|
+
* start a prompt request is, a rejected control action, and the process exit.
|
|
7
|
+
* A record oar read nothing from yields no events. Pure given `actions`, the
|
|
8
|
+
* kinds of the toRuntime requests seen so far (a rejected response names
|
|
9
|
+
* only its `requestId`; `controlActionsOf` builds the map from a log), so a
|
|
10
|
+
* RawEvent log replays into exactly the events the live subscription
|
|
11
|
+
* delivered.
|
|
12
|
+
*/
|
|
13
|
+
export declare function eventsOf(record: RawEvent, actions?: ReadonlyMap<string, ControlAction>): readonly Event[];
|
|
14
|
+
/** The action of every toRuntime request in a log, by request id; the `actions` input `eventsOf` needs for rejections. */
|
|
15
|
+
export declare function controlActionsOf(records: readonly RawEvent[]): ReadonlyMap<string, ControlAction>;
|
|
16
|
+
/** A raw-event observer that delivers `eventsOf` each record to `observer`, remembering request kinds so rejections name their action. */
|
|
17
|
+
export declare function eventsReader(observer: EventObserver): RawEventObserver;
|
|
18
|
+
/**
|
|
19
|
+
* Consumer-side coalescing: wrap an event observer so consecutive text (or
|
|
20
|
+
* readable reasoning) pieces of one agent arrive as one event instead of a
|
|
21
|
+
* token stream. Flushes when the kind or agent changes, a non-text event
|
|
22
|
+
* arrives, or (when `maxHoldMs` is set) the stream goes quiet for that long.
|
|
23
|
+
* The merged event carries the LAST piece's envelope. Order is safe because
|
|
24
|
+
* only consecutive same-lane pieces are ever held.
|
|
25
|
+
*/
|
|
26
|
+
export declare function coalesceText(observer: EventObserver, options?: {
|
|
27
|
+
readonly maxHoldMs?: number;
|
|
28
|
+
}): EventObserver;
|
|
29
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/observe/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,KAAK,EACL,aAAa,EACb,QAAQ,EACR,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAa,GAAG,SAAS,KAAK,EAAE,CA6BpH;AAED,0HAA0H;AAC1H,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAQjG;AAED,0IAA0I;AAC1I,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,gBAAgB,CAatE;AAuBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,aAAa,CA0Cf"}
|