fascicle 0.17.7 → 0.18.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +25 -2
  3. package/dist/AGENTS.md +23 -11
  4. package/dist/acp.d.ts +3 -17
  5. package/dist/acp.js +25 -44
  6. package/dist/acp.js.map +1 -1
  7. package/dist/{adapters-CDUzZlby.js → adapters-CpKpDk7r.js} +9 -17
  8. package/dist/{adapters-CDUzZlby.js.map → adapters-CpKpDk7r.js.map} +1 -1
  9. package/dist/adapters.d.ts +1 -13
  10. package/dist/adapters.js +1 -1
  11. package/dist/agents.d.ts +3 -5
  12. package/dist/agents.js +2 -3
  13. package/dist/{console-CdB4pcFO.js → console-B1ozi_ii.js} +2 -3
  14. package/dist/{console-CdB4pcFO.js.map → console-B1ozi_ii.js.map} +1 -1
  15. package/dist/{core-Bfzt55Fl.js → core-BH7sWpEG.js} +34 -66
  16. package/dist/{core-Bfzt55Fl.js.map → core-BH7sWpEG.js.map} +1 -1
  17. package/dist/diagram_bin.d.ts +0 -2
  18. package/dist/diagram_bin.js +3 -5
  19. package/dist/diagram_bin.js.map +1 -1
  20. package/dist/{engine-B5iQ3if9.js → engine-fOjYHcv6.js} +302 -98
  21. package/dist/engine-fOjYHcv6.js.map +1 -0
  22. package/dist/index.d.ts +4 -98
  23. package/dist/index.js +27 -47
  24. package/dist/index.js.map +1 -1
  25. package/dist/{invoke-DnmWf8gE.js → invoke-7iu8db6V.js} +19 -12
  26. package/dist/{invoke-DnmWf8gE.js.map → invoke-7iu8db6V.js.map} +1 -1
  27. package/dist/{json_schema_to_standard-C4F4lXHE.js → json_schema_to_standard-BstoXjM8.js} +3 -4
  28. package/dist/{json_schema_to_standard-C4F4lXHE.js.map → json_schema_to_standard-BstoXjM8.js.map} +1 -1
  29. package/dist/{leading_system-CHSYz0h9.js → leading_system-BeQUSAim.js} +6 -10
  30. package/dist/{leading_system-CHSYz0h9.js.map → leading_system-BeQUSAim.js.map} +1 -1
  31. package/dist/{mcp-8mKK7eDY.js → mcp-CHJ88HiG.js} +9 -14
  32. package/dist/{mcp-8mKK7eDY.js.map → mcp-CHJ88HiG.js.map} +1 -1
  33. package/dist/mcp.d.ts +3 -11
  34. package/dist/mcp.js +2 -2
  35. package/dist/otel.d.ts +1 -5
  36. package/dist/otel.js +3 -6
  37. package/dist/otel.js.map +1 -1
  38. package/dist/{records-1HU7mWXf.js → records-Btlmvunj.js} +2 -3
  39. package/dist/{records-1HU7mWXf.js.map → records-Btlmvunj.js.map} +1 -1
  40. package/dist/{search-DjhdMsJ8.js → search-BZagxXtd.js} +7 -11
  41. package/dist/{search-DjhdMsJ8.js.map → search-BZagxXtd.js.map} +1 -1
  42. package/dist/search_worker.js +2 -3
  43. package/dist/stdio.d.ts +2 -6
  44. package/dist/stdio.js +5 -7
  45. package/dist/stdio.js.map +1 -1
  46. package/dist/testing.d.ts +2 -18
  47. package/dist/testing.js +12 -21
  48. package/dist/testing.js.map +1 -1
  49. package/dist/{trajectory-DeURWIhj.js → trajectory-CkCFZWNR.js} +2 -3
  50. package/dist/{trajectory-DeURWIhj.js.map → trajectory-CkCFZWNR.js.map} +1 -1
  51. package/dist/{trajectory-BKGNxi7u.d.ts → trajectory-Dt0-A7kb.d.ts} +1 -3
  52. package/dist/{types-CPqLZOEr.d.ts → types-BUXt_zgJ.d.ts} +1 -3
  53. package/dist/{types-BK0UW28o.d.ts → types-CvghbZ0x.d.ts} +1 -5
  54. package/dist/{types-xYjCEd6i.d.ts → types-Dk9tLpUq.d.ts} +42 -9
  55. package/dist/ui.d.ts +1 -3
  56. package/dist/ui.js +1 -2
  57. package/dist/viewer-app/assets/index-D8Tb3drm.js +4 -0
  58. package/dist/viewer-app/index.html +1 -1
  59. package/dist/viewer.d.ts +1 -11
  60. package/dist/viewer.js +8 -14
  61. package/dist/viewer.js.map +1 -1
  62. package/dist/web.d.ts +83 -0
  63. package/dist/web.js +2888 -0
  64. package/dist/web.js.map +1 -0
  65. package/package.json +34 -28
  66. package/dist/engine-B5iQ3if9.js.map +0 -1
  67. package/dist/viewer-app/assets/index-YrQFld-l.js +0 -4
@@ -1,11 +1,11 @@
1
- import { C as validate_schema, D as wait_with_abort, E as compute_backoff, S as format_schema_issues, T as failure_meta, j as aborted_error } from "./core-Bfzt55Fl.js";
2
- import { n as is_record$1 } from "./records-1HU7mWXf.js";
3
- import { A as provider_auth_error, C as translate_effort_to_sdk_reasoning, D as incomplete_generation_error, E as engine_disposed_error, F as rate_limit_error, I as schema_validation_error, L as tool_approval_denied_error, M as provider_error, N as provider_not_configured_error, O as model_required_error, P as provider_required_error, R as tool_error, S as resolve_transport, T as engine_config_error, _ as load_optional_peer, a as invoke_http_turn, b as normalize_local_usage, c as network_detail, d as parse_tool_call_arguments, f as protocol_error, g as default_normalize_usage, h as unreachable_message, i as error_body_message, j as provider_capability_error, k as on_chunk_error, l as network_failure, m as split_assistant_parts, n as consume_framed_stream, p as read_dialect_init, r as create_line_splitter, s as map_messages_by_role, t as split_leading_system_run, u as non_retryable_status_error, v as missing_config_error, w as claude_cli_error, x as refuse_credentials_in_base_url, y as missing_peer_error, z as turn_timeout_error } from "./leading_system-CHSYz0h9.js";
1
+ import { A as provider_auth_error, C as translate_effort_to_sdk_reasoning, D as incomplete_generation_error, E as engine_disposed_error, F as rate_limit_error, I as schema_validation_error, L as tool_approval_denied_error, M as provider_error, N as provider_not_configured_error, O as model_required_error, P as provider_required_error, R as tool_error, S as resolve_transport, T as engine_config_error, _ as load_optional_peer, a as invoke_http_turn, b as normalize_local_usage, c as network_detail, d as parse_tool_call_arguments, f as protocol_error, g as default_normalize_usage, h as unreachable_message, i as error_body_message, j as provider_capability_error, k as on_chunk_error, l as network_failure, m as split_assistant_parts, n as consume_framed_stream, p as read_dialect_init, r as create_line_splitter, s as map_messages_by_role, t as split_leading_system_run, u as non_retryable_status_error, v as missing_config_error, w as claude_cli_error, x as refuse_credentials_in_base_url, y as missing_peer_error, z as turn_timeout_error } from "./leading_system-BeQUSAim.js";
2
+ import { C as validate_schema, D as wait_with_abort, E as compute_backoff, S as format_schema_issues, T as failure_meta, j as aborted_error } from "./core-BH7sWpEG.js";
3
+ import { n as is_record$1 } from "./records-Btlmvunj.js";
4
4
  import { join } from "node:path";
