@friskai/frisk-js 0.2.10 → 0.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/README.md +1 -1
- package/dist/adapters/langchain/frisk-tool-middleware.d.ts.map +1 -1
- package/dist/adapters/langchain/index.js +211 -159
- package/dist/adapters/langchain/index.js.map +15 -16
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts +3 -3
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts.map +1 -1
- package/dist/core/extensions.d.ts +30 -0
- package/dist/core/extensions.d.ts.map +1 -0
- package/dist/core/frisk-session.d.ts +7 -4
- package/dist/core/frisk-session.d.ts.map +1 -1
- package/dist/core/frisk.d.ts +14 -24
- package/dist/core/frisk.d.ts.map +1 -1
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/framework-adapter/base-framework-adapter.d.ts +3 -3
- package/dist/framework-adapter/base-framework-adapter.d.ts.map +1 -1
- package/dist/framework-adapter/framework-adapter.d.ts +3 -3
- package/dist/framework-adapter/framework-adapter.d.ts.map +1 -1
- package/dist/framework-adapter/index.d.ts +2 -2
- package/dist/framework-adapter/index.d.ts.map +1 -1
- package/dist/generated/sdk-meta.d.ts +1 -1
- package/dist/generated/sdk-meta.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +217 -171
- package/dist/index.js.map +12 -13
- package/dist/utils/redact.d.ts +5 -5
- package/dist/utils/redact.d.ts.map +1 -1
- package/package.json +3 -27
- package/dist/adapters/claude/claude-framework-adapter/claude-framework-adapter.d.ts +0 -99
- package/dist/adapters/claude/claude-framework-adapter/claude-framework-adapter.d.ts.map +0 -1
- package/dist/adapters/claude/claude-framework-adapter/get-claude-agent-sdk-version.d.ts +0 -2
- package/dist/adapters/claude/claude-framework-adapter/get-claude-agent-sdk-version.d.ts.map +0 -1
- package/dist/adapters/claude/claude-framework-adapter/wrap-tool-with-llm-reasoning.d.ts +0 -4
- package/dist/adapters/claude/claude-framework-adapter/wrap-tool-with-llm-reasoning.d.ts.map +0 -1
- package/dist/adapters/claude/frisk-claude-session.d.ts +0 -29
- package/dist/adapters/claude/frisk-claude-session.d.ts.map +0 -1
- package/dist/adapters/claude/frisk-claude.d.ts +0 -71
- package/dist/adapters/claude/frisk-claude.d.ts.map +0 -1
- package/dist/adapters/claude/index.d.ts +0 -3
- package/dist/adapters/claude/index.d.ts.map +0 -1
- package/dist/adapters/claude/index.js +0 -65732
- package/dist/adapters/claude/index.js.map +0 -449
- package/dist/adapters/claude/resolve-claude-tool-name.d.ts +0 -2
- package/dist/adapters/claude/resolve-claude-tool-name.d.ts.map +0 -1
- package/dist/native-bindings/index.d.ts +0 -23
- package/dist/native-bindings/index.d.ts.map +0 -1
- package/native/README.md +0 -55
- package/native/frisk-js.darwin-arm64.node +0 -0
- package/native/frisk-js.darwin-x64.node +0 -0
- package/native/frisk-js.linux-arm64-gnu.node +0 -0
- package/native/frisk-js.linux-arm64-musl.node +0 -0
- package/native/frisk-js.linux-x64-gnu.node +0 -0
- package/native/frisk-js.linux-x64-musl.node +0 -0
- package/native/frisk-js.win32-arm64-msvc.node +0 -0
- package/native/frisk-js.win32-x64-msvc.node +0 -0
- package/native/index.cjs +0 -580
- package/native/index.d.ts +0 -73
|
@@ -2542,7 +2542,7 @@ var require_call_credentials = __commonJS((exports) => {
|
|
|
2542
2542
|
if (isCurrentOauth2Client(googleCredentials)) {
|
|
2543
2543
|
getHeaders = googleCredentials.getRequestHeaders(options.service_url);
|
|
2544
2544
|
} else {
|
|
2545
|
-
getHeaders = new Promise((
|
|
2545
|
+
getHeaders = new Promise((resolve, reject) => {
|
|
2546
2546
|
googleCredentials.getRequestMetadata(options.service_url, (err, headers) => {
|
|
2547
2547
|
if (err) {
|
|
2548
2548
|
reject(err);
|
|
@@ -2552,7 +2552,7 @@ var require_call_credentials = __commonJS((exports) => {
|
|
|
2552
2552
|
reject(new Error("Headers not set by metadata plugin"));
|
|
2553
2553
|
return;
|
|
2554
2554
|
}
|
|
2555
|
-
|
|
2555
|
+
resolve(headers);
|
|
2556
2556
|
});
|
|
2557
2557
|
});
|
|
2558
2558
|
}
|
|
@@ -2607,10 +2607,10 @@ var require_call_credentials = __commonJS((exports) => {
|
|
|
2607
2607
|
this.metadataGenerator = metadataGenerator;
|
|
2608
2608
|
}
|
|
2609
2609
|
generateMetadata(options) {
|
|
2610
|
-
return new Promise((
|
|
2610
|
+
return new Promise((resolve, reject) => {
|
|
2611
2611
|
this.metadataGenerator(options, (err, metadata) => {
|
|
2612
2612
|
if (metadata !== undefined) {
|
|
2613
|
-
|
|
2613
|
+
resolve(metadata);
|
|
2614
2614
|
} else {
|
|
2615
2615
|
reject(err);
|
|
2616
2616
|
}
|
|
@@ -2932,14 +2932,14 @@ var require_channel_credentials = __commonJS((exports) => {
|
|
|
2932
2932
|
}
|
|
2933
2933
|
connect(socket) {
|
|
2934
2934
|
const tlsConnectOptions = Object.assign({ socket }, this.connectionOptions);
|
|
2935
|
-
return new Promise((
|
|
2935
|
+
return new Promise((resolve, reject) => {
|
|
2936
2936
|
const tlsSocket = (0, tls_1.connect)(tlsConnectOptions, () => {
|
|
2937
2937
|
var _a2;
|
|
2938
2938
|
if (((_a2 = this.connectionOptions.rejectUnauthorized) !== null && _a2 !== undefined ? _a2 : true) && !tlsSocket.authorized) {
|
|
2939
2939
|
reject(tlsSocket.authorizationError);
|
|
2940
2940
|
return;
|
|
2941
2941
|
}
|
|
2942
|
-
|
|
2942
|
+
resolve({
|
|
2943
2943
|
socket: tlsSocket,
|
|
2944
2944
|
secure: true
|
|
2945
2945
|
});
|
|
@@ -3059,8 +3059,8 @@ var require_channel_credentials = __commonJS((exports) => {
|
|
|
3059
3059
|
if (this.hasReceivedUpdates()) {
|
|
3060
3060
|
return Promise.resolve(this.getLatestSecureContext());
|
|
3061
3061
|
} else {
|
|
3062
|
-
return new Promise((
|
|
3063
|
-
this.secureContextWatchers.push(
|
|
3062
|
+
return new Promise((resolve) => {
|
|
3063
|
+
this.secureContextWatchers.push(resolve);
|
|
3064
3064
|
});
|
|
3065
3065
|
}
|
|
3066
3066
|
}
|
|
@@ -3093,7 +3093,7 @@ var require_channel_credentials = __commonJS((exports) => {
|
|
|
3093
3093
|
this.callCredentials = callCredentials;
|
|
3094
3094
|
}
|
|
3095
3095
|
connect(socket) {
|
|
3096
|
-
return new Promise((
|
|
3096
|
+
return new Promise((resolve, reject) => {
|
|
3097
3097
|
const secureContext = this.parent.getLatestSecureContext();
|
|
3098
3098
|
if (!secureContext) {
|
|
3099
3099
|
reject(new Error("Failed to load credentials"));
|
|
@@ -3118,7 +3118,7 @@ var require_channel_credentials = __commonJS((exports) => {
|
|
|
3118
3118
|
reject(tlsSocket.authorizationError);
|
|
3119
3119
|
return;
|
|
3120
3120
|
}
|
|
3121
|
-
|
|
3121
|
+
resolve({
|
|
3122
3122
|
socket: tlsSocket,
|
|
3123
3123
|
secure: true
|
|
3124
3124
|
});
|
|
@@ -6646,7 +6646,7 @@ var require_aspromise = __commonJS((exports, module) => {
|
|
|
6646
6646
|
var params = new Array(arguments.length - 1), offset = 0, index = 2, pending = true;
|
|
6647
6647
|
while (index < arguments.length)
|
|
6648
6648
|
params[offset++] = arguments[index++];
|
|
6649
|
-
return new Promise(function executor(
|
|
6649
|
+
return new Promise(function executor(resolve, reject) {
|
|
6650
6650
|
params[offset] = function callback(err) {
|
|
6651
6651
|
if (pending) {
|
|
6652
6652
|
pending = false;
|
|
@@ -6656,7 +6656,7 @@ var require_aspromise = __commonJS((exports, module) => {
|
|
|
6656
6656
|
var params2 = new Array(arguments.length - 1), offset2 = 0;
|
|
6657
6657
|
while (offset2 < params2.length)
|
|
6658
6658
|
params2[offset2++] = arguments[offset2];
|
|
6659
|
-
|
|
6659
|
+
resolve.apply(null, params2);
|
|
6660
6660
|
}
|
|
6661
6661
|
}
|
|
6662
6662
|
};
|
|
@@ -8044,7 +8044,7 @@ var require_path = __commonJS((exports) => {
|
|
|
8044
8044
|
}
|
|
8045
8045
|
return prefix + parts.join("/");
|
|
8046
8046
|
};
|
|
8047
|
-
path.resolve = function
|
|
8047
|
+
path.resolve = function resolve(originPath, includePath, alreadyNormalized) {
|
|
8048
8048
|
if (!alreadyNormalized)
|
|
8049
8049
|
includePath = normalize(includePath);
|
|
8050
8050
|
if (isAbsolute(includePath))
|
|
@@ -8357,7 +8357,7 @@ var require_mapfield = __commonJS((exports, module) => {
|
|
|
8357
8357
|
keepComments ? this.comment : undefined
|
|
8358
8358
|
]);
|
|
8359
8359
|
};
|
|
8360
|
-
MapField.prototype.resolve = function
|
|
8360
|
+
MapField.prototype.resolve = function resolve() {
|
|
8361
8361
|
if (this.resolved)
|
|
8362
8362
|
return this;
|
|
8363
8363
|
if (types.mapKey[this.keyType] === undefined)
|
|
@@ -8430,7 +8430,7 @@ var require_method = __commonJS((exports, module) => {
|
|
|
8430
8430
|
this.parsedOptions
|
|
8431
8431
|
]);
|
|
8432
8432
|
};
|
|
8433
|
-
Method.prototype.resolve = function
|
|
8433
|
+
Method.prototype.resolve = function resolve() {
|
|
8434
8434
|
if (this.resolved)
|
|
8435
8435
|
return this;
|
|
8436
8436
|
this.resolvedRequestType = this.parent.lookupType(this.requestType);
|
|
@@ -9830,7 +9830,7 @@ var require_field = __commonJS((exports, module) => {
|
|
|
9830
9830
|
keepComments ? this.comment : undefined
|
|
9831
9831
|
]);
|
|
9832
9832
|
};
|
|
9833
|
-
Field.prototype.resolve = function
|
|
9833
|
+
Field.prototype.resolve = function resolve() {
|
|
9834
9834
|
if (this.resolved)
|
|
9835
9835
|
return this;
|
|
9836
9836
|
if ((this.typeDefault = types.defaults[this.type]) === undefined) {
|
|
@@ -10084,7 +10084,7 @@ var require_object = __commonJS((exports, module) => {
|
|
|
10084
10084
|
this.parent = null;
|
|
10085
10085
|
this.resolved = false;
|
|
10086
10086
|
};
|
|
10087
|
-
ReflectionObject.prototype.resolve = function
|
|
10087
|
+
ReflectionObject.prototype.resolve = function resolve() {
|
|
10088
10088
|
if (this.resolved)
|
|
10089
10089
|
return this;
|
|
10090
10090
|
if (this.root instanceof Root)
|
|
@@ -15635,18 +15635,18 @@ var require_compression_filter = __commonJS((exports) => {
|
|
|
15635
15635
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
15636
15636
|
}
|
|
15637
15637
|
compressMessage(message) {
|
|
15638
|
-
return new Promise((
|
|
15638
|
+
return new Promise((resolve, reject) => {
|
|
15639
15639
|
zlib.deflate(message, (err, output) => {
|
|
15640
15640
|
if (err) {
|
|
15641
15641
|
reject(err);
|
|
15642
15642
|
} else {
|
|
15643
|
-
|
|
15643
|
+
resolve(output);
|
|
15644
15644
|
}
|
|
15645
15645
|
});
|
|
15646
15646
|
});
|
|
15647
15647
|
}
|
|
15648
15648
|
decompressMessage(message) {
|
|
15649
|
-
return new Promise((
|
|
15649
|
+
return new Promise((resolve, reject) => {
|
|
15650
15650
|
let totalLength = 0;
|
|
15651
15651
|
const messageParts = [];
|
|
15652
15652
|
const decompresser = zlib.createInflate();
|
|
@@ -15662,7 +15662,7 @@ var require_compression_filter = __commonJS((exports) => {
|
|
|
15662
15662
|
}
|
|
15663
15663
|
});
|
|
15664
15664
|
decompresser.on("end", () => {
|
|
15665
|
-
|
|
15665
|
+
resolve(Buffer.concat(messageParts));
|
|
15666
15666
|
});
|
|
15667
15667
|
decompresser.write(message);
|
|
15668
15668
|
decompresser.end();
|
|
@@ -15676,18 +15676,18 @@ var require_compression_filter = __commonJS((exports) => {
|
|
|
15676
15676
|
this.maxRecvMessageLength = maxRecvMessageLength;
|
|
15677
15677
|
}
|
|
15678
15678
|
compressMessage(message) {
|
|
15679
|
-
return new Promise((
|
|
15679
|
+
return new Promise((resolve, reject) => {
|
|
15680
15680
|
zlib.gzip(message, (err, output) => {
|
|
15681
15681
|
if (err) {
|
|
15682
15682
|
reject(err);
|
|
15683
15683
|
} else {
|
|
15684
|
-
|
|
15684
|
+
resolve(output);
|
|
15685
15685
|
}
|
|
15686
15686
|
});
|
|
15687
15687
|
});
|
|
15688
15688
|
}
|
|
15689
15689
|
decompressMessage(message) {
|
|
15690
|
-
return new Promise((
|
|
15690
|
+
return new Promise((resolve, reject) => {
|
|
15691
15691
|
let totalLength = 0;
|
|
15692
15692
|
const messageParts = [];
|
|
15693
15693
|
const decompresser = zlib.createGunzip();
|
|
@@ -15703,7 +15703,7 @@ var require_compression_filter = __commonJS((exports) => {
|
|
|
15703
15703
|
}
|
|
15704
15704
|
});
|
|
15705
15705
|
decompresser.on("end", () => {
|
|
15706
|
-
|
|
15706
|
+
resolve(Buffer.concat(messageParts));
|
|
15707
15707
|
});
|
|
15708
15708
|
decompresser.write(message);
|
|
15709
15709
|
decompresser.end();
|
|
@@ -16957,7 +16957,7 @@ var require_http_proxy = __commonJS((exports) => {
|
|
|
16957
16957
|
options.headers = headers;
|
|
16958
16958
|
const proxyAddressString = (0, subchannel_address_1.subchannelAddressToString)(address);
|
|
16959
16959
|
trace3("Using proxy " + proxyAddressString + " to connect to " + options.path);
|
|
16960
|
-
return new Promise((
|
|
16960
|
+
return new Promise((resolve, reject) => {
|
|
16961
16961
|
const request = http.request(options);
|
|
16962
16962
|
request.once("connect", (res, socket, head) => {
|
|
16963
16963
|
request.removeAllListeners();
|
|
@@ -16968,7 +16968,7 @@ var require_http_proxy = __commonJS((exports) => {
|
|
|
16968
16968
|
socket.unshift(head);
|
|
16969
16969
|
}
|
|
16970
16970
|
trace3("Successfully established a plaintext connection to " + options.path + " through proxy " + proxyAddressString);
|
|
16971
|
-
|
|
16971
|
+
resolve(socket);
|
|
16972
16972
|
} else {
|
|
16973
16973
|
(0, logging_1.log)(constants_1.LogVerbosity.ERROR, "Failed to connect to " + options.path + " through proxy " + proxyAddressString + " with status " + res.statusCode);
|
|
16974
16974
|
reject();
|
|
@@ -17840,7 +17840,7 @@ var require_transport = __commonJS((exports) => {
|
|
|
17840
17840
|
if (secureConnectResult.socket.closed) {
|
|
17841
17841
|
return Promise.reject("Connection closed before starting HTTP/2 handshake");
|
|
17842
17842
|
}
|
|
17843
|
-
return new Promise((
|
|
17843
|
+
return new Promise((resolve, reject) => {
|
|
17844
17844
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
17845
17845
|
let remoteName = null;
|
|
17846
17846
|
let realTarget = this.channelTarget;
|
|
@@ -17905,7 +17905,7 @@ var require_transport = __commonJS((exports) => {
|
|
|
17905
17905
|
session.removeAllListeners();
|
|
17906
17906
|
secureConnectResult.socket.removeListener("close", closeHandler);
|
|
17907
17907
|
secureConnectResult.socket.removeListener("error", errorHandler);
|
|
17908
|
-
|
|
17908
|
+
resolve(new Http2Transport(session, address, options, remoteName));
|
|
17909
17909
|
this.session = null;
|
|
17910
17910
|
});
|
|
17911
17911
|
session.once("close", closeHandler);
|
|
@@ -17919,7 +17919,7 @@ var require_transport = __commonJS((exports) => {
|
|
|
17919
17919
|
if (proxiedSocket) {
|
|
17920
17920
|
return proxiedSocket;
|
|
17921
17921
|
} else {
|
|
17922
|
-
return new Promise((
|
|
17922
|
+
return new Promise((resolve, reject) => {
|
|
17923
17923
|
const closeCallback = () => {
|
|
17924
17924
|
reject(new Error("Socket closed"));
|
|
17925
17925
|
};
|
|
@@ -17929,7 +17929,7 @@ var require_transport = __commonJS((exports) => {
|
|
|
17929
17929
|
const socket = net.connect(address, () => {
|
|
17930
17930
|
socket.removeListener("close", closeCallback);
|
|
17931
17931
|
socket.removeListener("error", errorCallback);
|
|
17932
|
-
|
|
17932
|
+
resolve(socket);
|
|
17933
17933
|
});
|
|
17934
17934
|
socket.once("close", closeCallback);
|
|
17935
17935
|
socket.once("error", errorCallback);
|
|
@@ -21143,7 +21143,7 @@ var require_server_interceptors = __commonJS((exports) => {
|
|
|
21143
21143
|
} else {
|
|
21144
21144
|
decompresser = zlib.createGunzip();
|
|
21145
21145
|
}
|
|
21146
|
-
return new Promise((
|
|
21146
|
+
return new Promise((resolve, reject) => {
|
|
21147
21147
|
let totalLength = 0;
|
|
21148
21148
|
const messageParts = [];
|
|
21149
21149
|
decompresser.on("data", (chunk) => {
|
|
@@ -21158,7 +21158,7 @@ var require_server_interceptors = __commonJS((exports) => {
|
|
|
21158
21158
|
}
|
|
21159
21159
|
});
|
|
21160
21160
|
decompresser.on("end", () => {
|
|
21161
|
-
|
|
21161
|
+
resolve(Buffer.concat(messageParts));
|
|
21162
21162
|
});
|
|
21163
21163
|
decompresser.write(messageContents);
|
|
21164
21164
|
decompresser.end();
|
|
@@ -21751,10 +21751,10 @@ var require_server = __commonJS((exports) => {
|
|
|
21751
21751
|
bindOneAddress(address, boundPortObject) {
|
|
21752
21752
|
this.trace("Attempting to bind " + (0, subchannel_address_1.subchannelAddressToString)(address));
|
|
21753
21753
|
const http2Server = this.createHttp2Server(boundPortObject.credentials);
|
|
21754
|
-
return new Promise((
|
|
21754
|
+
return new Promise((resolve, reject) => {
|
|
21755
21755
|
const onError = (err) => {
|
|
21756
21756
|
this.trace("Failed to bind " + (0, subchannel_address_1.subchannelAddressToString)(address) + " with error " + err.message);
|
|
21757
|
-
|
|
21757
|
+
resolve({
|
|
21758
21758
|
port: "port" in address ? address.port : 1,
|
|
21759
21759
|
error: err.message
|
|
21760
21760
|
});
|
|
@@ -21782,7 +21782,7 @@ var require_server = __commonJS((exports) => {
|
|
|
21782
21782
|
});
|
|
21783
21783
|
boundPortObject.listeningServers.add(http2Server);
|
|
21784
21784
|
this.trace("Successfully bound " + (0, subchannel_address_1.subchannelAddressToString)(boundSubchannelAddress));
|
|
21785
|
-
|
|
21785
|
+
resolve({
|
|
21786
21786
|
port: "port" in boundSubchannelAddress ? boundSubchannelAddress.port : 1
|
|
21787
21787
|
});
|
|
21788
21788
|
http2Server.removeListener("error", onError);
|
|
@@ -21835,7 +21835,7 @@ var require_server = __commonJS((exports) => {
|
|
|
21835
21835
|
}
|
|
21836
21836
|
}
|
|
21837
21837
|
resolvePort(port) {
|
|
21838
|
-
return new Promise((
|
|
21838
|
+
return new Promise((resolve, reject) => {
|
|
21839
21839
|
let seenResolution = false;
|
|
21840
21840
|
const resolverListener = (endpointList, attributes, serviceConfig, resolutionNote) => {
|
|
21841
21841
|
if (seenResolution) {
|
|
@@ -21851,7 +21851,7 @@ var require_server = __commonJS((exports) => {
|
|
|
21851
21851
|
reject(new Error(`No addresses resolved for port ${port}`));
|
|
21852
21852
|
return true;
|
|
21853
21853
|
}
|
|
21854
|
-
|
|
21854
|
+
resolve(addressList);
|
|
21855
21855
|
return true;
|
|
21856
21856
|
};
|
|
21857
21857
|
const resolver = (0, resolver_1.createResolver)(port, resolverListener, this.options);
|
|
@@ -27564,8 +27564,8 @@ var require_promise = __commonJS((exports) => {
|
|
|
27564
27564
|
_resolve;
|
|
27565
27565
|
_reject;
|
|
27566
27566
|
constructor() {
|
|
27567
|
-
this._promise = new Promise((
|
|
27568
|
-
this._resolve =
|
|
27567
|
+
this._promise = new Promise((resolve, reject) => {
|
|
27568
|
+
this._resolve = resolve;
|
|
27569
27569
|
this._reject = reject;
|
|
27570
27570
|
});
|
|
27571
27571
|
}
|
|
@@ -27653,9 +27653,9 @@ var require_exporter = __commonJS((exports) => {
|
|
|
27653
27653
|
var api_1 = require_src();
|
|
27654
27654
|
var suppress_tracing_1 = require_suppress_tracing();
|
|
27655
27655
|
function _export(exporter, arg) {
|
|
27656
|
-
return new Promise((
|
|
27656
|
+
return new Promise((resolve) => {
|
|
27657
27657
|
api_1.context.with((0, suppress_tracing_1.suppressTracing)(api_1.context.active()), () => {
|
|
27658
|
-
exporter.export(arg,
|
|
27658
|
+
exporter.export(arg, resolve);
|
|
27659
27659
|
});
|
|
27660
27660
|
});
|
|
27661
27661
|
}
|
|
@@ -28111,22 +28111,22 @@ var require_grpc_exporter_transport = __commonJS((exports) => {
|
|
|
28111
28111
|
});
|
|
28112
28112
|
}
|
|
28113
28113
|
}
|
|
28114
|
-
return new Promise((
|
|
28114
|
+
return new Promise((resolve) => {
|
|
28115
28115
|
const deadline = Date.now() + timeoutMillis;
|
|
28116
28116
|
if (this._metadata == null) {
|
|
28117
|
-
return
|
|
28117
|
+
return resolve({
|
|
28118
28118
|
error: new Error("metadata was null"),
|
|
28119
28119
|
status: "failure"
|
|
28120
28120
|
});
|
|
28121
28121
|
}
|
|
28122
28122
|
this._client.export(buffer, this._metadata, { deadline }, (err, response) => {
|
|
28123
28123
|
if (err) {
|
|
28124
|
-
|
|
28124
|
+
resolve({
|
|
28125
28125
|
status: "failure",
|
|
28126
28126
|
error: err
|
|
28127
28127
|
});
|
|
28128
28128
|
} else {
|
|
28129
|
-
|
|
28129
|
+
resolve({
|
|
28130
28130
|
data: response,
|
|
28131
28131
|
status: "success"
|
|
28132
28132
|
});
|
|
@@ -28469,9 +28469,9 @@ var require_http_exporter_transport = __commonJS((exports) => {
|
|
|
28469
28469
|
async send(data, timeoutMillis) {
|
|
28470
28470
|
const { agent, request } = await this._loadUtils();
|
|
28471
28471
|
const headers = await this._parameters.headers();
|
|
28472
|
-
return new Promise((
|
|
28472
|
+
return new Promise((resolve) => {
|
|
28473
28473
|
(0, http_transport_utils_1.sendWithHttp)(request, this._parameters.url, headers, this._parameters.compression, this._parameters.userAgent, agent, data, (result) => {
|
|
28474
|
-
|
|
28474
|
+
resolve(result);
|
|
28475
28475
|
}, timeoutMillis);
|
|
28476
28476
|
});
|
|
28477
28477
|
}
|
|
@@ -28520,9 +28520,9 @@ var require_retrying_transport = __commonJS((exports) => {
|
|
|
28520
28520
|
this._transport = transport;
|
|
28521
28521
|
}
|
|
28522
28522
|
retry(data, timeoutMillis, inMillis) {
|
|
28523
|
-
return new Promise((
|
|
28523
|
+
return new Promise((resolve, reject) => {
|
|
28524
28524
|
setTimeout(() => {
|
|
28525
|
-
this._transport.send(data, timeoutMillis).then(
|
|
28525
|
+
this._transport.send(data, timeoutMillis).then(resolve, reject);
|
|
28526
28526
|
}, inMillis);
|
|
28527
28527
|
});
|
|
28528
28528
|
}
|
|
@@ -42765,14 +42765,14 @@ var require_BatchSpanProcessorBase = __commonJS((exports) => {
|
|
|
42765
42765
|
this._maybeStartTimer();
|
|
42766
42766
|
}
|
|
42767
42767
|
_flushAll() {
|
|
42768
|
-
return new Promise((
|
|
42768
|
+
return new Promise((resolve, reject) => {
|
|
42769
42769
|
const promises = [];
|
|
42770
42770
|
const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
|
|
42771
42771
|
for (let i = 0, j = count;i < j; i++) {
|
|
42772
42772
|
promises.push(this._flushOneBatch());
|
|
42773
42773
|
}
|
|
42774
42774
|
Promise.all(promises).then(() => {
|
|
42775
|
-
|
|
42775
|
+
resolve();
|
|
42776
42776
|
}).catch(reject);
|
|
42777
42777
|
});
|
|
42778
42778
|
}
|
|
@@ -42781,7 +42781,7 @@ var require_BatchSpanProcessorBase = __commonJS((exports) => {
|
|
|
42781
42781
|
if (this._finishedSpans.length === 0) {
|
|
42782
42782
|
return Promise.resolve();
|
|
42783
42783
|
}
|
|
42784
|
-
return new Promise((
|
|
42784
|
+
return new Promise((resolve, reject) => {
|
|
42785
42785
|
const timer = setTimeout(() => {
|
|
42786
42786
|
reject(new Error("Timeout"));
|
|
42787
42787
|
}, this._exportTimeoutMillis);
|
|
@@ -42796,7 +42796,7 @@ var require_BatchSpanProcessorBase = __commonJS((exports) => {
|
|
|
42796
42796
|
const doExport = () => this._exporter.export(spans, (result) => {
|
|
42797
42797
|
clearTimeout(timer);
|
|
42798
42798
|
if (result.code === core_1.ExportResultCode.SUCCESS) {
|
|
42799
|
-
|
|
42799
|
+
resolve();
|
|
42800
42800
|
} else {
|
|
42801
42801
|
reject(result.error ?? new Error("BatchSpanProcessor: span export failed"));
|
|
42802
42802
|
}
|
|
@@ -43056,12 +43056,12 @@ var require_MultiSpanProcessor = __commonJS((exports) => {
|
|
|
43056
43056
|
for (const spanProcessor of this._spanProcessors) {
|
|
43057
43057
|
promises.push(spanProcessor.forceFlush());
|
|
43058
43058
|
}
|
|
43059
|
-
return new Promise((
|
|
43059
|
+
return new Promise((resolve) => {
|
|
43060
43060
|
Promise.all(promises).then(() => {
|
|
43061
|
-
|
|
43061
|
+
resolve();
|
|
43062
43062
|
}).catch((error2) => {
|
|
43063
43063
|
(0, core_1.globalErrorHandler)(error2 || new Error("MultiSpanProcessor: forceFlush failed"));
|
|
43064
|
-
|
|
43064
|
+
resolve();
|
|
43065
43065
|
});
|
|
43066
43066
|
});
|
|
43067
43067
|
}
|
|
@@ -43087,9 +43087,9 @@ var require_MultiSpanProcessor = __commonJS((exports) => {
|
|
|
43087
43087
|
for (const spanProcessor of this._spanProcessors) {
|
|
43088
43088
|
promises.push(spanProcessor.shutdown());
|
|
43089
43089
|
}
|
|
43090
|
-
return new Promise((
|
|
43090
|
+
return new Promise((resolve, reject) => {
|
|
43091
43091
|
Promise.all(promises).then(() => {
|
|
43092
|
-
|
|
43092
|
+
resolve();
|
|
43093
43093
|
}, reject);
|
|
43094
43094
|
});
|
|
43095
43095
|
}
|
|
@@ -43142,32 +43142,32 @@ var require_BasicTracerProvider = __commonJS((exports) => {
|
|
|
43142
43142
|
forceFlush() {
|
|
43143
43143
|
const timeout = this._config.forceFlushTimeoutMillis;
|
|
43144
43144
|
const promises = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
|
|
43145
|
-
return new Promise((
|
|
43145
|
+
return new Promise((resolve) => {
|
|
43146
43146
|
let state;
|
|
43147
43147
|
const timeoutInterval = setTimeout(() => {
|
|
43148
|
-
|
|
43148
|
+
resolve(new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
|
|
43149
43149
|
state = ForceFlushState.timeout;
|
|
43150
43150
|
}, timeout);
|
|
43151
43151
|
spanProcessor.forceFlush().then(() => {
|
|
43152
43152
|
clearTimeout(timeoutInterval);
|
|
43153
43153
|
if (state !== ForceFlushState.timeout) {
|
|
43154
43154
|
state = ForceFlushState.resolved;
|
|
43155
|
-
|
|
43155
|
+
resolve(state);
|
|
43156
43156
|
}
|
|
43157
43157
|
}).catch((error2) => {
|
|
43158
43158
|
clearTimeout(timeoutInterval);
|
|
43159
43159
|
state = ForceFlushState.error;
|
|
43160
|
-
|
|
43160
|
+
resolve(error2);
|
|
43161
43161
|
});
|
|
43162
43162
|
});
|
|
43163
43163
|
});
|
|
43164
|
-
return new Promise((
|
|
43164
|
+
return new Promise((resolve, reject) => {
|
|
43165
43165
|
Promise.all(promises).then((results) => {
|
|
43166
43166
|
const errors3 = results.filter((result) => result !== ForceFlushState.resolved);
|
|
43167
43167
|
if (errors3.length > 0) {
|
|
43168
43168
|
reject(errors3);
|
|
43169
43169
|
} else {
|
|
43170
|
-
|
|
43170
|
+
resolve();
|
|
43171
43171
|
}
|
|
43172
43172
|
}).catch((error2) => reject([error2]));
|
|
43173
43173
|
});
|
|
@@ -43618,6 +43618,13 @@ class UnexpectedFriskServerResponseError extends Error {
|
|
|
43618
43618
|
}
|
|
43619
43619
|
}
|
|
43620
43620
|
|
|
43621
|
+
class MissingToolPoliciesExtensionError extends FriskError {
|
|
43622
|
+
constructor(options) {
|
|
43623
|
+
super("decide_tool_call requires the tool policies extension. Install and register the @friskai/frisk-js-tool-policies extension; calling frisk.connect() alone is not sufficient.", options);
|
|
43624
|
+
this.name = "MissingToolPoliciesExtensionError";
|
|
43625
|
+
}
|
|
43626
|
+
}
|
|
43627
|
+
|
|
43621
43628
|
class ToolCallSpanNotInitializedError extends Error {
|
|
43622
43629
|
constructor(message = "Tool call span has not been initialized. Call enter() first.") {
|
|
43623
43630
|
super(message);
|
|
@@ -48358,6 +48365,7 @@ class FriskSession {
|
|
|
48358
48365
|
logger;
|
|
48359
48366
|
_rootRunId = null;
|
|
48360
48367
|
_isTracing = false;
|
|
48368
|
+
_agentState = null;
|
|
48361
48369
|
toolCallSequenceNumber = 0;
|
|
48362
48370
|
toolCallSequenceGenerator = this.createToolCallSequenceGenerator();
|
|
48363
48371
|
toolCallErrorCount = 0;
|
|
@@ -48385,13 +48393,19 @@ class FriskSession {
|
|
|
48385
48393
|
}
|
|
48386
48394
|
async createToolCallSpan({
|
|
48387
48395
|
name,
|
|
48388
|
-
args: toolArgsInput
|
|
48396
|
+
args: toolArgsInput,
|
|
48397
|
+
agentState
|
|
48389
48398
|
}) {
|
|
48390
48399
|
const toolArgs = this.validateToolArgs(toolArgsInput);
|
|
48391
48400
|
const redactedToolArgsResult = this.frisk.adapter?.serializeToolArgs(removeLlmReasoningArg(toolArgs), { redact: this.redaction.redactToolArgs }) ?? {
|
|
48392
48401
|
value: "{}",
|
|
48393
48402
|
redactedPaths: []
|
|
48394
48403
|
};
|
|
48404
|
+
const agentStateToUse = agentState ?? this._agentState ?? {};
|
|
48405
|
+
const redactedAgentStateResult = this.frisk.adapter?.serializeAgentState(agentStateToUse, { redact: this.redaction.redactAgentState }) ?? {
|
|
48406
|
+
value: "{}",
|
|
48407
|
+
redactedPaths: []
|
|
48408
|
+
};
|
|
48395
48409
|
const sessionSpan = this.rootSpan;
|
|
48396
48410
|
const parentContext = sessionSpan ? import_api2.trace.setSpan(import_api2.context.active(), sessionSpan) : import_api2.context.active();
|
|
48397
48411
|
const spanAttributes = {
|
|
@@ -48399,6 +48413,8 @@ class FriskSession {
|
|
|
48399
48413
|
[ATTRIBUTE_NAME_TOOL_NAME]: name,
|
|
48400
48414
|
[ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value,
|
|
48401
48415
|
[ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths),
|
|
48416
|
+
[ATTRIBUTE_NAME_AGENT_STATE_JSON]: redactedAgentStateResult.value ?? "{}",
|
|
48417
|
+
[ATTRIBUTE_NAME_AGENT_STATE_REDACTED_PATHS_JSON]: JSON.stringify(redactedAgentStateResult.redactedPaths),
|
|
48402
48418
|
[ATTRIBUTE_NAME_TOOL_CALL_SEQUENCE_NUMBER]: this.toolCallSequenceGenerator.next().value
|
|
48403
48419
|
};
|
|
48404
48420
|
await this.frisk.toolRegistrationComplete;
|
|
@@ -48510,13 +48526,14 @@ class FriskSession {
|
|
|
48510
48526
|
getToolCallErrorCount() {
|
|
48511
48527
|
return this.toolCallErrorCount;
|
|
48512
48528
|
}
|
|
48513
|
-
initTracing({ runId,
|
|
48529
|
+
initTracing({ runId, agentState }) {
|
|
48514
48530
|
this._rootRunId = runId;
|
|
48515
48531
|
this._isTracing = true;
|
|
48532
|
+
this._agentState = agentState;
|
|
48516
48533
|
const span = this.tracer.startSpan(SPAN_NAME_FRISK_SESSION);
|
|
48517
48534
|
span.setAttribute(ATTRIBUTE_NAME_SESSION_ID, this.id);
|
|
48518
48535
|
span.setAttribute(ATTRIBUTE_NAME_REMOTE_SESSION_ID, runId);
|
|
48519
|
-
const userPrompt = this.frisk.adapter.extractPrompt?.(
|
|
48536
|
+
const userPrompt = this.frisk.adapter.extractPrompt?.(agentState);
|
|
48520
48537
|
if (userPrompt) {
|
|
48521
48538
|
span.setAttribute(ATTRIBUTE_NAME_SESSION_PROMPT, userPrompt);
|
|
48522
48539
|
}
|
|
@@ -48565,7 +48582,7 @@ class FriskCallbackHandler extends BaseCallbackHandler {
|
|
|
48565
48582
|
if (parentRunId === undefined) {
|
|
48566
48583
|
this.session.initTracing({
|
|
48567
48584
|
runId,
|
|
48568
|
-
inputs
|
|
48585
|
+
agentState: inputs
|
|
48569
48586
|
});
|
|
48570
48587
|
}
|
|
48571
48588
|
}
|
|
@@ -48679,26 +48696,52 @@ function combineRedactOptions(...options) {
|
|
|
48679
48696
|
}
|
|
48680
48697
|
return false;
|
|
48681
48698
|
}
|
|
48682
|
-
function
|
|
48699
|
+
function deleteDotPath(root, path) {
|
|
48700
|
+
const parts = path.split(".").filter((p) => p.length > 0);
|
|
48701
|
+
if (parts.length === 0)
|
|
48702
|
+
return false;
|
|
48703
|
+
let cur = root;
|
|
48704
|
+
for (const key of parts.slice(0, -1)) {
|
|
48705
|
+
if (cur === null || typeof cur !== "object" || Array.isArray(cur))
|
|
48706
|
+
return false;
|
|
48707
|
+
if (!(key in cur))
|
|
48708
|
+
return false;
|
|
48709
|
+
cur = cur[key];
|
|
48710
|
+
}
|
|
48711
|
+
if (cur === null || typeof cur !== "object" || Array.isArray(cur))
|
|
48712
|
+
return false;
|
|
48713
|
+
const last = parts[parts.length - 1];
|
|
48714
|
+
if (!(last in cur))
|
|
48715
|
+
return false;
|
|
48716
|
+
delete cur[last];
|
|
48717
|
+
return true;
|
|
48718
|
+
}
|
|
48719
|
+
function deepClone(obj) {
|
|
48720
|
+
return JSON.parse(JSON.stringify(obj));
|
|
48721
|
+
}
|
|
48722
|
+
function redactObject(data, redactOption) {
|
|
48683
48723
|
if (redactOption === undefined || redactOption === false) {
|
|
48684
48724
|
return { value: data, redactedPaths: [] };
|
|
48685
48725
|
}
|
|
48686
|
-
const redactedPaths = [];
|
|
48687
|
-
const result = { ...data };
|
|
48688
48726
|
if (redactOption === true) {
|
|
48689
|
-
|
|
48690
|
-
|
|
48691
|
-
|
|
48692
|
-
}
|
|
48693
|
-
}
|
|
48694
|
-
|
|
48695
|
-
|
|
48696
|
-
|
|
48697
|
-
|
|
48698
|
-
|
|
48727
|
+
return { value: {}, redactedPaths: ["*"] };
|
|
48728
|
+
}
|
|
48729
|
+
if (!Array.isArray(redactOption) || redactOption.length === 0) {
|
|
48730
|
+
return { value: data, redactedPaths: [] };
|
|
48731
|
+
}
|
|
48732
|
+
const out = deepClone(data);
|
|
48733
|
+
const hits = [];
|
|
48734
|
+
const seen = new Set;
|
|
48735
|
+
for (const rawPath of redactOption) {
|
|
48736
|
+
const path = rawPath.trim();
|
|
48737
|
+
if (path.length === 0)
|
|
48738
|
+
continue;
|
|
48739
|
+
if (deleteDotPath(out, path) && !seen.has(path)) {
|
|
48740
|
+
seen.add(path);
|
|
48741
|
+
hits.push(path);
|
|
48699
48742
|
}
|
|
48700
48743
|
}
|
|
48701
|
-
return { value:
|
|
48744
|
+
return { value: out, redactedPaths: hits };
|
|
48702
48745
|
}
|
|
48703
48746
|
// src/framework-adapter/base-framework-adapter.ts
|
|
48704
48747
|
class BaseFrameworkAdapter {
|
|
@@ -48725,10 +48768,10 @@ class BaseFrameworkAdapter {
|
|
|
48725
48768
|
};
|
|
48726
48769
|
}
|
|
48727
48770
|
toolArgsToDict(toolArgs, options) {
|
|
48728
|
-
return
|
|
48771
|
+
return redactObject(toolArgs, options?.redact);
|
|
48729
48772
|
}
|
|
48730
48773
|
agentStateToDict(agentState, options) {
|
|
48731
|
-
return
|
|
48774
|
+
return redactObject(agentState, options?.redact);
|
|
48732
48775
|
}
|
|
48733
48776
|
normalizeToolCall(toolCall) {
|
|
48734
48777
|
return {
|
|
@@ -48749,22 +48792,6 @@ class BaseFrameworkAdapter {
|
|
|
48749
48792
|
var DefaultWrapToolOptions = {
|
|
48750
48793
|
captureReasoning: true
|
|
48751
48794
|
};
|
|
48752
|
-
|
|
48753
|
-
// src/native-bindings/index.ts
|
|
48754
|
-
import { createRequire as createRequire2 } from "module";
|
|
48755
|
-
import { dirname, resolve } from "path";
|
|
48756
|
-
var require2 = createRequire2(import.meta.url);
|
|
48757
|
-
function resolveNativePath() {
|
|
48758
|
-
const injected = process.env.FRISk_NATIVE_BINDINGS_PATH;
|
|
48759
|
-
if (injected)
|
|
48760
|
-
return injected;
|
|
48761
|
-
const pkgJsonPath = require2.resolve("@friskai/frisk-js/package.json");
|
|
48762
|
-
const pkgRoot = dirname(pkgJsonPath);
|
|
48763
|
-
return resolve(pkgRoot, "native/index.cjs");
|
|
48764
|
-
}
|
|
48765
|
-
var nativeBindings = require2(resolveNativePath());
|
|
48766
|
-
var FriskHandle = nativeBindings.FriskHandle;
|
|
48767
|
-
var redactDictionary = nativeBindings.redactDictionary;
|
|
48768
48795
|
// src/telemetry/tracing-manager.ts
|
|
48769
48796
|
var import_grpc_js = __toESM(require_src4(), 1);
|
|
48770
48797
|
var import_exporter_trace_otlp_grpc = __toESM(require_src12(), 1);
|
|
@@ -49075,12 +49102,12 @@ function detectRuntime() {
|
|
|
49075
49102
|
|
|
49076
49103
|
// src/core/sdk-attributes/read-sdk-meta.ts
|
|
49077
49104
|
import { existsSync, readFileSync } from "node:fs";
|
|
49078
|
-
import { dirname
|
|
49105
|
+
import { dirname, join } from "node:path";
|
|
49079
49106
|
import { fileURLToPath } from "node:url";
|
|
49080
49107
|
|
|
49081
49108
|
// src/generated/sdk-meta.ts
|
|
49082
49109
|
var SDK_NAME = "@friskai/frisk-js";
|
|
49083
|
-
var SDK_VERSION = "0.
|
|
49110
|
+
var SDK_VERSION = "0.3.0";
|
|
49084
49111
|
|
|
49085
49112
|
// src/core/sdk-attributes/read-sdk-meta.ts
|
|
49086
49113
|
function getSdkMeta() {
|
|
@@ -49114,7 +49141,7 @@ function findNearestPackageJson(startDir) {
|
|
|
49114
49141
|
if (existsSync(candidate)) {
|
|
49115
49142
|
return candidate;
|
|
49116
49143
|
}
|
|
49117
|
-
const parent =
|
|
49144
|
+
const parent = dirname(dir);
|
|
49118
49145
|
if (parent === dir) {
|
|
49119
49146
|
return null;
|
|
49120
49147
|
}
|
|
@@ -49123,7 +49150,7 @@ function findNearestPackageJson(startDir) {
|
|
|
49123
49150
|
}
|
|
49124
49151
|
function tryReadPackageJson() {
|
|
49125
49152
|
try {
|
|
49126
|
-
const here =
|
|
49153
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
49127
49154
|
const pkgPath = findNearestPackageJson(here);
|
|
49128
49155
|
if (!pkgPath)
|
|
49129
49156
|
return null;
|
|
@@ -49491,6 +49518,9 @@ class ToolRegistry {
|
|
|
49491
49518
|
|
|
49492
49519
|
// src/core/frisk.ts
|
|
49493
49520
|
class Frisk {
|
|
49521
|
+
get toolPoliciesAvailable() {
|
|
49522
|
+
return this.toolPolicies?.available ?? false;
|
|
49523
|
+
}
|
|
49494
49524
|
get redaction() {
|
|
49495
49525
|
return this._redaction;
|
|
49496
49526
|
}
|
|
@@ -49498,24 +49528,34 @@ class Frisk {
|
|
|
49498
49528
|
apiBaseUrl;
|
|
49499
49529
|
otlpEndpoint;
|
|
49500
49530
|
accessTokenProvider;
|
|
49531
|
+
get adapter() {
|
|
49532
|
+
return this._adapter;
|
|
49533
|
+
}
|
|
49534
|
+
get logLevel() {
|
|
49535
|
+
return this._logLevel;
|
|
49536
|
+
}
|
|
49537
|
+
get tracingManager() {
|
|
49538
|
+
if (!this._tracingManager) {
|
|
49539
|
+
throw new FriskNotInitializedError;
|
|
49540
|
+
}
|
|
49541
|
+
return this._tracingManager;
|
|
49542
|
+
}
|
|
49501
49543
|
initialized = false;
|
|
49502
49544
|
rootLogger;
|
|
49503
49545
|
logger;
|
|
49504
49546
|
_logLevel;
|
|
49505
49547
|
_adapter;
|
|
49506
|
-
_friskHandle = null;
|
|
49507
49548
|
_tracingManager = null;
|
|
49508
|
-
|
|
49549
|
+
toolRegistry;
|
|
49509
49550
|
sdkAttributes;
|
|
49551
|
+
extensions = [];
|
|
49552
|
+
toolPolicies = null;
|
|
49510
49553
|
wrapToolsCalled = false;
|
|
49511
49554
|
get toolRegistrationComplete() {
|
|
49512
49555
|
if (!this.wrapToolsCalled) {
|
|
49513
49556
|
return Promise.resolve(true);
|
|
49514
49557
|
}
|
|
49515
|
-
return this.
|
|
49516
|
-
}
|
|
49517
|
-
get logLevel() {
|
|
49518
|
-
return this._logLevel;
|
|
49558
|
+
return this.toolRegistry.initialized;
|
|
49519
49559
|
}
|
|
49520
49560
|
static async connect(options) {
|
|
49521
49561
|
const instance = new this(options);
|
|
@@ -49529,7 +49569,7 @@ class Frisk {
|
|
|
49529
49569
|
this._logLevel = options?.logging?.logLevel;
|
|
49530
49570
|
this.logger = deriveSdkLogger({
|
|
49531
49571
|
logger: this.rootLogger,
|
|
49532
|
-
logLevel: this.
|
|
49572
|
+
logLevel: this.logLevel
|
|
49533
49573
|
}, {
|
|
49534
49574
|
component: "FriskCore"
|
|
49535
49575
|
});
|
|
@@ -49549,10 +49589,10 @@ class Frisk {
|
|
|
49549
49589
|
baseUrl,
|
|
49550
49590
|
logging: {
|
|
49551
49591
|
logger: this.rootLogger,
|
|
49552
|
-
logLevel: this.
|
|
49592
|
+
logLevel: this.logLevel
|
|
49553
49593
|
}
|
|
49554
49594
|
});
|
|
49555
|
-
this.
|
|
49595
|
+
this.toolRegistry = new ToolRegistry({
|
|
49556
49596
|
apiBaseUrl: baseUrl,
|
|
49557
49597
|
getAccessToken: async () => this.accessTokenProvider.getAccessToken(),
|
|
49558
49598
|
logger: this.logger
|
|
@@ -49563,21 +49603,20 @@ class Frisk {
|
|
|
49563
49603
|
}
|
|
49564
49604
|
this.otlpEndpoint = otlpEndpoint;
|
|
49565
49605
|
this._redaction = resolveRedactionOptions(options?.redact);
|
|
49606
|
+
this.extensions = options?.extensions ?? [];
|
|
49607
|
+
this.mountExtensions();
|
|
49566
49608
|
}
|
|
49567
|
-
|
|
49568
|
-
|
|
49569
|
-
|
|
49609
|
+
mountExtensions() {
|
|
49610
|
+
for (const ext of this.extensions) {
|
|
49611
|
+
if ("available" in ext && "decideToolCall" in ext) {
|
|
49612
|
+
this.toolPolicies = ext;
|
|
49613
|
+
}
|
|
49570
49614
|
}
|
|
49571
|
-
return this._friskHandle;
|
|
49572
|
-
}
|
|
49573
|
-
get adapter() {
|
|
49574
|
-
return this._adapter;
|
|
49575
49615
|
}
|
|
49576
|
-
|
|
49577
|
-
|
|
49578
|
-
|
|
49616
|
+
async initializeExtensions() {
|
|
49617
|
+
for (const ext of this.extensions) {
|
|
49618
|
+
await ext.initialize(this);
|
|
49579
49619
|
}
|
|
49580
|
-
return this._tracingManager;
|
|
49581
49620
|
}
|
|
49582
49621
|
async connect() {
|
|
49583
49622
|
if (!this.initialized) {
|
|
@@ -49591,20 +49630,20 @@ class Frisk {
|
|
|
49591
49630
|
tracerName: TRACER_NAME,
|
|
49592
49631
|
tracerVersion: TRACER_VERSION
|
|
49593
49632
|
});
|
|
49594
|
-
this._friskHandle = new FriskHandle(currentToken, this.apiBaseUrl, this.otlpEndpoint);
|
|
49595
49633
|
this.accessTokenProvider.addCallback((newToken) => this.updateAccessToken(newToken));
|
|
49596
49634
|
this.accessTokenProvider.startBackgroundRefresh();
|
|
49597
49635
|
this.initialized = true;
|
|
49636
|
+
await this.initializeExtensions();
|
|
49598
49637
|
}
|
|
49599
49638
|
}
|
|
49600
49639
|
session(metadata) {
|
|
49601
49640
|
const session = new FriskSession({
|
|
49602
49641
|
frisk: this,
|
|
49603
|
-
redact: this.
|
|
49642
|
+
redact: this.redaction,
|
|
49604
49643
|
tracer: this.tracingManager.getTracer(),
|
|
49605
49644
|
logging: {
|
|
49606
49645
|
logger: this.rootLogger,
|
|
49607
|
-
logLevel: this.
|
|
49646
|
+
logLevel: this.logLevel
|
|
49608
49647
|
}
|
|
49609
49648
|
});
|
|
49610
49649
|
const registry2 = SessionRegistry.getInstance();
|
|
@@ -49612,20 +49651,20 @@ class Frisk {
|
|
|
49612
49651
|
return session;
|
|
49613
49652
|
}
|
|
49614
49653
|
normalizeToolCall(toolCall) {
|
|
49615
|
-
return this.
|
|
49654
|
+
return this.adapter.normalizeToolCall(toolCall);
|
|
49616
49655
|
}
|
|
49617
49656
|
wrapTools(tools, options = DefaultWrapToolOptions) {
|
|
49618
49657
|
this.wrapToolsCalled = true;
|
|
49619
49658
|
const toolList = [...tools];
|
|
49620
|
-
const registerToolProperties = toolList.map((tool) => this.
|
|
49659
|
+
const registerToolProperties = toolList.map((tool) => this.adapter.extractRegisterToolProperties?.(tool)).filter((properties) => properties !== null && properties !== undefined);
|
|
49621
49660
|
if (registerToolProperties.length > 0) {
|
|
49622
|
-
this.
|
|
49661
|
+
this.toolRegistry.registerTools({
|
|
49623
49662
|
tools: registerToolProperties,
|
|
49624
49663
|
sdkAttributes: this.sdkAttributes
|
|
49625
49664
|
});
|
|
49626
49665
|
}
|
|
49627
|
-
if (this.
|
|
49628
|
-
return this.
|
|
49666
|
+
if (this.adapter.wrapTools) {
|
|
49667
|
+
return this.adapter.wrapTools(toolList, options);
|
|
49629
49668
|
}
|
|
49630
49669
|
return toolList;
|
|
49631
49670
|
}
|
|
@@ -49637,8 +49676,8 @@ class Frisk {
|
|
|
49637
49676
|
};
|
|
49638
49677
|
}
|
|
49639
49678
|
wrapTool(tool, options = DefaultWrapToolOptions) {
|
|
49640
|
-
if (this.
|
|
49641
|
-
return this.
|
|
49679
|
+
if (this.adapter.wrapTool) {
|
|
49680
|
+
return this.adapter.wrapTool(tool, options);
|
|
49642
49681
|
}
|
|
49643
49682
|
return tool;
|
|
49644
49683
|
}
|
|
@@ -49647,30 +49686,38 @@ class Frisk {
|
|
|
49647
49686
|
return registry2.get(sessionId);
|
|
49648
49687
|
}
|
|
49649
49688
|
updateAccessToken(authToken) {
|
|
49650
|
-
this.
|
|
49689
|
+
this.toolPolicies?.updateAccessToken(authToken);
|
|
49651
49690
|
this.tracingManager.updateAuthToken(authToken);
|
|
49652
49691
|
}
|
|
49653
49692
|
getRegisteredTool(toolName) {
|
|
49654
|
-
return this.
|
|
49693
|
+
return this.toolRegistry.getRegisteredTool(toolName);
|
|
49655
49694
|
}
|
|
49656
49695
|
decideToolCall({
|
|
49657
49696
|
toolCall,
|
|
49658
49697
|
agentState,
|
|
49659
49698
|
traceContextCarrier
|
|
49660
49699
|
}) {
|
|
49661
|
-
|
|
49662
|
-
|
|
49663
|
-
|
|
49664
|
-
const
|
|
49665
|
-
const
|
|
49666
|
-
const
|
|
49667
|
-
|
|
49668
|
-
|
|
49669
|
-
|
|
49670
|
-
|
|
49671
|
-
|
|
49672
|
-
|
|
49673
|
-
|
|
49700
|
+
if (!this.toolPolicies) {
|
|
49701
|
+
throw new MissingToolPoliciesExtensionError;
|
|
49702
|
+
}
|
|
49703
|
+
const toolArgsJson = toolCall.args ? JSON.stringify(toolCall.args) : null;
|
|
49704
|
+
const agentStateJson = agentState ? JSON.stringify(agentState) : null;
|
|
49705
|
+
const redactedArgs = toolCall.args ? redactObject(toolCall.args, this.redaction.redactToolArgs) : { value: {}, redactedPaths: [] };
|
|
49706
|
+
const toolArgsRedactedJson = toolCall.args ? JSON.stringify(redactedArgs.value) : null;
|
|
49707
|
+
const toolArgsRedactedPathsJson = JSON.stringify(redactedArgs.redactedPaths);
|
|
49708
|
+
const redactedState = agentState ? redactObject(agentState, this.redaction.redactAgentState) : { value: {}, redactedPaths: [] };
|
|
49709
|
+
const agentStateRedactedJson = agentState ? JSON.stringify(redactedState.value) : null;
|
|
49710
|
+
const agentStateRedactedPathsJson = JSON.stringify(redactedState.redactedPaths);
|
|
49711
|
+
return this.toolPolicies.decideToolCall({
|
|
49712
|
+
toolCall,
|
|
49713
|
+
toolArgsJson,
|
|
49714
|
+
toolArgsRedactedJson,
|
|
49715
|
+
toolArgsRedactedPathsJson,
|
|
49716
|
+
agentStateJson,
|
|
49717
|
+
agentStateRedactedJson,
|
|
49718
|
+
agentStateRedactedPathsJson,
|
|
49719
|
+
traceContextCarrier
|
|
49720
|
+
});
|
|
49674
49721
|
}
|
|
49675
49722
|
async getOrCreateToolApprovalRequest({
|
|
49676
49723
|
toolCallId,
|
|
@@ -49718,7 +49765,9 @@ class Frisk {
|
|
|
49718
49765
|
if (this.tracingManager) {
|
|
49719
49766
|
await this.tracingManager.shutdown();
|
|
49720
49767
|
}
|
|
49721
|
-
this.
|
|
49768
|
+
for (const ext of this.extensions) {
|
|
49769
|
+
ext.shutdown();
|
|
49770
|
+
}
|
|
49722
49771
|
}
|
|
49723
49772
|
}
|
|
49724
49773
|
|
|
@@ -49778,7 +49827,10 @@ class FriskToolMiddleware {
|
|
|
49778
49827
|
this.logger = deriveSdkLogger(options?.logging, {
|
|
49779
49828
|
component: "FriskToolMiddleware"
|
|
49780
49829
|
});
|
|
49781
|
-
this.toolPoliciesEnabled = options?.controls?.toolPolicies
|
|
49830
|
+
this.toolPoliciesEnabled = options?.controls?.toolPolicies === true;
|
|
49831
|
+
if (this.toolPoliciesEnabled && !frisk.toolPoliciesAvailable) {
|
|
49832
|
+
throw new MissingToolPoliciesExtensionError;
|
|
49833
|
+
}
|
|
49782
49834
|
}
|
|
49783
49835
|
get frisk() {
|
|
49784
49836
|
return this._frisk;
|
|
@@ -50039,14 +50091,14 @@ function createFriskToolCallId() {
|
|
|
50039
50091
|
}
|
|
50040
50092
|
|
|
50041
50093
|
// src/adapters/langchain/langchain-framework-adapter/get-langchain-version.ts
|
|
50042
|
-
import { createRequire as
|
|
50094
|
+
import { createRequire as createRequire2 } from "module";
|
|
50043
50095
|
var langchainVersionSet = false;
|
|
50044
50096
|
var langchainVersion = null;
|
|
50045
50097
|
function tryGetLangchainVersion() {
|
|
50046
50098
|
if (!langchainVersionSet) {
|
|
50047
50099
|
try {
|
|
50048
|
-
const
|
|
50049
|
-
const pkg =
|
|
50100
|
+
const require2 = createRequire2(import.meta.url);
|
|
50101
|
+
const pkg = require2("langchain/package.json");
|
|
50050
50102
|
langchainVersion = pkg.version ?? null;
|
|
50051
50103
|
} catch {
|
|
50052
50104
|
langchainVersion = null;
|
|
@@ -50147,11 +50199,11 @@ class LangchainFrameworkAdapter {
|
|
|
50147
50199
|
};
|
|
50148
50200
|
}
|
|
50149
50201
|
toolArgsToDict(toolArgs, options) {
|
|
50150
|
-
return
|
|
50202
|
+
return redactObject(toolArgs, options?.redact);
|
|
50151
50203
|
}
|
|
50152
50204
|
agentStateToDict(agentState, options) {
|
|
50153
50205
|
const combinedRedact = combineRedactOptions(EXCLUDED_STATE_KEYS, options?.redact);
|
|
50154
|
-
return
|
|
50206
|
+
return redactObject(agentState, combinedRedact);
|
|
50155
50207
|
}
|
|
50156
50208
|
normalizeToolCall(toolCall) {
|
|
50157
50209
|
return {
|
|
@@ -50218,7 +50270,7 @@ var FRISK_CONTEXT_SCHEMA = object({
|
|
|
50218
50270
|
[FRISK_SESSION_ID_KEY]: string2().optional()
|
|
50219
50271
|
});
|
|
50220
50272
|
var DefaultFriskGuardControls = {
|
|
50221
|
-
toolPolicies:
|
|
50273
|
+
toolPolicies: false
|
|
50222
50274
|
};
|
|
50223
50275
|
|
|
50224
50276
|
class FriskLangchain extends Frisk {
|
|
@@ -50279,5 +50331,5 @@ export {
|
|
|
50279
50331
|
FRISK_SESSION_ID_KEY
|
|
50280
50332
|
};
|
|
50281
50333
|
|
|
50282
|
-
//# debugId=
|
|
50334
|
+
//# debugId=46F5000910B6966364756E2164756E21
|
|
50283
50335
|
//# sourceMappingURL=index.js.map
|