@cortexkit/opencode-magic-context 0.49.63 → 0.49.65

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 (83) hide show
  1. package/dist/auto-search-worker.js +1 -1
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/{context-aaht09yh.js → context-3mfsdp1v.js} +14 -14
  4. package/dist/features/magic-context/overflow-detection.d.ts +0 -20
  5. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  6. package/dist/features/magic-context/storage-tags.d.ts +7 -0
  7. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  8. package/dist/hooks/magic-context/compartment-prompt.d.ts +8 -1
  9. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  10. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  11. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  12. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
  13. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  14. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +10 -3
  16. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/inject-compartments.d.ts +11 -0
  19. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/reference-retrieval.d.ts +3 -2
  21. package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts +1 -0
  25. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  26. package/dist/{index-tq20edcs.js → index-0ab398z2.js} +2 -2
  27. package/dist/{index-d0feqcs5.js → index-6kgsfb81.js} +1 -1
  28. package/dist/{index-3hk445am.js → index-71h616be.js} +1 -1
  29. package/dist/{index-ev2rrjfc.js → index-7dj3s7qq.js} +1 -1
  30. package/dist/{index-s2qsd3w9.js → index-8596jbnw.js} +6 -5
  31. package/dist/{index-3yyfftqq.js → index-c0k54yhd.js} +3 -3
  32. package/dist/{index-ywxvdwmj.js → index-ezr8mr1c.js} +1 -1
  33. package/dist/{index-s2jdky2x.js → index-g59gpt1j.js} +3 -3
  34. package/dist/{index-kv4ntrr6.js → index-gwb2wpz7.js} +2 -2
  35. package/dist/{index-8sc7vqt7.js → index-kvfrse61.js} +75 -43
  36. package/dist/{index-0cz8bsyx.js → index-qn27gh4e.js} +1 -1
  37. package/dist/{index-qdver0af.js → index-san8daqa.js} +6 -6
  38. package/dist/{index-bqd5dmm4.js → index-stqmv1mt.js} +65 -37
  39. package/dist/{index-3wq9btxt.js → index-wz0t5e5s.js} +3 -3
  40. package/dist/{index-4yjn3er4.js → index-x2hwwzk1.js} +65 -11
  41. package/dist/index.js +19 -18
  42. package/dist/{message-index-bounded-f6yz4xq8.js → message-index-bounded-zs7ah2te.js} +3 -3
  43. package/dist/migration-worker.js +1 -1
  44. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  45. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  46. package/dist/raw-ordinal-warmup-worker.js +4 -4
  47. package/dist/{read-session-chunk-8b1g06nz.js → read-session-chunk-jf2f8jz8.js} +2 -2
  48. package/dist/{recomp-orchestrator-7s8nyzhy.js → recomp-orchestrator-nyj8ca0y.js} +7 -7
  49. package/dist/{render-nrfbtkkw.js → render-n46wpv2n.js} +6 -6
  50. package/dist/{search-archive-1ppdjfm9.js → search-archive-9k6vsp44.js} +4 -4
  51. package/dist/{search-xha0r30f.js → search-s386bwwh.js} +5 -5
  52. package/dist/shared/tag-transcript.d.ts.map +1 -1
  53. package/dist/{storage-tags-spet01yb.js → storage-tags-2r952wqy.js} +1 -1
  54. package/dist/{transform-postprocess-phase-fxp1atm1.js → transform-postprocess-phase-8yjcca9t.js} +8 -8
  55. package/dist/v2/auto-search-worker.js +1 -1
  56. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  57. package/dist/v2/{context-hk9x7ngz.js → context-34sr5ner.js} +62 -34
  58. package/dist/v2/{message-index-bounded-0w8eh8fc.js → message-index-bounded-axbs1s97.js} +3 -3
  59. package/dist/v2/migration-worker.js +1 -1
  60. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  61. package/dist/v2/{read-session-chunk-dxs1tgt9.js → read-session-chunk-41cm522x.js} +2 -2
  62. package/dist/v2/{recomp-orchestrator-zc1wdv9q.js → recomp-orchestrator-r4gqhhaw.js} +6 -6
  63. package/dist/v2/{render-9knrdrjs.js → render-7v7yx9xb.js} +6 -6
  64. package/dist/v2/{search-archive-2jmyvj69.js → search-archive-1yc8bh6y.js} +4 -4
  65. package/dist/v2/{search-a2a0qs3t.js → search-mabwkzw2.js} +4 -4
  66. package/dist/v2/{server-svx20ra2.js → server-8w9b5exq.js} +1 -1
  67. package/dist/v2/{server-8hcxmt1w.js → server-9rwm2z2h.js} +65 -11
  68. package/dist/v2/{server-9m5r04ws.js → server-anh8gf0w.js} +2 -2
  69. package/dist/v2/{server-ja6swvmb.js → server-bh9yzxpz.js} +2 -2
  70. package/dist/v2/{server-9ab9jnpq.js → server-bnka2vf2.js} +3 -3
  71. package/dist/v2/{server-8ycacd59.js → server-cdddk5d1.js} +1 -1
  72. package/dist/v2/{server-88n85n60.js → server-hb5zm7yh.js} +75 -43
  73. package/dist/v2/{server-tzh55x6d.js → server-hcgqsdrh.js} +1 -1
  74. package/dist/v2/{server-4r86tcs2.js → server-k97r77x3.js} +2 -2
  75. package/dist/v2/{server-t8tmrtcg.js → server-yxw43z2w.js} +1 -1
  76. package/dist/v2/server.js +2 -2
  77. package/dist/v2/{storage-tags-50wsqg3t.js → storage-tags-9zs0gc7w.js} +1 -1
  78. package/dist/v2/{v2-archive-reader-ycjh6a2d.js → v2-archive-reader-pgk140pb.js} +1 -1
  79. package/dist/v2/{wrapup-orchestrator-fyyb28jf.js → wrapup-orchestrator-p0ysz3s9.js} +7 -6
  80. package/dist/{v2-archive-reader-wec0a8fx.js → v2-archive-reader-cv6veqnz.js} +1 -1
  81. package/dist/{wrapup-orchestrator-560v99mk.js → wrapup-orchestrator-dxda1svq.js} +8 -8
  82. package/package.json +1 -1
  83. package/src/shared/tag-transcript.ts +105 -1
