@dexto/core 1.6.26 → 1.6.27
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 +75 -90
- package/dist/agent/DextoAgent.d.ts +4 -4
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +76 -91
- package/dist/agent/error-codes.cjs +1 -0
- package/dist/agent/error-codes.d.ts +1 -0
- package/dist/agent/error-codes.d.ts.map +1 -1
- package/dist/agent/error-codes.js +1 -0
- package/dist/agent/errors.cjs +13 -0
- package/dist/agent/errors.d.ts +6 -0
- package/dist/agent/errors.d.ts.map +1 -1
- package/dist/agent/errors.js +13 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/schemas.d.ts +2 -2
- package/dist/agent/types.d.ts +11 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/approval/factory.cjs +1 -0
- package/dist/approval/factory.d.ts.map +1 -1
- package/dist/approval/factory.js +1 -0
- package/dist/approval/manager.cjs +19 -6
- package/dist/approval/manager.d.ts +6 -0
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +19 -6
- package/dist/approval/schemas.cjs +10 -0
- package/dist/approval/schemas.d.ts +305 -0
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +10 -0
- package/dist/events/index.cjs +210 -75
- package/dist/events/index.d.ts +44 -181
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +206 -74
- package/dist/hooks/manager.cjs +5 -2
- package/dist/hooks/manager.d.ts +2 -0
- package/dist/hooks/manager.d.ts.map +1 -1
- package/dist/hooks/manager.js +5 -2
- package/dist/hooks/types.d.ts +3 -0
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/llm/executor/turn-executor.cjs +8 -4
- package/dist/llm/executor/turn-executor.d.ts +3 -1
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +8 -4
- package/dist/llm/services/vercel.cjs +29 -6
- package/dist/llm/services/vercel.d.ts +3 -0
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +27 -5
- package/dist/mcp/manager.cjs +7 -2
- package/dist/mcp/manager.d.ts +3 -1
- package/dist/mcp/manager.d.ts.map +1 -1
- package/dist/mcp/manager.js +7 -2
- package/dist/mcp/mcp-client.cjs +71 -62
- package/dist/mcp/mcp-client.d.ts +3 -2
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +71 -62
- package/dist/mcp/schemas.d.ts +10 -10
- package/dist/resources/handlers/filesystem-handler.cjs +22 -3
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +22 -3
- package/dist/runtime/host-runtime.cjs +163 -0
- package/dist/runtime/host-runtime.d.ts +23 -0
- package/dist/runtime/host-runtime.d.ts.map +1 -0
- package/dist/runtime/host-runtime.js +133 -0
- package/dist/runtime/index.cjs +42 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +21 -0
- package/dist/runtime/run-context.cjs +53 -0
- package/dist/runtime/run-context.d.ts +13 -0
- package/dist/runtime/run-context.d.ts.map +1 -0
- package/dist/runtime/run-context.js +34 -0
- package/dist/session/chat-session.cjs +30 -32
- package/dist/session/chat-session.d.ts +5 -15
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +31 -33
- package/dist/session/error-codes.cjs +1 -0
- package/dist/session/error-codes.d.ts +2 -1
- package/dist/session/error-codes.d.ts.map +1 -1
- package/dist/session/error-codes.js +1 -0
- package/dist/session/errors.cjs +13 -0
- package/dist/session/errors.d.ts +6 -0
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/errors.js +13 -0
- package/dist/telemetry/decorators.cjs +75 -57
- package/dist/telemetry/decorators.d.ts +2 -0
- package/dist/telemetry/decorators.d.ts.map +1 -1
- package/dist/telemetry/decorators.js +75 -57
- package/dist/telemetry/utils.cjs +9 -6
- package/dist/telemetry/utils.d.ts +3 -0
- package/dist/telemetry/utils.d.ts.map +1 -1
- package/dist/telemetry/utils.js +9 -6
- package/dist/tools/tool-manager.cjs +92 -36
- package/dist/tools/tool-manager.d.ts +12 -3
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +92 -36
- package/dist/tools/types.d.ts +7 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/mcp/mcp-client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../chunk-PTJYTZNU.js";
|
|
2
2
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3
4
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
4
5
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
5
6
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
@@ -31,6 +32,7 @@ function buildClientCapabilities() {
|
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
class DextoMcpClient extends EventEmitter {
|
|
35
|
+
toolInvocationContext = new AsyncLocalStorage();
|
|
34
36
|
client = null;
|
|
35
37
|
transport = null;
|
|
36
38
|
isConnected = false;
|
|
@@ -304,71 +306,75 @@ class DextoMcpClient extends EventEmitter {
|
|
|
304
306
|
* @param args Tool arguments
|
|
305
307
|
* @returns Result of the tool execution
|
|
306
308
|
*/
|
|
307
|
-
async callTool(name, args) {
|
|
309
|
+
async callTool(name, args, invocation) {
|
|
308
310
|
this.ensureConnected();
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
this.logger.debug(`Calling tool '${name}' with args: ${JSON.stringify(args, null, 2)}`);
|
|
324
|
-
let toolArgs = args;
|
|
325
|
-
if (typeof args === "string") {
|
|
326
|
-
try {
|
|
327
|
-
toolArgs = JSON.parse(args);
|
|
328
|
-
} catch {
|
|
329
|
-
toolArgs = { input: args };
|
|
311
|
+
return await this.toolInvocationContext.run(invocation, async () => {
|
|
312
|
+
const shouldTrace = hasActiveTelemetry();
|
|
313
|
+
const tracer = shouldTrace ? trace.getTracer("dexto") : null;
|
|
314
|
+
const span = tracer?.startSpan(`mcp.tool.${name}`, {
|
|
315
|
+
kind: SpanKind.CLIENT
|
|
316
|
+
});
|
|
317
|
+
try {
|
|
318
|
+
if (span) {
|
|
319
|
+
const ctx = trace.setSpan(context.active(), span);
|
|
320
|
+
addBaggageAttributesToSpan(span, ctx, this.logger);
|
|
321
|
+
span.setAttribute("tool.name", name);
|
|
322
|
+
span.setAttribute("tool.server", this.serverAlias || "unknown");
|
|
323
|
+
span.setAttribute("tool.timeout", this.timeout);
|
|
324
|
+
span.setAttribute("tool.arguments", safeStringify(args, 4096));
|
|
330
325
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const logResult = JSON.stringify(
|
|
341
|
-
result,
|
|
342
|
-
(key, value) => {
|
|
343
|
-
if (key === "data" && typeof value === "string" && value.length > 100) {
|
|
344
|
-
return `[Base64 data: ${value.length} chars]`;
|
|
326
|
+
this.logger.debug(
|
|
327
|
+
`Calling tool '${name}' with args: ${JSON.stringify(args, null, 2)}`
|
|
328
|
+
);
|
|
329
|
+
let toolArgs = args;
|
|
330
|
+
if (typeof args === "string") {
|
|
331
|
+
try {
|
|
332
|
+
toolArgs = JSON.parse(args);
|
|
333
|
+
} catch {
|
|
334
|
+
toolArgs = { input: args };
|
|
345
335
|
}
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
336
|
+
}
|
|
337
|
+
this.logger.debug(`Using timeout: ${this.timeout}`);
|
|
338
|
+
const result = await this.client.callTool(
|
|
339
|
+
{ name, arguments: toolArgs },
|
|
340
|
+
void 0,
|
|
341
|
+
// resultSchema (optional)
|
|
342
|
+
{ timeout: this.timeout }
|
|
343
|
+
// Use server-specific timeout, default 1 minute
|
|
344
|
+
);
|
|
345
|
+
const logResult = JSON.stringify(
|
|
346
|
+
result,
|
|
347
|
+
(key, value) => {
|
|
348
|
+
if (key === "data" && typeof value === "string" && value.length > 100) {
|
|
349
|
+
return `[Base64 data: ${value.length} chars]`;
|
|
350
|
+
}
|
|
351
|
+
return value;
|
|
352
|
+
},
|
|
353
|
+
2
|
|
354
|
+
);
|
|
355
|
+
this.logger.debug(`Tool '${name}' result: ${logResult}`);
|
|
356
|
+
if (span) {
|
|
357
|
+
span.setAttribute("tool.result", safeStringify(result, 4096));
|
|
358
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
359
|
+
}
|
|
360
|
+
if (result === null || result === void 0) {
|
|
361
|
+
return "Tool executed successfully with no result data.";
|
|
362
|
+
}
|
|
363
|
+
return result;
|
|
364
|
+
} catch (error) {
|
|
365
|
+
this.logger.error(`Tool call '${name}' failed: ${JSON.stringify(error, null, 2)}`);
|
|
366
|
+
if (span) {
|
|
367
|
+
span.recordException(error);
|
|
368
|
+
span.setStatus({
|
|
369
|
+
code: SpanStatusCode.ERROR,
|
|
370
|
+
message: error instanceof Error ? error.message : String(error)
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
return `Error executing tool '${name}': ${error instanceof Error ? error.message : String(error)}`;
|
|
374
|
+
} finally {
|
|
375
|
+
span?.end();
|
|
367
376
|
}
|
|
368
|
-
|
|
369
|
-
} finally {
|
|
370
|
-
span?.end();
|
|
371
|
-
}
|
|
377
|
+
});
|
|
372
378
|
}
|
|
373
379
|
/**
|
|
374
380
|
* Get the list of tools provided by this client
|
|
@@ -639,10 +645,13 @@ class DextoMcpClient extends EventEmitter {
|
|
|
639
645
|
);
|
|
640
646
|
return { action: "decline" };
|
|
641
647
|
}
|
|
648
|
+
const invocation = this.toolInvocationContext.getStore();
|
|
642
649
|
const response = await this.approvalManager.requestElicitation({
|
|
643
650
|
schema: params.requestedSchema,
|
|
644
651
|
prompt: params.message,
|
|
645
|
-
serverName: this.serverAlias || "unknown"
|
|
652
|
+
serverName: this.serverAlias || "unknown",
|
|
653
|
+
...invocation?.sessionId !== void 0 ? { sessionId: invocation.sessionId } : {},
|
|
654
|
+
...invocation?.runContext?.hostRuntime !== void 0 ? { hostRuntime: invocation.runContext.hostRuntime } : {}
|
|
646
655
|
});
|
|
647
656
|
if (response.status === ApprovalStatus.APPROVED && response.data) {
|
|
648
657
|
const formData = response.data && typeof response.data === "object" && "formData" in response.data ? response.data.formData : {};
|
package/dist/mcp/schemas.d.ts
CHANGED
|
@@ -54,8 +54,8 @@ export declare const SseServerConfigSchema: z.ZodObject<{
|
|
|
54
54
|
}, "strict", z.ZodTypeAny, {
|
|
55
55
|
timeout: number;
|
|
56
56
|
type: "sse";
|
|
57
|
-
enabled: boolean;
|
|
58
57
|
url: string;
|
|
58
|
+
enabled: boolean;
|
|
59
59
|
connectionMode: "strict" | "lenient";
|
|
60
60
|
headers: Record<string, string>;
|
|
61
61
|
}, {
|
|
@@ -78,8 +78,8 @@ export declare const HttpServerConfigSchema: z.ZodObject<{
|
|
|
78
78
|
}, "strict", z.ZodTypeAny, {
|
|
79
79
|
timeout: number;
|
|
80
80
|
type: "http";
|
|
81
|
-
enabled: boolean;
|
|
82
81
|
url: string;
|
|
82
|
+
enabled: boolean;
|
|
83
83
|
connectionMode: "strict" | "lenient";
|
|
84
84
|
headers: Record<string, string>;
|
|
85
85
|
}, {
|
|
@@ -126,8 +126,8 @@ export declare const McpServerConfigSchema: z.ZodBranded<z.ZodEffects<z.ZodDiscr
|
|
|
126
126
|
}, "strict", z.ZodTypeAny, {
|
|
127
127
|
timeout: number;
|
|
128
128
|
type: "sse";
|
|
129
|
-
enabled: boolean;
|
|
130
129
|
url: string;
|
|
130
|
+
enabled: boolean;
|
|
131
131
|
connectionMode: "strict" | "lenient";
|
|
132
132
|
headers: Record<string, string>;
|
|
133
133
|
}, {
|
|
@@ -147,8 +147,8 @@ export declare const McpServerConfigSchema: z.ZodBranded<z.ZodEffects<z.ZodDiscr
|
|
|
147
147
|
}, "strict", z.ZodTypeAny, {
|
|
148
148
|
timeout: number;
|
|
149
149
|
type: "http";
|
|
150
|
-
enabled: boolean;
|
|
151
150
|
url: string;
|
|
151
|
+
enabled: boolean;
|
|
152
152
|
connectionMode: "strict" | "lenient";
|
|
153
153
|
headers: Record<string, string>;
|
|
154
154
|
}, {
|
|
@@ -169,15 +169,15 @@ export declare const McpServerConfigSchema: z.ZodBranded<z.ZodEffects<z.ZodDiscr
|
|
|
169
169
|
} | {
|
|
170
170
|
timeout: number;
|
|
171
171
|
type: "sse";
|
|
172
|
-
enabled: boolean;
|
|
173
172
|
url: string;
|
|
173
|
+
enabled: boolean;
|
|
174
174
|
connectionMode: "strict" | "lenient";
|
|
175
175
|
headers: Record<string, string>;
|
|
176
176
|
} | {
|
|
177
177
|
timeout: number;
|
|
178
178
|
type: "http";
|
|
179
|
-
enabled: boolean;
|
|
180
179
|
url: string;
|
|
180
|
+
enabled: boolean;
|
|
181
181
|
connectionMode: "strict" | "lenient";
|
|
182
182
|
headers: Record<string, string>;
|
|
183
183
|
}, {
|
|
@@ -239,8 +239,8 @@ export declare const ServersConfigSchema: z.ZodBranded<z.ZodRecord<z.ZodString,
|
|
|
239
239
|
}, "strict", z.ZodTypeAny, {
|
|
240
240
|
timeout: number;
|
|
241
241
|
type: "sse";
|
|
242
|
-
enabled: boolean;
|
|
243
242
|
url: string;
|
|
243
|
+
enabled: boolean;
|
|
244
244
|
connectionMode: "strict" | "lenient";
|
|
245
245
|
headers: Record<string, string>;
|
|
246
246
|
}, {
|
|
@@ -260,8 +260,8 @@ export declare const ServersConfigSchema: z.ZodBranded<z.ZodRecord<z.ZodString,
|
|
|
260
260
|
}, "strict", z.ZodTypeAny, {
|
|
261
261
|
timeout: number;
|
|
262
262
|
type: "http";
|
|
263
|
-
enabled: boolean;
|
|
264
263
|
url: string;
|
|
264
|
+
enabled: boolean;
|
|
265
265
|
connectionMode: "strict" | "lenient";
|
|
266
266
|
headers: Record<string, string>;
|
|
267
267
|
}, {
|
|
@@ -282,15 +282,15 @@ export declare const ServersConfigSchema: z.ZodBranded<z.ZodRecord<z.ZodString,
|
|
|
282
282
|
} | {
|
|
283
283
|
timeout: number;
|
|
284
284
|
type: "sse";
|
|
285
|
-
enabled: boolean;
|
|
286
285
|
url: string;
|
|
286
|
+
enabled: boolean;
|
|
287
287
|
connectionMode: "strict" | "lenient";
|
|
288
288
|
headers: Record<string, string>;
|
|
289
289
|
} | {
|
|
290
290
|
timeout: number;
|
|
291
291
|
type: "http";
|
|
292
|
-
enabled: boolean;
|
|
293
292
|
url: string;
|
|
293
|
+
enabled: boolean;
|
|
294
294
|
connectionMode: "strict" | "lenient";
|
|
295
295
|
headers: Record<string, string>;
|
|
296
296
|
}, {
|
|
@@ -305,11 +305,21 @@ class FileSystemResourceHandler {
|
|
|
305
305
|
".cache",
|
|
306
306
|
".vscode",
|
|
307
307
|
".idea",
|
|
308
|
-
".changeset",
|
|
309
308
|
".github",
|
|
310
309
|
".husky",
|
|
310
|
+
".agents",
|
|
311
|
+
".claude",
|
|
312
|
+
".cursor",
|
|
313
|
+
".dexto",
|
|
314
|
+
".conductor",
|
|
315
|
+
".logs",
|
|
311
316
|
"tmp",
|
|
312
|
-
"temp"
|
|
317
|
+
"temp",
|
|
318
|
+
"__pycache__",
|
|
319
|
+
".pytest_cache",
|
|
320
|
+
"target",
|
|
321
|
+
"vendor",
|
|
322
|
+
"site"
|
|
313
323
|
];
|
|
314
324
|
return ignoredDirectories.includes(basename);
|
|
315
325
|
}
|
|
@@ -320,15 +330,24 @@ class FileSystemResourceHandler {
|
|
|
320
330
|
if (!includeHidden) {
|
|
321
331
|
const allowedDotfiles = [
|
|
322
332
|
".gitignore",
|
|
333
|
+
".gitattributes",
|
|
323
334
|
".env",
|
|
324
335
|
".env.example",
|
|
336
|
+
".env.local",
|
|
337
|
+
".env.development",
|
|
338
|
+
".env.production",
|
|
325
339
|
".npmignore",
|
|
326
340
|
".dockerignore",
|
|
327
|
-
".editorconfig"
|
|
341
|
+
".editorconfig",
|
|
342
|
+
".prettierignore",
|
|
343
|
+
".eslintignore",
|
|
344
|
+
".nvmrc",
|
|
345
|
+
".node-version"
|
|
328
346
|
];
|
|
329
347
|
if (!allowedDotfiles.includes(basename)) return false;
|
|
330
348
|
}
|
|
331
349
|
if (basename === ".env" || basename.startsWith(".env.")) return true;
|
|
350
|
+
if (basename === ".nvmrc" || basename === ".node-version") return true;
|
|
332
351
|
}
|
|
333
352
|
if (!ext) {
|
|
334
353
|
const commonNoExtFiles = [
|
|
@@ -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,kBA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;AAC7E,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEpF,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;IAiDzB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IA0C7B,OAAO,CAAC,WAAW;CA4EtB"}
|
|
@@ -273,11 +273,21 @@ class FileSystemResourceHandler {
|
|
|
273
273
|
".cache",
|
|
274
274
|
".vscode",
|
|
275
275
|
".idea",
|
|
276
|
-
".changeset",
|
|
277
276
|
".github",
|
|
278
277
|
".husky",
|
|
278
|
+
".agents",
|
|
279
|
+
".claude",
|
|
280
|
+
".cursor",
|
|
281
|
+
".dexto",
|
|
282
|
+
".conductor",
|
|
283
|
+
".logs",
|
|
279
284
|
"tmp",
|
|
280
|
-
"temp"
|
|
285
|
+
"temp",
|
|
286
|
+
"__pycache__",
|
|
287
|
+
".pytest_cache",
|
|
288
|
+
"target",
|
|
289
|
+
"vendor",
|
|
290
|
+
"site"
|
|
281
291
|
];
|
|
282
292
|
return ignoredDirectories.includes(basename);
|
|
283
293
|
}
|
|
@@ -288,15 +298,24 @@ class FileSystemResourceHandler {
|
|
|
288
298
|
if (!includeHidden) {
|
|
289
299
|
const allowedDotfiles = [
|
|
290
300
|
".gitignore",
|
|
301
|
+
".gitattributes",
|
|
291
302
|
".env",
|
|
292
303
|
".env.example",
|
|
304
|
+
".env.local",
|
|
305
|
+
".env.development",
|
|
306
|
+
".env.production",
|
|
293
307
|
".npmignore",
|
|
294
308
|
".dockerignore",
|
|
295
|
-
".editorconfig"
|
|
309
|
+
".editorconfig",
|
|
310
|
+
".prettierignore",
|
|
311
|
+
".eslintignore",
|
|
312
|
+
".nvmrc",
|
|
313
|
+
".node-version"
|
|
296
314
|
];
|
|
297
315
|
if (!allowedDotfiles.includes(basename)) return false;
|
|
298
316
|
}
|
|
299
317
|
if (basename === ".env" || basename.startsWith(".env.")) return true;
|
|
318
|
+
if (basename === ".nvmrc" || basename === ".node-version") return true;
|
|
300
319
|
}
|
|
301
320
|
if (!ext) {
|
|
302
321
|
const commonNoExtFiles = [
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var host_runtime_exports = {};
|
|
20
|
+
__export(host_runtime_exports, {
|
|
21
|
+
HostRuntimeContextSchema: () => HostRuntimeContextSchema,
|
|
22
|
+
HostRuntimeIdsSchema: () => HostRuntimeIdsSchema,
|
|
23
|
+
getHostRuntimeAttributes: () => getHostRuntimeAttributes,
|
|
24
|
+
getHostRuntimeBaggageEntries: () => getHostRuntimeBaggageEntries,
|
|
25
|
+
getHostRuntimeContextFromBaggage: () => getHostRuntimeContextFromBaggage,
|
|
26
|
+
isHostRuntimeBaggageKey: () => isHostRuntimeBaggageKey,
|
|
27
|
+
normalizeHostRuntimeContext: () => normalizeHostRuntimeContext,
|
|
28
|
+
resolveHostRuntimeContext: () => resolveHostRuntimeContext
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(host_runtime_exports);
|
|
31
|
+
var import_api = require("@opentelemetry/api");
|
|
32
|
+
var import_zod = require("zod");
|
|
33
|
+
const HOST_RUNTIME_ENTRY_PREFIX = "hostRuntime.ids.";
|
|
34
|
+
const WELL_KNOWN_HOST_RUNTIME_ID_KEYS = ["runtimeId", "runId", "attemptId", "workspaceId"];
|
|
35
|
+
const WELL_KNOWN_HOST_RUNTIME_ID_KEY_SET = new Set(WELL_KNOWN_HOST_RUNTIME_ID_KEYS);
|
|
36
|
+
const HostRuntimeIdKeySchema = import_zod.z.string().min(1).regex(
|
|
37
|
+
/^[A-Za-z0-9._-]+$/,
|
|
38
|
+
"Runtime ID keys may only contain letters, numbers, dot, underscore, or hyphen."
|
|
39
|
+
);
|
|
40
|
+
const HostRuntimeIdValueSchema = import_zod.z.string().trim().min(1);
|
|
41
|
+
const HostRuntimeIdsSchema = import_zod.z.record(HostRuntimeIdKeySchema, HostRuntimeIdValueSchema).describe(
|
|
42
|
+
"Host-owned runtime IDs keyed by a stable identifier name such as runId, attemptId, or workspaceId."
|
|
43
|
+
);
|
|
44
|
+
const HostRuntimeContextSchema = import_zod.z.object({
|
|
45
|
+
ids: HostRuntimeIdsSchema.optional().describe(
|
|
46
|
+
"Optional host-owned runtime IDs used for correlation across orchestration, telemetry, logs, and events."
|
|
47
|
+
)
|
|
48
|
+
}).strict().describe("Host-owned runtime context surfaced through core runtime flows.");
|
|
49
|
+
function freezeHostRuntimeContext(hostRuntime) {
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
ids: Object.freeze({ ...hostRuntime.ids })
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function normalizeHostRuntimeContext(input) {
|
|
55
|
+
if (input === void 0) {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
const parsed = HostRuntimeContextSchema.parse(input);
|
|
59
|
+
if (!parsed.ids || Object.keys(parsed.ids).length === 0) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
return freezeHostRuntimeContext({ ids: parsed.ids });
|
|
63
|
+
}
|
|
64
|
+
function resolveHostRuntimeContext({
|
|
65
|
+
inherited,
|
|
66
|
+
explicit,
|
|
67
|
+
runId
|
|
68
|
+
}) {
|
|
69
|
+
const ids = {
|
|
70
|
+
...inherited?.ids ?? {},
|
|
71
|
+
...explicit?.ids ?? {},
|
|
72
|
+
...runId !== void 0 ? { runId } : {}
|
|
73
|
+
};
|
|
74
|
+
if (Object.keys(ids).length === 0) {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
return normalizeHostRuntimeContext({ ids });
|
|
78
|
+
}
|
|
79
|
+
function isWellKnownHostRuntimeIdKey(key) {
|
|
80
|
+
return WELL_KNOWN_HOST_RUNTIME_ID_KEY_SET.has(key);
|
|
81
|
+
}
|
|
82
|
+
function isHostRuntimeBaggageKey(key) {
|
|
83
|
+
return key.startsWith(HOST_RUNTIME_ENTRY_PREFIX) || WELL_KNOWN_HOST_RUNTIME_ID_KEY_SET.has(key);
|
|
84
|
+
}
|
|
85
|
+
function getValidHostRuntimeIdValue(value) {
|
|
86
|
+
const parsed = HostRuntimeIdValueSchema.safeParse(value);
|
|
87
|
+
return parsed.success ? parsed.data : void 0;
|
|
88
|
+
}
|
|
89
|
+
function getHostRuntimeBaggageEntries(hostRuntime) {
|
|
90
|
+
const ids = hostRuntime?.ids;
|
|
91
|
+
if (!ids) {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
const entries = {};
|
|
95
|
+
for (const [key, value] of Object.entries(ids)) {
|
|
96
|
+
entries[`${HOST_RUNTIME_ENTRY_PREFIX}${key}`] = { value };
|
|
97
|
+
if (isWellKnownHostRuntimeIdKey(key)) {
|
|
98
|
+
entries[key] = { value };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return entries;
|
|
102
|
+
}
|
|
103
|
+
function getHostRuntimeAttributes(hostRuntime) {
|
|
104
|
+
const ids = hostRuntime?.ids;
|
|
105
|
+
if (!ids) {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
const attributes = {};
|
|
109
|
+
for (const [key, value] of Object.entries(ids)) {
|
|
110
|
+
attributes[`${HOST_RUNTIME_ENTRY_PREFIX}${key}`] = value;
|
|
111
|
+
if (isWellKnownHostRuntimeIdKey(key)) {
|
|
112
|
+
attributes[key] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return attributes;
|
|
116
|
+
}
|
|
117
|
+
function getHostRuntimeContextFromBaggage(ctx) {
|
|
118
|
+
const baggage = import_api.propagation.getBaggage(ctx);
|
|
119
|
+
if (!baggage) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
const ids = {};
|
|
123
|
+
for (const [key, entry] of baggage.getAllEntries()) {
|
|
124
|
+
if (key.startsWith(HOST_RUNTIME_ENTRY_PREFIX)) {
|
|
125
|
+
const hostRuntimeKey = key.slice(HOST_RUNTIME_ENTRY_PREFIX.length);
|
|
126
|
+
if (!HostRuntimeIdKeySchema.safeParse(hostRuntimeKey).success) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const value = getValidHostRuntimeIdValue(entry.value);
|
|
130
|
+
if (value === void 0) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
ids[hostRuntimeKey] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const key of WELL_KNOWN_HOST_RUNTIME_ID_KEYS) {
|
|
137
|
+
if (ids[key] !== void 0) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const entry = baggage.getEntry(key);
|
|
141
|
+
if (entry) {
|
|
142
|
+
const value = getValidHostRuntimeIdValue(entry.value);
|
|
143
|
+
if (value !== void 0) {
|
|
144
|
+
ids[key] = value;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (Object.keys(ids).length === 0) {
|
|
149
|
+
return void 0;
|
|
150
|
+
}
|
|
151
|
+
return normalizeHostRuntimeContext({ ids });
|
|
152
|
+
}
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
HostRuntimeContextSchema,
|
|
156
|
+
HostRuntimeIdsSchema,
|
|
157
|
+
getHostRuntimeAttributes,
|
|
158
|
+
getHostRuntimeBaggageEntries,
|
|
159
|
+
getHostRuntimeContextFromBaggage,
|
|
160
|
+
isHostRuntimeBaggageKey,
|
|
161
|
+
normalizeHostRuntimeContext,
|
|
162
|
+
resolveHostRuntimeContext
|
|
163
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BaggageEntry, Context } from '@opentelemetry/api';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const HostRuntimeIdsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
4
|
+
export declare const HostRuntimeContextSchema: z.ZodObject<{
|
|
5
|
+
ids: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
|
+
ids?: Record<string, string> | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
ids?: Record<string, string> | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
export type HostRuntimeIds = z.output<typeof HostRuntimeIdsSchema>;
|
|
12
|
+
export type HostRuntimeContext = z.output<typeof HostRuntimeContextSchema>;
|
|
13
|
+
export declare function normalizeHostRuntimeContext(input: z.input<typeof HostRuntimeContextSchema> | undefined): HostRuntimeContext | undefined;
|
|
14
|
+
export declare function resolveHostRuntimeContext({ inherited, explicit, runId, }: {
|
|
15
|
+
inherited?: HostRuntimeContext | undefined;
|
|
16
|
+
explicit?: HostRuntimeContext | undefined;
|
|
17
|
+
runId?: string | undefined;
|
|
18
|
+
}): HostRuntimeContext | undefined;
|
|
19
|
+
export declare function isHostRuntimeBaggageKey(key: string): boolean;
|
|
20
|
+
export declare function getHostRuntimeBaggageEntries(hostRuntime?: HostRuntimeContext): Record<string, BaggageEntry>;
|
|
21
|
+
export declare function getHostRuntimeAttributes(hostRuntime?: HostRuntimeContext): Record<string, string>;
|
|
22
|
+
export declare function getHostRuntimeContextFromBaggage(ctx: Context): HostRuntimeContext | undefined;
|
|
23
|
+
//# sourceMappingURL=host-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/host-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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