@orbit-build/cli 1.0.0 → 1.0.1

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 +1258 -665
  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,363 @@ 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
+ displayName: z32.string().trim().min(1).max(120).optional(),
239398
+ description: z32.string().trim().max(2e3).default(""),
239399
+ provider: z32.string().trim().min(1).max(256).optional(),
239400
+ model: z32.string().trim().min(1).max(1024).optional(),
239401
+ permissionMode: z32.enum(["strict", "normal", "auto", "plan"]).optional(),
239402
+ allowedTools: z32.array(ToolNameSchema).max(256).optional(),
239403
+ disallowedTools: z32.array(ToolNameSchema).max(256).default([]),
239404
+ skills: z32.array(SkillNameSchema).max(32).default([]),
239405
+ maxTurns: z32.number().int().min(1).max(1e3).optional(),
239406
+ systemPrompt: z32.string().trim().max(2e4).optional(),
239407
+ isolation: z32.enum(["workspace", "worktree"]).default("workspace"),
239408
+ memory: z32.enum(["project", "none"]).default("project")
239409
+ }).superRefine((profile, context) => {
239410
+ const allowed = new Set(profile.allowedTools ?? []);
239411
+ for (const tool of profile.disallowedTools) {
239412
+ if (allowed.has(tool)) {
239413
+ context.addIssue({
239414
+ code: z32.ZodIssueCode.custom,
239415
+ path: ["disallowedTools"],
239416
+ message: `Tool ${tool} cannot be both allowed and disallowed.`
239417
+ });
239418
+ }
239419
+ }
239420
+ });
239421
+ var AgentProfileSettingsSchema = z32.object({
239422
+ enabled: z32.boolean().default(true),
239423
+ directories: z32.array(z32.string().trim().min(1).max(4096)).max(20).default([
239424
+ ".agents/agents",
239425
+ ".orbit/agents",
239426
+ ".claude/agents",
239427
+ "~/.orbit/agents",
239428
+ "~/.claude/agents"
239429
+ ]),
239430
+ defaultProfile: ProfileNameSchema.optional(),
239431
+ maxProfiles: z32.number().int().min(1).max(MAX_AGENT_PROFILES).default(32)
239432
+ }).default({});
239433
+ function resolveAgentProfileDirectories(cwd, directories) {
239434
+ const resolved = /* @__PURE__ */ new Map();
239435
+ for (const directory of directories) {
239436
+ const trimmed = directory.trim();
239437
+ if (!trimmed) continue;
239438
+ const expanded = trimmed === "~" ? homedir() : trimmed.startsWith("~/") || trimmed.startsWith("~\\") ? join2(homedir(), trimmed.slice(2)) : trimmed;
239439
+ const absolute = isAbsolute2(expanded) ? resolve3(expanded) : resolve3(cwd, expanded);
239440
+ const key = process.platform === "win32" ? absolute.toLowerCase() : absolute;
239441
+ if (!resolved.has(key)) resolved.set(key, absolute);
239442
+ }
239443
+ return [...resolved.values()];
239444
+ }
239445
+ function discoverAgentProfiles(cwd, settings2) {
239446
+ const directories = resolveAgentProfileDirectories(cwd, settings2.directories);
239447
+ const diagnostics = [];
239448
+ const loaded = [];
239449
+ const maxProfiles = Math.min(MAX_AGENT_PROFILES, settings2.maxProfiles);
239450
+ for (const directory of directories) {
239451
+ if (!existsSync4(directory)) continue;
239452
+ if (isProjectProfile(cwd, directory)) {
239453
+ try {
239454
+ resolveSafePath(cwd, directory);
239455
+ } catch {
239456
+ diagnostics.push({
239457
+ path: normalizeDiagnosticPath(directory),
239458
+ severity: "error",
239459
+ code: "unsafe-directory",
239460
+ message: "Agent profile directory escapes the project boundary."
239461
+ });
239462
+ continue;
239463
+ }
239464
+ }
239465
+ let entries;
239466
+ try {
239467
+ entries = readdirSync(directory, { withFileTypes: true });
239468
+ } catch (error) {
239469
+ diagnostics.push({
239470
+ path: normalizeDiagnosticPath(directory),
239471
+ severity: "warning",
239472
+ code: "unreadable-directory",
239473
+ message: `Agent profile directory could not be read: ${safeMessage(error)}`
239474
+ });
239475
+ continue;
239476
+ }
239477
+ entries.sort((left, right) => left.name.localeCompare(right.name));
239478
+ for (const entry of entries) {
239479
+ if (loaded.length >= maxProfiles) {
239480
+ diagnostics.push({
239481
+ path: normalizeDiagnosticPath(directory),
239482
+ severity: "warning",
239483
+ code: "discovery-limit",
239484
+ message: `Agent profile discovery stopped after ${maxProfiles} profiles.`
239485
+ });
239486
+ break;
239487
+ }
239488
+ if (!entry.isFile() || !/\.(?:ya?ml|json)$/i.test(entry.name)) continue;
239489
+ const filePath = join2(directory, entry.name);
239490
+ try {
239491
+ const raw = readBoundedRegularFile(
239492
+ filePath,
239493
+ MAX_AGENT_PROFILE_FILE_BYTES
239494
+ );
239495
+ if (raw === void 0) continue;
239496
+ const parsed = AgentProfileSchema.safeParse(parse(raw));
239497
+ if (!parsed.success) {
239498
+ diagnostics.push({
239499
+ path: normalizeDiagnosticPath(filePath),
239500
+ severity: "error",
239501
+ code: "invalid-profile",
239502
+ message: formatProfileIssues(parsed.error)
239503
+ });
239504
+ continue;
239505
+ }
239506
+ const profile = parsed.data;
239507
+ const duplicate = loaded.find(
239508
+ (candidate) => candidate.name.toLowerCase() === profile.name.toLowerCase()
239509
+ );
239510
+ if (duplicate) {
239511
+ diagnostics.push({
239512
+ path: normalizeDiagnosticPath(filePath),
239513
+ severity: "warning",
239514
+ code: "duplicate-profile",
239515
+ message: `Profile "${profile.name}" ignored; using ${duplicate.path}.`
239516
+ });
239517
+ continue;
239518
+ }
239519
+ loaded.push({
239520
+ ...profile,
239521
+ path: normalizeDiagnosticPath(filePath),
239522
+ source: isProjectProfile(cwd, directory) ? "project" : "user"
239523
+ });
239524
+ } catch (error) {
239525
+ diagnostics.push({
239526
+ path: normalizeDiagnosticPath(filePath),
239527
+ severity: "error",
239528
+ code: "read-error",
239529
+ message: redactSecrets(safeMessage(error)).slice(0, 2e3)
239530
+ });
239531
+ }
239532
+ }
239533
+ }
239534
+ return {
239535
+ profiles: loaded.sort((left, right) => left.name.localeCompare(right.name)),
239536
+ diagnostics,
239537
+ directories: directories.map(normalizeDiagnosticPath)
239538
+ };
239539
+ }
239540
+ function resolveAgentProfile(catalog, name, config, options = {}) {
239541
+ const normalized = name.trim().toLowerCase();
239542
+ const profile = catalog.profiles.find(
239543
+ (candidate) => candidate.name.toLowerCase() === normalized
239544
+ );
239545
+ if (!profile) throw new Error(`Agent profile not found: ${name}`);
239546
+ if (profile.provider) {
239547
+ const violation = validateManagedRuntimeChange(config, {
239548
+ provider: profile.provider
239549
+ });
239550
+ if (violation) throw new Error(violation);
239551
+ }
239552
+ if (profile.model) {
239553
+ const violation = validateManagedRuntimeChange(config, {
239554
+ model: profile.model
239555
+ });
239556
+ if (violation) throw new Error(violation);
239557
+ }
239558
+ if (profile.permissionMode && !options.allowPermissionEscalation) {
239559
+ const current = permissionRank2(config.permissions.mode);
239560
+ if (permissionRank2(profile.permissionMode) < current) {
239561
+ throw new Error(
239562
+ `Agent profile ${profile.name} requests ${profile.permissionMode} mode; confirm Full Access explicitly before selecting it.`
239563
+ );
239564
+ }
239565
+ }
239566
+ if (profile.maxTurns !== void 0) {
239567
+ const violation = validateManagedRuntimeChange(config, {
239568
+ agentMaxIterations: profile.maxTurns
239569
+ });
239570
+ if (violation) throw new Error(violation);
239571
+ }
239572
+ if (profile.isolation === "worktree") {
239573
+ throw new Error(
239574
+ `Agent profile ${profile.name} requests worktree isolation, which must be selected through an isolated orchestration run.`
239575
+ );
239576
+ }
239577
+ return profile;
239578
+ }
239579
+ function permissionRank2(mode) {
239580
+ return { auto: 0, normal: 1, strict: 2, plan: 3 }[mode];
239581
+ }
239582
+ function isProjectProfile(cwd, directory) {
239583
+ const projectRoots = [
239584
+ resolve3(cwd, ".agents", "agents"),
239585
+ resolve3(cwd, ".orbit", "agents"),
239586
+ resolve3(cwd, ".claude", "agents")
239587
+ ];
239588
+ const normalized = resolve3(directory);
239589
+ return projectRoots.some(
239590
+ (root) => process.platform === "win32" ? root.toLowerCase() === normalized.toLowerCase() : root === normalized
239591
+ );
239592
+ }
239593
+ function normalizeDiagnosticPath(filePath) {
239594
+ return filePath.replace(/\\/g, "/");
239595
+ }
239596
+ function formatProfileIssues(error) {
239597
+ return error.issues.slice(0, 4).map((issue) => `${issue.path.join(".") || "profile"}: ${issue.message}`).join("; ");
239598
+ }
239599
+ function safeMessage(error) {
239600
+ return error instanceof Error ? error.message : String(error);
239601
+ }
239240
239602
  var ORBIT_CONFIG_SCHEMA_VERSION = 1;
239241
239603
  var DEFAULT_AGENT_MAX_ITERATIONS = 200;
239242
239604
  var MAX_AGENT_MAX_ITERATIONS = 1e3;
@@ -239255,26 +239617,26 @@ var ORBIT_LIFECYCLE_HOOK_EVENTS = [
239255
239617
  "subagentStop",
239256
239618
  "stop"
239257
239619
  ];
