@wrongstack/core 0.267.0 → 0.269.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 (78) hide show
  1. package/dist/{agent-bridge-STJ3JwwK.d.ts → agent-bridge-PcHQl_UQ.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-CzPGP3jA.d.ts → agent-subagent-runner-SHJW7t8q.d.ts} +8 -8
  3. package/dist/{brain-Cdg77tVN.d.ts → brain-BYcK__Ym.d.ts} +1 -1
  4. package/dist/{compactor-iMZ84CXq.d.ts → compactor-C2RKEBtC.d.ts} +1 -1
  5. package/dist/{config-Du3pYYln.d.ts → config-C_ae2k86.d.ts} +79 -2
  6. package/dist/{context-dT5Ueund.d.ts → context-Dp87Bcaq.d.ts} +47 -1
  7. package/dist/coordination/index.d.ts +62 -160
  8. package/dist/coordination/index.js +566 -149
  9. package/dist/coordination/index.js.map +1 -1
  10. package/dist/defaults/index.d.ts +26 -25
  11. package/dist/defaults/index.js +366 -137
  12. package/dist/defaults/index.js.map +1 -1
  13. package/dist/execution/index.d.ts +72 -16
  14. package/dist/execution/index.js +267 -55
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/execution/prompt-enhancer.d.ts +1 -1
  17. package/dist/extension/index.d.ts +7 -6
  18. package/dist/global-mailbox-Bvrz1P3f.d.ts +664 -0
  19. package/dist/{goal-preamble-SulMTowG.d.ts → goal-preamble-CA_4yiGQ.d.ts} +9 -9
  20. package/dist/{goal-store-CABDwdFE.d.ts → goal-store-DhuJoUNG.d.ts} +1 -1
  21. package/dist/hq/index.d.ts +204 -0
  22. package/dist/hq/index.js +1931 -0
  23. package/dist/hq/index.js.map +1 -0
  24. package/dist/{index-DtCVWel4.d.ts → index-CZQ6Pwbs.d.ts} +8 -8
  25. package/dist/{index-Bms0m4oy.d.ts → index-W4VJCzHa.d.ts} +5 -5
  26. package/dist/{index-IEuxQd-E.d.ts → index-whDfTANu.d.ts} +2 -2
  27. package/dist/index.d.ts +46 -42
  28. package/dist/index.js +3472 -1651
  29. package/dist/index.js.map +1 -1
  30. package/dist/infrastructure/index.d.ts +6 -6
  31. package/dist/infrastructure/index.js +48 -21
  32. package/dist/infrastructure/index.js.map +1 -1
  33. package/dist/kernel/index.d.ts +10 -9
  34. package/dist/{pipeline-BfD2k1rT.d.ts → mailbox-types-Ct2hJq0P.d.ts} +1 -244
  35. package/dist/{mcp-servers-C2cBTxUR.d.ts → mcp-servers-DJdZiRcv.d.ts} +10 -4
  36. package/dist/models/index.d.ts +5 -5
  37. package/dist/models/index.js +4 -3
  38. package/dist/models/index.js.map +1 -1
  39. package/dist/{models-registry-BqGZNJQ-.d.ts → models-registry-C3a-2-Yd.d.ts} +1 -1
  40. package/dist/{multi-agent-coordinator-B8R43uPz.d.ts → multi-agent-coordinator-CJSpTe5O.d.ts} +1 -1
  41. package/dist/{null-fleet-bus-CnXa5oTH.d.ts → null-fleet-bus-QVshIsDx.d.ts} +6 -6
  42. package/dist/observability/index.d.ts +2 -2
  43. package/dist/{parallel-eternal-engine-DdNnw9BQ.d.ts → parallel-eternal-engine-D9y5Pkcc.d.ts} +9 -15
  44. package/dist/{path-resolver-COIMLCQL.d.ts → path-resolver-CnQ8SIfh.d.ts} +4 -3
  45. package/dist/{permission-B75JAi3-.d.ts → permission-CvYQNUqZ.d.ts} +1 -1
  46. package/dist/{permission-policy-DlR9eJAM.d.ts → permission-policy-D5Ss8j4B.d.ts} +2 -3
  47. package/dist/pipeline-l_zzFRh3.d.ts +245 -0
  48. package/dist/{plan-templates-DSIKCXZN.d.ts → plan-templates-NtPgyeJA.d.ts} +6 -5
  49. package/dist/{provider-model-resolve-BNRsNuJx.d.ts → provider-model-resolve-d5poT5y0.d.ts} +3 -3
  50. package/dist/{provider-runner-CX7iIvox.d.ts → provider-runner-gkctlQV_.d.ts} +3 -3
  51. package/dist/{retry-policy-BilV1ujH.d.ts → retry-policy-CtFhfwa8.d.ts} +1 -1
  52. package/dist/sdd/index.d.ts +9 -8
  53. package/dist/sdd/index.js +33 -3
  54. package/dist/sdd/index.js.map +1 -1
  55. package/dist/{secret-vault-gkvEZZfE.d.ts → secret-vault-BLsVmTIK.d.ts} +1 -1
  56. package/dist/security/index.d.ts +5 -5
  57. package/dist/security/index.js +39 -29
  58. package/dist/security/index.js.map +1 -1
  59. package/dist/{selector-Bc7eWtT3.d.ts → selector-CXl2_y9W.d.ts} +1 -1
  60. package/dist/{session-event-bridge-D-araDEz.d.ts → session-event-bridge-Ccud20CC.d.ts} +1 -1
  61. package/dist/{session-reader-D7Dapswh.d.ts → session-reader-ZeXQmsmE.d.ts} +1 -1
  62. package/dist/skills/index.js.map +1 -1
  63. package/dist/storage/index.d.ts +16 -12
  64. package/dist/storage/index.js +273 -100
  65. package/dist/storage/index.js.map +1 -1
  66. package/dist/tools/index.d.ts +2 -2
  67. package/dist/tools/index.js +166 -31
  68. package/dist/tools/index.js.map +1 -1
  69. package/dist/types/index.d.ts +22 -21
  70. package/dist/types/index.js +178 -70
  71. package/dist/types/index.js.map +1 -1
  72. package/dist/utils/index.d.ts +22 -3
  73. package/dist/utils/index.js +197 -25
  74. package/dist/utils/index.js.map +1 -1
  75. package/package.json +5 -1
  76. package/skills/chimera/SKILL.md +1 -1
  77. package/skills/typescript-strict/SKILL.md +3 -3
  78. package/skills/typescript-strict/SKILL.save.md +1 -1