@@ -3,12 +3,12 @@ import {
3
3
  } from "./index-5vsk2cpp.js";
4
4
  import {
5
5
  getTagById2
6
- } from "./index-8sc7vqt7.js";
6
+ } from "./index-kvfrse61.js";
7
7
  import {
8
8
  expandToolPart,
9
9
  visitRawSessionMessages2,
10
10
  readRawSessionMessageById2
11
- } from "./index-d0feqcs5.js";
11
+ } from "./index-6kgsfb81.js";
12
12
 
13
13
  // src/tools/ctx-expand/render.ts
14
14
  import { createHash } from "node:crypto";
@@ -9,7 +9,7 @@ import {
9
9
  estimateMessageTokens,
10
10
  getCandidateToolOwners2,
11
11
  pickNearestPriorOwner2
12
- } from "./index-8sc7vqt7.js";
12
+ } from "./index-kvfrse61.js";
13
13
  import {
14
14
  OMO_INTERNAL_INITIATOR_MARKER,
15
15
  isSystemDirective,
@@ -28,7 +28,7 @@ import {
28
28
  clearIndexedMessages,
29
29
  indexSingleMessage,
30
30
  indexMessagesAfterOrdinal
31
- } from "./index-ev2rrjfc.js";
31
+ } from "./index-7dj3s7qq.js";
32
32
 
33
33
  // src/features/magic-context/message-index-async.ts
34
34
  var indexCancellations = new Map;
@@ -9,7 +9,7 @@ import {
9
9
  } from "./index-5vsk2cpp.js";
