@cortexkit/pi-magic-context 0.48.0 → 0.49.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/auto-search-worker.js +3 -3
- package/dist/embedding-backfill-b71dvfs8.js +20 -0
- package/dist/embedding-worker.js +4 -4
- package/dist/historian-calibration-extension.js +30 -5
- package/dist/{index-dkx0b1kt.js → index-041ex0cj.js} +7 -2
- package/dist/{index-fp37he9a.js → index-0vrkp1jq.js} +1 -1
- package/dist/{index-6pgq5ns2.js → index-1evzceyw.js} +2 -2
- package/dist/{index-419bndtm.js → index-21v1kfs7.js} +2 -2
- package/dist/{index-wrm4nbj7.js → index-290tzwp1.js} +1 -1
- package/dist/{index-72bdc1bd.js → index-3mgf68pn.js} +4 -4
- package/dist/{index-hrf13mn3.js → index-3rea6zd9.js} +16 -8
- package/dist/{index-0am8a7k1.js → index-904reqtg.js} +4 -4
- package/dist/{index-fm3ksh5e.js → index-bejpsj10.js} +4 -4
- package/dist/{index-98z1c1r0.js → index-ehybv5nr.js} +109 -35
- package/dist/{index-pvm4pd5d.js → index-hwqb3s7f.js} +811 -76
- package/dist/{index-5hd7h4rr.js → index-kjd1fj55.js} +39 -31
- package/dist/{index-8y5knskr.js → index-mcgehvgw.js} +93 -9
- package/dist/{index-603mt6nm.js → index-r024r8da.js} +1 -1
- package/dist/{index-9xb0axhc.js → index-r56xgha8.js} +1 -1
- package/dist/{index-r7xg4hvw.js → index-t7xfqtg6.js} +8 -8
- package/dist/{index-rt5jgzp1.js → index-vakawmbc.js} +160 -25
- package/dist/{index-f956htf3.js → index-x3dcnxh0.js} +6 -2
- package/dist/{index-544c0e0x.js → index-yarjn32j.js} +7 -7
- package/dist/{index-5jp1h0bz.js → index-yzcjxnt2.js} +48 -11
- package/dist/{index-zrr5t5a7.js → index-zh1jw8qp.js} +106 -1
- package/dist/index.js +1149 -680
- package/dist/{logger-v3dsxdnm.js → logger-j6tecd1h.js} +1 -1
- package/dist/{message-index-bounded-t7vvty76.js → message-index-bounded-qz5dz2se.js} +11 -11
- package/dist/{message-time-backfill-4ndf7hrq.js → message-time-backfill-05ppypkz.js} +2 -2
- package/dist/migration-worker.js +8 -8
- package/dist/{project-embedding-registry-jy2hmq28.js → project-embedding-registry-ky7wrkr1.js} +9 -9
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-47pjn7fz.js → read-session-chunk-24sd89tf.js} +8 -6
- package/dist/{read-session-raw-yn8nawav.js → read-session-raw-npx3920c.js} +5 -3
- package/dist/{safe-notification-target-3c1ns931.js → safe-notification-target-vn9kpmv4.js} +2 -2
- package/dist/{search-42szfhwp.js → search-jbh28nwy.js} +17 -17
- package/dist/{storage-tags-jym5z6yk.js → storage-tags-kjnsqbdb.js} +6 -6
- package/dist/subagent-entry.js +20 -19
- package/package.json +1 -1
- package/dist/embedding-backfill-bnnytehy.js +0 -20
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getHarness2
|
|
3
|
+
} from "./index-0h2mkab2.js";
|
|
1
4
|
import {
|
|
2
5
|
removeSystemReminders,
|
|
3
6
|
hasMeaningfulUserText2,
|
|
4
7
|
extractTexts2
|
|
5
|
-
} from "./index-
|
|
6
|
-
import {
|
|
7
|
-
getHarness2
|
|
8
|
-
} from "./index-0h2mkab2.js";
|
|
8
|
+
} from "./index-r56xgha8.js";
|
|
9
9
|
import {
|
|
10
10
|
withSqliteBackgroundWriter2,
|
|
11
11
|
withoutSqliteTransformPass2
|
|
@@ -15,20 +15,25 @@ import {
|
|
|
15
15
|
recordIndexedMessageTime,
|
|
16
16
|
messageFtsOrdinalRangeIsMapped,
|
|
17
17
|
deleteUnmappedMessageFtsRows
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-r024r8da.js";
|
|
19
19
|
import {
|
|
20
20
|
deleteChunkEmbedBackoffForSession
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-bejpsj10.js";
|
|
22
22
|
import {
|
|
23
23
|
closeQuietly,
|
|
24
|
+
TAG_TOMBSTONE_OWNER_PREFIX,
|
|
25
|
+
tagTombstoneOwnerRange,
|
|
26
|
+
tagTombstoneOwnerKey,
|
|
27
|
+
tagRevisionKey,
|
|
28
|
+
tagIdentityRevisionKey,
|
|
24
29
|
deleteTagIdentityRevisions
|
|
25
|
-
} from "./index-
|
|
30
|
+
} from "./index-mcgehvgw.js";
|
|
26
31
|
import {
|
|
27
32
|
cleanUserText2
|
|
28
|
-
} from "./index-
|
|
33
|
+
} from "./index-3rea6zd9.js";
|
|
29
34
|
import {
|
|
30
35
|
logSlowWriteTransaction
|
|
31
|
-
} from "./index-
|
|
36
|
+
} from "./index-0vrkp1jq.js";
|
|
32
37
|
|
|
33
38
|
// ../plugin/src/features/magic-context/session-activity.ts
|
|
34
39
|
var PREFIX = "retrospective_activity:";
|
|
@@ -176,6 +181,17 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
176
181
|
if (deletableSessionIds.length === 0)
|
|
177
182
|
return 0;
|
|
178
183
|
const placeholders = deletableSessionIds.map(() => "?").join(", ");
|
|
184
|
+
const harnessTables = SESSION_SCOPED_TABLES.filter((definition) => definition.harnessScoped);
|
|
185
|
+
if (options.preserveTagRevisionTombstones) {
|
|
186
|
+
const owners = db.prepare(harnessTables.map((definition) => `SELECT session_id, harness FROM ${definition.table} WHERE session_id IN (${placeholders})${definition.extraPredicate ? ` AND ${definition.extraPredicate}` : ""}`).join(" UNION ")).all(...harnessTables.flatMap(() => deletableSessionIds));
|
|
187
|
+
const record = db.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, ?)");
|
|
188
|
+
for (const owner of owners)
|
|
189
|
+
record.run(tagTombstoneOwnerKey(owner.session_id, owner.harness), owner.harness);
|
|
190
|
+
const fallback = db.prepare(`INSERT INTO schema_migrations_meta (key, value)
|
|
191
|
+
SELECT ?, ? WHERE NOT EXISTS (SELECT 1 FROM schema_migrations_meta WHERE key >= ? AND key < ?)`);
|
|
192
|
+
for (const id of deletableSessionIds)
|
|
193
|
+
fallback.run(tagTombstoneOwnerKey(id, getHarness2()), getHarness2(), ...tagTombstoneOwnerRange(id));
|
|
194
|
+
}
|
|
179
195
|
for (const sessionId of deletableSessionIds)
|
|
180
196
|
deleteChunkEmbedBackoffForSession(db, sessionId);
|
|
181
197
|
for (const definition of SESSION_SCOPED_TABLES) {
|
|
@@ -202,6 +218,20 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
202
218
|
statement.run(...deletableSessionIds);
|
|
203
219
|
}
|
|
204
220
|
deleteSessionActivity(db, deletableSessionIds);
|
|
221
|
+
if (!options.preserveTagRevisionTombstones) {
|
|
222
|
+
const retireOwner = db.prepare(harness === undefined ? "DELETE FROM schema_migrations_meta WHERE key >= ? AND key < ?" : "DELETE FROM schema_migrations_meta WHERE key = ?");
|
|
223
|
+
const survivingRows = harnessTables.map((definition) => `EXISTS (SELECT 1 FROM ${definition.table} WHERE session_id = ?${definition.extraPredicate ? ` AND ${definition.extraPredicate}` : ""})`).join(" OR ");
|
|
224
|
+
const retire = db.prepare(`DELETE FROM schema_migrations_meta WHERE key IN (?, ?)
|
|
225
|
+
AND NOT (${survivingRows})
|
|
226
|
+
AND NOT EXISTS (SELECT 1 FROM schema_migrations_meta AS owners WHERE owners.key >= ? AND owners.key < ?)`);
|
|
227
|
+
for (const id of deletableSessionIds) {
|
|
228
|
+
if (harness === undefined)
|
|
229
|
+
retireOwner.run(...tagTombstoneOwnerRange(id));
|
|
230
|
+
else
|
|
231
|
+
retireOwner.run(tagTombstoneOwnerKey(id, harness));
|
|
232
|
+
retire.run(tagIdentityRevisionKey(id), tagRevisionKey(id), ...harnessTables.map(() => id), ...tagTombstoneOwnerRange(id));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
205
235
|
return deletableSessionIds.length;
|
|
206
236
|
}
|
|
207
237
|
|
|
@@ -641,12 +671,19 @@ function persistMessageHistoryOrphanSweepState(db, cursor, lastSweptAt, harness)
|
|
|
641
671
|
last_swept_at = excluded.last_swept_at`).run(harness, cursor, lastSweptAt);
|
|
642
672
|
}
|
|
643
673
|
function getOpenCodeSessionScopedCandidateSourceSql(harness) {
|
|
644
|
-
|
|
674
|
+
const sources = SESSION_SCOPED_TABLES.filter((definition) => definition.harnessScoped === true).map((definition) => {
|
|
645
675
|
const predicates = ["session_id IS NOT NULL", `harness = '${harness}'`];
|
|
646
676
|
if (definition.extraPredicate)
|
|
647
677
|
predicates.push(definition.extraPredicate);
|
|
648
678
|
return `SELECT session_id FROM ${definition.table} WHERE ${predicates.join(" AND ")}`;
|
|
649
|
-
})
|
|
679
|
+
});
|
|
680
|
+
const jsonId = `SUBSTR(key, ${TAG_TOMBSTONE_OWNER_PREFIX.length + 1}, LENGTH(key) - ${TAG_TOMBSTONE_OWNER_PREFIX.length + harness.length + 1})`;
|
|
681
|
+
sources.push(`SELECT CASE WHEN json_valid(${jsonId}) THEN
|
|
682
|
+
CASE WHEN json_type(${jsonId}) = 'text' THEN json_extract(${jsonId}, '$') END END AS session_id
|
|
683
|
+
FROM schema_migrations_meta WHERE value = '${harness}'
|
|
684
|
+
AND key >= '${TAG_TOMBSTONE_OWNER_PREFIX}' AND key < '${TAG_TOMBSTONE_OWNER_PREFIX.slice(0, -1)};'
|
|
685
|
+
AND SUBSTR(key, -${harness.length + 1}) = ':${harness}'`);
|
|
686
|
+
return sources.join(`
|
|
650
687
|
UNION
|
|
651
688
|
`);
|
|
652
689
|
}
|
|
@@ -134,6 +134,111 @@ function buildHiddenAgentRegistrations(args) {
|
|
|
134
134
|
];
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
// ../plugin/src/shared/models-dev-temperature.ts
|
|
138
|
+
import { readFileSync, statSync } from "node:fs";
|
|
139
|
+
import { homedir } from "node:os";
|
|
140
|
+
import { join } from "node:path";
|
|
141
|
+
var CATALOG_PROVIDER_ALIASES = {
|
|
142
|
+
"google-antigravity": "google",
|
|
143
|
+
"opencode-zen": "opencode"
|
|
144
|
+
};
|
|
145
|
+
var ANTIGRAVITY_MODEL_PREFIX = "antigravity-";
|
|
146
|
+
var cached;
|
|
147
|
+
function modelsDevCatalogPath(env = process.env) {
|
|
148
|
+
if (env.OPENCODE_MODELS_PATH)
|
|
149
|
+
return env.OPENCODE_MODELS_PATH;
|
|
150
|
+
return join(env.XDG_CACHE_HOME || join(homedir(), ".cache"), "opencode", "models.json");
|
|
151
|
+
}
|
|
152
|
+
function buildIndex(raw) {
|
|
153
|
+
const index = new Map;
|
|
154
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
155
|
+
return index;
|
|
156
|
+
for (const [providerID, provider] of Object.entries(raw)) {
|
|
157
|
+
const models = provider?.models;
|
|
158
|
+
if (!models || typeof models !== "object")
|
|
159
|
+
continue;
|
|
160
|
+
for (const [modelID, model] of Object.entries(models)) {
|
|
161
|
+
const temperature = model?.temperature;
|
|
162
|
+
if (typeof temperature === "boolean")
|
|
163
|
+
index.set(`${providerID}/${modelID}`, temperature);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return index;
|
|
167
|
+
}
|
|
168
|
+
function loadIndex() {
|
|
169
|
+
const path = modelsDevCatalogPath();
|
|
170
|
+
try {
|
|
171
|
+
const stat = statSync(path);
|
|
172
|
+
if (cached?.path === path && cached.mtimeMs === stat.mtimeMs && cached.size === stat.size)
|
|
173
|
+
return cached.index;
|
|
174
|
+
const index = buildIndex(JSON.parse(readFileSync(path, "utf8")));
|
|
175
|
+
cached = { path, mtimeMs: stat.mtimeMs, size: stat.size, index };
|
|
176
|
+
return index;
|
|
177
|
+
} catch {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function catalogCandidates(providerID, modelID) {
|
|
182
|
+
const provider = Object.hasOwn(CATALOG_PROVIDER_ALIASES, providerID) ? CATALOG_PROVIDER_ALIASES[providerID] : providerID;
|
|
183
|
+
const candidates = [`${provider}/${modelID}`];
|
|
184
|
+
if (provider === "google" && modelID.startsWith(ANTIGRAVITY_MODEL_PREFIX))
|
|
185
|
+
candidates.push(`google/${modelID.slice(ANTIGRAVITY_MODEL_PREFIX.length)}`);
|
|
186
|
+
return candidates;
|
|
187
|
+
}
|
|
188
|
+
function catalogTemperature(model) {
|
|
189
|
+
const slash = model.indexOf("/");
|
|
190
|
+
if (slash <= 0 || slash === model.length - 1)
|
|
191
|
+
return;
|
|
192
|
+
const index = loadIndex();
|
|
193
|
+
if (!index)
|
|
194
|
+
return;
|
|
195
|
+
for (const entry of catalogCandidates(model.slice(0, slash), model.slice(slash + 1))) {
|
|
196
|
+
const temperature = index.get(entry);
|
|
197
|
+
if (temperature !== undefined)
|
|
198
|
+
return { temperature, entry };
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ../plugin/src/shared/subagent-temperature.ts
|
|
204
|
+
var loggedDecisions = new Set;
|
|
205
|
+
function temperatureCapability(metadata) {
|
|
206
|
+
if (!metadata || typeof metadata !== "object")
|
|
207
|
+
return;
|
|
208
|
+
const model = metadata;
|
|
209
|
+
const supported = model.capabilities?.temperature ?? model.temperature ?? model.compat?.supportsTemperature ?? model.compat?.supportsSamplingParams;
|
|
210
|
+
return typeof supported === "boolean" ? supported : undefined;
|
|
211
|
+
}
|
|
212
|
+
function resolveTemperatureCapability(model, metadata) {
|
|
213
|
+
const host = temperatureCapability(metadata);
|
|
214
|
+
if (host !== undefined)
|
|
215
|
+
return { supported: host, source: "host" };
|
|
216
|
+
const catalog = catalogTemperature(model);
|
|
217
|
+
if (catalog)
|
|
218
|
+
return { supported: catalog.temperature, source: "catalog", entry: catalog.entry };
|
|
219
|
+
return { supported: undefined, source: "none" };
|
|
220
|
+
}
|
|
221
|
+
function describeTemperatureDecision(model, decision) {
|
|
222
|
+
const verdict = decision.supported === true ? "sent" : "omitted";
|
|
223
|
+
const answer = decision.supported === true ? "yes" : "no";
|
|
224
|
+
const reason = decision.source === "host" ? `host model metadata says ${answer}` : decision.source === "catalog" ? `models.dev cache entry ${decision.entry ?? "unknown"} says ${answer}` : "no host or models.dev metadata";
|
|
225
|
+
return `Subagent temperature ${verdict} for ${model}: ${reason}`;
|
|
226
|
+
}
|
|
227
|
+
function logTemperatureDecision(model, decision, log) {
|
|
228
|
+
const key = `${model}\x00${decision.source}\x00${decision.supported}\x00${decision.entry ?? ""}`;
|
|
229
|
+
if (loggedDecisions.has(key))
|
|
230
|
+
return;
|
|
231
|
+
loggedDecisions.add(key);
|
|
232
|
+
log(describeTemperatureDecision(model, decision), decision);
|
|
233
|
+
}
|
|
234
|
+
function subagentTemperature(model, metadata, temperature, log) {
|
|
235
|
+
if (temperature === undefined)
|
|
236
|
+
return;
|
|
237
|
+
const decision = resolveTemperatureCapability(model, metadata);
|
|
238
|
+
logTemperatureDecision(model, decision, log);
|
|
239
|
+
return decision.supported === true ? temperature : undefined;
|
|
240
|
+
}
|
|
241
|
+
|
|
137
242
|
// src/subagent-telemetry.ts
|
|
138
243
|
import { createHash } from "node:crypto";
|
|
139
244
|
var stepCaps = new Map(buildHiddenAgentRegistrations({
|
|
@@ -250,4 +355,4 @@ function readHostSystemPrompt(ctx) {
|
|
|
250
355
|
return;
|
|
251
356
|
}
|
|
252
357
|
|
|
253
|
-
export { buildHiddenAgentRegistrations, subagentStepCap, promptFingerprint, SubagentTelemetry, readHostSystemPrompt };
|
|
358
|
+
export { buildHiddenAgentRegistrations, logTemperatureDecision, subagentTemperature, subagentStepCap, promptFingerprint, SubagentTelemetry, readHostSystemPrompt };
|