@kya-os/mcp-i-cloudflare 1.13.0 → 1.13.2

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.
Files changed (33) hide show
  1. package/dist/helpers/env-mapper.d.ts.map +1 -1
  2. package/dist/helpers/env-mapper.js +6 -0
  3. package/dist/helpers/env-mapper.js.map +1 -1
  4. package/dist/runtime/oauth-handler.d.ts.map +1 -1
  5. package/dist/runtime/oauth-handler.js +12 -1
  6. package/dist/runtime/oauth-handler.js.map +1 -1
  7. package/dist/runtime/oidc/idp-scopes.d.ts +26 -0
  8. package/dist/runtime/oidc/idp-scopes.d.ts.map +1 -0
  9. package/dist/runtime/oidc/idp-scopes.js +24 -0
  10. package/dist/runtime/oidc/idp-scopes.js.map +1 -0
  11. package/dist/services/batch-queue.d.ts +103 -0
  12. package/dist/services/batch-queue.d.ts.map +1 -0
  13. package/dist/services/batch-queue.js +180 -0
  14. package/dist/services/batch-queue.js.map +1 -0
  15. package/dist/services/consent.service.d.ts +7 -0
  16. package/dist/services/consent.service.d.ts.map +1 -1
  17. package/dist/services/consent.service.js +118 -61
  18. package/dist/services/consent.service.js.map +1 -1
  19. package/dist/services/kya-os-events.service.d.ts +131 -0
  20. package/dist/services/kya-os-events.service.d.ts.map +1 -0
  21. package/dist/services/kya-os-events.service.js +135 -0
  22. package/dist/services/kya-os-events.service.js.map +1 -0
  23. package/dist/services/proof-batch-queue.d.ts +15 -67
  24. package/dist/services/proof-batch-queue.d.ts.map +1 -1
  25. package/dist/services/proof-batch-queue.js +12 -147
  26. package/dist/services/proof-batch-queue.js.map +1 -1
  27. package/dist/services/proof.service.d.ts +7 -0
  28. package/dist/services/proof.service.d.ts.map +1 -1
  29. package/dist/services/proof.service.js +35 -0
  30. package/dist/services/proof.service.js.map +1 -1
  31. package/dist/types.d.ts +2 -0
  32. package/dist/types.d.ts.map +1 -1
  33. package/package.json +2 -2
