@cortexkit/opencode-magic-context 0.49.24 → 0.49.26
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 +5 -5
- package/dist/{compartment-chunk-embedding-eypvn607.js → compartment-chunk-embedding-96ec8a7h.js} +3 -3
- package/dist/{conflict-warning-hook-a27bhggg.js → conflict-warning-hook-dv8fdc2w.js} +4 -4
- package/dist/{context-tvrjhnmj.js → context-pjqa24nd.js} +30 -24
- package/dist/{embedding-backfill-vddgmem3.js → embedding-backfill-a91rvdf9.js} +5 -5
- package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -57
- package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +14 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +11 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/foreign-text-parts.d.ts +47 -0
- package/dist/hooks/magic-context/foreign-text-parts.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +21 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +20 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
- package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-messages.d.ts +15 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +7 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-2haxh8h3.js → index-064v90e8.js} +1 -1
- package/dist/{index-p6evxfcc.js → index-40ma8m0c.js} +7 -49
- package/dist/{index-6g7tyb6e.js → index-56tfs78r.js} +96 -41
- package/dist/{index-jrjr58ez.js → index-6g1zq1sk.js} +3 -3
- package/dist/{index-3d5wnkq7.js → index-6tmf87w0.js} +1 -1
- package/dist/index-cfaet9cg.js +405 -0
- package/dist/{index-t1zk694n.js → index-dn2ke3b9.js} +30 -14
- package/dist/{index-t6j3qxnd.js → index-e5b61ty6.js} +1 -1
- package/dist/{index-dds7cxhz.js → index-hjnrp6vy.js} +67 -21
- package/dist/{index-c9zrgcnt.js → index-j43m40zd.js} +1 -1
- package/dist/{index-7tdtpqrg.js → index-m8va3mma.js} +39 -6
- package/dist/{index-z928hmnp.js → index-mphkpyap.js} +1 -1
- package/dist/{index-21bkd3m6.js → index-r3bteyev.js} +5 -5
- package/dist/{index-8e9qsnrw.js → index-rp78nqvr.js} +169 -11
- package/dist/{index-z05n7702.js → index-sgchhbvy.js} +1 -1
- package/dist/{index-jd0y50w3.js → index-va2g2q57.js} +3 -3
- package/dist/{index-jcr6pe7z.js → index-w55zp7kf.js} +1 -1
- package/dist/{index-szf8r0ba.js → index-xbbgcwd2.js} +1 -1
- package/dist/{index-7516anfj.js → index-xyx2ge2y.js} +4 -4
- package/dist/{index-57jf5ztp.js → index-zn2n24yr.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -35
- package/dist/{message-fts-rowid-map-9e1getgs.js → message-fts-rowid-map-4ksatb6f.js} +2 -2
- package/dist/{message-index-bounded-k8pgrxad.js → message-index-bounded-whh5wv4a.js} +7 -7
- package/dist/{message-index-1sgzev6c.js → message-index-ywx53y30.js} +7 -7
- package/dist/migration-worker.js +4 -4
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-rstzmb60.js → project-embedding-registry-t9fx6jwh.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-q9z6s48t.js → read-session-chunk-mqmkgdx0.js} +6 -4
- package/dist/{read-session-raw-s4amywnh.js → read-session-raw-dy2xxafq.js} +3 -1
- package/dist/{recomp-orchestrator-hr8ddk8z.js → recomp-orchestrator-qwcz86r1.js} +14 -14
- package/dist/{search-archive-c00etw7k.js → search-archive-8md3twv2.js} +5 -5
- package/dist/{search-3zjjmc60.js → search-y2t97tbb.js} +11 -11
- package/dist/{send-session-notification-ygj4mja0.js → send-session-notification-kzazs7fy.js} +3 -3
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-rredw6bz.js → transform-postprocess-phase-ppm1tfa7.js} +14 -14
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +5 -5
- package/dist/v2/{compartment-chunk-embedding-tk6g4q80.js → compartment-chunk-embedding-5rmrn09z.js} +3 -3
- package/dist/v2/{context-zbydzq4g.js → context-10pj3bwd.js} +245 -45
- package/dist/v2/{embedding-backfill-w5qp7t28.js → embedding-backfill-r9mzt2eg.js} +5 -5
- package/dist/v2/hooks/context.d.ts +4 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-pqk3a55v.js → message-fts-rowid-map-2s3ta05x.js} +2 -2
- package/dist/v2/{message-index-bounded-a9xa8wsq.js → message-index-bounded-f4269d3a.js} +6 -6
- package/dist/v2/{message-index-5gnnn64b.js → message-index-v6g8mgn7.js} +6 -6
- package/dist/v2/migration-worker.js +4 -4
- package/dist/v2/{project-embedding-registry-e7zftfvj.js → project-embedding-registry-tgtmart7.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
- package/dist/v2/{read-session-chunk-qqvda7zv.js → read-session-chunk-ym5zvexn.js} +5 -3
- package/dist/v2/{read-session-raw-ppjxnqk4.js → read-session-raw-484g8kf2.js} +3 -1
- package/dist/v2/{recomp-orchestrator-nmt9y25j.js → recomp-orchestrator-b44s2snm.js} +11 -11
- package/dist/v2/{search-6dawx2gt.js → search-75tf953m.js} +10 -10
- package/dist/v2/{search-archive-dhqj1w31.js → search-archive-pmf2c1kb.js} +4 -4
- package/dist/v2/{send-session-notification-f8scq6ae.js → send-session-notification-gd21f5rq.js} +1 -1
- package/dist/v2/{server-y9ncq4ck.js → server-317f3x9y.js} +3 -3
- package/dist/v2/{server-wxrdher8.js → server-4frtg2z1.js} +1 -1
- package/dist/v2/server-7d6m1p2b.js +361 -0
- package/dist/v2/{server-pw21ypwb.js → server-7dpnt0ys.js} +1 -1
- package/dist/v2/{server-r209n2fk.js → server-9zh78t8y.js} +65 -19
- package/dist/v2/{server-swvhxhxz.js → server-erk2bvdf.js} +39 -6
- package/dist/v2/{server-q5z0gag0.js → server-hnmm8yzq.js} +1 -1
- package/dist/v2/{server-gwmshgx9.js → server-jcsw05aa.js} +29 -13
- package/dist/v2/{server-mefps930.js → server-k46ec388.js} +7 -49
- package/dist/v2/{server-9xbbaekh.js → server-nmwhe524.js} +1 -1
- package/dist/v2/{server-9e55n4wx.js → server-vjer2jdn.js} +5 -5
- package/dist/v2/{server-16dpnz56.js → server-w7x9wgm0.js} +2 -2
- package/dist/v2/{server-8j2e7t31.js → server-wj8h2q21.js} +1 -1
- package/dist/v2/server.js +2 -2
- package/dist/v2/{wrapup-orchestrator-9z81xj66.js → wrapup-orchestrator-gwww44st.js} +11 -11
- package/dist/{wrapup-orchestrator-dbnb530w.js → wrapup-orchestrator-a9r8r4sk.js} +15 -15
- package/package.json +1 -1
- package/dist/index-j76ah6d7.js +0 -120
- package/dist/v2/server-d1dzgvwd.js +0 -120
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
estimateTokens
|
|
3
|
-
} from "./server-3mz2qh5a.js";
|
|
4
|
-
import {
|
|
5
|
-
stableStringify
|
|
6
|
-
} from "./server-rqebawx1.js";
|
|
7
|
-
|
|
8
|
-
// src/features/magic-context/tool-definition-tokens.ts
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
var measurements = new Map;
|
|
11
|
-
var fingerprints = new Map;
|
|
12
|
-
var persistenceDb = null;
|
|
13
|
-
var cachedInsertStmt = null;
|
|
14
|
-
function keyFor(providerID, modelID, agentName) {
|
|
15
|
-
const agent = agentName && agentName.length > 0 ? agentName : "default";
|
|
16
|
-
return `${providerID}/${modelID}/${agent}`;
|
|
17
|
-
}
|
|
18
|
-
function fingerprintFor(description, parameters) {
|
|
19
|
-
return createHash("sha256").update(description).update("\x00").update(stableStringify(parameters)).digest("hex");
|
|
20
|
-
}
|
|
21
|
-
function getCurrentToolSetHash(providerID, modelID, agentName) {
|
|
22
|
-
if (!providerID || !modelID)
|
|
23
|
-
return "";
|
|
24
|
-
const toolIds = measurements.get(keyFor(providerID, modelID, agentName));
|
|
25
|
-
if (!toolIds || toolIds.size === 0)
|
|
26
|
-
return "";
|
|
27
|
-
return createHash("sha256").update(Array.from(toolIds.keys()).sort().join("\x00")).digest("hex");
|
|
28
|
-
}
|
|
29
|
-
function getToolDefinitionMeasurementSignature(providerID, modelID, agentName) {
|
|
30
|
-
const key = keyFor(providerID, modelID, agentName);
|
|
31
|
-
const measured = measurements.get(key);
|
|
32
|
-
const observed = fingerprints.get(key);
|
|
33
|
-
if (!measured || !observed || [...measured.keys()].some((id) => !observed.has(id)))
|
|
34
|
-
return;
|
|
35
|
-
return createHash("sha256").update(JSON.stringify([...measured.keys()].sort().map((id) => [id, observed.get(id)]))).digest("hex");
|
|
36
|
-
}
|
|
37
|
-
function setDatabase(db) {
|
|
38
|
-
persistenceDb = db;
|
|
39
|
-
cachedInsertStmt = null;
|
|
40
|
-
}
|
|
41
|
-
function loadToolDefinitionMeasurements(db) {
|
|
42
|
-
let rows = [];
|
|
43
|
-
try {
|
|
44
|
-
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count FROM tool_definition_measurements").all();
|
|
45
|
-
} catch {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (const row of rows) {
|
|
49
|
-
const key = keyFor(row.provider_id, row.model_id, row.agent_name);
|
|
50
|
-
let inner = measurements.get(key);
|
|
51
|
-
if (!inner) {
|
|
52
|
-
inner = new Map;
|
|
53
|
-
measurements.set(key, inner);
|
|
54
|
-
}
|
|
55
|
-
inner.set(row.tool_id, row.token_count);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function recordToolDefinition(providerID, modelID, agentName, toolID, description, parameters) {
|
|
59
|
-
if (!providerID || !modelID || !toolID)
|
|
60
|
-
return;
|
|
61
|
-
const key = keyFor(providerID, modelID, agentName);
|
|
62
|
-
const fp = fingerprintFor(description ?? "", parameters);
|
|
63
|
-
let innerFp = fingerprints.get(key);
|
|
64
|
-
if (innerFp && innerFp.get(toolID) === fp)
|
|
65
|
-
return;
|
|
66
|
-
let paramsText = "";
|
|
67
|
-
try {
|
|
68
|
-
paramsText = parameters === undefined ? "" : JSON.stringify(parameters);
|
|
69
|
-
} catch {
|
|
70
|
-
paramsText = "";
|
|
71
|
-
}
|
|
72
|
-
const tokens = estimateTokens(description ?? "") + estimateTokens(paramsText);
|
|
73
|
-
let inner = measurements.get(key);
|
|
74
|
-
if (!inner) {
|
|
75
|
-
inner = new Map;
|
|
76
|
-
measurements.set(key, inner);
|
|
77
|
-
}
|
|
78
|
-
inner.set(toolID, tokens);
|
|
79
|
-
if (!innerFp) {
|
|
80
|
-
innerFp = new Map;
|
|
81
|
-
fingerprints.set(key, innerFp);
|
|
82
|
-
}
|
|
83
|
-
innerFp.set(toolID, fp);
|
|
84
|
-
if (persistenceDb) {
|
|
85
|
-
try {
|
|
86
|
-
const agent = agentName && agentName.length > 0 ? agentName : "default";
|
|
87
|
-
if (!cachedInsertStmt) {
|
|
88
|
-
cachedInsertStmt = persistenceDb.prepare(`INSERT OR REPLACE INTO tool_definition_measurements
|
|
89
|
-
(provider_id, model_id, agent_name, tool_id, token_count, recorded_at)
|
|
90
|
-
VALUES (?, ?, ?, ?, ?, ?)`);
|
|
91
|
-
}
|
|
92
|
-
cachedInsertStmt.run(providerID, modelID, agent, toolID, tokens, Date.now());
|
|
93
|
-
} catch {
|
|
94
|
-
cachedInsertStmt = null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function getLargestMeasuredToolDefinitionTokens() {
|
|
99
|
-
let largest = 0;
|
|
100
|
-
for (const tools of measurements.values()) {
|
|
101
|
-
let total = 0;
|
|
102
|
-
for (const tokens of tools.values())
|
|
103
|
-
total += tokens;
|
|
104
|
-
largest = Math.max(largest, total);
|
|
105
|
-
}
|
|
106
|
-
return largest > 0 ? largest : undefined;
|
|
107
|
-
}
|
|
108
|
-
function getMeasuredToolDefinitionTokens(providerID, modelID, agentName) {
|
|
109
|
-
if (!providerID || !modelID)
|
|
110
|
-
return;
|
|
111
|
-
const inner = measurements.get(keyFor(providerID, modelID, agentName));
|
|
112
|
-
if (!inner || inner.size === 0)
|
|
113
|
-
return;
|
|
114
|
-
let total = 0;
|
|
115
|
-
for (const tokens of inner.values())
|
|
116
|
-
total += tokens;
|
|
117
|
-
return total;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export { getCurrentToolSetHash, getToolDefinitionMeasurementSignature, setDatabase, loadToolDefinitionMeasurements, recordToolDefinition, getLargestMeasuredToolDefinitionTokens, getMeasuredToolDefinitionTokens };
|