@cortexkit/pi-magic-context 0.49.43 → 0.49.45

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 (43) hide show
  1. package/dist/auto-search-worker.js +4 -4
  2. package/dist/chunk-embedding-write-worker.js +6 -6
  3. package/dist/{compaction-marker-candidates-8qhackvy.js → compaction-marker-candidates-17a21jfn.js} +12 -2
  4. package/dist/compaction-marker-candidates-worker.js +5 -2
  5. package/dist/{compartment-chunk-embedding-jpcme6tz.js → compartment-chunk-embedding-nyjs3dfh.js} +5 -5
  6. package/dist/{embedding-backfill-002vyexq.js → embedding-backfill-er9jc4xf.js} +9 -9
  7. package/dist/embedding-worker.js +4 -4
  8. package/dist/{index-wt7vmyj4.js → index-000fthre.js} +4 -0
  9. package/dist/{index-p8jpbrj4.js → index-2kmwjq42.js} +64 -12
  10. package/dist/{index-c1dqxr10.js → index-3g9fnq6y.js} +2 -1
  11. package/dist/{index-f9qet7y8.js → index-4sa1rx3h.js} +3 -3
  12. package/dist/{index-p9jfa33t.js → index-6bedye3n.js} +7 -7
  13. package/dist/{index-mx757f3g.js → index-7esg5v2x.js} +7 -4
  14. package/dist/{index-ck8wj35v.js → index-bbbp8zs1.js} +1 -1
  15. package/dist/{index-j0h89gxy.js → index-fzadydec.js} +3 -3
  16. package/dist/{index-rzfr7wdv.js → index-gwvahsdz.js} +1 -1
  17. package/dist/{index-ccanzg8p.js → index-gzk7d940.js} +1 -1
  18. package/dist/{index-wwsfevck.js → index-jaqdcqwz.js} +1 -1
  19. package/dist/{index-6cvt64cn.js → index-k7gdgs11.js} +143 -57
  20. package/dist/{index-k0csz6pb.js → index-nvgq29cw.js} +3 -3
  21. package/dist/{index-g2j58qpq.js → index-qt711raa.js} +6 -6
  22. package/dist/{index-z7dktknj.js → index-rcenqffj.js} +64 -22
  23. package/dist/{index-2qqsnh1b.js → index-tsg6swzr.js} +2 -2
  24. package/dist/{index-ry84c8dr.js → index-v7m1nqwz.js} +2 -2
  25. package/dist/{index-a7sj2bam.js → index-wwf9vxpf.js} +2 -2
  26. package/dist/{index-pwp6zyx3.js → index-zchc0df8.js} +1 -1
  27. package/dist/{index-jbkwszd5.js → index-zwbgxt01.js} +4 -4
  28. package/dist/index.js +217 -73
  29. package/dist/{message-fts-rowid-map-hmgyfxxa.js → message-fts-rowid-map-ff4qg3e4.js} +2 -2
  30. package/dist/{message-index-bounded-39z2atfj.js → message-index-bounded-cqn6x6fc.js} +7 -7
  31. package/dist/migration-worker.js +4 -4
  32. package/dist/{project-embedding-registry-16pj4vyf.js → project-embedding-registry-ysaezfqw.js} +8 -8
  33. package/dist/raw-ordinal-warmup-worker.js +7 -7
  34. package/dist/{read-session-chunk-jxq427v6.js → read-session-chunk-0ecmbegv.js} +5 -5
  35. package/dist/{read-session-raw-a9ntjqap.js → read-session-raw-nttnwy8p.js} +1 -1
  36. package/dist/{render-6bhqgkpq.js → render-s6k2xqhj.js} +11 -11
  37. package/dist/{search-archive-yvdq2nfp.js → search-archive-qza20zkm.js} +7 -7
  38. package/dist/{search-45wknkb6.js → search-p4fj69gn.js} +13 -13
  39. package/dist/{storage-tags-p9y3bnw7.js → storage-tags-g0j9mr4b.js} +2 -2
  40. package/dist/subagent-entry.js +19 -19
  41. package/dist/tag-snapshot-worker-pi.js +6 -6
  42. package/dist/{v2-archive-reader-bd94n954.js → v2-archive-reader-2v7a879f.js} +1 -1
  43. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -150,7 +150,7 @@ import {
150
150
  registerTodoStateLifecycle,
151
151
  syncCtxMemoryToolEnabled,
152
152
  registerMagicContextTools
153
- } from "./index-6cvt64cn.js";
153
+ } from "./index-k7gdgs11.js";
154
154
  import"./index-4knyh1kt.js";
