@cortexkit/pi-magic-context 0.44.4 → 0.46.0

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.
Files changed (41) hide show
  1. package/dist/embedding-worker.js +47 -0
  2. package/dist/emscripten-module-0g8f45e6.js +602 -0
  3. package/dist/emscripten-module-0pekdjxz.js +1532 -0
  4. package/dist/emscripten-module-e67xwsp3.js +503 -0
  5. package/dist/emscripten-module-pj1vyb44.js +4559 -0
  6. package/dist/ffi-3cx1cxpk.js +78 -0
  7. package/dist/ffi-7bqqe4cd.js +91 -0
  8. package/dist/ffi-7e6gryj5.js +91 -0
  9. package/dist/ffi-bpvkebwr.js +78 -0
  10. package/dist/historian-calibration-extension.js +7 -4
  11. package/dist/index-266qrgss.js +417 -0
  12. package/dist/index-2p1e8706.js +30 -0
  13. package/dist/index-4vfrjwf6.js +7737 -0
  14. package/dist/{index-59dmj4zs.js → index-7n8gb6j3.js} +165 -3
  15. package/dist/index-901ekbga.js +244 -0
  16. package/dist/{module-asyncify-2EFITU5U-rkqjhjxd.js → index-g20jdh0p.js} +114 -105
  17. package/dist/{index-5fw91enm.js → index-n3g5mwa8.js} +1 -1
  18. package/dist/index-phh7e055.js +290 -0
  19. package/dist/index-q1yc6bs0.js +104 -0
  20. package/dist/index-sg8zbjs0.js +8937 -0
  21. package/dist/index-td885aah.js +576 -0
  22. package/dist/index-vf38qhee.js +150 -0
  23. package/dist/{index-5am7amy4.js → index-vhzmjpsk.js} +10220 -25155
  24. package/dist/{index-n8kg008j.js → index-w76x3af7.js} +28 -18
  25. package/dist/index-wv28nczk.js +464 -0
  26. package/dist/{index-npagr1cy.js → index-xvw8zptx.js} +4021 -3973
  27. package/dist/index.js +6942 -2942
  28. package/dist/{message-time-backfill-5yrp95cx.js → message-time-backfill-4688z1k2.js} +19 -4
  29. package/dist/migration-worker.js +56 -0
  30. package/dist/module-ES6BEMUI-3cet1pyp.js +12 -0
  31. package/dist/module-asyncify-2EFITU5U-c2razzd9.js +6 -0
  32. package/dist/{read-session-chunk-w493f72c.js → read-session-chunk-tc6yn2pe.js} +32 -5
  33. package/dist/rpc-notifications-gm1mdpwh.js +16 -0
  34. package/dist/{safe-notification-target-y3hg2m7p.js → safe-notification-target-6cn3z99t.js} +2 -2
  35. package/dist/subagent-entry.js +15 -6
  36. package/package.json +7 -6
  37. package/dist/index-97e5fzy3.js +0 -16
  38. package/dist/index-b3eqj1g6.js +0 -51
  39. package/dist/index-rn7gafjr.js +0 -8
  40. package/dist/index-v6t0tg85.js +0 -13
  41. package/dist/rpc-notifications-jxy30tgz.js +0 -8
