@friskai/frisk-js 0.2.3 → 0.2.6
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/frisk-claude.d.ts.map +1 -1
- package/dist/adapters/claude/index.js +485 -7
- package/dist/adapters/claude/index.js.map +13 -12
- package/dist/adapters/langchain/frisk-tool-middleware.d.ts +3 -1
- package/dist/adapters/langchain/frisk-tool-middleware.d.ts.map +1 -1
- package/dist/adapters/langchain/index.js +1071 -447
- package/dist/adapters/langchain/index.js.map +17 -13
- 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/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 +3 -2
- package/dist/core/frisk-session.d.ts.map +1 -1
- package/dist/core/frisk.d.ts +9 -2
- package/dist/core/frisk.d.ts.map +1 -1
- package/dist/core/tool-approval-request.d.ts +7 -2
- 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 +31 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- 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 +7 -0
- package/dist/framework-adapter/framework-adapter.d.ts.map +1 -1
- package/dist/index.js +481 -6
- package/dist/index.js.map +11 -10
- package/dist/telemetry/constants.d.ts +2 -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
|
@@ -43715,6 +43715,9 @@ class BaseFrameworkAdapter {
|
|
|
43715
43715
|
const prompt = agentState["prompt"];
|
|
43716
43716
|
return typeof prompt === "string" ? prompt : null;
|
|
43717
43717
|
}
|
|
43718
|
+
extractRegisterToolProperties(_tool) {
|
|
43719
|
+
return null;
|
|
43720
|
+
}
|
|
43718
43721
|
}
|
|
43719
43722
|
// src/framework-adapter/framework-adapter.ts
|
|
43720
43723
|
var DefaultWrapToolOptions = {
|
|
@@ -43849,6 +43852,8 @@ var ATTRIBUTE_NAME_SESSION_ID = "frisk.session.id";
|
|
|
43849
43852
|
var ATTRIBUTE_NAME_REMOTE_SESSION_ID = "frisk.session.remote_id";
|
|
43850
43853
|
var ATTRIBUTE_NAME_LLM_REASONING = "frisk.llm_reasoning";
|
|
43851
43854
|
var ATTRIBUTE_NAME_TOOL_NAME = "frisk.tool.name";
|
|
43855
|
+
var ATTRIBUTE_NAME_FRISK_TOOL_ID = "frisk.tool.id";
|
|
43856
|
+
var ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID = "frisk.tool.version_id";
|
|
43852
43857
|
var ATTRIBUTE_NAME_TOOL_CALL_ID = "frisk.tool_call.id";
|
|
43853
43858
|
var ATTRIBUTE_NAME_TOOL_ARGS_JSON = "frisk.tool.args.json";
|
|
43854
43859
|
var ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON = "frisk.tool.args_redacted_paths.json";
|
|
@@ -47318,10 +47323,92 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
47318
47323
|
}
|
|
47319
47324
|
}
|
|
47320
47325
|
};
|
|
47326
|
+
var numberProcessor = (schema, ctx, _json, _params) => {
|
|
47327
|
+
const json = _json;
|
|
47328
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
47329
|
+
if (typeof format === "string" && format.includes("int"))
|
|
47330
|
+
json.type = "integer";
|
|
47331
|
+
else
|
|
47332
|
+
json.type = "number";
|
|
47333
|
+
if (typeof exclusiveMinimum === "number") {
|
|
47334
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
47335
|
+
json.minimum = exclusiveMinimum;
|
|
47336
|
+
json.exclusiveMinimum = true;
|
|
47337
|
+
} else {
|
|
47338
|
+
json.exclusiveMinimum = exclusiveMinimum;
|
|
47339
|
+
}
|
|
47340
|
+
}
|
|
47341
|
+
if (typeof minimum === "number") {
|
|
47342
|
+
json.minimum = minimum;
|
|
47343
|
+
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
47344
|
+
if (exclusiveMinimum >= minimum)
|
|
47345
|
+
delete json.minimum;
|
|
47346
|
+
else
|
|
47347
|
+
delete json.exclusiveMinimum;
|
|
47348
|
+
}
|
|
47349
|
+
}
|
|
47350
|
+
if (typeof exclusiveMaximum === "number") {
|
|
47351
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
47352
|
+
json.maximum = exclusiveMaximum;
|
|
47353
|
+
json.exclusiveMaximum = true;
|
|
47354
|
+
} else {
|
|
47355
|
+
json.exclusiveMaximum = exclusiveMaximum;
|
|
47356
|
+
}
|
|
47357
|
+
}
|
|
47358
|
+
if (typeof maximum === "number") {
|
|
47359
|
+
json.maximum = maximum;
|
|
47360
|
+
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
47361
|
+
if (exclusiveMaximum <= maximum)
|
|
47362
|
+
delete json.maximum;
|
|
47363
|
+
else
|
|
47364
|
+
delete json.exclusiveMaximum;
|
|
47365
|
+
}
|
|
47366
|
+
}
|
|
47367
|
+
if (typeof multipleOf === "number")
|
|
47368
|
+
json.multipleOf = multipleOf;
|
|
47369
|
+
};
|
|
47370
|
+
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
47371
|
+
json.type = "boolean";
|
|
47372
|
+
};
|
|
47373
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
47374
|
+
if (ctx.unrepresentable === "throw") {
|
|
47375
|
+
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
47376
|
+
}
|
|
47377
|
+
};
|
|
47378
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
47379
|
+
if (ctx.unrepresentable === "throw") {
|
|
47380
|
+
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
47381
|
+
}
|
|
47382
|
+
};
|
|
47383
|
+
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
47384
|
+
if (ctx.target === "openapi-3.0") {
|
|
47385
|
+
json.type = "string";
|
|
47386
|
+
json.nullable = true;
|
|
47387
|
+
json.enum = [null];
|
|
47388
|
+
} else {
|
|
47389
|
+
json.type = "null";
|
|
47390
|
+
}
|
|
47391
|
+
};
|
|
47392
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
47393
|
+
if (ctx.unrepresentable === "throw") {
|
|
47394
|
+
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
47395
|
+
}
|
|
47396
|
+
};
|
|
47397
|
+
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
47398
|
+
if (ctx.unrepresentable === "throw") {
|
|
47399
|
+
throw new Error("Void cannot be represented in JSON Schema");
|
|
47400
|
+
}
|
|
47401
|
+
};
|
|
47321
47402
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
47322
47403
|
json.not = {};
|
|
47323
47404
|
};
|
|
47405
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
47324
47406
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
47407
|
+
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
47408
|
+
if (ctx.unrepresentable === "throw") {
|
|
47409
|
+
throw new Error("Date cannot be represented in JSON Schema");
|
|
47410
|
+
}
|
|
47411
|
+
};
|
|
47325
47412
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
47326
47413
|
const def = schema._zod.def;
|
|
47327
47414
|
const values = getEnumValues(def.entries);
|
|
@@ -47331,16 +47418,109 @@ var enumProcessor = (schema, _ctx, json, _params) => {
|
|
|
47331
47418
|
json.type = "string";
|
|
47332
47419
|
json.enum = values;
|
|
47333
47420
|
};
|
|
47421
|
+
var literalProcessor = (schema, ctx, json, _params) => {
|
|
47422
|
+
const def = schema._zod.def;
|
|
47423
|
+
const vals = [];
|
|
47424
|
+
for (const val of def.values) {
|
|
47425
|
+
if (val === undefined) {
|
|
47426
|
+
if (ctx.unrepresentable === "throw") {
|
|
47427
|
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
47428
|
+
} else {}
|
|
47429
|
+
} else if (typeof val === "bigint") {
|
|
47430
|
+
if (ctx.unrepresentable === "throw") {
|
|
47431
|
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
47432
|
+
} else {
|
|
47433
|
+
vals.push(Number(val));
|
|
47434
|
+
}
|
|
47435
|
+
} else {
|
|
47436
|
+
vals.push(val);
|
|
47437
|
+
}
|
|
47438
|
+
}
|
|
47439
|
+
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
47440
|
+
const val = vals[0];
|
|
47441
|
+
json.type = val === null ? "null" : typeof val;
|
|
47442
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
47443
|
+
json.enum = [val];
|
|
47444
|
+
} else {
|
|
47445
|
+
json.const = val;
|
|
47446
|
+
}
|
|
47447
|
+
} else {
|
|
47448
|
+
if (vals.every((v) => typeof v === "number"))
|
|
47449
|
+
json.type = "number";
|
|
47450
|
+
if (vals.every((v) => typeof v === "string"))
|
|
47451
|
+
json.type = "string";
|
|
47452
|
+
if (vals.every((v) => typeof v === "boolean"))
|
|
47453
|
+
json.type = "boolean";
|
|
47454
|
+
if (vals.every((v) => v === null))
|
|
47455
|
+
json.type = "null";
|
|
47456
|
+
json.enum = vals;
|
|
47457
|
+
}
|
|
47458
|
+
};
|
|
47459
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
47460
|
+
if (ctx.unrepresentable === "throw") {
|
|
47461
|
+
throw new Error("NaN cannot be represented in JSON Schema");
|
|
47462
|
+
}
|
|
47463
|
+
};
|
|
47464
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
47465
|
+
const _json = json;
|
|
47466
|
+
const pattern = schema._zod.pattern;
|
|
47467
|
+
if (!pattern)
|
|
47468
|
+
throw new Error("Pattern not found in template literal");
|
|
47469
|
+
_json.type = "string";
|
|
47470
|
+
_json.pattern = pattern.source;
|
|
47471
|
+
};
|
|
47472
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
47473
|
+
const _json = json;
|
|
47474
|
+
const file = {
|
|
47475
|
+
type: "string",
|
|
47476
|
+
format: "binary",
|
|
47477
|
+
contentEncoding: "binary"
|
|
47478
|
+
};
|
|
47479
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
47480
|
+
if (minimum !== undefined)
|
|
47481
|
+
file.minLength = minimum;
|
|
47482
|
+
if (maximum !== undefined)
|
|
47483
|
+
file.maxLength = maximum;
|
|
47484
|
+
if (mime) {
|
|
47485
|
+
if (mime.length === 1) {
|
|
47486
|
+
file.contentMediaType = mime[0];
|
|
47487
|
+
Object.assign(_json, file);
|
|
47488
|
+
} else {
|
|
47489
|
+
Object.assign(_json, file);
|
|
47490
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
47491
|
+
}
|
|
47492
|
+
} else {
|
|
47493
|
+
Object.assign(_json, file);
|
|
47494
|
+
}
|
|
47495
|
+
};
|
|
47496
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
47497
|
+
json.type = "boolean";
|
|
47498
|
+
};
|
|
47334
47499
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
47335
47500
|
if (ctx.unrepresentable === "throw") {
|
|
47336
47501
|
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
47337
47502
|
}
|
|
47338
47503
|
};
|
|
47504
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
47505
|
+
if (ctx.unrepresentable === "throw") {
|
|
47506
|
+
throw new Error("Function types cannot be represented in JSON Schema");
|
|
47507
|
+
}
|
|
47508
|
+
};
|
|
47339
47509
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
47340
47510
|
if (ctx.unrepresentable === "throw") {
|
|
47341
47511
|
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
47342
47512
|
}
|
|
47343
47513
|
};
|
|
47514
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
47515
|
+
if (ctx.unrepresentable === "throw") {
|
|
47516
|
+
throw new Error("Map cannot be represented in JSON Schema");
|
|
47517
|
+
}
|
|
47518
|
+
};
|
|
47519
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
47520
|
+
if (ctx.unrepresentable === "throw") {
|
|
47521
|
+
throw new Error("Set cannot be represented in JSON Schema");
|
|
47522
|
+
}
|
|
47523
|
+
};
|
|
47344
47524
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
47345
47525
|
const json = _json;
|
|
47346
47526
|
const def = schema._zod.def;
|
|
@@ -47418,6 +47598,84 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
47418
47598
|
];
|
|
47419
47599
|
json.allOf = allOf;
|
|
47420
47600
|
};
|
|
47601
|
+
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
47602
|
+
const json = _json;
|
|
47603
|
+
const def = schema._zod.def;
|
|
47604
|
+
json.type = "array";
|
|
47605
|
+
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
47606
|
+
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
47607
|
+
const prefixItems = def.items.map((x, i) => process2(x, ctx, {
|
|
47608
|
+
...params,
|
|
47609
|
+
path: [...params.path, prefixPath, i]
|
|
47610
|
+
}));
|
|
47611
|
+
const rest = def.rest ? process2(def.rest, ctx, {
|
|
47612
|
+
...params,
|
|
47613
|
+
path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
|
|
47614
|
+
}) : null;
|
|
47615
|
+
if (ctx.target === "draft-2020-12") {
|
|
47616
|
+
json.prefixItems = prefixItems;
|
|
47617
|
+
if (rest) {
|
|
47618
|
+
json.items = rest;
|
|
47619
|
+
}
|
|
47620
|
+
} else if (ctx.target === "openapi-3.0") {
|
|
47621
|
+
json.items = {
|
|
47622
|
+
anyOf: prefixItems
|
|
47623
|
+
};
|
|
47624
|
+
if (rest) {
|
|
47625
|
+
json.items.anyOf.push(rest);
|
|
47626
|
+
}
|
|
47627
|
+
json.minItems = prefixItems.length;
|
|
47628
|
+
if (!rest) {
|
|
47629
|
+
json.maxItems = prefixItems.length;
|
|
47630
|
+
}
|
|
47631
|
+
} else {
|
|
47632
|
+
json.items = prefixItems;
|
|
47633
|
+
if (rest) {
|
|
47634
|
+
json.additionalItems = rest;
|
|
47635
|
+
}
|
|
47636
|
+
}
|
|
47637
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
47638
|
+
if (typeof minimum === "number")
|
|
47639
|
+
json.minItems = minimum;
|
|
47640
|
+
if (typeof maximum === "number")
|
|
47641
|
+
json.maxItems = maximum;
|
|
47642
|
+
};
|
|
47643
|
+
var recordProcessor = (schema, ctx, _json, params) => {
|
|
47644
|
+
const json = _json;
|
|
47645
|
+
const def = schema._zod.def;
|
|
47646
|
+
json.type = "object";
|
|
47647
|
+
const keyType = def.keyType;
|
|
47648
|
+
const keyBag = keyType._zod.bag;
|
|
47649
|
+
const patterns = keyBag?.patterns;
|
|
47650
|
+
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
47651
|
+
const valueSchema = process2(def.valueType, ctx, {
|
|
47652
|
+
...params,
|
|
47653
|
+
path: [...params.path, "patternProperties", "*"]
|
|
47654
|
+
});
|
|
47655
|
+
json.patternProperties = {};
|
|
47656
|
+
for (const pattern of patterns) {
|
|
47657
|
+
json.patternProperties[pattern.source] = valueSchema;
|
|
47658
|
+
}
|
|
47659
|
+
} else {
|
|
47660
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
47661
|
+
json.propertyNames = process2(def.keyType, ctx, {
|
|
47662
|
+
...params,
|
|
47663
|
+
path: [...params.path, "propertyNames"]
|
|
47664
|
+
});
|
|
47665
|
+
}
|
|
47666
|
+
json.additionalProperties = process2(def.valueType, ctx, {
|
|
47667
|
+
...params,
|
|
47668
|
+
path: [...params.path, "additionalProperties"]
|
|
47669
|
+
});
|
|
47670
|
+
}
|
|
47671
|
+
const keyValues = keyType._zod.values;
|
|
47672
|
+
if (keyValues) {
|
|
47673
|
+
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
47674
|
+
if (validKeyValues.length > 0) {
|
|
47675
|
+
json.required = validKeyValues;
|
|
47676
|
+
}
|
|
47677
|
+
}
|
|
47678
|
+
};
|
|
47421
47679
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
47422
47680
|
const def = schema._zod.def;
|
|
47423
47681
|
const inner = process2(def.innerType, ctx, params);
|
|
@@ -47477,12 +47735,99 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
47477
47735
|
seen.ref = def.innerType;
|
|
47478
47736
|
json.readOnly = true;
|
|
47479
47737
|
};
|
|
47738
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
47739
|
+
const def = schema._zod.def;
|
|
47740
|
+
process2(def.innerType, ctx, params);
|
|
47741
|
+
const seen = ctx.seen.get(schema);
|
|
47742
|
+
seen.ref = def.innerType;
|
|
47743
|
+
};
|
|
47480
47744
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
47481
47745
|
const def = schema._zod.def;
|
|
47482
47746
|
process2(def.innerType, ctx, params);
|
|
47483
47747
|
const seen = ctx.seen.get(schema);
|
|
47484
47748
|
seen.ref = def.innerType;
|
|
47485
47749
|
};
|
|
47750
|
+
var lazyProcessor = (schema, ctx, _json, params) => {
|
|
47751
|
+
const innerType = schema._zod.innerType;
|
|
47752
|
+
process2(innerType, ctx, params);
|
|
47753
|
+
const seen = ctx.seen.get(schema);
|
|
47754
|
+
seen.ref = innerType;
|
|
47755
|
+
};
|
|
47756
|
+
var allProcessors = {
|
|
47757
|
+
string: stringProcessor,
|
|
47758
|
+
number: numberProcessor,
|
|
47759
|
+
boolean: booleanProcessor,
|
|
47760
|
+
bigint: bigintProcessor,
|
|
47761
|
+
symbol: symbolProcessor,
|
|
47762
|
+
null: nullProcessor,
|
|
47763
|
+
undefined: undefinedProcessor,
|
|
47764
|
+
void: voidProcessor,
|
|
47765
|
+
never: neverProcessor,
|
|
47766
|
+
any: anyProcessor,
|
|
47767
|
+
unknown: unknownProcessor,
|
|
47768
|
+
date: dateProcessor,
|
|
47769
|
+
enum: enumProcessor,
|
|
47770
|
+
literal: literalProcessor,
|
|
47771
|
+
nan: nanProcessor,
|
|
47772
|
+
template_literal: templateLiteralProcessor,
|
|
47773
|
+
file: fileProcessor,
|
|
47774
|
+
success: successProcessor,
|
|
47775
|
+
custom: customProcessor,
|
|
47776
|
+
function: functionProcessor,
|
|
47777
|
+
transform: transformProcessor,
|
|
47778
|
+
map: mapProcessor,
|
|
47779
|
+
set: setProcessor,
|
|
47780
|
+
array: arrayProcessor,
|
|
47781
|
+
object: objectProcessor,
|
|
47782
|
+
union: unionProcessor,
|
|
47783
|
+
intersection: intersectionProcessor,
|
|
47784
|
+
tuple: tupleProcessor,
|
|
47785
|
+
record: recordProcessor,
|
|
47786
|
+
nullable: nullableProcessor,
|
|
47787
|
+
nonoptional: nonoptionalProcessor,
|
|
47788
|
+
default: defaultProcessor,
|
|
47789
|
+
prefault: prefaultProcessor,
|
|
47790
|
+
catch: catchProcessor,
|
|
47791
|
+
pipe: pipeProcessor,
|
|
47792
|
+
readonly: readonlyProcessor,
|
|
47793
|
+
promise: promiseProcessor,
|
|
47794
|
+
optional: optionalProcessor,
|
|
47795
|
+
lazy: lazyProcessor
|
|
47796
|
+
};
|
|
47797
|
+
function toJSONSchema(input, params) {
|
|
47798
|
+
if ("_idmap" in input) {
|
|
47799
|
+
const registry2 = input;
|
|
47800
|
+
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
47801
|
+
const defs = {};
|
|
47802
|
+
for (const entry of registry2._idmap.entries()) {
|
|
47803
|
+
const [_, schema] = entry;
|
|
47804
|
+
process2(schema, ctx2);
|
|
47805
|
+
}
|
|
47806
|
+
const schemas = {};
|
|
47807
|
+
const external = {
|
|
47808
|
+
registry: registry2,
|
|
47809
|
+
uri: params?.uri,
|
|
47810
|
+
defs
|
|
47811
|
+
};
|
|
47812
|
+
ctx2.external = external;
|
|
47813
|
+
for (const entry of registry2._idmap.entries()) {
|
|
47814
|
+
const [key, schema] = entry;
|
|
47815
|
+
extractDefs(ctx2, schema);
|
|
47816
|
+
schemas[key] = finalize(ctx2, schema);
|
|
47817
|
+
}
|
|
47818
|
+
if (Object.keys(defs).length > 0) {
|
|
47819
|
+
const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
47820
|
+
schemas.__shared = {
|
|
47821
|
+
[defsSegment]: defs
|
|
47822
|
+
};
|
|
47823
|
+
}
|
|
47824
|
+
return { schemas };
|
|
47825
|
+
}
|
|
47826
|
+
const ctx = initializeContext({ ...params, processors: allProcessors });
|
|
47827
|
+
process2(input, ctx);
|
|
47828
|
+
extractDefs(ctx, input);
|
|
47829
|
+
return finalize(ctx, input);
|
|
47830
|
+
}
|
|
47486
47831
|
// ../../node_modules/zod/v4/classic/iso.js
|
|
47487
47832
|
var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
47488
47833
|
$ZodISODateTime.init(inst, def);
|
|
@@ -48155,6 +48500,7 @@ function resolveRedactionOptions(options) {
|
|
|
48155
48500
|
class ToolCallSpan {
|
|
48156
48501
|
adapter;
|
|
48157
48502
|
toolCall;
|
|
48503
|
+
friskToolId;
|
|
48158
48504
|
agentState;
|
|
48159
48505
|
parent;
|
|
48160
48506
|
tracer;
|
|
@@ -48163,10 +48509,13 @@ class ToolCallSpan {
|
|
|
48163
48509
|
_startTimeNs = null;
|
|
48164
48510
|
_traceContextCarrier = null;
|
|
48165
48511
|
sessionId;
|
|
48512
|
+
friskToolVersionId;
|
|
48166
48513
|
constructor({
|
|
48167
48514
|
sessionId,
|
|
48168
48515
|
adapter,
|
|
48169
48516
|
toolCall,
|
|
48517
|
+
friskToolId,
|
|
48518
|
+
friskToolVersionId,
|
|
48170
48519
|
agentState,
|
|
48171
48520
|
parent,
|
|
48172
48521
|
tracer,
|
|
@@ -48175,6 +48524,8 @@ class ToolCallSpan {
|
|
|
48175
48524
|
this.sessionId = sessionId;
|
|
48176
48525
|
this.adapter = adapter;
|
|
48177
48526
|
this.toolCall = toolCall;
|
|
48527
|
+
this.friskToolId = friskToolId ?? null;
|
|
48528
|
+
this.friskToolVersionId = friskToolVersionId ?? null;
|
|
48178
48529
|
this.agentState = agentState;
|
|
48179
48530
|
this.parent = parent;
|
|
48180
48531
|
this.tracer = tracer;
|
|
@@ -48243,6 +48594,10 @@ class ToolCallSpan {
|
|
|
48243
48594
|
attributes: {
|
|
48244
48595
|
[ATTRIBUTE_NAME_SESSION_ID]: this.sessionId,
|
|
48245
48596
|
[ATTRIBUTE_NAME_TOOL_NAME]: this.toolCall.name,
|
|
48597
|
+
...this.friskToolId !== null ? { [ATTRIBUTE_NAME_FRISK_TOOL_ID]: this.friskToolId } : {},
|
|
48598
|
+
...this.friskToolVersionId !== null ? {
|
|
48599
|
+
[ATTRIBUTE_NAME_FRISK_TOOL_VERSION_ID]: this.friskToolVersionId
|
|
48600
|
+
} : {},
|
|
48246
48601
|
[ATTRIBUTE_NAME_TOOL_CALL_ID]: this.toolCall.id,
|
|
48247
48602
|
[ATTRIBUTE_NAME_TOOL_ARGS_JSON]: redactedToolArgsResult.value ?? "",
|
|
48248
48603
|
[ATTRIBUTE_NAME_TOOL_ARGS_REDACTED_PATHS_JSON]: JSON.stringify(redactedToolArgsResult.redactedPaths),
|
|
@@ -48306,10 +48661,13 @@ class FriskSession {
|
|
|
48306
48661
|
toolCall,
|
|
48307
48662
|
agentState
|
|
48308
48663
|
}) {
|
|
48664
|
+
const registeredTool = this.frisk.getRegisteredTool(toolCall.name);
|
|
48309
48665
|
const toolCallSpan = new ToolCallSpan({
|
|
48310
48666
|
sessionId: this.id,
|
|
48311
48667
|
adapter: this.frisk.adapter,
|
|
48312
48668
|
toolCall,
|
|
48669
|
+
friskToolId: registeredTool?.id ?? null,
|
|
48670
|
+
friskToolVersionId: registeredTool?.versionId ?? null,
|
|
48313
48671
|
agentState,
|
|
48314
48672
|
parent: this.rootSpan,
|
|
48315
48673
|
tracer: this.tracer,
|
|
@@ -48395,6 +48753,7 @@ var ToolApprovalStatus;
|
|
|
48395
48753
|
ToolApprovalStatus2["APPROVED"] = "APPROVED";
|
|
48396
48754
|
ToolApprovalStatus2["REJECTED"] = "REJECTED";
|
|
48397
48755
|
ToolApprovalStatus2["CANCELED"] = "CANCELED";
|
|
48756
|
+
ToolApprovalStatus2["EXPIRED"] = "EXPIRED";
|
|
48398
48757
|
})(ToolApprovalStatus ||= {});
|
|
48399
48758
|
function getTimeoutSignal() {
|
|
48400
48759
|
if (typeof AbortSignal === "undefined") {
|
|
@@ -48492,6 +48851,8 @@ async function safeReadErrorBody(response) {
|
|
|
48492
48851
|
async function getOrCreateToolApprovalRequest({
|
|
48493
48852
|
toolCallId,
|
|
48494
48853
|
toolName,
|
|
48854
|
+
toolId,
|
|
48855
|
+
toolVersionId,
|
|
48495
48856
|
policyId,
|
|
48496
48857
|
policyVersionId,
|
|
48497
48858
|
sessionId,
|
|
@@ -48504,7 +48865,9 @@ async function getOrCreateToolApprovalRequest({
|
|
|
48504
48865
|
policyId,
|
|
48505
48866
|
policyVersionId,
|
|
48506
48867
|
sessionId,
|
|
48507
|
-
toolName
|
|
48868
|
+
toolName,
|
|
48869
|
+
...toolId == null ? {} : { toolId },
|
|
48870
|
+
...toolVersionId == null ? {} : { toolVersionId }
|
|
48508
48871
|
};
|
|
48509
48872
|
try {
|
|
48510
48873
|
logger.debug?.(`Creating tool approval request for tool call ${toolCallId}`);
|
|
@@ -48537,7 +48900,9 @@ async function getOrCreateManyToolApprovalRequests({
|
|
|
48537
48900
|
toolCallId: input.toolCallId,
|
|
48538
48901
|
policyId: input.policyId,
|
|
48539
48902
|
policyVersionId: input.policyVersionId,
|
|
48540
|
-
toolName: input.toolName
|
|
48903
|
+
toolName: input.toolName,
|
|
48904
|
+
toolId: input.toolId ?? null,
|
|
48905
|
+
toolVersionId: input.toolVersionId ?? null
|
|
48541
48906
|
})),
|
|
48542
48907
|
agentId: "unknown",
|
|
48543
48908
|
organizationId: "unknown",
|
|
@@ -48615,6 +48980,89 @@ async function cancelManyToolApprovalRequests({
|
|
|
48615
48980
|
}
|
|
48616
48981
|
}
|
|
48617
48982
|
|
|
48983
|
+
// src/core/tool-registry.ts
|
|
48984
|
+
function buildRegisterToolsEndpoint(apiBaseUrl) {
|
|
48985
|
+
return new URL("/tool-registry/register-tools", apiBaseUrl).toString();
|
|
48986
|
+
}
|
|
48987
|
+
function parseRegisterToolsResponse(responseJson) {
|
|
48988
|
+
if (!Array.isArray(responseJson)) {
|
|
48989
|
+
throw new TypeError("registerTools response must be an array");
|
|
48990
|
+
}
|
|
48991
|
+
const toolNameToId = {};
|
|
48992
|
+
for (const [index, item] of responseJson.entries()) {
|
|
48993
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
48994
|
+
throw new TypeError(`registerTools response item at index ${index} must be an object`);
|
|
48995
|
+
}
|
|
48996
|
+
const { id: toolId, name: toolName } = item;
|
|
48997
|
+
if (typeof toolId !== "string" || toolId.length === 0) {
|
|
48998
|
+
throw new TypeError(`registerTools response item at index ${index} is missing a valid id`);
|
|
48999
|
+
}
|
|
49000
|
+
if (typeof toolName !== "string" || toolName.length === 0) {
|
|
49001
|
+
throw new TypeError(`registerTools response item at index ${index} is missing a valid name`);
|
|
49002
|
+
}
|
|
49003
|
+
toolNameToId[toolName] = item;
|
|
49004
|
+
}
|
|
49005
|
+
return toolNameToId;
|
|
49006
|
+
}
|
|
49007
|
+
|
|
49008
|
+
class ToolRegistry {
|
|
49009
|
+
initialized = Promise.resolve(true);
|
|
49010
|
+
apiBaseUrl;
|
|
49011
|
+
getAccessToken;
|
|
49012
|
+
logger;
|
|
49013
|
+
toolNameToId = new Map;
|
|
49014
|
+
constructor({ apiBaseUrl, getAccessToken, logger: logger2 }) {
|
|
49015
|
+
this.apiBaseUrl = apiBaseUrl;
|
|
49016
|
+
this.getAccessToken = getAccessToken;
|
|
49017
|
+
this.logger = logger2;
|
|
49018
|
+
}
|
|
49019
|
+
getRegisteredTool(toolName) {
|
|
49020
|
+
return this.toolNameToId.get(toolName) ?? null;
|
|
49021
|
+
}
|
|
49022
|
+
registerTools(properties) {
|
|
49023
|
+
const propertiesList = [...properties];
|
|
49024
|
+
if (propertiesList.length === 0) {
|
|
49025
|
+
this.initialized = Promise.resolve(true);
|
|
49026
|
+
return;
|
|
49027
|
+
}
|
|
49028
|
+
this.initialized = this.executeRegisterTools(propertiesList);
|
|
49029
|
+
this.initialized;
|
|
49030
|
+
}
|
|
49031
|
+
async executeRegisterTools(properties) {
|
|
49032
|
+
try {
|
|
49033
|
+
const accessToken = await this.getAccessToken();
|
|
49034
|
+
const response = await fetch(buildRegisterToolsEndpoint(this.apiBaseUrl), {
|
|
49035
|
+
method: "POST",
|
|
49036
|
+
headers: {
|
|
49037
|
+
Authorization: `Bearer ${accessToken}`,
|
|
49038
|
+
"Content-Type": "application/json"
|
|
49039
|
+
},
|
|
49040
|
+
body: JSON.stringify({
|
|
49041
|
+
properties: properties.map((property) => ({
|
|
49042
|
+
name: property.name,
|
|
49043
|
+
description: property.description,
|
|
49044
|
+
inputJsonSchema: property.inputJsonSchema,
|
|
49045
|
+
outputJsonSchema: property.outputJsonSchema,
|
|
49046
|
+
responseFormat: property.responseFormat
|
|
49047
|
+
}))
|
|
49048
|
+
})
|
|
49049
|
+
});
|
|
49050
|
+
if (!response.ok) {
|
|
49051
|
+
this.logger?.error?.(`Failed to register tools: HTTP ${response.status} ${await response.text()}`);
|
|
49052
|
+
return true;
|
|
49053
|
+
}
|
|
49054
|
+
const responseJson = await response.json();
|
|
49055
|
+
const registerToolsResponse = parseRegisterToolsResponse(responseJson);
|
|
49056
|
+
for (const [toolName, tool] of Object.entries(registerToolsResponse)) {
|
|
49057
|
+
this.toolNameToId.set(toolName, tool);
|
|
49058
|
+
}
|
|
49059
|
+
} catch (error) {
|
|
49060
|
+
this.logger?.error?.(`Failed to register tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
49061
|
+
}
|
|
49062
|
+
return true;
|
|
49063
|
+
}
|
|
49064
|
+
}
|
|
49065
|
+
|
|
48618
49066
|
// src/core/frisk.ts
|
|
48619
49067
|
class Frisk {
|
|
48620
49068
|
redaction;
|
|
@@ -48628,6 +49076,14 @@ class Frisk {
|
|
|
48628
49076
|
_adapter;
|
|
48629
49077
|
_friskHandle = null;
|
|
48630
49078
|
_tracingManager = null;
|
|
49079
|
+
_toolRegistry;
|
|
49080
|
+
wrapToolsCalled = false;
|
|
49081
|
+
get toolRegistrationComplete() {
|
|
49082
|
+
if (!this.wrapToolsCalled) {
|
|
49083
|
+
return Promise.resolve(true);
|
|
49084
|
+
}
|
|
49085
|
+
return this._toolRegistry.initialized;
|
|
49086
|
+
}
|
|
48631
49087
|
static async connect(options) {
|
|
48632
49088
|
const instance = new this(options);
|
|
48633
49089
|
await instance.connect();
|
|
@@ -48661,6 +49117,11 @@ class Frisk {
|
|
|
48661
49117
|
logLevel: this.logLevel
|
|
48662
49118
|
}
|
|
48663
49119
|
});
|
|
49120
|
+
this._toolRegistry = new ToolRegistry({
|
|
49121
|
+
apiBaseUrl: baseUrl,
|
|
49122
|
+
getAccessToken: async () => this.accessTokenProvider.getAccessToken(),
|
|
49123
|
+
logger: this.logger
|
|
49124
|
+
});
|
|
48664
49125
|
const otlpEndpoint = options?.otlpEndpoint ?? getEnv(FRISK_TELEMETRY_ENDPOINT, FRISK_TELEMETRY_ENDPOINT_DEFAULT);
|
|
48665
49126
|
if (!otlpEndpoint) {
|
|
48666
49127
|
throw new MissingOtlpEndpointError;
|
|
@@ -48720,10 +49181,16 @@ class Frisk {
|
|
|
48720
49181
|
return this._adapter.normalizeToolCall(toolCall);
|
|
48721
49182
|
}
|
|
48722
49183
|
wrapTools(tools, options = DefaultWrapToolOptions) {
|
|
49184
|
+
this.wrapToolsCalled = true;
|
|
49185
|
+
const toolList = [...tools];
|
|
49186
|
+
const registerToolProperties = toolList.map((tool) => this._adapter.extractRegisterToolProperties?.(tool)).filter((properties) => properties !== null && properties !== undefined);
|
|
49187
|
+
if (registerToolProperties.length > 0) {
|
|
49188
|
+
this._toolRegistry.registerTools(registerToolProperties);
|
|
49189
|
+
}
|
|
48723
49190
|
if (this._adapter.wrapTools) {
|
|
48724
|
-
return this._adapter.wrapTools(
|
|
49191
|
+
return this._adapter.wrapTools(toolList, options);
|
|
48725
49192
|
}
|
|
48726
|
-
return
|
|
49193
|
+
return toolList;
|
|
48727
49194
|
}
|
|
48728
49195
|
wrapTool(tool, options = DefaultWrapToolOptions) {
|
|
48729
49196
|
if (this._adapter.wrapTool) {
|
|
@@ -48739,6 +49206,9 @@ class Frisk {
|
|
|
48739
49206
|
this.friskHandle.updateAuthToken(authToken);
|
|
48740
49207
|
this.tracingManager.updateAuthToken(authToken);
|
|
48741
49208
|
}
|
|
49209
|
+
getRegisteredTool(toolName) {
|
|
49210
|
+
return this._toolRegistry.getRegisteredTool(toolName);
|
|
49211
|
+
}
|
|
48742
49212
|
decideToolCall({
|
|
48743
49213
|
toolCall,
|
|
48744
49214
|
agentState,
|
|
@@ -48747,7 +49217,8 @@ class Frisk {
|
|
|
48747
49217
|
const id = toolCall.id ?? v4();
|
|
48748
49218
|
const argsJson = toolCall.args ? JSON.stringify(removeLlmReasoningArg(toolCall.args)) : null;
|
|
48749
49219
|
const stateJson = agentState ? JSON.stringify(agentState) : null;
|
|
48750
|
-
const
|
|
49220
|
+
const registeredTool = this.getRegisteredTool(toolCall.name);
|
|
49221
|
+
const coreResult = this.friskHandle.process(toolCall.name, registeredTool?.id ?? null, registeredTool?.versionId ?? null, argsJson, stateJson, id, this.redaction, traceContextCarrier);
|
|
48751
49222
|
const outcome = coreResult.decision === "allow" ? "allow" /* ALLOW */ : coreResult.decision === "deny" ? "deny" /* DENY */ : coreResult.decision === "escalate" ? "escalate" /* ESCALATE */ : "error" /* ERROR */;
|
|
48752
49223
|
return {
|
|
48753
49224
|
outcome,
|
|
@@ -48760,6 +49231,8 @@ class Frisk {
|
|
|
48760
49231
|
async getOrCreateToolApprovalRequest({
|
|
48761
49232
|
toolCallId,
|
|
48762
49233
|
toolName,
|
|
49234
|
+
toolId,
|
|
49235
|
+
toolVersionId,
|
|
48763
49236
|
policyId,
|
|
48764
49237
|
policyVersionId,
|
|
48765
49238
|
sessionId
|
|
@@ -48767,6 +49240,8 @@ class Frisk {
|
|
|
48767
49240
|
return getOrCreateToolApprovalRequest({
|
|
48768
49241
|
toolCallId,
|
|
48769
49242
|
toolName,
|
|
49243
|
+
toolId,
|
|
49244
|
+
toolVersionId,
|
|
48770
49245
|
policyId,
|
|
48771
49246
|
policyVersionId,
|
|
48772
49247
|
sessionId,
|
|
@@ -64889,6 +65364,9 @@ class ClaudeFrameworkAdapter {
|
|
|
64889
65364
|
}
|
|
64890
65365
|
return result;
|
|
64891
65366
|
}
|
|
65367
|
+
extractRegisterToolProperties(_tool) {
|
|
65368
|
+
return null;
|
|
65369
|
+
}
|
|
64892
65370
|
}
|
|
64893
65371
|
|
|
64894
65372
|
// src/adapters/claude/resolve-claude-tool-name.ts
|
|
@@ -64986,7 +65464,7 @@ class FriskClaude extends Frisk {
|
|
|
64986
65464
|
return session;
|
|
64987
65465
|
}
|
|
64988
65466
|
wrapTools(tools, options = DefaultWrapToolOptions) {
|
|
64989
|
-
return
|
|
65467
|
+
return super.wrapTools(tools, options);
|
|
64990
65468
|
}
|
|
64991
65469
|
wrapTool(tool2, options = DefaultWrapToolOptions) {
|
|
64992
65470
|
return this.adapter.wrapTool(tool2, options);
|
|
@@ -64999,5 +65477,5 @@ export {
|
|
|
64999
65477
|
FriskClaude as Frisk
|
|
65000
65478
|
};
|
|
65001
65479
|
|
|
65002
|
-
//# debugId=
|
|
65480
|
+
//# debugId=FB271C75D2E12BDA64756E2164756E21
|
|
65003
65481
|
//# sourceMappingURL=index.js.map
|