@cortexkit/opencode-magic-context 0.49.104 → 0.49.106
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 +3 -3
- package/dist/chunk-embedding-write-worker.js +8 -5
- package/dist/{context-7hbmnpe8.js → context-ywdwfzg5.js} +116 -136
- package/dist/{embedding-backfill-aratv25b.js → embedding-backfill-kqwx0vhj.js} +4 -4
- package/dist/features/magic-context/chunk-embedding-write-worker-install-failure.fixture.d.ts +2 -0
- package/dist/features/magic-context/chunk-embedding-write-worker-install-failure.fixture.d.ts.map +1 -0
- package/dist/features/magic-context/chunk-scope-repair-revision.d.ts +16 -1
- package/dist/features/magic-context/chunk-scope-repair-revision.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify-checkout.d.ts +2 -0
- package/dist/features/magic-context/dreamer/verify-checkout.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-worker-observer.fixture.d.ts +26 -0
- package/dist/features/magic-context/memory/embedding-worker-observer.fixture.d.ts.map +1 -0
- package/dist/features/magic-context/message-fts-rowid-map-startup-worker-test-support.d.ts +2 -0
- package/dist/features/magic-context/message-fts-rowid-map-startup-worker-test-support.d.ts.map +1 -0
- 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/search-pool-fixture.d.ts +15 -0
- package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.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 +4 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +7 -2
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-persist.d.ts +1 -0
- package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +7 -0
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +3 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-8gzmeyae.js → index-20e7w8v8.js} +3 -3
- package/dist/{index-a9wn0d9h.js → index-3p08zzfq.js} +3 -3
- package/dist/{index-fd3hkyk1.js → index-42fsf88t.js} +1 -1
- package/dist/{index-tvh3y650.js → index-5phmpcme.js} +5 -5
- package/dist/{index-8yj4vd7k.js → index-92p5yfpp.js} +1 -1
- package/dist/{index-mwjvjn0p.js → index-a3t1ck7g.js} +6 -6
- package/dist/{index-4ba3zp54.js → index-as8bg7eh.js} +365 -113
- package/dist/{index-8eke8yh2.js → index-cxh5g5bt.js} +1 -1
- package/dist/{index-vegw385y.js → index-cy5fn70d.js} +89 -1
- package/dist/{index-4dywj733.js → index-dzb1yc9w.js} +1 -1
- package/dist/{index-3rp2b482.js → index-e4szqthq.js} +299 -37
- package/dist/{index-jjxpmypb.js → index-e7awy9eb.js} +1 -1
- package/dist/{index-ke0mkz7g.js → index-g1h1efr0.js} +1 -1
- package/dist/{index-f455a0g3.js → index-k37h4yrb.js} +5 -3
- package/dist/{index-3nxhxeeg.js → index-sfgz2h7y.js} +4 -4
- package/dist/{index-sqvkh5d0.js → index-xa8jgw6w.js} +20 -7
- package/dist/{index-hyvxmz3e.js → index-y1875y4h.js} +1 -1
- package/dist/{index-4v50y0jr.js → index-ydevzvfs.js} +1 -1
- package/dist/{index-4536jdzj.js → index-ze1t940p.js} +68 -25
- package/dist/{index-ab86c21b.js → index-zj0ra8vs.js} +1 -1
- package/dist/index.js +50 -59
- package/dist/migration-worker.js +3 -3
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-1n4cexsv.js → project-embedding-registry-0z0nd73p.js} +3 -3
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{recomp-orchestrator-16rs8aty.js → recomp-orchestrator-7sf94073.js} +12 -12
- package/dist/{render-f32trg2t.js → render-93qzv0vk.js} +6 -6
- package/dist/{search-v9ywqb4f.js → search-7e1rcqb7.js} +9 -9
- package/dist/{search-archive-yh6xtvrx.js → search-archive-dv483a5c.js} +2 -2
- package/dist/shared/sqlite-busy-test-support.d.ts +21 -0
- package/dist/shared/sqlite-busy-test-support.d.ts.map +1 -0
- package/dist/shared/sqlite-write-locker-test-support.d.ts +12 -0
- package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -1
- package/dist/{store-wpx314rk.js → store-4eeezg83.js} +2 -2
- package/dist/{store-reader-c5fwa9qx.js → store-reader-g8w2wp88.js} +1 -1
- package/dist/{transform-postprocess-phase-yef4mxk3.js → transform-postprocess-phase-vd9rckyd.js} +13 -13
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +8 -5
- package/dist/v2/{context-mk2h2ven.js → context-6g9j3tq9.js} +248 -160
- package/dist/v2/{embedding-backfill-kyn5sv0f.js → embedding-backfill-e44pv5db.js} +4 -4
- package/dist/v2/event-subscription.fixture.d.ts +9 -0
- package/dist/v2/event-subscription.fixture.d.ts.map +1 -0
- package/dist/v2/hidden-model-activity.d.ts +13 -0
- package/dist/v2/hidden-model-activity.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +1 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +2 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/event-subscription-worker.d.ts +11 -0
- package/dist/v2/hooks/event-subscription-worker.d.ts.map +1 -0
- package/dist/v2/hooks/types.d.ts +1 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/hooks/update-check.d.ts +1 -0
- package/dist/v2/hooks/update-check.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-j1sxtefe.js → message-index-bounded-nwqfb1p5.js} +3 -3
- package/dist/v2/migration-worker.js +3 -3
- package/dist/v2/{project-embedding-registry-1jv2rxhb.js → project-embedding-registry-rhzjnypp.js} +3 -3
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-p6z3kmdj.js → read-session-chunk-brqatg83.js} +2 -2
- package/dist/v2/{recomp-orchestrator-5t2csd46.js → recomp-orchestrator-j84xfa80.js} +14 -14
- package/dist/v2/{render-jpj43axy.js → render-tzs5r2pg.js} +10 -10
- package/dist/v2/{search-archive-wbhxp0p1.js → search-archive-31dpm5zs.js} +5 -5
- package/dist/v2/{search-w9m2fd5c.js → search-sffewrs4.js} +12 -12
- package/dist/v2/{server-47ajg9xc.js → server-16115spd.js} +1 -1
- package/dist/v2/server-28jqb7s0.js +6 -0
- package/dist/v2/{server-qg8jyfxa.js → server-5xx10mqe.js} +1 -1
- package/dist/v2/{server-t45hgcsg.js → server-7jw608jk.js} +2 -2
- package/dist/v2/{server-3mb205v9.js → server-83rjf4df.js} +1 -1
- package/dist/v2/{server-xpy46ddq.js → server-af25mmb6.js} +3 -3
- package/dist/v2/{server-ga6y57vh.js → server-c32505fr.js} +6 -4
- package/dist/v2/{server-qdpd8h27.js → server-fn6k1ack.js} +1 -1
- package/dist/v2/{server-8m5wk6aq.js → server-ggs7sxp6.js} +5 -5
- package/dist/v2/{server-zsbc0n4v.js → server-ghb2q1z9.js} +1 -1
- package/dist/v2/{server-af51b1zg.js → server-hqcdvs2n.js} +11 -11
- package/dist/v2/{server-9ms9b75c.js → server-j00jprwm.js} +4 -6
- package/dist/v2/{server-8f92sd2r.js → server-jqk6g663.js} +72 -27
- package/dist/v2/{server-b01a7dhj.js → server-kk2kbzq3.js} +1 -1
- package/dist/v2/{server-mc5t7k8v.js → server-ma0qhqg9.js} +1 -1
- package/dist/v2/{server-x22jtpna.js → server-n3bfqd0j.js} +4 -2
- package/dist/v2/{server-wmpgvvc4.js → server-pjvqyg6g.js} +365 -113
- package/dist/v2/{server-jrs4gny6.js → server-qtajgx1e.js} +89 -1
- package/dist/v2/server-t104h957.js +177 -0
- package/dist/v2/{server-j09jx1n9.js → server-v2r04xds.js} +1 -1
- package/dist/v2/{server-3gnpqjez.js → server-v60f6dk3.js} +26 -11
- package/dist/v2/{server-7c5p0bh1.js → server-z77hman6.js} +1 -1
- package/dist/v2/server.js +31 -40
- package/dist/v2/{storage-tags-s7nvvyg8.js → storage-tags-ee72g2zv.js} +1 -1
- package/dist/v2/{store-mba47sxn.js → store-9rsrj5pt.js} +2 -2
- package/dist/v2/{store-reader-w7w8vfsy.js → store-reader-tb0f9621.js} +1 -1
- package/dist/v2/store-reader.d.ts +1 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/tui/index.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-5njmg3a3.js → v2-archive-reader-7vrma2dm.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-ykgx8hw8.js → wrapup-orchestrator-m1ymvccg.js} +14 -14
- package/dist/{v2-archive-reader-y38khjax.js → v2-archive-reader-aqck4zea.js} +1 -1
- package/dist/{wrapup-orchestrator-a9tshrp4.js → wrapup-orchestrator-k7azmnym.js} +13 -13
- package/package.json +1 -1
- package/src/config/migrate-config-location.test.ts +41 -29
- package/src/shared/model-suggestion-retry.test.ts +137 -90
- package/src/shared/off-thread-migration-clock.test.ts +19 -9
- package/src/shared/prompt-async-transport.test.ts +125 -42
- package/src/shared/rpc-async-probes.test.ts +56 -36
- package/src/shared/rpc-client.test.ts +51 -18
- package/src/shared/sqlite-acquisition-routing.test.ts +79 -22
- package/src/shared/sqlite-busy-budget-review.test.ts +129 -111
- package/src/shared/sqlite-busy-test-support.ts +154 -0
- package/src/shared/sqlite-foreground-wait.test.ts +213 -156
- package/src/shared/sqlite-pass-scope.test.ts +142 -105
- package/src/shared/sqlite-turn-deadline.test.ts +149 -124
- package/src/shared/sqlite-write-locker-test-support.ts +44 -12
- package/src/shared/stable-json-linear.test.ts +29 -11
- package/src/shared/startup-maintenance-policy.test.ts +72 -2
- package/src/shared/storage-busy.test.ts +45 -18
- package/src/shared/storage-file-mutex-review.test.ts +65 -51
- package/src/shared/tui-preferences.test.ts +15 -5
- package/src/shared/worker-shutdown.test.ts +26 -20
- package/src/tui/data/notification-socket.test.ts +220 -108
- package/src/v2/tui/index.ts +5 -1
- package/src/v2/tui/status-dialog-fallback.test.ts +23 -1
- package/dist/v2/server-84w6rvvf.js +0 -14
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
inRootAsyncContext2
|
|
10
10
|
} from "./index-gzy5w8ya.js";
|
|
11
|
+
import {
|
|
12
|
+
isKnownAutocommit
|
|
13
|
+
} from "./index-8ajstryz.js";
|
|
11
14
|
import {
|
|
12
15
|
projectDirectoryKey
|
|
13
16
|
} from "./index-knvkbfvh.js";
|
|
@@ -737,4 +740,89 @@ function setBootQuietPeriodForTests(startAtMs) {
|
|
|
737
740
|
bootQuietUntilMs = startAtMs === null ? 0 : startAtMs + BOOT_QUIET_MS;
|
|
738
741
|
}
|
|
739
742
|
|
|
740
|
-
|
|
743
|
+
// src/features/magic-context/chunk-scope-repair-revision.ts
|
|
744
|
+
var revisions = new WeakMap;
|
|
745
|
+
var installedAtSchema = new WeakMap;
|
|
746
|
+
var warned = new WeakSet;
|
|
747
|
+
var BINDING_KEY = "chunk_scope_repair_binding_revision";
|
|
748
|
+
var ROW_KEY = "chunk_scope_repair_row_revision";
|
|
749
|
+
var missingBinding = `NOT EXISTS (SELECT 1 FROM session_projects WHERE session_id = NEW.session_id
|
|
750
|
+
AND harness = NEW.harness AND project_path = NEW.project_path)`;
|
|
751
|
+
var bump = (key, where = "") => `INSERT INTO schema_migrations_meta(key, value) SELECT '${key}', lower(hex(randomblob(16))) ${where}
|
|
752
|
+
ON CONFLICT(key) DO UPDATE SET value = excluded.value;`;
|
|
753
|
+
function installChunkScopeRepairTriggers(db) {
|
|
754
|
+
if (installedAtSchema.has(db))
|
|
755
|
+
return;
|
|
756
|
+
const { schema_version } = db.prepare("PRAGMA main.schema_version").get();
|
|
757
|
+
const bumpBinding = bump(BINDING_KEY);
|
|
758
|
+
db.exec(`CREATE TEMP TRIGGER IF NOT EXISTS mc_chunk_scope_binding_bi
|
|
759
|
+
BEFORE INSERT ON main.session_projects WHEN ${missingBinding}
|
|
760
|
+
BEGIN ${bumpBinding} END;
|
|
761
|
+
CREATE TEMP TRIGGER IF NOT EXISTS mc_chunk_scope_binding_au
|
|
762
|
+
AFTER UPDATE ON main.session_projects
|
|
763
|
+
WHEN OLD.session_id IS NOT NEW.session_id OR OLD.harness IS NOT NEW.harness
|
|
764
|
+
OR OLD.project_path IS NOT NEW.project_path
|
|
765
|
+
BEGIN ${bumpBinding} END;
|
|
766
|
+
CREATE TEMP TRIGGER IF NOT EXISTS mc_chunk_scope_rows_bi
|
|
767
|
+
BEFORE INSERT ON main.compartment_chunk_embeddings
|
|
768
|
+
BEGIN
|
|
769
|
+
${bump(ROW_KEY)}
|
|
770
|
+
${bump(BINDING_KEY, `WHERE ${missingBinding}`)}
|
|
771
|
+
END;
|
|
772
|
+
CREATE TEMP TRIGGER IF NOT EXISTS mc_chunk_scope_rows_au
|
|
773
|
+
AFTER UPDATE OF project_path, session_id, harness ON main.compartment_chunk_embeddings
|
|
774
|
+
WHEN ${missingBinding}
|
|
775
|
+
BEGIN ${bumpBinding} END;`);
|
|
776
|
+
installedAtSchema.set(db, schema_version);
|
|
777
|
+
}
|
|
778
|
+
function tryInstallChunkScopeRepairTriggers(db) {
|
|
779
|
+
try {
|
|
780
|
+
installChunkScopeRepairTriggers(db);
|
|
781
|
+
} catch (error) {
|
|
782
|
+
forgetAndWarn(db, error);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function forgetAndWarn(db, error) {
|
|
786
|
+
revisions.delete(db);
|
|
787
|
+
installedAtSchema.delete(db);
|
|
788
|
+
if (warned.has(db))
|
|
789
|
+
return;
|
|
790
|
+
warned.add(db);
|
|
791
|
+
log2("[magic-context] chunk scope repair revision unreadable; checking without the memo", error);
|
|
792
|
+
}
|
|
793
|
+
function readChunkScopeRepairRevision(db) {
|
|
794
|
+
if (!isKnownAutocommit(db))
|
|
795
|
+
return null;
|
|
796
|
+
try {
|
|
797
|
+
return readRevision(db);
|
|
798
|
+
} catch (error) {
|
|
799
|
+
forgetAndWarn(db, error);
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function readRevision(db) {
|
|
804
|
+
let statement = revisions.get(db);
|
|
805
|
+
if (!statement) {
|
|
806
|
+
if (!db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'schema_migrations_meta'").get())
|
|
807
|
+
return null;
|
|
808
|
+
installChunkScopeRepairTriggers(db);
|
|
809
|
+
statement = db.prepare(`SELECT
|
|
810
|
+
(SELECT value FROM schema_migrations_meta WHERE key = '${BINDING_KEY}') AS binding,
|
|
811
|
+
(SELECT value FROM schema_migrations_meta WHERE key = '${ROW_KEY}') AS rows,
|
|
812
|
+
(SELECT data_version FROM pragma_data_version) AS external,
|
|
813
|
+
(SELECT schema_version FROM pragma_schema_version) AS schemaVersion`);
|
|
814
|
+
revisions.set(db, statement);
|
|
815
|
+
}
|
|
816
|
+
const row = statement.get();
|
|
817
|
+
if (!row || !Number.isInteger(row.schemaVersion) || !Number.isInteger(row.external)) {
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
if (installedAtSchema.get(db) !== row.schemaVersion) {
|
|
821
|
+
revisions.delete(db);
|
|
822
|
+
installedAtSchema.delete(db);
|
|
823
|
+
return readRevision(db);
|
|
824
|
+
}
|
|
825
|
+
return row;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export { pruneMissingProjectIdentities, setHomeProjectPermission, shouldSkipHomeProjectMemory, ProjectIdentityError, directoryFallback, resolveProjectIdentityStrict, takeDubiousOwnershipProjectIdentityWarning, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, describeUnresolvedProjectIdentity, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, bootQuietRemainingMs, scheduleAfterBootQuiet, setBootQuietPeriodForTests, tryInstallChunkScopeRepairTriggers, readChunkScopeRepairRevision };
|
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
storedPathBelongsToIdentity,
|
|
88
88
|
beginBootQuietPeriod,
|
|
89
89
|
scheduleAfterBootQuiet
|
|
90
|
-
} from "./index-
|
|
90
|
+
} from "./index-cy5fn70d.js";
|
|
91
91
|
import {
|
|
92
92
|
recordSessionProjectIdentity,
|
|
93
93
|
hasRecordedSessionProjectIdentity,
|
|
@@ -97,7 +97,7 @@ import {
|
|
|
97
97
|
markGitSweepSuccessAndRelease,
|
|
98
98
|
parkGitSweepNonIndexable,
|
|
99
99
|
releaseGitSweepLease
|
|
100
|
-
} from "./index-
|
|
100
|
+
} from "./index-42fsf88t.js";
|
|
101
101
|
import {
|
|
102
102
|
CTX_MEMORY_TOOL_NAME,
|
|
103
103
|
CTX_MEMORY_LIST_TOOL_NAME,
|
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
snapRangeToCompartments,
|
|
220
220
|
getActiveCompartmentRun,
|
|
221
221
|
startCompartmentAgent
|
|
222
|
-
} from "./index-
|
|
222
|
+
} from "./index-xa8jgw6w.js";
|
|
223
223
|
import {
|
|
224
224
|
formatWindowDerivationLine,
|
|
225
225
|
getSdkWindowGeometry,
|
|
@@ -475,7 +475,7 @@ import {
|
|
|
475
475
|
runSqliteOptimize,
|
|
476
476
|
openDatabase,
|
|
477
477
|
openCurrentDatabase
|
|
478
|
-
} from "./index-
|
|
478
|
+
} from "./index-k37h4yrb.js";
|
|
479
479
|
import {
|
|
480
480
|
unescapeXml,
|
|
481
481
|
resolveWorkspaceShareCategories,
|
|
@@ -484,7 +484,7 @@ import {
|
|
|
484
484
|
resolveStoredPathWorkspaceIdentity,
|
|
485
485
|
storedPathBelongsToWorkspace,
|
|
486
486
|
computeWorkspaceEpochFingerprint
|
|
487
|
-
} from "./index-
|
|
487
|
+
} from "./index-y1875y4h.js";
|
|
488
488
|
import {
|
|
489
489
|
V2_MEMORY_CATEGORIES,
|
|
490
490
|
CATEGORY_PRIORITY
|
|
@@ -572,6 +572,7 @@ import {
|
|
|
572
572
|
commitServedRequest,
|
|
573
573
|
lkgInputIdentity,
|
|
574
574
|
beginLkgPass,
|
|
575
|
+
holdLkgCaptureGeneration,
|
|
575
576
|
visitMessageContentFields,
|
|
576
577
|
contentSnapshotValue,
|
|
577
578
|
messageContentFields,
|
|
@@ -582,6 +583,7 @@ import {
|
|
|
582
583
|
lkgSlotRejection,
|
|
583
584
|
captureSlot,
|
|
584
585
|
getInMemorySlot,
|
|
586
|
+
getInMemorySlotIdentity,
|
|
585
587
|
getSlot,
|
|
586
588
|
forgetInMemorySlot,
|
|
587
589
|
dropSlot,
|
|
@@ -594,7 +596,7 @@ import {
|
|
|
594
596
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
595
597
|
getProjectState,
|
|
596
598
|
bumpProjectUserProfileVersion
|
|
597
|
-
} from "./index-
|
|
599
|
+
} from "./index-ze1t940p.js";
|
|
598
600
|
import {
|
|
599
601
|
getLastIndexedOrdinal
|
|
600
602
|
} from "./index-p8nc9axh.js";
|
|
@@ -623,7 +625,7 @@ import {
|
|
|
623
625
|
createPrimer,
|
|
624
626
|
updatePrimerSupport,
|
|
625
627
|
updatePrimerAnswer
|
|
626
|
-
} from "./index-
|
|
628
|
+
} from "./index-zj0ra8vs.js";
|
|
627
629
|
import {
|
|
628
630
|
registerNotificationSink2,
|
|
629
631
|
pushNotification2,
|
|
@@ -656,7 +658,7 @@ import {
|
|
|
656
658
|
embedSessionCompartmentChunks2,
|
|
657
659
|
getEmbeddingCoverageStatus2,
|
|
658
660
|
getAutoEmbeddingSessionCoverage2
|
|
659
|
-
} from "./index-
|
|
661
|
+
} from "./index-as8bg7eh.js";
|
|
660
662
|
import {
|
|
661
663
|
saveEmbeddingIfHashMatches,
|
|
662
664
|
invalidateProject2,
|
|
@@ -682,7 +684,7 @@ import {
|
|
|
682
684
|
readGitFileChangeTimesSince,
|
|
683
685
|
verificationFileExists,
|
|
684
686
|
normalizeVerificationFiles
|
|
685
|
-
} from "./index-
|
|
687
|
+
} from "./index-92p5yfpp.js";
|
|
686
688
|
import {
|
|
687
689
|
computeCueContentHash,
|
|
688
690
|
hasMuralCueColumns,
|
|
@@ -730,13 +732,13 @@ import {
|
|
|
730
732
|
resolveMemoriesByIdsForSearch2,
|
|
731
733
|
unifiedSearch2,
|
|
732
734
|
formatSearchResults2
|
|
733
|
-
} from "./index-
|
|
735
|
+
} from "./index-a3t1ck7g.js";
|
|
734
736
|
import {
|
|
735
737
|
scheduleReconciliation,
|
|
736
738
|
scheduleIncrementalIndex,
|
|
737
739
|
getMessageIndexQueueHeapStats,
|
|
738
740
|
clearSessionTracking
|
|
739
|
-
} from "./index-
|
|
741
|
+
} from "./index-ydevzvfs.js";
|
|
740
742
|
import {
|
|
741
743
|
resolveModelCacheTtl,
|
|
742
744
|
resolveContextWindowGeometry,
|
|
@@ -835,7 +837,7 @@ import {
|
|
|
835
837
|
abortSessionFailClosed2,
|
|
836
838
|
evaluateEmergencyFailClosed2,
|
|
837
839
|
runPostTransformPhase2
|
|
838
|
-
} from "./index-
|
|
840
|
+
} from "./index-5phmpcme.js";
|
|
839
841
|
import {
|
|
840
842
|
flushIgnoredMessages2,
|
|
841
843
|
clearIgnoredMessages2,
|
|
@@ -845,7 +847,7 @@ import {
|
|
|
845
847
|
import {
|
|
846
848
|
setRecompStarting2,
|
|
847
849
|
setRecompTerminal2
|
|
848
|
-
} from "./index-
|
|
850
|
+
} from "./index-3p08zzfq.js";
|
|
849
851
|
import {
|
|
850
852
|
ANNOUNCEMENT_VERSION2,
|
|
851
853
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -863,11 +865,11 @@ import {
|
|
|
863
865
|
} from "./index-zh683xh2.js";
|
|
864
866
|
import {
|
|
865
867
|
readV2ArchiveOffThread2
|
|
866
|
-
} from "./index-
|
|
868
|
+
} from "./index-sfgz2h7y.js";
|
|
867
869
|
import {
|
|
868
870
|
unresolvedLiveTailRefusal2,
|
|
869
871
|
renderSearchArchiveOffThread2
|
|
870
|
-
} from "./index-
|
|
872
|
+
} from "./index-e7awy9eb.js";
|
|
871
873
|
import {
|
|
872
874
|
takeCoveredInstructionRows,
|
|
873
875
|
cloneKeepingCoveredInstructionMarks
|
|
@@ -10088,6 +10090,35 @@ function recordInvocation4(args, startedAt, params) {
|
|
|
10088
10090
|
});
|
|
10089
10091
|
}
|
|
10090
10092
|
|
|
10093
|
+
// src/features/magic-context/dreamer/verify-checkout.ts
|
|
10094
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
10095
|
+
import { promisify as promisify4 } from "node:util";
|
|
10096
|
+
var exec2 = promisify4(execFile4);
|
|
10097
|
+
var MAX_VERIFY_COMMITS_BEHIND = 10;
|
|
10098
|
+
async function verifyCheckoutSkipReason(directory) {
|
|
10099
|
+
const options = {
|
|
10100
|
+
cwd: directory,
|
|
10101
|
+
encoding: "utf8",
|
|
10102
|
+
timeout: 5000,
|
|
10103
|
+
maxBuffer: 4096,
|
|
10104
|
+
windowsHide: true
|
|
10105
|
+
};
|
|
10106
|
+
try {
|
|
10107
|
+
const head = await exec2("git", ["rev-parse", "--abbrev-ref", "HEAD"], options);
|
|
10108
|
+
if (head.stdout.trim() === "HEAD")
|
|
10109
|
+
return "project checkout has a detached HEAD";
|
|
10110
|
+
const result = await exec2("git", ["rev-list", "--count", "HEAD..@{upstream}"], options);
|
|
10111
|
+
const count = result.stdout.trim();
|
|
10112
|
+
if (!/^\d+$/.test(count))
|
|
10113
|
+
return;
|
|
10114
|
+
const behind = Number(count);
|
|
10115
|
+
if (Number.isSafeInteger(behind) && behind > MAX_VERIFY_COMMITS_BEHIND) {
|
|
10116
|
+
return `project checkout is ${behind} commits behind its upstream branch`;
|
|
10117
|
+
}
|
|
10118
|
+
} catch {}
|
|
10119
|
+
return;
|
|
10120
|
+
}
|
|
10121
|
+
|
|
10091
10122
|
// src/features/magic-context/dreamer/task-executor.ts
|
|
10092
10123
|
function dreamRunFailureDetail(error) {
|
|
10093
10124
|
const prompt = getPromptFailureDetail(error);
|
|
@@ -10370,14 +10401,16 @@ function createDreamTaskExecutor(deps) {
|
|
|
10370
10401
|
...refused === undefined ? {} : { refused: Math.max(0, refused) }
|
|
10371
10402
|
});
|
|
10372
10403
|
};
|
|
10373
|
-
|
|
10404
|
+
const checkoutSkipReason = config.task === "verify" || config.task === "verify-broad" ? await verifyCheckoutSkipReason(deps.sessionDirectory) : undefined;
|
|
10405
|
+
if (!checkoutSkipReason)
|
|
10406
|
+
reportProgress(0);
|
|
10374
10407
|
const incompleteMessage = (remaining) => {
|
|
10375
10408
|
const processed = processedDreamTaskItems(backlogAtStart.pending, remaining);
|
|
10376
10409
|
return `${config.task} incomplete: ${remaining} remain (was ${backlogAtStart.pending} at run start; processed ${processed} this run)`;
|
|
10377
10410
|
};
|
|
10378
10411
|
const migrationRequired = projectNeedsSingleStoreMigration(db, projectIdentity);
|
|
10379
10412
|
let moduleRoute;
|
|
10380
|
-
if (!migrationRequired && !config.modelChainUnavailable && (config.task === "curate" || config.task === "map-memories" || config.task === "compress-cues" || config.task === "classify-memories" || config.task === "verify" || config.task === "verify-broad" || config.task === "retrospective")) {
|
|
10413
|
+
if (!checkoutSkipReason && !migrationRequired && !config.modelChainUnavailable && (config.task === "curate" || config.task === "map-memories" || config.task === "compress-cues" || config.task === "classify-memories" || config.task === "verify" || config.task === "verify-broad" || config.task === "retrospective")) {
|
|
10381
10414
|
try {
|
|
10382
10415
|
moduleRoute = await resolveDreamerModuleRoute({
|
|
10383
10416
|
db,
|
|
@@ -10391,7 +10424,7 @@ function createDreamTaskExecutor(deps) {
|
|
|
10391
10424
|
throw new DreamerModuleFailureError("store admission", error);
|
|
10392
10425
|
}
|
|
10393
10426
|
}
|
|
10394
|
-
const parent = migrationRequired || config.modelChainUnavailable ? deps.parentSessionId : await resolveParentSessionId(deadline);
|
|
10427
|
+
const parent = checkoutSkipReason || migrationRequired || config.modelChainUnavailable ? deps.parentSessionId : await resolveParentSessionId(deadline);
|
|
10395
10428
|
if (!leaseOwnershipMatches(db, holderId, leaseAcquisition.generation, leaseKey)) {
|
|
10396
10429
|
throw new Error("Dream lease lost during executor setup");
|
|
10397
10430
|
}
|
|
@@ -10494,6 +10527,8 @@ function createDreamTaskExecutor(deps) {
|
|
|
10494
10527
|
recordRun("skipped", reason);
|
|
10495
10528
|
return { status: "skipped", detail: reason };
|
|
10496
10529
|
};
|
|
10530
|
+
if (checkoutSkipReason)
|
|
10531
|
+
return skip(checkoutSkipReason);
|
|
10497
10532
|
if (config.modelChainUnavailable)
|
|
10498
10533
|
return skip("Pi model chain is empty (no configured model resolves in Pi)");
|
|
10499
10534
|
if (migrationRequired)
|
|
@@ -16524,7 +16559,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16524
16559
|
const db = readDatabase();
|
|
16525
16560
|
if (!db)
|
|
16526
16561
|
return { ok: false, error: "db unavailable" };
|
|
16527
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16562
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-7sf94073.js"));
|
|
16528
16563
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-tfhs4dbc.js"));
|
|
16529
16564
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16530
16565
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -16609,7 +16644,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16609
16644
|
const db = readDatabase();
|
|
16610
16645
|
if (!db)
|
|
16611
16646
|
return { ok: false, error: "db unavailable" };
|
|
16612
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16647
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-k7azmnym.js"));
|
|
16613
16648
|
const model = await args.readSelectedSessionModel?.(sessionId) ?? liveSessionState.liveModelBySession.get(sessionId);
|
|
16614
16649
|
const window = resolveOpenCodeWrapupWindow(db, sessionId, model);
|
|
16615
16650
|
if (!window)
|
|
@@ -24783,6 +24818,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
24783
24818
|
return {
|
|
24784
24819
|
client: args.client,
|
|
24785
24820
|
hiddenCompletionExecutor: args.hiddenCompletionExecutor,
|
|
24821
|
+
isHistorianInstanceDisposed: args.isHistorianInstanceDisposed,
|
|
24786
24822
|
compactionMarkerStrategy: args.compactionMarkerStrategy,
|
|
24787
24823
|
db: args.db,
|
|
24788
24824
|
sessionId: args.sessionId,
|
|
@@ -24930,6 +24966,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
24930
24966
|
startCompartmentAgent({
|
|
24931
24967
|
client: args.client,
|
|
24932
24968
|
hiddenCompletionExecutor: args.hiddenCompletionExecutor,
|
|
24969
|
+
isHistorianInstanceDisposed: args.isHistorianInstanceDisposed,
|
|
24933
24970
|
compactionMarkerStrategy: args.compactionMarkerStrategy,
|
|
24934
24971
|
db: args.db,
|
|
24935
24972
|
sessionId: args.sessionId,
|
|
@@ -25212,6 +25249,9 @@ function createTransform(deps) {
|
|
|
25212
25249
|
const finalWireUsage = createFinalWireUsageTracker();
|
|
25213
25250
|
const host = resolveTransformHostSeams(deps);
|
|
25214
25251
|
const loadedSessions = new Set;
|
|
25252
|
+
const lastGoodPublications = deps.trackLastGoodForDispose ? new WeakMap : undefined;
|
|
25253
|
+
const queuedLastGood = deps.trackLastGoodForDispose ? new Map : undefined;
|
|
25254
|
+
let disposingLastGood = false;
|
|
25215
25255
|
const prefixHoldLogTurnIds = new Map;
|
|
25216
25256
|
const thinkingFitRetries = new Set;
|
|
25217
25257
|
const compactionModeTransitionPending = new Set;
|
|
@@ -25890,6 +25930,7 @@ function createTransform(deps) {
|
|
|
25890
25930
|
startCompartmentAgent({
|
|
25891
25931
|
client: deps.client,
|
|
25892
25932
|
hiddenCompletionExecutor: deps.hiddenCompletionExecutor,
|
|
25933
|
+
isHistorianInstanceDisposed: deps.isHistorianInstanceDisposed,
|
|
25893
25934
|
compactionMarkerStrategy: deps.compactionMarkerStrategy,
|
|
25894
25935
|
db,
|
|
25895
25936
|
sessionId,
|
|
@@ -26238,6 +26279,7 @@ ${notice}`, notificationParams));
|
|
|
26238
26279
|
const tCompartmentPhase = performance.now();
|
|
26239
26280
|
const compartmentPhase = await runCompartmentPhase({
|
|
26240
26281
|
hiddenCompletionExecutor: deps.hiddenCompletionExecutor,
|
|
26282
|
+
isHistorianInstanceDisposed: deps.isHistorianInstanceDisposed,
|
|
26241
26283
|
compactionMarkerStrategy: deps.compactionMarkerStrategy,
|
|
26242
26284
|
canRunCompartments,
|
|
26243
26285
|
fullFeatureMode,
|
|
@@ -27030,7 +27072,8 @@ ${notice}`, notificationParams));
|
|
|
27030
27072
|
if (captured) {
|
|
27031
27073
|
afterCapture(sessionId, "deferred last-good save", () => {
|
|
27032
27074
|
const capturedSlot = getInMemorySlot(sessionId);
|
|
27033
|
-
|
|
27075
|
+
const identity = getInMemorySlotIdentity(sessionId);
|
|
27076
|
+
if (!capturedSlot || !identity)
|
|
27034
27077
|
return;
|
|
27035
27078
|
const revision = lkgDirtyRevision(sessionId) ?? dirtyLkgRecoveryRevision(sessionId, capturedSlot);
|
|
27036
27079
|
const fence = {
|
|
@@ -27039,18 +27082,41 @@ ${notice}`, notificationParams));
|
|
|
27039
27082
|
rebuild: !!recoveryReleaseReason,
|
|
27040
27083
|
retainDirtyRevision: recovery.prefix && !recoveryReleaseReason ? revision : undefined
|
|
27041
27084
|
};
|
|
27042
|
-
|
|
27043
|
-
|
|
27044
|
-
|
|
27045
|
-
|
|
27046
|
-
|
|
27047
|
-
|
|
27048
|
-
|
|
27049
|
-
|
|
27050
|
-
|
|
27051
|
-
|
|
27052
|
-
|
|
27053
|
-
|
|
27085
|
+
const publication = { fence, handledByDispose: false };
|
|
27086
|
+
const generation = holdLkgCaptureGeneration(sessionId);
|
|
27087
|
+
lastGoodPublications?.set(identity, publication);
|
|
27088
|
+
queuedLastGood?.set(sessionId, {
|
|
27089
|
+
slot: capturedSlot,
|
|
27090
|
+
publication,
|
|
27091
|
+
isCurrent: generation.isCurrent
|
|
27092
|
+
});
|
|
27093
|
+
const release = () => {
|
|
27094
|
+
generation.release();
|
|
27095
|
+
if (queuedLastGood?.get(sessionId)?.publication === publication)
|
|
27096
|
+
queuedLastGood.delete(sessionId);
|
|
27097
|
+
};
|
|
27098
|
+
try {
|
|
27099
|
+
withoutSqliteTransformPass2(() => setImmediate(function saveDeferredLastGood() {
|
|
27100
|
+
try {
|
|
27101
|
+
if (!generation.isCurrent() || publication.handledByDispose)
|
|
27102
|
+
return;
|
|
27103
|
+
if (fence.requiredRevision) {
|
|
27104
|
+
const latest = getInMemorySlot(sessionId);
|
|
27105
|
+
if (!latest || latest.capturedAt !== capturedSlot.capturedAt || latest.jsonPrefix !== capturedSlot.jsonPrefix || latest.lastInputMessageId !== capturedSlot.lastInputMessageId || latest.modelKey !== capturedSlot.modelKey || latest.providerKey !== capturedSlot.providerKey)
|
|
27106
|
+
return;
|
|
27107
|
+
}
|
|
27108
|
+
if (saveLkgSlotToDb(db, sessionId, capturedSlot, undefined, fence))
|
|
27109
|
+
lastGoodPublications?.delete(identity);
|
|
27110
|
+
} catch (error) {
|
|
27111
|
+
sessionLog2(sessionId, "Last-good deferred publication remains uncertified:", error);
|
|
27112
|
+
} finally {
|
|
27113
|
+
release();
|
|
27114
|
+
}
|
|
27115
|
+
}));
|
|
27116
|
+
} catch (error) {
|
|
27117
|
+
release();
|
|
27118
|
+
throw error;
|
|
27119
|
+
}
|
|
27054
27120
|
});
|
|
27055
27121
|
noteLkgHealthyPrefix(sessionId, lkgInput, messages, !!recoveryReleaseReason);
|
|
27056
27122
|
}
|
|
@@ -27235,6 +27301,46 @@ ${notice}`, notificationParams));
|
|
|
27235
27301
|
});
|
|
27236
27302
|
return Object.assign(timedTransform, {
|
|
27237
27303
|
clearSessionLogState,
|
|
27304
|
+
disposeLastGood() {
|
|
27305
|
+
if (!lastGoodPublications || disposingLastGood)
|
|
27306
|
+
return;
|
|
27307
|
+
disposingLastGood = true;
|
|
27308
|
+
const captures = [];
|
|
27309
|
+
for (const sessionId of loadedSessions) {
|
|
27310
|
+
const queued = queuedLastGood?.get(sessionId);
|
|
27311
|
+
if (queued?.isCurrent()) {
|
|
27312
|
+
captures.push({
|
|
27313
|
+
sessionId,
|
|
27314
|
+
slot: queued.slot,
|
|
27315
|
+
publication: queued.publication
|
|
27316
|
+
});
|
|
27317
|
+
} else {
|
|
27318
|
+
const identity = getInMemorySlotIdentity(sessionId);
|
|
27319
|
+
const publication = identity && lastGoodPublications.get(identity);
|
|
27320
|
+
if (!publication)
|
|
27321
|
+
continue;
|
|
27322
|
+
const slot = getInMemorySlot(sessionId);
|
|
27323
|
+
if (!slot)
|
|
27324
|
+
continue;
|
|
27325
|
+
captures.push({ sessionId, slot, publication });
|
|
27326
|
+
}
|
|
27327
|
+
}
|
|
27328
|
+
withoutSqliteTransformPass2(() => {
|
|
27329
|
+
for (const { sessionId, slot, publication } of captures) {
|
|
27330
|
+
publication.handledByDispose = true;
|
|
27331
|
+
try {
|
|
27332
|
+
saveLkgSlotToDb(deps.db, sessionId, slot, undefined, {
|
|
27333
|
+
...publication.fence,
|
|
27334
|
+
onlyIfNewer: true
|
|
27335
|
+
});
|
|
27336
|
+
} catch (error) {
|
|
27337
|
+
sessionLog2(sessionId, "Last-good dispose publication given up:", error);
|
|
27338
|
+
if (isTransientSqliteError2(error))
|
|
27339
|
+
break;
|
|
27340
|
+
}
|
|
27341
|
+
}
|
|
27342
|
+
});
|
|
27343
|
+
},
|
|
27238
27344
|
invalidateRustWireState(sessionId) {
|
|
27239
27345
|
rustModeTransform?.invalidateWireState(sessionId);
|
|
27240
27346
|
},
|
|
@@ -29501,9 +29607,9 @@ function isMissingError(error) {
|
|
|
29501
29607
|
}
|
|
29502
29608
|
|
|
29503
29609
|
// ../retina-local-fs/src/provider.ts
|
|
29504
|
-
import { execFile as
|
|
29505
|
-
import { promisify as
|
|
29506
|
-
var execFileAsync3 =
|
|
29610
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
29611
|
+
import { promisify as promisify5 } from "node:util";
|
|
29612
|
+
var execFileAsync3 = promisify5(execFile5);
|
|
29507
29613
|
function parseSemver(value) {
|
|
29508
29614
|
const match = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(value);
|
|
29509
29615
|
if (!match) {
|
|
@@ -31075,4 +31181,160 @@ function applyHiddenSubagentTemperature(input, output, log) {
|
|
|
31075
31181
|
output.temperature = temperature;
|
|
31076
31182
|
}
|
|
31077
31183
|
|
|
31078
|
-
|
|
31184
|
+
// src/v2/hidden-model-activity.ts
|
|
31185
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
31186
|
+
var OUTPUT_EVENT_TYPES = [
|
|
31187
|
+
"session.text.delta",
|
|
31188
|
+
"session.reasoning.delta",
|
|
31189
|
+
"session.tool.input.delta",
|
|
31190
|
+
"session.text.ended",
|
|
31191
|
+
"session.reasoning.ended",
|
|
31192
|
+
"session.tool.input.started"
|
|
31193
|
+
];
|
|
31194
|
+
var STABLE_EVENT_SUBSCRIPTION_MS = 30000;
|
|
31195
|
+
async function waitForEventSubscriptionRetry(signal, subscribedAt, retry) {
|
|
31196
|
+
if (Date.now() - subscribedAt >= STABLE_EVENT_SUBSCRIPTION_MS)
|
|
31197
|
+
retry = 0;
|
|
31198
|
+
const ceiling = Math.min(30000, 250 * 2 ** retry);
|
|
31199
|
+
try {
|
|
31200
|
+
await delay(ceiling * (0.5 + Math.random() * 0.5), undefined, { signal });
|
|
31201
|
+
} catch (error) {
|
|
31202
|
+
if (!signal.aborted)
|
|
31203
|
+
throw error;
|
|
31204
|
+
}
|
|
31205
|
+
return Math.min(retry + 1, 7);
|
|
31206
|
+
}
|
|
31207
|
+
|
|
31208
|
+
class HiddenModelActivity {
|
|
31209
|
+
event;
|
|
31210
|
+
watchers = new Map;
|
|
31211
|
+
controller;
|
|
31212
|
+
loggedFailure = false;
|
|
31213
|
+
disposed = false;
|
|
31214
|
+
constructor(event) {
|
|
31215
|
+
this.event = event;
|
|
31216
|
+
}
|
|
31217
|
+
watch(sessionID, onOutput) {
|
|
31218
|
+
if (this.disposed)
|
|
31219
|
+
return () => {};
|
|
31220
|
+
this.watchers.set(sessionID, onOutput);
|
|
31221
|
+
if (!this.controller) {
|
|
31222
|
+
this.controller = new AbortController;
|
|
31223
|
+
const { signal } = this.controller;
|
|
31224
|
+
this.consume(signal).catch((error) => {
|
|
31225
|
+
if (!signal.aborted)
|
|
31226
|
+
this.warn(error);
|
|
31227
|
+
});
|
|
31228
|
+
}
|
|
31229
|
+
return () => {
|
|
31230
|
+
if (this.watchers.get(sessionID) === onOutput)
|
|
31231
|
+
this.watchers.delete(sessionID);
|
|
31232
|
+
if (this.watchers.size === 0) {
|
|
31233
|
+
this.controller?.abort();
|
|
31234
|
+
this.controller = undefined;
|
|
31235
|
+
}
|
|
31236
|
+
};
|
|
31237
|
+
}
|
|
31238
|
+
dispose() {
|
|
31239
|
+
this.disposed = true;
|
|
31240
|
+
this.watchers.clear();
|
|
31241
|
+
this.controller?.abort();
|
|
31242
|
+
this.controller = undefined;
|
|
31243
|
+
}
|
|
31244
|
+
warn(error) {
|
|
31245
|
+
if (this.loggedFailure)
|
|
31246
|
+
return;
|
|
31247
|
+
this.loggedFailure = true;
|
|
31248
|
+
log2("[magic-context] v2 hidden output subscription ended unexpectedly; retrying while watched", error);
|
|
31249
|
+
}
|
|
31250
|
+
async consume(signal) {
|
|
31251
|
+
let retry = 0;
|
|
31252
|
+
while (!signal.aborted) {
|
|
31253
|
+
const subscribedAt = Date.now();
|
|
31254
|
+
try {
|
|
31255
|
+
for await (const event of this.event.subscribe({
|
|
31256
|
+
signal,
|
|
31257
|
+
types: OUTPUT_EVENT_TYPES
|
|
31258
|
+
})) {
|
|
31259
|
+
if (signal.aborted)
|
|
31260
|
+
break;
|
|
31261
|
+
this.observe(event);
|
|
31262
|
+
}
|
|
31263
|
+
if (!signal.aborted)
|
|
31264
|
+
this.warn();
|
|
31265
|
+
} catch (error) {
|
|
31266
|
+
if (!signal.aborted)
|
|
31267
|
+
this.warn(error);
|
|
31268
|
+
}
|
|
31269
|
+
if (!signal.aborted)
|
|
31270
|
+
retry = await waitForEventSubscriptionRetry(signal, subscribedAt, retry);
|
|
31271
|
+
}
|
|
31272
|
+
}
|
|
31273
|
+
observe(event) {
|
|
31274
|
+
if (!isRecord(event) || typeof event.type !== "string" || !OUTPUT_EVENT_TYPES.includes(event.type))
|
|
31275
|
+
return;
|
|
31276
|
+
if (!isRecord(event.data))
|
|
31277
|
+
return;
|
|
31278
|
+
const { sessionID, delta, text } = event.data;
|
|
31279
|
+
if (typeof sessionID !== "string")
|
|
31280
|
+
return;
|
|
31281
|
+
const streamed = event.type.endsWith(".delta") && typeof delta === "string" && delta.length > 0;
|
|
31282
|
+
const ended = event.type.endsWith(".ended") && typeof text === "string" && text.length > 0;
|
|
31283
|
+
if (streamed || ended || event.type === "session.tool.input.started") {
|
|
31284
|
+
this.watchers.get(sessionID)?.();
|
|
31285
|
+
}
|
|
31286
|
+
}
|
|
31287
|
+
}
|
|
31288
|
+
|
|
31289
|
+
// src/v2/hooks/event-subscription-worker.ts
|
|
31290
|
+
function startEventSubscriptionWorker(event, types, diagnostics, handle) {
|
|
31291
|
+
const controller = new AbortController;
|
|
31292
|
+
const { signal } = controller;
|
|
31293
|
+
const handlerFailures = new Set;
|
|
31294
|
+
const done = (async () => {
|
|
31295
|
+
let retry = 0;
|
|
31296
|
+
let loggedOutage = false;
|
|
31297
|
+
while (!signal.aborted) {
|
|
31298
|
+
const subscribedAt = Date.now();
|
|
31299
|
+
let streamError;
|
|
31300
|
+
try {
|
|
31301
|
+
for await (const value of event.subscribe({ signal, types })) {
|
|
31302
|
+
if (signal.aborted)
|
|
31303
|
+
break;
|
|
31304
|
+
try {
|
|
31305
|
+
if (await handle(value, signal))
|
|
31306
|
+
handlerFailures.clear();
|
|
31307
|
+
} catch (error) {
|
|
31308
|
+
if (signal.aborted)
|
|
31309
|
+
break;
|
|
31310
|
+
const cause = error instanceof Error ? `${error.name}: ${error.message}` : error;
|
|
31311
|
+
if (!handlerFailures.has(cause)) {
|
|
31312
|
+
handlerFailures.add(cause);
|
|
31313
|
+
diagnostics.handlerFailed(error);
|
|
31314
|
+
}
|
|
31315
|
+
}
|
|
31316
|
+
}
|
|
31317
|
+
} catch (error) {
|
|
31318
|
+
streamError = error;
|
|
31319
|
+
}
|
|
31320
|
+
if (signal.aborted)
|
|
31321
|
+
break;
|
|
31322
|
+
if (Date.now() - subscribedAt >= STABLE_EVENT_SUBSCRIPTION_MS)
|
|
31323
|
+
loggedOutage = false;
|
|
31324
|
+
if (!loggedOutage) {
|
|
31325
|
+
loggedOutage = true;
|
|
31326
|
+
diagnostics.subscriptionEnded(streamError);
|
|
31327
|
+
}
|
|
31328
|
+
retry = await waitForEventSubscriptionRetry(signal, subscribedAt, retry);
|
|
31329
|
+
}
|
|
31330
|
+
})();
|
|
31331
|
+
return {
|
|
31332
|
+
done,
|
|
31333
|
+
async dispose() {
|
|
31334
|
+
controller.abort();
|
|
31335
|
+
await done;
|
|
31336
|
+
}
|
|
31337
|
+
};
|
|
31338
|
+
}
|
|
31339
|
+
|
|
31340
|
+
export { logConfigDependencyNotesOnce, openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, startDreamScheduleTimer, createDreamTimerModuleClient, ensureProjectRegisteredFromOpenCodeDirectory, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, recordHostSqliteRuntime, maybeAutoEmbedSessionBackfill, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, stageOpenCodeV2TransformDecision, bindOpenCodeV2TransformDecision, maybeDeliverChannel2, PROVIDER_OVERFLOW_NOTICE, noteServedRecoveryForOverflowHint, holdOverflowResendHint, ProviderRefusalCounts, snapshotRefusalHistory, pushRefusalFields, withProviderRefusalPass, createM0RenderOptions, lkgReplayLimit, measureLkgReplay, moduleRawBlockMappings, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, isClearlyOverWindow, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, rendersCompartmentHistory, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, removePrimaryOnlyTools, storedSubagentMode, createCtxExpandTools, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createDreamerMemoryTools, CTX_NOTE_DESCRIPTION, withoutSmartNoteText, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer, subagentTemperature, applyHiddenSubagentTemperature, waitForEventSubscriptionRetry, HiddenModelActivity, startEventSubscriptionWorker };
|