@friskai/frisk-js 0.2.4 → 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 +4 -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/frisk-claude.d.ts.map +1 -1
- package/dist/adapters/claude/index.js +694 -40
- package/dist/adapters/claude/index.js.map +18 -12
- 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/frisk-tool-middleware.d.ts.map +1 -1
- package/dist/adapters/langchain/index.js +24147 -23226
- package/dist/adapters/langchain/index.js.map +77 -68
- 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 +4 -0
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts.map +1 -1
- package/dist/adapters/langchain/langchain-framework-adapter/normalize-to-json-schema.d.ts +3 -0
- package/dist/adapters/langchain/langchain-framework-adapter/normalize-to-json-schema.d.ts.map +1 -0
- package/dist/core/frisk-session.d.ts +6 -3
- package/dist/core/frisk-session.d.ts.map +1 -1
- package/dist/core/frisk.d.ts +15 -4
- 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-approval-request.d.ts +5 -1
- package/dist/core/tool-approval-request.d.ts.map +1 -1
- package/dist/core/tool-call-span.d.ts +5 -1
- package/dist/core/tool-call-span.d.ts.map +1 -1
- package/dist/core/tool-registry.d.ts +35 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/framework-adapter/base-framework-adapter.d.ts +4 -0
- package/dist/framework-adapter/base-framework-adapter.d.ts.map +1 -1
- package/dist/framework-adapter/framework-adapter.d.ts +9 -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 +651 -20
- package/dist/index.js.map +15 -10
- package/dist/telemetry/constants.d.ts +5 -0
- package/dist/telemetry/constants.d.ts.map +1 -1
- 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 +52 -52
- package/native/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -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: [] };
|
|
@@ -43715,6 +43717,9 @@ class BaseFrameworkAdapter {
|
|
|
43715
43717
|
const prompt = agentState["prompt"];
|
|
43716
43718
|
return typeof prompt === "string" ? prompt : null;
|
|
43717
43719
|
}
|
|
43720
|
+
extractRegisterToolProperties(_tool) {
|
|
43721
|
+
return null;
|
|
43722
|
+
}
|
|
43718
43723
|
}
|
|
43719
43724
|
// src/framework-adapter/framework-adapter.ts
|
|
43720
43725
|
var DefaultWrapToolOptions = {
|
|
@@ -43843,12 +43848,15 @@ var redactDictionary = nativeBindings.redactDictionary;
|
|
|
43843
43848
|
var TRACER_NAME = "frisk_js_sdk";
|
|
43844
43849
|
var TRACER_VERSION = "0.1.0";
|
|
43845
43850
|
var SPAN_NAME_DECIDE_TOOL_CALL = "frisk.tool_call.decide";
|
|
43851
|
+
var SPAN_NAME_OBSERVE_TOOL_CALL = "frisk.tool_call.observation";
|
|
43846
43852
|
var SPAN_NAME_FRISK_SESSION = "frisk.session";
|
|
43847
43853
|
var ATTRIBUTE_NAME_SESSION_PROMPT = "frisk.session.prompt";
|
|
43848
43854
|
var ATTRIBUTE_NAME_SESSION_ID = "frisk.session.id";
|
|
43849
43855
|
var ATTRIBUTE_NAME_REMOTE_SESSION_ID = "frisk.session.remote_id";
|
|
43850
43856
|
var ATTRIBUTE_NAME_LLM_REASONING = "frisk.llm_reasoning";
|
|
43851
43857
|
var ATTRIBUTE_NAME_TOOL_NAME = "frisk.tool.name";
|
|
43858
|
+
var ATTRIBUTE_NAME_FRISK_TOOL_ID = "frisk.tool.id";
|
|
43859
|
+
var ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID = "frisk.tool.version_id";
|
|
43852
43860
|
var ATTRIBUTE_NAME_TOOL_CALL_ID = "frisk.tool_call.id";
|
|
43853
43861
|
var ATTRIBUTE_NAME_TOOL_ARGS_JSON = "frisk.tool.args.json";
|
|
43854
43862
|
var ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON = "frisk.tool.args_redacted_paths.json";
|
|
@@ -43860,6 +43868,8 @@ var ATTRIBUTE_NAME_DECISION_REASON = "frisk.decision.reason";
|
|
|
43860
43868
|
var ATTRIBUTE_NAME_ERROR_TYPE = "error.type";
|
|
43861
43869
|
var ATTRIBUTE_NAME_ERROR_MESSAGE = "error.message";
|
|
43862
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";
|
|
43863
43873
|
// src/telemetry/tracing-manager.ts
|
|
43864
43874
|
var import_grpc_js = __toESM(require_src3(), 1);
|
|
43865
43875
|
var import_exporter_trace_otlp_grpc = __toESM(require_src12(), 1);
|
|
@@ -47318,10 +47328,92 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
47318
47328
|
}
|
|
47319
47329
|
}
|
|
47320
47330
|
};
|
|
47331
|
+
var numberProcessor = (schema, ctx, _json, _params) => {
|
|
47332
|
+
const json = _json;
|
|
47333
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
47334
|
+
if (typeof format === "string" && format.includes("int"))
|
|
47335
|
+
json.type = "integer";
|
|
47336
|
+
else
|
|
47337
|
+
json.type = "number";
|
|
47338
|
+
if (typeof exclusiveMinimum === "number") {
|
|
47339
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
47340
|
+
json.minimum = exclusiveMinimum;
|
|
47341
|
+
json.exclusiveMinimum = true;
|
|
47342
|
+
} else {
|
|
47343
|
+
json.exclusiveMinimum = exclusiveMinimum;
|
|
47344
|
+
}
|
|
47345
|
+
}
|
|
47346
|
+
if (typeof minimum === "number") {
|
|
47347
|
+
json.minimum = minimum;
|
|
47348
|
+
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
47349
|
+
if (exclusiveMinimum >= minimum)
|
|
47350
|
+
delete json.minimum;
|
|
47351
|
+
else
|
|
47352
|
+
delete json.exclusiveMinimum;
|
|
47353
|
+
}
|
|
47354
|
+
}
|
|
47355
|
+
if (typeof exclusiveMaximum === "number") {
|
|
47356
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
47357
|
+
json.maximum = exclusiveMaximum;
|
|
47358
|
+
json.exclusiveMaximum = true;
|
|
47359
|
+
} else {
|
|
47360
|
+
json.exclusiveMaximum = exclusiveMaximum;
|
|
47361
|
+
}
|
|
47362
|
+
}
|
|
47363
|
+
if (typeof maximum === "number") {
|
|
47364
|
+
json.maximum = maximum;
|
|
47365
|
+
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
47366
|
+
if (exclusiveMaximum <= maximum)
|
|
47367
|
+
delete json.maximum;
|
|
47368
|
+
else
|
|
47369
|
+
delete json.exclusiveMaximum;
|
|
47370
|
+
}
|
|
47371
|
+
}
|
|
47372
|
+
if (typeof multipleOf === "number")
|
|
47373
|
+
json.multipleOf = multipleOf;
|
|
47374
|
+
};
|
|
47375
|
+
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
47376
|
+
json.type = "boolean";
|
|
47377
|
+
};
|
|
47378
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
47379
|
+
if (ctx.unrepresentable === "throw") {
|
|
47380
|
+
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
47381
|
+
}
|
|
47382
|
+
};
|
|
47383
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
47384
|
+
if (ctx.unrepresentable === "throw") {
|
|
47385
|
+
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
47386
|
+
}
|
|
47387
|
+
};
|
|
47388
|
+
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
47389
|
+
if (ctx.target === "openapi-3.0") {
|
|
47390
|
+
json.type = "string";
|
|
47391
|
+
json.nullable = true;
|
|
47392
|
+
json.enum = [null];
|
|
47393
|
+
} else {
|
|
47394
|
+
json.type = "null";
|
|
47395
|
+
}
|
|
47396
|
+
};
|
|
47397
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
47398
|
+
if (ctx.unrepresentable === "throw") {
|
|
47399
|
+
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
47400
|
+
}
|
|
47401
|
+
};
|
|
47402
|
+
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
47403
|
+
if (ctx.unrepresentable === "throw") {
|
|
47404
|
+
throw new Error("Void cannot be represented in JSON Schema");
|
|
47405
|
+
}
|
|
47406
|
+
};
|
|
47321
47407
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
47322
47408
|
json.not = {};
|
|
47323
47409
|
};
|
|
47410
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
47324
47411
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
47412
|
+
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
47413
|
+
if (ctx.unrepresentable === "throw") {
|
|
47414
|
+
throw new Error("Date cannot be represented in JSON Schema");
|
|
47415
|
+
}
|
|
47416
|
+
};
|
|
47325
47417
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
47326
47418
|
const def = schema._zod.def;
|
|
47327
47419
|
const values = getEnumValues(def.entries);
|
|
@@ -47331,16 +47423,109 @@ var enumProcessor = (schema, _ctx, json, _params) => {
|
|
|
47331
47423
|
json.type = "string";
|
|
47332
47424
|
json.enum = values;
|
|
47333
47425
|
};
|
|
47426
|
+
var literalProcessor = (schema, ctx, json, _params) => {
|
|
47427
|
+
const def = schema._zod.def;
|
|
47428
|
+
const vals = [];
|
|
47429
|
+
for (const val of def.values) {
|
|
47430
|
+
if (val === undefined) {
|
|
47431
|
+
if (ctx.unrepresentable === "throw") {
|
|
47432
|
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
47433
|
+
} else {}
|
|
47434
|
+
} else if (typeof val === "bigint") {
|
|
47435
|
+
if (ctx.unrepresentable === "throw") {
|
|
47436
|
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
47437
|
+
} else {
|
|
47438
|
+
vals.push(Number(val));
|
|
47439
|
+
}
|
|
47440
|
+
} else {
|
|
47441
|
+
vals.push(val);
|
|
47442
|
+
}
|
|
47443
|
+
}
|
|
47444
|
+
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
47445
|
+
const val = vals[0];
|
|
47446
|
+
json.type = val === null ? "null" : typeof val;
|
|
47447
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
47448
|
+
json.enum = [val];
|
|
47449
|
+
} else {
|
|
47450
|
+
json.const = val;
|
|
47451
|
+
}
|
|
47452
|
+
} else {
|
|
47453
|
+
if (vals.every((v) => typeof v === "number"))
|
|
47454
|
+
json.type = "number";
|
|
47455
|
+
if (vals.every((v) => typeof v === "string"))
|
|
47456
|
+
json.type = "string";
|
|
47457
|
+
if (vals.every((v) => typeof v === "boolean"))
|
|
47458
|
+
json.type = "boolean";
|
|
47459
|
+
if (vals.every((v) => v === null))
|
|
47460
|
+
json.type = "null";
|
|
47461
|
+
json.enum = vals;
|
|
47462
|
+
}
|
|
47463
|
+
};
|
|
47464
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
47465
|
+
if (ctx.unrepresentable === "throw") {
|
|
47466
|
+
throw new Error("NaN cannot be represented in JSON Schema");
|
|
47467
|
+
}
|
|
47468
|
+
};
|
|
47469
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
47470
|
+
const _json = json;
|
|
47471
|
+
const pattern = schema._zod.pattern;
|
|
47472
|
+
if (!pattern)
|
|
47473
|
+
throw new Error("Pattern not found in template literal");
|
|
47474
|
+
_json.type = "string";
|
|
47475
|
+
_json.pattern = pattern.source;
|
|
47476
|
+
};
|
|
47477
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
47478
|
+
const _json = json;
|
|
47479
|
+
const file = {
|
|
47480
|
+
type: "string",
|
|
47481
|
+
format: "binary",
|
|
47482
|
+
contentEncoding: "binary"
|
|
47483
|
+
};
|
|
47484
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
47485
|
+
if (minimum !== undefined)
|
|
47486
|
+
file.minLength = minimum;
|
|
47487
|
+
if (maximum !== undefined)
|
|
47488
|
+
file.maxLength = maximum;
|
|
47489
|
+
if (mime) {
|
|
47490
|
+
if (mime.length === 1) {
|
|
47491
|
+
file.contentMediaType = mime[0];
|
|
47492
|
+
Object.assign(_json, file);
|
|
47493
|
+
} else {
|
|
47494
|
+
Object.assign(_json, file);
|
|
47495
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
47496
|
+
}
|
|
47497
|
+
} else {
|
|
47498
|
+
Object.assign(_json, file);
|
|
47499
|
+
}
|
|
47500
|
+
};
|
|
47501
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
47502
|
+
json.type = "boolean";
|
|
47503
|
+
};
|
|
47334
47504
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
47335
47505
|
if (ctx.unrepresentable === "throw") {
|
|
47336
47506
|
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
47337
47507
|
}
|
|
47338
47508
|
};
|
|
47509
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
47510
|
+
if (ctx.unrepresentable === "throw") {
|
|
47511
|
+
throw new Error("Function types cannot be represented in JSON Schema");
|
|
47512
|
+
}
|
|
47513
|
+
};
|
|
47339
47514
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
47340
47515
|
if (ctx.unrepresentable === "throw") {
|
|
47341
47516
|
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
47342
47517
|
}
|
|
47343
47518
|
};
|
|
47519
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
47520
|
+
if (ctx.unrepresentable === "throw") {
|
|
47521
|
+
throw new Error("Map cannot be represented in JSON Schema");
|
|
47522
|
+
}
|
|
47523
|
+
};
|
|
47524
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
47525
|
+
if (ctx.unrepresentable === "throw") {
|
|
47526
|
+
throw new Error("Set cannot be represented in JSON Schema");
|
|
47527
|
+
}
|
|
47528
|
+
};
|
|
47344
47529
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
47345
47530
|
const json = _json;
|
|
47346
47531
|
const def = schema._zod.def;
|
|
@@ -47418,6 +47603,84 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
47418
47603
|
];
|
|
47419
47604
|
json.allOf = allOf;
|
|
47420
47605
|
};
|
|
47606
|
+
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
47607
|
+
const json = _json;
|
|
47608
|
+
const def = schema._zod.def;
|
|
47609
|
+
json.type = "array";
|
|
47610
|
+
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
47611
|
+
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
47612
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
47613
|
+
...params,
|
|
47614
|
+
path: [...params.path, prefixPath, i]
|
|
47615
|
+
}));
|
|
47616
|
+
const rest = def.rest ? process2(def.rest, ctx, {
|
|
47617
|
+
...params,
|
|
47618
|
+
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
47619
|
+
}) : null;
|
|
47620
|
+
if (ctx.target === "draft-2020-12") {
|
|
47621
|
+
json.prefixItems = prefixItems;
|
|
47622
|
+
if (rest) {
|
|
47623
|
+
json.items = rest;
|
|
47624
|
+
}
|
|
47625
|
+
} else if (ctx.target === "openapi-3.0") {
|
|
47626
|
+
json.items = {
|
|
47627
|
+
anyOf: prefixItems
|
|
47628
|
+
};
|
|
47629
|
+
if (rest) {
|
|
47630
|
+
json.items.anyOf.push(rest);
|
|
47631
|
+
}
|
|
47632
|
+
json.minItems = prefixItems.length;
|
|
47633
|
+
if (!rest) {
|
|
47634
|
+
json.maxItems = prefixItems.length;
|
|
47635
|
+
}
|
|
47636
|
+
} else {
|
|
47637
|
+
json.items = prefixItems;
|
|
47638
|
+
if (rest) {
|
|
47639
|
+
json.additionalItems = rest;
|
|
47640
|
+
}
|
|
47641
|
+
}
|
|
47642
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
47643
|
+
if (typeof minimum === "number")
|
|
47644
|
+
json.minItems = minimum;
|
|
47645
|
+
if (typeof maximum === "number")
|
|
47646
|
+
json.maxItems = maximum;
|
|
47647
|
+
};
|
|
47648
|
+
var recordProcessor = (schema, ctx, _json, params) => {
|
|
47649
|
+
const json = _json;
|
|
47650
|
+
const def = schema._zod.def;
|
|
47651
|
+
json.type = "object";
|
|
47652
|
+
const keyType = def.keyType;
|
|
47653
|
+
const keyBag = keyType._zod.bag;
|
|
47654
|
+
const patterns = keyBag?.patterns;
|
|
47655
|
+
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
47656
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
47657
|
+
...params,
|
|
47658
|
+
path: [...params.path, "patternProperties", "*"]
|
|
47659
|
+
});
|
|
47660
|
+
json.patternProperties = {};
|
|
47661
|
+
for (const pattern of patterns) {
|
|
47662
|
+
json.patternProperties[pattern.source] = valueSchema;
|
|
47663
|
+
}
|
|
47664
|
+
} else {
|
|
47665
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
47666
|
+
json.propertyNames = process2(def.keyType, ctx, {
|
|
47667
|
+
...params,
|
|
47668
|
+
path: [...params.path, "propertyNames"]
|
|
47669
|
+
});
|
|
47670
|
+
}
|
|
47671
|
+
json.additionalProperties = process2(def.valueType, ctx, {
|
|
47672
|
+
...params,
|
|
47673
|
+
path: [...params.path, "additionalProperties"]
|
|
47674
|
+
});
|
|
47675
|
+
}
|
|
47676
|
+
const keyValues = keyType._zod.values;
|
|
47677
|
+
if (keyValues) {
|
|
47678
|
+
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
47679
|
+
if (validKeyValues.length > 0) {
|
|
47680
|
+
json.required = validKeyValues;
|
|
47681
|
+
}
|
|
47682
|
+
}
|
|
47683
|
+
};
|
|
47421
47684
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
47422
47685
|
const def = schema._zod.def;
|
|
47423
47686
|
const inner = process2(def.innerType, ctx, params);
|
|
@@ -47477,12 +47740,99 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
47477
47740
|
seen.ref = def.innerType;
|
|
47478
47741
|
json.readOnly = true;
|
|
47479
47742
|
};
|
|
47743
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
47744
|
+
const def = schema._zod.def;
|
|
47745
|
+
process2(def.innerType, ctx, params);
|
|
47746
|
+
const seen = ctx.seen.get(schema);
|
|
47747
|
+
seen.ref = def.innerType;
|
|
47748
|
+
};
|
|
47480
47749
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
47481
47750
|
const def = schema._zod.def;
|
|
47482
47751
|
process2(def.innerType, ctx, params);
|
|
47483
47752
|
const seen = ctx.seen.get(schema);
|
|
47484
47753
|
seen.ref = def.innerType;
|
|
47485
47754
|
};
|
|
47755
|
+
var lazyProcessor = (schema, ctx, _json, params) => {
|
|
47756
|
+
const innerType = schema._zod.innerType;
|
|
47757
|
+
process2(innerType, ctx, params);
|
|
47758
|
+
const seen = ctx.seen.get(schema);
|
|
47759
|
+
seen.ref = innerType;
|
|
47760
|
+
};
|
|
47761
|
+
var allProcessors = {
|
|
47762
|
+
string: stringProcessor,
|
|
47763
|
+
number: numberProcessor,
|
|
47764
|
+
boolean: booleanProcessor,
|
|
47765
|
+
bigint: bigintProcessor,
|
|
47766
|
+
symbol: symbolProcessor,
|
|
47767
|
+
null: nullProcessor,
|
|
47768
|
+
undefined: undefinedProcessor,
|
|
47769
|
+
void: voidProcessor,
|
|
47770
|
+
never: neverProcessor,
|
|
47771
|
+
any: anyProcessor,
|
|
47772
|
+
unknown: unknownProcessor,
|
|
47773
|
+
date: dateProcessor,
|
|
47774
|
+
enum: enumProcessor,
|
|
47775
|
+
literal: literalProcessor,
|
|
47776
|
+
nan: nanProcessor,
|
|
47777
|
+
template_literal: templateLiteralProcessor,
|
|
47778
|
+
file: fileProcessor,
|
|
47779
|
+
success: successProcessor,
|
|
47780
|
+
custom: customProcessor,
|
|
47781
|
+
function: functionProcessor,
|
|
47782
|
+
transform: transformProcessor,
|
|
47783
|
+
map: mapProcessor,
|
|
47784
|
+
set: setProcessor,
|
|
47785
|
+
array: arrayProcessor,
|
|
47786
|
+
object: objectProcessor,
|
|
47787
|
+
union: unionProcessor,
|
|
47788
|
+
intersection: intersectionProcessor,
|
|
47789
|
+
tuple: tupleProcessor,
|
|
47790
|
+
record: recordProcessor,
|
|
47791
|
+
nullable: nullableProcessor,
|
|
47792
|
+
nonoptional: nonoptionalProcessor,
|
|
47793
|
+
default: defaultProcessor,
|
|
47794
|
+
prefault: prefaultProcessor,
|
|
47795
|
+
catch: catchProcessor,
|
|
47796
|
+
pipe: pipeProcessor,
|
|
47797
|
+
readonly: readonlyProcessor,
|
|
47798
|
+
promise: promiseProcessor,
|
|
47799
|
+
optional: optionalProcessor,
|
|
47800
|
+
lazy: lazyProcessor
|
|
47801
|
+
};
|
|
47802
|
+
function toJSONSchema(input, params) {
|
|
47803
|
+
if ("_idmap" in input) {
|
|
47804
|
+
const registry2 = input;
|
|
47805
|
+
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
47806
|
+
const defs = {};
|
|
47807
|
+
for (const entry of registry2._idmap.entries()) {
|
|
47808
|
+
const [_, schema] = entry;
|
|
47809
|
+
process2(schema, ctx2);
|
|
47810
|
+
}
|
|
47811
|
+
const schemas = {};
|
|
47812
|
+
const external = {
|
|
47813
|
+
registry: registry2,
|
|
47814
|
+
uri: params?.uri,
|
|
47815
|
+
defs
|
|
47816
|
+
};
|
|
47817
|
+
ctx2.external = external;
|
|
47818
|
+
for (const entry of registry2._idmap.entries()) {
|
|
47819
|
+
const [key, schema] = entry;
|
|
47820
|
+
extractDefs(ctx2, schema);
|
|
47821
|
+
schemas[key] = finalize(ctx2, schema);
|
|
47822
|
+
}
|
|
47823
|
+
if (Object.keys(defs).length > 0) {
|
|
47824
|
+
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
47825
|
+
schemas.__shared = {
|
|
47826
|
+
[defsSegment]: defs
|
|
47827
|
+
};
|
|
47828
|
+
}
|
|
47829
|
+
return { schemas };
|
|
47830
|
+
}
|
|
47831
|
+
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
47832
|
+
process2(input, ctx);
|
|
47833
|
+
extractDefs(ctx, input);
|
|
47834
|
+
return finalize(ctx, input);
|
|
47835
|
+
}
|
|
47486
47836
|
// ../../node_modules/zod/v4/classic/iso.js
|
|
47487
47837
|
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
47488
47838
|
$ZodISODateTime.init(inst, def);
|
|
@@ -48155,6 +48505,7 @@ function resolveRedactionOptions(options) {
|
|
|
48155
48505
|
class ToolCallSpan {
|
|
48156
48506
|
adapter;
|
|
48157
48507
|
toolCall;
|
|
48508
|
+
friskToolId;
|
|
48158
48509
|
agentState;
|
|
48159
48510
|
parent;
|
|
48160
48511
|
tracer;
|
|
@@ -48163,10 +48514,13 @@ class ToolCallSpan {
|
|
|
48163
48514
|
_startTimeNs = null;
|
|
48164
48515
|
_traceContextCarrier = null;
|
|
48165
48516
|
sessionId;
|
|
48517
|
+
friskToolVersionId;
|
|
48166
48518
|
constructor({
|
|
48167
48519
|
sessionId,
|
|
48168
48520
|
adapter,
|
|
48169
48521
|
toolCall,
|
|
48522
|
+
friskToolId,
|
|
48523
|
+
friskToolVersionId,
|
|
48170
48524
|
agentState,
|
|
48171
48525
|
parent,
|
|
48172
48526
|
tracer,
|
|
@@ -48175,6 +48529,8 @@ class ToolCallSpan {
|
|
|
48175
48529
|
this.sessionId = sessionId;
|
|
48176
48530
|
this.adapter = adapter;
|
|
48177
48531
|
this.toolCall = toolCall;
|
|
48532
|
+
this.friskToolId = friskToolId ?? null;
|
|
48533
|
+
this.friskToolVersionId = friskToolVersionId ?? null;
|
|
48178
48534
|
this.agentState = agentState;
|
|
48179
48535
|
this.parent = parent;
|
|
48180
48536
|
this.tracer = tracer;
|
|
@@ -48243,6 +48599,10 @@ class ToolCallSpan {
|
|
|
48243
48599
|
attributes: {
|
|
48244
48600
|
[ATTRIBUTE_NAME_SESSION_ID]: this.sessionId,
|
|
48245
48601
|
[ATTRIBUTE_NAME_TOOL_NAME]: this.toolCall.name,
|
|
48602
|
+
...this.friskToolId !== null ? { [ATTRIBUTE_NAME_FRISK_TOOL_ID]: this.friskToolId } : {},
|
|
48603
|
+
...this.friskToolVersionId !== null ? {
|
|
48604
|
+
[ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID]: this.friskToolVersionId
|
|
48605
|
+
} : {},
|
|
48246
48606
|
[ATTRIBUTE_NAME_TOOL_CALL_ID]: this.toolCall.id,
|
|
48247
48607
|
[ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value ?? "",
|
|
48248
48608
|
[ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths),
|
|
@@ -48280,7 +48640,7 @@ var DecisionOutcome;
|
|
|
48280
48640
|
class FriskSession {
|
|
48281
48641
|
frisk;
|
|
48282
48642
|
id;
|
|
48283
|
-
|
|
48643
|
+
_rootSpan = null;
|
|
48284
48644
|
redaction;
|
|
48285
48645
|
tracer;
|
|
48286
48646
|
logger;
|
|
@@ -48296,6 +48656,12 @@ class FriskSession {
|
|
|
48296
48656
|
this.redaction = redact;
|
|
48297
48657
|
this.tracer = tracer;
|
|
48298
48658
|
}
|
|
48659
|
+
get rootSpan() {
|
|
48660
|
+
return this._rootSpan;
|
|
48661
|
+
}
|
|
48662
|
+
getTracer() {
|
|
48663
|
+
return this.tracer;
|
|
48664
|
+
}
|
|
48299
48665
|
get isTracing() {
|
|
48300
48666
|
return this._isTracing;
|
|
48301
48667
|
}
|
|
@@ -48306,12 +48672,15 @@ class FriskSession {
|
|
|
48306
48672
|
toolCall,
|
|
48307
48673
|
agentState
|
|
48308
48674
|
}) {
|
|
48675
|
+
const registeredTool = this.frisk.getRegisteredTool(toolCall.name);
|
|
48309
48676
|
const toolCallSpan = new ToolCallSpan({
|
|
48310
48677
|
sessionId: this.id,
|
|
48311
48678
|
adapter: this.frisk.adapter,
|
|
48312
48679
|
toolCall,
|
|
48680
|
+
friskToolId: registeredTool?.id ?? null,
|
|
48681
|
+
friskToolVersionId: registeredTool?.versionId ?? null,
|
|
48313
48682
|
agentState,
|
|
48314
|
-
parent: this.
|
|
48683
|
+
parent: this._rootSpan,
|
|
48315
48684
|
tracer: this.tracer,
|
|
48316
48685
|
redact: this.redaction
|
|
48317
48686
|
});
|
|
@@ -48369,21 +48738,139 @@ class FriskSession {
|
|
|
48369
48738
|
return span;
|
|
48370
48739
|
}
|
|
48371
48740
|
endTracing() {
|
|
48372
|
-
if (this.
|
|
48373
|
-
this.
|
|
48741
|
+
if (this._rootSpan) {
|
|
48742
|
+
this._rootSpan.end();
|
|
48374
48743
|
}
|
|
48375
48744
|
this._isTracing = false;
|
|
48376
48745
|
const registry2 = SessionRegistry.getInstance();
|
|
48377
48746
|
registry2.unregister(this.id);
|
|
48378
48747
|
}
|
|
48379
48748
|
setRootSpan(span) {
|
|
48380
|
-
this.
|
|
48749
|
+
this._rootSpan = span;
|
|
48381
48750
|
}
|
|
48382
48751
|
static generateSessionId() {
|
|
48383
48752
|
return v4();
|
|
48384
48753
|
}
|
|
48385
48754
|
}
|
|
48386
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
|
+
|
|
48387
48874
|
// src/core/tool-approval-request.ts
|
|
48388
48875
|
var REQUEST_TIMEOUT_MS = 1e4;
|
|
48389
48876
|
var logger = deriveSdkLogger(undefined, {
|
|
@@ -48493,6 +48980,8 @@ async function safeReadErrorBody(response) {
|
|
|
48493
48980
|
async function getOrCreateToolApprovalRequest({
|
|
48494
48981
|
toolCallId,
|
|
48495
48982
|
toolName,
|
|
48983
|
+
toolId,
|
|
48984
|
+
toolVersionId,
|
|
48496
48985
|
policyId,
|
|
48497
48986
|
policyVersionId,
|
|
48498
48987
|
sessionId,
|
|
@@ -48505,7 +48994,9 @@ async function getOrCreateToolApprovalRequest({
|
|
|
48505
48994
|
policyId,
|
|
48506
48995
|
policyVersionId,
|
|
48507
48996
|
sessionId,
|
|
48508
|
-
toolName
|
|
48997
|
+
toolName,
|
|
48998
|
+
...toolId == null ? {} : { toolId },
|
|
48999
|
+
...toolVersionId == null ? {} : { toolVersionId }
|
|
48509
49000
|
};
|
|
48510
49001
|
try {
|
|
48511
49002
|
logger.debug?.(`Creating tool approval request for tool call ${toolCallId}`);
|
|
@@ -48538,7 +49029,9 @@ async function getOrCreateManyToolApprovalRequests({
|
|
|
48538
49029
|
toolCallId: input.toolCallId,
|
|
48539
49030
|
policyId: input.policyId,
|
|
48540
49031
|
policyVersionId: input.policyVersionId,
|
|
48541
|
-
toolName: input.toolName
|
|
49032
|
+
toolName: input.toolName,
|
|
49033
|
+
toolId: input.toolId ?? null,
|
|
49034
|
+
toolVersionId: input.toolVersionId ?? null
|
|
48542
49035
|
})),
|
|
48543
49036
|
agentId: "unknown",
|
|
48544
49037
|
organizationId: "unknown",
|
|
@@ -48616,19 +49109,127 @@ async function cancelManyToolApprovalRequests({
|
|
|
48616
49109
|
}
|
|
48617
49110
|
}
|
|
48618
49111
|
|
|
49112
|
+
// src/core/tool-registry.ts
|
|
49113
|
+
function buildRegisterToolsEndpoint(apiBaseUrl) {
|
|
49114
|
+
return new URL("/tool-registry/register-tools", apiBaseUrl).toString();
|
|
49115
|
+
}
|
|
49116
|
+
function parseRegisterToolsResponse(responseJson) {
|
|
49117
|
+
if (!Array.isArray(responseJson)) {
|
|
49118
|
+
throw new TypeError("registerTools response must be an array");
|
|
49119
|
+
}
|
|
49120
|
+
const toolNameToId = {};
|
|
49121
|
+
for (const [index, item] of responseJson.entries()) {
|
|
49122
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
49123
|
+
throw new TypeError(`registerTools response item at index ${index} must be an object`);
|
|
49124
|
+
}
|
|
49125
|
+
const { id: toolId, name: toolName } = item;
|
|
49126
|
+
if (typeof toolId !== "string" || toolId.length === 0) {
|
|
49127
|
+
throw new TypeError(`registerTools response item at index ${index} is missing a valid id`);
|
|
49128
|
+
}
|
|
49129
|
+
if (typeof toolName !== "string" || toolName.length === 0) {
|
|
49130
|
+
throw new TypeError(`registerTools response item at index ${index} is missing a valid name`);
|
|
49131
|
+
}
|
|
49132
|
+
toolNameToId[toolName] = item;
|
|
49133
|
+
}
|
|
49134
|
+
return toolNameToId;
|
|
49135
|
+
}
|
|
49136
|
+
|
|
49137
|
+
class ToolRegistry {
|
|
49138
|
+
initialized = Promise.resolve(true);
|
|
49139
|
+
apiBaseUrl;
|
|
49140
|
+
getAccessToken;
|
|
49141
|
+
logger;
|
|
49142
|
+
toolNameToId = new Map;
|
|
49143
|
+
constructor({ apiBaseUrl, getAccessToken, logger: logger2 }) {
|
|
49144
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
49145
|
+
this.getAccessToken = getAccessToken;
|
|
49146
|
+
this.logger = logger2;
|
|
49147
|
+
}
|
|
49148
|
+
getRegisteredTool(toolName) {
|
|
49149
|
+
return this.toolNameToId.get(toolName) ?? null;
|
|
49150
|
+
}
|
|
49151
|
+
registerTools({
|
|
49152
|
+
tools,
|
|
49153
|
+
sdkAttributes
|
|
49154
|
+
}) {
|
|
49155
|
+
const toolsList = [...tools];
|
|
49156
|
+
if (toolsList.length === 0 && !sdkAttributes) {
|
|
49157
|
+
this.initialized = Promise.resolve(true);
|
|
49158
|
+
return;
|
|
49159
|
+
}
|
|
49160
|
+
this.initialized = this.executeRegisterTools({
|
|
49161
|
+
tools: toolsList,
|
|
49162
|
+
sdkAttributes
|
|
49163
|
+
});
|
|
49164
|
+
this.initialized;
|
|
49165
|
+
}
|
|
49166
|
+
async executeRegisterTools({
|
|
49167
|
+
tools,
|
|
49168
|
+
sdkAttributes
|
|
49169
|
+
}) {
|
|
49170
|
+
try {
|
|
49171
|
+
const accessToken = await this.getAccessToken();
|
|
49172
|
+
const response = await fetch(buildRegisterToolsEndpoint(this.apiBaseUrl), {
|
|
49173
|
+
method: "POST",
|
|
49174
|
+
headers: {
|
|
49175
|
+
Authorization: `Bearer ${accessToken}`,
|
|
49176
|
+
"Content-Type": "application/json"
|
|
49177
|
+
},
|
|
49178
|
+
body: JSON.stringify({
|
|
49179
|
+
properties: tools.map((property) => ({
|
|
49180
|
+
name: property.name,
|
|
49181
|
+
description: property.description,
|
|
49182
|
+
inputJsonSchema: property.inputJsonSchema,
|
|
49183
|
+
outputJsonSchema: property.outputJsonSchema,
|
|
49184
|
+
responseFormat: property.responseFormat
|
|
49185
|
+
})),
|
|
49186
|
+
sdk: sdkAttributes
|
|
49187
|
+
})
|
|
49188
|
+
});
|
|
49189
|
+
if (!response.ok) {
|
|
49190
|
+
this.logger?.error?.(`Failed to register tools: HTTP ${response.status} ${await response.text()}`);
|
|
49191
|
+
return true;
|
|
49192
|
+
}
|
|
49193
|
+
const responseJson = await response.json();
|
|
49194
|
+
const registerToolsResponse = parseRegisterToolsResponse(responseJson);
|
|
49195
|
+
for (const [toolName, tool] of Object.entries(registerToolsResponse)) {
|
|
49196
|
+
this.toolNameToId.set(toolName, tool);
|
|
49197
|
+
}
|
|
49198
|
+
} catch (error) {
|
|
49199
|
+
this.logger?.error?.(`Failed to register tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
49200
|
+
}
|
|
49201
|
+
return true;
|
|
49202
|
+
}
|
|
49203
|
+
}
|
|
49204
|
+
|
|
48619
49205
|
// src/core/frisk.ts
|
|
48620
49206
|
class Frisk {
|
|
48621
|
-
redaction
|
|
49207
|
+
get redaction() {
|
|
49208
|
+
return this._redaction;
|
|
49209
|
+
}
|
|
49210
|
+
_redaction;
|
|
48622
49211
|
apiBaseUrl;
|
|
48623
49212
|
otlpEndpoint;
|
|
48624
49213
|
accessTokenProvider;
|
|
48625
49214
|
initialized = false;
|
|
48626
49215
|
rootLogger;
|
|
48627
49216
|
logger;
|
|
48628
|
-
|
|
49217
|
+
_logLevel;
|
|
48629
49218
|
_adapter;
|
|
48630
49219
|
_friskHandle = null;
|
|
48631
49220
|
_tracingManager = null;
|
|
49221
|
+
_toolRegistry;
|
|
49222
|
+
sdkAttributes;
|
|
49223
|
+
wrapToolsCalled = false;
|
|
49224
|
+
get toolRegistrationComplete() {
|
|
49225
|
+
if (!this.wrapToolsCalled) {
|
|
49226
|
+
return Promise.resolve(true);
|
|
49227
|
+
}
|
|
49228
|
+
return this._toolRegistry.initialized;
|
|
49229
|
+
}
|
|
49230
|
+
get logLevel() {
|
|
49231
|
+
return this._logLevel;
|
|
49232
|
+
}
|
|
48632
49233
|
static async connect(options) {
|
|
48633
49234
|
const instance = new this(options);
|
|
48634
49235
|
await instance.connect();
|
|
@@ -48638,13 +49239,15 @@ class Frisk {
|
|
|
48638
49239
|
this.rootLogger = deriveSdkLogger(options?.logging, {
|
|
48639
49240
|
sdk: "frisk"
|
|
48640
49241
|
});
|
|
48641
|
-
this.
|
|
49242
|
+
this._logLevel = options?.logging?.logLevel;
|
|
48642
49243
|
this.logger = deriveSdkLogger({
|
|
48643
49244
|
logger: this.rootLogger,
|
|
48644
|
-
logLevel: this.
|
|
49245
|
+
logLevel: this._logLevel
|
|
48645
49246
|
}, {
|
|
48646
49247
|
component: "FriskCore"
|
|
48647
49248
|
});
|
|
49249
|
+
this._adapter = options?.adapter ?? new BaseFrameworkAdapter;
|
|
49250
|
+
this.sdkAttributes = this.getSdkAttributes();
|
|
48648
49251
|
const apiKey = options?.apiKey ?? getEnv(FRISK_API_KEY);
|
|
48649
49252
|
if (!apiKey) {
|
|
48650
49253
|
throw new MissingAPIKeyError;
|
|
@@ -48659,16 +49262,20 @@ class Frisk {
|
|
|
48659
49262
|
baseUrl,
|
|
48660
49263
|
logging: {
|
|
48661
49264
|
logger: this.rootLogger,
|
|
48662
|
-
logLevel: this.
|
|
49265
|
+
logLevel: this._logLevel
|
|
48663
49266
|
}
|
|
48664
49267
|
});
|
|
49268
|
+
this._toolRegistry = new ToolRegistry({
|
|
49269
|
+
apiBaseUrl: baseUrl,
|
|
49270
|
+
getAccessToken: async () => this.accessTokenProvider.getAccessToken(),
|
|
49271
|
+
logger: this.logger
|
|
49272
|
+
});
|
|
48665
49273
|
const otlpEndpoint = options?.otlpEndpoint ?? getEnv(FRISK_TELEMETRY_ENDPOINT, FRISK_TELEMETRY_ENDPOINT_DEFAULT);
|
|
48666
49274
|
if (!otlpEndpoint) {
|
|
48667
49275
|
throw new MissingOtlpEndpointError;
|
|
48668
49276
|
}
|
|
48669
49277
|
this.otlpEndpoint = otlpEndpoint;
|
|
48670
|
-
this.
|
|
48671
|
-
this._adapter = options?.adapter ?? new BaseFrameworkAdapter;
|
|
49278
|
+
this._redaction = resolveRedactionOptions(options?.redact);
|
|
48672
49279
|
}
|
|
48673
49280
|
get friskHandle() {
|
|
48674
49281
|
if (!this._friskHandle) {
|
|
@@ -48706,11 +49313,11 @@ class Frisk {
|
|
|
48706
49313
|
session(metadata) {
|
|
48707
49314
|
const session = new FriskSession({
|
|
48708
49315
|
frisk: this,
|
|
48709
|
-
redact: this.
|
|
49316
|
+
redact: this._redaction,
|
|
48710
49317
|
tracer: this.tracingManager.getTracer(),
|
|
48711
49318
|
logging: {
|
|
48712
49319
|
logger: this.rootLogger,
|
|
48713
|
-
logLevel: this.
|
|
49320
|
+
logLevel: this._logLevel
|
|
48714
49321
|
}
|
|
48715
49322
|
});
|
|
48716
49323
|
const registry2 = SessionRegistry.getInstance();
|
|
@@ -48721,10 +49328,26 @@ class Frisk {
|
|
|
48721
49328
|
return this._adapter.normalizeToolCall(toolCall);
|
|
48722
49329
|
}
|
|
48723
49330
|
wrapTools(tools, options = DefaultWrapToolOptions) {
|
|
49331
|
+
this.wrapToolsCalled = true;
|
|
49332
|
+
const toolList = [...tools];
|
|
49333
|
+
const registerToolProperties = toolList.map((tool) => this._adapter.extractRegisterToolProperties?.(tool)).filter((properties) => properties !== null && properties !== undefined);
|
|
49334
|
+
if (registerToolProperties.length > 0) {
|
|
49335
|
+
this._toolRegistry.registerTools({
|
|
49336
|
+
tools: registerToolProperties,
|
|
49337
|
+
sdkAttributes: this.sdkAttributes
|
|
49338
|
+
});
|
|
49339
|
+
}
|
|
48724
49340
|
if (this._adapter.wrapTools) {
|
|
48725
|
-
return this._adapter.wrapTools(
|
|
49341
|
+
return this._adapter.wrapTools(toolList, options);
|
|
48726
49342
|
}
|
|
48727
|
-
return
|
|
49343
|
+
return toolList;
|
|
49344
|
+
}
|
|
49345
|
+
getSdkAttributes() {
|
|
49346
|
+
return {
|
|
49347
|
+
...getCoreSdkAttributes(),
|
|
49348
|
+
agentFramework: this.adapter.agentFramework ?? null,
|
|
49349
|
+
agentFrameworkVersion: this.adapter.agentFrameworkVersion ?? null
|
|
49350
|
+
};
|
|
48728
49351
|
}
|
|
48729
49352
|
wrapTool(tool, options = DefaultWrapToolOptions) {
|
|
48730
49353
|
if (this._adapter.wrapTool) {
|
|
@@ -48740,6 +49363,9 @@ class Frisk {
|
|
|
48740
49363
|
this.friskHandle.updateAuthToken(authToken);
|
|
48741
49364
|
this.tracingManager.updateAuthToken(authToken);
|
|
48742
49365
|
}
|
|
49366
|
+
getRegisteredTool(toolName) {
|
|
49367
|
+
return this._toolRegistry.getRegisteredTool(toolName);
|
|
49368
|
+
}
|
|
48743
49369
|
decideToolCall({
|
|
48744
49370
|
toolCall,
|
|
48745
49371
|
agentState,
|
|
@@ -48748,7 +49374,8 @@ class Frisk {
|
|
|
48748
49374
|
const id = toolCall.id ?? v4();
|
|
48749
49375
|
const argsJson = toolCall.args ? JSON.stringify(removeLlmReasoningArg(toolCall.args)) : null;
|
|
48750
49376
|
const stateJson = agentState ? JSON.stringify(agentState) : null;
|
|
48751
|
-
const
|
|
49377
|
+
const registeredTool = this.getRegisteredTool(toolCall.name);
|
|
49378
|
+
const coreResult = this.friskHandle.process(toolCall.name, registeredTool?.id ?? null, registeredTool?.versionId ?? null, argsJson, stateJson, id, this._redaction, traceContextCarrier);
|
|
48752
49379
|
const outcome = coreResult.decision === "allow" ? "allow" /* ALLOW */ : coreResult.decision === "deny" ? "deny" /* DENY */ : coreResult.decision === "escalate" ? "escalate" /* ESCALATE */ : "error" /* ERROR */;
|
|
48753
49380
|
return {
|
|
48754
49381
|
outcome,
|
|
@@ -48761,6 +49388,8 @@ class Frisk {
|
|
|
48761
49388
|
async getOrCreateToolApprovalRequest({
|
|
48762
49389
|
toolCallId,
|
|
48763
49390
|
toolName,
|
|
49391
|
+
toolId,
|
|
49392
|
+
toolVersionId,
|
|
48764
49393
|
policyId,
|
|
48765
49394
|
policyVersionId,
|
|
48766
49395
|
sessionId
|
|
@@ -48768,6 +49397,8 @@ class Frisk {
|
|
|
48768
49397
|
return getOrCreateToolApprovalRequest({
|
|
48769
49398
|
toolCallId,
|
|
48770
49399
|
toolName,
|
|
49400
|
+
toolId,
|
|
49401
|
+
toolVersionId,
|
|
48771
49402
|
policyId,
|
|
48772
49403
|
policyVersionId,
|
|
48773
49404
|
sessionId,
|
|
@@ -48809,12 +49440,30 @@ function createFriskToolCallId() {
|
|
|
48809
49440
|
return v4();
|
|
48810
49441
|
}
|
|
48811
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
|
+
|
|
48812
49461
|
// ../../node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
48813
49462
|
import * as fs from "fs";
|
|
48814
49463
|
import { stat as statPromise, open } from "fs/promises";
|
|
48815
|
-
import { join } from "path";
|
|
49464
|
+
import { join as join2 } from "path";
|
|
48816
49465
|
import { homedir } from "os";
|
|
48817
|
-
import { dirname as
|
|
49466
|
+
import { dirname as dirname3, join as join22 } from "path";
|
|
48818
49467
|
import { cwd } from "process";
|
|
48819
49468
|
import { realpathSync as realpathSync2 } from "fs";
|
|
48820
49469
|
import { randomUUID } from "crypto";
|
|
@@ -55533,7 +56182,7 @@ function shouldShowDebugMessage(message, filter) {
|
|
|
55533
56182
|
return shouldShowDebugCategories(categories, filter);
|
|
55534
56183
|
}
|
|
55535
56184
|
function getClaudeConfigHomeDir() {
|
|
55536
|
-
return process.env.CLAUDE_CONFIG_DIR ??
|
|
56185
|
+
return process.env.CLAUDE_CONFIG_DIR ?? join2(homedir(), ".claude");
|
|
55537
56186
|
}
|
|
55538
56187
|
function isEnvTruthy(envVar) {
|
|
55539
56188
|
if (!envVar)
|
|
@@ -55819,8 +56468,8 @@ function getDebugWriter() {
|
|
|
55819
56468
|
debugWriter = createBufferedWriter({
|
|
55820
56469
|
writeFn: (content) => {
|
|
55821
56470
|
const path = getDebugLogPath();
|
|
55822
|
-
if (!getFsImplementation().existsSync(
|
|
55823
|
-
getFsImplementation().mkdirSync(
|
|
56471
|
+
if (!getFsImplementation().existsSync(dirname3(path))) {
|
|
56472
|
+
getFsImplementation().mkdirSync(dirname3(path));
|
|
55824
56473
|
}
|
|
55825
56474
|
getFsImplementation().appendFileSync(path, content);
|
|
55826
56475
|
updateLatestDebugLogSymlink();
|
|
@@ -55853,7 +56502,7 @@ function logForDebugging(message, { level } = {
|
|
|
55853
56502
|
getDebugWriter().write(output);
|
|
55854
56503
|
}
|
|
55855
56504
|
function getDebugLogPath() {
|
|
55856
|
-
return process.env.CLAUDE_CODE_DEBUG_LOGS_DIR ??
|
|
56505
|
+
return process.env.CLAUDE_CODE_DEBUG_LOGS_DIR ?? join22(getClaudeConfigHomeDir(), "debug", `${getSessionId()}.txt`);
|
|
55857
56506
|
}
|
|
55858
56507
|
var updateLatestDebugLogSymlink = memoize_default(() => {
|
|
55859
56508
|
if (process.argv[2] === "--ripgrep") {
|
|
@@ -55861,8 +56510,8 @@ var updateLatestDebugLogSymlink = memoize_default(() => {
|
|
|
55861
56510
|
}
|
|
55862
56511
|
try {
|
|
55863
56512
|
const debugLogPath = getDebugLogPath();
|
|
55864
|
-
const debugLogsDir =
|
|
55865
|
-
const latestSymlinkPath =
|
|
56513
|
+
const debugLogsDir = dirname3(debugLogPath);
|
|
56514
|
+
const latestSymlinkPath = join22(debugLogsDir, "latest");
|
|
55866
56515
|
if (!getFsImplementation().existsSync(debugLogsDir)) {
|
|
55867
56516
|
getFsImplementation().mkdirSync(debugLogsDir);
|
|
55868
56517
|
}
|
|
@@ -57400,11 +58049,11 @@ function datetimeRegex(args) {
|
|
|
57400
58049
|
regex = `${regex}(${opts.join("|")})`;
|
|
57401
58050
|
return new RegExp(`^${regex}$`);
|
|
57402
58051
|
}
|
|
57403
|
-
function isValidIP(ip,
|
|
57404
|
-
if ((
|
|
58052
|
+
function isValidIP(ip, version4) {
|
|
58053
|
+
if ((version4 === "v4" || !version4) && ipv4Regex.test(ip)) {
|
|
57405
58054
|
return true;
|
|
57406
58055
|
}
|
|
57407
|
-
if ((
|
|
58056
|
+
if ((version4 === "v6" || !version4) && ipv6Regex.test(ip)) {
|
|
57408
58057
|
return true;
|
|
57409
58058
|
}
|
|
57410
58059
|
return false;
|
|
@@ -57431,11 +58080,11 @@ function isValidJWT2(jwt, alg) {
|
|
|
57431
58080
|
return false;
|
|
57432
58081
|
}
|
|
57433
58082
|
}
|
|
57434
|
-
function isValidCidr(ip,
|
|
57435
|
-
if ((
|
|
58083
|
+
function isValidCidr(ip, version4) {
|
|
58084
|
+
if ((version4 === "v4" || !version4) && ipv4CidrRegex.test(ip)) {
|
|
57436
58085
|
return true;
|
|
57437
58086
|
}
|
|
57438
|
-
if ((
|
|
58087
|
+
if ((version4 === "v6" || !version4) && ipv6CidrRegex.test(ip)) {
|
|
57439
58088
|
return true;
|
|
57440
58089
|
}
|
|
57441
58090
|
return false;
|
|
@@ -61053,10 +61702,10 @@ var ksuid2 = /^[A-Za-z0-9]{27}$/;
|
|
|
61053
61702
|
var nanoid2 = /^[a-zA-Z0-9_-]{21}$/;
|
|
61054
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)?)?)$/;
|
|
61055
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})$/;
|
|
61056
|
-
var uuid3 = (
|
|
61057
|
-
if (!
|
|
61705
|
+
var uuid3 = (version4) => {
|
|
61706
|
+
if (!version4)
|
|
61058
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)$/;
|
|
61059
|
-
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})$`);
|
|
61060
61709
|
};
|
|
61061
61710
|
var email2 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
61062
61711
|
var _emoji3 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
@@ -61517,7 +62166,7 @@ class Doc2 {
|
|
|
61517
62166
|
`));
|
|
61518
62167
|
}
|
|
61519
62168
|
}
|
|
61520
|
-
var
|
|
62169
|
+
var version4 = {
|
|
61521
62170
|
major: 4,
|
|
61522
62171
|
minor: 0,
|
|
61523
62172
|
patch: 0
|
|
@@ -61527,7 +62176,7 @@ var $ZodType2 = /* @__PURE__ */ $constructor2("$ZodType", (inst, def) => {
|
|
|
61527
62176
|
inst ?? (inst = {});
|
|
61528
62177
|
inst._zod.def = def;
|
|
61529
62178
|
inst._zod.bag = inst._zod.bag || {};
|
|
61530
|
-
inst._zod.version =
|
|
62179
|
+
inst._zod.version = version4;
|
|
61531
62180
|
const checks2 = [...inst._zod.def.checks ?? []];
|
|
61532
62181
|
if (inst._zod.traits.has("$ZodCheck")) {
|
|
61533
62182
|
checks2.unshift(inst);
|
|
@@ -64832,6 +65481,8 @@ function wrapToolWithLlmReasoning(originalTool) {
|
|
|
64832
65481
|
|
|
64833
65482
|
// src/adapters/claude/claude-framework-adapter/claude-framework-adapter.ts
|
|
64834
65483
|
class ClaudeFrameworkAdapter {
|
|
65484
|
+
agentFramework = "@anthropic-ai/claude-agent-sdk";
|
|
65485
|
+
agentFrameworkVersion = getClaudeAgentSdkVersion();
|
|
64835
65486
|
serializeToolArgs(toolArgs, options) {
|
|
64836
65487
|
if (toolArgs == null) {
|
|
64837
65488
|
return { value: null, redactedPaths: [] };
|
|
@@ -64890,6 +65541,9 @@ class ClaudeFrameworkAdapter {
|
|
|
64890
65541
|
}
|
|
64891
65542
|
return result;
|
|
64892
65543
|
}
|
|
65544
|
+
extractRegisterToolProperties(_tool) {
|
|
65545
|
+
return null;
|
|
65546
|
+
}
|
|
64893
65547
|
}
|
|
64894
65548
|
|
|
64895
65549
|
// src/adapters/claude/resolve-claude-tool-name.ts
|
|
@@ -64987,7 +65641,7 @@ class FriskClaude extends Frisk {
|
|
|
64987
65641
|
return session;
|
|
64988
65642
|
}
|
|
64989
65643
|
wrapTools(tools, options = DefaultWrapToolOptions) {
|
|
64990
|
-
return
|
|
65644
|
+
return super.wrapTools(tools, options);
|
|
64991
65645
|
}
|
|
64992
65646
|
wrapTool(tool2, options = DefaultWrapToolOptions) {
|
|
64993
65647
|
return this.adapter.wrapTool(tool2, options);
|
|
@@ -65000,5 +65654,5 @@ export {
|
|
|
65000
65654
|
FriskClaude as Frisk
|
|
65001
65655
|
};
|
|
65002
65656
|
|
|
65003
|
-
//# debugId=
|
|
65657
|
+
//# debugId=62340F95406CA2D464756E2164756E21
|
|
65004
65658
|
//# sourceMappingURL=index.js.map
|