@sekuire/sdk 0.1.24 → 0.2.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  import * as z from 'zod';
2
- import { Tracer } from '@opentelemetry/api';
3
- import { ExportResult } from '@opentelemetry/core';
4
- import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
5
2
 
6
3
  interface ActivePolicy {
7
4
  policy_id: string;
@@ -49,8 +46,8 @@ interface CustomRule {
49
46
  agents?: string[];
50
47
  };
51
48
  conditions: RuleCondition[];
52
- logic: "any" | "all";
53
- action: "deny" | "warn";
49
+ logic: 'any' | 'all';
50
+ action: 'deny' | 'warn';
54
51
  message: string;
55
52
  }
56
53
  interface RuleCondition {
@@ -59,7 +56,7 @@ interface RuleCondition {
59
56
  value: unknown;
60
57
  case_sensitive?: boolean;
61
58
  }
62
- type ConditionOperator = "contains" | "not_contains" | "equals" | "not_equals" | "starts_with" | "ends_with" | "matches" | "in" | "not_in" | "greater_than" | "less_than";
59
+ type ConditionOperator = 'contains' | 'not_contains' | 'equals' | 'not_equals' | 'starts_with' | 'ends_with' | 'matches' | 'in' | 'not_in' | 'greater_than' | 'less_than';
63
60
  interface PolicyDecision {
64
61
  allowed: boolean;
65
62
  violations: PolicyViolation[];
@@ -634,16 +631,12 @@ declare class AgentIdentity {
634
631
  verify(message: string, signatureHex: string): boolean;
635
632
  }
636
633
 
637
- /**
638
- * 🛡️ Sekuire Logger - Asynchronous Event Logging for TypeScript SDK
639
- *
640
- * Provides batched, fire-and-forget logging to Sekuire Registry API
641
- */
642
634
  type EventType = "tool_execution" | "model_call" | "policy_violation" | "policy_check" | "network_access" | "file_access" | "health";
643
635
  type Severity = "debug" | "info" | "warn" | "error";
636
+ type FallbackMode = "console" | "file" | "silent";
644
637
  interface LoggerConfig$1 {
645
638
  sekuireId: string;
646
- apiBaseUrl: string;
639
+ apiBaseUrl?: string;
647
640
  apiKey?: string;
648
641
  sessionId?: string;
649
642
  workspaceId?: string;
@@ -651,10 +644,16 @@ interface LoggerConfig$1 {
651
644
  enabled?: boolean;
652
645
  batchSize?: number;
653
646
  flushInterval?: number;
647
+ maxRetries?: number;
648
+ retryBaseDelay?: number;
654
649
  onError?: (error: Error, context: {
655
650
  operation: string;
656
651
  eventsLost?: number;
657
652
  }) => void;
653
+ fallback?: FallbackMode;
654
+ fallbackFilePath?: string;
655
+ maxBufferSize?: number;
656
+ privateKey?: string;
658
657
  }
659
658
  interface EventLog {
660
659
  sekuire_id: string;
@@ -665,68 +664,46 @@ interface EventLog {
665
664
  event_timestamp: string;
666
665
  event_data: Record<string, any>;
667
666
  metadata: Record<string, any>;
667
+ signature?: string;
668
668
  }
669
- /**
670
- * Asynchronous logger for Sekuire compliance events
671
- *
672
- * Features:
673
- * - Buffered batching (flush every N events or X seconds)
674
- * - Fire-and-forget (non-blocking)
675
- * - Health heartbeat tracking
676
- * - Graceful shutdown
677
- */
678
669
  declare class SekuireLogger {
679
670
  private config;
680
671
  private buffer;
672
+ private retryQueue;
673
+ private overflowEventsTotal;
681
674
  private flushTimer?;
682
675
  private heartbeatTimer?;
683
676
  private isFlushing;
684
677
  private client;
685
678
  private readonly sdkVersion;
679
+ private readonly apiAvailable;
680
+ private readonly fallbackMode;
681
+ private readonly maxBufferSize;
682
+ private readonly maxRetries;
683
+ private readonly retryBaseDelay;
684
+ private readonly privateKey?;
686
685
  constructor(config: LoggerConfig$1);
687
- /**
688
- * Log an event (buffered, non-blocking)
689
- */
690
686
  logEvent(eventType: EventType, severity: Severity, eventData: Record<string, any>): void;
691
- /**
692
- * Flush buffer to API (fire-and-forget)
693
- */
694
687
  flush(): Promise<void>;
695
- /**
696
- * Send health heartbeat to API
697
- */
688
+ private sendBatch;
689
+ private processRetryQueue;
690
+ private writeFallback;
691
+ private writeFallbackToFile;
698
692
  private sendHealthHeartbeat;
699
- /**
700
- * Start flush timer (every N milliseconds)
701
- */
702
693
  private startFlushTimer;
703
- /**
704
- * Start heartbeat timer (every 30 seconds)
705
- */
706
694
  private startHeartbeatTimer;
707
- /**
708
- * Stop timers
709
- */
710
695
  private stopTimers;
711
- /**
712
- * Shutdown logger gracefully
713
- * - Stops timers
714
- * - Flushes remaining events
715
- * - Safe to call multiple times
716
- */
717
696
  shutdown(): Promise<void>;
718
- /**
719
- * Get logger status for debugging
720
- */
721
697
  getStatus(): {
722
698
  enabled: boolean;
723
699
  bufferedEvents: number;
724
700
  sessionId: string;
725
701
  environment: string;
702
+ apiAvailable: boolean;
703
+ fallbackMode: FallbackMode;
704
+ overflowEventsTotal: number;
705
+ retryQueueSize: number;
726
706
  };
727
- /**
728
- * Enable/disable logging at runtime
729
- */
730
707
  setEnabled(enabled: boolean): void;
731
708
  }
732
709
 
@@ -803,6 +780,7 @@ declare class TaskWorker {
803
780
  private credentialsStore?;
804
781
  private tokenProvider?;
805
782
  private policyGateway?;
783
+ private degradedMode;
806
784
  constructor(config: WorkerConfig);
807
785
  private getEnvVar;
808
786
  /**
@@ -1538,10 +1516,31 @@ interface HandshakeWelcome {
1538
1516
  agentId: string;
1539
1517
  agentNonce: string;
1540
1518
  signatureC: string;
1519
+ agentPublicKey: string;
1541
1520
  credentials: string[];
1542
1521
  }
1543
1522
  interface HandshakeAuth {
1544
1523
  signatureA: string;
1524
+ clientPublicKey: string;
1525
+ clientNonce?: string;
1526
+ }
1527
+ interface HandshakeAuthResult {
1528
+ success: true;
1529
+ sessionToken: string;
1530
+ expiresInSeconds: number;
1531
+ }
1532
+ interface SignedRequestVerificationInput {
1533
+ method: string;
1534
+ path: string;
1535
+ body?: unknown;
1536
+ sessionToken: string | string[] | undefined;
1537
+ timestamp: string | number | string[] | undefined;
1538
+ signature: string | string[] | undefined;
1539
+ }
1540
+ interface VerifiedRequestContext {
1541
+ sessionToken: string;
1542
+ clientPublicKey: string;
1543
+ timestampMs: number;
1545
1544
  }
1546
1545
  interface VerifyAgentRequest {
1547
1546
  sekuireId: string;
@@ -1618,6 +1617,7 @@ interface HandshakeResult {
1618
1617
  agentId: string;
1619
1618
  verified: boolean;
1620
1619
  credentials: string[];
1620
+ sessionToken?: string;
1621
1621
  }
1622
1622
  declare class SekuireError extends Error {
1623
1623
  readonly code: string;
@@ -1648,6 +1648,7 @@ type AgentId = string;
1648
1648
  declare class SekuireClient {
1649
1649
  private readonly keyPair;
1650
1650
  private readonly httpClient;
1651
+ private sessionToken?;
1651
1652
  constructor(keyPair: KeyPair, config: SekuireClientConfig);
1652
1653
  /**
1653
1654
  * Perform the full handshake with a remote agent
@@ -1673,6 +1674,20 @@ declare class SekuireClient {
1673
1674
  * Sign data with the client's private key
1674
1675
  */
1675
1676
  sign(data: string): string;
1677
+ private buildRequestSignatureMessage;
1678
+ /**
1679
+ * Build signed headers for protected agent endpoints (for example /chat, /webhook, /a2a/tasks).
1680
+ * Requires a successful connect() call to obtain a session token.
1681
+ */
1682
+ createSignedRequestHeaders(method: string, path: string, body?: unknown, timestampMs?: number): Record<string, string>;
1683
+ /**
1684
+ * Get the current authenticated session token, if any.
1685
+ */
1686
+ getSessionToken(): string | undefined;
1687
+ /**
1688
+ * Clear the local session token.
1689
+ */
1690
+ clearSession(): void;
1676
1691
  /**
1677
1692
  * Get the client's public key
1678
1693
  */
@@ -1901,6 +1916,21 @@ interface AgentConfig {
1901
1916
  llm: LLMConfig;
1902
1917
  memory?: MemoryConfig;
1903
1918
  compliance?: ComplianceConfig;
1919
+ allowed_tools?: string[];
1920
+ blocked_tools?: string[];
1921
+ network?: {
1922
+ enabled?: boolean;
1923
+ require_tls?: boolean;
1924
+ allow?: string[];
1925
+ block?: string[];
1926
+ };
1927
+ filesystem?: {
1928
+ enabled?: boolean;
1929
+ allow_read?: string[];
1930
+ allow_write?: string[];
1931
+ block_all?: string[];
1932
+ allowed_extensions?: string[];
1933
+ };
1904
1934
  models?: {
1905
1935
  allowed_models?: string[];
1906
1936
  blocked_models?: string[];
@@ -1923,7 +1953,7 @@ interface LLMConfig {
1923
1953
  base_url?: string;
1924
1954
  }
1925
1955
  interface MemoryConfig {
1926
- type: 'in-memory' | 'buffer' | 'redis' | 'postgres' | 'sqlite' | 'upstash' | 'cloudflare-kv' | 'cloudflare-d1' | 'dynamodb' | 'turso' | 'convex' | string;
1956
+ type: 'in-memory' | 'buffer' | 'redis' | 'postgres' | 'sqlite' | 'file' | 'upstash' | 'cloudflare-kv' | 'cloudflare-d1' | 'dynamodb' | 'turso' | 'convex' | string;
1927
1957
  max_messages?: number;
1928
1958
  redis?: {
1929
1959
  url?: string;
@@ -1946,6 +1976,9 @@ interface MemoryConfig {
1946
1976
  filename: string;
1947
1977
  tableName?: string;
1948
1978
  };
1979
+ file?: {
1980
+ path: string;
1981
+ };
1949
1982
  upstash?: {
1950
1983
  url: string;
1951
1984
  token: string;
@@ -1978,7 +2011,40 @@ interface MemoryConfig {
1978
2011
  url: string;
1979
2012
  adminKey?: string;
1980
2013
  };
1981
- config?: Record<string, unknown>;
2014
+ config?: {
2015
+ filename?: string;
2016
+ path?: string;
2017
+ url?: string;
2018
+ token?: string;
2019
+ table_name?: string;
2020
+ tableName?: string;
2021
+ namespace_id?: string;
2022
+ namespaceId?: string;
2023
+ database_id?: string;
2024
+ databaseId?: string;
2025
+ account_id?: string;
2026
+ accountId?: string;
2027
+ api_token?: string;
2028
+ apiToken?: string;
2029
+ auth_token?: string;
2030
+ authToken?: string;
2031
+ admin_key?: string;
2032
+ adminKey?: string;
2033
+ connection_string?: string;
2034
+ connectionString?: string;
2035
+ host?: string;
2036
+ port?: number;
2037
+ database?: string;
2038
+ user?: string;
2039
+ password?: string;
2040
+ db?: number;
2041
+ keyPrefix?: string;
2042
+ endpoint?: string;
2043
+ create_table?: boolean;
2044
+ createTable?: boolean;
2045
+ readonly?: boolean;
2046
+ [key: string]: unknown;
2047
+ };
1982
2048
  }
1983
2049
  interface ComplianceConfig {
1984
2050
  framework?: string;
@@ -2044,9 +2110,40 @@ declare class SekuireCrypto {
2044
2110
  */
2045
2111
  static hash(data: string | Uint8Array): HexString;
2046
2112
  /**
2047
- * Calculate Sekuire ID from agent components
2113
+ * Calculate Sekuire ID using the canonical algorithm (V2).
2114
+ *
2115
+ * Matches the CLI reference implementation (auth.rs:243-250):
2116
+ * fingerprint = "model:{model}|prompt:{BLAKE3(trim(prompt))}|tools:{BLAKE3(canonical_json(tools))}"
2117
+ * sekuire_id = BLAKE3(fingerprint)
2118
+ *
2119
+ * projectName and projectVersion are accepted for backwards compatibility
2120
+ * but are NOT used in the ID computation.
2048
2121
  */
2049
2122
  static calculateSekuireId(params: {
2123
+ model: string;
2124
+ systemPrompt: string;
2125
+ tools: string;
2126
+ projectName?: string;
2127
+ projectVersion?: string;
2128
+ }): HexString;
2129
+ /**
2130
+ * Canonical identity algorithm aligned with CLI (auth.rs:243-250).
2131
+ *
2132
+ * 1. promptHash = BLAKE3(trim(systemPrompt))
2133
+ * 2. toolsHash = BLAKE3(JSON.stringify(JSON.parse(tools))) // canonical JSON
2134
+ * 3. fingerprint = "model:{model}|prompt:{promptHash}|tools:{toolsHash}"
2135
+ * 4. sekuireId = BLAKE3(fingerprint)
2136
+ */
2137
+ static calculateSekuireIdV2(params: {
2138
+ model: string;
2139
+ systemPrompt: string;
2140
+ tools: string;
2141
+ }): HexString;
2142
+ /**
2143
+ * @deprecated Use calculateSekuireId (V2) instead. This legacy algorithm
2144
+ * concatenates all fields in a single pass and does not match the CLI.
2145
+ */
2146
+ static calculateSekuireIdLegacy(params: {
2050
2147
  model: string;
2051
2148
  systemPrompt: string;
2052
2149
  tools: string;
@@ -2074,7 +2171,7 @@ declare class SekuireCrypto {
2074
2171
  */
2075
2172
  static isValidPublicKey(hex: string): boolean;
2076
2173
  /**
2077
- * Validate Ed25519 private key format (64 bytes)
2174
+ * Validate Ed25519 private key format (32-byte seed or 64-byte secret key)
2078
2175
  */
2079
2176
  static isValidPrivateKey(hex: string): boolean;
2080
2177
  /**
@@ -2083,6 +2180,31 @@ declare class SekuireCrypto {
2083
2180
  static isValidNonce(hex: string): boolean;
2084
2181
  }
2085
2182
 
2183
+ type ViolationHandler = (rule: string, reason: string) => void;
2184
+ declare class PolicyEnforcer {
2185
+ private readonly policy;
2186
+ private readonly onViolation?;
2187
+ private readonly override;
2188
+ private rateLimitWindows;
2189
+ constructor(policy: ActivePolicy, override?: boolean, onViolation?: ViolationHandler | undefined);
2190
+ enforceNetwork(domain: string, protocol: string): void;
2191
+ enforceFilesystem(path: string, operation: string): void;
2192
+ enforceTool(toolName: string): void;
2193
+ private matchesCategoryPattern;
2194
+ private toolMatchesCategory;
2195
+ private toolMatchesCategoryOperation;
2196
+ enforceModel(model: string): void;
2197
+ enforceApi(service: string): void;
2198
+ enforceRateLimit(type: "request" | "token", count?: number): void;
2199
+ isOverrideEnabled(): boolean;
2200
+ private checkWindow;
2201
+ private cleanupStaleWindows;
2202
+ private throw;
2203
+ private warnOnly;
2204
+ private matches;
2205
+ private pathMatch;
2206
+ }
2207
+
2086
2208
  interface ToolDefinition {
2087
2209
  type: 'function';
2088
2210
  function: {
@@ -2138,30 +2260,13 @@ interface ChatChunk {
2138
2260
  * Base interface for LLM providers
2139
2261
  */
2140
2262
  interface LLMProvider {
2141
- /**
2142
- * Send chat messages and get response
2143
- */
2144
2263
  chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
2145
- /**
2146
- * Stream chat response
2147
- */
2148
2264
  chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
2149
- /**
2150
- * Count tokens in text (approximate)
2151
- */
2152
2265
  countTokens(text: string): number;
2153
- /**
2154
- * Get maximum context window size
2155
- */
2156
2266
  getMaxTokens(): number;
2157
- /**
2158
- * Get provider name
2159
- */
2160
2267
  getProviderName(): string;
2161
- /**
2162
- * Get model name
2163
- */
2164
2268
  getModelName(): string;
2269
+ setPolicyEnforcer?(enforcer: unknown): void;
2165
2270
  }
2166
2271
  /**
2167
2272
  * Configuration for creating LLM providers
@@ -2178,7 +2283,14 @@ interface LLMProviderConfig {
2178
2283
  declare abstract class BaseLLMProvider implements LLMProvider {
2179
2284
  protected model: string;
2180
2285
  protected maxTokens: number;
2286
+ private _policyEnforcer?;
2181
2287
  constructor(config: LLMProviderConfig);
2288
+ setPolicyEnforcer(enforcer: PolicyEnforcer): void;
2289
+ getPolicyEnforcer(): PolicyEnforcer | undefined;
2290
+ protected enforcePreCall(): void;
2291
+ protected enforcePostCall(usage?: {
2292
+ total_tokens: number;
2293
+ }): void;
2182
2294
  abstract chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
2183
2295
  abstract chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
2184
2296
  abstract getProviderName(): string;
@@ -2191,6 +2303,7 @@ declare abstract class BaseLLMProvider implements LLMProvider {
2191
2303
  declare class AnthropicProvider extends BaseLLMProvider {
2192
2304
  private client;
2193
2305
  constructor(config: LLMProviderConfig);
2306
+ static create(config: LLMProviderConfig): Promise<AnthropicProvider>;
2194
2307
  chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
2195
2308
  chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
2196
2309
  getProviderName(): string;
@@ -2200,10 +2313,13 @@ declare class AnthropicProvider extends BaseLLMProvider {
2200
2313
  declare class GoogleProvider extends BaseLLMProvider {
2201
2314
  private client;
2202
2315
  constructor(config: LLMProviderConfig);
2316
+ static create(config: LLMProviderConfig): Promise<GoogleProvider>;
2203
2317
  chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
2204
2318
  chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
2205
2319
  getProviderName(): string;
2206
2320
  protected getMaxTokensForModel(model: string): number;
2321
+ private buildTools;
2322
+ private buildHistory;
2207
2323
  }
2208
2324
 
2209
2325
  declare class OllamaProvider extends BaseLLMProvider {
@@ -2218,6 +2334,7 @@ declare class OllamaProvider extends BaseLLMProvider {
2218
2334
  declare class OpenAIProvider extends BaseLLMProvider {
2219
2335
  private client;
2220
2336
  constructor(config: LLMProviderConfig);
2337
+ static create(config: LLMProviderConfig): Promise<OpenAIProvider>;
2221
2338
  chat(messages: Message[], options?: ChatOptions): Promise<ChatResponse>;
2222
2339
  chatStream(messages: Message[], options?: ChatOptions): AsyncGenerator<ChatChunk>;
2223
2340
  getProviderName(): string;
@@ -2227,20 +2344,20 @@ declare class OpenAIProvider extends BaseLLMProvider {
2227
2344
  /**
2228
2345
  * Create an LLM provider based on provider name
2229
2346
  */
2230
- declare function createLLMProvider(provider: string, config: LLMProviderConfig): LLMProvider;
2347
+ declare function createLLMProvider(provider: string, config: LLMProviderConfig): Promise<LLMProvider>;
2231
2348
  /**
2232
2349
  * Factory functions for easy LLM instantiation
2233
2350
  */
2234
2351
  declare const llm: {
2235
2352
  openai: (config: Omit<LLMProviderConfig, "model"> & {
2236
2353
  model?: string;
2237
- }) => OpenAIProvider;
2354
+ }) => Promise<OpenAIProvider>;
2238
2355
  anthropic: (config: Omit<LLMProviderConfig, "model"> & {
2239
2356
  model?: string;
2240
- }) => AnthropicProvider;
2357
+ }) => Promise<AnthropicProvider>;
2241
2358
  google: (config: Omit<LLMProviderConfig, "model"> & {
2242
2359
  model?: string;
2243
- }) => GoogleProvider;
2360
+ }) => Promise<GoogleProvider>;
2244
2361
  ollama: (config: Omit<LLMProviderConfig, "model"> & {
2245
2362
  model?: string;
2246
2363
  }) => OllamaProvider;
@@ -2351,6 +2468,7 @@ declare class SQLiteStorage extends BaseMemoryStorage {
2351
2468
  private connectionPromise;
2352
2469
  constructor(config: SQLiteConfig);
2353
2470
  connect(): Promise<void>;
2471
+ private loadDatabaseDriver;
2354
2472
  private ensureTableExists;
2355
2473
  private ensureConnected;
2356
2474
  add(sessionId: string, message: MemoryMessage): Promise<void>;
@@ -2361,6 +2479,10 @@ declare class SQLiteStorage extends BaseMemoryStorage {
2361
2479
  disconnect(): Promise<void>;
2362
2480
  }
2363
2481
 
2482
+ interface FileStorageConfig {
2483
+ path: string;
2484
+ }
2485
+
2364
2486
  interface UpstashConfig {
2365
2487
  url: string;
2366
2488
  token: string;
@@ -2513,13 +2635,14 @@ declare function getStorageInfo(): Array<{
2513
2635
  description?: string;
2514
2636
  }>;
2515
2637
 
2516
- type BuiltInMemoryType = 'in-memory' | 'buffer' | 'redis' | 'postgres' | 'sqlite' | 'upstash' | 'cloudflare-kv' | 'cloudflare-d1' | 'dynamodb' | 'turso' | 'convex';
2638
+ type BuiltInMemoryType = 'in-memory' | 'buffer' | 'redis' | 'postgres' | 'sqlite' | 'file' | 'upstash' | 'cloudflare-kv' | 'cloudflare-d1' | 'dynamodb' | 'turso' | 'convex';
2517
2639
  type MemoryType = BuiltInMemoryType | string;
2518
2640
  interface MemoryFactoryConfig {
2519
2641
  type: MemoryType;
2520
2642
  redis?: RedisConfig;
2521
2643
  postgres?: PostgresConfig;
2522
2644
  sqlite?: SQLiteConfig;
2645
+ file?: FileStorageConfig;
2523
2646
  upstash?: UpstashConfig;
2524
2647
  cloudflareKV?: CloudflareKVConfig;
2525
2648
  cloudflareD1?: CloudflareD1Config;
@@ -2531,28 +2654,6 @@ interface MemoryFactoryConfig {
2531
2654
  }
2532
2655
  declare function createMemoryStorage(config: MemoryFactoryConfig): MemoryStorage;
2533
2656
 
2534
- type ViolationHandler = (rule: string, reason: string) => void;
2535
- declare class PolicyEnforcer {
2536
- private readonly policy;
2537
- private readonly onViolation?;
2538
- private readonly override;
2539
- private rateLimitWindows;
2540
- constructor(policy: ActivePolicy, override?: boolean, onViolation?: ViolationHandler | undefined);
2541
- enforceNetwork(domain: string, protocol: string): void;
2542
- enforceFilesystem(path: string, operation: string): void;
2543
- enforceTool(toolName: string): void;
2544
- private getCategoryPrefix;
2545
- enforceModel(model: string): void;
2546
- enforceApi(service: string): void;
2547
- enforceRateLimit(type: "request" | "token", count?: number): void;
2548
- private checkWindow;
2549
- private cleanupStaleWindows;
2550
- private throw;
2551
- private warnOnly;
2552
- private matches;
2553
- private pathMatch;
2554
- }
2555
-
2556
2657
  /**
2557
2658
  * Options for overriding agent configuration
2558
2659
  */
@@ -2690,7 +2791,17 @@ declare function getTools(agentName?: string, configPath?: string): Promise<Tool
2690
2791
  declare abstract class SekuireServer {
2691
2792
  protected readonly agentId: string;
2692
2793
  protected readonly keyPair: KeyPair;
2794
+ private readonly pendingHandshakes;
2795
+ private readonly activeSessions;
2796
+ private static readonly HANDSHAKE_TTL_MS;
2797
+ private static readonly SESSION_TTL_MS;
2798
+ private static readonly REQUEST_CLOCK_SKEW_MS;
2693
2799
  constructor(agentId: string, keyPair: KeyPair);
2800
+ private purgeExpiredHandshakes;
2801
+ private purgeExpiredSessions;
2802
+ private firstHeaderValue;
2803
+ private parseTimestamp;
2804
+ private buildRequestSignatureMessage;
2694
2805
  /**
2695
2806
  * Handle the HELLO handshake message
2696
2807
  */
@@ -2698,7 +2809,12 @@ declare abstract class SekuireServer {
2698
2809
  /**
2699
2810
  * Handle the AUTH handshake message
2700
2811
  */
2701
- handleAuth(auth: HandshakeAuth, clientNonce: string): Promise<void>;
2812
+ handleAuth(auth: HandshakeAuth, clientNonce: string): Promise<HandshakeAuthResult>;
2813
+ /**
2814
+ * Verify a signed request for protected application endpoints (for example /chat, /webhook, /a2a/tasks).
2815
+ * Requires a valid handshake session token and Ed25519 signature by the authenticated client key.
2816
+ */
2817
+ verifySignedRequest(input: SignedRequestVerificationInput): Promise<VerifiedRequestContext>;
2702
2818
  /**
2703
2819
  * Get the agent's public key
2704
2820
  */
@@ -2716,10 +2832,23 @@ declare abstract class SekuireServer {
2716
2832
  * Express.js middleware for Sekuire protocol
2717
2833
  */
2718
2834
  declare function createSekuireExpressMiddleware(server: SekuireServer): any[];
2835
+ interface RequestAuthOptions {
2836
+ protectedPaths?: string[];
2837
+ }
2838
+ /**
2839
+ * Express middleware that enforces signed-request authentication for protected paths.
2840
+ * Defaults to protecting POST /chat, POST /webhook, and POST /a2a/tasks.
2841
+ */
2842
+ declare function createSekuireExpressRequestAuthMiddleware(server: SekuireServer, options?: RequestAuthOptions): (req: any, res: any, next: any) => Promise<any>;
2719
2843
  /**
2720
2844
  * Fastify plugin for Sekuire protocol
2721
2845
  */
2722
2846
  declare function createSekuireFastifyPlugin(server: SekuireServer): (fastify: any, options: any) => Promise<void>;
2847
+ /**
2848
+ * Fastify preHandler that enforces signed-request authentication for protected paths.
2849
+ * Defaults to protecting POST /chat, POST /webhook, and POST /a2a/tasks.
2850
+ */
2851
+ declare function createSekuireFastifyRequestAuthHook(server: SekuireServer, options?: RequestAuthOptions): (request: any, reply: any) => Promise<void>;
2723
2852
 
2724
2853
  interface ToolInput {
2725
2854
  [key: string]: string | number | boolean | object;
@@ -3296,9 +3425,22 @@ declare function createDelegationTool(client: SekuireClient): ToolDefinition$2;
3296
3425
  */
3297
3426
  declare function generateKeyPair(): KeyPair;
3298
3427
  /**
3299
- * Calculate Sekuire ID from agent configuration
3428
+ * Calculate Sekuire ID from agent configuration (canonical V2 algorithm).
3429
+ *
3430
+ * projectName and projectVersion are accepted for backwards compatibility
3431
+ * but are NOT used in the ID computation.
3300
3432
  */
3301
3433
  declare function calculateSekuireId(params: {
3434
+ model: string;
3435
+ systemPrompt: string;
3436
+ tools: string;
3437
+ projectName?: string;
3438
+ projectVersion?: string;
3439
+ }): string;
3440
+ /**
3441
+ * @deprecated Use calculateSekuireId (V2) instead.
3442
+ */
3443
+ declare function calculateSekuireIdLegacy(params: {
3302
3444
  model: string;
3303
3445
  systemPrompt: string;
3304
3446
  tools: string;
@@ -3316,11 +3458,11 @@ interface SekuireExporterConfig {
3316
3458
  authToken?: string;
3317
3459
  workspaceId?: string;
3318
3460
  }
3319
- declare class SekuireSpanExporter implements SpanExporter {
3461
+ declare class SekuireSpanExporter {
3320
3462
  private config;
3321
3463
  private pendingExport;
3322
3464
  constructor(config: SekuireExporterConfig);
3323
- export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
3465
+ export(spans: any[], resultCallback: (result: any) => void): void;
3324
3466
  private spanToEvent;
3325
3467
  private mapSpanToEventType;
3326
3468
  private getDurationMs;
@@ -3346,8 +3488,8 @@ interface TelemetryConfig {
3346
3488
  scheduledDelayMillis?: number;
3347
3489
  };
3348
3490
  }
3349
- declare function initTelemetry(config: TelemetryConfig): Tracer;
3350
- declare function getTracer(): Tracer;
3491
+ declare function initTelemetry(config: TelemetryConfig): any;
3492
+ declare function getTracer(): any;
3351
3493
  declare function shutdownTelemetry(): Promise<void>;
3352
3494
 
3353
3495
  declare function detectDeploymentUrl(): string | undefined;
@@ -3567,5 +3709,5 @@ declare class A2AServer {
3567
3709
  private generateId;
3568
3710
  }
3569
3711
 
3570
- export { A2AClient, A2AError, A2AServer, A2ATaskDelegator, SekuireAgent as Agent, AgentIdentity, AnthropicProvider, BaseMemoryStorage, Beacon, CONVEX_FUNCTIONS_TEMPLATE, CONVEX_SCHEMA_TEMPLATE, CloudflareD1Storage, CloudflareKVStorage, ComplianceError, ComplianceMonitor, ContentPolicyError, ConvexStorage, CryptoError, DEFAULT_API_URL, DynamoDBStorage, FileAccessError, GoogleProvider, InMemoryStorage, NetworkComplianceError, NetworkError, OllamaProvider, OpenAIProvider, PolicyClient, PolicyEnforcer, PolicyGateway, PolicyViolationError, PostgresStorage, ProtocolError, RedisStorage, RuntimeCredentialsStore, SQLiteStorage, SekuireAgent$1 as SekuireAgent, SekuireAgentBuilder, SekuireClient, SekuireCrypto, SekuireError, SekuireLogger, SekuireRegistryClient, SekuireSDK, SekuireServer, SekuireSpanExporter, TaskWorker, Tool, ToolPatternParser, ToolRegistry, ToolUsageError, TursoStorage, UpstashStorage, applyBootstrapResponse, builtInTools, calculateSekuireId, createAgent, createBeacon, createDefaultToolRegistry, createDelegationTool, createDelegator, createDiscoveryTool, createLLMProvider, createMemoryStorage, createRegistryClient, createSekuireClient, createSekuireExpressMiddleware, createSekuireFastifyPlugin, createWorker, detectDeploymentUrl, generateKeyPair, getAgent, getAgentConfig, getAgents, getTools$1 as getLegacyTools, getStorageInfo, getSystemPrompt, getTools, getTracer, hasStorage, initTelemetry, listStorageTypes, llm, loadConfig, loadSystemPrompt, loadTools, registerStorage, shutdownTelemetry, tool, tools };
3571
- export type { A2AArtifact, A2AClientOptions, A2AMessage, A2AMessagePart, A2ARouteRequest, A2ARouteResponse, A2AServerOptions, A2ATask, A2ATaskState, A2ATaskStatus, ActivePolicy, ActivePolicyResponse, AgentCapabilities, AgentCard, AgentConfig, AgentId, AgentInvokeOptions, AgentOptions, AgentProvider, AgentResponse$1 as AgentResponse, AgentSkill, BeaconConfig, BeaconStatus, BootstrapResponse, BootstrapResponseData, BootstrapTarget, BuiltInMemoryType, ChatChunk, ChatOptions, ChatResponse, CloudflareD1Config, CloudflareKVConfig, ComplianceConfig, ComplianceViolation, ConditionOperator, ToolDefinition$1 as ConfigToolDefinition, ConvexConfig, CreateOrgRequest, CreateWorkspaceRequest, CustomRule, DelegationRequest, DelegationResult, DelegatorConfig, DisputeRequest, DisputeResponse, DynamoDBConfig, EventLog, EventType, ExporterType, HandshakeAuth, HandshakeHello, HandshakeResult, HandshakeWelcome, HexString, IdentityConfig, InstallationCredentials, InviteRequest, InviteResponse, JsonRpcError, JsonRpcRequest, JsonRpcResponse, KeyPair, LLMConfig, Message as LLMMessage, LLMProvider, LLMProviderConfig, ToolCallFunction as LLMToolCall, ToolDefinition as LLMToolDefinition, LeaderboardEntry, LoggerConfig$1 as LoggerConfig, Manifest, MemoryConfig, MemoryFactoryConfig, MemoryMessage, MemoryStorage, MemoryType, Message$1 as Message, OrgResponse, OrgSummary, PerAgentLimits, PolicyDecision, PolicyViolation, PostgresConfig, ProjectMetadata, PublishAgentOptions, PublishRequest, PublishResponse, RateLimitsConfig$1 as RateLimitsConfig, RedisConfig, RegistryClientConfig, ReputationLog, ReputationResponse, RuleCondition, RuntimeCredentials, SQLiteConfig, SearchAgentsOptions, SekuireAgentConfig, SekuireClientConfig, SekuireConfig, SekuireExporterConfig, SekuireSDKConfig, Severity, SkillContext, SkillHandler, StreamingSkillContext, StreamingSkillHandler, StreamingUpdate, SubmitReputationRequest, TaskCompletion, TaskContext, TaskEvent, TaskHandler, TaskState, TaskUpdateEvent, TasksCancelParams, TasksGetParams, TasksSendParams, TasksSendSubscribeParams, TelemetryConfig, ToolCall, ToolDefinition$2 as ToolDefinition, ToolInput, ToolMetadata, ToolParameter, ToolsSchema, TrustHeaders, TrustHeadersRequest, TursoConfig, UpdateAgentOptions, UpstashConfig, UserContextResponse, VerificationIssue, VerificationRequest, VerificationResult, VerificationStatus, VerifyAgentRequest, WorkerConfig, WorkspaceResponse, WorkspaceSummary };
3712
+ export { A2AClient, A2AError, A2AServer, A2ATaskDelegator, SekuireAgent as Agent, AgentIdentity, AnthropicProvider, BaseMemoryStorage, Beacon, CONVEX_FUNCTIONS_TEMPLATE, CONVEX_SCHEMA_TEMPLATE, CloudflareD1Storage, CloudflareKVStorage, ComplianceError, ComplianceMonitor, ContentPolicyError, ConvexStorage, CryptoError, DEFAULT_API_URL, DynamoDBStorage, FileAccessError, GoogleProvider, InMemoryStorage, NetworkComplianceError, NetworkError, OllamaProvider, OpenAIProvider, PolicyClient, PolicyEnforcer, PolicyGateway, PolicyViolationError, PostgresStorage, ProtocolError, RedisStorage, RuntimeCredentialsStore, SQLiteStorage, SekuireAgent$1 as SekuireAgent, SekuireAgentBuilder, SekuireClient, SekuireCrypto, SekuireError, SekuireLogger, SekuireRegistryClient, SekuireSDK, SekuireServer, SekuireSpanExporter, TaskWorker, Tool, ToolPatternParser, ToolRegistry, ToolUsageError, TursoStorage, UpstashStorage, applyBootstrapResponse, builtInTools, calculateSekuireId, calculateSekuireIdLegacy, createAgent, createBeacon, createDefaultToolRegistry, createDelegationTool, createDelegator, createDiscoveryTool, createLLMProvider, createMemoryStorage, createRegistryClient, createSekuireClient, createSekuireExpressMiddleware, createSekuireExpressRequestAuthMiddleware, createSekuireFastifyPlugin, createSekuireFastifyRequestAuthHook, createWorker, detectDeploymentUrl, generateKeyPair, getAgent, getAgentConfig, getAgents, getTools$1 as getLegacyTools, getStorageInfo, getSystemPrompt, getTools, getTracer, hasStorage, initTelemetry, listStorageTypes, llm, loadConfig, loadSystemPrompt, loadTools, registerStorage, shutdownTelemetry, tool, tools };
3713
+ export type { A2AArtifact, A2AClientOptions, A2AMessage, A2AMessagePart, A2ARouteRequest, A2ARouteResponse, A2AServerOptions, A2ATask, A2ATaskState, A2ATaskStatus, ActivePolicy, ActivePolicyResponse, AgentCapabilities, AgentCard, AgentConfig, AgentId, AgentInvokeOptions, AgentOptions, AgentProvider, AgentResponse$1 as AgentResponse, AgentSkill, BeaconConfig, BeaconStatus, BootstrapResponse, BootstrapResponseData, BootstrapTarget, BuiltInMemoryType, ChatChunk, ChatOptions, ChatResponse, CloudflareD1Config, CloudflareKVConfig, ComplianceConfig, ComplianceViolation, ConditionOperator, ToolDefinition$1 as ConfigToolDefinition, ConvexConfig, CreateOrgRequest, CreateWorkspaceRequest, CustomRule, DelegationRequest, DelegationResult, DelegatorConfig, DisputeRequest, DisputeResponse, DynamoDBConfig, EventLog, EventType, ExporterType, FallbackMode, HandshakeAuth, HandshakeAuthResult, HandshakeHello, HandshakeResult, HandshakeWelcome, HexString, IdentityConfig, InstallationCredentials, InviteRequest, InviteResponse, JsonRpcError, JsonRpcRequest, JsonRpcResponse, KeyPair, LLMConfig, Message as LLMMessage, LLMProvider, LLMProviderConfig, ToolCallFunction as LLMToolCall, ToolDefinition as LLMToolDefinition, LeaderboardEntry, LoggerConfig$1 as LoggerConfig, Manifest, MemoryConfig, MemoryFactoryConfig, MemoryMessage, MemoryStorage, MemoryType, Message$1 as Message, OrgResponse, OrgSummary, PerAgentLimits, PolicyDecision, PolicyViolation, PostgresConfig, ProjectMetadata, PublishAgentOptions, PublishRequest, PublishResponse, RateLimitsConfig$1 as RateLimitsConfig, RedisConfig, RegistryClientConfig, ReputationLog, ReputationResponse, RequestAuthOptions, RuleCondition, RuntimeCredentials, SQLiteConfig, SearchAgentsOptions, SekuireAgentConfig, SekuireClientConfig, SekuireConfig, SekuireExporterConfig, SekuireSDKConfig, Severity, SignedRequestVerificationInput, SkillContext, SkillHandler, StreamingSkillContext, StreamingSkillHandler, StreamingUpdate, SubmitReputationRequest, TaskCompletion, TaskContext, TaskEvent, TaskHandler, TaskState, TaskUpdateEvent, TasksCancelParams, TasksGetParams, TasksSendParams, TasksSendSubscribeParams, TelemetryConfig, ToolCall, ToolDefinition$2 as ToolDefinition, ToolInput, ToolMetadata, ToolParameter, ToolsSchema, TrustHeaders, TrustHeadersRequest, TursoConfig, UpdateAgentOptions, UpstashConfig, UserContextResponse, VerificationIssue, VerificationRequest, VerificationResult, VerificationStatus, VerifiedRequestContext, VerifyAgentRequest, WorkerConfig, WorkspaceResponse, WorkspaceSummary };