@orbit-build/cli 0.9.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.
- package/README.md +9 -0
- package/dist/index.js +1386 -673
- 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
|
|
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 =
|
|
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
|
|
519
|
+
var parse7 = require_parse();
|
|
520
520
|
var enoent = require_enoent();
|
|
521
521
|
function spawn5(command, args, options) {
|
|
522
|
-
const parsed =
|
|
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 =
|
|
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 =
|
|
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) =>
|
|
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
|
|
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
|
-
|
|
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 =
|
|
235107
|
-
relative12 =
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
239189
|
+
import { z as z4 } from "zod";
|
|
239190
239190
|
import { z as z3 } from "zod";
|
|
239191
|
-
import { homedir
|
|
239192
|
-
import {
|
|
239193
|
-
import {
|
|
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
|
|
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
|
|
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 {
|
|
239207
|
-
import {
|
|
239208
|
-
import {
|
|
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
|
|
239211
|
-
import { z as
|
|
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
|
|
239215
|
-
import { resolve as
|
|
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 =
|
|
239259
|
-
var LifecycleHookCommandSchema =
|
|
239260
|
-
command:
|
|
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:
|
|
239263
|
-
timeoutMs:
|
|
239264
|
-
onFailure:
|
|
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 =
|
|
239628
|
+
var LifecycleHooksSchema = z4.object(
|
|
239267
239629
|
Object.fromEntries(
|
|
239268
239630
|
ORBIT_LIFECYCLE_HOOK_EVENTS.map((event) => [
|
|
239269
239631
|
event,
|
|
239270
|
-
|
|
239632
|
+
z4.array(LifecycleHookCommandSchema).max(16).optional()
|
|
239271
239633
|
])
|
|
239272
239634
|
)
|
|
239273
239635
|
).strict();
|
|
239274
|
-
var EnvironmentVariableNameSchema =
|
|
239275
|
-
var HttpHeaderNameSchema =
|
|
239276
|
-
var HttpHeaderValueSchema =
|
|
239277
|
-
var HttpHeadersSchema =
|
|
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 =
|
|
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 =
|
|
239296
|
-
streaming:
|
|
239297
|
-
toolCalls:
|
|
239298
|
-
jsonMode:
|
|
239299
|
-
thinking:
|
|
239300
|
-
vision:
|
|
239301
|
-
promptCaching:
|
|
239302
|
-
maxContextTokens:
|
|
239303
|
-
maxOutputTokens:
|
|
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:
|
|
239306
|
-
outputModalities:
|
|
239307
|
-
apiFormats:
|
|
239308
|
-
reasoningEfforts:
|
|
239309
|
-
parallelToolCalls:
|
|
239310
|
-
modelVersion:
|
|
239311
|
-
effectiveContextWindowPercent:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
239330
|
-
type:
|
|
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:
|
|
239700
|
+
baseUrl: z4.string().url().max(4096).optional(),
|
|
239339
239701
|
apiKeyEnv: EnvironmentVariableNameSchema.optional(),
|
|
239340
|
-
apiKey:
|
|
239702
|
+
apiKey: z4.string().min(1).max(16384).optional(),
|
|
239341
239703
|
apiKeyHeader: HttpHeaderNameSchema.optional(),
|
|
239342
|
-
apiKeyPrefix:
|
|
239704
|
+
apiKeyPrefix: z4.string().max(1024).refine((value) => !/[\r\n]/.test(value)).optional(),
|
|
239343
239705
|
headers: HttpHeadersSchema.optional(),
|
|
239344
|
-
models:
|
|
239345
|
-
requestTimeoutMs:
|
|
239346
|
-
streamTimeoutMs:
|
|
239347
|
-
totalTimeoutMs:
|
|
239348
|
-
maxRetries:
|
|
239349
|
-
disablePreheat:
|
|
239350
|
-
deepSeekApiFormat:
|
|
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 =
|
|
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 =
|
|
239364
|
-
transport:
|
|
239365
|
-
command:
|
|
239366
|
-
args:
|
|
239367
|
-
env:
|
|
239368
|
-
inheritEnv:
|
|
239369
|
-
url:
|
|
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:
|
|
239373
|
-
oauth:
|
|
239374
|
-
mode:
|
|
239375
|
-
tokenUrl:
|
|
239376
|
-
authorizationUrl:
|
|
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:
|
|
239380
|
-
audience:
|
|
239741
|
+
scope: z4.string().max(1e3).optional(),
|
|
239742
|
+
audience: z4.string().max(1e3).optional()
|
|
239381
239743
|
}).optional(),
|
|
239382
|
-
resources:
|
|
239383
|
-
enabled:
|
|
239744
|
+
resources: z4.object({
|
|
239745
|
+
enabled: z4.boolean().default(true)
|
|
239384
239746
|
}).default({ enabled: true }),
|
|
239385
|
-
prompts:
|
|
239386
|
-
enabled:
|
|
239747
|
+
prompts: z4.object({
|
|
239748
|
+
enabled: z4.boolean().default(true)
|
|
239387
239749
|
}).default({ enabled: true }),
|
|
239388
|
-
tools:
|
|
239389
|
-
|
|
239390
|
-
risk:
|
|
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 =
|
|
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 =
|
|
239449
|
-
inputCostPer1M:
|
|
239450
|
-
outputCostPer1M:
|
|
239451
|
-
cacheReadCostPer1M:
|
|
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:
|
|
239455
|
-
effectiveAt:
|
|
239456
|
-
peakHoursUtc:
|
|
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 =
|
|
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 =
|
|
239470
|
-
schemaVersion:
|
|
239471
|
-
name:
|
|
239472
|
-
editor:
|
|
239473
|
-
autoCommit:
|
|
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:
|
|
239476
|
-
trustProjectExecutables:
|
|
239477
|
-
encryptCheckpoints:
|
|
239837
|
+
security: z4.object({
|
|
239838
|
+
trustProjectExecutables: z4.boolean().default(false),
|
|
239839
|
+
encryptCheckpoints: z4.boolean().default(true)
|
|
239478
239840
|
}).default({}),
|
|
239479
|
-
provider:
|
|
239480
|
-
default:
|
|
239481
|
-
embedding:
|
|
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:
|
|
239484
|
-
default:
|
|
239485
|
-
fast:
|
|
239486
|
-
planner:
|
|
239487
|
-
coder:
|
|
239488
|
-
reviewer:
|
|
239489
|
-
summarizer:
|
|
239490
|
-
embedding:
|
|
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:
|
|
239494
|
-
mode:
|
|
239495
|
-
allowRead:
|
|
239496
|
-
requireApprovalForWrite:
|
|
239497
|
-
requireApprovalForBash:
|
|
239498
|
-
blockDangerousCommands:
|
|
239499
|
-
protectSecrets:
|
|
239500
|
-
protectedPaths:
|
|
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:
|
|
239523
|
-
maxFilesToIndex:
|
|
239524
|
-
maxFileSizeKb:
|
|
239525
|
-
autoCodebaseRetrieval:
|
|
239526
|
-
ignore:
|
|
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:
|
|
239548
|
-
compactThreshold:
|
|
239549
|
-
autoRepair:
|
|
239550
|
-
maxRepairAttempts:
|
|
239551
|
-
testCommands:
|
|
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:
|
|
239554
|
-
maxIterations:
|
|
239555
|
-
fastMaxOutputTokens:
|
|
239556
|
-
maxOutputTokens:
|
|
239557
|
-
teamPreset:
|
|
239558
|
-
maxReviewAttempts:
|
|
239559
|
-
maxReviewConcurrency:
|
|
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
|
-
|
|
239562
|
-
|
|
239563
|
-
|
|
239564
|
-
|
|
239565
|
-
|
|
239566
|
-
|
|
239567
|
-
|
|
239568
|
-
|
|
239569
|
-
|
|
239570
|
-
|
|
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:
|
|
239574
|
-
mouse:
|
|
239575
|
-
scrollSpeed:
|
|
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:
|
|
239578
|
-
bash:
|
|
239579
|
-
enabled:
|
|
239580
|
-
timeoutMs:
|
|
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:
|
|
239583
|
-
maxConcurrentTasks:
|
|
239584
|
-
maxRetainedTasks:
|
|
239585
|
-
maxOutputBytes:
|
|
239586
|
-
terminateGraceMs:
|
|
239587
|
-
awaitOnCompletion:
|
|
239588
|
-
completionWaitMs:
|
|
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:
|
|
239594
|
-
enabled:
|
|
239595
|
-
provider:
|
|
239596
|
-
searxngUrls:
|
|
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:
|
|
239599
|
-
timeoutMs:
|
|
239600
|
-
maxResults:
|
|
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:
|
|
239603
|
-
enabled:
|
|
239965
|
+
mcp: z4.object({
|
|
239966
|
+
enabled: z4.boolean().default(false)
|
|
239604
239967
|
}).default({})
|
|
239605
239968
|
}).default({}),
|
|
239606
|
-
skills:
|
|
239607
|
-
enabled:
|
|
239608
|
-
directories:
|
|
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:
|
|
239616
|
-
maxActive:
|
|
239617
|
-
disabled:
|
|
239618
|
-
maxSkillBytes:
|
|
239619
|
-
maxAutoSkillBytes:
|
|
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:
|
|
239623
|
-
allowedProviders:
|
|
239624
|
-
allowedModels:
|
|
239625
|
-
minimumPermissionMode:
|
|
239626
|
-
requireWriteApproval:
|
|
239627
|
-
requireBashApproval:
|
|
239628
|
-
disableWebSearch:
|
|
239629
|
-
disableMcp:
|
|
239630
|
-
maxIterations:
|
|
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:
|
|
239995
|
+
hooks: z4.object({
|
|
239633
239996
|
/** @deprecated Use lifecycle.preToolUse with a write-tool matcher. */
|
|
239634
|
-
preEdit:
|
|
239997
|
+
preEdit: z4.string().max(2e4).optional(),
|
|
239635
239998
|
/** @deprecated Use lifecycle.postToolUse with a write-tool matcher. */
|
|
239636
|
-
postEdit:
|
|
239999
|
+
postEdit: z4.string().max(2e4).optional(),
|
|
239637
240000
|
lifecycle: LifecycleHooksSchema.optional()
|
|
239638
240001
|
}).strict().default({}),
|
|
239639
240002
|
pricing: PricingTableSchema.default({}),
|
|
239640
|
-
budgetLimit:
|
|
239641
|
-
session:
|
|
239642
|
-
store:
|
|
239643
|
-
path:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
240042
|
-
var SecretsFileSchema =
|
|
240043
|
-
var EncryptedSecretSchema =
|
|
240044
|
-
iv:
|
|
240045
|
-
encrypted:
|
|
240046
|
-
tag:
|
|
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 ??
|
|
240064
|
-
this.secretsPath =
|
|
240065
|
-
this.masterKeyPath =
|
|
240066
|
-
this.mutationLockPath =
|
|
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 =
|
|
240212
|
-
pid:
|
|
240213
|
-
createdAt:
|
|
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 =
|
|
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 =
|
|
240784
|
+
var ProviderProfileSchema = z7.object({
|
|
240411
240785
|
id: ProviderProfileIdSchema,
|
|
240412
|
-
name:
|
|
240786
|
+
name: z7.string().trim().min(1).max(120),
|
|
240413
240787
|
config: ProviderConfigSchema.omit({ apiKey: true }),
|
|
240414
|
-
createdAt:
|
|
240415
|
-
updatedAt:
|
|
240788
|
+
createdAt: z7.string().datetime(),
|
|
240789
|
+
updatedAt: z7.string().datetime()
|
|
240416
240790
|
});
|
|
240417
|
-
var ProviderProfilesFileSchema =
|
|
240418
|
-
version:
|
|
240791
|
+
var ProviderProfilesFileSchema = z7.object({
|
|
240792
|
+
version: z7.literal(1).default(1),
|
|
240419
240793
|
activeProvider: ProviderProfileIdSchema.optional(),
|
|
240420
|
-
profiles:
|
|
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 ??
|
|
240432
|
-
this.profilePath =
|
|
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 =
|
|
240680
|
-
var ContributionNameSchema =
|
|
240681
|
-
var CredentialEnvironmentNameSchema =
|
|
240682
|
-
var RelativeContributionPathSchema =
|
|
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 =
|
|
240917
|
+
var NamedContributionSchema = z8.object({
|
|
240687
240918
|
name: ContributionNameSchema,
|
|
240688
240919
|
path: RelativeContributionPathSchema,
|
|
240689
|
-
description:
|
|
240920
|
+
description: z8.string().trim().min(1).max(500).optional()
|
|
240690
240921
|
});
|
|
240691
|
-
var ExtensionPermissionSchema =
|
|
240692
|
-
filesystem:
|
|
240693
|
-
|
|
240694
|
-
mode:
|
|
240695
|
-
scope: RelativeContributionPathSchema.or(
|
|
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:
|
|
240699
|
-
|
|
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:
|
|
240705
|
-
credentials:
|
|
240935
|
+
process: z8.boolean().default(false),
|
|
240936
|
+
credentials: z8.array(CredentialEnvironmentNameSchema).max(64).default([])
|
|
240706
240937
|
});
|
|
240707
|
-
var OrbitExtensionManifestSchema =
|
|
240708
|
-
schemaVersion:
|
|
240709
|
-
id:
|
|
240710
|
-
displayName:
|
|
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:
|
|
240713
|
-
orbit:
|
|
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:
|
|
240719
|
-
commands:
|
|
240720
|
-
skills:
|
|
240721
|
-
agents:
|
|
240722
|
-
tools:
|
|
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:
|
|
240955
|
+
risk: z8.enum(["read", "write", "execute", "dangerous", "network"])
|
|
240725
240956
|
})
|
|
240726
240957
|
).max(200).default([]),
|
|
240727
|
-
hooks:
|
|
240728
|
-
|
|
240729
|
-
event:
|
|
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:
|
|
240973
|
+
command: z8.string().trim().min(1).max(4e3)
|
|
240743
240974
|
})
|
|
240744
240975
|
).max(100).default([]),
|
|
240745
|
-
mcpServers:
|
|
240746
|
-
templates:
|
|
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 =
|
|
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 =
|
|
240767
|
-
var InstalledExtensionSchema =
|
|
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:
|
|
241000
|
+
digest: z9.string().regex(/^[a-f0-9]{64}$/),
|
|
240770
241001
|
digestAlgorithm: ExtensionDigestAlgorithmSchema.default("sha256-v1"),
|
|
240771
|
-
trusted:
|
|
240772
|
-
path:
|
|
240773
|
-
manifestFile:
|
|
241002
|
+
trusted: z9.boolean(),
|
|
241003
|
+
path: z9.string(),
|
|
241004
|
+
manifestFile: z9.string().min(1).max(4096).default("extension.yaml")
|
|
240774
241005
|
});
|
|
240775
|
-
var ExtensionRegistrySchema =
|
|
240776
|
-
schemaVersion:
|
|
240777
|
-
extensions:
|
|
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 =
|
|
240781
|
-
if (!
|
|
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 =
|
|
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 =
|
|
240800
|
-
if (root !==
|
|
241030
|
+
const root = resolve22(extension.path);
|
|
241031
|
+
if (root !== resolve22(extensionsRoot, extension.id)) continue;
|
|
240801
241032
|
try {
|
|
240802
|
-
if (!
|
|
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
|
|
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 =
|
|
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 ??
|
|
241389
|
+
const homeDirectory = options.homeDir ?? homedir4();
|
|
241137
241390
|
const env = options.env ?? process.env;
|
|
241138
|
-
const globalConfigPath =
|
|
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 =
|
|
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:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 ?
|
|
241233
|
-
if (
|
|
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:
|
|
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
|
|
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 =
|
|
243311
|
-
var ProviderCollectionIndexSchema =
|
|
243312
|
-
var AnthropicUsageSchema =
|
|
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 =
|
|
243319
|
-
message:
|
|
243320
|
-
type:
|
|
243571
|
+
var AnthropicErrorSchema = z10.object({
|
|
243572
|
+
message: z10.string(),
|
|
243573
|
+
type: z10.string().optional()
|
|
243321
243574
|
}).passthrough();
|
|
243322
|
-
var AnthropicContentBlockSchema =
|
|
243323
|
-
|
|
243324
|
-
type:
|
|
243325
|
-
text:
|
|
243575
|
+
var AnthropicContentBlockSchema = z10.discriminatedUnion("type", [
|
|
243576
|
+
z10.object({
|
|
243577
|
+
type: z10.literal("text"),
|
|
243578
|
+
text: z10.string()
|
|
243326
243579
|
}).passthrough(),
|
|
243327
|
-
|
|
243328
|
-
type:
|
|
243329
|
-
thinking:
|
|
243330
|
-
signature:
|
|
243580
|
+
z10.object({
|
|
243581
|
+
type: z10.literal("thinking"),
|
|
243582
|
+
thinking: z10.string(),
|
|
243583
|
+
signature: z10.string().optional()
|
|
243331
243584
|
}).passthrough(),
|
|
243332
|
-
|
|
243333
|
-
type:
|
|
243334
|
-
id:
|
|
243335
|
-
name:
|
|
243336
|
-
input:
|
|
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 =
|
|
243340
|
-
id:
|
|
243341
|
-
model:
|
|
243342
|
-
content:
|
|
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:
|
|
243597
|
+
stop_reason: z10.string().nullable().optional()
|
|
243345
243598
|
}).passthrough();
|
|
243346
|
-
var AnthropicStreamEventSchema =
|
|
243347
|
-
type:
|
|
243599
|
+
var AnthropicStreamEventSchema = z10.object({
|
|
243600
|
+
type: z10.string(),
|
|
243348
243601
|
index: ProviderCollectionIndexSchema.optional(),
|
|
243349
|
-
message:
|
|
243350
|
-
id:
|
|
243351
|
-
model:
|
|
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:
|
|
243356
|
-
type:
|
|
243357
|
-
text:
|
|
243358
|
-
thinking:
|
|
243359
|
-
signature:
|
|
243360
|
-
partial_json:
|
|
243361
|
-
stop_reason:
|
|
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()
|
|
@@ -243792,7 +244045,13 @@ var AnthropicCompatibleProvider = class {
|
|
|
243792
244045
|
signal: chatSignal,
|
|
243793
244046
|
timeout: this.options.requestTimeoutMs
|
|
243794
244047
|
},
|
|
243795
|
-
|
|
244048
|
+
Math.max(
|
|
244049
|
+
0,
|
|
244050
|
+
Math.min(
|
|
244051
|
+
5,
|
|
244052
|
+
input.retryBudget ?? this.options.maxRetries ?? (this.isOfficialDeepSeekEndpoint() ? 0 : 2)
|
|
244053
|
+
)
|
|
244054
|
+
)
|
|
243796
244055
|
);
|
|
243797
244056
|
} catch (error) {
|
|
243798
244057
|
const sanitized = sanitizeProviderError(error, [key]);
|
|
@@ -244839,7 +245098,10 @@ async function* chatWithDeepSeekResponses(input, options) {
|
|
|
244839
245098
|
signal: controller.signal,
|
|
244840
245099
|
timeout: options.runtime.requestTimeoutMs
|
|
244841
245100
|
},
|
|
244842
|
-
|
|
245101
|
+
Math.max(
|
|
245102
|
+
0,
|
|
245103
|
+
Math.min(5, input.retryBudget ?? options.runtime.maxRetries ?? 0)
|
|
245104
|
+
)
|
|
244843
245105
|
);
|
|
244844
245106
|
if (!response.ok) {
|
|
244845
245107
|
const detail = await readProviderErrorText(response);
|
|
@@ -245534,7 +245796,13 @@ ${jsonInstruction}`;
|
|
|
245534
245796
|
signal: chatSignal,
|
|
245535
245797
|
timeout: this.options.requestTimeoutMs
|
|
245536
245798
|
},
|
|
245537
|
-
|
|
245799
|
+
Math.max(
|
|
245800
|
+
0,
|
|
245801
|
+
Math.min(
|
|
245802
|
+
5,
|
|
245803
|
+
input.retryBudget ?? this.options.maxRetries ?? (isOfficialDeepSeek ? 0 : 2)
|
|
245804
|
+
)
|
|
245805
|
+
)
|
|
245538
245806
|
);
|
|
245539
245807
|
} catch (error) {
|
|
245540
245808
|
const sanitized = sanitizeProviderError(error, [key]);
|
|
@@ -246207,19 +246475,19 @@ function normalizeOllamaOpenAiBaseUrl(baseUrl) {
|
|
|
246207
246475
|
}
|
|
246208
246476
|
|
|
246209
246477
|
// src/runtime/CacheDiagnostics.ts
|
|
246210
|
-
import { existsSync as existsSync13, readdirSync as
|
|
246478
|
+
import { existsSync as existsSync13, readdirSync as readdirSync6 } from "fs";
|
|
246211
246479
|
import { join as join11 } from "path";
|
|
246212
246480
|
import picocolors4 from "picocolors";
|
|
246213
246481
|
|
|
246214
246482
|
// ../core/dist/index.js
|
|
246215
|
-
import { existsSync as existsSync12, readdirSync as
|
|
246483
|
+
import { existsSync as existsSync12, readdirSync as readdirSync5 } from "fs";
|
|
246216
246484
|
import { createHash as createHash7 } from "crypto";
|
|
246217
246485
|
import { join as join10 } from "path";
|
|
246218
246486
|
import { z as z31 } from "zod";
|
|
246219
246487
|
import { z as z211 } from "zod";
|
|
246220
246488
|
|
|
246221
246489
|
// ../tools/dist/index.js
|
|
246222
|
-
import { z as
|
|
246490
|
+
import { z as z11 } from "zod";
|
|
246223
246491
|
import { z as z24 } from "zod";
|
|
246224
246492
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
246225
246493
|
import {
|
|
@@ -246232,10 +246500,10 @@ import {
|
|
|
246232
246500
|
unlinkSync as unlinkSync2,
|
|
246233
246501
|
writeFileSync as writeFileSync3
|
|
246234
246502
|
} from "fs";
|
|
246235
|
-
import { dirname as dirname4, isAbsolute as
|
|
246503
|
+
import { dirname as dirname4, isAbsolute as isAbsolute3, join as join6, resolve as resolve4 } from "path";
|
|
246236
246504
|
import { isAbsolute as isAbsolute22, resolve as resolve23 } from "path";
|
|
246237
246505
|
import { z as z34 } from "zod";
|
|
246238
|
-
import { isAbsolute as
|
|
246506
|
+
import { isAbsolute as isAbsolute32, relative as relative4, win32 } from "path";
|
|
246239
246507
|
import glob from "fast-glob";
|
|
246240
246508
|
import { existsSync as existsSync23 } from "fs";
|
|
246241
246509
|
import { z as z42 } from "zod";
|
|
@@ -247833,12 +248101,12 @@ import { z as z52 } from "zod";
|
|
|
247833
248101
|
import { z as z62 } from "zod";
|
|
247834
248102
|
import { z as z72 } from "zod";
|
|
247835
248103
|
import { createHash as createHash3 } from "crypto";
|
|
247836
|
-
import { existsSync as
|
|
248104
|
+
import { existsSync as existsSync33 } from "fs";
|
|
247837
248105
|
import { z as z82 } from "zod";
|
|
247838
248106
|
import { z as z92 } from "zod";
|
|
247839
248107
|
import { z as z102 } from "zod";
|
|
247840
248108
|
import { relative as relative22 } from "path";
|
|
247841
|
-
import { z as
|
|
248109
|
+
import { z as z112 } from "zod";
|
|
247842
248110
|
import { z as z12 } from "zod";
|
|
247843
248111
|
import { existsSync as existsSync42 } from "fs";
|
|
247844
248112
|
import { join as join23 } from "path";
|
|
@@ -247854,7 +248122,7 @@ import { existsSync as existsSync7 } from "fs";
|
|
|
247854
248122
|
import { win32 as win322 } from "path";
|
|
247855
248123
|
import { z as z18 } from "zod";
|
|
247856
248124
|
import { existsSync as existsSync8 } from "fs";
|
|
247857
|
-
import { join as join32, resolve as
|
|
248125
|
+
import { join as join32, resolve as resolve33 } from "path";
|
|
247858
248126
|
import { z as z20 } from "zod";
|
|
247859
248127
|
var import_ipaddr = __toESM(require_ipaddr(), 1);
|
|
247860
248128
|
import { lookup } from "dns/promises";
|
|
@@ -247866,10 +248134,10 @@ import { z as z21 } from "zod";
|
|
|
247866
248134
|
import { z as z222 } from "zod";
|
|
247867
248135
|
import { execFile, spawn } from "child_process";
|
|
247868
248136
|
import { randomUUID as randomUUID22 } from "crypto";
|
|
247869
|
-
var ToolRegistrationSchema =
|
|
247870
|
-
name:
|
|
247871
|
-
description:
|
|
247872
|
-
risk:
|
|
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"])
|
|
247873
248141
|
});
|
|
247874
248142
|
var ToolRegistry = class {
|
|
247875
248143
|
tools = /* @__PURE__ */ new Map();
|
|
@@ -247904,14 +248172,14 @@ var MAX_TOOL_FILE_BYTES = 16 * 1024 * 1024;
|
|
|
247904
248172
|
var MAX_GREP_FALLBACK_FILE_BYTES = 2 * 1024 * 1024;
|
|
247905
248173
|
function atomicWriteToolFile(cwd, requestedPath, content, expectedCurrentContent, options = {}) {
|
|
247906
248174
|
const resolveRequestedPath = () => options.allowOutsideWorkspace ? normalizePath(
|
|
247907
|
-
|
|
248175
|
+
isAbsolute3(requestedPath) ? resolve4(requestedPath) : resolve4(cwd, requestedPath)
|
|
247908
248176
|
) : resolveSafePath(cwd, requestedPath);
|
|
247909
248177
|
let safePath = resolveRequestedPath();
|
|
247910
248178
|
const parent = dirname4(safePath);
|
|
247911
248179
|
mkdirSync2(parent, { recursive: true });
|
|
247912
248180
|
safePath = resolveRequestedPath();
|
|
247913
248181
|
assertExpectedContent(safePath, expectedCurrentContent);
|
|
247914
|
-
const temporaryPath =
|
|
248182
|
+
const temporaryPath = join6(parent, `.orbit-write-${randomUUID3()}.tmp`);
|
|
247915
248183
|
let descriptor;
|
|
247916
248184
|
try {
|
|
247917
248185
|
descriptor = openSync3(temporaryPath, "wx", 384);
|
|
@@ -248584,7 +248852,7 @@ var IGNORED_DIRECTORIES = [
|
|
|
248584
248852
|
function isWorkspaceRelativeGlob(pattern) {
|
|
248585
248853
|
const candidate = pattern.startsWith("!") ? pattern.slice(1) : pattern;
|
|
248586
248854
|
const normalized = candidate.replace(/\\/g, "/");
|
|
248587
|
-
return candidate.length > 0 && !
|
|
248855
|
+
return candidate.length > 0 && !isAbsolute32(candidate) && !win32.isAbsolute(candidate) && !normalized.includes("..");
|
|
248588
248856
|
}
|
|
248589
248857
|
async function findWorkspaceFiles(root, pattern, options = {}) {
|
|
248590
248858
|
if (!isWorkspaceRelativeGlob(pattern)) {
|
|
@@ -249012,7 +249280,7 @@ var WriteFileTool = class {
|
|
|
249012
249280
|
if (!fullHostAccess) throw error;
|
|
249013
249281
|
currentContentKnown = false;
|
|
249014
249282
|
}
|
|
249015
|
-
const fileExists = currentContentKnown ? current !== void 0 :
|
|
249283
|
+
const fileExists = currentContentKnown ? current !== void 0 : existsSync33(safePath);
|
|
249016
249284
|
if (input.intent === "create" && fileExists) {
|
|
249017
249285
|
return { ok: false, error: `File already exists: ${input.path}` };
|
|
249018
249286
|
}
|
|
@@ -249169,7 +249437,7 @@ var GitRestoreTool = class {
|
|
|
249169
249437
|
}
|
|
249170
249438
|
}
|
|
249171
249439
|
};
|
|
249172
|
-
var GitStatusInputSchema =
|
|
249440
|
+
var GitStatusInputSchema = z112.object({});
|
|
249173
249441
|
var GitStatusTool = class {
|
|
249174
249442
|
name = "git_status";
|
|
249175
249443
|
description = "Show working tree status of git files (short format).";
|
|
@@ -249869,11 +250137,11 @@ function detectTrustedTerminalSuccess(command, cwd, output, exitCode) {
|
|
|
249869
250137
|
);
|
|
249870
250138
|
const script = match?.[1] || match?.[2] || match?.[3];
|
|
249871
250139
|
if (!script) return void 0;
|
|
249872
|
-
const actual = comparablePath(
|
|
250140
|
+
const actual = comparablePath(resolve33(cwd, script));
|
|
249873
250141
|
const expected = [
|
|
249874
|
-
|
|
250142
|
+
resolve33(cwd, ".cumcm", "finalize.py"),
|
|
249875
250143
|
// Read compatibility for projects scaffolded by Orbit <= 0.8.3.
|
|
249876
|
-
|
|
250144
|
+
resolve33(cwd, "code", "finalize.py")
|
|
249877
250145
|
].map(comparablePath);
|
|
249878
250146
|
return expected.includes(actual) ? "cumcm-finalizer" : void 0;
|
|
249879
250147
|
}
|
|
@@ -251821,14 +252089,14 @@ function errorMessage(error) {
|
|
|
251821
252089
|
}
|
|
251822
252090
|
|
|
251823
252091
|
// ../context-engine/dist/index.js
|
|
251824
|
-
import { join as
|
|
252092
|
+
import { join as join62 } from "path";
|
|
251825
252093
|
import { existsSync as existsSync9 } from "fs";
|
|
251826
252094
|
import { pathToFileURL } from "url";
|
|
251827
252095
|
import { z as z25 } from "zod";
|
|
251828
252096
|
import { basename, join as join7 } from "path";
|
|
251829
252097
|
import { existsSync as existsSync43, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3, renameSync as renameSync3, rmSync as rmSync2 } from "fs";
|
|
251830
252098
|
import { promises as fsPromises3 } from "fs";
|
|
251831
|
-
import { join as join24, dirname as dirname32, isAbsolute as isAbsolute4, resolve as
|
|
252099
|
+
import { join as join24, dirname as dirname32, isAbsolute as isAbsolute4, resolve as resolve34 } from "path";
|
|
251832
252100
|
import { createHash as createHash4, randomUUID as randomUUID32 } from "crypto";
|
|
251833
252101
|
import { execFile as execFile2 } from "child_process";
|
|
251834
252102
|
import glob3 from "fast-glob";
|
|
@@ -251838,7 +252106,7 @@ import { existsSync as existsSync24, promises as fsPromises2 } from "fs";
|
|
|
251838
252106
|
import { dirname as dirname5, resolve as resolve5 } from "path";
|
|
251839
252107
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
251840
252108
|
import { z as z26 } from "zod";
|
|
251841
|
-
import { existsSync as
|
|
252109
|
+
import { existsSync as existsSync34, promises as fsPromises22 } from "fs";
|
|
251842
252110
|
import { dirname as dirname22, resolve as resolve24 } from "path";
|
|
251843
252111
|
import { randomUUID as randomUUID23 } from "crypto";
|
|
251844
252112
|
import { z as z35 } from "zod";
|
|
@@ -251847,7 +252115,7 @@ import { extname as extname22 } from "path";
|
|
|
251847
252115
|
import { resolve as resolve42 } from "path";
|
|
251848
252116
|
import { dirname as dirname52 } from "path";
|
|
251849
252117
|
import { isAbsolute as isAbsolute23, join as join33, resolve as resolve52 } from "path";
|
|
251850
|
-
import { homedir as
|
|
252118
|
+
import { homedir as homedir5 } from "os";
|
|
251851
252119
|
import { existsSync as existsSync53, promises as fs2 } from "fs";
|
|
251852
252120
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
251853
252121
|
import { parse as parseYaml3 } from "yaml";
|
|
@@ -251856,7 +252124,7 @@ import { dirname as dirname42, join as join42 } from "path";
|
|
|
251856
252124
|
import { parse as parseYaml22 } from "yaml";
|
|
251857
252125
|
import { z as z63 } from "zod";
|
|
251858
252126
|
import { existsSync as existsSync62, lstatSync as lstatSync3, promises as fs22 } from "fs";
|
|
251859
|
-
import { dirname as dirname6, isAbsolute as
|
|
252127
|
+
import { dirname as dirname6, isAbsolute as isAbsolute33, join as join52, win32 as win323 } from "path";
|
|
251860
252128
|
import { parse as parseYaml32 } from "yaml";
|
|
251861
252129
|
var ProjectIndexer = class {
|
|
251862
252130
|
constructor(cwd) {
|
|
@@ -252189,6 +252457,7 @@ var JSVectorStore = class {
|
|
|
252189
252457
|
loaded = false;
|
|
252190
252458
|
loading = null;
|
|
252191
252459
|
cacheState = "uninitialized";
|
|
252460
|
+
persistenceError;
|
|
252192
252461
|
async addDocuments(docs, persist = true) {
|
|
252193
252462
|
if (!this.loaded) {
|
|
252194
252463
|
await this.load();
|
|
@@ -252295,7 +252564,13 @@ var JSVectorStore = class {
|
|
|
252295
252564
|
await fsPromises2.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
252296
252565
|
}
|
|
252297
252566
|
this.cacheState = "valid";
|
|
252298
|
-
|
|
252567
|
+
this.persistenceError = void 0;
|
|
252568
|
+
} catch (error) {
|
|
252569
|
+
this.cacheState = "invalid";
|
|
252570
|
+
this.persistenceError = error instanceof Error ? error.message : String(error);
|
|
252571
|
+
throw new Error(
|
|
252572
|
+
`Failed to persist the Orbit vector cache: ${this.persistenceError}`
|
|
252573
|
+
);
|
|
252299
252574
|
}
|
|
252300
252575
|
}
|
|
252301
252576
|
async load() {
|
|
@@ -252371,6 +252646,10 @@ var JSVectorStore = class {
|
|
|
252371
252646
|
hasValidCache() {
|
|
252372
252647
|
return this.cacheState === "valid";
|
|
252373
252648
|
}
|
|
252649
|
+
/** Returns the last persistence failure without exposing filesystem details. */
|
|
252650
|
+
getPersistenceError() {
|
|
252651
|
+
return this.persistenceError;
|
|
252652
|
+
}
|
|
252374
252653
|
initializeCachePath() {
|
|
252375
252654
|
if (this.cachePathInitialized) return;
|
|
252376
252655
|
this.dbPath = getOrbitCachePath(this.cwd, "vector_store.json");
|
|
@@ -252583,7 +252862,7 @@ var BM25Store = class {
|
|
|
252583
252862
|
this.initializeCachePath();
|
|
252584
252863
|
try {
|
|
252585
252864
|
const parentDir = dirname22(this.dbPath);
|
|
252586
|
-
if (!
|
|
252865
|
+
if (!existsSync34(parentDir)) {
|
|
252587
252866
|
await fsPromises22.mkdir(parentDir, { recursive: true });
|
|
252588
252867
|
}
|
|
252589
252868
|
const data = {
|
|
@@ -252618,7 +252897,7 @@ var BM25Store = class {
|
|
|
252618
252897
|
}
|
|
252619
252898
|
async loadFromDisk() {
|
|
252620
252899
|
this.initializeCachePath();
|
|
252621
|
-
if (!
|
|
252900
|
+
if (!existsSync34(this.dbPath)) {
|
|
252622
252901
|
this.docs = createRecord();
|
|
252623
252902
|
this.df = createRecord();
|
|
252624
252903
|
this.avgdl = 0;
|
|
@@ -252665,7 +252944,7 @@ var BM25Store = class {
|
|
|
252665
252944
|
this.avgdl = 0;
|
|
252666
252945
|
this.loaded = true;
|
|
252667
252946
|
this.cacheState = "missing";
|
|
252668
|
-
if (
|
|
252947
|
+
if (existsSync34(this.dbPath)) {
|
|
252669
252948
|
try {
|
|
252670
252949
|
await fsPromises22.unlink(this.dbPath);
|
|
252671
252950
|
} catch {
|
|
@@ -253084,7 +253363,7 @@ function embeddingBatches(texts) {
|
|
|
253084
253363
|
return batches;
|
|
253085
253364
|
}
|
|
253086
253365
|
function workspaceIndexKey(cwd) {
|
|
253087
|
-
const absolute =
|
|
253366
|
+
const absolute = resolve34(cwd).replace(/\\/g, "/");
|
|
253088
253367
|
return process.platform === "win32" ? absolute.toLowerCase() : absolute;
|
|
253089
253368
|
}
|
|
253090
253369
|
function resolveConfiguredApiKey(provider) {
|
|
@@ -253289,7 +253568,7 @@ function getEmbeddingProvider(config) {
|
|
|
253289
253568
|
var SymbolIndexer = class {
|
|
253290
253569
|
constructor(cwd) {
|
|
253291
253570
|
this.cwd = cwd;
|
|
253292
|
-
this.indexPath =
|
|
253571
|
+
this.indexPath = resolve34(cwd, ".orbit", "symbols.json");
|
|
253293
253572
|
}
|
|
253294
253573
|
cwd;
|
|
253295
253574
|
indexPath;
|
|
@@ -253311,9 +253590,9 @@ var SymbolIndexer = class {
|
|
|
253311
253590
|
async performIndex() {
|
|
253312
253591
|
try {
|
|
253313
253592
|
this.initializeIndexPath();
|
|
253314
|
-
const normCwd =
|
|
253593
|
+
const normCwd = resolve34(this.cwd).toLowerCase().replace(/\\/g, "/");
|
|
253315
253594
|
const { homedir: homedir22 } = await import("os");
|
|
253316
|
-
const normHome =
|
|
253595
|
+
const normHome = resolve34(homedir22()).toLowerCase().replace(/\\/g, "/");
|
|
253317
253596
|
if (normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname32(normCwd) === normCwd) {
|
|
253318
253597
|
return;
|
|
253319
253598
|
}
|
|
@@ -254144,9 +254423,9 @@ function resolveSkillDirectory(cwd, directory) {
|
|
|
254144
254423
|
if (directory === "@orbit/builtin-skills") {
|
|
254145
254424
|
return resolveBundledSkillsDirectory();
|
|
254146
254425
|
}
|
|
254147
|
-
if (directory === "~") return
|
|
254426
|
+
if (directory === "~") return homedir5();
|
|
254148
254427
|
if (directory.startsWith("~/") || directory.startsWith("~\\")) {
|
|
254149
|
-
return resolve52(
|
|
254428
|
+
return resolve52(homedir5(), directory.slice(2));
|
|
254150
254429
|
}
|
|
254151
254430
|
return isAbsolute23(directory) ? resolve52(directory) : resolve52(cwd, directory);
|
|
254152
254431
|
}
|
|
@@ -254702,7 +254981,7 @@ function validateReference(skill, reference, diagnostics) {
|
|
|
254702
254981
|
return;
|
|
254703
254982
|
}
|
|
254704
254983
|
if (!relativePath) return;
|
|
254705
|
-
if (
|
|
254984
|
+
if (isAbsolute33(relativePath) || win323.isAbsolute(relativePath)) {
|
|
254706
254985
|
diagnostics.push(
|
|
254707
254986
|
diagnostic(
|
|
254708
254987
|
skill.path,
|
|
@@ -254816,7 +255095,11 @@ var ContextPackBuilder = class {
|
|
|
254816
255095
|
const projectIndexPromise = this.indexer.index();
|
|
254817
255096
|
const projectInstructionsPromise = this.loadInstructions();
|
|
254818
255097
|
const config = ConfigLoader.loadSync(this.cwd);
|
|
254819
|
-
const skillsPromise = this.loadSkills(
|
|
255098
|
+
const skillsPromise = this.loadSkills(
|
|
255099
|
+
config,
|
|
255100
|
+
userQuery,
|
|
255101
|
+
options.forcedSkills
|
|
255102
|
+
);
|
|
254820
255103
|
let codebaseContextPromise = Promise.resolve(void 0);
|
|
254821
255104
|
const retrievalMode = selectCodebaseRetrievalMode(
|
|
254822
255105
|
userQuery,
|
|
@@ -254995,7 +255278,7 @@ var ContextPackBuilder = class {
|
|
|
254995
255278
|
"README.md"
|
|
254996
255279
|
];
|
|
254997
255280
|
for (const name of candidates) {
|
|
254998
|
-
const p =
|
|
255281
|
+
const p = join62(this.cwd, ...name.split("/"));
|
|
254999
255282
|
try {
|
|
255000
255283
|
const content = readBoundedRegularFile(
|
|
255001
255284
|
p,
|
|
@@ -255007,7 +255290,7 @@ var ContextPackBuilder = class {
|
|
|
255007
255290
|
}
|
|
255008
255291
|
return "";
|
|
255009
255292
|
}
|
|
255010
|
-
async loadSkills(config, userQuery) {
|
|
255293
|
+
async loadSkills(config, userQuery, forcedSkills = []) {
|
|
255011
255294
|
const skillsConfig = config.skills;
|
|
255012
255295
|
if (skillsConfig.enabled === false) {
|
|
255013
255296
|
return { index: [], active: [], diagnostics: [] };
|
|
@@ -255032,11 +255315,12 @@ var ContextPackBuilder = class {
|
|
|
255032
255315
|
};
|
|
255033
255316
|
}
|
|
255034
255317
|
const { skills, diagnostics } = this.skillsCache;
|
|
255318
|
+
const forcedQuery = forcedSkills.length ? `${userQuery || ""} ${forcedSkills.map((name) => `$${name}`).join(" ")}` : userQuery;
|
|
255035
255319
|
return {
|
|
255036
255320
|
// The always-in-context index advertises only enabled skills, and only
|
|
255037
255321
|
// the fields the prompt renders — not byte accounting or UI metadata.
|
|
255038
255322
|
index: skills.filter((skill) => !skill.disabled).map(({ name, description, path: path9 }) => ({ name, description, path: path9 })),
|
|
255039
|
-
active: selectSkills(skills,
|
|
255323
|
+
active: selectSkills(skills, forcedQuery, skillsConfig),
|
|
255040
255324
|
diagnostics
|
|
255041
255325
|
};
|
|
255042
255326
|
}
|
|
@@ -255613,7 +255897,7 @@ var MCPClient = class {
|
|
|
255613
255897
|
child.on("error", (error) => {
|
|
255614
255898
|
this.cleanup(
|
|
255615
255899
|
new Error(
|
|
255616
|
-
`MCP server "${this.serverName}" failed to start: ${
|
|
255900
|
+
`MCP server "${this.serverName}" failed to start: ${safeMessage2(error)}`
|
|
255617
255901
|
)
|
|
255618
255902
|
);
|
|
255619
255903
|
});
|
|
@@ -255636,7 +255920,7 @@ var MCPClient = class {
|
|
|
255636
255920
|
if (this.child !== child) return;
|
|
255637
255921
|
this.cleanup(
|
|
255638
255922
|
new Error(
|
|
255639
|
-
`MCP server "${this.serverName}" stdin failed: ${
|
|
255923
|
+
`MCP server "${this.serverName}" stdin failed: ${safeMessage2(error)}`
|
|
255640
255924
|
)
|
|
255641
255925
|
);
|
|
255642
255926
|
});
|
|
@@ -255919,7 +256203,7 @@ var MCPClient = class {
|
|
|
255919
256203
|
this.pendingRequests.delete(id);
|
|
255920
256204
|
pending.removeAbortListener?.();
|
|
255921
256205
|
pending.reject(
|
|
255922
|
-
new Error(`Unable to write MCP request: ${
|
|
256206
|
+
new Error(`Unable to write MCP request: ${safeMessage2(error)}`)
|
|
255923
256207
|
);
|
|
255924
256208
|
}
|
|
255925
256209
|
);
|
|
@@ -255985,7 +256269,7 @@ var MCPClient = class {
|
|
|
255985
256269
|
pending.reject(
|
|
255986
256270
|
new McpJsonRpcError(
|
|
255987
256271
|
response.error.code,
|
|
255988
|
-
|
|
256272
|
+
safeMessage2(response.error.message),
|
|
255989
256273
|
"data" in response.error ? response.error.data : void 0
|
|
255990
256274
|
)
|
|
255991
256275
|
);
|
|
@@ -255995,7 +256279,7 @@ var MCPClient = class {
|
|
|
255995
256279
|
}
|
|
255996
256280
|
cleanup(error) {
|
|
255997
256281
|
this.isConnected = false;
|
|
255998
|
-
this.lastError =
|
|
256282
|
+
this.lastError = safeMessage2(error);
|
|
255999
256283
|
for (const pending of this.pendingRequests.values()) {
|
|
256000
256284
|
clearTimeout(pending.timeout);
|
|
256001
256285
|
pending.removeAbortListener?.();
|
|
@@ -256050,7 +256334,7 @@ function assertSupportedProtocolVersion(initializeResult) {
|
|
|
256050
256334
|
);
|
|
256051
256335
|
}
|
|
256052
256336
|
}
|
|
256053
|
-
function
|
|
256337
|
+
function safeMessage2(error) {
|
|
256054
256338
|
return sanitizeExternalErrorMessage(error, { singleLine: true });
|
|
256055
256339
|
}
|
|
256056
256340
|
var DynamicMCPTool = class {
|
|
@@ -256102,7 +256386,7 @@ var DynamicMCPTool = class {
|
|
|
256102
256386
|
} catch (error) {
|
|
256103
256387
|
return {
|
|
256104
256388
|
ok: false,
|
|
256105
|
-
error: `MCP tool execution failed: ${
|
|
256389
|
+
error: `MCP tool execution failed: ${safeMessage2(error)}`
|
|
256106
256390
|
};
|
|
256107
256391
|
}
|
|
256108
256392
|
}
|
|
@@ -256161,7 +256445,7 @@ ${templateCatalog}` : "");
|
|
|
256161
256445
|
} catch (error) {
|
|
256162
256446
|
return {
|
|
256163
256447
|
ok: false,
|
|
256164
|
-
error: `MCP resource read failed: ${
|
|
256448
|
+
error: `MCP resource read failed: ${safeMessage2(error)}`
|
|
256165
256449
|
};
|
|
256166
256450
|
}
|
|
256167
256451
|
}
|
|
@@ -256275,7 +256559,7 @@ var StreamableHttpMCPClient = class {
|
|
|
256275
256559
|
return true;
|
|
256276
256560
|
} catch (error) {
|
|
256277
256561
|
this.protocolWarnings.push(
|
|
256278
|
-
`Excluded MCP tool "${tool.name}": ${
|
|
256562
|
+
`Excluded MCP tool "${tool.name}": ${safeMessage22(error)}.`
|
|
256279
256563
|
);
|
|
256280
256564
|
return false;
|
|
256281
256565
|
}
|
|
@@ -256415,7 +256699,7 @@ var StreamableHttpMCPClient = class {
|
|
|
256415
256699
|
} catch (error) {
|
|
256416
256700
|
if (error instanceof McpSessionExpiredError && allowSessionRecovery && this.started && this.negotiatedProtocol?.era === "legacy" && method !== "initialize") {
|
|
256417
256701
|
this.recoveryCount += 1;
|
|
256418
|
-
this.lastError =
|
|
256702
|
+
this.lastError = safeMessage22(error);
|
|
256419
256703
|
await this.reinitialize(abortSignal);
|
|
256420
256704
|
if ("cursor" in params) {
|
|
256421
256705
|
throw new McpPaginationSessionResetError(this.serverName);
|
|
@@ -256439,7 +256723,7 @@ var StreamableHttpMCPClient = class {
|
|
|
256439
256723
|
if (parsed.data.error) {
|
|
256440
256724
|
throw new McpJsonRpcError(
|
|
256441
256725
|
parsed.data.error.code,
|
|
256442
|
-
|
|
256726
|
+
safeMessage22(parsed.data.error.message),
|
|
256443
256727
|
"data" in parsed.data.error ? parsed.data.error.data : void 0
|
|
256444
256728
|
);
|
|
256445
256729
|
}
|
|
@@ -256609,7 +256893,7 @@ var StreamableHttpMCPClient = class {
|
|
|
256609
256893
|
if (protocolError) throw protocolError;
|
|
256610
256894
|
throw new McpHttpResponseError(
|
|
256611
256895
|
response.status,
|
|
256612
|
-
`MCP HTTP ${response.status}: ${
|
|
256896
|
+
`MCP HTTP ${response.status}: ${safeMessage22(detail || response.statusText)}`
|
|
256613
256897
|
);
|
|
256614
256898
|
}
|
|
256615
256899
|
const sessionId = isModern ? null : response.headers.get("mcp-session-id");
|
|
@@ -256651,7 +256935,7 @@ var StreamableHttpMCPClient = class {
|
|
|
256651
256935
|
throw error;
|
|
256652
256936
|
}
|
|
256653
256937
|
throw new Error(
|
|
256654
|
-
`MCP server "${this.serverName}" request failed: ${
|
|
256938
|
+
`MCP server "${this.serverName}" request failed: ${safeMessage22(error)}`
|
|
256655
256939
|
);
|
|
256656
256940
|
} finally {
|
|
256657
256941
|
clearTimeout(timeout);
|
|
@@ -256756,7 +257040,7 @@ function parseHttpProtocolError(body) {
|
|
|
256756
257040
|
if (!parsed.success || !parsed.data.error) return void 0;
|
|
256757
257041
|
return new McpJsonRpcError(
|
|
256758
257042
|
parsed.data.error.code,
|
|
256759
|
-
|
|
257043
|
+
safeMessage22(parsed.data.error.message),
|
|
256760
257044
|
"data" in parsed.data.error ? parsed.data.error.data : void 0
|
|
256761
257045
|
);
|
|
256762
257046
|
} catch {
|
|
@@ -256878,7 +257162,7 @@ function parseSseJson(body, expectedId) {
|
|
|
256878
257162
|
}
|
|
256879
257163
|
throw new Error("MCP SSE response contained no matching JSON-RPC response.");
|
|
256880
257164
|
}
|
|
256881
|
-
function
|
|
257165
|
+
function safeMessage22(value) {
|
|
256882
257166
|
return sanitizeExternalErrorMessage(value, { singleLine: true });
|
|
256883
257167
|
}
|
|
256884
257168
|
function assertSecureMcpUrl(value, label) {
|
|
@@ -257649,7 +257933,7 @@ import {
|
|
|
257649
257933
|
existsSync as existsSync10,
|
|
257650
257934
|
lstatSync as lstatSync4,
|
|
257651
257935
|
mkdirSync as mkdirSync4,
|
|
257652
|
-
readdirSync as
|
|
257936
|
+
readdirSync as readdirSync3,
|
|
257653
257937
|
renameSync as renameSync4,
|
|
257654
257938
|
rmSync as rmSync3
|
|
257655
257939
|
} from "fs";
|
|
@@ -257764,7 +258048,7 @@ var CheckpointManager = class {
|
|
|
257764
258048
|
const sessionDir = this.getSessionCheckpointDir();
|
|
257765
258049
|
if (!existsSync10(sessionDir)) return;
|
|
257766
258050
|
const loaded = [];
|
|
257767
|
-
for (const entry of
|
|
258051
|
+
for (const entry of readdirSync3(sessionDir, { withFileTypes: true })) {
|
|
257768
258052
|
if (!entry.isDirectory() || !CheckpointIdSchema.safeParse(entry.name).success) {
|
|
257769
258053
|
continue;
|
|
257770
258054
|
}
|
|
@@ -258458,7 +258742,7 @@ import {
|
|
|
258458
258742
|
lstatSync as lstatSync5,
|
|
258459
258743
|
mkdirSync as mkdirSync5,
|
|
258460
258744
|
openSync as openSync5,
|
|
258461
|
-
readdirSync as
|
|
258745
|
+
readdirSync as readdirSync4,
|
|
258462
258746
|
renameSync as renameSync5,
|
|
258463
258747
|
rmSync as rmSync4,
|
|
258464
258748
|
statSync as statSync2,
|
|
@@ -258474,8 +258758,8 @@ import {
|
|
|
258474
258758
|
statSync as statSync22,
|
|
258475
258759
|
unlinkSync as unlinkSync4
|
|
258476
258760
|
} from "fs";
|
|
258477
|
-
import { homedir as
|
|
258478
|
-
import { basename as basename2, dirname as dirname23, isAbsolute as isAbsolute24, join as join25, parse as
|
|
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";
|
|
258479
258763
|
import { z as z37 } from "zod";
|
|
258480
258764
|
import {
|
|
258481
258765
|
closeSync as closeSync32,
|
|
@@ -258486,7 +258770,7 @@ import {
|
|
|
258486
258770
|
readdirSync as readdirSync22,
|
|
258487
258771
|
unlinkSync as unlinkSync22
|
|
258488
258772
|
} from "fs";
|
|
258489
|
-
import { basename as basename22, join as join34, resolve as
|
|
258773
|
+
import { basename as basename22, join as join34, resolve as resolve35 } from "path";
|
|
258490
258774
|
import { z as z45 } from "zod";
|
|
258491
258775
|
var SafeObjectKeySchema = z30.string().refine(
|
|
258492
258776
|
(key) => !["__proto__", "constructor", "prototype"].includes(key),
|
|
@@ -258802,6 +259086,7 @@ var PRIVATE_DIRECTORY_MODE2 = 448;
|
|
|
258802
259086
|
var PRIVATE_FILE_MODE2 = 384;
|
|
258803
259087
|
var SESSION_SNAPSHOT_MAX_BYTES = 256 * 1024 * 1024;
|
|
258804
259088
|
var SESSION_LOG_MAX_BYTES = 256 * 1024 * 1024;
|
|
259089
|
+
var SESSION_EVENT_CACHE_MAX_ITEMS = 25e3;
|
|
258805
259090
|
var HISTORY_JOURNAL_COMPACT_BYTES = 1024 * 1024;
|
|
258806
259091
|
var HISTORY_JOURNAL_COMPACT_RECORDS = 32;
|
|
258807
259092
|
var HistoryJournalRecordSchema = z210.object({
|
|
@@ -258981,10 +259266,18 @@ function normalizeTracePath(filePath, cwd) {
|
|
|
258981
259266
|
}
|
|
258982
259267
|
return replaceWorkspacePath(filePath, cwd);
|
|
258983
259268
|
}
|
|
259269
|
+
function cloneSessionEvents(events) {
|
|
259270
|
+
return events.map((event) => ({
|
|
259271
|
+
...event,
|
|
259272
|
+
payload: structuredClone(event.payload)
|
|
259273
|
+
}));
|
|
259274
|
+
}
|
|
258984
259275
|
var SessionStore = class {
|
|
258985
259276
|
cwd;
|
|
258986
259277
|
sessionRootPath;
|
|
258987
259278
|
historyJournalWrites = /* @__PURE__ */ new Map();
|
|
259279
|
+
/** Avoid reparsing a long immutable event journal for every UI refresh. */
|
|
259280
|
+
eventCache = /* @__PURE__ */ new Map();
|
|
258988
259281
|
constructor(cwd, sessionRootPath = ".orbit/sessions") {
|
|
258989
259282
|
this.cwd = resolve7(cwd);
|
|
258990
259283
|
this.sessionRootPath = sessionRootPath.trim();
|
|
@@ -259056,7 +259349,7 @@ var SessionStore = class {
|
|
|
259056
259349
|
try {
|
|
259057
259350
|
sessionRoot = this.resolveSessionRoot();
|
|
259058
259351
|
if (!existsSync11(sessionRoot)) return [];
|
|
259059
|
-
dirs =
|
|
259352
|
+
dirs = readdirSync4(sessionRoot);
|
|
259060
259353
|
} catch {
|
|
259061
259354
|
return [];
|
|
259062
259355
|
}
|
|
@@ -259079,6 +259372,7 @@ var SessionStore = class {
|
|
|
259079
259372
|
});
|
|
259080
259373
|
const file = join9(this.resolveSessionDirectory(sessionId), "events.jsonl");
|
|
259081
259374
|
appendJsonLine(file, event);
|
|
259375
|
+
this.eventCache.delete(sessionId);
|
|
259082
259376
|
return event;
|
|
259083
259377
|
}
|
|
259084
259378
|
getEvents(sessionId) {
|
|
@@ -259088,14 +259382,27 @@ var SessionStore = class {
|
|
|
259088
259382
|
} catch {
|
|
259089
259383
|
return [];
|
|
259090
259384
|
}
|
|
259091
|
-
if (!existsSync11(file))
|
|
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
|
+
}
|
|
259092
259399
|
let content;
|
|
259093
259400
|
try {
|
|
259094
259401
|
content = readBoundedRegularFile(file, SESSION_LOG_MAX_BYTES) ?? "";
|
|
259095
259402
|
} catch {
|
|
259096
259403
|
return [];
|
|
259097
259404
|
}
|
|
259098
|
-
|
|
259405
|
+
const events = content.split("\n").filter((line) => line.trim()).flatMap((line) => {
|
|
259099
259406
|
try {
|
|
259100
259407
|
const parsed = SessionEventSchema.safeParse(JSON.parse(line));
|
|
259101
259408
|
return parsed.success && parsed.data.sessionId === sessionId ? [
|
|
@@ -259111,6 +259418,12 @@ var SessionStore = class {
|
|
|
259111
259418
|
return [];
|
|
259112
259419
|
}
|
|
259113
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);
|
|
259114
259427
|
}
|
|
259115
259428
|
/** Returns a compact, local-only summary derived from the audit stream. */
|
|
259116
259429
|
getMetrics(sessionId) {
|
|
@@ -259435,6 +259748,7 @@ var SessionStore = class {
|
|
|
259435
259748
|
if (existsSync11(dir)) {
|
|
259436
259749
|
rmSync4(dir, { recursive: true, force: true });
|
|
259437
259750
|
}
|
|
259751
|
+
this.eventCache.delete(id);
|
|
259438
259752
|
}
|
|
259439
259753
|
createUniqueSessionDirectory() {
|
|
259440
259754
|
for (let attempt = 0; attempt < 10; attempt += 1) {
|
|
@@ -259912,7 +260226,7 @@ function parseProjectRegistrySnapshot(value) {
|
|
|
259912
260226
|
}
|
|
259913
260227
|
var ProjectRegistry = class {
|
|
259914
260228
|
filePath;
|
|
259915
|
-
constructor(rootPath = join25(
|
|
260229
|
+
constructor(rootPath = join25(homedir6(), ".orbit")) {
|
|
259916
260230
|
const root = resolve25(rootPath);
|
|
259917
260231
|
this.filePath = join25(root, "projects.json");
|
|
259918
260232
|
}
|
|
@@ -260075,7 +260389,7 @@ function canonicalizeProjectPath(projectPath) {
|
|
|
260075
260389
|
if (!isAbsolute24(projectPath))
|
|
260076
260390
|
throw new Error("Project path must be absolute.");
|
|
260077
260391
|
const requested = resolve25(projectPath);
|
|
260078
|
-
if (requested ===
|
|
260392
|
+
if (requested === parse3(requested).root) {
|
|
260079
260393
|
throw new Error(
|
|
260080
260394
|
"A filesystem root cannot be registered as an Orbit project."
|
|
260081
260395
|
);
|
|
@@ -260083,7 +260397,7 @@ function canonicalizeProjectPath(projectPath) {
|
|
|
260083
260397
|
if (!isDirectory(requested))
|
|
260084
260398
|
throw new Error("Project path must be an existing directory.");
|
|
260085
260399
|
const canonical = realpathSync2.native(requested);
|
|
260086
|
-
if (canonical ===
|
|
260400
|
+
if (canonical === parse3(canonical).root) {
|
|
260087
260401
|
throw new Error(
|
|
260088
260402
|
"A filesystem root cannot be registered as an Orbit project."
|
|
260089
260403
|
);
|
|
@@ -260177,7 +260491,7 @@ var AgentRunSchema = z45.object({
|
|
|
260177
260491
|
var AgentRunStore = class {
|
|
260178
260492
|
constructor(cwd, options = {}) {
|
|
260179
260493
|
this.cwd = cwd;
|
|
260180
|
-
this.directory =
|
|
260494
|
+
this.directory = resolve35(cwd, ".orbit", "agent-runs");
|
|
260181
260495
|
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
260182
260496
|
this.ownerPid = options.ownerPid ?? process.pid;
|
|
260183
260497
|
this.ownerInstanceId = options.ownerInstanceId ?? generateId("orbit");
|
|
@@ -260408,7 +260722,7 @@ var AgentRunStore = class {
|
|
|
260408
260722
|
* The returned cleanup callback is idempotent and the timer never keeps the
|
|
260409
260723
|
* process alive on its own.
|
|
260410
260724
|
*/
|
|
260411
|
-
startLeaseHeartbeat(runId) {
|
|
260725
|
+
startLeaseHeartbeat(runId, options = {}) {
|
|
260412
260726
|
this.renewLease(runId);
|
|
260413
260727
|
let active = true;
|
|
260414
260728
|
const heartbeat = setInterval(
|
|
@@ -260416,9 +260730,10 @@ var AgentRunStore = class {
|
|
|
260416
260730
|
if (!active) return;
|
|
260417
260731
|
try {
|
|
260418
260732
|
this.renewLease(runId);
|
|
260419
|
-
} catch {
|
|
260733
|
+
} catch (error) {
|
|
260420
260734
|
active = false;
|
|
260421
260735
|
clearInterval(heartbeat);
|
|
260736
|
+
options.onLeaseLost?.(error);
|
|
260422
260737
|
}
|
|
260423
260738
|
},
|
|
260424
260739
|
Math.max(1e3, Math.floor(this.leaseDurationMs / 3))
|
|
@@ -260508,7 +260823,7 @@ var AgentRunStore = class {
|
|
|
260508
260823
|
this.cwd,
|
|
260509
260824
|
join34(".orbit", "agent-runs")
|
|
260510
260825
|
);
|
|
260511
|
-
if (
|
|
260826
|
+
if (resolve35(safeDirectory) !== this.directory) {
|
|
260512
260827
|
throw new Error("Orbit agent-run directory escaped the workspace.");
|
|
260513
260828
|
}
|
|
260514
260829
|
}
|
|
@@ -260605,9 +260920,9 @@ import { z as z73 } from "zod";
|
|
|
260605
260920
|
import { randomUUID as randomUUID52 } from "crypto";
|
|
260606
260921
|
import { z as z103 } from "zod";
|
|
260607
260922
|
import { z as z93 } from "zod";
|
|
260608
|
-
import { z as
|
|
260923
|
+
import { z as z113 } from "zod";
|
|
260609
260924
|
import path8 from "path";
|
|
260610
|
-
import { existsSync as
|
|
260925
|
+
import { existsSync as existsSync35, statSync as statSync3 } from "fs";
|
|
260611
260926
|
import { z as z122 } from "zod";
|
|
260612
260927
|
import { z as z132 } from "zod";
|
|
260613
260928
|
function createInitialState(sessionId, task, maxAttempts = 8) {
|
|
@@ -260877,7 +261192,7 @@ var PromptCacheSlabBuilder = class {
|
|
|
260877
261192
|
"- Run at least one DeepSeek request to create a stable slab."
|
|
260878
261193
|
].join("\n");
|
|
260879
261194
|
}
|
|
260880
|
-
const slabs =
|
|
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) => {
|
|
260881
261196
|
const aTime = Date.parse(
|
|
260882
261197
|
a2.telemetry?.at(-1)?.recordedAt || a2.lastPrimedAt || ""
|
|
260883
261198
|
);
|
|
@@ -261144,7 +261459,7 @@ function compactHistoryMessages(sourceHistory, options) {
|
|
|
261144
261459
|
}
|
|
261145
261460
|
var SEMANTIC_SUMMARY_MIN_DIGEST_CHARS = 400;
|
|
261146
261461
|
var SEMANTIC_SUMMARY_DIGEST_TOKEN_BUDGET = 6e3;
|
|
261147
|
-
async function buildSemanticCompactionSummary(dropped, provider, fastModel) {
|
|
261462
|
+
async function buildSemanticCompactionSummary(dropped, provider, fastModel, options = {}) {
|
|
261148
261463
|
if (!fastModel || dropped.length === 0) return null;
|
|
261149
261464
|
const digest = buildDroppedHistoryDigest(dropped);
|
|
261150
261465
|
if (digest.length < SEMANTIC_SUMMARY_MIN_DIGEST_CHARS) return null;
|
|
@@ -261176,9 +261491,13 @@ async function buildSemanticCompactionSummary(dropped, provider, fastModel) {
|
|
|
261176
261491
|
],
|
|
261177
261492
|
tools: [],
|
|
261178
261493
|
thinking: { enabled: false },
|
|
261179
|
-
maxTokens: 1024
|
|
261494
|
+
maxTokens: 1024,
|
|
261495
|
+
abortSignal: options.abortSignal,
|
|
261496
|
+
retryBudget: 0
|
|
261180
261497
|
})) {
|
|
261498
|
+
if (options.abortSignal?.aborted) return null;
|
|
261181
261499
|
if (event.type === "text_delta") text2 += event.text;
|
|
261500
|
+
if (event.type === "usage") options.onUsage?.(event.usage);
|
|
261182
261501
|
if (event.type === "error") return null;
|
|
261183
261502
|
}
|
|
261184
261503
|
const cleaned = text2.trim();
|
|
@@ -264506,8 +264825,19 @@ var AgentLoop = class _AgentLoop {
|
|
|
264506
264825
|
});
|
|
264507
264826
|
this.verificationManager.initialize();
|
|
264508
264827
|
this.sessionManager.saveHistory(this.state.history);
|
|
264509
|
-
|
|
264510
|
-
|
|
264828
|
+
try {
|
|
264829
|
+
await this.provider.initialize?.();
|
|
264830
|
+
} catch (error) {
|
|
264831
|
+
const message2 = safeAgentLoopErrorMessage(error);
|
|
264832
|
+
this.sessionManager.logEvent("provider_initialization_failed", {
|
|
264833
|
+
provider: this.provider.id,
|
|
264834
|
+
message: message2
|
|
264835
|
+
});
|
|
264836
|
+
this.interaction.showText(
|
|
264837
|
+
picocolors3.red(`\u2716 Provider initialization failed: ${message2}`)
|
|
264838
|
+
);
|
|
264839
|
+
return this.createFailedOutcome("provider_error", message2);
|
|
264840
|
+
}
|
|
264511
264841
|
if (isNewSession) {
|
|
264512
264842
|
const sessionHooks = await this.runLifecycleHooks("sessionStart", {
|
|
264513
264843
|
sessionId: this.state.sessionId,
|
|
@@ -264759,7 +265089,8 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
264759
265089
|
this.getContextWindowStatus(activeModel2).compactAtTokens * 0.4
|
|
264760
265090
|
)
|
|
264761
265091
|
)
|
|
264762
|
-
)
|
|
265092
|
+
),
|
|
265093
|
+
forcedSkills: this.options?.forcedSkills
|
|
264763
265094
|
}
|
|
264764
265095
|
);
|
|
264765
265096
|
this.reportSkillContext(this.cachedContextPack);
|
|
@@ -264786,6 +265117,10 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
264786
265117
|
(t2) => this.options.allowedTools.includes(t2.name)
|
|
264787
265118
|
);
|
|
264788
265119
|
}
|
|
265120
|
+
if (this.options?.disallowedTools) {
|
|
265121
|
+
const deniedTools = new Set(this.options.disallowedTools);
|
|
265122
|
+
toolDefs = toolDefs.filter((tool) => !deniedTools.has(tool.name));
|
|
265123
|
+
}
|
|
264789
265124
|
if (this.finalResponseOnlyReason) {
|
|
264790
265125
|
toolDefs = [];
|
|
264791
265126
|
}
|
|
@@ -264794,7 +265129,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
264794
265129
|
this.provider,
|
|
264795
265130
|
activeModel2
|
|
264796
265131
|
);
|
|
264797
|
-
const projectMemory = this.projectMemoryStore.read();
|
|
265132
|
+
const projectMemory = this.options?.memoryMode === "none" ? void 0 : this.projectMemoryStore.read();
|
|
264798
265133
|
const taskPlan = this.sessionManager.getTaskPlan();
|
|
264799
265134
|
const baseSystemPrompt = this.options?.systemPromptOverride || Planner.makeSystemPrompt(
|
|
264800
265135
|
activeModel2,
|
|
@@ -264825,7 +265160,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
264825
265160
|
now: runStartedAt,
|
|
264826
265161
|
repoMapText,
|
|
264827
265162
|
sessionGoal: this.sessionManager.getActiveSession()?.goal,
|
|
264828
|
-
projectMemory: projectMemory
|
|
265163
|
+
projectMemory: projectMemory?.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
|
|
264829
265164
|
taskPlan: taskPlan?.items.map(
|
|
264830
265165
|
(item) => `[${item.status}] ${item.text}`
|
|
264831
265166
|
)
|
|
@@ -264852,7 +265187,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
264852
265187
|
now: runStartedAt,
|
|
264853
265188
|
repoMapText,
|
|
264854
265189
|
sessionGoal: this.sessionManager.getActiveSession()?.goal,
|
|
264855
|
-
projectMemory: projectMemory
|
|
265190
|
+
projectMemory: projectMemory?.enabled ? projectMemory.entries.map((entry) => entry.text) : [],
|
|
264856
265191
|
taskPlan: taskPlan?.items.map(
|
|
264857
265192
|
(item) => `[${item.status}] ${item.text}`
|
|
264858
265193
|
)
|
|
@@ -264909,6 +265244,9 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
264909
265244
|
maxTokens: this.getContextWindowStatus(activeModel2).reservedOutputTokens,
|
|
264910
265245
|
userId: this.userId,
|
|
264911
265246
|
abortSignal: this.abortController.signal,
|
|
265247
|
+
// The Agent owns the retry budget and fallback policy. Prevent a
|
|
265248
|
+
// provider transport from nesting its own retries inside the loop.
|
|
265249
|
+
retryBudget: 0,
|
|
264912
265250
|
thinking: supportsThinking ? {
|
|
264913
265251
|
enabled: thinkingEnabled,
|
|
264914
265252
|
budgetTokens: thinkingBudget,
|
|
@@ -266039,9 +266377,9 @@ ${commandError}`,
|
|
|
266039
266377
|
content: [
|
|
266040
266378
|
{
|
|
266041
266379
|
type: "text",
|
|
266042
|
-
text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete)
|
|
266380
|
+
text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete) from the following change summary. Output ONLY the commit message, no formatting, no markdown, no quotes, just the text:
|
|
266043
266381
|
|
|
266044
|
-
${stdout2
|
|
266382
|
+
${buildCommitContextForModel(stdout2)}`
|
|
266045
266383
|
}
|
|
266046
266384
|
]
|
|
266047
266385
|
}
|
|
@@ -266871,9 +267209,9 @@ ${guardNudge.message}` : ""),
|
|
|
266871
267209
|
content: [
|
|
266872
267210
|
{
|
|
266873
267211
|
type: "text",
|
|
266874
|
-
text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete)
|
|
267212
|
+
text: `Generate a concise, high-quality conventional git commit message (e.g. feat(cli): add autocomplete) from the following change summary. Output ONLY the commit message, no formatting, no markdown, no quotes, just the text:
|
|
266875
267213
|
|
|
266876
|
-
${diff
|
|
267214
|
+
${buildCommitContextForModel(diff)}`
|
|
266877
267215
|
}
|
|
266878
267216
|
]
|
|
266879
267217
|
}
|
|
@@ -267739,7 +268077,11 @@ ${diff.substring(0, 2e4)}`
|
|
|
267739
268077
|
const semanticSummary = await buildSemanticCompactionSummary(
|
|
267740
268078
|
droppedHistory,
|
|
267741
268079
|
this.provider,
|
|
267742
|
-
this.config.models.fast
|
|
268080
|
+
this.config.models.fast,
|
|
268081
|
+
{
|
|
268082
|
+
abortSignal: this.abortController?.signal,
|
|
268083
|
+
onUsage: (usage2) => this.accumulateCost(this.config.models.fast, usage2)
|
|
268084
|
+
}
|
|
267743
268085
|
);
|
|
267744
268086
|
const summaryBlock = semanticSummary ? history.find((message2) => message2.id === summaryMessageId)?.content.find((block2) => block2.type === "text") : void 0;
|
|
267745
268087
|
if (semanticSummary && summaryBlock?.type === "text") {
|
|
@@ -267952,6 +268294,29 @@ ${diff.substring(0, 2e4)}`
|
|
|
267952
268294
|
}
|
|
267953
268295
|
}
|
|
267954
268296
|
};
|
|
268297
|
+
function buildCommitContextForModel(diff) {
|
|
268298
|
+
const files = /* @__PURE__ */ new Set();
|
|
268299
|
+
let additions = 0;
|
|
268300
|
+
let deletions = 0;
|
|
268301
|
+
for (const line of diff.split(/\r?\n/)) {
|
|
268302
|
+
if (line.startsWith("diff --git ")) {
|
|
268303
|
+
const match = line.match(/ b\/(.+)$/);
|
|
268304
|
+
if (match?.[1]) files.add(match[1]);
|
|
268305
|
+
} else if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
268306
|
+
additions += 1;
|
|
268307
|
+
} else if (line.startsWith("-") && !line.startsWith("---")) {
|
|
268308
|
+
deletions += 1;
|
|
268309
|
+
}
|
|
268310
|
+
}
|
|
268311
|
+
const fileList = [...files].slice(0, 100);
|
|
268312
|
+
return redactSecrets(
|
|
268313
|
+
[
|
|
268314
|
+
`Files changed (${files.size}): ${fileList.join(", ") || "unknown"}`,
|
|
268315
|
+
`Line changes: +${additions} / -${deletions}.`,
|
|
268316
|
+
"Infer the scope from paths and counts only; do not invent implementation details."
|
|
268317
|
+
].join("\n")
|
|
268318
|
+
).slice(0, 8e3);
|
|
268319
|
+
}
|
|
267955
268320
|
function toUnknownRecord(value) {
|
|
267956
268321
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
267957
268322
|
}
|
|
@@ -268254,20 +268619,20 @@ function abortError2(signal) {
|
|
|
268254
268619
|
function toError2(error) {
|
|
268255
268620
|
return error instanceof Error ? error : new Error(String(error));
|
|
268256
268621
|
}
|
|
268257
|
-
var ParallelWriterTaskSchema =
|
|
268258
|
-
id:
|
|
268259
|
-
task:
|
|
268260
|
-
scopes:
|
|
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)
|
|
268261
268626
|
});
|
|
268262
|
-
var ParallelWorkPlanSchema =
|
|
268263
|
-
summary:
|
|
268264
|
-
tasks:
|
|
268627
|
+
var ParallelWorkPlanSchema = z113.object({
|
|
268628
|
+
summary: z113.string().trim().min(1).max(2e4),
|
|
268629
|
+
tasks: z113.array(ParallelWriterTaskSchema).min(1).max(4)
|
|
268265
268630
|
}).superRefine((plan, context) => {
|
|
268266
268631
|
const ids = /* @__PURE__ */ new Set();
|
|
268267
268632
|
for (const [index, task] of plan.tasks.entries()) {
|
|
268268
268633
|
if (ids.has(task.id)) {
|
|
268269
268634
|
context.addIssue({
|
|
268270
|
-
code:
|
|
268635
|
+
code: z113.ZodIssueCode.custom,
|
|
268271
268636
|
path: ["tasks", index, "id"],
|
|
268272
268637
|
message: `Duplicate writer task id: ${task.id}`
|
|
268273
268638
|
});
|
|
@@ -268284,7 +268649,7 @@ var ParallelWorkPlanSchema = z112.object({
|
|
|
268284
268649
|
);
|
|
268285
268650
|
if (!overlap) continue;
|
|
268286
268651
|
context.addIssue({
|
|
268287
|
-
code:
|
|
268652
|
+
code: z113.ZodIssueCode.custom,
|
|
268288
268653
|
path: ["tasks", right, "scopes"],
|
|
268289
268654
|
message: `Writer scopes overlap with task ${plan.tasks[left].id}.`
|
|
268290
268655
|
});
|
|
@@ -268332,7 +268697,11 @@ var AgentRunTracker = class {
|
|
|
268332
268697
|
task: this.task,
|
|
268333
268698
|
budgetUsd: this.budgetUsd
|
|
268334
268699
|
});
|
|
268335
|
-
this.stopLeaseHeartbeat = store.startLeaseHeartbeat(this.run.id
|
|
268700
|
+
this.stopLeaseHeartbeat = store.startLeaseHeartbeat(this.run.id, {
|
|
268701
|
+
onLeaseLost: (error) => this.warn(
|
|
268702
|
+
`Agent run lease was lost; durable state is no longer being renewed: ${errorMessage2(error)}`
|
|
268703
|
+
)
|
|
268704
|
+
});
|
|
268336
268705
|
} catch (error) {
|
|
268337
268706
|
this.warn(`Agent run state will be memory-only: ${errorMessage2(error)}`);
|
|
268338
268707
|
}
|
|
@@ -268462,12 +268831,13 @@ var ReviewVerdictSchema = z122.object({
|
|
|
268462
268831
|
feedback: z122.string().default("")
|
|
268463
268832
|
});
|
|
268464
268833
|
var Orchestrator = class {
|
|
268465
|
-
constructor(cwd, config, provider, task, interaction) {
|
|
268834
|
+
constructor(cwd, config, provider, task, interaction, profile) {
|
|
268466
268835
|
this.cwd = cwd;
|
|
268467
268836
|
this.config = config;
|
|
268468
268837
|
this.provider = provider;
|
|
268469
268838
|
this.task = task;
|
|
268470
268839
|
this.interaction = interaction;
|
|
268840
|
+
this.profile = profile;
|
|
268471
268841
|
this.agentRunTracker = new AgentRunTracker(
|
|
268472
268842
|
cwd,
|
|
268473
268843
|
task,
|
|
@@ -268480,6 +268850,7 @@ var Orchestrator = class {
|
|
|
268480
268850
|
provider;
|
|
268481
268851
|
task;
|
|
268482
268852
|
interaction;
|
|
268853
|
+
profile;
|
|
268483
268854
|
activeLoops = /* @__PURE__ */ new Map();
|
|
268484
268855
|
activeTaskScheduler;
|
|
268485
268856
|
agentRunTracker;
|
|
@@ -268563,7 +268934,7 @@ var Orchestrator = class {
|
|
|
268563
268934
|
snapshotWorkingTree: true
|
|
268564
268935
|
});
|
|
268565
268936
|
}
|
|
268566
|
-
if (!
|
|
268937
|
+
if (!existsSync35(worktree.path) || !statSync3(worktree.path).isDirectory()) {
|
|
268567
268938
|
throw new Error(
|
|
268568
268939
|
`Worktree manager returned a missing directory: ${worktree.path}`
|
|
268569
268940
|
);
|
|
@@ -268702,13 +269073,13 @@ var Orchestrator = class {
|
|
|
268702
269073
|
`Create a detailed implementation plan for: ${this.task}`,
|
|
268703
269074
|
this.interaction,
|
|
268704
269075
|
{
|
|
268705
|
-
modelOverride: this.config.models.planner,
|
|
269076
|
+
modelOverride: this.profile?.model || this.config.models.planner,
|
|
268706
269077
|
systemPromptOverride: `You are the Orbit Planner Agent.
|
|
268707
269078
|
Analyze the codebase and produce a bounded implementation plan. Do not modify files.
|
|
268708
269079
|
Return ONLY one JSON object with this shape:
|
|
268709
269080
|
{"summary":"shared architecture and acceptance criteria","tasks":[{"id":"short-id","task":"self-contained writer assignment","scopes":["workspace-relative/path"]}]}
|
|
268710
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.`,
|
|
268711
|
-
allowedTools: [
|
|
269082
|
+
allowedTools: applyProfileToolPolicy(this.profile, [
|
|
268712
269083
|
"read_file",
|
|
268713
269084
|
"list_files",
|
|
268714
269085
|
"glob",
|
|
@@ -268717,7 +269088,10 @@ Use 2-4 tasks only when their write scopes are provably disjoint and they can be
|
|
|
268717
269088
|
"git_diff",
|
|
268718
269089
|
"detect_project",
|
|
268719
269090
|
"inspect_project"
|
|
268720
|
-
],
|
|
269091
|
+
]),
|
|
269092
|
+
disallowedTools: this.profile?.disallowedTools,
|
|
269093
|
+
forcedSkills: this.profile?.skills,
|
|
269094
|
+
memoryMode: this.profile?.memory,
|
|
268721
269095
|
disableMcp: true,
|
|
268722
269096
|
agent: { id: activeId, role: "planner" },
|
|
268723
269097
|
sessionStorage: this.agentSessionStorage()
|
|
@@ -268791,7 +269165,7 @@ Work only in your assigned isolated worktree and only inside the declared write
|
|
|
268791
269165
|
const tracked = this.addTrackedAgent(
|
|
268792
269166
|
role,
|
|
268793
269167
|
prompt,
|
|
268794
|
-
this.config.models.coder,
|
|
269168
|
+
this.profile?.model || this.config.models.coder,
|
|
268795
269169
|
budgetFraction,
|
|
268796
269170
|
"write",
|
|
268797
269171
|
scopes
|
|
@@ -268804,9 +269178,9 @@ Work only in your assigned isolated worktree and only inside the declared write
|
|
|
268804
269178
|
prompt,
|
|
268805
269179
|
this.interaction,
|
|
268806
269180
|
{
|
|
268807
|
-
modelOverride: this.config.models.coder,
|
|
268808
|
-
systemPromptOverride: systemPrompt,
|
|
268809
|
-
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, [
|
|
268810
269184
|
"read_file",
|
|
268811
269185
|
"write_file",
|
|
268812
269186
|
"edit_file",
|
|
@@ -268820,7 +269194,10 @@ Work only in your assigned isolated worktree and only inside the declared write
|
|
|
268820
269194
|
"get_background_task_output",
|
|
268821
269195
|
"kill_background_task",
|
|
268822
269196
|
"list_background_tasks"
|
|
268823
|
-
],
|
|
269197
|
+
]),
|
|
269198
|
+
disallowedTools: this.profile?.disallowedTools,
|
|
269199
|
+
forcedSkills: this.profile?.skills,
|
|
269200
|
+
memoryMode: this.profile?.memory,
|
|
268824
269201
|
disableMcp: true,
|
|
268825
269202
|
agent: { id: activeId, role },
|
|
268826
269203
|
sessionStorage: this.agentSessionStorage()
|
|
@@ -269206,6 +269583,13 @@ function errorMessage22(error) {
|
|
|
269206
269583
|
const raw = error instanceof Error ? error.message : String(error);
|
|
269207
269584
|
return redactSecrets(raw).replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").replace(/\s+/g, " ").trim().slice(0, 2e3);
|
|
269208
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
|
+
}
|
|
269209
269593
|
var AcceptanceVerificationSchema = z132.object({
|
|
269210
269594
|
name: z132.string().trim().min(1).max(120),
|
|
269211
269595
|
command: z132.string().trim().min(1).max(4e3),
|
|
@@ -269718,7 +270102,7 @@ function buildCacheDiagnostics(cwd) {
|
|
|
269718
270102
|
"\u25CF No cache telemetry yet. It will appear after a completed DeepSeek request."
|
|
269719
270103
|
);
|
|
269720
270104
|
}
|
|
269721
|
-
const slabs =
|
|
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);
|
|
269722
270106
|
if (slabs.length === 0) {
|
|
269723
270107
|
return picocolors4.gray(
|
|
269724
270108
|
"\u25CF No readable cache slab metadata found. Remove stale .orbit/cache-slabs entries if this persists."
|
|
@@ -270386,7 +270770,9 @@ var DoctorSnapshotSchema = z47.object({
|
|
|
270386
270770
|
mcp: z47.boolean(),
|
|
270387
270771
|
mcpServerCount: z47.number().int().nonnegative(),
|
|
270388
270772
|
skills: z47.boolean(),
|
|
270389
|
-
automaticCompaction: z47.boolean()
|
|
270773
|
+
automaticCompaction: z47.boolean(),
|
|
270774
|
+
agentProfiles: z47.number().int().nonnegative(),
|
|
270775
|
+
agentProfileErrors: z47.number().int().nonnegative()
|
|
270390
270776
|
}),
|
|
270391
270777
|
safety: z47.object({
|
|
270392
270778
|
permissionMode: z47.enum(["strict", "normal", "auto", "plan"]),
|
|
@@ -270498,6 +270884,19 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
|
|
|
270498
270884
|
);
|
|
270499
270885
|
const configuredModels = allConfiguredModelNames(config);
|
|
270500
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
|
+
}
|
|
270501
270900
|
if (nodeMajor < 20) {
|
|
270502
270901
|
issues.push({
|
|
270503
270902
|
severity: "error",
|
|
@@ -270611,7 +271010,9 @@ function buildDoctorSnapshot(cwd, config = ConfigLoader.loadSync(cwd), options =
|
|
|
270611
271010
|
mcp: config.tools.mcp.enabled,
|
|
270612
271011
|
mcpServerCount: Object.keys(config.mcpServers).length,
|
|
270613
271012
|
skills: config.skills.enabled,
|
|
270614
|
-
automaticCompaction: config.context.autoCompact
|
|
271013
|
+
automaticCompaction: config.context.autoCompact,
|
|
271014
|
+
agentProfiles: profileCatalog.profiles.length,
|
|
271015
|
+
agentProfileErrors: profileErrors.length
|
|
270615
271016
|
},
|
|
270616
271017
|
safety: {
|
|
270617
271018
|
permissionMode: config.permissions.mode,
|
|
@@ -270732,6 +271133,7 @@ function buildDoctorReport(cwd, config = ConfigLoader.loadSync(cwd), options = {
|
|
|
270732
271133
|
const gitStatus = commandOutput(exec6, "git status --short", cwd);
|
|
270733
271134
|
const webSearch = config.tools.webSearch;
|
|
270734
271135
|
const skills = config.skills;
|
|
271136
|
+
const agentSettings = config.agents ?? DEFAULT_CONFIG.agents;
|
|
270735
271137
|
const mcpServers = Object.keys(config.mcpServers || {});
|
|
270736
271138
|
const providerKeyName = provider?.apiKeyEnv || "configured provider key";
|
|
270737
271139
|
const hasApiKey = apiKeyLoaded(defaultProvider, config);
|
|
@@ -270852,6 +271254,15 @@ function buildDoctorReport(cwd, config = ConfigLoader.loadSync(cwd), options = {
|
|
|
270852
271254
|
lines.push(
|
|
270853
271255
|
`\u25CF Skill dirs: ${skills.directories.map((dir) => picocolors6.cyan(dir)).join(", ")}`
|
|
270854
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
|
+
);
|
|
270855
271266
|
lines.push("");
|
|
270856
271267
|
lines.push(picocolors6.bold("Safety & Context"));
|
|
270857
271268
|
lines.push(
|
|
@@ -272185,7 +272596,7 @@ var n2 = class extends V {
|
|
|
272185
272596
|
import { styleText as styleText2, stripVTControlCharacters } from "util";
|
|
272186
272597
|
import process$1 from "process";
|
|
272187
272598
|
var import_sisteransi2 = __toESM(require_src(), 1);
|
|
272188
|
-
import { existsSync as existsSync15, lstatSync as lstatSync6, readdirSync as
|
|
272599
|
+
import { existsSync as existsSync15, lstatSync as lstatSync6, readdirSync as readdirSync7 } from "fs";
|
|
272189
272600
|
import { dirname as dirname9, join as join13 } from "path";
|
|
272190
272601
|
function isUnicodeSupported() {
|
|
272191
272602
|
if (process$1.platform !== "win32") {
|
|
@@ -273460,7 +273871,7 @@ import picocolors20 from "picocolors";
|
|
|
273460
273871
|
|
|
273461
273872
|
// src/tui/FullscreenTui.ts
|
|
273462
273873
|
import { join as join15 } from "path";
|
|
273463
|
-
import { homedir as
|
|
273874
|
+
import { homedir as homedir8 } from "os";
|
|
273464
273875
|
import { existsSync as existsSync16 } from "fs";
|
|
273465
273876
|
import { exec as exec4 } from "child_process";
|
|
273466
273877
|
import readline3 from "readline";
|
|
@@ -274552,14 +274963,14 @@ function findPreviousHistoryEntry(history, query, startIndex = history.length) {
|
|
|
274552
274963
|
|
|
274553
274964
|
// src/tui/InputHistoryStore.ts
|
|
274554
274965
|
import { join as join14 } from "path";
|
|
274555
|
-
import { homedir as
|
|
274966
|
+
import { homedir as homedir7 } from "os";
|
|
274556
274967
|
import { z as z49 } from "zod";
|
|
274557
274968
|
var INPUT_HISTORY_MAX_BYTES = 1048576;
|
|
274558
274969
|
var INPUT_HISTORY_MAX_ENTRIES = 500;
|
|
274559
274970
|
var INPUT_HISTORY_ENTRY_MAX_CHARS = 2e4;
|
|
274560
274971
|
var inputHistorySchema = z49.array(z49.string().max(INPUT_HISTORY_ENTRY_MAX_CHARS)).max(INPUT_HISTORY_MAX_ENTRIES);
|
|
274561
274972
|
var InputHistoryStore = class {
|
|
274562
|
-
constructor(filePath = join14(
|
|
274973
|
+
constructor(filePath = join14(homedir7(), ".orbit", "input_history.json")) {
|
|
274563
274974
|
this.filePath = filePath;
|
|
274564
274975
|
}
|
|
274565
274976
|
filePath;
|
|
@@ -275236,7 +275647,7 @@ function parseNpmJsonString(raw) {
|
|
|
275236
275647
|
}
|
|
275237
275648
|
}
|
|
275238
275649
|
function compareSemanticVersions(left, right) {
|
|
275239
|
-
const
|
|
275650
|
+
const parse7 = (version) => {
|
|
275240
275651
|
const withoutBuild = version.split("+", 1)[0] ?? version;
|
|
275241
275652
|
const prereleaseSeparator = withoutBuild.indexOf("-");
|
|
275242
275653
|
const corePart = prereleaseSeparator === -1 ? withoutBuild : withoutBuild.slice(0, prereleaseSeparator);
|
|
@@ -275246,8 +275657,8 @@ function compareSemanticVersions(left, right) {
|
|
|
275246
275657
|
prerelease: prereleasePart ? prereleasePart.split(".") : []
|
|
275247
275658
|
};
|
|
275248
275659
|
};
|
|
275249
|
-
const leftVersion =
|
|
275250
|
-
const rightVersion =
|
|
275660
|
+
const leftVersion = parse7(left);
|
|
275661
|
+
const rightVersion = parse7(right);
|
|
275251
275662
|
for (let index = 0; index < 3; index++) {
|
|
275252
275663
|
const difference = (leftVersion.core[index] ?? 0) - (rightVersion.core[index] ?? 0);
|
|
275253
275664
|
if (difference !== 0) return Math.sign(difference);
|
|
@@ -275427,7 +275838,7 @@ async function pageText(text2) {
|
|
|
275427
275838
|
var TUI_ERROR_LOG_MAX_BYTES = 1048576;
|
|
275428
275839
|
function appendTuiErrorLog(context, error) {
|
|
275429
275840
|
try {
|
|
275430
|
-
const logPath = join15(
|
|
275841
|
+
const logPath = join15(homedir8(), ".orbit", "tui_error.log");
|
|
275431
275842
|
let previous = "";
|
|
275432
275843
|
try {
|
|
275433
275844
|
previous = readBoundedRegularFile(logPath, TUI_ERROR_LOG_MAX_BYTES) ?? "";
|
|
@@ -277525,7 +277936,7 @@ var FullscreenTui = class {
|
|
|
277525
277936
|
import picocolors19 from "picocolors";
|
|
277526
277937
|
import { rmSync as rmSync6, watch } from "fs";
|
|
277527
277938
|
import { dirname as dirname14, resolve as resolve14 } from "path";
|
|
277528
|
-
import { homedir as
|
|
277939
|
+
import { homedir as homedir11 } from "os";
|
|
277529
277940
|
import http3 from "http";
|
|
277530
277941
|
import { randomBytes as randomBytes4, randomUUID as randomUUID13, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
277531
277942
|
import { z as z70 } from "zod";
|
|
@@ -277534,11 +277945,11 @@ import { z as z70 } from "zod";
|
|
|
277534
277945
|
import picocolors18 from "picocolors";
|
|
277535
277946
|
|
|
277536
277947
|
// src/commands/customCommands.ts
|
|
277537
|
-
import { existsSync as existsSync17, readdirSync as
|
|
277948
|
+
import { existsSync as existsSync17, readdirSync as readdirSync8 } from "fs";
|
|
277538
277949
|
import { basename as basename4, extname as extname3, join as join16 } from "path";
|
|
277539
|
-
import { homedir as
|
|
277950
|
+
import { homedir as homedir9 } from "os";
|
|
277540
277951
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
277541
|
-
import { parse as
|
|
277952
|
+
import { parse as parse4 } from "yaml";
|
|
277542
277953
|
import { z as z51 } from "zod";
|
|
277543
277954
|
var CommandMetadataSchema = z51.object({
|
|
277544
277955
|
description: z51.string().max(240).optional(),
|
|
@@ -277559,7 +277970,7 @@ function parseLooseFrontmatter(raw) {
|
|
|
277559
277970
|
}
|
|
277560
277971
|
function parseCommandMetadata(raw) {
|
|
277561
277972
|
try {
|
|
277562
|
-
return
|
|
277973
|
+
return parse4(raw) || {};
|
|
277563
277974
|
} catch {
|
|
277564
277975
|
return parseLooseFrontmatter(raw);
|
|
277565
277976
|
}
|
|
@@ -277598,7 +278009,7 @@ function loadDirectory(directory, source) {
|
|
|
277598
278009
|
const current = queue.shift();
|
|
277599
278010
|
let entries;
|
|
277600
278011
|
try {
|
|
277601
|
-
entries =
|
|
278012
|
+
entries = readdirSync8(current, { withFileTypes: true });
|
|
277602
278013
|
} catch {
|
|
277603
278014
|
continue;
|
|
277604
278015
|
}
|
|
@@ -277633,7 +278044,7 @@ function loadCustomCommands(cwd, reservedNames = [], options = {}) {
|
|
|
277633
278044
|
Array.from(reservedNames, (name) => name.replace(/^\//, "").toLowerCase())
|
|
277634
278045
|
);
|
|
277635
278046
|
const merged = /* @__PURE__ */ new Map();
|
|
277636
|
-
const userHome = options.homeDir ||
|
|
278047
|
+
const userHome = options.homeDir || homedir9();
|
|
277637
278048
|
const builtinDirectory = options.builtinDir === false ? void 0 : options.builtinDir || resolveBundledCommandsDirectory();
|
|
277638
278049
|
if (builtinDirectory) {
|
|
277639
278050
|
mergeDirectory(merged, builtinDirectory, "builtin", reserved);
|
|
@@ -277751,8 +278162,8 @@ import { z as z58 } from "zod";
|
|
|
277751
278162
|
|
|
277752
278163
|
// src/runtime/AutocompleteCandidates.ts
|
|
277753
278164
|
import glob4 from "fast-glob";
|
|
277754
|
-
import { existsSync as existsSync18, readdirSync as
|
|
277755
|
-
import { homedir as
|
|
278165
|
+
import { existsSync as existsSync18, readdirSync as readdirSync9 } from "fs";
|
|
278166
|
+
import { homedir as homedir10 } from "os";
|
|
277756
278167
|
import { dirname as dirname10, join as join17, resolve as resolve9 } from "path";
|
|
277757
278168
|
import { z as z55 } from "zod";
|
|
277758
278169
|
var AUTOCOMPLETE_SYMBOL_INDEX_MAX_BYTES = 256 * 1024 * 1024;
|
|
@@ -277795,7 +278206,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
|
|
|
277795
278206
|
const symbols = [];
|
|
277796
278207
|
const sessions = [];
|
|
277797
278208
|
const normCwd = resolve9(cwd).toLowerCase().replace(/\\/g, "/");
|
|
277798
|
-
const normHome = resolve9(
|
|
278209
|
+
const normHome = resolve9(homedir10()).toLowerCase().replace(/\\/g, "/");
|
|
277799
278210
|
const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname10(normCwd) === normCwd;
|
|
277800
278211
|
if (isHomeOrRoot) {
|
|
277801
278212
|
return { commands, commandDetails, files, symbols, sessions };
|
|
@@ -277837,7 +278248,7 @@ async function getAutocompleteCandidates(cwd, config, mcpPromptCommands = []) {
|
|
|
277837
278248
|
config.session?.path ?? ".orbit/sessions"
|
|
277838
278249
|
);
|
|
277839
278250
|
if (existsSync18(sessionDir)) {
|
|
277840
|
-
for (const dir of
|
|
278251
|
+
for (const dir of readdirSync9(sessionDir)) {
|
|
277841
278252
|
if (existsSync18(join17(sessionDir, dir, "session.json"))) {
|
|
277842
278253
|
sessions.push(dir);
|
|
277843
278254
|
}
|
|
@@ -278051,6 +278462,8 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278051
278462
|
elements.inspectorClose.addEventListener('click', () => setInspector(false));
|
|
278052
278463
|
elements.inspectorBackdrop.addEventListener('click', () => setInspector(false));
|
|
278053
278464
|
elements.inspector.addEventListener('keydown', trapInspectorFocus);
|
|
278465
|
+
elements.sidebar.addEventListener('keydown', trapSidebarFocus);
|
|
278466
|
+
elements.commandPalette.addEventListener('keydown', trapCommandPaletteFocus);
|
|
278054
278467
|
elements.connectionState.addEventListener('click', () => {
|
|
278055
278468
|
if (!state.ready) void initialize();
|
|
278056
278469
|
});
|
|
@@ -278240,6 +278653,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278240
278653
|
if (state.projectLaunchPending && !force) return;
|
|
278241
278654
|
elements.projectDialog.hidden = true;
|
|
278242
278655
|
elements.projectDialog.setAttribute('aria-hidden', 'true');
|
|
278656
|
+
syncApplicationModalState();
|
|
278243
278657
|
if (restoreFocus && state.projectDialogReturnFocus) state.projectDialogReturnFocus.focus();
|
|
278244
278658
|
state.projectDialogReturnFocus = null;
|
|
278245
278659
|
};
|
|
@@ -278248,6 +278662,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278248
278662
|
state.projectDialogReturnFocus = document.activeElement;
|
|
278249
278663
|
elements.projectDialog.hidden = false;
|
|
278250
278664
|
elements.projectDialog.setAttribute('aria-hidden', 'false');
|
|
278665
|
+
syncApplicationModalState();
|
|
278251
278666
|
elements.projectPathInput.focus();
|
|
278252
278667
|
elements.projectPathInput.select();
|
|
278253
278668
|
};
|
|
@@ -278500,6 +278915,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278500
278915
|
if (elements.sessionDeleteDialog.hidden) return;
|
|
278501
278916
|
elements.sessionDeleteDialog.hidden = true;
|
|
278502
278917
|
elements.sessionDeleteDialog.setAttribute('aria-hidden', 'true');
|
|
278918
|
+
syncApplicationModalState();
|
|
278503
278919
|
state.pendingSessionDeleteId = null;
|
|
278504
278920
|
if (restoreFocus && state.sessionDeleteReturnFocus) state.sessionDeleteReturnFocus.focus();
|
|
278505
278921
|
state.sessionDeleteReturnFocus = null;
|
|
@@ -278512,6 +278928,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278512
278928
|
elements.sessionDeleteName.textContent = title && title.textContent || copy.untitledTask;
|
|
278513
278929
|
elements.sessionDeleteDialog.hidden = false;
|
|
278514
278930
|
elements.sessionDeleteDialog.setAttribute('aria-hidden', 'false');
|
|
278931
|
+
syncApplicationModalState();
|
|
278515
278932
|
elements.sessionDeleteConfirm.focus();
|
|
278516
278933
|
};
|
|
278517
278934
|
const handleSessionListClick = (event) => {
|
|
@@ -278586,7 +279003,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278586
279003
|
elements.fullAccessBackdrop.disabled = false;
|
|
278587
279004
|
elements.fullAccessCancel.disabled = false;
|
|
278588
279005
|
elements.fullAccessConfirm.disabled = false;
|
|
278589
|
-
|
|
279006
|
+
syncApplicationModalState();
|
|
278590
279007
|
state.fullAccessRequest = null;
|
|
278591
279008
|
if (restoreFocus && state.fullAccessReturnFocus) state.fullAccessReturnFocus.focus();
|
|
278592
279009
|
state.fullAccessReturnFocus = null;
|
|
@@ -278612,7 +279029,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
278612
279029
|
};
|
|
278613
279030
|
elements.fullAccessDialog.hidden = false;
|
|
278614
279031
|
elements.fullAccessDialog.setAttribute('aria-hidden', 'false');
|
|
278615
|
-
|
|
279032
|
+
syncApplicationModalState();
|
|
278616
279033
|
elements.fullAccessConfirm.focus();
|
|
278617
279034
|
return promise;
|
|
278618
279035
|
};
|
|
@@ -280611,6 +281028,11 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
280611
281028
|
elements.sidebarCollapseButton.setAttribute('aria-label', copy.collapseNavigation);
|
|
280612
281029
|
}
|
|
280613
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
|
+
|
|
280614
281036
|
function setDesktopSidebarCollapsed(collapsed) {
|
|
280615
281037
|
elements.appShell.classList.toggle('sidebar-collapsed', collapsed);
|
|
280616
281038
|
writeLocalStorage('orbit.webui.sidebar', collapsed ? 'collapsed' : 'expanded');
|
|
@@ -280645,8 +281067,14 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
280645
281067
|
elements.appShell.classList.add('sidebar-open');
|
|
280646
281068
|
elements.menuButton.setAttribute('aria-expanded', 'true');
|
|
280647
281069
|
syncSidebarInteractivity();
|
|
280648
|
-
const firstControl = elements.sidebar.
|
|
280649
|
-
|
|
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();
|
|
280650
281078
|
}
|
|
280651
281079
|
|
|
280652
281080
|
function setInspector(open, tab) {
|
|
@@ -280679,7 +281107,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
280679
281107
|
if (event.key !== 'Tab' || !elements.inspector.classList.contains('is-open')) return;
|
|
280680
281108
|
const focusable = Array.from(elements.inspector.querySelectorAll(
|
|
280681
281109
|
'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])',
|
|
280682
|
-
)).filter((node) => !node.hidden && node.
|
|
281110
|
+
)).filter((node) => !node.hidden && node.getClientRects().length > 0 && getComputedStyle(node).visibility !== 'hidden');
|
|
280683
281111
|
if (!focusable.length) {
|
|
280684
281112
|
event.preventDefault();
|
|
280685
281113
|
elements.inspector.focus();
|
|
@@ -280696,6 +281124,23 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
280696
281124
|
}
|
|
280697
281125
|
}
|
|
280698
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
|
+
|
|
280699
281144
|
function selectInspectorTab(tab) {
|
|
280700
281145
|
const tasks = tab === 'tasks';
|
|
280701
281146
|
const activity = tab === 'activity';
|
|
@@ -282239,7 +282684,7 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
|
|
|
282239
282684
|
paletteReturnFocus = document.activeElement;
|
|
282240
282685
|
elements.commandPalette.hidden = false;
|
|
282241
282686
|
elements.commandPalette.setAttribute('aria-hidden', 'false');
|
|
282242
|
-
|
|
282687
|
+
syncApplicationModalState();
|
|
282243
282688
|
elements.commandSearch.value = '';
|
|
282244
282689
|
paletteSelection = 0;
|
|
282245
282690
|
renderCommandPalette();
|
|
@@ -282250,12 +282695,29 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
|
|
|
282250
282695
|
if (elements.commandPalette.hidden) return;
|
|
282251
282696
|
elements.commandPalette.hidden = true;
|
|
282252
282697
|
elements.commandPalette.setAttribute('aria-hidden', 'true');
|
|
282253
|
-
|
|
282698
|
+
syncApplicationModalState();
|
|
282254
282699
|
const returnTarget = paletteReturnFocus;
|
|
282255
282700
|
paletteReturnFocus = null;
|
|
282256
282701
|
if (returnTarget && returnTarget.isConnected) returnTarget.focus();
|
|
282257
282702
|
}
|
|
282258
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
|
+
|
|
282259
282721
|
function executePaletteAction(index) {
|
|
282260
282722
|
const action = paletteActions[index];
|
|
282261
282723
|
if (!action || (action.idle && state.busy)) return;
|
|
@@ -283853,6 +284315,25 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
283853
284315
|
state.ready = true;
|
|
283854
284316
|
updateSendButtonState();
|
|
283855
284317
|
setConnection('connected', copy.connected);
|
|
284318
|
+
} else if (event.kind === 'replay_gap') {
|
|
284319
|
+
// The server retained only a bounded replay window. Reconcile the
|
|
284320
|
+
// authoritative snapshot immediately so a reconnect never leaves the
|
|
284321
|
+
// UI presenting a silently incomplete turn or session history.
|
|
284322
|
+
state.ready = false;
|
|
284323
|
+
updateSendButtonState();
|
|
284324
|
+
setConnection(
|
|
284325
|
+
'connecting',
|
|
284326
|
+
language === 'en'
|
|
284327
|
+
? 'Some events expired; syncing the latest state…'
|
|
284328
|
+
: chinese('部分事件已过期,正在同步最新状态…', '部分事件已過期,正在同步最新狀態…'),
|
|
284329
|
+
);
|
|
284330
|
+
void reconcileStatus().finally(() => {
|
|
284331
|
+
if (state.eventSource === source && state.ready === false) {
|
|
284332
|
+
state.ready = true;
|
|
284333
|
+
updateSendButtonState();
|
|
284334
|
+
setConnection('connected', copy.connected);
|
|
284335
|
+
}
|
|
284336
|
+
});
|
|
283856
284337
|
} else if (event.kind === 'turn_started') {
|
|
283857
284338
|
state.activeTurnId = event.turnId;
|
|
283858
284339
|
setBusy(true, copy.working);
|
|
@@ -285379,13 +285860,14 @@ var WebUiEventStream = class {
|
|
|
285379
285860
|
const payload = sanitizeWebEventPayload(event.type, event.payload);
|
|
285380
285861
|
if (payload === void 0) return;
|
|
285381
285862
|
const turn = this.getActiveTurn();
|
|
285863
|
+
const identity2 = extractEventIdentity(payload);
|
|
285382
285864
|
this.broadcast({
|
|
285383
285865
|
kind: "orbit_event",
|
|
285384
285866
|
schemaVersion: event.schemaVersion,
|
|
285385
285867
|
id: event.eventId,
|
|
285386
285868
|
timestamp: event.timestamp,
|
|
285387
|
-
turnId: turn?.id,
|
|
285388
|
-
sessionId: turn?.sessionId,
|
|
285869
|
+
turnId: identity2.turnId || turn?.id,
|
|
285870
|
+
sessionId: identity2.sessionId || turn?.sessionId,
|
|
285389
285871
|
type: event.type,
|
|
285390
285872
|
payload
|
|
285391
285873
|
});
|
|
@@ -285445,6 +285927,19 @@ var WebUiEventStream = class {
|
|
|
285445
285927
|
);
|
|
285446
285928
|
const lastEventId = parseLastEventId(req.headers?.["last-event-id"]);
|
|
285447
285929
|
if (lastEventId !== void 0) {
|
|
285930
|
+
const firstBufferedId = this.replayBuffer[0]?.id;
|
|
285931
|
+
if (firstBufferedId !== void 0 && lastEventId + 1 < firstBufferedId) {
|
|
285932
|
+
res.write(
|
|
285933
|
+
formatSseEvent({
|
|
285934
|
+
id: firstBufferedId - 1,
|
|
285935
|
+
event: {
|
|
285936
|
+
kind: "replay_gap",
|
|
285937
|
+
afterEventId: lastEventId,
|
|
285938
|
+
firstAvailableEventId: firstBufferedId
|
|
285939
|
+
}
|
|
285940
|
+
})
|
|
285941
|
+
);
|
|
285942
|
+
}
|
|
285448
285943
|
for (const entry of this.replayBuffer) {
|
|
285449
285944
|
if (entry.id > lastEventId) res.write(formatSseEvent(entry));
|
|
285450
285945
|
}
|
|
@@ -285501,6 +285996,15 @@ var WebUiEventStream = class {
|
|
|
285501
285996
|
if (destroy && !client.destroyed) client.destroy();
|
|
285502
285997
|
}
|
|
285503
285998
|
};
|
|
285999
|
+
function extractEventIdentity(payload) {
|
|
286000
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
286001
|
+
return {};
|
|
286002
|
+
}
|
|
286003
|
+
const record = payload;
|
|
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 };
|
|
286007
|
+
}
|
|
285504
286008
|
function parseLastEventId(value) {
|
|
285505
286009
|
const text2 = Array.isArray(value) ? value[0] : value;
|
|
285506
286010
|
if (!text2 || !/^\d+$/.test(text2)) return void 0;
|
|
@@ -286117,7 +286621,7 @@ function renderComposer(copy) {
|
|
|
286117
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>
|
|
286118
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>
|
|
286119
286623
|
<input id="attachmentInput" data-testid="attachment-input" type="file" accept="image/png,image/jpeg,image/gif,image/webp" multiple hidden />
|
|
286120
|
-
<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>
|
|
286121
286625
|
<div class="select-control composer-select-control" data-select-control>
|
|
286122
286626
|
<select class="native-select-proxy" id="permissionSelect" aria-label="${copy.permission}" tabindex="-1" aria-hidden="true" hidden>
|
|
286123
286627
|
<option value="strict">${copy.modeStrict}</option>
|
|
@@ -286921,6 +287425,7 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
|
|
|
286921
287425
|
}
|
|
286922
287426
|
|
|
286923
287427
|
.composer-tools {
|
|
287428
|
+
flex: 1 1 auto;
|
|
286924
287429
|
min-width: 0;
|
|
286925
287430
|
display: flex;
|
|
286926
287431
|
align-items: center;
|
|
@@ -286933,6 +287438,22 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
|
|
|
286933
287438
|
display: none;
|
|
286934
287439
|
}
|
|
286935
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
|
+
|
|
286936
287457
|
.composer-chip,
|
|
286937
287458
|
.composer-select-trigger {
|
|
286938
287459
|
height: 29px;
|
|
@@ -289630,6 +290151,7 @@ body {
|
|
|
289630
290151
|
width: 100%;
|
|
289631
290152
|
height: 100%;
|
|
289632
290153
|
overflow: hidden;
|
|
290154
|
+
overscroll-behavior: none;
|
|
289633
290155
|
}
|
|
289634
290156
|
|
|
289635
290157
|
body {
|
|
@@ -289812,7 +290334,10 @@ var WEB_UI_INSPECTOR_STYLES = String.raw`
|
|
|
289812
290334
|
|
|
289813
290335
|
.inspector-content {
|
|
289814
290336
|
min-height: 0;
|
|
290337
|
+
overflow-x: hidden;
|
|
289815
290338
|
overflow-y: auto;
|
|
290339
|
+
overscroll-behavior: contain;
|
|
290340
|
+
scrollbar-gutter: stable;
|
|
289816
290341
|
padding: 4px 17px 18px;
|
|
289817
290342
|
}
|
|
289818
290343
|
|
|
@@ -291598,12 +292123,13 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
|
|
|
291598
292123
|
}
|
|
291599
292124
|
|
|
291600
292125
|
.workspace-view {
|
|
291601
|
-
grid-template-rows: 54px auto minmax(0, 1fr);
|
|
292126
|
+
grid-template-rows: calc(54px + env(safe-area-inset-top)) auto minmax(0, 1fr);
|
|
291602
292127
|
}
|
|
291603
292128
|
|
|
291604
292129
|
.topbar {
|
|
291605
|
-
height: 54px;
|
|
292130
|
+
height: calc(54px + env(safe-area-inset-top));
|
|
291606
292131
|
padding: 0 10px;
|
|
292132
|
+
padding-top: env(safe-area-inset-top);
|
|
291607
292133
|
}
|
|
291608
292134
|
|
|
291609
292135
|
.workspace-heading span,
|
|
@@ -292116,6 +292642,8 @@ var WEB_UI_SELECT_STYLES = String.raw`
|
|
|
292116
292642
|
// src/runtime/webui/styles/WebUiShellStyles.ts
|
|
292117
292643
|
var WEB_UI_SHELL_STYLES = String.raw`
|
|
292118
292644
|
.app-shell {
|
|
292645
|
+
min-width: 0;
|
|
292646
|
+
min-height: 0;
|
|
292119
292647
|
height: 100vh;
|
|
292120
292648
|
height: 100dvh;
|
|
292121
292649
|
display: grid;
|
|
@@ -292998,6 +293526,7 @@ var WEB_UI_SHELL_STYLES = String.raw`
|
|
|
292998
293526
|
display: grid;
|
|
292999
293527
|
grid-template-rows: 62px auto minmax(0, 1fr);
|
|
293000
293528
|
overflow: hidden;
|
|
293529
|
+
scrollbar-gutter: stable;
|
|
293001
293530
|
background: var(--canvas);
|
|
293002
293531
|
border: 1px solid color-mix(in srgb, white 8%, var(--border-strong));
|
|
293003
293532
|
border-radius: 18px;
|
|
@@ -296459,7 +296988,7 @@ function copyBooleanCapability(source, sourceKey, target, targetKey) {
|
|
|
296459
296988
|
// src/runtime/ProjectLauncher.ts
|
|
296460
296989
|
import { spawn as spawn4 } from "child_process";
|
|
296461
296990
|
import { existsSync as existsSync21, mkdirSync as mkdirSync7, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
|
|
296462
|
-
import { dirname as dirname13, isAbsolute as isAbsolute8, parse as
|
|
296991
|
+
import { dirname as dirname13, isAbsolute as isAbsolute8, parse as parse5, resolve as resolve13 } from "path";
|
|
296463
296992
|
var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
|
|
296464
296993
|
var ProjectLaunchError = class extends Error {
|
|
296465
296994
|
constructor(code, message2, options) {
|
|
@@ -296628,7 +297157,7 @@ function requireProjectDirectory(projectPath) {
|
|
|
296628
297157
|
}
|
|
296629
297158
|
function rejectFilesystemRoot(projectPath) {
|
|
296630
297159
|
const normalized = resolve13(projectPath);
|
|
296631
|
-
if (normalized ===
|
|
297160
|
+
if (normalized === parse5(normalized).root) {
|
|
296632
297161
|
throw new ProjectLaunchError(
|
|
296633
297162
|
"filesystem_root",
|
|
296634
297163
|
"A filesystem root cannot be opened as an Orbit project."
|
|
@@ -297764,7 +298293,8 @@ var CommandRouter = class {
|
|
|
297764
298293
|
if (shellResult) return shellResult;
|
|
297765
298294
|
if (trimmed.startsWith("/")) {
|
|
297766
298295
|
const parts = trimmed.split(" ");
|
|
297767
|
-
const
|
|
298296
|
+
const rawCommand = parts[0].toLowerCase();
|
|
298297
|
+
const command = rawCommand === "/permissions" ? "/mode" : rawCommand;
|
|
297768
298298
|
const queueResult = handleInputQueueCommand(
|
|
297769
298299
|
command,
|
|
297770
298300
|
parts.slice(1).join(" ").trim(),
|
|
@@ -299936,7 +300466,7 @@ Risk Warning: ${reason}`);
|
|
|
299936
300466
|
return new RegExp(finalPattern);
|
|
299937
300467
|
});
|
|
299938
300468
|
const normCwd = resolve14(this.cwd).toLowerCase().replace(/\\/g, "/");
|
|
299939
|
-
const normHome = resolve14(
|
|
300469
|
+
const normHome = resolve14(homedir11()).toLowerCase().replace(/\\/g, "/");
|
|
299940
300470
|
const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname14(normCwd) === normCwd;
|
|
299941
300471
|
if (!isHomeOrRoot) {
|
|
299942
300472
|
const indexer = new SymbolIndexer(this.cwd);
|
|
@@ -300312,6 +300842,15 @@ function getExplicitProviderOverride(cliOverrides) {
|
|
|
300312
300842
|
const normalized = selected.trim();
|
|
300313
300843
|
return normalized || void 0;
|
|
300314
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
|
+
}
|
|
300315
300854
|
function applyStoredRuntimeSelection(config, localState, cliOverrides) {
|
|
300316
300855
|
if (shouldUseStoredProvider(cliOverrides) && localState.lastProvider && config.providers[localState.lastProvider]) {
|
|
300317
300856
|
config.provider.default = localState.lastProvider;
|
|
@@ -300348,6 +300887,8 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
|
|
|
300348
300887
|
}
|
|
300349
300888
|
const config = ConfigLoader.loadSync(cwd, cliOverrides);
|
|
300350
300889
|
const explicitModelOverride = getExplicitModelOverride(cliOverrides);
|
|
300890
|
+
const explicitProviderOverride = getExplicitProviderOverride(cliOverrides);
|
|
300891
|
+
const explicitAgentProfileOverride = getExplicitAgentProfileOverride(cliOverrides);
|
|
300351
300892
|
applyStoredRuntimeSelection(
|
|
300352
300893
|
config,
|
|
300353
300894
|
readLocalRuntimeState(cwd),
|
|
@@ -300367,6 +300908,66 @@ async function runAgent(cwd, task, cliOverrides, multi, options) {
|
|
|
300367
300908
|
);
|
|
300368
300909
|
}
|
|
300369
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
|
+
}
|
|
300370
300971
|
let providerInstance;
|
|
300371
300972
|
try {
|
|
300372
300973
|
providerInstance = createProviderFromConfig(config);
|
|
@@ -300431,6 +301032,11 @@ Risk Warning: ${reason}`);
|
|
|
300431
301032
|
};
|
|
300432
301033
|
const activeTask = task;
|
|
300433
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
|
+
}
|
|
300434
301040
|
const controller = new ReplController(
|
|
300435
301041
|
cwd,
|
|
300436
301042
|
config,
|
|
@@ -300449,7 +301055,8 @@ Risk Warning: ${reason}`);
|
|
|
300449
301055
|
config,
|
|
300450
301056
|
providerInstance,
|
|
300451
301057
|
activeTask,
|
|
300452
|
-
interaction
|
|
301058
|
+
interaction,
|
|
301059
|
+
selectedProfile
|
|
300453
301060
|
);
|
|
300454
301061
|
return await orchestrator.run();
|
|
300455
301062
|
} else {
|
|
@@ -300467,7 +301074,12 @@ Risk Warning: ${reason}`);
|
|
|
300467
301074
|
requireSession: Boolean(options?.resumeSessionId),
|
|
300468
301075
|
disableStatusBar: !!options?.nonInteractive || !!options?.jsonl,
|
|
300469
301076
|
nonInteractive: !!options?.nonInteractive,
|
|
300470
|
-
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
|
|
300471
301083
|
}
|
|
300472
301084
|
);
|
|
300473
301085
|
return await loop.run();
|
|
@@ -301396,6 +302008,88 @@ async function runSkillsCommand(action, options = {}) {
|
|
|
301396
302008
|
return 0;
|
|
301397
302009
|
}
|
|
301398
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
|
+
|
|
301399
302093
|
// src/commands/trace.ts
|
|
301400
302094
|
import {
|
|
301401
302095
|
existsSync as existsSync28,
|
|
@@ -301463,7 +302157,7 @@ import {
|
|
|
301463
302157
|
import { basename as basename5, dirname as dirname16, join as join19 } from "path";
|
|
301464
302158
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
301465
302159
|
import { promisify as promisify5 } from "util";
|
|
301466
|
-
import
|
|
302160
|
+
import picocolors26 from "picocolors";
|
|
301467
302161
|
import { parse as parseYaml4 } from "yaml";
|
|
301468
302162
|
import { z as z76 } from "zod";
|
|
301469
302163
|
var exec5 = promisify5(execCallback);
|
|
@@ -301497,7 +302191,7 @@ async function runEval(cwd, suiteFile, options = {}) {
|
|
|
301497
302191
|
const results = [];
|
|
301498
302192
|
for (const task of tasks) {
|
|
301499
302193
|
if (!value.json) {
|
|
301500
|
-
console.log(
|
|
302194
|
+
console.log(picocolors26.cyan(`\u25CF Evaluating ${task.id}...`));
|
|
301501
302195
|
}
|
|
301502
302196
|
let worktree;
|
|
301503
302197
|
const taskStartedAt = Date.now();
|
|
@@ -301651,13 +302345,13 @@ async function runEval(cwd, suiteFile, options = {}) {
|
|
|
301651
302345
|
console.log(JSON.stringify(report, null, 2));
|
|
301652
302346
|
} else {
|
|
301653
302347
|
console.log(
|
|
301654
|
-
report.passed ?
|
|
302348
|
+
report.passed ? picocolors26.green(
|
|
301655
302349
|
`\u2714 Acceptance passed: ${passedTasks}/${results.length} tasks.`
|
|
301656
|
-
) :
|
|
302350
|
+
) : picocolors26.red(
|
|
301657
302351
|
`\u2716 Acceptance failed: ${passedTasks}/${results.length} tasks passed.`
|
|
301658
302352
|
)
|
|
301659
302353
|
);
|
|
301660
|
-
console.log(
|
|
302354
|
+
console.log(picocolors26.gray(`Report: ${reportPath}`));
|
|
301661
302355
|
}
|
|
301662
302356
|
if (!report.passed) process.exitCode = 1;
|
|
301663
302357
|
return report;
|
|
@@ -301904,25 +302598,25 @@ function safeSummary(value) {
|
|
|
301904
302598
|
|
|
301905
302599
|
// src/commands/clean.ts
|
|
301906
302600
|
import readline6 from "readline";
|
|
301907
|
-
import
|
|
302601
|
+
import picocolors27 from "picocolors";
|
|
301908
302602
|
import { resolve as resolve17 } from "path";
|
|
301909
302603
|
import { z as z78 } from "zod";
|
|
301910
302604
|
|
|
301911
302605
|
// src/runtime/CleanupManager.ts
|
|
301912
302606
|
import {
|
|
301913
302607
|
lstatSync as lstatSync10,
|
|
301914
|
-
readdirSync as
|
|
302608
|
+
readdirSync as readdirSync10,
|
|
301915
302609
|
realpathSync as realpathSync4,
|
|
301916
302610
|
rmSync as rmSync9,
|
|
301917
302611
|
unlinkSync as unlinkSync6
|
|
301918
302612
|
} from "fs";
|
|
301919
|
-
import { homedir as
|
|
301920
|
-
import { basename as basename6, join as join20, parse as
|
|
302613
|
+
import { homedir as homedir12 } from "os";
|
|
302614
|
+
import { basename as basename6, join as join20, parse as parse6, resolve as resolve16 } from "path";
|
|
301921
302615
|
import { z as z77 } from "zod";
|
|
301922
302616
|
var CleanupScopeSchema = z77.enum(["user", "project"]);
|
|
301923
302617
|
function buildCleanupPlan(options) {
|
|
301924
302618
|
const scopes = z77.array(CleanupScopeSchema).min(1).parse(options.scopes);
|
|
301925
|
-
const homeDirectory = resolve16(options.homeDirectory ??
|
|
302619
|
+
const homeDirectory = resolve16(options.homeDirectory ?? homedir12());
|
|
301926
302620
|
const projectDirectory = resolve16(options.projectDirectory ?? options.cwd);
|
|
301927
302621
|
const candidates = scopes.map((scope) => ({
|
|
301928
302622
|
scope,
|
|
@@ -302031,7 +302725,7 @@ function inspectPath(targetPath) {
|
|
|
302031
302725
|
}
|
|
302032
302726
|
totals.directories++;
|
|
302033
302727
|
try {
|
|
302034
|
-
for (const entry of
|
|
302728
|
+
for (const entry of readdirSync10(currentPath)) {
|
|
302035
302729
|
visit(join20(currentPath, entry));
|
|
302036
302730
|
}
|
|
302037
302731
|
} catch (error) {
|
|
@@ -302043,21 +302737,21 @@ function inspectPath(targetPath) {
|
|
|
302043
302737
|
}
|
|
302044
302738
|
function assertSafeOrbitDataPath(targetPath) {
|
|
302045
302739
|
const absolutePath = resolve16(targetPath);
|
|
302046
|
-
if (absolutePath ===
|
|
302740
|
+
if (absolutePath === parse6(absolutePath).root) {
|
|
302047
302741
|
throw new Error("Refusing to clean a filesystem root.");
|
|
302048
302742
|
}
|
|
302049
302743
|
if (basename6(absolutePath).toLowerCase() !== ".orbit") {
|
|
302050
302744
|
throw new Error("Cleanup targets must be an Orbit data directory.");
|
|
302051
302745
|
}
|
|
302052
302746
|
const parentPath = resolve16(absolutePath, "..");
|
|
302053
|
-
if (parentPath ===
|
|
302747
|
+
if (parentPath === parse6(absolutePath).root) {
|
|
302054
302748
|
throw new Error(
|
|
302055
302749
|
"Refusing to clean an Orbit directory directly under a filesystem root."
|
|
302056
302750
|
);
|
|
302057
302751
|
}
|
|
302058
302752
|
try {
|
|
302059
302753
|
const canonicalParent = realpathSync4.native(parentPath);
|
|
302060
|
-
if (canonicalParent ===
|
|
302754
|
+
if (canonicalParent === parse6(canonicalParent).root) {
|
|
302061
302755
|
throw new Error(
|
|
302062
302756
|
"Refusing to clean an Orbit directory through a filesystem-root link."
|
|
302063
302757
|
);
|
|
@@ -302121,7 +302815,7 @@ async function runClean(cwd, rawOptions, dependencies = {}) {
|
|
|
302121
302815
|
);
|
|
302122
302816
|
}
|
|
302123
302817
|
if (!confirmed) {
|
|
302124
|
-
if (!options.json) write(
|
|
302818
|
+
if (!options.json) write(picocolors27.yellow("\u26A0 Cleanup cancelled."));
|
|
302125
302819
|
return { applied: false, plan, removed: [], skipped: [] };
|
|
302126
302820
|
}
|
|
302127
302821
|
const userTarget = plan.targets.find(
|
|
@@ -302143,7 +302837,7 @@ async function runClean(cwd, rawOptions, dependencies = {}) {
|
|
|
302143
302837
|
);
|
|
302144
302838
|
} else {
|
|
302145
302839
|
write(
|
|
302146
|
-
|
|
302840
|
+
picocolors27.green(
|
|
302147
302841
|
`\u2714 Removed ${result.removed.length} Orbit data director${result.removed.length === 1 ? "y" : "ies"}.`
|
|
302148
302842
|
)
|
|
302149
302843
|
);
|
|
@@ -302160,18 +302854,18 @@ function resolveScopes(options) {
|
|
|
302160
302854
|
return scopes;
|
|
302161
302855
|
}
|
|
302162
302856
|
function printCleanupPlan(plan, write) {
|
|
302163
|
-
write(
|
|
302857
|
+
write(picocolors27.bold("\nOrbit cleanup preview\n"));
|
|
302164
302858
|
for (const target of plan.targets) {
|
|
302165
302859
|
const scope = target.scopes.join(" + ");
|
|
302166
302860
|
const status = target.exists ? `${target.files} files \xB7 ${target.directories} directories \xB7 ${formatBytes(target.bytes)}` : "not present";
|
|
302167
302861
|
write(` ${target.exists ? "\u25CF" : "\u25CB"} ${scope}: ${target.path}`);
|
|
302168
|
-
write(` ${
|
|
302862
|
+
write(` ${picocolors27.gray(status)}`);
|
|
302169
302863
|
for (const warning2 of target.warnings) {
|
|
302170
|
-
write(` ${
|
|
302864
|
+
write(` ${picocolors27.yellow(`\u26A0 ${warning2}`)}`);
|
|
302171
302865
|
}
|
|
302172
302866
|
}
|
|
302173
302867
|
write(
|
|
302174
|
-
|
|
302868
|
+
picocolors27.gray(
|
|
302175
302869
|
"\nOnly .orbit data directories are included. Project source, ORBIT.md, and orbit.config.yaml are preserved."
|
|
302176
302870
|
)
|
|
302177
302871
|
);
|
|
@@ -302198,7 +302892,7 @@ async function confirmDeletion(prompt) {
|
|
|
302198
302892
|
|
|
302199
302893
|
// src/commands/backup.ts
|
|
302200
302894
|
import { basename as basename7, resolve as resolve19 } from "path";
|
|
302201
|
-
import
|
|
302895
|
+
import picocolors28 from "picocolors";
|
|
302202
302896
|
import { z as z80 } from "zod";
|
|
302203
302897
|
|
|
302204
302898
|
// src/runtime/ProjectBackup.ts
|
|
@@ -302206,7 +302900,7 @@ import {
|
|
|
302206
302900
|
existsSync as existsSync30,
|
|
302207
302901
|
lstatSync as lstatSync11,
|
|
302208
302902
|
mkdirSync as mkdirSync10,
|
|
302209
|
-
readdirSync as
|
|
302903
|
+
readdirSync as readdirSync11,
|
|
302210
302904
|
renameSync as renameSync8,
|
|
302211
302905
|
rmSync as rmSync10,
|
|
302212
302906
|
writeFileSync as writeFileSync10
|
|
@@ -302390,7 +303084,7 @@ function listBackupFiles(root) {
|
|
|
302390
303084
|
`Project backup tree exceeds ${MAX_BACKUP_TREE_DEPTH} directory levels.`
|
|
302391
303085
|
);
|
|
302392
303086
|
}
|
|
302393
|
-
for (const name of
|
|
303087
|
+
for (const name of readdirSync11(directory).sort()) {
|
|
302394
303088
|
visitedEntries += 1;
|
|
302395
303089
|
if (visitedEntries > MAX_BACKUP_TREE_ENTRIES) {
|
|
302396
303090
|
throw new Error(
|
|
@@ -302510,12 +303204,12 @@ function runBackupCreate(cwd, rawOptions = {}) {
|
|
|
302510
303204
|
);
|
|
302511
303205
|
} else {
|
|
302512
303206
|
console.log(
|
|
302513
|
-
|
|
303207
|
+
picocolors28.green(
|
|
302514
303208
|
`\u2714 Backed up ${bundle.files.length} durable project file(s) to ${outputPath}`
|
|
302515
303209
|
)
|
|
302516
303210
|
);
|
|
302517
303211
|
console.log(
|
|
302518
|
-
|
|
303212
|
+
picocolors28.gray(
|
|
302519
303213
|
" Regenerable caches, temporary state, exports, and credentials were excluded."
|
|
302520
303214
|
)
|
|
302521
303215
|
);
|
|
@@ -302533,7 +303227,7 @@ function runBackupInspect(input, options = {}) {
|
|
|
302533
303227
|
};
|
|
302534
303228
|
if (options.json) console.log(JSON.stringify(summary));
|
|
302535
303229
|
else {
|
|
302536
|
-
console.log(
|
|
303230
|
+
console.log(picocolors28.bold(`
|
|
302537
303231
|
${basename7(input)}
|
|
302538
303232
|
`));
|
|
302539
303233
|
console.log(` Project: ${summary.sourceName}`);
|
|
@@ -302541,7 +303235,7 @@ ${basename7(input)}
|
|
|
302541
303235
|
console.log(
|
|
302542
303236
|
` Content: ${summary.files} files \xB7 ${formatBytes3(summary.bytes)}`
|
|
302543
303237
|
);
|
|
302544
|
-
console.log(
|
|
303238
|
+
console.log(picocolors28.green(" \u2714 Integrity verified"));
|
|
302545
303239
|
}
|
|
302546
303240
|
}
|
|
302547
303241
|
function runBackupRestore(cwd, input, options = {}) {
|
|
@@ -302551,13 +303245,13 @@ function runBackupRestore(cwd, input, options = {}) {
|
|
|
302551
303245
|
console.log(JSON.stringify({ schemaVersion: 1, ...result }));
|
|
302552
303246
|
} else {
|
|
302553
303247
|
console.log(
|
|
302554
|
-
|
|
303248
|
+
picocolors28.green(
|
|
302555
303249
|
`\u2714 Restored ${result.restored.length} project file(s) from ${resolve19(input)}`
|
|
302556
303250
|
)
|
|
302557
303251
|
);
|
|
302558
303252
|
if (result.conflicts.length > 0) {
|
|
302559
303253
|
console.log(
|
|
302560
|
-
|
|
303254
|
+
picocolors28.yellow(
|
|
302561
303255
|
` Replaced ${result.conflicts.length} existing file(s) because --force was supplied.`
|
|
302562
303256
|
)
|
|
302563
303257
|
);
|
|
@@ -302574,21 +303268,21 @@ function formatBytes3(bytes) {
|
|
|
302574
303268
|
}
|
|
302575
303269
|
|
|
302576
303270
|
// src/commands/extension.ts
|
|
302577
|
-
import
|
|
303271
|
+
import picocolors29 from "picocolors";
|
|
302578
303272
|
|
|
302579
303273
|
// src/runtime/ExtensionManager.ts
|
|
302580
303274
|
import {
|
|
302581
303275
|
existsSync as existsSync31,
|
|
302582
303276
|
lstatSync as lstatSync12,
|
|
302583
303277
|
mkdirSync as mkdirSync11,
|
|
302584
|
-
readdirSync as
|
|
303278
|
+
readdirSync as readdirSync12,
|
|
302585
303279
|
renameSync as renameSync9,
|
|
302586
303280
|
rmSync as rmSync11,
|
|
302587
303281
|
writeFileSync as writeFileSync11
|
|
302588
303282
|
} from "fs";
|
|
302589
303283
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
302590
303284
|
import { dirname as dirname18, isAbsolute as isAbsolute10, join as join26, relative as relative11, resolve as resolve20, sep as sep3 } from "path";
|
|
302591
|
-
import { homedir as
|
|
303285
|
+
import { homedir as homedir13 } from "os";
|
|
302592
303286
|
import { z as z81 } from "zod";
|
|
302593
303287
|
var InstalledExtensionSchema2 = z81.object({
|
|
302594
303288
|
id: InstalledExtensionIdSchema,
|
|
@@ -302609,7 +303303,7 @@ var ExtensionManager = class {
|
|
|
302609
303303
|
orbitDir;
|
|
302610
303304
|
extensionsDir;
|
|
302611
303305
|
registryPath;
|
|
302612
|
-
constructor(homeDirectory =
|
|
303306
|
+
constructor(homeDirectory = homedir13()) {
|
|
302613
303307
|
this.orbitDir = join26(homeDirectory, ".orbit");
|
|
302614
303308
|
this.extensionsDir = join26(this.orbitDir, "extensions");
|
|
302615
303309
|
this.registryPath = join26(this.orbitDir, "extensions.json");
|
|
@@ -302929,7 +303623,7 @@ function copyDirectoryEntry(source, target, budget, depth) {
|
|
|
302929
303623
|
throw new Error("Extension directories cannot contain symlinks.");
|
|
302930
303624
|
if (stats.isDirectory()) {
|
|
302931
303625
|
mkdirSync11(target, { recursive: true });
|
|
302932
|
-
for (const entry of
|
|
303626
|
+
for (const entry of readdirSync12(source)) {
|
|
302933
303627
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
302934
303628
|
copyDirectoryEntry(
|
|
302935
303629
|
join26(source, entry),
|
|
@@ -302987,9 +303681,9 @@ function verifyOrbitCompatibility(manifest, currentVersion) {
|
|
|
302987
303681
|
}
|
|
302988
303682
|
}
|
|
302989
303683
|
function compareVersions(left, right) {
|
|
302990
|
-
const
|
|
302991
|
-
const a2 =
|
|
302992
|
-
const b =
|
|
303684
|
+
const parse7 = (value) => value.split("-", 1)[0].split(".").map(Number);
|
|
303685
|
+
const a2 = parse7(left);
|
|
303686
|
+
const b = parse7(right);
|
|
302993
303687
|
for (let index = 0; index < 3; index += 1) {
|
|
302994
303688
|
if ((a2[index] || 0) !== (b[index] || 0))
|
|
302995
303689
|
return (a2[index] || 0) - (b[index] || 0);
|
|
@@ -303009,12 +303703,12 @@ function validateExtension(cwd, manifestPath, options = {}) {
|
|
|
303009
303703
|
0
|
|
303010
303704
|
);
|
|
303011
303705
|
console.log(
|
|
303012
|
-
|
|
303706
|
+
picocolors29.green(
|
|
303013
303707
|
`\u2714 Extension manifest is valid: ${manifest.displayName} ${manifest.version}`
|
|
303014
303708
|
)
|
|
303015
303709
|
);
|
|
303016
303710
|
console.log(
|
|
303017
|
-
|
|
303711
|
+
picocolors29.gray(
|
|
303018
303712
|
` ${manifest.id} \xB7 ${contributionCount} contribution(s) \xB7 process=${manifest.permissions.process}`
|
|
303019
303713
|
)
|
|
303020
303714
|
);
|
|
@@ -303023,12 +303717,12 @@ function validateExtension(cwd, manifestPath, options = {}) {
|
|
|
303023
303717
|
function installExtension(cwd, manifestPath, options = {}) {
|
|
303024
303718
|
const installed = new ExtensionManager().install(cwd, manifestPath, options);
|
|
303025
303719
|
console.log(
|
|
303026
|
-
|
|
303720
|
+
picocolors29.green(
|
|
303027
303721
|
`\u2714 Installed extension: ${installed.displayName} ${installed.version}`
|
|
303028
303722
|
)
|
|
303029
303723
|
);
|
|
303030
303724
|
console.log(
|
|
303031
|
-
|
|
303725
|
+
picocolors29.gray(
|
|
303032
303726
|
` ${installed.id} \xB7 sha256:${installed.digest.slice(0, 16)}\u2026`
|
|
303033
303727
|
)
|
|
303034
303728
|
);
|
|
@@ -303040,24 +303734,24 @@ function listExtensions(options = {}) {
|
|
|
303040
303734
|
return;
|
|
303041
303735
|
}
|
|
303042
303736
|
if (!extensions.length) {
|
|
303043
|
-
console.log(
|
|
303737
|
+
console.log(picocolors29.gray("No Orbit extensions are installed."));
|
|
303044
303738
|
return;
|
|
303045
303739
|
}
|
|
303046
303740
|
for (const extension of extensions) {
|
|
303047
303741
|
console.log(
|
|
303048
|
-
`${
|
|
303742
|
+
`${picocolors29.green("\u25CF")} ${extension.displayName} ${extension.version} ${picocolors29.gray(`(${extension.id})`)}`
|
|
303049
303743
|
);
|
|
303050
303744
|
}
|
|
303051
303745
|
}
|
|
303052
303746
|
function removeExtension(id) {
|
|
303053
303747
|
const removed = new ExtensionManager().remove(id);
|
|
303054
303748
|
console.log(
|
|
303055
|
-
removed ?
|
|
303749
|
+
removed ? picocolors29.green(`\u2714 Removed extension: ${id}`) : picocolors29.yellow(`Extension is not installed: ${id}`)
|
|
303056
303750
|
);
|
|
303057
303751
|
}
|
|
303058
303752
|
|
|
303059
303753
|
// src/index.ts
|
|
303060
|
-
import { existsSync as
|
|
303754
|
+
import { existsSync as existsSync36, realpathSync as realpathSync5, statSync as statSync6 } from "fs";
|
|
303061
303755
|
import { resolve as resolve21 } from "path";
|
|
303062
303756
|
|
|
303063
303757
|
// src/runtime/CliRunOverrides.ts
|
|
@@ -303069,6 +303763,9 @@ function createCliRunOverrides(options) {
|
|
|
303069
303763
|
if (options.model) {
|
|
303070
303764
|
overrides.models = { default: options.model };
|
|
303071
303765
|
}
|
|
303766
|
+
if (options.agentProfile) {
|
|
303767
|
+
overrides.agentProfile = options.agentProfile;
|
|
303768
|
+
}
|
|
303072
303769
|
if (options.direct) {
|
|
303073
303770
|
overrides.direct = true;
|
|
303074
303771
|
}
|
|
@@ -303085,6 +303782,9 @@ function applyOutcomeExitCode(outcome) {
|
|
|
303085
303782
|
process.exitCode = Math.max(currentExitCode, exitCodeForOutcome(outcome));
|
|
303086
303783
|
}
|
|
303087
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(
|
|
303088
303788
|
"--yes",
|
|
303089
303789
|
"enable unrestricted Full Access and approve every enabled tool action"
|
|
303090
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) => {
|
|
@@ -303095,7 +303795,9 @@ program.name("orbit").description("Orbit - Local AI Coding Agent Runtime").versi
|
|
|
303095
303795
|
direct: !!options.direct,
|
|
303096
303796
|
fullAccess: !!options.yes
|
|
303097
303797
|
});
|
|
303098
|
-
const outcome = await runAgent(cwd, task, overrides, !!options.multi
|
|
303798
|
+
const outcome = await runAgent(cwd, task, overrides, !!options.multi, {
|
|
303799
|
+
agentProfile: options.agentProfile
|
|
303800
|
+
});
|
|
303099
303801
|
applyOutcomeExitCode(outcome);
|
|
303100
303802
|
});
|
|
303101
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) => {
|
|
@@ -303175,11 +303877,18 @@ skillsCommand.command("validate").description("validate SKILL.md files; non-zero
|
|
|
303175
303877
|
});
|
|
303176
303878
|
}
|
|
303177
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
|
+
});
|
|
303178
303887
|
var mcpCommand = program.command("mcp").description("manage Model Context Protocol servers");
|
|
303179
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) => {
|
|
303180
303889
|
const port = options.port ? Number.parseInt(options.port, 10) : void 0;
|
|
303181
303890
|
if (options.port && (!Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
303182
|
-
console.error(
|
|
303891
|
+
console.error(picocolors30.red("\u2716 --port must be an integer in 1-65535."));
|
|
303183
303892
|
process.exitCode = 1;
|
|
303184
303893
|
return;
|
|
303185
303894
|
}
|
|
@@ -303305,7 +304014,7 @@ program.command("webui").description("start Orbit as a browser-first local codin
|
|
|
303305
304014
|
fullAccess: !!options.yes
|
|
303306
304015
|
});
|
|
303307
304016
|
const requestedCwd = resolve21(localOptions.cwd || process.cwd());
|
|
303308
|
-
if (!
|
|
304017
|
+
if (!existsSync36(requestedCwd) || !statSync6(requestedCwd).isDirectory()) {
|
|
303309
304018
|
throw new Error(
|
|
303310
304019
|
`Web UI project directory does not exist: ${requestedCwd}`
|
|
303311
304020
|
);
|
|
@@ -303316,7 +304025,10 @@ program.command("webui").description("start Orbit as a browser-first local codin
|
|
|
303316
304025
|
});
|
|
303317
304026
|
applyOutcomeExitCode(outcome);
|
|
303318
304027
|
});
|
|
303319
|
-
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(
|
|
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) => {
|
|
303320
304032
|
const options = { ...command.optsWithGlobals(), ...localOptions };
|
|
303321
304033
|
const cwd = process.cwd();
|
|
303322
304034
|
const overrides = createCliRunOverrides({
|
|
@@ -303327,7 +304039,8 @@ program.command("exec").description("run a task in non-interactive mode and stre
|
|
|
303327
304039
|
const outcome = await runAgent(cwd, prompt, overrides, false, {
|
|
303328
304040
|
nonInteractive: true,
|
|
303329
304041
|
jsonl: !!options.jsonl,
|
|
303330
|
-
resumeSessionId: options.resume
|
|
304042
|
+
resumeSessionId: options.resume,
|
|
304043
|
+
agentProfile: options.agentProfile
|
|
303331
304044
|
});
|
|
303332
304045
|
applyOutcomeExitCode(outcome);
|
|
303333
304046
|
});
|
|
@@ -303336,7 +304049,7 @@ try {
|
|
|
303336
304049
|
} catch (error) {
|
|
303337
304050
|
const message2 = error instanceof Error ? error.message : String(error);
|
|
303338
304051
|
console.error(
|
|
303339
|
-
|
|
304052
|
+
picocolors30.red(`\u2716 Orbit command failed: ${redactSecrets(message2)}`)
|
|
303340
304053
|
);
|
|
303341
304054
|
process.exitCode = 1;
|
|
303342
304055
|
}
|