@zhixuan92/multi-model-agent-core 0.3.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/load.js +9 -9
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +168 -275
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +30 -39
- package/dist/config/schema.js.map +1 -1
- package/dist/cost/cost-meter.d.ts +13 -0
- package/dist/cost/cost-meter.d.ts.map +1 -0
- package/dist/cost/cost-meter.js +20 -0
- package/dist/cost/cost-meter.js.map +1 -0
- package/dist/delegate-with-escalation.d.ts +1 -28
- package/dist/delegate-with-escalation.d.ts.map +1 -1
- package/dist/delegate-with-escalation.js +10 -89
- package/dist/delegate-with-escalation.js.map +1 -1
- package/dist/error-codes.d.ts +4 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +16 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/model-profiles.json +10 -5
- package/dist/provider.d.ts +2 -2
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +10 -13
- package/dist/provider.js.map +1 -1
- package/dist/readiness/normalization-budget.d.ts +2 -0
- package/dist/readiness/normalization-budget.d.ts.map +1 -0
- package/dist/readiness/normalization-budget.js +9 -0
- package/dist/readiness/normalization-budget.js.map +1 -0
- package/dist/readiness/normalize-brief.d.ts +17 -0
- package/dist/readiness/normalize-brief.d.ts.map +1 -0
- package/dist/readiness/normalize-brief.js +124 -0
- package/dist/readiness/normalize-brief.js.map +1 -0
- package/dist/readiness/readiness.d.ts +16 -0
- package/dist/readiness/readiness.d.ts.map +1 -0
- package/dist/readiness/readiness.js +160 -0
- package/dist/readiness/readiness.js.map +1 -0
- package/dist/reporting/structured-report.d.ts +18 -0
- package/dist/reporting/structured-report.d.ts.map +1 -0
- package/dist/reporting/structured-report.js +100 -0
- package/dist/reporting/structured-report.js.map +1 -0
- package/dist/review/aggregate-result.d.ts +3 -0
- package/dist/review/aggregate-result.d.ts.map +1 -0
- package/dist/review/aggregate-result.js +31 -0
- package/dist/review/aggregate-result.js.map +1 -0
- package/dist/review/quality-reviewer.d.ts +13 -0
- package/dist/review/quality-reviewer.d.ts.map +1 -0
- package/dist/review/quality-reviewer.js +39 -0
- package/dist/review/quality-reviewer.js.map +1 -0
- package/dist/review/reviewer-prompt.d.ts +10 -0
- package/dist/review/reviewer-prompt.d.ts.map +1 -0
- package/dist/review/reviewer-prompt.js +58 -0
- package/dist/review/reviewer-prompt.js.map +1 -0
- package/dist/review/spec-reviewer.d.ts +13 -0
- package/dist/review/spec-reviewer.d.ts.map +1 -0
- package/dist/review/spec-reviewer.js +37 -0
- package/dist/review/spec-reviewer.js.map +1 -0
- package/dist/routing/model-profiles.d.ts +5 -0
- package/dist/routing/model-profiles.d.ts.map +1 -1
- package/dist/routing/model-profiles.js +5 -0
- package/dist/routing/model-profiles.js.map +1 -1
- package/dist/routing/resolve-agent.d.ts +8 -0
- package/dist/routing/resolve-agent.d.ts.map +1 -0
- package/dist/routing/resolve-agent.js +45 -0
- package/dist/routing/resolve-agent.js.map +1 -0
- package/dist/run-tasks.d.ts +0 -23
- package/dist/run-tasks.d.ts.map +1 -1
- package/dist/run-tasks.js +241 -72
- package/dist/run-tasks.js.map +1 -1
- package/dist/runners/claude-runner.d.ts.map +1 -1
- package/dist/runners/claude-runner.js +71 -34
- package/dist/runners/claude-runner.js.map +1 -1
- package/dist/runners/codex-runner.d.ts.map +1 -1
- package/dist/runners/codex-runner.js +72 -31
- package/dist/runners/codex-runner.js.map +1 -1
- package/dist/runners/openai-runner.d.ts.map +1 -1
- package/dist/runners/openai-runner.js +144 -32
- package/dist/runners/openai-runner.js.map +1 -1
- package/dist/runners/prevention.d.ts +2 -0
- package/dist/runners/prevention.d.ts.map +1 -1
- package/dist/runners/prevention.js +12 -0
- package/dist/runners/prevention.js.map +1 -1
- package/dist/runners/supervision.d.ts +31 -5
- package/dist/runners/supervision.d.ts.map +1 -1
- package/dist/runners/supervision.js +43 -68
- package/dist/runners/supervision.js.map +1 -1
- package/dist/tools/call-cache.d.ts +16 -0
- package/dist/tools/call-cache.d.ts.map +1 -0
- package/dist/tools/call-cache.js +28 -0
- package/dist/tools/call-cache.js.map +1 -0
- package/dist/types.d.ts +92 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +48 -16
- package/dist/routing/capabilities.d.ts +0 -3
- package/dist/routing/capabilities.d.ts.map +0 -1
- package/dist/routing/capabilities.js +0 -26
- package/dist/routing/capabilities.js.map +0 -1
- package/dist/routing/get-provider-eligibility.d.ts +0 -8
- package/dist/routing/get-provider-eligibility.d.ts.map +0 -1
- package/dist/routing/get-provider-eligibility.js +0 -53
- package/dist/routing/get-provider-eligibility.js.map +0 -1
- package/dist/routing/resolve-task-capabilities.d.ts +0 -7
- package/dist/routing/resolve-task-capabilities.d.ts.map +0 -1
- package/dist/routing/resolve-task-capabilities.js +0 -19
- package/dist/routing/resolve-task-capabilities.js.map +0 -1
- package/dist/routing/select-provider-for-task.d.ts +0 -18
- package/dist/routing/select-provider-for-task.d.ts.map +0 -1
- package/dist/routing/select-provider-for-task.js +0 -50
- package/dist/routing/select-provider-for-task.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class CostMeter {
|
|
2
|
+
spent = 0;
|
|
3
|
+
ceiling;
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
this.ceiling = options.ceiling ?? Infinity;
|
|
6
|
+
}
|
|
7
|
+
add(amount) {
|
|
8
|
+
this.spent += amount;
|
|
9
|
+
}
|
|
10
|
+
total() {
|
|
11
|
+
return this.spent;
|
|
12
|
+
}
|
|
13
|
+
canProceed(nextCost) {
|
|
14
|
+
return this.spent + nextCost <= this.ceiling;
|
|
15
|
+
}
|
|
16
|
+
remaining() {
|
|
17
|
+
return Math.max(0, this.ceiling - this.spent);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=cost-meter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-meter.js","sourceRoot":"","sources":["../../src/cost/cost-meter.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,SAAS;IACZ,KAAK,GAAW,CAAC,CAAC;IACT,OAAO,CAAS;IAEjC,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC;IAC7C,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;IACvB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,UAAU,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,KAAK,GAAG,QAAQ,IAAI,IAAI,CAAC,OAAO,CAAC;IAC/C,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
import type { TaskSpec, RunResult, Provider,
|
|
1
|
+
import type { TaskSpec, RunResult, Provider, ProgressEvent } from './types.js';
|
|
2
2
|
export interface DelegateOptions {
|
|
3
|
-
/** When true, the orchestrator does not walk the chain on failure —
|
|
4
|
-
* the first (and only) provider's result is returned as-is. */
|
|
5
3
|
explicitlyPinned?: boolean;
|
|
6
|
-
/** Optional in-flight progress sink. When provided, it is threaded into
|
|
7
|
-
* every `provider.run(...)` call so runners can emit turn/tool/injection
|
|
8
|
-
* events, and the orchestrator itself emits one `escalation_start` event
|
|
9
|
-
* between attempts whenever it hops to the next provider in the chain.
|
|
10
|
-
* The callback MUST NOT throw. See `ProgressEvent` for variants. */
|
|
11
4
|
onProgress?: (event: ProgressEvent) => void;
|
|
12
5
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Build the escalation chain for an auto-routed task. Returns all eligible
|
|
15
|
-
* providers sorted cheapest-first with alphabetical tiebreak — this mirrors
|
|
16
|
-
* `selectProviderForTask`'s ordering so the first element of the chain is the
|
|
17
|
-
* same provider auto-routing would have picked.
|
|
18
|
-
*
|
|
19
|
-
* Eligibility (capability + tier filters) is handled entirely by
|
|
20
|
-
* `getProviderEligibility`; we just drop the ineligible entries.
|
|
21
|
-
*/
|
|
22
|
-
export declare function buildEscalationChain(task: TaskSpec, config: MultiModelConfig): Provider[];
|
|
23
|
-
/**
|
|
24
|
-
* Walks the provider chain for an auto-routed task. Returns the first
|
|
25
|
-
* successful result; if all attempts fail, returns the best salvageable
|
|
26
|
-
* output (longest non-empty) with status 'incomplete' and the full
|
|
27
|
-
* escalation log.
|
|
28
|
-
*
|
|
29
|
-
* For explicitly-pinned tasks, the chain has length 1 and there is no
|
|
30
|
-
* walking — the pinned provider's result is returned as-is. See spec
|
|
31
|
-
* Part A.4.
|
|
32
|
-
*/
|
|
33
6
|
export declare function delegateWithEscalation(task: TaskSpec, chain: Provider[], options?: DelegateOptions): Promise<RunResult>;
|
|
34
7
|
//# sourceMappingURL=delegate-with-escalation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate-with-escalation.d.ts","sourceRoot":"","sources":["../src/delegate-with-escalation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EAER,
|
|
1
|
+
{"version":3,"file":"delegate-with-escalation.d.ts","sourceRoot":"","sources":["../src/delegate-with-escalation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,EAER,aAAa,EACd,MAAM,YAAY,CAAC;AAGpB,MAAM,WAAW,eAAe;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC7C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,QAAQ,EAAE,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,SAAS,CAAC,CAuGpB"}
|
|
@@ -1,66 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getProviderEligibility } from './routing/get-provider-eligibility.js';
|
|
3
|
-
import { getEffectiveCostTier } from './routing/model-profiles.js';
|
|
4
|
-
// NOTE: must stay byte-identical to the ordering in
|
|
5
|
-
// routing/select-provider-for-task.ts so the head of the escalation chain is
|
|
6
|
-
// the same provider auto-routing would have picked. If you change one, change
|
|
7
|
-
// both.
|
|
8
|
-
const COST_ORDER = { free: 0, low: 1, medium: 2, high: 3 };
|
|
9
|
-
/**
|
|
10
|
-
* Build the escalation chain for an auto-routed task. Returns all eligible
|
|
11
|
-
* providers sorted cheapest-first with alphabetical tiebreak — this mirrors
|
|
12
|
-
* `selectProviderForTask`'s ordering so the first element of the chain is the
|
|
13
|
-
* same provider auto-routing would have picked.
|
|
14
|
-
*
|
|
15
|
-
* Eligibility (capability + tier filters) is handled entirely by
|
|
16
|
-
* `getProviderEligibility`; we just drop the ineligible entries.
|
|
17
|
-
*/
|
|
18
|
-
export function buildEscalationChain(task, config) {
|
|
19
|
-
const eligibility = getProviderEligibility(task, config);
|
|
20
|
-
const eligible = eligibility.filter((e) => e.eligible);
|
|
21
|
-
eligible.sort((a, b) => {
|
|
22
|
-
const aTier = COST_ORDER[getEffectiveCostTier(a.config)] ?? 3;
|
|
23
|
-
const bTier = COST_ORDER[getEffectiveCostTier(b.config)] ?? 3;
|
|
24
|
-
if (aTier !== bTier)
|
|
25
|
-
return aTier - bTier;
|
|
26
|
-
return a.name.localeCompare(b.name);
|
|
27
|
-
});
|
|
28
|
-
return eligible.map((e) => createProvider(e.name, config));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Walks the provider chain for an auto-routed task. Returns the first
|
|
32
|
-
* successful result; if all attempts fail, returns the best salvageable
|
|
33
|
-
* output (longest non-empty) with status 'incomplete' and the full
|
|
34
|
-
* escalation log.
|
|
35
|
-
*
|
|
36
|
-
* For explicitly-pinned tasks, the chain has length 1 and there is no
|
|
37
|
-
* walking — the pinned provider's result is returned as-is. See spec
|
|
38
|
-
* Part A.4.
|
|
39
|
-
*/
|
|
1
|
+
import { retryableFor } from './error-codes.js';
|
|
40
2
|
export async function delegateWithEscalation(task, chain, options = {}) {
|
|
41
3
|
if (chain.length === 0) {
|
|
42
4
|
throw new Error('delegateWithEscalation called with empty chain');
|
|
43
5
|
}
|
|
44
|
-
// Wrap the user-supplied sink with try/catch so a throwing callback can
|
|
45
|
-
// never corrupt a task. The contract says callbacks MUST NOT throw, but
|
|
46
|
-
// Tasks 9-11 will call this from hot runner loops — defense in depth.
|
|
47
|
-
// This wrapper is also the callback handed to `provider.run`, so runner
|
|
48
|
-
// emissions are covered by the same guard.
|
|
49
6
|
const safeSink = options.onProgress
|
|
50
7
|
? (event) => {
|
|
51
8
|
try {
|
|
52
9
|
options.onProgress(event);
|
|
53
10
|
}
|
|
54
11
|
catch {
|
|
55
|
-
// Swallow — a broken sink must not affect dispatch.
|
|
56
12
|
}
|
|
57
13
|
}
|
|
58
14
|
: undefined;
|
|
59
15
|
const attempts = [];
|
|
60
16
|
for (let i = 0; i < chain.length; i++) {
|
|
61
17
|
const provider = chain[i];
|
|
62
|
-
// Emit one `escalation_start` between attempts (never before the first).
|
|
63
|
-
// The previous attempt's record is guaranteed to exist here because i>0.
|
|
64
18
|
if (i > 0 && safeSink) {
|
|
65
19
|
const prev = attempts[attempts.length - 1].record;
|
|
66
20
|
safeSink({
|
|
@@ -70,11 +24,6 @@ export async function delegateWithEscalation(task, chain, options = {}) {
|
|
|
70
24
|
nextProvider: provider.name,
|
|
71
25
|
});
|
|
72
26
|
}
|
|
73
|
-
// Per-attempt metadata captured via the runner's `onInitialRequest`
|
|
74
|
-
// callback. Reset inside the loop so a subsequent escalation hop
|
|
75
|
-
// starts fresh. The runner invokes this exactly once per attempt
|
|
76
|
-
// (Task 12). We wrap assignment in try/catch at the runner site, but
|
|
77
|
-
// assigning to these locals cannot itself throw.
|
|
78
27
|
let initialPromptLengthChars = 0;
|
|
79
28
|
let initialPromptHash = '';
|
|
80
29
|
const result = await provider.run(task.prompt, {
|
|
@@ -85,8 +34,10 @@ export async function delegateWithEscalation(task, chain, options = {}) {
|
|
|
85
34
|
effort: task.effort,
|
|
86
35
|
sandboxPolicy: task.sandboxPolicy,
|
|
87
36
|
expectedCoverage: task.expectedCoverage,
|
|
88
|
-
|
|
37
|
+
skipCompletionHeuristic: task.skipCompletionHeuristic,
|
|
89
38
|
parentModel: task.parentModel,
|
|
39
|
+
maxCostUSD: task.maxCostUSD,
|
|
40
|
+
formatConstraints: task.formatConstraints,
|
|
90
41
|
onProgress: safeSink,
|
|
91
42
|
onInitialRequest: (meta) => {
|
|
92
43
|
initialPromptLengthChars = meta.lengthChars;
|
|
@@ -102,13 +53,9 @@ export async function delegateWithEscalation(task, chain, options = {}) {
|
|
|
102
53
|
costUSD: result.usage.costUSD,
|
|
103
54
|
initialPromptLengthChars,
|
|
104
55
|
initialPromptHash,
|
|
105
|
-
// Use `||` (not `??`) so an empty-string error falls through to the
|
|
106
|
-
// status sentinel — an empty `reason` would be indistinguishable from
|
|
107
|
-
// an `ok` row in the escalation log.
|
|
108
56
|
reason: result.status === 'ok'
|
|
109
57
|
? undefined
|
|
110
58
|
: (result.error || `status=${result.status}`),
|
|
111
|
-
...(result.progressTrace && { progressTrace: result.progressTrace }),
|
|
112
59
|
};
|
|
113
60
|
attempts.push({ result, record });
|
|
114
61
|
if (result.status === 'ok') {
|
|
@@ -117,44 +64,15 @@ export async function delegateWithEscalation(task, chain, options = {}) {
|
|
|
117
64
|
escalationLog: attempts.map((a) => a.record),
|
|
118
65
|
};
|
|
119
66
|
}
|
|
120
|
-
// Pinned: stop after the first attempt regardless of status.
|
|
121
67
|
if (options.explicitlyPinned) {
|
|
122
68
|
return {
|
|
123
69
|
...result,
|
|
70
|
+
errorCode: result.errorCode ?? result.status,
|
|
71
|
+
retryable: result.retryable ?? retryableFor(result.status),
|
|
124
72
|
escalationLog: attempts.map((a) => a.record),
|
|
125
73
|
};
|
|
126
74
|
}
|
|
127
75
|
}
|
|
128
|
-
// All providers failed. Return the best salvageable output.
|
|
129
|
-
//
|
|
130
|
-
// Two-tier selection based on `RunResult.outputIsDiagnostic`:
|
|
131
|
-
//
|
|
132
|
-
// Tier 1 (preferred): attempts whose `output` contains real
|
|
133
|
-
// model-produced content — a clean final answer (on `ok`, but
|
|
134
|
-
// `ok` short-circuits above so we never see one here) or
|
|
135
|
-
// `scratchpad.latest()` text that the runner actually buffered
|
|
136
|
-
// before termination. These are flagged `outputIsDiagnostic: false`.
|
|
137
|
-
//
|
|
138
|
-
// Tier 2 (fallback): attempts whose `output` is a runner-synthesized
|
|
139
|
-
// diagnostic template (`"Sub-agent error: …"`, `"Agent timed out…"`,
|
|
140
|
-
// `buildXxxIncompleteDiagnostic(...)`, etc.) because the scratchpad
|
|
141
|
-
// was empty at termination. These are `outputIsDiagnostic: true`.
|
|
142
|
-
//
|
|
143
|
-
// Why: status alone is NOT enough. Two `incomplete` attempts can both
|
|
144
|
-
// exist where one has genuine scratchpad content and the other has
|
|
145
|
-
// just the diagnostic template — picking by raw output length would
|
|
146
|
-
// silently discard the real work in favor of a longer diagnostic.
|
|
147
|
-
// Likewise a late `api_error` attempt with a long
|
|
148
|
-
// `"Sub-agent error: <stack trace>"` would beat an earlier
|
|
149
|
-
// `incomplete` attempt with a shorter genuine partial.
|
|
150
|
-
//
|
|
151
|
-
// Within each tier we still pick the longest output, because a
|
|
152
|
-
// longer genuine salvage is usually more useful than a shorter one,
|
|
153
|
-
// and among pure-diagnostic attempts a longer diagnostic usually
|
|
154
|
-
// carries more debugging signal than a shorter one.
|
|
155
|
-
//
|
|
156
|
-
// Note: the `ok` short-circuit above means every entry here is non-ok,
|
|
157
|
-
// so the status-remap below is defensive only.
|
|
158
76
|
const realContentAttempts = attempts.filter((a) => !a.result.outputIsDiagnostic);
|
|
159
77
|
const pool = realContentAttempts.length > 0 ? realContentAttempts : attempts;
|
|
160
78
|
let best = pool[0].result;
|
|
@@ -163,9 +81,12 @@ export async function delegateWithEscalation(task, chain, options = {}) {
|
|
|
163
81
|
best = a.result;
|
|
164
82
|
}
|
|
165
83
|
}
|
|
84
|
+
const finalStatus = best.status === 'ok' ? 'incomplete' : best.status;
|
|
166
85
|
return {
|
|
167
86
|
...best,
|
|
168
|
-
status:
|
|
87
|
+
status: finalStatus,
|
|
88
|
+
errorCode: best.errorCode ?? finalStatus,
|
|
89
|
+
retryable: best.retryable ?? retryableFor(finalStatus),
|
|
169
90
|
escalationLog: attempts.map((a) => a.record),
|
|
170
91
|
};
|
|
171
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate-with-escalation.js","sourceRoot":"","sources":["../src/delegate-with-escalation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delegate-with-escalation.js","sourceRoot":"","sources":["../src/delegate-with-escalation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,IAAc,EACd,KAAiB,EACjB,UAA2B,EAAE;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,QAAQ,GAAiD,OAAO,CAAC,UAAU;QAC/E,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,CAAC;gBACH,OAAO,CAAC,UAAW,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;YAAC,MAAM,CAAC;YACT,CAAC;QACH,CA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QACJ,CAAC;IACH,CAAC;IAED,MAAM,mBAAmB,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC;IAE7E,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC1B,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAChD,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;IACtE,OAAO;QACL,GAAG,IAAI;QACP,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,WAAW;QACxC,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,YAAY,CAAC,WAAW,CAAC;QACtD,aAAa,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type ErrorCode = 'capability_missing' | 'agent_not_found' | 'context_block_not_found' | 'brief_too_vague' | 'timeout' | 'network_error' | 'api_error' | 'api_aborted' | 'max_turns' | 'error' | 'unknown';
|
|
2
|
+
export declare function retryableFor(status: string): boolean;
|
|
3
|
+
export declare function classifyContextBlockError(err: Error): 'context_block_not_found' | 'retryable' | 'non_retryable';
|
|
4
|
+
//# sourceMappingURL=error-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,oBAAoB,GACpB,iBAAiB,GACjB,yBAAyB,GACzB,iBAAiB,GACjB,SAAS,GACT,eAAe,GACf,WAAW,GACX,aAAa,GACb,WAAW,GACX,OAAO,GACP,SAAS,CAAC;AAEd,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,KAAK,GAAG,yBAAyB,GAAG,WAAW,GAAG,eAAe,CAW/G"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function retryableFor(status) {
|
|
2
|
+
return ['timeout', 'network_error', 'api_error'].includes(status);
|
|
3
|
+
}
|
|
4
|
+
export function classifyContextBlockError(err) {
|
|
5
|
+
const msg = err.message.toLowerCase();
|
|
6
|
+
if (msg.includes('context block') || (msg.includes('id') && msg.includes('undefined'))) {
|
|
7
|
+
if (msg.includes('not found') || msg.includes('undefined') || msg.includes('missing')) {
|
|
8
|
+
return 'context_block_not_found';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (msg.includes('rate limit') || msg.includes('429') || msg.includes('503') || msg.includes('502')) {
|
|
12
|
+
return 'retryable';
|
|
13
|
+
}
|
|
14
|
+
return 'non_retryable';
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=error-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,CAAC,SAAS,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,GAAU;IAClD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACtC,IAAI,GAAG,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;QACvF,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACtF,OAAO,yBAAyB,CAAC;QACnC,CAAC;IACH,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpG,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { loadConfigFromFile } from './config/load.js';
|
|
2
2
|
export { parseConfig, multiModelConfigSchema } from './config/schema.js';
|
|
3
|
-
export type {
|
|
3
|
+
export type { ToolMode, SandboxPolicy, AgentType, AgentCapability, AgentConfig, Effort, CostTier, RunStatus, TaskSpec, ProviderConfig, CodexProviderConfig, ClaudeProviderConfig, OpenAICompatibleProviderConfig, MultiModelConfig, TokenUsage, RunResult, BatchTimings, BatchProgress, BatchAggregateCost, Provider, RunOptions, RunTasksRuntime, ProgressEvent, EligibilityFailureCheck, EligibilityFailure, ProviderEligibility, BriefQualityWarning, BriefQualityPolicy, ReadinessResult, } from './types.js';
|
|
4
|
+
export { ParsedStructuredReport } from './reporting/structured-report.js';
|
|
4
5
|
export { InMemoryContextBlockStore, ContextBlockNotFoundError, } from './context/context-block-store.js';
|
|
5
6
|
export type { ContextBlockStore, RegisteredBlock, InMemoryContextBlockStoreOptions, } from './context/context-block-store.js';
|
|
6
7
|
export { expandContextBlocks } from './context/expand-context-blocks.js';
|
|
7
8
|
export { createProvider } from './provider.js';
|
|
8
9
|
export { runTasks } from './run-tasks.js';
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
10
|
+
export { evaluateReadiness, hasScopePillar, hasInputsPillar, hasDoneConditionPillar, hasOutputContractPillar, detectOutsourcedDiscovery, detectBrittleLineAnchors, detectMixedEnvironmentActions, detectConcretePath, detectNamedCodeArtifact, detectReasonableLength, } from './readiness/readiness.js';
|
|
11
|
+
export { resolveAgent } from './routing/resolve-agent.js';
|
|
12
|
+
export type { ResolvedAgent } from './routing/resolve-agent.js';
|
|
11
13
|
export { findModelProfile, getEffectiveCostTier } from './routing/model-profiles.js';
|
|
12
|
-
export { selectProviderForTask } from './routing/select-provider-for-task.js';
|
|
13
|
-
export { getProviderEligibility } from './routing/get-provider-eligibility.js';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGzE,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGzE,YAAY,EACV,QAAQ,EACR,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,EACX,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,8BAA8B,EAC9B,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAG1E,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,gCAAgC,GACjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,10 +8,9 @@ export { expandContextBlocks } from './context/expand-context-blocks.js';
|
|
|
8
8
|
export { createProvider } from './provider.js';
|
|
9
9
|
// Run tasks
|
|
10
10
|
export { runTasks } from './run-tasks.js';
|
|
11
|
-
//
|
|
12
|
-
export {
|
|
13
|
-
|
|
11
|
+
// Readiness
|
|
12
|
+
export { evaluateReadiness, hasScopePillar, hasInputsPillar, hasDoneConditionPillar, hasOutputContractPillar, detectOutsourcedDiscovery, detectBrittleLineAnchors, detectMixedEnvironmentActions, detectConcretePath, detectNamedCodeArtifact, detectReasonableLength, } from './readiness/readiness.js';
|
|
13
|
+
// Agent resolution
|
|
14
|
+
export { resolveAgent } from './routing/resolve-agent.js';
|
|
14
15
|
export { findModelProfile, getEffectiveCostTier } from './routing/model-profiles.js';
|
|
15
|
-
export { selectProviderForTask } from './routing/select-provider-for-task.js';
|
|
16
|
-
export { getProviderEligibility } from './routing/get-provider-eligibility.js';
|
|
17
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAoCzE,iBAAiB;AACjB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,kCAAkC,CAAC;AAM1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,WAAW;AACX,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,YAAY;AACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,YAAY;AACZ,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAElC,mBAAmB;AACnB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/model-profiles.json
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"outputCostPerMTok": 25,
|
|
12
12
|
"rateSource": "https://claude.com/pricing",
|
|
13
13
|
"rateLookupDate": "2026-04-11",
|
|
14
|
-
"inputTokenSoftLimit": 150000
|
|
14
|
+
"inputTokenSoftLimit": 150000,
|
|
15
|
+
"capabilities": ["web_search", "web_fetch"]
|
|
15
16
|
},
|
|
16
17
|
{
|
|
17
18
|
"prefix": "claude-sonnet",
|
|
@@ -25,7 +26,8 @@
|
|
|
25
26
|
"outputCostPerMTok": 15,
|
|
26
27
|
"rateSource": "https://claude.com/pricing",
|
|
27
28
|
"rateLookupDate": "2026-04-11",
|
|
28
|
-
"inputTokenSoftLimit": 150000
|
|
29
|
+
"inputTokenSoftLimit": 150000,
|
|
30
|
+
"capabilities": ["web_search", "web_fetch"]
|
|
29
31
|
},
|
|
30
32
|
{
|
|
31
33
|
"prefix": "claude-haiku",
|
|
@@ -39,7 +41,8 @@
|
|
|
39
41
|
"outputCostPerMTok": 5,
|
|
40
42
|
"rateSource": "https://claude.com/pricing",
|
|
41
43
|
"rateLookupDate": "2026-04-11",
|
|
42
|
-
"inputTokenSoftLimit": 150000
|
|
44
|
+
"inputTokenSoftLimit": 150000,
|
|
45
|
+
"capabilities": ["web_search", "web_fetch"]
|
|
43
46
|
},
|
|
44
47
|
{
|
|
45
48
|
"prefix": "gpt-5",
|
|
@@ -53,7 +56,8 @@
|
|
|
53
56
|
"outputCostPerMTok": 15,
|
|
54
57
|
"rateSource": "https://openai.com/api/pricing/",
|
|
55
58
|
"rateLookupDate": "2026-04-11",
|
|
56
|
-
"inputTokenSoftLimit": 1000000
|
|
59
|
+
"inputTokenSoftLimit": 1000000,
|
|
60
|
+
"capabilities": ["web_search"]
|
|
57
61
|
},
|
|
58
62
|
{
|
|
59
63
|
"prefix": "MiniMax-M2",
|
|
@@ -67,6 +71,7 @@
|
|
|
67
71
|
"outputCostPerMTok": 1.2,
|
|
68
72
|
"rateSource": "https://platform.minimax.io/docs/guides/pricing-paygo",
|
|
69
73
|
"rateLookupDate": "2026-04-11",
|
|
70
|
-
"inputTokenSoftLimit": 200000
|
|
74
|
+
"inputTokenSoftLimit": 200000,
|
|
75
|
+
"capabilities": []
|
|
71
76
|
}
|
|
72
77
|
]
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Provider, MultiModelConfig } from './types.js';
|
|
2
|
-
export declare function createProvider(
|
|
1
|
+
import type { AgentType, Provider, MultiModelConfig } from './types.js';
|
|
2
|
+
export declare function createProvider(slot: AgentType, config: MultiModelConfig): Provider;
|
|
3
3
|
//# sourceMappingURL=provider.d.ts.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAyB,gBAAgB,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAyB,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAG/G,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,GAAG,QAAQ,CAwDlF"}
|
package/dist/provider.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export function createProvider(
|
|
2
|
-
const
|
|
3
|
-
if (!
|
|
4
|
-
|
|
5
|
-
throw new Error(`Provider "${name}" not found in config. Available: ${available}`);
|
|
1
|
+
export function createProvider(slot, config) {
|
|
2
|
+
const agentConfig = config.agents[slot];
|
|
3
|
+
if (!agentConfig) {
|
|
4
|
+
throw new Error(`Unknown agent slot: "${slot}". Config must have "standard" and "complex".`);
|
|
6
5
|
}
|
|
6
|
+
const providerConfig = agentConfig;
|
|
7
7
|
const defaults = config.defaults;
|
|
8
8
|
const run = async (prompt, options = {}) => {
|
|
9
9
|
try {
|
|
10
|
-
switch (
|
|
10
|
+
switch (agentConfig.type) {
|
|
11
11
|
case 'codex': {
|
|
12
12
|
const { runCodex } = await import('./runners/codex-runner.js');
|
|
13
13
|
return await runCodex(prompt, options, providerConfig, defaults);
|
|
@@ -19,17 +19,16 @@ export function createProvider(name, config) {
|
|
|
19
19
|
case 'openai-compatible': {
|
|
20
20
|
const { runOpenAI } = await import('./runners/openai-runner.js');
|
|
21
21
|
const { default: OpenAI } = await import('openai');
|
|
22
|
-
const apiKey =
|
|
23
|
-
?? (
|
|
22
|
+
const apiKey = agentConfig.apiKey
|
|
23
|
+
?? (agentConfig.apiKeyEnv ? process.env[agentConfig.apiKeyEnv] : undefined);
|
|
24
24
|
const client = new OpenAI({
|
|
25
25
|
apiKey: apiKey || 'not-needed',
|
|
26
|
-
baseURL:
|
|
26
|
+
baseURL: agentConfig.baseUrl,
|
|
27
27
|
});
|
|
28
28
|
const runnerOpts = { client, providerConfig, defaults };
|
|
29
29
|
return await runOpenAI(prompt, options, runnerOpts);
|
|
30
30
|
}
|
|
31
31
|
default: {
|
|
32
|
-
// All provider types are handled above; this is a type safety net.
|
|
33
32
|
throw new Error(`Unreachable: unknown provider type`);
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -43,14 +42,12 @@ export function createProvider(name, config) {
|
|
|
43
42
|
filesRead: [],
|
|
44
43
|
filesWritten: [],
|
|
45
44
|
toolCalls: [],
|
|
46
|
-
// Fallback error wrapper around a thrown runner — no scratchpad
|
|
47
|
-
// involved, just the raw error message.
|
|
48
45
|
outputIsDiagnostic: true,
|
|
49
46
|
escalationLog: [],
|
|
50
47
|
error: err instanceof Error ? err.message : String(err),
|
|
51
48
|
};
|
|
52
49
|
}
|
|
53
50
|
};
|
|
54
|
-
return { name, config: providerConfig, run };
|
|
51
|
+
return { name: slot, config: providerConfig, run };
|
|
55
52
|
}
|
|
56
53
|
//# sourceMappingURL=provider.js.map
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,cAAc,CAAC,IAAe,EAAE,MAAwB;IACtE,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,+CAA+C,CAAC,CAAC;IAC/F,CAAC;IAED,MAAM,cAAc,GAAG,WAAwC,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAEjC,MAAM,GAAG,GAAG,KAAK,EAAE,MAAc,EAAE,UAAsB,EAAE,EAAsB,EAAE;QACjF,IAAI,CAAC;YACH,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC;gBACzB,KAAK,OAAO,CAAC,CAAC,CAAC;oBACb,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAAC;oBAC/D,OAAO,MAAM,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;gBACnE,CAAC;gBAED,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM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AE,IAAI,EAAE;gBACzE,KAAK,EAAE,CAAC;gBACR,SAAS,EAAE,EAAE;gBACb,YAAY,EAAE,EAAE;gBAChB,SAAS,EAAE,EAAE;gBACb,kBAAkB,EAAE,IAAI;gBACxB,aAAa,EAAE,EAAE;gBACjB,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization-budget.d.ts","sourceRoot":"","sources":["../../src/readiness/normalization-budget.ts"],"names":[],"mappings":"AAAA,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKjF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function computeNormalizationBudget(maxCostUSD) {
|
|
2
|
+
const FLAT_CEIL = 0.01;
|
|
3
|
+
if (maxCostUSD === undefined)
|
|
4
|
+
return FLAT_CEIL;
|
|
5
|
+
if (maxCostUSD <= 0)
|
|
6
|
+
return 0;
|
|
7
|
+
return Math.min(FLAT_CEIL, 0.2 * maxCostUSD);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=normalization-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization-budget.js","sourceRoot":"","sources":["../../src/readiness/normalization-budget.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,0BAA0B,CAAC,UAA8B;IACvE,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,UAAU,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TaskSpec, MultiModelConfig } from '../types.js';
|
|
2
|
+
export interface NormalizationDecision {
|
|
3
|
+
original: string;
|
|
4
|
+
resolved: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
}
|
|
7
|
+
export interface NormalizationResult {
|
|
8
|
+
normalizedPrompt: string;
|
|
9
|
+
decisions: NormalizationDecision[];
|
|
10
|
+
writeSet: string[];
|
|
11
|
+
verificationPlan: string[];
|
|
12
|
+
unresolved: string[];
|
|
13
|
+
spentCostUSD: number;
|
|
14
|
+
skipped: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function normalizeBrief(task: TaskSpec, config: MultiModelConfig): Promise<NormalizationResult>;
|
|
17
|
+
//# sourceMappingURL=normalize-brief.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-brief.d.ts","sourceRoot":"","sources":["../../src/readiness/normalize-brief.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK9D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,qBAAqB,EAAE,CAAC;IACnC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB;AA4BD,wBAAsB,cAAc,CAClC,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,mBAAmB,CAAC,CA2C9B"}
|