@cortexkit/opencode-magic-context 0.49.24 → 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 +1 -1
- package/dist/chunk-embedding-write-worker.js +2 -2
- package/dist/{context-tvrjhnmj.js → context-keb00be8.js} +22 -16
- 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/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/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/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/transform.d.ts.map +1 -1
- package/dist/{index-dds7cxhz.js → index-0s8454t2.js} +9 -9
- package/dist/{index-p6evxfcc.js → index-awcftgmx.js} +5 -47
- package/dist/{index-8e9qsnrw.js → index-axjgxeww.js} +6 -4
- package/dist/{index-57jf5ztp.js → index-bhyksfyy.js} +1 -1
- package/dist/index-cfaet9cg.js +405 -0
- package/dist/{index-7516anfj.js → index-ebsvmc5s.js} +3 -3
- package/dist/{index-21bkd3m6.js → index-n18sch77.js} +1 -1
- package/dist/{index-jrjr58ez.js → index-q7ywt6xt.js} +2 -2
- package/dist/{index-6g7tyb6e.js → index-y6xpzjzr.js} +69 -24
- package/dist/{index-t1zk694n.js → index-yrrsp47d.js} +13 -11
- package/dist/{index-jd0y50w3.js → index-zzrzjnx5.js} +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -20
- package/dist/{message-index-1sgzev6c.js → message-index-3g966xn7.js} +3 -3
- package/dist/{message-index-bounded-k8pgrxad.js → message-index-bounded-vaeqhp9w.js} +3 -3
- package/dist/migration-worker.js +2 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-q9z6s48t.js → read-session-chunk-z5gnc0zb.js} +2 -2
- package/dist/{recomp-orchestrator-hr8ddk8z.js → recomp-orchestrator-qwqeskhq.js} +6 -6
- package/dist/{search-3zjjmc60.js → search-84zfqeky.js} +4 -4
- package/dist/{search-archive-c00etw7k.js → search-archive-mfabzyn2.js} +3 -3
- package/dist/{transform-postprocess-phase-rredw6bz.js → transform-postprocess-phase-hr1ntmjj.js} +6 -6
- package/dist/v2/auto-search-worker.js +1 -1
- package/dist/v2/chunk-embedding-write-worker.js +2 -2
- package/dist/v2/{context-zbydzq4g.js → context-y7wfvdve.js} +77 -26
- package/dist/v2/hooks/context.d.ts +4 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-a9xa8wsq.js → message-index-bounded-te303atj.js} +3 -3
- package/dist/v2/{message-index-5gnnn64b.js → message-index-fz6b4jeh.js} +3 -3
- package/dist/v2/migration-worker.js +2 -2
- package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
- package/dist/v2/{read-session-chunk-qqvda7zv.js → read-session-chunk-knvkq1hf.js} +2 -2
- package/dist/v2/{recomp-orchestrator-nmt9y25j.js → recomp-orchestrator-e8a4jpvr.js} +5 -5
- package/dist/v2/{search-archive-dhqj1w31.js → search-archive-vrwgxv6z.js} +3 -3
- package/dist/v2/{search-6dawx2gt.js → search-hav4dggf.js} +4 -4
- package/dist/v2/{server-gwmshgx9.js → server-5brp2rfn.js} +13 -11
- package/dist/v2/{server-mefps930.js → server-6a8pxpxg.js} +5 -47
- package/dist/v2/server-7d6m1p2b.js +361 -0
- package/dist/v2/{server-r209n2fk.js → server-7weh65vd.js} +9 -9
- package/dist/v2/{server-y9ncq4ck.js → server-e75vag9d.js} +2 -2
- package/dist/v2/{server-16dpnz56.js → server-m6yyn961.js} +1 -1
- package/dist/v2/{server-9e55n4wx.js → server-tfawsj08.js} +1 -1
- package/dist/v2/server.js +2 -2
- package/dist/v2/{wrapup-orchestrator-9z81xj66.js → wrapup-orchestrator-ycs8y6n4.js} +5 -5
- package/dist/{wrapup-orchestrator-dbnb530w.js → wrapup-orchestrator-f642w8n3.js} +7 -7
- package/package.json +1 -1
- package/dist/index-j76ah6d7.js +0 -120
- package/dist/v2/server-d1dzgvwd.js +0 -120
package/dist/v2/server.js
CHANGED
|
@@ -7874,7 +7874,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7874
7874
|
// package.json
|
|
7875
7875
|
var package_default = {
|
|
7876
7876
|
name: "@cortexkit/opencode-magic-context",
|
|
7877
|
-
version: "0.49.
|
|
7877
|
+
version: "0.49.25",
|
|
7878
7878
|
type: "module",
|
|
7879
7879
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7880
7880
|
main: "dist/index.js",
|
|
@@ -8195,7 +8195,7 @@ async function setup(context) {
|
|
|
8195
8195
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8196
8196
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
8197
8197
|
}
|
|
8198
|
-
const { registerContext } = await import("./context-
|
|
8198
|
+
const { registerContext } = await import("./context-y7wfvdve.js");
|
|
8199
8199
|
setHarness2("opencode2");
|
|
8200
8200
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8201
8201
|
const duties = await registerContext(context);
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
registerActiveCompartmentRun,
|
|
20
20
|
setRecompStarting2,
|
|
21
21
|
setRecompTerminal2
|
|
22
|
-
} from "./server-
|
|
22
|
+
} from "./server-7weh65vd.js";
|
|
23
23
|
import"./server-q5z0gag0.js";
|
|
24
24
|
import"./server-3mz2qh5a.js";
|
|
25
25
|
import"./server-ab1g0wn9.js";
|
|
@@ -31,7 +31,7 @@ import"./server-cpjk5jd2.js";
|
|
|
31
31
|
import"./server-swvhxhxz.js";
|
|
32
32
|
import"./server-wxrdher8.js";
|
|
33
33
|
import"./server-pw21ypwb.js";
|
|
34
|
-
import"./server-
|
|
34
|
+
import"./server-6a8pxpxg.js";
|
|
35
35
|
import {
|
|
36
36
|
getWrapupInProgressState,
|
|
37
37
|
acquireWrapupInProgress,
|
|
@@ -40,15 +40,15 @@ import {
|
|
|
40
40
|
getHistorianFailureState,
|
|
41
41
|
clearEmergencyRecovery,
|
|
42
42
|
prepareRawSessionOrdinals2
|
|
43
|
-
} from "./server-
|
|
43
|
+
} from "./server-5brp2rfn.js";
|
|
44
44
|
import"./server-rqebawx1.js";
|
|
45
|
-
import"./server-
|
|
45
|
+
import"./server-e75vag9d.js";
|
|
46
46
|
import"./server-1zx87sdm.js";
|
|
47
47
|
import"./server-fa7vtp40.js";
|
|
48
48
|
import"./server-24g8r2d0.js";
|
|
49
49
|
import"./server-2ra6pwf3.js";
|
|
50
50
|
import"./server-3vhxy2k5.js";
|
|
51
|
-
import"./server-
|
|
51
|
+
import"./server-7d6m1p2b.js";
|
|
52
52
|
import"./server-fr0wbhdn.js";
|
|
53
53
|
import"./server-wwaw5npa.js";
|
|
54
54
|
import"./server-qjvk4a9t.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runManagedWrapup2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-ebsvmc5s.js";
|
|
4
|
+
import"./index-zzrzjnx5.js";
|
|
5
|
+
import"./index-0s8454t2.js";
|
|
6
6
|
import"./index-qgh1qwjj.js";
|
|
7
7
|
import"./index-z928hmnp.js";
|
|
8
|
-
import"./index-
|
|
8
|
+
import"./index-awcftgmx.js";
|
|
9
9
|
import"./index-sd3egckz.js";
|
|
10
10
|
import"./index-t6j3qxnd.js";
|
|
11
11
|
import"./index-z05n7702.js";
|
|
@@ -14,7 +14,7 @@ import"./index-4dhv7mqz.js";
|
|
|
14
14
|
import"./index-spwjbkc7.js";
|
|
15
15
|
import"./index-jcr6pe7z.js";
|
|
16
16
|
import"./index-qt1qqasc.js";
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-yrrsp47d.js";
|
|
18
18
|
import"./index-whcgcfrv.js";
|
|
19
19
|
import"./index-1zx87sdm.js";
|
|
20
20
|
import"./index-c9zrgcnt.js";
|
|
@@ -25,14 +25,14 @@ import"./index-nxrsns5x.js";
|
|
|
25
25
|
import"./index-kfyb3k6n.js";
|
|
26
26
|
import"./index-3d5wnkq7.js";
|
|
27
27
|
import"./index-wfybj1dw.js";
|
|
28
|
-
import"./index-
|
|
28
|
+
import"./index-q7ywt6xt.js";
|
|
29
29
|
import"./index-fb3zxn06.js";
|
|
30
30
|
import"./index-9q1g3c5q.js";
|
|
31
31
|
import"./index-kq5w68dp.js";
|
|
32
32
|
import"./index-szf8r0ba.js";
|
|
33
33
|
import"./index-fr0wbhdn.js";
|
|
34
34
|
import"./index-c7phnbvk.js";
|
|
35
|
-
import"./index-
|
|
35
|
+
import"./index-cfaet9cg.js";
|
|
36
36
|
import"./index-x9k3mqrf.js";
|
|
37
37
|
import"./index-58e3y90n.js";
|
|
38
38
|
import"./index-7tdtpqrg.js";
|
package/package.json
CHANGED
package/dist/index-j76ah6d7.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
estimateTokens
|
|
3
|
-
} from "./index-b88dwwrh.js";
|
|
4
|
-
import {
|
|
5
|
-
stableStringify
|
|
6
|
-
} from "./index-x9k3mqrf.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 };
|
|
@@ -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 };
|