5
5
  import { mkdtempSync, writeFileSync } from "node:fs";
6
6
  import { tmpdir } from "node:os";
7
7
  import { spawn } from "node:child_process";
8
- //#region src/schema/errors.ts
8
+ // src/schema/errors.ts
9
9
  /**
10
10
  * The one error this zone raises.
11
11
  *
@@ -21,8 +21,7 @@ var schema_not_convertible_error = class extends Error {
21
21
  this.vendor = vendor;
22
22
  }
23
23
  };
24
- //#endregion
25
- //#region src/schema/json_schema.ts
24
+ // src/schema/json_schema.ts
26
25
  /**
27
26
  * JSON Schema emission for schemas that reach a model.
28
27
  *
@@ -137,8 +136,7 @@ function strip_meta_keys(json) {
137
136
  const { $schema: _schema, $id: _id, ...rest } = json;
138
137
  return rest;
139
138
  }
140
- //#endregion
141
- //#region src/engine/pricing.ts
139
+ // src/engine/pricing.ts
142
140
  const FREE_PROVIDERS = /* @__PURE__ */ new Set(["ollama", "lmstudio"]);
143
141
  const CACHE_READ_MULTIPLIER = .1;
144
142
  const CACHE_WRITE_MULTIPLIER = 1.25;
@@ -411,8 +409,7 @@ function decompose_total_cost(total_cost_usd, usage) {
411
409
  if (cache_write > 0) breakdown.cache_write_usd = cache_write_usd_raw;
412
410
  return breakdown;
413
411
  }
414
- //#endregion
415
- //#region src/engine/retry.ts
412
+ // src/engine/retry.ts
416
413
  const DEFAULT_RETRY = {
417
414
  max_attempts: 4,
418
415
  initial_delay_ms: 1e3,
@@ -724,8 +721,7 @@ function classify_retryable$1(err) {
724
721
  retryable.cause = err instanceof Error ? err : Reflect.get(err, "cause");
725
722
  return retryable;
726
723
  }
727
- //#endregion
728
- //#region src/engine/providers/sse_native.ts
724
+ // src/engine/providers/sse_native.ts
729
725
  /**
730
726
  * Incremental SSE decoder shared by the native (raw-HTTP) provider adapters.
731
727
  */
@@ -759,8 +755,7 @@ function create_sse_decoder() {
759
755
  }
760
756
  }, close_event);
761
757
  }
762
- //#endregion
763
- //#region src/engine/providers/anthropic_native.ts
758
+ // src/engine/providers/anthropic_native.ts
764
759
  /**
765
760
  * Native Anthropic provider adapter (raw HTTP).
766
761
  *
@@ -1499,8 +1494,7 @@ const create_anthropic_native_adapter = (init) => {
1499
1494
  supports: (capability) => SUPPORTED$10.has(capability)
1500
1495
  };
1501
1496
  };
1502
- //#endregion
1503
- //#region src/engine/providers/anthropic.ts
1497
+ // src/engine/providers/anthropic.ts
1504
1498
  /**
1505
1499
  * Normalize Anthropic usage via the shared default mapper, since the AI SDK
1506
1500
  * already reports cache and reasoning tokens in the fields the default reads.
@@ -1588,8 +1582,7 @@ const create_anthropic_ai_sdk_adapter = (init) => {
1588
1582
  translate_cache: translate_anthropic_cache
1589
1583
  };
1590
1584
  };
1591
- //#endregion
1592
- //#region src/engine/providers/openai_compatible_native.ts
1585
+ // src/engine/providers/openai_compatible_native.ts
1593
1586
  /**
1594
1587
  * OpenAI-compatible native core: one `chat/completions` implementation
1595
1588
  * talking raw HTTP, shared by every OpenAI-compatible provider.
@@ -2249,8 +2242,7 @@ const create_openai_compatible_adapter = (dialect) => {
2249
2242
  supports: (capability) => SUPPORTED$8.has(capability)
2250
2243
  };
2251
2244
  };
2252
- //#endregion
2253
- //#region src/engine/providers/openai.ts
2245
+ // src/engine/providers/openai.ts
2254
2246
  /**
2255
2247
  * Normalize OpenAI's raw usage payload into UsageTotals.
2256
2248
  */
@@ -2331,8 +2323,7 @@ const create_openai_ai_sdk_adapter = (init) => {
2331
2323
  prompt_cache: "automatic"
2332
2324
  };
2333
2325
  };
2334
- //#endregion
2335
- //#region src/engine/providers/google.ts
2326
+ // src/engine/providers/google.ts
2336
2327
  /**
2337
2328
  * Normalize Google's raw usage payload into UsageTotals.
2338
2329
  */
@@ -2370,8 +2361,7 @@ const create_google_adapter = (init) => {
2370
2361
  prompt_cache: "automatic"
2371
2362
  };
2372
2363
  };
