@nathapp/nax 0.84.0 → 0.85.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/nax.js +290 -87
  2. package/package.json +3 -3
package/dist/nax.js CHANGED
@@ -143,14 +143,48 @@ var init_infra = __esm(() => {
143
143
  init_nax_error();
144
144
  });
145
145
 
146
+ // ../nax-agent/src/internal/redact-structured.ts
147
+ function redactStructured(text) {
148
+ let out = text;
149
+ for (const { re } of STRUCTURED_PATTERNS) {
150
+ re.lastIndex = 0;
151
+ out = out.replace(re, (_match, keep) => `${keep}${REDACTED}`);
152
+ }
153
+ return out;
154
+ }
155
+ var REDACTED = "[REDACTED]", KEYWORD, KEY, DQ_BODY, ESCAPED_BODY, SQ_BODY, NOT_A_REFERENCE, NOT_A_TOKEN_COUNT, AUTH_SCHEME, STRUCTURED_PATTERNS;
156
+ var init_redact_structured = __esm(() => {
157
+ KEYWORD = String.raw`(?:SECRET|TOKEN(?!s\b)|API[_-]?KEY|PASSWORD|PRIVATE[_-]?KEY|ACCESS[_-]?KEY|WEBHOOK|AUTHORIZATION|COOKIE|CREDENTIAL|PASSWD|(?<=[\w.-])_(?:URI|DSN)|CONNECTION_?STRING)`;
158
+ KEY = String.raw`[\w.-]{0,64}?${KEYWORD}[\w.-]{0,64}`;
159
+ DQ_BODY = String.raw`(?:[^"\\\r\n]|\\.)+`;
160
+ ESCAPED_BODY = String.raw`(?:[^"\\\r\n]|\\(?!\\*"))+`;
161
+ SQ_BODY = String.raw`[^'\r\n]+`;
162
+ NOT_A_REFERENCE = String.raw`(?!["'$<{(\[]|process\.|import\.meta|os\.|env\.|await\b|new\b|[\w.]+\(|(?:string|number|boolean|str|int|any|unknown|undefined|null|true|false|none)(?![\w-]))`;
163
+ NOT_A_TOKEN_COUNT = String.raw`(?![\w.-]{0,64}?TOKEN(?!s\b)[\w.-]{0,64}[ \t]{0,8}[=:][ \t]{0,8}\d+(?![\w.-]))`;
164
+ AUTH_SCHEME = String.raw`(?:(?:Bearer|Basic|Digest|Token)[ \t]+)?`;
165
+ STRUCTURED_PATTERNS = [
166
+ { re: new RegExp(String.raw`("${KEY}"\s{0,256}:\s{0,256}")(${DQ_BODY})`, "gi") },
167
+ { re: new RegExp(String.raw`('${KEY}'\s{0,256}:\s{0,256}')(${SQ_BODY})`, "gi") },
168
+ { re: new RegExp(String.raw`('${KEY}'\s{0,256}:\s{0,256}")(${DQ_BODY})`, "gi") },
169
+ { re: new RegExp(String.raw`(\\{1,3}"${KEY}\\{1,3}"\s{0,256}:\s{0,256}\\{1,3}")(${ESCAPED_BODY})`, "gi") },
170
+ { re: new RegExp(String.raw`(?<![\w.-])(${KEY}[ \t]{0,8}[=:][ \t]{0,8}")(${DQ_BODY})`, "gi") },
171
+ { re: new RegExp(String.raw`(?<![\w.-])(${KEY}[ \t]{0,8}[=:][ \t]{0,8}')(${SQ_BODY})`, "gi") },
172
+ {
173
+ re: new RegExp(String.raw`(?<![\w.-])${NOT_A_TOKEN_COUNT}(${KEY}[ \t]{0,8}[=:][ \t]{0,8})${NOT_A_REFERENCE}(${AUTH_SCHEME}[^\s"',]+)`, "gi")
174
+ }
175
+ ];
176
+ });
177
+
146
178
  // ../nax-agent/src/internal/redact.ts
