@tangle-network/agent-runtime 0.60.0 → 0.62.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.
Files changed (58) hide show
  1. package/dist/agent.d.ts +3 -2
  2. package/dist/agent.js +2 -3
  3. package/dist/agent.js.map +1 -1
  4. package/dist/analyst-loop.d.ts +1 -1
  5. package/dist/chunk-DVQGYDN5.js +59 -0
  6. package/dist/chunk-DVQGYDN5.js.map +1 -0
  7. package/dist/{chunk-ZWGEA722.js → chunk-E4X4FNQZ.js} +2 -2
  8. package/dist/{chunk-45D64J7B.js → chunk-MT4XM3G6.js} +191 -100
  9. package/dist/chunk-MT4XM3G6.js.map +1 -0
  10. package/dist/{chunk-GLMFBUKT.js → chunk-O2UPHN7X.js} +1 -1
  11. package/dist/chunk-O2UPHN7X.js.map +1 -0
  12. package/dist/{chunk-MMDIORZY.js → chunk-RTNMMHWR.js} +4 -23
  13. package/dist/chunk-RTNMMHWR.js.map +1 -0
  14. package/dist/chunk-RYD7ND4A.js +475 -0
  15. package/dist/chunk-RYD7ND4A.js.map +1 -0
  16. package/dist/{chunk-IN7WHMGZ.js → chunk-YWO4H64E.js} +47 -7
  17. package/dist/chunk-YWO4H64E.js.map +1 -0
  18. package/dist/coder-2leJPOvC.d.ts +52 -0
  19. package/dist/coordination-Curpzeyc.d.ts +381 -0
  20. package/dist/{delegates-C94qchkz.d.ts → delegates-CLFNAKyi.d.ts} +650 -21
  21. package/dist/improvement.js +1 -1
  22. package/dist/index.d.ts +10 -6
  23. package/dist/index.js +10 -10
  24. package/dist/intelligence.d.ts +3 -2
  25. package/dist/intelligence.js.map +1 -1
  26. package/dist/{loop-runner-bin-Noz7P-mS.d.ts → loop-runner-bin-B6dzNZC8.d.ts} +46 -12
  27. package/dist/loop-runner-bin.d.ts +8 -4
  28. package/dist/loop-runner-bin.js +5 -5
  29. package/dist/loops.d.ts +8 -6
  30. package/dist/loops.js +18 -7
  31. package/dist/mcp/bin.js +11 -11
  32. package/dist/mcp/bin.js.map +1 -1
  33. package/dist/mcp/index.d.ts +13 -12
  34. package/dist/mcp/index.js +8 -8
  35. package/dist/{openai-tools-d4GKwgya.d.ts → openai-tools-CA2N3-Ak.d.ts} +1 -1
  36. package/dist/profiles.d.ts +9 -10
  37. package/dist/profiles.js +5 -7
  38. package/dist/profiles.js.map +1 -1
  39. package/dist/{run-loop-CcqfR_gy.d.ts → run-loop-D3PwlG7J.d.ts} +1 -1
  40. package/dist/runtime.d.ts +31 -1046
  41. package/dist/runtime.js +18 -7
  42. package/dist/{types-CUzjRFZ3.d.ts → types-Crxftafi.d.ts} +2 -2
  43. package/dist/workflow.d.ts +2 -2
  44. package/dist/workflow.js +2 -3
  45. package/dist/workflow.js.map +1 -1
  46. package/dist/worktree-fanout-DUiKPApb.d.ts +1099 -0
  47. package/package.json +6 -2
  48. package/dist/chunk-45D64J7B.js.map +0 -1
  49. package/dist/chunk-4FEUFYOY.js +0 -282
  50. package/dist/chunk-4FEUFYOY.js.map +0 -1
  51. package/dist/chunk-7QYOXFCD.js +0 -293
  52. package/dist/chunk-7QYOXFCD.js.map +0 -1
  53. package/dist/chunk-GLMFBUKT.js.map +0 -1
  54. package/dist/chunk-IN7WHMGZ.js.map +0 -1
  55. package/dist/chunk-MMDIORZY.js.map +0 -1
  56. package/dist/coder-CybltHEm.d.ts +0 -163
  57. package/dist/coordination-Biw19JzN.d.ts +0 -944
  58. /package/dist/{chunk-ZWGEA722.js.map → chunk-E4X4FNQZ.js.map} +0 -0
@@ -1,6 +1,3 @@
1
- import {
2
- runCoderChecks
3
- } from "./chunk-7QYOXFCD.js";
4
1
  import {
5
2
  UI_LENSES
6
3
  } from "./chunk-WIR4HOOJ.js";
