@n8n/instance-ai 1.12.2 → 1.13.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/apply-agent-thinking.d.ts +2 -0
- package/dist/agent/apply-agent-thinking.js +41 -0
- package/dist/agent/apply-agent-thinking.js.map +1 -0
- package/dist/agent/instance-agent.js +10 -2
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/sanitize-mcp-schemas.js +133 -125
- package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
- package/dist/agent/shared-prompts.d.ts +0 -1
- package/dist/agent/shared-prompts.js +4 -11
- package/dist/agent/shared-prompts.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +4 -4
- package/dist/agent/system-prompt.js +3 -10
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/debug/run-debug-buffer.d.ts +63 -0
- package/dist/debug/run-debug-buffer.js +177 -0
- package/dist/debug/run-debug-buffer.js.map +1 -0
- package/dist/debug/sanitize-debug-snapshot.d.ts +2 -0
- package/dist/debug/sanitize-debug-snapshot.js +88 -0
- package/dist/debug/sanitize-debug-snapshot.js.map +1 -0
- package/dist/error-formatting.js +3 -5
- package/dist/error-formatting.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base/build-templates-index.d.ts +1 -0
- package/dist/knowledge-base/build-templates-index.js +18 -2
- package/dist/knowledge-base/build-templates-index.js.map +1 -1
- package/dist/knowledge-base/materialize-knowledge-base.d.ts +2 -3
- package/dist/knowledge-base/materialize-knowledge-base.js +10 -7
- package/dist/knowledge-base/materialize-knowledge-base.js.map +1 -1
- package/dist/mcp/mcp-client-manager.d.ts +1 -1
- package/dist/mcp/mcp-client-manager.js +13 -9
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/runtime/memory-task-registry.d.ts +8 -0
- package/dist/runtime/memory-task-registry.js +42 -0
- package/dist/runtime/memory-task-registry.js.map +1 -0
- package/dist/runtime/resumable-stream-executor.d.ts +3 -0
- package/dist/runtime/resumable-stream-executor.js +171 -90
- package/dist/runtime/resumable-stream-executor.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +2 -0
- package/dist/runtime/run-state-registry.js +3 -0
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/runtime/stream-runner.d.ts +3 -0
- package/dist/runtime/stream-runner.js +3 -0
- package/dist/runtime/stream-runner.js.map +1 -1
- package/dist/skills/materialize-runtime-skills.d.ts +3 -3
- package/dist/skills/materialize-runtime-skills.js +1 -1
- package/dist/skills/materialize-runtime-skills.js.map +1 -1
- package/dist/source-map-filter.js +0 -1
- package/dist/source-map-filter.js.map +1 -1
- package/dist/storage/terminal-outcome-storage.d.ts +2 -2
- package/dist/storage/workflow-loop-storage.d.ts +75 -4
- package/dist/stream/map-chunk.js +198 -237
- package/dist/stream/map-chunk.js.map +1 -1
- package/dist/stream/output-redaction.js +2 -2
- package/dist/stream/output-redaction.js.map +1 -1
- package/dist/stream/usage-accumulator.d.ts +90 -0
- package/dist/stream/usage-accumulator.js +89 -0
- package/dist/stream/usage-accumulator.js.map +1 -0
- package/dist/stream/work-summary-accumulator.d.ts +6 -6
- package/dist/tools/attachments/parse-file.tool.js +1 -1
- package/dist/tools/attachments/parse-file.tool.js.map +1 -1
- package/dist/tools/credentials.tool.js +4 -1
- package/dist/tools/credentials.tool.js.map +1 -1
- package/dist/tools/data-tables.tool.js +5 -2
- package/dist/tools/data-tables.tool.js.map +1 -1
- package/dist/tools/evals/column-ref-utils.d.ts +1 -2
- package/dist/tools/evals/column-ref-utils.js +19 -18
- package/dist/tools/evals/column-ref-utils.js.map +1 -1
- package/dist/tools/evals/describe-metric-for-workflow.service.js +7 -25
- package/dist/tools/evals/describe-metric-for-workflow.service.js.map +1 -1
- package/dist/tools/evals/detect-tool-refs.service.js +2 -1
- package/dist/tools/evals/detect-tool-refs.service.js.map +1 -1
- package/dist/tools/evals/eval-data-requirements.service.js +10 -9
- package/dist/tools/evals/eval-data-requirements.service.js.map +1 -1
- package/dist/tools/evals/evals.tool.js +2 -2
- package/dist/tools/evals/evals.tool.js.map +1 -1
- package/dist/tools/evals/extract-rows-from-history.service.js +8 -8
- package/dist/tools/evals/extract-rows-from-history.service.js.map +1 -1
- package/dist/tools/evals/generate-sample-rows.service.d.ts +2 -2
- package/dist/tools/evals/generate-sample-rows.service.js +30 -49
- package/dist/tools/evals/generate-sample-rows.service.js.map +1 -1
- package/dist/tools/evals/generate-tool-ref-pin-data.service.js +10 -23
- package/dist/tools/evals/generate-tool-ref-pin-data.service.js.map +1 -1
- package/dist/tools/evals/metric-catalog.js +3 -3
- package/dist/tools/evals/metric-catalog.js.map +1 -1
- package/dist/tools/executions.tool.js +10 -2
- package/dist/tools/executions.tool.js.map +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.js +8 -10
- package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.js +21 -42
- package/dist/tools/nodes/node-search-engine.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.types.d.ts +2 -0
- package/dist/tools/nodes/preferred-chat-model.d.ts +1 -0
- package/dist/tools/nodes/preferred-chat-model.js +19 -0
- package/dist/tools/nodes/preferred-chat-model.js.map +1 -0
- package/dist/tools/nodes/suggested-nodes-data.js +13 -3
- package/dist/tools/nodes/suggested-nodes-data.js.map +1 -1
- package/dist/tools/nodes.tool.js +32 -7
- package/dist/tools/nodes.tool.js.map +1 -1
- package/dist/tools/orchestration/complete-checkpoint.tool.js +3 -5
- package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -1
- package/dist/tools/orchestration/eval-data-agent.tool.js +2 -1
- package/dist/tools/orchestration/eval-data-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/eval-setup-agent.prompt.d.ts +1 -1
- package/dist/tools/orchestration/eval-setup-agent.prompt.js +3 -3
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +2 -2
- package/dist/tools/orchestration/report-verification-verdict.tool.js +1 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
- package/dist/tools/orchestration/verify-built-workflow.tool.js +320 -307
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/research.tool.js +1 -1
- package/dist/tools/research.tool.js.map +1 -1
- package/dist/tools/shared/ask-user.tool.d.ts +4 -4
- package/dist/tools/shared/ask-user.tool.js +6 -1
- package/dist/tools/shared/ask-user.tool.js.map +1 -1
- package/dist/tools/tool-ids.d.ts +0 -1
- package/dist/tools/tool-ids.js +0 -1
- package/dist/tools/tool-ids.js.map +1 -1
- package/dist/tools/workflows/build-workflow.tool.d.ts +4 -22
- package/dist/tools/workflows/build-workflow.tool.js +373 -317
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/classify-node-destructiveness.service.d.ts +7 -0
- package/dist/tools/workflows/classify-node-destructiveness.service.js +307 -0
- package/dist/tools/workflows/classify-node-destructiveness.service.js.map +1 -0
- package/dist/tools/workflows/generate-simulation-fixtures.service.d.ts +8 -0
- package/dist/tools/workflows/generate-simulation-fixtures.service.js +95 -0
- package/dist/tools/workflows/generate-simulation-fixtures.service.js.map +1 -0
- package/dist/tools/workflows/plan-verification-simulation.d.ts +15 -0
- package/dist/tools/workflows/plan-verification-simulation.js +32 -0
- package/dist/tools/workflows/plan-verification-simulation.js.map +1 -0
- package/dist/tools/workflows/resolve-credentials.d.ts +0 -2
- package/dist/tools/workflows/resolve-credentials.js +0 -13
- package/dist/tools/workflows/resolve-credentials.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.service.js +259 -215
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
- package/dist/tools/workflows/validate-workflow.service.js +81 -66
- package/dist/tools/workflows/validate-workflow.service.js.map +1 -1
- package/dist/tools/workflows/workflow-build-context.d.ts +33 -0
- package/dist/tools/workflows/workflow-build-context.js +80 -0
- package/dist/tools/workflows/workflow-build-context.js.map +1 -0
- package/dist/tools/workflows/workflow-build-remediation.d.ts +11 -0
- package/dist/tools/workflows/workflow-build-remediation.js +89 -0
- package/dist/tools/workflows/workflow-build-remediation.js.map +1 -0
- package/dist/tools/workflows/workflow-build-reporting.d.ts +19 -0
- package/dist/tools/workflows/workflow-build-reporting.js +78 -0
- package/dist/tools/workflows/workflow-build-reporting.js.map +1 -0
- package/dist/tools/workflows/workflow-build-routing.d.ts +2 -0
- package/dist/tools/workflows/workflow-build-routing.js +83 -0
- package/dist/tools/workflows/workflow-build-routing.js.map +1 -0
- package/dist/tools/workflows/workflow-build-telemetry.d.ts +18 -0
- package/dist/tools/workflows/workflow-build-telemetry.js +33 -0
- package/dist/tools/workflows/workflow-build-telemetry.js.map +1 -0
- package/dist/tools/workflows/workflow-file-bindings.d.ts +28 -0
- package/dist/tools/workflows/workflow-file-bindings.js +104 -0
- package/dist/tools/workflows/workflow-file-bindings.js.map +1 -0
- package/dist/tools/workflows/workflow-json-utils.d.ts +3 -0
- package/dist/tools/workflows/workflow-json-utils.js +54 -5
- package/dist/tools/workflows/workflow-json-utils.js.map +1 -1
- package/dist/tools/workflows/workflow-source-compiler.d.ts +19 -0
- package/dist/tools/workflows/workflow-source-compiler.js +217 -0
- package/dist/tools/workflows/workflow-source-compiler.js.map +1 -0
- package/dist/tools/workflows/workflow-validation-warnings.d.ts +14 -0
- package/dist/tools/workflows/workflow-validation-warnings.js +28 -0
- package/dist/tools/workflows/workflow-validation-warnings.js.map +1 -0
- package/dist/tools/workflows.tool.js +107 -99
- package/dist/tools/workflows.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.js +7 -7
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/tracing/trace-payloads.d.ts +2 -1
- package/dist/tracing/trace-payloads.js +152 -114
- package/dist/tracing/trace-payloads.js.map +1 -1
- package/dist/types.d.ts +24 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/eval-agents.d.ts +0 -3
- package/dist/utils/eval-agents.js +3 -11
- package/dist/utils/eval-agents.js.map +1 -1
- package/dist/utils/generate-validated-json.d.ts +16 -0
- package/dist/utils/generate-validated-json.js +38 -0
- package/dist/utils/generate-validated-json.js.map +1 -0
- package/dist/utils/stream-helpers.d.ts +0 -1
- package/dist/utils/stream-helpers.js +5 -8
- package/dist/utils/stream-helpers.js.map +1 -1
- package/dist/workflow-builder/build-failure-tracker.js +25 -1
- package/dist/workflow-builder/build-failure-tracker.js.map +1 -1
- package/dist/workflow-builder/index.d.ts +0 -4
- package/dist/workflow-builder/index.js +1 -11
- package/dist/workflow-builder/index.js.map +1 -1
- package/dist/workflow-loop/guidance.js +14 -15
- package/dist/workflow-loop/guidance.js.map +1 -1
- package/dist/workflow-loop/runtime.js +1 -0
- package/dist/workflow-loop/runtime.js.map +1 -1
- package/dist/workflow-loop/verification-obligation.js +8 -1
- package/dist/workflow-loop/verification-obligation.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-controller.js +17 -1
- package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-state.d.ts +90 -6
- package/dist/workflow-loop/workflow-loop-state.js +13 -1
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
- package/dist/workspace/builder-templates-service.d.ts +5 -5
- package/dist/workspace/builder-templates-service.js +17 -14
- package/dist/workspace/builder-templates-service.js.map +1 -1
- package/dist/workspace/create-workspace.js +8 -1
- package/dist/workspace/create-workspace.js.map +1 -1
- package/dist/workspace/prebaked-workspace-bundle.d.ts +2 -2
- package/dist/workspace/prebaked-workspace-bundle.js +5 -5
- package/dist/workspace/prebaked-workspace-bundle.js.map +1 -1
- package/dist/workspace/sandbox-setup.d.ts +1 -1
- package/dist/workspace/sandbox-setup.js +10 -37
- package/dist/workspace/sandbox-setup.js.map +1 -1
- package/dist/workspace/snapshot-manager.d.ts +1 -1
- package/dist/workspace/template-telemetry.js +2 -5
- package/dist/workspace/template-telemetry.js.map +1 -1
- package/dist/workspace/workspace-files.d.ts +1 -1
- package/dist/workspace/workspace-files.js +3 -3
- package/dist/workspace/workspace-files.js.map +1 -1
- package/dist/workspace/workspace-manifest.js +2 -2
- package/dist/workspace/workspace-manifest.js.map +1 -1
- package/dist/workspace/workspace-paths.d.ts +4 -0
- package/dist/workspace/workspace-paths.js +25 -0
- package/dist/workspace/workspace-paths.js.map +1 -0
- package/knowledge-base/reference/open-ai-output-shape.md +79 -0
- package/knowledge-base/reference/workflow-builder-guardrails.md +15 -0
- package/package.json +13 -12
- package/skills/planned-task-runtime/SKILL.md +3 -2
- package/skills/planning/SKILL.md +5 -0
- package/skills/post-build-flow/SKILL.md +25 -9
- package/skills/workflow-builder/SKILL.md +89 -134
- package/dist/tools/workflows/submit-workflow-identity.d.ts +0 -39
- package/dist/tools/workflows/submit-workflow-identity.js +0 -181
- package/dist/tools/workflows/submit-workflow-identity.js.map +0 -1
- package/dist/tools/workflows/submit-workflow.tool.d.ts +0 -223
- package/dist/tools/workflows/submit-workflow.tool.js +0 -491
- package/dist/tools/workflows/submit-workflow.tool.js.map +0 -1
- package/dist/workflow-builder/extract-code.d.ts +0 -5
- package/dist/workflow-builder/extract-code.js +0 -105
- package/dist/workflow-builder/extract-code.js.map +0 -1
- package/dist/workflow-builder/parse-validate.d.ts +0 -10
- package/dist/workflow-builder/parse-validate.js +0 -50
- package/dist/workflow-builder/parse-validate.js.map +0 -1
- package/dist/workflow-builder/patch-code.d.ts +0 -14
- package/dist/workflow-builder/patch-code.js +0 -117
- package/dist/workflow-builder/patch-code.js.map +0 -1
- package/dist/workflow-builder/types.d.ts +0 -11
- package/dist/workflow-builder/types.js +0 -3
- package/dist/workflow-builder/types.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GEN_AI_COMPLETION = exports.GEN_AI_PROMPT = void 0;
|
|
3
|
+
exports.GEN_AI_COMPLETION = exports.GEN_AI_PROMPT = exports.DEFAULT_TELEMETRY_REDACTION_OPTIONS = void 0;
|
|
4
4
|
exports.toTelemetryAttributeValue = toTelemetryAttributeValue;
|
|
5
5
|
exports.toTelemetryMetadata = toTelemetryMetadata;
|
|
6
6
|
exports.redactLangSmithTelemetrySpan = redactLangSmithTelemetrySpan;
|
|
@@ -9,11 +9,11 @@ exports.sanitizeTracePayload = sanitizeTracePayload;
|
|
|
9
9
|
exports.serializeModelIdForTrace = serializeModelIdForTrace;
|
|
10
10
|
exports.mergeTraceInputs = mergeTraceInputs;
|
|
11
11
|
exports.buildAgentTraceInputs = buildAgentTraceInputs;
|
|
12
|
+
const agents_1 = require("@n8n/agents");
|
|
12
13
|
const utils_1 = require("@n8n/utils");
|
|
13
14
|
const node_crypto_1 = require("node:crypto");
|
|
14
15
|
const tool_ids_1 = require("../tools/tool-ids");
|
|
15
16
|
const trace_labels_1 = require("./trace-labels");
|
|
16
|
-
const stream_helpers_1 = require("../utils/stream-helpers");
|
|
17
17
|
const MAX_TRACE_DEPTH = 4;
|
|
18
18
|
const MAX_PROMPT_SCHEMA_TRACE_DEPTH = 12;
|
|
19
19
|
const MAX_TOOL_IO_TRACE_DEPTH = 8;
|
|
@@ -22,6 +22,24 @@ const MAX_TOOL_ACTION_DISPLAY_LENGTH = 64;
|
|
|
22
22
|
const MAX_TRACE_ARRAY_ITEMS = 20;
|
|
23
23
|
const MAX_TRACE_OBJECT_KEYS = 30;
|
|
24
24
|
const SENSITIVE_TELEMETRY_KEY_PATTERN = /(api[_-]?key|authorization|bearer|cookie|credentials?|password|secret|access[_-]?token|refresh[_-]?token|id[_-]?token|session[_-]?token|auth[_-]?token|(?:^|[._-])token$)/i;
|
|
25
|
+
const STRUCTURAL_TELEMETRY_ID_KEYS = new Set([
|
|
26
|
+
'langsmith.span.id',
|
|
27
|
+
'langsmith.span.parent_id',
|
|
28
|
+
'langsmith.trace.id',
|
|
29
|
+
'langsmith.span.dotted_order',
|
|
30
|
+
'langsmith.traceable_parent_otel_span_id',
|
|
31
|
+
]);
|
|
32
|
+
const CORRELATION_ID_KEY_PATTERN = /(?:^|[._])(?:run|trace|span|activation)_id$/;
|
|
33
|
+
function isStructuralTelemetryIdKey(key) {
|
|
34
|
+
return STRUCTURAL_TELEMETRY_ID_KEYS.has(key) || CORRELATION_ID_KEY_PATTERN.test(key);
|
|
35
|
+
}
|
|
36
|
+
exports.DEFAULT_TELEMETRY_REDACTION_OPTIONS = {
|
|
37
|
+
secrets: true,
|
|
38
|
+
detect: agents_1.SUPPORTED_PII_CATEGORIES,
|
|
39
|
+
};
|
|
40
|
+
function scrubTelemetryText(value) {
|
|
41
|
+
return (0, agents_1.redactText)(value, exports.DEFAULT_TELEMETRY_REDACTION_OPTIONS).text;
|
|
42
|
+
}
|
|
25
43
|
const LANGSMITH_TRACE_NAME = 'langsmith.trace.name';
|
|
26
44
|
const LANGSMITH_SPAN_KIND = 'langsmith.span.kind';
|
|
27
45
|
const LANGSMITH_USAGE_METADATA = 'langsmith.usage_metadata';
|
|
@@ -101,7 +119,7 @@ function redactTelemetryJsonValue(value, keyHint, depth = 0, maxDepth = MAX_TRAC
|
|
|
101
119
|
return '[redacted]';
|
|
102
120
|
}
|
|
103
121
|
if (typeof value === 'string') {
|
|
104
|
-
return (
|
|
122
|
+
return scrubTelemetryText(value);
|
|
105
123
|
}
|
|
106
124
|
if (typeof value === 'number' || typeof value === 'boolean' || value === null) {
|
|
107
125
|
return value;
|
|
@@ -109,7 +127,7 @@ function redactTelemetryJsonValue(value, keyHint, depth = 0, maxDepth = MAX_TRAC
|
|
|
109
127
|
if (Array.isArray(value)) {
|
|
110
128
|
return value.map((entry) => redactTelemetryJsonValue(entry, keyHint, depth + 1, maxDepth));
|
|
111
129
|
}
|
|
112
|
-
if ((0,
|
|
130
|
+
if ((0, utils_1.isRecord)(value)) {
|
|
113
131
|
const redacted = {};
|
|
114
132
|
for (const [key, entryValue] of Object.entries(value)) {
|
|
115
133
|
redacted[key] = redactTelemetryJsonValue(entryValue, key, depth + 1, maxDepth);
|
|
@@ -128,6 +146,9 @@ function maxRedactionDepthForAttribute(key) {
|
|
|
128
146
|
return MAX_TRACE_DEPTH;
|
|
129
147
|
}
|
|
130
148
|
function redactTelemetryAttribute(key, value) {
|
|
149
|
+
if (isStructuralTelemetryIdKey(key)) {
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
131
152
|
if (SENSITIVE_TELEMETRY_KEY_PATTERN.test(key)) {
|
|
132
153
|
return '[redacted]';
|
|
133
154
|
}
|
|
@@ -143,10 +164,10 @@ function redactTelemetryAttribute(key, value) {
|
|
|
143
164
|
return JSON.stringify(redactTelemetryJsonValue(parsed, key, 0, maxDepth));
|
|
144
165
|
}
|
|
145
166
|
catch {
|
|
146
|
-
return (
|
|
167
|
+
return scrubTelemetryText(value);
|
|
147
168
|
}
|
|
148
169
|
}
|
|
149
|
-
return (
|
|
170
|
+
return scrubTelemetryText(value);
|
|
150
171
|
}
|
|
151
172
|
function parseTelemetryJson(value) {
|
|
152
173
|
if (typeof value !== 'string') {
|
|
@@ -204,6 +225,28 @@ function stringifyToolPayload(value) {
|
|
|
204
225
|
return '[unserializable]';
|
|
205
226
|
}
|
|
206
227
|
}
|
|
228
|
+
function extractAssistantToolCall(part) {
|
|
229
|
+
const toolCallId = typeof part.toolCallId === 'string'
|
|
230
|
+
? part.toolCallId
|
|
231
|
+
: typeof part.id === 'string'
|
|
232
|
+
? part.id
|
|
233
|
+
: undefined;
|
|
234
|
+
const toolName = typeof part.toolName === 'string'
|
|
235
|
+
? part.toolName
|
|
236
|
+
: typeof part.name === 'string'
|
|
237
|
+
? part.name
|
|
238
|
+
: undefined;
|
|
239
|
+
if (!toolCallId || !toolName)
|
|
240
|
+
return undefined;
|
|
241
|
+
return {
|
|
242
|
+
id: toolCallId,
|
|
243
|
+
type: 'function',
|
|
244
|
+
function: {
|
|
245
|
+
name: toolName,
|
|
246
|
+
arguments: stringifyToolPayload(readToolCallPayload(part)),
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
207
250
|
function normalizeAssistantMessageForLangSmith(message) {
|
|
208
251
|
const content = message.content;
|
|
209
252
|
if (!Array.isArray(content)) {
|
|
@@ -212,7 +255,7 @@ function normalizeAssistantMessageForLangSmith(message) {
|
|
|
212
255
|
const textParts = [];
|
|
213
256
|
const toolCalls = [];
|
|
214
257
|
for (const part of content) {
|
|
215
|
-
if (!(0,
|
|
258
|
+
if (!(0, utils_1.isRecord)(part))
|
|
216
259
|
continue;
|
|
217
260
|
if (part.type === 'text' && typeof part.text === 'string') {
|
|
218
261
|
textParts.push(part.text);
|
|
@@ -220,26 +263,9 @@ function normalizeAssistantMessageForLangSmith(message) {
|
|
|
220
263
|
}
|
|
221
264
|
if (part.type !== 'tool-call')
|
|
222
265
|
continue;
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
? part.id
|
|
227
|
-
: undefined;
|
|
228
|
-
const toolName = typeof part.toolName === 'string'
|
|
229
|
-
? part.toolName
|
|
230
|
-
: typeof part.name === 'string'
|
|
231
|
-
? part.name
|
|
232
|
-
: undefined;
|
|
233
|
-
if (!toolCallId || !toolName)
|
|
234
|
-
continue;
|
|
235
|
-
toolCalls.push({
|
|
236
|
-
id: toolCallId,
|
|
237
|
-
type: 'function',
|
|
238
|
-
function: {
|
|
239
|
-
name: toolName,
|
|
240
|
-
arguments: stringifyToolPayload(readToolCallPayload(part)),
|
|
241
|
-
},
|
|
242
|
-
});
|
|
266
|
+
const toolCall = extractAssistantToolCall(part);
|
|
267
|
+
if (toolCall)
|
|
268
|
+
toolCalls.push(toolCall);
|
|
243
269
|
}
|
|
244
270
|
if (toolCalls.length === 0) {
|
|
245
271
|
return message;
|
|
@@ -257,7 +283,7 @@ function normalizeToolMessageForLangSmith(message) {
|
|
|
257
283
|
}
|
|
258
284
|
const normalizedMessages = [];
|
|
259
285
|
for (const part of content) {
|
|
260
|
-
if (!(0,
|
|
286
|
+
if (!(0, utils_1.isRecord)(part) || part.type !== 'tool-result') {
|
|
261
287
|
continue;
|
|
262
288
|
}
|
|
263
289
|
const toolCallId = typeof part.toolCallId === 'string'
|
|
@@ -284,7 +310,7 @@ function normalizeToolMessageForLangSmith(message) {
|
|
|
284
310
|
function normalizeMessagesForLangSmith(messages) {
|
|
285
311
|
const normalizedMessages = [];
|
|
286
312
|
for (const message of messages) {
|
|
287
|
-
if (!(0,
|
|
313
|
+
if (!(0, utils_1.isRecord)(message) || typeof message.role !== 'string') {
|
|
288
314
|
normalizedMessages.push(message);
|
|
289
315
|
continue;
|
|
290
316
|
}
|
|
@@ -304,7 +330,7 @@ function stableStringify(value) {
|
|
|
304
330
|
if (Array.isArray(value)) {
|
|
305
331
|
return `[${value.map((entry) => stableStringify(entry)).join(',')}]`;
|
|
306
332
|
}
|
|
307
|
-
if ((0,
|
|
333
|
+
if ((0, utils_1.isRecord)(value)) {
|
|
308
334
|
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
|
|
309
335
|
return `{${entries
|
|
310
336
|
.map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`)
|
|
@@ -316,13 +342,13 @@ function stableHash(value) {
|
|
|
316
342
|
return (0, node_crypto_1.createHash)('sha256').update(stableStringify(value)).digest('hex');
|
|
317
343
|
}
|
|
318
344
|
function toolNameFromDefinition(tool) {
|
|
319
|
-
if (!(0,
|
|
345
|
+
if (!(0, utils_1.isRecord)(tool))
|
|
320
346
|
return undefined;
|
|
321
347
|
if (typeof tool.name === 'string')
|
|
322
348
|
return tool.name;
|
|
323
349
|
if (typeof tool.id === 'string')
|
|
324
350
|
return tool.id;
|
|
325
|
-
if ((0,
|
|
351
|
+
if ((0, utils_1.isRecord)(tool.function) && typeof tool.function.name === 'string') {
|
|
326
352
|
return tool.function.name;
|
|
327
353
|
}
|
|
328
354
|
return undefined;
|
|
@@ -387,7 +413,7 @@ function numberFromAttribute(value) {
|
|
|
387
413
|
}
|
|
388
414
|
function readTokenDetail(details, keys) {
|
|
389
415
|
const parsedDetails = typeof details === 'string' ? parseTelemetryJson(details) : details;
|
|
390
|
-
if (!(0,
|
|
416
|
+
if (!(0, utils_1.isRecord)(parsedDetails)) {
|
|
391
417
|
return undefined;
|
|
392
418
|
}
|
|
393
419
|
for (const key of keys) {
|
|
@@ -401,16 +427,16 @@ function readTokenDetail(details, keys) {
|
|
|
401
427
|
function readNestedRecord(record, keys) {
|
|
402
428
|
let current = record;
|
|
403
429
|
for (const key of keys) {
|
|
404
|
-
if (!(0,
|
|
430
|
+
if (!(0, utils_1.isRecord)(current)) {
|
|
405
431
|
return {};
|
|
406
432
|
}
|
|
407
433
|
current = current[key];
|
|
408
434
|
}
|
|
409
|
-
return (0,
|
|
435
|
+
return (0, utils_1.isRecord)(current) ? current : {};
|
|
410
436
|
}
|
|
411
437
|
function readProviderAnthropicUsage(attributes) {
|
|
412
438
|
const providerMetadata = parseTelemetryJson(attributes['ai.response.providerMetadata']);
|
|
413
|
-
return (0,
|
|
439
|
+
return (0, utils_1.isRecord)(providerMetadata)
|
|
414
440
|
? readNestedRecord(providerMetadata, ['anthropic', 'usage'])
|
|
415
441
|
: {};
|
|
416
442
|
}
|
|
@@ -434,23 +460,8 @@ function calculateInputTokenAccounting(inputTokens, cacheReadTokens, cacheCreati
|
|
|
434
460
|
totalInputTokens: regularInputTokens + cachedInputTokens,
|
|
435
461
|
};
|
|
436
462
|
}
|
|
437
|
-
function
|
|
438
|
-
|
|
439
|
-
GEN_AI_USAGE_INPUT_TOKENS,
|
|
440
|
-
'ai.usage.inputTokens',
|
|
441
|
-
'ai.usage.promptTokens',
|
|
442
|
-
]);
|
|
443
|
-
const outputTokens = firstNumberAttribute(attributes, [
|
|
444
|
-
GEN_AI_USAGE_OUTPUT_TOKENS,
|
|
445
|
-
'ai.usage.outputTokens',
|
|
446
|
-
'ai.usage.completionTokens',
|
|
447
|
-
]) ?? 0;
|
|
448
|
-
if (inputTokens === undefined && outputTokens === 0) {
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
const providerAnthropicUsage = readProviderAnthropicUsage(attributes);
|
|
452
|
-
const inputDetails = attributes[GEN_AI_USAGE_INPUT_TOKEN_DETAILS];
|
|
453
|
-
const cacheReadTokens = firstNumberAttribute(attributes, [
|
|
463
|
+
function readCacheReadTokens(attributes, providerAnthropicUsage, inputDetails) {
|
|
464
|
+
return (firstNumberAttribute(attributes, [
|
|
454
465
|
'ai.usage.inputTokenDetails.cacheReadTokens',
|
|
455
466
|
'ai.usage.cachedInputTokens',
|
|
456
467
|
'ai.usage.cacheReadInputTokens',
|
|
@@ -462,8 +473,10 @@ function buildLangSmithUsageMetadata(attributes) {
|
|
|
462
473
|
'cache_read_input_tokens',
|
|
463
474
|
'cached_tokens',
|
|
464
475
|
]) ??
|
|
465
|
-
0;
|
|
466
|
-
|
|
476
|
+
0);
|
|
477
|
+
}
|
|
478
|
+
function readCacheCreationTokens(attributes, providerAnthropicUsage, inputDetails) {
|
|
479
|
+
return (firstNumberAttribute(attributes, [
|
|
467
480
|
'ai.usage.inputTokenDetails.cacheCreationTokens',
|
|
468
481
|
'ai.usage.cacheCreationInputTokens',
|
|
469
482
|
'ai.usage.inputTokenDetails.cacheWriteTokens',
|
|
@@ -481,7 +494,26 @@ function buildLangSmithUsageMetadata(attributes) {
|
|
|
481
494
|
'cache_write_tokens',
|
|
482
495
|
'cache_write_input_tokens',
|
|
483
496
|
]) ??
|
|
484
|
-
0;
|
|
497
|
+
0);
|
|
498
|
+
}
|
|
499
|
+
function buildLangSmithUsageMetadata(attributes) {
|
|
500
|
+
const inputTokens = firstNumberAttribute(attributes, [
|
|
501
|
+
GEN_AI_USAGE_INPUT_TOKENS,
|
|
502
|
+
'ai.usage.inputTokens',
|
|
503
|
+
'ai.usage.promptTokens',
|
|
504
|
+
]);
|
|
505
|
+
const outputTokens = firstNumberAttribute(attributes, [
|
|
506
|
+
GEN_AI_USAGE_OUTPUT_TOKENS,
|
|
507
|
+
'ai.usage.outputTokens',
|
|
508
|
+
'ai.usage.completionTokens',
|
|
509
|
+
]) ?? 0;
|
|
510
|
+
if (inputTokens === undefined && outputTokens === 0) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const providerAnthropicUsage = readProviderAnthropicUsage(attributes);
|
|
514
|
+
const inputDetails = attributes[GEN_AI_USAGE_INPUT_TOKEN_DETAILS];
|
|
515
|
+
const cacheReadTokens = readCacheReadTokens(attributes, providerAnthropicUsage, inputDetails);
|
|
516
|
+
const cacheCreationTokens = readCacheCreationTokens(attributes, providerAnthropicUsage, inputDetails);
|
|
485
517
|
const { totalInputTokens } = calculateInputTokenAccounting(inputTokens, cacheReadTokens, cacheCreationTokens);
|
|
486
518
|
const inputTokenDetails = {};
|
|
487
519
|
if (cacheReadTokens > 0) {
|
|
@@ -500,26 +532,8 @@ function buildLangSmithUsageMetadata(attributes) {
|
|
|
500
532
|
: {}),
|
|
501
533
|
};
|
|
502
534
|
}
|
|
503
|
-
function
|
|
504
|
-
const
|
|
505
|
-
if (!usageMetadata) {
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
const inputTokens = firstNumberAttribute(attributes, [
|
|
509
|
-
GEN_AI_USAGE_INPUT_TOKENS,
|
|
510
|
-
'ai.usage.inputTokens',
|
|
511
|
-
'ai.usage.promptTokens',
|
|
512
|
-
]);
|
|
513
|
-
const outputTokens = numberFromAttribute(usageMetadata.output_tokens) ?? 0;
|
|
514
|
-
const inputTokenDetails = (0, stream_helpers_1.isRecord)(usageMetadata.input_token_details)
|
|
515
|
-
? usageMetadata.input_token_details
|
|
516
|
-
: {};
|
|
517
|
-
const cacheReadTokens = numberFromAttribute(inputTokenDetails.cache_read) ?? 0;
|
|
518
|
-
const cacheCreationTokens = numberFromAttribute(inputTokenDetails.cache_creation) ??
|
|
519
|
-
numberFromAttribute(inputTokenDetails.ephemeral_5m_input_tokens) ??
|
|
520
|
-
0;
|
|
521
|
-
const totalInputTokens = numberFromAttribute(usageMetadata.input_tokens) ?? 0;
|
|
522
|
-
const { regularInputTokens } = calculateInputTokenAccounting(inputTokens, cacheReadTokens, cacheCreationTokens);
|
|
535
|
+
function applyLangSmithUsageAttributes(attributes, usageMetadata, tokens) {
|
|
536
|
+
const { inputTokens, totalInputTokens, outputTokens, regularInputTokens, cacheReadTokens, cacheCreationTokens, } = tokens;
|
|
523
537
|
attributes[GEN_AI_USAGE_INPUT_TOKENS] = totalInputTokens;
|
|
524
538
|
attributes[GEN_AI_USAGE_OUTPUT_TOKENS] = outputTokens;
|
|
525
539
|
attributes[GEN_AI_USAGE_TOTAL_TOKENS] = totalInputTokens + outputTokens;
|
|
@@ -544,6 +558,35 @@ function normalizeUsageForLangSmith(attributes) {
|
|
|
544
558
|
...(inputTokens !== undefined ? { original_input_tokens: inputTokens } : {}),
|
|
545
559
|
});
|
|
546
560
|
}
|
|
561
|
+
function normalizeUsageForLangSmith(attributes) {
|
|
562
|
+
const usageMetadata = buildLangSmithUsageMetadata(attributes);
|
|
563
|
+
if (!usageMetadata) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
const inputTokens = firstNumberAttribute(attributes, [
|
|
567
|
+
GEN_AI_USAGE_INPUT_TOKENS,
|
|
568
|
+
'ai.usage.inputTokens',
|
|
569
|
+
'ai.usage.promptTokens',
|
|
570
|
+
]);
|
|
571
|
+
const outputTokens = numberFromAttribute(usageMetadata.output_tokens) ?? 0;
|
|
572
|
+
const inputTokenDetails = (0, utils_1.isRecord)(usageMetadata.input_token_details)
|
|
573
|
+
? usageMetadata.input_token_details
|
|
574
|
+
: {};
|
|
575
|
+
const cacheReadTokens = numberFromAttribute(inputTokenDetails.cache_read) ?? 0;
|
|
576
|
+
const cacheCreationTokens = numberFromAttribute(inputTokenDetails.cache_creation) ??
|
|
577
|
+
numberFromAttribute(inputTokenDetails.ephemeral_5m_input_tokens) ??
|
|
578
|
+
0;
|
|
579
|
+
const totalInputTokens = numberFromAttribute(usageMetadata.input_tokens) ?? 0;
|
|
580
|
+
const { regularInputTokens } = calculateInputTokenAccounting(inputTokens, cacheReadTokens, cacheCreationTokens);
|
|
581
|
+
applyLangSmithUsageAttributes(attributes, usageMetadata, {
|
|
582
|
+
inputTokens,
|
|
583
|
+
totalInputTokens,
|
|
584
|
+
outputTokens,
|
|
585
|
+
regularInputTokens,
|
|
586
|
+
cacheReadTokens,
|
|
587
|
+
cacheCreationTokens,
|
|
588
|
+
});
|
|
589
|
+
}
|
|
547
590
|
function readStringAttribute(attributes, keys) {
|
|
548
591
|
for (const key of keys) {
|
|
549
592
|
const value = attributes[key];
|
|
@@ -580,7 +623,7 @@ function displayNameForNativeLlmSpan(attributes) {
|
|
|
580
623
|
}
|
|
581
624
|
function parseTelemetryObject(value) {
|
|
582
625
|
const parsed = typeof value === 'string' ? parseTelemetryJson(value) : value;
|
|
583
|
-
return (0,
|
|
626
|
+
return (0, utils_1.isRecord)(parsed) ? parsed : undefined;
|
|
584
627
|
}
|
|
585
628
|
function sanitizeToolActionForDisplay(action) {
|
|
586
629
|
const sanitized = action
|
|
@@ -693,7 +736,7 @@ function moveNonLlmUsageAttributes(attributes) {
|
|
|
693
736
|
}
|
|
694
737
|
}
|
|
695
738
|
function redactLangSmithTelemetrySpan(span) {
|
|
696
|
-
if (!(0,
|
|
739
|
+
if (!(0, utils_1.isRecord)(span) || !(0, utils_1.isRecord)(span.attributes)) {
|
|
697
740
|
return span;
|
|
698
741
|
}
|
|
699
742
|
const attributes = {};
|
|
@@ -734,7 +777,7 @@ function serializeTraceText(value) {
|
|
|
734
777
|
return Object.fromEntries(chunks.map((chunk, index) => [`part_${String(index + 1).padStart(2, '0')}`, chunk]));
|
|
735
778
|
}
|
|
736
779
|
function summarizeToolDescription(tool) {
|
|
737
|
-
if (!(0,
|
|
780
|
+
if (!(0, utils_1.isRecord)(tool)) {
|
|
738
781
|
return undefined;
|
|
739
782
|
}
|
|
740
783
|
return typeof tool.description === 'string' ? tool.description : undefined;
|
|
@@ -748,7 +791,6 @@ function classifyToolSource(name, toolRecord) {
|
|
|
748
791
|
}
|
|
749
792
|
if (name.startsWith('workspace_') ||
|
|
750
793
|
name === tool_ids_1.WORKSPACE_TOOL_IDS.WRITE_FILE ||
|
|
751
|
-
name === tool_ids_1.WORKSPACE_TOOL_IDS.SUBMIT_WORKFLOW ||
|
|
752
794
|
name === tool_ids_1.ORCHESTRATION_TOOL_IDS.APPLY_WORKFLOW_CREDENTIALS) {
|
|
753
795
|
return 'workspace';
|
|
754
796
|
}
|
|
@@ -764,7 +806,7 @@ function classifyToolCategory(name) {
|
|
|
764
806
|
return 'browser';
|
|
765
807
|
if (name.includes('data-table'))
|
|
766
808
|
return 'data-table';
|
|
767
|
-
if (name.includes('workflow')
|
|
809
|
+
if (name.includes('workflow')) {
|
|
768
810
|
return 'workflow';
|
|
769
811
|
}
|
|
770
812
|
if (name === tool_ids_1.DOMAIN_TOOL_IDS.NODES || name === 'materialize-node-type')
|
|
@@ -806,14 +848,14 @@ function classifyToolSideEffect(name) {
|
|
|
806
848
|
return 'read';
|
|
807
849
|
}
|
|
808
850
|
function getToolInputSchema(tool) {
|
|
809
|
-
if (!(0,
|
|
851
|
+
if (!(0, utils_1.isRecord)(tool)) {
|
|
810
852
|
return undefined;
|
|
811
853
|
}
|
|
812
854
|
const inputSchema = tool.inputSchema;
|
|
813
855
|
if (inputSchema === undefined) {
|
|
814
856
|
return undefined;
|
|
815
857
|
}
|
|
816
|
-
const toJSONSchema = (0,
|
|
858
|
+
const toJSONSchema = (0, utils_1.isRecord)(inputSchema) ? inputSchema.toJSONSchema : undefined;
|
|
817
859
|
if (typeof toJSONSchema === 'function' && toJSONSchema.length === 0) {
|
|
818
860
|
try {
|
|
819
861
|
const schema = Reflect.apply(toJSONSchema, inputSchema, []);
|
|
@@ -823,7 +865,7 @@ function getToolInputSchema(tool) {
|
|
|
823
865
|
return { type: 'zod', conversion: 'failed' };
|
|
824
866
|
}
|
|
825
867
|
}
|
|
826
|
-
if ((0,
|
|
868
|
+
if ((0, utils_1.isRecord)(inputSchema) && typeof inputSchema.safeParse === 'function') {
|
|
827
869
|
return { type: 'zod' };
|
|
828
870
|
}
|
|
829
871
|
return inputSchema;
|
|
@@ -833,9 +875,9 @@ function summarizeToolForManifest(name, tool) {
|
|
|
833
875
|
const redactedSchema = schema === undefined
|
|
834
876
|
? undefined
|
|
835
877
|
: redactTelemetryJsonValue(schema, undefined, 0, MAX_PROMPT_SCHEMA_TRACE_DEPTH);
|
|
836
|
-
const toolRecord = (0,
|
|
878
|
+
const toolRecord = (0, utils_1.isRecord)(tool) ? tool : {};
|
|
837
879
|
const description = summarizeToolDescription(tool);
|
|
838
|
-
const providerOptions = (0,
|
|
880
|
+
const providerOptions = (0, utils_1.isRecord)(toolRecord.providerOptions)
|
|
839
881
|
? redactTelemetryJsonValue(toolRecord.providerOptions)
|
|
840
882
|
: undefined;
|
|
841
883
|
return {
|
|
@@ -879,7 +921,7 @@ function summarizeToolSet(fieldPrefix, tools) {
|
|
|
879
921
|
};
|
|
880
922
|
}
|
|
881
923
|
function summarizeMemoryBinding(memory) {
|
|
882
|
-
if (!(0,
|
|
924
|
+
if (!(0, utils_1.isRecord)(memory)) {
|
|
883
925
|
return {};
|
|
884
926
|
}
|
|
885
927
|
return {
|
|
@@ -902,33 +944,32 @@ function summarizeRuntimeSkillRegistry(registry) {
|
|
|
902
944
|
...(categories.length > 0 ? { runtime_skill_categories: categories } : {}),
|
|
903
945
|
};
|
|
904
946
|
}
|
|
905
|
-
|
|
906
|
-
|
|
947
|
+
const NOT_SCALAR = Symbol('not-scalar');
|
|
948
|
+
function sanitizeTraceScalar(value) {
|
|
949
|
+
if (value === null || value === undefined)
|
|
907
950
|
return value;
|
|
908
|
-
|
|
909
|
-
if (typeof value === 'string') {
|
|
951
|
+
if (typeof value === 'string')
|
|
910
952
|
return truncateString(value);
|
|
911
|
-
|
|
912
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
953
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
913
954
|
return value;
|
|
914
|
-
|
|
915
|
-
if (typeof value === 'bigint') {
|
|
955
|
+
if (typeof value === 'bigint')
|
|
916
956
|
return value.toString();
|
|
917
|
-
|
|
918
|
-
if (typeof value === 'function') {
|
|
957
|
+
if (typeof value === 'function')
|
|
919
958
|
return `[function ${value.name || 'anonymous'}]`;
|
|
920
|
-
|
|
921
|
-
if (value instanceof Date) {
|
|
959
|
+
if (value instanceof Date)
|
|
922
960
|
return value.toISOString();
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
name: value.name,
|
|
927
|
-
message: truncateString(value.message),
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
if (value instanceof Uint8Array) {
|
|
961
|
+
if (value instanceof Error)
|
|
962
|
+
return { name: value.name, message: truncateString(value.message) };
|
|
963
|
+
if (value instanceof Uint8Array)
|
|
931
964
|
return `[binary ${value.byteLength} bytes]`;
|
|
965
|
+
if (typeof value === 'symbol')
|
|
966
|
+
return value.toString();
|
|
967
|
+
return NOT_SCALAR;
|
|
968
|
+
}
|
|
969
|
+
function sanitizeTraceValue(value, depth = 0) {
|
|
970
|
+
const scalar = sanitizeTraceScalar(value);
|
|
971
|
+
if (scalar !== NOT_SCALAR) {
|
|
972
|
+
return scalar;
|
|
932
973
|
}
|
|
933
974
|
if (Array.isArray(value)) {
|
|
934
975
|
if (depth >= MAX_TRACE_DEPTH) {
|
|
@@ -938,7 +979,7 @@ function sanitizeTraceValue(value, depth = 0) {
|
|
|
938
979
|
.slice(0, MAX_TRACE_ARRAY_ITEMS)
|
|
939
980
|
.map((entry) => sanitizeTraceValue(entry, depth + 1));
|
|
940
981
|
}
|
|
941
|
-
if ((0,
|
|
982
|
+
if ((0, utils_1.isRecord)(value)) {
|
|
942
983
|
if (depth >= MAX_TRACE_DEPTH) {
|
|
943
984
|
return `[object ${Object.keys(value).length} keys]`;
|
|
944
985
|
}
|
|
@@ -952,13 +993,10 @@ function sanitizeTraceValue(value, depth = 0) {
|
|
|
952
993
|
}
|
|
953
994
|
return sanitized;
|
|
954
995
|
}
|
|
955
|
-
if (typeof value === 'symbol') {
|
|
956
|
-
return value.toString();
|
|
957
|
-
}
|
|
958
996
|
return truncateString(Object.prototype.toString.call(value));
|
|
959
997
|
}
|
|
960
998
|
function sanitizeTracePayload(value) {
|
|
961
|
-
if ((0,
|
|
999
|
+
if ((0, utils_1.isRecord)(value)) {
|
|
962
1000
|
const sanitized = {};
|
|
963
1001
|
for (const [key, entryValue] of Object.entries(value)) {
|
|
964
1002
|
sanitized[key] = sanitizeTraceValue(entryValue);
|
|
@@ -974,13 +1012,13 @@ function serializeModelIdForTrace(modelId) {
|
|
|
974
1012
|
if (typeof modelId === 'string' && modelId.length > 0) {
|
|
975
1013
|
return truncateString(modelId);
|
|
976
1014
|
}
|
|
977
|
-
if ((0,
|
|
1015
|
+
if ((0, utils_1.isRecord)(modelId) && typeof modelId.id === 'string') {
|
|
978
1016
|
return truncateString(modelId.id);
|
|
979
1017
|
}
|
|
980
1018
|
return sanitizeTraceValue(modelId);
|
|
981
1019
|
}
|
|
982
1020
|
function mergeTraceInputs(baseInputs, inputs) {
|
|
983
|
-
const existingInputs = (0,
|
|
1021
|
+
const existingInputs = (0, utils_1.isRecord)(baseInputs) && !Array.isArray(baseInputs) ? { ...baseInputs } : {};
|
|
984
1022
|
return {
|
|
985
1023
|
...existingInputs,
|
|
986
1024
|
...(inputs ?? {}),
|