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