@sekuire/sdk 0.1.12 → 0.1.13

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/beacon.d.ts CHANGED
@@ -70,6 +70,18 @@ export declare class Beacon {
70
70
  * Get current beacon status
71
71
  */
72
72
  getStatus(): BeaconStatus;
73
+ /**
74
+ * Get runtime credentials after successful bootstrap.
75
+ *
76
+ * Use this to share credentials with other components (e.g., TaskWorker)
77
+ * to avoid dual bootstrap token consumption.
78
+ *
79
+ * @returns Runtime credentials or null if not bootstrapped
80
+ */
81
+ getRuntimeCredentials(): {
82
+ installationId: string;
83
+ runtimeToken: string;
84
+ } | null;
73
85
  /**
74
86
  * Bootstrap with retry and exponential backoff
75
87
  *
package/dist/index.d.ts CHANGED
@@ -75,6 +75,18 @@ declare class Beacon {
75
75
  * Get current beacon status
76
76
  */
77
77
  getStatus(): BeaconStatus;
78
+ /**
79
+ * Get runtime credentials after successful bootstrap.
80
+ *
81
+ * Use this to share credentials with other components (e.g., TaskWorker)
82
+ * to avoid dual bootstrap token consumption.
83
+ *
84
+ * @returns Runtime credentials or null if not bootstrapped
85
+ */
86
+ getRuntimeCredentials(): {
87
+ installationId: string;
88
+ runtimeToken: string;
89
+ } | null;
78
90
  /**
79
91
  * Bootstrap with retry and exponential backoff
80
92
  *
@@ -240,6 +252,120 @@ declare class SekuireLogger {
240
252
  setEnabled(enabled: boolean): void;
241
253
  }
242
254
 
255
+ /**
256
+ * Sekuire Task Worker
257
+ *
258
+ * Handles SSE connection to Core for real-time task delivery.
259
+ * Provides `onTask()` API for agents to register task handlers.
260
+ */
261
+ interface TaskEvent {
262
+ task_id: string;
263
+ capability?: string;
264
+ tool?: string;
265
+ input: Record<string, unknown>;
266
+ workspace_id: string;
267
+ requester_agent_id?: string;
268
+ parent_task_id?: string;
269
+ trace_id?: string;
270
+ workflow_id?: string;
271
+ }
272
+ interface TaskContext {
273
+ taskId: string;
274
+ workspaceId: string;
275
+ requesterId?: string;
276
+ parentTaskId?: string;
277
+ traceId?: string;
278
+ workflowId?: string;
279
+ }
280
+ type TaskHandler = (ctx: TaskContext, input: Record<string, unknown>) => Promise<unknown>;
281
+ interface WorkerConfig {
282
+ apiBaseUrl: string;
283
+ agentId: string;
284
+ installToken?: string;
285
+ runtimeToken?: string;
286
+ heartbeatIntervalMs?: number;
287
+ reconnectDelayMs?: number;
288
+ maxReconnectDelayMs?: number;
289
+ deploymentUrl?: string;
290
+ capabilities?: string[];
291
+ }
292
+ declare class TaskWorker {
293
+ private eventSource;
294
+ private handlers;
295
+ private config;
296
+ private heartbeatInterval;
297
+ private reconnectDelay;
298
+ private isConnected;
299
+ private isPaused;
300
+ private installationId;
301
+ private runtimeToken;
302
+ private refreshToken;
303
+ private expiresAt;
304
+ private onCommandCallback?;
305
+ constructor(config: WorkerConfig);
306
+ /**
307
+ * Register a handler for a specific capability
308
+ */
309
+ onTask(capability: string, handler: TaskHandler): this;
310
+ /**
311
+ * Start the worker (connects to SSE stream and starts heartbeat)
312
+ */
313
+ start(): Promise<void>;
314
+ /**
315
+ * Stop the worker gracefully
316
+ */
317
+ stop(): Promise<void>;
318
+ /**
319
+ * Check if the worker is currently paused
320
+ */
321
+ getIsPaused(): boolean;
322
+ /**
323
+ * Register a callback for control commands
324
+ */
325
+ onCommand(callback: (cmd: {
326
+ type: string;
327
+ reason?: string;
328
+ }) => void): this;
329
+ /**
330
+ * Handle control commands from SSE or heartbeat fallback
331
+ */
332
+ private handleCommand;
333
+ /**
334
+ * Get runtime token for API calls
335
+ */
336
+ private getToken;
337
+ /**
338
+ * Connect to SSE stream
339
+ */
340
+ private connect;
341
+ /**
342
+ * Schedule reconnection with exponential backoff
343
+ */
344
+ private scheduleReconnect;
345
+ /**
346
+ * Handle incoming task
347
+ */
348
+ private handleTask;
349
+ /**
350
+ * Report task completion to Core
351
+ */
352
+ private completeTask;
353
+ /**
354
+ * Register this agent installation with Sekuire using install_token
355
+ * Returns runtime_token for subsequent API calls
356
+ */
357
+ private bootstrap;
358
+ /**
359
+ * Start heartbeat/lease renewal loop
360
+ */
361
+ private startHeartbeat;
362
+ /**
363
+ * Refresh the runtime token using the refresh token
364
+ */
365
+ private refreshRuntimeToken;
366
+ }
367
+ declare function createWorker(config: WorkerConfig): TaskWorker;
368
+
243
369
  /**
244
370
  * SekuireSDK - Main SDK entry point for TypeScript agents
245
371
  *
@@ -330,6 +456,47 @@ declare class SekuireSDK {
330
456
  * Get the current beacon status (heartbeat health, connection info).
331
457
  */
332
458
  getBeaconStatus(): BeaconStatus;
459
+ /**
460
+ * Get runtime credentials after SDK has started.
461
+ *
462
+ * Use this to share credentials with TaskWorker to avoid dual bootstrap
463
+ * token consumption. The SDK must be started first.
464
+ *
465
+ * @returns Runtime credentials or null if not bootstrapped
466
+ */
467
+ getRuntimeCredentials(): {
468
+ installationId: string;
469
+ runtimeToken: string;
470
+ } | null;
471
+ /**
472
+ * Create a TaskWorker that shares credentials with this SDK instance.
473
+ *
474
+ * This avoids the dual bootstrap token consumption issue by reusing
475
+ * the runtime credentials from the SDK's beacon. The SDK must be started
476
+ * before calling this method.
477
+ *
478
+ * @param options Optional worker configuration overrides
479
+ * @returns TaskWorker instance ready to be started
480
+ * @throws Error if SDK hasn't been started or bootstrap failed
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * const sdk = new SekuireSDK({ ... });
485
+ * await sdk.start();
486
+ *
487
+ * const worker = sdk.createTaskWorker();
488
+ * worker.onTask("my-capability", async (ctx, input) => {
489
+ * return { result: "done" };
490
+ * });
491
+ * await worker.start();
492
+ * ```
493
+ */
494
+ createTaskWorker(options?: {
495
+ heartbeatIntervalMs?: number;
496
+ reconnectDelayMs?: number;
497
+ maxReconnectDelayMs?: number;
498
+ capabilities?: string[];
499
+ }): TaskWorker;
333
500
  /**
334
501
  * Get the agent ID.
335
502
  */
@@ -2586,120 +2753,6 @@ declare function calculateSekuireId(params: {
2586
2753
  */
2587
2754
  declare function createSekuireClient(keyPair: KeyPair, registryUrl?: string, options?: Partial<SekuireClientConfig>): SekuireClient;
2588
2755
 
2589
- /**
2590
- * Sekuire Task Worker
2591
- *
2592
- * Handles SSE connection to Core for real-time task delivery.
2593
- * Provides `onTask()` API for agents to register task handlers.
2594
- */
2595
- interface TaskEvent {
2596
- task_id: string;
2597
- capability?: string;
2598
- tool?: string;
2599
- input: Record<string, unknown>;
2600
- workspace_id: string;
2601
- requester_agent_id?: string;
2602
- parent_task_id?: string;
2603
- trace_id?: string;
2604
- workflow_id?: string;
2605
- }
2606
- interface TaskContext {
2607
- taskId: string;
2608
- workspaceId: string;
2609
- requesterId?: string;
2610
- parentTaskId?: string;
2611
- traceId?: string;
2612
- workflowId?: string;
2613
- }
2614
- type TaskHandler = (ctx: TaskContext, input: Record<string, unknown>) => Promise<unknown>;
2615
- interface WorkerConfig {
2616
- apiBaseUrl: string;
2617
- agentId: string;
2618
- installToken?: string;
2619
- runtimeToken?: string;
2620
- heartbeatIntervalMs?: number;
2621
- reconnectDelayMs?: number;
2622
- maxReconnectDelayMs?: number;
2623
- deploymentUrl?: string;
2624
- capabilities?: string[];
2625
- }
2626
- declare class TaskWorker {
2627
- private eventSource;
2628
- private handlers;
2629
- private config;
2630
- private heartbeatInterval;
2631
- private reconnectDelay;
2632
- private isConnected;
2633
- private isPaused;
2634
- private installationId;
2635
- private runtimeToken;
2636
- private refreshToken;
2637
- private expiresAt;
2638
- private onCommandCallback?;
2639
- constructor(config: WorkerConfig);
2640
- /**
2641
- * Register a handler for a specific capability
2642
- */
2643
- onTask(capability: string, handler: TaskHandler): this;
2644
- /**
2645
- * Start the worker (connects to SSE stream and starts heartbeat)
2646
- */
2647
- start(): Promise<void>;
2648
- /**
2649
- * Stop the worker gracefully
2650
- */
2651
- stop(): Promise<void>;
2652
- /**
2653
- * Check if the worker is currently paused
2654
- */
2655
- getIsPaused(): boolean;
2656
- /**
2657
- * Register a callback for control commands
2658
- */
2659
- onCommand(callback: (cmd: {
2660
- type: string;
2661
- reason?: string;
2662
- }) => void): this;
2663
- /**
2664
- * Handle control commands from SSE or heartbeat fallback
2665
- */
2666
- private handleCommand;
2667
- /**
2668
- * Get runtime token for API calls
2669
- */
2670
- private getToken;
2671
- /**
2672
- * Connect to SSE stream
2673
- */
2674
- private connect;
2675
- /**
2676
- * Schedule reconnection with exponential backoff
2677
- */
2678
- private scheduleReconnect;
2679
- /**
2680
- * Handle incoming task
2681
- */
2682
- private handleTask;
2683
- /**
2684
- * Report task completion to Core
2685
- */
2686
- private completeTask;
2687
- /**
2688
- * Register this agent installation with Sekuire using install_token
2689
- * Returns runtime_token for subsequent API calls
2690
- */
2691
- private bootstrap;
2692
- /**
2693
- * Start heartbeat/lease renewal loop
2694
- */
2695
- private startHeartbeat;
2696
- /**
2697
- * Refresh the runtime token using the refresh token
2698
- */
2699
- private refreshRuntimeToken;
2700
- }
2701
- declare function createWorker(config: WorkerConfig): TaskWorker;
2702
-
2703
2756
  interface SekuireExporterConfig {
2704
2757
  apiUrl: string;
2705
2758
  agentId: string;