@cortexkit/pi-magic-context 0.49.34 → 0.49.35
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 +11 -6
- package/dist/chunk-embedding-write-worker.js +16 -13
- package/dist/{compaction-marker-candidates-p1kqkqhq.js → compaction-marker-candidates-hk2frhac.js} +3 -2
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/{compartment-chunk-embedding-8c85ebce.js → compartment-chunk-embedding-5j1d1e3v.js} +8 -7
- package/dist/embedding-backfill-jt459ady.js +26 -0
- package/dist/embedding-worker-process.js +2 -1
- package/dist/embedding-worker.js +5 -4
- package/dist/expand-attachments-8sxeyj26.js +21 -0
- package/dist/historian-calibration-extension.js +2 -1
- package/dist/{index-0mc0vv97.js → index-0rvn6vhq.js} +3 -3
- package/dist/{index-hqw0rt9k.js → index-0wtm7g7f.js} +1 -1
- package/dist/{index-np9ryr8y.js → index-11knwv2h.js} +20 -240
- package/dist/{index-0gymvr5j.js → index-2p691ayw.js} +19 -8
- package/dist/{index-wqpjhx1p.js → index-2qqsnh1b.js} +2 -2
- package/dist/index-3bb24eb6.js +229 -0
- package/dist/{index-48twbev2.js → index-6pk49fc3.js} +37 -51
- package/dist/index-6y6v2wvn.js +194 -0
- package/dist/{index-e61zxfts.js → index-8m82cez2.js} +4 -4
- package/dist/{index-xn5yh0pn.js → index-a11nmw5t.js} +29 -128
- package/dist/index-by1bzjcd.js +24 -0
- package/dist/index-c6wbq66z.js +168 -0
- package/dist/{index-jn44h81p.js → index-cq71g4dk.js} +1 -1
- package/dist/{index-6wdwv3a6.js → index-d0w84hy5.js} +1 -1
- package/dist/{index-pb3ea2tq.js → index-d107f484.js} +5 -5
- package/dist/index-d21rhpbd.js +4171 -0
- package/dist/index-dnp1jjar.js +222 -0
- package/dist/index-ea37qn4x.js +777 -0
- package/dist/{index-f4fz95fy.js → index-fzm8fm4z.js} +303 -4980
- package/dist/{index-fgs78jyd.js → index-gymgz20n.js} +5 -222
- package/dist/index-hgd00nas.js +113 -0
- package/dist/{index-cj3bkd16.js → index-m68qfjte.js} +2 -2
- package/dist/{index-6981g1xv.js → index-mkh1cm5k.js} +1 -1
- package/dist/{index-4zemngt7.js → index-mp0gh04g.js} +2 -2
- package/dist/{index-23t8ryqw.js → index-n0zjvs3h.js} +1 -168
- package/dist/{index-bvpar0bg.js → index-rgvqh5x7.js} +2 -2
- package/dist/{index-gwxaz0z5.js → index-rzfr7wdv.js} +2 -2
- package/dist/{index-eenxm3t3.js → index-svqk0701.js} +40 -29
- package/dist/{index-9xd7qveg.js → index-vgfk2xa5.js} +4 -4
- package/dist/index-w26zvs1q.js +528 -0
- package/dist/index-wrr9rp9a.js +16 -0
- package/dist/{index-my0dn413.js → index-wt7vmyj4.js} +1 -1
- package/dist/{index-c474g0gj.js → index-yacs388s.js} +1 -1
- package/dist/{index-g2tfayfc.js → index-yg42q9bc.js} +95 -550
- package/dist/{index-eqw9t2ty.js → index-yhsmjvqa.js} +3 -3
- package/dist/index.js +523 -236
- package/dist/{logger-shetp43v.js → logger-2j70hhz4.js} +2 -1
- package/dist/{message-fts-rowid-map-3mbvdgn9.js → message-fts-rowid-map-aw4xa05a.js} +5 -4
- package/dist/{message-index-bounded-a6na71rg.js → message-index-bounded-da34vhs4.js} +12 -10
- package/dist/{message-time-backfill-e3r8ddh1.js → message-time-backfill-x45573rs.js} +3 -2
- package/dist/migration-worker.js +13 -10
- package/dist/{project-embedding-registry-acqb6be4.js → project-embedding-registry-davzvsz9.js} +13 -11
- package/dist/raw-ordinal-warmup-worker.js +12 -7
- package/dist/{read-session-chunk-2xcp6f40.js → read-session-chunk-nbcznexm.js} +14 -8
- package/dist/{read-session-raw-g9b1zdn5.js → read-session-raw-zb8kpa2y.js} +3 -2
- package/dist/render-d931g2vv.js +41 -0
- package/dist/{safe-notification-target-zcpchea6.js → safe-notification-target-jk69jxwp.js} +3 -2
- package/dist/search-archive-a76pp30g.js +24 -0
- package/dist/{search-b6hp64hc.js → search-atp7g95j.js} +24 -20
- package/dist/{storage-tags-6409qq18.js → storage-tags-jy8b0xsy.js} +5 -4
- package/dist/store-kabezr25.js +453 -0
- package/dist/store-reader-2m80zs5z.js +14 -0
- package/dist/subagent-entry.js +31 -23
- package/dist/tag-snapshot-worker-pi.js +15 -12
- package/dist/v2-archive-reader-wcjcfdzq.js +11 -0
- package/package.json +1 -1
- package/dist/embedding-backfill-rwfmyvze.js +0 -24
- package/dist/search-archive-jate39w5.js +0 -21
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// ../plugin/src/shared/redaction.ts
|
|
2
|
+
import { homedir, userInfo } from "node:os";
|
|
3
|
+
function escapeRegex(value) {
|
|
4
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
|
+
}
|
|
6
|
+
var SECRET_WORDS = [
|
|
7
|
+
"key",
|
|
8
|
+
"token",
|
|
9
|
+
"secret",
|
|
10
|
+
"password",
|
|
11
|
+
"auth",
|
|
12
|
+
"authorization",
|
|
13
|
+
"bearer",
|
|
14
|
+
"credential"
|
|
15
|
+
];
|
|
16
|
+
var SECRET_SEGMENT_PATTERN = new RegExp(`^(?:${SECRET_WORDS.map((w) => `${w}s?`).join("|")})$`, "i");
|
|
17
|
+
var TRAILING_DESCRIPTORS = new Set(["id", "ids", "value", "values", "header", "headers"]);
|
|
18
|
+
function redactionTypeForKey(key) {
|
|
19
|
+
const normalized = key.trim().toLowerCase().replace(/[^a-z0-9_.-]+/g, "_");
|
|
20
|
+
const suffix = normalized.split(".").filter(Boolean).at(-1) ?? normalized;
|
|
21
|
+
return suffix || "secret";
|
|
22
|
+
}
|
|
23
|
+
function isNonSecretScalarValue(value) {
|
|
24
|
+
const v = value.trim();
|
|
25
|
+
if (v === "true" || v === "false" || v === "null" || v === "undefined")
|
|
26
|
+
return true;
|
|
27
|
+
return /^[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(v);
|
|
28
|
+
}
|
|
29
|
+
var SECRET_QUALIFIERS = new Set([
|
|
30
|
+
"api",
|
|
31
|
+
"access",
|
|
32
|
+
"private",
|
|
33
|
+
"client",
|
|
34
|
+
"auth",
|
|
35
|
+
"authorization",
|
|
36
|
+
"secret",
|
|
37
|
+
"bearer",
|
|
38
|
+
"session",
|
|
39
|
+
"refresh",
|
|
40
|
+
"service",
|
|
41
|
+
"x",
|
|
42
|
+
"openai",
|
|
43
|
+
"anthropic",
|
|
44
|
+
"google",
|
|
45
|
+
"github",
|
|
46
|
+
"huggingface",
|
|
47
|
+
"aws",
|
|
48
|
+
"azure",
|
|
49
|
+
"id"
|
|
50
|
+
]);
|
|
51
|
+
var UNQUALIFIED_SECRET_SEGMENT_PATTERN = /^(?:password|secret|credential|bearer|authorization)s?$/;
|
|
52
|
+
function isSecretKey(key) {
|
|
53
|
+
const segments = key.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().split(/[._-]+/).filter(Boolean);
|
|
54
|
+
if (segments.length === 0)
|
|
55
|
+
return false;
|
|
56
|
+
if (segments.length === 1) {
|
|
57
|
+
const first = segments[0];
|
|
58
|
+
return Boolean(first && SECRET_SEGMENT_PATTERN.test(first));
|
|
59
|
+
}
|
|
60
|
+
for (let i = 0;i < segments.length; i++) {
|
|
61
|
+
const seg = segments[i];
|
|
62
|
+
if (!seg || !SECRET_SEGMENT_PATTERN.test(seg))
|
|
63
|
+
continue;
|
|
64
|
+
let trailingOk = true;
|
|
65
|
+
for (let j = i + 1;j < segments.length; j++) {
|
|
66
|
+
const tail = segments[j];
|
|
67
|
+
if (!tail)
|
|
68
|
+
continue;
|
|
69
|
+
if (TRAILING_DESCRIPTORS.has(tail))
|
|
70
|
+
continue;
|
|
71
|
+
if (SECRET_SEGMENT_PATTERN.test(tail))
|
|
72
|
+
continue;
|
|
73
|
+
trailingOk = false;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
if (!trailingOk)
|
|
77
|
+
continue;
|
|
78
|
+
if (UNQUALIFIED_SECRET_SEGMENT_PATTERN.test(seg))
|
|
79
|
+
return true;
|
|
80
|
+
for (let k = i - 1;k >= 0; k--) {
|
|
81
|
+
const lead = segments[k];
|
|
82
|
+
if (lead && SECRET_QUALIFIERS.has(lead))
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
function sanitizePathString(value) {
|
|
89
|
+
const home = process.env.HOME || process.env.USERPROFILE || homedir();
|
|
90
|
+
const username = userInfo().username;
|
|
91
|
+
let sanitized = value;
|
|
92
|
+
if (home) {
|
|
93
|
+
sanitized = sanitized.replace(new RegExp(escapeRegex(home), "g"), "~");
|
|
94
|
+
}
|
|
95
|
+
sanitized = sanitized.replace(/\/Users\/[^/]+\//g, "/Users/<USER>/");
|
|
96
|
+
sanitized = sanitized.replace(/\/home\/[^/]+\//g, "/home/<USER>/");
|
|
97
|
+
sanitized = sanitized.replace(/C:\\Users\\[^\\]+\\/g, "C:\\Users\\<USER>\\");
|
|
98
|
+
if (username) {
|
|
99
|
+
sanitized = sanitized.replace(new RegExp(escapeRegex(username), "g"), "<USER>");
|
|
100
|
+
}
|
|
101
|
+
return sanitized;
|
|
102
|
+
}
|
|
103
|
+
var SECRET_TEXT_PATTERNS = [
|
|
104
|
+
{
|
|
105
|
+
pattern: /\bsk-ant-(?:api03-)?[A-Za-z0-9_-]{32,}/g,
|
|
106
|
+
replacement: "<ANTHROPIC_API_KEY_REDACTED>"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
pattern: /\bsk-(?:proj-)?[A-Za-z0-9_-]{12,}/g,
|
|
110
|
+
replacement: "<OPENAI_API_KEY_REDACTED>"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g,
|
|
114
|
+
replacement: "<GITHUB_PAT_REDACTED>"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
pattern: /\b(?:gh[opsu]|ghr)_[A-Za-z0-9_-]{30,}/g,
|
|
118
|
+
replacement: "<GITHUB_TOKEN_REDACTED>"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
pattern: /\bhf_[A-Za-z0-9]{30,}/g,
|
|
122
|
+
replacement: "<HUGGINGFACE_TOKEN_REDACTED>"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
pattern: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
126
|
+
replacement: "<AWS_ACCESS_KEY_ID_REDACTED>"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
pattern: /\bxox[abprsuvc]-[A-Za-z0-9-]{10,}/g,
|
|
130
|
+
replacement: "<SLACK_TOKEN_REDACTED>"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
pattern: /\bAIza[A-Za-z0-9_-]{35}\b/g,
|
|
134
|
+
replacement: "<GOOGLE_API_KEY_REDACTED>"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
pattern: /\b(Authorization\s*:\s*Bearer\s+)([A-Za-z0-9._~+/=-]{8,})/gi,
|
|
138
|
+
replacement: (_full, prefix) => `${prefix}<REDACTED:bearer>`
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
pattern: /\b((?:Proxy-)?Authorization\s*:\s*(?:Basic|Digest|Token|Negotiate|NTLM)\s+)([A-Za-z0-9._~+/=-]{4,})/gi,
|
|
142
|
+
replacement: (_full, prefix) => `${prefix}<REDACTED:authorization>`
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
pattern: /\b((?:x-)?(?:api-?key|api-?token|auth-?token|access-?token)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
|
|
146
|
+
replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:api_key>`
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
pattern: /\b((?:api[_-]?key|client[_-]?secret|access[_-]?token|token|secret|password|passwd|pwd)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
|
|
150
|
+
replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:credential>`
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
pattern: /\b([a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:)([^\s/@]+)(@)/gi,
|
|
154
|
+
replacement: (_full, prefix, _password, at) => `${prefix}<REDACTED:password>${at}`
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
pattern: /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,
|
|
158
|
+
replacement: "<JWT_REDACTED>"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
pattern: /(["'])([^"']*(?:key|token|secret|password|auth|bearer|credential)[^"']*)\1(\s*:\s*)(["'])([^"']*)\4/gi,
|
|
162
|
+
replacement: (full, quote, key, separator, valueQuote, value) => isNonSecretScalarValue(value) ? full : `${quote}${key}${quote}${separator}${valueQuote}<REDACTED:${redactionTypeForKey(key)}>${valueQuote}`
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
pattern: /\b([A-Za-z0-9_.-]*(?:key|token|secret|password|auth|bearer|credential)[A-Za-z0-9_.-]*)\s*=\s*([^\s'"`]+)/gi,
|
|
166
|
+
replacement: (full, key, value) => isNonSecretScalarValue(value) ? full : `${key}=<REDACTED:${redactionTypeForKey(key)}>`
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
function redactSecretText(value) {
|
|
170
|
+
let redacted = value;
|
|
171
|
+
for (const { pattern, replacement } of SECRET_TEXT_PATTERNS) {
|
|
172
|
+
if (typeof replacement === "string") {
|
|
173
|
+
redacted = redacted.replace(pattern, replacement);
|
|
174
|
+
} else {
|
|
175
|
+
redacted = redacted.replace(pattern, replacement);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return redacted;
|
|
179
|
+
}
|
|
180
|
+
function sanitizeDiagnosticText(value) {
|
|
181
|
+
return redactSecretText(sanitizePathString(value));
|
|
182
|
+
}
|
|
183
|
+
var SHAREABILITY_SENSITIVE_PATTERNS = [
|
|
184
|
+
/\bC:\/Users\/[^/\s]+/i,
|
|
185
|
+
/(?:^|\s)~\/[^\s]+/,
|
|
186
|
+
/\b(?:api[_-]?key|secret|token|password|passwd|pwd|client[_-]?secret|access[_-]?key)\b\s*[:=]\s*\S+/i,
|
|
187
|
+
/\b(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[::1\])(?::\d+)?\b/i,
|
|
188
|
+
/\b(?:10|127)\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/,
|
|
189
|
+
/\b192\.168\.\d{1,3}\.\d{1,3}\b/,
|
|
190
|
+
/\b172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}\b/
|
|
191
|
+
];
|
|
192
|
+
function hasShareabilitySensitiveText(text) {
|
|
193
|
+
try {
|
|
194
|
+
if (sanitizeDiagnosticText(text) !== text)
|
|
195
|
+
return true;
|
|
196
|
+
return SHAREABILITY_SENSITIVE_PATTERNS.some((pattern) => pattern.test(text));
|
|
197
|
+
} catch {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function sanitizeConfigValue(value, keyPath = []) {
|
|
202
|
+
if (value === null || typeof value === "number" || typeof value === "boolean")
|
|
203
|
+
return value;
|
|
204
|
+
const key = keyPath.at(-1) ?? "";
|
|
205
|
+
if (key && isSecretKey(key)) {
|
|
206
|
+
return `<REDACTED:${redactionTypeForKey(key)}>`;
|
|
207
|
+
}
|
|
208
|
+
if (typeof value === "string")
|
|
209
|
+
return sanitizeDiagnosticText(value);
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
return value.map((entry, index) => sanitizeConfigValue(entry, [...keyPath, String(index)]));
|
|
212
|
+
}
|
|
213
|
+
if (value && typeof value === "object") {
|
|
214
|
+
return Object.fromEntries(Object.entries(value).map(([entryKey, entry]) => [
|
|
215
|
+
entryKey,
|
|
216
|
+
sanitizeConfigValue(entry, [...keyPath, entryKey])
|
|
217
|
+
]));
|
|
218
|
+
}
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export { sanitizeDiagnosticText, hasShareabilitySensitiveText, sanitizeConfigValue };
|