@a5c-ai/babysitter-sdk 0.0.170-staging.4197e511 → 0.0.170-staging.4601ccbc
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeCode.d.ts","sourceRoot":"","sources":["../../src/harness/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0BH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"claudeCode.d.ts","sourceRoot":"","sources":["../../src/harness/claudeCode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0BH,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,SAAS,CAAC;AA8xBjB,wBAAgB,uBAAuB,IAAI,cAAc,CA4DxD"}
|
|
@@ -351,9 +351,26 @@ async function handleStopHookImpl(args) {
|
|
|
351
351
|
let entrypointImportPath;
|
|
352
352
|
if (runId) {
|
|
353
353
|
try {
|
|
354
|
-
|
|
354
|
+
let runDir = path.isAbsolute(runId)
|
|
355
355
|
? runId
|
|
356
356
|
: path.join(runsDir, runId);
|
|
357
|
+
// Fallback: if run.json not found at primary path, search common
|
|
358
|
+
// alternative locations (e.g. nested .a5c/.a5c/runs/ created when
|
|
359
|
+
// babysit skill installs SDK in .a5c/ and runs commands from there).
|
|
360
|
+
if (!(0, node_fs_1.existsSync)(path.join(runDir, "run.json")) && !path.isAbsolute(runId)) {
|
|
361
|
+
const alternatives = [
|
|
362
|
+
path.join(".a5c", ".a5c", "runs", runId),
|
|
363
|
+
path.join(".a5c", "runs", runId),
|
|
364
|
+
];
|
|
365
|
+
for (const alt of alternatives) {
|
|
366
|
+
const resolved = path.resolve(alt);
|
|
367
|
+
if (resolved !== path.resolve(runDir) && (0, node_fs_1.existsSync)(path.join(resolved, "run.json"))) {
|
|
368
|
+
log.info(`Run not found at ${runDir}, using fallback: ${resolved}`);
|
|
369
|
+
runDir = resolved;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
357
374
|
const metadata = await (0, runFiles_1.readRunMetadata)(runDir);
|
|
358
375
|
entrypointImportPath = metadata?.entrypoint?.importPath;
|
|
359
376
|
const journal = await (0, journal_1.loadJournal)(runDir);
|
|
@@ -388,8 +405,9 @@ async function handleStopHookImpl(args) {
|
|
|
388
405
|
log.info("Completion proof available");
|
|
389
406
|
}
|
|
390
407
|
if (!runState) {
|
|
408
|
+
log.warn(`Run state unknown for ${runId} — allowing exit but preserving session file for recovery`);
|
|
391
409
|
if (verbose) {
|
|
392
|
-
process.stderr.write(`[hook:run stop] Run state is empty for ${runId}; run may be misconfigured\n`);
|
|
410
|
+
process.stderr.write(`[hook:run stop] Run state is empty for ${runId}; run may be misconfigured — preserving session file\n`);
|
|
393
411
|
}
|
|
394
412
|
if (runId) {
|
|
395
413
|
await appendStopHookEvent(path.join(runsDir, runId), {
|
|
@@ -402,7 +420,9 @@ async function handleStopHookImpl(args) {
|
|
|
402
420
|
hasPromise,
|
|
403
421
|
});
|
|
404
422
|
}
|
|
405
|
-
|
|
423
|
+
// Do NOT delete session file here — the run state may be temporarily
|
|
424
|
+
// unreadable (race with run:create, disk issue, etc.). Preserving the
|
|
425
|
+
// file allows session:associate or doctor to re-bind and recover.
|
|
406
426
|
process.stdout.write("{}\n");
|
|
407
427
|
return 0;
|
|
408
428
|
}
|
package/dist/session/write.d.ts
CHANGED
|
@@ -39,12 +39,12 @@ export declare function getCurrentTimestamp(): string;
|
|
|
39
39
|
export declare function isoToEpochSeconds(isoTimestamp: string): number | null;
|
|
40
40
|
/**
|
|
41
41
|
* Calculate iteration duration and update times array.
|
|
42
|
-
* Keeps only the last
|
|
42
|
+
* Keeps only the last 10 durations for runaway loop detection.
|
|
43
43
|
*/
|
|
44
44
|
export declare function updateIterationTimes(existingTimes: number[], lastIterationAt: string, currentTime: string): number[];
|
|
45
45
|
/**
|
|
46
46
|
* Check if average iteration time indicates runaway loop.
|
|
47
|
-
* Returns true if
|
|
47
|
+
* Returns true if at least 10 consecutive iterations averaged <= 15 seconds.
|
|
48
48
|
*/
|
|
49
49
|
export declare function isIterationTooFast(iterationTimes: number[]): boolean;
|
|
50
50
|
//# sourceMappingURL=write.d.ts.map
|
package/dist/session/write.js
CHANGED
|
@@ -166,7 +166,7 @@ function isoToEpochSeconds(isoTimestamp) {
|
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* Calculate iteration duration and update times array.
|
|
169
|
-
* Keeps only the last
|
|
169
|
+
* Keeps only the last 10 durations for runaway loop detection.
|
|
170
170
|
*/
|
|
171
171
|
function updateIterationTimes(existingTimes, lastIterationAt, currentTime) {
|
|
172
172
|
const lastEpoch = isoToEpochSeconds(lastIterationAt);
|
|
@@ -179,15 +179,15 @@ function updateIterationTimes(existingTimes, lastIterationAt, currentTime) {
|
|
|
179
179
|
return existingTimes;
|
|
180
180
|
}
|
|
181
181
|
const newTimes = [...existingTimes, duration];
|
|
182
|
-
// Keep only last
|
|
183
|
-
return newTimes.slice(-
|
|
182
|
+
// Keep only last 10
|
|
183
|
+
return newTimes.slice(-10);
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* Check if average iteration time indicates runaway loop.
|
|
187
|
-
* Returns true if
|
|
187
|
+
* Returns true if at least 10 consecutive iterations averaged <= 15 seconds.
|
|
188
188
|
*/
|
|
189
189
|
function isIterationTooFast(iterationTimes) {
|
|
190
|
-
if (iterationTimes.length <
|
|
190
|
+
if (iterationTimes.length < 10) {
|
|
191
191
|
return false;
|
|
192
192
|
}
|
|
193
193
|
const sum = iterationTimes.reduce((a, b) => a + b, 0);
|
package/package.json
CHANGED