@friskai/frisk-js 0.2.6 → 0.2.8
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/adapters/claude/claude-framework-adapter/claude-framework-adapter.d.ts +2 -0
- package/dist/adapters/claude/claude-framework-adapter/claude-framework-adapter.d.ts.map +1 -1
- package/dist/adapters/claude/claude-framework-adapter/get-claude-agent-sdk-version.d.ts +2 -0
- package/dist/adapters/claude/claude-framework-adapter/get-claude-agent-sdk-version.d.ts.map +1 -0
- package/dist/adapters/claude/index.js +220 -43
- package/dist/adapters/claude/index.js.map +15 -10
- package/dist/adapters/langchain/frisk-callback-handler.d.ts +21 -16
- package/dist/adapters/langchain/frisk-callback-handler.d.ts.map +1 -1
- package/dist/adapters/langchain/frisk-langchain-session.d.ts.map +1 -1
- package/dist/adapters/langchain/index.js +23444 -23137
- package/dist/adapters/langchain/index.js.map +71 -66
- package/dist/adapters/langchain/langchain-framework-adapter/get-langchain-version.d.ts +2 -0
- package/dist/adapters/langchain/langchain-framework-adapter/get-langchain-version.d.ts.map +1 -0
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts +2 -0
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts.map +1 -1
- package/dist/core/frisk-session.d.ts +3 -1
- package/dist/core/frisk-session.d.ts.map +1 -1
- package/dist/core/frisk.d.ts +6 -2
- package/dist/core/frisk.d.ts.map +1 -1
- package/dist/core/sdk-attributes/detect-runtime.d.ts +5 -0
- package/dist/core/sdk-attributes/detect-runtime.d.ts.map +1 -0
- package/dist/core/sdk-attributes/get-core-sdk-attributes.d.ts +12 -0
- package/dist/core/sdk-attributes/get-core-sdk-attributes.d.ts.map +1 -0
- package/dist/core/sdk-attributes/read-sdk-meta.d.ts +7 -0
- package/dist/core/sdk-attributes/read-sdk-meta.d.ts.map +1 -0
- package/dist/core/tool-registry.d.ts +5 -1
- package/dist/core/tool-registry.d.ts.map +1 -1
- package/dist/framework-adapter/base-framework-adapter.d.ts +2 -0
- package/dist/framework-adapter/base-framework-adapter.d.ts.map +1 -1
- package/dist/framework-adapter/framework-adapter.d.ts +2 -0
- package/dist/framework-adapter/framework-adapter.d.ts.map +1 -1
- package/dist/generated/sdk-meta.d.ts +3 -0
- package/dist/generated/sdk-meta.d.ts.map +1 -0
- package/dist/index.js +181 -24
- package/dist/index.js.map +13 -9
- package/dist/telemetry/constants.d.ts +3 -0
- package/dist/telemetry/constants.d.ts.map +1 -1
- package/native/frisk-js.win32-arm64-msvc.node +0 -0
- package/native/frisk-js.win32-x64-msvc.node +0 -0
- package/native/index.cjs +52 -52
- package/package.json +1 -1
|
@@ -30,6 +30,8 @@ export interface ClaudeTool {
|
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
32
|
export declare class ClaudeFrameworkAdapter implements FrameworkAdapter<ClaudeToolCall, ClaudeTool> {
|
|
33
|
+
readonly agentFramework = "@anthropic-ai/claude-agent-sdk";
|
|
34
|
+
readonly agentFrameworkVersion: string | null;
|
|
33
35
|
/**
|
|
34
36
|
* Serialize tool arguments to JSON with optional redaction
|
|
35
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-framework-adapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/claude/claude-framework-adapter/claude-framework-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,EAEL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EAChB,MAAM,8CAA8C,CAAA;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACb,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"claude-framework-adapter.d.ts","sourceRoot":"","sources":["../../../../src/adapters/claude/claude-framework-adapter/claude-framework-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AACjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,EAEL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EAChB,MAAM,8CAA8C,CAAA;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,wBAAwB,EACxB,YAAY,EACb,MAAM,uBAAuB,CAAA;AAK9B;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,yEAAyE;AACzE,MAAM,WAAW,UAAU;CAE1B;AAED;;;;;;GAMG;AACH,qBAAa,sBACX,YAAW,gBAAgB,CAAC,cAAc,EAAE,UAAU,CAAC;IAEvD,SAAgB,cAAc,oCAAmC;IACjE,SAAgB,qBAAqB,gBAA6B;IAElE;;OAEG;IACH,iBAAiB,CACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EACpD,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,GAClC,wBAAwB;IAY3B;;;;;OAKG;IACH,mBAAmB,CACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EACtD,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,GAClC,wBAAwB;IAY3B;;OAEG;IACH,cAAc,CACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,GAClC,kBAAkB;IAIrB;;;;OAIG;IACH,gBAAgB,CACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,GAClC,kBAAkB;IAIrB;;OAEG;IACH,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,YAAY;IAQzD;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAQ7B;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,IAAI;IAIvD;;;;;OAKG;IACH,SAAS,CACP,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,EAClD,OAAO,GAAE,eAAwC,GAChD,oBAAoB,CAAC,WAAW,CAAC,EAAE;IAItC;;;;OAIG;IACI,QAAQ,CACb,IAAI,EAAE,oBAAoB,CAAC,WAAW,CAAC,EACvC,OAAO,GAAE,eAAwC,GAChD,oBAAoB,CAAC,WAAW,CAAC;IAQpC,6BAA6B,CAC3B,KAAK,EAAE,oBAAoB,CAAC,WAAW,CAAC,GACvC,sBAAsB,GAAG,IAAI;CAGjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-claude-agent-sdk-version.d.ts","sourceRoot":"","sources":["../../../../src/adapters/claude/claude-framework-adapter/get-claude-agent-sdk-version.ts"],"names":[],"mappings":"AAMA,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,CAWxD"}
|
|
@@ -43678,6 +43678,8 @@ function redactDictionarySimple(data, redactOption) {
|
|
|
43678
43678
|
}
|
|
43679
43679
|
// src/framework-adapter/base-framework-adapter.ts
|
|
43680
43680
|
class BaseFrameworkAdapter {
|
|
43681
|
+
agentFramework = "none";
|
|
43682
|
+
agentFrameworkVersion = null;
|
|
43681
43683
|
serializeToolArgs(toolArgs, options) {
|
|
43682
43684
|
if (toolArgs == null) {
|
|
43683
43685
|
return { value: null, redactedPaths: [] };
|
|
@@ -43846,6 +43848,7 @@ var redactDictionary = nativeBindings.redactDictionary;
|
|
|
43846
43848
|
var TRACER_NAME = "frisk_js_sdk";
|
|
43847
43849
|
var TRACER_VERSION = "0.1.0";
|
|
43848
43850
|
var SPAN_NAME_DECIDE_TOOL_CALL = "frisk.tool_call.decide";
|
|
43851
|
+
var SPAN_NAME_OBSERVE_TOOL_CALL = "frisk.tool_call.observation";
|
|
43849
43852
|
var SPAN_NAME_FRISK_SESSION = "frisk.session";
|
|
43850
43853
|
var ATTRIBUTE_NAME_SESSION_PROMPT = "frisk.session.prompt";
|
|
43851
43854
|
var ATTRIBUTE_NAME_SESSION_ID = "frisk.session.id";
|
|
@@ -43865,6 +43868,8 @@ var ATTRIBUTE_NAME_DECISION_REASON = "frisk.decision.reason";
|
|
|
43865
43868
|
var ATTRIBUTE_NAME_ERROR_TYPE = "error.type";
|
|
43866
43869
|
var ATTRIBUTE_NAME_ERROR_MESSAGE = "error.message";
|
|
43867
43870
|
var ATTRIBUTE_NAME_LATENCY_NS = "latency_ns";
|
|
43871
|
+
var ATTRIBUTE_NAME_TOOL_CALL_IS_SUCCESS = "frisk.tool_call.is_success";
|
|
43872
|
+
var ATTRIBUTE_NAME_TOOL_CALL_IS_ERROR = "frisk.tool_call.is_error";
|
|
43868
43873
|
// src/telemetry/tracing-manager.ts
|
|
43869
43874
|
var import_grpc_js = __toESM(require_src3(), 1);
|
|
43870
43875
|
var import_exporter_trace_otlp_grpc = __toESM(require_src12(), 1);
|
|
@@ -48635,7 +48640,7 @@ var DecisionOutcome;
|
|
|
48635
48640
|
class FriskSession {
|
|
48636
48641
|
frisk;
|
|
48637
48642
|
id;
|
|
48638
|
-
|
|
48643
|
+
_rootSpan = null;
|
|
48639
48644
|
redaction;
|
|
48640
48645
|
tracer;
|
|
48641
48646
|
logger;
|
|
@@ -48651,6 +48656,12 @@ class FriskSession {
|
|
|
48651
48656
|
this.redaction = redact;
|
|
48652
48657
|
this.tracer = tracer;
|
|
48653
48658
|
}
|
|
48659
|
+
get rootSpan() {
|
|
48660
|
+
return this._rootSpan;
|
|
48661
|
+
}
|
|
48662
|
+
getTracer() {
|
|
48663
|
+
return this.tracer;
|
|
48664
|
+
}
|
|
48654
48665
|
get isTracing() {
|
|
48655
48666
|
return this._isTracing;
|
|
48656
48667
|
}
|
|
@@ -48669,7 +48680,7 @@ class FriskSession {
|
|
|
48669
48680
|
friskToolId: registeredTool?.id ?? null,
|
|
48670
48681
|
friskToolVersionId: registeredTool?.versionId ?? null,
|
|
48671
48682
|
agentState,
|
|
48672
|
-
parent: this.
|
|
48683
|
+
parent: this._rootSpan,
|
|
48673
48684
|
tracer: this.tracer,
|
|
48674
48685
|
redact: this.redaction
|
|
48675
48686
|
});
|
|
@@ -48727,21 +48738,139 @@ class FriskSession {
|
|
|
48727
48738
|
return span;
|
|
48728
48739
|
}
|
|
48729
48740
|
endTracing() {
|
|
48730
|
-
if (this.
|
|
48731
|
-
this.
|
|
48741
|
+
if (this._rootSpan) {
|
|
48742
|
+
this._rootSpan.end();
|
|
48732
48743
|
}
|
|
48733
48744
|
this._isTracing = false;
|
|
48734
48745
|
const registry2 = SessionRegistry.getInstance();
|
|
48735
48746
|
registry2.unregister(this.id);
|
|
48736
48747
|
}
|
|
48737
48748
|
setRootSpan(span) {
|
|
48738
|
-
this.
|
|
48749
|
+
this._rootSpan = span;
|
|
48739
48750
|
}
|
|
48740
48751
|
static generateSessionId() {
|
|
48741
48752
|
return v4();
|
|
48742
48753
|
}
|
|
48743
48754
|
}
|
|
48744
48755
|
|
|
48756
|
+
// src/core/sdk-attributes/detect-runtime.ts
|
|
48757
|
+
function detectRuntime() {
|
|
48758
|
+
const g = globalThis;
|
|
48759
|
+
if (g.Bun) {
|
|
48760
|
+
return {
|
|
48761
|
+
runtime: "bun",
|
|
48762
|
+
runtimeVersion: g.Bun.version
|
|
48763
|
+
};
|
|
48764
|
+
}
|
|
48765
|
+
if (g.Deno) {
|
|
48766
|
+
return {
|
|
48767
|
+
runtime: "deno",
|
|
48768
|
+
runtimeVersion: g.Deno.version.deno
|
|
48769
|
+
};
|
|
48770
|
+
}
|
|
48771
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
48772
|
+
return {
|
|
48773
|
+
runtime: "node",
|
|
48774
|
+
runtimeVersion: process.versions.node
|
|
48775
|
+
};
|
|
48776
|
+
}
|
|
48777
|
+
if (typeof navigator !== "undefined") {
|
|
48778
|
+
return {
|
|
48779
|
+
runtime: "browser",
|
|
48780
|
+
runtimeVersion: navigator.userAgent
|
|
48781
|
+
};
|
|
48782
|
+
}
|
|
48783
|
+
return {
|
|
48784
|
+
runtime: "unknown",
|
|
48785
|
+
runtimeVersion: "unknown"
|
|
48786
|
+
};
|
|
48787
|
+
}
|
|
48788
|
+
|
|
48789
|
+
// src/core/sdk-attributes/read-sdk-meta.ts
|
|
48790
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
48791
|
+
import { dirname as dirname2, join } from "node:path";
|
|
48792
|
+
import { fileURLToPath } from "node:url";
|
|
48793
|
+
|
|
48794
|
+
// src/generated/sdk-meta.ts
|
|
48795
|
+
var SDK_NAME = "@friskai/frisk-js";
|
|
48796
|
+
var SDK_VERSION = "0.2.8";
|
|
48797
|
+
|
|
48798
|
+
// src/core/sdk-attributes/read-sdk-meta.ts
|
|
48799
|
+
function getSdkMeta() {
|
|
48800
|
+
if (isNonEmptyString(SDK_NAME) && isNonEmptyString(SDK_VERSION)) {
|
|
48801
|
+
return {
|
|
48802
|
+
sdkName: SDK_NAME,
|
|
48803
|
+
sdkVersion: SDK_VERSION,
|
|
48804
|
+
source: "injected"
|
|
48805
|
+
};
|
|
48806
|
+
}
|
|
48807
|
+
const fromPkg = tryReadPackageJson();
|
|
48808
|
+
if (fromPkg) {
|
|
48809
|
+
return {
|
|
48810
|
+
...fromPkg,
|
|
48811
|
+
source: "package.json"
|
|
48812
|
+
};
|
|
48813
|
+
}
|
|
48814
|
+
return {
|
|
48815
|
+
sdkName: "unknown",
|
|
48816
|
+
sdkVersion: "unknown",
|
|
48817
|
+
source: "unknown"
|
|
48818
|
+
};
|
|
48819
|
+
}
|
|
48820
|
+
function isNonEmptyString(value) {
|
|
48821
|
+
return typeof value === "string" && value.length > 0;
|
|
48822
|
+
}
|
|
48823
|
+
function findNearestPackageJson(startDir) {
|
|
48824
|
+
let dir = startDir;
|
|
48825
|
+
while (true) {
|
|
48826
|
+
const candidate = join(dir, "package.json");
|
|
48827
|
+
if (existsSync(candidate)) {
|
|
48828
|
+
return candidate;
|
|
48829
|
+
}
|
|
48830
|
+
const parent = dirname2(dir);
|
|
48831
|
+
if (parent === dir) {
|
|
48832
|
+
return null;
|
|
48833
|
+
}
|
|
48834
|
+
dir = parent;
|
|
48835
|
+
}
|
|
48836
|
+
}
|
|
48837
|
+
function tryReadPackageJson() {
|
|
48838
|
+
try {
|
|
48839
|
+
const here = dirname2(fileURLToPath(import.meta.url));
|
|
48840
|
+
const pkgPath = findNearestPackageJson(here);
|
|
48841
|
+
if (!pkgPath)
|
|
48842
|
+
return null;
|
|
48843
|
+
const raw = readFileSync(pkgPath, "utf8");
|
|
48844
|
+
const pkg = JSON.parse(raw);
|
|
48845
|
+
if (!isNonEmptyString(pkg.name) || !isNonEmptyString(pkg.version)) {
|
|
48846
|
+
return null;
|
|
48847
|
+
}
|
|
48848
|
+
return {
|
|
48849
|
+
sdkName: pkg.name,
|
|
48850
|
+
sdkVersion: pkg.version
|
|
48851
|
+
};
|
|
48852
|
+
} catch {
|
|
48853
|
+
return null;
|
|
48854
|
+
}
|
|
48855
|
+
}
|
|
48856
|
+
|
|
48857
|
+
// src/core/sdk-attributes/get-core-sdk-attributes.ts
|
|
48858
|
+
var coreSdkAttributes = null;
|
|
48859
|
+
function getCoreSdkAttributes() {
|
|
48860
|
+
if (!coreSdkAttributes) {
|
|
48861
|
+
const { sdkName, sdkVersion } = getSdkMeta();
|
|
48862
|
+
const { runtime, runtimeVersion } = detectRuntime();
|
|
48863
|
+
coreSdkAttributes = {
|
|
48864
|
+
version: sdkVersion,
|
|
48865
|
+
language: "js",
|
|
48866
|
+
name: sdkName,
|
|
48867
|
+
runtime,
|
|
48868
|
+
runtimeVersion
|
|
48869
|
+
};
|
|
48870
|
+
}
|
|
48871
|
+
return coreSdkAttributes;
|
|
48872
|
+
}
|
|
48873
|
+
|
|
48745
48874
|
// src/core/tool-approval-request.ts
|
|
48746
48875
|
var REQUEST_TIMEOUT_MS = 1e4;
|
|
48747
48876
|
var logger = deriveSdkLogger(undefined, {
|
|
@@ -49019,16 +49148,25 @@ class ToolRegistry {
|
|
|
49019
49148
|
getRegisteredTool(toolName) {
|
|
49020
49149
|
return this.toolNameToId.get(toolName) ?? null;
|
|
49021
49150
|
}
|
|
49022
|
-
registerTools(
|
|
49023
|
-
|
|
49024
|
-
|
|
49151
|
+
registerTools({
|
|
49152
|
+
tools,
|
|
49153
|
+
sdkAttributes
|
|
49154
|
+
}) {
|
|
49155
|
+
const toolsList = [...tools];
|
|
49156
|
+
if (toolsList.length === 0 && !sdkAttributes) {
|
|
49025
49157
|
this.initialized = Promise.resolve(true);
|
|
49026
49158
|
return;
|
|
49027
49159
|
}
|
|
49028
|
-
this.initialized = this.executeRegisterTools(
|
|
49160
|
+
this.initialized = this.executeRegisterTools({
|
|
49161
|
+
tools: toolsList,
|
|
49162
|
+
sdkAttributes
|
|
49163
|
+
});
|
|
49029
49164
|
this.initialized;
|
|
49030
49165
|
}
|
|
49031
|
-
async executeRegisterTools(
|
|
49166
|
+
async executeRegisterTools({
|
|
49167
|
+
tools,
|
|
49168
|
+
sdkAttributes
|
|
49169
|
+
}) {
|
|
49032
49170
|
try {
|
|
49033
49171
|
const accessToken = await this.getAccessToken();
|
|
49034
49172
|
const response = await fetch(buildRegisterToolsEndpoint(this.apiBaseUrl), {
|
|
@@ -49038,13 +49176,14 @@ class ToolRegistry {
|
|
|
49038
49176
|
"Content-Type": "application/json"
|
|
49039
49177
|
},
|
|
49040
49178
|
body: JSON.stringify({
|
|
49041
|
-
properties:
|
|
49179
|
+
properties: tools.map((property) => ({
|
|
49042
49180
|
name: property.name,
|
|
49043
49181
|
description: property.description,
|
|
49044
49182
|
inputJsonSchema: property.inputJsonSchema,
|
|
49045
49183
|
outputJsonSchema: property.outputJsonSchema,
|
|
49046
49184
|
responseFormat: property.responseFormat
|
|
49047
|
-
}))
|
|
49185
|
+
})),
|
|
49186
|
+
sdk: sdkAttributes
|
|
49048
49187
|
})
|
|
49049
49188
|
});
|
|
49050
49189
|
if (!response.ok) {
|
|
@@ -49065,18 +49204,22 @@ class ToolRegistry {
|
|
|
49065
49204
|
|
|
49066
49205
|
// src/core/frisk.ts
|
|
49067
49206
|
class Frisk {
|
|
49068
|
-
redaction
|
|
49207
|
+
get redaction() {
|
|
49208
|
+
return this._redaction;
|
|
49209
|
+
}
|
|
49210
|
+
_redaction;
|
|
49069
49211
|
apiBaseUrl;
|
|
49070
49212
|
otlpEndpoint;
|
|
49071
49213
|
accessTokenProvider;
|
|
49072
49214
|
initialized = false;
|
|
49073
49215
|
rootLogger;
|
|
49074
49216
|
logger;
|
|
49075
|
-
|
|
49217
|
+
_logLevel;
|
|
49076
49218
|
_adapter;
|
|
49077
49219
|
_friskHandle = null;
|
|
49078
49220
|
_tracingManager = null;
|
|
49079
49221
|
_toolRegistry;
|
|
49222
|
+
sdkAttributes;
|
|
49080
49223
|
wrapToolsCalled = false;
|
|
49081
49224
|
get toolRegistrationComplete() {
|
|
49082
49225
|
if (!this.wrapToolsCalled) {
|
|
@@ -49084,6 +49227,9 @@ class Frisk {
|
|
|
49084
49227
|
}
|
|
49085
49228
|
return this._toolRegistry.initialized;
|
|
49086
49229
|
}
|
|
49230
|
+
get logLevel() {
|
|
49231
|
+
return this._logLevel;
|
|
49232
|
+
}
|
|
49087
49233
|
static async connect(options) {
|
|
49088
49234
|
const instance = new this(options);
|
|
49089
49235
|
await instance.connect();
|
|
@@ -49093,13 +49239,15 @@ class Frisk {
|
|
|
49093
49239
|
this.rootLogger = deriveSdkLogger(options?.logging, {
|
|
49094
49240
|
sdk: "frisk"
|
|
49095
49241
|
});
|
|
49096
|
-
this.
|
|
49242
|
+
this._logLevel = options?.logging?.logLevel;
|
|
49097
49243
|
this.logger = deriveSdkLogger({
|
|
49098
49244
|
logger: this.rootLogger,
|
|
49099
|
-
logLevel: this.
|
|
49245
|
+
logLevel: this._logLevel
|
|
49100
49246
|
}, {
|
|
49101
49247
|
component: "FriskCore"
|
|
49102
49248
|
});
|
|
49249
|
+
this._adapter = options?.adapter ?? new BaseFrameworkAdapter;
|
|
49250
|
+
this.sdkAttributes = this.getSdkAttributes();
|
|
49103
49251
|
const apiKey = options?.apiKey ?? getEnv(FRISK_API_KEY);
|
|
49104
49252
|
if (!apiKey) {
|
|
49105
49253
|
throw new MissingAPIKeyError;
|
|
@@ -49114,7 +49262,7 @@ class Frisk {
|
|
|
49114
49262
|
baseUrl,
|
|
49115
49263
|
logging: {
|
|
49116
49264
|
logger: this.rootLogger,
|
|
49117
|
-
logLevel: this.
|
|
49265
|
+
logLevel: this._logLevel
|
|
49118
49266
|
}
|
|
49119
49267
|
});
|
|
49120
49268
|
this._toolRegistry = new ToolRegistry({
|
|
@@ -49127,8 +49275,7 @@ class Frisk {
|
|
|
49127
49275
|
throw new MissingOtlpEndpointError;
|
|
49128
49276
|
}
|
|
49129
49277
|
this.otlpEndpoint = otlpEndpoint;
|
|
49130
|
-
this.
|
|
49131
|
-
this._adapter = options?.adapter ?? new BaseFrameworkAdapter;
|
|
49278
|
+
this._redaction = resolveRedactionOptions(options?.redact);
|
|
49132
49279
|
}
|
|
49133
49280
|
get friskHandle() {
|
|
49134
49281
|
if (!this._friskHandle) {
|
|
@@ -49166,11 +49313,11 @@ class Frisk {
|
|
|
49166
49313
|
session(metadata) {
|
|
49167
49314
|
const session = new FriskSession({
|
|
49168
49315
|
frisk: this,
|
|
49169
|
-
redact: this.
|
|
49316
|
+
redact: this._redaction,
|
|
49170
49317
|
tracer: this.tracingManager.getTracer(),
|
|
49171
49318
|
logging: {
|
|
49172
49319
|
logger: this.rootLogger,
|
|
49173
|
-
logLevel: this.
|
|
49320
|
+
logLevel: this._logLevel
|
|
49174
49321
|
}
|
|
49175
49322
|
});
|
|
49176
49323
|
const registry2 = SessionRegistry.getInstance();
|
|
@@ -49185,13 +49332,23 @@ class Frisk {
|
|
|
49185
49332
|
const toolList = [...tools];
|
|
49186
49333
|
const registerToolProperties = toolList.map((tool) => this._adapter.extractRegisterToolProperties?.(tool)).filter((properties) => properties !== null && properties !== undefined);
|
|
49187
49334
|
if (registerToolProperties.length > 0) {
|
|
49188
|
-
this._toolRegistry.registerTools(
|
|
49335
|
+
this._toolRegistry.registerTools({
|
|
49336
|
+
tools: registerToolProperties,
|
|
49337
|
+
sdkAttributes: this.sdkAttributes
|
|
49338
|
+
});
|
|
49189
49339
|
}
|
|
49190
49340
|
if (this._adapter.wrapTools) {
|
|
49191
49341
|
return this._adapter.wrapTools(toolList, options);
|
|
49192
49342
|
}
|
|
49193
49343
|
return toolList;
|
|
49194
49344
|
}
|
|
49345
|
+
getSdkAttributes() {
|
|
49346
|
+
return {
|
|
49347
|
+
...getCoreSdkAttributes(),
|
|
49348
|
+
agentFramework: this.adapter.agentFramework ?? null,
|
|
49349
|
+
agentFrameworkVersion: this.adapter.agentFrameworkVersion ?? null
|
|
49350
|
+
};
|
|
49351
|
+
}
|
|
49195
49352
|
wrapTool(tool, options = DefaultWrapToolOptions) {
|
|
49196
49353
|
if (this._adapter.wrapTool) {
|
|
49197
49354
|
return this._adapter.wrapTool(tool, options);
|
|
@@ -49218,7 +49375,7 @@ class Frisk {
|
|
|
49218
49375
|
const argsJson = toolCall.args ? JSON.stringify(removeLlmReasoningArg(toolCall.args)) : null;
|
|
49219
49376
|
const stateJson = agentState ? JSON.stringify(agentState) : null;
|
|
49220
49377
|
const registeredTool = this.getRegisteredTool(toolCall.name);
|
|
49221
|
-
const coreResult = this.friskHandle.process(toolCall.name, registeredTool?.id ?? null, registeredTool?.versionId ?? null, argsJson, stateJson, id, this.
|
|
49378
|
+
const coreResult = this.friskHandle.process(toolCall.name, registeredTool?.id ?? null, registeredTool?.versionId ?? null, argsJson, stateJson, id, this._redaction, traceContextCarrier);
|
|
49222
49379
|
const outcome = coreResult.decision === "allow" ? "allow" /* ALLOW */ : coreResult.decision === "deny" ? "deny" /* DENY */ : coreResult.decision === "escalate" ? "escalate" /* ESCALATE */ : "error" /* ERROR */;
|
|
49223
49380
|
return {
|
|
49224
49381
|
outcome,
|
|
@@ -49283,12 +49440,30 @@ function createFriskToolCallId() {
|
|
|
49283
49440
|
return v4();
|
|
49284
49441
|
}
|
|
49285
49442
|
|
|
49443
|
+
// src/adapters/claude/claude-framework-adapter/get-claude-agent-sdk-version.ts
|
|
49444
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
49445
|
+
var require3 = createRequire3(import.meta.url);
|
|
49446
|
+
var versionSet = false;
|
|
49447
|
+
var version3 = null;
|
|
49448
|
+
function getClaudeAgentSdkVersion() {
|
|
49449
|
+
if (!versionSet) {
|
|
49450
|
+
try {
|
|
49451
|
+
const pkg = require3("@anthropic-ai/claude-agent-sdk/package.json");
|
|
49452
|
+
version3 = typeof pkg.version === "string" ? pkg.version : null;
|
|
49453
|
+
} catch {
|
|
49454
|
+
version3 = null;
|
|
49455
|
+
}
|
|
49456
|
+
versionSet = true;
|
|
49457
|
+
}
|
|
49458
|
+
return version3;
|
|
49459
|
+
}
|
|
49460
|
+
|
|
49286
49461
|
// ../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
49287
49462
|
import * as fs from "fs";
|
|
49288
49463
|
import { stat as statPromise, open } from "fs/promises";
|
|
49289
|
-
import { join } from "path";
|
|
49464
|
+
import { join as join2 } from "path";
|
|
49290
49465
|
import { homedir } from "os";
|
|
49291
|
-
import { dirname as
|
|
49466
|
+
import { dirname as dirname3, join as join22 } from "path";
|
|
49292
49467
|
import { cwd } from "process";
|
|
49293
49468
|
import { realpathSync as realpathSync2 } from "fs";
|
|
49294
49469
|
import { randomUUID } from "crypto";
|
|
@@ -56007,7 +56182,7 @@ function shouldShowDebugMessage(message, filter) {
|
|
|
56007
56182
|
return shouldShowDebugCategories(categories, filter);
|
|
56008
56183
|
}
|
|
56009
56184
|
function getClaudeConfigHomeDir() {
|
|
56010
|
-
return process.env.CLAUDE_CONFIG_DIR ??
|
|
56185
|
+
return process.env.CLAUDE_CONFIG_DIR ?? join2(homedir(), ".claude");
|
|
56011
56186
|
}
|
|
56012
56187
|
function isEnvTruthy(envVar) {
|
|
56013
56188
|
if (!envVar)
|
|
@@ -56293,8 +56468,8 @@ function getDebugWriter() {
|
|
|
56293
56468
|
debugWriter = createBufferedWriter({
|
|
56294
56469
|
writeFn: (content) => {
|
|
56295
56470
|
const path = getDebugLogPath();
|
|
56296
|
-
if (!getFsImplementation().existsSync(
|
|
56297
|
-
getFsImplementation().mkdirSync(
|
|
56471
|
+
if (!getFsImplementation().existsSync(dirname3(path))) {
|
|
56472
|
+
getFsImplementation().mkdirSync(dirname3(path));
|
|
56298
56473
|
}
|
|
56299
56474
|
getFsImplementation().appendFileSync(path, content);
|
|
56300
56475
|
updateLatestDebugLogSymlink();
|
|
@@ -56327,7 +56502,7 @@ function logForDebugging(message, { level } = {
|
|
|
56327
56502
|
getDebugWriter().write(output);
|
|
56328
56503
|
}
|
|
56329
56504
|
function getDebugLogPath() {
|
|
56330
|
-
return process.env.CLAUDE_CODE_DEBUG_LOGS_DIR ??
|
|
56505
|
+
return process.env.CLAUDE_CODE_DEBUG_LOGS_DIR ?? join22(getClaudeConfigHomeDir(), "debug", `${getSessionId()}.txt`);
|
|
56331
56506
|
}
|
|
56332
56507
|
var updateLatestDebugLogSymlink = memoize_default(() => {
|
|
56333
56508
|
if (process.argv[2] === "--ripgrep") {
|
|
@@ -56335,8 +56510,8 @@ var updateLatestDebugLogSymlink = memoize_default(() => {
|
|
|
56335
56510
|
}
|
|
56336
56511
|
try {
|
|
56337
56512
|
const debugLogPath = getDebugLogPath();
|
|
56338
|
-
const debugLogsDir =
|
|
56339
|
-
const latestSymlinkPath =
|
|
56513
|
+
const debugLogsDir = dirname3(debugLogPath);
|
|
56514
|
+
const latestSymlinkPath = join22(debugLogsDir, "latest");
|
|
56340
56515
|
if (!getFsImplementation().existsSync(debugLogsDir)) {
|
|
56341
56516
|
getFsImplementation().mkdirSync(debugLogsDir);
|
|
56342
56517
|
}
|
|
@@ -57874,11 +58049,11 @@ function datetimeRegex(args) {
|
|
|
57874
58049
|
regex = `${regex}(${opts.join("|")})`;
|
|
57875
58050
|
return new RegExp(`^${regex}$`);
|
|
57876
58051
|
}
|
|
57877
|
-
function isValidIP(ip,
|
|
57878
|
-
if ((
|
|
58052
|
+
function isValidIP(ip, version4) {
|
|
58053
|
+
if ((version4 === "v4" || !version4) && ipv4Regex.test(ip)) {
|
|
57879
58054
|
return true;
|
|
57880
58055
|
}
|
|
57881
|
-
if ((
|
|
58056
|
+
if ((version4 === "v6" || !version4) && ipv6Regex.test(ip)) {
|
|
57882
58057
|
return true;
|
|
57883
58058
|
}
|
|
57884
58059
|
return false;
|
|
@@ -57905,11 +58080,11 @@ function isValidJWT2(jwt, alg) {
|
|
|
57905
58080
|
return false;
|
|
57906
58081
|
}
|
|
57907
58082
|
}
|
|
57908
|
-
function isValidCidr(ip,
|
|
57909
|
-
if ((
|
|
58083
|
+
function isValidCidr(ip, version4) {
|
|
58084
|
+
if ((version4 === "v4" || !version4) && ipv4CidrRegex.test(ip)) {
|
|
57910
58085
|
return true;
|
|
57911
58086
|
}
|
|
57912
|
-
if ((
|
|
58087
|
+
if ((version4 === "v6" || !version4) && ipv6CidrRegex.test(ip)) {
|
|
57913
58088
|
return true;
|
|
57914
58089
|
}
|
|
57915
58090
|
return false;
|
|
@@ -61527,10 +61702,10 @@ var ksuid2 = /^[A-Za-z0-9]{27}$/;
|
|
|
61527
61702
|
var nanoid2 = /^[a-zA-Z0-9_-]{21}$/;
|
|
61528
61703
|
var duration3 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
61529
61704
|
var guid2 = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
61530
|
-
var uuid3 = (
|
|
61531
|
-
if (!
|
|
61705
|
+
var uuid3 = (version4) => {
|
|
61706
|
+
if (!version4)
|
|
61532
61707
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
|
|
61533
|
-
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${
|
|
61708
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version4}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
61534
61709
|
};
|
|
61535
61710
|
var email2 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
61536
61711
|
var _emoji3 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
@@ -61991,7 +62166,7 @@ class Doc2 {
|
|
|
61991
62166
|
`));
|
|
61992
62167
|
}
|
|
61993
62168
|
}
|
|
61994
|
-
var
|
|
62169
|
+
var version4 = {
|
|
61995
62170
|
major: 4,
|
|
61996
62171
|
minor: 0,
|
|
61997
62172
|
patch: 0
|
|
@@ -62001,7 +62176,7 @@ var $ZodType2 = /* @__PURE__ */ $constructor2("$ZodType", (inst, def) => {
|
|
|
62001
62176
|
inst ?? (inst = {});
|
|
62002
62177
|
inst._zod.def = def;
|
|
62003
62178
|
inst._zod.bag = inst._zod.bag || {};
|
|
62004
|
-
inst._zod.version =
|
|
62179
|
+
inst._zod.version = version4;
|
|
62005
62180
|
const checks2 = [...inst._zod.def.checks ?? []];
|
|
62006
62181
|
if (inst._zod.traits.has("$ZodCheck")) {
|
|
62007
62182
|
checks2.unshift(inst);
|
|
@@ -65306,6 +65481,8 @@ function wrapToolWithLlmReasoning(originalTool) {
|
|
|
65306
65481
|
|
|
65307
65482
|
// src/adapters/claude/claude-framework-adapter/claude-framework-adapter.ts
|
|
65308
65483
|
class ClaudeFrameworkAdapter {
|
|
65484
|
+
agentFramework = "@anthropic-ai/claude-agent-sdk";
|
|
65485
|
+
agentFrameworkVersion = getClaudeAgentSdkVersion();
|
|
65309
65486
|
serializeToolArgs(toolArgs, options) {
|
|
65310
65487
|
if (toolArgs == null) {
|
|
65311
65488
|
return { value: null, redactedPaths: [] };
|
|
@@ -65477,5 +65654,5 @@ export {
|
|
|
65477
65654
|
FriskClaude as Frisk
|
|
65478
65655
|
};
|
|
65479
65656
|
|
|
65480
|
-
//# debugId=
|
|
65657
|
+
//# debugId=62340F95406CA2D464756E2164756E21
|
|
65481
65658
|
//# sourceMappingURL=index.js.map
|