@cortexkit/opencode-magic-context 0.49.55 → 0.49.56
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/{context-vx5gw5h2.js → context-bejy30t5.js} +182 -53
- package/dist/features/magic-context/pi-identity-fold-guards.d.ts +38 -0
- package/dist/features/magic-context/pi-identity-fold-guards.d.ts.map +1 -0
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
- package/dist/{index-a3n2dczz.js → index-12p4j9wa.js} +1 -1
- package/dist/{index-xj5bap1r.js → index-3jeq08jv.js} +1 -1
- package/dist/{index-567xsm72.js → index-3wmp1nb7.js} +3 -3
- package/dist/{index-yamsmkmh.js → index-5483ntzh.js} +2 -2
- package/dist/{index-9n6mdfqy.js → index-ffab4edg.js} +18 -16
- package/dist/{index-eyr425dx.js → index-pxfb7pp8.js} +2 -2
- package/dist/{index-xvtjwhm6.js → index-qfc1kjh4.js} +2 -2
- package/dist/{index-tx8nfw85.js → index-wgbp5zch.js} +9 -0
- package/dist/index.js +11 -11
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{recomp-orchestrator-wbm4kpq9.js → recomp-orchestrator-2tsjqbrm.js} +3 -3
- package/dist/{render-73vrt30h.js → render-fgxbcmnh.js} +1 -1
- package/dist/{search-archive-ew4c3bsw.js → search-archive-0mz3p1g1.js} +2 -2
- package/dist/{transform-postprocess-phase-mt4dcbhd.js → transform-postprocess-phase-64xtx439.js} +3 -3
- package/dist/v2/{context-13er940g.js → context-5hhm89jw.js} +181 -52
- package/dist/v2/hidden-child-native.d.ts +10 -13
- package/dist/v2/hidden-child-native.d.ts.map +1 -1
- package/dist/v2/hidden-child-record.d.ts +2 -0
- package/dist/v2/hidden-child-record.d.ts.map +1 -1
- package/dist/v2/hidden-child-sweep.d.ts +39 -0
- package/dist/v2/hidden-child-sweep.d.ts.map +1 -0
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
- package/dist/v2/{recomp-orchestrator-cdkfynz4.js → recomp-orchestrator-dzdxrgdt.js} +2 -2
- package/dist/v2/{render-a7j6fqbd.js → render-jfa3hj8z.js} +1 -1
- package/dist/v2/{search-archive-3a36887a.js → search-archive-p4s9q7a3.js} +2 -2
- package/dist/v2/{server-578pc4tf.js → server-8e5m2gre.js} +2 -2
- package/dist/v2/{server-79tbtk5w.js → server-kyfj1090.js} +1 -1
- package/dist/v2/{server-7rmf6a57.js → server-q02z0jq7.js} +9 -0
- package/dist/v2/{server-96g41nad.js → server-z6sxv6n3.js} +1 -1
- package/dist/v2/server.js +2 -2
- package/dist/v2/{v2-archive-reader-jm3d7ccj.js → v2-archive-reader-jpdh0ktt.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-xnqq81c4.js → wrapup-orchestrator-5dfj2mcs.js} +2 -2
- package/dist/{v2-archive-reader-9bbfh131.js → v2-archive-reader-557b5dn3.js} +1 -1
- package/dist/{wrapup-orchestrator-svhee0fn.js → wrapup-orchestrator-21hgybdk.js} +4 -4
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
rebaseSessionCoordinatesAsync,
|
|
39
39
|
resolveOpenCodeProtectedTailBoundary,
|
|
40
40
|
getActiveCompartmentRun
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-3jeq08jv.js";
|
|
42
42
|
import"./index-sd3egckz.js";
|
|
43
43
|
import {
|
|
44
44
|
getHarness2
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
applyJsonSchemaParameterDescriptions,
|
|
130
130
|
MagicContextRpcServer,
|
|
131
131
|
subagentTemperature
|
|
132
|
-
} from "./index-
|
|
132
|
+
} from "./index-ffab4edg.js";
|
|
133
133
|
import {
|
|
134
134
|
resolveHistorianModel2
|
|
135
135
|
} from "./index-5kym00ag.js";
|
|
@@ -260,7 +260,7 @@ import {
|
|
|
260
260
|
getSlot,
|
|
261
261
|
dropSlot,
|
|
262
262
|
copySessionStateForClone
|
|
263
|
-
} from "./index-
|
|
263
|
+
} from "./index-wgbp5zch.js";
|
|
264
264
|
import {
|
|
265
265
|
startBootDeadline,
|
|
266
266
|
BOOT_SQLITE_BUSY_TIMEOUT_MS,
|
|
@@ -291,7 +291,7 @@ import {
|
|
|
291
291
|
servedHeadChanged,
|
|
292
292
|
noteHostCheckpointCommit,
|
|
293
293
|
isSyntheticHeadMessage2
|
|
294
|
-
} from "./index-
|
|
294
|
+
} from "./index-pxfb7pp8.js";
|
|
295
295
|
import"./index-90z05d0p.js";
|
|
296
296
|
import"./index-qt1qqasc.js";
|
|
297
297
|
import {
|
|
@@ -313,7 +313,7 @@ import {
|
|
|
313
313
|
import"./index-gz001bx7.js";
|
|
314
314
|
import"./index-r9agn061.js";
|
|
315
315
|
import"./index-by14cr73.js";
|
|
316
|
-
import"./index-
|
|
316
|
+
import"./index-5483ntzh.js";
|
|
317
317
|
import"./index-cd3vp8xa.js";
|
|
318
318
|
import {
|
|
319
319
|
detectConflicts
|
|
@@ -338,8 +338,8 @@ import {
|
|
|
338
338
|
import"./index-fmsr7v69.js";
|
|
339
339
|
import"./index-5gqszjq9.js";
|
|
340
340
|
import"./index-52x68mj4.js";
|
|
341
|
-
import"./index-
|
|
342
|
-
import"./index-
|
|
341
|
+
import"./index-qfc1kjh4.js";
|
|
342
|
+
import"./index-12p4j9wa.js";
|
|
343
343
|
import {
|
|
344
344
|
isDreamerRunnable,
|
|
345
345
|
isSmartNoteSurfaceAvailable,
|
|
@@ -3670,7 +3670,104 @@ function errorText(value) {
|
|
|
3670
3670
|
}
|
|
3671
3671
|
}
|
|
3672
3672
|
|
|
3673
|
+
// src/v2/hidden-child-sweep.ts
|
|
3674
|
+
var PREFIX = "hidden_child:";
|
|
3675
|
+
var HIDDEN_CHILD_MAX_AGE_MS = 60 * 60 * 1000;
|
|
3676
|
+
var HIDDEN_CHILD_SWEEP_INTERVAL_MS = 30 * 60 * 1000;
|
|
3677
|
+
var HIDDEN_CHILD_DEADLINE_GRACE_MS = 10 * 60 * 1000;
|
|
3678
|
+
var SWEEP_REMOVAL_LIMIT = 50;
|
|
3679
|
+
var SWEEP_BUDGET_MS = 30000;
|
|
3680
|
+
function recordHiddenChild(db, child) {
|
|
3681
|
+
db.prepare("INSERT INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(`${PREFIX}${child.id}`, JSON.stringify(child));
|
|
3682
|
+
}
|
|
3683
|
+
function forgetHiddenChild(db, id) {
|
|
3684
|
+
db.prepare("DELETE FROM schema_migrations_meta WHERE key = ?").run(`${PREFIX}${id}`);
|
|
3685
|
+
}
|
|
3686
|
+
function extendHiddenChildDeadline(db, id, deadlineAt) {
|
|
3687
|
+
db.prepare(`UPDATE schema_migrations_meta
|
|
3688
|
+
SET value = json_set(value, '$.deadline_at', MAX(COALESCE(json_extract(value, '$.deadline_at'), 0), ?))
|
|
3689
|
+
WHERE key = ?`).run(deadlineAt, `${PREFIX}${id}`);
|
|
3690
|
+
}
|
|
3691
|
+
function markHiddenChildRemovalFailed(db, id, failedAt) {
|
|
3692
|
+
db.prepare("UPDATE schema_migrations_meta SET value = json_set(value, '$.failed_at', ?) WHERE key = ?").run(failedAt, `${PREFIX}${id}`);
|
|
3693
|
+
}
|
|
3694
|
+
function createHiddenChildSweeper(remove, log, options = {}) {
|
|
3695
|
+
let stopped = false;
|
|
3696
|
+
let running;
|
|
3697
|
+
return {
|
|
3698
|
+
start(db) {
|
|
3699
|
+
if (stopped || running)
|
|
3700
|
+
return;
|
|
3701
|
+
running = sweepHiddenChildren(db, remove, log, {
|
|
3702
|
+
...options,
|
|
3703
|
+
shouldStop: () => stopped || options.shouldStop?.() === true
|
|
3704
|
+
}).catch((error) => log("[magic-context] hidden-child sweep failed", error)).finally(() => {
|
|
3705
|
+
running = undefined;
|
|
3706
|
+
});
|
|
3707
|
+
},
|
|
3708
|
+
async dispose() {
|
|
3709
|
+
stopped = true;
|
|
3710
|
+
await running;
|
|
3711
|
+
}
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
async function sweepHiddenChildren(db, remove, note, options = {}) {
|
|
3715
|
+
const now = options.now ?? Date.now();
|
|
3716
|
+
const clock = options.clock ?? (() => performance.now());
|
|
3717
|
+
const passDeadline = clock() + (options.budgetMs ?? SWEEP_BUDGET_MS);
|
|
3718
|
+
let remaining = options.limit ?? SWEEP_REMOVAL_LIMIT;
|
|
3719
|
+
const rows = db.prepare(`SELECT key, value FROM (
|
|
3720
|
+
SELECT key, value,
|
|
3721
|
+
CASE WHEN json_valid(value) THEN json_extract(value, '$.failed_at') END AS failed_at,
|
|
3722
|
+
CASE WHEN json_valid(value) THEN json_extract(value, '$.created_at') END AS created_at
|
|
3723
|
+
FROM schema_migrations_meta WHERE key GLOB ?
|
|
3724
|
+
)
|
|
3725
|
+
ORDER BY failed_at IS NOT NULL, COALESCE(failed_at, created_at), created_at, key`).all(`${PREFIX}*`);
|
|
3726
|
+
for (const row of rows) {
|
|
3727
|
+
if (remaining <= 0 || clock() >= passDeadline || options.shouldStop?.())
|
|
3728
|
+
break;
|
|
3729
|
+
let timer;
|
|
3730
|
+
try {
|
|
3731
|
+
const child = JSON.parse(row.value);
|
|
3732
|
+
if (!child || typeof child.id !== "string" || row.key !== `${PREFIX}${child.id}` || typeof child.directory !== "string" || !Number.isFinite(child.created_at) || child.deadline_at !== undefined && !Number.isFinite(child.deadline_at))
|
|
3733
|
+
throw new Error(`invalid cleanup record ${row.key}`);
|
|
3734
|
+
const expiresAt = Math.max(child.created_at + (options.maxAgeMs ?? HIDDEN_CHILD_MAX_AGE_MS), child.deadline_at === undefined ? 0 : child.deadline_at + HIDDEN_CHILD_DEADLINE_GRACE_MS);
|
|
3735
|
+
if (now <= expiresAt || options.isLive?.(child.id))
|
|
3736
|
+
continue;
|
|
3737
|
+
remaining--;
|
|
3738
|
+
try {
|
|
3739
|
+
await Promise.race([
|
|
3740
|
+
remove({ sessionID: child.id }),
|
|
3741
|
+
new Promise((_, reject) => {
|
|
3742
|
+
timer = setTimeout(() => reject(new Error("session.remove timed out")), Math.min(options.removalTimeoutMs ?? 5000, Math.max(1, passDeadline - clock())));
|
|
3743
|
+
})
|
|
3744
|
+
]);
|
|
3745
|
+
} catch (error) {
|
|
3746
|
+
if (!isSessionNotFound(error)) {
|
|
3747
|
+
try {
|
|
3748
|
+
markHiddenChildRemovalFailed(db, child.id, now);
|
|
3749
|
+
} catch (markError) {
|
|
3750
|
+
note(`[magic-context] hidden-child sweep could not mark ${row.key} failed: ${String(markError)}`);
|
|
3751
|
+
}
|
|
3752
|
+
throw error;
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
forgetHiddenChild(db, child.id);
|
|
3756
|
+
note(`[magic-context] stale hidden child ${child.id} removed`);
|
|
3757
|
+
} catch (error) {
|
|
3758
|
+
note(`[magic-context] hidden-child sweep deferred ${row.key}: ${String(error)}`);
|
|
3759
|
+
} finally {
|
|
3760
|
+
if (timer)
|
|
3761
|
+
clearTimeout(timer);
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3673
3766
|
// src/v2/hidden-child-native.ts
|
|
3767
|
+
var liveChildren = new Set;
|
|
3768
|
+
function isLiveHiddenChild(id) {
|
|
3769
|
+
return liveChildren.has(id);
|
|
3770
|
+
}
|
|
3674
3771
|
function nativeSessionRemove(session) {
|
|
3675
3772
|
const remove = session.remove;
|
|
3676
3773
|
if (typeof remove !== "function")
|
|
@@ -3686,7 +3783,6 @@ function isSessionNotFound(error) {
|
|
|
3686
3783
|
const label = [fields.name, fields._tag, fields.message].filter((value) => typeof value === "string").join(" ");
|
|
3687
3784
|
return /not\s*found/i.test(label);
|
|
3688
3785
|
}
|
|
3689
|
-
var parentDroppedNoted = false;
|
|
3690
3786
|
function createNativeHiddenChildren(host, removeSession, options) {
|
|
3691
3787
|
const removing = new Map;
|
|
3692
3788
|
const remove = (child) => {
|
|
@@ -3708,68 +3804,74 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
3708
3804
|
if (timer)
|
|
3709
3805
|
clearTimeout(timer);
|
|
3710
3806
|
}
|
|
3807
|
+
forgetHiddenChild(options.db, child.id);
|
|
3711
3808
|
options.log(`[magic-context] hidden child ${child.id} removed`);
|
|
3712
3809
|
} catch (error) {
|
|
3713
|
-
if (isSessionNotFound(error))
|
|
3810
|
+
if (isSessionNotFound(error)) {
|
|
3811
|
+
try {
|
|
3812
|
+
forgetHiddenChild(options.db, child.id);
|
|
3813
|
+
} catch (storeError) {
|
|
3814
|
+
options.log(`[magic-context] hidden child ${child.id} record cleanup deferred: ${errorText(storeError)}`);
|
|
3815
|
+
}
|
|
3714
3816
|
return;
|
|
3715
|
-
|
|
3817
|
+
}
|
|
3818
|
+
options.log(`[magic-context] hidden child ${child.id} could not be removed: ${errorText(error)}`);
|
|
3716
3819
|
}
|
|
3717
3820
|
})().finally(() => {
|
|
3718
3821
|
removing.delete(child.id);
|
|
3822
|
+
liveChildren.delete(child.id);
|
|
3719
3823
|
});
|
|
3720
3824
|
removing.set(child.id, done);
|
|
3721
3825
|
return done;
|
|
3722
3826
|
};
|
|
3723
|
-
const noteCreated = (sessionID, role, parentID) => {
|
|
3724
|
-
options.log(`[magic-context] hidden child ${sessionID} created role=${role} parent=${parentID} keep_subagents=${options.keepSubagents}`);
|
|
3725
|
-
};
|
|
3726
|
-
const confirmPlacement = async (sessionID, parentID, role) => {
|
|
3727
|
-
let stored;
|
|
3728
|
-
try {
|
|
3729
|
-
stored = await host.get({ sessionID });
|
|
3730
|
-
} catch (error) {
|
|
3731
|
-
noteCreated(sessionID, role, "unknown");
|
|
3732
|
-
options.log(`[magic-context] could not read back hidden child ${sessionID} to confirm its parent: ${errorText(error)}`);
|
|
3733
|
-
return;
|
|
3734
|
-
}
|
|
3735
|
-
noteCreated(sessionID, role, stored.parentID ?? "none");
|
|
3736
|
-
const directory = stored.location?.directory;
|
|
3737
|
-
if (options.directory !== undefined && directory !== undefined && !sameProjectDirectory(directory, options.directory)) {
|
|
3738
|
-
throw new HiddenCompletionRefusal("hidden_prompt_unrecognized", `hidden child ${sessionID} is bound to ${directory}, not to this instance's ${options.directory}. Reopen the parent session in ${directory}, then run /ctx-recomp so its owning instance can rebuild history.`, true);
|
|
3739
|
-
}
|
|
3740
|
-
if (stored.parentID === parentID || parentDroppedNoted)
|
|
3741
|
-
return;
|
|
3742
|
-
parentDroppedNoted = true;
|
|
3743
|
-
options.log(`[magic-context] this OpenCode 2 host does not keep the parent of hidden-run sessions (asked for ${parentID}, read back ${stored.parentID ?? "none"}); they are created as separate sessions and still removed when each run ends`);
|
|
3744
|
-
};
|
|
3745
3827
|
const create = async (identity, role, model) => {
|
|
3746
|
-
const parentID = identity.parentSessionId;
|
|
3747
3828
|
const input = childCreateInput(identity, role, model);
|
|
3748
|
-
const
|
|
3749
|
-
const created = await host.create(parentID ? { ...parented, parentID } : { ...parented, location });
|
|
3829
|
+
const created = await host.create(input);
|
|
3750
3830
|
if (!created.id)
|
|
3751
3831
|
throw new Error("OpenCode 2 did not return a child session id");
|
|
3832
|
+
const createdAt = Date.now();
|
|
3833
|
+
liveChildren.add(created.id);
|
|
3834
|
+
if (!options.keepSubagents) {
|
|
3835
|
+
try {
|
|
3836
|
+
recordHiddenChild(options.db, {
|
|
3837
|
+
id: created.id,
|
|
3838
|
+
directory: identity.directory,
|
|
3839
|
+
created_at: createdAt,
|
|
3840
|
+
deadline_at: createdAt + identity.timeoutMs
|
|
3841
|
+
});
|
|
3842
|
+
} catch (storeError) {
|
|
3843
|
+
let removed = false;
|
|
3844
|
+
let timer;
|
|
3845
|
+
try {
|
|
3846
|
+
await Promise.race([
|
|
3847
|
+
removeSession({ sessionID: created.id }),
|
|
3848
|
+
new Promise((_, reject) => {
|
|
3849
|
+
timer = setTimeout(() => reject(new Error("session.remove timed out")), options.removalTimeoutMs ?? 5000);
|
|
3850
|
+
})
|
|
3851
|
+
]);
|
|
3852
|
+
removed = true;
|
|
3853
|
+
} catch (error) {
|
|
3854
|
+
removed = isSessionNotFound(error);
|
|
3855
|
+
} finally {
|
|
3856
|
+
if (timer)
|
|
3857
|
+
clearTimeout(timer);
|
|
3858
|
+
liveChildren.delete(created.id);
|
|
3859
|
+
}
|
|
3860
|
+
options.log(`[magic-context] hidden child ${created.id} record failed; removed=${removed}: ${errorText(storeError)}`);
|
|
3861
|
+
throw storeError;
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3752
3864
|
options.hook.registerChild(created.id, input.agent);
|
|
3753
|
-
|
|
3865
|
+
options.log(`[magic-context] hidden child ${created.id} created role=${role} keep_subagents=${options.keepSubagents}`);
|
|
3866
|
+
return {
|
|
3754
3867
|
id: created.id,
|
|
3755
3868
|
role,
|
|
3756
3869
|
generation: options.generation,
|
|
3757
3870
|
title: roleTitle(role),
|
|
3758
3871
|
model,
|
|
3759
|
-
created_at:
|
|
3872
|
+
created_at: createdAt,
|
|
3760
3873
|
directory: identity.directory
|
|
3761
3874
|
};
|
|
3762
|
-
if (parentID) {
|
|
3763
|
-
try {
|
|
3764
|
-
await confirmPlacement(created.id, parentID, role);
|
|
3765
|
-
} catch (error) {
|
|
3766
|
-
await remove(child);
|
|
3767
|
-
throw error;
|
|
3768
|
-
}
|
|
3769
|
-
} else {
|
|
3770
|
-
noteCreated(created.id, role, "none");
|
|
3771
|
-
}
|
|
3772
|
-
return child;
|
|
3773
3875
|
};
|
|
3774
3876
|
const kept = (child) => keptUnderRetention(options.keepSubagents, child);
|
|
3775
3877
|
return {
|
|
@@ -3777,6 +3879,7 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
3777
3879
|
create,
|
|
3778
3880
|
retire(child) {
|
|
3779
3881
|
if (kept(child)) {
|
|
3882
|
+
liveChildren.delete(child.id);
|
|
3780
3883
|
options.log(`[magic-context] hidden child ${child.id} kept (keep_subagents)`);
|
|
3781
3884
|
} else {
|
|
3782
3885
|
remove(child);
|
|
@@ -3788,23 +3891,33 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
3788
3891
|
return;
|
|
3789
3892
|
}
|
|
3790
3893
|
if (kept(child)) {
|
|
3894
|
+
liveChildren.delete(child.id);
|
|
3791
3895
|
options.log(`[magic-context] hidden child ${child.id} kept (keep_subagents)`);
|
|
3792
3896
|
} else {
|
|
3793
3897
|
await remove(child);
|
|
3794
3898
|
}
|
|
3795
3899
|
},
|
|
3900
|
+
extendDeadline(child, deadlineAt) {
|
|
3901
|
+
if (options.keepSubagents)
|
|
3902
|
+
return;
|
|
3903
|
+
try {
|
|
3904
|
+
extendHiddenChildDeadline(options.db, child.id, deadlineAt);
|
|
3905
|
+
} catch (error) {
|
|
3906
|
+
options.log(`[magic-context] hidden child ${child.id} deadline update deferred: ${errorText(error)}`);
|
|
3907
|
+
}
|
|
3908
|
+
},
|
|
3796
3909
|
updateModel: (child, model) => ({ ...child, model }),
|
|
3797
3910
|
markEverSettled: (child) => ({ ...child, ever_settled: true })
|
|
3798
3911
|
};
|
|
3799
3912
|
}
|
|
3800
3913
|
|
|
3801
3914
|
// src/v2/hidden-child-cleanup.ts
|
|
3802
|
-
var
|
|
3915
|
+
var PREFIX2 = "opencode2_hidden_children:";
|
|
3803
3916
|
var COMPLETE = "opencode2_hidden_children_cleanup_complete";
|
|
3804
3917
|
async function cleanupLegacyHiddenChildren(db, remove, note, options = {}) {
|
|
3805
3918
|
if (db.prepare("SELECT 1 FROM schema_migrations_meta WHERE key = ?").get(COMPLETE))
|
|
3806
3919
|
return;
|
|
3807
|
-
const rows = db.prepare("SELECT key, value FROM schema_migrations_meta WHERE key GLOB ? ORDER BY key LIMIT 25").all(`${
|
|
3920
|
+
const rows = db.prepare("SELECT key, value FROM schema_migrations_meta WHERE key GLOB ? ORDER BY key LIMIT 25").all(`${PREFIX2}*`);
|
|
3808
3921
|
let remaining = options.limit ?? 25;
|
|
3809
3922
|
const now = options.now ?? (() => performance.now());
|
|
3810
3923
|
const deadline = now() + (options.budgetMs ?? 2000);
|
|
@@ -3856,7 +3969,7 @@ async function cleanupLegacyHiddenChildren(db, remove, note, options = {}) {
|
|
|
3856
3969
|
if (Object.keys(record.active ?? {}).length === 0 && (record.retired_children ?? []).length === 0)
|
|
3857
3970
|
db.prepare("DELETE FROM schema_migrations_meta WHERE key = ?").run(row.key);
|
|
3858
3971
|
}
|
|
3859
|
-
if (!db.prepare("SELECT 1 FROM schema_migrations_meta WHERE key GLOB ? LIMIT 1").get(`${
|
|
3972
|
+
if (!db.prepare("SELECT 1 FROM schema_migrations_meta WHERE key GLOB ? LIMIT 1").get(`${PREFIX2}*`))
|
|
3860
3973
|
db.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, 'true')").run(COMPLETE);
|
|
3861
3974
|
}
|
|
3862
3975
|
|
|
@@ -4149,12 +4262,12 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4149
4262
|
if (!removeSession)
|
|
4150
4263
|
throw new Error("Magic Context requires OpenCode 2.0.22 session.remove");
|
|
4151
4264
|
const lifecycle = createNativeHiddenChildren(host, (input) => removeSession.call(host, input), {
|
|
4265
|
+
db: options.db,
|
|
4152
4266
|
hook: options.hook,
|
|
4153
4267
|
generation,
|
|
4154
4268
|
keepSubagents: options.keepSubagents === true,
|
|
4155
4269
|
log: note,
|
|
4156
|
-
removalTimeoutMs: options.removalTimeoutMs
|
|
4157
|
-
directory: options.directory
|
|
4270
|
+
removalTimeoutMs: options.removalTimeoutMs
|
|
4158
4271
|
});
|
|
4159
4272
|
const acquireRole = async (role) => {
|
|
4160
4273
|
const previous = roleTails.get(role) ?? Promise.resolve();
|
|
@@ -4383,6 +4496,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
4383
4496
|
run.attempt = { child: attempt, baseline };
|
|
4384
4497
|
options.hook.registerAttempt(marker, attempt);
|
|
4385
4498
|
const deadline = Date.now() + run.identity.timeoutMs;
|
|
4499
|
+
lifecycle.extendDeadline(run.child, deadline);
|
|
4386
4500
|
const budget = run.budget;
|
|
4387
4501
|
if (budget?.snapshot().finalizeFired) {
|
|
4388
4502
|
throw new DreamTokenBudgetExceeded(run.child.id, budget.snapshot().spent);
|
|
@@ -6667,11 +6781,23 @@ async function registerContext(context) {
|
|
|
6667
6781
|
let db = await probeV2StorageAtBoot(storage);
|
|
6668
6782
|
const storageOpenedAtBoot = db !== undefined;
|
|
6669
6783
|
let legacyCleanupStarted = false;
|
|
6784
|
+
const hiddenChildSweep = createHiddenChildSweeper(nativeRemove, log2, {
|
|
6785
|
+
isLive: isLiveHiddenChild
|
|
6786
|
+
});
|
|
6787
|
+
let hiddenChildSweepTimer;
|
|
6788
|
+
const sweepChildren = (database) => {
|
|
6789
|
+
hiddenChildSweep.start(database);
|
|
6790
|
+
};
|
|
6670
6791
|
const cleanupLegacyOnce = async (database) => {
|
|
6671
6792
|
if (legacyCleanupStarted)
|
|
6672
6793
|
return;
|
|
6673
6794
|
legacyCleanupStarted = true;
|
|
6674
6795
|
await cleanupLegacyHiddenChildren(database, nativeRemove, log2);
|
|
6796
|
+
sweepChildren(database);
|
|
6797
|
+
hiddenChildSweepTimer = inRootAsyncContext2(() => setInterval(() => {
|
|
6798
|
+
sweepChildren(database);
|
|
6799
|
+
}, HIDDEN_CHILD_SWEEP_INTERVAL_MS));
|
|
6800
|
+
hiddenChildSweepTimer.unref?.();
|
|
6675
6801
|
};
|
|
6676
6802
|
if (db && isDatabasePersisted(db))
|
|
6677
6803
|
await cleanupLegacyOnce(db);
|
|
@@ -8280,6 +8406,9 @@ async function registerContext(context) {
|
|
|
8280
8406
|
}, 0));
|
|
8281
8407
|
return {
|
|
8282
8408
|
async dispose() {
|
|
8409
|
+
if (hiddenChildSweepTimer)
|
|
8410
|
+
clearInterval(hiddenChildSweepTimer);
|
|
8411
|
+
await hiddenChildSweep.dispose();
|
|
8283
8412
|
messageTimesCache.clear();
|
|
8284
8413
|
hostFoldIdle?.dispose();
|
|
8285
8414
|
usageController.abort();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Database } from "../../shared/sqlite";
|
|
2
|
+
/**
|
|
3
|
+
* Pi's once-guards for tag-identity repairs, one per repaired identity.
|
|
4
|
+
*
|
|
5
|
+
* A guard records that an identity (a tool call or a message part that was
|
|
6
|
+
* tagged twice) has had its one repair, so the same identity is never folded
|
|
7
|
+
* or rebuilt a second time. Older builds kept these guards in the session's
|
|
8
|
+
* shared Pi content-decision ledger (`session_meta.merged_reasoning_stripped_ids`),
|
|
9
|
+
* whose 4,096-entry cap they shared with reminder-strip and seam-temporal-strip
|
|
10
|
+
* replay decisions. A session with thousands of duplicated identities filled
|
|
11
|
+
* that ledger and left no room for the strip decisions. New guards live in
|
|
12
|
+
* their own row of the `schema_migrations_meta` key/value table instead, so no
|
|
13
|
+
* schema change is needed; guards already in the shared ledger stay valid and
|
|
14
|
+
* are still read.
|
|
15
|
+
*
|
|
16
|
+
* The value is a JSON array of guard keys (each a JSON-encoded identity key).
|
|
17
|
+
* Session deletion removes the row together with the session's metadata (see
|
|
18
|
+
* storage-session-tables.ts).
|
|
19
|
+
*/
|
|
20
|
+
export declare const PI_IDENTITY_FOLD_GUARD_PREFIX = "pi_identity_fold_guards:";
|
|
21
|
+
/**
|
|
22
|
+
* Guard keys are about 60 bytes for a tool call and 95 for a message part, so
|
|
23
|
+
* a full row is about 1.5 MB at most. The row is read once and written once per
|
|
24
|
+
* committed adoption chunk, so this bounds each of those writes. A session
|
|
25
|
+
* with more duplicated identities than this leaves the rest unmerged, which
|
|
26
|
+
* serves them as tagging does without a repair.
|
|
27
|
+
*/
|
|
28
|
+
export declare const PI_IDENTITY_FOLD_GUARD_LIMIT = 16384;
|
|
29
|
+
export declare function piIdentityFoldGuardKey(sessionId: string): string;
|
|
30
|
+
/** The session's fold guards. Throws when the stored row is not a JSON array of strings. */
|
|
31
|
+
export declare function readPiIdentityFoldGuards(db: Database, sessionId: string): Set<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Store `guards` as the session's complete guard set. The caller holds the
|
|
34
|
+
* writer transaction it read the current set under, adds to that set, and
|
|
35
|
+
* keeps it within PI_IDENTITY_FOLD_GUARD_LIMIT.
|
|
36
|
+
*/
|
|
37
|
+
export declare function writePiIdentityFoldGuards(db: Database, sessionId: string, guards: ReadonlySet<string>): void;
|
|
38
|
+
//# sourceMappingURL=pi-identity-fold-guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-identity-fold-guards.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/pi-identity-fold-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AAExE;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,4FAA4F;AAC5F,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CASrF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACrC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAC5B,IAAI,CAON"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-session-tables.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-session-tables.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAA0C,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"storage-session-tables.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-session-tables.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAA0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AE,MAAM,KAAK,MAAM,CAAC;IACnD,gBAAgB,EAAE,CACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,kBAAkB,KACzB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjD,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,iGAAiG;IACjG,gCAAgC,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE;QACN,MAAM,EAAE,aAAa,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB;6EACqE;QACrE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;KACjE,CAAC;CACL;sCAgDkB,mBAAmB,WACjB,oBAAoB,WACpB,kBAAkB,KAC5B,OAAO,CAAC,IAAI,CAAC;EAibvB"}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
releaseCompartmentLeaseBestEffort,
|
|
9
9
|
getCompartments,
|
|
10
10
|
getLastCompartmentEndMessage
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-wgbp5zch.js";
|
|
12
12
|
import {
|
|
13
13
|
inRootAsyncContext2
|
|
14
14
|
} from "./index-gzy5w8ya.js";
|
|
@@ -34,14 +34,14 @@ import {
|
|
|
34
34
|
getActiveCompartmentRun,
|
|
35
35
|
markActiveCompartmentRunPublished,
|
|
36
36
|
registerActiveCompartmentRun
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-3jeq08jv.js";
|
|
38
38
|
import {
|
|
39
39
|
sendStatusNotification2
|
|
40
40
|
} from "./index-r9agn061.js";
|
|
41
41
|
import {
|
|
42
42
|
setRecompStarting2,
|
|
43
43
|
setRecompTerminal2
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-5483ntzh.js";
|
|
45
45
|
|
|
46
46
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
|
47
47
|
import * as crypto from "node:crypto";
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-wgbp5zch.js";
|
|
11
11
|
import {
|
|
12
12
|
executeContextRecomp
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-3jeq08jv.js";
|
|
14
14
|
import {
|
|
15
15
|
renderUserFacingFailure,
|
|
16
16
|
userFacingFailureCode
|
|
@@ -194,7 +194,7 @@ import {
|
|
|
194
194
|
snapRangeToCompartments,
|
|
195
195
|
getActiveCompartmentRun,
|
|
196
196
|
startCompartmentAgent
|
|
197
|
-
} from "./index-
|
|
197
|
+
} from "./index-3jeq08jv.js";
|
|
198
198
|
import {
|
|
199
199
|
hasTrustedAbsoluteWall,
|
|
200
200
|
applyProvenInputFloor,
|
|
@@ -568,7 +568,7 @@ import {
|
|
|
568
568
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
569
569
|
getProjectState,
|
|
570
570
|
bumpProjectUserProfileVersion
|
|
571
|
-
} from "./index-
|
|
571
|
+
} from "./index-wgbp5zch.js";
|
|
572
572
|
import {
|
|
573
573
|
getLastIndexedOrdinal
|
|
574
574
|
} from "./index-h62j8z2r.js";
|
|
@@ -721,7 +721,7 @@ import {
|
|
|
721
721
|
import {
|
|
722
722
|
setRecompStarting2,
|
|
723
723
|
setRecompTerminal2
|
|
724
|
-
} from "./index-
|
|
724
|
+
} from "./index-5483ntzh.js";
|
|
725
725
|
import {
|
|
726
726
|
makeToolCompositeKey,
|
|
727
727
|
searchMessageHistoryOffThread,
|
|
@@ -806,7 +806,7 @@ import {
|
|
|
806
806
|
abortSessionFailClosed2,
|
|
807
807
|
evaluateEmergencyFailClosed2,
|
|
808
808
|
runPostTransformPhase2
|
|
809
|
-
} from "./index-
|
|
809
|
+
} from "./index-pxfb7pp8.js";
|
|
810
810
|
import {
|
|
811
811
|
ANNOUNCEMENT_VERSION2,
|
|
812
812
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -824,10 +824,10 @@ import {
|
|
|
824
824
|
} from "./index-5gqszjq9.js";
|
|
825
825
|
import {
|
|
826
826
|
readV2ArchiveOffThread2
|
|
827
|
-
} from "./index-
|
|
827
|
+
} from "./index-qfc1kjh4.js";
|
|
828
828
|
import {
|
|
829
829
|
renderSearchArchiveOffThread2
|
|
830
|
-
} from "./index-
|
|
830
|
+
} from "./index-12p4j9wa.js";
|
|
831
831
|
import {
|
|
832
832
|
COMPACTION_ENABLED_PATH,
|
|
833
833
|
isDreamerRunnable,
|
|
@@ -14580,14 +14580,16 @@ var HTTP_COOKIES_TYPE_ID = "~effect/http/Cookies";
|
|
|
14580
14580
|
var HTTP_BODY_TYPE_ID = "~effect/http/HttpBody";
|
|
14581
14581
|
var ERROR_REPORTER_IGNORE = "~effect/ErrorReporter/ignore";
|
|
14582
14582
|
function throwSentinel(command) {
|
|
14583
|
-
const
|
|
14584
|
-
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14583
|
+
const fields = {
|
|
14584
|
+
[HTTP_SERVER_RESPONSE_TYPE_ID]: HTTP_SERVER_RESPONSE_TYPE_ID,
|
|
14585
|
+
[ERROR_REPORTER_IGNORE]: true,
|
|
14586
|
+
status: 204,
|
|
14587
|
+
statusText: undefined,
|
|
14588
|
+
headers: {},
|
|
14589
|
+
cookies: { [HTTP_COOKIES_TYPE_ID]: HTTP_COOKIES_TYPE_ID, cookies: {} },
|
|
14590
|
+
body: { [HTTP_BODY_TYPE_ID]: HTTP_BODY_TYPE_ID, _tag: "Empty" }
|
|
14591
|
+
};
|
|
14592
|
+
const sentinel = Object.assign(new Error(`${SENTINEL_PREFIX}${command.toUpperCase()}_HANDLED__`), fields);
|
|
14591
14593
|
throw sentinel;
|
|
14592
14594
|
}
|
|
14593
14595
|
function getLegacyCompartmentCount(db, sessionId) {
|
|
@@ -16446,7 +16448,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16446
16448
|
const db = readDatabase();
|
|
16447
16449
|
if (!db)
|
|
16448
16450
|
return { ok: false, error: "db unavailable" };
|
|
16449
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16451
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-2tsjqbrm.js"));
|
|
16450
16452
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-gamjee2f.js"));
|
|
16451
16453
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16452
16454
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -16531,7 +16533,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16531
16533
|
const db = readDatabase();
|
|
16532
16534
|
if (!db)
|
|
16533
16535
|
return { ok: false, error: "db unavailable" };
|
|
16534
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16536
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-21hgybdk.js"));
|
|
16535
16537
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16536
16538
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16537
16539
|
const ctx = {
|
|
@@ -224,7 +224,7 @@ import {
|
|
|
224
224
|
saveSourceContent,
|
|
225
225
|
replaceSourceContent,
|
|
226
226
|
getSourceContents
|
|
227
|
-
} from "./index-
|
|
227
|
+
} from "./index-wgbp5zch.js";
|
|
228
228
|
import {
|
|
229
229
|
cleanSearchText,
|
|
230
230
|
matchedSearchSnippet
|
|
@@ -281,7 +281,7 @@ import {
|
|
|
281
281
|
peekNoteNudgeText,
|
|
282
282
|
markNoteNudgeDelivered,
|
|
283
283
|
getActiveCompartmentRun
|
|
284
|
-
} from "./index-
|
|
284
|
+
} from "./index-3jeq08jv.js";
|
|
285
285
|
import {
|
|
286
286
|
userFacingFailureCode
|
|
287
287
|
} from "./index-pdh4tdcq.js";
|
|
@@ -140,8 +140,8 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
140
140
|
import("./store-reader-3eh1s1m8.js"),
|
|
141
141
|
import("./store-h20ny8b8.js"),
|
|
142
142
|
import("./read-session-chunk-70aam2c1.js"),
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
143
|
+
import("./render-fgxbcmnh.js"),
|
|
144
|
+
import("./search-archive-0mz3p1g1.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -1231,6 +1231,12 @@ function resolveIsSubagentFromOpenCode2Db(sessionId) {
|
|
|
1231
1231
|
}
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
|
+
// src/features/magic-context/pi-identity-fold-guards.ts
|
|
1235
|
+
var PI_IDENTITY_FOLD_GUARD_PREFIX = "pi_identity_fold_guards:";
|
|
1236
|
+
function piIdentityFoldGuardKey(sessionId) {
|
|
1237
|
+
return `${PI_IDENTITY_FOLD_GUARD_PREFIX}${sessionId}`;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1234
1240
|
// src/features/magic-context/storage-session-tables.ts
|
|
1235
1241
|
var SESSION_SCOPED_TABLES = [
|
|
1236
1242
|
{ table: "pending_ops", harnessScoped: true },
|
|
@@ -1347,6 +1353,9 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
1347
1353
|
statement.run(...deletableSessionIds);
|
|
1348
1354
|
}
|
|
1349
1355
|
deleteSessionActivity(db, deletableSessionIds);
|
|
1356
|
+
const deleteFoldGuards = cleanupStatement(db, "DELETE FROM schema_migrations_meta WHERE key = ? AND NOT EXISTS (SELECT 1 FROM session_meta WHERE session_id = ?)");
|
|
1357
|
+
for (const id of deletableSessionIds)
|
|
1358
|
+
deleteFoldGuards.run(piIdentityFoldGuardKey(id), id);
|
|
1350
1359
|
if (!options.preserveTagRevisionTombstones) {
|
|
1351
1360
|
const retireOwner = cleanupStatement(db, harness === undefined ? "DELETE FROM schema_migrations_meta WHERE key >= ? AND key < ?" : "DELETE FROM schema_migrations_meta WHERE key = ?");
|
|
1352
1361
|
const survivingRows = harnessTables.map((definition) => `EXISTS (SELECT 1 FROM ${definition.table} WHERE session_id = ?${definition.extraPredicate ? ` AND ${definition.extraPredicate}` : ""})`).join(" OR ");
|