@odla-ai/cli 0.46.9 → 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.
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-URBPUBP5.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-NG7AYYH3.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-NG7AYYH3.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-NG7AYYH3.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-NG7AYYH3.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,112 @@ 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) {
7403
+ this.control = control;
7404
+ this.engine = engine;
7405
+ }
7406
+ control;
7407
+ engine;
7408
+ results = /* @__PURE__ */ new Map();
7409
+ async reconcile(snapshot) {
7410
+ for (const command of snapshot.commands) {
7411
+ let completed = this.results.get(command.commandId);
7412
+ if (!completed) {
7413
+ let result;
7414
+ try {
7415
+ result = await this.engine.execute(command);
7416
+ } catch (error) {
7417
+ result = { status: "failed", message: (error instanceof Error ? error.message : String(error)).slice(0, 2e3) };
7418
+ }
7419
+ completed = { result, notified: false };
7420
+ this.results.set(command.commandId, completed);
7421
+ if (this.results.size > 1024) this.results.delete(this.results.keys().next().value);
7422
+ }
7423
+ await this.control.acknowledge(command.commandId, completed.result);
7424
+ if (!completed.notified) {
7425
+ await this.engine.acknowledged?.(command, completed.result);
7426
+ completed.notified = true;
7427
+ }
7428
+ }
7429
+ }
7430
+ };
7431
+ function retryableControlFailure(value2) {
7432
+ if (!value2 || typeof value2 !== "object") return false;
7433
+ const failure = value2;
7434
+ if (failure.code === "invalid_response" || typeof failure.status !== "number") return false;
7435
+ return failure.status === 408 || failure.status === 425 || failure.status === 429 || failure.status >= 500;
7436
+ }
7437
+ function wait(ms, signal) {
7438
+ return new Promise((resolve52) => {
7439
+ if (signal?.aborted) return resolve52();
7440
+ const timer = setTimeout(resolve52, ms);
7441
+ signal?.addEventListener("abort", () => {
7442
+ clearTimeout(timer);
7443
+ resolve52();
7444
+ }, { once: true });
7445
+ });
7446
+ }
7447
+ var CodeRuntimeControlError = class extends Error {
7448
+ constructor(message2, status, code = "control_error") {
7449
+ super(message2);
7450
+ this.status = status;
7451
+ this.code = code;
7452
+ }
7453
+ status;
7454
+ code;
7455
+ name = "CodeRuntimeControlError";
7456
+ };
7437
7457
  function validatedEndpoint(value2) {
7438
7458
  const endpoint = value2.replace(/\/+$/, "");
7439
7459
  let url;
@@ -7452,6 +7472,10 @@ function validSessionId(value2) {
7452
7472
  if (!/^csess_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code session id");
7453
7473
  return value2;
7454
7474
  }
7475
+ function validCommandId(value2) {
7476
+ if (!/^ccmd_[0-9a-f]{32}$/.test(value2)) throw new TypeError("invalid Code runtime command id");
7477
+ return value2;
7478
+ }
7455
7479
  function validateHeartbeat(version, capabilities) {
7456
7480
  if (!version.trim() || version.length > 80) throw new TypeError("runtimeVersion is required and at most 80 characters");
7457
7481
  if (capabilities.protocolVersion !== CODE_RUNTIME_PROTOCOL_VERSION) throw new TypeError("unsupported Code runtime protocol version");
@@ -7533,6 +7557,91 @@ function parseCandidate(value2) {
7533
7557
  }
7534
7558
  return { candidateId: candidate.candidateId, status: candidate.status };
7535
7559
  }
7560
+ function parseCollaborationSkills(value2) {
7561
+ const items = record5(value2)?.skills;
7562
+ if (!Array.isArray(items) || items.length > 16) throw invalid("collaboration skills");
7563
+ const skillNames2 = /* @__PURE__ */ new Set();
7564
+ const toolNames = /* @__PURE__ */ new Set();
7565
+ return items.map((item) => {
7566
+ const skill = record5(item);
7567
+ 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) {
7568
+ throw invalid("collaboration skill");
7569
+ }
7570
+ skillNames2.add(skill.name);
7571
+ const tools = skill.tools.map((candidate) => {
7572
+ const tool = record5(candidate);
7573
+ const inputSchema = record5(tool?.inputSchema);
7574
+ 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") {
7575
+ throw invalid("collaboration tool");
7576
+ }
7577
+ const outputTaint = parseTaintLabels(tool.outputTaint);
7578
+ const acceptsTaint = parseTaintLabels(tool.acceptsTaint);
7579
+ toolNames.add(tool.name);
7580
+ return {
7581
+ name: tool.name,
7582
+ description: tool.description,
7583
+ inputSchema,
7584
+ ...tool.concurrency === "parallel" ? { concurrency: "parallel" } : {},
7585
+ ...outputTaint ? { outputTaint } : {},
7586
+ ...acceptsTaint ? { acceptsTaint } : {}
7587
+ };
7588
+ });
7589
+ return {
7590
+ name: skill.name,
7591
+ ...typeof skill.instructions === "string" ? { instructions: skill.instructions } : {},
7592
+ tools
7593
+ };
7594
+ });
7595
+ }
7596
+ function validateCollaborationToolRequest(value2) {
7597
+ validCommandId(value2.commandId);
7598
+ 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) {
7599
+ throw new TypeError("invalid Code collaboration tool request");
7600
+ }
7601
+ }
7602
+ function parseCollaborationToolOutput(value2) {
7603
+ const output = record5(record5(value2)?.output);
7604
+ if (!output || output.isError !== void 0 && typeof output.isError !== "boolean") {
7605
+ throw invalid("collaboration tool");
7606
+ }
7607
+ if (typeof output.content === "string") {
7608
+ if (utf8Bytes(output.content) > 1e6) throw invalid("collaboration tool");
7609
+ return { content: output.content, ...output.isError === true ? { isError: true } : {} };
7610
+ }
7611
+ if (!Array.isArray(output.content) || output.content.length > 64 || jsonBytes(output.content) > 1e6 || !output.content.every((block2) => {
7612
+ const item = record5(block2);
7613
+ return item && ["text", "image", "audio", "document", "tool_use", "tool_result", "thinking"].includes(String(item.type));
7614
+ })) throw invalid("collaboration tool");
7615
+ return {
7616
+ content: output.content,
7617
+ ...output.isError === true ? { isError: true } : {}
7618
+ };
7619
+ }
7620
+ function parseTaintLabels(value2) {
7621
+ if (value2 === void 0) return void 0;
7622
+ if (!Array.isArray(value2) || value2.length > 16) throw invalid("collaboration tool taint");
7623
+ const labels = value2.map((item) => {
7624
+ if (item === "web_untrusted" || item === "operator_pasted_untrusted" || item === "llm_inherited") return item;
7625
+ if (typeof item === "string" && /^tool_untrusted:[^\s\u0000-\u001f\u007f]{1,100}$/.test(item)) {
7626
+ return item;
7627
+ }
7628
+ throw invalid("collaboration tool taint");
7629
+ });
7630
+ return [...new Set(labels)];
7631
+ }
7632
+ function validManifestName(value2) {
7633
+ return typeof value2 === "string" && /^[A-Za-z][A-Za-z0-9._:-]{0,127}$/.test(value2);
7634
+ }
7635
+ function utf8Bytes(value2) {
7636
+ return new TextEncoder().encode(value2).byteLength;
7637
+ }
7638
+ function jsonBytes(value2) {
7639
+ try {
7640
+ return utf8Bytes(JSON.stringify(value2));
7641
+ } catch {
7642
+ return Number.POSITIVE_INFINITY;
7643
+ }
7644
+ }
7536
7645
  var record5 = (value2) => value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
