@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,527 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/contracts/registry.ts
|
|
4
|
+
import Type from "@sinclair/typebox";
|
|
5
|
+
import { Check, Errors } from "@sinclair/typebox/value";
|
|
6
|
+
var PROTOCOL_VERSION = "2.1";
|
|
7
|
+
var LEGACY_PROTOCOL_VERSION = "2.0";
|
|
8
|
+
var SUPPORTED_PROTOCOL_VERSIONS = [LEGACY_PROTOCOL_VERSION, PROTOCOL_VERSION];
|
|
9
|
+
var SUPPORTED_PROTOCOL_RANGE = SUPPORTED_PROTOCOL_VERSIONS.join(",");
|
|
10
|
+
var PROTOCOL_HEADER = "x-agent-bridge-protocol-version";
|
|
11
|
+
var SUPPORTED_PROTOCOL_HEADER = "x-agent-bridge-supported-protocol-versions";
|
|
12
|
+
var SCOPE_ENFORCEMENT = true;
|
|
13
|
+
var StringArray = Type.Array(Type.String());
|
|
14
|
+
var Empty = Type.Object({}, { additionalProperties: false });
|
|
15
|
+
var OptionalString = () => Type.Optional(Type.String());
|
|
16
|
+
var OptionalNumber = (options = {}) => Type.Optional(Type.Number(options));
|
|
17
|
+
var OptionalBoolean = () => Type.Optional(Type.Boolean());
|
|
18
|
+
var NullableString = () => Type.Union([Type.String(), Type.Null()]);
|
|
19
|
+
var NullableNumber = () => Type.Union([Type.Number(), Type.Null()]);
|
|
20
|
+
var UUID_V7_PATTERN = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-7[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$";
|
|
21
|
+
var ErrorIssueSchema = Type.Object({
|
|
22
|
+
path: Type.String(),
|
|
23
|
+
message: Type.String()
|
|
24
|
+
}, { additionalProperties: true });
|
|
25
|
+
var ErrorEnvelopeSchema = Type.Object({
|
|
26
|
+
error: Type.Object({
|
|
27
|
+
code: Type.String(),
|
|
28
|
+
requestId: Type.String(),
|
|
29
|
+
message: OptionalString(),
|
|
30
|
+
operation: OptionalString(),
|
|
31
|
+
issues: Type.Optional(Type.Array(ErrorIssueSchema)),
|
|
32
|
+
details: Type.Optional(Type.Any()),
|
|
33
|
+
supportedProtocolVersions: Type.Optional(StringArray)
|
|
34
|
+
}, { additionalProperties: true })
|
|
35
|
+
}, { additionalProperties: true });
|
|
36
|
+
var DeliveryPolicySchema = Type.Union([
|
|
37
|
+
Type.Object({ mode: Type.Literal("mailbox") }, { additionalProperties: false }),
|
|
38
|
+
Type.Object({
|
|
39
|
+
mode: Type.Literal("leased"),
|
|
40
|
+
maxAttempts: Type.Number(),
|
|
41
|
+
retryBaseDelayMs: Type.Number(),
|
|
42
|
+
retryMaxDelayMs: Type.Number(),
|
|
43
|
+
retryJitterRatio: Type.Number(),
|
|
44
|
+
notBefore: OptionalString()
|
|
45
|
+
}, { additionalProperties: false })
|
|
46
|
+
]);
|
|
47
|
+
var DeliveryPolicyInputSchema = Type.Object({
|
|
48
|
+
mode: Type.Optional(Type.Enum(["mailbox", "leased"])),
|
|
49
|
+
maxAttempts: OptionalNumber(),
|
|
50
|
+
retryBaseDelayMs: OptionalNumber(),
|
|
51
|
+
retryMaxDelayMs: OptionalNumber(),
|
|
52
|
+
retryJitterRatio: OptionalNumber(),
|
|
53
|
+
notBefore: OptionalString()
|
|
54
|
+
}, { additionalProperties: false });
|
|
55
|
+
var MessageDraftSchema = Type.Object({
|
|
56
|
+
id: Type.Optional(Type.String({ pattern: UUID_V7_PATTERN })),
|
|
57
|
+
source: OptionalString(),
|
|
58
|
+
project: OptionalString(),
|
|
59
|
+
type: Type.String(),
|
|
60
|
+
content: Type.String(),
|
|
61
|
+
contentType: OptionalString(),
|
|
62
|
+
data: Type.Optional(Type.Any()),
|
|
63
|
+
targets: Type.Optional(StringArray),
|
|
64
|
+
threadId: OptionalString(),
|
|
65
|
+
replyToId: OptionalString(),
|
|
66
|
+
correlationId: OptionalString(),
|
|
67
|
+
causationId: OptionalString(),
|
|
68
|
+
priority: Type.Optional(Type.Enum(["info", "high", "urgent"])),
|
|
69
|
+
expiresAt: OptionalString(),
|
|
70
|
+
idempotencyKey: OptionalString(),
|
|
71
|
+
atribReceiptId: OptionalString(),
|
|
72
|
+
informedBy: Type.Optional(StringArray),
|
|
73
|
+
metadata: Type.Optional(Type.Any()),
|
|
74
|
+
deliveryPolicy: Type.Optional(DeliveryPolicyInputSchema)
|
|
75
|
+
}, { additionalProperties: false });
|
|
76
|
+
var LegacyMessageDraftSchema = Type.Object({
|
|
77
|
+
id: OptionalString(),
|
|
78
|
+
source: OptionalString(),
|
|
79
|
+
type: Type.String(),
|
|
80
|
+
content: Type.String(),
|
|
81
|
+
contentType: OptionalString(),
|
|
82
|
+
data: Type.Optional(Type.Any()),
|
|
83
|
+
targets: Type.Optional(StringArray),
|
|
84
|
+
threadId: OptionalString(),
|
|
85
|
+
replyToId: OptionalString(),
|
|
86
|
+
correlationId: OptionalString(),
|
|
87
|
+
causationId: OptionalString(),
|
|
88
|
+
priority: Type.Optional(Type.Enum(["info", "high", "urgent"])),
|
|
89
|
+
expiresAt: OptionalString(),
|
|
90
|
+
idempotencyKey: OptionalString(),
|
|
91
|
+
atribReceiptId: OptionalString(),
|
|
92
|
+
informedBy: Type.Optional(StringArray),
|
|
93
|
+
metadata: Type.Optional(Type.Any())
|
|
94
|
+
}, { additionalProperties: false });
|
|
95
|
+
var MessageSchema = Type.Object({
|
|
96
|
+
id: Type.String(),
|
|
97
|
+
workspace: Type.String(),
|
|
98
|
+
project: OptionalString(),
|
|
99
|
+
source: Type.String(),
|
|
100
|
+
type: Type.String(),
|
|
101
|
+
content: Type.String(),
|
|
102
|
+
contentType: Type.String(),
|
|
103
|
+
sequence: Type.String(),
|
|
104
|
+
createdAt: Type.String(),
|
|
105
|
+
data: Type.Optional(Type.Any()),
|
|
106
|
+
targets: StringArray,
|
|
107
|
+
threadId: OptionalString(),
|
|
108
|
+
replyToId: OptionalString(),
|
|
109
|
+
correlationId: OptionalString(),
|
|
110
|
+
causationId: OptionalString(),
|
|
111
|
+
priority: Type.Enum(["info", "high", "urgent"]),
|
|
112
|
+
expiresAt: OptionalString(),
|
|
113
|
+
idempotencyKey: OptionalString(),
|
|
114
|
+
atribReceiptId: OptionalString(),
|
|
115
|
+
informedBy: Type.Optional(StringArray),
|
|
116
|
+
metadata: Type.Optional(Type.Any()),
|
|
117
|
+
deliveryPolicy: DeliveryPolicySchema
|
|
118
|
+
}, { additionalProperties: true });
|
|
119
|
+
var LegacyMessageSchema = Type.Object({
|
|
120
|
+
id: Type.String(),
|
|
121
|
+
workspace: Type.String(),
|
|
122
|
+
source: Type.String(),
|
|
123
|
+
type: Type.String(),
|
|
124
|
+
content: Type.String(),
|
|
125
|
+
contentType: Type.String(),
|
|
126
|
+
sequence: Type.String(),
|
|
127
|
+
createdAt: Type.String(),
|
|
128
|
+
data: Type.Optional(Type.Any()),
|
|
129
|
+
targets: StringArray,
|
|
130
|
+
threadId: OptionalString(),
|
|
131
|
+
replyToId: OptionalString(),
|
|
132
|
+
correlationId: OptionalString(),
|
|
133
|
+
causationId: OptionalString(),
|
|
134
|
+
priority: Type.Enum(["info", "high", "urgent"]),
|
|
135
|
+
expiresAt: OptionalString(),
|
|
136
|
+
idempotencyKey: OptionalString(),
|
|
137
|
+
atribReceiptId: OptionalString(),
|
|
138
|
+
informedBy: Type.Optional(StringArray),
|
|
139
|
+
metadata: Type.Optional(Type.Any())
|
|
140
|
+
}, { additionalProperties: true });
|
|
141
|
+
var DeliveryStateSchema = Type.Enum(["pending", "claimed", "acked", "retrying", "dead", "cancelled"]);
|
|
142
|
+
var DeliveryActionSchema = Type.Enum(["created", "claim", "ack", "nack_retry", "nack_dead", "lease_expired", "attempts_exhausted", "message_expired", "cancel", "requeue"]);
|
|
143
|
+
var DeliverySchema = Type.Object({
|
|
144
|
+
id: Type.String(),
|
|
145
|
+
messageId: Type.String(),
|
|
146
|
+
workspace: Type.String(),
|
|
147
|
+
recipient: Type.String(),
|
|
148
|
+
state: DeliveryStateSchema,
|
|
149
|
+
attempt: Type.Number(),
|
|
150
|
+
cycleAttempt: Type.Number(),
|
|
151
|
+
requeueCount: Type.Number(),
|
|
152
|
+
createdAt: Type.String(),
|
|
153
|
+
priorityRank: Type.Number(),
|
|
154
|
+
availableAt: Type.String(),
|
|
155
|
+
leaseToken: OptionalString(),
|
|
156
|
+
leaseOwner: OptionalString(),
|
|
157
|
+
leaseExpiresAt: OptionalString(),
|
|
158
|
+
lastError: OptionalString(),
|
|
159
|
+
lastActor: OptionalString(),
|
|
160
|
+
lastAction: DeliveryActionSchema
|
|
161
|
+
}, { additionalProperties: true });
|
|
162
|
+
var LegacyDeliverySchema = Type.Object({
|
|
163
|
+
id: Type.String(),
|
|
164
|
+
messageId: Type.String(),
|
|
165
|
+
workspace: Type.String(),
|
|
166
|
+
recipient: Type.String(),
|
|
167
|
+
state: Type.Enum(["pending", "claimed", "acked", "retrying", "dead"]),
|
|
168
|
+
attempt: Type.Number(),
|
|
169
|
+
availableAt: Type.String(),
|
|
170
|
+
leaseToken: OptionalString(),
|
|
171
|
+
leaseOwner: OptionalString(),
|
|
172
|
+
leaseExpiresAt: OptionalString(),
|
|
173
|
+
lastError: OptionalString()
|
|
174
|
+
}, { additionalProperties: true });
|
|
175
|
+
var DeliveryEventSchema = Type.Object({
|
|
176
|
+
sequence: Type.String(),
|
|
177
|
+
deliveryId: Type.String(),
|
|
178
|
+
messageId: Type.String(),
|
|
179
|
+
workspace: Type.String(),
|
|
180
|
+
recipient: Type.String(),
|
|
181
|
+
fromState: Type.Optional(DeliveryStateSchema),
|
|
182
|
+
toState: DeliveryStateSchema,
|
|
183
|
+
attempt: Type.Number(),
|
|
184
|
+
cycleAttempt: Type.Number(),
|
|
185
|
+
requeueCount: Type.Number(),
|
|
186
|
+
leaseOwner: OptionalString(),
|
|
187
|
+
error: OptionalString(),
|
|
188
|
+
actor: Type.String(),
|
|
189
|
+
action: DeliveryActionSchema,
|
|
190
|
+
createdAt: Type.String()
|
|
191
|
+
}, { additionalProperties: true });
|
|
192
|
+
var PresenceSchema = Type.Object({
|
|
193
|
+
workspace: Type.String(),
|
|
194
|
+
agent: Type.String(),
|
|
195
|
+
instance: Type.String(),
|
|
196
|
+
runtimeType: OptionalString(),
|
|
197
|
+
capabilities: StringArray,
|
|
198
|
+
leaseExpiresAt: Type.String(),
|
|
199
|
+
lastSeenAt: Type.String()
|
|
200
|
+
}, { additionalProperties: true });
|
|
201
|
+
var DeliveryDiagnosticsProperties = {
|
|
202
|
+
schemaVersion: Type.Enum(["local-v2", "postgres-v2", "legacy-v1"]),
|
|
203
|
+
deliverySupported: Type.Boolean(),
|
|
204
|
+
pending: NullableNumber(),
|
|
205
|
+
claimed: NullableNumber(),
|
|
206
|
+
retrying: NullableNumber(),
|
|
207
|
+
dead: NullableNumber(),
|
|
208
|
+
cancelled: Type.Optional(NullableNumber()),
|
|
209
|
+
oldestAvailableAt: OptionalString(),
|
|
210
|
+
due: Type.Optional(NullableNumber()),
|
|
211
|
+
scheduled: Type.Optional(NullableNumber()),
|
|
212
|
+
expiredLeases: Type.Optional(NullableNumber()),
|
|
213
|
+
oldestDueAt: OptionalString(),
|
|
214
|
+
queueLagMs: Type.Optional(NullableNumber()),
|
|
215
|
+
principal: Type.Optional(Type.Object({ workspace: Type.String(), agent: Type.String() }, { additionalProperties: true }))
|
|
216
|
+
};
|
|
217
|
+
var DiagnosticsSchema = Type.Object(DeliveryDiagnosticsProperties, { additionalProperties: true });
|
|
218
|
+
var ClientDiagnosticsSchema = Type.Object({
|
|
219
|
+
...DeliveryDiagnosticsProperties,
|
|
220
|
+
remoteReachable: Type.Optional(Type.Union([Type.Boolean(), Type.Null()])),
|
|
221
|
+
outboxPending: OptionalNumber(),
|
|
222
|
+
outboxBlocked: OptionalNumber(),
|
|
223
|
+
cachedMessages: OptionalNumber(),
|
|
224
|
+
lastSyncAt: OptionalString(),
|
|
225
|
+
lastSyncError: OptionalString(),
|
|
226
|
+
outboxDue: OptionalNumber(),
|
|
227
|
+
outboxScheduled: OptionalNumber(),
|
|
228
|
+
outboxLeased: OptionalNumber(),
|
|
229
|
+
outboxOldestDueAt: OptionalString(),
|
|
230
|
+
outboxQueueLagMs: OptionalNumber(),
|
|
231
|
+
outboxOldestBlockedAt: OptionalString(),
|
|
232
|
+
outboxBlockedAgeMs: Type.Optional(NullableNumber()),
|
|
233
|
+
outboxBlockedMaxAttempts: OptionalNumber(),
|
|
234
|
+
outboxBlockedLastError: OptionalString(),
|
|
235
|
+
outboxNextRetryAt: OptionalString(),
|
|
236
|
+
lastOutboundSyncAt: OptionalString(),
|
|
237
|
+
lastInboundSyncAt: OptionalString(),
|
|
238
|
+
lastSyncAttemptAt: OptionalString(),
|
|
239
|
+
syncLoopState: Type.Optional(Type.Enum(["disabled", "idle", "running", "backoff", "stopped", "failed"])),
|
|
240
|
+
syncLoopError: OptionalString(),
|
|
241
|
+
remoteError: OptionalString()
|
|
242
|
+
}, { additionalProperties: true });
|
|
243
|
+
var ClientStatusSchema = Type.Object({
|
|
244
|
+
status: Type.Enum(["ok", "unknown", "degraded", "failed"]),
|
|
245
|
+
localHealthy: Type.Boolean(),
|
|
246
|
+
connected: Type.Boolean(),
|
|
247
|
+
remoteReachable: Type.Union([Type.Boolean(), Type.Null()]),
|
|
248
|
+
provider: Type.Enum(["local", "gateway", "legacy-supabase"]),
|
|
249
|
+
workspace: Type.String(),
|
|
250
|
+
agent: Type.String(),
|
|
251
|
+
instance: Type.Union([Type.String(), Type.Null()]),
|
|
252
|
+
schemaVersion: Type.Enum(["local-v2", "postgres-v2", "legacy-v1"]),
|
|
253
|
+
endpoint: Type.Union([Type.String(), Type.Null()]),
|
|
254
|
+
database: Type.Union([Type.String(), Type.Null()]),
|
|
255
|
+
cursorPath: Type.String(),
|
|
256
|
+
lastCursor: Type.Union([Type.String(), Type.Null()]),
|
|
257
|
+
queue: ClientDiagnosticsSchema,
|
|
258
|
+
checks: Type.Array(Type.Object({
|
|
259
|
+
name: Type.String(),
|
|
260
|
+
status: Type.Enum(["ok", "unknown", "degraded", "failed"]),
|
|
261
|
+
message: Type.String()
|
|
262
|
+
}, { additionalProperties: false }))
|
|
263
|
+
}, { additionalProperties: true });
|
|
264
|
+
var HistoryRequestSchema = Type.Object({
|
|
265
|
+
cursor: OptionalString(),
|
|
266
|
+
limit: OptionalNumber({ minimum: 1, maximum: 200 }),
|
|
267
|
+
types: Type.Optional(StringArray),
|
|
268
|
+
mailbox: Type.Optional(Type.Enum(["inbox", "sent", "all"])),
|
|
269
|
+
receiptState: Type.Optional(Type.Enum(["any", "unread", "read"])),
|
|
270
|
+
includeExpired: OptionalBoolean(),
|
|
271
|
+
source: OptionalString(),
|
|
272
|
+
project: OptionalString(),
|
|
273
|
+
since: OptionalString(),
|
|
274
|
+
unacknowledgedBy: OptionalString(),
|
|
275
|
+
threadId: OptionalString(),
|
|
276
|
+
latest: OptionalBoolean()
|
|
277
|
+
}, { additionalProperties: false });
|
|
278
|
+
var MessagePageSchema = Type.Object({
|
|
279
|
+
messages: Type.Array(MessageSchema),
|
|
280
|
+
cursor: OptionalString(),
|
|
281
|
+
source: Type.Optional(Type.Enum(["remote", "cache"])),
|
|
282
|
+
stale: OptionalBoolean(),
|
|
283
|
+
degraded: OptionalBoolean(),
|
|
284
|
+
acknowledgements: Type.Optional(Type.Enum(["authoritative", "unknown"])),
|
|
285
|
+
lastSyncedAt: OptionalString()
|
|
286
|
+
}, { additionalProperties: true });
|
|
287
|
+
var DeliveryPageSchema = Type.Object({ deliveries: Type.Array(DeliverySchema), cursor: OptionalString() }, { additionalProperties: true });
|
|
288
|
+
var DeliveryEventPageSchema = Type.Object({ events: Type.Array(DeliveryEventSchema), cursor: OptionalString() }, { additionalProperties: true });
|
|
289
|
+
var DeliveryIdSchema = Type.Object({ deliveryId: Type.String() }, { additionalProperties: false });
|
|
290
|
+
var LeaseSchema = Type.Object({ deliveryId: Type.String(), leaseToken: Type.String() }, { additionalProperties: false });
|
|
291
|
+
var RetryPolicySchema = Type.Object({
|
|
292
|
+
maxAttempts: OptionalNumber(),
|
|
293
|
+
baseDelayMs: OptionalNumber(),
|
|
294
|
+
maxDelayMs: OptionalNumber(),
|
|
295
|
+
jitterRatio: OptionalNumber()
|
|
296
|
+
}, { additionalProperties: false });
|
|
297
|
+
var NegativeAcknowledgeRequestSchema = Type.Object({
|
|
298
|
+
deliveryId: Type.String(),
|
|
299
|
+
leaseToken: Type.String(),
|
|
300
|
+
error: Type.String(),
|
|
301
|
+
disposition: Type.Optional(Type.Enum(["retry", "dead"])),
|
|
302
|
+
dead: OptionalBoolean(),
|
|
303
|
+
retryPolicy: Type.Optional(RetryPolicySchema)
|
|
304
|
+
}, { additionalProperties: false });
|
|
305
|
+
var LegacyNegativeAcknowledgeRequestSchema = Type.Object({
|
|
306
|
+
deliveryId: Type.String(),
|
|
307
|
+
leaseToken: Type.String(),
|
|
308
|
+
error: OptionalString(),
|
|
309
|
+
disposition: Type.Optional(Type.Enum(["retry", "dead"])),
|
|
310
|
+
dead: OptionalBoolean(),
|
|
311
|
+
retryPolicy: Type.Optional(RetryPolicySchema)
|
|
312
|
+
}, { additionalProperties: false });
|
|
313
|
+
var SyncResponseSchema = Type.Object({
|
|
314
|
+
online: Type.Boolean(),
|
|
315
|
+
pushed: Type.Number(),
|
|
316
|
+
deduplicated: Type.Number(),
|
|
317
|
+
pulled: Type.Number(),
|
|
318
|
+
pending: Type.Number(),
|
|
319
|
+
blocked: Type.Number(),
|
|
320
|
+
cached: Type.Number(),
|
|
321
|
+
cursor: Type.Optional(NullableString()),
|
|
322
|
+
lastSyncedAt: Type.Optional(NullableString()),
|
|
323
|
+
lastError: Type.Optional(NullableString()),
|
|
324
|
+
failureRetryable: OptionalBoolean()
|
|
325
|
+
}, { additionalProperties: true });
|
|
326
|
+
var ClaimResponseSchema = Type.Object({
|
|
327
|
+
delivery: Type.Union([DeliverySchema, Type.Null()]),
|
|
328
|
+
leaseToken: OptionalString()
|
|
329
|
+
}, {
|
|
330
|
+
additionalProperties: true,
|
|
331
|
+
oneOf: [
|
|
332
|
+
{ properties: { delivery: { type: "null" }, leaseToken: false }, required: ["delivery"] },
|
|
333
|
+
{ properties: { delivery: DeliverySchema, leaseToken: { type: "string" } }, required: ["delivery", "leaseToken"] }
|
|
334
|
+
]
|
|
335
|
+
});
|
|
336
|
+
var ALL_PROVIDERS = ["local", "gateway", "legacy-supabase"];
|
|
337
|
+
var DELIVERY_PROVIDERS = ["local", "gateway"];
|
|
338
|
+
var GATEWAY_PROVIDER = ["gateway"];
|
|
339
|
+
var operation = (entry) => entry;
|
|
340
|
+
var HistoryCliOptions = ["cursor", "limit", "type", "category", "mailbox", "receipt-state", "source", "project", "since", "unacked-by", "thread-id", "latest"];
|
|
341
|
+
var LegacyGetRowSchema = Type.Object({
|
|
342
|
+
id: Type.Union([Type.String(), Type.Number()]),
|
|
343
|
+
source: Type.String(),
|
|
344
|
+
category: Type.String(),
|
|
345
|
+
content: Type.String(),
|
|
346
|
+
priority: Type.Enum(["info", "high", "urgent"]),
|
|
347
|
+
project: NullableString(),
|
|
348
|
+
metadata: Type.Any(),
|
|
349
|
+
created_at: Type.String()
|
|
350
|
+
}, { additionalProperties: false });
|
|
351
|
+
var ReceiptCliResponseSchema = Type.Object({
|
|
352
|
+
acknowledged: Type.Number(),
|
|
353
|
+
agent: Type.String()
|
|
354
|
+
}, { additionalProperties: true });
|
|
355
|
+
var operations = [
|
|
356
|
+
operation({ id: "capabilities", summary: "Discover operations available on the current surface.", request: Empty, response: Type.Object({ protocolVersion: Type.String(), currentProtocolVersion: Type.String(), selectedProtocolVersion: Type.String(), supportedProtocolVersions: StringArray, scopeEnforcement: Type.Boolean(), requestAuthority: Type.Boolean(), rowIsolation: Type.Boolean(), authorizationModel: Type.Enum(["scoped-credential", "credential-wide", "process-identity", "legacy-key"]), surface: Type.Enum(["mcp", "http", "cli"]), provider: Type.Enum(["local", "gateway", "legacy-supabase"]), operations: Type.Array(Type.Object({ id: Type.String(), summary: Type.String(), requiredScopes: StringArray, mcp: Type.Optional(Type.Any()), http: Type.Optional(Type.Any()), cli: Type.Optional(Type.Any()) }, { additionalProperties: true })) }, { additionalProperties: true }), scopes: [], providers: ALL_PROVIDERS, mcp: { name: "capabilities" }, http: { method: "GET", path: "/v2/capabilities" }, cli: { command: "capabilities", options: [] } }),
|
|
357
|
+
operation({ id: "status", summary: "Read gateway delivery diagnostics.", request: Empty, response: DiagnosticsSchema, scopes: ["status:read"], providers: ALL_PROVIDERS, http: { method: "GET", path: "/v2/status" } }),
|
|
358
|
+
operation({ id: "client_status", summary: "Read client connectivity and provider diagnostics.", request: Empty, response: ClientStatusSchema, scopes: ["status:read"], providers: ALL_PROVIDERS, cli: { command: "status", aliases: ["doctor"], options: [] } }),
|
|
359
|
+
operation({ id: "gateway_metrics", summary: "Read Prometheus gateway counters.", request: Empty, response: Type.String(), scopes: ["gateway:metrics"], providers: GATEWAY_PROVIDER, http: { method: "GET", path: "/metrics", responseContentType: "text/plain" } }),
|
|
360
|
+
operation({ id: "publish_message", summary: "Create an immutable Agent Bridge v2 message.", request: MessageDraftSchema, response: Type.Object({ created: Type.Boolean(), message: MessageSchema, disposition: Type.Optional(Type.Enum(["committed", "queued"])), authoritative: OptionalBoolean() }, { additionalProperties: true }), scopes: ["messages:write"], providers: ALL_PROVIDERS, mcp: { name: "send" }, http: { method: "POST", path: "/v2/messages", successStatus: 201 }, cli: { command: "send", aliases: ["post"], options: ["source", "project", "type", "kind", "category", "content", "content-type", "data", "payload", "payload-mime", "payload-ref", "payload-ciphertext", "target", "target-agent", "target-agents", "thread-id", "reply-to-id", "correlation-id", "causation-id", "priority", "expires-at", "idempotency-key", "atrib-receipt-id", "informed-by", "metadata", "delivery-mode", "delivery-policy", "delivery-max-attempts", "retry-base-ms", "retry-max-ms", "retry-jitter", "not-before", "message-id"] } }),
|
|
361
|
+
operation({ id: "history", summary: "Read visible messages after an opaque cursor.", request: HistoryRequestSchema, response: MessagePageSchema, scopes: ["messages:read"], providers: ALL_PROVIDERS, mcp: { name: "history" }, http: { method: "GET", path: "/v2/history", queryAliases: { unacknowledgedBy: ["unacked_by"] } }, cli: { command: "history", aliases: ["inbox", "sent"], options: HistoryCliOptions, variants: [{ command: "get", condition: { kind: "always" }, routesTo: "history", options: HistoryCliOptions, response: Type.Array(LegacyGetRowSchema) }] } }),
|
|
362
|
+
operation({ id: "record_receipt", summary: "Record caller-bound inbox read receipts.", request: Type.Object({ messageIds: Type.Array(Type.String(), { minItems: 1, maxItems: 200 }) }, { additionalProperties: false }), response: Type.Object({ recorded: Type.Number() }, { additionalProperties: true }), scopes: ["receipts:write"], providers: ALL_PROVIDERS, http: { method: "POST", path: "/v2/receipts" }, cli: { command: "acknowledge", aliases: ["receipt"], options: ["ids"], response: ReceiptCliResponseSchema, variants: [{ command: "ack", condition: { kind: "option-present", option: "ids" }, routesTo: "record_receipt", options: ["ids"], response: ReceiptCliResponseSchema }] } }),
|
|
363
|
+
operation({ id: "claim_delivery", summary: "Atomically claim the next targeted delivery.", request: Type.Object({ leaseMs: OptionalNumber(), maxAttempts: OptionalNumber() }, { additionalProperties: false }), response: ClaimResponseSchema, scopes: ["deliveries:claim"], providers: DELIVERY_PROVIDERS, mcp: { name: "claim" }, http: { method: "POST", path: "/v2/deliveries/claim" }, cli: { command: "claim", options: ["lease-ms", "max-attempts"], response: Type.Union([Type.Object({ delivery: DeliverySchema, leaseToken: Type.String() }, { additionalProperties: true }), Type.Null()]) } }),
|
|
364
|
+
operation({ id: "list_deliveries", summary: "List caller-visible deliveries.", request: Type.Object({ cursor: OptionalString(), limit: OptionalNumber(), role: Type.Optional(Type.Enum(["recipient", "publisher", "all"])), messageId: OptionalString(), recipient: OptionalString(), states: Type.Optional(Type.Array(DeliveryStateSchema)) }, { additionalProperties: false }), response: DeliveryPageSchema, scopes: ["deliveries:read"], providers: DELIVERY_PROVIDERS, mcp: { name: "list_deliveries" }, http: { method: "GET", path: "/v2/deliveries" }, cli: { command: "deliveries", aliases: ["dead-letters"], options: ["cursor", "limit", "role", "message-id", "recipient", "state"] } }),
|
|
365
|
+
operation({ id: "list_delivery_events", summary: "List the append-only event history for a delivery.", request: Type.Object({ deliveryId: Type.String(), cursor: OptionalString(), limit: OptionalNumber() }, { additionalProperties: false }), response: DeliveryEventPageSchema, scopes: ["deliveries:read"], providers: DELIVERY_PROVIDERS, mcp: { name: "list_delivery_events" }, http: { method: "GET", path: "/v2/deliveries/{deliveryId}/events" }, cli: { command: "delivery-events", options: ["delivery-id", "cursor", "limit"] } }),
|
|
366
|
+
operation({ id: "cancel_delivery", summary: "Cancel a delivery as its publisher.", request: DeliveryIdSchema, response: Type.Object({ delivery: Type.Union([DeliverySchema, Type.Null()]) }, { additionalProperties: true }), scopes: ["deliveries:manage"], providers: DELIVERY_PROVIDERS, mcp: { name: "cancel_delivery" }, http: { method: "POST", path: "/v2/deliveries/{deliveryId}/cancel" }, cli: { command: "cancel", options: ["delivery-id"], response: Type.Union([DeliverySchema, Type.Null()]) } }),
|
|
367
|
+
operation({ id: "requeue_delivery", summary: "Requeue a delivery as its publisher.", request: DeliveryIdSchema, response: Type.Object({ delivery: Type.Union([DeliverySchema, Type.Null()]) }, { additionalProperties: true }), scopes: ["deliveries:manage"], providers: DELIVERY_PROVIDERS, mcp: { name: "requeue_delivery" }, http: { method: "POST", path: "/v2/deliveries/{deliveryId}/requeue" }, cli: { command: "requeue", options: ["delivery-id"], response: Type.Union([DeliverySchema, Type.Null()]) } }),
|
|
368
|
+
operation({ id: "extend_delivery", summary: "Extend a claimed delivery lease.", request: Type.Object({ deliveryId: Type.String(), leaseToken: Type.String(), leaseMs: Type.Number() }, { additionalProperties: false }), response: Type.Object({ delivery: Type.Union([DeliverySchema, Type.Null()]) }, { additionalProperties: true }), scopes: ["deliveries:settle"], providers: DELIVERY_PROVIDERS, mcp: { name: "extend" }, http: { method: "POST", path: "/v2/deliveries/{deliveryId}/extend" }, cli: { command: "extend", options: ["delivery-id", "lease-token", "lease-ms"], response: Type.Union([DeliverySchema, Type.Null()]) } }),
|
|
369
|
+
operation({ id: "acknowledge_delivery", summary: "Settle a claimed delivery successfully.", request: LeaseSchema, response: Type.Object({ delivery: Type.Union([DeliverySchema, Type.Null()]) }, { additionalProperties: true }), scopes: ["deliveries:settle"], providers: DELIVERY_PROVIDERS, mcp: { name: "acknowledge" }, http: { method: "POST", path: "/v2/deliveries/{deliveryId}/ack" }, cli: { command: "ack", options: ["delivery-id", "lease-token"], response: Type.Union([DeliverySchema, Type.Null()]) } }),
|
|
370
|
+
operation({ id: "negative_acknowledge_delivery", summary: "Settle a claimed delivery for retry or dead letter.", request: NegativeAcknowledgeRequestSchema, response: Type.Object({ delivery: Type.Union([DeliverySchema, Type.Null()]) }, { additionalProperties: true }), scopes: ["deliveries:settle"], providers: DELIVERY_PROVIDERS, mcp: { name: "negative_acknowledge" }, http: { method: "POST", path: "/v2/deliveries/{deliveryId}/nack" }, cli: { command: "nack", options: ["delivery-id", "lease-token", "error", "disposition", "dead"], response: Type.Union([DeliverySchema, Type.Null()]) } }),
|
|
371
|
+
operation({ id: "heartbeat", summary: "Publish a leased runtime presence record.", request: Type.Object({ leaseMs: OptionalNumber({ minimum: 1e3, maximum: 9e5 }), runtimeType: OptionalString(), capabilities: Type.Optional(StringArray) }, { additionalProperties: false }), response: PresenceSchema, scopes: ["presence:write"], providers: DELIVERY_PROVIDERS, mcp: { name: "heartbeat" }, http: { method: "POST", path: "/v2/presence/heartbeat" }, cli: { command: "join", options: ["lease-ms", "runtime", "capability"] } }),
|
|
372
|
+
operation({ id: "presence", summary: "List active agent runtime instances.", request: Empty, response: Type.Object({ agents: Type.Array(PresenceSchema) }, { additionalProperties: true }), scopes: ["presence:read"], providers: DELIVERY_PROVIDERS, mcp: { name: "presence" }, http: { method: "GET", path: "/v2/presence" }, cli: { command: "presence", options: [] } }),
|
|
373
|
+
operation({ id: "sync", summary: "Replay a gateway outbox and refresh its inbox cache.", request: Type.Object({ maxPush: OptionalNumber(), maxPages: OptionalNumber() }, { additionalProperties: false }), response: SyncResponseSchema, scopes: ["messages:write", "messages:read"], providers: GATEWAY_PROVIDER, mcp: { name: "sync" }, cli: { command: "sync", options: ["max-push", "max-pages", "limit"] } })
|
|
374
|
+
];
|
|
375
|
+
var byId = new Map(operations.map((entry) => [entry.id, entry]));
|
|
376
|
+
var ContractValidationError = class extends Error {
|
|
377
|
+
constructor(operation2, issues2) {
|
|
378
|
+
super(`Request does not match the ${operation2} schema`);
|
|
379
|
+
this.operation = operation2;
|
|
380
|
+
this.issues = issues2;
|
|
381
|
+
this.code = "invalid_input";
|
|
382
|
+
this.status = 400;
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var ContractResponseError = class extends Error {
|
|
386
|
+
constructor(operation2, issues2) {
|
|
387
|
+
super(`Response does not match the ${operation2} schema`);
|
|
388
|
+
this.operation = operation2;
|
|
389
|
+
this.issues = issues2;
|
|
390
|
+
this.code = "protocol_mismatch";
|
|
391
|
+
this.status = 502;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
function issues(schema, value) {
|
|
395
|
+
return [...Errors(schema, value)].map((entry) => ({ path: entry.instancePath || "/", message: entry.message }));
|
|
396
|
+
}
|
|
397
|
+
function operationContract(operationId) {
|
|
398
|
+
const contract = byId.get(operationId);
|
|
399
|
+
if (!contract) throw new Error(`Unknown operation contract: ${operationId}`);
|
|
400
|
+
return contract;
|
|
401
|
+
}
|
|
402
|
+
function validateRequest(operationId, value) {
|
|
403
|
+
const contract = operationContract(operationId);
|
|
404
|
+
if (!Check(contract.request, value)) throw new ContractValidationError(operationId, issues(contract.request, value));
|
|
405
|
+
return value;
|
|
406
|
+
}
|
|
407
|
+
function validateRequestForProtocol(operationId, value, protocolVersion) {
|
|
408
|
+
if (protocolVersion === LEGACY_PROTOCOL_VERSION) {
|
|
409
|
+
if (operationId === "publish_message") {
|
|
410
|
+
if (!Check(LegacyMessageDraftSchema, value)) throw new ContractValidationError(operationId, issues(LegacyMessageDraftSchema, value));
|
|
411
|
+
return value;
|
|
412
|
+
}
|
|
413
|
+
if (["list_deliveries", "list_delivery_events", "cancel_delivery", "requeue_delivery", "capabilities"].includes(operationId)) {
|
|
414
|
+
throw new ContractValidationError(operationId, [{ path: "/", message: `Operation is not supported by protocol ${LEGACY_PROTOCOL_VERSION}` }]);
|
|
415
|
+
}
|
|
416
|
+
if (operationId === "history" && value && typeof value === "object") {
|
|
417
|
+
const unsupported = ["mailbox", "receiptState", "project"].find((field) => value[field] !== void 0);
|
|
418
|
+
if (unsupported) throw new ContractValidationError(operationId, [{ path: `/${unsupported}`, message: `Field is not supported by protocol ${LEGACY_PROTOCOL_VERSION}` }]);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (operationId !== "negative_acknowledge_delivery" || protocolVersion !== LEGACY_PROTOCOL_VERSION) {
|
|
422
|
+
return validateRequest(operationId, value);
|
|
423
|
+
}
|
|
424
|
+
if (!Check(LegacyNegativeAcknowledgeRequestSchema, value)) {
|
|
425
|
+
throw new ContractValidationError(operationId, issues(LegacyNegativeAcknowledgeRequestSchema, value));
|
|
426
|
+
}
|
|
427
|
+
return value;
|
|
428
|
+
}
|
|
429
|
+
function parseResponse(operationId, value) {
|
|
430
|
+
const contract = operationContract(operationId);
|
|
431
|
+
const serialized = JSON.stringify(value);
|
|
432
|
+
const wireValue = serialized === void 0 ? value : JSON.parse(serialized);
|
|
433
|
+
if (!Check(contract.response, wireValue)) throw new ContractResponseError(operationId, issues(contract.response, wireValue));
|
|
434
|
+
return wireValue;
|
|
435
|
+
}
|
|
436
|
+
function parseCliResponse(operationId, value, invocation) {
|
|
437
|
+
const contract = operationContract(operationId);
|
|
438
|
+
const optionNames = new Set(invocation?.optionNames ?? []);
|
|
439
|
+
const variant = contract.cli?.variants?.find((entry) => entry.command === invocation?.command && cliVariantMatches(entry, optionNames));
|
|
440
|
+
const schema = variant?.response ?? contract.cli?.response ?? contract.response;
|
|
441
|
+
const serialized = JSON.stringify(value);
|
|
442
|
+
const wireValue = serialized === void 0 ? value : JSON.parse(serialized);
|
|
443
|
+
if (!Check(schema, wireValue)) throw new ContractResponseError(operationId, issues(schema, wireValue));
|
|
444
|
+
return wireValue;
|
|
445
|
+
}
|
|
446
|
+
function availableOperations(context) {
|
|
447
|
+
return operations.filter((entry) => entry.providers.includes(context.provider) && Boolean(entry[context.surface]));
|
|
448
|
+
}
|
|
449
|
+
function cliVariantMatches(variant, optionNames) {
|
|
450
|
+
return variant.condition.kind === "always" || optionNames.has(variant.condition.option);
|
|
451
|
+
}
|
|
452
|
+
function operationForCli(command, provider, optionNames = []) {
|
|
453
|
+
const selectedOptions = new Set(optionNames);
|
|
454
|
+
return availableOperations({ surface: "cli", provider }).find((entry) => entry.cli?.command === command || entry.cli?.aliases?.includes(command) || entry.cli?.variants?.some((variant) => variant.command === command && cliVariantMatches(variant, selectedOptions)));
|
|
455
|
+
}
|
|
456
|
+
function capabilityDocument(context = { surface: "http", provider: "gateway" }) {
|
|
457
|
+
const selectedProtocolVersion = context.selectedProtocolVersion ?? PROTOCOL_VERSION;
|
|
458
|
+
return {
|
|
459
|
+
protocolVersion: selectedProtocolVersion,
|
|
460
|
+
currentProtocolVersion: PROTOCOL_VERSION,
|
|
461
|
+
selectedProtocolVersion,
|
|
462
|
+
supportedProtocolVersions: [...SUPPORTED_PROTOCOL_VERSIONS],
|
|
463
|
+
scopeEnforcement: context.provider === "gateway" ? SCOPE_ENFORCEMENT : false,
|
|
464
|
+
requestAuthority: context.provider === "gateway" && context.requestAuthority === true,
|
|
465
|
+
rowIsolation: context.provider === "gateway" && context.requestAuthority === true && context.rowIsolation === true,
|
|
466
|
+
authorizationModel: context.provider === "gateway" ? "scoped-credential" : context.provider === "local" ? "process-identity" : "legacy-key",
|
|
467
|
+
surface: context.surface,
|
|
468
|
+
provider: context.provider,
|
|
469
|
+
operations: availableOperations(context).map(({ request: _request, response, providers: _providers, scopes, cli, ...entry }) => ({
|
|
470
|
+
...entry,
|
|
471
|
+
...cli ? {
|
|
472
|
+
cli: {
|
|
473
|
+
command: cli.command,
|
|
474
|
+
...cli.aliases ? { aliases: cli.aliases } : {},
|
|
475
|
+
options: cli.options,
|
|
476
|
+
outputSchema: cli.response ?? response,
|
|
477
|
+
...cli.variants ? {
|
|
478
|
+
variants: cli.variants.map((variant) => ({
|
|
479
|
+
command: variant.command,
|
|
480
|
+
condition: variant.condition,
|
|
481
|
+
routesTo: variant.routesTo,
|
|
482
|
+
options: variant.options,
|
|
483
|
+
outputSchema: variant.response
|
|
484
|
+
}))
|
|
485
|
+
} : {}
|
|
486
|
+
}
|
|
487
|
+
} : {},
|
|
488
|
+
requiredScopes: [...scopes]
|
|
489
|
+
}))
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function negotiateProtocolVersion(value) {
|
|
493
|
+
const requested = Array.isArray(value) ? value[0] : value;
|
|
494
|
+
if (requested === void 0 || requested.trim() === "") return LEGACY_PROTOCOL_VERSION;
|
|
495
|
+
if (SUPPORTED_PROTOCOL_VERSIONS.includes(requested.trim())) return requested.trim();
|
|
496
|
+
const error = new Error("Unsupported Agent Bridge protocol version");
|
|
497
|
+
error.status = 426;
|
|
498
|
+
error.code = "unsupported_protocol_version";
|
|
499
|
+
error.supported = SUPPORTED_PROTOCOL_RANGE;
|
|
500
|
+
throw error;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export {
|
|
504
|
+
PROTOCOL_VERSION,
|
|
505
|
+
LEGACY_PROTOCOL_VERSION,
|
|
506
|
+
SUPPORTED_PROTOCOL_VERSIONS,
|
|
507
|
+
PROTOCOL_HEADER,
|
|
508
|
+
SUPPORTED_PROTOCOL_HEADER,
|
|
509
|
+
SCOPE_ENFORCEMENT,
|
|
510
|
+
ErrorEnvelopeSchema,
|
|
511
|
+
LegacyMessageDraftSchema,
|
|
512
|
+
LegacyMessageSchema,
|
|
513
|
+
LegacyDeliverySchema,
|
|
514
|
+
operations,
|
|
515
|
+
ContractValidationError,
|
|
516
|
+
ContractResponseError,
|
|
517
|
+
operationContract,
|
|
518
|
+
validateRequest,
|
|
519
|
+
validateRequestForProtocol,
|
|
520
|
+
parseResponse,
|
|
521
|
+
parseCliResponse,
|
|
522
|
+
availableOperations,
|
|
523
|
+
operationForCli,
|
|
524
|
+
capabilityDocument,
|
|
525
|
+
negotiateProtocolVersion
|
|
526
|
+
};
|
|
527
|
+
//# sourceMappingURL=chunk-GADH244D.js.map
|