@cortexkit/pi-magic-context 0.49.46 → 0.49.48
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 +1 -1
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{index-v7m1nqwz.js → index-6748dkmx.js} +1 -1
- package/dist/{index-qt711raa.js → index-806brt0p.js} +1 -1
- package/dist/{index-wwf9vxpf.js → index-bbffazv6.js} +1 -1
- package/dist/{index-zchc0df8.js → index-bhj8kymt.js} +1 -9
- package/dist/{index-nvgq29cw.js → index-gwm5x42c.js} +5 -5
- package/dist/{index-ewf0sd7d.js → index-h1rtbjrp.js} +112 -12
- package/dist/{index-jaqdcqwz.js → index-j1kkx3f3.js} +1 -1
- package/dist/{index-ea37qn4x.js → index-nvh6d3bz.js} +66 -14
- package/dist/{index-6bedye3n.js → index-pja6ggeq.js} +4 -4
- package/dist/{index-7esg5v2x.js → index-vnygvrad.js} +1 -1
- package/dist/{index-fzadydec.js → index-zybqfwfv.js} +1 -1
- package/dist/index.js +336 -28
- package/dist/{message-index-bounded-cqn6x6fc.js → message-index-bounded-f0bk44ch.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-0ecmbegv.js → read-session-chunk-6nt4dzkk.js} +2 -2
- package/dist/{render-s6k2xqhj.js → render-yn7fgmg7.js} +6 -6
- package/dist/{search-archive-qza20zkm.js → search-archive-pcf0za02.js} +4 -4
- package/dist/{search-p4fj69gn.js → search-yvcam5gm.js} +4 -4
- package/dist/{storage-tags-g0j9mr4b.js → storage-tags-s0zqj0m0.js} +1 -1
- package/dist/{store-v60q7dje.js → store-0hhs1db3.js} +1 -1
- package/dist/{store-reader-2m80zs5z.js → store-reader-mmfw2h48.js} +1 -1
- package/dist/subagent-entry.js +10 -10
- package/dist/tag-snapshot-worker-pi.js +3 -3
- package/dist/{v2-archive-reader-2v7a879f.js → v2-archive-reader-accb2tjp.js} +1 -1
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ serveWorkerJobs(async (initial, port) => {
|
|
|
31
31
|
import("./embedding-cache-7rp4gqzr.js"),
|
|
32
32
|
import("./storage-memory-0ndn65fm.js"),
|
|
33
33
|
import("./project-embedding-registry-ysaezfqw.js"),
|
|
34
|
-
import("./search-
|
|
34
|
+
import("./search-yvcam5gm.js"),
|
|
35
35
|
import("./compartment-chunk-embedding-nyjs3dfh.js"),
|
|
36
36
|
import("./embedding-activity-ew6dshfd.js"),
|
|
37
37
|
import("./harness-9872e0ym.js"),
|
|
@@ -1788,7 +1788,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1788
1788
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1789
1789
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1790
1790
|
return;
|
|
1791
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1791
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-6nt4dzkk.js"));
|
|
1792
1792
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-x45573rs.js"));
|
|
1793
1793
|
if (signal.aborted)
|
|
1794
1794
|
return;
|
|
@@ -1149,8 +1149,6 @@ var TODO_PRIORITIES = [
|
|
|
1149
1149
|
TODO_PRIORITY_MEDIUM,
|
|
1150
1150
|
TODO_PRIORITY_LOW
|
|
1151
1151
|
];
|
|
1152
|
-
var TODO_STATUS_SET = new Set(TODO_STATUSES);
|
|
1153
|
-
var TODO_PRIORITY_SET = new Set(TODO_PRIORITIES);
|
|
1154
1152
|
var TERMINAL_STATUSES = new Set([
|
|
1155
1153
|
TODO_STATUS_COMPLETED,
|
|
1156
1154
|
TODO_STATUS_CANCELLED
|
|
@@ -1223,17 +1221,11 @@ function parseTodoState(stateJson) {
|
|
|
1223
1221
|
return null;
|
|
1224
1222
|
}
|
|
1225
1223
|
}
|
|
1226
|
-
function isTodoStatus(value) {
|
|
1227
|
-
return typeof value === "string" && TODO_STATUS_SET.has(value);
|
|
1228
|
-
}
|
|
1229
|
-
function isTodoPriority(value) {
|
|
1230
|
-
return typeof value === "string" && TODO_PRIORITY_SET.has(value);
|
|
1231
|
-
}
|
|
1232
1224
|
function isTodoItem(value) {
|
|
1233
1225
|
if (value === null || typeof value !== "object")
|
|
1234
1226
|
return false;
|
|
1235
1227
|
const todo = value;
|
|
1236
|
-
return typeof todo.content === "string" &&
|
|
1228
|
+
return typeof todo.content === "string" && typeof todo.status === "string" && todo.status.length > 0 && (todo.priority === undefined || typeof todo.priority === "string");
|
|
1237
1229
|
}
|
|
1238
1230
|
|
|
1239
1231
|
// ../plugin/src/hooks/magic-context/tail-hygiene-walk.ts
|
|
@@ -137,11 +137,11 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
137
137
|
{ createV2RecoveryAttachments }
|
|
138
138
|
] = await Promise.all([
|
|
139
139
|
import("./sqlite-v89bj0yy.js"),
|
|
140
|
-
import("./store-reader-
|
|
141
|
-
import("./store-
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
140
|
+
import("./store-reader-mmfw2h48.js"),
|
|
141
|
+
import("./store-0hhs1db3.js"),
|
|
142
|
+
import("./read-session-chunk-6nt4dzkk.js"),
|
|
143
|
+
import("./render-yn7fgmg7.js"),
|
|
144
|
+
import("./search-archive-pcf0za02.js"),
|
|
145
145
|
import("./expand-attachments-8sxeyj26.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
import {
|
|
57
57
|
piHarnessKindFromExecutable,
|
|
58
58
|
getErrorMessage
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-bbffazv6.js";
|
|
60
60
|
import {
|
|
61
61
|
getOrCreateSessionMeta,
|
|
62
62
|
updateSessionMeta,
|
|
@@ -70,10 +70,10 @@ import {
|
|
|
70
70
|
renderMessageByOrdinal2,
|
|
71
71
|
renderVerboseRange2,
|
|
72
72
|
renderItemByTag2
|
|
73
|
-
} from "./index-
|
|
73
|
+
} from "./index-pja6ggeq.js";
|
|
74
74
|
import {
|
|
75
75
|
getLastIndexedOrdinal
|
|
76
|
-
} from "./index-
|
|
76
|
+
} from "./index-zybqfwfv.js";
|
|
77
77
|
import {
|
|
78
78
|
setNoteLastReadAt,
|
|
79
79
|
getPersistedCompactionMarkerState,
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
hasRawMessageProvider2,
|
|
84
84
|
setRawMessageProvider2,
|
|
85
85
|
readSessionChunk2
|
|
86
|
-
} from "./index-
|
|
86
|
+
} from "./index-vnygvrad.js";
|
|
87
87
|
import {
|
|
88
88
|
stableStringify
|
|
89
89
|
} from "./index-yacs388s.js";
|
|
@@ -134,7 +134,7 @@ import {
|
|
|
134
134
|
resolveMemoriesByIdsForSearch2,
|
|
135
135
|
unifiedSearch2,
|
|
136
136
|
formatSearchResults2
|
|
137
|
-
} from "./index-
|
|
137
|
+
} from "./index-806brt0p.js";
|
|
138
138
|
import {
|
|
139
139
|
TODO_STATUSES,
|
|
140
140
|
TODO_PRIORITIES,
|
|
@@ -145,7 +145,7 @@ import {
|
|
|
145
145
|
getInertWhitespaceAssistantTagsByNumbers2,
|
|
146
146
|
getTagNumberByMessageId2,
|
|
147
147
|
getTagsBySession2
|
|
148
|
-
} from "./index-
|
|
148
|
+
} from "./index-bhj8kymt.js";
|
|
149
149
|
import {
|
|
150
150
|
resolveOpenCodeDbPath,
|
|
151
151
|
assertOpenCodeStoreGeneration
|
|
@@ -184,7 +184,7 @@ import {
|
|
|
184
184
|
} from "./index-2kmwjq42.js";
|
|
185
185
|
import {
|
|
186
186
|
renderSearchArchive2
|
|
187
|
-
} from "./index-
|
|
187
|
+
} from "./index-6748dkmx.js";
|
|
188
188
|
import {
|
|
189
189
|
computeNormalizedHash
|
|
190
190
|
} from "./index-9x1f96r8.js";
|
|
@@ -4792,15 +4792,115 @@ function resolveMuralWire(db, projectIdentity, modelKey, enabled, budgetTokens =
|
|
|
4792
4792
|
};
|
|
4793
4793
|
}
|
|
4794
4794
|
|
|
4795
|
-
// ../plugin/src/features/magic-context/
|
|
4795
|
+
// ../plugin/src/features/magic-context/request-tool-definitions.ts
|
|
4796
4796
|
import { createHash as createHash4 } from "node:crypto";
|
|
4797
|
+
var sha = (value) => createHash4("sha256").update(JSON.stringify(value)).digest("hex");
|
|
4798
|
+
var v2SchemaDigests = new Map;
|
|
4799
|
+
function requestToolsFingerprint(tools, referencedNames) {
|
|
4800
|
+
let referenced;
|
|
4801
|
+
const included = [];
|
|
4802
|
+
for (const tool of tools) {
|
|
4803
|
+
if (tool.deferLoading === true) {
|
|
4804
|
+
referenced ??= referencedNames?.() ?? new Set;
|
|
4805
|
+
if (!referenced.has(tool.name))
|
|
4806
|
+
continue;
|
|
4807
|
+
}
|
|
4808
|
+
included.push(tool);
|
|
4809
|
+
}
|
|
4810
|
+
included.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
4811
|
+
return {
|
|
4812
|
+
names: sha(included.map((tool) => tool.name)),
|
|
4813
|
+
descriptions: sha(included.map((tool) => [tool.name, tool.description])),
|
|
4814
|
+
schemas: sha(included.map((tool) => tool.deferLoading === true ? [tool.name, tool.description, tool.schemaDigest, "defer_loading"] : [tool.name, tool.description, tool.schemaDigest]))
|
|
4815
|
+
};
|
|
4816
|
+
}
|
|
4817
|
+
function classifyRequestToolsChange(previous, current) {
|
|
4818
|
+
if (previous.names !== current.names)
|
|
4819
|
+
return "names";
|
|
4820
|
+
if (previous.descriptions !== current.descriptions)
|
|
4821
|
+
return "descriptions";
|
|
4822
|
+
if (previous.schemas !== current.schemas)
|
|
4823
|
+
return "schemas";
|
|
4824
|
+
return null;
|
|
4825
|
+
}
|
|
4826
|
+
function requestToolSchemaDigest(schema) {
|
|
4827
|
+
const pieces = [];
|
|
4828
|
+
writeCanonicalJson(toJsonValue(schema, ""), [], pieces);
|
|
4829
|
+
return createHash4("sha256").update(pieces.join("")).digest("hex");
|
|
4830
|
+
}
|
|
4831
|
+
function isJsonValue(value) {
|
|
4832
|
+
return value !== undefined && typeof value !== "function" && typeof value !== "symbol";
|
|
4833
|
+
}
|
|
4834
|
+
function toJsonValue(value, key) {
|
|
4835
|
+
if (typeof value !== "object" || value === null)
|
|
4836
|
+
return value;
|
|
4837
|
+
const toJSON = value.toJSON;
|
|
4838
|
+
const resolved = typeof toJSON === "function" ? toJSON.call(value, key) : value;
|
|
4839
|
+
if (resolved instanceof Number)
|
|
4840
|
+
return Number(resolved);
|
|
4841
|
+
if (resolved instanceof String)
|
|
4842
|
+
return String(resolved);
|
|
4843
|
+
if (resolved instanceof Boolean)
|
|
4844
|
+
return resolved.valueOf();
|
|
4845
|
+
return resolved;
|
|
4846
|
+
}
|
|
4847
|
+
function writeCanonicalJson(value, ancestors, out) {
|
|
4848
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
4849
|
+
out.push(JSON.stringify(value));
|
|
4850
|
+
return;
|
|
4851
|
+
}
|
|
4852
|
+
if (typeof value === "number") {
|
|
4853
|
+
out.push(Number.isFinite(value) ? JSON.stringify(value) : "null");
|
|
4854
|
+
return;
|
|
4855
|
+
}
|
|
4856
|
+
if (typeof value === "bigint") {
|
|
4857
|
+
out.push(JSON.stringify(value.toString()));
|
|
4858
|
+
return;
|
|
4859
|
+
}
|
|
4860
|
+
if (typeof value !== "object") {
|
|
4861
|
+
out.push("null");
|
|
4862
|
+
return;
|
|
4863
|
+
}
|
|
4864
|
+
if (ancestors.includes(value)) {
|
|
4865
|
+
out.push('"[Circular]"');
|
|
4866
|
+
return;
|
|
4867
|
+
}
|
|
4868
|
+
ancestors.push(value);
|
|
4869
|
+
if (Array.isArray(value)) {
|
|
4870
|
+
out.push("[");
|
|
4871
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
4872
|
+
if (index > 0)
|
|
4873
|
+
out.push(",");
|
|
4874
|
+
const item = toJsonValue(value[index], String(index));
|
|
4875
|
+
if (isJsonValue(item))
|
|
4876
|
+
writeCanonicalJson(item, ancestors, out);
|
|
4877
|
+
else
|
|
4878
|
+
out.push("null");
|
|
4879
|
+
}
|
|
4880
|
+
out.push("]");
|
|
4881
|
+
} else {
|
|
4882
|
+
const entries = Object.entries(value).map(([key, child]) => [key, toJsonValue(child, key)]).filter(([, child]) => isJsonValue(child)).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
4883
|
+
out.push("{");
|
|
4884
|
+
entries.forEach(([key, child], index) => {
|
|
4885
|
+
if (index > 0)
|
|
4886
|
+
out.push(",");
|
|
4887
|
+
out.push(JSON.stringify(key), ":");
|
|
4888
|
+
writeCanonicalJson(child, ancestors, out);
|
|
4889
|
+
});
|
|
4890
|
+
out.push("}");
|
|
4891
|
+
}
|
|
4892
|
+
ancestors.pop();
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4895
|
+
// ../plugin/src/features/magic-context/compaction-marker.ts
|
|
4896
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
4797
4897
|
import { existsSync as existsSync6, statSync as statSync4 } from "node:fs";
|
|
4798
4898
|
var BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4799
4899
|
var ID_PREFIX_HEX_LENGTH = 12;
|
|
4800
4900
|
var ID_SUFFIX_LENGTH = 14;
|
|
4801
4901
|
var ID_PREFIX_MASK = (1n << BigInt(ID_PREFIX_HEX_LENGTH * 4)) - 1n;
|
|
4802
4902
|
function deterministicBase62(seed, length) {
|
|
4803
|
-
let value = BigInt(`0x${
|
|
4903
|
+
let value = BigInt(`0x${createHash5("sha256").update(seed).digest("hex")}`);
|
|
4804
4904
|
const chars = Array(length);
|
|
4805
4905
|
for (let index = length - 1;index >= 0; index -= 1) {
|
|
4806
4906
|
chars[index] = BASE62_CHARS[Number(value % 62n)];
|
|
@@ -6446,7 +6546,7 @@ async function wakePlaneStatus() {
|
|
|
6446
6546
|
import { statSync as statSync5 } from "node:fs";
|
|
6447
6547
|
|
|
6448
6548
|
// ../plugin/src/plugin/embedding-bootstrap-helpers.ts
|
|
6449
|
-
import { createHash as
|
|
6549
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
6450
6550
|
var EMBEDDING_AFFECTING_KEYS = new Set([
|
|
6451
6551
|
"embedding.api_key",
|
|
6452
6552
|
"embedding.endpoint",
|
|
@@ -6494,7 +6594,7 @@ var EMBEDDING_WARNING_TERMS = [
|
|
|
6494
6594
|
];
|
|
6495
6595
|
var loggedFailureSignatures = new Map;
|
|
6496
6596
|
function sha256Prefix(value, length = 16) {
|
|
6497
|
-
return
|
|
6597
|
+
return createHash6("sha256").update(value).digest("hex").slice(0, length);
|
|
6498
6598
|
}
|
|
6499
6599
|
function warningLooksEmbeddingRelated(message) {
|
|
6500
6600
|
const lower = message.toLowerCase();
|
|
@@ -10710,4 +10810,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
10710
10810
|
}
|
|
10711
10811
|
}
|
|
10712
10812
|
|
|
10713
|
-
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, isCommitRetentionPaused, copyCommitRetentionRecovery, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, neutralizeOmpMentions, restoreOmpMentions, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
10813
|
+
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, isCommitRetentionPaused, copyCommitRetentionRecovery, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, requestToolsFingerprint, classifyRequestToolsChange, requestToolSchemaDigest, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, neutralizeOmpMentions, restoreOmpMentions, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
@@ -301,6 +301,50 @@ class V2StoreReader2 {
|
|
|
301
301
|
}
|
|
302
302
|
return statement;
|
|
303
303
|
}
|
|
304
|
+
hasPartTable() {
|
|
305
|
+
this.connection.partTable ??= Boolean(this.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'session_part'").get());
|
|
306
|
+
return this.connection.partTable;
|
|
307
|
+
}
|
|
308
|
+
withParts(rows) {
|
|
309
|
+
const ids = rows.flatMap((row) => row.type === "assistant" ? [row.id] : []);
|
|
310
|
+
if (ids.length === 0 || !this.hasPartTable())
|
|
311
|
+
return rows;
|
|
312
|
+
const parts = new Map;
|
|
313
|
+
for (let offset = 0;offset < ids.length; offset += 500) {
|
|
314
|
+
const chunk = ids.slice(offset, offset + 500);
|
|
315
|
+
const partRows = this.prepare(`SELECT message_id, ordinal, data FROM session_part
|
|
316
|
+
WHERE message_id IN (${chunk.map(() => "?").join(", ")})
|
|
317
|
+
ORDER BY message_id ASC, ordinal ASC`).all(...chunk);
|
|
318
|
+
for (const part of partRows) {
|
|
319
|
+
let data;
|
|
320
|
+
try {
|
|
321
|
+
data = JSON.parse(part.data);
|
|
322
|
+
} catch {
|
|
323
|
+
throw new Error(`Invalid session_part data for ${part.message_id} at ordinal ${part.ordinal}`);
|
|
324
|
+
}
|
|
325
|
+
const list = parts.get(part.message_id);
|
|
326
|
+
if (list)
|
|
327
|
+
list.push(data);
|
|
328
|
+
else
|
|
329
|
+
parts.set(part.message_id, [data]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (parts.size === 0)
|
|
333
|
+
return rows;
|
|
334
|
+
return rows.map((row) => {
|
|
335
|
+
const content = parts.get(row.id);
|
|
336
|
+
if (!content)
|
|
337
|
+
return row;
|
|
338
|
+
const inline = row.data.content;
|
|
339
|
+
return {
|
|
340
|
+
...row,
|
|
341
|
+
data: {
|
|
342
|
+
...row.data,
|
|
343
|
+
content: Array.isArray(inline) ? [...content, ...inline] : content
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
}
|
|
304
348
|
close() {
|
|
305
349
|
if (this.closed)
|
|
306
350
|
return;
|
|
@@ -330,9 +374,9 @@ class V2StoreReader2 {
|
|
|
330
374
|
predicates.push("type = ?");
|
|
331
375
|
parameters.push(options.type);
|
|
332
376
|
}
|
|
333
|
-
const rows = this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
377
|
+
const rows = this.withParts(this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
334
378
|
WHERE ${predicates.join(" AND ")}
|
|
335
|
-
ORDER BY seq ASC LIMIT ?`).all(...parameters, limit).map(decode);
|
|
379
|
+
ORDER BY seq ASC LIMIT ?`).all(...parameters, limit).map(decode));
|
|
336
380
|
return { rows, cursor: rows.at(-1)?.seq };
|
|
337
381
|
});
|
|
338
382
|
}
|
|
@@ -350,14 +394,14 @@ class V2StoreReader2 {
|
|
|
350
394
|
if (after) {
|
|
351
395
|
const anchor = this.prepare("SELECT seq FROM session_message WHERE session_id = ? AND id = ?").get(sessionID, after.id);
|
|
352
396
|
if (anchor) {
|
|
353
|
-
return this.prepare(`SELECT id, session_id, type, seq, time_created, data
|
|
397
|
+
return this.withParts(this.prepare(`SELECT id, session_id, type, seq, time_created, data
|
|
354
398
|
FROM session_message WHERE session_id = ? AND seq > ?
|
|
355
|
-
AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS}) ORDER BY seq ASC LIMIT ?`).all(sessionID, anchor.seq, ...RAW_MESSAGE_TYPES2, pageSize).map(decode);
|
|
399
|
+
AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS}) ORDER BY seq ASC LIMIT ?`).all(sessionID, anchor.seq, ...RAW_MESSAGE_TYPES2, pageSize).map(decode));
|
|
356
400
|
}
|
|
357
401
|
}
|
|
358
402
|
const maximumSeq = Number.MAX_SAFE_INTEGER;
|
|
359
403
|
const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES2, Math.max(0, afterOrdinal - 1), sessionID, sessionID, ...RAW_MESSAGE_TYPES2, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES2, pageSize);
|
|
360
|
-
return rows.map(decode);
|
|
404
|
+
return this.withParts(rows.map(decode));
|
|
361
405
|
});
|
|
362
406
|
}
|
|
363
407
|
messageCount(sessionID) {
|
|
@@ -491,7 +535,7 @@ class V2StoreReader2 {
|
|
|
491
535
|
const rawTypes = RAW_MESSAGE_TYPES2.map(() => "?").join(", ");
|
|
492
536
|
const row = this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
493
537
|
WHERE session_id = ? AND id = ? AND type IN (${rawTypes}) LIMIT 1`).get(sessionID, id, ...RAW_MESSAGE_TYPES2);
|
|
494
|
-
return row ? decode(row) : null;
|
|
538
|
+
return row ? this.withParts([decode(row)])[0] ?? null : null;
|
|
495
539
|
});
|
|
496
540
|
}
|
|
497
541
|
messageTimeVersions(sessionID, ids, span) {
|
|
@@ -626,12 +670,20 @@ class V2StoreReader2 {
|
|
|
626
670
|
spanRowStamps(sessionID, after, through) {
|
|
627
671
|
if (!Number.isSafeInteger(after) || !Number.isSafeInteger(through))
|
|
628
672
|
throw new Error("Invalid seq span");
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
|
|
673
|
+
const partJoin = this.hasPartTable() ? `LEFT JOIN (SELECT p.message_id AS message_id, COUNT(*) AS parts,
|
|
674
|
+
MAX(p.time_updated) AS partsUpdated,
|
|
675
|
+
SUM(length(CAST(p.data AS BLOB))) AS partsBytes
|
|
676
|
+
FROM session_message s JOIN session_part p ON p.message_id = s.id
|
|
677
|
+
WHERE s.session_id = ? AND s.seq > ? AND s.seq <= ?
|
|
678
|
+
GROUP BY p.message_id) g ON g.message_id = m.id` : "";
|
|
679
|
+
const rows = this.prepare(`SELECT m.seq AS seq, m.id AS id, m.time_updated AS updated,
|
|
680
|
+
length(CAST(m.data AS BLOB)) AS bytes${partJoin ? ", g.parts AS parts, g.partsUpdated AS partsUpdated, g.partsBytes AS partsBytes" : ""}
|
|
681
|
+
FROM session_message m ${partJoin}
|
|
682
|
+
WHERE m.session_id = ? AND m.seq > ? AND m.seq <= ?
|
|
683
|
+
ORDER BY m.seq ASC`).all(...partJoin ? [sessionID, after, through] : [], sessionID, after, through);
|
|
632
684
|
const stamps = new Map;
|
|
633
685
|
for (const row of rows)
|
|
634
|
-
stamps.set(row.seq, `${row.id}\x00${row.updated ?? ""}\x00${row.bytes ?? ""}`);
|
|
686
|
+
stamps.set(row.seq, `${row.id}\x00${row.updated ?? ""}\x00${row.bytes ?? ""}${row.parts ? `\x00${row.parts}\x00${row.partsUpdated ?? ""}\x00${row.partsBytes ?? ""}` : ""}`);
|
|
635
687
|
return stamps;
|
|
636
688
|
}
|
|
637
689
|
rawRowsThrough(sessionID, throughSeq, limit) {
|
|
@@ -641,9 +693,9 @@ class V2StoreReader2 {
|
|
|
641
693
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 1e4)
|
|
642
694
|
throw new Error("Invalid page limit");
|
|
643
695
|
const rawTypes = RAW_MESSAGE_TYPES2.map(() => "?").join(", ");
|
|
644
|
-
return this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
696
|
+
return this.withParts(this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
645
697
|
WHERE session_id = ? AND type IN (${rawTypes}) AND seq <= ?
|
|
646
|
-
ORDER BY seq DESC LIMIT ?`).all(sessionID, ...RAW_MESSAGE_TYPES2, throughSeq, limit).map(decode);
|
|
698
|
+
ORDER BY seq DESC LIMIT ?`).all(sessionID, ...RAW_MESSAGE_TYPES2, throughSeq, limit).map(decode));
|
|
647
699
|
});
|
|
648
700
|
}
|
|
649
701
|
instructionRowsThrough(sessionID, throughSeq) {
|
|
@@ -734,7 +786,7 @@ class V2StoreReader2 {
|
|
|
734
786
|
const rows = this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
735
787
|
WHERE session_id = ? AND type = 'assistant' AND seq > ?
|
|
736
788
|
ORDER BY seq ASC`).all(sessionID, afterSeq);
|
|
737
|
-
return rows.map(
|
|
789
|
+
return this.withParts(rows.map(decode));
|
|
738
790
|
});
|
|
739
791
|
}
|
|
740
792
|
latestAssistant(sessionID) {
|
|
@@ -742,7 +794,7 @@ class V2StoreReader2 {
|
|
|
742
794
|
const row = this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
743
795
|
WHERE session_id = ? AND type = 'assistant'
|
|
744
796
|
ORDER BY seq DESC LIMIT 1`).get(sessionID);
|
|
745
|
-
return row ? decode(row) : undefined;
|
|
797
|
+
return row ? this.withParts([decode(row)])[0] : undefined;
|
|
746
798
|
});
|
|
747
799
|
}
|
|
748
800
|
latestIdle(sessionID) {
|
|
@@ -39,12 +39,12 @@ import {
|
|
|
39
39
|
expandToolPart,
|
|
40
40
|
visitRawSessionMessages2,
|
|
41
41
|
readRawSessionMessageById2
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-vnygvrad.js";
|
|
43
43
|
import {
|
|
44
44
|
isRecord,
|
|
45
45
|
providerVisibleMessage,
|
|
46
46
|
getTagById2
|
|
47
|
-
} from "./index-
|
|
47
|
+
} from "./index-bhj8kymt.js";
|
|
48
48
|
import {
|
|
49
49
|
estimateTokens
|
|
50
50
|
} from "./index-000fthre.js";
|
|
@@ -64,11 +64,11 @@ import {
|
|
|
64
64
|
import {
|
|
65
65
|
isPidAlive,
|
|
66
66
|
readProcessStartTime
|
|
67
|
-
} from "./index-
|
|
67
|
+
} from "./index-bbffazv6.js";
|
|
68
68
|
import {
|
|
69
69
|
gaDatabasePath2,
|
|
70
70
|
V2StoreReader2
|
|
71
|
-
} from "./index-
|
|
71
|
+
} from "./index-nvh6d3bz.js";
|
|
72
72
|
import {
|
|
73
73
|
deleteUnmappedMessageFtsRows2
|
|
74
74
|
} from "./index-bbbp8zs1.js";
|