@cortexkit/pi-magic-context 0.49.23 → 0.49.25
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 +4 -4
- package/dist/chunk-embedding-write-worker.js +6 -6
- package/dist/{compartment-chunk-embedding-y01m95c2.js → compartment-chunk-embedding-g9a977b8.js} +3 -3
- package/dist/{embedding-backfill-2vh6m3bg.js → embedding-backfill-qxzjy5v2.js} +5 -5
- package/dist/{index-w1twp2kp.js → index-00c5a49f.js} +1 -1
- package/dist/{index-3c3ztwgc.js → index-0dr64gsy.js} +1 -1
- package/dist/{index-2bx7ge3x.js → index-1g0r4req.js} +35 -35
- package/dist/{index-8976mezv.js → index-23t8ryqw.js} +148 -12
- package/dist/{index-579m1751.js → index-8a2wvrda.js} +1 -1
- package/dist/{index-at6py2k3.js → index-8hmqdav2.js} +5 -1
- package/dist/{index-gqjxy2p7.js → index-cm9e52mb.js} +78 -6
- package/dist/{index-st4gwt64.js → index-cms6wfmd.js} +1 -1
- package/dist/{index-dbgg6hsf.js → index-d53veb5e.js} +4 -4
- package/dist/{index-5j6vwg4z.js → index-fzfpq5bd.js} +32 -22
- package/dist/{index-pe5gz5c4.js → index-nxq2srg9.js} +1 -1
- package/dist/{index-vx6f7wff.js → index-wb2t932e.js} +1 -1
- package/dist/{index-wgmhk91m.js → index-zmg1td73.js} +6 -50
- package/dist/{index-ftvm2acc.js → index-zn2xdbjy.js} +5 -5
- package/dist/index.js +537 -158
- package/dist/{message-fts-rowid-map-59y476bk.js → message-fts-rowid-map-1tb3qjtc.js} +2 -2
- package/dist/{message-index-bounded-4ngt600v.js → message-index-bounded-yj7s7cwz.js} +6 -6
- package/dist/{message-index-3snxf11x.js → message-index-fedjhja5.js} +6 -6
- package/dist/migration-worker.js +5 -5
- package/dist/{project-embedding-registry-hfyzs654.js → project-embedding-registry-9e82qsb6.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-5dmc77q2.js → read-session-chunk-rndwjfrx.js} +3 -3
- package/dist/{read-session-raw-yxv2fv34.js → read-session-raw-napqv76k.js} +3 -1
- package/dist/{search-jhfh3tsj.js → search-2aa5kzyp.js} +10 -10
- package/dist/{search-archive-3daj5ttc.js → search-archive-qa1sf8hc.js} +4 -4
- package/dist/subagent-entry.js +13 -13
- package/dist/tag-snapshot-worker-pi.js +6 -6
- package/package.json +4 -3
|
@@ -24,12 +24,12 @@ var [
|
|
|
24
24
|
{ Database, registerSqliteDiagnosticSink },
|
|
25
25
|
{ log }
|
|
26
26
|
] = await Promise.all([
|
|
27
|
-
import("./embedding-backfill-
|
|
27
|
+
import("./embedding-backfill-qxzjy5v2.js"),
|
|
28
28
|
import("./embedding-cache-7rp4gqzr.js"),
|
|
29
29
|
import("./storage-memory-0ndn65fm.js"),
|
|
30
|
-
import("./project-embedding-registry-
|
|
31
|
-
import("./search-
|
|
32
|
-
import("./compartment-chunk-embedding-
|
|
30
|
+
import("./project-embedding-registry-9e82qsb6.js"),
|
|
31
|
+
import("./search-2aa5kzyp.js"),
|
|
32
|
+
import("./compartment-chunk-embedding-g9a977b8.js"),
|
|
33
33
|
import("./embedding-activity-ew6dshfd.js"),
|
|
34
34
|
import("./harness-9872e0ym.js"),
|
|
35
35
|
import("./sqlite-v89bj0yy.js"),
|
|
@@ -15,14 +15,14 @@ import"./index-my0dn413.js";
|
|
|
15
15
|
import"./index-fgs78jyd.js";
|
|
16
16
|
import"./index-gwxaz0z5.js";
|
|
17
17
|
import"./index-399p688g.js";
|
|
18
|
-
import"./index-
|
|
19
|
-
import"./index-
|
|
18
|
+
import"./index-8hmqdav2.js";
|
|
19
|
+
import"./index-8a2wvrda.js";
|
|
20
20
|
import {
|
|
21
21
|
replaceCompartmentChunkEmbeddings2,
|
|
22
22
|
recordChunkEmbedBackoff2,
|
|
23
23
|
loadUnembeddedSessionChunkCandidates2,
|
|
24
24
|
countUnembeddedSessionCompartments2
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-wb2t932e.js";
|
|
26
26
|
import {
|
|
27
27
|
recordSessionProjectIdentity,
|
|
28
28
|
acquireGitSweepLease,
|
|
@@ -34,11 +34,11 @@ import"./index-n4wyxcgr.js";
|
|
|
34
34
|
import {
|
|
35
35
|
LATEST_SUPPORTED_VERSION,
|
|
36
36
|
enforceSchemaFence
|
|
37
|
-
} from "./index-
|
|
38
|
-
import"./index-
|
|
37
|
+
} from "./index-d53veb5e.js";
|
|
38
|
+
import"./index-0dr64gsy.js";
|
|
39
39
|
import"./index-w1avzkdt.js";
|
|
40
40
|
import"./index-135e8hvg.js";
|
|
41
|
-
import"./index-
|
|
41
|
+
import"./index-23t8ryqw.js";
|
|
42
42
|
import"./index-hqw0rt9k.js";
|
|
43
43
|
|
|
44
44
|
// ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts
|
package/dist/{compartment-chunk-embedding-y01m95c2.js → compartment-chunk-embedding-g9a977b8.js}
RENAMED
|
@@ -24,10 +24,10 @@ import {
|
|
|
24
24
|
countSessionCompartmentEmbedCoverage2,
|
|
25
25
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
26
26
|
countUnembeddedSessionCompartmentsPolite2
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-wb2t932e.js";
|
|
28
28
|
import"./index-gwxaz0z5.js";
|
|
29
|
-
import"./index-
|
|
30
|
-
import"./index-
|
|
29
|
+
import"./index-8a2wvrda.js";
|
|
30
|
+
import"./index-8hmqdav2.js";
|
|
31
31
|
import"./index-399p688g.js";
|
|
32
32
|
import"./index-hqw0rt9k.js";
|
|
33
33
|
import"./index-my0dn413.js";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ensureMemoryEmbeddings2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
3
|
+
} from "./index-nxq2srg9.js";
|
|
4
|
+
import"./index-00c5a49f.js";
|
|
5
5
|
import"./index-9p40dgkm.js";
|
|
6
6
|
import"./index-yhzhdp3m.js";
|
|
7
7
|
import"./index-j3pz3a1b.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-wb2t932e.js";
|
|
9
9
|
import"./index-wqpjhx1p.js";
|
|
10
10
|
import"./index-gwxaz0z5.js";
|
|
11
11
|
import"./index-ccanzg8p.js";
|
|
12
12
|
import"./index-hxp6q5f8.js";
|
|
13
|
-
import"./index-
|
|
14
|
-
import"./index-
|
|
13
|
+
import"./index-8a2wvrda.js";
|
|
14
|
+
import"./index-8hmqdav2.js";
|
|
15
15
|
import"./index-399p688g.js";
|
|
16
16
|
import"./index-hqw0rt9k.js";
|
|
17
17
|
import"./index-my0dn413.js";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
countSessionCompartmentEmbedCoverage2,
|
|
42
42
|
countSessionCompartmentEmbedCoveragePolite2,
|
|
43
43
|
countUnembeddedSessionCompartmentsPolite2
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-wb2t932e.js";
|
|
45
45
|
import {
|
|
46
46
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
47
47
|
} from "./index-ccanzg8p.js";
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
visitRawSessionMessages2,
|
|
68
68
|
readRawSessionMessageById2,
|
|
69
69
|
readSessionChunk2
|
|
70
|
-
} from "./index-
|
|
70
|
+
} from "./index-cm9e52mb.js";
|
|
71
71
|
import {
|
|
72
72
|
isRecord,
|
|
73
73
|
providerVisibleMessage,
|
|
@@ -101,7 +101,6 @@ import {
|
|
|
101
101
|
isPidAlive
|
|
102
102
|
} from "./index-n4wyxcgr.js";
|
|
103
103
|
import {
|
|
104
|
-
BoundedSessionMap,
|
|
105
104
|
clearLkgFenceProcessState,
|
|
106
105
|
commitLkgWithRecoveryFence,
|
|
107
106
|
clearLkgRecoveryFence,
|
|
@@ -109,14 +108,15 @@ import {
|
|
|
109
108
|
V2StoreReader,
|
|
110
109
|
deleteSessionScopedRows,
|
|
111
110
|
getLastIndexedOrdinal2
|
|
112
|
-
} from "./index-
|
|
111
|
+
} from "./index-zmg1td73.js";
|
|
113
112
|
import {
|
|
113
|
+
BoundedSessionMap,
|
|
114
114
|
resolveOpenCodeDbPath,
|
|
115
115
|
assertOpenCodeStoreGeneration
|
|
116
|
-
} from "./index-
|
|
116
|
+
} from "./index-23t8ryqw.js";
|
|
117
117
|
import {
|
|
118
118
|
noteRawSessionSummaryRowWritten2
|
|
119
|
-
} from "./index-
|
|
119
|
+
} from "./index-8hmqdav2.js";
|
|
120
120
|
import {
|
|
121
121
|
SubcClient,
|
|
122
122
|
connectionFileExists,
|
|
@@ -136,10 +136,10 @@ import {
|
|
|
136
136
|
unregisterProjectEmbedding2,
|
|
137
137
|
getProjectEmbeddingSnapshot2,
|
|
138
138
|
embedTextForProject2
|
|
139
|
-
} from "./index-
|
|
139
|
+
} from "./index-00c5a49f.js";
|
|
140
140
|
import {
|
|
141
141
|
getErrorMessage
|
|
142
|
-
} from "./index-
|
|
142
|
+
} from "./index-d53veb5e.js";
|
|
143
143
|
import {
|
|
144
144
|
V2_MEMORY_CATEGORIES,
|
|
145
145
|
CATEGORY_PRIORITY,
|
|
@@ -153,7 +153,7 @@ import {
|
|
|
153
153
|
expandWorkspaceIdentitySetWithAliases,
|
|
154
154
|
resolveStoredPathWorkspaceIdentity,
|
|
155
155
|
storedPathBelongsToWorkspace
|
|
156
|
-
} from "./index-
|
|
156
|
+
} from "./index-0dr64gsy.js";
|
|
157
157
|
import {
|
|
158
158
|
directoryHasGitMetadata,
|
|
159
159
|
resolveProjectIdentityForSession,
|
|
@@ -175,7 +175,7 @@ import {
|
|
|
175
175
|
resolveMemoriesByIdsForSearch2,
|
|
176
176
|
unifiedSearch2,
|
|
177
177
|
formatSearchResults2
|
|
178
|
-
} from "./index-
|
|
178
|
+
} from "./index-zn2xdbjy.js";
|
|
179
179
|
import {
|
|
180
180
|
computeCueContentHash,
|
|
181
181
|
getMuralCueState,
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
} from "./index-6wdwv3a6.js";
|
|
207
207
|
import {
|
|
208
208
|
renderSearchArchive2
|
|
209
|
-
} from "./index-
|
|
209
|
+
} from "./index-cms6wfmd.js";
|
|
210
210
|
import {
|
|
211
211
|
computeNormalizedHash
|
|
212
212
|
} from "./index-9x1f96r8.js";
|
|
@@ -10379,18 +10379,18 @@ var FULL_PARAMETER_DESCRIPTIONS = {
|
|
|
10379
10379
|
message: "Message ordinal from a <session-history> heading or a ctx_search hit, not a tag number. Returns that one message in full. Use alone."
|
|
10380
10380
|
},
|
|
10381
10381
|
ctx_note: {
|
|
10382
|
-
action: "write | read | update | dismiss.
|
|
10382
|
+
action: "write | read | update | dismiss.",
|
|
10383
10383
|
content: "Note text for write/update: first line is the title (under 80 chars), then the detail.",
|
|
10384
10384
|
surface_condition: "Makes this a smart note: a condition an outside checker can verify on its own, periodically — repository state, releases, web pages, anything it can look up — never something only this conversation knows. The note is parked until the condition holds.",
|
|
10385
10385
|
filter: "Read filter: all, active, pending (unsurfaced smart notes), ready, dismissed. Omitted, it shows active session notes plus every current smart note (pending included); active shows only notes whose stored status is active.",
|
|
10386
10386
|
limit: "Rows per read (default 25).",
|
|
10387
10387
|
offset: "Skip this many newest rows (default 0).",
|
|
10388
|
-
note_ids: "Note ids: one for update, 1–50 for dismiss or
|
|
10388
|
+
note_ids: "Note ids: one for update, 1–50 for dismiss, or 1–50 to read those notes in full. Write and a plain read take an empty list."
|
|
10389
10389
|
},
|
|
10390
10390
|
ctx_memory: {
|
|
10391
10391
|
action: "write | update | archive | merge | get",
|
|
10392
10392
|
content: "The memory text — one standalone fact (write, update, merge).",
|
|
10393
|
-
category: "Kind of fact (required for write; on update/merge
|
|
10393
|
+
category: "Kind of fact (required for write; on update/merge, pass the memory's current category to keep it).",
|
|
10394
10394
|
ids: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get.",
|
|
10395
10395
|
reason: "Why it is being archived (optional)."
|
|
10396
10396
|
},
|
|
@@ -10414,18 +10414,18 @@ var LIGHT_PARAMETER_DESCRIPTIONS = {
|
|
|
10414
10414
|
message: "Message ordinal from a <session-history> heading or a ctx_search hit, not a tag number. Returns that one message in full. Use alone."
|
|
10415
10415
|
},
|
|
10416
10416
|
ctx_note: {
|
|
10417
|
-
action: "write | read | update | dismiss
|
|
10417
|
+
action: "write | read | update | dismiss.",
|
|
10418
10418
|
content: "Note text: first line title (<80 chars), then detail.",
|
|
10419
10419
|
surface_condition: "A condition an outside checker can verify on its own, periodically (repository, releases, web — anything it can look up); never something only this conversation knows.",
|
|
10420
10420
|
filter: "Read filter: all, active, pending, ready, dismissed. Omitted: active notes plus every current smart note (pending included); active: only active-status notes.",
|
|
10421
10421
|
limit: "Rows per read (default 25).",
|
|
10422
10422
|
offset: "Skip newest rows (default 0).",
|
|
10423
|
-
note_ids: "One id for update, 1–50 for dismiss or read
|
|
10423
|
+
note_ids: "One id for update, 1–50 for dismiss, or 1–50 to read those notes in full. Write and a plain read take an empty list."
|
|
10424
10424
|
},
|
|
10425
10425
|
ctx_memory: {
|
|
10426
10426
|
action: "write | update | archive | merge | get",
|
|
10427
10427
|
content: "One standalone fact (write, update, merge).",
|
|
10428
|
-
category: "Kind of fact (required for write;
|
|
10428
|
+
category: "Kind of fact (required for write; on update/merge pass the current category to keep it).",
|
|
10429
10429
|
ids: "Ids from <project-memory>: one for update, 1+ for archive, 2+ for merge, 1–20 for get.",
|
|
10430
10430
|
reason: "Why it is archived (optional)."
|
|
10431
10431
|
},
|
|
@@ -11324,18 +11324,18 @@ var ALL_ACTIONS = [...PRIMARY_ACTIONS, "list"];
|
|
|
11324
11324
|
var DREAMER_ONLY_ACTIONS = new Set(["list"]);
|
|
11325
11325
|
var GET_MAX_IDS = 20;
|
|
11326
11326
|
var ParamsShape = {
|
|
11327
|
-
action:
|
|
11327
|
+
action: Union(PRIMARY_ACTIONS.map((a) => Literal(a)), {
|
|
11328
11328
|
description: "write | update | archive | merge | get"
|
|
11329
|
-
})
|
|
11330
|
-
content:
|
|
11329
|
+
}),
|
|
11330
|
+
content: String2({
|
|
11331
11331
|
description: "The memory text — one standalone fact (write, update, merge)."
|
|
11332
|
-
})
|
|
11333
|
-
category:
|
|
11334
|
-
description: "Kind of fact (required for write; on update/merge
|
|
11335
|
-
})
|
|
11336
|
-
ids:
|
|
11332
|
+
}),
|
|
11333
|
+
category: Union(V2_MEMORY_CATEGORIES.map((c) => Literal(c)), {
|
|
11334
|
+
description: "Kind of fact (required for write; on update/merge, pass the memory's current category to keep it)."
|
|
11335
|
+
}),
|
|
11336
|
+
ids: _Array_(Number2(), {
|
|
11337
11337
|
description: "Memory ids from <project-memory>: one for update, one or more for archive, two or more for merge, 1–20 for get."
|
|
11338
|
-
})
|
|
11338
|
+
}),
|
|
11339
11339
|
reason: Optional(String2({
|
|
11340
11340
|
description: "Why it is being archived (optional)."
|
|
11341
11341
|
}))
|
|
@@ -12382,25 +12382,24 @@ var FILTER_VALUES = [
|
|
|
12382
12382
|
"all"
|
|
12383
12383
|
];
|
|
12384
12384
|
var ParamsSchema2 = _Object_({
|
|
12385
|
-
action:
|
|
12385
|
+
action: Union([
|
|
12386
12386
|
Literal("write"),
|
|
12387
12387
|
Literal("read"),
|
|
12388
12388
|
Literal("dismiss"),
|
|
12389
12389
|
Literal("update")
|
|
12390
12390
|
], {
|
|
12391
|
-
description: "write | read | update | dismiss.
|
|
12392
|
-
})
|
|
12393
|
-
content:
|
|
12391
|
+
description: "write | read | update | dismiss."
|
|
12392
|
+
}),
|
|
12393
|
+
content: String2({
|
|
12394
12394
|
description: "Note text for write/update: first line is the title (under 80 chars), then the detail."
|
|
12395
|
-
})
|
|
12395
|
+
}),
|
|
12396
12396
|
surface_condition: Optional(String2({
|
|
12397
12397
|
description: "Makes this a smart note: a condition an outside checker can verify on its own, periodically — repository state, releases, web pages, anything it can look up — never something only this conversation knows. The note is parked until the condition holds."
|
|
12398
12398
|
})),
|
|
12399
|
-
note_ids:
|
|
12400
|
-
minItems: 1,
|
|
12399
|
+
note_ids: _Array_(Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER }), {
|
|
12401
12400
|
maxItems: 50,
|
|
12402
|
-
description: "Note ids: one for update, 1–50 for dismiss or
|
|
12403
|
-
})
|
|
12401
|
+
description: "Note ids: one for update, 1–50 for dismiss, or 1–50 to read those notes in full. Write and a plain read take an empty list."
|
|
12402
|
+
}),
|
|
12404
12403
|
filter: Optional(Union(FILTER_VALUES.map((value) => Literal(value)), {
|
|
12405
12404
|
description: "Read filter: all, active, pending (unsurfaced smart notes), ready, dismissed. Omitted, it shows active session notes plus every current smart note (pending included); active shows only notes whose stored status is active."
|
|
12406
12405
|
})),
|
|
@@ -12492,7 +12491,8 @@ function createCtxNoteTool(deps) {
|
|
|
12492
12491
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
12493
12492
|
const dreamerEnabled = deps.resolveDreamerEnabled?.(ctx) ?? deps.dreamerEnabled;
|
|
12494
12493
|
const action = params.action ?? (params.content?.trim() ? "write" : "read");
|
|
12495
|
-
const
|
|
12494
|
+
const targetedReadIds = action === "read" && Array.isArray(params.note_ids) && params.note_ids.length === 0 ? undefined : params.note_ids;
|
|
12495
|
+
const noteIds = action === "dismiss" || action === "update" || action === "read" && targetedReadIds !== undefined ? parseNoteIds(action, targetedReadIds) : undefined;
|
|
12496
12496
|
if (typeof noteIds === "string")
|
|
12497
12497
|
return err3(noteIds);
|
|
12498
12498
|
if (action === "write") {
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
// ../plugin/src/shared/bounded-session-map.ts
|
|
2
|
+
class BoundedSessionMap {
|
|
3
|
+
maxEntries;
|
|
4
|
+
store = new Map;
|
|
5
|
+
constructor(maxEntries) {
|
|
6
|
+
if (!Number.isFinite(maxEntries) || maxEntries < 1) {
|
|
7
|
+
throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
|
|
8
|
+
}
|
|
9
|
+
this.maxEntries = maxEntries;
|
|
10
|
+
}
|
|
11
|
+
get(sessionId) {
|
|
12
|
+
const value = this.store.get(sessionId);
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return;
|
|
15
|
+
this.store.delete(sessionId);
|
|
16
|
+
this.store.set(sessionId, value);
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
peek(sessionId) {
|
|
20
|
+
return this.store.get(sessionId);
|
|
21
|
+
}
|
|
22
|
+
has(sessionId) {
|
|
23
|
+
return this.store.has(sessionId);
|
|
24
|
+
}
|
|
25
|
+
set(sessionId, value) {
|
|
26
|
+
if (this.store.has(sessionId)) {
|
|
27
|
+
this.store.delete(sessionId);
|
|
28
|
+
} else if (this.store.size >= this.maxEntries) {
|
|
29
|
+
const oldest = this.store.keys().next().value;
|
|
30
|
+
if (oldest !== undefined)
|
|
31
|
+
this.store.delete(oldest);
|
|
32
|
+
}
|
|
33
|
+
this.store.set(sessionId, value);
|
|
34
|
+
}
|
|
35
|
+
delete(sessionId) {
|
|
36
|
+
return this.store.delete(sessionId);
|
|
37
|
+
}
|
|
38
|
+
clear() {
|
|
39
|
+
this.store.clear();
|
|
40
|
+
}
|
|
41
|
+
get size() {
|
|
42
|
+
return this.store.size;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
1
46
|
// ../plugin/src/shared/opencode-db-path.ts
|
|
2
47
|
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
3
48
|
import { homedir } from "node:os";
|
|
@@ -176,34 +221,125 @@ function claimOpenCodeDbDiagnosticOnce(surface, resolution) {
|
|
|
176
221
|
}
|
|
177
222
|
|
|
178
223
|
// ../plugin/src/features/magic-context/tool-definition-tokens.ts
|
|
179
|
-
var
|
|
180
|
-
var
|
|
224
|
+
var ACTIVITY_WINDOW_MS = 10 * 60000;
|
|
225
|
+
var MAX_ACTIVITY_GAP_MS = 60000;
|
|
226
|
+
var WINDOWED_SINCE_KEY = "tool_definition_measurements:windowed_since";
|
|
227
|
+
var routes = new Map;
|
|
228
|
+
var sessionFlights = new BoundedSessionMap(1000);
|
|
181
229
|
var persistenceDb = null;
|
|
230
|
+
var windowedSince;
|
|
231
|
+
var boundAt = 0;
|
|
182
232
|
var cachedInsertStmt = null;
|
|
233
|
+
var cachedDeleteStmt = null;
|
|
234
|
+
function agentKey(agentName) {
|
|
235
|
+
return agentName && agentName.length > 0 ? agentName : "default";
|
|
236
|
+
}
|
|
183
237
|
function keyFor(providerID, modelID, agentName) {
|
|
184
|
-
|
|
185
|
-
|
|
238
|
+
return `${providerID}/${modelID}/${agentKey(agentName)}`;
|
|
239
|
+
}
|
|
240
|
+
function routeFor(providerID, modelID, agentName) {
|
|
241
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
242
|
+
let route = routes.get(key);
|
|
243
|
+
if (!route) {
|
|
244
|
+
route = {
|
|
245
|
+
providerID,
|
|
246
|
+
modelID,
|
|
247
|
+
agentName: agentKey(agentName),
|
|
248
|
+
tools: new Map,
|
|
249
|
+
live: false,
|
|
250
|
+
clock: 0,
|
|
251
|
+
lastWallAt: Date.now(),
|
|
252
|
+
oldestFireAt: Number.POSITIVE_INFINITY,
|
|
253
|
+
retired: new Map,
|
|
254
|
+
legacyRows: new Set
|
|
255
|
+
};
|
|
256
|
+
routes.set(key, route);
|
|
257
|
+
}
|
|
258
|
+
return { key, route };
|
|
259
|
+
}
|
|
260
|
+
function advanceClock(route) {
|
|
261
|
+
const now = Date.now();
|
|
262
|
+
const gap = Math.min(Math.max(now - route.lastWallAt, 0), MAX_ACTIVITY_GAP_MS);
|
|
263
|
+
route.clock += gap;
|
|
264
|
+
route.lastWallAt = Math.max(route.lastWallAt, now);
|
|
265
|
+
return route.clock;
|
|
266
|
+
}
|
|
267
|
+
function readWindowedSince(db) {
|
|
268
|
+
try {
|
|
269
|
+
const row = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(WINDOWED_SINCE_KEY);
|
|
270
|
+
if (!row)
|
|
271
|
+
return;
|
|
272
|
+
const value = Number(row.value);
|
|
273
|
+
return Number.isFinite(value) ? value : undefined;
|
|
274
|
+
} catch {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function markWindowed() {
|
|
279
|
+
if (windowedSince !== undefined || !persistenceDb)
|
|
280
|
+
return;
|
|
281
|
+
try {
|
|
282
|
+
persistenceDb.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(WINDOWED_SINCE_KEY, String(boundAt));
|
|
283
|
+
windowedSince = readWindowedSince(persistenceDb);
|
|
284
|
+
} catch {}
|
|
186
285
|
}
|
|
187
286
|
function setDatabase(db) {
|
|
287
|
+
const rebound = persistenceDb !== null && persistenceDb !== db;
|
|
188
288
|
persistenceDb = db;
|
|
289
|
+
boundAt = Date.now();
|
|
189
290
|
cachedInsertStmt = null;
|
|
291
|
+
cachedDeleteStmt = null;
|
|
292
|
+
if (rebound) {
|
|
293
|
+
for (const route of routes.values()) {
|
|
294
|
+
for (const slot of route.tools.values()) {
|
|
295
|
+
slot.persisted = false;
|
|
296
|
+
slot.writeFailedAt = undefined;
|
|
297
|
+
}
|
|
298
|
+
for (const retired of route.retired.values())
|
|
299
|
+
retired.rowKept = false;
|
|
300
|
+
route.legacyRows.clear();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
windowedSince = readWindowedSince(db);
|
|
304
|
+
if (windowedSince !== undefined)
|
|
305
|
+
return;
|
|
306
|
+
try {
|
|
307
|
+
if (!db.prepare("SELECT 1 FROM tool_definition_measurements LIMIT 1").get())
|
|
308
|
+
markWindowed();
|
|
309
|
+
} catch {}
|
|
190
310
|
}
|
|
191
311
|
function loadToolDefinitionMeasurements(db) {
|
|
192
312
|
let rows = [];
|
|
193
313
|
try {
|
|
194
|
-
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count FROM tool_definition_measurements").all();
|
|
314
|
+
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count, recorded_at FROM tool_definition_measurements").all();
|
|
195
315
|
} catch {
|
|
196
316
|
return;
|
|
197
317
|
}
|
|
318
|
+
const since = readWindowedSince(db);
|
|
319
|
+
const loadedAt = new Map;
|
|
198
320
|
for (const row of rows) {
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
321
|
+
const { route } = routeFor(row.provider_id, row.model_id, row.agent_name);
|
|
322
|
+
if (route.live)
|
|
323
|
+
continue;
|
|
324
|
+
let now = loadedAt.get(route);
|
|
325
|
+
if (now === undefined) {
|
|
326
|
+
now = advanceClock(route);
|
|
327
|
+
loadedAt.set(route, now);
|
|
204
328
|
}
|
|
205
|
-
|
|
329
|
+
const legacy = since === undefined || !(Number(row.recorded_at) >= since);
|
|
330
|
+
route.tools.set(row.tool_id, {
|
|
331
|
+
tokens: row.token_count,
|
|
332
|
+
fingerprint: undefined,
|
|
333
|
+
lastFireAt: now,
|
|
334
|
+
legacy,
|
|
335
|
+
persisted: !legacy
|
|
336
|
+
});
|
|
337
|
+
route.oldestFireAt = Math.min(route.oldestFireAt, now);
|
|
338
|
+
if (legacy)
|
|
339
|
+
route.legacyRows.add(row.tool_id);
|
|
340
|
+
else
|
|
341
|
+
route.legacyRows.delete(row.tool_id);
|
|
206
342
|
}
|
|
207
343
|
}
|
|
208
344
|
|
|
209
|
-
export { resolveOpenCodeDbPath, hasV1MessageTables, assertOpenCodeStoreGeneration, openCodeDbPathExists, getOpenCodeDbProbeDescriptions, recordOpenCodeDbReadFailure, clearOpenCodeDbReadFailure, claimOpenCodeDbDiagnosticOnce, setDatabase, loadToolDefinitionMeasurements };
|
|
345
|
+
export { BoundedSessionMap, resolveOpenCodeDbPath, hasV1MessageTables, assertOpenCodeStoreGeneration, openCodeDbPathExists, getOpenCodeDbProbeDescriptions, recordOpenCodeDbReadFailure, clearOpenCodeDbReadFailure, claimOpenCodeDbDiagnosticOnce, setDatabase, loadToolDefinitionMeasurements };
|
|
@@ -184,6 +184,10 @@ function recordFailure(key, sessionId, failure, detail) {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
// ../plugin/src/hooks/magic-context/read-session-raw.ts
|
|
187
|
+
function areRustHistorianSyntheticParts2(parts) {
|
|
188
|
+
const contentParts = parts.filter((part) => part === null || typeof part !== "object" || part.type !== "compaction");
|
|
189
|
+
return contentParts.length > 0 && contentParts.every((part) => part !== null && typeof part === "object" && (part.synthetic === true || part.syntheticTodoMarker === true));
|
|
190
|
+
}
|
|
187
191
|
function isStrictGapHealingMessage2(message) {
|
|
188
192
|
if (message.storeType === "synthetic")
|
|
189
193
|
return true;
|
|
@@ -1281,4 +1285,4 @@ function readRawSessionBoundaryEndpointsFromDb2(db, sessionId, ids, blockIds = [
|
|
|
1281
1285
|
}
|
|
1282
1286
|
}
|
|
1283
1287
|
|
|
1284
|
-
export { runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb, isStrictGapHealingMessage2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, RAW_SUMMARY_TEXT_MAX_CHARS2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2 };
|
|
1288
|
+
export { runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb, areRustHistorianSyntheticParts2, isStrictGapHealingMessage2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, RAW_SUMMARY_TEXT_MAX_CHARS2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2 };
|