@excitedjs/agent-runtime-claude-code 0.7.0-alpha.g72af66e58ab3 → 0.7.0-alpha.g91feafcb30a7
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 +17 -29
- package/dist/control-rpc.d.ts +21 -0
- package/dist/control-rpc.d.ts.map +1 -0
- package/dist/control-rpc.js +103 -0
- package/dist/control-rpc.js.map +1 -0
- package/dist/rpc.d.ts +25 -20
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +98 -106
- package/dist/rpc.js.map +1 -1
- package/dist/runtime-submissions.d.ts +9 -10
- package/dist/runtime-submissions.d.ts.map +1 -1
- package/dist/runtime-submissions.js +75 -7
- package/dist/runtime-submissions.js.map +1 -1
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +28 -13
- package/dist/runtime.js.map +1 -1
- package/dist/stream.d.ts +5 -7
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +14 -12
- package/dist/stream.js.map +1 -1
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +15 -0
- package/dist/supervisor.js.map +1 -1
- package/dist/types.d.ts +7 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,25 +35,24 @@ through the same package-loader path as external `npm:` providers.
|
|
|
35
35
|
## Turn lifecycle
|
|
36
36
|
|
|
37
37
|
The public runtime boundary returns one `RuntimeSubmission` handle per accepted
|
|
38
|
-
send
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
send, settled by an immutable provider-owned `RuntimeCompletion` created at each
|
|
39
|
+
real native result boundary. Inputs merged before session creation and supported
|
|
40
|
+
live steering settle with the same completion object; queued sends settle with
|
|
41
|
+
distinct completions in native order. Command UUIDs are private wire aliases;
|
|
42
|
+
when `msg_lifecycle_v1` is available, all aliases must reach a terminal command
|
|
43
|
+
state and a final result must be captured before the object settles. Live steer
|
|
44
|
+
fails loudly without that capability. Runtime stop fences queued session work,
|
|
45
|
+
terminates the supervised process group with absence proof, and resolves every
|
|
46
|
+
unsettled public object as stopped.
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
written, while `ambiguous` means a native write may have been accepted and must
|
|
53
|
-
not be retried automatically. Runtime stop synchronously fences new input,
|
|
54
|
-
releases pending capability/write waiters, terminates the supervised process
|
|
55
|
-
group with absence proof, resolves unsettled submissions as stopped, and drains
|
|
56
|
-
already-started admission calls before it resolves.
|
|
48
|
+
Source deduplication is provider-private. A source is reserved while its native
|
|
49
|
+
admission is in flight, committed only after acceptance or an ambiguous
|
|
50
|
+
post-write failure, and released after a proven pre-write failure. Concurrent
|
|
51
|
+
uses of the same reserved source share the same admission outcome. Accordingly,
|
|
52
|
+
`failed` means the command was proven not written, while `ambiguous` means a
|
|
53
|
+
native write may have been accepted and must not be retried automatically.
|
|
54
|
+
Runtime stop synchronously fences new input, releases pending capability/write
|
|
55
|
+
waiters, and drains all already-started admission calls before it resolves.
|
|
57
56
|
|
|
58
57
|
## Native sessions and transcripts
|
|
59
58
|
|
|
@@ -73,14 +72,3 @@ message/tool blocks in chronological order, and owns opaque cursors, query and
|
|
|
73
72
|
rewrite mismatch detection, payload redaction/truncation, and the fixed host
|
|
74
73
|
output budget. Native command/session IDs and filesystem paths never appear in
|
|
75
74
|
transcript pages.
|
|
76
|
-
|
|
77
|
-
## Custom session factories
|
|
78
|
-
|
|
79
|
-
A custom `ClaudeCodeSessionFactory` that emits `onProtocolEvent` results must
|
|
80
|
-
include `commandUuids`: the submitted commands answered by that result. Use an
|
|
81
|
-
empty array for a native turn with no related submission. Folded inputs share
|
|
82
|
-
one result and its command group; a queued input is included only in the result
|
|
83
|
-
that answers it. The default session computes this group from native command
|
|
84
|
-
lifecycle and matching result UUID evidence. The turn's original trigger does
|
|
85
|
-
not decide completion delivery. This Claude-specific callback requirement does
|
|
86
|
-
not change the neutral `AgentRuntime` or `RuntimeSubmission` contracts.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Writable } from 'node:stream';
|
|
2
|
+
interface InterruptibleTurn {
|
|
3
|
+
interruptRequested: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class ClaudeCodeControlRpc {
|
|
6
|
+
private readonly stdin;
|
|
7
|
+
private readonly options;
|
|
8
|
+
private remoteControlRequestId;
|
|
9
|
+
private pendingInterrupt;
|
|
10
|
+
constructor(stdin: Writable, options: {
|
|
11
|
+
log?: (level: 'info' | 'warn' | 'error', msg: string, err?: unknown) => void;
|
|
12
|
+
onRemoteControlUrl?: (url: string) => void;
|
|
13
|
+
});
|
|
14
|
+
interruptTurn(turn: InterruptibleTurn | null, reason: string): Promise<boolean>;
|
|
15
|
+
settleTurn(turn: InterruptibleTurn, failure?: Error, interrupted?: boolean): void;
|
|
16
|
+
enableRemoteControl(): void;
|
|
17
|
+
onControlRequest(requestId: string | null, subtype: string | null, request: Record<string, unknown>): void;
|
|
18
|
+
onControlResponse(requestId: string | null, ok: boolean, response: Record<string, unknown> | null, error: string | null): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=control-rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-rpc.d.ts","sourceRoot":"","sources":["../src/control-rpc.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAS5C,UAAU,iBAAiB;IACzB,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAUD,qBAAa,oBAAoB;IAK7B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,sBAAsB,CAAuB;IACrD,OAAO,CAAC,gBAAgB,CAAiC;gBAGtC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE;QACxB,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;QAC7E,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;KAC5C;IAGH,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuB/E,UAAU,CACR,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,KAAK,EACf,WAAW,UAAQ,GAClB,IAAI;IAQP,mBAAmB,IAAI,IAAI;IAM3B,gBAAgB,CACd,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI;IAoBP,iBAAiB,CACf,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,EAAE,EAAE,OAAO,EACX,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACxC,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,IAAI;CA+BR"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Claude Code stream-json control requests and their one pending reply. */
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { buildCanUseToolAllow, buildControlAck, buildInterruptRequest, buildRemoteControlEnable, } from './stream.js';
|
|
4
|
+
export class ClaudeCodeControlRpc {
|
|
5
|
+
stdin;
|
|
6
|
+
options;
|
|
7
|
+
remoteControlRequestId = null;
|
|
8
|
+
pendingInterrupt = null;
|
|
9
|
+
constructor(stdin, options) {
|
|
10
|
+
this.stdin = stdin;
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
interruptTurn(turn, reason) {
|
|
14
|
+
if (turn === null)
|
|
15
|
+
return Promise.resolve(false);
|
|
16
|
+
if (this.pendingInterrupt !== null)
|
|
17
|
+
return this.pendingInterrupt.promise;
|
|
18
|
+
const requestId = randomUUID();
|
|
19
|
+
let resolve;
|
|
20
|
+
let reject;
|
|
21
|
+
const promise = new Promise((resolvePromise, rejectPromise) => {
|
|
22
|
+
resolve = resolvePromise;
|
|
23
|
+
reject = rejectPromise;
|
|
24
|
+
});
|
|
25
|
+
const pending = { requestId, turn, promise, resolve, reject };
|
|
26
|
+
turn.interruptRequested = true;
|
|
27
|
+
this.pendingInterrupt = pending;
|
|
28
|
+
this.stdin.write(`${buildInterruptRequest(requestId, reason)}\n`, (error) => {
|
|
29
|
+
if (error != null && this.pendingInterrupt === pending) {
|
|
30
|
+
this.pendingInterrupt = null;
|
|
31
|
+
turn.interruptRequested = false;
|
|
32
|
+
reject(error);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return promise;
|
|
36
|
+
}
|
|
37
|
+
settleTurn(turn, failure, interrupted = false) {
|
|
38
|
+
const pending = this.pendingInterrupt;
|
|
39
|
+
if (pending?.turn !== turn)
|
|
40
|
+
return;
|
|
41
|
+
this.pendingInterrupt = null;
|
|
42
|
+
if (failure !== undefined)
|
|
43
|
+
pending.reject(failure);
|
|
44
|
+
else
|
|
45
|
+
pending.resolve(interrupted);
|
|
46
|
+
}
|
|
47
|
+
enableRemoteControl() {
|
|
48
|
+
if (!this.stdin.writable)
|
|
49
|
+
return;
|
|
50
|
+
this.remoteControlRequestId = randomUUID();
|
|
51
|
+
this.stdin.write(`${buildRemoteControlEnable(this.remoteControlRequestId)}\n`);
|
|
52
|
+
}
|
|
53
|
+
onControlRequest(requestId, subtype, request) {
|
|
54
|
+
if (requestId === null || !this.stdin.writable)
|
|
55
|
+
return;
|
|
56
|
+
// Unattended posture: answer permission callbacks so a turn never wedges
|
|
57
|
+
// waiting on a human.
|
|
58
|
+
let reply;
|
|
59
|
+
if (subtype === 'can_use_tool') {
|
|
60
|
+
const rawInput = request['input'];
|
|
61
|
+
const input = typeof rawInput === 'object' &&
|
|
62
|
+
rawInput !== null &&
|
|
63
|
+
!Array.isArray(rawInput)
|
|
64
|
+
? rawInput
|
|
65
|
+
: {};
|
|
66
|
+
reply = buildCanUseToolAllow(requestId, input);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
reply = buildControlAck(requestId);
|
|
70
|
+
}
|
|
71
|
+
this.stdin.write(`${reply}\n`);
|
|
72
|
+
}
|
|
73
|
+
onControlResponse(requestId, ok, response, error) {
|
|
74
|
+
if (requestId === null)
|
|
75
|
+
return;
|
|
76
|
+
const interrupt = this.pendingInterrupt;
|
|
77
|
+
if (interrupt !== null && requestId === interrupt.requestId) {
|
|
78
|
+
this.pendingInterrupt = null;
|
|
79
|
+
if (ok)
|
|
80
|
+
interrupt.resolve(true);
|
|
81
|
+
else {
|
|
82
|
+
interrupt.turn.interruptRequested = false;
|
|
83
|
+
interrupt.reject(new Error(error ?? 'claude interrupt request failed'));
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (requestId !== this.remoteControlRequestId)
|
|
88
|
+
return;
|
|
89
|
+
this.remoteControlRequestId = null;
|
|
90
|
+
if (ok && response !== null) {
|
|
91
|
+
const url = response['session_url'] ?? response['connect_url'];
|
|
92
|
+
if (typeof url === 'string') {
|
|
93
|
+
this.options.onRemoteControlUrl?.(url);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.options.log?.('warn', 'claude remote control enable succeeded without a URL');
|
|
97
|
+
}
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.options.log?.('warn', `claude remote control enable failed${error !== null ? `: ${error}` : ''}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=control-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-rpc.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AC;iBAAM,CAAC;gBACN,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAChB,MAAM,EACN,sDAAsD,CACvD,CAAC;YACJ,CAAC;YACD,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAChB,MAAM,EACN,sCAAsC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC3E,CAAC;IACJ,CAAC;CACF"}
|
package/dist/rpc.d.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Claude Code stream-json turn RPC.
|
|
3
3
|
*
|
|
4
4
|
* The supervisor owns the child process. This class owns one in-flight command
|
|
5
|
-
* group,
|
|
6
|
-
* and defensive control replies.
|
|
5
|
+
* group, stdout line demux, command drainage, and defensive control replies.
|
|
7
6
|
*
|
|
8
7
|
* One resident CLI execution window can span several submitted commands: a
|
|
9
8
|
* live steer is written while the CLI is already running. How the CLI answers them is
|
|
@@ -17,17 +16,16 @@
|
|
|
17
16
|
* - **Or they do not.** A command that arrives between turns runs on its own
|
|
18
17
|
* and gets its own `result`.
|
|
19
18
|
* - **`result.user_message_uuid` is not a completion ledger.** It is present
|
|
20
|
-
* only sometimes
|
|
21
|
-
* is
|
|
22
|
-
*
|
|
19
|
+
* only sometimes and is not reliably the first-submitted uuid of a fold. It
|
|
20
|
+
* is present on the artifact an accepted interrupt produces (measured
|
|
21
|
+
* against claude 2.1.263), so presence does not mean "this is an answer".
|
|
23
22
|
* - **`command_lifecycle` is the attribution signal.** Started commands identify
|
|
24
23
|
* the submissions represented by the next native `result`; terminal states
|
|
25
24
|
* drain the resident execution window. Its ordering against `result` is not
|
|
26
25
|
* stable.
|
|
27
26
|
*
|
|
28
|
-
* Every valid `result` is forwarded immediately as its own native
|
|
29
|
-
*
|
|
30
|
-
* and attributed results decide when the command group has
|
|
27
|
+
* Every valid `result` is forwarded immediately as its own native completion
|
|
28
|
+
* boundary. Lifecycle terminality only decides when the command group has
|
|
31
29
|
* drained and the resident session may accept a new initial command; it never
|
|
32
30
|
* aggregates several results into one completion.
|
|
33
31
|
*/
|
|
@@ -49,26 +47,36 @@ export declare class ClaudeCodeStreamRpc {
|
|
|
49
47
|
private readonly stdin;
|
|
50
48
|
private readonly options;
|
|
51
49
|
private readonly lineBuf;
|
|
52
|
-
private readonly aggregator;
|
|
53
50
|
private pending;
|
|
54
51
|
private lifecycleSupported;
|
|
55
|
-
private
|
|
52
|
+
private readonly control;
|
|
56
53
|
constructor(stdin: Writable, options: ClaudeCodeStreamRpcOptions);
|
|
57
54
|
submitTurn(prompt: string, options?: TurnSubmitOptions, commandUuid?: string): Promise<void>;
|
|
58
55
|
steerTurn(prompt: string, options?: TurnSubmitOptions, commandUuid?: string): Promise<void>;
|
|
59
56
|
private writeSteer;
|
|
60
57
|
onStdoutChunk(chunk: string): void;
|
|
61
58
|
failPending(err: Error): void;
|
|
59
|
+
interruptTurn(reason: string): Promise<boolean>;
|
|
62
60
|
enableRemoteControl(): void;
|
|
63
61
|
/**
|
|
64
62
|
* Detach the in-flight turn: clear its deadline timer and null `pending`,
|
|
65
63
|
* returning it so the caller can resolve or reject it exactly once.
|
|
66
64
|
*/
|
|
67
65
|
private settlePending;
|
|
66
|
+
/**
|
|
67
|
+
* End the execution window on the artifact of an accepted interrupt. This is
|
|
68
|
+
* the only settlement an interrupt has, deliberately: a lifecycle
|
|
69
|
+
* `cancelled` for the same command arrives *after* the artifact and is then
|
|
70
|
+
* a no-op, so no path can settle the turn early and leave the artifact to
|
|
71
|
+
* arrive against an empty `pending` — which the `result` case reads as an
|
|
72
|
+
* unattributable envelope and answers by reaping the resident child.
|
|
73
|
+
*/
|
|
74
|
+
private settleInterrupted;
|
|
68
75
|
/**
|
|
69
76
|
* Mark a submitted command as producing nothing further, then re-check
|
|
70
|
-
*
|
|
71
|
-
* and a short phrase for a command
|
|
77
|
+
* settlement. `abnormalReason` is `null` for the normal ending (`completed`)
|
|
78
|
+
* and a short phrase for a command that never ran — those are logged,
|
|
79
|
+
* because the CLI gives no other trace of a command it declined.
|
|
72
80
|
*
|
|
73
81
|
* A command ending abnormally never fails the turn by itself: the probe
|
|
74
82
|
* shows a `cancelled` command coexisting with another that answers normally
|
|
@@ -78,22 +86,21 @@ export declare class ClaudeCodeStreamRpc {
|
|
|
78
86
|
private markCommandTerminal;
|
|
79
87
|
/**
|
|
80
88
|
* The drainage gate: every submitted command has reached a terminal
|
|
81
|
-
* lifecycle state
|
|
82
|
-
*
|
|
83
|
-
* condition. Each native boundary has already been forwarded separately.
|
|
89
|
+
* lifecycle state AND at least one valid `result` has been seen. Result
|
|
90
|
+
* identity and settlement have already been forwarded one-by-one.
|
|
84
91
|
*
|
|
85
92
|
* Two escapes, both anti-hang:
|
|
86
93
|
*
|
|
87
94
|
* - no lifecycle signal at all (`msg_lifecycle_v1` absent, so no
|
|
88
95
|
* `command_lifecycle` will ever arrive) — the `result` is then the only
|
|
89
96
|
* terminal event there is, so settle on it;
|
|
90
|
-
* - every command terminal, none
|
|
91
|
-
*
|
|
97
|
+
* - every command terminal, none of them ever ran, and no result — nothing
|
|
98
|
+
* can answer this turn, so fail it loudly. The idle deadline is not an
|
|
92
99
|
* acceptable backstop here: it reaps the resident child, and any inbound
|
|
93
100
|
* line re-arms it, so a healthy session could be killed long after the
|
|
94
101
|
* turn became unanswerable.
|
|
95
102
|
*
|
|
96
|
-
* When a command
|
|
103
|
+
* When a command *did* run but no result has arrived yet, this waits: the
|
|
97
104
|
* probe shows terminal lifecycle states arriving both before and after the
|
|
98
105
|
* result they belong to, so "terminal, therefore no result is coming" is not
|
|
99
106
|
* a sound inference.
|
|
@@ -114,7 +121,5 @@ export declare class ClaudeCodeStreamRpc {
|
|
|
114
121
|
private resolveWriteWaiter;
|
|
115
122
|
private rejectWriteWaiter;
|
|
116
123
|
private rejectWriteWaiters;
|
|
117
|
-
private onControlRequest;
|
|
118
|
-
private onControlResponse;
|
|
119
124
|
}
|
|
120
125
|
//# sourceMappingURL=rpc.d.ts.map
|
package/dist/rpc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAU5C,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqDhE,gFAAgF;AAChF,qBAAa,yBAA0B,SAAQ,KAAK;IAEhD,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,WAAW;gBAAjC,SAAS,EAAE,QAAQ,GAAG,WAAW,EAC1C,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7E,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,eAAe,CAAC,EAAE,OAAO,YAAY,EAAE,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;CACjF;AAED,qBAAa,mBAAmB;IAO5B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,kBAAkB,CAAwB;IAClD,OAAO,CAAC,QA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