@tangle-network/agent-eval 0.123.0 → 0.123.2
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 +9 -0
- package/README.md +151 -161
- package/dist/analyst/index.d.ts +9 -1
- package/dist/analyst/index.js +5 -5
- package/dist/authenticity/index.js +3 -2
- package/dist/authenticity/index.js.map +1 -1
- package/dist/belief-state/index.d.ts +45 -5
- package/dist/belief-state/index.js +41 -3
- package/dist/belief-state/index.js.map +1 -1
- package/dist/benchmarks/index.d.ts +2 -1
- package/dist/benchmarks/index.js +6 -6
- package/dist/campaign/index.d.ts +29 -33
- package/dist/campaign/index.js +6 -6
- package/dist/{chunk-A5S77LSE.js → chunk-4SOQ4ND2.js} +2 -2
- package/dist/{chunk-VJ7T5WIO.js → chunk-5YMKIFYP.js} +3 -3
- package/dist/{chunk-U5CHZ5M3.js → chunk-DNVPOYUS.js} +4 -4
- package/dist/{chunk-6WX7CBAR.js → chunk-E3HAD4A3.js} +19 -8
- package/dist/chunk-E3HAD4A3.js.map +1 -0
- package/dist/{chunk-LBAHQOBI.js → chunk-EBDOTTZJ.js} +37 -11
- package/dist/chunk-EBDOTTZJ.js.map +1 -0
- package/dist/{chunk-XJYR7XFV.js → chunk-GC4ATIKK.js} +1 -1
- package/dist/chunk-GC4ATIKK.js.map +1 -0
- package/dist/{chunk-HZJF4IUO.js → chunk-HQY7LBV2.js} +3 -3
- package/dist/{chunk-NJC7U437.js → chunk-J7S4YM27.js} +6 -5
- package/dist/chunk-J7S4YM27.js.map +1 -0
- package/dist/{chunk-S3UZOQ5Y.js → chunk-LOW3U7JZ.js} +2 -2
- package/dist/{chunk-OYZAPX5G.js → chunk-R226UZOI.js} +2 -2
- package/dist/{chunk-GS3FJGUF.js → chunk-RQP5UTK5.js} +120 -14
- package/dist/chunk-RQP5UTK5.js.map +1 -0
- package/dist/{chunk-DTJ6QUQB.js → chunk-VGRCHJON.js} +39 -7
- package/dist/chunk-VGRCHJON.js.map +1 -0
- package/dist/{chunk-G2GPNLSX.js → chunk-WMJR67FX.js} +3 -3
- package/dist/{chunk-FC5NDO3E.js → chunk-WXQTVEKM.js} +3 -3
- package/dist/cli.js +100 -10
- package/dist/cli.js.map +1 -1
- package/dist/contract/index.d.ts +97 -5
- package/dist/contract/index.js +9 -7
- package/dist/contract/index.js.map +1 -1
- package/dist/control.js +3 -3
- package/dist/fuzz.js +3 -2
- package/dist/fuzz.js.map +1 -1
- package/dist/hosted/index.d.ts +8 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/openapi.json +1 -1
- package/dist/rl.d.ts +48 -12
- package/dist/rl.js +5 -5
- package/dist/storyboard/index.js +1 -1
- package/dist/storyboard/index.js.map +1 -1
- package/dist/traces.js +3 -3
- package/dist/wire/index.d.ts +61 -4
- package/dist/wire/index.js +2 -2
- package/docs/adapters-observability.md +6 -6
- package/docs/building-doctrine.md +5 -5
- package/docs/concepts.md +29 -29
- package/docs/customer-journeys.md +80 -155
- package/docs/design/loop-taxonomy.md +26 -27
- package/docs/design.md +70 -0
- package/docs/distributed-driver.md +14 -14
- package/docs/eval-surface-map.md +11 -11
- package/docs/hosted-ingest-spec.md +4 -4
- package/docs/improvement-glossary.md +38 -38
- package/docs/insight-report.md +32 -27
- package/docs/multi-shot-optimization.md +8 -8
- package/docs/research-report-methodology.md +9 -9
- package/docs/self-improvement-map.md +13 -13
- package/docs/trace-analysis.md +2 -2
- package/docs/wire-protocol.md +16 -16
- package/package.json +2 -1
- package/dist/chunk-6WX7CBAR.js.map +0 -1
- package/dist/chunk-DTJ6QUQB.js.map +0 -1
- package/dist/chunk-GS3FJGUF.js.map +0 -1
- package/dist/chunk-LBAHQOBI.js.map +0 -1
- package/dist/chunk-NJC7U437.js.map +0 -1
- package/dist/chunk-XJYR7XFV.js.map +0 -1
- package/docs/auto-research-loop-end-to-end.md +0 -186
- /package/dist/{chunk-A5S77LSE.js.map → chunk-4SOQ4ND2.js.map} +0 -0
- /package/dist/{chunk-VJ7T5WIO.js.map → chunk-5YMKIFYP.js.map} +0 -0
- /package/dist/{chunk-U5CHZ5M3.js.map → chunk-DNVPOYUS.js.map} +0 -0
- /package/dist/{chunk-HZJF4IUO.js.map → chunk-HQY7LBV2.js.map} +0 -0
- /package/dist/{chunk-S3UZOQ5Y.js.map → chunk-LOW3U7JZ.js.map} +0 -0
- /package/dist/{chunk-OYZAPX5G.js.map → chunk-R226UZOI.js.map} +0 -0
- /package/dist/{chunk-G2GPNLSX.js.map → chunk-WMJR67FX.js.map} +0 -0
- /package/dist/{chunk-FC5NDO3E.js.map → chunk-WXQTVEKM.js.map} +0 -0
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
runImprovementLoop,
|
|
16
16
|
surfaceContentHash,
|
|
17
17
|
surfaceHash
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HQY7LBV2.js";
|
|
19
19
|
import {
|
|
20
20
|
SearchLedgerConflictError,
|
|
21
21
|
SearchLedgerError,
|
|
@@ -51,14 +51,14 @@ import {
|
|
|
51
51
|
mapConcurrent,
|
|
52
52
|
policyEditsFromFindings,
|
|
53
53
|
validatePolicyEditCandidateRecord
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-WXQTVEKM.js";
|
|
55
55
|
import {
|
|
56
56
|
callLlm,
|
|
57
57
|
callLlmJson,
|
|
58
58
|
costReceiptFromLlm,
|
|
59
59
|
costReceiptFromLlmError,
|
|
60
60
|
maximumChargeForLlmRequest
|
|
61
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-J7S4YM27.js";
|
|
62
62
|
import {
|
|
63
63
|
eProcess,
|
|
64
64
|
mcnemar,
|
|
@@ -80,10 +80,10 @@ import {
|
|
|
80
80
|
import {
|
|
81
81
|
modelHasSnapshot,
|
|
82
82
|
validateRunRecord
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-LOW3U7JZ.js";
|
|
84
84
|
import {
|
|
85
85
|
buildAgentProfileCell
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-GC4ATIKK.js";
|
|
87
87
|
import {
|
|
88
88
|
canonicalize
|
|
89
89
|
} from "./chunk-VSMTAMNK.js";
|
|
@@ -4960,9 +4960,24 @@ function compositeProposer(opts) {
|
|
|
4960
4960
|
const members = opts.proposers;
|
|
4961
4961
|
if (members.length === 0)
|
|
4962
4962
|
throw new Error("compositeProposer: at least one member proposer required");
|
|
4963
|
+
const memberKinds = /* @__PURE__ */ new Set();
|
|
4964
|
+
for (const member of members) {
|
|
4965
|
+
if (!member.kind || member.kind.trim() !== member.kind) {
|
|
4966
|
+
throw new Error("compositeProposer: member kinds must be trimmed and non-empty");
|
|
4967
|
+
}
|
|
4968
|
+
if (member.kind.includes(":")) {
|
|
4969
|
+
throw new Error(`compositeProposer: member kind '${member.kind}' must not contain ':'`);
|
|
4970
|
+
}
|
|
4971
|
+
if (memberKinds.has(member.kind)) {
|
|
4972
|
+
throw new Error(`compositeProposer: duplicate member kind '${member.kind}'`);
|
|
4973
|
+
}
|
|
4974
|
+
memberKinds.add(member.kind);
|
|
4975
|
+
}
|
|
4963
4976
|
const weights = opts.weights ?? members.map(() => 1);
|
|
4964
|
-
if (weights.length !== members.length || weights.some((
|
|
4965
|
-
throw new Error(
|
|
4977
|
+
if (weights.length !== members.length || weights.some((weight) => !Number.isFinite(weight) || weight <= 0)) {
|
|
4978
|
+
throw new Error(
|
|
4979
|
+
"compositeProposer: weights must match proposers length and be finite and positive"
|
|
4980
|
+
);
|
|
4966
4981
|
}
|
|
4967
4982
|
return {
|
|
4968
4983
|
kind: `composite(${members.map((m) => m.kind).join("+")})`,
|
|
@@ -4985,7 +5000,11 @@ function compositeProposer(opts) {
|
|
|
4985
5000
|
const share = shares[i] ?? 0;
|
|
4986
5001
|
if (!member || share === 0 || ctx.signal.aborted) continue;
|
|
4987
5002
|
try {
|
|
4988
|
-
const proposals = await member.propose({
|
|
5003
|
+
const proposals = await member.propose({
|
|
5004
|
+
...ctx,
|
|
5005
|
+
history: historyForMember(ctx.history, member.kind),
|
|
5006
|
+
populationSize: share
|
|
5007
|
+
});
|
|
4989
5008
|
for (const proposal of proposals) {
|
|
4990
5009
|
const isCandidate = typeof proposal === "object" && proposal !== null && "surface" in proposal;
|
|
4991
5010
|
const surface = isCandidate ? proposal.surface : proposal;
|
|
@@ -5019,7 +5038,11 @@ function compositeProposer(opts) {
|
|
|
5019
5038
|
return pool.slice(0, ctx.populationSize);
|
|
5020
5039
|
},
|
|
5021
5040
|
decide(args) {
|
|
5022
|
-
const votes = members.filter((m) => typeof m.decide === "function").map(
|
|
5041
|
+
const votes = members.filter((m) => typeof m.decide === "function").map(
|
|
5042
|
+
(m) => m.decide({
|
|
5043
|
+
history: historyForMember(args.history, m.kind)
|
|
5044
|
+
})
|
|
5045
|
+
);
|
|
5023
5046
|
if (votes.length === 0) return { stop: false };
|
|
5024
5047
|
const allStop = votes.every((v) => v.stop);
|
|
5025
5048
|
return allStop ? {
|
|
@@ -5029,6 +5052,15 @@ function compositeProposer(opts) {
|
|
|
5029
5052
|
}
|
|
5030
5053
|
};
|
|
5031
5054
|
}
|
|
5055
|
+
function historyForMember(history, memberKind) {
|
|
5056
|
+
const prefix = `${memberKind}:`;
|
|
5057
|
+
return history.map((generation) => ({
|
|
5058
|
+
...generation,
|
|
5059
|
+
candidates: generation.candidates.map(
|
|
5060
|
+
(candidate) => candidate.label?.startsWith(prefix) ? { ...candidate, label: candidate.label.slice(prefix.length) } : candidate
|
|
5061
|
+
)
|
|
5062
|
+
}));
|
|
5063
|
+
}
|
|
5032
5064
|
|
|
5033
5065
|
// src/campaign/proposers/halo.ts
|
|
5034
5066
|
import { execFile } from "child_process";
|
|
@@ -5327,6 +5359,7 @@ var JSON_POLICY_EDIT_TARGET_SURFACES = [
|
|
|
5327
5359
|
"agent-profile"
|
|
5328
5360
|
];
|
|
5329
5361
|
var NonEmptyStringSchema = z.string().trim().min(1);
|
|
5362
|
+
var JsonObjectKeySchema = z.string().min(1).refine((key) => key.trim() === key, "JSON object keys must not have surrounding whitespace");
|
|
5330
5363
|
var JsonValueSchema = z.lazy(
|
|
5331
5364
|
() => z.union([
|
|
5332
5365
|
z.string(),
|
|
@@ -5334,7 +5367,7 @@ var JsonValueSchema = z.lazy(
|
|
|
5334
5367
|
z.boolean(),
|
|
5335
5368
|
z.null(),
|
|
5336
5369
|
z.array(JsonValueSchema),
|
|
5337
|
-
z.record(
|
|
5370
|
+
z.record(JsonObjectKeySchema, JsonValueSchema)
|
|
5338
5371
|
])
|
|
5339
5372
|
);
|
|
5340
5373
|
var AuthoredJsonChangeSchema = z.discriminatedUnion("mode", [
|
|
@@ -5539,6 +5572,13 @@ var POLICY_EDIT_AUTHOR_SYSTEM = [
|
|
|
5539
5572
|
"Treat expectedGain and confidence as forecasts, never as measured evidence. Learn from baselineOutcome, incumbentOutcome, and observedDeltaFromParent.",
|
|
5540
5573
|
"Do not invent a finding, path, field, score, or task fact. Do not include schemaVersion, editId, metadata, prose, or undeclared keys."
|
|
5541
5574
|
].join("\n");
|
|
5575
|
+
function policyEditAuthorSystem(responseSchema) {
|
|
5576
|
+
return [
|
|
5577
|
+
POLICY_EDIT_AUTHOR_SYSTEM,
|
|
5578
|
+
"The exact required response JSON Schema follows. Obey it even when the provider does not enforce response_format:",
|
|
5579
|
+
JSON.stringify(responseSchema)
|
|
5580
|
+
].join("\n");
|
|
5581
|
+
}
|
|
5542
5582
|
function llmPolicyEditProposer(opts) {
|
|
5543
5583
|
const allowedJsonPaths = validateAllowedJsonPaths(opts.allowedJsonPaths);
|
|
5544
5584
|
const allowedPathSet = new Set(allowedJsonPaths);
|
|
@@ -5593,6 +5633,12 @@ function llmPolicyEditProposer(opts) {
|
|
|
5593
5633
|
{ currentSurface, allowedJsonPaths, objectives, targetSurface: opts.targetSurface },
|
|
5594
5634
|
scenarioIds
|
|
5595
5635
|
);
|
|
5636
|
+
const modelSurface = redactCurrentSurfaceForModel(
|
|
5637
|
+
currentSurface,
|
|
5638
|
+
allowedJsonPaths,
|
|
5639
|
+
opts.redactCurrentSurfaceForModel
|
|
5640
|
+
);
|
|
5641
|
+
assertSurfaceIsTaskAgnostic(modelSurface, scenarioIds);
|
|
5596
5642
|
const measuredSources = measuredSourceMeasurements(ctx);
|
|
5597
5643
|
const findings = citableFindings(ctx.findings, measuredSources, maxFindings);
|
|
5598
5644
|
const findingByKey = new Map(
|
|
@@ -5605,7 +5651,7 @@ function llmPolicyEditProposer(opts) {
|
|
|
5605
5651
|
objectives,
|
|
5606
5652
|
candidateCount: limit,
|
|
5607
5653
|
generation: ctx.generation,
|
|
5608
|
-
currentSurface,
|
|
5654
|
+
currentSurface: modelSurface,
|
|
5609
5655
|
findings: findings.map(
|
|
5610
5656
|
(finding, index) => renderFinding(finding, `finding-${index + 1}`, scenarioIds, measuredSources)
|
|
5611
5657
|
),
|
|
@@ -5633,15 +5679,16 @@ function llmPolicyEditProposer(opts) {
|
|
|
5633
5679
|
allowedJsonPaths,
|
|
5634
5680
|
objectives
|
|
5635
5681
|
);
|
|
5682
|
+
const system = policyEditAuthorSystem(responseSchema);
|
|
5636
5683
|
assertPolicyEditAuthorContextBudget(
|
|
5637
|
-
{ system
|
|
5684
|
+
{ system, authorContext, responseSchema },
|
|
5638
5685
|
maxAuthorContextChars
|
|
5639
5686
|
);
|
|
5640
5687
|
const userContent = JSON.stringify(authorContext);
|
|
5641
5688
|
const request = {
|
|
5642
5689
|
model: opts.model,
|
|
5643
5690
|
messages: [
|
|
5644
|
-
{ role: "system", content:
|
|
5691
|
+
{ role: "system", content: system },
|
|
5645
5692
|
{ role: "user", content: userContent }
|
|
5646
5693
|
],
|
|
5647
5694
|
jsonSchema: {
|
|
@@ -6209,6 +6256,65 @@ function parseJsonSurface(surface) {
|
|
|
6209
6256
|
}
|
|
6210
6257
|
return parsed;
|
|
6211
6258
|
}
|
|
6259
|
+
function redactCurrentSurfaceForModel(surface, allowedJsonPaths, redact) {
|
|
6260
|
+
if (!redact) return surface;
|
|
6261
|
+
const redacted = redact(structuredClone(surface));
|
|
6262
|
+
const parsed = JsonValueSchema.safeParse(redacted);
|
|
6263
|
+
if (!parsed.success) {
|
|
6264
|
+
const detail = formatJsonValidationError(parsed.error);
|
|
6265
|
+
throw new Error(
|
|
6266
|
+
`llmPolicyEditProposer: redactCurrentSurfaceForModel returned invalid JSON (${detail})`
|
|
6267
|
+
);
|
|
6268
|
+
}
|
|
6269
|
+
if (!parsed.data || typeof parsed.data !== "object" || Array.isArray(parsed.data)) {
|
|
6270
|
+
throw new Error("llmPolicyEditProposer: redactCurrentSurfaceForModel must return a JSON object");
|
|
6271
|
+
}
|
|
6272
|
+
for (const path of allowedJsonPaths) {
|
|
6273
|
+
if (!jsonValuesEqual(readJsonPath(surface, path), readJsonPath(parsed.data, path))) {
|
|
6274
|
+
throw new Error(
|
|
6275
|
+
`llmPolicyEditProposer: redactCurrentSurfaceForModel must not change or hide editable JSON path '${path}'`
|
|
6276
|
+
);
|
|
6277
|
+
}
|
|
6278
|
+
}
|
|
6279
|
+
return parsed.data;
|
|
6280
|
+
}
|
|
6281
|
+
function formatJsonValidationError(error) {
|
|
6282
|
+
const messages = [...new Set(collectZodMessages(error.issues))];
|
|
6283
|
+
const informative = messages.filter(
|
|
6284
|
+
(message) => message !== "Invalid input" && message !== "Invalid key in record"
|
|
6285
|
+
);
|
|
6286
|
+
const custom = informative.filter((message) => !message.startsWith("Invalid input: expected"));
|
|
6287
|
+
return (custom.length > 0 ? custom : informative).join("; ") || "invalid JSON value";
|
|
6288
|
+
}
|
|
6289
|
+
function collectZodMessages(value) {
|
|
6290
|
+
if (Array.isArray(value)) return value.flatMap(collectZodMessages);
|
|
6291
|
+
if (!value || typeof value !== "object") return [];
|
|
6292
|
+
const issue = value;
|
|
6293
|
+
return [
|
|
6294
|
+
...typeof issue.message === "string" ? [issue.message] : [],
|
|
6295
|
+
...collectZodMessages(issue.errors),
|
|
6296
|
+
...collectZodMessages(issue.issues)
|
|
6297
|
+
];
|
|
6298
|
+
}
|
|
6299
|
+
function readJsonPath(root, path) {
|
|
6300
|
+
let cursor = root;
|
|
6301
|
+
for (const part of path.split(".").map((segment) => segment.trim()).filter(Boolean)) {
|
|
6302
|
+
if (!cursor || typeof cursor !== "object" || Array.isArray(cursor)) return void 0;
|
|
6303
|
+
cursor = cursor[part];
|
|
6304
|
+
}
|
|
6305
|
+
return cursor;
|
|
6306
|
+
}
|
|
6307
|
+
function jsonValuesEqual(left, right) {
|
|
6308
|
+
if (left === right) return true;
|
|
6309
|
+
if (left === void 0 || right === void 0 || left === null || right === null) return false;
|
|
6310
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
6311
|
+
return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => jsonValuesEqual(value, right[index]));
|
|
6312
|
+
}
|
|
6313
|
+
if (typeof left !== "object" || typeof right !== "object") return false;
|
|
6314
|
+
const leftKeys = Object.keys(left);
|
|
6315
|
+
const rightKeys = Object.keys(right);
|
|
6316
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && jsonValuesEqual(left[key], right[key]));
|
|
6317
|
+
}
|
|
6212
6318
|
function citableFindings(inputs, measuredSources, limit) {
|
|
6213
6319
|
if (inputs.length === 0) {
|
|
6214
6320
|
throw new Error("llmPolicyEditProposer: at least one analyst finding is required");
|
|
@@ -8279,4 +8385,4 @@ export {
|
|
|
8279
8385
|
verifyCodeSurface,
|
|
8280
8386
|
resolveWorktreePath
|
|
8281
8387
|
};
|
|
8282
|
-
//# sourceMappingURL=chunk-
|
|
8388
|
+
//# sourceMappingURL=chunk-RQP5UTK5.js.map
|