@cortexkit/pi-magic-context 0.49.10 → 0.49.11
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 +3 -3
- package/dist/{embedding-backfill-chva00z3.js → embedding-backfill-1tknh2jn.js} +3 -3
- package/dist/{index-rkwh9kce.js → index-0vq6ebae.js} +35 -16
- package/dist/{index-ns319t8e.js → index-2df03yc3.js} +12 -7
- package/dist/{index-qc8e13wc.js → index-78c864c8.js} +1 -1
- package/dist/{index-243wh86p.js → index-9azmm7cg.js} +1 -1
- package/dist/{index-6e3yv1jt.js → index-drah07tf.js} +238 -130
- package/dist/{index-9vzkrnrf.js → index-m8aaepft.js} +23 -19
- package/dist/{index-h160xxaq.js → index-s3c9dskk.js} +2 -2
- package/dist/{index-v26j81w6.js → index-s9kwv5pp.js} +1 -1
- package/dist/index.js +125 -49
- package/dist/{message-index-ejaa9may.js → message-index-5zjmsg57.js} +3 -3
- package/dist/{message-index-bounded-y1c88n9a.js → message-index-bounded-chgr6dn3.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-bxawck58.js → project-embedding-registry-dk5axctd.js} +2 -2
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{read-session-chunk-4094zemt.js → read-session-chunk-3kb7r5pq.js} +1 -1
- package/dist/{search-hsr95vex.js → search-8pczyejh.js} +6 -6
- package/dist/subagent-entry.js +8 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -154,7 +154,7 @@ import {
|
|
|
154
154
|
noteTouchedAt,
|
|
155
155
|
noteNudgePickIndex,
|
|
156
156
|
formatNoteNudge,
|
|
157
|
-
|
|
157
|
+
systemPromptFingerprint,
|
|
158
158
|
createPromptSurfaceRuntime,
|
|
159
159
|
createPromptSurfaceGuidanceEpochCache,
|
|
160
160
|
SYNTH_USER_ID_PREFIX,
|
|
@@ -250,7 +250,7 @@ import {
|
|
|
250
250
|
registerTodoStateLifecycle,
|
|
251
251
|
syncCtxMemoryToolEnabled,
|
|
252
252
|
registerMagicContextTools
|
|
253
|
-
} from "./index-
|
|
253
|
+
} from "./index-0vq6ebae.js";
|
|
254
254
|
import {
|
|
255
255
|
canonicalModelIdentity,
|
|
256
256
|
piModelRefToCanonical,
|
|
@@ -290,7 +290,7 @@ import {
|
|
|
290
290
|
openCurrentDatabase,
|
|
291
291
|
openDatabaseAsync,
|
|
292
292
|
closeDatabase
|
|
293
|
-
} from "./index-
|
|
293
|
+
} from "./index-9azmm7cg.js";
|
|
294
294
|
import {
|
|
295
295
|
setHomeProjectPermission,
|
|
296
296
|
ProjectIdentityError,
|
|
@@ -460,7 +460,7 @@ import {
|
|
|
460
460
|
getRawSessionTagKeysThrough2,
|
|
461
461
|
getLegacyProtectedTailStartOrdinal2,
|
|
462
462
|
readSessionChunk2
|
|
463
|
-
} from "./index-
|
|
463
|
+
} from "./index-m8aaepft.js";
|
|
464
464
|
import {
|
|
465
465
|
UNKNOWN_FIT_RATIO,
|
|
466
466
|
hasMeasuredDecisionCalibration,
|
|
@@ -622,7 +622,7 @@ import {
|
|
|
622
622
|
indexSingleMessage2,
|
|
623
623
|
indexMessagesAfterOrdinal2,
|
|
624
624
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
625
|
-
} from "./index-
|
|
625
|
+
} from "./index-s3c9dskk.js";
|
|
626
626
|
import {
|
|
627
627
|
formatSynapseLaneDescriptor
|
|
628
628
|
} from "./index-szh001qb.js";
|
|
@@ -638,7 +638,7 @@ import {
|
|
|
638
638
|
replaceCompartmentChunkEmbeddings,
|
|
639
639
|
deleteChunkEmbedBackoffForSession,
|
|
640
640
|
chunkWindowSourceKey
|
|
641
|
-
} from "./index-
|
|
641
|
+
} from "./index-drah07tf.js";
|
|
642
642
|
import {
|
|
643
643
|
recordSessionProjectIdentity,
|
|
644
644
|
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
@@ -663,7 +663,7 @@ import {
|
|
|
663
663
|
embedSessionCompartmentChunks2,
|
|
664
664
|
getEmbeddingCoverageStatus2,
|
|
665
665
|
getAutoEmbeddingSessionCoverage2
|
|
666
|
-
} from "./index-
|
|
666
|
+
} from "./index-78c864c8.js";
|
|
667
667
|
import {
|
|
668
668
|
rememberV1HiddenRun
|
|
669
669
|
} from "./index-6x556c2q.js";
|
|
@@ -728,7 +728,7 @@ import {
|
|
|
728
728
|
normalizeVerificationFiles,
|
|
729
729
|
indexCommitsForProject,
|
|
730
730
|
embedUnembeddedCommits
|
|
731
|
-
} from "./index-
|
|
731
|
+
} from "./index-2df03yc3.js";
|
|
732
732
|
import {
|
|
733
733
|
setEmbeddingSessionBusy2,
|
|
734
734
|
isEmbeddingHostBusy2
|
|
@@ -762,7 +762,7 @@ import {
|
|
|
762
762
|
import"./index-8yjhda46.js";
|
|
763
763
|
import {
|
|
764
764
|
cosineSimilarity
|
|
765
|
-
} from "./index-
|
|
765
|
+
} from "./index-s9kwv5pp.js";
|
|
766
766
|
import"./index-729kkhmf.js";
|
|
767
767
|
import {
|
|
768
768
|
buildHiddenAgentRegistrations,
|
|
@@ -3432,7 +3432,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3432
3432
|
// package.json
|
|
3433
3433
|
var package_default = {
|
|
3434
3434
|
name: "@cortexkit/pi-magic-context",
|
|
3435
|
-
version: "0.49.
|
|
3435
|
+
version: "0.49.11",
|
|
3436
3436
|
type: "module",
|
|
3437
3437
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3438
3438
|
main: "dist/index.js",
|
|
@@ -5682,6 +5682,14 @@ function formatRunTokenLog(tokens) {
|
|
|
5682
5682
|
return `tokens=${JSON.stringify(tokens)}`;
|
|
5683
5683
|
}
|
|
5684
5684
|
|
|
5685
|
+
// ../plugin/src/features/magic-context/memory-enabled.ts
|
|
5686
|
+
function isProjectMemoryEnabled(enabled) {
|
|
5687
|
+
return enabled !== false;
|
|
5688
|
+
}
|
|
5689
|
+
function readEnabledProjectMemories(enabled, read) {
|
|
5690
|
+
return isProjectMemoryEnabled(enabled) ? read() : [];
|
|
5691
|
+
}
|
|
5692
|
+
|
|
5685
5693
|
// ../plugin/src/hooks/magic-context/historian-prompt.generated.ts
|
|
5686
5694
|
var COMPARTMENT_AGENT_SYSTEM_PROMPT = `# Historian
|
|
5687
5695
|
|
|
@@ -6564,8 +6572,7 @@ function buildCompartmentAgentPrompt(inputs) {
|
|
|
6564
6572
|
parts.push(inputs.seedExamples);
|
|
6565
6573
|
if (inputs.sessionReferences)
|
|
6566
6574
|
parts.push(inputs.sessionReferences);
|
|
6567
|
-
|
|
6568
|
-
parts.push(inputs.projectMemory);
|
|
6575
|
+
parts.push(...readEnabledProjectMemories(inputs.memoryEnabled, () => inputs.projectMemory ? [inputs.projectMemory] : []));
|
|
6569
6576
|
if (inputs.extractionFree) {
|
|
6570
6577
|
parts.push(`<extraction>disabled</extraction>
|
|
6571
6578
|
Structural recomp mode: emit compartments and <meta> only. Do NOT emit <facts>, <events>, <user_observations>, or <primer_candidates>.`);
|
|
@@ -6890,7 +6897,7 @@ ${HISTORIAN_TRUNCATION_MARKER}
|
|
|
6890
6897
|
function fitAtomicHistorianSourceToProducerWindow(args) {
|
|
6891
6898
|
const producerInputLimitTokens = producerInputTokenLimit(args.contextLimitTokens, args.maxOutputTokens, args.inputLimitTokens);
|
|
6892
6899
|
const originalTokens = estimateTokens(args.text);
|
|
6893
|
-
const target = producerInputLimitTokens === undefined ?
|
|
6900
|
+
const target = producerInputLimitTokens === undefined ? args.maxSourceTokens : Math.min(producerInputLimitTokens, args.maxSourceTokens ?? Infinity);
|
|
6894
6901
|
if (target === undefined || originalTokens < target || target <= 0) {
|
|
6895
6902
|
return { text: args.text, producerInputLimitTokens, removedTokens: 0 };
|
|
6896
6903
|
}
|
|
@@ -8790,7 +8797,7 @@ function fitHistorianPrompt(args) {
|
|
|
8790
8797
|
const requested = Math.max(0, Math.floor(args.requestedChunkTokens));
|
|
8791
8798
|
const seeds = selectSeeds(args.sessionId, args.chunkStart);
|
|
8792
8799
|
const references = selectSessionReferences(args.sessionCompartments, seeds, args.sessionId, args.chunkStart);
|
|
8793
|
-
const memories = orderHistorianMemories(args.memories);
|
|
8800
|
+
const memories = orderHistorianMemories(readEnabledProjectMemories(args.memoryEnabled, () => typeof args.memories === "function" ? args.memories() : args.memories));
|
|
8794
8801
|
const render = (refs, memoryCount, seedCount) => ({
|
|
8795
8802
|
seedExamples: renderSeedExamplesBlock(seeds.slice(0, seedCount)),
|
|
8796
8803
|
sessionReferences: renderSessionReferencesBlock(references, refs),
|
|
@@ -8803,26 +8810,38 @@ function fitHistorianPrompt(args) {
|
|
|
8803
8810
|
seeds: seedCount,
|
|
8804
8811
|
seedsTotal: seeds.length
|
|
8805
8812
|
});
|
|
8806
|
-
|
|
8807
|
-
|
|
8813
|
+
let systemLocal;
|
|
8814
|
+
const fitLimitFor = (window) => {
|
|
8815
|
+
const limit = producerInputTokenLimit(window.contextLimitTokens, window.maxOutputTokens, window.inputLimitTokens);
|
|
8816
|
+
if (limit === undefined)
|
|
8817
|
+
return;
|
|
8818
|
+
const calibration = calibrationForModelKey(window.modelKey);
|
|
8819
|
+
systemLocal ??= estimateFixedPromptTokens(args.systemPrompt);
|
|
8820
|
+
const system = systemLocal;
|
|
8808
8821
|
return {
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
...render(references.length, memories.length, seeds.length),
|
|
8813
|
-
trimmed: false,
|
|
8814
|
-
kept: kept(references.length, memories.length, seeds.length)
|
|
8822
|
+
modelKey: window.modelKey,
|
|
8823
|
+
limit,
|
|
8824
|
+
mass: (proseLocal) => providerMass({ prose: proseLocal, system }, calibration, true)
|
|
8815
8825
|
};
|
|
8816
|
-
}
|
|
8817
|
-
const
|
|
8818
|
-
|
|
8819
|
-
const mass = (proseLocal) => providerMass({ prose: proseLocal, system: systemLocal }, calibration, true);
|
|
8820
|
-
if (!Number.isFinite(mass(0)) || mass(0) <= 0) {
|
|
8826
|
+
};
|
|
8827
|
+
const primary = fitLimitFor(args.window);
|
|
8828
|
+
if (primary && (!Number.isFinite(primary.mass(0)) || primary.mass(0) <= 0)) {
|
|
8821
8829
|
return {
|
|
8822
8830
|
ok: false,
|
|
8823
8831
|
reason: `producer_prompt_fit_unavailable model=${args.window.modelKey ?? "unknown"}`
|
|
8824
8832
|
};
|
|
8825
8833
|
}
|
|
8834
|
+
const fallbackLimits = (args.fallbackWindows ?? []).map(fitLimitFor).filter((entry) => entry !== undefined && Number.isFinite(entry.mass(0)) && entry.mass(0) > 0);
|
|
8835
|
+
const unguarded = () => ({
|
|
8836
|
+
ok: true,
|
|
8837
|
+
guarded: false,
|
|
8838
|
+
chunkTokens: requested,
|
|
8839
|
+
...render(references.length, memories.length, seeds.length),
|
|
8840
|
+
trimmed: false,
|
|
8841
|
+
kept: kept(references.length, memories.length, seeds.length)
|
|
8842
|
+
});
|
|
8843
|
+
if (!primary && fallbackLimits.length === 0)
|
|
8844
|
+
return unguarded();
|
|
8826
8845
|
const chunkHeader = `Messages ${args.chunkStart}-${args.lastOrdinal}:
|
|
8827
8846
|
|
|
8828
8847
|
`;
|
|
@@ -8841,8 +8860,7 @@ function fitHistorianPrompt(args) {
|
|
|
8841
8860
|
}
|
|
8842
8861
|
return tokens;
|
|
8843
8862
|
};
|
|
8844
|
-
const
|
|
8845
|
-
const fixed = fixedLocal(blocks);
|
|
8863
|
+
const roomUnder = ({ mass, limit }, fixed) => {
|
|
8846
8864
|
if (mass(fixed) > limit)
|
|
8847
8865
|
return -1;
|
|
8848
8866
|
let lo = 0;
|
|
@@ -8858,8 +8876,29 @@ function fitHistorianPrompt(args) {
|
|
|
8858
8876
|
else
|
|
8859
8877
|
hi = mid;
|
|
8860
8878
|
}
|
|
8861
|
-
return
|
|
8879
|
+
return lo;
|
|
8880
|
+
};
|
|
8881
|
+
const roomAmong = (limits, blocks) => {
|
|
8882
|
+
const fixed = fixedLocal(blocks);
|
|
8883
|
+
let room = Infinity;
|
|
8884
|
+
for (const entry of limits) {
|
|
8885
|
+
const one = roomUnder(entry, fixed);
|
|
8886
|
+
if (one < 0)
|
|
8887
|
+
return -1;
|
|
8888
|
+
room = Math.min(room, one);
|
|
8889
|
+
}
|
|
8890
|
+
return Math.max(0, room - FIT_SLACK_TOKENS);
|
|
8862
8891
|
};
|
|
8892
|
+
const floor = Math.min(requested, HISTORIAN_MIN_FIT_CHUNK_TOKENS);
|
|
8893
|
+
const sizedFor = primary ? [primary] : [];
|
|
8894
|
+
for (const entry of fallbackLimits) {
|
|
8895
|
+
const alone = roomAmong([entry], render(0, 0, 0));
|
|
8896
|
+
if (alone >= floor && alone > 0)
|
|
8897
|
+
sizedFor.push(entry);
|
|
8898
|
+
}
|
|
8899
|
+
if (sizedFor.length === 0)
|
|
8900
|
+
return unguarded();
|
|
8901
|
+
const roomFor = (blocks) => roomAmong(sizedFor, blocks);
|
|
8863
8902
|
const accept = (refs, memoryCount, seedCount, chunkTokens) => ({
|
|
8864
8903
|
ok: true,
|
|
8865
8904
|
guarded: true,
|
|
@@ -8891,16 +8930,16 @@ function fitHistorianPrompt(args) {
|
|
|
8891
8930
|
return accept(0, 0, seedCount, requested);
|
|
8892
8931
|
}
|
|
8893
8932
|
}
|
|
8894
|
-
const floor = Math.min(requested, HISTORIAN_MIN_FIT_CHUNK_TOKENS);
|
|
8895
8933
|
const room = roomFor(render(0, 0, 0));
|
|
8896
8934
|
if (room >= floor && room > 0)
|
|
8897
8935
|
return accept(0, 0, 0, Math.min(requested, room));
|
|
8898
|
-
const
|
|
8936
|
+
const refused = sizedFor[0];
|
|
8937
|
+
const fixedTokens = refused.mass(fixedLocal(render(0, 0, 0), `Messages 1-1:
|
|
8899
8938
|
|
|
8900
8939
|
`));
|
|
8901
8940
|
return {
|
|
8902
8941
|
ok: false,
|
|
8903
|
-
reason: `producer_prompt_unfit model=${
|
|
8942
|
+
reason: `producer_prompt_unfit model=${refused.modelKey ?? "unknown"} limit=${refused.limit} fixed_tokens=${fixedTokens} min_chunk_tokens=${floor}`
|
|
8904
8943
|
};
|
|
8905
8944
|
}
|
|
8906
8945
|
|
|
@@ -18325,6 +18364,8 @@ async function runManualDream(deps) {
|
|
|
18325
18364
|
} else {
|
|
18326
18365
|
selected = deps.tasks.filter((t) => t.schedule.trim() !== "");
|
|
18327
18366
|
}
|
|
18367
|
+
if (!isProjectMemoryEnabled(deps.projectMemoryEnabled))
|
|
18368
|
+
selected = selected.filter((config) => config.task === "evaluate-smart-notes");
|
|
18328
18369
|
if (selected.length === 0)
|
|
18329
18370
|
return result;
|
|
18330
18371
|
const selectedTaskNames = selected.map((config) => config.task);
|
|
@@ -18390,7 +18431,7 @@ async function runManualDream(deps) {
|
|
|
18390
18431
|
async function runDueTasksForProject(deps) {
|
|
18391
18432
|
if (!isUsableProjectIdentity(deps.projectIdentity))
|
|
18392
18433
|
return 0;
|
|
18393
|
-
if (deps.projectMemoryEnabled
|
|
18434
|
+
if (!isProjectMemoryEnabled(deps.projectMemoryEnabled))
|
|
18394
18435
|
return 0;
|
|
18395
18436
|
const now = deps.now ?? Date.now();
|
|
18396
18437
|
const due = planDueTasks(deps.db, deps.projectIdentity, deps.tasks, now);
|
|
@@ -19113,7 +19154,7 @@ function scheduleInitialProjectRun(reg, db) {
|
|
|
19113
19154
|
async function runProjectMaintenance(reg, origin, db) {
|
|
19114
19155
|
const sampled = reg.sampleDreamRun?.();
|
|
19115
19156
|
const current = sampled ? { ...reg, ...sampled } : reg;
|
|
19116
|
-
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true ||
|
|
19157
|
+
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || current.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
19117
19158
|
if (!projectMaintenanceEnabled)
|
|
19118
19159
|
return;
|
|
19119
19160
|
await reg.ensureRegistered(reg.directory, db);
|
|
@@ -19124,7 +19165,7 @@ async function runProjectMaintenance(reg, origin, db) {
|
|
|
19124
19165
|
log2(`[magic-context] proactively embedded ${embeddedCount} ${embeddedCount === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
|
|
19125
19166
|
}
|
|
19126
19167
|
}
|
|
19127
|
-
await sweepProject(current, origin, db);
|
|
19168
|
+
await sweepProject(current, origin, db, current.gitCommitIndexing?.enabled === true);
|
|
19128
19169
|
}
|
|
19129
19170
|
async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
19130
19171
|
if (!directoryStillExists(reg.directory)) {
|
|
@@ -21774,7 +21815,7 @@ var piSubagentRunnerFactory = () => new PiSubagentRunner;
|
|
|
21774
21815
|
var startDreamScheduleTimerFn = startDreamScheduleTimer;
|
|
21775
21816
|
function registerPiDreamerProject(opts) {
|
|
21776
21817
|
const directory = resolve2(opts.projectDir);
|
|
21777
|
-
if (
|
|
21818
|
+
if (!isUsableProjectIdentity(opts.projectIdentity) || directory === parse(directory).root || directory === homedir2()) {
|
|
21778
21819
|
return;
|
|
21779
21820
|
}
|
|
21780
21821
|
const existing = registeredProjects2.get(opts.projectIdentity);
|
|
@@ -21838,11 +21879,15 @@ function registerPiDreamerProject(opts) {
|
|
|
21838
21879
|
}
|
|
21839
21880
|
const sampled = manualOpts.sampleDreamRun?.();
|
|
21840
21881
|
const dreamerConfig = sampled?.dreamerConfig ?? manualOpts.config;
|
|
21882
|
+
if (dreamerConfig.disable === true) {
|
|
21883
|
+
throw new Error(`Pi dreamer is disabled for project ${opts.projectIdentity}`);
|
|
21884
|
+
}
|
|
21841
21885
|
const mural = sampled?.mural ?? manualOpts.mural;
|
|
21842
21886
|
const manualClient = createPiDreamerClient(manualOpts, notifyOwnersOfAdjunctRefresh, () => owners.get(manualOpts.registrationOwner)?.projectDir === manualOpts.projectDir, () => dreamerConfig.maxTokens, () => dreamerConfig);
|
|
21843
21887
|
const manualRun = runManualDream({
|
|
21844
21888
|
db: manualOpts.db,
|
|
21845
21889
|
projectIdentity: manualOpts.projectIdentity,
|
|
21890
|
+
projectMemoryEnabled: manualOpts.memoryEnabled,
|
|
21846
21891
|
tasks: manualOpts.modelRegistry ? validatePiDreamerModels(buildDreamTaskRuntimeConfigs(dreamerConfig, manualOpts.harness, manualOpts.language, manualOpts.smartNotesEnabled), manualOpts.modelRegistry, manualOpts.harness) : buildDreamTaskRuntimeConfigs(dreamerConfig, manualOpts.harness, manualOpts.language, manualOpts.smartNotesEnabled),
|
|
21847
21892
|
executor: createDreamTaskExecutor({
|
|
21848
21893
|
client: manualClient,
|
|
@@ -23428,6 +23473,11 @@ var pendingDecisionBySession = new Map;
|
|
|
23428
23473
|
var pendingPiDecisionBySession = new Map;
|
|
23429
23474
|
var lastBoundMessageIdBySession = new Map;
|
|
23430
23475
|
var scheduledWriteTokensBySession = new Map;
|
|
23476
|
+
var systemHashChangedSessions = new Set;
|
|
23477
|
+
var piSystemHashChangedSessions = new Set;
|
|
23478
|
+
var unbustedPassBySession = new Map;
|
|
23479
|
+
var newestInputAssistantBySession = new Map;
|
|
23480
|
+
var stagedV2DecisionBySession = new Map;
|
|
23431
23481
|
var writerOverrideForTests = null;
|
|
23432
23482
|
var retentionOverrideForTests = null;
|
|
23433
23483
|
function normalizeMaterializeReason(harness, reason, rematerialized) {
|
|
@@ -23442,12 +23492,28 @@ function normalizeMaterializeReason(harness, reason, rematerialized) {
|
|
|
23442
23492
|
}
|
|
23443
23493
|
return rematerialized ? "pressure_refold" : null;
|
|
23444
23494
|
}
|
|
23495
|
+
function notePiSystemPromptHashChange(sessionId) {
|
|
23496
|
+
piSystemHashChangedSessions.add(sessionId);
|
|
23497
|
+
}
|
|
23498
|
+
function hasPendingPiSystemPromptHashChange(sessionId) {
|
|
23499
|
+
return piSystemHashChangedSessions.has(sessionId);
|
|
23500
|
+
}
|
|
23501
|
+
var IDLE_EXPIRY_REASONS = new Set([
|
|
23502
|
+
"ttl_idle",
|
|
23503
|
+
"ttl_expiry"
|
|
23504
|
+
]);
|
|
23505
|
+
function withSystemHashReason(decision) {
|
|
23506
|
+
if (IDLE_EXPIRY_REASONS.has(decision.materializeReason))
|
|
23507
|
+
return decision;
|
|
23508
|
+
return { ...decision, materializeReason: "system_hash" };
|
|
23509
|
+
}
|
|
23445
23510
|
function recordPendingPiTransformDecision(sessionId, decision, snapshotNewestAssistantEntryId, publicationGuard) {
|
|
23446
23511
|
publicationGuard?.();
|
|
23447
|
-
|
|
23512
|
+
const systemHashChanged = piSystemHashChangedSessions.delete(sessionId);
|
|
23513
|
+
if (!decision.bustedThisPass && !systemHashChanged)
|
|
23448
23514
|
return;
|
|
23449
23515
|
pendingPiDecisionBySession.set(sessionId, {
|
|
23450
|
-
...decision,
|
|
23516
|
+
...systemHashChanged ? withSystemHashReason(decision) : decision,
|
|
23451
23517
|
snapshotNewestAssistantEntryId,
|
|
23452
23518
|
publicationGuard
|
|
23453
23519
|
});
|
|
@@ -28218,22 +28284,33 @@ async function runPiHistorian(deps) {
|
|
|
28218
28284
|
return;
|
|
28219
28285
|
}
|
|
28220
28286
|
const projectPath = resolveProjectIdentityForSession(directory, allowHomeProject);
|
|
28221
|
-
const memories = projectPath ? getMemoriesByProject2(db, projectPath, ["active", "permanent"]) : [];
|
|
28222
28287
|
const fitModelKey = piModelRefToCanonical(historianModel ?? "");
|
|
28223
28288
|
const fitContext = fitModelKey ? resolveProducerContextLimit(fitModelKey) : undefined;
|
|
28289
|
+
const fallbackWindows = [
|
|
28290
|
+
...(fallbackModels ?? []).map((entry) => typeof entry === "string" ? entry : entry.model),
|
|
28291
|
+
fallbackModelId
|
|
28292
|
+
].map((model) => model ? piModelRefToCanonical(model) : "").filter((key) => key.length > 0 && key !== fitModelKey).map((key) => {
|
|
28293
|
+
const context = resolveProducerContextLimit(key);
|
|
28294
|
+
return {
|
|
28295
|
+
modelKey: key,
|
|
28296
|
+
contextLimitTokens: context,
|
|
28297
|
+
maxOutputTokens: historianProducerReserve(context, maxOutputTokens, deps.resolveHostOutputLimit?.(key))
|
|
28298
|
+
};
|
|
28299
|
+
});
|
|
28224
28300
|
const promptFit = fitHistorianPrompt({
|
|
28225
28301
|
window: {
|
|
28226
28302
|
modelKey: fitModelKey || undefined,
|
|
28227
28303
|
contextLimitTokens: fitContext,
|
|
28228
28304
|
maxOutputTokens: historianProducerReserve(fitContext, maxOutputTokens, deps.resolveHostOutputLimit?.(fitModelKey))
|
|
28229
28305
|
},
|
|
28306
|
+
fallbackWindows,
|
|
28230
28307
|
systemPrompt: historianSystemPrompt,
|
|
28231
28308
|
requestedChunkTokens: historianChunkTokens,
|
|
28232
28309
|
sessionId,
|
|
28233
28310
|
chunkStart: Math.max(1, offset),
|
|
28234
28311
|
lastOrdinal: eligibleEndOrdinal - 1,
|
|
28235
28312
|
sessionCompartments: priorCompartments,
|
|
28236
|
-
memories,
|
|
28313
|
+
memories: () => projectPath ? getMemoriesByProject2(db, projectPath, ["active", "permanent"]) : [],
|
|
28237
28314
|
memoryEnabled: memoryEnabled !== false
|
|
28238
28315
|
});
|
|
28239
28316
|
if (!promptFit.ok) {
|
|
@@ -39542,9 +39619,6 @@ function stripPiProcessedImages(args) {
|
|
|
39542
39619
|
return { stripped, newlyStrippedIds };
|
|
39543
39620
|
}
|
|
39544
39621
|
|
|
39545
|
-
// src/system-prompt.ts
|
|
39546
|
-
import { createHash as createHash17 } from "node:crypto";
|
|
39547
|
-
|
|
39548
39622
|
// ../plugin/src/hooks/magic-context/system-prompt-dates.ts
|
|
39549
39623
|
function replaceHostDates(prompt, replace) {
|
|
39550
39624
|
const fields = /<(plugin-env|environment|env)>[\s\S]*?<\/\1>|Today's date: [^\r\n<]+/g;
|
|
@@ -39665,7 +39739,7 @@ function processSystemPromptForCache(args) {
|
|
|
39665
39739
|
const dates = systemPromptDates(systemPrompt, stickyDate);
|
|
39666
39740
|
const liveDate = dates.live;
|
|
39667
39741
|
const stableCandidate = dates.stable;
|
|
39668
|
-
const stableCandidateHash =
|
|
39742
|
+
const stableCandidateHash = systemPromptFingerprint(stableCandidate, args.promptSurfacePreset);
|
|
39669
39743
|
const contentOrPresetChanged = !isFirstHash && stableCandidateHash !== previousHash;
|
|
39670
39744
|
const idleCacheExpired = sessionMeta !== undefined && computeHardCacheExpired(sessionMeta.cacheTtl, sessionMeta.lastResponseTime, Date.now());
|
|
39671
39745
|
const dateMayAdvance = isCacheBusting || idleCacheExpired || contentOrPresetChanged;
|
|
@@ -39680,7 +39754,7 @@ function processSystemPromptForCache(args) {
|
|
|
39680
39754
|
sessionLog2(sessionId, `system prompt date frozen: real=${liveDate}, using=${stickyDate} (cache-stable pass)`);
|
|
39681
39755
|
}
|
|
39682
39756
|
}
|
|
39683
|
-
const currentHash =
|
|
39757
|
+
const currentHash = systemPromptFingerprint(frozenPrompt, args.promptSurfacePreset);
|
|
39684
39758
|
const hashChanged = !isFirstHash && currentHash !== previousHash;
|
|
39685
39759
|
if (hashChanged) {
|
|
39686
39760
|
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${frozenPrompt.length})`);
|
|
@@ -40361,6 +40435,7 @@ function signalPiSystemHashChange(sessionId, hash) {
|
|
|
40361
40435
|
signalPiSystemPromptRefresh(sessionId);
|
|
40362
40436
|
if (!pendingMaterializationSessions.has(sessionId))
|
|
40363
40437
|
signalPiPendingMaterialization(sessionId, "system_hash");
|
|
40438
|
+
notePiSystemPromptHashChange(sessionId);
|
|
40364
40439
|
}
|
|
40365
40440
|
function deferPiDeliveredSystemRefresh(sessionId, ownsHistory) {
|
|
40366
40441
|
deferDeliveredSystemRefresh({
|
|
@@ -42613,7 +42688,7 @@ function registerPiContextHandler(pi, baseOptions) {
|
|
|
42613
42688
|
assertCurrentPass();
|
|
42614
42689
|
recordSuccessfulTaggedMessageIds(sessionId, taggedInputEntryIds ?? strictEntryIds, branchEntries);
|
|
42615
42690
|
}
|
|
42616
|
-
const piDecisionSnapshotNewestAssistant = result.bustedThisPass ? findNewestPiAssistantEntryId(branchEntries) : undefined;
|
|
42691
|
+
const piDecisionSnapshotNewestAssistant = result.bustedThisPass || hasPendingPiSystemPromptHashChange(sessionId) ? findNewestPiAssistantEntryId(branchEntries) : undefined;
|
|
42617
42692
|
const publishTransformDecision = !budget.sideTurn && piDecisionSnapshotNewestAssistant !== undefined ? () => {
|
|
42618
42693
|
recordPendingPiTransformDecision(sessionId, {
|
|
42619
42694
|
tsMs: Date.now(),
|
|
@@ -49609,7 +49684,8 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
|
|
|
49609
49684
|
return;
|
|
49610
49685
|
}
|
|
49611
49686
|
seenDreamerProjectIdentities.add(current.projectIdentity);
|
|
49612
|
-
|
|
49687
|
+
const timerConfig = current.dreamerConfig ?? current.config.dreamer;
|
|
49688
|
+
if (!timerConfig) {
|
|
49613
49689
|
unregisterPiDreamerProject({
|
|
49614
49690
|
projectIdentity: current.projectIdentity,
|
|
49615
49691
|
registrationOwner: dreamerRegistrationOwner
|
|
@@ -49621,7 +49697,7 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
|
|
|
49621
49697
|
projectDir: current.projectDir,
|
|
49622
49698
|
projectIdentity: current.projectIdentity,
|
|
49623
49699
|
registrationOwner: dreamerRegistrationOwner,
|
|
49624
|
-
config:
|
|
49700
|
+
config: timerConfig,
|
|
49625
49701
|
modelRegistry,
|
|
49626
49702
|
sampleDreamRun: () => {
|
|
49627
49703
|
const fresh = liveReaderFor(current.projectDir, current.config).poll().effective;
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
indexMessagesAfterOrdinal2,
|
|
18
18
|
indexSourcesAfterOrdinal2,
|
|
19
19
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
20
|
-
} from "./index-
|
|
21
|
-
import"./index-
|
|
22
|
-
import"./index-
|
|
20
|
+
} from "./index-s3c9dskk.js";
|
|
21
|
+
import"./index-drah07tf.js";
|
|
22
|
+
import"./index-m8aaepft.js";
|
|
23
23
|
import"./index-x7426vy4.js";
|
|
24
24
|
import"./index-4vj37yw9.js";
|
|
25
25
|
import"./index-399p688g.js";
|
|
@@ -12,7 +12,7 @@ import"./index-ta0ed2nc.js";
|
|
|
12
12
|
import"./index-399p688g.js";
|
|
13
13
|
import"./index-4vj37yw9.js";
|
|
14
14
|
import"./index-8976mezv.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-m8aaepft.js";
|
|
16
16
|
import"./index-6x556c2q.js";
|
|
17
17
|
import {
|
|
18
18
|
MESSAGE_INDEX_MAX_FTS_BYTES2,
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
markMessageIndexDirty2,
|
|
22
22
|
getIndexableContent2,
|
|
23
23
|
indexSingleMessage2
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-s3c9dskk.js";
|
|
25
25
|
import"./index-fdxzpnbj.js";
|
|
26
26
|
import"./index-3veejgp8.js";
|
|
27
27
|
import"./index-szh001qb.js";
|
|
28
|
-
import"./index-
|
|
28
|
+
import"./index-drah07tf.js";
|
|
29
29
|
import"./index-43zqh10z.js";
|
|
30
30
|
|
|
31
31
|
// ../plugin/src/features/magic-context/message-index-bounded.ts
|
package/dist/migration-worker.js
CHANGED
package/dist/{project-embedding-registry-bxawck58.js → project-embedding-registry-dk5axctd.js}
RENAMED
|
@@ -33,9 +33,9 @@ import {
|
|
|
33
33
|
sweepAllRegisteredProjects2,
|
|
34
34
|
_setTestProviderFactoryForProject2,
|
|
35
35
|
_resetProjectEmbeddingRegistryForTests2
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-78c864c8.js";
|
|
37
37
|
import"./index-9p40dgkm.js";
|
|
38
|
-
import"./index-
|
|
38
|
+
import"./index-drah07tf.js";
|
|
39
39
|
import"./index-yhzhdp3m.js";
|
|
40
40
|
import"./index-8yjhda46.js";
|
|
41
41
|
import"./index-szh001qb.js";
|
|
@@ -30,7 +30,7 @@ try {
|
|
|
30
30
|
{ configureContextDatabasePragmas }
|
|
31
31
|
] = await Promise.all([
|
|
32
32
|
import("./harness-9872e0ym.js"),
|
|
33
|
-
import("./message-index-
|
|
33
|
+
import("./message-index-5zjmsg57.js"),
|
|
34
34
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
35
35
|
]);
|
|
36
36
|
setHarness(input.harness ?? "opencode");
|
|
@@ -44,7 +44,7 @@ try {
|
|
|
44
44
|
const { setHarness } = await import("./harness-9872e0ym.js");
|
|
45
45
|
setHarness(input.harness ?? "opencode");
|
|
46
46
|
const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
|
|
47
|
-
import("./message-index-bounded-
|
|
47
|
+
import("./message-index-bounded-chgr6dn3.js"),
|
|
48
48
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
49
49
|
]);
|
|
50
50
|
configureContextDatabasePragmas(db);
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
resolveMemoriesByIdsForSearch2,
|
|
6
6
|
unifiedSearch2,
|
|
7
7
|
formatSearchResults2
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
8
|
+
} from "./index-2df03yc3.js";
|
|
9
|
+
import"./index-s3c9dskk.js";
|
|
10
|
+
import"./index-s9kwv5pp.js";
|
|
11
11
|
import"./index-hy44m6jc.js";
|
|
12
|
-
import"./index-
|
|
12
|
+
import"./index-78c864c8.js";
|
|
13
13
|
import"./index-9p40dgkm.js";
|
|
14
|
-
import"./index-
|
|
14
|
+
import"./index-drah07tf.js";
|
|
15
15
|
import"./index-yhzhdp3m.js";
|
|
16
|
-
import"./index-
|
|
16
|
+
import"./index-m8aaepft.js";
|
|
17
17
|
import"./index-x7426vy4.js";
|
|
18
18
|
import"./index-4vj37yw9.js";
|
|
19
19
|
import"./index-399p688g.js";
|
package/dist/subagent-entry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TOKEN_BUDGET_TOOL_REFUSAL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-m8aaepft.js";
|
|
4
4
|
import {
|
|
5
5
|
setHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
@@ -15,7 +15,7 @@ import"./index-3veejgp8.js";
|
|
|
15
15
|
import"./index-fapenpch.js";
|
|
16
16
|
import {
|
|
17
17
|
openDatabase
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-9azmm7cg.js";
|
|
19
19
|
import"./index-fdxzpnbj.js";
|
|
20
20
|
import"./index-g13fb2sj.js";
|
|
21
21
|
import"./index-ttxsmaj5.js";
|
|
@@ -27,21 +27,21 @@ import {
|
|
|
27
27
|
ensureProjectRegisteredFromPiDirectory,
|
|
28
28
|
resolvePiHarnessKind,
|
|
29
29
|
registerMagicContextTools
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-0vq6ebae.js";
|
|
31
31
|
import"./index-ta0ed2nc.js";
|
|
32
32
|
import"./index-szh001qb.js";
|
|
33
|
-
import"./index-
|
|
33
|
+
import"./index-drah07tf.js";
|
|
34
34
|
import"./index-8yjhda46.js";
|
|
35
|
-
import"./index-
|
|
35
|
+
import"./index-78c864c8.js";
|
|
36
36
|
import"./index-9p40dgkm.js";
|
|
37
37
|
import"./index-yhzhdp3m.js";
|
|
38
|
-
import"./index-
|
|
39
|
-
import"./index-
|
|
38
|
+
import"./index-s9kwv5pp.js";
|
|
39
|
+
import"./index-s3c9dskk.js";
|
|
40
40
|
import"./index-x7426vy4.js";
|
|
41
41
|
import"./index-399p688g.js";
|
|
42
42
|
import"./index-4vj37yw9.js";
|
|
43
43
|
import"./index-6x556c2q.js";
|
|
44
|
-
import"./index-
|
|
44
|
+
import"./index-2df03yc3.js";
|
|
45
45
|
import"./index-hy44m6jc.js";
|
|
46
46
|
import"./index-729kkhmf.js";
|
|
47
47
|
import"./index-43zqh10z.js";
|
package/package.json
CHANGED