@cortexkit/pi-magic-context 0.49.6 → 0.49.8
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 +10 -7
- package/dist/{compaction-marker-candidates-9w5g66at.js → compaction-marker-candidates-n4dphyz4.js} +3 -3
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/embedding-backfill-chva00z3.js +20 -0
- package/dist/embedding-worker-process.js +6 -2
- package/dist/embedding-worker.js +6 -5
- package/dist/historian-calibration-extension.js +1 -1
- package/dist/{index-j7pa3t4s.js → index-18qe4gs1.js} +113 -27
- package/dist/{index-0j0zqb4t.js → index-3veejgp8.js} +1 -1
- package/dist/{index-0vrkp1jq.js → index-43zqh10z.js} +1 -1
- package/dist/{index-r56xgha8.js → index-4pxydwvg.js} +1 -1
- package/dist/{index-5rc9kvrk.js → index-4vj37yw9.js} +4 -3
- package/dist/{index-fcacf11g.js → index-54r5vs9w.js} +4 -4
- package/dist/{index-cd6bjrj4.js → index-6e3yv1jt.js} +4 -4
- package/dist/{index-swab4319.js → index-729kkhmf.js} +4 -3
- package/dist/{index-gc2749rx.js → index-8yjhda46.js} +9 -6
- package/dist/{index-8vbh4tzw.js → index-asrxgdt4.js} +63 -19
- package/dist/{index-wf7mwdnf.js → index-fdxzpnbj.js} +2 -2
- package/dist/{index-kamhcj15.js → index-gqxsds3q.js} +6 -3
- package/dist/{index-x3dcnxh0.js → index-gycf3sp7.js} +5 -1
- package/dist/{index-kxxdyjfs.js → index-hy44m6jc.js} +1 -1
- package/dist/{index-0p9gemc6.js → index-jsyjxgfy.js} +172 -36
- package/dist/{index-290tzwp1.js → index-kh3jt7t9.js} +1 -1
- package/dist/{index-hfnjfk4d.js → index-pdhbj18g.js} +71 -70
- package/dist/{index-fx0r5485.js → index-qc8e13wc.js} +22 -22
- package/dist/{index-9mn34fnx.js → index-r8cy8hmq.js} +5 -5
- package/dist/{index-57mvvbbh.js → index-rggtvnbg.js} +40 -29
- package/dist/{index-21v1kfs7.js → index-szh001qb.js} +6 -3
- package/dist/{index-cyrnv16r.js → index-ta0ed2nc.js} +2 -0
- package/dist/{index-5z1h0qsa.js → index-tdhppxwd.js} +9 -9
- package/dist/{index-p4matwj0.js → index-v26j81w6.js} +5 -5
- package/dist/{index-mcgehvgw.js → index-zzn7qbps.js} +1 -1
- package/dist/index.js +1071 -390
- package/dist/{logger-j6tecd1h.js → logger-qg51hmp7.js} +1 -1
- package/dist/{message-index-m6snq0fh.js → message-index-1wta074c.js} +14 -14
- package/dist/{message-index-bounded-8a94k72f.js → message-index-bounded-ss3ctdwb.js} +14 -14
- package/dist/{message-time-backfill-xqwg3hg1.js → message-time-backfill-q9s88zdv.js} +3 -3
- package/dist/migration-worker.js +10 -10
- package/dist/{project-embedding-registry-3x6nmszv.js → project-embedding-registry-bxawck58.js} +11 -11
- package/dist/raw-ordinal-warmup-worker.js +17 -15
- package/dist/{read-session-chunk-49e1ayzs.js → read-session-chunk-1jagnq05.js} +11 -9
- package/dist/{read-session-raw-545mgtjz.js → read-session-raw-hm7ptnrh.js} +3 -3
- package/dist/{safe-notification-target-vn9kpmv4.js → safe-notification-target-62ty6rvp.js} +2 -2
- package/dist/{search-q76dp7w9.js → search-x7cachq0.js} +21 -21
- package/dist/{sqlite-wp7wddw3.js → sqlite-adjpy399.js} +3 -1
- package/dist/{storage-memory-7417pbm9.js → storage-memory-axnsk5t1.js} +2 -2
- package/dist/{storage-tags-cvjsrbqh.js → storage-tags-6j5s2q49.js} +5 -5
- package/dist/subagent-entry.js +24 -24
- package/package.json +1 -1
- package/dist/embedding-backfill-809pgwvb.js +0 -20
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
getHarness2
|
|
3
3
|
} from "./index-0h2mkab2.js";
|
|
4
4
|
import {
|
|
5
|
+
inRootAsyncContext2,
|
|
5
6
|
isTransientSqliteError2
|
|
6
|
-
} from "./index-
|
|
7
|
+
} from "./index-asrxgdt4.js";
|
|
7
8
|
import {
|
|
8
9
|
PROMOTABLE_CATEGORIES,
|
|
9
10
|
CATEGORY_DEFAULT_TTL
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
sanitizeDiagnosticText,
|
|
14
15
|
log2,
|
|
15
16
|
sessionLog2
|
|
16
|
-
} from "./index-
|
|
17
|
+
} from "./index-gycf3sp7.js";
|
|
17
18
|
import {
|
|
18
19
|
resolveWorkspaceShareCategories,
|
|
19
20
|
resolveWorkspaceIdentitySet,
|
|
@@ -21,17 +22,17 @@ import {
|
|
|
21
22
|
resolveStoredPathWorkspaceIdentity,
|
|
22
23
|
sourceNameForMemory,
|
|
23
24
|
managedAuthorityNoteRow
|
|
24
|
-
} from "./index-
|
|
25
|
+
} from "./index-r8cy8hmq.js";
|
|
25
26
|
import {
|
|
26
27
|
isKnownAutocommit
|
|
27
|
-
} from "./index-
|
|
28
|
+
} from "./index-zzn7qbps.js";
|
|
28
29
|
import {
|
|
29
30
|
SubcClient
|
|
30
|
-
} from "./index-
|
|
31
|
+
} from "./index-szh001qb.js";
|
|
31
32
|
import {
|
|
32
33
|
buildCanonicalChunkTextFromFts,
|
|
33
34
|
loadCompartmentChunkEmbeddingsForSearch
|
|
34
|
-
} from "./index-
|
|
35
|
+
} from "./index-6e3yv1jt.js";
|
|
35
36
|
import {
|
|
36
37
|
recordEmbeddingMeasurement,
|
|
37
38
|
saveCommitEmbedding,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
getProjectEmbeddingSnapshot2,
|
|
50
51
|
embedTextForProject2,
|
|
51
52
|
embedItemsForProject2
|
|
52
|
-
} from "./index-
|
|
53
|
+
} from "./index-qc8e13wc.js";
|
|
53
54
|
import {
|
|
54
55
|
saveEmbeddingIfHashMatches,
|
|
55
56
|
getProjectEmbeddings2
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
isEmbeddingEnabled,
|
|
60
61
|
embedText,
|
|
61
62
|
ensureMemoryEmbeddings2
|
|
62
|
-
} from "./index-
|
|
63
|
+
} from "./index-v26j81w6.js";
|
|
63
64
|
import {
|
|
64
65
|
getMemorySelectColumns2,
|
|
65
66
|
isMemoryRow2,
|
|
@@ -73,10 +74,10 @@ import {
|
|
|
73
74
|
getMemoryById2,
|
|
74
75
|
updateMemorySeenCount2,
|
|
75
76
|
updateMemoryRetrievalCount2
|
|
76
|
-
} from "./index-
|
|
77
|
+
} from "./index-hy44m6jc.js";
|
|
77
78
|
import {
|
|
78
79
|
getIndexedMessageCorpusSize2
|
|
79
|
-
} from "./index-
|
|
80
|
+
} from "./index-tdhppxwd.js";
|
|
80
81
|
import {
|
|
81
82
|
computeNormalizedHash
|
|
82
83
|
} from "./index-9x1f96r8.js";
|
|
@@ -612,8 +613,8 @@ var USER_FACING_FAILURES = {
|
|
|
612
613
|
},
|
|
613
614
|
history_boundary_unresolved: {
|
|
614
615
|
code: "MC-H04",
|
|
615
|
-
sentence: "This request was not sent:
|
|
616
|
-
action: "
|
|
616
|
+
sentence: "This request was not sent: Magic Context could not safely place the history summary boundary in the loaded conversation, and the untrimmed request is larger than the model's context window.",
|
|
617
|
+
action: "Reopen this session in its current project directory, then run /ctx-recomp to rebuild the history summary. A model with a larger context window can also help."
|
|
617
618
|
},
|
|
618
619
|
history_over_window_unmanaged: {
|
|
619
620
|
code: "MC-H06",
|
|
@@ -1792,6 +1793,61 @@ function searchGitCommitsSync(db, projectPath, query, options) {
|
|
|
1792
1793
|
});
|
|
1793
1794
|
return results.slice(0, options.limit);
|
|
1794
1795
|
}
|
|
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
|
+
|
|
1795
1851
|
// ../plugin/src/features/magic-context/literal-probes.ts
|
|
1796
1852
|
var MAX_PROBES = 5;
|
|
1797
1853
|
var MIN_PROBE_LENGTH = 3;
|
|
@@ -1848,61 +1904,6 @@ function containsProbeVerbatim(text, probes) {
|
|
|
1848
1904
|
return probes.some((probe) => haystack.includes(probe.toLowerCase()));
|
|
1849
1905
|
}
|
|
1850
1906
|
|
|
1851
|
-
// ../plugin/src/features/magic-context/message-fts-session-filter.ts
|
|
1852
|
-
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
1853
|
-
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
1854
|
-
) AND `;
|
|
1855
|
-
var coverageCaches = new WeakMap;
|
|
1856
|
-
function getCoverageCache(db) {
|
|
1857
|
-
let cache = coverageCaches.get(db);
|
|
1858
|
-
if (!cache) {
|
|
1859
|
-
cache = {
|
|
1860
|
-
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
1861
|
-
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
1862
|
-
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
1863
|
-
FROM message_history_fts WHERE rowid IN (
|
|
1864
|
-
SELECT id FROM message_history_fts_docsize
|
|
1865
|
-
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
1866
|
-
)`)
|
|
1867
|
-
};
|
|
1868
|
-
coverageCaches.set(db, cache);
|
|
1869
|
-
}
|
|
1870
|
-
return cache;
|
|
1871
|
-
}
|
|
1872
|
-
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
1873
|
-
let cacheable = false;
|
|
1874
|
-
try {
|
|
1875
|
-
const transaction = db;
|
|
1876
|
-
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
1877
|
-
if (!cacheable)
|
|
1878
|
-
coverageCaches.delete(db);
|
|
1879
|
-
} catch {
|
|
1880
|
-
coverageCaches.delete(db);
|
|
1881
|
-
}
|
|
1882
|
-
return db.transaction(() => {
|
|
1883
|
-
let sessionFirst = false;
|
|
1884
|
-
try {
|
|
1885
|
-
const cache = getCoverageCache(db);
|
|
1886
|
-
cache.pin.get();
|
|
1887
|
-
const stamp = cache.stamp.get();
|
|
1888
|
-
let incomplete = cache.incompleteSessions;
|
|
1889
|
-
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
1890
|
-
const rows = cache.missing.all();
|
|
1891
|
-
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
1892
|
-
if (cacheable) {
|
|
1893
|
-
cache.version = stamp.version;
|
|
1894
|
-
cache.changes = stamp.changes;
|
|
1895
|
-
cache.incompleteSessions = incomplete;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
sessionFirst = !incomplete.has(sessionId);
|
|
1899
|
-
} catch {
|
|
1900
|
-
coverageCaches.delete(db);
|
|
1901
|
-
}
|
|
1902
|
-
return read(sessionFirst);
|
|
1903
|
-
}).deferred();
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
1907
|
// ../plugin/src/features/magic-context/search-measurement.ts
|
|
1907
1908
|
import { createHash } from "node:crypto";
|
|
1908
1909
|
function resultId(result) {
|
|
@@ -2153,7 +2154,7 @@ var connections = new Map;
|
|
|
2153
2154
|
async function connect(connectionFile) {
|
|
2154
2155
|
let connection = connections.get(connectionFile);
|
|
2155
2156
|
if (!connection) {
|
|
2156
|
-
connection = SubcClient.connect({ connectionFile });
|
|
2157
|
+
connection = inRootAsyncContext2(() => SubcClient.connect({ connectionFile }));
|
|
2157
2158
|
connections.set(connectionFile, connection);
|
|
2158
2159
|
connection.catch(() => connections.delete(connectionFile));
|
|
2159
2160
|
}
|
|
@@ -3789,7 +3790,7 @@ ${diagnosticLines.join(`
|
|
|
3789
3790
|
bodyParts.push(diagnosticLines.join(`
|
|
3790
3791
|
`));
|
|
3791
3792
|
if (results.some((result) => result.source === "message" || result.source === "compartment")) {
|
|
3792
|
-
bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the
|
|
3793
|
+
bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the conversation context. If the host no longer holds those messages, ctx_expand returns indexed text from the search archive only, with no surrounding messages or tool output.");
|
|
3793
3794
|
}
|
|
3794
3795
|
if (results.some((result) => result.source === "note" && result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId)) {
|
|
3795
3796
|
bodyParts.push(SEARCH_NOTE_EXPAND_HINT);
|
|
@@ -3801,4 +3802,4 @@ ${bodyParts.join(`
|
|
|
3801
3802
|
`)}`;
|
|
3802
3803
|
}
|
|
3803
3804
|
|
|
3804
|
-
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 };
|
|
3805
|
+
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, withMessageFtsSessionFilter, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -4,25 +4,26 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
sanitizeDiagnosticText,
|
|
6
6
|
log2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-gycf3sp7.js";
|
|
8
8
|
import {
|
|
9
9
|
isUserHomeDirectory,
|
|
10
10
|
setBootQuietPeriodForTests
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-gqxsds3q.js";
|
|
12
12
|
import {
|
|
13
|
+
inRootAsyncContext2,
|
|
13
14
|
withSqliteBackgroundWriter2,
|
|
14
15
|
withoutSqliteTransformPass2,
|
|
15
16
|
isTransientSqliteError2
|
|
16
|
-
} from "./index-
|
|
17
|
+
} from "./index-asrxgdt4.js";
|
|
17
18
|
import {
|
|
18
19
|
estimateTokens
|
|
19
|
-
} from "./index-
|
|
20
|
+
} from "./index-4pxydwvg.js";
|
|
20
21
|
import {
|
|
21
22
|
SYNAPSE_DEFAULT_MODEL,
|
|
22
23
|
isSynapseEmbeddingTruncated,
|
|
23
24
|
getSynapseBatchRequestKey,
|
|
24
25
|
SynapseEmbeddingProvider
|
|
25
|
-
} from "./index-
|
|
26
|
+
} from "./index-szh001qb.js";
|
|
26
27
|
import {
|
|
27
28
|
CHUNK_WINDOW_SAFETY_RATIO,
|
|
28
29
|
normalizeCompartmentChunkMaxInputTokens,
|
|
@@ -39,10 +40,17 @@ import {
|
|
|
39
40
|
countSessionCompartmentEmbedCoverage,
|
|
40
41
|
countSessionCompartmentEmbedCoveragePolite,
|
|
41
42
|
countUnembeddedSessionCompartmentsPolite
|
|
42
|
-
} from "./index-
|
|
43
|
+
} from "./index-6e3yv1jt.js";
|
|
43
44
|
import {
|
|
44
45
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
45
|
-
} from "./index-
|
|
46
|
+
} from "./index-ta0ed2nc.js";
|
|
47
|
+
import {
|
|
48
|
+
embeddingModelsMatch,
|
|
49
|
+
resolveEmbeddingTextPrefixes,
|
|
50
|
+
getEmbeddingProviderIdentity,
|
|
51
|
+
dominantEmbeddingFailure,
|
|
52
|
+
LocalEmbeddingProvider
|
|
53
|
+
} from "./index-8yjhda46.js";
|
|
46
54
|
import {
|
|
47
55
|
isEmbeddingHostBusy2
|
|
48
56
|
} from "./index-9p40dgkm.js";
|
|
@@ -51,16 +59,9 @@ import {
|
|
|
51
59
|
getMemoryEmbedCoverage,
|
|
52
60
|
invalidateProject2
|
|
53
61
|
} from "./index-yhzhdp3m.js";
|
|
54
|
-
import {
|
|
55
|
-
embeddingModelsMatch,
|
|
56
|
-
resolveEmbeddingTextPrefixes,
|
|
57
|
-
getEmbeddingProviderIdentity,
|
|
58
|
-
dominantEmbeddingFailure,
|
|
59
|
-
LocalEmbeddingProvider
|
|
60
|
-
} from "./index-gc2749rx.js";
|
|
61
62
|
import {
|
|
62
63
|
logSlowWriteTransaction
|
|
63
|
-
} from "./index-
|
|
64
|
+
} from "./index-43zqh10z.js";
|
|
64
65
|
|
|
65
66
|
// ../plugin/src/features/magic-context/session-project-storage.ts
|
|
66
67
|
var SESSION_CHUNK_REPAIR_BATCH_SIZE = 100;
|
|
@@ -1012,7 +1013,6 @@ function listShadowBackfillStalls2(db, projectIdentity) {
|
|
|
1012
1013
|
}
|
|
1013
1014
|
return stalls;
|
|
1014
1015
|
}
|
|
1015
|
-
|
|
1016
1016
|
// ../plugin/src/features/magic-context/project-embedding-registry.ts
|
|
1017
1017
|
var OFF_PROVIDER_IDENTITY = "embedding-provider:off";
|
|
1018
1018
|
var SWEEP_MAX_WALL_CLOCK_MS = 10 * 60 * 1000;
|
|
@@ -2604,12 +2604,12 @@ async function drainCommitBacklogForProject2(db, projectIdentity, deadline) {
|
|
|
2604
2604
|
}
|
|
2605
2605
|
let total = 0;
|
|
2606
2606
|
let leaseLost = false;
|
|
2607
|
-
const renewal = setInterval(() => {
|
|
2607
|
+
const renewal = inRootAsyncContext2(() => setInterval(() => {
|
|
2608
2608
|
try {
|
|
2609
2609
|
if (!renewGitSweepLease(db, projectIdentity, holderId))
|
|
2610
2610
|
leaseLost = true;
|
|
2611
2611
|
} catch {}
|
|
2612
|
-
}, SESSION_EMBED_LEASE_RENEWAL_MS);
|
|
2612
|
+
}, SESSION_EMBED_LEASE_RENEWAL_MS));
|
|
2613
2613
|
renewal.unref?.();
|
|
2614
2614
|
try {
|
|
2615
2615
|
while (!leaseLost && !isEmbeddingHostBusy2() && Date.now() < deadline && total < COMMIT_DRAIN_MAX_PER_SWEEP) {
|
|
@@ -2773,12 +2773,12 @@ async function drainCompartmentChunkBacklogForProject(db, projectIdentity, deadl
|
|
|
2773
2773
|
}
|
|
2774
2774
|
let total = 0;
|
|
2775
2775
|
let leaseLost = false;
|
|
2776
|
-
const renewal = setInterval(() => {
|
|
2776
|
+
const renewal = inRootAsyncContext2(() => setInterval(() => {
|
|
2777
2777
|
try {
|
|
2778
2778
|
if (!renewGitSweepLease(db, projectIdentity, holderId))
|
|
2779
2779
|
leaseLost = true;
|
|
2780
2780
|
} catch {}
|
|
2781
|
-
}, SESSION_EMBED_LEASE_RENEWAL_MS);
|
|
2781
|
+
}, SESSION_EMBED_LEASE_RENEWAL_MS));
|
|
2782
2782
|
renewal.unref?.();
|
|
2783
2783
|
try {
|
|
2784
2784
|
while (!leaseLost && !isEmbeddingHostBusy2() && Date.now() < deadline && total < CHUNK_DRAIN_MAX_PER_SWEEP) {
|
|
@@ -2819,14 +2819,14 @@ async function embedSessionCompartmentChunks2(db, projectIdentity, sessionId, op
|
|
|
2819
2819
|
drainAbort.abort();
|
|
2820
2820
|
else
|
|
2821
2821
|
options?.signal?.addEventListener("abort", forwardCallerAbort, { once: true });
|
|
2822
|
-
const renewal = setInterval(() => {
|
|
2822
|
+
const renewal = inRootAsyncContext2(() => setInterval(() => {
|
|
2823
2823
|
try {
|
|
2824
2824
|
if (!renewGitSweepLease(db, projectIdentity, holderId)) {
|
|
2825
2825
|
leaseLost = true;
|
|
2826
2826
|
drainAbort.abort();
|
|
2827
2827
|
}
|
|
2828
2828
|
} catch {}
|
|
2829
|
-
}, SESSION_EMBED_LEASE_RENEWAL_MS);
|
|
2829
|
+
}, SESSION_EMBED_LEASE_RENEWAL_MS));
|
|
2830
2830
|
renewal.unref?.();
|
|
2831
2831
|
const batchSize = Math.max(1, options?.batchSize ?? CHUNK_DRAIN_BATCH_SIZE);
|
|
2832
2832
|
const skipIds = [];
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
} from "./index-135e8hvg.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-gycf3sp7.js";
|
|
7
7
|
import {
|
|
8
8
|
ensureColumn,
|
|
9
9
|
healAllNullColumns,
|
|
10
10
|
installV95PerfSchema
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-zzn7qbps.js";
|
|
12
12
|
import {
|
|
13
13
|
resolveOpenCodeDbPath,
|
|
14
14
|
openCodeDbPathExists,
|
|
@@ -16,14 +16,14 @@ import {
|
|
|
16
16
|
} from "./index-8976mezv.js";
|
|
17
17
|
import {
|
|
18
18
|
Database2
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-asrxgdt4.js";
|
|
20
20
|
import {
|
|
21
21
|
normalizeStoredProjectPath,
|
|
22
22
|
storedPathBelongsToIdentity
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-gqxsds3q.js";
|
|
24
24
|
import {
|
|
25
25
|
logSlowWriteTransaction
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-43zqh10z.js";
|
|
27
27
|
|
|
28
28
|
// ../plugin/src/features/magic-context/migrations.ts
|
|
29
29
|
import { isMainThread } from "node:worker_threads";
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
importPluginModule,
|
|
6
6
|
writeForwardedLogLine2,
|
|
7
7
|
log2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-gycf3sp7.js";
|
|
9
9
|
import {
|
|
10
|
+
inRootAsyncContext2,
|
|
10
11
|
registerSlowWriteReporter2,
|
|
11
12
|
registerSqliteDiagnosticSink2,
|
|
12
13
|
detectSqliteRuntime2,
|
|
@@ -15,8 +16,13 @@ import {
|
|
|
15
16
|
withoutSqliteTransformPass2,
|
|
16
17
|
isTransientSqliteError2,
|
|
17
18
|
withPrivilegedWriter2
|
|
18
|
-
} from "./index-
|
|
19
|
+
} from "./index-asrxgdt4.js";
|
|
19
20
|
import {
|
|
21
|
+
bootQuietRemainingMs,
|
|
22
|
+
scheduleAfterBootQuiet
|
|
23
|
+
} from "./index-gqxsds3q.js";
|
|
24
|
+
import {
|
|
25
|
+
getHarness2,
|
|
20
26
|
harnessOwnsOpenCodeStore2
|
|
21
27
|
} from "./index-0h2mkab2.js";
|
|
22
28
|
import {
|
|
@@ -29,13 +35,13 @@ import {
|
|
|
29
35
|
parseRpcPortFile,
|
|
30
36
|
inspectProcessesAsync,
|
|
31
37
|
inspectWindowsProcessesSync
|
|
32
|
-
} from "./index-
|
|
38
|
+
} from "./index-3veejgp8.js";
|
|
33
39
|
import {
|
|
34
40
|
configureContextDatabasePragmas2
|
|
35
41
|
} from "./index-fapenpch.js";
|
|
36
42
|
import {
|
|
37
43
|
startMessageFtsRowidMapBackfill
|
|
38
|
-
} from "./index-
|
|
44
|
+
} from "./index-fdxzpnbj.js";
|
|
39
45
|
import {
|
|
40
46
|
LKG_SLOT_CHUNKS_DDL,
|
|
41
47
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -45,26 +51,22 @@ import {
|
|
|
45
51
|
hasPendingMigrations,
|
|
46
52
|
getMainThreadMigrationBodyCount,
|
|
47
53
|
runMigrations
|
|
48
|
-
} from "./index-
|
|
54
|
+
} from "./index-r8cy8hmq.js";
|
|
49
55
|
import {
|
|
50
56
|
closeQuietly,
|
|
51
57
|
ensureColumn,
|
|
52
58
|
installV95PerfSchema,
|
|
53
59
|
installTagIdentityRevisionTrigger
|
|
54
|
-
} from "./index-
|
|
60
|
+
} from "./index-zzn7qbps.js";
|
|
55
61
|
import {
|
|
56
62
|
resolveOpenCodeDbPath,
|
|
57
63
|
hasV1MessageTables,
|
|
58
64
|
setDatabase,
|
|
59
65
|
loadToolDefinitionMeasurements
|
|
60
66
|
} from "./index-8976mezv.js";
|
|
61
|
-
import {
|
|
62
|
-
bootQuietRemainingMs,
|
|
63
|
-
scheduleAfterBootQuiet
|
|
64
|
-
} from "./index-kamhcj15.js";
|
|
65
67
|
import {
|
|
66
68
|
logSlowWriteTransaction
|
|
67
|
-
} from "./index-
|
|
69
|
+
} from "./index-43zqh10z.js";
|
|
68
70
|
import {
|
|
69
71
|
shouldEnforcePrivateStoragePermissions,
|
|
70
72
|
ensureStorageDirectorySync,
|
|
@@ -412,15 +414,25 @@ var activeMigrations = 0;
|
|
|
412
414
|
var activeSince = 0;
|
|
413
415
|
var accumulatedMs = 0;
|
|
414
416
|
var idleWaiters = [];
|
|
415
|
-
|
|
416
|
-
|
|
417
|
+
var testClock;
|
|
418
|
+
function now() {
|
|
419
|
+
return testClock?.now() ?? performance.now();
|
|
420
|
+
}
|
|
421
|
+
function scheduleTimeout(callback, delayMs) {
|
|
422
|
+
if (testClock)
|
|
423
|
+
return testClock.setTimeout(callback, delayMs);
|
|
424
|
+
const timer = setTimeout(callback, delayMs);
|
|
425
|
+
return () => clearTimeout(timer);
|
|
426
|
+
}
|
|
427
|
+
function offThreadMigrationMs(at = now()) {
|
|
428
|
+
return accumulatedMs + (activeMigrations > 0 ? Math.max(0, at - activeSince) : 0);
|
|
417
429
|
}
|
|
418
430
|
function isOffThreadMigrationRunning() {
|
|
419
431
|
return activeMigrations > 0;
|
|
420
432
|
}
|
|
421
433
|
function beginOffThreadMigration() {
|
|
422
434
|
if (activeMigrations === 0)
|
|
423
|
-
activeSince =
|
|
435
|
+
activeSince = now();
|
|
424
436
|
activeMigrations += 1;
|
|
425
437
|
let ended = false;
|
|
426
438
|
return () => {
|
|
@@ -430,7 +442,7 @@ function beginOffThreadMigration() {
|
|
|
430
442
|
activeMigrations -= 1;
|
|
431
443
|
if (activeMigrations > 0)
|
|
432
444
|
return;
|
|
433
|
-
accumulatedMs += Math.max(0,
|
|
445
|
+
accumulatedMs += Math.max(0, now() - activeSince);
|
|
434
446
|
const waiters = idleWaiters;
|
|
435
447
|
idleWaiters = [];
|
|
436
448
|
for (const wake of waiters)
|
|
@@ -443,10 +455,10 @@ function whenOffThreadMigrationIdle() {
|
|
|
443
455
|
return new Promise((resolve) => idleWaiters.push(resolve));
|
|
444
456
|
}
|
|
445
457
|
function startBootDeadline(timeoutMs, onDeferred) {
|
|
446
|
-
const startedAt =
|
|
458
|
+
const startedAt = now();
|
|
447
459
|
const migratedAtStart = offThreadMigrationMs(startedAt);
|
|
448
460
|
const budgetMs = Math.max(0, timeoutMs);
|
|
449
|
-
let
|
|
461
|
+
let cancelTimer;
|
|
450
462
|
let cancelled = false;
|
|
451
463
|
let deferredReported = false;
|
|
452
464
|
let resolveExpired;
|
|
@@ -454,12 +466,12 @@ function startBootDeadline(timeoutMs, onDeferred) {
|
|
|
454
466
|
resolveExpired = resolve;
|
|
455
467
|
});
|
|
456
468
|
const remainingMs = () => {
|
|
457
|
-
const
|
|
458
|
-
const countedMs =
|
|
469
|
+
const currentTime = now();
|
|
470
|
+
const countedMs = currentTime - startedAt - (offThreadMigrationMs(currentTime) - migratedAtStart);
|
|
459
471
|
return budgetMs - countedMs;
|
|
460
472
|
};
|
|
461
473
|
const check = () => {
|
|
462
|
-
|
|
474
|
+
cancelTimer = undefined;
|
|
463
475
|
if (cancelled)
|
|
464
476
|
return;
|
|
465
477
|
if (isOffThreadMigrationRunning()) {
|
|
@@ -472,19 +484,18 @@ function startBootDeadline(timeoutMs, onDeferred) {
|
|
|
472
484
|
}
|
|
473
485
|
const left = remainingMs();
|
|
474
486
|
if (left > 0) {
|
|
475
|
-
|
|
487
|
+
cancelTimer = scheduleTimeout(check, left);
|
|
476
488
|
return;
|
|
477
489
|
}
|
|
478
490
|
resolveExpired();
|
|
479
491
|
};
|
|
480
|
-
|
|
492
|
+
cancelTimer = scheduleTimeout(check, budgetMs);
|
|
481
493
|
return {
|
|
482
494
|
expired,
|
|
483
495
|
cancel: () => {
|
|
484
496
|
cancelled = true;
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
timer = undefined;
|
|
497
|
+
cancelTimer?.();
|
|
498
|
+
cancelTimer = undefined;
|
|
488
499
|
}
|
|
489
500
|
};
|
|
490
501
|
}
|
|
@@ -501,7 +512,7 @@ function runMigrationsOffThread(data) {
|
|
|
501
512
|
return new Promise((resolve, reject) => {
|
|
502
513
|
let worker;
|
|
503
514
|
try {
|
|
504
|
-
worker = new Worker(workerEntryOverride ?? defaultWorkerEntry(), { workerData: data });
|
|
515
|
+
worker = inRootAsyncContext2(() => new Worker(workerEntryOverride ?? defaultWorkerEntry(), { workerData: data }));
|
|
505
516
|
} catch (error) {
|
|
506
517
|
reject(workerStartError(error instanceof Error ? error.message : String(error)));
|
|
507
518
|
return;
|
|
@@ -838,7 +849,7 @@ function backfillToolOwnersInChunks(db, result) {
|
|
|
838
849
|
|
|
839
850
|
// ../plugin/src/features/magic-context/storage-db.ts
|
|
840
851
|
registerSlowWriteReporter2(logSlowWriteTransaction);
|
|
841
|
-
registerSqliteDiagnosticSink2((message) => log2(message));
|
|
852
|
+
registerSqliteDiagnosticSink2((message) => log2(message), getHarness2);
|
|
842
853
|
var databases = new Map;
|
|
843
854
|
var pendingAsyncOpens = new Map;
|
|
844
855
|
var persistenceByDatabase = new WeakMap;
|
|
@@ -1287,8 +1298,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1287
1298
|
startMessageFtsRowidMapBackfill(db).then(async () => {
|
|
1288
1299
|
if (!readsOpenCodeStore)
|
|
1289
1300
|
return;
|
|
1290
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1291
|
-
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-
|
|
1301
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-1jagnq05.js"));
|
|
1302
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-q9s88zdv.js"));
|
|
1292
1303
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
1293
1304
|
readPage: readRawSessionMessagePage
|
|
1294
1305
|
}));
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
estimateTokens
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-4pxydwvg.js";
|
|
4
4
|
import {
|
|
5
5
|
getHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
7
7
|
import {
|
|
8
8
|
log2
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-gycf3sp7.js";
|
|
10
|
+
import {
|
|
11
|
+
inRootAsyncContext2
|
|
12
|
+
} from "./index-asrxgdt4.js";
|
|
10
13
|
|
|
11
14
|
// ../plugin/src/features/magic-context/memory/embedding-synapse.ts
|
|
12
15
|
import { createHash } from "node:crypto";
|
|
@@ -1921,7 +1924,7 @@ async function getSharedClient(options) {
|
|
|
1921
1924
|
if (sharedClientPromise && sharedClientFile === options.connectionFile)
|
|
1922
1925
|
return sharedClientPromise;
|
|
1923
1926
|
sharedClientFile = options.connectionFile;
|
|
1924
|
-
sharedClientPromise = SubcClient.connect({ connectionFile: options.connectionFile }).then((client) => {
|
|
1927
|
+
sharedClientPromise = inRootAsyncContext2(() => SubcClient.connect({ connectionFile: options.connectionFile })).then((client) => {
|
|
1925
1928
|
sharedClient = client;
|
|
1926
1929
|
return client;
|
|
1927
1930
|
});
|
|
@@ -4837,6 +4837,7 @@ var FIELDS = [
|
|
|
4837
4837
|
];
|
|
4838
4838
|
var MINUTE_MS = 60000;
|
|
4839
4839
|
var MAX_SEARCH_MS = 4 * 366 * 24 * 60 * MINUTE_MS;
|
|
4840
|
+
var candidateVisitsForTests;
|
|
4840
4841
|
function parseField(token, spec) {
|
|
4841
4842
|
const values = new Set;
|
|
4842
4843
|
const normalize = (n) => spec.name === "day-of-week" && n === 7 ? 0 : n;
|
|
@@ -4956,6 +4957,7 @@ function nextOccurrence(cron, after, excludeCivilMinute, maxSearchMs = MAX_SEARC
|
|
|
4956
4957
|
let cursorMs = Math.floor(afterMs / MINUTE_MS) * MINUTE_MS + MINUTE_MS;
|
|
4957
4958
|
const capMs = afterMs + Math.max(0, Math.min(MAX_SEARCH_MS, maxSearchMs));
|
|
4958
4959
|
while (cursorMs <= capMs) {
|
|
4960
|
+
candidateVisitsForTests?.();
|
|
4959
4961
|
const candidate = new Date(cursorMs);
|
|
4960
4962
|
if (matchesCron(cron, candidate)) {
|
|
4961
4963
|
if (!excludeCivilMinute || civilMinuteKey(candidate) !== excludeCivilMinute) {
|
|
@@ -3,29 +3,29 @@ import {
|
|
|
3
3
|
} from "./index-0h2mkab2.js";
|
|
4
4
|
import {
|
|
5
5
|
getMagicContextStorageDir
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-gycf3sp7.js";
|
|
7
7
|
import {
|
|
8
8
|
isPidAlive,
|
|
9
9
|
readProcessStartTime
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-3veejgp8.js";
|
|
11
11
|
import {
|
|
12
12
|
removeSystemReminders,
|
|
13
13
|
hasMeaningfulUserText2,
|
|
14
14
|
extractTexts2
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-4pxydwvg.js";
|
|
16
16
|
import {
|
|
17
17
|
withSqliteBackgroundWriter2,
|
|
18
18
|
withoutSqliteTransformPass2
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-asrxgdt4.js";
|
|
20
20
|
import {
|
|
21
21
|
recordMessageFtsRowid,
|
|
22
22
|
recordIndexedMessageTime,
|
|
23
23
|
messageFtsOrdinalRangeIsMapped,
|
|
24
24
|
deleteUnmappedMessageFtsRows
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-fdxzpnbj.js";
|
|
26
26
|
import {
|
|
27
27
|
deleteChunkEmbedBackoffForSession
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-6e3yv1jt.js";
|
|
29
29
|
import {
|
|
30
30
|
closeQuietly,
|
|
31
31
|
TAG_TOMBSTONE_OWNER_PREFIX,
|
|
@@ -34,13 +34,13 @@ import {
|
|
|
34
34
|
tagRevisionKey,
|
|
35
35
|
tagIdentityRevisionKey,
|
|
36
36
|
deleteTagIdentityRevisions
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-zzn7qbps.js";
|
|
38
38
|
import {
|
|
39
39
|
cleanUserText2
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-18qe4gs1.js";
|
|
41
41
|
import {
|
|
42
42
|
logSlowWriteTransaction
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-43zqh10z.js";
|
|
44
44
|
import {
|
|
45
45
|
ensurePrivateStorageDirectorySync,
|
|
46
46
|
writeStorageFileSync,
|