10
10
  import {
11
11
  cleanUserText2
12
- } from "./index-d0feqcs5.js";
12
+ } from "./index-6kgsfb81.js";
13
13
  import {
14
14
  recordMessageFtsRowid2,
15
15
  recordIndexedMessageTime2,
@@ -8,7 +8,7 @@ import {
8
8
  releaseCompartmentLeaseBestEffort,
9
9
  getCompartments,
10
10
  getLastCompartmentEndMessage
11
- } from "./index-ywxvdwmj.js";
11
+ } from "./index-ezr8mr1c.js";
12
12
  import {
13
13
  inRootAsyncContext2
14
14
  } from "./index-gzy5w8ya.js";
@@ -19,10 +19,10 @@ import {
19
19
  releaseWrapupInProgress,
20
20
  getHistorianFailureState,
21
21
  clearEmergencyRecovery
22
- } from "./index-8sc7vqt7.js";
22
+ } from "./index-kvfrse61.js";
23
23
  import {
24
24
  prepareRawSessionOrdinals2
25
- } from "./index-d0feqcs5.js";
25
+ } from "./index-6kgsfb81.js";
26
26
  import {
27
27
  pushNotification2
28
28
  } from "./index-x8a7jmkh.js";
@@ -34,14 +34,14 @@ import {
34
34
  getActiveCompartmentRun,
35
35
  markActiveCompartmentRunPublished,
36
36
  registerActiveCompartmentRun
37
- } from "./index-4yjn3er4.js";
37
+ } from "./index-x2hwwzk1.js";
38
38
  import {
39
39
  sendStatusNotification2
40
40
  } from "./index-1sq1krqw.js";
41
41
  import {
42
42
  setRecompStarting2,
43
43
  setRecompTerminal2
44
- } from "./index-3wq9btxt.js";
44
+ } from "./index-wz0t5e5s.js";
45
45
 
46
46
  // src/hooks/magic-context/wrapup-orchestrator.ts
47
47
  import * as crypto from "node:crypto";
@@ -193,6 +193,7 @@ async function runOneWrapupIteration(args) {
193
193
  historianTwoPass: ctx.historianTwoPass,
194
194
  historianExpandTools: ctx.historianExpandTools,
195
195
  memoryEnabled: ctx.memoryEnabled,
196
+ memoryInjectionBudgetTokens: ctx.memoryInjectionBudgetTokens,
196
197
  autoPromote: ctx.autoPromote,
197
198
  experimentalUserMemories: ctx.userMemoriesEnabled,
198
199
  userObservationsRequested: ctx.userObservationsRequested,
@@ -67,21 +67,21 @@ import {
67
67
  import {
68
68
  matchedSearchSnippet,
69
69
  getIndexedMessageCorpusSize
70
- } from "./index-ev2rrjfc.js";
70
+ } from "./index-7dj3s7qq.js";
71
71
  import {
72
72
  getMessageIndexEpoch,
73
73
  isMessageIndexSearchable,
74
74
  withMemoryHintContent,
75
75
  autoSearchRelevance,
76
76
  recordAutoSearchLane
77
- } from "./index-3hk445am.js";
77
+ } from "./index-71h616be.js";
78
78
  import {
79
79
  MESSAGE_FTS_SESSION_FILTER_SQL,
80
80
  withMessageFtsSessionFilter
81
81
  } from "./index-52x68mj4.js";
82
82
  import {
83
83
  isRecord
84
- } from "./index-8sc7vqt7.js";
84
+ } from "./index-kvfrse61.js";
85
85
  import {
86
86
  resolveWorkspaceShareCategories,
87
87
  resolveWorkspaceIdentitySet,
@@ -67,7 +67,7 @@ import {
67
67
  getPendingPiCompactionMarkerState,
68
68
  logPiCompactionMarkerClear,
69
69
  isPrefixBoundThinkingModel
70
- } from "./index-8sc7vqt7.js";
70
+ } from "./index-kvfrse61.js";
71
71
  import {
72
72
  withReadOnlySessionDb
73
73
  } from "./index-x40zr813.js";
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
139
139
  import("./sqlite-zdgm52sv.js"),
