@nathapp/nax 0.83.7 → 0.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/nax.js +506 -388
  2. package/package.json +4 -5
package/dist/nax.js CHANGED
@@ -2198,6 +2198,266 @@ function killProcessGroup(pid, signal) {
2198
2198
  }
2199
2199
  }
2200
2200
 
2201
+ // ../nax-agent/src/terminal-auth/open-url.ts
2202
+ import { spawn } from "child_process";
2203
+ function spawnDetached(command) {
2204
+ const [file, ...args] = command;
2205
+ const child = spawn(file ?? "", args, { stdio: "ignore", detached: true, windowsHide: true });
2206
+ child.on("error", () => {});
2207
+ child.unref();
2208
+ return child;
2209
+ }
2210
+ function openerFor(platform, url) {
2211
+ if (platform === "darwin")
2212
+ return ["open", url];
2213
+ if (platform === "win32")
2214
+ return ["cmd", "/c", "start", "", url];
2215
+ return ["xdg-open", url];
2216
+ }
2217
+ function openUrl(url) {
2218
+ try {
2219
+ _openUrlDeps.spawn(openerFor(_openUrlDeps.platform(), url));
2220
+ } catch {}
2221
+ }
2222
+ var _openUrlDeps;
2223
+ var init_open_url = __esm(() => {
2224
+ _openUrlDeps = {
2225
+ spawn: (command) => {
2226
+ spawnDetached(command);
2227
+ },
2228
+ platform: () => process.platform
2229
+ };
2230
+ });
2231
+
2232
+ // ../nax-agent/src/terminal-auth/prompt.ts
2233
+ function stdinOf() {
2234
+ return _terminalPromptDeps.stdin ?? process.stdin;
2235
+ }
2236
+ function keyAction(char, bufferEmpty, hasEmptyHook) {
2237
+ if (char === ETX || char === EOT)
2238
+ return { kind: "cancel" };
2239
+ if (char === CR || char === LF) {
2240
+ return bufferEmpty && hasEmptyHook ? { kind: "empty-submit" } : { kind: "submit" };
2241
+ }
2242
+ if (char === BACKSPACE)
2243
+ return { kind: "erase" };
2244
+ return { kind: "append" };
2245
+ }
2246
+ function applyEdit(action, char, buffer, echo, onEmptySubmit) {
2247
+ if (action.kind === "empty-submit") {
2248
+ onEmptySubmit?.();
2249
+ return buffer;
2250
+ }
2251
+ if (action.kind === "erase") {
2252
+ if (echo)
2253
+ _terminalPromptDeps.write("\b \b");
2254
+ return buffer.slice(0, -1);
2255
+ }
2256
+ if (echo)
2257
+ _terminalPromptDeps.write(char);
2258
+ return buffer + char;
2259
+ }
2260
+ function read(message, echo, onEmptySubmit, style) {
2261
+ const stdin = stdinOf();
2262
+ if (stdin.isTTY !== true)
2263
+ return Promise.reject(new PromptCancelledError);
2264
+ _terminalPromptDeps.write(`${style.accent("?")} ${message} `);
2265
+ return new Promise((resolve3, reject) => {
2266
+ let buffer = "";
2267
+ let settled = false;
2268
+ const cleanup = () => {
2269
+ if (settled)
2270
+ return;
2271
+ settled = true;
2272
+ stdin.removeListener("data", onData);
2273
+ stdin.removeListener("end", onEnd);
2274
+ stdin.removeListener("error", onEnd);
2275
+ stdin.setRawMode(false);
2276
+ stdin.pause();
2277
+ _terminalPromptDeps.write(`
2278
+ `);
2279
+ };
2280
+ const onEnd = () => {
2281
+ cleanup();
2282
+ reject(new PromptCancelledError);
2283
+ };
2284
+ const onData = (chunk) => {
2285
+ for (const char of chunk) {
2286
+ const action = keyAction(char, buffer.length === 0, onEmptySubmit !== undefined);
2287
+ if (action.kind === "cancel") {
2288
+ onEnd();
2289
+ return;
2290
+ }
2291
+ if (action.kind === "submit") {
2292
+ cleanup();
2293
+ resolve3(buffer);
2294
+ return;
2295
+ }
2296
+ buffer = applyEdit(action, char, buffer, echo, onEmptySubmit);
2297
+ }
2298
+ };
2299
+ stdin.setRawMode(true);
2300
+ stdin.resume();
2301
+ stdin.setEncoding("utf8");
2302
+ stdin.on("data", onData);
2303
+ stdin.once("end", onEnd);
2304
+ stdin.once("error", onEnd);
2305
+ });
2306
+ }
2307
+ function promptForSecret(message, style = PLAIN_STYLE) {
2308
+ return read(message, false, undefined, style);
2309
+ }
2310
+ function promptForLine(message, onEmptySubmit, style = PLAIN_STYLE) {
2311
+ return read(message, true, onEmptySubmit, style);
2312
+ }
2313
+ function promptForSelect(message, choices, style = PLAIN_STYLE) {
2314
+ const stdin = stdinOf();
2315
+ if (stdin.isTTY !== true)
2316
+ return Promise.reject(new PromptCancelledError);
2317
+ if (choices.length === 0)
2318
+ return Promise.reject(new PromptCancelledError);
2319
+ _terminalPromptDeps.write(`${style.accent("?")} ${message}
2320
+ `);
2321
+ return new Promise((resolve3, reject) => {
2322
+ let index = 0;
2323
+ let settled = false;
2324
+ let drawn = false;
2325
+ const render = () => {
2326
+ if (drawn)
2327
+ _terminalPromptDeps.write(`\x1B[${choices.length}A`);
2328
+ drawn = true;
2329
+ for (const [i, choice] of choices.entries()) {
2330
+ const active = i === index;
2331
+ const marker = active ? style.accent(">") : " ";
2332
+ const label = active ? style.accent(choice.label) : choice.label;
2333
+ _terminalPromptDeps.write(`\r\x1B[2K${marker} ${label}
2334
+ `);
2335
+ }
2336
+ };
2337
+ const cleanup = () => {
2338
+ if (settled)
2339
+ return;
2340
+ settled = true;
2341
+ stdin.removeListener("data", onData);
2342
+ stdin.removeListener("end", onEnd);
2343
+ stdin.removeListener("error", onEnd);
2344
+ stdin.setRawMode(false);
2345
+ stdin.pause();
2346
+ };
2347
+ const onEnd = () => {
2348
+ cleanup();
2349
+ reject(new PromptCancelledError);
2350
+ };
2351
+ const onData = (chunk) => {
2352
+ if (chunk.includes(ETX) || chunk.includes(EOT)) {
2353
+ onEnd();
2354
+ return;
2355
+ }
2356
+ if (chunk.includes(ARROW_UP)) {
2357
+ index = (index - 1 + choices.length) % choices.length;
2358
+ render();
2359
+ return;
2360
+ }
2361
+ if (chunk.includes(ARROW_DOWN)) {
2362
+ index = (index + 1) % choices.length;
2363
+ render();
2364
+ return;
2365
+ }
2366
+ if (chunk.includes(CR) || chunk.includes(LF)) {
2367
+ const chosen = choices[index];
2368
+ cleanup();
2369
+ resolve3(chosen.id);
2370
+ }
2371
+ };
2372
+ stdin.setRawMode(true);
2373
+ stdin.resume();
2374
+ stdin.setEncoding("utf8");
2375
+ stdin.on("data", onData);
2376
+ stdin.once("end", onEnd);
2377
+ stdin.once("error", onEnd);
2378
+ render();
2379
+ });
2380
+ }
2381
+ var ETX = "\x03", EOT = "\x04", CR = "\r", LF = `
2382
+ `, BACKSPACE = "\x7F", ARROW_UP = "\x1B[A", ARROW_DOWN = "\x1B[B", identity = (text) => text, PLAIN_STYLE, PromptCancelledError, _terminalPromptDeps;
2383
+ var init_prompt = __esm(() => {
2384
+ PLAIN_STYLE = { accent: identity, dim: identity, bold: identity };
2385
+ PromptCancelledError = class PromptCancelledError extends Error {
2386
+ constructor() {
2387
+ super("Prompt cancelled");
2388
+ this.name = "PromptCancelledError";
2389
+ }
2390
+ };
2391
+ _terminalPromptDeps = {
2392
+ stdin: undefined,
2393
+ write: (text) => process.stdout.write(text)
2394
+ };
2395
+ });
2396
+
2397
+ // ../nax-agent/src/terminal-auth/interaction.ts
2398
+ function createTerminalAuthInteraction(options) {
2399
+ const style = options.style ?? PLAIN_STYLE;
2400
+ const open = options.openUrl ?? openUrl;
2401
+ let pendingUrl;
2402
+ const manualCode = (message) => {
2403
+ const url = pendingUrl;
2404
+ if (url === undefined)
2405
+ return promptForLine(message, undefined, style);
2406
+ pendingUrl = undefined;
2407
+ options.log(style.dim("Press Enter to open it in your browser."));
2408
+ return promptForLine(message, () => {
2409
+ options.log(style.dim("Opening your browser..."));
2410
+ open(url);
2411
+ }, style);
2412
+ };
2413
+ return {
2414
+ prompt: async (prompt) => {
2415
+ if (prompt.type === "manual-code")
2416
+ return manualCode(prompt.message);
2417
+ if (prompt.type === "text")
2418
+ return promptForLine(prompt.message, undefined, style);
2419
+ if (prompt.type === "select") {
2420
+ return promptForSelect(prompt.message, prompt.options.map((option) => ({ id: option.id, label: option.label })), style);
2421
+ }
2422
+ return promptForSecret(prompt.message, style);
2423
+ },
2424
+ notify: (event) => {
2425
+ switch (event.type) {
2426
+ case "auth-url":
2427
+ options.log(`
2428
+ ${style.bold("Open this URL to continue:")}
2429
+ ${event.url}`);
2430
+ pendingUrl = event.url;
2431
+ return;
2432
+ case "device-code":
2433
+ options.log(`
2434
+ Go to ${event.verificationUri} and enter code ${style.bold(event.userCode)}`);
2435
+ return;
2436
+ case "info":
2437
+ options.log(event.message);
2438
+ for (const link of event.links ?? [])
2439
+ options.log(` ${link.label ?? "Link"}: ${link.url}`);
2440
+ return;
2441
+ case "progress":
2442
+ options.log(style.dim(event.message));
2443
+ return;
2444
+ default:
2445
+ }
2446
+ }
2447
+ };
2448
+ }
2449
+ var init_interaction = __esm(() => {
2450
+ init_open_url();
2451
+ init_prompt();
2452
+ });
2453
+
2454
+ // ../nax-agent/src/terminal-auth/index.ts
2455
+ var init_terminal_auth = __esm(() => {
2456
+ init_interaction();
2457
+ init_open_url();
2458
+ init_prompt();
2459
+ });
2460
+
2201
2461
  // ../nax-agent/src/native/credentials/chained-store.ts
