@cortexkit/pi-magic-context 0.40.1 → 0.41.1
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/README.md +9 -0
- package/dist/historian-calibration-extension.js +64 -0
- package/dist/{index-fre7qcqg.js → index-0jgz8yja.js} +833 -499
- package/dist/index-q2vgz0j1.js +463 -0
- package/dist/index.js +1380 -493
- package/dist/{safe-notification-target-q00qgjm6.js → safe-notification-target-hjcb423r.js} +1 -1
- package/dist/subagent-entry.js +2 -2
- package/dist/transformers-web.js +24570 -0
- package/dist/transformers.node-b1wa0hgx.js +28808 -0
- package/package.json +92 -87
- package/dist/index-hk6sj7dn.js +0 -147
- /package/dist/{index-8sseka65.js → index-y63nbvkk.js} +0 -0
package/README.md
CHANGED
|
@@ -131,6 +131,15 @@ Magic Context stores everything in a single shared SQLite database at:
|
|
|
131
131
|
~/.local/share/cortexkit/magic-context/context.db
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
When a host isolates `XDG_DATA_HOME` per process, set
|
|
135
|
+
`MAGIC_CONTEXT_STORAGE_DIR` to the absolute, complete shared Magic Context
|
|
136
|
+
storage directory. The explicit path takes precedence over the XDG-derived path
|
|
137
|
+
and does not change Pi's own configuration or session directories. The host must
|
|
138
|
+
propagate one identical value to every process that shares the database; Magic
|
|
139
|
+
Context never originates this variable from its default. This affects the
|
|
140
|
+
harness-side database only, not `subc` daemon state. Mixed-version processes on
|
|
141
|
+
one directory still block migrations until all processes use a compatible build.
|
|
142
|
+
|
|
134
143
|
This is the **same database** the OpenCode plugin and OMP extension use. Tables are scoped by:
|
|
135
144
|
- `harness` column (`'pi'` or `'opencode'`) for session-scoped data; OMP intentionally uses `'pi'`
|
|
136
145
|
- `project_path` (resolved git root) for project-scoped data (memories, embeddings, dreamer runs)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import"./index-1yh8g550.js";
|
|
2
|
+
|
|
3
|
+
// src/historian-calibration-extension.ts
|
|
4
|
+
var HISTORIAN_TEMPERATURE_ENV = "MAGIC_CONTEXT_HISTORIAN_TEMPERATURE";
|
|
5
|
+
var HISTORIAN_MAX_OUTPUT_TOKENS_ENV = "MAGIC_CONTEXT_HISTORIAN_MAX_OUTPUT_TOKENS";
|
|
6
|
+
function finiteNumber(value) {
|
|
7
|
+
if (value === undefined || value.trim().length === 0)
|
|
8
|
+
return;
|
|
9
|
+
const parsed = Number(value);
|
|
10
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
|
|
11
|
+
}
|
|
12
|
+
function calibrateHistorianProviderPayload(payload, temperature, maxOutputTokens) {
|
|
13
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
14
|
+
return payload;
|
|
15
|
+
if (temperature === undefined && maxOutputTokens === undefined)
|
|
16
|
+
return payload;
|
|
17
|
+
const calibrated = { ...payload };
|
|
18
|
+
const generationConfig = calibrated.generationConfig;
|
|
19
|
+
if (typeof generationConfig === "object" && generationConfig !== null && !Array.isArray(generationConfig)) {
|
|
20
|
+
calibrated.generationConfig = {
|
|
21
|
+
...generationConfig,
|
|
22
|
+
...temperature !== undefined ? { temperature } : {},
|
|
23
|
+
...maxOutputTokens !== undefined ? { maxOutputTokens } : {}
|
|
24
|
+
};
|
|
25
|
+
return calibrated;
|
|
26
|
+
}
|
|
27
|
+
const inferenceConfig = calibrated.inferenceConfig;
|
|
28
|
+
if (typeof inferenceConfig === "object" && inferenceConfig !== null && !Array.isArray(inferenceConfig)) {
|
|
29
|
+
calibrated.inferenceConfig = {
|
|
30
|
+
...inferenceConfig,
|
|
31
|
+
...temperature !== undefined ? { temperature } : {},
|
|
32
|
+
...maxOutputTokens !== undefined ? { maxTokens: maxOutputTokens } : {}
|
|
33
|
+
};
|
|
34
|
+
return calibrated;
|
|
35
|
+
}
|
|
36
|
+
if (temperature !== undefined) {
|
|
37
|
+
calibrated.temperature = temperature;
|
|
38
|
+
}
|
|
39
|
+
if (maxOutputTokens !== undefined) {
|
|
40
|
+
if ("max_output_tokens" in calibrated) {
|
|
41
|
+
calibrated.max_output_tokens = maxOutputTokens;
|
|
42
|
+
} else if ("max_completion_tokens" in calibrated) {
|
|
43
|
+
calibrated.max_completion_tokens = maxOutputTokens;
|
|
44
|
+
} else if ("max_tokens" in calibrated) {
|
|
45
|
+
calibrated.max_tokens = maxOutputTokens;
|
|
46
|
+
} else if ("maxTokens" in calibrated) {
|
|
47
|
+
calibrated.maxTokens = maxOutputTokens;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return calibrated;
|
|
51
|
+
}
|
|
52
|
+
function historianCalibrationExtension(pi) {
|
|
53
|
+
const temperature = finiteNumber(process.env[HISTORIAN_TEMPERATURE_ENV]);
|
|
54
|
+
const maxOutputTokens = finiteNumber(process.env[HISTORIAN_MAX_OUTPUT_TOKENS_ENV]);
|
|
55
|
+
if (temperature === undefined && maxOutputTokens === undefined)
|
|
56
|
+
return;
|
|
57
|
+
pi.on("before_provider_request", (event) => calibrateHistorianProviderPayload(event.payload, temperature, maxOutputTokens));
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
HISTORIAN_MAX_OUTPUT_TOKENS_ENV,
|
|
61
|
+
HISTORIAN_TEMPERATURE_ENV,
|
|
62
|
+
calibrateHistorianProviderPayload,
|
|
63
|
+
historianCalibrationExtension as default
|
|
64
|
+
};
|