@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.js CHANGED
@@ -172,7 +172,7 @@ function absoluteEntryPath(entryPath) {
172
172
 
173
173
  // src/bin.ts
174
174
  var argv = process.argv.slice(2);
175
- requireCurrentCliForProvision(argv).then(() => requireCoherentProvisionRuntime(argv)).then(async () => (await import("./cli-CDIXAFN4.js")).runCli()).catch((err) => {
175
+ requireCurrentCliForProvision(argv).then(() => requireCoherentProvisionRuntime(argv)).then(async () => (await import("./cli-BI26ENP4.js")).runCli()).catch((err) => {
176
176
  console.error(redactSecrets(`odla-ai: ${err instanceof Error ? err.message : String(err)}`));
177
177
  process.exitCode = exitCodeFor(err);
178
178
  });
@@ -6319,7 +6319,7 @@ async function stageWorkspacePair(baselineSource, workspaceSource, options = {})
6319
6319
  }
6320
6320
  }
6321
6321
 
6322
- // ../harness/dist/chunk-IWVGSWY6.js
6322
+ // ../harness/dist/chunk-J7XU5QB7.js
6323
6323
  import { createHash as createHash3 } from "crypto";
6324
6324
  import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
6325
6325
  import { relative as relative4, resolve as resolve10 } from "path";
@@ -6656,7 +6656,7 @@ function validateSnapshot(snapshot, limits) {
6656
6656
  }
6657
6657
  }
6658
6658
 
6659
- // ../harness/dist/chunk-IWVGSWY6.js
6659
+ // ../harness/dist/chunk-J7XU5QB7.js
6660
6660
  import { spawn as spawn4 } from "child_process";
6661
6661
  import { lstat as lstat2 } from "fs/promises";
6662
6662
  import { resolve as resolve23, sep as sep3 } from "path";
@@ -6963,7 +6963,7 @@ function looksLikeDestination(value2) {
6963
6963
  return /^(?:[a-z][a-z0-9+.-]*:\/\/|\/|\\\\)/i.test(text4) || /^[\w.-]+\.[a-z]{2,}(?:[/:]|$)/i.test(text4);
6964
6964
  }
6965
6965
 
6966
- // ../harness/dist/chunk-IWVGSWY6.js
6966
+ // ../harness/dist/chunk-J7XU5QB7.js
6967
6967
  import { readFile as readFile4, stat as stat2 } from "fs/promises";
6968
6968
  import { readFile as readFile3 } from "fs/promises";
6969
6969
  import { join as join33 } from "path";
@@ -7231,7 +7231,7 @@ async function buildCodeGraph(input) {
7231
7231
  return builder.build();
7232
7232
  }
7233
7233
 
7234
- // ../harness/dist/chunk-IWVGSWY6.js
7234
+ // ../harness/dist/chunk-J7XU5QB7.js
7235
7235
  import { createHash as createHash32 } from "crypto";
7236
7236
  async function digestStagedWorkspace(root, limits) {
7237
7237
  const files = [];
@@ -7259,86 +7259,6 @@ async function digestStagedWorkspace(root, limits) {
7259
7259
  }
7260
7260
  return `sha256:${hash.digest("hex")}`;
7261
7261
  }
