@tangle-network/agent-runtime 0.240.0 → 0.247.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activation-q224yRQK.js → activation-DYqnl8zq.js} +3 -3
- package/dist/{activation-q224yRQK.js.map → activation-DYqnl8zq.js.map} +1 -1
- package/dist/{activation-CtkpoWet.d.ts → activation-DizpINK3.d.ts} +115 -5
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +2 -2
- package/dist/candidate-execution/index.js +7 -7
- package/dist/candidate-execution/index.js.map +1 -1
- package/dist/{coordination-driver-CMprWr0k.js → coordination-driver-BV4AAUns.js} +35 -14
- package/dist/coordination-driver-BV4AAUns.js.map +1 -0
- package/dist/{delegate-kwBecu_w.js → delegate-DQAzB5Xv.js} +2 -2
- package/dist/{delegate-kwBecu_w.js.map → delegate-DQAzB5Xv.js.map} +1 -1
- package/dist/{durable-file-D24y9zg7.js → durable-file-DWQA4ooo.js} +2 -2
- package/dist/{durable-file-D24y9zg7.js.map → durable-file-DWQA4ooo.js.map} +1 -1
- package/dist/durable.d.ts +2 -2
- package/dist/durable.js +3 -3
- package/dist/{graph-Bke7I2gs.js → graph-DcBmMLIp.js} +3 -3
- package/dist/{graph-Bke7I2gs.js.map → graph-DcBmMLIp.js.map} +1 -1
- package/dist/{improvement-cycle-BpSVwIJw.js → improvement-cycle-B049YmQ8.js} +458 -60
- package/dist/improvement-cycle-B049YmQ8.js.map +1 -0
- package/dist/{index-CbZaoYbD.d.ts → index-DLzlXwr6.d.ts} +14 -9
- package/dist/index.d.ts +11 -8
- package/dist/index.js +27 -17
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +7 -5
- package/dist/intelligence.js +15 -11
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +3 -3
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-BUkkPt10.d.ts → loop-runner-bin-HbMECmxT.d.ts} +3 -3
- package/dist/{loop-runner-bin-DU8XqsGN.js → loop-runner-bin-iqq1azfy.js} +3 -3
- package/dist/{loop-runner-bin-DU8XqsGN.js.map → loop-runner-bin-iqq1azfy.js.map} +1 -1
- 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 +5 -5
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-BI1ofIfL.d.ts → openai-tools-DvLk_Ddg.d.ts} +2 -2
- package/dist/{prepare-Dc30WRB0.js → prepare-CibQrhfi.js} +28 -28
- package/dist/prepare-CibQrhfi.js.map +1 -0
- package/dist/profiles.d.ts +2 -2
- package/dist/{protected-model-port-D5gDcnrH.js → protected-model-port-Dhdi5mDl.js} +3 -3
- package/dist/{protected-model-port-D5gDcnrH.js.map → protected-model-port-Dhdi5mDl.js.map} +1 -1
- package/dist/{protected-redaction-wGo44k2K.js → protected-redaction-Fn1ETfJ-.js} +6 -6
- package/dist/protected-redaction-Fn1ETfJ-.js.map +1 -0
- package/dist/{provision-supervisor-DoSrqsM7.js → provision-supervisor-BgQx2Avp.js} +5 -5
- package/dist/{provision-supervisor-DoSrqsM7.js.map → provision-supervisor-BgQx2Avp.js.map} +1 -1
- package/dist/{run-layout-hZREkcfu.js → run-layout-hKAJGF4g.js} +7 -2
- package/dist/run-layout-hKAJGF4g.js.map +1 -0
- package/dist/{runtime-CmuAQsWI.js → runtime-HpTXhB3g.js} +16 -13
- package/dist/{runtime-CmuAQsWI.js.map → runtime-HpTXhB3g.js.map} +1 -1
- package/dist/{server-shkdLqls.js → server-OOE7mXrN.js} +3 -3
- package/dist/{server-shkdLqls.js.map → server-OOE7mXrN.js.map} +1 -1
- package/dist/{stream-agent-turn-DayHmtvw.d.ts → stream-agent-turn-CcumM0Bu.d.ts} +2 -2
- package/dist/{structural-rollout-CW67upUV.js → structural-rollout-z1A0okaB.js} +2 -2
- package/dist/{structural-rollout-CW67upUV.js.map → structural-rollout-z1A0okaB.js.map} +1 -1
- package/dist/{substrate-iQOskmQ_.d.ts → substrate-CQ0hfewn.d.ts} +2 -2
- package/dist/{supervise-DzoCYAe-.js → supervise-DZEOpzRw.js} +148 -35
- package/dist/supervise-DZEOpzRw.js.map +1 -0
- package/dist/{supervisor-CFSPj8rx.js → supervisor-BIBWUFUr.js} +325 -150
- package/dist/supervisor-BIBWUFUr.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +398 -398
- package/dist/{top-app-CMMd8DgR.js → top-app-d-bmwO7O.js} +2 -2
- package/dist/{top-app-CMMd8DgR.js.map → top-app-d-bmwO7O.js.map} +1 -1
- package/dist/tui/bin.js +1 -1
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-CEma9LKR.d.ts → types-BUhz284C.d.ts} +25 -11
- package/dist/{workspace-archive-CBX0hwL_.js → workspace-archive-DSRT4Tro.js} +8 -8
- package/dist/workspace-archive-DSRT4Tro.js.map +1 -0
- package/package.json +6 -6
- package/dist/coordination-driver-CMprWr0k.js.map +0 -1
- package/dist/improvement-cycle-BpSVwIJw.js.map +0 -1
- package/dist/prepare-Dc30WRB0.js.map +0 -1
- package/dist/protected-redaction-wGo44k2K.js.map +0 -1
- package/dist/run-layout-hZREkcfu.js.map +0 -1
- package/dist/supervise-DzoCYAe-.js.map +0 -1
- package/dist/supervisor-CFSPj8rx.js.map +0 -1
- package/dist/workspace-archive-CBX0hwL_.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ur as Driver, Vr as AgentRunSpec, hi as Validator, ui as OutputAdapter } from "./types-
|
|
1
|
+
import { Ur as Driver, Vr as AgentRunSpec, hi as Validator, ui as OutputAdapter } from "./types-BUhz284C.js";
|
|
2
2
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
|
3
3
|
//#region src/profiles/coder.d.ts
|
|
4
4
|
/**
|
|
@@ -281,4 +281,4 @@ interface UiFinding {
|
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
export { CoderTask as _, UiFindingSeverity as a, KnowledgeUpdate as c, ResearchSource as d, ResearchTask as f, researcherProfile as g, multiHarnessResearcherFanout as h, UiFindingScreenshot as i, MultiHarnessResearcherFanoutOptions as l, createResearcherValidator as m, UI_LENSES as n, UiLens as o, ResearcherProfileOptions as p, UiFinding as r, KnowledgeItem as s, UI_FINDING_SEVERITIES as t, ResearchOutput as u, coderTaskToPrompt as v };
|
|
284
|
-
//# sourceMappingURL=substrate-
|
|
284
|
+
//# sourceMappingURL=substrate-CQ0hfewn.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $n as contentAddress, Bn as linkAbort, Br as
|
|
1
|
+
import { $i as withBudgetResources, $n as contentAddress, Bn as linkAbort, Br as promptControlProfileMaterialization, C as restoreScopeOwnerAcceptedExecution, Cn as routerBrain, F as prepareScopeRetainedOwnerTask, Fr as assertProfileMaterialization, Ft as newUsageTotals, Gr as renderUnsupported, I as scopeRetainedOwnerContext, Ii as addSpend, In as registerRetainedExecutorPreparation, Ir as controlProfileMaterialization, Ji as unmeteredSpend, L as scopeRetainedOwnerPriorSpend, Ln as retainedExecutorSeamKey, Lr as defineProfileMaterializationContract, Lt as spendFromUsageTotals, M as bindScopeRetainedOwnerEnvironmentId, Mt as assertValidBudget, N as bindScopeRetainedOwnerProvider, P as consumeScopeRetainedOwnerResult, Pt as meterUsageEvent, Qi as resourceTelemetry, Qr as readCommittedJsonLines, R as scopeRetainedOwnerResourceReader, Rn as RunCancellationReason, Rr as fullProfileMaterialization, Rt as WORKER_TRACE_PROPAGATION, S as recordScopeOwnerMaterialization, Vn as runAbortable, Vr as promptModelProfileMaterialization, Wi as sleep, Xi as zeroSpend, Xr as isNoEntError, Yi as withTimeout, Yr as worktreeCliProfileMaterialization, Zi as addResourceSpend, Zr as prepareJsonlAppend, _ as beginScopeOwnerAttempt, aa as teardownExecutor, an as bridgeAdmissionRefusal, b as meterRuntimeOwnedAccounting, ci as providerAttemptEvidence, d as defaultUnmetContractSteer, di as runtimeOwnedExecutorExecutionBinding, dn as bridgeRuntimeAttachmentsKey, f as runDriverWithRetry, fi as runtimeOwnedExecutorMaterialization, fn as bridgeStopSignalKey, fr as generateSpanId, ft as snapshotExecutorConfig, gr as toOtelAttributes, h as isDriverSpec, hi as runtimeOwnedScopeOwnerRuntime, ii as inheritRuntimeOwnedExecutorAttestation, in as executorFailure, jn as resolveAgentEnvironmentProvider, l as HarnessTurnFailedError, li as recordRuntimeOwnedDriveHarnessProviderEvidence, lr as createOtelExporter, m as driverExecutorFactory, mi as runtimeOwnedPendingExecutorMaterialization, n as createSupervisor, o as runFinalizer, on as bridgeModelRouteRefusal, ot as bindReusableExecutorExecutionId, p as driverChild, pi as runtimeOwnedExecutorProviderEvidence, qr as unsupportedProfileDimensions, qt as createInbox, r as bestDelivered, ra as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, s as runTree, st as captureReusableExecutorConfig, t as createRootHandle, ti as attestRuntimeOwnedScopeOwner, tt as errMessage, ui as runtimeOwnedDriveHarnessProviderEvidence, ut as createExecutor, w as scopeOwnerExecutorNodeContext, x as meterRuntimeOwnedProviderAttempt, xi as detachedSnapshot, y as deriveNodeExecutionIdentity, z as scopeRetainedOwnerResult, zr as profileMaterializationAxes$1 } from "./supervisor-BIBWUFUr.js";
|
|
2
2
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
3
|
import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
|
|
4
4
|
import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
|
|
5
|
-
import { n as assertNoSymlinkDescendant } from "./durable-file-
|
|
5
|
+
import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
|
|
6
6
|
import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-x9NEhvHZ.js";
|
|
7
|
-
import { D as coordinationVerbNames,
|
|
8
|
-
import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-
|
|
7
|
+
import { D as coordinationVerbNames, S as watchRunCancellation, c as createProgressTracker, d as progressStop, k as createCoordinationToolsForManager, n as createSteerAcknowledger, r as driverAgent, t as createCancelAcknowledger, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-BV4AAUns.js";
|
|
8
|
+
import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-hKAJGF4g.js";
|
|
9
9
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
10
10
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
11
11
|
import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
|
|
@@ -597,6 +597,10 @@ function coordinationResponseFenceMs(requestTimeoutMs) {
|
|
|
597
597
|
}
|
|
598
598
|
/** Stand up the existing coordination tools with bounded HTTP access over one live scope. */
|
|
599
599
|
async function serveCoordinationMcp(opts) {
|
|
600
|
+
return (await serveCoordinationMcpForManager(opts)).handle;
|
|
601
|
+
}
|
|
602
|
+
/** Runtime-only binding: operator controls stay off the public MCP handle and tool grants. */
|
|
603
|
+
async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
600
604
|
const host = opts.host ?? "127.0.0.1";
|
|
601
605
|
assertCoordinationTransport(opts);
|
|
602
606
|
const requestTimeoutMs = coordinationHttpLimits(opts).requestTimeoutMs;
|
|
@@ -666,7 +670,7 @@ async function serveCoordinationMcp(opts) {
|
|
|
666
670
|
const audiences = /* @__PURE__ */ new Set();
|
|
667
671
|
const paths = /* @__PURE__ */ new Set(["/mcp"]);
|
|
668
672
|
const ownerReader = opts.spawnResourceReader ?? (opts.spawnResourceRoot === void 0 ? scopeRetainedOwnerResourceReader(opts.scope) : void 0);
|
|
669
|
-
const coord =
|
|
673
|
+
const coord = createCoordinationToolsForManager({
|
|
670
674
|
scope: opts.scope,
|
|
671
675
|
blobs: opts.blobs,
|
|
672
676
|
makeWorkerAgent: opts.makeWorkerAgent,
|
|
@@ -694,7 +698,7 @@ async function serveCoordinationMcp(opts) {
|
|
|
694
698
|
...opts.spawnResourceRoot ? { spawnResourceRoot: opts.spawnResourceRoot } : {},
|
|
695
699
|
...ownerReader ? { spawnResourceReader: ownerReader } : {},
|
|
696
700
|
...opts.peerMail ? { peerMail: typeof opts.peerMail === "object" && opts.peerMail.limits ? { limits: opts.peerMail.limits } : {} } : {}
|
|
697
|
-
});
|
|
701
|
+
}, lifetime);
|
|
698
702
|
await coord.ready();
|
|
699
703
|
const reservedNames = new Set(coord.tools.map((tool) => tool.name));
|
|
700
704
|
for (const tool of opts.nodeTools ?? []) {
|
|
@@ -746,6 +750,14 @@ async function serveCoordinationMcp(opts) {
|
|
|
746
750
|
resolve(typeof addr === "object" && addr ? addr.port : opts.port ?? 0);
|
|
747
751
|
});
|
|
748
752
|
});
|
|
753
|
+
const addressLifetime = new AbortController();
|
|
754
|
+
const abortAddress = () => addressLifetime.abort(opts.scope.signal.reason);
|
|
755
|
+
opts.scope.signal.addEventListener("abort", abortAddress, { once: true });
|
|
756
|
+
if (opts.scope.signal.aborted) abortAddress();
|
|
757
|
+
const releaseAddress = () => {
|
|
758
|
+
opts.scope.signal.removeEventListener("abort", abortAddress);
|
|
759
|
+
if (!addressLifetime.signal.aborted) addressLifetime.abort(/* @__PURE__ */ new Error("coordination listener closed"));
|
|
760
|
+
};
|
|
749
761
|
const localUrl = `http://${host.includes(":") && !host.startsWith("[") ? `[${host}]` : host}:${port}/mcp`;
|
|
750
762
|
let url;
|
|
751
763
|
try {
|
|
@@ -754,7 +766,7 @@ async function serveCoordinationMcp(opts) {
|
|
|
754
766
|
host,
|
|
755
767
|
port,
|
|
756
768
|
...identity,
|
|
757
|
-
signal:
|
|
769
|
+
signal: addressLifetime.signal
|
|
758
770
|
}), opts.scope.signal, "coordination public address resolution aborted") : resolver;
|
|
759
771
|
const publicAddress = new URL(configured ?? localUrl);
|
|
760
772
|
if (!["http:", "https:"].includes(publicAddress.protocol) || publicAddress.username || publicAddress.password || publicAddress.search || publicAddress.hash) throw new ConfigError("coordination publicUrl must be an HTTP endpoint without credentials, query, or fragment");
|
|
@@ -774,6 +786,7 @@ async function serveCoordinationMcp(opts) {
|
|
|
774
786
|
toolNames: selectedNames
|
|
775
787
|
});
|
|
776
788
|
} catch (error) {
|
|
789
|
+
releaseAddress();
|
|
777
790
|
closed = true;
|
|
778
791
|
await new Promise((resolve) => {
|
|
779
792
|
server.close(() => resolve());
|
|
@@ -784,31 +797,35 @@ async function serveCoordinationMcp(opts) {
|
|
|
784
797
|
const mailbox = coord.peerMail;
|
|
785
798
|
const mailListener = mailbox === void 0 ? void 0 : await servePeerMail(mailbox, host);
|
|
786
799
|
return {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
800
|
+
handle: {
|
|
801
|
+
url,
|
|
802
|
+
port,
|
|
803
|
+
get headers() {
|
|
804
|
+
return headers;
|
|
805
|
+
},
|
|
806
|
+
get credentialExpiresAt() {
|
|
807
|
+
return credentialExpiresAt;
|
|
808
|
+
},
|
|
809
|
+
rotateCredential,
|
|
810
|
+
settled: () => coord.settled(),
|
|
811
|
+
submittedResult: () => coord.submittedResult(),
|
|
812
|
+
drainResolved: () => coord.drainResolved(),
|
|
813
|
+
isStopped: () => coord.isStopped(),
|
|
814
|
+
history: () => coord.history(),
|
|
815
|
+
stats: () => coord.stats(),
|
|
816
|
+
raiseFinding: (finding) => coord.raiseFinding(finding),
|
|
817
|
+
mailHistory: () => mailbox?.history() ?? [],
|
|
818
|
+
stopMailThread: (threadId) => mailbox?.stopThread(threadId) ?? false,
|
|
819
|
+
close: async () => {
|
|
820
|
+
releaseAddress();
|
|
821
|
+
closed = true;
|
|
822
|
+
await new Promise((resolve) => {
|
|
823
|
+
server.close(() => resolve());
|
|
824
|
+
});
|
|
825
|
+
await mailListener?.close();
|
|
826
|
+
}
|
|
794
827
|
},
|
|
795
|
-
|
|
796
|
-
settled: () => coord.settled(),
|
|
797
|
-
submittedResult: () => coord.submittedResult(),
|
|
798
|
-
drainResolved: () => coord.drainResolved(),
|
|
799
|
-
isStopped: () => coord.isStopped(),
|
|
800
|
-
history: () => coord.history(),
|
|
801
|
-
stats: () => coord.stats(),
|
|
802
|
-
raiseFinding: (finding) => coord.raiseFinding(finding),
|
|
803
|
-
mailHistory: () => mailbox?.history() ?? [],
|
|
804
|
-
stopMailThread: (threadId) => mailbox?.stopThread(threadId) ?? false,
|
|
805
|
-
close: async () => {
|
|
806
|
-
closed = true;
|
|
807
|
-
await new Promise((resolve) => {
|
|
808
|
-
server.close(() => resolve());
|
|
809
|
-
});
|
|
810
|
-
await mailListener?.close();
|
|
811
|
-
}
|
|
828
|
+
controls: coord
|
|
812
829
|
};
|
|
813
830
|
}
|
|
814
831
|
/**
|
|
@@ -1357,6 +1374,74 @@ function errorMessage(error) {
|
|
|
1357
1374
|
return error instanceof Error ? error.message : String(error);
|
|
1358
1375
|
}
|
|
1359
1376
|
//#endregion
|
|
1377
|
+
//#region src/runtime/supervise/worker-control-observer.ts
|
|
1378
|
+
/** Observe durable worker controls while the native harness owns the manager's turn loop. */
|
|
1379
|
+
function observeWorkerControls(options) {
|
|
1380
|
+
const { dir, coord, scope, signal, controlScope, onError } = options;
|
|
1381
|
+
const deps = {
|
|
1382
|
+
dir,
|
|
1383
|
+
coord,
|
|
1384
|
+
scope,
|
|
1385
|
+
signal,
|
|
1386
|
+
now: Date.now,
|
|
1387
|
+
ownerId: scope.view.root,
|
|
1388
|
+
controlScope
|
|
1389
|
+
};
|
|
1390
|
+
const steers = createSteerAcknowledger({
|
|
1391
|
+
...deps,
|
|
1392
|
+
deliverRoot: options.deliverRoot
|
|
1393
|
+
});
|
|
1394
|
+
const cancellations = createCancelAcknowledger(deps);
|
|
1395
|
+
let active = true;
|
|
1396
|
+
let timer;
|
|
1397
|
+
let steering = false;
|
|
1398
|
+
let inFlight = Promise.resolve();
|
|
1399
|
+
let failure;
|
|
1400
|
+
let closing;
|
|
1401
|
+
const stop = () => {
|
|
1402
|
+
active = false;
|
|
1403
|
+
clearInterval(timer);
|
|
1404
|
+
signal.removeEventListener("abort", stop);
|
|
1405
|
+
};
|
|
1406
|
+
const fail = (error) => {
|
|
1407
|
+
failure = { error };
|
|
1408
|
+
stop();
|
|
1409
|
+
onError(error);
|
|
1410
|
+
};
|
|
1411
|
+
const poll = () => {
|
|
1412
|
+
if (!active) return;
|
|
1413
|
+
try {
|
|
1414
|
+
cancellations.pass("turn");
|
|
1415
|
+
if (steering) return;
|
|
1416
|
+
steering = true;
|
|
1417
|
+
inFlight = steers.pass("turn").catch(fail).finally(() => {
|
|
1418
|
+
steering = false;
|
|
1419
|
+
});
|
|
1420
|
+
} catch (error) {
|
|
1421
|
+
fail(error);
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
1425
|
+
if (signal.aborted) stop();
|
|
1426
|
+
else {
|
|
1427
|
+
timer = setInterval(poll, 100);
|
|
1428
|
+
timer.unref();
|
|
1429
|
+
poll();
|
|
1430
|
+
}
|
|
1431
|
+
const finish = async () => {
|
|
1432
|
+
stop();
|
|
1433
|
+
await inFlight;
|
|
1434
|
+
try {
|
|
1435
|
+
await steers.pass("final");
|
|
1436
|
+
cancellations.pass("final");
|
|
1437
|
+
} finally {
|
|
1438
|
+
cancellations.finish();
|
|
1439
|
+
}
|
|
1440
|
+
if (failure) throw failure.error;
|
|
1441
|
+
};
|
|
1442
|
+
return { close: () => closing ??= finish() };
|
|
1443
|
+
}
|
|
1444
|
+
//#endregion
|
|
1360
1445
|
//#region src/runtime/supervise/supervisor-agent.ts
|
|
1361
1446
|
/**
|
|
1362
1447
|
* `supervisorAgent` — build a supervisor `Agent` FROM its profile. The brain is resolved from
|
|
@@ -1646,6 +1731,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1646
1731
|
const nodeTools = resolveTools && context ? await bindSupervisorTools(resolveTools, context, scope.signal, slot) : void 0;
|
|
1647
1732
|
const nodeObserver = bindSupervisorNodeObserver(context, observeNodeEvent, deps.onEvent);
|
|
1648
1733
|
const stopController = new AbortController();
|
|
1734
|
+
const coordinationLifetime = linkAbort(scope.signal);
|
|
1649
1735
|
const tracker = deps.stopRule ? createProgressTracker({ now: Date.now }) : void 0;
|
|
1650
1736
|
let progressStopReason;
|
|
1651
1737
|
let ledger;
|
|
@@ -1660,7 +1746,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1660
1746
|
deps.onProgressStop?.(decision.reason);
|
|
1661
1747
|
if (!stopController.signal.aborted) stopController.abort(decision.reason);
|
|
1662
1748
|
} : nodeObserver;
|
|
1663
|
-
const mcp = await
|
|
1749
|
+
const { handle: mcp, controls } = await serveCoordinationMcpForManager({
|
|
1664
1750
|
scope,
|
|
1665
1751
|
blobs: deps.blobs,
|
|
1666
1752
|
makeWorkerAgent: deps.makeWorkerAgent,
|
|
@@ -1682,7 +1768,11 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1682
1768
|
...deps.watchWorkers ? { watchWorkers: deps.watchWorkers } : {},
|
|
1683
1769
|
...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {},
|
|
1684
1770
|
...deps.continuityByProfile ? { continuityByProfile: deps.continuityByProfile } : {},
|
|
1685
|
-
|
|
1771
|
+
onEvent: async (event, record) => {
|
|
1772
|
+
await runAbortable(async () => {
|
|
1773
|
+
await onEvent?.(event, record);
|
|
1774
|
+
}, coordinationLifetime.signal, "supervisor coordination stopped");
|
|
1775
|
+
},
|
|
1686
1776
|
...deps.replaySettlements ? { replaySettlements: true } : {},
|
|
1687
1777
|
...deps.preflightSpawn ? { preflightSpawn: deps.preflightSpawn } : {},
|
|
1688
1778
|
...deps.resolveSpawnProfile ? { resolveSpawnProfile: deps.resolveSpawnProfile } : {},
|
|
@@ -1696,11 +1786,27 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1696
1786
|
...nodeTools?.length ? { nodeTools } : {},
|
|
1697
1787
|
toolNames: runtimeToolNames,
|
|
1698
1788
|
onCoordinationTools: (tools) => slot.bind(tools)
|
|
1789
|
+
}, coordinationLifetime.signal).catch((error) => {
|
|
1790
|
+
coordinationLifetime.abort(error);
|
|
1791
|
+
throw error;
|
|
1699
1792
|
});
|
|
1700
1793
|
ledger = mcp;
|
|
1701
1794
|
const coordinationTools = slot.descriptors();
|
|
1702
1795
|
const providerProfile = detachedSnapshot(providerVisibleProfile(stableProfile), "supervisorAgent provider-visible profile");
|
|
1796
|
+
let controlObserver;
|
|
1703
1797
|
try {
|
|
1798
|
+
if (deps.controlDir !== void 0) controlObserver = observeWorkerControls({
|
|
1799
|
+
dir: deps.controlDir,
|
|
1800
|
+
coord: controls,
|
|
1801
|
+
scope,
|
|
1802
|
+
signal: coordinationLifetime.signal,
|
|
1803
|
+
controlScope: deps.controlScope ?? "run",
|
|
1804
|
+
...deps.controlScope === "subtree" ? {} : { deliverRoot: (message) => deliver?.(message) ?? false },
|
|
1805
|
+
onError: (error) => {
|
|
1806
|
+
coordinationLifetime.abort(error);
|
|
1807
|
+
stopController.abort(error);
|
|
1808
|
+
}
|
|
1809
|
+
});
|
|
1704
1810
|
const recoveredSubmission = mcp.submittedResult();
|
|
1705
1811
|
if (recoveredSubmission) {
|
|
1706
1812
|
deps.onAcceptedSubmission?.(recoveredSubmission.result);
|
|
@@ -1777,7 +1883,12 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1777
1883
|
}
|
|
1778
1884
|
return contractDeclared ? candidate : await finalize();
|
|
1779
1885
|
} finally {
|
|
1780
|
-
|
|
1886
|
+
coordinationLifetime.abort(/* @__PURE__ */ new Error("supervisor manager stopped"));
|
|
1887
|
+
try {
|
|
1888
|
+
await controlObserver?.close();
|
|
1889
|
+
} finally {
|
|
1890
|
+
await mcp.close();
|
|
1891
|
+
}
|
|
1781
1892
|
}
|
|
1782
1893
|
}
|
|
1783
1894
|
};
|
|
@@ -3467,6 +3578,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3467
3578
|
replaySettlements: true
|
|
3468
3579
|
} : {},
|
|
3469
3580
|
...analysts ? { analysts } : {},
|
|
3581
|
+
...options.escalateQuestion ? { escalateQuestion: options.escalateQuestion } : {},
|
|
3470
3582
|
...options.analyzeOnSettle ? { analyzeOnSettle: options.analyzeOnSettle } : {},
|
|
3471
3583
|
...options.watchWorkers ? { watchWorkers: options.watchWorkers } : {},
|
|
3472
3584
|
...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
|
|
@@ -3570,6 +3682,7 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
3570
3682
|
...options.extraTools ? { extraTools: options.extraTools } : {},
|
|
3571
3683
|
...options.executeExtraTool ? { executeExtraTool: options.executeExtraTool } : {},
|
|
3572
3684
|
...analysts ? { analysts } : {},
|
|
3685
|
+
...options.escalateQuestion ? { escalateQuestion: options.escalateQuestion } : {},
|
|
3573
3686
|
...options.analyzeOnSettle ? { analyzeOnSettle: options.analyzeOnSettle } : {},
|
|
3574
3687
|
...options.watchWorkers ? { watchWorkers: options.watchWorkers } : {},
|
|
3575
3688
|
...options.stallAfterMs !== void 0 ? { stallAfterMs: options.stallAfterMs } : {},
|
|
@@ -3700,4 +3813,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
|
|
|
3700
3813
|
//#endregion
|
|
3701
3814
|
export { createSupervisorSpanRecorder as _, isPreSpawnExecutorFailure as a, mapExecutorResult as b, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, readRootStreamReceipt as g, readRootStream as h, workerFromBackend as i, assertCoordinationBinding as l, ROOT_STREAM_FILE as m, supervise as n, resolveWorkerSpawnRetry as o, supervisorAgentWithTestBrain as p, superviseWithTestBrain as r, retryPreSpawnRefusals as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, coordinationProfileToolPrefix as u, serveCoordinationMcp as v, gateOnDeliverable as y };
|
|
3702
3815
|
|
|
3703
|
-
//# sourceMappingURL=supervise-
|
|
3816
|
+
//# sourceMappingURL=supervise-DZEOpzRw.js.map
|