@tradejs/node 3.1.29-beta.288 → 3.1.29-beta.290

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/mcp.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  listRuntimeDeployments,
8
8
  loadResolvedRuntimeStrategies
9
9
  } from "./chunk-BO42QWAB.mjs";
10
- import "./chunk-F7CLF3PT.mjs";
10
+ import "./chunk-PB2KHBGH.mjs";
11
11
  import {
12
12
  ensureIndicatorPluginsLoaded
13
13
  } from "./chunk-UL5Z46JL.mjs";
@@ -37,6 +37,7 @@ import { getRuntimeStorageDayKey } from "@tradejs/core/time";
37
37
  import { createHash } from "crypto";
38
38
  import { readFile } from "fs/promises";
39
39
  import path from "path";
40
+ import { stripVTControlCharacters } from "util";
40
41
  import { getDataStrict, mcpStorage, redisKeys } from "@tradejs/infra/redis";
41
42
  var MCP_JOB_TTL = 7 * 86400;
42
43
  var hash = (value) => createHash("sha256").update(value).digest("hex");
@@ -202,10 +203,29 @@ var readAuthorizedMcpJob = async (principal, id) => {
202
203
  throw new Error("Insufficient scope");
203
204
  return job;
204
205
  };
205
- var redactMcpJobLog = (line) => line.replace(/\u001b\[[0-9;]*m/g, "").replace(/\b(Bearer|Basic)\s+\S+/gi, "$1 [redacted]").replace(/([a-z][a-z0-9+.-]*:\/\/)[^\s/@]*:[^\s/@]+@/gi, "$1[redacted]@").replace(/((?:authorization|cookie)\s*:\s*)[^\r\n]+/gi, "$1[redacted]").replace(
206
+ var redactMcpLogLine = (line) => line.replace(/\u001b\[[0-9;]*m/g, "").replace(/\b(Bearer|Basic)\s+\S+/gi, "$1 [redacted]").replace(/([a-z][a-z0-9+.-]*:\/\/)[^\s/@]*:[^\s/@]+@/gi, "$1[redacted]@").replace(/((?:authorization|cookie)\s*:\s*)[^\r\n]+/gi, "$1[redacted]").replace(
206
207
  /((?:[\w.-]*(?:secret|password|token|api[_-]?key|private[_-]?key|authorization|cookie|credential)[\w.-]*)["']?\s*[:=]\s*)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^\s,;&}]+)/gi,
207
208
  "$1[redacted]"
208
- ).slice(0, 1e3);
209
+ );
210
+ var MCP_LOG_LINE_LIMIT = 1e3;
211
+ var redactMcpJobLog = (line) => redactMcpLogLine(line).slice(0, MCP_LOG_LINE_LIMIT);
212
+ var formatMcpArtifactLogLine = (line) => {
213
+ const text = redactMcpLogLine(
214
+ stripVTControlCharacters(line).replace(/\r/g, "")
215
+ );
216
+ const fragments = [];
217
+ let start = 0;
218
+ while (start < text.length) {
219
+ let end = Math.min(start + MCP_LOG_LINE_LIMIT, text.length);
220
+ const lastCodeUnit = text.charCodeAt(end - 1);
221
+ if (end < text.length && lastCodeUnit >= 55296 && lastCodeUnit <= 56319) {
222
+ end -= 1;
223
+ }
224
+ fragments.push(redactMcpJobLog(text.slice(start, end)));
225
+ start = end;
226
+ }
227
+ return fragments.join("\n") + "\n";
228
+ };
209
229
  var readMcpJobLogs = async (principal, id, offset = 0, limit = 50) => {
210
230
  if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1 || limit > 100)
211
231
  throw new Error("Select a non-negative log offset and a limit of 1\u2013100");
@@ -667,6 +687,7 @@ export {
667
687
  McpCursorError,
668
688
  cancelMcpJob,
669
689
  enqueueMcpJob,
690
+ formatMcpArtifactLogLine,
670
691
  isMcpRecord,
671
692
  mcpId,
672
693
  mcpJobDirectory,