@posthog/ai 8.22.0 → 8.22.2
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/adk/index.cjs +76 -28
- package/dist/adk/index.cjs.map +1 -1
- package/dist/adk/index.mjs +76 -28
- package/dist/adk/index.mjs.map +1 -1
- package/dist/anthropic/index.cjs +77 -29
- package/dist/anthropic/index.cjs.map +1 -1
- package/dist/anthropic/index.mjs +77 -29
- package/dist/anthropic/index.mjs.map +1 -1
- package/dist/claude-agent-sdk/index.cjs +76 -28
- package/dist/claude-agent-sdk/index.cjs.map +1 -1
- package/dist/claude-agent-sdk/index.mjs +76 -28
- package/dist/claude-agent-sdk/index.mjs.map +1 -1
- package/dist/gemini/index.cjs +77 -29
- package/dist/gemini/index.cjs.map +1 -1
- package/dist/gemini/index.mjs +77 -29
- package/dist/gemini/index.mjs.map +1 -1
- package/dist/genkit/index.cjs +84 -41
- package/dist/genkit/index.cjs.map +1 -1
- package/dist/genkit/index.mjs +84 -41
- package/dist/genkit/index.mjs.map +1 -1
- package/dist/index.cjs +77 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +77 -29
- package/dist/index.mjs.map +1 -1
- package/dist/langchain/index.cjs +76 -28
- package/dist/langchain/index.cjs.map +1 -1
- package/dist/langchain/index.mjs +77 -29
- package/dist/langchain/index.mjs.map +1 -1
- package/dist/langchain/middleware/index.cjs +76 -28
- package/dist/langchain/middleware/index.cjs.map +1 -1
- package/dist/langchain/middleware/index.mjs +77 -29
- package/dist/langchain/middleware/index.mjs.map +1 -1
- package/dist/openai/index.cjs +144 -75
- package/dist/openai/index.cjs.map +1 -1
- package/dist/openai/index.mjs +144 -75
- package/dist/openai/index.mjs.map +1 -1
- package/dist/openai-agents/index.cjs +26 -1
- package/dist/openai-agents/index.cjs.map +1 -1
- package/dist/openai-agents/index.mjs +26 -1
- package/dist/openai-agents/index.mjs.map +1 -1
- package/dist/otel/index.browser.cjs +51 -2
- package/dist/otel/index.browser.cjs.map +1 -1
- package/dist/otel/index.browser.mjs +51 -2
- package/dist/otel/index.browser.mjs.map +1 -1
- package/dist/otel/index.cjs +51 -2
- package/dist/otel/index.cjs.map +1 -1
- package/dist/otel/index.mjs +51 -2
- package/dist/otel/index.mjs.map +1 -1
- package/dist/vercel/index.cjs +77 -29
- package/dist/vercel/index.cjs.map +1 -1
- package/dist/vercel/index.mjs +77 -29
- package/dist/vercel/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/langchain/index.cjs
CHANGED
|
@@ -7,6 +7,81 @@ const isObject = (value) => {
|
|
|
7
7
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/mcpCredentials.ts
|
|
11
|
+
const MCP_CREDENTIAL_FIELDS = ["headers", "authorization"];
|
|
12
|
+
const MCP_TOOL_TYPES = /* @__PURE__ */ new Set(["mcp", "mcp_server"]);
|
|
13
|
+
const MCP_PROVIDER_TOOL_IDS = /* @__PURE__ */ new Set([
|
|
14
|
+
"openai.mcp",
|
|
15
|
+
"xai.mcp",
|
|
16
|
+
"google.mcp_server"
|
|
17
|
+
]);
|
|
18
|
+
const isMcpProviderTool = (tool) => (tool.type === "provider" || tool.type === "provider-defined") && typeof tool.id === "string" && MCP_PROVIDER_TOOL_IDS.has(tool.id);
|
|
19
|
+
const withoutMcpCredentials = (config) => {
|
|
20
|
+
const redacted = { ...config };
|
|
21
|
+
for (const field of MCP_CREDENTIAL_FIELDS) if (field in redacted) redacted[field] = "[REDACTED]";
|
|
22
|
+
return redacted;
|
|
23
|
+
};
|
|
24
|
+
const normalizeKey = (key) => key.toLowerCase().replace(/[-_]/g, "");
|
|
25
|
+
const isPlainObject = (value) => {
|
|
26
|
+
if (!isObject(value)) return false;
|
|
27
|
+
const prototype = Object.getPrototypeOf(value);
|
|
28
|
+
return prototype === Object.prototype || prototype === null;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Replaces the value of every key in `keys` (normalized) with `[REDACTED]`, through plain objects and arrays.
|
|
32
|
+
* Class instances, such as the MCP client inside an `mcpToTool()` tool, are returned as they are.
|
|
33
|
+
*/
|
|
34
|
+
function redactKeys(value, keys) {
|
|
35
|
+
if (Array.isArray(value)) return value.map((item) => redactKeys(item, keys));
|
|
36
|
+
if (!isPlainObject(value)) return value;
|
|
37
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, keys.has(normalizeKey(key)) ? "[REDACTED]" : redactKeys(item, keys)]));
|
|
38
|
+
}
|
|
39
|
+
const GEMINI_TOOL_FIELDS = new Set([
|
|
40
|
+
"codeExecution",
|
|
41
|
+
"computerUse",
|
|
42
|
+
"enterpriseWebSearch",
|
|
43
|
+
"exaAiSearch",
|
|
44
|
+
"fileSearch",
|
|
45
|
+
"functionDeclarations",
|
|
46
|
+
"googleMaps",
|
|
47
|
+
"googleSearch",
|
|
48
|
+
"googleSearchRetrieval",
|
|
49
|
+
"mcpServers",
|
|
50
|
+
"parallelAiSearch",
|
|
51
|
+
"retrieval",
|
|
52
|
+
"urlContext"
|
|
53
|
+
].map(normalizeKey));
|
|
54
|
+
const GEMINI_SCHEMA_FIELD = normalizeKey("functionDeclarations");
|
|
55
|
+
const GEMINI_CREDENTIAL_KEYS = new Set([
|
|
56
|
+
"apiAuth",
|
|
57
|
+
"authConfig",
|
|
58
|
+
"apiKey",
|
|
59
|
+
"headers"
|
|
60
|
+
].map(normalizeKey));
|
|
61
|
+
const isGeminiTool = (tool) => Object.keys(tool).map(normalizeKey).some((key) => key !== GEMINI_SCHEMA_FIELD && GEMINI_TOOL_FIELDS.has(key));
|
|
62
|
+
/**
|
|
63
|
+
* Masks the credential keys under every field of a `@google/genai` tool except its function declarations.
|
|
64
|
+
* A class-based tool, such as `mcpToTool(client)`, holds a live client with its auth headers, so only a stub is kept.
|
|
65
|
+
*/
|
|
66
|
+
function redactGeminiToolDefinition(tool) {
|
|
67
|
+
if (!isPlainObject(tool)) return isObject(tool) ? { type: "callable_tool" } : tool;
|
|
68
|
+
return Object.fromEntries(Object.entries(tool).map(([key, value]) => [key, normalizeKey(key) === GEMINI_SCHEMA_FIELD ? value : redactKeys((0, _posthog_core.toJsonSafeValue)(value), GEMINI_CREDENTIAL_KEYS)]));
|
|
69
|
+
}
|
|
70
|
+
/** Hides the credentials of a remote MCP or Gemini tool definition; everything else is kept as sent. */
|
|
71
|
+
function redactMcpToolDefinition(tool) {
|
|
72
|
+
if (!isObject(tool)) return tool;
|
|
73
|
+
if (typeof tool.type === "string" && MCP_TOOL_TYPES.has(tool.type)) return withoutMcpCredentials(tool);
|
|
74
|
+
if (isMcpProviderTool(tool) && isObject(tool.args)) return {
|
|
75
|
+
...tool,
|
|
76
|
+
args: withoutMcpCredentials(tool.args)
|
|
77
|
+
};
|
|
78
|
+
if (isPlainObject(tool) && isGeminiTool(tool)) return redactGeminiToolDefinition(tool);
|
|
79
|
+
return tool;
|
|
80
|
+
}
|
|
81
|
+
function redactMcpToolCredentials(tools) {
|
|
82
|
+
return Array.isArray(tools) ? tools.map(redactMcpToolDefinition) : tools;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
10
85
|
//#region src/captureAiEvent.ts
|
|
11
86
|
/** @internal */
|
|
12
87
|
function isFullAiCaptureEnabled(client) {
|
|
@@ -359,35 +434,8 @@ function sanitizeValues(obj) {
|
|
|
359
434
|
return jsonSafe;
|
|
360
435
|
}
|
|
361
436
|
//#endregion
|
|
362
|
-
//#region src/mcpCredentials.ts
|
|
363
|
-
const MCP_CREDENTIAL_FIELDS = ["headers", "authorization"];
|
|
364
|
-
const MCP_PROVIDER_TOOL_IDS = /* @__PURE__ */ new Set([
|
|
365
|
-
"openai.mcp",
|
|
366
|
-
"xai.mcp",
|
|
367
|
-
"google.mcp_server"
|
|
368
|
-
]);
|
|
369
|
-
const isMcpProviderTool = (tool) => (tool.type === "provider" || tool.type === "provider-defined") && typeof tool.id === "string" && MCP_PROVIDER_TOOL_IDS.has(tool.id);
|
|
370
|
-
const withoutMcpCredentials = (config) => {
|
|
371
|
-
const redacted = { ...config };
|
|
372
|
-
for (const field of MCP_CREDENTIAL_FIELDS) if (field in redacted) redacted[field] = "[REDACTED]";
|
|
373
|
-
return redacted;
|
|
374
|
-
};
|
|
375
|
-
/** Hides the credentials of a remote MCP tool definition; everything else is kept as sent. */
|
|
376
|
-
function redactMcpToolDefinition(tool) {
|
|
377
|
-
if (!isObject(tool)) return tool;
|
|
378
|
-
if (tool.type === "mcp") return withoutMcpCredentials(tool);
|
|
379
|
-
if (isMcpProviderTool(tool) && isObject(tool.args)) return {
|
|
380
|
-
...tool,
|
|
381
|
-
args: withoutMcpCredentials(tool.args)
|
|
382
|
-
};
|
|
383
|
-
return tool;
|
|
384
|
-
}
|
|
385
|
-
function redactMcpToolCredentials(tools) {
|
|
386
|
-
return Array.isArray(tools) ? tools.map(redactMcpToolDefinition) : tools;
|
|
387
|
-
}
|
|
388
|
-
//#endregion
|
|
389
437
|
//#region package.json
|
|
390
|
-
var version = "8.22.
|
|
438
|
+
var version = "8.22.2";
|
|
391
439
|
//#endregion
|
|
392
440
|
//#region src/serializeError.ts
|
|
393
441
|
const DEFAULT_MAX_DEPTH = 3;
|