@tangle-network/agent-runtime 0.321.0 → 0.322.4
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-BxOOvwjo.d.ts → activation-Bw6S7lI1.d.ts} +2 -2
- package/dist/{activation-CXFl5YVE.js → activation-ClHYiUF-.js} +2 -2
- package/dist/{activation-CXFl5YVE.js.map → activation-ClHYiUF-.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{coordination-driver-Bpn05N-Y.js → coordination-driver-xq1y2G6E.js} +69 -2
- package/dist/coordination-driver-xq1y2G6E.js.map +1 -0
- package/dist/{delegate-BHlcTOdK.js → delegate-C9dMTZ8s.js} +2 -2
- package/dist/{delegate-BHlcTOdK.js.map → delegate-C9dMTZ8s.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +2 -2
- package/dist/{graph-DE2dLhDI.js → graph-DLgIEaDB.js} +4 -4
- package/dist/{graph-DE2dLhDI.js.map → graph-DLgIEaDB.js.map} +1 -1
- package/dist/{improvement-cycle-CyChbojL.js → improvement-cycle-C0N4tt1G.js} +3 -3
- package/dist/{improvement-cycle-CyChbojL.js.map → improvement-cycle-C0N4tt1G.js.map} +1 -1
- package/dist/{index-BxiHetnG.d.ts → index-BE5-_p0B.d.ts} +638 -543
- package/dist/index.d.ts +4 -4
- package/dist/index.js +7 -7
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +22 -6
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +9 -9
- package/dist/{loop-runner-bin-CT02Vzco.js → loop-runner-bin-B4QRhI5z.js} +3 -3
- package/dist/{loop-runner-bin-CT02Vzco.js.map → loop-runner-bin-B4QRhI5z.js.map} +1 -1
- package/dist/{loop-runner-bin-DInJZNgs.d.ts → loop-runner-bin-DeT99QWD.d.ts} +2 -2
- 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 +2 -2
- package/dist/mcp/index.js +4 -4
- package/dist/{openai-tools-DLTw576v.d.ts → openai-tools-C80KeWl4.d.ts} +2 -2
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-DvgBNtoJ.js → provision-supervisor-C40ye4h2.js} +3 -3
- package/dist/{provision-supervisor-DvgBNtoJ.js.map → provision-supervisor-C40ye4h2.js.map} +1 -1
- package/dist/{runtime-wLgjMOaj.js → runtime-zv5GK0m4.js} +77 -12
- package/dist/runtime-zv5GK0m4.js.map +1 -0
- package/dist/{search-executor-TEKWC579.js → search-executor-BtJktjPt.js} +2 -2
- package/dist/{search-executor-TEKWC579.js.map → search-executor-BtJktjPt.js.map} +1 -1
- package/dist/{server-qYhzITTm.js → server-DNnLa4KU.js} +3 -3
- package/dist/{server-qYhzITTm.js.map → server-DNnLa4KU.js.map} +1 -1
- package/dist/{supervise-C4bLIU7J.js → supervise-DLezpJcp.js} +172 -123
- package/dist/supervise-DLezpJcp.js.map +1 -0
- package/dist/{supervisor-bkq2b8k-.js → supervisor-dlufUXys.js} +268 -42
- package/dist/supervisor-dlufUXys.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +12 -12
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +4 -4
- package/skills/profile-authoring/SKILL.md +4 -3
- package/dist/coordination-driver-Bpn05N-Y.js.map +0 -1
- package/dist/runtime-wLgjMOaj.js.map +0 -1
- package/dist/supervise-C4bLIU7J.js.map +0 -1
- package/dist/supervisor-bkq2b8k-.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $i as
|
|
1
|
+
import { $i as runtimeOwnedExecutorMaterialization, A as scopeOwnerExecutorNodeContext, Ai as promptControlProfileMaterialization, An as resolveAgentEnvironmentProvider, Ar as persistHarnessTranscript, At as captureReusableExecutorConfig, B as consumeScopeRetainedOwnerResult, C as deriveNodeExecutionIdentity, Ct as createContinuationKeeper, D as recordScopeOwnerMaterialization, Di as defineProfileMaterializationContract, Dr as runAbortable, E as recordScopeOwnerDriverAttempt, Ei as controlProfileMaterialization, Er as linkAbort, F as seatExecutionProfile, Fi as renderUnsupported, Fn as retainedExecutorSeamKey, Ft as snapshotExecutorConfig, G as scopeRetainedOwnerContext, Gi as inheritRuntimeOwnedExecutorAttestation, H as prepareScopeRetainedOwnerSeatSwitch, Hi as authoredAgentIdentity, I as abandonScopeRetainedOwnerInvocation, J as scopeRetainedOwnerResourceReader, Jn as isNoEntError, Jt as createActivityLog, K as scopeRetainedOwnerJournalRoot, L as beginScopeRetainedOwnerDrive, Li as unsupportedProfileDimensions, M as SeatChain, N as SeatChainExhaustedError, Nt as createExecutor, O as recordScopeOwnerPause, Oi as fullProfileMaterialization, P as authoredSeatStages, Pn as registerRetainedExecutorPreparation, Pr as contentAddress, Qi as runtimeOwnedExecutorExecutionBinding, Qr as createOtelExporter, R as bindScopeRetainedOwnerEnvironmentId, St as checkVerdictOf, T as meterRuntimeOwnedProviderAttempt, U as prepareScopeRetainedOwnerTask, V as noteScopeRetainedOwnerCoordination, Vi as attestRuntimeOwnedScopeOwner, Vt as WORKER_TRACE_PROPAGATION, W as reconcileScopeRetainedOwnerEnvironment, X as scopeRetainedOwnerResult, Xi as recordRuntimeOwnedDriveHarnessProviderEvidence, Xn as readCommittedJsonLines, Xt as createInbox, Y as scopeRetainedOwnerRestorePoint, Yi as providerAttemptEvidence, Yn as prepareJsonlAppend, Z as scopeRetainedOwnerTurnEnded, Zi as runtimeOwnedDriveHarnessProviderEvidence, _ as isDriverSpec, an as isLiveNodeStatus, b as assertRecursiveReservationPolicy, c as runTree, ca as detachedSnapshot, cn as bridgeModelRouteRefusal, cr as meterUsageEvent, dr as spendFromUsageTotals, ea as runtimeOwnedExecutorProviderEvidence, ei as generateSpanId, f as runDriverWithRetry, fr as bridgeRuntimeAttachmentsKey, g as driverExecutorFactory, gt as CONTINUATIONS_DIR, h as driverChild, i as bestDelivered, ii as toOtelAttributes, it as providerVisibleProfile, ji as promptModelProfileMaterialization, jr as readHarnessTranscript, k as restoreScopeOwnerAcceptedExecution, ki as profileMaterializationAxes$1, kt as bindReusableExecutorExecutionId, lr as newUsageTotals, mr as errMessage, mt as gateOnDeliverable, n as createRootHandle, na as runtimeOwnedScopeOwnerRuntime, nt as coordinationMcpAlias, or as assertValidBudget, p as summarizeDriverAttempts, pr as bridgeStopSignalKey, q as scopeRetainedOwnerPriorSpend, r as createSupervisor, rr as executorFailure, rt as coordinationProfileToolPrefix, s as runFinalizer, sn as bridgeAdmissionRefusal, ta as runtimeOwnedPendingExecutorMaterialization, tr as parseWorkerToolTraceArtifact, u as HarnessTurnFailedError, vt as CheckUnavailableError, w as meterRuntimeOwnedAccounting, wi as assertProfileMaterialization, wn as routerBrain, wr as RunCancellationReason, x as beginScopeOwnerAttempt, xt as bestComposite, yt as admitContinuationPolicy, z as bindScopeRetainedOwnerProvider, zi as worktreeCliProfileMaterialization, zt as createRouterTranscript } from "./supervisor-dlufUXys.js";
|
|
2
2
|
import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
|
|
3
3
|
import { Dt as teardownSurfaces, Et as teardownExecutor, V as addSpend, Z as isAsyncIterable$1, ct as withTimeout, dt as addResourceSpend, lt as zeroSpend, mt as withBudgetResources, pt as resourceTelemetry, q as errorMessage, rt as sleep, st as unmeteredSpend, yt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS } from "./workspace-streams-DFAhW7hF.js";
|
|
4
4
|
import { _ as agentHarness, a as concreteProfileModel, c as profileModelExecutionSettings, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CNe257pB.js";
|
|
5
5
|
import { n as assertNoSymlinkDescendant } from "./durable-file-DWQA4ooo.js";
|
|
6
6
|
import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
|
|
7
|
-
import { C as createFileRunContext, F as createCoordinationToolsForManager, N as coordinationVerbNames, O as applyRunCancellation, T as withRunContext, c as refreshedWake, g as progressStop, h as plateau, k as watchRunCancellation, l as resolveWakePolicy, n as createSteerAcknowledger, o as composeWakeInput, p as createProgressTracker, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as createInMemoryRunContext } from "./coordination-driver-
|
|
7
|
+
import { C as createFileRunContext, F as createCoordinationToolsForManager, N as coordinationVerbNames, O as applyRunCancellation, T as withRunContext, c as refreshedWake, g as progressStop, h as plateau, k as watchRunCancellation, l as resolveWakePolicy, n as createSteerAcknowledger, o as composeWakeInput, p as createProgressTracker, r as driverAgent, s as deadlineWarningAt, t as createCancelAcknowledger, w as createInMemoryRunContext } from "./coordination-driver-xq1y2G6E.js";
|
|
8
8
|
import { r as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-Dqer2M4_.js";
|
|
9
9
|
import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-DSCWdbX2.js";
|
|
10
10
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
@@ -14,7 +14,7 @@ import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
|
|
|
14
14
|
import { dirname, resolve } from "node:path";
|
|
15
15
|
import { mkdir } from "node:fs/promises";
|
|
16
16
|
import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
|
|
17
|
-
import { ATTR } from "@tangle-network/agent-trace-contract";
|
|
17
|
+
import { ATTR, agentIdentityAttributes } from "@tangle-network/agent-trace-contract";
|
|
18
18
|
import { createServer } from "node:http";
|
|
19
19
|
import { withProfileKb } from "@tangle-network/agent-interface/profile-kb";
|
|
20
20
|
//#region src/mcp/tools/coordination-request-context.ts
|
|
@@ -523,6 +523,7 @@ function assertCoordinationTransport(options) {
|
|
|
523
523
|
if (!signingKeys.activeKeyId || !Object.hasOwn(signingKeys.keys, signingKeys.activeKeyId)) throw new ConfigError("coordination signingKeys must contain the active key");
|
|
524
524
|
for (const [id, key] of Object.entries(signingKeys.keys)) if (!/^[A-Za-z0-9_-]{1,64}$/.test(id) || typeof key !== "string" || Buffer.byteLength(key) < 32) throw new ConfigError("coordination signing keys require bounded key IDs and at least 32 secret bytes");
|
|
525
525
|
}
|
|
526
|
+
if (options.onReadReady && !options.authentication) throw new ConfigError("coordination read capability publication requires authentication");
|
|
526
527
|
coordinationHttpLimits(options);
|
|
527
528
|
}
|
|
528
529
|
/**
|
|
@@ -556,7 +557,6 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
556
557
|
assertCoordinationTransport(opts);
|
|
557
558
|
const requestTimeoutMs = coordinationHttpLimits(opts).requestTimeoutMs;
|
|
558
559
|
const responseFenceMs = coordinationResponseFenceMs(requestTimeoutMs);
|
|
559
|
-
if (opts.peerMail && (!isLoopbackHost(host) || opts.publicUrl)) throw new ConfigError("remote peer mail requires a separate reachable capability transport; coordination authentication does not authorize the peer listener");
|
|
560
560
|
const identity = Object.freeze({ ...opts.identity ?? {
|
|
561
561
|
runId: opts.scope.view?.root ?? "",
|
|
562
562
|
actorId: opts.scope.view?.root ?? ""
|
|
@@ -567,6 +567,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
567
567
|
activeKeyId: auth.signingKeys.activeKeyId,
|
|
568
568
|
keys: { ...auth.signingKeys.keys }
|
|
569
569
|
} : void 0;
|
|
570
|
+
let readerToken = Buffer.from(randomBytes(32).toString("base64url"));
|
|
570
571
|
let token;
|
|
571
572
|
let credentialExpiresAt;
|
|
572
573
|
let headers = Object.freeze({});
|
|
@@ -596,6 +597,7 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
596
597
|
})).toString("base64url");
|
|
597
598
|
text = `${payload}.${createHmac("sha256", signingKeys.keys[signingKeys.activeKeyId]).update(payload).digest("base64url")}`;
|
|
598
599
|
}
|
|
600
|
+
readerToken = Buffer.from(randomBytes(32).toString("base64url"));
|
|
599
601
|
token = Buffer.from(text);
|
|
600
602
|
headers = Object.freeze({ Authorization: `Bearer ${text}` });
|
|
601
603
|
};
|
|
@@ -698,7 +700,44 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
698
700
|
tools: servedTools
|
|
699
701
|
});
|
|
700
702
|
opts.onCoordinationTools?.([...mcp.tools.values()], coord);
|
|
701
|
-
const
|
|
703
|
+
const authority = (req) => {
|
|
704
|
+
const address = req.socket.localAddress?.replace(/^::ffff:/, "");
|
|
705
|
+
const localAuthority = address?.includes(":") ? `[${address}]:${req.socket.localPort}` : `${address}:${req.socket.localPort}`;
|
|
706
|
+
const boundAuthority = audiences.size > 0 && (host === "0.0.0.0" || host === "::") && address !== void 0 && req.socket.localPort !== void 0 && req.headers.host === localAuthority;
|
|
707
|
+
if (!audiences.has(req.headers.host ?? "") && !boundAuthority) return {
|
|
708
|
+
status: 403,
|
|
709
|
+
reason: "wrong-host"
|
|
710
|
+
};
|
|
711
|
+
if (closed) return {
|
|
712
|
+
status: 401,
|
|
713
|
+
reason: "listener-closed"
|
|
714
|
+
};
|
|
715
|
+
};
|
|
716
|
+
const readMcp = createStdioToolServer({
|
|
717
|
+
serverName: "supervisor-reader",
|
|
718
|
+
serverVersion: "1",
|
|
719
|
+
tools: coord.tools.filter((tool) => tool.name === "observe_agent" || tool.name === "read_journal")
|
|
720
|
+
});
|
|
721
|
+
const readPaths = /* @__PURE__ */ new Set();
|
|
722
|
+
const readHandler = coordinationHttpHandler({
|
|
723
|
+
options: opts,
|
|
724
|
+
identity,
|
|
725
|
+
toolNames: /* @__PURE__ */ new Set(["observe_agent", "read_journal"]),
|
|
726
|
+
backgroundActions: () => 0,
|
|
727
|
+
authorize: (req) => {
|
|
728
|
+
const refused = authority(req);
|
|
729
|
+
if (refused) return refused;
|
|
730
|
+
const supplied = typeof req.headers.authorization === "string" && req.headers.authorization.startsWith("Bearer ") ? Buffer.from(req.headers.authorization.slice(7)) : Buffer.alloc(0);
|
|
731
|
+
if (supplied.length !== readerToken.length || !timingSafeEqual(supplied, readerToken) || credentialExpiresAt !== void 0 && credentialExpiresAt <= Date.now()) return {
|
|
732
|
+
status: 401,
|
|
733
|
+
reason: "credential-refused"
|
|
734
|
+
};
|
|
735
|
+
},
|
|
736
|
+
handle: (message) => readMcp.handle(message)
|
|
737
|
+
});
|
|
738
|
+
const peerHandlers = /* @__PURE__ */ new Map();
|
|
739
|
+
const mailPaths = /* @__PURE__ */ new Set();
|
|
740
|
+
const mainHandler = coordinationHttpHandler({
|
|
702
741
|
options: opts,
|
|
703
742
|
identity,
|
|
704
743
|
toolNames: new Set(servedTools.map((tool) => tool.name)),
|
|
@@ -713,17 +752,8 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
713
752
|
status: 404,
|
|
714
753
|
reason: "unknown-path"
|
|
715
754
|
};
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
const boundAuthority = audiences.size > 0 && (host === "0.0.0.0" || host === "::") && address !== void 0 && req.socket.localPort !== void 0 && req.headers.host === localAuthority;
|
|
719
|
-
if (!audiences.has(req.headers.host ?? "") && !boundAuthority) return {
|
|
720
|
-
status: 403,
|
|
721
|
-
reason: "wrong-host"
|
|
722
|
-
};
|
|
723
|
-
if (closed) return {
|
|
724
|
-
status: 401,
|
|
725
|
-
reason: "listener-closed"
|
|
726
|
-
};
|
|
755
|
+
const refusedAuthority = authority(req);
|
|
756
|
+
if (refusedAuthority) return refusedAuthority;
|
|
727
757
|
if (!opts.authentication) return void 0;
|
|
728
758
|
const authorization = req.headers.authorization;
|
|
729
759
|
const supplied = typeof authorization === "string" && authorization.startsWith("Bearer ") ? Buffer.from(authorization.slice(7)) : Buffer.alloc(0);
|
|
@@ -733,7 +763,44 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
733
763
|
reason: refused
|
|
734
764
|
};
|
|
735
765
|
}
|
|
736
|
-
})
|
|
766
|
+
});
|
|
767
|
+
const server = createServer((req, res) => {
|
|
768
|
+
if (readPaths.has(req.url ?? "")) return readHandler(req, res);
|
|
769
|
+
for (const base of mailPaths) {
|
|
770
|
+
if (!(req.url ?? "").startsWith(base + "/")) continue;
|
|
771
|
+
const capabilityId = (req.url ?? "").slice(base.length + 1);
|
|
772
|
+
const mailbox = coord.peerMail;
|
|
773
|
+
if (!/^[0-9a-f]{32}$/.test(capabilityId) || !mailbox?.hasCapability(capabilityId)) {
|
|
774
|
+
res.writeHead(404).end();
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
let handler = peerHandlers.get(capabilityId);
|
|
778
|
+
if (!handler) {
|
|
779
|
+
const peerMcp = createStdioToolServer({
|
|
780
|
+
serverName: "peer-mail",
|
|
781
|
+
serverVersion: "1",
|
|
782
|
+
tools: mailbox.tools(capabilityId)
|
|
783
|
+
});
|
|
784
|
+
handler = coordinationHttpHandler({
|
|
785
|
+
options: opts,
|
|
786
|
+
identity: {
|
|
787
|
+
runId: identity.runId,
|
|
788
|
+
actorId: "peer"
|
|
789
|
+
},
|
|
790
|
+
toolNames: /* @__PURE__ */ new Set(["send_mail", "read_mail"]),
|
|
791
|
+
backgroundActions: () => 0,
|
|
792
|
+
authorize: (request) => authority(request) ?? (!mailbox.hasCapability(capabilityId) ? {
|
|
793
|
+
status: 401,
|
|
794
|
+
reason: "credential-refused"
|
|
795
|
+
} : void 0),
|
|
796
|
+
handle: (message) => peerMcp.handle(message)
|
|
797
|
+
});
|
|
798
|
+
peerHandlers.set(capabilityId, handler);
|
|
799
|
+
}
|
|
800
|
+
return handler(req, res);
|
|
801
|
+
}
|
|
802
|
+
return mainHandler(req, res);
|
|
803
|
+
});
|
|
737
804
|
server.requestTimeout = requestTimeoutMs;
|
|
738
805
|
server.headersTimeout = requestTimeoutMs;
|
|
739
806
|
const port = await new Promise((resolve, reject) => {
|
|
@@ -771,6 +838,10 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
771
838
|
audiences.add(publicAddress.host);
|
|
772
839
|
if (host === "0.0.0.0" || host === "::") audiences.add(`127.0.0.1:${port}`);
|
|
773
840
|
paths.add(publicAddress.pathname);
|
|
841
|
+
for (const path of paths) {
|
|
842
|
+
readPaths.add(path.replace(/\/$/, "") + "/read");
|
|
843
|
+
mailPaths.add(path.replace(/\/$/, "") + "/mail");
|
|
844
|
+
}
|
|
774
845
|
if (configured !== void 0) await preflightPublicCoordination({
|
|
775
846
|
url,
|
|
776
847
|
headers,
|
|
@@ -788,108 +859,55 @@ async function serveCoordinationMcpForManager(opts, lifetime) {
|
|
|
788
859
|
throw error;
|
|
789
860
|
}
|
|
790
861
|
const mailbox = coord.peerMail;
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
},
|
|
802
|
-
rotateCredential,
|
|
803
|
-
settled: () => coord.settled(),
|
|
804
|
-
submittedResult: () => coord.submittedResult(),
|
|
805
|
-
drainResolved: () => coord.drainResolved(),
|
|
806
|
-
finishAnalysis: (input) => coord.finishAnalysis(input),
|
|
807
|
-
isStopped: () => coord.isStopped(),
|
|
808
|
-
history: () => coord.history(),
|
|
809
|
-
stats: () => coord.stats(),
|
|
810
|
-
raiseFinding: (finding) => coord.raiseFinding(finding),
|
|
811
|
-
mailHistory: () => mailbox?.history() ?? [],
|
|
812
|
-
stopMailThread: (threadId) => mailbox?.stopThread(threadId) ?? false,
|
|
813
|
-
close: async () => {
|
|
814
|
-
releaseAddress();
|
|
815
|
-
closed = true;
|
|
816
|
-
await new Promise((resolve) => {
|
|
817
|
-
server.close(() => resolve());
|
|
818
|
-
});
|
|
819
|
-
await mailListener?.close();
|
|
820
|
-
}
|
|
862
|
+
mailbox?.setEndpoint(url.replace(/\/$/, "") + "/mail");
|
|
863
|
+
const handle = {
|
|
864
|
+
url,
|
|
865
|
+
port,
|
|
866
|
+
get readOnly() {
|
|
867
|
+
if (!opts.authentication) throw new ConfigError("coordination read access requires authentication");
|
|
868
|
+
return {
|
|
869
|
+
url: url.replace(/\/$/, "") + "/read",
|
|
870
|
+
headers: Object.freeze({ Authorization: `Bearer ${readerToken.toString()}` })
|
|
871
|
+
};
|
|
821
872
|
},
|
|
822
|
-
|
|
873
|
+
get headers() {
|
|
874
|
+
return headers;
|
|
875
|
+
},
|
|
876
|
+
get credentialExpiresAt() {
|
|
877
|
+
return credentialExpiresAt;
|
|
878
|
+
},
|
|
879
|
+
rotateCredential,
|
|
880
|
+
settled: () => coord.settled(),
|
|
881
|
+
submittedResult: () => coord.submittedResult(),
|
|
882
|
+
drainResolved: () => coord.drainResolved(),
|
|
883
|
+
finishAnalysis: (input) => coord.finishAnalysis(input),
|
|
884
|
+
isStopped: () => coord.isStopped(),
|
|
885
|
+
history: () => coord.history(),
|
|
886
|
+
stats: () => coord.stats(),
|
|
887
|
+
raiseFinding: (finding) => coord.raiseFinding(finding),
|
|
888
|
+
mailHistory: () => mailbox?.history() ?? [],
|
|
889
|
+
stopMailThread: (threadId) => mailbox?.stopThread(threadId) ?? false,
|
|
890
|
+
close: async () => {
|
|
891
|
+
releaseAddress();
|
|
892
|
+
closed = true;
|
|
893
|
+
await new Promise((resolve) => {
|
|
894
|
+
server.close(() => resolve());
|
|
895
|
+
});
|
|
896
|
+
}
|
|
823
897
|
};
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
const forCapability = (capabilityId) => {
|
|
837
|
-
const existing = servers.get(capabilityId);
|
|
838
|
-
if (existing) return existing;
|
|
839
|
-
const created = createStdioToolServer({
|
|
840
|
-
serverName: "peer-mail",
|
|
841
|
-
serverVersion: "1",
|
|
842
|
-
tools: mailbox.tools(capabilityId)
|
|
843
|
-
});
|
|
844
|
-
servers.set(capabilityId, created);
|
|
845
|
-
return created;
|
|
898
|
+
try {
|
|
899
|
+
await runAbortable(async () => opts.onReadReady?.({
|
|
900
|
+
...handle.readOnly,
|
|
901
|
+
...identity
|
|
902
|
+
}), opts.scope.signal, "read capability publication aborted");
|
|
903
|
+
} catch (error) {
|
|
904
|
+
await handle.close();
|
|
905
|
+
throw error;
|
|
906
|
+
}
|
|
907
|
+
return {
|
|
908
|
+
handle,
|
|
909
|
+
controls: coord
|
|
846
910
|
};
|
|
847
|
-
const listener = createServer((req, res) => {
|
|
848
|
-
const capabilityId = /^\/mail\/([0-9a-f]{32})$/.exec(req.url ?? "")?.[1];
|
|
849
|
-
if (req.method !== "POST" || capabilityId === void 0 || !mailbox.hasCapability(capabilityId)) {
|
|
850
|
-
res.writeHead(404).end();
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
let body = "";
|
|
854
|
-
req.on("data", (chunk) => {
|
|
855
|
-
body += chunk;
|
|
856
|
-
});
|
|
857
|
-
req.on("end", () => {
|
|
858
|
-
(async () => {
|
|
859
|
-
try {
|
|
860
|
-
const message = JSON.parse(body);
|
|
861
|
-
const response = await forCapability(capabilityId).handle(message);
|
|
862
|
-
if (response === null) {
|
|
863
|
-
res.writeHead(202).end();
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
867
|
-
res.end(JSON.stringify(response));
|
|
868
|
-
} catch (e) {
|
|
869
|
-
res.writeHead(200, { "content-type": "application/json" });
|
|
870
|
-
res.end(JSON.stringify({
|
|
871
|
-
jsonrpc: "2.0",
|
|
872
|
-
id: null,
|
|
873
|
-
error: {
|
|
874
|
-
code: -32700,
|
|
875
|
-
message: e instanceof Error ? e.message : "parse error"
|
|
876
|
-
}
|
|
877
|
-
}));
|
|
878
|
-
}
|
|
879
|
-
})();
|
|
880
|
-
});
|
|
881
|
-
});
|
|
882
|
-
const port = await new Promise((resolve, reject) => {
|
|
883
|
-
listener.once("error", reject);
|
|
884
|
-
listener.listen(0, host, () => {
|
|
885
|
-
const addr = listener.address();
|
|
886
|
-
resolve(typeof addr === "object" && addr ? addr.port : 0);
|
|
887
|
-
});
|
|
888
|
-
});
|
|
889
|
-
mailbox.setEndpoint(`http://${host}:${port}/mail`);
|
|
890
|
-
return { close: () => new Promise((resolve) => {
|
|
891
|
-
listener.close(() => resolve());
|
|
892
|
-
}) };
|
|
893
911
|
}
|
|
894
912
|
//#endregion
|
|
895
913
|
//#region src/runtime/supervise/otel-spans.ts
|
|
@@ -949,6 +967,8 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
949
967
|
"tangle.sessionId": opts.runId,
|
|
950
968
|
...opts.attributes ?? {}
|
|
951
969
|
};
|
|
970
|
+
const rootIdentity = agentIdentityAttributes(opts.agentIdentity);
|
|
971
|
+
const identityOf = /* @__PURE__ */ new Map([[opts.runId, rootIdentity]]);
|
|
952
972
|
/** Node id → its open span. Seeded with the run id ⇒ the root span, because a depth-0 spawn's
|
|
953
973
|
* `parentId` is the run id itself and every deeper spawn's is a real node id. */
|
|
954
974
|
const open = /* @__PURE__ */ new Map();
|
|
@@ -1004,6 +1024,9 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1004
1024
|
"tangle.supervise.node.kind": "agent",
|
|
1005
1025
|
"tangle.supervise.tree.root": event.runId
|
|
1006
1026
|
};
|
|
1027
|
+
const identity = agentIdentityAttributes(record(p.agent));
|
|
1028
|
+
identityOf.set(childId, identity);
|
|
1029
|
+
Object.assign(attrs, identity);
|
|
1007
1030
|
if (event.parentId) attrs["tangle.supervise.node.parent_id"] = event.parentId;
|
|
1008
1031
|
if (runtime) attrs["tangle.supervise.node.runtime"] = runtime;
|
|
1009
1032
|
if (typeof p.depth === "number") attrs["tangle.supervise.node.depth"] = p.depth;
|
|
@@ -1066,6 +1089,7 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1066
1089
|
const parentSpanId = parent.spanId;
|
|
1067
1090
|
const attrs = {
|
|
1068
1091
|
...base,
|
|
1092
|
+
...identityOf.get(parentId ?? opts.runId) ?? {},
|
|
1069
1093
|
[ATTR.parentConfidence]: parent.confidence,
|
|
1070
1094
|
[ATTR.spanKind]: "LLM",
|
|
1071
1095
|
"inference.observation_kind": "LLM",
|
|
@@ -1127,6 +1151,7 @@ function createSupervisorSpanRecorder(opts) {
|
|
|
1127
1151
|
open.clear();
|
|
1128
1152
|
emit(span(rootSpanId, opts.parentSpanId, "supervisor.run", rootStartMs, endMs, {
|
|
1129
1153
|
...rootAttrs(base, opts.agentName ?? "supervisor", outcome),
|
|
1154
|
+
...rootIdentity,
|
|
1130
1155
|
...opts.parentSpanId ? { [ATTR.parentConfidence]: "explicit" } : {}
|
|
1131
1156
|
}, rootStatus(outcome), rootMessage(outcome)));
|
|
1132
1157
|
} catch {}
|
|
@@ -2775,14 +2800,31 @@ function workerFromBackend(backend, deliverable, seams) {
|
|
|
2775
2800
|
}));
|
|
2776
2801
|
const boundSessionId = boundBackend.backend === "bridge" ? boundBackend.sessionId : void 0;
|
|
2777
2802
|
const peerMailAttachment = peerMailRuntimeAttachment(profile, capturedBackend, spawnContext);
|
|
2778
|
-
|
|
2803
|
+
if (spawnContext?.peerMailUrl && boundBackend.backend === "provider" && Object.hasOwn(boundBackend.defaults?.runtimeAttachments?.mcp ?? {}, peerMailMcpAlias)) throw new ValidationError("workerFromBackend: provider defaults contain the reserved peer-mail attachment alias");
|
|
2804
|
+
const baseFactory = createExecutor(spawnContext?.peerMailUrl && boundBackend.backend === "provider" ? {
|
|
2805
|
+
...boundBackend,
|
|
2806
|
+
steering: boundBackend.steering ?? {},
|
|
2807
|
+
defaults: {
|
|
2808
|
+
...boundBackend.defaults ?? {},
|
|
2809
|
+
runtimeAttachments: {
|
|
2810
|
+
...boundBackend.defaults?.runtimeAttachments ?? {},
|
|
2811
|
+
mcp: {
|
|
2812
|
+
...boundBackend.defaults?.runtimeAttachments?.mcp ?? {},
|
|
2813
|
+
[peerMailMcpAlias]: {
|
|
2814
|
+
transport: "http",
|
|
2815
|
+
url: spawnContext.peerMailUrl
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
} : boundBackend);
|
|
2779
2821
|
const executorFactory = (spec, ctx) => {
|
|
2780
2822
|
if (boundSessionId !== void 0 && ctx.node?.nodeId !== void 0) bridgeSessionByWorker.set(ctx.node.nodeId, boundSessionId);
|
|
2781
2823
|
const extraSeams = seams?.();
|
|
2782
|
-
const seamsForChild = extraSeams === void 0 && peerMailAttachment === void 0 ? ctx.seams : {
|
|
2824
|
+
const seamsForChild = extraSeams === void 0 && (peerMailAttachment === void 0 || boundBackend.backend === "provider") ? ctx.seams : {
|
|
2783
2825
|
...extraSeams,
|
|
2784
2826
|
...ctx.seams,
|
|
2785
|
-
...peerMailAttachment === void 0 ? {} : { [bridgeRuntimeAttachmentsKey]: {
|
|
2827
|
+
...peerMailAttachment === void 0 || boundBackend.backend === "provider" ? {} : { [bridgeRuntimeAttachmentsKey]: {
|
|
2786
2828
|
...readCallerRuntimeAttachments(ctx.seams),
|
|
2787
2829
|
...peerMailAttachment
|
|
2788
2830
|
} }
|
|
@@ -2829,7 +2871,9 @@ const peerMailMcpAlias = "agent-runtime-peer-mail";
|
|
|
2829
2871
|
*
|
|
2830
2872
|
* - `bridge` MOUNTS it. cli-bridge advertises `capabilities.runtimeAttachments.mcp` and mounts
|
|
2831
2873
|
* the named servers for the run without binding them into the session profile.
|
|
2832
|
-
* - `
|
|
2874
|
+
* - `provider` mounts the same capability through runtimeAttachments.mcp and uses the existing
|
|
2875
|
+
* steerable session inbox so peer delivery can be acknowledged.
|
|
2876
|
+
* - `router` and `router-tools` mount NOTHING. Those workers are in-process tool
|
|
2833
2877
|
* loops with no MCP client; their tool surface is the caller's own array, and
|
|
2834
2878
|
* `WorkerSpawnContext.peerMailUrl` is the deliverable a caller uses directly.
|
|
2835
2879
|
* - Every other backend REFUSES the spawn. A sandbox box or a local CLI harness receives tools
|
|
@@ -2840,10 +2884,11 @@ const peerMailMcpAlias = "agent-runtime-peer-mail";
|
|
|
2840
2884
|
function peerMailRuntimeAttachment(profile, backend, spawnContext) {
|
|
2841
2885
|
const url = spawnContext?.peerMailUrl;
|
|
2842
2886
|
if (url === void 0) return void 0;
|
|
2887
|
+
if (backend.backend === "provider" && backend.shared) throw new ValidationError("provider peer mail requires a dedicated steerable session; shared placement is not supported");
|
|
2843
2888
|
switch (backend.backend) {
|
|
2844
2889
|
case "router":
|
|
2845
|
-
case "router-tools":
|
|
2846
|
-
case "provider":
|
|
2890
|
+
case "router-tools": return;
|
|
2891
|
+
case "provider":
|
|
2847
2892
|
case "bridge": break;
|
|
2848
2893
|
default: throw new ValidationError(`workerFromBackend: the '${backend.backend}' backend seam cannot mount a peer-mail endpoint — it materializes tools only through the AgentProfile, and writing a per-process capability URL there would move the canonical profile digest. Run peer-mail workers on the 'bridge' backend, mount the endpoint yourself from WorkerSpawnContext.peerMailUrl through makeLeafAgent or makeWorkerAgent, or drop peerMail for this run`);
|
|
2849
2894
|
}
|
|
@@ -4768,6 +4813,10 @@ function superviseInternal(profile, task, opts, testBrain) {
|
|
|
4768
4813
|
runId,
|
|
4769
4814
|
namespace: runNamespace,
|
|
4770
4815
|
...options.otel,
|
|
4816
|
+
agentIdentity: {
|
|
4817
|
+
...options.otel.agentIdentity,
|
|
4818
|
+
...authoredAgentIdentity(canonicalProfile, rootExecution.identity.profileDigest)
|
|
4819
|
+
},
|
|
4771
4820
|
now
|
|
4772
4821
|
}) : void 0;
|
|
4773
4822
|
const recorder = spans;
|
|
@@ -4889,4 +4938,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
|
|
|
4889
4938
|
//#endregion
|
|
4890
4939
|
export { readRootStreamReceipt as _, superviseWithTestBrain as a, createSupervisorSpanRecorder as b, resolveWorkerSpawnRetry as c, assertCoordinationBinding as d, resolveSupervisorProfile as f, readRootStream as g, ROOT_STREAM_FILE as h, superviseRootProfile as i, retryPreSpawnRefusals as l, supervisorAgentWithTestBrain as m, profileGuidanceComposer as n, workerFromBackend as o, supervisorAgent as p, supervise as r, isPreSpawnExecutorFailure as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, withWorkerSpawnRetry as u, UNPROVEN_CONTINUITY as v, serveCoordinationMcp as x, composeReentryTask as y };
|
|
4891
4940
|
|
|
4892
|
-
//# sourceMappingURL=supervise-
|
|
4941
|
+
//# sourceMappingURL=supervise-DLezpJcp.js.map
|