7262
- var CODE_RUNTIME_PROTOCOL_VERSION = 1;
7263
- async function runCodeRuntimeHeartbeatLoop(options) {
7264
- const heartbeatMs = options.heartbeatMs ?? 15e3;
7265
- if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1e3 || heartbeatMs > 3e5) {
7266
- throw new TypeError("heartbeatMs must be an integer from 1000 to 300000");
7267
- }
7268
- let retryMs = 1e3;
7269
- do {
7270
- if (options.signal?.aborted) return;
7271
- try {
7272
- const snapshot = await options.control.heartbeat(options.runtimeVersion, options.capabilities);
7273
- await options.onSnapshot?.(snapshot);
7274
- retryMs = 1e3;
7275
- if (options.once) return;
7276
- await wait(heartbeatMs, options.signal);
7277
- } catch (error) {
7278
- if (options.signal?.aborted) return;
7279
- if (options.once || !retryableControlFailure(error)) throw error;
7280
- await options.onRetry?.(error, retryMs);
7281
- await wait(retryMs, options.signal);
7282
- retryMs = Math.min(retryMs * 2, 3e4);
7283
- }
7284
- } while (!options.signal?.aborted);
7285
- }
7286
- var CodeRuntimeReconciler = class {
7287
- constructor(control, engine) {
7288
- this.control = control;
7289
- this.engine = engine;
7290
- }
7291
- control;
7292
- engine;
7293
- results = /* @__PURE__ */ new Map();
7294
- async reconcile(snapshot) {
7295
- for (const command of snapshot.commands) {
7296
- let completed = this.results.get(command.commandId);
7297
- if (!completed) {
7298
- let result;
7299
- try {
7300
- result = await this.engine.execute(command);
7301
- } catch (error) {
7302
- result = { status: "failed", message: (error instanceof Error ? error.message : String(error)).slice(0, 2e3) };
7303
- }
7304
- completed = { result, notified: false };
7305
- this.results.set(command.commandId, completed);
7306
- if (this.results.size > 1024) this.results.delete(this.results.keys().next().value);
7307
- }
7308
- await this.control.acknowledge(command.commandId, completed.result);
7309
- if (!completed.notified) {
7310
- await this.engine.acknowledged?.(command, completed.result);
7311
- completed.notified = true;
7312
- }
7313
- }
7314
- }
7315
- };
7316
- function retryableControlFailure(value2) {
7317
- if (!value2 || typeof value2 !== "object") return false;
7318
- const failure = value2;
7319
- if (failure.code === "invalid_response" || typeof failure.status !== "number") return false;
7320
- return failure.status === 408 || failure.status === 425 || failure.status === 429 || failure.status >= 500;
7321
- }
7322
- function wait(ms, signal) {
7323
- return new Promise((resolve52) => {
7324
- if (signal?.aborted) return resolve52();
7325
- const timer = setTimeout(resolve52, ms);
7326
- signal?.addEventListener("abort", () => {
7327
- clearTimeout(timer);
7328
- resolve52();
7329
- }, { once: true });
7330
- });
7331
- }
7332
- var CodeRuntimeControlError = class extends Error {
7333
- constructor(message2, status, code = "control_error") {
7334
- super(message2);
7335
- this.status = status;
7336
- this.code = code;
7337
- }
7338
- status;
7339
- code;
7340
- name = "CodeRuntimeControlError";
7341
- };
7342
7262
  function createCodeRuntimeControlClient(options) {
7343
7263
  const endpoint = validatedEndpoint(options.endpoint);
7344
7264
  if (!/^odla_code_host_[0-9a-f]{64}$/.test(options.token)) throw new TypeError("invalid Code host credential");
@@ -7351,9 +7271,10 @@ function createCodeRuntimeControlClient(options) {
7351
7271
  throw new TypeError("modelRequestTimeoutMs must be an integer from 30000 to 1800000");
7352
7272
  }
7353
7273
  const request3 = options.fetch ?? fetch;
7354
- const call4 = async (path, body, timeoutMs = requestTimeoutMs) => {
7274
+ const call4 = async (path, body, timeoutMs = requestTimeoutMs, operationSignal) => {
7355
7275
  const timeout = AbortSignal.timeout(timeoutMs);
7356
- const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
7276
+ const signals = [options.signal, operationSignal, timeout].filter((item) => Boolean(item));
7277
+ const signal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
7357
7278
  let response2;
7358
7279
  try {
7359
7280
  response2 = await request3(`${endpoint}${path}`, {
@@ -7364,7 +7285,7 @@ function createCodeRuntimeControlClient(options) {
7364
7285
  signal
7365
7286
  });
7366
7287
  } catch (cause) {
7367
- if (options.signal?.aborted) throw cause;
7288
+ if (options.signal?.aborted || operationSignal?.aborted) throw cause;
7368
7289
  throw new CodeRuntimeControlError("Code runtime control plane is unavailable", 503, "transport_unavailable");
7369
7290
  }
7370
7291
  const value2 = await response2.json().catch(() => null);
@@ -7384,8 +7305,7 @@ function createCodeRuntimeControlClient(options) {
7384
7305
  return parseSnapshot(await call4("/registry/code/runtime/heartbeat", { runtimeVersion: version, capabilities }));
7385
7306
  },
7386
7307
  acknowledge: async (commandId, result) => {
7387
- if (!/^ccmd_[0-9a-f]{32}$/.test(commandId)) throw new TypeError("invalid Code runtime command id");
7388
- await call4(`/registry/code/runtime/commands/${commandId}/ack`, result);
7308
+ await call4(`/registry/code/runtime/commands/${validCommandId(commandId)}/ack`, result);
7389
7309
  },
7390
7310
  source: async (sessionId) => parseSource(
7391
7311
  await call4(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/source`, {})
@@ -7428,12 +7348,120 @@ function createCodeRuntimeControlClient(options) {
7428
7348
  rememberMemory: async (sessionId, memory) => {
7429
7349
  await call4(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/remember`, memory);
7430
7350
  },
7351
+ collaborationSkills: async (sessionId, commandId) => {
7352
+ try {
7353
+ return parseCollaborationSkills(await call4(
7354
+ `/registry/code/runtime/sessions/${validSessionId(sessionId)}/collaboration/skills`,
7355
+ { commandId: validCommandId(commandId) }
7356
+ ));
7357
+ } catch (cause) {
7358
+ if (cause instanceof CodeRuntimeControlError && cause.status === 404 && cause.code === "not_found") return [];
7359
+ throw cause;
7360
+ }
7361
+ },
7362
+ executeCollaborationTool: async (sessionId, collaboration, signal) => {
7363
+ validateCollaborationToolRequest(collaboration);
7364
+ return parseCollaborationToolOutput(await call4(
7365
+ `/registry/code/runtime/sessions/${validSessionId(sessionId)}/collaboration/tools`,
7366
+ collaboration,
7367
+ requestTimeoutMs,
7368
+ signal
7369
+ ));
7370
+ },
7431
7371
  reportSessionFailure: async (sessionId, message2) => {
7432
7372
  if (!message2.trim() || message2.length > 2e3) throw new TypeError("invalid Code session failure");
7433
7373
  await call4(`/registry/code/runtime/sessions/${validSessionId(sessionId)}/failure`, { message: message2 });
7434
7374
  }
7435
7375
  };
7436
7376
  }
7377
+ var CODE_RUNTIME_PROTOCOL_VERSION = 1;
7378
+ async function runCodeRuntimeHeartbeatLoop(options) {
7379
+ const heartbeatMs = options.heartbeatMs ?? 15e3;
7380
+ if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1e3 || heartbeatMs > 3e5) {
7381
+ throw new TypeError("heartbeatMs must be an integer from 1000 to 300000");
7382
+ }
7383
+ let retryMs = 1e3;
7384
+ do {
7385
+ if (options.signal?.aborted) return;
7386
+ try {
7387
+ const snapshot = await options.control.heartbeat(options.runtimeVersion, options.capabilities);
7388
+ await options.onSnapshot?.(snapshot);
7389
+ retryMs = 1e3;
7390
+ if (options.once) return;
7391
+ await wait(heartbeatMs, options.signal);
7392
+ } catch (error) {
7393
+ if (options.signal?.aborted) return;
7394
+ if (options.once || !retryableControlFailure(error)) throw error;
7395
+ await options.onRetry?.(error, retryMs);
7396
+ await wait(retryMs, options.signal);
7397
+ retryMs = Math.min(retryMs * 2, 3e4);
7398
+ }
7399
+ } while (!options.signal?.aborted);
7400
+ }
7401
+ var CodeRuntimeReconciler = class {
7402
+ constructor(control, engine, onDiagnostic) {
7403
+ this.control = control;
7404
+ this.engine = engine;
7405
+ this.onDiagnostic = onDiagnostic;
7406
+ }
7407
+ control;
7408
+ engine;
7409
+ onDiagnostic;
7410
+ results = /* @__PURE__ */ new Map();
7411
+ async reconcile(snapshot) {
7412
+ for (const command of snapshot.commands) {
7413
+ let completed = this.results.get(command.commandId);
7414
+ if (!completed) {
7415
+ let result;
7416
+ try {
7417
+ result = await this.engine.execute(command);
7418
+ } catch (error) {
7419
+ result = { status: "failed", message: (error instanceof Error ? error.message : String(error)).slice(0, 2e3) };
7420
+ }
7421
+ completed = { result, notified: false };
7422
+ this.results.set(command.commandId, completed);
7423
+ if (this.results.size > 1024) this.results.delete(this.results.keys().next().value);
7424
+ }
7425
+ await this.control.acknowledge(command.commandId, completed.result);
7426
+ if (!completed.notified) {
7427
+ try {
7428
+ await this.engine.acknowledged?.(command, completed.result);
7429
+ } catch (error) {
7430
+ this.onDiagnostic?.(
7431
+ `command ${command.commandId} acknowledged handling failed \xB7 ${error instanceof Error ? error.message : String(error)}`
7432
+ );
7433
+ }
7434
+ completed.notified = true;
7435
+ }
7436
+ }
7437
+ }
7438
+ };
7439
+ function retryableControlFailure(value2) {
7440
+ if (!value2 || typeof value2 !== "object") return false;
7441
+ const failure = value2;
7442
+ if (failure.code === "invalid_response" || typeof failure.status !== "number") return false;
7443
+ return failure.status === 408 || failure.status === 425 || failure.status === 429 || failure.status >= 500;
7444
+ }
7445
+ function wait(ms, signal) {
7446
+ return new Promise((resolve52) => {
7447
+ if (signal?.aborted) return resolve52();
7448
+ const timer = setTimeout(resolve52, ms);
7449
+ signal?.addEventListener("abort", () => {
7450
+ clearTimeout(timer);
7451
+ resolve52();
7452
+ }, { once: true });
7453
+ });
7454
+ }
7455
+ var CodeRuntimeControlError = class extends Error {
7456
+ constructor(message2, status, code = "control_error") {
7457
+ super(message2);
7458
+ this.status = status;
7459
+ this.code = code;
7460
+ }
7461
+ status;
7462
+ code;
7463
+ name = "CodeRuntimeControlError";
7464
+ };
7437
7465
  function validatedEndpoint(value2) {
7438
7466
  const endpoint = value2.replace(/\/+$/, "");
7439
7467
  let url;
@@ -7452,6 +7480,10 @@ function validSessionId(value2) {
7452
7480
  if (!/^csess_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code session id");
7453
7481
  return value2;
7454
7482
  }
7483
+ function validCommandId(value2) {
7484
+ if (!/^ccmd_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code runtime command id");
7485
+ return value2;
7486
+ }
7455
7487
  function validateHeartbeat(version, capabilities) {
7456
7488
  if (!version.trim() || version.length > 80) throw new TypeError("runtimeVersion is required and at most 80 characters");
7457
7489
  if (capabilities.protocolVersion !== CODE_RUNTIME_PROTOCOL_VERSION) throw new TypeError("unsupported Code runtime protocol version");
@@ -7533,6 +7565,91 @@ function parseCandidate(value2) {
7533
7565
  }
7534
7566
  return { candidateId: candidate.candidateId, status: candidate.status };
7535
7567
  }
7568
+ function parseCollaborationSkills(value2) {
7569
+ const items = record5(value2)?.skills;
7570
+ if (!Array.isArray(items) || items.length > 16) throw invalid("collaboration skills");
7571
+ const skillNames2 = /* @__PURE__ */ new Set();
7572
+ const toolNames = /* @__PURE__ */ new Set();
7573
+ return items.map((item) => {
7574
+ const skill = record5(item);
7575
+ 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) {
7576
+ throw invalid("collaboration skill");
7577
+ }
7578
+ skillNames2.add(skill.name);
7579
+ const tools = skill.tools.map((candidate) => {
7580
+ const tool = record5(candidate);
7581
+ const inputSchema = record5(tool?.inputSchema);
7582
+ 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") {
7583
+ throw invalid("collaboration tool");
7584
+ }
7585
+ const outputTaint = parseTaintLabels(tool.outputTaint);
7586
+ const acceptsTaint = parseTaintLabels(tool.acceptsTaint);
7587
+ toolNames.add(tool.name);
7588
+ return {
7589
+ name: tool.name,
7590
+ description: tool.description,
7591
+ inputSchema,
7592
+ ...tool.concurrency === "parallel" ? { concurrency: "parallel" } : {},
7593
+ ...outputTaint ? { outputTaint } : {},
7594
+ ...acceptsTaint ? { acceptsTaint } : {}
7595
+ };
7596
+ });
7597
+ return {
7598
+ name: skill.name,
7599
+ ...typeof skill.instructions === "string" ? { instructions: skill.instructions } : {},
7600
+ tools
7601
+ };
7602
+ });
7603
+ }
7604
+ function validateCollaborationToolRequest(value2) {
7605
+ validCommandId(value2.commandId);
7606
+ 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) {
7607
+ throw new TypeError("invalid Code collaboration tool request");
7608
+ }
7609
+ }
7610
+ function parseCollaborationToolOutput(value2) {
7611
+ const output = record5(record5(value2)?.output);
7612
+ if (!output || output.isError !== void 0 && typeof output.isError !== "boolean") {
7613
+ throw invalid("collaboration tool");
7614
+ }
7615
+ if (typeof output.content === "string") {
7616
+ if (utf8Bytes(output.content) > 1e6) throw invalid("collaboration tool");
7617
+ return { content: output.content, ...output.isError === true ? { isError: true } : {} };
7618
+ }
7619
+ if (!Array.isArray(output.content) || output.content.length > 64 || jsonBytes(output.content) > 1e6 || !output.content.every((block2) => {
7620
+ const item = record5(block2);
7621
+ return item && ["text", "image", "audio", "document", "tool_use", "tool_result", "thinking"].includes(String(item.type));
7622
+ })) throw invalid("collaboration tool");
7623
+ return {
7624
+ content: output.content,
7625
+ ...output.isError === true ? { isError: true } : {}
7626
+ };
7627
+ }
7628
+ function parseTaintLabels(value2) {
7629
+ if (value2 === void 0) return void 0;
7630
+ if (!Array.isArray(value2) || value2.length > 16) throw invalid("collaboration tool taint");
7631
+ const labels = value2.map((item) => {
7632
+ if (item === "web_untrusted" || item === "operator_pasted_untrusted" || item === "llm_inherited") return item;
7633
+ if (typeof item === "string" && /^tool_untrusted:[^\s\u0000-\u001f\u007f]{1,100}$/.test(item)) {
7634
+ return item;
7635
+ }
7636
+ throw invalid("collaboration tool taint");
7637
+ });
7638
+ return [...new Set(labels)];
7639
+ }
7640
+ function validManifestName(value2) {
7641
+ return typeof value2 === "string" && /^[A-Za-z][A-Za-z0-9._:-]{0,127}$/.test(value2);
7642
+ }
7643
+ function utf8Bytes(value2) {
7644
+ return new TextEncoder().encode(value2).byteLength;
7645
+ }
7646
+ function jsonBytes(value2) {
7647
+ try {
7648
+ return utf8Bytes(JSON.stringify(value2));
7649
+ } catch {
7650
+ return Number.POSITIVE_INFINITY;
7651
+ }
7652
+ }
7536
7653
  var record5 = (value2) => value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
7537
7654
  var invalid = (part) => new CodeRuntimeControlError(`invalid Code runtime ${part} response`, 502, "invalid_response");
7538
7655
  var RESERVED = /* @__PURE__ */ new Set([".git", ".odla", ".wrangler", "node_modules", "dist", "coverage"]);
@@ -8547,6 +8664,46 @@ Finish with a concise, non-empty answer to the owner. Do not call tools or promi
8547
8664
  return { status: "failed", finalText: "", error };
8548
8665
  }
