@odla-ai/cli 0.46.8 → 0.46.10

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "./chunk-OW5WW5ET.js";
4
+ } from "./chunk-QI2UJSSB.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-CDIXAFN4.js.map
12
+ //# sourceMappingURL=cli-URBPUBP5.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-IWVGSWY6.js
6498
+ // ../harness/dist/chunk-NG7AYYH3.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-IWVGSWY6.js
6835
+ // ../harness/dist/chunk-NG7AYYH3.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-IWVGSWY6.js
7139
+ // ../harness/dist/chunk-NG7AYYH3.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-IWVGSWY6.js
7407
+ // ../harness/dist/chunk-NG7AYYH3.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 signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
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
- if (!/^ccmd_[0-9a-f]{32}$/.test(commandId)) throw new TypeError("invalid Code runtime command id");
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,112 @@ 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) {
7576
+ this.control = control;
7577
+ this.engine = engine;
7578
+ }
7579
+ control;
7580
+ engine;
7581
+ results = /* @__PURE__ */ new Map();
7582
+ async reconcile(snapshot) {
7583
+ for (const command of snapshot.commands) {
7584
+ let completed = this.results.get(command.commandId);
7585
+ if (!completed) {
7586
+ let result;
7587
+ try {
7588
+ result = await this.engine.execute(command);
7589
+ } catch (error) {
7590
+ result = { status: "failed", message: (error instanceof Error ? error.message : String(error)).slice(0, 2e3) };
7591
+ }
7592
+ completed = { result, notified: false };
7593
+ this.results.set(command.commandId, completed);
7594
+ if (this.results.size > 1024) this.results.delete(this.results.keys().next().value);
7595
+ }
7596
+ await this.control.acknowledge(command.commandId, completed.result);
7597
+ if (!completed.notified) {
7598
+ await this.engine.acknowledged?.(command, completed.result);
7599
+ completed.notified = true;
7600
+ }
7601
+ }
7602
+ }
7603
+ };
7604
+ function retryableControlFailure(value2) {
7605
+ if (!value2 || typeof value2 !== "object") return false;
7606
+ const failure = value2;
7607
+ if (failure.code === "invalid_response" || typeof failure.status !== "number") return false;
7608
+ return failure.status === 408 || failure.status === 425 || failure.status === 429 || failure.status >= 500;
7609
+ }
7610
+ function wait(ms, signal) {
7611
+ return new Promise((resolve52) => {
7612
+ if (signal?.aborted) return resolve52();
7613
+ const timer = setTimeout(resolve52, ms);
7614
+ signal?.addEventListener("abort", () => {
7615
+ clearTimeout(timer);
7616
+ resolve52();
7617
+ }, { once: true });
7618
+ });
7619
+ }
7620
+ var CodeRuntimeControlError = class extends Error {
7621
+ constructor(message2, status, code = "control_error") {
7622
+ super(message2);
7623
+ this.status = status;
7624
+ this.code = code;
7625
+ }
7626
+ status;
7627
+ code;
7628
+ name = "CodeRuntimeControlError";
7629
+ };
7610
7630
  function validatedEndpoint(value2) {
7611
7631
  const endpoint = value2.replace(/\/+$/, "");
7612
7632
  let url;
@@ -7625,6 +7645,10 @@ function validSessionId(value2) {
7625
7645
  if (!/^csess_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code session id");
7626
7646
  return value2;
7627
7647
  }
7648
+ function validCommandId(value2) {
7649
+ if (!/^ccmd_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code runtime command id");
7650
+ return value2;
7651
+ }
7628
7652
  function validateHeartbeat(version, capabilities) {
7629
7653
  if (!version.trim() || version.length > 80) throw new TypeError("runtimeVersion is required and at most 80 characters");
7630
7654
  if (capabilities.protocolVersion !== CODE_RUNTIME_PROTOCOL_VERSION) throw new TypeError("unsupported Code runtime protocol version");
@@ -7706,6 +7730,91 @@ function parseCandidate(value2) {
7706
7730
  }
7707
7731
  return { candidateId: candidate.candidateId, status: candidate.status };
7708
7732
  }
7733
+ function parseCollaborationSkills(value2) {
7734
+ const items = record5(value2)?.skills;
7735
+ if (!Array.isArray(items) || items.length > 16) throw invalid("collaboration skills");
7736
+ const skillNames2 = /* @__PURE__ */ new Set();
7737
+ const toolNames = /* @__PURE__ */ new Set();
7738
+ return items.map((item) => {
7739
+ const skill = record5(item);
7740
+ 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) {
7741
+ throw invalid("collaboration skill");
7742
+ }
7743
+ skillNames2.add(skill.name);
7744
+ const tools = skill.tools.map((candidate) => {
7745
+ const tool = record5(candidate);
7746
+ const inputSchema = record5(tool?.inputSchema);
7747
+ 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") {
7748
+ throw invalid("collaboration tool");
7749
+ }
7750
+ const outputTaint = parseTaintLabels(tool.outputTaint);
7751
+ const acceptsTaint = parseTaintLabels(tool.acceptsTaint);
7752
+ toolNames.add(tool.name);
7753
+ return {
7754
+ name: tool.name,
7755
+ description: tool.description,
7756
+ inputSchema,
7757
+ ...tool.concurrency === "parallel" ? { concurrency: "parallel" } : {},
7758
+ ...outputTaint ? { outputTaint } : {},
7759
+ ...acceptsTaint ? { acceptsTaint } : {}
7760
+ };
7761
+ });
7762
+ return {
7763
+ name: skill.name,
7764
+ ...typeof skill.instructions === "string" ? { instructions: skill.instructions } : {},
7765
+ tools
7766
+ };
7767
+ });
7768
+ }
7769
+ function validateCollaborationToolRequest(value2) {
7770
+ validCommandId(value2.commandId);
7771
+ 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) {
7772
+ throw new TypeError("invalid Code collaboration tool request");
7773
+ }
7774
+ }
7775
+ function parseCollaborationToolOutput(value2) {
7776
+ const output = record5(record5(value2)?.output);
7777
+ if (!output || output.isError !== void 0 && typeof output.isError !== "boolean") {
7778
+ throw invalid("collaboration tool");
7779
+ }
7780
+ if (typeof output.content === "string") {
7781
+ if (utf8Bytes(output.content) > 1e6) throw invalid("collaboration tool");
7782
+ return { content: output.content, ...output.isError === true ? { isError: true } : {} };
7783
+ }
7784
+ if (!Array.isArray(output.content) || output.content.length > 64 || jsonBytes(output.content) > 1e6 || !output.content.every((block2) => {
7785
+ const item = record5(block2);
7786
+ return item && ["text", "image", "audio", "document", "tool_use", "tool_result", "thinking"].includes(String(item.type));
7787
+ })) throw invalid("collaboration tool");
7788
+ return {
7789
+ content: output.content,
7790
+ ...output.isError === true ? { isError: true } : {}
7791
+ };
7792
+ }
7793
+ function parseTaintLabels(value2) {
7794
+ if (value2 === void 0) return void 0;
7795
+ if (!Array.isArray(value2) || value2.length > 16) throw invalid("collaboration tool taint");
7796
+ const labels = value2.map((item) => {
7797
+ if (item === "web_untrusted" || item === "operator_pasted_untrusted" || item === "llm_inherited") return item;
7798
+ if (typeof item === "string" && /^tool_untrusted:[^\s\u0000-\u001f\u007f]{1,100}$/.test(item)) {
7799
+ return item;
7800
+ }
7801
+ throw invalid("collaboration tool taint");
7802
+ });
7803
+ return [...new Set(labels)];
7804
+ }
7805
+ function validManifestName(value2) {
7806
+ return typeof value2 === "string" && /^[A-Za-z][A-Za-z0-9._:-]{0,127}$/.test(value2);
7807
+ }
7808
+ function utf8Bytes(value2) {
7809
+ return new TextEncoder().encode(value2).byteLength;
7810
+ }
7811
+ function jsonBytes(value2) {
7812
+ try {
7813
+ return utf8Bytes(JSON.stringify(value2));
7814
+ } catch {
7815
+ return Number.POSITIVE_INFINITY;
7816
+ }
7817
+ }
7709
7818
  var record5 = (value2) => value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
