@tangle-network/agent-runtime 0.78.0 → 0.79.1

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 (44) hide show
  1. package/dist/agent.js +4 -3
  2. package/dist/agent.js.map +1 -1
  3. package/dist/{chunk-QJ6BWENI.js → chunk-2DS6T46I.js} +3 -3
  4. package/dist/{chunk-O2UPHN7X.js → chunk-5JAUQZQA.js} +1 -1
  5. package/dist/chunk-5JAUQZQA.js.map +1 -0
  6. package/dist/{chunk-YHS6I2IS.js → chunk-75V2XXYJ.js} +8 -6
  7. package/dist/chunk-75V2XXYJ.js.map +1 -0
  8. package/dist/{chunk-JPURCA2O.js → chunk-LWGVVP2C.js} +2 -2
  9. package/dist/{chunk-OL2SEETC.js → chunk-SONQUREI.js} +2 -2
  10. package/dist/{chunk-OLPH6W3J.js → chunk-TSDKBFZP.js} +53 -144
  11. package/dist/chunk-TSDKBFZP.js.map +1 -0
  12. package/dist/chunk-Z3RRRPRB.js +916 -0
  13. package/dist/chunk-Z3RRRPRB.js.map +1 -0
  14. package/dist/{coordination-Csxsy39a.d.ts → coordination-BoEPhGas.d.ts} +30 -22
  15. package/dist/environment-provider.d.ts +66 -0
  16. package/dist/environment-provider.js +16 -0
  17. package/dist/environment-provider.js.map +1 -0
  18. package/dist/index.d.ts +7 -6
  19. package/dist/index.js +7 -6
  20. package/dist/index.js.map +1 -1
  21. package/dist/lifecycle.d.ts +2 -2
  22. package/dist/lifecycle.js +2 -2
  23. package/dist/{local-harness-BE_h8szs.d.ts → local-harness-DU7yV6mG.d.ts} +1 -1
  24. package/dist/{loop-runner-bin-BTMpf1oY.d.ts → loop-runner-bin-DCr5OMe5.d.ts} +2 -2
  25. package/dist/loop-runner-bin.d.ts +5 -4
  26. package/dist/loop-runner-bin.js +5 -4
  27. package/dist/loops.d.ts +13 -9
  28. package/dist/loops.js +15 -3
  29. package/dist/mcp/bin.js +3 -2
  30. package/dist/mcp/bin.js.map +1 -1
  31. package/dist/mcp/index.d.ts +12 -10
  32. package/dist/mcp/index.js +10 -8
  33. package/dist/mcp/index.js.map +1 -1
  34. package/dist/{mcp-serve-verifier-CT1KLTG_.d.ts → mcp-serve-verifier-BvMAV_8U.d.ts} +1 -1
  35. package/dist/{worktree-DH_Y0brm.d.ts → types-C1sozrte.d.ts} +1 -123
  36. package/dist/worktree-CpptK3oF.d.ts +125 -0
  37. package/dist/{worktree-fanout-DGC7jS7i.d.ts → worktree-fanout-CtQrRDME.d.ts} +3 -2
  38. package/package.json +11 -3
  39. package/dist/chunk-O2UPHN7X.js.map +0 -1
  40. package/dist/chunk-OLPH6W3J.js.map +0 -1
  41. package/dist/chunk-YHS6I2IS.js.map +0 -1
  42. /package/dist/{chunk-QJ6BWENI.js.map → chunk-2DS6T46I.js.map} +0 -0
  43. /package/dist/{chunk-JPURCA2O.js.map → chunk-LWGVVP2C.js.map} +0 -0
  44. /package/dist/{chunk-OL2SEETC.js.map → chunk-SONQUREI.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runLocalHarness
3
- } from "./chunk-O2UPHN7X.js";
3
+ } from "./chunk-5JAUQZQA.js";
4
4
 
5
5
  // src/improvement/agentic-generator.ts
6
6
  import { spawnSync } from "child_process";
@@ -263,4 +263,4 @@ export {
263
263
  mcpBuildPrompt,
264
264
  mcpServeVerifier
265
265
  };