239258
- var LifecycleHookEventSchema = z22.enum(ORBIT_LIFECYCLE_HOOK_EVENTS);
239259
- var LifecycleHookCommandSchema = z22.object({
239260
- command: z22.string().trim().min(1).max(2e4),
239620
+ var LifecycleHookEventSchema = z4.enum(ORBIT_LIFECYCLE_HOOK_EVENTS);
239621
+ var LifecycleHookCommandSchema = z4.object({
239622
+ command: z4.string().trim().min(1).max(2e4),
239261
239623
  /** 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")
239624
+ matcher: z4.string().trim().min(1).max(256).optional(),
239625
+ timeoutMs: z4.number().int().min(100).max(6e5).default(3e4),
239626
+ onFailure: z4.enum(["block", "warn", "ignore"]).default("warn")
239265
239627
  });
239266
- var LifecycleHooksSchema = z22.object(
239628
+ var LifecycleHooksSchema = z4.object(
239267
239629
  Object.fromEntries(
239268
239630
  ORBIT_LIFECYCLE_HOOK_EVENTS.map((event) => [
239269
239631
  event,
239270
- z22.array(LifecycleHookCommandSchema).max(16).optional()
239632
+ z4.array(LifecycleHookCommandSchema).max(16).optional()
239271
239633
  ])
239272
239634
  )
239273
239635
  ).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) => {
239636
+ var EnvironmentVariableNameSchema = z4.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
239637
+ var HttpHeaderNameSchema = z4.string().max(256).regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/);
239638
+ var HttpHeaderValueSchema = z4.string().max(16384).refine((value) => !/[\r\n]/.test(value));
239639
+ var HttpHeadersSchema = z4.record(HttpHeaderNameSchema, HttpHeaderValueSchema).superRefine((value, context) => {
239278
239640
  if (Object.keys(value).length > 200) {
239279
239641
  context.addIssue({
239280
239642
  code: "custom",
@@ -239282,7 +239644,7 @@ var HttpHeadersSchema = z22.record(HttpHeaderNameSchema, HttpHeaderValueSchema).
239282
239644
  });
239283
239645
  }
239284
239646
  });
239285
- var ModelKindSchema = z22.enum([
239647
+ var ModelKindSchema = z4.enum([
239286
239648
  "chat",
239287
239649
  "embedding",
239288
239650
  "image",
@@ -239292,25 +239654,25 @@ var ModelKindSchema = z22.enum([
239292
239654
  "rerank",
239293
239655
  "unknown"
239294
239656
  ]);
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(),
239657
+ var ModelCapabilitiesConfigSchema = z4.object({
239658
+ streaming: z4.boolean().optional(),
239659
+ toolCalls: z4.boolean().optional(),
239660
+ jsonMode: z4.boolean().optional(),
239661
+ thinking: z4.boolean().optional(),
239662
+ vision: z4.boolean().optional(),
239663
+ promptCaching: z4.boolean().optional(),
239664
+ maxContextTokens: z4.number().int().positive().max(1e7).optional(),
239665
+ maxOutputTokens: z4.number().int().positive().max(1e7).optional(),
239304
239666
  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()
239667
+ inputModalities: z4.array(z4.string().min(1).max(64)).max(16).optional(),
239668
+ outputModalities: z4.array(z4.string().min(1).max(64)).max(16).optional(),
239669
+ apiFormats: z4.array(z4.enum(["chat-completions", "responses", "anthropic"])).max(4).optional(),
239670
+ reasoningEfforts: z4.array(z4.enum(["low", "medium", "high", "xhigh", "max"])).max(5).optional(),
239671
+ parallelToolCalls: z4.boolean().optional(),
239672
+ modelVersion: z4.string().min(1).max(256).optional(),
239673
+ effectiveContextWindowPercent: z4.number().positive().max(1).optional()
239312
239674
  });
239313
- var ModelCapabilitiesMapSchema = z22.record(z22.string().min(1).max(1024), ModelCapabilitiesConfigSchema).superRefine((value, context) => {
239675
+ var ModelCapabilitiesMapSchema = z4.record(z4.string().min(1).max(1024), ModelCapabilitiesConfigSchema).superRefine((value, context) => {
239314
239676
  if (Object.keys(value).length > 1e3) {
239315
239677
  context.addIssue({
239316
239678
  code: "custom",
@@ -239318,7 +239680,7 @@ var ModelCapabilitiesMapSchema = z22.record(z22.string().min(1).max(1024), Model
239318
239680
  });
239319
239681
  }
239320
239682
  });
239321
- var ExtraBodySchema = z22.record(z22.unknown()).superRefine((value, context) => {
239683
+ var ExtraBodySchema = z4.record(z4.unknown()).superRefine((value, context) => {
239322
239684
  if (Object.keys(value).length > 1e3) {
239323
239685
  context.addIssue({
239324
239686
  code: "custom",
@@ -239326,8 +239688,8 @@ var ExtraBodySchema = z22.record(z22.unknown()).superRefine((value, context) =>
239326
239688
  });
239327
239689
  }
239328
239690
  });
239329
- var ProviderConfigSchema = z22.object({
239330
- type: z22.enum([
239691
+ var ProviderConfigSchema = z4.object({
239692
+ type: z4.enum([
239331
239693
  "openai",
239332
239694
  "anthropic",
239333
239695
  "openai-compatible",
@@ -239335,24 +239697,24 @@ var ProviderConfigSchema = z22.object({
239335
239697
  "deepseek",
239336
239698
  "ollama"
239337
239699
  ]),
239338
- baseUrl: z22.string().url().max(4096).optional(),
239700
+ baseUrl: z4.string().url().max(4096).optional(),
239339
239701
  apiKeyEnv: EnvironmentVariableNameSchema.optional(),
239340
- apiKey: z22.string().min(1).max(16384).optional(),
239702
+ apiKey: z4.string().min(1).max(16384).optional(),
239341
239703
  apiKeyHeader: HttpHeaderNameSchema.optional(),
239342
- apiKeyPrefix: z22.string().max(1024).refine((value) => !/[\r\n]/.test(value)).optional(),
239704
+ apiKeyPrefix: z4.string().max(1024).refine((value) => !/[\r\n]/.test(value)).optional(),
239343
239705
  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(),
239706
+ models: z4.array(z4.string().min(1).max(1024)).max(1e3).optional(),
239707
+ requestTimeoutMs: z4.number().int().min(1e3).max(6e5).optional(),
239708
+ streamTimeoutMs: z4.number().int().min(1e3).max(6e5).optional(),
239709
+ totalTimeoutMs: z4.number().int().min(1e3).max(9e5).optional(),
239710
+ maxRetries: z4.number().int().min(0).max(5).optional(),
239711
+ disablePreheat: z4.boolean().optional(),
239712
+ deepSeekApiFormat: z4.enum(["auto", "chat-completions", "responses", "anthropic"]).optional(),
239351
239713
  extraBody: ExtraBodySchema.optional(),
239352
239714
  capabilities: ModelCapabilitiesConfigSchema.optional(),
239353
239715
  modelCapabilities: ModelCapabilitiesMapSchema.optional()
239354
239716
  });
239355
- var ProvidersSchema = z22.record(z22.string().min(1).max(256), ProviderConfigSchema).superRefine((value, context) => {
239717
+ var ProvidersSchema = z4.record(z4.string().min(1).max(256), ProviderConfigSchema).superRefine((value, context) => {
239356
239718
  if (Object.keys(value).length > 100) {
239357
239719
  context.addIssue({
239358
239720
  code: "custom",
@@ -239360,34 +239722,34 @@ var ProvidersSchema = z22.record(z22.string().min(1).max(256), ProviderConfigSch
239360
239722
  });
239361
239723
  }
239362
239724
  });
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(),
239725
+ var McpServerConfigBaseSchema = z4.object({
239726
+ transport: z4.enum(["stdio", "streamable-http"]).default("stdio"),
239727
+ command: z4.string().min(1).max(4096).optional(),
239728
+ args: z4.array(z4.string().max(2e4)).max(200).default([]),
239729
+ env: z4.record(EnvironmentVariableNameSchema, z4.string().max(1e5)).optional(),
239730
+ inheritEnv: z4.array(EnvironmentVariableNameSchema).max(200).default([]),
239731
+ url: z4.string().url().max(4096).optional(),
239370
239732
  headers: HttpHeadersSchema.default({}),
239371
239733
  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(),
239734
+ requestTimeoutMs: z4.number().int().min(1e3).max(6e5).optional(),
239735
+ oauth: z4.object({
239736
+ mode: z4.enum(["client_credentials", "authorization_code"]).default("client_credentials"),
239737
+ tokenUrl: z4.string().url().max(4096),
239738
+ authorizationUrl: z4.string().url().max(4096).optional(),
239377
239739
  clientIdEnv: EnvironmentVariableNameSchema,
239378
239740
  clientSecretEnv: EnvironmentVariableNameSchema.optional(),
239379
- scope: z22.string().max(1e3).optional(),
239380
- audience: z22.string().max(1e3).optional()
239741
+ scope: z4.string().max(1e3).optional(),
239742
+ audience: z4.string().max(1e3).optional()
239381
239743
  }).optional(),
239382
- resources: z22.object({
239383
- enabled: z22.boolean().default(true)
239744
+ resources: z4.object({
239745
+ enabled: z4.boolean().default(true)
239384
239746
  }).default({ enabled: true }),
239385
- prompts: z22.object({
239386
- enabled: z22.boolean().default(true)
239747
+ prompts: z4.object({
239748
+ enabled: z4.boolean().default(true)
239387
239749
  }).default({ enabled: true }),
239388
- tools: z22.record(
239389
- z22.object({
239390
- risk: z22.enum(["read", "write", "execute", "dangerous", "network"]).default("execute")
239750
+ tools: z4.record(
239751
+ z4.object({
239752
+ risk: z4.enum(["read", "write", "execute", "dangerous", "network"]).default("execute")
239391
239753
  })
239392
239754
  ).default({})
239393
239755
  });
@@ -239437,7 +239799,7 @@ var McpServerConfigSchema = McpServerConfigBaseSchema.superRefine(
239437
239799
  }
239438
239800
  }
239439
239801
  );
239440
- var McpServersSchema = z22.record(z22.string().min(1).max(256), McpServerConfigSchema).superRefine((value, context) => {
239802
+ var McpServersSchema = z4.record(z4.string().min(1).max(256), McpServerConfigSchema).superRefine((value, context) => {
239441
239803
  if (Object.keys(value).length > 100) {
239442
239804
  context.addIssue({
239443
239805
  code: "custom",
@@ -239445,20 +239807,20 @@ var McpServersSchema = z22.record(z22.string().min(1).max(256), McpServerConfigS
239445
239807
  });
239446
239808
  }
239447
239809
  });
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()
239810
+ var ModelRateSchema = z4.object({
239811
+ inputCostPer1M: z4.number().finite().nonnegative().default(0),
239812
+ outputCostPer1M: z4.number().finite().nonnegative().default(0),
239813
+ cacheReadCostPer1M: z4.number().finite().nonnegative().optional()
239452
239814
  });
239453
239815
  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),
239816
+ scheduled: z4.object({
239817
+ effectiveAt: z4.string().datetime({ offset: true }),
239818
+ peakHoursUtc: z4.array(z4.string().regex(/^\d{2}:\d{2}-\d{2}:\d{2}$/)).max(24),
239457
239819
  peak: ModelRateSchema,
239458
239820
  offPeak: ModelRateSchema
239459
239821
  }).optional()
239460
239822
  });
239461
- var PricingTableSchema = z22.record(z22.string().min(1).max(1024), ModelPriceSchema).superRefine((value, context) => {
239823
+ var PricingTableSchema = z4.record(z4.string().min(1).max(1024), ModelPriceSchema).superRefine((value, context) => {
239462
239824
  if (Object.keys(value).length > 1e4) {
239463
239825
  context.addIssue({
239464
239826
  code: "custom",
@@ -239466,38 +239828,38 @@ var PricingTableSchema = z22.record(z22.string().min(1).max(1024), ModelPriceSch
239466
239828
  });
239467
239829
  }
239468
239830
  });
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),
239831
+ var ConfigSchema = z4.object({
239832
+ schemaVersion: z4.literal(ORBIT_CONFIG_SCHEMA_VERSION).default(1),
239833
+ name: z4.string().min(1).max(256).default("orbit-project"),
239834
+ editor: z4.string().min(1).max(4096).default("notepad.exe"),
239835
+ autoCommit: z4.boolean().default(false),
239474
239836
  language: OrbitLanguageSchema.default("en"),
239475
- security: z22.object({
239476
- trustProjectExecutables: z22.boolean().default(false),
239477
- encryptCheckpoints: z22.boolean().default(true)
239837
+ security: z4.object({
239838
+ trustProjectExecutables: z4.boolean().default(false),
239839
+ encryptCheckpoints: z4.boolean().default(true)
239478
239840
  }).default({}),
239479
- provider: z22.object({
239480
- default: z22.string().min(1).max(256).default("deepseek"),
239481
- embedding: z22.string().min(1).max(256).optional()
239841
+ provider: z4.object({
239842
+ default: z4.string().min(1).max(256).default("deepseek"),
239843
+ embedding: z4.string().min(1).max(256).optional()
239482
239844
  }).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")
239845
+ models: z4.object({
239846
+ default: z4.string().min(1).max(1024).default("deepseek-v4-flash"),
239847
+ fast: z4.string().min(1).max(1024).default("deepseek-v4-flash"),
239848
+ planner: z4.string().min(1).max(1024).default("deepseek-v4-pro"),
239849
+ coder: z4.string().min(1).max(1024).default("deepseek-v4-pro"),
239850
+ reviewer: z4.string().min(1).max(1024).default("deepseek-v4-pro"),
239851
+ summarizer: z4.string().min(1).max(1024).default("deepseek-v4-flash"),
239852
+ embedding: z4.string().min(1).max(1024).default("text-embedding-3-small")
239491
239853
  }).default({}),
239492
239854
  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([
239855
+ permissions: z4.object({
239856
+ mode: z4.enum(["strict", "normal", "auto", "plan"]).default("normal"),
239857
+ allowRead: z4.boolean().default(true),
239858
+ requireApprovalForWrite: z4.boolean().default(true),
239859
+ requireApprovalForBash: z4.boolean().default(true),
239860
+ blockDangerousCommands: z4.boolean().default(true),
239861
+ protectSecrets: z4.boolean().default(true),
239862
+ protectedPaths: z4.array(z4.string().min(1).max(4096)).max(1e3).default([
239501
239863
  ".env",
239502
239864
  ".env.*",
239503
239865
  ".git/**",
@@ -239519,11 +239881,11 @@ var ConfigSchema = z22.object({
239519
239881
  "**/*credential*"
239520
239882
  ])
239521
239883
  }).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([
239884
+ context: z4.object({
239885
+ maxFilesToIndex: z4.number().int().min(1).max(1e5).default(5e3),
239886
+ maxFileSizeKb: z4.number().int().min(1).max(102400).default(512),
239887
+ autoCodebaseRetrieval: z4.boolean().default(true),
239888
+ ignore: z4.array(z4.string().min(1).max(4096)).max(2e3).default([
239527
239889
  "node_modules/**",
239528
239890
  "dist/**",
239529
239891
  "build/**",
@@ -239544,103 +239906,104 @@ var ConfigSchema = z22.object({
239544
239906
  "**/.rustup/**",
239545
239907
  "**/.orbit/**"
239546
239908
  ]),
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([])
239909
+ autoCompact: z4.boolean().default(true),
239910
+ compactThreshold: z4.number().finite().min(0.1).max(1).default(0.75),
239911
+ autoRepair: z4.boolean().default(false),
239912
+ maxRepairAttempts: z4.number().int().min(0).max(10).default(3),
239913
+ testCommands: z4.array(z4.string().max(2e4)).max(100).default([])
239552
239914
  }).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)
239915
+ agent: z4.object({
239916
+ maxIterations: z4.number().int().min(1).max(MAX_AGENT_MAX_ITERATIONS).default(DEFAULT_AGENT_MAX_ITERATIONS),
239917
+ fastMaxOutputTokens: z4.number().int().min(256).max(384e3).default(32768),
239918
+ maxOutputTokens: z4.number().int().min(256).max(384e3).default(16384),
239919
+ teamPreset: z4.enum(["fast", "balanced", "thorough"]).default("balanced"),
239920
+ maxReviewAttempts: z4.number().int().min(1).max(10).default(3),
239921
+ maxReviewConcurrency: z4.number().int().min(1).max(8).default(2)
239560
239922
  }).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)
239923
+ agents: AgentProfileSettingsSchema,
239924
+ autocomplete: z4.object({
239925
+ enabled: z4.boolean().default(true),
239926
+ provider: z4.string().min(1).max(256).default("ollama"),
239927
+ model: z4.string().min(1).max(1024).default("qwen2.5-coder:1.5b"),
239928
+ debounceMs: z4.number().int().min(0).max(1e4).default(150),
239929
+ speculative: z4.object({
239930
+ enabled: z4.boolean().default(false),
239931
+ provider: z4.string().min(1).max(256).default("ollama"),
239932
+ model: z4.string().min(1).max(1024).default("qwen2.5-coder:0.5b"),
239933
+ timeoutMs: z4.number().int().min(0).max(1e4).default(150)
239571
239934
  }).optional()
239572
239935
  }).default({}),
239573
- tui: z22.object({
239574
- mouse: z22.boolean().default(true),
239575
- scrollSpeed: z22.number().int().min(1).max(100).default(50)
239936
+ tui: z4.object({
239937
+ mouse: z4.boolean().default(true),
239938
+ scrollSpeed: z4.number().int().min(1).max(100).default(50)
239576
239939
  }).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)
239940
+ tools: z4.object({
239941
+ bash: z4.object({
239942
+ enabled: z4.boolean().default(true),
239943
+ timeoutMs: z4.number().int().min(1e3).max(6e5).default(12e4)
239581
239944
  }).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)
239945
+ backgroundTasks: z4.object({
239946
+ maxConcurrentTasks: z4.number().int().min(1).max(32).default(8),
239947
+ maxRetainedTasks: z4.number().int().min(1).max(256).default(64),
239948
+ maxOutputBytes: z4.number().int().min(16 * 1024).max(16 * 1024 * 1024).default(1024 * 1024),
239949
+ terminateGraceMs: z4.number().int().min(100).max(3e4).default(2e3),
239950
+ awaitOnCompletion: z4.boolean().default(true),
239951
+ completionWaitMs: z4.number().int().min(1e3).max(3e4).default(3e4)
239589
239952
  }).refine((value) => value.maxRetainedTasks >= value.maxConcurrentTasks, {
239590
239953
  message: "maxRetainedTasks must be greater than or equal to maxConcurrentTasks.",
239591
239954
  path: ["maxRetainedTasks"]
239592
239955
  }).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([]),
239956
+ webSearch: z4.object({
239957
+ enabled: z4.boolean().default(true),
239958
+ provider: z4.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).default("auto"),
239959
+ searxngUrls: z4.array(z4.string().url().max(4096)).max(20).default([]),
239597
239960
  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)
239961
+ tavilyBaseUrl: z4.string().url().max(4096).default("https://api.tavily.com/search"),
239962
+ timeoutMs: z4.number().int().min(1e3).max(3e4).default(8e3),
239963
+ maxResults: z4.number().int().min(1).max(20).default(8)
239601
239964
  }).default({}),
239602
- mcp: z22.object({
239603
- enabled: z22.boolean().default(false)
239965
+ mcp: z4.object({
239966
+ enabled: z4.boolean().default(false)
239604
239967
  }).default({})
239605
239968
  }).default({}),
239606
- skills: z22.object({
239607
- enabled: z22.boolean().default(true),
239608
- directories: z22.array(z22.string().min(1).max(4096)).max(50).default([
239969
+ skills: z4.object({
239970
+ enabled: z4.boolean().default(true),
239971
+ directories: z4.array(z4.string().min(1).max(4096)).max(50).default([
239609
239972
  ".orbit/skills",
239610
239973
  ".agents/skills",
239611
239974
  ".claude/skills",
239612
239975
  "~/.claude/skills",
239613
239976
  "~/.orbit/skills"
239614
239977
  ]),
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)
239978
+ activation: z4.enum(["explicit", "auto"]).default("auto"),
239979
+ maxActive: z4.number().int().min(0).max(8).default(3),
239980
+ disabled: z4.array(z4.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/)).max(200).default([]),
239981
+ maxSkillBytes: z4.number().int().min(512).max(2e5).default(24e3),
239982
+ maxAutoSkillBytes: z4.number().int().min(512).max(2e5).default(8e3)
239620
239983
  }).default({}),
239621
239984
  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()
239985
+ managedPolicy: z4.object({
239986
+ allowedProviders: z4.array(z4.string().min(1).max(1024)).max(1e3).optional(),
239987
+ allowedModels: z4.array(z4.string().min(1).max(1024)).max(1e3).optional(),
239988
+ minimumPermissionMode: z4.enum(["auto", "normal", "strict", "plan"]).optional(),
239989
+ requireWriteApproval: z4.boolean().default(false),
239990
+ requireBashApproval: z4.boolean().default(false),
239991
+ disableWebSearch: z4.boolean().default(false),
239992
+ disableMcp: z4.boolean().default(false),
239993
+ maxIterations: z4.number().int().positive().max(MAX_AGENT_MAX_ITERATIONS).optional()
239631
239994
  }).optional(),
239632
- hooks: z22.object({
239995
+ hooks: z4.object({
239633
239996
  /** @deprecated Use lifecycle.preToolUse with a write-tool matcher. */
239634
- preEdit: z22.string().max(2e4).optional(),
239997
+ preEdit: z4.string().max(2e4).optional(),
239635
239998
  /** @deprecated Use lifecycle.postToolUse with a write-tool matcher. */
239636
- postEdit: z22.string().max(2e4).optional(),
239999
+ postEdit: z4.string().max(2e4).optional(),
239637
240000
  lifecycle: LifecycleHooksSchema.optional()
239638
240001
  }).strict().default({}),
239639
240002
  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")
240003
+ budgetLimit: z4.number().finite().nonnegative().default(10),
240004
+ session: z4.object({
240005
+ store: z4.enum(["sqlite", "jsonl"]).default("jsonl"),
240006
+ path: z4.string().min(1).max(4096).default(".orbit/sessions")
239644
240007
  }).default({})
239645
240008
  });
239646
240009
  var DEFAULT_CONFIG = {
@@ -239778,6 +240141,17 @@ var DEFAULT_CONFIG = {
239778
240141
  maxReviewAttempts: 3,
239779
240142
  maxReviewConcurrency: 2
239780
240143
  },
240144
+ agents: {
240145
+ enabled: true,
240146
+ directories: [
240147
+ ".agents/agents",
240148
+ ".orbit/agents",
240149
+ ".claude/agents",
240150
+ "~/.orbit/agents",
240151
+ "~/.claude/agents"
240152
+ ],
240153
+ maxProfiles: 32
240154
+ },
239781
240155
  tools: {
239782
240156
  bash: {
239783
240157
  enabled: true,
@@ -239878,7 +240252,7 @@ var DEFAULT_CONFIG = {
239878
240252
  scrollSpeed: 50
239879
240253
  }
239880
240254
  };
239881
- var EncodedCredentialKeySchema = z32.string().trim().refine((value) => Buffer.from(value, "base64").length === 32);
240255
+ var EncodedCredentialKeySchema = z5.string().trim().refine((value) => Buffer.from(value, "base64").length === 32);
239882
240256
  var MacOSKeychainKeyStore = class {
239883
240257
  service;
239884
240258
  account;
@@ -240035,15 +240409,15 @@ function isMissingKeychainItem(error) {
240035
240409
  function isUnavailableSecretService(error) {
240036
240410
  return typeof error === "object" && error !== null && ("code" in error && error.code === "ENOENT" || "status" in error && (error.status === 1 || error.status === 2));
240037
240411
  }
240038
- var CredentialKeySchema = z4.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).refine(
240412
+ var CredentialKeySchema = z6.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/).refine(
240039
240413
  (value) => value !== "__proto__" && value !== "constructor" && value !== "prototype"
240040
240414
  );
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)
240415
+ var CredentialValueSchema = z6.string().min(1).max(16384).refine((value) => !/[\r\n]/.test(value));
240416
+ var SecretsFileSchema = z6.record(CredentialKeySchema, z6.string());
240417
+ var EncryptedSecretSchema = z6.object({
240418
+ iv: z6.string().regex(/^[0-9a-f]{24}$/i),
240419
+ encrypted: z6.string().regex(/^[0-9a-f]*$/i),
240420
+ tag: z6.string().regex(/^[0-9a-f]{32}$/i)
240047
240421
  });
240048
240422
  var MAX_SECRETS_FILE_BYTES = 2 * 1024 * 1024;
240049
240423
  var MAX_MASTER_KEY_FILE_BYTES = 1024;
@@ -240060,10 +240434,10 @@ var CredentialsManager = class {
240060
240434
  fallbackKey;
240061
240435
  registeredSecrets = /* @__PURE__ */ new Set();
240062
240436
  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");
240437
+ this.orbitDir = options.orbitDir ?? join22(homedir2(), ".orbit");
240438
+ this.secretsPath = join22(this.orbitDir, "secrets.json");
240439
+ this.masterKeyPath = join22(this.orbitDir, "master.key");
240440
+ this.mutationLockPath = join22(this.orbitDir, "secrets.lock");
240067
240441
  const platform = options.platform ?? process.platform;
240068
240442
  this.isWindows = platform === "win32";
240069
240443
  this.keyStore = options.keyStore === void 0 ? platform === "darwin" ? new MacOSKeychainKeyStore() : platform === "linux" ? new LinuxSecretServiceKeyStore() : null : options.keyStore;
@@ -240208,9 +240582,9 @@ var CredentialsManager = class {
240208
240582
  try {
240209
240583
  const raw = readBoundedRegularFile(this.mutationLockPath, 4096);
240210
240584
  if (raw === void 0) return true;
240211
- const payload = z4.object({
240212
- pid: z4.number().int().positive(),
240213
- createdAt: z4.string().datetime()
240585
+ const payload = z6.object({
240586
+ pid: z6.number().int().positive(),
240587
+ createdAt: z6.string().datetime()
240214
240588
  }).parse(JSON.parse(raw));
240215
240589
  let processAlive = true;
240216
240590
  try {
@@ -240405,19 +240779,19 @@ var CredentialsManager = class {
240405
240779
  chmodSync2(filePath, 384);
240406
240780
  }
240407
240781
  };
240408
- var ProviderProfileIdSchema = z5.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/);
240782
+ var ProviderProfileIdSchema = z7.string().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/);
240409
240783
  var MAX_PROVIDER_PROFILES_BYTES = 1024 * 1024;
240410
- var ProviderProfileSchema = z5.object({
240784
+ var ProviderProfileSchema = z7.object({
240411
240785
  id: ProviderProfileIdSchema,
240412
- name: z5.string().trim().min(1).max(120),
240786
+ name: z7.string().trim().min(1).max(120),
240413
240787
  config: ProviderConfigSchema.omit({ apiKey: true }),
240414
- createdAt: z5.string().datetime(),
240415
- updatedAt: z5.string().datetime()
240788
+ createdAt: z7.string().datetime(),
240789
+ updatedAt: z7.string().datetime()
240416
240790
  });
240417
- var ProviderProfilesFileSchema = z5.object({
240418
- version: z5.literal(1).default(1),
240791
+ var ProviderProfilesFileSchema = z7.object({
240792
+ version: z7.literal(1).default(1),
240419
240793
  activeProvider: ProviderProfileIdSchema.optional(),
240420
- profiles: z5.array(ProviderProfileSchema).max(100)
240794
+ profiles: z7.array(ProviderProfileSchema).max(100)
240421
240795
  });
240422
240796
  var EMPTY_SNAPSHOT = {
240423
240797
  version: 1,
@@ -240428,8 +240802,8 @@ var ProviderProfileStore = class {
240428
240802
  profilePath;
240429
240803
  isWindows;
240430
240804
  constructor(options = {}) {
240431
- this.orbitDir = options.orbitDir ?? join22(homedir2(), ".orbit");
240432
- this.profilePath = join22(this.orbitDir, "providers.json");
240805
+ this.orbitDir = options.orbitDir ?? join3(homedir3(), ".orbit");
240806
+ this.profilePath = join3(this.orbitDir, "providers.json");
240433
240807
  this.isWindows = (options.platform ?? process.platform) === "win32";
240434
240808
  }
240435
240809
  read() {
@@ -240531,202 +240905,59 @@ var ProviderProfileStore = class {
240531
240905
  );
240532
240906
  }
240533
240907
  };
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
240908
  var ORBIT_EXTENSION_MANIFEST_VERSION = 1;
240678
240909
  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(
240910
+ var SemverSchema = z8.string().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/);
240911
+ var ContributionNameSchema = z8.string().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/);
240912
+ var CredentialEnvironmentNameSchema = z8.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/);
240913
+ var RelativeContributionPathSchema = z8.string().min(1).max(4096).refine(
240683
240914
  (value) => !value.includes("\0") && !/^(?:[A-Za-z]:[\\/]|[\\/])/.test(value) && !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(value),
240684
240915
  "Contribution paths must remain inside the extension directory."
240685
240916
  );
240686
- var NamedContributionSchema = z7.object({
240917
+ var NamedContributionSchema = z8.object({
240687
240918
  name: ContributionNameSchema,
240688
240919
  path: RelativeContributionPathSchema,
240689
- description: z7.string().trim().min(1).max(500).optional()
240920
+ description: z8.string().trim().min(1).max(500).optional()
240690
240921
  });
240691
- var ExtensionPermissionSchema = z7.object({
240692
- filesystem: z7.array(
240693
- z7.object({
240694
- mode: z7.enum(["read", "write"]),
240695
- scope: RelativeContributionPathSchema.or(z7.literal("*"))
240922
+ var ExtensionPermissionSchema = z8.object({
240923
+ filesystem: z8.array(
240924
+ z8.object({
240925
+ mode: z8.enum(["read", "write"]),
240926
+ scope: RelativeContributionPathSchema.or(z8.literal("*"))
240696
240927
  })
240697
240928
  ).max(128).default([]),
240698
- network: z7.array(
240699
- z7.string().min(1).max(253).regex(
240929
+ network: z8.array(
240930
+ z8.string().min(1).max(253).regex(
240700
240931
  /^(?:[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
240932
  "Expected a hostname without a URL scheme, path, or credentials."
240702
240933
  )
240703
240934
  ).max(128).default([]),
240704
- process: z7.boolean().default(false),
240705
- credentials: z7.array(CredentialEnvironmentNameSchema).max(64).default([])
240935
+ process: z8.boolean().default(false),
240936
+ credentials: z8.array(CredentialEnvironmentNameSchema).max(64).default([])
240706
240937
  });
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),
240938
+ var OrbitExtensionManifestSchema = z8.object({
240939
+ schemaVersion: z8.literal(ORBIT_EXTENSION_MANIFEST_VERSION),
240940
+ id: z8.string().regex(/^[a-z0-9][a-z0-9._-]{1,127}$/),
240941
+ displayName: z8.string().trim().min(1).max(200),
240711
240942
  version: SemverSchema,
240712
- description: z7.string().trim().max(2e3).optional(),
240713
- orbit: z7.object({
240943
+ description: z8.string().trim().max(2e3).optional(),
240944
+ orbit: z8.object({
240714
240945
  minVersion: SemverSchema,
240715
240946
  maxVersion: SemverSchema.optional()
240716
240947
  }),
240717
240948
  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(
240949
+ contributes: z8.object({
240950
+ commands: z8.array(NamedContributionSchema).max(200).default([]),
240951
+ skills: z8.array(NamedContributionSchema).max(200).default([]),
240952
+ agents: z8.array(NamedContributionSchema).max(100).default([]),
240953
+ tools: z8.array(
240723
240954
  NamedContributionSchema.extend({
240724
- risk: z7.enum(["read", "write", "execute", "dangerous", "network"])
240955
+ risk: z8.enum(["read", "write", "execute", "dangerous", "network"])
240725
240956
  })
240726
240957
  ).max(200).default([]),
240727
- hooks: z7.array(
240728
- z7.object({
240729
- event: z7.enum([
240958
+ hooks: z8.array(
240959
+ z8.object({
240960
+ event: z8.enum([
240730
240961
  "session_start",
240731
240962
  "prompt_submit",
240732
240963
  "permission_request",
@@ -240739,11 +240970,11 @@ var OrbitExtensionManifestSchema = z7.object({
240739
240970
  "agent_end",
240740
240971
  "session_stop"
240741
240972
  ]),
240742
- command: z7.string().trim().min(1).max(4e3)
240973
+ command: z8.string().trim().min(1).max(4e3)
240743
240974
  })
240744
240975
  ).max(100).default([]),
240745
- mcpServers: z7.record(McpServerConfigBaseSchema.omit({ env: true })).default({}),
240746
- templates: z7.array(NamedContributionSchema).max(200).default([])
240976
+ mcpServers: z8.record(McpServerConfigBaseSchema.omit({ env: true })).default({}),
240977
+ templates: z8.array(NamedContributionSchema).max(200).default([])
240747
240978
  }).default({})
240748
240979
  });
240749
240980
  function loadOrbitExtensionManifest(cwd, manifestPath) {
@@ -240754,7 +240985,7 @@ function loadOrbitExtensionManifest(cwd, manifestPath) {
240754
240985
  const raw = extname(resolved).toLowerCase() === ".json" ? JSON.parse(text2) : parseYaml2(text2);
240755
240986
  return OrbitExtensionManifestSchema.parse(raw);
240756
240987
  }
240757
- var ExtensionDigestAlgorithmSchema = z8.enum([
240988
+ var ExtensionDigestAlgorithmSchema = z9.enum([
240758
240989
  "sha256-v1",
240759
240990
  "sha256-v2"
240760
240991
  ]);
@@ -240763,22 +240994,22 @@ var MAX_EXTENSION_TREE_BYTES = 256 * 1024 * 1024;
240763
240994
  var MAX_EXTENSION_TREE_ENTRIES = 1e4;
240764
240995
  var MAX_EXTENSION_TREE_DEPTH = 64;
240765
240996
  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({
240997
+ var InstalledExtensionIdSchema = z9.string().regex(/^[a-z0-9][a-z0-9._-]{1,127}$/);
240998
+ var InstalledExtensionSchema = z9.object({
240768
240999
  id: InstalledExtensionIdSchema,
240769
- digest: z8.string().regex(/^[a-f0-9]{64}$/),
241000
+ digest: z9.string().regex(/^[a-f0-9]{64}$/),
240770
241001
  digestAlgorithm: ExtensionDigestAlgorithmSchema.default("sha256-v1"),
240771
- trusted: z8.boolean(),
240772
- path: z8.string(),
240773
- manifestFile: z8.string().min(1).max(4096).default("extension.yaml")
241002
+ trusted: z9.boolean(),
241003
+ path: z9.string(),
241004
+ manifestFile: z9.string().min(1).max(4096).default("extension.yaml")
240774
241005
  });
240775
- var ExtensionRegistrySchema = z8.object({
240776
- schemaVersion: z8.literal(1),
240777
- extensions: z8.array(InstalledExtensionSchema).max(500).default([])
241006
+ var ExtensionRegistrySchema = z9.object({
241007
+ schemaVersion: z9.literal(1),
241008
+ extensions: z9.array(InstalledExtensionSchema).max(500).default([])
240778
241009
  });
240779
241010
  function applyInstalledExtensionContributions(source, homeDirectory) {
240780
- const registryPath = join3(homeDirectory, ".orbit", "extensions.json");
240781
- if (!existsSync4(registryPath)) return source;
241011
+ const registryPath = join4(homeDirectory, ".orbit", "extensions.json");
241012
+ if (!existsSync22(registryPath)) return source;
240782
241013
  let registry;
240783
241014
  try {
240784
241015
  const raw = readBoundedRegularFile(
@@ -240793,13 +241024,13 @@ function applyInstalledExtensionContributions(source, homeDirectory) {
240793
241024
  const parsed = ExtensionRegistrySchema.safeParse(registry);
240794
241025
  if (!parsed.success) return source;
240795
241026
  const config = structuredClone(source);
240796
- const extensionsRoot = resolve3(homeDirectory, ".orbit", "extensions");
241027
+ const extensionsRoot = resolve22(homeDirectory, ".orbit", "extensions");
240797
241028
  for (const extension of parsed.data.extensions) {
240798
241029
  if (!extension.trusted) continue;
240799
- const root = resolve3(extension.path);
240800
- if (root !== resolve3(extensionsRoot, extension.id)) continue;
241030
+ const root = resolve22(extension.path);
241031
+ if (root !== resolve22(extensionsRoot, extension.id)) continue;
240801
241032
  try {
240802
- if (!existsSync4(root) || lstatSync2(root).isSymbolicLink()) continue;
241033
+ if (!existsSync22(root) || lstatSync2(root).isSymbolicLink()) continue;
240803
241034
  if (hashExtensionDirectory(root, extension.digestAlgorithm) !== extension.digest) {
240804
241035
  continue;
240805
241036
  }
@@ -240827,12 +241058,12 @@ function hashExtensionDirectory(root, algorithm = "sha256-v2") {
240827
241058
  if (depth > MAX_EXTENSION_TREE_DEPTH) {
240828
241059
  throw new Error("Extension tree exceeds the maximum depth.");
240829
241060
  }
240830
- for (const entry of readdirSync(directory).sort()) {
241061
+ for (const entry of readdirSync2(directory).sort()) {
240831
241062
  entries += 1;
240832
241063
  if (entries > MAX_EXTENSION_TREE_ENTRIES) {
240833
241064
  throw new Error("Extension tree contains too many entries.");
240834
241065
  }
240835
- const path9 = join3(directory, entry);
241066
+ const path9 = join4(directory, entry);
240836
241067
  const stats = lstatSync2(path9);
240837
241068
  if (stats.isSymbolicLink()) {
240838
241069
  throw new Error("Symlinked extension entry.");
@@ -240953,6 +241184,28 @@ function sanitizeUntrustedProjectConfig(source, baseline) {
240953
241184
  )
240954
241185
  };
240955
241186
  }
241187
+ if (isRecord(source.agents)) {
241188
+ const agents = {};
241189
+ if (source.agents.enabled === false) agents.enabled = false;
241190
+ if (typeof source.agents.maxProfiles === "number") {
241191
+ agents.maxProfiles = Math.min(
241192
+ source.agents.maxProfiles,
241193
+ baseline.agents.maxProfiles
241194
+ );
241195
+ }
241196
+ if (Array.isArray(source.agents.directories)) {
241197
+ const projectDirectories = /* @__PURE__ */ new Set([
241198
+ ".agents/agents",
241199
+ ".orbit/agents",
241200
+ ".claude/agents"
241201
+ ]);
241202
+ const directories = source.agents.directories.filter(
241203
+ (directory) => typeof directory === "string" && projectDirectories.has(directory)
241204
+ );
241205
+ if (directories.length > 0) agents.directories = directories;
241206
+ }
241207
+ safe.agents = agents;
241208
+ }
240956
241209
  if (isRecord(source.permissions)) {
240957
241210
  const permissions = {};
240958
241211
  const requestedMode = source.permissions.mode;
@@ -241133,9 +241386,9 @@ var ConfigLoader = class {
241133
241386
  }
241134
241387
  static loadSync(cwd, cliOverrides, options = {}) {
241135
241388
  let config = structuredClone(DEFAULT_CONFIG);
241136
- const homeDirectory = options.homeDir ?? homedir3();
241389
+ const homeDirectory = options.homeDir ?? homedir4();
241137
241390
  const env = options.env ?? process.env;
241138
- const globalConfigPath = join4(homeDirectory, ".orbit", "config.yaml");
241391
+ const globalConfigPath = join5(homeDirectory, ".orbit", "config.yaml");
241139
241392
  try {
241140
241393
  const raw = readBoundedRegularFile(
241141
241394
  globalConfigPath,
@@ -241143,7 +241396,7 @@ var ConfigLoader = class {
241143
241396
  { allowSymbolicLink: true }
241144
241397
  );
241145
241398
  if (raw !== void 0) {
241146
- const parsed = parse(raw);
241399
+ const parsed = parse2(raw);
241147
241400
  if (hasUnsupportedSchemaVersion(parsed)) {
241148
241401
  warnUnsupportedConfiguration(globalConfigPath);
241149
241402
  } else {
@@ -241158,7 +241411,7 @@ var ConfigLoader = class {
241158
241411
  } catch {
241159
241412
  warnIgnoredConfiguration(globalConfigPath);
241160
241413
  }
241161
- const profileStore = options.providerProfileStore ?? new ProviderProfileStore({ orbitDir: join4(homeDirectory, ".orbit") });
241414
+ const profileStore = options.providerProfileStore ?? new ProviderProfileStore({ orbitDir: join5(homeDirectory, ".orbit") });
241162
241415
  const providerProfiles = profileStore.read();
241163
241416
  for (const profile of providerProfiles.profiles) {
241164
241417
  config.providers[profile.id] = this.merge(
@@ -241170,7 +241423,7 @@ var ConfigLoader = class {
241170
241423
  config.provider.default = providerProfiles.activeProvider;
241171
241424
  }
241172
241425
  const trustProjectExecutables = options.trustProjectExecutables ?? config.security?.trustProjectExecutables ?? false;
241173
- const projectConfigPath = join4(cwd, "orbit.config.yaml");
241426
+ const projectConfigPath = join5(cwd, "orbit.config.yaml");
241174
241427
  try {
241175
241428
  const raw = readBoundedRegularFile(
241176
241429
  projectConfigPath,
@@ -241178,7 +241431,7 @@ var ConfigLoader = class {
241178
241431
  { allowSymbolicLink: true }
241179
241432
  );
241180
241433
  if (raw !== void 0) {
241181
- const parsed = parse(raw);
241434
+ const parsed = parse2(raw);
241182
241435
  if (hasUnsupportedSchemaVersion(parsed)) {
241183
241436
  warnUnsupportedConfiguration(projectConfigPath);
241184
241437
  } else {
@@ -241197,7 +241450,7 @@ var ConfigLoader = class {
241197
241450
  warnIgnoredConfiguration(projectConfigPath);
241198
241451
  }
241199
241452
  config = this.applyEnvOverrides(config, env);
241200
- const pricingPath = join4(homeDirectory, ".orbit", "pricing.json");
241453
+ const pricingPath = join5(homeDirectory, ".orbit", "pricing.json");
241201
241454
  try {
241202
241455
  const raw = readBoundedRegularFile(pricingPath, MAX_PRICING_FILE_BYTES, {
241203
241456
  allowSymbolicLink: true
@@ -241229,8 +241482,8 @@ var ConfigLoader = class {
241229
241482
  );
241230
241483
  }
241231
241484
  }
241232
- const managedPolicyPath = env.ORBIT_MANAGED_POLICY ? resolve22(env.ORBIT_MANAGED_POLICY) : join4(homeDirectory, ".orbit", "policy.yaml");
241233
- if (existsSync22(managedPolicyPath)) {
241485
+ const managedPolicyPath = env.ORBIT_MANAGED_POLICY ? resolve32(env.ORBIT_MANAGED_POLICY) : join5(homeDirectory, ".orbit", "policy.yaml");
241486
+ if (existsSync32(managedPolicyPath)) {
241234
241487
  try {
241235
241488
  config = applyManagedPolicy(
241236
241489
  ConfigSchema.parse(config),
@@ -241255,7 +241508,7 @@ var ConfigLoader = class {
241255
241508
  path: migrateLegacySessionPath(finalConfig.session.path)
241256
241509
  };
241257
241510
  }
241258
- const credsManager = options.credentialsManager ?? new CredentialsManager({ orbitDir: join4(homeDirectory, ".orbit") });
241511
+ const credsManager = options.credentialsManager ?? new CredentialsManager({ orbitDir: join5(homeDirectory, ".orbit") });
241259
241512
  for (const key of Object.keys(finalConfig.providers)) {
241260
241513
  const provider = finalConfig.providers[key];
241261
241514
  if (!provider.apiKey && provider.apiKeyEnv) {
@@ -242754,7 +243007,7 @@ var zodToJsonSchema = (schema, options) => {
242754
243007
 
242755
243008
  // ../model-providers/dist/index.js
242756
243009
  import { createHash as createHash2 } from "crypto";
242757
- import { z as z9 } from "zod";
243010
+ import { z as z10 } from "zod";
242758
243011
  import { z as z23 } from "zod";
242759
243012
  import { z as z33 } from "zod";
242760
243013
  var DEEPSEEK_V4_FLASH = "deepseek-v4-flash";
@@ -243307,58 +243560,58 @@ function validateJsonObjectToolArguments(argumentsText) {
243307
243560
  invalid: "DeepSeek tool arguments must be a JSON object."
243308
243561
  });
243309
243562
  }
243310
- var ProviderTokenCountSchema = z9.number().int().nonnegative().max(1e9);
243311
- var ProviderCollectionIndexSchema = z9.number().int().nonnegative().max(1e6);
243312
- var AnthropicUsageSchema = z9.object({
243563
+ var ProviderTokenCountSchema = z10.number().int().nonnegative().max(1e9);
243564
+ var ProviderCollectionIndexSchema = z10.number().int().nonnegative().max(1e6);
243565
+ var AnthropicUsageSchema = z10.object({
243313
243566
  input_tokens: ProviderTokenCountSchema.optional(),
243314
243567
  output_tokens: ProviderTokenCountSchema.optional(),
243315
243568
  cache_read_input_tokens: ProviderTokenCountSchema.optional(),
243316
243569
  cache_creation_input_tokens: ProviderTokenCountSchema.optional()
243317
243570
  }).passthrough();
243318
- var AnthropicErrorSchema = z9.object({
243319
- message: z9.string(),
243320
- type: z9.string().optional()
243571
+ var AnthropicErrorSchema = z10.object({
243572
+ message: z10.string(),
243573
+ type: z10.string().optional()
243321
243574
  }).passthrough();
243322
- var AnthropicContentBlockSchema = z9.discriminatedUnion("type", [
243323
- z9.object({
243324
- type: z9.literal("text"),
243325
- text: z9.string()
243575
+ var AnthropicContentBlockSchema = z10.discriminatedUnion("type", [
243576
+ z10.object({
243577
+ type: z10.literal("text"),
243578
+ text: z10.string()
243326
243579
  }).passthrough(),
243327
- z9.object({
243328
- type: z9.literal("thinking"),
243329
- thinking: z9.string(),
243330
- signature: z9.string().optional()
243580
+ z10.object({
243581
+ type: z10.literal("thinking"),
243582
+ thinking: z10.string(),
243583
+ signature: z10.string().optional()
243331
243584
  }).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())
243585
+ z10.object({
243586
+ type: z10.literal("tool_use"),
243587
+ id: z10.string().min(1),
243588
+ name: z10.string().min(1),
243589
+ input: z10.record(z10.unknown())
243337
243590
  }).passthrough()
243338
243591
  ]);
243339
- var AnthropicMessageResponseSchema = z9.object({
243340
- id: z9.string().optional(),
243341
- model: z9.string().optional(),
243342
- content: z9.array(AnthropicContentBlockSchema).max(1e4),
243592
+ var AnthropicMessageResponseSchema = z10.object({
243593
+ id: z10.string().optional(),
243594
+ model: z10.string().optional(),
243595
+ content: z10.array(AnthropicContentBlockSchema).max(1e4),
243343
243596
  usage: AnthropicUsageSchema.optional(),
243344
- stop_reason: z9.string().nullable().optional()
243597
+ stop_reason: z10.string().nullable().optional()
243345
243598
  }).passthrough();
243346
- var AnthropicStreamEventSchema = z9.object({
243347
- type: z9.string(),
243599
+ var AnthropicStreamEventSchema = z10.object({
243600
+ type: z10.string(),
243348
243601
  index: ProviderCollectionIndexSchema.optional(),
243349
- message: z9.object({
243350
- id: z9.string().optional(),
243351
- model: z9.string().optional(),
243602
+ message: z10.object({
243603
+ id: z10.string().optional(),
243604
+ model: z10.string().optional(),
243352
243605
  usage: AnthropicUsageSchema.optional()
243353
243606
  }).passthrough().optional(),
243354
243607
  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()
243608
+ delta: z10.object({
243609
+ type: z10.string().optional(),
243610
+ text: z10.string().optional(),
243611
+ thinking: z10.string().optional(),
243612
+ signature: z10.string().optional(),
243613
+ partial_json: z10.string().optional(),
243614
+ stop_reason: z10.string().nullable().optional()
243362
243615
  }).passthrough().optional(),
243363
243616
  usage: AnthropicUsageSchema.optional(),
243364
243617
  error: AnthropicErrorSchema.optional()
@@ -246222,19 +246475,19 @@ function normalizeOllamaOpenAiBaseUrl(baseUrl) {
246222
246475
  }
246223
246476
 
246224
246477
  // src/runtime/CacheDiagnostics.ts
246225
- import { existsSync as existsSync13, readdirSync as readdirSync5 } from "fs";
246478
+ import { existsSync as existsSync13, readdirSync as readdirSync6 } from "fs";
246226
246479
  import { join as join11 } from "path";
246227
246480
  import picocolors4 from "picocolors";
246228
246481
 
246229
246482
  // ../core/dist/index.js
246230
- import { existsSync as existsSync12, readdirSync as readdirSync4 } from "fs";
246483
+ import { existsSync as existsSync12, readdirSync as readdirSync5 } from "fs";
246231
246484
  import { createHash as createHash7 } from "crypto";
246232
246485
  import { join as join10 } from "path";
246233
246486
  import { z as z31 } from "zod";
246234
246487
  import { z as z211 } from "zod";
246235
246488
 
246236
246489
  // ../tools/dist/index.js
246237
- import { z as z10 } from "zod";
246490
+ import { z as z11 } from "zod";
246238
246491
  import { z as z24 } from "zod";
246239
246492
  import { randomUUID as randomUUID3 } from "crypto";
246240
246493
  import {
@@ -246247,10 +246500,10 @@ import {
246247
246500
  unlinkSync as unlinkSync2,
246248
246501
  writeFileSync as writeFileSync3
246249
246502
  } from "fs";
246250
- import { dirname as dirname4, isAbsolute as isAbsolute2, join as join5, resolve as resolve4 } from "path";
246503
+ import { dirname as dirname4, isAbsolute as isAbsolute3, join as join6, resolve as resolve4 } from "path";
246251
246504
  import { isAbsolute as isAbsolute22, resolve as resolve23 } from "path";
246252
246505
  import { z as z34 } from "zod";
246253
- import { isAbsolute as isAbsolute3, relative as relative4, win32 } from "path";
246506
+ import { isAbsolute as isAbsolute32, relative as relative4, win32 } from "path";
246254
246507
  import glob from "fast-glob";
246255
246508
  import { existsSync as existsSync23 } from "fs";
246256
246509
  import { z as z42 } from "zod";
@@ -247848,12 +248101,12 @@ import { z as z52 } from "zod";
247848
248101
  import { z as z62 } from "zod";
247849
248102
  import { z as z72 } from "zod";
247850
248103
  import { createHash as createHash3 } from "crypto";
247851
- import { existsSync as existsSync32 } from "fs";
248104
+ import { existsSync as existsSync33 } from "fs";
247852
248105
  import { z as z82 } from "zod";
247853
248106
  import { z as z92 } from "zod";
247854
248107
  import { z as z102 } from "zod";
247855
248108
  import { relative as relative22 } from "path";
247856
- import { z as z11 } from "zod";
248109
+ import { z as z112 } from "zod";
247857
248110
  import { z as z12 } from "zod";
247858
248111
  import { existsSync as existsSync42 } from "fs";
247859
248112
  import { join as join23 } from "path";
@@ -247869,7 +248122,7 @@ import { existsSync as existsSync7 } from "fs";
247869
248122
  import { win32 as win322 } from "path";
247870
248123
  import { z as z18 } from "zod";
247871
248124
  import { existsSync as existsSync8 } from "fs";
247872
- import { join as join32, resolve as resolve32 } from "path";
248125
+ import { join as join32, resolve as resolve33 } from "path";
247873
248126
  import { z as z20 } from "zod";
247874
248127
  var import_ipaddr = __toESM(require_ipaddr(), 1);
247875
248128
  import { lookup } from "dns/promises";
@@ -247881,10 +248134,10 @@ import { z as z21 } from "zod";
247881
248134
  import { z as z222 } from "zod";
247882
248135
  import { execFile, spawn } from "child_process";
247883
248136
  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"])
248137
+ var ToolRegistrationSchema = z11.object({
248138
+ name: z11.string().regex(/^[A-Za-z0-9_-]{1,64}$/),
248139
+ description: z11.string().trim().min(1).max(2e4),
248140
+ risk: z11.enum(["read", "write", "execute", "network", "dangerous"])
247888
248141
  });
247889
248142
  var ToolRegistry = class {
247890
248143
  tools = /* @__PURE__ */ new Map();
@@ -247919,14 +248172,14 @@ var MAX_TOOL_FILE_BYTES = 16 * 1024 * 1024;
247919
248172
  var MAX_GREP_FALLBACK_FILE_BYTES = 2 * 1024 * 1024;
247920
248173
  function atomicWriteToolFile(cwd, requestedPath, content, expectedCurrentContent, options = {}) {
247921
248174
  const resolveRequestedPath = () => options.allowOutsideWorkspace ? normalizePath(
247922
- isAbsolute2(requestedPath) ? resolve4(requestedPath) : resolve4(cwd, requestedPath)
248175
+ isAbsolute3(requestedPath) ? resolve4(requestedPath) : resolve4(cwd, requestedPath)
247923
248176
  ) : resolveSafePath(cwd, requestedPath);
247924
248177
  let safePath = resolveRequestedPath();
247925
248178
  const parent = dirname4(safePath);
247926
248179
  mkdirSync2(parent, { recursive: true });
247927
248180
  safePath = resolveRequestedPath();
247928
248181
  assertExpectedContent(safePath, expectedCurrentContent);
247929
- const temporaryPath = join5(parent, `.orbit-write-${randomUUID3()}.tmp`);
248182
+ const temporaryPath = join6(parent, `.orbit-write-${randomUUID3()}.tmp`);
247930
248183
  let descriptor;
247931
248184
  try {
247932
248185
  descriptor = openSync3(temporaryPath, "wx", 384);
@@ -248599,7 +248852,7 @@ var IGNORED_DIRECTORIES = [
248599
248852
  function isWorkspaceRelativeGlob(pattern) {
248600
248853
  const candidate = pattern.startsWith("!") ? pattern.slice(1) : pattern;
248601
248854
  const normalized = candidate.replace(/\\/g, "/");
248602
- return candidate.length > 0 && !isAbsolute3(candidate) && !win32.isAbsolute(candidate) && !normalized.includes("..");
248855
+ return candidate.length > 0 && !isAbsolute32(candidate) && !win32.isAbsolute(candidate) && !normalized.includes("..");
248603
248856
  }
248604
248857
  async function findWorkspaceFiles(root, pattern, options = {}) {
248605
248858
  if (!isWorkspaceRelativeGlob(pattern)) {
@@ -249027,7 +249280,7 @@ var WriteFileTool = class {
249027
249280
  if (!fullHostAccess) throw error;
249028
249281
  currentContentKnown = false;
249029
249282
  }
249030
- const fileExists = currentContentKnown ? current !== void 0 : existsSync32(safePath);
249283
+ const fileExists = currentContentKnown ? current !== void 0 : existsSync33(safePath);
249031
249284
  if (input.intent === "create" && fileExists) {
249032
249285
  return { ok: false, error: `File already exists: ${input.path}` };
249033
249286
  }
@@ -249184,7 +249437,7 @@ var GitRestoreTool = class {
249184
249437
  }
249185
249438
  }
249186
249439
  };
249187
- var GitStatusInputSchema = z11.object({});
249440
+ var GitStatusInputSchema = z112.object({});
249188
249441
  var GitStatusTool = class {
249189
249442
  name = "git_status";
249190
249443
  description = "Show working tree status of git files (short format).";
@@ -249884,11 +250137,11 @@ function detectTrustedTerminalSuccess(command, cwd, output, exitCode) {
249884
250137
  );
249885
250138
  const script = match?.[1] || match?.[2] || match?.[3];
249886
250139
  if (!script) return void 0;
249887
- const actual = comparablePath(resolve32(cwd, script));
250140
+ const actual = comparablePath(resolve33(cwd, script));
249888
250141
  const expected = [
249889
- resolve32(cwd, ".cumcm", "finalize.py"),
250142
+ resolve33(cwd, ".cumcm", "finalize.py"),
249890
250143
  // Read compatibility for projects scaffolded by Orbit <= 0.8.3.
249891
- resolve32(cwd, "code", "finalize.py")
250144
+ resolve33(cwd, "code", "finalize.py")
249892
250145
  ].map(comparablePath);
249893
250146
  return expected.includes(actual) ? "cumcm-finalizer" : void 0;
249894
250147
  }
@@ -251836,14 +252089,14 @@ function errorMessage(error) {
251836
252089
  }
251837
252090
 
251838
252091
  // ../context-engine/dist/index.js
251839
- import { join as join6 } from "path";
252092
+ import { join as join62 } from "path";
251840
252093
  import { existsSync as existsSync9 } from "fs";
251841
252094
  import { pathToFileURL } from "url";
251842
252095
  import { z as z25 } from "zod";
251843
252096
  import { basename, join as join7 } from "path";
251844
252097
  import { existsSync as existsSync43, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3, renameSync as renameSync3, rmSync as rmSync2 } from "fs";
251845
252098
  import { promises as fsPromises3 } from "fs";
251846
- import { join as join24, dirname as dirname32, isAbsolute as isAbsolute4, resolve as resolve33 } from "path";
252099
+ import { join as join24, dirname as dirname32, isAbsolute as isAbsolute4, resolve as resolve34 } from "path";
251847
252100
  import { createHash as createHash4, randomUUID as randomUUID32 } from "crypto";
251848
252101
  import { execFile as execFile2 } from "child_process";
251849
252102
  import glob3 from "fast-glob";
@@ -251853,7 +252106,7 @@ import { existsSync as existsSync24, promises as fsPromises2 } from "fs";
251853
252106
  import { dirname as dirname5, resolve as resolve5 } from "path";
251854
252107
  import { randomUUID as randomUUID4 } from "crypto";
251855
252108
  import { z as z26 } from "zod";
251856
- import { existsSync as existsSync33, promises as fsPromises22 } from "fs";
252109
+ import { existsSync as existsSync34, promises as fsPromises22 } from "fs";
251857
252110
  import { dirname as dirname22, resolve as resolve24 } from "path";
251858
252111
  import { randomUUID as randomUUID23 } from "crypto";
251859
252112
  import { z as z35 } from "zod";
@@ -251862,7 +252115,7 @@ import { extname as extname22 } from "path";
251862
252115
  import { resolve as resolve42 } from "path";
251863
252116
  import { dirname as dirname52 } from "path";
251864
252117
  import { isAbsolute as isAbsolute23, join as join33, resolve as resolve52 } from "path";
251865
- import { homedir as homedir4 } from "os";
252118
+ import { homedir as homedir5 } from "os";
251866
252119
  import { existsSync as existsSync53, promises as fs2 } from "fs";
251867
252120
  import { fileURLToPath as fileURLToPath2 } from "url";
251868
252121
  import { parse as parseYaml3 } from "yaml";
@@ -251871,7 +252124,7 @@ import { dirname as dirname42, join as join42 } from "path";
251871
252124
  import { parse as parseYaml22 } from "yaml";
251872
252125
  import { z as z63 } from "zod";
251873
252126
  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";
252127
+ import { dirname as dirname6, isAbsolute as isAbsolute33, join as join52, win32 as win323 } from "path";
251875
252128
  import { parse as parseYaml32 } from "yaml";
251876
252129
  var ProjectIndexer = class {
251877
252130
  constructor(cwd) {
@@ -252609,7 +252862,7 @@ var BM25Store = class {
252609
252862
  this.initializeCachePath();
252610
252863
  try {
252611
252864
  const parentDir = dirname22(this.dbPath);
252612
- if (!existsSync33(parentDir)) {
252865
+ if (!existsSync34(parentDir)) {
252613
252866
  await fsPromises22.mkdir(parentDir, { recursive: true });
252614
252867
  }
252615
252868
  const data = {
@@ -252644,7 +252897,7 @@ var BM25Store = class {
252644
252897
  }
252645
252898
  async loadFromDisk() {
252646
252899
  this.initializeCachePath();
252647
- if (!existsSync33(this.dbPath)) {
252900
+ if (!existsSync34(this.dbPath)) {
252648
252901
  this.docs = createRecord();
252649
252902
  this.df = createRecord();
252650
252903
  this.avgdl = 0;
@@ -252691,7 +252944,7 @@ var BM25Store = class {
252691
252944
  this.avgdl = 0;
252692
252945
  this.loaded = true;
252693
252946
  this.cacheState = "missing";
252694
- if (existsSync33(this.dbPath)) {
252947
+ if (existsSync34(this.dbPath)) {
252695
252948
  try {
252696
252949
  await fsPromises22.unlink(this.dbPath);
252697
252950
  } catch {
@@ -253110,7 +253363,7 @@ function embeddingBatches(texts) {
253110
253363
  return batches;
253111
253364
  }
253112
253365
  function workspaceIndexKey(cwd) {
253113
- const absolute = resolve33(cwd).replace(/\\/g, "/");
253366
+ const absolute = resolve34(cwd).replace(/\\/g, "/");
253114
253367
  return process.platform === "win32" ? absolute.toLowerCase() : absolute;
253115
253368
  }
253116
253369
  function resolveConfiguredApiKey(provider) {
@@ -253315,7 +253568,7 @@ function getEmbeddingProvider(config) {
253315
253568
  var SymbolIndexer = class {
253316
253569
  constructor(cwd) {
253317
253570
  this.cwd = cwd;
253318
- this.indexPath = resolve33(cwd, ".orbit", "symbols.json");
253571
+ this.indexPath = resolve34(cwd, ".orbit", "symbols.json");
253319
253572
  }
253320
253573
  cwd;
253321
253574
  indexPath;
@@ -253337,9 +253590,9 @@ var SymbolIndexer = class {
253337
253590
  async performIndex() {
253338
253591
  try {
253339
253592
  this.initializeIndexPath();
253340
- const normCwd = resolve33(this.cwd).toLowerCase().replace(/\\/g, "/");
253593
+ const normCwd = resolve34(this.cwd).toLowerCase().replace(/\\/g, "/");
253341
253594
  const { homedir: homedir22 } = await import("os");
253342
- const normHome = resolve33(homedir22()).toLowerCase().replace(/\\/g, "/");
253595
+ const normHome = resolve34(homedir22()).toLowerCase().replace(/\\/g, "/");
253343
253596
  if (normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname32(normCwd) === normCwd) {
253344
253597
  return;
253345
253598
  }
@@ -254170,9 +254423,9 @@ function resolveSkillDirectory(cwd, directory) {
254170
254423
  if (directory === "@orbit/builtin-skills") {
254171
254424
  return resolveBundledSkillsDirectory();
254172
254425
  }
254173
- if (directory === "~") return homedir4();
254426
+ if (directory === "~") return homedir5();
254174
254427
  if (directory.startsWith("~/") || directory.startsWith("~\\")) {
254175
- return resolve52(homedir4(), directory.slice(2));
254428
+ return resolve52(homedir5(), directory.slice(2));
254176
254429
  }
254177
254430
  return isAbsolute23(directory) ? resolve52(directory) : resolve52(cwd, directory);
254178
254431
  }
@@ -254728,7 +254981,7 @@ function validateReference(skill, reference, diagnostics) {
254728
254981
  return;
254729
254982
  }
254730
254983
  if (!relativePath) return;
254731
- if (isAbsolute32(relativePath) || win323.isAbsolute(relativePath)) {
254984
+ if (isAbsolute33(relativePath) || win323.isAbsolute(relativePath)) {
254732
254985
  diagnostics.push(
254733
254986
  diagnostic(
254734
254987
  skill.path,
@@ -254842,7 +255095,11 @@ var ContextPackBuilder = class {
254842
255095
  const projectIndexPromise = this.indexer.index();
254843
255096
  const projectInstructionsPromise = this.loadInstructions();
254844
255097
  const config = ConfigLoader.loadSync(this.cwd);
254845
- const skillsPromise = this.loadSkills(config, userQuery);
255098
+ const skillsPromise = this.loadSkills(
255099
+ config,
255100
+ userQuery,
255101
+ options.forcedSkills
255102
+ );
254846
255103
  let codebaseContextPromise = Promise.resolve(void 0);
254847
255104
  const retrievalMode = selectCodebaseRetrievalMode(
254848
255105
  userQuery,
@@ -255021,7 +255278,7 @@ var ContextPackBuilder = class {
255021
255278
  "README.md"
255022
255279
  ];
255023
255280
  for (const name of candidates) {
255024
- const p = join6(this.cwd, ...name.split("/"));
255281
+ const p = join62(this.cwd, ...name.split("/"));
255025
255282
  try {
255026
255283
  const content = readBoundedRegularFile(
255027
255284
  p,
@@ -255033,7 +255290,7 @@ var ContextPackBuilder = class {
255033
255290
  }
255034
255291
  return "";
255035
255292
  }
255036
- async loadSkills(config, userQuery) {
255293
+ async loadSkills(config, userQuery, forcedSkills = []) {
255037
255294
  const skillsConfig = config.skills;
255038
255295
  if (skillsConfig.enabled === false) {
255039
255296
  return { index: [], active: [], diagnostics: [] };
@@ -255058,11 +255315,12 @@ var ContextPackBuilder = class {
255058
255315
  };
255059
255316
  }
255060
255317
  const { skills, diagnostics } = this.skillsCache;
255318
+ const forcedQuery = forcedSkills.length ? `${userQuery || ""} ${forcedSkills.map((name) => `$${name}`).join(" ")}` : userQuery;
255061
255319
  return {
255062
255320
  // The always-in-context index advertises only enabled skills, and only
255063
255321
  // the fields the prompt renders — not byte accounting or UI metadata.
255064
255322
  index: skills.filter((skill) => !skill.disabled).map(({ name, description, path: path9 }) => ({ name, description, path: path9 })),
255065
- active: selectSkills(skills, userQuery, skillsConfig),
255323
+ active: selectSkills(skills, forcedQuery, skillsConfig),
255066
255324
  diagnostics
255067
255325
  };
255068
255326
  }
@@ -255639,7 +255897,7 @@ var MCPClient = class {
255639
255897
  child.on("error", (error) => {
255640
255898
  this.cleanup(
255641
255899
  new Error(
255642
- `MCP server "${this.serverName}" failed to start: ${safeMessage(error)}`
255900
+ `MCP server "${this.serverName}" failed to start: ${safeMessage2(error)}`
255643
255901
  )
255644
255902
  );
255645
255903
  });
@@ -255662,7 +255920,7 @@ var MCPClient = class {
255662
255920
  if (this.child !== child) return;
255663
255921
  this.cleanup(
255664
255922
  new Error(
255665
- `MCP server "${this.serverName}" stdin failed: ${safeMessage(error)}`
255923
+ `MCP server "${this.serverName}" stdin failed: ${safeMessage2(error)}`
255666
255924
  )
255667
255925
  );
255668
255926
  });
@@ -255945,7 +256203,7 @@ var MCPClient = class {
255945
256203
  this.pendingRequests.delete(id);
255946
256204
  pending.removeAbortListener?.();
255947
256205
  pending.reject(
255948
- new Error(`Unable to write MCP request: ${safeMessage(error)}`)
256206
+ new Error(`Unable to write MCP request: ${safeMessage2(error)}`)
255949
256207
  );
255950
256208
  }
255951
256209
  );
@@ -256011,7 +256269,7 @@ var MCPClient = class {
256011
256269
  pending.reject(
256012
256270
  new McpJsonRpcError(
256013
256271
  response.error.code,
256014
- safeMessage(response.error.message),
256272
+ safeMessage2(response.error.message),
256015
256273
  "data" in response.error ? response.error.data : void 0
256016
256274
  )
256017
256275
  );
@@ -256021,7 +256279,7 @@ var MCPClient = class {
256021
256279
  }
256022
256280
  cleanup(error) {
256023
256281
  this.isConnected = false;
256024
- this.lastError = safeMessage(error);
256282
+ this.lastError = safeMessage2(error);
256025
256283
  for (const pending of this.pendingRequests.values()) {
256026
256284
  clearTimeout(pending.timeout);
256027
256285
  pending.removeAbortListener?.();
@@ -256076,7 +256334,7 @@ function assertSupportedProtocolVersion(initializeResult) {
256076
256334
  );
256077
256335
  }
256078
256336
  }
256079
- function safeMessage(error) {
256337
+ function safeMessage2(error) {
256080
256338
  return sanitizeExternalErrorMessage(error, { singleLine: true });
256081
256339
  }
256082
256340
  var DynamicMCPTool = class {
@@ -256128,7 +256386,7 @@ var DynamicMCPTool = class {
256128
256386
  } catch (error) {
256129
256387
  return {
256130
256388
  ok: false,
256131
- error: `MCP tool execution failed: ${safeMessage(error)}`
256389
+ error: `MCP tool execution failed: ${safeMessage2(error)}`
256132
256390
  };
256133
256391
  }
256134
256392
  }
@@ -256187,7 +256445,7 @@ ${templateCatalog}` : "");
256187
256445
  } catch (error) {
256188
256446
  return {
256189
256447
  ok: false,
256190
- error: `MCP resource read failed: ${safeMessage(error)}`
256448
+ error: `MCP resource read failed: ${safeMessage2(error)}`
256191
256449
  };
256192
256450
  }
256193
256451
  }
@@ -256301,7 +256559,7 @@ var StreamableHttpMCPClient = class {
256301
256559
  return true;
256302
256560
  } catch (error) {
256303
256561
  this.protocolWarnings.push(
256304
- `Excluded MCP tool "${tool.name}": ${safeMessage2(error)}.`
256562
+ `Excluded MCP tool "${tool.name}": ${safeMessage22(error)}.`
256305
256563
  );
256306
256564
  return false;
256307
256565
  }
@@ -256441,7 +256699,7 @@ var StreamableHttpMCPClient = class {
256441
256699
  } catch (error) {
256442
256700
  if (error instanceof McpSessionExpiredError && allowSessionRecovery && this.started && this.negotiatedProtocol?.era === "legacy" && method !== "initialize") {
256443
256701
  this.recoveryCount += 1;
256444
- this.lastError = safeMessage2(error);
256702
+ this.lastError = safeMessage22(error);
256445
256703
  await this.reinitialize(abortSignal);
256446
256704
  if ("cursor" in params) {
256447
256705
  throw new McpPaginationSessionResetError(this.serverName);
@@ -256465,7 +256723,7 @@ var StreamableHttpMCPClient = class {
256465
256723
  if (parsed.data.error) {
256466
256724
  throw new McpJsonRpcError(
256467
256725
  parsed.data.error.code,
256468
- safeMessage2(parsed.data.error.message),
256726
+ safeMessage22(parsed.data.error.message),
256469
256727
  "data" in parsed.data.error ? parsed.data.error.data : void 0
256470
256728
  );
256471
256729
  }
@@ -256635,7 +256893,7 @@ var StreamableHttpMCPClient = class {
256635
256893
  if (protocolError) throw protocolError;
256636
256894
  throw new McpHttpResponseError(
256637
256895
  response.status,
256638
- `MCP HTTP ${response.status}: ${safeMessage2(detail || response.statusText)}`
256896
+ `MCP HTTP ${response.status}: ${safeMessage22(detail || response.statusText)}`
256639
256897
  );
256640
256898
  }
256641
256899
  const sessionId = isModern ? null : response.headers.get("mcp-session-id");
@@ -256677,7 +256935,7 @@ var StreamableHttpMCPClient = class {
256677
256935
  throw error;
256678
256936
  }
256679
256937
  throw new Error(
256680
- `MCP server "${this.serverName}" request failed: ${safeMessage2(error)}`
256938
+ `MCP server "${this.serverName}" request failed: ${safeMessage22(error)}`
256681
256939
  );
256682
256940
  } finally {
256683
256941
  clearTimeout(timeout);
@@ -256782,7 +257040,7 @@ function parseHttpProtocolError(body) {
256782
257040
  if (!parsed.success || !parsed.data.error) return void 0;
256783
257041
  return new McpJsonRpcError(
256784
257042
  parsed.data.error.code,
256785
- safeMessage2(parsed.data.error.message),
257043
+ safeMessage22(parsed.data.error.message),
256786
257044
  "data" in parsed.data.error ? parsed.data.error.data : void 0
256787
257045
  );
256788
257046
  } catch {
@@ -256904,7 +257162,7 @@ function parseSseJson(body, expectedId) {
256904
257162
  }
256905
257163
  throw new Error("MCP SSE response contained no matching JSON-RPC response.");
256906
257164
  }
256907
- function safeMessage2(value) {
257165
+ function safeMessage22(value) {
256908
257166
  return sanitizeExternalErrorMessage(value, { singleLine: true });
256909
257167
  }
256910
257168
  function assertSecureMcpUrl(value, label) {
@@ -257675,7 +257933,7 @@ import {
257675
257933
  existsSync as existsSync10,
257676
257934
  lstatSync as lstatSync4,
257677
257935
  mkdirSync as mkdirSync4,
257678
- readdirSync as readdirSync2,
257936
+ readdirSync as readdirSync3,
257679
257937
  renameSync as renameSync4,
257680
257938
  rmSync as rmSync3
257681
257939
  } from "fs";
@@ -257790,7 +258048,7 @@ var CheckpointManager = class {
257790
258048
  const sessionDir = this.getSessionCheckpointDir();
257791
258049
  if (!existsSync10(sessionDir)) return;
257792
258050
  const loaded = [];
257793
- for (const entry of readdirSync2(sessionDir, { withFileTypes: true })) {
258051
+ for (const entry of readdirSync3(sessionDir, { withFileTypes: true })) {
257794
258052
  if (!entry.isDirectory() || !CheckpointIdSchema.safeParse(entry.name).success) {
257795
258053
  continue;
257796
258054
  }
@@ -258484,7 +258742,7 @@ import {
258484
258742
  lstatSync as lstatSync5,
258485
258743
  mkdirSync as mkdirSync5,
258486
258744
  openSync as openSync5,
258487
- readdirSync as readdirSync3,
258745
+ readdirSync as readdirSync4,
258488
258746
  renameSync as renameSync5,
258489
258747
  rmSync as rmSync4,
258490
258748
  statSync as statSync2,
@@ -258500,8 +258758,8 @@ import {
258500
258758
  statSync as statSync22,
258501
258759
  unlinkSync as unlinkSync4
258502
258760
  } 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";
258761
+ import { homedir as homedir6 } from "os";
258762
+ import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute24, join as join25, parse as parse3, resolve as resolve25 } from "path";
258505
258763
  import { z as z37 } from "zod";
258506
258764
  import {
258507
258765
  closeSync as closeSync32,
@@ -258512,7 +258770,7 @@ import {
258512
258770
  readdirSync as readdirSync22,
258513
258771
  unlinkSync as unlinkSync22
258514
258772
  } from "fs";
258515
- import { basename as basename22, join as join34, resolve as resolve34 } from "path";
258773
+ import { basename as basename22, join as join34, resolve as resolve35 } from "path";
258516
258774
  import { z as z45 } from "zod";
258517
258775
  var SafeObjectKeySchema = z30.string().refine(
258518
258776
  (key) => !["__proto__", "constructor", "prototype"].includes(key),
@@ -258828,6 +259086,7 @@ var PRIVATE_DIRECTORY_MODE2 = 448;
258828
259086
  var PRIVATE_FILE_MODE2 = 384;
258829
259087
  var SESSION_SNAPSHOT_MAX_BYTES = 256 * 1024 * 1024;
258830
259088
  var SESSION_LOG_MAX_BYTES = 256 * 1024 * 1024;
259089
+ var SESSION_EVENT_CACHE_MAX_ITEMS = 25e3;
258831
259090
  var HISTORY_JOURNAL_COMPACT_BYTES = 1024 * 1024;
258832
259091
  var HISTORY_JOURNAL_COMPACT_RECORDS = 32;
258833
259092
  var HistoryJournalRecordSchema = z210.object({
@@ -259007,10 +259266,18 @@ function normalizeTracePath(filePath, cwd) {
259007
259266
  }
259008
259267
  return replaceWorkspacePath(filePath, cwd);
259009
259268
  }
259269
+ function cloneSessionEvents(events) {
259270
+ return events.map((event) => ({
259271
+ ...event,
259272
+ payload: structuredClone(event.payload)
259273
+ }));
259274
+ }
259010
259275
  var SessionStore = class {
259011
259276
  cwd;
259012
259277
  sessionRootPath;
259013
259278
  historyJournalWrites = /* @__PURE__ */ new Map();
259279
+ /** Avoid reparsing a long immutable event journal for every UI refresh. */
259280
+ eventCache = /* @__PURE__ */ new Map();
259014
259281
  constructor(cwd, sessionRootPath = ".orbit/sessions") {
259015
259282
  this.cwd = resolve7(cwd);
259016
259283
  this.sessionRootPath = sessionRootPath.trim();
@@ -259082,7 +259349,7 @@ var SessionStore = class {
259082
259349
  try {
259083
259350
  sessionRoot = this.resolveSessionRoot();
259084
259351
  if (!existsSync11(sessionRoot)) return [];
259085
- dirs = readdirSync3(sessionRoot);
259352
+ dirs = readdirSync4(sessionRoot);
259086
259353
  } catch {
259087
259354
  return [];
259088
259355
  }
@@ -259105,6 +259372,7 @@ var SessionStore = class {
259105
259372
  });
259106
259373
  const file = join9(this.resolveSessionDirectory(sessionId), "events.jsonl");
259107
259374
  appendJsonLine(file, event);
259375
+ this.eventCache.delete(sessionId);
259108
259376
  return event;
259109
259377
  }
259110
259378
  getEvents(sessionId) {
@@ -259114,14 +259382,27 @@ var SessionStore = class {
259114
259382
  } catch {
259115
259383
  return [];
259116
259384
  }
259117
- if (!existsSync11(file)) return [];
259385
+ if (!existsSync11(file)) {
259386
+ this.eventCache.delete(sessionId);
259387
+ return [];
259388
+ }
259389
+ let fileStats;
259390
+ try {
259391
+ const stats = statSync2(file);
259392
+ fileStats = { mtimeMs: stats.mtimeMs, size: stats.size };
259393
+ const cached = this.eventCache.get(sessionId);
259394
+ if (cached && cached.mtimeMs === fileStats.mtimeMs && cached.size === fileStats.size) {
259395
+ return cloneSessionEvents(cached.events);
259396
+ }
259397
+ } catch {
259398
+ }
259118
259399
  let content;
259119
259400
  try {
259120
259401
  content = readBoundedRegularFile(file, SESSION_LOG_MAX_BYTES) ?? "";
259121
259402
  } catch {
259122
259403
  return [];
259123
259404
  }
259124
- return content.split("\n").filter((line) => line.trim()).flatMap((line) => {
259405
+ const events = content.split("\n").filter((line) => line.trim()).flatMap((line) => {
259125
259406
  try {
259126
259407
  const parsed = SessionEventSchema.safeParse(JSON.parse(line));
259127
259408
  return parsed.success && parsed.data.sessionId === sessionId ? [
@@ -259137,6 +259418,12 @@ var SessionStore = class {
259137
259418
  return [];
259138
259419
  }
259139
259420
  });
259421
+ if (fileStats && events.length <= SESSION_EVENT_CACHE_MAX_ITEMS) {
259422
+ this.eventCache.set(sessionId, { ...fileStats, events });
259423
+ } else {
259424
+ this.eventCache.delete(sessionId);
259425
+ }
259426
+ return cloneSessionEvents(events);
259140
259427
  }
259141
259428
  /** Returns a compact, local-only summary derived from the audit stream. */
259142
259429
  getMetrics(sessionId) {
@@ -259461,6 +259748,7 @@ var SessionStore = class {
259461
259748
  if (existsSync11(dir)) {
259462
259749
  rmSync4(dir, { recursive: true, force: true });
259463
259750
  }
259751
+ this.eventCache.delete(id);
259464
259752
  }
259465
259753
  createUniqueSessionDirectory() {
259466
259754
  for (let attempt = 0; attempt < 10; attempt += 1) {
@@ -259938,7 +260226,7 @@ function parseProjectRegistrySnapshot(value) {
259938
260226
  }
259939
260227
  var ProjectRegistry = class {
259940
260228
  filePath;
259941
- constructor(rootPath = join25(homedir5(), ".orbit")) {
260229
+ constructor(rootPath = join25(homedir6(), ".orbit")) {
259942
260230
  const root = resolve25(rootPath);
259943
260231
  this.filePath = join25(root, "projects.json");
259944
260232
  }
@@ -260101,7 +260389,7 @@ function canonicalizeProjectPath(projectPath) {
260101
260389
  if (!isAbsolute24(projectPath))
260102
260390
  throw new Error("Project path must be absolute.");
260103
260391
  const requested = resolve25(projectPath);
260104
- if (requested === parse2(requested).root) {
260392
+ if (requested === parse3(requested).root) {
260105
260393
  throw new Error(
260106
260394
  "A filesystem root cannot be registered as an Orbit project."
260107
260395
  );
@@ -260109,7 +260397,7 @@ function canonicalizeProjectPath(projectPath) {
260109
260397
  if (!isDirectory(requested))
260110
260398
  throw new Error("Project path must be an existing directory.");
260111
260399
  const canonical = realpathSync2.native(requested);
260112
- if (canonical === parse2(canonical).root) {
260400
+ if (canonical === parse3(canonical).root) {
260113
260401
  throw new Error(
260114
260402
  "A filesystem root cannot be registered as an Orbit project."
260115
260403
  );
@@ -260203,7 +260491,7 @@ var AgentRunSchema = z45.object({
260203
260491
  var AgentRunStore = class {
260204
260492
  constructor(cwd, options = {}) {
260205
260493
  this.cwd = cwd;
260206
- this.directory = resolve34(cwd, ".orbit", "agent-runs");
260494
+ this.directory = resolve35(cwd, ".orbit", "agent-runs");
260207
260495
  this.now = options.now ?? (() => /* @__PURE__ */ new Date());
260208
260496
  this.ownerPid = options.ownerPid ?? process.pid;
260209
260497
  this.ownerInstanceId = options.ownerInstanceId ?? generateId("orbit");
@@ -260535,7 +260823,7 @@ var AgentRunStore = class {
260535
260823
  this.cwd,
260536
260824
  join34(".orbit", "agent-runs")
260537
260825
  );
260538
- if (resolve34(safeDirectory) !== this.directory) {
260826
+ if (resolve35(safeDirectory) !== this.directory) {
260539
260827
  throw new Error("Orbit agent-run directory escaped the workspace.");
260540
260828
  }
260541
260829
  }
@@ -260632,9 +260920,9 @@ import { z as z73 } from "zod";
260632
260920
  import { randomUUID as randomUUID52 } from "crypto";
260633
260921
  import { z as z103 } from "zod";
260634
260922
  import { z as z93 } from "zod";
260635
- import { z as z112 } from "zod";
260923
+ import { z as z113 } from "zod";
260636
260924
  import path8 from "path";
260637
- import { existsSync as existsSync34, statSync as statSync3 } from "fs";
260925
+ import { existsSync as existsSync35, statSync as statSync3 } from "fs";
260638
260926
  import { z as z122 } from "zod";
260639
260927
  import { z as z132 } from "zod";
260640
260928
  function createInitialState(sessionId, task, maxAttempts = 8) {
@@ -260904,7 +261192,7 @@ var PromptCacheSlabBuilder = class {
260904
261192
  "- Run at least one DeepSeek request to create a stable slab."
260905
261193
  ].join("\n");
260906
261194
  }
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) => {
261195
+ 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
261196
  const aTime = Date.parse(
260909
261197
  a2.telemetry?.at(-1)?.recordedAt || a2.lastPrimedAt || ""
260910
261198
  );
@@ -264801,7 +265089,8 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264801
265089
  this.getContextWindowStatus(activeModel2).compactAtTokens * 0.4
264802
265090
  )
264803
265091
  )
264804
- )
265092
+ ),
265093
+ forcedSkills: this.options?.forcedSkills
264805
265094
  }
264806
265095
  );
264807
265096
  this.reportSkillContext(this.cachedContextPack);
@@ -264828,6 +265117,10 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264828
265117
  (t2) => this.options.allowedTools.includes(t2.name)
264829
265118
  );
264830
265119
  }
265120
+ if (this.options?.disallowedTools) {
265121
+ const deniedTools = new Set(this.options.disallowedTools);
265122
+ toolDefs = toolDefs.filter((tool) => !deniedTools.has(tool.name));
265123
+ }
264831
265124
  if (this.finalResponseOnlyReason) {
264832
265125
  toolDefs = [];
264833
265126
  }
@@ -264836,7 +265129,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264836
265129
  this.provider,
264837
265130
  activeModel2
264838
265131
  );
264839
- const projectMemory = this.projectMemoryStore.read();
265132
+ const projectMemory = this.options?.memoryMode === "none" ? void 0 : this.projectMemoryStore.read();
264840
265133
  const taskPlan = this.sessionManager.getTaskPlan();
264841
265134
  const baseSystemPrompt = this.options?.systemPromptOverride || Planner.makeSystemPrompt(
264842
265135
  activeModel2,
@@ -264867,7 +265160,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264867
265160
  now: runStartedAt,
264868
265161
  repoMapText,
264869
265162
  sessionGoal: this.sessionManager.getActiveSession()?.goal,
264870
- projectMemory: projectMemory.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
265163
+ projectMemory: projectMemory?.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
264871
265164
  taskPlan: taskPlan?.items.map(
264872
265165
  (item) => `[${item.status}] ${item.text}`
264873
265166
  )
@@ -264894,7 +265187,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
264894
265187
  now: runStartedAt,
264895
265188
  repoMapText,
264896
265189
  sessionGoal: this.sessionManager.getActiveSession()?.goal,
264897
- projectMemory: projectMemory.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
265190
+ projectMemory: projectMemory?.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
264898
265191
  taskPlan: taskPlan?.items.map(
264899
265192
  (item) => `[${item.status}] ${item.text}`
264900
265193
  )
@@ -268326,20 +268619,20 @@ function abortError2(signal) {
268326
268619
  function toError2(error) {
268327
268620
  return error instanceof Error ? error : new Error(String(error));
268328
268621
  }
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)
268622
+ var ParallelWriterTaskSchema = z113.object({
268623
+ id: z113.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/),
268624
+ task: z113.string().trim().min(1).max(2e4),
268625
+ scopes: z113.array(AgentOwnershipScopeSchema).min(1).max(50)
268333
268626
  });
268334
- var ParallelWorkPlanSchema = z112.object({
268335
- summary: z112.string().trim().min(1).max(2e4),
268336
- tasks: z112.array(ParallelWriterTaskSchema).min(1).max(4)
268627
+ var ParallelWorkPlanSchema = z113.object({
268628
+ summary: z113.string().trim().min(1).max(2e4),
268629
+ tasks: z113.array(ParallelWriterTaskSchema).min(1).max(4)
268337
268630
  }).superRefine((plan, context) => {
268338
268631
  const ids = /* @__PURE__ */ new Set();
268339
268632
  for (const [index, task] of plan.tasks.entries()) {
268340
268633
  if (ids.has(task.id)) {
268341
268634
  context.addIssue({
268342
- code: z112.ZodIssueCode.custom,
268635
+ code: z113.ZodIssueCode.custom,
268343
268636
  path: ["tasks", index, "id"],
268344
268637
  message: `Duplicate writer task id: ${task.id}`
268345
268638
  });
@@ -268356,7 +268649,7 @@ var ParallelWorkPlanSchema = z112.object({
268356
268649
  );
268357
268650
  if (!overlap) continue;
268358
268651
  context.addIssue({
268359
- code: z112.ZodIssueCode.custom,
268652
+ code: z113.ZodIssueCode.custom,
268360
268653
  path: ["tasks", right, "scopes"],
268361
268654
  message: `Writer scopes overlap with task ${plan.tasks[left].id}.`
268362
268655
  });
@@ -268538,12 +268831,13 @@ var ReviewVerdictSchema = z122.object({
268538
268831
  feedback: z122.string().default("")
268539
268832
  });
268540
268833
  var Orchestrator = class {
268541
- constructor(cwd, config, provider, task, interaction) {
268834
+ constructor(cwd, config, provider, task, interaction, profile) {
268542
268835
  this.cwd = cwd;
268543
268836
  this.config = config;
268544
268837
  this.provider = provider;
268545
268838
  this.task = task;
268546
268839
  this.interaction = interaction;
268840
+ this.profile = profile;
268547
268841
  this.agentRunTracker = new AgentRunTracker(
268548
268842
  cwd,
268549
268843
  task,
@@ -268556,6 +268850,7 @@ var Orchestrator = class {
268556
268850
  provider;
268557
268851
  task;
268558
268852
  interaction;
268853
+ profile;
268559
268854
  activeLoops = /* @__PURE__ */ new Map();
268560
268855
  activeTaskScheduler;
268561
268856
  agentRunTracker;
@@ -268639,7 +268934,7 @@ var Orchestrator = class {
268639
268934
  snapshotWorkingTree: true
268640
268935
  });
268641
268936
  }
268642
- if (!existsSync34(worktree.path) || !statSync3(worktree.path).isDirectory()) {
268937
+ if (!existsSync35(worktree.path) || !statSync3(worktree.path).isDirectory()) {
268643
268938
  throw new Error(
268644
268939
  `Worktree manager returned a missing directory: ${worktree.path}`
268645
268940
  );
@@ -268778,13 +269073,13 @@ var Orchestrator = class {
268778
269073
  `Create a detailed implementation plan for: ${this.task}`,
268779
269074
  this.interaction,
268780
269075
  {
268781
- modelOverride: this.config.models.planner,
269076
+ modelOverride: this.profile?.model || this.config.models.planner,
268782
269077
  systemPromptOverride: `You are the Orbit Planner Agent.
268783
269078
  Analyze the codebase and produce a bounded implementation plan. Do not modify files.
268784
269079
  Return ONLY one JSON object with this shape:
268785
269080
  {"summary":"shared architecture and acceptance criteria","tasks":[{"id":"short-id","task":"self-contained writer assignment","scopes":["workspace-relative/path"]}]}
268786
269081
  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: [
269082
+ allowedTools: applyProfileToolPolicy(this.profile, [
268788
269083
  "read_file",
268789
269084
  "list_files",
268790
269085
  "glob",
@@ -268793,7 +269088,10 @@ Use 2-4 tasks only when their write scopes are provably disjoint and they can be
268793
269088
  "git_diff",
268794
269089
  "detect_project",
268795
269090
  "inspect_project"
268796
- ],
269091
+ ]),
269092
+ disallowedTools: this.profile?.disallowedTools,
269093
+ forcedSkills: this.profile?.skills,
269094
+ memoryMode: this.profile?.memory,
268797
269095
  disableMcp: true,
268798
269096
  agent: { id: activeId, role: "planner" },
268799
269097
  sessionStorage: this.agentSessionStorage()
@@ -268867,7 +269165,7 @@ Work only in your assigned isolated worktree and only inside the declared write
268867
269165
  const tracked = this.addTrackedAgent(
268868
269166
  role,
268869
269167
  prompt,
268870
- this.config.models.coder,
269168
+ this.profile?.model || this.config.models.coder,
268871
269169
  budgetFraction,
268872
269170
  "write",
268873
269171
  scopes
@@ -268880,9 +269178,9 @@ Work only in your assigned isolated worktree and only inside the declared write
268880
269178
  prompt,
268881
269179
  this.interaction,
268882
269180
  {
268883
- modelOverride: this.config.models.coder,
268884
- systemPromptOverride: systemPrompt,
268885
- allowedTools: [
269181
+ modelOverride: this.profile?.model || this.config.models.coder,
269182
+ systemPromptOverride: [systemPrompt, this.profile?.systemPrompt].filter(Boolean).join("\n\n"),
269183
+ allowedTools: applyProfileToolPolicy(this.profile, [
268886
269184
  "read_file",
268887
269185
  "write_file",
268888
269186
  "edit_file",
@@ -268896,7 +269194,10 @@ Work only in your assigned isolated worktree and only inside the declared write
268896
269194
  "get_background_task_output",
268897
269195
  "kill_background_task",
268898
269196
  "list_background_tasks"
268899
- ],
269197
+ ]),
269198
+ disallowedTools: this.profile?.disallowedTools,
269199
+ forcedSkills: this.profile?.skills,
269200
+ memoryMode: this.profile?.memory,
268900
269201
  disableMcp: true,
268901
269202
  agent: { id: activeId, role },
268902
269203
  sessionStorage: this.agentSessionStorage()
@@ -269282,6 +269583,13 @@ function errorMessage22(error) {
269282
269583
  const raw = error instanceof Error ? error.message : String(error);
269283
269584
  return redactSecrets(raw).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim().slice(0, 2e3);
269284
269585
  }
269586
+ function applyProfileToolPolicy(profile, tools) {
269587
+ const denied = new Set(profile?.disallowedTools ?? []);
269588
+ const allowed = profile?.allowedTools;
269589
+ return tools.filter(
269590
+ (tool) => !denied.has(tool) && (!allowed || allowed.includes(tool))
269591
+ );
269592
+ }
269285
269593
  var AcceptanceVerificationSchema = z132.object({
269286
269594
  name: z132.string().trim().min(1).max(120),
269287
269595
  command: z132.string().trim().min(1).max(4e3),
@@ -269794,7 +270102,7 @@ function buildCacheDiagnostics(cwd) {
269794
270102
  "\u25CF No cache telemetry yet. It will appear after a completed DeepSeek request."
269795
270103
  );
269796
270104
  }
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);
270105
+ 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
270106
  if (slabs.length === 0) {
269799
270107
  return picocolors4.gray(
269800
270108
  "\u25CF No readable cache slab metadata found. Remove stale .orbit/cache-slabs entries if this persists."
@@ -270462,7 +270770,9 @@ var DoctorSnapshotSchema = z47.object({
270462
270770
  mcp: z47.boolean(),
270463
270771
  mcpServerCount: z47.number().int().nonnegative(),
270464
270772
  skills: z47.boolean(),
270465
- automaticCompaction: z47.boolean()
270773
+ automaticCompaction: z47.boolean(),
270774
+ agentProfiles: z47.number().int().nonnegative(),
270775
+ agentProfileErrors: z47.number().int().nonnegative()
270466
270776
  }),
270467
270777
  safety: z47.object({
270468
270778
  permissionMode: z47.enum(["strict", "normal", "auto", "plan"]),
@@ -270574,6 +270884,19 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
270574
270884
  );
270575
270885
  const configuredModels = allConfiguredModelNames(config);
270576
270886
  const issues = [];
270887
+ const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
270888
+ const profileCatalog = agentSettings.enabled ? discoverAgentProfiles(cwd, agentSettings) : { profiles: [], diagnostics: [] };
270889
+ const profileErrors = profileCatalog.diagnostics.filter(
270890
+ (diagnostic2) => diagnostic2.severity === "error"
270891
+ );
270892
+ if (profileErrors.length > 0) {
270893
+ issues.push({
270894
+ severity: "error",
270895
+ code: "agent_profiles.invalid",
270896
+ message: `${profileErrors.length} Agent Profile manifest(s) failed validation.`,
270897
+ remediation: "Run orbit agents validate --json and repair the reported manifests."
270898
+ });
270899
+ }
270577
270900
  if (nodeMajor < 20) {
270578
270901
  issues.push({
270579
270902
  severity: "error",
@@ -270687,7 +271010,9 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
270687
271010
  mcp: config.tools.mcp.enabled,
270688
271011
  mcpServerCount: Object.keys(config.mcpServers).length,
270689
271012
  skills: config.skills.enabled,
270690
- automaticCompaction: config.context.autoCompact
271013
+ automaticCompaction: config.context.autoCompact,
271014
+ agentProfiles: profileCatalog.profiles.length,
271015
+ agentProfileErrors: profileErrors.length
270691
271016
  },
270692
271017
  safety: {
270693
271018
  permissionMode: config.permissions.mode,
@@ -270808,6 +271133,7 @@ function buildDoctorReport(cwd, config = ConfigLoader.loadSync(cwd), options = {
270808
271133
  const gitStatus = commandOutput(exec6, "git status --short", cwd);
270809
271134
  const webSearch = config.tools.webSearch;
270810
271135
  const skills = config.skills;
271136
+ const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
270811
271137
  const mcpServers = Object.keys(config.mcpServers || {});
270812
271138
  const providerKeyName = provider?.apiKeyEnv || "configured provider key";
270813
271139
  const hasApiKey = apiKeyLoaded(defaultProvider, config);
@@ -270928,6 +271254,15 @@ function buildDoctorReport(cwd, config = ConfigLoader.loadSync(cwd), options = {
270928
271254
  lines.push(
270929
271255
  `\u25CF Skill dirs: ${skills.directories.map((dir) => picocolors6.cyan(dir)).join(", ")}`
270930
271256
  );
271257
+ const agentProfiles = agentSettings.enabled ? discoverAgentProfiles(cwd, agentSettings) : { profiles: [], diagnostics: [] };
271258
+ lines.push("");
271259
+ lines.push(picocolors6.bold("Agent Profiles"));
271260
+ lines.push(
271261
+ `\u25CF Profiles: ${boolText(agentSettings.enabled)} discovered=${agentProfiles.profiles.length} errors=${agentProfiles.diagnostics.filter((item) => item.severity === "error").length}`
271262
+ );
271263
+ lines.push(
271264
+ `\u25CF Profile dirs: ${agentSettings.directories.map((dir) => picocolors6.cyan(dir)).join(", ")}`
271265
+ );
270931
271266
  lines.push("");
270932
271267
  lines.push(picocolors6.bold("Safety & Context"));
270933
271268
  lines.push(
@@ -272261,7 +272596,7 @@ var n2 = class extends V {
272261
272596
  import { styleText as styleText2, stripVTControlCharacters } from "util";
272262
272597
  import process$1 from "process";
272263
272598
  var import_sisteransi2 = __toESM(require_src(), 1);
272264
- import { existsSync as existsSync15, lstatSync as lstatSync6, readdirSync as readdirSync6 } from "fs";
272599
+ import { existsSync as existsSync15, lstatSync as lstatSync6, readdirSync as readdirSync7 } from "fs";
272265
272600
  import { dirname as dirname9, join as join13 } from "path";
272266
272601
  function isUnicodeSupported() {
272267
272602
  if (process$1.platform !== "win32") {
@@ -273536,7 +273871,7 @@ import picocolors20 from "picocolors";
273536
273871
 
273537
273872
  // src/tui/FullscreenTui.ts
273538
273873
  import { join as join15 } from "path";
273539
- import { homedir as homedir7 } from "os";
273874
+ import { homedir as homedir8 } from "os";
273540
273875
  import { existsSync as existsSync16 } from "fs";
273541
273876
  import { exec as exec4 } from "child_process";
273542
273877
  import readline3 from "readline";
@@ -274628,14 +274963,14 @@ function findPreviousHistoryEntry(history, query, startIndex = history.length) {
274628
274963
 
274629
274964
  // src/tui/InputHistoryStore.ts
274630
274965
  import { join as join14 } from "path";
274631
- import { homedir as homedir6 } from "os";
274966
+ import { homedir as homedir7 } from "os";
274632
274967
  import { z as z49 } from "zod";
274633
274968
  var INPUT_HISTORY_MAX_BYTES = 1048576;
274634
274969
  var INPUT_HISTORY_MAX_ENTRIES = 500;
274635
274970
  var INPUT_HISTORY_ENTRY_MAX_CHARS = 2e4;
274636
274971
  var inputHistorySchema = z49.array(z49.string().max(INPUT_HISTORY_ENTRY_MAX_CHARS)).max(INPUT_HISTORY_MAX_ENTRIES);
274637
274972
  var InputHistoryStore = class {
274638
- constructor(filePath = join14(homedir6(), ".orbit", "input_history.json")) {
274973
+ constructor(filePath = join14(homedir7(), ".orbit", "input_history.json")) {
274639
274974
  this.filePath = filePath;
274640
274975
  }
274641
274976
  filePath;
@@ -275312,7 +275647,7 @@ function parseNpmJsonString(raw) {
275312
275647
  }
275313
275648
  }
275314
275649
  function compareSemanticVersions(left, right) {
275315
- const parse6 = (version) => {
275650
+ const parse7 = (version) => {
275316
275651
  const withoutBuild = version.split("+", 1)[0] ?? version;
275317
275652
  const prereleaseSeparator = withoutBuild.indexOf("-");
275318
275653
  const corePart = prereleaseSeparator === -1 ? withoutBuild : withoutBuild.slice(0, prereleaseSeparator);
@@ -275322,8 +275657,8 @@ function compareSemanticVersions(left, right) {
275322
275657
  prerelease: prereleasePart ? prereleasePart.split(".") : []
275323
275658
  };
275324
275659
  };
275325
- const leftVersion = parse6(left);
275326
- const rightVersion = parse6(right);
275660
+ const leftVersion = parse7(left);
275661
+ const rightVersion = parse7(right);
275327
275662
  for (let index = 0; index < 3; index++) {
275328
275663
  const difference = (leftVersion.core[index] ?? 0) - (rightVersion.core[index] ?? 0);
275329
275664
  if (difference !== 0) return Math.sign(difference);
@@ -275503,7 +275838,7 @@ async function pageText(text2) {
275503
275838
  var TUI_ERROR_LOG_MAX_BYTES = 1048576;
275504
275839
  function appendTuiErrorLog(context, error) {
275505
275840
  try {
275506
- const logPath = join15(homedir7(), ".orbit", "tui_error.log");
275841
+ const logPath = join15(homedir8(), ".orbit", "tui_error.log");
275507
275842
  let previous = "";
275508
275843
  try {
275509
275844
  previous = readBoundedRegularFile(logPath, TUI_ERROR_LOG_MAX_BYTES) ?? "";
@@ -277601,7 +277936,7 @@ var FullscreenTui = class {
277601
277936
  import picocolors19 from "picocolors";
277602
277937
  import { rmSync as rmSync6, watch } from "fs";
277603
277938
  import { dirname as dirname14, resolve as resolve14 } from "path";
277604
- import { homedir as homedir10 } from "os";
277939
+ import { homedir as homedir11 } from "os";
277605
277940
  import http3 from "http";
277606
277941
  import { randomBytes as randomBytes4, randomUUID as randomUUID13, timingSafeEqual as timingSafeEqual2 } from "crypto";
277607
277942
  import { z as z70 } from "zod";
@@ -277610,11 +277945,11 @@ import { z as z70 } from "zod";
277610
277945
  import picocolors18 from "picocolors";
277611
277946
 
277612
277947
  // src/commands/customCommands.ts
277613
- import { existsSync as existsSync17, readdirSync as readdirSync7 } from "fs";
277948
+ import { existsSync as existsSync17, readdirSync as readdirSync8 } from "fs";
277614
277949
  import { basename as basename4, extname as extname3, join as join16 } from "path";
277615
- import { homedir as homedir8 } from "os";
277950
+ import { homedir as homedir9 } from "os";
277616
277951
  import { fileURLToPath as fileURLToPath3 } from "url";
277617
- import { parse as parse3 } from "yaml";
277952
+ import { parse as parse4 } from "yaml";
277618
277953
  import { z as z51 } from "zod";
277619
277954
  var CommandMetadataSchema = z51.object({
277620
277955
  description: z51.string().max(240).optional(),
@@ -277635,7 +277970,7 @@ function parseLooseFrontmatter(raw) {
277635
277970
  }
277636
277971
  function parseCommandMetadata(raw) {
277637
277972
  try {
277638
- return parse3(raw) || {};
277973
+ return parse4(raw) || {};
277639
277974
  } catch {
277640
277975
  return parseLooseFrontmatter(raw);
277641
277976
  }
@@ -277674,7 +278009,7 @@ function loadDirectory(directory, source) {
277674
278009
  const current = queue.shift();
277675
278010
  let entries;
277676
278011
  try {
277677
- entries = readdirSync7(current, { withFileTypes: true });
278012
+ entries = readdirSync8(current, { withFileTypes: true });
277678
278013
  } catch {
277679
278014
  continue;
277680
278015
  }
@@ -277709,7 +278044,7 @@ function loadCustomCommands(cwd, reservedNames = [], options = {}) {
277709
278044
  Array.from(reservedNames, (name) => name.replace(/^\//, "").toLowerCase())
277710
278045
  );
277711
278046
  const merged = /* @__PURE__ */ new Map();
277712
- const userHome = options.homeDir || homedir8();
278047
+ const userHome = options.homeDir || homedir9();
277713
278048
  const builtinDirectory = options.builtinDir === false ? void 0 : options.builtinDir || resolveBundledCommandsDirectory();
277714
278049
  if (builtinDirectory) {
277715
278050
  mergeDirectory(merged, builtinDirectory, "builtin", reserved);
@@ -277827,8 +278162,8 @@ import { z as z58 } from "zod";
277827
278162
 
277828
278163
  // src/runtime/AutocompleteCandidates.ts
277829
278164
  import glob4 from "fast-glob";
277830
- import { existsSync as existsSync18, readdirSync as readdirSync8 } from "fs";
277831
- import { homedir as homedir9 } from "os";
278165
+ import { existsSync as existsSync18, readdirSync as readdirSync9 } from "fs";
278166
+ import { homedir as homedir10 } from "os";
277832
278167
  import { dirname as dirname10, join as join17, resolve as resolve9 } from "path";
277833
278168
  import { z as z55 } from "zod";
277834
278169
  var AUTOCOMPLETE_SYMBOL_INDEX_MAX_BYTES = 256 * 1024 * 1024;
@@ -277871,7 +278206,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
277871
278206
  const symbols = [];
277872
278207
  const sessions = [];
277873
278208
  const normCwd = resolve9(cwd).toLowerCase().replace(/\\/g, "/");
277874
- const normHome = resolve9(homedir9()).toLowerCase().replace(/\\/g, "/");
278209
+ const normHome = resolve9(homedir10()).toLowerCase().replace(/\\/g, "/");
277875
278210
  const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname10(normCwd) === normCwd;
277876
278211
  if (isHomeOrRoot) {
277877
278212
  return { commands, commandDetails, files, symbols, sessions };
@@ -277913,7 +278248,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
277913
278248
  config.session?.path ?? ".orbit/sessions"
277914
278249
  );
277915
278250
  if (existsSync18(sessionDir)) {
277916
- for (const dir of readdirSync8(sessionDir)) {
278251
+ for (const dir of readdirSync9(sessionDir)) {
277917
278252
  if (existsSync18(join17(sessionDir, dir, "session.json"))) {
277918
278253
  sessions.push(dir);
277919
278254
  }
@@ -278127,6 +278462,8 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278127
278462
  elements.inspectorClose.addEventListener('click', () => setInspector(false));
278128
278463
  elements.inspectorBackdrop.addEventListener('click', () => setInspector(false));
278129
278464
  elements.inspector.addEventListener('keydown', trapInspectorFocus);
278465
+ elements.sidebar.addEventListener('keydown', trapSidebarFocus);
278466
+ elements.commandPalette.addEventListener('keydown', trapCommandPaletteFocus);
278130
278467
  elements.connectionState.addEventListener('click', () => {
278131
278468
  if (!state.ready) void initialize();
278132
278469
  });
@@ -278316,6 +278653,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278316
278653
  if (state.projectLaunchPending && !force) return;
278317
278654
  elements.projectDialog.hidden = true;
278318
278655
  elements.projectDialog.setAttribute('aria-hidden', 'true');
278656
+ syncApplicationModalState();
278319
278657
  if (restoreFocus && state.projectDialogReturnFocus) state.projectDialogReturnFocus.focus();
278320
278658
  state.projectDialogReturnFocus = null;
278321
278659
  };
@@ -278324,6 +278662,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278324
278662
  state.projectDialogReturnFocus = document.activeElement;
278325
278663
  elements.projectDialog.hidden = false;
278326
278664
  elements.projectDialog.setAttribute('aria-hidden', 'false');
278665
+ syncApplicationModalState();
278327
278666
  elements.projectPathInput.focus();
278328
278667
  elements.projectPathInput.select();
278329
278668
  };
@@ -278576,6 +278915,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278576
278915
  if (elements.sessionDeleteDialog.hidden) return;
278577
278916
  elements.sessionDeleteDialog.hidden = true;
278578
278917
  elements.sessionDeleteDialog.setAttribute('aria-hidden', 'true');
278918
+ syncApplicationModalState();
278579
278919
  state.pendingSessionDeleteId = null;
278580
278920
  if (restoreFocus && state.sessionDeleteReturnFocus) state.sessionDeleteReturnFocus.focus();
278581
278921
  state.sessionDeleteReturnFocus = null;
@@ -278588,6 +278928,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278588
278928
  elements.sessionDeleteName.textContent = title && title.textContent || copy.untitledTask;
278589
278929
  elements.sessionDeleteDialog.hidden = false;
278590
278930
  elements.sessionDeleteDialog.setAttribute('aria-hidden', 'false');
278931
+ syncApplicationModalState();
278591
278932
  elements.sessionDeleteConfirm.focus();
278592
278933
  };
278593
278934
  const handleSessionListClick = (event) => {
@@ -278662,7 +279003,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278662
279003
  elements.fullAccessBackdrop.disabled = false;
278663
279004
  elements.fullAccessCancel.disabled = false;
278664
279005
  elements.fullAccessConfirm.disabled = false;
278665
- elements.appShell.inert = false;
279006
+ syncApplicationModalState();
278666
279007
  state.fullAccessRequest = null;
278667
279008
  if (restoreFocus && state.fullAccessReturnFocus) state.fullAccessReturnFocus.focus();
278668
279009
  state.fullAccessReturnFocus = null;
@@ -278688,7 +279029,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
278688
279029
  };
278689
279030
  elements.fullAccessDialog.hidden = false;
278690
279031
  elements.fullAccessDialog.setAttribute('aria-hidden', 'false');
278691
- elements.appShell.inert = true;
279032
+ syncApplicationModalState();
278692
279033
  elements.fullAccessConfirm.focus();
278693
279034
  return promise;
278694
279035
  };
@@ -280687,6 +281028,11 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280687
281028
  elements.sidebarCollapseButton.setAttribute('aria-label', copy.collapseNavigation);
280688
281029
  }
280689
281030
 
281031
+ function syncApplicationModalState() {
281032
+ const modalOpen = !elements.commandPalette.hidden || !elements.sessionDeleteDialog.hidden || !elements.fullAccessDialog.hidden || !elements.projectDialog.hidden;
281033
+ elements.appShell.inert = modalOpen;
281034
+ }
281035
+
280690
281036
  function setDesktopSidebarCollapsed(collapsed) {
280691
281037
  elements.appShell.classList.toggle('sidebar-collapsed', collapsed);
280692
281038
  writeLocalStorage('orbit.webui.sidebar', collapsed ? 'collapsed' : 'expanded');
@@ -280721,8 +281067,14 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280721
281067
  elements.appShell.classList.add('sidebar-open');
280722
281068
  elements.menuButton.setAttribute('aria-expanded', 'true');
280723
281069
  syncSidebarInteractivity();
280724
- const firstControl = elements.sidebar.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
280725
- if (firstControl) firstControl.focus();
281070
+ const firstControl = Array.from(elements.sidebar.querySelectorAll(
281071
+ 'button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])',
281072
+ )).find((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
281073
+ const focusFirstControl = () => {
281074
+ if (firstControl) firstControl.focus({ preventScroll: true });
281075
+ };
281076
+ if (typeof requestAnimationFrame === 'function') requestAnimationFrame(focusFirstControl);
281077
+ else focusFirstControl();
280726
281078
  }
280727
281079
 
280728
281080
  function setInspector(open, tab) {
@@ -280755,7 +281107,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280755
281107
  if (event.key !== 'Tab' || !elements.inspector.classList.contains('is-open')) return;
280756
281108
  const focusable = Array.from(elements.inspector.querySelectorAll(
280757
281109
  '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);
281110
+ )).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
280759
281111
  if (!focusable.length) {
280760
281112
  event.preventDefault();
280761
281113
  elements.inspector.focus();
@@ -280772,6 +281124,23 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
280772
281124
  }
280773
281125
  }
280774
281126
 
281127
+ function trapSidebarFocus(event) {
281128
+ if (event.key !== 'Tab' || !mobileSidebarQuery.matches || !elements.appShell.classList.contains('sidebar-open')) return;
281129
+ const focusable = Array.from(elements.sidebar.querySelectorAll(
281130
+ 'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])',
281131
+ )).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
281132
+ if (!focusable.length) return;
281133
+ const first = focusable[0];
281134
+ const last = focusable[focusable.length - 1];
281135
+ if (event.shiftKey && document.activeElement === first) {
281136
+ event.preventDefault();
281137
+ last.focus();
281138
+ } else if (!event.shiftKey && document.activeElement === last) {
281139
+ event.preventDefault();
281140
+ first.focus();
281141
+ }
281142
+ }
281143
+
280775
281144
  function selectInspectorTab(tab) {
280776
281145
  const tasks = tab === 'tasks';
280777
281146
  const activity = tab === 'activity';
@@ -282315,7 +282684,7 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
282315
282684
  paletteReturnFocus = document.activeElement;
282316
282685
  elements.commandPalette.hidden = false;
282317
282686
  elements.commandPalette.setAttribute('aria-hidden', 'false');
282318
- elements.appShell.inert = true;
282687
+ syncApplicationModalState();
282319
282688
  elements.commandSearch.value = '';
282320
282689
  paletteSelection = 0;
282321
282690
  renderCommandPalette();
@@ -282326,12 +282695,29 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
282326
282695
  if (elements.commandPalette.hidden) return;
282327
282696
  elements.commandPalette.hidden = true;
282328
282697
  elements.commandPalette.setAttribute('aria-hidden', 'true');
282329
- elements.appShell.inert = false;
282698
+ syncApplicationModalState();
282330
282699
  const returnTarget = paletteReturnFocus;
282331
282700
  paletteReturnFocus = null;
282332
282701
  if (returnTarget && returnTarget.isConnected) returnTarget.focus();
282333
282702
  }
282334
282703
 
282704
+ function trapCommandPaletteFocus(event) {
282705
+ if (event.key !== 'Tab' || elements.commandPalette.hidden) return;
282706
+ const focusable = Array.from(elements.commandPalette.querySelectorAll(
282707
+ 'button:not(:disabled):not([tabindex="-1"]), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])',
282708
+ )).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
282709
+ if (!focusable.length) return;
282710
+ const first = focusable[0];
282711
+ const last = focusable[focusable.length - 1];
282712
+ if (event.shiftKey && document.activeElement === first) {
282713
+ event.preventDefault();
282714
+ last.focus();
282715
+ } else if (!event.shiftKey && document.activeElement === last) {
282716
+ event.preventDefault();
282717
+ first.focus();
282718
+ }
282719
+ }
282720
+
282335
282721
  function executePaletteAction(index) {
282336
282722
  const action = paletteActions[index];
282337
282723
  if (!action || (action.idle && state.busy)) return;
@@ -285474,14 +285860,14 @@ var WebUiEventStream = class {
285474
285860
  const payload = sanitizeWebEventPayload(event.type, event.payload);
285475
285861
  if (payload === void 0) return;
285476
285862
  const turn = this.getActiveTurn();
285477
- const eventSessionId = extractSessionId(payload);
285863
+ const identity2 = extractEventIdentity(payload);
285478
285864
  this.broadcast({
285479
285865
  kind: "orbit_event",
285480
285866
  schemaVersion: event.schemaVersion,
285481
285867
  id: event.eventId,
285482
285868
  timestamp: event.timestamp,
285483
- turnId: turn?.id,
285484
- sessionId: eventSessionId || turn?.sessionId,
285869
+ turnId: identity2.turnId || turn?.id,
285870
+ sessionId: identity2.sessionId || turn?.sessionId,
285485
285871
  type: event.type,
285486
285872
  payload
285487
285873
  });
@@ -285610,16 +285996,14 @@ var WebUiEventStream = class {
285610
285996
  if (destroy && !client.destroyed) client.destroy();
285611
285997
  }
285612
285998
  };
285613
- function extractSessionId(payload) {
285999
+ function extractEventIdentity(payload) {
285614
286000
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
285615
- return void 0;
286001
+ return {};
285616
286002
  }
285617
286003
  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;
286004
+ const sessionId = typeof record.sessionId === "string" && record.sessionId.trim() ? record.sessionId : void 0;
286005
+ const turnId = typeof record.turnId === "string" && record.turnId.trim() ? record.turnId : void 0;
286006
+ return { sessionId, turnId };
285623
286007
  }
285624
286008
  function parseLastEventId(value) {
285625
286009
  const text2 = Array.isArray(value) ? value[0] : value;
@@ -286237,7 +286621,7 @@ function renderComposer(copy) {
286237
286621
  <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
286622
  <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
286623
  <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>
286624
+ <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
286625
  <div class="select-control composer-select-control" data-select-control>
286242
286626
  <select class="native-select-proxy" id="permissionSelect" aria-label="${copy.permission}" tabindex="-1" aria-hidden="true" hidden>
286243
286627
  <option value="strict">${copy.modeStrict}</option>
@@ -287041,6 +287425,7 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
287041
287425
  }
287042
287426
 
287043
287427
  .composer-tools {
287428
+ flex: 1 1 auto;
287044
287429
  min-width: 0;
287045
287430
  display: flex;
287046
287431
  align-items: center;
@@ -287053,6 +287438,22 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
287053
287438
  display: none;
287054
287439
  }
287055
287440
 
287441
+ @media (max-width: 420px) {
287442
+ .composer-chip {
287443
+ gap: 4px;
287444
+ padding-inline: 7px;
287445
+ }
287446
+
287447
+ .composer-chip > span:not(.context-chip-count):not(.web-status-dot) {
287448
+ display: none;
287449
+ }
287450
+
287451
+ .composer-select-trigger {
287452
+ gap: 4px;
287453
+ padding-inline: 7px;
287454
+ }
287455
+ }
287456
+
287056
287457
  .composer-chip,
287057
287458
  .composer-select-trigger {
287058
287459
  height: 29px;
@@ -289750,6 +290151,7 @@ body {
289750
290151
  width: 100%;
289751
290152
  height: 100%;
289752
290153
  overflow: hidden;
290154
+ overscroll-behavior: none;
289753
290155
  }
289754
290156
 
289755
290157
  body {
@@ -289932,7 +290334,10 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
289932
290334
 
289933
290335
  .inspector-content {
289934
290336
  min-height: 0;
290337
+ overflow-x: hidden;
289935
290338
  overflow-y: auto;
290339
+ overscroll-behavior: contain;
290340
+ scrollbar-gutter: stable;
289936
290341
  padding: 4px 17px 18px;
289937
290342
  }
289938
290343
 
@@ -291718,12 +292123,13 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
291718
292123
  }
291719
292124
 
291720
292125
  .workspace-view {
291721
- grid-template-rows: 54px auto minmax(0, 1fr);
292126
+ grid-template-rows: calc(54px + env(safe-area-inset-top)) auto minmax(0, 1fr);
291722
292127
  }
291723
292128
 
291724
292129
  .topbar {
291725
- height: 54px;
292130
+ height: calc(54px + env(safe-area-inset-top));
291726
292131
  padding: 0 10px;
292132
+ padding-top: env(safe-area-inset-top);
291727
292133
  }
291728
292134
 
291729
292135
  .workspace-heading span,
@@ -292236,6 +292642,8 @@ var WEB_UI_SELECT_STYLES = String.raw`
292236
292642
  // src/runtime/webui/styles/WebUiShellStyles.ts
292237
292643
  var WEB_UI_SHELL_STYLES = String.raw`
292238
292644
  .app-shell {
292645
+ min-width: 0;
292646
+ min-height: 0;
292239
292647
  height: 100vh;
292240
292648
  height: 100dvh;
292241
292649
  display: grid;
@@ -293118,6 +293526,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
293118
293526
  display: grid;
293119
293527
  grid-template-rows: 62px auto minmax(0, 1fr);
293120
293528
  overflow: hidden;
293529
+ scrollbar-gutter: stable;
293121
293530
  background: var(--canvas);
293122
293531
  border: 1px solid color-mix(in srgb, white 8%, var(--border-strong));
293123
293532
  border-radius: 18px;
@@ -296579,7 +296988,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
296579
296988
  // src/runtime/ProjectLauncher.ts
296580
296989
  import { spawn as spawn4 } from "child_process";
296581
296990
  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";
296991
+ import { dirname as dirname13, isAbsolute as isAbsolute8, parse as parse5, resolve as resolve13 } from "path";
296583
296992
  var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
296584
296993
  var ProjectLaunchError = class extends Error {
296585
296994
  constructor(code, message2, options) {
@@ -296748,7 +297157,7 @@ function requireProjectDirectory(projectPath) {
296748
297157
  }
296749
297158
  function rejectFilesystemRoot(projectPath) {
296750
297159
  const normalized = resolve13(projectPath);
296751
- if (normalized === parse4(normalized).root) {
297160
+ if (normalized === parse5(normalized).root) {
296752
297161
  throw new ProjectLaunchError(
296753
297162
  "filesystem_root",
296754
297163
  "A filesystem root cannot be opened as an Orbit project."
@@ -297884,7 +298293,8 @@ var CommandRouter = class {
297884
298293
  if (shellResult) return shellResult;
297885
298294
  if (trimmed.startsWith("/")) {
297886
298295
  const parts = trimmed.split(" ");
297887
- const command = parts[0].toLowerCase();
298296
+ const rawCommand = parts[0].toLowerCase();
298297
+ const command = rawCommand === "/permissions" ? "/mode" : rawCommand;
297888
298298
  const queueResult = handleInputQueueCommand(
297889
298299
  command,
297890
298300
  parts.slice(1).join(" ").trim(),
@@ -300056,7 +300466,7 @@ Risk Warning: ${reason}`);
300056
300466
  return new RegExp(finalPattern);
300057
300467
  });
300058
300468
  const normCwd = resolve14(this.cwd).toLowerCase().replace(/\\/g, "/");
300059
- const normHome = resolve14(homedir10()).toLowerCase().replace(/\\/g, "/");
300469
+ const normHome = resolve14(homedir11()).toLowerCase().replace(/\\/g, "/");
300060
300470
  const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname14(normCwd) === normCwd;
300061
300471
  if (!isHomeOrRoot) {
300062
300472
  const indexer = new SymbolIndexer(this.cwd);
@@ -300432,6 +300842,15 @@ function getExplicitProviderOverride(cliOverrides) {
300432
300842
  const normalized = selected.trim();
300433
300843
  return normalized || void 0;
300434
300844
  }
300845
+ function getExplicitAgentProfileOverride(cliOverrides) {
300846
+ if (typeof cliOverrides !== "object" || cliOverrides === null || Array.isArray(cliOverrides)) {
300847
+ return void 0;
300848
+ }
300849
+ const selected = cliOverrides.agentProfile;
300850
+ if (typeof selected !== "string") return void 0;
300851
+ const normalized = selected.trim();
300852
+ return normalized || void 0;
300853
+ }
300435
300854
  function applyStoredRuntimeSelection(config, localState, cliOverrides) {
300436
300855
  if (shouldUseStoredProvider(cliOverrides) && localState.lastProvider && config.providers[localState.lastProvider]) {
300437
300856
  config.provider.default = localState.lastProvider;
@@ -300468,6 +300887,8 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
300468
300887
  }
300469
300888
  const config = ConfigLoader.loadSync(cwd, cliOverrides);
300470
300889
  const explicitModelOverride = getExplicitModelOverride(cliOverrides);
300890
+ const explicitProviderOverride = getExplicitProviderOverride(cliOverrides);
300891
+ const explicitAgentProfileOverride = getExplicitAgentProfileOverride(cliOverrides);
300471
300892
  applyStoredRuntimeSelection(
300472
300893
  config,
300473
300894
  readLocalRuntimeState(cwd),
@@ -300487,6 +300908,66 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
300487
300908
  );
300488
300909
  }
300489
300910
  }
300911
+ const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
300912
+ let selectedProfile;
300913
+ const profileName = options?.agentProfile?.trim() || explicitAgentProfileOverride || agentSettings.defaultProfile;
300914
+ if (profileName) {
300915
+ try {
300916
+ if (!agentSettings.enabled) {
300917
+ throw new Error(
300918
+ "Agent Profiles are disabled (agents.enabled: false)."
300919
+ );
300920
+ }
300921
+ const catalog = discoverAgentProfiles(cwd, agentSettings);
300922
+ selectedProfile = resolveAgentProfile(catalog, profileName, config, {
300923
+ allowPermissionEscalation: isFullAccessEnabled(config)
300924
+ });
300925
+ if (!explicitProviderOverride && selectedProfile.provider) {
300926
+ if (!config.providers[selectedProfile.provider]) {
300927
+ throw new Error(
300928
+ `Agent profile ${selectedProfile.name} references unknown provider ${selectedProfile.provider}.`
300929
+ );
300930
+ }
300931
+ config.provider.default = selectedProfile.provider;
300932
+ }
300933
+ if (!explicitModelOverride && selectedProfile.model) {
300934
+ config.models.default = selectedProfile.model;
300935
+ }
300936
+ if (selectedProfile.permissionMode && !cliOverrides?.permissions) {
300937
+ const result = applyPermissionModePreset(
300938
+ config,
300939
+ selectedProfile.permissionMode
300940
+ );
300941
+ if (!result.ok)
300942
+ throw new Error(
300943
+ result.message || "Agent profile permission mode is not allowed."
300944
+ );
300945
+ }
300946
+ if (selectedProfile.maxTurns !== void 0 && shouldUseStoredAgentMaxIterations(cliOverrides)) {
300947
+ config.agent.maxIterations = Math.min(
300948
+ selectedProfile.maxTurns,
300949
+ config.managedPolicy?.maxIterations ?? MAX_AGENT_MAX_ITERATIONS
300950
+ );
300951
+ }
300952
+ } catch (error) {
300953
+ const message2 = redactSecrets(
300954
+ error instanceof Error ? error.message : String(error)
300955
+ );
300956
+ const outcome = {
300957
+ status: "failed",
300958
+ sessionId: "",
300959
+ attempts: 0,
300960
+ error: { code: "execution_error", message: message2 }
300961
+ };
300962
+ eventBus.emitEvent("agent_completed", {
300963
+ taskId: "startup",
300964
+ success: false,
300965
+ result: outcome,
300966
+ error: message2
300967
+ });
300968
+ return outcome;
300969
+ }
300970
+ }
300490
300971
  let providerInstance;
300491
300972
  try {
300492
300973
  providerInstance = createProviderFromConfig(config);
@@ -300551,6 +301032,11 @@ Risk Warning: ${reason}`);
300551
301032
  };
300552
301033
  const activeTask = task;
300553
301034
  if (!activeTask) {
301035
+ if (selectedProfile) {
301036
+ throw new Error(
301037
+ "Agent Profiles currently apply to one-shot task runs; provide a task prompt."
301038
+ );
301039
+ }
300554
301040
  const controller = new ReplController(
300555
301041
  cwd,
300556
301042
  config,
@@ -300569,7 +301055,8 @@ Risk Warning: ${reason}`);
300569
301055
  config,
300570
301056
  providerInstance,
300571
301057
  activeTask,
300572
- interaction
301058
+ interaction,
301059
+ selectedProfile
300573
301060
  );
300574
301061
  return await orchestrator.run();
300575
301062
  } else {
@@ -300587,7 +301074,12 @@ Risk Warning: ${reason}`);
300587
301074
  requireSession: Boolean(options?.resumeSessionId),
300588
301075
  disableStatusBar: !!options?.nonInteractive || !!options?.jsonl,
300589
301076
  nonInteractive: !!options?.nonInteractive,
300590
- autoContinueRunaway: shouldAutoContinueRunaway(config, options)
301077
+ autoContinueRunaway: shouldAutoContinueRunaway(config, options),
301078
+ allowedTools: selectedProfile?.allowedTools,
301079
+ disallowedTools: selectedProfile?.disallowedTools,
301080
+ forcedSkills: selectedProfile?.skills,
301081
+ memoryMode: selectedProfile?.memory,
301082
+ systemPromptOverride: selectedProfile?.systemPrompt
300591
301083
  }
300592
301084
  );
300593
301085
  return await loop.run();
@@ -301516,6 +302008,88 @@ async function runSkillsCommand(action, options = {}) {
301516
302008
  return 0;
301517
302009
  }
301518
302010
 
302011
+ // src/commands/agents.ts
302012
+ import picocolors25 from "picocolors";
302013
+ function runAgentsCommand(action, options = {}) {
302014
+ const cwd = options.cwd ?? process.cwd();
302015
+ const config = ConfigLoader.loadSync(cwd);
302016
+ if (!config.agents.enabled) {
302017
+ if (options.json) {
302018
+ console.log(
302019
+ JSON.stringify({ enabled: false, profiles: [], diagnostics: [] })
302020
+ );
302021
+ } else {
302022
+ console.log("Agent Profiles are disabled (agents.enabled: false).");
302023
+ }
302024
+ return 0;
302025
+ }
302026
+ const catalog = discoverAgentProfiles(cwd, config.agents);
302027
+ const errors = catalog.diagnostics.filter(
302028
+ (item) => item.severity === "error"
302029
+ );
302030
+ if (options.json) {
302031
+ console.log(
302032
+ JSON.stringify(
302033
+ {
302034
+ schemaVersion: 1,
302035
+ enabled: true,
302036
+ directories: catalog.directories,
302037
+ profiles: catalog.profiles.map((profile) => ({
302038
+ name: profile.name,
302039
+ displayName: profile.displayName,
302040
+ description: profile.description,
302041
+ provider: profile.provider,
302042
+ model: profile.model,
302043
+ permissionMode: profile.permissionMode,
302044
+ allowedTools: profile.allowedTools,
302045
+ disallowedTools: profile.disallowedTools,
302046
+ skills: profile.skills,
302047
+ maxTurns: profile.maxTurns,
302048
+ isolation: profile.isolation,
302049
+ memory: profile.memory,
302050
+ path: profile.path,
302051
+ source: profile.source
302052
+ })),
302053
+ diagnostics: catalog.diagnostics
302054
+ },
302055
+ null,
302056
+ 2
302057
+ )
302058
+ );
302059
+ return action === "validate" && errors.length > 0 ? 1 : 0;
302060
+ }
302061
+ if (catalog.profiles.length === 0)
302062
+ console.log("No Agent Profiles discovered.");
302063
+ for (const profile of catalog.profiles) {
302064
+ const model = profile.model ? ` \xB7 model=${profile.model}` : "";
302065
+ const mode = profile.permissionMode ? ` \xB7 mode=${profile.permissionMode}` : "";
302066
+ console.log(
302067
+ `${picocolors25.green(profile.name)}${picocolors25.gray(`${model}${mode}`)}`
302068
+ );
302069
+ if (profile.description) console.log(` ${profile.description}`);
302070
+ console.log(picocolors25.gray(` ${profile.source} \xB7 ${profile.path}`));
302071
+ }
302072
+ for (const diagnostic2 of catalog.diagnostics) {
302073
+ const paint = diagnostic2.severity === "error" ? picocolors25.red : picocolors25.yellow;
302074
+ console.log(
302075
+ `${paint(diagnostic2.severity)} [${diagnostic2.code}] ${diagnostic2.message}`
302076
+ );
302077
+ console.log(picocolors25.gray(` ${diagnostic2.path}`));
302078
+ }
302079
+ if (action === "validate") {
302080
+ if (errors.length > 0) {
302081
+ console.error(
302082
+ picocolors25.red(`\u2716 ${errors.length} Agent Profile error(s) found.`)
302083
+ );
302084
+ return 1;
302085
+ }
302086
+ console.log(
302087
+ picocolors25.green(`\u2714 ${catalog.profiles.length} Agent Profile(s) valid.`)
302088
+ );
302089
+ }
302090
+ return 0;
302091
+ }
302092
+
301519
302093
  // src/commands/trace.ts
301520
302094
  import {
301521
302095
  existsSync as existsSync28,
@@ -301583,7 +302157,7 @@ import {
301583
302157
  import { basename as basename5, dirname as dirname16, join as join19 } from "path";
301584
302158
  import { randomUUID as randomUUID15 } from "crypto";
301585
302159
  import { promisify as promisify5 } from "util";
301586
- import picocolors25 from "picocolors";
302160
+ import picocolors26 from "picocolors";
301587
302161
  import { parse as parseYaml4 } from "yaml";
301588
302162
  import { z as z76 } from "zod";
301589
302163
  var exec5 = promisify5(execCallback);
@@ -301617,7 +302191,7 @@ async function runEval(cwd, suiteFile, options = {}) {
301617
302191
  const results = [];
301618
302192
  for (const task of tasks) {
301619
302193
  if (!value.json) {
301620
- console.log(picocolors25.cyan(`\u25CF Evaluating ${task.id}...`));
302194
+ console.log(picocolors26.cyan(`\u25CF Evaluating ${task.id}...`));
301621
302195
  }
301622
302196
  let worktree;
301623
302197
  const taskStartedAt = Date.now();
@@ -301771,13 +302345,13 @@ async function runEval(cwd, suiteFile, options = {}) {
301771
302345
  console.log(JSON.stringify(report, null, 2));
301772
302346
  } else {
301773
302347
  console.log(
301774
- report.passed ? picocolors25.green(
302348
+ report.passed ? picocolors26.green(
301775
302349
  `\u2714 Acceptance passed: ${passedTasks}/${results.length} tasks.`
301776
- ) : picocolors25.red(
302350
+ ) : picocolors26.red(
301777
302351
  `\u2716 Acceptance failed: ${passedTasks}/${results.length} tasks passed.`
301778
302352
  )
301779
302353
  );
301780
- console.log(picocolors25.gray(`Report: ${reportPath}`));
302354
+ console.log(picocolors26.gray(`Report: ${reportPath}`));
301781
302355
  }
301782
302356
  if (!report.passed) process.exitCode = 1;
301783
302357
  return report;
@@ -302024,25 +302598,25 @@ function safeSummary(value) {
302024
302598
 
302025
302599
  // src/commands/clean.ts
302026
302600
  import readline6 from "readline";
302027
- import picocolors26 from "picocolors";
302601
+ import picocolors27 from "picocolors";
302028
302602
  import { resolve as resolve17 } from "path";
302029
302603
  import { z as z78 } from "zod";
302030
302604
 
302031
302605
  // src/runtime/CleanupManager.ts
302032
302606
  import {
302033
302607
  lstatSync as lstatSync10,
302034
- readdirSync as readdirSync9,
302608
+ readdirSync as readdirSync10,
302035
302609
  realpathSync as realpathSync4,
302036
302610
  rmSync as rmSync9,
302037
302611
  unlinkSync as unlinkSync6
302038
302612
  } 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";
302613
+ import { homedir as homedir12 } from "os";
302614
+ import { basename as basename6, join as join20, parse as parse6, resolve as resolve16 } from "path";
302041
302615
  import { z as z77 } from "zod";
302042
302616
  var CleanupScopeSchema = z77.enum(["user", "project"]);
302043
302617
  function buildCleanupPlan(options) {
302044
302618
  const scopes = z77.array(CleanupScopeSchema).min(1).parse(options.scopes);
302045
- const homeDirectory = resolve16(options.homeDirectory ?? homedir11());
302619
+ const homeDirectory = resolve16(options.homeDirectory ?? homedir12());
302046
302620
  const projectDirectory = resolve16(options.projectDirectory ?? options.cwd);
302047
302621
  const candidates = scopes.map((scope) => ({
302048
302622
  scope,
@@ -302151,7 +302725,7 @@ function inspectPath(targetPath) {
302151
302725
  }
302152
302726
  totals.directories++;
302153
302727
  try {
302154
- for (const entry of readdirSync9(currentPath)) {
302728
+ for (const entry of readdirSync10(currentPath)) {
302155
302729
  visit(join20(currentPath, entry));
302156
302730
  }
302157
302731
  } catch (error) {
@@ -302163,21 +302737,21 @@ function inspectPath(targetPath) {
302163
302737
  }
302164
302738
  function assertSafeOrbitDataPath(targetPath) {
302165
302739
  const absolutePath = resolve16(targetPath);
302166
- if (absolutePath === parse5(absolutePath).root) {
302740
+ if (absolutePath === parse6(absolutePath).root) {
302167
302741
  throw new Error("Refusing to clean a filesystem root.");
302168
302742
  }
302169
302743
  if (basename6(absolutePath).toLowerCase() !== ".orbit") {
302170
302744
  throw new Error("Cleanup targets must be an Orbit data directory.");
302171
302745
  }
302172
302746
  const parentPath = resolve16(absolutePath, "..");
302173
- if (parentPath === parse5(absolutePath).root) {
302747
+ if (parentPath === parse6(absolutePath).root) {
302174
302748
  throw new Error(
302175
302749
  "Refusing to clean an Orbit directory directly under a filesystem root."
302176
302750
  );
302177
302751
  }
302178
302752
  try {
302179
302753
  const canonicalParent = realpathSync4.native(parentPath);
302180
- if (canonicalParent === parse5(canonicalParent).root) {
302754
+ if (canonicalParent === parse6(canonicalParent).root) {
302181
302755
  throw new Error(
302182
302756
  "Refusing to clean an Orbit directory through a filesystem-root link."
302183
302757
  );
@@ -302241,7 +302815,7 @@ async function runClean(cwd, rawOptions, dependencies = {}) {
302241
302815
  );
302242
302816
  }
302243
302817
  if (!confirmed) {
302244
- if (!options.json) write(picocolors26.yellow("\u26A0 Cleanup cancelled."));
302818
+ if (!options.json) write(picocolors27.yellow("\u26A0 Cleanup cancelled."));
302245
302819
  return { applied: false, plan, removed: [], skipped: [] };
302246
302820
  }
302247
302821
  const userTarget = plan.targets.find(
@@ -302263,7 +302837,7 @@ async function runClean(cwd, rawOptions, dependencies = {}) {
302263
302837
  );
302264
302838
  } else {
302265
302839
  write(
302266
- picocolors26.green(
302840
+ picocolors27.green(
302267
302841
  `\u2714 Removed ${result.removed.length} Orbit data director${result.removed.length === 1 ? "y" : "ies"}.`
302268
302842
  )
302269
302843
  );
@@ -302280,18 +302854,18 @@ function resolveScopes(options) {
302280
302854
  return scopes;
302281
302855
  }
302282
302856
  function printCleanupPlan(plan, write) {
302283
- write(picocolors26.bold("\nOrbit cleanup preview\n"));
302857
+ write(picocolors27.bold("\nOrbit cleanup preview\n"));
302284
302858
  for (const target of plan.targets) {
302285
302859
  const scope = target.scopes.join(" + ");
302286
302860
  const status = target.exists ? `${target.files} files \xB7 ${target.directories} directories \xB7 ${formatBytes(target.bytes)}` : "not present";
302287
302861
  write(` ${target.exists ? "\u25CF" : "\u25CB"} ${scope}: ${target.path}`);
302288
- write(` ${picocolors26.gray(status)}`);
302862
+ write(` ${picocolors27.gray(status)}`);
302289
302863
  for (const warning2 of target.warnings) {
302290
- write(` ${picocolors26.yellow(`\u26A0 ${warning2}`)}`);
302864
+ write(` ${picocolors27.yellow(`\u26A0 ${warning2}`)}`);
302291
302865
  }
302292
302866
  }
302293
302867
  write(
302294
- picocolors26.gray(
302868
+ picocolors27.gray(
302295
302869
  "\nOnly .orbit data directories are included. Project source, ORBIT.md, and orbit.config.yaml are preserved."
302296
302870
  )
302297
302871
  );
@@ -302318,7 +302892,7 @@ async function confirmDeletion(prompt) {
302318
302892
 
302319
302893
  // src/commands/backup.ts
302320
302894
  import { basename as basename7, resolve as resolve19 } from "path";
302321
- import picocolors27 from "picocolors";
302895
+ import picocolors28 from "picocolors";
302322
302896
  import { z as z80 } from "zod";
302323
302897
 
302324
302898
  // src/runtime/ProjectBackup.ts
@@ -302326,7 +302900,7 @@ import {
302326
302900
  existsSync as existsSync30,
302327
302901
  lstatSync as lstatSync11,
302328
302902
  mkdirSync as mkdirSync10,
302329
- readdirSync as readdirSync10,
302903
+ readdirSync as readdirSync11,
302330
302904
  renameSync as renameSync8,
302331
302905
  rmSync as rmSync10,
302332
302906
  writeFileSync as writeFileSync10
@@ -302510,7 +303084,7 @@ function listBackupFiles(root) {
302510
303084
  `Project backup tree exceeds ${MAX_BACKUP_TREE_DEPTH} directory levels.`
302511
303085
  );
302512
303086
  }
302513
- for (const name of readdirSync10(directory).sort()) {
303087
+ for (const name of readdirSync11(directory).sort()) {
302514
303088
  visitedEntries += 1;
302515
303089
  if (visitedEntries > MAX_BACKUP_TREE_ENTRIES) {
302516
303090
  throw new Error(
@@ -302630,12 +303204,12 @@ function runBackupCreate(cwd, rawOptions = {}) {
302630
303204
  );
302631
303205
  } else {
302632
303206
  console.log(
302633
- picocolors27.green(
303207
+ picocolors28.green(
302634
303208
  `\u2714 Backed up ${bundle.files.length} durable project file(s) to ${outputPath}`
302635
303209
  )
302636
303210
  );
302637
303211
  console.log(
302638
- picocolors27.gray(
303212
+ picocolors28.gray(
302639
303213
  " Regenerable caches, temporary state, exports, and credentials were excluded."
302640
303214
  )
302641
303215
  );
@@ -302653,7 +303227,7 @@ function runBackupInspect(input, options = {}) {
302653
303227
  };
302654
303228
  if (options.json) console.log(JSON.stringify(summary));
302655
303229
  else {
302656
- console.log(picocolors27.bold(`
303230
+ console.log(picocolors28.bold(`
302657
303231
  ${basename7(input)}
302658
303232
  `));
302659
303233
  console.log(` Project: ${summary.sourceName}`);
@@ -302661,7 +303235,7 @@ ${basename7(input)}
302661
303235
  console.log(
302662
303236
  ` Content: ${summary.files} files \xB7 ${formatBytes3(summary.bytes)}`
302663
303237
  );
302664
- console.log(picocolors27.green(" \u2714 Integrity verified"));
303238
+ console.log(picocolors28.green(" \u2714 Integrity verified"));
302665
303239
  }
302666
303240
  }
302667
303241
  function runBackupRestore(cwd, input, options = {}) {
@@ -302671,13 +303245,13 @@ function runBackupRestore(cwd, input, options = {}) {
302671
303245
  console.log(JSON.stringify({ schemaVersion: 1, ...result }));
302672
303246
  } else {
302673
303247
  console.log(
302674
- picocolors27.green(
303248
+ picocolors28.green(
302675
303249
  `\u2714 Restored ${result.restored.length} project file(s) from ${resolve19(input)}`
302676
303250
  )
302677
303251
  );
302678
303252
  if (result.conflicts.length > 0) {
302679
303253
  console.log(
302680
- picocolors27.yellow(
303254
+ picocolors28.yellow(
302681
303255
  ` Replaced ${result.conflicts.length} existing file(s) because --force was supplied.`
302682
303256
  )
302683
303257
  );
@@ -302694,21 +303268,21 @@ function formatBytes3(bytes) {
302694
303268
  }
302695
303269
 
302696
303270
  // src/commands/extension.ts
302697
- import picocolors28 from "picocolors";
303271
+ import picocolors29 from "picocolors";
302698
303272
 
302699
303273
  // src/runtime/ExtensionManager.ts
302700
303274
  import {
302701
303275
  existsSync as existsSync31,
302702
303276
  lstatSync as lstatSync12,
302703
303277
  mkdirSync as mkdirSync11,
302704
- readdirSync as readdirSync11,
303278
+ readdirSync as readdirSync12,
302705
303279
  renameSync as renameSync9,
302706
303280
  rmSync as rmSync11,
302707
303281
  writeFileSync as writeFileSync11
302708
303282
  } from "fs";
302709
303283
  import { randomUUID as randomUUID17 } from "crypto";
302710
303284
  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";
303285
+ import { homedir as homedir13 } from "os";
302712
303286
  import { z as z81 } from "zod";
302713
303287
  var InstalledExtensionSchema2 = z81.object({
302714
303288
  id: InstalledExtensionIdSchema,
@@ -302729,7 +303303,7 @@ var ExtensionManager = class {
302729
303303
  orbitDir;
302730
303304
  extensionsDir;
302731
303305
  registryPath;
302732
- constructor(homeDirectory = homedir12()) {
303306
+ constructor(homeDirectory = homedir13()) {
302733
303307
  this.orbitDir = join26(homeDirectory, ".orbit");
302734
303308
  this.extensionsDir = join26(this.orbitDir, "extensions");
302735
303309
  this.registryPath = join26(this.orbitDir, "extensions.json");
@@ -303049,7 +303623,7 @@ function copyDirectoryEntry(source, target, budget, depth) {
303049
303623
  throw new Error("Extension directories cannot contain symlinks.");
303050
303624
  if (stats.isDirectory()) {
303051
303625
  mkdirSync11(target, { recursive: true });
303052
- for (const entry of readdirSync11(source)) {
303626
+ for (const entry of readdirSync12(source)) {
303053
303627
  if (entry === "node_modules" || entry === ".git") continue;
303054
303628
  copyDirectoryEntry(
303055
303629
  join26(source, entry),
@@ -303107,9 +303681,9 @@ function verifyOrbitCompatibility(manifest, currentVersion) {
303107
303681
  }
303108
303682
  }
303109
303683
  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);
303684
+ const parse7 = (value) => value.split("-", 1)[0].split(".").map(Number);
303685
+ const a2 = parse7(left);
303686
+ const b = parse7(right);
303113
303687
  for (let index = 0; index < 3; index += 1) {
303114
303688
  if ((a2[index] || 0) !== (b[index] || 0))
303115
303689
  return (a2[index] || 0) - (b[index] || 0);
@@ -303129,12 +303703,12 @@ function validateExtension(cwd, manifestPath, options = {}) {
303129
303703
  0
303130
303704
  );
303131
303705
  console.log(
303132
- picocolors28.green(
303706
+ picocolors29.green(
303133
303707
  `\u2714 Extension manifest is valid: ${manifest.displayName} ${manifest.version}`
303134
303708
  )
303135
303709
  );
303136
303710
  console.log(
303137
- picocolors28.gray(
303711
+ picocolors29.gray(
303138
303712
  ` ${manifest.id} \xB7 ${contributionCount} contribution(s) \xB7 process=${manifest.permissions.process}`
303139
303713
  )
303140
303714
  );
@@ -303143,12 +303717,12 @@ function validateExtension(cwd, manifestPath, options = {}) {
303143
303717
  function installExtension(cwd, manifestPath, options = {}) {
303144
303718
  const installed = new ExtensionManager().install(cwd, manifestPath, options);
303145
303719
  console.log(
303146
- picocolors28.green(
303720
+ picocolors29.green(
303147
303721
  `\u2714 Installed extension: ${installed.displayName} ${installed.version}`
303148
303722
  )
303149
303723
  );
303150
303724
  console.log(
303151
- picocolors28.gray(
303725
+ picocolors29.gray(
303152
303726
  ` ${installed.id} \xB7 sha256:${installed.digest.slice(0, 16)}\u2026`
303153
303727
  )
303154
303728
  );
@@ -303160,24 +303734,24 @@ function listExtensions(options = {}) {
303160
303734
  return;
303161
303735
  }
303162
303736
  if (!extensions.length) {
303163
- console.log(picocolors28.gray("No Orbit extensions are installed."));
303737
+ console.log(picocolors29.gray("No Orbit extensions are installed."));
303164
303738
  return;
303165
303739
  }
303166
303740
  for (const extension of extensions) {
303167
303741
  console.log(
303168
- `${picocolors28.green("\u25CF")} ${extension.displayName} ${extension.version} ${picocolors28.gray(`(${extension.id})`)}`
303742
+ `${picocolors29.green("\u25CF")} ${extension.displayName} ${extension.version} ${picocolors29.gray(`(${extension.id})`)}`
303169
303743
  );
303170
303744
  }
303171
303745
  }
303172
303746
  function removeExtension(id) {
303173
303747
  const removed = new ExtensionManager().remove(id);
303174
303748
  console.log(
303175
- removed ? picocolors28.green(`\u2714 Removed extension: ${id}`) : picocolors28.yellow(`Extension is not installed: ${id}`)
303749
+ removed ? picocolors29.green(`\u2714 Removed extension: ${id}`) : picocolors29.yellow(`Extension is not installed: ${id}`)
303176
303750
  );
303177
303751
  }
303178
303752
 
303179
303753
  // src/index.ts
303180
- import { existsSync as existsSync35, realpathSync as realpathSync5, statSync as statSync6 } from "fs";
303754
+ import { existsSync as existsSync36, realpathSync as realpathSync5, statSync as statSync6 } from "fs";
303181
303755
  import { resolve as resolve21 } from "path";
303182
303756
 
303183
303757
  // src/runtime/CliRunOverrides.ts
@@ -303189,6 +303763,9 @@ function createCliRunOverrides(options) {
303189
303763
  if (options.model) {
303190
303764
  overrides.models = { default: options.model };
303191
303765
  }
303766
+ if (options.agentProfile) {
303767
+ overrides.agentProfile = options.agentProfile;
303768
+ }
303192
303769
  if (options.direct) {
303193
303770
  overrides.direct = true;
303194
303771
  }
@@ -303205,6 +303782,9 @@ function applyOutcomeExitCode(outcome) {
303205
303782
  process.exitCode = Math.max(currentExitCode, exitCodeForOutcome(outcome));
303206
303783
  }
303207
303784
  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(
303785
+ "--agent-profile <name>",
303786
+ "select a validated Agent Profile for this task"
303787
+ ).option(
303208
303788
  "--yes",
303209
303789
  "enable unrestricted Full Access and approve every enabled tool action"
303210
303790
  ).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 +303795,9 @@ program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").versi
303215
303795
  direct: !!options.direct,
303216
303796
  fullAccess: !!options.yes
303217
303797
  });
303218
- const outcome = await runAgent(cwd, task, overrides, !!options.multi);
303798
+ const outcome = await runAgent(cwd, task, overrides, !!options.multi, {
303799
+ agentProfile: options.agentProfile
303800
+ });
303219
303801
  applyOutcomeExitCode(outcome);
303220
303802
  });
303221
303803
  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 +303877,18 @@ skillsCommand.command("validate").description("validate SKILL.md files; non-zero
303295
303877
  });
303296
303878
  }
303297
303879
  );
303880
+ var agentsCommand = program.command("agents").description("list and validate reusable Agent Profiles");
303881
+ agentsCommand.command("list").description("list discovered Agent Profiles with diagnostics").option("--json", "print a machine-readable catalog").action((options) => {
303882
+ process.exitCode = runAgentsCommand("list", { json: !!options.json });
303883
+ });
303884
+ agentsCommand.command("validate").description("validate Agent Profile manifests; non-zero on errors").option("--json", "print a machine-readable report").action((options) => {
303885
+ process.exitCode = runAgentsCommand("validate", { json: !!options.json });
303886
+ });
303298
303887
  var mcpCommand = program.command("mcp").description("manage Model Context Protocol servers");
303299
303888
  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
303889
  const port = options.port ? Number.parseInt(options.port, 10) : void 0;
303301
303890
  if (options.port && (!Number.isInteger(port) || port < 1 || port > 65535)) {
303302
- console.error(picocolors29.red("\u2716 --port must be an integer in 1-65535."));
303891
+ console.error(picocolors30.red("\u2716 --port must be an integer in 1-65535."));
303303
303892
  process.exitCode = 1;
303304
303893
  return;
303305
303894
  }
@@ -303425,7 +304014,7 @@ program.command("webui").description("start Orbit as a browser-first local codin
303425
304014
  fullAccess: !!options.yes
303426
304015
  });
303427
304016
  const requestedCwd = resolve21(localOptions.cwd || process.cwd());
303428
- if (!existsSync35(requestedCwd) || !statSync6(requestedCwd).isDirectory()) {
304017
+ if (!existsSync36(requestedCwd) || !statSync6(requestedCwd).isDirectory()) {
303429
304018
  throw new Error(
303430
304019
  `Web UI project directory does not exist: ${requestedCwd}`
303431
304020
  );
@@ -303436,7 +304025,10 @@ program.command("webui").description("start Orbit as a browser-first local codin
303436
304025
  });
303437
304026
  applyOutcomeExitCode(outcome);
303438
304027
  });
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) => {
304028
+ 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(
304029
+ "--agent-profile <name>",
304030
+ "select a validated Agent Profile for this task"
304031
+ ).option("--resume <session>", "resume a persisted Orbit session").option("--jsonl", "output event logs in JSONL format").action(async (prompt, localOptions, command) => {
303440
304032
  const options = { ...command.optsWithGlobals(), ...localOptions };
303441
304033
  const cwd = process.cwd();
303442
304034
  const overrides = createCliRunOverrides({
@@ -303447,7 +304039,8 @@ program.command("exec").description("run a task in non-interactive mode and stre
303447
304039
  const outcome = await runAgent(cwd, prompt, overrides, false, {
303448
304040
  nonInteractive: true,
303449
304041
  jsonl: !!options.jsonl,
303450
- resumeSessionId: options.resume
304042
+ resumeSessionId: options.resume,
304043
+ agentProfile: options.agentProfile
303451
304044
  });
303452
304045
  applyOutcomeExitCode(outcome);
303453
304046
  });
@@ -303456,7 +304049,7 @@ try {
303456
304049
  } catch (error) {
303457
304050
  const message2 = error instanceof Error ? error.message : String(error);
303458
304051
  console.error(
303459
- picocolors29.red(`\u2716 Orbit command failed: ${redactSecrets(message2)}`)
304052
+ picocolors30.red(`\u2716 Orbit command failed: ${redactSecrets(message2)}`)
303460
304053
  );
303461
304054
  process.exitCode = 1;
303462
304055
  }