@cortexkit/pi-magic-context 0.49.34 → 0.49.36

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.
Files changed (73) hide show
  1. package/dist/auto-search-worker.js +163 -155
  2. package/dist/chunk-embedding-write-worker.js +71 -66
  3. package/dist/{compaction-marker-candidates-p1kqkqhq.js → compaction-marker-candidates-9fzqg6y0.js} +6 -3
  4. package/dist/compaction-marker-candidates-worker.js +24 -23
  5. package/dist/{compartment-chunk-embedding-8c85ebce.js → compartment-chunk-embedding-jpcme6tz.js} +11 -9
  6. package/dist/embedding-backfill-002vyexq.js +27 -0
  7. package/dist/embedding-worker-process.js +2 -1
  8. package/dist/embedding-worker.js +5 -4
  9. package/dist/expand-attachments-8sxeyj26.js +21 -0
  10. package/dist/historian-calibration-extension.js +2 -1
  11. package/dist/{index-hqw0rt9k.js → index-0wtm7g7f.js} +1 -1
  12. package/dist/{index-wqpjhx1p.js → index-2qqsnh1b.js} +2 -2
  13. package/dist/index-3bb24eb6.js +229 -0
  14. package/dist/{index-48twbev2.js → index-6pk49fc3.js} +37 -51
  15. package/dist/{index-399p688g.js → index-8sqebjzk.js} +4 -1
  16. package/dist/{index-np9ryr8y.js → index-a7sj2bam.js} +24 -241
  17. package/dist/index-by1bzjcd.js +24 -0
  18. package/dist/{index-6981g1xv.js → index-c1dqxr10.js} +35 -5
  19. package/dist/index-c6wbq66z.js +168 -0
  20. package/dist/{index-bvpar0bg.js → index-ck8wj35v.js} +2 -2
  21. package/dist/{index-jn44h81p.js → index-cq71g4dk.js} +1 -1
  22. package/dist/{index-pb3ea2tq.js → index-d107f484.js} +5 -5
  23. package/dist/{index-f4fz95fy.js → index-dgqjq8sg.js} +398 -4996
  24. package/dist/index-dnp1jjar.js +222 -0
  25. package/dist/index-ea37qn4x.js +777 -0
  26. package/dist/{index-g2tfayfc.js → index-f6y7mdq9.js} +98 -552
  27. package/dist/{index-0gymvr5j.js → index-f9qet7y8.js} +19 -8
  28. package/dist/index-gxqmh9hq.js +194 -0
  29. package/dist/{index-fgs78jyd.js → index-gymgz20n.js} +5 -222
  30. package/dist/index-hgd00nas.js +113 -0
  31. package/dist/{index-9xd7qveg.js → index-jbkwszd5.js} +4 -4
  32. package/dist/{index-e61zxfts.js → index-kj49vs41.js} +4 -4
  33. package/dist/{index-4zemngt7.js → index-mp0gh04g.js} +2 -2
  34. package/dist/{index-eenxm3t3.js → index-mx757f3g.js} +51 -32
  35. package/dist/{index-23t8ryqw.js → index-n0zjvs3h.js} +1 -168
  36. package/dist/index-nypgv96r.js +58 -0
  37. package/dist/index-p9jfa33t.js +4171 -0
  38. package/dist/{index-eqw9t2ty.js → index-pwp6zyx3.js} +15 -4
  39. package/dist/{index-cj3bkd16.js → index-ry84c8dr.js} +2 -2
  40. package/dist/{index-gwxaz0z5.js → index-rzfr7wdv.js} +2 -2
  41. package/dist/index-w26zvs1q.js +528 -0
  42. package/dist/index-wfqysrwq.js +204 -0
  43. package/dist/index-wrr9rp9a.js +16 -0
  44. package/dist/{index-my0dn413.js → index-wt7vmyj4.js} +1 -1
  45. package/dist/{index-0mc0vv97.js → index-wwsfevck.js} +8 -5
  46. package/dist/{index-54wmg4rj.js → index-x2n261wp.js} +16 -14
  47. package/dist/{index-6wdwv3a6.js → index-y90fxz4t.js} +10 -4
  48. package/dist/{index-c474g0gj.js → index-yacs388s.js} +1 -1
  49. package/dist/{index-xn5yh0pn.js → index-z7dktknj.js} +34 -131
  50. package/dist/index.js +1316 -488
  51. package/dist/{logger-shetp43v.js → logger-2j70hhz4.js} +2 -1
  52. package/dist/{message-fts-rowid-map-3mbvdgn9.js → message-fts-rowid-map-hmgyfxxa.js} +8 -6
  53. package/dist/{message-index-bounded-a6na71rg.js → message-index-bounded-82sergz7.js} +15 -12
  54. package/dist/{message-time-backfill-e3r8ddh1.js → message-time-backfill-x45573rs.js} +3 -2
  55. package/dist/migration-worker.js +56 -48
  56. package/dist/{project-embedding-registry-acqb6be4.js → project-embedding-registry-16pj4vyf.js} +16 -13
  57. package/dist/raw-ordinal-warmup-worker.js +114 -113
  58. package/dist/{read-session-chunk-2xcp6f40.js → read-session-chunk-jxq427v6.js} +17 -10
  59. package/dist/{read-session-raw-g9b1zdn5.js → read-session-raw-a9ntjqap.js} +6 -4
  60. package/dist/render-2wan3bfh.js +42 -0
  61. package/dist/{safe-notification-target-zcpchea6.js → safe-notification-target-jk69jxwp.js} +3 -2
  62. package/dist/search-3p18trsb.js +50 -0
  63. package/dist/search-archive-pgrv04gv.js +25 -0
  64. package/dist/{storage-tags-6409qq18.js → storage-tags-p9y3bnw7.js} +5 -4
  65. package/dist/store-reader-2m80zs5z.js +14 -0
  66. package/dist/store-v60q7dje.js +452 -0
  67. package/dist/subagent-entry.js +34 -25
  68. package/dist/tag-snapshot-worker-pi.js +218 -209
  69. package/dist/v2-archive-reader-5zpj8hrg.js +11 -0
  70. package/package.json +1 -1
  71. package/dist/embedding-backfill-rwfmyvze.js +0 -24
  72. package/dist/search-archive-jate39w5.js +0 -21
  73. package/dist/search-b6hp64hc.js +0 -45
@@ -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 };