@@ -0,0 +1,290 @@
1
+ // ../plugin/src/shared/harness-provider-map.ts
2
+ var CANONICAL_TO_PI_PROVIDER = {
3
+ openai: "openai-codex",
4
+ google: "google-antigravity"
5
+ };
6
+ var PI_TO_CANONICAL_PROVIDER = {
7
+ "openai-codex": "openai",
8
+ "google-antigravity": "google"
9
+ };
10
+ var CANONICAL_TO_OMP_PROVIDER = {
11
+ openai: "openai-codex",
12
+ google: "google-antigravity",
13
+ opencode: "opencode-zen"
14
+ };
15
+ var OMP_TO_CANONICAL_PROVIDER = {
16
+ "openai-codex": "openai",
17
+ "google-antigravity": "google",
18
+ "opencode-zen": "opencode"
19
+ };
20
+ var CANONICAL_MODEL_IDENTITY_ALIASES = {
21
+ "github-copilot/gpt-6-astra": "openai/gpt-6-astra"
22
+ };
23
+ function remapProviderPrefix(ref, map) {
24
+ if (typeof ref !== "string")
25
+ return ref;
26
+ const slash = ref.indexOf("/");
27
+ if (slash <= 0)
28
+ return ref;
29
+ const provider = ref.slice(0, slash);
30
+ if (!Object.hasOwn(map, provider))
31
+ return ref;
32
+ return `${map[provider]}${ref.slice(slash)}`;
33
+ }
34
+ function canonicalModelIdentity(ref) {
35
+ const harnessCanonical = piModelRefToCanonical(ompModelRefToCanonical(ref));
36
+ return CANONICAL_MODEL_IDENTITY_ALIASES[harnessCanonical.toLowerCase()] ?? harnessCanonical;
37
+ }
38
+ function piModelRefToCanonical(ref) {
39
+ return remapProviderPrefix(ref, PI_TO_CANONICAL_PROVIDER);
40
+ }
41
+ function resolveModelRefForPi(ref) {
42
+ return remapProviderPrefix(piModelRefToCanonical(ref), CANONICAL_TO_PI_PROVIDER);
43
+ }
44
+ function modelRefLookupOrder(ref) {
45
+ const canonical = piModelRefToCanonical(ompModelRefToCanonical(ref));
46
+ return [
47
+ ...new Set([
48
+ canonical,
49
+ ref,
50
+ resolveModelRefForPi(canonical),
51
+ resolveModelRefForOmp(canonical)
52
+ ])
53
+ ];
54
+ }
55
+ function ompModelRefToCanonical(ref) {
56
+ return remapProviderPrefix(ref, OMP_TO_CANONICAL_PROVIDER);
57
+ }
58
+ function resolveModelRefForOmp(ref) {
59
+ return remapProviderPrefix(ompModelRefToCanonical(ref), CANONICAL_TO_OMP_PROVIDER);
60
+ }
61
+
62
+ // ../plugin/src/shared/historian-tool-template.ts
63
+ class Parser {
64
+ source;
65
+ pos = 0;
66
+ constructor(source) {
67
+ this.source = source;
68
+ }
69
+ error() {
70
+ throw new Error(`Invalid tool expansion template at character ${this.pos + 1}`);
71
+ }
72
+ take(value) {
73
+ if (!this.source.startsWith(value, this.pos))
74
+ return false;
75
+ this.pos += value.length;
76
+ return true;
77
+ }
78
+ field() {
79
+ const match = /^[A-Za-z_][A-Za-z0-9_-]*/.exec(this.source.slice(this.pos));
80
+ if (!match)
81
+ return this.error();
82
+ this.pos += match[0].length;
83
+ return match[0];
84
+ }
85
+ quoted() {
86
+ const start = this.pos;
87
+ if (!this.take('"'))
88
+ return this.error();
89
+ while (this.pos < this.source.length) {
90
+ if (this.take("\\")) {
91
+ this.pos++;
92
+ continue;
93
+ }
94
+ if (this.take('"')) {
95
+ try {
96
+ return JSON.parse(this.source.slice(start, this.pos));
97
+ } catch {
98
+ return this.error();
99
+ }
100
+ }
101
+ this.pos++;
102
+ }
103
+ return this.error();
104
+ }
105
+ integer() {
106
+ const match = /^\d+/.exec(this.source.slice(this.pos));
107
+ if (!match)
108
+ return this.error();
109
+ this.pos += match[0].length;
110
+ const n = Number(match[0]);
111
+ if (!Number.isSafeInteger(n))
112
+ return this.error();
113
+ return n;
114
+ }
115
+ expression(relative) {
116
+ const steps = [];
117
+ if (!(relative && this.take("."))) {
118
+ const root = this.field();
119
+ if (!relative && root !== "input" && root !== "output")
120
+ return this.error();
121
+ steps.push({ field: root });
122
+ }
123
+ while (true) {
124
+ if (this.take("[")) {
125
+ if (this.take("*]."))
126
+ steps.push({ project: this.field() });
127
+ else {
128
+ const index = this.integer();
129
+ if (!this.take("]"))
130
+ return this.error();
131
+ steps.push({ index });
132
+ }
133
+ } else if (this.source[this.pos] === "." && !/^\.(each\(|join\(|count(?:\.|\})|truncate\()/.test(this.source.slice(this.pos))) {
134
+ this.pos++;
135
+ steps.push({ field: this.field() });
136
+ if (this.source[this.pos] === "(")
137
+ return this.error();
138
+ } else
139
+ break;
140
+ }
141
+ const expression = { steps, cap: 300 };
142
+ if (this.take(".each(")) {
143
+ if (relative)
144
+ return this.error();
145
+ expression.each = parseTemplate(this.quoted(), true);
146
+ if (!this.take(")"))
147
+ return this.error();
148
+ }
149
+ if (this.take(".join(")) {
150
+ expression.join = this.quoted();
151
+ if (!this.take(")"))
152
+ return this.error();
153
+ }
154
+ if (this.take(".count")) {
155
+ if (expression.each || expression.join !== undefined)
156
+ return this.error();
157
+ expression.count = true;
158
+ }
159
+ if (this.take(".truncate(")) {
160
+ expression.cap = this.integer();
161
+ if (!this.take(")"))
162
+ return this.error();
163
+ }
164
+ if (!this.take("}"))
165
+ return this.error();
166
+ return expression;
167
+ }
168
+ template(relative) {
169
+ const nodes = [];
170
+ while (this.pos < this.source.length) {
171
+ const next = this.source.indexOf("${", this.pos);
172
+ if (next < 0) {
173
+ nodes.push(this.source.slice(this.pos));
174
+ break;
175
+ }
176
+ nodes.push(this.source.slice(this.pos, next));
177
+ this.pos = next + 2;
178
+ nodes.push(this.expression(relative));
179
+ }
180
+ return nodes;
181
+ }
182
+ }
183
+ function parseTemplate(source, relative = false) {
184
+ return new Parser(source).template(relative);
185
+ }
186
+ function toolTemplateError(source) {
187
+ try {
188
+ parseTemplate(source);
189
+ return;
190
+ } catch (error) {
191
+ return error.message;
192
+ }
193
+ }
194
+ var templates = new Map;
195
+ function compiled(source) {
196
+ if (!templates.has(source)) {
197
+ try {
198
+ templates.set(source, parseTemplate(source));
199
+ } catch {
200
+ templates.set(source, null);
201
+ }
202
+ }
203
+ return templates.get(source) ?? null;
204
+ }
205
+ function oneLine(value) {
206
+ return value.replace(/[\r\n\u2028\u2029]+/g, " ");
207
+ }
208
+ function truncate(value, cap) {
209
+ const chars = Array.from(oneLine(value));
210
+ return chars.length > cap ? `${chars.slice(0, cap).join("")}…` : chars.join("");
211
+ }
212
+ function scalar(value) {
213
+ if (value === undefined)
214
+ return "";
215
+ return typeof value === "string" ? value : compactJson(value);
216
+ }
217
+ function compactJson(value) {
218
+ if (Array.isArray(value))
219
+ return `[${value.map((v) => compactJson(v)).join(",")}]`;
220
+ if (value !== null && typeof value === "object")
221
+ return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${compactJson(value[key])}`).join(",")}}`;
222
+ return JSON.stringify(value) ?? "null";
223
+ }
224
+ function field(value, key) {
225
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.hasOwn(value, key) ? value[key] : undefined;
226
+ }
227
+ function render(nodes, root) {
228
+ return nodes.map((node) => {
229
+ if (typeof node === "string")
230
+ return node;
231
+ let value = root;
232
+ let list = false;
233
+ for (const step of node.steps) {
234
+ if ("field" in step)
235
+ value = list && Array.isArray(value) ? value.map((item) => field(item, step.field)) : field(value, step.field);
236
+ else if ("index" in step)
237
+ value = Array.isArray(value) ? value[step.index] : undefined;
238
+ else {
239
+ value = Array.isArray(value) ? value.map((item) => field(item, step.project)) : undefined;
240
+ list = true;
241
+ }
242
+ }
243
+ if (node.count)
244
+ return truncate(Array.isArray(value) ? String(value.length) : "", node.cap);
245
+ if (node.each || list || node.join !== undefined) {
246
+ if (!Array.isArray(value))
247
+ return "";
248
+ const elements = value.slice(0, 10).map((item) => truncate(node.each ? render(node.each, item) : scalar(item), 300));
249
+ if (value.length > 10)
250
+ elements.push(`… +${value.length - 10} more`);
251
+ return truncate(elements.join(node.join ?? (node.each ? "; " : ", ")), node.cap);
252
+ }
253
+ return truncate(scalar(value), node.cap);
254
+ }).join("");
255
+ }
256
+ function renderToolTemplate(source, input, output) {
257
+ const nodes = compiled(source);
258
+ if (!nodes)
259
+ return null;
260
+ const text = typeof output === "string" ? output : output === undefined ? "" : compactJson(output);
261
+ let structured = output;
262
+ if (typeof output === "string") {
263
+ try {
264
+ const parsed = JSON.parse(output);
265
+ structured = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
266
+ } catch {
267
+ structured = undefined;
268
+ }
269
+ }
270
+ const root = { input, output: structured };
271
+ const bareOutputNodes = nodes.map((node) => typeof node !== "string" && node.steps.length === 1 && ("field" in node.steps[0]) && node.steps[0].field === "output" && !node.each && !node.count && node.join === undefined ? truncate(text ?? "", node.cap) : node);
272
+ return truncate(render(bareOutputNodes, root), 1000);
273
+ }
274
+
275
+ // ../plugin/src/shared/protected-tools-policy.ts
276
+ var DEFAULT_PROTECTED_TOOLS = {
277
+ todowrite: 1,
278
+ ctx_reduce: 3
279
+ };
280
+ function normalizeProtectedToolName(name) {
281
+ return (name ?? "").toLowerCase().replace(/^mcp_/, "");
282
+ }
283
+ function mergeProtectedTools(...maps) {
284
+ return Object.fromEntries([DEFAULT_PROTECTED_TOOLS, ...maps].flatMap((map) => Object.entries(map ?? {}).map(([name, count]) => [
285
+ normalizeProtectedToolName(name),
286
+ count
287
+ ])));
288
+ }
289
+
290
+ export { canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, toolTemplateError, renderToolTemplate, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools };
@@ -0,0 +1,104 @@
1
+ // ../plugin/src/shared/rpc-notifications.ts
2
+ var queue = [];
3
+ var nextNotificationId = 1;
4
+ var sinks = new Set;
5
+ function registerNotificationSink2(sink) {
6
+ sinks.add(sink);
7
+ return () => {
8
+ sinks.delete(sink);
9
+ };
10
+ }
11
+ function notificationMatchesSink(notification, sink) {
12
+ if (notification.sessionId === undefined)
13
+ return true;
14
+ if (sink.sessionId !== undefined)
15
+ return notification.sessionId === sink.sessionId;
16
+ return sink.protocol !== 2;
17
+ }
18
+ function pushNotification2(type, payload, sessionId) {
19
+ const notification = { id: nextNotificationId++, type, payload, sessionId };
20
+ queue.push(notification);
21
+ for (const sink of sinks) {
22
+ if (!notificationMatchesSink(notification, sink))
23
+ continue;
24
+ try {
25
+ sink.send(notification);
26
+ } catch {}
27
+ }
28
+ if (queue.length > 100) {
29
+ const reservedIds = new Set;
30
+ const reservedScopes = new Set;
31
+ for (let i = queue.length - 1;i >= 0 && reservedScopes.size < 25; i -= 1) {
32
+ const candidate = queue[i];
33
+ const scope = candidate.sessionId ?? "\x00global";
34
+ if (reservedScopes.has(scope))
35
+ continue;
36
+ reservedScopes.add(scope);
37
+ reservedIds.add(candidate.id);
38
+ }
39
+ const evictionIndex = queue.findIndex((candidate) => !reservedIds.has(candidate.id));
40
+ queue.splice(evictionIndex >= 0 ? evictionIndex : 0, 1);
41
+ }
42
+ }
43
+ function acknowledgeNotifications2(ids) {
44
+ const acknowledged = new Set(ids.filter((id) => Number.isSafeInteger(id) && id > 0));
45
+ if (acknowledged.size === 0)
46
+ return;
47
+ queue = queue.filter((notification) => !acknowledged.has(notification.id));
48
+ }
49
+ function __resetNotificationStateForTests2() {
50
+ queue = [];
51
+ nextNotificationId = 1;
52
+ sinks.clear();
53
+ }
54
+ function cursor(value) {
55
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
56
+ }
57
+ function drainNotifications2(lastReceivedId = 0, sessionId, options = {}) {
58
+ const sessionCursor = cursor(lastReceivedId);
59
+ if (options.globalOnly) {
60
+ queue = queue.filter((notification) => notification.sessionId !== undefined || notification.id > sessionCursor);
61
+ return queue.filter((notification) => notification.sessionId === undefined && notification.id > sessionCursor);
62
+ }
63
+ if (options.sessionOnly) {
64
+ if (sessionId === undefined)
65
+ return [];
66
+ queue = queue.filter((notification) => notification.sessionId !== sessionId || notification.id > sessionCursor);
67
+ return queue.filter((notification) => notification.sessionId === sessionId && notification.id > sessionCursor);
68
+ }
69
+ if (sessionId !== undefined && options.globalLastReceivedId !== undefined) {
70
+ const globalCursor = cursor(options.globalLastReceivedId);
71
+ queue = queue.filter((notification) => {
72
+ if (notification.sessionId === undefined)
73
+ return notification.id > globalCursor;
74
+ if (notification.sessionId === sessionId)
75
+ return notification.id > sessionCursor;
76
+ return true;
77
+ });
78
+ return queue.filter((notification) => {
79
+ if (notification.sessionId === undefined)
80
+ return notification.id > globalCursor;
81
+ return notification.sessionId === sessionId && notification.id > sessionCursor;
82
+ });
83
+ }
84
+ const matchesClient = (notification) => sessionId === undefined || notification.sessionId === undefined || notification.sessionId === sessionId;
85
+ if (sessionCursor > 0) {
86
+ queue = queue.filter((notification) => !(notification.id <= sessionCursor && matchesClient(notification)));
87
+ }
88
+ return queue.filter((notification) => notification.id > sessionCursor && matchesClient(notification));
89
+ }
90
+ function isTuiConnected2(sessionId) {
91
+ if (sinks.size === 0)
92
+ return false;
93
+ if (sessionId === undefined)
94
+ return true;
95
+ for (const sink of sinks) {
96
+ if (sink.sessionId === sessionId)
97
+ return true;
98
+ if (sink.sessionId === undefined && sink.protocol !== 2)
99
+ return true;
100
+ }
101
+ return false;
102
+ }
103
+
104
+ export { registerNotificationSink2, pushNotification2, acknowledgeNotifications2, __resetNotificationStateForTests2, drainNotifications2, isTuiConnected2 };