@crowdstrike/aidr-mcp-proxy 1.2.2 → 1.3.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/proxy.mjs +13 -3
- package/package.json +1 -1
package/dist/proxy.mjs
CHANGED
|
@@ -9,6 +9,12 @@ import { defineCommand, runMain } from "citty";
|
|
|
9
9
|
import { consola } from "consola";
|
|
10
10
|
|
|
11
11
|
//#region src/proxy.ts
|
|
12
|
+
function isTextContent(x) {
|
|
13
|
+
return x.type === "text";
|
|
14
|
+
}
|
|
15
|
+
function isImageContent(x) {
|
|
16
|
+
return x.type === "image";
|
|
17
|
+
}
|
|
12
18
|
runMain(defineCommand({
|
|
13
19
|
args: {},
|
|
14
20
|
async run({ args }) {
|
|
@@ -150,11 +156,15 @@ runMain(defineCommand({
|
|
|
150
156
|
}];
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
|
-
} else for (const contentItem of content.filter((c) => c
|
|
159
|
+
} else for (const contentItem of content.filter((c) => isTextContent(c) || isImageContent(c))) {
|
|
160
|
+
const content$1 = isTextContent(contentItem) ? contentItem.text : [{
|
|
161
|
+
type: "image_url",
|
|
162
|
+
image_url: { url: `data:${contentItem.mimeType};base64,${contentItem.data}` }
|
|
163
|
+
}];
|
|
154
164
|
const guardedOutput = await aiGuard.guardChatCompletions({
|
|
155
165
|
guard_input: { messages: [{
|
|
156
166
|
role: "tool",
|
|
157
|
-
content:
|
|
167
|
+
content: content$1
|
|
158
168
|
}] },
|
|
159
169
|
app_id: process.env.APP_ID,
|
|
160
170
|
event_type: "tool_output",
|
|
@@ -175,7 +185,7 @@ runMain(defineCommand({
|
|
|
175
185
|
isError: true
|
|
176
186
|
};
|
|
177
187
|
}
|
|
178
|
-
if (guardedOutput.result?.transformed) contentItem.text = (guardedOutput.result.guard_output?.messages)[0].content;
|
|
188
|
+
if (isTextContent(contentItem) && guardedOutput.result?.transformed) contentItem.text = (guardedOutput.result.guard_output?.messages)[0].content;
|
|
179
189
|
}
|
|
180
190
|
return response;
|
|
181
191
|
});
|