@orbit-build/cli 1.0.0 → 1.5.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 (3) hide show
  1. package/README.md +9 -0
  2. package/dist/index.js +1808 -740
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -438,7 +438,7 @@ var require_parse = __commonJS({
438
438
  }
439
439
  return parsed;
440
440
  }
441
- function parse6(command, args, options) {
441
+ function parse7(command, args, options) {
442
442
  if (args && !Array.isArray(args)) {
443
443
  options = args;
444
444
  args = null;
@@ -457,7 +457,7 @@ var require_parse = __commonJS({
457
457
  };
458
458
  return options.shell ? parsed : parseNonShell(parsed);
459
459
  }
460
- module.exports = parse6;
460
+ module.exports = parse7;
461
461
  }
462
462
  });
463
463
 
@@ -516,16 +516,16 @@ var require_cross_spawn = __commonJS({
516
516
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
517
517
  "use strict";
518
518
  var cp = __require("child_process");
519
- var parse6 = require_parse();
519
+ var parse7 = require_parse();
520
520
  var enoent = require_enoent();
521
521
  function spawn5(command, args, options) {
522
- const parsed = parse6(command, args, options);
522
+ const parsed = parse7(command, args, options);
523
523
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
524
524
  enoent.hookChildProcess(spawned, parsed);
525
525
  return spawned;
526
526
  }
527
527
  function spawnSync(command, args, options) {
528
- const parsed = parse6(command, args, options);
528
+ const parsed = parse7(command, args, options);
529
529
  const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
530
530
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
531
531
  return result;
@@ -533,7 +533,7 @@ var require_cross_spawn = __commonJS({
533
533
  module.exports = spawn5;
534
534
  module.exports.spawn = spawn5;
535
535
  module.exports.sync = spawnSync;
536
- module.exports._parse = parse6;
536
+ module.exports._parse = parse7;
537
537
  module.exports._enoent = enoent;
538
538
  }
539
539
  });
@@ -207590,7 +207590,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
207590
207590
  return ts_textChanges_exports.ChangeTracker.with(
207591
207591
  { host, formatContext, preferences },
207592
207592
  (changeTracker) => {
207593
- const parsed = contents.map((c2) => parse6(sourceFile, c2));
207593
+ const parsed = contents.map((c2) => parse7(sourceFile, c2));
207594
207594
  const flattenedLocations = focusLocations && flatten(focusLocations);
207595
207595
  for (const nodes of parsed) {
207596
207596
  placeNodeGroup(
@@ -207603,7 +207603,7 @@ ${newComment.split("\n").map((c2) => ` * ${c2}`).join("\n")}
207603
207603
  }
207604
207604
  );
207605
207605
  }
207606
- function parse6(sourceFile, content) {
207606
+ function parse7(sourceFile, content) {
207607
207607
  const nodeKinds = [
207608
207608
  {
207609
207609
  parse: () => createSourceFile(
@@ -235085,7 +235085,7 @@ var require_fast_uri = __commonJS({
235085
235085
  normalizeString(uri, options);
235086
235086
  } else if (typeof uri === "object") {
235087
235087
  uri = /** @type {T} */
235088
- parse6(serialize(uri, options), options);
235088
+ parse7(serialize(uri, options), options);
235089
235089
  }
235090
235090
  return uri;
235091
235091
  }
@@ -235103,8 +235103,8 @@ var require_fast_uri = __commonJS({
235103
235103
  function resolveComponent(base, relative12, options, skipNormalization) {
235104
235104
  const target = {};
235105
235105
  if (!skipNormalization) {
235106
- base = parse6(serialize(base, options), options);
235107
- relative12 = parse6(serialize(relative12, options), options);
235106
+ base = parse7(serialize(base, options), options);
235107
+ relative12 = parse7(serialize(relative12, options), options);
235108
235108
  }
235109
235109
  options = options || {};
235110
235110
  if (!options.tolerant && relative12.scheme) {
@@ -235348,7 +235348,7 @@ var require_fast_uri = __commonJS({
235348
235348
  }
235349
235349
  return { parsed, malformedAuthorityOrPort };
235350
235350
  }
235351
- function parse6(uri, opts) {
235351
+ function parse7(uri, opts) {
235352
235352
  return parseWithStatus(uri, opts).parsed;
235353
235353
  }
235354
235354
  function normalizeString(uri, opts) {
@@ -235377,7 +235377,7 @@ var require_fast_uri = __commonJS({
235377
235377
  resolveComponent,
235378
235378
  equal,
235379
235379
  serialize,
235380
- parse: parse6
235380
+ parse: parse7
235381
235381
  };
235382
235382
  module.exports = fastUri;
235383
235383
  module.exports.default = fastUri;
@@ -238103,7 +238103,7 @@ var require_src = __commonJS({
238103
238103
 
238104
238104
  // src/index.ts
238105
238105
  import { Command, Option } from "commander";
238106
- import picocolors29 from "picocolors";
238106
+ import picocolors30 from "picocolors";
238107
238107
 
238108
238108
  // ../shared/dist/index.js
238109
238109
  import { randomUUID } from "crypto";
@@ -239186,33 +239186,38 @@ async function runInit(cwd, options = {}) {
239186
239186
  }
239187
239187
 
239188
239188
  // ../config/dist/index.js
239189
- import { z as z22 } from "zod";
239189
+ import { z as z4 } from "zod";
239190
239190
  import { z as z3 } from "zod";
239191
- import { homedir as homedir3 } from "os";
239192
- import { join as join4 } from "path";
239193
- import { existsSync as existsSync22 } from "fs";
239191
+ import { homedir } from "os";
239192
+ import { existsSync as existsSync4, readdirSync } from "fs";
239193
+ import { isAbsolute as isAbsolute2, join as join2, resolve as resolve3 } from "path";
239194
239194
  import { parse } from "yaml";
239195
+ import { z as z32 } from "zod";
239196
+ import { parse as parseYaml } from "yaml";
239197
+ import { z as z22 } from "zod";
239198
+ import { homedir as homedir4 } from "os";
239199
+ import { join as join5 } from "path";
239200
+ import { existsSync as existsSync32 } from "fs";
239201
+ import { parse as parse2 } from "yaml";
239195
239202
  import { execFileSync as execFileSync2 } from "child_process";
239196
239203
  import { chmodSync as chmodSync2, closeSync as closeSync2, openSync as openSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
239197
- import { join as join2 } from "path";
239198
- import { homedir } from "os";
239204
+ import { join as join22 } from "path";
239205
+ import { homedir as homedir2 } from "os";
239199
239206
  import crypto from "crypto";
239200
- import { z as z4 } from "zod";
239207
+ import { z as z6 } from "zod";
239201
239208
  import { execFileSync as execFileSync3 } from "child_process";
239202
- import { z as z32 } from "zod";
239203
- import { homedir as homedir2 } from "os";
239204
- import { join as join22 } from "path";
239205
239209
  import { z as z5 } from "zod";
239206
- import { parse as parseYaml } from "yaml";
239207
- import { z as z6 } from "zod";
239208
- import { existsSync as existsSync4, lstatSync as lstatSync2, readdirSync } from "fs";
239210
+ import { homedir as homedir3 } from "os";
239211
+ import { join as join3 } from "path";
239212
+ import { z as z7 } from "zod";
239213
+ import { existsSync as existsSync22, lstatSync as lstatSync2, readdirSync as readdirSync2 } from "fs";
239209
239214
  import { createHash } from "crypto";
239210
- import { join as join3, relative as relative3, resolve as resolve3 } from "path";
239211
- import { z as z8 } from "zod";
239215
+ import { join as join4, relative as relative3, resolve as resolve22 } from "path";
239216
+ import { z as z9 } from "zod";
239212
239217
  import { extname } from "path";
239213
239218
  import { parse as parseYaml2 } from "yaml";
239214
- import { z as z7 } from "zod";
239215
- import { resolve as resolve22 } from "path";
239219
+ import { z as z8 } from "zod";
239220
+ import { resolve as resolve32 } from "path";
239216
239221
  var OrbitLanguageSchema = z3.enum(["en", "zh", "zh-TW"]);
239217
239222
  var LANGUAGE_ALIASES = {
239218
239223
  en: "en",
@@ -239237,6 +239242,416 @@ function localizeOrbit(language, english, simplifiedChinese, traditionalChinese)
239237
239242
  if (language === "zh-TW") return traditionalChinese;
239238
239243
  return language === "zh" ? simplifiedChinese : english;
239239
239244
  }
239245
+ var MAX_MANAGED_POLICY_BYTES = 1024 * 1024;
239246
+ var ManagedPolicySchema = z22.object({
239247
+ schemaVersion: z22.literal(1),
239248
+ allowedProviders: z22.array(z22.string().min(1).max(256)).max(100).optional(),
239249
+ allowedModels: z22.array(z22.string().min(1).max(256)).max(500).optional(),
239250
+ minimumPermissionMode: z22.enum(["auto", "normal", "strict", "plan"]).optional(),
239251
+ requireWriteApproval: z22.boolean().default(true),
239252
+ requireBashApproval: z22.boolean().default(true),
239253
+ disableWebSearch: z22.boolean().default(false),
239254
+ disableMcp: z22.boolean().default(false),
239255
+ maxBudgetUsd: z22.number().finite().positive().max(1e6).optional(),
239256
+ maxIterations: z22.number().int().positive().max(1e3).optional(),
239257
+ protectedPaths: z22.array(z22.string().min(1).max(4096)).max(1e3).default([])
239258
+ });
239259
+ function loadManagedPolicy(filePath) {
239260
+ const raw = readBoundedRegularFile(filePath, MAX_MANAGED_POLICY_BYTES, {
239261
+ allowSymbolicLink: true
239262
+ });
239263
+ if (raw === void 0) {
239264
+ throw new Error(`Managed policy file was not found: ${filePath}`);
239265
+ }
239266
+ const value = filePath.toLowerCase().endsWith(".json") ? JSON.parse(raw) : parseYaml(raw);
239267
+ return ManagedPolicySchema.strict().parse(value);
239268
+ }
239269
+ function applyManagedPolicy(source, policy) {
239270
+ const config = structuredClone(source);
239271
+ let effectiveAllowedProviders = policy.allowedProviders;
239272
+ if (policy.allowedProviders?.length) {
239273
+ const allowed = new Set(
239274
+ policy.allowedProviders.flatMap((id) => {
239275
+ if (config.providers[id]) return [id];
239276
+ if (config.providers.deepseek && (id === "deepseek-openai" || id === "deepseek-anthropic")) {
239277
+ return ["deepseek"];
239278
+ }
239279
+ return [id];
239280
+ })
239281
+ );
239282
+ effectiveAllowedProviders = [...allowed];
239283
+ config.providers = Object.fromEntries(
239284
+ Object.entries(config.providers).filter(([id]) => allowed.has(id))
239285
+ );
239286
+ if (!config.providers[config.provider.default]) {
239287
+ const replacement = effectiveAllowedProviders.find(
239288
+ (id) => config.providers[id]
239289
+ );
239290
+ if (!replacement) {
239291
+ throw new Error(
239292
+ "Managed policy does not allow any configured model provider."
239293
+ );
239294
+ }
239295
+ config.provider.default = replacement;
239296
+ }
239297
+ if (config.provider.embedding && !config.providers[config.provider.embedding]) {
239298
+ delete config.provider.embedding;
239299
+ }
239300
+ }
239301
+ if (policy.allowedModels?.length) {
239302
+ const allowed = new Set(policy.allowedModels);
239303
+ const fallback = policy.allowedModels[0];
239304
+ for (const key of [
239305
+ "default",
239306
+ "fast",
239307
+ "planner",
239308
+ "coder",
239309
+ "reviewer",
239310
+ "summarizer"
239311
+ ]) {
239312
+ if (!allowed.has(config.models[key])) config.models[key] = fallback;
239313
+ }
239314
+ for (const provider of Object.values(config.providers)) {
239315
+ if (provider.models) {
239316
+ provider.models = provider.models.filter((model) => allowed.has(model));
239317
+ }
239318
+ }
239319
+ }
239320
+ if (policy.minimumPermissionMode && permissionRank(config.permissions.mode) < permissionRank(policy.minimumPermissionMode)) {
239321
+ config.permissions.mode = policy.minimumPermissionMode;
239322
+ }
239323
+ if (policy.requireWriteApproval) {
239324
+ config.permissions.requireApprovalForWrite = true;
239325
+ }
239326
+ if (policy.requireBashApproval) {
239327
+ config.permissions.requireApprovalForBash = true;
239328
+ }
239329
+ if (config.permissions.mode !== "auto" || policy.requireWriteApproval || policy.requireBashApproval) {
239330
+ config.permissions.blockDangerousCommands = true;
239331
+ config.permissions.protectSecrets = true;
239332
+ }
239333
+ config.permissions.protectedPaths = Array.from(
239334
+ /* @__PURE__ */ new Set([...config.permissions.protectedPaths, ...policy.protectedPaths])
239335
+ );
239336
+ if (policy.disableWebSearch) config.tools.webSearch.enabled = false;
239337
+ if (policy.disableMcp) config.tools.mcp.enabled = false;
239338
+ if (policy.maxBudgetUsd !== void 0) {
239339
+ config.budgetLimit = Math.min(config.budgetLimit, policy.maxBudgetUsd);
239340
+ }
239341
+ if (policy.maxIterations !== void 0) {
239342
+ config.agent.maxIterations = Math.min(
239343
+ config.agent.maxIterations,
239344
+ policy.maxIterations
239345
+ );
239346
+ }
239347
+ config.managedPolicy = {
239348
+ allowedProviders: effectiveAllowedProviders,
239349
+ allowedModels: policy.allowedModels,
239350
+ minimumPermissionMode: policy.minimumPermissionMode,
239351
+ requireWriteApproval: policy.requireWriteApproval,
239352
+ requireBashApproval: policy.requireBashApproval,
239353
+ disableWebSearch: policy.disableWebSearch,
239354
+ disableMcp: policy.disableMcp,
239355
+ maxIterations: policy.maxIterations
239356
+ };
239357
+ return config;
239358
+ }
239359
+ function validateManagedRuntimeChange(config, change) {
239360
+ const policy = config.managedPolicy;
239361
+ if (!policy) return void 0;
239362
+ if (change.provider && policy.allowedProviders?.length && !policy.allowedProviders.includes(change.provider)) {
239363
+ return `Managed policy does not allow provider ${change.provider}.`;
239364
+ }
239365
+ if (change.model && change.model !== "__auto__" && policy.allowedModels?.length && !policy.allowedModels.includes(change.model)) {
239366
+ return `Managed policy does not allow model ${change.model}.`;
239367
+ }
239368
+ if (change.permissionMode && policy.minimumPermissionMode && permissionRank(change.permissionMode) < permissionRank(policy.minimumPermissionMode)) {
239369
+ return `Managed policy requires ${policy.minimumPermissionMode} mode or stricter.`;
239370
+ }
239371
+ if (change.requireWriteApproval === false && policy.requireWriteApproval) {
239372
+ return "Managed policy requires write approval.";
239373
+ }
239374
+ if (change.requireBashApproval === false && policy.requireBashApproval) {
239375
+ return "Managed policy requires command approval.";
239376
+ }
239377
+ if (change.webSearchEnabled && policy.disableWebSearch) {
239378
+ return "Managed policy disables web search.";
239379
+ }
239380
+ if (change.agentMaxIterations !== void 0 && policy.maxIterations !== void 0 && change.agentMaxIterations > policy.maxIterations) {
239381
+ return `Managed policy limits agent runs to ${policy.maxIterations} iterations.`;
239382
+ }
239383
+ return void 0;
239384
+ }
239385
+ function permissionRank(mode) {
239386
+ return { auto: 0, normal: 1, strict: 2, plan: 3 }[mode];
239387
+ }
239388
+ var AGENT_PROFILE_SCHEMA_VERSION = 1;
239389
+ var MAX_AGENT_PROFILE_FILE_BYTES = 128 * 1024;
239390
+ var MAX_AGENT_PROFILES = 100;
239391
+ var ProfileNameSchema = z32.string().trim().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]*$/);
239392
+ var ToolNameSchema = z32.string().trim().min(1).max(128).regex(/^[a-z][a-z0-9_:-]*$/);
239393
+ var SkillNameSchema = z32.string().trim().min(1).max(64).regex(/^[a-z0-9][a-z0-9-]*$/);
239394
+ var AgentProfileSchema = z32.object({
239395
+ schemaVersion: z32.literal(AGENT_PROFILE_SCHEMA_VERSION).default(1),
239396
+ name: ProfileNameSchema,
239397
+ /** Optional parent profile resolved from the same discovered catalog. */
239398
+ extends: ProfileNameSchema.optional(),
239399
+ displayName: z32.string().trim().min(1).max(120).optional(),
239400
+ description: z32.string().trim().max(2e3).default(""),
239401
+ provider: z32.string().trim().min(1).max(256).optional(),
239402
+ model: z32.string().trim().min(1).max(1024).optional(),
239403
+ permissionMode: z32.enum(["strict", "normal", "auto", "plan"]).optional(),
239404
+ allowedTools: z32.array(ToolNameSchema).max(256).optional(),
239405
+ disallowedTools: z32.array(ToolNameSchema).max(256).default([]),
239406
+ skills: z32.array(SkillNameSchema).max(32).default([]),
239407
+ maxTurns: z32.number().int().min(1).max(1e3).optional(),
239408
+ effort: z32.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
239409
+ systemPrompt: z32.string().trim().max(2e4).optional(),
239410
+ isolation: z32.enum(["workspace", "worktree"]).default("workspace"),
239411
+ memory: z32.enum(["project", "none"]).default("project")
239412
+ }).superRefine((profile, context) => {
239413
+ const allowed = new Set(profile.allowedTools ?? []);
239414
+ for (const tool of profile.disallowedTools) {
239415
+ if (allowed.has(tool)) {
239416
+ context.addIssue({
239417
+ code: z32.ZodIssueCode.custom,
239418
+ path: ["disallowedTools"],
239419
+ message: `Tool ${tool} cannot be both allowed and disallowed.`
239420
+ });
239421
+ }
239422
+ }
239423
+ });
239424
+ var AgentProfileSettingsSchema = z32.object({
239425
+ enabled: z32.boolean().default(true),
239426
+ directories: z32.array(z32.string().trim().min(1).max(4096)).max(20).default([
239427
+ ".agents/agents",
239428
+ ".orbit/agents",
239429
+ ".claude/agents",
239430
+ "~/.orbit/agents",
239431
+ "~/.claude/agents"
239432
+ ]),
239433
+ defaultProfile: ProfileNameSchema.optional(),
239434
+ maxProfiles: z32.number().int().min(1).max(MAX_AGENT_PROFILES).default(32)
239435
+ }).default({});
239436
+ function resolveAgentProfileDirectories(cwd, directories) {
239437
+ const resolved = /* @__PURE__ */ new Map();
239438
+ for (const directory of directories) {
239439
+ const trimmed = directory.trim();
239440
+ if (!trimmed) continue;
239441
+ const expanded = trimmed === "~" ? homedir() : trimmed.startsWith("~/") || trimmed.startsWith("~\\") ? join2(homedir(), trimmed.slice(2)) : trimmed;
239442
+ const absolute = isAbsolute2(expanded) ? resolve3(expanded) : resolve3(cwd, expanded);
239443
+ const key = process.platform === "win32" ? absolute.toLowerCase() : absolute;
239444
+ if (!resolved.has(key)) resolved.set(key, absolute);
239445
+ }
239446
+ return [...resolved.values()];
239447
+ }
239448
+ function discoverAgentProfiles(cwd, settings2) {
239449
+ const directories = resolveAgentProfileDirectories(cwd, settings2.directories);
239450
+ const diagnostics = [];
239451
+ const loaded = [];
239452
+ const maxProfiles = Math.min(MAX_AGENT_PROFILES, settings2.maxProfiles);
239453
+ for (const directory of directories) {
239454
+ if (!existsSync4(directory)) continue;
239455
+ if (isProjectProfile(cwd, directory)) {
239456
+ try {
239457
+ resolveSafePath(cwd, directory);
239458
+ } catch {
239459
+ diagnostics.push({
239460
+ path: normalizeDiagnosticPath(directory),
239461
+ severity: "error",
239462
+ code: "unsafe-directory",
239463
+ message: "Agent profile directory escapes the project boundary."
239464
+ });
239465
+ continue;
239466
+ }
239467
+ }
239468
+ let entries;
239469
+ try {
239470
+ entries = readdirSync(directory, { withFileTypes: true });
239471
+ } catch (error) {
239472
+ diagnostics.push({
239473
+ path: normalizeDiagnosticPath(directory),
239474
+ severity: "warning",
239475
+ code: "unreadable-directory",
239476
+ message: `Agent profile directory could not be read: ${safeMessage(error)}`
239477
+ });
239478
+ continue;
239479
+ }
239480
+ entries.sort((left, right) => left.name.localeCompare(right.name));
239481
+ for (const entry of entries) {
239482
+ if (loaded.length >= maxProfiles) {
239483
+ diagnostics.push({
239484
+ path: normalizeDiagnosticPath(directory),
239485
+ severity: "warning",
239486
+ code: "discovery-limit",
239487
+ message: `Agent profile discovery stopped after ${maxProfiles} profiles.`
239488
+ });
239489
+ break;
239490
+ }
239491
+ if (!entry.isFile() || !/\.(?:ya?ml|json)$/i.test(entry.name)) continue;
239492
+ const filePath = join2(directory, entry.name);
239493
+ try {
239494
+ const raw = readBoundedRegularFile(
239495
+ filePath,
239496
+ MAX_AGENT_PROFILE_FILE_BYTES
239497
+ );
239498
+ if (raw === void 0) continue;
239499
+ const document2 = parse(raw);
239500
+ const declaredFields = isRecord(document2) ? Object.keys(document2) : [];
239501
+ const parsed = AgentProfileSchema.safeParse(document2);
239502
+ if (!parsed.success) {
239503
+ diagnostics.push({
239504
+ path: normalizeDiagnosticPath(filePath),
239505
+ severity: "error",
239506
+ code: "invalid-profile",
239507
+ message: formatProfileIssues(parsed.error)
239508
+ });
239509
+ continue;
239510
+ }
239511
+ const profile = parsed.data;
239512
+ const duplicate = loaded.find(
239513
+ (candidate) => candidate.name.toLowerCase() === profile.name.toLowerCase()
239514
+ );
239515
+ if (duplicate) {
239516
+ diagnostics.push({
239517
+ path: normalizeDiagnosticPath(filePath),
239518
+ severity: "warning",
239519
+ code: "duplicate-profile",
239520
+ message: `Profile "${profile.name}" ignored; using ${duplicate.path}.`
239521
+ });
239522
+ continue;
239523
+ }
239524
+ loaded.push({
239525
+ ...profile,
239526
+ path: normalizeDiagnosticPath(filePath),
239527
+ source: isProjectProfile(cwd, directory) ? "project" : "user",
239528
+ declaredFields
239529
+ });
239530
+ } catch (error) {
239531
+ diagnostics.push({
239532
+ path: normalizeDiagnosticPath(filePath),
239533
+ severity: "error",
239534
+ code: "read-error",
239535
+ message: redactSecrets(safeMessage(error)).slice(0, 2e3)
239536
+ });
239537
+ }
239538
+ }
239539
+ }
239540
+ return {
239541
+ profiles: loaded.sort((left, right) => left.name.localeCompare(right.name)),
239542
+ diagnostics,
239543
+ directories: directories.map(normalizeDiagnosticPath)
239544
+ };
239545
+ }
239546
+ function resolveAgentProfile(catalog, name, config, options = {}) {
239547
+ const normalized = name.trim().toLowerCase();
239548
+ const profile = resolveInheritedProfile(catalog, normalized, []);
239549
+ if (profile.provider) {
239550
+ const violation = validateManagedRuntimeChange(config, {
239551
+ provider: profile.provider
239552
+ });
239553
+ if (violation) throw new Error(violation);
239554
+ }
239555
+ if (profile.model) {
239556
+ const violation = validateManagedRuntimeChange(config, {
239557
+ model: profile.model
239558
+ });
239559
+ if (violation) throw new Error(violation);
239560
+ }
239561
+ if (profile.permissionMode && !options.allowPermissionEscalation) {
239562
+ const current = permissionRank2(config.permissions.mode);
239563
+ if (permissionRank2(profile.permissionMode) < current) {
239564
+ throw new Error(
239565
+ `Agent profile ${profile.name} requests ${profile.permissionMode} mode; confirm Full Access explicitly before selecting it.`
239566
+ );
239567
+ }
239568
+ }
239569
+ if (profile.maxTurns !== void 0) {
239570
+ const violation = validateManagedRuntimeChange(config, {
239571
+ agentMaxIterations: profile.maxTurns
239572
+ });
239573
+ if (violation) throw new Error(violation);
239574
+ }
239575
+ if (profile.isolation === "worktree") {
239576
+ throw new Error(
239577
+ `Agent profile ${profile.name} requests worktree isolation, which must be selected through an isolated orchestration run.`
239578
+ );
239579
+ }
239580
+ return profile;
239581
+ }
239582
+ function resolveInheritedProfile(catalog, normalizedName, stack) {
239583
+ const profile = catalog.profiles.find(
239584
+ (candidate) => candidate.name.toLowerCase() === normalizedName
239585
+ );
239586
+ if (!profile) throw new Error(`Agent profile not found: ${normalizedName}`);
239587
+ if (stack.includes(normalizedName)) {
239588
+ throw new Error(
239589
+ `Agent profile inheritance cycle detected: ${[...stack, normalizedName].join(" -> ")}.`
239590
+ );
239591
+ }
239592
+ if (stack.length >= 8) {
239593
+ throw new Error(
239594
+ `Agent profile inheritance exceeds the maximum depth of 8: ${[...stack, normalizedName].join(" -> ")}.`
239595
+ );
239596
+ }
239597
+ if (!profile.extends) return profile;
239598
+ const parent = resolveInheritedProfile(
239599
+ catalog,
239600
+ profile.extends.toLowerCase(),
239601
+ [...stack, normalizedName]
239602
+ );
239603
+ const childFields = new Set(profile.declaredFields ?? []);
239604
+ const inherited = {
239605
+ ...parent,
239606
+ ...profile,
239607
+ description: childFields.has("description") ? profile.description : parent.description,
239608
+ displayName: childFields.has("displayName") ? profile.displayName : parent.displayName,
239609
+ provider: childFields.has("provider") ? profile.provider : parent.provider,
239610
+ model: childFields.has("model") ? profile.model : parent.model,
239611
+ permissionMode: childFields.has("permissionMode") ? profile.permissionMode : parent.permissionMode,
239612
+ allowedTools: childFields.has("allowedTools") ? profile.allowedTools : parent.allowedTools,
239613
+ disallowedTools: childFields.has("disallowedTools") ? profile.disallowedTools : parent.disallowedTools,
239614
+ skills: childFields.has("skills") ? profile.skills : parent.skills,
239615
+ maxTurns: childFields.has("maxTurns") ? profile.maxTurns : parent.maxTurns,
239616
+ effort: childFields.has("effort") ? profile.effort : parent.effort,
239617
+ systemPrompt: childFields.has("systemPrompt") ? profile.systemPrompt : parent.systemPrompt,
239618
+ isolation: childFields.has("isolation") ? profile.isolation : parent.isolation,
239619
+ memory: childFields.has("memory") ? profile.memory : parent.memory,
239620
+ declaredFields: [
239621
+ .../* @__PURE__ */ new Set([
239622
+ ...parent.declaredFields ?? [],
239623
+ ...profile.declaredFields ?? []
239624
+ ])
239625
+ ]
239626
+ };
239627
+ return inherited;
239628
+ }
239629
+ function permissionRank2(mode) {
239630
+ return { auto: 0, normal: 1, strict: 2, plan: 3 }[mode];
239631
+ }
239632
+ function isProjectProfile(cwd, directory) {
239633
+ const projectRoots = [
239634
+ resolve3(cwd, ".agents", "agents"),
239635
+ resolve3(cwd, ".orbit", "agents"),
239636
+ resolve3(cwd, ".claude", "agents")
239637
+ ];
239638
+ const normalized = resolve3(directory);
239639
+ return projectRoots.some(
239640
+ (root) => process.platform === "win32" ? root.toLowerCase() === normalized.toLowerCase() : root === normalized
239641
+ );
239642
+ }
239643
+ function normalizeDiagnosticPath(filePath) {
239644
+ return filePath.replace(/\\/g, "/");
239645
+ }
239646
+ function formatProfileIssues(error) {
239647
+ return error.issues.slice(0, 4).map((issue) => `${issue.path.join(".") || "profile"}: ${issue.message}`).join("; ");
239648
+ }
239649
+ function safeMessage(error) {
239650
+ return error instanceof Error ? error.message : String(error);
239651
+ }
239652
+ function isRecord(value) {
239653
+ return typeof value === "object" && value !== null && !Array.isArray(value);
239654
+ }
239240
239655
  var ORBIT_CONFIG_SCHEMA_VERSION = 1;
239241
239656
  var DEFAULT_AGENT_MAX_ITERATIONS = 200;
239242
239657
  var MAX_AGENT_MAX_ITERATIONS = 1e3;
@@ -239255,26 +239670,26 @@ var ORBIT_LIFECYCLE_HOOK_EVENTS = [
239255
239670
  "subagentStop",
239256
239671
  "stop"
239257
239672
  ];
239258
- var LifecycleHookEventSchema = z22.enum(ORBIT_LIFECYCLE_HOOK_EVENTS);
239259
- var LifecycleHookCommandSchema = z22.object({
239260
- command: z22.string().trim().min(1).max(2e4),
239673
+ var LifecycleHookEventSchema = z4.enum(ORBIT_LIFECYCLE_HOOK_EVENTS);
239674
+ var LifecycleHookCommandSchema = z4.object({
239675
+ command: z4.string().trim().min(1).max(2e4),
239261
239676
  /** Safe glob matched against the tool name, agent role, or lifecycle subject. */
239262
- matcher: z22.string().trim().min(1).max(256).optional(),
239263
- timeoutMs: z22.number().int().min(100).max(6e5).default(3e4),
239264
- onFailure: z22.enum(["block", "warn", "ignore"]).default("warn")
239677
+ matcher: z4.string().trim().min(1).max(256).optional(),
239678
+ timeoutMs: z4.number().int().min(100).max(6e5).default(3e4),
239679
+ onFailure: z4.enum(["block", "warn", "ignore"]).default("warn")
239265
239680
  });
239266
- var LifecycleHooksSchema = z22.object(
239681
+ var LifecycleHooksSchema = z4.object(
239267
239682
  Object.fromEntries(
239268
239683
  ORBIT_LIFECYCLE_HOOK_EVENTS.map((event) => [
239269
239684
  event,
239270
- z22.array(LifecycleHookCommandSchema).max(16).optional()
239685
+ z4.array(LifecycleHookCommandSchema).max(16).optional()
239271
239686
  ])
239272
239687
  )
239273
239688
  ).strict();
239274
- var EnvironmentVariableNameSchema = z22.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
239275
- var HttpHeaderNameSchema = z22.string().max(256).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/);
239276
- var HttpHeaderValueSchema = z22.string().max(16384).refine((value) => !/[\r\n]/.test(value));
239277
- var HttpHeadersSchema = z22.record(HttpHeaderNameSchema, HttpHeaderValueSchema).superRefine((value, context) => {
239689
+ var EnvironmentVariableNameSchema = z4.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
239690
+ var HttpHeaderNameSchema = z4.string().max(256).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/);
239691
+ var HttpHeaderValueSchema = z4.string().max(16384).refine((value) => !/[\r\n]/.test(value));
239692
+ var HttpHeadersSchema = z4.record(HttpHeaderNameSchema, HttpHeaderValueSchema).superRefine((value, context) => {
239278
239693
  if (Object.keys(value).length > 200) {
239279
239694
  context.addIssue({
239280
239695
  code: "custom",
@@ -239282,7 +239697,7 @@ var HttpHeadersSchema = z22.record(HttpHeaderNameSchema, HttpHeaderValueSchema).
239282
239697
  });
239283
239698
  }
239284
239699
  });
239285
- var ModelKindSchema = z22.enum([
239700
+ var ModelKindSchema = z4.enum([
239286
239701
  "chat",
239287
239702
  "embedding",
239288
239703
  "image",
@@ -239292,25 +239707,25 @@ var ModelKindSchema = z22.enum([
239292
239707
  "rerank",
239293
239708
  "unknown"
239294
239709
  ]);
239295
- var ModelCapabilitiesConfigSchema = z22.object({
239296
- streaming: z22.boolean().optional(),
239297
- toolCalls: z22.boolean().optional(),
239298
- jsonMode: z22.boolean().optional(),
239299
- thinking: z22.boolean().optional(),
239300
- vision: z22.boolean().optional(),
239301
- promptCaching: z22.boolean().optional(),
239302
- maxContextTokens: z22.number().int().positive().max(1e7).optional(),
239303
- maxOutputTokens: z22.number().int().positive().max(1e7).optional(),
239710
+ var ModelCapabilitiesConfigSchema = z4.object({
239711
+ streaming: z4.boolean().optional(),
239712
+ toolCalls: z4.boolean().optional(),
239713
+ jsonMode: z4.boolean().optional(),
239714
+ thinking: z4.boolean().optional(),
239715
+ vision: z4.boolean().optional(),
239716
+ promptCaching: z4.boolean().optional(),
239717
+ maxContextTokens: z4.number().int().positive().max(1e7).optional(),
239718
+ maxOutputTokens: z4.number().int().positive().max(1e7).optional(),
239304
239719
  kind: ModelKindSchema.optional(),
239305
- inputModalities: z22.array(z22.string().min(1).max(64)).max(16).optional(),
239306
- outputModalities: z22.array(z22.string().min(1).max(64)).max(16).optional(),
239307
- apiFormats: z22.array(z22.enum(["chat-completions", "responses", "anthropic"])).max(4).optional(),
239308
- reasoningEfforts: z22.array(z22.enum(["low", "medium", "high", "xhigh", "max"])).max(5).optional(),
239309
- parallelToolCalls: z22.boolean().optional(),
239310
- modelVersion: z22.string().min(1).max(256).optional(),
239311
- effectiveContextWindowPercent: z22.number().positive().max(1).optional()
239720
+ inputModalities: z4.array(z4.string().min(1).max(64)).max(16).optional(),
239721
+ outputModalities: z4.array(z4.string().min(1).max(64)).max(16).optional(),
239722
+ apiFormats: z4.array(z4.enum(["chat-completions", "responses", "anthropic"])).max(4).optional(),
239723
+ reasoningEfforts: z4.array(z4.enum(["low", "medium", "high", "xhigh", "max"])).max(5).optional(),
239724
+ parallelToolCalls: z4.boolean().optional(),
239725
+ modelVersion: z4.string().min(1).max(256).optional(),
239726
+ effectiveContextWindowPercent: z4.number().positive().max(1).optional()
239312
239727
  });
239313
- var ModelCapabilitiesMapSchema = z22.record(z22.string().min(1).max(1024), ModelCapabilitiesConfigSchema).superRefine((value, context) => {
239728
+ var ModelCapabilitiesMapSchema = z4.record(z4.string().min(1).max(1024), ModelCapabilitiesConfigSchema).superRefine((value, context) => {
239314
239729
  if (Object.keys(value).length > 1e3) {
239315
239730
  context.addIssue({
239316
239731
  code: "custom",
@@ -239318,7 +239733,7 @@ var ModelCapabilitiesMapSchema = z22.record(z22.string().min(1).max(1024), Model
239318
239733
  });
239319
239734
  }
239320
239735
  });
239321
- var ExtraBodySchema = z22.record(z22.unknown()).superRefine((value, context) => {
239736
+ var ExtraBodySchema = z4.record(z4.unknown()).superRefine((value, context) => {
239322
239737
  if (Object.keys(value).length > 1e3) {
239323
239738
  context.addIssue({
239324
239739
  code: "custom",
@@ -239326,8 +239741,8 @@ var ExtraBodySchema = z22.record(z22.unknown()).superRefine((value, context) =>
239326
239741
  });
239327
239742
  }
239328
239743
  });
239329
- var ProviderConfigSchema = z22.object({
239330
- type: z22.enum([
239744
+ var ProviderConfigSchema = z4.object({
239745
+ type: z4.enum([
239331
239746
  "openai",
239332
239747
  "anthropic",
239333
239748
  "openai-compatible",
@@ -239335,24 +239750,24 @@ var ProviderConfigSchema = z22.object({
239335
239750
  "deepseek",
239336
239751
  "ollama"
239337
239752
  ]),
239338
- baseUrl: z22.string().url().max(4096).optional(),
239753
+ baseUrl: z4.string().url().max(4096).optional(),
239339
239754
  apiKeyEnv: EnvironmentVariableNameSchema.optional(),
239340
- apiKey: z22.string().min(1).max(16384).optional(),
239755
+ apiKey: z4.string().min(1).max(16384).optional(),
239341
239756
  apiKeyHeader: HttpHeaderNameSchema.optional(),
239342
- apiKeyPrefix: z22.string().max(1024).refine((value) => !/[\r\n]/.test(value)).optional(),
239757
+ apiKeyPrefix: z4.string().max(1024).refine((value) => !/[\r\n]/.test(value)).optional(),
239343
239758
  headers: HttpHeadersSchema.optional(),
239344
- models: z22.array(z22.string().min(1).max(1024)).max(1e3).optional(),
239345
- requestTimeoutMs: z22.number().int().min(1e3).max(6e5).optional(),
239346
- streamTimeoutMs: z22.number().int().min(1e3).max(6e5).optional(),
239347
- totalTimeoutMs: z22.number().int().min(1e3).max(9e5).optional(),
239348
- maxRetries: z22.number().int().min(0).max(5).optional(),
239349
- disablePreheat: z22.boolean().optional(),
239350
- deepSeekApiFormat: z22.enum(["auto", "chat-completions", "responses", "anthropic"]).optional(),
239759
+ models: z4.array(z4.string().min(1).max(1024)).max(1e3).optional(),
239760
+ requestTimeoutMs: z4.number().int().min(1e3).max(6e5).optional(),
239761
+ streamTimeoutMs: z4.number().int().min(1e3).max(6e5).optional(),
239762
+ totalTimeoutMs: z4.number().int().min(1e3).max(9e5).optional(),
239763
+ maxRetries: z4.number().int().min(0).max(5).optional(),
239764
+ disablePreheat: z4.boolean().optional(),
239765
+ deepSeekApiFormat: z4.enum(["auto", "chat-completions", "responses", "anthropic"]).optional(),
239351
239766
  extraBody: ExtraBodySchema.optional(),
239352
239767
  capabilities: ModelCapabilitiesConfigSchema.optional(),
239353
239768
  modelCapabilities: ModelCapabilitiesMapSchema.optional()
239354
239769
  });
239355
- var ProvidersSchema = z22.record(z22.string().min(1).max(256), ProviderConfigSchema).superRefine((value, context) => {
239770
+ var ProvidersSchema = z4.record(z4.string().min(1).max(256), ProviderConfigSchema).superRefine((value, context) => {
239356
239771
  if (Object.keys(value).length > 100) {
239357
239772
  context.addIssue({
239358
239773
  code: "custom",
@@ -239360,34 +239775,34 @@ var ProvidersSchema = z22.record(z22.string().min(1).max(256), ProviderConfigSch
239360
239775
  });
239361
239776
  }
239362
239777
  });
239363
- var McpServerConfigBaseSchema = z22.object({
239364
- transport: z22.enum(["stdio", "streamable-http"]).default("stdio"),
239365
- command: z22.string().min(1).max(4096).optional(),
239366
- args: z22.array(z22.string().max(2e4)).max(200).default([]),
239367
- env: z22.record(EnvironmentVariableNameSchema, z22.string().max(1e5)).optional(),
239368
- inheritEnv: z22.array(EnvironmentVariableNameSchema).max(200).default([]),
239369
- url: z22.string().url().max(4096).optional(),
239778
+ var McpServerConfigBaseSchema = z4.object({
239779
+ transport: z4.enum(["stdio", "streamable-http"]).default("stdio"),
239780
+ command: z4.string().min(1).max(4096).optional(),
239781
+ args: z4.array(z4.string().max(2e4)).max(200).default([]),
239782
+ env: z4.record(EnvironmentVariableNameSchema, z4.string().max(1e5)).optional(),
239783
+ inheritEnv: z4.array(EnvironmentVariableNameSchema).max(200).default([]),
239784
+ url: z4.string().url().max(4096).optional(),
239370
239785
  headers: HttpHeadersSchema.default({}),
239371
239786
  bearerTokenEnv: EnvironmentVariableNameSchema.optional(),
239372
- requestTimeoutMs: z22.number().int().min(1e3).max(6e5).optional(),
239373
- oauth: z22.object({
239374
- mode: z22.enum(["client_credentials", "authorization_code"]).default("client_credentials"),
239375
- tokenUrl: z22.string().url().max(4096),
239376
- authorizationUrl: z22.string().url().max(4096).optional(),
239787
+ requestTimeoutMs: z4.number().int().min(1e3).max(6e5).optional(),
239788
+ oauth: z4.object({
239789
+ mode: z4.enum(["client_credentials", "authorization_code"]).default("client_credentials"),
239790
+ tokenUrl: z4.string().url().max(4096),
239791
+ authorizationUrl: z4.string().url().max(4096).optional(),
239377
239792
  clientIdEnv: EnvironmentVariableNameSchema,
239378
239793
  clientSecretEnv: EnvironmentVariableNameSchema.optional(),
239379
- scope: z22.string().max(1e3).optional(),
239380
- audience: z22.string().max(1e3).optional()
239794
+ scope: z4.string().max(1e3).optional(),
239795
+ audience: z4.string().max(1e3).optional()
239381
239796
  }).optional(),
239382
- resources: z22.object({
239383
- enabled: z22.boolean().default(true)
239797
+ resources: z4.object({
239798
+ enabled: z4.boolean().default(true)
239384
239799
  }).default({ enabled: true }),
239385
- prompts: z22.object({
239386
- enabled: z22.boolean().default(true)
239800
+ prompts: z4.object({
239801
+ enabled: z4.boolean().default(true)
239387
239802
  }).default({ enabled: true }),
239388
- tools: z22.record(
239389
- z22.object({
239390
- risk: z22.enum(["read", "write", "execute", "dangerous", "network"]).default("execute")
239803
+ tools: z4.record(
239804
+ z4.object({
239805
+ risk: z4.enum(["read", "write", "execute", "dangerous", "network"]).default("execute")
239391
239806
  })
239392
239807
  ).default({})
239393
239808
  });
@@ -239437,7 +239852,7 @@ var McpServerConfigSchema = McpServerConfigBaseSchema.superRefine(
239437
239852
  }
239438
239853
  }
239439
239854
  );
239440
- var McpServersSchema = z22.record(z22.string().min(1).max(256), McpServerConfigSchema).superRefine((value, context) => {
239855
+ var McpServersSchema = z4.record(z4.string().min(1).max(256), McpServerConfigSchema).superRefine((value, context) => {
239441
239856
  if (Object.keys(value).length > 100) {
239442
239857
  context.addIssue({
239443
239858
  code: "custom",
@@ -239445,20 +239860,20 @@ var McpServersSchema = z22.record(z22.string().min(1).max(256), McpServerConfigS
239445
239860
  });
239446
239861
  }
239447
239862
  });
239448
- var ModelRateSchema = z22.object({
239449
- inputCostPer1M: z22.number().finite().nonnegative().default(0),
239450
- outputCostPer1M: z22.number().finite().nonnegative().default(0),
239451
- cacheReadCostPer1M: z22.number().finite().nonnegative().optional()
239863
+ var ModelRateSchema = z4.object({
239864
+ inputCostPer1M: z4.number().finite().nonnegative().default(0),
239865
+ outputCostPer1M: z4.number().finite().nonnegative().default(0),
239866
+ cacheReadCostPer1M: z4.number().finite().nonnegative().optional()
239452
239867
  });
239453
239868
  var ModelPriceSchema = ModelRateSchema.extend({
239454
- scheduled: z22.object({
239455
- effectiveAt: z22.string().datetime({ offset: true }),
239456
- peakHoursUtc: z22.array(z22.string().regex(/^\d{2}:\d{2}-\d{2}:\d{2}$/)).max(24),
239869
+ scheduled: z4.object({
239870
+ effectiveAt: z4.string().datetime({ offset: true }),
239871
+ peakHoursUtc: z4.array(z4.string().regex(/^\d{2}:\d{2}-\d{2}:\d{2}$/)).max(24),
239457
239872
  peak: ModelRateSchema,
239458
239873
  offPeak: ModelRateSchema
239459
239874
  }).optional()
239460
239875
  });
239461
- var PricingTableSchema = z22.record(z22.string().min(1).max(1024), ModelPriceSchema).superRefine((value, context) => {
239876
+ var PricingTableSchema = z4.record(z4.string().min(1).max(1024), ModelPriceSchema).superRefine((value, context) => {
239462
239877
  if (Object.keys(value).length > 1e4) {
239463
239878
  context.addIssue({
239464
239879
  code: "custom",
@@ -239466,38 +239881,38 @@ var PricingTableSchema = z22.record(z22.string().min(1).max(1024), ModelPriceSch
239466
239881
  });
239467
239882
  }
239468
239883
  });
239469
- var ConfigSchema = z22.object({
239470
- schemaVersion: z22.literal(ORBIT_CONFIG_SCHEMA_VERSION).default(1),
239471
- name: z22.string().min(1).max(256).default("orbit-project"),
239472
- editor: z22.string().min(1).max(4096).default("notepad.exe"),
239473
- autoCommit: z22.boolean().default(false),
239884
+ var ConfigSchema = z4.object({
239885
+ schemaVersion: z4.literal(ORBIT_CONFIG_SCHEMA_VERSION).default(1),
239886
+ name: z4.string().min(1).max(256).default("orbit-project"),
239887
+ editor: z4.string().min(1).max(4096).default("notepad.exe"),
239888
+ autoCommit: z4.boolean().default(false),
239474
239889
  language: OrbitLanguageSchema.default("en"),
239475
- security: z22.object({
239476
- trustProjectExecutables: z22.boolean().default(false),
239477
- encryptCheckpoints: z22.boolean().default(true)
239890
+ security: z4.object({
239891
+ trustProjectExecutables: z4.boolean().default(false),
239892
+ encryptCheckpoints: z4.boolean().default(true)
239478
239893
  }).default({}),
239479
- provider: z22.object({
239480
- default: z22.string().min(1).max(256).default("deepseek"),
239481
- embedding: z22.string().min(1).max(256).optional()
239894
+ provider: z4.object({
239895
+ default: z4.string().min(1).max(256).default("deepseek"),
239896
+ embedding: z4.string().min(1).max(256).optional()
239482
239897
  }).default({}),
239483
- models: z22.object({
239484
- default: z22.string().min(1).max(1024).default("deepseek-v4-flash"),
239485
- fast: z22.string().min(1).max(1024).default("deepseek-v4-flash"),
239486
- planner: z22.string().min(1).max(1024).default("deepseek-v4-pro"),
239487
- coder: z22.string().min(1).max(1024).default("deepseek-v4-pro"),
239488
- reviewer: z22.string().min(1).max(1024).default("deepseek-v4-pro"),
239489
- summarizer: z22.string().min(1).max(1024).default("deepseek-v4-flash"),
239490
- embedding: z22.string().min(1).max(1024).default("text-embedding-3-small")
239898
+ models: z4.object({
239899
+ default: z4.string().min(1).max(1024).default("deepseek-v4-flash"),
239900
+ fast: z4.string().min(1).max(1024).default("deepseek-v4-flash"),
239901
+ planner: z4.string().min(1).max(1024).default("deepseek-v4-pro"),
239902
+ coder: z4.string().min(1).max(1024).default("deepseek-v4-pro"),
239903
+ reviewer: z4.string().min(1).max(1024).default("deepseek-v4-pro"),
239904
+ summarizer: z4.string().min(1).max(1024).default("deepseek-v4-flash"),
239905
+ embedding: z4.string().min(1).max(1024).default("text-embedding-3-small")
239491
239906
  }).default({}),
239492
239907
  providers: ProvidersSchema.default({}),
239493
- permissions: z22.object({
239494
- mode: z22.enum(["strict", "normal", "auto", "plan"]).default("normal"),
239495
- allowRead: z22.boolean().default(true),
239496
- requireApprovalForWrite: z22.boolean().default(true),
239497
- requireApprovalForBash: z22.boolean().default(true),
239498
- blockDangerousCommands: z22.boolean().default(true),
239499
- protectSecrets: z22.boolean().default(true),
239500
- protectedPaths: z22.array(z22.string().min(1).max(4096)).max(1e3).default([
239908
+ permissions: z4.object({
239909
+ mode: z4.enum(["strict", "normal", "auto", "plan"]).default("normal"),
239910
+ allowRead: z4.boolean().default(true),
239911
+ requireApprovalForWrite: z4.boolean().default(true),
239912
+ requireApprovalForBash: z4.boolean().default(true),
239913
+ blockDangerousCommands: z4.boolean().default(true),
239914
+ protectSecrets: z4.boolean().default(true),
239915
+ protectedPaths: z4.array(z4.string().min(1).max(4096)).max(1e3).default([
239501
239916
  ".env",
239502
239917
  ".env.*",
239503
239918
  ".git/**",
@@ -239519,11 +239934,11 @@ var ConfigSchema = z22.object({
239519
239934
  "**/*credential*"
239520
239935
  ])
239521
239936
  }).default({}),
239522
- context: z22.object({
239523
- maxFilesToIndex: z22.number().int().min(1).max(1e5).default(5e3),
239524
- maxFileSizeKb: z22.number().int().min(1).max(102400).default(512),
239525
- autoCodebaseRetrieval: z22.boolean().default(true),
239526
- ignore: z22.array(z22.string().min(1).max(4096)).max(2e3).default([
239937
+ context: z4.object({
239938
+ maxFilesToIndex: z4.number().int().min(1).max(1e5).default(5e3),
239939
+ maxFileSizeKb: z4.number().int().min(1).max(102400).default(512),
239940
+ autoCodebaseRetrieval: z4.boolean().default(true),
239941
+ ignore: z4.array(z4.string().min(1).max(4096)).max(2e3).default([
239527
239942
  "node_modules/**",
239528
239943
  "dist/**",
239529
239944
  "build/**",
@@ -239544,103 +239959,104 @@ var ConfigSchema = z22.object({
239544
239959
  "**/.rustup/**",
239545
239960
  "**/.orbit/**"
239546
239961
  ]),
239547
- autoCompact: z22.boolean().default(true),
239548
- compactThreshold: z22.number().finite().min(0.1).max(1).default(0.75),
239549
- autoRepair: z22.boolean().default(false),
239550
- maxRepairAttempts: z22.number().int().min(0).max(10).default(3),
239551
- testCommands: z22.array(z22.string().max(2e4)).max(100).default([])
239962
+ autoCompact: z4.boolean().default(true),
239963
+ compactThreshold: z4.number().finite().min(0.1).max(1).default(0.75),
239964
+ autoRepair: z4.boolean().default(false),
239965
+ maxRepairAttempts: z4.number().int().min(0).max(10).default(3),
239966
+ testCommands: z4.array(z4.string().max(2e4)).max(100).default([])
239552
239967
  }).default({}),
239553
- agent: z22.object({
239554
- maxIterations: z22.number().int().min(1).max(MAX_AGENT_MAX_ITERATIONS).default(DEFAULT_AGENT_MAX_ITERATIONS),
239555
- fastMaxOutputTokens: z22.number().int().min(256).max(384e3).default(32768),
239556
- maxOutputTokens: z22.number().int().min(256).max(384e3).default(16384),
239557
- teamPreset: z22.enum(["fast", "balanced", "thorough"]).default("balanced"),
239558
- maxReviewAttempts: z22.number().int().min(1).max(10).default(3),
239559
- maxReviewConcurrency: z22.number().int().min(1).max(8).default(2)
239968
+ agent: z4.object({
239969
+ maxIterations: z4.number().int().min(1).max(MAX_AGENT_MAX_ITERATIONS).default(DEFAULT_AGENT_MAX_ITERATIONS),
239970
+ fastMaxOutputTokens: z4.number().int().min(256).max(384e3).default(32768),
239971
+ maxOutputTokens: z4.number().int().min(256).max(384e3).default(16384),
239972
+ teamPreset: z4.enum(["fast", "balanced", "thorough"]).default("balanced"),
239973
+ maxReviewAttempts: z4.number().int().min(1).max(10).default(3),
239974
+ maxReviewConcurrency: z4.number().int().min(1).max(8).default(2)
239560
239975
  }).default({}),
239561
- autocomplete: z22.object({
239562
- enabled: z22.boolean().default(true),
239563
- provider: z22.string().min(1).max(256).default("ollama"),
239564
- model: z22.string().min(1).max(1024).default("qwen2.5-coder:1.5b"),
239565
- debounceMs: z22.number().int().min(0).max(1e4).default(150),
239566
- speculative: z22.object({
239567
- enabled: z22.boolean().default(false),
239568
- provider: z22.string().min(1).max(256).default("ollama"),
239569
- model: z22.string().min(1).max(1024).default("qwen2.5-coder:0.5b"),
239570
- timeoutMs: z22.number().int().min(0).max(1e4).default(150)
239976
+ agents: AgentProfileSettingsSchema,
239977
+ autocomplete: z4.object({
239978
+ enabled: z4.boolean().default(true),
239979
+ provider: z4.string().min(1).max(256).default("ollama"),
239980
+ model: z4.string().min(1).max(1024).default("qwen2.5-coder:1.5b"),
239981
+ debounceMs: z4.number().int().min(0).max(1e4).default(150),
239982
+ speculative: z4.object({
239983
+ enabled: z4.boolean().default(false),
239984
+ provider: z4.string().min(1).max(256).default("ollama"),
239985
+ model: z4.string().min(1).max(1024).default("qwen2.5-coder:0.5b"),
239986
+ timeoutMs: z4.number().int().min(0).max(1e4).default(150)
239571
239987
  }).optional()
239572
239988
  }).default({}),
239573
- tui: z22.object({
239574
- mouse: z22.boolean().default(true),
239575
- scrollSpeed: z22.number().int().min(1).max(100).default(50)
239989
+ tui: z4.object({
239990
+ mouse: z4.boolean().default(true),
239991
+ scrollSpeed: z4.number().int().min(1).max(100).default(50)
239576
239992
  }).default({}),
239577
- tools: z22.object({
239578
- bash: z22.object({
239579
- enabled: z22.boolean().default(true),
239580
- timeoutMs: z22.number().int().min(1e3).max(6e5).default(12e4)
239993
+ tools: z4.object({
239994
+ bash: z4.object({
239995
+ enabled: z4.boolean().default(true),
239996
+ timeoutMs: z4.number().int().min(1e3).max(6e5).default(12e4)
239581
239997
  }).default({}),
239582
- backgroundTasks: z22.object({
239583
- maxConcurrentTasks: z22.number().int().min(1).max(32).default(8),
239584
- maxRetainedTasks: z22.number().int().min(1).max(256).default(64),
239585
- maxOutputBytes: z22.number().int().min(16 * 1024).max(16 * 1024 * 1024).default(1024 * 1024),
239586
- terminateGraceMs: z22.number().int().min(100).max(3e4).default(2e3),
239587
- awaitOnCompletion: z22.boolean().default(true),
239588
- completionWaitMs: z22.number().int().min(1e3).max(3e4).default(3e4)
239998
+ backgroundTasks: z4.object({
239999
+ maxConcurrentTasks: z4.number().int().min(1).max(32).default(8),
240000
+ maxRetainedTasks: z4.number().int().min(1).max(256).default(64),
240001
+ maxOutputBytes: z4.number().int().min(16 * 1024).max(16 * 1024 * 1024).default(1024 * 1024),
240002
+ terminateGraceMs: z4.number().int().min(100).max(3e4).default(2e3),
240003
+ awaitOnCompletion: z4.boolean().default(true),
240004
+ completionWaitMs: z4.number().int().min(1e3).max(3e4).default(3e4)
239589
240005
  }).refine((value) => value.maxRetainedTasks >= value.maxConcurrentTasks, {
239590
240006
  message: "maxRetainedTasks must be greater than or equal to maxConcurrentTasks.",
239591
240007
  path: ["maxRetainedTasks"]
239592
240008
  }).default({}),
239593
- webSearch: z22.object({
239594
- enabled: z22.boolean().default(true),
239595
- provider: z22.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).default("auto"),
239596
- searxngUrls: z22.array(z22.string().url().max(4096)).max(20).default([]),
240009
+ webSearch: z4.object({
240010
+ enabled: z4.boolean().default(true),
240011
+ provider: z4.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).default("auto"),
240012
+ searxngUrls: z4.array(z4.string().url().max(4096)).max(20).default([]),
239597
240013
  tavilyApiKeyEnv: EnvironmentVariableNameSchema.default("TAVILY_API_KEY"),
239598
- tavilyBaseUrl: z22.string().url().max(4096).default("https://api.tavily.com/search"),
239599
- timeoutMs: z22.number().int().min(1e3).max(3e4).default(8e3),
239600
- maxResults: z22.number().int().min(1).max(20).default(8)
240014
+ tavilyBaseUrl: z4.string().url().max(4096).default("https://api.tavily.com/search"),
240015
+ timeoutMs: z4.number().int().min(1e3).max(3e4).default(8e3),
240016
+ maxResults: z4.number().int().min(1).max(20).default(8)
239601
240017
  }).default({}),
239602
- mcp: z22.object({
239603
- enabled: z22.boolean().default(false)
240018
+ mcp: z4.object({
240019
+ enabled: z4.boolean().default(false)
239604
240020
  }).default({})
239605
240021
  }).default({}),
239606
- skills: z22.object({
239607
- enabled: z22.boolean().default(true),
239608
- directories: z22.array(z22.string().min(1).max(4096)).max(50).default([
240022
+ skills: z4.object({
240023
+ enabled: z4.boolean().default(true),
240024
+ directories: z4.array(z4.string().min(1).max(4096)).max(50).default([
239609
240025
  ".orbit/skills",
239610
240026
  ".agents/skills",
239611
240027
  ".claude/skills",
239612
240028
  "~/.claude/skills",
239613
240029
  "~/.orbit/skills"
239614
240030
  ]),
239615
- activation: z22.enum(["explicit", "auto"]).default("auto"),
239616
- maxActive: z22.number().int().min(0).max(8).default(3),
239617
- disabled: z22.array(z22.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).max(200).default([]),
239618
- maxSkillBytes: z22.number().int().min(512).max(2e5).default(24e3),
239619
- maxAutoSkillBytes: z22.number().int().min(512).max(2e5).default(8e3)
240031
+ activation: z4.enum(["explicit", "auto"]).default("auto"),
240032
+ maxActive: z4.number().int().min(0).max(8).default(3),
240033
+ disabled: z4.array(z4.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).max(200).default([]),
240034
+ maxSkillBytes: z4.number().int().min(512).max(2e5).default(24e3),
240035
+ maxAutoSkillBytes: z4.number().int().min(512).max(2e5).default(8e3)
239620
240036
  }).default({}),
239621
240037
  mcpServers: McpServersSchema.default({}),
239622
- managedPolicy: z22.object({
239623
- allowedProviders: z22.array(z22.string().min(1).max(1024)).max(1e3).optional(),
239624
- allowedModels: z22.array(z22.string().min(1).max(1024)).max(1e3).optional(),
239625
- minimumPermissionMode: z22.enum(["auto", "normal", "strict", "plan"]).optional(),
239626
- requireWriteApproval: z22.boolean().default(false),
239627
- requireBashApproval: z22.boolean().default(false),
239628
- disableWebSearch: z22.boolean().default(false),
239629
- disableMcp: z22.boolean().default(false),
239630
- maxIterations: z22.number().int().positive().max(MAX_AGENT_MAX_ITERATIONS).optional()
240038
+ managedPolicy: z4.object({
240039
+ allowedProviders: z4.array(z4.string().min(1).max(1024)).max(1e3).optional(),
240040
+ allowedModels: z4.array(z4.string().min(1).max(1024)).max(1e3).optional(),
240041
+ minimumPermissionMode: z4.enum(["auto", "normal", "strict", "plan"]).optional(),
240042
+ requireWriteApproval: z4.boolean().default(false),
240043
+ requireBashApproval: z4.boolean().default(false),
240044
+ disableWebSearch: z4.boolean().default(false),
240045
+ disableMcp: z4.boolean().default(false),
240046
+ maxIterations: z4.number().int().positive().max(MAX_AGENT_MAX_ITERATIONS).optional()
239631
240047
  }).optional(),
239632
- hooks: z22.object({
240048
+ hooks: z4.object({
239633
240049
  /** @deprecated Use lifecycle.preToolUse with a write-tool matcher. */
239634
- preEdit: z22.string().max(2e4).optional(),
240050
+ preEdit: z4.string().max(2e4).optional(),
239635
240051
  /** @deprecated Use lifecycle.postToolUse with a write-tool matcher. */
239636
- postEdit: z22.string().max(2e4).optional(),
240052
+ postEdit: z4.string().max(2e4).optional(),
239637
240053
  lifecycle: LifecycleHooksSchema.optional()
239638
240054
  }).strict().default({}),
239639
240055
  pricing: PricingTableSchema.default({}),
239640
- budgetLimit: z22.number().finite().nonnegative().default(10),
239641
- session: z22.object({
239642
- store: z22.enum(["sqlite", "jsonl"]).default("jsonl"),
239643
- path: z22.string().min(1).max(4096).default(".orbit/sessions")
240056
+ budgetLimit: z4.number().finite().nonnegative().default(10),
240057
+ session: z4.object({
240058
+ store: z4.enum(["sqlite", "jsonl"]).default("jsonl"),
240059
+ path: z4.string().min(1).max(4096).default(".orbit/sessions")
239644
240060
  }).default({})
239645
240061
  });
239646
240062
  var DEFAULT_CONFIG = {
@@ -239778,6 +240194,17 @@ var DEFAULT_CONFIG = {
239778
240194
  maxReviewAttempts: 3,
239779
240195
  maxReviewConcurrency: 2
239780
240196
  },
240197
+ agents: {
240198
+ enabled: true,
240199
+ directories: [
240200
+ ".agents/agents",
240201
+ ".orbit/agents",
240202
+ ".claude/agents",
240203
+ "~/.orbit/agents",
240204
+ "~/.claude/agents"
240205
+ ],
240206
+ maxProfiles: 32
240207
+ },
239781
240208
  tools: {
239782
240209
  bash: {
239783
240210
  enabled: true,
@@ -239878,7 +240305,7 @@ var DEFAULT_CONFIG = {
239878
240305
  scrollSpeed: 50
239879
240306
  }
239880
240307
  };
239881
- var EncodedCredentialKeySchema = z32.string().trim().refine((value) => Buffer.from(value, "base64").length === 32);
240308
+ var EncodedCredentialKeySchema = z5.string().trim().refine((value) => Buffer.from(value, "base64").length === 32);
239882
240309
  var MacOSKeychainKeyStore = class {
239883
240310
  service;
239884
240311
  account;
@@ -240035,15 +240462,15 @@ function isMissingKeychainItem(error) {
240035
240462
  function isUnavailableSecretService(error) {
240036
240463
  return typeof error === "object" && error !== null && ("code" in error && error.code === "ENOENT" || "status" in error && (error.status === 1 || error.status === 2));
240037
240464
  }
240038
- var CredentialKeySchema = z4.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).refine(
240465
+ var CredentialKeySchema = z6.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).refine(
240039
240466
  (value) => value !== "__proto__" && value !== "constructor" && value !== "prototype"
240040
240467
  );
240041
- var CredentialValueSchema = z4.string().min(1).max(16384).refine((value) => !/[\r\n]/.test(value));
240042
- var SecretsFileSchema = z4.record(CredentialKeySchema, z4.string());
240043
- var EncryptedSecretSchema = z4.object({
240044
- iv: z4.string().regex(/^[0-9a-f]{24}$/i),
240045
- encrypted: z4.string().regex(/^[0-9a-f]*$/i),
240046
- tag: z4.string().regex(/^[0-9a-f]{32}$/i)
240468
+ var CredentialValueSchema = z6.string().min(1).max(16384).refine((value) => !/[\r\n]/.test(value));
240469
+ var SecretsFileSchema = z6.record(CredentialKeySchema, z6.string());
240470
+ var EncryptedSecretSchema = z6.object({
240471
+ iv: z6.string().regex(/^[0-9a-f]{24}$/i),
240472
+ encrypted: z6.string().regex(/^[0-9a-f]*$/i),
240473
+ tag: z6.string().regex(/^[0-9a-f]{32}$/i)
240047
240474
  });
240048
240475
  var MAX_SECRETS_FILE_BYTES = 2 * 1024 * 1024;
240049
240476
  var MAX_MASTER_KEY_FILE_BYTES = 1024;
@@ -240060,10 +240487,10 @@ var CredentialsManager = class {
240060
240487
  fallbackKey;
240061
240488
  registeredSecrets = /* @__PURE__ */ new Set();
240062
240489
  constructor(options = {}) {
240063
- this.orbitDir = options.orbitDir ?? join2(homedir(), ".orbit");
240064
- this.secretsPath = join2(this.orbitDir, "secrets.json");
240065
- this.masterKeyPath = join2(this.orbitDir, "master.key");
240066
- this.mutationLockPath = join2(this.orbitDir, "secrets.lock");
240490
+ this.orbitDir = options.orbitDir ?? join22(homedir2(), ".orbit");
240491
+ this.secretsPath = join22(this.orbitDir, "secrets.json");
240492
+ this.masterKeyPath = join22(this.orbitDir, "master.key");
240493
+ this.mutationLockPath = join22(this.orbitDir, "secrets.lock");
240067
240494
  const platform = options.platform ?? process.platform;
240068
240495
  this.isWindows = platform === "win32";
240069
240496
  this.keyStore = options.keyStore === void 0 ? platform === "darwin" ? new MacOSKeychainKeyStore() : platform === "linux" ? new LinuxSecretServiceKeyStore() : null : options.keyStore;
@@ -240208,9 +240635,9 @@ var CredentialsManager = class {
240208
240635
  try {
240209
240636
  const raw = readBoundedRegularFile(this.mutationLockPath, 4096);
240210
240637
  if (raw === void 0) return true;
240211
- const payload = z4.object({
240212
- pid: z4.number().int().positive(),
240213
- createdAt: z4.string().datetime()
240638
+ const payload = z6.object({
240639
+ pid: z6.number().int().positive(),
240640
+ createdAt: z6.string().datetime()
240214
240641
  }).parse(JSON.parse(raw));
240215
240642
  let processAlive = true;
240216
240643
  try {
@@ -240405,19 +240832,19 @@ var CredentialsManager = class {
240405
240832
  chmodSync2(filePath, 384);
240406
240833
  }
240407
240834
  };
240408
- var ProviderProfileIdSchema = z5.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/);
240835
+ var ProviderProfileIdSchema = z7.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/);
240409
240836
  var MAX_PROVIDER_PROFILES_BYTES = 1024 * 1024;
240410
- var ProviderProfileSchema = z5.object({
240837
+ var ProviderProfileSchema = z7.object({
240411
240838
  id: ProviderProfileIdSchema,
240412
- name: z5.string().trim().min(1).max(120),
240839
+ name: z7.string().trim().min(1).max(120),
240413
240840
  config: ProviderConfigSchema.omit({ apiKey: true }),
240414
- createdAt: z5.string().datetime(),
240415
- updatedAt: z5.string().datetime()
240841
+ createdAt: z7.string().datetime(),
240842
+ updatedAt: z7.string().datetime()
240416
240843
  });
240417
- var ProviderProfilesFileSchema = z5.object({
240418
- version: z5.literal(1).default(1),
240844
+ var ProviderProfilesFileSchema = z7.object({
240845
+ version: z7.literal(1).default(1),
240419
240846
  activeProvider: ProviderProfileIdSchema.optional(),
240420
- profiles: z5.array(ProviderProfileSchema).max(100)
240847
+ profiles: z7.array(ProviderProfileSchema).max(100)
240421
240848
  });
240422
240849
  var EMPTY_SNAPSHOT = {
240423
240850
  version: 1,
@@ -240428,8 +240855,8 @@ var ProviderProfileStore = class {
240428
240855
  profilePath;
240429
240856
  isWindows;
240430
240857
  constructor(options = {}) {
240431
- this.orbitDir = options.orbitDir ?? join22(homedir2(), ".orbit");
240432
- this.profilePath = join22(this.orbitDir, "providers.json");
240858
+ this.orbitDir = options.orbitDir ?? join3(homedir3(), ".orbit");
240859
+ this.profilePath = join3(this.orbitDir, "providers.json");
240433
240860
  this.isWindows = (options.platform ?? process.platform) === "win32";
240434
240861
  }
240435
240862
  read() {
@@ -240531,202 +240958,59 @@ var ProviderProfileStore = class {
240531
240958
  );
240532
240959
  }
240533
240960
  };
240534
- var MAX_MANAGED_POLICY_BYTES = 1024 * 1024;
240535
- var ManagedPolicySchema = z6.object({
240536
- schemaVersion: z6.literal(1),
240537
- allowedProviders: z6.array(z6.string().min(1).max(256)).max(100).optional(),
240538
- allowedModels: z6.array(z6.string().min(1).max(256)).max(500).optional(),
240539
- minimumPermissionMode: z6.enum(["auto", "normal", "strict", "plan"]).optional(),
240540
- requireWriteApproval: z6.boolean().default(true),
240541
- requireBashApproval: z6.boolean().default(true),
240542
- disableWebSearch: z6.boolean().default(false),
240543
- disableMcp: z6.boolean().default(false),
240544
- maxBudgetUsd: z6.number().finite().positive().max(1e6).optional(),
240545
- maxIterations: z6.number().int().positive().max(1e3).optional(),
240546
- protectedPaths: z6.array(z6.string().min(1).max(4096)).max(1e3).default([])
240547
- });
240548
- function loadManagedPolicy(filePath) {
240549
- const raw = readBoundedRegularFile(filePath, MAX_MANAGED_POLICY_BYTES, {
240550
- allowSymbolicLink: true
240551
- });
240552
- if (raw === void 0) {
240553
- throw new Error(`Managed policy file was not found: ${filePath}`);
240554
- }
240555
- const value = filePath.toLowerCase().endsWith(".json") ? JSON.parse(raw) : parseYaml(raw);
240556
- return ManagedPolicySchema.strict().parse(value);
240557
- }
240558
- function applyManagedPolicy(source, policy) {
240559
- const config = structuredClone(source);
240560
- let effectiveAllowedProviders = policy.allowedProviders;
240561
- if (policy.allowedProviders?.length) {
240562
- const allowed = new Set(
240563
- policy.allowedProviders.flatMap((id) => {
240564
- if (config.providers[id]) return [id];
240565
- if (config.providers.deepseek && (id === "deepseek-openai" || id === "deepseek-anthropic")) {
240566
- return ["deepseek"];
240567
- }
240568
- return [id];
240569
- })
240570
- );
240571
- effectiveAllowedProviders = [...allowed];
240572
- config.providers = Object.fromEntries(
240573
- Object.entries(config.providers).filter(([id]) => allowed.has(id))
240574
- );
240575
- if (!config.providers[config.provider.default]) {
240576
- const replacement = effectiveAllowedProviders.find(
240577
- (id) => config.providers[id]
240578
- );
240579
- if (!replacement) {
240580
- throw new Error(
240581
- "Managed policy does not allow any configured model provider."
240582
- );
240583
- }
240584
- config.provider.default = replacement;
240585
- }
240586
- if (config.provider.embedding && !config.providers[config.provider.embedding]) {
240587
- delete config.provider.embedding;
240588
- }
240589
- }
240590
- if (policy.allowedModels?.length) {
240591
- const allowed = new Set(policy.allowedModels);
240592
- const fallback = policy.allowedModels[0];
240593
- for (const key of [
240594
- "default",
240595
- "fast",
240596
- "planner",
240597
- "coder",
240598
- "reviewer",
240599
- "summarizer"
240600
- ]) {
240601
- if (!allowed.has(config.models[key])) config.models[key] = fallback;
240602
- }
240603
- for (const provider of Object.values(config.providers)) {
240604
- if (provider.models) {
240605
- provider.models = provider.models.filter((model) => allowed.has(model));
240606
- }
240607
- }
240608
- }
240609
- if (policy.minimumPermissionMode && permissionRank(config.permissions.mode) < permissionRank(policy.minimumPermissionMode)) {
240610
- config.permissions.mode = policy.minimumPermissionMode;
240611
- }
240612
- if (policy.requireWriteApproval) {
240613
- config.permissions.requireApprovalForWrite = true;
240614
- }
240615
- if (policy.requireBashApproval) {
240616
- config.permissions.requireApprovalForBash = true;
240617
- }
240618
- if (config.permissions.mode !== "auto" || policy.requireWriteApproval || policy.requireBashApproval) {
240619
- config.permissions.blockDangerousCommands = true;
240620
- config.permissions.protectSecrets = true;
240621
- }
240622
- config.permissions.protectedPaths = Array.from(
240623
- /* @__PURE__ */ new Set([...config.permissions.protectedPaths, ...policy.protectedPaths])
240624
- );
240625
- if (policy.disableWebSearch) config.tools.webSearch.enabled = false;
240626
- if (policy.disableMcp) config.tools.mcp.enabled = false;
240627
- if (policy.maxBudgetUsd !== void 0) {
240628
- config.budgetLimit = Math.min(config.budgetLimit, policy.maxBudgetUsd);
240629
- }
240630
- if (policy.maxIterations !== void 0) {
240631
- config.agent.maxIterations = Math.min(
240632
- config.agent.maxIterations,
240633
- policy.maxIterations
240634
- );
240635
- }
240636
- config.managedPolicy = {
240637
- allowedProviders: effectiveAllowedProviders,
240638
- allowedModels: policy.allowedModels,
240639
- minimumPermissionMode: policy.minimumPermissionMode,
240640
- requireWriteApproval: policy.requireWriteApproval,
240641
- requireBashApproval: policy.requireBashApproval,
240642
- disableWebSearch: policy.disableWebSearch,
240643
- disableMcp: policy.disableMcp,
240644
- maxIterations: policy.maxIterations
240645
- };
240646
- return config;
240647
- }
240648
- function validateManagedRuntimeChange(config, change) {
240649
- const policy = config.managedPolicy;
240650
- if (!policy) return void 0;
240651
- if (change.provider && policy.allowedProviders?.length && !policy.allowedProviders.includes(change.provider)) {
240652
- return `Managed policy does not allow provider ${change.provider}.`;
240653
- }
240654
- if (change.model && change.model !== "__auto__" && policy.allowedModels?.length && !policy.allowedModels.includes(change.model)) {
240655
- return `Managed policy does not allow model ${change.model}.`;
240656
- }
240657
- if (change.permissionMode && policy.minimumPermissionMode && permissionRank(change.permissionMode) < permissionRank(policy.minimumPermissionMode)) {
240658
- return `Managed policy requires ${policy.minimumPermissionMode} mode or stricter.`;
240659
- }
240660
- if (change.requireWriteApproval === false && policy.requireWriteApproval) {
240661
- return "Managed policy requires write approval.";
240662
- }
240663
- if (change.requireBashApproval === false && policy.requireBashApproval) {
240664
- return "Managed policy requires command approval.";
240665
- }
240666
- if (change.webSearchEnabled && policy.disableWebSearch) {
240667
- return "Managed policy disables web search.";
240668
- }
240669
- if (change.agentMaxIterations !== void 0 && policy.maxIterations !== void 0 && change.agentMaxIterations > policy.maxIterations) {
240670
- return `Managed policy limits agent runs to ${policy.maxIterations} iterations.`;
240671
- }
240672
- return void 0;
240673
- }
240674
- function permissionRank(mode) {
240675
- return { auto: 0, normal: 1, strict: 2, plan: 3 }[mode];
240676
- }
240677
240961
  var ORBIT_EXTENSION_MANIFEST_VERSION = 1;
240678
240962
  var MAX_MANIFEST_BYTES = 1024 * 1024;
240679
- var SemverSchema = z7.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/);
240680
- var ContributionNameSchema = z7.string().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/);
240681
- var CredentialEnvironmentNameSchema = z7.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
240682
- var RelativeContributionPathSchema = z7.string().min(1).max(4096).refine(
240963
+ var SemverSchema = z8.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/);
240964
+ var ContributionNameSchema = z8.string().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/);
240965
+ var CredentialEnvironmentNameSchema = z8.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
240966
+ var RelativeContributionPathSchema = z8.string().min(1).max(4096).refine(
240683
240967
  (value) => !value.includes("\0") && !/^(?:[A-Za-z]:[\\/]|[\\/])/.test(value) && !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(value),
240684
240968
  "Contribution paths must remain inside the extension directory."
240685
240969
  );
240686
- var NamedContributionSchema = z7.object({
240970
+ var NamedContributionSchema = z8.object({
240687
240971
  name: ContributionNameSchema,
240688
240972
  path: RelativeContributionPathSchema,
240689
- description: z7.string().trim().min(1).max(500).optional()
240973
+ description: z8.string().trim().min(1).max(500).optional()
240690
240974
  });
240691
- var ExtensionPermissionSchema = z7.object({
240692
- filesystem: z7.array(
240693
- z7.object({
240694
- mode: z7.enum(["read", "write"]),
240695
- scope: RelativeContributionPathSchema.or(z7.literal("*"))
240975
+ var ExtensionPermissionSchema = z8.object({
240976
+ filesystem: z8.array(
240977
+ z8.object({
240978
+ mode: z8.enum(["read", "write"]),
240979
+ scope: RelativeContributionPathSchema.or(z8.literal("*"))
240696
240980
  })
240697
240981
  ).max(128).default([]),
240698
- network: z7.array(
240699
- z7.string().min(1).max(253).regex(
240982
+ network: z8.array(
240983
+ z8.string().min(1).max(253).regex(
240700
240984
  /^(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(?:\.(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*$/,
240701
240985
  "Expected a hostname without a URL scheme, path, or credentials."
240702
240986
  )
240703
240987
  ).max(128).default([]),
240704
- process: z7.boolean().default(false),
240705
- credentials: z7.array(CredentialEnvironmentNameSchema).max(64).default([])
240988
+ process: z8.boolean().default(false),
240989
+ credentials: z8.array(CredentialEnvironmentNameSchema).max(64).default([])
240706
240990
  });
240707
- var OrbitExtensionManifestSchema = z7.object({
240708
- schemaVersion: z7.literal(ORBIT_EXTENSION_MANIFEST_VERSION),
240709
- id: z7.string().regex(/^[a-z0-9][a-z0-9._-]{1,127}$/),
240710
- displayName: z7.string().trim().min(1).max(200),
240991
+ var OrbitExtensionManifestSchema = z8.object({
240992
+ schemaVersion: z8.literal(ORBIT_EXTENSION_MANIFEST_VERSION),
240993
+ id: z8.string().regex(/^[a-z0-9][a-z0-9._-]{1,127}$/),
240994
+ displayName: z8.string().trim().min(1).max(200),
240711
240995
  version: SemverSchema,
240712
- description: z7.string().trim().max(2e3).optional(),
240713
- orbit: z7.object({
240996
+ description: z8.string().trim().max(2e3).optional(),
240997
+ orbit: z8.object({
240714
240998
  minVersion: SemverSchema,
240715
240999
  maxVersion: SemverSchema.optional()
240716
241000
  }),
240717
241001
  permissions: ExtensionPermissionSchema.default({}),
240718
- contributes: z7.object({
240719
- commands: z7.array(NamedContributionSchema).max(200).default([]),
240720
- skills: z7.array(NamedContributionSchema).max(200).default([]),
240721
- agents: z7.array(NamedContributionSchema).max(100).default([]),
240722
- tools: z7.array(
241002
+ contributes: z8.object({
241003
+ commands: z8.array(NamedContributionSchema).max(200).default([]),
241004
+ skills: z8.array(NamedContributionSchema).max(200).default([]),
241005
+ agents: z8.array(NamedContributionSchema).max(100).default([]),
241006
+ tools: z8.array(
240723
241007
  NamedContributionSchema.extend({
240724
- risk: z7.enum(["read", "write", "execute", "dangerous", "network"])
241008
+ risk: z8.enum(["read", "write", "execute", "dangerous", "network"])
240725
241009
  })
240726
241010
  ).max(200).default([]),
240727
- hooks: z7.array(
240728
- z7.object({
240729
- event: z7.enum([
241011
+ hooks: z8.array(
241012
+ z8.object({
241013
+ event: z8.enum([
240730
241014
  "session_start",
240731
241015
  "prompt_submit",
240732
241016
  "permission_request",
@@ -240739,11 +241023,11 @@ var OrbitExtensionManifestSchema = z7.object({
240739
241023
  "agent_end",
240740
241024
  "session_stop"
240741
241025
  ]),
240742
- command: z7.string().trim().min(1).max(4e3)
241026
+ command: z8.string().trim().min(1).max(4e3)
240743
241027
  })
240744
241028
  ).max(100).default([]),
240745
- mcpServers: z7.record(McpServerConfigBaseSchema.omit({ env: true })).default({}),
240746
- templates: z7.array(NamedContributionSchema).max(200).default([])
241029
+ mcpServers: z8.record(McpServerConfigBaseSchema.omit({ env: true })).default({}),
241030
+ templates: z8.array(NamedContributionSchema).max(200).default([])
240747
241031
  }).default({})
240748
241032
  });
240749
241033
  function loadOrbitExtensionManifest(cwd, manifestPath) {
@@ -240754,7 +241038,7 @@ function loadOrbitExtensionManifest(cwd, manifestPath) {
240754
241038
  const raw = extname(resolved).toLowerCase() === ".json" ? JSON.parse(text2) : parseYaml2(text2);
240755
241039
  return OrbitExtensionManifestSchema.parse(raw);
240756
241040
  }
240757
- var ExtensionDigestAlgorithmSchema = z8.enum([
241041
+ var ExtensionDigestAlgorithmSchema = z9.enum([
240758
241042
  "sha256-v1",
240759
241043
  "sha256-v2"
240760
241044
  ]);
@@ -240763,22 +241047,22 @@ var MAX_EXTENSION_TREE_BYTES = 256 * 1024 * 1024;
240763
241047
  var MAX_EXTENSION_TREE_ENTRIES = 1e4;
240764
241048
  var MAX_EXTENSION_TREE_DEPTH = 64;
240765
241049
  var MAX_EXTENSION_REGISTRY_BYTES = 1024 * 1024;
240766
- var InstalledExtensionIdSchema = z8.string().regex(/^[a-z0-9][a-z0-9._-]{1,127}$/);
240767
- var InstalledExtensionSchema = z8.object({
241050
+ var InstalledExtensionIdSchema = z9.string().regex(/^[a-z0-9][a-z0-9._-]{1,127}$/);
241051
+ var InstalledExtensionSchema = z9.object({
240768
241052
  id: InstalledExtensionIdSchema,
240769
- digest: z8.string().regex(/^[a-f0-9]{64}$/),
241053
+ digest: z9.string().regex(/^[a-f0-9]{64}$/),
240770
241054
  digestAlgorithm: ExtensionDigestAlgorithmSchema.default("sha256-v1"),
240771
- trusted: z8.boolean(),
240772
- path: z8.string(),
240773
- manifestFile: z8.string().min(1).max(4096).default("extension.yaml")
241055
+ trusted: z9.boolean(),
241056
+ path: z9.string(),
241057
+ manifestFile: z9.string().min(1).max(4096).default("extension.yaml")
240774
241058
  });
240775
- var ExtensionRegistrySchema = z8.object({
240776
- schemaVersion: z8.literal(1),
240777
- extensions: z8.array(InstalledExtensionSchema).max(500).default([])
241059
+ var ExtensionRegistrySchema = z9.object({
241060
+ schemaVersion: z9.literal(1),
241061
+ extensions: z9.array(InstalledExtensionSchema).max(500).default([])
240778
241062
  });
240779
241063
  function applyInstalledExtensionContributions(source, homeDirectory) {
240780
- const registryPath = join3(homeDirectory, ".orbit", "extensions.json");
240781
- if (!existsSync4(registryPath)) return source;
241064
+ const registryPath = join4(homeDirectory, ".orbit", "extensions.json");
241065
+ if (!existsSync22(registryPath)) return source;
240782
241066
  let registry;
240783
241067
  try {
240784
241068
  const raw = readBoundedRegularFile(
@@ -240793,13 +241077,13 @@ function applyInstalledExtensionContributions(source, homeDirectory) {
240793
241077
  const parsed = ExtensionRegistrySchema.safeParse(registry);
240794
241078
  if (!parsed.success) return source;
240795
241079
  const config = structuredClone(source);
240796
- const extensionsRoot = resolve3(homeDirectory, ".orbit", "extensions");
241080
+ const extensionsRoot = resolve22(homeDirectory, ".orbit", "extensions");
240797
241081
  for (const extension of parsed.data.extensions) {
240798
241082
  if (!extension.trusted) continue;
240799
- const root = resolve3(extension.path);
240800
- if (root !== resolve3(extensionsRoot, extension.id)) continue;
241083
+ const root = resolve22(extension.path);
241084
+ if (root !== resolve22(extensionsRoot, extension.id)) continue;
240801
241085
  try {
240802
- if (!existsSync4(root) || lstatSync2(root).isSymbolicLink()) continue;
241086
+ if (!existsSync22(root) || lstatSync2(root).isSymbolicLink()) continue;
240803
241087
  if (hashExtensionDirectory(root, extension.digestAlgorithm) !== extension.digest) {
240804
241088
  continue;
240805
241089
  }
@@ -240827,12 +241111,12 @@ function hashExtensionDirectory(root, algorithm = "sha256-v2") {
240827
241111
  if (depth > MAX_EXTENSION_TREE_DEPTH) {
240828
241112
  throw new Error("Extension tree exceeds the maximum depth.");
240829
241113
  }
240830
- for (const entry of readdirSync(directory).sort()) {
241114
+ for (const entry of readdirSync2(directory).sort()) {
240831
241115
  entries += 1;
240832
241116
  if (entries > MAX_EXTENSION_TREE_ENTRIES) {
240833
241117
  throw new Error("Extension tree contains too many entries.");
240834
241118
  }
240835
- const path9 = join3(directory, entry);
241119
+ const path9 = join4(directory, entry);
240836
241120
  const stats = lstatSync2(path9);
240837
241121
  if (stats.isSymbolicLink()) {
240838
241122
  throw new Error("Symlinked extension entry.");
@@ -240918,16 +241202,16 @@ function createPermissionModeOverride(mode) {
240918
241202
  }
240919
241203
  var MAX_CONFIG_FILE_BYTES = 2 * 1024 * 1024;
240920
241204
  var MAX_PRICING_FILE_BYTES = 1024 * 1024;
240921
- function isRecord(value) {
241205
+ function isRecord2(value) {
240922
241206
  return typeof value === "object" && value !== null && !Array.isArray(value);
240923
241207
  }
240924
241208
  function sanitizeUntrustedProjectConfig(source, baseline) {
240925
- if (!isRecord(source)) return {};
241209
+ if (!isRecord2(source)) return {};
240926
241210
  const safe = {};
240927
241211
  for (const key of ["name", "language", "tui"]) {
240928
241212
  if (source[key] !== void 0) safe[key] = source[key];
240929
241213
  }
240930
- if (isRecord(source.context)) {
241214
+ if (isRecord2(source.context)) {
240931
241215
  const context = { ...source.context };
240932
241216
  delete context.testCommands;
240933
241217
  if (context.autoRepair !== false) delete context.autoRepair;
@@ -240945,7 +241229,7 @@ function sanitizeUntrustedProjectConfig(source, baseline) {
240945
241229
  }
240946
241230
  safe.context = context;
240947
241231
  }
240948
- if (isRecord(source.agent) && typeof source.agent.maxIterations === "number") {
241232
+ if (isRecord2(source.agent) && typeof source.agent.maxIterations === "number") {
240949
241233
  safe.agent = {
240950
241234
  maxIterations: Math.min(
240951
241235
  source.agent.maxIterations,
@@ -240953,7 +241237,29 @@ function sanitizeUntrustedProjectConfig(source, baseline) {
240953
241237
  )
240954
241238
  };
240955
241239
  }
240956
- if (isRecord(source.permissions)) {
241240
+ if (isRecord2(source.agents)) {
241241
+ const agents = {};
241242
+ if (source.agents.enabled === false) agents.enabled = false;
241243
+ if (typeof source.agents.maxProfiles === "number") {
241244
+ agents.maxProfiles = Math.min(
241245
+ source.agents.maxProfiles,
241246
+ baseline.agents.maxProfiles
241247
+ );
241248
+ }
241249
+ if (Array.isArray(source.agents.directories)) {
241250
+ const projectDirectories = /* @__PURE__ */ new Set([
241251
+ ".agents/agents",
241252
+ ".orbit/agents",
241253
+ ".claude/agents"
241254
+ ]);
241255
+ const directories = source.agents.directories.filter(
241256
+ (directory) => typeof directory === "string" && projectDirectories.has(directory)
241257
+ );
241258
+ if (directories.length > 0) agents.directories = directories;
241259
+ }
241260
+ safe.agents = agents;
241261
+ }
241262
+ if (isRecord2(source.permissions)) {
240957
241263
  const permissions = {};
240958
241264
  const requestedMode = source.permissions.mode;
240959
241265
  if (typeof requestedMode === "string" && permissionSafetyRank(requestedMode) >= permissionSafetyRank(baseline.permissions.mode)) {
@@ -240980,9 +241286,9 @@ function sanitizeUntrustedProjectConfig(source, baseline) {
240980
241286
  }
240981
241287
  safe.permissions = permissions;
240982
241288
  }
240983
- if (isRecord(source.tools)) {
241289
+ if (isRecord2(source.tools)) {
240984
241290
  const tools = {};
240985
- if (isRecord(source.tools.bash)) {
241291
+ if (isRecord2(source.tools.bash)) {
240986
241292
  const bash = {};
240987
241293
  if (source.tools.bash.enabled === false) bash.enabled = false;
240988
241294
  if (typeof source.tools.bash.timeoutMs === "number") {
@@ -240993,7 +241299,7 @@ function sanitizeUntrustedProjectConfig(source, baseline) {
240993
241299
  }
240994
241300
  tools.bash = bash;
240995
241301
  }
240996
- if (isRecord(source.tools.backgroundTasks)) {
241302
+ if (isRecord2(source.tools.backgroundTasks)) {
240997
241303
  const backgroundTasks = {};
240998
241304
  for (const key of [
240999
241305
  "maxConcurrentTasks",
@@ -241020,19 +241326,19 @@ function sanitizeUntrustedProjectConfig(source, baseline) {
241020
241326
  }
241021
241327
  tools.backgroundTasks = backgroundTasks;
241022
241328
  }
241023
- if (isRecord(source.tools.webSearch)) {
241329
+ if (isRecord2(source.tools.webSearch)) {
241024
241330
  tools.webSearch = {
241025
241331
  ...source.tools.webSearch.enabled === false ? { enabled: false } : {}
241026
241332
  };
241027
241333
  }
241028
- if (isRecord(source.tools.mcp)) {
241334
+ if (isRecord2(source.tools.mcp)) {
241029
241335
  tools.mcp = {
241030
241336
  ...source.tools.mcp.enabled === false ? { enabled: false } : {}
241031
241337
  };
241032
241338
  }
241033
241339
  safe.tools = tools;
241034
241340
  }
241035
- if (isRecord(source.skills)) {
241341
+ if (isRecord2(source.skills)) {
241036
241342
  const skills = {};
241037
241343
  if (source.skills.enabled === false) skills.enabled = false;
241038
241344
  if (source.skills.activation === "explicit") skills.activation = "explicit";
@@ -241072,7 +241378,7 @@ function warnIgnoredConfiguration(filePath) {
241072
241378
  console.warn(`Warning: Invalid configuration at ${filePath}; file ignored.`);
241073
241379
  }
241074
241380
  function hasUnsupportedSchemaVersion(source) {
241075
- if (!isRecord(source) || source.schemaVersion === void 0) return false;
241381
+ if (!isRecord2(source) || source.schemaVersion === void 0) return false;
241076
241382
  return source.schemaVersion !== ORBIT_CONFIG_SCHEMA_VERSION;
241077
241383
  }
241078
241384
  function warnUnsupportedConfiguration(filePath) {
@@ -241116,14 +241422,14 @@ function migrateLegacyDeepSeekProvider(config) {
241116
241422
  }
241117
241423
  var ConfigLoader = class {
241118
241424
  static merge(target, source) {
241119
- if (!isRecord(source)) return target;
241120
- const result = isRecord(target) ? { ...target } : {};
241425
+ if (!isRecord2(source)) return target;
241426
+ const result = isRecord2(target) ? { ...target } : {};
241121
241427
  for (const key of Object.keys(source)) {
241122
241428
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
241123
241429
  continue;
241124
241430
  }
241125
241431
  const sourceValue = source[key];
241126
- if (isRecord(sourceValue)) {
241432
+ if (isRecord2(sourceValue)) {
241127
241433
  result[key] = this.merge(result[key] ?? {}, sourceValue);
241128
241434
  } else if (sourceValue !== void 0) {
241129
241435
  result[key] = sourceValue;
@@ -241133,9 +241439,9 @@ var ConfigLoader = class {
241133
241439
  }
241134
241440
  static loadSync(cwd, cliOverrides, options = {}) {
241135
241441
  let config = structuredClone(DEFAULT_CONFIG);
241136
- const homeDirectory = options.homeDir ?? homedir3();
241442
+ const homeDirectory = options.homeDir ?? homedir4();
241137
241443
  const env = options.env ?? process.env;
241138
- const globalConfigPath = join4(homeDirectory, ".orbit", "config.yaml");
241444
+ const globalConfigPath = join5(homeDirectory, ".orbit", "config.yaml");
241139
241445
  try {
241140
241446
  const raw = readBoundedRegularFile(
241141
241447
  globalConfigPath,
@@ -241143,7 +241449,7 @@ var ConfigLoader = class {
241143
241449
  { allowSymbolicLink: true }
241144
241450
  );
241145
241451
  if (raw !== void 0) {
241146
- const parsed = parse(raw);
241452
+ const parsed = parse2(raw);
241147
241453
  if (hasUnsupportedSchemaVersion(parsed)) {
241148
241454
  warnUnsupportedConfiguration(globalConfigPath);
241149
241455
  } else {
@@ -241158,7 +241464,7 @@ var ConfigLoader = class {
241158
241464
  } catch {
241159
241465
  warnIgnoredConfiguration(globalConfigPath);
241160
241466
  }
241161
- const profileStore = options.providerProfileStore ?? new ProviderProfileStore({ orbitDir: join4(homeDirectory, ".orbit") });
241467
+ const profileStore = options.providerProfileStore ?? new ProviderProfileStore({ orbitDir: join5(homeDirectory, ".orbit") });
241162
241468
  const providerProfiles = profileStore.read();
241163
241469
  for (const profile of providerProfiles.profiles) {
241164
241470
  config.providers[profile.id] = this.merge(
@@ -241170,7 +241476,7 @@ var ConfigLoader = class {
241170
241476
  config.provider.default = providerProfiles.activeProvider;
241171
241477
  }
241172
241478
  const trustProjectExecutables = options.trustProjectExecutables ?? config.security?.trustProjectExecutables ?? false;
241173
- const projectConfigPath = join4(cwd, "orbit.config.yaml");
241479
+ const projectConfigPath = join5(cwd, "orbit.config.yaml");
241174
241480
  try {
241175
241481
  const raw = readBoundedRegularFile(
241176
241482
  projectConfigPath,
@@ -241178,7 +241484,7 @@ var ConfigLoader = class {
241178
241484
  { allowSymbolicLink: true }
241179
241485
  );
241180
241486
  if (raw !== void 0) {
241181
- const parsed = parse(raw);
241487
+ const parsed = parse2(raw);
241182
241488
  if (hasUnsupportedSchemaVersion(parsed)) {
241183
241489
  warnUnsupportedConfiguration(projectConfigPath);
241184
241490
  } else {
@@ -241197,7 +241503,7 @@ var ConfigLoader = class {
241197
241503
  warnIgnoredConfiguration(projectConfigPath);
241198
241504
  }
241199
241505
  config = this.applyEnvOverrides(config, env);
241200
- const pricingPath = join4(homeDirectory, ".orbit", "pricing.json");
241506
+ const pricingPath = join5(homeDirectory, ".orbit", "pricing.json");
241201
241507
  try {
241202
241508
  const raw = readBoundedRegularFile(pricingPath, MAX_PRICING_FILE_BYTES, {
241203
241509
  allowSymbolicLink: true
@@ -241229,8 +241535,8 @@ var ConfigLoader = class {
241229
241535
  );
241230
241536
  }
241231
241537
  }
241232
- const managedPolicyPath = env.ORBIT_MANAGED_POLICY ? resolve22(env.ORBIT_MANAGED_POLICY) : join4(homeDirectory, ".orbit", "policy.yaml");
241233
- if (existsSync22(managedPolicyPath)) {
241538
+ const managedPolicyPath = env.ORBIT_MANAGED_POLICY ? resolve32(env.ORBIT_MANAGED_POLICY) : join5(homeDirectory, ".orbit", "policy.yaml");
241539
+ if (existsSync32(managedPolicyPath)) {
241234
241540
  try {
241235
241541
  config = applyManagedPolicy(
241236
241542
  ConfigSchema.parse(config),
@@ -241255,7 +241561,7 @@ var ConfigLoader = class {
241255
241561
  path: migrateLegacySessionPath(finalConfig.session.path)
241256
241562
  };
241257
241563
  }
241258
- const credsManager = options.credentialsManager ?? new CredentialsManager({ orbitDir: join4(homeDirectory, ".orbit") });
241564
+ const credsManager = options.credentialsManager ?? new CredentialsManager({ orbitDir: join5(homeDirectory, ".orbit") });
241259
241565
  for (const key of Object.keys(finalConfig.providers)) {
241260
241566
  const provider = finalConfig.providers[key];
241261
241567
  if (!provider.apiKey && provider.apiKeyEnv) {
@@ -242754,7 +243060,7 @@ var zodToJsonSchema = (schema, options) => {
242754
243060
 
242755
243061
  // ../model-providers/dist/index.js
242756
243062
  import { createHash as createHash2 } from "crypto";
242757
- import { z as z9 } from "zod";
243063
+ import { z as z10 } from "zod";
242758
243064
  import { z as z23 } from "zod";
242759
243065
  import { z as z33 } from "zod";
242760
243066
  var DEEPSEEK_V4_FLASH = "deepseek-v4-flash";
@@ -242840,6 +243146,14 @@ function getDeepSeekReasoningEffort(budgetTokens = 4096, explicitEffort) {
242840
243146
  return "high";
242841
243147
  }
242842
243148
  function getDeepSeekThinkingPolicy(profile, input) {
243149
+ if (input.requestedEffort) {
243150
+ const effort = getDeepSeekReasoningEffort(4096, input.requestedEffort);
243151
+ return {
243152
+ enabled: true,
243153
+ effort,
243154
+ budgetTokens: effort === "low" ? 2048 : effort === "max" ? 8192 : 4096
243155
+ };
243156
+ }
242843
243157
  if (profile.legacyAlias) {
242844
243158
  return profile.optimizedThinkingDefault ? { enabled: true, effort: "high", budgetTokens: 4096 } : { enabled: false, effort: "high", budgetTokens: 0 };
242845
243159
  }
@@ -242868,6 +243182,13 @@ function resolveModelThinkingPolicy(model, context) {
242868
243182
  if (adaptation.family === "deepseek-v4") {
242869
243183
  return getDeepSeekThinkingPolicy(adaptation.deepSeekV4, context);
242870
243184
  }
243185
+ if (context.requestedEffort) {
243186
+ return {
243187
+ enabled: true,
243188
+ effort: context.requestedEffort,
243189
+ budgetTokens: budgetForEffort(context.requestedEffort)
243190
+ };
243191
+ }
242871
243192
  if (context.isRepairTurn) {
242872
243193
  return { enabled: true, budgetTokens: 8192 };
242873
243194
  }
@@ -242876,6 +243197,19 @@ function resolveModelThinkingPolicy(model, context) {
242876
243197
  }
242877
243198
  return void 0;
242878
243199
  }
243200
+ function budgetForEffort(effort) {
243201
+ switch (effort) {
243202
+ case "low":
243203
+ return 2048;
243204
+ case "medium":
243205
+ return 3072;
243206
+ case "high":
243207
+ return 4096;
243208
+ case "xhigh":
243209
+ case "max":
243210
+ return 8192;
243211
+ }
243212
+ }
242879
243213
  function resolveModelCanonicalName(model) {
242880
243214
  const adaptation = resolveModelAdaptation(model);
242881
243215
  return adaptation.family === "deepseek-v4" ? adaptation.deepSeekV4.canonicalModel : model;
@@ -243307,58 +243641,58 @@ function validateJsonObjectToolArguments(argumentsText) {
243307
243641
  invalid: "DeepSeek tool arguments must be a JSON object."
243308
243642
  });
243309
243643
  }
243310
- var ProviderTokenCountSchema = z9.number().int().nonnegative().max(1e9);
243311
- var ProviderCollectionIndexSchema = z9.number().int().nonnegative().max(1e6);
243312
- var AnthropicUsageSchema = z9.object({
243644
+ var ProviderTokenCountSchema = z10.number().int().nonnegative().max(1e9);
243645
+ var ProviderCollectionIndexSchema = z10.number().int().nonnegative().max(1e6);
243646
+ var AnthropicUsageSchema = z10.object({
243313
243647
  input_tokens: ProviderTokenCountSchema.optional(),
243314
243648
  output_tokens: ProviderTokenCountSchema.optional(),
243315
243649
  cache_read_input_tokens: ProviderTokenCountSchema.optional(),
243316
243650
  cache_creation_input_tokens: ProviderTokenCountSchema.optional()
243317
243651
  }).passthrough();
243318
- var AnthropicErrorSchema = z9.object({
243319
- message: z9.string(),
243320
- type: z9.string().optional()
243652
+ var AnthropicErrorSchema = z10.object({
243653
+ message: z10.string(),
243654
+ type: z10.string().optional()
243321
243655
  }).passthrough();
243322
- var AnthropicContentBlockSchema = z9.discriminatedUnion("type", [
243323
- z9.object({
243324
- type: z9.literal("text"),
243325
- text: z9.string()
243656
+ var AnthropicContentBlockSchema = z10.discriminatedUnion("type", [
243657
+ z10.object({
243658
+ type: z10.literal("text"),
243659
+ text: z10.string()
243326
243660
  }).passthrough(),
243327
- z9.object({
243328
- type: z9.literal("thinking"),
243329
- thinking: z9.string(),
243330
- signature: z9.string().optional()
243661
+ z10.object({
243662
+ type: z10.literal("thinking"),
243663
+ thinking: z10.string(),
243664
+ signature: z10.string().optional()
243331
243665
  }).passthrough(),
243332
- z9.object({
243333
- type: z9.literal("tool_use"),
243334
- id: z9.string().min(1),
243335
- name: z9.string().min(1),
243336
- input: z9.record(z9.unknown())
243666
+ z10.object({
243667
+ type: z10.literal("tool_use"),
243668
+ id: z10.string().min(1),
243669
+ name: z10.string().min(1),
243670
+ input: z10.record(z10.unknown())
243337
243671
  }).passthrough()
243338
243672
  ]);
243339
- var AnthropicMessageResponseSchema = z9.object({
243340
- id: z9.string().optional(),
243341
- model: z9.string().optional(),
243342
- content: z9.array(AnthropicContentBlockSchema).max(1e4),
243673
+ var AnthropicMessageResponseSchema = z10.object({
243674
+ id: z10.string().optional(),
243675
+ model: z10.string().optional(),
243676
+ content: z10.array(AnthropicContentBlockSchema).max(1e4),
243343
243677
  usage: AnthropicUsageSchema.optional(),
243344
- stop_reason: z9.string().nullable().optional()
243678
+ stop_reason: z10.string().nullable().optional()
243345
243679
  }).passthrough();
243346
- var AnthropicStreamEventSchema = z9.object({
243347
- type: z9.string(),
243680
+ var AnthropicStreamEventSchema = z10.object({
243681
+ type: z10.string(),
243348
243682
  index: ProviderCollectionIndexSchema.optional(),
243349
- message: z9.object({
243350
- id: z9.string().optional(),
243351
- model: z9.string().optional(),
243683
+ message: z10.object({
243684
+ id: z10.string().optional(),
243685
+ model: z10.string().optional(),
243352
243686
  usage: AnthropicUsageSchema.optional()
243353
243687
  }).passthrough().optional(),
243354
243688
  content_block: AnthropicContentBlockSchema.optional(),
243355
- delta: z9.object({
243356
- type: z9.string().optional(),
243357
- text: z9.string().optional(),
243358
- thinking: z9.string().optional(),
243359
- signature: z9.string().optional(),
243360
- partial_json: z9.string().optional(),
243361
- stop_reason: z9.string().nullable().optional()
243689
+ delta: z10.object({
243690
+ type: z10.string().optional(),
243691
+ text: z10.string().optional(),
243692
+ thinking: z10.string().optional(),
243693
+ signature: z10.string().optional(),
243694
+ partial_json: z10.string().optional(),
243695
+ stop_reason: z10.string().nullable().optional()
243362
243696
  }).passthrough().optional(),
243363
243697
  usage: AnthropicUsageSchema.optional(),
243364
243698
  error: AnthropicErrorSchema.optional()
@@ -246222,19 +246556,19 @@ function normalizeOllamaOpenAiBaseUrl(baseUrl) {
246222
246556
  }
246223
246557
 
246224
246558
  // src/runtime/CacheDiagnostics.ts
246225
- import { existsSync as existsSync13, readdirSync as readdirSync5 } from "fs";
246559
+ import { existsSync as existsSync13, readdirSync as readdirSync6 } from "fs";
246226
246560
  import { join as join11 } from "path";
246227
246561
  import picocolors4 from "picocolors";
246228
246562
 
246229
246563
  // ../core/dist/index.js
246230
- import { existsSync as existsSync12, readdirSync as readdirSync4 } from "fs";
246564
+ import { existsSync as existsSync12, readdirSync as readdirSync5 } from "fs";
246231
246565
  import { createHash as createHash7 } from "crypto";
246232
246566
  import { join as join10 } from "path";
246233
246567
  import { z as z31 } from "zod";
246234
246568
  import { z as z211 } from "zod";
246235
246569
 
246236
246570
  // ../tools/dist/index.js
246237
- import { z as z10 } from "zod";
246571
+ import { z as z11 } from "zod";
246238
246572
  import { z as z24 } from "zod";
246239
246573
  import { randomUUID as randomUUID3 } from "crypto";
246240
246574
  import {
@@ -246247,10 +246581,10 @@ import {
246247
246581
  unlinkSync as unlinkSync2,
246248
246582
  writeFileSync as writeFileSync3
246249
246583
  } from "fs";
246250
- import { dirname as dirname4, isAbsolute as isAbsolute2, join as join5, resolve as resolve4 } from "path";
246584
+ import { dirname as dirname4, isAbsolute as isAbsolute3, join as join6, resolve as resolve4 } from "path";
246251
246585
  import { isAbsolute as isAbsolute22, resolve as resolve23 } from "path";
246252
246586
  import { z as z34 } from "zod";
246253
- import { isAbsolute as isAbsolute3, relative as relative4, win32 } from "path";
246587
+ import { isAbsolute as isAbsolute32, relative as relative4, win32 } from "path";
246254
246588
  import glob from "fast-glob";
246255
246589
  import { existsSync as existsSync23 } from "fs";
246256
246590
  import { z as z42 } from "zod";
@@ -247848,12 +248182,12 @@ import { z as z52 } from "zod";
247848
248182
  import { z as z62 } from "zod";
247849
248183
  import { z as z72 } from "zod";
247850
248184
  import { createHash as createHash3 } from "crypto";
247851
- import { existsSync as existsSync32 } from "fs";
248185
+ import { existsSync as existsSync33 } from "fs";
247852
248186
  import { z as z82 } from "zod";
247853
248187
  import { z as z92 } from "zod";
247854
248188
  import { z as z102 } from "zod";
247855
248189
  import { relative as relative22 } from "path";
247856
- import { z as z11 } from "zod";
248190
+ import { z as z112 } from "zod";
247857
248191
  import { z as z12 } from "zod";
247858
248192
  import { existsSync as existsSync42 } from "fs";
247859
248193
  import { join as join23 } from "path";
@@ -247869,7 +248203,7 @@ import { existsSync as existsSync7 } from "fs";
247869
248203
  import { win32 as win322 } from "path";
247870
248204
  import { z as z18 } from "zod";
247871
248205
  import { existsSync as existsSync8 } from "fs";
247872
- import { join as join32, resolve as resolve32 } from "path";
248206
+ import { join as join32, resolve as resolve33 } from "path";
247873
248207
  import { z as z20 } from "zod";
247874
248208
  var import_ipaddr = __toESM(require_ipaddr(), 1);
247875
248209
  import { lookup } from "dns/promises";
@@ -247881,10 +248215,10 @@ import { z as z21 } from "zod";
247881
248215
  import { z as z222 } from "zod";
247882
248216
  import { execFile, spawn } from "child_process";
247883
248217
  import { randomUUID as randomUUID22 } from "crypto";
247884
- var ToolRegistrationSchema = z10.object({
247885
- name: z10.string().regex(/^[A-Za-z0-9_-]{1,64}$/),
247886
- description: z10.string().trim().min(1).max(2e4),
247887
- risk: z10.enum(["read", "write", "execute", "network", "dangerous"])
248218
+ var ToolRegistrationSchema = z11.object({
248219
+ name: z11.string().regex(/^[A-Za-z0-9_-]{1,64}$/),
248220
+ description: z11.string().trim().min(1).max(2e4),
248221
+ risk: z11.enum(["read", "write", "execute", "network", "dangerous"])
247888
248222
  });
247889
248223
  var ToolRegistry = class {
247890
248224
  tools = /* @__PURE__ */ new Map();
@@ -247919,14 +248253,14 @@ var MAX_TOOL_FILE_BYTES = 16 * 1024 * 1024;
247919
248253
  var MAX_GREP_FALLBACK_FILE_BYTES = 2 * 1024 * 1024;
247920
248254
  function atomicWriteToolFile(cwd, requestedPath, content, expectedCurrentContent, options = {}) {
247921
248255
  const resolveRequestedPath = () => options.allowOutsideWorkspace ? normalizePath(
247922
- isAbsolute2(requestedPath) ? resolve4(requestedPath) : resolve4(cwd, requestedPath)
248256
+ isAbsolute3(requestedPath) ? resolve4(requestedPath) : resolve4(cwd, requestedPath)
247923
248257
  ) : resolveSafePath(cwd, requestedPath);
247924
248258
  let safePath = resolveRequestedPath();
247925
248259
  const parent = dirname4(safePath);
247926
248260
  mkdirSync2(parent, { recursive: true });
247927
248261
  safePath = resolveRequestedPath();
247928
248262
  assertExpectedContent(safePath, expectedCurrentContent);
247929
- const temporaryPath = join5(parent, `.orbit-write-${randomUUID3()}.tmp`);
248263
+ const temporaryPath = join6(parent, `.orbit-write-${randomUUID3()}.tmp`);
247930
248264
  let descriptor;
247931
248265
  try {
247932
248266
  descriptor = openSync3(temporaryPath, "wx", 384);
@@ -248599,7 +248933,7 @@ var IGNORED_DIRECTORIES = [
248599
248933
  function isWorkspaceRelativeGlob(pattern) {
248600
248934
  const candidate = pattern.startsWith("!") ? pattern.slice(1) : pattern;
248601
248935
  const normalized = candidate.replace(/\\/g, "/");
248602
- return candidate.length > 0 && !isAbsolute3(candidate) && !win32.isAbsolute(candidate) && !normalized.includes("..");
248936
+ return candidate.length > 0 && !isAbsolute32(candidate) && !win32.isAbsolute(candidate) && !normalized.includes("..");
248603
248937
  }
248604
248938
  async function findWorkspaceFiles(root, pattern, options = {}) {
248605
248939
  if (!isWorkspaceRelativeGlob(pattern)) {
@@ -249027,7 +249361,7 @@ var WriteFileTool = class {
249027
249361
  if (!fullHostAccess) throw error;
249028
249362
  currentContentKnown = false;
249029
249363
  }
249030
- const fileExists = currentContentKnown ? current !== void 0 : existsSync32(safePath);
249364
+ const fileExists = currentContentKnown ? current !== void 0 : existsSync33(safePath);
249031
249365
  if (input.intent === "create" && fileExists) {
249032
249366
  return { ok: false, error: `File already exists: ${input.path}` };
249033
249367
  }
@@ -249184,7 +249518,7 @@ var GitRestoreTool = class {
249184
249518
  }
249185
249519
  }
249186
249520
  };
249187
- var GitStatusInputSchema = z11.object({});
249521
+ var GitStatusInputSchema = z112.object({});
249188
249522
  var GitStatusTool = class {
249189
249523
  name = "git_status";
249190
249524
  description = "Show working tree status of git files (short format).";
@@ -249884,11 +250218,11 @@ function detectTrustedTerminalSuccess(command, cwd, output, exitCode) {
249884
250218
  );
249885
250219
  const script = match?.[1] || match?.[2] || match?.[3];
249886
250220
  if (!script) return void 0;
249887
- const actual = comparablePath(resolve32(cwd, script));
250221
+ const actual = comparablePath(resolve33(cwd, script));
249888
250222
  const expected = [
249889
- resolve32(cwd, ".cumcm", "finalize.py"),
250223
+ resolve33(cwd, ".cumcm", "finalize.py"),
249890
250224
  // Read compatibility for projects scaffolded by Orbit <= 0.8.3.
249891
- resolve32(cwd, "code", "finalize.py")
250225
+ resolve33(cwd, "code", "finalize.py")
249892
250226
  ].map(comparablePath);
249893
250227
  return expected.includes(actual) ? "cumcm-finalizer" : void 0;
249894
250228
  }
@@ -251722,13 +252056,21 @@ Orbit could not confirm timeout termination: ${errorMessage(error)}
251722
252056
  task.requestedStop = status;
251723
252057
  const gracefulSignalConfirmed = await signalProcessTree(task.child, false);
251724
252058
  if (process.platform === "win32" && gracefulSignalConfirmed && task.status === "running") {
251725
- this.settleTask(task, status, task.child.exitCode);
252059
+ await waitForChildClosed(task.child, this.terminateGraceMs);
252060
+ if (task.status === "running") {
252061
+ releaseChildStreams(task.child);
252062
+ this.settleTask(task, status, task.child.exitCode);
252063
+ }
251726
252064
  return;
251727
252065
  }
251728
252066
  if (await waitWithTimeout(task.completion, this.terminateGraceMs)) return;
251729
252067
  const forcedSignalConfirmed = await signalProcessTree(task.child, true);
251730
252068
  if (process.platform === "win32" && forcedSignalConfirmed && task.status === "running") {
251731
- this.settleTask(task, status, task.child.exitCode);
252069
+ await waitForChildClosed(task.child, this.terminateGraceMs);
252070
+ if (task.status === "running") {
252071
+ releaseChildStreams(task.child);
252072
+ this.settleTask(task, status, task.child.exitCode);
252073
+ }
251732
252074
  return;
251733
252075
  }
251734
252076
  if (await waitWithTimeout(task.completion, this.terminateGraceMs)) return;
@@ -251795,6 +252137,27 @@ async function signalProcessTree(child, force) {
251795
252137
  }
251796
252138
  }
251797
252139
  }
252140
+ async function waitForChildClosed(child, timeoutMs) {
252141
+ if (child.exitCode !== null || child.signalCode !== null) return true;
252142
+ return new Promise((resolve43) => {
252143
+ let settled = false;
252144
+ const finish = (closed) => {
252145
+ if (settled) return;
252146
+ settled = true;
252147
+ clearTimeout(timer);
252148
+ child.removeListener("close", onClose);
252149
+ resolve43(closed);
252150
+ };
252151
+ const onClose = () => finish(true);
252152
+ const timer = setTimeout(() => finish(false), timeoutMs);
252153
+ child.once("close", onClose);
252154
+ });
252155
+ }
252156
+ function releaseChildStreams(child) {
252157
+ child.stdin?.destroy();
252158
+ child.stdout?.destroy();
252159
+ child.stderr?.destroy();
252160
+ }
251798
252161
  async function waitWithTimeout(promise, timeoutMs, abortSignal) {
251799
252162
  let timeout;
251800
252163
  let abortListener;
@@ -251836,14 +252199,14 @@ function errorMessage(error) {
251836
252199
  }
251837
252200
 
251838
252201
  // ../context-engine/dist/index.js
251839
- import { join as join6 } from "path";
252202
+ import { join as join62 } from "path";
251840
252203
  import { existsSync as existsSync9 } from "fs";
251841
252204
  import { pathToFileURL } from "url";
251842
252205
  import { z as z25 } from "zod";
251843
252206
  import { basename, join as join7 } from "path";
251844
252207
  import { existsSync as existsSync43, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3, renameSync as renameSync3, rmSync as rmSync2 } from "fs";
251845
252208
  import { promises as fsPromises3 } from "fs";
251846
- import { join as join24, dirname as dirname32, isAbsolute as isAbsolute4, resolve as resolve33 } from "path";
252209
+ import { join as join24, dirname as dirname32, isAbsolute as isAbsolute4, resolve as resolve34 } from "path";
251847
252210
  import { createHash as createHash4, randomUUID as randomUUID32 } from "crypto";
251848
252211
  import { execFile as execFile2 } from "child_process";
251849
252212
  import glob3 from "fast-glob";
@@ -251853,7 +252216,7 @@ import { existsSync as existsSync24, promises as fsPromises2 } from "fs";
251853
252216
  import { dirname as dirname5, resolve as resolve5 } from "path";
251854
252217
  import { randomUUID as randomUUID4 } from "crypto";
251855
252218
  import { z as z26 } from "zod";
251856
- import { existsSync as existsSync33, promises as fsPromises22 } from "fs";
252219
+ import { existsSync as existsSync34, promises as fsPromises22 } from "fs";
251857
252220
  import { dirname as dirname22, resolve as resolve24 } from "path";
251858
252221
  import { randomUUID as randomUUID23 } from "crypto";
251859
252222
  import { z as z35 } from "zod";
@@ -251862,7 +252225,7 @@ import { extname as extname22 } from "path";
251862
252225
  import { resolve as resolve42 } from "path";
251863
252226
  import { dirname as dirname52 } from "path";
251864
252227
  import { isAbsolute as isAbsolute23, join as join33, resolve as resolve52 } from "path";
251865
- import { homedir as homedir4 } from "os";
252228
+ import { homedir as homedir5 } from "os";
251866
252229
  import { existsSync as existsSync53, promises as fs2 } from "fs";
251867
252230
  import { fileURLToPath as fileURLToPath2 } from "url";
251868
252231
  import { parse as parseYaml3 } from "yaml";
@@ -251871,7 +252234,7 @@ import { dirname as dirname42, join as join42 } from "path";
251871
252234
  import { parse as parseYaml22 } from "yaml";
251872
252235
  import { z as z63 } from "zod";
251873
252236
  import { existsSync as existsSync62, lstatSync as lstatSync3, promises as fs22 } from "fs";
251874
- import { dirname as dirname6, isAbsolute as isAbsolute32, join as join52, win32 as win323 } from "path";
252237
+ import { dirname as dirname6, isAbsolute as isAbsolute33, join as join52, win32 as win323 } from "path";
251875
252238
  import { parse as parseYaml32 } from "yaml";
251876
252239
  var ProjectIndexer = class {
251877
252240
  constructor(cwd) {
@@ -252609,7 +252972,7 @@ var BM25Store = class {
252609
252972
  this.initializeCachePath();
252610
252973
  try {
252611
252974
  const parentDir = dirname22(this.dbPath);
252612
- if (!existsSync33(parentDir)) {
252975
+ if (!existsSync34(parentDir)) {
252613
252976
  await fsPromises22.mkdir(parentDir, { recursive: true });
252614
252977
  }
252615
252978
  const data = {
@@ -252644,7 +253007,7 @@ var BM25Store = class {
252644
253007
  }
252645
253008
  async loadFromDisk() {
252646
253009
  this.initializeCachePath();
252647
- if (!existsSync33(this.dbPath)) {
253010
+ if (!existsSync34(this.dbPath)) {
252648
253011
  this.docs = createRecord();
252649
253012
  this.df = createRecord();
252650
253013
  this.avgdl = 0;
@@ -252691,7 +253054,7 @@ var BM25Store = class {
252691
253054
  this.avgdl = 0;
252692
253055
  this.loaded = true;
252693
253056
  this.cacheState = "missing";
252694
- if (existsSync33(this.dbPath)) {
253057
+ if (existsSync34(this.dbPath)) {
252695
253058
  try {
252696
253059
  await fsPromises22.unlink(this.dbPath);
252697
253060
  } catch {
@@ -253110,7 +253473,7 @@ function embeddingBatches(texts) {
253110
253473
  return batches;
253111
253474
  }
253112
253475
  function workspaceIndexKey(cwd) {
253113
- const absolute = resolve33(cwd).replace(/\\/g, "/");
253476
+ const absolute = resolve34(cwd).replace(/\\/g, "/");
253114
253477
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
253115
253478
  }
253116
253479
  function resolveConfiguredApiKey(provider) {
@@ -253315,7 +253678,7 @@ function getEmbeddingProvider(config) {
253315
253678
  var SymbolIndexer = class {
253316
253679
  constructor(cwd) {
253317
253680
  this.cwd = cwd;
253318
- this.indexPath = resolve33(cwd, ".orbit", "symbols.json");
253681
+ this.indexPath = resolve34(cwd, ".orbit", "symbols.json");
253319
253682
  }
253320
253683
  cwd;
253321
253684
  indexPath;
@@ -253337,9 +253700,9 @@ var SymbolIndexer = class {
253337
253700
  async performIndex() {
253338
253701
  try {
253339
253702
  this.initializeIndexPath();
253340
- const normCwd = resolve33(this.cwd).toLowerCase().replace(/\\/g, "/");
253703
+ const normCwd = resolve34(this.cwd).toLowerCase().replace(/\\/g, "/");
253341
253704
  const { homedir: homedir22 } = await import("os");
253342
- const normHome = resolve33(homedir22()).toLowerCase().replace(/\\/g, "/");
253705
+ const normHome = resolve34(homedir22()).toLowerCase().replace(/\\/g, "/");
253343
253706
  if (normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname32(normCwd) === normCwd) {
253344
253707
  return;
253345
253708
  }
@@ -254170,9 +254533,9 @@ function resolveSkillDirectory(cwd, directory) {
254170
254533
  if (directory === "@orbit/builtin-skills") {
254171
254534
  return resolveBundledSkillsDirectory();
254172
254535
  }
254173
- if (directory === "~") return homedir4();
254536
+ if (directory === "~") return homedir5();
254174
254537
  if (directory.startsWith("~/") || directory.startsWith("~\\")) {
254175
- return resolve52(homedir4(), directory.slice(2));
254538
+ return resolve52(homedir5(), directory.slice(2));
254176
254539
  }
254177
254540
  return isAbsolute23(directory) ? resolve52(directory) : resolve52(cwd, directory);
254178
254541
  }
@@ -254728,7 +255091,7 @@ function validateReference(skill, reference, diagnostics) {
254728
255091
  return;
254729
255092
  }
254730
255093
  if (!relativePath) return;
254731
- if (isAbsolute32(relativePath) || win323.isAbsolute(relativePath)) {
255094
+ if (isAbsolute33(relativePath) || win323.isAbsolute(relativePath)) {
254732
255095
  diagnostics.push(
254733
255096
  diagnostic(
254734
255097
  skill.path,
@@ -254842,7 +255205,11 @@ var ContextPackBuilder = class {
254842
255205
  const projectIndexPromise = this.indexer.index();
254843
255206
  const projectInstructionsPromise = this.loadInstructions();
254844
255207
  const config = ConfigLoader.loadSync(this.cwd);
254845
- const skillsPromise = this.loadSkills(config, userQuery);
255208
+ const skillsPromise = this.loadSkills(
255209
+ config,
255210
+ userQuery,
255211
+ options.forcedSkills
255212
+ );
254846
255213
  let codebaseContextPromise = Promise.resolve(void 0);
254847
255214
  const retrievalMode = selectCodebaseRetrievalMode(
254848
255215
  userQuery,
@@ -255021,7 +255388,7 @@ var ContextPackBuilder = class {
255021
255388
  "README.md"
255022
255389
  ];
255023
255390
  for (const name of candidates) {
255024
- const p = join6(this.cwd, ...name.split("/"));
255391
+ const p = join62(this.cwd, ...name.split("/"));
255025
255392
  try {
255026
255393
  const content = readBoundedRegularFile(
255027
255394
  p,
@@ -255033,7 +255400,7 @@ var ContextPackBuilder = class {
255033
255400
  }
255034
255401
  return "";
255035
255402
  }
255036
- async loadSkills(config, userQuery) {
255403
+ async loadSkills(config, userQuery, forcedSkills = []) {
255037
255404
  const skillsConfig = config.skills;
255038
255405
  if (skillsConfig.enabled === false) {
255039
255406
  return { index: [], active: [], diagnostics: [] };
@@ -255058,11 +255425,12 @@ var ContextPackBuilder = class {
255058
255425
  };
255059
255426
  }
255060
255427
  const { skills, diagnostics } = this.skillsCache;
255428
+ const forcedQuery = forcedSkills.length ? `${userQuery || ""} ${forcedSkills.map((name) => `$${name}`).join(" ")}` : userQuery;
255061
255429
  return {
255062
255430
  // The always-in-context index advertises only enabled skills, and only
255063
255431
  // the fields the prompt renders — not byte accounting or UI metadata.
255064
255432
  index: skills.filter((skill) => !skill.disabled).map(({ name, description, path: path9 }) => ({ name, description, path: path9 })),
255065
- active: selectSkills(skills, userQuery, skillsConfig),
255433
+ active: selectSkills(skills, forcedQuery, skillsConfig),
255066
255434
  diagnostics
255067
255435
  };
255068
255436
  }
@@ -255209,6 +255577,26 @@ var MCP_SUPPORTED_PROTOCOL_VERSIONS = [
255209
255577
  ];
255210
255578
  var MCP_LATEST_PROTOCOL_VERSION = MCP_MODERN_PROTOCOL_VERSIONS[0];
255211
255579
  var MCP_LATEST_LEGACY_PROTOCOL_VERSION = MCP_LEGACY_PROTOCOL_VERSIONS[0];
255580
+ var MCP_TASK_STATUS_VALUES = [
255581
+ "working",
255582
+ "input_required",
255583
+ "completed",
255584
+ "failed",
255585
+ "cancelled"
255586
+ ];
255587
+ var MCPTaskSchema = z28.object({
255588
+ taskId: z28.string().min(1).max(512),
255589
+ status: z28.enum(MCP_TASK_STATUS_VALUES),
255590
+ statusMessage: z28.string().max(1e4).optional(),
255591
+ createdAt: z28.string().datetime(),
255592
+ lastUpdatedAt: z28.string().datetime(),
255593
+ ttl: z28.number().int().nonnegative().nullable().optional(),
255594
+ pollInterval: z28.number().int().positive().max(3e5).optional()
255595
+ });
255596
+ var MCPCreateTaskResultSchema = z28.object({
255597
+ task: MCPTaskSchema,
255598
+ _meta: z28.record(z28.unknown()).optional()
255599
+ });
255212
255600
  var MCP_IMPLEMENTATION_NAME_MAX_CHARS = 512;
255213
255601
  var MCP_VERSION_MAX_CHARS = 100;
255214
255602
  var MCP_DISCOVERY_INSTRUCTIONS_MAX_CHARS = 1e5;
@@ -255232,7 +255620,7 @@ var McpJsonRpcError = class extends Error {
255232
255620
  name = "McpJsonRpcError";
255233
255621
  };
255234
255622
  function createModernRequestParams(params, protocolVersion, clientVersion) {
255235
- const existingMeta = isRecord2(params._meta) ? params._meta : {};
255623
+ const existingMeta = isRecord3(params._meta) ? params._meta : {};
255236
255624
  return {
255237
255625
  ...params,
255238
255626
  _meta: {
@@ -255259,7 +255647,7 @@ function isRecognizedModernProtocolError(error) {
255259
255647
  }
255260
255648
  function modernVersionsFromUnsupportedError(error) {
255261
255649
  if (!(error instanceof McpJsonRpcError) || error.code !== -32022) return [];
255262
- if (!isRecord2(error.data) || !Array.isArray(error.data.supported)) return [];
255650
+ if (!isRecord3(error.data) || !Array.isArray(error.data.supported)) return [];
255263
255651
  return error.data.supported.filter(
255264
255652
  (value) => typeof value === "string"
255265
255653
  );
@@ -255308,7 +255696,7 @@ function compileMirroredToolParameters(inputSchema) {
255308
255696
  for (const nested of value) visit(nested, path9, false);
255309
255697
  return;
255310
255698
  }
255311
- if (!isRecord2(value)) return;
255699
+ if (!isRecord3(value)) return;
255312
255700
  if ("x-mcp-header" in value) {
255313
255701
  const headerName = value["x-mcp-header"];
255314
255702
  const type = value.type;
@@ -255328,7 +255716,7 @@ function compileMirroredToolParameters(inputSchema) {
255328
255716
  }
255329
255717
  for (const [key, nested] of Object.entries(value)) {
255330
255718
  if (key === "x-mcp-header") continue;
255331
- if (key === "properties" && isRecord2(nested)) {
255719
+ if (key === "properties" && isRecord3(nested)) {
255332
255720
  for (const [propertyName, propertySchema] of Object.entries(nested)) {
255333
255721
  visit(propertySchema, [...path9, propertyName], true);
255334
255722
  }
@@ -255347,7 +255735,7 @@ function createMirroredToolHeaders(parameters, args) {
255347
255735
  for (const parameter of parameters) {
255348
255736
  let value = args;
255349
255737
  for (const segment of parameter.path) {
255350
- value = isRecord2(value) ? value[segment] : void 0;
255738
+ value = isRecord3(value) ? value[segment] : void 0;
255351
255739
  }
255352
255740
  if (value === void 0 || value === null) continue;
255353
255741
  const valid = parameter.type === "string" && typeof value === "string" || parameter.type === "boolean" && typeof value === "boolean" || (parameter.type === "number" || parameter.type === "integer") && typeof value === "number" && Number.isFinite(value) && (parameter.type === "number" || Number.isSafeInteger(value));
@@ -255362,7 +255750,7 @@ function createMirroredToolHeaders(parameters, args) {
255362
255750
  }
255363
255751
  return headers;
255364
255752
  }
255365
- function isRecord2(value) {
255753
+ function isRecord3(value) {
255366
255754
  return typeof value === "object" && value !== null && !Array.isArray(value);
255367
255755
  }
255368
255756
  var MCP_REQUEST_TIMEOUT_MS = 3e4;
@@ -255451,6 +255839,10 @@ var MCPPromptsListSchema = z36.object({
255451
255839
  prompts: z36.array(MCPPromptSchema).max(1e4).default([]),
255452
255840
  nextCursor: MCPPaginationCursorSchema.optional()
255453
255841
  });
255842
+ var MCPTasksListSchema = z36.object({
255843
+ tasks: z36.array(MCPTaskSchema).max(1e4).default([]),
255844
+ nextCursor: MCPPaginationCursorSchema.optional()
255845
+ });
255454
255846
  var MCPPromptGetResultSchema = z36.object({
255455
255847
  description: z36.string().max(1e4).optional(),
255456
255848
  messages: z36.array(
@@ -255528,7 +255920,8 @@ function parseServerCapabilities(initializeResult) {
255528
255920
  return {
255529
255921
  tools: has("tools"),
255530
255922
  resources: has("resources"),
255531
- prompts: has("prompts")
255923
+ prompts: has("prompts"),
255924
+ tasks: has("tasks")
255532
255925
  };
255533
255926
  }
255534
255927
  function flattenResourceContents(result) {
@@ -255611,9 +256004,11 @@ var MCPClient = class {
255611
256004
  serverCapabilities = {
255612
256005
  tools: false,
255613
256006
  resources: false,
255614
- prompts: false
256007
+ prompts: false,
256008
+ tasks: false
255615
256009
  };
255616
256010
  catalogListeners = /* @__PURE__ */ new Set();
256011
+ taskStatusListeners = /* @__PURE__ */ new Set();
255617
256012
  lastError;
255618
256013
  get effectiveRequestTimeoutMs() {
255619
256014
  return this.requestTimeoutMs ?? MCP_REQUEST_TIMEOUT_MS;
@@ -255639,7 +256034,7 @@ var MCPClient = class {
255639
256034
  child.on("error", (error) => {
255640
256035
  this.cleanup(
255641
256036
  new Error(
255642
- `MCP server "${this.serverName}" failed to start: ${safeMessage(error)}`
256037
+ `MCP server "${this.serverName}" failed to start: ${safeMessage2(error)}`
255643
256038
  )
255644
256039
  );
255645
256040
  });
@@ -255662,7 +256057,7 @@ var MCPClient = class {
255662
256057
  if (this.child !== child) return;
255663
256058
  this.cleanup(
255664
256059
  new Error(
255665
- `MCP server "${this.serverName}" stdin failed: ${safeMessage(error)}`
256060
+ `MCP server "${this.serverName}" stdin failed: ${safeMessage2(error)}`
255666
256061
  )
255667
256062
  );
255668
256063
  });
@@ -255798,6 +256193,117 @@ var MCPClient = class {
255798
256193
  );
255799
256194
  return flattenPromptMessages(result);
255800
256195
  }
256196
+ /** Create a durable task-augmented MCP tool call. */
256197
+ async callToolTask(originalToolName, args, options = {}) {
256198
+ this.requireTaskCapability();
256199
+ const ttl = options.ttl;
256200
+ if (ttl !== void 0 && (!Number.isSafeInteger(ttl) || ttl < 1 || ttl > 7 * 24 * 60 * 60 * 1e3)) {
256201
+ throw new Error(
256202
+ "MCP task ttl must be an integer between 1ms and 7 days."
256203
+ );
256204
+ }
256205
+ const result = await this.sendRequest(
256206
+ "tools/call",
256207
+ {
256208
+ name: originalToolName,
256209
+ arguments: args,
256210
+ task: ttl === void 0 ? {} : { ttl }
256211
+ },
256212
+ options.abortSignal,
256213
+ { skipModernResultCheck: true }
256214
+ );
256215
+ return MCPCreateTaskResultSchema.parse(result).task;
256216
+ }
256217
+ /** Read one durable task state without assuming a live notification stream. */
256218
+ async getTask(taskId, abortSignal) {
256219
+ this.requireTaskCapability();
256220
+ return MCPTaskSchema.parse(
256221
+ await this.sendRequest(
256222
+ "tasks/get",
256223
+ { taskId: validateTaskId(taskId) },
256224
+ abortSignal,
256225
+ { skipModernResultCheck: true }
256226
+ )
256227
+ );
256228
+ }
256229
+ /** List tasks through opaque cursor pagination with bounded memory. */
256230
+ async listTasks(abortSignal) {
256231
+ this.requireTaskCapability();
256232
+ return collectMcpPaginatedItems({
256233
+ method: "tasks/list",
256234
+ request: (params) => this.sendRequest("tasks/list", params, abortSignal, {
256235
+ skipModernResultCheck: true
256236
+ }),
256237
+ parse: (value) => {
256238
+ const page = MCPTasksListSchema.parse(value);
256239
+ return { items: page.tasks, nextCursor: page.nextCursor };
256240
+ },
256241
+ identity: (task) => task.taskId
256242
+ });
256243
+ }
256244
+ /** Request cancellation and return the receiver's authoritative state. */
256245
+ async cancelTask(taskId, abortSignal) {
256246
+ this.requireTaskCapability();
256247
+ return MCPTaskSchema.parse(
256248
+ await this.sendRequest(
256249
+ "tasks/cancel",
256250
+ { taskId: validateTaskId(taskId) },
256251
+ abortSignal,
256252
+ { skipModernResultCheck: true }
256253
+ )
256254
+ );
256255
+ }
256256
+ /** Retrieve the underlying tool result after a task reaches a terminal state. */
256257
+ async getTaskResult(taskId, abortSignal) {
256258
+ this.requireTaskCapability();
256259
+ return MCPToolCallResultSchema.parse(
256260
+ await this.sendRequest(
256261
+ "tasks/result",
256262
+ { taskId: validateTaskId(taskId) },
256263
+ abortSignal,
256264
+ { skipModernResultCheck: true }
256265
+ )
256266
+ );
256267
+ }
256268
+ /** Poll a durable task with bounded backoff until terminal or input-required. */
256269
+ async waitForTask(taskId, options = {}) {
256270
+ const maxWaitMs = Math.max(
256271
+ 1e3,
256272
+ Math.min(options.maxWaitMs ?? 10 * 6e4, 24 * 60 * 6e4)
256273
+ );
256274
+ const deadline = Date.now() + maxWaitMs;
256275
+ while (true) {
256276
+ const task = await this.getTask(taskId, options.abortSignal);
256277
+ if (task.status === "input_required") return { task };
256278
+ if (["completed", "failed", "cancelled"].includes(task.status)) {
256279
+ return {
256280
+ task,
256281
+ result: await this.getTaskResult(task.taskId, options.abortSignal)
256282
+ };
256283
+ }
256284
+ const remaining = deadline - Date.now();
256285
+ if (remaining <= 0) {
256286
+ throw new Error(
256287
+ `MCP task "${task.taskId}" did not finish within ${maxWaitMs}ms.`
256288
+ );
256289
+ }
256290
+ await waitForMcpTaskPoll(
256291
+ Math.min(task.pollInterval ?? 1e3, remaining),
256292
+ options.abortSignal
256293
+ );
256294
+ }
256295
+ }
256296
+ onTaskStatus(listener) {
256297
+ this.taskStatusListeners.add(listener);
256298
+ return () => this.taskStatusListeners.delete(listener);
256299
+ }
256300
+ requireTaskCapability() {
256301
+ if (!this.serverCapabilities.tasks) {
256302
+ throw new Error(
256303
+ `MCP server "${this.serverName}" does not advertise durable task support.`
256304
+ );
256305
+ }
256306
+ }
255801
256307
  async negotiateProtocol() {
255802
256308
  let rawDiscoverResult;
255803
256309
  try {
@@ -255945,13 +256451,13 @@ var MCPClient = class {
255945
256451
  this.pendingRequests.delete(id);
255946
256452
  pending.removeAbortListener?.();
255947
256453
  pending.reject(
255948
- new Error(`Unable to write MCP request: ${safeMessage(error)}`)
256454
+ new Error(`Unable to write MCP request: ${safeMessage2(error)}`)
255949
256455
  );
255950
256456
  }
255951
256457
  );
255952
256458
  });
255953
256459
  return request.then((result) => {
255954
- if (modernVersion && method !== "server/discover") {
256460
+ if (modernVersion && method !== "server/discover" && !options.skipModernResultCheck) {
255955
256461
  assertCompleteModernResult(result, method);
255956
256462
  }
255957
256463
  return result;
@@ -255990,6 +256496,14 @@ var MCPClient = class {
255990
256496
  }
255991
256497
  const notification = MCPNotificationSchema.safeParse(raw);
255992
256498
  if (notification.success && typeof raw === "object" && raw !== null && !("id" in raw)) {
256499
+ if (notification.data.method === "notifications/tasks/status") {
256500
+ const task = MCPTaskSchema.safeParse(notification.data.params);
256501
+ if (task.success) {
256502
+ for (const listener of this.taskStatusListeners) {
256503
+ listener(task.data);
256504
+ }
256505
+ }
256506
+ }
255993
256507
  const kinds = catalogKindsFromNotification(
255994
256508
  notification.data.method,
255995
256509
  notification.data.params
@@ -256011,7 +256525,7 @@ var MCPClient = class {
256011
256525
  pending.reject(
256012
256526
  new McpJsonRpcError(
256013
256527
  response.error.code,
256014
- safeMessage(response.error.message),
256528
+ safeMessage2(response.error.message),
256015
256529
  "data" in response.error ? response.error.data : void 0
256016
256530
  )
256017
256531
  );
@@ -256021,7 +256535,7 @@ var MCPClient = class {
256021
256535
  }
256022
256536
  cleanup(error) {
256023
256537
  this.isConnected = false;
256024
- this.lastError = safeMessage(error);
256538
+ this.lastError = safeMessage2(error);
256025
256539
  for (const pending of this.pendingRequests.values()) {
256026
256540
  clearTimeout(pending.timeout);
256027
256541
  pending.removeAbortListener?.();
@@ -256076,9 +256590,39 @@ function assertSupportedProtocolVersion(initializeResult) {
256076
256590
  );
256077
256591
  }
256078
256592
  }
256079
- function safeMessage(error) {
256593
+ function safeMessage2(error) {
256080
256594
  return sanitizeExternalErrorMessage(error, { singleLine: true });
256081
256595
  }
256596
+ function validateTaskId(taskId) {
256597
+ const parsed = z36.string().trim().min(1).max(512).safeParse(taskId);
256598
+ if (!parsed.success)
256599
+ throw new Error("MCP task id must be a non-empty string.");
256600
+ return parsed.data;
256601
+ }
256602
+ function waitForMcpTaskPoll(delayMs, abortSignal) {
256603
+ if (abortSignal?.aborted) {
256604
+ return Promise.reject(createAbortError("MCP task polling was cancelled."));
256605
+ }
256606
+ return new Promise((resolve26, reject) => {
256607
+ let settled = false;
256608
+ const timer = setTimeout(
256609
+ () => {
256610
+ settled = true;
256611
+ abortSignal?.removeEventListener("abort", onAbort);
256612
+ resolve26();
256613
+ },
256614
+ Math.max(1, delayMs)
256615
+ );
256616
+ const onAbort = () => {
256617
+ if (settled) return;
256618
+ settled = true;
256619
+ clearTimeout(timer);
256620
+ abortSignal?.removeEventListener("abort", onAbort);
256621
+ reject(createAbortError("MCP task polling was cancelled."));
256622
+ };
256623
+ abortSignal?.addEventListener("abort", onAbort, { once: true });
256624
+ });
256625
+ }
256082
256626
  var DynamicMCPTool = class {
256083
256627
  constructor(serverName, toolDefinition, risk, client) {
256084
256628
  this.client = client;
@@ -256128,7 +256672,7 @@ var DynamicMCPTool = class {
256128
256672
  } catch (error) {
256129
256673
  return {
256130
256674
  ok: false,
256131
- error: `MCP tool execution failed: ${safeMessage(error)}`
256675
+ error: `MCP tool execution failed: ${safeMessage2(error)}`
256132
256676
  };
256133
256677
  }
256134
256678
  }
@@ -256187,7 +256731,7 @@ ${templateCatalog}` : "");
256187
256731
  } catch (error) {
256188
256732
  return {
256189
256733
  ok: false,
256190
- error: `MCP resource read failed: ${safeMessage(error)}`
256734
+ error: `MCP resource read failed: ${safeMessage2(error)}`
256191
256735
  };
256192
256736
  }
256193
256737
  }
@@ -256256,8 +256800,10 @@ var StreamableHttpMCPClient = class {
256256
256800
  serverCapabilities = {
256257
256801
  tools: false,
256258
256802
  resources: false,
256259
- prompts: false
256803
+ prompts: false,
256804
+ tasks: false
256260
256805
  };
256806
+ taskStatusListeners = /* @__PURE__ */ new Set();
256261
256807
  async start() {
256262
256808
  if (this.started) {
256263
256809
  throw new Error(`MCP client "${this.serverName}" has already started.`);
@@ -256301,7 +256847,7 @@ var StreamableHttpMCPClient = class {
256301
256847
  return true;
256302
256848
  } catch (error) {
256303
256849
  this.protocolWarnings.push(
256304
- `Excluded MCP tool "${tool.name}": ${safeMessage2(error)}.`
256850
+ `Excluded MCP tool "${tool.name}": ${safeMessage22(error)}.`
256305
256851
  );
256306
256852
  return false;
256307
256853
  }
@@ -256392,6 +256938,116 @@ var StreamableHttpMCPClient = class {
256392
256938
  );
256393
256939
  return flattenPromptMessages(result);
256394
256940
  }
256941
+ async callToolTask(originalToolName, args, options = {}) {
256942
+ this.requireTaskCapability();
256943
+ const ttl = options.ttl;
256944
+ if (ttl !== void 0 && (!Number.isSafeInteger(ttl) || ttl < 1 || ttl > 7 * 24 * 60 * 60 * 1e3)) {
256945
+ throw new Error(
256946
+ "MCP task ttl must be an integer between 1ms and 7 days."
256947
+ );
256948
+ }
256949
+ const result = await this.request(
256950
+ "tools/call",
256951
+ {
256952
+ name: originalToolName,
256953
+ arguments: args,
256954
+ task: ttl === void 0 ? {} : { ttl }
256955
+ },
256956
+ options.abortSignal,
256957
+ true,
256958
+ { skipModernResultCheck: true }
256959
+ );
256960
+ return MCPCreateTaskResultSchema.parse(result).task;
256961
+ }
256962
+ async getTask(taskId, abortSignal) {
256963
+ this.requireTaskCapability();
256964
+ return MCPTaskSchema.parse(
256965
+ await this.request(
256966
+ "tasks/get",
256967
+ { taskId: validateTaskId2(taskId) },
256968
+ abortSignal,
256969
+ true,
256970
+ { skipModernResultCheck: true }
256971
+ )
256972
+ );
256973
+ }
256974
+ async listTasks(abortSignal) {
256975
+ this.requireTaskCapability();
256976
+ return collectMcpPaginatedItems({
256977
+ method: "tasks/list",
256978
+ request: (params) => this.request("tasks/list", params, abortSignal, true, {
256979
+ skipModernResultCheck: true
256980
+ }),
256981
+ parse: (value) => {
256982
+ const page = MCPTasksListSchema.parse(value);
256983
+ return { items: page.tasks, nextCursor: page.nextCursor };
256984
+ },
256985
+ identity: (task) => task.taskId,
256986
+ restartOnError: isPaginationSessionReset
256987
+ });
256988
+ }
256989
+ async cancelTask(taskId, abortSignal) {
256990
+ this.requireTaskCapability();
256991
+ return MCPTaskSchema.parse(
256992
+ await this.request(
256993
+ "tasks/cancel",
256994
+ { taskId: validateTaskId2(taskId) },
256995
+ abortSignal,
256996
+ true,
256997
+ { skipModernResultCheck: true }
256998
+ )
256999
+ );
257000
+ }
257001
+ async getTaskResult(taskId, abortSignal) {
257002
+ this.requireTaskCapability();
257003
+ return MCPToolCallResultSchema.parse(
257004
+ await this.request(
257005
+ "tasks/result",
257006
+ { taskId: validateTaskId2(taskId) },
257007
+ abortSignal,
257008
+ true,
257009
+ { skipModernResultCheck: true }
257010
+ )
257011
+ );
257012
+ }
257013
+ async waitForTask(taskId, options = {}) {
257014
+ const maxWaitMs = Math.max(
257015
+ 1e3,
257016
+ Math.min(options.maxWaitMs ?? 10 * 6e4, 24 * 60 * 6e4)
257017
+ );
257018
+ const deadline = Date.now() + maxWaitMs;
257019
+ while (true) {
257020
+ const task = await this.getTask(taskId, options.abortSignal);
257021
+ if (task.status === "input_required") return { task };
257022
+ if (["completed", "failed", "cancelled"].includes(task.status)) {
257023
+ return {
257024
+ task,
257025
+ result: await this.getTaskResult(task.taskId, options.abortSignal)
257026
+ };
257027
+ }
257028
+ const remaining = deadline - Date.now();
257029
+ if (remaining <= 0) {
257030
+ throw new Error(
257031
+ `MCP task "${task.taskId}" did not finish within ${maxWaitMs}ms.`
257032
+ );
257033
+ }
257034
+ await waitForMcpTaskPoll2(
257035
+ Math.min(task.pollInterval ?? 1e3, remaining),
257036
+ options.abortSignal
257037
+ );
257038
+ }
257039
+ }
257040
+ onTaskStatus(listener) {
257041
+ this.taskStatusListeners.add(listener);
257042
+ return () => this.taskStatusListeners.delete(listener);
257043
+ }
257044
+ requireTaskCapability() {
257045
+ if (!this.serverCapabilities.tasks) {
257046
+ throw new Error(
257047
+ `MCP server "${this.serverName}" does not advertise durable task support.`
257048
+ );
257049
+ }
257050
+ }
256395
257051
  async callTool(originalToolName, args, abortSignal) {
256396
257052
  if (!this.started) {
256397
257053
  throw new Error(`MCP client "${this.serverName}" is not connected.`);
@@ -256441,7 +257097,7 @@ var StreamableHttpMCPClient = class {
256441
257097
  } catch (error) {
256442
257098
  if (error instanceof McpSessionExpiredError && allowSessionRecovery && this.started && this.negotiatedProtocol?.era === "legacy" && method !== "initialize") {
256443
257099
  this.recoveryCount += 1;
256444
- this.lastError = safeMessage2(error);
257100
+ this.lastError = safeMessage22(error);
256445
257101
  await this.reinitialize(abortSignal);
256446
257102
  if ("cursor" in params) {
256447
257103
  throw new McpPaginationSessionResetError(this.serverName);
@@ -256465,12 +257121,12 @@ var StreamableHttpMCPClient = class {
256465
257121
  if (parsed.data.error) {
256466
257122
  throw new McpJsonRpcError(
256467
257123
  parsed.data.error.code,
256468
- safeMessage2(parsed.data.error.message),
257124
+ safeMessage22(parsed.data.error.message),
256469
257125
  "data" in parsed.data.error ? parsed.data.error.data : void 0
256470
257126
  );
256471
257127
  }
256472
257128
  const modernVersion = options.modernVersion ?? (this.negotiatedProtocol?.era === "modern" ? this.negotiatedProtocol.version : void 0);
256473
- if (modernVersion && method !== "server/discover") {
257129
+ if (modernVersion && method !== "server/discover" && !options.skipModernResultCheck) {
256474
257130
  assertCompleteModernResult(parsed.data.result, method);
256475
257131
  }
256476
257132
  this.lastError = void 0;
@@ -256635,7 +257291,7 @@ var StreamableHttpMCPClient = class {
256635
257291
  if (protocolError) throw protocolError;
256636
257292
  throw new McpHttpResponseError(
256637
257293
  response.status,
256638
- `MCP HTTP ${response.status}: ${safeMessage2(detail || response.statusText)}`
257294
+ `MCP HTTP ${response.status}: ${safeMessage22(detail || response.statusText)}`
256639
257295
  );
256640
257296
  }
256641
257297
  const sessionId = isModern ? null : response.headers.get("mcp-session-id");
@@ -256663,7 +257319,10 @@ var StreamableHttpMCPClient = class {
256663
257319
  const contentType = response.headers.get("content-type") || "";
256664
257320
  return contentType.includes("text/event-stream") ? parseSseJson(
256665
257321
  body,
256666
- typeof payload.id === "number" ? payload.id : void 0
257322
+ typeof payload.id === "number" ? payload.id : void 0,
257323
+ (task) => {
257324
+ for (const listener of this.taskStatusListeners) listener(task);
257325
+ }
256667
257326
  ) : JSON.parse(body);
256668
257327
  } catch (error) {
256669
257328
  if (controller.signal.aborted) {
@@ -256677,7 +257336,7 @@ var StreamableHttpMCPClient = class {
256677
257336
  throw error;
256678
257337
  }
256679
257338
  throw new Error(
256680
- `MCP server "${this.serverName}" request failed: ${safeMessage2(error)}`
257339
+ `MCP server "${this.serverName}" request failed: ${safeMessage22(error)}`
256681
257340
  );
256682
257341
  } finally {
256683
257342
  clearTimeout(timeout);
@@ -256782,7 +257441,7 @@ function parseHttpProtocolError(body) {
256782
257441
  if (!parsed.success || !parsed.data.error) return void 0;
256783
257442
  return new McpJsonRpcError(
256784
257443
  parsed.data.error.code,
256785
- safeMessage2(parsed.data.error.message),
257444
+ safeMessage22(parsed.data.error.message),
256786
257445
  "data" in parsed.data.error ? parsed.data.error.data : void 0
256787
257446
  );
256788
257447
  } catch {
@@ -256894,19 +257553,57 @@ async function fetchClientCredentialsToken(oauth, abortSignal) {
256894
257553
  );
256895
257554
  return grant.token;
256896
257555
  }
256897
- function parseSseJson(body, expectedId) {
257556
+ function parseSseJson(body, expectedId, onTaskStatus) {
256898
257557
  const dataEntries = body.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).filter((line) => line && line !== "[DONE]");
256899
257558
  for (const data of dataEntries) {
256900
257559
  const parsed = JSON.parse(data);
257560
+ if (onTaskStatus && typeof parsed === "object" && parsed !== null && "method" in parsed && parsed.method === "notifications/tasks/status" && !("id" in parsed && typeof parsed.id === "number") && "params" in parsed) {
257561
+ const task = MCPTaskSchema.safeParse(parsed.params);
257562
+ if (task.success) onTaskStatus(task.data);
257563
+ }
256901
257564
  if (expectedId === void 0 || typeof parsed === "object" && parsed !== null && "id" in parsed && parsed.id === expectedId) {
256902
257565
  return parsed;
256903
257566
  }
256904
257567
  }
256905
257568
  throw new Error("MCP SSE response contained no matching JSON-RPC response.");
256906
257569
  }
256907
- function safeMessage2(value) {
257570
+ function safeMessage22(value) {
256908
257571
  return sanitizeExternalErrorMessage(value, { singleLine: true });
256909
257572
  }
257573
+ function validateTaskId2(taskId) {
257574
+ const parsed = z44.string().trim().min(1).max(512).safeParse(taskId);
257575
+ if (!parsed.success)
257576
+ throw new Error("MCP task id must be a non-empty string.");
257577
+ return parsed.data;
257578
+ }
257579
+ function waitForMcpTaskPoll2(delayMs, abortSignal) {
257580
+ if (abortSignal?.aborted) {
257581
+ const error = new Error("MCP task polling was cancelled.");
257582
+ error.name = "AbortError";
257583
+ return Promise.reject(error);
257584
+ }
257585
+ return new Promise((resolve26, reject) => {
257586
+ let settled = false;
257587
+ const timer = setTimeout(
257588
+ () => {
257589
+ settled = true;
257590
+ abortSignal?.removeEventListener("abort", onAbort);
257591
+ resolve26();
257592
+ },
257593
+ Math.max(1, delayMs)
257594
+ );
257595
+ const onAbort = () => {
257596
+ if (settled) return;
257597
+ settled = true;
257598
+ clearTimeout(timer);
257599
+ abortSignal?.removeEventListener("abort", onAbort);
257600
+ const error = new Error("MCP task polling was cancelled.");
257601
+ error.name = "AbortError";
257602
+ reject(error);
257603
+ };
257604
+ abortSignal?.addEventListener("abort", onAbort, { once: true });
257605
+ });
257606
+ }
256910
257607
  function assertSecureMcpUrl(value, label) {
256911
257608
  const url = new URL(value);
256912
257609
  const hostname = url.hostname.toLowerCase().replace(/^\[|\]$/g, "");
@@ -257404,7 +258101,7 @@ var PermissionEngine = class {
257404
258101
  "replace_file_content",
257405
258102
  "multi_replace_file_content"
257406
258103
  ]);
257407
- const safeArgs = isRecord3(args) ? args : {};
258104
+ const safeArgs = isRecord4(args) ? args : {};
257408
258105
  if (toolName === "update_plan") {
257409
258106
  return {
257410
258107
  action: "allow",
@@ -257663,7 +258360,7 @@ var PermissionEngine = class {
257663
258360
  };
257664
258361
  }
257665
258362
  };
257666
- function isRecord3(value) {
258363
+ function isRecord4(value) {
257667
258364
  return typeof value === "object" && value !== null && !Array.isArray(value);
257668
258365
  }
257669
258366
  function firstString(...values) {
@@ -257675,7 +258372,7 @@ import {
257675
258372
  existsSync as existsSync10,
257676
258373
  lstatSync as lstatSync4,
257677
258374
  mkdirSync as mkdirSync4,
257678
- readdirSync as readdirSync2,
258375
+ readdirSync as readdirSync3,
257679
258376
  renameSync as renameSync4,
257680
258377
  rmSync as rmSync3
257681
258378
  } from "fs";
@@ -257790,7 +258487,7 @@ var CheckpointManager = class {
257790
258487
  const sessionDir = this.getSessionCheckpointDir();
257791
258488
  if (!existsSync10(sessionDir)) return;
257792
258489
  const loaded = [];
257793
- for (const entry of readdirSync2(sessionDir, { withFileTypes: true })) {
258490
+ for (const entry of readdirSync3(sessionDir, { withFileTypes: true })) {
257794
258491
  if (!entry.isDirectory() || !CheckpointIdSchema.safeParse(entry.name).success) {
257795
258492
  continue;
257796
258493
  }
@@ -258484,7 +259181,7 @@ import {
258484
259181
  lstatSync as lstatSync5,
258485
259182
  mkdirSync as mkdirSync5,
258486
259183
  openSync as openSync5,
258487
- readdirSync as readdirSync3,
259184
+ readdirSync as readdirSync4,
258488
259185
  renameSync as renameSync5,
258489
259186
  rmSync as rmSync4,
258490
259187
  statSync as statSync2,
@@ -258500,8 +259197,8 @@ import {
258500
259197
  statSync as statSync22,
258501
259198
  unlinkSync as unlinkSync4
258502
259199
  } from "fs";
258503
- import { homedir as homedir5 } from "os";
258504
- import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute24, join as join25, parse as parse2, resolve as resolve25 } from "path";
259200
+ import { homedir as homedir6 } from "os";
259201
+ import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute24, join as join25, parse as parse3, resolve as resolve25 } from "path";
258505
259202
  import { z as z37 } from "zod";
258506
259203
  import {
258507
259204
  closeSync as closeSync32,
@@ -258512,7 +259209,7 @@ import {
258512
259209
  readdirSync as readdirSync22,
258513
259210
  unlinkSync as unlinkSync22
258514
259211
  } from "fs";
258515
- import { basename as basename22, join as join34, resolve as resolve34 } from "path";
259212
+ import { basename as basename22, join as join34, resolve as resolve35 } from "path";
258516
259213
  import { z as z45 } from "zod";
258517
259214
  var SafeObjectKeySchema = z30.string().refine(
258518
259215
  (key) => !["__proto__", "constructor", "prototype"].includes(key),
@@ -258828,6 +259525,7 @@ var PRIVATE_DIRECTORY_MODE2 = 448;
258828
259525
  var PRIVATE_FILE_MODE2 = 384;
258829
259526
  var SESSION_SNAPSHOT_MAX_BYTES = 256 * 1024 * 1024;
258830
259527
  var SESSION_LOG_MAX_BYTES = 256 * 1024 * 1024;
259528
+ var SESSION_EVENT_CACHE_MAX_ITEMS = 25e3;
258831
259529
  var HISTORY_JOURNAL_COMPACT_BYTES = 1024 * 1024;
258832
259530
  var HISTORY_JOURNAL_COMPACT_RECORDS = 32;
258833
259531
  var HistoryJournalRecordSchema = z210.object({
@@ -259007,10 +259705,18 @@ function normalizeTracePath(filePath, cwd) {
259007
259705
  }
259008
259706
  return replaceWorkspacePath(filePath, cwd);
259009
259707
  }
259708
+ function cloneSessionEvents(events) {
259709
+ return events.map((event) => ({
259710
+ ...event,
259711
+ payload: structuredClone(event.payload)
259712
+ }));
259713
+ }
259010
259714
  var SessionStore = class {
259011
259715
  cwd;
259012
259716
  sessionRootPath;
259013
259717
  historyJournalWrites = /* @__PURE__ */ new Map();
259718
+ /** Avoid reparsing a long immutable event journal for every UI refresh. */
259719
+ eventCache = /* @__PURE__ */ new Map();
259014
259720
  constructor(cwd, sessionRootPath = ".orbit/sessions") {
259015
259721
  this.cwd = resolve7(cwd);
259016
259722
  this.sessionRootPath = sessionRootPath.trim();
@@ -259082,7 +259788,7 @@ var SessionStore = class {
259082
259788
  try {
259083
259789
  sessionRoot = this.resolveSessionRoot();
259084
259790
  if (!existsSync11(sessionRoot)) return [];
259085
- dirs = readdirSync3(sessionRoot);
259791
+ dirs = readdirSync4(sessionRoot);
259086
259792
  } catch {
259087
259793
  return [];
259088
259794
  }
@@ -259105,6 +259811,7 @@ var SessionStore = class {
259105
259811
  });
259106
259812
  const file = join9(this.resolveSessionDirectory(sessionId), "events.jsonl");
259107
259813
  appendJsonLine(file, event);
259814
+ this.eventCache.delete(sessionId);
259108
259815
  return event;
259109
259816
  }
259110
259817
  getEvents(sessionId) {
@@ -259114,14 +259821,27 @@ var SessionStore = class {
259114
259821
  } catch {
259115
259822
  return [];
259116
259823
  }
259117
- if (!existsSync11(file)) return [];
259824
+ if (!existsSync11(file)) {
259825
+ this.eventCache.delete(sessionId);
259826
+ return [];
259827
+ }
259828
+ let fileStats;
259829
+ try {
259830
+ const stats = statSync2(file);
259831
+ fileStats = { mtimeMs: stats.mtimeMs, size: stats.size };
259832
+ const cached = this.eventCache.get(sessionId);
259833
+ if (cached && cached.mtimeMs === fileStats.mtimeMs && cached.size === fileStats.size) {
259834
+ return cloneSessionEvents(cached.events);
259835
+ }
259836
+ } catch {
259837
+ }
259118
259838
  let content;
259119
259839
  try {
259120
259840
  content = readBoundedRegularFile(file, SESSION_LOG_MAX_BYTES) ?? "";
259121
259841
  } catch {
259122
259842
  return [];
259123
259843
  }
259124
- return content.split("\n").filter((line) => line.trim()).flatMap((line) => {
259844
+ const events = content.split("\n").filter((line) => line.trim()).flatMap((line) => {
259125
259845
  try {
259126
259846
  const parsed = SessionEventSchema.safeParse(JSON.parse(line));
259127
259847
  return parsed.success && parsed.data.sessionId === sessionId ? [
@@ -259137,6 +259857,12 @@ var SessionStore = class {
259137
259857
  return [];
259138
259858
  }
259139
259859
  });
259860
+ if (fileStats && events.length <= SESSION_EVENT_CACHE_MAX_ITEMS) {
259861
+ this.eventCache.set(sessionId, { ...fileStats, events });
259862
+ } else {
259863
+ this.eventCache.delete(sessionId);
259864
+ }
259865
+ return cloneSessionEvents(events);
259140
259866
  }
259141
259867
  /** Returns a compact, local-only summary derived from the audit stream. */
259142
259868
  getMetrics(sessionId) {
@@ -259461,6 +260187,7 @@ var SessionStore = class {
259461
260187
  if (existsSync11(dir)) {
259462
260188
  rmSync4(dir, { recursive: true, force: true });
259463
260189
  }
260190
+ this.eventCache.delete(id);
259464
260191
  }
259465
260192
  createUniqueSessionDirectory() {
259466
260193
  for (let attempt = 0; attempt < 10; attempt += 1) {
@@ -259938,7 +260665,7 @@ function parseProjectRegistrySnapshot(value) {
259938
260665
  }
259939
260666
  var ProjectRegistry = class {
259940
260667
  filePath;
259941
- constructor(rootPath = join25(homedir5(), ".orbit")) {
260668
+ constructor(rootPath = join25(homedir6(), ".orbit")) {
259942
260669
  const root = resolve25(rootPath);
259943
260670
  this.filePath = join25(root, "projects.json");
259944
260671
  }
@@ -260101,7 +260828,7 @@ function canonicalizeProjectPath(projectPath) {
260101
260828
  if (!isAbsolute24(projectPath))
260102
260829
  throw new Error("Project path must be absolute.");
260103
260830
  const requested = resolve25(projectPath);
260104
- if (requested === parse2(requested).root) {
260831
+ if (requested === parse3(requested).root) {
260105
260832
  throw new Error(
260106
260833
  "A filesystem root cannot be registered as an Orbit project."
260107
260834
  );
@@ -260109,7 +260836,7 @@ function canonicalizeProjectPath(projectPath) {
260109
260836
  if (!isDirectory(requested))
260110
260837
  throw new Error("Project path must be an existing directory.");
260111
260838
  const canonical = realpathSync2.native(requested);
260112
- if (canonical === parse2(canonical).root) {
260839
+ if (canonical === parse3(canonical).root) {
260113
260840
  throw new Error(
260114
260841
  "A filesystem root cannot be registered as an Orbit project."
260115
260842
  );
@@ -260203,7 +260930,7 @@ var AgentRunSchema = z45.object({
260203
260930
  var AgentRunStore = class {
260204
260931
  constructor(cwd, options = {}) {
260205
260932
  this.cwd = cwd;
260206
- this.directory = resolve34(cwd, ".orbit", "agent-runs");
260933
+ this.directory = resolve35(cwd, ".orbit", "agent-runs");
260207
260934
  this.now = options.now ?? (() => /* @__PURE__ */ new Date());
260208
260935
  this.ownerPid = options.ownerPid ?? process.pid;
260209
260936
  this.ownerInstanceId = options.ownerInstanceId ?? generateId("orbit");
@@ -260535,7 +261262,7 @@ var AgentRunStore = class {
260535
261262
  this.cwd,
260536
261263
  join34(".orbit", "agent-runs")
260537
261264
  );
260538
- if (resolve34(safeDirectory) !== this.directory) {
261265
+ if (resolve35(safeDirectory) !== this.directory) {
260539
261266
  throw new Error("Orbit agent-run directory escaped the workspace.");
260540
261267
  }
260541
261268
  }
@@ -260632,9 +261359,9 @@ import { z as z73 } from "zod";
260632
261359
  import { randomUUID as randomUUID52 } from "crypto";
260633
261360
  import { z as z103 } from "zod";
260634
261361
  import { z as z93 } from "zod";
260635
- import { z as z112 } from "zod";
261362
+ import { z as z113 } from "zod";
260636
261363
  import path8 from "path";
260637
- import { existsSync as existsSync34, statSync as statSync3 } from "fs";
261364
+ import { existsSync as existsSync35, statSync as statSync3 } from "fs";
260638
261365
  import { z as z122 } from "zod";
260639
261366
  import { z as z132 } from "zod";
260640
261367
  function createInitialState(sessionId, task, maxAttempts = 8) {
@@ -260904,7 +261631,7 @@ var PromptCacheSlabBuilder = class {
260904
261631
  "- Run at least one DeepSeek request to create a stable slab."
260905
261632
  ].join("\n");
260906
261633
  }
260907
- const slabs = readdirSync4(dir).filter((file) => file.endsWith(".json")).sort().slice(0, PROMPT_CACHE_MAX_FILES).map((file) => readPromptCacheSlabMetadata(join10(dir, file))).filter((meta) => Boolean(meta?.hash)).sort((a2, b) => {
261634
+ const slabs = readdirSync5(dir).filter((file) => file.endsWith(".json")).sort().slice(0, PROMPT_CACHE_MAX_FILES).map((file) => readPromptCacheSlabMetadata(join10(dir, file))).filter((meta) => Boolean(meta?.hash)).sort((a2, b) => {
260908
261635
  const aTime = Date.parse(
260909
261636
  a2.telemetry?.at(-1)?.recordedAt || a2.lastPrimedAt || ""
260910
261637
  );
@@ -264801,7 +265528,8 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264801
265528
  this.getContextWindowStatus(activeModel2).compactAtTokens * 0.4
264802
265529
  )
264803
265530
  )
264804
- )
265531
+ ),
265532
+ forcedSkills: this.options?.forcedSkills
264805
265533
  }
264806
265534
  );
264807
265535
  this.reportSkillContext(this.cachedContextPack);
@@ -264828,6 +265556,10 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264828
265556
  (t2) => this.options.allowedTools.includes(t2.name)
264829
265557
  );
264830
265558
  }
265559
+ if (this.options?.disallowedTools) {
265560
+ const deniedTools = new Set(this.options.disallowedTools);
265561
+ toolDefs = toolDefs.filter((tool) => !deniedTools.has(tool.name));
265562
+ }
264831
265563
  if (this.finalResponseOnlyReason) {
264832
265564
  toolDefs = [];
264833
265565
  }
@@ -264836,7 +265568,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264836
265568
  this.provider,
264837
265569
  activeModel2
264838
265570
  );
264839
- const projectMemory = this.projectMemoryStore.read();
265571
+ const projectMemory = this.options?.memoryMode === "none" ? void 0 : this.projectMemoryStore.read();
264840
265572
  const taskPlan = this.sessionManager.getTaskPlan();
264841
265573
  const baseSystemPrompt = this.options?.systemPromptOverride || Planner.makeSystemPrompt(
264842
265574
  activeModel2,
@@ -264867,7 +265599,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264867
265599
  now: runStartedAt,
264868
265600
  repoMapText,
264869
265601
  sessionGoal: this.sessionManager.getActiveSession()?.goal,
264870
- projectMemory: projectMemory.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
265602
+ projectMemory: projectMemory?.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
264871
265603
  taskPlan: taskPlan?.items.map(
264872
265604
  (item) => `[${item.status}] ${item.text}`
264873
265605
  )
@@ -264894,7 +265626,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264894
265626
  now: runStartedAt,
264895
265627
  repoMapText,
264896
265628
  sessionGoal: this.sessionManager.getActiveSession()?.goal,
264897
- projectMemory: projectMemory.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
265629
+ projectMemory: projectMemory?.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
264898
265630
  taskPlan: taskPlan?.items.map(
264899
265631
  (item) => `[${item.status}] ${item.text}`
264900
265632
  )
@@ -264916,7 +265648,8 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264916
265648
  const supportsThinking = capabilities.thinking;
264917
265649
  const thinkingPolicy = resolveModelThinkingPolicy(activeModel2, {
264918
265650
  isComplexTask,
264919
- isRepairTurn
265651
+ isRepairTurn,
265652
+ requestedEffort: this.options?.thinkingEffort
264920
265653
  });
264921
265654
  const thinkingEnabled = supportsThinking ? thinkingPolicy?.enabled ?? Boolean(isRepairTurn || isComplexTask) : false;
264922
265655
  if (!this.resolvePricing(activeModel2)) {
@@ -268326,20 +269059,20 @@ function abortError2(signal) {
268326
269059
  function toError2(error) {
268327
269060
  return error instanceof Error ? error : new Error(String(error));
268328
269061
  }
268329
- var ParallelWriterTaskSchema = z112.object({
268330
- id: z112.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/),
268331
- task: z112.string().trim().min(1).max(2e4),
268332
- scopes: z112.array(AgentOwnershipScopeSchema).min(1).max(50)
269062
+ var ParallelWriterTaskSchema = z113.object({
269063
+ id: z113.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/),
269064
+ task: z113.string().trim().min(1).max(2e4),
269065
+ scopes: z113.array(AgentOwnershipScopeSchema).min(1).max(50)
268333
269066
  });
268334
- var ParallelWorkPlanSchema = z112.object({
268335
- summary: z112.string().trim().min(1).max(2e4),
268336
- tasks: z112.array(ParallelWriterTaskSchema).min(1).max(4)
269067
+ var ParallelWorkPlanSchema = z113.object({
269068
+ summary: z113.string().trim().min(1).max(2e4),
269069
+ tasks: z113.array(ParallelWriterTaskSchema).min(1).max(4)
268337
269070
  }).superRefine((plan, context) => {
268338
269071
  const ids = /* @__PURE__ */ new Set();
268339
269072
  for (const [index, task] of plan.tasks.entries()) {
268340
269073
  if (ids.has(task.id)) {
268341
269074
  context.addIssue({
268342
- code: z112.ZodIssueCode.custom,
269075
+ code: z113.ZodIssueCode.custom,
268343
269076
  path: ["tasks", index, "id"],
268344
269077
  message: `Duplicate writer task id: ${task.id}`
268345
269078
  });
@@ -268356,7 +269089,7 @@ var ParallelWorkPlanSchema = z112.object({
268356
269089
  );
268357
269090
  if (!overlap) continue;
268358
269091
  context.addIssue({
268359
- code: z112.ZodIssueCode.custom,
269092
+ code: z113.ZodIssueCode.custom,
268360
269093
  path: ["tasks", right, "scopes"],
268361
269094
  message: `Writer scopes overlap with task ${plan.tasks[left].id}.`
268362
269095
  });
@@ -268538,12 +269271,13 @@ var ReviewVerdictSchema = z122.object({
268538
269271
  feedback: z122.string().default("")
268539
269272
  });
268540
269273
  var Orchestrator = class {
268541
- constructor(cwd, config, provider, task, interaction) {
269274
+ constructor(cwd, config, provider, task, interaction, profile) {
268542
269275
  this.cwd = cwd;
268543
269276
  this.config = config;
268544
269277
  this.provider = provider;
268545
269278
  this.task = task;
268546
269279
  this.interaction = interaction;
269280
+ this.profile = profile;
268547
269281
  this.agentRunTracker = new AgentRunTracker(
268548
269282
  cwd,
268549
269283
  task,
@@ -268556,6 +269290,7 @@ var Orchestrator = class {
268556
269290
  provider;
268557
269291
  task;
268558
269292
  interaction;
269293
+ profile;
268559
269294
  activeLoops = /* @__PURE__ */ new Map();
268560
269295
  activeTaskScheduler;
268561
269296
  agentRunTracker;
@@ -268639,7 +269374,7 @@ var Orchestrator = class {
268639
269374
  snapshotWorkingTree: true
268640
269375
  });
268641
269376
  }
268642
- if (!existsSync34(worktree.path) || !statSync3(worktree.path).isDirectory()) {
269377
+ if (!existsSync35(worktree.path) || !statSync3(worktree.path).isDirectory()) {
268643
269378
  throw new Error(
268644
269379
  `Worktree manager returned a missing directory: ${worktree.path}`
268645
269380
  );
@@ -268778,13 +269513,14 @@ var Orchestrator = class {
268778
269513
  `Create a detailed implementation plan for: ${this.task}`,
268779
269514
  this.interaction,
268780
269515
  {
268781
- modelOverride: this.config.models.planner,
269516
+ modelOverride: this.profile?.model || this.config.models.planner,
269517
+ thinkingEffort: this.profile?.effort,
268782
269518
  systemPromptOverride: `You are the Orbit Planner Agent.
268783
269519
  Analyze the codebase and produce a bounded implementation plan. Do not modify files.
268784
269520
  Return ONLY one JSON object with this shape:
268785
269521
  {"summary":"shared architecture and acceptance criteria","tasks":[{"id":"short-id","task":"self-contained writer assignment","scopes":["workspace-relative/path"]}]}
268786
269522
  Use 2-4 tasks only when their write scopes are provably disjoint and they can be implemented independently from the same baseline. Use one task with scope "workspace" for coupled work. Never invent absolute paths or parent traversal.`,
268787
- allowedTools: [
269523
+ allowedTools: applyProfileToolPolicy(this.profile, [
268788
269524
  "read_file",
268789
269525
  "list_files",
268790
269526
  "glob",
@@ -268793,7 +269529,10 @@ Use 2-4 tasks only when their write scopes are provably disjoint and they can be
268793
269529
  "git_diff",
268794
269530
  "detect_project",
268795
269531
  "inspect_project"
268796
- ],
269532
+ ]),
269533
+ disallowedTools: this.profile?.disallowedTools,
269534
+ forcedSkills: this.profile?.skills,
269535
+ memoryMode: this.profile?.memory,
268797
269536
  disableMcp: true,
268798
269537
  agent: { id: activeId, role: "planner" },
268799
269538
  sessionStorage: this.agentSessionStorage()
@@ -268867,7 +269606,7 @@ Work only in your assigned isolated worktree and only inside the declared write
268867
269606
  const tracked = this.addTrackedAgent(
268868
269607
  role,
268869
269608
  prompt,
268870
- this.config.models.coder,
269609
+ this.profile?.model || this.config.models.coder,
268871
269610
  budgetFraction,
268872
269611
  "write",
268873
269612
  scopes
@@ -268880,9 +269619,10 @@ Work only in your assigned isolated worktree and only inside the declared write
268880
269619
  prompt,
268881
269620
  this.interaction,
268882
269621
  {
268883
- modelOverride: this.config.models.coder,
268884
- systemPromptOverride: systemPrompt,
268885
- allowedTools: [
269622
+ modelOverride: this.profile?.model || this.config.models.coder,
269623
+ thinkingEffort: this.profile?.effort,
269624
+ systemPromptOverride: [systemPrompt, this.profile?.systemPrompt].filter(Boolean).join("\n\n"),
269625
+ allowedTools: applyProfileToolPolicy(this.profile, [
268886
269626
  "read_file",
268887
269627
  "write_file",
268888
269628
  "edit_file",
@@ -268896,7 +269636,10 @@ Work only in your assigned isolated worktree and only inside the declared write
268896
269636
  "get_background_task_output",
268897
269637
  "kill_background_task",
268898
269638
  "list_background_tasks"
268899
- ],
269639
+ ]),
269640
+ disallowedTools: this.profile?.disallowedTools,
269641
+ forcedSkills: this.profile?.skills,
269642
+ memoryMode: this.profile?.memory,
268900
269643
  disableMcp: true,
268901
269644
  agent: { id: activeId, role },
268902
269645
  sessionStorage: this.agentSessionStorage()
@@ -269137,6 +269880,7 @@ Work only in your assigned isolated worktree and only inside the declared write
269137
269880
  this.interaction,
269138
269881
  {
269139
269882
  modelOverride: this.config.models.reviewer,
269883
+ thinkingEffort: this.profile?.effort,
269140
269884
  systemPromptOverride: `You are the Orbit Reviewer Agent.
269141
269885
  Your assigned perspective is ${perspective}. ${instruction}
269142
269886
  Review the current workspace diff and run tests when useful. Do not edit files.
@@ -269282,6 +270026,13 @@ function errorMessage22(error) {
269282
270026
  const raw = error instanceof Error ? error.message : String(error);
269283
270027
  return redactSecrets(raw).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim().slice(0, 2e3);
269284
270028
  }
270029
+ function applyProfileToolPolicy(profile, tools) {
270030
+ const denied = new Set(profile?.disallowedTools ?? []);
270031
+ const allowed = profile?.allowedTools;
270032
+ return tools.filter(
270033
+ (tool) => !denied.has(tool) && (!allowed || allowed.includes(tool))
270034
+ );
270035
+ }
269285
270036
  var AcceptanceVerificationSchema = z132.object({
269286
270037
  name: z132.string().trim().min(1).max(120),
269287
270038
  command: z132.string().trim().min(1).max(4e3),
@@ -269794,7 +270545,7 @@ function buildCacheDiagnostics(cwd) {
269794
270545
  "\u25CF No cache telemetry yet. It will appear after a completed DeepSeek request."
269795
270546
  );
269796
270547
  }
269797
- const slabs = readdirSync5(dir).filter((file) => file.endsWith(".json")).sort().slice(0, CACHE_DIAGNOSTIC_MAX_FILES).map((file) => readPromptCacheSlabMetadata(join11(dir, file))).filter((item) => Boolean(item)).sort((a2, b) => latestObservation(b).localeCompare(latestObservation(a2))).slice(0, 5);
270548
+ const slabs = readdirSync6(dir).filter((file) => file.endsWith(".json")).sort().slice(0, CACHE_DIAGNOSTIC_MAX_FILES).map((file) => readPromptCacheSlabMetadata(join11(dir, file))).filter((item) => Boolean(item)).sort((a2, b) => latestObservation(b).localeCompare(latestObservation(a2))).slice(0, 5);
269798
270549
  if (slabs.length === 0) {
269799
270550
  return picocolors4.gray(
269800
270551
  "\u25CF No readable cache slab metadata found. Remove stale .orbit/cache-slabs entries if this persists."
@@ -270462,7 +271213,9 @@ var DoctorSnapshotSchema = z47.object({
270462
271213
  mcp: z47.boolean(),
270463
271214
  mcpServerCount: z47.number().int().nonnegative(),
270464
271215
  skills: z47.boolean(),
270465
- automaticCompaction: z47.boolean()
271216
+ automaticCompaction: z47.boolean(),
271217
+ agentProfiles: z47.number().int().nonnegative(),
271218
+ agentProfileErrors: z47.number().int().nonnegative()
270466
271219
  }),
270467
271220
  safety: z47.object({
270468
271221
  permissionMode: z47.enum(["strict", "normal", "auto", "plan"]),
@@ -270574,6 +271327,19 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
270574
271327
  );
270575
271328
  const configuredModels = allConfiguredModelNames(config);
270576
271329
  const issues = [];
271330
+ const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
271331
+ const profileCatalog = agentSettings.enabled ? discoverAgentProfiles(cwd, agentSettings) : { profiles: [], diagnostics: [] };
271332
+ const profileErrors = profileCatalog.diagnostics.filter(
271333
+ (diagnostic2) => diagnostic2.severity === "error"
271334
+ );
271335
+ if (profileErrors.length > 0) {
271336
+ issues.push({
271337
+ severity: "error",
271338
+ code: "agent_profiles.invalid",
271339
+ message: `${profileErrors.length} Agent Profile manifest(s) failed validation.`,
271340
+ remediation: "Run orbit agents validate --json and repair the reported manifests."
271341
+ });
271342
+ }
270577
271343
  if (nodeMajor < 20) {
270578
271344
  issues.push({
270579
271345
  severity: "error",
@@ -270687,7 +271453,9 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
270687
271453
  mcp: config.tools.mcp.enabled,
270688
271454
  mcpServerCount: Object.keys(config.mcpServers).length,
270689
271455
  skills: config.skills.enabled,
270690
- automaticCompaction: config.context.autoCompact
271456
+ automaticCompaction: config.context.autoCompact,
271457
+ agentProfiles: profileCatalog.profiles.length,
271458
+ agentProfileErrors: profileErrors.length
270691
271459
  },
270692
271460
  safety: {
270693
271461
  permissionMode: config.permissions.mode,
@@ -270808,6 +271576,7 @@ function buildDoctorReport(cwd, config = ConfigLoader.loadSync(cwd), options = {
270808
271576
  const gitStatus = commandOutput(exec6, "git status --short", cwd);
270809
271577
  const webSearch = config.tools.webSearch;
270810
271578
  const skills = config.skills;
271579
+ const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
270811
271580
  const mcpServers = Object.keys(config.mcpServers || {});
270812
271581
  const providerKeyName = provider?.apiKeyEnv || "configured provider key";
270813
271582
  const hasApiKey = apiKeyLoaded(defaultProvider, config);
@@ -270928,6 +271697,15 @@ function buildDoctorReport(cwd, config = ConfigLoader.loadSync(cwd), options = {
270928
271697
  lines.push(
270929
271698
  `\u25CF Skill dirs: ${skills.directories.map((dir) => picocolors6.cyan(dir)).join(", ")}`
270930
271699
  );
271700
+ const agentProfiles = agentSettings.enabled ? discoverAgentProfiles(cwd, agentSettings) : { profiles: [], diagnostics: [] };
271701
+ lines.push("");
271702
+ lines.push(picocolors6.bold("Agent Profiles"));
271703
+ lines.push(
271704
+ `\u25CF Profiles: ${boolText(agentSettings.enabled)} discovered=${agentProfiles.profiles.length} errors=${agentProfiles.diagnostics.filter((item) => item.severity === "error").length}`
271705
+ );
271706
+ lines.push(
271707
+ `\u25CF Profile dirs: ${agentSettings.directories.map((dir) => picocolors6.cyan(dir)).join(", ")}`
271708
+ );
270931
271709
  lines.push("");
270932
271710
  lines.push(picocolors6.bold("Safety & Context"));
270933
271711
  lines.push(
@@ -272261,7 +273039,7 @@ var n2 = class extends V {
272261
273039
  import { styleText as styleText2, stripVTControlCharacters } from "util";
272262
273040
  import process$1 from "process";
272263
273041
  var import_sisteransi2 = __toESM(require_src(), 1);
272264
- import { existsSync as existsSync15, lstatSync as lstatSync6, readdirSync as readdirSync6 } from "fs";
273042
+ import { existsSync as existsSync15, lstatSync as lstatSync6, readdirSync as readdirSync7 } from "fs";
272265
273043
  import { dirname as dirname9, join as join13 } from "path";
272266
273044
  function isUnicodeSupported() {
272267
273045
  if (process$1.platform !== "win32") {
@@ -273536,7 +274314,7 @@ import picocolors20 from "picocolors";
273536
274314
 
273537
274315
  // src/tui/FullscreenTui.ts
273538
274316
  import { join as join15 } from "path";
273539
- import { homedir as homedir7 } from "os";
274317
+ import { homedir as homedir8 } from "os";
273540
274318
  import { existsSync as existsSync16 } from "fs";
273541
274319
  import { exec as exec4 } from "child_process";
273542
274320
  import readline3 from "readline";
@@ -274628,14 +275406,14 @@ function findPreviousHistoryEntry(history, query, startIndex = history.length) {
274628
275406
 
274629
275407
  // src/tui/InputHistoryStore.ts
274630
275408
  import { join as join14 } from "path";
274631
- import { homedir as homedir6 } from "os";
275409
+ import { homedir as homedir7 } from "os";
274632
275410
  import { z as z49 } from "zod";
274633
275411
  var INPUT_HISTORY_MAX_BYTES = 1048576;
274634
275412
  var INPUT_HISTORY_MAX_ENTRIES = 500;
274635
275413
  var INPUT_HISTORY_ENTRY_MAX_CHARS = 2e4;
274636
275414
  var inputHistorySchema = z49.array(z49.string().max(INPUT_HISTORY_ENTRY_MAX_CHARS)).max(INPUT_HISTORY_MAX_ENTRIES);
274637
275415
  var InputHistoryStore = class {
274638
- constructor(filePath = join14(homedir6(), ".orbit", "input_history.json")) {
275416
+ constructor(filePath = join14(homedir7(), ".orbit", "input_history.json")) {
274639
275417
  this.filePath = filePath;
274640
275418
  }
274641
275419
  filePath;
@@ -275312,7 +276090,7 @@ function parseNpmJsonString(raw) {
275312
276090
  }
275313
276091
  }
275314
276092
  function compareSemanticVersions(left, right) {
275315
- const parse6 = (version) => {
276093
+ const parse7 = (version) => {
275316
276094
  const withoutBuild = version.split("+", 1)[0] ?? version;
275317
276095
  const prereleaseSeparator = withoutBuild.indexOf("-");
275318
276096
  const corePart = prereleaseSeparator === -1 ? withoutBuild : withoutBuild.slice(0, prereleaseSeparator);
@@ -275322,8 +276100,8 @@ function compareSemanticVersions(left, right) {
275322
276100
  prerelease: prereleasePart ? prereleasePart.split(".") : []
275323
276101
  };
275324
276102
  };
275325
- const leftVersion = parse6(left);
275326
- const rightVersion = parse6(right);
276103
+ const leftVersion = parse7(left);
276104
+ const rightVersion = parse7(right);
275327
276105
  for (let index = 0; index < 3; index++) {
275328
276106
  const difference = (leftVersion.core[index] ?? 0) - (rightVersion.core[index] ?? 0);
275329
276107
  if (difference !== 0) return Math.sign(difference);
@@ -275503,7 +276281,7 @@ async function pageText(text2) {
275503
276281
  var TUI_ERROR_LOG_MAX_BYTES = 1048576;
275504
276282
  function appendTuiErrorLog(context, error) {
275505
276283
  try {
275506
- const logPath = join15(homedir7(), ".orbit", "tui_error.log");
276284
+ const logPath = join15(homedir8(), ".orbit", "tui_error.log");
275507
276285
  let previous = "";
275508
276286
  try {
275509
276287
  previous = readBoundedRegularFile(logPath, TUI_ERROR_LOG_MAX_BYTES) ?? "";
@@ -277601,7 +278379,7 @@ var FullscreenTui = class {
277601
278379
  import picocolors19 from "picocolors";
277602
278380
  import { rmSync as rmSync6, watch } from "fs";
277603
278381
  import { dirname as dirname14, resolve as resolve14 } from "path";
277604
- import { homedir as homedir10 } from "os";
278382
+ import { homedir as homedir11 } from "os";
277605
278383
  import http3 from "http";
277606
278384
  import { randomBytes as randomBytes4, randomUUID as randomUUID13, timingSafeEqual as timingSafeEqual2 } from "crypto";
277607
278385
  import { z as z70 } from "zod";
@@ -277610,11 +278388,11 @@ import { z as z70 } from "zod";
277610
278388
  import picocolors18 from "picocolors";
277611
278389
 
277612
278390
  // src/commands/customCommands.ts
277613
- import { existsSync as existsSync17, readdirSync as readdirSync7 } from "fs";
278391
+ import { existsSync as existsSync17, readdirSync as readdirSync8 } from "fs";
277614
278392
  import { basename as basename4, extname as extname3, join as join16 } from "path";
277615
- import { homedir as homedir8 } from "os";
278393
+ import { homedir as homedir9 } from "os";
277616
278394
  import { fileURLToPath as fileURLToPath3 } from "url";
277617
- import { parse as parse3 } from "yaml";
278395
+ import { parse as parse4 } from "yaml";
277618
278396
  import { z as z51 } from "zod";
277619
278397
  var CommandMetadataSchema = z51.object({
277620
278398
  description: z51.string().max(240).optional(),
@@ -277635,7 +278413,7 @@ function parseLooseFrontmatter(raw) {
277635
278413
  }
277636
278414
  function parseCommandMetadata(raw) {
277637
278415
  try {
277638
- return parse3(raw) || {};
278416
+ return parse4(raw) || {};
277639
278417
  } catch {
277640
278418
  return parseLooseFrontmatter(raw);
277641
278419
  }
@@ -277674,7 +278452,7 @@ function loadDirectory(directory, source) {
277674
278452
  const current = queue.shift();
277675
278453
  let entries;
277676
278454
  try {
277677
- entries = readdirSync7(current, { withFileTypes: true });
278455
+ entries = readdirSync8(current, { withFileTypes: true });
277678
278456
  } catch {
277679
278457
  continue;
277680
278458
  }
@@ -277709,7 +278487,7 @@ function loadCustomCommands(cwd, reservedNames = [], options = {}) {
277709
278487
  Array.from(reservedNames, (name) => name.replace(/^\//, "").toLowerCase())
277710
278488
  );
277711
278489
  const merged = /* @__PURE__ */ new Map();
277712
- const userHome = options.homeDir || homedir8();
278490
+ const userHome = options.homeDir || homedir9();
277713
278491
  const builtinDirectory = options.builtinDir === false ? void 0 : options.builtinDir || resolveBundledCommandsDirectory();
277714
278492
  if (builtinDirectory) {
277715
278493
  mergeDirectory(merged, builtinDirectory, "builtin", reserved);
@@ -277827,8 +278605,8 @@ import { z as z58 } from "zod";
277827
278605
 
277828
278606
  // src/runtime/AutocompleteCandidates.ts
277829
278607
  import glob4 from "fast-glob";
277830
- import { existsSync as existsSync18, readdirSync as readdirSync8 } from "fs";
277831
- import { homedir as homedir9 } from "os";
278608
+ import { existsSync as existsSync18, readdirSync as readdirSync9 } from "fs";
278609
+ import { homedir as homedir10 } from "os";
277832
278610
  import { dirname as dirname10, join as join17, resolve as resolve9 } from "path";
277833
278611
  import { z as z55 } from "zod";
277834
278612
  var AUTOCOMPLETE_SYMBOL_INDEX_MAX_BYTES = 256 * 1024 * 1024;
@@ -277871,7 +278649,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
277871
278649
  const symbols = [];
277872
278650
  const sessions = [];
277873
278651
  const normCwd = resolve9(cwd).toLowerCase().replace(/\\/g, "/");
277874
- const normHome = resolve9(homedir9()).toLowerCase().replace(/\\/g, "/");
278652
+ const normHome = resolve9(homedir10()).toLowerCase().replace(/\\/g, "/");
277875
278653
  const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname10(normCwd) === normCwd;
277876
278654
  if (isHomeOrRoot) {
277877
278655
  return { commands, commandDetails, files, symbols, sessions };
@@ -277913,7 +278691,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
277913
278691
  config.session?.path ?? ".orbit/sessions"
277914
278692
  );
277915
278693
  if (existsSync18(sessionDir)) {
277916
- for (const dir of readdirSync8(sessionDir)) {
278694
+ for (const dir of readdirSync9(sessionDir)) {
277917
278695
  if (existsSync18(join17(sessionDir, dir, "session.json"))) {
277918
278696
  sessions.push(dir);
277919
278697
  }
@@ -278127,6 +278905,8 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278127
278905
  elements.inspectorClose.addEventListener('click', () => setInspector(false));
278128
278906
  elements.inspectorBackdrop.addEventListener('click', () => setInspector(false));
278129
278907
  elements.inspector.addEventListener('keydown', trapInspectorFocus);
278908
+ elements.sidebar.addEventListener('keydown', trapSidebarFocus);
278909
+ elements.commandPalette.addEventListener('keydown', trapCommandPaletteFocus);
278130
278910
  elements.connectionState.addEventListener('click', () => {
278131
278911
  if (!state.ready) void initialize();
278132
278912
  });
@@ -278316,6 +279096,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278316
279096
  if (state.projectLaunchPending && !force) return;
278317
279097
  elements.projectDialog.hidden = true;
278318
279098
  elements.projectDialog.setAttribute('aria-hidden', 'true');
279099
+ syncApplicationModalState();
278319
279100
  if (restoreFocus && state.projectDialogReturnFocus) state.projectDialogReturnFocus.focus();
278320
279101
  state.projectDialogReturnFocus = null;
278321
279102
  };
@@ -278324,6 +279105,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278324
279105
  state.projectDialogReturnFocus = document.activeElement;
278325
279106
  elements.projectDialog.hidden = false;
278326
279107
  elements.projectDialog.setAttribute('aria-hidden', 'false');
279108
+ syncApplicationModalState();
278327
279109
  elements.projectPathInput.focus();
278328
279110
  elements.projectPathInput.select();
278329
279111
  };
@@ -278576,6 +279358,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278576
279358
  if (elements.sessionDeleteDialog.hidden) return;
278577
279359
  elements.sessionDeleteDialog.hidden = true;
278578
279360
  elements.sessionDeleteDialog.setAttribute('aria-hidden', 'true');
279361
+ syncApplicationModalState();
278579
279362
  state.pendingSessionDeleteId = null;
278580
279363
  if (restoreFocus && state.sessionDeleteReturnFocus) state.sessionDeleteReturnFocus.focus();
278581
279364
  state.sessionDeleteReturnFocus = null;
@@ -278588,6 +279371,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278588
279371
  elements.sessionDeleteName.textContent = title && title.textContent || copy.untitledTask;
278589
279372
  elements.sessionDeleteDialog.hidden = false;
278590
279373
  elements.sessionDeleteDialog.setAttribute('aria-hidden', 'false');
279374
+ syncApplicationModalState();
278591
279375
  elements.sessionDeleteConfirm.focus();
278592
279376
  };
278593
279377
  const handleSessionListClick = (event) => {
@@ -278662,7 +279446,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278662
279446
  elements.fullAccessBackdrop.disabled = false;
278663
279447
  elements.fullAccessCancel.disabled = false;
278664
279448
  elements.fullAccessConfirm.disabled = false;
278665
- elements.appShell.inert = false;
279449
+ syncApplicationModalState();
278666
279450
  state.fullAccessRequest = null;
278667
279451
  if (restoreFocus && state.fullAccessReturnFocus) state.fullAccessReturnFocus.focus();
278668
279452
  state.fullAccessReturnFocus = null;
@@ -278688,7 +279472,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278688
279472
  };
278689
279473
  elements.fullAccessDialog.hidden = false;
278690
279474
  elements.fullAccessDialog.setAttribute('aria-hidden', 'false');
278691
- elements.appShell.inert = true;
279475
+ syncApplicationModalState();
278692
279476
  elements.fullAccessConfirm.focus();
278693
279477
  return promise;
278694
279478
  };
@@ -279829,6 +280613,8 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
279829
280613
  disconnected: '连接断开',
279830
280614
  retry: '立即重试',
279831
280615
  ready: '准备就绪',
280616
+ waitingApproval: '等待审批',
280617
+ cancelling: '正在取消',
279832
280618
  thinking: 'Orbit 正在思考…',
279833
280619
  sendAction: '发送消息',
279834
280620
  stopAction: '停止生成',
@@ -279983,6 +280769,8 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
279983
280769
  disconnected: 'Disconnected',
279984
280770
  retry: 'Retry now',
279985
280771
  ready: 'Ready',
280772
+ waitingApproval: 'Waiting for approval',
280773
+ cancelling: 'Cancelling',
279986
280774
  thinking: 'Orbit is thinking…',
279987
280775
  sendAction: 'Send message',
279988
280776
  stopAction: 'Stop generating',
@@ -280139,6 +280927,8 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280139
280927
  disconnected: '連線中斷',
280140
280928
  retry: '立即重試',
280141
280929
  ready: '準備就緒',
280930
+ waitingApproval: '等待審批',
280931
+ cancelling: '正在取消',
280142
280932
  thinking: 'Orbit 正在思考…',
280143
280933
  stopping: '正在停止…',
280144
280934
  stopped: '已停止產生',
@@ -280687,6 +281477,11 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280687
281477
  elements.sidebarCollapseButton.setAttribute('aria-label', copy.collapseNavigation);
280688
281478
  }
280689
281479
 
281480
+ function syncApplicationModalState() {
281481
+ const modalOpen = !elements.commandPalette.hidden || !elements.sessionDeleteDialog.hidden || !elements.fullAccessDialog.hidden || !elements.projectDialog.hidden;
281482
+ elements.appShell.inert = modalOpen;
281483
+ }
281484
+
280690
281485
  function setDesktopSidebarCollapsed(collapsed) {
280691
281486
  elements.appShell.classList.toggle('sidebar-collapsed', collapsed);
280692
281487
  writeLocalStorage('orbit.webui.sidebar', collapsed ? 'collapsed' : 'expanded');
@@ -280721,8 +281516,14 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280721
281516
  elements.appShell.classList.add('sidebar-open');
280722
281517
  elements.menuButton.setAttribute('aria-expanded', 'true');
280723
281518
  syncSidebarInteractivity();
280724
- const firstControl = elements.sidebar.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
280725
- if (firstControl) firstControl.focus();
281519
+ const firstControl = Array.from(elements.sidebar.querySelectorAll(
281520
+ 'button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])',
281521
+ )).find((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
281522
+ const focusFirstControl = () => {
281523
+ if (firstControl) firstControl.focus({ preventScroll: true });
281524
+ };
281525
+ if (typeof requestAnimationFrame === 'function') requestAnimationFrame(focusFirstControl);
281526
+ else focusFirstControl();
280726
281527
  }
280727
281528
 
280728
281529
  function setInspector(open, tab) {
@@ -280755,7 +281556,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280755
281556
  if (event.key !== 'Tab' || !elements.inspector.classList.contains('is-open')) return;
280756
281557
  const focusable = Array.from(elements.inspector.querySelectorAll(
280757
281558
  'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])',
280758
- )).filter((node) => !node.hidden && node.offsetParent !== null);
281559
+ )).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
280759
281560
  if (!focusable.length) {
280760
281561
  event.preventDefault();
280761
281562
  elements.inspector.focus();
@@ -280772,6 +281573,23 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280772
281573
  }
280773
281574
  }
280774
281575
 
281576
+ function trapSidebarFocus(event) {
281577
+ if (event.key !== 'Tab' || !mobileSidebarQuery.matches || !elements.appShell.classList.contains('sidebar-open')) return;
281578
+ const focusable = Array.from(elements.sidebar.querySelectorAll(
281579
+ 'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])',
281580
+ )).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
281581
+ if (!focusable.length) return;
281582
+ const first = focusable[0];
281583
+ const last = focusable[focusable.length - 1];
281584
+ if (event.shiftKey && document.activeElement === first) {
281585
+ event.preventDefault();
281586
+ last.focus();
281587
+ } else if (!event.shiftKey && document.activeElement === last) {
281588
+ event.preventDefault();
281589
+ first.focus();
281590
+ }
281591
+ }
281592
+
280775
281593
  function selectInspectorTab(tab) {
280776
281594
  const tasks = tab === 'tasks';
280777
281595
  const activity = tab === 'activity';
@@ -281990,7 +282808,7 @@ function createMissionControl(runtime) {
281990
282808
  const activeSession = session.recent.find((candidate) => candidate.active);
281991
282809
  const active = Boolean(data.turn?.active);
281992
282810
  const workActive = active || activeAgents > 0 || activeBackgroundTasks > 0;
281993
- const statusLabel = workActive ? copy.running : agents.some((agent) => agent.status === "blocked") ? language === "en" ? "Blocked" : chinese("\u5DF2\u963B\u585E", "\u5DF2\u963B\u585E") : copy.ready;
282811
+ const statusLabel = data.task.status === "waiting_approval" ? copy.waitingApproval : data.task.status === "cancelling" ? copy.cancelling : workActive ? copy.running : agents.some((agent) => agent.status === "blocked") ? language === "en" ? "Blocked" : chinese("\u5DF2\u963B\u585E", "\u5DF2\u963B\u585E") : copy.ready;
281994
282812
  const titleText = activeSession?.title || copy.untitledTask;
281995
282813
  const goalText = session.goal || (language === "en" ? "Add a durable goal with /goal so Orbit can keep long work aligned." : chinese(
281996
282814
  "\u4F7F\u7528 /goal \u6DFB\u52A0\u6301\u7EED\u76EE\u6807\uFF0C\u8BA9 Orbit \u5728\u957F\u4EFB\u52A1\u4E2D\u4FDD\u6301\u65B9\u5411\u3002",
@@ -282010,6 +282828,14 @@ function createMissionControl(runtime) {
282010
282828
  heading.append(title, status);
282011
282829
  const goal = document.createElement("p");
282012
282830
  goal.textContent = goalText;
282831
+ if (data.task.reason) {
282832
+ const reason = document.createElement("small");
282833
+ reason.className = "task-overview-reason";
282834
+ reason.textContent = data.task.reason;
282835
+ card.append(heading, goal, reason);
282836
+ } else {
282837
+ card.append(heading, goal);
282838
+ }
282013
282839
  const stats = document.createElement("dl");
282014
282840
  stats.className = "task-overview-stats";
282015
282841
  const rows = [
@@ -282045,7 +282871,7 @@ function createMissionControl(runtime) {
282045
282871
  item.append(term, description, small);
282046
282872
  stats.append(item);
282047
282873
  }
282048
- card.append(heading, goal, stats);
282874
+ card.append(stats);
282049
282875
  elements.taskOverview.replaceChildren(card);
282050
282876
  }
282051
282877
  function renderAgentRuns(value) {
@@ -282315,7 +283141,7 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
282315
283141
  paletteReturnFocus = document.activeElement;
282316
283142
  elements.commandPalette.hidden = false;
282317
283143
  elements.commandPalette.setAttribute('aria-hidden', 'false');
282318
- elements.appShell.inert = true;
283144
+ syncApplicationModalState();
282319
283145
  elements.commandSearch.value = '';
282320
283146
  paletteSelection = 0;
282321
283147
  renderCommandPalette();
@@ -282326,12 +283152,29 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
282326
283152
  if (elements.commandPalette.hidden) return;
282327
283153
  elements.commandPalette.hidden = true;
282328
283154
  elements.commandPalette.setAttribute('aria-hidden', 'true');
282329
- elements.appShell.inert = false;
283155
+ syncApplicationModalState();
282330
283156
  const returnTarget = paletteReturnFocus;
282331
283157
  paletteReturnFocus = null;
282332
283158
  if (returnTarget && returnTarget.isConnected) returnTarget.focus();
282333
283159
  }
282334
283160
 
283161
+ function trapCommandPaletteFocus(event) {
283162
+ if (event.key !== 'Tab' || elements.commandPalette.hidden) return;
283163
+ const focusable = Array.from(elements.commandPalette.querySelectorAll(
283164
+ 'button:not(:disabled):not([tabindex="-1"]), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])',
283165
+ )).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
283166
+ if (!focusable.length) return;
283167
+ const first = focusable[0];
283168
+ const last = focusable[focusable.length - 1];
283169
+ if (event.shiftKey && document.activeElement === first) {
283170
+ event.preventDefault();
283171
+ last.focus();
283172
+ } else if (!event.shiftKey && document.activeElement === last) {
283173
+ event.preventDefault();
283174
+ first.focus();
283175
+ }
283176
+ }
283177
+
282335
283178
  function executePaletteAction(index) {
282336
283179
  const action = paletteActions[index];
282337
283180
  if (!action || (action.idle && state.busy)) return;
@@ -284246,7 +285089,7 @@ var WEB_UI_PROJECT_ERROR_CODE_SET = new Set(
284246
285089
  WEB_UI_PROJECT_ERROR_CODES
284247
285090
  );
284248
285091
  function sanitizeWebEventPayload(type, payload) {
284249
- if (!isRecord4(payload)) return void 0;
285092
+ if (!isRecord5(payload)) return void 0;
284250
285093
  switch (type) {
284251
285094
  case "ui_turn_started":
284252
285095
  return {
@@ -284500,7 +285343,7 @@ function summarizeWebToolValue(value, options = {}) {
284500
285343
  return options.allowPlainText ? safeWebToolText(candidate, 700) : "";
284501
285344
  }
284502
285345
  }
284503
- if (!isRecord4(candidate)) return "";
285346
+ if (!isRecord5(candidate)) return "";
284504
285347
  const safeFields = [
284505
285348
  "path",
284506
285349
  "filePath",
@@ -284601,7 +285444,7 @@ function readCookie(req, name) {
284601
285444
  return "";
284602
285445
  }
284603
285446
  function sanitizeTokenUsage(value) {
284604
- if (!isRecord4(value)) return void 0;
285447
+ if (!isRecord5(value)) return void 0;
284605
285448
  return {
284606
285449
  inputTokens: safeNumber(value.inputTokens),
284607
285450
  outputTokens: safeNumber(value.outputTokens),
@@ -284628,7 +285471,7 @@ function safeWebToolText(value, maxLength) {
284628
285471
  function stripAnsi2(value) {
284629
285472
  return value.replace(/\u001b\[[0-9;]*m/g, "");
284630
285473
  }
284631
- function isRecord4(value) {
285474
+ function isRecord5(value) {
284632
285475
  return typeof value === "object" && value !== null;
284633
285476
  }
284634
285477
 
@@ -284636,7 +285479,7 @@ function isRecord4(value) {
284636
285479
  function summarizeWebUiAgentRuns(value) {
284637
285480
  if (!Array.isArray(value)) return [];
284638
285481
  return value.slice(0, 12).flatMap((candidate) => {
284639
- if (!isRecord5(candidate) || !Array.isArray(candidate.agents)) return [];
285482
+ if (!isRecord6(candidate) || !Array.isArray(candidate.agents)) return [];
284640
285483
  const id = boundedString(candidate.id, 128);
284641
285484
  if (!/^run_[a-z0-9-]+$/.test(id)) return [];
284642
285485
  return [
@@ -284653,7 +285496,7 @@ function summarizeWebUiAgentRuns(value) {
284653
285496
  costUsd: finiteNumber(candidate.costUsd),
284654
285497
  updatedAt: boundedString(candidate.updatedAt, 64),
284655
285498
  agents: candidate.agents.slice(0, 64).flatMap((agent) => {
284656
- if (!isRecord5(agent)) return [];
285499
+ if (!isRecord6(agent)) return [];
284657
285500
  const agentId = boundedString(agent.id, 128);
284658
285501
  if (!/^agent_[a-z0-9-]+$/.test(agentId)) return [];
284659
285502
  return [
@@ -284675,13 +285518,13 @@ function summarizeWebUiAgentRuns(value) {
284675
285518
  ) ? boundedString(agent.sessionId, 128) : "",
284676
285519
  budgetUsd: finiteNumber(agent.budgetUsd),
284677
285520
  costUsd: finiteNumber(agent.costUsd),
284678
- access: isRecord5(agent.access) && agent.access.mode === "write" ? "write" : "read",
284679
- scopes: isRecord5(agent.access) && Array.isArray(agent.access.scopes) ? agent.access.scopes.slice(0, 20).map((scope) => redactSecrets(boundedString(scope, 300))) : [],
285521
+ access: isRecord6(agent.access) && agent.access.mode === "write" ? "write" : "read",
285522
+ scopes: isRecord6(agent.access) && Array.isArray(agent.access.scopes) ? agent.access.scopes.slice(0, 20).map((scope) => redactSecrets(boundedString(scope, 300))) : [],
284680
285523
  startedAt: boundedString(agent.startedAt, 64),
284681
285524
  endedAt: boundedString(agent.endedAt, 64),
284682
285525
  error: redactSecrets(boundedString(agent.error, 1e3)),
284683
- steeringCount: isRecord5(agent.steering) && typeof agent.steering.count === "number" && Number.isFinite(agent.steering.count) ? Math.max(0, Math.floor(agent.steering.count)) : 0,
284684
- lastSteeredAt: isRecord5(agent.steering) && typeof agent.steering.lastAt === "string" ? boundedString(agent.steering.lastAt, 64) : ""
285526
+ steeringCount: isRecord6(agent.steering) && typeof agent.steering.count === "number" && Number.isFinite(agent.steering.count) ? Math.max(0, Math.floor(agent.steering.count)) : 0,
285527
+ lastSteeredAt: isRecord6(agent.steering) && typeof agent.steering.lastAt === "string" ? boundedString(agent.steering.lastAt, 64) : ""
284685
285528
  }
284686
285529
  ];
284687
285530
  })
@@ -284698,7 +285541,7 @@ function boundedString(value, maxLength) {
284698
285541
  function boundedEnum(value, values) {
284699
285542
  return typeof value === "string" && values.includes(value) ? value : "unknown";
284700
285543
  }
284701
- function isRecord5(value) {
285544
+ function isRecord6(value) {
284702
285545
  return typeof value === "object" && value !== null;
284703
285546
  }
284704
285547
 
@@ -284725,7 +285568,7 @@ function summarizeWebUiContextFiles(value, limit = 24) {
284725
285568
  const seen = /* @__PURE__ */ new Set();
284726
285569
  if (Array.isArray(value)) {
284727
285570
  for (const candidate of value) {
284728
- if (!isRecord6(candidate)) continue;
285571
+ if (!isRecord7(candidate)) continue;
284729
285572
  const path9 = normalizeSafeWebUiPath(candidate.path);
284730
285573
  if (!path9 || seen.has(path9)) continue;
284731
285574
  seen.add(path9);
@@ -284784,6 +285627,9 @@ function collectWebUiStatus(options, activeTurn) {
284784
285627
  const review = summarizeWebUiReview(
284785
285628
  safeCall(() => loop?.getSessionReview?.())
284786
285629
  );
285630
+ const approval = collectWebUiApproval(
285631
+ safeCall(() => options.getPendingApproval?.())
285632
+ );
284787
285633
  const contextFiles = summarizeWebUiContextFiles(relevantFiles);
284788
285634
  const normalizedSessions = normalizeSessions(sessions, sessionId);
284789
285635
  const recentSessions = normalizedSessions.filter(
@@ -284807,6 +285653,10 @@ function collectWebUiStatus(options, activeTurn) {
284807
285653
  workspace: cwd,
284808
285654
  projects,
284809
285655
  agentRuns,
285656
+ task: {
285657
+ status: activeTurn?.cancelRequested ? "cancelling" : approval ? "waiting_approval" : activeTurn ? "running" : "ready",
285658
+ reason: approval?.reason || ""
285659
+ },
284810
285660
  agentTeam: {
284811
285661
  preset: config.agent.teamPreset,
284812
285662
  maxReviewAttempts: config.agent.maxReviewAttempts,
@@ -284928,9 +285778,7 @@ function collectWebUiStatus(options, activeTurn) {
284928
285778
  startedAt: activeTurn.startedAt,
284929
285779
  cancelRequested: activeTurn.cancelRequested
284930
285780
  } : { active: false },
284931
- approval: collectWebUiApproval(
284932
- safeCall(() => options.getPendingApproval?.())
284933
- ),
285781
+ approval,
284934
285782
  cacheDiagnostics: redactSecrets(stripAnsi3(buildCacheDiagnostics(cwd))),
284935
285783
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
284936
285784
  };
@@ -284943,7 +285791,7 @@ function summarizeWebUiBackgroundTasks(value) {
284943
285791
  "killed",
284944
285792
  "timed_out"
284945
285793
  ]);
284946
- return (Array.isArray(value) ? value : []).filter(isRecord6).slice(0, 64).map((task) => ({
285794
+ return (Array.isArray(value) ? value : []).filter(isRecord7).slice(0, 64).map((task) => ({
284947
285795
  id: safeLabel(typeof task.id === "string" ? task.id : "", 200),
284948
285796
  status: typeof task.status === "string" && statuses.has(task.status) ? task.status : "failed",
284949
285797
  startedAt: safeLabel(
@@ -284959,7 +285807,7 @@ function summarizeWebUiBackgroundTasks(value) {
284959
285807
  function summarizeWebUiInputQueue(value) {
284960
285808
  const modes = /* @__PURE__ */ new Set(["follow_up", "steer"]);
284961
285809
  const sources = /* @__PURE__ */ new Set(["terminal", "web", "api"]);
284962
- return (Array.isArray(value) ? value : []).filter(isRecord6).slice(0, 12).map((item) => ({
285810
+ return (Array.isArray(value) ? value : []).filter(isRecord7).slice(0, 12).map((item) => ({
284963
285811
  id: safeLabel(typeof item.id === "string" ? item.id : "", 200),
284964
285812
  mode: typeof item.mode === "string" && modes.has(item.mode) ? item.mode : "follow_up",
284965
285813
  source: typeof item.source === "string" && sources.has(item.source) ? item.source : "api",
@@ -284978,12 +285826,12 @@ function summarizeWebUiInputQueue(value) {
284978
285826
  })).filter((item) => item.id && item.text);
284979
285827
  }
284980
285828
  function summarizeWebUiReview(value) {
284981
- const record = isRecord6(value) ? value : {};
285829
+ const record = isRecord7(value) ? value : {};
284982
285830
  const rawChanges = Array.isArray(record.fileChanges) ? record.fileChanges : [];
284983
285831
  const rawToolCalls = Array.isArray(record.toolCalls) ? record.toolCalls : [];
284984
285832
  const rawCheckpoints = Array.isArray(record.checkpoints) ? record.checkpoints : [];
284985
285833
  const rawVerification = Array.isArray(record.verification) ? record.verification : [];
284986
- const fileChanges = rawChanges.filter(isRecord6).slice(-80).reverse().map((change) => ({
285834
+ const fileChanges = rawChanges.filter(isRecord7).slice(-80).reverse().map((change) => ({
284987
285835
  id: safeLabel(typeof change.id === "string" ? change.id : "", 200),
284988
285836
  path: normalizeSafeWebUiPath(change.path) || "unknown",
284989
285837
  diff: redactSecrets(stripAnsi3(String(change.diff || ""))).slice(
@@ -284995,7 +285843,7 @@ function summarizeWebUiReview(value) {
284995
285843
  100
284996
285844
  )
284997
285845
  })).filter((change) => change.id && change.path !== "unknown");
284998
- const checkpoints = rawCheckpoints.filter(isRecord6).slice(-40).reverse().map((checkpoint) => ({
285846
+ const checkpoints = rawCheckpoints.filter(isRecord7).slice(-40).reverse().map((checkpoint) => ({
284999
285847
  id: safeLabel(
285000
285848
  typeof checkpoint.id === "string" ? checkpoint.id : "",
285001
285849
  200
@@ -285010,7 +285858,7 @@ function summarizeWebUiReview(value) {
285010
285858
  ),
285011
285859
  files: (Array.isArray(checkpoint.files) ? checkpoint.files : []).map((path9) => normalizeSafeWebUiPath(path9)).filter((path9) => Boolean(path9)).slice(0, 50)
285012
285860
  })).filter((checkpoint) => checkpoint.id);
285013
- const verification = rawVerification.filter(isRecord6).slice(-20).reverse().map((entry) => ({
285861
+ const verification = rawVerification.filter(isRecord7).slice(-20).reverse().map((entry) => ({
285014
285862
  timestamp: safeLabel(
285015
285863
  typeof entry.timestamp === "string" ? entry.timestamp : "",
285016
285864
  100
@@ -285018,7 +285866,7 @@ function summarizeWebUiReview(value) {
285018
285866
  success: typeof entry.success === "boolean" ? entry.success : void 0,
285019
285867
  detail: typeof entry.detail === "string" ? redactSecrets(stripAnsi3(entry.detail)).slice(0, 2e3) : void 0
285020
285868
  }));
285021
- const toolCalls = rawToolCalls.filter(isRecord6).slice(-100).reverse().map((tool) => {
285869
+ const toolCalls = rawToolCalls.filter(isRecord7).slice(-100).reverse().map((tool) => {
285022
285870
  const startedAt = safeLabel(
285023
285871
  typeof tool.startedAt === "string" ? tool.startedAt : "",
285024
285872
  100
@@ -285051,7 +285899,7 @@ function summarizeWebUiReview(value) {
285051
285899
  return { fileChanges, toolCalls, checkpoints, verification };
285052
285900
  }
285053
285901
  function collectWebUiApproval(value) {
285054
- if (!isRecord6(value)) return void 0;
285902
+ if (!isRecord7(value)) return void 0;
285055
285903
  if (typeof value.id !== "string" || !["tool", "change", "action"].includes(String(value.kind))) {
285056
285904
  return void 0;
285057
285905
  }
@@ -285080,7 +285928,7 @@ function safeApprovalText(value, maxLength, preserveLines) {
285080
285928
  }
285081
285929
  function normalizeSessions(sessions, activeId) {
285082
285930
  if (!Array.isArray(sessions)) return [];
285083
- return sessions.filter(isRecord6).map((session) => ({
285931
+ return sessions.filter(isRecord7).map((session) => ({
285084
285932
  id: typeof session.id === "string" ? session.id : "",
285085
285933
  title: typeof session.title === "string" && session.title.trim() ? redactSecrets(session.title.trim()).slice(0, 160) : "Untitled task",
285086
285934
  model: typeof session.model === "string" ? session.model : "",
@@ -285208,8 +286056,8 @@ function buildModelOptions(options, activeModel2) {
285208
286056
  return safeCall(() => options.loop?.getModelOverride?.()) ? [discovered[0], automatic, ...discovered.slice(1)] : [automatic, ...discovered];
285209
286057
  }
285210
286058
  function normalizeMessage(message2, index) {
285211
- const record = isRecord6(message2) ? message2 : {};
285212
- const metadata = isRecord6(record.metadata) ? record.metadata : {};
286059
+ const record = isRecord7(message2) ? message2 : {};
286060
+ const metadata = isRecord7(record.metadata) ? record.metadata : {};
285213
286061
  const role = record.role === "user" || record.role === "assistant" || record.role === "tool" ? record.role : "assistant";
285214
286062
  const blocks = normalizeMessageBlocks(record.content);
285215
286063
  return {
@@ -285228,7 +286076,7 @@ function normalizeMessageBlocks(content) {
285228
286076
  if (!Array.isArray(content)) return [];
285229
286077
  const blocks = [];
285230
286078
  for (const candidate of content) {
285231
- if (!isRecord6(candidate)) continue;
286079
+ if (!isRecord7(candidate)) continue;
285232
286080
  if (candidate.type === "text" && typeof candidate.text === "string") {
285233
286081
  blocks.push({ type: "text", text: candidate.text });
285234
286082
  continue;
@@ -285245,7 +286093,7 @@ function normalizeMessageBlocks(content) {
285245
286093
  });
285246
286094
  continue;
285247
286095
  }
285248
- if (candidate.type === "tool_call" && isRecord6(candidate.toolCall)) {
286096
+ if (candidate.type === "tool_call" && isRecord7(candidate.toolCall)) {
285249
286097
  blocks.push({
285250
286098
  type: "tool",
285251
286099
  id: typeof candidate.toolCall.id === "string" ? candidate.toolCall.id : "",
@@ -285255,7 +286103,7 @@ function normalizeMessageBlocks(content) {
285255
286103
  });
285256
286104
  continue;
285257
286105
  }
285258
- if (candidate.type === "tool_result" && isRecord6(candidate.toolResult)) {
286106
+ if (candidate.type === "tool_result" && isRecord7(candidate.toolResult)) {
285259
286107
  const isError = candidate.toolResult.isError === true;
285260
286108
  blocks.push({
285261
286109
  type: "tool",
@@ -285347,9 +286195,9 @@ function successfulToolSummary(toolName, value) {
285347
286195
  return {};
285348
286196
  }
285349
286197
  function isInternalWebMessage(message2) {
285350
- if (!isRecord6(message2)) return true;
286198
+ if (!isRecord7(message2)) return true;
285351
286199
  if (message2.role === "system") return true;
285352
- const metadata = isRecord6(message2.metadata) ? message2.metadata : {};
286200
+ const metadata = isRecord7(message2.metadata) ? message2.metadata : {};
285353
286201
  return metadata.kind === "orbit_volatile_context" || metadata.kind === "history_compaction_summary";
285354
286202
  }
285355
286203
  function safeCall(fn) {
@@ -285365,7 +286213,7 @@ function finiteNumber2(value) {
285365
286213
  function stripAnsi3(value) {
285366
286214
  return value.replace(/\u001b\[[0-9;]*m/g, "");
285367
286215
  }
285368
- function isRecord6(value) {
286216
+ function isRecord7(value) {
285369
286217
  return typeof value === "object" && value !== null;
285370
286218
  }
285371
286219
 
@@ -285474,14 +286322,14 @@ var WebUiEventStream = class {
285474
286322
  const payload = sanitizeWebEventPayload(event.type, event.payload);
285475
286323
  if (payload === void 0) return;
285476
286324
  const turn = this.getActiveTurn();
285477
- const eventSessionId = extractSessionId(payload);
286325
+ const identity2 = extractEventIdentity(payload);
285478
286326
  this.broadcast({
285479
286327
  kind: "orbit_event",
285480
286328
  schemaVersion: event.schemaVersion,
285481
286329
  id: event.eventId,
285482
286330
  timestamp: event.timestamp,
285483
- turnId: turn?.id,
285484
- sessionId: eventSessionId || turn?.sessionId,
286331
+ turnId: identity2.turnId || turn?.id,
286332
+ sessionId: identity2.sessionId || turn?.sessionId,
285485
286333
  type: event.type,
285486
286334
  payload
285487
286335
  });
@@ -285610,16 +286458,14 @@ var WebUiEventStream = class {
285610
286458
  if (destroy && !client.destroyed) client.destroy();
285611
286459
  }
285612
286460
  };
285613
- function extractSessionId(payload) {
286461
+ function extractEventIdentity(payload) {
285614
286462
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
285615
- return void 0;
286463
+ return {};
285616
286464
  }
285617
286465
  const record = payload;
285618
- for (const key of ["sessionId", "taskId", "agentId"]) {
285619
- const value = record[key];
285620
- if (typeof value === "string" && value.trim()) return value;
285621
- }
285622
- return void 0;
286466
+ const sessionId = typeof record.sessionId === "string" && record.sessionId.trim() ? record.sessionId : void 0;
286467
+ const turnId = typeof record.turnId === "string" && record.turnId.trim() ? record.turnId : void 0;
286468
+ return { sessionId, turnId };
285623
286469
  }
285624
286470
  function parseLastEventId(value) {
285625
286471
  const text2 = Array.isArray(value) ? value[0] : value;
@@ -286237,7 +287083,7 @@ function renderComposer(copy) {
286237
287083
  <button class="composer-chip" id="contextPickerButton" type="button" data-open-context aria-label="${copy.context}" aria-haspopup="dialog" aria-controls="contextPicker" aria-expanded="false">${renderUiIcon("context")}<span>${copy.context}</span><span class="context-chip-count" id="contextChipCount" aria-label="0" hidden>0</span></button>
286238
287084
  <button class="composer-chip" id="attachmentButton" type="button" aria-label="${copy.attachImage}">${renderUiIcon("image")}<span>${copy.attachments}</span><span class="context-chip-count" id="attachmentCount" aria-label="0" hidden>0</span></button>
286239
287085
  <input id="attachmentInput" data-testid="attachment-input" type="file" accept="image/png,image/jpeg,image/gif,image/webp" multiple hidden />
286240
- <button class="composer-chip" id="searchToggle" type="button" aria-pressed="false"><span class="web-status-dot" aria-hidden="true"></span><span>${copy.webSearch}</span></button>
287086
+ <button class="composer-chip" id="searchToggle" type="button" aria-label="${copy.webSearch}" aria-pressed="false"><span class="web-status-dot" aria-hidden="true"></span><span>${copy.webSearch}</span></button>
286241
287087
  <div class="select-control composer-select-control" data-select-control>
286242
287088
  <select class="native-select-proxy" id="permissionSelect" aria-label="${copy.permission}" tabindex="-1" aria-hidden="true" hidden>
286243
287089
  <option value="strict">${copy.modeStrict}</option>
@@ -287041,6 +287887,7 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
287041
287887
  }
287042
287888
 
287043
287889
  .composer-tools {
287890
+ flex: 1 1 auto;
287044
287891
  min-width: 0;
287045
287892
  display: flex;
287046
287893
  align-items: center;
@@ -287053,6 +287900,22 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
287053
287900
  display: none;
287054
287901
  }
287055
287902
 
287903
+ @media (max-width: 420px) {
287904
+ .composer-chip {
287905
+ gap: 4px;
287906
+ padding-inline: 7px;
287907
+ }
287908
+
287909
+ .composer-chip > span:not(.context-chip-count):not(.web-status-dot) {
287910
+ display: none;
287911
+ }
287912
+
287913
+ .composer-select-trigger {
287914
+ gap: 4px;
287915
+ padding-inline: 7px;
287916
+ }
287917
+ }
287918
+
287056
287919
  .composer-chip,
287057
287920
  .composer-select-trigger {
287058
287921
  height: 29px;
@@ -289750,6 +290613,7 @@ body {
289750
290613
  width: 100%;
289751
290614
  height: 100%;
289752
290615
  overflow: hidden;
290616
+ overscroll-behavior: none;
289753
290617
  }
289754
290618
 
289755
290619
  body {
@@ -289932,7 +290796,10 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
289932
290796
 
289933
290797
  .inspector-content {
289934
290798
  min-height: 0;
290799
+ overflow-x: hidden;
289935
290800
  overflow-y: auto;
290801
+ overscroll-behavior: contain;
290802
+ scrollbar-gutter: stable;
289936
290803
  padding: 4px 17px 18px;
289937
290804
  }
289938
290805
 
@@ -290469,6 +291336,14 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
290469
291336
  line-height: 1.5;
290470
291337
  }
290471
291338
 
291339
+ .task-overview-reason {
291340
+ display: block;
291341
+ margin-top: -5px;
291342
+ color: var(--warning-strong, var(--accent-strong));
291343
+ font-size: 9px;
291344
+ line-height: 1.45;
291345
+ }
291346
+
290472
291347
  .task-overview-stats {
290473
291348
  display: grid;
290474
291349
  grid-template-columns: repeat(3, minmax(0, 1fr));
@@ -291718,12 +292593,13 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
291718
292593
  }
291719
292594
 
291720
292595
  .workspace-view {
291721
- grid-template-rows: 54px auto minmax(0, 1fr);
292596
+ grid-template-rows: calc(54px + env(safe-area-inset-top)) auto minmax(0, 1fr);
291722
292597
  }
291723
292598
 
291724
292599
  .topbar {
291725
- height: 54px;
292600
+ height: calc(54px + env(safe-area-inset-top));
291726
292601
  padding: 0 10px;
292602
+ padding-top: env(safe-area-inset-top);
291727
292603
  }
291728
292604
 
291729
292605
  .workspace-heading span,
@@ -292236,6 +293112,8 @@ var WEB_UI_SELECT_STYLES = String.raw`
292236
293112
  // src/runtime/webui/styles/WebUiShellStyles.ts
292237
293113
  var WEB_UI_SHELL_STYLES = String.raw`
292238
293114
  .app-shell {
293115
+ min-width: 0;
293116
+ min-height: 0;
292239
293117
  height: 100vh;
292240
293118
  height: 100dvh;
292241
293119
  display: grid;
@@ -293118,6 +293996,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
293118
293996
  display: grid;
293119
293997
  grid-template-rows: 62px auto minmax(0, 1fr);
293120
293998
  overflow: hidden;
293999
+ scrollbar-gutter: stable;
293121
294000
  background: var(--canvas);
293122
294001
  border: 1px solid color-mix(in srgb, white 8%, var(--border-strong));
293123
294002
  border-radius: 18px;
@@ -294836,7 +295715,7 @@ Running shell command: ${shellCommand}...`)
294836
295715
  import picocolors11 from "picocolors";
294837
295716
 
294838
295717
  // src/runtime/ConfigObjectPath.ts
294839
- function isRecord7(value) {
295718
+ function isRecord8(value) {
294840
295719
  return typeof value === "object" && value !== null && !Array.isArray(value);
294841
295720
  }
294842
295721
  var blockedSegments = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
@@ -294852,7 +295731,7 @@ function getNestedProperty(root, path9) {
294852
295731
  if (!parts) return void 0;
294853
295732
  let current = root;
294854
295733
  for (const part of parts) {
294855
- if (!isRecord7(current) || !Object.hasOwn(current, part)) return void 0;
295734
+ if (!isRecord8(current) || !Object.hasOwn(current, part)) return void 0;
294856
295735
  current = current[part];
294857
295736
  }
294858
295737
  return current;
@@ -294863,7 +295742,7 @@ function setNestedProperty(root, path9, value) {
294863
295742
  let current = root;
294864
295743
  for (const part of parts.slice(0, -1)) {
294865
295744
  const child = current[part];
294866
- if (!isRecord7(child)) {
295745
+ if (!isRecord8(child)) {
294867
295746
  current[part] = {};
294868
295747
  }
294869
295748
  current = current[part];
@@ -296579,7 +297458,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
296579
297458
  // src/runtime/ProjectLauncher.ts
296580
297459
  import { spawn as spawn4 } from "child_process";
296581
297460
  import { existsSync as existsSync21, mkdirSync as mkdirSync7, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
296582
- import { dirname as dirname13, isAbsolute as isAbsolute8, parse as parse4, resolve as resolve13 } from "path";
297461
+ import { dirname as dirname13, isAbsolute as isAbsolute8, parse as parse5, resolve as resolve13 } from "path";
296583
297462
  var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
296584
297463
  var ProjectLaunchError = class extends Error {
296585
297464
  constructor(code, message2, options) {
@@ -296748,7 +297627,7 @@ function requireProjectDirectory(projectPath) {
296748
297627
  }
296749
297628
  function rejectFilesystemRoot(projectPath) {
296750
297629
  const normalized = resolve13(projectPath);
296751
- if (normalized === parse4(normalized).root) {
297630
+ if (normalized === parse5(normalized).root) {
296752
297631
  throw new ProjectLaunchError(
296753
297632
  "filesystem_root",
296754
297633
  "A filesystem root cannot be opened as an Orbit project."
@@ -297884,7 +298763,8 @@ var CommandRouter = class {
297884
298763
  if (shellResult) return shellResult;
297885
298764
  if (trimmed.startsWith("/")) {
297886
298765
  const parts = trimmed.split(" ");
297887
- const command = parts[0].toLowerCase();
298766
+ const rawCommand = parts[0].toLowerCase();
298767
+ const command = rawCommand === "/permissions" ? "/mode" : rawCommand;
297888
298768
  const queueResult = handleInputQueueCommand(
297889
298769
  command,
297890
298770
  parts.slice(1).join(" ").trim(),
@@ -300056,7 +300936,7 @@ Risk Warning: ${reason}`);
300056
300936
  return new RegExp(finalPattern);
300057
300937
  });
300058
300938
  const normCwd = resolve14(this.cwd).toLowerCase().replace(/\\/g, "/");
300059
- const normHome = resolve14(homedir10()).toLowerCase().replace(/\\/g, "/");
300939
+ const normHome = resolve14(homedir11()).toLowerCase().replace(/\\/g, "/");
300060
300940
  const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname14(normCwd) === normCwd;
300061
300941
  if (!isHomeOrRoot) {
300062
300942
  const indexer = new SymbolIndexer(this.cwd);
@@ -300432,6 +301312,15 @@ function getExplicitProviderOverride(cliOverrides) {
300432
301312
  const normalized = selected.trim();
300433
301313
  return normalized || void 0;
300434
301314
  }
301315
+ function getExplicitAgentProfileOverride(cliOverrides) {
301316
+ if (typeof cliOverrides !== "object" || cliOverrides === null || Array.isArray(cliOverrides)) {
301317
+ return void 0;
301318
+ }
301319
+ const selected = cliOverrides.agentProfile;
301320
+ if (typeof selected !== "string") return void 0;
301321
+ const normalized = selected.trim();
301322
+ return normalized || void 0;
301323
+ }
300435
301324
  function applyStoredRuntimeSelection(config, localState, cliOverrides) {
300436
301325
  if (shouldUseStoredProvider(cliOverrides) && localState.lastProvider && config.providers[localState.lastProvider]) {
300437
301326
  config.provider.default = localState.lastProvider;
@@ -300468,6 +301357,8 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
300468
301357
  }
300469
301358
  const config = ConfigLoader.loadSync(cwd, cliOverrides);
300470
301359
  const explicitModelOverride = getExplicitModelOverride(cliOverrides);
301360
+ const explicitProviderOverride = getExplicitProviderOverride(cliOverrides);
301361
+ const explicitAgentProfileOverride = getExplicitAgentProfileOverride(cliOverrides);
300471
301362
  applyStoredRuntimeSelection(
300472
301363
  config,
300473
301364
  readLocalRuntimeState(cwd),
@@ -300487,6 +301378,66 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
300487
301378
  );
300488
301379
  }
300489
301380
  }
301381
+ const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
301382
+ let selectedProfile;
301383
+ const profileName = options?.agentProfile?.trim() || explicitAgentProfileOverride || agentSettings.defaultProfile;
301384
+ if (profileName) {
301385
+ try {
301386
+ if (!agentSettings.enabled) {
301387
+ throw new Error(
301388
+ "Agent Profiles are disabled (agents.enabled: false)."
301389
+ );
301390
+ }
301391
+ const catalog = discoverAgentProfiles(cwd, agentSettings);
301392
+ selectedProfile = resolveAgentProfile(catalog, profileName, config, {
301393
+ allowPermissionEscalation: isFullAccessEnabled(config)
301394
+ });
301395
+ if (!explicitProviderOverride && selectedProfile.provider) {
301396
+ if (!config.providers[selectedProfile.provider]) {
301397
+ throw new Error(
301398
+ `Agent profile ${selectedProfile.name} references unknown provider ${selectedProfile.provider}.`
301399
+ );
301400
+ }
301401
+ config.provider.default = selectedProfile.provider;
301402
+ }
301403
+ if (!explicitModelOverride && selectedProfile.model) {
301404
+ config.models.default = selectedProfile.model;
301405
+ }
301406
+ if (selectedProfile.permissionMode && !cliOverrides?.permissions) {
301407
+ const result = applyPermissionModePreset(
301408
+ config,
301409
+ selectedProfile.permissionMode
301410
+ );
301411
+ if (!result.ok)
301412
+ throw new Error(
301413
+ result.message || "Agent profile permission mode is not allowed."
301414
+ );
301415
+ }
301416
+ if (selectedProfile.maxTurns !== void 0 && shouldUseStoredAgentMaxIterations(cliOverrides)) {
301417
+ config.agent.maxIterations = Math.min(
301418
+ selectedProfile.maxTurns,
301419
+ config.managedPolicy?.maxIterations ?? MAX_AGENT_MAX_ITERATIONS
301420
+ );
301421
+ }
301422
+ } catch (error) {
301423
+ const message2 = redactSecrets(
301424
+ error instanceof Error ? error.message : String(error)
301425
+ );
301426
+ const outcome = {
301427
+ status: "failed",
301428
+ sessionId: "",
301429
+ attempts: 0,
301430
+ error: { code: "execution_error", message: message2 }
301431
+ };
301432
+ eventBus.emitEvent("agent_completed", {
301433
+ taskId: "startup",
301434
+ success: false,
301435
+ result: outcome,
301436
+ error: message2
301437
+ });
301438
+ return outcome;
301439
+ }
301440
+ }
300490
301441
  let providerInstance;
300491
301442
  try {
300492
301443
  providerInstance = createProviderFromConfig(config);
@@ -300551,6 +301502,11 @@ Risk Warning: ${reason}`);
300551
301502
  };
300552
301503
  const activeTask = task;
300553
301504
  if (!activeTask) {
301505
+ if (selectedProfile) {
301506
+ throw new Error(
301507
+ "Agent Profiles currently apply to one-shot task runs; provide a task prompt."
301508
+ );
301509
+ }
300554
301510
  const controller = new ReplController(
300555
301511
  cwd,
300556
301512
  config,
@@ -300569,7 +301525,8 @@ Risk Warning: ${reason}`);
300569
301525
  config,
300570
301526
  providerInstance,
300571
301527
  activeTask,
300572
- interaction
301528
+ interaction,
301529
+ selectedProfile
300573
301530
  );
300574
301531
  return await orchestrator.run();
300575
301532
  } else {
@@ -300583,11 +301540,17 @@ Risk Warning: ${reason}`);
300583
301540
  interaction,
300584
301541
  {
300585
301542
  modelOverride: explicitModelOverride,
301543
+ thinkingEffort: selectedProfile?.effort,
300586
301544
  sessionId: options?.resumeSessionId,
300587
301545
  requireSession: Boolean(options?.resumeSessionId),
300588
301546
  disableStatusBar: !!options?.nonInteractive || !!options?.jsonl,
300589
301547
  nonInteractive: !!options?.nonInteractive,
300590
- autoContinueRunaway: shouldAutoContinueRunaway(config, options)
301548
+ autoContinueRunaway: shouldAutoContinueRunaway(config, options),
301549
+ allowedTools: selectedProfile?.allowedTools,
301550
+ disallowedTools: selectedProfile?.disallowedTools,
301551
+ forcedSkills: selectedProfile?.skills,
301552
+ memoryMode: selectedProfile?.memory,
301553
+ systemPromptOverride: selectedProfile?.systemPrompt
300591
301554
  }
300592
301555
  );
300593
301556
  return await loop.run();
@@ -300632,7 +301595,7 @@ function configureJsonlOutput() {
300632
301595
  schemaVersion: ORBIT_EVENT_SCHEMA_VERSION,
300633
301596
  sequence: ++sequence,
300634
301597
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
300635
- ...isRecord8(sanitized) ? sanitized : { type: "unknown", payload: {} }
301598
+ ...isRecord9(sanitized) ? sanitized : { type: "unknown", payload: {} }
300636
301599
  })
300637
301600
  );
300638
301601
  };
@@ -300646,8 +301609,8 @@ function configureJsonlOutput() {
300646
301609
  };
300647
301610
  }
300648
301611
  function sanitizeJsonlEvent(event) {
300649
- if (!isRecord8(event) || typeof event.type !== "string") return {};
300650
- const payload = isRecord8(event.payload) ? event.payload : {};
301612
+ if (!isRecord9(event) || typeof event.type !== "string") return {};
301613
+ const payload = isRecord9(event.payload) ? event.payload : {};
300651
301614
  const metadata = {
300652
301615
  ...typeof event.eventId === "string" ? { eventId: event.eventId } : {},
300653
301616
  ...typeof event.timestamp === "string" ? { timestamp: event.timestamp } : {}
@@ -300692,12 +301655,12 @@ function sanitizeJsonlEvent(event) {
300692
301655
  function redactJsonValue(value) {
300693
301656
  if (typeof value === "string") return redactSecrets(value);
300694
301657
  if (Array.isArray(value)) return value.map(redactJsonValue);
300695
- if (!isRecord8(value)) return value;
301658
+ if (!isRecord9(value)) return value;
300696
301659
  return Object.fromEntries(
300697
301660
  Object.entries(value).map(([key, item]) => [key, redactJsonValue(item)])
300698
301661
  );
300699
301662
  }
300700
- function isRecord8(value) {
301663
+ function isRecord9(value) {
300701
301664
  return typeof value === "object" && value !== null;
300702
301665
  }
300703
301666
 
@@ -301516,6 +302479,92 @@ async function runSkillsCommand(action, options = {}) {
301516
302479
  return 0;
301517
302480
  }
301518
302481
 
302482
+ // src/commands/agents.ts
302483
+ import picocolors25 from "picocolors";
302484
+ function runAgentsCommand(action, options = {}) {
302485
+ const cwd = options.cwd ?? process.cwd();
302486
+ const config = ConfigLoader.loadSync(cwd);
302487
+ if (!config.agents.enabled) {
302488
+ if (options.json) {
302489
+ console.log(
302490
+ JSON.stringify({ enabled: false, profiles: [], diagnostics: [] })
302491
+ );
302492
+ } else {
302493
+ console.log("Agent Profiles are disabled (agents.enabled: false).");
302494
+ }
302495
+ return 0;
302496
+ }
302497
+ const catalog = discoverAgentProfiles(cwd, config.agents);
302498
+ const errors = catalog.diagnostics.filter(
302499
+ (item) => item.severity === "error"
302500
+ );
302501
+ if (options.json) {
302502
+ console.log(
302503
+ JSON.stringify(
302504
+ {
302505
+ schemaVersion: 1,
302506
+ enabled: true,
302507
+ directories: catalog.directories,
302508
+ profiles: catalog.profiles.map((profile) => ({
302509
+ name: profile.name,
302510
+ extends: profile.extends,
302511
+ displayName: profile.displayName,
302512
+ description: profile.description,
302513
+ provider: profile.provider,
302514
+ model: profile.model,
302515
+ permissionMode: profile.permissionMode,
302516
+ allowedTools: profile.allowedTools,
302517
+ disallowedTools: profile.disallowedTools,
302518
+ skills: profile.skills,
302519
+ maxTurns: profile.maxTurns,
302520
+ effort: profile.effort,
302521
+ isolation: profile.isolation,
302522
+ memory: profile.memory,
302523
+ path: profile.path,
302524
+ source: profile.source
302525
+ })),
302526
+ diagnostics: catalog.diagnostics
302527
+ },
302528
+ null,
302529
+ 2
302530
+ )
302531
+ );
302532
+ return action === "validate" && errors.length > 0 ? 1 : 0;
302533
+ }
302534
+ if (catalog.profiles.length === 0)
302535
+ console.log("No Agent Profiles discovered.");
302536
+ for (const profile of catalog.profiles) {
302537
+ const model = profile.model ? ` \xB7 model=${profile.model}` : "";
302538
+ const mode = profile.permissionMode ? ` \xB7 mode=${profile.permissionMode}` : "";
302539
+ const effort = profile.effort ? ` \xB7 effort=${profile.effort}` : "";
302540
+ const parent = profile.extends ? ` \xB7 extends=${profile.extends}` : "";
302541
+ console.log(
302542
+ `${picocolors25.green(profile.name)}${picocolors25.gray(`${model}${mode}${effort}${parent}`)}`
302543
+ );
302544
+ if (profile.description) console.log(` ${profile.description}`);
302545
+ console.log(picocolors25.gray(` ${profile.source} \xB7 ${profile.path}`));
302546
+ }
302547
+ for (const diagnostic2 of catalog.diagnostics) {
302548
+ const paint = diagnostic2.severity === "error" ? picocolors25.red : picocolors25.yellow;
302549
+ console.log(
302550
+ `${paint(diagnostic2.severity)} [${diagnostic2.code}] ${diagnostic2.message}`
302551
+ );
302552
+ console.log(picocolors25.gray(` ${diagnostic2.path}`));
302553
+ }
302554
+ if (action === "validate") {
302555
+ if (errors.length > 0) {
302556
+ console.error(
302557
+ picocolors25.red(`\u2716 ${errors.length} Agent Profile error(s) found.`)
302558
+ );
302559
+ return 1;
302560
+ }
302561
+ console.log(
302562
+ picocolors25.green(`\u2714 ${catalog.profiles.length} Agent Profile(s) valid.`)
302563
+ );
302564
+ }
302565
+ return 0;
302566
+ }
302567
+
301519
302568
  // src/commands/trace.ts
301520
302569
  import {
301521
302570
  existsSync as existsSync28,
@@ -301583,7 +302632,7 @@ import {
301583
302632
  import { basename as basename5, dirname as dirname16, join as join19 } from "path";
301584
302633
  import { randomUUID as randomUUID15 } from "crypto";
301585
302634
  import { promisify as promisify5 } from "util";
301586
- import picocolors25 from "picocolors";
302635
+ import picocolors26 from "picocolors";
301587
302636
  import { parse as parseYaml4 } from "yaml";
301588
302637
  import { z as z76 } from "zod";
301589
302638
  var exec5 = promisify5(execCallback);
@@ -301617,7 +302666,7 @@ async function runEval(cwd, suiteFile, options = {}) {
301617
302666
  const results = [];
301618
302667
  for (const task of tasks) {
301619
302668
  if (!value.json) {
301620
- console.log(picocolors25.cyan(`\u25CF Evaluating ${task.id}...`));
302669
+ console.log(picocolors26.cyan(`\u25CF Evaluating ${task.id}...`));
301621
302670
  }
301622
302671
  let worktree;
301623
302672
  const taskStartedAt = Date.now();
@@ -301771,13 +302820,13 @@ async function runEval(cwd, suiteFile, options = {}) {
301771
302820
  console.log(JSON.stringify(report, null, 2));
301772
302821
  } else {
301773
302822
  console.log(
301774
- report.passed ? picocolors25.green(
302823
+ report.passed ? picocolors26.green(
301775
302824
  `\u2714 Acceptance passed: ${passedTasks}/${results.length} tasks.`
301776
- ) : picocolors25.red(
302825
+ ) : picocolors26.red(
301777
302826
  `\u2716 Acceptance failed: ${passedTasks}/${results.length} tasks passed.`
301778
302827
  )
301779
302828
  );
301780
- console.log(picocolors25.gray(`Report: ${reportPath}`));
302829
+ console.log(picocolors26.gray(`Report: ${reportPath}`));
301781
302830
  }
301782
302831
  if (!report.passed) process.exitCode = 1;
301783
302832
  return report;
@@ -302024,25 +303073,25 @@ function safeSummary(value) {
302024
303073
 
302025
303074
  // src/commands/clean.ts
302026
303075
  import readline6 from "readline";
302027
- import picocolors26 from "picocolors";
303076
+ import picocolors27 from "picocolors";
302028
303077
  import { resolve as resolve17 } from "path";
302029
303078
  import { z as z78 } from "zod";
302030
303079
 
302031
303080
  // src/runtime/CleanupManager.ts
302032
303081
  import {
302033
303082
  lstatSync as lstatSync10,
302034
- readdirSync as readdirSync9,
303083
+ readdirSync as readdirSync10,
302035
303084
  realpathSync as realpathSync4,
302036
303085
  rmSync as rmSync9,
302037
303086
  unlinkSync as unlinkSync6
302038
303087
  } from "fs";
302039
- import { homedir as homedir11 } from "os";
302040
- import { basename as basename6, join as join20, parse as parse5, resolve as resolve16 } from "path";
303088
+ import { homedir as homedir12 } from "os";
303089
+ import { basename as basename6, join as join20, parse as parse6, resolve as resolve16 } from "path";
302041
303090
  import { z as z77 } from "zod";
302042
303091
  var CleanupScopeSchema = z77.enum(["user", "project"]);
302043
303092
  function buildCleanupPlan(options) {
302044
303093
  const scopes = z77.array(CleanupScopeSchema).min(1).parse(options.scopes);
302045
- const homeDirectory = resolve16(options.homeDirectory ?? homedir11());
303094
+ const homeDirectory = resolve16(options.homeDirectory ?? homedir12());
302046
303095
  const projectDirectory = resolve16(options.projectDirectory ?? options.cwd);
302047
303096
  const candidates = scopes.map((scope) => ({
302048
303097
  scope,
@@ -302151,7 +303200,7 @@ function inspectPath(targetPath) {
302151
303200
  }
302152
303201
  totals.directories++;
302153
303202
  try {
302154
- for (const entry of readdirSync9(currentPath)) {
303203
+ for (const entry of readdirSync10(currentPath)) {
302155
303204
  visit(join20(currentPath, entry));
302156
303205
  }
302157
303206
  } catch (error) {
@@ -302163,21 +303212,21 @@ function inspectPath(targetPath) {
302163
303212
  }
302164
303213
  function assertSafeOrbitDataPath(targetPath) {
302165
303214
  const absolutePath = resolve16(targetPath);
302166
- if (absolutePath === parse5(absolutePath).root) {
303215
+ if (absolutePath === parse6(absolutePath).root) {
302167
303216
  throw new Error("Refusing to clean a filesystem root.");
302168
303217
  }
302169
303218
  if (basename6(absolutePath).toLowerCase() !== ".orbit") {
302170
303219
  throw new Error("Cleanup targets must be an Orbit data directory.");
302171
303220
  }
302172
303221
  const parentPath = resolve16(absolutePath, "..");
302173
- if (parentPath === parse5(absolutePath).root) {
303222
+ if (parentPath === parse6(absolutePath).root) {
302174
303223
  throw new Error(
302175
303224
  "Refusing to clean an Orbit directory directly under a filesystem root."
302176
303225
  );
302177
303226
  }
302178
303227
  try {
302179
303228
  const canonicalParent = realpathSync4.native(parentPath);
302180
- if (canonicalParent === parse5(canonicalParent).root) {
303229
+ if (canonicalParent === parse6(canonicalParent).root) {
302181
303230
  throw new Error(
302182
303231
  "Refusing to clean an Orbit directory through a filesystem-root link."
302183
303232
  );
@@ -302241,7 +303290,7 @@ async function runClean(cwd, rawOptions, dependencies = {}) {
302241
303290
  );
302242
303291
  }
302243
303292
  if (!confirmed) {
302244
- if (!options.json) write(picocolors26.yellow("\u26A0 Cleanup cancelled."));
303293
+ if (!options.json) write(picocolors27.yellow("\u26A0 Cleanup cancelled."));
302245
303294
  return { applied: false, plan, removed: [], skipped: [] };
302246
303295
  }
302247
303296
  const userTarget = plan.targets.find(
@@ -302263,7 +303312,7 @@ async function runClean(cwd, rawOptions, dependencies = {}) {
302263
303312
  );
302264
303313
  } else {
302265
303314
  write(
302266
- picocolors26.green(
303315
+ picocolors27.green(
302267
303316
  `\u2714 Removed ${result.removed.length} Orbit data director${result.removed.length === 1 ? "y" : "ies"}.`
302268
303317
  )
302269
303318
  );
@@ -302280,18 +303329,18 @@ function resolveScopes(options) {
302280
303329
  return scopes;
302281
303330
  }
302282
303331
  function printCleanupPlan(plan, write) {
302283
- write(picocolors26.bold("\nOrbit cleanup preview\n"));
303332
+ write(picocolors27.bold("\nOrbit cleanup preview\n"));
302284
303333
  for (const target of plan.targets) {
302285
303334
  const scope = target.scopes.join(" + ");
302286
303335
  const status = target.exists ? `${target.files} files \xB7 ${target.directories} directories \xB7 ${formatBytes(target.bytes)}` : "not present";
302287
303336
  write(` ${target.exists ? "\u25CF" : "\u25CB"} ${scope}: ${target.path}`);
302288
- write(` ${picocolors26.gray(status)}`);
303337
+ write(` ${picocolors27.gray(status)}`);
302289
303338
  for (const warning2 of target.warnings) {
302290
- write(` ${picocolors26.yellow(`\u26A0 ${warning2}`)}`);
303339
+ write(` ${picocolors27.yellow(`\u26A0 ${warning2}`)}`);
302291
303340
  }
302292
303341
  }
302293
303342
  write(
302294
- picocolors26.gray(
303343
+ picocolors27.gray(
302295
303344
  "\nOnly .orbit data directories are included. Project source, ORBIT.md, and orbit.config.yaml are preserved."
302296
303345
  )
302297
303346
  );
@@ -302318,7 +303367,7 @@ async function confirmDeletion(prompt) {
302318
303367
 
302319
303368
  // src/commands/backup.ts
302320
303369
  import { basename as basename7, resolve as resolve19 } from "path";
302321
- import picocolors27 from "picocolors";
303370
+ import picocolors28 from "picocolors";
302322
303371
  import { z as z80 } from "zod";
302323
303372
 
302324
303373
  // src/runtime/ProjectBackup.ts
@@ -302326,7 +303375,7 @@ import {
302326
303375
  existsSync as existsSync30,
302327
303376
  lstatSync as lstatSync11,
302328
303377
  mkdirSync as mkdirSync10,
302329
- readdirSync as readdirSync10,
303378
+ readdirSync as readdirSync11,
302330
303379
  renameSync as renameSync8,
302331
303380
  rmSync as rmSync10,
302332
303381
  writeFileSync as writeFileSync10
@@ -302510,7 +303559,7 @@ function listBackupFiles(root) {
302510
303559
  `Project backup tree exceeds ${MAX_BACKUP_TREE_DEPTH} directory levels.`
302511
303560
  );
302512
303561
  }
302513
- for (const name of readdirSync10(directory).sort()) {
303562
+ for (const name of readdirSync11(directory).sort()) {
302514
303563
  visitedEntries += 1;
302515
303564
  if (visitedEntries > MAX_BACKUP_TREE_ENTRIES) {
302516
303565
  throw new Error(
@@ -302630,12 +303679,12 @@ function runBackupCreate(cwd, rawOptions = {}) {
302630
303679
  );
302631
303680
  } else {
302632
303681
  console.log(
302633
- picocolors27.green(
303682
+ picocolors28.green(
302634
303683
  `\u2714 Backed up ${bundle.files.length} durable project file(s) to ${outputPath}`
302635
303684
  )
302636
303685
  );
302637
303686
  console.log(
302638
- picocolors27.gray(
303687
+ picocolors28.gray(
302639
303688
  " Regenerable caches, temporary state, exports, and credentials were excluded."
302640
303689
  )
302641
303690
  );
@@ -302653,7 +303702,7 @@ function runBackupInspect(input, options = {}) {
302653
303702
  };
302654
303703
  if (options.json) console.log(JSON.stringify(summary));
302655
303704
  else {
302656
- console.log(picocolors27.bold(`
303705
+ console.log(picocolors28.bold(`
302657
303706
  ${basename7(input)}
302658
303707
  `));
302659
303708
  console.log(` Project: ${summary.sourceName}`);
@@ -302661,7 +303710,7 @@ ${basename7(input)}
302661
303710
  console.log(
302662
303711
  ` Content: ${summary.files} files \xB7 ${formatBytes3(summary.bytes)}`
302663
303712
  );
302664
- console.log(picocolors27.green(" \u2714 Integrity verified"));
303713
+ console.log(picocolors28.green(" \u2714 Integrity verified"));
302665
303714
  }
302666
303715
  }
302667
303716
  function runBackupRestore(cwd, input, options = {}) {
@@ -302671,13 +303720,13 @@ function runBackupRestore(cwd, input, options = {}) {
302671
303720
  console.log(JSON.stringify({ schemaVersion: 1, ...result }));
302672
303721
  } else {
302673
303722
  console.log(
302674
- picocolors27.green(
303723
+ picocolors28.green(
302675
303724
  `\u2714 Restored ${result.restored.length} project file(s) from ${resolve19(input)}`
302676
303725
  )
302677
303726
  );
302678
303727
  if (result.conflicts.length > 0) {
302679
303728
  console.log(
302680
- picocolors27.yellow(
303729
+ picocolors28.yellow(
302681
303730
  ` Replaced ${result.conflicts.length} existing file(s) because --force was supplied.`
302682
303731
  )
302683
303732
  );
@@ -302694,21 +303743,21 @@ function formatBytes3(bytes) {
302694
303743
  }
302695
303744
 
302696
303745
  // src/commands/extension.ts
302697
- import picocolors28 from "picocolors";
303746
+ import picocolors29 from "picocolors";
302698
303747
 
302699
303748
  // src/runtime/ExtensionManager.ts
302700
303749
  import {
302701
303750
  existsSync as existsSync31,
302702
303751
  lstatSync as lstatSync12,
302703
303752
  mkdirSync as mkdirSync11,
302704
- readdirSync as readdirSync11,
303753
+ readdirSync as readdirSync12,
302705
303754
  renameSync as renameSync9,
302706
303755
  rmSync as rmSync11,
302707
303756
  writeFileSync as writeFileSync11
302708
303757
  } from "fs";
302709
303758
  import { randomUUID as randomUUID17 } from "crypto";
302710
303759
  import { dirname as dirname18, isAbsolute as isAbsolute10, join as join26, relative as relative11, resolve as resolve20, sep as sep3 } from "path";
302711
- import { homedir as homedir12 } from "os";
303760
+ import { homedir as homedir13 } from "os";
302712
303761
  import { z as z81 } from "zod";
302713
303762
  var InstalledExtensionSchema2 = z81.object({
302714
303763
  id: InstalledExtensionIdSchema,
@@ -302729,7 +303778,7 @@ var ExtensionManager = class {
302729
303778
  orbitDir;
302730
303779
  extensionsDir;
302731
303780
  registryPath;
302732
- constructor(homeDirectory = homedir12()) {
303781
+ constructor(homeDirectory = homedir13()) {
302733
303782
  this.orbitDir = join26(homeDirectory, ".orbit");
302734
303783
  this.extensionsDir = join26(this.orbitDir, "extensions");
302735
303784
  this.registryPath = join26(this.orbitDir, "extensions.json");
@@ -303049,7 +304098,7 @@ function copyDirectoryEntry(source, target, budget, depth) {
303049
304098
  throw new Error("Extension directories cannot contain symlinks.");
303050
304099
  if (stats.isDirectory()) {
303051
304100
  mkdirSync11(target, { recursive: true });
303052
- for (const entry of readdirSync11(source)) {
304101
+ for (const entry of readdirSync12(source)) {
303053
304102
  if (entry === "node_modules" || entry === ".git") continue;
303054
304103
  copyDirectoryEntry(
303055
304104
  join26(source, entry),
@@ -303107,9 +304156,9 @@ function verifyOrbitCompatibility(manifest, currentVersion) {
303107
304156
  }
303108
304157
  }
303109
304158
  function compareVersions(left, right) {
303110
- const parse6 = (value) => value.split("-", 1)[0].split(".").map(Number);
303111
- const a2 = parse6(left);
303112
- const b = parse6(right);
304159
+ const parse7 = (value) => value.split("-", 1)[0].split(".").map(Number);
304160
+ const a2 = parse7(left);
304161
+ const b = parse7(right);
303113
304162
  for (let index = 0; index < 3; index += 1) {
303114
304163
  if ((a2[index] || 0) !== (b[index] || 0))
303115
304164
  return (a2[index] || 0) - (b[index] || 0);
@@ -303129,12 +304178,12 @@ function validateExtension(cwd, manifestPath, options = {}) {
303129
304178
  0
303130
304179
  );
303131
304180
  console.log(
303132
- picocolors28.green(
304181
+ picocolors29.green(
303133
304182
  `\u2714 Extension manifest is valid: ${manifest.displayName} ${manifest.version}`
303134
304183
  )
303135
304184
  );
303136
304185
  console.log(
303137
- picocolors28.gray(
304186
+ picocolors29.gray(
303138
304187
  ` ${manifest.id} \xB7 ${contributionCount} contribution(s) \xB7 process=${manifest.permissions.process}`
303139
304188
  )
303140
304189
  );
@@ -303143,12 +304192,12 @@ function validateExtension(cwd, manifestPath, options = {}) {
303143
304192
  function installExtension(cwd, manifestPath, options = {}) {
303144
304193
  const installed = new ExtensionManager().install(cwd, manifestPath, options);
303145
304194
  console.log(
303146
- picocolors28.green(
304195
+ picocolors29.green(
303147
304196
  `\u2714 Installed extension: ${installed.displayName} ${installed.version}`
303148
304197
  )
303149
304198
  );
303150
304199
  console.log(
303151
- picocolors28.gray(
304200
+ picocolors29.gray(
303152
304201
  ` ${installed.id} \xB7 sha256:${installed.digest.slice(0, 16)}\u2026`
303153
304202
  )
303154
304203
  );
@@ -303160,24 +304209,24 @@ function listExtensions(options = {}) {
303160
304209
  return;
303161
304210
  }
303162
304211
  if (!extensions.length) {
303163
- console.log(picocolors28.gray("No Orbit extensions are installed."));
304212
+ console.log(picocolors29.gray("No Orbit extensions are installed."));
303164
304213
  return;
303165
304214
  }
303166
304215
  for (const extension of extensions) {
303167
304216
  console.log(
303168
- `${picocolors28.green("\u25CF")} ${extension.displayName} ${extension.version} ${picocolors28.gray(`(${extension.id})`)}`
304217
+ `${picocolors29.green("\u25CF")} ${extension.displayName} ${extension.version} ${picocolors29.gray(`(${extension.id})`)}`
303169
304218
  );
303170
304219
  }
303171
304220
  }
303172
304221
  function removeExtension(id) {
303173
304222
  const removed = new ExtensionManager().remove(id);
303174
304223
  console.log(
303175
- removed ? picocolors28.green(`\u2714 Removed extension: ${id}`) : picocolors28.yellow(`Extension is not installed: ${id}`)
304224
+ removed ? picocolors29.green(`\u2714 Removed extension: ${id}`) : picocolors29.yellow(`Extension is not installed: ${id}`)
303176
304225
  );
303177
304226
  }
303178
304227
 
303179
304228
  // src/index.ts
303180
- import { existsSync as existsSync35, realpathSync as realpathSync5, statSync as statSync6 } from "fs";
304229
+ import { existsSync as existsSync36, realpathSync as realpathSync5, statSync as statSync6 } from "fs";
303181
304230
  import { resolve as resolve21 } from "path";
303182
304231
 
303183
304232
  // src/runtime/CliRunOverrides.ts
@@ -303189,6 +304238,9 @@ function createCliRunOverrides(options) {
303189
304238
  if (options.model) {
303190
304239
  overrides.models = { default: options.model };
303191
304240
  }
304241
+ if (options.agentProfile) {
304242
+ overrides.agentProfile = options.agentProfile;
304243
+ }
303192
304244
  if (options.direct) {
303193
304245
  overrides.direct = true;
303194
304246
  }
@@ -303205,6 +304257,9 @@ function applyOutcomeExitCode(outcome) {
303205
304257
  process.exitCode = Math.max(currentExitCode, exitCodeForOutcome(outcome));
303206
304258
  }
303207
304259
  program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").version(readCliVersion()).argument("[task]", "task description for Orbit to execute").option("--provider <provider>", "specify model provider").option("--model <model>", "specify model name").option(
304260
+ "--agent-profile <name>",
304261
+ "select a validated Agent Profile for this task"
304262
+ ).option(
303208
304263
  "--yes",
303209
304264
  "enable unrestricted Full Access and approve every enabled tool action"
303210
304265
  ).option("--multi", "run in multi-agent planning/coding/review mode").option("--direct", "run interactive REPL in direct console streaming mode").action(async (task, options) => {
@@ -303215,7 +304270,9 @@ program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").versi
303215
304270
  direct: !!options.direct,
303216
304271
  fullAccess: !!options.yes
303217
304272
  });
303218
- const outcome = await runAgent(cwd, task, overrides, !!options.multi);
304273
+ const outcome = await runAgent(cwd, task, overrides, !!options.multi, {
304274
+ agentProfile: options.agentProfile
304275
+ });
303219
304276
  applyOutcomeExitCode(outcome);
303220
304277
  });
303221
304278
  program.command("init").description("initialize an Agent-first Orbit project contract and workflows").option("--minimal", "create only ORBIT.md for legacy-compatible setup").option("--json", "print the scaffold result as JSON").action(async (options) => {
@@ -303295,11 +304352,18 @@ skillsCommand.command("validate").description("validate SKILL.md files; non-zero
303295
304352
  });
303296
304353
  }
303297
304354
  );
304355
+ var agentsCommand = program.command("agents").description("list and validate reusable Agent Profiles");
304356
+ agentsCommand.command("list").description("list discovered Agent Profiles with diagnostics").option("--json", "print a machine-readable catalog").action((options) => {
304357
+ process.exitCode = runAgentsCommand("list", { json: !!options.json });
304358
+ });
304359
+ agentsCommand.command("validate").description("validate Agent Profile manifests; non-zero on errors").option("--json", "print a machine-readable report").action((options) => {
304360
+ process.exitCode = runAgentsCommand("validate", { json: !!options.json });
304361
+ });
303298
304362
  var mcpCommand = program.command("mcp").description("manage Model Context Protocol servers");
303299
304363
  mcpCommand.command("login <server>").description("authorize an MCP server via OAuth (PKCE) and save the login").option("--port <port>", "fixed loopback port for the OAuth redirect").action(async (server2, options) => {
303300
304364
  const port = options.port ? Number.parseInt(options.port, 10) : void 0;
303301
304365
  if (options.port && (!Number.isInteger(port) || port < 1 || port > 65535)) {
303302
- console.error(picocolors29.red("\u2716 --port must be an integer in 1-65535."));
304366
+ console.error(picocolors30.red("\u2716 --port must be an integer in 1-65535."));
303303
304367
  process.exitCode = 1;
303304
304368
  return;
303305
304369
  }
@@ -303425,7 +304489,7 @@ program.command("webui").description("start Orbit as a browser-first local codin
303425
304489
  fullAccess: !!options.yes
303426
304490
  });
303427
304491
  const requestedCwd = resolve21(localOptions.cwd || process.cwd());
303428
- if (!existsSync35(requestedCwd) || !statSync6(requestedCwd).isDirectory()) {
304492
+ if (!existsSync36(requestedCwd) || !statSync6(requestedCwd).isDirectory()) {
303429
304493
  throw new Error(
303430
304494
  `Web UI project directory does not exist: ${requestedCwd}`
303431
304495
  );
@@ -303436,7 +304500,10 @@ program.command("webui").description("start Orbit as a browser-first local codin
303436
304500
  });
303437
304501
  applyOutcomeExitCode(outcome);
303438
304502
  });
303439
- program.command("exec").description("run a task in non-interactive mode and stream events as JSONL").argument("<prompt>", "the task prompt to execute").option("--provider <provider>", "specify model provider").option("--model <model>", "specify model name").option("--resume <session>", "resume a persisted Orbit session").option("--jsonl", "output event logs in JSONL format").action(async (prompt, localOptions, command) => {
304503
+ program.command("exec").description("run a task in non-interactive mode and stream events as JSONL").argument("<prompt>", "the task prompt to execute").option("--provider <provider>", "specify model provider").option("--model <model>", "specify model name").option(
304504
+ "--agent-profile <name>",
304505
+ "select a validated Agent Profile for this task"
304506
+ ).option("--resume <session>", "resume a persisted Orbit session").option("--jsonl", "output event logs in JSONL format").action(async (prompt, localOptions, command) => {
303440
304507
  const options = { ...command.optsWithGlobals(), ...localOptions };
303441
304508
  const cwd = process.cwd();
303442
304509
  const overrides = createCliRunOverrides({
@@ -303447,7 +304514,8 @@ program.command("exec").description("run a task in non-interactive mode and stre
303447
304514
  const outcome = await runAgent(cwd, prompt, overrides, false, {
303448
304515
  nonInteractive: true,
303449
304516
  jsonl: !!options.jsonl,
303450
- resumeSessionId: options.resume
304517
+ resumeSessionId: options.resume,
304518
+ agentProfile: options.agentProfile
303451
304519
  });
303452
304520
  applyOutcomeExitCode(outcome);
303453
304521
  });
@@ -303456,7 +304524,7 @@ try {
303456
304524
  } catch (error) {
303457
304525
  const message2 = error instanceof Error ? error.message : String(error);
303458
304526
  console.error(
303459
- picocolors29.red(`\u2716 Orbit command failed: ${redactSecrets(message2)}`)
304527
+ picocolors30.red(`\u2716 Orbit command failed: ${redactSecrets(message2)}`)
303460
304528
  );
303461
304529
  process.exitCode = 1;
303462
304530
  }