@sekuire/sdk 0.1.9 → 0.1.10

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.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * A2A Protocol Client
3
+ *
4
+ * Client for interacting with A2A-compliant agents via the Sekuire API.
5
+ */
6
+ import type { A2AMessage, A2ARouteRequest, A2ARouteResponse, A2ATask, AgentCard, TasksSendParams, TaskUpdateEvent } from "./types/a2a-types";
7
+ export interface A2AClientOptions {
8
+ /** Base URL for the Sekuire API */
9
+ baseUrl: string;
10
+ /** Authentication token */
11
+ authToken: string;
12
+ /** Optional timeout in milliseconds (default: 30000) */
13
+ timeout?: number;
14
+ }
15
+ /**
16
+ * A2A Protocol Client
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const client = new A2AClient({
21
+ * baseUrl: "https://api.sekuire.ai",
22
+ * authToken: "your-token",
23
+ * });
24
+ *
25
+ * // Auto-discover and send task by skill
26
+ * const result = await client.sendBySkill({
27
+ * skill: "document:summarize",
28
+ * message: {
29
+ * role: "user",
30
+ * parts: [{ type: "text", text: "Summarize this document" }],
31
+ * },
32
+ * });
33
+ *
34
+ * // Stream task updates
35
+ * for await (const event of client.subscribe(result.taskId)) {
36
+ * console.log(event.status, event.artifacts);
37
+ * }
38
+ * ```
39
+ */
40
+ export declare class A2AClient {
41
+ private baseUrl;
42
+ private authToken;
43
+ private timeout;
44
+ constructor(options: A2AClientOptions);
45
+ /**
46
+ * Send a task by skill using auto-discovery routing.
47
+ * The API will find an agent with the matching skill and forward the task.
48
+ */
49
+ sendBySkill(request: A2ARouteRequest): Promise<A2ARouteResponse>;
50
+ /**
51
+ * Send a message directly to a specific agent.
52
+ */
53
+ send(agentUrl: string, message: A2AMessage, taskId?: string): Promise<A2ATask>;
54
+ /**
55
+ * Send a task via JSON-RPC to the Sekuire API.
56
+ */
57
+ sendTask(params: TasksSendParams): Promise<A2ATask>;
58
+ /**
59
+ * Get task status and details.
60
+ */
61
+ getTask(taskId: string): Promise<A2ATask>;
62
+ /**
63
+ * Cancel a running task.
64
+ */
65
+ cancelTask(taskId: string): Promise<A2ATask>;
66
+ /**
67
+ * Subscribe to task updates via SSE.
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * for await (const event of client.subscribe(taskId)) {
72
+ * console.log(event.status);
73
+ * if (event.status === "completed") break;
74
+ * }
75
+ * ```
76
+ */
77
+ subscribe(taskId: string): AsyncGenerator<TaskUpdateEvent>;
78
+ /**
79
+ * Get an agent's card (capabilities, skills).
80
+ */
81
+ getAgentCard(agentId: string): Promise<AgentCard>;
82
+ /**
83
+ * Make a JSON-RPC call to the A2A endpoint.
84
+ */
85
+ private jsonRpc;
86
+ private fetch;
87
+ }
88
+ /**
89
+ * A2A Protocol Error
90
+ */
91
+ export declare class A2AError extends Error {
92
+ readonly code: string;
93
+ readonly jsonRpcCode?: number | undefined;
94
+ constructor(message: string, code: string, jsonRpcCode?: number | undefined);
95
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * A2A Task Delegator
3
+ *
4
+ * Enables agents to delegate tasks to other agents and receive completion callbacks.
5
+ * Provides a complete feedback loop for multi-agent orchestration.
6
+ */
7
+ import type { A2AMessage, A2ATaskState, TaskUpdateEvent } from "./types/a2a-types";
8
+ export interface DelegatorConfig {
9
+ apiUrl: string;
10
+ authToken: string;
11
+ workspaceId: string;
12
+ agentId: string;
13
+ timeout?: number;
14
+ pollInterval?: number;
15
+ }
16
+ export interface DelegationRequest {
17
+ skill: string;
18
+ message: string | A2AMessage;
19
+ contextId?: string;
20
+ parentTaskId?: string;
21
+ traceId?: string;
22
+ timeout?: number;
23
+ onProgress?: (event: TaskUpdateEvent) => void;
24
+ }
25
+ export interface DelegationResult {
26
+ taskId: string;
27
+ agentId: string;
28
+ traceId?: string;
29
+ status: A2ATaskState;
30
+ result?: A2AMessage;
31
+ artifacts?: Array<{
32
+ name?: string;
33
+ parts: Array<{
34
+ type: string;
35
+ text?: string;
36
+ }>;
37
+ }>;
38
+ error?: string;
39
+ executionTimeMs: number;
40
+ }
41
+ export declare class A2ATaskDelegator {
42
+ private client;
43
+ private config;
44
+ private activeDelegations;
45
+ constructor(config: DelegatorConfig);
46
+ delegate(request: DelegationRequest): Promise<DelegationResult>;
47
+ delegateWithStreaming(request: DelegationRequest): AsyncGenerator<TaskUpdateEvent, DelegationResult>;
48
+ cancelDelegation(taskId: string): void;
49
+ cancelAllDelegations(): void;
50
+ discoverAgents(skill: string): Promise<Array<{
51
+ agentId: string;
52
+ name: string;
53
+ }>>;
54
+ private waitForCompletion;
55
+ private pollForCompletion;
56
+ private sleep;
57
+ }
58
+ export declare function createDelegator(config: DelegatorConfig): A2ATaskDelegator;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * A2A Protocol Server
3
+ *
4
+ * Server implementation for creating A2A-compliant agents with streaming support.
5
+ */
6
+ import type { A2AArtifact, A2AMessage, A2ATask, A2ATaskState, AgentCard, AgentSkill, JsonRpcRequest, JsonRpcResponse, TaskUpdateEvent } from "./types/a2a-types";
7
+ import { AgentIdentity } from "./identity";
8
+ export interface A2AServerOptions {
9
+ card: AgentCard;
10
+ identity?: AgentIdentity;
11
+ port?: number;
12
+ handlers: Record<string, SkillHandler>;
13
+ streamingHandlers?: Record<string, StreamingSkillHandler>;
14
+ }
15
+ export type SkillHandler = (message: A2AMessage, context: SkillContext) => Promise<A2AMessage | A2AArtifact[]>;
16
+ export type StreamingSkillHandler = (message: A2AMessage, context: StreamingSkillContext) => AsyncGenerator<StreamingUpdate>;
17
+ export interface SkillContext {
18
+ taskId: string;
19
+ contextId?: string;
20
+ history: A2AMessage[];
21
+ }
22
+ export interface StreamingSkillContext extends SkillContext {
23
+ emit: (update: StreamingUpdate) => void;
24
+ }
25
+ export type StreamingUpdate = {
26
+ type: "progress";
27
+ message: string;
28
+ percent?: number;
29
+ } | {
30
+ type: "artifact";
31
+ artifact: A2AArtifact;
32
+ } | {
33
+ type: "message";
34
+ message: A2AMessage;
35
+ } | {
36
+ type: "status";
37
+ status: A2ATaskState;
38
+ };
39
+ export interface TaskState {
40
+ id: string;
41
+ contextId?: string;
42
+ status: A2ATaskState;
43
+ history: A2AMessage[];
44
+ artifacts: A2AArtifact[];
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ subscribers: Set<(event: TaskUpdateEvent) => void>;
48
+ }
49
+ export declare class A2AServer {
50
+ private card;
51
+ private identity?;
52
+ private handlers;
53
+ private streamingHandlers;
54
+ private tasks;
55
+ private heartbeatInterval?;
56
+ constructor(options: A2AServerOptions);
57
+ /**
58
+ * Start sending heartbeats to the registry
59
+ * @param publicUrl The public URL where this agent is reachable
60
+ * @param registryUrl The registry API base URL (default: http://localhost:3000)
61
+ */
62
+ startHeartbeat(publicUrl: string, registryUrl?: string): Promise<void>;
63
+ stopHeartbeat(): void;
64
+ getAgentCard(): AgentCard;
65
+ getTask(taskId: string): TaskState | undefined;
66
+ handleRequest(request: JsonRpcRequest): Promise<JsonRpcResponse>;
67
+ handleStreamingRequest(request: JsonRpcRequest): AsyncGenerator<TaskUpdateEvent>;
68
+ subscribeToTask(taskId: string): AsyncGenerator<TaskUpdateEvent> | null;
69
+ formatSSE(event: TaskUpdateEvent): string;
70
+ notifySubscribers(taskId: string): void;
71
+ private handleTasksSend;
72
+ private handleTasksGet;
73
+ private handleTasksCancel;
74
+ private findHandler;
75
+ private findStreamingHandler;
76
+ private findHandlerInMap;
77
+ private extractText;
78
+ private createUpdateEvent;
79
+ private taskToResponse;
80
+ private success;
81
+ private error;
82
+ private generateId;
83
+ }
84
+ export type { A2AArtifact, A2AMessage, A2ATask, AgentCard, AgentSkill, TaskUpdateEvent };
package/dist/agent.d.ts CHANGED
@@ -30,7 +30,7 @@ export interface ToolDefinition<T extends z.ZodObject<any> = any> {
30
30
  /** Zod schema for input validation */
31
31
  schema: T;
32
32
  /** Tool execution function */
33
- execute: (input: z.infer<T>) => Promise<any> | any;
33
+ execute: (input: z.infer<T>) => Promise<unknown> | unknown;
34
34
  /** Optional: Additional compliance checks */
35
35
  beforeExecute?: (input: z.infer<T>) => Promise<void> | void;
36
36
  }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Sekuire Beacon - Deployment Registration & Heartbeat
3
+ *
4
+ * Automatically registers the agent with Sekuire and sends periodic heartbeats
5
+ * to show online status in the Dashboard.
6
+ */
7
+ export interface BeaconConfig {
8
+ /** Sekuire Core API base URL */
9
+ apiBaseUrl: string;
10
+ /** API key for authentication (reads from SEKUIRE_API_KEY if not set) */
11
+ apiKey?: string;
12
+ /** Agent ID to register */
13
+ agentId: string;
14
+ /** Heartbeat interval in milliseconds (default: 60000 = 60 seconds) */
15
+ heartbeatIntervalMs?: number;
16
+ /** Optional explicit deployment URL (auto-detected if not set) */
17
+ deploymentUrl?: string;
18
+ /** Optional callback to build a custom heartbeat payload (e.g. signed payloads) */
19
+ onHeartbeat?: (deploymentUrl: string | undefined) => Promise<Record<string, unknown>>;
20
+ /** Optional callback invoked on status changes */
21
+ onStatusChange?: (status: BeaconStatus) => void;
22
+ }
23
+ export interface BeaconStatus {
24
+ isRunning: boolean;
25
+ installationId?: string;
26
+ deploymentUrl?: string;
27
+ lastHeartbeat?: Date;
28
+ failedHeartbeats: number;
29
+ }
30
+ export declare class Beacon {
31
+ private config;
32
+ private intervalId;
33
+ private installationId;
34
+ private lastHeartbeat;
35
+ private failedHeartbeats;
36
+ constructor(config: BeaconConfig);
37
+ /**
38
+ * Start the beacon - registers with Sekuire and begins heartbeat loop
39
+ */
40
+ start(): Promise<void>;
41
+ /**
42
+ * Stop the beacon
43
+ */
44
+ stop(): void;
45
+ /**
46
+ * Get current beacon status
47
+ */
48
+ getStatus(): BeaconStatus;
49
+ /**
50
+ * Bootstrap registration with Sekuire
51
+ */
52
+ private bootstrap;
53
+ /**
54
+ * Send heartbeat to Sekuire
55
+ */
56
+ private heartbeat;
57
+ /**
58
+ * Get API key from environment
59
+ */
60
+ private getApiKey;
61
+ }
62
+ /**
63
+ * Create a new beacon instance
64
+ */
65
+ export declare function createBeacon(config: BeaconConfig): Beacon;
@@ -171,21 +171,21 @@ export declare class ComplianceMonitor {
171
171
  * @param codeSnippet Code snippet for pattern checking
172
172
  * @throws ToolUsageError If tool usage is blocked
173
173
  */
174
- checkToolUsage(toolName: string, codeSnippet?: string): boolean;
174
+ checkToolUsage(toolName: string, codeSnippet?: string): void;
175
175
  /**
176
176
  * 💬 Check input content for policy violations
177
177
  *
178
178
  * @param content Input content to check
179
179
  * @throws ContentPolicyError If content violates policy
180
180
  */
181
- checkInputContent(content: string): boolean;
181
+ checkInputContent(content: string): void;
182
182
  /**
183
183
  * 📤 Check output content for policy violations
184
184
  *
185
185
  * @param content Output content to check
186
186
  * @throws ContentPolicyError If content violates policy
187
187
  */
188
- checkOutputContent(content: string): boolean;
188
+ checkOutputContent(content: string): void;
189
189
  private checkContent;
190
190
  /**
191
191
  * 🤖 Check AI model usage compliance
package/dist/crypto.d.ts CHANGED
@@ -1,7 +1,4 @@
1
1
  import { type HexString, type KeyPair } from "./types";
2
- /**
3
- * Cryptographic utilities for Sekuire protocol
4
- */
5
2
  export declare class SekuireCrypto {
6
3
  /**
7
4
  * Generate a new Ed25519 keypair
@@ -0,0 +1,25 @@
1
+ export interface HttpClientConfig {
2
+ baseUrl: string;
3
+ timeout?: number;
4
+ retries?: number;
5
+ apiKey?: string;
6
+ authToken?: string;
7
+ }
8
+ export declare class HttpClient {
9
+ private baseUrl;
10
+ private timeout;
11
+ private retries;
12
+ private apiKey?;
13
+ private authToken?;
14
+ constructor(config: HttpClientConfig);
15
+ setAuthToken(token: string): void;
16
+ setApiKey(apiKey: string): void;
17
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
18
+ post<T>(path: string, data?: unknown): Promise<T>;
19
+ put<T>(path: string, data?: unknown): Promise<T>;
20
+ delete<T>(path: string): Promise<T>;
21
+ private resolveUrl;
22
+ private fetchWithRetry;
23
+ private shouldRetry;
24
+ private delay;
25
+ }
@@ -0,0 +1,2 @@
1
+ export { HttpClient } from './base-client';
2
+ export type { HttpClientConfig } from './base-client';
@@ -2,8 +2,17 @@ export declare class AgentIdentity {
2
2
  readonly name: string;
3
3
  readonly sekuireId: string;
4
4
  private readonly privateKey?;
5
- private readonly publicKey?;
5
+ readonly publicKey?: string | undefined;
6
6
  constructor(name: string, sekuireId: string, privateKey?: string | undefined, publicKey?: string | undefined);
7
7
  static load(manifestPath?: string): Promise<AgentIdentity>;
8
- sign(payload: any): Promise<string>;
8
+ /**
9
+ * Sign a message using Ed25519
10
+ * @param message The message string to sign
11
+ * @returns Hex-encoded signature
12
+ */
13
+ sign(message: string): Promise<string>;
14
+ /**
15
+ * Verify a signature (useful for testing)
16
+ */
17
+ verify(message: string, signatureHex: string): boolean;
9
18
  }