@@ -1,8 +1,8 @@
1
- import { C as Context, w as ContextEvidenceState, k as ToolOutputMetadata, J as JSONSchema, M as Message, t as TodoItem } from '../context-dT5Ueund.js';
1
+ import { C as Context, z as ContextEvidenceState, k as ToolOutputMetadata, J as JSONSchema, M as Message, w as TodoItem } from '../context-Dp87Bcaq.js';
2
2
  export { H as HttpDispatcher, a as HttpsAgentAsDispatcher } from '../dispatcher-types.d-BBeXBQgS.js';
3
3
  export { toErrorMessage } from './error.js';
4
4
  export { expectDefined } from './expect-defined.js';
5
- import { v as CustomModelDefinition, a as ModelsDevPayload } from '../config-Du3pYYln.js';
5
+ import { v as CustomModelDefinition, a as ModelsDevPayload } from '../config-C_ae2k86.js';
6
6
  export { T as TaskItem, c as computeTaskItemProgress, f as formatTaskList, a as formatTaskProgress } from '../task-format-vGOIftmK.js';
7
7
  export { a as WstackPathOptions, W as WstackPaths, p as projectHash, b as projectSlug, r as resolveWstackPaths, w as wstackGlobalRoot } from '../wstack-paths-hOpNLmvf.js';