8549
8666
  }
8667
+ function createCodeRuntimeSessionSkillLoader(control) {
8668
+ const load = control.collaborationSkills?.bind(control);
8669
+ const execute2 = control.executeCollaborationTool?.bind(control);
8670
+ if (!load || !execute2) return async () => [];
8671
+ return async (command) => {
8672
+ const manifests = await load(command.sessionId, command.commandId);
8673
+ return manifests.map((manifest) => ({
8674
+ name: manifest.name,
8675
+ ...manifest.instructions === void 0 ? {} : { instructions: manifest.instructions },
8676
+ tools: manifest.tools.map((tool) => ({
8677
+ name: tool.name,
8678
+ description: tool.description,
8679
+ inputSchema: tool.inputSchema,
8680
+ ...tool.concurrency === void 0 ? {} : { concurrency: tool.concurrency },
8681
+ ...tool.outputTaint === void 0 ? {} : { outputTaint: tool.outputTaint },
8682
+ ...tool.acceptsTaint === void 0 ? {} : { acceptsTaint: tool.acceptsTaint },
8683
+ handler: async (input, context) => {
8684
+ if (!context.toolCallId) throw new TypeError("collaboration tool call identity is required");
8685
+ return execute2(command.sessionId, {
8686
+ commandId: command.commandId,
8687
+ toolCallId: context.toolCallId,
8688
+ skill: manifest.name,
8689
+ tool: tool.name,
8690
+ input
8691
+ }, context.signal);
8692
+ }
8693
+ }))
8694
+ }));
8695
+ };
8696
+ }
8697
+ async function sessionSkillsFor(options, command) {
8698
+ try {
8699
+ return await options.sessionSkills?.(command) ?? [];
8700
+ } catch (cause) {
8701
+ options.onDiagnostic?.(
8702
+ `session skills unavailable, continuing with code tools only: ${cause instanceof Error ? cause.message : String(cause)}`
8703
+ );
8704
+ return [];
8705
+ }
8706
+ }
8550
8707
  async function handleCodeRuntimeInference(input) {
8551
8708
  const { command, request: request3, state: state2 } = input;
8552
8709
  const startedAt = Date.now();
@@ -9410,16 +9567,6 @@ function assertBudget(budget) {
9410
9567
  throw new TypeError("goal budget deadline must be epoch milliseconds");
9411
9568
  }
9412
9569
  }
