@tangle-network/agent-runtime 0.240.0 → 0.246.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-C6d-NTWk.js} +3 -3
- package/dist/{activation-q224yRQK.js.map → activation-C6d-NTWk.js.map} +1 -1
- package/dist/{activation-CtkpoWet.d.ts → activation-Df-ae5Uq.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-De8pyM57.js} +18 -10
- package/dist/coordination-driver-De8pyM57.js.map +1 -0
- package/dist/{delegate-kwBecu_w.js → delegate-DE6hNhbD.js} +2 -2
- package/dist/{delegate-kwBecu_w.js.map → delegate-DE6hNhbD.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-s57f-VCR.js} +3 -3
- package/dist/{graph-Bke7I2gs.js.map → graph-s57f-VCR.js.map} +1 -1
- package/dist/{improvement-cycle-BpSVwIJw.js → improvement-cycle-BE3gIJwL.js} +458 -60
- package/dist/improvement-cycle-BE3gIJwL.js.map +1 -0
- package/dist/{index-CbZaoYbD.d.ts → index-CAG31NtK.d.ts} +7 -7
- 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 +3 -3
- package/dist/intelligence.js +9 -6
- 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-B_oSVrE7.d.ts} +3 -3
- package/dist/{loop-runner-bin-DU8XqsGN.js → loop-runner-bin-Bp8Mih20.js} +3 -3
- package/dist/{loop-runner-bin-DU8XqsGN.js.map → loop-runner-bin-Bp8Mih20.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-B1GMKDjW.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-D0X9KUv-.js} +5 -5
- package/dist/{provision-supervisor-DoSrqsM7.js.map → provision-supervisor-D0X9KUv-.js.map} +1 -1
- package/dist/{run-layout-hZREkcfu.js → run-layout-B8-Gqhpg.js} +2 -2
- package/dist/{run-layout-hZREkcfu.js.map → run-layout-B8-Gqhpg.js.map} +1 -1
- package/dist/{runtime-CmuAQsWI.js → runtime-CHbVv5UI.js} +16 -13
- package/dist/{runtime-CmuAQsWI.js.map → runtime-CHbVv5UI.js.map} +1 -1
- package/dist/{server-shkdLqls.js → server-DwsC_FyV.js} +3 -3
- package/dist/{server-shkdLqls.js.map → server-DwsC_FyV.js.map} +1 -1
- package/dist/{stream-agent-turn-DayHmtvw.d.ts → stream-agent-turn-DQ-W8mHf.d.ts} +2 -2
- package/dist/{structural-rollout-CW67upUV.js → structural-rollout-DasmuuUp.js} +2 -2
- package/dist/{structural-rollout-CW67upUV.js.map → structural-rollout-DasmuuUp.js.map} +1 -1
- package/dist/{substrate-iQOskmQ_.d.ts → substrate-DJOnuoa_.d.ts} +2 -2
- package/dist/{supervise-DzoCYAe-.js → supervise-o6CzD2Rt.js} +142 -35
- package/dist/supervise-o6CzD2Rt.js.map +1 -0
- package/dist/{supervisor-CFSPj8rx.js → supervisor-tGq-TPIv.js} +161 -103
- package/dist/supervisor-tGq-TPIv.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-DL-sjv7K.js} +2 -2
- package/dist/{top-app-CMMd8DgR.js.map → top-app-DL-sjv7K.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-BoEzH8V6.d.ts} +3 -2
- 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/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-BoEzH8V6.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-DJOnuoa_.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-tGq-TPIv.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-De8pyM57.js";
|
|
8
|
+
import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-B8-Gqhpg.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,71 @@ 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(deps);
|
|
1391
|
+
const cancellations = createCancelAcknowledger(deps);
|
|
1392
|
+
let active = true;
|
|
1393
|
+
let timer;
|
|
1394
|
+
let steering = false;
|
|
1395
|
+
let inFlight = Promise.resolve();
|
|
1396
|
+
let failure;
|
|
1397
|
+
let closing;
|
|
1398
|
+
const stop = () => {
|
|
1399
|
+
active = false;
|
|
1400
|
+
clearInterval(timer);
|
|
1401
|
+
signal.removeEventListener("abort", stop);
|
|
1402
|
+
};
|
|
1403
|
+
const fail = (error) => {
|
|
1404
|
+
failure = { error };
|
|
1405
|
+
stop();
|
|
1406
|
+
onError(error);
|
|
1407
|
+
};
|
|
1408
|
+
const poll = () => {
|
|
1409
|
+
if (!active) return;
|
|
1410
|
+
try {
|
|
1411
|
+
cancellations.pass("turn");
|
|
1412
|
+
if (steering) return;
|
|
1413
|
+
steering = true;
|
|
1414
|
+
inFlight = steers.pass("turn").catch(fail).finally(() => {
|
|
1415
|
+
steering = false;
|
|
1416
|
+
});
|
|
1417
|
+
} catch (error) {
|
|
1418
|
+
fail(error);
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
1422
|
+
if (signal.aborted) stop();
|
|
1423
|
+
else {
|
|
1424
|
+
timer = setInterval(poll, 100);
|
|
1425
|
+
timer.unref();
|
|
1426
|
+
poll();
|
|
1427
|
+
}
|
|
1428
|
+
const finish = async () => {
|
|
1429
|
+
stop();
|
|
1430
|
+
await inFlight;
|
|
1431
|
+
try {
|
|
1432
|
+
await steers.pass("final");
|
|
1433
|
+
cancellations.pass("final");
|
|
1434
|
+
} finally {
|
|
1435
|
+
cancellations.finish();
|
|
1436
|
+
}
|
|
1437
|
+
if (failure) throw failure.error;
|
|
1438
|
+
};
|
|
1439
|
+
return { close: () => closing ??= finish() };
|
|
1440
|
+
}
|
|
1441
|
+
//#endregion
|
|
1360
1442
|
//#region src/runtime/supervise/supervisor-agent.ts
|
|
1361
1443
|
/**
|
|
1362
1444
|
* `supervisorAgent` — build a supervisor `Agent` FROM its profile. The brain is resolved from
|
|
@@ -1646,6 +1728,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1646
1728
|
const nodeTools = resolveTools && context ? await bindSupervisorTools(resolveTools, context, scope.signal, slot) : void 0;
|
|
1647
1729
|
const nodeObserver = bindSupervisorNodeObserver(context, observeNodeEvent, deps.onEvent);
|
|
1648
1730
|
const stopController = new AbortController();
|
|
1731
|
+
const coordinationLifetime = linkAbort(scope.signal);
|
|
1649
1732
|
const tracker = deps.stopRule ? createProgressTracker({ now: Date.now }) : void 0;
|
|
1650
1733
|
let progressStopReason;
|
|
1651
1734
|
let ledger;
|
|
@@ -1660,7 +1743,7 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1660
1743
|
deps.onProgressStop?.(decision.reason);
|
|
1661
1744
|
if (!stopController.signal.aborted) stopController.abort(decision.reason);
|
|
1662
1745
|
} : nodeObserver;
|
|
1663
|
-
const mcp = await
|
|
1746
|
+
const { handle: mcp, controls } = await serveCoordinationMcpForManager({
|
|
1664
1747
|
scope,
|
|
1665
1748
|
blobs: deps.blobs,
|
|
1666
1749
|
makeWorkerAgent: deps.makeWorkerAgent,
|
|
@@ -1682,7 +1765,11 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1682
1765
|
...deps.watchWorkers ? { watchWorkers: deps.watchWorkers } : {},
|
|
1683
1766
|
...deps.stallAfterMs !== void 0 ? { stallAfterMs: deps.stallAfterMs } : {},
|
|
1684
1767
|
...deps.continuityByProfile ? { continuityByProfile: deps.continuityByProfile } : {},
|
|
1685
|
-
|
|
1768
|
+
onEvent: async (event, record) => {
|
|
1769
|
+
await runAbortable(async () => {
|
|
1770
|
+
await onEvent?.(event, record);
|
|
1771
|
+
}, coordinationLifetime.signal, "supervisor coordination stopped");
|
|
1772
|
+
},
|
|
1686
1773
|
...deps.replaySettlements ? { replaySettlements: true } : {},
|
|
1687
1774
|
...deps.preflightSpawn ? { preflightSpawn: deps.preflightSpawn } : {},
|
|
1688
1775
|
...deps.resolveSpawnProfile ? { resolveSpawnProfile: deps.resolveSpawnProfile } : {},
|
|
@@ -1696,11 +1783,26 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1696
1783
|
...nodeTools?.length ? { nodeTools } : {},
|
|
1697
1784
|
toolNames: runtimeToolNames,
|
|
1698
1785
|
onCoordinationTools: (tools) => slot.bind(tools)
|
|
1786
|
+
}, coordinationLifetime.signal).catch((error) => {
|
|
1787
|
+
coordinationLifetime.abort(error);
|
|
1788
|
+
throw error;
|
|
1699
1789
|
});
|
|
1700
1790
|
ledger = mcp;
|
|
1701
1791
|
const coordinationTools = slot.descriptors();
|
|
1702
1792
|
const providerProfile = detachedSnapshot(providerVisibleProfile(stableProfile), "supervisorAgent provider-visible profile");
|
|
1793
|
+
let controlObserver;
|
|
1703
1794
|
try {
|
|
1795
|
+
if (deps.controlDir !== void 0) controlObserver = observeWorkerControls({
|
|
1796
|
+
dir: deps.controlDir,
|
|
1797
|
+
coord: controls,
|
|
1798
|
+
scope,
|
|
1799
|
+
signal: coordinationLifetime.signal,
|
|
1800
|
+
controlScope: deps.controlScope ?? "run",
|
|
1801
|
+
onError: (error) => {
|
|
1802
|
+
coordinationLifetime.abort(error);
|
|
1803
|
+
stopController.abort(error);
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1704
1806
|
const recoveredSubmission = mcp.submittedResult();
|
|
1705
1807
|
if (recoveredSubmission) {
|
|
1706
1808
|
deps.onAcceptedSubmission?.(recoveredSubmission.result);
|
|
@@ -1777,7 +1879,12 @@ function buildSupervisorAgent(profile, deps, testBrain) {
|
|
|
1777
1879
|
}
|
|
1778
1880
|
return contractDeclared ? candidate : await finalize();
|
|
1779
1881
|
} finally {
|
|
1780
|
-
|
|
1882
|
+
coordinationLifetime.abort(/* @__PURE__ */ new Error("supervisor manager stopped"));
|
|
1883
|
+
try {
|
|
1884
|
+
await controlObserver?.close();
|
|
1885
|
+
} finally {
|
|
1886
|
+
await mcp.close();
|
|
1887
|
+
}
|
|
1781
1888
|
}
|
|
1782
1889
|
}
|
|
1783
1890
|
};
|
|
@@ -3700,4 +3807,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
|
|
|
3700
3807
|
//#endregion
|
|
3701
3808
|
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
3809
|
|
|
3703
|
-
//# sourceMappingURL=supervise-
|
|
3810
|
+
//# sourceMappingURL=supervise-o6CzD2Rt.js.map
|