@sekuire/sdk 0.1.18 → 0.1.19

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.
@@ -4,6 +4,7 @@
4
4
  * Enables agents to delegate tasks to other agents and receive completion callbacks.
5
5
  * Provides a complete feedback loop for multi-agent orchestration.
6
6
  */
7
+ import type { PolicyGateway } from "./policy-gateway";
7
8
  import type { A2AMessage, A2ATaskState, TaskUpdateEvent } from "./types/a2a-types";
8
9
  export interface DelegatorConfig {
9
10
  apiUrl: string;
@@ -15,6 +16,7 @@ export interface DelegatorConfig {
15
16
  maxRetries?: number;
16
17
  retryDelayMs?: number;
17
18
  retryBackoffMultiplier?: number;
19
+ policyGateway?: PolicyGateway;
18
20
  }
19
21
  export interface DelegationRequest {
20
22
  skill: string;
@@ -49,6 +51,7 @@ export declare class A2ATaskDelegator {
49
51
  private client;
50
52
  private config;
51
53
  private activeDelegations;
54
+ private policyGateway?;
52
55
  constructor(config: DelegatorConfig);
53
56
  setRuntimeToken(token: string): void;
54
57
  delegate(request: DelegationRequest): Promise<DelegationResult>;
package/dist/beacon.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * 1. Install Token (recommended): Use an install token from the dashboard
9
9
  * 2. API Key: Use an API key for SDK-initiated bootstrap (requires workspace)
10
10
  */
11
+ import type { PolicyGateway } from "./policy-gateway";
11
12
  import { RuntimeCredentialsStore } from "./runtime-credentials";
12
13
  export interface BeaconConfig {
13
14
  /** Sekuire Core API base URL */
@@ -48,6 +49,7 @@ export interface BeaconConfig {
48
49
  * Reads from SEKUIRE_RUNTIME_TOKEN if not set.
49
50
  */
50
51
  runtimeToken?: string;
52
+ policyGateway?: PolicyGateway;
51
53
  }
52
54
  export interface BeaconStatus {
53
55
  isRunning: boolean;
@@ -86,6 +88,7 @@ export declare class Beacon {
86
88
  private recoveredFromEnv;
87
89
  private expiresAt;
88
90
  private credentialsStore?;
91
+ private policyGateway?;
89
92
  constructor(config: BeaconConfig);
90
93
  /**
91
94
  * Start the beacon - registers with Sekuire and begins heartbeat loop
@@ -103,6 +106,7 @@ export declare class Beacon {
103
106
  * Stop the beacon
104
107
  */
105
108
  stop(): void;
109
+ setPolicyGateway(gateway: PolicyGateway): void;
106
110
  /**
107
111
  * Get current beacon status
108
112
  */
package/dist/index.d.ts CHANGED
@@ -3,6 +3,95 @@ import { Tracer } from '@opentelemetry/api';
3
3
  import { ExportResult } from '@opentelemetry/core';
4
4
  import { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base';
5
5
 
6
+ interface ActivePolicy {
7
+ policy_id: string;
8
+ workspace_id: string;
9
+ version: string;
10
+ status: string;
11
+ hash: string;
12
+ content: any;
13
+ activated_at?: string;
14
+ updated_at?: string;
15
+ signature?: string;
16
+ signing_key_id?: string;
17
+ signing_public_key?: string;
18
+ }
19
+ declare class PolicyClient {
20
+ private readonly baseUrl;
21
+ private cache;
22
+ constructor(baseUrl: string);
23
+ invalidateCache(workspaceId: string): void;
24
+ fetchActivePolicy(workspaceId: string): Promise<ActivePolicy>;
25
+ verify(policy: ActivePolicy): void;
26
+ }
27
+
28
+ interface ActivePolicyResponse {
29
+ policy_id: string;
30
+ workspace_id: string;
31
+ version: string;
32
+ status: string;
33
+ hash: string;
34
+ content: unknown;
35
+ activated_at?: string;
36
+ updated_at?: string;
37
+ signature?: string;
38
+ signing_key_id?: string;
39
+ signing_public_key?: string;
40
+ }
41
+ interface CustomRule {
42
+ id: string;
43
+ name: string;
44
+ description?: string;
45
+ enabled: boolean;
46
+ priority?: number;
47
+ scope: {
48
+ capabilities: string[];
49
+ agents?: string[];
50
+ };
51
+ conditions: RuleCondition[];
52
+ logic: "any" | "all";
53
+ action: "deny" | "warn";
54
+ message: string;
55
+ }
56
+ interface RuleCondition {
57
+ field: string;
58
+ operator: ConditionOperator;
59
+ value: unknown;
60
+ case_sensitive?: boolean;
61
+ }
62
+ type ConditionOperator = "contains" | "not_contains" | "equals" | "not_equals" | "starts_with" | "ends_with" | "matches" | "in" | "not_in" | "greater_than" | "less_than";
63
+ interface PolicyDecision {
64
+ allowed: boolean;
65
+ violations: PolicyViolation[];
66
+ warnings: PolicyViolation[];
67
+ }
68
+ interface PolicyViolation {
69
+ rule_id: string;
70
+ rule_name: string;
71
+ message: string;
72
+ capability: string;
73
+ }
74
+ interface RateLimitsConfig$1 {
75
+ per_agent?: PerAgentLimits;
76
+ }
77
+ interface PerAgentLimits {
78
+ requests_per_minute?: number;
79
+ requests_per_hour?: number;
80
+ tokens_per_minute?: number;
81
+ }
82
+
83
+ declare class PolicyGateway {
84
+ private policyClient;
85
+ private workspaceId;
86
+ private enforcer;
87
+ private cachedPolicyHash;
88
+ constructor(policyClient: PolicyClient, workspaceId: string);
89
+ initialize(): Promise<void>;
90
+ checkRateLimit(type: "request" | "token", count?: number): PolicyDecision;
91
+ checkCapability(capability: string): PolicyDecision;
92
+ onHeartbeatResponse(policyHash: string | null): Promise<void>;
93
+ }
94
+
6
95
  /**
7
96
  * A2A Protocol Type Definitions
8
97
  *
@@ -215,6 +304,7 @@ interface DelegatorConfig {
215
304
  maxRetries?: number;
216
305
  retryDelayMs?: number;
217
306
  retryBackoffMultiplier?: number;
307
+ policyGateway?: PolicyGateway;
218
308
  }
219
309
  interface DelegationRequest {
220
310
  skill: string;
@@ -249,6 +339,7 @@ declare class A2ATaskDelegator {
249
339
  private client;
250
340
  private config;
251
341
  private activeDelegations;
342
+ private policyGateway?;
252
343
  constructor(config: DelegatorConfig);
253
344
  setRuntimeToken(token: string): void;
254
345
  delegate(request: DelegationRequest): Promise<DelegationResult>;
@@ -344,6 +435,7 @@ interface BeaconConfig {
344
435
  * Reads from SEKUIRE_RUNTIME_TOKEN if not set.
345
436
  */
346
437
  runtimeToken?: string;
438
+ policyGateway?: PolicyGateway;
347
439
  }
348
440
  interface BeaconStatus {
349
441
  isRunning: boolean;
@@ -382,6 +474,7 @@ declare class Beacon {
382
474
  private recoveredFromEnv;
383
475
  private expiresAt;
384
476
  private credentialsStore?;
477
+ private policyGateway?;
385
478
  constructor(config: BeaconConfig);
386
479
  /**
387
480
  * Start the beacon - registers with Sekuire and begins heartbeat loop
@@ -399,6 +492,7 @@ declare class Beacon {
399
492
  * Stop the beacon
400
493
  */
401
494
  stop(): void;
495
+ setPolicyGateway(gateway: PolicyGateway): void;
402
496
  /**
403
497
  * Get current beacon status
404
498
  */
@@ -655,6 +749,8 @@ interface WorkerConfig {
655
749
  capabilities?: string[];
656
750
  /** Optional shared credentials store for token synchronization */
657
751
  credentialsStore?: RuntimeCredentialsStore;
752
+ /** Optional policy gateway for infrastructure enforcement */
753
+ policyGateway?: PolicyGateway;
658
754
  /**
659
755
  * Pre-existing installation ID for credential recovery.
660
756
  * When set with refreshToken, allows recovery after container restarts.
@@ -684,6 +780,7 @@ declare class TaskWorker {
684
780
  private recoveredFromEnv;
685
781
  private credentialsStore?;
686
782
  private tokenProvider?;
783
+ private policyGateway?;
687
784
  constructor(config: WorkerConfig);
688
785
  private getEnvVar;
689
786
  /**
@@ -810,6 +907,7 @@ declare class SekuireSDK {
810
907
  private beacon;
811
908
  private isRunning;
812
909
  private credentialsStore;
910
+ private policyGateway;
813
911
  constructor(config: SekuireSDKConfig);
814
912
  /**
815
913
  * Create SDK instance from environment variables.
@@ -986,6 +1084,7 @@ declare class SekuireSDK {
986
1084
  * Get the underlying logger object.
987
1085
  */
988
1086
  getLogger(): SekuireLogger;
1087
+ getPolicyGateway(): PolicyGateway | null;
989
1088
  }
990
1089
 
991
1090
  /**
@@ -1346,20 +1445,6 @@ declare function tools<T extends ToolDefinition$2[]>(...definitions: T): T;
1346
1445
  */
1347
1446
  declare function getTools$1(agent: SekuireAgent$1, names?: string[]): ToolDefinition$2[];
1348
1447
 
1349
- interface ActivePolicyResponse {
1350
- policy_id: string;
1351
- workspace_id: string;
1352
- version: string;
1353
- status: string;
1354
- hash: string;
1355
- content: unknown;
1356
- activated_at?: string;
1357
- updated_at?: string;
1358
- signature?: string;
1359
- signing_key_id?: string;
1360
- signing_public_key?: string;
1361
- }
1362
-
1363
1448
  interface Manifest {
1364
1449
  project: ProjectMetadata;
1365
1450
  identity: IdentityConfig;
@@ -2421,32 +2506,12 @@ interface MemoryFactoryConfig {
2421
2506
  }
2422
2507
  declare function createMemoryStorage(config: MemoryFactoryConfig): MemoryStorage;
2423
2508
 
2424
- interface ActivePolicy {
2425
- policy_id: string;
2426
- workspace_id: string;
2427
- version: string;
2428
- status: string;
2429
- hash: string;
2430
- content: any;
2431
- activated_at?: string;
2432
- updated_at?: string;
2433
- signature?: string;
2434
- signing_key_id?: string;
2435
- signing_public_key?: string;
2436
- }
2437
- declare class PolicyClient {
2438
- private readonly baseUrl;
2439
- private cache;
2440
- constructor(baseUrl: string);
2441
- fetchActivePolicy(workspaceId: string): Promise<ActivePolicy>;
2442
- verify(policy: ActivePolicy): void;
2443
- }
2444
-
2445
2509
  type ViolationHandler = (rule: string, reason: string) => void;
2446
2510
  declare class PolicyEnforcer {
2447
2511
  private readonly policy;
2448
2512
  private readonly onViolation?;
2449
2513
  private readonly override;
2514
+ private rateLimitWindows;
2450
2515
  constructor(policy: ActivePolicy, override?: boolean, onViolation?: ViolationHandler | undefined);
2451
2516
  enforceNetwork(domain: string, protocol: string): void;
2452
2517
  enforceFilesystem(path: string, operation: string): void;
@@ -2455,6 +2520,8 @@ declare class PolicyEnforcer {
2455
2520
  enforceModel(model: string): void;
2456
2521
  enforceApi(service: string): void;
2457
2522
  enforceRateLimit(type: "request" | "token", count?: number): void;
2523
+ private checkWindow;
2524
+ private cleanupStaleWindows;
2458
2525
  private throw;
2459
2526
  private warnOnly;
2460
2527
  private matches;
@@ -3467,5 +3534,5 @@ declare class A2AServer {
3467
3534
  private generateId;
3468
3535
  }
3469
3536
 
3470
- 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, 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, 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 };
3471
- 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, BuiltInMemoryType, ChatChunk, ChatOptions, ChatResponse, CloudflareD1Config, CloudflareKVConfig, ComplianceConfig, ComplianceViolation, ToolDefinition$1 as ConfigToolDefinition, ConvexConfig, CreateOrgRequest, CreateWorkspaceRequest, 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, PostgresConfig, ProjectMetadata, PublishAgentOptions, PublishRequest, PublishResponse, RedisConfig, RegistryClientConfig, ReputationLog, ReputationResponse, 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 };
3537
+ 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, 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 };
3538
+ 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, 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 };