9413
- async function sessionSkillsFor(options, command) {
9414
- try {
9415
- return await options.sessionSkills?.(command) ?? [];
9416
- } catch (cause) {
9417
- options.onDiagnostic?.(
9418
- `session skills unavailable, continuing with code tools only: ${cause instanceof Error ? cause.message : String(cause)}`
9419
- );
9420
- return [];
9421
- }
9422
- }
9423
9570
  function createCodeRuntimeToolBroker(input, lease, role) {
9424
9571
  const broker = createCodeToolBroker({
9425
9572
  recipes: input.recipes,
@@ -9710,6 +9857,23 @@ function codeToolResultPresentation(request3, response2) {
9710
9857
  ...excerpt(output, true) ? { excerpt: excerpt(output, true) } : {}
9711
9858
  };
9712
9859
  }
9860
+ function codeRuntimeAcknowledgementGate(signal) {
9861
+ let settle;
9862
+ let settled = false;
9863
+ const ready = new Promise((resolve52) => {
9864
+ settle = resolve52;
9865
+ });
9866
+ const release = (run) => {
9867
+ if (settled) return;
9868
+ settled = true;
9869
+ signal.removeEventListener("abort", onAbort);
9870
+ settle(run);
9871
+ };
9872
+ const onAbort = () => release(false);
9873
+ if (signal.aborted) release(false);
9874
+ else signal.addEventListener("abort", onAbort, { once: true });
9875
+ return { ready, release };
9876
+ }
9713
9877
  var TheseusRuntimeEngine = class {
9714
9878
  constructor(options) {
9715
9879
  this.options = options;
@@ -9739,6 +9903,8 @@ var TheseusRuntimeEngine = class {
9739
9903
  const active = this.#active.get(command.sessionId);
9740
9904
  if (!active || result.status !== "running") return;
9741
9905
  active.acknowledged = true;
9906
+ active.startGate?.release(true);
9907
+ active.startGate = void 0;
9742
9908
  if (active.failure) await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
9743
9909
  }
9744
9910
  async close() {
@@ -9758,13 +9924,14 @@ var TheseusRuntimeEngine = class {
9758
9924
  control: this.options.control,
9759
9925
  ...this.options.localSource ? { localSource: this.options.localSource } : {}
9760
9926
  });
9761
- const abort = new AbortController();
9927
+ const abort = new AbortController(), startGate = codeRuntimeAcknowledgementGate(abort.signal);
9762
9928
  const conversationRefs = [];
9763
9929
  const active = {
9764
9930
  workspace,
9765
9931
  abort,
9766
9932
  conversationRefs,
9767
9933
  acknowledged: false,
9934
+ startGate,
9768
9935
  role: metadata2.role,
9769
9936
  title: metadata2.title,
9770
9937
  maxTokensPerInteraction: metadata2.maxTokensPerInteraction,
@@ -9788,7 +9955,7 @@ var TheseusRuntimeEngine = class {
9788
9955
  body: `Source snapshot: local checkout ${requestedLocal.snapshotDigest} \xB7 ${requestedLocal.modified ? "modified" : "clean"} \xB7 Git ${requestedLocal.headCommitSha}`
9789
9956
  }, conversationRefs);
9790
9957
  }
9791
- active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
9958
+ active.done = startGate.ready.then((run) => run ? this.#runAttempt(command, metadata2, active) : null).catch(async (cause) => {
9792
9959
  const detail = runtimeErrorMessage(cause);
9793
9960
  await this.#event(command, { type: "message", actor: "system", body: detail }, conversationRefs).catch(() => void 0);
9794
9961
  await this.#diagnostic(command, active, detail);
@@ -10423,10 +10590,15 @@ async function runCodeRuntime(input) {
10423
10590
  engine: input.engine,
10424
10591
  recipes: CODE_BUILD_RECIPES,
10425
10592
  recipeAuthorization: "registered_recipe",
10593
+ sessionSkills: createCodeRuntimeSessionSkillLoader(control),
10426
10594
  localSource: input.localSource,
10427
10595
  onDiagnostic: (message2) => input.stdout.error(`Theseus runtime failed \xB7 ${message2}`)
10428
10596
  });
10429
- const reconciler = new CodeRuntimeReconciler(control, commandEngine);
10597
+ const reconciler = new CodeRuntimeReconciler(
10598
+ control,
10599
+ commandEngine,
10600
+ (message2) => input.stdout.error(`Theseus runtime \xB7 ${message2}`)
10601
+ );
10430
10602
  try {
10431
10603
  await runCodeRuntimeHeartbeatLoop({
10432
10604
  control,
@@ -16264,4 +16436,4 @@ export {
16264
16436
  isTerminalHostedSecurityStatus,
16265
16437
  runCli
16266
16438
  };
16267
- //# sourceMappingURL=chunk-OW5WW5ET.js.map
16439
+ //# sourceMappingURL=chunk-J6GIGX6T.js.map