@dexto/core 1.16.5 → 1.17.0-beta.5
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/DextoAgent.cjs +2 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +2 -1
- package/dist/agent/schemas.d.ts +2 -2
- package/dist/approval/index.cjs +4 -0
- package/dist/approval/index.d.ts +1 -1
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +4 -0
- package/dist/events/index.cjs +2 -3
- package/dist/events/index.d.ts +6 -23
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -3
- package/dist/llm/auth/index.d.ts +1 -1
- package/dist/llm/auth/index.d.ts.map +1 -1
- package/dist/llm/auth/types.d.ts +14 -0
- package/dist/llm/auth/types.d.ts.map +1 -1
- package/dist/llm/error-codes.cjs +3 -0
- package/dist/llm/error-codes.d.ts +3 -0
- package/dist/llm/error-codes.d.ts.map +1 -1
- package/dist/llm/error-codes.js +3 -0
- package/dist/llm/errors.cjs +27 -0
- package/dist/llm/errors.d.ts +9 -0
- package/dist/llm/errors.d.ts.map +1 -1
- package/dist/llm/errors.js +27 -0
- package/dist/llm/executor/provider-error.cjs +14 -0
- package/dist/llm/executor/provider-error.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.js +14 -0
- package/dist/llm/executor/tool-output-spill.cjs +46 -14
- package/dist/llm/executor/tool-output-spill.d.ts.map +1 -1
- package/dist/llm/executor/tool-output-spill.js +46 -14
- package/dist/llm/executor/turn-executor.cjs +4 -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 +4 -0
- package/dist/llm/index.cjs +6 -0
- package/dist/llm/index.d.ts +3 -1
- 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/providers/codex-app-server.cjs +3 -3
- package/dist/llm/providers/codex-app-server.js +3 -3
- package/dist/llm/providers/local/errors.cjs +4 -4
- package/dist/llm/providers/local/errors.js +4 -4
- 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/llm/services/factory.cjs +204 -14
- package/dist/llm/services/factory.d.ts +1 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +204 -14
- package/dist/logger/logger.cjs +12 -9
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +12 -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/session/session-manager.cjs +2 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +2 -0
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/telemetry/decorators.cjs +2 -2
- package/dist/telemetry/decorators.js +2 -2
- package/dist/tools/activity.cjs +0 -16
- package/dist/tools/activity.d.ts +0 -2
- package/dist/tools/activity.d.ts.map +1 -1
- package/dist/tools/activity.js +0 -16
- package/dist/tools/tool-call-metadata.cjs +0 -12
- package/dist/tools/tool-call-metadata.d.ts +0 -3
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +0 -12
- package/dist/tools/tool-manager.cjs +10 -93
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +10 -93
- package/dist/tools/tool-output-read.cjs +4 -3
- package/dist/tools/tool-output-read.d.ts.map +1 -1
- package/dist/tools/tool-output-read.js +4 -3
- package/dist/utils/env.cjs +0 -5
- package/dist/utils/env.d.ts +0 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +0 -4
- 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/utils/text-boundary.cjs +32 -0
- package/dist/utils/text-boundary.d.ts +3 -0
- package/dist/utils/text-boundary.d.ts.map +1 -0
- package/dist/utils/text-boundary.js +9 -0
- 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 +3 -3
|
@@ -2,7 +2,7 @@ import type { ToolOutputStore } from '../../storage/tool-outputs/types.js';
|
|
|
2
2
|
import { ToolManager } from '../../tools/tool-manager.js';
|
|
3
3
|
import { ValidatedLLMConfig } from '../schemas.js';
|
|
4
4
|
import { VercelLLMService } from './vercel.js';
|
|
5
|
-
import type
|
|
5
|
+
import { type LanguageModel } from 'ai';
|
|
6
6
|
import { SessionEventBus } from '../../events/index.js';
|
|
7
7
|
import type { ConversationStore } from '../../storage/conversation/types.js';
|
|
8
8
|
import type { SystemPromptManager } from '../../systemPrompt/manager.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/llm/services/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,IAAI,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACR,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACvB,MAAM,YAAY,CAAC;AAwNpB;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACnC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC,aAAa,CAAC,CA0bxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAClC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,OAAO,0BAA0B,EAAE,eAAe,EACnE,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,EAChC,oBAAoB,CAAC,EAAE,oBAAoB,GAC5C,OAAO,CAAC,gBAAgB,CAAC,CA2C3B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
2
|
import { LLMError } from "../errors.js";
|
|
3
3
|
import { VercelLLMService } from "./vercel.js";
|
|
4
|
+
import { APICallError } from "ai";
|
|
4
5
|
import {
|
|
5
6
|
ANTHROPIC_BETA_HEADER,
|
|
6
7
|
ANTHROPIC_INTERLEAVED_THINKING_BETA,
|
|
@@ -70,13 +71,111 @@ function logRuntimeAuthResolution(input) {
|
|
|
70
71
|
model,
|
|
71
72
|
auth,
|
|
72
73
|
runtime: {
|
|
73
|
-
hasRuntimeFetch: Boolean(runtimeAuth?.fetch),
|
|
74
|
+
hasRuntimeFetch: Boolean(runtimeAuth?.fetch || runtimeAuth?.requestAuth),
|
|
74
75
|
hasRuntimeHeaders: Boolean(runtimeAuth?.headers),
|
|
75
76
|
hasRuntimeBaseURL: Boolean(runtimeAuth?.baseURL),
|
|
76
77
|
hasEffectiveBaseURL: Boolean(effectiveBaseURL)
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
}
|
|
81
|
+
const MAX_RETRY_ERROR_BODY_BYTES = 64 * 1024;
|
|
82
|
+
function boundedClassificationResponse(response) {
|
|
83
|
+
const clone = response.clone();
|
|
84
|
+
if (!clone.body) return { view: clone, cancel: () => {
|
|
85
|
+
} };
|
|
86
|
+
const reader = clone.body.getReader();
|
|
87
|
+
let remaining = MAX_RETRY_ERROR_BODY_BYTES;
|
|
88
|
+
const body = new globalThis.ReadableStream({
|
|
89
|
+
async pull(controller) {
|
|
90
|
+
try {
|
|
91
|
+
const chunk = await reader.read();
|
|
92
|
+
if (chunk.done) {
|
|
93
|
+
controller.close();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const part = chunk.value.subarray(0, remaining);
|
|
97
|
+
remaining -= part.byteLength;
|
|
98
|
+
if (part.byteLength) controller.enqueue(part);
|
|
99
|
+
if (remaining === 0) {
|
|
100
|
+
void reader.cancel().catch(() => {
|
|
101
|
+
});
|
|
102
|
+
controller.close();
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
controller.error(error);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
cancel() {
|
|
109
|
+
void reader.cancel().catch(() => {
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const view = new globalThis.Response(body, {
|
|
114
|
+
status: clone.status,
|
|
115
|
+
statusText: clone.statusText,
|
|
116
|
+
headers: clone.headers
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperties(view, {
|
|
119
|
+
url: { value: response.url },
|
|
120
|
+
redirected: { value: response.redirected }
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
view,
|
|
124
|
+
cancel: () => {
|
|
125
|
+
void reader.cancel().catch(() => {
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function rethrowAbort(error, signal) {
|
|
131
|
+
if (signal?.aborted || error instanceof Error && error.name === "AbortError") throw error;
|
|
132
|
+
}
|
|
133
|
+
async function readRetryErrorBody(response, signal) {
|
|
134
|
+
if (signal?.aborted) {
|
|
135
|
+
void response.body?.cancel().catch(() => {
|
|
136
|
+
});
|
|
137
|
+
throw new globalThis.DOMException("Request aborted", "AbortError");
|
|
138
|
+
}
|
|
139
|
+
if (!response.body) return "";
|
|
140
|
+
const reader = response.body.getReader();
|
|
141
|
+
const decoder = new globalThis.TextDecoder();
|
|
142
|
+
let body = "";
|
|
143
|
+
let bytes = 0;
|
|
144
|
+
let onAbort;
|
|
145
|
+
const aborted = signal ? new Promise((_, reject) => {
|
|
146
|
+
onAbort = () => {
|
|
147
|
+
reject(new globalThis.DOMException("Request aborted", "AbortError"));
|
|
148
|
+
void reader.cancel().catch(() => {
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
if (signal.aborted) onAbort();
|
|
152
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
153
|
+
}) : void 0;
|
|
154
|
+
void aborted?.catch(() => {
|
|
155
|
+
});
|
|
156
|
+
try {
|
|
157
|
+
for (; ; ) {
|
|
158
|
+
if (signal?.aborted) throw new globalThis.DOMException("Request aborted", "AbortError");
|
|
159
|
+
const read = reader.read();
|
|
160
|
+
const chunk = aborted ? await Promise.race([read, aborted]) : await read;
|
|
161
|
+
if (chunk.done) break;
|
|
162
|
+
const remaining = MAX_RETRY_ERROR_BODY_BYTES - bytes;
|
|
163
|
+
body += decoder.decode(chunk.value.subarray(0, remaining), { stream: true });
|
|
164
|
+
bytes += chunk.value.byteLength;
|
|
165
|
+
if (bytes >= MAX_RETRY_ERROR_BODY_BYTES) {
|
|
166
|
+
void reader.cancel().catch(() => {
|
|
167
|
+
});
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
body += decoder.decode();
|
|
172
|
+
} catch (error) {
|
|
173
|
+
rethrowAbort(error, signal);
|
|
174
|
+
} finally {
|
|
175
|
+
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
176
|
+
}
|
|
177
|
+
return body;
|
|
178
|
+
}
|
|
80
179
|
async function createVercelModel(llmConfig, context) {
|
|
81
180
|
const { provider, model, baseURL } = llmConfig;
|
|
82
181
|
const runtimeAuth = context?.authResolver?.resolveRuntimeAuth({
|
|
@@ -89,9 +188,68 @@ async function createVercelModel(llmConfig, context) {
|
|
|
89
188
|
const apiKey = runtimeAuth?.apiKey || llmConfig.apiKey || resolvedProviderApiKey;
|
|
90
189
|
const runtimeBaseURL = runtimeAuth?.baseURL;
|
|
91
190
|
const runtimeHeaders = runtimeAuth?.headers;
|
|
92
|
-
|
|
93
|
-
|
|
191
|
+
if (runtimeBaseURL !== void 0 && !runtimeBaseURL.trim()) {
|
|
192
|
+
throw LLMError.invalidRuntimeBaseURL(provider);
|
|
193
|
+
}
|
|
194
|
+
const requestAuth = runtimeAuth?.requestAuth;
|
|
195
|
+
if (requestAuth && runtimeAuth?.fetch) {
|
|
196
|
+
throw LLMError.runtimeAuthConflict(provider);
|
|
197
|
+
}
|
|
198
|
+
const runtimeFetch = requestAuth ? async (input, init) => {
|
|
199
|
+
const { response, provenance } = await requestAuth.fetch(input, init);
|
|
200
|
+
if (response.ok) return response;
|
|
201
|
+
const signal = init?.signal ?? (input instanceof globalThis.Request ? input.signal : void 0);
|
|
202
|
+
const classification = boundedClassificationResponse(response);
|
|
203
|
+
let retryable;
|
|
204
|
+
let onAbort;
|
|
205
|
+
try {
|
|
206
|
+
const decision = requestAuth.isRetryableResponse({
|
|
207
|
+
response: classification.view,
|
|
208
|
+
provenance,
|
|
209
|
+
...signal ? { signal } : {}
|
|
210
|
+
});
|
|
211
|
+
if (signal) {
|
|
212
|
+
const aborted = new Promise((_, reject) => {
|
|
213
|
+
onAbort = () => reject(new globalThis.DOMException("Request aborted", "AbortError"));
|
|
214
|
+
if (signal.aborted) onAbort();
|
|
215
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
216
|
+
});
|
|
217
|
+
retryable = await Promise.race([decision, aborted]);
|
|
218
|
+
} else retryable = await decision;
|
|
219
|
+
} catch (error) {
|
|
220
|
+
if (signal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
221
|
+
void response.body?.cancel().catch(() => {
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
rethrowAbort(error, signal);
|
|
225
|
+
return response;
|
|
226
|
+
} finally {
|
|
227
|
+
if (signal && onAbort) signal.removeEventListener("abort", onAbort);
|
|
228
|
+
classification.cancel();
|
|
229
|
+
}
|
|
230
|
+
if (!retryable) return response;
|
|
231
|
+
const responseHeaders = {};
|
|
232
|
+
response.headers.forEach((value, key) => {
|
|
233
|
+
responseHeaders[key] = value;
|
|
234
|
+
});
|
|
235
|
+
throw new APICallError({
|
|
236
|
+
message: "Host classified model request failure as retryable",
|
|
237
|
+
url: typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url,
|
|
238
|
+
requestBodyValues: {},
|
|
239
|
+
statusCode: response.status,
|
|
240
|
+
responseHeaders,
|
|
241
|
+
responseBody: await readRetryErrorBody(response, signal),
|
|
242
|
+
isRetryable: true
|
|
243
|
+
});
|
|
244
|
+
} : runtimeAuth?.fetch;
|
|
245
|
+
const effectiveBaseURL = runtimeBaseURL?.trim().replace(/\/$/, "") || baseURL?.trim().replace(/\/$/, "");
|
|
94
246
|
const usesCodexRuntimeAuth = runtimeBaseURL ? isCodexBaseURL(runtimeBaseURL) : false;
|
|
247
|
+
if ((provider === "bedrock" || provider === "local") && (runtimeBaseURL !== void 0 || runtimeHeaders !== void 0 || runtimeAuth?.fetch || requestAuth)) {
|
|
248
|
+
throw LLMError.runtimeAuthUnsupported(provider);
|
|
249
|
+
}
|
|
250
|
+
if (usesCodexRuntimeAuth && (runtimeHeaders !== void 0 || runtimeAuth?.fetch || requestAuth)) {
|
|
251
|
+
throw LLMError.runtimeAuthUnsupported(provider);
|
|
252
|
+
}
|
|
95
253
|
logRuntimeAuthResolution({
|
|
96
254
|
context,
|
|
97
255
|
provider,
|
|
@@ -101,7 +259,7 @@ async function createVercelModel(llmConfig, context) {
|
|
|
101
259
|
runtimeAuth,
|
|
102
260
|
effectiveBaseURL
|
|
103
261
|
});
|
|
104
|
-
if (requiresApiKey(provider) && !usesCodexRuntimeAuth && !apiKey?.trim()) {
|
|
262
|
+
if (requiresApiKey(provider) && !usesCodexRuntimeAuth && !apiKey?.trim() && !requestAuth) {
|
|
105
263
|
const envVar = getPrimaryApiKeyEnvVar(provider);
|
|
106
264
|
throw LLMError.apiKeyMissing(provider, envVar);
|
|
107
265
|
}
|
|
@@ -140,12 +298,14 @@ async function createVercelModel(llmConfig, context) {
|
|
|
140
298
|
return provider2.chatModel(model);
|
|
141
299
|
}
|
|
142
300
|
case "openrouter": {
|
|
143
|
-
const orBaseURL =
|
|
301
|
+
const orBaseURL = effectiveBaseURL || "https://openrouter.ai/api/v1";
|
|
144
302
|
const { createOpenRouter } = await import("@openrouter/ai-sdk-provider");
|
|
145
303
|
const provider2 = createOpenRouter({
|
|
146
304
|
apiKey: apiKey ?? "",
|
|
147
305
|
baseURL: orBaseURL,
|
|
148
|
-
compatibility: "strict"
|
|
306
|
+
compatibility: "strict",
|
|
307
|
+
...runtimeHeaders ? { headers: runtimeHeaders } : {},
|
|
308
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
149
309
|
});
|
|
150
310
|
const chatModel = provider2.chat(model);
|
|
151
311
|
if (!isLanguageModel(chatModel)) {
|
|
@@ -200,7 +360,9 @@ async function createVercelModel(llmConfig, context) {
|
|
|
200
360
|
}).chat(model);
|
|
201
361
|
}
|
|
202
362
|
case "dexto-nova": {
|
|
203
|
-
const dextoBaseURL = resolveDextoGatewayBaseURL(
|
|
363
|
+
const dextoBaseURL = resolveDextoGatewayBaseURL(
|
|
364
|
+
runtimeBaseURL?.trim() ? runtimeBaseURL : baseURL
|
|
365
|
+
);
|
|
204
366
|
const headers = {
|
|
205
367
|
...runtimeHeaders ?? {},
|
|
206
368
|
[DEXTO_GATEWAY_HEADERS.CLIENT_SOURCE]: context?.clientSource ?? "cli"
|
|
@@ -216,7 +378,7 @@ async function createVercelModel(llmConfig, context) {
|
|
|
216
378
|
baseURL: dextoBaseURL,
|
|
217
379
|
compatibility: "strict",
|
|
218
380
|
headers,
|
|
219
|
-
...apiKey?.trim() ? { apiKey } : {},
|
|
381
|
+
...apiKey?.trim() ? { apiKey } : requestAuth ? { apiKey: "" } : {},
|
|
220
382
|
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
221
383
|
});
|
|
222
384
|
const chatModel = provider2.chat(model);
|
|
@@ -246,18 +408,26 @@ async function createVercelModel(llmConfig, context) {
|
|
|
246
408
|
}
|
|
247
409
|
const location = process.env.GOOGLE_VERTEX_LOCATION;
|
|
248
410
|
if (model.includes("claude")) {
|
|
249
|
-
const headers =
|
|
411
|
+
const headers = mergeHeaders(
|
|
412
|
+
supportsAnthropicInterleavedThinking(model) ? { [ANTHROPIC_BETA_HEADER]: ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0,
|
|
413
|
+
runtimeHeaders
|
|
414
|
+
);
|
|
250
415
|
const { createVertexAnthropic } = await import("@ai-sdk/google-vertex/anthropic");
|
|
251
416
|
return createVertexAnthropic({
|
|
252
417
|
project: projectId,
|
|
253
418
|
location: location || "us-east5",
|
|
419
|
+
...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
|
|
420
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {},
|
|
254
421
|
...headers ? { headers } : {}
|
|
255
422
|
})(model);
|
|
256
423
|
}
|
|
257
424
|
const { createVertex } = await import("@ai-sdk/google-vertex");
|
|
258
425
|
return createVertex({
|
|
259
426
|
project: projectId,
|
|
260
|
-
location: location || "us-central1"
|
|
427
|
+
location: location || "us-central1",
|
|
428
|
+
...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
|
|
429
|
+
...runtimeHeaders ? { headers: runtimeHeaders } : {},
|
|
430
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
261
431
|
})(model);
|
|
262
432
|
}
|
|
263
433
|
case "bedrock": {
|
|
@@ -292,19 +462,39 @@ async function createVercelModel(llmConfig, context) {
|
|
|
292
462
|
}
|
|
293
463
|
case "google": {
|
|
294
464
|
const { createGoogleGenerativeAI } = await import("@ai-sdk/google");
|
|
295
|
-
return createGoogleGenerativeAI({
|
|
465
|
+
return createGoogleGenerativeAI({
|
|
466
|
+
apiKey: apiKey ?? "",
|
|
467
|
+
...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
|
|
468
|
+
...runtimeHeaders ? { headers: runtimeHeaders } : {},
|
|
469
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
470
|
+
})(model);
|
|
296
471
|
}
|
|
297
472
|
case "groq": {
|
|
298
473
|
const { createGroq } = await import("@ai-sdk/groq");
|
|
299
|
-
return createGroq({
|
|
474
|
+
return createGroq({
|
|
475
|
+
apiKey: apiKey ?? "",
|
|
476
|
+
...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
|
|
477
|
+
...runtimeHeaders ? { headers: runtimeHeaders } : {},
|
|
478
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
479
|
+
})(model);
|
|
300
480
|
}
|
|
301
481
|
case "xai": {
|
|
302
482
|
const { createXai } = await import("@ai-sdk/xai");
|
|
303
|
-
return createXai({
|
|
483
|
+
return createXai({
|
|
484
|
+
apiKey: apiKey ?? "",
|
|
485
|
+
...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
|
|
486
|
+
...runtimeHeaders ? { headers: runtimeHeaders } : {},
|
|
487
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
488
|
+
})(model);
|
|
304
489
|
}
|
|
305
490
|
case "cohere": {
|
|
306
491
|
const { createCohere } = await import("@ai-sdk/cohere");
|
|
307
|
-
return createCohere({
|
|
492
|
+
return createCohere({
|
|
493
|
+
apiKey: apiKey ?? "",
|
|
494
|
+
...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
|
|
495
|
+
...runtimeHeaders ? { headers: runtimeHeaders } : {},
|
|
496
|
+
...runtimeFetch ? { fetch: runtimeFetch } : {}
|
|
497
|
+
})(model);
|
|
308
498
|
}
|
|
309
499
|
case "ollama": {
|
|
310
500
|
const ollamaBaseURL = effectiveBaseURL || "http://localhost:11434/v1";
|
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)
|
|
@@ -115,6 +114,8 @@ class GlobalLogger {
|
|
|
115
114
|
if (this.logToConsole) {
|
|
116
115
|
transports.push(
|
|
117
116
|
new winston.transports.Console({
|
|
117
|
+
// Logs are diagnostics: stdout belongs to the command's output.
|
|
118
|
+
stderrLevels: Object.keys(logLevels),
|
|
118
119
|
format: winston.format.combine(
|
|
119
120
|
winston.format.timestamp({ format: "HH:mm:ss" }),
|
|
120
121
|
maskFormat(),
|
|
@@ -166,6 +167,8 @@ class GlobalLogger {
|
|
|
166
167
|
this.logToConsole = true;
|
|
167
168
|
transports.push(
|
|
168
169
|
new winston.transports.Console({
|
|
170
|
+
// Logs are diagnostics: stdout belongs to the command's output.
|
|
171
|
+
stderrLevels: Object.keys(logLevels),
|
|
169
172
|
format: winston.format.combine(
|
|
170
173
|
winston.format.timestamp({ format: "HH:mm:ss" }),
|
|
171
174
|
maskFormat(),
|
|
@@ -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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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)
|
|
@@ -82,6 +81,8 @@ class GlobalLogger {
|
|
|
82
81
|
if (this.logToConsole) {
|
|
83
82
|
transports.push(
|
|
84
83
|
new winston.transports.Console({
|
|
84
|
+
// Logs are diagnostics: stdout belongs to the command's output.
|
|
85
|
+
stderrLevels: Object.keys(logLevels),
|
|
85
86
|
format: winston.format.combine(
|
|
86
87
|
winston.format.timestamp({ format: "HH:mm:ss" }),
|
|
87
88
|
maskFormat(),
|
|
@@ -133,6 +134,8 @@ class GlobalLogger {
|
|
|
133
134
|
this.logToConsole = true;
|
|
134
135
|
transports.push(
|
|
135
136
|
new winston.transports.Console({
|
|
137
|
+
// Logs are diagnostics: stdout belongs to the command's output.
|
|
138
|
+
stderrLevels: Object.keys(logLevels),
|
|
136
139
|
format: winston.format.combine(
|
|
137
140
|
winston.format.timestamp({ format: "HH:mm:ss" }),
|
|
138
141
|
maskFormat(),
|
|
@@ -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;IACxB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,UAAU,CAAoB;IAKtC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAM5B;gBAEU,MAAM,EAAE,iBAAiB;IASrC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAM/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MA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
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,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;
|
|
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,EA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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
|
{
|