@retaw106/mmc-oc 2.3.0 → 2.5.0
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/cli.js +12 -1
- package/dist/config/schema/magic-context.d.ts +33 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/config-init.js +12 -1
- package/dist/{context-wt7g4f8k.js → context-xx09sh1g.js} +1985 -603
- package/dist/features/magic-context/memory-maintainer/launcher.d.ts +13 -4
- package/dist/features/magic-context/memory-maintainer/launcher.d.ts.map +1 -1
- package/dist/features/magic-context/memory-maintainer/manual-commands.d.ts.map +1 -1
- package/dist/features/magic-context/memory-maintainer/model-chain.d.ts +47 -0
- package/dist/features/magic-context/memory-maintainer/model-chain.d.ts.map +1 -0
- package/dist/features/magic-context/memory-maintainer/oc2-adapter.d.ts +17 -4
- package/dist/features/magic-context/memory-maintainer/oc2-adapter.d.ts.map +1 -1
- package/dist/features/magic-context/memory-maintainer/pipeline.d.ts +6 -0
- package/dist/features/magic-context/memory-maintainer/pipeline.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +6 -2
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +5 -8
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +5 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -0
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts +4 -0
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +4 -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/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts +34 -0
- package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts.map +1 -0
- package/dist/hooks/magic-context/apply-operations.d.ts +3 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +4 -0
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts +11 -0
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +1 -0
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
- package/dist/hooks/magic-context/degraded-pass-refusal.d.ts +2 -0
- package/dist/hooks/magic-context/degraded-pass-refusal.d.ts.map +1 -1
- package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
- package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
- package/dist/hooks/magic-context/edit-marker.d.ts +2 -0
- package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/file-token-coverage.d.ts +11 -0
- package/dist/hooks/magic-context/file-token-coverage.d.ts.map +1 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +10 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
- package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts +2 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-drop-eligibility.d.ts +14 -0
- package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/provider-visible-parts.d.ts +10 -4
- package/dist/hooks/magic-context/provider-visible-parts.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/render-options.d.ts +19 -0
- package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +5 -3
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-date-refresh.d.ts +3 -2
- package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +4 -0
- package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +15 -2
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +18 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +8 -4
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +2 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts +3 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-reclaim.d.ts +5 -2
- package/dist/hooks/magic-context/tool-reclaim.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-postprocess-phase.d.ts +8 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +4 -9
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +5 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
- package/dist/{index-kw21z5pe.js → index-0d40b4q8.js} +17119 -16569
- package/dist/{index-z2w1eq3y.js → index-1vxffj5j.js} +558 -211
- package/dist/{index-z2g20msd.js → index-azbmnekv.js} +4 -4
- package/dist/{index-18yrysyj.js → index-bpjjcdy9.js} +1 -1
- package/dist/{index-a5mw0xp3.js → index-k25thxq7.js} +1 -1
- package/dist/{index-3gj1ak4c.js → index-mjf0p7yq.js} +1 -1
- package/dist/{index-czba8tw3.js → index-pte3cfs9.js} +226 -14
- package/dist/index.js +2 -2
- package/dist/{message-time-backfill-sykevdax.js → message-time-backfill-g9py24yt.js} +1 -1
- package/dist/model-resolution-cvyrrcjw.js +8 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts +4 -0
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
- package/dist/{read-session-chunk-863d6c06.js → read-session-chunk-eb3fy45y.js} +3 -3
- package/dist/{recomp-orchestrator-wrjy3qym.js → recomp-orchestrator-mmpy5cb7.js} +6 -6
- package/dist/{send-session-notification-cz6ev088.js → send-session-notification-zpqs213d.js} +3 -3
- package/dist/shared/model-suggestion-retry.d.ts +23 -0
- package/dist/shared/model-suggestion-retry.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/shared/reclaim-distance.d.ts +33 -0
- package/dist/shared/reclaim-distance.d.ts.map +1 -0
- package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
- package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts +2 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/search-text.d.ts +8 -0
- package/dist/shared/search-text.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +8 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/stable-json.d.ts +7 -0
- package/dist/shared/stable-json.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/shared/system-directive.d.ts +2 -0
- package/dist/shared/system-directive.d.ts.map +1 -1
- package/dist/shared/tail-hygiene-json.d.ts +22 -0
- package/dist/shared/tail-hygiene-json.d.ts.map +1 -0
- package/dist/shared/user-facing-codes.d.ts +2 -2
- package/dist/v2/fold/native-replay.d.ts +11 -2
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/policy.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hidden-completion.d.ts +20 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/generate.d.ts +36 -1
- package/dist/v2/hooks/generate.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +22 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/lkg-system.d.ts +35 -4
- package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +10 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +2 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +12 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/server.js +16272 -13742
- package/dist/v2/store-reader.d.ts +38 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/web/main.js +262 -17
- package/dist/{wrapup-orchestrator-bmybc5p5.js → wrapup-orchestrator-jq589pgr.js} +6 -6
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +8 -0
- package/src/config/project-security.test.ts +17 -0
- package/src/config/schema/magic-context.test.ts +50 -0
- package/src/config/schema/magic-context.ts +34 -1
- package/src/shared/model-suggestion-retry.test.ts +52 -0
- package/src/shared/model-suggestion-retry.ts +13 -4
- package/src/shared/prompt-surface-runtime.ts +12 -0
- package/src/shared/reclaim-distance.test.ts +111 -0
- package/src/shared/reclaim-distance.ts +91 -0
- package/src/shared/root-async-context.probe.mjs +36 -0
- package/src/shared/root-async-context.test.ts +49 -0
- package/src/shared/rpc-discovery-cleanup.test.ts +125 -0
- package/src/shared/rpc-discovery-cleanup.ts +57 -0
- package/src/shared/rpc-server.ts +36 -13
- package/src/shared/search-text.test.ts +30 -0
- package/src/shared/search-text.ts +62 -0
- package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
- package/src/shared/sqlite-foreground-wait.test.ts +237 -1
- package/src/shared/sqlite-turn-deadline.test.ts +286 -0
- package/src/shared/sqlite.ts +292 -23
- package/src/shared/stable-json.ts +56 -14
- package/src/shared/storage-file-mutex.test.ts +51 -2
- package/src/shared/storage-file-mutex.ts +11 -1
- package/src/shared/system-directive.test.ts +37 -0
- package/src/shared/system-directive.ts +19 -1
- package/src/shared/tag-transcript.ts +16 -4
- package/src/shared/tail-hygiene-json.test.ts +117 -0
- package/src/shared/tail-hygiene-json.ts +217 -0
- package/src/shared/user-facing-codes.ts +2 -2
- package/dist/model-resolution-wazv26n0.js +0 -6
|
@@ -110,18 +110,45 @@ interface ReaderConnection {
|
|
|
110
110
|
}
|
|
111
111
|
/** Boot-scoped read-only handles. Each lease still closes in the caller's finally block.
|
|
112
112
|
* Statements, not results, are cached: WAL updates are visible on the next query.
|
|
113
|
-
* A replaced/missing file cannot reuse the old inode, and disposal releases all handles.
|
|
113
|
+
* A replaced/missing file cannot reuse the old inode, and disposal releases all handles.
|
|
114
|
+
*
|
|
115
|
+
* Work that opens readers over a long time (a hidden run polls the store for its whole
|
|
116
|
+
* lifetime) takes a `hold()`. Closing the pool while a hold is outstanding only marks it
|
|
117
|
+
* closing: readers can still be opened, and the pool closes when the last hold is
|
|
118
|
+
* released. Without that, disposing the plugin instance mid-run made the run's next poll
|
|
119
|
+
* fail with "Store reader pool is closed". */
|
|
114
120
|
export declare class V2StoreReaderPool {
|
|
115
121
|
private readonly capacity;
|
|
116
122
|
private readonly connections;
|
|
117
123
|
private closed;
|
|
124
|
+
private closing;
|
|
125
|
+
private holds;
|
|
126
|
+
private readonly idleWaiters;
|
|
118
127
|
constructor(capacity?: number);
|
|
119
128
|
open(path: string): V2StoreReader;
|
|
120
129
|
acquire(path: string): ReaderConnection;
|
|
121
130
|
release(connection: ReaderConnection): void;
|
|
122
131
|
private retire;
|
|
132
|
+
/**
|
|
133
|
+
* Keep the pool open until the returned release is called. Refused once the pool is
|
|
134
|
+
* closing or closed, so a close always finishes once the existing holders are done.
|
|
135
|
+
*/
|
|
136
|
+
hold(): () => void;
|
|
137
|
+
/** True once every handle is closed and no further reader can be opened. */
|
|
138
|
+
isClosed(): boolean;
|
|
139
|
+
/** Number of outstanding holds. */
|
|
140
|
+
holdCount(): number;
|
|
141
|
+
/** Close now when nothing holds the pool; otherwise close after the last hold is released. */
|
|
123
142
|
close(): void;
|
|
143
|
+
/**
|
|
144
|
+
* `close()`, then wait at most `timeoutMs` for the pool to actually close. Resolves
|
|
145
|
+
* true when it closed within the wait. On false the pool is still closing and will
|
|
146
|
+
* close when its last hold is released; the caller is not kept waiting for that.
|
|
147
|
+
*/
|
|
148
|
+
closeWhenIdle(timeoutMs: number): Promise<boolean>;
|
|
149
|
+
private finishClose;
|
|
124
150
|
}
|
|
151
|
+
export declare function messageTimesQuery(count: number): string;
|
|
125
152
|
/** Opens an existing store read-only; missing/corrupt stores propagate errors, never an empty history. */
|
|
126
153
|
export declare class V2StoreReader {
|
|
127
154
|
private readonly path;
|
|
@@ -158,6 +185,8 @@ export declare class V2StoreReader {
|
|
|
158
185
|
*/
|
|
159
186
|
messagePage(sessionID: string, afterOrdinal: number, limit: number, finalWatermark: number, after?: RawMessageOrdinalAnchor): StoreRow[];
|
|
160
187
|
messageCount(sessionID: string): number;
|
|
188
|
+
/** Count only appended conversational rows, using the host's session/sequence index. */
|
|
189
|
+
messageCountAfterSequence(sessionID: string, after: number, through: number): number;
|
|
161
190
|
/**
|
|
162
191
|
* One page of host sessions with the directory each was created in, in
|
|
163
192
|
* ascending id order after `afterSessionID` (exclusive; null starts at the
|
|
@@ -170,6 +199,8 @@ export declare class V2StoreReader {
|
|
|
170
199
|
latestMessageTime(sessionID: string): number | undefined;
|
|
171
200
|
/** Parent links are recorded by the host before a child's first context pass. */
|
|
172
201
|
isSubagent(sessionID: string): boolean | null;
|
|
202
|
+
/** Authoritative liveness snapshot for background orphan cleanup. */
|
|
203
|
+
sessionIds(): string[];
|
|
173
204
|
/** Count session_message rows after a sequence. This counts stored rows, not
|
|
174
205
|
* model messages: it includes idle rows (OpenCode's marker that a run finished)
|
|
175
206
|
* and compaction rows (checkpoints), and one stored assistant row can render as
|
|
@@ -178,6 +209,10 @@ export declare class V2StoreReader {
|
|
|
178
209
|
storedRowsAfter(sessionID: string, after: number): number;
|
|
179
210
|
storedMessageCount(sessionID: string): number;
|
|
180
211
|
messageById(sessionID: string, id: string): StoreRow | null;
|
|
212
|
+
messageTimes(sessionID: string, ids: readonly string[]): Map<string, {
|
|
213
|
+
created?: number;
|
|
214
|
+
completed?: number;
|
|
215
|
+
}>;
|
|
181
216
|
messageExistsById(sessionID: string, id: string): boolean;
|
|
182
217
|
messageOrdinalById(sessionID: string, id: string): number | null;
|
|
183
218
|
messageIdOrdinals(sessionID: string, fromOrdinal: number, toOrdinal: number): Map<string, number>;
|
|
@@ -193,6 +228,8 @@ export declare class V2StoreReader {
|
|
|
193
228
|
spanRowStamps(sessionID: string, after: number, through: number): Map<number, string>;
|
|
194
229
|
/** Conversational rows at or before `throughSeq`, newest first. */
|
|
195
230
|
rawRowsThrough(sessionID: string, throughSeq: number, limit: number): StoreRow[];
|
|
231
|
+
/** Instruction updates covered by a checkpoint, in host sequence order. */
|
|
232
|
+
instructionRowsThrough(sessionID: string, throughSeq: number): StoreRow[];
|
|
196
233
|
sequenceForId(sessionID: string, id: string | null | undefined): number | undefined;
|
|
197
234
|
/** Native synthetics are user-shaped on the wire; their store kind is unambiguous. */
|
|
198
235
|
syntheticMessageIDs(sessionID: string): Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-reader.d.ts","sourceRoot":"","sources":["../../src/v2/store-reader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAMvF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,yFAAyF;AACzF,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,SAAW,EAClB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACrC,MAAM,CAER;AAGD,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,mBAAmB,GACnB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,OAAO,GACP,OAAO,GACP,WAAW,GACX,YAAY,GACZ,MAAM,CAAC;AAEb,eAAO,MAAM,iBAAiB,yEAOa,CAAC;AAI5C,eAAO,MAAM,mBAAmB,QAkBP,CAAC;AAC1B,MAAM,WAAW,WAAW;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC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,CAAC,MAAM,CAAC,GAAG,SAAS;IAU3D,8EAA8E;IAC9E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IAWrC;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ,EAAE;IAItC,OAAO,CAAC,GAAG;CAcd"}
|
package/dist/web/main.js
CHANGED
|
@@ -446,7 +446,10 @@ var init_logger = __esm(() => {
|
|
|
446
446
|
});
|
|
447
447
|
|
|
448
448
|
// src/shared/sqlite.ts
|
|
449
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
449
|
+
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
450
|
+
function inRootAsyncContext(operation) {
|
|
451
|
+
return resourceRoot.runInAsyncScope(operation);
|
|
452
|
+
}
|
|
450
453
|
function registerSlowWriteReporter(reporter) {
|
|
451
454
|
reportSlowPrivilegedWrite = reporter;
|
|
452
455
|
}
|
|
@@ -569,6 +572,174 @@ function topLevelCommaSegments(text) {
|
|
|
569
572
|
segments.push(text.slice(start));
|
|
570
573
|
return segments;
|
|
571
574
|
}
|
|
575
|
+
function literalBusyTimeout(sql) {
|
|
576
|
+
const head = BUSY_TIMEOUT_SETTER.exec(sql);
|
|
577
|
+
if (!head)
|
|
578
|
+
return;
|
|
579
|
+
const match = /^(?:=\s*|\(\s*)(?:'(-?\d+)'|"(-?\d+)"|(-?\d+))\s*\)?\s*;?\s*$/.exec(sql.slice(head[0].length));
|
|
580
|
+
if (!match)
|
|
581
|
+
return;
|
|
582
|
+
const value = Number(match[1] ?? match[2] ?? match[3]);
|
|
583
|
+
return value < 0 ? 0 : value <= 2147483647 ? value : undefined;
|
|
584
|
+
}
|
|
585
|
+
function busyTimeoutStatements(sql) {
|
|
586
|
+
const statements = [];
|
|
587
|
+
let statement = "";
|
|
588
|
+
let quote = "";
|
|
589
|
+
for (let i = 0;i < sql.length; i++) {
|
|
590
|
+
const char = sql[i];
|
|
591
|
+
if (quote) {
|
|
592
|
+
statement += char;
|
|
593
|
+
if (char === quote) {
|
|
594
|
+
if (sql[i + 1] === quote)
|
|
595
|
+
statement += sql[++i];
|
|
596
|
+
else
|
|
597
|
+
quote = "";
|
|
598
|
+
}
|
|
599
|
+
} else if (char === "'" || char === '"' || char === "`" || char === "[") {
|
|
600
|
+
quote = char === "[" ? "]" : char;
|
|
601
|
+
statement += char;
|
|
602
|
+
} else if (char === "-" && sql[i + 1] === "-") {
|
|
603
|
+
while (i + 1 < sql.length && sql[i + 1] !== `
|
|
604
|
+
`)
|
|
605
|
+
i++;
|
|
606
|
+
statement += " ";
|
|
607
|
+
} else if (char === "/" && sql[i + 1] === "*") {
|
|
608
|
+
i += 2;
|
|
609
|
+
while (i < sql.length && !(sql[i] === "*" && sql[i + 1] === "/"))
|
|
610
|
+
i++;
|
|
611
|
+
i++;
|
|
612
|
+
statement += " ";
|
|
613
|
+
} else if (char === ";") {
|
|
614
|
+
statements.push(statement);
|
|
615
|
+
statement = "";
|
|
616
|
+
} else
|
|
617
|
+
statement += char;
|
|
618
|
+
}
|
|
619
|
+
statements.push(statement);
|
|
620
|
+
return statements.filter((part) => part.trim().length > 0);
|
|
621
|
+
}
|
|
622
|
+
function installNativeDeadlineRouting(db) {
|
|
623
|
+
const rawExec = db.exec.bind(db);
|
|
624
|
+
const rawPrepare = db.prepare.bind(db);
|
|
625
|
+
const readTimeout = () => {
|
|
626
|
+
const statement = rawPrepare("PRAGMA busy_timeout");
|
|
627
|
+
try {
|
|
628
|
+
return Object.values(statement.get())[0];
|
|
629
|
+
} finally {
|
|
630
|
+
statement.finalize?.();
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
const timeoutState = { current: readTimeout() };
|
|
634
|
+
busyTimeoutStates.set(db, timeoutState);
|
|
635
|
+
const setBusyTimeout = (timeout) => {
|
|
636
|
+
rawExec(`PRAGMA busy_timeout=${timeout}`);
|
|
637
|
+
timeoutState.current = timeout;
|
|
638
|
+
};
|
|
639
|
+
const withinDeadline = (operation) => {
|
|
640
|
+
const deadline = nativeWaitScope?.getStore();
|
|
641
|
+
if (!deadline?.active || !deadline.remainingMs)
|
|
642
|
+
return operation();
|
|
643
|
+
const remaining = deadline.remainingMs();
|
|
644
|
+
if (remaining === Infinity)
|
|
645
|
+
return operation();
|
|
646
|
+
const previous = timeoutState.current;
|
|
647
|
+
const timeout = Math.min(previous, Math.max(0, Math.floor(remaining)));
|
|
648
|
+
if (timeout === previous)
|
|
649
|
+
return operation();
|
|
650
|
+
setBusyTimeout(timeout);
|
|
651
|
+
try {
|
|
652
|
+
return operation();
|
|
653
|
+
} finally {
|
|
654
|
+
setBusyTimeout(previous);
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
Object.defineProperty(db, "exec", {
|
|
658
|
+
configurable: true,
|
|
659
|
+
writable: true,
|
|
660
|
+
value: (sql) => {
|
|
661
|
+
const parts = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql) : [];
|
|
662
|
+
if (parts.length === 1 && BUSY_TIMEOUT_QUERY.test(parts[0]))
|
|
663
|
+
return rawExec(sql);
|
|
664
|
+
const singleSetter = parts.length === 1 && BUSY_TIMEOUT_SETTER.test(parts[0]);
|
|
665
|
+
const setting = singleSetter ? literalBusyTimeout(parts[0]) : undefined;
|
|
666
|
+
if (singleSetter) {
|
|
667
|
+
const result = rawExec(sql);
|
|
668
|
+
timeoutState.current = setting ?? readTimeout();
|
|
669
|
+
return result;
|
|
670
|
+
}
|
|
671
|
+
if (!/\bbusy_timeout\b/i.test(sql))
|
|
672
|
+
return withinDeadline(() => rawExec(sql));
|
|
673
|
+
const setters = parts.filter((part) => BUSY_TIMEOUT_SETTER.test(part));
|
|
674
|
+
return withinDeadline(() => {
|
|
675
|
+
try {
|
|
676
|
+
const result = rawExec(sql);
|
|
677
|
+
if (setters.length)
|
|
678
|
+
timeoutState.current = literalBusyTimeout(setters[setters.length - 1]) ?? readTimeout();
|
|
679
|
+
return result;
|
|
680
|
+
} catch (error) {
|
|
681
|
+
if (setters.length)
|
|
682
|
+
timeoutState.current = readTimeout();
|
|
683
|
+
throw error;
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
const nativePrepare = (sql) => BUSY_TIMEOUT_QUERY.test(sql) || BUSY_TIMEOUT_SETTER.test(sql) ? rawPrepare(sql) : withinDeadline(() => rawPrepare(sql));
|
|
689
|
+
Object.defineProperty(db, "prepare", {
|
|
690
|
+
configurable: true,
|
|
691
|
+
writable: true,
|
|
692
|
+
value: (sql) => {
|
|
693
|
+
const statement = nativePrepare(sql);
|
|
694
|
+
const normalized = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql)[0] ?? sql : sql;
|
|
695
|
+
const setting = literalBusyTimeout(normalized);
|
|
696
|
+
const timeoutSetter = BUSY_TIMEOUT_SETTER.test(normalized);
|
|
697
|
+
const timeoutQuery = BUSY_TIMEOUT_QUERY.test(normalized);
|
|
698
|
+
if (timeoutSetter)
|
|
699
|
+
timeoutState.current = setting ?? readTimeout();
|
|
700
|
+
for (const method of ["run", "get", "all", "values"]) {
|
|
701
|
+
const execute = statement[method]?.bind(statement);
|
|
702
|
+
if (!execute)
|
|
703
|
+
continue;
|
|
704
|
+
Object.defineProperty(statement, method, {
|
|
705
|
+
configurable: true,
|
|
706
|
+
value: (...args) => {
|
|
707
|
+
if (timeoutQuery)
|
|
708
|
+
return execute(...args);
|
|
709
|
+
if (!timeoutSetter)
|
|
710
|
+
return withinDeadline(() => execute(...args));
|
|
711
|
+
const result = execute(...args);
|
|
712
|
+
timeoutState.current = readTimeout();
|
|
713
|
+
return result;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
if (typeof statement.iterate === "function") {
|
|
718
|
+
const iterate = statement.iterate.bind(statement);
|
|
719
|
+
Object.defineProperty(statement, "iterate", {
|
|
720
|
+
configurable: true,
|
|
721
|
+
value: (...args) => {
|
|
722
|
+
const iterator = !timeoutSetter && !timeoutQuery ? withinDeadline(() => iterate(...args)) : iterate(...args);
|
|
723
|
+
const next = iterator.next.bind(iterator);
|
|
724
|
+
if (timeoutSetter)
|
|
725
|
+
timeoutState.current = readTimeout();
|
|
726
|
+
iterator.next = () => {
|
|
727
|
+
if (timeoutQuery)
|
|
728
|
+
return next();
|
|
729
|
+
if (!timeoutSetter)
|
|
730
|
+
return withinDeadline(next);
|
|
731
|
+
const result = next();
|
|
732
|
+
timeoutState.current = readTimeout();
|
|
733
|
+
return result;
|
|
734
|
+
};
|
|
735
|
+
return iterator;
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
return statement;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
572
743
|
function installTransactionRouting(db, readonly) {
|
|
573
744
|
const nativeExec = db.exec.bind(db);
|
|
574
745
|
Object.defineProperty(db, "exec", {
|
|
@@ -597,7 +768,7 @@ function installTransactionRouting(db, readonly) {
|
|
|
597
768
|
return endWriterTransaction(db, () => nativeExec(sql), sql);
|
|
598
769
|
if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
|
|
599
770
|
try {
|
|
600
|
-
return withAutocommitTimeout(db, () => nativeExec(sql));
|
|
771
|
+
return withAutocommitTimeout(db, () => nativeExec(sql), false);
|
|
601
772
|
} finally {
|
|
602
773
|
if (mayChangeTagIdentity(sql))
|
|
603
774
|
tagIdentityWriteGeneration += 1;
|
|
@@ -706,7 +877,7 @@ function wrapRemainingTagWriteForms(statement) {
|
|
|
706
877
|
});
|
|
707
878
|
}
|
|
708
879
|
}
|
|
709
|
-
function trackSqliteConnection(db, filename, options) {
|
|
880
|
+
function trackSqliteConnection(db, filename, options, turnDeadlines = false) {
|
|
710
881
|
const originalClose = db.close.bind(db);
|
|
711
882
|
const sequence = nextSqliteConnectionSequence++;
|
|
712
883
|
const metadata = {
|
|
@@ -714,6 +885,8 @@ function trackSqliteConnection(db, filename, options) {
|
|
|
714
885
|
filename: typeof filename === "string" ? filename : Buffer.isBuffer(filename) ? "<buffer>" : ":memory:",
|
|
715
886
|
readonly: Boolean(options) && typeof options === "object" && (options.readonly === true || options.readOnly === true)
|
|
716
887
|
};
|
|
888
|
+
if (turnDeadlines)
|
|
889
|
+
installNativeDeadlineRouting(db);
|
|
717
890
|
installTransactionRouting(db, metadata.readonly);
|
|
718
891
|
Object.defineProperty(db, "close", {
|
|
719
892
|
configurable: true,
|
|
@@ -766,6 +939,11 @@ function pragmaValue(db, name) {
|
|
|
766
939
|
return row[name] ?? Object.values(row)[0];
|
|
767
940
|
}
|
|
768
941
|
function pragmaNumber(db, name) {
|
|
942
|
+
if (name === "busy_timeout") {
|
|
943
|
+
const state = busyTimeoutStates.get(db);
|
|
944
|
+
if (state)
|
|
945
|
+
return state.current;
|
|
946
|
+
}
|
|
769
947
|
try {
|
|
770
948
|
const value = pragmaValue(db, name);
|
|
771
949
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
@@ -839,29 +1017,48 @@ function foregroundWaitLease() {
|
|
|
839
1017
|
const lease = transformPassScope.getStore();
|
|
840
1018
|
return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
|
|
841
1019
|
}
|
|
842
|
-
function withAutocommitTimeout(db, operation) {
|
|
1020
|
+
function withAutocommitTimeout(db, operation, singleStatement = true) {
|
|
843
1021
|
assertTransformWrite();
|
|
844
1022
|
const lease = foregroundWaitLease();
|
|
845
1023
|
if (isInTransaction(db))
|
|
846
1024
|
return operation();
|
|
847
1025
|
const scoped = lease || backgroundWriterScope.getStore();
|
|
848
1026
|
const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
|
|
849
|
-
if (scoped)
|
|
850
|
-
db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
|
|
851
1027
|
const started = performance.now();
|
|
852
1028
|
let completed = false;
|
|
853
|
-
|
|
1029
|
+
const execute = () => {
|
|
854
1030
|
const result = operation();
|
|
855
1031
|
completed = true;
|
|
856
1032
|
return result;
|
|
1033
|
+
};
|
|
1034
|
+
try {
|
|
1035
|
+
if (!scoped)
|
|
1036
|
+
return execute();
|
|
1037
|
+
if (singleStatement) {
|
|
1038
|
+
db.exec("PRAGMA busy_timeout=0");
|
|
1039
|
+
try {
|
|
1040
|
+
return execute();
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
if (!isTransientSqliteError(error) || isInTransaction(db))
|
|
1043
|
+
throw error;
|
|
1044
|
+
}
|
|
1045
|
+
assertTransformWrite();
|
|
1046
|
+
}
|
|
1047
|
+
const timeout = Math.floor(Math.min(lease?.remainingWaitMs ?? SHORT_BUSY_TIMEOUT_MS, lease?.guard?.remainingMs() ?? Infinity));
|
|
1048
|
+
db.exec(`PRAGMA busy_timeout=${timeout}`);
|
|
1049
|
+
const waitStarted = performance.now();
|
|
1050
|
+
try {
|
|
1051
|
+
return execute();
|
|
1052
|
+
} finally {
|
|
1053
|
+
if (lease)
|
|
1054
|
+
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - waitStarted));
|
|
1055
|
+
}
|
|
857
1056
|
} catch (error) {
|
|
858
1057
|
if (lease && isTransientSqliteError(error))
|
|
859
1058
|
throw new SqliteAcquisitionBusyError(error, "autocommit");
|
|
860
1059
|
throw error;
|
|
861
1060
|
} finally {
|
|
862
1061
|
const elapsed = performance.now() - started;
|
|
863
|
-
if (lease)
|
|
864
|
-
lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
|
|
865
1062
|
if (previous !== null)
|
|
866
1063
|
db.exec(`PRAGMA busy_timeout=${previous}`);
|
|
867
1064
|
if (elapsed >= SLOW_WRITER_LOG_MS)
|
|
@@ -935,8 +1132,9 @@ function isInTransaction(db) {
|
|
|
935
1132
|
const candidate = db;
|
|
936
1133
|
return candidate.inTransaction === true || candidate.isTransaction === true;
|
|
937
1134
|
}
|
|
938
|
-
var reportSlowPrivilegedWrite, sqliteDiagnosticSink, sqliteDiagnosticHost = () => "unknown", bunSpec, nodeSpec, SqliteRuntimeUnavailableError, detectedRuntime, isBun, sqliteModule, DatabaseImpl, trackedSqliteConnections, nextSqliteConnectionSequence = 1, TAG_COLUMNS_OUTSIDE_IDENTITY, tagIdentityWriteGeneration = 0, TrackedDatabase, Database, statementOwners, FIRST_PRUNE_AT = 256, privilegeDepth, transformPassScope, admissionScope, backgroundWriterScope, SqliteAcquisitionBusyError, SHORT_BUSY_TIMEOUT_MS = 25, SLOW_WRITER_LOG_MS = 100, WRITER_TRANSACTION_END, writerAcquisitionScope, openWriterTransactions, indexCoordinationKey, indexCoordinationHeap, indexCoordinationBuffer, indexCoordinationState;
|
|
1135
|
+
var resourceRoot, reportSlowPrivilegedWrite, sqliteDiagnosticSink, sqliteDiagnosticHost = () => "unknown", bunSpec, nodeSpec, SqliteRuntimeUnavailableError, detectedRuntime, isBun, sqliteModule, DatabaseImpl, trackedSqliteConnections, nextSqliteConnectionSequence = 1, TAG_COLUMNS_OUTSIDE_IDENTITY, tagIdentityWriteGeneration = 0, busyTimeoutStates, BUSY_TIMEOUT_QUERY, BUSY_TIMEOUT_SETTER, TrackedDatabase, Database, statementOwners, FIRST_PRUNE_AT = 256, privilegeDepth, nativeWaitScope, transformPassScope, admissionScope, backgroundWriterScope, SqliteAcquisitionBusyError, SHORT_BUSY_TIMEOUT_MS = 25, SLOW_WRITER_LOG_MS = 100, WRITER_TRANSACTION_END, writerAcquisitionScope, openWriterTransactions, indexCoordinationKey, indexCoordinationHeap, indexCoordinationBuffer, indexCoordinationState;
|
|
939
1136
|
var init_sqlite = __esm(async () => {
|
|
1137
|
+
resourceRoot = new AsyncResource("magic-context:root");
|
|
940
1138
|
bunSpec = "bun:" + "sqlite";
|
|
941
1139
|
nodeSpec = "node:" + "sqlite";
|
|
942
1140
|
SqliteRuntimeUnavailableError = class SqliteRuntimeUnavailableError extends Error {
|
|
@@ -968,9 +1166,12 @@ var init_sqlite = __esm(async () => {
|
|
|
968
1166
|
"tool_name",
|
|
969
1167
|
"harness"
|
|
970
1168
|
]);
|
|
1169
|
+
busyTimeoutStates = new WeakMap;
|
|
1170
|
+
BUSY_TIMEOUT_QUERY = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*;?\s*$/i;
|
|
1171
|
+
BUSY_TIMEOUT_SETTER = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*(?==|\()/i;
|
|
971
1172
|
TrackedDatabase = new Proxy(DatabaseImpl, {
|
|
972
1173
|
construct(target, args) {
|
|
973
|
-
const db = Reflect.construct(target, args, target);
|
|
1174
|
+
const db = inRootAsyncContext(() => Reflect.construct(target, args, target));
|
|
974
1175
|
return trackSqliteConnection(db, args[0], args[1]);
|
|
975
1176
|
}
|
|
976
1177
|
});
|
|
@@ -4144,6 +4345,12 @@ function closeConnection(connection) {
|
|
|
4144
4345
|
counters.readersClosed += 1;
|
|
4145
4346
|
}
|
|
4146
4347
|
}
|
|
4348
|
+
function messageTimesQuery(count) {
|
|
4349
|
+
return `SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
|
|
4350
|
+
json_extract(data, '$.time.completed') AS completed
|
|
4351
|
+
FROM session_message WHERE +session_id = ? AND id IN (${Array.from({ length: count }, () => "?").join(",")})`;
|
|
4352
|
+
}
|
|
4353
|
+
|
|
4147
4354
|
class V2StoreReader {
|
|
4148
4355
|
path;
|
|
4149
4356
|
pool;
|
|
@@ -4239,6 +4446,12 @@ class V2StoreReader {
|
|
|
4239
4446
|
return typeof row?.count === "number" ? row.count : 0;
|
|
4240
4447
|
});
|
|
4241
4448
|
}
|
|
4449
|
+
messageCountAfterSequence(sessionID, after, through) {
|
|
4450
|
+
const rawTypes = RAW_MESSAGE_TYPES.map(() => "?").join(", ");
|
|
4451
|
+
const row = this.prepare(`SELECT COUNT(*) AS count FROM session_message
|
|
4452
|
+
WHERE session_id = ? AND seq > ? AND seq <= ? AND type IN (${rawTypes})`).get(sessionID, after, through, ...RAW_MESSAGE_TYPES);
|
|
4453
|
+
return typeof row?.count === "number" ? row.count : 0;
|
|
4454
|
+
}
|
|
4242
4455
|
sessionDirectoryPage(afterSessionID, limit) {
|
|
4243
4456
|
const rows = this.prepare(`SELECT id, COALESCE(directory, '') AS directory FROM session_v2
|
|
4244
4457
|
WHERE id > ? ORDER BY id ASC LIMIT ?`).all(afterSessionID ?? "", limit);
|
|
@@ -4254,6 +4467,9 @@ class V2StoreReader {
|
|
|
4254
4467
|
return null;
|
|
4255
4468
|
return typeof row.parent_id === "string" && row.parent_id.length > 0;
|
|
4256
4469
|
}
|
|
4470
|
+
sessionIds() {
|
|
4471
|
+
return this.prepare("SELECT id FROM session_v2").all().map((row) => row.id);
|
|
4472
|
+
}
|
|
4257
4473
|
storedRowsAfter(sessionID, after) {
|
|
4258
4474
|
const row = this.prepare("SELECT COUNT(*) AS count FROM session_message WHERE session_id = ? AND seq > ?").get(sessionID, after);
|
|
4259
4475
|
return row.count;
|
|
@@ -4272,6 +4488,19 @@ class V2StoreReader {
|
|
|
4272
4488
|
return row ? decode(row) : null;
|
|
4273
4489
|
});
|
|
4274
4490
|
}
|
|
4491
|
+
messageTimes(sessionID, ids) {
|
|
4492
|
+
const times = new Map;
|
|
4493
|
+
for (let offset = 0;offset < ids.length; offset += 500) {
|
|
4494
|
+
const batch = ids.slice(offset, offset + 500);
|
|
4495
|
+
const rows = this.prepare(messageTimesQuery(batch.length)).all(sessionID, ...batch);
|
|
4496
|
+
for (const row of rows)
|
|
4497
|
+
times.set(row.id, {
|
|
4498
|
+
created: typeof row.created === "number" ? row.created : undefined,
|
|
4499
|
+
completed: typeof row.completed === "number" ? row.completed : undefined
|
|
4500
|
+
});
|
|
4501
|
+
}
|
|
4502
|
+
return times;
|
|
4503
|
+
}
|
|
4275
4504
|
messageExistsById(sessionID, id) {
|
|
4276
4505
|
return trackDecodeOperation("messageExistsById", () => {
|
|
4277
4506
|
const rawTypes = RAW_MESSAGE_TYPES.map(() => "?").join(", ");
|
|
@@ -4357,6 +4586,14 @@ class V2StoreReader {
|
|
|
4357
4586
|
ORDER BY seq DESC LIMIT ?`).all(sessionID, ...RAW_MESSAGE_TYPES, throughSeq, limit).map(decode);
|
|
4358
4587
|
});
|
|
4359
4588
|
}
|
|
4589
|
+
instructionRowsThrough(sessionID, throughSeq) {
|
|
4590
|
+
return trackDecodeOperation("instructionRowsThrough", () => {
|
|
4591
|
+
if (!Number.isSafeInteger(throughSeq))
|
|
4592
|
+
throw new Error("Invalid seq upper bound");
|
|
4593
|
+
return this.prepare(`SELECT id, session_id, type, seq, time_created, data FROM session_message
|
|
4594
|
+
WHERE session_id = ? AND type = 'system' AND seq <= ? ORDER BY seq ASC`).all(sessionID, throughSeq).map(decode);
|
|
4595
|
+
});
|
|
4596
|
+
}
|
|
4360
4597
|
sequenceForId(sessionID, id) {
|
|
4361
4598
|
if (!id)
|
|
4362
4599
|
return;
|
|
@@ -5150,6 +5387,7 @@ var AGENT_STEP_CAPS = {
|
|
|
5150
5387
|
[MEMORY_MAINTAINER_A_AGENT]: MEMORY_MAINTAINER_A_STEP_CAP,
|
|
5151
5388
|
[HIDDEN_HISTORIAN_AGENT]: HISTORIAN_STEP_CAP
|
|
5152
5389
|
};
|
|
5390
|
+
var DISPOSED_CHILDREN_KEY = Symbol.for("magic-context.v2.disposed-hidden-children");
|
|
5153
5391
|
|
|
5154
5392
|
// src/v2/hidden-child-record.ts
|
|
5155
5393
|
var HIDDEN_CHILD_ROLE_TITLES = {
|
|
@@ -5298,24 +5536,31 @@ ${data.output?.output ?? ""}`
|
|
|
5298
5536
|
const sameModel = sameProvider && previousModel?.id === model.id;
|
|
5299
5537
|
const reuse = sameModel && data.error === undefined;
|
|
5300
5538
|
const metadata = (state) => state === undefined ? undefined : { [model.providerID]: state };
|
|
5539
|
+
const reasoningInterrupted = data.content?.some((part) => part.type === "reasoning" && part.time !== undefined && part.time.completed === undefined);
|
|
5301
5540
|
const content = [];
|
|
5302
5541
|
const results = [];
|
|
5303
5542
|
for (const part of data.content ?? []) {
|
|
5543
|
+
let native = "native" in part ? part.native : part.type === "tool" ? part.providerState : part.state;
|
|
5544
|
+
if (part.type === "tool" && part.providerResultState !== null && typeof part.providerResultState === "object" && !Array.isArray(part.providerResultState))
|
|
5545
|
+
native = {
|
|
5546
|
+
...native !== null && typeof native === "object" && !Array.isArray(native) ? native : {},
|
|
5547
|
+
...part.providerResultState
|
|
5548
|
+
};
|
|
5304
5549
|
if (part.type === "text") {
|
|
5305
5550
|
if (part.text !== "")
|
|
5306
5551
|
content.push({
|
|
5307
5552
|
type: "text",
|
|
5308
5553
|
text: part.text,
|
|
5309
|
-
providerMetadata: reuse ? metadata(
|
|
5554
|
+
providerMetadata: reuse ? metadata(native) : undefined
|
|
5310
5555
|
});
|
|
5311
5556
|
continue;
|
|
5312
5557
|
}
|
|
5313
5558
|
if (part.type === "reasoning") {
|
|
5314
|
-
if (part.text !== "" || reuse &&
|
|
5559
|
+
if (part.text !== "" || reuse && !reasoningInterrupted && native !== undefined)
|
|
5315
5560
|
content.push({
|
|
5316
|
-
type:
|
|
5561
|
+
type: data.error === undefined && !reasoningInterrupted ? "reasoning" : "text",
|
|
5317
5562
|
text: part.text,
|
|
5318
|
-
providerMetadata: reuse ? metadata(
|
|
5563
|
+
providerMetadata: reuse && !reasoningInterrupted ? metadata(native) : undefined
|
|
5319
5564
|
});
|
|
5320
5565
|
continue;
|
|
5321
5566
|
}
|
|
@@ -5334,7 +5579,7 @@ ${data.output?.output ?? ""}`
|
|
|
5334
5579
|
name: part.name,
|
|
5335
5580
|
input,
|
|
5336
5581
|
providerExecuted: part.executed,
|
|
5337
|
-
providerMetadata: toolReuse ? metadata(
|
|
5582
|
+
providerMetadata: toolReuse ? metadata(native) : undefined
|
|
5338
5583
|
});
|
|
5339
5584
|
if (!completed)
|
|
5340
5585
|
continue;
|
|
@@ -5345,7 +5590,7 @@ ${data.output?.output ?? ""}`
|
|
|
5345
5590
|
id: part.id,
|
|
5346
5591
|
name: part.name,
|
|
5347
5592
|
providerExecuted: part.executed,
|
|
5348
|
-
providerMetadata:
|
|
5593
|
+
providerMetadata: (part.executed === true ? sameProvider : reuse) ? metadata(native) : undefined,
|
|
5349
5594
|
result: state.status === "error" ? { error: state.error, content: toolContent } : single?.type === "text" ? { type: "text", value: single.text } : { type: "content", value: toolContent },
|
|
5350
5595
|
...state.status === "error" ? { resultType: "error" } : {}
|
|
5351
5596
|
};
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
getActiveCompartmentRun,
|
|
22
22
|
markActiveCompartmentRunPublished,
|
|
23
23
|
registerActiveCompartmentRun
|
|
24
|
-
} from "./index-
|
|
25
|
-
import"./index-
|
|
24
|
+
} from "./index-0d40b4q8.js";
|
|
25
|
+
import"./index-pte3cfs9.js";
|
|
26
26
|
import"./index-x37vg474.js";
|
|
27
|
-
import"./index-
|
|
28
|
-
import"./index-
|
|
27
|
+
import"./index-1vxffj5j.js";
|
|
28
|
+
import"./index-bpjjcdy9.js";
|
|
29
29
|
import {
|
|
30
30
|
pushNotification2
|
|
31
31
|
} from "./index-jdxxq8cz.js";
|
|
@@ -33,11 +33,11 @@ import"./index-5ty9rnbx.js";
|
|
|
33
33
|
import"./index-kmbme1v1.js";
|
|
34
34
|
import {
|
|
35
35
|
sendStatusNotification2
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-k25thxq7.js";
|
|
37
37
|
import {
|
|
38
38
|
setRecompStarting2,
|
|
39
39
|
setRecompTerminal2
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-mjf0p7yq.js";
|
|
41
41
|
import"./index-yjv8dpht.js";
|
|
42
42
|
|
|
43
43
|
// src/hooks/magic-context/wrapup-orchestrator.ts
|
package/package.json
CHANGED
|
@@ -153,6 +153,14 @@ const KNOWN_SLOTS: Record<string, KnownSlot> = {
|
|
|
153
153
|
classification: "DIAGNOSTIC",
|
|
154
154
|
reason: "Most-recent diagnostic: every open attempt clears or overwrites it.",
|
|
155
155
|
},
|
|
156
|
+
"packages/pi-plugin/src/index.ts:loggedPiMaintenanceModelMissing": {
|
|
157
|
+
classification: "PUBLICATION",
|
|
158
|
+
reason: "Once-per-process log dedup only (plan 18): the unconfigured-maintenance diagnosis is logged once to avoid per-pass spam. It gates no behavior — buildPiMaintenanceOptions re-evaluates the model chain on every call.",
|
|
159
|
+
},
|
|
160
|
+
"packages/pi-plugin/src/pi-append-compaction.ts:loggedIncompatibleHost": {
|
|
161
|
+
classification: "PUBLICATION",
|
|
162
|
+
reason: "Once-per-process diagnostic dedup only: each adapter call rechecks host arity and getEntry; this flag suppresses only repeated logs, never a compatible binding.",
|
|
163
|
+
},
|
|
156
164
|
"packages/plugin/src/shared/models-dev-cache.ts:apiCache": {
|
|
157
165
|
classification: "PUBLICATION",
|
|
158
166
|
reason: "Publishes last-known-good model metadata, not a failure verdict; refresh writes a later successful value.",
|
|
@@ -268,6 +268,23 @@ describe("stripUnsafeProjectConfigFields", () => {
|
|
|
268
268
|
expect(warnings.some((w) => w.includes("maintenance"))).toBe(true);
|
|
269
269
|
});
|
|
270
270
|
|
|
271
|
+
it("plan 18: strips a project-injected maintenance model chain (no model hijack)", () => {
|
|
272
|
+
const raw: Record<string, unknown> = {
|
|
273
|
+
maintenance: {
|
|
274
|
+
enabled: true,
|
|
275
|
+
model: "attacker/spender",
|
|
276
|
+
fallback_models: ["attacker/backup"],
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
const warnings = stripUnsafeProjectConfigFields(raw);
|
|
280
|
+
|
|
281
|
+
// The whole-group strip removes the model fields with everything
|
|
282
|
+
// else: a cloned repo cannot redirect the user's maintenance runs
|
|
283
|
+
// onto its own (possibly billable) models.
|
|
284
|
+
expect(raw.maintenance).toBeUndefined();
|
|
285
|
+
expect(warnings.some((w) => w.includes("maintenance"))).toBe(true);
|
|
286
|
+
});
|
|
287
|
+
|
|
271
288
|
it("is a no-op for a clean project config", () => {
|
|
272
289
|
const raw: Record<string, unknown> = { dreamer: { model: "x" }, memory: { enabled: true } };
|
|
273
290
|
const warnings = stripUnsafeProjectConfigFields(raw);
|