@dexto/core 1.16.6 → 1.17.0
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/agent/schemas.d.ts +2 -2
- package/dist/llm/executor/turn-executor.cjs +3 -0
- package/dist/llm/executor/turn-executor.d.ts +5 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +3 -0
- package/dist/llm/index.cjs +6 -0
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/private-address.cjs +88 -0
- package/dist/llm/private-address.d.ts +3 -0
- package/dist/llm/private-address.d.ts.map +1 -0
- package/dist/llm/private-address.js +65 -0
- package/dist/llm/safe-download.cjs +159 -0
- package/dist/llm/safe-download.d.ts +21 -0
- package/dist/llm/safe-download.d.ts.map +1 -0
- package/dist/llm/safe-download.js +126 -0
- package/dist/logger/logger.cjs +8 -9
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +8 -9
- package/dist/logger/v2/dexto-logger.cjs +3 -2
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/dexto-logger.js +3 -2
- package/dist/mcp/mcp-client.cjs +17 -8
- package/dist/mcp/mcp-client.d.ts +4 -2
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +17 -8
- package/dist/mcp/schemas.cjs +3 -0
- package/dist/mcp/schemas.d.ts +3 -0
- package/dist/mcp/schemas.d.ts.map +1 -1
- package/dist/mcp/schemas.js +3 -0
- package/dist/resources/handlers/filesystem-handler.cjs +7 -6
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +7 -6
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/telemetry/decorators.cjs +2 -2
- package/dist/telemetry/decorators.js +2 -2
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/metadata-address.cjs +138 -0
- package/dist/utils/metadata-address.d.ts +24 -0
- package/dist/utils/metadata-address.d.ts.map +1 -0
- package/dist/utils/metadata-address.js +113 -0
- package/dist/utils/path.cjs +0 -15
- package/dist/utils/path.d.ts +0 -6
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +0 -14
- package/dist/utils/redactor.cjs +242 -34
- package/dist/utils/redactor.d.ts +15 -0
- package/dist/utils/redactor.d.ts.map +1 -1
- package/dist/utils/redactor.js +238 -34
- package/dist/workspace/index.cjs +7 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/shell-environment.cjs +96 -0
- package/dist/workspace/shell-environment.d.ts +18 -0
- package/dist/workspace/shell-environment.d.ts.map +1 -0
- package/dist/workspace/shell-environment.js +72 -0
- package/dist/workspace/types.d.ts +9 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { promises as dns } from "node:dns";
|
|
3
|
+
import http from "node:http";
|
|
4
|
+
import https from "node:https";
|
|
5
|
+
import { DownloadError } from "ai";
|
|
6
|
+
import { isMetadataHost } from "../utils/metadata-address.js";
|
|
7
|
+
import { isPrivateAddress } from "./private-address.js";
|
|
8
|
+
const MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
9
|
+
const MAX_REDIRECTS = 10;
|
|
10
|
+
const DOWNLOAD_TIMEOUT_MS = 6e4;
|
|
11
|
+
const DOWNLOAD_HEADERS = { "user-agent": "@dexto/core", accept: "*/*" };
|
|
12
|
+
function blockedDownloadMessage(hostname) {
|
|
13
|
+
return `Download from ${hostname} is blocked`;
|
|
14
|
+
}
|
|
15
|
+
function createCheckedLookup(dnsLookup, isBlockedAddress) {
|
|
16
|
+
return (hostname, options, callback) => {
|
|
17
|
+
dnsLookup(hostname, { all: true, verbatim: true }).then(
|
|
18
|
+
(records) => {
|
|
19
|
+
const blocked = records.find(
|
|
20
|
+
(record) => isMetadataHost(record.address) || isBlockedAddress(record.address)
|
|
21
|
+
);
|
|
22
|
+
if (blocked) {
|
|
23
|
+
callback(new Error(blockedDownloadMessage(hostname)), []);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const [first] = records;
|
|
27
|
+
if (!first) {
|
|
28
|
+
callback(new Error(`Failed to resolve ${hostname}`), []);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (options.all) {
|
|
32
|
+
callback(null, records);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
callback(null, first.address, first.family);
|
|
36
|
+
},
|
|
37
|
+
(error) => callback(error, [])
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function requestOnce(url, lookup, signal) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const request = (url.protocol === "https:" ? https : http).request(
|
|
44
|
+
url,
|
|
45
|
+
{ method: "GET", lookup, signal, headers: DOWNLOAD_HEADERS },
|
|
46
|
+
resolve
|
|
47
|
+
);
|
|
48
|
+
request.on("error", reject);
|
|
49
|
+
request.end();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function readLimited(response, url) {
|
|
53
|
+
const chunks = [];
|
|
54
|
+
let total = 0;
|
|
55
|
+
for await (const chunk of response) {
|
|
56
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
57
|
+
total += buffer.length;
|
|
58
|
+
if (total > MAX_DOWNLOAD_BYTES) {
|
|
59
|
+
response.destroy();
|
|
60
|
+
throw new DownloadError({
|
|
61
|
+
url,
|
|
62
|
+
message: `Download of ${url} exceeded maximum size of ${MAX_DOWNLOAD_BYTES} bytes.`
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
chunks.push(buffer);
|
|
66
|
+
}
|
|
67
|
+
return new Uint8Array(Buffer.concat(chunks));
|
|
68
|
+
}
|
|
69
|
+
function createSafeDownload(options = {}) {
|
|
70
|
+
const isBlockedAddress = options.isBlockedAddress ?? isPrivateAddress;
|
|
71
|
+
const lookup = createCheckedLookup(
|
|
72
|
+
options.dnsLookup ?? ((hostname, lookupOptions) => dns.lookup(hostname, lookupOptions)),
|
|
73
|
+
isBlockedAddress
|
|
74
|
+
);
|
|
75
|
+
async function download(first) {
|
|
76
|
+
const signal = AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS);
|
|
77
|
+
let url = first;
|
|
78
|
+
for (let redirects = 0; redirects <= MAX_REDIRECTS; redirects++) {
|
|
79
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
80
|
+
throw new DownloadError({
|
|
81
|
+
url: url.toString(),
|
|
82
|
+
message: `URL scheme must be http or https, got ${url.protocol}`
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (isMetadataHost(url.hostname) || isBlockedAddress(url.hostname)) {
|
|
86
|
+
throw new DownloadError({
|
|
87
|
+
url: url.toString(),
|
|
88
|
+
message: blockedDownloadMessage(url.hostname)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const response = await requestOnce(url, lookup, signal).catch((cause) => {
|
|
92
|
+
throw new DownloadError({ url: url.toString(), cause });
|
|
93
|
+
});
|
|
94
|
+
const location = response.headers.location;
|
|
95
|
+
const status = response.statusCode ?? 0;
|
|
96
|
+
if (status >= 300 && status < 400 && location) {
|
|
97
|
+
response.resume();
|
|
98
|
+
url = new URL(location, url);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (status < 200 || status >= 300) {
|
|
102
|
+
response.resume();
|
|
103
|
+
throw new DownloadError({
|
|
104
|
+
url: url.toString(),
|
|
105
|
+
statusCode: status,
|
|
106
|
+
statusText: response.statusMessage ?? ""
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const data = await readLimited(response, url.toString());
|
|
110
|
+
const contentType = response.headers["content-type"]?.split(";")[0]?.trim();
|
|
111
|
+
return { data, mediaType: contentType || void 0 };
|
|
112
|
+
}
|
|
113
|
+
throw new DownloadError({
|
|
114
|
+
url: first.toString(),
|
|
115
|
+
message: `Too many redirects (max ${MAX_REDIRECTS})`
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return (requests) => Promise.all(
|
|
119
|
+
requests.map(
|
|
120
|
+
({ url, isUrlSupportedByModel }) => isUrlSupportedByModel ? null : download(url)
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
createSafeDownload
|
|
126
|
+
};
|
package/dist/logger/logger.cjs
CHANGED
|
@@ -37,6 +37,7 @@ var import_chalk = __toESM(require("chalk"), 1);
|
|
|
37
37
|
var import_boxen = __toESM(require("boxen"), 1);
|
|
38
38
|
var fs = __toESM(require("fs"), 1);
|
|
39
39
|
var path = __toESM(require("path"), 1);
|
|
40
|
+
var import_redactor = require("../utils/redactor.js");
|
|
40
41
|
const logLevels = {
|
|
41
42
|
error: 0,
|
|
42
43
|
warn: 1,
|
|
@@ -61,16 +62,13 @@ const consoleFormat = winston.format.printf(({ level, message, timestamp, color
|
|
|
61
62
|
return `${import_chalk.default.dim(timestamp)} ${colorize(level.toUpperCase())}: ${formattedMessage}`;
|
|
62
63
|
});
|
|
63
64
|
const SHOULD_REDACT = process.env.REDACT_SECRETS !== "false";
|
|
64
|
-
const SENSITIVE_KEYS = ["apiKey", "password", "secret", "token"];
|
|
65
|
-
const MASK_REGEX = new RegExp(
|
|
66
|
-
`(${SENSITIVE_KEYS.join("|")})(["']?\\s*[:=]\\s*)(["'])?.*?\\3`,
|
|
67
|
-
"gi"
|
|
68
|
-
);
|
|
69
65
|
const maskFormat = winston.format((info) => {
|
|
70
|
-
if (SHOULD_REDACT
|
|
71
|
-
|
|
66
|
+
if (!SHOULD_REDACT) return info;
|
|
67
|
+
const redacted = (0, import_redactor.redactLogRecord)(info, ["level", "timestamp"]);
|
|
68
|
+
for (const key of Object.keys(info)) {
|
|
69
|
+
if (key !== "level" && key !== "timestamp") delete info[key];
|
|
72
70
|
}
|
|
73
|
-
return info;
|
|
71
|
+
return Object.assign(info, { message: import_redactor.UNREDACTABLE_LOG_DATA }, redacted);
|
|
74
72
|
});
|
|
75
73
|
const getDefaultLogLevel = () => {
|
|
76
74
|
const envLevel = process.env.DEXTO_LOG_LEVEL;
|
|
@@ -93,9 +91,10 @@ class GlobalLogger {
|
|
|
93
91
|
silent: options.silent || false,
|
|
94
92
|
format: winston.format.combine(
|
|
95
93
|
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
96
|
-
maskFormat(),
|
|
97
94
|
winston.format.errors({ stack: true }),
|
|
95
|
+
// splat() copies the logged metadata back onto the entry, so mask after it.
|
|
98
96
|
winston.format.splat(),
|
|
97
|
+
maskFormat(),
|
|
99
98
|
winston.format.json()
|
|
100
99
|
),
|
|
101
100
|
transports: this.createTransports(options)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAyCH,KAAK,UAAU,GACT,OAAO,GACP,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,GACT,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,aAAa,GACb,WAAW,GACX,aAAa,GACb,cAAc,GACd,YAAY,GACZ,eAAe,GACf,YAAY,GACZ,aAAa,CAAC;AA0CpB,MAAM,WAAW,mBAAmB;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Q,CAAC,KAAK,EAAE,MAAM;IAatB,cAAc,IAAI,MAAM,GAAG,IAAI;IAK/B,QAAQ,IAAI,MAAM;IAKlB,kBAAkB,CAAC,IAAI,EAAE;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,gBAAgB,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC;QACtD,iBAAiB,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAC;QAC9C,SAAS,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;QAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB;IAwDD,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAkB9C;AAGD,eAAO,MAAM,MAAM,cAAqB,CAAC"}
|
package/dist/logger/logger.js
CHANGED
|
@@ -4,6 +4,7 @@ import chalk from "chalk";
|
|
|
4
4
|
import boxen from "boxen";
|
|
5
5
|
import * as fs from "fs";
|
|
6
6
|
import * as path from "path";
|
|
7
|
+
import { redactLogRecord, UNREDACTABLE_LOG_DATA } from "../utils/redactor.js";
|
|
7
8
|
const logLevels = {
|
|
8
9
|
error: 0,
|
|
9
10
|
warn: 1,
|
|
@@ -28,16 +29,13 @@ const consoleFormat = winston.format.printf(({ level, message, timestamp, color
|
|
|
28
29
|
return `${chalk.dim(timestamp)} ${colorize(level.toUpperCase())}: ${formattedMessage}`;
|
|
29
30
|
});
|
|
30
31
|
const SHOULD_REDACT = process.env.REDACT_SECRETS !== "false";
|
|
31
|
-
const SENSITIVE_KEYS = ["apiKey", "password", "secret", "token"];
|
|
32
|
-
const MASK_REGEX = new RegExp(
|
|
33
|
-
`(${SENSITIVE_KEYS.join("|")})(["']?\\s*[:=]\\s*)(["'])?.*?\\3`,
|
|
34
|
-
"gi"
|
|
35
|
-
);
|
|
36
32
|
const maskFormat = winston.format((info) => {
|
|
37
|
-
if (SHOULD_REDACT
|
|
38
|
-
|
|
33
|
+
if (!SHOULD_REDACT) return info;
|
|
34
|
+
const redacted = redactLogRecord(info, ["level", "timestamp"]);
|
|
35
|
+
for (const key of Object.keys(info)) {
|
|
36
|
+
if (key !== "level" && key !== "timestamp") delete info[key];
|
|
39
37
|
}
|
|
40
|
-
return info;
|
|
38
|
+
return Object.assign(info, { message: UNREDACTABLE_LOG_DATA }, redacted);
|
|
41
39
|
});
|
|
42
40
|
const getDefaultLogLevel = () => {
|
|
43
41
|
const envLevel = process.env.DEXTO_LOG_LEVEL;
|
|
@@ -60,9 +58,10 @@ class GlobalLogger {
|
|
|
60
58
|
silent: options.silent || false,
|
|
61
59
|
format: winston.format.combine(
|
|
62
60
|
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
63
|
-
maskFormat(),
|
|
64
61
|
winston.format.errors({ stack: true }),
|
|
62
|
+
// splat() copies the logged metadata back onto the entry, so mask after it.
|
|
65
63
|
winston.format.splat(),
|
|
64
|
+
maskFormat(),
|
|
66
65
|
winston.format.json()
|
|
67
66
|
),
|
|
68
67
|
transports: this.createTransports(options)
|
|
@@ -21,6 +21,7 @@ __export(dexto_logger_exports, {
|
|
|
21
21
|
DextoLogger: () => DextoLogger
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(dexto_logger_exports);
|
|
24
|
+
var import_redactor = require("../../utils/redactor.js");
|
|
24
25
|
class DextoLogger {
|
|
25
26
|
/** Shared level reference - allows parent and all children to share the same level */
|
|
26
27
|
levelRef;
|
|
@@ -84,12 +85,12 @@ class DextoLogger {
|
|
|
84
85
|
log(level, message, context) {
|
|
85
86
|
const entry = {
|
|
86
87
|
level,
|
|
87
|
-
message,
|
|
88
|
+
message: (0, import_redactor.redactLogMessage)(message),
|
|
88
89
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
89
90
|
component: this.component,
|
|
90
91
|
agentId: this.agentId,
|
|
91
92
|
...this.sessionId !== void 0 && { sessionId: this.sessionId },
|
|
92
|
-
context
|
|
93
|
+
...context !== void 0 && { context: (0, import_redactor.redactLogRecord)(context) }
|
|
93
94
|
};
|
|
94
95
|
for (const transport of this.transports) {
|
|
95
96
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dexto-logger.d.ts","sourceRoot":"","sources":["../../../src/logger/v2/dexto-logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"dexto-logger.d.ts","sourceRoot":"","sources":["../../../src/logger/v2/dexto-logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAY,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEjG,MAAM,WAAW,iBAAiB;IAC9B,kCAAkC;IAClC,KAAK,EAAE,QAAQ,CAAC;IAChB,2BAA2B;IAC3B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,oFAAoF;IACpF,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAA;KAAE,CAAC;CACnC;AAED;;GAEG;AACH,qBAAa,WAAY,YAAW,MAAM;IACtC,sFAAsF;IACtF,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAS;IAC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AC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;KAClC,GAAG,WAAW;IAWf;;;OAGG;IACH,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,GAAG,WAAW;IAe9D;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAWjC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
|
+
import { redactLogMessage, redactLogRecord } from "../../utils/redactor.js";
|
|
2
3
|
class DextoLogger {
|
|
3
4
|
/** Shared level reference - allows parent and all children to share the same level */
|
|
4
5
|
levelRef;
|
|
@@ -62,12 +63,12 @@ class DextoLogger {
|
|
|
62
63
|
log(level, message, context) {
|
|
63
64
|
const entry = {
|
|
64
65
|
level,
|
|
65
|
-
message,
|
|
66
|
+
message: redactLogMessage(message),
|
|
66
67
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
67
68
|
component: this.component,
|
|
68
69
|
agentId: this.agentId,
|
|
69
70
|
...this.sessionId !== void 0 && { sessionId: this.sessionId },
|
|
70
|
-
context
|
|
71
|
+
...context !== void 0 && { context: redactLogRecord(context) }
|
|
71
72
|
};
|
|
72
73
|
for (const transport of this.transports) {
|
|
73
74
|
try {
|
package/dist/mcp/mcp-client.cjs
CHANGED
|
@@ -33,6 +33,7 @@ var import_types = require("../logger/v2/types.js");
|
|
|
33
33
|
var import_types2 = require("../approval/types.js");
|
|
34
34
|
var import_errors = require("./errors.js");
|
|
35
35
|
var import_error_codes = require("./error-codes.js");
|
|
36
|
+
var import_shell_environment = require("../workspace/shell-environment.js");
|
|
36
37
|
var import_types3 = require("@modelcontextprotocol/sdk/types.js");
|
|
37
38
|
var import_api = require("@opentelemetry/api");
|
|
38
39
|
var import_operation_span = require("../telemetry/operation-span.js");
|
|
@@ -99,7 +100,13 @@ class DextoMcpClient extends import_events.EventEmitter {
|
|
|
99
100
|
if (process.platform === "win32" && command === "npx") {
|
|
100
101
|
command = "C:\\Program Files\\nodejs\\npx.cmd";
|
|
101
102
|
}
|
|
102
|
-
return this.connectViaStdio(
|
|
103
|
+
return this.connectViaStdio(
|
|
104
|
+
command,
|
|
105
|
+
stdioConfig.args,
|
|
106
|
+
stdioConfig.env,
|
|
107
|
+
serverName,
|
|
108
|
+
stdioConfig.passEnvironment
|
|
109
|
+
);
|
|
103
110
|
} else if (config.type === "sse") {
|
|
104
111
|
const sseConfig = config;
|
|
105
112
|
return this.connectViaSSE(sseConfig.url, sseConfig.headers, serverName);
|
|
@@ -120,10 +127,12 @@ class DextoMcpClient extends import_events.EventEmitter {
|
|
|
120
127
|
* Connect to an MCP server via stdio
|
|
121
128
|
* @param command Command to run
|
|
122
129
|
* @param args Arguments for the command
|
|
123
|
-
* @param env Environment variables
|
|
130
|
+
* @param env Environment variables set for the server, applied over everything else
|
|
124
131
|
* @param serverAlias Optional server alias/name to show in logs
|
|
132
|
+
* @param passEnvironment Names of host environment variables to forward to the server.
|
|
133
|
+
* The server otherwise gets only the allowlisted host variables plus `env`.
|
|
125
134
|
*/
|
|
126
|
-
async connectViaStdio(command, args = [], env, serverAlias) {
|
|
135
|
+
async connectViaStdio(command, args = [], env, serverAlias, passEnvironment = []) {
|
|
127
136
|
this.serverCommand = command;
|
|
128
137
|
this.originalArgs = [...args];
|
|
129
138
|
this.resolvedArgs = [...this.originalArgs];
|
|
@@ -131,14 +140,14 @@ class DextoMcpClient extends import_events.EventEmitter {
|
|
|
131
140
|
this.serverAlias = serverAlias || null;
|
|
132
141
|
const serverName = this.serverAlias ?? "stdio";
|
|
133
142
|
this.logger.info(`Connecting to MCP server: ${serverName}`);
|
|
134
|
-
const expandedEnv = {
|
|
135
|
-
...process.env,
|
|
136
|
-
...env || {}
|
|
137
|
-
};
|
|
138
143
|
this.transport = new import_stdio.StdioClientTransport({
|
|
139
144
|
command,
|
|
140
145
|
args: this.resolvedArgs,
|
|
141
|
-
env:
|
|
146
|
+
env: (0, import_shell_environment.buildShellEnvironment)(
|
|
147
|
+
process.env,
|
|
148
|
+
(0, import_shell_environment.pickHostVariables)(process.env, passEnvironment),
|
|
149
|
+
env
|
|
150
|
+
)
|
|
142
151
|
});
|
|
143
152
|
this.client = new import_client.Client(
|
|
144
153
|
{
|
package/dist/mcp/mcp-client.d.ts
CHANGED
|
@@ -36,10 +36,12 @@ export declare class DextoMcpClient extends EventEmitter implements McpClient {
|
|
|
36
36
|
* Connect to an MCP server via stdio
|
|
37
37
|
* @param command Command to run
|
|
38
38
|
* @param args Arguments for the command
|
|
39
|
-
* @param env Environment variables
|
|
39
|
+
* @param env Environment variables set for the server, applied over everything else
|
|
40
40
|
* @param serverAlias Optional server alias/name to show in logs
|
|
41
|
+
* @param passEnvironment Names of host environment variables to forward to the server.
|
|
42
|
+
* The server otherwise gets only the allowlisted host variables plus `env`.
|
|
41
43
|
*/
|
|
42
|
-
connectViaStdio(command: string, args?: string[], env?: Record<string, string>, serverAlias?: string): Promise<Client>;
|
|
44
|
+
connectViaStdio(command: string, args?: string[], env?: Record<string, string>, serverAlias?: string, passEnvironment?: readonly string[]): Promise<Client>;
|
|
43
45
|
connectViaSSE(url: string, headers: Record<string, string> | undefined, serverName: string): Promise<Client>;
|
|
44
46
|
/**
|
|
45
47
|
* Connect to an MCP server via Streamable HTTP transport
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAMnE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EACR,wBAAwB,EAI3B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,wBAAwB,EAAE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G,OAAO,CAAC,eAAe,CAAC;IAqBnE;;;;OAIG;IACG,aAAa,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAsBpD;;;;OAIG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkB5D;;OAEG;IACH,mBAAmB,IAAI,OAAO;IAI9B;;OAEG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B;;OAEG;IACH,aAAa,IAAI;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAC9B,YAAY,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;QACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB;IAYD;;;OAGG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAO3C,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA4CjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAKhC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAK9B;;OAEG;IACH,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;IAQ1D;;OAEG;IACH,OAAO,CAAC,uBAAuB;CA2GlC"}
|
package/dist/mcp/mcp-client.js
CHANGED
|
@@ -11,6 +11,7 @@ import { DextoLogComponent } from "../logger/v2/types.js";
|
|
|
11
11
|
import { ApprovalStatus } from "../approval/types.js";
|
|
12
12
|
import { MCPError } from "./errors.js";
|
|
13
13
|
import { MCPErrorCode } from "./error-codes.js";
|
|
14
|
+
import { buildShellEnvironment, pickHostVariables } from "../workspace/shell-environment.js";
|
|
14
15
|
import {
|
|
15
16
|
CallToolResultSchema,
|
|
16
17
|
ResourceUpdatedNotificationSchema,
|
|
@@ -82,7 +83,13 @@ class DextoMcpClient extends EventEmitter {
|
|
|
82
83
|
if (process.platform === "win32" && command === "npx") {
|
|
83
84
|
command = "C:\\Program Files\\nodejs\\npx.cmd";
|
|
84
85
|
}
|
|
85
|
-
return this.connectViaStdio(
|
|
86
|
+
return this.connectViaStdio(
|
|
87
|
+
command,
|
|
88
|
+
stdioConfig.args,
|
|
89
|
+
stdioConfig.env,
|
|
90
|
+
serverName,
|
|
91
|
+
stdioConfig.passEnvironment
|
|
92
|
+
);
|
|
86
93
|
} else if (config.type === "sse") {
|
|
87
94
|
const sseConfig = config;
|
|
88
95
|
return this.connectViaSSE(sseConfig.url, sseConfig.headers, serverName);
|
|
@@ -103,10 +110,12 @@ class DextoMcpClient extends EventEmitter {
|
|
|
103
110
|
* Connect to an MCP server via stdio
|
|
104
111
|
* @param command Command to run
|
|
105
112
|
* @param args Arguments for the command
|
|
106
|
-
* @param env Environment variables
|
|
113
|
+
* @param env Environment variables set for the server, applied over everything else
|
|
107
114
|
* @param serverAlias Optional server alias/name to show in logs
|
|
115
|
+
* @param passEnvironment Names of host environment variables to forward to the server.
|
|
116
|
+
* The server otherwise gets only the allowlisted host variables plus `env`.
|
|
108
117
|
*/
|
|
109
|
-
async connectViaStdio(command, args = [], env, serverAlias) {
|
|
118
|
+
async connectViaStdio(command, args = [], env, serverAlias, passEnvironment = []) {
|
|
110
119
|
this.serverCommand = command;
|
|
111
120
|
this.originalArgs = [...args];
|
|
112
121
|
this.resolvedArgs = [...this.originalArgs];
|
|
@@ -114,14 +123,14 @@ class DextoMcpClient extends EventEmitter {
|
|
|
114
123
|
this.serverAlias = serverAlias || null;
|
|
115
124
|
const serverName = this.serverAlias ?? "stdio";
|
|
116
125
|
this.logger.info(`Connecting to MCP server: ${serverName}`);
|
|
117
|
-
const expandedEnv = {
|
|
118
|
-
...process.env,
|
|
119
|
-
...env || {}
|
|
120
|
-
};
|
|
121
126
|
this.transport = new StdioClientTransport({
|
|
122
127
|
command,
|
|
123
128
|
args: this.resolvedArgs,
|
|
124
|
-
env:
|
|
129
|
+
env: buildShellEnvironment(
|
|
130
|
+
process.env,
|
|
131
|
+
pickHostVariables(process.env, passEnvironment),
|
|
132
|
+
env
|
|
133
|
+
)
|
|
125
134
|
});
|
|
126
135
|
this.client = new Client(
|
|
127
136
|
{
|
package/dist/mcp/schemas.cjs
CHANGED
|
@@ -61,6 +61,9 @@ const StdioServerConfigSchema = import_zod.z.object({
|
|
|
61
61
|
}),
|
|
62
62
|
args: import_zod.z.array((0, import_result.EnvExpandedString)()).default([]).describe("Array of arguments for the command (e.g., ['script.js'])"),
|
|
63
63
|
env: import_zod.z.record(import_zod.z.string(), (0, import_result.EnvExpandedString)()).default({}).describe("Optional environment variables for the server process"),
|
|
64
|
+
passEnvironment: import_zod.z.array(import_zod.z.string().regex(/^[^=\s]+$/, 'Variable names cannot contain "=" or spaces')).default([]).describe(
|
|
65
|
+
"Names of host environment variables to forward to the server, such as GITHUB_TOKEN. The server otherwise receives only a small allowlist of host variables plus its configured env."
|
|
66
|
+
),
|
|
64
67
|
timeout: import_zod.z.coerce.number().int().positive().default(3e4),
|
|
65
68
|
connectionMode: import_zod.z.enum(MCP_CONNECTION_MODES).default(DEFAULT_MCP_CONNECTION_MODE)
|
|
66
69
|
}).strict();
|
package/dist/mcp/schemas.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const StdioServerConfigSchema: z.ZodObject<{
|
|
|
23
23
|
command: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
24
24
|
args: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
25
25
|
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
26
|
+
passEnvironment: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
26
27
|
timeout: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
27
28
|
connectionMode: z.ZodDefault<z.ZodEnum<{
|
|
28
29
|
strict: "strict";
|
|
@@ -63,6 +64,7 @@ export declare const McpServerConfigSchema: z.core.$ZodBranded<z.ZodDiscriminate
|
|
|
63
64
|
command: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
64
65
|
args: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
65
66
|
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
67
|
+
passEnvironment: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
66
68
|
timeout: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
67
69
|
connectionMode: z.ZodDefault<z.ZodEnum<{
|
|
68
70
|
strict: "strict";
|
|
@@ -97,6 +99,7 @@ export declare const ServersConfigSchema: z.core.$ZodBranded<z.ZodRecord<z.ZodSt
|
|
|
97
99
|
command: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
98
100
|
args: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
99
101
|
env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
|
|
102
|
+
passEnvironment: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
100
103
|
timeout: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
101
104
|
connectionMode: z.ZodDefault<z.ZodEnum<{
|
|
102
105
|
strict: "strict";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB,mCAAoC,CA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AC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/mcp/schemas.js
CHANGED
|
@@ -31,6 +31,9 @@ const StdioServerConfigSchema = z.object({
|
|
|
31
31
|
}),
|
|
32
32
|
args: z.array(EnvExpandedString()).default([]).describe("Array of arguments for the command (e.g., ['script.js'])"),
|
|
33
33
|
env: z.record(z.string(), EnvExpandedString()).default({}).describe("Optional environment variables for the server process"),
|
|
34
|
+
passEnvironment: z.array(z.string().regex(/^[^=\s]+$/, 'Variable names cannot contain "=" or spaces')).default([]).describe(
|
|
35
|
+
"Names of host environment variables to forward to the server, such as GITHUB_TOKEN. The server otherwise receives only a small allowlist of host variables plus its configured env."
|
|
36
|
+
),
|
|
34
37
|
timeout: z.coerce.number().int().positive().default(3e4),
|
|
35
38
|
connectionMode: z.enum(MCP_CONNECTION_MODES).default(DEFAULT_MCP_CONNECTION_MODE)
|
|
36
39
|
}).strict();
|
|
@@ -35,6 +35,10 @@ var import_fs = require("fs");
|
|
|
35
35
|
var import_path = __toESM(require("path"), 1);
|
|
36
36
|
var import_types = require("../../logger/v2/types.js");
|
|
37
37
|
var import_errors = require("../errors.js");
|
|
38
|
+
function isSecretEnvFile(basename) {
|
|
39
|
+
const name = basename.toLowerCase();
|
|
40
|
+
return (name === ".env" || name.startsWith(".env.")) && name !== ".env.example";
|
|
41
|
+
}
|
|
38
42
|
class FileSystemResourceHandler {
|
|
39
43
|
config;
|
|
40
44
|
resourcesCache = /* @__PURE__ */ new Map();
|
|
@@ -102,7 +106,7 @@ class FileSystemResourceHandler {
|
|
|
102
106
|
} catch (_error) {
|
|
103
107
|
throw import_errors.ResourceError.resourceNotFound(uri);
|
|
104
108
|
}
|
|
105
|
-
if (!this.isPathAllowed(canonicalPath)) {
|
|
109
|
+
if (!this.isPathAllowed(canonicalPath) || isSecretEnvFile(import_path.default.basename(canonicalPath))) {
|
|
106
110
|
throw import_errors.ResourceError.accessDenied(uri);
|
|
107
111
|
}
|
|
108
112
|
try {
|
|
@@ -331,11 +335,7 @@ class FileSystemResourceHandler {
|
|
|
331
335
|
const allowedDotfiles = [
|
|
332
336
|
".gitignore",
|
|
333
337
|
".gitattributes",
|
|
334
|
-
".env",
|
|
335
338
|
".env.example",
|
|
336
|
-
".env.local",
|
|
337
|
-
".env.development",
|
|
338
|
-
".env.production",
|
|
339
339
|
".npmignore",
|
|
340
340
|
".dockerignore",
|
|
341
341
|
".editorconfig",
|
|
@@ -346,7 +346,8 @@ class FileSystemResourceHandler {
|
|
|
346
346
|
];
|
|
347
347
|
if (!allowedDotfiles.includes(basename)) return false;
|
|
348
348
|
}
|
|
349
|
-
if (basename
|
|
349
|
+
if (isSecretEnvFile(basename)) return false;
|
|
350
|
+
if (basename === ".env.example") return true;
|
|
350
351
|
if (basename === ".nvmrc" || basename === ".node-version") return true;
|
|
351
352
|
}
|
|
352
353
|
if (!ext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-handler.d.ts","sourceRoot":"","sources":["../../../src/resources/handlers/filesystem-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"filesystem-handler.d.ts","sourceRoot":"","sources":["../../../src/resources/handlers/filesystem-handler.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAQpF,qBAAa,yBAA0B,YAAW,uBAAuB;IACrE,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,cAAc,CAA4C;IAClE,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,MAAM,CAAS;gBAGnB,MAAM,EAAE,iCAAiC,EACzC,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM;IAO5B,OAAO,IAAI,MAAM;IAIX,UAAU,CAAC,SAAS,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9D,aAAa,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAIlD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI/B,OAAO,CAAC,aAAa;IAWrB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAexB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6D5D,OAAO,CAAC,YAAY;IA8Dd,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAIhB,kBAAkB;YA8BlB,QAAQ;IA4EtB,OAAO,CAAC,qBAAqB;IAgC7B,OAAO,CAAC,iBAAiB;IA8CzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0C7B,OAAO,CAAC,WAAW;CA4EtB"}
|
|
@@ -3,6 +3,10 @@ import { promises as fs } from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { DextoLogComponent } from "../../logger/v2/types.js";
|
|
5
5
|
import { ResourceError } from "../errors.js";
|
|
6
|
+
function isSecretEnvFile(basename) {
|
|
7
|
+
const name = basename.toLowerCase();
|
|
8
|
+
return (name === ".env" || name.startsWith(".env.")) && name !== ".env.example";
|
|
9
|
+
}
|
|
6
10
|
class FileSystemResourceHandler {
|
|
7
11
|
config;
|
|
8
12
|
resourcesCache = /* @__PURE__ */ new Map();
|
|
@@ -70,7 +74,7 @@ class FileSystemResourceHandler {
|
|
|
70
74
|
} catch (_error) {
|
|
71
75
|
throw ResourceError.resourceNotFound(uri);
|
|
72
76
|
}
|
|
73
|
-
if (!this.isPathAllowed(canonicalPath)) {
|
|
77
|
+
if (!this.isPathAllowed(canonicalPath) || isSecretEnvFile(path.basename(canonicalPath))) {
|
|
74
78
|
throw ResourceError.accessDenied(uri);
|
|
75
79
|
}
|
|
76
80
|
try {
|
|
@@ -299,11 +303,7 @@ class FileSystemResourceHandler {
|
|
|
299
303
|
const allowedDotfiles = [
|
|
300
304
|
".gitignore",
|
|
301
305
|
".gitattributes",
|
|
302
|
-
".env",
|
|
303
306
|
".env.example",
|
|
304
|
-
".env.local",
|
|
305
|
-
".env.development",
|
|
306
|
-
".env.production",
|
|
307
307
|
".npmignore",
|
|
308
308
|
".dockerignore",
|
|
309
309
|
".editorconfig",
|
|
@@ -314,7 +314,8 @@ class FileSystemResourceHandler {
|
|
|
314
314
|
];
|
|
315
315
|
if (!allowedDotfiles.includes(basename)) return false;
|
|
316
316
|
}
|
|
317
|
-
if (basename
|
|
317
|
+
if (isSecretEnvFile(basename)) return false;
|
|
318
|
+
if (basename === ".env.example") return true;
|
|
318
319
|
if (basename === ".nvmrc" || basename === ".node-version") return true;
|
|
319
320
|
}
|
|
320
321
|
if (!ext) {
|
|
@@ -11,9 +11,9 @@ export declare const ContributorConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
11
11
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
12
12
|
type: z.ZodLiteral<"dynamic">;
|
|
13
13
|
source: z.ZodEnum<{
|
|
14
|
+
env: "env";
|
|
14
15
|
resources: "resources";
|
|
15
16
|
date: "date";
|
|
16
|
-
env: "env";
|
|
17
17
|
}>;
|
|
18
18
|
}, z.core.$strict>, z.ZodObject<{
|
|
19
19
|
id: z.ZodString;
|
|
@@ -53,9 +53,9 @@ export declare const SystemPromptContributorsSchema: z.ZodObject<{
|
|
|
53
53
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
54
54
|
type: z.ZodLiteral<"dynamic">;
|
|
55
55
|
source: z.ZodEnum<{
|
|
56
|
+
env: "env";
|
|
56
57
|
resources: "resources";
|
|
57
58
|
date: "date";
|
|
58
|
-
env: "env";
|
|
59
59
|
}>;
|
|
60
60
|
}, z.core.$strict>, z.ZodObject<{
|
|
61
61
|
id: z.ZodString;
|
|
@@ -96,9 +96,9 @@ export declare const SystemPromptConfigSchema: z.core.$ZodBranded<z.ZodUnion<rea
|
|
|
96
96
|
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
97
97
|
type: z.ZodLiteral<"dynamic">;
|
|
98
98
|
source: z.ZodEnum<{
|
|
99
|
+
env: "env";
|
|
99
100
|
resources: "resources";
|
|
100
101
|
date: "date";
|
|
101
|
-
env: "env";
|
|
102
102
|
}>;
|
|
103
103
|
}, z.core.$strict>, z.ZodObject<{
|
|
104
104
|
id: z.ZodString;
|
|
@@ -27,7 +27,7 @@ var import_utils = require("./utils.js");
|
|
|
27
27
|
var import_safe_stringify = require("../utils/safe-stringify.js");
|
|
28
28
|
var import_runtime = require("../runtime/index.js");
|
|
29
29
|
function withSpan(options) {
|
|
30
|
-
const captureArguments = options.captureArguments ??
|
|
30
|
+
const captureArguments = options.captureArguments ?? false;
|
|
31
31
|
const captureErrors = options.captureErrors ?? true;
|
|
32
32
|
const captureResult = options.captureResult ?? true;
|
|
33
33
|
return function(_target, propertyKey, descriptor) {
|
|
@@ -236,7 +236,7 @@ function InstrumentClass(options) {
|
|
|
236
236
|
target.prototype,
|
|
237
237
|
method,
|
|
238
238
|
withSpan({
|
|
239
|
-
captureArguments: options?.captureArguments ??
|
|
239
|
+
captureArguments: options?.captureArguments ?? false,
|
|
240
240
|
captureErrors: options?.captureErrors ?? true,
|
|
241
241
|
captureResult: options?.captureResult ?? true,
|
|
242
242
|
spanName: options?.prefix ? `${options.prefix}.${method}` : method,
|
|
@@ -10,7 +10,7 @@ import { hasActiveTelemetry, getBaggageValues } from "./utils.js";
|
|
|
10
10
|
import { safeStringify } from "../utils/safe-stringify.js";
|
|
11
11
|
import { getHostRuntimeAttributes, getHostRuntimeBaggageEntries } from "../runtime/index.js";
|
|
12
12
|
function withSpan(options) {
|
|
13
|
-
const captureArguments = options.captureArguments ??
|
|
13
|
+
const captureArguments = options.captureArguments ?? false;
|
|
14
14
|
const captureErrors = options.captureErrors ?? true;
|
|
15
15
|
const captureResult = options.captureResult ?? true;
|
|
16
16
|
return function(_target, propertyKey, descriptor) {
|
|
@@ -219,7 +219,7 @@ function InstrumentClass(options) {
|
|
|
219
219
|
target.prototype,
|
|
220
220
|
method,
|
|
221
221
|
withSpan({
|
|
222
|
-
captureArguments: options?.captureArguments ??
|
|
222
|
+
captureArguments: options?.captureArguments ?? false,
|
|
223
223
|
captureErrors: options?.captureErrors ?? true,
|
|
224
224
|
captureResult: options?.captureResult ?? true,
|
|
225
225
|
spanName: options?.prefix ? `${options.prefix}.${method}` : method,
|