@tangle-network/agent-runtime 0.296.0 → 0.297.2

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.
Files changed (40) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +1 -1
  3. package/dist/{coordination-driver-BTwCdKrl.js → coordination-driver-C3ox4-8J.js} +77 -19
  4. package/dist/coordination-driver-C3ox4-8J.js.map +1 -0
  5. package/dist/{delegate-CXkgU67D.js → delegate-C4OXzzuI.js} +2 -2
  6. package/dist/{delegate-CXkgU67D.js.map → delegate-C4OXzzuI.js.map} +1 -1
  7. package/dist/durable.d.ts +1 -1
  8. package/dist/durable.js +1 -1
  9. package/dist/{graph-CqKrLWkl.js → graph-Nr_j33Ko.js} +3 -3
  10. package/dist/{graph-CqKrLWkl.js.map → graph-Nr_j33Ko.js.map} +1 -1
  11. package/dist/{index-3GzNNtI9.d.ts → index-CrLf_h23.d.ts} +23 -2
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +3 -3
  14. package/dist/kernel.d.ts +2 -2
  15. package/dist/kernel.js +6 -6
  16. package/dist/{loop-runner-bin-BjRHJLW9.d.ts → loop-runner-bin-DNAb0fqu.d.ts} +2 -2
  17. package/dist/{loop-runner-bin-CmduY4JY.js → loop-runner-bin-Dt5Tm0LL.js} +2 -2
  18. package/dist/{loop-runner-bin-CmduY4JY.js.map → loop-runner-bin-Dt5Tm0LL.js.map} +1 -1
  19. package/dist/loop-runner-bin.d.ts +1 -1
  20. package/dist/loop-runner-bin.js +1 -1
  21. package/dist/mcp/bin.js +2 -2
  22. package/dist/mcp/index.d.ts +2 -2
  23. package/dist/mcp/index.js +3 -3
  24. package/dist/{provision-supervisor-B-7DnLBR.js → provision-supervisor-DVjTqpF1.js} +2 -2
  25. package/dist/{provision-supervisor-B-7DnLBR.js.map → provision-supervisor-DVjTqpF1.js.map} +1 -1
  26. package/dist/{runtime-DicgLBWl.js → runtime-C-jN8ONc.js} +6 -6
  27. package/dist/{runtime-DicgLBWl.js.map → runtime-C-jN8ONc.js.map} +1 -1
  28. package/dist/{server-DHHeobZh.js → server-Di-qMU3Q.js} +2 -2
  29. package/dist/{server-DHHeobZh.js.map → server-Di-qMU3Q.js.map} +1 -1
  30. package/dist/{supervise-B5r5oZZ1.js → supervise-Bnqm88tQ.js} +3 -3
  31. package/dist/{supervise-B5r5oZZ1.js.map → supervise-Bnqm88tQ.js.map} +1 -1
  32. package/dist/testing.d.ts +1 -1
  33. package/dist/testing.js +11 -11
  34. package/dist/tui/index.d.ts +1 -1
  35. package/dist/tui/index.js +1 -1
  36. package/package.json +1 -1
  37. package/skills/profile-authoring/SKILL.md +10 -6
  38. package/skills/profile-authoring/references/research-directors.md +48 -0
  39. package/skills/supervise/SKILL.md +6 -0
  40. package/dist/coordination-driver-BTwCdKrl.js.map +0 -1
package/dist/agent.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Ma as OutputAdapter, Pa as SandboxClient, la as AgentRunSpec, po as RuntimeStreamEvent } from "./types-CwGpKzG1.js";
2
2
  import { a as createSurfaceImprovementProposer, c as SurfaceValidationIssue, d as validateSurfaces, i as SurfaceImprovementEdit, l as renderSurfaceIssues, n as DraftPatchInput, o as AgentSurfaces, r as DraftPatchOutput, s as ResolvedSurface, t as CreateSurfaceImprovementProposerOptions, u as resolveSubjectPath } from "./improvement-adapter-D5gwwoXQ.js";
