@tangle-network/agent-eval 0.108.1 → 0.110.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/analyst/index.d.ts +10 -12
- package/dist/analyst/index.js +8 -11
- package/dist/analyst/index.js.map +1 -1
- package/dist/{analyze-runs-DJYpep3L.d.ts → analyze-runs-Dmz6LA9e.d.ts} +4 -4
- package/dist/{baseline-Bbid3WoO.d.ts → baseline-DsNteOgR.d.ts} +32 -2
- package/dist/belief-state/index.d.ts +6 -6
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +7 -8
- package/dist/builder-eval/index.d.ts +4 -4
- package/dist/builder-eval/index.js +1 -2
- package/dist/builder-eval/index.js.map +1 -1
- package/dist/{calibration-BPmzuVPk.d.ts → calibration-Dz8TQV4y.d.ts} +2 -2
- package/dist/campaign/index.d.ts +161 -20
- package/dist/campaign/index.js +15 -8
- package/dist/{chunk-LOJ2QVCE.js → chunk-2IY4ILP4.js} +2 -2
- package/dist/{chunk-LIEJUH2I.js → chunk-6PL5MGDL.js} +9 -9
- package/dist/{chunk-2OGPXHOB.js → chunk-7NX6ZSBG.js} +36 -7
- package/dist/chunk-7NX6ZSBG.js.map +1 -0
- package/dist/{chunk-OVPVM4JC.js → chunk-GTERJI6Q.js} +4 -4
- package/dist/{chunk-YEHAEDUD.js → chunk-IMWDSFUM.js} +604 -2
- package/dist/chunk-IMWDSFUM.js.map +1 -0
- package/dist/{chunk-JZXGWLK5.js → chunk-MHNQWM4I.js} +62 -6
- package/dist/chunk-MHNQWM4I.js.map +1 -0
- package/dist/{chunk-QRVS7MX4.js → chunk-OW47B5WA.js} +3 -5
- package/dist/{chunk-QRVS7MX4.js.map → chunk-OW47B5WA.js.map} +1 -1
- package/dist/{chunk-DBDRR6GF.js → chunk-PLOMR3HP.js} +48 -2
- package/dist/chunk-PLOMR3HP.js.map +1 -0
- package/dist/{chunk-GDZAWO2I.js → chunk-QFGTU7MT.js} +2 -2
- package/dist/{chunk-6SKVFBTR.js → chunk-RNB2NICW.js} +115 -13
- package/dist/chunk-RNB2NICW.js.map +1 -0
- package/dist/{chunk-V7HNA47Z.js → chunk-RSVSSZKF.js} +5 -5
- package/dist/{chunk-5PK3626Q.js → chunk-XRGOKCMO.js} +88 -17
- package/dist/chunk-XRGOKCMO.js.map +1 -0
- package/dist/{code-agent-session-rnJKlqmT.d.ts → code-agent-session-yitf9I-F.d.ts} +1 -1
- package/dist/contract/index.d.ts +20 -23
- package/dist/contract/index.js +11 -13
- package/dist/contract/index.js.map +1 -1
- package/dist/{control-B8UthSBL.d.ts → control-U8LBKUES.d.ts} +5 -6
- package/dist/control.d.ts +8 -9
- package/dist/control.js +6 -8
- package/dist/{dataset-DS7ytHZU.d.ts → dataset-NENEzRgk.d.ts} +1 -1
- package/dist/{default-registry-BswHCXnU.d.ts → default-registry-Bcf1uKVI.d.ts} +1 -2
- package/dist/{emitter-C2rqGH_l.d.ts → emitter-BRchAAAx.d.ts} +2 -2
- package/dist/{failure-cluster-DH9Flgcf.d.ts → failure-cluster-C48PiReX.d.ts} +2 -2
- package/dist/feedback-trajectory-pDcz1lQ1.d.ts +348 -0
- package/dist/{gepa-B3x5Ulcv.d.ts → gepa-BUNP3606.d.ts} +143 -2
- package/dist/hosted/index.d.ts +7 -7
- package/dist/{index-pPtfoIJO.d.ts → index-Dc3VLGhp.d.ts} +2 -2
- package/dist/index.d.ts +645 -61
- package/dist/index.js +1282 -190
- package/dist/index.js.map +1 -1
- package/dist/{insight-report-B4xrdwEK.d.ts → insight-report-D4cXFsLt.d.ts} +1 -1
- package/dist/{integrity-DqGZg3st.d.ts → integrity-qemeBAyx.d.ts} +1 -1
- package/dist/{types-D1ytG0Yg.d.ts → kind-factory-20hcaYpf.d.ts} +169 -2
- package/dist/meta-eval/index.d.ts +5 -5
- package/dist/meta-eval/index.js +1 -2
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/{multi-layer-verifier-CI4jdX-q.d.ts → multi-layer-verifier-BsqKuLyN.d.ts} +1 -1
- package/dist/multishot/index.d.ts +3 -3
- package/dist/openapi.json +1 -1
- package/dist/pipelines/index.d.ts +6 -7
- package/dist/pipelines/index.js +3 -6
- package/dist/pipelines/index.js.map +1 -1
- package/dist/{policy-edit-DQUXYMDm.d.ts → policy-edit-D2bBDZDf.d.ts} +2 -2
- package/dist/{pre-registration-BUhVPzE7.d.ts → pre-registration-BepVVa6P.d.ts} +3 -3
- package/dist/{provenance-DdDhf6cg.d.ts → provenance-DMvsfknv.d.ts} +3 -5
- package/dist/{query-0aTmbmQe.d.ts → query-Ck190MOd.d.ts} +2 -2
- package/dist/{release-report-DeJpsBiA.d.ts → release-report-oBfOz8ku.d.ts} +3 -3
- package/dist/reporting.d.ts +8 -8
- package/dist/{researcher-Wc7dx6GM.d.ts → researcher-CaH0CwFC.d.ts} +6 -6
- package/dist/rl.d.ts +568 -15
- package/dist/rl.js +4 -4
- package/dist/{rubric-predictive-validity-DPnyG-CE.d.ts → rubric-predictive-validity-C-fMteAW.d.ts} +1 -1
- package/dist/{run-record-I-Z3JNvO.d.ts → run-record-DksGsfgv.d.ts} +1 -1
- package/dist/{runtime-trajectory-iW9IhV3e.d.ts → runtime-trajectory-h5i0SZUj.d.ts} +1 -1
- package/dist/{schema-m0gsnbt3.d.ts → schema-SGWcK9wa.d.ts} +1 -1
- package/dist/{semantic-concept-judge-BmNZPB_j.d.ts → semantic-concept-judge-D7z6JCLZ.d.ts} +57 -4
- package/dist/{store-BcFXE6LG.d.ts → store-BsVi7ncX.d.ts} +1 -1
- package/dist/storyboard/index.d.ts +1 -1
- package/dist/{summary-report-QMZVe3P-.d.ts → summary-report-Bz-0-t8v.d.ts} +2 -2
- package/dist/{test-graded-scenario-DeODGLra.d.ts → test-graded-scenario-mzYBKspu.d.ts} +3 -3
- package/dist/traces.d.ts +54 -11
- package/dist/traces.js +25 -27
- package/dist/{types-BdIv5dvA.d.ts → types-v--ctu-b.d.ts} +2 -2
- package/dist/wire/index.d.ts +5 -6
- package/package.json +1 -71
- package/dist/adapters/http.d.ts +0 -142
- package/dist/adapters/http.js +0 -203
- package/dist/adapters/http.js.map +0 -1
- package/dist/adapters/langchain.d.ts +0 -95
- package/dist/adapters/langchain.js +0 -34
- package/dist/adapters/langchain.js.map +0 -1
- package/dist/adapters/otel.d.ts +0 -112
- package/dist/adapters/otel.js +0 -110
- package/dist/adapters/otel.js.map +0 -1
- package/dist/chunk-2OGPXHOB.js.map +0 -1
- package/dist/chunk-45EEMHTC.js +0 -35
- package/dist/chunk-45EEMHTC.js.map +0 -1
- package/dist/chunk-5BKGXME7.js +0 -65
- package/dist/chunk-5BKGXME7.js.map +0 -1
- package/dist/chunk-5PK3626Q.js.map +0 -1
- package/dist/chunk-6SK5VFYK.js +0 -100
- package/dist/chunk-6SK5VFYK.js.map +0 -1
- package/dist/chunk-6SKVFBTR.js.map +0 -1
- package/dist/chunk-DBDRR6GF.js.map +0 -1
- package/dist/chunk-DJWX3GVS.js +0 -81
- package/dist/chunk-DJWX3GVS.js.map +0 -1
- package/dist/chunk-FOUG2VVS.js +0 -855
- package/dist/chunk-FOUG2VVS.js.map +0 -1
- package/dist/chunk-JZXGWLK5.js.map +0 -1
- package/dist/chunk-K7QEIHHJ.js +0 -613
- package/dist/chunk-K7QEIHHJ.js.map +0 -1
- package/dist/chunk-KKHDIONI.js +0 -414
- package/dist/chunk-KKHDIONI.js.map +0 -1
- package/dist/chunk-KMPRBJK4.js +0 -74
- package/dist/chunk-KMPRBJK4.js.map +0 -1
- package/dist/chunk-Q2JRAWRI.js +0 -196
- package/dist/chunk-Q2JRAWRI.js.map +0 -1
- package/dist/chunk-RZTMDUO7.js +0 -49
- package/dist/chunk-RZTMDUO7.js.map +0 -1
- package/dist/chunk-STGVSCDH.js +0 -202
- package/dist/chunk-STGVSCDH.js.map +0 -1
- package/dist/chunk-YEHAEDUD.js.map +0 -1
- package/dist/control-runtime-Acf9CGhw.d.ts +0 -182
- package/dist/corpus-eBVwhCp1.d.ts +0 -560
- package/dist/counterfactual-DlOz8PBx.d.ts +0 -85
- package/dist/diagnose.d.ts +0 -252
- package/dist/diagnose.js +0 -382
- package/dist/diagnose.js.map +0 -1
- package/dist/feedback-trajectory-C9KCo8ag.d.ts +0 -169
- package/dist/governance/index.d.ts +0 -135
- package/dist/governance/index.js +0 -18
- package/dist/governance/index.js.map +0 -1
- package/dist/groundedness/index.d.ts +0 -112
- package/dist/groundedness/index.js +0 -77
- package/dist/groundedness/index.js.map +0 -1
- package/dist/harness-optimizer-mOl9XX_O.d.ts +0 -106
- package/dist/kind-factory-DvIGo_cP.d.ts +0 -171
- package/dist/knowledge/index.d.ts +0 -103
- package/dist/knowledge/index.js +0 -18
- package/dist/knowledge/index.js.map +0 -1
- package/dist/pareto-E-pembql.d.ts +0 -81
- package/dist/perf/index.d.ts +0 -123
- package/dist/perf/index.js +0 -18
- package/dist/perf/index.js.map +0 -1
- package/dist/prm/index.d.ts +0 -104
- package/dist/prm/index.js +0 -265
- package/dist/prm/index.js.map +0 -1
- package/dist/product-benchmark/index.d.ts +0 -247
- package/dist/product-benchmark/index.js +0 -37
- package/dist/product-benchmark/index.js.map +0 -1
- package/dist/red-team-KmmiqBlY.d.ts +0 -63
- package/dist/redact-B40YG2M_.d.ts +0 -45
- package/dist/rubric-Cc6UHvUb.d.ts +0 -73
- package/dist/run-critic-CmMf05uV.d.ts +0 -56
- package/dist/sink-fetch-B1Yg4Til.d.ts +0 -101
- package/dist/telemetry/file.d.ts +0 -19
- package/dist/telemetry/file.js +0 -45
- package/dist/telemetry/file.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -38
- package/dist/telemetry/index.js +0 -130
- package/dist/telemetry/index.js.map +0 -1
- package/dist/testing-C21CHsq2.d.ts +0 -20
- package/dist/testing.d.ts +0 -1
- package/dist/testing.js +0 -8
- package/dist/testing.js.map +0 -1
- package/dist/trajectory-2TkpSEVh.d.ts +0 -33
- package/dist/workflow/index.d.ts +0 -496
- package/dist/workflow/index.js +0 -2178
- package/dist/workflow/index.js.map +0 -1
- /package/dist/{chunk-LOJ2QVCE.js.map → chunk-2IY4ILP4.js.map} +0 -0
- /package/dist/{chunk-LIEJUH2I.js.map → chunk-6PL5MGDL.js.map} +0 -0
- /package/dist/{chunk-OVPVM4JC.js.map → chunk-GTERJI6Q.js.map} +0 -0
- /package/dist/{chunk-GDZAWO2I.js.map → chunk-QFGTU7MT.js.map} +0 -0
- /package/dist/{chunk-V7HNA47Z.js.map → chunk-RSVSSZKF.js.map} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assertProductBenchmarkRun,
|
|
3
|
-
buildProductBenchmarkManifest,
|
|
4
|
-
exportProductBenchmark,
|
|
5
|
-
exportProductBenchmarkRuns,
|
|
6
|
-
findProductBenchmarkArtifacts,
|
|
7
|
-
productBenchmarkIntegrityFailures,
|
|
8
|
-
productBenchmarkMutableSurfaces,
|
|
9
|
-
productBenchmarkRepoIdentity,
|
|
10
|
-
productBenchmarkSplits,
|
|
11
|
-
readProductBenchmarkManifest,
|
|
12
|
-
readProductBenchmarkRecords,
|
|
13
|
-
runRecordToProductBenchmarkRecord,
|
|
14
|
-
validateProductBenchmarkManifest,
|
|
15
|
-
validateProductBenchmarkRecord,
|
|
16
|
-
validateProductBenchmarkRun
|
|
17
|
-
} from "../chunk-FOUG2VVS.js";
|
|
18
|
-
import "../chunk-ONWEPEDO.js";
|
|
19
|
-
import "../chunk-PZ5AY32C.js";
|
|
20
|
-
export {
|
|
21
|
-
assertProductBenchmarkRun,
|
|
22
|
-
buildProductBenchmarkManifest,
|
|
23
|
-
exportProductBenchmark,
|
|
24
|
-
exportProductBenchmarkRuns,
|
|
25
|
-
findProductBenchmarkArtifacts,
|
|
26
|
-
productBenchmarkIntegrityFailures,
|
|
27
|
-
productBenchmarkMutableSurfaces,
|
|
28
|
-
productBenchmarkRepoIdentity,
|
|
29
|
-
productBenchmarkSplits,
|
|
30
|
-
readProductBenchmarkManifest,
|
|
31
|
-
readProductBenchmarkRecords,
|
|
32
|
-
runRecordToProductBenchmarkRecord,
|
|
33
|
-
validateProductBenchmarkManifest,
|
|
34
|
-
validateProductBenchmarkRecord,
|
|
35
|
-
validateProductBenchmarkRun
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { a as DatasetScenario, b as Dataset } from './dataset-DS7ytHZU.js';
|
|
2
|
-
import { T as TraceStore } from './store-BcFXE6LG.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Red-team battery — adversarial scenario corpus with per-category
|
|
6
|
-
* scorers.
|
|
7
|
-
*
|
|
8
|
-
* Every scenario is a `DatasetScenario` with a `redTeam: {...}` payload
|
|
9
|
-
* that declares: category, expected refusal, attack surface. Scorers
|
|
10
|
-
* inspect the agent's output + trajectory and return a PASS/FAIL per
|
|
11
|
-
* category. Aggregated via `redTeamReport`.
|
|
12
|
-
*
|
|
13
|
-
* The built-in corpus is intentionally conservative — 40 cases
|
|
14
|
-
* covering the most-seen attack patterns. Extend via `extendCorpus`.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
type RedTeamCategory = 'prompt_injection_direct' | 'prompt_injection_indirect' | 'jailbreak_persona' | 'jailbreak_dan' | 'pii_leak' | 'permission_escalation' | 'data_exfil' | 'policy_override';
|
|
18
|
-
interface RedTeamPayload {
|
|
19
|
-
category: RedTeamCategory;
|
|
20
|
-
/** The hostile input the agent sees. */
|
|
21
|
-
input: string;
|
|
22
|
-
/**
|
|
23
|
-
* What a safe agent should do: "refuse" means explicit refusal,
|
|
24
|
-
* "ignore" means process benignly without executing the attack.
|
|
25
|
-
*/
|
|
26
|
-
expected: 'refuse' | 'ignore';
|
|
27
|
-
/** Substring(s) that MUST NOT appear in output. */
|
|
28
|
-
forbiddenStrings?: string[];
|
|
29
|
-
/** Tool names the agent MUST NOT call for this scenario. */
|
|
30
|
-
forbiddenTools?: string[];
|
|
31
|
-
}
|
|
32
|
-
interface RedTeamCase extends DatasetScenario {
|
|
33
|
-
payload: RedTeamPayload;
|
|
34
|
-
}
|
|
35
|
-
interface RedTeamFinding {
|
|
36
|
-
scenarioId: string;
|
|
37
|
-
category: RedTeamCategory;
|
|
38
|
-
passed: boolean;
|
|
39
|
-
reason: string;
|
|
40
|
-
evidence?: string;
|
|
41
|
-
}
|
|
42
|
-
interface RedTeamReport {
|
|
43
|
-
findings: RedTeamFinding[];
|
|
44
|
-
passRateByCategory: Record<RedTeamCategory, number>;
|
|
45
|
-
overallPassRate: number;
|
|
46
|
-
}
|
|
47
|
-
/** Ship a canonical, small corpus. Consumers extend via `extendCorpus`. */
|
|
48
|
-
declare const DEFAULT_RED_TEAM_CORPUS: RedTeamCase[];
|
|
49
|
-
declare function redTeamDataset(extraCases?: RedTeamCase[]): Dataset;
|
|
50
|
-
/**
|
|
51
|
-
* Score a single agent response against the red-team case.
|
|
52
|
-
* `toolCalls` should be the names of tools the agent invoked during the run.
|
|
53
|
-
*/
|
|
54
|
-
declare function scoreRedTeamOutput(output: string, toolCalls: string[], rtCase: RedTeamCase): RedTeamFinding;
|
|
55
|
-
/** Aggregate red-team findings into per-category pass rates. */
|
|
56
|
-
declare function redTeamReport(findings: RedTeamFinding[]): RedTeamReport;
|
|
57
|
-
/**
|
|
58
|
-
* Extract the tool-call names from a corpus run — convenience for the
|
|
59
|
-
* common pipeline (run the scenario → score the run).
|
|
60
|
-
*/
|
|
61
|
-
declare function toolNamesForRun(store: TraceStore, runId: string): Promise<string[]>;
|
|
62
|
-
|
|
63
|
-
export { DEFAULT_RED_TEAM_CORPUS as D, type RedTeamCase as R, type RedTeamCategory as a, type RedTeamFinding as b, type RedTeamPayload as c, type RedTeamReport as d, redTeamReport as e, redTeamDataset as r, scoreRedTeamOutput as s, toolNamesForRun as t };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redaction — remove PII / secrets from trace payloads before persist.
|
|
3
|
-
*
|
|
4
|
-
* Pre-persistence rules mean raw traces in storage are already scrubbed.
|
|
5
|
-
* Unredacted variants (for debugging / post-mortems) live in a separate
|
|
6
|
-
* storage layer with stricter access controls; this module only covers
|
|
7
|
-
* the default scrub-then-persist path.
|
|
8
|
-
*
|
|
9
|
-
* Rules compose: pass an array of `RedactionRule`, each is applied in
|
|
10
|
-
* order. Strings that match get replaced with a tagged sentinel so the
|
|
11
|
-
* eval framework can count how many redactions happened per run
|
|
12
|
-
* (surfaced via `redaction_applied` events).
|
|
13
|
-
*/
|
|
14
|
-
interface RedactionRule {
|
|
15
|
-
id: string;
|
|
16
|
-
pattern: RegExp;
|
|
17
|
-
/** Replacement — e.g. '[PII:email]'. Defaults to `[redacted:{id}]`. */
|
|
18
|
-
replacement?: string;
|
|
19
|
-
}
|
|
20
|
-
interface RedactionReport {
|
|
21
|
-
redactionCount: number;
|
|
22
|
-
byRule: Record<string, number>;
|
|
23
|
-
}
|
|
24
|
-
/** OWASP / common-sense defaults — extend per-domain. */
|
|
25
|
-
declare const DEFAULT_REDACTION_RULES: RedactionRule[];
|
|
26
|
-
declare const REDACTION_VERSION = "1.0.0";
|
|
27
|
-
/**
|
|
28
|
-
* Redact a single string. Returns the new string and a per-rule count of
|
|
29
|
-
* how many substitutions fired.
|
|
30
|
-
*/
|
|
31
|
-
declare function redactString(input: string, rules?: RedactionRule[]): {
|
|
32
|
-
output: string;
|
|
33
|
-
report: RedactionReport;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Walk a JSON-ish value applying `redactString` to every string leaf.
|
|
37
|
-
* Arrays and plain objects are recursed; other types pass through
|
|
38
|
-
* untouched. Circular references throw — traces should be tree-shaped.
|
|
39
|
-
*/
|
|
40
|
-
declare function redactValue(value: unknown, rules?: RedactionRule[], report?: RedactionReport): {
|
|
41
|
-
value: unknown;
|
|
42
|
-
report: RedactionReport;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export { DEFAULT_REDACTION_RULES as D, type RedactionRule as R, type RedactionReport as a, REDACTION_VERSION as b, redactValue as c, redactString as r };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { S as Span, J as JudgeSpan } from './schema-m0gsnbt3.js';
|
|
2
|
-
import { T as TraceStore } from './store-BcFXE6LG.js';
|
|
3
|
-
import { T as Trajectory, a as TrajectoryStep } from './trajectory-2TkpSEVh.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Process Reward Modeling — per-step rubric grading.
|
|
7
|
-
*
|
|
8
|
-
* A StepRubric inspects one span and returns a score + rationale.
|
|
9
|
-
* PrmGrader applies an array of rubrics to every LLM span in a
|
|
10
|
-
* trajectory (consumers can broaden to tool/retrieval spans via the
|
|
11
|
-
* `kind` filter on each rubric).
|
|
12
|
-
*
|
|
13
|
-
* Why this matters: outcome-only eval (did the final artifact work?)
|
|
14
|
-
* gives sparse reward — most agent turns are unattributable. PRMs
|
|
15
|
-
* densify the signal so optimizers and RL fine-tuning can assign
|
|
16
|
-
* credit per turn.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
interface StepContext {
|
|
20
|
-
trajectory: Trajectory;
|
|
21
|
-
step: TrajectoryStep;
|
|
22
|
-
/** Steps preceding `step` in trajectory order. */
|
|
23
|
-
prior: TrajectoryStep[];
|
|
24
|
-
/** Steps following `step`. */
|
|
25
|
-
next: TrajectoryStep[];
|
|
26
|
-
}
|
|
27
|
-
interface StepRubric {
|
|
28
|
-
id: string;
|
|
29
|
-
/** Only grade spans of these kinds (default: all). */
|
|
30
|
-
kinds?: Array<Span['kind']>;
|
|
31
|
-
/** Weight in the aggregate score. Default 1. */
|
|
32
|
-
weight?: number;
|
|
33
|
-
/** Returns score in 0..1 + optional rationale/evidence. Return `null` to
|
|
34
|
-
* skip grading (rubric doesn't apply to this step). */
|
|
35
|
-
grade: (ctx: StepContext) => Promise<{
|
|
36
|
-
score: number;
|
|
37
|
-
rationale?: string;
|
|
38
|
-
evidence?: string;
|
|
39
|
-
} | null>;
|
|
40
|
-
}
|
|
41
|
-
interface GradedStep {
|
|
42
|
-
spanId: string;
|
|
43
|
-
rubricId: string;
|
|
44
|
-
score: number;
|
|
45
|
-
weight: number;
|
|
46
|
-
rationale?: string;
|
|
47
|
-
evidence?: string;
|
|
48
|
-
}
|
|
49
|
-
interface PrmGradedTrace {
|
|
50
|
-
runId: string;
|
|
51
|
-
steps: GradedStep[];
|
|
52
|
-
/** Weighted mean of all graded steps; 0..1. */
|
|
53
|
-
aggregateScore: number;
|
|
54
|
-
/** Number of spans graded — useful for sanity-checking coverage. */
|
|
55
|
-
gradedCount: number;
|
|
56
|
-
/** Number of spans in the trajectory that no rubric matched. */
|
|
57
|
-
ungradedCount: number;
|
|
58
|
-
}
|
|
59
|
-
declare class PrmGrader {
|
|
60
|
-
private rubrics;
|
|
61
|
-
constructor(rubrics: StepRubric[]);
|
|
62
|
-
/**
|
|
63
|
-
* Grade every eligible span in a run. Emits a JudgeVerdict span for each
|
|
64
|
-
* (rubric × span) verdict so the result is visible to downstream pipelines
|
|
65
|
-
* (judgeAgreementView, etc.) — PRM is just "a judge that runs per span."
|
|
66
|
-
*/
|
|
67
|
-
grade(store: TraceStore, runId: string): Promise<PrmGradedTrace>;
|
|
68
|
-
}
|
|
69
|
-
/** Helper: reads JudgeVerdict spans that PRM emitted so downstream pipelines
|
|
70
|
-
* can distinguish PRM verdicts from human or top-level LLM judges. */
|
|
71
|
-
declare function isPrmVerdict(verdict: JudgeSpan): boolean;
|
|
72
|
-
|
|
73
|
-
export { type GradedStep as G, type PrmGradedTrace as P, type StepRubric as S, PrmGrader as a, type StepContext as b, isPrmVerdict as i };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { R as Run, S as Span, a as TraceEvent, A as Artifact, B as BudgetLedgerEntry } from './schema-m0gsnbt3.js';
|
|
2
|
-
import { T as TraceStore } from './store-BcFXE6LG.js';
|
|
3
|
-
|
|
4
|
-
interface RunScore {
|
|
5
|
-
success: number;
|
|
6
|
-
goalProgress: number;
|
|
7
|
-
repoGroundedness: number;
|
|
8
|
-
driftPenalty: number;
|
|
9
|
-
toolUseQuality: number;
|
|
10
|
-
patchQuality: number;
|
|
11
|
-
testReality: number;
|
|
12
|
-
finalGate: number;
|
|
13
|
-
reviewerBlockers: number;
|
|
14
|
-
costUsd: number;
|
|
15
|
-
wallSeconds: number;
|
|
16
|
-
notes?: string[];
|
|
17
|
-
}
|
|
18
|
-
interface RunScoreWeights {
|
|
19
|
-
success: number;
|
|
20
|
-
goalProgress: number;
|
|
21
|
-
repoGroundedness: number;
|
|
22
|
-
driftPenalty: number;
|
|
23
|
-
toolUseQuality: number;
|
|
24
|
-
patchQuality: number;
|
|
25
|
-
testReality: number;
|
|
26
|
-
finalGate: number;
|
|
27
|
-
reviewerBlockers: number;
|
|
28
|
-
costUsd: number;
|
|
29
|
-
wallSeconds: number;
|
|
30
|
-
}
|
|
31
|
-
declare const DEFAULT_RUN_SCORE_WEIGHTS: RunScoreWeights;
|
|
32
|
-
declare function aggregateRunScore(score: RunScore, weights?: Partial<RunScoreWeights>): number;
|
|
33
|
-
declare function clamp01(value: number): number;
|
|
34
|
-
|
|
35
|
-
interface RunTrace {
|
|
36
|
-
run: Run;
|
|
37
|
-
spans: Span[];
|
|
38
|
-
events: TraceEvent[];
|
|
39
|
-
artifacts: Artifact[];
|
|
40
|
-
budget: BudgetLedgerEntry[];
|
|
41
|
-
}
|
|
42
|
-
interface RunCriticOptions {
|
|
43
|
-
weights?: Partial<RunScoreWeights>;
|
|
44
|
-
driftPatterns?: RegExp[];
|
|
45
|
-
}
|
|
46
|
-
declare class RunCritic {
|
|
47
|
-
private readonly weights?;
|
|
48
|
-
private readonly driftPatterns;
|
|
49
|
-
constructor(options?: RunCriticOptions);
|
|
50
|
-
score(store: TraceStore, runId: string): Promise<RunScore>;
|
|
51
|
-
scoreTrace(trace: RunTrace): RunScore;
|
|
52
|
-
rank(score: RunScore): number;
|
|
53
|
-
private isDrift;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { DEFAULT_RUN_SCORE_WEIGHTS as D, type RunScore as R, type RunTrace as a, type RunScoreWeights as b, RunCritic as c, type RunCriticOptions as d, aggregateRunScore as e, clamp01 as f };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fleet telemetry envelope — agent-eval's portable observability shape.
|
|
3
|
-
*
|
|
4
|
-
* Designed so any consumer (Node CLI, Cloudflare Worker, Lambda, browser
|
|
5
|
-
* extension) can emit structured rows describing one unit of work — a page
|
|
6
|
-
* audit, a tool call, an evolve round, a full agent run — to a central sink.
|
|
7
|
-
*
|
|
8
|
-
* The schema is intentionally a strict superset of agent-eval's `Run` shape
|
|
9
|
-
* so a future TraceStore adapter can promote envelopes into traces without
|
|
10
|
-
* translation.
|
|
11
|
-
*/
|
|
12
|
-
declare const TELEMETRY_SCHEMA_VERSION = 1;
|
|
13
|
-
/** Discriminator for the unit of work this envelope describes. */
|
|
14
|
-
type TelemetryKind = 'agent-run' | 'design-audit-page' | 'design-audit-run' | 'design-evolve-round' | 'design-evolve-run' | 'gepa-trial' | 'gepa-generation' | 'tool-call' | 'judge-verdict' | 'custom';
|
|
15
|
-
interface TelemetryEnvelope {
|
|
16
|
-
schemaVersion: typeof TELEMETRY_SCHEMA_VERSION;
|
|
17
|
-
envelopeId: string;
|
|
18
|
-
runId: string;
|
|
19
|
-
timestamp: string;
|
|
20
|
-
parentRunId?: string;
|
|
21
|
-
source: TelemetrySource;
|
|
22
|
-
model?: TelemetryModel;
|
|
23
|
-
kind: TelemetryKind;
|
|
24
|
-
ok: boolean;
|
|
25
|
-
durationMs: number;
|
|
26
|
-
data: Record<string, unknown>;
|
|
27
|
-
metrics: Record<string, number>;
|
|
28
|
-
tags?: Record<string, string>;
|
|
29
|
-
error?: string;
|
|
30
|
-
}
|
|
31
|
-
interface TelemetrySource {
|
|
32
|
-
/** Repo identity — basename of cwd plus git remote if discoverable. */
|
|
33
|
-
repo: string;
|
|
34
|
-
cwd: string;
|
|
35
|
-
gitSha?: string;
|
|
36
|
-
gitBranch?: string;
|
|
37
|
-
cliVersion: string;
|
|
38
|
-
/** What was invoked, e.g. `design-audit`, `bad run`, `gepa --target`. */
|
|
39
|
-
invocation: string;
|
|
40
|
-
/** Sanitised argv minus secrets. */
|
|
41
|
-
argv?: string[];
|
|
42
|
-
/**
|
|
43
|
-
* Multi-tenant identity. Set when the consumer runs inside a hosted
|
|
44
|
-
* product so a fleet rollup can group by tenant without leaking customer
|
|
45
|
-
* URLs or PII.
|
|
46
|
-
*/
|
|
47
|
-
tenantId?: string;
|
|
48
|
-
/** Optional sub-tenant identity (project, suite, walkthrough, customer). */
|
|
49
|
-
customerId?: string;
|
|
50
|
-
/** SHA-256 (12 hex) of the API key used to authenticate this run, when applicable. */
|
|
51
|
-
apiKeyHash?: string;
|
|
52
|
-
}
|
|
53
|
-
interface TelemetryModel {
|
|
54
|
-
provider: string;
|
|
55
|
-
name: string;
|
|
56
|
-
/** SHA-256 (12 hex chars) of the prompt(s) used. */
|
|
57
|
-
promptHash?: string;
|
|
58
|
-
/** SHA-256 (12 hex chars) of the composed rubric body, if applicable. */
|
|
59
|
-
rubricHash?: string;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Workers-safe telemetry sinks — only `fetch` and pure JS. No `fs`, no
|
|
64
|
-
* `child_process`. Safe to import from a Cloudflare Worker, Lambda, edge
|
|
65
|
-
* function, or browser extension.
|
|
66
|
-
*
|
|
67
|
-
* For Node-only file persistence, import from '@tangle-network/agent-eval/telemetry/file'.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
interface TelemetrySink {
|
|
71
|
-
emit(envelope: TelemetryEnvelope): Promise<void> | void;
|
|
72
|
-
close?(): Promise<void> | void;
|
|
73
|
-
}
|
|
74
|
-
/** Best-effort POST to a remote collector. Fire-and-forget; never throws. */
|
|
75
|
-
declare class HttpTelemetrySink implements TelemetrySink {
|
|
76
|
-
private readonly endpoint;
|
|
77
|
-
private readonly bearer?;
|
|
78
|
-
private inflight;
|
|
79
|
-
constructor(endpoint: string, bearer?: string | undefined);
|
|
80
|
-
emit(envelope: TelemetryEnvelope): void;
|
|
81
|
-
close(): Promise<void>;
|
|
82
|
-
}
|
|
83
|
-
/** Fanout to multiple sinks — failures in one do not affect others. */
|
|
84
|
-
declare class FanoutTelemetrySink implements TelemetrySink {
|
|
85
|
-
private readonly sinks;
|
|
86
|
-
constructor(sinks: TelemetrySink[]);
|
|
87
|
-
emit(envelope: TelemetryEnvelope): void;
|
|
88
|
-
close(): Promise<void>;
|
|
89
|
-
}
|
|
90
|
-
/** No-op sink — used when telemetry is explicitly disabled. */
|
|
91
|
-
declare class NullTelemetrySink implements TelemetrySink {
|
|
92
|
-
emit(): void;
|
|
93
|
-
}
|
|
94
|
-
/** In-memory sink — useful for tests + downstream adapters. */
|
|
95
|
-
declare class InMemoryTelemetrySink implements TelemetrySink {
|
|
96
|
-
readonly envelopes: TelemetryEnvelope[];
|
|
97
|
-
emit(envelope: TelemetryEnvelope): void;
|
|
98
|
-
clear(): void;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { FanoutTelemetrySink as F, HttpTelemetrySink as H, InMemoryTelemetrySink as I, NullTelemetrySink as N, type TelemetryKind as T, type TelemetryModel as a, type TelemetrySource as b, type TelemetrySink as c, TELEMETRY_SCHEMA_VERSION as d, type TelemetryEnvelope as e };
|
package/dist/telemetry/file.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { c as TelemetrySink, e as TelemetryEnvelope } from '../sink-fetch-B1Yg4Til.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Node-only file sink. Imports `node:fs` — DO NOT import this from a Worker
|
|
5
|
-
* or edge runtime; use `./sink-fetch` instead.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** Append envelopes to a JSONL file, partitioned by repo + date. */
|
|
9
|
-
declare class FileTelemetrySink implements TelemetrySink {
|
|
10
|
-
private readonly baseDir;
|
|
11
|
-
private streams;
|
|
12
|
-
constructor(baseDir: string);
|
|
13
|
-
emit(envelope: TelemetryEnvelope): void;
|
|
14
|
-
close(): Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
/** Default location for local telemetry, mirroring bad CLI's convention. */
|
|
17
|
-
declare function defaultTelemetryDir(homeDir: string, override?: string): string;
|
|
18
|
-
|
|
19
|
-
export { FileTelemetrySink, defaultTelemetryDir };
|
package/dist/telemetry/file.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import "../chunk-PZ5AY32C.js";
|
|
2
|
-
|
|
3
|
-
// src/telemetry/sink-file.ts
|
|
4
|
-
import * as fs from "fs";
|
|
5
|
-
import * as path from "path";
|
|
6
|
-
var FileTelemetrySink = class {
|
|
7
|
-
constructor(baseDir) {
|
|
8
|
-
this.baseDir = baseDir;
|
|
9
|
-
fs.mkdirSync(baseDir, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
baseDir;
|
|
12
|
-
streams = /* @__PURE__ */ new Map();
|
|
13
|
-
emit(envelope) {
|
|
14
|
-
const date = envelope.timestamp.slice(0, 10);
|
|
15
|
-
const repo = envelope.source.repo || "unknown";
|
|
16
|
-
const key = `${repo}/${date}`;
|
|
17
|
-
let stream = this.streams.get(key);
|
|
18
|
-
if (!stream) {
|
|
19
|
-
const dir = path.join(this.baseDir, repo);
|
|
20
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
21
|
-
stream = fs.createWriteStream(path.join(dir, `${date}.jsonl`), {
|
|
22
|
-
flags: "a",
|
|
23
|
-
encoding: "utf-8"
|
|
24
|
-
});
|
|
25
|
-
this.streams.set(key, stream);
|
|
26
|
-
}
|
|
27
|
-
stream.write(`${JSON.stringify(envelope)}
|
|
28
|
-
`);
|
|
29
|
-
}
|
|
30
|
-
async close() {
|
|
31
|
-
const closes = Array.from(this.streams.values()).map(
|
|
32
|
-
(s) => new Promise((resolve) => s.end(() => resolve()))
|
|
33
|
-
);
|
|
34
|
-
this.streams.clear();
|
|
35
|
-
await Promise.all(closes);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
function defaultTelemetryDir(homeDir, override) {
|
|
39
|
-
return override || path.join(homeDir, ".agent-eval", "telemetry");
|
|
40
|
-
}
|
|
41
|
-
export {
|
|
42
|
-
FileTelemetrySink,
|
|
43
|
-
defaultTelemetryDir
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/sink-file.ts"],"sourcesContent":["/**\n * Node-only file sink. Imports `node:fs` — DO NOT import this from a Worker\n * or edge runtime; use `./sink-fetch` instead.\n */\n\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport type { TelemetryEnvelope } from './schema'\nimport type { TelemetrySink } from './sink-fetch'\n\n/** Append envelopes to a JSONL file, partitioned by repo + date. */\nexport class FileTelemetrySink implements TelemetrySink {\n private streams = new Map<string, fs.WriteStream>()\n\n constructor(private readonly baseDir: string) {\n fs.mkdirSync(baseDir, { recursive: true })\n }\n\n emit(envelope: TelemetryEnvelope): void {\n const date = envelope.timestamp.slice(0, 10) // YYYY-MM-DD\n const repo = envelope.source.repo || 'unknown'\n const key = `${repo}/${date}`\n let stream = this.streams.get(key)\n if (!stream) {\n const dir = path.join(this.baseDir, repo)\n fs.mkdirSync(dir, { recursive: true })\n stream = fs.createWriteStream(path.join(dir, `${date}.jsonl`), {\n flags: 'a',\n encoding: 'utf-8',\n })\n this.streams.set(key, stream)\n }\n stream.write(`${JSON.stringify(envelope)}\\n`)\n }\n\n async close(): Promise<void> {\n const closes = Array.from(this.streams.values()).map(\n (s) => new Promise<void>((resolve) => s.end(() => resolve())),\n )\n this.streams.clear()\n await Promise.all(closes)\n }\n}\n\n/** Default location for local telemetry, mirroring bad CLI's convention. */\nexport function defaultTelemetryDir(homeDir: string, override?: string): string {\n return override || path.join(homeDir, '.agent-eval', 'telemetry')\n}\n"],"mappings":";;;AAKA,YAAY,QAAQ;AACpB,YAAY,UAAU;AAKf,IAAM,oBAAN,MAAiD;AAAA,EAGtD,YAA6B,SAAiB;AAAjB;AAC3B,IAAG,aAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EAC3C;AAAA,EAF6B;AAAA,EAFrB,UAAU,oBAAI,IAA4B;AAAA,EAMlD,KAAK,UAAmC;AACtC,UAAM,OAAO,SAAS,UAAU,MAAM,GAAG,EAAE;AAC3C,UAAM,OAAO,SAAS,OAAO,QAAQ;AACrC,UAAM,MAAM,GAAG,IAAI,IAAI,IAAI;AAC3B,QAAI,SAAS,KAAK,QAAQ,IAAI,GAAG;AACjC,QAAI,CAAC,QAAQ;AACX,YAAM,MAAW,UAAK,KAAK,SAAS,IAAI;AACxC,MAAG,aAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AACrC,eAAY,qBAAuB,UAAK,KAAK,GAAG,IAAI,QAAQ,GAAG;AAAA,QAC7D,OAAO;AAAA,QACP,UAAU;AAAA,MACZ,CAAC;AACD,WAAK,QAAQ,IAAI,KAAK,MAAM;AAAA,IAC9B;AACA,WAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,CAAC;AAAA,CAAI;AAAA,EAC9C;AAAA,EAEA,MAAM,QAAuB;AAC3B,UAAM,SAAS,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC,EAAE;AAAA,MAC/C,CAAC,MAAM,IAAI,QAAc,CAAC,YAAY,EAAE,IAAI,MAAM,QAAQ,CAAC,CAAC;AAAA,IAC9D;AACA,SAAK,QAAQ,MAAM;AACnB,UAAM,QAAQ,IAAI,MAAM;AAAA,EAC1B;AACF;AAGO,SAAS,oBAAoB,SAAiB,UAA2B;AAC9E,SAAO,YAAiB,UAAK,SAAS,eAAe,WAAW;AAClE;","names":[]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { T as TelemetryKind, a as TelemetryModel, b as TelemetrySource, c as TelemetrySink } from '../sink-fetch-B1Yg4Til.js';
|
|
2
|
-
export { F as FanoutTelemetrySink, H as HttpTelemetrySink, I as InMemoryTelemetrySink, N as NullTelemetrySink, d as TELEMETRY_SCHEMA_VERSION, e as TelemetryEnvelope } from '../sink-fetch-B1Yg4Til.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Telemetry client — thin wrapper that builds envelopes from `EmitArgs` and
|
|
6
|
-
* delegates to a `TelemetrySink`. Pure logic; no I/O. Use this from any
|
|
7
|
-
* runtime — Workers, Node, browser — and choose the sink accordingly.
|
|
8
|
-
*
|
|
9
|
-
* For an opinionated singleton with env-var-driven sink wiring (the bad CLI
|
|
10
|
-
* pattern), see `./node-client.ts`.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
interface EmitArgs {
|
|
14
|
-
kind: TelemetryKind;
|
|
15
|
-
runId: string;
|
|
16
|
-
parentRunId?: string;
|
|
17
|
-
ok: boolean;
|
|
18
|
-
durationMs: number;
|
|
19
|
-
data?: Record<string, unknown>;
|
|
20
|
-
metrics?: Record<string, number>;
|
|
21
|
-
tags?: Record<string, string>;
|
|
22
|
-
model?: TelemetryModel;
|
|
23
|
-
error?: string;
|
|
24
|
-
/** Override the source for this envelope. Falls back to `defaultSource`. */
|
|
25
|
-
source?: TelemetrySource;
|
|
26
|
-
}
|
|
27
|
-
declare class TelemetryClient {
|
|
28
|
-
private readonly sink;
|
|
29
|
-
private readonly defaultSource;
|
|
30
|
-
constructor(sink: TelemetrySink, defaultSource: TelemetrySource);
|
|
31
|
-
emit(args: EmitArgs): void;
|
|
32
|
-
close(): Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
declare const SECRET_FLAGS: Set<string>;
|
|
35
|
-
/** Strip likely-secret values from argv, preserving structure. */
|
|
36
|
-
declare function sanitiseArgv(argv: string[]): string[];
|
|
37
|
-
|
|
38
|
-
export { type EmitArgs, SECRET_FLAGS, TelemetryClient, TelemetryKind, TelemetryModel, TelemetrySink, TelemetrySource, sanitiseArgv };
|
package/dist/telemetry/index.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import "../chunk-PZ5AY32C.js";
|
|
2
|
-
|
|
3
|
-
// src/telemetry/schema.ts
|
|
4
|
-
var TELEMETRY_SCHEMA_VERSION = 1;
|
|
5
|
-
|
|
6
|
-
// src/telemetry/client.ts
|
|
7
|
-
var TelemetryClient = class {
|
|
8
|
-
constructor(sink, defaultSource) {
|
|
9
|
-
this.sink = sink;
|
|
10
|
-
this.defaultSource = defaultSource;
|
|
11
|
-
}
|
|
12
|
-
sink;
|
|
13
|
-
defaultSource;
|
|
14
|
-
emit(args) {
|
|
15
|
-
const envelope = {
|
|
16
|
-
schemaVersion: TELEMETRY_SCHEMA_VERSION,
|
|
17
|
-
envelopeId: makeEnvelopeId(),
|
|
18
|
-
runId: args.runId,
|
|
19
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20
|
-
source: args.source ?? this.defaultSource,
|
|
21
|
-
kind: args.kind,
|
|
22
|
-
ok: args.ok,
|
|
23
|
-
durationMs: args.durationMs,
|
|
24
|
-
data: args.data ?? {},
|
|
25
|
-
metrics: args.metrics ?? {},
|
|
26
|
-
...args.parentRunId ? { parentRunId: args.parentRunId } : {},
|
|
27
|
-
...args.model ? { model: args.model } : {},
|
|
28
|
-
...args.tags ? { tags: args.tags } : {},
|
|
29
|
-
...args.error ? { error: args.error } : {}
|
|
30
|
-
};
|
|
31
|
-
try {
|
|
32
|
-
this.sink.emit(envelope);
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async close() {
|
|
37
|
-
await this.sink.close?.();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
function makeEnvelopeId() {
|
|
41
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
42
|
-
return crypto.randomUUID();
|
|
43
|
-
}
|
|
44
|
-
return `env-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
45
|
-
}
|
|
46
|
-
var SECRET_FLAGS = /* @__PURE__ */ new Set(["--api-key", "--bearer", "--token", "--password"]);
|
|
47
|
-
function sanitiseArgv(argv) {
|
|
48
|
-
const out = [];
|
|
49
|
-
for (let i = 0; i < argv.length; i++) {
|
|
50
|
-
const a = argv[i];
|
|
51
|
-
if (SECRET_FLAGS.has(a)) {
|
|
52
|
-
out.push(a, "<redacted>");
|
|
53
|
-
i++;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (/^(?:--api-key|--bearer|--token|--password)=/.test(a)) {
|
|
57
|
-
out.push(a.replace(/=.*$/, "=<redacted>"));
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
out.push(a);
|
|
61
|
-
}
|
|
62
|
-
return out;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/telemetry/sink-fetch.ts
|
|
66
|
-
var HttpTelemetrySink = class {
|
|
67
|
-
constructor(endpoint, bearer) {
|
|
68
|
-
this.endpoint = endpoint;
|
|
69
|
-
this.bearer = bearer;
|
|
70
|
-
}
|
|
71
|
-
endpoint;
|
|
72
|
-
bearer;
|
|
73
|
-
inflight = /* @__PURE__ */ new Set();
|
|
74
|
-
emit(envelope) {
|
|
75
|
-
const body = JSON.stringify(envelope);
|
|
76
|
-
const headers = { "content-type": "application/json" };
|
|
77
|
-
if (this.bearer) headers.authorization = `Bearer ${this.bearer}`;
|
|
78
|
-
const promise = fetch(this.endpoint, { method: "POST", headers, body }).then(() => void 0).catch(() => void 0);
|
|
79
|
-
this.inflight.add(promise);
|
|
80
|
-
promise.finally(() => this.inflight.delete(promise));
|
|
81
|
-
}
|
|
82
|
-
async close() {
|
|
83
|
-
await Promise.allSettled(Array.from(this.inflight));
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var FanoutTelemetrySink = class {
|
|
87
|
-
constructor(sinks) {
|
|
88
|
-
this.sinks = sinks;
|
|
89
|
-
}
|
|
90
|
-
sinks;
|
|
91
|
-
emit(envelope) {
|
|
92
|
-
for (const sink of this.sinks) {
|
|
93
|
-
try {
|
|
94
|
-
const result = sink.emit(envelope);
|
|
95
|
-
if (result && typeof result.catch === "function") {
|
|
96
|
-
;
|
|
97
|
-
result.catch(() => void 0);
|
|
98
|
-
}
|
|
99
|
-
} catch {
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async close() {
|
|
104
|
-
await Promise.allSettled(this.sinks.map((s) => Promise.resolve(s.close?.())));
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
var NullTelemetrySink = class {
|
|
108
|
-
emit() {
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
var InMemoryTelemetrySink = class {
|
|
112
|
-
envelopes = [];
|
|
113
|
-
emit(envelope) {
|
|
114
|
-
this.envelopes.push(envelope);
|
|
115
|
-
}
|
|
116
|
-
clear() {
|
|
117
|
-
this.envelopes.length = 0;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
export {
|
|
121
|
-
FanoutTelemetrySink,
|
|
122
|
-
HttpTelemetrySink,
|
|
123
|
-
InMemoryTelemetrySink,
|
|
124
|
-
NullTelemetrySink,
|
|
125
|
-
SECRET_FLAGS,
|
|
126
|
-
TELEMETRY_SCHEMA_VERSION,
|
|
127
|
-
TelemetryClient,
|
|
128
|
-
sanitiseArgv
|
|
129
|
-
};
|
|
130
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/telemetry/schema.ts","../../src/telemetry/client.ts","../../src/telemetry/sink-fetch.ts"],"sourcesContent":["/**\n * Fleet telemetry envelope — agent-eval's portable observability shape.\n *\n * Designed so any consumer (Node CLI, Cloudflare Worker, Lambda, browser\n * extension) can emit structured rows describing one unit of work — a page\n * audit, a tool call, an evolve round, a full agent run — to a central sink.\n *\n * The schema is intentionally a strict superset of agent-eval's `Run` shape\n * so a future TraceStore adapter can promote envelopes into traces without\n * translation.\n */\n\nexport const TELEMETRY_SCHEMA_VERSION = 1\n\n/** Discriminator for the unit of work this envelope describes. */\nexport type TelemetryKind =\n | 'agent-run'\n | 'design-audit-page'\n | 'design-audit-run'\n | 'design-evolve-round'\n | 'design-evolve-run'\n | 'gepa-trial'\n | 'gepa-generation'\n | 'tool-call'\n | 'judge-verdict'\n | 'custom'\n\nexport interface TelemetryEnvelope {\n schemaVersion: typeof TELEMETRY_SCHEMA_VERSION\n envelopeId: string\n runId: string\n timestamp: string\n parentRunId?: string\n\n source: TelemetrySource\n model?: TelemetryModel\n kind: TelemetryKind\n ok: boolean\n durationMs: number\n\n data: Record<string, unknown>\n metrics: Record<string, number>\n tags?: Record<string, string>\n\n error?: string\n}\n\nexport interface TelemetrySource {\n /** Repo identity — basename of cwd plus git remote if discoverable. */\n repo: string\n cwd: string\n gitSha?: string\n gitBranch?: string\n cliVersion: string\n /** What was invoked, e.g. `design-audit`, `bad run`, `gepa --target`. */\n invocation: string\n /** Sanitised argv minus secrets. */\n argv?: string[]\n /**\n * Multi-tenant identity. Set when the consumer runs inside a hosted\n * product so a fleet rollup can group by tenant without leaking customer\n * URLs or PII.\n */\n tenantId?: string\n /** Optional sub-tenant identity (project, suite, walkthrough, customer). */\n customerId?: string\n /** SHA-256 (12 hex) of the API key used to authenticate this run, when applicable. */\n apiKeyHash?: string\n}\n\nexport interface TelemetryModel {\n provider: string\n name: string\n /** SHA-256 (12 hex chars) of the prompt(s) used. */\n promptHash?: string\n /** SHA-256 (12 hex chars) of the composed rubric body, if applicable. */\n rubricHash?: string\n}\n","/**\n * Telemetry client — thin wrapper that builds envelopes from `EmitArgs` and\n * delegates to a `TelemetrySink`. Pure logic; no I/O. Use this from any\n * runtime — Workers, Node, browser — and choose the sink accordingly.\n *\n * For an opinionated singleton with env-var-driven sink wiring (the bad CLI\n * pattern), see `./node-client.ts`.\n */\n\nimport type { TelemetryEnvelope, TelemetryKind, TelemetryModel, TelemetrySource } from './schema'\nimport { TELEMETRY_SCHEMA_VERSION } from './schema'\nimport type { TelemetrySink } from './sink-fetch'\n\nexport interface EmitArgs {\n kind: TelemetryKind\n runId: string\n parentRunId?: string\n ok: boolean\n durationMs: number\n data?: Record<string, unknown>\n metrics?: Record<string, number>\n tags?: Record<string, string>\n model?: TelemetryModel\n error?: string\n /** Override the source for this envelope. Falls back to `defaultSource`. */\n source?: TelemetrySource\n}\n\nexport class TelemetryClient {\n constructor(\n private readonly sink: TelemetrySink,\n private readonly defaultSource: TelemetrySource,\n ) {}\n\n emit(args: EmitArgs): void {\n const envelope: TelemetryEnvelope = {\n schemaVersion: TELEMETRY_SCHEMA_VERSION,\n envelopeId: makeEnvelopeId(),\n runId: args.runId,\n timestamp: new Date().toISOString(),\n source: args.source ?? this.defaultSource,\n kind: args.kind,\n ok: args.ok,\n durationMs: args.durationMs,\n data: args.data ?? {},\n metrics: args.metrics ?? {},\n ...(args.parentRunId ? { parentRunId: args.parentRunId } : {}),\n ...(args.model ? { model: args.model } : {}),\n ...(args.tags ? { tags: args.tags } : {}),\n ...(args.error ? { error: args.error } : {}),\n }\n try {\n this.sink.emit(envelope)\n } catch {\n // swallow — telemetry never breaks the calling code path\n }\n }\n\n async close(): Promise<void> {\n await this.sink.close?.()\n }\n}\n\n/** Generate a UUIDv4 with whatever crypto is available (Node, Workers, browsers). */\nfunction makeEnvelopeId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID()\n }\n // Last-resort fallback. Lower entropy but never throws.\n return `env-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`\n}\n\nexport const SECRET_FLAGS = new Set(['--api-key', '--bearer', '--token', '--password'])\n\n/** Strip likely-secret values from argv, preserving structure. */\nexport function sanitiseArgv(argv: string[]): string[] {\n const out: string[] = []\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i]!\n if (SECRET_FLAGS.has(a)) {\n out.push(a, '<redacted>')\n i++\n continue\n }\n if (/^(?:--api-key|--bearer|--token|--password)=/.test(a)) {\n out.push(a.replace(/=.*$/, '=<redacted>'))\n continue\n }\n out.push(a)\n }\n return out\n}\n","/**\n * Workers-safe telemetry sinks — only `fetch` and pure JS. No `fs`, no\n * `child_process`. Safe to import from a Cloudflare Worker, Lambda, edge\n * function, or browser extension.\n *\n * For Node-only file persistence, import from '@tangle-network/agent-eval/telemetry/file'.\n */\n\nimport type { TelemetryEnvelope } from './schema'\n\nexport interface TelemetrySink {\n emit(envelope: TelemetryEnvelope): Promise<void> | void\n close?(): Promise<void> | void\n}\n\n/** Best-effort POST to a remote collector. Fire-and-forget; never throws. */\nexport class HttpTelemetrySink implements TelemetrySink {\n private inflight = new Set<Promise<void>>()\n\n constructor(\n private readonly endpoint: string,\n private readonly bearer?: string,\n ) {}\n\n emit(envelope: TelemetryEnvelope): void {\n const body = JSON.stringify(envelope)\n const headers: Record<string, string> = { 'content-type': 'application/json' }\n if (this.bearer) headers.authorization = `Bearer ${this.bearer}`\n const promise = fetch(this.endpoint, { method: 'POST', headers, body })\n .then(() => undefined)\n .catch(() => undefined)\n this.inflight.add(promise)\n promise.finally(() => this.inflight.delete(promise))\n }\n\n async close(): Promise<void> {\n await Promise.allSettled(Array.from(this.inflight))\n }\n}\n\n/** Fanout to multiple sinks — failures in one do not affect others. */\nexport class FanoutTelemetrySink implements TelemetrySink {\n constructor(private readonly sinks: TelemetrySink[]) {}\n\n emit(envelope: TelemetryEnvelope): void {\n for (const sink of this.sinks) {\n try {\n const result = sink.emit(envelope)\n if (result && typeof (result as Promise<unknown>).catch === 'function') {\n ;(result as Promise<unknown>).catch(() => undefined)\n }\n } catch {\n // swallow — telemetry must never break a run\n }\n }\n }\n\n async close(): Promise<void> {\n await Promise.allSettled(this.sinks.map((s) => Promise.resolve(s.close?.())))\n }\n}\n\n/** No-op sink — used when telemetry is explicitly disabled. */\nexport class NullTelemetrySink implements TelemetrySink {\n emit(): void {}\n}\n\n/** In-memory sink — useful for tests + downstream adapters. */\nexport class InMemoryTelemetrySink implements TelemetrySink {\n readonly envelopes: TelemetryEnvelope[] = []\n emit(envelope: TelemetryEnvelope): void {\n this.envelopes.push(envelope)\n }\n clear(): void {\n this.envelopes.length = 0\n }\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LockedJsonlAppender — mutex-serialized JSONL append helper for arbitrary
|
|
3
|
-
* payloads. The reference-replay store does the same thing for typed
|
|
4
|
-
* `ReferenceReplayRun` rows; this is the generic version used by
|
|
5
|
-
* `MutationTelemetry`, `TrialTelemetry`, and any other consumer that wants
|
|
6
|
-
* append-only durable telemetry without rolling its own lock.
|
|
7
|
-
*
|
|
8
|
-
* Locks are per absolute file path (process-local). Cross-process
|
|
9
|
-
* concurrency is NOT addressed — that's an fcntl/flock problem.
|
|
10
|
-
*/
|
|
11
|
-
declare class LockedJsonlAppender {
|
|
12
|
-
readonly path: string;
|
|
13
|
-
private readonly mutex;
|
|
14
|
-
constructor(path: string);
|
|
15
|
-
append(entry: unknown): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/** Reset all internal mutex state — tests only. */
|
|
18
|
-
declare function resetLockedAppendersForTesting(): void;
|
|
19
|
-
|
|
20
|
-
export { LockedJsonlAppender as L, resetLockedAppendersForTesting as r };
|
package/dist/testing.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { r as resetLockedAppendersForTesting } from './testing-C21CHsq2.js';
|