@@ -0,0 +1,131 @@
1
+ /**
2
+ * KYA-OS Activity Events Emitter (Cloudflare Workers Implementation)
3
+ *
4
+ * Emits SPEC-EVENTS v0.1 audit events to a KYA-OS events sink (Checkpoint's
5
+ * `POST /api/v1/kya-os/events`), which fans them out into the activity feed.
6
+ *
7
+ * This is the activity-surface counterpart to the proof batch queue. The two
8
+ * are DELIBERATELY separate surfaces:
9
+ * - Proofs (`/api/v1/bouncer/proofs`) are cryptographic action receipts.
10
+ * - Activity events (`/api/v1/kya-os/events`) are the human-readable feed that
11
+ * powers the dashboard `/activity` view and per-deployment activity.
12
+ *
13
+ * Both share the same AgentShield credentials (`AGENTSHIELD_API_URL` +
14
+ * `AGENTSHIELD_API_KEY`) and the same generic {@link BatchQueue} engine:
15
+ * fire-and-forget, auto-flush at batch size, cron-driven flush across requests.
16
+ *
17
+ * Tool arguments and results NEVER appear in an event.
18
+ */
19
+ import { type BatchDestination } from "./batch-queue";
20
+ /** The SPEC-EVENTS schema version this emitter produces. */
21
+ export declare const SPEC_EVENTS_VERSION = "0.1";
22
+ /** Self-identification forwarded to the sink's `source.sdk` block. */
23
+ export declare const KYA_OS_EVENTS_SDK_NAME = "mcp-i-cloudflare";
24
+ /**
25
+ * A `tool.invoked` event (SPEC-EVENTS v0.1). Mirrors
26
+ * `toolInvokedEventSchema` in Checkpoint's `lib/api/schemas/kya-os-events.ts`.
27
+ */
28
+ export interface ToolInvokedEvent {
29
+ specVersion: string;
30
+ ts: string;
31
+ /** The emitting server. `serverDid` is REQUIRED on every event. */
32
+ source: {
33
+ serverDid: string;
34
+ sdk?: {
35
+ name: string;
36
+ version?: string;
37
+ };
38
+ };
39
+ session?: {
40
+ id: string;
41
+ agent?: {
42
+ did?: string;
43
+ };
44
+ };
45
+ type: "tool.invoked";
46
+ tool: {
47
+ name: string;
48
+ capability?: string;
49
+ };
50
+ verdict: "pass" | "fail";
51
+ /** Only when verdict=fail. */
52
+ error?: {
53
+ excerpt: string;
54
+ };
55
+ }
56
+ /** Union of the event types this emitter can produce (extensible). */
57
+ export type KyaOsEvent = ToolInvokedEvent;
58
+ /**
59
+ * KYA-OS events sink destination.
60
+ *
61
+ * POSTs a `{ events: [...] }` batch (1-100) to the sink with Bearer auth.
62
+ */
63
+ export declare class KyaOsEventsDestination implements BatchDestination<KyaOsEvent> {
64
+ name: string;
65
+ private apiUrl;
66
+ private apiKey;
67
+ constructor(apiUrl: string, apiKey: string);
68
+ submit(events: KyaOsEvent[]): Promise<void>;
69
+ }
70
+ /**
71
+ * Input to {@link KyaOsEventsEmitter.emitToolInvoked}. Purposefully small: the
72
+ * caller (the proof/tool-call seam) already holds all of this.
73
+ */
74
+ export interface ToolInvokedInput {
75
+ /** The emitting server's own DID (proof `meta.did`). REQUIRED. */
76
+ serverDid: string;
77
+ /** MCP session id, when known. */
78
+ sessionId?: string;
79
+ /** Verified calling-agent DID (holder-of-key), when known. */
80
+ agentDid?: string;
81
+ /** The dispatched tool name. REQUIRED. */
82
+ toolName: string;
83
+ /** Optional capability string for the tool. */
84
+ capability?: string;
85
+ /** Whether the dispatch succeeded. `false` => verdict "fail". */
86
+ success?: boolean;
87
+ /** Short failure excerpt (only forwarded when `success === false`). */
88
+ errorExcerpt?: string;
89
+ /** Injectable timestamp for deterministic tests; defaults to now. */
90
+ ts?: string;
91
+ }
92
+ export interface KyaOsEventsEmitterOptions {
93
+ maxBatchSize?: number;
94
+ maxRetries?: number;
95
+ debug?: boolean;
96
+ /** Emitting SDK version, forwarded as `source.sdk.version` when set. */
97
+ sdkVersion?: string;
98
+ }
99
+ /**
100
+ * Batches and submits KYA-OS activity events.
101
+ *
102
+ * Lifecycle mirrors the proof service: `emitToolInvoked` enqueues (auto-flush
103
+ * at batch size), and `flush()` is called from the scheduled (cron) handler to
104
+ * drain across requests.
105
+ */
106
+ export declare class KyaOsEventsEmitter {
107
+ private queue;
108
+ private sdkVersion?;
109
+ constructor(apiUrl: string, apiKey: string, options?: KyaOsEventsEmitterOptions);
110
+ /** Build the `source.sdk` block (name always; version when configured). */
111
+ private sdk;
112
+ /**
113
+ * Construct and enqueue a `tool.invoked` event.
114
+ *
115
+ * A `serverDid` or `toolName` that is empty is dropped (the sink requires
116
+ * both), so a malformed call can never poison a batch.
117
+ */
118
+ emitToolInvoked(input: ToolInvokedInput): void;
119
+ /** Drain the queue and retry any pending batches (cron-driven). */
120
+ flush(): Promise<void>;
121
+ /** Flush remaining events and stop accepting new ones. */
122
+ close(): Promise<void>;
123
+ /** Queue statistics (for diagnostics/tests). */
124
+ getStats(): {
125
+ queued: number;
126
+ submitted: number;
127
+ failed: number;
128
+ batchesSubmitted: number;
129
+ };
130
+ }
131
+ //# sourceMappingURL=kya-os-events.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kya-os-events.service.d.ts","sourceRoot":"","sources":["../../src/services/kya-os-events.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAElE,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAQzD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC1C,CAAC;IACF,OAAO,CAAC,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC1B,CAAC;IACF,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAA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EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,yBAA8B;IAazC,2EAA2E;IAC3E,OAAO,CAAC,GAAG;IAMX;;;;;OAKG;IACH,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAiC9C,mEAAmE;IAC7D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,0DAA0D;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,gDAAgD;IAChD,QAAQ;;;;;;CAGT"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * KYA-OS Activity Events Emitter (Cloudflare Workers Implementation)
3
+ *
4
+ * Emits SPEC-EVENTS v0.1 audit events to a KYA-OS events sink (Checkpoint's
5
+ * `POST /api/v1/kya-os/events`), which fans them out into the activity feed.
6
+ *
7
+ * This is the activity-surface counterpart to the proof batch queue. The two
8
+ * are DELIBERATELY separate surfaces:
9
+ * - Proofs (`/api/v1/bouncer/proofs`) are cryptographic action receipts.
10
+ * - Activity events (`/api/v1/kya-os/events`) are the human-readable feed that
11
+ * powers the dashboard `/activity` view and per-deployment activity.
12
+ *
13
+ * Both share the same AgentShield credentials (`AGENTSHIELD_API_URL` +
14
+ * `AGENTSHIELD_API_KEY`) and the same generic {@link BatchQueue} engine:
15
+ * fire-and-forget, auto-flush at batch size, cron-driven flush across requests.
16
+ *
17
+ * Tool arguments and results NEVER appear in an event.
18
+ */
19
+ import { BatchQueue } from "./batch-queue";
20
+ /** The SPEC-EVENTS schema version this emitter produces. */
21
+ export const SPEC_EVENTS_VERSION = "0.1";
22
+ /** Self-identification forwarded to the sink's `source.sdk` block. */
23
+ export const KYA_OS_EVENTS_SDK_NAME = "mcp-i-cloudflare";
24
+ /** The sink path appended to the AgentShield API base URL. */
25
+ const EVENTS_PATH = "/api/v1/kya-os/events";
26
+ /** Max characters retained from a failure excerpt (sink caps at 200). */
27
+ const MAX_ERROR_EXCERPT = 200;
28
+ /**
29
+ * KYA-OS events sink destination.
30
+ *
31
+ * POSTs a `{ events: [...] }` batch (1-100) to the sink with Bearer auth.
32
+ */
33
+ export class KyaOsEventsDestination {
34
+ name = "KyaOsEvents";
35
+ apiUrl;
36
+ apiKey;
37
+ constructor(apiUrl, apiKey) {
38
+ this.apiUrl = apiUrl.replace(/\/$/, "");
39
+ this.apiKey = apiKey;
40
+ }
41
+ async submit(events) {
42
+ if (events.length === 0) {
43
+ return;
44
+ }
45
+ const response = await fetch(`${this.apiUrl}${EVENTS_PATH}`, {
46
+ method: "POST",
47
+ headers: {
48
+ "Content-Type": "application/json",
49
+ Authorization: `Bearer ${this.apiKey}`,
50
+ },
51
+ body: JSON.stringify({ events }),
52
+ });
53
+ if (!response.ok) {
54
+ const errorBody = await response
55
+ .text()
56
+ .catch(() => "Unable to read error body");
57
+ throw new Error(`KYA-OS events submission failed: ${response.status} ${response.statusText}\n${errorBody}`);
58
+ }
59
+ }
60
+ }
61
+ /**
62
+ * Batches and submits KYA-OS activity events.
63
+ *
64
+ * Lifecycle mirrors the proof service: `emitToolInvoked` enqueues (auto-flush
65
+ * at batch size), and `flush()` is called from the scheduled (cron) handler to
66
+ * drain across requests.
67
+ */
68
+ export class KyaOsEventsEmitter {
69
+ queue;
70
+ sdkVersion;
71
+ constructor(apiUrl, apiKey, options = {}) {
72
+ this.sdkVersion = options.sdkVersion;
73
+ this.queue = new BatchQueue({
74
+ destinations: [new KyaOsEventsDestination(apiUrl, apiKey)],
75
+ maxBatchSize: options.maxBatchSize ?? 10,
76
+ maxRetries: options.maxRetries ?? 3,
77
+ debug: options.debug ?? false,
78
+ logPrefix: "KyaOsEventsEmitter",
79
+ noun: "event",
80
+ });
81
+ }
82
+ /** Build the `source.sdk` block (name always; version when configured). */
83
+ sdk() {
84
+ return this.sdkVersion
85
+ ? { name: KYA_OS_EVENTS_SDK_NAME, version: this.sdkVersion }
86
+ : { name: KYA_OS_EVENTS_SDK_NAME };
87
+ }
88
+ /**
89
+ * Construct and enqueue a `tool.invoked` event.
90
+ *
91
+ * A `serverDid` or `toolName` that is empty is dropped (the sink requires
92
+ * both), so a malformed call can never poison a batch.
93
+ */
94
+ emitToolInvoked(input) {
95
+ if (!input.serverDid || !input.toolName) {
96
+ return;
97
+ }
98
+ const failed = input.success === false;
99
+ const event = {
100
+ specVersion: SPEC_EVENTS_VERSION,
101
+ ts: input.ts ?? new Date().toISOString(),
102
+ source: { serverDid: input.serverDid, sdk: this.sdk() },
103
+ type: "tool.invoked",
104
+ tool: {
105
+ name: input.toolName,
106
+ ...(input.capability ? { capability: input.capability } : {}),
107
+ },
108
+ verdict: failed ? "fail" : "pass",
109
+ };
110
+ if (input.sessionId) {
111
+ event.session = {
112
+ id: input.sessionId,
113
+ ...(input.agentDid ? { agent: { did: input.agentDid } } : {}),
114
+ };
115
+ }
116
+ if (failed && input.errorExcerpt) {
117
+ event.error = { excerpt: input.errorExcerpt.slice(0, MAX_ERROR_EXCERPT) };
118
+ }
119
+ this.queue.enqueue(event);
120
+ }
121
+ /** Drain the queue and retry any pending batches (cron-driven). */
122
+ async flush() {
123
+ await this.queue.flush();
124
+ await this.queue.retryPending();
125
+ }
126
+ /** Flush remaining events and stop accepting new ones. */
127
+ async close() {
128
+ await this.queue.close();
129
+ }
130
+ /** Queue statistics (for diagnostics/tests). */
131
+ getStats() {
132
+ return this.queue.getStats();
133
+ }
134
+ }
135
+ //# sourceMappingURL=kya-os-events.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kya-os-events.service.js","sourceRoot":"","sources":["../../src/services/kya-os-events.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAyB,MAAM,eAAe,CAAC;AAElE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,sEAAsE;AACtE,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,8DAA8D;AAC9D,MAAM,WAAW,GAAG,uBAAu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AAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;SAClC,CAAC;QAEF,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,KAAK,CAAC,OAAO,GAAG;gBACd,EAAE,EAAE,KAAK,CAAC,SAAS;gBACnB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9D,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;YACjC,KAAK,CAAC,KAAK,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,EAAE,CAAC;QAC5E,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;IAClC,CAAC;IAED,0DAA0D;IAC1D,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,gDAAgD;IAChD,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF"}
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Proof Batch Queue (Cloudflare Workers Implementation)
3
3
  *