3
- import { $h as ValidateProfileMaterializationOptions, Gh as AGENT_PROFILE_MATERIALIZATION_AXES, Jh as CanonicalAgentProfileMaterializationAxis, Kh as AgentProfileMaterializationAxis, Qh as ProfileMaterializationIssue, Xh as KnownAgentProfileMaterializationAxis, Yh as DefineProfileMaterializationContractOptions, Zh as ProfileMaterializationContract, ag as promptControlProfileMaterialization, cg as promptResourceProfileMaterialization, dg as validateProfileMaterialization, eg as assertProfileMaterialization, fg as worktreeCliProfileMaterialization, ig as profileMaterializationAxes, lg as renderProfileMaterializationIssues, ng as defineProfileMaterializationContract, og as promptModelProfileMaterialization, qh as AssertProfileMaterializationOptions, rg as fullProfileMaterialization, sg as promptOnlyProfileMaterialization, tg as controlProfileMaterialization, ug as sandboxActProfileMaterialization } from "./index-3GzNNtI9.js";
3
+ import { $h as ProfileMaterializationIssue, Jh as AssertProfileMaterializationOptions, Kh as AGENT_PROFILE_MATERIALIZATION_AXES, Qh as ProfileMaterializationContract, Xh as DefineProfileMaterializationContractOptions, Yh as CanonicalAgentProfileMaterializationAxis, Zh as KnownAgentProfileMaterializationAxis, ag as profileMaterializationAxes, cg as promptOnlyProfileMaterialization, dg as sandboxActProfileMaterialization, eg as ValidateProfileMaterializationOptions, fg as validateProfileMaterialization, ig as fullProfileMaterialization, lg as promptResourceProfileMaterialization, ng as controlProfileMaterialization, og as promptControlProfileMaterialization, pg as worktreeCliProfileMaterialization, qh as AgentProfileMaterializationAxis, rg as defineProfileMaterializationContract, sg as promptModelProfileMaterialization, tg as assertProfileMaterialization, ug as renderProfileMaterializationIssues } from "./index-CrLf_h23.js";
4
4
  import { AgentProfile, AgentProfileFileMount, AgentProfileMcpServer } from "@tangle-network/agent-interface";
5
5
  import { TraceAnalystDefinition } from "@tangle-network/agent-eval";
6
6
  import { SandboxEvent } from "@tangle-network/sandbox";
package/dist/agent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Ci as renderProfileMaterializationIssues, Di as validateProfileMaterialization, Oi as worktreeCliProfileMaterialization, Si as promptResourceProfileMaterialization, Ti as sandboxActProfileMaterialization, _i as fullProfileMaterialization, bi as promptModelProfileMaterialization, gi as defineProfileMaterializationContract, hi as controlProfileMaterialization, la as mapSandboxEvent, mi as assertProfileMaterialization, pi as AGENT_PROFILE_MATERIALIZATION_AXES, pn as createSandboxForSpec, vi as profileMaterializationAxes, xi as promptOnlyProfileMaterialization, yi as promptControlProfileMaterialization } from "./supervisor-Rov7xW0j.js";
2
- import "./runtime-DicgLBWl.js";
2
+ import "./runtime-C-jN8ONc.js";
3
3
  import { createHash } from "node:crypto";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import { isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -1,7 +1,7 @@
1
1
  import { $i as detachedFrozen, $n as parseWorkerToolTraceArtifact, Aa as addResourceSpend, Ai as prepareJsonlAppend, Bn as InMemoryResultBlobStore, Da as unmeteredSpend, E as failedItems, It as createRouterTranscript, Lr as resolveRedactor, M as withDriverExecutor, Ma as withBudgetResources, Mi as writeAllBytes, Qt as createPeerMailbox, Rn as FileResultBlobStore, Tn as runBrainLoop, Vi as providerAttemptEvidence, Vn as InMemorySpawnJournal, _ as CheckUnavailableError, c as runTree, er as workerTraceAnalysisStore, ft as resolveSpawnResourcePaths, ga as chargedTokens, i as bestDelivered, ir as assertValidBudget, ji as readCommittedJsonLines, jt as createExecutorRegistry, nn as isLiveNodeStatus, o as pickBestDelivered, ot as scopeRetainedOwnerResourceReader, qt as createInbox, rn as isTerminalNodeStatus, s as runFinalizer, ur as errMessage, x as checkVerdictOf, xa as promptCacheTokenClasses, z as meterRuntimeOwnedProviderAttempt, zn as FileSpawnJournal } from "./supervisor-Rov7xW0j.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-DSCWdbX2.js";
4
- import { agentProfileSchema, canonicalCandidateDigest } from "@tangle-network/agent-interface";
4
+ import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest } from "@tangle-network/agent-interface";
5
5
  import { argHash, errorStreakDetector, observeAll, repeatedActionDetector } from "@tangle-network/agent-eval";
