@excitedjs/agent-runtime-claude-code 0.5.0-beta.168 → 0.5.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 +43 -1
- package/dist/args.d.ts +2 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +5 -0
- package/dist/args.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +5 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +10 -4
- package/dist/provider.js.map +1 -1
- package/dist/rpc.d.ts +79 -6
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +329 -57
- package/dist/rpc.js.map +1 -1
- package/dist/runtime-deps.d.ts +30 -0
- package/dist/runtime-deps.d.ts.map +1 -0
- package/dist/runtime-deps.js +2 -0
- package/dist/runtime-deps.js.map +1 -0
- package/dist/runtime-session.d.ts +13 -0
- package/dist/runtime-session.d.ts.map +1 -0
- package/dist/runtime-session.js +41 -0
- package/dist/runtime-session.js.map +1 -0
- package/dist/runtime-submissions.d.ts +34 -0
- package/dist/runtime-submissions.d.ts.map +1 -0
- package/dist/runtime-submissions.js +200 -0
- package/dist/runtime-submissions.js.map +1 -0
- package/dist/runtime.d.ts +33 -131
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +286 -268
- package/dist/runtime.js.map +1 -1
- package/dist/skill-adapter.d.ts +11 -1
- package/dist/skill-adapter.d.ts.map +1 -1
- package/dist/skill-adapter.js +60 -7
- package/dist/skill-adapter.js.map +1 -1
- package/dist/skill-materializer.d.ts +6 -0
- package/dist/skill-materializer.d.ts.map +1 -0
- package/dist/skill-materializer.js +45 -0
- package/dist/skill-materializer.js.map +1 -0
- package/dist/source-reservation.d.ts +6 -0
- package/dist/source-reservation.d.ts.map +1 -0
- package/dist/source-reservation.js +48 -0
- package/dist/source-reservation.js.map +1 -0
- package/dist/stream.d.ts +3 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +48 -1
- package/dist/stream.js.map +1 -1
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +68 -14
- package/dist/supervisor.js.map +1 -1
- package/dist/transcript/budget.d.ts +8 -0
- package/dist/transcript/budget.d.ts.map +1 -0
- package/dist/transcript/budget.js +9 -0
- package/dist/transcript/budget.js.map +1 -0
- package/dist/transcript/completion.d.ts +8 -0
- package/dist/transcript/completion.d.ts.map +1 -0
- package/dist/transcript/completion.js +57 -0
- package/dist/transcript/completion.js.map +1 -0
- package/dist/transcript/cursor.d.ts +25 -0
- package/dist/transcript/cursor.d.ts.map +1 -0
- package/dist/transcript/cursor.js +62 -0
- package/dist/transcript/cursor.js.map +1 -0
- package/dist/transcript/error.d.ts +9 -0
- package/dist/transcript/error.d.ts.map +1 -0
- package/dist/transcript/error.js +9 -0
- package/dist/transcript/error.js.map +1 -0
- package/dist/transcript/native-hash.d.ts +2 -0
- package/dist/transcript/native-hash.d.ts.map +1 -0
- package/dist/transcript/native-hash.js +79 -0
- package/dist/transcript/native-hash.js.map +1 -0
- package/dist/transcript/opened-file.d.ts +13 -0
- package/dist/transcript/opened-file.d.ts.map +1 -0
- package/dist/transcript/opened-file.js +110 -0
- package/dist/transcript/opened-file.js.map +1 -0
- package/dist/transcript/parallel-tools.d.ts +6 -0
- package/dist/transcript/parallel-tools.d.ts.map +1 -0
- package/dist/transcript/parallel-tools.js +123 -0
- package/dist/transcript/parallel-tools.js.map +1 -0
- package/dist/transcript/path.d.ts +25 -0
- package/dist/transcript/path.d.ts.map +1 -0
- package/dist/transcript/path.js +253 -0
- package/dist/transcript/path.js.map +1 -0
- package/dist/transcript/reader.d.ts +7 -0
- package/dist/transcript/reader.d.ts.map +1 -0
- package/dist/transcript/reader.js +476 -0
- package/dist/transcript/reader.js.map +1 -0
- package/dist/transcript/rewrites.d.ts +5 -0
- package/dist/transcript/rewrites.d.ts.map +1 -0
- package/dist/transcript/rewrites.js +65 -0
- package/dist/transcript/rewrites.js.map +1 -0
- package/dist/types.d.ts +33 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ClaudeCodeSession } from './supervisor.js';
|
|
2
|
+
import type { ClaudeProtocolEvent, TurnSubmitOptions } from './types.js';
|
|
3
|
+
import type { JsonValue, RuntimeActivitySink, RuntimeSubmission, RuntimeSubmissionSettlement } from '@excitedjs/dreamux-types';
|
|
4
|
+
export interface SubmissionDeferred {
|
|
5
|
+
submission: RuntimeSubmission;
|
|
6
|
+
settle: (settlement: RuntimeSubmissionSettlement) => boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ActiveTurn {
|
|
9
|
+
initialCommandUuid: string;
|
|
10
|
+
submissions: Map<string, SubmissionDeferred>;
|
|
11
|
+
started: string[];
|
|
12
|
+
completedCommands: Set<string>;
|
|
13
|
+
activitySequence: number;
|
|
14
|
+
tools: Map<string, {
|
|
15
|
+
name: string;
|
|
16
|
+
arguments: JsonValue | null;
|
|
17
|
+
}>;
|
|
18
|
+
session: ClaudeCodeSession | null;
|
|
19
|
+
sessionReady: Promise<ClaudeCodeSession>;
|
|
20
|
+
resolveSession: (session: ClaudeCodeSession) => void;
|
|
21
|
+
rejectSession: (error: Error) => void;
|
|
22
|
+
steerQueue: Promise<void>;
|
|
23
|
+
generation: number;
|
|
24
|
+
submitOptions?: TurnSubmitOptions;
|
|
25
|
+
}
|
|
26
|
+
export interface ProtocolEventContext {
|
|
27
|
+
threadId: string | null;
|
|
28
|
+
outputSchemaEnabled: boolean;
|
|
29
|
+
activitySink: RuntimeActivitySink;
|
|
30
|
+
log: (level: 'info' | 'warn' | 'error', message: string, error?: unknown) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createRuntimeSubmission(): SubmissionDeferred;
|
|
33
|
+
export declare function handleProtocolEvent(active: ActiveTurn, event: ClaudeProtocolEvent, context: ProtocolEventContext): void;
|
|
34
|
+
//# sourceMappingURL=runtime-submissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-submissions.d.ts","sourceRoot":"","sources":["../src/runtime-submissions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAe,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,KAAK,EACV,SAAS,EAET,mBAAmB,EAEnB,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,MAAM,EAAE,CAAC,UAAU,EAAE,2BAA2B,KAAK,OAAO,CAAC;CAC9D;AAED,MAAM,WAAW,UAAU;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAClE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACzC,cAAc,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE,mBAAmB,CAAC;IAClC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACnF;AAED,wBAAgB,uBAAuB,IAAI,kBAAkB,CAiB5D;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,oBAAoB,GAC5B,IAAI,CAkBN"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { resultTextFromTurnOutcome } from './runtime-session.js';
|
|
2
|
+
export function createRuntimeSubmission() {
|
|
3
|
+
let resolve;
|
|
4
|
+
let settled = false;
|
|
5
|
+
const submission = Object.freeze({
|
|
6
|
+
settled: new Promise((value) => {
|
|
7
|
+
resolve = value;
|
|
8
|
+
}),
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
submission,
|
|
12
|
+
settle(settlement) {
|
|
13
|
+
if (settled)
|
|
14
|
+
return false;
|
|
15
|
+
settled = true;
|
|
16
|
+
resolve(settlement);
|
|
17
|
+
return true;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function handleProtocolEvent(active, event, context) {
|
|
22
|
+
if (event.kind === 'command_lifecycle') {
|
|
23
|
+
if (event.state === 'started' &&
|
|
24
|
+
active.submissions.has(event.commandUuid) &&
|
|
25
|
+
!active.completedCommands.has(event.commandUuid) &&
|
|
26
|
+
!active.started.includes(event.commandUuid)) {
|
|
27
|
+
active.started.push(event.commandUuid);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (event.kind === 'result') {
|
|
32
|
+
completeStartedGroup(active, event.outcome, context);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const raw = recordValue(event.line.raw);
|
|
36
|
+
if (raw !== null)
|
|
37
|
+
emitStreamActivity(active, raw, context);
|
|
38
|
+
}
|
|
39
|
+
function completeStartedGroup(active, outcome, context) {
|
|
40
|
+
const commandUuids = active.started.splice(0);
|
|
41
|
+
if (commandUuids.length === 0 &&
|
|
42
|
+
(active.submissions.size > 1 || active.completedCommands.size > 0)) {
|
|
43
|
+
failUnattributedResult(active, context);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (const uuid of commandUuids)
|
|
47
|
+
active.completedCommands.add(uuid);
|
|
48
|
+
let representative = commandUuids
|
|
49
|
+
.map(uuid => active.submissions.get(uuid))
|
|
50
|
+
.find((deferred) => deferred !== undefined);
|
|
51
|
+
if (representative === undefined && active.submissions.size === 1) {
|
|
52
|
+
const only = active.submissions.entries().next().value;
|
|
53
|
+
if (only !== undefined) {
|
|
54
|
+
commandUuids.push(only[0]);
|
|
55
|
+
representative = only[1];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (representative === undefined) {
|
|
59
|
+
failUnattributedResult(active, context);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let completion;
|
|
63
|
+
if (outcome.isError) {
|
|
64
|
+
completion = Object.freeze({
|
|
65
|
+
status: 'failed',
|
|
66
|
+
displaySubmission: representative.submission,
|
|
67
|
+
error: new Error(outcome.errors.join('; ') || outcome.subtype || 'claude turn failed'),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
try {
|
|
72
|
+
completion = Object.freeze({
|
|
73
|
+
status: 'completed',
|
|
74
|
+
displaySubmission: representative.submission,
|
|
75
|
+
resultText: resultTextFromTurnOutcome(outcome, context.threadId, context.outputSchemaEnabled),
|
|
76
|
+
truncated: false,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
completion = Object.freeze({
|
|
81
|
+
status: 'failed',
|
|
82
|
+
displaySubmission: representative.submission,
|
|
83
|
+
error: asError(error),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
for (const uuid of commandUuids) {
|
|
88
|
+
active.submissions.get(uuid)?.settle({ kind: 'completion', completion });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function failUnattributedResult(active, context) {
|
|
92
|
+
const error = new Error(active.completedCommands.size > 0
|
|
93
|
+
? 'claude emitted a conflicting result without a new started command'
|
|
94
|
+
: 'claude result cannot be attributed without command started lifecycle');
|
|
95
|
+
context.log('error', error.message, error);
|
|
96
|
+
for (const deferred of active.submissions.values()) {
|
|
97
|
+
deferred.settle({ kind: 'failed', error });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function emitStreamActivity(active, raw, context) {
|
|
101
|
+
const representativeUuid = active.started[0] ?? (active.submissions.size === 1
|
|
102
|
+
? active.submissions.keys().next().value
|
|
103
|
+
: undefined);
|
|
104
|
+
if (representativeUuid === undefined)
|
|
105
|
+
return;
|
|
106
|
+
const representative = active.submissions.get(representativeUuid);
|
|
107
|
+
if (representative === undefined)
|
|
108
|
+
return;
|
|
109
|
+
const message = recordValue(raw['message']) ?? raw;
|
|
110
|
+
const messageId = stringValue(message['id']) ?? `stream-${active.activitySequence++}`;
|
|
111
|
+
const content = Array.isArray(message['content']) ? message['content'] : [];
|
|
112
|
+
for (const [blockIndex, candidate] of content.entries()) {
|
|
113
|
+
const block = recordValue(candidate);
|
|
114
|
+
if (block === null)
|
|
115
|
+
continue;
|
|
116
|
+
const activity = activityForBlock(active, messageId, blockIndex, block);
|
|
117
|
+
if (activity === null)
|
|
118
|
+
continue;
|
|
119
|
+
try {
|
|
120
|
+
context.activitySink(Object.freeze({
|
|
121
|
+
submission: representative.submission,
|
|
122
|
+
activity: Object.freeze(activity),
|
|
123
|
+
occurredAt: Date.now(),
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
context.log('warn', 'claude activity projection failed', error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function activityForBlock(active, messageId, blockIndex, block) {
|
|
132
|
+
if (block['type'] === 'text' && typeof block['text'] === 'string' && block['text'] !== '') {
|
|
133
|
+
return {
|
|
134
|
+
kind: 'assistant.message',
|
|
135
|
+
id: `${messageId}:text:${blockIndex}`,
|
|
136
|
+
text: block['text'],
|
|
137
|
+
truncated: false,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (block['type'] === 'tool_use') {
|
|
141
|
+
const callId = stringValue(block['id']);
|
|
142
|
+
const name = stringValue(block['name']);
|
|
143
|
+
if (callId === null || callId === '' || name === null)
|
|
144
|
+
return null;
|
|
145
|
+
const args = toJsonValue(block['input']);
|
|
146
|
+
active.tools.set(callId, { name, arguments: args });
|
|
147
|
+
return {
|
|
148
|
+
kind: 'tool.call',
|
|
149
|
+
id: `${messageId}:${callId}:started`,
|
|
150
|
+
callId,
|
|
151
|
+
toolName: name,
|
|
152
|
+
status: 'started',
|
|
153
|
+
arguments: args,
|
|
154
|
+
result: null,
|
|
155
|
+
error: null,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (block['type'] !== 'tool_result')
|
|
159
|
+
return null;
|
|
160
|
+
const callId = stringValue(block['tool_use_id']);
|
|
161
|
+
if (callId === null || callId === '')
|
|
162
|
+
return null;
|
|
163
|
+
const known = active.tools.get(callId);
|
|
164
|
+
const failed = block['is_error'] === true;
|
|
165
|
+
return {
|
|
166
|
+
kind: 'tool.call',
|
|
167
|
+
id: `${messageId}:${callId}:result`,
|
|
168
|
+
callId,
|
|
169
|
+
toolName: known?.name ?? 'tool',
|
|
170
|
+
status: failed ? 'failed' : 'completed',
|
|
171
|
+
arguments: known?.arguments ?? null,
|
|
172
|
+
result: toJsonValue(block['content']),
|
|
173
|
+
error: failed ? renderJsonValue(block['content']) : null,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function recordValue(value) {
|
|
177
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
178
|
+
? value
|
|
179
|
+
: null;
|
|
180
|
+
}
|
|
181
|
+
function stringValue(value) {
|
|
182
|
+
return typeof value === 'string' ? value : null;
|
|
183
|
+
}
|
|
184
|
+
function toJsonValue(value) {
|
|
185
|
+
if (value === undefined)
|
|
186
|
+
return null;
|
|
187
|
+
try {
|
|
188
|
+
return JSON.parse(JSON.stringify(value));
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
return String(value);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function renderJsonValue(value) {
|
|
195
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
196
|
+
}
|
|
197
|
+
function asError(error) {
|
|
198
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=runtime-submissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-submissions.js","sourceRoot":"","sources":["../src/runtime-submissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAwCjE,MAAM,UAAU,uBAAuB;IACrC,IAAI,OAA2D,CAAC;IAChE,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,OAAO,EAAE,IAAI,OAAO,CAA8B,CAAC,KAAK,EAAE,EAAE;YAC1D,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC,CAAC;KACH,CAAC,CAAC;IACH,OAAO;QACL,UAAU;QACV,MAAM,CAAC,UAAU;YACf,IAAI,OAAO;gBAAE,OAAO,KAAK,CAAC;YAC1B,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,CAAC,UAAU,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAkB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,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAc,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,119 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* in issue #209).
|
|
5
|
-
*
|
|
6
|
-
* A real second agent runtime that proves the AgentRuntimeProvider abstraction
|
|
7
|
-
* is not "Codex renamed". Like Codex it runs a **resident child process**
|
|
8
|
-
* supervised for the runtime's lifetime — but it differs in every
|
|
9
|
-
* runtime-specific dimension:
|
|
10
|
-
*
|
|
11
|
-
* - **Stream-json over stdio, not an app-server WebSocket.** The resident child
|
|
12
|
-
* is `claude --print --input-format stream-json --output-format stream-json`
|
|
13
|
-
* (see `./args.ts`); turns are NDJSON `user` lines on stdin and
|
|
14
|
-
* `init`/`assistant`/`result` envelopes on stdout (see `./stream.ts`). There
|
|
15
|
-
* is no `initialize` handshake — the child emits `init` lazily with the first
|
|
16
|
-
* turn — so readiness is "child spawned", not "handshake completed".
|
|
17
|
-
* - **MCP injection is an inline JSON config document** (`--mcp-config <json>`),
|
|
18
|
-
* not Codex's `-c mcp_servers.*` TOML CLI flags.
|
|
19
|
-
* - **Runtime-owned config** is `DispatcherClaudeCodeConfig` (bin / model /
|
|
20
|
-
* permission_mode / remote_control / extra_args / extra_env), distinct from
|
|
21
|
-
* the Codex config.
|
|
22
|
-
* - **Completion delivery** is a plain user turn (no fake task-notification),
|
|
23
|
-
* not the Codex inbox-then-trigger path.
|
|
24
|
-
*
|
|
25
|
-
* Process spawning goes through an injectable {@link ClaudeCodeSessionFactory}
|
|
26
|
-
* seam (mirroring Codex's process-factory seam), so the lifecycle contract is
|
|
27
|
-
* fully unit-testable with a fake session. A live `claude` binary is exercised
|
|
28
|
-
* only by the opt-in live test.
|
|
29
|
-
*
|
|
30
|
-
* Failure contract (unchanged by #120): a turn failure (spawn error, child
|
|
31
|
-
* exit, error `result`) is never swallowed. For inbound/restart turns it drives
|
|
32
|
-
* the runtime to `degraded` with a persisted `last_error` (observable via
|
|
33
|
-
* status/doctor). For `completionInput` it surfaces as a `failed`
|
|
34
|
-
* result the caller can act on (PR8 delivery retry). `channelInput` still
|
|
35
|
-
* returns after accept (submit != completion) so the channel can ack promptly.
|
|
36
|
-
*
|
|
37
|
-
* Restart: an unexpected child exit marks the runtime `degraded`; the next turn
|
|
38
|
-
* re-spawns the resident child with `--resume <session_id>`, restoring the
|
|
39
|
-
* conversation. There is no background backoff timer — re-spawn is lazy and
|
|
40
|
-
* bound to the (serialized) turn queue, so it stays deterministic.
|
|
41
|
-
*
|
|
42
|
-
* Per-turn idle deadline: a turn whose still-alive child goes silent — never
|
|
43
|
-
* emitting another stream line (a stall, or a wait on input the runtime cannot
|
|
44
|
-
* satisfy) — would otherwise pend forever and wedge the serial queue, and behind
|
|
45
|
-
* it TeamMate completion delivery, which awaits this runtime. `turn_timeout_ms`
|
|
46
|
-
* is a *max-idle* window (issue #156): it is reset on every inbound stream line,
|
|
47
|
-
* so a long but continuously-streaming turn (e.g. a deep audit running many
|
|
48
|
-
* tool calls for far longer than the window) is never reaped, while a child that
|
|
49
|
-
* emits nothing for the whole window still is — turning an infinite hang into a
|
|
50
|
-
* normal degraded + `last_error` (inbound) or `failed` delivery result.
|
|
51
|
-
*
|
|
52
|
-
* Reference: the resident stream-json protocol model and process-supervision
|
|
53
|
-
* shape are adapted from the Claudemux `next` implementation; the AgentRuntime /
|
|
54
|
-
* Channel / DispatcherService boundaries (provider seam, runtime-owned MCP
|
|
55
|
-
* injection, degraded/last_error status, TeamMate delivery result contract) are
|
|
56
|
-
* Dreamux's own, per `.agents/decisions/agent-runtime-provider.md`.
|
|
57
|
-
*/
|
|
58
|
-
import type { DispatcherClaudeCodeConfig } from './config.js';
|
|
59
|
-
import { type ClaudeCodeSessionFactory } from './supervisor.js';
|
|
60
|
-
import type { AgentRuntimeCapabilities, AgentRuntime, AgentRuntimeIdentity, AgentRuntimeLastResult, AgentRuntimeMcpServer, AgentRuntimePathContext, AgentRuntimeSkillSource, AgentRuntimeStateCallbacks, AgentRuntimeStatus, AgentRuntimeTextInput, AgentRuntimeTurnResult, DreamuxLogger, InboundTurnInput, TurnSettledSignal } from '@excitedjs/dreamux-types';
|
|
61
|
-
/**
|
|
62
|
-
* Everything the Claude Code runtime needs, assembled by the provider from the
|
|
63
|
-
* neutral create context plus host-supplied hooks. The host contracts the
|
|
64
|
-
* package must not reconstruct — the per-dispatcher path context, the durable
|
|
65
|
-
* state sink, and the base process env (`PATH` seeded with the host package
|
|
66
|
-
* bins) — arrive here; nothing references a Dreamux host module.
|
|
67
|
-
*/
|
|
68
|
-
export interface ClaudeCodeRuntimeDeps {
|
|
69
|
-
/** Provider-parsed Claude Code runtime config. */
|
|
70
|
-
config: DispatcherClaudeCodeConfig;
|
|
71
|
-
/** Working directory the resident `claude` child runs in. */
|
|
72
|
-
cwd: string;
|
|
73
|
-
/** Neutral state sink for status/thread transitions. */
|
|
74
|
-
state: AgentRuntimeStateCallbacks;
|
|
75
|
-
/** Neutral path context: the runtime derives its cache/log subpaths here. */
|
|
76
|
-
paths: AgentRuntimePathContext;
|
|
77
|
-
/** MCP server descriptors translated into the `--mcp-config` JSON document. */
|
|
78
|
-
mcpServers: readonly AgentRuntimeMcpServer[];
|
|
79
|
-
/** Resident-session factory (tests inject a fake). */
|
|
80
|
-
sessionFactory: ClaudeCodeSessionFactory;
|
|
81
|
-
/** Host-level bin resolver (default: identity on the config bin). */
|
|
82
|
-
resolveBinPath: (bin: string) => string;
|
|
83
|
-
/**
|
|
84
|
-
* The host's neutral env-injection entries from the create context, merged
|
|
85
|
-
* into the resident child env before this provider's own `extra_env`.
|
|
86
|
-
* Empty/omitted means inject nothing (the common case).
|
|
87
|
-
*/
|
|
88
|
-
injectEnv?: Record<string, string>;
|
|
89
|
-
/**
|
|
90
|
-
* Launcher-supplied ordered role/system-prompt content, applied as an APPEND
|
|
91
|
-
* via `--append-system-prompt`. Omitted for launches that supply none.
|
|
92
|
-
*/
|
|
93
|
-
systemPromptAppend?: readonly string[];
|
|
94
|
-
/**
|
|
95
|
-
* Role-gated skill sources core selected (issue #209 slice 6). The
|
|
96
|
-
* add-dir-compatible ones become `--add-dir` flags on every (re)spawn.
|
|
97
|
-
*/
|
|
98
|
-
skillSources?: readonly AgentRuntimeSkillSource[];
|
|
99
|
-
/**
|
|
100
|
-
* Neutral feature names the host asked this runtime to disable. Args mapping
|
|
101
|
-
* is applied on every resident (re)spawn.
|
|
102
|
-
*/
|
|
103
|
-
disableFeatures?: readonly string[];
|
|
104
|
-
/**
|
|
105
|
-
* Optional JSON Schema constraining every turn's final assistant message for
|
|
106
|
-
* the resident session's lifetime. Passed straight through to
|
|
107
|
-
* `claudeCodeResidentArgs` as the native `--json-schema` flag on every
|
|
108
|
-
* (re)spawn. In-memory only — never persisted to identity, so a resumed
|
|
109
|
-
* session that did not start with a schema does not silently gain one.
|
|
110
|
-
*/
|
|
111
|
-
outputSchema?: Record<string, unknown>;
|
|
112
|
-
/** Fired each time a delivered turn reaches a terminal state. */
|
|
113
|
-
onTurnSettled?: (settled: TurnSettledSignal) => void;
|
|
114
|
-
/** Structured logger; falls back to a minimal `console.error` sink. */
|
|
115
|
-
logger?: DreamuxLogger;
|
|
116
|
-
}
|
|
1
|
+
/** Resident Claude Code AgentRuntime using stream-json stdio. */
|
|
2
|
+
import type { ClaudeCodeRuntimeDeps } from './runtime-deps.js';
|
|
3
|
+
import type { AgentRuntimeCapabilities, AgentRuntime, AgentRuntimeIdentity, AgentRuntimeStatus, AgentRuntimeTextInput, InboundTurnInput, RuntimeAdmission } from '@excitedjs/dreamux-types';
|
|
117
4
|
/**
|
|
118
5
|
* The Claude Code agent runtime for one dispatcher. A single resident
|
|
119
6
|
* stream-json child serves every turn. Turns run serially (one at a time) and
|
|
@@ -133,15 +20,24 @@ export declare class ClaudeCodeRuntime implements AgentRuntime {
|
|
|
133
20
|
private readonly logger;
|
|
134
21
|
private status;
|
|
135
22
|
private threadId;
|
|
23
|
+
private transcriptLocator;
|
|
24
|
+
private resumeOnNextSpawn;
|
|
136
25
|
private resumed;
|
|
137
26
|
private stopped;
|
|
138
27
|
private readonly seen;
|
|
28
|
+
private readonly seenOrder;
|
|
139
29
|
private readonly seenTextInputIds;
|
|
30
|
+
private readonly seenTextInputIdOrder;
|
|
31
|
+
private readonly sourceIdDedupeWindow;
|
|
32
|
+
private readonly pendingChannelSources;
|
|
33
|
+
private readonly pendingTextSources;
|
|
34
|
+
private readonly pendingAdmissions;
|
|
140
35
|
private queue;
|
|
141
|
-
private readonly runtimeInstanceId;
|
|
142
|
-
private turnCounter;
|
|
143
36
|
private session;
|
|
144
|
-
private
|
|
37
|
+
private sessionStarting;
|
|
38
|
+
private startTask;
|
|
39
|
+
private stopTask;
|
|
40
|
+
private generation;
|
|
145
41
|
private activeTurn;
|
|
146
42
|
private queuedTurnCount;
|
|
147
43
|
private idlePromise;
|
|
@@ -151,36 +47,42 @@ export declare class ClaudeCodeRuntime implements AgentRuntime {
|
|
|
151
47
|
getCapabilities(): AgentRuntimeCapabilities;
|
|
152
48
|
getCheckpoint(): {
|
|
153
49
|
id: string;
|
|
50
|
+
transcript_locator?: string | null;
|
|
154
51
|
} | null;
|
|
155
52
|
wasCheckpointResumed(): boolean;
|
|
156
|
-
getLast(): Promise<AgentRuntimeLastResult | null>;
|
|
157
53
|
getContext(): Promise<null>;
|
|
158
54
|
resume(): Promise<void>;
|
|
159
55
|
start(): Promise<void>;
|
|
56
|
+
private startRuntime;
|
|
160
57
|
stop(): Promise<void>;
|
|
161
|
-
|
|
162
|
-
|
|
58
|
+
private stopRuntime;
|
|
59
|
+
completionInput(input: AgentRuntimeTextInput): Promise<RuntimeAdmission>;
|
|
60
|
+
private completionInputImpl;
|
|
61
|
+
private acceptTextInput;
|
|
62
|
+
channelInput(input: InboundTurnInput): Promise<RuntimeAdmission>;
|
|
63
|
+
private channelInputImpl;
|
|
64
|
+
private acceptChannelInput;
|
|
65
|
+
private acceptInput;
|
|
66
|
+
private trackAdmission;
|
|
67
|
+
private drainAdmissions;
|
|
163
68
|
waitIdle(): Promise<void>;
|
|
164
69
|
private runActiveTurnOnQueue;
|
|
165
70
|
private runActiveTurn;
|
|
166
71
|
private steerActiveTurn;
|
|
167
72
|
private markTurnSucceeded;
|
|
168
73
|
private markTurnFailed;
|
|
74
|
+
private stopUnsettled;
|
|
169
75
|
private recordQueuedTurnStart;
|
|
170
76
|
private recordQueuedTurnEnd;
|
|
171
77
|
private resolveIdleWaitersIfIdle;
|
|
172
|
-
/**
|
|
173
|
-
* Ensure a live resident session exists, spawning (or re-spawning after an
|
|
174
|
-
* unexpected exit) as needed. Re-spawn resumes the persisted session id so the
|
|
175
|
-
* conversation survives a crash.
|
|
176
|
-
*/
|
|
78
|
+
/** Ensure a live resident session exists, resuming after a child exit. */
|
|
177
79
|
private ensureSession;
|
|
178
|
-
private
|
|
80
|
+
private createSession;
|
|
81
|
+
private resolveTranscriptPath;
|
|
179
82
|
/** React to an unexpected resident-child exit: degrade and drop the session. */
|
|
180
83
|
private onSessionExit;
|
|
181
|
-
private
|
|
182
|
-
private
|
|
183
|
-
private buildProcessEnv;
|
|
84
|
+
private onProtocolEvent;
|
|
85
|
+
private assertGeneration;
|
|
184
86
|
private setStatus;
|
|
185
87
|
private log;
|
|
186
88
|
}
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAuBjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAe/D,OAAO,KAAK,EACV,wBAAwB,EACxB,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EAErB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAMlC;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IA4ClD,OAAO,CAAC,QAAQ,CAAC,IAAI;IA3CvB,QAAQ,CAAC,WAAW,yBAAoC;IAExD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA6B;IACpD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAC1C,OAAO,CAAC,Q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