@yaks/claude 0.0.0-stage → 0.2.36

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/limits.ts ADDED
@@ -0,0 +1,66 @@
1
+ // Claude's plan limits, as the CLI's stream reports them. Its own module
2
+ // (`@yaks/claude/limits`) so a reader of the stream's lines (@yaks/session)
3
+ // reads them as the model does, without loading the model.
4
+
5
+ import type { Limit } from 'jsr:@yaks/model@0.2.36'
6
+
7
+ // Claude's plan windows a reading is kept of, in minutes. The week has a
8
+ // second limit, `seven_day_overage_included`, which only a Fable request's
9
+ // stream reports: the plan's weekly cap on that model.
10
+ let WINDOWS: Record<string, Pick<Limit, 'window' | 'per'>> = {
11
+ five_hour: { window: 300 },
12
+ seven_day: { window: 10080 },
13
+ seven_day_overage_included: { window: 10080, per: 'model' },
14
+ }
15
+
16
+ type Info = Record<string, unknown>
17
+ let obj = (v: unknown): Info =>
18
+ v && typeof v == 'object' && !Array.isArray(v) ? v as Info : {}
19
+ let count = (v: unknown): number | undefined => {
20
+ if (v == null) return undefined
21
+ let n = Number(v)
22
+ return Number.isFinite(n) ? n : undefined
23
+ }
24
+
25
+ /**
26
+ * The readings in a `rate_limit_event`'s `rate_limit_info`: each window's
27
+ * fraction used and when it resets (`unifiedWindows`), whatever the status;
28
+ * where an older CLI sends none, the one window the event is about, which
29
+ * says how much is used only past a warning.
30
+ *
31
+ * ```ts
32
+ * import { metered } from './limits.ts'
33
+ * import { equal } from '@yaks/testing'
34
+ *
35
+ * let week = { utilization: 0.25, resetsAt: 1794913200 }
36
+ * equal(metered({ status: 'allowed', unifiedWindows: { seven_day: week } }), [
37
+ * { provider: 'claude', window: 10080, used: 25, resets: '2026-11-17T11:00:00.000Z' },
38
+ * ])
39
+ * equal(metered({ rateLimitType: 'five_hour', utilization: 0.9 }), [
40
+ * { provider: 'claude', window: 300, used: 90 },
41
+ * ])
42
+ * equal(metered({ status: 'allowed', rateLimitType: 'five_hour' }), [])
43
+ * // The model's own weekly cap is a second limit beside the week.
44
+ * let cap = { utilization: 0.06, resetsAt: 1794913200 }
45
+ * equal(metered({ unifiedWindows: { seven_day: week, seven_day_overage_included: cap } })[1], {
46
+ * provider: 'claude', window: 10080, per: 'model', used: 6, resets: '2026-11-17T11:00:00.000Z',
47
+ * })
48
+ * ```
49
+ */
50
+ export let metered = (info: Info): Limit[] => {
51
+ let each = obj(info.unifiedWindows)
52
+ let windows = Object.keys(each).length
53
+ ? each
54
+ : { [String(info.rateLimitType ?? '')]: info }
55
+ return Object.entries(WINDOWS).flatMap(([name, limit]) => {
56
+ let w = obj(windows[name])
57
+ return count(w.utilization) == null ? [] : [{
58
+ provider: 'claude',
59
+ ...limit,
60
+ used: Math.round(Number(w.utilization) * 100),
61
+ ...count(w.resetsAt) == null
62
+ ? {}
63
+ : { resets: new Date(Number(w.resetsAt) * 1000).toISOString() },
64
+ }]
65
+ })
66
+ }
package/mark.js ADDED
@@ -0,0 +1,14 @@
1
+ // What a host writes on the entry recording a reply, importable without the
2
+ // model (./mod.ts): a host that loads it lazily still marks its replies at once.
3
+ import { prefixCacheMark } from "@yaks/model";
4
+ /** `claude{response_id, session_id, cache_expires_at}` for a reply. The CLI
5
+ * chooses how long its cache keeps a prefix and names no expiry, so the expiry
6
+ * is the request's start plus the lifetime its provider row records
7
+ * (`provider{cache_retention}`), and unknown where the row records none. */ export let mark = (reply, cache)=>({
8
+ claude: {
9
+ response_id: reply.id,
10
+ session_id: reply.claudeSession,
11
+ ...prefixCacheMark(reply, cache)
12
+ }
13
+ });
14
+ //# sourceMappingURL=mark.js.map
package/mark.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mark.js","sources":["./mark.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,iFAAiF;AACjF,SAA4B,eAAe,2BAA4C;AAEvF;;;0EAG0E,GAC1E,OAAO,IAAI,OAAO,CAChB,OACA,QACwC,CAAC;IACzC,QAAQ;MACN,aAAa,MAAM,EAAE;MACrB,YAAY,MAAM,aAAa;MAC/B,GAAG,gBAAgB,OAAO,MAAM;IAClC;EACF,CAAC,EAAC"}
package/mark.ts ADDED
@@ -0,0 +1,18 @@
1
+ // What a host writes on the entry recording a reply, importable without the
2
+ // model (./mod.ts): a host that loads it lazily still marks its replies at once.
3
+ import { type CacheContext, prefixCacheMark, type Reply } from '@yaks/model'
4
+
5
+ /** `claude{response_id, session_id, cache_expires_at}` for a reply. The CLI
6
+ * chooses how long its cache keeps a prefix and names no expiry, so the expiry
7
+ * is the request's start plus the lifetime its provider row records
8
+ * (`provider{cache_retention}`), and unknown where the row records none. */
9
+ export let mark = (
10
+ reply: Reply & { claudeSession?: string },
11
+ cache?: CacheContext,
12
+ ): { claude: Record<string, unknown> } => ({
13
+ claude: {
14
+ response_id: reply.id,
15
+ session_id: reply.claudeSession,
16
+ ...prefixCacheMark(reply, cache),
17
+ },
18
+ })
package/mod.js ADDED
@@ -0,0 +1,507 @@
1
+ import { trash } from "@yaks/process/trash";
2
+ import * as io from "@yaks/file/io";
3
+ import { command } from "@yaks/process/command";
4
+ import { claudeDoc } from "./vocab.js";
5
+ /**
6
+ * Claude Code as a one-turn @yaks/model implementation. The MCP server it
7
+ * hosts over the CLI's control channel only advertises tools: calls are
8
+ * returned to the harness, never executed here.
9
+ * Each request replays graph history; no Claude conversation is authoritative.
10
+ * @module
11
+ */ import { acknowledged, began, ModelError, submitted } from "@yaks/model";
12
+ import { metered } from "./limits.js";
13
+ import { stallMs, watchdog, watchedBody } from "@yaks/model/stall";
14
+ import { mark } from "./mark.js";
15
+ import { offer } from "./offer.js";
16
+ /** CLI aliases are resolved by the installed Claude Code, not pinned releases. */ export let listing = ()=>[
17
+ 'haiku',
18
+ 'sonnet',
19
+ 'opus'
20
+ ].map((name)=>({
21
+ name,
22
+ label: `Claude Code ${name}`,
23
+ modalities: [
24
+ 'text'
25
+ ]
26
+ }));
27
+ /** Full graph history is data in one stream-json user message, not --resume:
28
+ * one text block per item, oldest first. The CLI marks the message's last
29
+ * block for the prompt cache, and the next step's message begins with the same
30
+ * blocks, so the cache finds this step's prefix there and only the items since
31
+ * are read anew. One string of the whole transcript differs from the last
32
+ * step's at its end, and the cache found none of it. */ export let input = (req)=>JSON.stringify({
33
+ type: 'user',
34
+ message: {
35
+ role: 'user',
36
+ content: req.items.map((item)=>({
37
+ type: 'text',
38
+ text: JSON.stringify(item)
39
+ }))
40
+ }
41
+ }) + '\n';
42
+ /** The public text and tool requests of one completed assistant frame. The
43
+ * CLI lists the harness's tools as `mcp__harness__<name>`, while the
44
+ * transcript it replays names each call by its own name, so Claude asks for a
45
+ * tool by either; both are that tool. A call to anything else goes to the
46
+ * harness as asked, which answers it with a refusal the model reads, as it
47
+ * does every provider's. */ export let items = (message)=>{
48
+ if (!Array.isArray(message.content)) {
49
+ throw new ModelError('claude_protocol', 'Missing assistant content');
50
+ }
51
+ return message.content.flatMap((p)=>{
52
+ if (p.type == 'text') {
53
+ return [
54
+ {
55
+ kind: 'assistant',
56
+ text: p.text,
57
+ id: String(message.id)
58
+ }
59
+ ];
60
+ }
61
+ if (p.type == 'thinking' || p.type == 'redacted_thinking') return [];
62
+ if (p.type == 'tool_use') {
63
+ let name = String(p.name).replace(/^mcp__harness__/, '');
64
+ return [
65
+ {
66
+ kind: 'call',
67
+ id: p.id,
68
+ name,
69
+ args: JSON.stringify(p.input)
70
+ }
71
+ ];
72
+ }
73
+ throw new ModelError('claude_protocol', `Unsupported assistant content: ${p.type}`);
74
+ });
75
+ };
76
+ /** A reply's usage from the API's usage fields, which count cache reads and
77
+ * writes beside `input_tokens`; here they are parts of it. A write kept an
78
+ * hour is priced apart from one kept five minutes, so it is counted apart. */ let counted = (u)=>{
79
+ let cached = u.cache_read_input_tokens ?? 0;
80
+ let wrote = u.cache_creation_input_tokens ?? 0;
81
+ let hour = u.cache_creation?.ephemeral_1h_input_tokens;
82
+ let input = (u.input_tokens ?? 0) + cached + wrote;
83
+ let output = u.output_tokens ?? 0;
84
+ return {
85
+ input_tokens: input,
86
+ output_tokens: output,
87
+ total_tokens: input + output,
88
+ cached_tokens: cached,
89
+ cache_write_tokens: wrote,
90
+ ...hour ? {
91
+ cache_write_1h_tokens: hour
92
+ } : {}
93
+ };
94
+ };
95
+ // The CLI's errors that pass: a 429 (`rate_limit`), whether a plan window is
96
+ // spent or the service is short of capacity, and a 5xx (`server_error`).
97
+ let PASSING = [
98
+ 'rate_limit',
99
+ 'server_error'
100
+ ];
101
+ // The longest a spent window defers a step: its owner may reset it early.
102
+ let RESET_WAIT = 60 * 60 * 1000;
103
+ /**
104
+ * What an assistant frame's `error` comes to. One that passes is `busy`, as an
105
+ * API's 429 or 5xx is (@yaks/anthropic): asked again after a backoff, or, where
106
+ * a window the stream reported is spent, deferred until it resets, an hour at
107
+ * most, spending no attempt. Any other is the CLI's no, `claude`.
108
+ */ let refused = (frame, limits, now = Date.now())=>{
109
+ let code = String(frame.error);
110
+ let content = frame.message?.content;
111
+ let said = (Array.isArray(content) ? content : []).map((p)=>p.text).filter(Boolean).join('\n') || code;
112
+ let error = !PASSING.includes(code) ? new ModelError('claude', said) : new ModelError('busy', said, resets(limits, now));
113
+ return Object.assign(error, limits.length ? {
114
+ limits
115
+ } : {});
116
+ };
117
+ // How long until the last spent window resets, an hour at most, as a deferral;
118
+ // a plain retry where no reading says a window is spent.
119
+ let resets = (limits, now)=>{
120
+ let wait = Math.max(0, ...limits.filter((l)=>l.used >= 100 && l.resets).map((l)=>Date.parse(l.resets) - now));
121
+ return wait > 0 ? {
122
+ after: Math.min(wait, RESET_WAIT),
123
+ defer: true
124
+ } : {};
125
+ };
126
+ /**
127
+ * Read one turn from the CLI's frames. Text reaches `onText` as its
128
+ * `stream_event` deltas arrive, at its place among the reply's assistant
129
+ * items; each completed assistant frame then adds its items to the reply and
130
+ * tells whatever of its text no delta carried, so the text told is always the
131
+ * reply's text. Usage is the count the message ended with, which its
132
+ * `message_delta` carries; an `assistant` frame holds the count it started
133
+ * with. A message that requests a call is read through its `message_delta`,
134
+ * which the CLI writes before it dispatches the call, and reading stops there.
135
+ * Otherwise it stops at the turn's `result`. The plan limits the stream
136
+ * reports on the way are kept with the turn, and with the failure where the
137
+ * turn ends in one.
138
+ */ export let read = async (req, frames)=>{
139
+ let turn = {
140
+ session: '',
141
+ terminal: false,
142
+ limits: []
143
+ };
144
+ let id = '';
145
+ // Content block index to its place among the assistant items.
146
+ let place = new Map();
147
+ let told = [];
148
+ // The message's usage as last reported, newest fields winning.
149
+ let usage = {};
150
+ let tell = (index, text)=>{
151
+ if (!text) return;
152
+ told[index] = (told[index] ?? '') + text;
153
+ req.onText?.({
154
+ index,
155
+ id,
156
+ text
157
+ });
158
+ };
159
+ for await (let frame of frames){
160
+ if (frame.session_id && !turn.session) {
161
+ turn.session = frame.session_id;
162
+ await acknowledged(req, {
163
+ claude: {
164
+ session_id: turn.session
165
+ }
166
+ });
167
+ }
168
+ if (frame.type == 'rate_limit_event') {
169
+ let read = metered(frame.rate_limit_info ?? {});
170
+ turn.limits = [
171
+ ...turn.limits.filter((l)=>!read.some((r)=>r.window == l.window && r.per == l.per)),
172
+ ...read
173
+ ];
174
+ }
175
+ if (frame.type == 'stream_event') {
176
+ let e = frame.event ?? {};
177
+ if (e.type == 'message_start') {
178
+ id = String(e.message?.id);
179
+ usage = {
180
+ ...e.message?.usage
181
+ };
182
+ }
183
+ if (e.type == 'message_delta') {
184
+ usage = {
185
+ ...usage,
186
+ ...e.usage
187
+ };
188
+ if (turn.reply) turn.reply.usage = counted(usage);
189
+ if (turn.reply?.items.some((i)=>i.kind == 'call')) break;
190
+ }
191
+ if (e.type == 'content_block_start') {
192
+ began(req);
193
+ if (e.content_block?.type == 'text') place.set(e.index, place.size);
194
+ }
195
+ let at = place.get(e.index);
196
+ if (e.delta?.type == 'text_delta' && at != null) tell(at, e.delta.text);
197
+ }
198
+ if (frame.type == 'assistant') {
199
+ if (turn.reply && turn.reply.id != frame.message?.id) {
200
+ throw new ModelError('claude_protocol', 'More than one model turn');
201
+ }
202
+ if (frame.error) throw refused(frame, turn.limits);
203
+ began(req);
204
+ let message = frame.message;
205
+ id = String(message.id);
206
+ let prior = turn.reply?.items ?? [];
207
+ let output = items(message);
208
+ // The frame's count is the message's start: never below a later one.
209
+ usage = {
210
+ ...message.usage,
211
+ ...usage
212
+ };
213
+ turn.reply = {
214
+ id,
215
+ model: message.model ?? req.model,
216
+ items: [
217
+ ...prior,
218
+ ...output
219
+ ],
220
+ usage: counted(usage)
221
+ };
222
+ let at = prior.filter((i)=>i.kind == 'assistant').length;
223
+ for (let item of output){
224
+ if (item.kind != 'assistant') continue;
225
+ tell(at, item.text.slice(told[at]?.length ?? 0));
226
+ at++;
227
+ }
228
+ }
229
+ if (frame.type == 'result') {
230
+ turn.terminal = true;
231
+ if (frame.is_error || frame.subtype != 'success') {
232
+ throw Object.assign(new ModelError('claude', JSON.stringify(frame)), turn.limits.length ? {
233
+ limits: turn.limits
234
+ } : {});
235
+ }
236
+ break;
237
+ }
238
+ }
239
+ return turn;
240
+ };
241
+ /** The CLI's arguments for one model at one effort. A step's prompt and tools
242
+ * are not among them: they reach the process with the step (`opening`), so
243
+ * the process can start before its step is known. Built-ins, settings, hooks,
244
+ * slash commands and saved sessions are all off. */ export let argv = (model, effort)=>[
245
+ '-p',
246
+ '--model',
247
+ model,
248
+ '--input-format',
249
+ 'stream-json',
250
+ '--output-format',
251
+ 'stream-json',
252
+ '--verbose',
253
+ '--include-partial-messages',
254
+ '--max-turns',
255
+ '1',
256
+ '--no-session-persistence',
257
+ '--tools',
258
+ '',
259
+ '--strict-mcp-config',
260
+ '--setting-sources',
261
+ '',
262
+ '--settings',
263
+ '{"disableAllHooks":true}',
264
+ '--disable-slash-commands',
265
+ '--permission-mode',
266
+ 'dontAsk',
267
+ '--allowedTools',
268
+ 'mcp__harness__*',
269
+ ...effort ? [
270
+ '--effort',
271
+ effort
272
+ ] : []
273
+ ];
274
+ /** The control request that opens a step: its system prompt, and the harness
275
+ * as an SDK-hosted MCP server, which the CLI asks for its tools over the same
276
+ * stdin and stdout (`offer`). */ export let opening = (req)=>JSON.stringify({
277
+ type: 'control_request',
278
+ request_id: crypto.randomUUID(),
279
+ request: {
280
+ subtype: 'initialize',
281
+ systemPrompt: [
282
+ [
283
+ 'You are the model of a graph-native harness. The user message contains the authoritative transcript, one JSON item per block, oldest first.',
284
+ 'Continue that transcript, responding to its latest user or tool result. Prior assistant/call/result items are history, not new requests.',
285
+ 'Use only the offered harness MCP tools. The graph harness executes your calls after this turn. Do not simulate tool results.',
286
+ req.instructions ?? ''
287
+ ].join('\n\n')
288
+ ],
289
+ sdkMcpServers: [
290
+ 'harness'
291
+ ]
292
+ }
293
+ }) + '\n';
294
+ let spawn = (program, options)=>command(program, options).spawn();
295
+ let start = async (opts, model, effort)=>{
296
+ let cwd = await io.makeTempDir({
297
+ prefix: 'yak-claude-'
298
+ });
299
+ let child = (opts.spawn ?? spawn)(opts.command ?? 'claude', {
300
+ args: [
301
+ ...opts.args ?? [],
302
+ ...argv(model, effort)
303
+ ],
304
+ cwd,
305
+ stdin: 'piped',
306
+ stdout: 'piped',
307
+ stderr: 'piped',
308
+ env: {
309
+ CLAUDE_CODE_DISABLE_AUTO_MEMORY: '1',
310
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1'
311
+ }
312
+ });
313
+ let proc = {
314
+ child,
315
+ cwd,
316
+ ended: false
317
+ };
318
+ let ended = ()=>{
319
+ proc.ended = true;
320
+ };
321
+ child.status.then(ended, ended);
322
+ await child.started.catch(async (error)=>{
323
+ await trash(cwd);
324
+ throw error;
325
+ });
326
+ // A process waiting for its step never holds its host open; it ends when
327
+ // the host does, and its stdin with it.
328
+ child.unref();
329
+ return proc;
330
+ };
331
+ let end = async (proc)=>{
332
+ // Its exit is waited for, so it holds the host open until then.
333
+ proc.child.ref();
334
+ proc.child.kill('SIGKILL');
335
+ await proc.child.status.catch(()=>{});
336
+ await trash(proc.cwd);
337
+ };
338
+ let lines = (stream)=>{
339
+ let buffer = '';
340
+ return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new TransformStream({
341
+ transform (chunk, controller) {
342
+ buffer += chunk;
343
+ let lines = buffer.split('\n');
344
+ buffer = lines.pop();
345
+ for (let line of lines)if (line.trim()) controller.enqueue(line);
346
+ },
347
+ flush (controller) {
348
+ if (buffer.trim()) controller.enqueue(buffer);
349
+ }
350
+ }));
351
+ };
352
+ /**
353
+ * Claude Code answering model requests, one CLI process per step. Requires a
354
+ * signed-in local CLI. Each step takes a process started before it, for its
355
+ * model and effort, and starts the next step's while it waits on the model,
356
+ * so a step doesn't wait for the CLI to start. A process answers one step and
357
+ * is ended: nothing one step sends reaches another's reply.
358
+ */ export let claude = (opts = {})=>{
359
+ // The process the next step of each model and effort takes.
360
+ let spares = new Map();
361
+ let key = (req)=>JSON.stringify([
362
+ req.model,
363
+ req.effort ?? null
364
+ ]);
365
+ let spare = (req)=>{
366
+ if (spares.has(key(req))) return;
367
+ spares.set(key(req), start(opts, req.model, req.effort).catch(()=>undefined));
368
+ };
369
+ let accounted = (limits)=>opts.account ? limits.map((l)=>({
370
+ ...l,
371
+ account: opts.account
372
+ })) : limits;
373
+ let take = async (req)=>{
374
+ let held = spares.get(key(req));
375
+ spares.delete(key(req));
376
+ let proc = await held;
377
+ if (proc && !proc.ended) return proc;
378
+ if (proc) await end(proc);
379
+ return await start(opts, req.model, req.effort);
380
+ };
381
+ return Object.assign(async (req)=>{
382
+ if (req.questions) {
383
+ throw new ModelError('questions', 'Claude Code answers no typed questions');
384
+ }
385
+ if (req.input || req.items.some((i)=>'bytes' in i) || req.modalities?.some((m)=>m != 'text')) {
386
+ throw new ModelError('claude_input', 'Claude Code provider supports text and harness tools only');
387
+ }
388
+ req.signal?.throwIfAborted();
389
+ let tools = offer(req.tools);
390
+ let proc;
391
+ let kill = ()=>proc?.child.kill('SIGKILL');
392
+ let dog = watchdog(stallMs(req), opts.clock, req.signal);
393
+ let signal = dog.signal;
394
+ let stderr;
395
+ try {
396
+ await submitted(req);
397
+ signal?.throwIfAborted();
398
+ proc = await take(req);
399
+ let child = proc.child;
400
+ child.ref();
401
+ signal?.addEventListener('abort', kill, {
402
+ once: true
403
+ });
404
+ signal?.throwIfAborted();
405
+ // Drain stderr concurrently to avoid a full pipe blocking stdout.
406
+ stderr = new Response(watchedBody(child.stderr, 0, undefined, signal)).text().then((s)=>s.slice(-8192));
407
+ stderr.catch(()=>{});
408
+ let writer = child.stdin.getWriter();
409
+ let send = (line)=>writer.write(new TextEncoder().encode(line));
410
+ await send(opening(req) + input(req));
411
+ spare(req);
412
+ let reader = lines(watchedBody(child.stdout, 0, undefined, signal)).getReader();
413
+ // The turn's frames; the control channel is answered here.
414
+ let frames = async function*() {
415
+ try {
416
+ while(true){
417
+ dog.kick();
418
+ let { value, done } = await reader.read();
419
+ if (done) return;
420
+ let frame = JSON.parse(value);
421
+ if (frame.type == 'control_response') {
422
+ if (frame.response?.subtype == 'error') {
423
+ throw new ModelError('claude_protocol', frame.response.error);
424
+ }
425
+ continue;
426
+ }
427
+ if (frame.type != 'control_request') {
428
+ dog.rest();
429
+ yield frame;
430
+ continue;
431
+ }
432
+ let r = frame.request ?? {};
433
+ let mcp = r.subtype == 'mcp_message' && r.server_name == 'harness' ? tools(r.message ?? {}) : undefined;
434
+ // A call is never answered: the harness runs it.
435
+ if (mcp == undefined && r.message?.method == 'tools/call') continue;
436
+ await send(JSON.stringify({
437
+ type: 'control_response',
438
+ response: mcp ? {
439
+ subtype: 'success',
440
+ request_id: frame.request_id,
441
+ response: {
442
+ mcp_response: mcp
443
+ }
444
+ } : {
445
+ subtype: 'error',
446
+ request_id: frame.request_id,
447
+ error: `Unsupported control request: ${r.subtype}`
448
+ }
449
+ }) + '\n');
450
+ }
451
+ } finally{
452
+ void reader.cancel().catch(()=>{});
453
+ reader.releaseLock();
454
+ }
455
+ };
456
+ let { reply, session, terminal, limits } = await read(req, frames());
457
+ kill();
458
+ dog.kick();
459
+ signal?.throwIfAborted();
460
+ if (!reply || !terminal && !reply.items.some((i)=>i.kind == 'call')) {
461
+ throw new ModelError('claude_exit', await stderr || 'Claude ended without a completed turn');
462
+ }
463
+ return Object.assign(reply, {
464
+ claudeSession: session,
465
+ ...limits.length ? {
466
+ limits: accounted(limits)
467
+ } : {}
468
+ });
469
+ } catch (error) {
470
+ kill();
471
+ if (dog.stalled()) {
472
+ throw new ModelError('stalled', `Claude Code stalled — ${signal?.reason}`, {});
473
+ }
474
+ signal?.throwIfAborted();
475
+ if (error instanceof ModelError && error.limits) {
476
+ error.limits = accounted(error.limits);
477
+ }
478
+ let failed = await proc?.child.status.then(()=>{}, (e)=>e);
479
+ if (io.isNotFound(error) || io.isNotFound(failed)) {
480
+ throw new ModelError('claude_missing', 'Install and sign in to Claude Code on the harness host');
481
+ }
482
+ throw error;
483
+ } finally{
484
+ try {
485
+ dog.kick();
486
+ if (proc) await end(proc);
487
+ await stderr?.catch(()=>{});
488
+ } finally{
489
+ signal?.removeEventListener('abort', kill);
490
+ dog.close();
491
+ }
492
+ }
493
+ }, {
494
+ list: ()=>Promise.resolve(listing()),
495
+ info: (name)=>Promise.resolve(listing().find((m)=>m.name == name)),
496
+ mark,
497
+ vocab: claudeDoc,
498
+ /** Ends the processes waiting for steps. */ [Symbol.asyncDispose]: async ()=>{
499
+ let held = [
500
+ ...spares.values()
501
+ ];
502
+ spares.clear();
503
+ for (let proc of (await Promise.all(held)))if (proc) await end(proc);
504
+ }
505
+ });
506
+ };
507
+ //# sourceMappingURL=mod.js.map
package/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA,SAAS,KAAK,mCAAwC;AACtD,YAAY,6BAAkC;AAC9C,SAEE,OAAO,qCAEgC;AACzC,SAAS,SAAS,qBAAoB;AACtC;;;;;;CAMC,GACD,SACE,YAAY,EACZ,KAAK,EAKL,UAAU,EAGV,SAAS,2BAEoB;AAC/B,SAAS,OAAO,sBAAqB;AACrC,SAAS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