@botiverse/oar 0.0.10 → 0.1.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 +2 -2
- package/dist/contracts/model-catalog.d.ts +1 -1
- package/dist/contracts/model-catalog.js +1 -1
- package/dist/contracts/provider-auth.d.ts +2 -2
- package/dist/contracts/provider-auth.js +2 -2
- package/dist/contracts/records.d.ts +205 -0
- package/dist/contracts/records.d.ts.map +1 -0
- package/dist/contracts/records.js +8 -0
- package/dist/contracts/records.js.map +1 -0
- package/dist/contracts/session.d.ts +83 -144
- package/dist/contracts/session.d.ts.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/observe/agent-status.d.ts +32 -18
- package/dist/observe/agent-status.d.ts.map +1 -1
- package/dist/observe/agent-status.js +66 -14
- package/dist/observe/agent-status.js.map +1 -1
- package/dist/observe/aggregate-events.d.ts +7 -6
- package/dist/observe/aggregate-events.d.ts.map +1 -1
- package/dist/observe/aggregate-events.js +38 -28
- package/dist/observe/aggregate-events.js.map +1 -1
- package/dist/observe/index.d.ts +4 -1
- package/dist/observe/index.d.ts.map +1 -1
- package/dist/observe/index.js +3 -1
- package/dist/observe/index.js.map +1 -1
- package/dist/observe/observe-agent.d.ts +4 -4
- package/dist/observe/observe-agent.d.ts.map +1 -1
- package/dist/observe/observe-agent.js +3 -3
- package/dist/observe/observe-agent.js.map +1 -1
- package/dist/observe/stall-observer.d.ts +7 -6
- package/dist/observe/stall-observer.d.ts.map +1 -1
- package/dist/observe/stall-observer.js +6 -5
- 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 +37 -0
- package/dist/observe/turns.d.ts.map +1 -0
- package/dist/observe/turns.js +70 -0
- package/dist/observe/turns.js.map +1 -0
- package/dist/observe/usage.d.ts +15 -0
- package/dist/observe/usage.d.ts.map +1 -0
- package/dist/observe/usage.js +79 -0
- package/dist/observe/usage.js.map +1 -0
- package/dist/runtimes/claude/account-usage.js +1 -1
- package/dist/runtimes/claude/context-usage.d.ts +1 -1
- package/dist/runtimes/claude/context-usage.js +1 -1
- package/dist/runtimes/claude/projection.d.ts +40 -27
- package/dist/runtimes/claude/projection.d.ts.map +1 -1
- package/dist/runtimes/claude/projection.js +107 -21
- package/dist/runtimes/claude/projection.js.map +1 -1
- package/dist/runtimes/claude/session.d.ts.map +1 -1
- package/dist/runtimes/claude/session.js +119 -87
- package/dist/runtimes/claude/session.js.map +1 -1
- package/dist/runtimes/codex/app-server-client.d.ts +38 -3
- package/dist/runtimes/codex/app-server-client.d.ts.map +1 -1
- package/dist/runtimes/codex/app-server-client.js +62 -15
- package/dist/runtimes/codex/app-server-client.js.map +1 -1
- package/dist/runtimes/codex/projection.d.ts +12 -12
- package/dist/runtimes/codex/projection.d.ts.map +1 -1
- package/dist/runtimes/codex/projection.js +101 -38
- package/dist/runtimes/codex/projection.js.map +1 -1
- package/dist/runtimes/codex/rpc-control.d.ts +31 -0
- package/dist/runtimes/codex/rpc-control.d.ts.map +1 -0
- package/dist/runtimes/codex/rpc-control.js +51 -0
- package/dist/runtimes/codex/rpc-control.js.map +1 -0
- package/dist/runtimes/codex/session.d.ts.map +1 -1
- package/dist/runtimes/codex/session.js +199 -148
- package/dist/runtimes/codex/session.js.map +1 -1
- package/dist/runtimes/grok/session.d.ts +37 -1
- package/dist/runtimes/grok/session.d.ts.map +1 -1
- package/dist/runtimes/grok/session.js +74 -0
- package/dist/runtimes/grok/session.js.map +1 -1
- package/dist/runtimes/kimi/session.d.ts.map +1 -1
- package/dist/runtimes/kimi/session.js +5 -0
- package/dist/runtimes/kimi/session.js.map +1 -1
- package/dist/runtimes/pi/auth.d.ts.map +1 -1
- package/dist/runtimes/pi/auth.js +6 -1
- package/dist/runtimes/pi/auth.js.map +1 -1
- package/dist/runtimes/pi/catalog.d.ts.map +1 -1
- package/dist/runtimes/pi/catalog.js +6 -1
- package/dist/runtimes/pi/catalog.js.map +1 -1
- package/dist/runtimes/pi/http.d.ts +34 -0
- package/dist/runtimes/pi/http.d.ts.map +1 -0
- package/dist/runtimes/pi/http.js +95 -0
- package/dist/runtimes/pi/http.js.map +1 -0
- package/dist/runtimes/pi/list-models.d.ts.map +1 -1
- package/dist/runtimes/pi/list-models.js +10 -3
- package/dist/runtimes/pi/list-models.js.map +1 -1
- package/dist/runtimes/pi/open.d.ts +32 -0
- package/dist/runtimes/pi/open.d.ts.map +1 -0
- package/dist/runtimes/pi/open.js +106 -0
- package/dist/runtimes/pi/open.js.map +1 -0
- package/dist/runtimes/pi/projection.d.ts +27 -25
- package/dist/runtimes/pi/projection.d.ts.map +1 -1
- package/dist/runtimes/pi/projection.js +85 -50
- package/dist/runtimes/pi/projection.js.map +1 -1
- package/dist/runtimes/pi/session.d.ts +1 -22
- package/dist/runtimes/pi/session.d.ts.map +1 -1
- package/dist/runtimes/pi/session.js +178 -184
- package/dist/runtimes/pi/session.js.map +1 -1
- package/dist/shared/acp/client-app.d.ts +23 -0
- package/dist/shared/acp/client-app.d.ts.map +1 -0
- package/dist/shared/acp/client-app.js +55 -0
- package/dist/shared/acp/client-app.js.map +1 -0
- package/dist/shared/acp/model.d.ts +3 -17
- package/dist/shared/acp/model.d.ts.map +1 -1
- package/dist/shared/acp/model.js +3 -14
- package/dist/shared/acp/model.js.map +1 -1
- package/dist/shared/acp/profile.d.ts +32 -7
- package/dist/shared/acp/profile.d.ts.map +1 -1
- package/dist/shared/acp/profile.js +17 -8
- package/dist/shared/acp/profile.js.map +1 -1
- package/dist/shared/acp/projection.d.ts +16 -8
- package/dist/shared/acp/projection.d.ts.map +1 -1
- package/dist/shared/acp/projection.js +51 -32
- package/dist/shared/acp/projection.js.map +1 -1
- package/dist/shared/acp/records.d.ts +46 -0
- package/dist/shared/acp/records.d.ts.map +1 -0
- package/dist/shared/acp/records.js +125 -0
- package/dist/shared/acp/records.js.map +1 -0
- package/dist/shared/acp/session.d.ts.map +1 -1
- package/dist/shared/acp/session.js +98 -224
- package/dist/shared/acp/session.js.map +1 -1
- package/dist/shared/acp/terminal.d.ts +1 -3
- package/dist/shared/acp/terminal.d.ts.map +1 -1
- package/dist/shared/acp/terminal.js +1 -21
- package/dist/shared/acp/terminal.js.map +1 -1
- package/dist/shared/acp/turns.d.ts +45 -0
- package/dist/shared/acp/turns.d.ts.map +1 -0
- package/dist/shared/acp/turns.js +160 -0
- package/dist/shared/acp/turns.js.map +1 -0
- package/dist/shared/acp/usage-wait.d.ts +6 -6
- package/dist/shared/acp/usage-wait.d.ts.map +1 -1
- package/dist/shared/acp/usage-wait.js +2 -2
- package/dist/shared/acp/usage-wait.js.map +1 -1
- package/dist/shared/failure-class.d.ts +1 -1
- package/dist/shared/failure-class.js +2 -2
- package/dist/shared/failure-class.js.map +1 -1
- package/dist/shared/seal-session.d.ts +5 -3
- package/dist/shared/seal-session.d.ts.map +1 -1
- package/dist/shared/seal-session.js +24 -16
- package/dist/shared/seal-session.js.map +1 -1
- package/dist/shared/session-kernel.d.ts +68 -18
- package/dist/shared/session-kernel.d.ts.map +1 -1
- package/dist/shared/session-kernel.js +82 -42
- package/dist/shared/session-kernel.js.map +1 -1
- package/dist/voyage.d.ts +4 -7
- package/dist/voyage.d.ts.map +1 -1
- package/dist/voyage.js +14 -19
- package/dist/voyage.js.map +1 -1
- package/package.json +5 -6
- package/dist/runtimes/codex/context-usage.d.ts +0 -10
- package/dist/runtimes/codex/context-usage.d.ts.map +0 -1
- package/dist/runtimes/codex/context-usage.js +0 -16
- package/dist/runtimes/codex/context-usage.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ControlResult, Session, SessionRecord, TurnOutcome } from "../contracts/session.js";
|
|
2
|
+
/**
|
|
3
|
+
* Turn helpers for consumers. A turn is a SPAN on the stream, not a control
|
|
4
|
+
* object: it starts at the prompt request record and ends at the runtime's own
|
|
5
|
+
* `turn_ended` event (or at the process exit oar observed). These folds locate
|
|
6
|
+
* that end; they never synthesize one.
|
|
7
|
+
*
|
|
8
|
+
* Scope: the ROOT SESSION's ROOT AGENT. A derived child session's records
|
|
9
|
+
* (codex child threads, grok child sessions) carry the child's own `sessionId`
|
|
10
|
+
* and `agentPath []`; its `turn_ended` is that child's turn, not the root's.
|
|
11
|
+
* Observed live on codex 0.149.0, where the child's `turn/completed` reached
|
|
12
|
+
* the stream BEFORE the root's.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* The root-agent turn end after `afterSeq`, if the stream already holds one:
|
|
16
|
+
* the runtime's turn_ended view, or an observed process exit. When `sessionId`
|
|
17
|
+
* is given, only that session's records count.
|
|
18
|
+
*/
|
|
19
|
+
export declare function turnEndAfter(records: readonly SessionRecord[], afterSeq: number, sessionId?: string): TurnOutcome | null;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve with the first turn end of the session's root agent recorded after
|
|
22
|
+
* `afterSeq`, from the retained log if it already happened, otherwise live.
|
|
23
|
+
* A derived child session's turn end never satisfies it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function awaitTurnEnd(session: Session, afterSeq: number): Promise<TurnOutcome>;
|
|
26
|
+
export type PromptRun = {
|
|
27
|
+
readonly kind: "rejected";
|
|
28
|
+
readonly result: ControlResult;
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "ended";
|
|
32
|
+
readonly result: ControlResult;
|
|
33
|
+
readonly outcome: TurnOutcome;
|
|
34
|
+
};
|
|
35
|
+
/** Prompt, then wait for the runtime to end the turn it opened. A rejected prompt (busy, dead runtime) returns without waiting. */
|
|
36
|
+
export declare function promptAndWait(session: Session, input: string): Promise<PromptRun>;
|
|
37
|
+
//# sourceMappingURL=turns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turns.d.ts","sourceRoot":"","sources":["../../src/observe/turns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAElG;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,WAAW,GAAG,IAAI,CAmBpB;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAgB3F;AAED,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtF;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAE9F,mIAAmI;AACnI,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAQvF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn helpers for consumers. A turn is a SPAN on the stream, not a control
|
|
3
|
+
* object: it starts at the prompt request record and ends at the runtime's own
|
|
4
|
+
* `turn_ended` event (or at the process exit oar observed). These folds locate
|
|
5
|
+
* that end; they never synthesize one.
|
|
6
|
+
*
|
|
7
|
+
* Scope: the ROOT SESSION's ROOT AGENT. A derived child session's records
|
|
8
|
+
* (codex child threads, grok child sessions) carry the child's own `sessionId`
|
|
9
|
+
* and `agentPath []`; its `turn_ended` is that child's turn, not the root's.
|
|
10
|
+
* Observed live on codex 0.149.0, where the child's `turn/completed` reached
|
|
11
|
+
* the stream BEFORE the root's.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The root-agent turn end after `afterSeq`, if the stream already holds one:
|
|
15
|
+
* the runtime's turn_ended view, or an observed process exit. When `sessionId`
|
|
16
|
+
* is given, only that session's records count.
|
|
17
|
+
*/
|
|
18
|
+
export function turnEndAfter(records, afterSeq, sessionId) {
|
|
19
|
+
for (const record of records) {
|
|
20
|
+
if (record.seq <= afterSeq || record.agentPath.length > 0) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (sessionId !== undefined && record.sessionId !== sessionId) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (record.kind === "event") {
|
|
27
|
+
const ended = record.body.views.find((view) => view.kind === "turn_ended");
|
|
28
|
+
if (ended?.kind === "turn_ended") {
|
|
29
|
+
return ended.outcome;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (record.kind === "response" && record.body.kind === "exited") {
|
|
33
|
+
return { kind: "failed", reason: "runtime exited", failure: "runtime_exited" };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve with the first turn end of the session's root agent recorded after
|
|
40
|
+
* `afterSeq`, from the retained log if it already happened, otherwise live.
|
|
41
|
+
* A derived child session's turn end never satisfies it.
|
|
42
|
+
*/
|
|
43
|
+
export async function awaitTurnEnd(session, afterSeq) {
|
|
44
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
45
|
+
let done = false;
|
|
46
|
+
const unsubscribe = session.subscribe((record) => {
|
|
47
|
+
if (done) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const outcome = turnEndAfter([record], afterSeq, session.id);
|
|
51
|
+
if (outcome !== null) {
|
|
52
|
+
done = true;
|
|
53
|
+
resolve(outcome);
|
|
54
|
+
}
|
|
55
|
+
}, { sessionId: session.id, afterSeq });
|
|
56
|
+
const outcome = await promise;
|
|
57
|
+
unsubscribe();
|
|
58
|
+
return outcome;
|
|
59
|
+
}
|
|
60
|
+
/** Prompt, then wait for the runtime to end the turn it opened. A rejected prompt (busy, dead runtime) returns without waiting. */
|
|
61
|
+
export async function promptAndWait(session, input) {
|
|
62
|
+
const result = await session.prompt(input);
|
|
63
|
+
if (result.response.body.kind !== "accepted") {
|
|
64
|
+
const reason = result.response.body.kind === "rejected" ? result.response.body.reason : result.response.body.kind;
|
|
65
|
+
return { kind: "rejected", result, reason };
|
|
66
|
+
}
|
|
67
|
+
const outcome = await awaitTurnEnd(session, result.request.seq);
|
|
68
|
+
return { kind: "ended", result, outcome };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=turns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turns.js","sourceRoot":"","sources":["../../src/observe/turns.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAiC,EACjC,QAAgB,EAChB,SAAkB;IAElB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,MAAM,CAAC,GAAG,IAAI,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1D,SAAS;QACX,CAAC;QACD,IAAI,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC9D,SAAS;QACX,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;YAC3E,IAAI,KA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C;IAC3C,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;QAClH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9C,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ContextUsage, SessionRecord, SessionUsage } from "../contracts/session.js";
|
|
2
|
+
/** The latest model the runtime reported for the root agent; null before any. */
|
|
3
|
+
export declare function modelOf(records: readonly SessionRecord[], sessionId?: string): string | null;
|
|
4
|
+
/** The latest context fullness the runtime reported for the root agent; null before any. */
|
|
5
|
+
export declare function contextUsageOf(records: readonly SessionRecord[], sessionId?: string): ContextUsage | null;
|
|
6
|
+
/**
|
|
7
|
+
* Session total plus a per-agent breakdown. Each agent's totals are the
|
|
8
|
+
* LATEST cumulative figure its records reported (adapters resolve their
|
|
9
|
+
* runtime's accounting into cumulative-per-agent before the record is
|
|
10
|
+
* stamped), so the breakdown is deduplicated by construction and sums to the
|
|
11
|
+
* total. Agents are the `agentPath`s of THIS session; derived child sessions
|
|
12
|
+
* are not agents of it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function usageOf(records: readonly SessionRecord[], sessionId?: string): SessionUsage;
|
|
15
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/observe/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,YAAY,EAEb,MAAM,yBAAyB,CAAC;AA2BjC,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW5F;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAWzG;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,CAwB3F"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query = projection over the stream. Model, token usage and context
|
|
3
|
+
* fullness are folds over seq-carrying records, never a second source of
|
|
4
|
+
* truth held beside the stream, so every answer can be aligned with the
|
|
5
|
+
* record that produced it and reproduced from a replay.
|
|
6
|
+
*
|
|
7
|
+
* Scope: one session. A derived child session (codex child thread, grok child
|
|
8
|
+
* session) carries its own `sessionId` and `agentPath []` on its records; it
|
|
9
|
+
* is a separate session, not a sub-agent of this one, so its figures are NOT
|
|
10
|
+
* folded into this session's answers. When `sessionId` is given, records of
|
|
11
|
+
* other sessions are skipped; the session graph says where the child came
|
|
12
|
+
* from and the child's own records hold its usage. Observed live on codex
|
|
13
|
+
* 0.149.0: both threads report `thread/tokenUsage/updated` with cumulative
|
|
14
|
+
* totals on the parent's connection, and without this scope the child's
|
|
15
|
+
* figure overwrote the root's under the same `agentPath []` key.
|
|
16
|
+
*/
|
|
17
|
+
function pathKey(agentPath) {
|
|
18
|
+
return JSON.stringify(agentPath);
|
|
19
|
+
}
|
|
20
|
+
function inSession(record, sessionId) {
|
|
21
|
+
return sessionId === undefined || record.sessionId === sessionId;
|
|
22
|
+
}
|
|
23
|
+
/** The latest model the runtime reported for the root agent; null before any. */
|
|
24
|
+
export function modelOf(records, sessionId) {
|
|
25
|
+
for (let index = records.length - 1; index >= 0; index -= 1) {
|
|
26
|
+
const record = records[index];
|
|
27
|
+
if (record?.kind === "event" && record.agentPath.length === 0 && inSession(record, sessionId)) {
|
|
28
|
+
const view = record.body.views.findLast((candidate) => candidate.kind === "model");
|
|
29
|
+
if (view?.kind === "model") {
|
|
30
|
+
return view.model;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
/** The latest context fullness the runtime reported for the root agent; null before any. */
|
|
37
|
+
export function contextUsageOf(records, sessionId) {
|
|
38
|
+
for (let index = records.length - 1; index >= 0; index -= 1) {
|
|
39
|
+
const record = records[index];
|
|
40
|
+
if (record?.kind === "event" && record.agentPath.length === 0 && inSession(record, sessionId)) {
|
|
41
|
+
const view = record.body.views.findLast((candidate) => candidate.kind === "usage" && candidate.usage.context !== undefined);
|
|
42
|
+
if (view?.kind === "usage" && view.usage.context !== undefined) {
|
|
43
|
+
return view.usage.context;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Session total plus a per-agent breakdown. Each agent's totals are the
|
|
51
|
+
* LATEST cumulative figure its records reported (adapters resolve their
|
|
52
|
+
* runtime's accounting into cumulative-per-agent before the record is
|
|
53
|
+
* stamped), so the breakdown is deduplicated by construction and sums to the
|
|
54
|
+
* total. Agents are the `agentPath`s of THIS session; derived child sessions
|
|
55
|
+
* are not agents of it.
|
|
56
|
+
*/
|
|
57
|
+
export function usageOf(records, sessionId) {
|
|
58
|
+
const latest = new Map();
|
|
59
|
+
for (const record of records) {
|
|
60
|
+
if (record.kind !== "event" || !inSession(record, sessionId)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
for (const view of record.body.views) {
|
|
64
|
+
if (view.kind === "usage" && view.usage.tokens !== undefined) {
|
|
65
|
+
latest.set(pathKey(record.agentPath), { agentPath: record.agentPath, tokens: view.usage.tokens });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const byAgent = [...latest.values()];
|
|
70
|
+
if (byAgent.length === 0) {
|
|
71
|
+
// Nothing reported yet (or a runtime whose interface never carries token
|
|
72
|
+
// totals): null, never a guessed zero.
|
|
73
|
+
return { total: null };
|
|
74
|
+
}
|
|
75
|
+
const total = byAgent.reduce((sum, entry) => ({ input: sum.input + entry.tokens.input, output: sum.output + entry.tokens.output }), { input: 0, output: 0 });
|
|
76
|
+
const onlyRoot = byAgent.length <= 1 && byAgent.every((entry) => entry.agentPath.length === 0);
|
|
77
|
+
return onlyRoot ? { total } : { total, byAgent };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/observe/usage.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AAEH,SAAS,OAAO,CAAC,SAA4B;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CAAC,MAAqB,EAAE,SAA6B;IACrE,OAAO,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC;AACnE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,OAAO,CAAC,OAAiC,EAAE,SAAkB;IAC3E,KAAK,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,MAA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AM,QAAQ,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;IAC/F,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -29,7 +29,7 @@ function credentialsFilePath() {
|
|
|
29
29
|
* Read Claude Code's persisted `/login` OAuth credential, mirroring the
|
|
30
30
|
* `getClaudeAIOAuthTokens()` fallback: the plaintext credentials file (Linux,
|
|
31
31
|
* and the macOS/Windows fallback), then the macOS Keychain, which stores the
|
|
32
|
-
* same JSON blob. Any failure degrades to `null
|
|
32
|
+
* same JSON blob. Any failure degrades to `null`; never throws.
|
|
33
33
|
*/
|
|
34
34
|
async function readStoredOAuth(timeoutMs) {
|
|
35
35
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContextUsage } from "../../contracts/session.js";
|
|
2
2
|
import { type JsonRecord } from "../../shared/json.js";
|
|
3
3
|
/**
|
|
4
|
-
* Claude reports context usage in the result frame (structured
|
|
4
|
+
* Claude reports context usage in the result frame (structured; no need for
|
|
5
5
|
* the human-facing /context command): usage.{input,cache_read,cache_creation}
|
|
6
6
|
* tokens are the context sent, and modelUsage[model].contextWindow is the
|
|
7
7
|
* window. We cache the latest as the current snapshot (last-write-wins).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asNumber, asRecord } from "../../shared/json.js";
|
|
2
2
|
/**
|
|
3
|
-
* Claude reports context usage in the result frame (structured
|
|
3
|
+
* Claude reports context usage in the result frame (structured; no need for
|
|
4
4
|
* the human-facing /context command): usage.{input,cache_read,cache_creation}
|
|
5
5
|
* tokens are the context sent, and modelUsage[model].contextWindow is the
|
|
6
6
|
* window. We cache the latest as the current snapshot (last-write-wins).
|
|
@@ -1,42 +1,55 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EventBody, ResponseBody, TokenTotals } from "../../contracts/session.js";
|
|
2
2
|
import { type JsonRecord } from "../../shared/json.js";
|
|
3
3
|
/**
|
|
4
|
-
* The claude stdout →
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* The claude stdout → record projection as a PURE FOLD. A reducer over the
|
|
5
|
+
* raw stream-json frames that emits kernel COMMANDS (append an event with its
|
|
6
|
+
* attribution, answer one of our control requests, surface a runtime→app
|
|
7
|
+
* request) instead of touching the kernel itself. The live adapter applies
|
|
8
|
+
* the commands to a real kernel; tests apply them to nothing and snapshot the
|
|
9
|
+
* list. No transport, no side effects, so it is trivially unit-testable and
|
|
10
|
+
* shared verbatim between live and replay.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Rules the fold enforces: EVERY frame becomes exactly one event record
|
|
13
|
+
* (verbatim `native`, views in block order); nothing is gated on whether a
|
|
14
|
+
* turn is "open"; the turn's end is claude's own `result` frame; attribution
|
|
15
|
+
* comes from `parent_tool_use_id` (a child's path is its parent's path plus
|
|
16
|
+
* the Task tool_use id that spawned it).
|
|
15
17
|
*/
|
|
16
18
|
export type ProjectionCommand = {
|
|
17
|
-
readonly kind: "
|
|
18
|
-
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
readonly
|
|
19
|
+
readonly kind: "event";
|
|
20
|
+
readonly body: EventBody;
|
|
21
|
+
readonly agentPath: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/** claude answered one of our `control_request`s (interrupt): the response to that request record. */
|
|
24
|
+
| {
|
|
25
|
+
readonly kind: "respond";
|
|
26
|
+
readonly requestId: string;
|
|
27
|
+
readonly body: ResponseBody;
|
|
28
|
+
}
|
|
29
|
+
/** claude asked US something (`control_request`): a toApp request record, verbatim. */
|
|
30
|
+
| {
|
|
31
|
+
readonly kind: "toApp";
|
|
32
|
+
readonly id: string;
|
|
33
|
+
readonly type: string;
|
|
34
|
+
readonly native: unknown;
|
|
24
35
|
};
|
|
25
36
|
/**
|
|
26
|
-
* Fold state. `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
37
|
+
* Fold state. `abortRequested` is the one input that is NOT in the provider
|
|
38
|
+
* stream: abort is a control-plane intent, and claude reports its result as
|
|
39
|
+
* an ordinary result frame, so the flag is how the fold tells aborted from
|
|
40
|
+
* completed. `agents` maps every tool_use id seen to the agentPath of the
|
|
41
|
+
* message that carried it, so a frame with `parent_tool_use_id` attributes to
|
|
42
|
+
* that tool call's agent plus the call; nested Task calls nest the path.
|
|
43
|
+
* `tokens` accumulates per-agent result usage so usage views are cumulative.
|
|
32
44
|
*/
|
|
33
45
|
export interface ClaudeProjectionState {
|
|
34
|
-
readonly inTurn: boolean;
|
|
35
46
|
readonly abortRequested: boolean;
|
|
47
|
+
readonly agents: ReadonlyMap<string, readonly string[]>;
|
|
48
|
+
readonly tokens: ReadonlyMap<string, TokenTotals>;
|
|
36
49
|
}
|
|
37
50
|
export declare const initialClaudeProjection: ClaudeProjectionState;
|
|
38
|
-
/** Control plane → state: a prompt
|
|
39
|
-
export declare function claudePrompted(): ClaudeProjectionState;
|
|
51
|
+
/** Control plane → state: a prompt clears any stale abort intent; an abort arms it. */
|
|
52
|
+
export declare function claudePrompted(state: ClaudeProjectionState): ClaudeProjectionState;
|
|
40
53
|
export declare function claudeAbortRequested(state: ClaudeProjectionState): ClaudeProjectionState;
|
|
41
54
|
/** Fold one parsed claude stdout frame into the next state plus commands. */
|
|
42
55
|
export declare function foldClaudeStdout(state: ClaudeProjectionState, message: JsonRecord): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../src/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ED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAExF;AAiID,6EAA6E;AAC7E,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,EAC5B,OAAO,EAAE,UAAU,GAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,CA8D5F"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { classifyFailure } from "../../shared/failure-class.js";
|
|
2
|
-
import { asRecord } from "../../shared/json.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { asNumber, asRecord } from "../../shared/json.js";
|
|
3
|
+
import { claudeContextUsageFromResult } from "./context-usage.js";
|
|
4
|
+
export const initialClaudeProjection = {
|
|
5
|
+
abortRequested: false,
|
|
6
|
+
agents: new Map(),
|
|
7
|
+
tokens: new Map(),
|
|
8
|
+
};
|
|
9
|
+
/** Control plane → state: a prompt clears any stale abort intent; an abort arms it. */
|
|
10
|
+
export function claudePrompted(state) {
|
|
11
|
+
return { ...state, abortRequested: false };
|
|
7
12
|
}
|
|
8
13
|
export function claudeAbortRequested(state) {
|
|
9
14
|
return { ...state, abortRequested: true };
|
|
@@ -16,7 +21,7 @@ function contentBlocks(message) {
|
|
|
16
21
|
}
|
|
17
22
|
return content.map((block) => asRecord(block)).filter((block) => block !== null);
|
|
18
23
|
}
|
|
19
|
-
function
|
|
24
|
+
function assistantViews(message) {
|
|
20
25
|
const out = [];
|
|
21
26
|
for (const block of contentBlocks(message)) {
|
|
22
27
|
switch (String(block.type)) {
|
|
@@ -53,7 +58,7 @@ function assistantEvents(message) {
|
|
|
53
58
|
}
|
|
54
59
|
return out;
|
|
55
60
|
}
|
|
56
|
-
function
|
|
61
|
+
function toolResultViews(message) {
|
|
57
62
|
const out = [];
|
|
58
63
|
for (const block of contentBlocks(message)) {
|
|
59
64
|
if (block.type === "tool_result" && typeof block.tool_use_id === "string") {
|
|
@@ -83,28 +88,109 @@ function resultOutcome(state, message) {
|
|
|
83
88
|
}
|
|
84
89
|
return { kind: "completed" };
|
|
85
90
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
function pathKey(agentPath) {
|
|
92
|
+
return JSON.stringify(agentPath);
|
|
93
|
+
}
|
|
94
|
+
/** The agent a frame belongs to: root, or the Task call that spawned it (nested through the call's own agent). */
|
|
95
|
+
function attributionOf(state, message) {
|
|
96
|
+
const parent = message.parent_tool_use_id;
|
|
97
|
+
if (typeof parent !== "string" || parent.length === 0) {
|
|
98
|
+
return [];
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
return [...(state.agents.get(parent) ?? []), parent];
|
|
101
|
+
}
|
|
102
|
+
function rememberToolUses(state, message, agentPath) {
|
|
103
|
+
const ids = contentBlocks(message)
|
|
104
|
+
.filter((block) => block.type === "tool_use" && typeof block.id === "string")
|
|
105
|
+
.map((block) => String(block.id));
|
|
106
|
+
if (ids.length === 0) {
|
|
107
|
+
return state;
|
|
108
|
+
}
|
|
109
|
+
const agents = new Map(state.agents);
|
|
110
|
+
for (const id of ids) {
|
|
111
|
+
agents.set(id, agentPath);
|
|
112
|
+
}
|
|
113
|
+
return { ...state, agents };
|
|
114
|
+
}
|
|
115
|
+
function frameType(message) {
|
|
116
|
+
const type = typeof message.type === "string" ? message.type : "unknown";
|
|
117
|
+
return typeof message.subtype === "string" ? `${type}/${message.subtype}` : type;
|
|
118
|
+
}
|
|
119
|
+
/** Cumulative per-agent tokens after folding this result frame's own turn usage. */
|
|
120
|
+
function accumulate(state, agentPath, message) {
|
|
121
|
+
const usage = asRecord(message.usage);
|
|
122
|
+
if (usage === null) {
|
|
123
|
+
return null;
|
|
95
124
|
}
|
|
125
|
+
const previous = state.tokens.get(pathKey(agentPath)) ?? { input: 0, output: 0 };
|
|
126
|
+
const tokens = {
|
|
127
|
+
input: previous.input + (asNumber(usage.input_tokens) ?? 0)
|
|
128
|
+
+ (asNumber(usage.cache_read_input_tokens) ?? 0) + (asNumber(usage.cache_creation_input_tokens) ?? 0),
|
|
129
|
+
output: previous.output + (asNumber(usage.output_tokens) ?? 0),
|
|
130
|
+
};
|
|
131
|
+
const next = new Map([...state.tokens, [pathKey(agentPath), tokens]]);
|
|
132
|
+
return { state: { ...state, tokens: next }, tokens };
|
|
133
|
+
}
|
|
134
|
+
/** Fold one parsed claude stdout frame into the next state plus commands. */
|
|
135
|
+
export function foldClaudeStdout(state, message) {
|
|
136
|
+
const type = frameType(message);
|
|
137
|
+
const agentPath = attributionOf(state, message);
|
|
138
|
+
const event = (body, next = state) => ({ state: next, commands: [{ kind: "event", body: { type, native: message, ...body }, agentPath }] });
|
|
96
139
|
switch (String(message.type)) {
|
|
97
140
|
case "assistant":
|
|
98
|
-
return {
|
|
141
|
+
return event({ views: assistantViews(message) }, rememberToolUses(state, message, agentPath));
|
|
99
142
|
case "user":
|
|
100
|
-
return {
|
|
101
|
-
case "result":
|
|
143
|
+
return event({ views: toolResultViews(message) });
|
|
144
|
+
case "result": {
|
|
145
|
+
const views = [{ kind: "turn_ended", outcome: resultOutcome(state, message) }];
|
|
146
|
+
const accumulated = accumulate(state, agentPath, message);
|
|
147
|
+
const context = claudeContextUsageFromResult(message);
|
|
148
|
+
if (accumulated !== null || context !== null) {
|
|
149
|
+
views.push({ kind: "usage", usage: {
|
|
150
|
+
...(context === null ? {} : { context }),
|
|
151
|
+
...(accumulated === null ? {} : { tokens: accumulated.tokens }),
|
|
152
|
+
} });
|
|
153
|
+
}
|
|
154
|
+
return event({ views }, { ...(accumulated?.state ?? state), abortRequested: false });
|
|
155
|
+
}
|
|
156
|
+
case "system": {
|
|
157
|
+
const model = message.subtype === "init" && typeof message.model === "string" ? message.model : null;
|
|
158
|
+
return event({ views: model === null ? [] : [{ kind: "model", model }] });
|
|
159
|
+
}
|
|
160
|
+
case "control_response": {
|
|
161
|
+
// claude answering one of OUR control_requests (interrupt): the frame IS
|
|
162
|
+
// the response record (native verbatim); one frame, one record, so it
|
|
163
|
+
// is not also recorded as an event. A control_response we cannot pair
|
|
164
|
+
// is recorded as a plain event.
|
|
165
|
+
const response = asRecord(message.response);
|
|
166
|
+
const requestId = typeof response?.request_id === "string" ? response.request_id : null;
|
|
167
|
+
if (requestId === null) {
|
|
168
|
+
return event({ views: [] });
|
|
169
|
+
}
|
|
170
|
+
const error = typeof response?.error === "string" ? response.error : null;
|
|
171
|
+
return { state, commands: [{
|
|
172
|
+
kind: "respond",
|
|
173
|
+
requestId,
|
|
174
|
+
body: response?.subtype === "error" || error !== null
|
|
175
|
+
? { kind: "rejected", reason: error ?? "control request failed", native: message }
|
|
176
|
+
: { kind: "accepted", native: message },
|
|
177
|
+
}] };
|
|
178
|
+
}
|
|
179
|
+
case "control_request": {
|
|
180
|
+
// claude asks the app something (permission, question). Recorded verbatim; the adapter answers nothing.
|
|
181
|
+
const id = typeof message.request_id === "string" ? message.request_id : `claude-${String(Date.now())}`;
|
|
182
|
+
const request = asRecord(message.request);
|
|
183
|
+
const subtype = typeof request?.subtype === "string" ? request.subtype : "control_request";
|
|
102
184
|
return {
|
|
103
|
-
state
|
|
104
|
-
commands: [
|
|
185
|
+
state,
|
|
186
|
+
commands: [
|
|
187
|
+
{ kind: "event", body: { type, native: message, views: [] }, agentPath },
|
|
188
|
+
{ kind: "toApp", id, type: subtype, native: message },
|
|
189
|
+
],
|
|
105
190
|
};
|
|
191
|
+
}
|
|
106
192
|
default:
|
|
107
|
-
return {
|
|
193
|
+
return event({ views: [] });
|
|
108
194
|
}
|
|
109
195
|
}
|
|
110
196
|
//# sourceMappingURL=projection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/runtimes/claude/projection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"projection.js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,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;YACxG,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,OAAO,OAAO,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC;YAC3F,OAAO;gBACL,KAAK;gBACL,QAAQ,EAAE;oBACR,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;oBACxE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;iBACtD;aACF,CAAC;QACJ,CAAC;QACD;YACE,OAAO,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/runtimes/claude/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,YAAY,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/runtimes/claude/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,YAAY,EACb,MAAM,4BAA4B,CAAC;AA8CpC,eAAO,MAAM,aAAa,EAAE,YAqL3B,CAAC"}
|