140
140
  import("./store-reader-3eh1s1m8.js"),
141
141
  import("./store-h20ny8b8.js"),
142
- import("./read-session-chunk-8b1g06nz.js"),
143
- import("./render-nrfbtkkw.js"),
144
- import("./search-archive-1ppdjfm9.js"),
142
+ import("./read-session-chunk-jf2f8jz8.js"),
143
+ import("./render-n46wpv2n.js"),
144
+ import("./search-archive-9k6vsp44.js"),
145
145
  import("./expand-attachments-h33jbgyz.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -19,10 +19,10 @@ import {
19
19
  rawMessageWorkerSource2,
20
20
  rawMessageOffThreadRangeReader2,
21
21
  readRawSessionMessageIdOrdinalsForRange2
22
- } from "./index-d0feqcs5.js";
22
+ } from "./index-6kgsfb81.js";
23
23
  import {
24
24
  readV2ArchiveOffThread2
25
- } from "./index-s2jdky2x.js";
25
+ } from "./index-g59gpt1j.js";
26
26
 
27
27
  // src/tools/ctx-expand/search-archive.ts
28
28
  var archiveReadsOnThisThread = 0;
@@ -5046,6 +5046,11 @@ function markDropLeavesReasoning(db, sessionId) {
5046
5046
  }
5047
5047
 
5048
5048
  // src/features/magic-context/overflow-detection.ts
