@securecoms/agent-bridge 0.21.0 → 0.23.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.
@@ -0,0 +1,7 @@
1
+ export type ServiceLogLevel = "debug" | "info" | "warn" | "error";
2
+ export type ServiceLogFields = Readonly<Record<string, number | boolean>>;
3
+ export type ServiceLog = (level: ServiceLogLevel, event: string, fields?: ServiceLogFields, error?: unknown) => void;
4
+ /** Reduce a thrown value without reading its message, stack, or string form. */
5
+ export declare function errorClass(error: unknown): string;
6
+ export declare function formatServiceLog(level: ServiceLogLevel, event: string, fields?: ServiceLogFields, error?: unknown): string;
7
+ export declare function writeServiceLog(level: ServiceLogLevel, event: string, fields?: ServiceLogFields, error?: unknown): void;
@@ -1,3 +1,4 @@
1
+ import type { ServiceLog } from "./service-log.js";
1
2
  export declare const SUMMARY_PROMPT: string;
2
3
  export interface WireTranscriptTurn {
3
4
  t: number;
@@ -29,7 +30,7 @@ export interface SummarizeRequest {
29
30
  requestedBy: string;
30
31
  transcript: WireTranscript;
31
32
  }
32
- export declare function parseSummarizeBody(parsed: unknown, selfIdentityId: string, log?: (message: string) => void): SummarizeRequest | null;
33
+ export declare function parseSummarizeBody(parsed: unknown, selfIdentityId: string, log?: ServiceLog): SummarizeRequest | null;
33
34
  export declare function transcriptToPrompt(transcript: WireTranscript): string;
34
35
  export declare function parseSummaryOutput(text: string): {
35
36
  paragraph: string;
@@ -50,5 +51,5 @@ export declare function runSummarize(opts: {
50
51
  }) => Promise<string>;
51
52
  timeoutMs?: number;
52
53
  now?: () => Date;
53
- log: (message: string) => void;
54
+ log: ServiceLog;
54
55
  }): Promise<Record<string, unknown> | null>;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const BRIDGE_VERSION = "0.21.0";
1
+ export declare const BRIDGE_VERSION = "0.23.0";
@@ -14,12 +14,21 @@
14
14
  * { "type":"sent", message_id } // ack of a send
15
15
  * { "type":"ok" } // ack of a status report
16
16
  * { "type":"error", error, message, detail? } // canonical codes (see errors.ts):
17
- * // channel_pending | invalid_request
17
+ * // channel_pending | rate_limited |
18
+ * // invalid_request | agent_paused |
19
+ * // send_forbidden (the last two are
20
+ * // TERMINAL: the in_reply_to message
21
+ * // is acked by the daemon, no retry)
18
22
  * Agent → daemon:
19
23
  * { "type":"send", channel_id, text?, a2a?, idempotency_key?,
20
24
  * in_reply_to? } // exactly one of text | a2a; correlation is metadata-only
21
25
  * { "type":"status", channel_id, state, detail? }
22
26
  * { "type":"ack", message_id } // confirms a delivered `message` was consumed
27
+ * { "type":"nack", message_id, reason? } // final-wave I1(b): THIS message's turn
28
+ * // failed — requeued behind a backoff; the
29
+ * // socket and other channels' turns stay up
30
+ * { "type":"hello", features? } // → { "type":"hello", features:["nack"] }; a
31
+ * // runtime nacks only after seeing "nack" here
23
32
  * { "type":"action_begin", channel_id } // → { "type":"action_begun", run_id }
24
33
  * { "type":"action_start", run_id, node_type, title, parent_id? } // → { "type":"action_started", node_id }
25
34
  * { "type":"action_update", run_id, node_id, status?, detail? } // → { "type":"ok" }
@@ -31,6 +40,22 @@
31
40
  * is re-buffered and redelivered to the next consumer. The agent dedups by
32
41
  * message_id (a fresh UUID minted per send; server-side dedup is on replay_nonce).
33
42
  *
43
+ * Bounded work (Phase 3):
44
+ * - F2 ordering: at most ONE message per channel is in flight on a socket;
45
+ * the next message for that channel is sent only after the previous one is
46
+ * acked (or retired). A backlog replays in order instead of flooding the
47
+ * runtime, which used to answer the overflow with a "busy" reply and ack it.
48
+ * - F1 attempt cap: every delivery is counted durably; a message that
49
+ * reaches the cap is dead-lettered (content-free log + ack + one
50
+ * content-free notice to the channel per hour) rather than redelivered
51
+ * forever, and a channel where the agent is paused is not delivered at
52
+ * all (no model call).
53
+ * - Final-wave I1: a FAILED delivery (a `nack`, or the socket closing with
54
+ * it in flight — older runtimes close on any failed turn) is requeued
55
+ * behind a 2^attempts × 5 s backoff. A nack fails only its own message.
56
+ * Messages never handed over (mid-flush close, a failed frame write) go
57
+ * back without that penalty.
58
+ *
34
59
  * Single consumer: the daemon serves one agent per process. A new `/v1/ws`
35
60
  * connection replaces the prior one (newest wins, mirroring the SSE path); the
36
61
  * replaced socket's un-acked in-flight messages are re-buffered.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@securecoms/agent-bridge",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",