@mastra/datadog 1.2.1-alpha.2 → 1.2.1-alpha.3
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +43 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/datadog
|
|
2
2
|
|
|
3
|
+
## 1.2.1-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed Datadog LLM output tool calls so they render as structured tool call blocks. ([#16789](https://github.com/mastra-ai/mastra/pull/16789))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`27fd1b7`](https://github.com/mastra-ai/mastra/commit/27fd1b79ac62eb7694f92587eb7d1be05b59be01), [`a702009`](https://github.com/mastra-ai/mastra/commit/a702009d3cfaa745120f501e21c783ed4d6a3072), [`8534d79`](https://github.com/mastra-ai/mastra/commit/8534d791fa1cb70fe1c19e2604c4b63cc10dd051), [`c78f8cd`](https://github.com/mastra-ai/mastra/commit/c78f8cd6222a86e6c60ae5210b6929ad5221b6fb), [`e146aad`](https://github.com/mastra-ai/mastra/commit/e146aadbba66c410ba0e74bac4c50135495cb8dd), [`1a0ec78`](https://github.com/mastra-ai/mastra/commit/1a0ec789a26cae443744e9abbd62ed6ee676af39), [`d52b6fe`](https://github.com/mastra-ai/mastra/commit/d52b6fe1c56853eb38864baae0bbfa75cc739ccb)]:
|
|
10
|
+
- @mastra/core@1.36.0-alpha.10
|
|
11
|
+
|
|
3
12
|
## 1.2.1-alpha.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -113,7 +113,7 @@ function safeStringify(data) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
function isMessageArray(data) {
|
|
116
|
-
return Array.isArray(data) && data.every((m) => m?.role && m?.content !== void 0);
|
|
116
|
+
return Array.isArray(data) && data.every((m) => m?.role && (m?.content !== void 0 || Array.isArray(m.toolCalls)));
|
|
117
117
|
}
|
|
118
118
|
function isModelDataSpan(spanType) {
|
|
119
119
|
return spanType === observability$1.SpanType.MODEL_GENERATION || spanType === observability$1.SpanType.MODEL_STEP || spanType === observability$1.SpanType.MODEL_INFERENCE;
|
|
@@ -125,10 +125,39 @@ function toMessageContent(content) {
|
|
|
125
125
|
return typeof content === "string" ? content : safeStringify(content);
|
|
126
126
|
}
|
|
127
127
|
function toDatadogMessages(messages) {
|
|
128
|
-
return messages.map((m) =>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
return messages.map((m) => {
|
|
129
|
+
const message = {
|
|
130
|
+
role: m.role,
|
|
131
|
+
content: m.content == null ? "" : toMessageContent(m.content)
|
|
132
|
+
};
|
|
133
|
+
if (m.toolCalls) {
|
|
134
|
+
message.toolCalls = m.toolCalls;
|
|
135
|
+
}
|
|
136
|
+
return message;
|
|
137
|
+
}).filter((m) => !(m.role === "user" && m.content.trim().length === 0));
|
|
138
|
+
}
|
|
139
|
+
function parseToolArguments(args) {
|
|
140
|
+
if (args == null) return void 0;
|
|
141
|
+
if (typeof args === "string") {
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(args);
|
|
144
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
145
|
+
return parsed;
|
|
146
|
+
}
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
return { value: args };
|
|
150
|
+
}
|
|
151
|
+
if (typeof args === "object" && !Array.isArray(args)) return args;
|
|
152
|
+
return { value: args };
|
|
153
|
+
}
|
|
154
|
+
function toDatadogToolCalls(toolCalls) {
|
|
155
|
+
return toolCalls.map((c) => ({
|
|
156
|
+
name: c?.toolName ?? c?.name ?? c?.function?.name ?? "unknown",
|
|
157
|
+
arguments: parseToolArguments(c?.args ?? c?.input ?? c?.function?.arguments),
|
|
158
|
+
toolId: c?.toolCallId ?? c?.toolId ?? c?.id,
|
|
159
|
+
type: c?.type === "function" ? c.type : "function"
|
|
160
|
+
}));
|
|
132
161
|
}
|
|
133
162
|
function geminiContentToMessage(item) {
|
|
134
163
|
const text = item.parts.map((p) => {
|
|
@@ -176,16 +205,21 @@ function formatOutput(output, spanType) {
|
|
|
176
205
|
return [{ role: "assistant", content: output }];
|
|
177
206
|
}
|
|
178
207
|
if (output && typeof output === "object") {
|
|
208
|
+
if (Array.isArray(output.toolCalls) && output.toolCalls.length > 0) {
|
|
209
|
+
return [
|
|
210
|
+
{
|
|
211
|
+
role: "assistant",
|
|
212
|
+
content: typeof output.text === "string" ? output.text : "",
|
|
213
|
+
toolCalls: toDatadogToolCalls(output.toolCalls)
|
|
214
|
+
}
|
|
215
|
+
];
|
|
216
|
+
}
|
|
179
217
|
if (typeof output.text === "string" && output.text.length > 0) {
|
|
180
218
|
return [{ role: "assistant", content: output.text }];
|
|
181
219
|
}
|
|
182
220
|
if (output.object !== void 0) {
|
|
183
221
|
return [{ role: "assistant", content: safeStringify(output.object) }];
|
|
184
222
|
}
|
|
185
|
-
if (Array.isArray(output.toolCalls) && output.toolCalls.length > 0) {
|
|
186
|
-
const summary = output.toolCalls.map((c) => `[tool: ${c?.toolName ?? c?.name ?? "unknown"}]`).join("");
|
|
187
|
-
return [{ role: "assistant", content: summary }];
|
|
188
|
-
}
|
|
189
223
|
}
|
|
190
224
|
return [{ role: "assistant", content: safeStringify(output) }];
|
|
191
225
|
}
|