2373
- //#endregion
2374
- //#region src/engine/providers/ollama_native.ts
2364
+ // src/engine/providers/ollama_native.ts
2375
2365
  /**
2376
2366
  * Map user message content to a plain string, the shape this wire expects
2377
2367
  * (no part-array support). Image parts throw a capability error: they are
@@ -2720,8 +2710,7 @@ const create_ollama_native_adapter = (init) => {
2720
2710
  supports: (capability) => SUPPORTED$5.has(capability)
2721
2711
  };
2722
2712
  };
2723
- //#endregion
2724
- //#region src/engine/providers/ollama.ts
2713
+ // src/engine/providers/ollama.ts
2725
2714
  /**
2726
2715
  * Give a failure that `ai-sdk-ollama` raised the `url` and `statusCode` that
2727
2716
  * the AI SDK's own errors carry. The package wraps the `ollama` client's
@@ -2811,8 +2800,7 @@ const create_ollama_ai_sdk_adapter = (init) => {
2811
2800
  supports: (capability) => SUPPORTED$4.has(capability)
2812
2801
  };
2813
2802
  };
2814
- //#endregion
2815
- //#region src/engine/providers/lmstudio.ts
2803
+ // src/engine/providers/lmstudio.ts
2816
2804
  /**
2817
2805
  * LM Studio has no reasoning-effort control, so every non-`none` level is
2818
2806
  * reported as ignored and no provider option is emitted.
@@ -2886,8 +2874,7 @@ const create_lmstudio_ai_sdk_adapter = (init) => {
2886
2874
  supports: (capability) => SUPPORTED$3.has(capability)
2887
2875
  };
2888
2876
  };
2889
- //#endregion
2890
- //#region src/engine/providers/openrouter.ts
2877
+ // src/engine/providers/openrouter.ts
2891
2878
  /**
2892
2879
  * Map an EffortLevel to OpenRouter's `reasoning.effort` provider option.
2893
2880
  *
@@ -2997,8 +2984,7 @@ const create_openrouter_ai_sdk_adapter = (init) => {
2997
2984
  supports: (capability) => SUPPORTED$2.has(capability)
2998
2985
  };
2999
2986
  };
3000
- //#endregion
3001
- //#region src/engine/providers/bedrock.ts
2987
+ // src/engine/providers/bedrock.ts
3002
2988
  /**
3003
2989
  * Normalize Bedrock's raw usage payload into UsageTotals.
3004
2990
  */
@@ -3098,8 +3084,7 @@ const create_bedrock_adapter = (init) => {
3098
3084
  supports: (capability) => SUPPORTED$1.has(capability)
3099
3085
  };
3100
3086
  };
3101
- //#endregion
3102
- //#region src/engine/providers/claude_cli/constants.ts
3087
+ // src/engine/providers/claude_cli/constants.ts
3103
3088
  /**
3104
3089
  * Frozen constants for the claude_cli provider: startup and idle defaults,
3105
3090
  * the escalation window, and the auth failure pattern list.
@@ -3121,9 +3106,25 @@ const CLI_AUTH_ERROR_PATTERNS = Object.freeze([
3121
3106
  * names and its `refresh_command` carries.
3122
3107
  */
3123
3108
  const CLI_REFRESH_COMMAND = "claude auth login";
3109
+ /**
3110
+ * The variable that runs the CLI in bare mode, the same as passing `--bare`.
3111
+ * Bare mode never reads the CLI's login, so an `oauth` call scrubs it.
3112
+ */
3113
+ const CLI_BARE_MODE_ENV = "CLAUDE_CODE_SIMPLE";
3114
+ /**
3115
+ * The oldest Claude Code that honors every key the `claude_code` sandbox
3116
+ * renders, as `[major, minor, patch]`. 2.1.314 added
3117
+ * `blockWritesOutsideWorkingDirectories`, the newest of them, and an older
3118
+ * CLI drops a key it doesn't know without a word, which would leave the
3119
+ * file tools unconfined.
3120
+ */
3121
+ const CLAUDE_CODE_SANDBOX_MIN_VERSION = Object.freeze([
3122
+ 2,
3123
+ 1,
3124
+ 314
3125
+ ]);
3124
3126
  const DEFAULT_SETTING_SOURCES = Object.freeze(["project", "local"]);
3125
- //#endregion
3126
- //#region src/engine/providers/claude_cli/auth.ts
3127
+ // src/engine/providers/claude_cli/auth.ts
3127
3128
  /**
3128
3129
  * Authentication enforcement for the claude_cli adapter.
3129
3130
  *
@@ -3191,13 +3192,15 @@ function seed_base_env(config, auth_mode) {
3191
3192
  }
3192
3193
  /**
3193
3194
  * Apply the auth-mode scrub last, after base and caller env are merged, so
3194
- * nothing can re-introduce `ANTHROPIC_API_KEY` under `'oauth'`. `'api_key'`
3195
+ * nothing can re-introduce `ANTHROPIC_API_KEY` under `'oauth'`, or the
3196
+ * bare-mode variable that would stop the CLI reading its login. `'api_key'`
3195
3197
  * forces the configured key (empty string when absent); `'auto'` forwards a
3196
3198
  * non-empty configured key and otherwise leaves the inherited env untouched.
3197
3199
  */
