pi-harness-runtime 1.1.451 → 1.1.453
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/AGENTS.md +85 -3
- package/CHANGELOG.md +52 -0
- package/index.ts +248 -21
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/batch-plan.d.ts +150 -0
- package/packages/jev-judge/dist/batch-plan.d.ts.map +1 -0
- package/packages/jev-judge/dist/batch-plan.js +192 -0
- package/packages/jev-judge/dist/batch-plan.js.map +1 -0
- package/packages/jev-judge/dist/continuation-status.d.ts +31 -0
- package/packages/jev-judge/dist/continuation-status.d.ts.map +1 -0
- package/packages/jev-judge/dist/continuation-status.js +40 -0
- package/packages/jev-judge/dist/continuation-status.js.map +1 -0
- package/packages/jev-judge/dist/delegation-harness.d.ts +94 -1
- package/packages/jev-judge/dist/delegation-harness.d.ts.map +1 -1
- package/packages/jev-judge/dist/delegation-harness.js +247 -20
- package/packages/jev-judge/dist/delegation-harness.js.map +1 -1
- package/packages/jev-judge/dist/delegation-observer.d.ts +98 -0
- package/packages/jev-judge/dist/delegation-observer.d.ts.map +1 -0
- package/packages/jev-judge/dist/delegation-observer.js +152 -0
- package/packages/jev-judge/dist/delegation-observer.js.map +1 -0
- package/packages/jev-judge/dist/delegation-scope.d.ts +88 -0
- package/packages/jev-judge/dist/delegation-scope.d.ts.map +1 -0
- package/packages/jev-judge/dist/delegation-scope.js +218 -0
- package/packages/jev-judge/dist/delegation-scope.js.map +1 -0
- package/packages/jev-judge/dist/index.d.ts +4 -0
- package/packages/jev-judge/dist/index.d.ts.map +1 -1
- package/packages/jev-judge/dist/index.js +4 -0
- package/packages/jev-judge/dist/index.js.map +1 -1
- package/packages/jev-judge/dist/pilot.d.ts +127 -0
- package/packages/jev-judge/dist/pilot.d.ts.map +1 -0
- package/packages/jev-judge/dist/pilot.js +178 -0
- package/packages/jev-judge/dist/pilot.js.map +1 -0
- package/packages/jev-judge/dist/validation-plan.d.ts +18 -0
- package/packages/jev-judge/dist/validation-plan.d.ts.map +1 -1
- package/packages/jev-judge/dist/validation-plan.js +93 -4
- package/packages/jev-judge/dist/validation-plan.js.map +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/batch-plan.ts +273 -0
- package/packages/jev-judge/src/continuation-status.ts +41 -0
- package/packages/jev-judge/src/delegation-harness.ts +337 -47
- package/packages/jev-judge/src/delegation-observer.ts +181 -0
- package/packages/jev-judge/src/delegation-scope.ts +264 -0
- package/packages/jev-judge/src/index.ts +36 -0
- package/packages/jev-judge/src/pilot.ts +257 -0
- package/packages/jev-judge/src/validation-plan.ts +110 -4
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/dist/classify.d.ts +26 -1
- package/packages/two-phase-review/dist/classify.d.ts.map +1 -1
- package/packages/two-phase-review/dist/classify.js +42 -1
- package/packages/two-phase-review/dist/classify.js.map +1 -1
- package/packages/two-phase-review/dist/index.d.ts +4 -2
- package/packages/two-phase-review/dist/index.d.ts.map +1 -1
- package/packages/two-phase-review/dist/index.js +3 -2
- package/packages/two-phase-review/dist/index.js.map +1 -1
- package/packages/two-phase-review/dist/rules.d.ts +38 -3
- package/packages/two-phase-review/dist/rules.d.ts.map +1 -1
- package/packages/two-phase-review/dist/rules.js +83 -10
- package/packages/two-phase-review/dist/rules.js.map +1 -1
- package/packages/two-phase-review/dist/runtime.d.ts +17 -0
- package/packages/two-phase-review/dist/runtime.d.ts.map +1 -1
- package/packages/two-phase-review/dist/runtime.js +122 -22
- package/packages/two-phase-review/dist/runtime.js.map +1 -1
- package/packages/two-phase-review/dist/state.d.ts +15 -0
- package/packages/two-phase-review/dist/state.d.ts.map +1 -1
- package/packages/two-phase-review/dist/state.js +37 -2
- package/packages/two-phase-review/dist/state.js.map +1 -1
- package/packages/two-phase-review/dist/types.d.ts +2 -2
- package/packages/two-phase-review/dist/types.d.ts.map +1 -1
- package/packages/two-phase-review/dist/validation.d.ts +50 -0
- package/packages/two-phase-review/dist/validation.d.ts.map +1 -0
- package/packages/two-phase-review/dist/validation.js +54 -0
- package/packages/two-phase-review/dist/validation.js.map +1 -0
- package/packages/two-phase-review/package.json +1 -1
- package/packages/two-phase-review/src/classify.ts +47 -1
- package/packages/two-phase-review/src/index.ts +16 -0
- package/packages/two-phase-review/src/rules.ts +117 -9
- package/packages/two-phase-review/src/runtime.ts +151 -21
- package/packages/two-phase-review/src/state.ts +38 -2
- package/packages/two-phase-review/src/types.ts +2 -1
- package/packages/two-phase-review/src/validation.ts +86 -0
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The batches of a large job.
|
|
3
|
+
*
|
|
4
|
+
* A large job does not run in one piece. It starts with a measured pilot
|
|
5
|
+
* and continues in bounded batches, and the state of every batch is kept
|
|
6
|
+
* so a failure resumes instead of restarting.
|
|
7
|
+
*
|
|
8
|
+
* Every number here is either given or measured. The harness never
|
|
9
|
+
* estimates a duration from a number it invented: an estimate needs a
|
|
10
|
+
* measured cost per record, and without one the estimate is unknown.
|
|
11
|
+
*/
|
|
12
|
+
/** The kind of a batch. */
|
|
13
|
+
export type BatchKind = "pilot" | "scale-up";
|
|
14
|
+
/** The state of a batch. */
|
|
15
|
+
export type BatchStatus = "pending" | "running" | "done" | "failed";
|
|
16
|
+
/**
|
|
17
|
+
* One batch of a large job.
|
|
18
|
+
*/
|
|
19
|
+
export interface Batch {
|
|
20
|
+
/** The id of the batch. */
|
|
21
|
+
id: string;
|
|
22
|
+
/** The kind of the batch. */
|
|
23
|
+
kind: BatchKind;
|
|
24
|
+
/** The first record of the batch (inclusive). */
|
|
25
|
+
from: number;
|
|
26
|
+
/** The last record of the batch (inclusive). */
|
|
27
|
+
to: number;
|
|
28
|
+
/** The number of records of the batch. */
|
|
29
|
+
records: number;
|
|
30
|
+
/** The state of the batch. */
|
|
31
|
+
status: BatchStatus;
|
|
32
|
+
/** How often the batch was tried. */
|
|
33
|
+
attempts: number;
|
|
34
|
+
/** The measured duration of the batch. */
|
|
35
|
+
durationMs?: number;
|
|
36
|
+
/** The reason of a failure. */
|
|
37
|
+
failure?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The plan of a large job.
|
|
41
|
+
*
|
|
42
|
+
* The limits are explicit: the size of the pilot, the size of a batch,
|
|
43
|
+
* the number of batches that may run at the same time and the budget.
|
|
44
|
+
*/
|
|
45
|
+
export interface BatchPlan {
|
|
46
|
+
/** The number of records of the whole job. */
|
|
47
|
+
totalRecords: number;
|
|
48
|
+
/** The number of records of the representative pilot. */
|
|
49
|
+
pilotRecords: number;
|
|
50
|
+
/** The maximum number of records of a scale-up batch. */
|
|
51
|
+
maxBatchRecords: number;
|
|
52
|
+
/** The maximum number of batches that may run at the same time. */
|
|
53
|
+
maxConcurrentBatches: number;
|
|
54
|
+
/**
|
|
55
|
+
* The measured cost of one record, in milliseconds.
|
|
56
|
+
*
|
|
57
|
+
* Without a measured cost the estimated duration of the job is
|
|
58
|
+
* unknown, and the plan says so.
|
|
59
|
+
*/
|
|
60
|
+
msPerRecord?: number;
|
|
61
|
+
/** The budget of the whole job, in minutes. */
|
|
62
|
+
budgetMinutes?: number;
|
|
63
|
+
/** How often a failed batch is tried again. */
|
|
64
|
+
maxAttempts?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The progress of the batches.
|
|
68
|
+
*/
|
|
69
|
+
export interface BatchProgress {
|
|
70
|
+
/** The batches that are done. */
|
|
71
|
+
done: number;
|
|
72
|
+
/** The batches that failed. */
|
|
73
|
+
failed: number;
|
|
74
|
+
/** The batches that still have to run. */
|
|
75
|
+
pending: number;
|
|
76
|
+
/** The records that are done. */
|
|
77
|
+
recordsDone: number;
|
|
78
|
+
/** The records of the whole job. */
|
|
79
|
+
recordsTotal: number;
|
|
80
|
+
/** The measured duration of the finished batches. */
|
|
81
|
+
durationMs: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The batches of a job.
|
|
85
|
+
*
|
|
86
|
+
* The first batch is the pilot. The rest are the scale-up, in the order
|
|
87
|
+
* of the records.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildBatches(plan: BatchPlan): Batch[];
|
|
90
|
+
/**
|
|
91
|
+
* The estimated duration of the whole job.
|
|
92
|
+
*
|
|
93
|
+
* The estimate needs a measured cost per record. Without one the answer
|
|
94
|
+
* is unknown: the plan never guesses a duration.
|
|
95
|
+
*/
|
|
96
|
+
export declare function estimateJobMs(plan: BatchPlan): number | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* May the scale-up start?
|
|
99
|
+
*
|
|
100
|
+
* The pilot has to be done and it has to have passed. A failed pilot
|
|
101
|
+
* stops the job: the plan never scales up on a failure.
|
|
102
|
+
*/
|
|
103
|
+
export declare function mayStartScaleUp(batches: Batch[]): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* The batches that may run now.
|
|
106
|
+
*
|
|
107
|
+
* The scale-up waits for the pilot, the limit of parallel batches is
|
|
108
|
+
* respected, and a batch that already used up its attempts is never
|
|
109
|
+
* offered again.
|
|
110
|
+
*/
|
|
111
|
+
export declare function nextBatches(batches: Batch[], plan: BatchPlan): Batch[];
|
|
112
|
+
/**
|
|
113
|
+
* The result of one batch attempt.
|
|
114
|
+
*/
|
|
115
|
+
export interface BatchResult {
|
|
116
|
+
/** The id of the batch. */
|
|
117
|
+
id: string;
|
|
118
|
+
/** Did the batch succeed? */
|
|
119
|
+
ok: boolean;
|
|
120
|
+
/** The measured duration of the attempt. */
|
|
121
|
+
durationMs?: number;
|
|
122
|
+
/** The reason of a failure. */
|
|
123
|
+
failure?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Record the result of a batch attempt.
|
|
127
|
+
*
|
|
128
|
+
* A failed batch keeps its place: the batches that are done are never
|
|
129
|
+
* repeated, and a failed batch is tried again until it used up its
|
|
130
|
+
* attempts.
|
|
131
|
+
*/
|
|
132
|
+
export declare function recordBatchResult(batches: Batch[], result: BatchResult): Batch[];
|
|
133
|
+
/**
|
|
134
|
+
* The progress of the batches.
|
|
135
|
+
*/
|
|
136
|
+
export declare function batchProgress(batches: Batch[]): BatchProgress;
|
|
137
|
+
/**
|
|
138
|
+
* Is the job over the budget?
|
|
139
|
+
*
|
|
140
|
+
* The budget is a limit, not a wish: a job that spent it stops and
|
|
141
|
+
* reports. A budget that was never measured cannot be spent.
|
|
142
|
+
*/
|
|
143
|
+
export declare function overBudget(plan: BatchPlan, elapsedMs: number | undefined): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* The description of the batches, for the status line.
|
|
146
|
+
*
|
|
147
|
+
* The line is plain ASCII and names the measured facts.
|
|
148
|
+
*/
|
|
149
|
+
export declare function describeBatches(batches: Batch[]): string;
|
|
150
|
+
//# sourceMappingURL=batch-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-plan.d.ts","sourceRoot":"","sources":["../src/batch-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAE7C,4BAA4B;AAC5B,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,KAAK;IACrB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,eAAe,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM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yB7D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC3B,OAAO,CAIT;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAQxD"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The batches of a large job.
|
|
3
|
+
*
|
|
4
|
+
* A large job does not run in one piece. It starts with a measured pilot
|
|
5
|
+
* and continues in bounded batches, and the state of every batch is kept
|
|
6
|
+
* so a failure resumes instead of restarting.
|
|
7
|
+
*
|
|
8
|
+
* Every number here is either given or measured. The harness never
|
|
9
|
+
* estimates a duration from a number it invented: an estimate needs a
|
|
10
|
+
* measured cost per record, and without one the estimate is unknown.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The batches of a job.
|
|
14
|
+
*
|
|
15
|
+
* The first batch is the pilot. The rest are the scale-up, in the order
|
|
16
|
+
* of the records.
|
|
17
|
+
*/
|
|
18
|
+
export function buildBatches(plan) {
|
|
19
|
+
const batches = [];
|
|
20
|
+
if (plan.totalRecords <= 0)
|
|
21
|
+
return batches;
|
|
22
|
+
const pilotRecords = Math.max(0, Math.min(plan.pilotRecords, plan.totalRecords));
|
|
23
|
+
if (pilotRecords > 0) {
|
|
24
|
+
batches.push({
|
|
25
|
+
id: "batch-1",
|
|
26
|
+
kind: "pilot",
|
|
27
|
+
from: 1,
|
|
28
|
+
to: pilotRecords,
|
|
29
|
+
records: pilotRecords,
|
|
30
|
+
status: "pending",
|
|
31
|
+
attempts: 0,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const maxBatch = Math.max(1, plan.maxBatchRecords);
|
|
35
|
+
let from = pilotRecords + 1;
|
|
36
|
+
let index = 2;
|
|
37
|
+
while (from <= plan.totalRecords) {
|
|
38
|
+
const to = Math.min(from + maxBatch - 1, plan.totalRecords);
|
|
39
|
+
batches.push({
|
|
40
|
+
id: `batch-${index}`,
|
|
41
|
+
kind: "scale-up",
|
|
42
|
+
from,
|
|
43
|
+
to,
|
|
44
|
+
records: to - from + 1,
|
|
45
|
+
status: "pending",
|
|
46
|
+
attempts: 0,
|
|
47
|
+
});
|
|
48
|
+
from = to + 1;
|
|
49
|
+
index += 1;
|
|
50
|
+
}
|
|
51
|
+
return batches;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The estimated duration of the whole job.
|
|
55
|
+
*
|
|
56
|
+
* The estimate needs a measured cost per record. Without one the answer
|
|
57
|
+
* is unknown: the plan never guesses a duration.
|
|
58
|
+
*/
|
|
59
|
+
export function estimateJobMs(plan) {
|
|
60
|
+
if (plan.msPerRecord === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
if (plan.totalRecords <= 0)
|
|
63
|
+
return 0;
|
|
64
|
+
return Math.round(plan.msPerRecord * plan.totalRecords);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* May the scale-up start?
|
|
68
|
+
*
|
|
69
|
+
* The pilot has to be done and it has to have passed. A failed pilot
|
|
70
|
+
* stops the job: the plan never scales up on a failure.
|
|
71
|
+
*/
|
|
72
|
+
export function mayStartScaleUp(batches) {
|
|
73
|
+
const pilot = batches.find((batch) => batch.kind === "pilot");
|
|
74
|
+
if (!pilot)
|
|
75
|
+
return true;
|
|
76
|
+
return pilot.status === "done";
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The batches that may run now.
|
|
80
|
+
*
|
|
81
|
+
* The scale-up waits for the pilot, the limit of parallel batches is
|
|
82
|
+
* respected, and a batch that already used up its attempts is never
|
|
83
|
+
* offered again.
|
|
84
|
+
*/
|
|
85
|
+
export function nextBatches(batches, plan) {
|
|
86
|
+
const running = batches.filter((batch) => batch.status === "running").length;
|
|
87
|
+
let free = Math.max(0, plan.maxConcurrentBatches - running);
|
|
88
|
+
if (free === 0)
|
|
89
|
+
return [];
|
|
90
|
+
const candidates = batches.filter((batch) => {
|
|
91
|
+
if (batch.status === "done")
|
|
92
|
+
return false;
|
|
93
|
+
if (batch.status === "running")
|
|
94
|
+
return false;
|
|
95
|
+
if (batch.kind === "scale-up" && !mayStartScaleUp(batches))
|
|
96
|
+
return false;
|
|
97
|
+
if (batch.attempts >= (plan.maxAttempts ?? 1))
|
|
98
|
+
return false;
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
// The pilot comes first: it is the batch that proves the job.
|
|
102
|
+
candidates.sort((a, b) => {
|
|
103
|
+
if (a.kind !== b.kind)
|
|
104
|
+
return a.kind === "pilot" ? -1 : 1;
|
|
105
|
+
return a.from - b.from;
|
|
106
|
+
});
|
|
107
|
+
return candidates.slice(0, free).map((batch) => ({ ...batch, status: "running" }));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Record the result of a batch attempt.
|
|
111
|
+
*
|
|
112
|
+
* A failed batch keeps its place: the batches that are done are never
|
|
113
|
+
* repeated, and a failed batch is tried again until it used up its
|
|
114
|
+
* attempts.
|
|
115
|
+
*/
|
|
116
|
+
export function recordBatchResult(batches, result) {
|
|
117
|
+
return batches.map((batch) => {
|
|
118
|
+
if (batch.id !== result.id)
|
|
119
|
+
return batch;
|
|
120
|
+
const next = {
|
|
121
|
+
...batch,
|
|
122
|
+
status: result.ok ? "done" : "failed",
|
|
123
|
+
attempts: batch.attempts + 1,
|
|
124
|
+
};
|
|
125
|
+
if (result.durationMs !== undefined)
|
|
126
|
+
next.durationMs = result.durationMs;
|
|
127
|
+
if (result.failure !== undefined)
|
|
128
|
+
next.failure = result.failure;
|
|
129
|
+
return next;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The progress of the batches.
|
|
134
|
+
*/
|
|
135
|
+
export function batchProgress(batches) {
|
|
136
|
+
let done = 0;
|
|
137
|
+
let failed = 0;
|
|
138
|
+
let pending = 0;
|
|
139
|
+
let recordsDone = 0;
|
|
140
|
+
let durationMs = 0;
|
|
141
|
+
for (const batch of batches) {
|
|
142
|
+
if (batch.status === "done") {
|
|
143
|
+
done += 1;
|
|
144
|
+
recordsDone += batch.records;
|
|
145
|
+
}
|
|
146
|
+
else if (batch.status === "failed") {
|
|
147
|
+
failed += 1;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
pending += 1;
|
|
151
|
+
}
|
|
152
|
+
if (batch.durationMs !== undefined)
|
|
153
|
+
durationMs += batch.durationMs;
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
done,
|
|
157
|
+
failed,
|
|
158
|
+
pending,
|
|
159
|
+
recordsDone,
|
|
160
|
+
recordsTotal: batches.reduce((sum, batch) => sum + batch.records, 0),
|
|
161
|
+
durationMs,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Is the job over the budget?
|
|
166
|
+
*
|
|
167
|
+
* The budget is a limit, not a wish: a job that spent it stops and
|
|
168
|
+
* reports. A budget that was never measured cannot be spent.
|
|
169
|
+
*/
|
|
170
|
+
export function overBudget(plan, elapsedMs) {
|
|
171
|
+
if (plan.budgetMinutes === undefined)
|
|
172
|
+
return false;
|
|
173
|
+
if (elapsedMs === undefined)
|
|
174
|
+
return false;
|
|
175
|
+
return elapsedMs > plan.budgetMinutes * 60_000;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The description of the batches, for the status line.
|
|
179
|
+
*
|
|
180
|
+
* The line is plain ASCII and names the measured facts.
|
|
181
|
+
*/
|
|
182
|
+
export function describeBatches(batches) {
|
|
183
|
+
const progress = batchProgress(batches);
|
|
184
|
+
const parts = [
|
|
185
|
+
`batch ${progress.done + progress.failed}/${batches.length}`,
|
|
186
|
+
`${progress.recordsDone}/${progress.recordsTotal} records`,
|
|
187
|
+
];
|
|
188
|
+
if (progress.failed > 0)
|
|
189
|
+
parts.push(`${progress.failed} failed`);
|
|
190
|
+
return parts.join(" | ");
|
|
191
|
+
}
|
|
192
|
+
//#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CAAC,aAAa,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,SAAS,GAAG,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC/C,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG;QACb,SAAS,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE;QAC5D,GAAG,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,YAAY,UAAU;KAC1D,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,SAAS,CAAC,CAAC;IACjE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lifecycle of a continuation that the harness dispatched.
|
|
3
|
+
*
|
|
4
|
+
* A continuation is a turn that the harness started itself. While that
|
|
5
|
+
* turn runs, the status says so: a timer that clears the status while the
|
|
6
|
+
* agent is still working would claim that nothing runs any more.
|
|
7
|
+
*
|
|
8
|
+
* The gate is the only thing that decides whether a continuation is still
|
|
9
|
+
* pending, so it can be read and tested without a session.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContinuationGate {
|
|
12
|
+
private inFlight;
|
|
13
|
+
/**
|
|
14
|
+
* A continuation was dispatched.
|
|
15
|
+
*
|
|
16
|
+
* The status stays "RUN" from here until the turn settles.
|
|
17
|
+
*/
|
|
18
|
+
begin(): void;
|
|
19
|
+
/**
|
|
20
|
+
* The turn settled.
|
|
21
|
+
*
|
|
22
|
+
* @returns True when a continuation was still pending, so the caller
|
|
23
|
+
* has to clear the status. False when there was nothing to clear.
|
|
24
|
+
*/
|
|
25
|
+
settle(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a continuation is still running.
|
|
28
|
+
*/
|
|
29
|
+
get pending(): boolean;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=continuation-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation-status.d.ts","sourceRoot":"","sources":["../src/continuation-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAEZ;IAED;;;;;OAKG;IACH,MAAM,IAAI,OAAO,CAIhB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;CACD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lifecycle of a continuation that the harness dispatched.
|
|
3
|
+
*
|
|
4
|
+
* A continuation is a turn that the harness started itself. While that
|
|
5
|
+
* turn runs, the status says so: a timer that clears the status while the
|
|
6
|
+
* agent is still working would claim that nothing runs any more.
|
|
7
|
+
*
|
|
8
|
+
* The gate is the only thing that decides whether a continuation is still
|
|
9
|
+
* pending, so it can be read and tested without a session.
|
|
10
|
+
*/
|
|
11
|
+
export class ContinuationGate {
|
|
12
|
+
inFlight = false;
|
|
13
|
+
/**
|
|
14
|
+
* A continuation was dispatched.
|
|
15
|
+
*
|
|
16
|
+
* The status stays "RUN" from here until the turn settles.
|
|
17
|
+
*/
|
|
18
|
+
begin() {
|
|
19
|
+
this.inFlight = true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The turn settled.
|
|
23
|
+
*
|
|
24
|
+
* @returns True when a continuation was still pending, so the caller
|
|
25
|
+
* has to clear the status. False when there was nothing to clear.
|
|
26
|
+
*/
|
|
27
|
+
settle() {
|
|
28
|
+
if (!this.inFlight)
|
|
29
|
+
return false;
|
|
30
|
+
this.inFlight = false;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Whether a continuation is still running.
|
|
35
|
+
*/
|
|
36
|
+
get pending() {
|
|
37
|
+
return this.inFlight;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=continuation-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"continuation-status.js","sourceRoot":"","sources":["../src/continuation-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,gBAAgB;IACpB,QAAQ,GAAG,KAAK,CAAC;IAEzB;;;;OAIG;IACH,KAAK;QACJ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,MAAM;QACL,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACD"}
|
|
@@ -5,15 +5,33 @@
|
|
|
5
5
|
* Uses inline types to avoid cross-package dependency.
|
|
6
6
|
*/
|
|
7
7
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
import type { ScopeMeasurement, ScopeWorkGroup } from "./delegation-scope.js";
|
|
9
|
+
import { type DelegationChild } from "./delegation-observer.js";
|
|
8
10
|
/**
|
|
9
11
|
* Extension capability for delegation (inline to avoid dependency)
|
|
10
12
|
*/
|
|
11
13
|
export interface ExtensionCapability {
|
|
12
14
|
name: string;
|
|
15
|
+
/** The tool that can dispatch a child. */
|
|
16
|
+
toolName: string;
|
|
13
17
|
supportsSubagents: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The schema of the tool carries a parameter that isolates the work of
|
|
20
|
+
* a child. Without such a parameter the claim is not made.
|
|
21
|
+
*/
|
|
14
22
|
supportsWorkIsolation: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The schema of the tool carries a parameter that stops a child. Without
|
|
25
|
+
* such a parameter the claim is not made.
|
|
26
|
+
*/
|
|
15
27
|
supportsCancellation: boolean;
|
|
16
28
|
availableTools: string[];
|
|
29
|
+
/**
|
|
30
|
+
* The schema of the tool was read and the tool is active.
|
|
31
|
+
*
|
|
32
|
+
* This is not a proof that a child ever ran: it says that the session
|
|
33
|
+
* can ask for one. Only a dispatch that was really sent proves that.
|
|
34
|
+
*/
|
|
17
35
|
verified: boolean;
|
|
18
36
|
}
|
|
19
37
|
/**
|
|
@@ -26,10 +44,28 @@ export type DelegationStrategy = "delegate" | "script_then_delegate" | "script_o
|
|
|
26
44
|
export interface DelegationDecision {
|
|
27
45
|
strategy: DelegationStrategy;
|
|
28
46
|
reason: string;
|
|
29
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The groups the work falls into. They are empty unless the scope was
|
|
49
|
+
* measured: a decision without groups is not a delegation plan.
|
|
50
|
+
*/
|
|
51
|
+
workGroups: ScopeWorkGroup[];
|
|
30
52
|
validationExpectations: string;
|
|
31
53
|
confidence: "high" | "medium" | "low";
|
|
32
54
|
jevUsed: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a child was really dispatched.
|
|
57
|
+
*
|
|
58
|
+
* The harness assesses the work, it does not run it: the agent is the
|
|
59
|
+
* one that sends the groups to the sub-agent tool.
|
|
60
|
+
*/
|
|
61
|
+
dispatched: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The name of the active tool that can dispatch a child.
|
|
64
|
+
*
|
|
65
|
+
* It is empty when no such tool is active. The name is the proof that
|
|
66
|
+
* the dispatch is possible, not the proof that it happened.
|
|
67
|
+
*/
|
|
68
|
+
dispatchTool?: string;
|
|
33
69
|
reassessmentTriggers: string[];
|
|
34
70
|
}
|
|
35
71
|
/**
|
|
@@ -46,6 +82,11 @@ export interface ScopeFacts {
|
|
|
46
82
|
isComplex: boolean;
|
|
47
83
|
fileTypes: Record<string, number>;
|
|
48
84
|
fingerprint: string;
|
|
85
|
+
/**
|
|
86
|
+
* The measured groups of the work. A delegation decision needs them:
|
|
87
|
+
* without groups there is nothing to hand to a child.
|
|
88
|
+
*/
|
|
89
|
+
workGroups: ScopeWorkGroup[];
|
|
49
90
|
}
|
|
50
91
|
/**
|
|
51
92
|
* Delegation receipt
|
|
@@ -61,6 +102,13 @@ export interface DelegationReceipt {
|
|
|
61
102
|
updatedAt: number;
|
|
62
103
|
status: "assessing" | "in_progress" | "completed" | "failed" | "cancelled";
|
|
63
104
|
childIds: string[];
|
|
105
|
+
/**
|
|
106
|
+
* The children that were really dispatched.
|
|
107
|
+
*
|
|
108
|
+
* They are observed, not assumed: a child is in this list when its
|
|
109
|
+
* tool call was seen, and it carries what the extension reported.
|
|
110
|
+
*/
|
|
111
|
+
children: DelegationChild[];
|
|
64
112
|
pendingValidation: string[];
|
|
65
113
|
userConstraints: string[];
|
|
66
114
|
}
|
|
@@ -72,6 +120,39 @@ export interface DelegationHarnessConfig {
|
|
|
72
120
|
minCallSites?: number;
|
|
73
121
|
minComponents?: number;
|
|
74
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Build the scope facts from a measurement.
|
|
125
|
+
*
|
|
126
|
+
* Every number is a count of something the measurement found. The
|
|
127
|
+
* estimate is the size of the workspace: it is a real number, and it says
|
|
128
|
+
* how much of the repository the measured files are.
|
|
129
|
+
*/
|
|
130
|
+
export declare function scopeFactsFromMeasurement(measurement: ScopeMeasurement): ScopeFacts;
|
|
131
|
+
/**
|
|
132
|
+
* Build the message that hands a delegation plan to the agent.
|
|
133
|
+
*
|
|
134
|
+
* The message names the measured groups and the tool that can dispatch a
|
|
135
|
+
* child. It does not claim that anything was dispatched: the harness
|
|
136
|
+
* measured the work, the agent is the one that sends the groups out.
|
|
137
|
+
*
|
|
138
|
+
* @param decision The decision of the assessment.
|
|
139
|
+
* @returns The message, or null when there is nothing to hand out.
|
|
140
|
+
*/
|
|
141
|
+
export declare function buildDelegationSteer(decision: {
|
|
142
|
+
strategy: string;
|
|
143
|
+
workGroups?: {
|
|
144
|
+
id: string;
|
|
145
|
+
files: string[];
|
|
146
|
+
}[];
|
|
147
|
+
dispatchTool?: string;
|
|
148
|
+
} | null): string | null;
|
|
149
|
+
/**
|
|
150
|
+
* The property names of a tool schema.
|
|
151
|
+
*
|
|
152
|
+
* A schema is a plain object: the properties of the object, of every
|
|
153
|
+
* branch of a union, and of every item of an array.
|
|
154
|
+
*/
|
|
155
|
+
export declare function schemaPropertyNames(schema: unknown): Set<string>;
|
|
75
156
|
/**
|
|
76
157
|
* Create delegation harness integration
|
|
77
158
|
*/
|
|
@@ -79,6 +160,18 @@ export declare function createDelegationHarness(pi: ExtensionAPI, config?: Deleg
|
|
|
79
160
|
discoverCapability: () => Promise<ExtensionCapability | null>;
|
|
80
161
|
shouldAssess: (facts: ScopeFacts) => boolean;
|
|
81
162
|
assess: (facts: ScopeFacts, parentTaskId: string) => Promise<DelegationDecision | null>;
|
|
163
|
+
observeToolStart: (event: {
|
|
164
|
+
toolCallId: string;
|
|
165
|
+
toolName: string;
|
|
166
|
+
args?: unknown;
|
|
167
|
+
}) => DelegationChild | null;
|
|
168
|
+
observeToolEnd: (event: {
|
|
169
|
+
toolCallId: string;
|
|
170
|
+
toolName: string;
|
|
171
|
+
result?: unknown;
|
|
172
|
+
isError?: boolean;
|
|
173
|
+
}) => DelegationChild | null;
|
|
174
|
+
getChildren: () => DelegationChild[];
|
|
82
175
|
getReceipt: () => DelegationReceipt | null;
|
|
83
176
|
getLastDecision: () => DelegationDecision | null;
|
|
84
177
|
clear: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegation-harness.d.ts","sourceRoot":"","sources":["../src/delegation-harness.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,i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