@odla-ai/cli 0.46.9 → 0.46.11
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/bin.cjs +235 -63
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-OW5WW5ET.js → chunk-J6GIGX6T.js} +275 -103
- package/dist/chunk-J6GIGX6T.js.map +1 -0
- package/dist/{cli-CDIXAFN4.js → cli-BI26ENP4.js} +2 -2
- package/dist/index.cjs +274 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-OW5WW5ET.js.map +0 -1
- /package/dist/{cli-CDIXAFN4.js.map → cli-BI26ENP4.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runCli
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-J6GIGX6T.js";
|
|
5
5
|
import {
|
|
6
6
|
exitCodeFor
|
|
7
7
|
} from "./chunk-5MEO3BVF.js";
|
|
@@ -9,4 +9,4 @@ export {
|
|
|
9
9
|
exitCodeFor,
|
|
10
10
|
runCli
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=cli-
|
|
12
|
+
//# sourceMappingURL=cli-BI26ENP4.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -6495,7 +6495,7 @@ async function stageWorkspacePair(baselineSource, workspaceSource, options = {})
|
|
|
6495
6495
|
}
|
|
6496
6496
|
}
|
|
6497
6497
|
|
|
6498
|
-
// ../harness/dist/chunk-
|
|
6498
|
+
// ../harness/dist/chunk-J7XU5QB7.js
|
|
6499
6499
|
var import_crypto = require("crypto");
|
|
6500
6500
|
var import_promises5 = require("fs/promises");
|
|
6501
6501
|
var import_path5 = require("path");
|
|
@@ -6832,7 +6832,7 @@ function validateSnapshot(snapshot, limits) {
|
|
|
6832
6832
|
}
|
|
6833
6833
|
}
|
|
6834
6834
|
|
|
6835
|
-
// ../harness/dist/chunk-
|
|
6835
|
+
// ../harness/dist/chunk-J7XU5QB7.js
|
|
6836
6836
|
var import_child_process4 = require("child_process");
|
|
6837
6837
|
var import_promises6 = require("fs/promises");
|
|
6838
6838
|
var import_path6 = require("path");
|
|
@@ -7136,7 +7136,7 @@ function looksLikeDestination(value2) {
|
|
|
7136
7136
|
return /^(?:[a-z][a-z0-9+.-]*:\/\/|\/|\\\\)/i.test(text4) || /^[\w.-]+\.[a-z]{2,}(?:[/:]|$)/i.test(text4);
|
|
7137
7137
|
}
|
|
7138
7138
|
|
|
7139
|
-
// ../harness/dist/chunk-
|
|
7139
|
+
// ../harness/dist/chunk-J7XU5QB7.js
|
|
7140
7140
|
var import_promises10 = require("fs/promises");
|
|
7141
7141
|
var import_promises11 = require("fs/promises");
|
|
7142
7142
|
var import_path10 = require("path");
|
|
@@ -7404,7 +7404,7 @@ async function buildCodeGraph(input) {
|
|
|
7404
7404
|
return builder.build();
|
|
7405
7405
|
}
|
|
7406
7406
|
|
|
7407
|
-
// ../harness/dist/chunk-
|
|
7407
|
+
// ../harness/dist/chunk-J7XU5QB7.js
|
|
7408
7408
|
var import_crypto4 = require("crypto");
|
|
7409
7409
|
async function digestStagedWorkspace(root, limits) {
|
|
7410
7410
|
const files = [];
|
|
@@ -7432,86 +7432,6 @@ async function digestStagedWorkspace(root, limits) {
|
|
|
7432
7432
|
}
|
|
7433
7433
|
return `sha256:${hash.digest("hex")}`;
|
|
7434
7434
|
}
|
|
7435
|
-
var CODE_RUNTIME_PROTOCOL_VERSION = 1;
|
|
7436
|
-
async function runCodeRuntimeHeartbeatLoop(options) {
|
|
7437
|
-
const heartbeatMs = options.heartbeatMs ?? 15e3;
|
|
7438
|
-
if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1e3 || heartbeatMs > 3e5) {
|
|
7439
|
-
throw new TypeError("heartbeatMs must be an integer from 1000 to 300000");
|
|
7440
|
-
}
|
|
7441
|
-
let retryMs = 1e3;
|
|
7442
|
-
do {
|
|
7443
|
-
if (options.signal?.aborted) return;
|
|
7444
|
-
try {
|
|
7445
|
-
const snapshot = await options.control.heartbeat(options.runtimeVersion, options.capabilities);
|
|
7446
|
-
await options.onSnapshot?.(snapshot);
|
|
7447
|
-
retryMs = 1e3;
|
|
7448
|
-
if (options.once) return;
|
|
7449
|
-
await wait(heartbeatMs, options.signal);
|
|
7450
|
-
} catch (error) {
|
|
7451
|
-
if (options.signal?.aborted) return;
|
|
7452
|
-
if (options.once || !retryableControlFailure(error)) throw error;
|
|
7453
|
-
await options.onRetry?.(error, retryMs);
|
|
7454
|
-
await wait(retryMs, options.signal);
|
|
7455
|
-
retryMs = Math.min(retryMs * 2, 3e4);
|
|
7456
|
-
}
|
|
7457
|
-
} while (!options.signal?.aborted);
|
|
7458
|
-
}
|
|
7459
|
-
var CodeRuntimeReconciler = class {
|
|
7460
|
-
constructor(control, engine) {
|
|
7461
|
-
this.control = control;
|
|
7462
|
-
this.engine = engine;
|
|
7463
|
-
}
|
|
7464
|
-
control;
|
|
7465
|
-
engine;
|
|
7466
|
-
results = /* @__PURE__ */ new Map();
|
|
7467
|
-
async reconcile(snapshot) {
|
|
7468
|
-
for (const command of snapshot.commands) {
|
|
7469
|
-
let completed = this.results.get(command.commandId);
|
|
7470
|
-
if (!completed) {
|
|
7471
|
-
let result;
|
|
7472
|
-
try {
|
|
7473
|
-
result = await this.engine.execute(command);
|
|
7474
|
-
} catch (error) {
|
|
7475
|
-
result = { status: "failed", message: (error instanceof Error ? error.message : String(error)).slice(0, 2e3) };
|
|
7476
|
-
}
|
|
7477
|
-
completed = { result, notified: false };
|
|
7478
|
-
this.results.set(command.commandId, completed);
|
|
7479
|
-
if (this.results.size > 1024) this.results.delete(this.results.keys().next().value);
|
|
7480
|
-
}
|
|
7481
|
-
await this.control.acknowledge(command.commandId, completed.result);
|
|
7482
|
-
if (!completed.notified) {
|
|
7483
|
-
await this.engine.acknowledged?.(command, completed.result);
|
|
7484
|
-
completed.notified = true;
|
|
7485
|
-
}
|
|
7486
|
-
}
|
|
7487
|
-
}
|
|
7488
|
-
};
|
|
7489
|
-
function retryableControlFailure(value2) {
|
|
7490
|
-
if (!value2 || typeof value2 !== "object") return false;
|
|
7491
|
-
const failure = value2;
|
|
7492
|
-
if (failure.code === "invalid_response" || typeof failure.status !== "number") return false;
|
|
7493
|
-
return failure.status === 408 || failure.status === 425 || failure.status === 429 || failure.status >= 500;
|
|
7494
|
-
}
|
|
7495
|
-
function wait(ms, signal) {
|
|
7496
|
-
return new Promise((resolve52) => {
|
|
7497
|
-
if (signal?.aborted) return resolve52();
|
|
7498
|
-
const timer = setTimeout(resolve52, ms);
|
|
7499
|
-
signal?.addEventListener("abort", () => {
|
|
7500
|
-
clearTimeout(timer);
|
|
7501
|
-
resolve52();
|
|
7502
|
-
}, { once: true });
|
|
7503
|
-
});
|
|
7504
|
-
}
|
|
7505
|
-
var CodeRuntimeControlError = class extends Error {
|
|
7506
|
-
constructor(message2, status, code = "control_error") {
|
|
7507
|
-
super(message2);
|
|
7508
|
-
this.status = status;
|
|
7509
|
-
this.code = code;
|
|
7510
|
-
}
|
|
7511
|
-
status;
|
|
7512
|
-
code;
|
|
7513
|
-
name = "CodeRuntimeControlError";
|
|
7514
|
-
};
|
|
7515
7435
|
function createCodeRuntimeControlClient(options) {
|
|
7516
7436
|
const endpoint = validatedEndpoint(options.endpoint);
|
|
7517
7437
|
if (!/^odla_code_host_[0-9a-f]{64}$/.test(options.token)) throw new TypeError("invalid Code host credential");
|
|
@@ -7524,9 +7444,10 @@ function createCodeRuntimeControlClient(options) {
|
|
|
7524
7444
|
throw new TypeError("modelRequestTimeoutMs must be an integer from 30000 to 1800000");
|
|
7525
7445
|
}
|
|
7526
7446
|
const request3 = options.fetch ?? fetch;
|
|
7527
|
-
const call4 = async (path, body, timeoutMs = requestTimeoutMs) => {
|
|
7447
|
+
const call4 = async (path, body, timeoutMs = requestTimeoutMs, operationSignal) => {
|
|
7528
7448
|
const timeout = AbortSignal.timeout(timeoutMs);
|
|
7529
|
-
const
|
|
7449
|
+
const signals = [options.signal, operationSignal, timeout].filter((item) => Boolean(item));
|
|
7450
|
+
const signal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
7530
7451
|
let response2;
|
|
7531
7452
|
try {
|
|
7532
7453
|
response2 = await request3(`${endpoint}${path}`, {
|
|
@@ -7537,7 +7458,7 @@ function createCodeRuntimeControlClient(options) {
|
|
|
7537
7458
|
signal
|
|
7538
7459
|
});
|
|
7539
7460
|
} catch (cause) {
|
|
7540
|
-
if (options.signal?.aborted) throw cause;
|
|
7461
|
+
if (options.signal?.aborted || operationSignal?.aborted) throw cause;
|
|
7541
7462
|
throw new CodeRuntimeControlError("Code runtime control plane is unavailable", 503, "transport_unavailable");
|
|
7542
7463
|
}
|
|
7543
7464
|
const value2 = await response2.json().catch(() => null);
|
|
@@ -7557,8 +7478,7 @@ function createCodeRuntimeControlClient(options) {
|
|
|
7557
7478
|
return parseSnapshot(await call4("/registry/code/runtime/heartbeat", { runtimeVersion: version, capabilities }));
|
|
7558
7479
|
},
|
|
7559
7480
|
acknowledge: async (commandId, result) => {
|
|
7560
|
-
|
|
7561
|
-
await call4(`/registry/code/runtime/commands/${commandId}/ack`, result);
|
|
7481
|
+
await call4(`/registry/code/runtime/commands/${validCommandId(commandId)}/ack`, result);
|
|
7562
7482
|
},
|
|
7563
7483
|
source: async (sessionId) => parseSource(
|
|
7564
7484
|
await call4(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
|
|
@@ -7601,12 +7521,120 @@ function createCodeRuntimeControlClient(options) {
|
|
|
7601
7521
|
rememberMemory: async (sessionId, memory) => {
|
|
7602
7522
|
await call4(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/remember`, memory);
|
|
7603
7523
|
},
|
|
7524
|
+
collaborationSkills: async (sessionId, commandId) => {
|
|
7525
|
+
try {
|
|
7526
|
+
return parseCollaborationSkills(await call4(
|
|
7527
|
+
`/registry/code/runtime/sessions/${validSessionId(sessionId)}/collaboration/skills`,
|
|
7528
|
+
{ commandId: validCommandId(commandId) }
|
|
7529
|
+
));
|
|
7530
|
+
} catch (cause) {
|
|
7531
|
+
if (cause instanceof CodeRuntimeControlError && cause.status === 404 && cause.code === "not_found") return [];
|
|
7532
|
+
throw cause;
|
|
7533
|
+
}
|
|
7534
|
+
},
|
|
7535
|
+
executeCollaborationTool: async (sessionId, collaboration, signal) => {
|
|
7536
|
+
validateCollaborationToolRequest(collaboration);
|
|
7537
|
+
return parseCollaborationToolOutput(await call4(
|
|
7538
|
+
`/registry/code/runtime/sessions/${validSessionId(sessionId)}/collaboration/tools`,
|
|
7539
|
+
collaboration,
|
|
7540
|
+
requestTimeoutMs,
|
|
7541
|
+
signal
|
|
7542
|
+
));
|
|
7543
|
+
},
|
|
7604
7544
|
reportSessionFailure: async (sessionId, message2) => {
|
|
7605
7545
|
if (!message2.trim() || message2.length > 2e3) throw new TypeError("invalid Code session failure");
|
|
7606
7546
|
await call4(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/failure`, { message: message2 });
|
|
7607
7547
|
}
|
|
7608
7548
|
};
|
|
7609
7549
|
}
|
|
7550
|
+
var CODE_RUNTIME_PROTOCOL_VERSION = 1;
|
|
7551
|
+
async function runCodeRuntimeHeartbeatLoop(options) {
|
|
7552
|
+
const heartbeatMs = options.heartbeatMs ?? 15e3;
|
|
7553
|
+
if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1e3 || heartbeatMs > 3e5) {
|
|
7554
|
+
throw new TypeError("heartbeatMs must be an integer from 1000 to 300000");
|
|
7555
|
+
}
|
|
7556
|
+
let retryMs = 1e3;
|
|
7557
|
+
do {
|
|
7558
|
+
if (options.signal?.aborted) return;
|
|
7559
|
+
try {
|
|
7560
|
+
const snapshot = await options.control.heartbeat(options.runtimeVersion, options.capabilities);
|
|
7561
|
+
await options.onSnapshot?.(snapshot);
|
|
7562
|
+
retryMs = 1e3;
|
|
7563
|
+
if (options.once) return;
|
|
7564
|
+
await wait(heartbeatMs, options.signal);
|
|
7565
|
+
} catch (error) {
|
|
7566
|
+
if (options.signal?.aborted) return;
|
|
7567
|
+
if (options.once || !retryableControlFailure(error)) throw error;
|
|
7568
|
+
await options.onRetry?.(error, retryMs);
|
|
7569
|
+
await wait(retryMs, options.signal);
|
|
7570
|
+
retryMs = Math.min(retryMs * 2, 3e4);
|
|
7571
|
+
}
|
|
7572
|
+
} while (!options.signal?.aborted);
|
|
7573
|
+
}
|
|
7574
|
+
var CodeRuntimeReconciler = class {
|
|
7575
|
+
constructor(control, engine, onDiagnostic) {
|
|
7576
|
+
this.control = control;
|
|
7577
|
+
this.engine = engine;
|
|
7578
|
+
this.onDiagnostic = onDiagnostic;
|
|
7579
|
+
}
|
|
7580
|
+
control;
|
|
7581
|
+
engine;
|
|
7582
|
+
onDiagnostic;
|
|
7583
|
+
results = /* @__PURE__ */ new Map();
|
|
7584
|
+
async reconcile(snapshot) {
|
|
7585
|
+
for (const command of snapshot.commands) {
|
|
7586
|
+
let completed = this.results.get(command.commandId);
|
|
7587
|
+
if (!completed) {
|
|
7588
|
+
let result;
|
|
7589
|
+
try {
|
|
7590
|
+
result = await this.engine.execute(command);
|
|
7591
|
+
} catch (error) {
|
|
7592
|
+
result = { status: "failed", message: (error instanceof Error ? error.message : String(error)).slice(0, 2e3) };
|
|
7593
|
+
}
|
|
7594
|
+
completed = { result, notified: false };
|
|
7595
|
+
this.results.set(command.commandId, completed);
|
|
7596
|
+
if (this.results.size > 1024) this.results.delete(this.results.keys().next().value);
|
|
7597
|
+
}
|
|
7598
|
+
await this.control.acknowledge(command.commandId, completed.result);
|
|
7599
|
+
if (!completed.notified) {
|
|
7600
|
+
try {
|
|
7601
|
+
await this.engine.acknowledged?.(command, completed.result);
|
|
7602
|
+
} catch (error) {
|
|
7603
|
+
this.onDiagnostic?.(
|
|
7604
|
+
`command ${command.commandId} acknowledged handling failed \xB7 ${error instanceof Error ? error.message : String(error)}`
|
|
7605
|
+
);
|
|
7606
|
+
}
|
|
7607
|
+
completed.notified = true;
|
|
7608
|
+
}
|
|
7609
|
+
}
|
|
7610
|
+
}
|
|
7611
|
+
};
|
|
7612
|
+
function retryableControlFailure(value2) {
|
|
7613
|
+
if (!value2 || typeof value2 !== "object") return false;
|
|
7614
|
+
const failure = value2;
|
|
7615
|
+
if (failure.code === "invalid_response" || typeof failure.status !== "number") return false;
|
|
7616
|
+
return failure.status === 408 || failure.status === 425 || failure.status === 429 || failure.status >= 500;
|
|
7617
|
+
}
|
|
7618
|
+
function wait(ms, signal) {
|
|
7619
|
+
return new Promise((resolve52) => {
|
|
7620
|
+
if (signal?.aborted) return resolve52();
|
|
7621
|
+
const timer = setTimeout(resolve52, ms);
|
|
7622
|
+
signal?.addEventListener("abort", () => {
|
|
7623
|
+
clearTimeout(timer);
|
|
7624
|
+
resolve52();
|
|
7625
|
+
}, { once: true });
|
|
7626
|
+
});
|
|
7627
|
+
}
|
|
7628
|
+
var CodeRuntimeControlError = class extends Error {
|
|
7629
|
+
constructor(message2, status, code = "control_error") {
|
|
7630
|
+
super(message2);
|
|
7631
|
+
this.status = status;
|
|
7632
|
+
this.code = code;
|
|
7633
|
+
}
|
|
7634
|
+
status;
|
|
7635
|
+
code;
|
|
7636
|
+
name = "CodeRuntimeControlError";
|
|
7637
|
+
};
|
|
7610
7638
|
function validatedEndpoint(value2) {
|
|
7611
7639
|
const endpoint = value2.replace(/\/+$/, "");
|
|
7612
7640
|
let url;
|
|
@@ -7625,6 +7653,10 @@ function validSessionId(value2) {
|
|
|
7625
7653
|
if (!/^csess_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code session id");
|
|
7626
7654
|
return value2;
|
|
7627
7655
|
}
|
|
7656
|
+
function validCommandId(value2) {
|
|
7657
|
+
if (!/^ccmd_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code runtime command id");
|
|
7658
|
+
return value2;
|
|
7659
|
+
}
|
|
7628
7660
|
function validateHeartbeat(version, capabilities) {
|
|
7629
7661
|
if (!version.trim() || version.length > 80) throw new TypeError("runtimeVersion is required and at most 80 characters");
|
|
7630
7662
|
if (capabilities.protocolVersion !== CODE_RUNTIME_PROTOCOL_VERSION) throw new TypeError("unsupported Code runtime protocol version");
|
|
@@ -7706,6 +7738,91 @@ function parseCandidate(value2) {
|
|
|
7706
7738
|
}
|
|
7707
7739
|
return { candidateId: candidate.candidateId, status: candidate.status };
|
|
7708
7740
|
}
|
|
7741
|
+
function parseCollaborationSkills(value2) {
|
|
7742
|
+
const items = record5(value2)?.skills;
|
|
7743
|
+
if (!Array.isArray(items) || items.length > 16) throw invalid("collaboration skills");
|
|
7744
|
+
const skillNames2 = /* @__PURE__ */ new Set();
|
|
7745
|
+
const toolNames = /* @__PURE__ */ new Set();
|
|
7746
|
+
return items.map((item) => {
|
|
7747
|
+
const skill = record5(item);
|
|
7748
|
+
if (!skill || !validManifestName(skill.name) || skillNames2.has(skill.name) || skill.instructions !== void 0 && (typeof skill.instructions !== "string" || utf8Bytes(skill.instructions) > 32e3) || !Array.isArray(skill.tools) || !skill.tools.length || skill.tools.length > 128) {
|
|
7749
|
+
throw invalid("collaboration skill");
|
|
7750
|
+
}
|
|
7751
|
+
skillNames2.add(skill.name);
|
|
7752
|
+
const tools = skill.tools.map((candidate) => {
|
|
7753
|
+
const tool = record5(candidate);
|
|
7754
|
+
const inputSchema = record5(tool?.inputSchema);
|
|
7755
|
+
if (!tool || !validManifestName(tool.name) || toolNames.has(tool.name) || typeof tool.description !== "string" || utf8Bytes(tool.description) > 8e3 || !inputSchema || jsonBytes(inputSchema) > 64e3 || tool.concurrency !== void 0 && tool.concurrency !== "parallel") {
|
|
7756
|
+
throw invalid("collaboration tool");
|
|
7757
|
+
}
|
|
7758
|
+
const outputTaint = parseTaintLabels(tool.outputTaint);
|
|
7759
|
+
const acceptsTaint = parseTaintLabels(tool.acceptsTaint);
|
|
7760
|
+
toolNames.add(tool.name);
|
|
7761
|
+
return {
|
|
7762
|
+
name: tool.name,
|
|
7763
|
+
description: tool.description,
|
|
7764
|
+
inputSchema,
|
|
7765
|
+
...tool.concurrency === "parallel" ? { concurrency: "parallel" } : {},
|
|
7766
|
+
...outputTaint ? { outputTaint } : {},
|
|
7767
|
+
...acceptsTaint ? { acceptsTaint } : {}
|
|
7768
|
+
};
|
|
7769
|
+
});
|
|
7770
|
+
return {
|
|
7771
|
+
name: skill.name,
|
|
7772
|
+
...typeof skill.instructions === "string" ? { instructions: skill.instructions } : {},
|
|
7773
|
+
tools
|
|
7774
|
+
};
|
|
7775
|
+
});
|
|
7776
|
+
}
|
|
7777
|
+
function validateCollaborationToolRequest(value2) {
|
|
7778
|
+
validCommandId(value2.commandId);
|
|
7779
|
+
if (typeof value2.toolCallId !== "string" || value2.toolCallId.length > 256 || !/^[^\s\u0000-\u001f\u007f]+$/.test(value2.toolCallId) || !validManifestName(value2.skill) || !validManifestName(value2.tool) || !record5(value2.input) || jsonBytes(value2.input) > 128e3) {
|
|
7780
|
+
throw new TypeError("invalid Code collaboration tool request");
|
|
7781
|
+
}
|
|
7782
|
+
}
|
|
7783
|
+
function parseCollaborationToolOutput(value2) {
|
|
7784
|
+
const output = record5(record5(value2)?.output);
|
|
7785
|
+
if (!output || output.isError !== void 0 && typeof output.isError !== "boolean") {
|
|
7786
|
+
throw invalid("collaboration tool");
|
|
7787
|
+
}
|
|
7788
|
+
if (typeof output.content === "string") {
|
|
7789
|
+
if (utf8Bytes(output.content) > 1e6) throw invalid("collaboration tool");
|
|
7790
|
+
return { content: output.content, ...output.isError === true ? { isError: true } : {} };
|
|
7791
|
+
}
|
|
7792
|
+
if (!Array.isArray(output.content) || output.content.length > 64 || jsonBytes(output.content) > 1e6 || !output.content.every((block2) => {
|
|
7793
|
+
const item = record5(block2);
|
|
7794
|
+
return item && ["text", "image", "audio", "document", "tool_use", "tool_result", "thinking"].includes(String(item.type));
|
|
7795
|
+
})) throw invalid("collaboration tool");
|
|
7796
|
+
return {
|
|
7797
|
+
content: output.content,
|
|
7798
|
+
...output.isError === true ? { isError: true } : {}
|
|
7799
|
+
};
|
|
7800
|
+
}
|
|
7801
|
+
function parseTaintLabels(value2) {
|
|
7802
|
+
if (value2 === void 0) return void 0;
|
|
7803
|
+
if (!Array.isArray(value2) || value2.length > 16) throw invalid("collaboration tool taint");
|
|
7804
|
+
const labels = value2.map((item) => {
|
|
7805
|
+
if (item === "web_untrusted" || item === "operator_pasted_untrusted" || item === "llm_inherited") return item;
|
|
7806
|
+
if (typeof item === "string" && /^tool_untrusted:[^\s\u0000-\u001f\u007f]{1,100}$/.test(item)) {
|
|
7807
|
+
return item;
|
|
7808
|
+
}
|
|
7809
|
+
throw invalid("collaboration tool taint");
|
|
7810
|
+
});
|
|
7811
|
+
return [...new Set(labels)];
|
|
7812
|
+
}
|
|
7813
|
+
function validManifestName(value2) {
|
|
7814
|
+
return typeof value2 === "string" && /^[A-Za-z][A-Za-z0-9._:-]{0,127}$/.test(value2);
|
|
7815
|
+
}
|
|
7816
|
+
function utf8Bytes(value2) {
|
|
7817
|
+
return new TextEncoder().encode(value2).byteLength;
|
|
7818
|
+
}
|
|
7819
|
+
function jsonBytes(value2) {
|
|
7820
|
+
try {
|
|
7821
|
+
return utf8Bytes(JSON.stringify(value2));
|
|
7822
|
+
} catch {
|
|
7823
|
+
return Number.POSITIVE_INFINITY;
|
|
7824
|
+
}
|
|
7825
|
+
}
|
|
7709
7826
|
var record5 = (value2) => value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
|
|
7710
7827
|
var invalid = (part) => new CodeRuntimeControlError(`invalid Code runtime ${part} response`, 502, "invalid_response");
|
|
7711
7828
|
var RESERVED = /* @__PURE__ */ new Set([".git", ".odla", ".wrangler", "node_modules", "dist", "coverage"]);
|
|
@@ -8720,6 +8837,46 @@ Finish with a concise, non-empty answer to the owner. Do not call tools or promi
|
|
|
8720
8837
|
return { status: "failed", finalText: "", error };
|
|
8721
8838
|
}
|
|
8722
8839
|
}
|
|
8840
|
+
function createCodeRuntimeSessionSkillLoader(control) {
|
|
8841
|
+
const load = control.collaborationSkills?.bind(control);
|
|
8842
|
+
const execute2 = control.executeCollaborationTool?.bind(control);
|
|
8843
|
+
if (!load || !execute2) return async () => [];
|
|
8844
|
+
return async (command) => {
|
|
8845
|
+
const manifests = await load(command.sessionId, command.commandId);
|
|
8846
|
+
return manifests.map((manifest) => ({
|
|
8847
|
+
name: manifest.name,
|
|
8848
|
+
...manifest.instructions === void 0 ? {} : { instructions: manifest.instructions },
|
|
8849
|
+
tools: manifest.tools.map((tool) => ({
|
|
8850
|
+
name: tool.name,
|
|
8851
|
+
description: tool.description,
|
|
8852
|
+
inputSchema: tool.inputSchema,
|
|
8853
|
+
...tool.concurrency === void 0 ? {} : { concurrency: tool.concurrency },
|
|
8854
|
+
...tool.outputTaint === void 0 ? {} : { outputTaint: tool.outputTaint },
|
|
8855
|
+
...tool.acceptsTaint === void 0 ? {} : { acceptsTaint: tool.acceptsTaint },
|
|
8856
|
+
handler: async (input, context) => {
|
|
8857
|
+
if (!context.toolCallId) throw new TypeError("collaboration tool call identity is required");
|
|
8858
|
+
return execute2(command.sessionId, {
|
|
8859
|
+
commandId: command.commandId,
|
|
8860
|
+
toolCallId: context.toolCallId,
|
|
8861
|
+
skill: manifest.name,
|
|
8862
|
+
tool: tool.name,
|
|
8863
|
+
input
|
|
8864
|
+
}, context.signal);
|
|
8865
|
+
}
|
|
8866
|
+
}))
|
|
8867
|
+
}));
|
|
8868
|
+
};
|
|
8869
|
+
}
|
|
8870
|
+
async function sessionSkillsFor(options, command) {
|
|
8871
|
+
try {
|
|
8872
|
+
return await options.sessionSkills?.(command) ?? [];
|
|
8873
|
+
} catch (cause) {
|
|
8874
|
+
options.onDiagnostic?.(
|
|
8875
|
+
`session skills unavailable, continuing with code tools only: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
8876
|
+
);
|
|
8877
|
+
return [];
|
|
8878
|
+
}
|
|
8879
|
+
}
|
|
8723
8880
|
async function handleCodeRuntimeInference(input) {
|
|
8724
8881
|
const { command, request: request3, state: state2 } = input;
|
|
8725
8882
|
const startedAt = Date.now();
|
|
@@ -9583,16 +9740,6 @@ function assertBudget(budget) {
|
|
|
9583
9740
|
throw new TypeError("goal budget deadline must be epoch milliseconds");
|
|
9584
9741
|
}
|
|
9585
9742
|
}
|
|
9586
|
-
async function sessionSkillsFor(options, command) {
|
|
9587
|
-
try {
|
|
9588
|
-
return await options.sessionSkills?.(command) ?? [];
|
|
9589
|
-
} catch (cause) {
|
|
9590
|
-
options.onDiagnostic?.(
|
|
9591
|
-
`session skills unavailable, continuing with code tools only: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
9592
|
-
);
|
|
9593
|
-
return [];
|
|
9594
|
-
}
|
|
9595
|
-
}
|
|
9596
9743
|
function createCodeRuntimeToolBroker(input, lease, role) {
|
|
9597
9744
|
const broker = createCodeToolBroker({
|
|
9598
9745
|
recipes: input.recipes,
|
|
@@ -9883,6 +10030,23 @@ function codeToolResultPresentation(request3, response2) {
|
|
|
9883
10030
|
...excerpt(output, true) ? { excerpt: excerpt(output, true) } : {}
|
|
9884
10031
|
};
|
|
9885
10032
|
}
|
|
10033
|
+
function codeRuntimeAcknowledgementGate(signal) {
|
|
10034
|
+
let settle;
|
|
10035
|
+
let settled = false;
|
|
10036
|
+
const ready = new Promise((resolve52) => {
|
|
10037
|
+
settle = resolve52;
|
|
10038
|
+
});
|
|
10039
|
+
const release = (run) => {
|
|
10040
|
+
if (settled) return;
|
|
10041
|
+
settled = true;
|
|
10042
|
+
signal.removeEventListener("abort", onAbort);
|
|
10043
|
+
settle(run);
|
|
10044
|
+
};
|
|
10045
|
+
const onAbort = () => release(false);
|
|
10046
|
+
if (signal.aborted) release(false);
|
|
10047
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
10048
|
+
return { ready, release };
|
|
10049
|
+
}
|
|
9886
10050
|
var TheseusRuntimeEngine = class {
|
|
9887
10051
|
constructor(options) {
|
|
9888
10052
|
this.options = options;
|
|
@@ -9912,6 +10076,8 @@ var TheseusRuntimeEngine = class {
|
|
|
9912
10076
|
const active = this.#active.get(command.sessionId);
|
|
9913
10077
|
if (!active || result.status !== "running") return;
|
|
9914
10078
|
active.acknowledged = true;
|
|
10079
|
+
active.startGate?.release(true);
|
|
10080
|
+
active.startGate = void 0;
|
|
9915
10081
|
if (active.failure) await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
|
|
9916
10082
|
}
|
|
9917
10083
|
async close() {
|
|
@@ -9931,13 +10097,14 @@ var TheseusRuntimeEngine = class {
|
|
|
9931
10097
|
control: this.options.control,
|
|
9932
10098
|
...this.options.localSource ? { localSource: this.options.localSource } : {}
|
|
9933
10099
|
});
|
|
9934
|
-
const abort = new AbortController();
|
|
10100
|
+
const abort = new AbortController(), startGate = codeRuntimeAcknowledgementGate(abort.signal);
|
|
9935
10101
|
const conversationRefs = [];
|
|
9936
10102
|
const active = {
|
|
9937
10103
|
workspace,
|
|
9938
10104
|
abort,
|
|
9939
10105
|
conversationRefs,
|
|
9940
10106
|
acknowledged: false,
|
|
10107
|
+
startGate,
|
|
9941
10108
|
role: metadata2.role,
|
|
9942
10109
|
title: metadata2.title,
|
|
9943
10110
|
maxTokensPerInteraction: metadata2.maxTokensPerInteraction,
|
|
@@ -9961,7 +10128,7 @@ var TheseusRuntimeEngine = class {
|
|
|
9961
10128
|
body: `Source snapshot: local checkout ${requestedLocal.snapshotDigest} \xB7 ${requestedLocal.modified ? "modified" : "clean"} \xB7 Git ${requestedLocal.headCommitSha}`
|
|
9962
10129
|
}, conversationRefs);
|
|
9963
10130
|
}
|
|
9964
|
-
active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
|
|
10131
|
+
active.done = startGate.ready.then((run) => run ? this.#runAttempt(command, metadata2, active) : null).catch(async (cause) => {
|
|
9965
10132
|
const detail = runtimeErrorMessage(cause);
|
|
9966
10133
|
await this.#event(command, { type: "message", actor: "system", body: detail }, conversationRefs).catch(() => void 0);
|
|
9967
10134
|
await this.#diagnostic(command, active, detail);
|
|
@@ -10596,10 +10763,15 @@ async function runCodeRuntime(input) {
|
|
|
10596
10763
|
engine: input.engine,
|
|
10597
10764
|
recipes: CODE_BUILD_RECIPES,
|
|
10598
10765
|
recipeAuthorization: "registered_recipe",
|
|
10766
|
+
sessionSkills: createCodeRuntimeSessionSkillLoader(control),
|
|
10599
10767
|
localSource: input.localSource,
|
|
10600
10768
|
onDiagnostic: (message2) => input.stdout.error(`Theseus runtime failed \xB7 ${message2}`)
|
|
10601
10769
|
});
|
|
10602
|
-
const reconciler = new CodeRuntimeReconciler(
|
|
10770
|
+
const reconciler = new CodeRuntimeReconciler(
|
|
10771
|
+
control,
|
|
10772
|
+
commandEngine,
|
|
10773
|
+
(message2) => input.stdout.error(`Theseus runtime \xB7 ${message2}`)
|
|
10774
|
+
);
|
|
10603
10775
|
try {
|
|
10604
10776
|
await runCodeRuntimeHeartbeatLoop({
|
|
10605
10777
|
control,
|