7710
7819
  var invalid = (part) => new CodeRuntimeControlError(`invalid Code runtime ${part} response`, 502, "invalid_response");
7711
7820
  var RESERVED = /* @__PURE__ */ new Set([".git", ".odla", ".wrangler", "node_modules", "dist", "coverage"]);
@@ -8720,6 +8829,46 @@ Finish with a concise, non-empty answer to the owner. Do not call tools or promi
8720
8829
  return { status: "failed", finalText: "", error };
8721
8830
  }
8722
8831
  }
8832
+ function createCodeRuntimeSessionSkillLoader(control) {
8833
+ const load = control.collaborationSkills?.bind(control);
8834
+ const execute2 = control.executeCollaborationTool?.bind(control);
8835
+ if (!load || !execute2) return async () => [];
8836
+ return async (command) => {
8837
+ const manifests = await load(command.sessionId, command.commandId);
8838
+ return manifests.map((manifest) => ({
8839
+ name: manifest.name,
8840
+ ...manifest.instructions === void 0 ? {} : { instructions: manifest.instructions },
8841
+ tools: manifest.tools.map((tool) => ({
8842
+ name: tool.name,
8843
+ description: tool.description,
8844
+ inputSchema: tool.inputSchema,
8845
+ ...tool.concurrency === void 0 ? {} : { concurrency: tool.concurrency },
8846
+ ...tool.outputTaint === void 0 ? {} : { outputTaint: tool.outputTaint },
8847
+ ...tool.acceptsTaint === void 0 ? {} : { acceptsTaint: tool.acceptsTaint },
8848
+ handler: async (input, context) => {
8849
+ if (!context.toolCallId) throw new TypeError("collaboration tool call identity is required");
8850
+ return execute2(command.sessionId, {
8851
+ commandId: command.commandId,
8852
+ toolCallId: context.toolCallId,
8853
+ skill: manifest.name,
8854
+ tool: tool.name,
8855
+ input
8856
+ }, context.signal);
8857
+ }
8858
+ }))
8859
+ }));
8860
+ };
8861
+ }
8862
+ async function sessionSkillsFor(options, command) {
8863
+ try {
8864
+ return await options.sessionSkills?.(command) ?? [];
8865
+ } catch (cause) {
8866
+ options.onDiagnostic?.(
8867
+ `session skills unavailable, continuing with code tools only: ${cause instanceof Error ? cause.message : String(cause)}`
8868
+ );
8869
+ return [];
8870
+ }
8871
+ }
8723
8872
  async function handleCodeRuntimeInference(input) {
8724
8873
  const { command, request: request3, state: state2 } = input;
8725
8874
  const startedAt = Date.now();
@@ -9583,16 +9732,6 @@ function assertBudget(budget) {
9583
9732
  throw new TypeError("goal budget deadline must be epoch milliseconds");
9584
9733
  }
9585
9734
  }
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
9735
  function createCodeRuntimeToolBroker(input, lease, role) {
9597
9736
  const broker = createCodeToolBroker({
9598
9737
  recipes: input.recipes,
@@ -9883,6 +10022,23 @@ function codeToolResultPresentation(request3, response2) {
9883
10022
  ...excerpt(output, true) ? { excerpt: excerpt(output, true) } : {}
9884
10023
  };
9885
10024
  }
10025
+ function codeRuntimeAcknowledgementGate(signal) {
10026
+ let settle;
10027
+ let settled = false;
10028
+ const ready = new Promise((resolve52) => {
10029
+ settle = resolve52;
10030
+ });
10031
+ const release = (run) => {
10032
+ if (settled) return;
10033
+ settled = true;
10034
+ signal.removeEventListener("abort", onAbort);
10035
+ settle(run);
10036
+ };
10037
+ const onAbort = () => release(false);
10038
+ if (signal.aborted) release(false);
10039
+ else signal.addEventListener("abort", onAbort, { once: true });
10040
+ return { ready, release };
10041
+ }
9886
10042
  var TheseusRuntimeEngine = class {
9887
10043
  constructor(options) {
9888
10044
  this.options = options;
@@ -9912,6 +10068,8 @@ var TheseusRuntimeEngine = class {
9912
10068
  const active = this.#active.get(command.sessionId);
9913
10069
  if (!active || result.status !== "running") return;
9914
10070
  active.acknowledged = true;
10071
+ active.startGate?.release(true);
10072
+ active.startGate = void 0;
9915
10073
  if (active.failure) await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
9916
10074
  }
9917
10075
  async close() {
@@ -9931,13 +10089,14 @@ var TheseusRuntimeEngine = class {
9931
10089
  control: this.options.control,
9932
10090
  ...this.options.localSource ? { localSource: this.options.localSource } : {}
9933
10091
  });
9934
- const abort = new AbortController();
10092
+ const abort = new AbortController(), startGate = codeRuntimeAcknowledgementGate(abort.signal);
9935
10093
  const conversationRefs = [];
9936
10094
  const active = {
9937
10095
  workspace,
9938
10096
  abort,
9939
10097
  conversationRefs,
9940
10098
  acknowledged: false,
10099
+ startGate,
9941
10100
  role: metadata2.role,
9942
10101
  title: metadata2.title,
9943
10102
  maxTokensPerInteraction: metadata2.maxTokensPerInteraction,
@@ -9961,7 +10120,7 @@ var TheseusRuntimeEngine = class {
9961
10120
  body: `Source snapshot: local checkout ${requestedLocal.snapshotDigest} \xB7 ${requestedLocal.modified ? "modified" : "clean"} \xB7 Git ${requestedLocal.headCommitSha}`
9962
10121
  }, conversationRefs);
9963
10122
  }
9964
- active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
10123
+ active.done = startGate.ready.then((run) => run ? this.#runAttempt(command, metadata2, active) : null).catch(async (cause) => {
9965
10124
  const detail = runtimeErrorMessage(cause);
9966
10125
  await this.#event(command, { type: "message", actor: "system", body: detail }, conversationRefs).catch(() => void 0);
9967
10126
  await this.#diagnostic(command, active, detail);
@@ -10596,6 +10755,7 @@ async function runCodeRuntime(input) {
10596
10755
  engine: input.engine,
10597
10756
  recipes: CODE_BUILD_RECIPES,
10598
10757
  recipeAuthorization: "registered_recipe",
10758
+ sessionSkills: createCodeRuntimeSessionSkillLoader(control),
10599
10759
  localSource: input.localSource,
10600
10760
  onDiagnostic: (message2) => input.stdout.error(`Theseus runtime failed \xB7 ${message2}`)
10601
10761
  });