4
- * Platform-agnostic proof batching for Cloudflare Workers.
5
- * Copied from @kya-os/mcp-i to avoid pulling in @swc/core dependency.
6
- *
7
- * Collects proofs in memory and submits them in batches to AgentShield.
8
- * This prevents blocking tool execution while ensuring proofs are eventually submitted.
4
+ * Proof-typed view over the generic {@link BatchQueue}. Collects proofs in
5
+ * memory and submits them in batches to AgentShield, without blocking tool
6
+ * execution. All batching/retry/flush semantics live in `batch-queue.ts`;
7
+ * this module only adds the proof-specific destination wire format.
9
8
  *
10
9
  * Performance:
11
10
  * - Batch size: 10 proofs (configurable)
@@ -18,17 +17,13 @@
18
17
  * - Failed proofs logged and dropped after max retries
19
18
  */
20
19
  import type { DetachedProof } from "@kya-os/contracts/proof";
20
+ import { BatchQueue, type BatchDestination, type BatchQueueConfig } from "./batch-queue";
21
21
  /**
22
- * Proof submission destination
22
+ * Proof submission destination.
23
23
  */
24
- export interface ProofDestination {
25
- /** Destination name (for logging) */
26
- name: string;
27
- /** Submit batch of proofs */
28
- submit(proofs: DetachedProof[]): Promise<void>;
29
- }
24
+ export type ProofDestination = BatchDestination<DetachedProof>;
30
25
  /**
31
- * AgentShield proof submission destination
26
+ * AgentShield proof submission destination.
32
27
  *
33
28
  * Submits proofs to AgentShield's /api/v1/bouncer/proofs endpoint
34
29
  * with proper authentication and session grouping.
@@ -41,64 +36,17 @@ export declare class AgentShieldProofDestination implements ProofDestination {
41
36
  submit(proofs: DetachedProof[]): Promise<void>;
42
37
  }
43
38
  /**
44
- * Proof batch queue configuration
39
+ * Proof batch queue configuration.
45
40
  */