@@ -16,7 +13,7 @@ import {
16
13
  import {
17
14
  harnessInvocation,
18
15
  runLocalHarness
19
- } from "./chunk-GLMFBUKT.js";
16
+ } from "./chunk-O2UPHN7X.js";
20
17
  import {
21
18
  buildLoopSpanNodes
22
19
  } from "./chunk-G3RGMA7C.js";
@@ -2572,6 +2569,31 @@ function errMessage(err) {
2572
2569
  }
2573
2570
 
2574
2571
  // src/runtime/personify/combinators.ts
2572
+ function selectValidWinner(opts) {
2573
+ const strategy = opts?.strategy ?? "highest-score";
2574
+ const sizeOfIter = (iter) => {
2575
+ const out = iter.output;
2576
+ if (out === void 0 || opts?.sizeOf === void 0) return Number.POSITIVE_INFINITY;
2577
+ const deliverable = out.kind === "done" ? out.deliverable : out;
2578
+ return opts.sizeOf(deliverable);
2579
+ };
2580
+ return (iterations) => {
2581
+ const valid = iterations.filter(
2582
+ (iter) => iter.output !== void 0 && !iter.error && iter.verdict?.valid === true
2583
+ );
2584
+ if (valid.length === 0) return void 0;
2585
+ switch (strategy) {
2586
+ case "first-valid":
2587
+ return [...valid].sort((a, b) => a.index - b.index)[0];
2588
+ case "smallest-artifact":
2589
+ return [...valid].sort((a, b) => sizeOfIter(a) - sizeOfIter(b) || a.index - b.index)[0];
2590
+ default:
2591
+ return [...valid].sort(
2592
+ (a, b) => (b.verdict?.score ?? 0) - (a.verdict?.score ?? 0) || a.index - b.index
2593
+ )[0];
2594
+ }
2595
+ };
2596
+ }
2575
2597
  function pipeline(stages) {
2576
2598
  if (stages.length === 0) {
2577
2599
  throw new ValidationError("pipeline: at least one stage is required");
@@ -3500,7 +3522,7 @@ function ensureGitOk(step, result) {
3500
3522
  }
3501
3523
  }
3502
3524
  async function createWorktree(options) {
3503
- const variants = options.variantsDir ?? ".coder-variants";
3525
+ const variants = options.variantsDir ?? ".agent-worktrees";
3504
3526
  const baseRef = options.baseRef ?? "HEAD";
3505
3527
  const branch = `delegate/${options.runId}`;
3506
3528
  const path2 = `${options.repoRoot.replace(/\/+$/, "")}/${variants}/${options.runId}`;
@@ -6880,98 +6902,6 @@ function authoredWorker(profile, opts) {
6880
6902
  return { name: profile.name, act: async () => "", executorSpec: spec };
6881
6903
  }
6882
6904
 
6883
- // src/runtime/supervise/coder-deliverable.ts
6884
- function coderDeliverable(options = {}) {
6885
- const require2 = new Set(options.require ?? []);
6886
- const constraints = {
6887
- ...options.maxDiffLines !== void 0 ? { maxDiffLines: options.maxDiffLines } : {},
6888
- ...options.forbiddenPaths !== void 0 ? { forbiddenPaths: options.forbiddenPaths } : {}
6889
- };
6890
- return {
6891
- describe: "coder patch: no-op/secret/forbidden/diff-size + required test/typecheck pass",
6892
- check(artifact) {
6893
- const input = {
6894
- patch: artifact.patch,
6895
- testsPassed: signalPass(artifact.checks?.tests?.passed, require2.has("tests")),
6896
- typecheckPassed: signalPass(artifact.checks?.typecheck?.passed, require2.has("typecheck"))
6897
- };
6898
- return runCoderChecks(input, constraints).valid === true;
6899
- }
6900
- };
6901
- }
6902
- function signalPass(value, required) {
6903
- if (value !== void 0) return value;
6904
- return !required;
6905
- }
6906
-
6907
- // src/runtime/supervise/coder-fanout.ts
6908
- function worktreeCoderFanout(options) {
6909
- const deliverable = coderDeliverable({
6910
- ...options.maxDiffLines !== void 0 ? { maxDiffLines: options.maxDiffLines } : {},
6911
- ...options.forbiddenPaths !== void 0 ? { forbiddenPaths: options.forbiddenPaths } : {},
6912
- ...options.require !== void 0 ? { require: options.require } : {}
6913
- });
6914
- const itemSpec = (item) => {
6915
- const executor = gateOnDeliverable(
6916
- createWorktreeCliExecutor({
6917
- repoRoot: options.repoRoot,
6918
- profile: item.profile,
6919
- harness: item.harness,
6920
- taskPrompt: options.taskPrompt,
6921
- ...item.runId ? { runId: item.runId } : {},
6922
- ...item.baseRef ? { baseRef: item.baseRef } : {},
6923
- ...options.testCmd !== void 0 ? { testCmd: options.testCmd } : {},
6924
- ...options.typecheckCmd !== void 0 ? { typecheckCmd: options.typecheckCmd } : {},
6925
- ...options.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: options.harnessTimeoutMs } : {},
6926
- ...options.runGit ? { runGit: options.runGit } : {},
6927
- ...options.runHarness ? { runHarness: options.runHarness } : {},
6928
- ...options.runCommand ? { runCommand: options.runCommand } : {}
6929
- }),
6930
- deliverable
6931
- );
6932
- return { profile: item.profile, harness: null, executor };
6933
- };
6934
- const selectWinner = winnerSelectorFor(options.winnerStrategy ?? "highest-score");
6935
- return fanout(options.harnesses, {
6936
- itemTask: () => options.taskPrompt,
6937
- label: (item, i) => `${item.name}:${i}`,
6938
- itemSpec: (item) => itemSpec(item),
6939
- selectWinner
6940
- });
6941
- }
6942
- function winnerSelectorFor(strategy) {
6943
- return (iterations) => {
6944
- const valid = iterations.filter(
6945
- (iter) => iter.output !== void 0 && !iter.error && iter.verdict?.valid === true
6946
- );
6947
- if (valid.length === 0) return void 0;
6948
- switch (strategy) {
6949
- case "first-valid":
6950
- return [...valid].sort((a, b) => a.index - b.index)[0];
6951
- case "smallest-diff":
6952
- return [...valid].sort((a, b) => diffLines(a) - diffLines(b) || a.index - b.index)[0];
6953
- default:
6954
- return [...valid].sort(
6955
- (a, b) => (b.verdict?.score ?? 0) - (a.verdict?.score ?? 0) || a.index - b.index
6956
- )[0];
6957
- }
6958
- };
6959
- }
6960
- function diffLines(iter) {
6961
- const artifact = artifactOf(iter.output);
6962
- if (!artifact) return Number.POSITIVE_INFINITY;
6963
- return artifact.stats.insertions + artifact.stats.deletions;
6964
- }
6965
- function artifactOf(output) {
6966
- if (!output) return void 0;
6967
- if (isArtifact(output)) return output;
6968
- if (output.kind === "done" && isArtifact(output.deliverable)) return output.deliverable;
6969
- return void 0;
6970
- }
6971
- function isArtifact(value) {
6972
- return value !== null && typeof value === "object" && typeof value.patch === "string" && typeof value.stats === "object";
6973
- }
6974
-
6975
6905
  // src/runtime/supervise/event-bus.ts
6976
6906
  function createEventBus(now = Date.now) {
6977
6907
  const queue = [];
@@ -9734,6 +9664,122 @@ function watchTrace(source, opts = {}) {
9734
9664
  });
9735
9665
  }
