@cortexkit/pi-magic-context 0.45.0 → 0.46.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/embedding-worker.js +4 -4
- package/dist/{index-j0mbc5vj.js → index-266qrgss.js} +59 -1
- package/dist/index-2p1e8706.js +30 -0
- package/dist/{index-k0yd1ph9.js → index-4vfrjwf6.js} +129 -166
- package/dist/{index-g0xfx1c2.js → index-phh7e055.js} +16 -1
- package/dist/{index-ttf0cqq8.js → index-sg8zbjs0.js} +23 -24
- package/dist/index-td885aah.js +576 -0
- package/dist/index-vf38qhee.js +150 -0
- package/dist/{index-2bw9k8nx.js → index-vhzmjpsk.js} +1308 -1019
- package/dist/{index-2pbbk3en.js → index-wv28nczk.js} +55 -1
- package/dist/{index-vxjgsr9m.js → index-xvw8zptx.js} +3565 -3349
- package/dist/index.js +3136 -1449
- package/dist/{message-time-backfill-g83dkh8m.js → message-time-backfill-4688z1k2.js} +2 -2
- package/dist/migration-worker.js +11 -6
- package/dist/{read-session-chunk-kmt7a6zj.js → read-session-chunk-tc6yn2pe.js} +5 -5
- package/dist/subagent-entry.js +10 -10
- package/package.json +4 -3
- package/dist/index-4d3cba70.js +0 -10
- package/dist/index-7s5yk3za.js +0 -16
- package/dist/index-e16q5sd7.js +0 -240
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
modelRefLookupOrder,
|
|
3
|
-
toolTemplateError
|
|
4
|
-
|
|
3
|
+
toolTemplateError,
|
|
4
|
+
DEFAULT_PROTECTED_TOOLS,
|
|
5
|
+
mergeProtectedTools
|
|
6
|
+
} from "./index-phh7e055.js";
|
|
5
7
|
import {
|
|
6
8
|
getHarness,
|
|
7
9
|
getMagicContextStorageDir,
|
|
@@ -10,14 +12,18 @@ import {
|
|
|
10
12
|
} from "./index-7n8gb6j3.js";
|
|
11
13
|
import {
|
|
12
14
|
estimateTokens
|
|
13
|
-
} from "./index-
|
|
15
|
+
} from "./index-266qrgss.js";
|
|
14
16
|
import {
|
|
15
|
-
shouldEnforcePrivateStoragePermissions
|
|
16
|
-
|
|
17
|
+
shouldEnforcePrivateStoragePermissions,
|
|
18
|
+
ensureStorageDirectorySync,
|
|
19
|
+
writeStorageFileAsync,
|
|
20
|
+
writeStorageFileHandleAsync,
|
|
21
|
+
createStorageFileHandleAsync
|
|
22
|
+
} from "./index-vf38qhee.js";
|
|
17
23
|
|
|
18
24
|
// ../plugin/src/features/magic-context/memory/embedding-local.ts
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
25
|
+
import { readdirSync, statSync } from "node:fs";
|
|
26
|
+
import { stat, unlink } from "node:fs/promises";
|
|
21
27
|
import { dirname, join } from "node:path";
|
|
22
28
|
import { pathToFileURL } from "node:url";
|
|
23
29
|
import { workerData } from "node:worker_threads";
|
|
@@ -5435,7 +5441,7 @@ var MagicContextConfigSchema = object({
|
|
|
5435
5441
|
smart_notes: object({
|
|
5436
5442
|
retina_handoff: boolean2().default(false).describe("When true, dreamer skips smart notes whose surface conditions compiled to retina provider configs at authoring time. Default false keeps both paths active until the retina consumer is deployed.")
|
|
5437
5443
|
}).default({ retina_handoff: false }).describe("Smart-note ownership transition controls."),
|
|
5438
|
-
cache_ttl: union([string2(), object({ default: string2() }).catchall(string2())]).default("5m").describe(`How long Magic Context assumes the provider's cached prefix stays valid. This is MC's own deferral gate — it does not change the provider's actual cache lifetime. String (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "provider/model": "1h", "provider/*": "never" }); keys resolve most-specific first (exact provider/model, bare model ID, shorter dash-prefixes, then the provider/* wildcard).
|
|
5444
|
+
cache_ttl: union([string2(), object({ default: string2() }).catchall(string2())]).default("5m").describe(`How long Magic Context assumes the provider's cached prefix stays valid. This is MC's own deferral gate — it does not change the provider's actual cache lifetime. String (e.g. "5m", "1h", "30s") or per-model object ({ default: "5m", "provider/model": "1h", "provider/*": "never" }); keys resolve most-specific first (exact provider/model, bare model ID, shorter dash-prefixes, then the provider/* wildcard, then default). User and project settings, including an explicit "5m" or object default, apply on the next pass. Only built-in defaults are frozen per session, including across restarts: when unset, GPT-5.6 and later (including gpt-6*, through any provider prefix) use 30m, other models use 5m. /ctx-status shows the effective TTL and whether it comes from your config or a frozen built-in default. Editing the TTL does not itself rewrite prompt bytes; a lowered TTL rebuilds only after normal idle expiry. OpenAI documents at least 30 minutes since the latest write or reuse: https://developers.openai.com/api/docs/guides/prompt-caching (Cache lifetime and Summary of model differences). Set to "never" to mean MC never assumes expiry (for lanes kept warm externally by a cache-keep tool) — disables the idle-TTL heuristic so MC never initiates a rebuild based on elapsed time. Provider-side extended TTL is a separate request-level concern (cache_control: { ttl } in the request body).`),
|
|
5439
5445
|
prompt_surface: PromptSurfaceConfigSchema.default({ default: "full" }).describe("Prompt-surface presets: default is full; models use bare model IDs, provider/model, or provider/* routing keys. Guidance and tool-description overrides are user-level only. OpenCode 1.x, Pi, and OMP register tool descriptions once per process (they follow the default preset). OpenCode 2 rewrites the five ctx_* descriptions per request from the draft model."),
|
|
5440
5446
|
output_reserve: union([
|
|
5441
5447
|
number2().min(0),
|
|
@@ -5473,8 +5479,8 @@ var MagicContextConfigSchema = object({
|
|
|
5473
5479
|
mmap_size_mb: number2().min(0).max(8192).default(0).describe("Memory-mapped I/O size in MiB (PRAGMA mmap_size). 0 disables mmap (SQLite default). Raising it can cut read overhead on large DBs at the cost of address space. (min 0, max 8192, default 0)")
|
|
5474
5480
|
}).default({ cache_size_mb: 64, mmap_size_mb: 0 }).describe("SQLite connection tuning for Magic Context's own context.db. These are per-connection PRAGMAs applied at open; they do not change the schema or what is stored."),
|
|
5475
5481
|
storage: object({
|
|
5476
|
-
enforce_private_permissions: boolean2().default(true).describe("When true (default), Magic Context creates and re-tightens its storage directories to owner-only 0700 and storage files to owner-only 0600. Set false only for a deliberate trusted-group deployment whose operator manages
|
|
5477
|
-
}).default({ enforce_private_permissions: true }).describe("Storage permission policy. The default keeps session content and memories owner-private. Disabling enforcement is for trusted shared-group storage managed externally;
|
|
5482
|
+
enforce_private_permissions: boolean2().default(true).describe("When true (default), Magic Context creates and re-tightens its TypeScript-mode storage directories to owner-only 0700 and storage files to owner-only 0600. Set false only for a deliberate trusted-group deployment whose operator manages those files externally; in TypeScript mode Magic Context then skips its own creation modes and recursive tightening. In Rust transform mode, ck-mc's store library always keeps the shared data directory owner-only 0700, regardless of this setting. USER-LEVEL ONLY — ignored in project config for security. On Windows, POSIX chmod modes are already meaningless, so this setting is a no-op.")
|
|
5483
|
+
}).default({ enforce_private_permissions: true }).describe("Storage permission policy. The default keeps session content and memories owner-private. Disabling enforcement is for trusted shared-group storage managed externally; TypeScript mode follows that policy, but Rust transform mode always keeps its shared data directory owner-only because ck-mc's store library enforces it."),
|
|
5478
5484
|
embedding: EmbeddingConfigSchema.default({
|
|
5479
5485
|
provider: "local",
|
|
5480
5486
|
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
@@ -5498,7 +5504,8 @@ var MagicContextConfigSchema = object({
|
|
|
5498
5504
|
overlay: boolean2().default(true).describe("Pi only: show the persistent todo overlay above the editor while tasks are active.")
|
|
5499
5505
|
}).default({ enabled: false, overlay: true }).describe("Pi-only todowrite tool and overlay controls. Pi registers tools and widgets at extension boot, so changing this after /cd requires /reload or restart."),
|
|
5500
5506
|
pi: PiConfigSchema.describe("Pi-only child-process extension controls. This setting is user-level only; project configuration cannot choose which extensions a user's subagent children load."),
|
|
5501
|
-
smart_drops:
|
|
5507
|
+
smart_drops: unknown().optional().describe("Deprecated: ignored. Content-aware supersession reclaim is always on, only on passes already rebuilding the cache. Remove this key; it no longer does anything.").meta({ deprecated: true }),
|
|
5508
|
+
protected_tools: record(string2(), number2().int().nonnegative()).default({ ...DEFAULT_PROTECTED_TOOLS }).transform((map) => mergeProtectedTools(map)).describe("Keep each tool's newest N still-active results in every automatic drop lane (issue 621). User and project maps merge over defaults {todowrite: 1, ctx_reduce: 3}; 0 turns protection off. Names are case-insensitive and ignore leading mcp_. Holds even at 95% pressure, with no byte cap: large protected outputs can reach refusal sooner. Queued drops, from the agent or historian publication, are held until newer calls displace the result and a later cache-rebuilding pass applies them. The historian's summary is unaffected; the raw result leaves at the next fold. Frozen strips are unaffected. Changes and rotation never originate a bust; dropped results are never restored."),
|
|
5502
5509
|
caveman_text_compression: object({
|
|
5503
5510
|
enabled: boolean2().default(false).describe("Apply deterministic caveman-style text compression to old conversation text. Active for primary sessions when enabled; never for subagents. Compresses user/assistant text in oldest-first tiers: ultra (oldest 20%), full, lite, untouched (newest 40%)."),
|
|
5504
5511
|
min_chars: number2().min(100).max(1e4).default(500).describe("Text parts shorter than this (characters) stay untouched. Min 100, max 10000. Default: 500.")
|
|
@@ -5533,6 +5540,7 @@ var MagicContextConfigSchema = object({
|
|
|
5533
5540
|
};
|
|
5534
5541
|
});
|
|
5535
5542
|
var LIVE_RELOAD_CONFIG_PATHS = [
|
|
5543
|
+
"cache_ttl",
|
|
5536
5544
|
"mural.model",
|
|
5537
5545
|
"toast_duration_ms",
|
|
5538
5546
|
"historian.opencode.model",
|
|
@@ -8280,9 +8288,9 @@ async function acquireModelLoadLock(lockPath) {
|
|
|
8280
8288
|
const waitStart = Date.now();
|
|
8281
8289
|
while (true) {
|
|
8282
8290
|
try {
|
|
8283
|
-
const handle = await
|
|
8291
|
+
const handle = await createStorageFileHandleAsync(lockPath, "wx");
|
|
8284
8292
|
try {
|
|
8285
|
-
await handle
|
|
8293
|
+
await writeStorageFileHandleAsync(handle, `pid=${process.pid} started=${Date.now()}
|
|
8286
8294
|
`);
|
|
8287
8295
|
} catch {}
|
|
8288
8296
|
await handle.close();
|
|
@@ -8318,7 +8326,7 @@ async function acquireModelLoadLock(lockPath) {
|
|
|
8318
8326
|
function startLockHeartbeat(lockPath) {
|
|
8319
8327
|
const HEARTBEAT_MS = Math.floor(STALE_LOCK_MS / 3);
|
|
8320
8328
|
const timer = setInterval(() => {
|
|
8321
|
-
|
|
8329
|
+
writeStorageFileAsync(lockPath, `pid=${process.pid} alive=${Date.now()}
|
|
8322
8330
|
`).catch(() => {});
|
|
8323
8331
|
}, HEARTBEAT_MS);
|
|
8324
8332
|
timer.unref?.();
|
|
@@ -8681,16 +8689,7 @@ class LocalEmbeddingProvider {
|
|
|
8681
8689
|
}
|
|
8682
8690
|
const modelCacheDir = modelCacheDirForRuntime();
|
|
8683
8691
|
try {
|
|
8684
|
-
|
|
8685
|
-
mkdirSync(modelCacheDir, { recursive: true, mode: 448 });
|
|
8686
|
-
if (process.platform !== "win32") {
|
|
8687
|
-
try {
|
|
8688
|
-
chmodSync(modelCacheDir, 448);
|
|
8689
|
-
} catch {}
|
|
8690
|
-
}
|
|
8691
|
-
} else {
|
|
8692
|
-
mkdirSync(modelCacheDir, { recursive: true });
|
|
8693
|
-
}
|
|
8692
|
+
ensureStorageDirectorySync(modelCacheDir);
|
|
8694
8693
|
env.cacheDir = modelCacheDir;
|
|
8695
8694
|
} catch {
|
|
8696
8695
|
log("[magic-context] could not create model cache dir, using library default");
|