@creatornader/agent-bridge 0.2.0 → 0.3.1
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/CHANGELOG.md +86 -4
- package/README.md +567 -55
- package/ROADMAP.md +114 -0
- package/SECURITY.md +90 -0
- package/SKILL.md +68 -2
- package/bin/agent-bridge +2 -2
- package/clients/claude-desktop.json +3 -1
- package/dist/archive.d.ts +163 -0
- package/dist/archive.js +50 -0
- package/dist/archive.js.map +1 -0
- package/dist/bridge-domain-CBX3IVqC.d.ts +153 -0
- package/dist/{bridge-service-CfqMcMAn.d.ts → bridge-service-hX1ZQp4W.d.ts} +15 -5
- package/dist/bridge-store-DPVSCwfs.d.ts +102 -0
- package/dist/bridge.d.ts +76 -17
- package/dist/bridge.js +52 -24
- package/dist/chunk-2DFNOLMO.js +618 -0
- package/dist/chunk-2DFNOLMO.js.map +1 -0
- package/dist/{chunk-KVR4JBRF.js → chunk-2EVLG3YA.js} +2 -2
- package/dist/{chunk-KVR4JBRF.js.map → chunk-2EVLG3YA.js.map} +1 -1
- package/dist/chunk-45BZGB77.js +709 -0
- package/dist/chunk-45BZGB77.js.map +1 -0
- package/dist/chunk-4VB44KJU.js +230 -0
- package/dist/chunk-4VB44KJU.js.map +1 -0
- package/dist/chunk-5GMB3A77.js +1013 -0
- package/dist/chunk-5GMB3A77.js.map +1 -0
- package/dist/chunk-A6W4QALF.js +1258 -0
- package/dist/chunk-A6W4QALF.js.map +1 -0
- package/dist/chunk-BZLMF5O5.js +328 -0
- package/dist/chunk-BZLMF5O5.js.map +1 -0
- package/dist/{chunk-AXL2I7FH.js → chunk-CEXBMOI5.js} +240 -79
- package/dist/chunk-CEXBMOI5.js.map +1 -0
- package/dist/chunk-GADH244D.js +527 -0
- package/dist/chunk-GADH244D.js.map +1 -0
- package/dist/chunk-MBPZXTJA.js +2428 -0
- package/dist/chunk-MBPZXTJA.js.map +1 -0
- package/dist/chunk-NCO7RLBM.js +146 -0
- package/dist/chunk-NCO7RLBM.js.map +1 -0
- package/dist/chunk-Q6PPMXJC.js +1050 -0
- package/dist/chunk-Q6PPMXJC.js.map +1 -0
- package/dist/{chunk-4KAOBC5X.js → chunk-SPSMZOCJ.js} +190 -165
- package/dist/chunk-SPSMZOCJ.js.map +1 -0
- package/dist/chunk-UAHMP6GC.js +54 -0
- package/dist/chunk-UAHMP6GC.js.map +1 -0
- package/dist/{chunk-YD6YJATN.js → chunk-VOQIDTCJ.js} +4 -2
- package/dist/chunk-VOQIDTCJ.js.map +1 -0
- package/dist/chunk-WAI2IYIQ.js +554 -0
- package/dist/chunk-WAI2IYIQ.js.map +1 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +3555 -214
- package/dist/cli.js.map +1 -1
- package/dist/client-config.d.ts +1 -1
- package/dist/client-config.js +1 -1
- package/dist/client-runtime.d.ts +10 -6
- package/dist/client-runtime.js +9 -6
- package/dist/contracts/generate.d.ts +2 -0
- package/dist/contracts/generate.js +247 -0
- package/dist/contracts/generate.js.map +1 -0
- package/dist/dr.d.ts +324 -0
- package/dist/dr.js +124 -0
- package/dist/dr.js.map +1 -0
- package/dist/gateway-CggQ8vTC.d.ts +78 -0
- package/dist/gateway-main.js +190 -8
- package/dist/gateway-main.js.map +1 -1
- package/dist/gateway.d.ts +4 -3
- package/dist/gateway.js +4 -3
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/postgres-bridge-store-Bfd3hRId.d.ts +49 -0
- package/dist/server.d.ts +3 -2
- package/dist/server.js +13 -8
- package/dist/sqlite.d.ts +94 -12
- package/dist/sqlite.js +7 -4
- package/docs/architecture-v2.md +394 -0
- package/docs/decisions/0001-protocol-layers-and-acknowledgment-semantics.md +85 -0
- package/docs/decisions/0002-canonical-operation-contract-registry.md +46 -0
- package/docs/decisions/0003-host-adapters-and-consumer-instance-keys.md +88 -0
- package/docs/ecosystem.md +86 -0
- package/docs/postmortems/2026-07-08-wrapper-source-drift.md +82 -0
- package/docs/troubleshooting.md +89 -0
- package/llms.txt +107 -6
- package/openapi/agent-bridge-v2.openapi.json +9610 -0
- package/package.json +24 -4
- package/schemas/agent-bridge-v2.capabilities.json +1829 -0
- package/schemas/agent-bridge-v2.mcp.json +2074 -0
- package/schemas/agent-bridge-v2.schema.json +4560 -0
- package/sql/migrations/008_message_projects.sql +36 -0
- package/sql/migrations/009_mailbox_query_indexes.sql +28 -0
- package/sql/migrations/010_publisher_delivery_policy.sql +210 -0
- package/sql/migrations/011_credential_security.sql +875 -0
- package/sql/migrations/012_request_authority.sql +177 -0
- package/sql/migrations/013_row_isolation.sql +495 -0
- package/sql/migrations/014_owner_control_plane.sql +1641 -0
- package/sql/migrations/015_portable_archives.sql +1813 -0
- package/sql/migrations/016_native_dr_fence.sql +1005 -0
- package/bin/CLAUDE.md +0 -11
- package/dist/bridge-domain-BcnBeHOn.d.ts +0 -97
- package/dist/bridge-store-BuGjxTn4.d.ts +0 -61
- package/dist/chunk-4KAOBC5X.js.map +0 -1
- package/dist/chunk-6MAZ6YLZ.js +0 -146
- package/dist/chunk-6MAZ6YLZ.js.map +0 -1
- package/dist/chunk-AXL2I7FH.js.map +0 -1
- package/dist/chunk-BV6W4AJK.js +0 -211
- package/dist/chunk-BV6W4AJK.js.map +0 -1
- package/dist/chunk-CKSKUBDQ.js +0 -153
- package/dist/chunk-CKSKUBDQ.js.map +0 -1
- package/dist/chunk-JOUBDRYX.js +0 -272
- package/dist/chunk-JOUBDRYX.js.map +0 -1
- package/dist/chunk-JTC5YURG.js +0 -49
- package/dist/chunk-JTC5YURG.js.map +0 -1
- package/dist/chunk-O26W5QHS.js +0 -409
- package/dist/chunk-O26W5QHS.js.map +0 -1
- package/dist/chunk-WEULPMUY.js +0 -988
- package/dist/chunk-WEULPMUY.js.map +0 -1
- package/dist/chunk-YD6YJATN.js.map +0 -1
- package/dist/gateway-BULozv3K.d.ts +0 -54
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
2
|
+
[key: string]: JsonValue;
|
|
3
|
+
};
|
|
4
|
+
type DeliveryState = "pending" | "claimed" | "acked" | "retrying" | "dead" | "cancelled";
|
|
5
|
+
type MessagePriority = "info" | "high" | "urgent";
|
|
6
|
+
interface LeasedDeliveryPolicy {
|
|
7
|
+
mode: "leased";
|
|
8
|
+
maxAttempts: number;
|
|
9
|
+
retryBaseDelayMs: number;
|
|
10
|
+
retryMaxDelayMs: number;
|
|
11
|
+
retryJitterRatio: number;
|
|
12
|
+
notBefore?: string;
|
|
13
|
+
}
|
|
14
|
+
type DeliveryPolicy = {
|
|
15
|
+
mode: "mailbox";
|
|
16
|
+
} | LeasedDeliveryPolicy;
|
|
17
|
+
/** @deprecated Consumer retry policy is validated and ignored for one compatibility release. */
|
|
18
|
+
interface RetryPolicy {
|
|
19
|
+
maxAttempts: number;
|
|
20
|
+
baseDelayMs: number;
|
|
21
|
+
maxDelayMs: number;
|
|
22
|
+
jitterRatio: number;
|
|
23
|
+
}
|
|
24
|
+
type DeliveryAction = "created" | "claim" | "ack" | "nack_retry" | "nack_dead" | "lease_expired" | "attempts_exhausted" | "message_expired" | "cancel" | "requeue";
|
|
25
|
+
interface BridgePrincipal {
|
|
26
|
+
workspace: string;
|
|
27
|
+
agent: string;
|
|
28
|
+
instance?: string;
|
|
29
|
+
}
|
|
30
|
+
interface MessageDraft {
|
|
31
|
+
id?: string;
|
|
32
|
+
project?: string;
|
|
33
|
+
type: string;
|
|
34
|
+
content: string;
|
|
35
|
+
contentType?: string;
|
|
36
|
+
data?: JsonValue;
|
|
37
|
+
targets?: string[];
|
|
38
|
+
threadId?: string;
|
|
39
|
+
replyToId?: string;
|
|
40
|
+
correlationId?: string;
|
|
41
|
+
causationId?: string;
|
|
42
|
+
priority?: MessagePriority;
|
|
43
|
+
expiresAt?: string;
|
|
44
|
+
idempotencyKey?: string;
|
|
45
|
+
atribReceiptId?: string;
|
|
46
|
+
informedBy?: string[];
|
|
47
|
+
metadata?: JsonValue;
|
|
48
|
+
deliveryPolicy?: DeliveryPolicy | Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
interface BridgeMessage extends Required<Pick<MessageDraft, "id" | "type" | "content" | "contentType" | "targets" | "priority">> {
|
|
51
|
+
workspace: string;
|
|
52
|
+
project?: string;
|
|
53
|
+
source: string;
|
|
54
|
+
sequence: string;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
data?: JsonValue;
|
|
57
|
+
threadId?: string;
|
|
58
|
+
replyToId?: string;
|
|
59
|
+
correlationId?: string;
|
|
60
|
+
causationId?: string;
|
|
61
|
+
expiresAt?: string;
|
|
62
|
+
idempotencyKey?: string;
|
|
63
|
+
atribReceiptId?: string;
|
|
64
|
+
informedBy?: string[];
|
|
65
|
+
metadata?: JsonValue;
|
|
66
|
+
deliveryPolicy: DeliveryPolicy;
|
|
67
|
+
}
|
|
68
|
+
interface BridgeDelivery {
|
|
69
|
+
id: string;
|
|
70
|
+
messageId: string;
|
|
71
|
+
workspace: string;
|
|
72
|
+
recipient: string;
|
|
73
|
+
state: DeliveryState;
|
|
74
|
+
attempt: number;
|
|
75
|
+
cycleAttempt: number;
|
|
76
|
+
requeueCount: number;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
priorityRank: number;
|
|
79
|
+
availableAt: string;
|
|
80
|
+
leaseToken?: string;
|
|
81
|
+
leaseOwner?: string;
|
|
82
|
+
leaseExpiresAt?: string;
|
|
83
|
+
lastError?: string;
|
|
84
|
+
lastActor?: string;
|
|
85
|
+
lastAction: DeliveryAction;
|
|
86
|
+
}
|
|
87
|
+
interface BridgeDeliveryEvent {
|
|
88
|
+
sequence: string;
|
|
89
|
+
deliveryId: string;
|
|
90
|
+
messageId: string;
|
|
91
|
+
workspace: string;
|
|
92
|
+
recipient: string;
|
|
93
|
+
fromState?: DeliveryState;
|
|
94
|
+
toState: DeliveryState;
|
|
95
|
+
attempt: number;
|
|
96
|
+
cycleAttempt: number;
|
|
97
|
+
requeueCount: number;
|
|
98
|
+
leaseOwner?: string;
|
|
99
|
+
error?: string;
|
|
100
|
+
actor: string;
|
|
101
|
+
action: DeliveryAction;
|
|
102
|
+
createdAt: string;
|
|
103
|
+
}
|
|
104
|
+
interface AgentPresence {
|
|
105
|
+
workspace: string;
|
|
106
|
+
agent: string;
|
|
107
|
+
instance: string;
|
|
108
|
+
runtimeType?: string;
|
|
109
|
+
capabilities: string[];
|
|
110
|
+
leaseExpiresAt: string;
|
|
111
|
+
lastSeenAt: string;
|
|
112
|
+
}
|
|
113
|
+
declare class BridgeValidationError extends Error {
|
|
114
|
+
readonly code = "invalid_input";
|
|
115
|
+
}
|
|
116
|
+
declare class BridgePrincipalMismatchError extends Error {
|
|
117
|
+
readonly code = "principal_mismatch";
|
|
118
|
+
readonly status = 403;
|
|
119
|
+
}
|
|
120
|
+
declare class DeliveryStateConflictError extends Error {
|
|
121
|
+
readonly code = "delivery_state_conflict";
|
|
122
|
+
readonly status = 409;
|
|
123
|
+
}
|
|
124
|
+
declare function validateProject(value: unknown): string | undefined;
|
|
125
|
+
declare function uuidv7(now?: number): string;
|
|
126
|
+
declare function validatePrincipal(value: BridgePrincipal): BridgePrincipal;
|
|
127
|
+
declare function validateUuid(value: unknown, field: string): string;
|
|
128
|
+
declare function validateLeasedDeliveryPolicy(input?: Record<string, unknown>): LeasedDeliveryPolicy;
|
|
129
|
+
declare function validateDeliveryPolicy(input: Record<string, unknown> | null | undefined, targeted: boolean): DeliveryPolicy;
|
|
130
|
+
declare function validateMessageDraft(input: MessageDraft): Omit<BridgeMessage, "workspace" | "source" | "sequence" | "createdAt">;
|
|
131
|
+
interface CursorScopeQuery {
|
|
132
|
+
mailbox?: "inbox" | "sent" | "all";
|
|
133
|
+
receiptState?: "any" | "unread" | "read";
|
|
134
|
+
project?: string;
|
|
135
|
+
types?: string[];
|
|
136
|
+
includeExpired?: boolean;
|
|
137
|
+
source?: string;
|
|
138
|
+
since?: string;
|
|
139
|
+
threadId?: string;
|
|
140
|
+
}
|
|
141
|
+
declare function cursorScope(principal: BridgePrincipal, query: CursorScopeQuery): string;
|
|
142
|
+
declare function encodeCursor(sequence: string, scope?: string): string;
|
|
143
|
+
declare function decodeCursor(cursor: string | undefined, scope?: string): string | undefined;
|
|
144
|
+
declare function scopedCursorScope(kind: string, principal: BridgePrincipal, filters: JsonValue): string;
|
|
145
|
+
declare function encodeScopedCursor(scope: string, position: JsonValue): string;
|
|
146
|
+
declare function decodeScopedCursor(cursor: string | undefined, scope: string): JsonValue | undefined;
|
|
147
|
+
declare function validateDeliveryCursorPosition(position: JsonValue | undefined): {
|
|
148
|
+
createdAt: string;
|
|
149
|
+
id: string;
|
|
150
|
+
} | undefined;
|
|
151
|
+
declare function validateEventCursorPosition(position: JsonValue | undefined): string | undefined;
|
|
152
|
+
|
|
153
|
+
export { type AgentPresence as A, type BridgeDelivery as B, type DeliveryAction as D, type JsonValue as J, type LeasedDeliveryPolicy as L, type MessageDraft as M, type RetryPolicy as R, type BridgeDeliveryEvent as a, type BridgeMessage as b, type BridgePrincipal as c, BridgePrincipalMismatchError as d, BridgeValidationError as e, type DeliveryPolicy as f, type DeliveryState as g, DeliveryStateConflictError as h, type MessagePriority as i, cursorScope as j, decodeCursor as k, decodeScopedCursor as l, encodeCursor as m, encodeScopedCursor as n, validateDeliveryPolicy as o, validateEventCursorPosition as p, validateLeasedDeliveryPolicy as q, validateMessageDraft as r, scopedCursorScope as s, validatePrincipal as t, uuidv7 as u, validateDeliveryCursorPosition as v, validateProject as w, validateUuid as x };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as BridgeStore, I as InsertMessageResult, d as MessageQuery, M as MessagePage, c as DeliveryQuery, b as DeliveryPage, D as DeliveryEventPage } from './bridge-store-DPVSCwfs.js';
|
|
2
|
+
import { c as BridgePrincipal, M as MessageDraft, B as BridgeDelivery, A as AgentPresence } from './bridge-domain-CBX3IVqC.js';
|
|
3
3
|
|
|
4
|
+
type PublicMessageQuery = MessageQuery & {
|
|
5
|
+
unacknowledgedBy?: string;
|
|
6
|
+
};
|
|
4
7
|
declare class BridgeService {
|
|
5
8
|
private readonly store;
|
|
6
9
|
constructor(store: BridgeStore);
|
|
7
10
|
publish(principalInput: BridgePrincipal, draftInput: MessageDraft): Promise<InsertMessageResult>;
|
|
8
|
-
history(principalInput: BridgePrincipal, query?:
|
|
11
|
+
history(principalInput: BridgePrincipal, query?: PublicMessageQuery): Promise<MessagePage>;
|
|
9
12
|
acknowledge(principalInput: BridgePrincipal, messageIds: string[]): Promise<number>;
|
|
10
13
|
claim(principalInput: BridgePrincipal, options?: {
|
|
11
14
|
leaseMs?: number;
|
|
@@ -16,7 +19,14 @@ declare class BridgeService {
|
|
|
16
19
|
} | null>;
|
|
17
20
|
extend(principalInput: BridgePrincipal, deliveryId: string, leaseToken: string, leaseMs?: number): Promise<BridgeDelivery | null>;
|
|
18
21
|
ack(principalInput: BridgePrincipal, deliveryId: string, leaseToken: string): Promise<BridgeDelivery | null>;
|
|
19
|
-
nack(principalInput: BridgePrincipal, deliveryId: string, leaseToken: string, error: string,
|
|
22
|
+
nack(principalInput: BridgePrincipal, deliveryId: string, leaseToken: string, error: string, disposition?: "retry" | "dead" | boolean, deprecatedRetryPolicy?: unknown): Promise<BridgeDelivery | null>;
|
|
23
|
+
deliveries(principalInput: BridgePrincipal, query?: DeliveryQuery): Promise<DeliveryPage>;
|
|
24
|
+
deliveryEvents(principalInput: BridgePrincipal, deliveryId: string, query?: {
|
|
25
|
+
cursor?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
}): Promise<DeliveryEventPage>;
|
|
28
|
+
cancel(principalInput: BridgePrincipal, deliveryId: string): Promise<BridgeDelivery | null>;
|
|
29
|
+
requeue(principalInput: BridgePrincipal, deliveryId: string): Promise<BridgeDelivery | null>;
|
|
20
30
|
heartbeat(principalInput: BridgePrincipal, options?: {
|
|
21
31
|
leaseMs?: number;
|
|
22
32
|
runtimeType?: string;
|
|
@@ -25,4 +35,4 @@ declare class BridgeService {
|
|
|
25
35
|
presence(principalInput: BridgePrincipal): Promise<AgentPresence[]>;
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
export { BridgeService as B };
|
|
38
|
+
export { BridgeService as B, type PublicMessageQuery as P };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { b as BridgeMessage, c as BridgePrincipal, B as BridgeDelivery, g as DeliveryState, R as RetryPolicy, a as BridgeDeliveryEvent, A as AgentPresence } from './bridge-domain-CBX3IVqC.js';
|
|
2
|
+
|
|
3
|
+
interface InsertMessageResult {
|
|
4
|
+
message: BridgeMessage;
|
|
5
|
+
created: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface MessageQuery {
|
|
8
|
+
mailbox?: "inbox" | "sent" | "all";
|
|
9
|
+
receiptState?: "any" | "unread" | "read";
|
|
10
|
+
project?: string;
|
|
11
|
+
cursor?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
types?: string[];
|
|
14
|
+
includeExpired?: boolean;
|
|
15
|
+
source?: string;
|
|
16
|
+
since?: string;
|
|
17
|
+
threadId?: string;
|
|
18
|
+
latest?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface MessagePage {
|
|
21
|
+
messages: BridgeMessage[];
|
|
22
|
+
cursor?: string;
|
|
23
|
+
}
|
|
24
|
+
interface BridgeDiagnostics {
|
|
25
|
+
schemaVersion: "local-v2" | "postgres-v2" | "legacy-v1";
|
|
26
|
+
deliverySupported: boolean;
|
|
27
|
+
pending: number | null;
|
|
28
|
+
claimed: number | null;
|
|
29
|
+
retrying: number | null;
|
|
30
|
+
dead: number | null;
|
|
31
|
+
cancelled?: number | null;
|
|
32
|
+
oldestAvailableAt?: string;
|
|
33
|
+
due?: number | null;
|
|
34
|
+
scheduled?: number | null;
|
|
35
|
+
expiredLeases?: number | null;
|
|
36
|
+
oldestDueAt?: string;
|
|
37
|
+
queueLagMs?: number | null;
|
|
38
|
+
principal?: {
|
|
39
|
+
workspace: string;
|
|
40
|
+
agent: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
interface ClaimOptions {
|
|
44
|
+
leaseMs: number;
|
|
45
|
+
now?: Date;
|
|
46
|
+
maxAttempts?: number;
|
|
47
|
+
}
|
|
48
|
+
interface DeliveryQuery {
|
|
49
|
+
role?: "recipient" | "publisher" | "all";
|
|
50
|
+
states?: DeliveryState[];
|
|
51
|
+
messageId?: string;
|
|
52
|
+
recipient?: string;
|
|
53
|
+
cursor?: string;
|
|
54
|
+
limit?: number;
|
|
55
|
+
}
|
|
56
|
+
interface DeliveryPage {
|
|
57
|
+
deliveries: BridgeDelivery[];
|
|
58
|
+
cursor?: string;
|
|
59
|
+
}
|
|
60
|
+
interface DeliveryEventPage {
|
|
61
|
+
events: BridgeDeliveryEvent[];
|
|
62
|
+
cursor?: string;
|
|
63
|
+
}
|
|
64
|
+
interface BridgeStore {
|
|
65
|
+
initialize(options?: {
|
|
66
|
+
signal?: AbortSignal;
|
|
67
|
+
mode?: "active" | "passive";
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
insertMessage(message: Omit<BridgeMessage, "sequence" | "createdAt">, options?: {
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
}): Promise<InsertMessageResult>;
|
|
72
|
+
listMessages(principal: BridgePrincipal, query?: MessageQuery, options?: {
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
}): Promise<MessagePage>;
|
|
75
|
+
recordReceipt(principal: BridgePrincipal, messageIds: string[], readAt?: Date): Promise<number>;
|
|
76
|
+
recordLegacyReceipt?(legacyIds: string[], principal: string): Promise<number>;
|
|
77
|
+
claimDelivery(principal: BridgePrincipal, options: ClaimOptions): Promise<BridgeDelivery | null>;
|
|
78
|
+
renewDelivery(principal: BridgePrincipal, deliveryId: string, leaseToken: string, leaseMs: number): Promise<BridgeDelivery | null>;
|
|
79
|
+
settleDelivery(principal: BridgePrincipal, deliveryId: string, leaseToken: string, state: Extract<DeliveryState, "acked" | "retrying" | "dead">, error?: string, retryPolicy?: RetryPolicy): Promise<BridgeDelivery | null>;
|
|
80
|
+
listDeliveries?(principal: BridgePrincipal, query?: DeliveryQuery): Promise<DeliveryPage>;
|
|
81
|
+
listDeliveryEvents?(principal: BridgePrincipal, deliveryId: string, query?: {
|
|
82
|
+
cursor?: string;
|
|
83
|
+
limit?: number;
|
|
84
|
+
}): Promise<DeliveryEventPage>;
|
|
85
|
+
cancelDelivery?(principal: BridgePrincipal, deliveryId: string): Promise<BridgeDelivery | null>;
|
|
86
|
+
requeueDelivery?(principal: BridgePrincipal, deliveryId: string): Promise<BridgeDelivery | null>;
|
|
87
|
+
diagnostics?(principal: BridgePrincipal, options?: {
|
|
88
|
+
mode?: "snapshot" | "probe";
|
|
89
|
+
}): Promise<BridgeDiagnostics>;
|
|
90
|
+
heartbeat?(principal: BridgePrincipal, leaseMs: number, runtimeType?: string, capabilities?: string[]): Promise<AgentPresence>;
|
|
91
|
+
listPresence?(principal: BridgePrincipal): Promise<AgentPresence[]>;
|
|
92
|
+
sync?(options?: {
|
|
93
|
+
maxPush?: number;
|
|
94
|
+
maxPages?: number;
|
|
95
|
+
signal?: AbortSignal;
|
|
96
|
+
}): Promise<unknown>;
|
|
97
|
+
verifyRemote?(): Promise<void>;
|
|
98
|
+
capabilities?(): Promise<unknown>;
|
|
99
|
+
close?(): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type { BridgeDiagnostics as B, ClaimOptions as C, DeliveryEventPage as D, InsertMessageResult as I, MessagePage as M, BridgeStore as a, DeliveryPage as b, DeliveryQuery as c, MessageQuery as d };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { b as BridgeMessage, c as BridgePrincipal, B as BridgeDelivery, R as RetryPolicy, A as AgentPresence } from './bridge-domain-
|
|
2
|
-
export { a as BridgeDeliveryEvent, d as BridgeValidationError, D as DeliveryState, J as JsonValue, M as MessageDraft,
|
|
3
|
-
import { a as BridgeStore, I as InsertMessageResult,
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { b as BridgeMessage, c as BridgePrincipal, B as BridgeDelivery, R as RetryPolicy, A as AgentPresence } from './bridge-domain-CBX3IVqC.js';
|
|
2
|
+
export { a as BridgeDeliveryEvent, d as BridgePrincipalMismatchError, e as BridgeValidationError, D as DeliveryAction, f as DeliveryPolicy, g as DeliveryState, h as DeliveryStateConflictError, J as JsonValue, L as LeasedDeliveryPolicy, M as MessageDraft, i as MessagePriority, j as cursorScope, k as decodeCursor, l as decodeScopedCursor, m as encodeCursor, n as encodeScopedCursor, s as scopedCursorScope, u as uuidv7, v as validateDeliveryCursorPosition, o as validateDeliveryPolicy, p as validateEventCursorPosition, q as validateLeasedDeliveryPolicy, r as validateMessageDraft, t as validatePrincipal, w as validateProject, x as validateUuid } from './bridge-domain-CBX3IVqC.js';
|
|
3
|
+
import { a as BridgeStore, I as InsertMessageResult, d as MessageQuery, M as MessagePage, C as ClaimOptions, B as BridgeDiagnostics, c as DeliveryQuery } from './bridge-store-DPVSCwfs.js';
|
|
4
|
+
export { D as DeliveryEventPage, b as DeliveryPage } from './bridge-store-DPVSCwfs.js';
|
|
5
|
+
export { B as BridgeService, P as PublicMessageQuery } from './bridge-service-hX1ZQp4W.js';
|
|
6
|
+
import { P as PgQueryable } from './postgres-bridge-store-Bfd3hRId.js';
|
|
7
|
+
export { a as PgTransactionClient, b as PostgresBridgeStore } from './postgres-bridge-store-Bfd3hRId.js';
|
|
8
|
+
export { A as AuthenticatedCredential, C as CredentialResolver, G as GatewayOptions, P as PostgresCredentialResolver, b as bearerToken, c as createGateway, h as hashCredential, s as safeTokenHashEqual } from './gateway-CggQ8vTC.js';
|
|
7
9
|
export { CachedMessagePage, EdgeConflictError, EdgeEnqueueResult, EdgeOutboxRecord, EdgeScope, EdgeStats, PendingMessage, SQLiteBridgeStore, SQLiteEdgeStore, SyncDiagnostics, SyncInsertResult, SyncReport, SyncingBridgeStore, SyncingBridgeStoreOptions, edgeMessageFingerprint, edgeScopeKey, isRetryableSyncError, stableIdempotency } from './sqlite.js';
|
|
8
10
|
import 'node:http';
|
|
9
11
|
|
|
@@ -20,15 +22,18 @@ declare class LegacySupabaseRestStore implements BridgeStore {
|
|
|
20
22
|
private readonly legacyIds;
|
|
21
23
|
private initialized;
|
|
22
24
|
constructor(url: string, key: string, fetchImpl?: typeof fetch, timeoutMs?: number);
|
|
23
|
-
initialize(
|
|
25
|
+
initialize(options?: {
|
|
26
|
+
mode?: "active" | "passive";
|
|
27
|
+
}): Promise<void>;
|
|
24
28
|
private request;
|
|
29
|
+
private visibleReceiptIds;
|
|
25
30
|
insertMessage(input: Omit<BridgeMessage, "sequence" | "createdAt">): Promise<InsertMessageResult>;
|
|
26
31
|
listMessages(principal: BridgePrincipal, query?: MessageQuery): Promise<MessagePage>;
|
|
27
|
-
recordReceipt(
|
|
32
|
+
recordReceipt(principal: BridgePrincipal, ids: string[]): Promise<number>;
|
|
28
33
|
recordLegacyReceipt(ids: string[], principal: string): Promise<number>;
|
|
29
34
|
claimDelivery(_principal: BridgePrincipal, _options: ClaimOptions): Promise<BridgeDelivery | null>;
|
|
30
35
|
renewDelivery(_principal: BridgePrincipal, _deliveryId: string, _leaseToken: string, _leaseMs: number): Promise<BridgeDelivery | null>;
|
|
31
|
-
settleDelivery(_principal: BridgePrincipal, _deliveryId: string, _leaseToken: string, _state: "acked" | "retrying" | "dead", _error
|
|
36
|
+
settleDelivery(_principal: BridgePrincipal, _deliveryId: string, _leaseToken: string, _state: "acked" | "retrying" | "dead", _error?: string, _retryPolicy?: RetryPolicy): Promise<BridgeDelivery | null>;
|
|
32
37
|
diagnostics(_principal: BridgePrincipal): Promise<BridgeDiagnostics>;
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -43,27 +48,51 @@ interface HttpBridgeStoreOptions {
|
|
|
43
48
|
declare class BridgeHttpError extends Error {
|
|
44
49
|
readonly status: number;
|
|
45
50
|
readonly code: string;
|
|
46
|
-
|
|
51
|
+
readonly requestId?: string | undefined;
|
|
52
|
+
readonly details?: unknown | undefined;
|
|
53
|
+
constructor(status: number, code: string, requestId?: string | undefined, details?: unknown | undefined, message?: string);
|
|
47
54
|
}
|
|
48
55
|
declare class HttpBridgeStore implements BridgeStore {
|
|
49
56
|
private readonly options;
|
|
50
57
|
private readonly fetchImpl;
|
|
58
|
+
private readonly closeController;
|
|
59
|
+
private closed;
|
|
60
|
+
private selectedProtocolVersion?;
|
|
61
|
+
private protocolProbe?;
|
|
51
62
|
constructor(options: HttpBridgeStoreOptions);
|
|
52
|
-
initialize(
|
|
63
|
+
initialize(options?: {
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
mode?: "active" | "passive";
|
|
66
|
+
}): Promise<void>;
|
|
53
67
|
private assertBoundPrincipal;
|
|
54
68
|
private request;
|
|
69
|
+
private ensureProtocol;
|
|
70
|
+
capabilities(): Promise<unknown>;
|
|
55
71
|
private assertPrincipal;
|
|
56
|
-
insertMessage(message: Omit<BridgeMessage, "sequence" | "createdAt"
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
insertMessage(message: Omit<BridgeMessage, "sequence" | "createdAt">, options?: {
|
|
73
|
+
signal?: AbortSignal;
|
|
74
|
+
}): Promise<InsertMessageResult>;
|
|
75
|
+
listMessages(principal: BridgePrincipal, query?: MessageQuery, options?: {
|
|
76
|
+
signal?: AbortSignal;
|
|
77
|
+
}): Promise<MessagePage>;
|
|
78
|
+
recordReceipt(principal: BridgePrincipal, ids: string[]): Promise<number>;
|
|
59
79
|
diagnostics(principal: BridgePrincipal): Promise<BridgeDiagnostics>;
|
|
60
80
|
claimDelivery(principal: BridgePrincipal, options: ClaimOptions): Promise<BridgeDelivery | null>;
|
|
81
|
+
listDeliveries(principal: BridgePrincipal, query?: DeliveryQuery): Promise<any>;
|
|
82
|
+
listDeliveryEvents(principal: BridgePrincipal, id: string, query?: {
|
|
83
|
+
cursor?: string;
|
|
84
|
+
limit?: number;
|
|
85
|
+
}): Promise<any>;
|
|
86
|
+
cancelDelivery(principal: BridgePrincipal, id: string): Promise<any>;
|
|
87
|
+
requeueDelivery(principal: BridgePrincipal, id: string): Promise<any>;
|
|
61
88
|
renewDelivery(principal: BridgePrincipal, id: string, token: string, leaseMs: number): Promise<BridgeDelivery | null>;
|
|
62
|
-
settleDelivery(principal: BridgePrincipal, id: string, token: string, state: "acked" | "retrying" | "dead", error
|
|
89
|
+
settleDelivery(principal: BridgePrincipal, id: string, token: string, state: "acked" | "retrying" | "dead", error?: string, _retryPolicy?: RetryPolicy): Promise<BridgeDelivery | null>;
|
|
63
90
|
heartbeat(principal: BridgePrincipal, leaseMs: number, runtimeType?: string, capabilities?: string[]): Promise<AgentPresence>;
|
|
64
91
|
listPresence(principal: BridgePrincipal): Promise<AgentPresence[]>;
|
|
92
|
+
close(): Promise<void>;
|
|
65
93
|
}
|
|
66
94
|
|
|
95
|
+
declare const NATIVE_DR_ADVISORY_LOCK_KEY = 1646705664;
|
|
67
96
|
interface AppliedMigration {
|
|
68
97
|
version: number;
|
|
69
98
|
name: string;
|
|
@@ -93,10 +122,40 @@ declare const REQUIRED_MIGRATIONS: readonly [{
|
|
|
93
122
|
}, {
|
|
94
123
|
readonly version: 7;
|
|
95
124
|
readonly name: "runtime_role";
|
|
125
|
+
}, {
|
|
126
|
+
readonly version: 8;
|
|
127
|
+
readonly name: "message_projects";
|
|
128
|
+
}, {
|
|
129
|
+
readonly version: 9;
|
|
130
|
+
readonly name: "mailbox_query_indexes";
|
|
131
|
+
}, {
|
|
132
|
+
readonly version: 10;
|
|
133
|
+
readonly name: "publisher_delivery_policy";
|
|
134
|
+
}, {
|
|
135
|
+
readonly version: 11;
|
|
136
|
+
readonly name: "credential_security";
|
|
137
|
+
}, {
|
|
138
|
+
readonly version: 12;
|
|
139
|
+
readonly name: "request_authority";
|
|
140
|
+
}, {
|
|
141
|
+
readonly version: 13;
|
|
142
|
+
readonly name: "row_isolation";
|
|
143
|
+
}, {
|
|
144
|
+
readonly version: 14;
|
|
145
|
+
readonly name: "owner_control_plane";
|
|
146
|
+
}, {
|
|
147
|
+
readonly version: 15;
|
|
148
|
+
readonly name: "portable_archives";
|
|
149
|
+
}, {
|
|
150
|
+
readonly version: 16;
|
|
151
|
+
readonly name: "native_dr_fence";
|
|
96
152
|
}];
|
|
97
153
|
declare function loadMigrationPlan(directory: string): Promise<MigrationPlanEntry[]>;
|
|
98
154
|
declare function migrationsReady(db: PgQueryable, expected: ReadonlyArray<Pick<MigrationPlanEntry, "version" | "name" | "checksum">>): Promise<boolean>;
|
|
99
|
-
declare function
|
|
155
|
+
declare function rowIsolationReady(db: PgQueryable, allowPrivilegedCaller: boolean): Promise<boolean>;
|
|
156
|
+
declare function runtimeSchemaReady(db: PgQueryable, options?: {
|
|
157
|
+
allowPrivilegedCaller?: boolean;
|
|
158
|
+
}): Promise<boolean>;
|
|
100
159
|
declare function runMigrations(db: PgQueryable, directory: string): Promise<AppliedMigration[]>;
|
|
101
160
|
|
|
102
|
-
export { AgentPresence, type AppliedMigration, BridgeDelivery, BridgeDiagnostics, BridgeHttpError, BridgeMessage, BridgePrincipal, BridgeStore, ClaimOptions, HttpBridgeStore, type HttpBridgeStoreOptions, InsertMessageResult, LegacySupabaseError, LegacySupabaseRestStore, MessagePage, MessageQuery, type MigrationPlanEntry, PgQueryable, REQUIRED_MIGRATIONS, RetryPolicy, loadMigrationPlan, migrationsReady, runMigrations, runtimeSchemaReady };
|
|
161
|
+
export { AgentPresence, type AppliedMigration, BridgeDelivery, BridgeDiagnostics, BridgeHttpError, BridgeMessage, BridgePrincipal, BridgeStore, ClaimOptions, DeliveryQuery, HttpBridgeStore, type HttpBridgeStoreOptions, InsertMessageResult, LegacySupabaseError, LegacySupabaseRestStore, MessagePage, MessageQuery, type MigrationPlanEntry, NATIVE_DR_ADVISORY_LOCK_KEY, PgQueryable, REQUIRED_MIGRATIONS, RetryPolicy, loadMigrationPlan, migrationsReady, rowIsolationReady, runMigrations, runtimeSchemaReady };
|
package/dist/bridge.js
CHANGED
|
@@ -1,59 +1,78 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
BridgeHttpError,
|
|
4
|
+
HttpBridgeStore,
|
|
5
|
+
LegacySupabaseError,
|
|
6
|
+
LegacySupabaseRestStore
|
|
7
|
+
} from "./chunk-CEXBMOI5.js";
|
|
8
|
+
import {
|
|
9
|
+
EdgeConflictError,
|
|
10
|
+
SQLiteEdgeStore,
|
|
11
|
+
SyncingBridgeStore,
|
|
12
|
+
edgeMessageFingerprint,
|
|
13
|
+
edgeScopeKey,
|
|
14
|
+
isRetryableSyncError,
|
|
15
|
+
stableIdempotency
|
|
16
|
+
} from "./chunk-Q6PPMXJC.js";
|
|
17
|
+
import {
|
|
18
|
+
SQLiteBridgeStore
|
|
19
|
+
} from "./chunk-5GMB3A77.js";
|
|
20
|
+
import "./chunk-NCO7RLBM.js";
|
|
2
21
|
import {
|
|
3
22
|
PostgresBridgeStore
|
|
4
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-2DFNOLMO.js";
|
|
5
24
|
import {
|
|
25
|
+
NATIVE_DR_ADVISORY_LOCK_KEY,
|
|
6
26
|
REQUIRED_MIGRATIONS,
|
|
7
27
|
loadMigrationPlan,
|
|
8
28
|
migrationsReady,
|
|
29
|
+
rowIsolationReady,
|
|
9
30
|
runMigrations,
|
|
10
31
|
runtimeSchemaReady
|
|
11
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-45BZGB77.js";
|
|
33
|
+
import "./chunk-VOQIDTCJ.js";
|
|
12
34
|
import {
|
|
13
35
|
PostgresCredentialResolver,
|
|
14
36
|
bearerToken,
|
|
15
37
|
createGateway,
|
|
16
38
|
hashCredential,
|
|
17
39
|
safeTokenHashEqual
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
BridgeHttpError,
|
|
21
|
-
HttpBridgeStore,
|
|
22
|
-
LegacySupabaseError,
|
|
23
|
-
LegacySupabaseRestStore
|
|
24
|
-
} from "./chunk-AXL2I7FH.js";
|
|
25
|
-
import {
|
|
26
|
-
EdgeConflictError,
|
|
27
|
-
SQLiteBridgeStore,
|
|
28
|
-
SQLiteEdgeStore,
|
|
29
|
-
SyncingBridgeStore,
|
|
30
|
-
edgeMessageFingerprint,
|
|
31
|
-
edgeScopeKey,
|
|
32
|
-
isRetryableSyncError,
|
|
33
|
-
stableIdempotency
|
|
34
|
-
} from "./chunk-WEULPMUY.js";
|
|
35
|
-
import "./chunk-YD6YJATN.js";
|
|
40
|
+
} from "./chunk-WAI2IYIQ.js";
|
|
36
41
|
import {
|
|
37
42
|
BridgeService
|
|
38
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-4VB44KJU.js";
|
|
44
|
+
import "./chunk-GADH244D.js";
|
|
39
45
|
import {
|
|
46
|
+
BridgePrincipalMismatchError,
|
|
40
47
|
BridgeValidationError,
|
|
48
|
+
DeliveryStateConflictError,
|
|
49
|
+
cursorScope,
|
|
41
50
|
decodeCursor,
|
|
51
|
+
decodeScopedCursor,
|
|
42
52
|
encodeCursor,
|
|
53
|
+
encodeScopedCursor,
|
|
54
|
+
scopedCursorScope,
|
|
43
55
|
uuidv7,
|
|
56
|
+
validateDeliveryCursorPosition,
|
|
57
|
+
validateDeliveryPolicy,
|
|
58
|
+
validateEventCursorPosition,
|
|
59
|
+
validateLeasedDeliveryPolicy,
|
|
44
60
|
validateMessageDraft,
|
|
45
61
|
validatePrincipal,
|
|
46
|
-
|
|
62
|
+
validateProject,
|
|
47
63
|
validateUuid
|
|
48
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-BZLMF5O5.js";
|
|
49
65
|
export {
|
|
50
66
|
BridgeHttpError,
|
|
67
|
+
BridgePrincipalMismatchError,
|
|
51
68
|
BridgeService,
|
|
52
69
|
BridgeValidationError,
|
|
70
|
+
DeliveryStateConflictError,
|
|
53
71
|
EdgeConflictError,
|
|
54
72
|
HttpBridgeStore,
|
|
55
73
|
LegacySupabaseError,
|
|
56
74
|
LegacySupabaseRestStore,
|
|
75
|
+
NATIVE_DR_ADVISORY_LOCK_KEY,
|
|
57
76
|
PostgresBridgeStore,
|
|
58
77
|
PostgresCredentialResolver,
|
|
59
78
|
REQUIRED_MIGRATIONS,
|
|
@@ -62,22 +81,31 @@ export {
|
|
|
62
81
|
SyncingBridgeStore,
|
|
63
82
|
bearerToken,
|
|
64
83
|
createGateway,
|
|
84
|
+
cursorScope,
|
|
65
85
|
decodeCursor,
|
|
86
|
+
decodeScopedCursor,
|
|
66
87
|
edgeMessageFingerprint,
|
|
67
88
|
edgeScopeKey,
|
|
68
89
|
encodeCursor,
|
|
90
|
+
encodeScopedCursor,
|
|
69
91
|
hashCredential,
|
|
70
92
|
isRetryableSyncError,
|
|
71
93
|
loadMigrationPlan,
|
|
72
94
|
migrationsReady,
|
|
95
|
+
rowIsolationReady,
|
|
73
96
|
runMigrations,
|
|
74
97
|
runtimeSchemaReady,
|
|
75
98
|
safeTokenHashEqual,
|
|
99
|
+
scopedCursorScope,
|
|
76
100
|
stableIdempotency,
|
|
77
101
|
uuidv7,
|
|
102
|
+
validateDeliveryCursorPosition,
|
|
103
|
+
validateDeliveryPolicy,
|
|
104
|
+
validateEventCursorPosition,
|
|
105
|
+
validateLeasedDeliveryPolicy,
|
|
78
106
|
validateMessageDraft,
|
|
79
107
|
validatePrincipal,
|
|
80
|
-
|
|
108
|
+
validateProject,
|
|
81
109
|
validateUuid
|
|
82
110
|
};
|
|
83
111
|
//# sourceMappingURL=bridge.js.map
|