7537
7646
  var invalid = (part) => new CodeRuntimeControlError(`invalid Code runtime ${part} response`, 502, "invalid_response");
7538
7647
  var RESERVED = /* @__PURE__ */ new Set([".git", ".odla", ".wrangler", "node_modules", "dist", "coverage"]);
@@ -8547,6 +8656,46 @@ Finish with a concise, non-empty answer to the owner. Do not call tools or promi
8547
8656
  return { status: "failed", finalText: "", error };
8548
8657
  }
8549
8658
  }
8659
+ function createCodeRuntimeSessionSkillLoader(control) {
8660
+ const load = control.collaborationSkills?.bind(control);
8661
+ const execute2 = control.executeCollaborationTool?.bind(control);
8662
+ if (!load || !execute2) return async () => [];
8663
+ return async (command) => {
8664
+ const manifests = await load(command.sessionId, command.commandId);
8665
+ return manifests.map((manifest) => ({
8666
+ name: manifest.name,
8667
+ ...manifest.instructions === void 0 ? {} : { instructions: manifest.instructions },
8668
+ tools: manifest.tools.map((tool) => ({
8669
+ name: tool.name,
8670
+ description: tool.description,
8671
+ inputSchema: tool.inputSchema,
8672
+ ...tool.concurrency === void 0 ? {} : { concurrency: tool.concurrency },
8673
+ ...tool.outputTaint === void 0 ? {} : { outputTaint: tool.outputTaint },
8674
+ ...tool.acceptsTaint === void 0 ? {} : { acceptsTaint: tool.acceptsTaint },
8675
+ handler: async (input, context) => {
8676
+ if (!context.toolCallId) throw new TypeError("collaboration tool call identity is required");
8677
+ return execute2(command.sessionId, {
8678
+ commandId: command.commandId,
8679
+ toolCallId: context.toolCallId,
8680
+ skill: manifest.name,
8681
+ tool: tool.name,
8682
+ input
8683
+ }, context.signal);
8684
+ }
8685
+ }))
8686
+ }));
8687
+ };
8688
+ }
8689
+ async function sessionSkillsFor(options, command) {
8690
+ try {
8691
+ return await options.sessionSkills?.(command) ?? [];
8692
+ } catch (cause) {
8693
+ options.onDiagnostic?.(
8694
+ `session skills unavailable, continuing with code tools only: ${cause instanceof Error ? cause.message : String(cause)}`
8695
+ );
8696
+ return [];
8697
+ }
8698
+ }
8550
8699
  async function handleCodeRuntimeInference(input) {
8551
8700
  const { command, request: request3, state: state2 } = input;
8552
8701
  const startedAt = Date.now();
@@ -9410,16 +9559,6 @@ function assertBudget(budget) {
9410
9559
  throw new TypeError("goal budget deadline must be epoch milliseconds");
9411
9560
  }
9412
9561
  }
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
9562
  function createCodeRuntimeToolBroker(input, lease, role) {
9424
9563
  const broker = createCodeToolBroker({
9425
9564
  recipes: input.recipes,
@@ -9710,6 +9849,23 @@ function codeToolResultPresentation(request3, response2) {
9710
9849
  ...excerpt(output, true) ? { excerpt: excerpt(output, true) } : {}
9711
9850
  };
9712
9851
  }
9852
+ function codeRuntimeAcknowledgementGate(signal) {
9853
+ let settle;
9854
+ let settled = false;
9855
+ const ready = new Promise((resolve52) => {
9856
+ settle = resolve52;
9857
+ });
9858
+ const release = (run) => {
9859
+ if (settled) return;
9860
+ settled = true;
9861
+ signal.removeEventListener("abort", onAbort);
9862
+ settle(run);
9863
+ };
9864
+ const onAbort = () => release(false);
9865
+ if (signal.aborted) release(false);
9866
+ else signal.addEventListener("abort", onAbort, { once: true });
9867
+ return { ready, release };
9868
+ }
9713
9869
  var TheseusRuntimeEngine = class {
9714
9870
  constructor(options) {
9715
9871
  this.options = options;
@@ -9739,6 +9895,8 @@ var TheseusRuntimeEngine = class {
9739
9895
  const active = this.#active.get(command.sessionId);
9740
9896
  if (!active || result.status !== "running") return;
9741
9897
  active.acknowledged = true;
9898
+ active.startGate?.release(true);
9899
+ active.startGate = void 0;
9742
9900
  if (active.failure) await this.options.control.reportSessionFailure(command.sessionId, active.failure).catch(() => void 0);
9743
9901
  }
9744
9902
  async close() {
@@ -9758,13 +9916,14 @@ var TheseusRuntimeEngine = class {
9758
9916
  control: this.options.control,
9759
9917
  ...this.options.localSource ? { localSource: this.options.localSource } : {}
9760
9918
  });
9761
- const abort = new AbortController();
9919
+ const abort = new AbortController(), startGate = codeRuntimeAcknowledgementGate(abort.signal);
9762
9920
  const conversationRefs = [];
9763
9921
  const active = {
9764
9922
  workspace,
9765
9923
  abort,
9766
9924
  conversationRefs,
9767
9925
  acknowledged: false,
9926
+ startGate,
9768
9927
  role: metadata2.role,
9769
9928
  title: metadata2.title,
9770
9929
  maxTokensPerInteraction: metadata2.maxTokensPerInteraction,
@@ -9788,7 +9947,7 @@ var TheseusRuntimeEngine = class {
9788
9947
  body: `Source snapshot: local checkout ${requestedLocal.snapshotDigest} \xB7 ${requestedLocal.modified ? "modified" : "clean"} \xB7 Git ${requestedLocal.headCommitSha}`
9789
9948
  }, conversationRefs);
9790
9949
  }
9791
- active.done = this.#runAttempt(command, metadata2, active).catch(async (cause) => {
9950
+ active.done = startGate.ready.then((run) => run ? this.#runAttempt(command, metadata2, active) : null).catch(async (cause) => {
9792
9951
  const detail = runtimeErrorMessage(cause);
9793
9952
  await this.#event(command, { type: "message", actor: "system", body: detail }, conversationRefs).catch(() => void 0);
9794
9953
  await this.#diagnostic(command, active, detail);
@@ -10423,6 +10582,7 @@ async function runCodeRuntime(input) {
10423
10582
  engine: input.engine,
10424
10583
  recipes: CODE_BUILD_RECIPES,
10425
10584
  recipeAuthorization: "registered_recipe",
10585
+ sessionSkills: createCodeRuntimeSessionSkillLoader(control),
10426
10586
  localSource: input.localSource,
10427
10587
  onDiagnostic: (message2) => input.stdout.error(`Theseus runtime failed \xB7 ${message2}`)
10428
10588
  });
@@ -16264,4 +16424,4 @@ export {
16264
16424
  isTerminalHostedSecurityStatus,
16265
16425
  runCli
16266
16426
  };
16267
- //# sourceMappingURL=chunk-OW5WW5ET.js.map
16427
+ //# sourceMappingURL=chunk-QI2UJSSB.js.map