nexrall-code 0.5.110 → 0.5.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +234 -129
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3182,12 +3182,11 @@ var require_auth = __commonJS({
3182
3182
  exports2.saveAuth = saveAuth2;
3183
3183
  exports2.loadAuth = loadAuth2;
3184
3184
  exports2.clearAuth = clearAuth2;
3185
- exports2.isAuthenticated = isAuthenticated3;
3185
+ exports2.isAuthenticated = isAuthenticated4;
3186
3186
  exports2.getToken = getToken;
3187
3187
  exports2.getRefreshToken = getRefreshToken;
3188
3188
  exports2.updateTokens = updateTokens;
3189
- exports2.getBillingTeamId = getBillingTeamId;
3190
- exports2.setBillingTeamId = setBillingTeamId;
3189
+ exports2.getBillingTeamOverride = getBillingTeamOverride;
3191
3190
  var fs9 = __importStar(__require("fs"));
3192
3191
  var path8 = __importStar(__require("path"));
3193
3192
  var os6 = __importStar(__require("os"));
@@ -3229,7 +3228,7 @@ var require_auth = __commonJS({
3229
3228
  } catch {
3230
3229
  }
3231
3230
  }
3232
- function isAuthenticated3() {
3231
+ function isAuthenticated4() {
3233
3232
  const auth = loadAuth2();
3234
3233
  return auth !== null && auth.token.length > 0;
3235
3234
  }
@@ -3265,29 +3264,21 @@ var require_auth = __commonJS({
3265
3264
  };
3266
3265
  fs9.writeFileSync(CONFIG_FILE, JSON.stringify(next, null, 2), { mode: 384 });
3267
3266
  }
3268
- function getBillingTeamId() {
3269
- const auth = loadAuth2();
3270
- const v = auth?.billingTeamId;
3271
- return typeof v === "number" && Number.isSafeInteger(v) && v > 0 ? v : null;
3272
- }
3273
- function setBillingTeamId(teamId) {
3274
- let existing = {};
3275
- try {
3276
- if (fs9.existsSync(CONFIG_FILE)) {
3277
- const parsed = JSON.parse(fs9.readFileSync(CONFIG_FILE, "utf-8"));
3278
- if (typeof parsed === "object" && parsed !== null)
3279
- existing = parsed;
3267
+ function getBillingTeamOverride() {
3268
+ const raw = process.env.NEXRALL_BILLING_TEAM;
3269
+ if (raw != null && raw !== "") {
3270
+ const trimmed = raw.trim();
3271
+ if (/^(personal|null|0)$/i.test(trimmed))
3272
+ return null;
3273
+ if (/^\d+$/.test(trimmed)) {
3274
+ const n = Number(trimmed);
3275
+ if (Number.isSafeInteger(n) && n > 0)
3276
+ return n;
3280
3277
  }
3281
- } catch {
3282
3278
  }
3283
- ensureConfigDir();
3284
- const next = { ...existing };
3285
- if (typeof teamId === "number" && Number.isSafeInteger(teamId) && teamId > 0) {
3286
- next.billingTeamId = teamId;
3287
- } else {
3288
- delete next.billingTeamId;
3289
- }
3290
- fs9.writeFileSync(CONFIG_FILE, JSON.stringify(next, null, 2), { mode: 384 });
3279
+ if (process.env.NEXRALL_TOKEN)
3280
+ return null;
3281
+ return void 0;
3291
3282
  }
3292
3283
  }
3293
3284
  });
@@ -9929,7 +9920,9 @@ var require_client = __commonJS({
9929
9920
  exports2.revokeRefreshToken = revokeRefreshToken2;
9930
9921
  exports2.describeAttachment = describeAttachment2;
9931
9922
  exports2.getBalance = getBalance3;
9932
- exports2.getOrgs = getOrgs;
9923
+ exports2.billingOverrideFields = billingOverrideFields2;
9924
+ exports2.setBillingTarget = setBillingTarget2;
9925
+ exports2.getOrgs = getOrgs2;
9933
9926
  exports2.getCodeModels = getCodeModels;
9934
9927
  exports2.getUsageDaily = getUsageDaily;
9935
9928
  exports2.exchangeVscodeCode = exchangeVscodeCode;
@@ -10118,7 +10111,7 @@ var require_client = __commonJS({
10118
10111
  {
10119
10112
  method: "POST",
10120
10113
  headers: authHeaders(),
10121
- body: JSON.stringify({ messages, model, env: env4, editorContext, nexrallMd, mode, effort, clientType, extraTools, agents, skills, turnId, canWriteSharedMemory, hasOwnAgentStore, canSpawnSubAgents, canBrowseWeb, teamId: (0, index_1.getBillingTeamId)() }),
10114
+ body: JSON.stringify({ messages, model, env: env4, editorContext, nexrallMd, mode, effort, clientType, extraTools, agents, skills, turnId, canWriteSharedMemory, hasOwnAgentStore, canSpawnSubAgents, canBrowseWeb, ...billingOverrideFields2() }),
10122
10115
  signal
10123
10116
  }
10124
10117
  ];
@@ -10690,7 +10683,7 @@ var require_client = __commonJS({
10690
10683
  const fetchOnce = () => (0, node_fetch_1.default)(`${exports2.API_BASE}/api/code/assets/describe`, {
10691
10684
  method: "POST",
10692
10685
  headers: { ...authHeaders(), "Content-Type": "application/json" },
10693
- body: JSON.stringify({ kind, data, media_type: mediaType, name, teamId: (0, index_1.getBillingTeamId)() })
10686
+ body: JSON.stringify({ kind, data, media_type: mediaType, name, ...billingOverrideFields2() })
10694
10687
  });
10695
10688
  let response = await fetchOnce();
10696
10689
  if (response.status === 401 || response.status === 403) {
@@ -10735,7 +10728,28 @@ var require_client = __commonJS({
10735
10728
  const data = await response.json();
10736
10729
  return typeof data.balance === "number" ? data.balance : 0;
10737
10730
  }
10738
- async function getOrgs() {
10731
+ function billingOverrideFields2() {
10732
+ const override = (0, index_1.getBillingTeamOverride)();
10733
+ return override === void 0 ? {} : { teamId: override };
10734
+ }
10735
+ async function setBillingTarget2(teamId) {
10736
+ const response = await (0, node_fetch_1.default)(`${exports2.API_BASE}/api/user/billing-target`, {
10737
+ method: "PUT",
10738
+ headers: authHeaders(),
10739
+ body: JSON.stringify({ teamId })
10740
+ });
10741
+ if (!response.ok) {
10742
+ let message = `API error ${response.status}`;
10743
+ try {
10744
+ const parsed = await response.json();
10745
+ if (parsed.error)
10746
+ message = parsed.error;
10747
+ } catch {
10748
+ }
10749
+ throw new Error(message);
10750
+ }
10751
+ }
10752
+ async function getOrgs2() {
10739
10753
  const fetchOnce = () => (0, node_fetch_1.default)(`${exports2.API_BASE}/api/code/orgs`, { method: "GET", headers: authHeaders() });
10740
10754
  let response = await fetchOnce();
10741
10755
  if (response.status === 401 || response.status === 403) {
@@ -10752,7 +10766,8 @@ var require_client = __commonJS({
10752
10766
  const json = await response.json();
10753
10767
  return {
10754
10768
  personal: { balance: typeof json.personal?.balance === "number" ? json.personal.balance : 0 },
10755
- teams: Array.isArray(json.teams) ? json.teams : []
10769
+ teams: Array.isArray(json.teams) ? json.teams : [],
10770
+ billingTargetTeamId: typeof json.billingTargetTeamId === "number" ? json.billingTargetTeamId : null
10756
10771
  };
10757
10772
  }
10758
10773
  async function getCodeModels() {
@@ -101044,13 +101059,14 @@ var require_executor = __commonJS({
101044
101059
  var child_process_1 = __require("child_process");
101045
101060
  var sandbox_1 = require_sandbox();
101046
101061
  var auth_1 = require_auth();
101062
+ var client_1 = require_client();
101047
101063
  var editCompleteness_1 = require_editCompleteness();
101048
101064
  var securityLint_1 = require_securityLint();
101049
101065
  var memory_1 = require_memory();
101050
101066
  var skills_1 = require_skills();
101051
101067
  var testIntegrity_1 = require_testIntegrity();
101052
101068
  var crossFile_1 = require_crossFile();
101053
- var client_1 = require_client();
101069
+ var client_2 = require_client();
101054
101070
  var symbols_1 = require_symbols();
101055
101071
  var tsLangService_1 = require_tsLangService();
101056
101072
  var safeSlice_1 = require_safeSlice();
@@ -103007,7 +103023,7 @@ ${lines.join("\n")}`;
103007
103023
  let cost;
103008
103024
  let balance;
103009
103025
  try {
103010
- const r2 = await _httpsPost(`${client_1.API_BASE}/api/code/assets/generate`, JSON.stringify({ prompt: prompt2, aspect_ratio: aspectRatio, teamId: (0, auth_1.getBillingTeamId)() }), { "Content-Type": "application/json", Authorization: `Bearer ${token}` }, 17e4, abortSignal);
103026
+ const r2 = await _httpsPost(`${client_2.API_BASE}/api/code/assets/generate`, JSON.stringify({ prompt: prompt2, aspect_ratio: aspectRatio, ...(0, client_1.billingOverrideFields)() }), { "Content-Type": "application/json", Authorization: `Bearer ${token}` }, 17e4, abortSignal);
103011
103027
  let json = {};
103012
103028
  try {
103013
103029
  json = JSON.parse(r2.body);
@@ -103056,7 +103072,7 @@ ${lines.join("\n")}`;
103056
103072
  return { error: "Not authenticated. Run `nexrall-code login` first." };
103057
103073
  let photos;
103058
103074
  try {
103059
- const u = new URL(`${client_1.API_BASE}/api/code/assets/stock`);
103075
+ const u = new URL(`${client_2.API_BASE}/api/code/assets/stock`);
103060
103076
  u.searchParams.set("query", query);
103061
103077
  u.searchParams.set("count", String(count));
103062
103078
  if (orientation)
@@ -103112,7 +103128,7 @@ ${lines.join("\n")}` };
103112
103128
  if (!token)
103113
103129
  return { error: "Not authenticated. Run `nexrall-code login` first." };
103114
103130
  try {
103115
- const r2 = await _httpsPost(`${client_1.API_BASE}/api/code/tools/web_search`, JSON.stringify({ query, teamId: (0, auth_1.getBillingTeamId)() }), { "Content-Type": "application/json", Authorization: `Bearer ${token}` }, 3e4, abortSignal);
103131
+ const r2 = await _httpsPost(`${client_2.API_BASE}/api/code/tools/web_search`, JSON.stringify({ query, ...(0, client_1.billingOverrideFields)() }), { "Content-Type": "application/json", Authorization: `Bearer ${token}` }, 3e4, abortSignal);
103116
103132
  let json = {};
103117
103133
  try {
103118
103134
  json = JSON.parse(r2.body);
@@ -104891,7 +104907,6 @@ var require_loop = __commonJS({
104891
104907
  exports2.trimToResumableBoundary = trimToResumableBoundary;
104892
104908
  var types_1 = require_types();
104893
104909
  var client_1 = require_client();
104894
- var index_1 = require_auth();
104895
104910
  var executor_1 = require_executor();
104896
104911
  var agentTypes_1 = require_agentTypes();
104897
104912
  var skills_1 = require_skills();
@@ -104904,7 +104919,7 @@ var require_loop = __commonJS({
104904
104919
  var worktreeEnforcement_1 = require_worktreeEnforcement();
104905
104920
  var agentRegistry_1 = require_agentRegistry();
104906
104921
  var sandbox_1 = require_sandbox();
104907
- var index_2 = require_plugins();
104922
+ var index_1 = require_plugins();
104908
104923
  var testIntegrity_1 = require_testIntegrity();
104909
104924
  var flaky_1 = require_flaky();
104910
104925
  var claimEvidence_1 = require_claimEvidence();
@@ -104924,7 +104939,7 @@ var require_loop = __commonJS({
104924
104939
  fromSettings = JSON.parse(fs9.readFileSync(p, "utf-8")).hooks ?? {};
104925
104940
  } catch {
104926
104941
  }
104927
- const fromPlugins = (0, index_2.pluginHooks)(workDir);
104942
+ const fromPlugins = (0, index_1.pluginHooks)(workDir);
104928
104943
  const merged = { ...fromSettings };
104929
104944
  for (const phase of Object.keys(fromPlugins)) {
104930
104945
  const extra = fromPlugins[phase];
@@ -106447,7 +106462,6 @@ Continue the work from here.` }] });
106447
106462
  break;
106448
106463
  }
106449
106464
  if (status === 403 && typeof code === "string" && TEAM_SCOPE_ERROR_CODES.has(code)) {
106450
- (0, index_1.setBillingTeamId)(null);
106451
106465
  stopReason = "team-unavailable";
106452
106466
  break;
106453
106467
  }
@@ -143350,7 +143364,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
143350
143364
  var source_default = chalk;
143351
143365
 
143352
143366
  // src/index.ts
143353
- var import_code_core7 = __toESM(require_dist3(), 1);
143367
+ var import_code_core8 = __toESM(require_dist3(), 1);
143354
143368
 
143355
143369
  // src/commands/auth.ts
143356
143370
  import * as readline from "readline";
@@ -143474,6 +143488,90 @@ function stopSpinner(handle2) {
143474
143488
  process.stdout.write("\r\x1B[K");
143475
143489
  }
143476
143490
 
143491
+ // src/commands/billing.ts
143492
+ var import_code_core2 = __toESM(require_dist3(), 1);
143493
+ function money(usd) {
143494
+ return "$" + usd.toFixed(2);
143495
+ }
143496
+ async function requireAuth() {
143497
+ if ((0, import_code_core2.isAuthenticated)())
143498
+ return true;
143499
+ console.log(source_default.red("Not logged in. Run `nex auth` first."));
143500
+ return false;
143501
+ }
143502
+ async function billingStatusCommand() {
143503
+ if (!await requireAuth())
143504
+ return;
143505
+ let orgs;
143506
+ try {
143507
+ orgs = await (0, import_code_core2.getOrgs)();
143508
+ } catch {
143509
+ console.log(source_default.yellow("Could not read your billing target (offline, or a server without team support)."));
143510
+ return;
143511
+ }
143512
+ const targetId = orgs.billingTargetTeamId ?? null;
143513
+ const team = targetId == null ? null : orgs.teams.find((t2) => t2.id === targetId) ?? null;
143514
+ console.log("");
143515
+ console.log(source_default.bold("Billing target"));
143516
+ if (team) {
143517
+ console.log(` ${source_default.cyan(team.name)} ${source_default.gray(`(${money(team.remainingUsd)} left this month)`)}`);
143518
+ if (team.remainingUsd <= 0) {
143519
+ console.log(source_default.yellow(" \u26A0 This team has no budget left \u2014 ask a team admin to add funds."));
143520
+ }
143521
+ } else if (targetId != null) {
143522
+ console.log(` ${source_default.yellow(`team ${targetId}`)} ${source_default.gray("(not available to this account \u2014 usage falls back to your wallet)")}`);
143523
+ } else {
143524
+ console.log(` Personal wallet ${source_default.gray(`(${money(orgs.personal.balance)} available)`)}`);
143525
+ }
143526
+ if (orgs.teams.length > 0) {
143527
+ console.log("");
143528
+ console.log(source_default.gray("Teams you can bill to:"));
143529
+ for (const t2 of orgs.teams) {
143530
+ const marker = t2.id === targetId ? source_default.green(" \u2190 current") : "";
143531
+ const state = t2.remainingUsd > 0 ? source_default.gray(`${money(t2.remainingUsd)} left`) : source_default.yellow("no budget left");
143532
+ console.log(` ${source_default.bold(String(t2.id))} ${t2.name} ${state}${marker}`);
143533
+ }
143534
+ console.log("");
143535
+ console.log(source_default.gray("Change it with `nex billing use <id>` or `nex billing use personal`."));
143536
+ }
143537
+ const override = (0, import_code_core2.billingOverrideFields)();
143538
+ if ("teamId" in override) {
143539
+ console.log("");
143540
+ console.log(source_default.yellow(
143541
+ `Note: NEXRALL_BILLING_TEAM pins this run to ${override.teamId === null ? "your personal wallet" : `team ${override.teamId}`}, ignoring the account setting above.`
143542
+ ));
143543
+ }
143544
+ console.log("");
143545
+ }
143546
+ async function billingUseCommand(target) {
143547
+ if (!await requireAuth())
143548
+ return;
143549
+ const raw = (target || "").trim();
143550
+ if (/^(personal|null|0)$/i.test(raw)) {
143551
+ await applyTarget(null, "your personal wallet");
143552
+ return;
143553
+ }
143554
+ if (!/^\d+$/.test(raw)) {
143555
+ console.log(source_default.red("Usage: nex billing use <team id|personal> (see `nex billing` for the ids)"));
143556
+ process.exitCode = 1;
143557
+ return;
143558
+ }
143559
+ await applyTarget(Number(raw), `team ${raw}`);
143560
+ }
143561
+ async function applyTarget(teamId, label) {
143562
+ try {
143563
+ await (0, import_code_core2.setBillingTarget)(teamId);
143564
+ } catch (e2) {
143565
+ console.log(source_default.red(e2.message));
143566
+ process.exitCode = 1;
143567
+ return;
143568
+ }
143569
+ console.log(source_default.green(`\u2713 Usage will now be billed to ${label}.`));
143570
+ if (teamId !== null) {
143571
+ console.log(source_default.gray(" This applies to every product and client on this account, not just the CLI."));
143572
+ }
143573
+ }
143574
+
143477
143575
  // src/commands/chat.ts
143478
143576
  import * as readline3 from "readline";
143479
143577
  import * as path6 from "path";
@@ -143483,7 +143581,7 @@ import * as crypto4 from "crypto";
143483
143581
  import { createRequire } from "module";
143484
143582
  import { fileURLToPath as fileURLToPath2 } from "url";
143485
143583
  import { execSync, execFileSync as execFileSync2 } from "child_process";
143486
- var import_code_core4 = __toESM(require_dist3(), 1);
143584
+ var import_code_core5 = __toESM(require_dist3(), 1);
143487
143585
 
143488
143586
  // ../../node_modules/.pnpm/ansi-regex@6.2.2/node_modules/ansi-regex/index.js
143489
143587
  function ansiRegex({ onlyFirst = false } = {}) {
@@ -144441,18 +144539,18 @@ function showDiff(filePath, oldContent, newContent) {
144441
144539
  }
144442
144540
 
144443
144541
  // src/permissions/handler.ts
144444
- var import_code_core2 = __toESM(require_dist3(), 1);
144542
+ var import_code_core3 = __toESM(require_dist3(), 1);
144445
144543
  var autoApproved = /* @__PURE__ */ new Set();
144446
144544
  var _rules = { allow: [], ask: [], deny: [] };
144447
144545
  var _workDir = process.cwd();
144448
144546
  var _mode = "ask";
144449
144547
  function initPermissions(workDir) {
144450
144548
  _workDir = workDir;
144451
- _rules = (0, import_code_core2.loadSettings)(workDir).permissions;
144549
+ _rules = (0, import_code_core3.loadSettings)(workDir).permissions;
144452
144550
  return _rules;
144453
144551
  }
144454
144552
  function setMode(mode) {
144455
- _mode = (0, import_code_core2.parseMode)(mode);
144553
+ _mode = (0, import_code_core3.parseMode)(mode);
144456
144554
  }
144457
144555
  function setAutoApprove(category) {
144458
144556
  autoApproved.add(category);
@@ -144496,12 +144594,12 @@ function askUser(question) {
144496
144594
  }
144497
144595
  async function requestPermission(req) {
144498
144596
  const { tool, input } = req;
144499
- const decision = (0, import_code_core2.evaluatePermission)(_rules, tool, input, _workDir);
144597
+ const decision = (0, import_code_core3.evaluatePermission)(_rules, tool, input, _workDir);
144500
144598
  if (decision === "deny") {
144501
144599
  console.error(source_default.red(` \u2716 Denied by permission rule: ${tool}`));
144502
144600
  return false;
144503
144601
  }
144504
- const destructive = (0, import_code_core2.isDestructiveBash)(tool, input);
144602
+ const destructive = (0, import_code_core3.isDestructiveBash)(tool, input);
144505
144603
  if (destructive && process.env.NEXRALL_ALLOW_DESTRUCTIVE !== "1") {
144506
144604
  const command = input.command ?? input.cmd ?? "";
144507
144605
  console.error();
@@ -144519,7 +144617,7 @@ async function requestPermission(req) {
144519
144617
  }
144520
144618
  if (decision === "allow")
144521
144619
  return true;
144522
- const verdict = (0, import_code_core2.decide)({
144620
+ const verdict = (0, import_code_core3.decide)({
144523
144621
  tool,
144524
144622
  input,
144525
144623
  mode: _mode,
@@ -144681,7 +144779,7 @@ async function requestPermission(req) {
144681
144779
  }
144682
144780
 
144683
144781
  // src/audit.ts
144684
- var import_code_core3 = __toESM(require_dist3(), 1);
144782
+ var import_code_core4 = __toESM(require_dist3(), 1);
144685
144783
  import * as path from "path";
144686
144784
  var _state;
144687
144785
  var _sinks = /* @__PURE__ */ new Map();
@@ -144701,7 +144799,7 @@ function currentAudit() {
144701
144799
  const target = resolveAuditPath(_state);
144702
144800
  let sink = _sinks.get(target);
144703
144801
  if (!sink) {
144704
- sink = (0, import_code_core3.createJsonlAuditSink)(target);
144802
+ sink = (0, import_code_core4.createJsonlAuditSink)(target);
144705
144803
  _sinks.set(target, sink);
144706
144804
  }
144707
144805
  const cfg = {
@@ -144714,14 +144812,14 @@ function currentAudit() {
144714
144812
  // request that caused it. Same trap as @nexrall/agent's and Desktop's.
144715
144813
  sessionId: _state.getSessionId()
144716
144814
  };
144717
- const email = (0, import_code_core3.loadAuth)()?.email;
144815
+ const email = (0, import_code_core4.loadAuth)()?.email;
144718
144816
  if (email)
144719
144817
  cfg.userId = email;
144720
144818
  return cfg;
144721
144819
  }
144722
144820
 
144723
144821
  // src/commands/chat.ts
144724
- var import_code_core5 = __toESM(require_dist3(), 1);
144822
+ var import_code_core6 = __toESM(require_dist3(), 1);
144725
144823
 
144726
144824
  // src/commands/sessions.ts
144727
144825
  import * as fs3 from "fs";
@@ -154890,7 +154988,7 @@ var MODEL_COST_MULTIPLIER = {
154890
154988
  "glm-5.3": 0.6
154891
154989
  };
154892
154990
  function modelWithCostHint(id) {
154893
- const mult = (0, import_code_core4.liveCostMultiplierFor)(id, MODEL_COST_MULTIPLIER[id]);
154991
+ const mult = (0, import_code_core5.liveCostMultiplierFor)(id, MODEL_COST_MULTIPLIER[id]);
154894
154992
  return mult === void 0 ? id : `${id} (${mult}x)`;
154895
154993
  }
154896
154994
  var NO_VISION_MODELS = /* @__PURE__ */ new Set(["qwen3.7-max", "glm-5.3"]);
@@ -154906,13 +155004,13 @@ var NO_PDF_MODELS = /* @__PURE__ */ new Set([
154906
155004
  ...NO_VISION_MODELS
154907
155005
  ]);
154908
155006
  function needsVisionSidecar(model) {
154909
- return !(0, import_code_core4.liveSupportsImageInput)(model, !NO_VISION_MODELS.has(model));
155007
+ return !(0, import_code_core5.liveSupportsImageInput)(model, !NO_VISION_MODELS.has(model));
154910
155008
  }
154911
155009
  function needsPdfSidecar(model) {
154912
- return !(0, import_code_core4.liveSupportsPdfInput)(model, !NO_PDF_MODELS.has(model));
155010
+ return !(0, import_code_core5.liveSupportsPdfInput)(model, !NO_PDF_MODELS.has(model));
154913
155011
  }
154914
155012
  function selectableModelIds() {
154915
- return (0, import_code_core4.liveSelectableModelIds)() ?? SELECTABLE_MODELS;
155013
+ return (0, import_code_core5.liveSelectableModelIds)() ?? SELECTABLE_MODELS;
154916
155014
  }
154917
155015
  function normaliseModelId(model) {
154918
155016
  const raw = (model ?? "").trim();
@@ -154973,9 +155071,9 @@ var _BACKEND_STYLE_TO_LOCAL = {
154973
155071
  };
154974
155072
  function effortStyleFor(modelId) {
154975
155073
  const id = normaliseModelId(modelId);
154976
- if ((0, import_code_core4.liveVendorFor)(id) === "Anthropic")
155074
+ if ((0, import_code_core5.liveVendorFor)(id) === "Anthropic")
154977
155075
  return "anthropic";
154978
- const liveStyle = (0, import_code_core4.liveReasoningEffortStyle)(id);
155076
+ const liveStyle = (0, import_code_core5.liveReasoningEffortStyle)(id);
154979
155077
  if (liveStyle && _BACKEND_STYLE_TO_LOCAL[liveStyle])
154980
155078
  return _BACKEND_STYLE_TO_LOCAL[liveStyle];
154981
155079
  return MODEL_EFFORT_STYLE[id] ?? "anthropic";
@@ -154995,7 +155093,7 @@ function defaultEffortForModel(modelId) {
154995
155093
  }
154996
155094
  function resolveModelLabel(alias) {
154997
155095
  const id = normaliseModelId(alias);
154998
- return (0, import_code_core4.liveLabelFor)(id, MODEL_LABELS[id] ?? id);
155096
+ return (0, import_code_core5.liveLabelFor)(id, MODEL_LABELS[id] ?? id);
154999
155097
  }
155000
155098
  function tryExec(cmd, cwd2) {
155001
155099
  try {
@@ -155056,7 +155154,7 @@ var tryRead = (p) => {
155056
155154
  };
155057
155155
  function readNexrallMd(workDir) {
155058
155156
  const parts = [];
155059
- const memContent = (0, import_code_core4.readAllMemory)(workDir);
155157
+ const memContent = (0, import_code_core5.readAllMemory)(workDir);
155060
155158
  if (memContent)
155061
155159
  parts.push(memContent);
155062
155160
  const globalContent = tryRead(path6.join(os5.homedir(), ".nexrall", "nexrall.md"));
@@ -155166,12 +155264,12 @@ var Spinner = class {
155166
155264
  var _mcpManager = null;
155167
155265
  var _mcpConfig = null;
155168
155266
  async function initMcp(workDir) {
155169
- _mcpConfig = import_code_core4.McpManager.loadConfig(workDir);
155267
+ _mcpConfig = import_code_core5.McpManager.loadConfig(workDir);
155170
155268
  if (Object.keys(_mcpConfig.mcpServers).length === 0) {
155171
155269
  _mcpManager = null;
155172
155270
  return;
155173
155271
  }
155174
- const manager = new import_code_core4.McpManager();
155272
+ const manager = new import_code_core5.McpManager();
155175
155273
  await manager.connectAll(_mcpConfig);
155176
155274
  _mcpManager = manager;
155177
155275
  }
@@ -155192,10 +155290,10 @@ function formatMcpStatus() {
155192
155290
  return lines.join("\n");
155193
155291
  }
155194
155292
  function formatContextUsage(messages, modelAlias) {
155195
- const window2 = (0, import_code_core4.contextWindowFor)(modelAlias);
155196
- const tokens = (0, import_code_core4.estimateTokensRough)(messages);
155197
- const bytes = (0, import_code_core4.estimateBodyBytes)(messages);
155198
- const { prune, compact } = (0, import_code_core4.compactionThresholds)();
155293
+ const window2 = (0, import_code_core5.contextWindowFor)(modelAlias);
155294
+ const tokens = (0, import_code_core5.estimateTokensRough)(messages);
155295
+ const bytes = (0, import_code_core5.estimateBodyBytes)(messages);
155296
+ const { prune, compact } = (0, import_code_core5.compactionThresholds)();
155199
155297
  const pct = Math.min(100, tokens / window2 * 100);
155200
155298
  const barWidth = 30;
155201
155299
  const filled = Math.round(pct / 100 * barWidth);
@@ -155212,7 +155310,7 @@ function formatContextUsage(messages, modelAlias) {
155212
155310
  return lines.join("\n");
155213
155311
  }
155214
155312
  function formatAgentsList(workDir) {
155215
- const { types: types3, warnings } = (0, import_code_core4.loadAgentTypesWithWarnings)(workDir);
155313
+ const { types: types3, warnings } = (0, import_code_core5.loadAgentTypesWithWarnings)(workDir);
155216
155314
  if (!types3.length)
155217
155315
  return source_default.dim(" No agent types found (this should not happen \u2014 builtins always register).");
155218
155316
  const lines = types3.map((t2) => {
@@ -155259,7 +155357,7 @@ async function runTurn(messages, modelAlias, workDir, abortSignal, env4, nexrall
155259
155357
  setMode(mode);
155260
155358
  console.log();
155261
155359
  spinner.start("thinking\u2026", { hint: false });
155262
- const result = await (0, import_code_core4.runAgentLoop)(messages, {
155360
+ const result = await (0, import_code_core5.runAgentLoop)(messages, {
155263
155361
  workDir,
155264
155362
  model: modelAlias,
155265
155363
  env: env4,
@@ -155442,7 +155540,7 @@ async function runTurnHeadless(messages, modelAlias, workDir, _abortSignal, env4
155442
155540
  process.stdout.write(JSON.stringify(obj2) + "\n");
155443
155541
  };
155444
155542
  emit({ type: "start", model: modelAlias, workDir });
155445
- const result = await (0, import_code_core4.runAgentLoop)(messages, {
155543
+ const result = await (0, import_code_core5.runAgentLoop)(messages, {
155446
155544
  workDir,
155447
155545
  model: modelAlias,
155448
155546
  env: env4,
@@ -155538,7 +155636,7 @@ async function runTurnHeadless(messages, modelAlias, workDir, _abortSignal, env4
155538
155636
  // no human to confirm, they are denied unless NEXRALL_ALLOW_DESTRUCTIVE=1 is
155539
155637
  // explicitly set for this CI run.
155540
155638
  requestPermission: async ({ tool, input }) => {
155541
- const d = (0, import_code_core4.isDestructiveBash)(tool, input);
155639
+ const d = (0, import_code_core5.isDestructiveBash)(tool, input);
155542
155640
  if (d && process.env.NEXRALL_ALLOW_DESTRUCTIVE !== "1") {
155543
155641
  emit({ type: "error", error: `Destructive command blocked in headless mode (${d.category}): ${d.reason}. Set NEXRALL_ALLOW_DESTRUCTIVE=1 to permit.` });
155544
155642
  return false;
@@ -155643,7 +155741,7 @@ async function startChatSession(options) {
155643
155741
  let peerInbox;
155644
155742
  const peerInboxQueue = [];
155645
155743
  let modelAlias = options.model;
155646
- void (0, import_code_core4.getModelCatalogue)().catch(() => {
155744
+ void (0, import_code_core5.getModelCatalogue)().catch(() => {
155647
155745
  });
155648
155746
  const canPrompt = !headless && !options.prompt && !options.stdinText && process.stdin.isTTY === true && process.stdout.isTTY === true;
155649
155747
  if (!trustGrantedByEnv()) {
@@ -155671,9 +155769,9 @@ Set ${TRUST_ENV_VAR}=1 to confirm non-interactively, or run \`nex\` interactivel
155671
155769
  }
155672
155770
  if (options.worktree !== void 0) {
155673
155771
  const requestedName = typeof options.worktree === "string" ? options.worktree : void 0;
155674
- const existing = requestedName ? (0, import_code_core4.findWorktreeByName)(requestedWorkDir, requestedName) : null;
155772
+ const existing = requestedName ? (0, import_code_core5.findWorktreeByName)(requestedWorkDir, requestedName) : null;
155675
155773
  if (existing) {
155676
- const entered = (0, import_code_core4.enterWorktree)(existing);
155774
+ const entered = (0, import_code_core5.enterWorktree)(existing);
155677
155775
  if (!entered.ok) {
155678
155776
  process.stderr.write(`Failed to resume worktree "${requestedName}": ${entered.error}
155679
155777
  `);
@@ -155683,7 +155781,7 @@ Set ${TRUST_ENV_VAR}=1 to confirm non-interactively, or run \`nex\` interactivel
155683
155781
  if (!headless)
155684
155782
  console.log(source_default.dim(` Resumed worktree: ${source_default.bold(existing.name)} (${existing.worktreePath})`));
155685
155783
  } else {
155686
- const created = (0, import_code_core4.createWorktree)(requestedWorkDir, requestedName);
155784
+ const created = (0, import_code_core5.createWorktree)(requestedWorkDir, requestedName);
155687
155785
  if (!created.ok || !created.state) {
155688
155786
  process.stderr.write(`Failed to create worktree: ${created.error ?? "unknown error"}
155689
155787
  `);
@@ -155702,7 +155800,7 @@ Set ${TRUST_ENV_VAR}=1 to confirm non-interactively, or run \`nex\` interactivel
155702
155800
  process.on("exit", () => {
155703
155801
  if (!worktreeState)
155704
155802
  return;
155705
- const hadWork = (0, import_code_core4.worktreeHasWork)(worktreeState);
155803
+ const hadWork = (0, import_code_core5.worktreeHasWork)(worktreeState);
155706
155804
  if (hadWork) {
155707
155805
  process.stderr.write(
155708
155806
  `
@@ -155713,7 +155811,7 @@ Resume it with: nex --worktree ${worktreeState.name}
155713
155811
  );
155714
155812
  return;
155715
155813
  }
155716
- (0, import_code_core4.removeWorktree)(worktreeState);
155814
+ (0, import_code_core5.removeWorktree)(worktreeState);
155717
155815
  });
155718
155816
  }
155719
155817
  const env4 = collectEnv(workDir);
@@ -155721,8 +155819,8 @@ Resume it with: nex --worktree ${worktreeState.name}
155721
155819
  const interactive = !headless && !options.prompt && !options.stdinText;
155722
155820
  let peerHeartbeatTimer;
155723
155821
  if (interactive) {
155724
- const handle2 = (0, import_code_core4.registerPeer)({ clientType: "cli", workDir: requestedWorkDir });
155725
- const inbox = (0, import_code_core4.startPeerInbox)(handle2.record.id, { onMessage: (m2) => peerInboxQueue.push(m2) });
155822
+ const handle2 = (0, import_code_core5.registerPeer)({ clientType: "cli", workDir: requestedWorkDir });
155823
+ const inbox = (0, import_code_core5.startPeerInbox)(handle2.record.id, { onMessage: (m2) => peerInboxQueue.push(m2) });
155726
155824
  handle2.record.socketPath = inbox.socketPath;
155727
155825
  handle2.heartbeat();
155728
155826
  peerHandle = handle2;
@@ -155792,7 +155890,7 @@ Resume it with: nex --worktree ${worktreeState.name}
155792
155890
  const ruleCount = permRules.allow.length + permRules.ask.length + permRules.deny.length;
155793
155891
  if (ruleCount && !headless)
155794
155892
  console.log(source_default.dim(` ${ruleCount} permission rule(s) loaded`));
155795
- let skills = (0, import_code_core4.loadSkills)(workDir);
155893
+ let skills = (0, import_code_core5.loadSkills)(workDir);
155796
155894
  if (skills.length && !headless)
155797
155895
  console.log(source_default.dim(` ${skills.length} skill(s) loaded`));
155798
155896
  const mcpStarted = (async () => {
@@ -155824,7 +155922,7 @@ Resume it with: nex --worktree ${worktreeState.name}
155824
155922
  sessionId = stored.id;
155825
155923
  sessionTitle = stored.title;
155826
155924
  try {
155827
- const compacted = await (0, import_code_core4.compactMessagesForResume)(messages, {
155925
+ const compacted = await (0, import_code_core5.compactMessagesForResume)(messages, {
155828
155926
  workDir,
155829
155927
  model: modelAlias,
155830
155928
  clientType: "cli",
@@ -155841,7 +155939,7 @@ Resume it with: nex --worktree ${worktreeState.name}
155841
155939
  console.log();
155842
155940
  }
155843
155941
  }
155844
- const checkpoints = new import_code_core4.CheckpointManager(workDir, sessionId);
155942
+ const checkpoints = new import_code_core5.CheckpointManager(workDir, sessionId);
155845
155943
  if (options.audit) {
155846
155944
  const auditPath = enableAudit({
155847
155945
  filePath: typeof options.audit === "string" ? options.audit : void 0,
@@ -155859,7 +155957,7 @@ Resume it with: nex --worktree ${worktreeState.name}
155859
155957
  sessionTitle = raw.length > 60 ? raw.slice(0, 60) + "\u2026" : raw;
155860
155958
  };
155861
155959
  const recoverTurn = (err, current) => {
155862
- const salvaged = (0, import_code_core4.salvageHistory)(err);
155960
+ const salvaged = (0, import_code_core5.salvageHistory)(err);
155863
155961
  console.error("\n" + source_default.red("Error: ") + String(err.message));
155864
155962
  if (!salvaged)
155865
155963
  return current;
@@ -155908,7 +156006,7 @@ ${text}` : "");
155908
156006
  await new Promise((r2) => setImmediate(r2));
155909
156007
  process.exit(0);
155910
156008
  } catch (err) {
155911
- const salvaged = (0, import_code_core4.salvageHistory)(err);
156009
+ const salvaged = (0, import_code_core5.salvageHistory)(err);
155912
156010
  if (salvaged) {
155913
156011
  messages = salvaged;
155914
156012
  try {
@@ -156013,7 +156111,7 @@ ${text}` : "");
156013
156111
  messages = [];
156014
156112
  sessionId = crypto4.randomBytes(8).toString("hex");
156015
156113
  sessionTitle = "";
156016
- (0, import_code_core5.resetSessionSubAgentBudget)();
156114
+ (0, import_code_core6.resetSessionSubAgentBudget)();
156017
156115
  console.log(source_default.dim(" Conversation cleared. New session started."));
156018
156116
  rl.prompt();
156019
156117
  return;
@@ -156047,7 +156145,7 @@ ${text}` : "");
156047
156145
  sessionId = stored.id;
156048
156146
  sessionTitle = stored.title;
156049
156147
  try {
156050
- await (0, import_code_core4.compactMessagesForResume)(messages, {
156148
+ await (0, import_code_core5.compactMessagesForResume)(messages, {
156051
156149
  workDir,
156052
156150
  model: modelAlias,
156053
156151
  clientType: "cli",
@@ -156222,13 +156320,13 @@ ${dirList}`;
156222
156320
  const sub = arg.trim().toLowerCase();
156223
156321
  console.log();
156224
156322
  if (sub === "list") {
156225
- const all = (0, import_code_core4.listWorktrees)(requestedWorkDir);
156323
+ const all = (0, import_code_core5.listWorktrees)(requestedWorkDir);
156226
156324
  if (!all.length) {
156227
156325
  console.log(source_default.dim(" No worktrees under this project."));
156228
156326
  } else {
156229
156327
  console.log(source_default.bold(` Worktrees (${all.length})`));
156230
156328
  for (const w of all) {
156231
- const dirty = (0, import_code_core4.worktreeHasWork)(w) ? source_default.yellow("dirty") : source_default.dim("clean");
156329
+ const dirty = (0, import_code_core5.worktreeHasWork)(w) ? source_default.yellow("dirty") : source_default.dim("clean");
156232
156330
  console.log(` ${source_default.cyan(w.name)} ${source_default.dim(w.worktreePath)} [${dirty}]`);
156233
156331
  }
156234
156332
  console.log();
@@ -156266,7 +156364,7 @@ ${dirList}`;
156266
156364
  if (!targetName || !text) {
156267
156365
  console.log(source_default.dim(" Usage: /peers send <name> <message>"));
156268
156366
  } else {
156269
- const target = (0, import_code_core4.listPeers)().find((p) => p.name === targetName);
156367
+ const target = (0, import_code_core5.listPeers)().find((p) => p.name === targetName);
156270
156368
  if (!target) {
156271
156369
  console.log(source_default.red(` No live session named "${targetName}". Use /peers to list who's reachable.`));
156272
156370
  } else if (!target.socketPath) {
@@ -156283,7 +156381,7 @@ ${dirList}`;
156283
156381
  console.log(source_default.dim(" Usage: /peers broadcast <message>"));
156284
156382
  } else {
156285
156383
  const { broadcastPeerMessage } = await Promise.resolve().then(() => __toESM(require_dist3(), 1));
156286
- const targets = (0, import_code_core4.listPeers)(peerHandle.record.id).filter((p) => p.id !== peerHandle.record.id && p.socketPath && p.inbound !== "refuse").map((p) => ({ name: p.name, socketPath: p.socketPath }));
156384
+ const targets = (0, import_code_core5.listPeers)(peerHandle.record.id).filter((p) => p.id !== peerHandle.record.id && p.socketPath && p.inbound !== "refuse").map((p) => ({ name: p.name, socketPath: p.socketPath }));
156287
156385
  if (!targets.length) {
156288
156386
  console.log(source_default.dim(" No other reachable Nexrall Code sessions to broadcast to."));
156289
156387
  } else {
@@ -156295,7 +156393,7 @@ ${dirList}`;
156295
156393
  }
156296
156394
  }
156297
156395
  } else {
156298
- const peers = (0, import_code_core4.listPeers)(peerHandle.record.id);
156396
+ const peers = (0, import_code_core5.listPeers)(peerHandle.record.id);
156299
156397
  if (peers.length <= 1) {
156300
156398
  console.log(source_default.dim(" No other Nexrall Code sessions are currently discoverable on this machine."));
156301
156399
  } else {
@@ -156325,7 +156423,7 @@ ${dirList}`;
156325
156423
  const label = memScope === "global" ? "GLOBAL" : "this PROJECT's";
156326
156424
  const answer = await new Promise((resolve4) => rl.question(source_default.yellow(` Clear ${label} memory? This cannot be undone. [y/n] `), (a) => resolve4(a.trim())));
156327
156425
  if (answer === "y" || answer === "yes") {
156328
- (0, import_code_core4.clearMemory)(memScope, workDir);
156426
+ (0, import_code_core5.clearMemory)(memScope, workDir);
156329
156427
  console.log(source_default.green(` ${memScope === "global" ? "Global" : "Project"} memory cleared.`));
156330
156428
  } else {
156331
156429
  console.log(source_default.dim(" Cancelled."));
@@ -156336,20 +156434,20 @@ ${dirList}`;
156336
156434
  }
156337
156435
  console.log();
156338
156436
  if (wantsGlobalOnly) {
156339
- const stats = (0, import_code_core4.memoryStats)("global");
156340
- const content = (0, import_code_core4.readMemory)("global", void 0, { includeArchived: wantsArchived });
156437
+ const stats = (0, import_code_core5.memoryStats)("global");
156438
+ const content = (0, import_code_core5.readMemory)("global", void 0, { includeArchived: wantsArchived });
156341
156439
  const archivedNote = stats.archived > 0 ? `, ${stats.archived} archived` : "";
156342
156440
  console.log(source_default.bold(" Global memory ") + source_default.dim(`(${stats.entries} entries${archivedNote}, ${(stats.bytes / 1024).toFixed(1)}KB) \u2014 ${stats.file}`));
156343
156441
  console.log();
156344
156442
  console.log(content || source_default.dim(" No global memories saved yet."));
156345
156443
  } else {
156346
- const projStats = (0, import_code_core4.memoryStats)("project", workDir);
156347
- const globalStats = (0, import_code_core4.memoryStats)("global");
156444
+ const projStats = (0, import_code_core5.memoryStats)("project", workDir);
156445
+ const globalStats = (0, import_code_core5.memoryStats)("global");
156348
156446
  const projArchived = projStats.archived > 0 ? `+${projStats.archived} archived ` : "";
156349
156447
  const globalArchived = globalStats.archived > 0 ? `+${globalStats.archived} archived ` : "";
156350
156448
  console.log(source_default.bold(" Memory") + source_default.dim(` \u2014 project: ${projStats.entries} ${projArchived}entries (${(projStats.bytes / 1024).toFixed(1)}KB) \xB7 global: ${globalStats.entries} ${globalArchived}entries (${(globalStats.bytes / 1024).toFixed(1)}KB)`));
156351
156449
  console.log();
156352
- const merged = (0, import_code_core4.readAllMemory)(workDir, { includeArchived: wantsArchived });
156450
+ const merged = (0, import_code_core5.readAllMemory)(workDir, { includeArchived: wantsArchived });
156353
156451
  console.log(merged || source_default.dim(" No memories saved yet."));
156354
156452
  }
156355
156453
  console.log();
@@ -156388,12 +156486,12 @@ ${dirList}`;
156388
156486
  console.log(source_default.dim(` Current: ${source_default.cyan(agentMode)}`));
156389
156487
  for (const m2 of ["ask", "edit", "auto", "plan"]) {
156390
156488
  const marker = m2 === agentMode ? source_default.cyan("\u276F") : " ";
156391
- console.log(` ${marker} ${source_default.bold(m2.padEnd(5))} ${source_default.dim((0, import_code_core5.describeMode)(m2).replace(`${m2} \u2014 `, ""))}`);
156489
+ console.log(` ${marker} ${source_default.bold(m2.padEnd(5))} ${source_default.dim((0, import_code_core6.describeMode)(m2).replace(`${m2} \u2014 `, ""))}`);
156392
156490
  }
156393
156491
  } else if (["ask", "edit", "plan", "auto"].includes(modeArg)) {
156394
156492
  agentMode = modeArg;
156395
156493
  updateFooter();
156396
- console.log(source_default.green(` Mode \u2192 ${source_default.bold(modeArg)}`) + source_default.dim(` ${(0, import_code_core5.describeMode)(modeArg).replace(`${modeArg} \u2014 `, "")}`));
156494
+ console.log(source_default.green(` Mode \u2192 ${source_default.bold(modeArg)}`) + source_default.dim(` ${(0, import_code_core6.describeMode)(modeArg).replace(`${modeArg} \u2014 `, "")}`));
156397
156495
  } else {
156398
156496
  console.log(source_default.red(` Unknown: ${modeArg}`));
156399
156497
  }
@@ -156424,7 +156522,7 @@ ${dirList}`;
156424
156522
  case "/balance": {
156425
156523
  rl.pause();
156426
156524
  try {
156427
- const bal = await (0, import_code_core4.getBalance)();
156525
+ const bal = await (0, import_code_core5.getBalance)();
156428
156526
  console.log(source_default.dim(" Balance: ") + source_default.cyan(`$${bal.toFixed(4)}`));
156429
156527
  } catch (err) {
156430
156528
  console.error(source_default.red(" Failed: ") + String(err.message));
@@ -156510,7 +156608,7 @@ ${caption}` : `[Attached: ${rel}]`;
156510
156608
  if (needsSidecar) {
156511
156609
  console.log(source_default.dim(` ${resolveModelLabel(modelAlias)} can't read ${isPdf ? "PDFs" : "images"} directly \u2014 describing ${rel} with Claude Sonnet 5 first\u2026`));
156512
156610
  try {
156513
- const { text } = await (0, import_code_core4.describeAttachment)(isPdf ? "pdf" : "image", data, mimeType, rel);
156611
+ const { text } = await (0, import_code_core5.describeAttachment)(isPdf ? "pdf" : "image", data, mimeType, rel);
156514
156612
  content.push({ type: "text", text: `<attachment_description>
156515
156613
  ${text}
156516
156614
  </attachment_description>` });
@@ -156554,7 +156652,7 @@ ${text}
156554
156652
  process.exit(0);
156555
156653
  }
156556
156654
  case "/plugins": {
156557
- const plugins = (0, import_code_core4.loadPlugins)(workDir);
156655
+ const plugins = (0, import_code_core5.loadPlugins)(workDir);
156558
156656
  if (!plugins.length) {
156559
156657
  console.log(source_default.dim(" No plugins installed. Install one: nex plugin install owner/repo"));
156560
156658
  } else {
@@ -156567,7 +156665,7 @@ ${text}
156567
156665
  }
156568
156666
  console.log();
156569
156667
  }
156570
- skills = (0, import_code_core4.loadSkills)(workDir);
156668
+ skills = (0, import_code_core5.loadSkills)(workDir);
156571
156669
  rl.prompt();
156572
156670
  return;
156573
156671
  }
@@ -156702,8 +156800,8 @@ ${text}
156702
156800
  }
156703
156801
  case "/skills":
156704
156802
  case "/commands": {
156705
- skills = (0, import_code_core4.loadSkills)(workDir);
156706
- const invocable = (0, import_code_core4.userInvokableSkills)(skills);
156803
+ skills = (0, import_code_core5.loadSkills)(workDir);
156804
+ const invocable = (0, import_code_core5.userInvokableSkills)(skills);
156707
156805
  if (!invocable.length) {
156708
156806
  console.log(source_default.dim(" No skills. Add .nexrall/skills/<name>/SKILL.md (or .nexrall/commands/<name>.md) to create one."));
156709
156807
  } else {
@@ -156720,14 +156818,14 @@ ${text}
156720
156818
  return;
156721
156819
  }
156722
156820
  default: {
156723
- const custom = (0, import_code_core4.findSkill)(skills, cmd);
156821
+ const custom = (0, import_code_core5.findSkill)(skills, cmd);
156724
156822
  if (!custom) {
156725
156823
  console.log(source_default.red(` Unknown command: ${cmd}`));
156726
156824
  console.log(source_default.dim(" Type /help for built-ins or /skills for custom ones."));
156727
156825
  rl.prompt();
156728
156826
  return;
156729
156827
  }
156730
- const expanded = (0, import_code_core4.expandSkill)(custom, arg, workDir);
156828
+ const expanded = (0, import_code_core5.expandSkill)(custom, arg, workDir);
156731
156829
  const turnModel = custom.model ?? modelAlias;
156732
156830
  const turnMode = custom.mode ?? agentMode;
156733
156831
  console.log(source_default.dim(` Running /${custom.name}\u2026`));
@@ -156789,7 +156887,7 @@ ${text}
156789
156887
 
156790
156888
  // src/commands/plugin.ts
156791
156889
  var import_prompts = __toESM(require_prompts3(), 1);
156792
- var import_code_core6 = __toESM(require_dist3(), 1);
156890
+ var import_code_core7 = __toESM(require_dist3(), 1);
156793
156891
  function describeInspection(i2, name, ctx) {
156794
156892
  console.log();
156795
156893
  console.log(source_default.bold(` Plugin: ${name}`) + (i2.meta.version ? source_default.dim(` v${i2.meta.version}`) : ""));
@@ -156865,14 +156963,14 @@ async function pluginInstallCommand(spec, opts) {
156865
156963
  let registryName;
156866
156964
  const isShortName = /^[\w.-]+$/.test(spec.trim()) && !spec.includes("/");
156867
156965
  if (isShortName) {
156868
- const alias = (0, import_code_core6.resolveSourceAlias)(spec.trim(), process.cwd(), { includeProject: true });
156966
+ const alias = (0, import_code_core7.resolveSourceAlias)(spec.trim(), process.cwd(), { includeProject: true });
156869
156967
  if (alias) {
156870
156968
  source2 = alias.spec;
156871
156969
  console.log(source_default.dim(` Source: ${alias.name} (${alias.tier}) \u2190 ${alias.spec}`));
156872
156970
  }
156873
156971
  }
156874
156972
  if (isShortName && source2 === spec) {
156875
- const entry = await (0, import_code_core6.getRegistryPlugin)(spec.trim()).catch(() => null);
156973
+ const entry = await (0, import_code_core7.getRegistryPlugin)(spec.trim()).catch(() => null);
156876
156974
  if (entry) {
156877
156975
  source2 = entry.source;
156878
156976
  registryName = entry.name;
@@ -156887,7 +156985,7 @@ async function pluginInstallCommand(spec, opts) {
156887
156985
  return;
156888
156986
  }
156889
156987
  }
156890
- const res = await (0, import_code_core6.installPlugin)(source2, {
156988
+ const res = await (0, import_code_core7.installPlugin)(source2, {
156891
156989
  scope,
156892
156990
  workDir: process.cwd(),
156893
156991
  name: opts.name ?? registryName,
@@ -156895,7 +156993,7 @@ async function pluginInstallCommand(spec, opts) {
156895
156993
  confirm: (i2, name, ctx) => confirmInstall(i2, name, opts.yes === true, ctx)
156896
156994
  });
156897
156995
  if (registryName)
156898
- (0, import_code_core6.reportInstall)(registryName);
156996
+ (0, import_code_core7.reportInstall)(registryName);
156899
156997
  console.log();
156900
156998
  console.log(source_default.green(` \u2713 Installed "${res.name}" (${res.scope}) \u2192 ${res.dir}`) + (res.sha ? source_default.dim(` @ ${res.sha.slice(0, 7)}`) : ""));
156901
156999
  if (res.inspection.commands.length) {
@@ -156909,7 +157007,7 @@ async function pluginInstallCommand(spec, opts) {
156909
157007
  }
156910
157008
  function pluginRemoveCommand(name, opts) {
156911
157009
  try {
156912
- const dir = (0, import_code_core6.removePlugin)(name, {
157010
+ const dir = (0, import_code_core7.removePlugin)(name, {
156913
157011
  scope: opts.project ? "project" : void 0,
156914
157012
  // no flag → search both scopes
156915
157013
  workDir: process.cwd()
@@ -156922,14 +157020,14 @@ function pluginRemoveCommand(name, opts) {
156922
157020
  }
156923
157021
  async function pluginUpdateCommand(name, opts) {
156924
157022
  const workDir = process.cwd();
156925
- const targets = name ? [name] : (0, import_code_core6.loadPlugins)(workDir).filter((p) => (0, import_code_core6.readReceipt)(p.dir)?.kind === "github").map((p) => p.name);
157023
+ const targets = name ? [name] : (0, import_code_core7.loadPlugins)(workDir).filter((p) => (0, import_code_core7.readReceipt)(p.dir)?.kind === "github").map((p) => p.name);
156926
157024
  if (!targets.length) {
156927
157025
  console.log(source_default.dim(" No updatable plugins (only GitHub-installed plugins with receipts can update)."));
156928
157026
  return;
156929
157027
  }
156930
157028
  for (const t2 of targets) {
156931
157029
  try {
156932
- const res = await (0, import_code_core6.updatePlugin)(t2, {
157030
+ const res = await (0, import_code_core7.updatePlugin)(t2, {
156933
157031
  workDir,
156934
157032
  confirm: (i2, n, ctx) => confirmInstall(i2, n, opts.yes === true, ctx)
156935
157033
  });
@@ -156946,7 +157044,7 @@ function badgeFor(p) {
156946
157044
  }
156947
157045
  async function pluginSearchCommand(query) {
156948
157046
  try {
156949
- const results = await (0, import_code_core6.searchRegistry)(query);
157047
+ const results = await (0, import_code_core7.searchRegistry)(query);
156950
157048
  if (!results.length) {
156951
157049
  console.log(source_default.dim(query ? ` No plugins matching "${query}".` : " Registry is empty."));
156952
157050
  return;
@@ -156969,7 +157067,7 @@ async function pluginSearchCommand(query) {
156969
157067
  }
156970
157068
  async function pluginInfoCommand(name) {
156971
157069
  try {
156972
- const p = await (0, import_code_core6.getRegistryPlugin)(name);
157070
+ const p = await (0, import_code_core7.getRegistryPlugin)(name);
156973
157071
  if (!p) {
156974
157072
  console.error(source_default.red(` \u2717 "${name}" not found in the registry.`));
156975
157073
  process.exitCode = 1;
@@ -157005,7 +157103,7 @@ async function pluginInfoCommand(name) {
157005
157103
  }
157006
157104
  }
157007
157105
  function pluginListCommand() {
157008
- const plugins = (0, import_code_core6.loadPlugins)(process.cwd());
157106
+ const plugins = (0, import_code_core7.loadPlugins)(process.cwd());
157009
157107
  if (!plugins.length) {
157010
157108
  console.log(source_default.dim(" No plugins installed."));
157011
157109
  console.log(source_default.dim(" Install one: nex plugin install owner/repo"));
@@ -157014,10 +157112,10 @@ function pluginListCommand() {
157014
157112
  console.log();
157015
157113
  console.log(source_default.bold(" Installed plugins:"));
157016
157114
  for (const p of plugins) {
157017
- const receipt = (0, import_code_core6.readReceipt)(p.dir);
157115
+ const receipt = (0, import_code_core7.readReceipt)(p.dir);
157018
157116
  const src = receipt ? source_default.dim(` \u2190 ${receipt.source}`) : source_default.dim(" (manual)");
157019
157117
  const at = receipt?.sha ? source_default.dim(` @ ${receipt.sha.slice(0, 7)}`) : "";
157020
- const insp = (0, import_code_core6.inspectPluginDir)(p.dir);
157118
+ const insp = (0, import_code_core7.inspectPluginDir)(p.dir);
157021
157119
  const runs = insp.hasHooks || insp.hasMcp ? source_default.yellow(` \u26A0 ${[insp.hasHooks && "hooks", insp.hasMcp && "mcp"].filter(Boolean).join("+")}`) : "";
157022
157120
  console.log(
157023
157121
  " " + source_default.cyan(p.name.padEnd(24)) + source_default.dim(`${(p.version ?? "").padEnd(10)}${p.scope.padEnd(9)}`) + src + at + runs
@@ -157027,8 +157125,8 @@ function pluginListCommand() {
157027
157125
  }
157028
157126
  function pluginSourceListCommand() {
157029
157127
  const workDir = process.cwd();
157030
- const sources = (0, import_code_core6.loadDeclaredSources)(workDir, { includeProject: true });
157031
- const patterns = (0, import_code_core6.allowedSourcePatterns)();
157128
+ const sources = (0, import_code_core7.loadDeclaredSources)(workDir, { includeProject: true });
157129
+ const patterns = (0, import_code_core7.allowedSourcePatterns)();
157032
157130
  if (patterns) {
157033
157131
  console.log();
157034
157132
  console.log(source_default.bold(" Organisation policy: ") + source_default.dim(`installs restricted to ${patterns.join(", ")}`));
@@ -157043,7 +157141,7 @@ function pluginSourceListCommand() {
157043
157141
  console.log(source_default.bold(" Declared plugin sources:"));
157044
157142
  for (const s2 of sources) {
157045
157143
  const tier = s2.tier === "project" ? source_default.yellow(s2.tier.padEnd(9)) : source_default.dim(s2.tier.padEnd(9));
157046
- const blocked = !(0, import_code_core6.isSourceAllowed)(s2.spec, patterns) ? source_default.red(" \u2717 blocked by policy") : "";
157144
+ const blocked = !(0, import_code_core7.isSourceAllowed)(s2.spec, patterns) ? source_default.red(" \u2717 blocked by policy") : "";
157047
157145
  console.log(" " + source_default.cyan(s2.name.padEnd(20)) + tier + source_default.white(s2.spec) + blocked);
157048
157146
  }
157049
157147
  console.log();
@@ -157053,17 +157151,17 @@ function pluginSourceListCommand() {
157053
157151
  }
157054
157152
  function pluginSourceAddCommand(name, spec, opts) {
157055
157153
  try {
157056
- (0, import_code_core6.parsePluginSource)(spec);
157057
- const patterns = (0, import_code_core6.allowedSourcePatterns)();
157058
- if (patterns && !(0, import_code_core6.isSourceAllowed)(spec, patterns)) {
157154
+ (0, import_code_core7.parsePluginSource)(spec);
157155
+ const patterns = (0, import_code_core7.allowedSourcePatterns)();
157156
+ if (patterns && !(0, import_code_core7.isSourceAllowed)(spec, patterns)) {
157059
157157
  console.error(source_default.red(` \u2717 "${spec}" is not permitted by your organisation's policy.`));
157060
157158
  console.error(source_default.dim(` Allowed: ${patterns.join(", ")}`));
157061
157159
  process.exitCode = 1;
157062
157160
  return;
157063
157161
  }
157064
157162
  const scope = opts.project ? "project" : "user";
157065
- const file = (0, import_code_core6.sourcesFileFor)(scope, process.cwd());
157066
- (0, import_code_core6.writeDeclaredSource)(file, name, spec);
157163
+ const file = (0, import_code_core7.sourcesFileFor)(scope, process.cwd());
157164
+ (0, import_code_core7.writeDeclaredSource)(file, name, spec);
157067
157165
  console.log();
157068
157166
  console.log(source_default.green(` \u2713 Declared "${name}" \u2192 ${spec}`) + source_default.dim(` (${scope})`));
157069
157167
  console.log(source_default.dim(` ${file}`));
@@ -157077,13 +157175,13 @@ function pluginSourceAddCommand(name, spec, opts) {
157077
157175
  function pluginSourceRemoveCommand(name, opts) {
157078
157176
  const workDir = process.cwd();
157079
157177
  const scope = opts.project ? "project" : "user";
157080
- const file = (0, import_code_core6.sourcesFileFor)(scope, workDir);
157081
- if ((0, import_code_core6.removeDeclaredSource)(file, name)) {
157178
+ const file = (0, import_code_core7.sourcesFileFor)(scope, workDir);
157179
+ if ((0, import_code_core7.removeDeclaredSource)(file, name)) {
157082
157180
  console.log(source_default.green(` \u2713 Removed source "${name}" (${scope})`));
157083
157181
  console.log(source_default.dim(" Plugins already installed from it are untouched \u2014 remove them with nex plugin remove <name>"));
157084
157182
  return;
157085
157183
  }
157086
- const found = (0, import_code_core6.resolveSourceAlias)(name, workDir, { includeProject: true });
157184
+ const found = (0, import_code_core7.resolveSourceAlias)(name, workDir, { includeProject: true });
157087
157185
  if (found) {
157088
157186
  console.error(source_default.red(` \u2717 "${name}" is declared in the ${found.tier} tier, not ${scope}.`));
157089
157187
  console.error(source_default.dim(` ${found.file}`));
@@ -157104,6 +157202,13 @@ var program2 = new Command();
157104
157202
  program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version(NEX_VERSION).enablePositionalOptions();
157105
157203
  program2.command("auth").description("Login to your Nexrall account").action(authCommand);
157106
157204
  program2.command("logout").description("Log out of your Nexrall account").action(logoutCommand);
157205
+ var billing = program2.command("billing").description("Show, or change, which budget pays for your usage");
157206
+ billing.command("use <team|personal>").description("Bill to a team id (see `nex billing`) or back to your personal wallet").action(async (target) => {
157207
+ await billingUseCommand(target);
157208
+ });
157209
+ billing.action(async () => {
157210
+ await billingStatusCommand();
157211
+ });
157107
157212
  program2.command("update").description("Update nex to the latest version").option("-c, --check", "Check for updates without installing").option("-y, --yes", "Skip confirmation prompt").action(async (opts) => {
157108
157213
  await updateCommand({ check: opts.check, yes: opts.yes });
157109
157214
  });
@@ -157173,7 +157278,7 @@ program2.command("sessions").description("List or delete saved chat sessions").o
157173
157278
  console.log();
157174
157279
  });
157175
157280
  program2.option("-p, --pro", "Use Claude Opus 5 (most capable)").option("-t, --turbo", "Use Claude Sonnet 5 (fast, default)").option("-u, --ultra", "Use Claude Fable 5 (most powerful)").option("-y, --yolo", "Auto-approve all tool calls (no permission prompts)").option("-d, --dir <path>", "Set working directory (default: current directory)").option("-m, --model <name>", "Explicit model, e.g. claude-opus-5-5 | gpt-5.4 | gpt-4.1").option("-r, --resume [id]", "Resume last session, or a specific session id").option("-w, --worktree [name]", "Isolate this session in its own worktree \u2014 a separate directory (and, in a git repo, its own branch) so it can never overwrite files another session (or you) are touching in the main checkout. Omit a name for an auto-generated one; pass an existing name to resume that same worktree.").option("-e, --effort <level>", "Thinking effort \u2014 real levels depend on the model (e.g. DeepSeek: low|high|max, Qwen: low|high); run `nex --model <id>` then `/effort` with no argument to see a model's scale").option("--no-banner", "Skip the ASCII banner (useful in scripts/pipes)").option("--output-format <fmt>", "One-shot output format: text | json | stream-json (implies auto-approve)").option("--audit [path]", "Log every tool call (and refusal) to a JSONL trail (default: .nexrall/audit/<session>.jsonl)").argument("[prompt...]", "One-shot prompt \u2014 if omitted, starts interactive mode").action(async (promptParts, options) => {
157176
- if (!(0, import_code_core7.isAuthenticated)()) {
157281
+ if (!(0, import_code_core8.isAuthenticated)()) {
157177
157282
  console.error("Not logged in. Run: nex auth");
157178
157283
  process.exit(1);
157179
157284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexrall-code",
3
- "version": "0.5.110",
3
+ "version": "0.5.111",
4
4
  "description": "Nexrall Code — AI coding assistant for your terminal (headless agent for scripts, CI and automation)",
5
5
  "keywords": [
6
6
  "ai",