155
155
  import {
156
156
  canonicalModelIdentity,
@@ -168,7 +168,7 @@ import {
168
168
  DEFAULT_HISTORIAN_TIMEOUT_MS,
169
169
  DREAM_TASK_PROMOTION_DEFAULTS,
170
170
  LIVE_RELOAD_CONFIG_PATHS
171
- } from "./index-ccanzg8p.js";
171
+ } from "./index-gzk7d940.js";
172
172
  import {
173
173
  FAIL_CLOSED_DOCTOR_COMMAND,
174
174
  formatFailClosedBlockingMessage,
@@ -353,7 +353,7 @@ import {
353
353
  getRawSessionTagKeysThrough2,
354
354
  getLegacyProtectedTailStartOrdinal2,
355
355
  readSessionChunk2
356
- } from "./index-mx757f3g.js";
356
+ } from "./index-7esg5v2x.js";
357
357
  import {
358
358
  UNKNOWN_FIT_RATIO,
359
359
  hasMeasuredDecisionCalibration,
@@ -440,7 +440,7 @@ import {
440
440
  getToolTagNumberByOwner2,
441
441
  getNullOwnerToolTag2,
442
442
  adoptNullOwnerToolTag2
443
- } from "./index-pwp6zyx3.js";
443
+ } from "./index-zchc0df8.js";
444
444
  import {
445
445
  textMentionsRecentCommit,
446
446
  hasMeaningfulUserText2,
@@ -452,7 +452,7 @@ import {
452
452
  estimateTokens,
453
453
  estimateFixedPromptTokens,
454
454
  normalizeText
455
- } from "./index-wt7vmyj4.js";
455
+ } from "./index-000fthre.js";
456
456
  import {
457
457
  inRootAsyncContext2,
458
458
  Database2,
@@ -490,7 +490,7 @@ import {
490
490
  openCurrentDatabase,
491
491
  openDatabaseAsync,
492
492
  closeDatabase
493
- } from "./index-a7sj2bam.js";
493
+ } from "./index-wwf9vxpf.js";
494
494
  import {
495
495
  LkgRecoveryFenceError,
496
496
  clearLkgFenceProcessState,
@@ -607,7 +607,7 @@ import {
607
607
  getSourceContents,
608
608
  recordSubagentInvocation,
609
609
  getLatestHistorianInvocationId
610
- } from "./index-p9jfa33t.js";
610
+ } from "./index-6bedye3n.js";
611
611
  import {
612
612
  resolveOpenCodeDbPath,
613
613
  assertOpenCodeStoreGeneration,
@@ -625,12 +625,12 @@ import {
625
625
  } from "./index-x2n261wp.js";
626
626
  import {
627
627
  RAW_SUMMARY_TEXT_MAX_CHARS2
628
- } from "./index-c1dqxr10.js";
628
+ } from "./index-3g9fnq6y.js";
629
629
  import"./index-ea37qn4x.js";
630
630
  import {
631
631
  formatSynapseLaneDescriptor
632
- } from "./index-rzfr7wdv.js";
633
- import"./index-ck8wj35v.js";
632
+ } from "./index-gwvahsdz.js";
633
+ import"./index-bbbp8zs1.js";
634
634
  import {
635
635
  buildCanonicalChunkTextFromFts2,
636
636
  buildCompartmentSummaryFallbackText2,
@@ -640,7 +640,7 @@ import {
640
640
  replaceCompartmentChunkEmbeddings2,
641
641
  deleteChunkEmbedBackoffForSession2,
642
642
  chunkWindowSourceKey2
643
- } from "./index-f9qet7y8.js";
643
+ } from "./index-4sa1rx3h.js";
644
644
  import {
645
645
  recordSessionProjectIdentity,
646
646
  GIT_SWEEP_LEASE_RENEWAL_MS,
@@ -665,7 +665,7 @@ import {
665
665
  clearCompressionDepthRange,
666
666
  cleanSearchText,
667
667
  matchedSearchSnippet
668
- } from "./index-j0h89gxy.js";
668
+ } from "./index-fzadydec.js";
669
669
  import {
670
670
  rememberV1HiddenRun
671
671
  } from "./index-6x556c2q.js";
@@ -742,7 +742,7 @@ import {
742
742
  } from "./index-q1yc6bs0.js";
743
743
  import {
744
744
  getCachedLocalEmbeddingPooling
745
- } from "./index-2qqsnh1b.js";
745
+ } from "./index-tsg6swzr.js";
746
746
  import {
747
747
  describeShadowBackfillWriteRefusal2,
748
748
  contentSha2562,
@@ -760,10 +760,10 @@ import {
760
760
  embedSessionCompartmentChunks2,
761
761
  getEmbeddingCoverageStatus2,
762
762
  getAutoEmbeddingSessionCoverage2
763
- } from "./index-z7dktknj.js";
763
+ } from "./index-rcenqffj.js";
764
764
  import {
765
765
  cosineSimilarity
766
- } from "./index-jbkwszd5.js";
766
+ } from "./index-zwbgxt01.js";
767
767
  import {
768
768
  USER_FACING_FAILURES,
769
769
  renderUserFacingFailure,
@@ -797,8 +797,8 @@ import {
797
797
  scheduleClearAndReindex,
798
798
  clearSessionTracking,
799
799
  createAutoSearchDiagnostics
800
- } from "./index-g2j58qpq.js";
801
- import"./index-p8jpbrj4.js";
800
+ } from "./index-qt711raa.js";
801
+ import"./index-2kmwjq42.js";
802
802
  import {
803
803
  DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
804
804
  buildHiddenAgentRegistrations,
@@ -825,11 +825,11 @@ import {
825
825
  drainPiTagSnapshotSession,
826
826
  assertPiTagSnapshotReady,
827
827
  ensurePiTagSnapshotReady
828
- } from "./index-wwsfevck.js";
828
+ } from "./index-jaqdcqwz.js";
829
829
  import"./index-cq71g4dk.js";
830
830
  import"./index-1cvyaw9a.js";
831
- import"./index-k0csz6pb.js";
832
- import"./index-ry84c8dr.js";
831
+ import"./index-nvgq29cw.js";
832
+ import"./index-v7m1nqwz.js";
833
833
  import {
834
834
  __toESM
835
835
  } from "./index-22jkk6wg.js";