266
- //# sourceMappingURL=chunk-JPURCA2O.js.map
266
+ //# sourceMappingURL=chunk-LWGVVP2C.js.map
@@ -8,7 +8,7 @@ import {
8
8
  DELEGATION_STATUS_DESCRIPTION,
9
9
  DELEGATION_STATUS_INPUT_SCHEMA,
10
10
  DELEGATION_STATUS_TOOL_NAME
11
- } from "./chunk-OLPH6W3J.js";
11
+ } from "./chunk-TSDKBFZP.js";
12
12
 
13
13
  // src/mcp/openai-tools.ts
14
14
  function buildTool(name, description, parameters) {
@@ -45,4 +45,4 @@ export {
45
45
  mcpToolsForRuntimeMcp,
46
46
  mcpToolsForRuntimeMcpSubset
47
47
  };
48
- //# sourceMappingURL=chunk-OL2SEETC.js.map
48
+ //# sourceMappingURL=chunk-SONQUREI.js.map
@@ -1,13 +1,28 @@
1
1
  import {
2
2
  buildLoopSpanNodes
3
3
  } from "./chunk-VMNEQHJR.js";
4
+ import {
5
+ addTokenUsage,
6
+ deleteBoxSafe,
7
+ mapWithConcurrency,
8
+ providerAsExecutor,
9
+ randomSuffix,
10
+ randomUuid,
11
+ resolveAgentEnvironmentProvider,
12
+ sleep,
13
+ stringifySafe,
14
+ throwAbort,
15
+ throwIfAborted,
16
+ withTimeout,
17
+ zeroTokenUsage
18
+ } from "./chunk-Z3RRRPRB.js";
4
19
  import {
5
20
  extractLlmCallEvent
6
21
  } from "./chunk-T2HVQVB4.js";
7
22
  import {
8
23
  harnessInvocation,
9
24
  runLocalHarness
10
- } from "./chunk-O2UPHN7X.js";
25
+ } from "./chunk-5JAUQZQA.js";
11
26
  import {
12
27
  AgentEvalError,
13
28
  ConfigError,
@@ -31,118 +46,6 @@ function assertModelAllowed(model, allowed) {
31
46
 
32
47
  // src/durable/spawn-journal.ts
33
48
  import { createHash } from "crypto";
34
-
35
- // src/runtime/util.ts
36
- async function deleteBoxSafe(box) {
37
- if (!box || typeof box.delete !== "function") return true;
38
- try {
39
- await box.delete();
40
- return true;
41
- } catch {
42
- return false;
43
- }
44
- }
45
- function randomSuffix(len = 8) {
46
- return Math.random().toString(36).slice(2, 2 + len);
47
- }
48
- function randomUuid() {
49
- return crypto.randomUUID();
50
- }
51
- function abortError() {
52
- const err = new Error("aborted");
53
- err.name = "AbortError";
54
- return err;
55
- }
56
- function throwAbort() {
57
- throw abortError();
58
- }
59
- function throwIfAborted(signal) {
60
- if (signal?.aborted) throw abortError();
61
- }
62
- function isAbortError(err) {
63
- return err instanceof Error && err.name === "AbortError";
64
- }
65
- function sleep(ms, signal) {
66
- return new Promise((resolve) => {
67
- if (signal?.aborted) {
68
- resolve();
69
- return;
70
- }
71
- let onAbort;
72
- const timer = setTimeout(() => {
73
- if (onAbort && signal) signal.removeEventListener("abort", onAbort);
74
- resolve();
75
- }, ms);
76
- if (signal) {
77
- onAbort = () => {
78
- clearTimeout(timer);
79
- resolve();
80
- };
81
- signal.addEventListener("abort", onAbort, { once: true });
82
- }
83
- });
84
- }
85
- function withTimeout(promise, ms) {
86
- return new Promise((resolve) => {
87
- const timer = setTimeout(() => resolve(void 0), ms);
88
- promise.then(
89
- (value) => {
90
- clearTimeout(timer);
91
- resolve(value);
92
- },
93
- () => {
94
- clearTimeout(timer);
95
- resolve(void 0);
96
- }
97
- );
98
- });
99
- }
100
- function stringifySafe(value, opts = {}) {
101
- let s;
102
- try {
103
- if (typeof value === "string") {
104
- s = value;
105
- } else {
106
- const json = opts.pretty ? JSON.stringify(value, null, 2) : JSON.stringify(value);
107
- s = json ?? String(value);
108
- }
109
- } catch {
110
- s = String(value);
111
- }
112
- if (opts.max !== void 0 && s.length > opts.max) return `${s.slice(0, opts.max)}\u2026`;
113
- return s;
114
- }
115
- function zeroTokenUsage() {
116
- return { input: 0, output: 0 };
117
- }
118
- function addTokenUsage(acc, delta) {
119
- acc.input += delta.input ?? 0;
120
- acc.output += delta.output ?? 0;
121
- }
122
- async function mapWithConcurrency(items, limit, fn) {
123
- const bound = Math.max(1, Math.floor(limit));
124
- const results = new Array(items.length);
125
- let next = 0;
126
- let failed = false;
127
- const worker = async () => {
128
- while (!failed) {
129
- const i = next;
130
- next += 1;
131
- if (i >= items.length) return;
132
- try {
133
- results[i] = await fn(items[i], i);
134
- } catch (err) {
135
- failed = true;
136
- throw err;
137
- }
138
- }
139
- };
140
- const workerCount = Math.min(bound, items.length);
141
- await Promise.all(Array.from({ length: workerCount }, () => worker()));
142
- return results;
143
- }
144
-
145
- // src/durable/spawn-journal.ts
146
49
  function contentAddress(artifact) {
147
50
  const hex = createHash("sha256").update(stableStringify(artifact), "utf-8").digest("hex");
148
51
  return `sha256:${hex}`;
@@ -990,13 +893,13 @@ async function executeIteration(args) {
990
893
  await destroySandboxSafe(box, args.ctx.traceEmitter, args.runId, args.now);
991
894
  }
992
895
  }
993
- if (isAbortError2(slot.error) || args.signal.aborted) {
896
+ if (isAbortError(slot.error) || args.signal.aborted) {
994
897
  if (slot.error) throw slot.error;
995
898
  throwAbort();
996
899
  }
997
900
  if (slot.error instanceof ValidationError) throw slot.error;
998
901
  }
999
- function isAbortError2(err) {
902
+ function isAbortError(err) {
1000
903
  return err instanceof Error && err.name === "AbortError";
1001
904
  }
1002
905
  var TEARDOWN_TIMEOUT_MS2 = 15e3;
@@ -1604,7 +1507,7 @@ async function runChild(live, executor, childAbort, task, opts, pool, ticket, bl
1604
1507
  } catch (err) {
1605
1508
  reconcileOnce(live.spent);
1606
1509
  await teardownSafe(executor, "brutalKill");
1607
- const aborted = childAbort.signal.aborted || isAbortError3(err);
1510
+ const aborted = childAbort.signal.aborted || isAbortError2(err);
1608
1511
  return downRecord(errMessage(err), aborted || isInfraError(err), executor.metered?.());
1609
1512
  }
1610
1513
  }
@@ -1706,7 +1609,7 @@ function isAgentSpec(value) {
1706
1609
  const v = value;
1707
1610
  return "profile" in v && "harness" in v;
1708
1611
  }
1709
- function isAbortError3(err) {
1612
+ function isAbortError2(err) {
1710
1613
  return typeof err === "object" && err !== null && "name" in err && err.name === "AbortError";
1711
1614
  }
1712
1615
  function isInfraError(err) {
@@ -2207,6 +2110,7 @@ var sandboxSeamKey = "sandbox";
2207
2110
  var cliSeamKey = "cli";
2208
2111
  var bridgeSeamKey = "bridge";
2209
2112
  var cliWorktreeSeamKey = "cli-worktree";
2113
+ var providerSeamKey = "provider";
2210
2114
  function contentRef(prefix, value) {
2211
2115
  let str;
2212
2116
  try {
@@ -2895,6 +2799,14 @@ function createExecutor(config) {
2895
2799
  return cliExecutor(spec, seamed);
2896
2800
  case "cli-worktree":
2897
2801
  return cliWorktreeExecutor(spec, seamed);
2802
+ case "provider": {
2803
+ const providerSeam = readSeam(seamed, providerSeamKey, "provider");
2804
+ const provider = resolveAgentEnvironmentProvider(
2805
+ providerSeam.provider,
2806
+ providerSeam.registry
2807
+ );
2808
+ return providerAsExecutor(provider, providerSeam)(spec, seamed);
2809
+ }
2898
2810
  case "sandbox": {
2899
2811
  const harness = spec.harness ?? config.harness ?? null;
2900
2812
  return sandboxExecutor({ ...spec, harness }, seamed);
@@ -4499,7 +4411,7 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4499
4411
  static async restore(options = {}) {
4500
4412
  const queue = new _DelegationTaskQueue(options);
4501
4413
  const loaded = await queue.store.loadAll();
4502
- queue.rehydrate(loaded);
4414
+ await queue.rehydrate(loaded);
4503
4415
  return queue;
4504
4416
  }
4505
4417
  /**
@@ -4681,17 +4593,18 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4681
4593
  record.trace = trace;
4682
4594
  if (truncated) record.traceTruncated = true;
4683
4595
  }
4684
- rehydrate(loaded) {
4596
+ async rehydrate(loaded) {
4685
4597
  const records = [...loaded].sort((a, b) => a.startedAt.localeCompare(b.startedAt));
4686
4598
  for (const record of records) {
4687
4599
  this.records.set(record.taskId, record);
4688
4600
  if (record.idempotencyKey) this.byIdempotencyKey.set(record.idempotencyKey, record.taskId);
4689
4601
  }
4602
+ const restoreWrites = [];
4690
4603
  for (const record of this.records.values()) {
4691
4604
  if (isTerminal(record.status)) continue;
4692
4605
  if (record.detachedSessionRef && this.resumeDelegate) {
4693
4606
  record.status = "running";
4694
- this.persist(record);
4607
+ restoreWrites.push(this.persist(record));
4695
4608
  this.startResume(record, record.detachedSessionRef, this.resumeDelegate);
4696
4609
  continue;
4697
4610
  }
@@ -4701,9 +4614,12 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4701
4614
  message: record.detachedSessionRef ? `delegation driver restarted while the task was in flight; detached session "${record.detachedSessionRef}" needs a resumeDelegate to be resumed` : "delegation driver restarted while the task was in flight; the run was not detached and cannot be resumed",
4702
4615
  kind: "DriverRestartError"
4703
4616
  };
4704
- this.persist(record);
4617
+ restoreWrites.push(this.persist(record));
4705
4618
  }
4706
- this.enforceRetention();
4619
+ const retentionWrite = this.enforceRetention();
4620
+ if (retentionWrite) restoreWrites.push(retentionWrite);
4621
+ await Promise.all(restoreWrites);
4622
+ if (this.persistFailure) throw this.persistFailure;
4707
4623
  }
4708
4624
  startResume(record, detachedSessionRef, driver) {
4709
4625
  const controller = new AbortController();
@@ -4786,7 +4702,7 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4786
4702
  ]);
4787
4703
  }
4788
4704
  persist(record) {
4789
- if (this.persistFailure) return;
4705
+ if (this.persistFailure) return Promise.resolve();
4790
4706
  const snapshot = structuredClone(record);
4791
4707
  this.persistTail = this.persistTail.then(async () => {
4792
4708
  if (this.persistFailure) return;
@@ -4796,9 +4712,10 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4796
4712
  this.failPersistence(err);
4797
4713
  }
4798
4714
  });
4715
+ return this.persistTail;
4799
4716
  }
4800
4717
  persistRemoval(taskIds) {
4801
- if (this.persistFailure || taskIds.length === 0) return;
4718
+ if (this.persistFailure || taskIds.length === 0) return void 0;
4802
4719
  this.persistTail = this.persistTail.then(async () => {
4803
4720
  if (this.persistFailure) return;
4804
4721
  try {
@@ -4807,6 +4724,7 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4807
4724
  this.failPersistence(err);
4808
4725
  }
4809
4726
  });
4727
+ return this.persistTail;
4810
4728
  }
4811
4729
  failPersistence(cause) {
4812
4730
  if (this.persistFailure) return;
@@ -4818,13 +4736,13 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4818
4736
  this.onPersistError(error);
4819
4737
  }
4820
4738
  enforceRetention() {
4821
- if (!Number.isFinite(this.maxTerminalRecords)) return;
4739
+ if (!Number.isFinite(this.maxTerminalRecords)) return void 0;
4822
4740
  const terminal = [];
4823
4741
  for (const record of this.records.values()) {
4824
4742
  if (isTerminal(record.status)) terminal.push(record);
4825
4743
  }
4826
4744
  const excess = terminal.length - this.maxTerminalRecords;
4827
- if (excess <= 0) return;
4745
+ if (excess <= 0) return void 0;
4828
4746
  terminal.sort(
4829
4747
  (a, b) => (a.completedAt ?? a.startedAt).localeCompare(b.completedAt ?? b.startedAt)
4830
4748
  );
@@ -4835,7 +4753,7 @@ var DelegationTaskQueue = class _DelegationTaskQueue {
4835
4753
  this.byIdempotencyKey.delete(record.idempotencyKey);
4836
4754
  }
4837
4755
  }
4838
- this.persistRemoval(evicted.map((record) => record.taskId));
4756
+ return this.persistRemoval(evicted.map((record) => record.taskId));
4839
4757
  }
4840
4758
  };
4841
4759
  function isTerminal(status) {
@@ -5315,7 +5233,7 @@ var DELEGATE_FEEDBACK_DESCRIPTION = [
5315
5233
  "on the same target are expected and never deduped.",
5316
5234
  "",
5317
5235
  "`refersTo.kind`:",
5318
- ' - "delegation": ref is a taskId returned by delegate_code/delegate_research',
5236
+ ' - "delegation": ref is a taskId returned by delegate_ui_audit',
5319
5237
  ' - "artifact": ref is a URI/path/git-sha \u2014 anything you can dereference',
5320
5238
  ' - "outcome": ref is a free-form description of a downstream result',
5321
5239
  "",
@@ -5787,13 +5705,13 @@ var DELEGATION_STATUS_DESCRIPTION = [
5787
5705
  "(pending | running | completed | failed | cancelled), optional progress,",
5788
5706
  'and the final result when status === "completed".',
5789
5707
  "",
5790
- "Use when: you previously called delegate_code or delegate_research and",
5791
- "need to know whether the work is done. The agent's right rhythm is to",
5708
+ "Use when: you previously kicked off an async delegation (delegate_ui_audit)",
5709
+ "and need to know whether the work is done. The agent's right rhythm is to",
5792
5710
  "call this every minute or two while waiting; do not busy-poll.",
5793
5711
  "",
5794
- "For a completed coder task, `result.output` is a CoderOutput with branch,",
5795
- "patch, test/typecheck results, and diff stats. For a completed research",
5796
- "task, `result.output` is the items + citations + proposedWrites bundle.",
5712
+ "For a completed delegate_ui_audit run, `result.output` is the array of UI",
5713
+ "findings \u2014 one self-contained Markdown finding per issue, each with an",
5714
+ "embedded screenshot and a suggested fix.",
5797
5715
  "",
5798
5716
  "Pass includeTrace: true to also receive the journaled loop-trace span",
5799
5717
  "tree (loop \u2192 round \u2192 iteration, with placement/cost/verdict metadata).",
@@ -5805,7 +5723,7 @@ var DELEGATION_STATUS_DESCRIPTION = [
5805
5723
  var DELEGATION_STATUS_INPUT_SCHEMA = {
5806
5724
  type: "object",
5807
5725
  properties: {
5808
- taskId: { type: "string", description: "Returned by delegate_code / delegate_research." },
5726
+ taskId: { type: "string", description: "Returned by delegate_ui_audit." },
5809
5727
  includeTrace: {
5810
5728
  type: "boolean",
5811
5729
  description: "Also return the journaled loop-trace span tree for this delegation. Default false."
@@ -6168,15 +6086,6 @@ function routerBrainFromProfile(profile, deps) {
6168
6086
 
6169
6087
  export {
6170
6088
  assertModelAllowed,
6171
- deleteBoxSafe,
6172
- randomSuffix,
6173
- throwAbort,
6174
- throwIfAborted,
6175
- isAbortError,
6176
- sleep,
6177
- stringifySafe,
6178
- zeroTokenUsage,
6179
- addTokenUsage,
6180
6089
  contentAddress,
6181
6090
  InMemoryResultBlobStore,
6182
6091
  InMemorySpawnJournal,
@@ -6269,4 +6178,4 @@ export {
6269
6178
  createInProcessTransport,
6270
6179
  serveCoordinationMcp
6271
6180
  };
6272
- //# sourceMappingURL=chunk-OLPH6W3J.js.map
6181
+ //# sourceMappingURL=chunk-TSDKBFZP.js.map