@hotpathrun/cli 0.3.0 → 0.3.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/dist/hotpath.mjs +925 -93
- package/package.json +9 -9
- package/viewer/assets/index-C3A5oxP4.js +17 -0
- package/viewer/index.html +1 -1
- package/viewer/assets/index-CmtmWVrm.js +0 -17
package/dist/hotpath.mjs
CHANGED
|
@@ -7193,6 +7193,23 @@ function renderString(text, ctx) {
|
|
|
7193
7193
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
7194
7194
|
});
|
|
7195
7195
|
}
|
|
7196
|
+
function missingReferences(value, ctx, nullToo = false) {
|
|
7197
|
+
if (typeof value === "string") {
|
|
7198
|
+
return [...value.matchAll(TEMPLATE_RE)].map((m3) => m3[1].trim()).filter((expr) => {
|
|
7199
|
+
const v3 = lookup(expr, ctx);
|
|
7200
|
+
return v3 === void 0 || nullToo && v3 === null;
|
|
7201
|
+
});
|
|
7202
|
+
}
|
|
7203
|
+
if (Array.isArray(value)) {
|
|
7204
|
+
return value.flatMap((v3) => missingReferences(v3, ctx, nullToo));
|
|
7205
|
+
}
|
|
7206
|
+
if (value !== null && typeof value === "object") {
|
|
7207
|
+
return Object.values(value).flatMap(
|
|
7208
|
+
(v3) => missingReferences(v3, ctx, nullToo)
|
|
7209
|
+
);
|
|
7210
|
+
}
|
|
7211
|
+
return [];
|
|
7212
|
+
}
|
|
7196
7213
|
function lookupReference(expr, ctx) {
|
|
7197
7214
|
return lookup(expr, ctx);
|
|
7198
7215
|
}
|
|
@@ -7229,11 +7246,15 @@ function child(value, key) {
|
|
|
7229
7246
|
}
|
|
7230
7247
|
return void 0;
|
|
7231
7248
|
}
|
|
7232
|
-
|
|
7249
|
+
function requestInputs(inputs) {
|
|
7250
|
+
return Object.entries(inputs).filter(([, v3]) => typeof v3 === "string" && /\s/.test(v3.trim())).map(([k3]) => k3);
|
|
7251
|
+
}
|
|
7252
|
+
var TEMPLATE_RE, REQUEST_RULE;
|
|
7233
7253
|
var init_template = __esm({
|
|
7234
7254
|
"../shared/src/template.ts"() {
|
|
7235
7255
|
"use strict";
|
|
7236
7256
|
TEMPLATE_RE = /\{\{([^{}]+)\}\}/g;
|
|
7257
|
+
REQUEST_RULE = "The example shows format and level of detail only. Write in the language of the request and answer what it asks.";
|
|
7237
7258
|
}
|
|
7238
7259
|
});
|
|
7239
7260
|
|
|
@@ -7904,7 +7925,9 @@ var init_schemas = __esm({
|
|
|
7904
7925
|
]);
|
|
7905
7926
|
workflowInputSchema = external_exports.object({
|
|
7906
7927
|
type: external_exports.string(),
|
|
7907
|
-
example: external_exports.unknown()
|
|
7928
|
+
example: external_exports.unknown(),
|
|
7929
|
+
/** false: only some recordings had it (a customer gives an id or an email); a run may leave it out */
|
|
7930
|
+
required: external_exports.boolean().optional()
|
|
7908
7931
|
});
|
|
7909
7932
|
droppedCallSchema = external_exports.object({
|
|
7910
7933
|
/** tool_call.seq in the trace */
|
|
@@ -51362,7 +51385,7 @@ function retryDelayMs(headers, attempt) {
|
|
|
51362
51385
|
const date4 = Date.parse(after);
|
|
51363
51386
|
if (!Number.isNaN(date4)) return Math.max(0, date4 - Date.now());
|
|
51364
51387
|
}
|
|
51365
|
-
return Math.min(
|
|
51388
|
+
return Math.min(3e4, 1e3 * 2 ** attempt);
|
|
51366
51389
|
}
|
|
51367
51390
|
async function callWithRetries(call, waited) {
|
|
51368
51391
|
let rateLimited = 0;
|
|
@@ -51860,6 +51883,22 @@ function learnRule(yes, no) {
|
|
|
51860
51883
|
}
|
|
51861
51884
|
return null;
|
|
51862
51885
|
}
|
|
51886
|
+
function learnItemRule(yes, no) {
|
|
51887
|
+
const rule = learnRule(yes, no);
|
|
51888
|
+
if (rule || yes.length === 0 || no.length === 0) return rule;
|
|
51889
|
+
const refs = [...yes[0].keys()].filter(
|
|
51890
|
+
(r2) => [...yes, ...no].every((f3) => f3.has(r2))
|
|
51891
|
+
);
|
|
51892
|
+
const bool = (f3, v3) => f3 !== void 0 && "scalar" in f3 && f3.scalar === v3;
|
|
51893
|
+
for (const ref of refs) {
|
|
51894
|
+
for (const v3 of [true, false]) {
|
|
51895
|
+
if (yes.every((f3) => bool(f3.get(ref), v3)) && no.every((f3) => bool(f3.get(ref), !v3))) {
|
|
51896
|
+
return { kind: "equals", ref, value: v3 };
|
|
51897
|
+
}
|
|
51898
|
+
}
|
|
51899
|
+
}
|
|
51900
|
+
return null;
|
|
51901
|
+
}
|
|
51863
51902
|
function learnPathRule(yes, no) {
|
|
51864
51903
|
const rule = learnRule(yes, no);
|
|
51865
51904
|
if (rule) return rule;
|
|
@@ -51879,11 +51918,31 @@ function learnPathRule(yes, no) {
|
|
|
51879
51918
|
}
|
|
51880
51919
|
return null;
|
|
51881
51920
|
}
|
|
51882
|
-
|
|
51921
|
+
function varyingInputs(inputs) {
|
|
51922
|
+
const names2 = new Set(inputs.flatMap((i2) => Object.keys(i2)));
|
|
51923
|
+
return [...names2].filter((n3) => {
|
|
51924
|
+
const has3 = inputs.map((i2) => filled(i2[n3]));
|
|
51925
|
+
return has3.some(Boolean) && !has3.every(Boolean);
|
|
51926
|
+
});
|
|
51927
|
+
}
|
|
51928
|
+
function learnInputRule(yes, no) {
|
|
51929
|
+
if (yes.length === 0 || no.length === 0) return null;
|
|
51930
|
+
for (const name of varyingInputs([...yes, ...no])) {
|
|
51931
|
+
const ref = `inputs.${name}`;
|
|
51932
|
+
if (yes.every((i2) => filled(i2[name])) && no.every((i2) => !filled(i2[name])))
|
|
51933
|
+
return { kind: "nonEmpty", ref };
|
|
51934
|
+
if (yes.every((i2) => !filled(i2[name])) && no.every((i2) => filled(i2[name])))
|
|
51935
|
+
return { kind: "empty", ref };
|
|
51936
|
+
}
|
|
51937
|
+
return null;
|
|
51938
|
+
}
|
|
51939
|
+
var CATEGORY_FIELD, filled, givenInputs;
|
|
51883
51940
|
var init_rules3 = __esm({
|
|
51884
51941
|
"../compiler/src/rules.ts"() {
|
|
51885
51942
|
"use strict";
|
|
51886
51943
|
CATEGORY_FIELD = /\.(priority|category|type|kind|status|severity|level|class|tier|state|urgency|intent|label|action|decision|route|queue)$/i;
|
|
51944
|
+
filled = (v3) => v3 !== void 0 && v3 !== null && v3 !== "" && !(Array.isArray(v3) && v3.length === 0);
|
|
51945
|
+
givenInputs = (inputs, names2) => names2.filter((n3) => filled(inputs[n3]));
|
|
51887
51946
|
}
|
|
51888
51947
|
});
|
|
51889
51948
|
|
|
@@ -52176,7 +52235,32 @@ var init_layout2 = __esm({
|
|
|
52176
52235
|
function recordedItemCount(results) {
|
|
52177
52236
|
return results.reduce((n3, r2) => n3 + countItems(r2.result), 0);
|
|
52178
52237
|
}
|
|
52179
|
-
function
|
|
52238
|
+
function ruleHolds(rule, yes, no) {
|
|
52239
|
+
if (rule.kind !== "equals" && rule.kind !== "notEquals") return false;
|
|
52240
|
+
const test = (m3) => {
|
|
52241
|
+
const f3 = m3.get(rule.ref);
|
|
52242
|
+
if (!f3 || !("scalar" in f3)) return null;
|
|
52243
|
+
return rule.kind === "equals" ? f3.scalar === rule.value : f3.scalar !== rule.value;
|
|
52244
|
+
};
|
|
52245
|
+
return yes.every((m3) => test(m3) === true) && no.every((m3) => test(m3) === false);
|
|
52246
|
+
}
|
|
52247
|
+
function sampleItems(items, as, acted) {
|
|
52248
|
+
const out = { yes: [], no: [] };
|
|
52249
|
+
items.forEach((item, ix) => {
|
|
52250
|
+
const map = /* @__PURE__ */ new Map();
|
|
52251
|
+
features(item, as, map);
|
|
52252
|
+
(acted.has(ix) ? out.yes : out.no).push(map);
|
|
52253
|
+
});
|
|
52254
|
+
return out;
|
|
52255
|
+
}
|
|
52256
|
+
function addSamples(hints, tool, got) {
|
|
52257
|
+
if (!hints.samples) return;
|
|
52258
|
+
const have = hints.samples.get(tool) ?? { yes: [], no: [] };
|
|
52259
|
+
have.yes.push(...got.yes);
|
|
52260
|
+
have.no.push(...got.no);
|
|
52261
|
+
hints.samples.set(tool, have);
|
|
52262
|
+
}
|
|
52263
|
+
function compileTraceDetailed(trace2, compiledFrom, hints = {}) {
|
|
52180
52264
|
const steps = [];
|
|
52181
52265
|
const earlier = [];
|
|
52182
52266
|
const annotationsByTool = new Map(
|
|
@@ -52203,11 +52287,21 @@ function compileTraceDetailed(trace2, compiledFrom) {
|
|
|
52203
52287
|
return value;
|
|
52204
52288
|
};
|
|
52205
52289
|
for (let index = 0; index < kept.length; ) {
|
|
52206
|
-
const loop = detectLoop(kept, index, earlier);
|
|
52290
|
+
const loop = detectLoop(kept, index, earlier, hints);
|
|
52207
52291
|
if (loop) {
|
|
52208
52292
|
const loopId = newId();
|
|
52209
52293
|
const calls = kept.slice(index, index + loop.count);
|
|
52210
52294
|
const first = calls[0];
|
|
52295
|
+
const listTool = readOnlyResults.find(
|
|
52296
|
+
(r2) => r2.id === loop.source.id
|
|
52297
|
+
)?.tool;
|
|
52298
|
+
if (listTool) {
|
|
52299
|
+
hints.sources?.set(first.tool, {
|
|
52300
|
+
tool: listTool,
|
|
52301
|
+
path: loop.source.path,
|
|
52302
|
+
as: loop.as
|
|
52303
|
+
});
|
|
52304
|
+
}
|
|
52211
52305
|
const args2 = {};
|
|
52212
52306
|
for (const [key, value] of Object.entries(first.args)) {
|
|
52213
52307
|
const itemPath = loop.itemArgs.get(key);
|
|
@@ -52256,14 +52350,15 @@ function compileTraceDetailed(trace2, compiledFrom) {
|
|
|
52256
52350
|
args[key] = templated;
|
|
52257
52351
|
continue;
|
|
52258
52352
|
}
|
|
52259
|
-
if (typeof value === "string" && isLlmWrittenText(value)) {
|
|
52353
|
+
if (typeof value === "string" && (isLlmWrittenText(value) || hints.textArgs?.has(textArgKey(call.tool, key)) || quotesData(value, sideEffect, readOnlyResults))) {
|
|
52260
52354
|
const llmId = newId();
|
|
52261
52355
|
const prompt = buildPrompt(
|
|
52262
52356
|
trace2.meta.task,
|
|
52263
52357
|
readOnlyResults,
|
|
52264
52358
|
key,
|
|
52265
52359
|
call.tool,
|
|
52266
|
-
constantSiblings(call.args, key)
|
|
52360
|
+
constantSiblings(call.args, key),
|
|
52361
|
+
requestInputs(trace2.meta.inputs)
|
|
52267
52362
|
);
|
|
52268
52363
|
const layout = inferLayout(value, readOnlyResults);
|
|
52269
52364
|
llmStepsForTool.push({
|
|
@@ -52313,6 +52408,16 @@ function compileTraceDetailed(trace2, compiledFrom) {
|
|
|
52313
52408
|
result: call.result
|
|
52314
52409
|
});
|
|
52315
52410
|
}
|
|
52411
|
+
for (const [tool, src] of hints.sources ?? []) {
|
|
52412
|
+
if (kept.some((c2) => c2.tool === tool)) continue;
|
|
52413
|
+
const list = walk4(
|
|
52414
|
+
readOnlyResults.find((r2) => r2.tool === src.tool)?.result,
|
|
52415
|
+
src.path
|
|
52416
|
+
);
|
|
52417
|
+
if (Array.isArray(list)) {
|
|
52418
|
+
addSamples(hints, tool, sampleItems(list, src.as, /* @__PURE__ */ new Set()));
|
|
52419
|
+
}
|
|
52420
|
+
}
|
|
52316
52421
|
const workflow = {
|
|
52317
52422
|
version: 1,
|
|
52318
52423
|
task: trace2.meta.task,
|
|
@@ -52331,18 +52436,30 @@ function compileTraceDetailed(trace2, compiledFrom) {
|
|
|
52331
52436
|
};
|
|
52332
52437
|
return { workflow, recorded: earlier };
|
|
52333
52438
|
}
|
|
52334
|
-
function arraysIn(node, path36 = []) {
|
|
52439
|
+
function arraysIn(node, path36 = [], min = 2) {
|
|
52335
52440
|
const found = [];
|
|
52336
52441
|
if (Array.isArray(node)) {
|
|
52337
|
-
if (node.length >=
|
|
52338
|
-
node.forEach(
|
|
52442
|
+
if (node.length >= min) found.push({ path: path36, items: node });
|
|
52443
|
+
node.forEach(
|
|
52444
|
+
(v3, i2) => found.push(...arraysIn(v3, [...path36, String(i2)], min))
|
|
52445
|
+
);
|
|
52339
52446
|
} else if (node !== null && typeof node === "object") {
|
|
52340
52447
|
for (const [k3, v3] of Object.entries(node)) {
|
|
52341
|
-
found.push(...arraysIn(v3, [...path36, k3]));
|
|
52448
|
+
found.push(...arraysIn(v3, [...path36, k3], min));
|
|
52342
52449
|
}
|
|
52343
52450
|
}
|
|
52344
52451
|
return found;
|
|
52345
52452
|
}
|
|
52453
|
+
function varyingArgs(window2, items) {
|
|
52454
|
+
if (window2.length === 1 && items) {
|
|
52455
|
+
return Object.keys(window2[0].args).filter(
|
|
52456
|
+
(k3) => items.some((item) => pathsOf(item, window2[0].args[k3]).length > 0)
|
|
52457
|
+
);
|
|
52458
|
+
}
|
|
52459
|
+
return Object.keys(window2[0].args).filter(
|
|
52460
|
+
(k3) => window2.some((c2) => !deepEqual(c2.args[k3], window2[0].args[k3]))
|
|
52461
|
+
);
|
|
52462
|
+
}
|
|
52346
52463
|
function pathsOf(node, value, path36 = []) {
|
|
52347
52464
|
if (deepEqual(node, value)) return [path36];
|
|
52348
52465
|
const found = [];
|
|
@@ -52365,15 +52482,16 @@ function loopVariable(path36) {
|
|
|
52365
52482
|
const singular = last.endsWith("ies") ? `${last.slice(0, -3)}y` : last.endsWith("s") ? last.slice(0, -1) : "";
|
|
52366
52483
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(singular) && !["inputs", "steps", ""].includes(singular) ? singular : "item";
|
|
52367
52484
|
}
|
|
52368
|
-
function detectLoop(calls, index, earlier) {
|
|
52485
|
+
function detectLoop(calls, index, earlier, hints) {
|
|
52369
52486
|
const tool = calls[index].tool;
|
|
52487
|
+
const known = hints.loopTools?.has(tool) === true;
|
|
52370
52488
|
let runEnd = index;
|
|
52371
52489
|
while (runEnd < calls.length && calls[runEnd].tool === tool) runEnd++;
|
|
52372
52490
|
const runLength = runEnd - index;
|
|
52373
|
-
if (runLength < 2) return null;
|
|
52491
|
+
if (runLength < (known ? 1 : 2)) return null;
|
|
52374
52492
|
for (const source of earlier) {
|
|
52375
52493
|
if (source.field !== "result") continue;
|
|
52376
|
-
for (const list of arraysIn(source.result)) {
|
|
52494
|
+
for (const list of arraysIn(source.result, [], known ? 1 : 2)) {
|
|
52377
52495
|
const n3 = list.items.length;
|
|
52378
52496
|
if (n3 > runLength) continue;
|
|
52379
52497
|
const window2 = calls.slice(index, index + n3);
|
|
@@ -52381,9 +52499,7 @@ function detectLoop(calls, index, earlier) {
|
|
|
52381
52499
|
if (window2.some((c2) => Object.keys(c2.args).sort().join("\0") !== keys)) {
|
|
52382
52500
|
continue;
|
|
52383
52501
|
}
|
|
52384
|
-
const varying =
|
|
52385
|
-
(k3) => window2.some((c2) => !deepEqual(c2.args[k3], window2[0].args[k3]))
|
|
52386
|
-
);
|
|
52502
|
+
const varying = varyingArgs(window2, known ? list.items : null);
|
|
52387
52503
|
if (varying.length === 0) continue;
|
|
52388
52504
|
const itemArgs = /* @__PURE__ */ new Map();
|
|
52389
52505
|
for (const key of varying) {
|
|
@@ -52397,29 +52513,37 @@ function detectLoop(calls, index, earlier) {
|
|
|
52397
52513
|
itemArgs.set(key, path36);
|
|
52398
52514
|
}
|
|
52399
52515
|
if (itemArgs.size !== varying.length) continue;
|
|
52516
|
+
const as = loopVariable(list.path);
|
|
52517
|
+
const got = sampleItems(list.items, as, new Set(list.items.keys()));
|
|
52518
|
+
addSamples(hints, tool, got);
|
|
52519
|
+
const rule = hints.itemRules?.get(tool);
|
|
52400
52520
|
return {
|
|
52401
52521
|
count: n3,
|
|
52402
52522
|
source: { id: source.id, path: list.path },
|
|
52403
|
-
as
|
|
52404
|
-
itemArgs
|
|
52523
|
+
as,
|
|
52524
|
+
itemArgs,
|
|
52525
|
+
...rule && ruleHolds(rule, got.yes, got.no) ? { when: rule } : {}
|
|
52405
52526
|
};
|
|
52406
52527
|
}
|
|
52407
52528
|
}
|
|
52408
|
-
return detectItemSubsetLoop(calls, index, runLength, earlier);
|
|
52529
|
+
return detectItemSubsetLoop(calls, index, runLength, earlier, hints);
|
|
52409
52530
|
}
|
|
52410
|
-
function detectItemSubsetLoop(calls, index, runLength, earlier) {
|
|
52531
|
+
function detectItemSubsetLoop(calls, index, runLength, earlier, hints) {
|
|
52532
|
+
const known = hints.loopTools?.has(calls[index].tool) === true;
|
|
52411
52533
|
const window2 = calls.slice(index, index + runLength);
|
|
52412
52534
|
const keys = Object.keys(window2[0].args).sort().join("\0");
|
|
52413
52535
|
if (window2.some((c2) => Object.keys(c2.args).sort().join("\0") !== keys)) {
|
|
52414
52536
|
return null;
|
|
52415
52537
|
}
|
|
52416
|
-
const
|
|
52417
|
-
|
|
52538
|
+
const sourceLists = (source) => source.field === "result" ? arraysIn(source.result, [], known ? 1 : 2) : [];
|
|
52539
|
+
const varying = varyingArgs(
|
|
52540
|
+
window2,
|
|
52541
|
+
known ? earlier.flatMap((e2) => sourceLists(e2)).flatMap((l2) => l2.items) : null
|
|
52418
52542
|
);
|
|
52419
52543
|
if (varying.length === 0) return null;
|
|
52420
52544
|
for (const source of earlier) {
|
|
52421
52545
|
if (source.field !== "result") continue;
|
|
52422
|
-
for (const list of
|
|
52546
|
+
for (const list of sourceLists(source)) {
|
|
52423
52547
|
const items = list.items;
|
|
52424
52548
|
if (items.length <= runLength) continue;
|
|
52425
52549
|
const first = varying[0];
|
|
@@ -52453,14 +52577,10 @@ function detectItemSubsetLoop(calls, index, runLength, earlier) {
|
|
|
52453
52577
|
if (itemArgs.size !== varying.length) continue;
|
|
52454
52578
|
const as = loopVariable(list.path);
|
|
52455
52579
|
const acted = new Set(chosen);
|
|
52456
|
-
const yes =
|
|
52457
|
-
|
|
52458
|
-
|
|
52459
|
-
|
|
52460
|
-
features(item, as, map);
|
|
52461
|
-
(acted.has(ix) ? yes : no).push(map);
|
|
52462
|
-
});
|
|
52463
|
-
const when = learnRule(yes, no);
|
|
52580
|
+
const { yes, no } = sampleItems(items, as, acted);
|
|
52581
|
+
addSamples(hints, calls[index].tool, { yes, no });
|
|
52582
|
+
const pooled = hints.itemRules?.get(calls[index].tool);
|
|
52583
|
+
const when = pooled && ruleHolds(pooled, yes, no) ? pooled : learnItemRule(yes, no);
|
|
52464
52584
|
if (!when) continue;
|
|
52465
52585
|
return {
|
|
52466
52586
|
count: runLength,
|
|
@@ -52495,7 +52615,14 @@ function inferCommonSchema(values) {
|
|
|
52495
52615
|
};
|
|
52496
52616
|
}
|
|
52497
52617
|
const types = new Set(values.map((v3) => v3 === null ? "null" : typeof v3));
|
|
52498
|
-
|
|
52618
|
+
if (types.size === 1) return { type: [...types][0] };
|
|
52619
|
+
if (types.size === 2 && types.has("null")) {
|
|
52620
|
+
const other = [...types].find((t2) => t2 !== "null");
|
|
52621
|
+
if (other === "string" || other === "number" || other === "boolean") {
|
|
52622
|
+
return { type: [other, "null"] };
|
|
52623
|
+
}
|
|
52624
|
+
}
|
|
52625
|
+
return {};
|
|
52499
52626
|
}
|
|
52500
52627
|
function isGroundable(value) {
|
|
52501
52628
|
if (typeof value === "string") {
|
|
@@ -52544,15 +52671,15 @@ function collectExampleFacts(example, results) {
|
|
|
52544
52671
|
}
|
|
52545
52672
|
function mentionedValues(example, results) {
|
|
52546
52673
|
const byValue = /* @__PURE__ */ new Map();
|
|
52547
|
-
const visit = (id, field2, node,
|
|
52674
|
+
const visit = (id, field2, node, segments2) => {
|
|
52548
52675
|
if (Array.isArray(node)) {
|
|
52549
|
-
node.forEach((v3, i2) => visit(id, field2, v3, [...
|
|
52676
|
+
node.forEach((v3, i2) => visit(id, field2, v3, [...segments2, String(i2)]));
|
|
52550
52677
|
} else if (node !== null && typeof node === "object") {
|
|
52551
52678
|
for (const [k3, v3] of Object.entries(node)) {
|
|
52552
|
-
visit(id, field2, v3, [...
|
|
52679
|
+
visit(id, field2, v3, [...segments2, k3]);
|
|
52553
52680
|
}
|
|
52554
52681
|
} else if (isGroundable(node) && mentions(example, node)) {
|
|
52555
|
-
const ref = ["steps", id, field2, ...
|
|
52682
|
+
const ref = ["steps", id, field2, ...segments2].join(".");
|
|
52556
52683
|
const key = `${typeof node}:${node}`;
|
|
52557
52684
|
const entry = byValue.get(key);
|
|
52558
52685
|
if (entry) entry.paths.push(ref);
|
|
@@ -52675,6 +52802,11 @@ function errorPreview(result) {
|
|
|
52675
52802
|
function isLlmWrittenText(value) {
|
|
52676
52803
|
return value.length >= LLM_TEXT_MIN_CHARS || value.includes("\n");
|
|
52677
52804
|
}
|
|
52805
|
+
function quotesData(value, sideEffect, results) {
|
|
52806
|
+
return sideEffect && /\s/.test(value.trim()) && mentionedValues(value, results).some(
|
|
52807
|
+
(e2) => typeof e2.value === "string" && e2.value.length >= QUOTE_MIN_CHARS
|
|
52808
|
+
);
|
|
52809
|
+
}
|
|
52678
52810
|
function recordedContext(trace2, earlier) {
|
|
52679
52811
|
const steps = {};
|
|
52680
52812
|
for (const { id, field: field2, result } of earlier) {
|
|
@@ -52682,15 +52814,19 @@ function recordedContext(trace2, earlier) {
|
|
|
52682
52814
|
}
|
|
52683
52815
|
return { inputs: trace2.meta.inputs, steps };
|
|
52684
52816
|
}
|
|
52685
|
-
function buildPrompt(task, readOnlyResults, argName, tool, siblings) {
|
|
52817
|
+
function buildPrompt(task, readOnlyResults, argName, tool, siblings, request = []) {
|
|
52686
52818
|
const parts = [`You are compiling the task "${task}".`];
|
|
52819
|
+
for (const name of request) {
|
|
52820
|
+
parts.push(`the request (inputs.${name}):
|
|
52821
|
+
{{inputs.${name}}}`);
|
|
52822
|
+
}
|
|
52687
52823
|
for (const { id, tool: toolName2, field: field2 } of readOnlyResults) {
|
|
52688
52824
|
const label = field2 === "results" ? `results (one per item)` : "result";
|
|
52689
52825
|
parts.push(`${id} ${toolName2} ${label}:
|
|
52690
52826
|
{{steps.${id}.${field2}}}`);
|
|
52691
52827
|
}
|
|
52692
52828
|
parts.push(
|
|
52693
|
-
`write the \`${argName}\` for \`${tool}\`${siblings}. Use only the data above and cover every item in it
|
|
52829
|
+
`write the \`${argName}\` for \`${tool}\`${siblings}. Use only the data above and cover every item in it.${request.length > 0 ? ` ${REQUEST_RULE}` : ""}`
|
|
52694
52830
|
);
|
|
52695
52831
|
return parts.join("\n\n");
|
|
52696
52832
|
}
|
|
@@ -52743,7 +52879,7 @@ function inferSchema(value) {
|
|
|
52743
52879
|
function deepEqual(a2, b3) {
|
|
52744
52880
|
return JSON.stringify(a2) === JSON.stringify(b3);
|
|
52745
52881
|
}
|
|
52746
|
-
var LLM_TEXT_MIN_CHARS, GROUNDING_MIN_STRING;
|
|
52882
|
+
var LLM_TEXT_MIN_CHARS, textArgKey, GROUNDING_MIN_STRING, QUOTE_MIN_CHARS;
|
|
52747
52883
|
var init_compiler = __esm({
|
|
52748
52884
|
"../compiler/src/compiler.ts"() {
|
|
52749
52885
|
"use strict";
|
|
@@ -52753,7 +52889,9 @@ var init_compiler = __esm({
|
|
|
52753
52889
|
init_grounding();
|
|
52754
52890
|
init_layout2();
|
|
52755
52891
|
LLM_TEXT_MIN_CHARS = 40;
|
|
52892
|
+
textArgKey = (tool, arg) => `${tool}\0${arg}`;
|
|
52756
52893
|
GROUNDING_MIN_STRING = 4;
|
|
52894
|
+
QUOTE_MIN_CHARS = 12;
|
|
52757
52895
|
}
|
|
52758
52896
|
});
|
|
52759
52897
|
|
|
@@ -53388,6 +53526,18 @@ function mergePaths(all) {
|
|
|
53388
53526
|
]
|
|
53389
53527
|
};
|
|
53390
53528
|
}
|
|
53529
|
+
function renameRecorded(recorded, steps, suffix) {
|
|
53530
|
+
const own = new Set(
|
|
53531
|
+
steps.flatMap((s3) => [
|
|
53532
|
+
s3.id,
|
|
53533
|
+
...s3.type === "foreach" ? s3.body.map((b3) => b3.id) : []
|
|
53534
|
+
])
|
|
53535
|
+
);
|
|
53536
|
+
const base = (id) => id.split(".")[0];
|
|
53537
|
+
return recorded.map(
|
|
53538
|
+
(r2) => own.has(r2.id) || own.has(base(r2.id)) ? { ...r2, id: `${base(r2.id)}${suffix}${r2.id.slice(base(r2.id).length)}` } : r2
|
|
53539
|
+
);
|
|
53540
|
+
}
|
|
53391
53541
|
var MAX_EXAMPLE_CHARS, keyOf;
|
|
53392
53542
|
var init_paths2 = __esm({
|
|
53393
53543
|
"../compiler/src/paths.ts"() {
|
|
@@ -53400,8 +53550,12 @@ var init_paths2 = __esm({
|
|
|
53400
53550
|
});
|
|
53401
53551
|
|
|
53402
53552
|
// ../compiler/src/branches.ts
|
|
53403
|
-
function compile(trace2, compiledFrom) {
|
|
53404
|
-
const { workflow, recorded } = compileTraceDetailed(
|
|
53553
|
+
function compile(trace2, compiledFrom, hints = {}) {
|
|
53554
|
+
const { workflow, recorded } = compileTraceDetailed(
|
|
53555
|
+
trace2,
|
|
53556
|
+
compiledFrom,
|
|
53557
|
+
hints
|
|
53558
|
+
);
|
|
53405
53559
|
const steps = workflow.steps.filter((s3) => s3.type !== "llm");
|
|
53406
53560
|
return {
|
|
53407
53561
|
trace: trace2,
|
|
@@ -53413,19 +53567,79 @@ function compile(trace2, compiledFrom) {
|
|
|
53413
53567
|
sig: steps.map(
|
|
53414
53568
|
(s3) => s3.type === "foreach" ? `${s3.body[0].tool}*` : s3.tool
|
|
53415
53569
|
),
|
|
53416
|
-
ids: steps.map((s3) => s3.id)
|
|
53570
|
+
ids: steps.map((s3) => s3.id),
|
|
53571
|
+
effects: steps.map(
|
|
53572
|
+
(s3) => s3.type === "foreach" ? s3.body[0].sideEffect : s3.sideEffect === true
|
|
53573
|
+
),
|
|
53574
|
+
keys: steps.map((s3) => {
|
|
53575
|
+
const tool = s3.type === "foreach" ? s3.body[0] : s3;
|
|
53576
|
+
const consts = Object.entries(
|
|
53577
|
+
tool.args
|
|
53578
|
+
).filter(
|
|
53579
|
+
([, v3]) => typeof v3 === "string" && !v3.includes("{{") && v3.length < 40
|
|
53580
|
+
).map(([k3, v3]) => `${k3}=${String(v3)}`);
|
|
53581
|
+
return `${tool.tool}${s3.type === "foreach" ? "*" : ""}(${consts.join(",")})`;
|
|
53582
|
+
})
|
|
53417
53583
|
};
|
|
53418
53584
|
}
|
|
53419
|
-
function
|
|
53585
|
+
function withoutNoise(c2, all) {
|
|
53586
|
+
const keep = c2.keys.map(
|
|
53587
|
+
(key, i2) => c2.effects[i2] || all.some((o2) => o2 !== c2 && o2.keys.includes(key))
|
|
53588
|
+
);
|
|
53589
|
+
const pick3 = (xs) => xs.filter((_3, i2) => keep[i2]);
|
|
53590
|
+
return {
|
|
53591
|
+
...c2,
|
|
53592
|
+
sig: pick3(c2.sig),
|
|
53593
|
+
ids: pick3(c2.ids),
|
|
53594
|
+
keys: pick3(c2.keys),
|
|
53595
|
+
effects: pick3(c2.effects)
|
|
53596
|
+
};
|
|
53597
|
+
}
|
|
53598
|
+
function align(own, base) {
|
|
53599
|
+
const ordered = embedClosest(own, base);
|
|
53600
|
+
const exact = ordered?.every((j2, i2) => own.keys[i2] === base.keys[j2]);
|
|
53601
|
+
return exact ? ordered : matchReordered(own, base) ?? ordered;
|
|
53602
|
+
}
|
|
53603
|
+
function embedClosest(sub, sup) {
|
|
53604
|
+
const n3 = sub.sig.length;
|
|
53605
|
+
const m3 = sup.sig.length;
|
|
53606
|
+
const best = Array.from(
|
|
53607
|
+
{ length: n3 + 1 },
|
|
53608
|
+
() => new Array(m3 + 1).fill(Infinity)
|
|
53609
|
+
);
|
|
53610
|
+
for (let j3 = 0; j3 <= m3; j3++) best[n3][j3] = 0;
|
|
53611
|
+
for (let i2 = n3 - 1; i2 >= 0; i2--) {
|
|
53612
|
+
for (let j3 = m3 - 1; j3 >= 0; j3--) {
|
|
53613
|
+
const skip = best[i2][j3 + 1];
|
|
53614
|
+
const take = sub.sig[i2] === sup.sig[j3] ? best[i2 + 1][j3 + 1] + (sub.keys[i2] === sup.keys[j3] ? 0 : 1) : Infinity;
|
|
53615
|
+
best[i2][j3] = Math.min(skip, take);
|
|
53616
|
+
}
|
|
53617
|
+
}
|
|
53618
|
+
if (!Number.isFinite(best[0][0])) return null;
|
|
53420
53619
|
const at2 = [];
|
|
53421
53620
|
let j2 = 0;
|
|
53422
|
-
for (
|
|
53423
|
-
while (
|
|
53424
|
-
|
|
53621
|
+
for (let i2 = 0; i2 < n3; i2++) {
|
|
53622
|
+
while (true) {
|
|
53623
|
+
const take = sub.sig[i2] === sup.sig[j2] ? best[i2 + 1][j2 + 1] + (sub.keys[i2] === sup.keys[j2] ? 0 : 1) : Infinity;
|
|
53624
|
+
if (take === best[i2][j2]) break;
|
|
53625
|
+
j2++;
|
|
53626
|
+
}
|
|
53425
53627
|
at2.push(j2++);
|
|
53426
53628
|
}
|
|
53427
53629
|
return at2;
|
|
53428
53630
|
}
|
|
53631
|
+
function matchReordered(own, base) {
|
|
53632
|
+
const used = /* @__PURE__ */ new Set();
|
|
53633
|
+
const at2 = [];
|
|
53634
|
+
for (const key of own.keys) {
|
|
53635
|
+
const j2 = base.keys.findIndex((k3, ix) => k3 === key && !used.has(ix));
|
|
53636
|
+
if (j2 === -1) return null;
|
|
53637
|
+
used.add(j2);
|
|
53638
|
+
at2.push(j2);
|
|
53639
|
+
}
|
|
53640
|
+
const acting = at2.filter((_3, i2) => own.effects[i2]);
|
|
53641
|
+
return acting.every((j2, i2) => i2 === 0 || j2 > acting[i2 - 1]) ? at2 : null;
|
|
53642
|
+
}
|
|
53429
53643
|
function shapeOf(value, prefix = "", out = /* @__PURE__ */ new Set()) {
|
|
53430
53644
|
if (Array.isArray(value)) {
|
|
53431
53645
|
for (const item of value) shapeOf(item, `${prefix}[]`, out);
|
|
@@ -53455,6 +53669,58 @@ function sameShapes(a2, b3) {
|
|
|
53455
53669
|
}
|
|
53456
53670
|
return true;
|
|
53457
53671
|
}
|
|
53672
|
+
function learnHints(all) {
|
|
53673
|
+
const loopTools = /* @__PURE__ */ new Set();
|
|
53674
|
+
for (const c2 of all) {
|
|
53675
|
+
for (const t2 of c2.sig) if (t2.endsWith("*")) loopTools.add(t2.slice(0, -1));
|
|
53676
|
+
}
|
|
53677
|
+
const base = [...all].reverse().find((c2) => all.every((o2) => align(o2, c2))) ?? all[all.length - 1];
|
|
53678
|
+
const textArgs = /* @__PURE__ */ new Set();
|
|
53679
|
+
const positional = /* @__PURE__ */ new Map();
|
|
53680
|
+
for (const c2 of all) {
|
|
53681
|
+
const seen = /* @__PURE__ */ new Set();
|
|
53682
|
+
for (const step of c2.workflow.steps) {
|
|
53683
|
+
if (step.type !== "tool") continue;
|
|
53684
|
+
for (const [key, v3] of Object.entries(step.args)) {
|
|
53685
|
+
if (typeof v3 !== "string") continue;
|
|
53686
|
+
const out = /^\{\{steps\.([^.}]+)\.output\}\}$/.exec(v3);
|
|
53687
|
+
if (out && c2.workflow.steps.some((o2) => o2.id === out[1] && o2.type === "llm")) {
|
|
53688
|
+
textArgs.add(textArgKey(step.tool, key));
|
|
53689
|
+
}
|
|
53690
|
+
if (/\{\{steps\.[^}]*\.\d+(\.[^}]*)?\}\}/.test(v3)) {
|
|
53691
|
+
const entry = positional.get(step.tool) ?? {
|
|
53692
|
+
templates: /* @__PURE__ */ new Set(),
|
|
53693
|
+
runs: 0
|
|
53694
|
+
};
|
|
53695
|
+
entry.templates.add(v3);
|
|
53696
|
+
if (!seen.has(step.tool)) entry.runs++;
|
|
53697
|
+
seen.add(step.tool);
|
|
53698
|
+
positional.set(step.tool, entry);
|
|
53699
|
+
}
|
|
53700
|
+
}
|
|
53701
|
+
}
|
|
53702
|
+
}
|
|
53703
|
+
for (const [tool, { templates: templates2, runs }] of positional) {
|
|
53704
|
+
if (templates2.size > 1 || runs < all.length) loopTools.add(tool);
|
|
53705
|
+
}
|
|
53706
|
+
for (const other of all) {
|
|
53707
|
+
if (other === base) continue;
|
|
53708
|
+
const ids = idMap(other, base);
|
|
53709
|
+
if (!ids) continue;
|
|
53710
|
+
for (const step of other.workflow.steps) {
|
|
53711
|
+
const mapped = base.workflow.steps.find((s3) => s3.id === ids.get(step.id));
|
|
53712
|
+
if (step.type !== "tool" || mapped?.type !== "tool") continue;
|
|
53713
|
+
for (const [key, a2] of Object.entries(step.args)) {
|
|
53714
|
+
const b3 = mapped.args[key];
|
|
53715
|
+
const constant = (v3) => typeof v3 === "string" && !v3.includes("{{");
|
|
53716
|
+
if (constant(a2) && constant(b3) && a2 !== b3) {
|
|
53717
|
+
textArgs.add(textArgKey(step.tool, key));
|
|
53718
|
+
}
|
|
53719
|
+
}
|
|
53720
|
+
}
|
|
53721
|
+
}
|
|
53722
|
+
return { loopTools, textArgs };
|
|
53723
|
+
}
|
|
53458
53724
|
function describe(step) {
|
|
53459
53725
|
if (step.type === "llm") return "write text";
|
|
53460
53726
|
if (step.type === "branch") return "choose a path";
|
|
@@ -53473,18 +53739,173 @@ function feeders(workflow, toolIds) {
|
|
|
53473
53739
|
}
|
|
53474
53740
|
return out;
|
|
53475
53741
|
}
|
|
53742
|
+
function richest(candidates2) {
|
|
53743
|
+
const size = (c2) => c2.results.reduce((n3, r2) => n3 + countItems(r2.result), 0);
|
|
53744
|
+
return candidates2.reduce((best, c2) => size(c2) >= size(best) ? c2 : best);
|
|
53745
|
+
}
|
|
53746
|
+
function widenGuards(workflow, base, all) {
|
|
53747
|
+
if (all.length < 2 || !all.every(
|
|
53748
|
+
(c2) => c2.sig.join() === base.sig.join() && c2.ids.length === base.ids.length
|
|
53749
|
+
)) {
|
|
53750
|
+
return workflow;
|
|
53751
|
+
}
|
|
53752
|
+
const schemas = /* @__PURE__ */ new Map();
|
|
53753
|
+
base.ids.forEach((id, i2) => {
|
|
53754
|
+
const values = [];
|
|
53755
|
+
for (const c2 of all) {
|
|
53756
|
+
const found = c2.results.find((r2) => r2.id === c2.ids[i2]);
|
|
53757
|
+
if (!found) return;
|
|
53758
|
+
if (found.field === "results")
|
|
53759
|
+
values.push(...found.result);
|
|
53760
|
+
else values.push(found.result);
|
|
53761
|
+
}
|
|
53762
|
+
schemas.set(id, inferCommonSchema(values));
|
|
53763
|
+
});
|
|
53764
|
+
const widen = (step) => {
|
|
53765
|
+
if (step.type === "tool" && step.guard.schema && schemas.has(step.id)) {
|
|
53766
|
+
return {
|
|
53767
|
+
...step,
|
|
53768
|
+
guard: { ...step.guard, schema: schemas.get(step.id) }
|
|
53769
|
+
};
|
|
53770
|
+
}
|
|
53771
|
+
if (step.type === "foreach" && schemas.has(step.id)) {
|
|
53772
|
+
return {
|
|
53773
|
+
...step,
|
|
53774
|
+
body: step.body.map(
|
|
53775
|
+
(b3) => b3.guard.schema ? { ...b3, guard: { ...b3.guard, schema: schemas.get(step.id) } } : b3
|
|
53776
|
+
)
|
|
53777
|
+
};
|
|
53778
|
+
}
|
|
53779
|
+
return step;
|
|
53780
|
+
};
|
|
53781
|
+
return { ...workflow, steps: workflow.steps.map(widen) };
|
|
53782
|
+
}
|
|
53476
53783
|
function compileTraces(traces, compiledFrom) {
|
|
53784
|
+
const result = compileUsed(traces, compiledFrom, true);
|
|
53785
|
+
const usedTraces = result.used.map((i2) => traces[i2]);
|
|
53786
|
+
return {
|
|
53787
|
+
...result,
|
|
53788
|
+
workflow: {
|
|
53789
|
+
...result.workflow,
|
|
53790
|
+
inputs: declareInputs(result.workflow.inputs, usedTraces)
|
|
53791
|
+
}
|
|
53792
|
+
};
|
|
53793
|
+
}
|
|
53794
|
+
function declareInputs(declared, traces) {
|
|
53795
|
+
const inputs = traces.map((t2) => t2.meta.inputs);
|
|
53796
|
+
const optional2 = new Set(varyingInputs(inputs));
|
|
53797
|
+
const out = { ...declared };
|
|
53798
|
+
for (const name of optional2) {
|
|
53799
|
+
const from = [...inputs].reverse().find((i2) => givenInputs(i2, [name]).length);
|
|
53800
|
+
const value = from?.[name];
|
|
53801
|
+
out[name] = {
|
|
53802
|
+
...out[name] ?? { type: typeof value, example: value },
|
|
53803
|
+
required: false
|
|
53804
|
+
};
|
|
53805
|
+
}
|
|
53806
|
+
return out;
|
|
53807
|
+
}
|
|
53808
|
+
function splitByInputs(used, compiledFrom) {
|
|
53809
|
+
const inputs = used.map(({ t: t2 }) => t2.meta.inputs);
|
|
53810
|
+
const names2 = varyingInputs(inputs);
|
|
53811
|
+
if (names2.length === 0) return null;
|
|
53812
|
+
const groups = /* @__PURE__ */ new Map();
|
|
53813
|
+
inputs.forEach((inp, k3) => {
|
|
53814
|
+
const key = givenInputs(inp, names2).join();
|
|
53815
|
+
groups.set(key, [...groups.get(key) ?? [], k3]);
|
|
53816
|
+
});
|
|
53817
|
+
if (groups.size < 2) return null;
|
|
53818
|
+
const parts = [...groups].map(([key, members]) => ({
|
|
53819
|
+
key,
|
|
53820
|
+
members,
|
|
53821
|
+
result: compileUsed(
|
|
53822
|
+
members.map((k3) => used[k3].t),
|
|
53823
|
+
compiledFrom,
|
|
53824
|
+
false
|
|
53825
|
+
)
|
|
53826
|
+
}));
|
|
53827
|
+
if (parts.some(
|
|
53828
|
+
(p3) => p3.result.workflow.steps.some((s3) => s3.type === "branch")
|
|
53829
|
+
) || new Set(parts.map((p3) => signatureOf(p3.result.workflow.steps))).size < 2) {
|
|
53830
|
+
return null;
|
|
53831
|
+
}
|
|
53832
|
+
const newestPart = parts.findIndex(
|
|
53833
|
+
(p3) => p3.members.includes(used.length - 1)
|
|
53834
|
+
);
|
|
53835
|
+
const cases = [];
|
|
53836
|
+
let otherwise;
|
|
53837
|
+
const recorded = [];
|
|
53838
|
+
for (const [gi, part] of parts.entries()) {
|
|
53839
|
+
const own = part.result.workflow.steps;
|
|
53840
|
+
const steps = gi === newestPart ? own : renameIds(own, `b${gi}`);
|
|
53841
|
+
recorded.push(
|
|
53842
|
+
...gi === newestPart ? part.result.recorded : renameRecorded(part.result.recorded, own, `b${gi}`)
|
|
53843
|
+
);
|
|
53844
|
+
if (part.key === "") {
|
|
53845
|
+
otherwise = steps;
|
|
53846
|
+
continue;
|
|
53847
|
+
}
|
|
53848
|
+
const rule = learnInputRule(
|
|
53849
|
+
part.members.map((k3) => inputs[k3]),
|
|
53850
|
+
parts.filter((o2) => o2 !== part).flatMap((o2) => o2.members.map((k3) => inputs[k3]))
|
|
53851
|
+
);
|
|
53852
|
+
if (!rule) return null;
|
|
53853
|
+
cases.push({ label: `${part.key} given`, when: rule, steps });
|
|
53854
|
+
}
|
|
53855
|
+
if (cases.length === 0) return null;
|
|
53856
|
+
const newestWorkflow = parts[newestPart].result.workflow;
|
|
53857
|
+
const branch = {
|
|
53858
|
+
id: "b1",
|
|
53859
|
+
type: "branch",
|
|
53860
|
+
cases,
|
|
53861
|
+
...otherwise ? { else: otherwise } : {}
|
|
53862
|
+
};
|
|
53863
|
+
return {
|
|
53864
|
+
workflow: { ...newestWorkflow, steps: [branch], compiledFrom },
|
|
53865
|
+
used: used.map((u2) => u2.i),
|
|
53866
|
+
warnings: parts.flatMap((p3) => p3.result.warnings),
|
|
53867
|
+
notes: [
|
|
53868
|
+
`b1 chooses the path from the inputs: ${parts.map((p3) => p3.key || "none of them").join(" | ")}`,
|
|
53869
|
+
...parts.flatMap((p3) => p3.result.notes)
|
|
53870
|
+
],
|
|
53871
|
+
recorded
|
|
53872
|
+
};
|
|
53873
|
+
}
|
|
53874
|
+
function compileUsed(traces, compiledFrom, allowSplit) {
|
|
53477
53875
|
if (traces.length === 0) throw new Error("no recordings to compile");
|
|
53478
53876
|
const newestTrace = traces[traces.length - 1];
|
|
53479
53877
|
const used = traces.map((t2, i3) => ({ t: t2, i: i3 })).filter(({ t: t2 }, i3) => i3 === traces.length - 1 || sameShapes(t2, newestTrace)).slice(-MAX_RECORDINGS);
|
|
53878
|
+
if (allowSplit && used.length > 1) {
|
|
53879
|
+
const split = splitByInputs(used, compiledFrom);
|
|
53880
|
+
if (split) return split;
|
|
53881
|
+
}
|
|
53480
53882
|
const warnings = [];
|
|
53481
|
-
|
|
53482
|
-
const
|
|
53883
|
+
let all = used.map(({ t: t2 }) => compile(t2, compiledFrom));
|
|
53884
|
+
const hints = learnHints(all);
|
|
53885
|
+
if (hasHints(hints)) {
|
|
53886
|
+
const sources = /* @__PURE__ */ new Map();
|
|
53887
|
+
used.forEach(
|
|
53888
|
+
({ t: t2 }) => compile(t2, compiledFrom, { ...hints, samples: /* @__PURE__ */ new Map(), sources })
|
|
53889
|
+
);
|
|
53890
|
+
const samples = /* @__PURE__ */ new Map();
|
|
53891
|
+
used.forEach(
|
|
53892
|
+
({ t: t2 }) => compile(t2, compiledFrom, { ...hints, samples, sources })
|
|
53893
|
+
);
|
|
53894
|
+
const itemRules = /* @__PURE__ */ new Map();
|
|
53895
|
+
for (const [tool, got] of samples) {
|
|
53896
|
+
const rule = got.no.length > 0 ? learnItemRule(got.yes, got.no) : null;
|
|
53897
|
+
if (rule) itemRules.set(tool, rule);
|
|
53898
|
+
}
|
|
53899
|
+
all = used.map(
|
|
53900
|
+
({ t: t2 }) => compile(t2, compiledFrom, { ...hints, itemRules })
|
|
53901
|
+
);
|
|
53902
|
+
}
|
|
53903
|
+
let newest = all[all.length - 1];
|
|
53483
53904
|
const indices = used.map((u2) => u2.i);
|
|
53484
53905
|
const finish = (base2, workflow) => {
|
|
53485
53906
|
const learned = learnCoverage(base2, workflow, all);
|
|
53486
53907
|
return {
|
|
53487
|
-
workflow: learned.workflow,
|
|
53908
|
+
workflow: widenGuards(learned.workflow, base2, all),
|
|
53488
53909
|
used: indices,
|
|
53489
53910
|
warnings,
|
|
53490
53911
|
notes: learned.notes,
|
|
@@ -53492,9 +53913,18 @@ function compileTraces(traces, compiledFrom) {
|
|
|
53492
53913
|
};
|
|
53493
53914
|
};
|
|
53494
53915
|
const plain = () => finish(newest, newest.workflow);
|
|
53495
|
-
if (all.length === 1
|
|
53496
|
-
|
|
53497
|
-
|
|
53916
|
+
if (all.length === 1) return plain();
|
|
53917
|
+
const quiet = all.map((c2) => withoutNoise(c2, all));
|
|
53918
|
+
if (quiet.some((c2, i3) => c2.sig.length !== all[i3].sig.length) && quiet.some((c2) => quiet.every((o2) => align(o2, c2)))) {
|
|
53919
|
+
all = quiet;
|
|
53920
|
+
newest = all[all.length - 1];
|
|
53921
|
+
}
|
|
53922
|
+
if (all.every((c2) => c2.sig.join() === newest.sig.join())) {
|
|
53923
|
+
const base2 = richest(all);
|
|
53924
|
+
return finish(base2, base2.workflow);
|
|
53925
|
+
}
|
|
53926
|
+
const bases = all.filter((c2) => all.every((o2) => align(o2, c2)));
|
|
53927
|
+
const base = bases.length > 0 ? richest(bases) : void 0;
|
|
53498
53928
|
if (!base) {
|
|
53499
53929
|
const merged = mergePaths(all);
|
|
53500
53930
|
if (merged) {
|
|
@@ -53511,7 +53941,7 @@ function compileTraces(traces, compiledFrom) {
|
|
|
53511
53941
|
);
|
|
53512
53942
|
return plain();
|
|
53513
53943
|
}
|
|
53514
|
-
const placed = all.map((c2) =>
|
|
53944
|
+
const placed = all.map((c2) => align(c2, base));
|
|
53515
53945
|
const present = (k3, i3) => placed[k3].includes(i3);
|
|
53516
53946
|
const always = base.sig.map((_3, i3) => all.every((_4, k3) => present(k3, i3)));
|
|
53517
53947
|
const featureSets = all.map((c2, k3) => {
|
|
@@ -53554,8 +53984,18 @@ function compileTraces(traces, compiledFrom) {
|
|
|
53554
53984
|
return m3;
|
|
53555
53985
|
};
|
|
53556
53986
|
const groupIds = base.ids.slice(i2, end + 1);
|
|
53557
|
-
const rule = learnRule(yesK.map(before), noK.map(before))
|
|
53987
|
+
const rule = learnRule(yesK.map(before), noK.map(before)) ?? learnInputRule(
|
|
53988
|
+
yesK.map((k3) => all[k3].trace.meta.inputs),
|
|
53989
|
+
noK.map((k3) => all[k3].trace.meta.inputs)
|
|
53990
|
+
);
|
|
53558
53991
|
const condition = rule ?? askCondition(base, all, i2, groupIds, yesK[0], noK[0], always);
|
|
53992
|
+
if (!condition) {
|
|
53993
|
+
warnings.push(
|
|
53994
|
+
`${groupIds.join(", ")} ran in only some recordings and nothing before them tells the recordings apart; they always run`
|
|
53995
|
+
);
|
|
53996
|
+
i2 = end + 1;
|
|
53997
|
+
continue;
|
|
53998
|
+
}
|
|
53559
53999
|
for (const id of groupIds) conditions.set(id, condition);
|
|
53560
54000
|
i2 = end + 1;
|
|
53561
54001
|
}
|
|
@@ -53571,7 +54011,7 @@ function compileTraces(traces, compiledFrom) {
|
|
|
53571
54011
|
return finish(base, { ...base.workflow, steps, compiledFrom });
|
|
53572
54012
|
}
|
|
53573
54013
|
function idMap(own, base) {
|
|
53574
|
-
const placed =
|
|
54014
|
+
const placed = align(own, base);
|
|
53575
54015
|
if (!placed) return null;
|
|
53576
54016
|
const map = /* @__PURE__ */ new Map();
|
|
53577
54017
|
placed.forEach(
|
|
@@ -53651,11 +54091,12 @@ function askCondition(base, all, start, groupIds, yesK, noK, always) {
|
|
|
53651
54091
|
const field2 = base.recorded.has(`${id}.results`) ? "results" : "result";
|
|
53652
54092
|
return { id, field: field2, tool: base.sig[base.ids.indexOf(id)] };
|
|
53653
54093
|
});
|
|
54094
|
+
if (refs.length === 0) return null;
|
|
53654
54095
|
const prompt = refs.map((r2) => `${r2.id} ${r2.tool} ${r2.field}:
|
|
53655
54096
|
{{steps.${r2.id}.${r2.field}}}`).join("\n\n");
|
|
53656
54097
|
const dataOf = (k3) => {
|
|
53657
54098
|
const c2 = all[k3];
|
|
53658
|
-
const placedK =
|
|
54099
|
+
const placedK = align(c2, base);
|
|
53659
54100
|
const ctx = {
|
|
53660
54101
|
inputs: c2.trace.meta.inputs,
|
|
53661
54102
|
steps: {}
|
|
@@ -53681,7 +54122,7 @@ function askCondition(base, all, start, groupIds, yesK, noK, always) {
|
|
|
53681
54122
|
no: dataOf(noK)
|
|
53682
54123
|
};
|
|
53683
54124
|
}
|
|
53684
|
-
var MAX_RECORDINGS, MAX_EXAMPLE_CHARS2;
|
|
54125
|
+
var MAX_RECORDINGS, MAX_EXAMPLE_CHARS2, hasHints, signatureOf;
|
|
53685
54126
|
var init_branches = __esm({
|
|
53686
54127
|
"../compiler/src/branches.ts"() {
|
|
53687
54128
|
"use strict";
|
|
@@ -53691,6 +54132,10 @@ var init_branches = __esm({
|
|
|
53691
54132
|
init_rules3();
|
|
53692
54133
|
MAX_RECORDINGS = 5;
|
|
53693
54134
|
MAX_EXAMPLE_CHARS2 = 1500;
|
|
54135
|
+
hasHints = (h2) => (h2.loopTools?.size ?? 0) > 0 || (h2.textArgs?.size ?? 0) > 0;
|
|
54136
|
+
signatureOf = (steps) => steps.map(
|
|
54137
|
+
(s3) => s3.type === "tool" ? `${s3.tool}${JSON.stringify(s3.args)}` : s3.type === "foreach" ? `each ${s3.over} ${signatureOf(s3.body)}` : s3.type
|
|
54138
|
+
).join(">");
|
|
53694
54139
|
}
|
|
53695
54140
|
});
|
|
53696
54141
|
|
|
@@ -66500,8 +66945,8 @@ var require_validate = __commonJS({
|
|
|
66500
66945
|
return data;
|
|
66501
66946
|
}
|
|
66502
66947
|
let expr = data;
|
|
66503
|
-
const
|
|
66504
|
-
for (const segment of
|
|
66948
|
+
const segments2 = jsonPointer.split("/");
|
|
66949
|
+
for (const segment of segments2) {
|
|
66505
66950
|
if (segment) {
|
|
66506
66951
|
data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
|
|
66507
66952
|
expr = (0, codegen_1._)`${expr} && ${data}`;
|
|
@@ -67030,12 +67475,12 @@ var require_utils2 = __commonJS({
|
|
|
67030
67475
|
if (path36 === "" || path36[0] === "/") {
|
|
67031
67476
|
return removeDotSegments(path36);
|
|
67032
67477
|
}
|
|
67033
|
-
const
|
|
67034
|
-
const last =
|
|
67478
|
+
const segments2 = path36.split("/");
|
|
67479
|
+
const last = segments2.length - 1;
|
|
67035
67480
|
const output = [];
|
|
67036
67481
|
let trailingDirectory = false;
|
|
67037
67482
|
for (let i2 = 0; i2 <= last; i2++) {
|
|
67038
|
-
const segment =
|
|
67483
|
+
const segment = segments2[i2];
|
|
67039
67484
|
if (segment === "." || segment === "..") {
|
|
67040
67485
|
if (segment === "..") {
|
|
67041
67486
|
if (output.length !== 0 && output[output.length - 1] !== "..") {
|
|
@@ -68086,7 +68531,7 @@ var require_core = __commonJS({
|
|
|
68086
68531
|
uriResolver
|
|
68087
68532
|
};
|
|
68088
68533
|
}
|
|
68089
|
-
var
|
|
68534
|
+
var Ajv4 = class {
|
|
68090
68535
|
constructor(opts = {}) {
|
|
68091
68536
|
this.schemas = {};
|
|
68092
68537
|
this.refs = {};
|
|
@@ -68376,9 +68821,9 @@ var require_core = __commonJS({
|
|
|
68376
68821
|
const rules = this.RULES.all;
|
|
68377
68822
|
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
|
68378
68823
|
for (const jsonPointer of keywordsJsonPointers) {
|
|
68379
|
-
const
|
|
68824
|
+
const segments2 = jsonPointer.split("/").slice(1);
|
|
68380
68825
|
let keywords = metaSchema;
|
|
68381
|
-
for (const seg of
|
|
68826
|
+
for (const seg of segments2)
|
|
68382
68827
|
keywords = keywords[seg];
|
|
68383
68828
|
for (const key in rules) {
|
|
68384
68829
|
const rule = rules[key];
|
|
@@ -68456,9 +68901,9 @@ var require_core = __commonJS({
|
|
|
68456
68901
|
}
|
|
68457
68902
|
}
|
|
68458
68903
|
};
|
|
68459
|
-
|
|
68460
|
-
|
|
68461
|
-
exports.default =
|
|
68904
|
+
Ajv4.ValidationError = validation_error_1.default;
|
|
68905
|
+
Ajv4.MissingRefError = ref_error_1.default;
|
|
68906
|
+
exports.default = Ajv4;
|
|
68462
68907
|
function checkOptions(checkOpts, options, msg, log = "error") {
|
|
68463
68908
|
for (const key in checkOpts) {
|
|
68464
68909
|
const opt = key;
|
|
@@ -70569,7 +71014,7 @@ var require_ajv = __commonJS({
|
|
|
70569
71014
|
var draft7MetaSchema = require_json_schema_draft_07();
|
|
70570
71015
|
var META_SUPPORT_DATA = ["/properties"];
|
|
70571
71016
|
var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema";
|
|
70572
|
-
var
|
|
71017
|
+
var Ajv4 = class extends core_1.default {
|
|
70573
71018
|
_addVocabularies() {
|
|
70574
71019
|
super._addVocabularies();
|
|
70575
71020
|
draft7_1.default.forEach((v3) => this.addVocabulary(v3));
|
|
@@ -70588,11 +71033,11 @@ var require_ajv = __commonJS({
|
|
|
70588
71033
|
return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
|
|
70589
71034
|
}
|
|
70590
71035
|
};
|
|
70591
|
-
exports.Ajv =
|
|
70592
|
-
module.exports = exports =
|
|
70593
|
-
module.exports.Ajv =
|
|
71036
|
+
exports.Ajv = Ajv4;
|
|
71037
|
+
module.exports = exports = Ajv4;
|
|
71038
|
+
module.exports.Ajv = Ajv4;
|
|
70594
71039
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70595
|
-
exports.default =
|
|
71040
|
+
exports.default = Ajv4;
|
|
70596
71041
|
var validate_1 = require_validate();
|
|
70597
71042
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
70598
71043
|
return validate_1.KeywordCxt;
|
|
@@ -73374,6 +73819,289 @@ var init_src3 = __esm({
|
|
|
73374
73819
|
}
|
|
73375
73820
|
});
|
|
73376
73821
|
|
|
73822
|
+
// ../runtime/src/guard-relax.ts
|
|
73823
|
+
function addUse(uses, step, use) {
|
|
73824
|
+
const list = uses.byStep.get(step) ?? [];
|
|
73825
|
+
list.push(uses.conditional ? { ...use, conditional: true } : use);
|
|
73826
|
+
uses.byStep.set(step, list);
|
|
73827
|
+
}
|
|
73828
|
+
function scanText(text, uses, aliases, viewOnly) {
|
|
73829
|
+
for (const m3 of text.matchAll(STEP_REF)) {
|
|
73830
|
+
const [, id, field2, tail] = m3;
|
|
73831
|
+
const path36 = segments(tail);
|
|
73832
|
+
if (path36.length === 0 && viewOnly) continue;
|
|
73833
|
+
if (field2 === "results") {
|
|
73834
|
+
const list = uses.loopResults.get(id) ?? [];
|
|
73835
|
+
const rest = path36.length > 0 && isIndex(path36[0]) ? path36.slice(1) : [];
|
|
73836
|
+
list.push({
|
|
73837
|
+
path: rest,
|
|
73838
|
+
structure: false,
|
|
73839
|
+
...uses.conditional ? { conditional: true } : {}
|
|
73840
|
+
});
|
|
73841
|
+
uses.loopResults.set(id, list);
|
|
73842
|
+
continue;
|
|
73843
|
+
}
|
|
73844
|
+
if (field2 !== "result") continue;
|
|
73845
|
+
addUse(uses, id, { path: path36, structure: false });
|
|
73846
|
+
}
|
|
73847
|
+
if (aliases.length === 0) return;
|
|
73848
|
+
for (const t2 of text.matchAll(TEMPLATE)) scanAlias(t2[1], uses, aliases);
|
|
73849
|
+
}
|
|
73850
|
+
function scanAlias(expr, uses, aliases) {
|
|
73851
|
+
for (const alias of aliases) {
|
|
73852
|
+
const re3 = new RegExp(
|
|
73853
|
+
`(?<![\\w.])${alias.as}((?:\\.${SEG})*)(?![\\w])`,
|
|
73854
|
+
"g"
|
|
73855
|
+
);
|
|
73856
|
+
for (const m3 of expr.matchAll(re3)) {
|
|
73857
|
+
if (!alias.base) continue;
|
|
73858
|
+
addUse(uses, alias.base.step, {
|
|
73859
|
+
path: [...alias.base.path, "*", ...segments(m3[1])],
|
|
73860
|
+
structure: false
|
|
73861
|
+
});
|
|
73862
|
+
}
|
|
73863
|
+
}
|
|
73864
|
+
}
|
|
73865
|
+
function scanValue(value, uses, aliases, viewOnly = false) {
|
|
73866
|
+
if (typeof value === "string") scanText(value, uses, aliases, viewOnly);
|
|
73867
|
+
else if (Array.isArray(value)) {
|
|
73868
|
+
for (const v3 of value) scanValue(v3, uses, aliases, viewOnly);
|
|
73869
|
+
} else if (value !== null && typeof value === "object") {
|
|
73870
|
+
for (const v3 of Object.values(value)) scanValue(v3, uses, aliases, viewOnly);
|
|
73871
|
+
}
|
|
73872
|
+
}
|
|
73873
|
+
function scanCondition(when, uses, aliases) {
|
|
73874
|
+
if (!when) return;
|
|
73875
|
+
if (when.kind === "ask") {
|
|
73876
|
+
scanText(when.prompt, uses, aliases, true);
|
|
73877
|
+
return;
|
|
73878
|
+
}
|
|
73879
|
+
const emptiness = when.kind === "nonEmpty" || when.kind === "empty";
|
|
73880
|
+
const target = emptiness ? resolveList(when.ref, aliases) : null;
|
|
73881
|
+
if (target && target !== "results") {
|
|
73882
|
+
addUse(uses, target.step, { path: target.path, structure: true });
|
|
73883
|
+
return;
|
|
73884
|
+
}
|
|
73885
|
+
scanText(when.ref, uses, aliases, false);
|
|
73886
|
+
scanAlias(when.ref, uses, aliases);
|
|
73887
|
+
}
|
|
73888
|
+
function resolveList(expr, aliases) {
|
|
73889
|
+
const text = expr.replace(/^\s*\{\{|\}\}\s*$/g, "").trim();
|
|
73890
|
+
const step = new RegExp(`^${STEP_REF.source}$`).exec(text);
|
|
73891
|
+
if (step) {
|
|
73892
|
+
if (step[2] !== "result") return "results";
|
|
73893
|
+
return { step: step[1], path: segments(step[3]) };
|
|
73894
|
+
}
|
|
73895
|
+
for (const alias of aliases) {
|
|
73896
|
+
const m3 = new RegExp(`^${alias.as}((?:\\.${SEG})*)$`).exec(text);
|
|
73897
|
+
if (m3 && alias.base) {
|
|
73898
|
+
return {
|
|
73899
|
+
step: alias.base.step,
|
|
73900
|
+
path: [...alias.base.path, "*", ...segments(m3[1])]
|
|
73901
|
+
};
|
|
73902
|
+
}
|
|
73903
|
+
}
|
|
73904
|
+
return null;
|
|
73905
|
+
}
|
|
73906
|
+
function stringsIn(node, skip, out = []) {
|
|
73907
|
+
if (typeof node === "string") out.push(node);
|
|
73908
|
+
else if (Array.isArray(node)) for (const v3 of node) stringsIn(v3, skip, out);
|
|
73909
|
+
else if (node !== null && typeof node === "object") {
|
|
73910
|
+
for (const [k3, v3] of Object.entries(node)) {
|
|
73911
|
+
if (!skip.includes(k3)) stringsIn(v3, skip, out);
|
|
73912
|
+
}
|
|
73913
|
+
}
|
|
73914
|
+
return out;
|
|
73915
|
+
}
|
|
73916
|
+
function scanSpec(node, uses, aliases) {
|
|
73917
|
+
if (Array.isArray(node)) {
|
|
73918
|
+
for (const v3 of node) scanSpec(v3, uses, aliases);
|
|
73919
|
+
return;
|
|
73920
|
+
}
|
|
73921
|
+
if (node === null || typeof node !== "object") {
|
|
73922
|
+
scanValue(node, uses, aliases);
|
|
73923
|
+
return;
|
|
73924
|
+
}
|
|
73925
|
+
const obj = node;
|
|
73926
|
+
const list = typeof obj.list === "string" ? resolveList(obj.list, aliases) : null;
|
|
73927
|
+
if (list && list !== "results") {
|
|
73928
|
+
addUse(uses, list.step, { path: list.path, structure: true });
|
|
73929
|
+
for (const name of stringsIn(obj, ["list", "line"])) {
|
|
73930
|
+
addUse(uses, list.step, {
|
|
73931
|
+
path: [...list.path, "*", ...segments(name)],
|
|
73932
|
+
structure: false
|
|
73933
|
+
});
|
|
73934
|
+
}
|
|
73935
|
+
}
|
|
73936
|
+
for (const [k3, v3] of Object.entries(obj)) {
|
|
73937
|
+
if (k3 === "line" || k3 === "list" && list && list !== "results") continue;
|
|
73938
|
+
scanSpec(v3, uses, aliases);
|
|
73939
|
+
}
|
|
73940
|
+
}
|
|
73941
|
+
function scanStep(step, uses, aliases) {
|
|
73942
|
+
const outer = uses.conditional;
|
|
73943
|
+
scanStepInner(step, uses, aliases);
|
|
73944
|
+
uses.conditional = outer;
|
|
73945
|
+
}
|
|
73946
|
+
function scanStepInner(step, uses, aliases) {
|
|
73947
|
+
const outer = uses.conditional;
|
|
73948
|
+
const own = (fn) => {
|
|
73949
|
+
uses.conditional = outer || step.when !== void 0;
|
|
73950
|
+
fn();
|
|
73951
|
+
uses.conditional = outer;
|
|
73952
|
+
};
|
|
73953
|
+
switch (step.type) {
|
|
73954
|
+
case "tool":
|
|
73955
|
+
own(() => scanValue(step.args, uses, aliases));
|
|
73956
|
+
scanCondition(step.when, uses, aliases);
|
|
73957
|
+
if (step.paginate) addUse(uses, step.id, { path: [], structure: false });
|
|
73958
|
+
return;
|
|
73959
|
+
case "llm": {
|
|
73960
|
+
scanCondition(step.when, uses, aliases);
|
|
73961
|
+
uses.conditional = outer || step.when !== void 0;
|
|
73962
|
+
scanText(step.prompt, uses, aliases, true);
|
|
73963
|
+
const guard = {
|
|
73964
|
+
...step.guard,
|
|
73965
|
+
exampleFacts: void 0,
|
|
73966
|
+
schema: void 0
|
|
73967
|
+
};
|
|
73968
|
+
scanSpec(guard, uses, aliases);
|
|
73969
|
+
scanSpec(step.calculations ?? [], uses, aliases);
|
|
73970
|
+
for (const row of step.layout?.rows ?? []) {
|
|
73971
|
+
const list = resolveList(row.over, aliases);
|
|
73972
|
+
if (!list || list === "results") {
|
|
73973
|
+
scanValue(row.over, uses, aliases);
|
|
73974
|
+
continue;
|
|
73975
|
+
}
|
|
73976
|
+
addUse(uses, list.step, { path: list.path, structure: true });
|
|
73977
|
+
for (const m3 of row.template.matchAll(
|
|
73978
|
+
/\{\{item((?:\.[^.{}\s]+)*)\}\}/g
|
|
73979
|
+
)) {
|
|
73980
|
+
addUse(uses, list.step, {
|
|
73981
|
+
path: [...list.path, "*", ...segments(m3[1])],
|
|
73982
|
+
structure: false
|
|
73983
|
+
});
|
|
73984
|
+
}
|
|
73985
|
+
}
|
|
73986
|
+
return;
|
|
73987
|
+
}
|
|
73988
|
+
case "foreach": {
|
|
73989
|
+
scanCondition(step.when, uses, aliases);
|
|
73990
|
+
uses.conditional = outer || step.when !== void 0;
|
|
73991
|
+
const list = resolveList(step.over, aliases);
|
|
73992
|
+
if (list === "results") scanValue(step.over, uses, aliases);
|
|
73993
|
+
else if (list) {
|
|
73994
|
+
addUse(uses, list.step, { path: list.path, structure: true });
|
|
73995
|
+
}
|
|
73996
|
+
const inner = [
|
|
73997
|
+
...aliases,
|
|
73998
|
+
{ as: step.as, base: list && list !== "results" ? list : null }
|
|
73999
|
+
];
|
|
74000
|
+
for (const b3 of step.body) scanStep(b3, uses, inner);
|
|
74001
|
+
return;
|
|
74002
|
+
}
|
|
74003
|
+
case "branch":
|
|
74004
|
+
scanCondition(step.when, uses, aliases);
|
|
74005
|
+
for (const c2 of step.cases) {
|
|
74006
|
+
uses.conditional = outer;
|
|
74007
|
+
scanCondition(c2.when, uses, aliases);
|
|
74008
|
+
uses.conditional = true;
|
|
74009
|
+
for (const s3 of c2.steps) scanStep(s3, uses, aliases);
|
|
74010
|
+
}
|
|
74011
|
+
uses.conditional = true;
|
|
74012
|
+
for (const s3 of step.else ?? []) scanStep(s3, uses, aliases);
|
|
74013
|
+
return;
|
|
74014
|
+
}
|
|
74015
|
+
}
|
|
74016
|
+
function allowNull(schema) {
|
|
74017
|
+
if ("enum" in schema || "const" in schema) return schema;
|
|
74018
|
+
const types = Array.isArray(schema.type) ? schema.type : typeof schema.type === "string" ? [schema.type] : null;
|
|
74019
|
+
if (!types) return schema;
|
|
74020
|
+
if (types.every((t2) => t2 === "null")) {
|
|
74021
|
+
const rest = { ...schema };
|
|
74022
|
+
delete rest.type;
|
|
74023
|
+
return rest;
|
|
74024
|
+
}
|
|
74025
|
+
if (types.includes("null")) return schema;
|
|
74026
|
+
return { ...schema, type: [...types, "null"] };
|
|
74027
|
+
}
|
|
74028
|
+
function relaxUnused(schema, uses) {
|
|
74029
|
+
if (uses.some((u2) => u2.path.length === 0 && !u2.structure)) return schema;
|
|
74030
|
+
const reading = uses.filter((u2) => u2.path.length > 0);
|
|
74031
|
+
const child2 = (node, below) => {
|
|
74032
|
+
if (node === null || typeof node !== "object") return void 0;
|
|
74033
|
+
const sub = node;
|
|
74034
|
+
if (below.length > 0) return relaxUnused(sub, below);
|
|
74035
|
+
const inner = relaxUnused(sub, []);
|
|
74036
|
+
return allowNull(inner);
|
|
74037
|
+
};
|
|
74038
|
+
const tails = (match) => reading.filter((u2) => match(u2.path[0])).map((u2) => ({ ...u2, path: u2.path.slice(1) }));
|
|
74039
|
+
if (schema.type === "object" && schema.properties !== null && typeof schema.properties === "object") {
|
|
74040
|
+
const properties = Object.fromEntries(
|
|
74041
|
+
Object.entries(schema.properties).map(
|
|
74042
|
+
([key, node]) => [
|
|
74043
|
+
key,
|
|
74044
|
+
child2(
|
|
74045
|
+
node,
|
|
74046
|
+
tails((s3) => s3 === key)
|
|
74047
|
+
) ?? node
|
|
74048
|
+
]
|
|
74049
|
+
)
|
|
74050
|
+
);
|
|
74051
|
+
return { ...schema, properties };
|
|
74052
|
+
}
|
|
74053
|
+
if (schema.type === "array" && schema.items) {
|
|
74054
|
+
const items = child2(schema.items, tails(isIndex));
|
|
74055
|
+
return items ? { ...schema, items } : schema;
|
|
74056
|
+
}
|
|
74057
|
+
return schema;
|
|
74058
|
+
}
|
|
74059
|
+
function relaxedGuards(workflow) {
|
|
74060
|
+
const uses = { byStep: /* @__PURE__ */ new Map(), loopResults: /* @__PURE__ */ new Map() };
|
|
74061
|
+
for (const step of workflow.steps) scanStep(step, uses, []);
|
|
74062
|
+
const out = /* @__PURE__ */ new Map();
|
|
74063
|
+
const visit = (step, loop, last = false) => {
|
|
74064
|
+
if (step.type === "tool") {
|
|
74065
|
+
if (!step.guard.schema) return;
|
|
74066
|
+
const read = [
|
|
74067
|
+
...uses.byStep.get(step.id) ?? [],
|
|
74068
|
+
...loop && last ? uses.loopResults.get(loop) ?? [] : []
|
|
74069
|
+
].filter((u2) => !u2.conditional);
|
|
74070
|
+
const relaxed = relaxUnused(step.guard.schema, read);
|
|
74071
|
+
try {
|
|
74072
|
+
new import_ajv2.Ajv({ strict: false }).compile(relaxed);
|
|
74073
|
+
out.set(step.id, { ...step.guard, schema: relaxed });
|
|
74074
|
+
} catch {
|
|
74075
|
+
out.set(step.id, step.guard);
|
|
74076
|
+
}
|
|
74077
|
+
} else if (step.type === "foreach") {
|
|
74078
|
+
step.body.forEach(
|
|
74079
|
+
(b3, i2) => visit(b3, step.id, i2 === step.body.length - 1)
|
|
74080
|
+
);
|
|
74081
|
+
} else if (step.type === "branch") {
|
|
74082
|
+
for (const c2 of step.cases) for (const s3 of c2.steps) visit(s3);
|
|
74083
|
+
for (const s3 of step.else ?? []) visit(s3);
|
|
74084
|
+
}
|
|
74085
|
+
};
|
|
74086
|
+
for (const step of workflow.steps) visit(step);
|
|
74087
|
+
return out;
|
|
74088
|
+
}
|
|
74089
|
+
var import_ajv2, SEG, STEP_REF, TEMPLATE, segments, isIndex;
|
|
74090
|
+
var init_guard_relax = __esm({
|
|
74091
|
+
"../runtime/src/guard-relax.ts"() {
|
|
74092
|
+
"use strict";
|
|
74093
|
+
import_ajv2 = __toESM(require_ajv(), 1);
|
|
74094
|
+
SEG = "[A-Za-z0-9_*-]+";
|
|
74095
|
+
STEP_REF = new RegExp(
|
|
74096
|
+
`steps\\.([A-Za-z_]\\w*(?:\\.\\d+)*)\\.(result|results|output)(?![\\w])((?:\\.${SEG})*)`,
|
|
74097
|
+
"g"
|
|
74098
|
+
);
|
|
74099
|
+
TEMPLATE = /\{\{([^{}]+)\}\}/g;
|
|
74100
|
+
segments = (tail) => tail.split(".").filter((s3) => s3 !== "");
|
|
74101
|
+
isIndex = (seg) => seg === "*" || /^\d+$/.test(seg);
|
|
74102
|
+
}
|
|
74103
|
+
});
|
|
74104
|
+
|
|
73377
74105
|
// ../runtime/src/checks.ts
|
|
73378
74106
|
function selectionMissing(entry, ctx, text) {
|
|
73379
74107
|
if (!entry.select) return null;
|
|
@@ -73481,13 +74209,59 @@ ${example}`.toLowerCase();
|
|
|
73481
74209
|
const found = [...text.match(URL_RE) ?? [], ...text.match(EMAIL_RE) ?? []].map((a2) => a2.replace(/[.,;:!?]+$/, "")).filter((a2) => !known.includes(a2.toLowerCase()));
|
|
73482
74210
|
return [...new Set(found)];
|
|
73483
74211
|
}
|
|
73484
|
-
|
|
74212
|
+
function latestItemFacts(readsIds, ctx) {
|
|
74213
|
+
const out = [];
|
|
74214
|
+
const visit = (node, at2, depth) => {
|
|
74215
|
+
if (Array.isArray(node)) {
|
|
74216
|
+
if (node.length >= 2 && node.every(
|
|
74217
|
+
(i2) => i2 !== null && typeof i2 === "object" && !Array.isArray(i2)
|
|
74218
|
+
)) {
|
|
74219
|
+
const items = node;
|
|
74220
|
+
const field2 = Object.keys(items[0]).find(
|
|
74221
|
+
(k3) => TIME_FIELD.test(k3) && items.every((i2) => dateMs(i2[k3]) !== null)
|
|
74222
|
+
);
|
|
74223
|
+
if (field2) {
|
|
74224
|
+
const newest = items.reduce(
|
|
74225
|
+
(best, i2) => dateMs(i2[field2]) >= dateMs(best[field2]) ? i2 : best
|
|
74226
|
+
);
|
|
74227
|
+
out.push(
|
|
74228
|
+
`The latest item of ${at2.replace(/^steps\./, "")} (the newest by its "${field2}", whatever its position) is: ${JSON.stringify(newest)}. When you say what is the latest or current state, use this item.`
|
|
74229
|
+
);
|
|
74230
|
+
}
|
|
74231
|
+
}
|
|
74232
|
+
return;
|
|
74233
|
+
}
|
|
74234
|
+
if (node !== null && typeof node === "object" && depth < 4) {
|
|
74235
|
+
for (const [k3, v3] of Object.entries(node))
|
|
74236
|
+
visit(v3, `${at2}.${k3}`, depth + 1);
|
|
74237
|
+
}
|
|
74238
|
+
};
|
|
74239
|
+
for (const id of readsIds) {
|
|
74240
|
+
const step = ctx.steps[id];
|
|
74241
|
+
if (!step) continue;
|
|
74242
|
+
for (const field2 of ["result", "results"]) {
|
|
74243
|
+
visit(step[field2], `steps.${id}.${field2}`, 0);
|
|
74244
|
+
}
|
|
74245
|
+
}
|
|
74246
|
+
return out;
|
|
74247
|
+
}
|
|
74248
|
+
function stepsRead(prompt) {
|
|
74249
|
+
return [
|
|
74250
|
+
...new Set(
|
|
74251
|
+
[...prompt.matchAll(/\{\{steps\.([^.}]+)\./g)].map((m3) => m3[1])
|
|
74252
|
+
)
|
|
74253
|
+
];
|
|
74254
|
+
}
|
|
74255
|
+
var URL_RE, EMAIL_RE, TIME_FIELD, ISO_DATE, dateMs;
|
|
73485
74256
|
var init_checks4 = __esm({
|
|
73486
74257
|
"../runtime/src/checks.ts"() {
|
|
73487
74258
|
"use strict";
|
|
73488
74259
|
init_src();
|
|
73489
74260
|
URL_RE = /\bhttps?:\/\/[^\s<>"'`)\]]+/gi;
|
|
73490
74261
|
EMAIL_RE = /\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/g;
|
|
74262
|
+
TIME_FIELD = /^(at|date|time|timestamp|datetime|\w+_at|\w+_date|\w+_time)$/i;
|
|
74263
|
+
ISO_DATE = /^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}.*)?$/;
|
|
74264
|
+
dateMs = (v3) => typeof v3 === "string" && ISO_DATE.test(v3) && !Number.isNaN(Date.parse(v3)) ? Date.parse(v3) : null;
|
|
73491
74265
|
}
|
|
73492
74266
|
});
|
|
73493
74267
|
|
|
@@ -75807,9 +76581,35 @@ async function readAgentRun(since) {
|
|
|
75807
76581
|
}
|
|
75808
76582
|
async function runWorkflow(workflow, options) {
|
|
75809
76583
|
const missing = Object.entries(workflow.inputs).filter(
|
|
75810
|
-
([name]) => !(name in options.inputs)
|
|
76584
|
+
([name, def]) => def.required !== false && !(name in options.inputs)
|
|
75811
76585
|
);
|
|
75812
76586
|
if (missing.length > 0) {
|
|
76587
|
+
const unknown2 = Object.keys(options.inputs).filter(
|
|
76588
|
+
(name) => !(name in workflow.inputs)
|
|
76589
|
+
);
|
|
76590
|
+
if (unknown2.length > 0) {
|
|
76591
|
+
throw new DriftError(
|
|
76592
|
+
"inputs",
|
|
76593
|
+
`this run gives ${unknown2.join(", ")}, which no recording had, and not ${missing.map(([n3]) => n3).join(", ")}`,
|
|
76594
|
+
false,
|
|
76595
|
+
{
|
|
76596
|
+
durationMs: 0,
|
|
76597
|
+
llmCalls: 0,
|
|
76598
|
+
promptTokens: 0,
|
|
76599
|
+
completionTokens: 0,
|
|
76600
|
+
costUsd: 0,
|
|
76601
|
+
fallback: false,
|
|
76602
|
+
steps: [],
|
|
76603
|
+
connectMs: 0,
|
|
76604
|
+
toolMs: 0,
|
|
76605
|
+
llmMs: 0,
|
|
76606
|
+
rateLimitWaitMs: 0,
|
|
76607
|
+
toolCalls: [],
|
|
76608
|
+
driftStep: "inputs",
|
|
76609
|
+
reason: "inputs never recorded"
|
|
76610
|
+
}
|
|
76611
|
+
);
|
|
76612
|
+
}
|
|
75813
76613
|
const listing = missing.map(
|
|
75814
76614
|
([name, def]) => ` ${name} (example: ${JSON.stringify(def.example)})`
|
|
75815
76615
|
).join("\n");
|
|
@@ -75883,8 +76683,15 @@ pass them as --input key=value`
|
|
|
75883
76683
|
},
|
|
75884
76684
|
...extra
|
|
75885
76685
|
});
|
|
76686
|
+
const calledArgs = [];
|
|
76687
|
+
const guards = relaxedGuards(workflow);
|
|
75886
76688
|
const callTool = async (step, label) => {
|
|
76689
|
+
const missing2 = missingReferences(step.args, ctx, true);
|
|
76690
|
+
if (missing2.length > 0) {
|
|
76691
|
+
return `${label}: ${step.tool} needs ${missing2.map((m3) => `{{${m3}}}`).join(", ")}, which today's data does not have`;
|
|
76692
|
+
}
|
|
75887
76693
|
const args = renderTemplate(step.args, ctx);
|
|
76694
|
+
calledArgs.push(args);
|
|
75888
76695
|
if (step.sideEffect && options.dryRun) {
|
|
75889
76696
|
console.log(
|
|
75890
76697
|
`dry-run: ${label} ${step.tool} would send ${JSON.stringify(args)}`
|
|
@@ -75948,7 +76755,7 @@ pass them as --input key=value`
|
|
|
75948
76755
|
if (isError) {
|
|
75949
76756
|
return `${label}: tool ${step.tool} returned an error: ${previewOf(value)}`;
|
|
75950
76757
|
}
|
|
75951
|
-
const failure = checkToolGuard(step.guard, value);
|
|
76758
|
+
const failure = checkToolGuard(guards.get(step.id) ?? step.guard, value);
|
|
75952
76759
|
return failure && label !== step.id ? `${label}: ${failure}` : failure;
|
|
75953
76760
|
};
|
|
75954
76761
|
try {
|
|
@@ -76029,10 +76836,18 @@ pass them as --input key=value`
|
|
|
76029
76836
|
}
|
|
76030
76837
|
if (step.type === "llm") {
|
|
76031
76838
|
const dataPrompt = renderTemplate(step.prompt, ctx);
|
|
76032
|
-
const
|
|
76839
|
+
const request = requestInputs(ctx.inputs);
|
|
76840
|
+
const changed = request.filter(
|
|
76841
|
+
(n3) => !step.prompt.includes(`inputs.${n3}`) && ctx.inputs[n3] !== workflow.inputs[n3]?.example
|
|
76842
|
+
);
|
|
76843
|
+
const key = answerKey(
|
|
76844
|
+
step.example,
|
|
76845
|
+
changed.length > 0 ? `${dataPrompt}
|
|
76846
|
+
${changed.map((n3) => ctx.inputs[n3]).join("\n")}` : dataPrompt
|
|
76847
|
+
);
|
|
76033
76848
|
const known = !reuse ? void 0 : key === step.inputKey ? step.example : answers[key]?.output;
|
|
76034
76849
|
const fromRecording = known !== void 0 && key === step.inputKey;
|
|
76035
|
-
if (known !== void 0 && checkLlmGuard(step.guard, known) === null && (!fromRecording || checkGrounding(step.guard.grounding, ctx, known).length === 0 && checkStale(step.guard.exampleFacts, ctx, known).length === 0 && figureProblems(todaysFigures(step.calculations, ctx), ctx, known).missing.length === 0)) {
|
|
76850
|
+
if (known !== void 0 && checkLlmGuard(step.guard, known) === null && (!fromRecording || checkGrounding(step.guard.grounding, ctx, known).length === 0 && checkStale(step.guard.exampleFacts, ctx, known, calledArgs).length === 0 && figureProblems(todaysFigures(step.calculations, ctx), ctx, known).missing.length === 0)) {
|
|
76036
76851
|
console.log(
|
|
76037
76852
|
`\u21BA ${step.id}: same data as an earlier run, reused its answer (HOTPATH_REUSE=0 to always ask the model)`
|
|
76038
76853
|
);
|
|
@@ -76046,6 +76861,11 @@ pass them as --input key=value`
|
|
|
76046
76861
|
"and cover every item in it.",
|
|
76047
76862
|
"and work out the figures from it. " + SELECTIVE_NOTE
|
|
76048
76863
|
) : dataPrompt;
|
|
76864
|
+
const requestTail = request.length > 0 ? `
|
|
76865
|
+
|
|
76866
|
+
Today's request:
|
|
76867
|
+
${request.map((n3) => String(ctx.inputs[n3])).join("\n")}
|
|
76868
|
+
Reply in the language of today's request, not the example's, and answer what it asks.` : "";
|
|
76049
76869
|
const unread = [
|
|
76050
76870
|
...new Set(
|
|
76051
76871
|
(step.calculations ?? []).flatMap((c2) => missingRates(c2, ctx))
|
|
@@ -76076,6 +76896,7 @@ pass them as --input key=value`
|
|
|
76076
76896
|
const hints = selectionHints(step.guard.grounding, ctx);
|
|
76077
76897
|
const computed = [
|
|
76078
76898
|
...hints.length > 0 ? [hints.join("\n")] : [],
|
|
76899
|
+
...latestItemFacts(stepsRead(step.prompt), ctx),
|
|
76079
76900
|
...figures.length > 0 ? [figuresPrompt(figures)] : []
|
|
76080
76901
|
];
|
|
76081
76902
|
const withDerived = (step.derived?.length ? `${askedData}
|
|
@@ -76092,23 +76913,23 @@ ${computed.join("\n\n")}` : "");
|
|
|
76092
76913
|
...figs.missing
|
|
76093
76914
|
],
|
|
76094
76915
|
stale: [
|
|
76095
|
-
...checkStale(step.guard.exampleFacts, ctx, t2),
|
|
76916
|
+
...checkStale(step.guard.exampleFacts, ctx, t2, calledArgs),
|
|
76096
76917
|
...figs.stale
|
|
76097
76918
|
]
|
|
76098
76919
|
};
|
|
76099
76920
|
};
|
|
76100
76921
|
const prompt = layout ? `${withDerived}
|
|
76101
76922
|
|
|
76102
|
-
Use only the data above. The example below comes from an earlier run on different data, so its facts must not be copied. In it, each line like ${layout.rows[0].marker} stands for a list that is filled in from the data afterwards (${layout.rows.map((r2) => `${r2.marker}: ${r2.over.split(".").slice(3).join(".") || "the items"}`).join("; ")}). Copy each of those lines exactly, once, on its own line, and do not write those lists yourself. Match the style and length of this example, roughly: ${layout.skeleton}
|
|
76923
|
+
Use only the data above. The example below comes from an earlier run on different data, so its facts must not be copied. In it, each line like ${layout.rows[0].marker} stands for a list that is filled in from the data afterwards (${layout.rows.map((r2) => `${r2.marker}: ${r2.over.split(".").slice(3).join(".") || "the items"}`).join("; ")}). Copy each of those lines exactly, once, on its own line, and do not write those lists yourself. Match the style and length of this example, roughly: ${layout.skeleton}${requestTail}
|
|
76103
76924
|
|
|
76104
76925
|
` + REPLY_ONLY : `${withDerived}
|
|
76105
76926
|
|
|
76106
|
-
Use only the data above. The example below comes from an earlier run on different data, so its facts must not be copied. Match the style and length of this example, roughly: ${step.example}
|
|
76927
|
+
Use only the data above. The example below comes from an earlier run on different data, so its facts must not be copied. Match the style and length of this example, roughly: ${step.example}${requestTail}
|
|
76107
76928
|
|
|
76108
76929
|
` + REPLY_ONLY;
|
|
76109
76930
|
const retryPrompt = `${withDerived}
|
|
76110
76931
|
|
|
76111
|
-
Use only the data above. Keep it to about ${lineCount(step.example)} lines
|
|
76932
|
+
Use only the data above. Keep it to about ${lineCount(step.example)} lines.${requestTail} ${REPLY_ONLY}`;
|
|
76112
76933
|
const writer = step.model === "strong" ? AGENT_MODEL : CHEAP_MODEL;
|
|
76113
76934
|
if (writer !== CHEAP_MODEL) {
|
|
76114
76935
|
console.log(
|
|
@@ -76160,9 +76981,9 @@ Use only the data above. Keep it to about ${lineCount(step.example)} lines. ${RE
|
|
|
76160
76981
|
let failure2 = checkLlmGuard(step.guard, text, todayItems);
|
|
76161
76982
|
if (failure2) await drift(failure2);
|
|
76162
76983
|
if (layout) {
|
|
76163
|
-
const
|
|
76164
|
-
if (
|
|
76165
|
-
text =
|
|
76984
|
+
const filled2 = fillRows(text, layout.rows, ctx);
|
|
76985
|
+
if (filled2 !== null) {
|
|
76986
|
+
text = filled2;
|
|
76166
76987
|
filledSteps.push(step.id);
|
|
76167
76988
|
}
|
|
76168
76989
|
}
|
|
@@ -76406,7 +77227,7 @@ function expandWildcards(path36, ctx) {
|
|
|
76406
77227
|
if (!Array.isArray(list)) return [];
|
|
76407
77228
|
return list.flatMap((_3, i2) => expandWildcards(`${prefix}.${i2}${rest}`, ctx));
|
|
76408
77229
|
}
|
|
76409
|
-
function checkStale(facts, ctx, text) {
|
|
77230
|
+
function checkStale(facts, ctx, text, alsoPresent = []) {
|
|
76410
77231
|
if (!facts || facts.length === 0) return [];
|
|
76411
77232
|
const current = [];
|
|
76412
77233
|
const visit = (node) => {
|
|
@@ -76419,6 +77240,7 @@ function checkStale(facts, ctx, text) {
|
|
|
76419
77240
|
};
|
|
76420
77241
|
visit(ctx.inputs);
|
|
76421
77242
|
visit(ctx.steps);
|
|
77243
|
+
visit(alsoPresent);
|
|
76422
77244
|
const stillThere = (fact) => current.some(
|
|
76423
77245
|
(v3) => typeof v3 === "number" ? v3 === fact || String(v3) === String(fact) : mentions(v3, fact)
|
|
76424
77246
|
);
|
|
@@ -76466,13 +77288,14 @@ function splitCommand(cmd) {
|
|
|
76466
77288
|
function isPageRecord(v3) {
|
|
76467
77289
|
return v3 !== null && typeof v3 === "object" && !Array.isArray(v3);
|
|
76468
77290
|
}
|
|
76469
|
-
var
|
|
77291
|
+
var import_ajv3, import_cross_spawn2, repoRoot2, outDir, IN_PROCESS_SERVER, HOTPATH_SECRETS, DriftError, INPUT_NAME_RE, MAX_ANSWERS, answersFile, REPLY_ONLY, ajv, SELECTIVE_NOTE;
|
|
76470
77292
|
var init_runtime = __esm({
|
|
76471
77293
|
"../runtime/src/runtime.ts"() {
|
|
76472
77294
|
"use strict";
|
|
77295
|
+
init_guard_relax();
|
|
76473
77296
|
init_client3();
|
|
76474
77297
|
init_stdio2();
|
|
76475
|
-
|
|
77298
|
+
import_ajv3 = __toESM(require_ajv(), 1);
|
|
76476
77299
|
import_cross_spawn2 = __toESM(require_cross_spawn(), 1);
|
|
76477
77300
|
init_src2();
|
|
76478
77301
|
init_src();
|
|
@@ -76505,7 +77328,7 @@ var init_runtime = __esm({
|
|
|
76505
77328
|
MAX_ANSWERS = 50;
|
|
76506
77329
|
answersFile = (task) => path11.join(repoRoot2, ".hotpath", "answers", `${assertTaskName(task)}.json`);
|
|
76507
77330
|
REPLY_ONLY = "Reply with the text only: no introduction, no code fences, no notes about the text.";
|
|
76508
|
-
ajv = new
|
|
77331
|
+
ajv = new import_ajv3.Ajv({ strict: false, allErrors: false });
|
|
76509
77332
|
SELECTIVE_NOTE = "The example reports only the items that matter for this task, not every item, together with the totals and converted amounts that go with them. Do the same with today's data: choose the equivalent items and give the same kinds of figures.";
|
|
76510
77333
|
}
|
|
76511
77334
|
});
|
|
@@ -76572,6 +77395,7 @@ var init_src4 = __esm({
|
|
|
76572
77395
|
init_egress();
|
|
76573
77396
|
init_journal();
|
|
76574
77397
|
init_verify();
|
|
77398
|
+
init_guard_relax();
|
|
76575
77399
|
}
|
|
76576
77400
|
});
|
|
76577
77401
|
|
|
@@ -78490,7 +79314,7 @@ var init_package = __esm({
|
|
|
78490
79314
|
"../../package.json"() {
|
|
78491
79315
|
package_default = {
|
|
78492
79316
|
name: "hotpath",
|
|
78493
|
-
version: "0.3.
|
|
79317
|
+
version: "0.3.1",
|
|
78494
79318
|
description: "Record your AI agent once. Replay it faster and cheaper, with AI only where judgment is needed.",
|
|
78495
79319
|
license: "Apache-2.0",
|
|
78496
79320
|
repository: {
|
|
@@ -78521,7 +79345,8 @@ var init_package = __esm({
|
|
|
78521
79345
|
"bench:guard-audit": "tsx bench/src/guard-audit.ts",
|
|
78522
79346
|
"bench:measure": "pnpm --filter demo-tools build && tsx bench/src/measure.ts",
|
|
78523
79347
|
"bench:branching": "pnpm --filter demo-tools build && tsx bench/src/branching.ts",
|
|
78524
|
-
"bench:replay": "pnpm --filter demo-tools build && tsx bench/src/replay-tokens.ts"
|
|
79348
|
+
"bench:replay": "pnpm --filter demo-tools build && tsx bench/src/replay-tokens.ts",
|
|
79349
|
+
fuzz: "pnpm --filter bench exec vitest run --config vitest.fuzz.config.ts"
|
|
78525
79350
|
},
|
|
78526
79351
|
devDependencies: {
|
|
78527
79352
|
"@eslint/js": "^9.17.0",
|
|
@@ -80883,6 +81708,13 @@ var init_agent = __esm({
|
|
|
80883
81708
|
maxTurns: 12,
|
|
80884
81709
|
nudge: false
|
|
80885
81710
|
},
|
|
81711
|
+
// heavy and real: two live web pages per company, 8 companies a day
|
|
81712
|
+
"lead-research": {
|
|
81713
|
+
system: (date4) => `You are a sales researcher. Today is ${date4}. Call get_leads for today's date. Then, one company at a time and in the order given, call fetch_page on its homepage and then on its pricing page. When every company is done, call send_message once with to="sales" and a markdown table with one row per company: company, what it sells (one line), who it is for, free plan (yes/no), cheapest paid plan with its price (or "not shown").`,
|
|
81714
|
+
user: "Please research today's leads now and send the table.",
|
|
81715
|
+
// 1 + 16 page reads + 1 send, one call per turn on most models
|
|
81716
|
+
maxTurns: 24
|
|
81717
|
+
},
|
|
80886
81718
|
"inbox-digest": {
|
|
80887
81719
|
system: (date4) => `You are a personal assistant. Today is ${date4}. Produce the inbox digest: call get_inbox, then open every email with get_email, one at a time and in the order get_inbox returned them, then call send_message with to="me" and a digest that mentions every email's subject and sender with one line about its content.`,
|
|
80888
81720
|
user: "Please produce the inbox digest now.",
|