@cortexkit/pi-magic-context 0.45.0 → 0.46.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/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-r01b1b78.js} +25 -24
- package/dist/index-td885aah.js +576 -0
- package/dist/index-vf38qhee.js +150 -0
- package/dist/{index-2pbbk3en.js → index-wv28nczk.js} +55 -1
- package/dist/{index-vxjgsr9m.js → index-xvw8zptx.js} +3565 -3349
- package/dist/{index-2bw9k8nx.js → index-ykb8kkm3.js} +1310 -1021
- package/dist/index.js +3309 -1480
- 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";
|
|
@@ -5287,6 +5293,7 @@ var AgentMetadataSchema = AgentOverrideConfigSchema.pick({
|
|
|
5287
5293
|
maxTokens: true
|
|
5288
5294
|
});
|
|
5289
5295
|
var DreamerConfigSchema = AgentMetadataSchema.extend({
|
|
5296
|
+
disable: boolean2().optional().describe("Disable this agent"),
|
|
5290
5297
|
runner: _enum(["broca", "host"]).optional().describe(`Which side runs the dreamer completions the Rust module routes (classify-memories) in Rust transform mode: "host" runs them on this process's carrier, "broca" routes them to the Broca module. When unset, historian.runner applies, and when that is unset too the harness decides the same way it does for the historian. User-level config only.`),
|
|
5291
5298
|
opencode: DreamerOpenCodeHarnessBlockSchema.optional(),
|
|
5292
5299
|
pi: DreamerPiHarnessBlockSchema.optional(),
|
|
@@ -5435,7 +5442,7 @@ var MagicContextConfigSchema = object({
|
|
|
5435
5442
|
smart_notes: object({
|
|
5436
5443
|
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
5444
|
}).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).
|
|
5445
|
+
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
5446
|
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
5447
|
output_reserve: union([
|
|
5441
5448
|
number2().min(0),
|
|
@@ -5473,8 +5480,8 @@ var MagicContextConfigSchema = object({
|
|
|
5473
5480
|
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
5481
|
}).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
5482
|
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;
|
|
5483
|
+
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.")
|
|
5484
|
+
}).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
5485
|
embedding: EmbeddingConfigSchema.default({
|
|
5479
5486
|
provider: "local",
|
|
5480
5487
|
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
@@ -5498,7 +5505,8 @@ var MagicContextConfigSchema = object({
|
|
|
5498
5505
|
overlay: boolean2().default(true).describe("Pi only: show the persistent todo overlay above the editor while tasks are active.")
|
|
5499
5506
|
}).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
5507
|
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:
|
|
5508
|
+
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 }),
|
|
5509
|
+
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
5510
|
caveman_text_compression: object({
|
|
5503
5511
|
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
5512
|
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 +5541,7 @@ var MagicContextConfigSchema = object({
|
|
|
5533
5541
|
};
|
|
5534
5542
|
});
|
|
5535
5543
|
var LIVE_RELOAD_CONFIG_PATHS = [
|
|
5544
|
+
"cache_ttl",
|
|
5536
5545
|
"mural.model",
|
|
5537
5546
|
"toast_duration_ms",
|
|
5538
5547
|
"historian.opencode.model",
|
|
@@ -5551,6 +5560,7 @@ var LIVE_RELOAD_CONFIG_PATHS = [
|
|
|
5551
5560
|
"commit_cluster_trigger.enabled",
|
|
5552
5561
|
"commit_cluster_trigger.min_clusters",
|
|
5553
5562
|
"memory.auto_promote",
|
|
5563
|
+
"dreamer.disable",
|
|
5554
5564
|
"dreamer.maxTokens",
|
|
5555
5565
|
"dreamer.opencode.model",
|
|
5556
5566
|
"dreamer.opencode.fallback_models",
|
|
@@ -8280,9 +8290,9 @@ async function acquireModelLoadLock(lockPath) {
|
|
|
8280
8290
|
const waitStart = Date.now();
|
|
8281
8291
|
while (true) {
|
|
8282
8292
|
try {
|
|
8283
|
-
const handle = await
|
|
8293
|
+
const handle = await createStorageFileHandleAsync(lockPath, "wx");
|
|
8284
8294
|
try {
|
|
8285
|
-
await handle
|
|
8295
|
+
await writeStorageFileHandleAsync(handle, `pid=${process.pid} started=${Date.now()}
|
|
8286
8296
|
`);
|
|
8287
8297
|
} catch {}
|
|
8288
8298
|
await handle.close();
|
|
@@ -8318,7 +8328,7 @@ async function acquireModelLoadLock(lockPath) {
|
|
|
8318
8328
|
function startLockHeartbeat(lockPath) {
|
|
8319
8329
|
const HEARTBEAT_MS = Math.floor(STALE_LOCK_MS / 3);
|
|
8320
8330
|
const timer = setInterval(() => {
|
|
8321
|
-
|
|
8331
|
+
writeStorageFileAsync(lockPath, `pid=${process.pid} alive=${Date.now()}
|
|
8322
8332
|
`).catch(() => {});
|
|
8323
8333
|
}, HEARTBEAT_MS);
|
|
8324
8334
|
timer.unref?.();
|
|
@@ -8681,16 +8691,7 @@ class LocalEmbeddingProvider {
|
|
|
8681
8691
|
}
|
|
8682
8692
|
const modelCacheDir = modelCacheDirForRuntime();
|
|
8683
8693
|
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
|
-
}
|
|
8694
|
+
ensureStorageDirectorySync(modelCacheDir);
|
|
8694
8695
|
env.cacheDir = modelCacheDir;
|
|
8695
8696
|
} catch {
|
|
8696
8697
|
log("[magic-context] could not create model cache dir, using library default");
|