@tangle-network/agent-eval 0.116.0 → 0.117.1
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/CHANGELOG.md +38 -0
- package/dist/analyst/index.d.ts +18 -11
- package/dist/analyst/index.js +10 -7
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyst-CFBc14Wc.d.ts → analyst-C8HHvfJp.d.ts} +1 -1
- package/dist/{analyze-runs-0rz_m29H.d.ts → analyze-runs--2x39HZ7.d.ts} +3 -3
- package/dist/{baseline-DsNteOgR.d.ts → baseline-DKq3gJpP.d.ts} +6 -3
- package/dist/belief-state/index.d.ts +6 -6
- package/dist/belief-state/index.js +1 -1
- package/dist/benchmarks/index.d.ts +11 -8
- package/dist/benchmarks/index.js +11 -10
- package/dist/builder-eval/index.d.ts +4 -4
- package/dist/builder-eval/index.js +1 -1
- package/dist/{calibration-Dz8TQV4y.d.ts → calibration-C8MTS7cw.d.ts} +2 -2
- package/dist/campaign/index.d.ts +54 -30
- package/dist/campaign/index.js +18 -13
- package/dist/chunk-3YYRZDON.js +45 -0
- package/dist/chunk-3YYRZDON.js.map +1 -0
- package/dist/{chunk-RPDDVKI7.js → chunk-4JLWXDYA.js} +2 -2
- package/dist/{chunk-NBSS5NDZ.js → chunk-CCZIVI3F.js} +54 -115
- package/dist/chunk-CCZIVI3F.js.map +1 -0
- package/dist/{chunk-J6P6PK2R.js → chunk-FQNLDL4D.js} +3 -3
- package/dist/{chunk-ONM6PEAE.js → chunk-GQCZRZ7L.js} +2 -2
- package/dist/chunk-HHWE3POT.js +94 -0
- package/dist/chunk-HHWE3POT.js.map +1 -0
- package/dist/{chunk-3274WNK7.js → chunk-HQPHZGL6.js} +687 -44
- package/dist/chunk-HQPHZGL6.js.map +1 -0
- package/dist/{chunk-FAOEFFRT.js → chunk-IDZTTFRR.js} +390 -78
- package/dist/chunk-IDZTTFRR.js.map +1 -0
- package/dist/{chunk-3LXTCTWL.js → chunk-JSDVRFAP.js} +2 -2
- package/dist/{chunk-GSW3OBHK.js → chunk-JSJZ4PJ6.js} +406 -726
- package/dist/chunk-JSJZ4PJ6.js.map +1 -0
- package/dist/{chunk-MHNQWM4I.js → chunk-LQUTGLOZ.js} +5 -1
- package/dist/chunk-LQUTGLOZ.js.map +1 -0
- package/dist/{chunk-4D5RVB3W.js → chunk-LTVG32KX.js} +30 -5
- package/dist/chunk-LTVG32KX.js.map +1 -0
- package/dist/{chunk-CIUOICJT.js → chunk-MGEHEHSN.js} +62 -15
- package/dist/chunk-MGEHEHSN.js.map +1 -0
- package/dist/{chunk-GY4SYVPJ.js → chunk-NJC7U437.js} +97 -25
- package/dist/chunk-NJC7U437.js.map +1 -0
- package/dist/{chunk-NYFUT3B3.js → chunk-ODVOOEWQ.js} +31 -10
- package/dist/chunk-ODVOOEWQ.js.map +1 -0
- package/dist/{chunk-LNQEP766.js → chunk-S2F4J57L.js} +44 -4
- package/dist/chunk-S2F4J57L.js.map +1 -0
- package/dist/chunk-VCTY3W6J.js +798 -0
- package/dist/chunk-VCTY3W6J.js.map +1 -0
- package/dist/chunk-VF3XSYTI.js +545 -0
- package/dist/chunk-VF3XSYTI.js.map +1 -0
- package/dist/{chunk-TLDB7WRY.js → chunk-YZPO4UHR.js} +28 -31
- package/dist/chunk-YZPO4UHR.js.map +1 -0
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/{code-agent-session-CdxteG0y.d.ts → code-agent-session-CjZsVd19.d.ts} +1 -1
- package/dist/contract/index.d.ts +43 -29
- package/dist/contract/index.js +56 -19
- package/dist/contract/index.js.map +1 -1
- package/dist/{control-DbcDxouY.d.ts → control-6vuGfmDH.d.ts} +5 -5
- package/dist/control.d.ts +6 -6
- package/dist/cost-ledger-DWy3XdJc.d.ts +183 -0
- package/dist/{default-registry-DDfv22MQ.d.ts → default-registry-DaK8b3fv.d.ts} +2 -2
- package/dist/{emitter-BRchAAAx.d.ts → emitter-CjD7vUwv.d.ts} +2 -2
- package/dist/{failure-cluster-C48PiReX.d.ts → failure-cluster-DOAcSJ87.d.ts} +2 -2
- package/dist/{feedback-trajectory-pDcz1lQ1.d.ts → feedback-trajectory-BUnM58xL.d.ts} +3 -3
- package/dist/fuzz.d.ts +8 -16
- package/dist/fuzz.js +72 -42
- package/dist/fuzz.js.map +1 -1
- package/dist/{gepa-CQelRtuC.d.ts → gepa-eESocoDi.d.ts} +56 -6
- package/dist/hosted/index.d.ts +13 -10
- package/dist/{index-DbCXJfZ1.d.ts → index-PdX4VnPA.d.ts} +3 -3
- package/dist/index.d.ts +102 -57
- package/dist/index.js +328 -235
- package/dist/index.js.map +1 -1
- package/dist/{insight-report-oMVxDTxl.d.ts → insight-report-DY4nDW9Q.d.ts} +1 -1
- package/dist/{integrity-C6PZ73iC.d.ts → integrity-DqlBiLyK.d.ts} +2 -2
- package/dist/{kind-factory-DWOvXjR_.d.ts → kind-factory-ClZmO25A.d.ts} +2 -2
- package/dist/llm-client-qoDd18Qz.d.ts +289 -0
- package/dist/meta-eval/index.d.ts +8 -7
- package/dist/meta-eval/index.js +1 -1
- package/dist/multishot/index.d.ts +9 -6
- package/dist/openapi.json +1 -1
- package/dist/pipelines/index.d.ts +16 -6
- package/dist/pipelines/index.js +119 -23
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{policy-edit-Clb2v6Oa.d.ts → policy-edit-wG9uFEFm.d.ts} +13 -266
- package/dist/{pre-registration--vU0mMtD.d.ts → pre-registration-BWQhJ3vz.d.ts} +24 -5
- package/dist/{provenance-BbVagC68.d.ts → provenance-DpjwyseI.d.ts} +6 -6
- package/dist/{query-Ck190MOd.d.ts → query-CF7PG61p.d.ts} +5 -3
- package/dist/raw-provider-sink-C46HDghv.d.ts +132 -0
- package/dist/{release-report-CamNDe90.d.ts → release-report-C8G2i5Xi.d.ts} +2 -2
- package/dist/reporting.d.ts +10 -9
- package/dist/{researcher-Dwbo_Fxx.d.ts → researcher-C8XyxQsu.d.ts} +8 -8
- package/dist/rl.d.ts +18 -15
- package/dist/rl.js +2 -2
- package/dist/{rubric-predictive-validity-BIdf9h4R.d.ts → rubric-predictive-validity-p49lLVrE.d.ts} +1 -1
- package/dist/{run-campaign-UADIM77S.js → run-campaign-IM26A6PD.js} +4 -2
- package/dist/{run-record-CZmcpWPo.d.ts → run-record-BDH49H2E.d.ts} +1 -1
- package/dist/{runtime-trajectory-CC0jx9ql.d.ts → runtime-trajectory-DGBIUt4B.d.ts} +1 -1
- package/dist/{schema-SGWcK9wa.d.ts → schema-B3Q3l9Z_.d.ts} +2 -0
- package/dist/{semantic-concept-judge-CKjePUMh.d.ts → semantic-concept-judge-CXnPEJbf.d.ts} +24 -6
- package/dist/{statistics-oUbOJe-S.d.ts → statistics-KUnG73jH.d.ts} +1 -1
- package/dist/{storage-Dw_f7WMt.d.ts → storage-DrX3v_5B.d.ts} +12 -1
- package/dist/{store-9cAScOcb.d.ts → store-C1YxJDEK.d.ts} +1 -132
- package/dist/{store-BsVi7ncX.d.ts → store-DGqD0Pyo.d.ts} +1 -1
- package/dist/storyboard/index.d.ts +1 -1
- package/dist/{summary-report-DTNgQycC.d.ts → summary-report-C5bKFfm-.d.ts} +2 -2
- package/dist/{test-graded-scenario-mzYBKspu.d.ts → test-graded-scenario-B0ybnPY7.d.ts} +3 -3
- package/dist/traces.d.ts +25 -14
- package/dist/traces.js +16 -4
- package/dist/{types-Ca_63YSD.d.ts → types-BSw1rOUB.d.ts} +41 -39
- package/dist/{types-C7DGg5ex.d.ts → types-BkfcQnxV.d.ts} +15 -0
- package/dist/wire/index.d.ts +28 -19
- package/dist/wire/index.js +4 -2
- package/docs/distributed-driver.md +1 -1
- package/package.json +3 -3
- package/dist/chunk-3274WNK7.js.map +0 -1
- package/dist/chunk-4D5RVB3W.js.map +0 -1
- package/dist/chunk-7GKEAIAD.js +0 -205
- package/dist/chunk-7GKEAIAD.js.map +0 -1
- package/dist/chunk-CIUOICJT.js.map +0 -1
- package/dist/chunk-FAOEFFRT.js.map +0 -1
- package/dist/chunk-GSW3OBHK.js.map +0 -1
- package/dist/chunk-GY4SYVPJ.js.map +0 -1
- package/dist/chunk-LNQEP766.js.map +0 -1
- package/dist/chunk-MHNQWM4I.js.map +0 -1
- package/dist/chunk-MPHTT5HE.js +0 -74
- package/dist/chunk-MPHTT5HE.js.map +0 -1
- package/dist/chunk-NBSS5NDZ.js.map +0 -1
- package/dist/chunk-NYFUT3B3.js.map +0 -1
- package/dist/chunk-TLDB7WRY.js.map +0 -1
- package/dist/cost-ledger-DuSqlw5B.d.ts +0 -113
- /package/dist/{chunk-RPDDVKI7.js.map → chunk-4JLWXDYA.js.map} +0 -0
- /package/dist/{chunk-J6P6PK2R.js.map → chunk-FQNLDL4D.js.map} +0 -0
- /package/dist/{chunk-ONM6PEAE.js.map → chunk-GQCZRZ7L.js.map} +0 -0
- /package/dist/{chunk-3LXTCTWL.js.map → chunk-JSDVRFAP.js.map} +0 -0
- /package/dist/{run-campaign-UADIM77S.js.map → run-campaign-IM26A6PD.js.map} +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { V as ValidationError } from './errors-oeQrLqXC.js';
|
|
2
|
+
|
|
3
|
+
type CostChannel = 'agent' | 'judge' | 'verifier' | 'analyst' | 'driver' | (string & {});
|
|
4
|
+
interface CostUsage {
|
|
5
|
+
inputTokens: number;
|
|
6
|
+
outputTokens: number;
|
|
7
|
+
cachedTokens?: number;
|
|
8
|
+
}
|
|
9
|
+
interface CostCallBase {
|
|
10
|
+
callId: string;
|
|
11
|
+
channel: CostChannel;
|
|
12
|
+
phase: string;
|
|
13
|
+
actor: string;
|
|
14
|
+
model: string;
|
|
15
|
+
maximumCostUsd?: number;
|
|
16
|
+
tags?: Record<string, string>;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
}
|
|
19
|
+
interface CostReceipt extends CostCallBase, CostUsage {
|
|
20
|
+
status: 'settled';
|
|
21
|
+
costUsd: number;
|
|
22
|
+
costUnknown: boolean;
|
|
23
|
+
usageUnknown?: boolean;
|
|
24
|
+
pricing?: {
|
|
25
|
+
inputUsdPerThousand: number;
|
|
26
|
+
outputUsdPerThousand: number;
|
|
27
|
+
};
|
|
28
|
+
actualCostUsd?: number;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
/** @deprecated Read-only compatibility shape. New paid work uses `runPaidCall`. */
|
|
32
|
+
type CostLedgerEntry = Omit<CostReceipt, 'status' | 'callId' | 'phase' | 'actor' | 'maximumCostUsd' | 'usageUnknown' | 'pricing' | 'error'>;
|
|
33
|
+
interface CostReceiptInput extends CostUsage {
|
|
34
|
+
model: string;
|
|
35
|
+
actualCostUsd?: number;
|
|
36
|
+
costUnknown?: boolean;
|
|
37
|
+
usageUnknown?: boolean;
|
|
38
|
+
}
|
|
39
|
+
type MaximumCharge = {
|
|
40
|
+
externallyEnforcedMaximumUsd: number;
|
|
41
|
+
} | ({
|
|
42
|
+
model: string;
|
|
43
|
+
} & CostUsage);
|
|
44
|
+
interface RunPaidCallInput<T> {
|
|
45
|
+
callId?: string;
|
|
46
|
+
channel: CostChannel;
|
|
47
|
+
phase: string;
|
|
48
|
+
actor: string;
|
|
49
|
+
/** Used before a provider receipt exists and on failures without one. */
|
|
50
|
+
model?: string;
|
|
51
|
+
tags?: Record<string, string>;
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
/** Provider-enforced dollar maximum, or maximum priced token usage. Required when capped. */
|
|
54
|
+
maximumCharge?: MaximumCharge;
|
|
55
|
+
/** `callId` can be forwarded as the provider's idempotency key. */
|
|
56
|
+
execute(signal: AbortSignal, callId: string): Promise<T>;
|
|
57
|
+
receipt(value: T): CostReceiptInput;
|
|
58
|
+
receiptFromError?(error: Error): CostReceiptInput | undefined;
|
|
59
|
+
}
|
|
60
|
+
type PaidCallResult<T> = {
|
|
61
|
+
succeeded: true;
|
|
62
|
+
callId: string;
|
|
63
|
+
value: T;
|
|
64
|
+
receipt: CostReceipt;
|
|
65
|
+
} | {
|
|
66
|
+
succeeded: false;
|
|
67
|
+
callId?: string;
|
|
68
|
+
error: Error;
|
|
69
|
+
receipt?: CostReceipt;
|
|
70
|
+
};
|
|
71
|
+
interface ChannelRollup {
|
|
72
|
+
channel: CostChannel;
|
|
73
|
+
calls: number;
|
|
74
|
+
inputTokens: number;
|
|
75
|
+
outputTokens: number;
|
|
76
|
+
cachedTokens: number;
|
|
77
|
+
costUsd: number;
|
|
78
|
+
unpricedCalls: number;
|
|
79
|
+
unknownUsageCalls: number;
|
|
80
|
+
}
|
|
81
|
+
interface CostLedgerSummary {
|
|
82
|
+
totalCalls: number;
|
|
83
|
+
pendingCalls: number;
|
|
84
|
+
unresolvedCalls: number;
|
|
85
|
+
reservedCostUsd: number;
|
|
86
|
+
inputTokens: number;
|
|
87
|
+
outputTokens: number;
|
|
88
|
+
cachedTokens: number;
|
|
89
|
+
totalCostUsd: number;
|
|
90
|
+
byChannel: ChannelRollup[];
|
|
91
|
+
unpricedModels: string[];
|
|
92
|
+
fullyPriced: boolean;
|
|
93
|
+
usageComplete: boolean;
|
|
94
|
+
accountingComplete: boolean;
|
|
95
|
+
incompleteReasons: string[];
|
|
96
|
+
}
|
|
97
|
+
interface CostLedgerFilter {
|
|
98
|
+
channel?: CostChannel;
|
|
99
|
+
phase?: string;
|
|
100
|
+
tags?: Record<string, string>;
|
|
101
|
+
}
|
|
102
|
+
/** Append-only storage. `append` must atomically reject stale revisions. */
|
|
103
|
+
interface CostLedgerPersistence {
|
|
104
|
+
read(): {
|
|
105
|
+
revision: string;
|
|
106
|
+
events: string;
|
|
107
|
+
};
|
|
108
|
+
append(expectedRevision: string, event: string): string | undefined;
|
|
109
|
+
}
|
|
110
|
+
interface CostLedgerOptions {
|
|
111
|
+
costCeilingUsd?: number;
|
|
112
|
+
persistence?: CostLedgerPersistence;
|
|
113
|
+
/** Import already-settled receipts without admitting new paid work. */
|
|
114
|
+
receipts?: readonly CostReceipt[];
|
|
115
|
+
}
|
|
116
|
+
declare class CostCeilingReachedError extends ValidationError {
|
|
117
|
+
constructor(ceilingUsd: number, committedAndReservedUsd: number, requestedUsd: number, phase: string, actor: string);
|
|
118
|
+
}
|
|
119
|
+
declare class CostAccountingIncompleteError extends ValidationError {
|
|
120
|
+
}
|
|
121
|
+
declare class CostReservationExceededError extends ValidationError {
|
|
122
|
+
constructor(actor: string, actualUsd: number, maximumUsd: number);
|
|
123
|
+
}
|
|
124
|
+
declare class CostCallConflictError extends ValidationError {
|
|
125
|
+
readonly callId?: string;
|
|
126
|
+
readonly receipt?: CostReceipt;
|
|
127
|
+
constructor(message: string, options?: {
|
|
128
|
+
callId?: string;
|
|
129
|
+
receipt?: CostReceipt;
|
|
130
|
+
cause?: unknown;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
declare class CostLedgerPersistenceError extends ValidationError {
|
|
134
|
+
readonly callId?: string;
|
|
135
|
+
readonly receipt?: CostReceipt;
|
|
136
|
+
constructor(cause: unknown, callId?: string, receipt?: CostReceipt);
|
|
137
|
+
}
|
|
138
|
+
declare class CostReceiptCaptureError extends ValidationError {
|
|
139
|
+
readonly callId: string;
|
|
140
|
+
readonly receipt?: CostReceipt;
|
|
141
|
+
readonly receiptError: Error;
|
|
142
|
+
constructor(callId: string, cause: unknown, receiptError: unknown, receipt?: CostReceipt);
|
|
143
|
+
}
|
|
144
|
+
/** Run-wide paid-call admission, durable call state, receipts, and summaries. */
|
|
145
|
+
declare class CostLedger {
|
|
146
|
+
private readonly records;
|
|
147
|
+
private readonly activeCallIds;
|
|
148
|
+
private readonly lateCallIds;
|
|
149
|
+
private completedTasks;
|
|
150
|
+
private revision;
|
|
151
|
+
private costLimitPersisted;
|
|
152
|
+
readonly costCeilingUsd?: number;
|
|
153
|
+
private readonly persistence?;
|
|
154
|
+
constructor(input?: number | CostLedgerOptions);
|
|
155
|
+
runPaidCall<T>(input: RunPaidCallInput<T>): Promise<PaidCallResult<T>>;
|
|
156
|
+
/** Settle a call left pending by a crashed process after reconciling with the provider. */
|
|
157
|
+
reconcile(callId: string, observed: CostReceiptInput, options?: {
|
|
158
|
+
error?: string;
|
|
159
|
+
}): CostReceipt;
|
|
160
|
+
list(filter?: CostLedgerFilter): CostReceipt[];
|
|
161
|
+
summary(filter?: CostLedgerFilter): CostLedgerSummary;
|
|
162
|
+
markCompleted(count?: number): void;
|
|
163
|
+
costPerCompletedTask(): number | null;
|
|
164
|
+
private execute;
|
|
165
|
+
private captureLateOutcome;
|
|
166
|
+
private commitOutcome;
|
|
167
|
+
private captureFailure;
|
|
168
|
+
private commitReceipt;
|
|
169
|
+
private resolveMaximum;
|
|
170
|
+
private hasIncompleteSettledCall;
|
|
171
|
+
private appendRecord;
|
|
172
|
+
private ensureCostLimitPersisted;
|
|
173
|
+
private appendEvent;
|
|
174
|
+
}
|
|
175
|
+
/** Return the canonical pricing-table key, or null when the model is unpriced. */
|
|
176
|
+
declare function modelPriceKey(model: string): string | null;
|
|
177
|
+
interface CostResult {
|
|
178
|
+
costUsd: number;
|
|
179
|
+
costUnknown: boolean;
|
|
180
|
+
}
|
|
181
|
+
declare function costForUsage(model: string, usage: CostUsage): CostResult;
|
|
182
|
+
|
|
183
|
+
export { CostLedger as C, type MaximumCharge as M, type PaidCallResult as P, type RunPaidCallInput as R, type CostChannel as a, type CostLedgerSummary as b, type CostReceiptInput as c, type CostReceipt as d, type ChannelRollup as e, CostAccountingIncompleteError as f, CostCallConflictError as g, CostCeilingReachedError as h, type CostLedgerEntry as i, type CostLedgerFilter as j, type CostLedgerOptions as k, type CostLedgerPersistence as l, CostLedgerPersistenceError as m, CostReceiptCaptureError as n, CostReservationExceededError as o, type CostResult as p, type CostUsage as q, costForUsage as r, modelPriceKey as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxAIService } from '@ax-llm/ax';
|
|
2
|
-
import { T as TraceAnalystKindSpec } from './kind-factory-
|
|
3
|
-
import { A as Analyst,
|
|
2
|
+
import { T as TraceAnalystKindSpec } from './kind-factory-ClZmO25A.js';
|
|
3
|
+
import { A as Analyst, a as AnalystContext, b as AnalystRunSummary, c as AnalystFinding, d as AnalystRunResult, C as ChatClient, e as AnalystRunInputs, f as AnalystRunEvent } from './policy-edit-wG9uFEFm.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* AnalystRegistry — orchestrate N analysts against one run.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as RunOutcome, R as Run, S as Span, b as SpanKind, L as LlmSpan, T as ToolSpan, c as RetrievalSpan, J as JudgeSpan, d as SandboxSpan, E as EventKind, e as TraceEvent, B as BudgetLedgerEntry, A as Artifact, M as Message } from './schema-
|
|
2
|
-
import { T as TraceStore } from './store-
|
|
1
|
+
import { a as RunOutcome, R as Run, S as Span, b as SpanKind, L as LlmSpan, T as ToolSpan, c as RetrievalSpan, J as JudgeSpan, d as SandboxSpan, E as EventKind, e as TraceEvent, B as BudgetLedgerEntry, A as Artifact, M as Message } from './schema-B3Q3l9Z_.js';
|
|
2
|
+
import { T as TraceStore } from './store-DGqD0Pyo.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* TraceEmitter — hierarchical span builder that auto-parents using an
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Run, S as Span, e as TraceEvent, F as FailureClass } from './schema-
|
|
2
|
-
import { T as TraceStore } from './store-
|
|
1
|
+
import { R as Run, S as Span, e as TraceEvent, F as FailureClass } from './schema-B3Q3l9Z_.js';
|
|
2
|
+
import { T as TraceStore } from './store-DGqD0Pyo.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Failure taxonomy — canonical classes + a default classifier.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TraceEmitter } from './emitter-
|
|
2
|
-
import { F as FailureClass } from './schema-
|
|
3
|
-
import { T as TraceStore } from './store-
|
|
1
|
+
import { T as TraceEmitter } from './emitter-CjD7vUwv.js';
|
|
2
|
+
import { F as FailureClass } from './schema-B3Q3l9Z_.js';
|
|
3
|
+
import { T as TraceStore } from './store-DGqD0Pyo.js';
|
|
4
4
|
import { a as DatasetSplit, D as DatasetScenario } from './dataset-NENEzRgk.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/fuzz.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { C as CostLedger, a as CostChannel } from './cost-ledger-
|
|
1
|
+
import { M as MaximumCharge, C as CostLedger, a as CostChannel } from './cost-ledger-DWy3XdJc.js';
|
|
2
2
|
import { D as DefaultVerdict } from './verdict-C9MlYujm.js';
|
|
3
3
|
import { A as AdversarialMutation } from './adversarial-B7loGVVX.js';
|
|
4
|
+
import './errors-oeQrLqXC.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Behavior-space exploration — types.
|
|
@@ -289,12 +290,11 @@ interface ExploreOptions<S> {
|
|
|
289
290
|
* every other cost option (`costBudgetUsd` / `ledger` / `onCost`).
|
|
290
291
|
*/
|
|
291
292
|
costOf?: (scenario: S, cell: Cell, ev: Evaluation) => RunCost | null;
|
|
293
|
+
/** Pre-call hard maximum. Required whenever the explorer uses a capped ledger. */
|
|
294
|
+
maximumChargeOf?: (scenario: S, cell: Cell) => MaximumCharge;
|
|
292
295
|
/**
|
|
293
|
-
* Hard dollar
|
|
294
|
-
*
|
|
295
|
-
* once spent ≥ ceiling; no new evaluation starts after that). Unknown-cost
|
|
296
|
-
* runs do not consume budget — they are reported separately, so the ceiling
|
|
297
|
-
* is honest about what it can see.
|
|
296
|
+
* Hard dollar cap. Each evaluation reserves `maximumChargeOf` before it starts;
|
|
297
|
+
* calls that do not fit are rejected. Unknown totals stop further paid work.
|
|
298
298
|
*/
|
|
299
299
|
costBudgetUsd?: number;
|
|
300
300
|
/**
|
|
@@ -423,21 +423,13 @@ declare class BehaviorExplorer<S> {
|
|
|
423
423
|
private consecutiveEvalErrors;
|
|
424
424
|
private stoppedEarly;
|
|
425
425
|
private rngState;
|
|
426
|
-
|
|
427
|
-
private
|
|
428
|
-
private costUnknownRuns;
|
|
426
|
+
private readonly costLedger?;
|
|
427
|
+
private readonly costPhase;
|
|
429
428
|
constructor(opts: ExploreOptions<S>);
|
|
430
429
|
private rng;
|
|
431
430
|
private binId;
|
|
432
431
|
private allocate;
|
|
433
432
|
private objectiveContext;
|
|
434
|
-
/** Mirrors control-runtime: stop once accumulated KNOWN cost ≥ the ceiling. */
|
|
435
|
-
private costExhausted;
|
|
436
|
-
/** Fold one run's cost in: null counts as unknown (never $0); a known cost
|
|
437
|
-
* accrues toward the budget, lands in the ledger, and fires `onCost`. */
|
|
438
|
-
/** Returns the run's known cost, `null` when tracked-but-unknown, `undefined`
|
|
439
|
-
* when cost tracking is not wired — the log row mirrors this exactly. */
|
|
440
|
-
private recordRunCost;
|
|
441
433
|
/** Elites whose INPUT cell matches — what the proposer mutates/deepens from. */
|
|
442
434
|
private elitesFor;
|
|
443
435
|
/** One allocate → propose → evaluate → gate → archive round. */
|
package/dist/fuzz.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
varianceBasedCurriculum
|
|
3
3
|
} from "./chunk-VZSRQ272.js";
|
|
4
|
+
import {
|
|
5
|
+
CostLedger,
|
|
6
|
+
CostReceiptCaptureError
|
|
7
|
+
} from "./chunk-VCTY3W6J.js";
|
|
8
|
+
import "./chunk-VI2UW6B6.js";
|
|
4
9
|
import {
|
|
5
10
|
ValidationError
|
|
6
11
|
} from "./chunk-ONWEPEDO.js";
|
|
@@ -326,6 +331,17 @@ var BehaviorExplorer = class {
|
|
|
326
331
|
"BehaviorExplorer: costBudgetUsd/ledger/onCost require costOf \u2014 the explorer cannot know run cost without it; supply costOf or drop the cost options"
|
|
327
332
|
);
|
|
328
333
|
}
|
|
334
|
+
if ((opts.costBudgetUsd !== void 0 || opts.ledger?.costCeilingUsd !== void 0) && !opts.maximumChargeOf) {
|
|
335
|
+
throw new ValidationError(
|
|
336
|
+
"BehaviorExplorer: capped cost tracking requires maximumChargeOf before evaluation"
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
if (opts.ledger && opts.costBudgetUsd !== void 0 && opts.ledger.costCeilingUsd !== opts.costBudgetUsd) {
|
|
340
|
+
throw new ValidationError(
|
|
341
|
+
"BehaviorExplorer: costBudgetUsd must match the supplied CostLedger ceiling"
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
if (opts.costOf) this.costLedger = opts.ledger ?? new CostLedger(opts.costBudgetUsd);
|
|
329
345
|
this.cellById = new Map(this.cells.map((c) => [c.id, c]));
|
|
330
346
|
this.objective = opts.objective ?? adversarialObjective(0.5);
|
|
331
347
|
this.threshold = this.objective.threshold ?? 0.5;
|
|
@@ -354,9 +370,8 @@ var BehaviorExplorer = class {
|
|
|
354
370
|
consecutiveEvalErrors = 0;
|
|
355
371
|
stoppedEarly;
|
|
356
372
|
rngState;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
costUnknownRuns = 0;
|
|
373
|
+
costLedger;
|
|
374
|
+
costPhase = "fuzz.explore";
|
|
360
375
|
// mulberry32 — deterministic per session.
|
|
361
376
|
rng = () => {
|
|
362
377
|
this.rngState = this.rngState + 1831565813 | 0;
|
|
@@ -393,37 +408,6 @@ var BehaviorExplorer = class {
|
|
|
393
408
|
archiveDescriptors: entries.map((e) => e.evaluation.descriptor)
|
|
394
409
|
};
|
|
395
410
|
}
|
|
396
|
-
/** Mirrors control-runtime: stop once accumulated KNOWN cost ≥ the ceiling. */
|
|
397
|
-
costExhausted() {
|
|
398
|
-
return this.opts.costBudgetUsd !== void 0 && this.spentKnownUsd >= this.opts.costBudgetUsd;
|
|
399
|
-
}
|
|
400
|
-
/** Fold one run's cost in: null counts as unknown (never $0); a known cost
|
|
401
|
-
* accrues toward the budget, lands in the ledger, and fires `onCost`. */
|
|
402
|
-
/** Returns the run's known cost, `null` when tracked-but-unknown, `undefined`
|
|
403
|
-
* when cost tracking is not wired — the log row mirrors this exactly. */
|
|
404
|
-
recordRunCost(scenario, cell, ev) {
|
|
405
|
-
if (!this.opts.costOf) return void 0;
|
|
406
|
-
const cost = this.opts.costOf(scenario, cell, ev);
|
|
407
|
-
if (cost === null) {
|
|
408
|
-
this.costUnknownRuns++;
|
|
409
|
-
return null;
|
|
410
|
-
}
|
|
411
|
-
if (typeof cost.usd !== "number" || !Number.isFinite(cost.usd) || cost.usd < 0) {
|
|
412
|
-
throw new RangeError(
|
|
413
|
-
`BehaviorExplorer: costOf returned an invalid usd (${String(cost?.usd)}) \u2014 return null when cost is unknown, never a fabricated number`
|
|
414
|
-
);
|
|
415
|
-
}
|
|
416
|
-
this.spentKnownUsd += cost.usd;
|
|
417
|
-
this.opts.ledger?.record({
|
|
418
|
-
model: cost.model ?? "unattributed",
|
|
419
|
-
channel: "agent",
|
|
420
|
-
usage: { inputTokens: 0, outputTokens: 0 },
|
|
421
|
-
actualCostUsd: cost.usd,
|
|
422
|
-
tags: { target: this.opts.target, cell: cell.id }
|
|
423
|
-
});
|
|
424
|
-
this.opts.onCost?.({ usd: cost.usd, channel: "agent" });
|
|
425
|
-
return cost.usd;
|
|
426
|
-
}
|
|
427
411
|
/** Elites whose INPUT cell matches — what the proposer mutates/deepens from. */
|
|
428
412
|
elitesFor(cellId2) {
|
|
429
413
|
const out = [];
|
|
@@ -433,13 +417,12 @@ var BehaviorExplorer = class {
|
|
|
433
417
|
/** One allocate → propose → evaluate → gate → archive round. */
|
|
434
418
|
async step() {
|
|
435
419
|
const remaining = this.opts.budget - this.runsUsed;
|
|
436
|
-
if (remaining <= 0 || this.
|
|
437
|
-
return { runs: 0, findings: [] };
|
|
420
|
+
if (remaining <= 0 || this.opts.signal?.aborted) return { runs: 0, findings: [] };
|
|
438
421
|
const allocations = this.allocate(Math.min(this.perRoundBudget, remaining));
|
|
439
422
|
const newFindings = [];
|
|
440
423
|
let runsThisStep = 0;
|
|
441
424
|
for (const alloc of allocations) {
|
|
442
|
-
if (this.runsUsed >= this.opts.budget || this.
|
|
425
|
+
if (this.runsUsed >= this.opts.budget || this.stoppedEarly !== void 0 || this.opts.signal?.aborted)
|
|
443
426
|
break;
|
|
444
427
|
const cell = this.cellById.get(alloc.cellId);
|
|
445
428
|
if (!cell) continue;
|
|
@@ -461,16 +444,56 @@ var BehaviorExplorer = class {
|
|
|
461
444
|
await pMap(
|
|
462
445
|
toEval,
|
|
463
446
|
async (scenario) => {
|
|
464
|
-
if (this.runsUsed >= this.opts.budget || this.
|
|
447
|
+
if (this.runsUsed >= this.opts.budget || this.stoppedEarly !== void 0 || this.opts.signal?.aborted)
|
|
465
448
|
return;
|
|
466
449
|
try {
|
|
467
450
|
const startedAt = performance.now();
|
|
468
|
-
const
|
|
451
|
+
const paid = this.costLedger ? await this.costLedger.runPaidCall({
|
|
452
|
+
channel: "agent",
|
|
453
|
+
phase: this.costPhase,
|
|
454
|
+
actor: "fuzz.evaluate",
|
|
455
|
+
tags: { target: this.opts.target, cell: cell.id },
|
|
456
|
+
signal: this.opts.signal,
|
|
457
|
+
maximumCharge: this.opts.maximumChargeOf?.(scenario, cell),
|
|
458
|
+
execute: () => this.opts.evaluate(scenario, cell),
|
|
459
|
+
receipt: (evaluation) => {
|
|
460
|
+
const cost = this.opts.costOf(scenario, cell, evaluation);
|
|
461
|
+
if (cost === null) {
|
|
462
|
+
return {
|
|
463
|
+
model: "unattributed",
|
|
464
|
+
inputTokens: 0,
|
|
465
|
+
outputTokens: 0,
|
|
466
|
+
costUnknown: true
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
if (!Number.isFinite(cost.usd) || cost.usd < 0) {
|
|
470
|
+
throw new RangeError(
|
|
471
|
+
`BehaviorExplorer: costOf returned an invalid usd (${String(cost.usd)}) \u2014 return null when cost is unknown, never a fabricated number`
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
model: cost.model ?? "unattributed",
|
|
476
|
+
inputTokens: 0,
|
|
477
|
+
outputTokens: 0,
|
|
478
|
+
actualCostUsd: cost.usd
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
}) : void 0;
|
|
482
|
+
if (paid && !paid.succeeded) {
|
|
483
|
+
if (paid.error instanceof CostReceiptCaptureError && paid.error.receiptError instanceof RangeError) {
|
|
484
|
+
throw paid.error.receiptError;
|
|
485
|
+
}
|
|
486
|
+
throw paid.error;
|
|
487
|
+
}
|
|
488
|
+
const ev = paid ? paid.value : await this.opts.evaluate(scenario, cell);
|
|
469
489
|
const latencyMs = ev.latencyMs ?? performance.now() - startedAt;
|
|
470
490
|
this.runsUsed++;
|
|
471
491
|
runsThisStep++;
|
|
472
492
|
this.consecutiveEvalErrors = 0;
|
|
473
|
-
const costUsd =
|
|
493
|
+
const costUsd = paid ? paid.receipt.costUnknown ? null : paid.receipt.costUsd : void 0;
|
|
494
|
+
if (paid?.receipt.actualCostUsd !== void 0) {
|
|
495
|
+
this.opts.onCost?.({ usd: paid.receipt.actualCostUsd, channel: "agent" });
|
|
496
|
+
}
|
|
474
497
|
const interest = this.objective.interest(ev, this.objectiveContext());
|
|
475
498
|
this.log.push({
|
|
476
499
|
cell,
|
|
@@ -535,7 +558,7 @@ var BehaviorExplorer = class {
|
|
|
535
558
|
/** Loop `step()` until the run or dollar budget is spent, the signal aborts,
|
|
536
559
|
* or no progress is made. */
|
|
537
560
|
async run() {
|
|
538
|
-
while (this.runsUsed < this.opts.budget &&
|
|
561
|
+
while (this.runsUsed < this.opts.budget && this.stoppedEarly === void 0 && !this.opts.signal?.aborted) {
|
|
539
562
|
const { runs } = await this.step();
|
|
540
563
|
if (runs === 0 && this.stoppedEarly === void 0) break;
|
|
541
564
|
}
|
|
@@ -548,6 +571,10 @@ var BehaviorExplorer = class {
|
|
|
548
571
|
return [...this._findings].sort((a, b) => b.interest - a.interest);
|
|
549
572
|
}
|
|
550
573
|
capsule() {
|
|
574
|
+
const cost = this.costLedger?.summary({
|
|
575
|
+
phase: this.costPhase,
|
|
576
|
+
tags: { target: this.opts.target }
|
|
577
|
+
});
|
|
551
578
|
return buildCapsule({
|
|
552
579
|
target: this.opts.target,
|
|
553
580
|
objective: this.objective.kind,
|
|
@@ -558,7 +585,10 @@ var BehaviorExplorer = class {
|
|
|
558
585
|
findings: this._findings,
|
|
559
586
|
candidateFindings: this.candidateFindings,
|
|
560
587
|
runsUsed: this.runsUsed,
|
|
561
|
-
cost:
|
|
588
|
+
cost: cost ? {
|
|
589
|
+
costUsd: cost.totalCostUsd,
|
|
590
|
+
costUnknownRuns: cost.byChannel.reduce((sum, row) => sum + row.unpricedCalls, 0)
|
|
591
|
+
} : void 0,
|
|
562
592
|
evalErrors: this.evalErrors,
|
|
563
593
|
stoppedEarly: this.stoppedEarly
|
|
564
594
|
});
|