@cortexkit/opencode-magic-context 0.49.11 → 0.49.13
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/README.md +1 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +28 -0
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -0
- package/dist/{announcement-hdbkt8v5.js → announcement-g789dmt6.js} +2 -2
- package/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +89 -0
- package/dist/{compaction-marker-candidates-xxz35vwp.js → compaction-marker-candidates-v5c6997n.js} +3 -3
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/config/agent-disable.d.ts +14 -0
- package/dist/config/agent-disable.d.ts.map +1 -1
- package/dist/config/dependency-notes.d.ts +34 -0
- package/dist/config/dependency-notes.d.ts.map +1 -0
- package/dist/config/schema/agent-overrides.d.ts +12 -12
- package/dist/config/schema/magic-context.d.ts +88 -88
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-xwkfncav.js → conflict-warning-hook-mgq17yr3.js} +8 -8
- package/dist/{context-twz3s0cg.js → context-azqk0vfd.js} +121 -145
- package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-zn7yzd2d.js} +3 -3
- package/dist/embedding-backfill-5e1t5wha.js +22 -0
- package/dist/embedding-worker-process.js +2 -2
- package/dist/embedding-worker.js +6 -6
- package/dist/features/magic-context/chunk-embedding-write-worker.d.ts +2 -0
- package/dist/features/magic-context/chunk-embedding-write-worker.d.ts.map +1 -0
- package/dist/features/magic-context/chunk-embedding-writer.d.ts +48 -0
- package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -0
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +3 -2
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +8 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -0
- package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +5 -0
- package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts +22 -4
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +22 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts +6 -1
- package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +25 -11
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +32 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/unborn-head.d.ts +34 -0
- package/dist/features/magic-context/memory/unborn-head.d.ts.map +1 -0
- package/dist/features/magic-context/mural/compress-cues.d.ts +3 -0
- package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +2 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/{history-owner-ty29fz0f.js → history-owner-xp3pngv7.js} +3 -3
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-embed-session.d.ts +10 -0
- package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-prompt.d.ts +6 -0
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts +12 -0
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
- package/dist/hooks/magic-context/embed-session-state.d.ts +8 -1
- package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -0
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +3 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +12 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts +58 -0
- package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts.map +1 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +7 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +19 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
- package/dist/hooks/magic-context/transform-compartment-phase.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 +4 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-bzp9s8z2.js → index-1d289pq2.js} +2 -2
- package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
- package/dist/{index-z7avx6rw.js → index-2jr1smmh.js} +280 -160
- package/dist/{index-4ccdr7yw.js → index-3kdm78zp.js} +5 -5
- package/dist/{index-9159kk15.js → index-3kx0kg0f.js} +64 -7
- package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
- package/dist/{index-84j7jq8a.js → index-aw1bh90w.js} +10 -10
- package/dist/{index-qr1mkc2y.js → index-b16gpywn.js} +9 -9
- package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
- package/dist/{index-yhrrx7qa.js → index-bxdg2nbt.js} +3 -3
- package/dist/{index-0abg88h2.js → index-dgs16axy.js} +4 -4
- package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
- package/dist/{index-bmwfzz28.js → index-e20m7284.js} +4 -4
- package/dist/{index-4jkhhpn1.js → index-e4dsjj1p.js} +3 -3
- package/dist/{index-s178h9z8.js → index-f71thw8j.js} +1 -1
- package/dist/{index-kvw6xew3.js → index-fkx2qnvw.js} +2 -2
- package/dist/{index-f8cn4xqa.js → index-fwefky9w.js} +18 -5
- package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
- package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
- package/dist/{index-g40wgxxt.js → index-hnm8raee.js} +4 -4
- package/dist/{index-gjvjh960.js → index-hqkczed7.js} +1 -1
- package/dist/{index-mvvephtj.js → index-j75v2476.js} +1 -1
- package/dist/{index-150zz6fh.js → index-k29z4aqh.js} +1 -1
- package/dist/{index-b64n4d0h.js → index-kee4kn5j.js} +1 -1
- package/dist/index-ksdyrrav.js +52 -0
- package/dist/{index-angx1s0k.js → index-mmfa86mt.js} +16 -6
- package/dist/{index-9jvab89d.js → index-n6m03s3n.js} +2 -2
- package/dist/{index-q28hsbpg.js → index-nj7yykkx.js} +1 -1
- package/dist/{index-ghc9f0n7.js → index-p5y3k4g7.js} +29 -1
- package/dist/{index-xztdf9t7.js → index-qkd9zz0p.js} +17 -17
- package/dist/index-saews2s3.js +229 -0
- package/dist/{index-kkvxnbt8.js → index-sj89f3b0.js} +62 -33
- package/dist/{index-jw4gbfkv.js → index-v10f1rjv.js} +5 -5
- package/dist/{index-0j6crjgh.js → index-v13skev1.js} +13 -13
- package/dist/{index-hqnggmxn.js → index-wj6ht7nm.js} +547 -179
- package/dist/{index-a865mj02.js → index-wk0n1cgt.js} +4 -4
- package/dist/{index-q3qck7j2.js → index-wz6mzzb1.js} +6 -5
- package/dist/{index-se1w3v2m.js → index-y1qysm3q.js} +332 -256
- package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +119 -129
- package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
- package/dist/{message-index-bounded-0rbbg9rd.js → message-index-bounded-vm64mqpq.js} +16 -16
- package/dist/{message-index-ct5x2kwa.js → message-index-seaqpb7c.js} +16 -16
- package/dist/{message-time-backfill-nb5hhnrt.js → message-time-backfill-qjge9044.js} +3 -3
- package/dist/migration-worker.js +11 -11
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- 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-ft9gh2e2.js → project-embedding-registry-x45bv3qr.js} +12 -11
- package/dist/raw-ordinal-warmup-worker.js +12 -7
- package/dist/{read-session-chunk-y3hhsbzw.js → read-session-chunk-ax05f7gr.js} +11 -11
- package/dist/{read-session-raw-gm6xj30v.js → read-session-raw-m56hc7v2.js} +7 -3
- package/dist/recomp-orchestrator-dmbeadwt.js +61 -0
- package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
- package/dist/{search-jd8xh721.js → search-5yd5ytzs.js} +25 -24
- package/dist/{send-session-notification-vzhj8bsg.js → send-session-notification-24r4esbh.js} +6 -6
- package/dist/shared/data-path.d.ts +4 -0
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/model-suggestion-retry.d.ts +2 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/{storage-tags-35m4gms2.js → storage-tags-yygfb9c8.js} +7 -5
- package/dist/{task-config-cgpg0nvh.js → task-config-x3qmayd2.js} +6 -2
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-pmqxfq4q.js → transform-postprocess-phase-72v86syx.js} +32 -31
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +88 -0
- package/dist/v2/{compaction-marker-candidates-a15w3mqh.js → compaction-marker-candidates-1vqwr3s5.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{context-p1zfcw41.js → context-w055w17c.js} +628 -255
- package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-2zh4gm2c.js} +3 -3
- package/dist/v2/embedding-backfill-jmaf8zrr.js +21 -0
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +5 -5
- package/dist/v2/{history-owner-2cr9py37.js → history-owner-42e16w0n.js} +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/transform-features.d.ts +3 -2
- package/dist/v2/hooks/transform-features.d.ts.map +1 -1
- package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
- package/dist/v2/{message-index-bounded-7wcbp975.js → message-index-bounded-wepg5723.js} +15 -15
- package/dist/v2/{message-index-cjhv92m2.js → message-index-gcmd0ng0.js} +15 -15
- package/dist/v2/{message-time-backfill-rz1pnpaj.js → message-time-backfill-bsteyc4d.js} +2 -2
- package/dist/v2/migration-worker.js +10 -10
- package/dist/v2/{project-embedding-registry-g34gcf74.js → project-embedding-registry-0msp56p8.js} +11 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
- package/dist/v2/{read-session-chunk-8d3v87vr.js → read-session-chunk-hr3w5bjk.js} +10 -10
- package/dist/v2/{read-session-raw-h4azh85b.js → read-session-raw-b3tf6ra1.js} +6 -2
- package/dist/v2/recomp-orchestrator-ca7qt75a.js +60 -0
- package/dist/v2/retrospective-raw-provider.d.ts.map +1 -1
- package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
- package/dist/v2/{search-a1acjwf8.js → search-c86dcv14.js} +24 -23
- package/dist/v2/{send-session-notification-z5mcjdea.js → send-session-notification-8ghn9tnv.js} +5 -5
- package/dist/v2/{server-npm52h2q.js → server-05xjtq6c.js} +1 -1
- package/dist/v2/{server-s6jqh8bj.js → server-0ppsweh6.js} +1 -1
- package/dist/v2/server-0s95v3en.js +49 -0
- package/dist/v2/{server-hn9fb3v0.js → server-34kwfsr4.js} +2 -2
- package/dist/v2/server-4gn3z5an.js +229 -0
- package/dist/v2/{server-kn7skz9r.js → server-6cdy4rc0.js} +3 -3
- package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
- package/dist/v2/{server-7fvmt15t.js → server-b81w6sw3.js} +273 -107
- package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
- package/dist/v2/{server-d6t16r89.js → server-d8tj10db.js} +1 -1
- package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
- package/dist/v2/{server-rxcq4t50.js → server-ef89gdsx.js} +5 -5
- package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
- package/dist/v2/{server-83d71zab.js → server-g10mdym6.js} +3 -3
- package/dist/v2/{server-njnx39q2.js → server-gvkm8xaj.js} +189 -29
- package/dist/v2/{server-ckrb5rm8.js → server-h0410h0v.js} +1 -1
- package/dist/v2/{server-sg68np13.js → server-hek6z3w6.js} +330 -254
- package/dist/v2/{server-f27he3j1.js → server-k2bzedxk.js} +4 -4
- package/dist/v2/{server-wkhfyzpg.js → server-m97brnat.js} +9 -9
- package/dist/v2/{server-erfp0xb6.js → server-n8ch9683.js} +16 -16
- package/dist/v2/{server-bx59ezg6.js → server-prg55b7k.js} +16 -6
- package/dist/v2/{server-89fcbe37.js → server-pwv4ezb0.js} +1 -1
- package/dist/v2/{server-r5p3b1wy.js → server-qd11g795.js} +29 -1
- package/dist/v2/{server-ewqshbs8.js → server-qhfvvfxj.js} +64 -7
- package/dist/v2/{server-988cqjme.js → server-rrqpvwqd.js} +2 -2
- package/dist/v2/{server-d3f4g62c.js → server-t4prcjc1.js} +13 -13
- package/dist/v2/{server-nveratm5.js → server-tbe1femw.js} +4 -4
- package/dist/v2/{server-jc8v585p.js → server-th4y11y7.js} +15 -15
- package/dist/v2/{server-h3wc20sv.js → server-vbe4se57.js} +4 -4
- package/dist/v2/{server-pbpp8r8h.js → server-xh7jar6k.js} +9 -9
- package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
- package/dist/v2/{server-5x7kmyz8.js → server-zc3e54vy.js} +10 -51
- package/dist/v2/{server-xqf2d2mg.js → server-zs8d0s3b.js} +2 -2
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +18 -10
- package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
- package/dist/v2/store-reader.d.ts +1 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{task-config-x0hq3qfd.js → task-config-nvz8mapa.js} +6 -2
- package/dist/v2/{wrapup-orchestrator-87q9d5e2.js → wrapup-orchestrator-e1a2w6jh.js} +31 -29
- package/dist/wrapup-orchestrator-2051r6qm.js +48 -0
- package/package.json +6 -5
- package/src/agents/smart-notes-dreamer-gate.fixture.ts +171 -0
- package/src/agents/smart-notes-dreamer-gate.golden.json +245 -0
- package/src/agents/smart-notes-dreamer-gate.test.ts +161 -0
- package/src/config/agent-disable.ts +13 -0
- package/src/config/dependency-notes.test.ts +114 -0
- package/src/config/dependency-notes.ts +80 -0
- package/src/config/schema/magic-context.ts +23 -14
- package/src/features/magic-context/dreamer/task-registry.ts +40 -0
- package/src/shared/data-path.test.ts +35 -1
- package/src/shared/data-path.ts +57 -1
- package/src/shared/model-suggestion-retry.test.ts +34 -0
- package/src/shared/model-suggestion-retry.ts +23 -3
- package/src/shared/prompt-async-transport.test.ts +1 -1
- package/src/shared/prompt-async-transport.ts +16 -3
- package/dist/embedding-backfill-fjbfh1dt.js +0 -21
- package/dist/recomp-orchestrator-67k45s0b.js +0 -60
- package/dist/v2/embedding-backfill-xcw3t6hp.js +0 -20
- package/dist/v2/recomp-orchestrator-n0pq36f0.js +0 -59
- package/dist/wrapup-orchestrator-jqapepw0.js +0 -47
- /package/dist/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
- /package/dist/v2/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
package/src/shared/data-path.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
lstatSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
readlinkSync,
|
|
7
|
+
realpathSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
2
10
|
import * as os from "node:os";
|
|
3
11
|
import * as path from "node:path";
|
|
4
12
|
import { getHarness, type HarnessId } from "./harness";
|
|
@@ -253,6 +261,54 @@ export function getMagicContextStorageDir(): string {
|
|
|
253
261
|
return getMagicContextStorageResolution().path;
|
|
254
262
|
}
|
|
255
263
|
|
|
264
|
+
function canonicalizeStoragePath(value: string, seen = new Set<string>()): string {
|
|
265
|
+
const absolute = path.resolve(value);
|
|
266
|
+
if (seen.has(absolute)) return absolute;
|
|
267
|
+
seen.add(absolute);
|
|
268
|
+
|
|
269
|
+
try {
|
|
270
|
+
return realpathSync.native(absolute);
|
|
271
|
+
} catch {
|
|
272
|
+
try {
|
|
273
|
+
if (lstatSync(absolute).isSymbolicLink()) {
|
|
274
|
+
const target = readlinkSync(absolute);
|
|
275
|
+
const resolvedTarget = path.isAbsolute(target)
|
|
276
|
+
? target
|
|
277
|
+
: path.resolve(path.dirname(absolute), target);
|
|
278
|
+
return canonicalizeStoragePath(resolvedTarget, seen);
|
|
279
|
+
}
|
|
280
|
+
} catch {
|
|
281
|
+
// The path may not exist yet; resolve the nearest existing parent below.
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const parent = path.dirname(absolute);
|
|
285
|
+
if (parent === absolute) return absolute;
|
|
286
|
+
const resolvedParent = canonicalizeStoragePath(parent, seen);
|
|
287
|
+
return path.resolve(resolvedParent, path.basename(absolute));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Whether the resolved store is outside the default CortexKit backup directory. */
|
|
292
|
+
export function isMagicContextStorageOutsideEngram(
|
|
293
|
+
storageDir = getMagicContextStorageDir(),
|
|
294
|
+
backupDir = path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
|
|
295
|
+
): boolean {
|
|
296
|
+
const resolvedStorageDir = canonicalizeStoragePath(storageDir);
|
|
297
|
+
const resolvedBackupDir = canonicalizeStoragePath(backupDir);
|
|
298
|
+
const relative = path.relative(resolvedBackupDir, resolvedStorageDir);
|
|
299
|
+
return path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
|
|
303
|
+
|
|
304
|
+
/** Claim the process-wide startup check so multiple host entries log at most once. */
|
|
305
|
+
export function claimStorageBackupWarningCheck(): boolean {
|
|
306
|
+
const processState = globalThis as unknown as { [key: symbol]: boolean | undefined };
|
|
307
|
+
if (processState[STORAGE_BACKUP_WARNING_CHECKED]) return false;
|
|
308
|
+
processState[STORAGE_BACKUP_WARNING_CHECKED] = true;
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
|
|
256
312
|
let testBackstopStorageDir: string | null = null;
|
|
257
313
|
let testBackstopWarned = false;
|
|
258
314
|
|
|
@@ -40,6 +40,18 @@ function createArgs(model?: { providerID: string; modelID: string }) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
describe("promptSyncWithModelSuggestionRetry", () => {
|
|
43
|
+
test("synchronous prompt completion retains await semantics with cancellation", async () => {
|
|
44
|
+
const prompt = mock(() => undefined);
|
|
45
|
+
const abort = mock(async () => ({}));
|
|
46
|
+
|
|
47
|
+
await promptSyncWithModelSuggestionRetry(createClient(prompt, abort), createArgs(), {
|
|
48
|
+
signal: new AbortController().signal,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(prompt).toHaveBeenCalledTimes(1);
|
|
52
|
+
expect(abort).not.toHaveBeenCalled();
|
|
53
|
+
});
|
|
54
|
+
|
|
43
55
|
test("primary succeeds, no fallback iteration", async () => {
|
|
44
56
|
const prompt = mock(async () => ({}));
|
|
45
57
|
const client = createClient(prompt);
|
|
@@ -799,3 +811,25 @@ test("DeepSeek unsupported-model 400 preserves provider status and message rathe
|
|
|
799
811
|
expect((caught as Error).message).not.toContain("no output");
|
|
800
812
|
expect(getPromptFailureDetail(caught)).toMatchObject({ failureClass: "provider_error" });
|
|
801
813
|
});
|
|
814
|
+
|
|
815
|
+
test("timeout rejects an uncooperative carrier and aborts its child", async () => {
|
|
816
|
+
const abort = mock(async () => ({}));
|
|
817
|
+
const client = createClient(
|
|
818
|
+
mock(() => new Promise(() => {})),
|
|
819
|
+
abort,
|
|
820
|
+
);
|
|
821
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
822
|
+
try {
|
|
823
|
+
await expect(
|
|
824
|
+
Promise.race([
|
|
825
|
+
promptSyncWithModelSuggestionRetry(client, createArgs(), { timeoutMs: 10 }),
|
|
826
|
+
new Promise((_, reject) => {
|
|
827
|
+
timer = setTimeout(() => reject(new Error("carrier remained stuck")), 200);
|
|
828
|
+
}),
|
|
829
|
+
]),
|
|
830
|
+
).rejects.toThrow("prompt timed out after 10ms");
|
|
831
|
+
expect(abort).toHaveBeenCalledTimes(1);
|
|
832
|
+
} finally {
|
|
833
|
+
clearTimeout(timer);
|
|
834
|
+
}
|
|
835
|
+
});
|
|
@@ -248,6 +248,23 @@ function externalAbortMessage(signal: AbortSignal): string {
|
|
|
248
248
|
return `prompt aborted by external signal${reason instanceof Error && /^lease_(?:lost|expired):/.test(reason.message) ? `: ${reason.message}` : ""}`;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/** A carrier may ignore cancellation; stop waiting without trusting it to reject. */
|
|
252
|
+
export function raceWithSignal<T>(work: Promise<T>, signal?: AbortSignal): Promise<T> {
|
|
253
|
+
// Match await's handling of synchronous completion as well as promises.
|
|
254
|
+
work = Promise.resolve(work);
|
|
255
|
+
if (!signal) return work;
|
|
256
|
+
return new Promise<T>((resolve, reject) => {
|
|
257
|
+
const abort = () => reject(new Error(externalAbortMessage(signal)));
|
|
258
|
+
if (signal.aborted) {
|
|
259
|
+
work.catch(() => {});
|
|
260
|
+
abort();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
264
|
+
work.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
251
268
|
async function promptWithTimeout(
|
|
252
269
|
client: Client,
|
|
253
270
|
args: PromptArgs,
|
|
@@ -273,10 +290,13 @@ async function promptWithTimeout(
|
|
|
273
290
|
|
|
274
291
|
try {
|
|
275
292
|
const request = { ...args, signal: controller.signal };
|
|
276
|
-
if (transport) await transport(request);
|
|
293
|
+
if (transport) await raceWithSignal(transport(request), controller.signal);
|
|
277
294
|
else {
|
|
278
295
|
if (!client) throw new Error("Hidden completion transport is unavailable");
|
|
279
|
-
await
|
|
296
|
+
await raceWithSignal<unknown>(
|
|
297
|
+
client.session.prompt(request as Parameters<typeof client.session.prompt>[0]),
|
|
298
|
+
controller.signal,
|
|
299
|
+
);
|
|
280
300
|
}
|
|
281
301
|
} catch (error) {
|
|
282
302
|
if (signal?.aborted) {
|
|
@@ -676,7 +696,7 @@ async function attemptAndValidate<TOutput, TValidated>(
|
|
|
676
696
|
|
|
677
697
|
let output: TOutput;
|
|
678
698
|
try {
|
|
679
|
-
output = await options.fetchOutput(args, attempt);
|
|
699
|
+
output = await raceWithSignal(options.fetchOutput(args, attempt), options.signal);
|
|
680
700
|
} catch (error) {
|
|
681
701
|
throw {
|
|
682
702
|
error,
|
|
@@ -202,7 +202,7 @@ describe("dreamer budget on an async child", () => {
|
|
|
202
202
|
},
|
|
203
203
|
readChildTokenBudget: (id: string) => {
|
|
204
204
|
expect(id).toBe("ses-child");
|
|
205
|
-
|
|
205
|
+
if (!ready) return undefined;
|
|
206
206
|
return { spent: 58, finalizeFired: true };
|
|
207
207
|
},
|
|
208
208
|
};
|
|
@@ -130,9 +130,22 @@ export function createPromptAsyncTransport(
|
|
|
130
130
|
if (!readChildTokenBudget || !session?.prompt) return undefined;
|
|
131
131
|
return Object.assign(
|
|
132
132
|
async (request: PromptArgs) => {
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
133
|
+
const previous = readChildTokenBudget(childSessionId);
|
|
134
|
+
const remaining =
|
|
135
|
+
options.tokenBudget === undefined
|
|
136
|
+
? undefined
|
|
137
|
+
: options.tokenBudget - (previous?.spent ?? 0);
|
|
138
|
+
if ((remaining !== undefined && remaining <= 0) || previous?.finalizeFired)
|
|
139
|
+
throw new DreamTokenBudgetExceeded(childSessionId, previous?.spent ?? 0);
|
|
140
|
+
try {
|
|
141
|
+
await session.prompt?.({
|
|
142
|
+
...request,
|
|
143
|
+
...(remaining === undefined ? {} : { tokenBudget: remaining }),
|
|
144
|
+
});
|
|
145
|
+
} finally {
|
|
146
|
+
const state = readChildTokenBudget(childSessionId);
|
|
147
|
+
if (state) options.onBudgetUpdate?.({ ...state, sessionId: childSessionId });
|
|
148
|
+
}
|
|
136
149
|
},
|
|
137
150
|
{ childSessionId },
|
|
138
151
|
);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ensureMemoryEmbeddings2
|
|
3
|
-
} from "./index-4ccdr7yw.js";
|
|
4
|
-
import"./index-se1w3v2m.js";
|
|
5
|
-
import"./index-9159kk15.js";
|
|
6
|
-
import"./index-4dhv7mqz.js";
|
|
7
|
-
import"./index-qt1qqasc.js";
|
|
8
|
-
import"./index-bmwfzz28.js";
|
|
9
|
-
import"./index-kvw6xew3.js";
|
|
10
|
-
import"./index-0jz47061.js";
|
|
11
|
-
import"./index-mp2kghkv.js";
|
|
12
|
-
import"./index-w28y7d0z.js";
|
|
13
|
-
import"./index-150zz6fh.js";
|
|
14
|
-
import"./index-gjvjh960.js";
|
|
15
|
-
import"./index-wafzvyhg.js";
|
|
16
|
-
import"./index-mvvephtj.js";
|
|
17
|
-
import"./index-0sahzkwr.js";
|
|
18
|
-
import"./index-pavzsdc6.js";
|
|
19
|
-
export {
|
|
20
|
-
ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
|
|
21
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isRecompFailure2,
|
|
3
|
-
isRecompSkip2,
|
|
4
|
-
extractRecompReason2,
|
|
5
|
-
setRecompStarting2,
|
|
6
|
-
setRecompNote2,
|
|
7
|
-
setRecompTerminal2,
|
|
8
|
-
buildRecompDeps2,
|
|
9
|
-
runManagedRecomp2
|
|
10
|
-
} from "./index-g40wgxxt.js";
|
|
11
|
-
import"./index-z7avx6rw.js";
|
|
12
|
-
import"./index-s178h9z8.js";
|
|
13
|
-
import"./index-yhrrx7qa.js";
|
|
14
|
-
import"./index-0j6crjgh.js";
|
|
15
|
-
import"./index-sd3egckz.js";
|
|
16
|
-
import"./index-4ccdr7yw.js";
|
|
17
|
-
import"./index-n78avt2p.js";
|
|
18
|
-
import"./index-se1w3v2m.js";
|
|
19
|
-
import"./index-9159kk15.js";
|
|
20
|
-
import"./index-4dhv7mqz.js";
|
|
21
|
-
import"./index-jw4gbfkv.js";
|
|
22
|
-
import"./index-0abg88h2.js";
|
|
23
|
-
import"./index-qt1qqasc.js";
|
|
24
|
-
import"./index-x8a7jmkh.js";
|
|
25
|
-
import"./index-a4b0gbyg.js";
|
|
26
|
-
import"./index-bmwfzz28.js";
|
|
27
|
-
import"./index-kvw6xew3.js";
|
|
28
|
-
import"./index-xztdf9t7.js";
|
|
29
|
-
import"./index-a865mj02.js";
|
|
30
|
-
import"./index-fb3zxn06.js";
|
|
31
|
-
import"./index-fr0wbhdn.js";
|
|
32
|
-
import"./index-0jz47061.js";
|
|
33
|
-
import"./index-mp2kghkv.js";
|
|
34
|
-
import"./index-q28hsbpg.js";
|
|
35
|
-
import"./index-qr1mkc2y.js";
|
|
36
|
-
import"./index-f8cn4xqa.js";
|
|
37
|
-
import"./index-1zx87sdm.js";
|
|
38
|
-
import"./index-bzp9s8z2.js";
|
|
39
|
-
import"./index-angx1s0k.js";
|
|
40
|
-
import"./index-v0p37hm2.js";
|
|
41
|
-
import"./index-w28y7d0z.js";
|
|
42
|
-
import"./index-9jvab89d.js";
|
|
43
|
-
import"./index-g7jkrz0x.js";
|
|
44
|
-
import"./index-58e3y90n.js";
|
|
45
|
-
import"./index-150zz6fh.js";
|
|
46
|
-
import"./index-gjvjh960.js";
|
|
47
|
-
import"./index-wafzvyhg.js";
|
|
48
|
-
import"./index-mvvephtj.js";
|
|
49
|
-
import"./index-0sahzkwr.js";
|
|
50
|
-
import"./index-pavzsdc6.js";
|
|
51
|
-
export {
|
|
52
|
-
buildRecompDeps2 as buildRecompDeps,
|
|
53
|
-
extractRecompReason2 as extractRecompReason,
|
|
54
|
-
isRecompFailure2 as isRecompFailure,
|
|
55
|
-
isRecompSkip2 as isRecompSkip,
|
|
56
|
-
runManagedRecomp2 as runManagedRecomp,
|
|
57
|
-
setRecompNote2 as setRecompNote,
|
|
58
|
-
setRecompStarting2 as setRecompStarting,
|
|
59
|
-
setRecompTerminal2 as setRecompTerminal
|
|
60
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ensureMemoryEmbeddings2
|
|
3
|
-
} from "./server-rxcq4t50.js";
|
|
4
|
-
import"./server-sg68np13.js";
|
|
5
|
-
import"./server-ewqshbs8.js";
|
|
6
|
-
import"./server-4dhv7mqz.js";
|
|
7
|
-
import"./server-qt1qqasc.js";
|
|
8
|
-
import"./server-83d71zab.js";
|
|
9
|
-
import"./server-988cqjme.js";
|
|
10
|
-
import"./server-njnx39q2.js";
|
|
11
|
-
import"./server-63ha7f0f.js";
|
|
12
|
-
import"./server-jc8v585p.js";
|
|
13
|
-
import"./server-7dv9wt9r.js";
|
|
14
|
-
import"./server-s6jqh8bj.js";
|
|
15
|
-
import"./server-wafzvyhg.js";
|
|
16
|
-
import"./server-9e5r8y60.js";
|
|
17
|
-
import"./server-pavzsdc6.js";
|
|
18
|
-
export {
|
|
19
|
-
ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
|
|
20
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isRecompFailure2,
|
|
3
|
-
isRecompSkip2,
|
|
4
|
-
extractRecompReason2,
|
|
5
|
-
setRecompStarting2,
|
|
6
|
-
setRecompNote2,
|
|
7
|
-
setRecompTerminal2,
|
|
8
|
-
buildRecompDeps2,
|
|
9
|
-
runManagedRecomp2
|
|
10
|
-
} from "./server-7fvmt15t.js";
|
|
11
|
-
import"./server-npm52h2q.js";
|
|
12
|
-
import"./server-kn7skz9r.js";
|
|
13
|
-
import"./server-d3f4g62c.js";
|
|
14
|
-
import"./server-rxcq4t50.js";
|
|
15
|
-
import"./server-n78avt2p.js";
|
|
16
|
-
import"./server-sg68np13.js";
|
|
17
|
-
import"./server-ewqshbs8.js";
|
|
18
|
-
import"./server-4dhv7mqz.js";
|
|
19
|
-
import"./server-hn9fb3v0.js";
|
|
20
|
-
import"./server-h3wc20sv.js";
|
|
21
|
-
import"./server-qt1qqasc.js";
|
|
22
|
-
import"./server-ckrb5rm8.js";
|
|
23
|
-
import"./server-5x7kmyz8.js";
|
|
24
|
-
import"./server-nveratm5.js";
|
|
25
|
-
import"./server-x8a7jmkh.js";
|
|
26
|
-
import"./server-83d71zab.js";
|
|
27
|
-
import"./server-988cqjme.js";
|
|
28
|
-
import"./server-erfp0xb6.js";
|
|
29
|
-
import"./server-fb3zxn06.js";
|
|
30
|
-
import"./server-f27he3j1.js";
|
|
31
|
-
import"./server-fr0wbhdn.js";
|
|
32
|
-
import"./server-njnx39q2.js";
|
|
33
|
-
import"./server-63ha7f0f.js";
|
|
34
|
-
import"./server-cxsr0ng6.js";
|
|
35
|
-
import"./server-wkhfyzpg.js";
|
|
36
|
-
import"./server-kmapq3v0.js";
|
|
37
|
-
import"./server-1zx87sdm.js";
|
|
38
|
-
import"./server-d6t16r89.js";
|
|
39
|
-
import"./server-bx59ezg6.js";
|
|
40
|
-
import"./server-51779zs2.js";
|
|
41
|
-
import"./server-jc8v585p.js";
|
|
42
|
-
import"./server-xqf2d2mg.js";
|
|
43
|
-
import"./server-89fcbe37.js";
|
|
44
|
-
import"./server-2ra6pwf3.js";
|
|
45
|
-
import"./server-7dv9wt9r.js";
|
|
46
|
-
import"./server-s6jqh8bj.js";
|
|
47
|
-
import"./server-wafzvyhg.js";
|
|
48
|
-
import"./server-9e5r8y60.js";
|
|
49
|
-
import"./server-pavzsdc6.js";
|
|
50
|
-
export {
|
|
51
|
-
buildRecompDeps2 as buildRecompDeps,
|
|
52
|
-
extractRecompReason2 as extractRecompReason,
|
|
53
|
-
isRecompFailure2 as isRecompFailure,
|
|
54
|
-
isRecompSkip2 as isRecompSkip,
|
|
55
|
-
runManagedRecomp2 as runManagedRecomp,
|
|
56
|
-
setRecompNote2 as setRecompNote,
|
|
57
|
-
setRecompStarting2 as setRecompStarting,
|
|
58
|
-
setRecompTerminal2 as setRecompTerminal
|
|
59
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runManagedWrapup2
|
|
3
|
-
} from "./index-q3qck7j2.js";
|
|
4
|
-
import"./index-g40wgxxt.js";
|
|
5
|
-
import"./index-z7avx6rw.js";
|
|
6
|
-
import"./index-s178h9z8.js";
|
|
7
|
-
import"./index-yhrrx7qa.js";
|
|
8
|
-
import"./index-0j6crjgh.js";
|
|
9
|
-
import"./index-sd3egckz.js";
|
|
10
|
-
import"./index-4ccdr7yw.js";
|
|
11
|
-
import"./index-n78avt2p.js";
|
|
12
|
-
import"./index-se1w3v2m.js";
|
|
13
|
-
import"./index-9159kk15.js";
|
|
14
|
-
import"./index-4dhv7mqz.js";
|
|
15
|
-
import"./index-jw4gbfkv.js";
|
|
16
|
-
import"./index-0abg88h2.js";
|
|
17
|
-
import"./index-qt1qqasc.js";
|
|
18
|
-
import"./index-x8a7jmkh.js";
|
|
19
|
-
import"./index-a4b0gbyg.js";
|
|
20
|
-
import"./index-bmwfzz28.js";
|
|
21
|
-
import"./index-kvw6xew3.js";
|
|
22
|
-
import"./index-xztdf9t7.js";
|
|
23
|
-
import"./index-a865mj02.js";
|
|
24
|
-
import"./index-fb3zxn06.js";
|
|
25
|
-
import"./index-fr0wbhdn.js";
|
|
26
|
-
import"./index-0jz47061.js";
|
|
27
|
-
import"./index-mp2kghkv.js";
|
|
28
|
-
import"./index-q28hsbpg.js";
|
|
29
|
-
import"./index-qr1mkc2y.js";
|
|
30
|
-
import"./index-f8cn4xqa.js";
|
|
31
|
-
import"./index-1zx87sdm.js";
|
|
32
|
-
import"./index-bzp9s8z2.js";
|
|
33
|
-
import"./index-angx1s0k.js";
|
|
34
|
-
import"./index-v0p37hm2.js";
|
|
35
|
-
import"./index-w28y7d0z.js";
|
|
36
|
-
import"./index-9jvab89d.js";
|
|
37
|
-
import"./index-g7jkrz0x.js";
|
|
38
|
-
import"./index-58e3y90n.js";
|
|
39
|
-
import"./index-150zz6fh.js";
|
|
40
|
-
import"./index-gjvjh960.js";
|
|
41
|
-
import"./index-wafzvyhg.js";
|
|
42
|
-
import"./index-mvvephtj.js";
|
|
43
|
-
import"./index-0sahzkwr.js";
|
|
44
|
-
import"./index-pavzsdc6.js";
|
|
45
|
-
export {
|
|
46
|
-
runManagedWrapup2 as runManagedWrapup
|
|
47
|
-
};
|
|
File without changes
|
|
File without changes
|