46
- export interface ProofBatchQueueConfig {
47
- /** Destinations to submit proofs to */
48
- destinations: ProofDestination[];
49
- /** Maximum batch size before auto-flush */
50
- maxBatchSize?: number;
51
- /** Flush interval in milliseconds (not used in Cloudflare Workers - rely on cron) */
52
- flushIntervalMs?: number;
53
- /** Maximum retry attempts for failed batches */
54
- maxRetries?: number;
55
- /** Enable debug logging */
56
- debug?: boolean;
57
- }
41
+ export type ProofBatchQueueConfig = Omit<BatchQueueConfig<DetachedProof>, "logPrefix" | "noun">;
58
42
  /**
59
- * Proof Batch Queue
60
- *
61
- * Collects proofs and submits them in batches to multiple destinations.
43
+ * Proof Batch Queue.
62
44
  *
63
- * Note: In Cloudflare Workers, timers don't persist across requests,
64
- * so automatic flush timers are disabled. Use manual flush() calls via cron jobs.
45
+ * A {@link BatchQueue} specialized for {@link DetachedProof}s. Preserves the
46
+ * historical public surface (constructor config, `enqueue`, `flush`,
47
+ * `retryPending`, `close`, `getStats`) and log wording (`[ProofBatchQueue]`).
65
48
  */
