@cortexkit/opencode-magic-context 0.49.10 → 0.49.12
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/{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/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-w3crzrar.js → conflict-warning-hook-f4x5wed7.js} +8 -8
- package/dist/{context-ey3ap3cc.js → context-dam8p201.js} +306 -119
- package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-5306b1jt.js} +3 -3
- package/dist/embedding-backfill-qbfcbp87.js +21 -0
- package/dist/embedding-worker-process.js +2 -2
- package/dist/embedding-worker.js +6 -6
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +12 -1
- package/dist/features/magic-context/compartment-chunk-embedding.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-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/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/memory-enabled.d.ts +5 -0
- package/dist/features/magic-context/memory-enabled.d.ts.map +1 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search-pool-fixture.d.ts +39 -0
- package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -0
- package/dist/features/magic-context/search.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/features/magic-context/transform-decision-log.d.ts +57 -2
- package/dist/features/magic-context/transform-decision-log.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/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/historian-prompt-fit.d.ts +14 -2
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -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/producer-window-guard.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-db.d.ts +5 -0
- package/dist/hooks/magic-context/read-session-db.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/render-options.d.ts +21 -0
- package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +4 -0
- package/dist/hooks/magic-context/tag-messages.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 +5 -7
- 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-21919gcq.js → index-05n6ykca.js} +4 -4
- package/dist/{index-q76br5zn.js → index-1d289pq2.js} +26 -21
- package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
- package/dist/{index-x57ep4fp.js → index-1wwh38fk.js} +323 -121
- package/dist/{index-pgy3h49n.js → index-2pgxcncf.js} +4 -4
- package/dist/{index-ffa8x2as.js → index-6sytd5w3.js} +18 -13
- package/dist/{index-16vwdyy5.js → index-6sz25c3s.js} +3 -3
- package/dist/{index-4hb8nt93.js → index-7h8a1xpc.js} +3 -3
- package/dist/{index-rg1cezmj.js → index-7zd5asz9.js} +140 -17
- package/dist/{index-jw4gbfkv.js → index-8ketfacn.js} +2 -2
- package/dist/{index-nenz4gpb.js → index-95s8xaj1.js} +6 -5
- package/dist/{index-bmwfzz28.js → index-9vqb5p1s.js} +4 -4
- package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
- package/dist/{index-wpwpn7nj.js → index-b16gpywn.js} +9 -9
- package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
- package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
- 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-a43xq1pg.js → index-fx90bvjd.js} +5 -5
- package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
- package/dist/{index-7bjgyaj1.js → index-gf0psee3.js} +243 -135
- package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
- 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-6k86es2p.js → index-qtbdx42g.js} +54 -25
- package/dist/{index-a865mj02.js → index-tdn0zkw4.js} +4 -4
- package/dist/{index-0x9cn9w1.js → index-wqs4q74r.js} +8 -8
- package/dist/{index-swgpe402.js → index-x2xjyq8f.js} +11 -11
- package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
- package/dist/{index-3403gbzj.js → index-yx5kgp2x.js} +288 -127
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +97 -76
- package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
- package/dist/{message-index-bounded-fskdyc81.js → message-index-bounded-nq6rp8xa.js} +16 -16
- package/dist/{message-index-6r1x9cqh.js → message-index-df7swgy1.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-vy7sv9jt.js → project-embedding-registry-q0ysjyzc.js} +11 -11
- package/dist/raw-ordinal-warmup-worker.js +12 -7
- package/dist/{read-session-chunk-zgpvs423.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-77xc8wpe.js → recomp-orchestrator-a0mvby4e.js} +29 -29
- package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
- package/dist/{search-72fkjwk2.js → search-fm002702.js} +23 -23
- package/dist/{send-session-notification-q8ngbap3.js → send-session-notification-y2wg3fkh.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/prompt-surface-runtime.d.ts +5 -0
- package/dist/shared/prompt-surface-runtime.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-r8d406j0.js → transform-postprocess-phase-s84rdf32.js} +29 -29
- package/dist/v2/auto-search-worker.js +4 -4
- 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-z2yagwy4.js → context-x60fa16g.js} +758 -286
- package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-z25jw3py.js} +3 -3
- package/dist/v2/embedding-backfill-mbjyza2a.js +20 -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 +1 -0
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +3 -1
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +6 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/transform-decision-binding.d.ts +15 -0
- package/dist/v2/hooks/transform-decision-binding.d.ts.map +1 -0
- package/dist/v2/hooks/transform-features.d.ts +40 -0
- package/dist/v2/hooks/transform-features.d.ts.map +1 -0
- package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
- package/dist/v2/{message-index-9ezq6wze.js → message-index-5nayhm1r.js} +15 -15
- package/dist/v2/{message-index-bounded-rqc603f2.js → message-index-bounded-pgv1ndpb.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-ja23aygk.js → project-embedding-registry-jbmjc0p4.js} +12 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
- package/dist/v2/{read-session-chunk-7f87tg2q.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-8w3449eb.js +59 -0
- package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
- package/dist/v2/{search-2td1b1wy.js → search-mhmxgq0e.js} +22 -22
- package/dist/v2/{send-session-notification-6n7chhyp.js → send-session-notification-jevgj9fe.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-2hxypdx5.js → server-25tg45b4.js} +17 -12
- package/dist/v2/{server-44ryn9rb.js → server-2x42esxd.js} +3 -3
- package/dist/v2/{server-4qr18rfg.js → server-37ngj8qw.js} +10 -51
- package/dist/v2/{server-4zwx20yg.js → server-4c10404h.js} +3 -3
- package/dist/v2/{server-23znwjqk.js → server-50mkkhy1.js} +14 -11
- package/dist/v2/{server-c9w52qss.js → server-5gvkzzrf.js} +290 -76
- package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
- package/dist/v2/{server-ak7w74j9.js → server-83ygfha2.js} +4 -4
- package/dist/v2/{server-4rs8sm06.js → server-9ewkzqgd.js} +5 -5
- package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
- package/dist/v2/{server-zrwaj29a.js → server-d8tj10db.js} +25 -20
- package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
- package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
- package/dist/v2/{server-hn9fb3v0.js → server-f7jfmrrz.js} +2 -2
- package/dist/v2/{server-f27he3j1.js → server-fa75w6gp.js} +4 -4
- 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-nveratm5.js → server-kn9n2qgd.js} +1 -1
- package/dist/v2/{server-gc8x2xdb.js → server-m97brnat.js} +9 -9
- package/dist/v2/{server-z0rjemg1.js → server-nmrm2rjy.js} +8 -8
- 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-988cqjme.js → server-rrqpvwqd.js} +2 -2
- package/dist/v2/{server-4easnf78.js → server-sz8jj92q.js} +150 -18
- package/dist/v2/{server-7e087rvk.js → server-th4y11y7.js} +16 -16
- package/dist/v2/{server-9a6bwc12.js → server-vknbt0gq.js} +255 -135
- package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
- 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 +13 -6
- package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
- package/dist/v2/store-reader.d.ts +4 -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-wg8dmmm9.js → wrapup-orchestrator-r82y780v.js} +30 -29
- package/dist/wrapup-orchestrator-vmt6z3q5.js +47 -0
- package/package.json +1 -1
- 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/chunk-vector-writer-guard.test.ts +72 -0
- package/src/shared/data-path.test.ts +35 -1
- package/src/shared/data-path.ts +57 -1
- package/src/shared/prompt-surface-runtime.test.ts +15 -0
- package/src/shared/prompt-surface-runtime.ts +12 -0
- package/dist/embedding-backfill-3h2m5n0q.js +0 -21
- package/dist/v2/embedding-backfill-vr7wdtrf.js +0 -20
- package/dist/v2/recomp-orchestrator-s5tdpsbs.js +0 -59
- package/dist/wrapup-orchestrator-b1z99yg5.js +0 -47
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMagicContextStorageDir,
|
|
3
3
|
log2
|
|
4
|
-
} from "./server-
|
|
4
|
+
} from "./server-f2xf5gcb.js";
|
|
5
5
|
import {
|
|
6
6
|
inRootAsyncContext2
|
|
7
7
|
} from "./server-wafzvyhg.js";
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
// src/features/magic-context/memory/project-identity.ts
|
|
16
16
|
import { execFileSync } from "node:child_process";
|
|
17
17
|
import { createHash as createHash2 } from "node:crypto";
|
|
18
|
-
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
18
|
+
import { existsSync, realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
19
19
|
import { homedir } from "node:os";
|
|
20
|
-
import
|
|
20
|
+
import path3 from "node:path";
|
|
21
21
|
|
|
22
22
|
// src/features/magic-context/memory/project-identity-cache.ts
|
|
23
23
|
import { createHash } from "node:crypto";
|
|
@@ -42,6 +42,162 @@ function readRememberedGitIdentity(directory, storageDir) {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// src/features/magic-context/memory/unborn-head.ts
|
|
46
|
+
import { readFileSync as readFileSync2, realpathSync, statSync } from "node:fs";
|
|
47
|
+
import path2 from "node:path";
|
|
48
|
+
var GIT_LOCATION_ENV_VARS = [
|
|
49
|
+
"GIT_DIR",
|
|
50
|
+
"GIT_COMMON_DIR",
|
|
51
|
+
"GIT_WORK_TREE",
|
|
52
|
+
"GIT_CEILING_DIRECTORIES"
|
|
53
|
+
];
|
|
54
|
+
function errorCode(error) {
|
|
55
|
+
if (error === null || typeof error !== "object" || !("code" in error))
|
|
56
|
+
return;
|
|
57
|
+
const code = error.code;
|
|
58
|
+
return typeof code === "string" ? code : undefined;
|
|
59
|
+
}
|
|
60
|
+
function readText(file) {
|
|
61
|
+
try {
|
|
62
|
+
return { ok: true, text: readFileSync2(file, "utf8") };
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return { ok: false, missing: errorCode(error) === "ENOENT" };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function entryKind(entry) {
|
|
68
|
+
try {
|
|
69
|
+
const stat = statSync(entry);
|
|
70
|
+
if (stat.isFile())
|
|
71
|
+
return "file";
|
|
72
|
+
if (stat.isDirectory())
|
|
73
|
+
return "directory";
|
|
74
|
+
return "other";
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return errorCode(error) === "ENOENT" ? "missing" : "error";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function stripLineEnding(text) {
|
|
80
|
+
return text.replace(/\r?\n$/u, "");
|
|
81
|
+
}
|
|
82
|
+
function resolveMetadataPath(baseDirectory, value) {
|
|
83
|
+
return path2.resolve(baseDirectory, value);
|
|
84
|
+
}
|
|
85
|
+
function isPlainBranchName(name) {
|
|
86
|
+
if (name.length === 0 || name.endsWith("/") || name.endsWith("."))
|
|
87
|
+
return false;
|
|
88
|
+
if (name.includes("..") || name.includes("//") || name.includes("@{"))
|
|
89
|
+
return false;
|
|
90
|
+
for (const character of name) {
|
|
91
|
+
const code = character.charCodeAt(0);
|
|
92
|
+
if (code <= 32 || code === 127 || "~^:?*[\\".includes(character))
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return name.split("/").every((component) => !component.startsWith(".") && !component.endsWith(".lock"));
|
|
96
|
+
}
|
|
97
|
+
function findGitDirectory(start) {
|
|
98
|
+
let current = start;
|
|
99
|
+
while (true) {
|
|
100
|
+
const dotGit = path2.join(current, ".git");
|
|
101
|
+
const kind = entryKind(dotGit);
|
|
102
|
+
if (kind === "directory")
|
|
103
|
+
return dotGit;
|
|
104
|
+
if (kind === "file") {
|
|
105
|
+
const read = readText(dotGit);
|
|
106
|
+
if (!read.ok)
|
|
107
|
+
return;
|
|
108
|
+
const match = /^gitdir: (.+)$/u.exec(stripLineEnding(read.text));
|
|
109
|
+
if (!match?.[1] || match[1].includes(`
|
|
110
|
+
`))
|
|
111
|
+
return;
|
|
112
|
+
return resolveMetadataPath(current, match[1]);
|
|
113
|
+
}
|
|
114
|
+
if (kind !== "missing")
|
|
115
|
+
return;
|
|
116
|
+
const parent = path2.dirname(current);
|
|
117
|
+
if (parent === current)
|
|
118
|
+
return;
|
|
119
|
+
current = parent;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function packedRefsList(text, ref) {
|
|
123
|
+
for (const rawLine of text.split(`
|
|
124
|
+
`)) {
|
|
125
|
+
const line = rawLine.replace(/\r$/u, "");
|
|
126
|
+
if (line === "" || line.startsWith("#") || line.startsWith("^"))
|
|
127
|
+
continue;
|
|
128
|
+
const match = /^[0-9a-f]{40,64} (\S+)$/u.exec(line);
|
|
129
|
+
if (!match)
|
|
130
|
+
return;
|
|
131
|
+
if (match[1] === ref)
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
function isUnbornHeadInLayout(directory) {
|
|
137
|
+
const gitDirectory = findGitDirectory(directory);
|
|
138
|
+
if (gitDirectory === undefined)
|
|
139
|
+
return false;
|
|
140
|
+
let commonDirectory = gitDirectory;
|
|
141
|
+
const commondir = readText(path2.join(gitDirectory, "commondir"));
|
|
142
|
+
if (commondir.ok) {
|
|
143
|
+
const value = stripLineEnding(commondir.text);
|
|
144
|
+
if (value === "" || value.includes(`
|
|
145
|
+
`))
|
|
146
|
+
return false;
|
|
147
|
+
commonDirectory = resolveMetadataPath(gitDirectory, value);
|
|
148
|
+
} else if (!commondir.missing) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (entryKind(path2.join(gitDirectory, "HEAD")) !== "file")
|
|
152
|
+
return false;
|
|
153
|
+
if (entryKind(path2.join(commonDirectory, "objects")) !== "directory")
|
|
154
|
+
return false;
|
|
155
|
+
if (entryKind(path2.join(commonDirectory, "refs")) !== "directory")
|
|
156
|
+
return false;
|
|
157
|
+
if (entryKind(path2.join(commonDirectory, "reftable")) !== "missing")
|
|
158
|
+
return false;
|
|
159
|
+
const config = readText(path2.join(commonDirectory, "config"));
|
|
160
|
+
if (config.ok) {
|
|
161
|
+
if (/refstorage/iu.test(config.text))
|
|
162
|
+
return false;
|
|
163
|
+
} else if (!config.missing) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
const head = readText(path2.join(gitDirectory, "HEAD"));
|
|
167
|
+
if (!head.ok)
|
|
168
|
+
return false;
|
|
169
|
+
const headMatch = /^ref: (refs\/heads\/(.+))$/u.exec(head.text.replace(/\s+$/u, ""));
|
|
170
|
+
const ref = headMatch?.[1];
|
|
171
|
+
const branch = headMatch?.[2];
|
|
172
|
+
if (!ref || branch === undefined || !isPlainBranchName(branch))
|
|
173
|
+
return false;
|
|
174
|
+
const refSegments = ref.split("/");
|
|
175
|
+
for (const base of new Set([commonDirectory, gitDirectory])) {
|
|
176
|
+
if (entryKind(path2.join(base, ...refSegments)) !== "missing")
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const packed = readText(path2.join(commonDirectory, "packed-refs"));
|
|
180
|
+
if (packed.ok) {
|
|
181
|
+
if (packedRefsList(packed.text, ref) !== false)
|
|
182
|
+
return false;
|
|
183
|
+
} else if (!packed.missing) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
function isUnbornHeadOnDisk(directory, env = process.env) {
|
|
189
|
+
if (GIT_LOCATION_ENV_VARS.some((name) => env[name] !== undefined && env[name] !== "")) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
let realDirectory;
|
|
193
|
+
try {
|
|
194
|
+
realDirectory = realpathSync.native(path2.resolve(directory));
|
|
195
|
+
} catch {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return isUnbornHeadInLayout(realDirectory);
|
|
199
|
+
}
|
|
200
|
+
|
|
45
201
|
// src/features/magic-context/memory/project-identity.ts
|
|
46
202
|
var GIT_TIMEOUT_MS = 5000;
|
|
47
203
|
var TRANSIENT_FAILURE_COOLDOWN_MS = 5 * 60 * 1000;
|
|
@@ -77,6 +233,7 @@ function shouldSkipHomeProjectMemory(directory) {
|
|
|
77
233
|
}
|
|
78
234
|
}
|
|
79
235
|
var execFileSyncForIdentity = execFileSync;
|
|
236
|
+
var gitTimeoutMs = GIT_TIMEOUT_MS;
|
|
80
237
|
var userHomeDirectoryForIdentity = () => homedir();
|
|
81
238
|
var nowMs = () => Date.now();
|
|
82
239
|
var filesystemProbeObserverForTests;
|
|
@@ -131,7 +288,7 @@ function getErrorStderr(error) {
|
|
|
131
288
|
return "";
|
|
132
289
|
}
|
|
133
290
|
function directoryFallback(directory) {
|
|
134
|
-
const canonical =
|
|
291
|
+
const canonical = path3.resolve(directory);
|
|
135
292
|
const hash = createHash2("md5").update(canonical, "utf8").digest("hex").slice(0, 12);
|
|
136
293
|
return `dir:${hash}`;
|
|
137
294
|
}
|
|
@@ -140,7 +297,7 @@ function rememberedIdentityOrDirectoryFallback(canonical) {
|
|
|
140
297
|
}
|
|
141
298
|
function assertDirectoryUsable(canonicalDirectory, rawDirectory) {
|
|
142
299
|
try {
|
|
143
|
-
const stat =
|
|
300
|
+
const stat = statSync2(canonicalDirectory);
|
|
144
301
|
if (!stat.isDirectory()) {
|
|
145
302
|
throw new ProjectIdentityError("unknown", rawDirectory, `Project path is not a directory: ${canonicalDirectory}`);
|
|
146
303
|
}
|
|
@@ -166,7 +323,7 @@ function hasUnbornHead(directory) {
|
|
|
166
323
|
encoding: "utf8",
|
|
167
324
|
env: { ...process.env, LC_ALL: "C", LANG: "C" },
|
|
168
325
|
stdio: ["ignore", "pipe", "pipe"],
|
|
169
|
-
timeout:
|
|
326
|
+
timeout: gitTimeoutMs,
|
|
170
327
|
windowsHide: true
|
|
171
328
|
};
|
|
172
329
|
try {
|
|
@@ -183,7 +340,7 @@ function hasUnbornHead(directory) {
|
|
|
183
340
|
}
|
|
184
341
|
function classifyGitError(error, rawDirectory) {
|
|
185
342
|
if (isGitTimeoutError(error)) {
|
|
186
|
-
return new ProjectIdentityError("git_timeout", rawDirectory, `git rev-list timed out after ${
|
|
343
|
+
return new ProjectIdentityError("git_timeout", rawDirectory, `git rev-list timed out after ${gitTimeoutMs}ms`, asError(error));
|
|
187
344
|
}
|
|
188
345
|
const code = getErrorCode(error);
|
|
189
346
|
if (code === "ENOENT") {
|
|
@@ -203,7 +360,7 @@ function classifyGitError(error, rawDirectory) {
|
|
|
203
360
|
}
|
|
204
361
|
function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectPermission, options = {}) {
|
|
205
362
|
assertProjectAllowed(directory, allowHomeProject);
|
|
206
|
-
const canonical =
|
|
363
|
+
const canonical = path3.resolve(directory);
|
|
207
364
|
const cached = options.cache === false ? undefined : identityCache.get(canonical);
|
|
208
365
|
if (cached !== undefined) {
|
|
209
366
|
return cached;
|
|
@@ -212,6 +369,9 @@ function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectP
|
|
|
212
369
|
if (!hasGitDir(canonical)) {
|
|
213
370
|
throw new ProjectIdentityError("not_git_repo", directory, "Directory has no git metadata; caller may use directory fallback");
|
|
214
371
|
}
|
|
372
|
+
if (isUnbornHeadOnDisk(canonical)) {
|
|
373
|
+
throw new ProjectIdentityError("no_commits", directory, "Git repository has no commits yet");
|
|
374
|
+
}
|
|
215
375
|
let output;
|
|
216
376
|
try {
|
|
217
377
|
output = execFileSyncForIdentity("git", ["rev-list", "--max-parents=0", "HEAD"], {
|
|
@@ -219,7 +379,7 @@ function resolveProjectIdentityStrict(directory, allowHomeProject = homeProjectP
|
|
|
219
379
|
encoding: "utf8",
|
|
220
380
|
env: { ...process.env, LC_ALL: "C", LANG: "C" },
|
|
221
381
|
stdio: ["ignore", "pipe", "pipe"],
|
|
222
|
-
timeout:
|
|
382
|
+
timeout: gitTimeoutMs,
|
|
223
383
|
windowsHide: true
|
|
224
384
|
});
|
|
225
385
|
} catch (error) {
|
|
@@ -272,9 +432,9 @@ function nearestLastKnownGitIdentity(canonical) {
|
|
|
272
432
|
const cached = lastKnownGitIdentity(current);
|
|
273
433
|
if (cached !== undefined)
|
|
274
434
|
return { identity: cached, source: current };
|
|
275
|
-
if (existsSync(
|
|
435
|
+
if (existsSync(path3.join(current, ".git")))
|
|
276
436
|
break;
|
|
277
|
-
const parent =
|
|
437
|
+
const parent = path3.dirname(current);
|
|
278
438
|
if (parent === current)
|
|
279
439
|
break;
|
|
280
440
|
current = parent;
|
|
@@ -285,7 +445,7 @@ function nearestLastKnownGitIdentity(canonical) {
|
|
|
285
445
|
if (exactOrAncestor)
|
|
286
446
|
return exactOrAncestor;
|
|
287
447
|
try {
|
|
288
|
-
const realCanonical =
|
|
448
|
+
const realCanonical = realpathSync2.native(canonical);
|
|
289
449
|
if (realCanonical !== canonical)
|
|
290
450
|
return walk(realCanonical);
|
|
291
451
|
} catch {}
|
|
@@ -313,7 +473,7 @@ function recordDubiousOwnershipFallback(canonical) {
|
|
|
313
473
|
log2(`[magic-context] ${formatDubiousOwnershipWarning(canonical)}`);
|
|
314
474
|
}
|
|
315
475
|
function takeDubiousOwnershipProjectIdentityWarning(directory) {
|
|
316
|
-
const canonical =
|
|
476
|
+
const canonical = path3.resolve(directory);
|
|
317
477
|
if (!dubiousOwnershipFallbackDirectories.has(canonical))
|
|
318
478
|
return null;
|
|
319
479
|
if (dubiousOwnershipWarnedDirectories.has(canonical))
|
|
@@ -324,7 +484,7 @@ function takeDubiousOwnershipProjectIdentityWarning(directory) {
|
|
|
324
484
|
function canonicalUserHomeDirectory() {
|
|
325
485
|
const homeDirectory = userHomeDirectoryForIdentity();
|
|
326
486
|
try {
|
|
327
|
-
return
|
|
487
|
+
return realpathSync2.native(homeDirectory);
|
|
328
488
|
} catch {
|
|
329
489
|
return homeDirectory;
|
|
330
490
|
}
|
|
@@ -333,20 +493,20 @@ function isUserHomeDirectory(directory) {
|
|
|
333
493
|
if (projectDirectoryKey(directory) === projectDirectoryKey(userHomeDirectoryForIdentity()))
|
|
334
494
|
return true;
|
|
335
495
|
try {
|
|
336
|
-
return projectDirectoryKey(
|
|
496
|
+
return projectDirectoryKey(realpathSync2.native(path3.resolve(directory))) === projectDirectoryKey(canonicalUserHomeDirectory());
|
|
337
497
|
} catch {
|
|
338
498
|
return false;
|
|
339
499
|
}
|
|
340
500
|
}
|
|
341
501
|
function assertProjectAllowed(directory, allowHomeProject) {
|
|
342
|
-
const canonical =
|
|
502
|
+
const canonical = path3.resolve(directory);
|
|
343
503
|
if (!allowHomeProject && (isUserHomeDirectory(directory) || isUserHomeDirectory(gitRootDirectory(canonical) ?? canonical))) {
|
|
344
504
|
throw new ProjectIdentityError("home_project_disabled", directory, "Home project memory is disabled; set allow_home_project to opt in");
|
|
345
505
|
}
|
|
346
506
|
}
|
|
347
507
|
function resolveProjectIdentity(directory, allowHomeProject = homeProjectPermission) {
|
|
348
508
|
assertProjectAllowed(directory, allowHomeProject);
|
|
349
|
-
const canonical =
|
|
509
|
+
const canonical = path3.resolve(directory);
|
|
350
510
|
const cachedFallback = directoryFallbackCache.get(canonical);
|
|
351
511
|
if (cachedFallback !== undefined) {
|
|
352
512
|
if (!hasGitDir(canonical)) {
|
|
@@ -394,7 +554,7 @@ function resolveProjectIdentityOrFallback(directory, allowHomeProject = homeProj
|
|
|
394
554
|
try {
|
|
395
555
|
return resolveProjectIdentity(directory, allowHomeProject);
|
|
396
556
|
} catch (error) {
|
|
397
|
-
const canonical =
|
|
557
|
+
const canonical = path3.resolve(directory);
|
|
398
558
|
if (hasGitDir(canonical) || error instanceof ProjectIdentityError && error.errorClass === "home_project_disabled")
|
|
399
559
|
throw error;
|
|
400
560
|
const fallback = rememberedIdentityOrDirectoryFallback(canonical);
|
|
@@ -408,7 +568,7 @@ function hasGitDir(canonical) {
|
|
|
408
568
|
return true;
|
|
409
569
|
}
|
|
410
570
|
try {
|
|
411
|
-
const realCanonical =
|
|
571
|
+
const realCanonical = realpathSync2.native(canonical);
|
|
412
572
|
return realCanonical !== canonical && hasGitDirInAncestorChain(realCanonical);
|
|
413
573
|
} catch {
|
|
414
574
|
return false;
|
|
@@ -417,14 +577,14 @@ function hasGitDir(canonical) {
|
|
|
417
577
|
function gitRootInAncestorChain(startDirectory) {
|
|
418
578
|
let current = startDirectory;
|
|
419
579
|
while (true) {
|
|
420
|
-
if (existsSync(
|
|
580
|
+
if (existsSync(path3.join(current, ".git"))) {
|
|
421
581
|
try {
|
|
422
|
-
return
|
|
582
|
+
return realpathSync2.native(current);
|
|
423
583
|
} catch {
|
|
424
|
-
return
|
|
584
|
+
return path3.resolve(current);
|
|
425
585
|
}
|
|
426
586
|
}
|
|
427
|
-
const parent =
|
|
587
|
+
const parent = path3.dirname(current);
|
|
428
588
|
if (parent === current) {
|
|
429
589
|
return null;
|
|
430
590
|
}
|
|
@@ -439,21 +599,21 @@ function gitRootDirectory(canonical) {
|
|
|
439
599
|
if (direct)
|
|
440
600
|
return direct;
|
|
441
601
|
try {
|
|
442
|
-
const realCanonical =
|
|
602
|
+
const realCanonical = realpathSync2.native(canonical);
|
|
443
603
|
return realCanonical === canonical ? null : gitRootInAncestorChain(realCanonical);
|
|
444
604
|
} catch {
|
|
445
605
|
return null;
|
|
446
606
|
}
|
|
447
607
|
}
|
|
448
608
|
function directoryHasGitMetadata(directory) {
|
|
449
|
-
return gitRootDirectory(
|
|
609
|
+
return gitRootDirectory(path3.resolve(directory)) !== null;
|
|
450
610
|
}
|
|
451
611
|
function describeUnresolvedProjectIdentity(directory) {
|
|
452
|
-
const resolvedDirectory =
|
|
612
|
+
const resolvedDirectory = path3.resolve(directory);
|
|
453
613
|
const canonicalHome = canonicalUserHomeDirectory();
|
|
454
614
|
const canonicalDirectory = (() => {
|
|
455
615
|
try {
|
|
456
|
-
return
|
|
616
|
+
return realpathSync2.native(resolvedDirectory);
|
|
457
617
|
} catch {
|
|
458
618
|
return resolvedDirectory;
|
|
459
619
|
}
|
|
@@ -469,7 +629,7 @@ function isUsableProjectIdentity(identity) {
|
|
|
469
629
|
return typeof identity === "string" && identity.trim().length > 0;
|
|
470
630
|
}
|
|
471
631
|
function resolveProjectIdentityForSession(directory, allowHomeProject = homeProjectPermission) {
|
|
472
|
-
const resolvedDirectory =
|
|
632
|
+
const resolvedDirectory = path3.resolve(directory);
|
|
473
633
|
const cacheKey = `${allowHomeProject ? "1" : "0"}\x00${resolvedDirectory}`;
|
|
474
634
|
const cached = sessionIdentityCache.get(cacheKey);
|
|
475
635
|
if (cached && (cached.revalidateAt === null || nowMs() < cached.revalidateAt) && !(cached.identity?.startsWith("dir:") && hasGitDir(resolvedDirectory))) {
|
|
@@ -480,7 +640,7 @@ function resolveProjectIdentityForSession(directory, allowHomeProject = homeProj
|
|
|
480
640
|
const canonicalDirectory = (() => {
|
|
481
641
|
try {
|
|
482
642
|
filesystemProbeObserverForTests?.();
|
|
483
|
-
return
|
|
643
|
+
return realpathSync2.native(resolvedDirectory);
|
|
484
644
|
} catch {
|
|
485
645
|
return resolvedDirectory;
|
|
486
646
|
}
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
TAG_SELECT_COLUMNS2,
|
|
24
24
|
getCandidateToolOwners2,
|
|
25
25
|
pickNearestPriorOwner2
|
|
26
|
-
} from "./server-
|
|
26
|
+
} from "./server-bxpwy6fy.js";
|
|
27
27
|
import {
|
|
28
28
|
OMO_INTERNAL_INITIATOR_MARKER,
|
|
29
29
|
isSystemDirective,
|
|
@@ -40,18 +40,18 @@ import {
|
|
|
40
40
|
formatBlock,
|
|
41
41
|
compactTextForSummary,
|
|
42
42
|
mergeCommitHashes
|
|
43
|
-
} from "./server-
|
|
43
|
+
} from "./server-0ppsweh6.js";
|
|
44
44
|
import {
|
|
45
45
|
sessionLog2
|
|
46
|
-
} from "./server-
|
|
46
|
+
} from "./server-f2xf5gcb.js";
|
|
47
47
|
import {
|
|
48
48
|
stableStringify
|
|
49
|
-
} from "./server-
|
|
49
|
+
} from "./server-pwv4ezb0.js";
|
|
50
50
|
import {
|
|
51
51
|
renderToolTemplate,
|
|
52
52
|
resolveModelConfigValue,
|
|
53
53
|
deriveDefaultProtectedTokens
|
|
54
|
-
} from "./server-
|
|
54
|
+
} from "./server-th4y11y7.js";
|
|
55
55
|
import {
|
|
56
56
|
readRawSessionMessagesFromDb2,
|
|
57
57
|
readRawSessionMessagePageFromDb2,
|
|
@@ -68,25 +68,25 @@ import {
|
|
|
68
68
|
readRawSeedTailFromDb2,
|
|
69
69
|
readRawSessionBoundaryEndpointsFromDb2,
|
|
70
70
|
prewarmRawSessionOrdinalsForDb
|
|
71
|
-
} from "./server-
|
|
71
|
+
} from "./server-prg55b7k.js";
|
|
72
72
|
import {
|
|
73
73
|
openCodeDbExists,
|
|
74
74
|
withReadOnlySessionDb,
|
|
75
75
|
getRawSessionMessageCountFromDb,
|
|
76
76
|
getMessageTimesFromOpenCodeDb
|
|
77
|
-
} from "./server-
|
|
77
|
+
} from "./server-d8tj10db.js";
|
|
78
78
|
import {
|
|
79
79
|
getToolDefinitionMeasurementSignature,
|
|
80
80
|
getLargestMeasuredToolDefinitionTokens,
|
|
81
81
|
getMeasuredToolDefinitionTokens
|
|
82
|
-
} from "./server-
|
|
82
|
+
} from "./server-zs8d0s3b.js";
|
|
83
83
|
import {
|
|
84
84
|
canonicalModelIdentity,
|
|
85
85
|
piModelRefToCanonical
|
|
86
86
|
} from "./server-avwt563y.js";
|
|
87
87
|
import {
|
|
88
88
|
logSlowWriteTransaction
|
|
89
|
-
} from "./server-
|
|
89
|
+
} from "./server-6pmqg9m4.js";
|
|
90
90
|
|
|
91
91
|
// src/features/magic-context/overflow-detection.ts
|
|
92
92
|
var OVERFLOW_PATTERNS = [
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
removeSystemReminders,
|
|
6
6
|
hasMeaningfulUserText2,
|
|
7
7
|
extractTexts2
|
|
8
|
-
} from "./server-
|
|
8
|
+
} from "./server-0ppsweh6.js";
|
|
9
9
|
import {
|
|
10
10
|
getMagicContextStorageDir
|
|
11
|
-
} from "./server-
|
|
11
|
+
} from "./server-f2xf5gcb.js";
|
|
12
12
|
import {
|
|
13
13
|
withSqliteBackgroundWriter2,
|
|
14
14
|
withoutSqliteTransformPass2
|
|
@@ -20,23 +20,23 @@ import {
|
|
|
20
20
|
tagRevisionKey,
|
|
21
21
|
tagIdentityRevisionKey,
|
|
22
22
|
deleteTagIdentityRevisions
|
|
23
|
-
} from "./server-
|
|
23
|
+
} from "./server-pwv4ezb0.js";
|
|
24
24
|
import {
|
|
25
25
|
cleanUserText2
|
|
26
|
-
} from "./server-
|
|
26
|
+
} from "./server-m97brnat.js";
|
|
27
27
|
import {
|
|
28
28
|
recordMessageFtsRowid,
|
|
29
29
|
recordIndexedMessageTime,
|
|
30
30
|
messageFtsOrdinalRangeIsMapped,
|
|
31
31
|
deleteUnmappedMessageFtsRows
|
|
32
|
-
} from "./server-
|
|
32
|
+
} from "./server-yrvqaswb.js";
|
|
33
33
|
import {
|
|
34
34
|
isPidAlive,
|
|
35
35
|
readProcessStartTime
|
|
36
|
-
} from "./server-
|
|
36
|
+
} from "./server-da07v4xp.js";
|
|
37
37
|
import {
|
|
38
38
|
deleteChunkEmbedBackoffForSession
|
|
39
|
-
} from "./server-
|
|
39
|
+
} from "./server-vknbt0gq.js";
|
|
40
40
|
import {
|
|
41
41
|
ensurePrivateStorageDirectorySync,
|
|
42
42
|
writeStorageFileSync,
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
} from "./server-8ajstryz.js";
|
|
50
50
|
import {
|
|
51
51
|
logSlowWriteTransaction
|
|
52
|
-
} from "./server-
|
|
52
|
+
} from "./server-6pmqg9m4.js";
|
|
53
53
|
|
|
54
54
|
// src/shared/bounded-session-map.ts
|
|
55
55
|
class BoundedSessionMap {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./server-51779zs2.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
|
-
} from "./server-
|
|
6
|
+
} from "./server-f2xf5gcb.js";
|
|
7
7
|
import {
|
|
8
8
|
inRootAsyncContext2,
|
|
9
9
|
getSqliteDatabasePath2,
|
|
@@ -175,7 +175,7 @@ function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWaterma
|
|
|
175
175
|
const skip = anchor === after && after ? 0 : ordinal - (floor?.ordinal ?? 0);
|
|
176
176
|
if (skip > ORDINAL_LOOKUP_LIMIT) {
|
|
177
177
|
prewarmRawSessionOrdinalsForDb(db, sessionId);
|
|
178
|
-
throw new
|
|
178
|
+
throw new RawOrdinalsNotReady2;
|
|
179
179
|
}
|
|
180
180
|
const rawLimit = skip + pageSize + ORDINAL_LOOKUP_LIMIT;
|
|
181
181
|
const rows = db.prepare(`SELECT id, data, time_created, time_updated, ${EXCLUDED_ROW_SQL} AS excluded
|
|
@@ -188,7 +188,7 @@ function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWaterma
|
|
|
188
188
|
const eligible = rows.filter((row) => row.excluded !== 1);
|
|
189
189
|
if (eligible.length <= skip && rows.length === rawLimit) {
|
|
190
190
|
prewarmRawSessionOrdinalsForDb(db, sessionId);
|
|
191
|
-
throw new
|
|
191
|
+
throw new RawOrdinalsNotReady2;
|
|
192
192
|
}
|
|
193
193
|
return eligible.slice(skip, skip + pageSize).filter(isRawMessageRow).map((row, index) => ({
|
|
194
194
|
...row,
|
|
@@ -276,11 +276,13 @@ function countRawSessionMessageOrdinalsFromDb2(db, sessionId) {
|
|
|
276
276
|
)`).get(sessionId);
|
|
277
277
|
return typeof row?.count === "number" ? row.count : 0;
|
|
278
278
|
}
|
|
279
|
+
var exactOrdinalScansOnThisThread = 0;
|
|
279
280
|
function readRawSessionMessageIdOrdinalsForRangeFromDb2(db, sessionId, fromOrdinal, toOrdinal) {
|
|
280
281
|
const from = Math.max(1, Math.floor(fromOrdinal));
|
|
281
282
|
const to = Math.floor(toOrdinal);
|
|
282
283
|
if (to < from)
|
|
283
284
|
return new Map;
|
|
285
|
+
exactOrdinalScansOnThisThread += 1;
|
|
284
286
|
const rows = db.prepare(`
|
|
285
287
|
SELECT id, data FROM message WHERE session_id = ?
|
|
286
288
|
AND CASE WHEN json_valid(data) THEN NOT (
|
|
@@ -296,6 +298,12 @@ function readRawSessionMessageIdOrdinalsForRangeFromDb2(db, sessionId, fromOrdin
|
|
|
296
298
|
}
|
|
297
299
|
return result;
|
|
298
300
|
}
|
|
301
|
+
function readRawSessionMessageIdsAtOrdinalsFromDb2(db, sessionId, ordinals) {
|
|
302
|
+
return withReadSnapshot(db, () => ordinals.map((ordinal) => [
|
|
303
|
+
ordinal,
|
|
304
|
+
readRawSessionMessageIdOrdinalsForRangeFromDb2(db, sessionId, ordinal, ordinal).keys().next().value ?? null
|
|
305
|
+
]));
|
|
306
|
+
}
|
|
299
307
|
function readRawSessionMessageOrdinalPageFromDb2(db, sessionId, after, limit) {
|
|
300
308
|
const pageSize = Math.max(1, Math.floor(limit));
|
|
301
309
|
const rows = (after ? db.prepare(`SELECT id, data, time_created
|
|
@@ -604,7 +612,7 @@ function extendOrdinalCheckpoints(db, sessionId, scan, limit) {
|
|
|
604
612
|
return true;
|
|
605
613
|
}
|
|
606
614
|
|
|
607
|
-
class
|
|
615
|
+
class RawOrdinalsNotReady2 extends Error {
|
|
608
616
|
constructor() {
|
|
609
617
|
super("canonical ordinals are warming off-thread; retry after preparation");
|
|
610
618
|
}
|
|
@@ -653,7 +661,7 @@ function boundedOrdinalPrefix(db, sessionId, through) {
|
|
|
653
661
|
ordinalJsonRowsRead += rows.length;
|
|
654
662
|
if (rows.length > ORDINAL_LOOKUP_LIMIT) {
|
|
655
663
|
prewarmRawSessionOrdinalsForDb(db, sessionId);
|
|
656
|
-
throw new
|
|
664
|
+
throw new RawOrdinalsNotReady2;
|
|
657
665
|
}
|
|
658
666
|
return (floor?.ordinal ?? 0) + rows.reduce((sum, row) => sum + (row.excluded === 1 ? 0 : 1), 0);
|
|
659
667
|
}
|
|
@@ -1193,6 +1201,8 @@ function runSessionWarmupWorker(input, options) {
|
|
|
1193
1201
|
finish({ inserted: reply.inserted, measurements: reply.measurements });
|
|
1194
1202
|
else if (reply.kind === "orphan-sweep")
|
|
1195
1203
|
finish({ orphanSweep: reply.result });
|
|
1204
|
+
else if (reply.kind === "exact-ordinal-ids")
|
|
1205
|
+
finish({ exactOrdinalIds: reply.ids });
|
|
1196
1206
|
else
|
|
1197
1207
|
finish({ failure: "worker-error", detail: reply.error });
|
|
1198
1208
|
});
|
|
@@ -1257,4 +1267,4 @@ function recordFailure(key, sessionId, failure, detail) {
|
|
|
1257
1267
|
log2(`[magic-context] WARN canonical ordinal warm-up failed for ${sessionId} (${failure}: ${detail}); counts remain bounded and callers must defer or retry`);
|
|
1258
1268
|
}
|
|
1259
1269
|
|
|
1260
|
-
export { isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|
|
1270
|
+
export { isStrictGapHealingMessage2, isRawCompactionSummaryInfo2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, extractInMemoryMessageViews2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2, runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveDreamerTaskModel2
|
|
3
3
|
} from "./server-8cd2j99z.js";
|
|
4
|
+
import {
|
|
5
|
+
isDreamerRunnable
|
|
6
|
+
} from "./server-0s95v3en.js";
|
|
4
7
|
|
|
5
8
|
// src/features/magic-context/dreamer/task-registry.ts
|
|
6
9
|
var CANONICAL_DREAM_TASKS = [
|
|
@@ -106,6 +109,25 @@ var MEMORY_DOMAIN_TASKS = [
|
|
|
106
109
|
"refresh-primers"
|
|
107
110
|
];
|
|
108
111
|
var MEMORY_DOMAIN_SET = new Set(MEMORY_DOMAIN_TASKS);
|
|
112
|
+
var PROJECT_MEMORY_DREAM_TASKS = [
|
|
113
|
+
"map-memories",
|
|
114
|
+
"verify",
|
|
115
|
+
"verify-broad",
|
|
116
|
+
"curate",
|
|
117
|
+
"compress-cues",
|
|
118
|
+
"classify-memories",
|
|
119
|
+
"retrospective",
|
|
120
|
+
"promote-primers",
|
|
121
|
+
"refresh-primers"
|
|
122
|
+
];
|
|
123
|
+
var PROJECT_MEMORY_DREAM_TASK_SET = new Set(PROJECT_MEMORY_DREAM_TASKS);
|
|
124
|
+
function dreamTaskAllowedBySettings(task, settings) {
|
|
125
|
+
if (PROJECT_MEMORY_DREAM_TASK_SET.has(task))
|
|
126
|
+
return settings.projectMemoryEnabled !== false;
|
|
127
|
+
if (task === "evaluate-smart-notes")
|
|
128
|
+
return settings.smartNotesEnabled !== false;
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
109
131
|
function leaseKindFor(task) {
|
|
110
132
|
if (MEMORY_DOMAIN_SET.has(task))
|
|
111
133
|
return "memory";
|
|
@@ -161,6 +183,12 @@ function userMemoryCollectionEnabled2(dreamer) {
|
|
|
161
183
|
const schedule = dreamer?.tasks?.["review-user-memories"]?.schedule;
|
|
162
184
|
return typeof schedule === "string" && schedule.trim() !== "";
|
|
163
185
|
}
|
|
186
|
+
function userObservationCollectionEnabled2(dreamer) {
|
|
187
|
+
return userObservationsRequested2(dreamer) && userMemoryCollectionEnabled2(dreamer);
|
|
188
|
+
}
|
|
189
|
+
function userObservationsRequested2(dreamer) {
|
|
190
|
+
return isDreamerRunnable({ dreamer });
|
|
191
|
+
}
|
|
164
192
|
function userMemoryPromotionThreshold2(dreamer) {
|
|
165
193
|
return dreamer?.tasks?.["review-user-memories"]?.promotion_threshold ?? 3;
|
|
166
194
|
}
|
|
@@ -180,4 +208,4 @@ function summarizeDreamSchedule2(dreamer, smartNotesEnabled = true) {
|
|
|
180
208
|
return enabled.map((t) => `${t} ${dreamer?.tasks[t]?.schedule}`).join(", ");
|
|
181
209
|
}
|
|
182
210
|
|
|
183
|
-
export { CANONICAL_DREAM_TASKS, DREAM_TASK_CAPABILITIES, toolLoopDreamTasks, formatUnsupportedDreamTasks, formatDreamTaskBacklogs, processedDreamTaskItems, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs2, userMemoryCollectionEnabled2, userMemoryPromotionThreshold2, dreamTaskScheduled2, enabledDreamTasks2, summarizeDreamSchedule2 };
|
|
211
|
+
export { CANONICAL_DREAM_TASKS, DREAM_TASK_CAPABILITIES, toolLoopDreamTasks, formatUnsupportedDreamTasks, formatDreamTaskBacklogs, processedDreamTaskItems, PROJECT_MEMORY_DREAM_TASKS, dreamTaskAllowedBySettings, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs2, userMemoryCollectionEnabled2, userObservationCollectionEnabled2, userObservationsRequested2, userMemoryPromotionThreshold2, dreamTaskScheduled2, enabledDreamTasks2, summarizeDreamSchedule2 };
|