2202
2462
  function createChainedCredentialStore(options) {
2203
2463
  const served = new Map;
@@ -2348,37 +2608,37 @@ function classify2(previous, next) {
2348
2608
  return "renewed";
2349
2609
  return "changed";
2350
2610
  }
2351
- function identityData(providerId, identity) {
2611
+ function identityData(providerId, identity2) {
2352
2612
  return {
2353
2613
  providerId,
2354
- kind: identity.kind,
2355
- source: identity.source,
2356
- fingerprint: identity.fingerprint,
2357
- ...identity.account !== undefined ? { account: identity.account } : {}
2614
+ kind: identity2.kind,
2615
+ source: identity2.source,
2616
+ fingerprint: identity2.fingerprint,
2617
+ ...identity2.account !== undefined ? { account: identity2.account } : {}
2358
2618
  };
2359
2619
  }
2360
- function replacementData(providerId, identity, previous) {
2620
+ function replacementData(providerId, identity2, previous) {
2361
2621
  return {
2362
- ...identityData(providerId, identity),
2622
+ ...identityData(providerId, identity2),
2363
2623
  previousFingerprint: previous.fingerprint,
2364
2624
  ...previous.account !== undefined ? { previousAccount: previous.account } : {}
2365
2625
  };
2366
2626
  }
2367
- function toStamp(identity) {
2627
+ function toStamp(identity2) {
2368
2628
  return {
2369
- fingerprint: identity.fingerprint,
2370
- source: identity.source,
2371
- ...identity.account !== undefined ? { account: identity.account } : {}
2629
+ fingerprint: identity2.fingerprint,
2630
+ source: identity2.source,
2631
+ ...identity2.account !== undefined ? { account: identity2.account } : {}
2372
2632
  };
2373
2633
  }
2374
2634
  function createChangeGuard(inner, options) {
2375
2635
  const identities = new Map;
2376
- async function read(providerId) {
2636
+ async function read2(providerId) {
2377
2637
  const credential = await inner.read(providerId);
2378
2638
  if (credential === undefined)
2379
2639
  return;
2380
2640
  const described = options.describe(providerId);
2381
- const identity = {
2641
+ const identity2 = {
2382
2642
  kind: credential.kind,
2383
2643
  fingerprint: await fingerprintCredential(credential, options.salt),
2384
2644
  source: described?.source ?? "file",
@@ -2386,39 +2646,39 @@ function createChangeGuard(inner, options) {
2386
2646
  };
2387
2647
  const previous = identities.get(providerId);
2388
2648
  if (previous === undefined) {
2389
- getSafeLogger()?.info("credentials", "credential.resolved", identityData(providerId, identity));
2390
- identities.set(providerId, identity);
2649
+ getSafeLogger()?.info("credentials", "credential.resolved", identityData(providerId, identity2));
2650
+ identities.set(providerId, identity2);
2391
2651
  return credential;
2392
2652
  }
2393
- const verdict = classify2(previous, identity);
2653
+ const verdict = classify2(previous, identity2);
2394
2654
  if (verdict === "renewed") {
2395
- getSafeLogger()?.info("credentials", "credential.renewed", replacementData(providerId, identity, previous));
2655
+ getSafeLogger()?.info("credentials", "credential.renewed", replacementData(providerId, identity2, previous));
2396
2656
  } else if (verdict === "changed") {
2397
2657
  getSafeLogger()?.warn("credentials", "credential.changed", {
2398
- ...replacementData(providerId, identity, previous),
2658
+ ...replacementData(providerId, identity2, previous),
2399
2659
  onChange: options.onChange
2400
2660
  });
2401
2661
  if (options.onChange === "refuse") {
2402
- throw new NaxError(`[credentials] Credential for ${providerId} changed from ${previous.fingerprint} to ${identity.fingerprint}`, "CREDENTIAL_CHANGED", {
2662
+ throw new NaxError(`[credentials] Credential for ${providerId} changed from ${previous.fingerprint} to ${identity2.fingerprint}`, "CREDENTIAL_CHANGED", {
2403
2663
  stage: "credentials",
2404
2664
  providerId,
2405
- kind: identity.kind,
2406
- source: identity.source,
2407
- fingerprint: identity.fingerprint,
2665
+ kind: identity2.kind,
2666
+ source: identity2.source,
2667
+ fingerprint: identity2.fingerprint,
2408
2668
  previousFingerprint: previous.fingerprint
2409
2669
  });
2410
2670
  }
2411
2671
  }
2412
- identities.set(providerId, identity);
2672
+ identities.set(providerId, identity2);
2413
2673
  return credential;
2414
2674
  }
2415
2675
  return {
2416
- read,
2676
+ read: read2,
2417
2677
  modify: (providerId, fn) => inner.modify(providerId, fn),
2418
2678
  delete: (providerId) => inner.delete(providerId),
2419
2679
  servedAuth: (providerId) => {
2420
- const identity = identities.get(providerId);
2421
- return identity === undefined ? undefined : toStamp(identity);
2680
+ const identity2 = identities.get(providerId);
2681
+ return identity2 === undefined ? undefined : toStamp(identity2);
2422
2682
  }
2423
2683
  };
2424
2684
  }
@@ -2980,7 +3240,7 @@ function createExecCredentialSource(options) {
2980
3240
  async function callHelper(providerId) {
2981
3241
  return applyOutcome(providerId, outcomeOf(await runHelper(options.command, providerId, timeoutMs)));
2982
3242
  }
2983
- async function read(providerId) {
3243
+ async function read2(providerId) {
2984
3244
  if (declined.has(providerId))
2985
3245
  return;
2986
3246
  const lease = leases.get(providerId);
@@ -3002,7 +3262,7 @@ function createExecCredentialSource(options) {
3002
3262
  return new NaxError(`[credentials] Cannot ${operation} the credential for ${providerId}: the exec helper owns it.`, "CREDENTIAL_MANAGED_BY_HELPER", { stage: "credentials", providerId, operation });
3003
3263
  }
3004
3264
  return {
3005
- read,
3265
+ read: read2,
3006
3266
  modify(providerId) {
3007
3267
  throw managedByHelper(providerId, "modify");
3008
3268
  },
@@ -3232,6 +3492,9 @@ async function importPiCredentials(options) {
3232
3492
  async function listStoredProviders() {
3233
3493
  return readStoredEntries();
3234
3494
  }
3495
+ async function loginProviderIds() {
3496
+ return _authDeps.providerIds();
3497
+ }
3235
3498
  async function removeStoredProvider(providerId) {
3236
3499
  await naxCredentialStore().delete(providerId);
3237
3500
  }
@@ -3668,6 +3931,20 @@ var init_model_resolver = __esm(() => {
3668
3931
  init_client();
3669
3932
  });
3670
3933
 
3934
+ // ../nax-agent/src/native/provider-models.ts
3935
+ async function listProviderModels(providerId, catalogOverrides = []) {
3936
+ const client = await getNativeClient(catalogOverrides);
3937
+ const models = await client.listModels(providerId);
3938
+ return models.filter((model) => model.supportsTools).map((model) => ({
3939
+ id: model.id,
3940
+ contextWindow: model.contextWindow,
3941
+ ...model.maxTokens !== undefined ? { maxTokens: model.maxTokens } : {}
3942
+ })).sort((a, b) => byCodePoint(a.id, b.id));
3943
+ }
3944
+ var init_provider_models = __esm(() => {
3945
+ init_client();
3946
+ });
3947
+
3671
3948
  // ../nax-agent/src/native/session/memory-transcript-store.ts
3672
3949
  function createMemoryTranscriptStore() {
3673
3950
  const live = new Map;
@@ -3704,8 +3981,8 @@ function createMemoryTranscriptStore() {
3704
3981
  function transcriptModelIdentity(rawModel) {
3705
3982
  return rawModel === undefined ? undefined : parseModelSpec(rawModel).model;
3706
3983
  }
3707
- function isForeignTranscript(doc, identity, sessionName) {
3708
- const { owner, model } = identity;
3984
+ function isForeignTranscript(doc, identity2, sessionName) {
3985
+ const { owner, model } = identity2;
3709
3986
  if (owner !== undefined && doc.owner !== owner) {
3710
3987
  getLogger().debug("native-session", "Ignoring a transcript owned by another invocation", {
3711
3988
  sessionName,
@@ -3714,7 +3991,7 @@ function isForeignTranscript(doc, identity, sessionName) {
3714
3991
  });
3715
3992
  return true;
3716
3993
  }
3717
- if (model !== undefined && doc.model !== undefined && doc.model !== model) {
3994
+ if (identity2.carryAcrossModels !== true && model !== undefined && doc.model !== undefined && doc.model !== model) {
3718
3995
  getLogger().debug("native-session", "Ignoring a transcript written by another model", {
3719
3996
  sessionName,
3720
3997
  storedModel: doc.model,
@@ -3724,7 +4001,7 @@ function isForeignTranscript(doc, identity, sessionName) {
3724
4001
  }
3725
4002
  return false;
3726
4003
  }
3727
- function historyFromTranscript(doc, identity, sessionName) {
4004
+ function historyFromTranscript(doc, identity2, sessionName) {
3728
4005
  if (doc === null)
3729
4006
  return [];
3730
4007
  const version = doc.schemaVersion;
@@ -3734,14 +4011,14 @@ function historyFromTranscript(doc, identity, sessionName) {
3734
4011
  if (!Array.isArray(doc.messages)) {
3735
4012
  throw new NaxError(`transcript for session "${sessionName}" is unreadable: messages is not an array`, "TRANSCRIPT_CORRUPT", { stage: "native-session" });
3736
4013
  }
3737
- if (isForeignTranscript(doc, identity, sessionName))
4014
+ if (isForeignTranscript(doc, identity2, sessionName))
3738
4015
  return [];
3739
4016
  return doc.messages;
3740
4017
  }
3741
- function transcriptDocFor(messages, identity) {
4018
+ function transcriptDocFor(messages, identity2) {
3742
4019
  return {
3743
- ...identity.owner !== undefined ? { owner: identity.owner } : {},
3744
- ...identity.model !== undefined ? { model: identity.model } : {},
4020
+ ...identity2.owner !== undefined ? { owner: identity2.owner } : {},
4021
+ ...identity2.model !== undefined ? { model: identity2.model } : {},
3745
4022
  savedAt: new Date().toISOString(),
3746
4023
  messages: [...messages]
3747
4024
  };
@@ -3818,11 +4095,11 @@ function createFileTranscriptStore(dir) {
3818
4095
  }
3819
4096
  };
3820
4097
  }
3821
- async function loadTranscript(dir, sessionName, identity = {}) {
3822
- return [...historyFromTranscript(await readTranscriptDoc(dir, sessionName), identity, sessionName)];
4098
+ async function loadTranscript(dir, sessionName, identity2 = {}) {
4099
+ return [...historyFromTranscript(await readTranscriptDoc(dir, sessionName), identity2, sessionName)];
3823
4100
  }
3824
- async function saveTranscript(dir, sessionName, messages, identity = {}) {
3825
- await writeTranscriptDoc(dir, sessionName, transcriptDocFor(messages, identity));
4101
+ async function saveTranscript(dir, sessionName, messages, identity2 = {}) {
4102
+ await writeTranscriptDoc(dir, sessionName, transcriptDocFor(messages, identity2));
3826
4103
  }
3827
4104
  async function retainTranscript(dir, sessionName) {
3828
4105
  const stamp = new Date().toISOString().replace(/[:.]/g, "-");
@@ -4543,7 +4820,7 @@ async function openRepositoryInstructions(name, opts, store) {
4543
4820
  if (doc === null || doc.schemaVersion !== undefined && doc.schemaVersion !== 1 || !Array.isArray(doc.messages))
4544
4821
  return instructions;
4545
4822
  const ownerMatches = opts.transcriptOwner === undefined || doc?.owner === opts.transcriptOwner;
4546
- const modelMatches = doc?.model === undefined || doc.model === transcriptModelIdentity(opts.modelDef?.model);
4823
+ const modelMatches = opts.carryHistoryAcrossModels === true || doc?.model === undefined || doc.model === transcriptModelIdentity(opts.modelDef?.model);
4547
4824
  if (ownerMatches && modelMatches) {
4548
4825
  const directories = doc?.instructionDirectories;
4549
4826
  if (Array.isArray(directories)) {
@@ -4596,6 +4873,7 @@ function createNativeSessionState() {
4596
4873
  streamHooks: new Map,
4597
4874
  failed: new Set,
4598
4875
  transcriptOwners: new Map,
4876
+ carryHistoryAcrossModels: new Set,
4599
4877
  compaction: new Map,
4600
4878
  transportRetry: new Map,
4601
4879
  spinBreakers: new Map,
@@ -4666,6 +4944,10 @@ async function openNativeSession(state, name, opts) {
4666
4944
  state.transcriptOwners.set(name, opts.transcriptOwner);
4667
4945
  else
4668
4946
  state.transcriptOwners.delete(name);
4947
+ if (opts.carryHistoryAcrossModels === true)
4948
+ state.carryHistoryAcrossModels.add(name);
4949
+ else
4950
+ state.carryHistoryAcrossModels.delete(name);
4669
4951
  recordSystemPrompt(state, name, opts.systemPrompt);
4670
4952
  const instructions = await openRepositoryInstructions(name, opts, store);
4671
4953
  state.repositoryInstructions.set(name, instructions);
@@ -4702,6 +4984,7 @@ function clearNativeSessionState(state, sessionName) {
4702
4984
  state.timeouts.delete(sessionName);
4703
4985
  state.scratchpadRoots.delete(sessionName);
4704
4986
  state.transcriptOwners.delete(sessionName);
4987
+ state.carryHistoryAcrossModels.delete(sessionName);
4705
4988
  state.streamHooks.delete(sessionName);
4706
4989
  state.failed.delete(sessionName);
4707
4990
  state.compaction.delete(sessionName);
@@ -5005,7 +5288,8 @@ function rewriteToolCallInput(messages, callId, input) {
5005
5288
  role: "assistant",
5006
5289
  content: lastAssistant.content,
5007
5290
  toolCalls,
5008
- ...lastAssistant.thinking !== undefined ? { thinking: lastAssistant.thinking } : {}
5291
+ ...lastAssistant.thinking !== undefined ? { thinking: lastAssistant.thinking } : {},
5292
+ ...lastAssistant.origin !== undefined ? { origin: lastAssistant.origin } : {}
5009
5293
  },
5010
5294
  ...messages.slice(lastAssistantIndex + 1)
5011
5295
  ];
@@ -20899,11 +21183,24 @@ function flagFromBoolean(input, field, subcommand, validVerbs, flag) {
20899
21183
  function looksLikeFlag(value) {
20900
21184
  return value.startsWith("-");
20901
21185
  }
21186
+ function buildGitRootArgv(input) {
21187
+ const extraFields = Object.keys(input).filter((field) => field !== "subcommand");
21188
+ if (extraFields.length > 0) {
21189
+ return { error: `rev-parse accepts no additional fields (received: ${extraFields.join(", ")})` };
21190
+ }
21191
+ return ["rev-parse", "--show-toplevel"];
21192
+ }
21193
+ function defaultGitExcludes(subcommand, excludes) {
21194
+ return subcommand === "blame" ? [] : excludes;
21195
+ }
20902
21196
  function buildGitArgv(input, defaultExcludes = []) {
20903
21197
  const subcommand = input.subcommand;
20904
21198
  if (typeof subcommand !== "string" || !GIT_READ_VERBS.includes(subcommand)) {
20905
21199
  return { error: `subcommand must be one of: ${GIT_READ_VERBS.join(", ")}` };
20906
21200
  }
21201
+ if (subcommand === "rev-parse") {
21202
+ return buildGitRootArgv(input);
21203
+ }
20907
21204
  const refs = Array.isArray(input.refs) ? input.refs : [];
20908
21205
  const paths = Array.isArray(input.paths) ? input.paths : [];
20909
21206
  const argv = [subcommand];
@@ -20969,8 +21266,7 @@ function buildGitArgv(input, defaultExcludes = []) {
20969
21266
  argv.push("--");
20970
21267
  if (paths.length === 0) {
20971
21268
  argv.push(".");
20972
- if (subcommand !== "blame")
20973
- argv.push(...defaultExcludes);
21269
+ argv.push(...defaultGitExcludes(subcommand, defaultExcludes));
20974
21270
  return argv;
20975
21271
  }
20976
21272
  for (const path of paths) {
@@ -20988,7 +21284,7 @@ var init_git = __esm(() => {
20988
21284
  init_git_exec();
20989
21285
  init_truncate();
20990
21286
  init_git_flags();
20991
- GIT_READ_VERBS = ["diff", "log", "show", "status", "blame"];
21287
+ GIT_READ_VERBS = ["diff", "log", "show", "status", "blame", "rev-parse"];
20992
21288
  GIT_DIFF_FILTERS = ["A", "M", "D", "R"];
20993
21289
  GIT_NAME_ONLY_VERBS = ["diff", "log", "show"];
20994
21290
  GIT_DIFF_FILTER_VERBS = ["diff", "log", "show"];
@@ -20997,11 +21293,15 @@ var init_git = __esm(() => {
20997
21293
  GIT_FULL_MESSAGE_VERBS = ["log"];
20998
21294
  gitTool = {
20999
21295
  name: "Git",
21000
- description: "Run a read-only git command (diff, log, show, status, blame) in the repository. Supply refs and pathspecs as arrays, not as a command line. Command-line flags are not accepted in any field; use the nameOnly, diffFilter, oneline, fullMessage and maxCount fields instead.",
21296
+ description: "Run a read-only git command (diff, log, show, status, blame, rev-parse) in the repository. rev-parse is fixed to `git rev-parse --show-toplevel` and accepts no other fields. Supply refs and pathspecs as arrays, not as a command line. Command-line flags are not accepted in any field; use the nameOnly, diffFilter, oneline, fullMessage and maxCount fields instead.",
21001
21297
  inputSchema: {
21002
21298
  type: "object",
21003
21299
  properties: {
21004
- subcommand: { type: "string", enum: [...GIT_READ_VERBS], description: "Read-only git subcommand" },
21300
+ subcommand: {
21301
+ type: "string",
21302
+ enum: [...GIT_READ_VERBS],
21303
+ description: "Read-only git subcommand; rev-parse is fixed to --show-toplevel"
21304
+ },
21005
21305
  refs: { type: "array", items: { type: "string" }, description: "Refs, e.g. ['HEAD~1','HEAD']" },
21006
21306
  paths: { type: "array", items: { type: "string" }, description: "Pathspecs, relative to the permitted root" },
21007
21307
  nameOnly: {
@@ -23701,7 +24001,7 @@ function redirectForVerb(deniedTool, verb, available, declaredCommands) {
23701
24001
  }
23702
24002
  var GIT_READ_VERBS2, GIT_COMMIT_VERBS, GIT_REVERT_VERBS, NAX_OWNED_RUN_STATE_EXPLANATION = "`.nax/` is nax's own run state, written by the harness during this run. It is not part of your diff and must not be reverted.", GLOB, GREP, READ, DELETE, GIT, GIT_COMMIT2, TEST_SCOPED, BASH, HEAD_INTENTS, TASK_RUNNERS, INSTALL_VERBS;
23703
24003
  var init_denial_redirect = __esm(() => {
23704
- GIT_READ_VERBS2 = new Set(["diff", "log", "show", "status", "blame"]);
24004
+ GIT_READ_VERBS2 = new Set(["diff", "log", "show", "status", "blame", "rev-parse"]);
23705
24005
  GIT_COMMIT_VERBS = new Set(["add", "commit"]);
23706
24006
  GIT_REVERT_VERBS = new Set(["checkout", "restore"]);
23707
24007
  GLOB = { tool: "Glob", how: "Glob lists repository paths by pattern" };
@@ -24846,7 +25146,7 @@ function usageEvent(round, usage, costUsd) {
24846
25146
  costUsd
24847
25147
  };
24848
25148
  }
24849
- function cappedInput(input) {
25149
+ function displayToolInput(input) {
24850
25150
  const redacted = redactSecrets(capStrings(input, REDACTION_SCAN_BYTES));
24851
25151
  let json2;
24852
25152
  try {
@@ -24858,7 +25158,7 @@ function cappedInput(input) {
24858
25158
  return redacted;
24859
25159
  return { truncated: true, preview: cutToByteCap(json2, TOOL_CALL_INPUT_BYTES) };
24860
25160
  }
24861
- function previewOf(content) {
25161
+ function toolResultPreview(content) {
24862
25162
  return cutToByteCap(redactSecrets(cutToByteCap(content, REDACTION_SCAN_BYTES)), TOOL_RESULT_PREVIEW_BYTES);
24863
25163
  }
24864
25164
  function createTurnEventEmitter(sink) {
@@ -24890,7 +25190,7 @@ function createTurnEventEmitter(sink) {
24890
25190
  emit,
24891
25191
  deltaSink: (round) => (delta) => emit({ ...delta, round }),
24892
25192
  toolCall(call, recordedInput) {
24893
- const input = cappedInput(recordedInput ?? call.input);
25193
+ const input = displayToolInput(recordedInput ?? call.input);
24894
25194
  outstanding.set(call.id, (outstanding.get(call.id) ?? 0) + 1);
24895
25195
  emit({ type: "tool_call", callId: call.id, name: call.name, input });
24896
25196
  },
@@ -24906,7 +25206,7 @@ function createTurnEventEmitter(sink) {
24906
25206
  type: "tool_result",
24907
25207
  callId: result.toolCallId,
24908
25208
  isError: result.isError === true,
24909
- preview: previewOf(result.content)
25209
+ preview: toolResultPreview(result.content)
24910
25210
  });
24911
25211
  },
24912
25212
  flushUnanswered() {
@@ -25535,6 +25835,15 @@ async function maybeCompact(state, params) {
25535
25835
  }
25536
25836
  return { summarizeFailed: step.summarizeFailed };
25537
25837
  }
25838
+ function originOf(raw) {
25839
+ if (raw === undefined)
25840
+ return;
25841
+ const spec = parseModelSpec(raw).model;
25842
+ const slash = spec.indexOf("/");
25843
+ if (slash <= 0 || slash === spec.length - 1)
25844
+ return;
25845
+ return { provider: spec.slice(0, slash), model: spec.slice(slash + 1) };
25846
+ }
25538
25847
  async function runModelRoundTrip(state, params, summarizeFailed) {
25539
25848
  const { handle, opts, deps, tools, loopEvents } = params;
25540
25849
  const step = await completeWithRecovery({
@@ -25590,11 +25899,13 @@ async function runModelRoundTrip(state, params, summarizeFailed) {
25590
25899
  state.output = assistantText;
25591
25900
  const assistantToolCalls = afterResponse.toolCalls ?? res.toolCalls;
25592
25901
  const assistantThinking = afterResponse.thinking ?? res.thinking;
25902
+ const origin = originOf(handle.modelDef?.model);
25593
25903
  state.messages.push({
25594
25904
  role: "assistant",
25595
25905
  content: assistantText,
25596
25906
  ...assistantToolCalls !== undefined ? { toolCalls: assistantToolCalls } : {},
25597
- ...assistantThinking !== undefined ? { thinking: assistantThinking } : {}
25907
+ ...assistantThinking !== undefined ? { thinking: assistantThinking } : {},
25908
+ ...origin !== undefined ? { origin } : {}
25598
25909
  });
25599
25910
  if (assistantToolCalls === undefined || assistantToolCalls.length === 0) {
25600
25911
  state.completedNormally = true;
@@ -25683,6 +25994,7 @@ var MAX_FOLLOW_UPS_PER_TURN = 3;
25683
25994
  var init_turn_loop_round_trip = __esm(() => {
25684
25995
  init_core();
25685
25996
  init_infra();
25997
+ init_models();
25686
25998
  init_turn_accumulator();
25687
25999
  init_turn_compaction_step();
25688
26000
  init_turn_complete_step();
@@ -25772,7 +26084,8 @@ async function runNativeTurn(handle, prompt, opts, deps) {
25772
26084
  const { store } = transcript;
25773
26085
  const transcriptIdentity = {
25774
26086
  owner: deps.sessionState.transcriptOwners.get(handle.id),
25775
- model: transcriptModelIdentity(handle.modelDef?.model)
26087
+ model: transcriptModelIdentity(handle.modelDef?.model),
26088
+ ...deps.sessionState.carryHistoryAcrossModels.has(handle.id) ? { carryAcrossModels: true } : {}
25776
26089
  };
25777
26090
  let messages = [
25778
26091
  ...historyFromTranscript(await store.load(handle.id), transcriptIdentity, handle.id)
@@ -26231,6 +26544,7 @@ var init_native = __esm(() => {
26231
26544
  init_errors();
26232
26545
  init_model_resolver();
26233
26546
  init_models();
26547
+ init_provider_models();
26234
26548
  init_transcript_store();
26235
26549
  init_session_adapter();
26236
26550
  init_session_affinity();
@@ -26409,7 +26723,8 @@ var init_native_backend_options = __esm(() => {
26409
26723
  commandInterceptor: exports_external.custom(hasMethods2(["intercept"]), "must implement intercept").optional()
26410
26724
  }).optional(),
26411
26725
  bashApproval: exports_external.enum(["raw", "gated", "escalate"]).optional(),
26412
- allowUnsandboxed: exports_external.boolean().optional()
26726
+ allowUnsandboxed: exports_external.boolean().optional(),
26727
+ carryHistoryAcrossModels: exports_external.boolean().optional()
26413
26728
  });
26414
26729
  });
26415
26730
 
@@ -26754,6 +27069,7 @@ var init_src = __esm(() => {
26754
27069
  init_stderr_tail();
26755
27070
  init_redact();
26756
27071
  init_nax_error();
27072
+ init_terminal_auth();
26757
27073
  init_native();
26758
27074
  init_turn_event_emitter();
26759
27075
  init_permissions();
@@ -29379,7 +29695,9 @@ __export(exports_internal, {
29379
29695
  NATIVE_AGENT_NAME: () => NATIVE_AGENT_NAME,
29380
29696
  NativeSessionUnsupportedError: () => NativeSessionUnsupportedError,
29381
29697
  NaxError: () => NaxError,
29698
+ PLAIN_STYLE: () => PLAIN_STYLE,
29382
29699
  PROVIDER_ID_RE: () => PROVIDER_ID_RE,
29700
+ PromptCancelledError: () => PromptCancelledError,
29383
29701
  READ_CEILING: () => READ_CEILING,
29384
29702
  RESERVED_TOOL_NAMES: () => RESERVED_TOOL_NAMES,
29385
29703
  SANDBOX_GLOB_CHARS: () => SANDBOX_GLOB_CHARS,
@@ -29411,6 +29729,7 @@ __export(exports_internal, {
29411
29729
  _grepDeps: () => _grepDeps,
29412
29730
  _instructionAccessDeps: () => _instructionAccessDeps,
29413
29731
  _launcherDeps: () => _launcherDeps,
29732
+ _openUrlDeps: () => _openUrlDeps,
29414
29733
  _policyInputDeps: () => _policyInputDeps,
29415
29734
  _probeDeps: () => _probeDeps,
29416
29735
  _repositoryInstructionDeps: () => _repositoryInstructionDeps,
@@ -29428,6 +29747,7 @@ __export(exports_internal, {
29428
29747
  _spillDeps: () => _spillDeps,
29429
29748
  _srtBackendDeps: () => _srtBackendDeps,
29430
29749
  _systemOneClientDeps: () => _systemOneClientDeps,
29750
+ _terminalPromptDeps: () => _terminalPromptDeps,
29431
29751
  abortableSleep: () => abortableSleep,
29432
29752
  adaptProviderTool: () => adaptProviderTool,
29433
29753
  advertisedSchemaBytes: () => advertisedSchemaBytes,
@@ -29488,6 +29808,7 @@ __export(exports_internal, {
29488
29808
  createRunCommandTool: () => createRunCommandTool,
29489
29809
  createSpinBreaker: () => createSpinBreaker,
29490
29810
  createSrtBackend: () => createSrtBackend,
29811
+ createTerminalAuthInteraction: () => createTerminalAuthInteraction,
29491
29812
  createToolAuditSink: () => createToolAuditSink,
29492
29813
  createTurnAccumulator: () => createTurnAccumulator,
29493
29814
  credentialFaultCode: () => credentialFaultCode,
@@ -29551,8 +29872,10 @@ __export(exports_internal, {
29551
29872
  listCredentialFiles: () => listCredentialFiles,
29552
29873
  listGitGuardFiles: () => listGitGuardFiles,
29553
29874
  listNaxEntries: () => listNaxEntries,
29875
+ listProviderModels: () => listProviderModels,
29554
29876
  listStoredProviders: () => listStoredProviders,
29555
29877
  loadTranscript: () => loadTranscript,
29878
+ loginProviderIds: () => loginProviderIds,
29556
29879
  markNativeTurnOutcome: () => markNativeTurnOutcome,
29557
29880
  maskForPrompt: () => maskForPrompt,
29558
29881
  mcpRuleAdmits: () => mcpRuleAdmits,
@@ -29566,6 +29889,7 @@ __export(exports_internal, {
29566
29889
  normalizeExec: () => normalizeExec,
29567
29890
  normalizeManagerBinary: () => normalizeManagerBinary,
29568
29891
  openNativeSession: () => openNativeSession,
29892
+ openUrl: () => openUrl,
29569
29893
  parseGitlinks: () => parseGitlinks,
29570
29894
  parseModelSpec: () => parseModelSpec,
29571
29895
  parseNativeModel: () => parseNativeModel,
@@ -29578,6 +29902,9 @@ __export(exports_internal, {
29578
29902
  prepareCompaction: () => prepareCompaction,
29579
29903
  probeSandbox: () => probeSandbox,
29580
29904
  probeSandboxOnce: () => probeSandboxOnce,
29905
+ promptForLine: () => promptForLine,
29906
+ promptForSecret: () => promptForSecret,
29907
+ promptForSelect: () => promptForSelect,
29581
29908
  providerAttachesTo: () => providerAttachesTo,
29582
29909
  providersWithoutCredentials: () => providersWithoutCredentials,
29583
29910
  pruneRetainedTranscripts: () => pruneRetainedTranscripts,
@@ -29643,6 +29970,7 @@ __export(exports_internal, {
29643
29970
  setAgentLogger: () => setAgentLogger,
29644
29971
  shellQuoteArg: () => shellQuoteArg,
29645
29972
  shouldCompact: () => shouldCompact,
29973
+ spawnDetached: () => spawnDetached,
29646
29974
  spillRelativePath: () => spillRelativePath,
29647
29975
  spinTerminalNotice: () => spinTerminalNotice,
29648
29976
  strayCommonDirTripwire: () => strayCommonDirTripwire,
@@ -29727,6 +30055,7 @@ var init_internal = __esm(() => {
29727
30055
  init_errors();
29728
30056
  init_model_resolver();
29729
30057
  init_models();
30058
+ init_provider_models();
29730
30059
  init_external_handler();
29731
30060
  init_loop_events();
29732
30061
  init_session();
@@ -29741,6 +30070,7 @@ var init_internal = __esm(() => {
29741
30070
  init_permissions();
29742
30071
  init_sandbox();
29743
30072
  init_agent_session_deps();
30073
+ init_terminal_auth();
29744
30074
  init_credential_read_deny();
29745
30075
  init_git();
29746
30076
  init_git_commit();
@@ -30395,9 +30725,9 @@ ${c.gray(JSON.stringify(filtered, null, 2))}`;
30395
30725
  }
30396
30726
  function buildDefaultMeta(data, mode, level) {
30397
30727
  const meta3 = [];
30398
- const identity = [data.agentName, data.model].filter((v) => typeof v === "string" && v.length > 0);
30399
- if (identity.length > 0)
30400
- meta3.push(`${EMOJI.agent} ${identity.join("\xB7")}`);
30728
+ const identity2 = [data.agentName, data.model].filter((v) => typeof v === "string" && v.length > 0);
30729
+ if (identity2.length > 0)
30730
+ meta3.push(`${EMOJI.agent} ${identity2.join("\xB7")}`);
30401
30731
  if (typeof data.phaseIndex === "number" && typeof data.totalPhases === "number") {
30402
30732
  meta3.push(`${data.phaseIndex}/${data.totalPhases}`);
30403
30733
  }
@@ -32625,7 +32955,7 @@ function isLegacyFlatModels(val) {
32625
32955
  }
32626
32956
  return false;
32627
32957
  }
32628
- var ConfigPricingTierSchema, ConfigPricingSchema, ThinkingLevelSchema, CatalogPricingSchema, OpenRouterRoutingSchema, CatalogModelOverrideSchema, LOOPBACK_HOSTS2, BASE_URL_MESSAGE = "baseUrl must be an https URL (http allowed only for localhost/127.0.0.1) and must not embed credentials", ProviderCatalogOverrideSchema, ModelDefSchema, ModelEntrySchema, PerAgentModelMapSchema, ModelMapSchema, ModelTierSchema, ConfiguredModelObjectSchema, ConfiguredModelSchema, TierConfigSchema;
32958
+ var ConfigPricingTierSchema, ConfigPricingSchema, ThinkingLevelSchema, CatalogPricingSchema, PercentileCutoffSchema, PercentileTargetSchema, OpenRouterRoutingSchema, CatalogModelOverrideSchema, LOOPBACK_HOSTS2, BASE_URL_MESSAGE = "baseUrl must be an https URL (http allowed only for localhost/127.0.0.1) and must not embed credentials", ProviderCatalogOverrideSchema, ModelDefSchema, ModelEntrySchema, PerAgentModelMapSchema, ModelMapSchema, ModelTierSchema, ConfiguredModelObjectSchema, ConfiguredModelSchema, TierConfigSchema;
32629
32959
  var init_schemas_model = __esm(() => {
32630
32960
  init_zod();
32631
32961
  ConfigPricingTierSchema = exports_external.object({
@@ -32649,6 +32979,13 @@ var init_schemas_model = __esm(() => {
32649
32979
  cacheRead: exports_external.number().min(0),
32650
32980
  cacheWrite: exports_external.number().min(0)
32651
32981
  }).strict();
32982
+ PercentileCutoffSchema = exports_external.object({
32983
+ p50: exports_external.number().positive().optional(),
32984
+ p75: exports_external.number().positive().optional(),
32985
+ p90: exports_external.number().positive().optional(),
32986
+ p99: exports_external.number().positive().optional()
32987
+ }).strict().refine((v) => Object.keys(v).length > 0, { message: "a percentile cutoff object must not be empty" });
32988
+ PercentileTargetSchema = exports_external.union([exports_external.number().positive(), PercentileCutoffSchema]);
32652
32989
  OpenRouterRoutingSchema = exports_external.object({
32653
32990
  allow_fallbacks: exports_external.boolean().optional(),
32654
32991
  require_parameters: exports_external.boolean().optional(),
@@ -32658,7 +32995,9 @@ var init_schemas_model = __esm(() => {
32658
32995
  only: exports_external.array(exports_external.string().min(1)).optional(),
32659
32996
  ignore: exports_external.array(exports_external.string().min(1)).optional(),
32660
32997
  quantizations: exports_external.array(exports_external.string().min(1)).optional(),
32661
- sort: exports_external.enum(["price", "throughput", "latency"]).optional()
32998
+ sort: exports_external.enum(["price", "throughput", "latency"]).optional(),
32999
+ preferred_min_throughput: PercentileTargetSchema.optional(),
33000
+ preferred_max_latency: PercentileTargetSchema.optional()
32662
33001
  }).strict().refine((v) => Object.keys(v).length > 0, {
32663
33002
  message: "openRouterRouting must not be empty \u2014 omit the key to leave the model's routing unset"
32664
33003
  });
@@ -36315,9 +36654,9 @@ function extractSpecStructure(specContent) {
36315
36654
  const stories = [];
36316
36655
  const warnings = [];
36317
36656
  for (const declarations of collectStoryDeclarations(specContent)) {
36318
- const read = readDeclarations(declarations);
36319
- stories.push(read.story);
36320
- warnings.push(...read.warnings);
36657
+ const read2 = readDeclarations(declarations);
36658
+ stories.push(read2.story);
36659
+ warnings.push(...read2.warnings);
36321
36660
  }
36322
36661
  return { stories, warnings };
36323
36662
  }
@@ -38554,7 +38893,7 @@ var package_default;
38554
38893
  var init_package = __esm(() => {
38555
38894
  package_default = {
38556
38895
  name: "@nathapp/nax",
38557
- version: "0.83.7",
38896
+ version: "0.85.0",
38558
38897
  description: "AI Coding Agent Orchestrator \u2014 loops until done",
38559
38898
  type: "module",
38560
38899
  bin: {
@@ -38566,7 +38905,7 @@ var init_package = __esm(() => {
38566
38905
  typecheck: "bun x tsc --noEmit && bun x tsc --noEmit -p tsconfig.test.json",
38567
38906
  lint: "bun run lint:biome && bun run lint:checks",
38568
38907
  "lint:biome": "bun scripts/quiet-run.ts bun x biome check --error-on-warnings --diagnostic-level=warn src/ bin/ test/ scripts/",
38569
- "lint:checks": "bun run check:no-real-global-nax && bun run check:feature-dir-ssot && bun run check:alias-internals && bun run check:import-cycles && bun run check:nax-error && bun run check:logger-storyid && bun run check:log-format-layering && bun run check:file-sizes && bun run check:complexity && bun run check:no-control-bytes && bun run check:review-prompts && bun run check:nax-ai-imports && bun run check:sandbox-imports && bun run check:git-spawn-env && bun run check:bundle-externals && bun run check:op-tool-capability && bun run check:nax-artifacts-untracked && bun run check:story-workdir-access && bun run check:package-frame-derivation && bun run check:config-profile-threading && bun run check:dispatch-field-forwarding && bun run check:bash-dispatch-ask && bun run check:test-satellites && bun run check:nax-ai-pin && bun run check:package-boundaries && bun run check:usage-vocabulary",
38908
+ "lint:checks": "bun run check:no-real-global-nax && bun run check:feature-dir-ssot && bun run check:alias-internals && bun run check:import-cycles && bun run check:nax-error && bun run check:logger-storyid && bun run check:log-format-layering && bun run check:file-sizes && bun run check:complexity && bun run check:no-control-bytes && bun run check:review-prompts && bun run check:nax-ai-imports && bun run check:sandbox-imports && bun run check:git-spawn-env && bun run check:bundle-externals && bun run check:op-tool-capability && bun run check:nax-artifacts-untracked && bun run check:story-workdir-access && bun run check:package-frame-derivation && bun run check:config-profile-threading && bun run check:dispatch-field-forwarding && bun run check:bash-dispatch-ask && bun run check:test-satellites && bun run check:lockstep && bun run check:package-boundaries && bun run check:usage-vocabulary",
38570
38909
  "lint:json": "bun x biome check --error-on-warnings src/ bin/ test/ scripts/ --reporter json && bun run check:nax-error 1>&2 && bun run check:logger-storyid 1>&2",
38571
38910
  "lint:fix": "bun x biome check --write src/ bin/ test/ scripts/",
38572
38911
  "check:no-real-global-nax": "bun run ../repo-tooling/scripts/check-no-real-global-nax.ts",
@@ -38588,7 +38927,7 @@ var init_package = __esm(() => {
38588
38927
  "check:no-control-bytes": "bun run ../repo-tooling/scripts/check-no-control-bytes.ts",
38589
38928
  "check:review-prompts": "bun run scripts/check-review-prompts-generated.ts",
38590
38929
  "check:nax-ai-imports": "bun run ../repo-tooling/scripts/check-nax-ai-imports.ts",
38591
- "check:nax-ai-pin": "bun run scripts/check-nax-ai-pin.ts",
38930
+ "check:lockstep": "bun run ../repo-tooling/scripts/check-lockstep.ts",
38592
38931
  "check:sandbox-imports": "bun run ../repo-tooling/scripts/check-sandbox-imports.ts",
38593
38932
  "check:git-spawn-env": "bun run ../repo-tooling/scripts/check-git-spawn-env.ts",
38594
38933
  "check:bundle-externals": "bun run scripts/check-bundle-externals.ts",
@@ -38602,7 +38941,6 @@ var init_package = __esm(() => {
38602
38941
  "check:bash-dispatch-ask": "bun run scripts/check-bash-dispatch-ask.ts",
38603
38942
  "check:rules-drift": "bun scripts/quiet-run.ts bun run scripts/check-rules-drift.ts",
38604
38943
  "gen:review-prompts": "bun run scripts/generate-review-prompts.ts",
38605
- release: "bun scripts/release.ts",
38606
38944
  test: "AGENT=1 bun run scripts/run-tests.ts",
38607
38945
  "test:verbose": "bun run scripts/run-tests.ts",
38608
38946
  "test:bail": "AGENT=1 bun run scripts/run-tests.ts --bail",
@@ -38642,7 +38980,7 @@ var init_package = __esm(() => {
38642
38980
  "@agentclientprotocol/sdk": "~1.7.0",
38643
38981
  "@anthropic-ai/sandbox-runtime": "0.0.77",
38644
38982
  "@modelcontextprotocol/sdk": "^1.30.0",
38645
- "@nathapp/nax-ai": "0.1.16",
38983
+ "@nathapp/nax-ai": "0.85.0",
38646
38984
  chalk: "^5.6.2",
38647
38985
  commander: "^13.1.0",
38648
38986
  ink: "^6.7.0",
@@ -38872,9 +39210,9 @@ function cancellableDelay(ms, signal) {
38872
39210
  signal?.addEventListener("abort", onAbort, { once: true });
38873
39211
  });
38874
39212
  }
38875
- var spawn;
39213
+ var spawn2;
38876
39214
  var init_bun_deps = __esm(() => {
38877
- spawn = Bun.spawn;
39215
+ spawn2 = Bun.spawn;
38878
39216
  });
38879
39217
 
38880
39218
  // src/agents/retry/failure-policy.ts
@@ -42479,7 +42817,7 @@ var init_nax_owned_paths = __esm(() => {
42479
42817
  });
42480
42818
 
42481
42819
  // src/review/diff-utils.ts
42482
- var {spawn: spawn2 } = globalThis.Bun;
42820
+ var {spawn: spawn3 } = globalThis.Bun;
42483
42821
  async function resolveNaxIgnorePathspecExcludes(workdir, options) {
42484
42822
  if (options?.naxIgnoreIndex)
42485
42823
  return options.naxIgnoreIndex.toPathspecExcludes(options.packageDir);
@@ -42632,7 +42970,7 @@ var init_diff_utils = __esm(() => {
42632
42970
  init_path_filters();
42633
42971
  ALWAYS_EXCLUDED = [...NAX_OWNED_REVIEW_EXCLUDE_PATHSPECS];
42634
42972
  _diffUtilsDeps = {
42635
- spawn: spawn2,
42973
+ spawn: spawn3,
42636
42974
  isGitRefValid,
42637
42975
  getMergeBase,
42638
42976
  timeoutMs: GIT_TIMEOUT_MS
@@ -44546,6 +44884,8 @@ function buildAgentScopeSection(root, workdirLabel) {
44546
44884
  return [
44547
44885
  "## Your file scope",
44548
44886
  "",
44887
+ `**Execution repository/worktree root:** \`${root}\``,
44888
+ "",
44549
44889
  "Your file tools (Read, Write, Edit, Glob, Grep, Git) are rooted at the repository root.",
44550
44890
  "Every path you pass them is resolved from there."
44551
44891
  ].join(`
@@ -44554,6 +44894,8 @@ function buildAgentScopeSection(root, workdirLabel) {
44554
44894
  return [
44555
44895
  "## Your file scope",
44556
44896
  "",
44897
+ `**Execution repository/worktree root:** \`${root}\``,
44898
+ "",
44557
44899
  "Your file tools (Read, Write, Edit, Glob, Grep, Git) are rooted at the repository root, NOT at your package.",
44558
44900
  `Your story's package is \`${workdirLabel}\`. Spell every path repo-rooted from the repository root: write`,
44559
44901
  `\`${workdirLabel}/src/index.ts\`, never \`src/index.ts\`.`,
@@ -56645,7 +56987,7 @@ function stripCarriageReturn(line) {
56645
56987
  return line.endsWith("\r") ? line.slice(0, -1) : line;
56646
56988
  }
56647
56989
  var CONSEQUENCE = "? nax will run this project's plugins, hooks, MCP servers and test commands.", _trustPromptDeps;
56648
- var init_prompt = __esm(() => {
56990
+ var init_prompt2 = __esm(() => {
56649
56991
  _trustPromptDeps = {
56650
56992
  ask: async (question) => {
56651
56993
  process.stderr.write(question);
@@ -56750,11 +57092,11 @@ async function removeFromStore(storePath, normalized) {
56750
57092
  return { outcome: "removed", entry };
56751
57093
  }
56752
57094
  async function readFoldersForWrite(storePath) {
56753
- const read = await readTrustStore();
56754
- if (read.state === "unparseable") {
56755
- throw trustStoreUnreadableError(storePath, read.reason);
57095
+ const read2 = await readTrustStore();
57096
+ if (read2.state === "unparseable") {
57097
+ throw trustStoreUnreadableError(storePath, read2.reason);
56756
57098
  }
56757
- return read.state === "ok" ? read.file.folders : [];
57099
+ return read2.state === "ok" ? read2.file.folders : [];
56758
57100
  }
56759
57101
  async function writeTrustStore(storePath, file2) {
56760
57102
  const tempPath = `${storePath}.${process.pid}.${randomUUID13()}.tmp`;
@@ -56833,7 +57175,7 @@ var _trustGateDeps;
56833
57175
  var init_gate = __esm(() => {
56834
57176
  init_errors4();
56835
57177
  init_match();
56836
- init_prompt();
57178
+ init_prompt2();
56837
57179
  init_registry4();
56838
57180
  init_store2();
56839
57181
  _trustGateDeps = {
@@ -56846,7 +57188,7 @@ var init_gate = __esm(() => {
56846
57188
  var init_trust = __esm(() => {
56847
57189
  init_gate();
56848
57190
  init_match();
56849
- init_prompt();
57191
+ init_prompt2();
56850
57192
  init_registry4();
56851
57193
  init_store2();
56852
57194
  });
@@ -57057,8 +57399,8 @@ var init_version = __esm(() => {
57057
57399
  NAX_AI_VERSION = CATALOG_VERSION;
57058
57400
  NAX_COMMIT = (() => {
57059
57401
  try {
57060
- if (/^[0-9a-f]{6,10}$/.test("cfab34e07"))
57061
- return "cfab34e07";
57402
+ if (/^[0-9a-f]{6,10}$/.test("dafafae"))
57403
+ return "dafafae";
57062
57404
  } catch {}
57063
57405
  try {
57064
57406
  const result = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
@@ -58265,9 +58607,9 @@ async function readProjectIdentity(projectKey) {
58265
58607
  return null;
58266
58608
  }
58267
58609
  }
58268
- async function writeProjectIdentity(projectKey, identity) {
58610
+ async function writeProjectIdentity(projectKey, identity2) {
58269
58611
  const p = identityPath(projectKey);
58270
- await Bun.write(p, JSON.stringify(identity, null, 2));
58612
+ await Bun.write(p, JSON.stringify(identity2, null, 2));
58271
58613
  }
58272
58614
  async function claimProjectIdentity(projectKey, workdir, remoteUrl) {
58273
58615
  const existing2 = await readProjectIdentity(projectKey);
@@ -68835,7 +69177,7 @@ var require_cross_spawn = __commonJS(function(exports, module) {
68835
69177
  var cp = __require("child_process");
68836
69178
  var parse6 = require_parse();
68837
69179
  var enoent = require_enoent();
68838
- function spawn3(command, args, options) {
69180
+ function spawn4(command, args, options) {
68839
69181
  const parsed = parse6(command, args, options);
68840
69182
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
68841
69183
  enoent.hookChildProcess(spawned, parsed);
@@ -68847,8 +69189,8 @@ var require_cross_spawn = __commonJS(function(exports, module) {
68847
69189
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
68848
69190
  return result;
68849
69191
  }
68850
- module.exports = spawn3;
68851
- module.exports.spawn = spawn3;
69192
+ module.exports = spawn4;
69193
+ module.exports.spawn = spawn4;
68852
69194
  module.exports.sync = spawnSync;
68853
69195
  module.exports._parse = parse6;
68854
69196
  module.exports._enoent = enoent;
@@ -69349,9 +69691,9 @@ function createMcpProviders(args) {
69349
69691
  return [];
69350
69692
  for (const [id] of servers)
69351
69693
  validateProviderId(id);
69352
- const read = args.readLock ?? readMcpLock;
69694
+ const read2 = args.readLock ?? readMcpLock;
69353
69695
  let lockPromise;
69354
- const lock = () => lockPromise ??= read(args.projectRoot);
69696
+ const lock = () => lockPromise ??= read2(args.projectRoot);
69355
69697
  return servers.map(([serverId, server]) => {
69356
69698
  return {
69357
69699
  id: serverId,
@@ -69597,7 +69939,7 @@ var init_executor = __esm(() => {
69597
69939
  init_bun_deps();
69598
69940
  init_trust();
69599
69941
  init_internal();
69600
- _executorDeps = { spawn };
69942
+ _executorDeps = { spawn: spawn2 };
69601
69943
  DRAIN_TIMEOUT3 = Symbol("drain-timeout");
69602
69944
  DEFAULT_STRIP_ENV_VARS = [];
69603
69945
  });
@@ -70663,7 +71005,7 @@ ${r.output}`).join(""),
70663
71005
  }
70664
71006
 
70665
71007
  // src/quality/runner.ts
70666
- var {spawn: spawn4 } = globalThis.Bun;
71008
+ var {spawn: spawn5 } = globalThis.Bun;
70667
71009
  function createDrainDeadline(deadlineMs) {
70668
71010
  let timeoutId;
70669
71011
  const promise3 = new Promise((resolve31) => {
@@ -70837,7 +71179,7 @@ var init_runner = __esm(() => {
70837
71179
  init_trust();
70838
71180
  init_executor();
70839
71181
  _qualityRunnerDeps = {
70840
- spawn: spawn4
71182
+ spawn: spawn5
70841
71183
  };
70842
71184
  });
70843
71185
 
@@ -77645,7 +77987,7 @@ ${detail}`,
77645
77987
  `);
77646
77988
  }
77647
77989
  var CLASSIFIER;
77648
- var init_prompt2 = __esm(() => {
77990
+ var init_prompt3 = __esm(() => {
77649
77991
  CLASSIFIER = [
77650
77992
  "Mark a finding for human judgment \u2014 and only such a finding \u2014 by adding a",
77651
77993
  "`Judgment: yes \u2014 <why>` line to its block. Use it when the finding is a spec",
@@ -77660,7 +78002,7 @@ var init_prompt2 = __esm(() => {
77660
78002
  var init_review = __esm(() => {
77661
78003
  init_audit_gaps();
77662
78004
  init_parse6();
77663
- init_prompt2();
78005
+ init_prompt3();
77664
78006
  });
77665
78007
 
77666
78008
  // src/operations/finish-fix.ts
@@ -78351,7 +78693,7 @@ var init_new_package_setup = __esm(() => {
78351
78693
  init_trust();
78352
78694
  init_command_argv();
78353
78695
  registry4 = new WeakMap;
78354
- _newPackageSetupDeps = { spawn };
78696
+ _newPackageSetupDeps = { spawn: spawn2 };
78355
78697
  });
78356
78698
 
78357
78699
  // src/operations/gate-cwd.ts
@@ -78792,7 +79134,7 @@ var init_isolation2 = __esm(() => {
78792
79134
  init_errors4();
78793
79135
  init_logger2();
78794
79136
  init_test_runners();
78795
- _isolationDeps = { spawn, timeoutMs: GIT_TIMEOUT_MS3 };
79137
+ _isolationDeps = { spawn: spawn2, timeoutMs: GIT_TIMEOUT_MS3 };
78796
79138
  SRC_PATTERNS = [/^src\//, /^lib\//, /^packages\//];
78797
79139
  });
78798
79140
 
@@ -88013,7 +88355,7 @@ function contentText(content) {
88013
88355
  return content.map(contentPart).filter((part) => part !== "").join(`
88014
88356
  `);
88015
88357
  }
88016
- function previewOf2(call2, secrets) {
88358
+ function previewOf(call2, secrets) {
88017
88359
  const fromContent = contentText(call2.content);
88018
88360
  let raw = fromContent;
88019
88361
  if (raw === "" && typeof call2.rawOutput === "string")
@@ -88088,7 +88430,7 @@ function createToolEvents(emit, secrets, now = Date.now) {
88088
88430
  running.add(state.id);
88089
88431
  const shown2 = announce(state);
88090
88432
  if (status !== "in_progress")
88091
- resolve35(shown2, status === "failed", previewOf2(shown2, secrets), resultBytesOf(shown2));
88433
+ resolve35(shown2, status === "failed", previewOf(shown2, secrets), resultBytesOf(shown2));
88092
88434
  },
88093
88435
  announce(toolCall) {
88094
88436
  const state = merge2(toolCall);
@@ -88503,7 +88845,7 @@ function race(promise3, opts) {
88503
88845
  }
88504
88846
 
88505
88847
  // ../nax-agent-acp/src/client/launch.ts
88506
- import { spawn as spawn5 } from "child_process";
88848
+ import { spawn as spawn6 } from "child_process";
88507
88849
  import { accessSync as accessSync3, constants as constants3, statSync as statSync8 } from "fs";
88508
88850
  import { delimiter as delimiter2, isAbsolute as isAbsolute25, join as join73 } from "path";
88509
88851
  import { Readable as Readable2, Writable } from "stream";
@@ -88548,7 +88890,7 @@ function failedLaunch(stderr, error48) {
88548
88890
  }
88549
88891
  function trySpawn(request) {
88550
88892
  try {
88551
- return spawn5(request.command, [...request.args], {
88893
+ return spawn6(request.command, [...request.args], {
88552
88894
  cwd: request.cwd,
88553
88895
  env: { ...request.env },
88554
88896
  stdio: "pipe",
@@ -92413,7 +92755,7 @@ var init_turn_interactions = __esm(() => {
92413
92755
  });
92414
92756
 
92415
92757
  // src/agents/interaction/index.ts
92416
- var init_interaction = __esm(() => {
92758
+ var init_interaction2 = __esm(() => {
92417
92759
  init_output_parsing();
92418
92760
  init_turn_interactions();
92419
92761
  });
@@ -92470,7 +92812,7 @@ function createAskPort(slot, beatMs = AWAITING_HUMAN_BEAT_MS, audit) {
92470
92812
  var STAGE = "acp", AWAITING_HUMAN_BEAT_MS = 30000;
92471
92813
  var init_ask_port = __esm(() => {
92472
92814
  init_logger2();
92473
- init_interaction();
92815
+ init_interaction2();
92474
92816
  });
92475
92817
 
92476
92818
  // src/agents/acp/profile-map.ts
@@ -93208,7 +93550,7 @@ var init_turn_loop2 = __esm(() => {
93208
93550
  init_src();
93209
93551
  init_errors4();
93210
93552
  init_logger2();
93211
- init_interaction();
93553
+ init_interaction2();
93212
93554
  init_turn();
93213
93555
  init_failure_map();
93214
93556
  init_pricing();
@@ -94359,17 +94701,17 @@ function formatEntryBlock(entry2) {
94359
94701
  const commandLines = lines2.map((line, index) => index === 0 ? `${ENTRY_INDENT}$ ${line}` : `${COMMAND_CONTINUATION_INDENT}${line}`);
94360
94702
  return [header, rootLine, ...commandLines];
94361
94703
  }
94362
- function toListJson(path10, read) {
94363
- const taint = read.file.taint === undefined ? null : read.file.taint;
94364
- const entries = read.file.entries.map((entry2) => ({
94704
+ function toListJson(path10, read2) {
94705
+ const taint = read2.file.taint === undefined ? null : read2.file.taint;
94706
+ const entries = read2.file.entries.map((entry2) => ({
94365
94707
  ...entry2,
94366
94708
  id: approvalId(entry2)
94367
94709
  }));
94368
94710
  return {
94369
94711
  path: path10,
94370
- state: read.state,
94712
+ state: read2.state,
94371
94713
  taint,
94372
- droppedMalformed: read.droppedMalformed,
94714
+ droppedMalformed: read2.droppedMalformed,
94373
94715
  entries
94374
94716
  };
94375
94717
  }
@@ -94413,12 +94755,12 @@ async function promptForConfirmation(question) {
94413
94755
  resolve36(answer);
94414
94756
  };
94415
94757
  const onData = (char) => {
94416
- if (char === ETX) {
94758
+ if (char === ETX2) {
94417
94759
  finish(false);
94418
94760
  _confirmDeps.exit(SIGINT_EXIT_CODE);
94419
94761
  return;
94420
94762
  }
94421
- if (char === EOT) {
94763
+ if (char === EOT2) {
94422
94764
  finish(false);
94423
94765
  return;
94424
94766
  }
@@ -94430,7 +94772,7 @@ async function promptForConfirmation(question) {
94430
94772
  stdin.once("error", onClosed);
94431
94773
  });
94432
94774
  }
94433
- var ETX = "\x03", EOT = "\x04", SIGINT_EXIT_CODE = 130, _confirmDeps;
94775
+ var ETX2 = "\x03", EOT2 = "\x04", SIGINT_EXIT_CODE = 130, _confirmDeps;
94434
94776
  var init_confirm = __esm(() => {
94435
94777
  init_source();
94436
94778
  _confirmDeps = {
@@ -94451,26 +94793,26 @@ async function resolveApprovalsFile(workdir) {
94451
94793
  async function approvalsListCommand(opts, deps = _approvalsCliDeps) {
94452
94794
  try {
94453
94795
  const path10 = await resolveApprovalsFile(opts.workdir);
94454
- const read = await deps.readApprovalsFileDetailed(path10);
94796
+ const read2 = await deps.readApprovalsFileDetailed(path10);
94455
94797
  if (opts.json) {
94456
- deps.log(JSON.stringify(toListJson(path10, read)));
94457
- if (read.state === "unparseable")
94798
+ deps.log(JSON.stringify(toListJson(path10, read2)));
94799
+ if (read2.state === "unparseable")
94458
94800
  deps.logErr(PARSE_WARNING);
94459
94801
  return 0;
94460
94802
  }
94461
- if (read.state === "missing") {
94803
+ if (read2.state === "missing") {
94462
94804
  deps.log(missingNotice(path10));
94463
94805
  return 0;
94464
94806
  }
94465
- if (read.state === "unparseable") {
94807
+ if (read2.state === "unparseable") {
94466
94808
  deps.logErr(PARSE_WARNING);
94467
94809
  deps.log(missingNotice(path10));
94468
94810
  return 0;
94469
94811
  }
94470
- const entries = read.file.entries;
94471
- const taint = read.file.taint;
94472
- if (read.droppedMalformed > 0)
94473
- deps.logErr(malformedEntriesWarning(read.droppedMalformed));
94812
+ const entries = read2.file.entries;
94813
+ const taint = read2.file.taint;
94814
+ if (read2.droppedMalformed > 0)
94815
+ deps.logErr(malformedEntriesWarning(read2.droppedMalformed));
94474
94816
  deps.log(`Approvals store: ${path10}`);
94475
94817
  deps.log(formatTrustLine(taint, deps.isProcessAlive));
94476
94818
  deps.log(`${entries.length} remembered approvals`);
@@ -94492,12 +94834,12 @@ async function runPrecheck(opts, deps) {
94492
94834
  try {
94493
94835
  const path10 = await resolveApprovalsFile(opts.workdir);
94494
94836
  if (opts.all) {
94495
- const read = await deps.readApprovalsFileDetailed(path10);
94496
- if (read.state === "missing" || read.state === "ok" && read.file.entries.length === 0) {
94837
+ const read2 = await deps.readApprovalsFileDetailed(path10);
94838
+ if (read2.state === "missing" || read2.state === "ok" && read2.file.entries.length === 0) {
94497
94839
  deps.log(missingNotice(path10));
94498
94840
  return { kind: "empty", path: path10 };
94499
94841
  }
94500
- if (read.state === "unparseable") {
94842
+ if (read2.state === "unparseable") {
94501
94843
  deps.logErr("approvals.json could not be parsed; not rewriting it");
94502
94844
  return { kind: "unparseable", path: path10 };
94503
94845
  }
@@ -94792,227 +95134,9 @@ var init_auth_list = __esm(() => {
94792
95134
  init_config();
94793
95135
  });
94794
95136
 
94795
- // src/cli/auth-prompt.ts
94796
- function read(message, echo, onEmptySubmit) {
94797
- const { stdin } = _authPromptDeps;
94798
- if (stdin.isTTY !== true)
94799
- return Promise.reject(new PromptCancelledError);
94800
- _authPromptDeps.write(`${source_default.cyan("?")} ${message} `);
94801
- return new Promise((resolve36, reject) => {
94802
- let buffer = "";
94803
- let settled2 = false;
94804
- const cleanup = () => {
94805
- if (settled2)
94806
- return;
94807
- settled2 = true;
94808
- stdin.removeListener("data", onData);
94809
- stdin.removeListener("end", onEnd);
94810
- stdin.removeListener("error", onEnd);
94811
- stdin.setRawMode(false);
94812
- stdin.pause();
94813
- _authPromptDeps.write(`
94814
- `);
94815
- };
94816
- const onEnd = () => {
94817
- cleanup();
94818
- reject(new PromptCancelledError);
94819
- };
94820
- const onData = (chunk) => {
94821
- for (const char of chunk) {
94822
- if (char === ETX2 || char === EOT2) {
94823
- cleanup();
94824
- reject(new PromptCancelledError);
94825
- return;
94826
- }
94827
- if (char === CR || char === LF) {
94828
- if (buffer.length === 0 && onEmptySubmit !== undefined) {
94829
- onEmptySubmit();
94830
- continue;
94831
- }
94832
- cleanup();
94833
- resolve36(buffer);
94834
- return;
94835
- }
94836
- if (char === BACKSPACE) {
94837
- buffer = buffer.slice(0, -1);
94838
- if (echo)
94839
- _authPromptDeps.write("\b \b");
94840
- continue;
94841
- }
94842
- buffer += char;
94843
- if (echo)
94844
- _authPromptDeps.write(char);
94845
- }
94846
- };
94847
- stdin.setRawMode(true);
94848
- stdin.resume();
94849
- stdin.setEncoding("utf8");
94850
- stdin.on("data", onData);
94851
- stdin.once("end", onEnd);
94852
- stdin.once("error", onEnd);
94853
- });
94854
- }
94855
- function promptForSecret(message) {
94856
- return read(message, false);
94857
- }
94858
- function promptForLine(message, onEmptySubmit) {
94859
- return read(message, true, onEmptySubmit);
94860
- }
94861
- function promptForSelect(message, choices) {
94862
- const { stdin } = _authPromptDeps;
94863
- if (stdin.isTTY !== true)
94864
- return Promise.reject(new PromptCancelledError);
94865
- if (choices.length === 0)
94866
- return Promise.reject(new PromptCancelledError);
94867
- _authPromptDeps.write(`${source_default.cyan("?")} ${message}
94868
- `);
94869
- return new Promise((resolve36, reject) => {
94870
- let index = 0;
94871
- let settled2 = false;
94872
- let drawn = false;
94873
- const render3 = () => {
94874
- if (drawn)
94875
- _authPromptDeps.write(`\x1B[${choices.length}A`);
94876
- drawn = true;
94877
- for (const [i, choice] of choices.entries()) {
94878
- const active = i === index;
94879
- const marker = active ? source_default.cyan(">") : " ";
94880
- const label2 = active ? source_default.cyan(choice.label) : choice.label;
94881
- _authPromptDeps.write(`\r\x1B[2K${marker} ${label2}
94882
- `);
94883
- }
94884
- };
94885
- const cleanup = () => {
94886
- if (settled2)
94887
- return;
94888
- settled2 = true;
94889
- stdin.removeListener("data", onData);
94890
- stdin.removeListener("end", onEnd);
94891
- stdin.removeListener("error", onEnd);
94892
- stdin.setRawMode(false);
94893
- stdin.pause();
94894
- };
94895
- const onEnd = () => {
94896
- cleanup();
94897
- reject(new PromptCancelledError);
94898
- };
94899
- const onData = (chunk) => {
94900
- if (chunk.includes(ETX2) || chunk.includes(EOT2)) {
94901
- cleanup();
94902
- reject(new PromptCancelledError);
94903
- return;
94904
- }
94905
- if (chunk.includes(ARROW_UP)) {
94906
- index = (index - 1 + choices.length) % choices.length;
94907
- render3();
94908
- return;
94909
- }
94910
- if (chunk.includes(ARROW_DOWN)) {
94911
- index = (index + 1) % choices.length;
94912
- render3();
94913
- return;
94914
- }
94915
- if (chunk.includes(CR) || chunk.includes(LF)) {
94916
- const chosen = choices[index];
94917
- cleanup();
94918
- resolve36(chosen.id);
94919
- }
94920
- };
94921
- stdin.setRawMode(true);
94922
- stdin.resume();
94923
- stdin.setEncoding("utf8");
94924
- stdin.on("data", onData);
94925
- stdin.once("end", onEnd);
94926
- stdin.once("error", onEnd);
94927
- render3();
94928
- });
94929
- }
94930
- var ETX2 = "\x03", EOT2 = "\x04", CR = "\r", LF = `
94931
- `, BACKSPACE = "\x7F", ARROW_UP = "\x1B[A", ARROW_DOWN = "\x1B[B", PromptCancelledError, _authPromptDeps;
94932
- var init_auth_prompt = __esm(() => {
94933
- init_source();
94934
- PromptCancelledError = class PromptCancelledError extends Error {
94935
- constructor() {
94936
- super("Prompt cancelled");
94937
- this.name = "PromptCancelledError";
94938
- }
94939
- };
94940
- _authPromptDeps = {
94941
- stdin: process.stdin,
94942
- write: (text) => process.stdout.write(text)
94943
- };
94944
- });
94945
-
94946
- // src/cli/open-url.ts
94947
- function openerFor(platform, url2) {
94948
- if (platform === "darwin")
94949
- return ["open", url2];
94950
- if (platform === "win32")
94951
- return ["cmd", "/c", "start", "", url2];
94952
- return ["xdg-open", url2];
94953
- }
94954
- function openUrl(url2) {
94955
- try {
94956
- _openUrlDeps.spawn(openerFor(_openUrlDeps.platform(), url2));
94957
- } catch {}
94958
- }
94959
- var _openUrlDeps;
94960
- var init_open_url = __esm(() => {
94961
- _openUrlDeps = {
94962
- spawn: (command2) => {
94963
- Bun.spawn([...command2], { stdin: "ignore", stdout: "ignore", stderr: "ignore" });
94964
- },
94965
- platform: () => process.platform
94966
- };
94967
- });
94968
-
94969
95137
  // src/cli/auth.ts
94970
95138
  function terminalInteraction() {
94971
- let pendingUrl;
94972
- return {
94973
- prompt: async (prompt) => {
94974
- if (prompt.type === "manual-code") {
94975
- const url2 = pendingUrl;
94976
- if (url2 === undefined)
94977
- return promptForLine(prompt.message);
94978
- pendingUrl = undefined;
94979
- _cliAuthDeps.log(source_default.dim("Press Enter to open it in your browser."));
94980
- return promptForLine(prompt.message, () => {
94981
- _cliAuthDeps.log(source_default.dim("Opening your browser..."));
94982
- openUrl(url2);
94983
- });
94984
- }
94985
- if (prompt.type === "text")
94986
- return promptForLine(prompt.message);
94987
- if (prompt.type === "select") {
94988
- return promptForSelect(prompt.message, prompt.options.map((option) => ({ id: option.id, label: option.label })));
94989
- }
94990
- return promptForSecret(prompt.message);
94991
- },
94992
- notify: (event) => {
94993
- switch (event.type) {
94994
- case "auth-url":
94995
- _cliAuthDeps.log(`
94996
- ${source_default.bold("Open this URL to continue:")}
94997
- ${event.url}`);
94998
- pendingUrl = event.url;
94999
- return;
95000
- case "device-code":
95001
- _cliAuthDeps.log(`
95002
- Go to ${event.verificationUri} and enter code ${source_default.bold(event.userCode)}`);
95003
- return;
95004
- case "info":
95005
- _cliAuthDeps.log(event.message);
95006
- for (const link2 of event.links ?? [])
95007
- _cliAuthDeps.log(` ${link2.label ?? "Link"}: ${link2.url}`);
95008
- return;
95009
- case "progress":
95010
- _cliAuthDeps.log(source_default.dim(event.message));
95011
- return;
95012
- default:
95013
- }
95014
- }
95015
- };
95139
+ return createTerminalAuthInteraction({ log: (text) => _cliAuthDeps.log(text), style: CHALK_STYLE });
95016
95140
  }
95017
95141
  async function authLoginCommand(providerId, method) {
95018
95142
  if (!_cliAuthDeps.isTTY()) {
@@ -95109,19 +95233,18 @@ async function authRmCommand(providerId) {
95109
95233
  return 1;
95110
95234
  }
95111
95235
  }
95112
- var _cliAuthDeps;
95236
+ var _cliAuthDeps, CHALK_STYLE;
95113
95237
  var init_auth3 = __esm(() => {
95114
95238
  init_src();
95115
95239
  init_source();
95116
95240
  init_config();
95117
95241
  init_auth_list();
95118
- init_auth_prompt();
95119
- init_open_url();
95120
95242
  _cliAuthDeps = {
95121
95243
  log: (text) => console.log(text),
95122
95244
  isTTY: () => process.stdin.isTTY === true,
95123
95245
  collectAuthList
95124
95246
  };
95247
+ CHALK_STYLE = { accent: source_default.cyan, dim: source_default.dim, bold: source_default.bold };
95125
95248
  });
95126
95249
 
95127
95250
  // src/cli/config-diff.ts
@@ -98041,7 +98164,7 @@ var init_triggers = __esm(() => {
98041
98164
  });
98042
98165
 
98043
98166
  // src/interaction/index.ts
98044
- var init_interaction2 = __esm(() => {
98167
+ var init_interaction3 = __esm(() => {
98045
98168
  init_ask_link();
98046
98169
  init_bridge_builder();
98047
98170
  init_chain();
@@ -98117,7 +98240,7 @@ var _configJsonDeps;
98117
98240
  var init_config_json = __esm(() => {
98118
98241
  init_internal();
98119
98242
  init_config();
98120
- init_interaction2();
98243
+ init_interaction3();
98121
98244
  init_config_display();
98122
98245
  init_config_profile();
98123
98246
  init_config_requirements();
@@ -100905,19 +101028,19 @@ function validateProjectName(name) {
100905
101028
  return { valid: true };
100906
101029
  }
100907
101030
  async function checkInitCollision(name, currentWorkdir, currentRemote) {
100908
- const identity = await readProjectIdentity(name);
100909
- if (!identity)
101031
+ const identity2 = await readProjectIdentity(name);
101032
+ if (!identity2)
100910
101033
  return { collision: false };
100911
- const sameRemote = isSameProject(currentRemote, identity.remoteUrl);
100912
- const sameWorkdir = !currentRemote && !identity.remoteUrl && currentWorkdir === identity.workdir;
101034
+ const sameRemote = isSameProject(currentRemote, identity2.remoteUrl);
101035
+ const sameWorkdir = !currentRemote && !identity2.remoteUrl && currentWorkdir === identity2.workdir;
100913
101036
  if (sameRemote || sameWorkdir)
100914
101037
  return { collision: false };
100915
101038
  return {
100916
101039
  collision: true,
100917
101040
  existing: {
100918
- workdir: identity.workdir,
100919
- remoteUrl: identity.remoteUrl,
100920
- lastSeen: identity.lastSeen
101041
+ workdir: identity2.workdir,
101042
+ remoteUrl: identity2.remoteUrl,
101043
+ lastSeen: identity2.lastSeen
100921
101044
  }
100922
101045
  };
100923
101046
  }
@@ -101432,7 +101555,7 @@ var init_checks_cli = __esm(() => {
101432
101555
  init_bun_deps();
101433
101556
  init_agents();
101434
101557
  _checkCliDeps = {
101435
- spawn
101558
+ spawn: spawn2
101436
101559
  };
101437
101560
  });
101438
101561
 
@@ -103111,7 +103234,7 @@ var init_cleanup = __esm(() => {
103111
103234
  init_bun_deps();
103112
103235
  init_logger2();
103113
103236
  _cleanupDeps = {
103114
- spawn,
103237
+ spawn: spawn2,
103115
103238
  sleep,
103116
103239
  kill: process.kill.bind(process),
103117
103240
  killProcessGroupFn: (pid, signal) => killProcessGroup(pid, signal)
@@ -108886,7 +109009,7 @@ var init_completion = __esm(() => {
108886
109009
  init_engine();
108887
109010
  init_fragments();
108888
109011
  init_execution2();
108889
- init_interaction2();
109012
+ init_interaction3();
108890
109013
  init_logger2();
108891
109014
  init_metrics();
108892
109015
  init_prd();
@@ -109497,12 +109620,12 @@ var init_execution = __esm(() => {
109497
109620
  init_engine();
109498
109621
  init_errors4();
109499
109622
  init_execution2();
109500
- init_interaction2();
109623
+ init_interaction3();
109501
109624
  init_logger2();
109502
109625
  init_git2();
109503
109626
  init_path_frame();
109504
109627
  init_scope_files();
109505
- init_interaction2();
109628
+ init_interaction3();
109506
109629
  init_execution_helpers();
109507
109630
  init_execution_helpers();
109508
109631
  RUNTIME_CRASH_CODES = new Set(["CALL_OP_NO_OUTPUT", "CALL_OP_MAX_RETRIES"]);
@@ -109699,7 +109822,7 @@ var init_optimizer2 = __esm(() => {
109699
109822
 
109700
109823
  // src/pipeline/stages/prompt.ts
109701
109824
  var _promptStageDeps, promptStage;
109702
- var init_prompt3 = __esm(() => {
109825
+ var init_prompt4 = __esm(() => {
109703
109826
  init_acceptance2();
109704
109827
  init_engine();
109705
109828
  init_logger2();
@@ -110057,7 +110180,7 @@ var init_stages = __esm(() => {
110057
110180
  init_context3();
110058
110181
  init_execution();
110059
110182
  init_optimizer2();
110060
- init_prompt3();
110183
+ init_prompt4();
110061
110184
  init_queue_check();
110062
110185
  init_routing2();
110063
110186
  init_acceptance3();
@@ -110067,7 +110190,7 @@ var init_stages = __esm(() => {
110067
110190
  init_context3();
110068
110191
  init_execution();
110069
110192
  init_optimizer2();
110070
- init_prompt3();
110193
+ init_prompt4();
110071
110194
  init_queue_check();
110072
110195
  init_routing2();
110073
110196
  defaultPipeline = new Proxy([], {
@@ -110694,7 +110817,7 @@ var init_pipeline_result_handler = __esm(() => {
110694
110817
  init_escalation();
110695
110818
  init_progress();
110696
110819
  _resultHandlerDeps = {
110697
- spawn,
110820
+ spawn: spawn2,
110698
110821
  existsSync: existsSync25,
110699
110822
  worktreeManager: new WorktreeManager,
110700
110823
  mergeEngine: new MergeEngine(new WorktreeManager),
@@ -111445,7 +111568,7 @@ async function openAcceptanceFixScope(ctx, runtime2, storyId, packageDir) {
111445
111568
  }
111446
111569
  var _acceptanceFixScopeDeps;
111447
111570
  var init_acceptance_fix_scope = __esm(() => {
111448
- init_interaction2();
111571
+ init_interaction3();
111449
111572
  init_path_frame();
111450
111573
  _acceptanceFixScopeDeps = {
111451
111574
  buildRunDispatchAskWiring
@@ -113192,7 +113315,7 @@ async function runDeferredRegression(options) {
113192
113315
  var _regressionDeps;
113193
113316
  var init_run_regression = __esm(() => {
113194
113317
  init_findings();
113195
- init_interaction2();
113318
+ init_interaction3();
113196
113319
  init_logger2();
113197
113320
  init_operations();
113198
113321
  init_event_bus();
@@ -114487,15 +114610,15 @@ function createOtelReporterPlugin(cfg, deps, workdir) {
114487
114610
  send: makeSendLogsBatch(resource)
114488
114611
  });
114489
114612
  const buildOrphanState = (startMs) => {
114490
- const identity = rootSpanIdentity();
114613
+ const identity2 = rootSpanIdentity();
114491
114614
  const orphanAttrs = buildResourceAttributes({ serviceName: cfg.serviceName, runId: "orphan" });
114492
114615
  return {
114493
- ...identity,
114616
+ ...identity2,
114494
114617
  startMs,
114495
114618
  feature: "",
114496
114619
  project: "",
114497
114620
  events: [],
114498
- spanTree: createSpanTree(identity.traceId, identity.spanId),
114621
+ spanTree: createSpanTree(identity2.traceId, identity2.spanId),
114499
114622
  spanQueue: makeSpanQueue(orphanAttrs),
114500
114623
  metrics: createPhaseMetricsAggregator(),
114501
114624
  storyBounds: new Map,
@@ -114573,7 +114696,7 @@ function createOtelReporterPlugin(cfg, deps, workdir) {
114573
114696
  const reporter = {
114574
114697
  name: STAGE8,
114575
114698
  async onRunStart(event) {
114576
- const identity = rootSpanIdentity();
114699
+ const identity2 = rootSpanIdentity();
114577
114700
  const runId = event.runId;
114578
114701
  let gitBranch;
114579
114702
  let gitSha;
@@ -114601,14 +114724,14 @@ function createOtelReporterPlugin(cfg, deps, workdir) {
114601
114724
  git: { branch: gitBranch, sha: gitSha }
114602
114725
  });
114603
114726
  const state = {
114604
- ...identity,
114727
+ ...identity2,
114605
114728
  startMs: Date.parse(event.startTime),
114606
114729
  feature: event.feature,
114607
114730
  project: event.project ?? "",
114608
114731
  gitBranch,
114609
114732
  gitSha,
114610
114733
  events: [],
114611
- spanTree: createSpanTree(identity.traceId, identity.spanId),
114734
+ spanTree: createSpanTree(identity2.traceId, identity2.spanId),
114612
114735
  spanQueue: makeSpanQueue(resourceAttrs),
114613
114736
  metrics: createPhaseMetricsAggregator(),
114614
114737
  storyBounds: new Map,
@@ -118016,7 +118139,7 @@ var init_run_initialization = __esm(() => {
118016
118139
  },
118017
118140
  hasCommitsForStory: (workdir, storyId) => hasCommitsForStory(workdir, storyId),
118018
118141
  runReview: (reviewConfig, workdir, executionConfig) => runReview({ config: reviewConfig, workdir, executionConfig }),
118019
- spawn
118142
+ spawn: spawn2
118020
118143
  };
118021
118144
  });
118022
118145
 
@@ -118285,9 +118408,9 @@ async function resolveProjectAsync(options = {}) {
118285
118408
  const identityFile = Bun.file(registryIdentityPath);
118286
118409
  if (await identityFile.exists()) {
118287
118410
  try {
118288
- const identity = await identityFile.json();
118289
- if (typeof identity.workdir === "string") {
118290
- return resolveProject({ ...options, dir: identity.workdir });
118411
+ const identity2 = await identityFile.json();
118412
+ if (typeof identity2.workdir === "string") {
118413
+ return resolveProject({ ...options, dir: identity2.workdir });
118291
118414
  }
118292
118415
  } catch {}
118293
118416
  }
@@ -120853,7 +120976,7 @@ var init_run_setup = __esm(() => {
120853
120976
  init_internal();
120854
120977
  init_errors4();
120855
120978
  init_rtk();
120856
- init_interaction2();
120979
+ init_interaction3();
120857
120980
  init_logger2();
120858
120981
  init_event_bus();
120859
120982
  init_prd();
@@ -121296,7 +121419,7 @@ async function cleanupSessionOnFailure(ctx, failAndClose2) {
121296
121419
  }
121297
121420
 
121298
121421
  // src/execution/deferred-review.ts
121299
- var {spawn: spawn6 } = globalThis.Bun;
121422
+ var {spawn: spawn7 } = globalThis.Bun;
121300
121423
  async function spawnGitWithDeadline(args, workdir) {
121301
121424
  const proc = _deferredReviewDeps.spawn({
121302
121425
  cmd: hardenedGitArgv(["git", ...args]),
@@ -121376,7 +121499,7 @@ var init_deferred_review = __esm(() => {
121376
121499
  init_internal();
121377
121500
  init_git2();
121378
121501
  init_path_filters();
121379
- _deferredReviewDeps = { spawn: spawn6 };
121502
+ _deferredReviewDeps = { spawn: spawn7 };
121380
121503
  });
121381
121504
 
121382
121505
  // src/execution/lifecycle/test-baseline-capture.ts
@@ -124665,7 +124788,7 @@ var _finishPhaseDeps;
124665
124788
  var init_phase = __esm(() => {
124666
124789
  init_internal();
124667
124790
  init_forge();
124668
- init_interaction2();
124791
+ init_interaction3();
124669
124792
  init_logger2();
124670
124793
  init_pipeline2();
124671
124794
  init_runtime3();
@@ -125254,8 +125377,8 @@ function wireInteraction(bus, interactionChain, config2) {
125254
125377
  u();
125255
125378
  };
125256
125379
  }
125257
- var init_interaction3 = __esm(() => {
125258
- init_interaction2();
125380
+ var init_interaction4 = __esm(() => {
125381
+ init_interaction3();
125259
125382
  init_logger2();
125260
125383
  });
125261
125384
 
@@ -126556,7 +126679,7 @@ var init_unified_executor = __esm(() => {
126556
126679
  init_runner2();
126557
126680
  init_events_writer();
126558
126681
  init_hooks2();
126559
- init_interaction3();
126682
+ init_interaction4();
126560
126683
  init_registry8();
126561
126684
  init_reporters();
126562
126685
  init_prd();
@@ -128861,7 +128984,7 @@ var init_plan_runtime = __esm(() => {
128861
128984
  init_analyze();
128862
128985
  init_config();
128863
128986
  init_generator2();
128864
- init_interaction2();
128987
+ init_interaction3();
128865
128988
  init_logger2();
128866
128989
  init_runtime3();
128867
128990
  init_plan_helpers();
@@ -129017,7 +129140,7 @@ var init_context_builder = __esm(() => {
129017
129140
  init_plan_runtime();
129018
129141
  init_config();
129019
129142
  init_errors4();
129020
- init_interaction2();
129143
+ init_interaction3();
129021
129144
  init_logger2();
129022
129145
  init_feature_name();
129023
129146
  init_spec_lint_gate();
@@ -132034,9 +132157,7 @@ __export(exports_cli, {
132034
132157
  MAX_CANONICAL_RULE_GLOB_FILES: () => MAX_CANONICAL_RULE_GLOB_FILES,
132035
132158
  MAX_DEAD_GLOB_SCAN_FILES: () => MAX_DEAD_GLOB_SCAN_FILES,
132036
132159
  MAX_DEAD_GLOB_SCAN_TOTAL_ENTRIES: () => MAX_DEAD_GLOB_SCAN_TOTAL_ENTRIES,
132037
- PromptCancelledError: () => PromptCancelledError,
132038
132160
  _approvalsCliDeps: () => _approvalsCliDeps,
132039
- _authPromptDeps: () => _authPromptDeps,
132040
132161
  _cliAuthDeps: () => _cliAuthDeps,
132041
132162
  _cliTrustDeps: () => _cliTrustDeps,
132042
132163
  _confirmDeps: () => _confirmDeps,
@@ -132096,8 +132217,6 @@ __export(exports_cli, {
132096
132217
  planMigration: () => planMigration,
132097
132218
  pluginsListCommand: () => pluginsListCommand,
132098
132219
  promptForConfirmation: () => promptForConfirmation,
132099
- promptForLine: () => promptForLine,
132100
- promptForSecret: () => promptForSecret,
132101
132220
  promptsCommand: () => promptsCommand,
132102
132221
  promptsInitCommand: () => promptsInitCommand,
132103
132222
  registerApprovalsCommand: () => registerApprovalsCommand,
@@ -132137,7 +132256,6 @@ var init_cli2 = __esm(() => {
132137
132256
  init_approvals();
132138
132257
  init_approvals_format();
132139
132258
  init_auth3();
132140
- init_auth_prompt();
132141
132259
  init_config2();
132142
132260
  init_config_descriptions();
132143
132261
  init_confirm();