@cortexkit/pi-magic-context 0.49.44 → 0.49.46
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.
- package/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +6 -6
- package/dist/{compartment-chunk-embedding-jpcme6tz.js → compartment-chunk-embedding-nyjs3dfh.js} +5 -5
- package/dist/{embedding-backfill-v9b8gkmp.js → embedding-backfill-er9jc4xf.js} +8 -8
- package/dist/embedding-worker.js +3 -3
- package/dist/{index-wt7vmyj4.js → index-000fthre.js} +4 -0
- package/dist/{index-c1dqxr10.js → index-3g9fnq6y.js} +2 -1
- package/dist/{index-f9qet7y8.js → index-4sa1rx3h.js} +3 -3
- package/dist/{index-gtd9kaaf.js → index-6bedye3n.js} +6 -6
- package/dist/{index-j2x88zk0.js → index-7esg5v2x.js} +6 -3
- package/dist/{index-ck8wj35v.js → index-bbbp8zs1.js} +1 -1
- package/dist/{index-fjmghcbx.js → index-ewf0sd7d.js} +30 -21
- package/dist/{index-025nxwc9.js → index-fzadydec.js} +3 -3
- package/dist/{index-rzfr7wdv.js → index-gwvahsdz.js} +1 -1
- package/dist/{index-wwsfevck.js → index-jaqdcqwz.js} +1 -1
- package/dist/{index-gg9r701n.js → index-nvgq29cw.js} +3 -3
- package/dist/{index-zttw4vew.js → index-qt711raa.js} +6 -6
- package/dist/{index-9tcbabqr.js → index-rcenqffj.js} +63 -21
- package/dist/{index-xf3ndcqd.js → index-tsg6swzr.js} +1 -1
- package/dist/{index-pb0ygvpa.js → index-v7m1nqwz.js} +2 -2
- package/dist/{index-p1jxxsth.js → index-wwf9vxpf.js} +2 -2
- package/dist/{index-pwp6zyx3.js → index-zchc0df8.js} +1 -1
- package/dist/{index-gajhgp4k.js → index-zwbgxt01.js} +3 -3
- package/dist/index.js +246 -36
- package/dist/{message-fts-rowid-map-hmgyfxxa.js → message-fts-rowid-map-ff4qg3e4.js} +2 -2
- package/dist/{message-index-bounded-1gj1pwjy.js → message-index-bounded-cqn6x6fc.js} +6 -6
- package/dist/migration-worker.js +4 -4
- package/dist/{project-embedding-registry-e81zewts.js → project-embedding-registry-ysaezfqw.js} +7 -7
- package/dist/raw-ordinal-warmup-worker.js +7 -7
- package/dist/{read-session-chunk-r9qy3jzj.js → read-session-chunk-0ecmbegv.js} +4 -4
- package/dist/{read-session-raw-a9ntjqap.js → read-session-raw-nttnwy8p.js} +1 -1
- package/dist/{render-dvmk12tf.js → render-s6k2xqhj.js} +10 -10
- package/dist/{search-archive-23s9g6dx.js → search-archive-qza20zkm.js} +6 -6
- package/dist/{search-khaxkbs1.js → search-p4fj69gn.js} +12 -12
- package/dist/{storage-tags-p9y3bnw7.js → storage-tags-g0j9mr4b.js} +2 -2
- package/dist/subagent-entry.js +17 -17
- package/dist/tag-snapshot-worker-pi.js +6 -6
- package/dist/{v2-archive-reader-z7qgxxp0.js → v2-archive-reader-2v7a879f.js} +1 -1
- 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-
|
|
153
|
+
} from "./index-ewf0sd7d.js";
|
|
154
154
|
import"./index-4knyh1kt.js";
|
|
155
155
|
import {
|
|
156
156
|
canonicalModelIdentity,
|
|
@@ -353,7 +353,7 @@ import {
|
|
|
353
353
|
getRawSessionTagKeysThrough2,
|
|
354
354
|
getLegacyProtectedTailStartOrdinal2,
|
|
355
355
|
readSessionChunk2
|
|
356
|
-
} from "./index-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
628
|
+
} from "./index-3g9fnq6y.js";
|
|
629
629
|
import"./index-ea37qn4x.js";
|
|
630
630
|
import {
|
|
631
631
|
formatSynapseLaneDescriptor
|
|
632
|
-
} from "./index-
|
|
633
|
-
import"./index-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
763
|
+
} from "./index-rcenqffj.js";
|
|
764
764
|
import {
|
|
765
765
|
cosineSimilarity
|
|
766
|
-
} from "./index-
|
|
766
|
+
} from "./index-zwbgxt01.js";
|
|
767
767
|
import {
|
|
768
768
|
USER_FACING_FAILURES,
|
|
769
769
|
renderUserFacingFailure,
|
|
@@ -797,7 +797,7 @@ import {
|
|
|
797
797
|
scheduleClearAndReindex,
|
|
798
798
|
clearSessionTracking,
|
|
799
799
|
createAutoSearchDiagnostics
|
|
800
|
-
} from "./index-
|
|
800
|
+
} from "./index-qt711raa.js";
|
|
801
801
|
import"./index-2kmwjq42.js";
|
|
802
802
|
import {
|
|
803
803
|
DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
|
|
@@ -825,11 +825,11 @@ import {
|
|
|
825
825
|
drainPiTagSnapshotSession,
|
|
826
826
|
assertPiTagSnapshotReady,
|
|
827
827
|
ensurePiTagSnapshotReady
|
|
828
|
-
} from "./index-
|
|
828
|
+
} from "./index-jaqdcqwz.js";
|
|
829
829
|
import"./index-cq71g4dk.js";
|
|
830
830
|
import"./index-1cvyaw9a.js";
|
|
831
|
-
import"./index-
|
|
832
|
-
import"./index-
|
|
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.
|
|
3587
|
+
version: "0.49.46",
|
|
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 : {};
|
|
@@ -27373,6 +27374,19 @@ function opencodeReasoningBudgetStatus(messages, budget, prefixBound, proseRatio
|
|
|
27373
27374
|
};
|
|
27374
27375
|
}
|
|
27375
27376
|
|
|
27377
|
+
// ../plugin/src/hooks/magic-context/recovery-fit.ts
|
|
27378
|
+
var RECOVERY_REFUSAL_NOTICE = "Magic Context is still summarizing older history so this conversation fits the model's context window. Send your message again to continue.";
|
|
27379
|
+
var RECOVERY_NO_HISTORY_REFUSAL_NOTICE = "This conversation no longer fits the model's context window, and Magic Context has no more older history it can summarize. Switch to a model with a larger context window to continue.";
|
|
27380
|
+
function recoveryLineTokens(windowTokens) {
|
|
27381
|
+
return Math.floor(windowTokens * BLOCK_UNTIL_DONE_PERCENTAGE / 100);
|
|
27382
|
+
}
|
|
27383
|
+
function recoveryAdmissionLimitTokens(windowTokens, historyRemains) {
|
|
27384
|
+
return historyRemains ? recoveryLineTokens(windowTokens) : Math.floor(windowTokens);
|
|
27385
|
+
}
|
|
27386
|
+
function recoveryRefusalNotice(historyRemains) {
|
|
27387
|
+
return historyRemains ? RECOVERY_REFUSAL_NOTICE : RECOVERY_NO_HISTORY_REFUSAL_NOTICE;
|
|
27388
|
+
}
|
|
27389
|
+
|
|
27376
27390
|
// ../plugin/src/hooks/magic-context/signed-thinking-hold.ts
|
|
27377
27391
|
var HEAVY_REASONING_TOKENS = 1500;
|
|
27378
27392
|
var HEAVY_REASONING_WINDOW_STEPS = 15;
|
|
@@ -27853,7 +27867,7 @@ function resolveUnknownUsageFromWireEstimate(input) {
|
|
|
27853
27867
|
const providerLimit = input.providerProvenLimitTokens;
|
|
27854
27868
|
const canUseProviderMass = input.wireEstimateTrusted === false && typeof providerTokens === "number" && Number.isFinite(providerTokens) && providerTokens > 0 && typeof providerLimit === "number" && Number.isFinite(providerLimit) && providerLimit > 0;
|
|
27855
27869
|
const tokens = canUseProviderMass ? Math.max(wireTokens, providerTokens) : wireTokens;
|
|
27856
|
-
const limit = input.
|
|
27870
|
+
const limit = input.windowTokens;
|
|
27857
27871
|
const estimatedPercentage = typeof limit === "number" && Number.isFinite(limit) && limit > 0 ? tokens / limit * 100 : input.usage.percentage;
|
|
27858
27872
|
return {
|
|
27859
27873
|
inputTokens: tokens,
|
|
@@ -30824,8 +30838,6 @@ ${chunkText}`,
|
|
|
30824
30838
|
clearHistorianDrainFailure(db, sessionId);
|
|
30825
30839
|
recordProtectedTailPublicationFloor(db, sessionId, lastNewEnd + 1);
|
|
30826
30840
|
acknowledgePiHistoryRetirement(db, sessionId, lastNewEnd, (id) => provider.readMessages().find((message) => message.id === id)?.ordinal);
|
|
30827
|
-
if (!isWrapupInProgress(db, sessionId))
|
|
30828
|
-
clearEmergencyRecovery(db, sessionId);
|
|
30829
30841
|
if (lastNewEndMessageId) {
|
|
30830
30842
|
setPendingPiCompactionMarkerState(db, sessionId, {
|
|
30831
30843
|
firstKeptEntryId,
|
|
@@ -35342,6 +35354,16 @@ function repairPiHistoryBoundary(db, sessionId, ctx, branchEntries) {
|
|
|
35342
35354
|
}
|
|
35343
35355
|
|
|
35344
35356
|
// src/native-replay-pi.ts
|
|
35357
|
+
var DROP_PLACEHOLDER = /^\[dropped §\d+§\]$/u;
|
|
35358
|
+
var TAG_LABEL = /^§\d+§ /u;
|
|
35359
|
+
var RESPONSES_APIS = new Set([
|
|
35360
|
+
"openai-responses",
|
|
35361
|
+
"azure-openai-responses",
|
|
35362
|
+
"openai-codex-responses"
|
|
35363
|
+
]);
|
|
35364
|
+
function isPiDropPlaceholder(text) {
|
|
35365
|
+
return DROP_PLACEHOLDER.test(text);
|
|
35366
|
+
}
|
|
35345
35367
|
function getNativeEnvelope(message) {
|
|
35346
35368
|
if (!isRecord(message) || isPiSystemEntry(message))
|
|
35347
35369
|
return;
|
|
@@ -35428,11 +35450,142 @@ function textIdentity(part) {
|
|
|
35428
35450
|
} catch {}
|
|
35429
35451
|
return;
|
|
35430
35452
|
}
|
|
35431
|
-
function
|
|
35453
|
+
function nativeTextSlots(content, items) {
|
|
35454
|
+
const slots = [];
|
|
35455
|
+
for (let itemIndex = 0;itemIndex < items.length; itemIndex++) {
|
|
35456
|
+
const item = items[itemIndex];
|
|
35457
|
+
if (!isRecord(item))
|
|
35458
|
+
return;
|
|
35459
|
+
if (item.type === "reasoning" || item.type === "function_call" || item.type === "custom_tool_call")
|
|
35460
|
+
continue;
|
|
35461
|
+
if (item.type !== "message" || item.role !== "assistant" || !Array.isArray(item.content))
|
|
35462
|
+
return;
|
|
35463
|
+
for (let outputIndex = 0;outputIndex < item.content.length; outputIndex++) {
|
|
35464
|
+
const output = item.content[outputIndex];
|
|
35465
|
+
if (!isRecord(output) || output.type !== "output_text" || typeof output.text !== "string")
|
|
35466
|
+
return;
|
|
35467
|
+
slots.push({ itemIndex, outputIndex, text: output.text });
|
|
35468
|
+
}
|
|
35469
|
+
}
|
|
35470
|
+
const blocks = content.filter((block) => isRecord(block) && block.type === "text").length;
|
|
35471
|
+
return slots.length === blocks ? slots : undefined;
|
|
35472
|
+
}
|
|
35473
|
+
function hookRewrittenSlot(previous, partIndex, items) {
|
|
35474
|
+
const slots = nativeTextSlots(previous, items);
|
|
35475
|
+
if (!slots)
|
|
35476
|
+
return;
|
|
35477
|
+
let ordinal = 0;
|
|
35478
|
+
let target;
|
|
35479
|
+
for (let index = 0;index < previous.length; index++) {
|
|
35480
|
+
const block = previous[index];
|
|
35481
|
+
if (!isRecord(block) || block.type !== "text")
|
|
35482
|
+
continue;
|
|
35483
|
+
const slot = slots[ordinal++];
|
|
35484
|
+
const item = items[slot.itemIndex];
|
|
35485
|
+
if (typeof block.text !== "string")
|
|
35486
|
+
return;
|
|
35487
|
+
if ("textSignature" in block) {
|
|
35488
|
+
const identity = textIdentity(block);
|
|
35489
|
+
if (index === partIndex || !identity || item.id !== identity.id || item.phase !== identity.phase)
|
|
35490
|
+
return;
|
|
35491
|
+
continue;
|
|
35492
|
+
}
|
|
35493
|
+
const stripped = stripPersistedAssistantText(slot.text);
|
|
35494
|
+
if (stripped !== block.text.replace(TAG_LABEL, ""))
|
|
35495
|
+
return;
|
|
35496
|
+
if (index !== partIndex)
|
|
35497
|
+
continue;
|
|
35498
|
+
if (stripped === slot.text || item.content.length !== 1)
|
|
35499
|
+
return;
|
|
35500
|
+
target = slot;
|
|
35501
|
+
}
|
|
35502
|
+
return target;
|
|
35503
|
+
}
|
|
35504
|
+
function emptyAssistantMessage(item) {
|
|
35505
|
+
if (item.type !== "message" || item.role !== "assistant")
|
|
35506
|
+
return false;
|
|
35507
|
+
if (typeof item.content === "string")
|
|
35508
|
+
return !/\S/u.test(item.content);
|
|
35509
|
+
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)));
|
|
35510
|
+
}
|
|
35511
|
+
function replayableNativeItems(message, model) {
|
|
35512
|
+
const payload = message.providerPayload;
|
|
35513
|
+
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)
|
|
35514
|
+
return;
|
|
35515
|
+
return payload.items.some((item) => !isRecord(item) || item.type !== "reasoning" && !emptyAssistantMessage(item)) ? payload.items : undefined;
|
|
35516
|
+
}
|
|
35517
|
+
function signedItemText(block, items) {
|
|
35518
|
+
const identity = textIdentity(block);
|
|
35519
|
+
if (!identity)
|
|
35520
|
+
return;
|
|
35521
|
+
const matches = items.filter((item) => isRecord(item) && item.type === "message" && item.role === "assistant" && item.id === identity.id && item.phase === identity.phase);
|
|
35522
|
+
const outputs = matches.length === 1 && Array.isArray(matches[0].content) ? matches[0].content.filter((output) => isRecord(output) && output.type === "output_text") : [];
|
|
35523
|
+
const text = outputs[0]?.text;
|
|
35524
|
+
return outputs.length === 1 && typeof text === "string" ? text : undefined;
|
|
35525
|
+
}
|
|
35526
|
+
function piNativeDropExpectations(messages, model) {
|
|
35527
|
+
const expectations = [];
|
|
35528
|
+
if (!model || !RESPONSES_APIS.has(String(model.api)))
|
|
35529
|
+
return expectations;
|
|
35530
|
+
for (let index = 0;index < messages.length; index++) {
|
|
35531
|
+
const message = messages[index];
|
|
35532
|
+
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)))
|
|
35533
|
+
continue;
|
|
35534
|
+
const items = replayableNativeItems(message, model);
|
|
35535
|
+
if (!items)
|
|
35536
|
+
continue;
|
|
35537
|
+
const slots = nativeTextSlots(message.content, items);
|
|
35538
|
+
let ordinal = 0;
|
|
35539
|
+
for (const block of message.content) {
|
|
35540
|
+
if (!isRecord(block) || block.type !== "text")
|
|
35541
|
+
continue;
|
|
35542
|
+
const slot = slots?.[ordinal++];
|
|
35543
|
+
if (typeof block.text !== "string" || !isPiDropPlaceholder(block.text))
|
|
35544
|
+
continue;
|
|
35545
|
+
const native = "textSignature" in block ? signedItemText(block, items) : slot?.text;
|
|
35546
|
+
expectations.push({
|
|
35547
|
+
message: index,
|
|
35548
|
+
placeholder: block.text,
|
|
35549
|
+
...native !== undefined && native !== block.text ? { stale: native } : {}
|
|
35550
|
+
});
|
|
35551
|
+
}
|
|
35552
|
+
}
|
|
35553
|
+
return expectations;
|
|
35554
|
+
}
|
|
35555
|
+
function wireAssistantTexts(payload) {
|
|
35556
|
+
const input = isRecord(payload) ? payload.input : undefined;
|
|
35557
|
+
if (!Array.isArray(input))
|
|
35558
|
+
return;
|
|
35559
|
+
const texts = new Set;
|
|
35560
|
+
for (const item of input) {
|
|
35561
|
+
if (!isRecord(item) || item.role !== "assistant")
|
|
35562
|
+
continue;
|
|
35563
|
+
if (typeof item.content === "string")
|
|
35564
|
+
texts.add(item.content);
|
|
35565
|
+
else if (Array.isArray(item.content)) {
|
|
35566
|
+
for (const part of item.content)
|
|
35567
|
+
if (isRecord(part) && typeof part.text === "string")
|
|
35568
|
+
texts.add(part.text);
|
|
35569
|
+
}
|
|
35570
|
+
}
|
|
35571
|
+
return texts;
|
|
35572
|
+
}
|
|
35573
|
+
function piNativeDropWireMismatch(payload, expectations) {
|
|
35574
|
+
if (!expectations?.length)
|
|
35575
|
+
return;
|
|
35576
|
+
const texts = wireAssistantTexts(payload);
|
|
35577
|
+
for (const expected of expectations)
|
|
35578
|
+
if (!texts?.has(expected.placeholder) || expected.stale !== undefined && texts.has(expected.stale))
|
|
35579
|
+
return `message=${expected.message} comparison=native_drop`;
|
|
35580
|
+
return;
|
|
35581
|
+
}
|
|
35582
|
+
function rewriteNativeAssistantTexts(message, previous, sessionId, options = {}) {
|
|
35432
35583
|
const envelope = getNativeEnvelope(message);
|
|
35433
35584
|
if (envelope?.message.role !== "assistant" || !isRecord(previous) || !Array.isArray(previous.content) || !Array.isArray(envelope.message.content))
|
|
35434
35585
|
return;
|
|
35435
35586
|
const content = envelope.message.content;
|
|
35587
|
+
const arrivedItems = envelope.items;
|
|
35588
|
+
const unsignedDrops = options.unsignedDrops === true && RESPONSES_APIS.has(String(envelope.message.api)) && envelope.payload.dt === true;
|
|
35436
35589
|
for (let index = 0;index < content.length; index++) {
|
|
35437
35590
|
const part = content[index];
|
|
35438
35591
|
const before = previous.content[index];
|
|
@@ -35441,6 +35594,23 @@ function rewriteNativeAssistantTexts(message, previous, sessionId) {
|
|
|
35441
35594
|
if (part.text.replace(/^§\d+§ /u, "") === before.text.replace(/^§\d+§ /u, ""))
|
|
35442
35595
|
continue;
|
|
35443
35596
|
const identity = textIdentity(part);
|
|
35597
|
+
if (identity === undefined && unsignedDrops && isPiDropPlaceholder(part.text) && !("textSignature" in part)) {
|
|
35598
|
+
const slot = hookRewrittenSlot(previous.content, index, arrivedItems);
|
|
35599
|
+
if (slot) {
|
|
35600
|
+
const item = envelope.items[slot.itemIndex];
|
|
35601
|
+
const outputs = item.content.slice();
|
|
35602
|
+
outputs[slot.outputIndex] = {
|
|
35603
|
+
...outputs[slot.outputIndex],
|
|
35604
|
+
text: part.text
|
|
35605
|
+
};
|
|
35606
|
+
const items = envelope.items.slice();
|
|
35607
|
+
items[slot.itemIndex] = { ...item, content: outputs };
|
|
35608
|
+
envelope.items = items;
|
|
35609
|
+
envelope.payload = { ...envelope.payload, items };
|
|
35610
|
+
envelope.message.providerPayload = envelope.payload;
|
|
35611
|
+
continue;
|
|
35612
|
+
}
|
|
35613
|
+
}
|
|
35444
35614
|
const sameIdentity = (value) => {
|
|
35445
35615
|
const other = textIdentity(value);
|
|
35446
35616
|
return identity !== undefined && other?.id === identity.id && other.phase === identity.phase;
|
|
@@ -37149,7 +37319,7 @@ function piExplainsOptionalAssistant(thinking, content) {
|
|
|
37149
37319
|
}
|
|
37150
37320
|
|
|
37151
37321
|
// src/pi-dispatch-tool-pairing.ts
|
|
37152
|
-
var
|
|
37322
|
+
var RESPONSES_APIS2 = new Set([
|
|
37153
37323
|
"openai-responses",
|
|
37154
37324
|
"openai-codex-responses",
|
|
37155
37325
|
"azure-openai-responses"
|
|
@@ -37168,7 +37338,7 @@ function piToolCallPairing(messages) {
|
|
|
37168
37338
|
const message = object7(value);
|
|
37169
37339
|
if (message?.role !== "assistant" || !Array.isArray(message.content))
|
|
37170
37340
|
continue;
|
|
37171
|
-
const responses =
|
|
37341
|
+
const responses = RESPONSES_APIS2.has(String(message.api));
|
|
37172
37342
|
for (const part of message.content) {
|
|
37173
37343
|
const block = object7(part);
|
|
37174
37344
|
if (block?.type !== "toolCall" || typeof block.id !== "string")
|
|
@@ -37655,6 +37825,8 @@ function piResponsesAssistantTexts(value, model, host, alternatives, frozenTagSt
|
|
|
37655
37825
|
texts.push(textIdentity2(text, undefined));
|
|
37656
37826
|
continue;
|
|
37657
37827
|
}
|
|
37828
|
+
if (host === "omp" && (block?.type === "image" || block?.type === "anthropicServerTool" || block?.type === "fallback" || block?.type === "redactedThinking" && !sameModel))
|
|
37829
|
+
continue;
|
|
37658
37830
|
if (block?.type !== "text" || typeof block.text !== "string")
|
|
37659
37831
|
return;
|
|
37660
37832
|
units += block.text.length;
|
|
@@ -37693,7 +37865,9 @@ function piResponsesAssistantTexts(value, model, host, alternatives, frozenTagSt
|
|
|
37693
37865
|
output = true;
|
|
37694
37866
|
continue;
|
|
37695
37867
|
}
|
|
37696
|
-
if (item?.type !== "message"
|
|
37868
|
+
if (item?.type !== "message")
|
|
37869
|
+
return;
|
|
37870
|
+
if (item.role !== "assistant" || !Array.isArray(item.content))
|
|
37697
37871
|
return texts;
|
|
37698
37872
|
const itemTexts = [];
|
|
37699
37873
|
for (const value of item.content) {
|
|
@@ -37711,11 +37885,12 @@ function piResponsesAssistantTexts(value, model, host, alternatives, frozenTagSt
|
|
|
37711
37885
|
const signed = signature?.v === 1 && typeof signature.id === "string" && item.id === signature.id && item.phase === signature.phase && part.text === block.text.replace(/^§\d+§ /u, "");
|
|
37712
37886
|
if (!signed) {
|
|
37713
37887
|
const stripped = stripPersistedAssistantText(part.text);
|
|
37714
|
-
|
|
37888
|
+
const droppedPlaceholder = isPiDropPlaceholder(block.text) && part.text === block.text;
|
|
37889
|
+
if (!allowUnsigned || "textSignature" in block || !droppedPlaceholder && stripped !== block.text.replace(/^§\d+§ /u, ""))
|
|
37715
37890
|
return texts;
|
|
37716
37891
|
unsigned = true;
|
|
37717
|
-
allUnsignedFrozen &&= part.text === block.text && ownsNativeResponseTagStrip(frozenTagStrips, item.id, item.phase, part.text);
|
|
37718
|
-
rewrittenText ||= part.text !== stripped;
|
|
37892
|
+
allUnsignedFrozen &&= droppedPlaceholder || part.text === block.text && ownsNativeResponseTagStrip(frozenTagStrips, item.id, item.phase, part.text);
|
|
37893
|
+
rewrittenText ||= !droppedPlaceholder && part.text !== stripped;
|
|
37719
37894
|
}
|
|
37720
37895
|
bound++;
|
|
37721
37896
|
itemTexts.push(part.text);
|
|
@@ -38183,7 +38358,12 @@ function preparePiDispatch(messages, model, omp, cwd) {
|
|
|
38183
38358
|
const reminders = structure && dateReminderPlans.get(structure);
|
|
38184
38359
|
if (reminders)
|
|
38185
38360
|
reminders.cwd = cwd;
|
|
38186
|
-
|
|
38361
|
+
const nativeDrops = omp ? piNativeDropExpectations(output, model) : [];
|
|
38362
|
+
return {
|
|
38363
|
+
messages: output,
|
|
38364
|
+
structure,
|
|
38365
|
+
...nativeDrops.length ? { nativeDrops } : {}
|
|
38366
|
+
};
|
|
38187
38367
|
}
|
|
38188
38368
|
function buildPiPreparedStructure(messages, model, prepareUser, host = "omp") {
|
|
38189
38369
|
if (!messages.length || messages.length > MAX_MESSAGES)
|
|
@@ -40287,6 +40467,7 @@ function releasePiOperationPayloads(operation) {
|
|
|
40287
40467
|
operation.managedSignature = undefined;
|
|
40288
40468
|
operation.cursorRoots = undefined;
|
|
40289
40469
|
operation.preparedStructure = undefined;
|
|
40470
|
+
operation.nativeDrops = undefined;
|
|
40290
40471
|
operation.preparedHistory = undefined;
|
|
40291
40472
|
}
|
|
40292
40473
|
function operationKey(ctx) {
|
|
@@ -40580,6 +40761,9 @@ function registerPiGuardedContext(pi, handler, options = {}) {
|
|
|
40580
40761
|
const fields = piConversationFields(payload);
|
|
40581
40762
|
if (!fields)
|
|
40582
40763
|
throw new Error("provider conversation identity could not be established");
|
|
40764
|
+
const nativeDrop = piNativeDropWireMismatch(checked, active.nativeDrops);
|
|
40765
|
+
if (nativeDrop)
|
|
40766
|
+
throw new Error(`provider request does not match this pass's managed dispatch (prepared turn structure); ${nativeDrop}`);
|
|
40583
40767
|
const body = checked;
|
|
40584
40768
|
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";
|
|
40585
40769
|
if (chained && skipReason)
|
|
@@ -40693,6 +40877,7 @@ function registerPiGuardedContext(pi, handler, options = {}) {
|
|
|
40693
40877
|
if (ctx.model?.api === "cursor-agent")
|
|
40694
40878
|
active.cursorRoots = piCursorManagedRoots(result.messages, active.managedSignature, ctx.cwd);
|
|
40695
40879
|
active.preparedStructure = prepared.structure;
|
|
40880
|
+
active.nativeDrops = prepared.nativeDrops;
|
|
40696
40881
|
if (fenceEnabled && !budget.sideTurn && piChainCapableApi(ctx.model?.api))
|
|
40697
40882
|
active.preparedHistory = piPreparedHistory(result.messages, ctx.model);
|
|
40698
40883
|
budget.completed = true;
|
|
@@ -41729,7 +41914,7 @@ function piRecoveryToolImageTokens(messages) {
|
|
|
41729
41914
|
}
|
|
41730
41915
|
return counts;
|
|
41731
41916
|
}
|
|
41732
|
-
function estimatePiOverflowRecoveryInputTokens(messages, envelope) {
|
|
41917
|
+
function estimatePiOverflowRecoveryInputTokens(messages, envelope, options = {}) {
|
|
41733
41918
|
if (!envelope || !estimatePiOutgoingInputTokens([], envelope).trusted)
|
|
41734
41919
|
return;
|
|
41735
41920
|
const raw = tokenizePiMessages([...messages]);
|
|
@@ -41770,7 +41955,7 @@ function estimatePiOverflowRecoveryInputTokens(messages, envelope) {
|
|
|
41770
41955
|
system: envelope.systemTokens,
|
|
41771
41956
|
tools: envelope.toolDefinitionTokens + raw.toolCall,
|
|
41772
41957
|
prose: raw.conversation
|
|
41773
|
-
}, envelope.calibration ?? calibrationForModelKey(envelope.modelKey), true);
|
|
41958
|
+
}, envelope.calibration ?? calibrationForModelKey(envelope.modelKey), options.fitEnvelope ?? true);
|
|
41774
41959
|
}
|
|
41775
41960
|
function resolvePiOverflowRecoveryUsage(args) {
|
|
41776
41961
|
if (!args.pricedPass || !args.providerOverflow || args.usage.inputTokens > 0)
|
|
@@ -41779,7 +41964,7 @@ function resolvePiOverflowRecoveryUsage(args) {
|
|
|
41779
41964
|
usage: args.usage,
|
|
41780
41965
|
pricedPass: args.pricedPass,
|
|
41781
41966
|
wireEstimateTokens: estimatePiOverflowRecoveryInputTokens(args.messages, args.envelope),
|
|
41782
|
-
|
|
41967
|
+
windowTokens: args.usableHardLimit
|
|
41783
41968
|
});
|
|
41784
41969
|
}
|
|
41785
41970
|
|
|
@@ -43576,9 +43761,10 @@ function createPiTranscript(source, sessionId, entryIds, options = {}) {
|
|
|
43576
43761
|
message.requiresToolArcSkeleton = false;
|
|
43577
43762
|
}
|
|
43578
43763
|
let committed = false;
|
|
43764
|
+
const harness = resolvePiHarnessKind();
|
|
43579
43765
|
return {
|
|
43580
43766
|
messages: transcriptMessages,
|
|
43581
|
-
harness
|
|
43767
|
+
harness,
|
|
43582
43768
|
prepareToolRemovalMeasurements(callIds) {
|
|
43583
43769
|
if (!options.authorizeToolRemovals || callIds.length === 0)
|
|
43584
43770
|
return;
|
|
@@ -43599,7 +43785,9 @@ function createPiTranscript(source, sessionId, entryIds, options = {}) {
|
|
|
43599
43785
|
return;
|
|
43600
43786
|
committed = true;
|
|
43601
43787
|
for (const index of dirtyMessages) {
|
|
43602
|
-
rewriteNativeAssistantTexts(working[index], source[index], sessionId
|
|
43788
|
+
rewriteNativeAssistantTexts(working[index], source[index], sessionId, {
|
|
43789
|
+
unsignedDrops: harness === "omp"
|
|
43790
|
+
});
|
|
43603
43791
|
}
|
|
43604
43792
|
for (const [index, parts] of removals) {
|
|
43605
43793
|
const message = working[index];
|
|
@@ -44191,6 +44379,7 @@ function logPiLkgRecovery(sessionId, message) {
|
|
|
44191
44379
|
var PI_STABLE_ID_SCHEME = 1;
|
|
44192
44380
|
var lastEmergencyNotificationAtMs = new Map;
|
|
44193
44381
|
var EMERGENCY_NOTIFICATION_COOLDOWN_MS = 60000;
|
|
44382
|
+
var untrustedRecoveryCountLoggedSessions = new Set;
|
|
44194
44383
|
var commitSeenLastPass = new Map;
|
|
44195
44384
|
var historyRefreshSessions = new Set;
|
|
44196
44385
|
var systemPromptRefreshSessions = new Set;
|
|
@@ -47106,6 +47295,26 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
47106
47295
|
if (getHarness2() === "pi" && classifyPiOutgoingFit(estimate, outgoingFitLimit) === "over-window-proof")
|
|
47107
47296
|
throw new PiDegradedPassError("outgoing-over-window");
|
|
47108
47297
|
}
|
|
47298
|
+
const recoveryWindow = windowGeometry?.usableHard;
|
|
47299
|
+
const recoveryLatch = !options.compactionOff && isEmergency && emergencyRecoveryArmed && typeof recoveryWindow === "number" && recoveryWindow > 0 ? getOverflowState(options.db, sessionId) : undefined;
|
|
47300
|
+
if (recoveryLatch?.needsEmergencyRecovery === true && recoveryLatch.emergencyRecoveryOrigin !== null && typeof recoveryWindow === "number") {
|
|
47301
|
+
const served = estimatePiOverflowRecoveryInputTokens(outputMessages, readPiLkgFitEnvelope(ctx, pi, resolvePiContextModelKey(ctx), sessionDecisionCalibration(options.db, sessionId), toolWireSchema), { fitEnvelope: false });
|
|
47302
|
+
const historyRemains = inFlightHistorian.has(sessionId);
|
|
47303
|
+
const limit = recoveryAdmissionLimitTokens(recoveryWindow, historyRemains);
|
|
47304
|
+
if (served !== undefined && served > limit) {
|
|
47305
|
+
sessionLog2(sessionId, historyRemains ? `transform: recovery request still over the window: about ${served} tokens against the 95% line ${limit} of ${recoveryWindow}; not sending it, recovery stays armed for the next turn` : `transform: recovery request still over the window: about ${served} tokens against the whole window ${limit}, with no older history left to summarize; not sending it`);
|
|
47306
|
+
throw contextRefusalError(recoveryRefusalNotice(historyRemains));
|
|
47307
|
+
}
|
|
47308
|
+
if (served === undefined) {
|
|
47309
|
+
if (!untrustedRecoveryCountLoggedSessions.has(sessionId)) {
|
|
47310
|
+
untrustedRecoveryCountLoggedSessions.add(sessionId);
|
|
47311
|
+
sessionLog2(sessionId, "transform: recovery request not counted: the fit envelope is untrusted (system prompt or tool definitions not measured yet), so only the byte-count check above applies");
|
|
47312
|
+
}
|
|
47313
|
+
} else {
|
|
47314
|
+
clearEmergencyRecovery(options.db, sessionId);
|
|
47315
|
+
sessionLog2(sessionId, `transform: recovery request admitted: about ${served} tokens, within ${limit} of ${recoveryWindow}; ${recoveryLatch.emergencyRecoveryOrigin} recovery ends`);
|
|
47316
|
+
}
|
|
47317
|
+
}
|
|
47109
47318
|
publishFinalRequestAccounting();
|
|
47110
47319
|
let serializedOutput;
|
|
47111
47320
|
let numbersCommitted = false;
|
|
@@ -49774,6 +49983,7 @@ function clearContextHandlerSession(sessionId) {
|
|
|
49774
49983
|
activeContextHandlerSessions.delete(sessionId);
|
|
49775
49984
|
clearAutoSearchForPiSession(sessionId);
|
|
49776
49985
|
lastEmergencyNotificationAtMs.delete(sessionId);
|
|
49986
|
+
untrustedRecoveryCountLoggedSessions.delete(sessionId);
|
|
49777
49987
|
historyRefreshSessions.delete(sessionId);
|
|
49778
49988
|
clearPendingMaterialization(pendingMaterializationSessions, sessionId);
|
|
49779
49989
|
systemPromptRefreshSessions.delete(sessionId);
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
startMessageFtsRowidMapBackfill2,
|
|
6
6
|
messageFtsOrdinalRangeIsMapped2,
|
|
7
7
|
deleteUnmappedMessageFtsRows2
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
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,8 +3,8 @@ import {
|
|
|
3
3
|
withIndexChunk2,
|
|
4
4
|
yieldIndexChunk2
|
|
5
5
|
} from "./index-2qtx0q6h.js";
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
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";
|
|
@@ -13,9 +13,9 @@ 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-
|
|
16
|
+
import"./index-3g9fnq6y.js";
|
|
17
17
|
import"./index-n0zjvs3h.js";
|
|
18
|
-
import"./index-
|
|
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-
|
|
29
|
-
import"./index-
|
|
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
|
package/dist/migration-worker.js
CHANGED
|
@@ -17,15 +17,15 @@ import"./index-6pk49fc3.js";
|
|
|
17
17
|
import {
|
|
18
18
|
setSqlitePragmaConfig,
|
|
19
19
|
initializeDatabase
|
|
20
|
-
} from "./index-
|
|
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-
|
|
27
|
-
import"./index-
|
|
28
|
-
import"./index-
|
|
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
|
package/dist/{project-embedding-registry-e81zewts.js → project-embedding-registry-ysaezfqw.js}
RENAMED
|
@@ -33,22 +33,22 @@ import {
|
|
|
33
33
|
sweepAllRegisteredProjects2,
|
|
34
34
|
_setTestProviderFactoryForProject2,
|
|
35
35
|
_resetProjectEmbeddingRegistryForTests2
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-rcenqffj.js";
|
|
37
37
|
import"./index-9p40dgkm.js";
|
|
38
38
|
import"./index-hgd00nas.js";
|
|
39
39
|
import"./index-yhzhdp3m.js";
|
|
40
40
|
import"./index-mp0gh04g.js";
|
|
41
|
-
import"./index-
|
|
42
|
-
import"./index-
|
|
43
|
-
import"./index-
|
|
41
|
+
import"./index-4sa1rx3h.js";
|
|
42
|
+
import"./index-tsg6swzr.js";
|
|
43
|
+
import"./index-gwvahsdz.js";
|
|
44
44
|
import"./index-gzk7d940.js";
|
|
45
45
|
import"./index-6pk49fc3.js";
|
|
46
|
-
import"./index-
|
|
47
|
-
import"./index-
|
|
46
|
+
import"./index-bbbp8zs1.js";
|
|
47
|
+
import"./index-3g9fnq6y.js";
|
|
48
48
|
import"./index-wfqysrwq.js";
|
|
49
49
|
import"./index-8sqebjzk.js";
|
|
50
50
|
import"./index-0wtm7g7f.js";
|
|
51
|
-
import"./index-
|
|
51
|
+
import"./index-000fthre.js";
|
|
52
52
|
import"./index-2qtx0q6h.js";
|
|
53
53
|
import"./index-gymgz20n.js";
|
|
54
54
|
import"./index-0h2mkab2.js";
|