@cortexkit/pi-magic-context 0.39.0 → 0.40.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/{index-qqgk7jmy.js → index-fre7qcqg.js} +1071 -397
- package/dist/index.js +46 -316
- package/dist/subagent-entry.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
DEFAULT_MEMORY_BUDGET_TOKENS,
|
|
14
14
|
DEFAULT_USER_PROFILE_BUDGET_TOKENS,
|
|
15
15
|
Database,
|
|
16
|
+
FAIL_CLOSED_DOCTOR_COMMAND,
|
|
16
17
|
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
17
18
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
18
19
|
LATEST_SUPPORTED_VERSION,
|
|
@@ -86,6 +87,8 @@ import {
|
|
|
86
87
|
copySessionStateForClone,
|
|
87
88
|
cosineSimilarity,
|
|
88
89
|
countPrimerCandidatesForProject,
|
|
90
|
+
createFailClosedBlockingError,
|
|
91
|
+
createFailClosedController,
|
|
89
92
|
createPrimer,
|
|
90
93
|
createPromptSurfaceGuidanceEpochCache,
|
|
91
94
|
createPromptSurfaceRuntime,
|
|
@@ -125,6 +128,7 @@ import {
|
|
|
125
128
|
findAdoptableFallbackTags,
|
|
126
129
|
findLastModelKeyFromBranch,
|
|
127
130
|
findPiFallbackToolOwnerTags,
|
|
131
|
+
formatFailClosedBlockingMessage,
|
|
128
132
|
formatWindowDerivationLine,
|
|
129
133
|
getActivePrimers,
|
|
130
134
|
getActiveTagsBySession,
|
|
@@ -226,6 +230,7 @@ import {
|
|
|
226
230
|
hasMuralCueColumns,
|
|
227
231
|
hasPiFallbackMessageTags,
|
|
228
232
|
hasPiFallbackToolOwnerTags,
|
|
233
|
+
hasShareabilitySensitiveText,
|
|
229
234
|
incrementHistorianFailure,
|
|
230
235
|
indexCommitsForProject,
|
|
231
236
|
indexMessagesAfterOrdinal,
|
|
@@ -241,6 +246,7 @@ import {
|
|
|
241
246
|
isCompartmentLeaseHeld,
|
|
242
247
|
isDreamerRunnable,
|
|
243
248
|
isEditTool,
|
|
249
|
+
isFailClosedBlockingError,
|
|
244
250
|
isMessageIndexReconciledThrough,
|
|
245
251
|
isMessageIndexSourceCurrent,
|
|
246
252
|
isMidTurn,
|
|
@@ -361,6 +367,7 @@ import {
|
|
|
361
367
|
setSqlitePragmaConfig,
|
|
362
368
|
setStoragePrivatePermissionEnforcement,
|
|
363
369
|
setTodoSnapshot,
|
|
370
|
+
shouldBypassFailClosedBlock,
|
|
364
371
|
shouldUseStickyChannel1Reminder,
|
|
365
372
|
sourceNameForMemory,
|
|
366
373
|
stripChannel1ReminderSpans,
|
|
@@ -396,7 +403,7 @@ import {
|
|
|
396
403
|
withMigrationLanguageDirective,
|
|
397
404
|
withRawMessageProvider,
|
|
398
405
|
withRawSessionMessageCache
|
|
399
|
-
} from "./index-
|
|
406
|
+
} from "./index-fre7qcqg.js";
|
|
400
407
|
import {
|
|
401
408
|
pushNotification
|
|
402
409
|
} from "./index-hw34xmzk.js";
|
|
@@ -620,170 +627,6 @@ function summarizeDreamSchedule(dreamer) {
|
|
|
620
627
|
return enabled.map((t) => `${t} ${dreamer?.tasks[t]?.schedule}`).join(", ");
|
|
621
628
|
}
|
|
622
629
|
|
|
623
|
-
// ../plugin/src/features/magic-context/fail-closed-block.ts
|
|
624
|
-
var FAIL_CLOSED_DOCTOR_COMMAND = "npx @cortexkit/magic-context@latest doctor";
|
|
625
|
-
var FAIL_CLOSED_REPROBE_EVERY_N = 5;
|
|
626
|
-
|
|
627
|
-
class FailClosedBlockingError extends Error {
|
|
628
|
-
code = "FAIL_CLOSED_BLOCKING";
|
|
629
|
-
reason;
|
|
630
|
-
constructor(message, reason, options) {
|
|
631
|
-
super(message, options);
|
|
632
|
-
this.name = "FailClosedBlockingError";
|
|
633
|
-
this.reason = reason;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
var OPENCODE_INTERNAL_AGENT_NAMES = new Set(["title", "summary", "compaction"]);
|
|
637
|
-
function isMagicContextHiddenAgentName(agent) {
|
|
638
|
-
if (agent === "sidekick" || agent === "smart-note-compiler" || agent.startsWith("smart-note-")) {
|
|
639
|
-
return true;
|
|
640
|
-
}
|
|
641
|
-
if (agent === "historian" || agent.startsWith("historian-"))
|
|
642
|
-
return true;
|
|
643
|
-
if (agent === "dreamer" || agent.startsWith("dreamer-"))
|
|
644
|
-
return true;
|
|
645
|
-
return false;
|
|
646
|
-
}
|
|
647
|
-
var MAX_FORMATTED_BLOCKING_PROCESSES = 8;
|
|
648
|
-
function normalizeFailClosedProcessKind(process2) {
|
|
649
|
-
switch (process2.kind) {
|
|
650
|
-
case "OpenCode server":
|
|
651
|
-
case "OpenCode instance (TUI/CLI)":
|
|
652
|
-
case "Pi":
|
|
653
|
-
case "process":
|
|
654
|
-
return process2.kind;
|
|
655
|
-
}
|
|
656
|
-
switch (process2.harness?.trim().toLowerCase()) {
|
|
657
|
-
case "opencode server":
|
|
658
|
-
return "OpenCode server";
|
|
659
|
-
case "opencode instance (tui/cli)":
|
|
660
|
-
case "opencode instance":
|
|
661
|
-
return "OpenCode instance (TUI/CLI)";
|
|
662
|
-
case "pi":
|
|
663
|
-
case "pi harness":
|
|
664
|
-
case "omp":
|
|
665
|
-
return "Pi";
|
|
666
|
-
default:
|
|
667
|
-
return "process";
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
function formatFailClosedBlockingProcesses(processes) {
|
|
671
|
-
const uniqueProcesses = new Map;
|
|
672
|
-
for (const process2 of processes) {
|
|
673
|
-
if (!Number.isInteger(process2.pid) || process2.pid <= 0)
|
|
674
|
-
continue;
|
|
675
|
-
const kind = normalizeFailClosedProcessKind(process2);
|
|
676
|
-
uniqueProcesses.set(`${kind}\x00${process2.pid}`, { kind, pid: process2.pid });
|
|
677
|
-
}
|
|
678
|
-
const entries = [...uniqueProcesses.values()];
|
|
679
|
-
const visible = entries.slice(0, MAX_FORMATTED_BLOCKING_PROCESSES);
|
|
680
|
-
const rendered = visible.map(({ kind, pid }) => `${kind} (PID ${pid})`);
|
|
681
|
-
const omitted = entries.length - visible.length;
|
|
682
|
-
if (omitted > 0)
|
|
683
|
-
rendered.push(`${omitted} more blocking process(es)`);
|
|
684
|
-
if (rendered.length === 0)
|
|
685
|
-
return "a live process";
|
|
686
|
-
if (rendered.length === 1)
|
|
687
|
-
return rendered[0];
|
|
688
|
-
const last = rendered.pop();
|
|
689
|
-
return `${rendered.join(", ")}, and ${last}`;
|
|
690
|
-
}
|
|
691
|
-
function formatFailClosedBlockingMessage(reason) {
|
|
692
|
-
if (reason.kind === "migration_guard") {
|
|
693
|
-
if (reason.unreadableFile) {
|
|
694
|
-
const arm = reason.unreadableArm ?? "io";
|
|
695
|
-
const recovery = arm === "io" ? `If none of these processes are running, it is safe to delete ${reason.unreadableFile} and retry.` : `The file may be a recent incomplete write; retry after the file is older than the ten-minute grace window, or stop the relevant process before deleting it.`;
|
|
696
|
-
return [
|
|
697
|
-
`Magic Context cannot migrate the shared database because RPC discovery file ${reason.unreadableFile} is uncertain (${arm} arm), so the absence of a live process cannot be proven.`,
|
|
698
|
-
recovery,
|
|
699
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
700
|
-
].join(" ");
|
|
701
|
-
}
|
|
702
|
-
return [
|
|
703
|
-
`Magic Context cannot migrate the shared database because ${formatFailClosedBlockingProcesses(reason.blockingProcesses)} may be running an older Magic Context build that would fail against the migrated database.`,
|
|
704
|
-
"Restart the blocking process (it will pick up the new build and migrate on start), or shut it down and retry.",
|
|
705
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
706
|
-
].join(" ");
|
|
707
|
-
}
|
|
708
|
-
if (reason.kind === "schema_fence") {
|
|
709
|
-
return [
|
|
710
|
-
`Magic Context cannot operate: this Magic Context build is older than the database; upgrade/restart this harness (upstream migration lane v${reason.persistedVersion}, build supports through v${reason.supportedVersion}).`,
|
|
711
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
712
|
-
].join(" ");
|
|
713
|
-
}
|
|
714
|
-
const cause = reason.cause.trim().length > 0 ? reason.cause.trim() : "unknown storage error";
|
|
715
|
-
return [
|
|
716
|
-
`Magic Context cannot operate: persistent storage failed (${cause}).`,
|
|
717
|
-
"The plugin will not silently degrade to native compaction while enabled.",
|
|
718
|
-
`Recovery: ${FAIL_CLOSED_DOCTOR_COMMAND}`
|
|
719
|
-
].join(" ");
|
|
720
|
-
}
|
|
721
|
-
function createFailClosedBlockingError(reason, options) {
|
|
722
|
-
return new FailClosedBlockingError(formatFailClosedBlockingMessage(reason), reason, options);
|
|
723
|
-
}
|
|
724
|
-
function isFailClosedBlockingError(error) {
|
|
725
|
-
return error instanceof FailClosedBlockingError || typeof error === "object" && error !== null && error.name === "FailClosedBlockingError" && error.code === "FAIL_CLOSED_BLOCKING";
|
|
726
|
-
}
|
|
727
|
-
function shouldBypassFailClosedBlock(input) {
|
|
728
|
-
if (input.isPiSubagentEnv === true)
|
|
729
|
-
return true;
|
|
730
|
-
if (input.isInternalChildSession === true)
|
|
731
|
-
return true;
|
|
732
|
-
const agent = typeof input.agent === "string" ? input.agent.trim() : "";
|
|
733
|
-
if (agent.length === 0)
|
|
734
|
-
return false;
|
|
735
|
-
if (OPENCODE_INTERNAL_AGENT_NAMES.has(agent))
|
|
736
|
-
return true;
|
|
737
|
-
if (isMagicContextHiddenAgentName(agent))
|
|
738
|
-
return true;
|
|
739
|
-
return false;
|
|
740
|
-
}
|
|
741
|
-
function createFailClosedController(options) {
|
|
742
|
-
const reprobeEveryN = Math.max(1, options?.reprobeEveryN ?? FAIL_CLOSED_REPROBE_EVERY_N);
|
|
743
|
-
let reason = null;
|
|
744
|
-
let blockedPassCount = 0;
|
|
745
|
-
return {
|
|
746
|
-
arm(next) {
|
|
747
|
-
reason = next;
|
|
748
|
-
blockedPassCount = 0;
|
|
749
|
-
},
|
|
750
|
-
clear() {
|
|
751
|
-
reason = null;
|
|
752
|
-
blockedPassCount = 0;
|
|
753
|
-
},
|
|
754
|
-
isArmed() {
|
|
755
|
-
return reason !== null;
|
|
756
|
-
},
|
|
757
|
-
getReason() {
|
|
758
|
-
return reason;
|
|
759
|
-
},
|
|
760
|
-
async enforce(input) {
|
|
761
|
-
if (!reason)
|
|
762
|
-
return;
|
|
763
|
-
if (!input.blockingEnabled)
|
|
764
|
-
return;
|
|
765
|
-
if (input.exempt)
|
|
766
|
-
return;
|
|
767
|
-
blockedPassCount += 1;
|
|
768
|
-
const shouldReprobe = typeof input.tryReopen === "function" && (blockedPassCount === 1 || blockedPassCount % reprobeEveryN === 0);
|
|
769
|
-
if (shouldReprobe) {
|
|
770
|
-
try {
|
|
771
|
-
const healed = await input.tryReopen?.();
|
|
772
|
-
if (healed) {
|
|
773
|
-
reason = null;
|
|
774
|
-
blockedPassCount = 0;
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
} catch {}
|
|
778
|
-
}
|
|
779
|
-
const blockedReason = reason;
|
|
780
|
-
if (!blockedReason)
|
|
781
|
-
return;
|
|
782
|
-
throw createFailClosedBlockingError(blockedReason);
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
|
|
787
630
|
// ../plugin/src/features/magic-context/message-index-async.ts
|
|
788
631
|
function isDatabaseLockedError(error) {
|
|
789
632
|
if (!error || typeof error !== "object")
|
|
@@ -5828,153 +5671,6 @@ function isRustAuthorityDrainingError(error) {
|
|
|
5828
5671
|
return error instanceof Error && error.message.includes("authority_draining");
|
|
5829
5672
|
}
|
|
5830
5673
|
|
|
5831
|
-
// ../plugin/src/shared/redaction.ts
|
|
5832
|
-
import { homedir as homedir2, userInfo } from "node:os";
|
|
5833
|
-
function escapeRegex(value) {
|
|
5834
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5835
|
-
}
|
|
5836
|
-
var SECRET_WORDS = [
|
|
5837
|
-
"key",
|
|
5838
|
-
"token",
|
|
5839
|
-
"secret",
|
|
5840
|
-
"password",
|
|
5841
|
-
"auth",
|
|
5842
|
-
"authorization",
|
|
5843
|
-
"bearer",
|
|
5844
|
-
"credential"
|
|
5845
|
-
];
|
|
5846
|
-
var SECRET_SEGMENT_PATTERN = new RegExp(`^(?:${SECRET_WORDS.map((w) => `${w}s?`).join("|")})$`, "i");
|
|
5847
|
-
var TRAILING_DESCRIPTORS = new Set(["id", "ids", "value", "values", "header", "headers"]);
|
|
5848
|
-
function redactionTypeForKey(key) {
|
|
5849
|
-
const normalized = key.trim().toLowerCase().replace(/[^a-z0-9_.-]+/g, "_");
|
|
5850
|
-
const suffix = normalized.split(".").filter(Boolean).at(-1) ?? normalized;
|
|
5851
|
-
return suffix || "secret";
|
|
5852
|
-
}
|
|
5853
|
-
function isNonSecretScalarValue(value) {
|
|
5854
|
-
const v = value.trim();
|
|
5855
|
-
if (v === "true" || v === "false" || v === "null" || v === "undefined")
|
|
5856
|
-
return true;
|
|
5857
|
-
return /^[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(v);
|
|
5858
|
-
}
|
|
5859
|
-
var SECRET_QUALIFIERS = new Set([
|
|
5860
|
-
"api",
|
|
5861
|
-
"access",
|
|
5862
|
-
"private",
|
|
5863
|
-
"client",
|
|
5864
|
-
"auth",
|
|
5865
|
-
"authorization",
|
|
5866
|
-
"secret",
|
|
5867
|
-
"bearer",
|
|
5868
|
-
"session",
|
|
5869
|
-
"refresh",
|
|
5870
|
-
"service",
|
|
5871
|
-
"x",
|
|
5872
|
-
"openai",
|
|
5873
|
-
"anthropic",
|
|
5874
|
-
"google",
|
|
5875
|
-
"github",
|
|
5876
|
-
"huggingface",
|
|
5877
|
-
"aws",
|
|
5878
|
-
"azure"
|
|
5879
|
-
]);
|
|
5880
|
-
function sanitizePathString(value) {
|
|
5881
|
-
const home = homedir2();
|
|
5882
|
-
const username = userInfo().username;
|
|
5883
|
-
let sanitized = value;
|
|
5884
|
-
if (home) {
|
|
5885
|
-
sanitized = sanitized.replace(new RegExp(escapeRegex(home), "g"), "~");
|
|
5886
|
-
}
|
|
5887
|
-
sanitized = sanitized.replace(/\/Users\/[^/]+\//g, "/Users/<USER>/");
|
|
5888
|
-
sanitized = sanitized.replace(/\/home\/[^/]+\//g, "/home/<USER>/");
|
|
5889
|
-
sanitized = sanitized.replace(/C:\\Users\\[^\\]+\\/g, "C:\\Users\\<USER>\\");
|
|
5890
|
-
if (username) {
|
|
5891
|
-
sanitized = sanitized.replace(new RegExp(escapeRegex(username), "g"), "<USER>");
|
|
5892
|
-
}
|
|
5893
|
-
return sanitized;
|
|
5894
|
-
}
|
|
5895
|
-
var SECRET_TEXT_PATTERNS = [
|
|
5896
|
-
{
|
|
5897
|
-
pattern: /\bsk-ant-(?:api03-)?[A-Za-z0-9_-]{32,}/g,
|
|
5898
|
-
replacement: "<ANTHROPIC_API_KEY_REDACTED>"
|
|
5899
|
-
},
|
|
5900
|
-
{
|
|
5901
|
-
pattern: /\bsk-(?:proj-)?[A-Za-z0-9_-]{32,}/g,
|
|
5902
|
-
replacement: "<OPENAI_API_KEY_REDACTED>"
|
|
5903
|
-
},
|
|
5904
|
-
{
|
|
5905
|
-
pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g,
|
|
5906
|
-
replacement: "<GITHUB_PAT_REDACTED>"
|
|
5907
|
-
},
|
|
5908
|
-
{
|
|
5909
|
-
pattern: /\b(?:gh[opsu]|ghr)_[A-Za-z0-9]{30,}/g,
|
|
5910
|
-
replacement: "<GITHUB_TOKEN_REDACTED>"
|
|
5911
|
-
},
|
|
5912
|
-
{
|
|
5913
|
-
pattern: /\bhf_[A-Za-z0-9]{30,}/g,
|
|
5914
|
-
replacement: "<HUGGINGFACE_TOKEN_REDACTED>"
|
|
5915
|
-
},
|
|
5916
|
-
{
|
|
5917
|
-
pattern: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
5918
|
-
replacement: "<AWS_ACCESS_KEY_ID_REDACTED>"
|
|
5919
|
-
},
|
|
5920
|
-
{
|
|
5921
|
-
pattern: /\bxox[abprsuvc]-[A-Za-z0-9-]{10,}/g,
|
|
5922
|
-
replacement: "<SLACK_TOKEN_REDACTED>"
|
|
5923
|
-
},
|
|
5924
|
-
{
|
|
5925
|
-
pattern: /\bAIza[A-Za-z0-9_-]{35}\b/g,
|
|
5926
|
-
replacement: "<GOOGLE_API_KEY_REDACTED>"
|
|
5927
|
-
},
|
|
5928
|
-
{
|
|
5929
|
-
pattern: /\b(Authorization\s*:\s*Bearer\s+)([A-Za-z0-9._~+/=-]{8,})/gi,
|
|
5930
|
-
replacement: (_full, prefix) => `${prefix}<REDACTED:bearer>`
|
|
5931
|
-
},
|
|
5932
|
-
{
|
|
5933
|
-
pattern: /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,
|
|
5934
|
-
replacement: "<JWT_REDACTED>"
|
|
5935
|
-
},
|
|
5936
|
-
{
|
|
5937
|
-
pattern: /(["'])([^"']*(?:key|token|secret|password|auth|bearer|credential)[^"']*)\1(\s*:\s*)(["'])([^"']*)\4/gi,
|
|
5938
|
-
replacement: (full, quote, key, separator, valueQuote, value) => isNonSecretScalarValue(value) ? full : `${quote}${key}${quote}${separator}${valueQuote}<REDACTED:${redactionTypeForKey(key)}>${valueQuote}`
|
|
5939
|
-
},
|
|
5940
|
-
{
|
|
5941
|
-
pattern: /\b([A-Za-z0-9_.-]*(?:key|token|secret|password|auth|bearer|credential)[A-Za-z0-9_.-]*)\s*=\s*([^\s'"`]+)/gi,
|
|
5942
|
-
replacement: (full, key, value) => isNonSecretScalarValue(value) ? full : `${key}=<REDACTED:${redactionTypeForKey(key)}>`
|
|
5943
|
-
}
|
|
5944
|
-
];
|
|
5945
|
-
function redactSecretText(value) {
|
|
5946
|
-
let redacted = value;
|
|
5947
|
-
for (const { pattern, replacement } of SECRET_TEXT_PATTERNS) {
|
|
5948
|
-
if (typeof replacement === "string") {
|
|
5949
|
-
redacted = redacted.replace(pattern, replacement);
|
|
5950
|
-
} else {
|
|
5951
|
-
redacted = redacted.replace(pattern, replacement);
|
|
5952
|
-
}
|
|
5953
|
-
}
|
|
5954
|
-
return redacted;
|
|
5955
|
-
}
|
|
5956
|
-
function sanitizeDiagnosticText(value) {
|
|
5957
|
-
return redactSecretText(sanitizePathString(value));
|
|
5958
|
-
}
|
|
5959
|
-
var SHAREABILITY_SENSITIVE_PATTERNS = [
|
|
5960
|
-
/\bC:\/Users\/[^/\s]+/i,
|
|
5961
|
-
/(?:^|\s)~\/[^\s]+/,
|
|
5962
|
-
/\b(?:api[_-]?key|secret|token|password|passwd|pwd|client[_-]?secret|access[_-]?key)\b\s*[:=]\s*\S+/i,
|
|
5963
|
-
/\b(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d+)?\b/i,
|
|
5964
|
-
/\b(?:10|127)\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/,
|
|
5965
|
-
/\b192\.168\.\d{1,3}\.\d{1,3}\b/,
|
|
5966
|
-
/\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b/
|
|
5967
|
-
];
|
|
5968
|
-
function hasShareabilitySensitiveText(text) {
|
|
5969
|
-
try {
|
|
5970
|
-
if (sanitizeDiagnosticText(text) !== text)
|
|
5971
|
-
return true;
|
|
5972
|
-
return SHAREABILITY_SENSITIVE_PATTERNS.some((pattern) => pattern.test(text));
|
|
5973
|
-
} catch {
|
|
5974
|
-
return true;
|
|
5975
|
-
}
|
|
5976
|
-
}
|
|
5977
|
-
|
|
5978
5674
|
// ../plugin/src/features/magic-context/dreamer/classify-prompt.ts
|
|
5979
5675
|
var SCORING_GUIDANCE = `### How to score importance (1-100)
|
|
5980
5676
|
Importance decides which memories survive when the injected memory block is over budget: high scores stay in context, low scores drop first. So the score is only useful if it **discriminates** — if most memories land in the same band, you have not classified them, you have just labelled them.
|
|
@@ -12293,6 +11989,28 @@ var embedPauseBySession = new Set;
|
|
|
12293
11989
|
var embedRunStateBySession = new Map;
|
|
12294
11990
|
var autoEmbedAttemptedBySession = new Set;
|
|
12295
11991
|
|
|
11992
|
+
// ../plugin/src/hooks/magic-context/format-embed-failure.ts
|
|
11993
|
+
function formatEmbedFailureSummary(embedded, remaining, failure) {
|
|
11994
|
+
const compartment = `compartment${embedded === 1 ? "" : "s"}`;
|
|
11995
|
+
if (!failure) {
|
|
11996
|
+
return `Embedded ${embedded} ${compartment}; ${remaining} could not be embedded (the provider returned no result). Run /ctx-embed start again to retry them.`;
|
|
11997
|
+
}
|
|
11998
|
+
const retry = " Run /ctx-embed start again to retry them.";
|
|
11999
|
+
switch (failure.class) {
|
|
12000
|
+
case "substitution_rejected":
|
|
12001
|
+
return `Embedded ${embedded} ${compartment}; ${remaining} rejected: ${failure.reason}. Fix: set embedding.model to the served spelling.`;
|
|
12002
|
+
case "http_error": {
|
|
12003
|
+
const fix = failure.reason.startsWith("HTTP 401") || failure.reason.startsWith("HTTP 403") ? " Fix: check embedding.api_key." : failure.reason.startsWith("HTTP 402") ? " Fix: check provider quota or billing." : failure.reason.startsWith("HTTP 404") ? " Fix: check embedding.endpoint and embedding.model." : failure.retryable ? retry : " Fix: check embedding.endpoint, embedding.model, and credentials.";
|
|
12004
|
+
return `Embedded ${embedded} ${compartment}; ${remaining} failed: ${failure.reason}.${fix}`;
|
|
12005
|
+
}
|
|
12006
|
+
case "invalid_envelope":
|
|
12007
|
+
return `Embedded ${embedded} ${compartment}; ${remaining} failed: ${failure.reason}. Fix: configure an OpenAI-compatible embedding endpoint that returns data[].embedding.`;
|
|
12008
|
+
case "empty_result":
|
|
12009
|
+
case "transport_error":
|
|
12010
|
+
return `Embedded ${embedded} ${compartment}; ${remaining} failed: ${failure.reason}.${failure.retryable ? retry : ""}`;
|
|
12011
|
+
}
|
|
12012
|
+
}
|
|
12013
|
+
|
|
12296
12014
|
// ../plugin/src/hooks/magic-context/format-embed-status.ts
|
|
12297
12015
|
function formatEmbedStatusText(coverage, drain) {
|
|
12298
12016
|
if (!coverage.enabled) {
|
|
@@ -12442,7 +12160,7 @@ Paused at ${cov.session.embedded}/${cov.session.total} compartments embedded.`,
|
|
|
12442
12160
|
return {
|
|
12443
12161
|
text: `## /ctx-embed
|
|
12444
12162
|
|
|
12445
|
-
|
|
12163
|
+
${formatEmbedFailureSummary(outcome.embedded, outcome.remaining, outcome.failure)}`,
|
|
12446
12164
|
level: "info"
|
|
12447
12165
|
};
|
|
12448
12166
|
default:
|
|
@@ -28631,7 +28349,7 @@ ${c.content}
|
|
|
28631
28349
|
// package.json
|
|
28632
28350
|
var package_default = {
|
|
28633
28351
|
name: "@cortexkit/pi-magic-context",
|
|
28634
|
-
version: "0.
|
|
28352
|
+
version: "0.40.1",
|
|
28635
28353
|
type: "module",
|
|
28636
28354
|
description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
28637
28355
|
main: "dist/index.js",
|
|
@@ -28817,6 +28535,7 @@ function renderInner(s, theme, innerWidth) {
|
|
|
28817
28535
|
lines.push("* Conversation includes model Reasoning; hygiene excludes it.");
|
|
28818
28536
|
lines.push("");
|
|
28819
28537
|
lines.push(`Counts: ${s.compartmentCount} compartments · ${s.memoryCount} memories (${s.memoryBlockCount} injected) · ${s.sessionNoteCount + s.readySmartNoteCount} notes`);
|
|
28538
|
+
lines.push(`Active profile: ${s.activeProfile ?? "none"}`);
|
|
28820
28539
|
lines.push(`Historian: ${s.historianRunning ? theme.fg("warning", "running") : theme.fg("accent", "idle")}${s.historianFailureCount > 0 ? ` · ${theme.fg("error", `last failure ${s.historianLastFailureAt ? relTime(s.historianLastFailureAt) : "unknown"}`)}` : ""}`);
|
|
28821
28540
|
if (s.recompInFlight) {
|
|
28822
28541
|
lines.push(`Upgrade: ${theme.fg("warning", "recomp/upgrade running…")}`);
|
|
@@ -28947,6 +28666,7 @@ ${safeStringify(tool.parameters)}`);
|
|
|
28947
28666
|
const compressionBudget = contextLimit > 0 ? Math.floor(contextLimit * (Math.min(threshold.percentage, 80) / 100) * historyBudgetPercentage) : null;
|
|
28948
28667
|
return {
|
|
28949
28668
|
sessionId,
|
|
28669
|
+
activeProfile: deps.activeProfile ?? null,
|
|
28950
28670
|
usagePercentage,
|
|
28951
28671
|
inputTokens,
|
|
28952
28672
|
systemPromptTokens,
|
|
@@ -29179,7 +28899,14 @@ No active Pi session is available.`,
|
|
|
29179
28899
|
backlog: getDreamTaskBacklogs(currentDeps.db, currentDeps.projectIdentity, CANONICAL_DREAM_TASKS)
|
|
29180
28900
|
}, windowGeometry, resolveTailHygieneStatus(getPiChannel1Baseline(sessionId)));
|
|
29181
28901
|
const details = buildStatusDetails(currentDeps, sessionId);
|
|
29182
|
-
|
|
28902
|
+
const profileStatus = currentDeps.activeProfile ?? "none";
|
|
28903
|
+
sendCtxStatusMessage(pi, {
|
|
28904
|
+
title: "/ctx-status",
|
|
28905
|
+
text: `${statusText}
|
|
28906
|
+
|
|
28907
|
+
Active profile: ${profileStatus}`,
|
|
28908
|
+
level: "info"
|
|
28909
|
+
}, details);
|
|
29183
28910
|
} catch (error) {
|
|
29184
28911
|
sendCtxStatusMessage(pi, {
|
|
29185
28912
|
title: "/ctx-status",
|
|
@@ -29203,6 +28930,7 @@ function buildStatusDetails(deps, sessionId) {
|
|
|
29203
28930
|
return {
|
|
29204
28931
|
sessionId,
|
|
29205
28932
|
projectIdentity: deps.projectIdentity,
|
|
28933
|
+
activeProfile: deps.activeProfile ?? null,
|
|
29206
28934
|
activeTags: activeTags.length,
|
|
29207
28935
|
droppedTags: droppedTags.length,
|
|
29208
28936
|
totalBytes,
|
|
@@ -30321,6 +30049,7 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
|
|
|
30321
30049
|
runnable: bootProjectDeps.dreamerEnabled,
|
|
30322
30050
|
scheduleSummary: summarizeDreamSchedule(bootProjectDeps.config.dreamer)
|
|
30323
30051
|
},
|
|
30052
|
+
activeProfile: bootProjectDeps.config.profile,
|
|
30324
30053
|
resolveStatusDeps: (ctx) => {
|
|
30325
30054
|
const current = resolveCurrentProjectDeps(ctx);
|
|
30326
30055
|
return {
|
|
@@ -30335,7 +30064,8 @@ async function startPiMagicContextRuntime(pi, database, dbPath) {
|
|
|
30335
30064
|
dreamer: {
|
|
30336
30065
|
runnable: current.dreamerEnabled,
|
|
30337
30066
|
scheduleSummary: summarizeDreamSchedule(current.config.dreamer)
|
|
30338
|
-
}
|
|
30067
|
+
},
|
|
30068
|
+
activeProfile: current.config.profile
|
|
30339
30069
|
};
|
|
30340
30070
|
}
|
|
30341
30071
|
});
|
package/dist/subagent-entry.js
CHANGED
package/package.json
CHANGED