@botiverse/oar 0.1.4 → 0.3.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 +50 -7
- package/dist/contracts/account-usage.d.ts +7 -0
- package/dist/contracts/account-usage.d.ts.map +1 -1
- package/dist/contracts/records.d.ts +121 -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 +3 -3
- 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 +7 -4
- package/dist/observe/agent-status.d.ts.map +1 -1
- package/dist/observe/agent-status.js +15 -9
- package/dist/observe/agent-status.js.map +1 -1
- package/dist/observe/events.d.ts +30 -0
- package/dist/observe/events.d.ts.map +1 -0
- package/dist/observe/events.js +142 -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/account-usage.d.ts.map +1 -1
- package/dist/runtimes/claude/account-usage.js +9 -6
- package/dist/runtimes/claude/account-usage.js.map +1 -1
- package/dist/runtimes/claude/projection.d.ts +6 -6
- package/dist/runtimes/claude/projection.d.ts.map +1 -1
- package/dist/runtimes/claude/projection.js +17 -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/account-usage.d.ts +3 -1
- package/dist/runtimes/codex/account-usage.d.ts.map +1 -1
- package/dist/runtimes/codex/account-usage.js +6 -6
- package/dist/runtimes/codex/account-usage.js.map +1 -1
- package/dist/runtimes/codex/projection.d.ts +10 -3
- package/dist/runtimes/codex/projection.d.ts.map +1 -1
- package/dist/runtimes/codex/projection.js +23 -5
- 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/grok/account-usage.js +4 -4
- package/dist/runtimes/grok/account-usage.js.map +1 -1
- package/dist/runtimes/kimi/account-usage.d.ts.map +1 -1
- package/dist/runtimes/kimi/account-usage.js +10 -8
- package/dist/runtimes/kimi/account-usage.js.map +1 -1
- package/dist/runtimes/pi/projection.d.ts +7 -7
- package/dist/runtimes/pi/projection.d.ts.map +1 -1
- package/dist/runtimes/pi/projection.js +47 -29
- 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 +19 -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,31 +3,74 @@
|
|
|
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 call start / progress / end, turn start and end, usage, model,
|
|
29
|
+
compaction start / end, retry, runtime→app requests and oar's answers,
|
|
30
|
+
control rejections, the process exit), each carrying the `seq` and
|
|
31
|
+
`agentPath` of the record it was read from. Kinds a runtime never says
|
|
32
|
+
(claude has no compaction start, ACP runtimes no compaction or retry) simply
|
|
33
|
+
never appear; the runtime pages say which. It is a projection over the record stream: `session.rawEvents()`
|
|
34
|
+
and `session.records()` expose that stream (`RawEvent`: `Frame` with the
|
|
35
|
+
native payload verbatim, `RequestRecord`, `ResponseRecord`) for consumers
|
|
36
|
+
who need the runtime's own frames.
|
|
37
|
+
|
|
22
38
|
## Public exports
|
|
23
39
|
|
|
24
40
|
The package has exactly two public entry points:
|
|
25
41
|
|
|
26
42
|
- `@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 `
|
|
43
|
+
- `@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
44
|
|
|
29
45
|
Any other deep import (`@botiverse/oar/dist/...`, source paths) is internal and may break without notice.
|
|
30
46
|
|
|
31
47
|
Grok and Kimi share an internal ACP v1 transport and session kernel, but only their concrete runtime identities are public. The registry deliberately does not expose a generic `acp` runtime.
|
|
32
48
|
|
|
33
49
|
The command-line interface is a separate package: `@botiverse/oar-cli`.
|
|
50
|
+
|
|
51
|
+
## Account usage reasons
|
|
52
|
+
|
|
53
|
+
Unsuccessful account-usage snapshots retain `kind: "unsupported"` or
|
|
54
|
+
`kind: "reauth_required"` and now include a stable `reason` from built-in readers.
|
|
55
|
+
Consumers should use `reason` rather than infer a cause from the runtime name.
|
|
56
|
+
The field is optional for compatibility with older/custom adapters; absent
|
|
57
|
+
reasons must be presented as unknown rather than guessed.
|
|
58
|
+
|
|
59
|
+
| Kind | Reason | Meaning |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| unsupported | capability_unavailable | The runtime has no account-usage reader (reported by the CLI/embedding app). |
|
|
62
|
+
| unsupported | unsupported_installation | This reader cannot query this installation type. |
|
|
63
|
+
| unsupported | unsupported_auth_mode | The selected authentication mode is not supported by the usage reader. This is the adapter's decision, not proof that a token was rejected. |
|
|
64
|
+
| unsupported | unsupported_auth_storage | The configured credential storage is not supported. |
|
|
65
|
+
| unsupported | auth_configuration_unavailable | The reader could not resolve the provider/auth configuration; no more specific cause is known. |
|
|
66
|
+
| unsupported | endpoint_unavailable | The provider/runtime does not expose the queried usage endpoint. |
|
|
67
|
+
| unsupported | quota_unavailable | The response does not expose a quota configuration. |
|
|
68
|
+
| reauth_required | not_authenticated | The runtime requires a login. |
|
|
69
|
+
| reauth_required | credentials_missing | No usable persisted credential was found. |
|
|
70
|
+
| reauth_required | scope_missing | The credential lacks the scope needed for usage queries. |
|
|
71
|
+
| reauth_required | credentials_rejected | The usage endpoint rejected the credential (401/403). |
|
|
72
|
+
|
|
73
|
+
Operational failures (network errors, timeouts, malformed responses) still reject
|
|
74
|
+
the promise. Reasons do not include tokens, credential values, or raw provider
|
|
75
|
+
responses. This change does not alter authentication precedence, refresh tokens,
|
|
76
|
+
or probe endpoints that were previously skipped.
|
|
@@ -15,6 +15,9 @@ export interface AccountUsageWindow {
|
|
|
15
15
|
/** Next reset as a UTC instant; omitted when the runtime does not report one. */
|
|
16
16
|
readonly resetsAt?: UtcInstant;
|
|
17
17
|
}
|
|
18
|
+
/** Stable reason codes; no credentials or provider response bodies are included. */
|
|
19
|
+
export type AccountUsageUnsupportedReason = "capability_unavailable" | "unsupported_installation" | "unsupported_auth_mode" | "unsupported_auth_storage" | "auth_configuration_unavailable" | "endpoint_unavailable" | "quota_unavailable";
|
|
20
|
+
export type AccountUsageReauthReason = "not_authenticated" | "credentials_missing" | "scope_missing" | "credentials_rejected";
|
|
18
21
|
export type AccountUsageSnapshot = {
|
|
19
22
|
readonly kind: "available";
|
|
20
23
|
/** Runtime-reported subscription plan or tier; omitted when not exposed. */
|
|
@@ -25,8 +28,12 @@ export type AccountUsageSnapshot = {
|
|
|
25
28
|
readonly windows: readonly AccountUsageWindow[];
|
|
26
29
|
} | {
|
|
27
30
|
readonly kind: "reauth_required";
|
|
31
|
+
/** Built-in readers always report a reason; optional for older adapters. */
|
|
32
|
+
readonly reason?: AccountUsageReauthReason;
|
|
28
33
|
} | {
|
|
29
34
|
readonly kind: "unsupported";
|
|
35
|
+
/** Unsupported for this installation/account does not imply missing capability. */
|
|
36
|
+
readonly reason?: AccountUsageUnsupportedReason;
|
|
30
37
|
};
|
|
31
38
|
export interface AccountUsageReadOptions {
|
|
32
39
|
readonly timeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-usage.d.ts","sourceRoot":"","sources":["../../src/contracts/account-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,eAAe,CAAC,EAAE,IAAI,CAAA;C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C;AAExB,MAAM,MAAM,wBAAwB,GAChC,mBAAmB,GACnB,qBAAqB,GACrB,eAAe,GACf,sBAAsB,CAAC;AAE3B,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACjD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,wBAAwB,CAAC;CAC5C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,mFAAmF;IACnF,QAAQ,CAAC,MAAM,CAAC,EAAE,6BAA6B,CAAC;CACjD,CAAC;AAEN,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC/B,YAAY,EAAE,qBAAqB,EACnC,OAAO,CAAC,EAAE,uBAAuB,KAC9B,OAAO,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -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
|
}
|
|
@@ -105,10 +121,45 @@ export type EventView = {
|
|
|
105
121
|
/** The runtime's explicit tool outcome; absent when it reported none. */
|
|
106
122
|
readonly result?: "ok" | "failed";
|
|
107
123
|
}
|
|
124
|
+
/** Partial output of a running tool call, when the runtime streams it (pi `tool_execution_update`, codex `item/commandExecution/outputDelta`, an ACP `tool_call_update` carrying `rawOutput`). claude streams none. */
|
|
125
|
+
| {
|
|
126
|
+
readonly kind: "tool_call_progress";
|
|
127
|
+
readonly callId: string;
|
|
128
|
+
readonly output?: string;
|
|
129
|
+
}
|
|
108
130
|
/** The runtime's OWN completion report for a turn (claude `result`, codex `turn/completed`, pi `agent_end`, an ACP prompt answer). The turn's start is the prompt request record itself; if a runtime reports no end, none appears. */
|
|
109
131
|
| {
|
|
110
132
|
readonly kind: "turn_ended";
|
|
111
133
|
readonly outcome: TurnOutcome;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The runtime began compacting its context. `trigger` is the runtime's own
|
|
137
|
+
* word for why (pi: manual | threshold | overflow; codex: none). claude
|
|
138
|
+
* reports only the boundary after the fact, so it never says this.
|
|
139
|
+
*/
|
|
140
|
+
| {
|
|
141
|
+
readonly kind: "compaction_started";
|
|
142
|
+
readonly trigger?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The runtime finished (or gave up) compacting (pi `compaction_end`, claude
|
|
146
|
+
* `system/compact_boundary`, codex `contextCompaction` item completed).
|
|
147
|
+
* `trigger` as above (claude: manual | auto); `reason` is the runtime's
|
|
148
|
+
* error text when it failed. ACP runtimes report no compaction.
|
|
149
|
+
*/
|
|
150
|
+
| {
|
|
151
|
+
readonly kind: "compaction_ended";
|
|
152
|
+
readonly outcome: "completed" | "aborted" | "failed";
|
|
153
|
+
readonly trigger?: string;
|
|
154
|
+
readonly reason?: string;
|
|
155
|
+
}
|
|
156
|
+
/** The runtime announced it will retry a failed provider call (pi `auto_retry_start`, `summarization_retry_scheduled`). Other shipped runtimes retry silently or not at all. */
|
|
157
|
+
| {
|
|
158
|
+
readonly kind: "retry";
|
|
159
|
+
readonly attempt: number;
|
|
160
|
+
readonly maxAttempts?: number;
|
|
161
|
+
readonly delayMs?: number;
|
|
162
|
+
readonly reason?: string;
|
|
112
163
|
} | {
|
|
113
164
|
readonly kind: "usage";
|
|
114
165
|
readonly usage: UsageReport;
|
|
@@ -118,6 +169,57 @@ export type EventView = {
|
|
|
118
169
|
readonly kind: "model";
|
|
119
170
|
readonly model: string;
|
|
120
171
|
};
|
|
172
|
+
/** The toRuntime control actions a Session issues. */
|
|
173
|
+
export type ControlAction = "prompt" | "steer" | "queue" | "abort" | "dispose";
|
|
174
|
+
/**
|
|
175
|
+
* Event kinds read off request and response records, so a consumer of
|
|
176
|
+
* `Session.events()` sees the control facts that matter without handling
|
|
177
|
+
* record kinds: a turn's start (the prompt request), a control action the runtime or
|
|
178
|
+
* adapter refused, a runtime→app request and oar's answer to it, and the
|
|
179
|
+
* process exit. Never carried by a Frame.
|
|
180
|
+
*/
|
|
181
|
+
export type ControlEventBody =
|
|
182
|
+
/** 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. */
|
|
183
|
+
{
|
|
184
|
+
readonly kind: "turn_started";
|
|
185
|
+
readonly requestId: string;
|
|
186
|
+
readonly input: string;
|
|
187
|
+
readonly lineage?: PromptLineage;
|
|
188
|
+
}
|
|
189
|
+
/** A `toRuntime` control action was rejected; the caller still owns the input. */
|
|
190
|
+
| {
|
|
191
|
+
readonly kind: "control_rejected";
|
|
192
|
+
readonly requestId: string;
|
|
193
|
+
readonly action: ControlAction;
|
|
194
|
+
readonly reason: string;
|
|
195
|
+
}
|
|
196
|
+
/** The runtime asked the application something (a `toApp` request: approval, question, terminal). `type` is the runtime's method or subtype; the body is on the request record. */
|
|
197
|
+
| {
|
|
198
|
+
readonly kind: "app_request";
|
|
199
|
+
readonly requestId: string;
|
|
200
|
+
readonly type: string;
|
|
201
|
+
}
|
|
202
|
+
/** oar answered a `toApp` request automatically (an `answered` response). */
|
|
203
|
+
| {
|
|
204
|
+
readonly kind: "app_answered";
|
|
205
|
+
readonly requestId: string;
|
|
206
|
+
}
|
|
207
|
+
/** The runtime process exited (an `exited` response). */
|
|
208
|
+
| {
|
|
209
|
+
readonly kind: "exited";
|
|
210
|
+
readonly code: number | null;
|
|
211
|
+
};
|
|
212
|
+
/** Every event kind `Session.events()` can deliver. */
|
|
213
|
+
export type EventBody = RuntimeEventBody | ControlEventBody;
|
|
214
|
+
/**
|
|
215
|
+
* The consumer face of the stream: one attributed fact. An Event is an
|
|
216
|
+
* EventBody plus the envelope of the record it was read from, so it carries
|
|
217
|
+
* `seq` (several events read from one frame share it), `agentPath`,
|
|
218
|
+
* `spanId` and `receivedAt` without the consumer touching the record. Lossy
|
|
219
|
+
* by design (no `native`, no `type`), and always re-derivable from the
|
|
220
|
+
* RawEvent stream via `eventsOf`.
|
|
221
|
+
*/
|
|
222
|
+
export type Event = EventBody & RecordEnvelope;
|
|
121
223
|
export type RequestBody = {
|
|
122
224
|
readonly kind: "prompt";
|
|
123
225
|
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,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: 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,OA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,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
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { RuntimeRegistry } from "./registry.js";
|
|
2
|
-
export type { AccountUsageReader, AccountUsageReadOptions, AccountUsageSnapshot, AccountUsageWindow, UtcInstant, } from "./contracts/account-usage.js";
|
|
2
|
+
export type { AccountUsageUnsupportedReason, AccountUsageReauthReason, AccountUsageReader, AccountUsageReadOptions, AccountUsageSnapshot, AccountUsageWindow, UtcInstant, } from "./contracts/account-usage.js";
|
|
3
3
|
export type { AvailableInstallation, BundledInstallation, ExecutableInstallation, InstallationProbe, InstallationSnapshot, } from "./contracts/installation.js";
|
|
4
4
|
export type { ProviderAuthFacade, ProviderAuthStatus, ProviderLoginEvent, ProviderLoginInteraction, ProviderLoginMethod, ProviderLoginPrompt, } from "./contracts/provider-auth.js";
|
|
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,6BAA6B,EAC7B,wBAAwB,EACxB,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,EACN,KAAK,EACL,SAAS,EACT,aAAa,EACb,aA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AE,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,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM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AC,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:
|
|
@@ -21,12 +21,15 @@ import type { SessionRecord, TurnOutcome } from "../contracts/session.js";
|
|
|
21
21
|
* event text_delta → running/responding
|
|
22
22
|
* event tool_call_started → running/{tool, callId}
|
|
23
23
|
* event tool_call_ended → running/waiting_model (the model consumes the result next)
|
|
24
|
+
* event tool_call_progress → running, phase unchanged (the clock moves)
|
|
25
|
+
* event compaction_started → running/compacting
|
|
26
|
+
* event compaction_ended, retry → running/waiting_model
|
|
24
27
|
* event turn_ended → idle{lastTurnOutcome} (the runtime's own completion)
|
|
25
28
|
* response exited → idle{failed runtime_exited} if a turn was running
|
|
26
29
|
* The fold is total: a mid-turn event while idle adopts that turn (a consumer
|
|
27
30
|
* may subscribe mid-turn, and a queued input runs as a turn with no request).
|
|
28
31
|
*/
|
|
29
|
-
export type RunningPhase = "waiting_model" | "thinking" | "responding" | {
|
|
32
|
+
export type RunningPhase = "waiting_model" | "thinking" | "responding" | "compacting" | {
|
|
30
33
|
readonly tool: string;
|
|
31
34
|
readonly callId: string;
|
|
32
35
|
};
|
|
@@ -44,7 +47,7 @@ export type AgentStatus = {
|
|
|
44
47
|
readonly lastEventAt: number;
|
|
45
48
|
};
|
|
46
49
|
export declare const initialStatus: AgentStatus;
|
|
47
|
-
export declare function reduceStatus(previous: AgentStatus, record:
|
|
50
|
+
export declare function reduceStatus(previous: AgentStatus, record: RawEvent, sessionId?: string): AgentStatus;
|
|
48
51
|
/** fold(records) × clock: how long a running status has been silent, if beyond the threshold. */
|
|
49
52
|
export declare function stallOf(status: AgentStatus, nowMs: number, thresholdMs: number): {
|
|
50
53
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,MAAM,YAAY,GACpB,eAAe,GACf,UAAU,GACV,YAAY,GACZ,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,eAA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