@cortexkit/opencode-magic-context 0.49.76 → 0.49.78
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/{context-8zhjv9tj.js → context-6pxdmpay.js} +52 -132
- package/dist/{index-swfwxev1.js → index-c3a833vk.js} +1 -1
- package/dist/{index-5jtq51xv.js → index-c7xvvhdd.js} +2 -2
- package/dist/{index-bw3pmrtk.js → index-cssarkg7.js} +2 -2
- package/dist/{index-ng6gfs0y.js → index-enpatj5k.js} +120 -14
- package/dist/index.js +5 -5
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{search-archive-4vcfm0wv.js → search-archive-2f1j2dh8.js} +2 -2
- package/dist/{store-h2a1g3wh.js → store-j5rvve3v.js} +1 -1
- package/dist/v2/{context-9nm9edea.js → context-h3r9gxrd.js} +51 -131
- package/dist/v2/fold/host-media.d.ts +16 -11
- package/dist/v2/fold/host-media.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts +7 -5
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +8 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
- package/dist/v2/{search-archive-9sx7fn3t.js → search-archive-ha08g13n.js} +2 -2
- package/dist/v2/{server-b0k0cfkd.js → server-fjd90bk0.js} +1 -1
- package/dist/v2/{server-06ew2dbf.js → server-qcbxjpkv.js} +2 -2
- package/dist/v2/{server-474m6n9v.js → server-wc0bb04b.js} +120 -14
- package/dist/v2/server.js +2 -2
- package/dist/v2/{store-4se2a0n0.js → store-1fax2zhj.js} +1 -1
- package/dist/v2/{v2-archive-reader-rm5qkv00.js → v2-archive-reader-xs0d7yyr.js} +1 -1
- package/dist/{v2-archive-reader-gwe0ry1a.js → v2-archive-reader-maj9xst8.js} +1 -1
- package/package.json +1 -1
|
@@ -130,7 +130,7 @@ import {
|
|
|
130
130
|
applyJsonSchemaParameterDescriptions,
|
|
131
131
|
MagicContextRpcServer,
|
|
132
132
|
subagentTemperature
|
|
133
|
-
} from "./index-
|
|
133
|
+
} from "./index-c7xvvhdd.js";
|
|
134
134
|
import {
|
|
135
135
|
resolveHistorianModel2
|
|
136
136
|
} from "./index-5kym00ag.js";
|
|
@@ -326,6 +326,10 @@ import {
|
|
|
326
326
|
formatStorageRecoveryNotice,
|
|
327
327
|
hasStorageNoticeShape,
|
|
328
328
|
dropStorageNotices,
|
|
329
|
+
rememberHostMedia,
|
|
330
|
+
hostMediaAsset,
|
|
331
|
+
hostMediaFromEncoded,
|
|
332
|
+
HOST_RESTORE_MEDIA,
|
|
329
333
|
restoreRow,
|
|
330
334
|
isToolError,
|
|
331
335
|
toolErrorText,
|
|
@@ -336,12 +340,12 @@ import {
|
|
|
336
340
|
readV2RawMessagePagesForConversion2,
|
|
337
341
|
createV2RawMessageReader2,
|
|
338
342
|
createV2RawMessageProvider2
|
|
339
|
-
} from "./index-
|
|
343
|
+
} from "./index-enpatj5k.js";
|
|
340
344
|
import"./index-fmsr7v69.js";
|
|
341
345
|
import"./index-k6b1av2m.js";
|
|
342
346
|
import"./index-52x68mj4.js";
|
|
343
|
-
import"./index-
|
|
344
|
-
import"./index-
|
|
347
|
+
import"./index-cssarkg7.js";
|
|
348
|
+
import"./index-c3a833vk.js";
|
|
345
349
|
import {
|
|
346
350
|
isDreamerRunnable,
|
|
347
351
|
isSmartNoteSurfaceAvailable,
|
|
@@ -688,128 +692,6 @@ function trimToRecordedBoundary(db, sessionId, messages) {
|
|
|
688
692
|
return safeStart;
|
|
689
693
|
}
|
|
690
694
|
|
|
691
|
-
// src/v2/fold/host-media.ts
|
|
692
|
-
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
693
|
-
function isClassInstance(value) {
|
|
694
|
-
if (!isRecord2(value))
|
|
695
|
-
return false;
|
|
696
|
-
const prototype = Object.getPrototypeOf(value);
|
|
697
|
-
return prototype !== Object.prototype && prototype !== null;
|
|
698
|
-
}
|
|
699
|
-
var rememberedAssetClass;
|
|
700
|
-
var rememberedMessageClass;
|
|
701
|
-
var schemaUsesAssets = new WeakMap;
|
|
702
|
-
function rememberHostMedia(messages) {
|
|
703
|
-
for (const message of messages) {
|
|
704
|
-
if (!isClassInstance(message))
|
|
705
|
-
continue;
|
|
706
|
-
rememberedMessageClass ??= Object.getPrototypeOf(message).constructor;
|
|
707
|
-
if (rememberedAssetClass)
|
|
708
|
-
return;
|
|
709
|
-
const content = message.content;
|
|
710
|
-
if (!Array.isArray(content))
|
|
711
|
-
continue;
|
|
712
|
-
for (const part of content) {
|
|
713
|
-
if (!isRecord2(part) || part.type !== "media")
|
|
714
|
-
continue;
|
|
715
|
-
const media = part.media;
|
|
716
|
-
if (isClassInstance(media) && isRecord2(media.source)) {
|
|
717
|
-
rememberedAssetClass = Object.getPrototypeOf(media).constructor;
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
function hostUsesMediaAssets() {
|
|
724
|
-
const messageClass = rememberedMessageClass;
|
|
725
|
-
if (!messageClass)
|
|
726
|
-
return rememberedAssetClass !== undefined;
|
|
727
|
-
const cached = schemaUsesAssets.get(messageClass);
|
|
728
|
-
if (cached !== undefined)
|
|
729
|
-
return cached;
|
|
730
|
-
let uses = rememberedAssetClass !== undefined;
|
|
731
|
-
if (!uses) {
|
|
732
|
-
try {
|
|
733
|
-
uses = JSON.stringify(messageClass.ast).includes('"Media.Asset"');
|
|
734
|
-
} catch {
|
|
735
|
-
uses = false;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
schemaUsesAssets.set(messageClass, uses);
|
|
739
|
-
return uses;
|
|
740
|
-
}
|
|
741
|
-
function decodeThroughHostSchema(encoded) {
|
|
742
|
-
const source = encoded.source;
|
|
743
|
-
const messageClass = rememberedMessageClass;
|
|
744
|
-
if (!messageClass)
|
|
745
|
-
return "no host message class seen";
|
|
746
|
-
const fields = messageClass.fields;
|
|
747
|
-
const union = fields?.content?.value;
|
|
748
|
-
const members = union?.members;
|
|
749
|
-
if (!Array.isArray(members))
|
|
750
|
-
return "host content schema has no union members";
|
|
751
|
-
const mediaPart = members.find((member) => {
|
|
752
|
-
const typeField = member?.fields;
|
|
753
|
-
const literal = typeField?.type?.ast?.literal;
|
|
754
|
-
return literal === "media";
|
|
755
|
-
});
|
|
756
|
-
const assetSchema = mediaPart?.fields?.media;
|
|
757
|
-
const encoding = assetSchema?.ast?.encoding;
|
|
758
|
-
const decode = Array.isArray(encoding) ? encoding[0]?.transformation?.decode : undefined;
|
|
759
|
-
const getter = decode;
|
|
760
|
-
let asset;
|
|
761
|
-
if (getter?._tag === "Transform") {
|
|
762
|
-
if (typeof getter.transform !== "function")
|
|
763
|
-
return "host media schema has no decode transformation";
|
|
764
|
-
asset = getter.transform(encoded);
|
|
765
|
-
} else {
|
|
766
|
-
if (getter?._tag !== undefined)
|
|
767
|
-
return `host media schema has unsupported decode transformation: ${String(getter._tag)}`;
|
|
768
|
-
const run = getter?.run;
|
|
769
|
-
if (typeof run !== "function")
|
|
770
|
-
return "host media schema has no decode transformation";
|
|
771
|
-
const result = run.call(decode, { _tag: "Some", value: encoded }, {});
|
|
772
|
-
const option = result?._tag === "Success" ? result.value : undefined;
|
|
773
|
-
asset = option?._tag === "Some" ? option.value : undefined;
|
|
774
|
-
}
|
|
775
|
-
if (!isClassInstance(asset) || asset.source !== source)
|
|
776
|
-
return "host media schema decode did not return an asset";
|
|
777
|
-
return asset;
|
|
778
|
-
}
|
|
779
|
-
function hostMediaAsset(data, mediaType) {
|
|
780
|
-
return hostMediaFromEncoded({ source: { type: "base64", data, mediaType } });
|
|
781
|
-
}
|
|
782
|
-
function hostMediaFromEncoded(value) {
|
|
783
|
-
if (!isRecord2(value.source))
|
|
784
|
-
return "missing Media.Asset source";
|
|
785
|
-
const encoded = structuredClone(value);
|
|
786
|
-
if (encoded.source.type === "bytes") {
|
|
787
|
-
if (typeof encoded.source.data !== "string")
|
|
788
|
-
return "bytes media has no JSON codec payload";
|
|
789
|
-
encoded.source.data = new Uint8Array(Buffer.from(encoded.source.data, "base64"));
|
|
790
|
-
}
|
|
791
|
-
if (!["bytes", "base64", "url", "ref"].includes(String(encoded.source.type)))
|
|
792
|
-
return "unknown Media.Asset source";
|
|
793
|
-
let first = "no Media.Asset seen in this process";
|
|
794
|
-
if (rememberedAssetClass) {
|
|
795
|
-
try {
|
|
796
|
-
return new rememberedAssetClass(encoded);
|
|
797
|
-
} catch (error) {
|
|
798
|
-
first = `remembered asset class threw: ${String(error)}`;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
let second;
|
|
802
|
-
try {
|
|
803
|
-
const decoded = decodeThroughHostSchema(encoded);
|
|
804
|
-
if (typeof decoded !== "string")
|
|
805
|
-
return decoded;
|
|
806
|
-
second = decoded;
|
|
807
|
-
} catch (error) {
|
|
808
|
-
second = `host media schema decode threw: ${String(error)}`;
|
|
809
|
-
}
|
|
810
|
-
return `${first}; ${second}`;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
695
|
// src/v2/fold/idle.ts
|
|
814
696
|
class HostFoldIdle {
|
|
815
697
|
fold;
|
|
@@ -1575,6 +1457,43 @@ function rejectContentPart(message, part, reason) {
|
|
|
1575
1457
|
else
|
|
1576
1458
|
log2(text);
|
|
1577
1459
|
}
|
|
1460
|
+
var mediaRepairLogged = new Set;
|
|
1461
|
+
function unpassableAttachmentNote(name, mediaType) {
|
|
1462
|
+
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) could not be passed to the model]`;
|
|
1463
|
+
}
|
|
1464
|
+
function repairMediaPart(message, partIndex, part) {
|
|
1465
|
+
const media = isRecord(part.media) ? part.media : undefined;
|
|
1466
|
+
const source = isRecord(media?.source) ? media.source : undefined;
|
|
1467
|
+
const mediaType = [part.mediaType, media?.mediaType, source?.mediaType].find((value) => typeof value === "string");
|
|
1468
|
+
let asset = "the part has neither an encoded asset nor inline data";
|
|
1469
|
+
if (media && source)
|
|
1470
|
+
asset = hostMediaFromEncoded(media);
|
|
1471
|
+
else if (part.media === undefined && typeof part.data === "string" && mediaType)
|
|
1472
|
+
asset = hostMediaAsset(part.data, mediaType);
|
|
1473
|
+
const sessionID = typeof message.info.sessionID === "string" ? message.info.sessionID : "";
|
|
1474
|
+
const key = JSON.stringify([sessionID, message.info.id ?? null, partIndex]);
|
|
1475
|
+
if (!mediaRepairLogged.has(key)) {
|
|
1476
|
+
mediaRepairLogged.add(key);
|
|
1477
|
+
const where = `message=${String(message.info.id ?? "<head>")} part=${partIndex} mediaType=${mediaType ?? "unknown"} fields=${Object.keys(part).join(",")}`;
|
|
1478
|
+
const text = typeof asset === "string" ? `v2 context replaced a media part that has no host asset by a note: ${where} reason=${JSON.stringify(asset)}` : `v2 context rebuilt a media part that had no host asset instance: ${where}`;
|
|
1479
|
+
if (sessionID)
|
|
1480
|
+
sessionLog2(sessionID, text);
|
|
1481
|
+
else
|
|
1482
|
+
log2(text);
|
|
1483
|
+
}
|
|
1484
|
+
if (typeof asset !== "string") {
|
|
1485
|
+
if (media)
|
|
1486
|
+
return { ...part, media: asset };
|
|
1487
|
+
const { type: _type, mediaType: _mediaType, data: _data, ...rest } = part;
|
|
1488
|
+
return { type: "media", media: asset, ...rest };
|
|
1489
|
+
}
|
|
1490
|
+
const name = typeof part.filename === "string" ? part.filename : undefined;
|
|
1491
|
+
return {
|
|
1492
|
+
type: "text",
|
|
1493
|
+
text: unpassableAttachmentNote(name, mediaType ?? "unknown media type"),
|
|
1494
|
+
...part.cache === undefined ? {} : { cache: part.cache }
|
|
1495
|
+
};
|
|
1496
|
+
}
|
|
1578
1497
|
var emptyTextOmissionLogged = new Set;
|
|
1579
1498
|
function placeCacheHint(content, hint) {
|
|
1580
1499
|
if (content.length === 0 || content.some((part) => part.cache !== undefined))
|
|
@@ -1941,6 +1860,10 @@ function adaptPayload(draft, syntheticIDs = new Set, messageTimes = new Map, hid
|
|
|
1941
1860
|
const { synthetic: _synthetic, ...clean } = part;
|
|
1942
1861
|
const original = hostPartTypes.has(clean.type) && !containsHostInstance(clean) ? hostParts.get(contentKey(clean)) : undefined;
|
|
1943
1862
|
const projected = original ?? clean;
|
|
1863
|
+
if (projected.type === "media" && !isHostInstance(projected.media)) {
|
|
1864
|
+
content.push(repairMediaPart(message, partIndex, projected));
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1944
1867
|
if (imageOmissions.get(message.info.id ?? "")?.has(partIndex))
|
|
1945
1868
|
emptyImages.add(projected);
|
|
1946
1869
|
content.push(projected);
|
|
@@ -2898,10 +2821,7 @@ ${cached}
|
|
|
2898
2821
|
return this.replayInput(args, replay);
|
|
2899
2822
|
}
|
|
2900
2823
|
rendered(row, model) {
|
|
2901
|
-
return restoreRow(row, model,
|
|
2902
|
-
asset: hostMediaAsset,
|
|
2903
|
-
unavailable: () => {}
|
|
2904
|
-
} : undefined);
|
|
2824
|
+
return restoreRow(row, model, HOST_RESTORE_MEDIA);
|
|
2905
2825
|
}
|
|
2906
2826
|
record(row, messages) {
|
|
2907
2827
|
const data = JSON.stringify(encodeNative(messages));
|
|
@@ -7681,10 +7601,10 @@ async function registerContext(context) {
|
|
|
7681
7601
|
if (moduleBoundarySeq !== undefined)
|
|
7682
7602
|
sessionLog2(draft.sessionID, `v2 restore: from the module boundary ${moduleBoundaryID} to the host checkpoint`);
|
|
7683
7603
|
const present = new Set(args.messages.map((message) => message.id));
|
|
7684
|
-
const restored = restoredRows.rows(reader, draft.sessionID, boundary, cut.seq).filter((row) => !retiredInstructions(row)).filter((row) => !present.has(row.id)).flatMap((row) => restoreRow(row, draft.model,
|
|
7604
|
+
const restored = restoredRows.rows(reader, draft.sessionID, boundary, cut.seq).filter((row) => !retiredInstructions(row)).filter((row) => !present.has(row.id)).flatMap((row) => restoreRow(row, draft.model, {
|
|
7685
7605
|
asset: hostMediaAsset,
|
|
7686
7606
|
unavailable: (detail) => sessionLog2(draft.sessionID, `v2 restore: attachment replaced by a note row=${detail.rowID} name=${JSON.stringify(detail.name ?? null)} mediaType=${detail.mediaType} reason=${JSON.stringify(detail.reason)}`)
|
|
7687
|
-
}
|
|
7607
|
+
}));
|
|
7688
7608
|
return [
|
|
7689
7609
|
...rustModeModuleClient ? [] : coveredInstructionRows(reader, draft.sessionID, Math.min(boundary, cut.seq), draft.model, retiredInstructions),
|
|
7690
7610
|
...restored,
|
|
@@ -823,10 +823,10 @@ import {
|
|
|
823
823
|
} from "./index-k6b1av2m.js";
|
|
824
824
|
import {
|
|
825
825
|
readV2ArchiveOffThread2
|
|
826
|
-
} from "./index-
|
|
826
|
+
} from "./index-cssarkg7.js";
|
|
827
827
|
import {
|
|
828
828
|
renderSearchArchiveOffThread2
|
|
829
|
-
} from "./index-
|
|
829
|
+
} from "./index-c3a833vk.js";
|
|
830
830
|
import {
|
|
831
831
|
COMPACTION_ENABLED_PATH,
|
|
832
832
|
isDreamerRunnable,
|
|
@@ -138,10 +138,10 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
138
138
|
] = await Promise.all([
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
140
|
import("./store-reader-3eh1s1m8.js"),
|
|
141
|
-
import("./store-
|
|
141
|
+
import("./store-j5rvve3v.js"),
|
|
142
142
|
import("./read-session-chunk-kqyb1y8c.js"),
|
|
143
143
|
import("./render-8s531gd5.js"),
|
|
144
|
-
import("./search-archive-
|
|
144
|
+
import("./search-archive-2f1j2dh8.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -45,7 +45,120 @@ async function dropStorageNotices(messages, isAdmittedSynthetic) {
|
|
|
45
45
|
return drop.size;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// src/v2/fold/host-media.ts
|
|
49
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
50
|
+
function isClassInstance(value) {
|
|
51
|
+
if (!isRecord(value))
|
|
52
|
+
return false;
|
|
53
|
+
const prototype = Object.getPrototypeOf(value);
|
|
54
|
+
return prototype !== Object.prototype && prototype !== null;
|
|
55
|
+
}
|
|
56
|
+
var rememberedAssetClass;
|
|
57
|
+
var rememberedAssetSchema;
|
|
58
|
+
var assetSchemaByClass = new WeakMap;
|
|
59
|
+
function assetSchemaOf(messageClass) {
|
|
60
|
+
const known = assetSchemaByClass.get(messageClass);
|
|
61
|
+
if (known !== undefined)
|
|
62
|
+
return known ?? undefined;
|
|
63
|
+
const fields = messageClass.fields;
|
|
64
|
+
const union = fields?.content?.value;
|
|
65
|
+
const members = union?.members;
|
|
66
|
+
const mediaPart = Array.isArray(members) ? members.find((member) => {
|
|
67
|
+
const memberFields = member?.fields;
|
|
68
|
+
const literal = memberFields?.type?.ast?.literal;
|
|
69
|
+
return literal === "media";
|
|
70
|
+
}) : undefined;
|
|
71
|
+
const media = mediaPart?.fields?.media;
|
|
72
|
+
const schema = typeof media === "object" && media !== null || typeof media === "function" ? media : undefined;
|
|
73
|
+
assetSchemaByClass.set(messageClass, schema ?? null);
|
|
74
|
+
return schema;
|
|
75
|
+
}
|
|
76
|
+
function rememberHostMedia(messages) {
|
|
77
|
+
for (const message of messages) {
|
|
78
|
+
if (rememberedAssetClass && rememberedAssetSchema)
|
|
79
|
+
return;
|
|
80
|
+
if (!isClassInstance(message))
|
|
81
|
+
continue;
|
|
82
|
+
rememberedAssetSchema ??= assetSchemaOf(Object.getPrototypeOf(message).constructor);
|
|
83
|
+
if (rememberedAssetClass)
|
|
84
|
+
continue;
|
|
85
|
+
const content = message.content;
|
|
86
|
+
if (!Array.isArray(content))
|
|
87
|
+
continue;
|
|
88
|
+
for (const part of content) {
|
|
89
|
+
if (!isRecord(part) || part.type !== "media")
|
|
90
|
+
continue;
|
|
91
|
+
const media = part.media;
|
|
92
|
+
if (isClassInstance(media) && isRecord(media.source)) {
|
|
93
|
+
rememberedAssetClass = Object.getPrototypeOf(media).constructor;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function decodeThroughHostSchema(encoded) {
|
|
100
|
+
const source = encoded.source;
|
|
101
|
+
const assetSchema = rememberedAssetSchema;
|
|
102
|
+
if (!assetSchema)
|
|
103
|
+
return "no host message schema with a media member seen";
|
|
104
|
+
const encoding = assetSchema.ast?.encoding;
|
|
105
|
+
const decode = Array.isArray(encoding) ? encoding[0]?.transformation?.decode : undefined;
|
|
106
|
+
const getter = decode;
|
|
107
|
+
let asset;
|
|
108
|
+
if (getter?._tag === "Transform") {
|
|
109
|
+
if (typeof getter.transform !== "function")
|
|
110
|
+
return "host media schema has no decode transformation";
|
|
111
|
+
asset = getter.transform(encoded);
|
|
112
|
+
} else {
|
|
113
|
+
if (getter?._tag !== undefined)
|
|
114
|
+
return `host media schema has unsupported decode transformation: ${String(getter._tag)}`;
|
|
115
|
+
const run = getter?.run;
|
|
116
|
+
if (typeof run !== "function")
|
|
117
|
+
return "host media schema has no decode transformation";
|
|
118
|
+
const result = run.call(decode, { _tag: "Some", value: encoded }, {});
|
|
119
|
+
const option = result?._tag === "Success" ? result.value : undefined;
|
|
120
|
+
asset = option?._tag === "Some" ? option.value : undefined;
|
|
121
|
+
}
|
|
122
|
+
if (!isClassInstance(asset) || asset.source !== source)
|
|
123
|
+
return "host media schema decode did not return an asset";
|
|
124
|
+
return asset;
|
|
125
|
+
}
|
|
126
|
+
function hostMediaAsset(data, mediaType) {
|
|
127
|
+
return hostMediaFromEncoded({ source: { type: "base64", data, mediaType } });
|
|
128
|
+
}
|
|
129
|
+
function hostMediaFromEncoded(value) {
|
|
130
|
+
if (!isRecord(value.source))
|
|
131
|
+
return "missing Media.Asset source";
|
|
132
|
+
const encoded = structuredClone(value);
|
|
133
|
+
if (encoded.source.type === "bytes") {
|
|
134
|
+
if (typeof encoded.source.data !== "string")
|
|
135
|
+
return "bytes media has no JSON codec payload";
|
|
136
|
+
encoded.source.data = new Uint8Array(Buffer.from(encoded.source.data, "base64"));
|
|
137
|
+
}
|
|
138
|
+
if (!["bytes", "base64", "url", "ref"].includes(String(encoded.source.type)))
|
|
139
|
+
return "unknown Media.Asset source";
|
|
140
|
+
let first = "no Media.Asset seen in this process";
|
|
141
|
+
if (rememberedAssetClass) {
|
|
142
|
+
try {
|
|
143
|
+
return new rememberedAssetClass(encoded);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
first = `remembered asset class threw: ${String(error)}`;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let second;
|
|
149
|
+
try {
|
|
150
|
+
const decoded = decodeThroughHostSchema(encoded);
|
|
151
|
+
if (typeof decoded !== "string")
|
|
152
|
+
return decoded;
|
|
153
|
+
second = decoded;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
second = `host media schema decode threw: ${String(error)}`;
|
|
156
|
+
}
|
|
157
|
+
return `${first}; ${second}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
48
160
|
// src/v2/fold/restore.ts
|
|
161
|
+
var HOST_RESTORE_MEDIA = { asset: hostMediaAsset, unavailable: () => {} };
|
|
49
162
|
function unavailableAttachmentNote(name, mediaType) {
|
|
50
163
|
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) is not available in this restored history]`;
|
|
51
164
|
}
|
|
@@ -96,17 +209,6 @@ ${[
|
|
|
96
209
|
return [];
|
|
97
210
|
const metadata = file.description === undefined ? undefined : { description: file.description };
|
|
98
211
|
const located = location ? [{ type: "text", text: `Attached file: ${location}` }] : [];
|
|
99
|
-
if (!media)
|
|
100
|
-
return [
|
|
101
|
-
...located,
|
|
102
|
-
{
|
|
103
|
-
type: "media",
|
|
104
|
-
mediaType: file.mime,
|
|
105
|
-
data: file.data,
|
|
106
|
-
filename: file.name,
|
|
107
|
-
metadata
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
212
|
const asset = media.asset(file.data, file.mime);
|
|
111
213
|
if (typeof asset === "string") {
|
|
112
214
|
media.unavailable({ rowID, name: file.name, mediaType: file.mime, reason: asset });
|
|
@@ -118,7 +220,7 @@ ${[
|
|
|
118
220
|
return [...located, { type: "media", media: asset, filename: file.name, metadata }];
|
|
119
221
|
});
|
|
120
222
|
}
|
|
121
|
-
function restoreRow(row, model, media) {
|
|
223
|
+
function restoreRow(row, model, media = HOST_RESTORE_MEDIA) {
|
|
122
224
|
const data = row.data;
|
|
123
225
|
const make = (role, content, metadata = data.metadata) => ({
|
|
124
226
|
id: row.id,
|
|
@@ -282,8 +384,12 @@ function toolStateContent(state) {
|
|
|
282
384
|
var rawMessageTypes = new Set(RAW_MESSAGE_TYPES2);
|
|
283
385
|
var isRawRow = (row) => rawMessageTypes.has(row.type);
|
|
284
386
|
var NO_MODEL = { providerID: "", id: "" };
|
|
387
|
+
var NO_MEDIA = {
|
|
388
|
+
asset: () => "rendered only to read message ids",
|
|
389
|
+
unavailable: () => {}
|
|
390
|
+
};
|
|
285
391
|
function hostServesRowById(row) {
|
|
286
|
-
return isRawRow(row) && restoreRow(row, NO_MODEL).some((message) => message.id === row.id);
|
|
392
|
+
return isRawRow(row) && restoreRow(row, NO_MODEL, NO_MEDIA).some((message) => message.id === row.id);
|
|
287
393
|
}
|
|
288
394
|
function projectRawMessages(rows, ordinalFor) {
|
|
289
395
|
return rows.filter(isRawRow).map((row, index) => {
|
|
@@ -531,4 +637,4 @@ function createV2RawMessageProvider2(reader, sessionID) {
|
|
|
531
637
|
};
|
|
532
638
|
}
|
|
533
639
|
|
|
534
|
-
export { STORAGE_NOTICE_PREFIX, formatStorageRefusalNotice, formatStorageRecoveryNotice, hasStorageNoticeShape, dropStorageNotices, restoreRow, isToolError, toolErrorText, toolStateContent, servedBoundaryRow2, resolveV2BoundaryUserMessage2, readAllV2RawMessagesForConversion2, readV2RawMessagePagesForConversion2, createV2RawMessageReader2, createV2RawMessageProvider2 };
|
|
640
|
+
export { STORAGE_NOTICE_PREFIX, formatStorageRefusalNotice, formatStorageRecoveryNotice, hasStorageNoticeShape, dropStorageNotices, rememberHostMedia, hostMediaAsset, hostMediaFromEncoded, HOST_RESTORE_MEDIA, restoreRow, isToolError, toolErrorText, toolStateContent, servedBoundaryRow2, resolveV2BoundaryUserMessage2, readAllV2RawMessagesForConversion2, readV2RawMessagePagesForConversion2, createV2RawMessageReader2, createV2RawMessageProvider2 };
|
package/dist/index.js
CHANGED
|
@@ -145,7 +145,7 @@ import {
|
|
|
145
145
|
parameterDescriptionsFor,
|
|
146
146
|
MagicContextRpcServer,
|
|
147
147
|
applyHiddenSubagentTemperature
|
|
148
|
-
} from "./index-
|
|
148
|
+
} from "./index-c7xvvhdd.js";
|
|
149
149
|
import {
|
|
150
150
|
resolveOpenCodeDbPath,
|
|
151
151
|
openCodeDbPathExists,
|
|
@@ -336,8 +336,8 @@ import {
|
|
|
336
336
|
} from "./index-7jj5jk78.js";
|
|
337
337
|
import"./index-k6b1av2m.js";
|
|
338
338
|
import"./index-52x68mj4.js";
|
|
339
|
-
import"./index-
|
|
340
|
-
import"./index-
|
|
339
|
+
import"./index-cssarkg7.js";
|
|
340
|
+
import"./index-c3a833vk.js";
|
|
341
341
|
import {
|
|
342
342
|
isDreamerRunnable,
|
|
343
343
|
isSmartNoteSurfaceAvailable,
|
|
@@ -8205,7 +8205,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
8205
8205
|
// package.json
|
|
8206
8206
|
var package_default = {
|
|
8207
8207
|
name: "@cortexkit/opencode-magic-context",
|
|
8208
|
-
version: "0.49.
|
|
8208
|
+
version: "0.49.78",
|
|
8209
8209
|
type: "module",
|
|
8210
8210
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
8211
8211
|
main: "dist/index.js",
|
|
@@ -12085,7 +12085,7 @@ async function setup(context) {
|
|
|
12085
12085
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
12086
12086
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
12087
12087
|
}
|
|
12088
|
-
const { registerContext } = await import("./context-
|
|
12088
|
+
const { registerContext } = await import("./context-6pxdmpay.js");
|
|
12089
12089
|
setHarness2("opencode2");
|
|
12090
12090
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
12091
12091
|
const duties = await registerContext(context);
|
|
@@ -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-maj9xst8.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-2f1j2dh8.js");
|
|
55
55
|
const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-3sc9231y.js");
|
|
56
56
|
const archive = input.searchArchive;
|
|
57
57
|
let raw;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderSearchArchive2,
|
|
3
3
|
renderSearchArchiveOffThread2
|
|
4
|
-
} from "./index-
|
|
5
|
-
import"./index-
|
|
4
|
+
} from "./index-c3a833vk.js";
|
|
5
|
+
import"./index-cssarkg7.js";
|
|
6
6
|
import"./index-52x68mj4.js";
|
|
7
7
|
import"./index-8mt6vvwx.js";
|
|
8
8
|
import"./index-bdnak4d0.js";
|
|
@@ -974,6 +974,9 @@ import {
|
|
|
974
974
|
sendStatusNotification2
|
|
975
975
|
} from "./server-qjff96a6.js";
|
|
976
976
|
import {
|
|
977
|
+
rememberHostMedia,
|
|
978
|
+
hostMediaAsset,
|
|
979
|
+
hostMediaFromEncoded,
|
|
977
980
|
isToolError,
|
|
978
981
|
toolErrorText,
|
|
979
982
|
toolStateContent,
|
|
@@ -982,6 +985,7 @@ import {
|
|
|
982
985
|
formatStorageRecoveryNotice,
|
|
983
986
|
hasStorageNoticeShape,
|
|
984
987
|
dropStorageNotices,
|
|
988
|
+
HOST_RESTORE_MEDIA,
|
|
985
989
|
restoreRow,
|
|
986
990
|
servedBoundaryRow2,
|
|
987
991
|
resolveV2BoundaryUserMessage2,
|
|
@@ -989,7 +993,7 @@ import {
|
|
|
989
993
|
readV2RawMessagePagesForConversion2,
|
|
990
994
|
createV2RawMessageReader2,
|
|
991
995
|
createV2RawMessageProvider2
|
|
992
|
-
} from "./server-
|
|
996
|
+
} from "./server-wc0bb04b.js";
|
|
993
997
|
import {
|
|
994
998
|
resolvePromptContext2
|
|
995
999
|
} from "./server-fmsr7v69.js";
|
|
@@ -1001,10 +1005,10 @@ import {
|
|
|
1001
1005
|
import"./server-52x68mj4.js";
|
|
1002
1006
|
import {
|
|
1003
1007
|
readV2ArchiveOffThread2
|
|
1004
|
-
} from "./server-
|
|
1008
|
+
} from "./server-qcbxjpkv.js";
|
|
1005
1009
|
import {
|
|
1006
1010
|
renderSearchArchiveOffThread2
|
|
1007
|
-
} from "./server-
|
|
1011
|
+
} from "./server-fjd90bk0.js";
|
|
1008
1012
|
import {
|
|
1009
1013
|
markHostInstructionRow,
|
|
1010
1014
|
hostInstructionRow,
|
|
@@ -27228,128 +27232,6 @@ function trimToRecordedBoundary(db, sessionId, messages) {
|
|
|
27228
27232
|
return safeStart;
|
|
27229
27233
|
}
|
|
27230
27234
|
|
|
27231
|
-
// src/v2/fold/host-media.ts
|
|
27232
|
-
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27233
|
-
function isClassInstance(value) {
|
|
27234
|
-
if (!isRecord5(value))
|
|
27235
|
-
return false;
|
|
27236
|
-
const prototype = Object.getPrototypeOf(value);
|
|
27237
|
-
return prototype !== Object.prototype && prototype !== null;
|
|
27238
|
-
}
|
|
27239
|
-
var rememberedAssetClass;
|
|
27240
|
-
var rememberedMessageClass;
|
|
27241
|
-
var schemaUsesAssets = new WeakMap;
|
|
27242
|
-
function rememberHostMedia(messages) {
|
|
27243
|
-
for (const message of messages) {
|
|
27244
|
-
if (!isClassInstance(message))
|
|
27245
|
-
continue;
|
|
27246
|
-
rememberedMessageClass ??= Object.getPrototypeOf(message).constructor;
|
|
27247
|
-
if (rememberedAssetClass)
|
|
27248
|
-
return;
|
|
27249
|
-
const content = message.content;
|
|
27250
|
-
if (!Array.isArray(content))
|
|
27251
|
-
continue;
|
|
27252
|
-
for (const part of content) {
|
|
27253
|
-
if (!isRecord5(part) || part.type !== "media")
|
|
27254
|
-
continue;
|
|
27255
|
-
const media = part.media;
|
|
27256
|
-
if (isClassInstance(media) && isRecord5(media.source)) {
|
|
27257
|
-
rememberedAssetClass = Object.getPrototypeOf(media).constructor;
|
|
27258
|
-
return;
|
|
27259
|
-
}
|
|
27260
|
-
}
|
|
27261
|
-
}
|
|
27262
|
-
}
|
|
27263
|
-
function hostUsesMediaAssets() {
|
|
27264
|
-
const messageClass = rememberedMessageClass;
|
|
27265
|
-
if (!messageClass)
|
|
27266
|
-
return rememberedAssetClass !== undefined;
|
|
27267
|
-
const cached = schemaUsesAssets.get(messageClass);
|
|
27268
|
-
if (cached !== undefined)
|
|
27269
|
-
return cached;
|
|
27270
|
-
let uses = rememberedAssetClass !== undefined;
|
|
27271
|
-
if (!uses) {
|
|
27272
|
-
try {
|
|
27273
|
-
uses = JSON.stringify(messageClass.ast).includes('"Media.Asset"');
|
|
27274
|
-
} catch {
|
|
27275
|
-
uses = false;
|
|
27276
|
-
}
|
|
27277
|
-
}
|
|
27278
|
-
schemaUsesAssets.set(messageClass, uses);
|
|
27279
|
-
return uses;
|
|
27280
|
-
}
|
|
27281
|
-
function decodeThroughHostSchema(encoded) {
|
|
27282
|
-
const source = encoded.source;
|
|
27283
|
-
const messageClass = rememberedMessageClass;
|
|
27284
|
-
if (!messageClass)
|
|
27285
|
-
return "no host message class seen";
|
|
27286
|
-
const fields = messageClass.fields;
|
|
27287
|
-
const union = fields?.content?.value;
|
|
27288
|
-
const members = union?.members;
|
|
27289
|
-
if (!Array.isArray(members))
|
|
27290
|
-
return "host content schema has no union members";
|
|
27291
|
-
const mediaPart = members.find((member) => {
|
|
27292
|
-
const typeField = member?.fields;
|
|
27293
|
-
const literal = typeField?.type?.ast?.literal;
|
|
27294
|
-
return literal === "media";
|
|
27295
|
-
});
|
|
27296
|
-
const assetSchema = mediaPart?.fields?.media;
|
|
27297
|
-
const encoding = assetSchema?.ast?.encoding;
|
|
27298
|
-
const decode = Array.isArray(encoding) ? encoding[0]?.transformation?.decode : undefined;
|
|
27299
|
-
const getter = decode;
|
|
27300
|
-
let asset;
|
|
27301
|
-
if (getter?._tag === "Transform") {
|
|
27302
|
-
if (typeof getter.transform !== "function")
|
|
27303
|
-
return "host media schema has no decode transformation";
|
|
27304
|
-
asset = getter.transform(encoded);
|
|
27305
|
-
} else {
|
|
27306
|
-
if (getter?._tag !== undefined)
|
|
27307
|
-
return `host media schema has unsupported decode transformation: ${String(getter._tag)}`;
|
|
27308
|
-
const run = getter?.run;
|
|
27309
|
-
if (typeof run !== "function")
|
|
27310
|
-
return "host media schema has no decode transformation";
|
|
27311
|
-
const result = run.call(decode, { _tag: "Some", value: encoded }, {});
|
|
27312
|
-
const option = result?._tag === "Success" ? result.value : undefined;
|
|
27313
|
-
asset = option?._tag === "Some" ? option.value : undefined;
|
|
27314
|
-
}
|
|
27315
|
-
if (!isClassInstance(asset) || asset.source !== source)
|
|
27316
|
-
return "host media schema decode did not return an asset";
|
|
27317
|
-
return asset;
|
|
27318
|
-
}
|
|
27319
|
-
function hostMediaAsset(data, mediaType) {
|
|
27320
|
-
return hostMediaFromEncoded({ source: { type: "base64", data, mediaType } });
|
|
27321
|
-
}
|
|
27322
|
-
function hostMediaFromEncoded(value) {
|
|
27323
|
-
if (!isRecord5(value.source))
|
|
27324
|
-
return "missing Media.Asset source";
|
|
27325
|
-
const encoded = structuredClone(value);
|
|
27326
|
-
if (encoded.source.type === "bytes") {
|
|
27327
|
-
if (typeof encoded.source.data !== "string")
|
|
27328
|
-
return "bytes media has no JSON codec payload";
|
|
27329
|
-
encoded.source.data = new Uint8Array(Buffer.from(encoded.source.data, "base64"));
|
|
27330
|
-
}
|
|
27331
|
-
if (!["bytes", "base64", "url", "ref"].includes(String(encoded.source.type)))
|
|
27332
|
-
return "unknown Media.Asset source";
|
|
27333
|
-
let first = "no Media.Asset seen in this process";
|
|
27334
|
-
if (rememberedAssetClass) {
|
|
27335
|
-
try {
|
|
27336
|
-
return new rememberedAssetClass(encoded);
|
|
27337
|
-
} catch (error) {
|
|
27338
|
-
first = `remembered asset class threw: ${String(error)}`;
|
|
27339
|
-
}
|
|
27340
|
-
}
|
|
27341
|
-
let second;
|
|
27342
|
-
try {
|
|
27343
|
-
const decoded = decodeThroughHostSchema(encoded);
|
|
27344
|
-
if (typeof decoded !== "string")
|
|
27345
|
-
return decoded;
|
|
27346
|
-
second = decoded;
|
|
27347
|
-
} catch (error) {
|
|
27348
|
-
second = `host media schema decode threw: ${String(error)}`;
|
|
27349
|
-
}
|
|
27350
|
-
return `${first}; ${second}`;
|
|
27351
|
-
}
|
|
27352
|
-
|
|
27353
27235
|
// src/v2/fold/idle.ts
|
|
27354
27236
|
class HostFoldIdle {
|
|
27355
27237
|
fold;
|
|
@@ -28115,6 +27997,43 @@ function rejectContentPart(message, part, reason) {
|
|
|
28115
27997
|
else
|
|
28116
27998
|
log2(text);
|
|
28117
27999
|
}
|
|
28000
|
+
var mediaRepairLogged = new Set;
|
|
28001
|
+
function unpassableAttachmentNote(name, mediaType) {
|
|
28002
|
+
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) could not be passed to the model]`;
|
|
28003
|
+
}
|
|
28004
|
+
function repairMediaPart(message, partIndex, part) {
|
|
28005
|
+
const media = isRecord(part.media) ? part.media : undefined;
|
|
28006
|
+
const source = isRecord(media?.source) ? media.source : undefined;
|
|
28007
|
+
const mediaType = [part.mediaType, media?.mediaType, source?.mediaType].find((value) => typeof value === "string");
|
|
28008
|
+
let asset = "the part has neither an encoded asset nor inline data";
|
|
28009
|
+
if (media && source)
|
|
28010
|
+
asset = hostMediaFromEncoded(media);
|
|
28011
|
+
else if (part.media === undefined && typeof part.data === "string" && mediaType)
|
|
28012
|
+
asset = hostMediaAsset(part.data, mediaType);
|
|
28013
|
+
const sessionID = typeof message.info.sessionID === "string" ? message.info.sessionID : "";
|
|
28014
|
+
const key = JSON.stringify([sessionID, message.info.id ?? null, partIndex]);
|
|
28015
|
+
if (!mediaRepairLogged.has(key)) {
|
|
28016
|
+
mediaRepairLogged.add(key);
|
|
28017
|
+
const where = `message=${String(message.info.id ?? "<head>")} part=${partIndex} mediaType=${mediaType ?? "unknown"} fields=${Object.keys(part).join(",")}`;
|
|
28018
|
+
const text = typeof asset === "string" ? `v2 context replaced a media part that has no host asset by a note: ${where} reason=${JSON.stringify(asset)}` : `v2 context rebuilt a media part that had no host asset instance: ${where}`;
|
|
28019
|
+
if (sessionID)
|
|
28020
|
+
sessionLog2(sessionID, text);
|
|
28021
|
+
else
|
|
28022
|
+
log2(text);
|
|
28023
|
+
}
|
|
28024
|
+
if (typeof asset !== "string") {
|
|
28025
|
+
if (media)
|
|
28026
|
+
return { ...part, media: asset };
|
|
28027
|
+
const { type: _type, mediaType: _mediaType, data: _data, ...rest } = part;
|
|
28028
|
+
return { type: "media", media: asset, ...rest };
|
|
28029
|
+
}
|
|
28030
|
+
const name = typeof part.filename === "string" ? part.filename : undefined;
|
|
28031
|
+
return {
|
|
28032
|
+
type: "text",
|
|
28033
|
+
text: unpassableAttachmentNote(name, mediaType ?? "unknown media type"),
|
|
28034
|
+
...part.cache === undefined ? {} : { cache: part.cache }
|
|
28035
|
+
};
|
|
28036
|
+
}
|
|
28118
28037
|
var emptyTextOmissionLogged = new Set;
|
|
28119
28038
|
function placeCacheHint(content, hint) {
|
|
28120
28039
|
if (content.length === 0 || content.some((part) => part.cache !== undefined))
|
|
@@ -28481,6 +28400,10 @@ function adaptPayload(draft, syntheticIDs = new Set, messageTimes = new Map, hid
|
|
|
28481
28400
|
const { synthetic: _synthetic, ...clean } = part;
|
|
28482
28401
|
const original = hostPartTypes.has(clean.type) && !containsHostInstance(clean) ? hostParts.get(contentKey(clean)) : undefined;
|
|
28483
28402
|
const projected = original ?? clean;
|
|
28403
|
+
if (projected.type === "media" && !isHostInstance(projected.media)) {
|
|
28404
|
+
content.push(repairMediaPart(message, partIndex, projected));
|
|
28405
|
+
continue;
|
|
28406
|
+
}
|
|
28484
28407
|
if (imageOmissions.get(message.info.id ?? "")?.has(partIndex))
|
|
28485
28408
|
emptyImages.add(projected);
|
|
28486
28409
|
content.push(projected);
|
|
@@ -29438,10 +29361,7 @@ ${cached}
|
|
|
29438
29361
|
return this.replayInput(args, replay);
|
|
29439
29362
|
}
|
|
29440
29363
|
rendered(row, model) {
|
|
29441
|
-
return restoreRow(row, model,
|
|
29442
|
-
asset: hostMediaAsset,
|
|
29443
|
-
unavailable: () => {}
|
|
29444
|
-
} : undefined);
|
|
29364
|
+
return restoreRow(row, model, HOST_RESTORE_MEDIA);
|
|
29445
29365
|
}
|
|
29446
29366
|
record(row, messages) {
|
|
29447
29367
|
const data = JSON.stringify(encodeNative(messages));
|
|
@@ -57944,10 +57864,10 @@ async function registerContext(context) {
|
|
|
57944
57864
|
if (moduleBoundarySeq !== undefined)
|
|
57945
57865
|
sessionLog2(draft.sessionID, `v2 restore: from the module boundary ${moduleBoundaryID} to the host checkpoint`);
|
|
57946
57866
|
const present = new Set(args.messages.map((message) => message.id));
|
|
57947
|
-
const restored = restoredRows.rows(reader, draft.sessionID, boundary, cut.seq).filter((row) => !retiredInstructions(row)).filter((row) => !present.has(row.id)).flatMap((row) => restoreRow(row, draft.model,
|
|
57867
|
+
const restored = restoredRows.rows(reader, draft.sessionID, boundary, cut.seq).filter((row) => !retiredInstructions(row)).filter((row) => !present.has(row.id)).flatMap((row) => restoreRow(row, draft.model, {
|
|
57948
57868
|
asset: hostMediaAsset,
|
|
57949
57869
|
unavailable: (detail) => sessionLog2(draft.sessionID, `v2 restore: attachment replaced by a note row=${detail.rowID} name=${JSON.stringify(detail.name ?? null)} mediaType=${detail.mediaType} reason=${JSON.stringify(detail.reason)}`)
|
|
57950
|
-
}
|
|
57870
|
+
}));
|
|
57951
57871
|
return [
|
|
57952
57872
|
...rustModeModuleClient ? [] : coveredInstructionRows(reader, draft.sessionID, Math.min(boundary, cut.seq), draft.model, retiredInstructions),
|
|
57953
57873
|
...restored,
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* From OpenCode 2.0.15 a media content part carries its bytes in a `Media.Asset` class
|
|
5
5
|
* instance, and after the context hook the host rebuilds every message with
|
|
6
|
-
* `Message.make
|
|
7
|
-
*
|
|
6
|
+
* `Message.make`. Every OpenCode 2 host the plugin supports is at least that new (the
|
|
7
|
+
* oldest one the e2e lane pins is 2.0.22), so a media part handed to the host must hold
|
|
8
|
+
* a real host instance: on 2.0.x the schema's `instanceof Asset` check rejects anything
|
|
9
|
+
* else, and on 2.3.x `Message.make` turns a part without one into an asset that has no
|
|
10
|
+
* bytes, which fails the request before any provider call. Rows restored from the store
|
|
11
|
+
* after a host checkpoint are built by Magic Context, not by the host, so their
|
|
8
12
|
* attachments need a real host instance. The plugin cannot import that class: a second
|
|
9
13
|
* copy of `@opencode/ai` has a different `Asset`, which fails the host's instanceof check.
|
|
10
14
|
*
|
|
@@ -12,9 +16,9 @@
|
|
|
12
16
|
* 1. The constructor of any `Media.Asset` the host itself put into a draft during this
|
|
13
17
|
* process. `new Asset({ source: { type: "base64", data, mediaType } })` is exactly what
|
|
14
18
|
* the host's own `Media.base64(data, mediaType)` does when it renders a stored row.
|
|
15
|
-
* 2. The host's own schema, reached from
|
|
16
|
-
* `
|
|
17
|
-
*
|
|
19
|
+
* 2. The host's own schema, reached from a draft message's class:
|
|
20
|
+
* `fields.content.value` (the content-part union) → the member whose `type` is the
|
|
21
|
+
* literal "media" → `fields.media` (`Media.AssetSchema`) → `ast.encoding[0]
|
|
18
22
|
* .transformation.decode`. OpenCode 2.0.22 (Effect 4.0.0-rc.112) exposes a getter whose
|
|
19
23
|
* `run(some(encoded), {})` returns `Success(some(asset))`. OpenCode 2.2.3 (Effect 4.0.6)
|
|
20
24
|
* uses a plain `{ _tag: "Transform", transform }` getter whose `transform(encoded)`
|
|
@@ -22,17 +26,18 @@
|
|
|
22
26
|
* tags are unavailable: they need optional/effectful evaluation rather than a direct
|
|
23
27
|
* synchronous transform. This depends on Effect Schema internals, so every step is
|
|
24
28
|
* checked and any mismatch counts as unavailable.
|
|
29
|
+
*
|
|
30
|
+
* OpenCode 2.0 and 2.1 have one message class for every role. From 2.3 each role has its
|
|
31
|
+
* own class, and the system and tool classes have no media member at all; a draft can
|
|
32
|
+
* start with a system message (a reasoning-effort change, for one). So the schema is
|
|
33
|
+
* taken from the first message class whose content union has a media member, never from
|
|
34
|
+
* whichever message happens to come first.
|
|
25
35
|
*/
|
|
26
36
|
type Part = Record<string, unknown>;
|
|
27
37
|
/** Test hook: forget what earlier drafts taught this process. */
|
|
28
38
|
export declare function resetHostMediaForTests(): void;
|
|
29
|
-
/** Learn the host's
|
|
39
|
+
/** Learn the host's media schema and, when present, its `Media.Asset` class from a draft. */
|
|
30
40
|
export declare function rememberHostMedia(messages: ReadonlyArray<unknown>): void;
|
|
31
|
-
/**
|
|
32
|
-
* True when the remembered host message schema declares attachments as `Media.Asset`
|
|
33
|
-
* (OpenCode 2.0.15 and later). Earlier hosts take the plain `{ mediaType, data }` shape.
|
|
34
|
-
*/
|
|
35
|
-
export declare function hostUsesMediaAssets(): boolean;
|
|
36
41
|
/**
|
|
37
42
|
* The host's own `Media.Asset` for a base64 payload, or the reason neither zero-loss way
|
|
38
43
|
* produced one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-media.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/host-media.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"host-media.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/host-media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAkBpC,iEAAiE;AACjE,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C;AA8BD,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI,CAiBxE;AA8BD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/E;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CA0BjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-replay.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/native-replay.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAEH,KAAK,QAAQ,EAEb,KAAK,aAAa,EACrB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAcH,KAAK,aAAa,EAKr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AAE,cAAc,CAAC,OAAO,CAAC,GAC/B,OAAO,CAAC,SAAS,EAAE,CAAC;IA8BvB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAGzC,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAG5C,OAAO,CAAC,KAAK;IAYP,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUjD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { V2Message } from "../hooks/types";
|
|
2
2
|
import type { StoreRow } from "../store-reader";
|
|
3
3
|
/**
|
|
4
|
-
* How restored attachments are rendered.
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the
|
|
4
|
+
* How restored attachments are rendered. Every supported OpenCode 2 host needs its own
|
|
5
|
+
* `Media.Asset` instance in a media part (see host-media.ts). When no instance can be
|
|
6
|
+
* produced the attachment is replaced by a short note, so the row's text still reaches
|
|
7
|
+
* the model and the host does not reject the whole request: a lost image is
|
|
8
|
+
* recoverable, a request the host cannot even prepare is not.
|
|
9
9
|
*/
|
|
10
10
|
export interface RestoreMedia {
|
|
11
11
|
/** The host's asset for a base64 payload, or why none could be built. */
|
|
@@ -18,6 +18,8 @@ export interface RestoreMedia {
|
|
|
18
18
|
reason: string;
|
|
19
19
|
}): void;
|
|
20
20
|
}
|
|
21
|
+
/** The host's own assets, with no report when one cannot be built. */
|
|
22
|
+
export declare const HOST_RESTORE_MEDIA: RestoreMedia;
|
|
21
23
|
/** Depends only on the stored row, so a replay of the same row produces the same bytes. */
|
|
22
24
|
export declare function unavailableAttachmentNote(name: string | undefined, mediaType: string): string;
|
|
23
25
|
/** Render retained store rows using GA's to-llm-message representation, not the lossy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/restore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"restore.d.ts","sourceRoot":"","sources":["../../../src/v2/fold/restore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAYhD;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IACzB,yEAAyE;IACzE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACxD,uDAAuD;IACvD,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAClG;AAED,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,EAAE,YAA+D,CAAC;AAEjG,2FAA2F;AAC3F,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7F;AAkED;;;GAGG;AACH,wBAAgB,UAAU,CACtB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EACzC,KAAK,GAAE,YAAiC,GACzC,SAAS,EAAE,CAgKb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AA4BxD,OAAO,EACH,KAAK,uBAAuB,EAG/B,MAAM,uDAAuD,CAAC;AAuC/D,OAAO,EACH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UAAU,CAAC,OAAO,6BAA6B,CAAC,EAAE,SAAS,CAAC,EAC/E,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC,GACrF,OAAO,CAAC,IAAI,CAAC,CAwCf;AAyBD,wBAAsB,eAAe,CAAC,OAAO,EAAE,SAAS;;eAmxFvD"}
|
|
@@ -2,6 +2,14 @@ import type { MessageLike } from "../../hooks/magic-context/tag-messages";
|
|
|
2
2
|
import type { SupersessionRow } from "../fold/instruction-supersession";
|
|
3
3
|
import type { SessionContext } from "./types";
|
|
4
4
|
export declare const HEAD_IDS: readonly ["__magic_context_v2_m0__", "__magic_context_v2_m1__"];
|
|
5
|
+
/**
|
|
6
|
+
* The note sent in place of a media part for which no host asset can be built. The part
|
|
7
|
+
* may come from the current turn as well as from restored history, so the wording says
|
|
8
|
+
* only that the attachment could not be passed on. It depends only on the part, so every
|
|
9
|
+
* request that still carries such a part gets the same bytes and the prompt cache keeps
|
|
10
|
+
* the corrected prefix.
|
|
11
|
+
*/
|
|
12
|
+
export declare function unpassableAttachmentNote(name: string | undefined, mediaType: string): string;
|
|
5
13
|
/** Deep copy that keeps class instances by reference, so a pipeline edit to the copy cannot
|
|
6
14
|
* reach the host's draft while the host's own objects survive the round trip. */
|
|
7
15
|
export declare function clonePreservingInstances<T>(value: T): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/payload.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/payload.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAI1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAIxE,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AAEzD,eAAO,MAAM,QAAQ,iEAAkE,CAAC;AAwBxF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5F;AA2HD;iFACiF;AACjF,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvD;AAED;;;;0EAI0E;AAC1E,wBAAgB,gCAAgC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAIxF;AAmID;;;GAGG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,cAAc,EACrB,YAAY,GAAE,WAAW,CAAC,MAAM,CAAa,EAC7C,YAAY,GAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAa;AAC1E;;;;GAIG;AACH,WAAW,UAAQ,EACnB,eAAe,GAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAa;;;EAoZpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,KAAK,EACR,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EAClB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAGH,KAAK,QAAQ,EACb,KAAK,aAAa,EACrB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;A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UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAgBrC;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,MAAM,aAAa,EAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,aAAa,GAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAiC,GAC5E,kBAAkB,CAsIpB;AAED,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,MAAM,GAClB,yBAAyB,CA6B3B"}
|
|
@@ -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-xs0d7yyr.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-ha08g13n.js");
|
|
55
55
|
const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-wg5zc29f.js");
|
|
56
56
|
const archive = input.searchArchive;
|
|
57
57
|
let raw;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderSearchArchive2,
|
|
3
3
|
renderSearchArchiveOffThread2
|
|
4
|
-
} from "./server-
|
|
5
|
-
import"./server-
|
|
4
|
+
} from "./server-fjd90bk0.js";
|
|
5
|
+
import"./server-qcbxjpkv.js";
|
|
6
6
|
import"./server-52x68mj4.js";
|
|
7
7
|
import"./server-6jxvkyrr.js";
|
|
8
8
|
import"./server-cxkb9725.js";
|
|
@@ -138,10 +138,10 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
138
138
|
] = await Promise.all([
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
140
|
import("./store-reader-yaxtdy6f.js"),
|
|
141
|
-
import("./store-
|
|
141
|
+
import("./store-1fax2zhj.js"),
|
|
142
142
|
import("./read-session-chunk-bh402br0.js"),
|
|
143
143
|
import("./render-90pve6jf.js"),
|
|
144
|
-
import("./search-archive-
|
|
144
|
+
import("./search-archive-ha08g13n.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -8,6 +8,118 @@ import {
|
|
|
8
8
|
markHostUnservedRow
|
|
9
9
|
} from "./server-s9x93tfs.js";
|
|
10
10
|
|
|
11
|
+
// src/v2/fold/host-media.ts
|
|
12
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
+
function isClassInstance(value) {
|
|
14
|
+
if (!isRecord(value))
|
|
15
|
+
return false;
|
|
16
|
+
const prototype = Object.getPrototypeOf(value);
|
|
17
|
+
return prototype !== Object.prototype && prototype !== null;
|
|
18
|
+
}
|
|
19
|
+
var rememberedAssetClass;
|
|
20
|
+
var rememberedAssetSchema;
|
|
21
|
+
var assetSchemaByClass = new WeakMap;
|
|
22
|
+
function assetSchemaOf(messageClass) {
|
|
23
|
+
const known = assetSchemaByClass.get(messageClass);
|
|
24
|
+
if (known !== undefined)
|
|
25
|
+
return known ?? undefined;
|
|
26
|
+
const fields = messageClass.fields;
|
|
27
|
+
const union = fields?.content?.value;
|
|
28
|
+
const members = union?.members;
|
|
29
|
+
const mediaPart = Array.isArray(members) ? members.find((member) => {
|
|
30
|
+
const memberFields = member?.fields;
|
|
31
|
+
const literal = memberFields?.type?.ast?.literal;
|
|
32
|
+
return literal === "media";
|
|
33
|
+
}) : undefined;
|
|
34
|
+
const media = mediaPart?.fields?.media;
|
|
35
|
+
const schema = typeof media === "object" && media !== null || typeof media === "function" ? media : undefined;
|
|
36
|
+
assetSchemaByClass.set(messageClass, schema ?? null);
|
|
37
|
+
return schema;
|
|
38
|
+
}
|
|
39
|
+
function rememberHostMedia(messages) {
|
|
40
|
+
for (const message of messages) {
|
|
41
|
+
if (rememberedAssetClass && rememberedAssetSchema)
|
|
42
|
+
return;
|
|
43
|
+
if (!isClassInstance(message))
|
|
44
|
+
continue;
|
|
45
|
+
rememberedAssetSchema ??= assetSchemaOf(Object.getPrototypeOf(message).constructor);
|
|
46
|
+
if (rememberedAssetClass)
|
|
47
|
+
continue;
|
|
48
|
+
const content = message.content;
|
|
49
|
+
if (!Array.isArray(content))
|
|
50
|
+
continue;
|
|
51
|
+
for (const part of content) {
|
|
52
|
+
if (!isRecord(part) || part.type !== "media")
|
|
53
|
+
continue;
|
|
54
|
+
const media = part.media;
|
|
55
|
+
if (isClassInstance(media) && isRecord(media.source)) {
|
|
56
|
+
rememberedAssetClass = Object.getPrototypeOf(media).constructor;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function decodeThroughHostSchema(encoded) {
|
|
63
|
+
const source = encoded.source;
|
|
64
|
+
const assetSchema = rememberedAssetSchema;
|
|
65
|
+
if (!assetSchema)
|
|
66
|
+
return "no host message schema with a media member seen";
|
|
67
|
+
const encoding = assetSchema.ast?.encoding;
|
|
68
|
+
const decode = Array.isArray(encoding) ? encoding[0]?.transformation?.decode : undefined;
|
|
69
|
+
const getter = decode;
|
|
70
|
+
let asset;
|
|
71
|
+
if (getter?._tag === "Transform") {
|
|
72
|
+
if (typeof getter.transform !== "function")
|
|
73
|
+
return "host media schema has no decode transformation";
|
|
74
|
+
asset = getter.transform(encoded);
|
|
75
|
+
} else {
|
|
76
|
+
if (getter?._tag !== undefined)
|
|
77
|
+
return `host media schema has unsupported decode transformation: ${String(getter._tag)}`;
|
|
78
|
+
const run = getter?.run;
|
|
79
|
+
if (typeof run !== "function")
|
|
80
|
+
return "host media schema has no decode transformation";
|
|
81
|
+
const result = run.call(decode, { _tag: "Some", value: encoded }, {});
|
|
82
|
+
const option = result?._tag === "Success" ? result.value : undefined;
|
|
83
|
+
asset = option?._tag === "Some" ? option.value : undefined;
|
|
84
|
+
}
|
|
85
|
+
if (!isClassInstance(asset) || asset.source !== source)
|
|
86
|
+
return "host media schema decode did not return an asset";
|
|
87
|
+
return asset;
|
|
88
|
+
}
|
|
89
|
+
function hostMediaAsset(data, mediaType) {
|
|
90
|
+
return hostMediaFromEncoded({ source: { type: "base64", data, mediaType } });
|
|
91
|
+
}
|
|
92
|
+
function hostMediaFromEncoded(value) {
|
|
93
|
+
if (!isRecord(value.source))
|
|
94
|
+
return "missing Media.Asset source";
|
|
95
|
+
const encoded = structuredClone(value);
|
|
96
|
+
if (encoded.source.type === "bytes") {
|
|
97
|
+
if (typeof encoded.source.data !== "string")
|
|
98
|
+
return "bytes media has no JSON codec payload";
|
|
99
|
+
encoded.source.data = new Uint8Array(Buffer.from(encoded.source.data, "base64"));
|
|
100
|
+
}
|
|
101
|
+
if (!["bytes", "base64", "url", "ref"].includes(String(encoded.source.type)))
|
|
102
|
+
return "unknown Media.Asset source";
|
|
103
|
+
let first = "no Media.Asset seen in this process";
|
|
104
|
+
if (rememberedAssetClass) {
|
|
105
|
+
try {
|
|
106
|
+
return new rememberedAssetClass(encoded);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
first = `remembered asset class threw: ${String(error)}`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
let second;
|
|
112
|
+
try {
|
|
113
|
+
const decoded = decodeThroughHostSchema(encoded);
|
|
114
|
+
if (typeof decoded !== "string")
|
|
115
|
+
return decoded;
|
|
116
|
+
second = decoded;
|
|
117
|
+
} catch (error) {
|
|
118
|
+
second = `host media schema decode threw: ${String(error)}`;
|
|
119
|
+
}
|
|
120
|
+
return `${first}; ${second}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
11
123
|
// src/v2/tool-result.ts
|
|
12
124
|
function isToolError(part) {
|
|
13
125
|
const result = part.result;
|
|
@@ -79,6 +191,7 @@ async function dropStorageNotices(messages, isAdmittedSynthetic) {
|
|
|
79
191
|
}
|
|
80
192
|
|
|
81
193
|
// src/v2/fold/restore.ts
|
|
194
|
+
var HOST_RESTORE_MEDIA = { asset: hostMediaAsset, unavailable: () => {} };
|
|
82
195
|
function unavailableAttachmentNote(name, mediaType) {
|
|
83
196
|
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) is not available in this restored history]`;
|
|
84
197
|
}
|
|
@@ -129,17 +242,6 @@ ${[
|
|
|
129
242
|
return [];
|
|
130
243
|
const metadata = file.description === undefined ? undefined : { description: file.description };
|
|
131
244
|
const located = location ? [{ type: "text", text: `Attached file: ${location}` }] : [];
|
|
132
|
-
if (!media)
|
|
133
|
-
return [
|
|
134
|
-
...located,
|
|
135
|
-
{
|
|
136
|
-
type: "media",
|
|
137
|
-
mediaType: file.mime,
|
|
138
|
-
data: file.data,
|
|
139
|
-
filename: file.name,
|
|
140
|
-
metadata
|
|
141
|
-
}
|
|
142
|
-
];
|
|
143
245
|
const asset = media.asset(file.data, file.mime);
|
|
144
246
|
if (typeof asset === "string") {
|
|
145
247
|
media.unavailable({ rowID, name: file.name, mediaType: file.mime, reason: asset });
|
|
@@ -151,7 +253,7 @@ ${[
|
|
|
151
253
|
return [...located, { type: "media", media: asset, filename: file.name, metadata }];
|
|
152
254
|
});
|
|
153
255
|
}
|
|
154
|
-
function restoreRow(row, model, media) {
|
|
256
|
+
function restoreRow(row, model, media = HOST_RESTORE_MEDIA) {
|
|
155
257
|
const data = row.data;
|
|
156
258
|
const make = (role, content, metadata = data.metadata) => ({
|
|
157
259
|
id: row.id,
|
|
@@ -282,8 +384,12 @@ ${data.output?.output ?? ""}`
|
|
|
282
384
|
var rawMessageTypes = new Set(RAW_MESSAGE_TYPES2);
|
|
283
385
|
var isRawRow = (row) => rawMessageTypes.has(row.type);
|
|
284
386
|
var NO_MODEL = { providerID: "", id: "" };
|
|
387
|
+
var NO_MEDIA = {
|
|
388
|
+
asset: () => "rendered only to read message ids",
|
|
389
|
+
unavailable: () => {}
|
|
390
|
+
};
|
|
285
391
|
function hostServesRowById(row) {
|
|
286
|
-
return isRawRow(row) && restoreRow(row, NO_MODEL).some((message) => message.id === row.id);
|
|
392
|
+
return isRawRow(row) && restoreRow(row, NO_MODEL, NO_MEDIA).some((message) => message.id === row.id);
|
|
287
393
|
}
|
|
288
394
|
function projectRawMessages(rows, ordinalFor) {
|
|
289
395
|
return rows.filter(isRawRow).map((row, index) => {
|
|
@@ -531,4 +637,4 @@ function createV2RawMessageProvider2(reader, sessionID) {
|
|
|
531
637
|
};
|
|
532
638
|
}
|
|
533
639
|
|
|
534
|
-
export { isToolError, toolErrorText, toolStateContent, STORAGE_NOTICE_PREFIX, formatStorageRefusalNotice, formatStorageRecoveryNotice, hasStorageNoticeShape, dropStorageNotices, restoreRow, servedBoundaryRow2, resolveV2BoundaryUserMessage2, readAllV2RawMessagesForConversion2, readV2RawMessagePagesForConversion2, createV2RawMessageReader2, createV2RawMessageProvider2 };
|
|
640
|
+
export { rememberHostMedia, hostMediaAsset, hostMediaFromEncoded, isToolError, toolErrorText, toolStateContent, STORAGE_NOTICE_PREFIX, formatStorageRefusalNotice, formatStorageRecoveryNotice, hasStorageNoticeShape, dropStorageNotices, HOST_RESTORE_MEDIA, restoreRow, servedBoundaryRow2, resolveV2BoundaryUserMessage2, readAllV2RawMessagesForConversion2, readV2RawMessagePagesForConversion2, createV2RawMessageReader2, createV2RawMessageProvider2 };
|
package/dist/v2/server.js
CHANGED
|
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7875
7875
|
// package.json
|
|
7876
7876
|
var package_default = {
|
|
7877
7877
|
name: "@cortexkit/opencode-magic-context",
|
|
7878
|
-
version: "0.49.
|
|
7878
|
+
version: "0.49.78",
|
|
7879
7879
|
type: "module",
|
|
7880
7880
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7881
7881
|
main: "dist/index.js",
|
|
@@ -8196,7 +8196,7 @@ async function setup(context) {
|
|
|
8196
8196
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8197
8197
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
8198
8198
|
}
|
|
8199
|
-
const { registerContext } = await import("./context-
|
|
8199
|
+
const { registerContext } = await import("./context-h3r9gxrd.js");
|
|
8200
8200
|
setHarness2("opencode2");
|
|
8201
8201
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8202
8202
|
const duties = await registerContext(context);
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
readV2RawMessagePagesForConversion2,
|
|
6
6
|
createV2RawMessageReader2,
|
|
7
7
|
createV2RawMessageProvider2
|
|
8
|
-
} from "./server-
|
|
8
|
+
} from "./server-wc0bb04b.js";
|
|
9
9
|
import"./server-rthnpmbp.js";
|
|
10
10
|
import"./server-468mya5v.js";
|
|
11
11
|
import"./server-2ra6pwf3.js";
|
package/package.json
CHANGED