@cortexkit/pi-magic-context 0.49.15 → 0.49.17
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 +76 -63
- package/dist/chunk-embedding-write-worker.js +11 -9
- package/dist/{compaction-marker-candidates-k4tqg4jb.js → compaction-marker-candidates-wjzqbspm.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/embedding-backfill-vwag34t0.js +23 -0
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +5 -5
- package/dist/historian-calibration-extension.js +4 -1
- package/dist/index-1cvyaw9a.js +58 -0
- package/dist/{index-g4jf772p.js → index-1kcfwk9c.js} +22 -2
- package/dist/{index-9jvktm7k.js → index-2mmy81qt.js} +3 -3
- package/dist/{index-ccsscaap.js → index-469ttgzv.js} +38 -17
- package/dist/index-4knyh1kt.js +1387 -0
- package/dist/{index-75ah9413.js → index-5k2mshvq.js} +10 -10
- package/dist/{index-a4pk5yv9.js → index-8r2t8fv2.js} +853 -84
- package/dist/{index-0awvkeb5.js → index-9j809q6f.js} +32 -72
- package/dist/{index-1k729e4f.js → index-bxmf4dhr.js} +6 -6
- package/dist/{index-6dz2ed1v.js → index-d8gc0112.js} +2 -2
- package/dist/{index-1vw4f2pe.js → index-dvbjsh98.js} +6 -8
- package/dist/{index-hy44m6jc.js → index-e1rza8gp.js} +1 -1
- package/dist/{index-j0n09wtp.js → index-ej4eak9d.js} +9 -7
- package/dist/{index-hshd96pt.js → index-es03azap.js} +127 -2093
- package/dist/{index-ajfpyk0x.js → index-fa485mqs.js} +59 -1
- package/dist/{index-6ex901g3.js → index-g7p75667.js} +33 -4
- package/dist/{index-bet4sd3e.js → index-gdjv1nnd.js} +2 -2
- package/dist/{index-46q4e104.js → index-qpq6w67c.js} +1 -1
- package/dist/{index-asrxgdt4.js → index-rrwv9y2k.js} +8 -0
- package/dist/{index-1mrvw9en.js → index-svgkv4g2.js} +1 -1
- package/dist/{index-he9s4qsj.js → index-vktahpdj.js} +23 -3
- package/dist/{index-nwbhe6qv.js → index-vmcgew7x.js} +11 -8
- package/dist/index-wrr9rp9a.js +16 -0
- package/dist/{index-7qc73yk5.js → index-xnch62s6.js} +14 -8
- package/dist/{index-djxc8w8c.js → index-yygsh681.js} +25 -26
- package/dist/{index-7wagp5jp.js → index-z2rkv0mb.js} +4 -4
- package/dist/index-z7kbck29.js +62 -0
- package/dist/index.js +688 -339
- package/dist/message-fts-rowid-map-cvpy2dmb.js +24 -0
- package/dist/{message-index-dw4z9efj.js → message-index-2g23b7fe.js} +13 -13
- package/dist/{message-index-bounded-z4d3x9ty.js → message-index-bounded-d6zj2tn5.js} +15 -15
- package/dist/{message-time-backfill-r2ar1qvk.js → message-time-backfill-ssshbdy8.js} +5 -5
- package/dist/migration-worker.js +8 -6
- package/dist/{project-embedding-registry-52zwmtbn.js → project-embedding-registry-vf1ncptn.js} +12 -10
- package/dist/raw-ordinal-warmup-worker.js +40 -10
- package/dist/{read-session-chunk-0fsgg2k1.js → read-session-chunk-2ky7mbqp.js} +7 -7
- package/dist/{read-session-raw-azkqjgzg.js → read-session-raw-9s3xn7fc.js} +2 -2
- package/dist/search-archive-9akqcr90.js +20 -0
- package/dist/{search-ddbz6v60.js → search-zjyc65g1.js} +20 -19
- package/dist/{sqlite-adjpy399.js → sqlite-fsp0sf3r.js} +1 -1
- package/dist/{storage-memory-axnsk5t1.js → storage-memory-yxxc5v4n.js} +2 -2
- package/dist/{storage-tags-3kb5tvgg.js → storage-tags-cx6ccsv1.js} +3 -3
- package/dist/subagent-entry.js +25 -22
- package/dist/tag-snapshot-worker-pi.js +17 -20
- package/package.json +1 -1
- package/dist/embedding-backfill-7kj16fh9.js +0 -21
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
inRootAsyncContext2,
|
|
6
6
|
isTransientSqliteError2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-rrwv9y2k.js";
|
|
8
8
|
import {
|
|
9
9
|
PROMOTABLE_CATEGORIES,
|
|
10
10
|
CATEGORY_DEFAULT_TTL
|
|
@@ -22,17 +22,17 @@ import {
|
|
|
22
22
|
resolveStoredPathWorkspaceIdentity,
|
|
23
23
|
sourceNameForMemory,
|
|
24
24
|
managedAuthorityNoteRow
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-gdjv1nnd.js";
|
|
26
26
|
import {
|
|
27
27
|
isKnownAutocommit
|
|
28
28
|
} from "./index-jrap43gc.js";
|
|
29
29
|
import {
|
|
30
30
|
SubcClient
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-d8gc0112.js";
|
|
32
32
|
import {
|
|
33
33
|
buildCanonicalChunkTextFromFts,
|
|
34
34
|
loadCompartmentChunkEmbeddingsForSearch
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-xnch62s6.js";
|
|
36
36
|
import {
|
|
37
37
|
recordEmbeddingMeasurement,
|
|
38
38
|
saveCommitEmbedding,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
getProjectEmbeddingSnapshot2,
|
|
51
51
|
embedTextForProject2,
|
|
52
52
|
embedItemsForProject2
|
|
53
|
-
} from "./index-
|
|
53
|
+
} from "./index-vmcgew7x.js";
|
|
54
54
|
import {
|
|
55
55
|
saveEmbeddingIfHashMatches,
|
|
56
56
|
getProjectEmbeddings2
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
isEmbeddingEnabled,
|
|
61
61
|
embedText,
|
|
62
62
|
ensureMemoryEmbeddings2
|
|
63
|
-
} from "./index-
|
|
63
|
+
} from "./index-z2rkv0mb.js";
|
|
64
64
|
import {
|
|
65
65
|
getMemorySelectColumns2,
|
|
66
66
|
isMemoryRow2,
|
|
@@ -74,10 +74,17 @@ import {
|
|
|
74
74
|
getMemoryById2,
|
|
75
75
|
updateMemorySeenCount2,
|
|
76
76
|
updateMemoryRetrievalCount2
|
|
77
|
-
} from "./index-
|
|
77
|
+
} from "./index-e1rza8gp.js";
|
|
78
78
|
import {
|
|
79
|
+
cleanSearchText,
|
|
80
|
+
keywordRelevance,
|
|
81
|
+
matchedSearchSnippet,
|
|
79
82
|
getIndexedMessageCorpusSize2
|
|
80
|
-
} from "./index-
|
|
83
|
+
} from "./index-8r2t8fv2.js";
|
|
84
|
+
import {
|
|
85
|
+
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
86
|
+
withMessageFtsSessionFilter
|
|
87
|
+
} from "./index-1cvyaw9a.js";
|
|
81
88
|
import {
|
|
82
89
|
computeNormalizedHash
|
|
83
90
|
} from "./index-9x1f96r8.js";
|
|
@@ -1495,6 +1502,10 @@ async function indexCommitsForProject(db, projectPath, directory, options) {
|
|
|
1495
1502
|
embedded: 0,
|
|
1496
1503
|
nonIndexable: false
|
|
1497
1504
|
};
|
|
1505
|
+
if (projectPath.startsWith("dir:")) {
|
|
1506
|
+
result.nonIndexable = true;
|
|
1507
|
+
return result;
|
|
1508
|
+
}
|
|
1498
1509
|
if (indexInProgress.has(projectPath)) {
|
|
1499
1510
|
log2(`[git-commits] index already in progress for ${projectPath}, skipping`);
|
|
1500
1511
|
return result;
|
|
@@ -1548,6 +1559,7 @@ async function embedUnembeddedCommits(db, projectPath) {
|
|
|
1548
1559
|
embedInProgress.add(projectPath);
|
|
1549
1560
|
const startedAt = Date.now();
|
|
1550
1561
|
const deadline = startedAt + EMBED_SWEEP_MAX_WALL_CLOCK_MS;
|
|
1562
|
+
const signal = AbortSignal.timeout(EMBED_SWEEP_MAX_WALL_CLOCK_MS);
|
|
1551
1563
|
let total = 0;
|
|
1552
1564
|
try {
|
|
1553
1565
|
while (Date.now() < deadline && total < EMBED_MAX_PER_SWEEP) {
|
|
@@ -1560,7 +1572,7 @@ async function embedUnembeddedCommits(db, projectPath) {
|
|
|
1560
1572
|
id: `commit:${row.sha}`,
|
|
1561
1573
|
text: row.message,
|
|
1562
1574
|
contentSha256: contentSha2562(row.message)
|
|
1563
|
-
})),
|
|
1575
|
+
})), signal, db, projectPath);
|
|
1564
1576
|
if (!result)
|
|
1565
1577
|
break;
|
|
1566
1578
|
db.transaction(() => {
|
|
@@ -1793,61 +1805,6 @@ function searchGitCommitsSync(db, projectPath, query, options) {
|
|
|
1793
1805
|
});
|
|
1794
1806
|
return results.slice(0, options.limit);
|
|
1795
1807
|
}
|
|
1796
|
-
// ../plugin/src/features/magic-context/message-fts-session-filter.ts
|
|
1797
|
-
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
1798
|
-
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
1799
|
-
) AND `;
|
|
1800
|
-
var coverageCaches = new WeakMap;
|
|
1801
|
-
function getCoverageCache(db) {
|
|
1802
|
-
let cache = coverageCaches.get(db);
|
|
1803
|
-
if (!cache) {
|
|
1804
|
-
cache = {
|
|
1805
|
-
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
1806
|
-
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
1807
|
-
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
1808
|
-
FROM message_history_fts WHERE rowid IN (
|
|
1809
|
-
SELECT id FROM message_history_fts_docsize
|
|
1810
|
-
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
1811
|
-
)`)
|
|
1812
|
-
};
|
|
1813
|
-
coverageCaches.set(db, cache);
|
|
1814
|
-
}
|
|
1815
|
-
return cache;
|
|
1816
|
-
}
|
|
1817
|
-
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
1818
|
-
let cacheable = false;
|
|
1819
|
-
try {
|
|
1820
|
-
const transaction = db;
|
|
1821
|
-
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
1822
|
-
if (!cacheable)
|
|
1823
|
-
coverageCaches.delete(db);
|
|
1824
|
-
} catch {
|
|
1825
|
-
coverageCaches.delete(db);
|
|
1826
|
-
}
|
|
1827
|
-
return db.transaction(() => {
|
|
1828
|
-
let sessionFirst = false;
|
|
1829
|
-
try {
|
|
1830
|
-
const cache = getCoverageCache(db);
|
|
1831
|
-
cache.pin.get();
|
|
1832
|
-
const stamp = cache.stamp.get();
|
|
1833
|
-
let incomplete = cache.incompleteSessions;
|
|
1834
|
-
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
1835
|
-
const rows = cache.missing.all();
|
|
1836
|
-
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
1837
|
-
if (cacheable) {
|
|
1838
|
-
cache.version = stamp.version;
|
|
1839
|
-
cache.changes = stamp.changes;
|
|
1840
|
-
cache.incompleteSessions = incomplete;
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
sessionFirst = !incomplete.has(sessionId);
|
|
1844
|
-
} catch {
|
|
1845
|
-
coverageCaches.delete(db);
|
|
1846
|
-
}
|
|
1847
|
-
return read(sessionFirst);
|
|
1848
|
-
}).deferred();
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
1808
|
// ../plugin/src/features/magic-context/literal-probes.ts
|
|
1852
1809
|
var MAX_PROBES = 5;
|
|
1853
1810
|
var MIN_PROBE_LENGTH = 3;
|
|
@@ -2973,7 +2930,7 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
2973
2930
|
const filtered = rows.slice(0, limit);
|
|
2974
2931
|
return filtered.map((row, rank) => ({
|
|
2975
2932
|
source: "message",
|
|
2976
|
-
content: previewText(row.content),
|
|
2933
|
+
content: matchedSearchSnippet(row.content, args.query) || previewText(row.content),
|
|
2977
2934
|
score: linearDecayScore(rank, filtered.length),
|
|
2978
2935
|
messageOrdinal: row.messageOrdinal,
|
|
2979
2936
|
messageId: row.messageId,
|
|
@@ -3050,7 +3007,7 @@ function searchMessagesInSnapshot(args, sessionFirst) {
|
|
|
3050
3007
|
const ranked = [...fused.values()].sort((a, b) => b.score !== a.score ? b.score - a.score : a.row.messageOrdinal - b.row.messageOrdinal).slice(0, resultLimit);
|
|
3051
3008
|
return ranked.map((entry, rank) => ({
|
|
3052
3009
|
source: "message",
|
|
3053
|
-
content: previewText(entry.row.content),
|
|
3010
|
+
content: matchedSearchSnippet(entry.row.content, args.query) || previewText(entry.row.content),
|
|
3054
3011
|
score: linearDecayScore(rank, ranked.length),
|
|
3055
3012
|
messageOrdinal: entry.row.messageOrdinal,
|
|
3056
3013
|
messageId: entry.row.messageId,
|
|
@@ -3273,10 +3230,7 @@ function mergeMessageAndCompartmentResults(args) {
|
|
|
3273
3230
|
}
|
|
3274
3231
|
}
|
|
3275
3232
|
const ranked = [...fused.values()].sort((left, right) => right.score !== left.score ? right.score - left.score : left.tieOrdinal - right.tieOrdinal).slice(0, args.limit);
|
|
3276
|
-
return ranked.map((entry
|
|
3277
|
-
...entry.result,
|
|
3278
|
-
score: linearDecayScore(rank, ranked.length)
|
|
3279
|
-
}));
|
|
3233
|
+
return ranked.map((entry) => entry.result);
|
|
3280
3234
|
}
|
|
3281
3235
|
function getSourceBoost(result) {
|
|
3282
3236
|
switch (result.source) {
|
|
@@ -3554,7 +3508,7 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3554
3508
|
if (options.diagnostics) {
|
|
3555
3509
|
options.diagnostics.suppressedLiveMessageMatches = outcome.suppressedLiveMessageMatches;
|
|
3556
3510
|
}
|
|
3557
|
-
messageResults = outcome.results;
|
|
3511
|
+
messageResults = outcome.results.filter((result) => result.messageId !== options.excludeMessageId);
|
|
3558
3512
|
if (lanes)
|
|
3559
3513
|
lanes.message_fts = (outcome.laneResults ?? outcome.results).slice(0, 25);
|
|
3560
3514
|
}
|
|
@@ -3687,6 +3641,12 @@ async function unifiedSearch2(db, sessionId, projectPath, query, options = {}) {
|
|
|
3687
3641
|
}).immediate();
|
|
3688
3642
|
}
|
|
3689
3643
|
}
|
|
3644
|
+
if (options.autoHint) {
|
|
3645
|
+
return results.map((result) => ({
|
|
3646
|
+
...result,
|
|
3647
|
+
relevanceScore: cleanSearchText(result.source === "compartment" ? result.title : result.content).length === 0 ? 0 : result.source === "message" || ("matchType" in result) && result.source !== "compartment" && result.matchType !== "semantic" ? keywordRelevance(trimmedQuery, result.content) : result.score
|
|
3648
|
+
}));
|
|
3649
|
+
}
|
|
3690
3650
|
return results;
|
|
3691
3651
|
}
|
|
3692
3652
|
var SEARCH_NOTE_EXPAND_HINT = "Use ctx_expand(start=N-10, end=N) around any note @msg anchor above to read the surrounding conversation context.";
|
|
@@ -3807,4 +3767,4 @@ ${bodyParts.join(`
|
|
|
3807
3767
|
`)}`;
|
|
3808
3768
|
}
|
|
3809
3769
|
|
|
3810
|
-
export { getNoteByIdInScope, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits,
|
|
3770
|
+
export { getNoteByIdInScope, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -5399,18 +5399,18 @@ var OmpEntryObjectSchema = object({
|
|
|
5399
5399
|
}).strict();
|
|
5400
5400
|
var OmpEntrySchema = union([string2(), OmpEntryObjectSchema]);
|
|
5401
5401
|
var OpenCodeHarnessBlockSchema = object({
|
|
5402
|
-
model: OcEntrySchema.optional().describe("Primary OpenCode model entry."),
|
|
5403
|
-
fallback_models: array(OcEntrySchema).optional().describe("Ordered fallback OpenCode entries.
|
|
5402
|
+
model: OcEntrySchema.optional().describe("Primary historian OpenCode model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. When absent, OpenCode inherits the session model."),
|
|
5403
|
+
fallback_models: array(OcEntrySchema).optional().describe("Ordered historian fallback OpenCode entries. A configured primary never adds the session model after this list. Requires an array; legacy singleton values migrate to a one-element array."),
|
|
5404
5404
|
variant: string2().optional().describe("OpenCode reasoning variant for the primary entry when it declares none. Fallback entries declare variants per-entry.")
|
|
5405
5405
|
}).strict().describe("Strict OpenCode model-resolution block. It accepts no Pi vocabulary.");
|
|
5406
5406
|
var PiHarnessBlockSchema = object({
|
|
5407
|
-
model: PiEntrySchema.optional().describe("Primary Pi model entry."),
|
|
5408
|
-
fallback_models: array(PiEntrySchema).optional().describe("Ordered fallback Pi entries.
|
|
5407
|
+
model: PiEntrySchema.optional().describe("Primary historian Pi model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. When absent, Pi does not run the historian."),
|
|
5408
|
+
fallback_models: array(PiEntrySchema).optional().describe("Ordered historian fallback Pi entries. The session model is never appended. Requires an array; legacy singleton values migrate to a one-element array."),
|
|
5409
5409
|
thinking_level: PiThinkingLevelSchema.describe("Pi thinking level for the primary entry when it declares none. Fallback entries declare thinking levels per-entry.")
|
|
5410
5410
|
}).strict().describe("Strict Pi model-resolution block. It accepts no OpenCode vocabulary.");
|
|
5411
5411
|
var OmpHarnessBlockSchema = object({
|
|
5412
|
-
model: OmpEntrySchema.optional().describe("Primary OMP model entry."),
|
|
5413
|
-
fallback_models: array(OmpEntrySchema).optional().describe("Ordered fallback OMP entries."),
|
|
5412
|
+
model: OmpEntrySchema.optional().describe("Primary historian OMP model entry. When set, only this model and fallback_models are used; exhaustion reports failure, never the session model. An absent OMP block inherits the Pi block; a selected block without a model does not run the historian."),
|
|
5413
|
+
fallback_models: array(OmpEntrySchema).optional().describe("Ordered historian fallback OMP entries. The session model is never appended."),
|
|
5414
5414
|
thinking_level: OmpThinkingLevelSchema.describe("OMP thinking level for the primary entry when it declares none. Fallback entries declare thinking levels per-entry.")
|
|
5415
5415
|
}).strict().describe("Strict OMP model-resolution block. It accepts no OpenCode vocabulary.");
|
|
5416
5416
|
var OpenCodeTaskExecutionSchema = object({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
estimateTokens
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-1kcfwk9c.js";
|
|
4
4
|
import {
|
|
5
5
|
getHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./index-7bqrfyny.js";
|
|
10
10
|
import {
|
|
11
11
|
inRootAsyncContext2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-rrwv9y2k.js";
|
|
13
13
|
|
|
14
14
|
// ../plugin/src/features/magic-context/memory/embedding-synapse.ts
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getTagsBySession2,
|
|
9
9
|
getTagsByNumbers2
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-ej4eak9d.js";
|
|
11
11
|
import {
|
|
12
12
|
inRootAsyncContext2,
|
|
13
13
|
getSqliteDatabasePath2
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-rrwv9y2k.js";
|
|
15
15
|
import {
|
|
16
16
|
createFailClosedBlockingError
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-469ttgzv.js";
|
|
18
18
|
|
|
19
19
|
// src/tag-snapshot-worker-client-pi.ts
|
|
20
20
|
import { setImmediate as yieldImmediate } from "node:timers/promises";
|
|
@@ -410,7 +410,6 @@ function createPiTagSnapshotReader(db) {
|
|
|
410
410
|
let desiredSession;
|
|
411
411
|
let failedUntil = 0;
|
|
412
412
|
let lastFailure;
|
|
413
|
-
const dataVersion = db.prepare("PRAGMA data_version");
|
|
414
413
|
const totalRevision = db.prepare("SELECT COALESCE(value, '0') AS revision, value IS NOT NULL AS present FROM (SELECT 1) LEFT JOIN schema_migrations_meta ON key = ?");
|
|
415
414
|
const assertOutsideTransaction = () => {
|
|
416
415
|
const connection = db;
|
|
@@ -433,7 +432,6 @@ function createPiTagSnapshotReader(db) {
|
|
|
433
432
|
foreignRevision: revision[1],
|
|
434
433
|
durableVersion: stamp.durable,
|
|
435
434
|
ownVersion: stamp.own,
|
|
436
|
-
dataVersion: dataVersion.get().data_version,
|
|
437
435
|
totalRevision: total.revision,
|
|
438
436
|
revisionPresent: total.present
|
|
439
437
|
};
|
|
@@ -684,7 +682,7 @@ function sameRow(left, right, keys) {
|
|
|
684
682
|
return true;
|
|
685
683
|
}
|
|
686
684
|
function samePiTagSnapshotToken(left, right) {
|
|
687
|
-
return left.connectionEpoch === right.connectionEpoch && left.sessionEpoch === right.sessionEpoch && left.jobId === right.jobId && left.sessionId === right.sessionId && left.localRevision === right.localRevision && left.foreignRevision === right.foreignRevision && left.durableVersion === right.durableVersion && left.ownVersion === right.ownVersion
|
|
685
|
+
return left.connectionEpoch === right.connectionEpoch && left.sessionEpoch === right.sessionEpoch && left.jobId === right.jobId && left.sessionId === right.sessionId && left.localRevision === right.localRevision && left.foreignRevision === right.foreignRevision && left.durableVersion === right.durableVersion && left.ownVersion === right.ownVersion;
|
|
688
686
|
}
|
|
689
687
|
function candidateRowBytes(row, overhead) {
|
|
690
688
|
let bytes = overhead;
|
|
@@ -877,7 +875,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
877
875
|
}
|
|
878
876
|
const end = deadline;
|
|
879
877
|
return (async () => {
|
|
880
|
-
for (
|
|
878
|
+
for (;; ) {
|
|
881
879
|
budget.assert();
|
|
882
880
|
const allowance = Math.min(end - performance.now(), budget.hydrationAllowance());
|
|
883
881
|
if (allowance <= 0)
|
|
@@ -895,7 +893,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
895
893
|
return;
|
|
896
894
|
} catch (error) {
|
|
897
895
|
budget.assert();
|
|
898
|
-
if (!(error instanceof PiTagHydrationError && error.code === "stale"
|
|
896
|
+
if (!(error instanceof PiTagHydrationError && error.code === "stale"))
|
|
899
897
|
throw error;
|
|
900
898
|
} finally {
|
|
901
899
|
clearTimeout(timer);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
estimateTokens
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-1kcfwk9c.js";
|
|
4
4
|
import {
|
|
5
5
|
getHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
getTagIdentityWriteGeneration2,
|
|
12
12
|
getSqliteDatabasePath2
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-rrwv9y2k.js";
|
|
14
14
|
import {
|
|
15
15
|
jsonHashSink,
|
|
16
16
|
tagOrderConstraintIndex,
|
|
@@ -1658,9 +1658,11 @@ function planEmergencyDrop(input) {
|
|
|
1658
1658
|
const workingSpan = Math.max(ceilingTokens - fixedFloor, 0);
|
|
1659
1659
|
const target = fixedFloor + TARGET_FRACTION * workingSpan;
|
|
1660
1660
|
const reclaimTokens = Math.round(currentTotalInputTokens - target);
|
|
1661
|
-
|
|
1661
|
+
if (fixedFloor > ceilingTokens) {
|
|
1662
|
+
return noop(`fixed floor ≈${Math.round(fixedFloor)} already exceeds ceiling ${Math.round(ceilingTokens)}: tool drops cannot reach the target`);
|
|
1663
|
+
}
|
|
1662
1664
|
if (reclaimTokens <= EMERGENCY_REARM_MIN_TOKENS) {
|
|
1663
|
-
return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})
|
|
1665
|
+
return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})`);
|
|
1664
1666
|
}
|
|
1665
1667
|
const cutoff = input.protectedCutoff;
|
|
1666
1668
|
const windowYields = absoluteEmergency;
|
|
@@ -1715,16 +1717,16 @@ function planEmergencyDrop(input) {
|
|
|
1715
1717
|
}
|
|
1716
1718
|
}
|
|
1717
1719
|
if (selected.length === 0) {
|
|
1718
|
-
return noop(
|
|
1720
|
+
return noop("no-candidates");
|
|
1719
1721
|
}
|
|
1720
1722
|
if (!input.passAlreadyPriced && reclaimed < EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS) {
|
|
1721
|
-
return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})
|
|
1723
|
+
return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})`);
|
|
1722
1724
|
}
|
|
1723
1725
|
return {
|
|
1724
1726
|
shouldDrop: true,
|
|
1725
1727
|
tagNumbers: selected,
|
|
1726
1728
|
reclaimTokens,
|
|
1727
|
-
reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})
|
|
1729
|
+
reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})`
|
|
1728
1730
|
};
|
|
1729
1731
|
}
|
|
1730
1732
|
function measureEmergencyTag(tag, target, calibration, skeleton) {
|