@@ -3584,7 +3584,7 @@ function startHostStallProfilerSwitch() {
3584
3584
  // package.json
3585
3585
  var package_default = {
3586
3586
  name: "@cortexkit/pi-magic-context",
3587
- version: "0.49.43",
3587
+ version: "0.49.45",
3588
3588
  type: "module",
3589
3589
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3590
3590
  main: "dist/index.js",
@@ -22545,7 +22545,8 @@ var TOOL_KEYS = [
22545
22545
  "query",
22546
22546
  "symbol",
22547
22547
  "module",
22548
- "action"
22548
+ "action",
22549
+ "command"
22549
22550
  ];
22550
22551
  function record2(value) {
22551
22552
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -24197,7 +24198,7 @@ function parseCacheTtl(ttl) {
24197
24198
  }
24198
24199
  function createScheduler(config) {
24199
24200
  return {
24200
- shouldExecute(sessionMeta, contextUsage, currentTime = Date.now(), sessionId, modelKey, contextLimit) {
24201
+ shouldExecute(sessionMeta, contextUsage, _currentTime, sessionId, modelKey, contextLimit) {
24201
24202
  if (contextUsage.percentage === 0 && sessionMeta.lastResponseTime === 0) {
24202
24203
  return "defer";
24203
24204
  }
@@ -24210,35 +24211,10 @@ function createScheduler(config) {
24210
24211
  if (contextUsage.percentage >= threshold) {
24211
24212
  return "execute";
24212
24213
  }
24213
- let ttlMs;
24214
- try {
24215
- ttlMs = parseCacheTtl(sessionMeta.cacheTtl);
24216
- } catch (error) {
24217
- if (sessionId) {
24218
- sessionLog2(sessionId, `invalid cache_ttl "${sessionMeta.cacheTtl}"; falling back to default 5m`, error);
24219
- } else {
24220
- log2(`[magic-context] invalid cache_ttl "${sessionMeta.cacheTtl}"; falling back to default 5m`, error);
24221
- }
24222
- ttlMs = parseCacheTtl("5m");
24223
- }
24224
- const elapsedTime = currentTime - sessionMeta.lastResponseTime;
24225
- if (elapsedTime > ttlMs) {
24226
- return "execute";
24227
- }
24228
24214
  return "defer";
24229
24215
  }
24230
24216
  };
24231
24217
  }
24232
- function computeHardCacheExpired(cacheTtl, lastResponseTime, now, onInvalid) {
24233
- let ttlMs;
24234
- try {
24235
- ttlMs = parseCacheTtl(cacheTtl);
24236
- } catch (error) {
24237
- onInvalid?.(error);
24238
- ttlMs = 5 * 60 * 1000;
24239
- }
24240
- return lastResponseTime > 0 && now - lastResponseTime > ttlMs;
24241
- }
24242
24218
 
24243
24219
  // ../plugin/src/features/magic-context/tagger.ts
24244
24220
  var TOOL_COMPOSITE_KEY_SEP = "\x00";
@@ -24995,7 +24971,6 @@ var CACHE_LOSING_FOLD_REASONS = new Set([
24995
24971
  "model_change",
24996
24972
  "system_hash",
24997
24973
  "tool_definitions",
24998
- "ttl_idle",
24999
24974
  "host_compaction"
25000
24975
  ]);
25001
24976
  function sameBytes(left, right) {
@@ -25369,7 +25344,7 @@ function hasReclaimRide(signals) {
25369
25344
  return signals.hardFold || signals.force || signals.explicitFlush || signals.publishedHistory || signals.subagentExecute === true || signals.executeReclaim === true || signals.servedShapeRepair === true;
25370
25345
  }
25371
25346
  function prefixMutationPermitted(gate) {
25372
- return !gate.signedThinkingHold || gate.firstRender || gate.idleExpiry || gate.emergency;
25347
+ return !gate.signedThinkingHold || gate.firstRender || gate.emergency;
25373
25348
  }
25374
25349
  function reclaimRidePermitted(signals, gate) {
25375
25350
  return prefixMutationPermitted(gate) && hasReclaimRide(signals);
@@ -34359,9 +34334,6 @@ function mustMaterializePi(state, db, currentCompartmentsOverride, passSnapshot)
34359
34334
  if (meta.cachedM0ProjectIdentity !== null && meta.cachedM0ProjectIdentity !== state.projectIdentity) {
34360
34335
  return piMaterializeMismatch("project_change", "projectIdentity", meta.cachedM0ProjectIdentity, state.projectIdentity);
34361
34336
  }
34362
- if (hard.cacheExpired && hard.lastResponseTime > 0 && hard.lastResponseTime > (meta.cachedM0MaterializedAt ?? 0)) {
34363
- return piMaterializeMismatch("ttl_idle", "lastResponseTimeAfterMaterialization", meta.cachedM0MaterializedAt ?? 0, hard.lastResponseTime);
34364
- }
34365
34337
  if (cached.upgradeState !== current.upgradeState) {
34366
34338
  return piMaterializeMismatch("renderer_upgrade", "upgradeState", cached.upgradeState, current.upgradeState);
34367
34339
  }
@@ -35371,6 +35343,16 @@ function repairPiHistoryBoundary(db, sessionId, ctx, branchEntries) {
35371
35343
  }
35372
35344
 
35373
35345
  // src/native-replay-pi.ts
35346
+ var DROP_PLACEHOLDER = /^\[dropped §\d+§\]$/u;
35347
+ var TAG_LABEL = /^§\d+§ /u;
35348
+ var RESPONSES_APIS = new Set([
35349
+ "openai-responses",
35350
+ "azure-openai-responses",
35351
+ "openai-codex-responses"
35352
+ ]);
35353
+ function isPiDropPlaceholder(text) {
35354
+ return DROP_PLACEHOLDER.test(text);
35355
+ }
35374
35356
  function getNativeEnvelope(message) {
35375
35357
  if (!isRecord(message) || isPiSystemEntry(message))
35376
35358
  return;
@@ -35457,11 +35439,142 @@ function textIdentity(part) {
35457
35439
  } catch {}
35458
35440
  return;
35459
35441
  }
35460
- function rewriteNativeAssistantTexts(message, previous, sessionId) {
35442
+ function nativeTextSlots(content, items) {
35443
+ const slots = [];
35444
+ for (let itemIndex = 0;itemIndex < items.length; itemIndex++) {
35445
+ const item = items[itemIndex];
35446
+ if (!isRecord(item))
35447
+ return;
35448
+ if (item.type === "reasoning" || item.type === "function_call" || item.type === "custom_tool_call")
35449
+ continue;
35450
+ if (item.type !== "message" || item.role !== "assistant" || !Array.isArray(item.content))
35451
+ return;
35452
+ for (let outputIndex = 0;outputIndex < item.content.length; outputIndex++) {
35453
+ const output = item.content[outputIndex];
35454
+ if (!isRecord(output) || output.type !== "output_text" || typeof output.text !== "string")
35455
+ return;
35456
+ slots.push({ itemIndex, outputIndex, text: output.text });
35457
+ }
35458
+ }
35459
+ const blocks = content.filter((block) => isRecord(block) && block.type === "text").length;
35460
+ return slots.length === blocks ? slots : undefined;
35461
+ }
35462
+ function hookRewrittenSlot(previous, partIndex, items) {
35463
+ const slots = nativeTextSlots(previous, items);
35464
+ if (!slots)
35465
+ return;
35466
+ let ordinal = 0;
35467
+ let target;
35468
+ for (let index = 0;index < previous.length; index++) {
35469
+ const block = previous[index];
35470
+ if (!isRecord(block) || block.type !== "text")
35471
+ continue;
35472
+ const slot = slots[ordinal++];
35473
+ const item = items[slot.itemIndex];
35474
+ if (typeof block.text !== "string")
35475
+ return;
35476
+ if ("textSignature" in block) {
35477
+ const identity = textIdentity(block);
35478
+ if (index === partIndex || !identity || item.id !== identity.id || item.phase !== identity.phase)
35479
+ return;
35480
+ continue;
35481
+ }
35482
+ const stripped = stripPersistedAssistantText(slot.text);
35483
+ if (stripped !== block.text.replace(TAG_LABEL, ""))
35484
+ return;
35485
+ if (index !== partIndex)
35486
+ continue;
35487
+ if (stripped === slot.text || item.content.length !== 1)
35488
+ return;
35489
+ target = slot;
35490
+ }
35491
+ return target;
35492
+ }
35493
+ function emptyAssistantMessage(item) {
35494
+ if (item.type !== "message" || item.role !== "assistant")
35495
+ return false;
35496
+ if (typeof item.content === "string")
35497
+ return !/\S/u.test(item.content);
35498
+ return Array.isArray(item.content) && !item.content.some((part) => isRecord(part) && (part.type === "output_text" && typeof part.text === "string" && /\S/u.test(part.text) || part.type === "refusal" && typeof part.refusal === "string" && /\S/u.test(part.refusal)));
35499
+ }
35500
+ function replayableNativeItems(message, model) {
35501
+ const payload = message.providerPayload;
35502
+ if (message.api !== model.api || message.model !== model.id || !isRecord(payload) || payload.type !== "openaiResponsesHistory" || !Array.isArray(payload.items) || (payload.provider ?? message.provider ?? model.provider) !== model.provider)
35503
+ return;
35504
+ return payload.items.some((item) => !isRecord(item) || item.type !== "reasoning" && !emptyAssistantMessage(item)) ? payload.items : undefined;
35505
+ }
35506
+ function signedItemText(block, items) {
35507
+ const identity = textIdentity(block);
35508
+ if (!identity)
35509
+ return;
35510
+ const matches = items.filter((item) => isRecord(item) && item.type === "message" && item.role === "assistant" && item.id === identity.id && item.phase === identity.phase);
35511
+ const outputs = matches.length === 1 && Array.isArray(matches[0].content) ? matches[0].content.filter((output) => isRecord(output) && output.type === "output_text") : [];
35512
+ const text = outputs[0]?.text;
35513
+ return outputs.length === 1 && typeof text === "string" ? text : undefined;
35514
+ }
35515
+ function piNativeDropExpectations(messages, model) {
35516
+ const expectations = [];
35517
+ if (!model || !RESPONSES_APIS.has(String(model.api)))
35518
+ return expectations;
35519
+ for (let index = 0;index < messages.length; index++) {
35520
+ const message = messages[index];
35521
+ if (!isRecord(message) || message.role !== "assistant" || !Array.isArray(message.content) || !message.content.some((block) => isRecord(block) && block.type === "text" && typeof block.text === "string" && isPiDropPlaceholder(block.text)))
35522
+ continue;
35523
+ const items = replayableNativeItems(message, model);
35524
+ if (!items)
35525
+ continue;
35526
+ const slots = nativeTextSlots(message.content, items);
35527
+ let ordinal = 0;
35528
+ for (const block of message.content) {
35529
+ if (!isRecord(block) || block.type !== "text")
35530
+ continue;
35531
+ const slot = slots?.[ordinal++];
35532
+ if (typeof block.text !== "string" || !isPiDropPlaceholder(block.text))
35533
+ continue;
35534
+ const native = "textSignature" in block ? signedItemText(block, items) : slot?.text;
35535
+ expectations.push({
35536
+ message: index,
35537
+ placeholder: block.text,
35538
+ ...native !== undefined && native !== block.text ? { stale: native } : {}
35539
+ });
35540
+ }
35541
+ }
35542
+ return expectations;
35543
+ }
35544
+ function wireAssistantTexts(payload) {
35545
+ const input = isRecord(payload) ? payload.input : undefined;
35546
+ if (!Array.isArray(input))
35547
+ return;
35548
+ const texts = new Set;
35549
+ for (const item of input) {
35550
+ if (!isRecord(item) || item.role !== "assistant")
35551
+ continue;
35552
+ if (typeof item.content === "string")
35553
+ texts.add(item.content);
35554
+ else if (Array.isArray(item.content)) {
35555
+ for (const part of item.content)
35556
+ if (isRecord(part) && typeof part.text === "string")
35557
+ texts.add(part.text);
35558
+ }
35559
+ }
35560
+ return texts;
35561
+ }
35562
+ function piNativeDropWireMismatch(payload, expectations) {
35563
+ if (!expectations?.length)
35564
+ return;
35565
+ const texts = wireAssistantTexts(payload);
35566
+ for (const expected of expectations)
35567
+ if (!texts?.has(expected.placeholder) || expected.stale !== undefined && texts.has(expected.stale))
35568
+ return `message=${expected.message} comparison=native_drop`;
35569
+ return;
35570
+ }
35571
+ function rewriteNativeAssistantTexts(message, previous, sessionId, options = {}) {
35461
35572
  const envelope = getNativeEnvelope(message);
35462
35573
  if (envelope?.message.role !== "assistant" || !isRecord(previous) || !Array.isArray(previous.content) || !Array.isArray(envelope.message.content))
35463
35574
  return;
35464
35575
  const content = envelope.message.content;
35576
+ const arrivedItems = envelope.items;
35577
+ const unsignedDrops = options.unsignedDrops === true && RESPONSES_APIS.has(String(envelope.message.api)) && envelope.payload.dt === true;
35465
35578
  for (let index = 0;index < content.length; index++) {
35466
35579
  const part = content[index];
35467
35580
  const before = previous.content[index];
@@ -35470,6 +35583,23 @@ function rewriteNativeAssistantTexts(message, previous, sessionId) {
35470
35583
  if (part.text.replace(/^§\d+§ /u, "") === before.text.replace(/^§\d+§ /u, ""))
35471
35584
  continue;
35472
35585
  const identity = textIdentity(part);
35586
+ if (identity === undefined && unsignedDrops && isPiDropPlaceholder(part.text) && !("textSignature" in part)) {
35587
+ const slot = hookRewrittenSlot(previous.content, index, arrivedItems);
35588
+ if (slot) {
35589
+ const item = envelope.items[slot.itemIndex];
35590
+ const outputs = item.content.slice();
35591
+ outputs[slot.outputIndex] = {
35592
+ ...outputs[slot.outputIndex],
35593
+ text: part.text
35594
+ };
35595
+ const items = envelope.items.slice();
35596
+ items[slot.itemIndex] = { ...item, content: outputs };
35597
+ envelope.items = items;
35598
+ envelope.payload = { ...envelope.payload, items };
35599
+ envelope.message.providerPayload = envelope.payload;
35600
+ continue;
35601
+ }
35602
+ }
35473
35603
  const sameIdentity = (value) => {
35474
35604
  const other = textIdentity(value);
35475
35605
  return identity !== undefined && other?.id === identity.id && other.phase === identity.phase;
@@ -37178,7 +37308,7 @@ function piExplainsOptionalAssistant(thinking, content) {
37178
37308
  }
37179
37309
 
37180
37310
  // src/pi-dispatch-tool-pairing.ts
37181
- var RESPONSES_APIS = new Set([
37311
+ var RESPONSES_APIS2 = new Set([
37182
37312
  "openai-responses",
37183
37313
  "openai-codex-responses",
37184
37314
  "azure-openai-responses"
@@ -37197,7 +37327,7 @@ function piToolCallPairing(messages) {
37197
37327
  const message = object7(value);
37198
37328
  if (message?.role !== "assistant" || !Array.isArray(message.content))
37199
37329
  continue;
37200
- const responses = RESPONSES_APIS.has(String(message.api));
37330
+ const responses = RESPONSES_APIS2.has(String(message.api));
37201
37331
  for (const part of message.content) {
37202
37332
  const block = object7(part);
37203
37333
  if (block?.type !== "toolCall" || typeof block.id !== "string")
@@ -37684,6 +37814,8 @@ function piResponsesAssistantTexts(value, model, host, alternatives, frozenTagSt
37684
37814
  texts.push(textIdentity2(text, undefined));
37685
37815
  continue;
37686
37816
  }
37817
+ if (host === "omp" && (block?.type === "image" || block?.type === "anthropicServerTool" || block?.type === "fallback" || block?.type === "redactedThinking" && !sameModel))
37818
+ continue;
37687
37819
  if (block?.type !== "text" || typeof block.text !== "string")
37688
37820
  return;
37689
37821
  units += block.text.length;
@@ -37722,7 +37854,9 @@ function piResponsesAssistantTexts(value, model, host, alternatives, frozenTagSt
37722
37854
  output = true;
37723
37855
  continue;
37724
37856
  }
37725
- if (item?.type !== "message" || item.role !== "assistant" || !Array.isArray(item.content))
37857
+ if (item?.type !== "message")
37858
+ return;
37859
+ if (item.role !== "assistant" || !Array.isArray(item.content))
37726
37860
  return texts;
37727
37861
  const itemTexts = [];
37728
37862
  for (const value of item.content) {
@@ -37740,11 +37874,12 @@ function piResponsesAssistantTexts(value, model, host, alternatives, frozenTagSt
37740
37874
  const signed = signature?.v === 1 && typeof signature.id === "string" && item.id === signature.id && item.phase === signature.phase && part.text === block.text.replace(/^§\d+§ /u, "");
37741
37875
  if (!signed) {
37742
37876
  const stripped = stripPersistedAssistantText(part.text);
37743
- if (!allowUnsigned || "textSignature" in block || stripped !== block.text.replace(/^§\d+§ /u, ""))
37877
+ const droppedPlaceholder = isPiDropPlaceholder(block.text) && part.text === block.text;
37878
+ if (!allowUnsigned || "textSignature" in block || !droppedPlaceholder && stripped !== block.text.replace(/^§\d+§ /u, ""))
37744
37879
  return texts;
37745
37880
  unsigned = true;
37746
- allUnsignedFrozen &&= part.text === block.text && ownsNativeResponseTagStrip(frozenTagStrips, item.id, item.phase, part.text);
37747
- rewrittenText ||= part.text !== stripped;
37881
+ allUnsignedFrozen &&= droppedPlaceholder || part.text === block.text && ownsNativeResponseTagStrip(frozenTagStrips, item.id, item.phase, part.text);
37882
+ rewrittenText ||= !droppedPlaceholder && part.text !== stripped;
37748
37883
  }
37749
37884
  bound++;
37750
37885
  itemTexts.push(part.text);
@@ -38212,7 +38347,12 @@ function preparePiDispatch(messages, model, omp, cwd) {
38212
38347
  const reminders = structure && dateReminderPlans.get(structure);
38213
38348
  if (reminders)
38214
38349
  reminders.cwd = cwd;
38215
- return { messages: output, structure };
38350
+ const nativeDrops = omp ? piNativeDropExpectations(output, model) : [];
38351
+ return {
38352
+ messages: output,
38353
+ structure,
38354
+ ...nativeDrops.length ? { nativeDrops } : {}
38355
+ };
38216
38356
  }
38217
38357
  function buildPiPreparedStructure(messages, model, prepareUser, host = "omp") {
38218
38358
  if (!messages.length || messages.length > MAX_MESSAGES)
@@ -40316,6 +40456,7 @@ function releasePiOperationPayloads(operation) {
40316
40456
  operation.managedSignature = undefined;
40317
40457
  operation.cursorRoots = undefined;
40318
40458
  operation.preparedStructure = undefined;
40459
+ operation.nativeDrops = undefined;
40319
40460
  operation.preparedHistory = undefined;
40320
40461
  }
40321
40462
  function operationKey(ctx) {
@@ -40609,6 +40750,9 @@ function registerPiGuardedContext(pi, handler, options = {}) {
40609
40750
  const fields = piConversationFields(payload);
40610
40751
  if (!fields)
40611
40752
  throw new Error("provider conversation identity could not be established");
40753
+ const nativeDrop = piNativeDropWireMismatch(checked, active.nativeDrops);
40754
+ if (nativeDrop)
40755
+ throw new Error(`provider request does not match this pass's managed dispatch (prepared turn structure); ${nativeDrop}`);
40612
40756
  const body = checked;
40613
40757
  const skipReason = piCursorConversation(checked) ? "Cursor history blob IDs do not expose prepared turn structure" : active.preparedStructure ? active.preparedStructure.structuralSkipReason ?? (active.preparedStructure.api && body?.messages === undefined && Array.isArray(body?.input) && !active.preparedStructure.responsesMessages ? "provider selected Responses items without a matching history plan" : undefined) : "prepared history representation is not modeled";
40614
40758
  if (chained && skipReason)
@@ -40722,6 +40866,7 @@ function registerPiGuardedContext(pi, handler, options = {}) {
40722
40866
  if (ctx.model?.api === "cursor-agent")
40723
40867
  active.cursorRoots = piCursorManagedRoots(result.messages, active.managedSignature, ctx.cwd);
40724
40868
  active.preparedStructure = prepared.structure;
40869
+ active.nativeDrops = prepared.nativeDrops;
40725
40870
  if (fenceEnabled && !budget.sideTurn && piChainCapableApi(ctx.model?.api))
40726
40871
  active.preparedHistory = piPreparedHistory(result.messages, ctx.model);
40727
40872
  budget.completed = true;
@@ -43538,8 +43683,7 @@ function processSystemPromptForCache(args) {
43538
43683
  const stableCandidate = dates.stable;
43539
43684
  const stableCandidateHash = systemPromptFingerprint(stableCandidate, args.promptSurfacePreset);
43540
43685
  const contentOrPresetChanged = !isFirstHash && stableCandidateHash !== previousHash;
43541
- const idleCacheExpired = sessionMeta !== undefined && computeHardCacheExpired(sessionMeta.cacheTtl, sessionMeta.lastResponseTime, Date.now());
43542
- const dateMayAdvance = isCacheBusting || idleCacheExpired || contentOrPresetChanged;
43686
+ const dateMayAdvance = isCacheBusting || contentOrPresetChanged;
43543
43687
  if (liveDate && !stickyDate) {
43544
43688
  stickyDateBySession.set(sessionId, liveDate);
43545
43689
  } else if (liveDate && stickyDate && liveDate !== stickyDate) {
@@ -43606,9 +43750,10 @@ function createPiTranscript(source, sessionId, entryIds, options = {}) {
43606
43750
  message.requiresToolArcSkeleton = false;
43607
43751
  }
43608
43752
  let committed = false;
43753
+ const harness = resolvePiHarnessKind();
43609
43754
  return {
43610
43755
  messages: transcriptMessages,
43611
- harness: resolvePiHarnessKind(),
43756
+ harness,
43612
43757
  prepareToolRemovalMeasurements(callIds) {
43613
43758
  if (!options.authorizeToolRemovals || callIds.length === 0)
43614
43759
  return;
@@ -43629,7 +43774,9 @@ function createPiTranscript(source, sessionId, entryIds, options = {}) {
43629
43774
  return;
43630
43775
  committed = true;
43631
43776
  for (const index of dirtyMessages) {
43632
- rewriteNativeAssistantTexts(working[index], source[index], sessionId);
43777
+ rewriteNativeAssistantTexts(working[index], source[index], sessionId, {
43778
+ unsignedDrops: harness === "omp"
43779
+ });
43633
43780
  }
43634
43781
  for (const [index, parts] of removals) {
43635
43782
  const message = working[index];
@@ -47848,7 +47995,6 @@ Historian previously failed ${failureCount} time(s), so Magic Context is retryin
47848
47995
  permission: {
47849
47996
  signedThinkingHold: args.signedThinkingHeld === true,
47850
47997
  firstRender: false,
47851
- idleExpiry: false,
47852
47998
  emergency: usage.percentage >= historianForceMaterializationPercentage
47853
47999
  }
47854
48000
  }, args.eligiblePendingDropTagIds, args.primaryExecute === true);
@@ -48356,12 +48502,11 @@ async function runPipeline(args) {
48356
48502
  }
48357
48503
  const routinePressureAlreadyApplied = !args.sessionMeta.isSubagent && executePressureEligible && routinePressureAppliedBySession.get(args.sessionId) === true;
48358
48504
  let hasPendingMaterializeSignal = !protectedSignedPrefix && hasPendingMaterialization(args.sessionId);
48359
- const heldIdleExpiryRebuild = protectedSignedPrefix && piHardSignals?.cacheExpired === true;
48360
48505
  const systemPrefixChangedThisPass = !prefixPreflightContended && effectiveSystemChangedThisPass;
48361
48506
  const rideSignals = {
48362
48507
  executeReclaim: false,
48363
48508
  subagentExecute: args.sessionMeta.isSubagent && args.schedulerDecision === "execute",
48364
- hardFold: foldBustsServedPrefixThisPass || systemPrefixChangedThisPass || firstRenderBust || heldIdleExpiryRebuild || isCacheBustingPass,
48509
+ hardFold: foldBustsServedPrefixThisPass || systemPrefixChangedThisPass || firstRenderBust || isCacheBustingPass,
48365
48510
  force: (args.forceMaterialization === true || emergencyDropEligible) && (args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0),
48366
48511
  explicitFlush: !protectedSignedPrefix && (args.userFlushOrigin === true || hasPendingMaterializationOrigin(pendingMaterializationSessions, args.sessionId, "user_flush")),
48367
48512
  publishedHistory: !prefixPreflightContended && publishedM1RefreshedThisPass
@@ -48369,7 +48514,6 @@ async function runPipeline(args) {
48369
48514
  const ridePermissionGate = {
48370
48515
  signedThinkingHold: protectedSignedPrefix,
48371
48516
  firstRender: firstRenderBust,
48372
- idleExpiry: heldIdleExpiryRebuild,
48373
48517
  emergency: emergencyDropEligible
48374
48518
  };
48375
48519
  let prefixMutationAllowed = prefixMutationPermitted(ridePermissionGate);
@@ -48385,7 +48529,7 @@ async function runPipeline(args) {
48385
48529
  onRejectedProjectOverride: (warning) => sessionLog2(args.sessionId, warning)
48386
48530
  });
48387
48531
  let protectionFloorResolution = resolveProtectionFloor();
48388
- let shouldRunHeuristics = args.heuristics !== undefined && isCacheBustingPass && (rideSignals.publishedHistory || systemPrefixChangedThisPass || rideSignals.explicitFlush || args.forceMaterialization === true || hasPendingMaterializeSignal || deferredMaterializeEligible || foldBustsServedPrefixThisPass || firstRenderBust || heldIdleExpiryRebuild || args.recoveryRebuildReason !== undefined && isCacheBustingPass || rideSignals.subagentExecute || args.schedulerDecision === "execute" && !alreadyRanHeuristicsThisTurn);
48532
+ let shouldRunHeuristics = args.heuristics !== undefined && isCacheBustingPass && (rideSignals.publishedHistory || systemPrefixChangedThisPass || rideSignals.explicitFlush || args.forceMaterialization === true || hasPendingMaterializeSignal || deferredMaterializeEligible || foldBustsServedPrefixThisPass || firstRenderBust || args.recoveryRebuildReason !== undefined && isCacheBustingPass || rideSignals.subagentExecute || args.schedulerDecision === "execute" && !alreadyRanHeuristicsThisTurn);
48389
48533
  let unavoidableCarriedIdentityRebuild = false;
48390
48534
  if (protectedSignedPrefix && readPiIdentityRebuilds(args.db, args.sessionId).length > 0) {
48391
48535
  args.tryReplayHeldIdentityRebuild?.();
@@ -48904,7 +49048,7 @@ async function runPipeline(args) {
48904
49048
  const tHeuristic = performance.now();
48905
49049
  const providerOverflow = args.providerOverflowRecovery === true;
48906
49050
  const recoveryCalibration = sessionDecisionCalibration(args.db, args.sessionId);
48907
- const independentMutationBeforeHeuristics = pendingOpsDidMutate || systemPrefixChangedThisPass || foldBustsServedPrefixThisPass || identityRebuild || firstRenderBust || heldIdleExpiryRebuild;
49051
+ const independentMutationBeforeHeuristics = pendingOpsDidMutate || systemPrefixChangedThisPass || foldBustsServedPrefixThisPass || identityRebuild || firstRenderBust;
48908
49052
  if (args.forceMaterialization === true && independentMutationBeforeHeuristics && getEmergencyInputSample(args.db, args.sessionId) > 0) {
48909
49053
  clearEmergencyDropSample(args.db, args.sessionId);
48910
49054
  }
@@ -49547,7 +49691,7 @@ async function runPipeline(args) {
49547
49691
  prefixMutationAllowed,
49548
49692
  strictThinkingKept: protectedSignedPrefix,
49549
49693
  signedPrefixRewritten: rewritingSignedPrefix,
49550
- prefixRebuildAlreadyPriced: firstRenderBust || heldIdleExpiryRebuild || !!args.recoveryRebuildReason && isCacheBustingPass,
49694
+ prefixRebuildAlreadyPriced: firstRenderBust || !!args.recoveryRebuildReason && isCacheBustingPass,
49551
49695
  identityRebuilt: identityRebuild,
49552
49696
  servedTagNumbers,
49553
49697
  heuristicsExecuted,
@@ -51205,7 +51349,7 @@ function cacheRows(source, now) {
51205
51349
  }
51206
51350
  rows.push({
51207
51351
  label: "Auto-execute",
51208
- value: source.cacheExpired ? "yes (expired)" : neverExpires ? `at ≥${threshold}` : `at TTL or ≥${threshold}`,
51352
+ value: `at ≥${threshold}`,
51209
51353
  tone: "muted"
51210
51354
  });
51211
51355
  return rows;
@@ -5,8 +5,8 @@ import {
5
5
  startMessageFtsRowidMapBackfill2,
6
6
  messageFtsOrdinalRangeIsMapped2,
7
7
  deleteUnmappedMessageFtsRows2
8
- } from "./index-ck8wj35v.js";
9
- import"./index-c1dqxr10.js";
8
+ } from "./index-bbbp8zs1.js";
9
+ import"./index-3g9fnq6y.js";
10
10
  import"./index-wfqysrwq.js";
11
11
  import"./index-8sqebjzk.js";
12
12
  import"./index-0wtm7g7f.js";
@@ -3,19 +3,19 @@ import {
3
3
  withIndexChunk2,
4
4
  yieldIndexChunk2
5
5
  } from "./index-2qtx0q6h.js";
6
- import"./index-pwp6zyx3.js";
7
- import"./index-wt7vmyj4.js";
6
+ import"./index-zchc0df8.js";
7
+ import"./index-000fthre.js";
8
8
  import"./index-0h2mkab2.js";
9
9
  import"./index-gymgz20n.js";
10
10
  import"./index-dnp1jjar.js";
11
11
  import"./index-yacs388s.js";
12
- import"./index-ccanzg8p.js";
12
+ import"./index-gzk7d940.js";
13
13
  import"./index-8sqebjzk.js";
14
14
  import"./index-wfqysrwq.js";
15
15
  import"./index-x2n261wp.js";
16
- import"./index-c1dqxr10.js";
16
+ import"./index-3g9fnq6y.js";
17
17
  import"./index-n0zjvs3h.js";
18
- import"./index-mx757f3g.js";
18
+ import"./index-7esg5v2x.js";
19
19
  import"./index-6x556c2q.js";
20
20
  import"./index-c6wbq66z.js";
21
21
  import {
@@ -25,8 +25,8 @@ import {
25
25
  markMessageIndexDirty,
26
26
  getIndexableContent,
27
27
  indexSingleMessage
28
- } from "./index-j0h89gxy.js";
29
- import"./index-ck8wj35v.js";
28
+ } from "./index-fzadydec.js";
29
+ import"./index-bbbp8zs1.js";
30
30
  import"./index-0wtm7g7f.js";
31
31
 
32
32
  // ../plugin/src/features/magic-context/message-index-bounded.ts
@@ -17,15 +17,15 @@ import"./index-6pk49fc3.js";
17
17
  import {
18
18
  setSqlitePragmaConfig,
19
19
  initializeDatabase
20
- } from "./index-a7sj2bam.js";
20
+ } from "./index-wwf9vxpf.js";
21
21
  import"./index-fapenpch.js";
22
22
  import"./index-3bb24eb6.js";
23
23
  import"./index-8sqebjzk.js";
24
24
  import"./index-wfqysrwq.js";
25
25
  import"./index-x2n261wp.js";
26
- import"./index-c1dqxr10.js";
27
- import"./index-ck8wj35v.js";
28
- import"./index-wt7vmyj4.js";
26
+ import"./index-3g9fnq6y.js";
27
+ import"./index-bbbp8zs1.js";
28
+ import"./index-000fthre.js";
29
29
  import"./index-c6wbq66z.js";
30
30
  import {
31
31
  closeQuietly