@cortexkit/opencode-magic-context 0.49.20 → 0.49.21
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 +6 -6
- package/dist/chunk-embedding-write-worker.js +9 -9
- package/dist/{compaction-marker-candidates-b2q30cft.js → compaction-marker-candidates-31h86ph0.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/{compartment-chunk-embedding-va090as0.js → compartment-chunk-embedding-he60aaa2.js} +5 -5
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +37 -3
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-frp3z2wk.js → conflict-warning-hook-2r32hyx6.js} +5 -5
- package/dist/{context-mkece1db.js → context-j7hp43a0.js} +153 -83
- package/dist/{embedding-backfill-gy3p78py.js → embedding-backfill-dtke6tck.js} +11 -11
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +4 -4
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts +1 -0
- package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts +7 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +7 -2
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +2 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search-rerank.d.ts +9 -2
- package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +2 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -0
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +1 -0
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/served-shape-repair.d.ts +19 -0
- package/dist/hooks/magic-context/served-shape-repair.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +4 -2
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +2 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +2 -2
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-t7hx3qcb.js → index-11gzxvf4.js} +101 -46
- package/dist/{index-neb2jaed.js → index-1gtfne2c.js} +1 -1
- package/dist/{index-67nyj0gy.js → index-1kbznkft.js} +48 -24
- package/dist/{index-1pefp8ar.js → index-3svaejkh.js} +4 -4
- package/dist/{index-0wthn7fp.js → index-51rdvtkz.js} +35 -4
- package/dist/{index-kc9pn495.js → index-66eby7hx.js} +1 -1
- package/dist/{index-pnjwa6qa.js → index-9q1g3c5q.js} +2 -2
- package/dist/{index-rmd0069m.js → index-a9zvn5fe.js} +24 -10
- package/dist/{index-jfh3cktr.js → index-ffzhwfzy.js} +3 -3
- package/dist/{v2/server-1zx2pa5d.js → index-gzy5w8ya.js} +193 -4
- package/dist/{index-d6rp4dxh.js → index-j32jj2t8.js} +4 -4
- package/dist/{index-35qc6606.js → index-jfem3dgz.js} +1 -1
- package/dist/{index-y4a3nhtk.js → index-jjvbk92s.js} +1 -1
- package/dist/{index-4n7w9rad.js → index-jmq8kfe7.js} +5 -5
- package/dist/{index-c4b76d4t.js → index-kfyb3k6n.js} +1 -1
- package/dist/{index-vkc1ca9p.js → index-kq5w68dp.js} +1 -1
- package/dist/{index-11zf2wwc.js → index-ksq50rg0.js} +2 -2
- package/dist/{index-153r2q6z.js → index-m32esgmj.js} +2 -2
- package/dist/{index-x4k3f4mf.js → index-mnhcdfxg.js} +148 -8
- package/dist/{index-48stjd56.js → index-mnnkgq0q.js} +10 -4
- package/dist/{index-wgypt3cs.js → index-nxrsns5x.js} +2466 -1290
- package/dist/{index-616rsjrv.js → index-qgh1qwjj.js} +1 -1
- package/dist/{index-jr5na10t.js → index-rxqr723x.js} +4 -4
- package/dist/{index-dc8hy95c.js → index-syaazvy2.js} +123 -40
- package/dist/{index-adk2z5d8.js → index-wfybj1dw.js} +2 -4
- package/dist/{index-305y133n.js → index-whcgcfrv.js} +6 -3
- package/dist/{index-jmycsey7.js → index-x6cbrv9h.js} +2 -2
- package/dist/{index-v7r4td4c.js → index-y76rhsnr.js} +28 -17
- package/dist/{index-2yhtnfcf.js → index-zy67whjr.js} +26 -8
- package/dist/index.js +43 -42
- package/dist/{message-fts-rowid-map-22tevnnj.js → message-fts-rowid-map-e79b7b6x.js} +3 -3
- package/dist/{message-index-5qxcz6h7.js → message-index-4q8ek2fc.js} +10 -10
- package/dist/{message-index-bounded-n0m0t7tv.js → message-index-bounded-rydsg9r5.js} +10 -10
- package/dist/{message-time-backfill-0myx7fz3.js → message-time-backfill-4qva0b4f.js} +1 -1
- package/dist/migration-worker.js +6 -6
- package/dist/plugin/embedding-bootstrap.d.ts +1 -0
- package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +1 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-s2pqgec9.js → project-embedding-registry-hn529988.js} +12 -10
- package/dist/raw-ordinal-warmup-worker.js +8 -8
- package/dist/{read-session-chunk-0a8vdyqp.js → read-session-chunk-t039f0m5.js} +6 -6
- package/dist/{read-session-raw-y5cszf0b.js → read-session-raw-aw6jgvwg.js} +2 -2
- package/dist/{recomp-orchestrator-61vyha9j.js → recomp-orchestrator-hbm53jj5.js} +23 -23
- package/dist/{search-archive-8q9s49p5.js → search-archive-weh164mh.js} +7 -7
- package/dist/{search-v1y9ejws.js → search-hea079d7.js} +19 -19
- package/dist/{send-session-notification-0k6qzydk.js → send-session-notification-gqzkz7da.js} +4 -4
- package/dist/shared/sqlite.d.ts +5 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/tag-transcript.d.ts +2 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/{sqlite-1rpvw2rj.js → sqlite-zdgm52sv.js} +5 -1
- package/dist/{storage-memory-nm7v82mj.js → storage-memory-e6a7mb0k.js} +2 -2
- package/dist/{storage-tags-r6nk29n4.js → storage-tags-a77q4v77.js} +2 -2
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +1 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-vtrgb7m6.js → transform-postprocess-phase-0b04tm1p.js} +23 -23
- package/dist/v2/auto-search-worker.js +6 -6
- package/dist/v2/chunk-embedding-write-worker.js +11 -11
- package/dist/v2/{compaction-marker-candidates-cfab70cs.js → compaction-marker-candidates-m4vmye3w.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/{compartment-chunk-embedding-nbdqx1td.js → compartment-chunk-embedding-8jjmcgeg.js} +5 -5
- package/dist/v2/{context-cc33tv2z.js → context-ea3x7smm.js} +652 -468
- package/dist/v2/{embedding-backfill-yxv2h5mc.js → embedding-backfill-5e74ae0m.js} +11 -11
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +4 -4
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts +1 -1
- package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +2 -0
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/embedding-lifecycle.d.ts +7 -0
- package/dist/v2/hooks/embedding-lifecycle.d.ts.map +1 -0
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +2 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts +2 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/hooks/transform-features.d.ts +2 -2
- package/dist/v2/hooks/transform-features.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-dg12wymk.js → message-fts-rowid-map-n8fdg2ja.js} +3 -3
- package/dist/v2/{message-index-bounded-f4e01xk0.js → message-index-bounded-8rcd7qq9.js} +12 -12
- package/dist/v2/{message-index-ydzrp6y6.js → message-index-qz9wdp82.js} +12 -12
- package/dist/v2/{message-time-backfill-ddh8n9gy.js → message-time-backfill-zvthw6xb.js} +1 -1
- package/dist/v2/migration-worker.js +8 -8
- package/dist/v2/{project-embedding-registry-deza9ksw.js → project-embedding-registry-v38q4xd5.js} +12 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +8 -8
- package/dist/v2/{read-session-chunk-8cxfagky.js → read-session-chunk-wazfyxcg.js} +8 -8
- package/dist/v2/{read-session-raw-1nrrecvx.js → read-session-raw-b70cpwzj.js} +2 -2
- package/dist/v2/{recomp-orchestrator-47m4hv5g.js → recomp-orchestrator-b12zaptj.js} +25 -25
- package/dist/v2/{search-archive-e80cvc09.js → search-archive-x64rtz1z.js} +9 -9
- package/dist/v2/{search-fjz746zr.js → search-hza9x72a.js} +21 -21
- package/dist/v2/{send-session-notification-nwvrv34d.js → send-session-notification-8eqe259v.js} +4 -4
- package/dist/v2/{server-4sxjs6hn.js → server-132h8twc.js} +4 -4
- package/dist/v2/{server-271qxsf5.js → server-24g8r2d0.js} +2466 -1290
- package/dist/v2/{server-m91f9m5s.js → server-33nqbqkw.js} +123 -40
- package/dist/v2/{server-brj8j2gk.js → server-3vhxy2k5.js} +1 -1
- package/dist/v2/{server-55rgxfrw.js → server-4kjmrjn4.js} +1 -1
- package/dist/v2/{server-wyawsa88.js → server-62g58aaz.js} +2 -2
- package/dist/v2/{server-230fnbws.js → server-6v3cdzsx.js} +1 -1
- package/dist/v2/{server-ygtykank.js → server-806rzhs6.js} +1 -1
- package/dist/v2/{server-5arr9ecn.js → server-94wk1ey3.js} +12 -1
- package/dist/v2/{server-af2pght7.js → server-ab1g0wn9.js} +2 -4
- package/dist/v2/{server-0epqaxhd.js → server-ad18djzs.js} +26 -8
- package/dist/v2/{server-4nw4fqhr.js → server-bsgd4dk1.js} +1 -1
- package/dist/v2/{server-dj7tz4ph.js → server-d1dzgvwd.js} +1 -1
- package/dist/v2/{server-vn2nwcv6.js → server-d48x3m4x.js} +4 -4
- package/dist/v2/{server-br1x0tev.js → server-dtp8hcjh.js} +2 -2
- package/dist/v2/{server-a3dwxfgd.js → server-fa7vtp40.js} +7 -4
- package/dist/{index-1zx2pa5d.js → v2/server-gzy5w8ya.js} +193 -4
- package/dist/v2/{server-hqzyq8n4.js → server-j8h7bsca.js} +26 -12
- package/dist/v2/{server-y4a3nhtk.js → server-jjvbk92s.js} +1 -1
- package/dist/v2/{server-ej96a39v.js → server-m4bfaevz.js} +1186 -1046
- package/dist/v2/{server-63fqdghs.js → server-ppcd1qxh.js} +92 -86
- package/dist/v2/{server-ne8arh8t.js → server-qjvk4a9t.js} +1 -1
- package/dist/v2/{server-xsryvyf6.js → server-qteg2kt9.js} +4 -4
- package/dist/v2/{server-168pb207.js → server-rqebawx1.js} +1 -1
- package/dist/v2/{server-j4jnp9b5.js → server-vr4szghm.js} +35 -4
- package/dist/v2/{server-9x0kmta4.js → server-wwaw5npa.js} +3 -3
- package/dist/v2/{server-c7dxxsj7.js → server-zg5y109h.js} +33 -33
- package/dist/v2/server.js +6 -6
- package/dist/v2/{sqlite-1rpvw2rj.js → sqlite-zdgm52sv.js} +5 -1
- package/dist/v2/{storage-memory-nm7v82mj.js → storage-memory-e6a7mb0k.js} +2 -2
- package/dist/v2/{storage-tags-ss08kj5r.js → storage-tags-q71rnr9f.js} +3 -3
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-639whfhq.js → wrapup-orchestrator-3ssd5yy1.js} +25 -25
- package/dist/wrapup-orchestrator-5vpcd1zx.js +49 -0
- package/package.json +2 -2
- package/src/config/index.test.ts +44 -0
- package/src/config/project-security.ts +15 -0
- package/src/config/rerank.test.ts +60 -0
- package/src/config/schema/magic-context.ts +57 -0
- package/src/shared/model-suggestion-retry.ts +1 -1
- package/src/shared/sqlite-turn-deadline.test.ts +270 -0
- package/src/shared/sqlite.ts +235 -7
- package/src/shared/tag-transcript.ts +9 -1
- package/dist/wrapup-orchestrator-mnvt2g8m.js +0 -49
|
@@ -175,6 +175,177 @@ function topLevelCommaSegments(text) {
|
|
|
175
175
|
function getTagIdentityWriteGeneration2() {
|
|
176
176
|
return tagIdentityWriteGeneration;
|
|
177
177
|
}
|
|
178
|
+
var busyTimeoutStates = new WeakMap;
|
|
179
|
+
var BUSY_TIMEOUT_QUERY = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*;?\s*$/i;
|
|
180
|
+
var BUSY_TIMEOUT_SETTER = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*(?==|\()/i;
|
|
181
|
+
function literalBusyTimeout(sql) {
|
|
182
|
+
const head = BUSY_TIMEOUT_SETTER.exec(sql);
|
|
183
|
+
if (!head)
|
|
184
|
+
return;
|
|
185
|
+
const match = /^(?:=\s*|\(\s*)(?:'(-?\d+)'|"(-?\d+)"|(-?\d+))\s*\)?\s*;?\s*$/.exec(sql.slice(head[0].length));
|
|
186
|
+
if (!match)
|
|
187
|
+
return;
|
|
188
|
+
const value = Number(match[1] ?? match[2] ?? match[3]);
|
|
189
|
+
return value < 0 ? 0 : value <= 2147483647 ? value : undefined;
|
|
190
|
+
}
|
|
191
|
+
function busyTimeoutStatements(sql) {
|
|
192
|
+
const statements = [];
|
|
193
|
+
let statement = "";
|
|
194
|
+
let quote = "";
|
|
195
|
+
for (let i = 0;i < sql.length; i++) {
|
|
196
|
+
const char = sql[i];
|
|
197
|
+
if (quote) {
|
|
198
|
+
statement += char;
|
|
199
|
+
if (char === quote) {
|
|
200
|
+
if (sql[i + 1] === quote)
|
|
201
|
+
statement += sql[++i];
|
|
202
|
+
else
|
|
203
|
+
quote = "";
|
|
204
|
+
}
|
|
205
|
+
} else if (char === "'" || char === '"' || char === "`" || char === "[") {
|
|
206
|
+
quote = char === "[" ? "]" : char;
|
|
207
|
+
statement += char;
|
|
208
|
+
} else if (char === "-" && sql[i + 1] === "-") {
|
|
209
|
+
while (i + 1 < sql.length && sql[i + 1] !== `
|
|
210
|
+
`)
|
|
211
|
+
i++;
|
|
212
|
+
statement += " ";
|
|
213
|
+
} else if (char === "/" && sql[i + 1] === "*") {
|
|
214
|
+
i += 2;
|
|
215
|
+
while (i < sql.length && !(sql[i] === "*" && sql[i + 1] === "/"))
|
|
216
|
+
i++;
|
|
217
|
+
i++;
|
|
218
|
+
statement += " ";
|
|
219
|
+
} else if (char === ";") {
|
|
220
|
+
statements.push(statement);
|
|
221
|
+
statement = "";
|
|
222
|
+
} else
|
|
223
|
+
statement += char;
|
|
224
|
+
}
|
|
225
|
+
statements.push(statement);
|
|
226
|
+
return statements.filter((part) => part.trim().length > 0);
|
|
227
|
+
}
|
|
228
|
+
function installNativeDeadlineRouting(db) {
|
|
229
|
+
const rawExec = db.exec.bind(db);
|
|
230
|
+
const rawPrepare = db.prepare.bind(db);
|
|
231
|
+
const readTimeout = () => {
|
|
232
|
+
const statement = rawPrepare("PRAGMA busy_timeout");
|
|
233
|
+
try {
|
|
234
|
+
return Object.values(statement.get())[0];
|
|
235
|
+
} finally {
|
|
236
|
+
statement.finalize?.();
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const timeoutState = { current: readTimeout() };
|
|
240
|
+
busyTimeoutStates.set(db, timeoutState);
|
|
241
|
+
const setBusyTimeout = (timeout) => {
|
|
242
|
+
rawExec(`PRAGMA busy_timeout=${timeout}`);
|
|
243
|
+
timeoutState.current = timeout;
|
|
244
|
+
};
|
|
245
|
+
const withinDeadline = (operation) => {
|
|
246
|
+
const deadline = nativeWaitScope?.getStore();
|
|
247
|
+
if (!deadline?.active || !deadline.remainingMs)
|
|
248
|
+
return operation();
|
|
249
|
+
const remaining = deadline.remainingMs();
|
|
250
|
+
if (remaining === Infinity)
|
|
251
|
+
return operation();
|
|
252
|
+
const previous = timeoutState.current;
|
|
253
|
+
const timeout = Math.min(previous, Math.max(0, Math.floor(remaining)));
|
|
254
|
+
if (timeout === previous)
|
|
255
|
+
return operation();
|
|
256
|
+
setBusyTimeout(timeout);
|
|
257
|
+
try {
|
|
258
|
+
return operation();
|
|
259
|
+
} finally {
|
|
260
|
+
setBusyTimeout(previous);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
Object.defineProperty(db, "exec", {
|
|
264
|
+
configurable: true,
|
|
265
|
+
writable: true,
|
|
266
|
+
value: (sql) => {
|
|
267
|
+
const parts = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql) : [];
|
|
268
|
+
if (parts.length === 1 && BUSY_TIMEOUT_QUERY.test(parts[0]))
|
|
269
|
+
return rawExec(sql);
|
|
270
|
+
const singleSetter = parts.length === 1 && BUSY_TIMEOUT_SETTER.test(parts[0]);
|
|
271
|
+
const setting = singleSetter ? literalBusyTimeout(parts[0]) : undefined;
|
|
272
|
+
if (singleSetter) {
|
|
273
|
+
const result = rawExec(sql);
|
|
274
|
+
timeoutState.current = setting ?? readTimeout();
|
|
275
|
+
return result;
|
|
276
|
+
}
|
|
277
|
+
if (!/\bbusy_timeout\b/i.test(sql))
|
|
278
|
+
return withinDeadline(() => rawExec(sql));
|
|
279
|
+
const setters = parts.filter((part) => BUSY_TIMEOUT_SETTER.test(part));
|
|
280
|
+
return withinDeadline(() => {
|
|
281
|
+
try {
|
|
282
|
+
const result = rawExec(sql);
|
|
283
|
+
if (setters.length)
|
|
284
|
+
timeoutState.current = literalBusyTimeout(setters[setters.length - 1]) ?? readTimeout();
|
|
285
|
+
return result;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
if (setters.length)
|
|
288
|
+
timeoutState.current = readTimeout();
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
const nativePrepare = (sql) => BUSY_TIMEOUT_QUERY.test(sql) || BUSY_TIMEOUT_SETTER.test(sql) ? rawPrepare(sql) : withinDeadline(() => rawPrepare(sql));
|
|
295
|
+
Object.defineProperty(db, "prepare", {
|
|
296
|
+
configurable: true,
|
|
297
|
+
writable: true,
|
|
298
|
+
value: (sql) => {
|
|
299
|
+
const statement = nativePrepare(sql);
|
|
300
|
+
const normalized = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql)[0] ?? sql : sql;
|
|
301
|
+
const setting = literalBusyTimeout(normalized);
|
|
302
|
+
const timeoutSetter = BUSY_TIMEOUT_SETTER.test(normalized);
|
|
303
|
+
const timeoutQuery = BUSY_TIMEOUT_QUERY.test(normalized);
|
|
304
|
+
if (timeoutSetter)
|
|
305
|
+
timeoutState.current = setting ?? readTimeout();
|
|
306
|
+
for (const method of ["run", "get", "all", "values"]) {
|
|
307
|
+
const execute = statement[method]?.bind(statement);
|
|
308
|
+
if (!execute)
|
|
309
|
+
continue;
|
|
310
|
+
Object.defineProperty(statement, method, {
|
|
311
|
+
configurable: true,
|
|
312
|
+
value: (...args) => {
|
|
313
|
+
if (timeoutQuery)
|
|
314
|
+
return execute(...args);
|
|
315
|
+
if (!timeoutSetter)
|
|
316
|
+
return withinDeadline(() => execute(...args));
|
|
317
|
+
const result = execute(...args);
|
|
318
|
+
timeoutState.current = readTimeout();
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (typeof statement.iterate === "function") {
|
|
324
|
+
const iterate = statement.iterate.bind(statement);
|
|
325
|
+
Object.defineProperty(statement, "iterate", {
|
|
326
|
+
configurable: true,
|
|
327
|
+
value: (...args) => {
|
|
328
|
+
const iterator = !timeoutSetter && !timeoutQuery ? withinDeadline(() => iterate(...args)) : iterate(...args);
|
|
329
|
+
const next = iterator.next.bind(iterator);
|
|
330
|
+
if (timeoutSetter)
|
|
331
|
+
timeoutState.current = readTimeout();
|
|
332
|
+
iterator.next = () => {
|
|
333
|
+
if (timeoutQuery)
|
|
334
|
+
return next();
|
|
335
|
+
if (!timeoutSetter)
|
|
336
|
+
return withinDeadline(next);
|
|
337
|
+
const result = next();
|
|
338
|
+
timeoutState.current = readTimeout();
|
|
339
|
+
return result;
|
|
340
|
+
};
|
|
341
|
+
return iterator;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
return statement;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
178
349
|
function installTransactionRouting(db, readonly) {
|
|
179
350
|
const nativeExec = db.exec.bind(db);
|
|
180
351
|
Object.defineProperty(db, "exec", {
|
|
@@ -312,7 +483,7 @@ function wrapRemainingTagWriteForms(statement) {
|
|
|
312
483
|
});
|
|
313
484
|
}
|
|
314
485
|
}
|
|
315
|
-
function trackSqliteConnection(db, filename, options) {
|
|
486
|
+
function trackSqliteConnection(db, filename, options, turnDeadlines = false) {
|
|
316
487
|
const originalClose = db.close.bind(db);
|
|
317
488
|
const sequence = nextSqliteConnectionSequence++;
|
|
318
489
|
const metadata = {
|
|
@@ -320,6 +491,8 @@ function trackSqliteConnection(db, filename, options) {
|
|
|
320
491
|
filename: typeof filename === "string" ? filename : Buffer.isBuffer(filename) ? "<buffer>" : ":memory:",
|
|
321
492
|
readonly: Boolean(options) && typeof options === "object" && (options.readonly === true || options.readOnly === true)
|
|
322
493
|
};
|
|
494
|
+
if (turnDeadlines)
|
|
495
|
+
installNativeDeadlineRouting(db);
|
|
323
496
|
installTransactionRouting(db, metadata.readonly);
|
|
324
497
|
Object.defineProperty(db, "close", {
|
|
325
498
|
configurable: true,
|
|
@@ -372,6 +545,12 @@ function buildNodeSqliteDatabaseClass(DatabaseSync) {
|
|
|
372
545
|
return NodeSqliteDatabase;
|
|
373
546
|
}
|
|
374
547
|
var Database2 = TrackedDatabase;
|
|
548
|
+
function createSqliteTurnDatabase2(filename, options) {
|
|
549
|
+
return trackSqliteConnection(new DatabaseImpl(filename, options), filename, options, true);
|
|
550
|
+
}
|
|
551
|
+
function hasSqliteTurnDeadlineRouting2(db) {
|
|
552
|
+
return busyTimeoutStates.has(db);
|
|
553
|
+
}
|
|
375
554
|
function getSqliteDatabasePath2(db) {
|
|
376
555
|
for (const connection of trackedSqliteConnections.values()) {
|
|
377
556
|
if (connection.reference.deref() === db) {
|
|
@@ -391,6 +570,11 @@ function pragmaValue(db, name) {
|
|
|
391
570
|
return row[name] ?? Object.values(row)[0];
|
|
392
571
|
}
|
|
393
572
|
function pragmaNumber(db, name) {
|
|
573
|
+
if (name === "busy_timeout") {
|
|
574
|
+
const state = busyTimeoutStates.get(db);
|
|
575
|
+
if (state)
|
|
576
|
+
return state.current;
|
|
577
|
+
}
|
|
394
578
|
try {
|
|
395
579
|
const value = pragmaValue(db, name);
|
|
396
580
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
@@ -521,11 +705,14 @@ function prepareCachedStatement2(db, sql) {
|
|
|
521
705
|
return ownPreparedStatement(db, db.prepare(sql));
|
|
522
706
|
}
|
|
523
707
|
var privilegeDepth = new WeakMap;
|
|
708
|
+
var nativeWaitScope;
|
|
524
709
|
var transformPassScope = new AsyncLocalStorage;
|
|
525
710
|
var admissionScope = new AsyncLocalStorage;
|
|
526
711
|
var backgroundWriterScope = new AsyncLocalStorage;
|
|
527
712
|
function withSqliteBackgroundWriter2(operation) {
|
|
528
|
-
|
|
713
|
+
if (!nativeWaitScope?.getStore())
|
|
714
|
+
return backgroundWriterScope.run(true, operation);
|
|
715
|
+
return nativeWaitScope.run(undefined, () => backgroundWriterScope.run(true, operation));
|
|
529
716
|
}
|
|
530
717
|
function withSqliteTransformPass2(operation) {
|
|
531
718
|
const existing = transformPassScope.getStore();
|
|
@@ -556,7 +743,9 @@ function withSqliteTransformPass2(operation) {
|
|
|
556
743
|
return typeof reservation === "function" ? run(reservation) : reservation.then(run);
|
|
557
744
|
}
|
|
558
745
|
function withoutSqliteTransformPass2(operation) {
|
|
559
|
-
|
|
746
|
+
if (!nativeWaitScope?.getStore())
|
|
747
|
+
return transformPassScope.run(undefined, operation);
|
|
748
|
+
return nativeWaitScope.run(undefined, () => transformPassScope.run(undefined, operation));
|
|
560
749
|
}
|
|
561
750
|
function assertTransformWrite2() {
|
|
562
751
|
if (!backgroundWriterScope.getStore())
|
|
@@ -890,4 +1079,4 @@ async function yieldIndexChunk2() {
|
|
|
890
1079
|
await yieldIndexTurn();
|
|
891
1080
|
}
|
|
892
1081
|
|
|
893
|
-
export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
|
|
1082
|
+
export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, createSqliteTurnDatabase2, hasSqliteTurnDeadlineRouting2, getSqliteDatabasePath2, getSqliteMemoryStats2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, SqliteAcquisitionBusyError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
|
|
@@ -4,14 +4,16 @@ import {
|
|
|
4
4
|
registerSqliteDiagnosticSink2,
|
|
5
5
|
detectSqliteRuntime2,
|
|
6
6
|
Database2,
|
|
7
|
+
createSqliteTurnDatabase2,
|
|
8
|
+
hasSqliteTurnDeadlineRouting2,
|
|
7
9
|
withSqliteBackgroundWriter2,
|
|
8
10
|
withoutSqliteTransformPass2,
|
|
9
11
|
isTransientSqliteError2,
|
|
10
12
|
withPrivilegedWriter2
|
|
11
|
-
} from "./server-
|
|
13
|
+
} from "./server-gzy5w8ya.js";
|
|
12
14
|
import {
|
|
13
15
|
scheduleAfterBootQuiet
|
|
14
|
-
} from "./server-
|
|
16
|
+
} from "./server-qjvk4a9t.js";
|
|
15
17
|
import {
|
|
16
18
|
getHarness2,
|
|
17
19
|
harnessOwnsOpenCodeStore2
|
|
@@ -40,7 +42,7 @@ import {
|
|
|
40
42
|
} from "./server-fb3zxn06.js";
|
|
41
43
|
import {
|
|
42
44
|
startMessageFtsRowidMapBackfill2
|
|
43
|
-
} from "./server-
|
|
45
|
+
} from "./server-dtp8hcjh.js";
|
|
44
46
|
import {
|
|
45
47
|
LKG_SLOT_CHUNKS_DDL,
|
|
46
48
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -50,12 +52,12 @@ import {
|
|
|
50
52
|
hasPendingMigrations,
|
|
51
53
|
getMainThreadMigrationBodyCount,
|
|
52
54
|
runMigrations
|
|
53
|
-
} from "./server-
|
|
55
|
+
} from "./server-wwaw5npa.js";
|
|
54
56
|
import {
|
|
55
57
|
ensureColumn,
|
|
56
58
|
installV95PerfSchema,
|
|
57
59
|
installTagIdentityRevisionTrigger
|
|
58
|
-
} from "./server-
|
|
60
|
+
} from "./server-rqebawx1.js";
|
|
59
61
|
import {
|
|
60
62
|
resolveOpenCodeDbPath,
|
|
61
63
|
hasV1MessageTables
|
|
@@ -63,7 +65,7 @@ import {
|
|
|
63
65
|
import {
|
|
64
66
|
setDatabase,
|
|
65
67
|
loadToolDefinitionMeasurements
|
|
66
|
-
} from "./server-
|
|
68
|
+
} from "./server-d1dzgvwd.js";
|
|
67
69
|
import {
|
|
68
70
|
getErrorMessage
|
|
69
71
|
} from "./server-y8v6yerm.js";
|
|
@@ -1219,8 +1221,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1219
1221
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1220
1222
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1221
1223
|
return;
|
|
1222
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1223
|
-
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-
|
|
1224
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-wazfyxcg.js"));
|
|
1225
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-zvthw6xb.js"));
|
|
1224
1226
|
if (signal.aborted)
|
|
1225
1227
|
return;
|
|
1226
1228
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
@@ -2525,6 +2527,10 @@ function openDatabase(dbPathOrOptions) {
|
|
|
2525
2527
|
return null;
|
|
2526
2528
|
}
|
|
2527
2529
|
if (existing) {
|
|
2530
|
+
if (options?.nativeTurnDeadlines && !hasSqliteTurnDeadlineRouting2(existing)) {
|
|
2531
|
+
log2("[magic-context] storage unavailable: native turn deadlines must be selected on the first open; restart the host");
|
|
2532
|
+
return null;
|
|
2533
|
+
}
|
|
2528
2534
|
if (!enforceSchemaFence(existing, dbPath, latestSupportedVersion)) {
|
|
2529
2535
|
return null;
|
|
2530
2536
|
}
|
|
@@ -2549,7 +2555,7 @@ function openDatabase(dbPathOrOptions) {
|
|
|
2549
2555
|
throw error;
|
|
2550
2556
|
}
|
|
2551
2557
|
}
|
|
2552
|
-
db = new Database2(dbPath);
|
|
2558
|
+
db = options?.nativeTurnDeadlines ? createSqliteTurnDatabase2(dbPath) : new Database2(dbPath);
|
|
2553
2559
|
installBootBusyTimeout(db, dbPath, busyTimeoutMs, options?.onBootBusyTimeout);
|
|
2554
2560
|
if (!enforceSchemaFence(db, dbPath, latestSupportedVersion)) {
|
|
2555
2561
|
closeQuietly(db);
|
|
@@ -2596,6 +2602,10 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2596
2602
|
lastMigrationOnOpenRefusal = null;
|
|
2597
2603
|
const existing = databases.get(dbPath);
|
|
2598
2604
|
if (existing) {
|
|
2605
|
+
if (options?.nativeTurnDeadlines && !hasSqliteTurnDeadlineRouting2(existing)) {
|
|
2606
|
+
log2("[magic-context] storage unavailable: native turn deadlines must be selected on the first open; restart the host");
|
|
2607
|
+
return null;
|
|
2608
|
+
}
|
|
2599
2609
|
const startedAt = performance.now();
|
|
2600
2610
|
const accepted = enforceSchemaFence(existing, dbPath, latestSupportedVersion);
|
|
2601
2611
|
if (accepted) {
|
|
@@ -2611,8 +2621,12 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2611
2621
|
return accepted ? existing : null;
|
|
2612
2622
|
}
|
|
2613
2623
|
const pending = pendingAsyncOpens.get(dbPath);
|
|
2614
|
-
if (pending)
|
|
2615
|
-
|
|
2624
|
+
if (pending) {
|
|
2625
|
+
if (!options?.nativeTurnDeadlines)
|
|
2626
|
+
return pending;
|
|
2627
|
+
const opened = await pending;
|
|
2628
|
+
return opened && hasSqliteTurnDeadlineRouting2(opened) ? opened : null;
|
|
2629
|
+
}
|
|
2616
2630
|
if (!isFileBackedPath(dbPath)) {
|
|
2617
2631
|
throw new Error("async migration requires a file-backed database; use the explicit synchronous opener for in-memory or URI test databases");
|
|
2618
2632
|
}
|
|
@@ -2638,7 +2652,7 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2638
2652
|
throw error;
|
|
2639
2653
|
}
|
|
2640
2654
|
}
|
|
2641
|
-
db = new Database2(dbPath);
|
|
2655
|
+
db = options?.nativeTurnDeadlines ? createSqliteTurnDatabase2(dbPath) : new Database2(dbPath);
|
|
2642
2656
|
installBootBusyTimeout(db, dbPath, busyTimeoutMs, options?.onBootBusyTimeout);
|
|
2643
2657
|
openMs = performance.now() - openStartedAt;
|
|
2644
2658
|
guardStartedAt = performance.now();
|