@bike4mind/cli 0.2.64-worktree-refactor-extract-search-query-builders.21815 → 0.2.64

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 (85) hide show
  1. package/bin/bike4mind-cli.mjs +6 -6
  2. package/dist/BubblewrapRuntime-BHbtqvLx.mjs +72 -0
  3. package/dist/ConfigStore-CllM6jOf.mjs +8614 -0
  4. package/dist/ImageStore-DaKT_Ew8.mjs +202 -0
  5. package/dist/ProxyManager-Dl2nFk-A.mjs +259 -0
  6. package/dist/ProxyManager-kiOD1X8-.mjs +3 -0
  7. package/dist/SandboxOrchestrator-BEW3rqYi.mjs +159 -0
  8. package/dist/SandboxOrchestrator-CHZgSR3P.mjs +3 -0
  9. package/dist/SandboxRuntimeAdapter-C1B4t20N.mjs +57 -0
  10. package/dist/SandboxRuntimeAdapter-D7UAG13n.mjs +3 -0
  11. package/dist/SeatbeltRuntime-D4m0VOcD.mjs +116 -0
  12. package/dist/StderrViolationParser-D0afQ3-1.mjs +70 -0
  13. package/dist/ViolationLogStore-CZl35HcA.mjs +96 -0
  14. package/dist/bashExecute-BTkdqlSs-5foM20Lb.mjs +466 -0
  15. package/dist/commands/doctorCommand.mjs +101 -0
  16. package/dist/commands/headlessCommand.mjs +319 -0
  17. package/dist/commands/mcpCommand.mjs +218 -0
  18. package/dist/commands/updateCommand.mjs +40 -0
  19. package/dist/createFile-yQfh8uvk-I-yM5DxC.mjs +63 -0
  20. package/dist/deleteFile-DKHfnyny-G3b1Kj2T.mjs +66 -0
  21. package/dist/globFiles-D1en6joM-8jekiXdX.mjs +100 -0
  22. package/dist/grepSearch-aMamoBn_-DCJcY8JS.mjs +173 -0
  23. package/dist/index.mjs +6722 -0
  24. package/dist/pathValidation-Cgjh5WQO-DiCZTcq6.mjs +63 -0
  25. package/dist/store-Dw1nZX2Y.mjs +128 -0
  26. package/dist/store-nZExNOWX.mjs +3 -0
  27. package/dist/terminalSetup-rmr1P8KF.mjs +254 -0
  28. package/dist/tools-C6M5aW8W.mjs +20907 -0
  29. package/dist/treeSitterEngine-DCSXcm_3.mjs +309 -0
  30. package/dist/types-DBEjF9YS.mjs +59 -0
  31. package/dist/types-DK3P88Px.mjs +3 -0
  32. package/dist/updateChecker-Cu9dkHxV.mjs +120 -0
  33. package/package.json +10 -10
  34. package/dist/BubblewrapRuntime-PMIOLWKR.js +0 -71
  35. package/dist/HydrationEngine-YL2HWJ3V.js +0 -9
  36. package/dist/ImageStore-MMUOUPI2.js +0 -224
  37. package/dist/ProxyManager-HEB4TLVX.js +0 -7
  38. package/dist/SandboxOrchestrator-UIJ5GYBB.js +0 -8
  39. package/dist/SandboxRuntimeAdapter-FQ56MAB2.js +0 -13
  40. package/dist/SeatbeltRuntime-EE3TTLEP.js +0 -98
  41. package/dist/StderrViolationParser-7OYPM2DJ.js +0 -59
  42. package/dist/ViolationLogStore-RIIUVURH.js +0 -104
  43. package/dist/artifactExtractor-R7DIP2XO.js +0 -180
  44. package/dist/bashExecute-GLGLD3JD.js +0 -379
  45. package/dist/chunk-4BIBE3J7.js +0 -48
  46. package/dist/chunk-5LZS5CVJ.js +0 -161
  47. package/dist/chunk-BDQBOLYG.js +0 -120
  48. package/dist/chunk-BPFEGDC7.js +0 -192
  49. package/dist/chunk-EPIYC3LA.js +0 -13770
  50. package/dist/chunk-G4ZGEQFT.js +0 -250
  51. package/dist/chunk-GQGOWACU.js +0 -770
  52. package/dist/chunk-J6ZBI6TI.js +0 -1079
  53. package/dist/chunk-JW3JRHH7.js +0 -12433
  54. package/dist/chunk-KQAMBXAW.js +0 -163
  55. package/dist/chunk-KUVV2NAB.js +0 -19125
  56. package/dist/chunk-LTLJRF6I.js +0 -44
  57. package/dist/chunk-PFBYGCOW.js +0 -449
  58. package/dist/chunk-QWB6ZYY4.js +0 -48
  59. package/dist/chunk-SGPRXN4C.js +0 -245
  60. package/dist/chunk-UZUHPHZC.js +0 -95
  61. package/dist/chunk-WBE7SQUB.js +0 -241
  62. package/dist/chunk-Y4WOJJM3.js +0 -147
  63. package/dist/commands/doctorCommand.js +0 -87
  64. package/dist/commands/headlessCommand.js +0 -380
  65. package/dist/commands/mcpCommand.js +0 -203
  66. package/dist/commands/updateCommand.js +0 -42
  67. package/dist/create-C4VEEEYR.js +0 -12
  68. package/dist/createFile-6PSPLW6R.js +0 -71
  69. package/dist/deleteFile-AUSRLWIK.js +0 -73
  70. package/dist/formatConverter-5QEJDW24.js +0 -7
  71. package/dist/globFiles-TSRN64N2.js +0 -120
  72. package/dist/grepSearch-634XWZOJ.js +0 -216
  73. package/dist/index.js +0 -6779
  74. package/dist/llmMarkdownGenerator-Z6NB26TT.js +0 -371
  75. package/dist/markdownGenerator-SK2ZQQL4.js +0 -269
  76. package/dist/mementoService-N4IM6QAC.js +0 -12
  77. package/dist/notificationDeduplicator-HUC53NEW.js +0 -9
  78. package/dist/src-F4KZCAA2.js +0 -319
  79. package/dist/src-ISX322I7.js +0 -1101
  80. package/dist/store-CAB6BV3P.js +0 -11
  81. package/dist/subtractCredits-D4KEM6VU.js +0 -12
  82. package/dist/terminalSetup-C5FHMLC3.js +0 -214
  83. package/dist/treeSitterEngine-4SGFQDY3.js +0 -330
  84. package/dist/types-KB5NP6T4.js +0 -7
  85. package/dist/utils-JCHWDM4Z.js +0 -31
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ../../b4m-core/packages/services/dist/src/llm/tools/utils/pathValidation.js
4
- import path from "path";
5
- import { realpathSync } from "fs";
6
- function resolveRealPath(filePath) {
7
- try {
8
- return realpathSync(filePath);
9
- } catch {
10
- const parentDir = path.dirname(filePath);
11
- const basename = path.basename(filePath);
12
- if (parentDir === filePath) {
13
- return filePath;
14
- }
15
- return path.join(resolveRealPath(parentDir), basename);
16
- }
17
- }
18
- function isPathAllowed(filePath, allowedDirectories) {
19
- const cwd = resolveRealPath(process.cwd());
20
- const allAllowed = [cwd, ...(allowedDirectories || []).map((d) => resolveRealPath(d))];
21
- const normalizedPath = path.normalize(filePath);
22
- const logicalPath = path.isAbsolute(normalizedPath) ? normalizedPath : path.resolve(cwd, normalizedPath);
23
- const resolvedPath = resolveRealPath(logicalPath);
24
- for (const dir of allAllowed) {
25
- if (resolvedPath === dir || resolvedPath.startsWith(dir + path.sep)) {
26
- return { allowed: true, resolvedPath, matchedDirectory: dir };
27
- }
28
- }
29
- return { allowed: false, resolvedPath };
30
- }
31
- function assertPathAllowed(filePath, allowedDirectories, operation = "access") {
32
- const result = isPathAllowed(filePath, allowedDirectories);
33
- if (!result.allowed) {
34
- const cwd = process.cwd();
35
- const dirsMsg = allowedDirectories && allowedDirectories.length > 0 ? `Allowed directories: ${[cwd, ...allowedDirectories].join(", ")}` : `Working directory: ${cwd}`;
36
- throw new Error(`Access denied: Cannot ${operation} files outside allowed directories. ${dirsMsg}`);
37
- }
38
- return result.resolvedPath;
39
- }
40
-
41
- export {
42
- isPathAllowed,
43
- assertPathAllowed
44
- };
@@ -1,449 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ../../b4m-core/packages/utils/dist/src/logger.js
4
- var Logger = class _Logger {
5
- static globalInstance = new _Logger();
6
- metadata = {};
7
- logInJson;
8
- prettyPrint;
9
- minLevel;
10
- // Log level hierarchy (higher number = more severe)
11
- static LOG_LEVELS = {
12
- debug: 0,
13
- info: 1,
14
- warn: 2,
15
- error: 3
16
- };
17
- // ANSI color codes for pretty printing
18
- static COLORS = {
19
- debug: "\x1B[36m",
20
- // Cyan
21
- info: "\x1B[32m",
22
- // Green
23
- warn: "\x1B[33m",
24
- // Yellow
25
- error: "\x1B[31m",
26
- // Red
27
- reset: "\x1B[0m",
28
- dim: "\x1B[2m"
29
- };
30
- // Level labels for pretty printing (padded for alignment)
31
- static LEVEL_LABELS = {
32
- debug: "DEBUG",
33
- info: " INFO",
34
- warn: " WARN",
35
- error: "ERROR"
36
- };
37
- // Indentation constants for pretty printing
38
- static INDENT = " ";
39
- static NESTED_INDENT = " ";
40
- constructor(options = {}) {
41
- const isLocalDev = process.env.IS_LOCAL === "true" || process.env.NODE_ENV === "development" || process.env.SST_LIVE === "true";
42
- const { metadata = {}, logInJson = process.env.LOG_JSON === "true" || !isLocalDev, prettyPrint = isLocalDev && process.env.LOG_PRETTY !== "false", minLevel = process.env.LOG_LEVEL || "info" } = options;
43
- this.metadata = metadata;
44
- this.logInJson = logInJson;
45
- this.prettyPrint = prettyPrint;
46
- this.minLevel = minLevel;
47
- }
48
- shouldLog(level) {
49
- return _Logger.LOG_LEVELS[level] >= _Logger.LOG_LEVELS[this.minLevel];
50
- }
51
- /**
52
- * Safely stringify a value, handling circular references
53
- */
54
- safeStringify(value, indent) {
55
- try {
56
- return JSON.stringify(value, null, indent);
57
- } catch {
58
- return "[Circular]";
59
- }
60
- }
61
- /**
62
- * Parse log arguments to extract message and optional metadata
63
- */
64
- parseArgs(args, errorAware = false) {
65
- if (args.length === 0) {
66
- return { message: "" };
67
- }
68
- const lastArg = args[args.length - 1];
69
- const hasMetadata = args.length > 1 && typeof lastArg === "object" && lastArg !== null && !Array.isArray(lastArg) && !(lastArg instanceof Error);
70
- const metadata = hasMetadata ? lastArg : void 0;
71
- const messageArgs = hasMetadata ? args.slice(0, -1) : args;
72
- const message = messageArgs.map((a) => {
73
- if (errorAware && a instanceof Error) {
74
- return a.stack || a.message;
75
- }
76
- return typeof a === "string" ? a : this.safeStringify(a);
77
- }).join(" ");
78
- return { message, metadata };
79
- }
80
- /**
81
- * Output a log message using the appropriate format
82
- */
83
- output(level, consoleFn, message, metadata) {
84
- const allMetadata = { ...this.metadata, ...metadata };
85
- if (this.logInJson) {
86
- consoleFn(this.safeStringify({ ...allMetadata, severity: level, message }));
87
- } else if (this.prettyPrint) {
88
- consoleFn(this.formatPretty(level, message, metadata));
89
- } else {
90
- const metadataKeys = Object.keys(allMetadata);
91
- if (metadataKeys.length > 0) {
92
- consoleFn(message, allMetadata);
93
- } else {
94
- consoleFn(message);
95
- }
96
- }
97
- }
98
- /**
99
- * Format a log message with pino-pretty-like output for local development
100
- */
101
- formatPretty(level, message, metadata) {
102
- const { reset, dim } = _Logger.COLORS;
103
- const color = _Logger.COLORS[level];
104
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
105
- const parts = [];
106
- parts.push(`${dim}[${timestamp}]${reset} ${color}${_Logger.LEVEL_LABELS[level]}${reset} ${message}`);
107
- const allMetadata = { ...this.metadata, ...metadata };
108
- const metadataKeys = Object.keys(allMetadata);
109
- if (metadataKeys.length > 0) {
110
- for (const key of metadataKeys) {
111
- const value = allMetadata[key];
112
- if (typeof value === "object" && value !== null) {
113
- const jsonStr = this.safeStringify(value, 2);
114
- const indentedJson = jsonStr.split("\n").map((line, idx) => idx === 0 ? line : _Logger.NESTED_INDENT + line).join("\n");
115
- parts.push(`${_Logger.INDENT}${dim}${key}:${reset} ${indentedJson}`);
116
- } else {
117
- parts.push(`${_Logger.INDENT}${dim}${key}:${reset} ${value}`);
118
- }
119
- }
120
- }
121
- return parts.join("\n");
122
- }
123
- resetMetadata() {
124
- this.metadata = {};
125
- return this;
126
- }
127
- withMetadata(metadata) {
128
- return new _Logger({
129
- metadata: {
130
- ...this.metadata,
131
- ...metadata
132
- },
133
- logInJson: this.logInJson,
134
- prettyPrint: this.prettyPrint,
135
- minLevel: this.minLevel
136
- });
137
- }
138
- updateMetadata(metadata) {
139
- this.metadata = {
140
- ...this.metadata,
141
- ...metadata
142
- };
143
- return this;
144
- }
145
- log(...args) {
146
- return this.info(...args);
147
- }
148
- debug(...args) {
149
- if (!this.shouldLog("debug"))
150
- return;
151
- const { message, metadata } = this.parseArgs(args);
152
- this.output("debug", console.debug, message, metadata);
153
- }
154
- info(...args) {
155
- if (!this.shouldLog("info"))
156
- return;
157
- const { message, metadata } = this.parseArgs(args);
158
- this.output("info", console.info, message, metadata);
159
- }
160
- warn(...args) {
161
- if (!this.shouldLog("warn"))
162
- return;
163
- const { message, metadata } = this.parseArgs(args);
164
- this.output("warn", console.warn, message, metadata);
165
- }
166
- error(...args) {
167
- if (!this.shouldLog("error"))
168
- return;
169
- const { message, metadata } = this.parseArgs(args, true);
170
- this.output("error", console.error, message, metadata);
171
- }
172
- /*
173
- * Global logger instance handling:
174
- */
175
- /** @deprecated: use Logger.log instance method instead */
176
- static log(...args) {
177
- return _Logger.globalInstance.log(...args);
178
- }
179
- /** @deprecated: use Logger.debug instance method instead */
180
- static debug(...args) {
181
- return _Logger.globalInstance.debug(...args);
182
- }
183
- /** @deprecated: use Logger.info instance method instead */
184
- static info(...args) {
185
- return _Logger.globalInstance.info(...args);
186
- }
187
- /** @deprecated: use Logger.warn instance method instead */
188
- static warn(...args) {
189
- return _Logger.globalInstance.warn(...args);
190
- }
191
- /** @deprecated: use Logger.error instance method instead */
192
- static error(...args) {
193
- return _Logger.globalInstance.error(...args);
194
- }
195
- /**
196
- * Update tags for all log following log messages (until resetMetadata()):
197
- * @deprecated: Use Logger.withMetadata() instead
198
- */
199
- static updateMetadata(metadata) {
200
- return _Logger.globalInstance.updateMetadata(metadata);
201
- }
202
- /**
203
- * Temporarily add tags for log messages descended from the returned handle:
204
- * @deprecated: Use Logger.withMetadata() instead
205
- */
206
- static withMetadata(metadata) {
207
- return _Logger.globalInstance.withMetadata(metadata);
208
- }
209
- /**
210
- * Reset tags associated with the global logger instance:
211
- * @deprecated: Don't use the global logger instance; use Logger injected from caller instead
212
- */
213
- static resetMetadata() {
214
- return _Logger.globalInstance.resetMetadata();
215
- }
216
- setLevel(level) {
217
- this.minLevel = level;
218
- return this;
219
- }
220
- static colorize = (...args) => ({
221
- black: `\x1B[30m${args.join(" ")}\x1B[0m`,
222
- red: `\x1B[31m${args.join(" ")}\x1B[0m`,
223
- green: `\x1B[32m${args.join(" ")}\x1B[0m`,
224
- yellow: `\x1B[33m${args.join(" ")}\x1B[0m`,
225
- blue: `\x1B[34m${args.join(" ")}\x1B[0m`
226
- });
227
- };
228
-
229
- // ../../b4m-core/packages/utils/dist/src/slack.js
230
- import axios, { isAxiosError } from "axios";
231
- import * as util from "util";
232
- import * as zlib from "zlib";
233
- var notifyEventLogsToSlack = async ({ event, stage, slackUrl, throttlingSlackUrl, enabledStages }) => {
234
- const payload = Buffer.from(event.awslogs.data, "base64");
235
- const decompressed = await util.promisify(zlib.gunzip)(payload);
236
- const logData = JSON.parse(decompressed.toString("utf8"));
237
- const allowedStages = enabledStages ?? ["production"];
238
- if (!allowedStages.includes(stage))
239
- return;
240
- const logEvents = logData.logEvents;
241
- const { notificationDeduplicator: notificationDeduplicator2 } = await import("./notificationDeduplicator-HUC53NEW.js");
242
- for (const logEvent of logEvents) {
243
- try {
244
- let message;
245
- let severity;
246
- let metadata;
247
- try {
248
- const logEventData = JSON.parse(logEvent.message.split(" ")[3]);
249
- message = logEventData.message;
250
- severity = logEventData.severity;
251
- metadata = logEventData;
252
- } catch (error) {
253
- message = logEvent.message;
254
- severity = "error";
255
- metadata = { source: "AWS" };
256
- }
257
- const targetSlackUrl = message.includes("ThrottlingException: Rate exceeded") && throttlingSlackUrl ? throttlingSlackUrl : slackUrl;
258
- await notificationDeduplicator2.handleErrorNotification(message, severity, metadata, logData, logEvent, stage, targetSlackUrl);
259
- } catch (error) {
260
- console.error(`Error: ${error}
261
- Log Event: ${JSON.stringify(logEvent)}`);
262
- }
263
- }
264
- };
265
- async function postMessageToSlack(slackWebhookUrl, message) {
266
- try {
267
- if (!slackWebhookUrl) {
268
- Logger.error("postMessageToSlack: Error posting message to Slack: slackWebhookUrl is not set");
269
- return;
270
- }
271
- await axios.post(slackWebhookUrl, { text: message }, {
272
- headers: { "Content-Type": "application/json" }
273
- });
274
- } catch (error) {
275
- Logger.error("Error posting message to Slack:", error);
276
- }
277
- }
278
- async function postLowCreditsNotificationToSlack(userId, username, email, currentCredits, organization, slackWebhookUrl) {
279
- try {
280
- if (!slackWebhookUrl) {
281
- Logger.error("postLowCreditsNotificationToSlack: Error posting low credits notification to Slack: slackWebhookUrl not set");
282
- Logger.error("User details:", { userId, username, email, currentCredits });
283
- return;
284
- }
285
- const message = `\u26A0\uFE0F *Low Credits Alert*
286
- *User:* ${username} (${email})
287
- *User ID:* ${userId}
288
- *Current Credits:* ${currentCredits}
289
- ${organization ? `*Organization:* ${organization.name} (${organization.id})` : ""}`;
290
- Logger.info("Sending low credits notification to Slack:", { userId, username, currentCredits });
291
- await axios.post(slackWebhookUrl, { text: message }, {
292
- headers: { "Content-Type": "application/json" }
293
- });
294
- Logger.info("Successfully sent low credits notification to Slack");
295
- } catch (error) {
296
- let errorMessage = "Something went wrong";
297
- if (isAxiosError(error)) {
298
- errorMessage = error.response?.data.error;
299
- } else if (error instanceof Error) {
300
- errorMessage = error.message;
301
- }
302
- Logger.error("Failed notification details:", { userId, username, email, currentCredits, error: errorMessage });
303
- }
304
- }
305
-
306
- // ../../b4m-core/packages/utils/dist/src/notificationDeduplicator.js
307
- var NotificationDeduplicator = class {
308
- errorGroups = /* @__PURE__ */ new Map();
309
- lowCreditTiers = {};
310
- // Configuration
311
- ERROR_GROUPING_WINDOW_MS = 5 * 60 * 1e3;
312
- // 5 minutes
313
- CLEANUP_INTERVAL_MS = 60 * 60 * 1e3;
314
- // 1 hour
315
- LOW_CREDIT_RESET_INTERVAL_MS = 24 * 60 * 60 * 1e3;
316
- // 24 hours
317
- constructor() {
318
- setInterval(() => this.cleanupOldEntries(), this.CLEANUP_INTERVAL_MS);
319
- }
320
- /**
321
- * Handle low credit notifications with tiered thresholds
322
- */
323
- async handleLowCreditNotification(userId, username, email, currentCredits, organization, slackWebhookUrl) {
324
- if (!slackWebhookUrl)
325
- return;
326
- if (!this.lowCreditTiers[userId]) {
327
- this.lowCreditTiers[userId] = { tier1000: false, tier300: false, tier0: false };
328
- }
329
- const userTiers = this.lowCreditTiers[userId];
330
- let shouldNotify = false;
331
- let tierMessage = "";
332
- if (currentCredits <= 0 && !userTiers.tier0) {
333
- userTiers.tier0 = true;
334
- shouldNotify = true;
335
- tierMessage = "\u{1F6A8} *CRITICAL* - User has run out of credits!";
336
- } else if (currentCredits <= 300 && !userTiers.tier300) {
337
- userTiers.tier300 = true;
338
- shouldNotify = true;
339
- tierMessage = "\u26A0\uFE0F *WARNING* - User credits critically low (\u2264300)";
340
- } else if (currentCredits <= 1e3 && !userTiers.tier1000) {
341
- userTiers.tier1000 = true;
342
- shouldNotify = true;
343
- tierMessage = "\u26A0\uFE0F *Low Credits Alert* - User credits below 1000";
344
- }
345
- if (shouldNotify) {
346
- const message = `${tierMessage}
347
- *User:* ${username} (${email})
348
- *User ID:* ${userId}
349
- *Current Credits:* ${currentCredits}${organization ? `
350
- *Organization:* ${organization.name} (${organization.id})` : ""}`;
351
- await postMessageToSlack(slackWebhookUrl, message);
352
- Logger.info(`Sent tiered low credit notification for user ${userId} at ${currentCredits} credits`);
353
- }
354
- if (currentCredits > 1e3) {
355
- userTiers.tier1000 = false;
356
- userTiers.tier300 = false;
357
- userTiers.tier0 = false;
358
- } else if (currentCredits > 300) {
359
- userTiers.tier300 = false;
360
- userTiers.tier0 = false;
361
- } else if (currentCredits > 0) {
362
- userTiers.tier0 = false;
363
- }
364
- }
365
- /**
366
- * Handle error notifications with deduplication and grouping
367
- */
368
- async handleErrorNotification(errorMessage, severity, metadata, logData, logEvent, stage, slackUrl) {
369
- const normalizedError = this.normalizeErrorMessage(errorMessage);
370
- const groupKey = `${severity}:${normalizedError}`;
371
- const now = /* @__PURE__ */ new Date();
372
- const existingEntry = this.errorGroups.get(groupKey);
373
- if (!existingEntry) {
374
- this.errorGroups.set(groupKey, {
375
- count: 1,
376
- firstOccurrence: now,
377
- lastOccurrence: now,
378
- lastNotificationSent: now
379
- });
380
- await this.sendErrorNotification(errorMessage, severity, metadata, logData, logEvent, stage, slackUrl, 1);
381
- } else {
382
- existingEntry.count++;
383
- existingEntry.lastOccurrence = now;
384
- const timeSinceLastNotification = now.getTime() - (existingEntry.lastNotificationSent?.getTime() || 0);
385
- if (timeSinceLastNotification >= this.ERROR_GROUPING_WINDOW_MS) {
386
- await this.sendErrorNotification(errorMessage, severity, metadata, logData, logEvent, stage, slackUrl, existingEntry.count, existingEntry.firstOccurrence, existingEntry.lastOccurrence);
387
- existingEntry.lastNotificationSent = now;
388
- }
389
- }
390
- }
391
- async sendErrorNotification(message, severity, metadata, logData, logEvent, stage, slackUrl, count, firstOccurrence, lastOccurrence) {
392
- const tags = Object.entries(metadata).map(([key, value]) => `\`${key}: ${value}\``).join(" ");
393
- const group = encodeURIComponent(logData.logGroup);
394
- const stream = encodeURIComponent(logData.logStream);
395
- const url = `https://console.aws.amazon.com/cloudwatch/home?region=${process.env.AWS_REGION}#logEventViewer:group=${group};stream=${stream};start=${logEvent.timestamp};end=${logEvent.timestamp}`;
396
- let slackMessage;
397
- if (count === 1) {
398
- slackMessage = `*${severity.toUpperCase()}* - ${message}
399
- \`env: ${stage}\` ${tags} [AWS](${url})`;
400
- } else {
401
- const duration = lastOccurrence && firstOccurrence ? this.formatDuration(lastOccurrence.getTime() - firstOccurrence.getTime()) : "";
402
- slackMessage = `*${severity.toUpperCase()}* - ${message}
403
- \`count: ${count}\` \`duration: ${duration}\` \`env: ${stage}\` ${tags} [AWS](${url})`;
404
- }
405
- await postMessageToSlack(slackUrl, slackMessage);
406
- }
407
- normalizeErrorMessage(message) {
408
- return message.replace(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/g, "[TIMESTAMP]").replace(/Request failed with status code \d+/g, "Request failed with status code [CODE]").replace(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/g, "[UUID]").replace(/\b\d+\.\d+\.\d+\.\d+\b/g, "[IP]").substring(0, 200);
409
- }
410
- formatDuration(ms) {
411
- const seconds = Math.floor(ms / 1e3);
412
- const minutes = Math.floor(seconds / 60);
413
- const hours = Math.floor(minutes / 60);
414
- if (hours > 0)
415
- return `${hours}h ${minutes % 60}m`;
416
- if (minutes > 0)
417
- return `${minutes}m ${seconds % 60}s`;
418
- return `${seconds}s`;
419
- }
420
- cleanupOldEntries() {
421
- const now = /* @__PURE__ */ new Date();
422
- const cutoffTime = now.getTime() - this.CLEANUP_INTERVAL_MS;
423
- for (const [key, entry] of Array.from(this.errorGroups.entries())) {
424
- if (entry.lastOccurrence.getTime() < cutoffTime) {
425
- this.errorGroups.delete(key);
426
- }
427
- }
428
- Logger.info(`Cleaned up old notification entries: ${this.errorGroups.size} error groups remaining`);
429
- }
430
- /**
431
- * Get current deduplication status (for monitoring)
432
- */
433
- getStatus() {
434
- return {
435
- errorGroupsCount: this.errorGroups.size,
436
- lowCreditUsersTracked: Object.keys(this.lowCreditTiers).length
437
- };
438
- }
439
- };
440
- var notificationDeduplicator = new NotificationDeduplicator();
441
-
442
- export {
443
- Logger,
444
- NotificationDeduplicator,
445
- notificationDeduplicator,
446
- notifyEventLogsToSlack,
447
- postMessageToSlack,
448
- postLowCreditsNotificationToSlack
449
- };
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/sandbox/runtime/SandboxRuntimeAdapter.ts
4
- import os from "os";
5
- import { accessSync, constants } from "fs";
6
- import path from "path";
7
- function detectPlatform() {
8
- const platform = os.platform();
9
- if (platform === "darwin") return "darwin";
10
- if (platform === "linux") return "linux";
11
- return null;
12
- }
13
- function isBinaryAvailable(binary) {
14
- const pathDirs = (process.env.PATH || "").split(path.delimiter);
15
- for (const dir of pathDirs) {
16
- try {
17
- accessSync(path.join(dir, binary), constants.X_OK);
18
- return true;
19
- } catch {
20
- }
21
- }
22
- return false;
23
- }
24
- function expandPath(pathStr) {
25
- return pathStr.replace(/\$HOME/g, os.homedir()).replace(/\$USER/g, os.userInfo().username).replace(/~\//g, `${os.homedir()}/`);
26
- }
27
- async function createSandboxRuntime() {
28
- const platform = detectPlatform();
29
- if (!platform) return null;
30
- if (platform === "darwin") {
31
- const { SeatbeltRuntime } = await import("./SeatbeltRuntime-EE3TTLEP.js");
32
- const runtime = new SeatbeltRuntime();
33
- return runtime.isAvailable() ? runtime : null;
34
- }
35
- if (platform === "linux") {
36
- const { BubblewrapRuntime } = await import("./BubblewrapRuntime-PMIOLWKR.js");
37
- const runtime = new BubblewrapRuntime();
38
- return runtime.isAvailable() ? runtime : null;
39
- }
40
- return null;
41
- }
42
-
43
- export {
44
- detectPlatform,
45
- isBinaryAvailable,
46
- expandPath,
47
- createSandboxRuntime
48
- };