@odla-ai/harness 0.6.0 → 0.7.0

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,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CODE_RUNTIME_PROTOCOL_VERSION,
4
- CodePiRuntimeEngine,
5
4
  CodeRuntimeReconciler,
5
+ TheseusRuntimeEngine,
6
6
  assertCodeBuildRecipe,
7
7
  createCodeRuntimeControlClient,
8
8
  runCodeRuntimeHeartbeatLoop
9
- } from "./chunk-ZYNGL5SC.js";
9
+ } from "./chunk-QZXCQSPZ.js";
10
10
  import {
11
11
  assertPinnedImage,
12
12
  selectContainerEngine
@@ -85,8 +85,8 @@ async function main() {
85
85
  };
86
86
  const controller = new AbortController();
87
87
  for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => controller.abort(signal));
88
- const control = createCodeRuntimeControlClient({ endpoint: options.endpoint, token, signal: controller.signal });
89
- const commandEngine = new CodePiRuntimeEngine({
88
+ const control = createCodeRuntimeControlClient({ endpoint: options.endpoint, token });
89
+ const commandEngine = new TheseusRuntimeEngine({
90
90
  control,
91
91
  engine,
92
92
  recipes: policy.recipes,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/code-runtime-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { cpus, totalmem } from \"node:os\";\nimport { readFile } from \"node:fs/promises\";\nimport {\n CODE_RUNTIME_PROTOCOL_VERSION,\n CodeRuntimeReconciler,\n createCodeRuntimeControlClient,\n runCodeRuntimeHeartbeatLoop,\n type CodeRuntimeCapabilities,\n} from \"./code-runtime\";\nimport { CodePiRuntimeEngine } from \"./code-runtime-engine\";\nimport { assertPinnedImage, selectContainerEngine, type ContainerEngine } from \"./container\";\nimport { assertCodeBuildRecipe } from \"./recipe-container\";\nimport type { CodeBuildRecipe } from \"./code-tool-types\";\n\nconst VERSION = \"0.1.0\";\n\nfunction usage(): string {\n return `Usage:\n ODLA_CODE_HOST_TOKEN=odla_code_host_... odla-code-runtime \\\\\n --endpoint https://odla.ai --image registry/odla-pi@sha256:... \\\\\n --build-policy ./odla-code-build.json [--engine auto|container|podman|docker] [--once]\n\nThe host token is read only from ODLA_CODE_HOST_TOKEN. The runtime makes\noutbound HTTPS heartbeats and never opens a listener.`;\n}\n\nfunction parse(argv: string[]): {\n endpoint: string; engine: ContainerEngine | \"auto\"; image: string;\n buildPolicy: string; heartbeatMs: number; once: boolean;\n} {\n const values = new Map<string, string>();\n const flags = new Set<string>();\n for (let index = 0; index < argv.length; index++) {\n const arg = argv[index]!;\n if (arg === \"--once\") { flags.add(arg); continue; }\n if (!arg.startsWith(\"--\") || !argv[index + 1]) throw new TypeError(usage());\n values.set(arg, argv[++index]!);\n }\n const endpoint = values.get(\"--endpoint\");\n const image = values.get(\"--image\");\n const buildPolicy = values.get(\"--build-policy\");\n const engine = values.get(\"--engine\") ?? \"auto\";\n const heartbeatMs = Number(values.get(\"--heartbeat-ms\") ?? 15_000);\n if (!endpoint || !image || !buildPolicy || ![\"auto\", \"container\", \"podman\", \"docker\"].includes(engine)) {\n throw new TypeError(usage());\n }\n assertPinnedImage(image);\n if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1_000 || heartbeatMs > 300_000) {\n throw new TypeError(\"--heartbeat-ms must be an integer from 1000 to 300000\");\n }\n return { endpoint, image, buildPolicy, engine: engine as ContainerEngine | \"auto\",\n heartbeatMs, once: flags.has(\"--once\") };\n}\n\nasync function readPolicy(path: string): Promise<{\n recipes: CodeBuildRecipe[]; recipeAuthorization: \"registered_recipe\" | \"exact_approval\";\n}> {\n const value = JSON.parse(await readFile(path, \"utf8\")) as Record<string, unknown>;\n if (!value || Object.keys(value).some((key) => ![\"recipes\", \"recipeAuthorization\"].includes(key))\n || !Array.isArray(value.recipes) || !value.recipes.length\n || (value.recipeAuthorization !== undefined && value.recipeAuthorization !== \"registered_recipe\"\n && value.recipeAuthorization !== \"exact_approval\")) throw new TypeError(\"invalid Code build policy file\");\n const recipes = value.recipes as CodeBuildRecipe[];\n for (const recipe of recipes) assertCodeBuildRecipe(recipe);\n const recipeAuthorization = value.recipeAuthorization === \"exact_approval\"\n ? \"exact_approval\" : \"registered_recipe\";\n return { recipes, recipeAuthorization };\n}\n\nasync function main(): Promise<void> {\n const token = process.env.ODLA_CODE_HOST_TOKEN;\n if (!token) throw new TypeError(\"ODLA_CODE_HOST_TOKEN is required\");\n const options = parse(process.argv.slice(2));\n if (process.platform !== \"darwin\" && process.platform !== \"linux\") throw new TypeError(\"Code runtime requires macOS or Linux\");\n const engine = await selectContainerEngine(options.engine);\n const policy = await readPolicy(options.buildPolicy);\n const capabilities: CodeRuntimeCapabilities = {\n protocolVersion: CODE_RUNTIME_PROTOCOL_VERSION,\n platform: process.platform === \"darwin\" ? \"macos\" : \"linux\",\n arch: process.arch,\n engines: [engine],\n cpuCount: cpus().length,\n memoryBytes: totalmem(),\n };\n const controller = new AbortController();\n for (const signal of [\"SIGINT\", \"SIGTERM\"] as const) process.once(signal, () => controller.abort(signal));\n const control = createCodeRuntimeControlClient({ endpoint: options.endpoint, token, signal: controller.signal });\n const commandEngine = new CodePiRuntimeEngine({\n control, engine, recipes: policy.recipes,\n recipeAuthorization: policy.recipeAuthorization,\n onDiagnostic: (message) => process.stderr.write(`[odla-code-runtime] agent failed · ${message}\\n`),\n });\n const reconciler = new CodeRuntimeReconciler(control, commandEngine);\n try {\n await runCodeRuntimeHeartbeatLoop({\n control, runtimeVersion: VERSION, capabilities, heartbeatMs: options.heartbeatMs,\n once: options.once, signal: controller.signal,\n onSnapshot: async (snapshot) => {\n process.stderr.write(\n `[odla-code-runtime] host ${snapshot.host.hostId} online · ${snapshot.bindings.length} active binding(s) · ${snapshot.commands.length} command(s)\\n`,\n );\n if (options.once && snapshot.commands.length) {\n throw new TypeError(\"--once is diagnostic-only and refuses pending Code commands\");\n }\n await reconciler.reconcile(snapshot);\n },\n onRetry: (error, delayMs) => {\n process.stderr.write(\n `[odla-code-runtime] control plane unavailable; retrying in ${delayMs}ms · ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n },\n });\n } finally { await commandEngine.close(); }\n}\n\nmain().catch((error) => {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AACA,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AAazB,IAAM,UAAU;AAEhB,SAAS,QAAgB;AACvB,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOT;AAEA,SAAS,MAAM,MAGb;AACA,QAAM,SAAS,oBAAI,IAAoB;AACvC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,WAAS,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;AAChD,UAAM,MAAM,KAAK,KAAK;AACtB,QAAI,QAAQ,UAAU;AAAE,YAAM,IAAI,GAAG;AAAG;AAAA,IAAU;AAClD,QAAI,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,KAAK,QAAQ,CAAC,EAAG,OAAM,IAAI,UAAU,MAAM,CAAC;AAC1E,WAAO,IAAI,KAAK,KAAK,EAAE,KAAK,CAAE;AAAA,EAChC;AACA,QAAM,WAAW,OAAO,IAAI,YAAY;AACxC,QAAM,QAAQ,OAAO,IAAI,SAAS;AAClC,QAAM,cAAc,OAAO,IAAI,gBAAgB;AAC/C,QAAM,SAAS,OAAO,IAAI,UAAU,KAAK;AACzC,QAAM,cAAc,OAAO,OAAO,IAAI,gBAAgB,KAAK,IAAM;AACjE,MAAI,CAAC,YAAY,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,QAAQ,aAAa,UAAU,QAAQ,EAAE,SAAS,MAAM,GAAG;AACtG,UAAM,IAAI,UAAU,MAAM,CAAC;AAAA,EAC7B;AACA,oBAAkB,KAAK;AACvB,MAAI,CAAC,OAAO,cAAc,WAAW,KAAK,cAAc,OAAS,cAAc,KAAS;AACtF,UAAM,IAAI,UAAU,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AAI;AAClF,UAAQ,WAAW;AACrB,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/code-runtime-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { cpus, totalmem } from \"node:os\";\nimport { readFile } from \"node:fs/promises\";\nimport {\n CODE_RUNTIME_PROTOCOL_VERSION,\n CodeRuntimeReconciler,\n createCodeRuntimeControlClient,\n runCodeRuntimeHeartbeatLoop,\n type CodeRuntimeCapabilities,\n} from \"./code-runtime\";\nimport { TheseusRuntimeEngine } from \"./code-runtime-engine\";\nimport { assertPinnedImage, selectContainerEngine, type ContainerEngine } from \"./container\";\nimport { assertCodeBuildRecipe } from \"./recipe-container\";\nimport type { CodeBuildRecipe } from \"./code-tool-types\";\n\nconst VERSION = \"0.1.0\";\n\nfunction usage(): string {\n return `Usage:\n ODLA_CODE_HOST_TOKEN=odla_code_host_... odla-code-runtime \\\\\n --endpoint https://odla.ai --image registry/odla-pi@sha256:... \\\\\n --build-policy ./odla-code-build.json [--engine auto|container|podman|docker] [--once]\n\nThe host token is read only from ODLA_CODE_HOST_TOKEN. The runtime makes\noutbound HTTPS heartbeats and never opens a listener.`;\n}\n\nfunction parse(argv: string[]): {\n endpoint: string; engine: ContainerEngine | \"auto\"; image: string;\n buildPolicy: string; heartbeatMs: number; once: boolean;\n} {\n const values = new Map<string, string>();\n const flags = new Set<string>();\n for (let index = 0; index < argv.length; index++) {\n const arg = argv[index]!;\n if (arg === \"--once\") { flags.add(arg); continue; }\n if (!arg.startsWith(\"--\") || !argv[index + 1]) throw new TypeError(usage());\n values.set(arg, argv[++index]!);\n }\n const endpoint = values.get(\"--endpoint\");\n const image = values.get(\"--image\");\n const buildPolicy = values.get(\"--build-policy\");\n const engine = values.get(\"--engine\") ?? \"auto\";\n const heartbeatMs = Number(values.get(\"--heartbeat-ms\") ?? 15_000);\n if (!endpoint || !image || !buildPolicy || ![\"auto\", \"container\", \"podman\", \"docker\"].includes(engine)) {\n throw new TypeError(usage());\n }\n assertPinnedImage(image);\n if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1_000 || heartbeatMs > 300_000) {\n throw new TypeError(\"--heartbeat-ms must be an integer from 1000 to 300000\");\n }\n return { endpoint, image, buildPolicy, engine: engine as ContainerEngine | \"auto\",\n heartbeatMs, once: flags.has(\"--once\") };\n}\n\nasync function readPolicy(path: string): Promise<{\n recipes: CodeBuildRecipe[]; recipeAuthorization: \"registered_recipe\" | \"exact_approval\";\n}> {\n const value = JSON.parse(await readFile(path, \"utf8\")) as Record<string, unknown>;\n if (!value || Object.keys(value).some((key) => ![\"recipes\", \"recipeAuthorization\"].includes(key))\n || !Array.isArray(value.recipes) || !value.recipes.length\n || (value.recipeAuthorization !== undefined && value.recipeAuthorization !== \"registered_recipe\"\n && value.recipeAuthorization !== \"exact_approval\")) throw new TypeError(\"invalid Code build policy file\");\n const recipes = value.recipes as CodeBuildRecipe[];\n for (const recipe of recipes) assertCodeBuildRecipe(recipe);\n const recipeAuthorization = value.recipeAuthorization === \"exact_approval\"\n ? \"exact_approval\" : \"registered_recipe\";\n return { recipes, recipeAuthorization };\n}\n\nasync function main(): Promise<void> {\n const token = process.env.ODLA_CODE_HOST_TOKEN;\n if (!token) throw new TypeError(\"ODLA_CODE_HOST_TOKEN is required\");\n const options = parse(process.argv.slice(2));\n if (process.platform !== \"darwin\" && process.platform !== \"linux\") throw new TypeError(\"Code runtime requires macOS or Linux\");\n const engine = await selectContainerEngine(options.engine);\n const policy = await readPolicy(options.buildPolicy);\n const capabilities: CodeRuntimeCapabilities = {\n protocolVersion: CODE_RUNTIME_PROTOCOL_VERSION,\n platform: process.platform === \"darwin\" ? \"macos\" : \"linux\",\n arch: process.arch,\n engines: [engine],\n cpuCount: cpus().length,\n memoryBytes: totalmem(),\n };\n const controller = new AbortController();\n for (const signal of [\"SIGINT\", \"SIGTERM\"] as const) process.once(signal, () => controller.abort(signal));\n // The heartbeat stops on the process signal, but the client must remain able\n // to report the active attempt's terminal events during engine.close().\n const control = createCodeRuntimeControlClient({ endpoint: options.endpoint, token });\n const commandEngine = new TheseusRuntimeEngine({\n control, engine, recipes: policy.recipes,\n recipeAuthorization: policy.recipeAuthorization,\n onDiagnostic: (message) => process.stderr.write(`[odla-code-runtime] agent failed · ${message}\\n`),\n });\n const reconciler = new CodeRuntimeReconciler(control, commandEngine);\n try {\n await runCodeRuntimeHeartbeatLoop({\n control, runtimeVersion: VERSION, capabilities, heartbeatMs: options.heartbeatMs,\n once: options.once, signal: controller.signal,\n onSnapshot: async (snapshot) => {\n process.stderr.write(\n `[odla-code-runtime] host ${snapshot.host.hostId} online · ${snapshot.bindings.length} active binding(s) · ${snapshot.commands.length} command(s)\\n`,\n );\n if (options.once && snapshot.commands.length) {\n throw new TypeError(\"--once is diagnostic-only and refuses pending Code commands\");\n }\n await reconciler.reconcile(snapshot);\n },\n onRetry: (error, delayMs) => {\n process.stderr.write(\n `[odla-code-runtime] control plane unavailable; retrying in ${delayMs}ms · ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n },\n });\n } finally { await commandEngine.close(); }\n}\n\nmain().catch((error) => {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AACA,SAAS,MAAM,gBAAgB;AAC/B,SAAS,gBAAgB;AAazB,IAAM,UAAU;AAEhB,SAAS,QAAgB;AACvB,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOT;AAEA,SAAS,MAAM,MAGb;AACA,QAAM,SAAS,oBAAI,IAAoB;AACvC,QAAM,QAAQ,oBAAI,IAAY;AAC9B,WAAS,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;AAChD,UAAM,MAAM,KAAK,KAAK;AACtB,QAAI,QAAQ,UAAU;AAAE,YAAM,IAAI,GAAG;AAAG;AAAA,IAAU;AAClD,QAAI,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,KAAK,QAAQ,CAAC,EAAG,OAAM,IAAI,UAAU,M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B,SAAS,SAAS,MAAM;AAAA;AAAA,QACvI;AACA,YAAI,QAAQ,QAAQ,SAAS,SAAS,QAAQ;AAC5C,gBAAM,IAAI,UAAU,6DAA6D;AAAA,QACnF;AACA,cAAM,WAAW,UAAU,QAAQ;AAAA,MACrC;AAAA,MACA,SAAS,CAAC,OAAO,YAAY;AAC3B,gBAAQ,OAAO;AAAA,UACb,8DAA8D,OAAO,WAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA;AAAA,QACrI;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH,UAAE;AAAU,UAAM,cAAc,MAAM;AAAA,EAAG;AAC3C;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAClF,UAAQ,WAAW;AACrB,CAAC;","names":[]}
package/dist/node.cjs CHANGED
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var node_exports = {};
22
22
  __export(node_exports, {
23
23
  CODE_RUNTIME_PROTOCOL_VERSION: () => CODE_RUNTIME_PROTOCOL_VERSION,
24
- CodePiRuntimeEngine: () => CodePiRuntimeEngine,
25
24
  CodeRuntimeCheckpointManager: () => CodeRuntimeCheckpointManager,
26
25
  CodeRuntimeControlError: () => CodeRuntimeControlError,
27
26
  CodeRuntimeReconciler: () => CodeRuntimeReconciler,
@@ -29,6 +28,7 @@ __export(node_exports, {
29
28
  MAX_MEMORY_BODY: () => MAX_MEMORY_BODY,
30
29
  MEASURED_PREMIUM: () => MEASURED_PREMIUM,
31
30
  SYSTEM_PROMPT_FOR: () => SYSTEM_PROMPT_FOR,
31
+ TheseusRuntimeEngine: () => TheseusRuntimeEngine,
32
32
  V1_SYSTEM_PROMPT: () => V1_SYSTEM_PROMPT,
33
33
  V2_SYSTEM_PROMPT: () => V2_SYSTEM_PROMPT,
34
34
  V3_SYSTEM_PROMPT: () => V3_SYSTEM_PROMPT,
@@ -1731,7 +1731,7 @@ var CodeRuntimeCheckpointManager = class {
1731
1731
  await this.options.event(command, { type: "message", actor: "system", body: prepared.note }, active.conversationRefs).catch(() => void 0);
1732
1732
  await active.workspace.cleanup();
1733
1733
  await this.options.event(command, { type: "status", status: "checkpointed" }, active.conversationRefs).catch(() => void 0);
1734
- return { status: "checkpointed", checkpoint: prepared.checkpoint, message: "Pi stopped at a portable checkpoint" };
1734
+ return { status: "checkpointed", checkpoint: prepared.checkpoint, message: "Theseus stopped at a portable checkpoint" };
1735
1735
  }
1736
1736
  async acknowledged(command, result) {
1737
1737
  if (command.kind !== "checkpoint_stop" || result.status !== "checkpointed") return false;
@@ -1973,7 +1973,7 @@ var import_ai2 = require("@odla-ai/ai");
1973
1973
  var import_ai = require("@odla-ai/ai");
1974
1974
 
1975
1975
  // src/code-agent-skill.ts
1976
- var V1_SYSTEM_PROMPT = `You are Pi, the coding agent inside an odla Code harness.
1976
+ var V1_SYSTEM_PROMPT = `You are Theseus, the coding agent inside an odla Code harness.
1977
1977
  Use only the odla_read, odla_apply_git_diff, and odla_run_recipe tools.
1978
1978
  For mutations, call odla_apply_git_diff with raw git diff text. It must start
1979
1979
  with "diff --git a/<path> b/<path>", include matching "---" and "+++" file
@@ -2056,11 +2056,17 @@ function codeSkill(opts) {
2056
2056
  };
2057
2057
  const runRecipe = {
2058
2058
  name: "odla_run_recipe",
2059
- description: "Run one app-registered build or test recipe through CaMeL policy.",
2059
+ description: `Run one app-registered build or test recipe through CaMeL policy.${opts.recipeIds?.length ? ` Available recipes: ${opts.recipeIds.join(", ")}.` : ""}`,
2060
2060
  inputSchema: {
2061
2061
  type: "object",
2062
2062
  required: ["recipeId"],
2063
- properties: { recipeId: { type: "string", minLength: 1, maxLength: 120, pattern: "^[a-zA-Z0-9._:-]+$" } },
2063
+ properties: { recipeId: {
2064
+ type: "string",
2065
+ minLength: 1,
2066
+ maxLength: 120,
2067
+ pattern: "^[a-zA-Z0-9._:-]+$",
2068
+ ...opts.recipeIds?.length ? { enum: [...opts.recipeIds] } : {}
2069
+ } },
2064
2070
  additionalProperties: false
2065
2071
  },
2066
2072
  handler: (input, ctx) => call("sandbox.run_recipe", input, ctx.signal)
@@ -2144,6 +2150,7 @@ async function runCodeAgent(options) {
2144
2150
  lease: options.lease,
2145
2151
  workspaceDir: options.workspaceDir,
2146
2152
  surface,
2153
+ ...options.recipeIds ? { recipeIds: options.recipeIds } : {},
2147
2154
  onToolCall: (call) => {
2148
2155
  toolCalls.push(call);
2149
2156
  options.onToolCall?.(call);
@@ -2174,7 +2181,7 @@ async function runCodeAgent(options) {
2174
2181
  // src/code-runtime-attempt.ts
2175
2182
  async function runCodeAgentAttempt(options) {
2176
2183
  try {
2177
- const surface = options.surface ?? "v2";
2184
+ const surface = options.surface ?? "v3";
2178
2185
  const { run } = await runCodeAgent({
2179
2186
  inference: options.inference,
2180
2187
  broker: options.broker,
@@ -2185,6 +2192,7 @@ async function runCodeAgentAttempt(options) {
2185
2192
  // id only labels the request the control plane is about to rewrite.
2186
2193
  model: "brokered",
2187
2194
  surface,
2195
+ ...options.recipeIds ? { recipeIds: options.recipeIds } : {},
2188
2196
  ...options.maxSteps === void 0 ? {} : { maxSteps: options.maxSteps },
2189
2197
  ...options.budget ? { budget: options.budget } : {},
2190
2198
  ...options.signal ? { signal: options.signal } : {},
@@ -3184,7 +3192,7 @@ var digestRuntimeValue = (value) => `sha256:${(0, import_node_crypto4.createHash
3184
3192
  var runtimeErrorMessage = (value) => value instanceof Error ? value.message : String(value);
3185
3193
 
3186
3194
  // src/code-runtime-engine.ts
3187
- var CodePiRuntimeEngine = class {
3195
+ var TheseusRuntimeEngine = class {
3188
3196
  constructor(options) {
3189
3197
  this.options = options;
3190
3198
  this.#attempt = options.runAgentAttempt ?? runCodeAgentAttempt;
@@ -3270,7 +3278,7 @@ var CodePiRuntimeEngine = class {
3270
3278
  await this.#failure(command, active, detail);
3271
3279
  return null;
3272
3280
  });
3273
- return { status: "running", message: resume ? "Pi resumed from a portable checkpoint" : "Pi started" };
3281
+ return { status: "running", message: resume ? "Theseus resumed from a portable checkpoint" : "Theseus started" };
3274
3282
  }
3275
3283
  /**
3276
3284
  * Pursue a goal: attempt, judge with the clean verifier, re-prompt from what
@@ -3358,7 +3366,7 @@ var CodePiRuntimeEngine = class {
3358
3366
  await this.#failure(command, active, detail);
3359
3367
  return null;
3360
3368
  });
3361
- return { status: "running", message: "Pi accepted the owner prompt" };
3369
+ return { status: "running", message: "Theseus accepted the owner prompt" };
3362
3370
  }
3363
3371
  async #runAttempt(command, metadata, active) {
3364
3372
  const lease = fakeCodeLease(command, metadata);
@@ -3383,7 +3391,8 @@ var CodePiRuntimeEngine = class {
3383
3391
  lease,
3384
3392
  workspaceDir: active.workspace.workspaceDir,
3385
3393
  prompt: metadata.prompt,
3386
- signal: active.abort.signal
3394
+ signal: active.abort.signal,
3395
+ recipeIds: this.options.recipes.map((recipe2) => recipe2.id)
3387
3396
  });
3388
3397
  const closing = result.finalText.trim();
3389
3398
  const completed = result.status === "completed" && Boolean(closing);
@@ -3447,7 +3456,7 @@ var CodePiRuntimeEngine = class {
3447
3456
  }
3448
3457
  }
3449
3458
  async #diagnostic(command, active, value) {
3450
- const detail = value.trim().slice(0, 2e3) || "Pi runtime failed";
3459
+ const detail = value.trim().slice(0, 2e3) || "Theseus runtime failed";
3451
3460
  this.options.onDiagnostic?.(detail);
3452
3461
  await this.#event(
3453
3462
  command,
@@ -3763,7 +3772,6 @@ async function installedDependencies(repoRoot) {
3763
3772
  // Annotate the CommonJS export names for ESM import in node:
3764
3773
  0 && (module.exports = {
3765
3774
  CODE_RUNTIME_PROTOCOL_VERSION,
3766
- CodePiRuntimeEngine,
3767
3775
  CodeRuntimeCheckpointManager,
3768
3776
  CodeRuntimeControlError,
3769
3777
  CodeRuntimeReconciler,
@@ -3771,6 +3779,7 @@ async function installedDependencies(repoRoot) {
3771
3779
  MAX_MEMORY_BODY,
3772
3780
  MEASURED_PREMIUM,
3773
3781
  SYSTEM_PROMPT_FOR,
3782
+ TheseusRuntimeEngine,
3774
3783
  V1_SYSTEM_PROMPT,
3775
3784
  V2_SYSTEM_PROMPT,
3776
3785
  V3_SYSTEM_PROMPT,