kontext-sdk 0.2.0 → 0.2.1
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/index.d.mts +90 -23
- package/dist/index.d.ts +90 -23
- package/dist/index.js +510 -284
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +510 -284
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -76,6 +76,8 @@ type Chain = 'ethereum' | 'base' | 'polygon' | 'arbitrum' | 'optimism' | 'arc' |
|
|
|
76
76
|
type Token = 'USDC' | 'USDT' | 'DAI' | 'EURC';
|
|
77
77
|
/** SDK operating mode */
|
|
78
78
|
type KontextMode = 'local' | 'cloud';
|
|
79
|
+
/** Log level for the SDK logger */
|
|
80
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
79
81
|
/** Environment configuration */
|
|
80
82
|
type Environment = 'development' | 'staging' | 'production';
|
|
81
83
|
/** Anomaly severity levels */
|
|
@@ -106,8 +108,38 @@ interface KontextConfig {
|
|
|
106
108
|
flushIntervalMs?: number;
|
|
107
109
|
/** Local file output directory for OSS mode */
|
|
108
110
|
localOutputDir?: string;
|
|
111
|
+
/** Minimum log level for SDK output (default: 'warn', or 'debug' if debug=true) */
|
|
112
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
109
113
|
/** Pluggable storage adapter for persistence (default: in-memory) */
|
|
110
114
|
storage?: StorageAdapter;
|
|
115
|
+
/**
|
|
116
|
+
* Optional metadata schema validator. When provided, all metadata passed to
|
|
117
|
+
* `log()`, `logTransaction()`, and `createTask()` will be validated against
|
|
118
|
+
* this schema before being recorded.
|
|
119
|
+
*
|
|
120
|
+
* Accepts any object with a `parse(data: unknown)` method (e.g., a Zod schema).
|
|
121
|
+
* Throws on validation failure, passes through on success.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* import { z } from 'zod';
|
|
126
|
+
*
|
|
127
|
+
* const kontext = Kontext.init({
|
|
128
|
+
* projectId: 'my-app',
|
|
129
|
+
* environment: 'production',
|
|
130
|
+
* metadataSchema: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
metadataSchema?: MetadataValidator;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Interface for metadata validation. Compatible with Zod schemas and any
|
|
138
|
+
* validator that implements a `parse` method.
|
|
139
|
+
*/
|
|
140
|
+
interface MetadataValidator {
|
|
141
|
+
/** Validate and return the metadata. Should throw on invalid data. */
|
|
142
|
+
parse(data: unknown): Record<string, unknown>;
|
|
111
143
|
}
|
|
112
144
|
/** Base action log entry */
|
|
113
145
|
interface ActionLog {
|
|
@@ -583,8 +615,8 @@ interface ComplianceCertificate {
|
|
|
583
615
|
}>;
|
|
584
616
|
/** Reasoning entries (if includeReasoning is true) */
|
|
585
617
|
reasoning: ReasoningEntry[];
|
|
586
|
-
/** SHA-256 hash of the certificate content for verification */
|
|
587
|
-
|
|
618
|
+
/** SHA-256 hash of the certificate content for integrity verification */
|
|
619
|
+
contentHash: string;
|
|
588
620
|
}
|
|
589
621
|
/** Error codes for Kontext SDK */
|
|
590
622
|
declare enum KontextErrorCode {
|
|
@@ -846,6 +878,11 @@ declare class Kontext {
|
|
|
846
878
|
getConfig(): Omit<KontextConfig, 'apiKey'> & {
|
|
847
879
|
apiKey?: string;
|
|
848
880
|
};
|
|
881
|
+
/**
|
|
882
|
+
* Validate metadata against the configured schema, if any.
|
|
883
|
+
* No-op when metadataSchema is not configured.
|
|
884
|
+
*/
|
|
885
|
+
private validateMetadata;
|
|
849
886
|
/**
|
|
850
887
|
* Log a generic agent action.
|
|
851
888
|
*
|
|
@@ -1164,6 +1201,28 @@ declare class UsdcCompliance {
|
|
|
1164
1201
|
* Get the chains supported for USDC compliance monitoring.
|
|
1165
1202
|
*/
|
|
1166
1203
|
static getSupportedChains(): Chain[];
|
|
1204
|
+
/**
|
|
1205
|
+
* Add new sanctioned addresses at runtime.
|
|
1206
|
+
* Normalizes all addresses to lowercase for consistent matching.
|
|
1207
|
+
* Skips addresses that are already in the list.
|
|
1208
|
+
*
|
|
1209
|
+
* @param addresses - Array of Ethereum addresses to add
|
|
1210
|
+
* @returns The count of newly added addresses (excluding duplicates)
|
|
1211
|
+
*/
|
|
1212
|
+
static addSanctionedAddresses(addresses: string[]): number;
|
|
1213
|
+
/**
|
|
1214
|
+
* Replace the entire sanctioned addresses list at runtime.
|
|
1215
|
+
* Clears existing entries and rebuilds from the provided array.
|
|
1216
|
+
*
|
|
1217
|
+
* @param addresses - The new complete list of sanctioned addresses
|
|
1218
|
+
*/
|
|
1219
|
+
static replaceSanctionedAddresses(addresses: string[]): void;
|
|
1220
|
+
/**
|
|
1221
|
+
* Get the current number of addresses in the sanctions list.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns The size of the current sanctions list
|
|
1224
|
+
*/
|
|
1225
|
+
static getSanctionsListSize(): number;
|
|
1167
1226
|
private static checkTokenType;
|
|
1168
1227
|
private static checkChainSupport;
|
|
1169
1228
|
private static checkAddressFormat;
|
|
@@ -2284,10 +2343,12 @@ declare class WebhookManager {
|
|
|
2284
2343
|
setActive(webhookId: string, active: boolean): WebhookConfig | undefined;
|
|
2285
2344
|
/**
|
|
2286
2345
|
* Get all registered webhooks.
|
|
2346
|
+
* Secrets are redacted to prevent accidental exposure in logs or API responses.
|
|
2287
2347
|
*/
|
|
2288
2348
|
getWebhooks(): WebhookConfig[];
|
|
2289
2349
|
/**
|
|
2290
2350
|
* Get a specific webhook by ID.
|
|
2351
|
+
* The secret is redacted to prevent accidental exposure in logs or API responses.
|
|
2291
2352
|
*/
|
|
2292
2353
|
getWebhook(webhookId: string): WebhookConfig | undefined;
|
|
2293
2354
|
/**
|
|
@@ -2327,6 +2388,27 @@ declare class WebhookManager {
|
|
|
2327
2388
|
private deliverToWebhook;
|
|
2328
2389
|
private computeSignature;
|
|
2329
2390
|
private sleep;
|
|
2391
|
+
/**
|
|
2392
|
+
* Verify a webhook signature using constant-time comparison to prevent
|
|
2393
|
+
* timing attacks. Use this in your webhook handler to validate incoming
|
|
2394
|
+
* payloads from Kontext.
|
|
2395
|
+
*
|
|
2396
|
+
* @param payload - The raw JSON payload body (string)
|
|
2397
|
+
* @param signature - The signature from the X-Kontext-Signature header
|
|
2398
|
+
* @param secret - The webhook secret used during registration
|
|
2399
|
+
* @returns Whether the signature is valid
|
|
2400
|
+
*
|
|
2401
|
+
* @example
|
|
2402
|
+
* ```typescript
|
|
2403
|
+
* const isValid = WebhookManager.verifySignature(
|
|
2404
|
+
* req.body, // raw JSON string
|
|
2405
|
+
* req.headers['x-kontext-signature'],
|
|
2406
|
+
* 'my-webhook-secret',
|
|
2407
|
+
* );
|
|
2408
|
+
* if (!isValid) return res.status(401).send('Invalid signature');
|
|
2409
|
+
* ```
|
|
2410
|
+
*/
|
|
2411
|
+
static verifySignature(payload: string, signature: string, secret: string): boolean;
|
|
2330
2412
|
}
|
|
2331
2413
|
|
|
2332
2414
|
/** AI operation types recognized by the Vercel AI SDK middleware. */
|
|
@@ -2481,38 +2563,23 @@ interface KontextAIContext {
|
|
|
2481
2563
|
* ```
|
|
2482
2564
|
*/
|
|
2483
2565
|
declare function kontextMiddleware(kontext: Kontext, options?: KontextAIOptions): {
|
|
2484
|
-
|
|
2485
|
-
* Logs the AI request parameters before the model is invoked.
|
|
2486
|
-
* Captures the operation type, model ID, tool count, and generation settings.
|
|
2487
|
-
*/
|
|
2488
|
-
transformParams: ({ params, type }: {
|
|
2566
|
+
transformParams: (ctx: {
|
|
2489
2567
|
params: Record<string, unknown>;
|
|
2490
2568
|
type: string;
|
|
2491
2569
|
}) => Promise<Record<string, unknown>>;
|
|
2492
|
-
|
|
2493
|
-
* Wraps synchronous generation (`generateText`, `generateObject`).
|
|
2494
|
-
* After the model returns, logs every tool call individually and the
|
|
2495
|
-
* overall response. For financial tools, automatically creates
|
|
2496
|
-
* compliance-tracked transaction records.
|
|
2497
|
-
*/
|
|
2498
|
-
wrapGenerate: ({ doGenerate, params, }: {
|
|
2570
|
+
wrapGenerate: (ctx: {
|
|
2499
2571
|
doGenerate: () => Promise<Record<string, unknown>>;
|
|
2500
2572
|
params: Record<string, unknown>;
|
|
2501
2573
|
}) => Promise<Record<string, unknown>>;
|
|
2502
|
-
|
|
2503
|
-
* Wraps streaming generation (`streamText`).
|
|
2504
|
-
* Pipes the response stream through a transform that monitors for
|
|
2505
|
-
* tool call chunks. On stream completion, logs the overall duration
|
|
2506
|
-
* and any tool calls that occurred during the stream.
|
|
2507
|
-
*/
|
|
2508
|
-
wrapStream: ({ doStream, params, }: {
|
|
2574
|
+
wrapStream: (ctx: {
|
|
2509
2575
|
doStream: () => Promise<{
|
|
2510
2576
|
stream: ReadableStream;
|
|
2511
2577
|
[key: string]: unknown;
|
|
2512
2578
|
}>;
|
|
2513
2579
|
params: Record<string, unknown>;
|
|
2514
2580
|
}) => Promise<{
|
|
2515
|
-
|
|
2581
|
+
[key: string]: unknown;
|
|
2582
|
+
stream: ReadableStream;
|
|
2516
2583
|
}>;
|
|
2517
2584
|
};
|
|
2518
2585
|
/**
|
|
@@ -2625,4 +2692,4 @@ declare function withKontext(handler: (req: Request, ctx: KontextAIContext) => P
|
|
|
2625
2692
|
*/
|
|
2626
2693
|
declare function extractAmount(args: unknown): number | null;
|
|
2627
2694
|
|
|
2628
|
-
export { type AIOperationType, type ActionLog, type AddressScreenResult, type AnomalyCallback, type AnomalyDetectionConfig, type AnomalyEvent, type AnomalyRuleType, type AnomalySeverity, type AnomalyThresholds, type BlockedToolCall, type CCTPAttestationInput, type CCTPHook, type CCTPHookResult, type CCTPMessageStatus, CCTPTransferManager, type CCTPValidationCheck, type CCTPValidationResult, type CCTPVersion, type CTRReport, type Chain, type CircleApiAdapter, type CircleComplianceAdapter, CircleComplianceEngine, type CircleWallet, CircleWalletManager, type CircleWalletOptions, type ComplianceCertificate, type ComplianceCheckResult, type ComplianceCheckSummary, type ComplianceReport, type CompliantTransferInput, type CompliantTransferResult, type ComprehensiveRiskFactor, type ComprehensiveRiskResult, type ConfirmCCTPTransferInput, type ConfirmTaskInput, type CreateKontextAIInput, type CreateKontextAIResult, type CreateTaskInput, type CreateWalletOptions, type CrossChainAuditEntry, type CrossChainTransfer, type DateRange, DigestChain, type DigestLink, type DigestVerification, type DualScreenResult, type Environment, type ExportFormat, type ExportOptions, type ExportResult, type FastTransferValidation, FileStorage, type GasEligibility, type GasEstimate, type GasEstimateInput, type GasSponsorshipLog, type GasStationAdapter, GasStationManager, type GenerateComplianceCertificateInput, type InitiateCCTPTransferInput, type InitiateFastTransferInput, Kontext, type KontextAIContext, type KontextAIOptions, type KontextConfig, KontextError, KontextErrorCode, type KontextMode, type LogActionInput, type LogReasoningInput, type LogTransactionInput, MemoryStorage, type PrecisionTimestamp, type ReasoningEntry, type RegisterWebhookInput, type ReportOptions, type ReportSubject, type ReportType, type RiskAssessmentInput, type RiskFactor, type SARReport, type SanctionsCheckResult, type ScreenTransactionInput, type StorageAdapter, type Task, type TaskEvidence, type TaskStatus, type Token, type TransactionEvaluation, type TransactionRecord, type TrustFactor, type TrustScore, UsdcCompliance, type UsdcComplianceCheck, type WalletBalance, type WalletSet, type WebhookConfig, type WebhookDeliveryResult, type WebhookEventType, WebhookManager, type WebhookPayload, type WebhookRetryConfig, type WithKontextOptions, createKontextAI, extractAmount, kontextMiddleware, kontextWrapModel, verifyExportedChain, withKontext };
|
|
2695
|
+
export { type AIOperationType, type ActionLog, type AddressScreenResult, type AnomalyCallback, type AnomalyDetectionConfig, type AnomalyEvent, type AnomalyRuleType, type AnomalySeverity, type AnomalyThresholds, type BlockedToolCall, type CCTPAttestationInput, type CCTPHook, type CCTPHookResult, type CCTPMessageStatus, CCTPTransferManager, type CCTPValidationCheck, type CCTPValidationResult, type CCTPVersion, type CTRReport, type Chain, type CircleApiAdapter, type CircleComplianceAdapter, CircleComplianceEngine, type CircleWallet, CircleWalletManager, type CircleWalletOptions, type ComplianceCertificate, type ComplianceCheckResult, type ComplianceCheckSummary, type ComplianceReport, type CompliantTransferInput, type CompliantTransferResult, type ComprehensiveRiskFactor, type ComprehensiveRiskResult, type ConfirmCCTPTransferInput, type ConfirmTaskInput, type CreateKontextAIInput, type CreateKontextAIResult, type CreateTaskInput, type CreateWalletOptions, type CrossChainAuditEntry, type CrossChainTransfer, type DateRange, DigestChain, type DigestLink, type DigestVerification, type DualScreenResult, type Environment, type ExportFormat, type ExportOptions, type ExportResult, type FastTransferValidation, FileStorage, type GasEligibility, type GasEstimate, type GasEstimateInput, type GasSponsorshipLog, type GasStationAdapter, GasStationManager, type GenerateComplianceCertificateInput, type InitiateCCTPTransferInput, type InitiateFastTransferInput, Kontext, type KontextAIContext, type KontextAIOptions, type KontextConfig, KontextError, KontextErrorCode, type KontextMode, type LogActionInput, type LogLevel, type LogReasoningInput, type LogTransactionInput, MemoryStorage, type MetadataValidator, type PrecisionTimestamp, type ReasoningEntry, type RegisterWebhookInput, type ReportOptions, type ReportSubject, type ReportType, type RiskAssessmentInput, type RiskFactor, type SARReport, type SanctionsCheckResult, type ScreenTransactionInput, type StorageAdapter, type Task, type TaskEvidence, type TaskStatus, type Token, type TransactionEvaluation, type TransactionRecord, type TrustFactor, type TrustScore, UsdcCompliance, type UsdcComplianceCheck, type WalletBalance, type WalletSet, type WebhookConfig, type WebhookDeliveryResult, type WebhookEventType, WebhookManager, type WebhookPayload, type WebhookRetryConfig, type WithKontextOptions, createKontextAI, extractAmount, kontextMiddleware, kontextWrapModel, verifyExportedChain, withKontext };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ type Chain = 'ethereum' | 'base' | 'polygon' | 'arbitrum' | 'optimism' | 'arc' |
|
|
|
76
76
|
type Token = 'USDC' | 'USDT' | 'DAI' | 'EURC';
|
|
77
77
|
/** SDK operating mode */
|
|
78
78
|
type KontextMode = 'local' | 'cloud';
|
|
79
|
+
/** Log level for the SDK logger */
|
|
80
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
79
81
|
/** Environment configuration */
|
|
80
82
|
type Environment = 'development' | 'staging' | 'production';
|
|
81
83
|
/** Anomaly severity levels */
|
|
@@ -106,8 +108,38 @@ interface KontextConfig {
|
|
|
106
108
|
flushIntervalMs?: number;
|
|
107
109
|
/** Local file output directory for OSS mode */
|
|
108
110
|
localOutputDir?: string;
|
|
111
|
+
/** Minimum log level for SDK output (default: 'warn', or 'debug' if debug=true) */
|
|
112
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
109
113
|
/** Pluggable storage adapter for persistence (default: in-memory) */
|
|
110
114
|
storage?: StorageAdapter;
|
|
115
|
+
/**
|
|
116
|
+
* Optional metadata schema validator. When provided, all metadata passed to
|
|
117
|
+
* `log()`, `logTransaction()`, and `createTask()` will be validated against
|
|
118
|
+
* this schema before being recorded.
|
|
119
|
+
*
|
|
120
|
+
* Accepts any object with a `parse(data: unknown)` method (e.g., a Zod schema).
|
|
121
|
+
* Throws on validation failure, passes through on success.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* import { z } from 'zod';
|
|
126
|
+
*
|
|
127
|
+
* const kontext = Kontext.init({
|
|
128
|
+
* projectId: 'my-app',
|
|
129
|
+
* environment: 'production',
|
|
130
|
+
* metadataSchema: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
metadataSchema?: MetadataValidator;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Interface for metadata validation. Compatible with Zod schemas and any
|
|
138
|
+
* validator that implements a `parse` method.
|
|
139
|
+
*/
|
|
140
|
+
interface MetadataValidator {
|
|
141
|
+
/** Validate and return the metadata. Should throw on invalid data. */
|
|
142
|
+
parse(data: unknown): Record<string, unknown>;
|
|
111
143
|
}
|
|
112
144
|
/** Base action log entry */
|
|
113
145
|
interface ActionLog {
|
|
@@ -583,8 +615,8 @@ interface ComplianceCertificate {
|
|
|
583
615
|
}>;
|
|
584
616
|
/** Reasoning entries (if includeReasoning is true) */
|
|
585
617
|
reasoning: ReasoningEntry[];
|
|
586
|
-
/** SHA-256 hash of the certificate content for verification */
|
|
587
|
-
|
|
618
|
+
/** SHA-256 hash of the certificate content for integrity verification */
|
|
619
|
+
contentHash: string;
|
|
588
620
|
}
|
|
589
621
|
/** Error codes for Kontext SDK */
|
|
590
622
|
declare enum KontextErrorCode {
|
|
@@ -846,6 +878,11 @@ declare class Kontext {
|
|
|
846
878
|
getConfig(): Omit<KontextConfig, 'apiKey'> & {
|
|
847
879
|
apiKey?: string;
|
|
848
880
|
};
|
|
881
|
+
/**
|
|
882
|
+
* Validate metadata against the configured schema, if any.
|
|
883
|
+
* No-op when metadataSchema is not configured.
|
|
884
|
+
*/
|
|
885
|
+
private validateMetadata;
|
|
849
886
|
/**
|
|
850
887
|
* Log a generic agent action.
|
|
851
888
|
*
|
|
@@ -1164,6 +1201,28 @@ declare class UsdcCompliance {
|
|
|
1164
1201
|
* Get the chains supported for USDC compliance monitoring.
|
|
1165
1202
|
*/
|
|
1166
1203
|
static getSupportedChains(): Chain[];
|
|
1204
|
+
/**
|
|
1205
|
+
* Add new sanctioned addresses at runtime.
|
|
1206
|
+
* Normalizes all addresses to lowercase for consistent matching.
|
|
1207
|
+
* Skips addresses that are already in the list.
|
|
1208
|
+
*
|
|
1209
|
+
* @param addresses - Array of Ethereum addresses to add
|
|
1210
|
+
* @returns The count of newly added addresses (excluding duplicates)
|
|
1211
|
+
*/
|
|
1212
|
+
static addSanctionedAddresses(addresses: string[]): number;
|
|
1213
|
+
/**
|
|
1214
|
+
* Replace the entire sanctioned addresses list at runtime.
|
|
1215
|
+
* Clears existing entries and rebuilds from the provided array.
|
|
1216
|
+
*
|
|
1217
|
+
* @param addresses - The new complete list of sanctioned addresses
|
|
1218
|
+
*/
|
|
1219
|
+
static replaceSanctionedAddresses(addresses: string[]): void;
|
|
1220
|
+
/**
|
|
1221
|
+
* Get the current number of addresses in the sanctions list.
|
|
1222
|
+
*
|
|
1223
|
+
* @returns The size of the current sanctions list
|
|
1224
|
+
*/
|
|
1225
|
+
static getSanctionsListSize(): number;
|
|
1167
1226
|
private static checkTokenType;
|
|
1168
1227
|
private static checkChainSupport;
|
|
1169
1228
|
private static checkAddressFormat;
|
|
@@ -2284,10 +2343,12 @@ declare class WebhookManager {
|
|
|
2284
2343
|
setActive(webhookId: string, active: boolean): WebhookConfig | undefined;
|
|
2285
2344
|
/**
|
|
2286
2345
|
* Get all registered webhooks.
|
|
2346
|
+
* Secrets are redacted to prevent accidental exposure in logs or API responses.
|
|
2287
2347
|
*/
|
|
2288
2348
|
getWebhooks(): WebhookConfig[];
|
|
2289
2349
|
/**
|
|
2290
2350
|
* Get a specific webhook by ID.
|
|
2351
|
+
* The secret is redacted to prevent accidental exposure in logs or API responses.
|
|
2291
2352
|
*/
|
|
2292
2353
|
getWebhook(webhookId: string): WebhookConfig | undefined;
|
|
2293
2354
|
/**
|
|
@@ -2327,6 +2388,27 @@ declare class WebhookManager {
|
|
|
2327
2388
|
private deliverToWebhook;
|
|
2328
2389
|
private computeSignature;
|
|
2329
2390
|
private sleep;
|
|
2391
|
+
/**
|
|
2392
|
+
* Verify a webhook signature using constant-time comparison to prevent
|
|
2393
|
+
* timing attacks. Use this in your webhook handler to validate incoming
|
|
2394
|
+
* payloads from Kontext.
|
|
2395
|
+
*
|
|
2396
|
+
* @param payload - The raw JSON payload body (string)
|
|
2397
|
+
* @param signature - The signature from the X-Kontext-Signature header
|
|
2398
|
+
* @param secret - The webhook secret used during registration
|
|
2399
|
+
* @returns Whether the signature is valid
|
|
2400
|
+
*
|
|
2401
|
+
* @example
|
|
2402
|
+
* ```typescript
|
|
2403
|
+
* const isValid = WebhookManager.verifySignature(
|
|
2404
|
+
* req.body, // raw JSON string
|
|
2405
|
+
* req.headers['x-kontext-signature'],
|
|
2406
|
+
* 'my-webhook-secret',
|
|
2407
|
+
* );
|
|
2408
|
+
* if (!isValid) return res.status(401).send('Invalid signature');
|
|
2409
|
+
* ```
|
|
2410
|
+
*/
|
|
2411
|
+
static verifySignature(payload: string, signature: string, secret: string): boolean;
|
|
2330
2412
|
}
|
|
2331
2413
|
|
|
2332
2414
|
/** AI operation types recognized by the Vercel AI SDK middleware. */
|
|
@@ -2481,38 +2563,23 @@ interface KontextAIContext {
|
|
|
2481
2563
|
* ```
|
|
2482
2564
|
*/
|
|
2483
2565
|
declare function kontextMiddleware(kontext: Kontext, options?: KontextAIOptions): {
|
|
2484
|
-
|
|
2485
|
-
* Logs the AI request parameters before the model is invoked.
|
|
2486
|
-
* Captures the operation type, model ID, tool count, and generation settings.
|
|
2487
|
-
*/
|
|
2488
|
-
transformParams: ({ params, type }: {
|
|
2566
|
+
transformParams: (ctx: {
|
|
2489
2567
|
params: Record<string, unknown>;
|
|
2490
2568
|
type: string;
|
|
2491
2569
|
}) => Promise<Record<string, unknown>>;
|
|
2492
|
-
|
|
2493
|
-
* Wraps synchronous generation (`generateText`, `generateObject`).
|
|
2494
|
-
* After the model returns, logs every tool call individually and the
|
|
2495
|
-
* overall response. For financial tools, automatically creates
|
|
2496
|
-
* compliance-tracked transaction records.
|
|
2497
|
-
*/
|
|
2498
|
-
wrapGenerate: ({ doGenerate, params, }: {
|
|
2570
|
+
wrapGenerate: (ctx: {
|
|
2499
2571
|
doGenerate: () => Promise<Record<string, unknown>>;
|
|
2500
2572
|
params: Record<string, unknown>;
|
|
2501
2573
|
}) => Promise<Record<string, unknown>>;
|
|
2502
|
-
|
|
2503
|
-
* Wraps streaming generation (`streamText`).
|
|
2504
|
-
* Pipes the response stream through a transform that monitors for
|
|
2505
|
-
* tool call chunks. On stream completion, logs the overall duration
|
|
2506
|
-
* and any tool calls that occurred during the stream.
|
|
2507
|
-
*/
|
|
2508
|
-
wrapStream: ({ doStream, params, }: {
|
|
2574
|
+
wrapStream: (ctx: {
|
|
2509
2575
|
doStream: () => Promise<{
|
|
2510
2576
|
stream: ReadableStream;
|
|
2511
2577
|
[key: string]: unknown;
|
|
2512
2578
|
}>;
|
|
2513
2579
|
params: Record<string, unknown>;
|
|
2514
2580
|
}) => Promise<{
|
|
2515
|
-
|
|
2581
|
+
[key: string]: unknown;
|
|
2582
|
+
stream: ReadableStream;
|
|
2516
2583
|
}>;
|
|
2517
2584
|
};
|
|
2518
2585
|
/**
|
|
@@ -2625,4 +2692,4 @@ declare function withKontext(handler: (req: Request, ctx: KontextAIContext) => P
|
|
|
2625
2692
|
*/
|
|
2626
2693
|
declare function extractAmount(args: unknown): number | null;
|
|
2627
2694
|
|
|
2628
|
-
export { type AIOperationType, type ActionLog, type AddressScreenResult, type AnomalyCallback, type AnomalyDetectionConfig, type AnomalyEvent, type AnomalyRuleType, type AnomalySeverity, type AnomalyThresholds, type BlockedToolCall, type CCTPAttestationInput, type CCTPHook, type CCTPHookResult, type CCTPMessageStatus, CCTPTransferManager, type CCTPValidationCheck, type CCTPValidationResult, type CCTPVersion, type CTRReport, type Chain, type CircleApiAdapter, type CircleComplianceAdapter, CircleComplianceEngine, type CircleWallet, CircleWalletManager, type CircleWalletOptions, type ComplianceCertificate, type ComplianceCheckResult, type ComplianceCheckSummary, type ComplianceReport, type CompliantTransferInput, type CompliantTransferResult, type ComprehensiveRiskFactor, type ComprehensiveRiskResult, type ConfirmCCTPTransferInput, type ConfirmTaskInput, type CreateKontextAIInput, type CreateKontextAIResult, type CreateTaskInput, type CreateWalletOptions, type CrossChainAuditEntry, type CrossChainTransfer, type DateRange, DigestChain, type DigestLink, type DigestVerification, type DualScreenResult, type Environment, type ExportFormat, type ExportOptions, type ExportResult, type FastTransferValidation, FileStorage, type GasEligibility, type GasEstimate, type GasEstimateInput, type GasSponsorshipLog, type GasStationAdapter, GasStationManager, type GenerateComplianceCertificateInput, type InitiateCCTPTransferInput, type InitiateFastTransferInput, Kontext, type KontextAIContext, type KontextAIOptions, type KontextConfig, KontextError, KontextErrorCode, type KontextMode, type LogActionInput, type LogReasoningInput, type LogTransactionInput, MemoryStorage, type PrecisionTimestamp, type ReasoningEntry, type RegisterWebhookInput, type ReportOptions, type ReportSubject, type ReportType, type RiskAssessmentInput, type RiskFactor, type SARReport, type SanctionsCheckResult, type ScreenTransactionInput, type StorageAdapter, type Task, type TaskEvidence, type TaskStatus, type Token, type TransactionEvaluation, type TransactionRecord, type TrustFactor, type TrustScore, UsdcCompliance, type UsdcComplianceCheck, type WalletBalance, type WalletSet, type WebhookConfig, type WebhookDeliveryResult, type WebhookEventType, WebhookManager, type WebhookPayload, type WebhookRetryConfig, type WithKontextOptions, createKontextAI, extractAmount, kontextMiddleware, kontextWrapModel, verifyExportedChain, withKontext };
|
|
2695
|
+
export { type AIOperationType, type ActionLog, type AddressScreenResult, type AnomalyCallback, type AnomalyDetectionConfig, type AnomalyEvent, type AnomalyRuleType, type AnomalySeverity, type AnomalyThresholds, type BlockedToolCall, type CCTPAttestationInput, type CCTPHook, type CCTPHookResult, type CCTPMessageStatus, CCTPTransferManager, type CCTPValidationCheck, type CCTPValidationResult, type CCTPVersion, type CTRReport, type Chain, type CircleApiAdapter, type CircleComplianceAdapter, CircleComplianceEngine, type CircleWallet, CircleWalletManager, type CircleWalletOptions, type ComplianceCertificate, type ComplianceCheckResult, type ComplianceCheckSummary, type ComplianceReport, type CompliantTransferInput, type CompliantTransferResult, type ComprehensiveRiskFactor, type ComprehensiveRiskResult, type ConfirmCCTPTransferInput, type ConfirmTaskInput, type CreateKontextAIInput, type CreateKontextAIResult, type CreateTaskInput, type CreateWalletOptions, type CrossChainAuditEntry, type CrossChainTransfer, type DateRange, DigestChain, type DigestLink, type DigestVerification, type DualScreenResult, type Environment, type ExportFormat, type ExportOptions, type ExportResult, type FastTransferValidation, FileStorage, type GasEligibility, type GasEstimate, type GasEstimateInput, type GasSponsorshipLog, type GasStationAdapter, GasStationManager, type GenerateComplianceCertificateInput, type InitiateCCTPTransferInput, type InitiateFastTransferInput, Kontext, type KontextAIContext, type KontextAIOptions, type KontextConfig, KontextError, KontextErrorCode, type KontextMode, type LogActionInput, type LogLevel, type LogReasoningInput, type LogTransactionInput, MemoryStorage, type MetadataValidator, type PrecisionTimestamp, type ReasoningEntry, type RegisterWebhookInput, type ReportOptions, type ReportSubject, type ReportType, type RiskAssessmentInput, type RiskFactor, type SARReport, type SanctionsCheckResult, type ScreenTransactionInput, type StorageAdapter, type Task, type TaskEvidence, type TaskStatus, type Token, type TransactionEvaluation, type TransactionRecord, type TrustFactor, type TrustScore, UsdcCompliance, type UsdcComplianceCheck, type WalletBalance, type WalletSet, type WebhookConfig, type WebhookDeliveryResult, type WebhookEventType, WebhookManager, type WebhookPayload, type WebhookRetryConfig, type WithKontextOptions, createKontextAI, extractAmount, kontextMiddleware, kontextWrapModel, verifyExportedChain, withKontext };
|