9736
9666
 
9667
+ // src/runtime/supervise/patch-checks.ts
9668
+ var DEFAULT_MAX_DIFF_LINES = 400;
9669
+ var secretPathPattern = /(^|\/)(\.env(\.|$)|.*\.(pem|key|p12|pfx|keystore|wallet)|id_rsa|id_ed25519|secrets?\.json|credentials?\.json)$/i;
9670
+ function touchedPathsFromPatch(patch) {
9671
+ const out = /* @__PURE__ */ new Set();
9672
+ for (const line of patch.split(/\r?\n/)) {
9673
+ if (line.startsWith("+++ ") || line.startsWith("--- ")) {
9674
+ const rest = line.slice(4).trim();
9675
+ if (rest === "/dev/null") continue;
9676
+ const stripped = rest.startsWith("a/") || rest.startsWith("b/") ? rest.slice(2) : rest;
9677
+ out.add(stripped);
9678
+ }
9679
+ }
9680
+ return [...out];
9681
+ }
9682
+ function countDiffLines(patch) {
9683
+ let count = 0;
9684
+ for (const line of patch.split(/\r?\n/)) {
9685
+ if ((line.startsWith("+") || line.startsWith("-")) && !line.startsWith("+++") && !line.startsWith("---")) {
9686
+ count += 1;
9687
+ }
9688
+ }
9689
+ return count;
9690
+ }
9691
+ function isNonEmptyPatch(patch) {
9692
+ return touchedPathsFromPatch(patch).length > 0 && patch.trim().length > 0;
9693
+ }
9694
+ function touchesSecretPath(patch) {
9695
+ return touchedPathsFromPatch(patch).filter((p) => secretPathPattern.test(p));
9696
+ }
9697
+ function runCoderChecks(input, constraints = {}) {
9698
+ const maxDiff = constraints.maxDiffLines ?? DEFAULT_MAX_DIFF_LINES;
9699
+ const forbidden = constraints.forbiddenPaths ?? [];
9700
+ const scores = {};
9701
+ const notes = [];
9702
+ let pass = true;
9703
+ const touched = touchedPathsFromPatch(input.patch);
9704
+ if (touched.length === 0 || input.patch.trim().length === 0) {
9705
+ pass = false;
9706
+ scores.nonEmpty = 0;
9707
+ notes.push("empty patch \u2014 no files changed");
9708
+ } else {
9709
+ scores.nonEmpty = 1;
9710
+ }
9711
+ const touchedSecrets = touched.filter((p) => secretPathPattern.test(p));
9712
+ if (touchedSecrets.length > 0) {
9713
+ pass = false;
9714
+ scores.noSecrets = 0;
9715
+ notes.push(`touched secret-shaped paths: ${touchedSecrets.join(", ")}`);
9716
+ } else {
9717
+ scores.noSecrets = 1;
9718
+ }
9719
+ const touchedForbidden = forbidden.filter((path2) => {
9720
+ const prefix = path2.endsWith("/") ? path2 : `${path2}/`;
9721
+ const exact = prefix.slice(0, -1);
9722
+ return touched.some((p) => p === exact || p.startsWith(prefix));
9723
+ });
9724
+ if (touchedForbidden.length > 0) {
9725
+ pass = false;
9726
+ scores.forbiddenPath = 0;
9727
+ notes.push(`touched forbidden paths: ${touchedForbidden.join(", ")}`);
9728
+ } else {
9729
+ scores.forbiddenPath = 1;
9730
+ }
9731
+ const diffLines = countDiffLines(input.patch);
9732
+ if (diffLines > maxDiff) {
9733
+ pass = false;
9734
+ scores.diffSize = 0;
9735
+ notes.push(`diff ${diffLines} lines exceeds cap ${maxDiff}`);
9736
+ } else {
9737
+ scores.diffSize = maxDiff === 0 ? 0 : Math.max(0, 1 - diffLines / maxDiff);
9738
+ }
9739
+ scores.tests = input.testsPassed ? 1 : 0;
9740
+ scores.typecheck = input.typecheckPassed ? 1 : 0;
9741
+ if (!input.testsPassed) {
9742
+ pass = false;
9743
+ notes.push("tests failed");
9744
+ }
9745
+ if (!input.typecheckPassed) {
9746
+ pass = false;
9747
+ notes.push("typecheck failed");
9748
+ }
9749
+ const score = 0.5 * scores.tests + 0.3 * scores.typecheck + 0.2 * scores.diffSize;
9750
+ const verdict = {
9751
+ valid: pass,
9752
+ score: Number.isFinite(score) ? score : 0,
9753
+ scores
9754
+ };
9755
+ if (notes.length > 0) verdict.notes = notes.join("; ");
9756
+ return verdict;
9757
+ }
9758
+
9759
+ // src/runtime/supervise/patch-deliverable.ts
9760
+ function patchDelivered(options = {}) {
9761
+ const require2 = new Set(options.require ?? []);
9762
+ const constraints = {
9763
+ ...options.maxDiffLines !== void 0 ? { maxDiffLines: options.maxDiffLines } : {},
9764
+ ...options.forbiddenPaths !== void 0 ? { forbiddenPaths: options.forbiddenPaths } : {}
9765
+ };
9766
+ return {
9767
+ describe: "patch: no-op/secret/forbidden/diff-size + required test/typecheck pass",
9768
+ check(artifact) {
9769
+ const input = {
9770
+ patch: artifact.patch,
9771
+ testsPassed: signalPass(artifact.checks?.tests?.passed, require2.has("tests")),
9772
+ typecheckPassed: signalPass(artifact.checks?.typecheck?.passed, require2.has("typecheck"))
9773
+ };
9774
+ return runCoderChecks(input, constraints).valid === true;
9775
+ }
9776
+ };
9777
+ }
9778
+ function signalPass(value, required) {
9779
+ if (value !== void 0) return value;
9780
+ return !required;
9781
+ }
9782
+
9737
9783
  // src/runtime/supervise/router-driver-chat.ts
