@wjarka/cezarion 0.14.3 → 0.14.4-pr455.702
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 +3 -0
- package/dist/automations/types.d.ts +2 -0
- package/dist/contract/automations.d.ts +8 -0
- package/dist/contract/index.js +1 -0
- package/dist/contract/runs.d.ts +7 -0
- package/dist/contract/skills.d.ts +1 -0
- package/dist/contract/workflows.d.ts +6 -0
- package/dist/core/cursor-acp-runner.d.ts +13 -0
- package/dist/core/cursor-acp-runner.js +118 -5
- package/dist/core/cursor-acp-runner.js.map +1 -1
- package/dist/core/cursor-provider-error.d.ts +30 -0
- package/dist/core/cursor-provider-error.js +53 -0
- package/dist/core/cursor-provider-error.js.map +1 -0
- package/dist/core/usage-limit.js +1 -1
- package/dist/core/usage-limit.js.map +1 -1
- package/dist/delegation/routes.d.ts +50 -50
- package/dist/delegation/transport.d.ts +4 -4
- package/dist/runs/agent-tmpdir.d.ts +20 -11
- package/dist/runs/agent-tmpdir.js +109 -60
- package/dist/runs/agent-tmpdir.js.map +1 -1
- package/dist/runs/event-history.js +14 -1
- package/dist/runs/event-history.js.map +1 -1
- package/dist/runs/store.d.ts +1 -0
- package/dist/server/server.d.ts +68 -0
- package/dist/skills-remote.d.ts +3 -2
- package/dist/skills-remote.js +5 -2
- package/dist/skills-remote.js.map +1 -1
- package/dist/workflows/run.js +36 -13
- package/dist/workflows/run.js.map +1 -1
- package/dist/workflows/types.d.ts +3 -0
- package/dist/workflows/types.js +2 -1
- package/dist/workflows/types.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mock-cursor-acp.mjs +11 -1
- package/web/dist/assets/{agent-accounts-BxBsIXGa.js → agent-accounts-DOj8HSjE.js} +1 -1
- package/web/dist/assets/{alert-dialog-BOp2HnnL.js → alert-dialog-DwX3l_F6.js} +1 -1
- package/web/dist/assets/{collapsible-bb0csfMs.js → collapsible-Cm4ZyeDl.js} +1 -1
- package/web/dist/assets/{commit-list-CEVhJoCF.js → commit-list-DfcoDkSs.js} +1 -1
- package/web/dist/assets/{compare-variants-CZqdiqvW.js → compare-variants-DHj_Z_xd.js} +1 -1
- package/web/dist/assets/{diff-BjLZHKfD2.js → diff-DwO-iLjW2.js} +2 -2
- package/web/dist/assets/{diff-controls-DaO836o4.js → diff-controls-CB1gIyGz.js} +1 -1
- package/web/dist/assets/{diff-stat-DpHwISUB.js → diff-stat-B74duZBH.js} +1 -1
- package/web/dist/assets/{diff-view-BaYxuP8L.js → diff-view-B7RqVISE.js} +1 -1
- package/web/dist/assets/{dropdown-menu-DAmCVaLJ.js → dropdown-menu-DTrRi6Tq.js} +1 -1
- package/web/dist/assets/{git-toolbar-rk3doc2w.js → git-toolbar-DPiD3q2A.js} +1 -1
- package/web/dist/assets/{github-BPfdr6aa.js → github-CHiHC-Ul.js} +1 -1
- package/web/dist/assets/{image-preview-CFHgISfb.js → image-preview-BIrCrR_9.js} +1 -1
- package/web/dist/assets/{index-C4iEPAUV.js → index-Bff_uxww.js} +5 -5
- package/web/dist/assets/index-DK0Mkv2m.css +1 -0
- package/web/dist/assets/{markdown-Ir62-VMS.js → markdown-CCLcdhiq.js} +1 -1
- package/web/dist/assets/pill-BaGyQ4aZ.js +1 -0
- package/web/dist/assets/{project-router-CvFAMDcP.js → project-router-Co4ydCGP.js} +1 -1
- package/web/dist/assets/{prompt-templates-BGGpAIzb.js → prompt-templates-B93O9ZLW.js} +1 -1
- package/web/dist/assets/{repo-git-C1Qv1JmM.js → repo-git-BYJGkDnL.js} +1 -1
- package/web/dist/assets/{run-diff-DrQsmf3-.js → run-diff-XvDCv2j1.js} +1 -1
- package/web/dist/assets/run-header-CdjwxiKT.js +1 -0
- package/web/dist/assets/{skills-_ZVZxmKz.js → skills-B4P6fUvq.js} +1 -1
- package/web/dist/assets/{tab-link-CkIV8ixq.js → tab-link-BUng-NBH.js} +1 -1
- package/web/dist/assets/{task-changes-BU9upwUw.js → task-changes-DkLcWKvN.js} +1 -1
- package/web/dist/assets/{task-commits-CbJutMBx.js → task-commits-D9bMgMee.js} +1 -1
- package/web/dist/assets/{task-files-_hQyxAc7.js → task-files-BDJe_ZXh.js} +1 -1
- package/web/dist/assets/task-thread-DGJg9FEr.js +9 -0
- package/web/dist/assets/{textarea-DfvlPIgO.js → textarea-CxPEK5l-.js} +1 -1
- package/web/dist/assets/thread-loading-Cj2yiYc1.js +1 -0
- package/web/dist/assets/{token-metrics-BLzFUb8F.js → token-metrics-DsVTrin_.js} +1 -1
- package/web/dist/assets/{utils-GZNjgma4.js → utils-xJM80c1H.js} +1 -1
- package/web/dist/assets/{workflows-B6Er16t0.js → workflows-VBAvsa8G.js} +3 -3
- package/web/dist/assets/{zoomable-image-COhBxkky.js → zoomable-image-Bj5ZU9UB.js} +1 -1
- package/web/dist/index.html +14 -14
- package/web/dist/assets/index-DPOGn7D5.css +0 -1
- package/web/dist/assets/pill-Dvvq0Otw.js +0 -1
- package/web/dist/assets/run-header-C9Aeh27u.js +0 -1
- package/web/dist/assets/task-thread-Yo52ML6l.js +0 -9
- package/web/dist/assets/thread-loading-B9uTF0dX.js +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { parseUsageLimit } from './usage-limit.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cursor provider error envelopes (#443). Cursor 2026.09.15 catches provider
|
|
4
|
+
* failures and emits them as an `agent_message_chunk` beginning with a literal
|
|
5
|
+
* `\n\nError: ` prefix, then ends the turn. The runner used to reduce that
|
|
6
|
+
* envelope to two canned strings, which discarded the reset instants the
|
|
7
|
+
* auto-resume machinery (spec 2026-08-03) needs and made a transient 429/5xx
|
|
8
|
+
* indistinguishable from a fatal one.
|
|
9
|
+
*/
|
|
10
|
+
/** Preserved provider text is diagnosis, not transcript bulk — cap it. */
|
|
11
|
+
export const CURSOR_PROVIDER_ERROR_MAX_CHARS = 500;
|
|
12
|
+
const ENVELOPE_PREFIX_RE = /^\n\nError: /u;
|
|
13
|
+
const CONTROL_RE = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/gu;
|
|
14
|
+
/**
|
|
15
|
+
* Transient provider failure signals worth one more prompt. Deliberately wide —
|
|
16
|
+
* the cost of a false positive is two wasted prompts (bounded below), while the
|
|
17
|
+
* cost of a false negative is a dead run that needed a human Continue. Fatal
|
|
18
|
+
* prose like "context length exceeded" or "model not found" matches none of these.
|
|
19
|
+
*/
|
|
20
|
+
const TRANSIENT_SIGNAL_RE = /\b(?:429|500|502|503|504|rate[ _-]?limit(?:ed)?|overloaded|temporar(?:y|ily)|timed?[ _-]?out|bad gateway|service unavailable|internal server error|connection (?:reset|refused|closed|error)|econn(?:reset|refused|aborted)|socket hang up|try again|retry)\b/i;
|
|
21
|
+
/**
|
|
22
|
+
* Strip the envelope prefix, control characters and runs of whitespace. Uncapped — this is the
|
|
23
|
+
* form classification and limit parsing read, so a verbose envelope cannot bury its reset
|
|
24
|
+
* instant past a display bound (#446 round 3).
|
|
25
|
+
*/
|
|
26
|
+
function collapseCursorProviderError(text) {
|
|
27
|
+
return text.replace(ENVELOPE_PREFIX_RE, '').replace(CONTROL_RE, ' ').replace(/\s+/g, ' ').trim();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The collapsed text, capped for display. Safe to embed in a run error and transcript;
|
|
31
|
+
* recovery-relevant structure survives through `classifyCursorProviderError` and the
|
|
32
|
+
* runner's fatal composition, never through this cap.
|
|
33
|
+
*/
|
|
34
|
+
export function sanitizeCursorProviderError(text) {
|
|
35
|
+
return collapseCursorProviderError(text).slice(0, CURSOR_PROVIDER_ERROR_MAX_CHARS);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Classify a raw envelope chunk. Auth wins first (login guidance, fatal);
|
|
39
|
+
* a limit phrase with a usable reset instant makes it transient-with-instant;
|
|
40
|
+
* any other transient signal is transient-without-instant; everything else is fatal.
|
|
41
|
+
*/
|
|
42
|
+
export function classifyCursorProviderError(text, now = Date.now()) {
|
|
43
|
+
const detail = collapseCursorProviderError(text);
|
|
44
|
+
if (/unauthenticated/i.test(detail))
|
|
45
|
+
return { kind: 'auth' };
|
|
46
|
+
const limit = parseUsageLimit(detail, now);
|
|
47
|
+
if (limit)
|
|
48
|
+
return { kind: 'transient', resetAt: limit.resetAt };
|
|
49
|
+
if (TRANSIENT_SIGNAL_RE.test(detail))
|
|
50
|
+
return { kind: 'transient' };
|
|
51
|
+
return { kind: 'fatal' };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=cursor-provider-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-provider-error.js","sourceRoot":"","sources":["../../src/core/cursor-provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;GAOG;AAEH,0EAA0E;AAC1E,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,CAAC;AAOnD,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAC3C,MAAM,UAAU,GAAG,kDAAkD,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,mBAAmB,GACvB,gQAAgQ,CAAC;AAEnQ;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACnG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY;IACtD,OAAO,2BAA2B,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,+BAA+B,CAAC,CAAC;AACrF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACxE,MAAM,MAAM,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7D,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,IAAI,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAChE,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IACnE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/core/usage-limit.js
CHANGED
|
@@ -33,7 +33,7 @@ const CLAUDE_MARKER_RE = /claude(?:\s+ai)?\s+usage\s+limit\s+reached\s*\|\s*(\d{
|
|
|
33
33
|
* "This is a limit, not a crash." Deliberately narrow: it gates the two prose shapes below, and a
|
|
34
34
|
* false positive there would schedule a resume on a timestamp that means something else entirely.
|
|
35
35
|
*/
|
|
36
|
-
const LIMIT_PHRASE_RE = /\b(?:usage|rate|session|weekly|hourly)[\s-]?limit\b|\brate[
|
|
36
|
+
const LIMIT_PHRASE_RE = /\b(?:usage|rate|session|weekly|hourly)[\s-]?limit\b|\brate[\s_-]?limit(?:_error|ed)?\b|\bquota\s+(?:exceeded|reached)\b|\bout\s+of\s+(?:credits|quota)\b/i;
|
|
37
37
|
/** `…try again at 2026-08-03T18:00:00Z`, `…resets at 2026-08-03 18:00`. */
|
|
38
38
|
const RESET_AT_RE = /(?:resets?|reset[s]?\s+at|try\s+again|retry|available\s+again|unlocks?)\b[^\n]{0,24}?\b(\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?)/i;
|
|
39
39
|
/** `...resets 8:10pm (Europe/Warsaw)`, `...try again at 20:10`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-limit.js","sourceRoot":"","sources":["../../src/core/usage-limit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AAE5D,+FAA+F;AAC/F,MAAM,gBAAgB,GAAG,+DAA+D,CAAC;AAEzF;;;GAGG;AACH,MAAM,eAAe,GACnB,
|
|
1
|
+
{"version":3,"file":"usage-limit.js","sourceRoot":"","sources":["../../src/core/usage-limit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AASH;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AAE5D,+FAA+F;AAC/F,MAAM,gBAAgB,GAAG,+DAA+D,CAAC;AAEzF;;;GAGG;AACH,MAAM,eAAe,GACnB,2JAA2J,CAAC;AAE9J,2EAA2E;AAC3E,MAAM,WAAW,GACf,6KAA6K,CAAC;AAEhL,mEAAmE;AACnE,MAAM,cAAc,GAClB,kLAAkL,CAAC;AAErL,oFAAoF;AACpF,MAAM,WAAW,GACf,gJAAgJ,CAAC;AACnJ,MAAM,qBAAqB,GAAG,8CAA8C,CAAC;AAE7E,MAAM,OAAO,GAA2B;IACtC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK;IAChE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IACrE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,E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O,IAAI,CAAC;IAC3C,IAAI,OAAO,GAAG,GAAG,GAAG,uBAAuB;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -300,18 +300,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
300
300
|
} & {
|
|
301
301
|
"/:workerId": {
|
|
302
302
|
$get: {
|
|
303
|
-
output: {
|
|
304
|
-
error: string;
|
|
305
|
-
code?: "invalid_input" | undefined;
|
|
306
|
-
};
|
|
307
|
-
outputFormat: "json";
|
|
308
|
-
status: 400;
|
|
309
|
-
input: {
|
|
310
|
-
param: {
|
|
311
|
-
workerId: string;
|
|
312
|
-
};
|
|
313
|
-
};
|
|
314
|
-
} | {
|
|
315
303
|
output: {
|
|
316
304
|
workerId: string;
|
|
317
305
|
parentRunId: string;
|
|
@@ -388,11 +376,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
388
376
|
workerId: string;
|
|
389
377
|
};
|
|
390
378
|
};
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
} & {
|
|
394
|
-
"/:workerId/collect": {
|
|
395
|
-
$post: {
|
|
379
|
+
} | {
|
|
396
380
|
output: {
|
|
397
381
|
error: string;
|
|
398
382
|
code?: "invalid_input" | undefined;
|
|
@@ -403,10 +387,12 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
403
387
|
param: {
|
|
404
388
|
workerId: string;
|
|
405
389
|
};
|
|
406
|
-
} & {
|
|
407
|
-
json: Record<string, never>;
|
|
408
390
|
};
|
|
409
|
-
}
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
} & {
|
|
394
|
+
"/:workerId/collect": {
|
|
395
|
+
$post: {
|
|
410
396
|
output: {
|
|
411
397
|
workerId: string;
|
|
412
398
|
parentRunId: string;
|
|
@@ -508,11 +494,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
508
494
|
} & {
|
|
509
495
|
json: Record<string, never>;
|
|
510
496
|
};
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
} & {
|
|
514
|
-
"/:workerId/steer": {
|
|
515
|
-
$post: {
|
|
497
|
+
} | {
|
|
516
498
|
output: {
|
|
517
499
|
error: string;
|
|
518
500
|
code?: "invalid_input" | undefined;
|
|
@@ -524,11 +506,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
524
506
|
workerId: string;
|
|
525
507
|
};
|
|
526
508
|
} & {
|
|
527
|
-
json:
|
|
528
|
-
text: string;
|
|
529
|
-
};
|
|
509
|
+
json: Record<string, never>;
|
|
530
510
|
};
|
|
531
|
-
}
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
} & {
|
|
514
|
+
"/:workerId/steer": {
|
|
515
|
+
$post: {
|
|
532
516
|
output: {
|
|
533
517
|
workerId: string;
|
|
534
518
|
state: "delivered" | "queued";
|
|
@@ -544,11 +528,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
544
528
|
text: string;
|
|
545
529
|
};
|
|
546
530
|
};
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
} & {
|
|
550
|
-
"/:workerId/stop": {
|
|
551
|
-
$post: {
|
|
531
|
+
} | {
|
|
552
532
|
output: {
|
|
553
533
|
error: string;
|
|
554
534
|
code?: "invalid_input" | undefined;
|
|
@@ -560,9 +540,15 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
560
540
|
workerId: string;
|
|
561
541
|
};
|
|
562
542
|
} & {
|
|
563
|
-
json:
|
|
543
|
+
json: {
|
|
544
|
+
text: string;
|
|
545
|
+
};
|
|
564
546
|
};
|
|
565
|
-
}
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
} & {
|
|
550
|
+
"/:workerId/stop": {
|
|
551
|
+
$post: {
|
|
566
552
|
output: {
|
|
567
553
|
workerId: string;
|
|
568
554
|
state: "stopping" | "terminated";
|
|
@@ -576,11 +562,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
576
562
|
} & {
|
|
577
563
|
json: Record<string, never>;
|
|
578
564
|
};
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
} & {
|
|
582
|
-
"/:workerId/destroy": {
|
|
583
|
-
$post: {
|
|
565
|
+
} | {
|
|
584
566
|
output: {
|
|
585
567
|
error: string;
|
|
586
568
|
code?: "invalid_input" | undefined;
|
|
@@ -594,7 +576,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
594
576
|
} & {
|
|
595
577
|
json: Record<string, never>;
|
|
596
578
|
};
|
|
597
|
-
}
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
} & {
|
|
582
|
+
"/:workerId/destroy": {
|
|
583
|
+
$post: {
|
|
598
584
|
output: {
|
|
599
585
|
workerId: string;
|
|
600
586
|
state: "complete" | "incomplete";
|
|
@@ -617,6 +603,20 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
617
603
|
} & {
|
|
618
604
|
json: Record<string, never>;
|
|
619
605
|
};
|
|
606
|
+
} | {
|
|
607
|
+
output: {
|
|
608
|
+
error: string;
|
|
609
|
+
code?: "invalid_input" | undefined;
|
|
610
|
+
};
|
|
611
|
+
outputFormat: "json";
|
|
612
|
+
status: 400;
|
|
613
|
+
input: {
|
|
614
|
+
param: {
|
|
615
|
+
workerId: string;
|
|
616
|
+
};
|
|
617
|
+
} & {
|
|
618
|
+
json: Record<string, never>;
|
|
619
|
+
};
|
|
620
620
|
} | {
|
|
621
621
|
output: {
|
|
622
622
|
workerId: string;
|
|
@@ -646,11 +646,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
646
646
|
"/:workerId/diff": {
|
|
647
647
|
$get: {
|
|
648
648
|
output: {
|
|
649
|
-
|
|
650
|
-
|
|
649
|
+
workerId: string;
|
|
650
|
+
baselineSha: string;
|
|
651
|
+
diff: string;
|
|
652
|
+
truncated: boolean;
|
|
651
653
|
};
|
|
652
654
|
outputFormat: "json";
|
|
653
|
-
status:
|
|
655
|
+
status: 200;
|
|
654
656
|
input: {
|
|
655
657
|
param: {
|
|
656
658
|
workerId: string;
|
|
@@ -658,13 +660,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
658
660
|
};
|
|
659
661
|
} | {
|
|
660
662
|
output: {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
diff: string;
|
|
664
|
-
truncated: boolean;
|
|
663
|
+
error: string;
|
|
664
|
+
code?: "invalid_input" | undefined;
|
|
665
665
|
};
|
|
666
666
|
outputFormat: "json";
|
|
667
|
-
status:
|
|
667
|
+
status: 400;
|
|
668
668
|
input: {
|
|
669
669
|
param: {
|
|
670
670
|
workerId: string;
|
|
@@ -67,13 +67,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
67
67
|
status: 200;
|
|
68
68
|
input: {
|
|
69
69
|
json: {
|
|
70
|
-
requestIds: string[];
|
|
71
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
72
|
-
timeoutSeconds?: number | undefined;
|
|
73
|
-
} | {
|
|
74
70
|
workerIds: string[];
|
|
75
71
|
timeoutSeconds?: number | undefined;
|
|
76
72
|
mode?: "all" | "any" | "one" | undefined;
|
|
73
|
+
} | {
|
|
74
|
+
requestIds: string[];
|
|
75
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
76
|
+
timeoutSeconds?: number | undefined;
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
};
|
|
@@ -13,11 +13,18 @@ export declare function agentTmpDir(dataDir: string, runId: string): string;
|
|
|
13
13
|
* like the 100-character directories #387 reports, moves to the fallback.
|
|
14
14
|
*/
|
|
15
15
|
export declare const MAX_SOCKET_SAFE_DIR_LENGTH = 78;
|
|
16
|
+
/** The first path whose UTF-8 byte length fits the socket budget, or
|
|
17
|
+
* `undefined` when none does. Pure on purpose (#440): resolution calls it
|
|
18
|
+
* with the real candidates, tests with synthetic ones, so the nothing-fits
|
|
19
|
+
* branch stays exercised even though a real platform root is always short. */
|
|
20
|
+
export declare function firstSocketSafeDir(paths: readonly string[]): string | undefined;
|
|
16
21
|
/**
|
|
17
22
|
* The temp directory this run should use: the repo-local per-run directory
|
|
18
|
-
* when it is short enough for unix-socket paths, and a short
|
|
19
|
-
* the OS temp root
|
|
20
|
-
*
|
|
23
|
+
* when it is short enough for unix-socket paths, and otherwise a short
|
|
24
|
+
* digest-named directory under the first OS temp root whose candidate fits —
|
|
25
|
+
* the env-honouring root first, the platform default when `TMPDIR` itself is
|
|
26
|
+
* too deep (#387, #440). Pure resolution — nothing is created, nothing is
|
|
27
|
+
* probed; `agentTmpEnv` owns the side effects.
|
|
21
28
|
*/
|
|
22
29
|
export declare function resolveAgentTmpDir(dataDir: string, runId: string): string;
|
|
23
30
|
/**
|
|
@@ -58,24 +65,26 @@ export declare function agentTmpEnv(dataDir: string, runId: string, env?: NodeJS
|
|
|
58
65
|
* agent is gone, and a Continue re-creates it through `agentTmpEnv`. Never
|
|
59
66
|
* throws — reaping must not break a terminal transition.
|
|
60
67
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
68
|
+
* The repo-local directory and the digest name under EVERY root are tried,
|
|
69
|
+
* because the resolution depends on the lengths of `dataDir` and the ambient
|
|
70
|
+
* `TMPDIR`, either of which a Continue, a re-base or a changed env can move
|
|
71
|
+
* between mint and reap; removing a name that was never minted is a no-op, so
|
|
72
|
+
* trying them all is pure safety.
|
|
65
73
|
*/
|
|
66
74
|
export declare function removeAgentTmpDir(dataDir: string, runId: string): void;
|
|
67
75
|
/**
|
|
68
76
|
* Remove every per-run directory that is not in `keepRunIds` — the startup
|
|
69
77
|
* sweep, so a crash (which never reaches the terminal-transition reap) cannot
|
|
70
|
-
* accumulate them forever.
|
|
78
|
+
* accumulate them forever. Three confined sets are swept and nothing else:
|
|
71
79
|
*
|
|
72
80
|
* - `<dataDir>/tmp`, where entries ARE the run ids (reports the ids reaped);
|
|
73
|
-
* - the
|
|
74
|
-
*
|
|
81
|
+
* - the `cez-agent-<12 hex>` directories under EVERY OS temp root — the
|
|
82
|
+
* env-honouring root and the platform default (#440) — where the name
|
|
83
|
+
* digests the dataDir and is not reversible to a run id (reports the
|
|
75
84
|
* directory names reaped). The pattern is exact — prefix, lowercase hex,
|
|
76
85
|
* fixed length, directories only — and a directory is removed only when
|
|
77
86
|
* its `.cez-owner` marker names THIS dataDir and none of this dataDir's
|
|
78
|
-
* kept runs claims it, so another project's scratch in
|
|
87
|
+
* kept runs claims it, so another project's scratch in a shared root is
|
|
79
88
|
* never touched.
|
|
80
89
|
*/
|
|
81
90
|
export declare function sweepAgentTmpDirs(dataDir: string, keepRunIds: Iterable<string>): string[];
|
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
* typechecking inside the run. A directory that would land too deep
|
|
31
31
|
* resolves instead to a short digest-named directory under the OS temp
|
|
32
32
|
* root — still per-run, still probed, still reaped. A repo whose own path
|
|
33
|
-
* already fits keeps today's directory, byte for byte.
|
|
33
|
+
* already fits keeps today's directory, byte for byte. When the ambient
|
|
34
|
+
* `TMPDIR` itself is too deep for that root's candidate (#440 — routine
|
|
35
|
+
* inside a cezar task session, whose `TMPDIR` is the checkout's own
|
|
36
|
+
* scratch tree per #785), the next root is the platform's own temp root
|
|
37
|
+
* (`/tmp`), which `TMPDIR` cannot deepen; only when no root fits does the
|
|
38
|
+
* spawn refuse.
|
|
34
39
|
*
|
|
35
40
|
* `CEZ_AGENT_TMPDIR=0` opts out of ALL THREE — cezar keeps its hands off the
|
|
36
41
|
* temp directory entirely and the pre-#785 behaviour is back, byte for byte.
|
|
@@ -85,6 +90,33 @@ function osTempRoot() {
|
|
|
85
90
|
return tmpdir();
|
|
86
91
|
}
|
|
87
92
|
}
|
|
93
|
+
/** The platform's own temp root — the one `TMPDIR`/`TEMP`/`TMP` cannot move.
|
|
94
|
+
* POSIX spells it `/tmp` (resolved through symlinks for the same reason
|
|
95
|
+
* `osTempRoot` resolves them). Windows has no such constant and no named
|
|
96
|
+
* unix sockets to protect, so it contributes no second root and keeps
|
|
97
|
+
* today's single-root behaviour. */
|
|
98
|
+
function platformTempRoot() {
|
|
99
|
+
if (process.platform === 'win32')
|
|
100
|
+
return undefined;
|
|
101
|
+
try {
|
|
102
|
+
return realpathSync('/tmp');
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return '/tmp';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Every root a fallback directory can hang off, most preferred first: the
|
|
109
|
+
* env-honouring OS temp root, then the platform default (#440). A cezar task
|
|
110
|
+
* session exports a `TMPDIR` as deep as the checkout it belongs to (#785),
|
|
111
|
+
* so the first root's candidate can itself cross the socket cap while the
|
|
112
|
+
* platform default still fits. Resolution picks the first root whose
|
|
113
|
+
* candidate fits; removal and the sweep walk them all, because the env can
|
|
114
|
+
* differ between mint and reap. */
|
|
115
|
+
function osTempRoots() {
|
|
116
|
+
const env = osTempRoot();
|
|
117
|
+
const platform = platformTempRoot();
|
|
118
|
+
return platform && platform !== env ? [env, platform] : [env];
|
|
119
|
+
}
|
|
88
120
|
const FALLBACK_PREFIX = 'cez-agent-';
|
|
89
121
|
const FALLBACK_NAME_LENGTH = 12;
|
|
90
122
|
/** The marker file inside a fallback directory naming the dataDir that minted
|
|
@@ -124,39 +156,52 @@ function writeOwnerMarker(dir, dataDir) {
|
|
|
124
156
|
}
|
|
125
157
|
}
|
|
126
158
|
/**
|
|
127
|
-
* Where the fallback lives for this dataDir+run pair. The name
|
|
128
|
-
* dataDir in, because the OS temp
|
|
129
|
-
* id alone would let one repo's reap delete another repo's live
|
|
130
|
-
* two run ids happen to share their leading characters. The name
|
|
131
|
-
* make the sweep safe — a digest is not reversible, so a sweep
|
|
132
|
-
* its own stale directories from another project's live ones —
|
|
133
|
-
* every fallback directory also carries the `.cez-owner` marker.
|
|
159
|
+
* Where the fallback lives for this dataDir+run pair under one root. The name
|
|
160
|
+
* digests the dataDir in, because the OS temp roots are SHARED: a name derived
|
|
161
|
+
* from the run id alone would let one repo's reap delete another repo's live
|
|
162
|
+
* scratch when two run ids happen to share their leading characters. The name
|
|
163
|
+
* alone cannot make the sweep safe — a digest is not reversible, so a sweep
|
|
164
|
+
* could not tell its own stale directories from another project's live ones —
|
|
165
|
+
* which is why every fallback directory also carries the `.cez-owner` marker.
|
|
166
|
+
* The digest does not include the root, so the name is stable across roots:
|
|
167
|
+
* whatever env a later reap or sweep runs under, it can find the directory.
|
|
134
168
|
*/
|
|
135
|
-
function fallbackTmpDir(dataDir, runId) {
|
|
169
|
+
function fallbackTmpDir(root, dataDir, runId) {
|
|
136
170
|
const digest = createHash('sha256').update(`${dataDir}:${runId}`).digest('hex');
|
|
137
|
-
return join(
|
|
171
|
+
return join(root, FALLBACK_PREFIX + digest.slice(0, FALLBACK_NAME_LENGTH));
|
|
172
|
+
}
|
|
173
|
+
/** The first path whose UTF-8 byte length fits the socket budget, or
|
|
174
|
+
* `undefined` when none does. Pure on purpose (#440): resolution calls it
|
|
175
|
+
* with the real candidates, tests with synthetic ones, so the nothing-fits
|
|
176
|
+
* branch stays exercised even though a real platform root is always short. */
|
|
177
|
+
export function firstSocketSafeDir(paths) {
|
|
178
|
+
return paths.find((path) => Buffer.byteLength(path, 'utf8') <= MAX_SOCKET_SAFE_DIR_LENGTH);
|
|
138
179
|
}
|
|
139
180
|
/**
|
|
140
181
|
* The temp directory this run should use: the repo-local per-run directory
|
|
141
|
-
* when it is short enough for unix-socket paths, and a short
|
|
142
|
-
* the OS temp root
|
|
143
|
-
*
|
|
182
|
+
* when it is short enough for unix-socket paths, and otherwise a short
|
|
183
|
+
* digest-named directory under the first OS temp root whose candidate fits —
|
|
184
|
+
* the env-honouring root first, the platform default when `TMPDIR` itself is
|
|
185
|
+
* too deep (#387, #440). Pure resolution — nothing is created, nothing is
|
|
186
|
+
* probed; `agentTmpEnv` owns the side effects.
|
|
144
187
|
*/
|
|
145
188
|
export function resolveAgentTmpDir(dataDir, runId) {
|
|
146
189
|
const local = agentTmpDir(dataDir, runId);
|
|
147
190
|
if (Buffer.byteLength(local, 'utf8') <= MAX_SOCKET_SAFE_DIR_LENGTH)
|
|
148
191
|
return local;
|
|
149
|
-
const
|
|
150
|
-
|
|
192
|
+
const candidates = osTempRoots().map((root) => fallbackTmpDir(root, dataDir, runId));
|
|
193
|
+
const fallback = firstSocketSafeDir(candidates);
|
|
194
|
+
if (fallback)
|
|
151
195
|
return fallback;
|
|
152
|
-
// Nothing fits —
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
+ `${Buffer.byteLength(
|
|
159
|
-
+ `${MAX_SOCKET_SAFE_DIR_LENGTH}-byte unix socket budget`
|
|
196
|
+
// Nothing fits — every root, the platform default included, has a candidate
|
|
197
|
+
// past the cap. Minting any would hand the agent a temp directory that
|
|
198
|
+
// cannot serve unix sockets: the silent failure #387 is about. Fail the
|
|
199
|
+
// spawn with the named error instead; the remedy names the escape.
|
|
200
|
+
const shortest = candidates.reduce((a, b) => Buffer.byteLength(a, 'utf8') < Buffer.byteLength(b, 'utf8') ? a : b);
|
|
201
|
+
throw new AgentTempDirError(Buffer.byteLength(shortest) < Buffer.byteLength(local) ? shortest : local, new Error(`no socket-safe temp directory exists — repo-local path is `
|
|
202
|
+
+ `${Buffer.byteLength(local)} bytes and every OS temp root candidate is past the `
|
|
203
|
+
+ `${MAX_SOCKET_SAFE_DIR_LENGTH}-byte unix socket budget (tried: `
|
|
204
|
+
+ candidates.map((c) => `${c} (${Buffer.byteLength(c)} bytes)`).join(', ') + ')'));
|
|
160
205
|
}
|
|
161
206
|
/** `errno` → the phrasing a human recognises from their shell. */
|
|
162
207
|
const REASONS = {
|
|
@@ -259,15 +304,17 @@ export function agentTmpEnv(dataDir, runId, env = process.env) {
|
|
|
259
304
|
* agent is gone, and a Continue re-creates it through `agentTmpEnv`. Never
|
|
260
305
|
* throws — reaping must not break a terminal transition.
|
|
261
306
|
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
307
|
+
* The repo-local directory and the digest name under EVERY root are tried,
|
|
308
|
+
* because the resolution depends on the lengths of `dataDir` and the ambient
|
|
309
|
+
* `TMPDIR`, either of which a Continue, a re-base or a changed env can move
|
|
310
|
+
* between mint and reap; removing a name that was never minted is a no-op, so
|
|
311
|
+
* trying them all is pure safety.
|
|
266
312
|
*/
|
|
267
313
|
export function removeAgentTmpDir(dataDir, runId) {
|
|
268
314
|
if (!safeRunId(runId))
|
|
269
315
|
return;
|
|
270
|
-
|
|
316
|
+
const locations = [agentTmpDir(dataDir, runId), ...osTempRoots().map((root) => fallbackTmpDir(root, dataDir, runId))];
|
|
317
|
+
for (const dir of locations) {
|
|
271
318
|
try {
|
|
272
319
|
rmSync(dir, { recursive: true, force: true });
|
|
273
320
|
}
|
|
@@ -279,15 +326,16 @@ export function removeAgentTmpDir(dataDir, runId) {
|
|
|
279
326
|
/**
|
|
280
327
|
* Remove every per-run directory that is not in `keepRunIds` — the startup
|
|
281
328
|
* sweep, so a crash (which never reaches the terminal-transition reap) cannot
|
|
282
|
-
* accumulate them forever.
|
|
329
|
+
* accumulate them forever. Three confined sets are swept and nothing else:
|
|
283
330
|
*
|
|
284
331
|
* - `<dataDir>/tmp`, where entries ARE the run ids (reports the ids reaped);
|
|
285
|
-
* - the
|
|
286
|
-
*
|
|
332
|
+
* - the `cez-agent-<12 hex>` directories under EVERY OS temp root — the
|
|
333
|
+
* env-honouring root and the platform default (#440) — where the name
|
|
334
|
+
* digests the dataDir and is not reversible to a run id (reports the
|
|
287
335
|
* directory names reaped). The pattern is exact — prefix, lowercase hex,
|
|
288
336
|
* fixed length, directories only — and a directory is removed only when
|
|
289
337
|
* its `.cez-owner` marker names THIS dataDir and none of this dataDir's
|
|
290
|
-
* kept runs claims it, so another project's scratch in
|
|
338
|
+
* kept runs claims it, so another project's scratch in a shared root is
|
|
291
339
|
* never touched.
|
|
292
340
|
*/
|
|
293
341
|
export function sweepAgentTmpDirs(dataDir, keepRunIds) {
|
|
@@ -316,44 +364,45 @@ export function sweepAgentTmpDirs(dataDir, keepRunIds) {
|
|
|
316
364
|
}
|
|
317
365
|
}
|
|
318
366
|
}
|
|
319
|
-
// The #387 fallback
|
|
367
|
+
// The #387 fallback locations, in every shared OS temp root. Kept narrow on
|
|
320
368
|
// purpose: exact prefix, 12 lowercase-hex name, directories only, and
|
|
321
369
|
// ownership — a directory is removed only when its `.cez-owner` marker
|
|
322
370
|
// names THIS dataDir (a marker that is missing or foreign is another
|
|
323
371
|
// project's, or unknown, and is never ours to remove) and none of this
|
|
324
372
|
// dataDir's kept runs claims it.
|
|
325
373
|
const owner = dataDirOwner(dataDir);
|
|
326
|
-
const claimed = new Set([...keep].filter(safeRunId).map((id) => basename(fallbackTmpDir(dataDir, id))));
|
|
327
|
-
const osRoot
|
|
328
|
-
|
|
329
|
-
try {
|
|
330
|
-
fallbackEntries = readdirSync(osRoot, { withFileTypes: true });
|
|
331
|
-
}
|
|
332
|
-
catch {
|
|
333
|
-
return reaped;
|
|
334
|
-
}
|
|
335
|
-
for (const entry of fallbackEntries) {
|
|
336
|
-
if (!entry.isDirectory() || !entry.name.startsWith(FALLBACK_PREFIX))
|
|
337
|
-
continue;
|
|
338
|
-
if (!/^[0-9a-f]{12}$/.test(entry.name.slice(FALLBACK_PREFIX.length)))
|
|
339
|
-
continue;
|
|
340
|
-
let entryOwner;
|
|
374
|
+
const claimed = new Set([...keep].filter(safeRunId).map((id) => basename(fallbackTmpDir(osTempRoot(), dataDir, id))));
|
|
375
|
+
for (const osRoot of osTempRoots()) {
|
|
376
|
+
let fallbackEntries;
|
|
341
377
|
try {
|
|
342
|
-
|
|
378
|
+
fallbackEntries = readdirSync(osRoot, { withFileTypes: true });
|
|
343
379
|
}
|
|
344
380
|
catch {
|
|
345
|
-
continue; //
|
|
381
|
+
continue; // an unreadable root is skipped, not fatal: others remain.
|
|
346
382
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
383
|
+
for (const entry of fallbackEntries) {
|
|
384
|
+
if (!entry.isDirectory() || !entry.name.startsWith(FALLBACK_PREFIX))
|
|
385
|
+
continue;
|
|
386
|
+
if (!/^[0-9a-f]{12}$/.test(entry.name.slice(FALLBACK_PREFIX.length)))
|
|
387
|
+
continue;
|
|
388
|
+
let entryOwner;
|
|
389
|
+
try {
|
|
390
|
+
entryOwner = readFileSync(join(osRoot, entry.name, OWNER_FILE), 'utf8').trim();
|
|
391
|
+
}
|
|
392
|
+
catch {
|
|
393
|
+
continue; // no readable marker: unknown ownership is never ours to remove.
|
|
394
|
+
}
|
|
395
|
+
if (entryOwner !== owner)
|
|
396
|
+
continue;
|
|
397
|
+
if (claimed.has(entry.name))
|
|
398
|
+
continue;
|
|
399
|
+
try {
|
|
400
|
+
rmSync(join(osRoot, entry.name), { recursive: true, force: true });
|
|
401
|
+
reaped.push(entry.name);
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
// best-effort: a locked directory is retried on the next boot.
|
|
405
|
+
}
|
|
357
406
|
}
|
|
358
407
|
}
|
|
359
408
|
return reaped;
|