@tangle-network/agent-runtime 0.294.0 → 0.295.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.
- package/dist/{activation-1BxDcwZs.d.ts → activation-DYCFEI_o.d.ts} +2 -2
- package/dist/{activation-BKz1t1Qb.js → activation-DbcZXadv.js} +3 -3
- package/dist/{activation-BKz1t1Qb.js.map → activation-DbcZXadv.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +2 -2
- package/dist/{bundle-BfW-32vB.js → bundle-CDR0caM4.js} +2 -2
- package/dist/{bundle-BfW-32vB.js.map → bundle-CDR0caM4.js.map} +1 -1
- package/dist/candidate-execution/index.d.ts +27 -3
- package/dist/candidate-execution/index.js +6 -6
- package/dist/{coordination-driver-BpEJv7GR.js → coordination-driver-Do3g6Qif.js} +2 -2
- package/dist/{coordination-driver-BpEJv7GR.js.map → coordination-driver-Do3g6Qif.js.map} +1 -1
- package/dist/{delegate-DEP51NR7.js → delegate-CCaU8M4O.js} +2 -2
- package/dist/{delegate-DEP51NR7.js.map → delegate-CCaU8M4O.js.map} +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +3 -3
- package/dist/{graph-oFWfYVpn.js → graph-dNmpMnzl.js} +4 -4
- package/dist/{graph-oFWfYVpn.js.map → graph-dNmpMnzl.js.map} +1 -1
- package/dist/{improvement-cycle-CBAuTq3p.js → improvement-cycle-D4hoGlAe.js} +6 -6
- package/dist/{improvement-cycle-CBAuTq3p.js.map → improvement-cycle-D4hoGlAe.js.map} +1 -1
- package/dist/{index-D25LzHVg.d.ts → index-nREMiWJP.d.ts} +17 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +9 -9
- package/dist/intelligence.d.ts +4 -4
- package/dist/intelligence.js +8 -8
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +8 -8
- package/dist/{loop-runner-bin-hjelfQvP.js → loop-runner-bin-CxT9Ua-0.js} +3 -3
- package/dist/{loop-runner-bin-hjelfQvP.js.map → loop-runner-bin-CxT9Ua-0.js.map} +1 -1
- package/dist/{loop-runner-bin-BxwHrpyo.d.ts → loop-runner-bin-cf1xZPC2.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/{prepare-CxnyZ1fG.js → prepare-Dzkj4AGj.js} +3 -3
- package/dist/prepare-Dzkj4AGj.js.map +1 -0
- package/dist/{profile-C4NDjZyB.js → profile-BubsrYhR.js} +2 -2
- package/dist/{profile-C4NDjZyB.js.map → profile-BubsrYhR.js.map} +1 -1
- package/dist/{protected-model-port-DDnU39ul.d.ts → protected-model-port-CAa0t1MT.d.ts} +2 -2
- package/dist/{protected-model-port-BSsgmdhI.js → protected-model-port-_Daje74V.js} +4 -4
- package/dist/{protected-model-port-BSsgmdhI.js.map → protected-model-port-_Daje74V.js.map} +1 -1
- package/dist/{provision-supervisor-CIwZLCGR.js → provision-supervisor-B_3hmSz6.js} +3 -3
- package/dist/{provision-supervisor-CIwZLCGR.js.map → provision-supervisor-B_3hmSz6.js.map} +1 -1
- package/dist/{runtime-B_OdIcAW.js → runtime-DtkHAkSl.js} +301 -67
- package/dist/{runtime-B_OdIcAW.js.map → runtime-DtkHAkSl.js.map} +1 -1
- package/dist/{search-method-3EtnGKdL.js → search-method-B0VM-hHV.js} +3 -3
- package/dist/{search-method-3EtnGKdL.js.map → search-method-B0VM-hHV.js.map} +1 -1
- package/dist/{server-DgEDz4Rn.js → server--GKA8T0f.js} +3 -3
- package/dist/{server-DgEDz4Rn.js.map → server--GKA8T0f.js.map} +1 -1
- package/dist/{stream-agent-turn-DsHYpI9p.d.ts → stream-agent-turn-CwqktoXW.d.ts} +2 -2
- package/dist/{supervise-Cu0yOTkc.js → supervise-BwfqpTVR.js} +3 -3
- package/dist/{supervise-Cu0yOTkc.js.map → supervise-BwfqpTVR.js.map} +1 -1
- package/dist/{supervisor-B-UbeBqD.js → supervisor-Da7iAPSw.js} +15 -6
- package/dist/supervisor-Da7iAPSw.js.map +1 -0
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +14 -14
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/dist/{workspace-archive-DpyZV2Cj.d.ts → workspace-archive-pz8YJ1fr.d.ts} +12 -1
- package/dist/{workspace-archive-MhowMCmp.js → workspace-streams-D4TMTrJV.js} +301 -15
- package/dist/workspace-streams-D4TMTrJV.js.map +1 -0
- package/package.json +1 -1
- package/dist/prepare-CxnyZ1fG.js.map +0 -1
- package/dist/supervisor-B-UbeBqD.js.map +0 -1
- package/dist/workspace-archive-MhowMCmp.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Ai as writeAllBytes, Da as zeroSpend, Dn as runBrainLoop, Dt as rollingDispatch, En as routerBrain, Fa as armDeadlineTimer, Fn as createPushTraceSource, Ft as createWorktreeCliExecutor, G as settledToIteration, Gn as assertContentAddress, Hn as InMemoryResultBlobStore, Kn as encodeResultBlob, M as withDriverExecutor, Mt as createExecutor, Nt as createExecutorRegistry, O as verdictFromJudgeScore, Oi as prepareJsonlAppend, Or as contentAddress, Qi as detachedSnapshot, Sa as stringifySafe, Tn as readPromptOptions, Un as InMemorySpawnJournal, Wn as SpawnEventIndex, Xi as executableAgentSpecSnapshot, Yi as executableAgentProfileSnapshot, Zi as detachedFrozen, _ as CheckUnavailableError, _a as hasCompleteCacheBreakdown, ba as randomSuffix, bn as probeSandboxCapabilities, er as isTraceAnalysisStore, gn as defaultSelectWinner, ha as cloneSpend, ki as readCommittedJsonLines, la as notifySandboxEventObserver, ma as chargedTokens, pa as addSpend, qn as insideCursorNamespace, r as createSupervisor, va as isAbortError, vn as runAgentRounds, wn as assertBoxlessPromptOptions, xa as sleep, yn as createSandboxLineage } from "./supervisor-
|
|
1
|
+
import { Ai as writeAllBytes, Da as zeroSpend, Dn as runBrainLoop, Dt as rollingDispatch, En as routerBrain, Fa as armDeadlineTimer, Fn as createPushTraceSource, Ft as createWorktreeCliExecutor, G as settledToIteration, Gn as assertContentAddress, Hn as InMemoryResultBlobStore, Kn as encodeResultBlob, M as withDriverExecutor, Mt as createExecutor, Nt as createExecutorRegistry, O as verdictFromJudgeScore, Oi as prepareJsonlAppend, Or as contentAddress, Qi as detachedSnapshot, Sa as stringifySafe, Tn as readPromptOptions, Un as InMemorySpawnJournal, Wn as SpawnEventIndex, Xi as executableAgentSpecSnapshot, Yi as executableAgentProfileSnapshot, Zi as detachedFrozen, _ as CheckUnavailableError, _a as hasCompleteCacheBreakdown, ba as randomSuffix, bn as probeSandboxCapabilities, er as isTraceAnalysisStore, gn as defaultSelectWinner, ha as cloneSpend, ki as readCommittedJsonLines, la as notifySandboxEventObserver, ma as chargedTokens, pa as addSpend, qn as insideCursorNamespace, r as createSupervisor, va as isAbortError, vn as runAgentRounds, wn as assertBoxlessPromptOptions, xa as sleep, yn as createSandboxLineage } from "./supervisor-Da7iAPSw.js";
|
|
2
2
|
import { i as ConfigError, m as ValidationError, n as AnalystError, s as PlannerError } from "./errors-DodWX-cb.js";
|
|
3
|
-
import { Q as sample, X as refine, Z as runAgentic, c as reconcileInterruptedSearchCalls, ct as strategyAuthorMethod, et as ObservationError, it as profileChatClient, nt as observe, o as dedicatedLane, r as runtimeShipDecision, rt as renderReport, u as searchExecutor } from "./search-method-
|
|
3
|
+
import { Q as sample, X as refine, Z as runAgentic, c as reconcileInterruptedSearchCalls, ct as strategyAuthorMethod, et as ObservationError, it as profileChatClient, nt as observe, o as dedicatedLane, r as runtimeShipDecision, rt as renderReport, u as searchExecutor } from "./search-method-B0VM-hHV.js";
|
|
4
4
|
import { c as profileModelExecutionSettings, i as concreteModelId, l as profileProviderModel, o as enforceTokenLimits, p as canonicalObservedModelParts, t as assertExecutableAgentProfile } from "./model-policy-DydyWTQg.js";
|
|
5
|
-
import {
|
|
5
|
+
import { D as canonicalCandidateDigest$1, N as sha256Bytes$1, h as WorkspaceScanLimitError, j as immutableCandidateValue, v as captureMaterializedWorkspace } from "./workspace-streams-D4TMTrJV.js";
|
|
6
6
|
import { i as notifyRuntimeHookEvent } from "./runtime-hooks-tXpAarhW.js";
|
|
7
7
|
import { i as redactProtectedValue, r as redactProtectedReason } from "./protected-redaction-DylCC_ot.js";
|
|
8
|
-
import { S as foldCoordinationRecords, y as createInMemoryRunContext } from "./coordination-driver-
|
|
9
|
-
import { C as gateOnDeliverable, r as supervise, w as mapExecutorResult } from "./supervise-
|
|
8
|
+
import { S as foldCoordinationRecords, y as createInMemoryRunContext } from "./coordination-driver-Do3g6Qif.js";
|
|
9
|
+
import { C as gateOnDeliverable, r as supervise, w as mapExecutorResult } from "./supervise-BwfqpTVR.js";
|
|
10
10
|
import "./run-layout-DSCWdbX2.js";
|
|
11
|
-
import "./provision-supervisor-
|
|
12
|
-
import "./delegate-
|
|
13
|
-
import "./graph-
|
|
11
|
+
import "./provision-supervisor-B_3hmSz6.js";
|
|
12
|
+
import "./delegate-CCaU8M4O.js";
|
|
13
|
+
import "./graph-dNmpMnzl.js";
|
|
14
14
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
|
|
15
15
|
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";
|
|
16
16
|
import { createAgentRunOutcomeTracker } from "@tangle-network/sandbox/runtime";
|
|
@@ -22,6 +22,7 @@ import { chmod, link, lstat, mkdir, mkdtemp, open, opendir, readFile, readdir, r
|
|
|
22
22
|
import { tmpdir } from "node:os";
|
|
23
23
|
import { isDeepStrictEqual, promisify } from "node:util";
|
|
24
24
|
import { redact } from "@tangle-network/agent-eval/traces";
|
|
25
|
+
import { Readable } from "node:stream";
|
|
25
26
|
import { collectAgentResponseText } from "@tangle-network/sandbox";
|
|
26
27
|
import { SearchRecorder, asha, beam, createRunCostLedger, estimateNode, fsCampaignStorage, openSearchLedger, renderSearchSummary, runProfileMatrix, runSearch, searchClaimReserveUsd, searchModelIdentity, surfaceDiff } from "@tangle-network/agent-eval/campaign";
|
|
27
28
|
import { defineEvaluationClaim, summarizeEvaluationUnits } from "@tangle-network/agent-eval/experiment";
|
|
@@ -5109,6 +5110,7 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
|
|
|
5109
5110
|
}
|
|
5110
5111
|
return objects;
|
|
5111
5112
|
};
|
|
5113
|
+
const uploading = /* @__PURE__ */ new Map();
|
|
5112
5114
|
const sweep = async (signal) => {
|
|
5113
5115
|
const objects = await localObjects();
|
|
5114
5116
|
const pending = [];
|
|
@@ -5120,7 +5122,7 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
|
|
|
5120
5122
|
durableHex.add(object.hex);
|
|
5121
5123
|
continue;
|
|
5122
5124
|
}
|
|
5123
|
-
if (durable === void 0) continue;
|
|
5125
|
+
if (durable === void 0 || uploading.has(object.hex)) continue;
|
|
5124
5126
|
const digest = `sha256:${object.hex}`;
|
|
5125
5127
|
if (refusal !== void 0) {
|
|
5126
5128
|
pending.push({
|
|
@@ -5129,17 +5131,53 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
|
|
|
5129
5131
|
});
|
|
5130
5132
|
continue;
|
|
5131
5133
|
}
|
|
5132
|
-
const bytes = await readLocal(object.path);
|
|
5133
|
-
if (bytes === void 0) continue;
|
|
5134
|
-
if (sha256(bytes) !== digest) {
|
|
5135
|
-
pending.push({
|
|
5136
|
-
digest,
|
|
5137
|
-
error: "local object failed digest verification; it stays on the host"
|
|
5138
|
-
});
|
|
5139
|
-
continue;
|
|
5140
|
-
}
|
|
5141
5134
|
try {
|
|
5142
|
-
|
|
5135
|
+
if (durable.putStream && durable.getStream) {
|
|
5136
|
+
const ref = {
|
|
5137
|
+
locator: {
|
|
5138
|
+
kind: "private-cas",
|
|
5139
|
+
namespace,
|
|
5140
|
+
digest
|
|
5141
|
+
},
|
|
5142
|
+
sha256: digest,
|
|
5143
|
+
byteLength: object.size
|
|
5144
|
+
};
|
|
5145
|
+
let failure;
|
|
5146
|
+
for (let attempt = 1; attempt <= DURABLE_ATTEMPTS; attempt++) {
|
|
5147
|
+
signal?.throwIfAborted();
|
|
5148
|
+
const chunks = readObject(object.path, ref, signal);
|
|
5149
|
+
try {
|
|
5150
|
+
await durable.putStream({
|
|
5151
|
+
namespace,
|
|
5152
|
+
digest,
|
|
5153
|
+
byteLength: object.size,
|
|
5154
|
+
chunks,
|
|
5155
|
+
signal
|
|
5156
|
+
});
|
|
5157
|
+
await writeReceipt(digest, object.size);
|
|
5158
|
+
failure = void 0;
|
|
5159
|
+
break;
|
|
5160
|
+
} catch (error) {
|
|
5161
|
+
failure = error;
|
|
5162
|
+
if (signal?.aborted) throw error;
|
|
5163
|
+
if (attempt < DURABLE_ATTEMPTS) await new Promise((settle) => setTimeout(settle, 1e3 * 4 ** (attempt - 1)));
|
|
5164
|
+
} finally {
|
|
5165
|
+
await chunks.return(void 0);
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
if (failure !== void 0) throw failure;
|
|
5169
|
+
} else {
|
|
5170
|
+
const bytes = await readLocal(object.path);
|
|
5171
|
+
if (bytes === void 0) continue;
|
|
5172
|
+
if (sha256(bytes) !== digest) {
|
|
5173
|
+
pending.push({
|
|
5174
|
+
digest,
|
|
5175
|
+
error: "local object failed digest verification; it stays on the host"
|
|
5176
|
+
});
|
|
5177
|
+
continue;
|
|
5178
|
+
}
|
|
5179
|
+
await storeDurably(digest, bytes, signal);
|
|
5180
|
+
}
|
|
5143
5181
|
durableHex.add(object.hex);
|
|
5144
5182
|
uploaded++;
|
|
5145
5183
|
} catch (error) {
|
|
@@ -5189,33 +5227,80 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
|
|
|
5189
5227
|
if (sha256(bytes) !== ref.sha256 || bytes.byteLength !== ref.byteLength) throw new Error("private CAS object failed digest or length verification");
|
|
5190
5228
|
return bytes;
|
|
5191
5229
|
};
|
|
5192
|
-
|
|
5193
|
-
|
|
5230
|
+
async function* readStream(ref, options = {}) {
|
|
5231
|
+
const { signal } = options;
|
|
5232
|
+
signal?.throwIfAborted();
|
|
5233
|
+
if (ref.locator.kind !== "private-cas" || ref.locator.namespace !== namespace || ref.locator.digest !== ref.sha256) throw new Error("private CAS locator does not match its digest and namespace");
|
|
5234
|
+
const path = destination(ref.sha256);
|
|
5235
|
+
try {
|
|
5236
|
+
await checkDirectories(join(store, hexOf(ref.sha256).slice(0, 2)), false);
|
|
5237
|
+
yield* readObject(path, ref, signal);
|
|
5238
|
+
return;
|
|
5239
|
+
} catch (error) {
|
|
5240
|
+
if (!missing(error)) throw error;
|
|
5241
|
+
}
|
|
5242
|
+
if (!durable?.getStream) throw new Error(`private CAS object is not on this host; streaming durable reads are unavailable: ${ref.sha256}`);
|
|
5243
|
+
const chunks = await durable.getStream({
|
|
5244
|
+
namespace,
|
|
5245
|
+
digest: ref.sha256,
|
|
5246
|
+
signal
|
|
5247
|
+
});
|
|
5248
|
+
if (!chunks) throw new Error(`private CAS object is neither on this host nor in ${durable.location}: ${ref.sha256}`);
|
|
5249
|
+
yield* checkedChunks(chunks, ref, signal);
|
|
5250
|
+
}
|
|
5251
|
+
async function* readObject(path, ref, signal) {
|
|
5252
|
+
signal?.throwIfAborted();
|
|
5253
|
+
const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
5254
|
+
try {
|
|
5255
|
+
const stats = await file.stat();
|
|
5256
|
+
if (!stats.isFile() || stats.size !== ref.byteLength) throw new Error("private CAS object failed digest or length verification");
|
|
5257
|
+
yield* checkedChunks(file.createReadStream({
|
|
5258
|
+
autoClose: false,
|
|
5259
|
+
highWaterMark: 64 * 1024
|
|
5260
|
+
}), ref, signal);
|
|
5261
|
+
} finally {
|
|
5262
|
+
await file.close();
|
|
5263
|
+
}
|
|
5264
|
+
}
|
|
5265
|
+
async function* checkedChunks(chunks, ref, signal) {
|
|
5266
|
+
const hash = createHash("sha256");
|
|
5267
|
+
let byteLength = 0;
|
|
5268
|
+
for await (const chunk of chunks) {
|
|
5194
5269
|
signal?.throwIfAborted();
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5270
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("private CAS emitted a non-byte chunk");
|
|
5271
|
+
byteLength += chunk.byteLength;
|
|
5272
|
+
if (byteLength > ref.byteLength) throw new Error("private CAS object failed digest or length verification");
|
|
5273
|
+
hash.update(chunk);
|
|
5274
|
+
yield chunk;
|
|
5275
|
+
}
|
|
5276
|
+
signal?.throwIfAborted();
|
|
5277
|
+
if (`sha256:${hash.digest("hex")}` !== ref.sha256 || byteLength !== ref.byteLength) throw new Error("private CAS object failed digest or length verification");
|
|
5278
|
+
}
|
|
5279
|
+
async function putStream(input) {
|
|
5280
|
+
const { signal } = input;
|
|
5281
|
+
signal?.throwIfAborted();
|
|
5282
|
+
await checkDirectories(store, true);
|
|
5283
|
+
const temporary = join(store, `.${randomUUID()}.tmp`);
|
|
5284
|
+
try {
|
|
5201
5285
|
const file = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
5286
|
+
const hash = createHash("sha256");
|
|
5287
|
+
let byteLength = 0;
|
|
5202
5288
|
try {
|
|
5203
|
-
await
|
|
5289
|
+
for await (const chunk of input.chunks) {
|
|
5290
|
+
signal?.throwIfAborted();
|
|
5291
|
+
if (!(chunk instanceof Uint8Array)) throw new Error("private CAS received a non-byte chunk");
|
|
5292
|
+
hash.update(chunk);
|
|
5293
|
+
byteLength += chunk.byteLength;
|
|
5294
|
+
if (!Number.isSafeInteger(byteLength)) throw new Error("private CAS object is too large");
|
|
5295
|
+
await file.writeFile(chunk);
|
|
5296
|
+
}
|
|
5297
|
+
signal?.throwIfAborted();
|
|
5204
5298
|
await file.sync();
|
|
5205
5299
|
} finally {
|
|
5206
5300
|
await file.close();
|
|
5207
5301
|
}
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
try {
|
|
5211
|
-
await link(temporary, path);
|
|
5212
|
-
} catch (error) {
|
|
5213
|
-
if (error.code !== "EEXIST") throw error;
|
|
5214
|
-
}
|
|
5215
|
-
await syncDirectory(directory);
|
|
5216
|
-
} finally {
|
|
5217
|
-
await unlink(temporary).catch(() => void 0);
|
|
5218
|
-
}
|
|
5302
|
+
const sha = hash.digest("hex");
|
|
5303
|
+
const digest = `sha256:${sha}`;
|
|
5219
5304
|
const ref = {
|
|
5220
5305
|
locator: {
|
|
5221
5306
|
kind: "private-cas",
|
|
@@ -5223,37 +5308,117 @@ function createPrivateCasArtifactPort(root, namespace, options = {}) {
|
|
|
5223
5308
|
digest
|
|
5224
5309
|
},
|
|
5225
5310
|
sha256: digest,
|
|
5226
|
-
byteLength
|
|
5311
|
+
byteLength
|
|
5227
5312
|
};
|
|
5228
|
-
await
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5313
|
+
for await (const _chunk of readObject(temporary, ref, signal));
|
|
5314
|
+
const path = destination(digest);
|
|
5315
|
+
const directory = join(store, sha.slice(0, 2));
|
|
5316
|
+
await checkDirectories(directory, true);
|
|
5317
|
+
signal?.throwIfAborted();
|
|
5318
|
+
try {
|
|
5319
|
+
await link(temporary, path);
|
|
5320
|
+
} catch (error) {
|
|
5321
|
+
if (error.code !== "EEXIST") throw error;
|
|
5322
|
+
for await (const _chunk of readStream(ref, { signal }));
|
|
5232
5323
|
}
|
|
5324
|
+
const dir = await open(directory, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
5325
|
+
try {
|
|
5326
|
+
await dir.sync();
|
|
5327
|
+
} finally {
|
|
5328
|
+
await dir.close();
|
|
5329
|
+
}
|
|
5330
|
+
if (durable !== void 0) await offload(signal);
|
|
5233
5331
|
return ref;
|
|
5332
|
+
} finally {
|
|
5333
|
+
await unlink(temporary).catch((error) => {
|
|
5334
|
+
if (error.code !== "ENOENT") throw error;
|
|
5335
|
+
});
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5338
|
+
const port = {
|
|
5339
|
+
...durable === void 0 || durable.putStream && durable.getStream ? {
|
|
5340
|
+
putStream,
|
|
5341
|
+
readStream
|
|
5342
|
+
} : {},
|
|
5343
|
+
async put({ bytes, signal }) {
|
|
5344
|
+
signal?.throwIfAborted();
|
|
5345
|
+
const digest = sha256(bytes);
|
|
5346
|
+
const sha = hexOf(digest);
|
|
5347
|
+
if (durable !== void 0) uploading.set(sha, (uploading.get(sha) ?? 0) + 1);
|
|
5348
|
+
try {
|
|
5349
|
+
return await putBuffered(bytes, digest, sha, signal);
|
|
5350
|
+
} finally {
|
|
5351
|
+
if (durable !== void 0) {
|
|
5352
|
+
const count = (uploading.get(sha) ?? 1) - 1;
|
|
5353
|
+
if (count === 0) uploading.delete(sha);
|
|
5354
|
+
else uploading.set(sha, count);
|
|
5355
|
+
}
|
|
5356
|
+
}
|
|
5234
5357
|
},
|
|
5235
5358
|
async read(ref) {
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5359
|
+
return readRef(ref);
|
|
5360
|
+
},
|
|
5361
|
+
offload
|
|
5362
|
+
};
|
|
5363
|
+
async function putBuffered(bytes, digest, sha, signal) {
|
|
5364
|
+
const path = destination(digest);
|
|
5365
|
+
const directory = join(store, sha.slice(0, 2));
|
|
5366
|
+
await checkDirectories(directory, true);
|
|
5367
|
+
const temporary = join(directory, `.${sha}.${randomUUID()}.tmp`);
|
|
5368
|
+
const file = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, 384);
|
|
5369
|
+
try {
|
|
5370
|
+
await file.writeFile(bytes);
|
|
5371
|
+
await file.sync();
|
|
5372
|
+
} finally {
|
|
5373
|
+
await file.close();
|
|
5374
|
+
}
|
|
5375
|
+
try {
|
|
5376
|
+
signal?.throwIfAborted();
|
|
5240
5377
|
try {
|
|
5241
|
-
await
|
|
5242
|
-
local = await readLocal(path);
|
|
5378
|
+
await link(temporary, path);
|
|
5243
5379
|
} catch (error) {
|
|
5244
|
-
if (
|
|
5380
|
+
if (error.code !== "EEXIST") throw error;
|
|
5245
5381
|
}
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5382
|
+
await syncDirectory(directory);
|
|
5383
|
+
} finally {
|
|
5384
|
+
await unlink(temporary).catch(() => void 0);
|
|
5385
|
+
}
|
|
5386
|
+
const ref = {
|
|
5387
|
+
locator: {
|
|
5388
|
+
kind: "private-cas",
|
|
5249
5389
|
namespace,
|
|
5250
|
-
digest
|
|
5251
|
-
}
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
}
|
|
5255
|
-
|
|
5256
|
-
|
|
5390
|
+
digest
|
|
5391
|
+
},
|
|
5392
|
+
sha256: digest,
|
|
5393
|
+
byteLength: bytes.byteLength
|
|
5394
|
+
};
|
|
5395
|
+
await readRef(ref);
|
|
5396
|
+
if (durable !== void 0) {
|
|
5397
|
+
if (!await hasReceipt(sha)) await storeDurably(digest, bytes, signal).catch(() => void 0);
|
|
5398
|
+
await offload(signal);
|
|
5399
|
+
}
|
|
5400
|
+
return ref;
|
|
5401
|
+
}
|
|
5402
|
+
async function readRef(ref) {
|
|
5403
|
+
if (ref.locator.kind !== "private-cas" || ref.locator.namespace !== namespace || ref.locator.digest !== ref.sha256) throw new Error("private CAS locator does not match its digest and namespace");
|
|
5404
|
+
const path = destination(ref.sha256);
|
|
5405
|
+
const shard = join(store, hexOf(ref.sha256).slice(0, 2));
|
|
5406
|
+
let local;
|
|
5407
|
+
try {
|
|
5408
|
+
await checkDirectories(shard, false);
|
|
5409
|
+
local = await readLocal(path);
|
|
5410
|
+
} catch (error) {
|
|
5411
|
+
if (!missing(error)) throw error;
|
|
5412
|
+
}
|
|
5413
|
+
if (local !== void 0) return verified(local, ref);
|
|
5414
|
+
if (durable === void 0) throw new Error(`private CAS object is not on this host: ${ref.sha256}`);
|
|
5415
|
+
const stored = await durable.get({
|
|
5416
|
+
namespace,
|
|
5417
|
+
digest: ref.sha256
|
|
5418
|
+
});
|
|
5419
|
+
if (stored === void 0) throw new Error(`private CAS object is neither on this host nor in ${durable.location}: ${ref.sha256}`);
|
|
5420
|
+
return verified(stored, ref);
|
|
5421
|
+
}
|
|
5257
5422
|
return port;
|
|
5258
5423
|
}
|
|
5259
5424
|
//#endregion
|
|
@@ -5505,7 +5670,7 @@ function createS3PrivateCasStore(options) {
|
|
|
5505
5670
|
if (!match) throw new Error("S3 private CAS digest must be sha256:<64 lowercase hex>");
|
|
5506
5671
|
return `${prefix}${namespace}/sha256/${match[1]}`;
|
|
5507
5672
|
};
|
|
5508
|
-
const request = async (method, objectKey, { body, payloadHash = EMPTY_PAYLOAD, headers = {}, signal } = {}) => {
|
|
5673
|
+
const request = async (method, objectKey, { body, byteLength, payloadHash = EMPTY_PAYLOAD, headers = {}, signal } = {}) => {
|
|
5509
5674
|
const path = `/${[options.bucket, ...objectKey.split("/")].map(encode).join("/")}`;
|
|
5510
5675
|
const url = new URL(path, endpoint);
|
|
5511
5676
|
const amzDate = (/* @__PURE__ */ new Date()).toISOString().replace(/[:-]|\.\d{3}/gu, "");
|
|
@@ -5533,7 +5698,7 @@ function createS3PrivateCasStore(options) {
|
|
|
5533
5698
|
hex(canonical)
|
|
5534
5699
|
].join("\n")).digest("hex");
|
|
5535
5700
|
const { host: _host, ...sent } = signed;
|
|
5536
|
-
const deadline = AbortSignal.timeout(timeoutMs + Math.ceil((
|
|
5701
|
+
const deadline = AbortSignal.timeout(timeoutMs + Math.ceil((byteLength ?? (body instanceof Uint8Array ? body.byteLength : 0)) / (1024 * 1024)) * 1e3);
|
|
5537
5702
|
return await send(url, {
|
|
5538
5703
|
method,
|
|
5539
5704
|
headers: {
|
|
@@ -5541,11 +5706,23 @@ function createS3PrivateCasStore(options) {
|
|
|
5541
5706
|
authorization: `AWS4-HMAC-SHA256 Credential=${options.accessKeyId}/${scope}, SignedHeaders=${names.join(";")}, Signature=${signature}`
|
|
5542
5707
|
},
|
|
5543
5708
|
...body === void 0 ? {} : { body },
|
|
5709
|
+
...body instanceof ReadableStream ? { duplex: "half" } : {},
|
|
5544
5710
|
signal: signal === void 0 ? deadline : AbortSignal.any([signal, deadline])
|
|
5545
5711
|
});
|
|
5546
5712
|
};
|
|
5547
5713
|
const refusal = async (response, action) => {
|
|
5548
|
-
const
|
|
5714
|
+
const reader = response.body?.getReader();
|
|
5715
|
+
let detail = "";
|
|
5716
|
+
try {
|
|
5717
|
+
while (reader && detail.length < 300) {
|
|
5718
|
+
const { done, value } = await reader.read();
|
|
5719
|
+
if (done) break;
|
|
5720
|
+
detail += new TextDecoder().decode(value.subarray(0, 300));
|
|
5721
|
+
}
|
|
5722
|
+
} catch {} finally {
|
|
5723
|
+
await reader?.cancel().catch(() => void 0);
|
|
5724
|
+
}
|
|
5725
|
+
detail = detail.replace(/\s+/gu, " ").slice(0, 300);
|
|
5549
5726
|
return /* @__PURE__ */ new Error(`S3 private CAS ${action} returned ${response.status}${detail ? `: ${detail}` : ""}`);
|
|
5550
5727
|
};
|
|
5551
5728
|
/** Whether the bucket holds this exact object; refuses a same-key object of other bytes. */
|
|
@@ -5560,6 +5737,63 @@ function createS3PrivateCasStore(options) {
|
|
|
5560
5737
|
};
|
|
5561
5738
|
return {
|
|
5562
5739
|
location: `s3://${options.bucket}/${prefix}`,
|
|
5740
|
+
async putStream({ namespace, digest, byteLength, chunks, signal }) {
|
|
5741
|
+
const objectKey = key(namespace, digest);
|
|
5742
|
+
if (await holds(objectKey, digest, byteLength, signal)) return;
|
|
5743
|
+
async function* checked() {
|
|
5744
|
+
const hash = createHash("sha256");
|
|
5745
|
+
let total = 0;
|
|
5746
|
+
for await (const chunk of chunks) {
|
|
5747
|
+
signal?.throwIfAborted();
|
|
5748
|
+
total += chunk.byteLength;
|
|
5749
|
+
if (total > byteLength) throw new Error("S3 private CAS stream exceeds its declared length");
|
|
5750
|
+
hash.update(chunk);
|
|
5751
|
+
yield chunk;
|
|
5752
|
+
}
|
|
5753
|
+
if (total !== byteLength || `sha256:${hash.digest("hex")}` !== digest) throw new Error("S3 private CAS stream failed digest or length verification");
|
|
5754
|
+
}
|
|
5755
|
+
const body = Readable.from(checked());
|
|
5756
|
+
try {
|
|
5757
|
+
const response = await request("PUT", objectKey, {
|
|
5758
|
+
body: Readable.toWeb(body),
|
|
5759
|
+
byteLength,
|
|
5760
|
+
payloadHash: DIGEST.exec(digest)[1],
|
|
5761
|
+
headers: {
|
|
5762
|
+
"content-type": CONTENT_TYPE,
|
|
5763
|
+
"content-length": String(byteLength),
|
|
5764
|
+
[METADATA_DIGEST]: digest
|
|
5765
|
+
},
|
|
5766
|
+
...signal === void 0 ? {} : { signal }
|
|
5767
|
+
});
|
|
5768
|
+
if (!response.ok) throw await refusal(response, "PUT");
|
|
5769
|
+
await response.body?.cancel().catch(() => void 0);
|
|
5770
|
+
if (!await holds(objectKey, digest, byteLength, signal)) throw new Error(`S3 private CAS object ${objectKey} is absent after its write`);
|
|
5771
|
+
} finally {
|
|
5772
|
+
body.destroy();
|
|
5773
|
+
}
|
|
5774
|
+
},
|
|
5775
|
+
async getStream({ namespace, digest, signal }) {
|
|
5776
|
+
const response = await request("GET", key(namespace, digest), signal === void 0 ? {} : { signal });
|
|
5777
|
+
if (response.status === 404) {
|
|
5778
|
+
await response.body?.cancel().catch(() => void 0);
|
|
5779
|
+
return;
|
|
5780
|
+
}
|
|
5781
|
+
if (!response.ok) throw await refusal(response, "GET");
|
|
5782
|
+
if (!response.body) throw new Error("S3 private CAS GET returned no body");
|
|
5783
|
+
return (async function* () {
|
|
5784
|
+
const reader = response.body.getReader();
|
|
5785
|
+
try {
|
|
5786
|
+
while (true) {
|
|
5787
|
+
signal?.throwIfAborted();
|
|
5788
|
+
const { done, value } = await reader.read();
|
|
5789
|
+
if (done) break;
|
|
5790
|
+
yield value;
|
|
5791
|
+
}
|
|
5792
|
+
} finally {
|
|
5793
|
+
await reader.cancel().catch(() => void 0);
|
|
5794
|
+
}
|
|
5795
|
+
})();
|
|
5796
|
+
},
|
|
5563
5797
|
async put({ namespace, digest, bytes, signal }) {
|
|
5564
5798
|
const objectKey = key(namespace, digest);
|
|
5565
5799
|
if (await holds(objectKey, digest, bytes.byteLength, signal)) return;
|
|
@@ -5573,13 +5807,13 @@ function createS3PrivateCasStore(options) {
|
|
|
5573
5807
|
...signal === void 0 ? {} : { signal }
|
|
5574
5808
|
});
|
|
5575
5809
|
if (!response.ok) throw await refusal(response, "PUT");
|
|
5576
|
-
await response.
|
|
5810
|
+
await response.body?.cancel().catch(() => void 0);
|
|
5577
5811
|
if (!await holds(objectKey, digest, bytes.byteLength, signal)) throw new Error(`S3 private CAS object ${objectKey} is absent after its write`);
|
|
5578
5812
|
},
|
|
5579
5813
|
async get({ namespace, digest, signal }) {
|
|
5580
5814
|
const response = await request("GET", key(namespace, digest), signal === void 0 ? {} : { signal });
|
|
5581
5815
|
if (response.status === 404) {
|
|
5582
|
-
await response.
|
|
5816
|
+
await response.body?.cancel().catch(() => void 0);
|
|
5583
5817
|
return;
|
|
5584
5818
|
}
|
|
5585
5819
|
if (!response.ok) throw await refusal(response, "GET");
|
|
@@ -8722,4 +8956,4 @@ function tail(s) {
|
|
|
8722
8956
|
//#endregion
|
|
8723
8957
|
export { FileCorpus as $, envKeyProvider as $t, unsafeInProcessRunner as A, readDeclaredCheck as At, SandboxRunAbortError as B, renderLeaderboardSvg as Bt, withUntrackedArtifacts as C, loopDispatch as Ct, patchDelivered as D, declaredCheckDeliverable as Dt, createSqlRunContext as E, checkProgramDigest as Et, strategyTournament as F, stopSentinel as Ft, createPrivateCasArtifactPort as G, openSqlRunStore as Gt, createS3PrivateCasStore as H, auditIntent as Ht, assertStrategyContract as I, leaderboard as It, definePersona as J, McpSpawnFault as Jt, equalKOnCost as K, SqlResultBlobStore as Kt, authorStrategy as L, pairwiseSignificance as Lt, chatWorkerSeam as M, completionAuthorizes as Mt, createChatSessionStore as N, deterministicCompletion as Nt, runCoderChecks as O, declaredCheckDigest as Ot, runStrategyEvolution as P, sentinelCompletion as Pt, registerShape as Q, sanitizeMcpToolSchema as Qt, strategyAuthorContract as R, renderLeaderboardHtml as Rt, copyUntrackedIntoClone as S, loopCampaignDispatch as St, createFencedSqlRunContext as T, assertDeclaredCheck as Tt, printBenchmarkReport as U, defaultAuditorInstruction as Ut, openSandboxRun as V, renderPairwiseMarkdown as Vt, runBenchmark as W, SqlRunOwnershipError as Wt, builtinShapes as X, materializeLocalMcp as Xt, runPersonified as Y, connectStdioMcp as Yt, createShapeRegistry as Z, createMcpEnvironment as Zt, NOTE_MAX_CHARS as _, harvestCorpus as _t, localShell as a, panel as at, composeWorkerEvidence as b, localSandboxClient as bt, createVerifierEnvironment as c, verify as ct, harvestSurfaceDiffs as d, buildSteerContext as dt, mcpSecretEnvMetadataKey as en, InMemoryCorpus as et, analystsFromRegistry as f, createScopeAnalyst as ft, EVIDENCE_MAX_CHARS as g, HarvestError as gt, worktreeFanout as h, inProcessSandboxClient as ht, jjWorkspace as i, createTangleSandboxExactProcessProvider as in, loopUntil as it, chatTransportExecutor as j, runIsolatedCheck as jt, codeModeSupervisorTools as k, declaredCheckJudge as kt, boxSurfaceReader as l, widen as lt, superviseSurface as m, observationFromRegistry as mt, makeFinding$1 as n, resolveSecretEnv as nn, fanout as nt, runInWorkspace as o, pipeline as ot, failuresAnalyst as p, registryScopeAnalyst as pt, trajectoryReport as q, SqlSpawnJournal as qt, gitWorkspace as r, secretEnvOfMcpServer as rn, flatWidenGate as rt, createWaterfallCollector as s, selectValidWinner as st, computeFindingId$1 as t, resolveMcpServerLaunch as tn, renderCorpusToInstructions as tt, fsSurfaceReader as u, assertTraceDerivedFindings as ut, VERIFY_TAIL_CHARS as v, defineLeaderboard as vt, analyzeTrace as w, superviseDispatch as wt, settledWorkerOut as x, inlineSandboxClient as xt, closingWorkerNote as y, resolveSandboxClient as yt, strategyAuthorSystemPrompt as z, renderLeaderboardMarkdown as zt };
|
|
8724
8958
|
|
|
8725
|
-
//# sourceMappingURL=runtime-
|
|
8959
|
+
//# sourceMappingURL=runtime-DtkHAkSl.js.map
|