8
8
  export { a as TaskPriority, b as TaskStatus, T as TaskType } from '../task-graph-u1q9Jkyk.js';
@@ -87,6 +87,20 @@ declare const color: {
87
87
  };
88
88
  declare function stripAnsi(s: string): string;
89
89
 
90
+ type JsonObject = Record<string, unknown>;
91
+ type JsonPathSegment = string | number;
92
+ type JsonPath = readonly JsonPathSegment[];
93
+ declare function readJsonObjectFile(filePath: string): Promise<JsonObject>;
94
+ declare function jsonObjectFileExists(filePath: string): Promise<boolean>;
95
+ declare function writeJsonObjectFile(filePath: string, value: JsonObject): Promise<void>;
96
+ declare function updateJsonObjectFile(filePath: string, mutator: (config: JsonObject) => void | JsonObject | Promise<void | JsonObject>): Promise<JsonObject>;
97
+ declare function getJsonPath(root: unknown, path: JsonPath): unknown;
98
+ declare function setJsonPath(root: JsonObject, path: JsonPath, value: unknown): JsonObject;
99
+ declare function removeJsonPath(root: JsonObject, path: JsonPath): boolean;
100
+ declare function setJsonPathInFile(filePath: string, path: JsonPath, value: unknown): Promise<JsonObject>;
101
+ declare function removeJsonPathInFile(filePath: string, path: JsonPath): Promise<JsonObject>;
102
+ declare function isJsonObject(value: unknown): value is JsonObject;
103
+
90
104
  declare function createContextEvidenceState(): ContextEvidenceState;
