@cortexkit/pi-magic-context 0.49.77 → 0.49.79
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-mm9y1m77.js → index-0t9xfj3x.js} +1 -1
- package/dist/{index-9a92hc6c.js → index-0th11rhf.js} +1 -1
- package/dist/{index-px5g7twk.js → index-55dhgfwp.js} +1 -1
- package/dist/{index-xxjx713t.js → index-6crdakkm.js} +3 -3
- package/dist/{index-6bjc4pam.js → index-97ay0whg.js} +25 -9
- package/dist/{index-cyzsn2hb.js → index-fvfq9gva.js} +1 -1
- package/dist/{index-0x61mf6t.js → index-hnvq96j6.js} +4 -4
- package/dist/{index-apff8dej.js → index-hpbdnbtf.js} +1 -1
- package/dist/{index-6gwasf0v.js → index-nh4srq1p.js} +5 -3
- package/dist/{index-wmkkxwvf.js → index-pdrberjp.js} +1 -1
- package/dist/index.js +155 -71
- package/dist/{message-index-bounded-cv87994v.js → message-index-bounded-sra4jpac.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-ygwyfvtr.js → read-session-chunk-wek7gb7j.js} +2 -2
- package/dist/{render-gbeyky54.js → render-fhrce5g6.js} +5 -5
- package/dist/{search-zazd3b88.js → search-9tg206vb.js} +4 -4
- package/dist/{search-archive-33p4gebn.js → search-archive-661vc3fb.js} +4 -4
- package/dist/{storage-tags-zzttnzn6.js → storage-tags-mj9tptw2.js} +1 -1
- package/dist/{store-grcwn6hs.js → store-e9ve3qzt.js} +79 -13
- package/dist/subagent-entry.js +9 -9
- package/dist/tag-snapshot-worker-pi.js +3 -3
- package/dist/{v2-archive-reader-5cydt27v.js → v2-archive-reader-zndhp4c4.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-zgzq9ehw.js"),
|
|
34
|
-
import("./search-
|
|
34
|
+
import("./search-9tg206vb.js"),
|
|
35
35
|
import("./compartment-chunk-embedding-avkyp2df.js"),
|
|
36
36
|
import("./embedding-activity-ew6dshfd.js"),
|
|
37
37
|
import("./harness-9872e0ym.js"),
|
|
@@ -1787,7 +1787,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1787
1787
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1788
1788
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1789
1789
|
return;
|
|
1790
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1790
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-wek7gb7j.js"));
|
|
1791
1791
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-8zwv9byv.js"));
|
|
1792
1792
|
if (signal.aborted)
|
|
1793
1793
|
return;
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
serializeProcessedImageMarkers,
|
|
41
41
|
getPendingPiCompactionMarkerState,
|
|
42
42
|
logPiCompactionMarkerClear
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-nh4srq1p.js";
|
|
44
44
|
import {
|
|
45
45
|
estimateTokens
|
|
46
46
|
} from "./index-pefn1gt5.js";
|
|
@@ -61,13 +61,13 @@ import {
|
|
|
61
61
|
import {
|
|
62
62
|
isPidAlive,
|
|
63
63
|
readProcessStartTime
|
|
64
|
-
} from "./index-
|
|
64
|
+
} from "./index-0th11rhf.js";
|
|
65
65
|
import {
|
|
66
66
|
withReadOnlySessionDb,
|
|
67
67
|
expandToolPart,
|
|
68
68
|
visitRawSessionMessages2,
|
|
69
69
|
readRawSessionMessageById2
|
|
70
|
-
} from "./index-
|
|
70
|
+
} from "./index-hpbdnbtf.js";
|
|
71
71
|
import {
|
|
72
72
|
gaDatabasePath2,
|
|
73
73
|
V2StoreReader2
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
import {
|
|
57
57
|
piHarnessKindFromExecutable,
|
|
58
58
|
getErrorMessage
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-0th11rhf.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-6crdakkm.js";
|
|
74
74
|
import {
|
|
75
75
|
getLastIndexedOrdinal
|
|
76
|
-
} from "./index-
|
|
76
|
+
} from "./index-0t9xfj3x.js";
|
|
77
77
|
import {
|
|
78
78
|
TODO_STATUSES,
|
|
79
79
|
TODO_PRIORITIES,
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
getCompactionMarkerPublicationState,
|
|
90
90
|
compareAndSetCompactionMarkerPublicationState,
|
|
91
91
|
getDeferredClearedCompactionMarkerState
|
|
92
|
-
} from "./index-
|
|
92
|
+
} from "./index-nh4srq1p.js";
|
|
93
93
|
import {
|
|
94
94
|
stableStringify,
|
|
95
95
|
BoundedSessionMap
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
resolveMemoriesByIdsForSearch2,
|
|
143
143
|
unifiedSearch2,
|
|
144
144
|
formatSearchResults2
|
|
145
|
-
} from "./index-
|
|
145
|
+
} from "./index-55dhgfwp.js";
|
|
146
146
|
import {
|
|
147
147
|
resolveOpenCodeDbPath,
|
|
148
148
|
assertOpenCodeStoreGeneration
|
|
@@ -151,7 +151,7 @@ import {
|
|
|
151
151
|
hasRawMessageProvider2,
|
|
152
152
|
setRawMessageProvider2,
|
|
153
153
|
readSessionChunk2
|
|
154
|
-
} from "./index-
|
|
154
|
+
} from "./index-hpbdnbtf.js";
|
|
155
155
|
import {
|
|
156
156
|
resolveWorkspaceShareCategories,
|
|
157
157
|
resolveWorkspaceIdentitySet,
|
|
@@ -184,7 +184,7 @@ import {
|
|
|
184
184
|
} from "./index-3s39a1md.js";
|
|
185
185
|
import {
|
|
186
186
|
renderSearchArchive2
|
|
187
|
-
} from "./index-
|
|
187
|
+
} from "./index-fvfq9gva.js";
|
|
188
188
|
import {
|
|
189
189
|
computeNormalizedHash
|
|
190
190
|
} from "./index-9x1f96r8.js";
|
|
@@ -3839,7 +3839,7 @@ function beginCurateCategoryRun(db, projectIdentity, memories) {
|
|
|
3839
3839
|
}));
|
|
3840
3840
|
return scope;
|
|
3841
3841
|
}
|
|
3842
|
-
function
|
|
3842
|
+
function curateTaskStateAfterCategoryTurn(db, projectIdentity, category) {
|
|
3843
3843
|
const state = readState(db, projectIdentity);
|
|
3844
3844
|
return JSON.stringify({
|
|
3845
3845
|
...state,
|
|
@@ -6555,6 +6555,22 @@ function isDirectiveShapedProjectRule(category, content) {
|
|
|
6555
6555
|
// ../plugin/src/features/magic-context/dreamer/curate-memory-safety.ts
|
|
6556
6556
|
var PROJECT_SCOPED_CATEGORIES = new Set(V2_MEMORY_CATEGORIES);
|
|
6557
6557
|
var USER_PROFILE_REFERENCE = /\buser(?:[\s_-]+)(?:profile|preferences?)\b|\bU\d+\b/i;
|
|
6558
|
+
var CURATE_SAFETY_REFUSAL_REASONS = [
|
|
6559
|
+
"missing-active-same-category-successor",
|
|
6560
|
+
"user-profile-is-not-project-memory",
|
|
6561
|
+
"directive-shaped-project-rule",
|
|
6562
|
+
"content-loss"
|
|
6563
|
+
];
|
|
6564
|
+
var refusalReasons = new Set(CURATE_SAFETY_REFUSAL_REASONS);
|
|
6565
|
+
function parseCurateSafetyRefusal(action, output) {
|
|
6566
|
+
if (action !== "archive" && action !== "update")
|
|
6567
|
+
return null;
|
|
6568
|
+
const refusal = /^Skipped (archive|update) for memory \[ID: -?\d+(?:, -?\d+)*\]: curate safety refusal \(([a-z,-]+)\); refused=[1-9]\d*\.$/.exec(output);
|
|
6569
|
+
if (refusal?.[1] !== action || !refusal[2])
|
|
6570
|
+
return null;
|
|
6571
|
+
const reasons = [...new Set(refusal[2].split(","))];
|
|
6572
|
+
return reasons.every((reason) => refusalReasons.has(reason)) ? reasons : null;
|
|
6573
|
+
}
|
|
6558
6574
|
var refusalCountsBySession = new Map;
|
|
6559
6575
|
function isSurvivingConsolidationTarget(memory, successor, projectIdentity) {
|
|
6560
6576
|
return successor !== null && successor.id !== memory.id && successor.status === "active" && successor.supersededByMemoryId === null && (successor.expiresAt === null || successor.expiresAt > Date.now()) && projectIdentity(successor) === projectIdentity(memory) && successor.category === memory.category;
|
|
@@ -11042,4 +11058,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
11042
11058
|
}
|
|
11043
11059
|
}
|
|
11044
11060
|
|
|
11045
|
-
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,
|
|
11061
|
+
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, curateTaskStateAfterCategoryTurn, 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, resolveWorkspaceRenderContext, sourceNamesForMemories, readM0ProjectMemories, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, parseCurateSafetyRefusal, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, neutralizeOmpMentions, restoreOmpMentions, resolvePiHarnessDetection, resolvePiHarnessKind, readSubagentStartupError, reportSubagentStartupError, legacyTui, canRenderPiRows, piTerminalRows, piOverlayOptions, matchesKey, truncateToWidth, visibleWidth, inheritPiOrdinalAlignment, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
@@ -138,10 +138,10 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
138
138
|
] = await Promise.all([
|
|
139
139
|
import("./sqlite-v89bj0yy.js"),
|
|
140
140
|
import("./store-reader-mmfw2h48.js"),
|
|
141
|
-
import("./store-
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
141
|
+
import("./store-e9ve3qzt.js"),
|
|
142
|
+
import("./read-session-chunk-wek7gb7j.js"),
|
|
143
|
+
import("./render-fhrce5g6.js"),
|
|
144
|
+
import("./search-archive-661vc3fb.js"),
|
|
145
145
|
import("./expand-attachments-8sxeyj26.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -1379,15 +1379,17 @@ function estimateImageTokensFromHeader(header, bytes, jpegReader) {
|
|
|
1379
1379
|
function nativeMediaImage(part) {
|
|
1380
1380
|
if (part.type !== "media" || !isRecord(part.media))
|
|
1381
1381
|
return;
|
|
1382
|
-
const { mediaType, source } = part.media;
|
|
1382
|
+
const { mediaType: assetMediaType, source } = part.media;
|
|
1383
|
+
const encoded = assetMediaType === undefined;
|
|
1384
|
+
const mediaType = encoded && isRecord(source) ? source.mediaType : assetMediaType;
|
|
1383
1385
|
if (typeof mediaType !== "string" || !mediaType.startsWith("image/"))
|
|
1384
1386
|
return;
|
|
1385
1387
|
let inline;
|
|
1386
1388
|
if (isRecord(source)) {
|
|
1387
1389
|
const { type, data } = source;
|
|
1388
|
-
if (type === "base64" && typeof data === "string" && data.length > 0)
|
|
1390
|
+
if ((type === "base64" || encoded && type === "bytes") && typeof data === "string" && data.length > 0)
|
|
1389
1391
|
inline = data;
|
|
1390
|
-
if (type === "bytes" && data instanceof Uint8Array && data.byteLength > 0)
|
|
1392
|
+
if (!encoded && type === "bytes" && data instanceof Uint8Array && data.byteLength > 0)
|
|
1391
1393
|
inline = data;
|
|
1392
1394
|
}
|
|
1393
1395
|
return { mediaType, inline };
|
package/dist/index.js
CHANGED
|
@@ -93,7 +93,7 @@ import {
|
|
|
93
93
|
curateCategoryForMemoryCategory,
|
|
94
94
|
peekCurateCategoryScope,
|
|
95
95
|
beginCurateCategoryRun,
|
|
96
|
-
|
|
96
|
+
curateTaskStateAfterCategoryTurn,
|
|
97
97
|
MEMORY_MURAL_BLOCK,
|
|
98
98
|
buildMagicContextSection,
|
|
99
99
|
resolveMuralWire,
|
|
@@ -134,6 +134,7 @@ import {
|
|
|
134
134
|
stripMemoryMuralBlock,
|
|
135
135
|
resetPrefixTrimFallbackState,
|
|
136
136
|
isDirectiveShapedProjectRule,
|
|
137
|
+
parseCurateSafetyRefusal,
|
|
137
138
|
takeCurateSafetyRefusalCount,
|
|
138
139
|
wakePlaneStatus,
|
|
139
140
|
loadPiConfig,
|
|
@@ -165,7 +166,7 @@ import {
|
|
|
165
166
|
registerTodoStateLifecycle,
|
|
166
167
|
syncCtxMemoryToolEnabled,
|
|
167
168
|
registerMagicContextTools
|
|
168
|
-
} from "./index-
|
|
169
|
+
} from "./index-97ay0whg.js";
|
|
169
170
|
import"./index-4knyh1kt.js";
|
|
170
171
|
import {
|
|
171
172
|
canonicalModelIdentity,
|
|
@@ -417,7 +418,7 @@ import {
|
|
|
417
418
|
setSessionWorkMetrics,
|
|
418
419
|
getSessionWorkMetrics,
|
|
419
420
|
resolveEpochFloorForPass
|
|
420
|
-
} from "./index-
|
|
421
|
+
} from "./index-nh4srq1p.js";
|
|
421
422
|
import {
|
|
422
423
|
textMentionsRecentCommit,
|
|
423
424
|
hasMeaningfulUserText2,
|
|
@@ -468,7 +469,7 @@ import {
|
|
|
468
469
|
openCurrentDatabase,
|
|
469
470
|
openDatabaseAsync,
|
|
470
471
|
closeDatabase
|
|
471
|
-
} from "./index-
|
|
472
|
+
} from "./index-0th11rhf.js";
|
|
472
473
|
import {
|
|
473
474
|
LkgRecoveryFenceError,
|
|
474
475
|
clearLkgFenceProcessState,
|
|
@@ -598,7 +599,7 @@ import {
|
|
|
598
599
|
getSourceContents,
|
|
599
600
|
recordSubagentInvocation,
|
|
600
601
|
getLatestHistorianInvocationId
|
|
601
|
-
} from "./index-
|
|
602
|
+
} from "./index-6crdakkm.js";
|
|
602
603
|
import {
|
|
603
604
|
resolveOpenCodeDbPath,
|
|
604
605
|
assertOpenCodeStoreGeneration,
|
|
@@ -664,7 +665,7 @@ import {
|
|
|
664
665
|
getRawSessionTagKeysThrough2,
|
|
665
666
|
getLegacyProtectedTailStartOrdinal2,
|
|
666
667
|
readSessionChunk2
|
|
667
|
-
} from "./index-
|
|
668
|
+
} from "./index-hpbdnbtf.js";
|
|
668
669
|
import"./index-nvh6d3bz.js";
|
|
669
670
|
import {
|
|
670
671
|
formatSynapseLaneDescriptor
|
|
@@ -704,7 +705,7 @@ import {
|
|
|
704
705
|
clearCompressionDepthRange,
|
|
705
706
|
cleanSearchText,
|
|
706
707
|
matchedSearchSnippet
|
|
707
|
-
} from "./index-
|
|
708
|
+
} from "./index-0t9xfj3x.js";
|
|
708
709
|
import {
|
|
709
710
|
rememberV1HiddenRun
|
|
710
711
|
} from "./index-6x556c2q.js";
|
|
@@ -831,7 +832,7 @@ import {
|
|
|
831
832
|
scheduleClearAndReindex,
|
|
832
833
|
clearSessionTracking,
|
|
833
834
|
createAutoSearchDiagnostics
|
|
834
|
-
} from "./index-
|
|
835
|
+
} from "./index-55dhgfwp.js";
|
|
835
836
|
import"./index-gczr1m66.js";
|
|
836
837
|
import"./index-3s39a1md.js";
|
|
837
838
|
import {
|
|
@@ -862,11 +863,11 @@ import {
|
|
|
862
863
|
drainPiTagSnapshotSession,
|
|
863
864
|
assertPiTagSnapshotReady,
|
|
864
865
|
ensurePiTagSnapshotReady
|
|
865
|
-
} from "./index-
|
|
866
|
+
} from "./index-pdrberjp.js";
|
|
866
867
|
import"./index-71rg8j43.js";
|
|
867
868
|
import"./index-8d2z6503.js";
|
|
868
|
-
import"./index-
|
|
869
|
-
import"./index-
|
|
869
|
+
import"./index-hnvq96j6.js";
|
|
870
|
+
import"./index-fvfq9gva.js";
|
|
870
871
|
import {
|
|
871
872
|
__toESM
|
|
872
873
|
} from "./index-22jkk6wg.js";
|
|
@@ -3618,7 +3619,7 @@ function startHostStallProfilerSwitch() {
|
|
|
3618
3619
|
// package.json
|
|
3619
3620
|
var package_default = {
|
|
3620
3621
|
name: "@cortexkit/pi-magic-context",
|
|
3621
|
-
version: "0.49.
|
|
3622
|
+
version: "0.49.79",
|
|
3622
3623
|
type: "module",
|
|
3623
3624
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
3624
3625
|
main: "dist/index.js",
|
|
@@ -18211,8 +18212,11 @@ function validateCurateAssistantText(text) {
|
|
|
18211
18212
|
}
|
|
18212
18213
|
return text;
|
|
18213
18214
|
}
|
|
18215
|
+
function emptyCurateMemoryOperations() {
|
|
18216
|
+
return { totalCalls: 0, completedActions: [], refusals: [] };
|
|
18217
|
+
}
|
|
18214
18218
|
function inspectCurateMemoryOperations(messages) {
|
|
18215
|
-
const summary =
|
|
18219
|
+
const summary = emptyCurateMemoryOperations();
|
|
18216
18220
|
if (!Array.isArray(messages))
|
|
18217
18221
|
return summary;
|
|
18218
18222
|
for (const message of messages) {
|
|
@@ -18227,28 +18231,69 @@ function inspectCurateMemoryOperations(messages) {
|
|
|
18227
18231
|
const toolName = part.tool ?? part.name;
|
|
18228
18232
|
if (toolName !== "ctx_memory")
|
|
18229
18233
|
continue;
|
|
18234
|
+
const state = isRecord(part.state) ? part.state : null;
|
|
18235
|
+
const input = isRecord(state?.input) ? state.input : null;
|
|
18236
|
+
const action = input?.action;
|
|
18237
|
+
const output = state?.status === "completed" && typeof state.output === "string" ? state.output : null;
|
|
18238
|
+
if (output && (action === "get" || action === "list") && /^(?:Found \d+ (?:active )?memor(?:y|ies):|No active memories found\.$|id -?\d+: not found or not visible from this project)/.test(output))
|
|
18239
|
+
continue;
|
|
18230
18240
|
summary.totalCalls += 1;
|
|
18231
|
-
if (!
|
|
18241
|
+
if (!output)
|
|
18232
18242
|
continue;
|
|
18233
|
-
|
|
18234
|
-
const action = input?.action;
|
|
18235
|
-
const output = typeof part.state.output === "string" ? part.state.output : "";
|
|
18236
|
-
if (output === "completed" && (action === "merge" || action === "archive" || action === "update") || action === "merge" && output.startsWith("Merged memories") || action === "archive" && output.startsWith("Archived memor") || action === "update" && output.startsWith("Updated memory"))
|
|
18243
|
+
if (action === "merge" && output.startsWith("Merged memories") || action === "archive" && output.startsWith("Archived memor") || action === "update" && output.startsWith("Updated memory")) {
|
|
18237
18244
|
summary.completedActions.push(action);
|
|
18245
|
+
} else {
|
|
18246
|
+
const reasons = parseCurateSafetyRefusal(action, output);
|
|
18247
|
+
if (reasons)
|
|
18248
|
+
summary.refusals.push(reasons);
|
|
18249
|
+
}
|
|
18238
18250
|
}
|
|
18239
18251
|
}
|
|
18240
18252
|
return summary;
|
|
18241
18253
|
}
|
|
18254
|
+
function unrecognisedCurateOperations(operations) {
|
|
18255
|
+
return operations.totalCalls - operations.completedActions.length - operations.refusals.length;
|
|
18256
|
+
}
|
|
18257
|
+
function validateCurateOutput(messages, text, transport) {
|
|
18258
|
+
const operations = inspectCurateMemoryOperations(messages);
|
|
18259
|
+
if (text)
|
|
18260
|
+
validateCurateAssistantText(text);
|
|
18261
|
+
if (operations.completedActions.length || operations.refusals.length && !unrecognisedCurateOperations(operations))
|
|
18262
|
+
return operations;
|
|
18263
|
+
if (!text && transport === "child")
|
|
18264
|
+
throw new Error("Dreamer returned no assistant output.");
|
|
18265
|
+
if (operations.totalCalls > 0)
|
|
18266
|
+
throw new Error("Curate returned no completed ctx_memory tool result.");
|
|
18267
|
+
if (!text)
|
|
18268
|
+
throw new Error("Dreamer returned no assistant output.");
|
|
18269
|
+
return operations;
|
|
18270
|
+
}
|
|
18242
18271
|
function formatExpiredArchiveProgress(count) {
|
|
18243
18272
|
return `curate: archived ${count} expired ${count === 1 ? "memory" : "memories"}`;
|
|
18244
18273
|
}
|
|
18245
|
-
function formatCurateMemoryOperations(
|
|
18274
|
+
function formatCurateMemoryOperations(operations) {
|
|
18275
|
+
const { completedActions: actions, refusals } = operations;
|
|
18276
|
+
if (!actions.length && !refusals.length)
|
|
18277
|
+
return null;
|
|
18246
18278
|
const actionCounts = new Map;
|
|
18247
18279
|
for (const action of actions)
|
|
18248
18280
|
actionCounts.set(action, (actionCounts.get(action) ?? 0) + 1);
|
|
18249
18281
|
const actionDetail = [...actionCounts].map(([action, count]) => count === 1 ? action : `${action} ×${count}`).join(", ");
|
|
18250
|
-
const
|
|
18251
|
-
|
|
18282
|
+
const applied = actions.length ? `${actions.length} memory ${actions.length === 1 ? "operation" : "operations"} applied (${actionDetail})` : "no changes";
|
|
18283
|
+
const detail = [`curate: ${applied}`];
|
|
18284
|
+
if (refusals.length) {
|
|
18285
|
+
const reasonCounts = new Map;
|
|
18286
|
+
for (const reasons of refusals) {
|
|
18287
|
+
for (const reason of reasons)
|
|
18288
|
+
reasonCounts.set(reason, (reasonCounts.get(reason) ?? 0) + 1);
|
|
18289
|
+
}
|
|
18290
|
+
const countedReasons = [...reasonCounts].sort(([a], [b]) => a.localeCompare(b)).map(([reason, count]) => `${reason} ×${count}`).join(", ");
|
|
18291
|
+
detail.push(`${refusals.length} ${refusals.length === 1 ? "operation" : "operations"} refused (${countedReasons})`);
|
|
18292
|
+
}
|
|
18293
|
+
const unrecognised = unrecognisedCurateOperations(operations);
|
|
18294
|
+
if (unrecognised)
|
|
18295
|
+
detail.push(`${unrecognised} with an unrecognised result`);
|
|
18296
|
+
return detail.join("; ");
|
|
18252
18297
|
}
|
|
18253
18298
|
function requireDreamClient(client) {
|
|
18254
18299
|
if (!client)
|
|
@@ -18456,6 +18501,7 @@ function createDreamTaskExecutor(deps) {
|
|
|
18456
18501
|
};
|
|
18457
18502
|
return writtenIds.length || deletedIds.length || archivedIds.length || mergedIds.length ? changes : null;
|
|
18458
18503
|
}
|
|
18504
|
+
let curateCategory;
|
|
18459
18505
|
try {
|
|
18460
18506
|
const skip = (reason) => {
|
|
18461
18507
|
log2(`[dreamer] ${config.task}: skipped (${reason})`);
|
|
@@ -18767,7 +18813,10 @@ function createDreamTaskExecutor(deps) {
|
|
|
18767
18813
|
computeMemoryDelta,
|
|
18768
18814
|
reportProgress,
|
|
18769
18815
|
leaseAcquisition,
|
|
18770
|
-
moduleRoute
|
|
18816
|
+
moduleRoute,
|
|
18817
|
+
onCurateCategory: (category) => {
|
|
18818
|
+
curateCategory = category;
|
|
18819
|
+
}
|
|
18771
18820
|
});
|
|
18772
18821
|
} catch (error) {
|
|
18773
18822
|
if (error instanceof DreamTokenBudgetExceeded) {
|
|
@@ -18785,7 +18834,11 @@ function createDreamTaskExecutor(deps) {
|
|
|
18785
18834
|
transient,
|
|
18786
18835
|
error: brief,
|
|
18787
18836
|
failureDetail: formatDreamRunFailure(failure),
|
|
18788
|
-
...retrospectiveOverflow ? { schedulePatch: retrospectiveOverflow.schedulePatch } : {
|
|
18837
|
+
...retrospectiveOverflow ? { schedulePatch: retrospectiveOverflow.schedulePatch } : curateCategory && !transient ? {
|
|
18838
|
+
schedulePatch: {
|
|
18839
|
+
taskStateJson: curateTaskStateAfterCategoryTurn(db, projectIdentity, curateCategory)
|
|
18840
|
+
}
|
|
18841
|
+
} : {}
|
|
18789
18842
|
};
|
|
18790
18843
|
} finally {
|
|
18791
18844
|
deps.onProgress?.(null, config.task);
|
|
@@ -19292,6 +19345,8 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19292
19345
|
const scope = beginCurateCategoryRun(db, projectIdentity, loadActiveMemoryPromptMemories(db, projectIdentity));
|
|
19293
19346
|
curateMemories = scope?.memories ?? [];
|
|
19294
19347
|
curateCategory = scope?.category;
|
|
19348
|
+
if (curateCategory)
|
|
19349
|
+
helpers.onCurateCategory(curateCategory);
|
|
19295
19350
|
log2(`[dreamer] curate pool: category=${curateCategory ?? "none"} in_scope=${curateMemories.length} expired_archived=${expiredArchived}`);
|
|
19296
19351
|
if (curateMemories.length === 0) {
|
|
19297
19352
|
const progress = expiredArchived > 0 ? formatExpiredArchiveProgress(expiredArchived) : "curate: no populated project-memory category";
|
|
@@ -19327,7 +19382,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19327
19382
|
}
|
|
19328
19383
|
const curateChunks = curateMemories ? chunkCurateMemories(curateMemories, Math.max(4000, Math.floor(resolveRetrospectiveUsableInputTokens(config, deps) * 2))) : [];
|
|
19329
19384
|
const batches = task === "curate" ? curateChunks : [{ memories: [], crossChunkCandidates: [] }];
|
|
19330
|
-
const
|
|
19385
|
+
const curateOperations = emptyCurateMemoryOperations();
|
|
19331
19386
|
let curateRefused = 0;
|
|
19332
19387
|
let run = {
|
|
19333
19388
|
output: [],
|
|
@@ -19376,14 +19431,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19376
19431
|
parseDocsProposalOutput(text);
|
|
19377
19432
|
if (task !== "curate")
|
|
19378
19433
|
return text;
|
|
19379
|
-
|
|
19380
|
-
if (text)
|
|
19381
|
-
validateCurateAssistantText(text);
|
|
19382
|
-
if (memoryOperations.totalCalls > 0 && memoryOperations.completedActions.length === 0)
|
|
19383
|
-
throw new Error("Curate returned no completed ctx_memory tool result.");
|
|
19384
|
-
if (!text && memoryOperations.completedActions.length === 0)
|
|
19385
|
-
throw new Error("Dreamer returned no assistant output.");
|
|
19386
|
-
return { text: text || null, memoryOperations };
|
|
19434
|
+
return validateCurateOutput(completion.messages, text, "hidden");
|
|
19387
19435
|
}
|
|
19388
19436
|
});
|
|
19389
19437
|
childSessionId = hidden.childSessionId;
|
|
@@ -19442,24 +19490,15 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19442
19490
|
parseDocsProposalOutput(text);
|
|
19443
19491
|
return text;
|
|
19444
19492
|
}
|
|
19445
|
-
|
|
19446
|
-
if (text)
|
|
19447
|
-
validateCurateAssistantText(text);
|
|
19448
|
-
if (memoryOperations.completedActions.length > 0) {
|
|
19449
|
-
return { text, memoryOperations };
|
|
19450
|
-
}
|
|
19451
|
-
if (!text)
|
|
19452
|
-
throw new Error("Dreamer returned no assistant output.");
|
|
19453
|
-
if (memoryOperations.totalCalls > 0) {
|
|
19454
|
-
throw new Error("Curate returned no completed ctx_memory tool result.");
|
|
19455
|
-
}
|
|
19456
|
-
return { text, memoryOperations };
|
|
19493
|
+
return validateCurateOutput(messages, text, "child");
|
|
19457
19494
|
}
|
|
19458
19495
|
});
|
|
19459
19496
|
promptSettled = true;
|
|
19460
19497
|
}
|
|
19461
|
-
if (
|
|
19462
|
-
|
|
19498
|
+
if (typeof run.validated !== "string") {
|
|
19499
|
+
curateOperations.totalCalls += run.validated.totalCalls;
|
|
19500
|
+
curateOperations.completedActions.push(...run.validated.completedActions);
|
|
19501
|
+
curateOperations.refusals.push(...run.validated.refusals);
|
|
19463
19502
|
curateRefused += takeCurateSafetyRefusalCount(childSessionId ?? "");
|
|
19464
19503
|
}
|
|
19465
19504
|
if (childSessionId && !deps.hiddenCompletionExecutor) {
|
|
@@ -19475,17 +19514,15 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19475
19514
|
childSessionId = null;
|
|
19476
19515
|
}
|
|
19477
19516
|
}
|
|
19478
|
-
if (task === "curate")
|
|
19479
|
-
run.validated = {
|
|
19480
|
-
text: null,
|
|
19481
|
-
memoryOperations: { totalCalls: completedActions.length, completedActions }
|
|
19482
|
-
};
|
|
19483
19517
|
if (leaseLost)
|
|
19484
19518
|
throw new Error("Dream lease lost during task");
|
|
19485
19519
|
if (curateRefused > 0) {
|
|
19486
19520
|
helpers.reportProgress(curateRefused, curateRefused);
|
|
19487
19521
|
log2(`[dreamer] curate safety summary: refused=${curateRefused}`);
|
|
19488
19522
|
}
|
|
19523
|
+
const unrecognised = unrecognisedCurateOperations(curateOperations);
|
|
19524
|
+
if (unrecognised > 0)
|
|
19525
|
+
log2(`[dreamer] curate result summary: unrecognised=${unrecognised}`);
|
|
19489
19526
|
recordInvocation("completed", run.output);
|
|
19490
19527
|
if (task === "maintain-docs" && docsHashes && changes) {
|
|
19491
19528
|
try {
|
|
@@ -19505,13 +19542,12 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19505
19542
|
return { status: "failed", error: reason };
|
|
19506
19543
|
}
|
|
19507
19544
|
}
|
|
19508
|
-
const curateOutput = task === "curate" ? run.validated : undefined;
|
|
19509
19545
|
const curateScopeProgress = task === "curate" && curateCategory && curateMemories ? `curate: ${curateCategory} (${curateMemories.length})` : null;
|
|
19510
19546
|
const progress = [
|
|
19511
19547
|
curateScopeProgress,
|
|
19512
19548
|
expiredArchived > 0 ? formatExpiredArchiveProgress(expiredArchived) : null,
|
|
19513
|
-
|
|
19514
|
-
curateRefused > 0 ? `curate: refused ${curateRefused} unsafe mutation(s)` : null
|
|
19549
|
+
formatCurateMemoryOperations(curateOperations),
|
|
19550
|
+
curateRefused > 0 && !curateOperations.refusals.length ? `curate: refused ${curateRefused} unsafe mutation(s)` : null
|
|
19515
19551
|
].filter((value) => Boolean(value)).join("; ");
|
|
19516
19552
|
const curateCount = task === "curate" && curateCategory ? loadActiveMemoryPromptMemories(db, projectIdentity).filter((memory) => curateCategoryForMemoryCategory(memory.category) === curateCategory).length : undefined;
|
|
19517
19553
|
const curateBacklog = curateCount !== undefined && curateCategory ? {
|
|
@@ -19530,7 +19566,7 @@ async function runAgenticTask(config, ctx, helpers) {
|
|
|
19530
19566
|
...curateBacklog ? { backlog: curateBacklog } : {},
|
|
19531
19567
|
...curateCategory ? {
|
|
19532
19568
|
schedulePatch: {
|
|
19533
|
-
taskStateJson:
|
|
19569
|
+
taskStateJson: curateTaskStateAfterCategoryTurn(db, projectIdentity, curateCategory)
|
|
19534
19570
|
}
|
|
19535
19571
|
} : {}
|
|
19536
19572
|
};
|
|
@@ -21949,15 +21985,23 @@ class PiSubagentRunner {
|
|
|
21949
21985
|
});
|
|
21950
21986
|
if (settled)
|
|
21951
21987
|
return;
|
|
21952
|
-
const
|
|
21953
|
-
if (
|
|
21988
|
+
const toolResults = (messages) => {
|
|
21989
|
+
if (options.accountingTask === "curate")
|
|
21990
|
+
return {
|
|
21991
|
+
curateMemoryToolCalls: extractCurateMemoryToolCalls(messages)
|
|
21992
|
+
};
|
|
21993
|
+
const completedToolCalls = extractCompletedToolCalls(messages).filter((call) => call.name === "ctx_memory");
|
|
21994
|
+
return completedToolCalls.length ? { completedToolCalls } : {};
|
|
21995
|
+
};
|
|
21996
|
+
const settleToolOnlyDreamer = (messages, results) => {
|
|
21997
|
+
if (!DREAMER_ACTION_AGENTS.has(options.agent) || !results.completedToolCalls?.length && !results.curateMemoryToolCalls?.length) {
|
|
21954
21998
|
return false;
|
|
21955
21999
|
}
|
|
21956
22000
|
settle({
|
|
21957
22001
|
ok: true,
|
|
21958
22002
|
assistantText: "",
|
|
21959
22003
|
toolCallCount: countToolCalls(messages),
|
|
21960
|
-
|
|
22004
|
+
...results,
|
|
21961
22005
|
durationMs: Date.now() - startTime,
|
|
21962
22006
|
meta: { stderr: stderr.length > 0 ? stderr : undefined }
|
|
21963
22007
|
});
|
|
@@ -21965,11 +22009,10 @@ class PiSubagentRunner {
|
|
|
21965
22009
|
};
|
|
21966
22010
|
if (sawAgentEnd) {
|
|
21967
22011
|
const outputMessages = agentEndMessages ?? accumulatedMessages;
|
|
21968
|
-
const
|
|
21969
|
-
const completedMemoryCalls = completedCalls.filter((call) => call.name === "ctx_memory");
|
|
22012
|
+
const results = toolResults(outputMessages);
|
|
21970
22013
|
const trimmedAssistantText = finalAssistantText?.trim() ?? null;
|
|
21971
22014
|
if (trimmedAssistantText === null || trimmedAssistantText.length === 0) {
|
|
21972
|
-
if (
|
|
22015
|
+
if (settleToolOnlyDreamer(outputMessages, results))
|
|
21973
22016
|
return;
|
|
21974
22017
|
const emptyAssistantReason = trimmedAssistantText === null ? "pi agent_end did not include an assistant message" : "pi assistant produced empty text";
|
|
21975
22018
|
settle({
|
|
@@ -21998,7 +22041,7 @@ class PiSubagentRunner {
|
|
|
21998
22041
|
ok: true,
|
|
21999
22042
|
assistantText: trimmedAssistantText,
|
|
22000
22043
|
toolCallCount: countToolCalls(outputMessages),
|
|
22001
|
-
...
|
|
22044
|
+
...results,
|
|
22002
22045
|
durationMs: Date.now() - startTime,
|
|
22003
22046
|
meta: { stderr: stderr.length > 0 ? stderr : undefined }
|
|
22004
22047
|
});
|
|
@@ -22032,8 +22075,7 @@ class PiSubagentRunner {
|
|
|
22032
22075
|
});
|
|
22033
22076
|
return;
|
|
22034
22077
|
}
|
|
22035
|
-
|
|
22036
|
-
if (settleCompletedToolOnlyDreamer(accumulatedMessages, completedMemoryCalls))
|
|
22078
|
+
if (settleToolOnlyDreamer(accumulatedMessages, toolResults(accumulatedMessages)))
|
|
22037
22079
|
return;
|
|
22038
22080
|
settle({
|
|
22039
22081
|
ok: false,
|
|
@@ -22252,7 +22294,7 @@ function extractFinalAssistant(messages) {
|
|
|
22252
22294
|
}
|
|
22253
22295
|
return { text: null, stopReason: null, errorMessage: null };
|
|
22254
22296
|
}
|
|
22255
|
-
function
|
|
22297
|
+
function extractToolInvocations(messages) {
|
|
22256
22298
|
const invocations = new Map;
|
|
22257
22299
|
for (const message of messages) {
|
|
22258
22300
|
if (typeof message !== "object" || message === null)
|
|
@@ -22274,6 +22316,10 @@ function extractCompletedToolCalls(messages) {
|
|
|
22274
22316
|
invocations.set(id, { name, arguments: args });
|
|
22275
22317
|
}
|
|
22276
22318
|
}
|
|
22319
|
+
return invocations;
|
|
22320
|
+
}
|
|
22321
|
+
function extractCompletedToolCalls(messages) {
|
|
22322
|
+
const invocations = extractToolInvocations(messages);
|
|
22277
22323
|
const completed = [];
|
|
22278
22324
|
const seen = new Set;
|
|
22279
22325
|
for (const message of messages) {
|
|
@@ -22293,6 +22339,36 @@ function extractCompletedToolCalls(messages) {
|
|
|
22293
22339
|
}
|
|
22294
22340
|
return completed;
|
|
22295
22341
|
}
|
|
22342
|
+
function extractCurateMemoryToolCalls(messages) {
|
|
22343
|
+
const calls = new Map;
|
|
22344
|
+
for (const [id, call] of extractToolInvocations(messages)) {
|
|
22345
|
+
if (call.name === "ctx_memory")
|
|
22346
|
+
calls.set(id, {
|
|
22347
|
+
id,
|
|
22348
|
+
name: call.name,
|
|
22349
|
+
arguments: call.arguments,
|
|
22350
|
+
status: "pending"
|
|
22351
|
+
});
|
|
22352
|
+
}
|
|
22353
|
+
for (const message of messages) {
|
|
22354
|
+
if (typeof message !== "object" || message === null)
|
|
22355
|
+
continue;
|
|
22356
|
+
const result = message;
|
|
22357
|
+
if (result.role !== "toolResult" || typeof result.toolCallId !== "string" || typeof result.isError !== "boolean")
|
|
22358
|
+
continue;
|
|
22359
|
+
const call = calls.get(result.toolCallId);
|
|
22360
|
+
if (call?.status !== "pending" || typeof result.toolName === "string" && result.toolName !== call.name)
|
|
22361
|
+
continue;
|
|
22362
|
+
call.status = result.isError ? "error" : "completed";
|
|
22363
|
+
if (Array.isArray(result.content)) {
|
|
22364
|
+
const text = result.content.flatMap((part) => part?.type === "text" && typeof part.text === "string" ? [part.text] : []).join(`
|
|
22365
|
+
`);
|
|
22366
|
+
if (text)
|
|
22367
|
+
call.output = text;
|
|
22368
|
+
}
|
|
22369
|
+
}
|
|
22370
|
+
return [...calls.values()];
|
|
22371
|
+
}
|
|
22296
22372
|
function countToolCalls(messages) {
|
|
22297
22373
|
let count = 0;
|
|
22298
22374
|
for (const msg of messages) {
|
|
@@ -23389,7 +23465,7 @@ function createPiDreamerClient(opts, onAdjunctsRefreshNeeded = opts.onAdjunctsRe
|
|
|
23389
23465
|
dreamSession.messages = [
|
|
23390
23466
|
makeMessage("user", [{ type: "text", text: userMessage }]),
|
|
23391
23467
|
makeMessage("assistant", [
|
|
23392
|
-
...syntheticToolParts(result.toolCallCount ?? 0, result.completedToolCalls),
|
|
23468
|
+
...syntheticToolParts(result.toolCallCount ?? 0, result.completedToolCalls, accountingTask === "curate" ? result.curateMemoryToolCalls ?? [] : undefined),
|
|
23393
23469
|
...result.assistantText ? [{ type: "text", text: result.assistantText }] : []
|
|
23394
23470
|
])
|
|
23395
23471
|
];
|
|
@@ -23505,9 +23581,17 @@ function extractBodyAgent(args) {
|
|
|
23505
23581
|
const agent = body.agent;
|
|
23506
23582
|
return typeof agent === "string" && agent.length > 0 ? agent : undefined;
|
|
23507
23583
|
}
|
|
23508
|
-
function syntheticToolParts(count, completedCalls = []) {
|
|
23509
|
-
const
|
|
23510
|
-
|
|
23584
|
+
function syntheticToolParts(count, completedCalls = [], curateCalls) {
|
|
23585
|
+
const calls = curateCalls ? curateCalls.map((call) => ({
|
|
23586
|
+
type: "tool",
|
|
23587
|
+
callID: call.id,
|
|
23588
|
+
tool: call.name,
|
|
23589
|
+
state: {
|
|
23590
|
+
status: call.status,
|
|
23591
|
+
input: call.arguments,
|
|
23592
|
+
...call.output === undefined ? {} : call.status === "error" ? { error: call.output } : { output: call.output }
|
|
23593
|
+
}
|
|
23594
|
+
})) : completedCalls.map((call, index) => ({
|
|
23511
23595
|
type: "tool",
|
|
23512
23596
|
callID: `pi-completed-tool-${index}`,
|
|
23513
23597
|
tool: call.name,
|
|
@@ -23517,12 +23601,12 @@ function syntheticToolParts(count, completedCalls = []) {
|
|
|
23517
23601
|
output: "completed"
|
|
23518
23602
|
}
|
|
23519
23603
|
}));
|
|
23520
|
-
const remaining = Array.from({ length:
|
|
23604
|
+
const remaining = Array.from({ length: Math.max(0, Math.floor(count) - calls.length) }, () => ({
|
|
23521
23605
|
type: "tool",
|
|
23522
23606
|
tool: "investigation",
|
|
23523
23607
|
state: { input: { description: "investigation step" } }
|
|
23524
23608
|
}));
|
|
23525
|
-
return [...
|
|
23609
|
+
return [...calls, ...remaining];
|
|
23526
23610
|
}
|
|
23527
23611
|
function makeMessage(role, parts) {
|
|
23528
23612
|
return {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
withIndexChunk2,
|
|
4
4
|
yieldIndexChunk2
|
|
5
5
|
} from "./index-2qtx0q6h.js";
|
|
6
|
-
import"./index-
|
|
6
|
+
import"./index-nh4srq1p.js";
|
|
7
7
|
import"./index-pefn1gt5.js";
|
|
8
8
|
import"./index-0h2mkab2.js";
|
|
9
9
|
import"./index-tm11k42a.js";
|
|
@@ -15,7 +15,7 @@ import"./index-wfqysrwq.js";
|
|
|
15
15
|
import"./index-x2n261wp.js";
|
|
16
16
|
import"./index-xjhq27z9.js";
|
|
17
17
|
import"./index-n0zjvs3h.js";
|
|
18
|
-
import"./index-
|
|
18
|
+
import"./index-hpbdnbtf.js";
|
|
19
19
|
import"./index-6x556c2q.js";
|
|
20
20
|
import {
|
|
21
21
|
MESSAGE_INDEX_MAX_FTS_BYTES,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
markMessageIndexDirty,
|
|
25
25
|
getIndexableContent,
|
|
26
26
|
indexSingleMessage
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-0t9xfj3x.js";
|
|
28
28
|
import"./index-ghp32f9m.js";
|
|
29
29
|
import"./index-1ts77n1b.js";
|
|
30
30
|
|
package/dist/migration-worker.js
CHANGED
|
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
19
19
|
await main();
|
|
20
20
|
async function main() {
|
|
21
21
|
if (input.v2ArchiveReader) {
|
|
22
|
-
const { serveV2ArchiveReads } = await import("./v2-archive-reader-
|
|
22
|
+
const { serveV2ArchiveReads } = await import("./v2-archive-reader-zndhp4c4.js");
|
|
23
23
|
await serveV2ArchiveReads(port, openConnections);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
51
51
|
await runMessageFtsRowidMapBackfill(db);
|
|
52
52
|
reply = { kind: "fts-rowid-backfill" };
|
|
53
53
|
} else if (input.searchArchive) {
|
|
54
|
-
const { renderSearchArchive } = await import("./search-archive-
|
|
54
|
+
const { renderSearchArchive } = await import("./search-archive-661vc3fb.js");
|
|
55
55
|
const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-0tytrjye.js");
|
|
56
56
|
const archive = input.searchArchive;
|
|
57
57
|
let raw;
|
|
@@ -81,7 +81,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
81
81
|
const { setHarness } = await import("./harness-9872e0ym.js");
|
|
82
82
|
setHarness(input.harness ?? "opencode");
|
|
83
83
|
const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
|
|
84
|
-
import("./message-index-bounded-
|
|
84
|
+
import("./message-index-bounded-sra4jpac.js"),
|
|
85
85
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
86
86
|
]);
|
|
87
87
|
configureContextDatabasePragmas(db);
|
|
@@ -95,7 +95,7 @@ serveWorkerJobs(async (input, port) => {
|
|
|
95
95
|
measurements: result.measurements
|
|
96
96
|
};
|
|
97
97
|
} else if (input.tagRatio !== undefined) {
|
|
98
|
-
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-
|
|
98
|
+
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-mj9tptw2.js");
|
|
99
99
|
const delta = input.tagState ? scanTagOwnerDelta(db, input.sessionId, input.tagState) : null;
|
|
100
100
|
if (delta)
|
|
101
101
|
reply = { kind: "tag-delta", delta };
|
|
@@ -38,8 +38,8 @@ import {
|
|
|
38
38
|
readSessionChunk2,
|
|
39
39
|
getRawSessionMessageIdsThrough2,
|
|
40
40
|
readRawSessionSeedTail2
|
|
41
|
-
} from "./index-
|
|
42
|
-
import"./index-
|
|
41
|
+
} from "./index-hpbdnbtf.js";
|
|
42
|
+
import"./index-nh4srq1p.js";
|
|
43
43
|
import"./index-6x556c2q.js";
|
|
44
44
|
import"./index-vcegxfwg.js";
|
|
45
45
|
import"./index-jhmz9tgv.js";
|
|
@@ -3,18 +3,18 @@ import {
|
|
|
3
3
|
renderVerboseRange2,
|
|
4
4
|
renderVerboseRangeForTool2,
|
|
5
5
|
renderItemByTag2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-6crdakkm.js";
|
|
7
7
|
import"./index-k7a8x7ba.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-0t9xfj3x.js";
|
|
9
9
|
import"./index-hgd00nas.js";
|
|
10
10
|
import"./index-nvh6d3bz.js";
|
|
11
11
|
import"./index-cxczethe.js";
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
12
|
+
import"./index-hpbdnbtf.js";
|
|
13
|
+
import"./index-nh4srq1p.js";
|
|
14
14
|
import"./index-6x556c2q.js";
|
|
15
15
|
import"./index-5rcjs14a.js";
|
|
16
16
|
import"./index-vcegxfwg.js";
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-0th11rhf.js";
|
|
18
18
|
import"./index-fapenpch.js";
|
|
19
19
|
import"./index-gavj3e6h.js";
|
|
20
20
|
import"./index-135e8hvg.js";
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
resolveMemoriesByIdsForSearch2,
|
|
6
6
|
unifiedSearch2,
|
|
7
7
|
formatSearchResults2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-55dhgfwp.js";
|
|
9
9
|
import"./index-k7a8x7ba.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-0t9xfj3x.js";
|
|
11
11
|
import"./index-8d2z6503.js";
|
|
12
12
|
import"./index-gczr1m66.js";
|
|
13
13
|
import"./index-29nw7n1r.js";
|
|
@@ -17,8 +17,8 @@ import"./index-hgd00nas.js";
|
|
|
17
17
|
import"./index-yhzhdp3m.js";
|
|
18
18
|
import"./index-79xfn84y.js";
|
|
19
19
|
import"./index-cxczethe.js";
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
20
|
+
import"./index-hpbdnbtf.js";
|
|
21
|
+
import"./index-nh4srq1p.js";
|
|
22
22
|
import"./index-6x556c2q.js";
|
|
23
23
|
import"./index-txcs0vnj.js";
|
|
24
24
|
import"./index-5rcjs14a.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderSearchArchive2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
3
|
+
} from "./index-fvfq9gva.js";
|
|
4
|
+
import"./index-hnvq96j6.js";
|
|
5
5
|
import"./index-8d2z6503.js";
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
6
|
+
import"./index-hpbdnbtf.js";
|
|
7
|
+
import"./index-nh4srq1p.js";
|
|
8
8
|
import"./index-6x556c2q.js";
|
|
9
9
|
import"./index-vcegxfwg.js";
|
|
10
10
|
import"./index-jhmz9tgv.js";
|
|
@@ -18,7 +18,80 @@ function isStorageNoticeText(text) {
|
|
|
18
18
|
return typeof text === "string" && text.startsWith(STORAGE_NOTICE_PREFIX);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// ../plugin/src/v2/fold/host-media.ts
|
|
22
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23
|
+
function isClassInstance(value) {
|
|
24
|
+
if (!isRecord(value))
|
|
25
|
+
return false;
|
|
26
|
+
const prototype = Object.getPrototypeOf(value);
|
|
27
|
+
return prototype !== Object.prototype && prototype !== null;
|
|
28
|
+
}
|
|
29
|
+
var rememberedAssetClass;
|
|
30
|
+
var rememberedAssetSchema;
|
|
31
|
+
var assetSchemaByClass = new WeakMap;
|
|
32
|
+
function decodeThroughHostSchema(encoded) {
|
|
33
|
+
const source = encoded.source;
|
|
34
|
+
const assetSchema = rememberedAssetSchema;
|
|
35
|
+
if (!assetSchema)
|
|
36
|
+
return "no host message schema with a media member seen";
|
|
37
|
+
const encoding = assetSchema.ast?.encoding;
|
|
38
|
+
const decode = Array.isArray(encoding) ? encoding[0]?.transformation?.decode : undefined;
|
|
39
|
+
const getter = decode;
|
|
40
|
+
let asset;
|
|
41
|
+
if (getter?._tag === "Transform") {
|
|
42
|
+
if (typeof getter.transform !== "function")
|
|
43
|
+
return "host media schema has no decode transformation";
|
|
44
|
+
asset = getter.transform(encoded);
|
|
45
|
+
} else {
|
|
46
|
+
if (getter?._tag !== undefined)
|
|
47
|
+
return `host media schema has unsupported decode transformation: ${String(getter._tag)}`;
|
|
48
|
+
const run = getter?.run;
|
|
49
|
+
if (typeof run !== "function")
|
|
50
|
+
return "host media schema has no decode transformation";
|
|
51
|
+
const result = run.call(decode, { _tag: "Some", value: encoded }, {});
|
|
52
|
+
const option = result?._tag === "Success" ? result.value : undefined;
|
|
53
|
+
asset = option?._tag === "Some" ? option.value : undefined;
|
|
54
|
+
}
|
|
55
|
+
if (!isClassInstance(asset) || asset.source !== source)
|
|
56
|
+
return "host media schema decode did not return an asset";
|
|
57
|
+
return asset;
|
|
58
|
+
}
|
|
59
|
+
function hostMediaAsset(data, mediaType) {
|
|
60
|
+
return hostMediaFromEncoded({ source: { type: "base64", data, mediaType } });
|
|
61
|
+
}
|
|
62
|
+
function hostMediaFromEncoded(value) {
|
|
63
|
+
if (!isRecord(value.source))
|
|
64
|
+
return "missing Media.Asset source";
|
|
65
|
+
const encoded = structuredClone(value);
|
|
66
|
+
if (encoded.source.type === "bytes") {
|
|
67
|
+
if (typeof encoded.source.data !== "string")
|
|
68
|
+
return "bytes media has no JSON codec payload";
|
|
69
|
+
encoded.source.data = new Uint8Array(Buffer.from(encoded.source.data, "base64"));
|
|
70
|
+
}
|
|
71
|
+
if (!["bytes", "base64", "url", "ref"].includes(String(encoded.source.type)))
|
|
72
|
+
return "unknown Media.Asset source";
|
|
73
|
+
let first = "no Media.Asset seen in this process";
|
|
74
|
+
if (rememberedAssetClass) {
|
|
75
|
+
try {
|
|
76
|
+
return new rememberedAssetClass(encoded);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
first = `remembered asset class threw: ${String(error)}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
let second;
|
|
82
|
+
try {
|
|
83
|
+
const decoded = decodeThroughHostSchema(encoded);
|
|
84
|
+
if (typeof decoded !== "string")
|
|
85
|
+
return decoded;
|
|
86
|
+
second = decoded;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
second = `host media schema decode threw: ${String(error)}`;
|
|
89
|
+
}
|
|
90
|
+
return `${first}; ${second}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
21
93
|
// ../plugin/src/v2/fold/restore.ts
|
|
94
|
+
var HOST_RESTORE_MEDIA = { asset: hostMediaAsset, unavailable: () => {} };
|
|
22
95
|
function unavailableAttachmentNote(name, mediaType) {
|
|
23
96
|
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) is not available in this restored history]`;
|
|
24
97
|
}
|
|
@@ -69,17 +142,6 @@ ${[
|
|
|
69
142
|
return [];
|
|
70
143
|
const metadata = file.description === undefined ? undefined : { description: file.description };
|
|
71
144
|
const located = location ? [{ type: "text", text: `Attached file: ${location}` }] : [];
|
|
72
|
-
if (!media)
|
|
73
|
-
return [
|
|
74
|
-
...located,
|
|
75
|
-
{
|
|
76
|
-
type: "media",
|
|
77
|
-
mediaType: file.mime,
|
|
78
|
-
data: file.data,
|
|
79
|
-
filename: file.name,
|
|
80
|
-
metadata
|
|
81
|
-
}
|
|
82
|
-
];
|
|
83
145
|
const asset = media.asset(file.data, file.mime);
|
|
84
146
|
if (typeof asset === "string") {
|
|
85
147
|
media.unavailable({ rowID, name: file.name, mediaType: file.mime, reason: asset });
|
|
@@ -91,7 +153,7 @@ ${[
|
|
|
91
153
|
return [...located, { type: "media", media: asset, filename: file.name, metadata }];
|
|
92
154
|
});
|
|
93
155
|
}
|
|
94
|
-
function restoreRow(row, model, media) {
|
|
156
|
+
function restoreRow(row, model, media = HOST_RESTORE_MEDIA) {
|
|
95
157
|
const data = row.data;
|
|
96
158
|
const make = (role, content, metadata = data.metadata) => ({
|
|
97
159
|
id: row.id,
|
|
@@ -251,8 +313,12 @@ function toolStateContent(state) {
|
|
|
251
313
|
var rawMessageTypes = new Set(RAW_MESSAGE_TYPES2);
|
|
252
314
|
var isRawRow = (row) => rawMessageTypes.has(row.type);
|
|
253
315
|
var NO_MODEL = { providerID: "", id: "" };
|
|
316
|
+
var NO_MEDIA = {
|
|
317
|
+
asset: () => "rendered only to read message ids",
|
|
318
|
+
unavailable: () => {}
|
|
319
|
+
};
|
|
254
320
|
function hostServesRowById(row) {
|
|
255
|
-
return isRawRow(row) && restoreRow(row, NO_MODEL).some((message) => message.id === row.id);
|
|
321
|
+
return isRawRow(row) && restoreRow(row, NO_MODEL, NO_MEDIA).some((message) => message.id === row.id);
|
|
256
322
|
}
|
|
257
323
|
function projectRawMessages(rows, ordinalFor) {
|
|
258
324
|
return rows.filter(isRawRow).map((row, index) => {
|
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-hpbdnbtf.js";
|
|
4
4
|
import {
|
|
5
5
|
setHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import"./index-2qtx0q6h.js";
|
|
15
15
|
import {
|
|
16
16
|
openDatabase
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-0th11rhf.js";
|
|
18
18
|
import"./index-fapenpch.js";
|
|
19
19
|
import"./index-3bb24eb6.js";
|
|
20
20
|
import"./index-8sqebjzk.js";
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
resolvePiHarnessKind,
|
|
35
35
|
reportSubagentStartupError,
|
|
36
36
|
registerMagicContextTools
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-97ay0whg.js";
|
|
38
38
|
import"./index-vcegxfwg.js";
|
|
39
39
|
import"./index-5rcjs14a.js";
|
|
40
40
|
import"./index-cxczethe.js";
|
|
@@ -44,16 +44,16 @@ import"./index-hgd00nas.js";
|
|
|
44
44
|
import"./index-9p40dgkm.js";
|
|
45
45
|
import"./index-79xfn84y.js";
|
|
46
46
|
import"./index-yhzhdp3m.js";
|
|
47
|
-
import"./index-
|
|
48
|
-
import"./index-
|
|
49
|
-
import"./index-
|
|
50
|
-
import"./index-
|
|
47
|
+
import"./index-55dhgfwp.js";
|
|
48
|
+
import"./index-6crdakkm.js";
|
|
49
|
+
import"./index-0t9xfj3x.js";
|
|
50
|
+
import"./index-nh4srq1p.js";
|
|
51
51
|
import"./index-6x556c2q.js";
|
|
52
52
|
import"./index-nvh6d3bz.js";
|
|
53
53
|
import"./index-k7a8x7ba.js";
|
|
54
54
|
import"./index-8d2z6503.js";
|
|
55
|
-
import"./index-
|
|
56
|
-
import"./index-
|
|
55
|
+
import"./index-hnvq96j6.js";
|
|
56
|
+
import"./index-fvfq9gva.js";
|
|
57
57
|
import"./index-gczr1m66.js";
|
|
58
58
|
import"./index-29nw7n1r.js";
|
|
59
59
|
import"./index-3s39a1md.js";
|
|
@@ -8,7 +8,7 @@ import"./index-tm11k42a.js";
|
|
|
8
8
|
import {
|
|
9
9
|
LATEST_SUPPORTED_VERSION,
|
|
10
10
|
getPersistedSchemaVersion
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-0th11rhf.js";
|
|
12
12
|
import"./index-fapenpch.js";
|
|
13
13
|
import"./index-3bb24eb6.js";
|
|
14
14
|
import"./index-8sqebjzk.js";
|
|
@@ -28,14 +28,14 @@ import"./index-pefn1gt5.js";
|
|
|
28
28
|
import {
|
|
29
29
|
normalizeTagSnapshotRow2,
|
|
30
30
|
TAG_SELECT_COLUMNS2
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-nh4srq1p.js";
|
|
32
32
|
import"./index-vcegxfwg.js";
|
|
33
33
|
import {
|
|
34
34
|
encodePiHydrationOperation,
|
|
35
35
|
projectPiPassTag,
|
|
36
36
|
PI_FALLBACK_ROW_COLUMNS,
|
|
37
37
|
PI_FALLBACK_ROW_PREDICATE
|
|
38
|
-
} from "./index-
|
|
38
|
+
} from "./index-pdrberjp.js";
|
|
39
39
|
import"./index-1ts77n1b.js";
|
|
40
40
|
import {
|
|
41
41
|
serveWorkerJobs
|
package/package.json
CHANGED