@friskai/frisk-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @friskai/frisk-js might be problematic. Click here for more details.
- package/README.md +316 -0
- package/dist/adapters/index.d.ts +7 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/langchain/frisk-callback-handler.d.ts +55 -0
- package/dist/adapters/langchain/frisk-callback-handler.d.ts.map +1 -0
- package/dist/adapters/langchain/frisk-langchain.d.ts +71 -0
- package/dist/adapters/langchain/frisk-langchain.d.ts.map +1 -0
- package/dist/adapters/langchain/frisk-tool-middleware.d.ts +68 -0
- package/dist/adapters/langchain/frisk-tool-middleware.d.ts.map +1 -0
- package/dist/adapters/langchain/index.d.ts +10 -0
- package/dist/adapters/langchain/index.d.ts.map +1 -0
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts +106 -0
- package/dist/adapters/langchain/langchain-framework-adapter/langchain-framework-adapter.d.ts.map +1 -0
- package/dist/adapters/langchain/langchain-framework-adapter/wrapToolWithLlmReasoning.d.ts +4 -0
- package/dist/adapters/langchain/langchain-framework-adapter/wrapToolWithLlmReasoning.d.ts.map +1 -0
- package/dist/adapters/langchain/langchain-framework-adapter.d.ts +105 -0
- package/dist/adapters/langchain/langchain-framework-adapter.d.ts.map +1 -0
- package/dist/adapters/langchain/types.d.ts +13 -0
- package/dist/adapters/langchain/types.d.ts.map +1 -0
- package/dist/adapters/langchain/wrapToolWithReasoning.d.ts +6 -0
- package/dist/adapters/langchain/wrapToolWithReasoning.d.ts.map +1 -0
- package/dist/core/frisk-options.d.ts +44 -0
- package/dist/core/frisk-options.d.ts.map +1 -0
- package/dist/core/frisk-session.d.ts +82 -0
- package/dist/core/frisk-session.d.ts.map +1 -0
- package/dist/core/frisk.d.ts +130 -0
- package/dist/core/frisk.d.ts.map +1 -0
- package/dist/core/install-graceful-shutdown.d.ts +67 -0
- package/dist/core/install-graceful-shutdown.d.ts.map +1 -0
- package/dist/core/llm-reasoning/constants.d.ts +2 -0
- package/dist/core/llm-reasoning/constants.d.ts.map +1 -0
- package/dist/core/llm-reasoning/removeLlmReasoningArg.d.ts +3 -0
- package/dist/core/llm-reasoning/removeLlmReasoningArg.d.ts.map +1 -0
- package/dist/core/session-registry.d.ts +50 -0
- package/dist/core/session-registry.d.ts.map +1 -0
- package/dist/core/token-manager.d.ts +155 -0
- package/dist/core/token-manager.d.ts.map +1 -0
- package/dist/core/tool-call-span.d.ts +89 -0
- package/dist/core/tool-call-span.d.ts.map +1 -0
- package/dist/core/types.d.ts +103 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/env/index.d.ts +26 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/mocks/mockEnv.d.ts +11 -0
- package/dist/env/mocks/mockEnv.d.ts.map +1 -0
- package/dist/errors/capture-error.d.ts +3 -0
- package/dist/errors/capture-error.d.ts.map +1 -0
- package/dist/errors/index.d.ts +76 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/framework-adapter/base-framework-adapter.d.ts +68 -0
- package/dist/framework-adapter/base-framework-adapter.d.ts.map +1 -0
- package/dist/framework-adapter/framework-adapter.d.ts +105 -0
- package/dist/framework-adapter/framework-adapter.d.ts.map +1 -0
- package/dist/framework-adapter/index.d.ts +12 -0
- package/dist/framework-adapter/index.d.ts.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58377 -0
- package/dist/index.js.map +493 -0
- package/dist/logging/console-logger.d.ts +3 -0
- package/dist/logging/console-logger.d.ts.map +1 -0
- package/dist/logging/create-scoped-logger.d.ts +6 -0
- package/dist/logging/create-scoped-logger.d.ts.map +1 -0
- package/dist/logging/derive-sdk-logger.d.ts +6 -0
- package/dist/logging/derive-sdk-logger.d.ts.map +1 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/log-error.d.ts +3 -0
- package/dist/logging/log-error.d.ts.map +1 -0
- package/dist/logging/types.d.ts +14 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/native-bindings/index.d.ts +18 -0
- package/dist/native-bindings/index.d.ts.map +1 -0
- package/dist/telemetry/constants.d.ts +6 -0
- package/dist/telemetry/constants.d.ts.map +1 -0
- package/dist/telemetry/dynamic-auth-metadata.d.ts +50 -0
- package/dist/telemetry/dynamic-auth-metadata.d.ts.map +1 -0
- package/dist/telemetry/get-otel-sdk.d.ts +18 -0
- package/dist/telemetry/get-otel-sdk.d.ts.map +1 -0
- package/dist/telemetry/get-tracer.d.ts +15 -0
- package/dist/telemetry/get-tracer.d.ts.map +1 -0
- package/dist/telemetry/index.d.ts +7 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/mocks/index.d.ts +6 -0
- package/dist/telemetry/mocks/index.d.ts.map +1 -0
- package/dist/telemetry/mocks/mockTracer.d.ts +38 -0
- package/dist/telemetry/mocks/mockTracer.d.ts.map +1 -0
- package/dist/telemetry/mocks/mockTracerHandle.d.ts +56 -0
- package/dist/telemetry/mocks/mockTracerHandle.d.ts.map +1 -0
- package/dist/telemetry/tracer-handle.d.ts +18 -0
- package/dist/telemetry/tracer-handle.d.ts.map +1 -0
- package/dist/utils/redact.d.ts +57 -0
- package/dist/utils/redact.d.ts.map +1 -0
- package/native/.gitnore.bak +1 -0
- package/native/README.md +55 -0
- package/native/frisk-js.darwin-arm64.node +0 -0
- package/native/index.cjs +580 -0
- package/native/index.d.ts +69 -0
- package/package.json +99 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-logger.d.ts","sourceRoot":"","sources":["../../src/logging/console-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AA0D7C,wBAAgB,aAAa,CAC3B,KAAK,GAAE,QAAiB,EACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,SAAS,CAyCX"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDKLogger } from './index';
|
|
2
|
+
export type Meta = Record<string, unknown>;
|
|
3
|
+
export declare function createScopedLogger(base: SDKLogger, bindings: Meta): SDKLogger & {
|
|
4
|
+
scope: (more: Meta) => ReturnType<typeof createScopedLogger>;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=create-scoped-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-scoped-logger.d.ts","sourceRoot":"","sources":["../../src/logging/create-scoped-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAa1C,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,IAAI,GACb,SAAS,GAAG;IACb,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;CAC7D,CA+BA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-sdk-logger.d.ts","sourceRoot":"","sources":["../../src/logging/derive-sdk-logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE7C,wBAAgB,eAAe,CAC7B,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACf,EACN,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACrC,SAAS,CA4BX"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-error.d.ts","sourceRoot":"","sources":["../../src/logging/log-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,wBAAgB,QAAQ,CACtB,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,EACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAc/B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
2
|
+
export interface SDKLogger {
|
|
3
|
+
trace?: (...args: any[]) => void;
|
|
4
|
+
debug?: (...args: any[]) => void;
|
|
5
|
+
info?: (...args: any[]) => void;
|
|
6
|
+
warn?: (...args: any[]) => void;
|
|
7
|
+
error?: (...args: any[]) => void;
|
|
8
|
+
child?: (bindings: Record<string, unknown>) => SDKLogger;
|
|
9
|
+
}
|
|
10
|
+
export type FriskSDKLogOptions = {
|
|
11
|
+
logger?: SDKLogger;
|
|
12
|
+
logLevel?: LogLevel;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/logging/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;AAE/E,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAChC,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAChC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC/B,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC/B,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAGhC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,SAAS,CAAA;CACzD;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @friskai/frisk-js Native Bindings
|
|
3
|
+
*
|
|
4
|
+
* This module encapsulates all access to the native N-API bindings.
|
|
5
|
+
* Other modules in the SDK should import from here rather than
|
|
6
|
+
* directly accessing the native/ folder.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const nativeBindings: any;
|
|
11
|
+
import type { JsProcessToolCallOptions, JsProcessToolCallResult, FriskHandle as NativeFriskHandleClass, RedactionResult, redactDictionary as redactDictionaryFn } from '../../native';
|
|
12
|
+
export declare const FriskHandle: typeof NativeFriskHandleClass;
|
|
13
|
+
export declare const redactDictionary: typeof redactDictionaryFn;
|
|
14
|
+
export type { JsProcessToolCallOptions as NativeProcessToolCallOptions };
|
|
15
|
+
export type { JsProcessToolCallResult as NativeProcessToolCallResult };
|
|
16
|
+
export type { RedactionResult as NativeRedactionResult };
|
|
17
|
+
export type FriskHandleInstance = InstanceType<typeof NativeFriskHandleClass>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/native-bindings/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH,eAAO,MAAM,cAAc,KAA+B,CAAA;AAG1D,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,IAAI,sBAAsB,EACrC,eAAe,EACf,gBAAgB,IAAI,kBAAkB,EACvC,MAAM,cAAc,CAAA;AAGrB,eAAO,MAAM,WAAW,EAAE,OAAO,sBACL,CAAA;AAC5B,eAAO,MAAM,gBAAgB,EAAE,OAAO,kBACL,CAAA;AAGjC,YAAY,EAAE,wBAAwB,IAAI,4BAA4B,EAAE,CAAA;AACxE,YAAY,EAAE,uBAAuB,IAAI,2BAA2B,EAAE,CAAA;AACtE,YAAY,EAAE,eAAe,IAAI,qBAAqB,EAAE,CAAA;AAGxD,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,OAAO,sBAAsB,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const SPAN_NAME_PROCESS_TOOL_CALL = "process_tool_call";
|
|
2
|
+
export declare const SPAN_NAME_FRISK_SESSION = "frisk_session";
|
|
3
|
+
export declare const TRACER_NAME = "frisk_js_sdk";
|
|
4
|
+
export declare const TRACER_VERSION = "0.1.0";
|
|
5
|
+
export declare const SPAN_ATTRIBUTE_LLM_REASONING = "llm_reasoning";
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/telemetry/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,sBAAsB,CAAA;AAC9D,eAAO,MAAM,uBAAuB,kBAAkB,CAAA;AACtD,eAAO,MAAM,WAAW,iBAAiB,CAAA;AACzC,eAAO,MAAM,cAAc,UAAU,CAAA;AACrC,eAAO,MAAM,4BAA4B,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { OutgoingHttpHeaders } from 'node:http2';
|
|
2
|
+
import { Metadata } from '@grpc/grpc-js';
|
|
3
|
+
/**
|
|
4
|
+
* Token provider function type that returns the current auth token
|
|
5
|
+
*/
|
|
6
|
+
export type TokenProvider = () => string;
|
|
7
|
+
/**
|
|
8
|
+
* A Metadata subclass that dynamically injects the authorization header
|
|
9
|
+
* when the metadata is accessed. This allows token rotation without
|
|
10
|
+
* recreating the exporter.
|
|
11
|
+
*
|
|
12
|
+
* IMPORTANT: The OpenTelemetry OTLP gRPC exporter caches the Metadata object
|
|
13
|
+
* after the first call to metadata(). To support token rotation, this class
|
|
14
|
+
* updates its internal state (via the inherited `set()` method) whenever
|
|
15
|
+
* any accessor method is called, ensuring the authorization header always
|
|
16
|
+
* contains the latest token.
|
|
17
|
+
*
|
|
18
|
+
* The gRPC library internally accesses metadata via methods like get(), getMap(),
|
|
19
|
+
* clone(), etc. We override all of these to first refresh the token.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DynamicAuthMetadata extends Metadata {
|
|
22
|
+
private tokenProvider;
|
|
23
|
+
constructor(tokenProvider: TokenProvider);
|
|
24
|
+
/**
|
|
25
|
+
* Update the internal authorization header with the latest token.
|
|
26
|
+
* This mutates the Metadata object in place.
|
|
27
|
+
*/
|
|
28
|
+
private refreshToken;
|
|
29
|
+
/**
|
|
30
|
+
* Override get() to refresh token before returning values.
|
|
31
|
+
*/
|
|
32
|
+
get(key: string): (string | Buffer)[];
|
|
33
|
+
/**
|
|
34
|
+
* Override getMap() to refresh token before returning the map.
|
|
35
|
+
*/
|
|
36
|
+
getMap(): {
|
|
37
|
+
[key: string]: string | Buffer;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Override clone() to refresh token before cloning.
|
|
41
|
+
* The cloned Metadata will have the current token value.
|
|
42
|
+
*/
|
|
43
|
+
clone(): Metadata;
|
|
44
|
+
/**
|
|
45
|
+
* Override toHttp2Headers() which is used by gRPC when sending requests.
|
|
46
|
+
* This ensures the token is refreshed right before the RPC is made.
|
|
47
|
+
*/
|
|
48
|
+
toHttp2Headers(): OutgoingHttpHeaders;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=dynamic-auth-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-auth-metadata.d.ts","sourceRoot":"","sources":["../../src/telemetry/dynamic-auth-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,MAAM,CAAA;AAExC;;;;;;;;;;;;;GAaG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;IAC/C,OAAO,CAAC,aAAa,CAAe;gBAExB,aAAa,EAAE,aAAa;IAOxC;;;OAGG;IACH,OAAO,CAAC,YAAY;IAKpB;;OAEG;IACM,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;IAK9C;;OAEG;IACM,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;KAAE;IAKrD;;;OAGG;IACM,KAAK,IAAI,QAAQ;IAK1B;;;OAGG;IACM,cAAc,IAAI,mBAAmB;CAI/C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class TracerHandle {
|
|
2
|
+
private telemetryEndpoint;
|
|
3
|
+
private tracerProvider;
|
|
4
|
+
private authToken;
|
|
5
|
+
private tracerName;
|
|
6
|
+
private tracerVersion;
|
|
7
|
+
constructor({ telemetryEndpoint, authToken, tracerName, tracerVersion, }: {
|
|
8
|
+
telemetryEndpoint: string;
|
|
9
|
+
authToken: string;
|
|
10
|
+
tracerName: string;
|
|
11
|
+
tracerVersion: string;
|
|
12
|
+
});
|
|
13
|
+
shutdown(): Promise<void>;
|
|
14
|
+
getTracer(): import("@opentelemetry/api").Tracer;
|
|
15
|
+
updateAuthToken(token: string): void;
|
|
16
|
+
private getTracerProvider;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=get-otel-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-otel-sdk.d.ts","sourceRoot":"","sources":["../../src/telemetry/get-otel-sdk.ts"],"names":[],"mappings":"AAUA,qBAAa,YAAY;IACvB,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAQ;gBAEV,EACjB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,aAAa,GACd,EAAE;QACD,iBAAiB,EAAE,MAAM,CAAA;QACzB,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,EAAE,MAAM,CAAA;KACtB;IAQY,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,SAAS;IAIT,eAAe,CAAC,KAAK,EAAE,MAAM;IAIpC,OAAO,CAAC,iBAAiB;CA8B1B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @friskai/frisk-js Telemetry - Tracer
|
|
3
|
+
*
|
|
4
|
+
* Provides OpenTelemetry tracer for the Frisk SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { type Tracer } from '@opentelemetry/api';
|
|
7
|
+
/**
|
|
8
|
+
* Get the OpenTelemetry tracer for the Frisk SDK.
|
|
9
|
+
*
|
|
10
|
+
* This creates a tracer using the global tracer provider.
|
|
11
|
+
*
|
|
12
|
+
* @returns The OpenTelemetry Tracer instance
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTracer(): Tracer;
|
|
15
|
+
//# sourceMappingURL=get-tracer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tracer.d.ts","sourceRoot":"","sources":["../../src/telemetry/get-tracer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAS,MAAM,oBAAoB,CAAA;AAGvD;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock telemetry utilities for unit tests
|
|
3
|
+
*/
|
|
4
|
+
export { createMockSpan, createMockTracer, getMockTracerInstance, resetMockTracer, setMockTracerInstance, } from './mockTracer';
|
|
5
|
+
export { createMockTracerHandle, injectMockTracerHandle, type MockTracerHandle, } from './mockTracerHandle';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/mocks/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,GACtB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock tracer for unit tests
|
|
3
|
+
*
|
|
4
|
+
* Provides a mock implementation of OpenTelemetry Tracer for testing
|
|
5
|
+
* FriskSession and ToolCallSpan without real telemetry infrastructure.
|
|
6
|
+
*/
|
|
7
|
+
import type { Span, Tracer } from '@opentelemetry/api';
|
|
8
|
+
/**
|
|
9
|
+
* Creates a mock Span that records calls for testing assertions
|
|
10
|
+
*/
|
|
11
|
+
export declare function createMockSpan(): Span & {
|
|
12
|
+
_attributes: Record<string, unknown>;
|
|
13
|
+
_events: Array<{
|
|
14
|
+
name: string;
|
|
15
|
+
attributes?: Record<string, unknown>;
|
|
16
|
+
}>;
|
|
17
|
+
_ended: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates a mock Tracer that returns mock spans
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMockTracer(): Tracer & {
|
|
23
|
+
_spans: Array<ReturnType<typeof createMockSpan>>;
|
|
24
|
+
_lastSpan: ReturnType<typeof createMockSpan> | null;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Get the current mock tracer instance (useful for test assertions)
|
|
28
|
+
*/
|
|
29
|
+
export declare function getMockTracerInstance(): ReturnType<typeof createMockTracer> | null;
|
|
30
|
+
/**
|
|
31
|
+
* Set a custom mock tracer instance
|
|
32
|
+
*/
|
|
33
|
+
export declare function setMockTracerInstance(tracer: ReturnType<typeof createMockTracer>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Reset the mock tracer instance
|
|
36
|
+
*/
|
|
37
|
+
export declare function resetMockTracer(): void;
|
|
38
|
+
//# sourceMappingURL=mockTracer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockTracer.d.ts","sourceRoot":"","sources":["../../../src/telemetry/mocks/mockTracer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAEV,IAAI,EAGJ,MAAM,EACP,MAAM,oBAAoB,CAAA;AAI3B;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,GAAG;IACvC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAA;IACtE,MAAM,EAAE,OAAO,CAAA;CAChB,CA4DA;AAKD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG;IAC3C,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAA;IAChD,SAAS,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,GAAG,IAAI,CAAA;CACpD,CAkDA;AAID;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,CACjD,OAAO,gBAAgB,CACxB,GAAG,IAAI,CAEP;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC1C,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock TracerHandle for unit tests
|
|
3
|
+
*
|
|
4
|
+
* Provides a mock implementation of TracerHandle for testing
|
|
5
|
+
* without real telemetry infrastructure.
|
|
6
|
+
*/
|
|
7
|
+
import { vi } from 'vitest';
|
|
8
|
+
import { createMockTracer } from './mockTracer';
|
|
9
|
+
export type MockTracerHandle = {
|
|
10
|
+
getTracer: ReturnType<typeof vi.fn>;
|
|
11
|
+
updateAuthToken: ReturnType<typeof vi.fn>;
|
|
12
|
+
shutdown: ReturnType<typeof vi.fn>;
|
|
13
|
+
_mockTracer: ReturnType<typeof createMockTracer>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Creates a mock TracerHandle that returns a mock tracer
|
|
17
|
+
*
|
|
18
|
+
* @param mockTracer - Optional pre-created mock tracer to use. If not provided, a new one will be created.
|
|
19
|
+
* @returns A mock TracerHandle instance
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const mockTracerHandle = createMockTracerHandle()
|
|
24
|
+
* // Set it on a frisk instance
|
|
25
|
+
* ;(frisk as any)._tracerHandle = mockTracerHandle
|
|
26
|
+
*
|
|
27
|
+
* // Access the mock tracer for assertions
|
|
28
|
+
* const mockTracer = mockTracerHandle._mockTracer
|
|
29
|
+
* expect(mockTracer.startSpan).toHaveBeenCalled()
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function createMockTracerHandle(mockTracer?: ReturnType<typeof createMockTracer>): MockTracerHandle;
|
|
33
|
+
/**
|
|
34
|
+
* Injects a mock TracerHandle into a Frisk instance for testing
|
|
35
|
+
*
|
|
36
|
+
* This is a convenience function that creates a mock TracerHandle
|
|
37
|
+
* and sets it on the Frisk instance's private `_tracerHandle` property.
|
|
38
|
+
*
|
|
39
|
+
* @param frisk - The Frisk instance to inject the mock into
|
|
40
|
+
* @param mockTracer - Optional pre-created mock tracer to use
|
|
41
|
+
* @returns The created MockTracerHandle for assertions
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const frisk = new Frisk({ apiKey: 'test-key', ... })
|
|
46
|
+
* const mockTracerHandle = injectMockTracerHandle(frisk)
|
|
47
|
+
*
|
|
48
|
+
* // Now frisk.tracerHandle.getTracer() returns a mock tracer
|
|
49
|
+
* const session = frisk.createSession()
|
|
50
|
+
*
|
|
51
|
+
* // Assert on the mock tracer
|
|
52
|
+
* expect(mockTracerHandle._mockTracer.startSpan).toHaveBeenCalled()
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function injectMockTracerHandle(frisk: any, mockTracer?: ReturnType<typeof createMockTracer>): MockTracerHandle;
|
|
56
|
+
//# sourceMappingURL=mockTracerHandle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockTracerHandle.d.ts","sourceRoot":"","sources":["../../../src/telemetry/mocks/mockTracerHandle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IACnC,eAAe,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IACzC,QAAQ,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;IAClC,WAAW,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;CACjD,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC/C,gBAAgB,CASlB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAEpC,KAAK,EAAE,GAAG,EACV,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC/C,gBAAgB,CAIlB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class TracerHandle {
|
|
2
|
+
private telemetryEndpoint;
|
|
3
|
+
private tracerProvider;
|
|
4
|
+
private authToken;
|
|
5
|
+
private tracerName;
|
|
6
|
+
private tracerVersion;
|
|
7
|
+
constructor({ telemetryEndpoint, authToken, tracerName, tracerVersion, }: {
|
|
8
|
+
telemetryEndpoint: string;
|
|
9
|
+
authToken: string;
|
|
10
|
+
tracerName: string;
|
|
11
|
+
tracerVersion: string;
|
|
12
|
+
});
|
|
13
|
+
shutdown(): Promise<void>;
|
|
14
|
+
getTracer(): import("@opentelemetry/api").Tracer;
|
|
15
|
+
updateAuthToken(token: string): void;
|
|
16
|
+
private getTracerProvider;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=tracer-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracer-handle.d.ts","sourceRoot":"","sources":["../../src/telemetry/tracer-handle.ts"],"names":[],"mappings":"AAaA,qBAAa,YAAY;IACvB,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAQ;gBAEV,EACjB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,aAAa,GACd,EAAE;QACD,iBAAiB,EAAE,MAAM,CAAA;QACzB,SAAS,EAAE,MAAM,CAAA;QACjB,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,EAAE,MAAM,CAAA;KACtB;IAQY,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,SAAS;IAIT,eAAe,CAAC,KAAK,EAAE,MAAM;IAIpC,OAAO,CAAC,iBAAiB;CA6B1B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @friskai/frisk-js Redaction Types
|
|
3
|
+
*
|
|
4
|
+
* Types for data redaction functionality.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Redaction option - can be:
|
|
8
|
+
* - `true` to redact all fields
|
|
9
|
+
* - `false` to redact nothing
|
|
10
|
+
* - An array of field names/paths to selectively redact
|
|
11
|
+
*/
|
|
12
|
+
export type RedactOption = boolean | string[];
|
|
13
|
+
/**
|
|
14
|
+
* Result of a dictionary redaction operation
|
|
15
|
+
*/
|
|
16
|
+
export interface RedactedDictionary {
|
|
17
|
+
/**
|
|
18
|
+
* The redacted dictionary value
|
|
19
|
+
*/
|
|
20
|
+
value: Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Paths that were redacted (e.g., ["password", "user.ssn"])
|
|
23
|
+
*/
|
|
24
|
+
redactedPaths: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of a serialized object redaction operation
|
|
28
|
+
*/
|
|
29
|
+
export interface RedactedSerializedObject {
|
|
30
|
+
/**
|
|
31
|
+
* The serialized (JSON string) value, or null if input was null
|
|
32
|
+
*/
|
|
33
|
+
value: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Paths that were redacted
|
|
36
|
+
*/
|
|
37
|
+
redactedPaths: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Combine multiple redact options into one
|
|
41
|
+
*
|
|
42
|
+
* @param options - Array of redact options to combine
|
|
43
|
+
* @returns Combined redact option
|
|
44
|
+
*/
|
|
45
|
+
export declare function combineRedactOptions(...options: (RedactOption | null | undefined)[]): RedactOption;
|
|
46
|
+
/**
|
|
47
|
+
* Redact fields from a dictionary based on the redact option
|
|
48
|
+
*
|
|
49
|
+
* This is a simple implementation that removes redacted fields from an object".
|
|
50
|
+
* For more complex redaction, use the native `redactDictionary` function.
|
|
51
|
+
*
|
|
52
|
+
* @param data - The dictionary to redact
|
|
53
|
+
* @param redactOption - The redaction configuration
|
|
54
|
+
* @returns The redacted dictionary with paths that were redacted
|
|
55
|
+
*/
|
|
56
|
+
export declare function redactDictionarySimple(data: Record<string, unknown>, redactOption?: RedactOption): RedactedDictionary;
|
|
57
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/utils/redact.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,EAAE,CAAA;AAE7C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAE9B;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAEpB;;OAEG;IACH,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,OAAO,EAAE,CAAC,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC9C,YAAY,CAuBd;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,CAAC,EAAE,YAAY,GAC1B,kBAAkB,CAyBpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.node
|
package/native/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Native Bindings
|
|
2
|
+
|
|
3
|
+
This folder contains the native N-API bindings for the `@friskai/frisk-js` package.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
| File | Description | Git Status |
|
|
8
|
+
|------|-------------|------------|
|
|
9
|
+
| `index.cjs` | Platform loader that detects the OS/architecture and loads the correct `.node` binary | ✅ Tracked |
|
|
10
|
+
| `index.d.ts` | TypeScript type definitions for the native bindings | ✅ Tracked |
|
|
11
|
+
| `*.node` | Native binary files (e.g., `frisk-js.darwin-arm64.node`) | ❌ Ignored |
|
|
12
|
+
|
|
13
|
+
## Why are `index.cjs` and `index.d.ts` committed?
|
|
14
|
+
|
|
15
|
+
These files are **auto-generated** by [napi-rs](https://napi.rs/) during the Rust build process (`npm run build:rust`), but they are committed to source control for the following reasons:
|
|
16
|
+
|
|
17
|
+
1. **IDE Support**: The type definitions (`index.d.ts`) enable TypeScript IntelliSense and type checking without requiring a native build.
|
|
18
|
+
|
|
19
|
+
2. **CI/CD Verification**: Type checking can be performed in CI environments that may not have Rust toolchain installed.
|
|
20
|
+
|
|
21
|
+
3. **Stability**: These files only change when the Rust API changes, making them safe to commit.
|
|
22
|
+
|
|
23
|
+
4. **Standard Practice**: This is the recommended approach for napi-rs projects (see [@napi-rs/canvas](https://github.com/nicolebienz/canvas), [@swc/core](https://github.com/swc-project/swc), etc.).
|
|
24
|
+
|
|
25
|
+
## Why is `index.cjs` instead of `index.js`?
|
|
26
|
+
|
|
27
|
+
The parent package uses `"type": "module"` in `package.json`, which means all `.js` files are treated as ES Modules. The napi-rs loader uses CommonJS syntax (`require`, `module.exports`), so we rename it to `.cjs` to ensure Node.js loads it correctly.
|
|
28
|
+
|
|
29
|
+
## Why are `.node` files ignored?
|
|
30
|
+
|
|
31
|
+
The `.node` files are platform-specific native binaries compiled from Rust. They are:
|
|
32
|
+
|
|
33
|
+
- **Large**: Binary files bloat the repository
|
|
34
|
+
- **Platform-specific**: Only the binary for the current platform is needed
|
|
35
|
+
- **Build artifacts**: Regenerated on every `npm run build:rust`
|
|
36
|
+
|
|
37
|
+
## Build Process
|
|
38
|
+
|
|
39
|
+
The `npm run build:rust` command:
|
|
40
|
+
|
|
41
|
+
1. Compiles Rust code to a native `.node` binary
|
|
42
|
+
2. Generates `index.js` (platform loader) and `index.d.ts` (type definitions)
|
|
43
|
+
3. Renames `index.js` to `index.cjs` for ESM compatibility
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Build native bindings
|
|
47
|
+
npm run build:rust
|
|
48
|
+
|
|
49
|
+
# Build TypeScript SDK
|
|
50
|
+
npm run build:ts
|
|
51
|
+
|
|
52
|
+
# Build everything
|
|
53
|
+
npm run build
|
|
54
|
+
```
|
|
55
|
+
|
|
Binary file
|