@cortexkit/opencode-magic-context 0.49.91 → 0.49.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +2 -2
- package/dist/{conflict-warning-hook-kbq6ppjf.js → conflict-warning-hook-exf96bpt.js} +3 -3
- package/dist/{context-6qq5e1ry.js → context-jpxthqxg.js} +98 -77
- package/dist/{embedding-backfill-w0yq71q2.js → embedding-backfill-6wzc4p2n.js} +4 -4
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +3 -0
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +7 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +13 -3
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-parser.d.ts +2 -0
- package/dist/hooks/magic-context/compartment-parser.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -5
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +4 -0
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +5 -0
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-drain-gate.d.ts +15 -0
- package/dist/hooks/magic-context/historian-drain-gate.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts +5 -0
- package/dist/hooks/magic-context/historian-publish-stage-logger.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/provider-overflow-notice.d.ts +8 -0
- package/dist/hooks/magic-context/provider-overflow-notice.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-db.d.ts +2 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +5 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-czz0w2c4.js → index-01h7tqe3.js} +11 -0
- package/dist/{index-r6r2eh90.js → index-1kem0xxx.js} +4 -4
- package/dist/{index-f25ha337.js → index-5zrzg8r1.js} +1 -1
- package/dist/{index-6zewd2n5.js → index-9ffntwyr.js} +1 -1
- package/dist/{index-mq97qmb8.js → index-dr6bd4c8.js} +3 -3
- package/dist/{index-83qd3n7s.js → index-et39x9k3.js} +1 -1
- package/dist/{index-nmkv8yvs.js → index-fpjnjxyx.js} +2 -2
- package/dist/{index-ran2b3fn.js → index-g5c67kay.js} +75 -67
- package/dist/{index-7rgnh11t.js → index-g6y2wk32.js} +5 -5
- package/dist/{index-e8my7q6m.js → index-g9qtxv87.js} +8 -8
- package/dist/{index-5wgdbj2h.js → index-gqfy38m9.js} +2 -2
- package/dist/{index-3yw525kb.js → index-hee64h6k.js} +6 -6
- package/dist/{index-xn9efn18.js → index-hes3k87g.js} +12 -5
- package/dist/{index-sr8dmp7p.js → index-j2w79s9r.js} +76 -6
- package/dist/{index-qna2ra0s.js → index-jba6ny4m.js} +27 -3
- package/dist/{index-dva352qe.js → index-kty5k23y.js} +1 -1
- package/dist/{index-ywgv1xcb.js → index-mjy2k9jr.js} +1 -1
- package/dist/{index-3n376ann.js → index-n9kd68vc.js} +2 -2
- package/dist/{index-capcna4r.js → index-pnawfv4e.js} +1 -1
- package/dist/{index-6t7jvp76.js → index-rz47hf2m.js} +3 -3
- package/dist/{index-x40zr813.js → index-sp5pvs95.js} +9 -1
- package/dist/{index-ydhymf0b.js → index-ttdk2w0z.js} +3 -3
- package/dist/{index-gqhebzxx.js → index-xr1t0fxb.js} +90 -25
- package/dist/{index-m6vhxsce.js → index-y2vshk67.js} +92 -70
- package/dist/{index-6nqz8hsz.js → index-y915t3ey.js} +1 -1
- package/dist/{index-wfahebsc.js → index-yqha238s.js} +47 -26
- package/dist/{index-febyth5n.js → index-za1yx1m4.js} +1375 -1310
- package/dist/index.js +83 -46
- package/dist/{message-index-bounded-wvnp6fcp.js → message-index-bounded-vjrnptar.js} +5 -5
- package/dist/migration-worker.js +2 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-8je0xg18.js → project-embedding-registry-m8zcmrsg.js} +3 -3
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-j4hjc1pk.js → read-session-chunk-zkzdc0e5.js} +4 -4
- package/dist/{recomp-orchestrator-ps1c8c5h.js → recomp-orchestrator-qb2hymj5.js} +17 -17
- package/dist/{render-nfj7280n.js → render-34p0kek8.js} +11 -11
- package/dist/{search-archive-1etwnve4.js → search-archive-08ppk0q5.js} +6 -6
- package/dist/{search-3r8b0jfa.js → search-e9bb9hpx.js} +13 -13
- package/dist/{send-session-notification-gzxz88vq.js → send-session-notification-0779tyd9.js} +2 -2
- package/dist/{storage-tags-nh2ftqhx.js → storage-tags-gk7gjkqt.js} +2 -2
- package/dist/{store-reader-a2v34xnh.js → store-reader-qbq6q4v0.js} +1 -1
- package/dist/{store-019k3ek7.js → store-yr443ye8.js} +2 -2
- package/dist/{transform-postprocess-phase-tqp968w4.js → transform-postprocess-phase-neds90e3.js} +18 -18
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +2 -2
- package/dist/v2/{context-d57v8c10.js → context-ctsd80vc.js} +168 -121
- package/dist/v2/{embedding-backfill-95m72gxa.js → embedding-backfill-40g0anxh.js} +4 -4
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/fold/host-media.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +1 -0
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts +15 -0
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hidden-child-native.d.ts.map +1 -1
- package/dist/v2/hidden-run-holder.d.ts +4 -4
- package/dist/v2/hooks/overflow-recovery.d.ts +6 -0
- package/dist/v2/hooks/overflow-recovery.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-2nhbwry6.js → message-index-bounded-1vew9c37.js} +5 -5
- package/dist/v2/migration-worker.js +2 -2
- package/dist/v2/{project-embedding-registry-fcxf4qht.js → project-embedding-registry-je5jam7y.js} +3 -3
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-jrrhwxgx.js → read-session-chunk-09sre4xv.js} +4 -4
- package/dist/v2/{recomp-orchestrator-n79hdd7n.js → recomp-orchestrator-mgcty3we.js} +17 -17
- package/dist/v2/{render-7emcjdt1.js → render-ygcmyn9x.js} +11 -11
- package/dist/v2/{search-archive-fpjbmxcx.js → search-archive-nrsqqmk5.js} +6 -6
- package/dist/v2/{search-vz2cpgr0.js → search-gmye6n25.js} +12 -12
- package/dist/v2/{send-session-notification-zazaxxpf.js → send-session-notification-v69y04f5.js} +2 -2
- package/dist/v2/{server-vsqmkvxc.js → server-00adcfjd.js} +1 -1
- package/dist/v2/{server-kwsqytwj.js → server-2xm0gxke.js} +1 -1
- package/dist/v2/{server-r4816kwv.js → server-4ecpanyn.js} +47 -26
- package/dist/v2/{server-7e89a2kf.js → server-6chcnnhq.js} +12 -5
- package/dist/v2/{server-hgfd6c3e.js → server-6x40bnb7.js} +2 -2
- package/dist/v2/{server-vfa7byfa.js → server-bnkc9kph.js} +5 -5
- package/dist/v2/{server-n431vzn5.js → server-btgnkr9z.js} +2 -2
- package/dist/v2/{server-4axv6kq6.js → server-cvp9w5gs.js} +1375 -1310
- package/dist/v2/{server-4bfk1sky.js → server-dgsjamm4.js} +3 -3
- package/dist/v2/{server-rz6g5xne.js → server-e6xneh68.js} +1 -1
- package/dist/v2/{server-q2ap5cty.js → server-g53asaqt.js} +3 -3
- package/dist/v2/{server-6250cxzs.js → server-gs2251jr.js} +1 -1
- package/dist/v2/{server-8r32etq0.js → server-jkj1dq6j.js} +27 -3
- package/dist/v2/{server-b4efn08m.js → server-k1xc2bw1.js} +1 -1
- package/dist/v2/{server-3z8rhacq.js → server-myp4pc6x.js} +7 -7
- package/dist/v2/{server-72k2r3kt.js → server-pcarsvj2.js} +2 -2
- package/dist/v2/{server-0h875f56.js → server-rkj44mez.js} +76 -6
- package/dist/v2/{server-8ps3717t.js → server-vc5fta6s.js} +3 -3
- package/dist/v2/{server-j9cm1czj.js → server-vtgeyhq6.js} +11 -0
- package/dist/v2/{server-xmgvy3cq.js → server-x69fqsvz.js} +1 -1
- package/dist/v2/{server-q104czn6.js → server-z9czv2vb.js} +90 -25
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-t0f9njdp.js → storage-tags-nccqr0kr.js} +2 -2
- package/dist/v2/{store-q3ef5rvz.js → store-enef5jcn.js} +2 -2
- package/dist/v2/{store-reader-wc01y2rc.js → store-reader-jbaqv1yp.js} +1 -1
- package/dist/v2/store-reader.d.ts +16 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-9p84yzk5.js → v2-archive-reader-7vmng8q7.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-acebazx8.js → wrapup-orchestrator-7r4y0bf6.js} +17 -17
- package/dist/{v2-archive-reader-w1bbaqe8.js → v2-archive-reader-7s90gfax.js} +1 -1
- package/dist/{wrapup-orchestrator-fwbe0mvm.js → wrapup-orchestrator-m2p89973.js} +18 -18
- package/package.json +1 -1
- package/src/config/schema/magic-context.ts +1 -1
- package/src/shared/models-dev-cache.test.ts +15 -0
- /package/dist/v2/{server-3ap5dmhc.js → server-5hwf5c7r.js} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
estimateMessageTokens,
|
|
7
7
|
getCandidateToolOwners2,
|
|
8
8
|
pickNearestPriorOwner2
|
|
9
|
-
} from "./server-
|
|
9
|
+
} from "./server-z9czv2vb.js";
|
|
10
10
|
import {
|
|
11
11
|
OMO_INTERNAL_INITIATOR_MARKER,
|
|
12
12
|
isSystemDirective,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "./server-qntmqaca.js";
|
|
31
31
|
import {
|
|
32
32
|
renderToolTemplate
|
|
33
|
-
} from "./server-
|
|
33
|
+
} from "./server-e6xneh68.js";
|
|
34
34
|
import {
|
|
35
35
|
readRawSessionMessagesFromDb2,
|
|
36
36
|
readRawSessionMessagePageFromDb2,
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
withReadOnlySessionDb,
|
|
54
54
|
getRawSessionMessageCountFromDb,
|
|
55
55
|
getMessageTimesFromOpenCodeDb
|
|
56
|
-
} from "./server-
|
|
56
|
+
} from "./server-5hwf5c7r.js";
|
|
57
57
|
import {
|
|
58
58
|
markHostUnservedRow,
|
|
59
59
|
isHostUnservedRow
|
|
@@ -7029,7 +7029,7 @@ var MagicContextConfigSchema = object({
|
|
|
7029
7029
|
execute_threshold_percentage: union([
|
|
7030
7030
|
number().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE),
|
|
7031
7031
|
object({ default: number().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE) }).catchall(number().min(20).max(90, EXECUTE_THRESHOLD_CAP_MESSAGE))
|
|
7032
|
-
]).default(DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE).describe('Context
|
|
7032
|
+
]).default(DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE).describe('Context usage above which a pass counts as an execute pass. Queued drops and cleanup then apply on the next rewrite of the cached prompt (a new summary, a fold, /ctx-flush, or high pressure); the threshold does not start a rewrite for every queued drop. Number or per-model object ({ default: 65, "provider/model": 45 }). Values above 90 are rejected because the runtime caps at 90% of the output-reserved safe window (MAX_EXECUTE_THRESHOLD). Default: DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE'),
|
|
7033
7033
|
execute_threshold_tokens: object({
|
|
7034
7034
|
default: number().min(5000).max(2000000).optional()
|
|
7035
7035
|
}).catchall(number().min(5000).max(2000000)).optional().describe("Absolute token thresholds per model. When matched, overrides execute_threshold_percentage for that model. Accepts `default` for all models or per-model keys. Values above 90% × context_limit are clamped with a warning log. Min 5_000, max 2_000_000."),
|
|
@@ -13,16 +13,16 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
openCodeDbExists,
|
|
15
15
|
withReadOnlySessionDb
|
|
16
|
-
} from "./server-
|
|
16
|
+
} from "./server-5hwf5c7r.js";
|
|
17
17
|
import {
|
|
18
18
|
hasRawMessageProvider2,
|
|
19
19
|
rawMessageWorkerSource2,
|
|
20
20
|
rawMessageOffThreadRangeReader2,
|
|
21
21
|
readRawSessionMessageIdOrdinalsForRange2
|
|
22
|
-
} from "./server-
|
|
22
|
+
} from "./server-dgsjamm4.js";
|
|
23
23
|
import {
|
|
24
24
|
readV2ArchiveOffThread2
|
|
25
|
-
} from "./server-
|
|
25
|
+
} from "./server-bnkc9kph.js";
|
|
26
26
|
|
|
27
27
|
// src/tools/ctx-expand/search-archive.ts
|
|
28
28
|
var archiveReadsOnThisThread = 0;
|
|
@@ -58,6 +58,8 @@ var TIER_OPEN_ANY_REGEX = /<p\d/;
|
|
|
58
58
|
var CATEGORY_BLOCK_REGEX = /<([A-Za-z_][A-Za-z0-9_-]*)>(.*?)<\/\1>/gs;
|
|
59
59
|
var HISTORIAN_CATEGORIES = new Set(V2_MEMORY_CATEGORIES);
|
|
60
60
|
var FACT_ITEM_REGEX = /^\s*\*\s*(.+)$/gm;
|
|
61
|
+
var FACT_ANCHOR_GROUP_REGEX = /^\[[ \t]*at_compartment[ \t]*=[^\]\r\n]*\]/i;
|
|
62
|
+
var FACT_ANCHOR_VALUE_REGEX = /^\[[ \t]*at_compartment[ \t]*=[ \t]*([0-9]+)(?:[ \t]+messages[ \t]*=[ \t]*([0-9]+(?:[ \t]*-[ \t]*[0-9]+)?(?:[ \t]*,[ \t]*[0-9]+(?:[ \t]*-[ \t]*[0-9]+)?)*))?[ \t]*\]$/i;
|
|
61
63
|
var UNPROCESSED_REGEX = /<unprocessed_from>(\d+)<\/unprocessed_from>/;
|
|
62
64
|
var USER_OBSERVATIONS_REGEX = /<user_observations>(.*?)<\/user_observations>/s;
|
|
63
65
|
var USER_OBS_ITEM_REGEX = /^\s*\*\s*(.+)$/gm;
|
|
@@ -68,6 +70,25 @@ var FACTS_BLOCK_REGEX = /<facts>(.*?)<\/facts>/s;
|
|
|
68
70
|
var EVENTS_BLOCK_REGEX = /<events>(.*?)<\/events>/s;
|
|
69
71
|
var EVENT_ELEMENT_REGEX = /<([a-z_]+)\s+at_compartment="(\d+)"\s*>(.*?)<\/\1>/gs;
|
|
70
72
|
var EVENT_FIELD_REGEX = /<([a-z_]+)\s*>(.*?)<\/\1>/gs;
|
|
73
|
+
function splitFactAnchorPrefix(item) {
|
|
74
|
+
let content = item;
|
|
75
|
+
let firstGroup;
|
|
76
|
+
while (content) {
|
|
77
|
+
const wrapper = content.startsWith("`") ? "`" : content.startsWith("**") ? "**" : "";
|
|
78
|
+
const group = content.slice(wrapper.length).match(FACT_ANCHOR_GROUP_REGEX)?.[0];
|
|
79
|
+
if (group === undefined || !content.startsWith(wrapper, wrapper.length + group.length))
|
|
80
|
+
break;
|
|
81
|
+
firstGroup ??= group;
|
|
82
|
+
content = content.slice(2 * wrapper.length + group.length).trim();
|
|
83
|
+
}
|
|
84
|
+
const anchor = firstGroup?.match(FACT_ANCHOR_VALUE_REGEX);
|
|
85
|
+
if (!anchor)
|
|
86
|
+
return { content };
|
|
87
|
+
const index = Number(anchor[1]);
|
|
88
|
+
const ranges = anchor[2]?.split(",") ?? [];
|
|
89
|
+
const validRanges = ranges.length <= 3 && ranges.every((range) => range.split("-").every((end) => Number.isSafeInteger(Number(end))));
|
|
90
|
+
return Number.isSafeInteger(index) && index > 0 && validRanges ? { content, originCompartmentIndex: index } : { content };
|
|
91
|
+
}
|
|
71
92
|
function searchFrom(s, regex, from) {
|
|
72
93
|
const at = s.slice(from).search(regex);
|
|
73
94
|
return at === -1 ? -1 : from + at;
|
|
@@ -240,8 +261,11 @@ function parseCompartmentOutput(text) {
|
|
|
240
261
|
log2(`[historian] Dropped <facts> category ${category} (${items.length} facts)`);
|
|
241
262
|
continue;
|
|
242
263
|
}
|
|
243
|
-
for (const
|
|
244
|
-
|
|
264
|
+
for (const item of items) {
|
|
265
|
+
const fact = splitFactAnchorPrefix(item);
|
|
266
|
+
if (fact.content)
|
|
267
|
+
facts.push({ category, ...fact });
|
|
268
|
+
}
|
|
245
269
|
}
|
|
246
270
|
const unprocessedMatch = outside.match(UNPROCESSED_REGEX);
|
|
247
271
|
const unprocessedFrom = unprocessedMatch ? parseInt(unprocessedMatch[1], 10) : null;
|
|
@@ -286,7 +310,7 @@ function parseCompartmentOutput(text) {
|
|
|
286
310
|
const remapAnchor = (anchor) => anchor >= 1 && anchor <= sortedPosition.length ? sortedPosition[anchor - 1] : anchor;
|
|
287
311
|
return {
|
|
288
312
|
compartments: sortedByStart.map(({ compartment }) => compartment),
|
|
289
|
-
facts,
|
|
313
|
+
facts: facts.map((fact) => fact.originCompartmentIndex === undefined ? fact : { ...fact, originCompartmentIndex: remapAnchor(fact.originCompartmentIndex) }),
|
|
290
314
|
droppedFactBlocks,
|
|
291
315
|
droppedFacts,
|
|
292
316
|
events: events.map((event) => event.atCompartment === null ? event : { ...event, atCompartment: remapAnchor(event.atCompartment) }),
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./server-1rrmxhd1.js";
|
|
16
16
|
import {
|
|
17
17
|
isRecord
|
|
18
|
-
} from "./server-
|
|
18
|
+
} from "./server-z9czv2vb.js";
|
|
19
19
|
import {
|
|
20
20
|
cleanSearchText,
|
|
21
21
|
hintKeywordRelevance,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isMessageIndexReconciledThrough,
|
|
26
26
|
clearIndexedMessages,
|
|
27
27
|
indexMessagesAfterOrdinal
|
|
28
|
-
} from "./server-
|
|
28
|
+
} from "./server-2xm0gxke.js";
|
|
29
29
|
import {
|
|
30
30
|
Priority,
|
|
31
31
|
AdmissionClass,
|
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
enqueueShadowEmbeddingItems2,
|
|
58
58
|
getProjectEmbeddingSnapshot2,
|
|
59
59
|
embedItemsForProject2
|
|
60
|
-
} from "./server-
|
|
60
|
+
} from "./server-pcarsvj2.js";
|
|
61
61
|
import {
|
|
62
62
|
recordEmbeddingMeasurement
|
|
63
63
|
} from "./server-2amn2s73.js";
|
|
@@ -73,7 +73,7 @@ import {
|
|
|
73
73
|
sanitizeFtsQuery,
|
|
74
74
|
searchMemoriesFTS,
|
|
75
75
|
searchMemoriesFTSUnion
|
|
76
|
-
} from "./server-
|
|
76
|
+
} from "./server-vc5fta6s.js";
|
|
77
77
|
import {
|
|
78
78
|
ModuleMemoryAuthorityError2,
|
|
79
79
|
getMemoriesByProject2,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
} from "./server-9emdjcb5.js";
|
|
83
83
|
import {
|
|
84
84
|
ensureMemoryEmbeddings2
|
|
85
|
-
} from "./server-
|
|
85
|
+
} from "./server-k1xc2bw1.js";
|
|
86
86
|
import {
|
|
87
87
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
88
88
|
withMessageFtsSessionFilter
|
|
@@ -93,11 +93,11 @@ import {
|
|
|
93
93
|
expandWorkspaceIdentitySetWithAliases,
|
|
94
94
|
resolveStoredPathWorkspaceIdentity,
|
|
95
95
|
sourceNameForMemory
|
|
96
|
-
} from "./server-
|
|
96
|
+
} from "./server-jkj1dq6j.js";
|
|
97
97
|
import {
|
|
98
98
|
getNotes,
|
|
99
99
|
getActivePrimers
|
|
100
|
-
} from "./server-
|
|
100
|
+
} from "./server-x69fqsvz.js";
|
|
101
101
|
import {
|
|
102
102
|
isKnownAutocommit
|
|
103
103
|
} from "./server-8ajstryz.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./server-
|
|
3
|
+
} from "./server-e6xneh68.js";
|
|
4
4
|
import {
|
|
5
5
|
embedPauseBySession,
|
|
6
6
|
activeEmbeddingSessions,
|
|
@@ -83,7 +83,7 @@ import {
|
|
|
83
83
|
logLocalEmbeddingPoolingUnavailableOnce,
|
|
84
84
|
getEmbeddingProviderIdentity,
|
|
85
85
|
LocalEmbeddingProvider
|
|
86
|
-
} from "./server-
|
|
86
|
+
} from "./server-6chcnnhq.js";
|
|
87
87
|
import {
|
|
88
88
|
isKnownAutocommit
|
|
89
89
|
} from "./server-8ajstryz.js";
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./server-39bcszk4.js";
|
|
4
4
|
import {
|
|
5
5
|
RAW_MESSAGE_TYPES2
|
|
6
|
-
} from "./server-
|
|
6
|
+
} from "./server-vtgeyhq6.js";
|
|
7
7
|
import {
|
|
8
8
|
markHostUnservedRow
|
|
9
9
|
} from "./server-s9x93tfs.js";
|
|
@@ -98,6 +98,8 @@ function hostMediaFromEncoded(value) {
|
|
|
98
98
|
return "bytes media has no JSON codec payload";
|
|
99
99
|
encoded.source.data = new Uint8Array(Buffer.from(encoded.source.data, "base64"));
|
|
100
100
|
}
|
|
101
|
+
if (encoded.source.type === "base64" && typeof encoded.source.data !== "string")
|
|
102
|
+
return "base64 media has no payload";
|
|
101
103
|
if (!["bytes", "base64", "url", "ref"].includes(String(encoded.source.type)))
|
|
102
104
|
return "unknown Media.Asset source";
|
|
103
105
|
let first = "no Media.Asset seen in this process";
|
|
@@ -223,13 +225,80 @@ function storageNoticeHasNewInput(messages, idleSeq, sequenceOf) {
|
|
|
223
225
|
|
|
224
226
|
// src/v2/fold/restore.ts
|
|
225
227
|
var HOST_RESTORE_MEDIA = { asset: hostMediaAsset, unavailable: () => {} };
|
|
228
|
+
function readerRestoreMedia(reader, unavailable = () => {}) {
|
|
229
|
+
return { asset: hostMediaAsset, unavailable, blob: (hash) => reader.mediaBlob(hash) };
|
|
230
|
+
}
|
|
226
231
|
function unavailableAttachmentNote(name, mediaType) {
|
|
227
232
|
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) is not available in this restored history]`;
|
|
228
233
|
}
|
|
234
|
+
function hostMissingMediaText(mediaType, name) {
|
|
235
|
+
return `[media unavailable: ${name === undefined ? mediaType : `${name} (${mediaType})`}]`;
|
|
236
|
+
}
|
|
237
|
+
var BLOB_HASH = /^[0-9a-f]{64}$/;
|
|
238
|
+
function readBlob(uri, media) {
|
|
239
|
+
const hash = uri.slice("media:".length);
|
|
240
|
+
if (!BLOB_HASH.test(hash))
|
|
241
|
+
return { kind: "unavailable", reason: "malformed media blob reference" };
|
|
242
|
+
if (!media.blob)
|
|
243
|
+
return { kind: "unavailable", reason: "payload is stored in the host's media blob table" };
|
|
244
|
+
const data = media.blob(hash);
|
|
245
|
+
if (data === undefined)
|
|
246
|
+
return { kind: "unavailable", reason: "the host's store has no media blob table" };
|
|
247
|
+
return data === null ? { kind: "missing" } : { kind: "found", data };
|
|
248
|
+
}
|
|
249
|
+
function withPayload(file, media) {
|
|
250
|
+
if (typeof file.data === "string")
|
|
251
|
+
return { kind: "payload", file };
|
|
252
|
+
if (!file.uri?.startsWith("media:"))
|
|
253
|
+
return { kind: "unavailable", reason: "attachment has no payload" };
|
|
254
|
+
const read = readBlob(file.uri, media);
|
|
255
|
+
if (read.kind === "unavailable")
|
|
256
|
+
return read;
|
|
257
|
+
const { uri: _uri, ...inline } = file;
|
|
258
|
+
if (read.kind === "found")
|
|
259
|
+
return { kind: "payload", file: { ...inline, data: read.data } };
|
|
260
|
+
return {
|
|
261
|
+
kind: "payload",
|
|
262
|
+
file: {
|
|
263
|
+
...inline,
|
|
264
|
+
data: Buffer.from(hostMissingMediaText(file.mime, file.name)).toString("base64"),
|
|
265
|
+
mime: "text/plain"
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
var isBlobFile = (entry) => typeof entry === "object" && entry !== null && entry.type === "file" && typeof entry.uri === "string" && entry.uri.startsWith("media:");
|
|
270
|
+
function toolContentWithPayloads(content, rowID, media) {
|
|
271
|
+
if (!Array.isArray(content) || !content.some(isBlobFile))
|
|
272
|
+
return content;
|
|
273
|
+
return content.map((entry) => {
|
|
274
|
+
if (!isBlobFile(entry))
|
|
275
|
+
return entry;
|
|
276
|
+
const mime = String(entry.mime);
|
|
277
|
+
const name = typeof entry.name === "string" ? entry.name : undefined;
|
|
278
|
+
const read = readBlob(entry.uri, media);
|
|
279
|
+
if (read.kind === "missing")
|
|
280
|
+
return { type: "text", text: hostMissingMediaText(mime, name) };
|
|
281
|
+
if (read.kind === "found")
|
|
282
|
+
return { ...entry, uri: `data:${mime};base64,${read.data}` };
|
|
283
|
+
media.unavailable({ rowID, name, mediaType: mime, reason: read.reason });
|
|
284
|
+
return { type: "text", text: unavailableAttachmentNote(name, mime) };
|
|
285
|
+
});
|
|
286
|
+
}
|
|
229
287
|
var imageMimes = new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
230
288
|
function attachmentParts(files, rowID, media) {
|
|
231
289
|
const seen = new Map;
|
|
232
|
-
return files.flatMap((
|
|
290
|
+
return files.flatMap((stored) => {
|
|
291
|
+
const result = withPayload(stored, media);
|
|
292
|
+
if (result.kind === "unavailable") {
|
|
293
|
+
media.unavailable({
|
|
294
|
+
rowID,
|
|
295
|
+
name: stored.name,
|
|
296
|
+
mediaType: stored.mime,
|
|
297
|
+
reason: result.reason
|
|
298
|
+
});
|
|
299
|
+
return [{ type: "text", text: unavailableAttachmentNote(stored.name, stored.mime) }];
|
|
300
|
+
}
|
|
301
|
+
const file = result.file;
|
|
233
302
|
if (imageMimes.has(file.mime) && file.source.type === "inline" && file.mention?.text) {
|
|
234
303
|
const key = JSON.stringify([
|
|
235
304
|
file.mime,
|
|
@@ -238,9 +307,10 @@ function attachmentParts(files, rowID, media) {
|
|
|
238
307
|
file.mention.text
|
|
239
308
|
]);
|
|
240
309
|
const payloads = seen.get(key) ?? new Set;
|
|
241
|
-
|
|
310
|
+
const payload = typeof stored.data === "string" ? stored.data : String(stored.uri);
|
|
311
|
+
if (payloads.has(payload))
|
|
242
312
|
return [];
|
|
243
|
-
payloads.add(
|
|
313
|
+
payloads.add(payload);
|
|
244
314
|
seen.set(key, payloads);
|
|
245
315
|
}
|
|
246
316
|
const uri = file.source.type === "uri" ? file.source.uri : undefined;
|
|
@@ -393,7 +463,7 @@ ${data.output?.output ?? ""}`
|
|
|
393
463
|
});
|
|
394
464
|
if (!completed)
|
|
395
465
|
continue;
|
|
396
|
-
const toolContent = state.content ?? [];
|
|
466
|
+
const toolContent = toolContentWithPayloads(state.content ?? [], row.id, media);
|
|
397
467
|
const single = toolContent.length === 1 ? toolContent[0] : undefined;
|
|
398
468
|
const result = {
|
|
399
469
|
type: "tool-result",
|
|
@@ -688,4 +758,4 @@ function createV2RawMessageProvider2(reader, sessionID) {
|
|
|
688
758
|
};
|
|
689
759
|
}
|
|
690
760
|
|
|
691
|
-
export { rememberHostMedia, hostMediaAsset, hostMediaFromEncoded, isToolError, toolErrorText, toolStateContent, STORAGE_NOTICE_PREFIX, formatStorageRefusalNotice, formatStorageRecoveryNotice, isCopiedStorageNotice, hasStorageNoticeShape, dropStorageNotices, storageNoticeHasNewInput,
|
|
761
|
+
export { rememberHostMedia, hostMediaAsset, hostMediaFromEncoded, isToolError, toolErrorText, toolStateContent, STORAGE_NOTICE_PREFIX, formatStorageRefusalNotice, formatStorageRecoveryNotice, isCopiedStorageNotice, hasStorageNoticeShape, dropStorageNotices, storageNoticeHasNewInput, readerRestoreMedia, restoreRow, rawMessagePage2, readV2MessageRange2, iterateV2MessageRange2, servedBoundaryRow2, resolveV2BoundaryUserMessage2, readAllV2RawMessagesForConversion2, readV2RawMessagePagesForConversion2, createV2RawMessageReader2, createV2RawMessageProvider2 };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./server-fr0wbhdn.js";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
10
|
-
} from "./server-
|
|
10
|
+
} from "./server-e6xneh68.js";
|
|
11
11
|
import {
|
|
12
12
|
sessionLog2
|
|
13
13
|
} from "./server-j8376q08.js";
|
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
} from "./server-ps6zrzwj.js";
|
|
18
18
|
import {
|
|
19
19
|
LocalEmbeddingProvider
|
|
20
|
-
} from "./server-
|
|
20
|
+
} from "./server-6chcnnhq.js";
|
|
21
21
|
import {
|
|
22
22
|
OpenAICompatibleEmbeddingProvider,
|
|
23
23
|
embedTextForProject2
|
|
24
|
-
} from "./server-
|
|
24
|
+
} from "./server-pcarsvj2.js";
|
|
25
25
|
import {
|
|
26
26
|
saveEmbeddingIfHashMatches
|
|
27
27
|
} from "./server-qjwpqvnf.js";
|
|
@@ -345,6 +345,17 @@ class V2StoreReader2 {
|
|
|
345
345
|
};
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
|
+
mediaBlob(hash) {
|
|
349
|
+
this.connection.blobTable ??= Boolean(this.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'blob'").get());
|
|
350
|
+
if (!this.connection.blobTable)
|
|
351
|
+
return;
|
|
352
|
+
const row = this.prepare("SELECT data FROM blob WHERE hash = ?").get(hash);
|
|
353
|
+
if (!row)
|
|
354
|
+
return null;
|
|
355
|
+
if (!(row.data instanceof Uint8Array))
|
|
356
|
+
throw new Error(`media blob ${hash} is not stored as bytes`);
|
|
357
|
+
return Buffer.from(row.data.buffer, row.data.byteOffset, row.data.byteLength).toString("base64");
|
|
358
|
+
}
|
|
348
359
|
close() {
|
|
349
360
|
if (this.closed)
|
|
350
361
|
return;
|