66
- export declare class ProofBatchQueue {
67
- private queue;
68
- private pendingBatches;
69
- private config;
70
- private closed;
71
- private stats;
49
+ export declare class ProofBatchQueue extends BatchQueue<DetachedProof> {
72
50
  constructor(config: ProofBatchQueueConfig);
73
- /**
74
- * Add proof to queue
75
- */
76
- enqueue(proof: DetachedProof): void;
77
- /**
78
- * Flush queue immediately (submit all queued proofs)
79
- */
80
- flush(): Promise<void>;
81
- /**
82
- * Submit batch to destination (with retries)
83
- */
84
- private submitBatch;
85
- /**
86
- * Retry pending batches that are ready
87
- * Called by cron job or manually
88
- */
89
- retryPending(): Promise<void>;
90
- /**
91
- * Close queue and flush remaining proofs
92
- */
93
- close(): Promise<void>;
94
- /**
95
- * Get queue statistics
96
- */
97
- getStats(): {
98
- queued: number;
99
- submitted: number;
100
- failed: number;
101
- batchesSubmitted: number;
102
- };
103
51
  }
104
52
  //# sourceMappingURL=proof-batch-queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"proof-batch-queue.d.ts","sourceRoot":"","sources":["../../src/services/proof-batch-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IAEb,6BAA6B;IAC7B,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,YAAW,gBAAgB;IAClE,IAAI,SAAiB;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO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C;AAEvB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,qBAAa,2BAA4B,YAAW,gBAAgB;IAClE,IAAI,SAAiB;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKpC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAmCrD;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,gBAAgB,CAAC,aAAa,CAAC,EAC/B,WAAW,GAAG,MAAM,CACrB,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa,CAAC;gBAChD,MAAM,EAAE,qBAAqB;CAG1C"}
@@ -1,11 +1,10 @@
1
1
  /**
2
2
  * Proof Batch Queue (Cloudflare Workers Implementation)
3
3
  *
4
- * Platform-agnostic proof batching for Cloudflare Workers.
5
- * Copied from @kya-os/mcp-i to avoid pulling in @swc/core dependency.
6
- *
7
- * Collects proofs in memory and submits them in batches to AgentShield.
8
- * This prevents blocking tool execution while ensuring proofs are eventually submitted.
4
+ * Proof-typed view over the generic {@link BatchQueue}. Collects proofs in
5
+ * memory and submits them in batches to AgentShield, without blocking tool
6
+ * execution. All batching/retry/flush semantics live in `batch-queue.ts`;
7
+ * this module only adds the proof-specific destination wire format.
9
8
  *
10
9
  * Performance:
11
10
  * - Batch size: 10 proofs (configurable)
@@ -17,8 +16,9 @@
17
16
  * - Max retries: 5
18
17
  * - Failed proofs logged and dropped after max retries
19
18
  */
19
+ import { BatchQueue, } from "./batch-queue";
20
20
  /**
21
- * AgentShield proof submission destination
21
+ * AgentShield proof submission destination.
22
22
  *
23
23
  * Submits proofs to AgentShield's /api/v1/bouncer/proofs endpoint
24
24
  * with proper authentication and session grouping.
@@ -62,150 +62,15 @@ export class AgentShieldProofDestination {
62
62
  }
63
63
  }
64
64
  /**
65
- * Proof Batch Queue
66
- *
67
- * Collects proofs and submits them in batches to multiple destinations.
65
+ * Proof Batch Queue.
68
66
  *
69
- * Note: In Cloudflare Workers, timers don't persist across requests,
70
- * so automatic flush timers are disabled. Use manual flush() calls via cron jobs.
67
+ * A {@link BatchQueue} specialized for {@link DetachedProof}s. Preserves the
68
+ * historical public surface (constructor config, `enqueue`, `flush`,
69
+ * `retryPending`, `close`, `getStats`) and log wording (`[ProofBatchQueue]`).
71
70
  */
72
- export class ProofBatchQueue {
73
- queue = [];
74
- pendingBatches = [];
75
- config;
76
- closed = false;
77
- // Stats
78
- stats = {
79
- queued: 0,
80
- submitted: 0,
81
- failed: 0,
82
- batchesSubmitted: 0,
83
- };
71
+ export class ProofBatchQueue extends BatchQueue {
84
72
  constructor(config) {
85
- this.config = {
86
- destinations: config.destinations,
87
- maxBatchSize: config.maxBatchSize || 10,
88
- flushIntervalMs: config.flushIntervalMs || 5000,
89
- maxRetries: config.maxRetries || 5,
90
- debug: config.debug || false,
91
- };
92
- // Note: Timers are disabled in Cloudflare Workers
93
- // Flush must be called manually via cron jobs
94
- }
95
- /**
96
- * Add proof to queue
97
- */
98
- enqueue(proof) {
99
- if (this.closed) {
100
- console.warn("[ProofBatchQueue] Queue is closed, dropping proof");
101
- return;
102
- }
103
- this.queue.push(proof);
104
- this.stats.queued++;
105
- if (this.config.debug) {
106
- console.error(`[ProofBatchQueue] Enqueued proof (queue size: ${this.queue.length})`);
107
- }
108
- // Flush immediately if batch size reached (Cloudflare Workers compatible)
109
- if (this.queue.length >= this.config.maxBatchSize) {
110
- this.flush();
111
- }
112
- }
113
- /**
114
- * Flush queue immediately (submit all queued proofs)
115
- */
116
- async flush() {
117
- if (this.queue.length === 0) {
118
- return;
119
- }
120
- const proofs = this.queue.splice(0, this.config.maxBatchSize);
121
- if (this.config.debug) {
122
- console.error(`[ProofBatchQueue] Flushing ${proofs.length} proofs to ${this.config.destinations.length} destinations`);
123
- }
124
- // Submit to all destinations
125
- for (const destination of this.config.destinations) {
126
- const batch = {
127
- proofs: [...proofs], // Copy proofs for each destination
128
- destination,
129
- retryCount: 0,
130
- };
131
- this.submitBatch(batch); // Fire-and-forget
132
- }
133
- }
134
- /**
135
- * Submit batch to destination (with retries)
136
- */
137
- async submitBatch(batch) {
138
- try {
139
- await batch.destination.submit(batch.proofs);
140
- this.stats.submitted += batch.proofs.length;
141
- this.stats.batchesSubmitted++;
142
- if (this.config.debug) {
143
- console.error(`[ProofBatchQueue] Successfully submitted ${batch.proofs.length} proofs to ${batch.destination.name}`);
144
- }
145
- }
146
- catch (error) {
147
- console.error(`[ProofBatchQueue] Failed to submit to ${batch.destination.name}:`, error);
148
- // Retry with exponential backoff
149
- if (batch.retryCount < this.config.maxRetries) {
150
- batch.retryCount++;
151
- const backoffMs = Math.min(1000 * Math.pow(2, batch.retryCount - 1), 16000);
152
- batch.nextRetryAt = Date.now() + backoffMs;
153
- this.pendingBatches.push(batch);
154
- if (this.config.debug) {
155
- console.error(`[ProofBatchQueue] Scheduling retry ${batch.retryCount}/${this.config.maxRetries} in ${backoffMs}ms`);
156
- }
157
- }
158
- else {
159
- // Max retries exceeded, drop batch
160
- this.stats.failed += batch.proofs.length;
161
- console.error(`[ProofBatchQueue] Max retries exceeded for ${batch.destination.name}, dropping ${batch.proofs.length} proofs`);
162
- }
163
- }
164
- }
165
- /**
166
- * Retry pending batches that are ready
167
- * Called by cron job or manually
168
- */
169
- async retryPending() {
170
- const now = Date.now();
171
- const retryBatches = this.pendingBatches.filter((batch) => batch.nextRetryAt && batch.nextRetryAt <= now);
172
- if (retryBatches.length > 0) {
173
- // Remove from pending
174
- this.pendingBatches = this.pendingBatches.filter((batch) => !retryBatches.includes(batch));
175
- // Retry each batch
176
- for (const batch of retryBatches) {
177
- this.submitBatch(batch); // Fire-and-forget
178
- }
179
- }
180
- }
181
- /**
182
- * Close queue and flush remaining proofs
183
- */
184
- async close() {
185
- if (this.closed) {
186
- return;
187
- }
188
- this.closed = true;
189
- // Flush remaining proofs
190
- if (this.queue.length > 0) {
191
- await this.flush();
192
- }
193
- // Wait for pending batches (with timeout)
194
- const timeout = 5000; // 5 seconds
195
- const startTime = Date.now();
196
- while (this.pendingBatches.length > 0 && Date.now() - startTime < timeout) {
197
- await this.retryPending();
198
- await new Promise((resolve) => setTimeout(resolve, 100));
199
- }
200
- if (this.pendingBatches.length > 0) {
201
- console.warn(`[ProofBatchQueue] Closing with ${this.pendingBatches.length} pending batches (timed out)`);
202
- }
203
- }
204
- /**
205
- * Get queue statistics
206
- */
207
- getStats() {
208
- return { ...this.stats };
73
+ super({ ...config, logPrefix: "ProofBatchQueue", noun: "proof" });
209
74
  }
210
75
  }
211
76
  //# sourceMappingURL=proof-batch-queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"proof-batch-queue.js","sourceRoot":"","sources":["../../src/services/proof-batch-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAeH;;;;;GAKG;AACH,MAAM,OAAO,2BAA2B;IACtC,IAAI,GAAG,aAAa,CAAC;IACb,MAAM,CAAS;IACf,MAAM,CAAS;IAEvB,YAAY,MAAc,EAAE,MAAc;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAuB;QAClC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,uEAAuE;QACvE,+DAA+D;QAC/D,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,IAAI,SAAS,CAAC;QAE1D,uEAAuE;QACvE,MAAM,WAAW,GAAG;YAClB,aAAa,EAAE,IAAI,EAAE,6CAA6C;YAClE,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chQueue?;
30
+ /**
31
+ * Emits SPEC-EVENTS `tool.invoked` activity events to the KYA-OS events sink
32
+ * (the dashboard `/activity` feed). Separate surface from proofs; shares the
33
+ * same AgentShield credentials. Absent when no valid AgentShield destination
34
+ * is configured.
35
+ */
36
+ private eventsEmitter?;
30
37
  private firstProofSubmitted;
31
38
  constructor(config: CloudflareRuntimeConfig, runtime?: CloudflareRuntime);
32
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"proof.service.d.ts","sourceRoot":"","sources":["../../src/services/proof.service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAEV,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAC;AAQrE,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAGF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAEnC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuCD,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,OAAO,CAAC,CAAoB;IACpC,OAAO,CAAC,UAAU,CAAC,CAAkB;IACrC,OAAO,CAAC,mBAAmB,CAAS;gBAExB,MAAM,EAAE,uBAAuB,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAmHxE;;;;;;;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