147
179
  function redactString(value) {
148
180
  let out = value;
149
- for (const { re } of SECRET_VALUE_PATTERNS) {
181
+ for (const { kind, re } of SECRET_VALUE_PATTERNS) {
182
+ if (STRUCTURED_KINDS.has(kind))
183
+ continue;
150
184
  re.lastIndex = 0;
151
- out = out.replace(re, REDACTED);
185
+ out = out.replace(re, REDACTED2);
152
186
  }
153
- return out;
187
+ return redactStructured(out);
154
188
  }
155
189
  function redactSecrets(input) {
156
190
  return redactValue(input);
@@ -204,15 +238,16 @@ function redactValue(input, seen = new WeakSet, depth = 0) {
204
238
  return input.map((item) => redactValue(item, seen, depth + 1));
205
239
  const out = {};
206
240
  for (const [key, value] of Object.entries(input)) {
207
- out[key] = SECRET_KEY_PATTERN.test(key) ? REDACTED : redactValue(value, seen, depth + 1);
241
+ out[key] = SECRET_KEY_PATTERN.test(key) ? REDACTED2 : redactValue(value, seen, depth + 1);
208
242
  }
209
243
  return out;
210
244
  } finally {
211
245
  seen.delete(input);
212
246
  }
213
247
  }
214
- var SECRET_KEY_PATTERN, SECRET_VALUE_PATTERNS, REDACTED = "[REDACTED]", MAX_REDACT_DEPTH = 100, CIRCULAR_REF_MARKER = "[Circular]";
248
+ var SECRET_KEY_PATTERN, SECRET_VALUE_PATTERNS, REDACTED2 = "[REDACTED]", STRUCTURED_KINDS, MAX_REDACT_DEPTH = 100, CIRCULAR_REF_MARKER = "[Circular]";
215
249
  var init_redact = __esm(() => {
250
+ init_redact_structured();
216
251
  SECRET_KEY_PATTERN = /(SECRET|TOKEN(?!s\b)|API_?KEY|PASSWORD|PRIVATE_?KEY|ACCESS_?KEY|WEBHOOK|AUTHORIZATION|COOKIE|CREDENTIAL|PASSWD|(?:\w+)?_URL|\w+_URI|\w+_DSN|CONNECTION\s*STRING)/i;
217
252
  SECRET_VALUE_PATTERNS = [
218
253
  { kind: "openai", re: /sk-[A-Za-z0-9_-]{16,}/g },
@@ -238,6 +273,7 @@ var init_redact = __esm(() => {
238
273
  { kind: "cookie", re: /\b(?:Set-)?Cookie\s*:\s*[^\r\n]+/gi },
239
274
  { kind: "url-credentials", re: /\b[a-z][a-z0-9+.-]*:\/\/(?:[^/\s@]*:[^/\s@]+)@/gi }
240
275
  ];
276
+ STRUCTURED_KINDS = new Set(["assignment", "api-key-header"]);
241
277
  });
242
278
 
243
279
  // ../nax-agent/src/permissions/secret-spans.ts
@@ -3931,6 +3967,20 @@ var init_model_resolver = __esm(() => {
3931
3967
  init_client();
3932
3968
  });
3933
3969
 
3970
+ // ../nax-agent/src/native/provider-models.ts
3971
+ async function listProviderModels(providerId, catalogOverrides = []) {
3972
+ const client = await getNativeClient(catalogOverrides);
3973
+ const models = await client.listModels(providerId);
3974
+ return models.filter((model) => model.supportsTools).map((model) => ({
3975
+ id: model.id,
3976
+ contextWindow: model.contextWindow,
3977
+ ...model.maxTokens !== undefined ? { maxTokens: model.maxTokens } : {}
3978
+ })).sort((a, b) => byCodePoint(a.id, b.id));
3979
+ }
3980
+ var init_provider_models = __esm(() => {
3981
+ init_client();
3982
+ });
3983
+
3934
3984
  // ../nax-agent/src/native/session/memory-transcript-store.ts
3935
3985
  function createMemoryTranscriptStore() {
3936
3986
  const live = new Map;
@@ -21169,11 +21219,24 @@ function flagFromBoolean(input, field, subcommand, validVerbs, flag) {
21169
21219
  function looksLikeFlag(value) {
21170
21220
  return value.startsWith("-");
21171
21221
  }
21222
+ function buildGitRootArgv(input) {
21223
+ const extraFields = Object.keys(input).filter((field) => field !== "subcommand");
21224
+ if (extraFields.length > 0) {
21225
+ return { error: `rev-parse accepts no additional fields (received: ${extraFields.join(", ")})` };
21226
+ }
21227
+ return ["rev-parse", "--show-toplevel"];
21228
+ }
21229
+ function defaultGitExcludes(subcommand, excludes) {
21230
+ return subcommand === "blame" ? [] : excludes;
21231
+ }
21172
21232
  function buildGitArgv(input, defaultExcludes = []) {
21173
21233
  const subcommand = input.subcommand;
21174
21234
  if (typeof subcommand !== "string" || !GIT_READ_VERBS.includes(subcommand)) {
21175
21235
  return { error: `subcommand must be one of: ${GIT_READ_VERBS.join(", ")}` };
21176
21236
  }
21237
+ if (subcommand === "rev-parse") {
21238
+ return buildGitRootArgv(input);
21239
+ }
21177
21240
  const refs = Array.isArray(input.refs) ? input.refs : [];
21178
21241
  const paths = Array.isArray(input.paths) ? input.paths : [];
21179
21242
  const argv = [subcommand];
@@ -21239,8 +21302,7 @@ function buildGitArgv(input, defaultExcludes = []) {
21239
21302
  argv.push("--");
21240
21303
  if (paths.length === 0) {
21241
21304
  argv.push(".");
21242
- if (subcommand !== "blame")
21243
- argv.push(...defaultExcludes);
21305
+ argv.push(...defaultGitExcludes(subcommand, defaultExcludes));
21244
21306
  return argv;
21245
21307
  }
21246
21308
  for (const path of paths) {
@@ -21258,7 +21320,7 @@ var init_git = __esm(() => {
21258
21320
  init_git_exec();
21259
21321
  init_truncate();
21260
21322
  init_git_flags();
21261
- GIT_READ_VERBS = ["diff", "log", "show", "status", "blame"];
21323
+ GIT_READ_VERBS = ["diff", "log", "show", "status", "blame", "rev-parse"];
21262
21324
  GIT_DIFF_FILTERS = ["A", "M", "D", "R"];
21263
21325
  GIT_NAME_ONLY_VERBS = ["diff", "log", "show"];
21264
21326
  GIT_DIFF_FILTER_VERBS = ["diff", "log", "show"];
@@ -21267,11 +21329,15 @@ var init_git = __esm(() => {
21267
21329
  GIT_FULL_MESSAGE_VERBS = ["log"];
21268
21330
  gitTool = {
21269
21331
  name: "Git",
21270
- 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.",
21332
+ 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.",
21271
21333
  inputSchema: {
21272
21334
  type: "object",
21273
21335
  properties: {
21274
- subcommand: { type: "string", enum: [...GIT_READ_VERBS], description: "Read-only git subcommand" },
21336
+ subcommand: {
21337
+ type: "string",
21338
+ enum: [...GIT_READ_VERBS],
21339
+ description: "Read-only git subcommand; rev-parse is fixed to --show-toplevel"
21340
+ },
21275
21341
  refs: { type: "array", items: { type: "string" }, description: "Refs, e.g. ['HEAD~1','HEAD']" },
21276
21342
  paths: { type: "array", items: { type: "string" }, description: "Pathspecs, relative to the permitted root" },
21277
21343
  nameOnly: {
@@ -23971,7 +24037,7 @@ function redirectForVerb(deniedTool, verb, available, declaredCommands) {
23971
24037
  }
23972
24038
  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;
23973
24039
  var init_denial_redirect = __esm(() => {
23974
- GIT_READ_VERBS2 = new Set(["diff", "log", "show", "status", "blame"]);
24040
+ GIT_READ_VERBS2 = new Set(["diff", "log", "show", "status", "blame", "rev-parse"]);
23975
24041
  GIT_COMMIT_VERBS = new Set(["add", "commit"]);
23976
24042
  GIT_REVERT_VERBS = new Set(["checkout", "restore"]);
23977
24043
  GLOB = { tool: "Glob", how: "Glob lists repository paths by pattern" };
@@ -26514,6 +26580,7 @@ var init_native = __esm(() => {
26514
26580
  init_errors();
26515
26581
  init_model_resolver();
26516
26582
  init_models();
26583
+ init_provider_models();
26517
26584
  init_transcript_store();
26518
26585
  init_session_adapter();
26519
26586
  init_session_affinity();
@@ -26668,6 +26735,23 @@ var init_interaction_handler = __esm(() => {
26668
26735
  NO_OP_INTERACTION_HANDLER2 = NO_OP_INTERACTION_HANDLER;
26669
26736
  });
26670
26737
 
26738
+ // ../nax-agent/src/native/session/compaction-settings.ts
26739
+ function resolveCompaction(input) {
26740
+ return compactionSettingsSchema.parse(input);
26741
+ }
26742
+ var DEFAULT_COMPACTION, compactionSettingsSchema;
26743
+ var init_compaction_settings = __esm(() => {
26744
+ init_zod();
26745
+ DEFAULT_COMPACTION = { enabled: true, compactAtPercent: 90, keepRecentPercent: 30 };
26746
+ compactionSettingsSchema = exports_external.object({
26747
+ enabled: exports_external.boolean().default(DEFAULT_COMPACTION.enabled),
26748
+ compactAtPercent: exports_external.number().int().min(50).max(99).default(DEFAULT_COMPACTION.compactAtPercent),
26749
+ keepRecentPercent: exports_external.number().int().min(5).max(79).default(DEFAULT_COMPACTION.keepRecentPercent)
26750
+ }).refine((c) => c.keepRecentPercent <= c.compactAtPercent - 20, {
26751
+ message: "keepRecentPercent must be at least 20 points below compactAtPercent"
26752
+ }).default({ ...DEFAULT_COMPACTION });
26753
+ });
26754
+
26671
26755
  // ../nax-agent/src/session/native-backend-options.ts
26672
26756
  function isRecord2(value) {
26673
26757
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -26679,6 +26763,7 @@ var isStringArray = (value) => Array.isArray(value) && value.every((item) => typ
26679
26763
  var init_native_backend_options = __esm(() => {
26680
26764
  init_zod();
26681
26765
  init_models();
26766
+ init_compaction_settings();
26682
26767
  init_instruction_file_name();
26683
26768
  init_agent_session_errors();
26684
26769
  OptionsSchema2 = exports_external.strictObject({
@@ -26693,7 +26778,8 @@ var init_native_backend_options = __esm(() => {
26693
26778
  }).optional(),
26694
26779
  bashApproval: exports_external.enum(["raw", "gated", "escalate"]).optional(),
26695
26780
  allowUnsandboxed: exports_external.boolean().optional(),
26696
- carryHistoryAcrossModels: exports_external.boolean().optional()
26781
+ carryHistoryAcrossModels: exports_external.boolean().optional(),
26782
+ compaction: compactionSettingsSchema.optional()
26697
26783
  });
26698
26784
  });
26699
26785
 
@@ -27020,6 +27106,7 @@ var init_session_tool_support = __esm(() => {
27020
27106
  var init_native_backend = __esm(() => {
27021
27107
  init_spin_breaker();
27022
27108
  init_models();
27109
+ init_compaction_settings();
27023
27110
  init_transcript_identity();
27024
27111
  init_session_adapter();
27025
27112
  init_agent_session_errors();
@@ -29630,6 +29717,7 @@ __export(exports_internal, {
29630
29717
  COMPACTION_SUMMARY_SUFFIX: () => COMPACTION_SUMMARY_SUFFIX,
29631
29718
  DEFAULT_BASH_APPROVAL_MODE: () => DEFAULT_BASH_APPROVAL_MODE,
29632
29719
  DEFAULT_BASH_SHELL: () => DEFAULT_BASH_SHELL,
29720
+ DEFAULT_COMPACTION: () => DEFAULT_COMPACTION,
29633
29721
  DEFAULT_INSTRUCTION_FILE_NAME: () => DEFAULT_INSTRUCTION_FILE_NAME,
29634
29722
  DEFAULT_LOG_FORMAT: () => DEFAULT_LOG_FORMAT,
29635
29723
  DEFAULT_LOG_MAX_COUNT: () => DEFAULT_LOG_MAX_COUNT,
@@ -29755,6 +29843,7 @@ __export(exports_internal, {
29755
29843
  codingToolSupportModule: () => exports_coding_tool_support,
29756
29844
  codingToolsToDefinitions: () => codingToolsToDefinitions,
29757
29845
  commandSpecIncludes: () => commandSpecIncludes,
29846
+ compactionSettingsSchema: () => compactionSettingsSchema,
29758
29847
  compactionThreshold: () => compactionThreshold,
29759
29848
  compileToolPolicy: () => compileToolPolicy,
29760
29849
  completeWithRecovery: () => completeWithRecovery,
@@ -29841,6 +29930,7 @@ __export(exports_internal, {
29841
29930
  listCredentialFiles: () => listCredentialFiles,
29842
29931
  listGitGuardFiles: () => listGitGuardFiles,
29843
29932
  listNaxEntries: () => listNaxEntries,
29933
+ listProviderModels: () => listProviderModels,
29844
29934
  listStoredProviders: () => listStoredProviders,
29845
29935
  loadTranscript: () => loadTranscript,
29846
29936
  loginProviderIds: () => loginProviderIds,
@@ -29908,6 +29998,7 @@ __export(exports_internal, {
29908
29998
  resetSandboxBackend: () => resetSandboxBackend,
29909
29999
  resolveBashApproval: () => resolveBashApproval,
29910
30000
  resolveBashSupport: () => resolveBashSupport,
30001
+ resolveCompaction: () => resolveCompaction,
29911
30002
  resolveContextWindow: () => resolveContextWindow,
29912
30003
  resolveGitLayout: () => resolveGitLayout,
29913
30004
  resolveNativeId: () => resolveNativeId,
@@ -29984,6 +30075,7 @@ var init_internal = __esm(() => {
29984
30075
  init_core();
29985
30076
  init_infra();
29986
30077
  init_git_exec();
30078
+ init_compaction_settings();
29987
30079
  init_instruction_file_name();
29988
30080
  init_repository_instructions();
29989
30081
  init_session();
@@ -30023,6 +30115,7 @@ var init_internal = __esm(() => {
30023
30115
  init_errors();
30024
30116
  init_model_resolver();
30025
30117
  init_models();
30118
+ init_provider_models();
30026
30119
  init_external_handler();
30027
30120
  init_loop_events();
30028
30121
  init_session();
@@ -32922,7 +33015,7 @@ function isLegacyFlatModels(val) {
32922
33015
  }
32923
33016
  return false;
32924
33017
  }
32925
- 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;
33018
+ 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;
32926
33019
  var init_schemas_model = __esm(() => {
32927
33020
  init_zod();
32928
33021
  ConfigPricingTierSchema = exports_external.object({
@@ -32946,6 +33039,13 @@ var init_schemas_model = __esm(() => {
32946
33039
  cacheRead: exports_external.number().min(0),
32947
33040
  cacheWrite: exports_external.number().min(0)
32948
33041
  }).strict();
33042
+ PercentileCutoffSchema = exports_external.object({
33043
+ p50: exports_external.number().positive().optional(),
33044
+ p75: exports_external.number().positive().optional(),
33045
+ p90: exports_external.number().positive().optional(),
33046
+ p99: exports_external.number().positive().optional()
33047
+ }).strict().refine((v) => Object.keys(v).length > 0, { message: "a percentile cutoff object must not be empty" });
33048
+ PercentileTargetSchema = exports_external.union([exports_external.number().positive(), PercentileCutoffSchema]);
32949
33049
  OpenRouterRoutingSchema = exports_external.object({
32950
33050
  allow_fallbacks: exports_external.boolean().optional(),
32951
33051
  require_parameters: exports_external.boolean().optional(),
@@ -32955,7 +33055,9 @@ var init_schemas_model = __esm(() => {
32955
33055
  only: exports_external.array(exports_external.string().min(1)).optional(),
32956
33056
  ignore: exports_external.array(exports_external.string().min(1)).optional(),
32957
33057
  quantizations: exports_external.array(exports_external.string().min(1)).optional(),
32958
- sort: exports_external.enum(["price", "throughput", "latency"]).optional()
33058
+ sort: exports_external.enum(["price", "throughput", "latency"]).optional(),
33059
+ preferred_min_throughput: PercentileTargetSchema.optional(),
33060
+ preferred_max_latency: PercentileTargetSchema.optional()
32959
33061
  }).strict().refine((v) => Object.keys(v).length > 0, {
32960
33062
  message: "openRouterRouting must not be empty \u2014 omit the key to leave the model's routing unset"
32961
33063
  });
@@ -33150,13 +33252,7 @@ var init_schemas_execution = __esm(() => {
33150
33252
  rectification: RectificationConfigSchema,
33151
33253
  regressionGate: RegressionGateConfigSchema,
33152
33254
  contextProviderTokenBudget: exports_external.number().int().positive({ message: "contextProviderTokenBudget must be > 0" }).default(2000),
33153
- compaction: exports_external.object({
33154
- enabled: exports_external.boolean().default(true),
33155
- compactAtPercent: exports_external.number().int().min(50).max(99).default(90),
33156
- keepRecentPercent: exports_external.number().int().min(5).max(79).default(30)
33157
- }).refine((c) => c.keepRecentPercent <= c.compactAtPercent - 20, {
33158
- message: "keepRecentPercent must be at least 20 points below compactAtPercent"
33159
- }).default({ enabled: true, compactAtPercent: 90, keepRecentPercent: 30 }),
33255
+ compaction: compactionSettingsSchema,
33160
33256
  lintCommand: exports_external.string().nullable().optional(),
33161
33257
  typecheckCommand: exports_external.string().nullable().optional(),
33162
33258
  permissionProfile: exports_external.enum(["unrestricted", "safe", "scoped"]).default("unrestricted"),
@@ -38851,7 +38947,7 @@ var package_default;
38851
38947
  var init_package = __esm(() => {
38852
38948
  package_default = {
38853
38949
  name: "@nathapp/nax",
38854
- version: "0.84.0",
38950
+ version: "0.85.1",
38855
38951
  description: "AI Coding Agent Orchestrator \u2014 loops until done",
38856
38952
  type: "module",
38857
38953
  bin: {
@@ -38937,8 +39033,8 @@ var init_package = __esm(() => {
38937
39033
  dependencies: {
38938
39034
  "@agentclientprotocol/sdk": "~1.7.0",
38939
39035
  "@anthropic-ai/sandbox-runtime": "0.0.77",
38940
- "@modelcontextprotocol/sdk": "^1.30.0",
38941
- "@nathapp/nax-ai": "0.84.0",
39036
+ "@modelcontextprotocol/sdk": "^1.32.1",
39037
+ "@nathapp/nax-ai": "0.85.1",
38942
39038
  chalk: "^5.6.2",
38943
39039
  commander: "^13.1.0",
38944
39040
  ink: "^6.7.0",
@@ -44842,6 +44938,8 @@ function buildAgentScopeSection(root, workdirLabel) {
44842
44938
  return [
44843
44939
  "## Your file scope",
44844
44940
  "",
44941
+ `**Execution repository/worktree root:** \`${root}\``,
44942
+ "",
44845
44943
  "Your file tools (Read, Write, Edit, Glob, Grep, Git) are rooted at the repository root.",
44846
44944
  "Every path you pass them is resolved from there."
44847
44945
  ].join(`
@@ -44850,6 +44948,8 @@ function buildAgentScopeSection(root, workdirLabel) {
44850
44948
  return [
44851
44949
  "## Your file scope",
44852
44950
  "",
44951
+ `**Execution repository/worktree root:** \`${root}\``,
44952
+ "",
44853
44953
  "Your file tools (Read, Write, Edit, Glob, Grep, Git) are rooted at the repository root, NOT at your package.",
44854
44954
  `Your story's package is \`${workdirLabel}\`. Spell every path repo-rooted from the repository root: write`,
44855
44955
  `\`${workdirLabel}/src/index.ts\`, never \`src/index.ts\`.`,
@@ -57353,8 +57453,8 @@ var init_version = __esm(() => {
57353
57453
  NAX_AI_VERSION = CATALOG_VERSION;
57354
57454
  NAX_COMMIT = (() => {
57355
57455
  try {
57356
- if (/^[0-9a-f]{6,10}$/.test("eeb09eb"))
57357
- return "eeb09eb";
57456
+ if (/^[0-9a-f]{6,10}$/.test("9611b61"))
57457
+ return "9611b61";
57358
57458
  } catch {}
57359
57459
  try {
57360
57460
  const result = Bun.spawnSync(["git", "rev-parse", "--short", "HEAD"], {
@@ -59203,7 +59303,7 @@ var init_v4_mini = __esm(() => {
59203
59303
  init_external2();
59204
59304
  });
59205
59305
 
59206
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
59306
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
59207
59307
  function isZ4Schema(s) {
59208
59308
  const schema = s;
59209
59309
  return !!schema._zod;
@@ -59280,7 +59380,7 @@ var init_v4 = __esm(() => {
59280
59380
  init_classic();
59281
59381
  });
59282
59382
 
59283
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
59383
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
59284
59384
  var LATEST_PROTOCOL_VERSION = "2025-11-25", DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26", SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task", JSONRPC_VERSION = "2.0", AssertObjectSchema, ProgressTokenSchema, CursorSchema, TaskCreationParamsSchema, TaskMetadataSchema, RelatedTaskMetadataSchema, RequestMetaSchema, BaseRequestParamsSchema, TaskAugmentedRequestParamsSchema, isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success, RequestSchema, NotificationsParamsSchema, NotificationSchema, ResultSchema, RequestIdSchema, JSONRPCRequestSchema, isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success, JSONRPCNotificationSchema, isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success, JSONRPCResultResponseSchema, isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success, ErrorCode, JSONRPCErrorResponseSchema, isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success, JSONRPCMessageSchema, JSONRPCResponseSchema, EmptyResultSchema, CancelledNotificationParamsSchema, CancelledNotificationSchema, IconSchema, IconsSchema, BaseMetadataSchema, ImplementationSchema, FormElicitationCapabilitySchema, ElicitationCapabilitySchema, ClientTasksCapabilitySchema, ServerTasksCapabilitySchema, ClientCapabilitiesSchema, InitializeRequestParamsSchema, InitializeRequestSchema, isInitializeRequest = (value) => InitializeRequestSchema.safeParse(value).success, ServerCapabilitiesSchema, InitializeResultSchema, InitializedNotificationSchema, PingRequestSchema, ProgressSchema, ProgressNotificationParamsSchema, ProgressNotificationSchema, PaginatedRequestParamsSchema, PaginatedRequestSchema, PaginatedResultSchema, TaskStatusSchema, TaskSchema, CreateTaskResultSchema, TaskStatusNotificationParamsSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, GetTaskPayloadResultSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ResourceContentsSchema, TextResourceContentsSchema, Base64Schema, BlobResourceContentsSchema, RoleSchema, AnnotationsSchema, ResourceSchema, ResourceTemplateSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListResourceTemplatesRequestSchema, ListResourceTemplatesResultSchema, ResourceRequestParamsSchema, ReadResourceRequestParamsSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SubscribeRequestParamsSchema, SubscribeRequestSchema, UnsubscribeRequestParamsSchema, UnsubscribeRequestSchema, ResourceUpdatedNotificationParamsSchema, ResourceUpdatedNotificationSchema, PromptArgumentSchema, PromptSchema, ListPromptsRequestSchema, ListPromptsResultSchema, GetPromptRequestParamsSchema, GetPromptRequestSchema, TextContentSchema, ImageContentSchema, AudioContentSchema, ToolUseContentSchema, EmbeddedResourceSchema, ResourceLinkSchema, ContentBlockSchema, PromptMessageSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ToolAnnotationsSchema, ToolExecutionSchema, ToolSchema, ListToolsRequestSchema, ListToolsResultSchema, CallToolResultSchema, CompatibilityCallToolResultSchema, CallToolRequestParamsSchema, CallToolRequestSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, LoggingLevelSchema, SetLevelRequestParamsSchema, SetLevelRequestSchema, LoggingMessageNotificationParamsSchema, LoggingMessageNotificationSchema, ModelHintSchema, ModelPreferencesSchema, ToolChoiceSchema, ToolResultContentSchema, SamplingContentSchema, SamplingMessageContentBlockSchema, SamplingMessageSchema, CreateMessageRequestParamsSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema, EnumSchemaSchema, PrimitiveSchemaDefinitionSchema, ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema, ElicitRequestParamsSchema, ElicitRequestSchema, ElicitationCompleteNotificationParamsSchema, ElicitationCompleteNotificationSchema, ElicitResultSchema, ResourceTemplateReferenceSchema, PromptReferenceSchema, CompleteRequestParamsSchema, CompleteRequestSchema, CompleteResultSchema, RootSchema, ListRootsRequestSchema, ListRootsResultSchema, RootsListChangedNotificationSchema, ClientRequestSchema, ClientNotificationSchema, ClientResultSchema, ServerRequestSchema, ServerNotificationSchema, ServerResultSchema, McpError, UrlElicitationRequiredError;
59285
59385
  var init_types7 = __esm(() => {
59286
59386
  init_v4();
@@ -60108,7 +60208,7 @@ var init_types7 = __esm(() => {
60108
60208
  };
60109
60209
  });
60110
60210
 
60111
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
60211
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
60112
60212
  function isTerminal(status) {
60113
60213
  return status === "completed" || status === "failed" || status === "cancelled";
60114
60214
  }
@@ -60326,7 +60426,7 @@ var init_esm = __esm(() => {
60326
60426
  init_zodToJsonSchema();
60327
60427
  });
60328
60428
 
60329
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
60429
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
60330
60430
  function getMethodLiteral(schema) {
60331
60431
  const shape = getObjectShape(schema);
60332
60432
  const methodSchema = shape?.method;
@@ -60351,7 +60451,7 @@ var init_zod_json_schema_compat = __esm(() => {
60351
60451
  init_esm();
60352
60452
  });
60353
60453
 
60354
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
60454
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
60355
60455
  class Protocol {
60356
60456
  constructor(_options) {
60357
60457
  this._options = _options;
@@ -60387,6 +60487,9 @@ class Protocol {
60387
60487
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
60388
60488
  const handleTaskResult = async () => {
60389
60489
  const taskId = request.params.taskId;
60490
+ if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
60491
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
60492
+ }
60390
60493
  if (this._taskMessageQueue) {
60391
60494
  let queuedMessage;
60392
60495
  while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
@@ -60417,12 +60520,12 @@ class Protocol {
60417
60520
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
60418
60521
  }
60419
60522
  if (!isTerminal(task.status)) {
60420
- await this._waitForTaskUpdate(taskId, extra.signal);
60523
+ await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
60421
60524
  return await handleTaskResult();
60422
60525
  }
60423
60526
  if (isTerminal(task.status)) {
60424
60527
  const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
60425
- this._clearTaskQueue(taskId);
60528
+ this._clearTaskQueue(taskId, extra.sessionId);
60426
60529
  return {
60427
60530
  ...result,
60428
60531
  _meta: {
@@ -60459,7 +60562,7 @@ class Protocol {
60459
60562
  throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
60460
60563
  }
60461
60564
  await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
60462
- this._clearTaskQueue(request.params.taskId);
60565
+ this._clearTaskQueue(request.params.taskId, extra.sessionId);
60463
60566
  const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
60464
60567
  if (!cancelledTask) {
60465
60568
  throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
@@ -60582,6 +60685,19 @@ class Protocol {
60582
60685
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
60583
60686
  const capturedTransport = this._transport;
60584
60687
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
60688
+ const sessionId = capturedTransport?.sessionId;
60689
+ const store = this._taskStore;
60690
+ let relatedTaskFound = true;
60691
+ let relatedTaskLookup;
60692
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId !== undefined) {
60693
+ relatedTaskFound = false;
60694
+ relatedTaskLookup = (async () => {
60695
+ if (!await store.getTask(relatedTaskId, sessionId)) {
60696
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
60697
+ }
60698
+ relatedTaskFound = true;
60699
+ })();
60700
+ }
60585
60701
  if (handler === undefined) {
60586
60702
  const errorResponse = {
60587
60703
  jsonrpc: "2.0",
@@ -60591,7 +60707,10 @@ class Protocol {
60591
60707
  message: "Method not found"
60592
60708
  }
60593
60709
  };
60594
- if (relatedTaskId && this._taskMessageQueue) {
60710
+ if (relatedTaskId && relatedTaskLookup) {
60711
+ const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
60712
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error48) => this._onerror(new Error(`Failed to send an error response: ${error48}`)));
60713
+ } else if (relatedTaskId && this._taskMessageQueue) {
60595
60714
  this._enqueueTaskMessage(relatedTaskId, {
60596
60715
  type: "error",
60597
60716
  message: errorResponse,
@@ -60642,7 +60761,10 @@ class Protocol {
60642
60761
  closeSSEStream: extra?.closeSSEStream,
60643
60762
  closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
60644
60763
  };
60645
- Promise.resolve().then(() => {
60764
+ (relatedTaskLookup ?? Promise.resolve()).then(() => {
60765
+ if (relatedTaskLookup && abortController.signal.aborted) {
60766
+ throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
60767
+ }
60646
60768
  if (taskCreationParams) {
60647
60769
  this.assertTaskHandlerCapability(request.method);
60648
60770
  }
@@ -60677,7 +60799,7 @@ class Protocol {
60677
60799
  ...error48["data"] !== undefined && { data: error48["data"] }
60678
60800
  }
60679
60801
  };
60680
- if (relatedTaskId && this._taskMessageQueue) {
60802
+ if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
60681
60803
  await this._enqueueTaskMessage(relatedTaskId, {
60682
60804
  type: "error",
60683
60805
  message: errorResponse,
@@ -61065,7 +61187,7 @@ class Protocol {
61065
61187
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
61066
61188
  }
61067
61189
  const maxQueueSize = this._options?.maxTaskQueueSize;
61068
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
61190
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
61069
61191
  }
61070
61192
  async _clearTaskQueue(taskId, sessionId) {
61071
61193
  if (this._taskMessageQueue) {
@@ -61084,10 +61206,10 @@ class Protocol {
61084
61206
  }
61085
61207
  }
61086
61208
  }
61087
- async _waitForTaskUpdate(taskId, signal) {
61209
+ async _waitForTaskUpdate(taskId, signal, sessionId) {
61088
61210
  let interval = this._options?.defaultTaskPollInterval ?? 1000;
61089
61211
  try {
61090
- const task = await this._taskStore?.getTask(taskId);
61212
+ const task = await this._taskStore?.getTask(taskId, sessionId);
61091
61213
  if (task?.pollInterval) {
61092
61214
  interval = task.pollInterval;
61093
61215
  }
@@ -64198,7 +64320,7 @@ var require_data = __commonJS(function(exports, module) {
64198
64320
  };
64199
64321
  });
64200
64322
 
64201
- // ../../node_modules/.bun/fast-uri@3.1.7/node_modules/fast-uri/lib/utils.js
64323
+ // ../../node_modules/.bun/fast-uri@3.1.8/node_modules/fast-uri/lib/utils.js
64202
64324
  var require_utils = __commonJS(function(exports, module) {
64203
64325
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
64204
64326
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
@@ -64715,7 +64837,7 @@ var require_utils = __commonJS(function(exports, module) {
64715
64837
  };
64716
64838
  });
64717
64839
 
64718
- // ../../node_modules/.bun/fast-uri@3.1.7/node_modules/fast-uri/lib/schemes.js
64840
+ // ../../node_modules/.bun/fast-uri@3.1.8/node_modules/fast-uri/lib/schemes.js
64719
64841
  var require_schemes = __commonJS(function(exports, module) {
64720
64842
  var { isUUID } = require_utils();
64721
64843
  var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
@@ -64890,7 +65012,7 @@ var require_schemes = __commonJS(function(exports, module) {
64890
65012
  };
64891
65013
  });
64892
65014
 
64893
- // ../../node_modules/.bun/fast-uri@3.1.7/node_modules/fast-uri/index.js
65015
+ // ../../node_modules/.bun/fast-uri@3.1.8/node_modules/fast-uri/index.js
64894
65016
  var require_fast_uri = __commonJS(function(exports, module) {
64895
65017
  var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
64896
65018
  var { SCHEMES, getSchemeHandler } = require_schemes();
@@ -65220,13 +65342,14 @@ var require_fast_uri = __commonJS(function(exports, module) {
65220
65342
  if (!malformedIPLiteral) {
65221
65343
  malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
65222
65344
  }
65223
- if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
65224
- if (uri.indexOf("%") !== -1) {
65225
- if (parsed.host !== undefined && !malformedIPLiteral) {
65226
- const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
65227
- parsed.host = reescapeHostDelimiters(host, isIP);
65228
- }
65345
+ if (uri.indexOf("%") !== -1 && parsed.host !== undefined && !malformedIPLiteral) {
65346
+ let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
65347
+ if (!isIP) {
65348
+ host = normalizePercentEncoding(host.toLowerCase());
65229
65349
  }
65350
+ parsed.host = reescapeHostDelimiters(host, isIP);
65351
+ }
65352
+ if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
65230
65353
  if (parsed.path) {
65231
65354
  parsed.path = normalizePathEncoding(parsed.path);
65232
65355
  }
@@ -68082,7 +68205,7 @@ var require_dist = __commonJS(function(exports, module) {
68082
68205
  exports.default = formatsPlugin;
68083
68206
  });
68084
68207
 
68085
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
68208
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
68086
68209
  function createDefaultAjvInstance() {
68087
68210
  const ajv = new import_ajv.default({
68088
68211
  strict: false,
@@ -68125,7 +68248,7 @@ var init_ajv_provider = __esm(() => {
68125
68248
  import_ajv_formats = __toESM(require_dist(), 1);
68126
68249
  });
68127
68250
 
68128
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
68251
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
68129
68252
  class ExperimentalClientTasks {
68130
68253
  constructor(_client) {
68131
68254
  this._client = _client;
@@ -68194,7 +68317,7 @@ var init_client2 = __esm(() => {
68194
68317
  init_types7();
68195
68318
  });
68196
68319
 
68197
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
68320
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
68198
68321
  function assertToolsCallTaskCapability(requests, method, entityName) {
68199
68322
  if (!requests) {
68200
68323
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -68229,7 +68352,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
68229
68352
  }
68230
68353
  }
68231
68354
 
68232
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
68355
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
68233
68356
  function applyElicitationDefaults(schema, data) {
68234
68357
  if (!schema || data === null || typeof data !== "object")
68235
68358
  return;
@@ -69150,7 +69273,7 @@ var require_cross_spawn = __commonJS(function(exports, module) {
69150
69273
  module.exports._enoent = enoent;
69151
69274
  });
69152
69275
 
69153
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
69276
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
69154
69277
  class ReadBuffer {
69155
69278
  constructor(options) {
69156
69279
  this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
@@ -69193,7 +69316,7 @@ var init_stdio = __esm(() => {
69193
69316
  STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
69194
69317
  });
69195
69318
 
69196
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
69319
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
69197
69320
  import process4 from "process";
69198
69321
  import { PassThrough } from "stream";
69199
69322
  function getDefaultEnvironment() {
@@ -89595,7 +89718,7 @@ var init_tool_calls = __esm(() => {
89595
89718
  TOO_MANY_TEXT = `Too many concurrent tool calls: at most ${MAX_CONCURRENT_TOOL_CALLS} run at once.`;
89596
89719
  });
89597
89720
 
89598
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
89721
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
89599
89722
  class ExperimentalServerTasks {
89600
89723
  constructor(_server) {
89601
89724
  this._server = _server;
@@ -89676,7 +89799,7 @@ var init_server = __esm(() => {
89676
89799
  init_types7();
89677
89800
  });
89678
89801
 
89679
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
89802
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
89680
89803
  var Server;
89681
89804
  var init_server2 = __esm(() => {
89682
89805
  init_protocol();
@@ -91409,7 +91532,7 @@ var require_content_type = __commonJS(function(exports) {
91409
91532
  }
91410
91533
  });
91411
91534
 
91412
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
91535
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
91413
91536
  function mediaTypeEssence(header) {
91414
91537
  if (!header) {
91415
91538
  return;
@@ -91435,7 +91558,53 @@ var init_mediaType = __esm(() => {
91435
91558
  import_content_type = __toESM(require_content_type(), 1);
91436
91559
  });
91437
91560
 
91438
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js
91561
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js
91562
+ function requestBodyTooLargeMessage(maxBytes) {
91563
+ return `Payload Too Large: Request body must not exceed ${maxBytes} bytes`;
91564
+ }
91565
+ function resolveMaxRequestBodySize(value) {
91566
+ if (value === undefined) {
91567
+ return DEFAULT_MAX_REQUEST_BODY_SIZE;
91568
+ }
91569
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
91570
+ throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(value)}`);
91571
+ }
91572
+ return value;
91573
+ }
91574
+ async function readRequestBody(request, maxBytes = DEFAULT_MAX_REQUEST_BODY_SIZE) {
91575
+ if (Number(request.headers.get("content-length")) > maxBytes) {
91576
+ return { tooLarge: true };
91577
+ }
91578
+ if (request.body === null) {
91579
+ return { tooLarge: false, text: "" };
91580
+ }
91581
+ const reader = request.body.getReader();
91582
+ const decoder = new TextDecoder;
91583
+ let received = 0;
91584
+ let text = "";
91585
+ try {
91586
+ for (;; ) {
91587
+ const { done, value } = await reader.read();
91588
+ if (done) {
91589
+ break;
91590
+ }
91591
+ received += value.byteLength;
91592
+ if (received > maxBytes) {
91593
+ return { tooLarge: true };
91594
+ }
91595
+ text += decoder.decode(value, { stream: true });
91596
+ }
91597
+ } finally {
91598
+ reader.releaseLock();
91599
+ }
91600
+ return { tooLarge: false, text: text + decoder.decode() };
91601
+ }
91602
+ var DEFAULT_MAX_REQUEST_BODY_SIZE, MAX_BATCH_SIZE = 100;
91603
+ var init_requestBody = __esm(() => {
91604
+ DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
91605
+ });
91606
+
91607
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js
91439
91608
  function armSseKeepAlive(intervalMs, onTick) {
91440
91609
  if (!Number.isFinite(intervalMs) || intervalMs < 1) {
91441
91610
  return;
@@ -91449,7 +91618,7 @@ var init_sseKeepAlive = __esm(() => {
91449
91618
  MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
91450
91619
  });
91451
91620
 
91452
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
91621
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
91453
91622
  class WebStandardStreamableHTTPServerTransport {
91454
91623
  constructor(options = {}) {
91455
91624
  this._started = false;
@@ -91472,6 +91641,7 @@ class WebStandardStreamableHTTPServerTransport {
91472
91641
  this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
91473
91642
  this._retryInterval = options.retryInterval;
91474
91643
  this._keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
91644
+ this._maxRequestBodySize = resolveMaxRequestBodySize(options.maxRequestBodySize);
91475
91645
  }
91476
91646
  startKeepAlive(controller, encoder) {
91477
91647
  if (this._closed)
@@ -91788,12 +91958,22 @@ data:
91788
91958
  rawMessage = options.parsedBody;
91789
91959
  } else {
91790
91960
  try {
91791
- rawMessage = await req.json();
91961
+ const body = await readRequestBody(req, this._maxRequestBodySize);
91962
+ if (body.tooLarge) {
91963
+ const message = requestBodyTooLargeMessage(this._maxRequestBodySize);
91964
+ this.onerror?.(new Error(message));
91965
+ return this.createJsonErrorResponse(413, -32000, message);
91966
+ }
91967
+ rawMessage = JSON.parse(body.text);
91792
91968
  } catch {
91793
91969
  this.onerror?.(new Error("Parse error: Invalid JSON"));
91794
91970
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
91795
91971
  }
91796
91972
  }
91973
+ if (Array.isArray(rawMessage) && rawMessage.length > MAX_BATCH_SIZE) {
91974
+ this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${MAX_BATCH_SIZE} messages`));
91975
+ return this.createJsonErrorResponse(400, -32600, `Invalid Request: Batch must not exceed ${MAX_BATCH_SIZE} messages`);
91976
+ }
91797
91977
  let messages;
91798
91978
  try {
91799
91979
  if (Array.isArray(rawMessage)) {
@@ -92107,11 +92287,12 @@ data:
92107
92287
  }
92108
92288
  var init_webStandardStreamableHttp = __esm(() => {
92109
92289
  init_mediaType();
92290
+ init_requestBody();
92110
92291
  init_sseKeepAlive();
92111
92292
  init_types7();
92112
92293
  });
92113
92294
 
92114
- // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.30.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js
92295
+ // ../../node_modules/.bun/@modelcontextprotocol+sdk@1.32.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js
92115
92296
  class StreamableHTTPServerTransport {
92116
92297
  constructor(options = {}) {
92117
92298
  this._requestContext = new WeakMap;
@@ -104208,7 +104389,8 @@ async function runRectification(ctx, state, phaseCosts, phaseOutputs, overrides)
104208
104389
  success: cycleResult.exitReason === "resolved",
104209
104390
  iterationCount: priorRectifyIterations + cycleResult.iterations.length,
104210
104391
  exitReason: reportedExitReason,
104211
- finalFindingsCount: cycleResult.finalFindings.length
104392
+ finalFindingsCount: cycleResult.finalFindings.length,
104393
+ ...provisionalMarker(cycleResult.exitReason, cycleResult.finalFindings.length)
104212
104394
  };
104213
104395
  const rectLogger = getSafeLogger2();
104214
104396
  const rectSummary = {
@@ -104255,6 +104437,9 @@ async function runRectification(ctx, state, phaseCosts, phaseOutputs, overrides)
104255
104437
  }
104256
104438
  return repoScoped;
104257
104439
  }
104440
+ function provisionalMarker(exitReason, finalFindingsCount) {
104441
+ return exitReason === "validate-short-circuit" && finalFindingsCount === 0 ? { provisional: true } : {};
104442
+ }
104258
104443
  var init_rectification = __esm(() => {
104259
104444
  init_findings();
104260
104445
  init_logger2();
@@ -104454,7 +104639,7 @@ async function runPostRectificationResume(plan, tracking, preRectGateFailureKeys
104454
104639
  phase: name,
104455
104640
  source: "post-rectification-resume"
104456
104641
  });
104457
- break;
104642
+ return false;
104458
104643
  }
104459
104644
  if (phasePassed(name, phaseOutputs[name], ctx.storyId))
104460
104645
  continue;
@@ -104465,8 +104650,19 @@ async function runPostRectificationResume(plan, tracking, preRectGateFailureKeys
104465
104650
  source: "post-rectification-resume",
104466
104651
  secondRectifyUsed: resumeRectifyUsed
104467
104652
  });
104468
- break;
104653
+ return false;
104469
104654
  }
104655
+ return true;
104656
+ }
104657
+ function settleProvisionalRectification(phaseOutputs, storyId) {
104658
+ const rect = phaseOutputs.rectification;
104659
+ if (rect?.provisional !== true)
104660
+ return;
104661
+ const othersPassed = Object.entries(phaseOutputs).every(([name, output]) => name === "rectification" || phasePassed(name, output, storyId));
104662
+ if (!othersPassed)
104663
+ return;
104664
+ const { provisional: _settled, ...rest } = rect;
104665
+ phaseOutputs.rectification = { ...rest, success: true, settledBy: "resume" };
104470
104666
  }
104471
104667
  async function runMechanicalOnlyResume(plan, tracking, rectResult) {
104472
104668
  const mechanicalOnly = !!rectResult.unfixedFindings?.length && rectResult.unfixedFindings.every((f) => f.source === "lint" || f.source === "typecheck");
@@ -104658,6 +104854,7 @@ function buildStoryOrchestratorResult(plan, tracking, inputs) {
104658
104854
  });
104659
104855
  const totalCostUsd = Object.values(phaseCosts).reduce((sum, cost) => sum + cost, 0);
104660
104856
  const durationMs = Date.now() - startedAt;
104857
+ const failedPhases = collectFailedPhases(ctx, phaseOutputs, { gateName, verifierPassedSsot, failedPhaseEntries });
104661
104858
  logStoryOrchestratorVerdict(ctx, {
104662
104859
  success: success2,
104663
104860
  phaseOutputs,
@@ -104667,9 +104864,7 @@ function buildStoryOrchestratorResult(plan, tracking, inputs) {
104667
104864
  missingRequiredReviewPhases,
104668
104865
  upstreamShortCircuited,
104669
104866
  shortCircuitPhase,
104670
- failedPhaseEntries,
104671
- gateName,
104672
- verifierPassedSsot
104867
+ failedPhases
104673
104868
  });
104674
104869
  return {
104675
104870
  success: success2,
@@ -104679,9 +104874,20 @@ function buildStoryOrchestratorResult(plan, tracking, inputs) {
104679
104874
  phaseOutputs,
104680
104875
  ...rectResult,
104681
104876
  gateRegressedDuringRect,
104682
- missingRequiredReviewPhases: missingRequiredReviewPhases.length > 0 ? missingRequiredReviewPhases : undefined
104877
+ missingRequiredReviewPhases: missingRequiredReviewPhases.length > 0 ? missingRequiredReviewPhases : undefined,
104878
+ ...failedPhases.length > 0 && { failedPhases }
104683
104879
  };
104684
104880
  }
104881
+ function collectFailedPhases(ctx, phaseOutputs, opts) {
104882
+ return [
104883
+ ...Object.entries(phaseOutputs).filter(([name, output]) => {
104884
+ if (opts.verifierPassedSsot && name === opts.gateName)
104885
+ return false;
104886
+ return !phasePassed(name, output, ctx.storyId);
104887
+ }).map(([name]) => name),
104888
+ ...opts.failedPhaseEntries.map((name) => `${name} (never ran)`)
104889
+ ];
104890
+ }
104685
104891
  function logStoryOrchestratorVerdict(ctx, inputs) {
104686
104892
  const {
104687
104893
  success: success2,
@@ -104692,19 +104898,9 @@ function logStoryOrchestratorVerdict(ctx, inputs) {
104692
104898
  missingRequiredReviewPhases,
104693
104899
  upstreamShortCircuited,
104694
104900
  shortCircuitPhase,
104695
- failedPhaseEntries,
104696
- gateName,
104697
- verifierPassedSsot
104901
+ failedPhases
104698
104902
  } = inputs;
104699
104903
  const logger = getSafeLogger2();
104700
- const failedPhases = [
104701
- ...Object.entries(phaseOutputs).filter(([name, output]) => {
104702
- if (verifierPassedSsot && name === gateName)
104703
- return false;
104704
- return !phasePassed(name, output, ctx.storyId);
104705
- }).map(([name]) => name),
104706
- ...failedPhaseEntries.map((name) => `${name} (never ran)`)
104707
- ];
104708
104904
  const summary = {
104709
104905
  storyId: ctx.storyId,
104710
104906
  success: success2,
@@ -104775,13 +104971,13 @@ class ExecutionPlan {
104775
104971
  isThreeSession: this.isThreeSession
104776
104972
  });
104777
104973
  const resumeLoopEligible = !!this.state.rectification && !rectResult.terminalReviewRequired && (!rectResult.rectificationExhausted || !!rectResult.liteScopeIncomplete);
104778
- if (resumeLoopEligible) {
104779
- await runPostRectificationResume(plan, tracking, preRectGateFailureKeys);
104780
- }
104974
+ const resumeCompleted = resumeLoopEligible && await runPostRectificationResume(plan, tracking, preRectGateFailureKeys);
104781
104975
  if (this.state.rectification && rectResult.rectificationExhausted) {
104782
104976
  await runMechanicalOnlyResume(plan, tracking, rectResult);
104783
104977
  }
104784
104978
  await maybeRunNonBlockingFix(plan, tracking, rectResult, { gateName, preRectGateFailureKeys });
104979
+ if (resumeCompleted)
104980
+ settleProvisionalRectification(tracking.phaseOutputs, this.ctx.storyId);
104785
104981
  return buildStoryOrchestratorResult(plan, tracking, {
104786
104982
  gateName,
104787
104983
  preRectGateFailureKeys,
@@ -109528,7 +109724,7 @@ function routeTddFailure(failureCategory, isLiteMode, ctx, reviewReason, failure
109528
109724
  };
109529
109725
  const pauseFallback = {
109530
109726
  action: "pause",
109531
- reason: reviewReason || "Three-session TDD requires review"
109727
+ reason: reviewReason || TDD_REVIEW_PAUSE_REASON
109532
109728
  };
109533
109729
  if (failureCategory === undefined) {
109534
109730
  return pauseFallback;
@@ -109560,6 +109756,7 @@ function routeTddFailure(failureCategory, isLiteMode, ctx, reviewReason, failure
109560
109756
  return pauseFallback;
109561
109757
  }
109562
109758
  }
109759
+ var TDD_REVIEW_PAUSE_REASON = "Three-session TDD requires review";
109563
109760
  var init_execution_helpers = __esm(() => {
109564
109761
  init_errors4();
109565
109762
  });
@@ -121900,7 +122097,13 @@ Category: ${failureCategory ?? "unknown"}`,
121900
122097
  });
121901
122098
  return { action: "pause", reason: `Human review needed: ${failureCategory ?? "unknown"}` };
121902
122099
  }
121903
- return routeTddFailure(failureCategory, isLiteMode, ctx);
122100
+ return routeTddFailure(failureCategory, isLiteMode, ctx, uncategorisedPauseReason(frame));
122101
+ }
122102
+ function uncategorisedPauseReason(frame) {
122103
+ const failed3 = frame.planResult.failedPhases;
122104
+ if (frame.inspection.failureCategory !== undefined || !failed3?.length)
122105
+ return;
122106
+ return `${TDD_REVIEW_PAUSE_REASON} (failed phases: ${failed3.join(", ")})`;
121904
122107
  }
121905
122108
  async function failOnMergeConflict(frame) {
121906
122109
  const { ctx, inspection, deps } = frame;
@@ -121919,7 +122122,7 @@ async function failOnMergeConflict(frame) {
121919
122122
  }
121920
122123
  return null;
121921
122124
  }
121922
- function collectFailedPhases(planResult) {
122125
+ function collectFailedPhases2(planResult) {
121923
122126
  const failedPhases = {};
121924
122127
  for (const [name, output] of Object.entries(planResult.phaseOutputs)) {
121925
122128
  if (!output || typeof output !== "object")
@@ -121951,7 +122154,7 @@ async function escalateFailedSession(frame) {
121951
122154
  const { ctx, planResult, inspection, deps } = frame;
121952
122155
  const logger = getLogger2();
121953
122156
  const { agentResult, failureCategory } = inspection;
121954
- const failedPhases = collectFailedPhases(planResult);
122157
+ const failedPhases = collectFailedPhases2(planResult);
121955
122158
  const stderrTail = (agentResult.stderr ?? "").slice(-500);
121956
122159
  const outputTail = (agentResult.output ?? "").slice(-500);
121957
122160
  logger.error("execution", "Agent session failed", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nax",
3
- "version": "0.84.0",
3
+ "version": "0.85.1",
4
4
  "description": "AI Coding Agent Orchestrator — loops until done",
5
5
  "type": "module",
6
6
  "bin": {
@@ -86,8 +86,8 @@
86
86
  "dependencies": {
87
87
  "@agentclientprotocol/sdk": "~1.7.0",
88
88
  "@anthropic-ai/sandbox-runtime": "0.0.77",
89
- "@modelcontextprotocol/sdk": "^1.30.0",
90
- "@nathapp/nax-ai": "0.84.0",
89
+ "@modelcontextprotocol/sdk": "^1.32.1",
90
+ "@nathapp/nax-ai": "0.85.1",
91
91
  "chalk": "^5.6.2",
92
92
  "commander": "^13.1.0",
93
93
  "ink": "^6.7.0",