@tangle-network/agent-runtime 0.266.0 → 0.273.3
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/{activation-BERiJjx5.js → activation-Cx2dKA_l.js} +2 -2
- package/dist/{activation-BERiJjx5.js.map → activation-Cx2dKA_l.js.map} +1 -1
- package/dist/{activation-VpxSbDKJ.d.ts → activation-IfDlhR3J.d.ts} +4 -4
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.js +2 -2
- package/dist/{coordination-driver-DdZ-nh_4.js → coordination-driver-CkcW4dxU.js} +173 -92
- package/dist/coordination-driver-CkcW4dxU.js.map +1 -0
- package/dist/{delegate-Ajx_PVyu.js → delegate-Dvb1-mE-.js} +2 -2
- package/dist/{delegate-Ajx_PVyu.js.map → delegate-Dvb1-mE-.js.map} +1 -1
- package/dist/durable.d.ts +3 -571
- package/dist/durable.js +93 -19
- package/dist/durable.js.map +1 -1
- package/dist/{graph-CK50N9vG.js → graph-C69Uxtzt.js} +17 -8
- package/dist/graph-C69Uxtzt.js.map +1 -0
- package/dist/{improvement-cycle-GRPoHLm1.js → improvement-cycle-CO2HRCQq.js} +10 -10
- package/dist/improvement-cycle-CO2HRCQq.js.map +1 -0
- package/dist/{index-CU2mlMfc.d.ts → index-D2ipSqkP.d.ts} +4335 -3055
- package/dist/index.d.ts +7 -451
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +9 -3
- package/dist/intelligence.js +13 -7
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +4 -4
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-cC16EPUq.js → loop-runner-bin-B9MIq9O7.js} +3 -3
- package/dist/{loop-runner-bin-cC16EPUq.js.map → loop-runner-bin-B9MIq9O7.js.map} +1 -1
- package/dist/{loop-runner-bin-XKZXM08Q.d.ts → loop-runner-bin-ThlwVkvo.d.ts} +3 -3
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +12 -6
- package/dist/mcp/index.js +7 -7
- package/dist/mcp/memory-bin.js +1 -1
- package/dist/{memory-server-Cn8LbAxO.js → memory-server-DXQ8IxGR.js} +2 -2
- package/dist/{memory-server-Cn8LbAxO.js.map → memory-server-DXQ8IxGR.js.map} +1 -1
- package/dist/{openai-tools-D3ajI_D2.d.ts → openai-tools-Bb0mAr5z.d.ts} +2 -2
- package/dist/{prepare-oHUQdC5-.js → prepare-DVlvGP7V.js} +2 -2
- package/dist/{prepare-oHUQdC5-.js.map → prepare-DVlvGP7V.js.map} +1 -1
- package/dist/profiles.d.ts +2 -2
- package/dist/{protected-model-port-DqF0qDU6.js → protected-model-port-BrWgsCnl.js} +2 -2
- package/dist/{protected-model-port-DqF0qDU6.js.map → protected-model-port-BrWgsCnl.js.map} +1 -1
- package/dist/{protected-redaction--F3v1oo8.js → protected-redaction-DylCC_ot.js} +14 -20
- package/dist/protected-redaction-DylCC_ot.js.map +1 -0
- package/dist/{provision-supervisor-Bf_bPaCv.js → provision-supervisor-BKAvsDtP.js} +3 -3
- package/dist/{provision-supervisor-Bf_bPaCv.js.map → provision-supervisor-BKAvsDtP.js.map} +1 -1
- package/dist/{runtime-hOLlAc1i.js → runtime-CHxXrUeZ.js} +1714 -854
- package/dist/runtime-CHxXrUeZ.js.map +1 -0
- package/dist/{server-DOb67ohd.js → server-2OeFrEVG.js} +4 -4
- package/dist/{server-DOb67ohd.js.map → server-2OeFrEVG.js.map} +1 -1
- package/dist/{stream-agent-turn-Gw9hLpBn.d.ts → stream-agent-turn-ewm3BZAp.d.ts} +34 -17
- package/dist/{structural-rollout-DV9YoQF6.js → structural-rollout-DCUprNpH.js} +2 -2
- package/dist/{structural-rollout-DV9YoQF6.js.map → structural-rollout-DCUprNpH.js.map} +1 -1
- package/dist/{substrate-CLt9S9ym.d.ts → substrate-VKjmrksz.d.ts} +2 -2
- package/dist/{supervise--njTtSL3.js → supervise-Dej5aSDa.js} +220 -52
- package/dist/supervise-Dej5aSDa.js.map +1 -0
- package/dist/{supervisor-B8UMAXya.js → supervisor-DdKPGluv.js} +1233 -303
- package/dist/supervisor-DdKPGluv.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +62 -62
- package/dist/testing.js.map +1 -1
- package/dist/{tool-server-x9NEhvHZ.js → tool-server-Dqer2M4_.js} +30 -12
- package/dist/tool-server-Dqer2M4_.js.map +1 -0
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{types-CrnwLVYQ.d.ts → types-DMRc3jru.d.ts} +463 -105
- package/package.json +6 -5
- package/dist/coordination-driver-DdZ-nh_4.js.map +0 -1
- package/dist/graph-CK50N9vG.js.map +0 -1
- package/dist/improvement-cycle-GRPoHLm1.js.map +0 -1
- package/dist/protected-redaction--F3v1oo8.js.map +0 -1
- package/dist/runtime-hOLlAc1i.js.map +0 -1
- package/dist/supervise--njTtSL3.js.map +0 -1
- package/dist/supervisor-B8UMAXya.js.map +0 -1
- package/dist/tool-server-x9NEhvHZ.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ai as readCommittedJsonLines, Bi as providerAttemptEvidence, E as failedItems, Ea as unmeteredSpend, En as isTerminalNodeStatus, It as FileResultBlobStore, Lt as FileSpawnJournal, M as withDriverExecutor, Pt as createRouterTranscript, Qi as detachedFrozen, Qt as workerTraceAnalysisStore, Rt as InMemoryResultBlobStore, Tn as isLiveNodeStatus, Zt as parseWorkerToolTraceArtifact, _ as CheckUnavailableError, at as scopeRetainedOwnerResourceReader, ba as promptCacheTokenClasses, c as runTree, gn as createInbox, ha as chargedTokens, i as bestDelivered, ja as withBudgetResources, ji as writeAllBytes, ka as addResourceSpend, ki as prepareJsonlAppend, kt as createExecutorRegistry, o as pickBestDelivered, qn as runBrainLoop, s as runFinalizer, tn as assertValidBudget, ur as errMessage, ut as resolveSpawnResourcePaths, wr as resolveRedactor, x as checkVerdictOf, xn as createPeerMailbox, z as meterRuntimeOwnedProviderAttempt, zt as InMemorySpawnJournal } from "./supervisor-DdKPGluv.js";
|
|
2
2
|
import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
3
|
import { A as writeWorkerCancellation, M as writeWorkerSteerAcknowledgement, b as workerCancellationsDir, c as readWorkerCancelRequests, d as readWorkerSteerRequests, k as writeRunCancellation, l as readWorkerCancellation, o as readRunCancelRequest, r as claimWorkerSteerDelivery, s as readRunCancellation, u as readWorkerSteerAcknowledgement } from "./run-layout-vwd4SwX_.js";
|
|
4
4
|
import { agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
|
|
@@ -532,6 +532,7 @@ const coordinationVerbNames = [
|
|
|
532
532
|
"submit_result",
|
|
533
533
|
"stop",
|
|
534
534
|
"report_blocked",
|
|
535
|
+
"read_continuation",
|
|
535
536
|
"read_journal",
|
|
536
537
|
"list_analysts",
|
|
537
538
|
"run_analyst",
|
|
@@ -901,6 +902,19 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
901
902
|
let driverAttempt;
|
|
902
903
|
let journalReadTo = 0;
|
|
903
904
|
let lastRejection;
|
|
905
|
+
const checkReads = [];
|
|
906
|
+
const recordCheckRead = (read) => {
|
|
907
|
+
const entry = detachedFrozen({
|
|
908
|
+
read: checkReads.length + 1,
|
|
909
|
+
attempt: driverAttempt ?? 1,
|
|
910
|
+
at: Date.now(),
|
|
911
|
+
source: read.source,
|
|
912
|
+
...read.verdict === void 0 ? {} : { verdict: read.verdict },
|
|
913
|
+
...read.unavailable === void 0 ? {} : { unavailable: read.unavailable }
|
|
914
|
+
});
|
|
915
|
+
checkReads.push(entry);
|
|
916
|
+
return entry;
|
|
917
|
+
};
|
|
904
918
|
const flushedAnalystRuns = /* @__PURE__ */ new Set();
|
|
905
919
|
const eventWorker = (event) => event.type === "settled" ? event.worker.id : event.type === "finding" ? event.finding.fromWorker : event.type === "question" ? event.question.from : void 0;
|
|
906
920
|
const acknowledge = async (targets, by) => {
|
|
@@ -1848,7 +1862,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
1848
1862
|
const tools = [
|
|
1849
1863
|
{
|
|
1850
1864
|
name: "spawn_worker",
|
|
1851
|
-
description: "Start a worker the driver will drive. `profile` is the worker or another driver; `task` is what it should do. Reserves budget from the conserved pool and fails closed. Pass an optional `budget` (per-field) to give a hard sub-task more than the default — it merges over the per-worker default; the conserved pool is still the hard fence. When every worker slot is busy, or the pool cannot cover the budget until your running workers return what they hold, the worker is admitted with `status: \"queued\"` and starts on its own when a slot and its budget free — it is never refused for concurrency, so spawn all the work you want done and await_event for the results. A queued worker whose budget never frees settles down as budget-exhausted. Pass a `key` naming the assignment to make it run-once ACROSS restarts: a key that already completed returns the finished result (`resumed: \"completed\"` — no work re-runs, nothing is spent), a key whose prior attempt failed (`down`) spawns fresh and says so (`resumed: \"retried\"`), and a key with no terminal receipt is refused (`error: \"in-doubt\"`) until its exact prior execution is recovered. A key still running is refused (`error: \"duplicate-key\"`). Returns `freeSlots`: how many MORE workers start at once (`null` = no slot bound), and `queued`: how many of your workers wait for a slot. Parallel workers finish the run sooner than one at a time." + (profileTable === void 0 ? "" : " This run has a profiles table: pass `profile` as one of the table's names to run that exact profile, or write a new profile under a name the table does not hold."),
|
|
1865
|
+
description: "Start a worker the driver will drive. `profile` is the worker or another driver; `task` is what it should do. Reserves budget from the conserved pool and fails closed. Pass an optional `budget` (per-field) to give a hard sub-task more than the default — it merges over the per-worker default; the conserved pool is still the hard fence. When every worker slot is busy, or the pool cannot cover the budget until your running workers return what they hold, the worker is admitted with `status: \"queued\"` and starts on its own when a slot and its budget free — it is never refused for concurrency, so spawn all the work you want done and await_event for the results. A queued worker whose budget never frees settles down as budget-exhausted. Pass a `key` naming the assignment to make it run-once ACROSS restarts: a key that already completed returns the finished result (`resumed: \"completed\"` — no work re-runs, nothing is spent), a key whose prior attempt failed (`down`) spawns fresh and says so (`resumed: \"retried\"`), and a key the process died with IN FLIGHT retries under the same key when the executor provably died with the process (an inline worker — the same `resumed: \"retried\"`, naming the interruption). A key with no terminal receipt whose execution may still exist elsewhere (sandbox, CLI bridge, router) is refused (`error: \"in-doubt\"`) until its exact prior execution is recovered. A key still running is refused (`error: \"duplicate-key\"`). Returns `freeSlots`: how many MORE workers start at once (`null` = no slot bound), and `queued`: how many of your workers wait for a slot. Parallel workers finish the run sooner than one at a time." + (profileTable === void 0 ? "" : " This run has a profiles table: pass `profile` as one of the table's names to run that exact profile, or write a new profile under a name the table does not hold."),
|
|
1852
1866
|
inputSchema: {
|
|
1853
1867
|
type: "object",
|
|
1854
1868
|
properties: {
|
|
@@ -2463,24 +2477,23 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2463
2477
|
};
|
|
2464
2478
|
}
|
|
2465
2479
|
const result = structuredClone(a.result);
|
|
2466
|
-
let
|
|
2467
|
-
let
|
|
2480
|
+
let verdict;
|
|
2481
|
+
let fault;
|
|
2468
2482
|
try {
|
|
2469
|
-
|
|
2483
|
+
verdict = checkVerdictOf(await deliverable.check(result));
|
|
2470
2484
|
} catch (error) {
|
|
2471
|
-
|
|
2472
|
-
|
|
2485
|
+
fault = {
|
|
2486
|
+
unavailable: error instanceof CheckUnavailableError,
|
|
2487
|
+
message: error instanceof Error ? error.message : String(error)
|
|
2488
|
+
};
|
|
2473
2489
|
}
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
}
|
|
2481
|
-
diagnosticError = error instanceof Error ? error.message : String(error);
|
|
2482
|
-
}
|
|
2483
|
-
const refusal = thrown === void 0 ? `the independent check did not pass on this result${explanation ? `. ${explanation}` : deliverable.describe ? `. Expected: ${deliverable.describe}` : ""}` : `the independent check THREW, so nothing was accepted: ${thrown}. This is a fault in the check, not necessarily in your result — report it rather than resubmitting unchanged`;
|
|
2490
|
+
const read = recordCheckRead({
|
|
2491
|
+
source: "submit",
|
|
2492
|
+
...verdict === void 0 ? {} : { verdict },
|
|
2493
|
+
...fault === void 0 ? {} : { unavailable: fault.message }
|
|
2494
|
+
});
|
|
2495
|
+
if (verdict === void 0 || !verdict.pass) {
|
|
2496
|
+
const refusal = verdict !== void 0 ? refusalText(verdict, deliverable, read.read) : fault?.unavailable === true ? `the check could not run, so this result was not judged (check read ${read.read}): ${fault.message}` : `the independent check THREW, so nothing was accepted (check read ${read.read}): ${fault?.message}. This is a fault in the check, not necessarily in your result — report it rather than resubmitting unchanged`;
|
|
2484
2497
|
lastRejection = {
|
|
2485
2498
|
at: Date.now(),
|
|
2486
2499
|
reason: refusal
|
|
@@ -2489,7 +2502,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2489
2502
|
accepted: false,
|
|
2490
2503
|
stop: false,
|
|
2491
2504
|
reason: refusal,
|
|
2492
|
-
|
|
2505
|
+
checkRead: read.read
|
|
2493
2506
|
};
|
|
2494
2507
|
}
|
|
2495
2508
|
if (submitted) return {
|
|
@@ -2529,7 +2542,7 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2529
2542
|
};
|
|
2530
2543
|
}
|
|
2531
2544
|
}] : [],
|
|
2532
|
-
{
|
|
2545
|
+
...deliverable ? [] : [{
|
|
2533
2546
|
name: "stop",
|
|
2534
2547
|
description: "Declare the run complete.",
|
|
2535
2548
|
inputSchema: {
|
|
@@ -2562,7 +2575,25 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2562
2575
|
notifyStop();
|
|
2563
2576
|
return Promise.resolve({ stopped: true });
|
|
2564
2577
|
}
|
|
2565
|
-
},
|
|
2578
|
+
}],
|
|
2579
|
+
...opts.readContinuation ? [{
|
|
2580
|
+
name: "read_continuation",
|
|
2581
|
+
description: ["Read a continuation note in full: the note, every line of the check's verdict, and", "the question panel's answers. Omit continuation for the latest."].join(" "),
|
|
2582
|
+
inputSchema: {
|
|
2583
|
+
type: "object",
|
|
2584
|
+
properties: { continuation: {
|
|
2585
|
+
type: "integer",
|
|
2586
|
+
minimum: 1,
|
|
2587
|
+
description: "Which continuation, 1-based. Omit for the latest."
|
|
2588
|
+
} },
|
|
2589
|
+
additionalProperties: false
|
|
2590
|
+
},
|
|
2591
|
+
handler: async (raw) => {
|
|
2592
|
+
const value = obj(raw).continuation;
|
|
2593
|
+
if (value !== void 0 && (!Number.isInteger(value) || value < 1)) throw new Error("read_continuation: \"continuation\" must be an integer >= 1");
|
|
2594
|
+
return opts.readContinuation?.(value);
|
|
2595
|
+
}
|
|
2596
|
+
}] : [],
|
|
2566
2597
|
{
|
|
2567
2598
|
name: "report_blocked",
|
|
2568
2599
|
description: [
|
|
@@ -2919,9 +2950,31 @@ function createCoordinationToolsForManager(opts, lifetime) {
|
|
|
2919
2950
|
});
|
|
2920
2951
|
},
|
|
2921
2952
|
blocked: () => blockedEvidence,
|
|
2953
|
+
checkReads: () => checkReads,
|
|
2954
|
+
recordCheckRead,
|
|
2922
2955
|
...peerMail ? { peerMail } : {}
|
|
2923
2956
|
};
|
|
2924
2957
|
}
|
|
2958
|
+
/**
|
|
2959
|
+
* The refusal a failed check reading returns to `submit_result`: the verdict as a located fact,
|
|
2960
|
+
* the FAIL lines unless the check's tests must stay hidden, and how many times the manager has
|
|
2961
|
+
* read the check.
|
|
2962
|
+
*/
|
|
2963
|
+
function refusalText(verdict, deliverable, read) {
|
|
2964
|
+
const total = Object.keys(verdict.items ?? {}).length;
|
|
2965
|
+
const failed = failedItems(verdict).length;
|
|
2966
|
+
const score = verdict.composite === void 0 ? "" : ` (composite ${verdict.composite}${verdict.threshold === void 0 ? "" : `, passes at ${verdict.threshold}`})`;
|
|
2967
|
+
const head = total > 0 ? `The outside check failed: ${failed} of ${total} items fail${score}. Check read ${read}.` : `The outside check failed${score}. Check read ${read}.`;
|
|
2968
|
+
if (deliverable.feedback === "pass-only") return head;
|
|
2969
|
+
const lines = verdict.failures ?? [];
|
|
2970
|
+
if (lines.length === 0) return deliverable.describe ? `${head} Expected: ${deliverable.describe}` : head;
|
|
2971
|
+
const shown = lines.slice(0, 40);
|
|
2972
|
+
return [
|
|
2973
|
+
head,
|
|
2974
|
+
...shown,
|
|
2975
|
+
...lines.length > shown.length ? [`${lines.length - shown.length} more failure lines.`] : []
|
|
2976
|
+
].join("\n");
|
|
2977
|
+
}
|
|
2925
2978
|
/** The verbs `report_blocked` never calls on a manager's behalf: each one changes the run. */
|
|
2926
2979
|
const unprobeableVerbs = /* @__PURE__ */ new Set([
|
|
2927
2980
|
"submit_result",
|
|
@@ -2995,7 +3048,7 @@ function applyRunCancellation(dir, abortRun, now, path = "turn-boundary") {
|
|
|
2995
3048
|
return record;
|
|
2996
3049
|
}
|
|
2997
3050
|
/** External drivers may remain silent indefinitely, so turn boundaries cannot observe control. */
|
|
2998
|
-
function watchRunCancellation(dir, abortRun) {
|
|
3051
|
+
function watchRunCancellation(dir, abortRun, createWatch = watch) {
|
|
2999
3052
|
mkdirSync(workerCancellationsDir(dir), { recursive: true });
|
|
3000
3053
|
let active = true;
|
|
3001
3054
|
let failure;
|
|
@@ -3008,15 +3061,21 @@ function watchRunCancellation(dir, abortRun) {
|
|
|
3008
3061
|
failure = error;
|
|
3009
3062
|
abortRun(`durable run cancellation observer failed: ${String(error)}`);
|
|
3010
3063
|
};
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3064
|
+
let watcher;
|
|
3065
|
+
try {
|
|
3066
|
+
watcher = createWatch(workerCancellationsDir(dir), (_event, filename) => {
|
|
3067
|
+
if (!active || filename !== null && filename !== "run.request.json") return;
|
|
3068
|
+
try {
|
|
3069
|
+
check();
|
|
3070
|
+
} catch (error) {
|
|
3071
|
+
fail(error);
|
|
3072
|
+
}
|
|
3073
|
+
});
|
|
3074
|
+
} catch (error) {
|
|
3075
|
+
const code = error.code;
|
|
3076
|
+
if (code !== "EMFILE" && code !== "ENOSPC") throw error;
|
|
3077
|
+
}
|
|
3078
|
+
watcher?.on("error", fail);
|
|
3020
3079
|
const fallback = setInterval(() => {
|
|
3021
3080
|
try {
|
|
3022
3081
|
check("fallback");
|
|
@@ -3029,7 +3088,7 @@ function watchRunCancellation(dir, abortRun) {
|
|
|
3029
3088
|
check,
|
|
3030
3089
|
close() {
|
|
3031
3090
|
active = false;
|
|
3032
|
-
watcher
|
|
3091
|
+
watcher?.close();
|
|
3033
3092
|
clearInterval(fallback);
|
|
3034
3093
|
}
|
|
3035
3094
|
};
|
|
@@ -3090,63 +3149,67 @@ var FileCoordinationLog = class {
|
|
|
3090
3149
|
}
|
|
3091
3150
|
}
|
|
3092
3151
|
async load(runId, ownerId) {
|
|
3093
|
-
|
|
3094
|
-
const findings = [];
|
|
3095
|
-
const escalations = [];
|
|
3096
|
-
const analystDefinitions = [];
|
|
3097
|
-
const continuations = [];
|
|
3098
|
-
const deliveryEvidence = [];
|
|
3099
|
-
const mail = [];
|
|
3100
|
-
const records = [];
|
|
3101
|
-
let legacySeq = 0;
|
|
3102
|
-
for await (const stored of readCommittedJsonLines(this.path, { allowMissing: true })) {
|
|
3103
|
-
if (stored.runId !== runId) continue;
|
|
3104
|
-
if (ownerId !== void 0 && stored.ownerId !== ownerId) continue;
|
|
3105
|
-
const record = "seq" in stored ? {
|
|
3106
|
-
seq: stored.seq,
|
|
3107
|
-
at: stored.at,
|
|
3108
|
-
priority: stored.priority,
|
|
3109
|
-
event: stored.event
|
|
3110
|
-
} : {
|
|
3111
|
-
seq: legacySeq++,
|
|
3112
|
-
at: Date.parse(stored.at),
|
|
3113
|
-
priority: 0,
|
|
3114
|
-
event: stored.event
|
|
3115
|
-
};
|
|
3116
|
-
records.push(record);
|
|
3117
|
-
const ev = record.event;
|
|
3118
|
-
if (ev.type === "delivery-attempt" || ev.type === "steer" || ev.type === "answer") deliveryEvidence.push(ev);
|
|
3119
|
-
if (ev.type === "question") byId.set(ev.question.id, ev.question);
|
|
3120
|
-
else if (ev.type === "finding") findings.push(ev.finding);
|
|
3121
|
-
else if (ev.type === "answer") {
|
|
3122
|
-
const prior = byId.get(ev.questionId);
|
|
3123
|
-
if (prior && ev.down.delivered) byId.set(ev.questionId, {
|
|
3124
|
-
...prior,
|
|
3125
|
-
status: "answered",
|
|
3126
|
-
decision: {
|
|
3127
|
-
kind: "answer",
|
|
3128
|
-
answer: ev.down.instruction,
|
|
3129
|
-
by: "prior-run"
|
|
3130
|
-
}
|
|
3131
|
-
});
|
|
3132
|
-
} else if (ev.type === "instruction") continuations.push(ev.instruction);
|
|
3133
|
-
else if (ev.type === "mail") mail.push(ev.mail);
|
|
3134
|
-
else if (ev.type === "escalation") escalations.push(ev.escalation);
|
|
3135
|
-
else if (ev.type === "analyst-defined") analystDefinitions.push(ev.analyst);
|
|
3136
|
-
}
|
|
3137
|
-
return {
|
|
3138
|
-
...ownerId !== void 0 ? { ownerId } : {},
|
|
3139
|
-
questions: [...byId.values()],
|
|
3140
|
-
findings,
|
|
3141
|
-
escalations,
|
|
3142
|
-
analystDefinitions,
|
|
3143
|
-
continuations,
|
|
3144
|
-
deliveryEvidence,
|
|
3145
|
-
mail,
|
|
3146
|
-
records
|
|
3147
|
-
};
|
|
3152
|
+
return foldCoordinationRecords(readCommittedJsonLines(this.path, { allowMissing: true }), runId, ownerId);
|
|
3148
3153
|
}
|
|
3149
3154
|
};
|
|
3155
|
+
/** @internal Shared replay semantics for file and SQL coordination evidence. */
|
|
3156
|
+
async function foldCoordinationRecords(source, runId, ownerId) {
|
|
3157
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3158
|
+
const findings = [];
|
|
3159
|
+
const escalations = [];
|
|
3160
|
+
const analystDefinitions = [];
|
|
3161
|
+
const continuations = [];
|
|
3162
|
+
const deliveryEvidence = [];
|
|
3163
|
+
const mail = [];
|
|
3164
|
+
const records = [];
|
|
3165
|
+
let legacySeq = 0;
|
|
3166
|
+
for await (const stored of source) {
|
|
3167
|
+
if (stored.runId !== runId) continue;
|
|
3168
|
+
if (ownerId !== void 0 && stored.ownerId !== ownerId) continue;
|
|
3169
|
+
const record = "seq" in stored ? {
|
|
3170
|
+
seq: stored.seq,
|
|
3171
|
+
at: stored.at,
|
|
3172
|
+
priority: stored.priority,
|
|
3173
|
+
event: stored.event
|
|
3174
|
+
} : {
|
|
3175
|
+
seq: legacySeq++,
|
|
3176
|
+
at: Date.parse(stored.at),
|
|
3177
|
+
priority: 0,
|
|
3178
|
+
event: stored.event
|
|
3179
|
+
};
|
|
3180
|
+
records.push(record);
|
|
3181
|
+
const ev = record.event;
|
|
3182
|
+
if (ev.type === "delivery-attempt" || ev.type === "steer" || ev.type === "answer") deliveryEvidence.push(ev);
|
|
3183
|
+
if (ev.type === "question") byId.set(ev.question.id, ev.question);
|
|
3184
|
+
else if (ev.type === "finding") findings.push(ev.finding);
|
|
3185
|
+
else if (ev.type === "answer") {
|
|
3186
|
+
const prior = byId.get(ev.questionId);
|
|
3187
|
+
if (prior && ev.down.delivered) byId.set(ev.questionId, {
|
|
3188
|
+
...prior,
|
|
3189
|
+
status: "answered",
|
|
3190
|
+
decision: {
|
|
3191
|
+
kind: "answer",
|
|
3192
|
+
answer: ev.down.instruction,
|
|
3193
|
+
by: "prior-run"
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
} else if (ev.type === "instruction") continuations.push(ev.instruction);
|
|
3197
|
+
else if (ev.type === "mail") mail.push(ev.mail);
|
|
3198
|
+
else if (ev.type === "escalation") escalations.push(ev.escalation);
|
|
3199
|
+
else if (ev.type === "analyst-defined") analystDefinitions.push(ev.analyst);
|
|
3200
|
+
}
|
|
3201
|
+
return {
|
|
3202
|
+
...ownerId !== void 0 ? { ownerId } : {},
|
|
3203
|
+
questions: [...byId.values()],
|
|
3204
|
+
findings,
|
|
3205
|
+
escalations,
|
|
3206
|
+
analystDefinitions,
|
|
3207
|
+
continuations,
|
|
3208
|
+
deliveryEvidence,
|
|
3209
|
+
mail,
|
|
3210
|
+
records
|
|
3211
|
+
};
|
|
3212
|
+
}
|
|
3150
3213
|
//#endregion
|
|
3151
3214
|
//#region src/runtime/supervise/run-context.ts
|
|
3152
3215
|
/**
|
|
@@ -3174,6 +3237,18 @@ var FileCoordinationLog = class {
|
|
|
3174
3237
|
*
|
|
3175
3238
|
* @experimental
|
|
3176
3239
|
*/
|
|
3240
|
+
/** Hold a run context's ownership (when it has any) across the whole run, releasing after. */
|
|
3241
|
+
async function withRunContext(context, signal, run) {
|
|
3242
|
+
if (context.acquire === void 0) return run(context, signal);
|
|
3243
|
+
const lease = await context.acquire(signal);
|
|
3244
|
+
try {
|
|
3245
|
+
const result = await run(lease.context, signal === void 0 ? lease.signal : AbortSignal.any([signal, lease.signal]));
|
|
3246
|
+
lease.signal.throwIfAborted();
|
|
3247
|
+
return result;
|
|
3248
|
+
} finally {
|
|
3249
|
+
await lease.release();
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3177
3252
|
/**
|
|
3178
3253
|
* Build a fresh in-memory run context. Every call returns NEW stores (no shared global
|
|
3179
3254
|
* state between runs), so two runs never cross-contaminate their journals/blobs.
|
|
@@ -4049,11 +4124,13 @@ function driverAgent(opts) {
|
|
|
4049
4124
|
const maxTurns = opts.maxTurns ?? 16;
|
|
4050
4125
|
const now = opts.now ?? Date.now;
|
|
4051
4126
|
const inbox = opts.inbox ?? createInbox();
|
|
4127
|
+
const transcript = opts.transcript ?? createRouterTranscript();
|
|
4052
4128
|
return {
|
|
4053
4129
|
name: opts.name,
|
|
4054
4130
|
deliver(message) {
|
|
4055
4131
|
return inbox.deliver(message);
|
|
4056
4132
|
},
|
|
4133
|
+
harnessTranscript: () => transcript.capture(),
|
|
4057
4134
|
async act(task, scope) {
|
|
4058
4135
|
const ownerReader = opts.spawnResourceReader ?? (opts.spawnResourceRoot === void 0 ? scopeRetainedOwnerResourceReader(scope) : void 0);
|
|
4059
4136
|
let probeableByName;
|
|
@@ -4148,7 +4225,7 @@ function driverAgent(opts) {
|
|
|
4148
4225
|
let progressStopReason;
|
|
4149
4226
|
let driverTurn = 0;
|
|
4150
4227
|
let driverCall = 0;
|
|
4151
|
-
const meteredBrain = async (messages, tools, detail) => {
|
|
4228
|
+
const meteredBrain = async (messages, tools, detail, conversationTurn) => {
|
|
4152
4229
|
let res;
|
|
4153
4230
|
const call = driverCall;
|
|
4154
4231
|
driverCall += 1;
|
|
@@ -4209,16 +4286,19 @@ function driverAgent(opts) {
|
|
|
4209
4286
|
...res.promptCache !== void 0 ? { promptCache: res.promptCache } : {},
|
|
4210
4287
|
...res.usageUnknown === true ? { streamUsageMissing: true } : {},
|
|
4211
4288
|
...res.costProvenance === "catalog-estimate" ? { estimatedCostUsd: res.costUsd } : {},
|
|
4212
|
-
...detail
|
|
4289
|
+
...detail,
|
|
4290
|
+
...conversationTurn ? { conversation: conversationTurn(res) } : {}
|
|
4213
4291
|
});
|
|
4214
4292
|
if (evidenceError !== void 0) throw evidenceError;
|
|
4215
4293
|
return res;
|
|
4216
4294
|
};
|
|
4217
4295
|
const chat = async (messages, tools) => {
|
|
4296
|
+
const turn = driverTurn;
|
|
4297
|
+
transcript.observe(messages);
|
|
4218
4298
|
const res = await meteredBrain(messages, tools, {
|
|
4219
4299
|
kind: "driver-inference",
|
|
4220
|
-
turn
|
|
4221
|
-
});
|
|
4300
|
+
turn
|
|
4301
|
+
}, (reply) => transcript.reply(reply));
|
|
4222
4302
|
driverTurn += 1;
|
|
4223
4303
|
return res;
|
|
4224
4304
|
};
|
|
@@ -4282,6 +4362,7 @@ function driverAgent(opts) {
|
|
|
4282
4362
|
role: "user",
|
|
4283
4363
|
content: inbox.fold(pending)
|
|
4284
4364
|
});
|
|
4365
|
+
transcript.observe(messages);
|
|
4285
4366
|
},
|
|
4286
4367
|
stopBefore: () => {
|
|
4287
4368
|
if (coord.isStopped() || scope.signal.aborted || poolStarved(scope, opts.perWorker, opts.preserveOwnerTurns) || deadlinePassed(scope, now)) return true;
|
|
@@ -4413,6 +4494,6 @@ function safeJson(v) {
|
|
|
4413
4494
|
}
|
|
4414
4495
|
}
|
|
4415
4496
|
//#endregion
|
|
4416
|
-
export {
|
|
4497
|
+
export { createCoordinationTools as A, applyRunCancellation as C, analystToolGroupNames as D, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as E, questionEscalationTargets as F, createEventBus as I, defaultToolDetectors as L, downMessageRefusalReasons as M, normalizeAnalyzeOnSettle as N, canonicalFindingEvent as O, parseAuthoredAnalystDefinition as P, watchTrace as R, foldCoordinationRecords as S, ANALYST_DEFINITION_BOUNDS as T, renderAnytimeTable as _, allOf as a, withRunContext as b, createProgressTracker as c, progressStop as d, sampleFromSettled as f, plateauLength as g, bestSoFar as h, finalizeBestDelivered as i, createCoordinationToolsForManager as j, coordinationVerbNames as k, noProgressFor as l, areaUnderCurve as m, createSteerAcknowledger as n, allWorkersStalled as o, anytimeReport as p, driverAgent as r, anyOf as s, createCancelAcknowledger as t, plateau as u, createFileRunContext as v, watchRunCancellation as w, FileCoordinationLog as x, createInMemoryRunContext as y };
|
|
4417
4498
|
|
|
4418
|
-
//# sourceMappingURL=coordination-driver-
|
|
4499
|
+
//# sourceMappingURL=coordination-driver-CkcW4dxU.js.map
|