@tangle-network/agent-runtime 0.325.15 → 0.325.17-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 (67) hide show
  1. package/dist/{activation-iY9Y4jXA.js → activation--9-iyGR8.js} +3 -3
  2. package/dist/{activation-iY9Y4jXA.js.map → activation--9-iyGR8.js.map} +1 -1
  3. package/dist/{activation-BZz9_4us.d.ts → activation-Q3CJgiCu.d.ts} +2 -2
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{bundle-DqvlwhKP.js → bundle-BJJmfEsw.js} +2 -2
  7. package/dist/{bundle-DqvlwhKP.js.map → bundle-BJJmfEsw.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +5 -5
  9. package/dist/{coordination-driver--ziIpb-L.js → coordination-driver-DkkUVe9g.js} +4 -4
  10. package/dist/{coordination-driver--ziIpb-L.js.map → coordination-driver-DkkUVe9g.js.map} +1 -1
  11. package/dist/{delegate-kimZgMCA.js → delegate-BDsaIl2K.js} +2 -2
  12. package/dist/{delegate-kimZgMCA.js.map → delegate-BDsaIl2K.js.map} +1 -1
  13. package/dist/durable.d.ts +1 -1
  14. package/dist/durable.js +5 -5
  15. package/dist/{graph-2WpXlBwe.js → graph-Cuz6Ubzd.js} +4 -4
  16. package/dist/{graph-2WpXlBwe.js.map → graph-Cuz6Ubzd.js.map} +1 -1
  17. package/dist/{improvement-cycle-CpObFDMU.js → improvement-cycle-B5Z8cHKx.js} +6 -6
  18. package/dist/{improvement-cycle-CpObFDMU.js.map → improvement-cycle-B5Z8cHKx.js.map} +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +9 -9
  21. package/dist/intelligence.d.ts +2 -2
  22. package/dist/intelligence.js +7 -7
  23. package/dist/kernel.d.ts +2 -2
  24. package/dist/kernel.js +9 -9
  25. package/dist/{loop-runner-bin-JQHD3oC0.js → loop-runner-bin-7m7KA5MN.js} +3 -3
  26. package/dist/{loop-runner-bin-JQHD3oC0.js.map → loop-runner-bin-7m7KA5MN.js.map} +1 -1
  27. package/dist/{loop-runner-bin-UpYsI0iM.d.ts → loop-runner-bin-Co7JKSwi.d.ts} +2 -2
  28. package/dist/loop-runner-bin.d.ts +1 -1
  29. package/dist/loop-runner-bin.js +1 -1
  30. package/dist/mcp/bin.js +3 -3
  31. package/dist/mcp/index.d.ts +2 -2
  32. package/dist/mcp/index.js +5 -5
  33. package/dist/{openai-tools-BoHnTyO2.d.ts → openai-tools-CbgZrQJ_.d.ts} +2 -2
  34. package/dist/placement.d.ts +1 -1
  35. package/dist/{prepare-0kTqt9qn.js → prepare-DpavgJT8.js} +7 -8
  36. package/dist/{prepare-0kTqt9qn.js.map → prepare-DpavgJT8.js.map} +1 -1
  37. package/dist/{profile-DhZvQngF.js → profile-ZS7_KLwK.js} +55 -30
  38. package/dist/profile-ZS7_KLwK.js.map +1 -0
  39. package/dist/{profile-materialization-BnoEf1co.d.ts → profile-materialization-C5-t3HJ7.d.ts} +8 -3
  40. package/dist/profiles.d.ts +1 -1
  41. package/dist/{protected-model-port-CFQj32Lt.js → protected-model-port-BLyyfL3l.js} +4 -4
  42. package/dist/{protected-model-port-CFQj32Lt.js.map → protected-model-port-BLyyfL3l.js.map} +1 -1
  43. package/dist/{provision-supervisor-WNnSjEEe.js → provision-supervisor-4BoHpGFJ.js} +4 -4
  44. package/dist/{provision-supervisor-WNnSjEEe.js.map → provision-supervisor-4BoHpGFJ.js.map} +1 -1
  45. package/dist/{runtime-CekT14Tg.js → runtime-DF2Mjm4l.js} +173 -177
  46. package/dist/runtime-DF2Mjm4l.js.map +1 -0
  47. package/dist/{search-executor-BIYpUqvP.js → search-executor-C-b4NaFl.js} +3 -3
  48. package/dist/{search-executor-BIYpUqvP.js.map → search-executor-C-b4NaFl.js.map} +1 -1
  49. package/dist/{server-DPNrNMRK.js → server-CcHaXgUT.js} +4 -4
  50. package/dist/{server-DPNrNMRK.js.map → server-CcHaXgUT.js.map} +1 -1
  51. package/dist/{supervise-ByxF154k.js → supervise-BlaB4CeL.js} +11 -50
  52. package/dist/supervise-BlaB4CeL.js.map +1 -0
  53. package/dist/{supervisor-BiWdGonz.js → supervisor-fq4JGynd.js} +13 -61
  54. package/dist/supervisor-fq4JGynd.js.map +1 -0
  55. package/dist/testing.d.ts +1 -1
  56. package/dist/testing.js +14 -14
  57. package/dist/tui/index.d.ts +1 -1
  58. package/dist/tui/index.js +1 -1
  59. package/dist/{types-Ca5R4QXR.d.ts → types-5r334mcg.d.ts} +2 -4
  60. package/dist/{sandbox-profile-compat-CVgQWb7T.js → workspace-streams-CcoARX4v.js} +12 -49
  61. package/dist/workspace-streams-CcoARX4v.js.map +1 -0
  62. package/package.json +9 -9
  63. package/dist/profile-DhZvQngF.js.map +0 -1
  64. package/dist/runtime-CekT14Tg.js.map +0 -1
  65. package/dist/sandbox-profile-compat-CVgQWb7T.js.map +0 -1
  66. package/dist/supervise-ByxF154k.js.map +0 -1
  67. package/dist/supervisor-BiWdGonz.js.map +0 -1
@@ -1,19 +1,19 @@
1
1
  import { o as writeAtomicDurableFile } from "./durable-file-B_eJr6Mb.js";
2
- import { $i as InMemoryResultBlobStore, Cn as assertBoxlessPromptOptions, En as runBrainLoop, Ft as createExecutorRegistry, Ki as notifySandboxEventObserver, Lt as createWorktreeCliExecutor, Pt as createExecutor, Ti as executableAgentSpecSnapshot, Tn as routerBrain, Yn as runAbortable, da as detachedFrozen, ea as InMemorySpawnJournal, fa as detachedSnapshot, gn as defaultSelectWinner, gt as mapExecutorResult, ht as gateOnDeliverable, j as settledToIteration, kt as verdictFromJudgeScore, mt as rollingDispatch, r as createSupervisor, rt as coordinationProfileToolPrefix, sa as isTraceAnalysisStore, ta as insideCursorNamespace, ua as contentAddress, v as withDriverExecutor, vn as runAgentRounds, wi as executableAgentProfileSnapshot, wn as readPromptOptions, yn as createSandboxLineage, yt as CheckUnavailableError } from "./supervisor-BiWdGonz.js";
2
+ import { $i as InMemorySpawnJournal, Ci as executableAgentProfileSnapshot, Cn as assertBoxlessPromptOptions, En as runBrainLoop, Ft as createExecutorRegistry, Gi as notifySandboxEventObserver, Lt as createWorktreeCliExecutor, Pt as createExecutor, Qi as InMemoryResultBlobStore, Tn as routerBrain, da as detachedSnapshot, ea as insideCursorNamespace, gn as defaultSelectWinner, gt as mapExecutorResult, ht as gateOnDeliverable, j as settledToIteration, kt as verdictFromJudgeScore, la as contentAddress, mt as rollingDispatch, oa as isTraceAnalysisStore, r as createSupervisor, rt as coordinationProfileToolPrefix, ua as detachedFrozen, v as withDriverExecutor, vn as runAgentRounds, wi as executableAgentSpecSnapshot, wn as readPromptOptions, yn as createSandboxLineage, yt as CheckUnavailableError } from "./supervisor-fq4JGynd.js";
3
3
  import { i as ConfigError, m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
4
- import { B as runAgentic, G as observe, K as renderReport, U as ObservationError, V as sample, X as strategyAuthorMethod, a as reconcileInterruptedSearchCalls, c as searchExecutor, q as profileChatClient, r as dedicatedLane, x as runtimeShipDecision, z as refine } from "./search-executor-BIYpUqvP.js";
5
- import { $ as isAsyncIterable, Ct as armDeadlineTimer, F as canonicalCandidateDigest$1, G as chargedTokens, K as cloneSpend, M as markPutStreamVerified, Q as isAbortError, U as addSpend, V as sha256Bytes$1, X as fnv1a32Hex, Y as errorMessage, Z as hasCompleteCacheBreakdown, at as sleep, dt as zeroSpend, et as mapWithConcurrency, nt as randomSuffix, ot as stringifySafe, w as captureMaterializedWorkspace, x as WorkspaceScanLimitError, z as immutableCandidateValue } from "./sandbox-profile-compat-CVgQWb7T.js";
4
+ import { B as runAgentic, G as observe, K as renderReport, U as ObservationError, V as sample, X as strategyAuthorMethod, a as reconcileInterruptedSearchCalls, c as searchExecutor, q as profileChatClient, r as dedicatedLane, x as runtimeShipDecision, z as refine } from "./search-executor-C-b4NaFl.js";
5
+ import { A as markPutStreamVerified, J as fnv1a32Hex, L as immutableCandidateValue, N as canonicalCandidateDigest$1, S as captureMaterializedWorkspace, U as chargedTokens, V as addSpend, W as cloneSpend, X as isAbortError, Y as hasCompleteCacheBreakdown, Z as isAsyncIterable, et as randomSuffix, it as stringifySafe, lt as zeroSpend, q as errorMessage, rt as sleep, xt as armDeadlineTimer, y as WorkspaceScanLimitError, z as sha256Bytes$1 } from "./workspace-streams-CcoARX4v.js";
6
6
  import { a as readCommittedJsonLines, i as readCommittedJsonFile, n as isNoEntError, o as upsertCommittedJsonLine, s as withJsonlFileLock, t as appendCommittedJsonLine } from "./jsonl-file-DBv31uPi.js";
7
7
  import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile, v as harnessRunsAgent } from "./model-policy-CyCUwHed.js";
8
8
  import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
9
9
  import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction-DFCeo4vg.js";
10
- import { D as foldCoordinationRecords, w as createInMemoryRunContext } from "./coordination-driver--ziIpb-L.js";
11
- import { r as supervise } from "./supervise-ByxF154k.js";
10
+ import { D as foldCoordinationRecords, w as createInMemoryRunContext } from "./coordination-driver-DkkUVe9g.js";
11
+ import { r as supervise } from "./supervise-BlaB4CeL.js";
12
12
  import { a as graphRunsFor, d as recordGraphRun, i as graphRegistry, l as lookupGraph, p as taskShapeDigest, r as graphFromStored, t as digestOfGraph } from "./graph-registry-DAI6KNXB.js";
13
13
  import "./run-layout-Cu8H7aeh.js";
14
- import "./provision-supervisor-WNnSjEEe.js";
15
- import "./delegate-kimZgMCA.js";
16
- import "./graph-2WpXlBwe.js";
14
+ import "./provision-supervisor-4BoHpGFJ.js";
15
+ import "./delegate-BDsaIl2K.js";
16
+ import "./graph-Cuz6Ubzd.js";
17
17
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
18
18
  import { CODING_HARNESSES, DEFAULT_TRACE_ANALYST_KINDS, InMemoryTraceStore, OUTPUT_VALUE, benjaminiHochberg, buildTrajectory, computeFindingId as computeFindingId$1, confidenceInterval, createTraceAnalyst, expandProfileAxes, makeFinding as makeFinding$1, pairedBootstrap, paretoFrontier, wilcoxonSignedRank, wilson } from "@tangle-network/agent-eval";
19
19
  import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
@@ -4918,9 +4918,6 @@ const SHARD = /^[0-9a-f]{2}$/u;
4918
4918
  const SAFE_NAMESPACE = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/u;
4919
4919
  const RECEIPT_SCHEMA = "agent-runtime.private-cas-durable-receipt.v1";
4920
4920
  const DURABLE_ATTEMPTS = 3;
4921
- const DURABLE_STALL_MS = 12e4;
4922
- const BUFFERED_BYTES_PER_MS = 256;
4923
- const OFFLOAD_COPIES_AT_ONCE = 16;
4924
4921
  async function realDirectory(path) {
4925
4922
  const entry = await lstat(path);
4926
4923
  if (!entry.isDirectory() || entry.isSymbolicLink()) throw new Error(`private CAS directory is not a real directory: ${path}`);
@@ -4975,8 +4972,7 @@ async function readLocal(path) {
4975
4972
  function createPrivateCasArtifactPort(root, namespace, options = {}) {
4976
4973
  if (!isAbsolute(root)) throw new Error("private CAS root must be absolute");
4977
4974
  if (!SAFE_NAMESPACE.test(namespace) || namespace === "." || namespace === "..") throw new Error("private CAS namespace must be one safe identifier");
4978
- const { durable, localBudgetBytes, durableStallMs = DURABLE_STALL_MS } = options;
4979
- if (!Number.isSafeInteger(durableStallMs) || durableStallMs <= 0) throw new Error("private CAS durableStallMs must be a positive integer");
4975
+ const { durable, localBudgetBytes } = options;
4980
4976
  if (localBudgetBytes !== void 0 && (durable === void 0 || !Number.isSafeInteger(localBudgetBytes) || localBudgetBytes < 0)) throw new Error("private CAS localBudgetBytes needs a durable store and a non-negative integer");
4981
4977
  const store = join(resolve(root), "sha256");
4982
4978
  const receipts = join(resolve(root), "durable", "sha256");
@@ -5018,42 +5014,23 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5018
5014
  await rename(temporary, join(receipts, hex));
5019
5015
  await syncDirectory(receipts);
5020
5016
  };
5021
- const watchAttempt = (idleMs, signal) => {
5022
- const stall = new AbortController();
5023
- let timer;
5024
- const touch = () => {
5025
- clearTimeout(timer);
5026
- timer = setTimeout(() => stall.abort(/* @__PURE__ */ new Error(`durable copy moved no bytes for ${idleMs} ms`)), idleMs);
5027
- };
5028
- touch();
5029
- const attempt = signal === void 0 ? stall.signal : AbortSignal.any([signal, stall.signal]);
5030
- return {
5031
- signal: attempt,
5032
- touch,
5033
- run: (act) => runAbortable(act, attempt, "private CAS durable copy was cancelled"),
5034
- done: () => clearTimeout(timer)
5035
- };
5036
- };
5037
5017
  const storeDurably = async (digest, bytes, signal) => {
5038
5018
  let failure;
5039
5019
  for (let attempt = 1; attempt <= DURABLE_ATTEMPTS; attempt++) {
5040
5020
  signal?.throwIfAborted();
5041
- const watch = watchAttempt(durableStallMs + Math.ceil(bytes.byteLength / BUFFERED_BYTES_PER_MS), signal);
5042
5021
  try {
5043
- await watch.run(() => durable.put({
5022
+ await durable.put({
5044
5023
  namespace,
5045
5024
  digest,
5046
5025
  bytes,
5047
- signal: watch.signal
5048
- }));
5026
+ ...signal === void 0 ? {} : { signal }
5027
+ });
5049
5028
  await writeReceipt(digest, bytes.byteLength);
5050
5029
  return;
5051
5030
  } catch (error) {
5052
5031
  failure = error;
5053
5032
  if (signal?.aborted) throw error;
5054
5033
  if (attempt < DURABLE_ATTEMPTS) await new Promise((settle) => setTimeout(settle, 1e3 * 4 ** (attempt - 1)));
5055
- } finally {
5056
- watch.done();
5057
5034
  }
5058
5035
  }
5059
5036
  throw failure;
@@ -5084,141 +5061,92 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5084
5061
  }
5085
5062
  return objects;
5086
5063
  };
5087
- const streamDurably = async (digest, path, byteLength, signal) => {
5088
- const ref = {
5089
- locator: {
5090
- kind: "private-cas",
5091
- namespace,
5092
- digest
5093
- },
5094
- sha256: digest,
5095
- byteLength
5096
- };
5097
- let failure;
5098
- for (let attempt = 1; attempt <= DURABLE_ATTEMPTS; attempt++) {
5099
- signal?.throwIfAborted();
5100
- const watch = watchAttempt(durableStallMs, signal);
5101
- const chunks = readObject(path, ref, watch.signal);
5102
- const pulled = (async function* () {
5103
- for await (const chunk of chunks) {
5104
- watch.touch();
5105
- yield chunk;
5106
- }
5107
- })();
5108
- try {
5109
- await watch.run(() => durable.putStream({
5110
- namespace,
5111
- digest,
5112
- byteLength,
5113
- chunks: pulled,
5114
- signal: watch.signal
5115
- }));
5116
- await writeReceipt(digest, byteLength);
5117
- return;
5118
- } catch (error) {
5119
- failure = error;
5120
- if (signal?.aborted) throw error;
5121
- if (attempt < DURABLE_ATTEMPTS) await new Promise((settle) => setTimeout(settle, 1e3 * 4 ** (attempt - 1)));
5122
- } finally {
5123
- watch.done();
5124
- await chunks.return(void 0);
5125
- }
5126
- }
5127
- throw failure;
5128
- };
5129
- let lastPass;
5130
- const settlePut = async (sha, byteLength, linked, upload, signal) => {
5131
- if (upload !== void 0 && !await hasReceipt(sha)) await copyOnce(sha, upload, signal).catch(() => void 0);
5132
- const durableNow = await hasReceipt(sha);
5133
- const added = linked ? byteLength : 0;
5134
- const known = lastPass;
5135
- if (durableNow && known !== void 0 && known.pending === 0 && (localBudgetBytes === void 0 || known.localBytes + added <= localBudgetBytes)) {
5136
- known.localBytes += added;
5137
- return;
5138
- }
5139
- await offload(signal);
5140
- };
5141
5064
  const uploading = /* @__PURE__ */ new Map();
5142
- const waitFor = (copy, signal) => {
5143
- const settled = copy.catch(() => void 0);
5144
- return signal === void 0 ? settled : runAbortable(() => settled, signal, "private CAS wait for a copy in flight was cancelled");
5145
- };
5146
- const copyOnce = async (sha, copy, signal) => {
5147
- for (let inflight = uploading.get(sha); inflight !== void 0; inflight = uploading.get(sha)) {
5148
- await waitFor(inflight, signal);
5149
- if (await hasReceipt(sha)) return false;
5150
- }
5151
- const current = copy();
5152
- uploading.set(sha, current);
5153
- try {
5154
- await current;
5155
- return true;
5156
- } finally {
5157
- if (uploading.get(sha) === current) uploading.delete(sha);
5158
- }
5159
- };
5160
5065
  const sweep = async (signal) => {
5161
5066
  const objects = await localObjects();
5067
+ const pending = [];
5068
+ let uploaded = 0;
5162
5069
  let refusal;
5163
- const outcomes = await mapWithConcurrency(objects, durable === void 0 || durable.putStream && durable.getStream ? OFFLOAD_COPIES_AT_ONCE : 1, async ({ hex, path, size }) => {
5164
- const inflight = uploading.get(hex);
5165
- if (inflight !== void 0) await waitFor(inflight, signal);
5166
- if (await hasReceipt(hex)) return {
5167
- hex,
5168
- durable: true,
5169
- copied: false
5170
- };
5171
- if (durable === void 0) return {
5172
- hex,
5173
- durable: false
5174
- };
5175
- const digest = `sha256:${hex}`;
5176
- if (refusal !== void 0) return {
5177
- hex,
5178
- durable: false,
5179
- error: `not attempted after an earlier refusal: ${refusal}`
5180
- };
5070
+ const durableHex = /* @__PURE__ */ new Set();
5071
+ for (const object of objects) {
5072
+ if (await hasReceipt(object.hex)) {
5073
+ durableHex.add(object.hex);
5074
+ continue;
5075
+ }
5076
+ if (durable === void 0) continue;
5077
+ const digest = `sha256:${object.hex}`;
5078
+ if (uploading.has(object.hex)) {
5079
+ pending.push({
5080
+ digest,
5081
+ error: "durable upload in progress"
5082
+ });
5083
+ continue;
5084
+ }
5085
+ if (refusal !== void 0) {
5086
+ pending.push({
5087
+ digest,
5088
+ error: `not attempted after an earlier refusal: ${refusal}`
5089
+ });
5090
+ continue;
5091
+ }
5181
5092
  try {
5182
- if (durable.putStream && durable.getStream) return {
5183
- hex,
5184
- durable: true,
5185
- copied: await copyOnce(hex, () => streamDurably(digest, path, size, signal), signal)
5186
- };
5187
- const bytes = await readLocal(path);
5188
- if (bytes === void 0) return {
5189
- hex,
5190
- durable: false
5191
- };
5192
- if (sha256(bytes) !== digest) return {
5193
- hex,
5194
- durable: false,
5195
- error: "local object failed digest verification; it stays on the host"
5196
- };
5197
- return {
5198
- hex,
5199
- durable: true,
5200
- copied: await copyOnce(hex, () => storeDurably(digest, bytes, signal), signal)
5201
- };
5093
+ if (durable.putStream && durable.getStream) {
5094
+ const ref = {
5095
+ locator: {
5096
+ kind: "private-cas",
5097
+ namespace,
5098
+ digest
5099
+ },
5100
+ sha256: digest,
5101
+ byteLength: object.size
5102
+ };
5103
+ let failure;
5104
+ for (let attempt = 1; attempt <= DURABLE_ATTEMPTS; attempt++) {
5105
+ signal?.throwIfAborted();
5106
+ const chunks = readObject(object.path, ref, signal);
5107
+ try {
5108
+ await durable.putStream({
5109
+ namespace,
5110
+ digest,
5111
+ byteLength: object.size,
5112
+ chunks,
5113
+ signal
5114
+ });
5115
+ await writeReceipt(digest, object.size);
5116
+ failure = void 0;
5117
+ break;
5118
+ } catch (error) {
5119
+ failure = error;
5120
+ if (signal?.aborted) throw error;
5121
+ if (attempt < DURABLE_ATTEMPTS) await new Promise((settle) => setTimeout(settle, 1e3 * 4 ** (attempt - 1)));
5122
+ } finally {
5123
+ await chunks.return(void 0);
5124
+ }
5125
+ }
5126
+ if (failure !== void 0) throw failure;
5127
+ } else {
5128
+ const bytes = await readLocal(object.path);
5129
+ if (bytes === void 0) continue;
5130
+ if (sha256(bytes) !== digest) {
5131
+ pending.push({
5132
+ digest,
5133
+ error: "local object failed digest verification; it stays on the host"
5134
+ });
5135
+ continue;
5136
+ }
5137
+ await storeDurably(digest, bytes, signal);
5138
+ }
5139
+ durableHex.add(object.hex);
5140
+ uploaded++;
5202
5141
  } catch (error) {
5203
5142
  if (signal?.aborted) throw error;
5204
- refusal ??= message(error);
5205
- return {
5206
- hex,
5207
- durable: false,
5208
- error: message(error)
5209
- };
5143
+ refusal = message(error);
5144
+ pending.push({
5145
+ digest,
5146
+ error: refusal
5147
+ });
5210
5148
  }
5211
- });
5212
- const pending = [];
5213
- let uploaded = 0;
5214
- const durableHex = /* @__PURE__ */ new Set();
5215
- for (const outcome of outcomes) if (outcome.durable) {
5216
- durableHex.add(outcome.hex);
5217
- if (outcome.copied) uploaded++;
5218
- } else if (outcome.error !== void 0) pending.push({
5219
- digest: `sha256:${outcome.hex}`,
5220
- error: outcome.error
5221
- });
5149
+ }
5222
5150
  let localBytes = objects.reduce((total, object) => total + object.size, 0);
5223
5151
  let evicted = 0;
5224
5152
  if (localBudgetBytes !== void 0) for (const object of [...objects].sort((a, b) => a.modifiedMs - b.modifiedMs)) {
@@ -5232,10 +5160,6 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5232
5160
  localBytes -= object.size;
5233
5161
  evicted++;
5234
5162
  }
5235
- lastPass = {
5236
- localBytes,
5237
- pending: pending.length
5238
- };
5239
5163
  let receiptCount = 0;
5240
5164
  try {
5241
5165
  receiptCount = (await readdir(receipts)).filter((name) => HEX.test(name)).length;
@@ -5349,12 +5273,10 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5349
5273
  const directory = join(store, sha.slice(0, 2));
5350
5274
  await checkDirectories(directory, true);
5351
5275
  signal?.throwIfAborted();
5352
- let linked = true;
5353
5276
  try {
5354
5277
  await link(temporary, path);
5355
5278
  } catch (error) {
5356
5279
  if (error.code !== "EEXIST") throw error;
5357
- linked = false;
5358
5280
  for await (const _chunk of readStream(ref, { signal }));
5359
5281
  }
5360
5282
  const dir = await open(directory, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
@@ -5363,7 +5285,7 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5363
5285
  } finally {
5364
5286
  await dir.close();
5365
5287
  }
5366
- if (durable !== void 0) await settlePut(sha, byteLength, linked, () => streamDurably(digest, path, byteLength, signal), signal);
5288
+ if (durable !== void 0) await offload(signal);
5367
5289
  return ref;
5368
5290
  } finally {
5369
5291
  await unlink(temporary).catch((error) => {
@@ -5379,7 +5301,17 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5379
5301
  async put({ bytes, signal }) {
5380
5302
  signal?.throwIfAborted();
5381
5303
  const digest = sha256(bytes);
5382
- return putBuffered(bytes, digest, hexOf(digest), signal);
5304
+ const sha = hexOf(digest);
5305
+ if (durable !== void 0) uploading.set(sha, (uploading.get(sha) ?? 0) + 1);
5306
+ try {
5307
+ return await putBuffered(bytes, digest, sha, signal);
5308
+ } finally {
5309
+ if (durable !== void 0) {
5310
+ const count = (uploading.get(sha) ?? 1) - 1;
5311
+ if (count === 0) uploading.delete(sha);
5312
+ else uploading.set(sha, count);
5313
+ }
5314
+ }
5383
5315
  },
5384
5316
  async read(ref) {
5385
5317
  return readRef(ref);
@@ -5423,14 +5355,12 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5423
5355
  } finally {
5424
5356
  await file.close();
5425
5357
  }
5426
- let linked = true;
5427
5358
  try {
5428
5359
  signal?.throwIfAborted();
5429
5360
  try {
5430
5361
  await link(temporary, path);
5431
5362
  } catch (error) {
5432
5363
  if (error.code !== "EEXIST") throw error;
5433
- linked = false;
5434
5364
  }
5435
5365
  await syncDirectory(directory);
5436
5366
  } finally {
@@ -5446,7 +5376,10 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
5446
5376
  byteLength: bytes.byteLength
5447
5377
  };
5448
5378
  await readRef(ref);
5449
- if (durable !== void 0) await settlePut(sha, bytes.byteLength, linked, () => storeDurably(digest, bytes, signal), signal);
5379
+ if (durable !== void 0) {
5380
+ if (!await hasReceipt(sha)) await storeDurably(digest, bytes, signal).catch(() => void 0);
5381
+ await offload(signal);
5382
+ }
5450
5383
  return ref;
5451
5384
  }
5452
5385
  async function readRef(ref) {
@@ -6032,11 +5965,11 @@ async function openSandboxRun(client, options, deliverable) {
6032
5965
  ...error !== void 0 ? { error: errorMessage(error) } : {}
6033
5966
  });
6034
5967
  async function settle(box, events, turnIndex, turnKind) {
6035
- const collected = [];
5968
+ const collector = createTurnEventCollector();
6036
5969
  const outcomeTracker = createAgentRunOutcomeTracker();
6037
5970
  try {
6038
5971
  for await (const ev of events) {
6039
- collected.push(ev);
5972
+ collector.push(ev);
6040
5973
  outcomeTracker.observe(ev);
6041
5974
  notifySandboxEventObserver(ev, options.onSandboxEvent, {
6042
5975
  turnIndex,
@@ -6045,9 +5978,10 @@ async function openSandboxRun(client, options, deliverable) {
6045
5978
  });
6046
5979
  }
6047
5980
  } catch (err) {
6048
- if (isAbortError(err)) throw new SandboxRunAbortError(collected);
5981
+ if (isAbortError(err)) throw new SandboxRunAbortError(collector.events());
6049
5982
  throw err;
6050
5983
  }
5984
+ const collected = collector.events();
6051
5985
  const outcome = outcomeTracker.finish();
6052
5986
  if (deliverable.kind === "events") return {
6053
5987
  out: deliverable.fromEvents(collected),
@@ -6219,6 +6153,68 @@ function hashText(value) {
6219
6153
  }
6220
6154
  return (hash >>> 0).toString(16).padStart(8, "0");
6221
6155
  }
6156
+ /**
6157
+ * Collect one turn's events, keeping only the newest snapshot of each streamed text or
6158
+ * reasoning part.
6159
+ *
6160
+ * opencode sends `message.part.updated` once per token, and every frame carries the part's
6161
+ * whole cumulative text, so keeping every frame holds O(L²) bytes per turn: two concurrent
6162
+ * audit workflows took the platform API from 459 MB to an OOM at 1.95 GB in 11 minutes.
6163
+ * A snapshot (a frame whose part carries `text`) whose text extends the previous snapshot
6164
+ * of the same part replaces it and moves to the newest position, which is the rule the
6165
+ * Sandbox SDK's text collectors already apply, so the collected text is unchanged. The kept
6166
+ * frame drops its `delta`, because its text already holds every earlier increment and a
6167
+ * reader that joins `delta ?? part.text` across frames would otherwise read only the last
6168
+ * one. Delta-only frames and every other event are kept as they arrived.
6169
+ */
6170
+ function createTurnEventCollector() {
6171
+ const slots = [];
6172
+ const snapshots = /* @__PURE__ */ new Map();
6173
+ return {
6174
+ push(event) {
6175
+ const snapshot = partSnapshot(event);
6176
+ if (!snapshot) {
6177
+ slots.push(event);
6178
+ return;
6179
+ }
6180
+ const previous = snapshots.get(snapshot.key);
6181
+ const extends_ = previous !== void 0 && snapshot.text.startsWith(previous.text);
6182
+ if (extends_) slots[previous.at] = void 0;
6183
+ snapshots.set(snapshot.key, {
6184
+ at: slots.length,
6185
+ text: snapshot.text
6186
+ });
6187
+ slots.push(extends_ ? withoutDelta(event) : event);
6188
+ },
6189
+ events() {
6190
+ return slots.filter((event) => event !== void 0);
6191
+ }
6192
+ };
6193
+ }
6194
+ function partSnapshot(event) {
6195
+ if (event?.type !== "message.part.updated") return void 0;
6196
+ const data = asRecord$1(event.data);
6197
+ const part = asRecord$1(data?.part) ?? asRecord$1(asRecord$1(data?.properties)?.part);
6198
+ if (!part || typeof part.id !== "string") return void 0;
6199
+ if (part.type !== "text" && part.type !== "reasoning" && part.type !== "thinking") return void 0;
6200
+ const text = typeof part.text === "string" ? part.text : typeof part.content === "string" ? part.content : void 0;
6201
+ return text === void 0 ? void 0 : {
6202
+ key: `${part.type}:${part.id}`,
6203
+ text
6204
+ };
6205
+ }
6206
+ function withoutDelta(event) {
6207
+ const data = asRecord$1(event.data);
6208
+ if (!data || !("delta" in data)) return event;
6209
+ const { delta: _delta, ...rest } = data;
6210
+ return {
6211
+ ...event,
6212
+ data: rest
6213
+ };
6214
+ }
6215
+ function asRecord$1(value) {
6216
+ return value !== null && typeof value === "object" ? value : void 0;
6217
+ }
6222
6218
  //#endregion
6223
6219
  //#region src/runtime/authored-code.ts
6224
6220
  /**
@@ -9350,4 +9346,4 @@ function tail(s) {
9350
9346
  //#endregion
9351
9347
  export { runBenchmark as $, McpSpawnFault as $t, connectRemoteSupervisor as A, inlineSandboxClient as At, chatTransportExecutor as B, runIsolatedCheck as Bt, analyzeTrace as C, observationFromRegistry as Ct, compileSearchSpec as D, defineLeaderboard as Dt, assertSearchSpec as E, harvestCorpus as Et, profileRunsForName as F, checkProgramDigest as Ft, assertStrategyContract as G, leaderboard as Gt, createChatSessionStore as H, deterministicCompletion as Ht, recordProfileRun as I, declaredCheckDeliverable as It, strategyAuthorSystemPrompt as J, renderLeaderboardMarkdown as Jt, authorStrategy as K, pairwiseSignificance as Kt, patchDelivered as L, declaredCheckDigest as Lt, loadProfile as M, loopDispatch as Mt, pickBestProfile as N, superviseDispatch as Nt, searchPresets as O, resolveSandboxClient as Ot, profileRegistry as P, assertDeclaredCheck as Pt, printBenchmarkReport as Q, openSqlRunStore as Qt, runCoderChecks as R, declaredCheckJudge as Rt, withUntrackedArtifacts as S, registryScopeAnalyst as St, SEARCH_SPEC_CORRELATION_KEY as T, HarvestError as Tt, runStrategyEvolution as U, sentinelCompletion as Ut, chatWorkerSeam as V, completionAuthorizes as Vt, strategyTournament as W, stopSentinel as Wt, openSandboxRun as X, renderPairwiseMarkdown as Xt, SandboxRunAbortError as Y, renderLeaderboardSvg as Yt, createS3PrivateCasStore as Z, SqlRunOwnershipError as Zt, VERIFY_TAIL_CHARS as _, verify as _t, localShell as a, mcpSecretEnvMetadataKey as an, builtinShapes as at, settledWorkerOut as b, buildSteerContext as bt, createVerifierEnvironment as c, secretEnvOfMcpServer as cn, FileCorpus as ct, harvestSurfaceDiffs as d, fanout as dt, connectStdioMcp as en, createPrivateCasArtifactPort as et, analystsFromRegistry as f, flatWidenGate as ft, NOTE_MAX_CHARS as g, selectValidWinner as gt, EVIDENCE_MAX_CHARS as h, pipeline as ht, jjWorkspace as i, envKeyProvider as in, runPersonified as it, bestProfileFor as j, loopCampaignDispatch as jt, searchSpecDigest as k, localSandboxClient as kt, boxSurfaceReader as l, createTangleSandboxExactProcessProvider as ln, InMemoryCorpus as lt, worktreeFanout as m, panel as mt, makeFinding$1 as n, createMcpEnvironment as nn, trajectoryReport as nt, runInWorkspace as o, resolveMcpServerLaunch as on, createShapeRegistry as ot, failuresAnalyst as p, loopUntil as pt, strategyAuthorContract as q, renderLeaderboardHtml as qt, gitWorkspace as r, sanitizeMcpToolSchema as rn, definePersona as rt, createWaterfallCollector as s, resolveSecretEnv as sn, registerShape as st, computeFindingId$1 as t, materializeLocalMcp as tn, equalKOnCost as tt, fsSurfaceReader as u, renderCorpusToInstructions as ut, closingWorkerNote as v, widen as vt, createFencedSqlRunContext as w, inProcessSandboxClient as wt, copyUntrackedIntoClone as x, createScopeAnalyst as xt, composeWorkerEvidence as y, assertTraceDerivedFindings as yt, graphDesignerExtraTools as z, readDeclaredCheck as zt };
9352
9348
 
9353
- //# sourceMappingURL=runtime-CekT14Tg.js.map
9349
+ //# sourceMappingURL=runtime-DF2Mjm4l.js.map