5049
+ var TOKEN_COUNT = String.raw`(?<![\d+_-])(?:\d+(?:[,_ .\u202f]+\d+)*(?=\s*tokens?\b)|\d+(?:[,_ \u202f]+\d+)*)(?!\w|[,_\s.]+\d)`;
5050
+ var ESTIMATED_REQUEST = String.raw`\bthis request has an estimated\b`;
5051
+ function overflowPattern(strings, ...fragments) {
5052
+ return new RegExp(String.raw(strings, ...fragments), "i");
5053
+ }
5049
5054
  var OVERFLOW_PATTERNS = [
5050
5055
  /prompt is too long/i,
5051
5056
  /input is too long for requested model/i,
@@ -5053,7 +5058,7 @@ var OVERFLOW_PATTERNS = [
5053
5058
  /input token count.*exceeds the maximum/i,
5054
5059
  /maximum prompt length is \d+/i,
5055
5060
  /reduce the length of the messages/i,
5056
- /maximum context length is \d+ tokens/i,
5061
+ overflowPattern`maximum context length is ${TOKEN_COUNT} tokens?\b`,
5057
5062
  /maximum model length is \d+/i,
5058
5063
  /exceeds the limit of \d+/i,
5059
5064
  /exceeds the available context size/i,
@@ -5062,48 +5067,84 @@ var OVERFLOW_PATTERNS = [
5062
5067
  /exceeded model token limit/i,
5063
5068
  /context[_ ]length[_ ]exceeded/i,
5064
5069
  /request entity too large/i,
5065
- /context length is only \d+ tokens/i,
5070
+ overflowPattern`context length is only ${TOKEN_COUNT} tokens?\b`,
5066
5071
  /input length.*exceeds.*context length/i,
5067
5072
  /\bContextWindowExceededError\b/i,
5068
- /\bthe input \(\d+ tokens?\) is longer than the model's context length \(\d+ tokens?\)/i,
5073
+ overflowPattern`\bthe input \(${TOKEN_COUNT} tokens?\) is longer than the model's context length \(${TOKEN_COUNT} tokens?\)`,
5069
5074
  /prompt too long; exceeded (?:max )?context length/i,
5070
- /too large for model with \d+ maximum context length/i,
5075
+ overflowPattern`too large for model with ${TOKEN_COUNT} maximum context length`,
5071
5076
  /model_context_window_exceeded/i,
5072
5077
  /context size has been exceeded/i,
5073
5078
  /prepared prompt exceeds engine max_context/i,
5074
5079
  /prompt exceeds (?:the )?.{0,32}\bmax_context\b/i
5075
5080
  ];
5076
5081
  var LIMIT_EXTRACTION_PATTERNS = [
5077
- { pattern: /maximum prompt length is (\d+)/i, provenance: "prompt_only" },
5078
5082
  {
5079
- pattern: /maximum context length is (\d+) tokens?/i,
5083
+ pattern: overflowPattern`maximum prompt length is (${TOKEN_COUNT})`,
5084
+ provenance: "prompt_only"
5085
+ },
5086
+ {
5087
+ pattern: overflowPattern`maximum context length is (${TOKEN_COUNT}) tokens?\b`,
5080
5088
  provenance: "combined"
5081
5089
  },
5082
- { pattern: /maximum model length is (\d+)/i, provenance: "combined" },
5083
- { pattern: /context length is only (\d+) tokens?/i, provenance: "combined" },
5084
- { pattern: /exceeds the limit of (\d+)/i, provenance: "unknown" },
5090
+ { pattern: overflowPattern`maximum model length is (${TOKEN_COUNT})`, provenance: "combined" },
5085
5091
  {
5086
- pattern: /too large for model with (\d+) maximum context length/i,
5092
+ pattern: overflowPattern`context length is only (${TOKEN_COUNT}) tokens?\b`,
5087
5093
  provenance: "combined"
5088
5094
  },
5089
- { pattern: /context size[^0-9]{0,40}(\d{4,})\s*tokens?/i, provenance: "combined" },
5090
- { pattern: /exceeds? the context length of (\d+)/i, provenance: "combined" },
5095
+ { pattern: overflowPattern`exceeds the limit of (${TOKEN_COUNT})`, provenance: "unknown" },
5091
5096
  {
5092
- pattern: /\bthe input \(\d+ tokens?\) is longer than the model's context length \((\d+) tokens?\)/i,
5097
+ pattern: overflowPattern`too large for model with (${TOKEN_COUNT}) maximum context length`,
5093
5098
  provenance: "combined"
5094
5099
  },
5095
5100
  {
5096
- pattern: />\s*(\d+)\s*(?:tokens?\s*)?(?:maximum|max|limit)\b/i,
5101
+ pattern: overflowPattern`context size[^0-9]{0,40}(${TOKEN_COUNT})\s*tokens?\b`,
5102
+ provenance: "combined"
5103
+ },
5104
+ {
5105
+ pattern: overflowPattern`exceeds? the context length of (${TOKEN_COUNT})`,
5106
+ provenance: "combined"
5107
+ },
5108
+ {
5109
+ pattern: overflowPattern`\bthe input \(${TOKEN_COUNT} tokens?\) is longer than the model's context length \((${TOKEN_COUNT}) tokens?\)`,
5110
+ provenance: "combined"
5111
+ },
5112
+ {
5113
+ pattern: overflowPattern`>\s*(${TOKEN_COUNT})\s*(?:tokens?\s*)?(?:maximum|max|limit)\b`,
5097
5114
  provenance: "prompt_only"
5098
5115
  },
5099
5116
  {
5100
- pattern: /maximum number of tokens allowed\s*\(?\s*(\d+)/i,
5117
+ pattern: overflowPattern`maximum number of tokens allowed\s*\(?\s*(${TOKEN_COUNT})`,
5101
5118
  provenance: "prompt_only"
5102
5119
  },
5103
- { pattern: /prepared prompt exceeds engine max_context\s+(\d+)/i, provenance: "unknown" },
5104
- { pattern: /prompt exceeds (?:the )?.{0,32}\bmax_context\s+(\d+)/i, provenance: "unknown" },
5105
- { pattern: /max(?:imum)?.*context.*?(\d+)/i, provenance: "unknown" }
5120
+ {
5121
+ pattern: overflowPattern`prepared prompt exceeds engine max_context\s+(${TOKEN_COUNT})`,
5122
+ provenance: "unknown"
5123
+ },
5124
+ {
5125
+ pattern: overflowPattern`prompt exceeds (?:the )?.{0,32}\bmax_context\s+(${TOKEN_COUNT})`,
5126
+ provenance: "unknown"
5127
+ },
5128
+ {
5129
+ pattern: overflowPattern`\ballows a context of up to (${TOKEN_COUNT}) tokens?\b`,
5130
+ provenance: "combined"
5131
+ },
5132
+ {
5133
+ pattern: overflowPattern`(?<!${ESTIMATED_REQUEST}\s+)\bup to (${TOKEN_COUNT}) tokens?\b`,
5134
+ provenance: "unknown"
5135
+ },
5136
+ {
5137
+ pattern: overflowPattern`max(?:imum)?.*context(?:(?!${ESTIMATED_REQUEST})[^\d\r\n])*(${TOKEN_COUNT})`,
5138
+ provenance: "unknown"
5139
+ }
5106
5140
  ];
5141
+ function parseTokenCount(raw) {
5142
+ if (raw === undefined || !/^(?:\d+|\d{1,3}([,_ .\u202f])\d{3}(?:\1\d{3})*)$/.test(raw)) {
5143
+ return null;
5144
+ }
5145
+ const value = Number(raw.replace(/[,_ .\u202f]/g, ""));
5146
+ return Number.isSafeInteger(value) ? value : null;
5147
+ }
5107
5148
  var MIN_PLAUSIBLE_LIMIT = 1024;
5108
5149
  var MAX_PLAUSIBLE_LIMIT = 1e7;
5109
5150
  var THINKING_BINDING_MISMATCH_PATTERN = /bound to a different conversation/i;
@@ -5225,24 +5266,22 @@ function detectOverflow(error) {
5225
5266
  matchedPattern: matched?.source
5226
5267
  };
5227
5268
  }
5269
+ var INPUT_EXTRACTION_PATTERNS = [
5270
+ overflowPattern`prompt is too long:\s*(${TOKEN_COUNT})`,
5271
+ overflowPattern`input token count\s*\(?\s*(${TOKEN_COUNT})`,
5272
+ overflowPattern`input length\s*(${TOKEN_COUNT})`,
5273
+ overflowPattern`prompt was\s*(${TOKEN_COUNT})`,
5274
+ overflowPattern`messages resulted in\s*(${TOKEN_COUNT})\s*tokens?\b`,
5275
+ overflowPattern`\bthe input \((${TOKEN_COUNT}) tokens?\) is longer than the model's context length \(${TOKEN_COUNT} tokens?\)`,
5276
+ overflowPattern`\(\s*(${TOKEN_COUNT})\s+in the messages,\s*${TOKEN_COUNT}\s+in the completion\s*\)`,
5277
+ overflowPattern`${ESTIMATED_REQUEST}\s+(${TOKEN_COUNT})`
5278
+ ];
5228
5279
  function parseReportedInputTokens(message) {
5229
5280
  if (!message)
5230
5281
  return;
5231
- const patterns = [
5232
- /prompt is too long:\s*(\d+)/i,
5233
- /input token count\s*\(?\s*(\d+)/i,
5234
- /input length\s*(\d+)/i,
5235
- /prompt was\s*(\d+)/i,
5236
- /messages resulted in\s*(\d+)\s*tokens?/i,
5237
- /\bthe input \((\d+) tokens?\) is longer than the model's context length \(\d+ tokens?\)/i,
5238
- /\(\s*(\d+)\s+in the messages,\s*\d+\s+in the completion\s*\)/i
5239
- ];
5240
- for (const pattern of patterns) {
5241
- const raw = message.match(pattern)?.[1];
5242
- if (!raw)
5243
- continue;
5244
- const value = Number.parseInt(raw, 10);
5245
- if (Number.isFinite(value) && value > 0)
5282
+ for (const pattern of INPUT_EXTRACTION_PATTERNS) {
5283
+ const value = parseTokenCount(message.match(pattern)?.[1]);
5284
+ if (value !== null && value > 0)
5246
5285
  return value;
5247
5286
  }
5248
5287
  return;
@@ -5251,16 +5290,8 @@ function parseReportedLimit(message) {
5251
5290
  if (!message)
5252
5291
  return;
5253
5292
  for (const { pattern, provenance } of LIMIT_EXTRACTION_PATTERNS) {
5254
- const match = message.match(pattern);
5255
- if (!match)
5256
- continue;
5257
- const raw = match[1];
5258
- if (!raw)
5259
- continue;
5260
- const value = Number.parseInt(raw, 10);
5261
- if (!Number.isFinite(value))
5262
- continue;
5263
- if (value < MIN_PLAUSIBLE_LIMIT || value > MAX_PLAUSIBLE_LIMIT)
5293
+ const value = parseTokenCount(message.match(pattern)?.[1]);
5294
+ if (value === null || value < MIN_PLAUSIBLE_LIMIT || value > MAX_PLAUSIBLE_LIMIT)
5264
5295
  continue;
5265
5296
  return { value, provenance };
5266
5297
  }
@@ -7445,6 +7476,7 @@ function getActiveTagTokenTotalsByMessage2(db, sessionId, messageIds) {
7445
7476
  return out;
7446
7477
  }
7447
7478
  var updateTagTokenCountStatements = new WeakMap;
7479
+ var setTagTokenCountStatements = new WeakMap;
7448
7480
  var updateTagInputTokenCountStatements = new WeakMap;
7449
7481
  function getUpdateTagTokenCountStatement(db) {
7450
7482
  let stmt = updateTagTokenCountStatements.get(db);
@@ -1021,7 +1021,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1021
1021
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1022
1022
  if (signal.aborted || !readsOpenCodeStore)
1023
1023
  return;
1024
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-8b1g06nz.js"));
1024
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-jf2f8jz8.js"));
1025
1025
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-pz5981mf.js"));
1026
1026
  if (signal.aborted)
1027
1027
  return;
@@ -171,7 +171,7 @@ import {
171
171
  adoptNullOwnerToolTag2,
172
172
  getCandidateToolOwners2,
173
173
  pickNearestPriorOwner2
174
- } from "./index-8sc7vqt7.js";
174
+ } from "./index-kvfrse61.js";
175
175
  import {
176
176
  textMentionsRecentCommit,
177
177
  hasMeaningfulUserText2,
@@ -224,11 +224,11 @@ import {
224
224
  saveSourceContent,
225
225
  replaceSourceContent,
226
226
  getSourceContents
227
- } from "./index-ywxvdwmj.js";
227
+ } from "./index-ezr8mr1c.js";
228
228
  import {
229
229
  cleanSearchText,
230
230
  matchedSearchSnippet
231
- } from "./index-ev2rrjfc.js";
231
+ } from "./index-7dj3s7qq.js";
232
232
  import {
233
233
  getProjectEmbeddingSnapshot2,
234
234
  embedTextForProject2,
@@ -241,7 +241,7 @@ import {
241
241
  getMessageIndexEpoch,
242
242
  isMessageIndexSearchable,
243
243
  createAutoSearchDiagnostics
244
- } from "./index-3hk445am.js";
244
+ } from "./index-71h616be.js";
245
245
  import {
246
246
  openCodeDbExists,
247
247
  withReadOnlySessionDb,
@@ -259,7 +259,7 @@ import {
259
259
  extractToolCallObservation,
260
260
  ToolMutationBatch,
261
261
  createToolDropTarget
262
- } from "./index-d0feqcs5.js";
262
+ } from "./index-6kgsfb81.js";
263
263
  import {
264
264
  compareOpenCodeMessagesByCanonicalOrder,
265
265
  startCompactionMarkerCandidatePreparation,
@@ -281,7 +281,7 @@ import {
281
281
  peekNoteNudgeText,
282
282
  markNoteNudgeDelivered,
283
283
  getActiveCompartmentRun
284
- } from "./index-4yjn3er4.js";
284
+ } from "./index-x2hwwzk1.js";
285
285
  import {
286
286
  userFacingFailureCode
287
287
  } from "./index-n6aye6ny.js";