91
105
  interface RecordToolOutputEvidenceInput {
92
106
  toolUseId: string;
@@ -529,6 +543,11 @@ declare function writeErr(s: string, stream?: NodeJS.WriteStream): boolean;
529
543
  */
530
544
  declare function formatTodosList(todos: TodoItem[]): string;
531
545
 
546
+ declare function escapeGlobSubject(value: string): string;
547
+ declare function normalizePathSubject(value: string): string;
548
+ declare function isPathSubjectKey(subjectKey: string): boolean;
549
+ declare function subjectForToolInput(toolName: string, input: unknown, subjectKey?: string): string | undefined;
550
+
532
551
  /**
533
552
  * Estimate tokens for a tool_use block input.
534
553
  * Caches the stringified result keyed by the stable string representation
@@ -688,4 +707,4 @@ interface CompactWireToolDefinition {
688
707
  declare function compactToolDefinitionForWire(tool: ToolWireDefinitionLike, opts?: CompactToolDefinitionForWireOptions): CompactWireToolDefinition;
689
708
  declare function compactSchemaDescriptions(schema: unknown, maxDescriptionChars?: number): Record<string, unknown>;
690
709
 
691
- export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompactToolDefinitionForWireOptions, type CompactWireToolDefinition, type CompileFail, type CompileResult, type DeepMergeOptions, FORBIDDEN_PROTO_KEYS, type FileLockOptions, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type OutputLineGuard, type RecordToolOutputEvidenceInput, type RequestTokenBreakdown, type SafeParseResult, type ToolOutputSerializerOptions, type ToolWireDefinitionLike, type UnifiedDiffOptions, type ValidationError, type ValidationResult, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, formatTodosList, getCalibrationState, getTermSize, isInteractive, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, safeParse, safeStringify, sanitizeJsonString, setOutputLineGuard, setRawMode, sleep, stripAnsi, toStyle, truncate, unifiedDiff, validateAgainstSchema, withFileLock, writeErr, writeOut };
710
+ export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompactToolDefinitionForWireOptions, type CompactWireToolDefinition, type CompileFail, type CompileResult, type DeepMergeOptions, FORBIDDEN_PROTO_KEYS, type FileLockOptions, type JsonObject, type JsonPath, type JsonPathSegment, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type OutputLineGuard, type RecordToolOutputEvidenceInput, type RequestTokenBreakdown, type SafeParseResult, type ToolOutputSerializerOptions, type ToolWireDefinitionLike, type UnifiedDiffOptions, type ValidationError, type ValidationResult, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, escapeGlobSubject, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, formatTodosList, getCalibrationState, getJsonPath, getTermSize, isInteractive, isJsonObject, isPathSubjectKey, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, jsonObjectFileExists, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizePathSubject, normalizeToLf, onResize, readJsonObjectFile, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, removeJsonPath, removeJsonPathInFile, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, safeParse, safeStringify, sanitizeJsonString, setJsonPath, setJsonPathInFile, setOutputLineGuard, setRawMode, sleep, stripAnsi, subjectForToolInput, toStyle, truncate, unifiedDiff, updateJsonObjectFile, validateAgainstSchema, withFileLock, writeErr, writeJsonObjectFile, writeOut };
@@ -256,7 +256,7 @@ function onResize(cb, stream = process.stdout) {
256
256
  };
257
257
  }
258
258
  function setRawMode(input, mode) {
259
- if (!input || input.isTTY !== true) return false;
259
+ if (input?.isTTY !== true) return false;
260
260
  if (typeof input.setRawMode !== "function") return false;
261
261
  input.setRawMode(mode);
262
262
  return true;
@@ -316,11 +316,110 @@ var color = {
316
316
  bgGreen: wrap("42", "49")
317
317
  };
318
318
  function stripAnsi(s) {
319
- return s.replace(
320
- // biome-ignore lint/suspicious/noControlCharactersInRegex: ANSI escape regex
321
- /\x1b\[[0-9;]*[A-Za-z]/g,
322
- ""
323
- );
319
+ return s.replace(/\x1b\[[0-9;]*[A-Za-z]/g, "");
320
+ }
321
+ async function readJsonObjectFile(filePath) {
322
+ try {
323
+ const parsed = JSON.parse(await fs.readFile(filePath, "utf8"));
324
+ return isJsonObject(parsed) ? parsed : {};
325
+ } catch {
326
+ return {};
327
+ }
328
+ }
329
+ async function jsonObjectFileExists(filePath) {
330
+ try {
331
+ await fs.access(filePath);
332
+ return true;
333
+ } catch {
334
+ return false;
335
+ }
336
+ }
337
+ async function writeJsonObjectFile(filePath, value) {
338
+ await atomicWrite(filePath, JSON.stringify(value, null, 2), { mode: 384 });
339
+ }
340
+ async function updateJsonObjectFile(filePath, mutator) {
341
+ const config = await readJsonObjectFile(filePath);
342
+ const maybeNext = await mutator(config);
343
+ const next = maybeNext && isJsonObject(maybeNext) ? maybeNext : config;
344
+ await writeJsonObjectFile(filePath, next);
345
+ return next;
346
+ }
347
+ function getJsonPath(root, path4) {
348
+ let current = root;
349
+ for (const segment of path4) {
350
+ if (typeof segment === "number") {
351
+ if (!Array.isArray(current)) return void 0;
352
+ current = current[segment];
353
+ continue;
354
+ }
355
+ if (!isJsonObject(current)) return void 0;
356
+ current = current[segment];
357
+ }
358
+ return current;
359
+ }
360
+ function setJsonPath(root, path4, value) {
361
+ if (path4.length === 0) {
362
+ if (!isJsonObject(value)) throw new Error("Root config value must be an object");
363
+ return value;
364
+ }
365
+ const parent = ensureJsonParent(root, path4);
366
+ const leaf = lastPathSegment(path4);
367
+ if (typeof leaf === "number") {
368
+ if (!Array.isArray(parent)) throw new Error(`Cannot set numeric segment ${leaf} on non-array parent`);
369
+ parent[leaf] = value;
370
+ } else {
371
+ if (!isJsonObject(parent)) throw new Error(`Cannot set property ${leaf} on non-object parent`);
372
+ parent[leaf] = value;
373
+ }
374
+ return root;
375
+ }
376
+ function removeJsonPath(root, path4) {
377
+ if (path4.length === 0) return false;
378
+ const parent = getJsonPath(root, path4.slice(0, -1));
379
+ const leaf = lastPathSegment(path4);
380
+ if (typeof leaf === "number") {
381
+ if (!Array.isArray(parent) || leaf < 0 || leaf >= parent.length) return false;
382
+ parent.splice(leaf, 1);
383
+ return true;
384
+ }
385
+ if (!isJsonObject(parent) || !(leaf in parent)) return false;
386
+ delete parent[leaf];
387
+ return true;
388
+ }
389
+ async function setJsonPathInFile(filePath, path4, value) {
390
+ return updateJsonObjectFile(filePath, (config) => setJsonPath(config, path4, value));
391
+ }
392
+ async function removeJsonPathInFile(filePath, path4) {
393
+ return updateJsonObjectFile(filePath, (config) => {
394
+ removeJsonPath(config, path4);
395
+ });
396
+ }
397
+ function isJsonObject(value) {
398
+ return typeof value === "object" && value !== null && !Array.isArray(value);
399
+ }
400
+ function lastPathSegment(path4) {
401
+ const segment = path4[path4.length - 1];
402
+ if (segment === void 0) throw new Error("Invalid empty JSON path");
403
+ return segment;
404
+ }
405
+ function ensureJsonParent(root, path4) {
406
+ let current = root;
407
+ for (let i = 0; i < path4.length - 1; i += 1) {
408
+ const segment = path4[i];
409
+ const nextSegment = path4[i + 1];
410
+ if (segment === void 0) throw new Error("Invalid empty JSON path segment");
411
+ const nextContainer = typeof nextSegment === "number" ? [] : {};
412
+ if (typeof segment === "number") {
413
+ if (!Array.isArray(current)) throw new Error(`Cannot traverse numeric segment ${segment} on non-array parent`);
414
+ if (!isJsonObject(current[segment]) && !Array.isArray(current[segment])) current[segment] = nextContainer;
415
+ current = current[segment];
416
+ } else {
417
+ if (!isJsonObject(current)) throw new Error(`Cannot traverse property ${segment} on non-object parent`);
418
+ if (!isJsonObject(current[segment]) && !Array.isArray(current[segment])) current[segment] = nextContainer;
419
+ current = current[segment];
420
+ }
421
+ }
422
+ return current;
324
423
  }
325
424
  var MAX_TOOL_CALLS = 80;
326
425
  var MAX_FACTS = 40;
@@ -1114,7 +1213,7 @@ function expandIPv6(addr) {
1114
1213
  };
1115
1214
  if (parts.length === 1) {
1116
1215
  const groups = parseGroups(parts[0] ?? "");
1117
- if (!groups || groups.length !== 8) return null;
1216
+ if (groups?.length !== 8) return null;
1118
1217
  return groups;
1119
1218
  }
1120
1219
  const head = parseGroups(parts[0] ?? "");
@@ -1483,7 +1582,7 @@ function hasToolResult(msg) {
1483
1582
  }
1484
1583
  function toolUseIds(msg) {
1485
1584
  const ids = /* @__PURE__ */ new Set();
1486
- if (!msg || msg.role !== "assistant") return ids;
1585
+ if (msg?.role !== "assistant") return ids;
1487
1586
  for (const block of contentBlocks(msg)) {
1488
1587
  if (block.type === "tool_use") ids.add(block.id);
1489
1588
  }
@@ -1491,7 +1590,7 @@ function toolUseIds(msg) {
1491
1590
  }
1492
1591
  function toolResultIds(msg) {
1493
1592
  const ids = /* @__PURE__ */ new Set();
1494
- if (!msg || msg.role !== "user") return ids;
1593
+ if (msg?.role !== "user") return ids;
1495
1594
  for (const block of contentBlocks(msg)) {
1496
1595
  if (block.type === "tool_result") ids.add(block.tool_use_id);
1497
1596
  }
@@ -1818,6 +1917,41 @@ function formatTodosList(todos) {
1818
1917
  return lines.join("\n");
1819
1918
  }
1820
1919
 
1920
+ // src/utils/tool-subject.ts
1921
+ var GLOB_METACHARACTERS = /[*?[\]]/g;
1922
+ function escapeGlobSubject(value) {
1923
+ return value.replace(GLOB_METACHARACTERS, (char) => `\\${char}`);
1924
+ }
1925
+ function normalizePathSubject(value) {
1926
+ return escapeGlobSubject(value.replace(/\\/g, "/"));
1927
+ }
1928
+ function isPathSubjectKey(subjectKey) {
1929
+ return subjectKey === "path" || subjectKey === "file" || subjectKey === "files";
1930
+ }
1931
+ function subjectForToolInput(toolName, input, subjectKey) {
1932
+ if (!input || typeof input !== "object") return void 0;
1933
+ const obj = input;
1934
+ if (subjectKey) {
1935
+ const value = obj[subjectKey];
1936
+ if (typeof value === "string") {
1937
+ return isPathSubjectKey(subjectKey) ? normalizePathSubject(value) : escapeGlobSubject(value);
1938
+ }
1939
+ }
1940
+ if (toolName === "bash" && typeof obj.command === "string") {
1941
+ return escapeGlobSubject(obj.command);
1942
+ }
1943
+ if (typeof obj.path === "string") {
1944
+ return normalizePathSubject(obj.path);
1945
+ }
1946
+ if (typeof obj.url === "string") {
1947
+ return escapeGlobSubject(obj.url);
1948
+ }
1949
+ if (typeof obj.name === "string") {
1950
+ return escapeGlobSubject(obj.name);
1951
+ }
1952
+ return void 0;
1953
+ }
1954
+
1821
1955
  // src/utils/tool-wire-compact.ts
1822
1956
  var TOOL_DESCRIPTION_MAX_CHARS = 640;
1823
1957
  var SCHEMA_DESCRIPTION_MAX_CHARS = 180;
@@ -1902,8 +2036,19 @@ function calState(key) {
1902
2036
  return state;
1903
2037
  }
1904
2038
  var MIN_SAMPLES_FOR_CALIBRATION = 3;
2039
+ var MODEL_FAMILY_RATIO = {
2040
+ // Anthropic: ~3.8-4.0 chars/token depending on model
2041
+ claude: 3.8,
2042
+ // OpenAI: ~4.0 chars/token
2043
+ "gpt-4": 4,
2044
+ "gpt-3.5": 4,
2045
+ // Google: ~3.5 chars/token
2046
+ gemini: 3.5,
2047
+ // DeepSeek: ~3.5 chars/token
2048
+ deepseek: 3.5
2049
+ };
1905
2050
  var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
1906
- var ESTIMATE_CACHE_MAX_SIZE = 1e4;
2051
+ var ESTIMATE_CACHE_MAX_SIZE = 5e4;
1907
2052
  function getCachedEstimate(key, compute) {
1908
2053
  const existing = ESTIMATE_CACHE.get(key);
1909
2054
  if (existing !== void 0) return existing;
@@ -2045,8 +2190,24 @@ function estimateRequestTokensCalibrated(messages, systemPrompt, tools, calibrat
2045
2190
  total: Math.round(result.total * safeRatio)
2046
2191
  };
2047
2192
  }
2193
+ const fallbackRatio = getModelFamilyRatio(calibrationKey);
2194
+ if (fallbackRatio !== null) {
2195
+ return {
2196
+ messages: Math.round(result.messages * fallbackRatio),
2197
+ systemPrompt: Math.round(result.systemPrompt * fallbackRatio),
2198
+ tools: Math.round(result.tools * fallbackRatio),
2199
+ total: Math.round(result.total * fallbackRatio)
2200
+ };
2201
+ }
2048
2202
  return result;
2049
2203
  }
2204
+ function getModelFamilyRatio(calibrationKey) {
2205
+ const lower = calibrationKey.toLowerCase();
2206
+ for (const [family, ratio] of Object.entries(MODEL_FAMILY_RATIO)) {
2207
+ if (lower.includes(family)) return ratio / 3.5;
2208
+ }
2209
+ return null;
2210
+ }
2050
2211
  function resetCalibration(calibrationKey) {
2051
2212
  if (calibrationKey === void 0) {
2052
2213
  _cals.clear();
@@ -2064,6 +2225,7 @@ var GREP_MATCHES_PER_FILE = 3;
2064
2225
  var DIFF_INLINE_LINE_LIMIT = 260;
2065
2226
  var DIFF_HUNK_LIMIT = 8;
2066
2227
  var DIFF_HUNK_CONTEXT = 14;
2228
+ var GREP_LINE_RE = /^(.+?):(\d+):(.*)$/;
2067
2229
  function createToolOutputSerializer(opts = {}) {
2068
2230
  const capBytes = opts.perIterationOutputCapBytes ?? 1e5;
2069
2231
  function serialize(value, context = {}) {
@@ -2449,7 +2611,7 @@ ${renderStringList(passthrough, "", 50)}`);
2449
2611
  return sections.join("\n");
2450
2612
  }
2451
2613
  function parseGrepContentLine(line) {
2452
- const match = /^(.+?):(\d+):(.*)$/.exec(line);
2614
+ const match = GREP_LINE_RE.exec(line);
2453
2615
  if (!match?.[1] || !match[2]) return void 0;
2454
2616
  return { file: match[1], line: match[2], text: match[3] ?? "" };
2455
2617
  }
@@ -2467,22 +2629,20 @@ function compactDiff(diff) {
2467
2629
  const hunks = lines.filter((line) => line.startsWith("@@")).length;
2468
2630
  const added = lines.filter((line) => line.startsWith("+") && !line.startsWith("+++")).length;
2469
2631
  const removed = lines.filter((line) => line.startsWith("-") && !line.startsWith("---")).length;
2470
- const selected = /* @__PURE__ */ new Set();
2632
+ const intervals = [];
2471
2633
  let hunkCount = 0;
2472
2634
  for (let i = 0; i < lines.length; i++) {
2473
2635
  const line = lines[i] ?? "";
2474
2636
  if (line.startsWith("diff --git") || line.startsWith("--- ") || line.startsWith("+++ ")) {
2475
- selected.add(i);
2637
+ intervals.push([i, i]);
2476
2638
  continue;
2477
2639
  }
2478
2640
  if (!line.startsWith("@@")) continue;
2479
2641
  if (hunkCount >= DIFF_HUNK_LIMIT) continue;
2480
2642
  hunkCount++;
2481
- for (let j = i; j <= Math.min(lines.length - 1, i + DIFF_HUNK_CONTEXT); j++) {
2482
- selected.add(j);
2483
- }
2643
+ intervals.push([i, Math.min(lines.length - 1, i + DIFF_HUNK_CONTEXT)]);
2484
2644
  }
2485
- if (selected.size === 0) {
2645
+ if (intervals.length === 0) {
2486
2646
  return joinSections([
2487
2647
  renderHeader("diff_summary", {
2488
2648
  files: fileCount,
@@ -2495,17 +2655,29 @@ function compactDiff(diff) {
2495
2655
  `[serializer omitted ${Math.max(0, lines.length - DIFF_INLINE_LINE_LIMIT)} diff line(s)]`
2496
2656
  ]);
2497
2657
  }
2658
+ const merged = [intervals[0]];
2659
+ for (let i = 1; i < intervals.length; i++) {
2660
+ const last = merged[merged.length - 1];
2661
+ const current = intervals[i];
2662
+ if (current[0] <= last[1] + 1) {
2663
+ last[1] = Math.max(last[1], current[1]);
2664
+ } else {
2665
+ merged.push(current);
2666
+ }
2667
+ }
2498
2668
  const excerpt = [];
2499
- let previous = -1;
2500
- for (const index of [...selected].sort((a, b) => a - b)) {
2501
- if (index > previous + 1) {
2502
- const omitted = previous === -1 ? index : index - previous - 1;
2669
+ let prevLine = -1;
2670
+ for (const [start, end] of merged) {
2671
+ if (start > prevLine + 1) {
2672
+ const omitted = prevLine === -1 ? start : start - prevLine - 1;
2503
2673
  excerpt.push(`[serializer omitted ${omitted} diff line(s)]`);
2504
2674
  }
2505
- excerpt.push(lines[index] ?? "");
2506
- previous = index;
2675
+ for (let j = start; j <= end; j++) {
2676
+ excerpt.push(lines[j] ?? "");
2677
+ }
2678
+ prevLine = end;
2507
2679
  }
2508
- const trailing = lines.length - previous - 1;
2680
+ const trailing = lines.length - prevLine - 1;
2509
2681
  if (trailing > 0) excerpt.push(`[serializer omitted ${trailing} trailing diff line(s)]`);
2510
2682
  return joinSections([
2511
2683
  renderHeader("diff_summary", {
@@ -2753,6 +2925,6 @@ function resolveWstackPaths(opts) {
2753
2925
  };
2754
2926
  }
2755
2927
 
2756
- export { FORBIDDEN_PROTO_KEYS, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, computeTaskItemProgress, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, expectDefined, formatTaskList, formatTaskProgress, formatTodosList, getCalibrationState, getTermSize, isInteractive, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizeToLf, onResize, projectHash, projectSlug, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, setOutputLineGuard, setRawMode, sleep, stripAnsi, toErrorMessage, toStyle, truncate, unifiedDiff, validateAgainstSchema, withFileLock, writeErr, writeOut, wstackGlobalRoot };
2928
+ export { FORBIDDEN_PROTO_KEYS, assertNever, assertNotPrivateHost, atomicWrite, buildChildEnv, buildContextEvidenceDigest, color, compactSchemaDescriptions, compactToolDefinitionForWire, compileGlob, compileUserRegex, completePartialObject, computeMessageTokens, computeTaskItemProgress, createContextEvidenceState, createToolOutputSerializer, deepMerge, detectNewlineStyle, ensureDir, escapeGlobSubject, estimateMessageTokens, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, expandIPv6, expectDefined, formatTaskList, formatTaskProgress, formatTodosList, getCalibrationState, getJsonPath, getTermSize, isInteractive, isJsonObject, isPathSubjectKey, isPrimitiveArray, isPrivateIPv4, isPrivateIPv6, isStdinTTY, isStdoutTTY, jsonObjectFileExists, markAssistantReferencedEvidence, matchAny, matchGlob, mergeCustomModelDefs, mergeModelsPayload, normalizePathSubject, normalizeToLf, onResize, projectHash, projectSlug, readJsonObjectFile, recordActualUsage, recordToolOutputEvidence, recordUserIntentEvidence, removeJsonPath, removeJsonPathInFile, repairToolUseAdjacency, repeatedReadPressure, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, setJsonPath, setJsonPathInFile, setOutputLineGuard, setRawMode, sleep, stripAnsi, subjectForToolInput, toErrorMessage, toStyle, truncate, unifiedDiff, updateJsonObjectFile, validateAgainstSchema, withFileLock, writeErr, writeJsonObjectFile, writeOut, wstackGlobalRoot };
2757
2929
  //# sourceMappingURL=index.js.map
2758
2930
  //# sourceMappingURL=index.js.map