@sovara/sdk 0.0.0-stage → 0.9.1
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/LICENSE +202 -0
- package/README.md +36 -2
- package/dist/apiTypes.d.ts +5 -0
- package/dist/apiTypes.d.ts.map +1 -0
- package/dist/apiTypes.js +5 -0
- package/dist/apiTypes.js.map +1 -0
- package/dist/capture/requestEnvelope.d.ts +10 -0
- package/dist/capture/requestEnvelope.d.ts.map +1 -0
- package/dist/capture/requestEnvelope.js +79 -0
- package/dist/capture/requestEnvelope.js.map +1 -0
- package/dist/capture/responseEnvelope.d.ts +17 -0
- package/dist/capture/responseEnvelope.d.ts.map +1 -0
- package/dist/capture/responseEnvelope.js +72 -0
- package/dist/capture/responseEnvelope.js.map +1 -0
- package/dist/capture/sensitiveHeaders.d.ts +7 -0
- package/dist/capture/sensitiveHeaders.d.ts.map +1 -0
- package/dist/capture/sensitiveHeaders.js +41 -0
- package/dist/capture/sensitiveHeaders.js.map +1 -0
- package/dist/capture/sseUtils.d.ts +3 -0
- package/dist/capture/sseUtils.d.ts.map +1 -0
- package/dist/capture/sseUtils.js +69 -0
- package/dist/capture/sseUtils.js.map +1 -0
- package/dist/capture/streamCapture.d.ts +5 -0
- package/dist/capture/streamCapture.d.ts.map +1 -0
- package/dist/capture/streamCapture.js +19 -0
- package/dist/capture/streamCapture.js.map +1 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +66 -0
- package/dist/client.js.map +1 -0
- package/dist/codeVersion.d.ts +17 -0
- package/dist/codeVersion.d.ts.map +1 -0
- package/dist/codeVersion.js +107 -0
- package/dist/codeVersion.js.map +1 -0
- package/dist/compatibility.d.ts +26 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +130 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +37 -0
- package/dist/constants.js.map +1 -0
- package/dist/context.d.ts +55 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +380 -0
- package/dist/context.js.map +1 -0
- package/dist/endpointPatterns.json +90 -0
- package/dist/endpointWhitelist.d.ts +2 -0
- package/dist/endpointWhitelist.d.ts.map +1 -0
- package/dist/endpointWhitelist.js +11 -0
- package/dist/endpointWhitelist.js.map +1 -0
- package/dist/env.d.ts +7 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +11 -0
- package/dist/env.js.map +1 -0
- package/dist/failsafe.d.ts +5 -0
- package/dist/failsafe.d.ts.map +1 -0
- package/dist/failsafe.js +25 -0
- package/dist/failsafe.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcpPatch.d.ts +2 -0
- package/dist/mcpPatch.d.ts.map +1 -0
- package/dist/mcpPatch.js +202 -0
- package/dist/mcpPatch.js.map +1 -0
- package/dist/openaiAgentsPatch.d.ts +2 -0
- package/dist/openaiAgentsPatch.d.ts.map +1 -0
- package/dist/openaiAgentsPatch.js +112 -0
- package/dist/openaiAgentsPatch.js.map +1 -0
- package/dist/payload/editIoExcludePatterns.json +322 -0
- package/dist/payload/filterDict.d.ts +3 -0
- package/dist/payload/filterDict.d.ts.map +1 -0
- package/dist/payload/filterDict.js +26 -0
- package/dist/payload/filterDict.js.map +1 -0
- package/dist/payload/flatten.d.ts +6 -0
- package/dist/payload/flatten.d.ts.map +1 -0
- package/dist/payload/flatten.js +79 -0
- package/dist/payload/flatten.js.map +1 -0
- package/dist/payload/wrap.d.ts +10 -0
- package/dist/payload/wrap.d.ts.map +1 -0
- package/dist/payload/wrap.js +82 -0
- package/dist/payload/wrap.js.map +1 -0
- package/dist/platformSession.d.ts +3 -0
- package/dist/platformSession.d.ts.map +1 -0
- package/dist/platformSession.js +21 -0
- package/dist/platformSession.js.map +1 -0
- package/dist/runtimeClient.d.ts +117 -0
- package/dist/runtimeClient.d.ts.map +1 -0
- package/dist/runtimeClient.js +287 -0
- package/dist/runtimeClient.js.map +1 -0
- package/dist/serverLifecycle.d.ts +12 -0
- package/dist/serverLifecycle.d.ts.map +1 -0
- package/dist/serverLifecycle.js +77 -0
- package/dist/serverLifecycle.js.map +1 -0
- package/dist/toolTraceUtils.d.ts +38 -0
- package/dist/toolTraceUtils.d.ts.map +1 -0
- package/dist/toolTraceUtils.js +189 -0
- package/dist/toolTraceUtils.js.map +1 -0
- package/dist/trace.d.ts +13 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +133 -0
- package/dist/trace.js.map +1 -0
- package/dist/traceLogCapture.d.ts +18 -0
- package/dist/traceLogCapture.d.ts.map +1 -0
- package/dist/traceLogCapture.js +125 -0
- package/dist/traceLogCapture.js.map +1 -0
- package/dist/transport/awsSdkHttp2Patch.d.ts +2 -0
- package/dist/transport/awsSdkHttp2Patch.d.ts.map +1 -0
- package/dist/transport/awsSdkHttp2Patch.js +442 -0
- package/dist/transport/awsSdkHttp2Patch.js.map +1 -0
- package/dist/transport/fetchPatch.d.ts +3 -0
- package/dist/transport/fetchPatch.d.ts.map +1 -0
- package/dist/transport/fetchPatch.js +257 -0
- package/dist/transport/fetchPatch.js.map +1 -0
- package/dist/transport/nodeHttpPatch.d.ts +3 -0
- package/dist/transport/nodeHttpPatch.d.ts.map +1 -0
- package/dist/transport/nodeHttpPatch.js +532 -0
- package/dist/transport/nodeHttpPatch.js.map +1 -0
- package/dist/util/logger.d.ts +2 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +9 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/stableJson.d.ts +2 -0
- package/dist/util/stableJson.d.ts.map +1 -0
- package/dist/util/stableJson.js +22 -0
- package/dist/util/stableJson.js.map +1 -0
- package/dist/util/stackTrace.d.ts +2 -0
- package/dist/util/stackTrace.d.ts.map +1 -0
- package/dist/util/stackTrace.js +11 -0
- package/dist/util/stackTrace.js.map +1 -0
- package/package.json +70 -4
package/dist/mcpPatch.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { performance } from "node:perf_hooks";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { API_TYPE_MCP_CLIENT_SESSION_SEND_REQUEST } from "./apiTypes.js";
|
|
6
|
+
import { getCurrentTraceScope } from "./context.js";
|
|
7
|
+
import { wrapForStorage } from "./payload/wrap.js";
|
|
8
|
+
import { stableJsonStringify } from "./util/stableJson.js";
|
|
9
|
+
import { sanitizeStackTrace } from "./util/stackTrace.js";
|
|
10
|
+
import { warnOnce } from "./util/logger.js";
|
|
11
|
+
const MCP_API_TYPE = API_TYPE_MCP_CLIENT_SESSION_SEND_REQUEST;
|
|
12
|
+
const MCP_PATCHED_SYMBOL = Symbol.for("sovara.mcpCallToolPatched");
|
|
13
|
+
const MCP_PATCHING_SYMBOL = Symbol.for("sovara.mcpCallToolPatching");
|
|
14
|
+
const MCP_CLIENT_PROTOTYPE_PATCHED_SYMBOL = Symbol.for("sovara.mcpClientPrototypePatched");
|
|
15
|
+
const MCP_CLIENT_SPECIFIER = "@modelcontextprotocol/sdk/client/index.js";
|
|
16
|
+
const DEBUG_MCP_PATCH = process.env.SOVARA_DEBUG_MCP_PATCH === "1";
|
|
17
|
+
function isCallToolParams(value) {
|
|
18
|
+
if (!value || typeof value !== "object") {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return typeof value.name === "string";
|
|
22
|
+
}
|
|
23
|
+
function buildErrorPayload(error) {
|
|
24
|
+
return stableJsonStringify({
|
|
25
|
+
kind: "exception",
|
|
26
|
+
source: MCP_API_TYPE,
|
|
27
|
+
message: error instanceof Error ? error.message : String(error),
|
|
28
|
+
type: error instanceof Error ? error.name : "Error",
|
|
29
|
+
details: {},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function cjsPathToEsmPath(resolvedPath) {
|
|
33
|
+
const marker = `${path.sep}dist${path.sep}cjs${path.sep}`;
|
|
34
|
+
const replacement = `${path.sep}dist${path.sep}esm${path.sep}`;
|
|
35
|
+
if (resolvedPath.includes(marker)) {
|
|
36
|
+
return resolvedPath.replace(marker, replacement);
|
|
37
|
+
}
|
|
38
|
+
return resolvedPath;
|
|
39
|
+
}
|
|
40
|
+
function buildModuleCandidateSpecifiers() {
|
|
41
|
+
const candidates = new Set();
|
|
42
|
+
try {
|
|
43
|
+
candidates.add(import.meta.resolve(MCP_CLIENT_SPECIFIER));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// ignore
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const cwdEntry = path.join(process.cwd(), "__sovara_mcp_patch__.js");
|
|
50
|
+
const resolver = createRequire(cwdEntry);
|
|
51
|
+
const resolvedCjsPath = resolver.resolve(MCP_CLIENT_SPECIFIER);
|
|
52
|
+
candidates.add(pathToFileURL(resolvedCjsPath).href);
|
|
53
|
+
candidates.add(pathToFileURL(cjsPathToEsmPath(resolvedCjsPath)).href);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// ignore
|
|
57
|
+
}
|
|
58
|
+
candidates.add(MCP_CLIENT_SPECIFIER);
|
|
59
|
+
const out = Array.from(candidates);
|
|
60
|
+
if (DEBUG_MCP_PATCH) {
|
|
61
|
+
console.error("[sovara:mcp] candidate module specifier count:", out.length);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
function patchClientPrototype(clientPrototype) {
|
|
66
|
+
if (!clientPrototype ||
|
|
67
|
+
clientPrototype[MCP_CLIENT_PROTOTYPE_PATCHED_SYMBOL] ||
|
|
68
|
+
typeof clientPrototype.callTool !== "function") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const originalCallTool = clientPrototype.callTool;
|
|
72
|
+
const patchedCallTool = async function patchedCallTool(...args) {
|
|
73
|
+
const scope = getCurrentTraceScope();
|
|
74
|
+
const params = args[0];
|
|
75
|
+
if (!scope ||
|
|
76
|
+
!isCallToolParams(params) ||
|
|
77
|
+
typeof scope.client.prepareCall !== "function" ||
|
|
78
|
+
typeof scope.client.recordOutput !== "function" ||
|
|
79
|
+
typeof scope.client.recordException !== "function") {
|
|
80
|
+
return originalCallTool.apply(this, args);
|
|
81
|
+
}
|
|
82
|
+
const stackTrace = sanitizeStackTrace(new Error().stack);
|
|
83
|
+
const wrappedInput = wrapForStorage({
|
|
84
|
+
root: {
|
|
85
|
+
method: "tools/call",
|
|
86
|
+
params,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
const inputJson = stableJsonStringify(wrappedInput);
|
|
90
|
+
const startedAt = performance.now();
|
|
91
|
+
let preparedCall = null;
|
|
92
|
+
try {
|
|
93
|
+
const prepared = await scope.client.prepareCall({
|
|
94
|
+
credentials: scope.credentials,
|
|
95
|
+
turnId: scope.turnId,
|
|
96
|
+
inputJson,
|
|
97
|
+
apiType: MCP_API_TYPE,
|
|
98
|
+
stackTrace,
|
|
99
|
+
promptBearingSuffixJson: "[]",
|
|
100
|
+
prepareRuntimeLessons: true,
|
|
101
|
+
lessonScopePaths: scope.lessonScopePaths,
|
|
102
|
+
});
|
|
103
|
+
preparedCall = {
|
|
104
|
+
stepUuid: prepared.stepUuid,
|
|
105
|
+
stepKind: prepared.stepKind ?? null,
|
|
106
|
+
preparedInputJson: prepared.preparedInputJson ?? inputJson,
|
|
107
|
+
suffixKeysJson: prepared.suffixKeysJson ?? "[]",
|
|
108
|
+
promptBearingSuffixJson: prepared.promptBearingSuffixJson ?? "[]",
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
warnOnce("mcp-patch-prepare", "[sovara] Failed to prepare MCP call.");
|
|
113
|
+
return originalCallTool.apply(this, args);
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const result = await originalCallTool.apply(this, args);
|
|
117
|
+
const outputJson = stableJsonStringify(wrapForStorage(result));
|
|
118
|
+
await scope.client.recordOutput({
|
|
119
|
+
credentials: scope.credentials,
|
|
120
|
+
turnId: scope.turnId,
|
|
121
|
+
stepUuid: preparedCall.stepUuid,
|
|
122
|
+
apiType: MCP_API_TYPE,
|
|
123
|
+
inputJson: preparedCall.preparedInputJson,
|
|
124
|
+
outputJson,
|
|
125
|
+
latencySeconds: Math.max(0, (performance.now() - startedAt) / 1000),
|
|
126
|
+
stackTrace,
|
|
127
|
+
stepKind: preparedCall.stepKind,
|
|
128
|
+
suffixKeysJson: preparedCall.suffixKeysJson,
|
|
129
|
+
promptBearingSuffixJson: preparedCall.promptBearingSuffixJson,
|
|
130
|
+
});
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
await scope.client
|
|
135
|
+
.recordException({
|
|
136
|
+
credentials: scope.credentials,
|
|
137
|
+
turnId: scope.turnId,
|
|
138
|
+
stepUuid: preparedCall.stepUuid,
|
|
139
|
+
apiType: MCP_API_TYPE,
|
|
140
|
+
inputJson: preparedCall.preparedInputJson,
|
|
141
|
+
errorJson: buildErrorPayload(error),
|
|
142
|
+
latencySeconds: Math.max(0, (performance.now() - startedAt) / 1000),
|
|
143
|
+
stackTrace,
|
|
144
|
+
stepKind: preparedCall.stepKind,
|
|
145
|
+
suffixKeysJson: preparedCall.suffixKeysJson,
|
|
146
|
+
promptBearingSuffixJson: preparedCall.promptBearingSuffixJson,
|
|
147
|
+
clearOutput: true,
|
|
148
|
+
})
|
|
149
|
+
.catch(() => {
|
|
150
|
+
warnOnce("mcp-patch-record-exception", "[sovara] Failed to finalize MCP exception.");
|
|
151
|
+
});
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
clientPrototype.callTool = patchedCallTool;
|
|
156
|
+
clientPrototype[MCP_CLIENT_PROTOTYPE_PATCHED_SYMBOL] = true;
|
|
157
|
+
if (DEBUG_MCP_PATCH) {
|
|
158
|
+
console.error("[sovara:mcp] patched MCP Client.prototype.callTool");
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
export async function ensureMcpPatchInstalled() {
|
|
163
|
+
const globalObject = globalThis;
|
|
164
|
+
if (globalObject[MCP_PATCHED_SYMBOL]) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (globalObject[MCP_PATCHING_SYMBOL]) {
|
|
168
|
+
return globalObject[MCP_PATCHING_SYMBOL];
|
|
169
|
+
}
|
|
170
|
+
globalObject[MCP_PATCHING_SYMBOL] = (async () => {
|
|
171
|
+
let installedAny = false;
|
|
172
|
+
const candidates = buildModuleCandidateSpecifiers();
|
|
173
|
+
for (const specifier of candidates) {
|
|
174
|
+
try {
|
|
175
|
+
const mod = (await import(specifier));
|
|
176
|
+
const ClientCtor = mod?.Client;
|
|
177
|
+
if (patchClientPrototype(ClientCtor?.prototype)) {
|
|
178
|
+
installedAny = true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// keep trying other candidate module copies
|
|
183
|
+
if (DEBUG_MCP_PATCH) {
|
|
184
|
+
console.error("[sovara:mcp] failed to import candidate");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (installedAny) {
|
|
189
|
+
globalObject[MCP_PATCHED_SYMBOL] = true;
|
|
190
|
+
}
|
|
191
|
+
else if (DEBUG_MCP_PATCH) {
|
|
192
|
+
console.error("[sovara:mcp] no MCP client prototype was patched");
|
|
193
|
+
}
|
|
194
|
+
})();
|
|
195
|
+
try {
|
|
196
|
+
await globalObject[MCP_PATCHING_SYMBOL];
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
delete globalObject[MCP_PATCHING_SYMBOL];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=mcpPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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AAM,IAAI,eAAe,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACpE,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,IAAI,CAAC;QACH,MAAM,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAC1C,CAAC;YAAS,CAAC;QACT,OAAO,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openaiAgentsPatch.d.ts","sourceRoot":"","sources":["../src/openaiAgentsPatch.ts"],"names":[],"mappings":"AAwJA,wBAAgB,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC,CAmBhE"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { API_TYPE_OPENAI_AGENTS_FUNCTION_TOOL_RUN } from "./apiTypes.js";
|
|
3
|
+
import { getCurrentTraceScope } from "./context.js";
|
|
4
|
+
import { buildToolErrorOutput, buildToolSuccessOutput, prepareToolTrace, recordPreparedToolOutput, } from "./toolTraceUtils.js";
|
|
5
|
+
import { warnOnce } from "./util/logger.js";
|
|
6
|
+
const AGENT_PATCHED_SYMBOL = Symbol.for("sovara.openAIAgentsAgentPatched");
|
|
7
|
+
const TOOL_PATCHED_SYMBOL = Symbol.for("sovara.openAIAgentsFunctionToolPatched");
|
|
8
|
+
let installPromise;
|
|
9
|
+
function parseToolInput(input) {
|
|
10
|
+
if (!input) {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(input);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return input;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function preparedToolInput(preparedRawInput, fallback) {
|
|
21
|
+
if (!preparedRawInput || typeof preparedRawInput !== "object" || Array.isArray(preparedRawInput)) {
|
|
22
|
+
return fallback;
|
|
23
|
+
}
|
|
24
|
+
const input = preparedRawInput.tool_input;
|
|
25
|
+
return input === undefined ? fallback : input;
|
|
26
|
+
}
|
|
27
|
+
function patchFunctionTool(tool) {
|
|
28
|
+
if (!tool ||
|
|
29
|
+
typeof tool !== "object" ||
|
|
30
|
+
tool.type !== "function" ||
|
|
31
|
+
typeof tool.invoke !== "function") {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const functionTool = tool;
|
|
35
|
+
if (functionTool[TOOL_PATCHED_SYMBOL]) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const originalInvoke = functionTool.invoke;
|
|
39
|
+
functionTool.invoke = async function sovaraPatchedFunctionTool(runContext, input, details) {
|
|
40
|
+
if (!getCurrentTraceScope()) {
|
|
41
|
+
return originalInvoke.call(this, runContext, input, details);
|
|
42
|
+
}
|
|
43
|
+
const toolCallId = details?.toolCall?.callId || randomUUID();
|
|
44
|
+
const toolInput = parseToolInput(input);
|
|
45
|
+
let prepared;
|
|
46
|
+
try {
|
|
47
|
+
prepared = await prepareToolTrace({
|
|
48
|
+
toolName: functionTool.name,
|
|
49
|
+
toolInput,
|
|
50
|
+
toolCallId,
|
|
51
|
+
apiType: API_TYPE_OPENAI_AGENTS_FUNCTION_TOOL_RUN,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
warnOnce("openai-agents-tool-prepare", "[sovara] Failed to prepare OpenAI Agents tool call.");
|
|
56
|
+
return originalInvoke.call(this, runContext, input, details);
|
|
57
|
+
}
|
|
58
|
+
const executedToolInput = preparedToolInput(prepared.preparedCall.preparedRawInput, toolInput);
|
|
59
|
+
const executedInput = JSON.stringify(executedToolInput);
|
|
60
|
+
if (details?.toolCall) {
|
|
61
|
+
details.toolCall.arguments = executedInput;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const result = await originalInvoke.call(this, runContext, executedInput, details);
|
|
65
|
+
await recordPreparedToolOutput(prepared, buildToolSuccessOutput({ toolName: functionTool.name, toolCallId, result }), API_TYPE_OPENAI_AGENTS_FUNCTION_TOOL_RUN).catch(() => {
|
|
66
|
+
warnOnce("openai-agents-tool-output", "[sovara] Failed to record OpenAI Agents tool output.");
|
|
67
|
+
});
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
await recordPreparedToolOutput(prepared, buildToolErrorOutput({ toolName: functionTool.name, toolCallId, error }), API_TYPE_OPENAI_AGENTS_FUNCTION_TOOL_RUN).catch(() => {
|
|
72
|
+
warnOnce("openai-agents-tool-error", "[sovara] Failed to record OpenAI Agents tool error.");
|
|
73
|
+
});
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperty(functionTool, TOOL_PATCHED_SYMBOL, { value: true });
|
|
78
|
+
}
|
|
79
|
+
function patchAgentConstructor(AgentClass) {
|
|
80
|
+
const prototype = AgentClass.prototype;
|
|
81
|
+
if (prototype[AGENT_PATCHED_SYMBOL]) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const originalGetAllTools = prototype.getAllTools;
|
|
85
|
+
if (typeof originalGetAllTools !== "function") {
|
|
86
|
+
throw new TypeError("OpenAI Agents Agent.getAllTools() is unavailable.");
|
|
87
|
+
}
|
|
88
|
+
prototype.getAllTools = async function sovaraPatchedGetAllTools(runContext) {
|
|
89
|
+
for (const tool of this.tools) {
|
|
90
|
+
patchFunctionTool(tool);
|
|
91
|
+
}
|
|
92
|
+
return originalGetAllTools.call(this, runContext);
|
|
93
|
+
};
|
|
94
|
+
Object.defineProperty(prototype, AGENT_PATCHED_SYMBOL, { value: true });
|
|
95
|
+
}
|
|
96
|
+
export function ensureOpenAIAgentsPatchInstalled() {
|
|
97
|
+
installPromise ??= import("@openai/agents")
|
|
98
|
+
.then((module) => {
|
|
99
|
+
patchAgentConstructor(module.Agent);
|
|
100
|
+
})
|
|
101
|
+
.catch((error) => {
|
|
102
|
+
const code = error && typeof error === "object"
|
|
103
|
+
? error.code
|
|
104
|
+
: undefined;
|
|
105
|
+
if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
warnOnce("openai-agents-patch", "[sovara] Failed to install OpenAI Agents tool patch.");
|
|
109
|
+
});
|
|
110
|
+
return installPromise;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=openaiAgentsPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openaiAgentsPatch.js","sourceRoot":"","sources":["../src/openaiAgentsPatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,wCAAwC,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAmBjF,IAAI,cAAyC,CAAC;AAE9C,SAAS,cAAc,CAAC,KAAa;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAY,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,gBAAyB,EAAE,QAAiB;IACrE,IAAI,CAAC,gBAAgB,IAAI,OAAO,gBAAgB,KAAK,QAA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;IACL,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"pattern": "^_.*"
|
|
4
|
+
},
|
|
5
|
+
{
|
|
6
|
+
"pattern": "^sse(\\.|$)"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"pattern": "^ndjson(\\.|$)"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"pattern": "(^|.*\\.)[^.]*encrypted[^.]*($|\\.)",
|
|
13
|
+
"flags": "i"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"pattern": "^url$"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"pattern": "(^|.*\\.)(?:urls)(?:\\.|$)"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"pattern": "(^|.*\\.)(?:[^.]+_url|[^.]+Url)$"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"pattern": "^max_tokens$"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"pattern": "^stream$"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"pattern": "^temperature$"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"pattern": "^metadata\\.user_id$"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"pattern": "^thinking(\\.|$)"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"pattern": "^context_management(\\.|$)"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"pattern": "^output_config\\.(?!effort$).+"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"pattern": "^body\\.metadata\\.user_id$"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"pattern": "^body\\.thinking(\\.|$)"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"pattern": "^body\\.context_management(\\.|$)"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"pattern": "^body\\.output_config\\.(?!effort$).+"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"pattern": "^body\\.attribution(\\.|$)"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"pattern": "^body\\.(?:requestPriority|bypassCaching|traceContext|sessionId)$"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"pattern": "^body\\.request\\.type$"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"pattern": "^body\\.request\\.gptChat\\.(?:reasoningEffort|temperature|top_p|n|stop|max_tokens|presence_penalty|frequency_penalty|logit_bias|seed|response_format|tool_choice)$"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"pattern": "^body\\.request\\.generic\\.(?!prompt$).+"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"pattern": "^body\\.stream$"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"pattern": "^body\\.contents\\.\\d+\\.parts\\.\\d+\\.thoughtSignature$"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"pattern": "^body\\.messages\\.\\d+\\.content\\.\\d+\\.signature$"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"pattern": "^body\\.inferenceConfig\\.(maxTokens|temperature)$"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"pattern": "^content\\.id$"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"pattern": "^content\\.type$"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"pattern": "^content\\.object$"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"pattern": "^content\\.created(_at)?$"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"pattern": "^content\\.completed_at$"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"pattern": "^content\\.model$"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"pattern": "^content\\.modelVersion$"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"pattern": "^content\\.status$"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"pattern": "^content\\.background$"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"pattern": "^content\\.context(\\.|$)"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"pattern": "^content\\.error$"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"pattern": "^content\\.instructions$"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"pattern": "^content\\.metadata"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"pattern": "^content\\.moderation$"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"pattern": "^content\\.request_id$"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"pattern": "^content\\.usage"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"pattern": "^content\\.service_tier$"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"pattern": "^content\\.system_fingerprint$"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"pattern": "^content\\.stop_sequence$"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"pattern": "^content\\.billing"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"pattern": "^content\\.max_output_tokens$"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"pattern": "^content\\.max_tool_calls$"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"pattern": "^content\\.createTime$"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"pattern": "^content\\.frequency_penalty$"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"pattern": "^content\\.incomplete_details(\\.|$)"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"pattern": "^content\\.parallel_tool_calls$"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"pattern": "^content\\.presence_penalty$"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"pattern": "^content\\.previous_response_id$"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"pattern": "^content\\.prompt_cache"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"pattern": "^content\\.reasoning\\.(effort|summary)$"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"pattern": "^content\\.safety_identifier$"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"pattern": "^content\\.signature$"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"pattern": "^content\\.store$"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"pattern": "^content\\.temperature$"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"pattern": "^content\\.text\\.(format\\.type|verbosity)$"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"pattern": "^content\\.tool_choice$"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"pattern": "^content\\.tools(\\.|$)"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"pattern": "^content\\.top_(logprobs|p)$"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"pattern": "^content\\.truncation$"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"pattern": "^content\\.user$"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"pattern": "^content\\.responseId$"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"pattern": "^content\\.metrics(\\.|$)"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"pattern": "^content\\.stopReason$"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"pattern": "^content\\.\\d+\\.signature$"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"pattern": "^content\\.content\\.\\d+\\.(type|id|signature)$"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"pattern": "^content\\.content\\.\\d+\\.content\\.\\d+\\.type$"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"pattern": "^content\\.choices\\.\\d+\\.index$"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"pattern": "^content\\.choices\\.\\d+\\.finish_reason$"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"pattern": "^content\\.choices\\.\\d+\\.message\\.(refusal|annotations|reasoning)$"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"pattern": "^content\\.choices\\.\\d+\\.(logprobs|seed)$"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"pattern": "^content\\.gptChat\\.(?:id|object|created|model)$"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"pattern": "^content\\.[^.]+\\.(?:usage|usageMetadata)"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"pattern": "^content\\.gptChat\\.choices\\.\\d+\\.(?:index|finish_reason)$"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"pattern": "^content\\.output\\.\\d+\\.(id|type|status)$"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"pattern": "^content\\.output\\.\\d+\\.content\\.\\d+\\.(type|annotations|logprobs)$"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"pattern": "^content\\.candidates\\.\\d+\\.avgLogprobs$"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"pattern": "^content\\.candidates\\.\\d+\\.(finishReason|index)$"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"pattern": "^content\\.candidates\\.\\d+\\.content\\.parts\\.\\d+\\.thoughtSignature$"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"pattern": "^content\\.usageMetadata"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"pattern": "^tools\\.\\d+\\.parameters\\.(additionalProperties|properties|required|type)$"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"pattern": "^tools\\.\\d+\\.strict$"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"pattern": "^content\\.done$"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"pattern": "^content\\.done_reason$"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"pattern": "^content\\.eval_count$"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"pattern": "^content\\.eval_duration$"
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"pattern": "^content\\.load_duration$"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"pattern": "^content\\.prompt_eval_count$"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"pattern": "^content\\.prompt_eval_duration$"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"pattern": "^content\\.total_duration$"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"pattern": "^headers(\\.|$)",
|
|
293
|
+
"flags": "i"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"pattern": "^client_message(_type)?(\\.|$)"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"pattern": "^content\\.output_transcription_segments(\\.|$)"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"pattern": "^protocol$"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"pattern": "^server_messages(\\.|$)"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"pattern": "^setup(\\.|$)"
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"pattern": "^uri$"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"pattern": "^request_headers(\\.|$)"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"pattern": "^(method|path|pool_(host|port|scheme))$"
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
"pattern": "^(reason|reason_phrase|request_url|status|status_code|version|version_string)$"
|
|
321
|
+
}
|
|
322
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterDict.d.ts","sourceRoot":"","sources":["../../src/payload/filterDict.ts"],"names":[],"mappings":"AAiBA,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBlE"}
|