9738
9784
  function routerDriverChat(c, opts = {}) {
9739
9785
  const temperature = opts.temperature ?? 0.4;
@@ -9982,6 +10028,45 @@ async function analyzeTrace(source, runId = "worker") {
9982
10028
  return { trajectory, stuckLoop, toolWaste };
9983
10029
  }
9984
10030
 
10031
+ // src/runtime/supervise/worktree-fanout.ts
10032
+ function worktreeFanout(options) {
10033
+ const deliverable = options.deliverable ?? patchDelivered({
10034
+ ...options.maxDiffLines !== void 0 ? { maxDiffLines: options.maxDiffLines } : {},
10035
+ ...options.forbiddenPaths !== void 0 ? { forbiddenPaths: options.forbiddenPaths } : {},
10036
+ ...options.require !== void 0 ? { require: options.require } : {}
10037
+ });
10038
+ const itemSpec = (item) => {
10039
+ const executor = gateOnDeliverable(
10040
+ createWorktreeCliExecutor({
10041
+ repoRoot: options.repoRoot,
10042
+ profile: item.profile,
10043
+ harness: item.harness,
10044
+ taskPrompt: options.taskPrompt,
10045
+ ...item.runId ? { runId: item.runId } : {},
10046
+ ...item.baseRef ? { baseRef: item.baseRef } : {},
10047
+ ...options.testCmd !== void 0 ? { testCmd: options.testCmd } : {},
10048
+ ...options.typecheckCmd !== void 0 ? { typecheckCmd: options.typecheckCmd } : {},
10049
+ ...options.harnessTimeoutMs !== void 0 ? { harnessTimeoutMs: options.harnessTimeoutMs } : {},
10050
+ ...options.runGit ? { runGit: options.runGit } : {},
10051
+ ...options.runHarness ? { runHarness: options.runHarness } : {},
10052
+ ...options.runCommand ? { runCommand: options.runCommand } : {}
10053
+ }),
10054
+ deliverable
10055
+ );
10056
+ return { profile: item.profile, harness: null, executor };
10057
+ };
10058
+ const selectWinner = selectValidWinner({
10059
+ strategy: options.winnerStrategy ?? "highest-score",
10060
+ sizeOf: (a) => a.stats.insertions + a.stats.deletions
10061
+ });
10062
+ return fanout(options.harnesses, {
10063
+ itemTask: () => options.taskPrompt,
10064
+ label: (item, i) => `${item.name}:${i}`,
10065
+ itemSpec: (item) => itemSpec(item),
10066
+ selectWinner
10067
+ });
10068
+ }
10069
+
9985
10070
  // src/runtime/verifier-environment.ts
9986
10071
  var submitTool = {
9987
10072
  type: "function",
@@ -10311,6 +10396,7 @@ export {
10311
10396
  nestedScopeSeamKey,
10312
10397
  createScope,
10313
10398
  settledToIteration,
10399
+ selectValidWinner,
10314
10400
  pipeline,
10315
10401
  fanout,
10316
10402
  loopUntil,
@@ -10372,8 +10458,6 @@ export {
10372
10458
  asAuthoredProfile,
10373
10459
  supervisorSkill,
10374
10460
  authoredWorker,
10375
- coderDeliverable,
10376
- worktreeCoderFanout,
10377
10461
  createEventBus,
10378
10462
  createCoordinationTools,
10379
10463
  coordinationDriverAgent,
@@ -10431,6 +10515,12 @@ export {
10431
10515
  serveCoordinationMcp,
10432
10516
  defaultToolDetectors,
10433
10517
  watchTrace,
10518
+ touchedPathsFromPatch,
10519
+ countDiffLines,
10520
+ isNonEmptyPatch,
10521
+ touchesSecretPath,
10522
+ runCoderChecks,
10523
+ patchDelivered,
10434
10524
  routerDriverChat,
10435
10525
  toToolSpan,
10436
10526
  decodeOpencodePart,
@@ -10442,6 +10532,7 @@ export {
10442
10532
  createPartsTraceSource,
10443
10533
  sandboxSessionTraceSource,
10444
10534
  analyzeTrace,
10535
+ worktreeFanout,
10445
10536
  createVerifierEnvironment,
10446
10537
  createWaterfallCollector,
10447
10538
  localShell,
@@ -10449,4 +10540,4 @@ export {
10449
10540
  jjWorkspace,
10450
10541
  runInWorkspace
10451
10542
  };
10452
- //# sourceMappingURL=chunk-45D64J7B.js.map
10543
+ //# sourceMappingURL=chunk-MT4XM3G6.js.map