@algosuite/vo-mcp 0.2.0-beta.69 → 0.2.0-beta.70
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/runner-cli.js +177 -42
- package/dist/runner-cli.js.map +3 -3
- package/dist/runner-supervisor.js +10 -4
- package/dist/runner-supervisor.js.map +1 -1
- package/package.json +1 -1
package/dist/runner-cli.js
CHANGED
|
@@ -3852,6 +3852,9 @@ var init_claim_gate_notice = __esm({
|
|
|
3852
3852
|
});
|
|
3853
3853
|
|
|
3854
3854
|
// ../../scripts/virtual-office/code-runner/control-plane-knowledge-context.mjs
|
|
3855
|
+
function canonicalizeKnowledgeContextQuery(value) {
|
|
3856
|
+
return typeof value === "string" ? value.trimStart().slice(0, KNOWLEDGE_CONTEXT_QUERY_MAX_CHARS) : "";
|
|
3857
|
+
}
|
|
3855
3858
|
function isRetryableStatus(status) {
|
|
3856
3859
|
return status >= 500 && status <= 599;
|
|
3857
3860
|
}
|
|
@@ -3860,7 +3863,7 @@ function defaultSleep(ms) {
|
|
|
3860
3863
|
setTimeout(resolve3, ms);
|
|
3861
3864
|
});
|
|
3862
3865
|
}
|
|
3863
|
-
async function getTaskKnowledgeContextRequest(req, taskId, { query } = {}, {
|
|
3866
|
+
async function getTaskKnowledgeContextRequest(req, taskId, { query, knowledgeRequestId } = {}, {
|
|
3864
3867
|
taskRequestTimeoutMs,
|
|
3865
3868
|
invalidateToken = () => {
|
|
3866
3869
|
},
|
|
@@ -3869,7 +3872,9 @@ async function getTaskKnowledgeContextRequest(req, taskId, { query } = {}, {
|
|
|
3869
3872
|
}
|
|
3870
3873
|
} = {}) {
|
|
3871
3874
|
const body = {};
|
|
3872
|
-
|
|
3875
|
+
const canonicalQuery = canonicalizeKnowledgeContextQuery(query);
|
|
3876
|
+
if (canonicalQuery.trim()) body.query = canonicalQuery;
|
|
3877
|
+
if (typeof knowledgeRequestId === "string" && knowledgeRequestId) body.knowledge_request_id = knowledgeRequestId;
|
|
3873
3878
|
const path23 = `/api/v1/code-task/${encodeURIComponent(taskId)}/knowledge-context`;
|
|
3874
3879
|
const timeoutMs = Math.max(Number(taskRequestTimeoutMs) || 0, MIN_KNOWLEDGE_CONTEXT_TIMEOUT_MS);
|
|
3875
3880
|
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt += 1) {
|
|
@@ -3899,11 +3904,12 @@ async function getTaskKnowledgeContextRequest(req, taskId, { query } = {}, {
|
|
|
3899
3904
|
}
|
|
3900
3905
|
throw new Error("knowledge-context retry loop exited unexpectedly");
|
|
3901
3906
|
}
|
|
3902
|
-
var MIN_KNOWLEDGE_CONTEXT_TIMEOUT_MS, RETRY_DELAYS_MS, MAX_ATTEMPTS;
|
|
3907
|
+
var MIN_KNOWLEDGE_CONTEXT_TIMEOUT_MS, KNOWLEDGE_CONTEXT_QUERY_MAX_CHARS, RETRY_DELAYS_MS, MAX_ATTEMPTS;
|
|
3903
3908
|
var init_control_plane_knowledge_context = __esm({
|
|
3904
3909
|
"../../scripts/virtual-office/code-runner/control-plane-knowledge-context.mjs"() {
|
|
3905
3910
|
"use strict";
|
|
3906
3911
|
MIN_KNOWLEDGE_CONTEXT_TIMEOUT_MS = 15e3;
|
|
3912
|
+
KNOWLEDGE_CONTEXT_QUERY_MAX_CHARS = 2e3;
|
|
3907
3913
|
RETRY_DELAYS_MS = [2e3, 6e3];
|
|
3908
3914
|
MAX_ATTEMPTS = RETRY_DELAYS_MS.length + 1;
|
|
3909
3915
|
}
|
|
@@ -4222,8 +4228,8 @@ function createControlPlaneClient({
|
|
|
4222
4228
|
return Buffer.from(await res.arrayBuffer());
|
|
4223
4229
|
},
|
|
4224
4230
|
// Raised per-attempt timeout (>=15s) + bounded retry — see control-plane-knowledge-context.mjs.
|
|
4225
|
-
async getTaskKnowledgeContext(taskId, { query } = {}) {
|
|
4226
|
-
return getTaskKnowledgeContextRequest(req, taskId, { query }, {
|
|
4231
|
+
async getTaskKnowledgeContext(taskId, { query, knowledgeRequestId } = {}) {
|
|
4232
|
+
return getTaskKnowledgeContextRequest(req, taskId, { query, knowledgeRequestId }, {
|
|
4227
4233
|
taskRequestTimeoutMs,
|
|
4228
4234
|
invalidateToken: () => {
|
|
4229
4235
|
cachedFirebaseToken = null;
|
|
@@ -9500,7 +9506,104 @@ var init_methodology_composer = __esm({
|
|
|
9500
9506
|
}
|
|
9501
9507
|
});
|
|
9502
9508
|
|
|
9509
|
+
// ../../scripts/virtual-office/code-runner/knowledge-exposure-receipt.mjs
|
|
9510
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
9511
|
+
function sha256Utf8(value) {
|
|
9512
|
+
return createHash4("sha256").update(String(value), "utf8").digest("hex");
|
|
9513
|
+
}
|
|
9514
|
+
function isUuid(value) {
|
|
9515
|
+
return typeof value === "string" && UUID_RE.test(value);
|
|
9516
|
+
}
|
|
9517
|
+
function verifyKnowledgeExposureResponse(response, task, requestId) {
|
|
9518
|
+
const context = typeof response?.context_markdown === "string" ? response.context_markdown : null;
|
|
9519
|
+
if (!context || context.length > 6e3) throw new Error("knowledge exposure response has invalid context bytes");
|
|
9520
|
+
if (!isUuid(response?.receipt_id) || !isUuid(response?.knowledge_request_id) || !isUuid(response?.claim_occurrence_id) || !SHA_RE.test(String(response?.context_sha256 ?? ""))) {
|
|
9521
|
+
throw new Error("knowledge exposure response is missing a valid receipt binding");
|
|
9522
|
+
}
|
|
9523
|
+
if (response.knowledge_request_id !== requestId || response.claim_occurrence_id !== task?.claim_occurrence_id) {
|
|
9524
|
+
throw new Error("knowledge exposure response does not bind this composition occurrence");
|
|
9525
|
+
}
|
|
9526
|
+
const contextSha256 = sha256Utf8(context);
|
|
9527
|
+
if (contextSha256 !== response.context_sha256) throw new Error("knowledge exposure context digest mismatch");
|
|
9528
|
+
return Object.freeze({
|
|
9529
|
+
receiptId: response.receipt_id,
|
|
9530
|
+
knowledgeRequestId: requestId,
|
|
9531
|
+
claimOccurrenceId: response.claim_occurrence_id,
|
|
9532
|
+
contextSha256,
|
|
9533
|
+
contextMarkdown: context,
|
|
9534
|
+
contextUtf8Bytes: Buffer.byteLength(context, "utf8"),
|
|
9535
|
+
degraded: response.degraded === true
|
|
9536
|
+
});
|
|
9537
|
+
}
|
|
9538
|
+
function knowledgeExposurePromptBlock(exposure) {
|
|
9539
|
+
const marker = `<!-- hq-knowledge-receipt:${exposure.receiptId} -->
|
|
9540
|
+
`;
|
|
9541
|
+
return {
|
|
9542
|
+
marker,
|
|
9543
|
+
markdown: [
|
|
9544
|
+
"## Knowledge exposure evidence",
|
|
9545
|
+
`Receipt ID: ${exposure.receiptId}`,
|
|
9546
|
+
`Context SHA-256: ${exposure.contextSha256}`,
|
|
9547
|
+
"This records server retrieval/exposure only. It does not prove reading, application, correctness, or benefit.",
|
|
9548
|
+
marker + exposure.contextMarkdown
|
|
9549
|
+
].join("\n")
|
|
9550
|
+
};
|
|
9551
|
+
}
|
|
9552
|
+
function buildKnowledgeDispatchAck({ exposure, prompt, agent }) {
|
|
9553
|
+
const { marker } = knowledgeExposurePromptBlock(exposure);
|
|
9554
|
+
const markerAt = String(prompt).indexOf(marker);
|
|
9555
|
+
if (markerAt < 0) throw new Error("composed prompt is missing its knowledge exposure marker");
|
|
9556
|
+
const contextStartChar = markerAt + marker.length;
|
|
9557
|
+
if (String(prompt).slice(contextStartChar, contextStartChar + exposure.contextMarkdown.length) !== exposure.contextMarkdown) {
|
|
9558
|
+
throw new Error("composed prompt knowledge bytes do not match the exposure receipt");
|
|
9559
|
+
}
|
|
9560
|
+
return Object.freeze({
|
|
9561
|
+
receipt_id: exposure.receiptId,
|
|
9562
|
+
knowledge_request_id: exposure.knowledgeRequestId,
|
|
9563
|
+
claim_occurrence_id: exposure.claimOccurrenceId,
|
|
9564
|
+
context_sha256: exposure.contextSha256,
|
|
9565
|
+
prompt_sha256: sha256Utf8(prompt),
|
|
9566
|
+
context_start_utf8_byte: Buffer.byteLength(String(prompt).slice(0, contextStartChar), "utf8"),
|
|
9567
|
+
context_utf8_bytes: exposure.contextUtf8Bytes,
|
|
9568
|
+
agent,
|
|
9569
|
+
prompt_transport: agent === "cursor" ? "argv_materialized" : "stdin_write_attempt",
|
|
9570
|
+
acknowledgement_kind: "process_spawn_prompt_delivery_attempt"
|
|
9571
|
+
});
|
|
9572
|
+
}
|
|
9573
|
+
function createKnowledgeSpawnAcknowledgement({ exposure, prompt, agent, post }) {
|
|
9574
|
+
const ack = exposure?.receiptId ? buildKnowledgeDispatchAck({ exposure, prompt, agent }) : null;
|
|
9575
|
+
let observedSpawn = false;
|
|
9576
|
+
let recorded = false;
|
|
9577
|
+
const send = async (spawnEvent) => {
|
|
9578
|
+
const patch = ack ? { knowledge_dispatch_ack: ack } : {};
|
|
9579
|
+
const result = await post(spawnEvent ? {
|
|
9580
|
+
stage: "agent_spawned",
|
|
9581
|
+
message: `${agent} process spawned; prompt delivery attempted`,
|
|
9582
|
+
...patch
|
|
9583
|
+
} : patch);
|
|
9584
|
+
recorded = Boolean(ack && result?.task?.knowledge_dispatch_ack?.receipt_id === ack.receipt_id);
|
|
9585
|
+
return result;
|
|
9586
|
+
};
|
|
9587
|
+
return Object.freeze({
|
|
9588
|
+
acknowledgement: ack,
|
|
9589
|
+
onSpawn: () => {
|
|
9590
|
+
observedSpawn = true;
|
|
9591
|
+
return send(true);
|
|
9592
|
+
},
|
|
9593
|
+
retryIfNeeded: () => ack && observedSpawn && !recorded ? send(false).catch(() => null) : Promise.resolve(null)
|
|
9594
|
+
});
|
|
9595
|
+
}
|
|
9596
|
+
var UUID_RE, SHA_RE;
|
|
9597
|
+
var init_knowledge_exposure_receipt = __esm({
|
|
9598
|
+
"../../scripts/virtual-office/code-runner/knowledge-exposure-receipt.mjs"() {
|
|
9599
|
+
"use strict";
|
|
9600
|
+
UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
9601
|
+
SHA_RE = /^[0-9a-f]{64}$/u;
|
|
9602
|
+
}
|
|
9603
|
+
});
|
|
9604
|
+
|
|
9503
9605
|
// ../../scripts/virtual-office/code-runner/task-prompt.mjs
|
|
9606
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9504
9607
|
function buildMissingKnowledgeMessage(taskId, reason) {
|
|
9505
9608
|
const id = taskId || "unknown-task";
|
|
9506
9609
|
return `task ${id} missing task-scoped AlgoHQ knowledge context: ${reason}`;
|
|
@@ -9558,36 +9661,55 @@ function methodologyLedgerFields(methodology) {
|
|
|
9558
9661
|
return { ...shape ? { methodology_shape: shape } : {}, ...stakes ? { governed_stakes: stakes } : {} };
|
|
9559
9662
|
}
|
|
9560
9663
|
async function composeCodeTaskPrompt(client, task, { log: log2 = () => {
|
|
9561
|
-
}, allowMissingKnowledgeContext = false, attachmentManifestMarkdown = "", onMethodology, repoRoot: repoRoot2 } = {}) {
|
|
9664
|
+
}, allowMissingKnowledgeContext = false, attachmentManifestMarkdown = "", onMethodology, onKnowledgeExposure, repoRoot: repoRoot2 } = {}) {
|
|
9562
9665
|
const taskId = task?.code_task_id;
|
|
9666
|
+
const reportNoReceipt = () => {
|
|
9667
|
+
try {
|
|
9668
|
+
onKnowledgeExposure?.(Object.freeze({ status: "no_receipt_degraded" }));
|
|
9669
|
+
} catch {
|
|
9670
|
+
}
|
|
9671
|
+
};
|
|
9563
9672
|
if (!taskId) {
|
|
9673
|
+
const missing = handleMissingKnowledgeContext(taskId, "missing code_task_id on the claimed task", {
|
|
9674
|
+
allowMissingKnowledgeContext,
|
|
9675
|
+
log: log2
|
|
9676
|
+
});
|
|
9677
|
+
reportNoReceipt();
|
|
9564
9678
|
return composeDispatchPrompt(withComposedMethodology(withAttachmentManifest(task?.prompt, attachmentManifestMarkdown), task, log2, taskId, onMethodology), {
|
|
9565
9679
|
repo: task?.repo,
|
|
9566
9680
|
repoRoot: repoRoot2,
|
|
9567
|
-
knowledgeContextMarkdown:
|
|
9568
|
-
allowMissingKnowledgeContext,
|
|
9569
|
-
log: log2
|
|
9570
|
-
})
|
|
9681
|
+
knowledgeContextMarkdown: missing
|
|
9571
9682
|
});
|
|
9572
9683
|
}
|
|
9573
9684
|
if (typeof client?.getTaskKnowledgeContext !== "function") {
|
|
9685
|
+
const missing = handleMissingKnowledgeContext(taskId, "control-plane client cannot fetch knowledge context", {
|
|
9686
|
+
allowMissingKnowledgeContext,
|
|
9687
|
+
log: log2
|
|
9688
|
+
});
|
|
9689
|
+
reportNoReceipt();
|
|
9574
9690
|
return composeDispatchPrompt(withComposedMethodology(withAttachmentManifest(task?.prompt, attachmentManifestMarkdown), task, log2, taskId, onMethodology), {
|
|
9575
9691
|
repo: task?.repo,
|
|
9576
9692
|
repoRoot: repoRoot2,
|
|
9577
|
-
knowledgeContextMarkdown:
|
|
9578
|
-
allowMissingKnowledgeContext,
|
|
9579
|
-
log: log2
|
|
9580
|
-
})
|
|
9693
|
+
knowledgeContextMarkdown: missing
|
|
9581
9694
|
});
|
|
9582
9695
|
}
|
|
9583
9696
|
let knowledgeContextMarkdown;
|
|
9697
|
+
let exposure = null;
|
|
9584
9698
|
try {
|
|
9585
|
-
const
|
|
9699
|
+
const receiptRequired = typeof task?.claim_occurrence_id === "string";
|
|
9700
|
+
const knowledgeRequestId = receiptRequired ? randomUUID3() : null;
|
|
9701
|
+
const context = await client.getTaskKnowledgeContext(taskId, {
|
|
9702
|
+
query: buildKnowledgeQuery(task),
|
|
9703
|
+
...knowledgeRequestId ? { knowledgeRequestId } : {}
|
|
9704
|
+
});
|
|
9586
9705
|
if (!context || typeof context !== "object") {
|
|
9587
9706
|
knowledgeContextMarkdown = handleMissingKnowledgeContext(taskId, "control-plane knowledge endpoint returned no context payload", {
|
|
9588
9707
|
allowMissingKnowledgeContext,
|
|
9589
9708
|
log: log2
|
|
9590
9709
|
});
|
|
9710
|
+
} else if (receiptRequired && knowledgeRequestId) {
|
|
9711
|
+
exposure = verifyKnowledgeExposureResponse(context, task, knowledgeRequestId);
|
|
9712
|
+
knowledgeContextMarkdown = knowledgeExposurePromptBlock(exposure).markdown;
|
|
9591
9713
|
} else {
|
|
9592
9714
|
knowledgeContextMarkdown = typeof context.context_markdown === "string" ? context.context_markdown : "";
|
|
9593
9715
|
}
|
|
@@ -9597,6 +9719,10 @@ async function composeCodeTaskPrompt(client, task, { log: log2 = () => {
|
|
|
9597
9719
|
log: log2
|
|
9598
9720
|
});
|
|
9599
9721
|
}
|
|
9722
|
+
try {
|
|
9723
|
+
onKnowledgeExposure?.(exposure ?? Object.freeze({ status: "no_receipt_degraded" }));
|
|
9724
|
+
} catch {
|
|
9725
|
+
}
|
|
9600
9726
|
const operatorInstructions = buildOperatorInstructionBlock(task);
|
|
9601
9727
|
const prompt = operatorInstructions ? `${task?.prompt ?? ""}
|
|
9602
9728
|
|
|
@@ -9613,12 +9739,13 @@ var init_task_prompt = __esm({
|
|
|
9613
9739
|
"use strict";
|
|
9614
9740
|
init_dispatch_onboarding();
|
|
9615
9741
|
init_methodology_composer();
|
|
9742
|
+
init_knowledge_exposure_receipt();
|
|
9616
9743
|
ALLOW_MISSING_KNOWLEDGE_CONTEXT_ENV = "VO_CODE_RUNNER_ALLOW_MISSING_KNOWLEDGE_CONTEXT";
|
|
9617
9744
|
}
|
|
9618
9745
|
});
|
|
9619
9746
|
|
|
9620
9747
|
// ../../scripts/virtual-office/code-runner/task-attachments.mjs
|
|
9621
|
-
import { createHash as
|
|
9748
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
9622
9749
|
import { chmod, mkdir, mkdtemp, readFile, readdir, realpath, rm, stat, writeFile } from "node:fs/promises";
|
|
9623
9750
|
import os2 from "node:os";
|
|
9624
9751
|
import path17 from "node:path";
|
|
@@ -9661,7 +9788,7 @@ async function createAttachmentDirectory(taskId, containmentRoot) {
|
|
|
9661
9788
|
throw new Error("task-attachment directory escaped the agent worktree root");
|
|
9662
9789
|
}
|
|
9663
9790
|
await writeFile(path17.join(directory, GITIGNORE_FILE), GITIGNORE_BODY, { encoding: "utf8", mode: 384 });
|
|
9664
|
-
const marker = JSON.stringify({ owner: MARKER_OWNER, token:
|
|
9791
|
+
const marker = JSON.stringify({ owner: MARKER_OWNER, token: randomUUID4(), directory: path17.basename(directory), created_at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
9665
9792
|
await writeFile(path17.join(directory, MARKER_FILE), marker, { encoding: "utf8", mode: 384 });
|
|
9666
9793
|
return { directory, marker, root, cleaned: false };
|
|
9667
9794
|
}
|
|
@@ -9759,7 +9886,7 @@ async function materializeTaskAttachments(client, task, { worktreeDir } = {}) {
|
|
|
9759
9886
|
const content = await client.downloadTaskAttachment(task.code_task_id, ref.attachment_id);
|
|
9760
9887
|
if (!Buffer.isBuffer(content)) throw new Error(`attachment ${ref.attachment_id} did not return binary content`);
|
|
9761
9888
|
if (content.byteLength !== ref.size_bytes) throw new Error(`attachment ${ref.attachment_id} size mismatch`);
|
|
9762
|
-
const sha2562 =
|
|
9889
|
+
const sha2562 = createHash5("sha256").update(content).digest("hex");
|
|
9763
9890
|
if (sha2562 !== ref.sha256) throw new Error(`attachment ${ref.attachment_id} sha256 mismatch`);
|
|
9764
9891
|
const name = sanitizeTaskAttachmentName(ref.name, index);
|
|
9765
9892
|
const filePath = path17.resolve(state.directory, name);
|
|
@@ -9809,9 +9936,9 @@ var init_task_attachments = __esm({
|
|
|
9809
9936
|
import { homedir as homedir7 } from "node:os";
|
|
9810
9937
|
import { join as join11 } from "node:path";
|
|
9811
9938
|
import { readdir as readdir2, readFile as readFile2, unlink, writeFile as writeFile2 } from "node:fs/promises";
|
|
9812
|
-
import { createHash as
|
|
9939
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
9813
9940
|
function deriveUuid(seed) {
|
|
9814
|
-
const h =
|
|
9941
|
+
const h = createHash6("sha256").update(seed).digest("hex");
|
|
9815
9942
|
return `${h.slice(0, 8)}-${h.slice(8, 12)}-5${h.slice(13, 16)}-${(parseInt(h.slice(16, 18), 16) & 63 | 128).toString(16)}${h.slice(18, 20)}-${h.slice(20, 32)}`;
|
|
9816
9943
|
}
|
|
9817
9944
|
function spoolToCloud(record, ids) {
|
|
@@ -11088,7 +11215,7 @@ var init_prepared_job_divergence = __esm({
|
|
|
11088
11215
|
|
|
11089
11216
|
// ../../scripts/virtual-office/code-runner/prepared-job-shadow.mjs
|
|
11090
11217
|
import { appendFileSync, mkdirSync as mkdirSync8 } from "node:fs";
|
|
11091
|
-
import { createHash as
|
|
11218
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
11092
11219
|
import { homedir as homedir9 } from "node:os";
|
|
11093
11220
|
import { dirname as dirname10, join as join14 } from "node:path";
|
|
11094
11221
|
function setRemotePreparedJobMode(mode) {
|
|
@@ -11377,7 +11504,7 @@ var init_prepared_job_shadow = __esm({
|
|
|
11377
11504
|
"methodology_shape",
|
|
11378
11505
|
"methodology_stakes"
|
|
11379
11506
|
];
|
|
11380
|
-
sha256 = (s) =>
|
|
11507
|
+
sha256 = (s) => createHash7("sha256").update(String(s ?? ""), "utf8").digest("hex");
|
|
11381
11508
|
sameValue = (a, b) => Array.isArray(a) || Array.isArray(b) ? JSON.stringify(a) === JSON.stringify(b) : (a ?? null) === (b ?? null);
|
|
11382
11509
|
verdictObserver = null;
|
|
11383
11510
|
}
|
|
@@ -12113,7 +12240,7 @@ var init_pr_watcher_failure_confirmation = __esm({
|
|
|
12113
12240
|
});
|
|
12114
12241
|
|
|
12115
12242
|
// ../../scripts/virtual-office/code-runner/watcher-coordination.mjs
|
|
12116
|
-
import { createHash as
|
|
12243
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
12117
12244
|
function ciFixOccurrenceKey({ repo, prNumber, headSha, repairAttempt }) {
|
|
12118
12245
|
const occurrence = JSON.stringify([
|
|
12119
12246
|
String(repo).toLowerCase(),
|
|
@@ -12121,7 +12248,7 @@ function ciFixOccurrenceKey({ repo, prNumber, headSha, repairAttempt }) {
|
|
|
12121
12248
|
String(headSha).toLowerCase(),
|
|
12122
12249
|
Number(repairAttempt)
|
|
12123
12250
|
]);
|
|
12124
|
-
return `ci-fix:v1:${
|
|
12251
|
+
return `ci-fix:v1:${createHash8("sha256").update(occurrence).digest("hex")}`;
|
|
12125
12252
|
}
|
|
12126
12253
|
function coordinationRetryDue(entry, nowMs) {
|
|
12127
12254
|
return !entry.nextRetryAt || nowMs >= entry.nextRetryAt;
|
|
@@ -12251,7 +12378,7 @@ var init_watcher_coordination = __esm({
|
|
|
12251
12378
|
});
|
|
12252
12379
|
|
|
12253
12380
|
// ../../scripts/virtual-office/code-runner/watcher-state.mjs
|
|
12254
|
-
import { randomUUID as
|
|
12381
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12255
12382
|
import { mkdir as mkdir3, open as open2, readFile as readFile4, rename, unlink as unlink2 } from "node:fs/promises";
|
|
12256
12383
|
import { dirname as dirname11 } from "node:path";
|
|
12257
12384
|
async function readWatcherState(stateFile) {
|
|
@@ -12271,7 +12398,7 @@ async function readWatcherState(stateFile) {
|
|
|
12271
12398
|
async function writeWatcherState(stateFile, state) {
|
|
12272
12399
|
const directory = dirname11(stateFile);
|
|
12273
12400
|
await mkdir3(directory, { recursive: true });
|
|
12274
|
-
const temp = `${stateFile}.${process.pid}.${
|
|
12401
|
+
const temp = `${stateFile}.${process.pid}.${randomUUID5()}.tmp`;
|
|
12275
12402
|
let handle;
|
|
12276
12403
|
try {
|
|
12277
12404
|
handle = await open2(temp, "wx");
|
|
@@ -12814,7 +12941,7 @@ var init_pr_watcher_github = __esm({
|
|
|
12814
12941
|
});
|
|
12815
12942
|
|
|
12816
12943
|
// ../../scripts/virtual-office/code-runner/enqueue-autonomous-code-task.mjs
|
|
12817
|
-
import { randomUUID as
|
|
12944
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
12818
12945
|
function isDefiniteRefusal(err) {
|
|
12819
12946
|
const status = Number(err?.status);
|
|
12820
12947
|
if (Number.isFinite(status) && status >= 400 && status < 500) return true;
|
|
@@ -12833,7 +12960,7 @@ async function enqueueAutonomousCodeTask(client, task, log2 = () => {
|
|
|
12833
12960
|
if (typeof client?.reserveAutonomousDispatchBudget !== "function" || typeof client?.releaseAutonomousDispatchBudget !== "function") {
|
|
12834
12961
|
throw new Error("autonomous dispatch admission client unavailable");
|
|
12835
12962
|
}
|
|
12836
|
-
const reservationId =
|
|
12963
|
+
const reservationId = randomUUID6();
|
|
12837
12964
|
const admission = await client.reserveAutonomousDispatchBudget({
|
|
12838
12965
|
requestedBudgetUsd,
|
|
12839
12966
|
reservationId,
|
|
@@ -13597,7 +13724,7 @@ var init_effort_mode_config = __esm({
|
|
|
13597
13724
|
});
|
|
13598
13725
|
|
|
13599
13726
|
// ../../scripts/virtual-office/model-registry.mjs
|
|
13600
|
-
import { randomUUID as
|
|
13727
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
13601
13728
|
import fs11 from "node:fs";
|
|
13602
13729
|
import os4 from "node:os";
|
|
13603
13730
|
import path19 from "node:path";
|
|
@@ -13608,7 +13735,7 @@ function userCacheRoot() {
|
|
|
13608
13735
|
if (home) return path19.join(home, ".claude");
|
|
13609
13736
|
} catch {
|
|
13610
13737
|
}
|
|
13611
|
-
return path19.join(os4.tmpdir(), `vo-model-registry-${
|
|
13738
|
+
return path19.join(os4.tmpdir(), `vo-model-registry-${randomUUID7()}`);
|
|
13612
13739
|
}
|
|
13613
13740
|
function resolveCacheBaseDir(env2 = process.env, moduleDir = __dirname) {
|
|
13614
13741
|
if (env2.VO_MODEL_REGISTRY_CACHE_DIR) return env2.VO_MODEL_REGISTRY_CACHE_DIR;
|
|
@@ -15939,7 +16066,7 @@ function consensusReceiptIdFrom(text) {
|
|
|
15939
16066
|
const source = String(text ?? "");
|
|
15940
16067
|
for (const match of source.matchAll(RECEIPT_RE)) {
|
|
15941
16068
|
const token2 = match[1];
|
|
15942
|
-
if (
|
|
16069
|
+
if (UUID_RE2.test(token2)) return token2.toLowerCase();
|
|
15943
16070
|
const end = match.index + match[0].length;
|
|
15944
16071
|
const probe = `${token2.replace(/[_-]+/gu, " ")} ${source.slice(end, end + 40)}`;
|
|
15945
16072
|
if (RECEIPT_NEGATIVE_RE.test(probe)) continue;
|
|
@@ -15956,13 +16083,13 @@ function terminalLedgerPatch(run, nowIso = (/* @__PURE__ */ new Date()).toISOStr
|
|
|
15956
16083
|
if (receipt) patch.consensus_receipt_id = receipt;
|
|
15957
16084
|
return patch;
|
|
15958
16085
|
}
|
|
15959
|
-
var FENCE_RE, KEY_RE,
|
|
16086
|
+
var FENCE_RE, KEY_RE, UUID_RE2, RECEIPT_RE, RECEIPT_NEGATIVE_RE, PLACEHOLDER_RE;
|
|
15960
16087
|
var init_terminal_ledger_patch = __esm({
|
|
15961
16088
|
"../../scripts/virtual-office/code-runner/terminal-ledger-patch.mjs"() {
|
|
15962
16089
|
"use strict";
|
|
15963
16090
|
FENCE_RE = /```vo-decision-request\s*\n([\s\S]*?)```/iu;
|
|
15964
16091
|
KEY_RE = /^[A-D]$/u;
|
|
15965
|
-
|
|
16092
|
+
UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
15966
16093
|
RECEIPT_RE = /(?<![A-Za-z0-9_-])(?:consensus[ _-]?)?receipt(?:[ _-]?id)?[`"'*]*\s*[:=#\-\u2013\u2014]\s*[`"'*]*\s*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|(?:rcpt|cons)[_-][A-Za-z0-9._:-]{4,115})[`"'*]?/giu;
|
|
15967
16094
|
RECEIPT_NEGATIVE_RE = /\b(?:not[_-]?available|unavailable|todo|n\/a|none|pending|missing|skipped)\b/iu;
|
|
15968
16095
|
PLACEHOLDER_RE = /^[\s.\u2026"'`\-_]*$/u;
|
|
@@ -16963,7 +17090,7 @@ var init_detached_economics_spool = __esm({
|
|
|
16963
17090
|
});
|
|
16964
17091
|
|
|
16965
17092
|
// ../../scripts/virtual-office/code-runner/killed-run-outcome.mjs
|
|
16966
|
-
import { randomUUID as
|
|
17093
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
16967
17094
|
async function handleKilledRun({
|
|
16968
17095
|
client,
|
|
16969
17096
|
id,
|
|
@@ -17000,7 +17127,7 @@ async function handleKilledRun({
|
|
|
17000
17127
|
};
|
|
17001
17128
|
}
|
|
17002
17129
|
if (reason === "claim_authority_changed") {
|
|
17003
|
-
const occurrenceId =
|
|
17130
|
+
const occurrenceId = randomUUID8();
|
|
17004
17131
|
const economics = {
|
|
17005
17132
|
occurrence_id: occurrenceId,
|
|
17006
17133
|
runner_id: runnerId,
|
|
@@ -17279,7 +17406,7 @@ var code_runner_daemon_exports = {};
|
|
|
17279
17406
|
__export(code_runner_daemon_exports, {
|
|
17280
17407
|
main: () => main
|
|
17281
17408
|
});
|
|
17282
|
-
import { randomUUID as
|
|
17409
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
17283
17410
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
17284
17411
|
function log(msg) {
|
|
17285
17412
|
console.log(`[code-runner ${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}`);
|
|
@@ -17291,6 +17418,7 @@ async function processOneTask(client, task, cfg, runnerInstanceId, swarmAdmissio
|
|
|
17291
17418
|
let attachmentBundle = null;
|
|
17292
17419
|
let run = null;
|
|
17293
17420
|
let methodology = null;
|
|
17421
|
+
let knowledgeExposure = null;
|
|
17294
17422
|
let rateLimitResume = null;
|
|
17295
17423
|
try {
|
|
17296
17424
|
if (await recoverPreservedCodeTask({ task, cfg, client, log })) return;
|
|
@@ -17312,11 +17440,20 @@ async function processOneTask(client, task, cfg, runnerInstanceId, swarmAdmissio
|
|
|
17312
17440
|
onMethodology: (m) => {
|
|
17313
17441
|
methodology = m;
|
|
17314
17442
|
},
|
|
17443
|
+
onKnowledgeExposure: (exposure) => {
|
|
17444
|
+
knowledgeExposure = exposure;
|
|
17445
|
+
},
|
|
17315
17446
|
allowMissingKnowledgeContext: process.env.VO_CODE_RUNNER_ALLOW_MISSING_KNOWLEDGE_CONTEXT === "1",
|
|
17316
17447
|
attachmentManifestMarkdown: attachmentBundle.manifestMarkdown,
|
|
17317
17448
|
repoRoot: wt.worktreeDir
|
|
17318
17449
|
// ADR-004 § 11.1c: the skill catalog must be the one THIS agent can read
|
|
17319
17450
|
}) });
|
|
17451
|
+
const knowledgeSpawn = createKnowledgeSpawnAcknowledgement({
|
|
17452
|
+
exposure: knowledgeExposure,
|
|
17453
|
+
prompt: effortPrompt,
|
|
17454
|
+
agent: sel.agent,
|
|
17455
|
+
post: (patch) => safeProgress(client, id, patch)
|
|
17456
|
+
});
|
|
17320
17457
|
await runPreparedJobShadow({ client, task, agent: sel.agent, env: process.env, log, local: {
|
|
17321
17458
|
// ADR-004 § 11.1b SHADOW: default OFF; return value deliberately unread — slice C owns consumption
|
|
17322
17459
|
prompt: effortPrompt,
|
|
@@ -17365,11 +17502,7 @@ async function processOneTask(client, task, cfg, runnerInstanceId, swarmAdmissio
|
|
|
17365
17502
|
void safeProgress(client, id, patch).catch(() => {
|
|
17366
17503
|
});
|
|
17367
17504
|
},
|
|
17368
|
-
onSpawn:
|
|
17369
|
-
client,
|
|
17370
|
-
id,
|
|
17371
|
-
runnerStagePatch("agent_spawned", `${sel.agent} process spawned; execution began`)
|
|
17372
|
-
),
|
|
17505
|
+
onSpawn: knowledgeSpawn.onSpawn,
|
|
17373
17506
|
shouldCancel: makeCancellationProbe({
|
|
17374
17507
|
client,
|
|
17375
17508
|
taskId: id,
|
|
@@ -17380,6 +17513,7 @@ async function processOneTask(client, task, cfg, runnerInstanceId, swarmAdmissio
|
|
|
17380
17513
|
cancelPollMs: cfg.cancelPollMs,
|
|
17381
17514
|
maxWallClockMs: cfg.maxWallClockMs
|
|
17382
17515
|
});
|
|
17516
|
+
await knowledgeSpawn.retryIfNeeded();
|
|
17383
17517
|
await assertCanonicalIsolation(canonicalBaseline, { worktreeDir: wt.worktreeDir, taskId: id });
|
|
17384
17518
|
if (run.killed) {
|
|
17385
17519
|
const stopped = await handleKilledRun({
|
|
@@ -17531,7 +17665,7 @@ Closes #${publicationTarget.supersedesPrNumber}` : "";
|
|
|
17531
17665
|
async function main({ env: env2 = process.env, once: once2 = false } = {}) {
|
|
17532
17666
|
const cfg = loadCodeRunnerConfig(env2, { log });
|
|
17533
17667
|
await sweepStaleTaskAttachmentDirectories().catch((error) => log(`stale attachment cleanup failed: ${error.message}`));
|
|
17534
|
-
const runnerInstanceId =
|
|
17668
|
+
const runnerInstanceId = randomUUID9();
|
|
17535
17669
|
const client = createControlPlaneClient({
|
|
17536
17670
|
env: env2,
|
|
17537
17671
|
runnerId: cfg.runnerId,
|
|
@@ -17691,6 +17825,7 @@ var init_code_runner_daemon = __esm({
|
|
|
17691
17825
|
init_orphan_agent_reaper();
|
|
17692
17826
|
init_publish_async();
|
|
17693
17827
|
init_task_prompt();
|
|
17828
|
+
init_knowledge_exposure_receipt();
|
|
17694
17829
|
init_task_attachments();
|
|
17695
17830
|
init_loop_ticks();
|
|
17696
17831
|
init_runner_capacity();
|