@cortexkit/pi-magic-context 0.49.34 → 0.49.36
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 +163 -155
- package/dist/chunk-embedding-write-worker.js +71 -66
- package/dist/{compaction-marker-candidates-p1kqkqhq.js → compaction-marker-candidates-9fzqg6y0.js} +6 -3
- package/dist/compaction-marker-candidates-worker.js +24 -23
- package/dist/{compartment-chunk-embedding-8c85ebce.js → compartment-chunk-embedding-jpcme6tz.js} +11 -9
- package/dist/embedding-backfill-002vyexq.js +27 -0
- package/dist/embedding-worker-process.js +2 -1
- package/dist/embedding-worker.js +5 -4
- package/dist/expand-attachments-8sxeyj26.js +21 -0
- package/dist/historian-calibration-extension.js +2 -1
- package/dist/{index-hqw0rt9k.js → index-0wtm7g7f.js} +1 -1
- package/dist/{index-wqpjhx1p.js → index-2qqsnh1b.js} +2 -2
- package/dist/index-3bb24eb6.js +229 -0
- package/dist/{index-48twbev2.js → index-6pk49fc3.js} +37 -51
- package/dist/{index-399p688g.js → index-8sqebjzk.js} +4 -1
- package/dist/{index-np9ryr8y.js → index-a7sj2bam.js} +24 -241
- package/dist/index-by1bzjcd.js +24 -0
- package/dist/{index-6981g1xv.js → index-c1dqxr10.js} +35 -5
- package/dist/index-c6wbq66z.js +168 -0
- package/dist/{index-bvpar0bg.js → index-ck8wj35v.js} +2 -2
- package/dist/{index-jn44h81p.js → index-cq71g4dk.js} +1 -1
- package/dist/{index-pb3ea2tq.js → index-d107f484.js} +5 -5
- package/dist/{index-f4fz95fy.js → index-dgqjq8sg.js} +398 -4996
- package/dist/index-dnp1jjar.js +222 -0
- package/dist/index-ea37qn4x.js +777 -0
- package/dist/{index-g2tfayfc.js → index-f6y7mdq9.js} +98 -552
- package/dist/{index-0gymvr5j.js → index-f9qet7y8.js} +19 -8
- package/dist/index-gxqmh9hq.js +194 -0
- package/dist/{index-fgs78jyd.js → index-gymgz20n.js} +5 -222
- package/dist/index-hgd00nas.js +113 -0
- package/dist/{index-9xd7qveg.js → index-jbkwszd5.js} +4 -4
- package/dist/{index-e61zxfts.js → index-kj49vs41.js} +4 -4
- package/dist/{index-4zemngt7.js → index-mp0gh04g.js} +2 -2
- package/dist/{index-eenxm3t3.js → index-mx757f3g.js} +51 -32
- package/dist/{index-23t8ryqw.js → index-n0zjvs3h.js} +1 -168
- package/dist/index-nypgv96r.js +58 -0
- package/dist/index-p9jfa33t.js +4171 -0
- package/dist/{index-eqw9t2ty.js → index-pwp6zyx3.js} +15 -4
- package/dist/{index-cj3bkd16.js → index-ry84c8dr.js} +2 -2
- package/dist/{index-gwxaz0z5.js → index-rzfr7wdv.js} +2 -2
- package/dist/index-w26zvs1q.js +528 -0
- package/dist/index-wfqysrwq.js +204 -0
- package/dist/index-wrr9rp9a.js +16 -0
- package/dist/{index-my0dn413.js → index-wt7vmyj4.js} +1 -1
- package/dist/{index-0mc0vv97.js → index-wwsfevck.js} +8 -5
- package/dist/{index-54wmg4rj.js → index-x2n261wp.js} +16 -14
- package/dist/{index-6wdwv3a6.js → index-y90fxz4t.js} +10 -4
- package/dist/{index-c474g0gj.js → index-yacs388s.js} +1 -1
- package/dist/{index-xn5yh0pn.js → index-z7dktknj.js} +34 -131
- package/dist/index.js +1316 -488
- package/dist/{logger-shetp43v.js → logger-2j70hhz4.js} +2 -1
- package/dist/{message-fts-rowid-map-3mbvdgn9.js → message-fts-rowid-map-hmgyfxxa.js} +8 -6
- package/dist/{message-index-bounded-a6na71rg.js → message-index-bounded-82sergz7.js} +15 -12
- package/dist/{message-time-backfill-e3r8ddh1.js → message-time-backfill-x45573rs.js} +3 -2
- package/dist/migration-worker.js +56 -48
- package/dist/{project-embedding-registry-acqb6be4.js → project-embedding-registry-16pj4vyf.js} +16 -13
- package/dist/raw-ordinal-warmup-worker.js +114 -113
- package/dist/{read-session-chunk-2xcp6f40.js → read-session-chunk-jxq427v6.js} +17 -10
- package/dist/{read-session-raw-g9b1zdn5.js → read-session-raw-a9ntjqap.js} +6 -4
- package/dist/render-2wan3bfh.js +42 -0
- package/dist/{safe-notification-target-zcpchea6.js → safe-notification-target-jk69jxwp.js} +3 -2
- package/dist/search-3p18trsb.js +50 -0
- package/dist/search-archive-pgrv04gv.js +25 -0
- package/dist/{storage-tags-6409qq18.js → storage-tags-p9y3bnw7.js} +5 -4
- package/dist/store-reader-2m80zs5z.js +14 -0
- package/dist/store-v60q7dje.js +452 -0
- package/dist/subagent-entry.js +34 -25
- package/dist/tag-snapshot-worker-pi.js +218 -209
- package/dist/v2-archive-reader-5zpj8hrg.js +11 -0
- package/package.json +1 -1
- package/dist/embedding-backfill-rwfmyvze.js +0 -24
- package/dist/search-archive-jate39w5.js +0 -21
- package/dist/search-b6hp64hc.js +0 -45
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createUnifiedSearchDiagnostics2,
|
|
3
|
+
searchMessageHistory2,
|
|
4
|
+
parseIdShapedQuery2,
|
|
5
|
+
resolveMemoriesByIdsForSearch2,
|
|
6
|
+
unifiedSearch2,
|
|
7
|
+
formatSearchResults2
|
|
8
|
+
} from "./index-f6y7mdq9.js";
|
|
9
|
+
import"./index-w26zvs1q.js";
|
|
10
|
+
import"./index-kj49vs41.js";
|
|
11
|
+
import"./index-1cvyaw9a.js";
|
|
12
|
+
import"./index-jbkwszd5.js";
|
|
13
|
+
import"./index-29nw7n1r.js";
|
|
14
|
+
import"./index-z7dktknj.js";
|
|
15
|
+
import"./index-9p40dgkm.js";
|
|
16
|
+
import"./index-hgd00nas.js";
|
|
17
|
+
import"./index-yhzhdp3m.js";
|
|
18
|
+
import"./index-mp0gh04g.js";
|
|
19
|
+
import"./index-f9qet7y8.js";
|
|
20
|
+
import"./index-mx757f3g.js";
|
|
21
|
+
import"./index-pwp6zyx3.js";
|
|
22
|
+
import"./index-6x556c2q.js";
|
|
23
|
+
import"./index-2qqsnh1b.js";
|
|
24
|
+
import"./index-rzfr7wdv.js";
|
|
25
|
+
import"./index-ccanzg8p.js";
|
|
26
|
+
import"./index-d107f484.js";
|
|
27
|
+
import"./index-135e8hvg.js";
|
|
28
|
+
import"./index-6pk49fc3.js";
|
|
29
|
+
import"./index-ck8wj35v.js";
|
|
30
|
+
import"./index-c6wbq66z.js";
|
|
31
|
+
import"./index-yacs388s.js";
|
|
32
|
+
import"./index-c1dqxr10.js";
|
|
33
|
+
import"./index-wfqysrwq.js";
|
|
34
|
+
import"./index-8sqebjzk.js";
|
|
35
|
+
import"./index-n0zjvs3h.js";
|
|
36
|
+
import"./index-0wtm7g7f.js";
|
|
37
|
+
import"./index-wt7vmyj4.js";
|
|
38
|
+
import"./index-2qtx0q6h.js";
|
|
39
|
+
import"./index-gymgz20n.js";
|
|
40
|
+
import"./index-0h2mkab2.js";
|
|
41
|
+
import"./index-dnp1jjar.js";
|
|
42
|
+
import"./index-x2n261wp.js";
|
|
43
|
+
export {
|
|
44
|
+
createUnifiedSearchDiagnostics2 as createUnifiedSearchDiagnostics,
|
|
45
|
+
formatSearchResults2 as formatSearchResults,
|
|
46
|
+
parseIdShapedQuery2 as parseIdShapedQuery,
|
|
47
|
+
resolveMemoriesByIdsForSearch2 as resolveMemoriesByIdsForSearch,
|
|
48
|
+
searchMessageHistory2 as searchMessageHistory,
|
|
49
|
+
unifiedSearch2 as unifiedSearch
|
|
50
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderSearchArchive2
|
|
3
|
+
} from "./index-ry84c8dr.js";
|
|
4
|
+
import"./index-gxqmh9hq.js";
|
|
5
|
+
import"./index-1cvyaw9a.js";
|
|
6
|
+
import"./index-mx757f3g.js";
|
|
7
|
+
import"./index-pwp6zyx3.js";
|
|
8
|
+
import"./index-6x556c2q.js";
|
|
9
|
+
import"./index-ccanzg8p.js";
|
|
10
|
+
import"./index-c6wbq66z.js";
|
|
11
|
+
import"./index-yacs388s.js";
|
|
12
|
+
import"./index-c1dqxr10.js";
|
|
13
|
+
import"./index-wfqysrwq.js";
|
|
14
|
+
import"./index-8sqebjzk.js";
|
|
15
|
+
import"./index-n0zjvs3h.js";
|
|
16
|
+
import"./index-0wtm7g7f.js";
|
|
17
|
+
import"./index-wt7vmyj4.js";
|
|
18
|
+
import"./index-2qtx0q6h.js";
|
|
19
|
+
import"./index-gymgz20n.js";
|
|
20
|
+
import"./index-0h2mkab2.js";
|
|
21
|
+
import"./index-dnp1jjar.js";
|
|
22
|
+
import"./index-x2n261wp.js";
|
|
23
|
+
export {
|
|
24
|
+
renderSearchArchive2 as renderSearchArchive
|
|
25
|
+
};
|
|
@@ -61,12 +61,13 @@ import {
|
|
|
61
61
|
adoptNullOwnerToolTag2,
|
|
62
62
|
getCandidateToolOwners2,
|
|
63
63
|
pickNearestPriorOwner2
|
|
64
|
-
} from "./index-
|
|
65
|
-
import"./index-
|
|
66
|
-
import"./index-
|
|
64
|
+
} from "./index-pwp6zyx3.js";
|
|
65
|
+
import"./index-yacs388s.js";
|
|
66
|
+
import"./index-wt7vmyj4.js";
|
|
67
67
|
import"./index-2qtx0q6h.js";
|
|
68
|
-
import"./index-
|
|
68
|
+
import"./index-gymgz20n.js";
|
|
69
69
|
import"./index-0h2mkab2.js";
|
|
70
|
+
import"./index-dnp1jjar.js";
|
|
70
71
|
export {
|
|
71
72
|
AGE_RECLAIM_MIN_TOKENS2 as AGE_RECLAIM_MIN_TOKENS,
|
|
72
73
|
PiTagIdentityConflictError2 as PiTagIdentityConflictError,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
gaDatabasePath2,
|
|
3
|
+
RAW_MESSAGE_TYPES2,
|
|
4
|
+
V2StoreReaderPool2,
|
|
5
|
+
V2StoreReader2
|
|
6
|
+
} from "./index-ea37qn4x.js";
|
|
7
|
+
import"./index-n0zjvs3h.js";
|
|
8
|
+
import"./index-2qtx0q6h.js";
|
|
9
|
+
export {
|
|
10
|
+
RAW_MESSAGE_TYPES2 as RAW_MESSAGE_TYPES,
|
|
11
|
+
V2StoreReader2 as V2StoreReader,
|
|
12
|
+
V2StoreReaderPool2 as V2StoreReaderPool,
|
|
13
|
+
gaDatabasePath2 as gaDatabasePath
|
|
14
|
+
};
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import"./index-dnp1jjar.js";
|
|
2
|
+
import"./index-3bb24eb6.js";
|
|
3
|
+
import"./index-n0zjvs3h.js";
|
|
4
|
+
import"./index-2qtx0q6h.js";
|
|
5
|
+
import {
|
|
6
|
+
RAW_MESSAGE_TYPES2
|
|
7
|
+
} from "./index-ea37qn4x.js";
|
|
8
|
+
import {
|
|
9
|
+
markHostUnservedRow
|
|
10
|
+
} from "./index-by1bzjcd.js";
|
|
11
|
+
|
|
12
|
+
// ../plugin/src/v2/fold/restore.ts
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
|
|
15
|
+
// ../plugin/src/v2/hooks/storage-notice.ts
|
|
16
|
+
var STORAGE_NOTICE_PREFIX = "[Magic Context storage notice] ";
|
|
17
|
+
function isStorageNoticeText(text) {
|
|
18
|
+
return typeof text === "string" && text.startsWith(STORAGE_NOTICE_PREFIX);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ../plugin/src/v2/fold/restore.ts
|
|
22
|
+
function unavailableAttachmentNote(name, mediaType) {
|
|
23
|
+
return `[Attachment ${name ? `"${name}" ` : ""}(${mediaType}) is not available in this restored history]`;
|
|
24
|
+
}
|
|
25
|
+
var imageMimes = new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
26
|
+
function attachmentParts(files, rowID, media) {
|
|
27
|
+
const seen = new Map;
|
|
28
|
+
return files.flatMap((file) => {
|
|
29
|
+
if (imageMimes.has(file.mime) && file.source.type === "inline" && file.mention?.text) {
|
|
30
|
+
const key = JSON.stringify([
|
|
31
|
+
file.mime,
|
|
32
|
+
file.name ?? null,
|
|
33
|
+
file.description ?? null,
|
|
34
|
+
file.mention.text
|
|
35
|
+
]);
|
|
36
|
+
const payloads = seen.get(key) ?? new Set;
|
|
37
|
+
if (payloads.has(file.data))
|
|
38
|
+
return [];
|
|
39
|
+
payloads.add(file.data);
|
|
40
|
+
seen.set(key, payloads);
|
|
41
|
+
}
|
|
42
|
+
const uri = file.source.type === "uri" ? file.source.uri : undefined;
|
|
43
|
+
const location = uri?.startsWith("file:") ? fileURLToPath(uri) : undefined;
|
|
44
|
+
if (file.mime === "text/plain" || file.mime === "application/x-directory") {
|
|
45
|
+
const directory = file.mime === "application/x-directory";
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: `
|
|
50
|
+
|
|
51
|
+
${[
|
|
52
|
+
directory ? `Attached directory: ${location ?? file.name ?? uri ?? "directory"}` : `Attached file: ${file.name ?? uri ?? "inline attachment"}`,
|
|
53
|
+
file.description === undefined ? undefined : `Description: ${file.description}`,
|
|
54
|
+
directory && !file.data.length ? undefined : "",
|
|
55
|
+
directory && !file.data.length ? undefined : Buffer.from(file.data, "base64").toString("utf8")
|
|
56
|
+
].filter((line) => line !== undefined).join(`
|
|
57
|
+
`)}`,
|
|
58
|
+
metadata: {
|
|
59
|
+
attachment: {
|
|
60
|
+
source: file.source,
|
|
61
|
+
name: file.name,
|
|
62
|
+
description: file.description
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
if (!imageMimes.has(file.mime) && file.mime !== "application/pdf")
|
|
69
|
+
return [];
|
|
70
|
+
const metadata = file.description === undefined ? undefined : { description: file.description };
|
|
71
|
+
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
|
+
const asset = media.asset(file.data, file.mime);
|
|
84
|
+
if (typeof asset === "string") {
|
|
85
|
+
media.unavailable({ rowID, name: file.name, mediaType: file.mime, reason: asset });
|
|
86
|
+
return [
|
|
87
|
+
...located,
|
|
88
|
+
{ type: "text", text: unavailableAttachmentNote(file.name, file.mime) }
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
return [...located, { type: "media", media: asset, filename: file.name, metadata }];
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function restoreRow(row, model, media) {
|
|
95
|
+
const data = row.data;
|
|
96
|
+
const make = (role, content, metadata = data.metadata) => ({
|
|
97
|
+
id: row.id,
|
|
98
|
+
role,
|
|
99
|
+
content,
|
|
100
|
+
...metadata === undefined ? {} : { metadata }
|
|
101
|
+
});
|
|
102
|
+
if (row.type === "user") {
|
|
103
|
+
const skills = data.skills ?? [];
|
|
104
|
+
const content = [
|
|
105
|
+
...skills.flatMap((skill) => skill.text === undefined ? [] : [{ type: "text", text: skill.text }]),
|
|
106
|
+
...data.text ? [{ type: "text", text: data.text }] : [],
|
|
107
|
+
...attachmentParts(data.files ?? [], row.id, media)
|
|
108
|
+
];
|
|
109
|
+
return content.length ? [
|
|
110
|
+
make("user", content, {
|
|
111
|
+
...data.metadata ?? {},
|
|
112
|
+
...data.agents?.length ? { agents: data.agents } : {}
|
|
113
|
+
})
|
|
114
|
+
] : [];
|
|
115
|
+
}
|
|
116
|
+
if (row.type === "system")
|
|
117
|
+
return [{ role: "system", content: [{ type: "text", text: data.text ?? "" }] }];
|
|
118
|
+
if (row.type === "synthetic" && isStorageNoticeText(data.text))
|
|
119
|
+
return [];
|
|
120
|
+
if (["synthetic", "skill"].includes(row.type))
|
|
121
|
+
return [make("user", [{ type: "text", text: data.text ?? "" }])];
|
|
122
|
+
if (row.type === "location-switched")
|
|
123
|
+
return [
|
|
124
|
+
make("user", [
|
|
125
|
+
{
|
|
126
|
+
type: "text",
|
|
127
|
+
text: `The working directory has been changed to ${data.location.directory}.`
|
|
128
|
+
}
|
|
129
|
+
])
|
|
130
|
+
];
|
|
131
|
+
if (row.type === "shell")
|
|
132
|
+
return data.metadata?.background === true ? [] : [
|
|
133
|
+
make("user", [
|
|
134
|
+
{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: `The following shell command was executed by the user:
|
|
137
|
+
|
|
138
|
+
Command:
|
|
139
|
+
${data.command}
|
|
140
|
+
|
|
141
|
+
Output:
|
|
142
|
+
${data.output?.output ?? ""}`
|
|
143
|
+
}
|
|
144
|
+
])
|
|
145
|
+
];
|
|
146
|
+
if (row.type !== "assistant")
|
|
147
|
+
return [];
|
|
148
|
+
const previousModel = data.model;
|
|
149
|
+
const sameProvider = previousModel?.providerID === model.providerID;
|
|
150
|
+
const sameModel = sameProvider && previousModel?.id === model.id;
|
|
151
|
+
const reuse = sameModel && data.error === undefined;
|
|
152
|
+
const metadata = (state) => state === undefined ? undefined : { [model.providerID]: state };
|
|
153
|
+
const reasoningInterrupted = data.content?.some((part) => part.type === "reasoning" && part.time !== undefined && part.time.completed === undefined);
|
|
154
|
+
const content = [];
|
|
155
|
+
const results = [];
|
|
156
|
+
for (const part of data.content ?? []) {
|
|
157
|
+
let native = "native" in part ? part.native : part.type === "tool" ? part.providerState : part.state;
|
|
158
|
+
if (part.type === "tool" && part.providerResultState !== null && typeof part.providerResultState === "object" && !Array.isArray(part.providerResultState))
|
|
159
|
+
native = {
|
|
160
|
+
...native !== null && typeof native === "object" && !Array.isArray(native) ? native : {},
|
|
161
|
+
...part.providerResultState
|
|
162
|
+
};
|
|
163
|
+
if (part.type === "text") {
|
|
164
|
+
if (part.text !== "")
|
|
165
|
+
content.push({
|
|
166
|
+
type: "text",
|
|
167
|
+
text: part.text,
|
|
168
|
+
providerMetadata: reuse ? metadata(native) : undefined
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (part.type === "reasoning") {
|
|
173
|
+
if (part.text !== "" || reuse && !reasoningInterrupted && native !== undefined)
|
|
174
|
+
content.push({
|
|
175
|
+
type: data.error === undefined && !reasoningInterrupted ? "reasoning" : "text",
|
|
176
|
+
text: part.text,
|
|
177
|
+
providerMetadata: reuse && !reasoningInterrupted ? metadata(native) : undefined
|
|
178
|
+
});
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const state = part.state;
|
|
182
|
+
const completed = state.status === "completed" || state.status === "error";
|
|
183
|
+
const toolReuse = reuse || sameModel && part.executed === true && completed;
|
|
184
|
+
let input = state.input;
|
|
185
|
+
if (state.status === "streaming" && typeof input === "string") {
|
|
186
|
+
try {
|
|
187
|
+
input = JSON.parse(input);
|
|
188
|
+
} catch {}
|
|
189
|
+
}
|
|
190
|
+
content.push({
|
|
191
|
+
type: "tool-call",
|
|
192
|
+
id: part.id,
|
|
193
|
+
name: part.name,
|
|
194
|
+
input,
|
|
195
|
+
providerExecuted: part.executed,
|
|
196
|
+
providerMetadata: toolReuse ? metadata(native) : undefined
|
|
197
|
+
});
|
|
198
|
+
if (!completed)
|
|
199
|
+
continue;
|
|
200
|
+
const toolContent = state.content ?? [];
|
|
201
|
+
const single = toolContent.length === 1 ? toolContent[0] : undefined;
|
|
202
|
+
const result = {
|
|
203
|
+
type: "tool-result",
|
|
204
|
+
id: part.id,
|
|
205
|
+
name: part.name,
|
|
206
|
+
providerExecuted: part.executed,
|
|
207
|
+
providerMetadata: (part.executed === true ? sameProvider : reuse) ? metadata(native) : undefined,
|
|
208
|
+
result: state.status === "error" ? { type: "error", value: { error: state.error, content: toolContent } } : single?.type === "text" ? { type: "text", value: single.text } : { type: "content", value: toolContent }
|
|
209
|
+
};
|
|
210
|
+
if (part.executed === true)
|
|
211
|
+
content.push(result);
|
|
212
|
+
else
|
|
213
|
+
results.push({ role: "tool", content: [result] });
|
|
214
|
+
}
|
|
215
|
+
return [...content.length ? [make("assistant", content)] : [], ...results];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ../plugin/src/v2/tool-result.ts
|
|
219
|
+
function toolErrorText(result) {
|
|
220
|
+
const value = result.value === undefined ? result : result.value;
|
|
221
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
222
|
+
}
|
|
223
|
+
function toolStateContent(state) {
|
|
224
|
+
if (typeof state.output === "string")
|
|
225
|
+
return state.output;
|
|
226
|
+
if (state.status === "error")
|
|
227
|
+
return toolErrorText({ error: state.error, content: state.content ?? [] });
|
|
228
|
+
if (typeof state.content === "string")
|
|
229
|
+
return state.content;
|
|
230
|
+
if (!Array.isArray(state.content))
|
|
231
|
+
return "";
|
|
232
|
+
return state.content.map((part) => {
|
|
233
|
+
if (typeof part === "string")
|
|
234
|
+
return part;
|
|
235
|
+
if (!part || typeof part !== "object")
|
|
236
|
+
return "";
|
|
237
|
+
const value = part;
|
|
238
|
+
if (typeof value.text === "string")
|
|
239
|
+
return value.text;
|
|
240
|
+
if (typeof value.value === "string")
|
|
241
|
+
return value.value;
|
|
242
|
+
return "";
|
|
243
|
+
}).filter(Boolean).join(`
|
|
244
|
+
`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ../plugin/src/v2/hooks/store.ts
|
|
248
|
+
var rawMessageTypes = new Set(RAW_MESSAGE_TYPES2);
|
|
249
|
+
var isRawRow = (row) => rawMessageTypes.has(row.type);
|
|
250
|
+
var NO_MODEL = { providerID: "", id: "" };
|
|
251
|
+
function hostServesRowById(row) {
|
|
252
|
+
return isRawRow(row) && restoreRow(row, NO_MODEL).some((message) => message.id === row.id);
|
|
253
|
+
}
|
|
254
|
+
function projectRawMessages(rows, ordinalFor) {
|
|
255
|
+
return rows.filter(isRawRow).map((row, index) => {
|
|
256
|
+
const message = {
|
|
257
|
+
id: row.id,
|
|
258
|
+
ordinal: ordinalFor(row, index),
|
|
259
|
+
role: row.type === "assistant" ? "assistant" : row.type === "system" ? "system" : "user",
|
|
260
|
+
createdAt: row.time_created ?? row.data.time?.created,
|
|
261
|
+
parts: row.type === "assistant" ? (row.data.content ?? []).map((part) => {
|
|
262
|
+
if (part.type !== "tool")
|
|
263
|
+
return { ...part };
|
|
264
|
+
const state = part.state;
|
|
265
|
+
const content = state.content;
|
|
266
|
+
return {
|
|
267
|
+
type: "tool",
|
|
268
|
+
tool: part.name,
|
|
269
|
+
callID: part.id,
|
|
270
|
+
state: {
|
|
271
|
+
...state,
|
|
272
|
+
output: state.status === "error" ? toolStateContent(state) : content?.filter((p) => p.type === "text").map((p) => p.text).join(`
|
|
273
|
+
`) ?? ""
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}) : [{ type: "text", text: row.data.text ?? "" }]
|
|
277
|
+
};
|
|
278
|
+
Object.defineProperty(message, "storeType", { value: row.type, enumerable: false });
|
|
279
|
+
if (!hostServesRowById(row))
|
|
280
|
+
markHostUnservedRow(message);
|
|
281
|
+
return message;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
function rawMessagePage(rows, afterOrdinal) {
|
|
285
|
+
return projectRawMessages(rows, (_row, index) => afterOrdinal + index + 1);
|
|
286
|
+
}
|
|
287
|
+
var SERVED_BOUNDARY_PAGE = 50;
|
|
288
|
+
function servedBoundaryRow(reader, sessionID, messageID) {
|
|
289
|
+
const boundary = reader.messageById(sessionID, messageID);
|
|
290
|
+
if (!boundary)
|
|
291
|
+
return null;
|
|
292
|
+
if (hostServesRowById(boundary))
|
|
293
|
+
return boundary;
|
|
294
|
+
let through = boundary.seq - 1;
|
|
295
|
+
for (;; ) {
|
|
296
|
+
const rows = reader.rawRowsThrough(sessionID, through, SERVED_BOUNDARY_PAGE);
|
|
297
|
+
const served = rows.find(hostServesRowById);
|
|
298
|
+
if (served)
|
|
299
|
+
return served;
|
|
300
|
+
const oldest = rows.at(-1);
|
|
301
|
+
if (rows.length < SERVED_BOUNDARY_PAGE || !oldest)
|
|
302
|
+
return null;
|
|
303
|
+
through = oldest.seq - 1;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function createV2RawMessageReader(openReader, storePath, releaseReader = (reader) => reader.close()) {
|
|
307
|
+
const servedBoundaryCache = new Map;
|
|
308
|
+
return {
|
|
309
|
+
storePath,
|
|
310
|
+
getRevision: (sessionID) => {
|
|
311
|
+
const reader = openReader();
|
|
312
|
+
try {
|
|
313
|
+
return reader.latestSequence(sessionID);
|
|
314
|
+
} finally {
|
|
315
|
+
releaseReader(reader);
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
getCountAfterRevision: (sessionID, after, through) => {
|
|
319
|
+
const reader = openReader();
|
|
320
|
+
try {
|
|
321
|
+
return reader.messageCountAfterSequence(sessionID, after, through);
|
|
322
|
+
} finally {
|
|
323
|
+
releaseReader(reader);
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
readPage: (sessionID, afterOrdinal, limit, finalWatermark, after) => {
|
|
327
|
+
const reader = openReader();
|
|
328
|
+
try {
|
|
329
|
+
return rawMessagePage(reader.messagePage(sessionID, afterOrdinal, limit, finalWatermark, after), afterOrdinal);
|
|
330
|
+
} finally {
|
|
331
|
+
releaseReader(reader);
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
findById: (sessionID, messageID) => {
|
|
335
|
+
const reader = openReader();
|
|
336
|
+
try {
|
|
337
|
+
const ordinal = reader.messageOrdinalById(sessionID, messageID);
|
|
338
|
+
const row = reader.messageById(sessionID, messageID);
|
|
339
|
+
if (ordinal === null || row === null)
|
|
340
|
+
return null;
|
|
341
|
+
return rawMessagePage([row], ordinal - 1)[0] ?? null;
|
|
342
|
+
} finally {
|
|
343
|
+
releaseReader(reader);
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
findPartsById: (sessionID, messageID) => {
|
|
347
|
+
const reader = openReader();
|
|
348
|
+
try {
|
|
349
|
+
const row = reader.messageById(sessionID, messageID);
|
|
350
|
+
return row ? rawMessagePage([row], 0)[0] ?? null : null;
|
|
351
|
+
} finally {
|
|
352
|
+
releaseReader(reader);
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
hasById: (sessionID, messageID) => {
|
|
356
|
+
const reader = openReader();
|
|
357
|
+
try {
|
|
358
|
+
return reader.messageExistsById(sessionID, messageID);
|
|
359
|
+
} finally {
|
|
360
|
+
releaseReader(reader);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
ordinalOf: (sessionID, messageID) => {
|
|
364
|
+
const reader = openReader();
|
|
365
|
+
try {
|
|
366
|
+
return reader.messageOrdinalById(sessionID, messageID);
|
|
367
|
+
} finally {
|
|
368
|
+
releaseReader(reader);
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
orderOf: (sessionID, messageID) => {
|
|
372
|
+
const reader = openReader();
|
|
373
|
+
try {
|
|
374
|
+
return reader.sequenceForId(sessionID, messageID) ?? null;
|
|
375
|
+
} finally {
|
|
376
|
+
releaseReader(reader);
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
ordinalMapForRange: (sessionID, fromOrdinal, toOrdinal) => {
|
|
380
|
+
const reader = openReader();
|
|
381
|
+
try {
|
|
382
|
+
return reader.messageIdOrdinals(sessionID, fromOrdinal, toOrdinal);
|
|
383
|
+
} finally {
|
|
384
|
+
releaseReader(reader);
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
readOrdinalPage: (sessionID, after, limit) => {
|
|
388
|
+
const reader = openReader();
|
|
389
|
+
try {
|
|
390
|
+
return reader.messageOrdinalPage(sessionID, after, limit);
|
|
391
|
+
} finally {
|
|
392
|
+
releaseReader(reader);
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
getCount: (sessionID) => {
|
|
396
|
+
const reader = openReader();
|
|
397
|
+
try {
|
|
398
|
+
return reader.messageCount(sessionID);
|
|
399
|
+
} finally {
|
|
400
|
+
releaseReader(reader);
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
getStoredCount: (sessionID) => {
|
|
404
|
+
const reader = openReader();
|
|
405
|
+
try {
|
|
406
|
+
return reader.storedMessageCount(sessionID);
|
|
407
|
+
} finally {
|
|
408
|
+
releaseReader(reader);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
servedBoundaryIdOf: (sessionID, messageID) => {
|
|
412
|
+
const key = `${sessionID}\x00${messageID}`;
|
|
413
|
+
if (servedBoundaryCache.has(key))
|
|
414
|
+
return servedBoundaryCache.get(key) ?? null;
|
|
415
|
+
const reader = openReader();
|
|
416
|
+
try {
|
|
417
|
+
const served = servedBoundaryRow(reader, sessionID, messageID)?.id ?? null;
|
|
418
|
+
if (servedBoundaryCache.size >= 1000)
|
|
419
|
+
servedBoundaryCache.clear();
|
|
420
|
+
if (served !== null)
|
|
421
|
+
servedBoundaryCache.set(key, served);
|
|
422
|
+
return served;
|
|
423
|
+
} finally {
|
|
424
|
+
releaseReader(reader);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function createV2RawMessageProvider(reader, sessionID) {
|
|
430
|
+
return {
|
|
431
|
+
...reader.storePath ? { workerSource: { kind: "opencode2", path: reader.storePath } } : {},
|
|
432
|
+
readMessagePage: (afterOrdinal, limit, finalWatermark, after) => reader.readPage(sessionID, afterOrdinal, limit, finalWatermark, after),
|
|
433
|
+
readMessageById: (messageID) => reader.findById(sessionID, messageID),
|
|
434
|
+
readMessagePartsById: (messageID) => reader.findPartsById(sessionID, messageID),
|
|
435
|
+
hasMessageById: (messageID) => reader.hasById(sessionID, messageID),
|
|
436
|
+
readMessageOrdinalById: (messageID) => reader.ordinalOf(sessionID, messageID),
|
|
437
|
+
...reader.orderOf ? {
|
|
438
|
+
readMessageOrderById: (messageID) => reader.orderOf?.(sessionID, messageID) ?? null
|
|
439
|
+
} : {},
|
|
440
|
+
readMessageIdOrdinalsForRange: (fromOrdinal, toOrdinal) => reader.ordinalMapForRange(sessionID, fromOrdinal, toOrdinal),
|
|
441
|
+
readMessageOrdinalPage: (after, limit) => reader.readOrdinalPage(sessionID, after, limit),
|
|
442
|
+
getMessageCount: () => reader.getCount(sessionID),
|
|
443
|
+
getStoredMessageCount: () => reader.getStoredCount(sessionID),
|
|
444
|
+
...reader.servedBoundaryIdOf ? {
|
|
445
|
+
readServedBoundaryId: (messageID) => reader.servedBoundaryIdOf?.(sessionID, messageID) ?? null
|
|
446
|
+
} : {}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
export {
|
|
450
|
+
createV2RawMessageProvider,
|
|
451
|
+
createV2RawMessageReader
|
|
452
|
+
};
|
package/dist/subagent-entry.js
CHANGED
|
@@ -1,54 +1,63 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TOKEN_BUDGET_TOOL_REFUSAL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-mx757f3g.js";
|
|
4
4
|
import {
|
|
5
5
|
setHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
7
7
|
import {
|
|
8
8
|
log2
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-gymgz20n.js";
|
|
10
|
+
import"./index-dnp1jjar.js";
|
|
10
11
|
import {
|
|
11
12
|
resolveProjectIdentityForSession
|
|
12
|
-
} from "./index-
|
|
13
|
+
} from "./index-6pk49fc3.js";
|
|
13
14
|
import"./index-2qtx0q6h.js";
|
|
14
15
|
import {
|
|
15
16
|
openDatabase
|
|
16
|
-
} from "./index-
|
|
17
|
+
} from "./index-a7sj2bam.js";
|
|
17
18
|
import"./index-fapenpch.js";
|
|
18
|
-
import"./index-
|
|
19
|
-
import"./index-
|
|
20
|
-
import"./index-
|
|
21
|
-
import"./index-
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-
|
|
19
|
+
import"./index-3bb24eb6.js";
|
|
20
|
+
import"./index-8sqebjzk.js";
|
|
21
|
+
import"./index-wfqysrwq.js";
|
|
22
|
+
import"./index-x2n261wp.js";
|
|
23
|
+
import"./index-c1dqxr10.js";
|
|
24
|
+
import"./index-ck8wj35v.js";
|
|
25
|
+
import"./index-d107f484.js";
|
|
26
|
+
import"./index-yacs388s.js";
|
|
24
27
|
import"./index-135e8hvg.js";
|
|
25
|
-
import"./index-
|
|
26
|
-
import"./index-
|
|
28
|
+
import"./index-n0zjvs3h.js";
|
|
29
|
+
import"./index-wt7vmyj4.js";
|
|
30
|
+
import"./index-c6wbq66z.js";
|
|
27
31
|
import"./index-4knyh1kt.js";
|
|
28
32
|
import {
|
|
29
33
|
loadPiConfig,
|
|
30
34
|
ensureProjectRegisteredFromPiDirectory,
|
|
31
35
|
resolvePiHarnessKind,
|
|
32
36
|
registerMagicContextTools
|
|
33
|
-
} from "./index-
|
|
37
|
+
} from "./index-dgqjq8sg.js";
|
|
34
38
|
import"./index-ccanzg8p.js";
|
|
35
|
-
import"./index-
|
|
36
|
-
import"./index-
|
|
37
|
-
import"./index-
|
|
38
|
-
import"./index-
|
|
39
|
+
import"./index-rzfr7wdv.js";
|
|
40
|
+
import"./index-f9qet7y8.js";
|
|
41
|
+
import"./index-2qqsnh1b.js";
|
|
42
|
+
import"./index-z7dktknj.js";
|
|
43
|
+
import"./index-hgd00nas.js";
|
|
39
44
|
import"./index-9p40dgkm.js";
|
|
40
|
-
import"./index-
|
|
45
|
+
import"./index-mp0gh04g.js";
|
|
41
46
|
import"./index-yhzhdp3m.js";
|
|
42
|
-
import"./index-
|
|
43
|
-
import"./index-
|
|
44
|
-
import"./index-
|
|
47
|
+
import"./index-jbkwszd5.js";
|
|
48
|
+
import"./index-p9jfa33t.js";
|
|
49
|
+
import"./index-kj49vs41.js";
|
|
50
|
+
import"./index-pwp6zyx3.js";
|
|
45
51
|
import"./index-6x556c2q.js";
|
|
46
|
-
import"./index-
|
|
52
|
+
import"./index-ea37qn4x.js";
|
|
53
|
+
import"./index-w26zvs1q.js";
|
|
47
54
|
import"./index-1cvyaw9a.js";
|
|
48
|
-
import"./index-
|
|
55
|
+
import"./index-gxqmh9hq.js";
|
|
56
|
+
import"./index-ry84c8dr.js";
|
|
49
57
|
import"./index-29nw7n1r.js";
|
|
50
|
-
import"./index-
|
|
51
|
-
import"./index-
|
|
58
|
+
import"./index-f6y7mdq9.js";
|
|
59
|
+
import"./index-y90fxz4t.js";
|
|
60
|
+
import"./index-0wtm7g7f.js";
|
|
52
61
|
import {
|
|
53
62
|
setStoragePrivatePermissionEnforcement
|
|
54
63
|
} from "./index-81nthk8j.js";
|