6
6
  import { randomUUID } from "node:crypto";
7
7
  import { mkdirSync, readFileSync, watch } from "node:fs";
@@ -558,6 +558,7 @@ const journalEventKinds = [
558
558
  "mail",
559
559
  "escalation",
560
560
  "analyst-defined",
561
+ "analyst-assignment",
561
562
  "acknowledgement"
562
563
  ];
563
564
  /** The reserved coordination verb names — the complete set `createCoordinationTools` can emit
@@ -919,8 +920,56 @@ function createCoordinationToolsForManager(opts, lifetime) {
919
920
  reason: settled.reason
920
921
  });
921
922
  };
923
+ const analystAssignments = /* @__PURE__ */ new Map();
924
+ for (const record of opts.priorJournal ?? []) {
925
+ if (record.event.type !== "analyst-assignment") continue;
926
+ const assignment = record.event.assignment;
927
+ const prior = analystAssignments.get(assignment.assignmentId);
928
+ if (prior && canonicalCandidateDigest(prior) !== canonicalCandidateDigest(assignment)) throw new Error(`coordination: conflicting analyst assignment '${assignment.assignmentId}'`);
929
+ analystAssignments.set(assignment.assignmentId, detachedFrozen(assignment));
930
+ }
931
+ const analystRuns = /* @__PURE__ */ new Map();
932
+ const flushedAnalystRuns = /* @__PURE__ */ new Set();
933
+ let analystRunOrdinal = 0;
934
+ for (const assignment of analystAssignments.values()) {
935
+ const ordinal = Number(/:o(\d+)$/.exec(assignment.assignmentId)?.[1]);
936
+ if (!Number.isSafeInteger(ordinal) || ordinal < 0 || ordinal === Number.MAX_SAFE_INTEGER) throw new Error(`coordination: invalid analyst assignment '${assignment.assignmentId}'`);
937
+ analystRunOrdinal = Math.max(analystRunOrdinal, ordinal + 1);
938
+ }
939
+ for (const node of [...opts.scope.resume?.view.nodes ?? [], ...opts.scope.view.nodes]) {
940
+ if (node.parent !== opts.scope.view.root || !node.assignmentId?.startsWith("analyst:")) continue;
941
+ const assignment = analystAssignments.get(node.assignmentId);
942
+ if (!assignment) throw new Error(`coordination: analyst assignment '${node.assignmentId}' has no durable source record; refusing to treat its review as a worker result`);
943
+ if (node.identity && (node.identity.profileDigest !== assignment.profileDigest || node.identity.taskDigest !== assignment.taskDigest)) throw new Error(`coordination: analyst assignment '${node.assignmentId}' conflicts with its journaled execution identity`);
944
+ analystRuns.set(node.id, {
945
+ route: {
946
+ kind: assignment.kind,
947
+ ...assignment.to === void 0 ? {} : { to: assignment.to }
948
+ },
949
+ sourceWorker: assignment.sourceWorker,
950
+ assignmentId: assignment.assignmentId
951
+ });
952
+ }
953
+ const analystRunFinding = (run, settled) => detachedFrozen({
954
+ type: "finding",
955
+ finding: canonicalFindingEvent({
956
+ fromWorker: run.sourceWorker,
957
+ analyst: run.route.kind,
958
+ analystWorkerId: settled.handle.id,
959
+ assignmentId: run.assignmentId,
960
+ findings: settled.kind === "done" ? settled.out : { analystRunFailed: settled.reason }
961
+ })
962
+ });
922
963
  const resumedWorkers = [];