3198
3200
  function apply_auth_key(env, config, auth_mode) {
3199
3201
  if (auth_mode === "oauth") {
3200
3202
  delete env["ANTHROPIC_API_KEY"];
3203
+ delete env[CLI_BARE_MODE_ENV];
3201
3204
  return;
3202
3205
  }
3203
3206
  if (auth_mode === "api_key") {
@@ -3220,8 +3223,9 @@ function apply_auth_key(env, config, auth_mode) {
3220
3223
  * session-specific vars to reach the already-logged-in OAuth session.
3221
3224
  * `omit_env` drops its names after the caller overrides are merged in, so a
3222
3225
  * call can't hand back a variable the provider keeps out. The auth-mode
3223
- * scrub runs last, so nothing can re-introduce `ANTHROPIC_API_KEY` under
3224
- * `'oauth'`, and a configured `api_key` still reaches the CLI.
3226
+ * scrub runs last, so nothing can re-introduce `ANTHROPIC_API_KEY` or
3227
+ * `CLAUDE_CODE_SIMPLE` under `'oauth'`, and a configured `api_key` still
3228
+ * reaches the CLI.
3225
3229
  */
3226
3230
  function build_env(config, caller_env, auth_mode) {
3227
3231
  const env = seed_base_env(config, auth_mode);
@@ -3243,8 +3247,111 @@ function stderr_is_auth_failure(stderr) {
3243
3247
  for (const pattern of CLI_AUTH_ERROR_PATTERNS) if (lower.includes(pattern.toLowerCase())) return true;
3244
3248
  return false;
3245
3249
  }
3246
- //#endregion
3247
- //#region src/engine/providers/claude_cli/argv.ts
3250
+ // src/engine/providers/claude_cli/settings.ts
3251
+ /**
3252
+ * Claude Code's own sandbox for the claude_cli adapter.
3253
+ *
3254
+ * A `claude_code` sandbox needs no wrapper around the binary. The CLI
3255
+ * enforces it from the JSON that `build_cli_argv` passes inline with
3256
+ * `--settings`, and this module renders that JSON and checks the policy
3257
+ * before any run.
3258
+ *
3259
+ * The sandbox confines Bash and nothing else: Claude's file tools, hooks,
3260
+ * and MCP servers run in the unsandboxed CLI process. So the policy pairs
3261
+ * the sandbox with the permission keys that keep the file tools inside the
3262
+ * working directories, and turns hooks off.
3263
+ */
3264
+ /**
3265
+ * Drop the trailing slashes from a path that's longer than its prefix, so
3266
+ * `~/.ssh/` and `~/.ssh` render the same rules.
3267
+ */
3268
+ function trim_path(path) {
3269
+ return path.length > 2 ? path.replace(/\/+$/, "") : path;
3270
+ }
3271
+ /**
3272
+ * The permission rules that keep the file tools off one denied path and
3273
+ * everything under it. A permission rule spells an absolute path with a
3274
+ * leading `//`, where the sandbox's own lists take a single `/`.
3275
+ */
3276
+ function read_deny_rules(path) {
3277
+ const rule_path = path.startsWith("~/") ? path : `/${path}`;
3278
+ return [`Read(${rule_path})`, `Read(${rule_path}/**)`];
3279
+ }
3280
+ /**
3281
+ * Throw `engine_config_error` when a `claude_code` sandbox names a path that
3282
+ * isn't absolute or under `~/`.
3283
+ *
3284
+ * Claude Code resolves a relative path against a different directory in
3285
+ * each of its lists, and against none that's documented when the settings
3286
+ * arrive inline, so the policy takes only paths that read the same
3287
+ * everywhere. Runs at adapter construction, before anything spawns.
3288
+ */
3289
+ function validate_sandbox_config(config) {
3290
+ const sandbox = config.sandbox;
3291
+ if (sandbox?.kind !== "claude_code") return;
3292
+ const relative = [
3293
+ ...sandbox.additional_write_paths ?? [],
3294
+ ...sandbox.additional_read_paths ?? [],
3295
+ ...sandbox.deny_read_paths ?? []
3296
+ ].filter((p) => !p.startsWith("/") && !p.startsWith("~/"));
3297
+ if (relative.length > 0) throw new engine_config_error(`providers.claude_cli.sandbox has relative paths (${relative.join(", ")}): make each one absolute or start it with ~/, since Claude Code resolves a relative path differently in each list`, "claude_cli");
3298
+ }
3299
+ /**
3300
+ * Throw `engine_config_error` when a call's `extra_args` carries its own
3301
+ * `--settings` under a `claude_code` sandbox.
3302
+ *
3303
+ * The sandbox travels as `--settings`, and a second one would replace or
3304
+ * merge with it in ways the CLI doesn't document, so the call is refused
3305
+ * instead of running with a policy nobody wrote.
3306
+ */
3307
+ function validate_sandbox_extra_args(sandbox, extra_args) {
3308
+ if (sandbox?.kind !== "claude_code") return;
3309
+ if ((extra_args ?? []).some((arg) => arg === "--settings" || arg.startsWith("--settings="))) throw new engine_config_error("extra_args can't carry --settings under a claude_code sandbox, because the sandbox is passed as --settings: drop it from extra_args, or leave the sandbox off this provider", "claude_cli");
3310
+ }
3311
+ /**
3312
+ * Render a `claude_code` sandbox as the JSON that the CLI takes inline with
3313
+ * `--settings`.
3314
+ *
3315
+ * - `failIfUnavailable` makes the CLI exit at startup when its sandbox
3316
+ * can't start, instead of running Bash unconfined.
3317
+ * - `allowUnsandboxedCommands: false` arriving through `--settings` makes
3318
+ * the sandbox admin-required, so a repo's own settings can't loosen it.
3319
+ * - `autoAllowBashIfSandboxed: false` leaves the call's allowlist deciding
3320
+ * whether Bash runs at all, rather than the sandbox approving it.
3321
+ * - `strictAllowlist` refuses a host off the list rather than asking for it.
3322
+ * - The two `permissions` blocks hold the file tools inside the working
3323
+ * directories in every permission mode, and the Read deny rules keep them
3324
+ * off the denied paths too.
3325
+ * - `disableAllHooks` turns hooks off, because they run outside the sandbox
3326
+ * and `-p` runs a project's hooks without asking.
3327
+ */
3328
+ function render_sandbox_settings(sandbox) {
3329
+ const deny_paths = (sandbox.deny_read_paths ?? []).map(trim_path);
3330
+ return JSON.stringify({
3331
+ sandbox: {
3332
+ enabled: true,
3333
+ failIfUnavailable: true,
3334
+ allowUnsandboxedCommands: false,
3335
+ autoAllowBashIfSandboxed: false,
3336
+ network: {
3337
+ allowedDomains: [...sandbox.network_allowlist ?? []],
3338
+ strictAllowlist: true
3339
+ },
3340
+ filesystem: {
3341
+ allowWrite: (sandbox.additional_write_paths ?? []).map(trim_path),
3342
+ allowRead: (sandbox.additional_read_paths ?? []).map(trim_path),
3343
+ denyRead: deny_paths
3344
+ }
3345
+ },
3346
+ permissions: {
3347
+ blockReadsOutsideWorkingDirectories: true,
3348
+ blockWritesOutsideWorkingDirectories: true,
3349
+ deny: deny_paths.flatMap(read_deny_rules)
3350
+ },
3351
+ disableAllHooks: true
3352
+ });
3353
+ }
3354
+ // src/engine/providers/claude_cli/argv.ts
3248
3355
  /**
3249
3356
  * Assemble the full argv array for one `claude` CLI invocation.
3250
3357
  *
@@ -3262,6 +3369,7 @@ function build_cli_argv(input) {
3262
3369
  args.push("--verbose");
3263
3370
  const setting_sources = input.provider_config.setting_sources ?? DEFAULT_SETTING_SOURCES;
3264
3371
  args.push("--setting-sources", setting_sources.join(","));
3372
+ args.push(...sandbox_args(input.provider_config));
3265
3373
  for (const tool of input.merged_allowed_tools) args.push("--allowedTools", tool);
3266
3374
  if (typeof input.call_opts.session_id === "string" && input.call_opts.session_id.length > 0) args.push("--resume", input.call_opts.session_id);
3267
3375
  if (input.call_opts.agents !== void 0) args.push("--agents", JSON.stringify(input.call_opts.agents));
@@ -3274,6 +3382,21 @@ function build_cli_argv(input) {
3274
3382
  return Object.freeze(args);
3275
3383
  }
3276
3384
  /**
3385
+ * The flags that a `claude_code` sandbox adds: its policy as `--settings`,
3386
+ * and `--strict-mcp-config`, since MCP servers run outside the sandbox and
3387
+ * the strict flag starts only the ones a caller names with `--mcp-config`,
3388
+ * never a repo's `.mcp.json`. Any other sandbox adds none.
3389
+ */
3390
+ function sandbox_args(config) {
3391
+ const sandbox = config.sandbox;
3392
+ if (sandbox?.kind !== "claude_code") return [];
3393
+ return [
3394
+ "--settings",
3395
+ render_sandbox_settings(sandbox),
3396
+ "--strict-mcp-config"
3397
+ ];
3398
+ }
3399
+ /**
3277
3400
  * Join the caller's `system` prompt and the `append_system_prompt` call
3278
3401
  * option into the single string passed to `--append-system-prompt`.
3279
3402
  *
@@ -3302,18 +3425,21 @@ function merge_allowed_tools(call_allowlist, tool_names) {
3302
3425
  for (const n of tool_names) push_unique(n);
3303
3426
  return merged;
3304
3427
  }
3305
- //#endregion
3306
- //#region src/engine/providers/claude_cli/sandbox.ts
3428
+ // src/engine/providers/claude_cli/sandbox.ts
3307
3429
  /**
3308
3430
  * Sandbox wrapper for the claude_cli adapter.
3309
3431
  *
3310
- * Builds the `{ spawn_cmd, prefix_args }` pair for bwrap and greywall. When
3311
- * no sandbox is configured, returns `{ spawn_cmd: binary, prefix_args: [] }`;
3312
- * the caller then concatenates prefix_args before the CLI argv.
3432
+ * Builds the `{ spawn_cmd, prefix_args }` pair for the deprecated bwrap and
3433
+ * greywall wrappers. With no sandbox, or a `claude_code` one, which the CLI
3434
+ * enforces itself from `--settings` (see `settings.ts`), it returns
3435
+ * `{ spawn_cmd: binary, prefix_args: [] }`; the caller then concatenates
3436
+ * prefix_args before the CLI argv.
3313
3437
  *
3314
- * Both wrappers allow the binary to execute while restricting network reach
3315
- * to the allowlist and write access to additional paths on top of the
3316
- * sandbox's default-read-only filesystem.
3438
+ * Both wrappers let the binary run with write access to additional paths on
3439
+ * top of the sandbox's default-read-only filesystem. Neither enforces
3440
+ * `network_allowlist`: bwrap shares the host network whenever the list is
3441
+ * non-empty, and greywall leaves host filtering to greyproxy, which nothing
3442
+ * here configures.
3317
3443
  *
3318
3444
  * greywall 0.3+ removed the `--allow-host` and `--rw` flags; policy now
3319
3445
  * lives in a JSON settings file passed via `--settings <path>`. Schema is
@@ -3333,10 +3459,10 @@ function merge_allowed_tools(call_allowlist, tool_names) {
3333
3459
  * Pick the sandbox wrapper (if any) and build its wrapping argv.
3334
3460
  *
3335
3461
  * Returns the unwrapped binary with no prefix args when `sandbox` is
3336
- * undefined.
3462
+ * undefined or a `claude_code` sandbox, which wraps nothing.
3337
3463
  */
3338
3464
  function build_sandbox_plan(binary, sandbox) {
3339
- if (sandbox === void 0) return {
3465
+ if (sandbox === void 0 || sandbox.kind === "claude_code") return {
3340
3466
  spawn_cmd: binary,
3341
3467
  prefix_args: []
3342
3468
  };
@@ -3414,8 +3540,7 @@ function write_greywall_settings(sandbox) {
3414
3540
  writeFileSync(path, JSON.stringify(payload, null, 2), "utf8");
3415
3541
  return path;
3416
3542
  }
3417
- //#endregion
3418
- //#region src/engine/providers/claude_cli/spawn.ts
3543
+ // src/engine/providers/claude_cli/spawn.ts
3419
3544
  /**
3420
3545
  * Subprocess lifecycle for the claude_cli adapter.
3421
3546
  *
@@ -3697,8 +3822,81 @@ async function* build_stdout_lines(child, on_data) {
3697
3822
  });
3698
3823
  }
3699
3824
  }
3700
- //#endregion
3701
- //#region src/engine/providers/claude_cli/stream_parse.ts
3825
+ // src/engine/providers/claude_cli/version.ts
3826
+ /**
3827
+ * Claude Code version gate for the `claude_code` sandbox.
3828
+ *
3829
+ * The sandbox's settings keys arrived over several Claude Code releases, and
3830
+ * the CLI drops a settings key it doesn't know without failing, so a run on
3831
+ * an older CLI would go ahead with part of its policy missing. The gate asks
3832
+ * the binary for its version before the first sandboxed call on each `PATH`,
3833
+ * and refuses a CLI older than `CLAUDE_CODE_SANDBOX_MIN_VERSION`.
3834
+ */
3835
+ /**
3836
+ * Read the `major.minor.patch` that `claude --version` prints first, as in
3837
+ * `2.1.316 (Claude Code)`. Returns `undefined` for anything else.
3838
+ */
3839
+ function parse_cli_version(text) {
3840
+ const match = /^\s*(\d+)\.(\d+)\.(\d+)/.exec(text);
3841
+ if (match === null) return void 0;
3842
+ return [
3843
+ Number(match[1]),
3844
+ Number(match[2]),
3845
+ Number(match[3])
3846
+ ];
3847
+ }
3848
+ /**
3849
+ * Whether `found` is the release `floor` names or a later one, comparing
3850
+ * major, then minor, then patch.
3851
+ */
3852
+ function version_at_least(found, floor) {
3853
+ const [major, minor, patch] = found;
3854
+ const [floor_major, floor_minor, floor_patch] = floor;
3855
+ if (major !== floor_major) return major > floor_major;
3856
+ if (minor !== floor_minor) return minor > floor_minor;
3857
+ return patch >= floor_patch;
3858
+ }
3859
+ /**
3860
+ * Run `<cmd> --version` once and throw `sandbox_unavailable` unless it
3861
+ * reports at least the floor.
3862
+ *
3863
+ * Output that doesn't lead with a version, or a nonzero exit, fails the same
3864
+ * way, since the gate can't vouch for a CLI it can't read.
3865
+ */
3866
+ async function check_cli_version(spawn_runtime, init, env, abort) {
3867
+ const session = await spawn_runtime.spawn_cli({
3868
+ ...init,
3869
+ argv: ["--version"],
3870
+ env,
3871
+ stdin: "",
3872
+ abort
3873
+ });
3874
+ const lines = [];
3875
+ for await (const line of session.stdout_lines) lines.push(line);
3876
+ const outcome = await session.wait_close();
3877
+ const output = lines.join("\n").trim();
3878
+ const found = outcome.code === 0 ? parse_cli_version(output) : void 0;
3879
+ const floor = CLAUDE_CODE_SANDBOX_MIN_VERSION.join(".");
3880
+ if (found === void 0) throw new claude_cli_error("sandbox_unavailable", `couldn't read a Claude Code version from '${init.cmd} --version' (exit ${String(outcome.code)}, output '${output.slice(0, 120)}'): the claude_code sandbox needs Claude Code ${floor} or later, so point providers.claude_cli.binary at a claude that prints one`, { stderr_snippet: outcome.stderr.slice(0, 512) });
3881
+ if (!version_at_least(found, CLAUDE_CODE_SANDBOX_MIN_VERSION)) throw new claude_cli_error("sandbox_unavailable", `Claude Code ${found.join(".")} is older than ${floor}, the first release that honors every setting the claude_code sandbox needs: run claude update, or point providers.claude_cli.binary at a newer claude`);
3882
+ }
3883
+ /**
3884
+ * Build the per-adapter gate. `ensure` checks the CLI the first time it sees
3885
+ * a call's `PATH`, because a bare binary name resolves against that `PATH`
3886
+ * and a call can pass its own, so a pass for one `PATH` says nothing about
3887
+ * the binary that another finds. It remembers only passes, so a CLI that's
3888
+ * updated after a failure passes on the next call.
3889
+ */
3890
+ function create_cli_version_gate(spawn_runtime, init) {
3891
+ const passed = /* @__PURE__ */ new Set();
3892
+ return { ensure: async (env, abort) => {
3893
+ const path = env["PATH"] ?? "";
3894
+ if (passed.has(path)) return;
3895
+ await check_cli_version(spawn_runtime, init, env, abort);
3896
+ passed.add(path);
3897
+ } };
3898
+ }
3899
+ // src/engine/providers/claude_cli/stream_parse.ts
3702
3900
  /** A non-null, non-array object: the shape every CLI event and sub-object takes. */
3703
3901
  function is_record(value) {
3704
3902
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -4209,8 +4407,7 @@ function snapshot(state) {
4209
4407
  if (state.api_error !== void 0) base.api_error = state.api_error;
4210
4408
  return base;
4211
4409
  }
4212
- //#endregion
4213
- //#region src/engine/providers/claude_cli/cost.ts
4410
+ // src/engine/providers/claude_cli/cost.ts
4214
4411
  /**
4215
4412
  * Cost allocation from the CLI's reported `total_cost_usd`.
4216
4413
  *
@@ -4253,8 +4450,7 @@ function allocate_cost_across_turns(total_cost_usd, turns) {
4253
4450
  const per_turn = split_total_across_turns(total_cost_usd, turns);
4254
4451
  return turns.map((t, i) => decompose_total_cost(per_turn[i] ?? 0, t.usage));
4255
4452
  }
4256
- //#endregion
4257
- //#region src/engine/providers/claude_cli/stream_result.ts
4453
+ // src/engine/providers/claude_cli/stream_result.ts
4258
4454
  /**
4259
4455
  * Sum a list of per-turn `UsageTotals` into one aggregate total.
4260
4456
  *
@@ -4459,8 +4655,7 @@ function build_generate_result(input) {
4459
4655
  if (Object.keys(provider_reported).length > 0) result.provider_reported = provider_reported;
4460
4656
  return result;
4461
4657
  }
4462
- //#endregion
4463
- //#region src/engine/schema.ts
4658
+ // src/engine/schema.ts
4464
4659
  /**
4465
4660
  * Schema parse and repair helpers.
4466
4661
  *
@@ -4577,8 +4772,7 @@ function build_repair_prompt_text(issues) {
4577
4772
  function throw_schema_validation(issues, raw_text) {
4578
4773
  throw new schema_validation_error(`schema validation failed: ${format_schema_issues(issues)}`, issues, raw_text);
4579
4774
  }
4580
- //#endregion
4581
- //#region src/engine/trajectory.ts
4775
+ // src/engine/trajectory.ts
4582
4776
  /**
4583
4777
  * Open the `engine.generate` span that brackets one whole generate call.
4584
4778
  */
@@ -5002,8 +5196,7 @@ function create_option_ignored_dedup(trajectory) {
5002
5196
  });
5003
5197
  } };
5004
5198
  }
5005
- //#endregion
5006
- //#region src/engine/providers/claude_cli/adapter.ts
5199
+ // src/engine/providers/claude_cli/adapter.ts
5007
5200
  /**
5008
5201
  * claude_cli adapter factory.
5009
5202
  *
@@ -5026,6 +5219,7 @@ const SUPPORTED = /* @__PURE__ */ new Set([
5026
5219
  ]);
5027
5220
  const PROVIDER_NAME = "claude_cli";
5028
5221
  const BWRAP_EXEC_MISSING = /^bwrap: execvp (.+): No such file or directory$/m;
5222
+ const CLI_SANDBOX_START_FAILED = /sandbox\.failIfUnavailable/;
5029
5223
  const CLAUDE_CLI_EFFORT_VALUES = {
5030
5224
  low: "low",
5031
5225
  medium: "medium",
@@ -5105,23 +5299,35 @@ function compile_schema(schema) {
5105
5299
  return JSON.stringify(to_json_schema(schema, { strip_meta: true }));
5106
5300
  }
5107
5301
  /**
5302
+ * Classify a close whose stderr or error result says that a sandbox kept
5303
+ * the run from going ahead, whether Claude Code's own or a wrapper. Returns
5304
+ * `undefined` when neither does.
5305
+ *
5306
+ * The bwrap check has to come before the wrapper check: bwrap's own
5307
+ * "execvp <binary>: No such file or directory" names bwrap and says the file
5308
+ * is missing, so the wrapper check would blame bwrap for the claude binary.
5309
+ */
5310
+ function classify_sandbox_failure(stderr, reported, snippet, detail) {
5311
+ if (CLI_SANDBOX_START_FAILED.test(stderr) || CLI_SANDBOX_START_FAILED.test(reported)) return new claude_cli_error("sandbox_unavailable", `Claude Code's sandbox couldn't start, so the claude_code sandbox stopped the run: on Linux and WSL2 it needs bubblewrap and socat, and native Windows has no sandbox (${detail})`, { stderr_snippet: snippet });
5312
+ const sandboxed_binary = BWRAP_EXEC_MISSING.exec(stderr)?.[1];
5313
+ if (sandboxed_binary !== void 0) return new claude_cli_error("binary_not_found", `bwrap ran but found no claude binary at '${sandboxed_binary}' inside its sandbox, which binds only /usr, /bin, /lib, /lib64, and additional_write_paths: ${snippet}`, { stderr_snippet: snippet });
5314
+ if (/bwrap|greywall|sandbox/i.test(stderr) && /not found|no such file|enoent/i.test(stderr)) return new claude_cli_error("sandbox_unavailable", `sandbox binary unavailable: ${snippet}`, { stderr_snippet: snippet });
5315
+ }
5316
+ /**
5108
5317
  * Turn a closed CLI subprocess's exit code, signal, stderr, and what its
5109
5318
  * stream reported into an `Error`.
5110
5319
  *
5111
- * Checks for an auth failure first, then for a claude binary that bwrap
5112
- * started but couldn't find inside its sandbox, then for a missing sandbox
5113
- * binary, then falls back to a generic exit-code error. The stderr snippet
5114
- * attached to each error is truncated to 512 bytes.
5320
+ * Checks for an auth failure first, then for a sandbox that stopped the run
5321
+ * (Claude Code's own failing to start, a claude binary that bwrap couldn't
5322
+ * find inside its sandbox, or a missing wrapper), then falls back to a
5323
+ * generic exit-code error. The stderr snippet attached to each error is
5324
+ * truncated to 512 bytes.
5115
5325
  *
5116
5326
  * A logged-out CLI says so on stdout and leaves stderr empty: it writes an
5117
5327
  * assistant message with the `authentication_failed` error code and an error
5118
5328
  * result that reads "Not logged in · Please run /login". So the auth check
5119
5329
  * reads the stream's error code as well as stderr, and when stderr is empty,
5120
5330
  * an error result's text stands in for it in the message.
5121
- *
5122
- * The bwrap check has to come before the sandbox check: bwrap's own
5123
- * "execvp <binary>: No such file or directory" names bwrap and says the file
5124
- * is missing, so the sandbox check would blame bwrap for the claude binary.
5125
5331
  */
5126
5332
  function classify_close_error(code, signal, stderr, parsed) {
5127
5333
  const snippet = stderr.slice(0, 512);
@@ -5131,9 +5337,8 @@ function classify_close_error(code, signal, stderr, parsed) {
5131
5337
  const reason = detail.length > 0 ? `${detail}: ` : "";
5132
5338
  return new provider_auth_error(PROVIDER_NAME, `claude CLI reported an auth failure: ${reason}run ${CLI_REFRESH_COMMAND}`, { refresh_command: CLI_REFRESH_COMMAND });
5133
5339
  }
5134
- const sandboxed_binary = BWRAP_EXEC_MISSING.exec(stderr)?.[1];
5135
- if (sandboxed_binary !== void 0) return new claude_cli_error("binary_not_found", `bwrap ran but found no claude binary at '${sandboxed_binary}' inside its sandbox, which binds only /usr, /bin, /lib, /lib64, and additional_write_paths: ${snippet}`, { stderr_snippet: snippet });
5136
- if (/bwrap|greywall|sandbox/i.test(stderr) && /not found|no such file|enoent/i.test(stderr)) return new claude_cli_error("sandbox_unavailable", `sandbox binary unavailable: ${snippet}`, { stderr_snippet: snippet });
5340
+ const sandbox_failure = classify_sandbox_failure(stderr, reported, snippet, detail);
5341
+ if (sandbox_failure !== void 0) return sandbox_failure;
5137
5342
  const status = typeof code === "number" ? code : void 0;
5138
5343
  const signal_part = signal !== null ? ` (signal ${signal})` : "";
5139
5344
  const message = `claude CLI exited with code ${String(code)}${signal_part}: ${detail}`;
@@ -5161,6 +5366,7 @@ async function run_cli(spawn_runtime, args) {
5161
5366
  ...args.compiled_schema !== void 0 ? { compiled_schema: args.compiled_schema } : {}
5162
5367
  });
5163
5368
  const full_argv = [...args.prefix_args, ...argv];
5369
+ const sandbox = args.provider_config.sandbox;
5164
5370
  const session = await spawn_runtime.spawn_cli({
5165
5371
  cmd: args.spawn_cmd,
5166
5372
  argv: full_argv,
@@ -5170,7 +5376,7 @@ async function run_cli(spawn_runtime, args) {
5170
5376
  stall_timeout_ms: args.stall_timeout_ms,
5171
5377
  ...args.cwd !== void 0 ? { cwd: args.cwd } : {},
5172
5378
  ...args.abort !== void 0 ? { abort: args.abort } : {},
5173
- ...args.provider_config.sandbox !== void 0 ? { spawn_failure_reason: "sandbox_unavailable" } : {}
5379
+ ...sandbox !== void 0 && sandbox.kind !== "claude_code" ? { spawn_failure_reason: "sandbox_unavailable" } : {}
5174
5380
  });
5175
5381
  const state = create_parser_state();
5176
5382
  const chunks = [];
@@ -5439,6 +5645,7 @@ function close_spans_on_error(trajectory, spans, err) {
5439
5645
  function create_claude_cli_adapter(init) {
5440
5646
  const config = init;
5441
5647
  validate_auth_config(config);
5648
+ validate_sandbox_config(config);
5442
5649
  const spawn_runtime = create_spawn_runtime();
5443
5650
  let disposed = false;
5444
5651
  const in_flight = /* @__PURE__ */ new Set();
@@ -5446,6 +5653,11 @@ function create_claude_cli_adapter(init) {
5446
5653
  const resolved_auth_mode = config.auth_mode ?? "auto";
5447
5654
  const resolved_startup_timeout = config.startup_timeout_ms ?? 12e4;
5448
5655
  const resolved_stall_timeout = config.stall_timeout_ms ?? 3e5;
5656
+ const sandbox_cli_gate = config.sandbox?.kind === "claude_code" ? create_cli_version_gate(spawn_runtime, {
5657
+ cmd: resolved_binary,
5658
+ startup_timeout_ms: resolved_startup_timeout,
5659
+ stall_timeout_ms: resolved_stall_timeout
5660
+ }) : void 0;
5449
5661
  return {
5450
5662
  kind: "external",
5451
5663
  name: PROVIDER_NAME,
@@ -5459,6 +5671,7 @@ function create_claude_cli_adapter(init) {
5459
5671
  const tools_list = opts.tools ?? [];
5460
5672
  const tool_bridge = call_opts.tool_bridge ?? "allowlist_only";
5461
5673
  validate_request(opts.prompt, tools_list, tool_bridge);
5674
+ validate_sandbox_extra_args(config.sandbox, call_opts.extra_args);
5462
5675
  const merged_allowed_tools = merge_allowed_tools(call_opts.allowed_tools, tools_list.map((t) => t.name));
5463
5676
  record_allowlist_only_drop(tools_list, tool_bridge, trajectory);
5464
5677
  const merged_system = merge_system(opts.system ?? extract_system_text(opts.prompt), call_opts.append_system_prompt);
@@ -5487,6 +5700,7 @@ function create_claude_cli_adapter(init) {
5487
5700
  trajectory
5488
5701
  };
5489
5702
  try {
5703
+ await sandbox_cli_gate?.ensure(env, controller.signal);
5490
5704
  const first_outcome = await run_cli(spawn_runtime, base_args);
5491
5705
  const { parsed, parsed_content } = await resolve_content(spawn_runtime, base_args, opts, first_outcome.parsed);
5492
5706
  const result = assemble_result$1(parsed, resolved, opts.schema, parsed_content);
@@ -5514,8 +5728,7 @@ function create_claude_cli_adapter(init) {
5514
5728
  }
5515
5729
  };
5516
5730
  }
5517
- //#endregion
5518
- //#region src/engine/providers/registry.ts
5731
+ // src/engine/providers/registry.ts
5519
5732
  /**
5520
5733
  * Provider name → adapter factory lookup for the built-in set.
5521
5734
  *
@@ -5552,8 +5765,7 @@ function get_provider_factory(name) {
5552
5765
  if (factory === void 0) throw new engine_config_error(`unknown provider '${name}'; built-in providers are: ${list_builtin_providers().join(", ")}`, name);
5553
5766
  return factory;
5554
5767
  }
5555
- //#endregion
5556
- //#region src/engine/first_chunk_stamp.ts
5768
+ // src/engine/first_chunk_stamp.ts
5557
5769
  /**
5558
5770
  * Creates the stamp one turn's attempts share, cleared by `reset` as each
5559
5771
  * attempt starts, so a failed attempt's chunks never count for the one that
@@ -5588,8 +5800,7 @@ function create_first_chunk_stamp() {
5588
5800
  whole_tool_call: () => whole
5589
5801
  };
5590
5802
  }
5591
- //#endregion
5592
- //#region src/engine/merge_defaults.ts
5803
+ // src/engine/merge_defaults.ts
5593
5804
  /**
5594
5805
  * Default-merging helpers for engine-level `EngineDefaults`.
5595
5806
  */
@@ -5630,8 +5841,7 @@ function merge_provider_options(defaults, call) {
5630
5841
  function is_plain_object$1(value) {
5631
5842
  return value !== null && typeof value === "object" && !Array.isArray(value);
5632
5843
  }
5633
- //#endregion
5634
- //#region src/engine/streaming.ts
5844
+ // src/engine/streaming.ts
5635
5845
  /**
5636
5846
  * Build a dispatcher around a user-supplied on_chunk. Catches sync throws and
5637
5847
  * rejected promises; once an error is recorded subsequent dispatch calls are
@@ -5655,8 +5865,7 @@ function create_chunk_dispatcher(on_chunk) {
5655
5865
  }
5656
5866
  };
5657
5867
  }
5658
- //#endregion
5659
- //#region src/engine/usage.ts
5868
+ // src/engine/usage.ts
5660
5869
  const OPTIONAL_FIELDS = [
5661
5870
  "reasoning_tokens",
5662
5871
  "cached_input_tokens",
@@ -5706,8 +5915,7 @@ function sum_usage(steps) {
5706
5915
  for (const key of OPTIONAL_FIELDS) if (present[key]) total[key] = sums[key];
5707
5916
  return total;
5708
5917
  }
5709
- //#endregion
5710
- //#region src/engine/tool_call_salvage.ts
5918
+ // src/engine/tool_call_salvage.ts
5711
5919
  /**
5712
5920
  * Salvage tool calls that a model emitted as assistant TEXT instead of a
5713
5921
  * structured tool_calls array. Local runtimes (Ollama native API, LM Studio
@@ -6089,8 +6297,7 @@ async function salvage_tool_calls(text, tool_map) {
6089
6297
  stripped_text: strip_spans(text, calls.map((c) => c.span))
6090
6298
  };
6091
6299
  }
6092
- //#endregion
6093
- //#region src/engine/tool_loop.ts
6300
+ // src/engine/tool_loop.ts
6094
6301
  /**
6095
6302
  * Tool-call loop orchestration.
6096
6303
  *
@@ -7284,8 +7491,7 @@ async function run_tool_loop(config) {
7284
7491
  step_index += 1;
7285
7492
  }
7286
7493
  }
7287
- //#endregion
7288
- //#region src/engine/generate.ts
7494
+ // src/engine/generate.ts
7289
7495
  /**
7290
7496
  * Build the initial message list for a generate call from `opts.system` and
7291
7497
  * `opts.prompt`.
@@ -7960,7 +8166,7 @@ async function build_ai_sdk_transport(cfg) {
7960
8166
  const provider_options = combined_provider_options !== void 0 && Object.keys(combined_provider_options).length > 0 ? combined_provider_options : void 0;
7961
8167
  let ai_sdk_invoke_mod;
7962
8168
  try {
7963
- ai_sdk_invoke_mod = await import("./invoke-DnmWf8gE.js");
8169
+ ai_sdk_invoke_mod = await import("./invoke-7iu8db6V.js");
7964
8170
  } catch (err) {
7965
8171
  throw missing_peer_error("ai", err);
7966
8172
  }
@@ -8421,8 +8627,7 @@ function aggregate_cost(steps, provider) {
8421
8627
  if (acc.reasoning_present) out.reasoning_usd = round6(acc.reasoning);
8422
8628
  return out;
8423
8629
  }
8424
- //#endregion
8425
- //#region src/engine/create_engine.ts
8630
+ // src/engine/create_engine.ts
8426
8631
  /**
8427
8632
  * Build the provider-name to adapter map from `providers`, resolving each
8428
8633
  * name to a `custom_providers` factory when one is supplied, or the built-in
@@ -8600,7 +8805,6 @@ function create_engine(config) {
8600
8805
  }
8601
8806
  };
8602
8807
  }
8603
- //#endregion
8604
8808
  export { to_json_schema as n, create_engine as t };
8605
8809
 
8606
- //# sourceMappingURL=engine-B5iQ3if9.js.map
8810
+ //# sourceMappingURL=engine-fOjYHcv6.js.map