964
+ const resumedFindings = [];
923
965
  for (const s of opts.scope.resume?.settled ?? []) {
966
+ const analyst = analystRuns.get(s.handle.id);
967
+ if (analyst) {
968
+ resumedFindings.push(analystRunFinding(analyst, s));
969
+ analystRuns.delete(s.handle.id);
970
+ flushedAnalystRuns.add(s.handle.id);
971
+ continue;
972
+ }
924
973
  const worker = projectSettled(s, true);
925
974
  resumedWorkers.push(worker);
926
975
  ledger.push(worker);
@@ -930,10 +979,10 @@ function createCoordinationToolsForManager(opts, lifetime) {
930
979
  const cb = opts.onEvent;
931
980
  bus.subscribe((rec) => cb(rec.event, rec));
932
981
  }
933
- const resumeEvents = opts.replaySettlements ? resumedWorkers.map((worker) => detachedFrozen({
982
+ const resumeEvents = opts.replaySettlements ? [...resumedWorkers.map((worker) => detachedFrozen({
934
983
  type: "settled",
935
984
  worker
936
- })) : [];
985
+ })), ...resumedFindings] : [];
937
986
  let resumeEventIndex = 0;
938
987
  let readyInFlight;
939
988
  const ready = () => {
@@ -968,7 +1017,6 @@ function createCoordinationToolsForManager(opts, lifetime) {
968
1017
  checkReads.push(entry);
969
1018
  return entry;
970
1019
  };
971
- const flushedAnalystRuns = /* @__PURE__ */ new Set();
972
1020
  const eventWorker = (event) => event.type === "settled" ? event.worker.id : event.type === "finding" ? event.finding.fromWorker : event.type === "question" ? event.question.from : void 0;
973
1021
  const acknowledge = async (targets, by) => {
974
1022
  const fresh = targets.filter((delivery) => !delivery.acknowledged);
@@ -1036,18 +1084,6 @@ function createCoordinationToolsForManager(opts, lifetime) {
1036
1084
  unwatchWorker(w.id);
1037
1085
  };
1038
1086
  let pendingSettlement;
1039
- const analystRuns = /* @__PURE__ */ new Map();
1040
- let analystRunOrdinal = 0;
1041
- /** The `finding` event an analyst-agent settlement becomes: its settle OUTPUT is the findings
1042
- * (a failed run publishes the failure as findings — degraded beats vanished). */
1043
- const analystRunFinding = (run, settled) => detachedFrozen({
1044
- type: "finding",
1045
- finding: canonicalFindingEvent({
1046
- fromWorker: run.sourceWorker,
1047
- analyst: run.route.kind,
1048
- findings: settled.kind === "done" ? settled.out : { analystRunFailed: settled.reason }
1049
- })
1050
- });
1051
1087
  /**
1052
1088
  * Spawn one analyst-AGENT run over a settled worker's evidence, through the SAME spawn
1053
1089
  * machinery a driver spawn uses (`scope.spawn` + `makeWorkerAgent`): the analyst's spend
@@ -1073,6 +1109,22 @@ function createCoordinationToolsForManager(opts, lifetime) {
1073
1109
  ].join("\n\n");
1074
1110
  const assignmentId = `analyst:${route.kind}:o${analystRunOrdinal++}`;
1075
1111
  const label = `analyst:${route.kind}`;
1112
+ const assignment = detachedFrozen({
1113
+ assignmentId,
1114
+ kind: route.kind,
1115
+ sourceWorker: worker.id,
1116
+ sourceTrace: worker.trace,
1117
+ ...worker.outRef === void 0 ? {} : { sourceOutRef: worker.outRef },
1118
+ profileDigest: canonicalAgentProfileDigest(route.agent),
1119
+ taskDigest: canonicalCandidateDigest(task),
1120
+ ...route.directive === void 0 ? {} : { directive: route.directive },
1121
+ ...route.to === void 0 ? {} : { to: route.to }
1122
+ });
1123
+ await bus.publish({
1124
+ type: "analyst-assignment",
1125
+ assignment
1126
+ }, { queue: false });
1127
+ analystAssignments.set(assignmentId, assignment);
1076
1128
  const context = Object.freeze({
1077
1129
  assignmentId,
1078
1130
  parentNodeId: opts.scope.view.root,
@@ -1108,8 +1160,10 @@ function createCoordinationToolsForManager(opts, lifetime) {
1108
1160
  }
1109
1161
  analystRuns.set(spawnedId, {
1110
1162
  route,
1111
- sourceWorker: worker.id
1163
+ sourceWorker: worker.id,
1164
+ assignmentId
1112
1165
  });
1166
+ if (route.agent?.name) profileNameByWorker.set(spawnedId, route.agent.name);
1113
1167
  watchWorker(spawnedId);
1114
1168
  };
1115
1169
  const workerRouteNames = (workerId) => {
@@ -1498,6 +1552,10 @@ function createCoordinationToolsForManager(opts, lifetime) {
1498
1552
  type: "analyst-defined",
1499
1553
  ...ev.analyst
1500
1554
  };
1555
+ if (ev.type === "analyst-assignment") return {
1556
+ type: "analyst-assignment",
1557
+ ...ev.assignment
1558
+ };
1501
1559
  if (ev.type === "acknowledgement") return {
1502
1560
  type: "acknowledgement",
1503
1561
  ...ev.acknowledgement
@@ -4557,7 +4615,7 @@ function resumeBrief(resume, current, prior) {
4557
4615
  return lines.join("\n");
4558
4616
  }
4559
4617
  function hasPriorCoordination(prior) {
4560
- return prior !== void 0 && (prior.questions.length > 0 || prior.findings.length > 0 || prior.continuations.length > 0 || prior.deliveryEvidence.length > 0 || prior.records.some((record) => record.event.type === "submission"));
4618
+ return prior !== void 0 && (prior.questions.length > 0 || prior.findings.length > 0 || prior.continuations.length > 0 || prior.deliveryEvidence.length > 0 || prior.records.length > 0);
4561
4619
  }
4562
4620
  function priorCoordinationBrief(prior) {
4563
4621
  const lines = [
@@ -4623,4 +4681,4 @@ function safeJson(v) {
4623
4681
  //#endregion
4624
4682
  export { createCoordinationTools as A, withCoordinationAwaitFence as B, applyRunCancellation as C, analystToolGroupNames as D, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as E, questionEscalationTargets as F, defaultToolDetectors as H, COORDINATION_CLIENT_TOOL_TIMEOUT_MS as I, MCP_TOOL_TIMEOUT_HEADER as L, downMessageRefusalReasons as M, normalizeAnalyzeOnSettle as N, canonicalFindingEvent as O, parseAuthoredAnalystDefinition as P, declaredAwaitFenceMs as R, foldCoordinationRecords as S, ANALYST_DEFINITION_BOUNDS as T, watchTrace as U, createEventBus as V, 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, declaredToolTimeoutMs as z };
4625
4683
 
4626
- //# sourceMappingURL=coordination-driver-BTwCdKrl.js.map
4684
+ //# sourceMappingURL=coordination-driver-C3ox4-8J.js.map