@creatornader/agent-bridge 0.3.1 → 0.4.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.
- package/CHANGELOG.md +150 -1
- package/README.md +239 -5
- package/ROADMAP.md +59 -7
- package/SECURITY.md +55 -5
- package/SKILL.md +103 -0
- package/dist/archive.d.ts +2 -2
- package/dist/archive.js +2 -2
- package/dist/{bridge-service-hX1ZQp4W.d.ts → bridge-service-YTjGr91A.d.ts} +1 -1
- package/dist/{bridge-store-DPVSCwfs.d.ts → bridge-store-Boaj-ZbO.d.ts} +2 -0
- package/dist/bridge.d.ts +17 -7
- package/dist/bridge.js +15 -7
- package/dist/{chunk-WAI2IYIQ.js → chunk-3YHVUPU2.js} +48 -5
- package/dist/chunk-3YHVUPU2.js.map +1 -0
- package/dist/{chunk-45BZGB77.js → chunk-6BTJE6D4.js} +168 -7
- package/dist/chunk-6BTJE6D4.js.map +1 -0
- package/dist/{chunk-5GMB3A77.js → chunk-DQOZJJZ2.js} +22 -10
- package/dist/chunk-DQOZJJZ2.js.map +1 -0
- package/dist/{chunk-NCO7RLBM.js → chunk-GTK4KOED.js} +108 -8
- package/dist/chunk-GTK4KOED.js.map +1 -0
- package/dist/{chunk-GADH244D.js → chunk-IHZFI7TH.js} +12 -4
- package/dist/chunk-IHZFI7TH.js.map +1 -0
- package/dist/{chunk-CEXBMOI5.js → chunk-LAHNQZDN.js} +2 -2
- package/dist/{chunk-UAHMP6GC.js → chunk-MCKKVNCE.js} +9 -6
- package/dist/chunk-MCKKVNCE.js.map +1 -0
- package/dist/{chunk-MBPZXTJA.js → chunk-PDIHDBP3.js} +173 -20
- package/dist/chunk-PDIHDBP3.js.map +1 -0
- package/dist/{chunk-Q6PPMXJC.js → chunk-SV3SVBYS.js} +377 -21
- package/dist/chunk-SV3SVBYS.js.map +1 -0
- package/dist/{chunk-SPSMZOCJ.js → chunk-SYGONYMM.js} +4 -4
- package/dist/{chunk-A6W4QALF.js → chunk-TC6A7GMF.js} +2 -2
- package/dist/cli.js +5865 -436
- package/dist/cli.js.map +1 -1
- package/dist/client-runtime.d.ts +4 -2
- package/dist/client-runtime.js +6 -6
- package/dist/contracts/generate.js +1 -1
- package/dist/dr.d.ts +9 -2
- package/dist/dr.js +6 -4
- package/dist/{gateway-CggQ8vTC.d.ts → gateway-BQHpV-MZ.d.ts} +27 -3
- package/dist/gateway-main.js +69 -5
- package/dist/gateway-main.js.map +1 -1
- package/dist/gateway.d.ts +3 -3
- package/dist/gateway.js +2 -2
- package/dist/index.js +7 -7
- package/dist/{postgres-bridge-store-Bfd3hRId.d.ts → postgres-bridge-store-WASumj26.d.ts} +1 -1
- package/dist/server.js +7 -7
- package/dist/sqlite-edge-store-Bc15DvpX.d.ts +148 -0
- package/dist/sqlite.d.ts +19 -80
- package/dist/sqlite.js +11 -3
- package/docs/architecture-v2.md +256 -10
- package/docs/decisions/0004-client-lifecycle-and-endpoint-migration.md +204 -0
- package/docs/deployment.md +205 -0
- package/docs/troubleshooting.md +23 -0
- package/llms.txt +67 -0
- package/openapi/agent-bridge-v2.openapi.json +1023 -0
- package/package.json +6 -2
- package/schemas/agent-bridge-v2.capabilities.json +24 -0
- package/schemas/agent-bridge-v2.mcp.json +6 -0
- package/schemas/agent-bridge-v2.schema.json +163 -0
- package/sql/migrations/017_gateway_authority_binding.sql +99 -0
- package/sql/migrations/018_endpoint_migration_challenges.sql +1028 -0
- package/sql/migrations/019_endpoint_migration_same_successor.sql +324 -0
- package/dist/chunk-45BZGB77.js.map +0 -1
- package/dist/chunk-5GMB3A77.js.map +0 -1
- package/dist/chunk-GADH244D.js.map +0 -1
- package/dist/chunk-MBPZXTJA.js.map +0 -1
- package/dist/chunk-NCO7RLBM.js.map +0 -1
- package/dist/chunk-Q6PPMXJC.js.map +0 -1
- package/dist/chunk-UAHMP6GC.js.map +0 -1
- package/dist/chunk-WAI2IYIQ.js.map +0 -1
- /package/dist/{chunk-CEXBMOI5.js.map → chunk-LAHNQZDN.js.map} +0 -0
- /package/dist/{chunk-SPSMZOCJ.js.map → chunk-SYGONYMM.js.map} +0 -0
- /package/dist/{chunk-A6W4QALF.js.map → chunk-TC6A7GMF.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contracts/registry.ts"],"sourcesContent":["import Type, { type TSchema } from \"@sinclair/typebox\";\nimport { Check, Errors } from \"@sinclair/typebox/value\";\n\nexport const PROTOCOL_VERSION = \"2.1\";\nexport const LEGACY_PROTOCOL_VERSION = \"2.0\";\nexport const SUPPORTED_PROTOCOL_VERSIONS = [LEGACY_PROTOCOL_VERSION, PROTOCOL_VERSION] as const;\nexport const SUPPORTED_PROTOCOL_RANGE = SUPPORTED_PROTOCOL_VERSIONS.join(\",\");\nexport const PROTOCOL_HEADER = \"x-agent-bridge-protocol-version\";\nexport const SUPPORTED_PROTOCOL_HEADER = \"x-agent-bridge-supported-protocol-versions\";\nexport const SCOPE_ENFORCEMENT = true;\n\nconst StringArray = Type.Array(Type.String());\nconst Empty = Type.Object({}, { additionalProperties: false });\nconst OptionalString = () => Type.Optional(Type.String());\nconst OptionalNumber = (options: Record<string, unknown> = {}) => Type.Optional(Type.Number(options));\nconst OptionalBoolean = () => Type.Optional(Type.Boolean());\nconst NullableString = () => Type.Union([Type.String(), Type.Null()]);\nconst NullableNumber = () => Type.Union([Type.Number(), Type.Null()]);\nconst UUID_PATTERN = \"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$\";\nconst 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}$\";\n\nexport const ErrorIssueSchema = Type.Object({\n path: Type.String(),\n message: Type.String(),\n}, { additionalProperties: true });\n\nexport const ErrorEnvelopeSchema = Type.Object({\n error: Type.Object({\n code: Type.String(),\n requestId: Type.String(),\n message: OptionalString(),\n operation: OptionalString(),\n issues: Type.Optional(Type.Array(ErrorIssueSchema)),\n details: Type.Optional(Type.Any()),\n supportedProtocolVersions: Type.Optional(StringArray),\n }, { additionalProperties: true }),\n}, { additionalProperties: true });\n\nconst DeliveryPolicySchema = Type.Union([\n Type.Object({ mode: Type.Literal(\"mailbox\") }, { additionalProperties: false }),\n Type.Object({\n mode: Type.Literal(\"leased\"),\n maxAttempts: Type.Number(),\n retryBaseDelayMs: Type.Number(),\n retryMaxDelayMs: Type.Number(),\n retryJitterRatio: Type.Number(),\n notBefore: OptionalString(),\n }, { additionalProperties: false }),\n]);\n\nconst DeliveryPolicyInputSchema = Type.Object({\n mode: Type.Optional(Type.Enum([\"mailbox\", \"leased\"])),\n maxAttempts: OptionalNumber(),\n retryBaseDelayMs: OptionalNumber(),\n retryMaxDelayMs: OptionalNumber(),\n retryJitterRatio: OptionalNumber(),\n notBefore: OptionalString(),\n}, { additionalProperties: false });\n\nconst MessageDraftSchema = Type.Object({\n id: Type.Optional(Type.String({ pattern: UUID_V7_PATTERN })),\n source: OptionalString(),\n project: OptionalString(),\n type: Type.String(),\n content: Type.String(),\n contentType: OptionalString(),\n data: Type.Optional(Type.Any()),\n targets: Type.Optional(StringArray),\n threadId: OptionalString(),\n replyToId: OptionalString(),\n correlationId: OptionalString(),\n causationId: OptionalString(),\n priority: Type.Optional(Type.Enum([\"info\", \"high\", \"urgent\"])),\n expiresAt: OptionalString(),\n idempotencyKey: OptionalString(),\n atribReceiptId: OptionalString(),\n informedBy: Type.Optional(StringArray),\n metadata: Type.Optional(Type.Any()),\n deliveryPolicy: Type.Optional(DeliveryPolicyInputSchema),\n}, { additionalProperties: false });\n\n// Exact field set released by package 0.2.0 at d8184fe. A headerless\n// gateway response selects this wire contract, not the current one.\nexport const LegacyMessageDraftSchema = Type.Object({\n id: OptionalString(), source: OptionalString(), type: Type.String(), content: Type.String(),\n contentType: OptionalString(), data: Type.Optional(Type.Any()), targets: Type.Optional(StringArray),\n threadId: OptionalString(), replyToId: OptionalString(), correlationId: OptionalString(),\n causationId: OptionalString(), priority: Type.Optional(Type.Enum([\"info\", \"high\", \"urgent\"])),\n expiresAt: OptionalString(), idempotencyKey: OptionalString(), atribReceiptId: OptionalString(),\n informedBy: Type.Optional(StringArray), metadata: Type.Optional(Type.Any()),\n}, { additionalProperties: false });\n\nconst MessageSchema = Type.Object({\n id: Type.String(),\n workspace: Type.String(),\n project: OptionalString(),\n source: Type.String(),\n type: Type.String(),\n content: Type.String(),\n contentType: Type.String(),\n sequence: Type.String(),\n createdAt: Type.String(),\n data: Type.Optional(Type.Any()),\n targets: StringArray,\n threadId: OptionalString(),\n replyToId: OptionalString(),\n correlationId: OptionalString(),\n causationId: OptionalString(),\n priority: Type.Enum([\"info\", \"high\", \"urgent\"]),\n expiresAt: OptionalString(),\n idempotencyKey: OptionalString(),\n atribReceiptId: OptionalString(),\n informedBy: Type.Optional(StringArray),\n metadata: Type.Optional(Type.Any()),\n deliveryPolicy: DeliveryPolicySchema,\n}, { additionalProperties: true });\n\nexport const LegacyMessageSchema = Type.Object({\n id: Type.String(), workspace: Type.String(), source: Type.String(), type: Type.String(),\n content: Type.String(), contentType: Type.String(), sequence: Type.String(), createdAt: Type.String(),\n data: Type.Optional(Type.Any()), targets: StringArray, threadId: OptionalString(), replyToId: OptionalString(),\n correlationId: OptionalString(), causationId: OptionalString(), priority: Type.Enum([\"info\", \"high\", \"urgent\"]),\n expiresAt: OptionalString(), idempotencyKey: OptionalString(), atribReceiptId: OptionalString(),\n informedBy: Type.Optional(StringArray), metadata: Type.Optional(Type.Any()),\n}, { additionalProperties: true });\n\nconst DeliveryStateSchema = Type.Enum([\"pending\", \"claimed\", \"acked\", \"retrying\", \"dead\", \"cancelled\"]);\nconst DeliveryActionSchema = Type.Enum([\"created\", \"claim\", \"ack\", \"nack_retry\", \"nack_dead\", \"lease_expired\", \"attempts_exhausted\", \"message_expired\", \"cancel\", \"requeue\"]);\nconst DeliverySchema = Type.Object({\n id: Type.String(),\n messageId: Type.String(),\n workspace: Type.String(),\n recipient: Type.String(),\n state: DeliveryStateSchema,\n attempt: Type.Number(),\n cycleAttempt: Type.Number(),\n requeueCount: Type.Number(),\n createdAt: Type.String(),\n priorityRank: Type.Number(),\n availableAt: Type.String(),\n leaseToken: OptionalString(),\n leaseOwner: OptionalString(),\n leaseExpiresAt: OptionalString(),\n lastError: OptionalString(),\n lastActor: OptionalString(),\n lastAction: DeliveryActionSchema,\n}, { additionalProperties: true });\n\nexport const LegacyDeliverySchema = Type.Object({\n id: Type.String(), messageId: Type.String(), workspace: Type.String(), recipient: Type.String(),\n state: Type.Enum([\"pending\", \"claimed\", \"acked\", \"retrying\", \"dead\"]), attempt: Type.Number(),\n availableAt: Type.String(), leaseToken: OptionalString(), leaseOwner: OptionalString(),\n leaseExpiresAt: OptionalString(), lastError: OptionalString(),\n}, { additionalProperties: true });\n\nconst DeliveryEventSchema = Type.Object({\n sequence: Type.String(),\n deliveryId: Type.String(),\n messageId: Type.String(),\n workspace: Type.String(),\n recipient: Type.String(),\n fromState: Type.Optional(DeliveryStateSchema),\n toState: DeliveryStateSchema,\n attempt: Type.Number(),\n cycleAttempt: Type.Number(),\n requeueCount: Type.Number(),\n leaseOwner: OptionalString(),\n error: OptionalString(),\n actor: Type.String(),\n action: DeliveryActionSchema,\n createdAt: Type.String(),\n}, { additionalProperties: true });\n\nconst PresenceSchema = Type.Object({\n workspace: Type.String(),\n agent: Type.String(),\n instance: Type.String(),\n runtimeType: OptionalString(),\n capabilities: StringArray,\n leaseExpiresAt: Type.String(),\n lastSeenAt: Type.String(),\n}, { additionalProperties: true });\n\nconst DeliveryDiagnosticsProperties = {\n schemaVersion: Type.Enum([\"local-v2\", \"postgres-v2\", \"legacy-v1\"]),\n deliverySupported: Type.Boolean(),\n pending: NullableNumber(),\n claimed: NullableNumber(),\n retrying: NullableNumber(),\n dead: NullableNumber(),\n cancelled: Type.Optional(NullableNumber()),\n oldestAvailableAt: OptionalString(),\n due: Type.Optional(NullableNumber()),\n scheduled: Type.Optional(NullableNumber()),\n expiredLeases: Type.Optional(NullableNumber()),\n oldestDueAt: OptionalString(),\n queueLagMs: Type.Optional(NullableNumber()),\n gatewayAuthorityId: OptionalString(),\n credentialId: OptionalString(),\n principal: Type.Optional(Type.Object({ workspace: Type.String(), agent: Type.String() }, { additionalProperties: true })),\n} as const;\n\nconst DiagnosticsSchema = Type.Object(DeliveryDiagnosticsProperties, { additionalProperties: true });\n\nconst ClientDiagnosticsSchema = Type.Object({\n ...DeliveryDiagnosticsProperties,\n remoteReachable: Type.Optional(Type.Union([Type.Boolean(), Type.Null()])),\n outboxPending: OptionalNumber(),\n outboxBlocked: OptionalNumber(),\n cachedMessages: OptionalNumber(),\n lastSyncAt: OptionalString(),\n lastSyncError: OptionalString(),\n outboxDue: OptionalNumber(),\n outboxScheduled: OptionalNumber(),\n outboxLeased: OptionalNumber(),\n outboxOldestDueAt: OptionalString(),\n outboxQueueLagMs: OptionalNumber(),\n outboxOldestBlockedAt: OptionalString(),\n outboxBlockedAgeMs: Type.Optional(NullableNumber()),\n outboxBlockedMaxAttempts: OptionalNumber(),\n outboxBlockedLastError: OptionalString(),\n outboxNextRetryAt: OptionalString(),\n lastOutboundSyncAt: OptionalString(),\n lastInboundSyncAt: OptionalString(),\n lastSyncAttemptAt: OptionalString(),\n syncLoopState: Type.Optional(Type.Enum([\"disabled\", \"idle\", \"running\", \"backoff\", \"paused\", \"stopped\", \"failed\"])),\n syncLoopError: OptionalString(),\n remoteError: OptionalString(),\n migrationState: Type.Optional(Type.Enum([\"active\", \"draining\", \"retired\"])),\n migrationOperationId: OptionalString(),\n migrationLeaseExpiresAt: OptionalString(),\n}, { additionalProperties: true });\n\nconst ClientStatusSchema = Type.Object({\n status: Type.Enum([\"ok\", \"unknown\", \"degraded\", \"failed\"]),\n localHealthy: Type.Boolean(),\n connected: Type.Boolean(),\n remoteReachable: Type.Union([Type.Boolean(), Type.Null()]),\n provider: Type.Enum([\"local\", \"gateway\", \"legacy-supabase\"]),\n workspace: Type.String(),\n agent: Type.String(),\n instance: Type.Union([Type.String(), Type.Null()]),\n schemaVersion: Type.Enum([\"local-v2\", \"postgres-v2\", \"legacy-v1\"]),\n endpoint: Type.Union([Type.String(), Type.Null()]),\n database: Type.Union([Type.String(), Type.Null()]),\n cursorPath: Type.String(),\n lastCursor: Type.Union([Type.String(), Type.Null()]),\n queue: ClientDiagnosticsSchema,\n checks: Type.Array(Type.Object({\n name: Type.String(),\n status: Type.Enum([\"ok\", \"unknown\", \"degraded\", \"failed\"]),\n message: Type.String(),\n }, { additionalProperties: false })),\n}, { additionalProperties: true });\n\nconst HistoryRequestSchema = Type.Object({\n cursor: OptionalString(),\n limit: OptionalNumber({ minimum: 1, maximum: 200 }),\n types: Type.Optional(StringArray),\n mailbox: Type.Optional(Type.Enum([\"inbox\", \"sent\", \"all\"])),\n receiptState: Type.Optional(Type.Enum([\"any\", \"unread\", \"read\"])),\n includeExpired: OptionalBoolean(),\n source: OptionalString(),\n project: OptionalString(),\n since: OptionalString(),\n unacknowledgedBy: OptionalString(),\n threadId: OptionalString(),\n latest: OptionalBoolean(),\n}, { additionalProperties: false });\n\nconst MessagePageSchema = Type.Object({\n messages: Type.Array(MessageSchema),\n cursor: OptionalString(),\n source: Type.Optional(Type.Enum([\"remote\", \"cache\"])),\n stale: OptionalBoolean(),\n degraded: OptionalBoolean(),\n acknowledgements: Type.Optional(Type.Enum([\"authoritative\", \"unknown\"])),\n lastSyncedAt: OptionalString(),\n}, { additionalProperties: true });\n\nconst DeliveryPageSchema = Type.Object({ deliveries: Type.Array(DeliverySchema), cursor: OptionalString() }, { additionalProperties: true });\nconst DeliveryEventPageSchema = Type.Object({ events: Type.Array(DeliveryEventSchema), cursor: OptionalString() }, { additionalProperties: true });\nconst DeliveryIdSchema = Type.Object({ deliveryId: Type.String() }, { additionalProperties: false });\nconst LeaseSchema = Type.Object({ deliveryId: Type.String(), leaseToken: Type.String() }, { additionalProperties: false });\nconst RetryPolicySchema = Type.Object({\n maxAttempts: OptionalNumber(),\n baseDelayMs: OptionalNumber(),\n maxDelayMs: OptionalNumber(),\n jitterRatio: OptionalNumber(),\n}, { additionalProperties: false });\n\nconst NegativeAcknowledgeRequestSchema = Type.Object({\n deliveryId: Type.String(),\n leaseToken: Type.String(),\n error: Type.String(),\n disposition: Type.Optional(Type.Enum([\"retry\", \"dead\"])),\n dead: OptionalBoolean(),\n retryPolicy: Type.Optional(RetryPolicySchema),\n}, { additionalProperties: false });\n\nconst LegacyNegativeAcknowledgeRequestSchema = Type.Object({\n deliveryId: Type.String(),\n leaseToken: Type.String(),\n error: OptionalString(),\n disposition: Type.Optional(Type.Enum([\"retry\", \"dead\"])),\n dead: OptionalBoolean(),\n retryPolicy: Type.Optional(RetryPolicySchema),\n}, { additionalProperties: false });\n\nconst SyncResponseSchema = Type.Object({\n online: Type.Boolean(),\n pushed: Type.Number(),\n deduplicated: Type.Number(),\n pulled: Type.Number(),\n pending: Type.Number(),\n blocked: Type.Number(),\n cached: Type.Number(),\n cursor: Type.Optional(NullableString()),\n lastSyncedAt: Type.Optional(NullableString()),\n lastError: Type.Optional(NullableString()),\n failureRetryable: OptionalBoolean(),\n}, { additionalProperties: true });\n\nconst ClaimResponseSchema = Type.Object({\n delivery: Type.Union([DeliverySchema, Type.Null()]),\n leaseToken: OptionalString(),\n}, {\n additionalProperties: true,\n oneOf: [\n { properties: { delivery: { type: \"null\" }, leaseToken: false }, required: [\"delivery\"] },\n { properties: { delivery: DeliverySchema, leaseToken: { type: \"string\" } }, required: [\"delivery\", \"leaseToken\"] },\n ],\n});\n\nexport const AUTHORIZATION_SCOPES = [\n \"deliveries:claim\",\n \"deliveries:manage\",\n \"deliveries:read\",\n \"deliveries:settle\",\n \"gateway:metrics\",\n \"messages:read\",\n \"messages:write\",\n \"presence:read\",\n \"presence:write\",\n \"receipts:write\",\n \"status:read\",\n] as const;\n\nexport type AuthorizationScope = typeof AUTHORIZATION_SCOPES[number];\n\nexport type ContractProvider = \"local\" | \"gateway\" | \"legacy-supabase\";\nexport type ContractSurface = \"mcp\" | \"http\" | \"cli\";\nexport type OperationId =\n | \"capabilities\" | \"status\" | \"client_status\" | \"gateway_metrics\" | \"publish_message\" | \"history\"\n | \"issue_endpoint_migration_challenge\" | \"consume_endpoint_migration_challenge\"\n | \"record_receipt\" | \"claim_delivery\" | \"list_deliveries\" | \"list_delivery_events\"\n | \"cancel_delivery\" | \"requeue_delivery\" | \"extend_delivery\" | \"acknowledge_delivery\"\n | \"negative_acknowledge_delivery\" | \"heartbeat\" | \"presence\" | \"sync\";\n\nexport interface HttpContract {\n method: \"GET\" | \"POST\";\n path: string;\n successStatus?: 200 | 201;\n responseContentType?: \"application/json\" | \"text/plain\";\n queryAliases?: Readonly<Record<string, readonly string[]>>;\n}\n\nexport interface CliContract {\n command: string;\n aliases?: readonly string[];\n options: readonly string[];\n response?: TSchema;\n variants?: readonly CliCompatibilityVariant[];\n}\n\nexport interface CliCompatibilityVariant {\n command: string;\n condition: { kind: \"always\" } | { kind: \"option-present\"; option: string };\n routesTo: OperationId;\n options: readonly string[];\n response: TSchema;\n}\n\nexport interface OperationContract {\n id: OperationId;\n summary: string;\n request: TSchema;\n response: TSchema;\n scopes: readonly AuthorizationScope[];\n providers: readonly ContractProvider[];\n mcp?: { name: string };\n http?: HttpContract;\n cli?: CliContract;\n}\n\nconst ALL_PROVIDERS = [\"local\", \"gateway\", \"legacy-supabase\"] as const;\nconst DELIVERY_PROVIDERS = [\"local\", \"gateway\"] as const;\nconst GATEWAY_PROVIDER = [\"gateway\"] as const;\nconst operation = (entry: OperationContract): OperationContract => entry;\nconst HistoryCliOptions = [\"cursor\", \"limit\", \"type\", \"category\", \"mailbox\", \"receipt-state\", \"source\", \"project\", \"since\", \"unacked-by\", \"thread-id\", \"latest\"] as const;\nconst LegacyGetRowSchema = Type.Object({\n id: Type.Union([Type.String(), Type.Number()]),\n source: Type.String(),\n category: Type.String(),\n content: Type.String(),\n priority: Type.Enum([\"info\", \"high\", \"urgent\"]),\n project: NullableString(),\n metadata: Type.Any(),\n created_at: Type.String(),\n}, { additionalProperties: false });\nconst ReceiptCliResponseSchema = Type.Object({\n acknowledged: Type.Number(),\n agent: Type.String(),\n}, { additionalProperties: true });\n\nexport const operations: readonly OperationContract[] = [\n 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\"]), grantedScopes: Type.Optional(StringArray), 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: [] } }),\n operation({ id: \"status\", summary: \"Read gateway delivery diagnostics.\", request: Empty, response: DiagnosticsSchema, scopes: [\"status:read\"], providers: ALL_PROVIDERS, http: { method: \"GET\", path: \"/v2/status\" } }),\n operation({ id: \"issue_endpoint_migration_challenge\", summary: \"Issue a short-lived endpoint migration challenge commitment.\", request: Type.Object({ challenge: Type.String({ pattern: \"^[0-9a-f]{64}$\" }), expectedGatewayAuthorityId: Type.String({ pattern: UUID_PATTERN }), verifierCredentialId: Type.String({ pattern: UUID_PATTERN }) }, { additionalProperties: false }), response: Type.Object({ gatewayAuthorityId: Type.String(), issuerCredentialId: Type.String(), verifierCredentialId: Type.String(), expiresAt: Type.String() }, { additionalProperties: false }), scopes: [], providers: GATEWAY_PROVIDER, http: { method: \"POST\", path: \"/v2/endpoint-migration-challenges\" } }),\n operation({ id: \"consume_endpoint_migration_challenge\", summary: \"Consume a short-lived endpoint migration challenge commitment.\", request: Type.Object({ challenge: Type.String({ pattern: \"^[0-9a-f]{64}$\" }), expectedGatewayAuthorityId: Type.String({ pattern: UUID_PATTERN }), issuerCredentialId: Type.String({ pattern: UUID_PATTERN }) }, { additionalProperties: false }), response: Type.Object({ gatewayAuthorityId: Type.String(), issuerCredentialId: Type.String(), verifierCredentialId: Type.String(), expiresAt: Type.Union([Type.String(), Type.Null()]), consumed: Type.Boolean() }, { additionalProperties: false }), scopes: [], providers: GATEWAY_PROVIDER, http: { method: \"POST\", path: \"/v2/endpoint-migration-challenges/consume\" } }),\n 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: [] } }),\n 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\" } }),\n 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\"] } }),\n 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) }] } }),\n 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 }] } }),\n 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()]) } }),\n 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\"] } }),\n 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\"] } }),\n 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()]) } }),\n 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()]) } }),\n 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()]) } }),\n 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()]) } }),\n 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()]) } }),\n operation({ id: \"heartbeat\", summary: \"Publish a leased runtime presence record.\", request: Type.Object({ leaseMs: OptionalNumber({ minimum: 1000, maximum: 900000 }), 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\"] } }),\n 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: [] } }),\n 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\"] } }),\n];\n\nconst byId = new Map(operations.map((entry) => [entry.id, entry]));\n\nexport class ContractValidationError extends Error {\n readonly code = \"invalid_input\";\n readonly status = 400;\n constructor(readonly operation: string, readonly issues: readonly { path: string; message: string }[]) {\n super(`Request does not match the ${operation} schema`);\n }\n}\n\nexport class ContractResponseError extends Error {\n readonly code = \"protocol_mismatch\";\n readonly status = 502;\n constructor(readonly operation: string, readonly issues: readonly { path: string; message: string }[]) {\n super(`Response does not match the ${operation} schema`);\n }\n}\n\nfunction issues(schema: TSchema, value: unknown): readonly { path: string; message: string }[] {\n return [...Errors(schema, value)].map((entry) => ({ path: entry.instancePath || \"/\", message: entry.message }));\n}\n\nexport function operationContract(operationId: string): OperationContract {\n const contract = byId.get(operationId as OperationId);\n if (!contract) throw new Error(`Unknown operation contract: ${operationId}`);\n return contract;\n}\n\nexport function validateRequest(operationId: string, value: unknown): Record<string, unknown> {\n const contract = operationContract(operationId);\n if (!Check(contract.request, value)) throw new ContractValidationError(operationId, issues(contract.request, value));\n return value as Record<string, unknown>;\n}\n\nexport function validateRequestForProtocol(operationId: string, value: unknown, protocolVersion: string): Record<string, unknown> {\n if (protocolVersion === LEGACY_PROTOCOL_VERSION) {\n if (operationId === \"publish_message\") {\n if (!Check(LegacyMessageDraftSchema, value)) throw new ContractValidationError(operationId, issues(LegacyMessageDraftSchema, value));\n return value as Record<string, unknown>;\n }\n if ([\"list_deliveries\", \"list_delivery_events\", \"cancel_delivery\", \"requeue_delivery\", \"capabilities\"].includes(operationId)) {\n throw new ContractValidationError(operationId, [{ path: \"/\", message: `Operation is not supported by protocol ${LEGACY_PROTOCOL_VERSION}` }]);\n }\n if (operationId === \"history\" && value && typeof value === \"object\") {\n const unsupported = [\"mailbox\", \"receiptState\", \"project\"].find((field) => (value as Record<string, unknown>)[field] !== undefined);\n if (unsupported) throw new ContractValidationError(operationId, [{ path: `/${unsupported}`, message: `Field is not supported by protocol ${LEGACY_PROTOCOL_VERSION}` }]);\n }\n }\n if (operationId !== \"negative_acknowledge_delivery\" || protocolVersion !== LEGACY_PROTOCOL_VERSION) {\n return validateRequest(operationId, value);\n }\n if (!Check(LegacyNegativeAcknowledgeRequestSchema, value)) {\n throw new ContractValidationError(operationId, issues(LegacyNegativeAcknowledgeRequestSchema, value));\n }\n return value as Record<string, unknown>;\n}\n\nexport function parseResponse(operationId: string, value: unknown): unknown {\n const contract = operationContract(operationId);\n const serialized = JSON.stringify(value);\n const wireValue = serialized === undefined ? value : JSON.parse(serialized);\n if (!Check(contract.response, wireValue)) throw new ContractResponseError(operationId, issues(contract.response, wireValue));\n return wireValue;\n}\n\nexport function parseResponseForProtocol(operationId: string, value: unknown, protocolVersion: string): unknown {\n if (protocolVersion !== LEGACY_PROTOCOL_VERSION) return parseResponse(operationId, value);\n let schema: TSchema | undefined;\n let normalized = value;\n if (operationId === \"publish_message\") schema = Type.Object({ created: Type.Boolean(), message: LegacyMessageSchema }, { additionalProperties: true });\n else if (operationId === \"history\") schema = Type.Object({ messages: Type.Array(LegacyMessageSchema), cursor: OptionalString() }, { additionalProperties: true });\n else if (operationId === \"claim_delivery\") {\n schema = Type.Union([Type.Object({ delivery: LegacyDeliverySchema, leaseToken: Type.String() }, { additionalProperties: true }), Type.Null()]);\n normalized = value === null ? { delivery: null } : value;\n } else if ([\"extend_delivery\", \"acknowledge_delivery\", \"negative_acknowledge_delivery\"].includes(operationId)) {\n schema = LegacyDeliverySchema;\n normalized = { delivery: value };\n }\n if (!schema) return parseResponse(operationId, value);\n if (!Check(schema, value)) throw new ContractResponseError(operationId, issues(schema, value));\n return normalized;\n}\n\nexport function parseCliResponse(\n operationId: string,\n value: unknown,\n invocation?: { command: string; optionNames?: readonly string[] },\n): unknown {\n const contract = operationContract(operationId);\n const optionNames = new Set(invocation?.optionNames ?? []);\n const variant = contract.cli?.variants?.find((entry) =>\n entry.command === invocation?.command && cliVariantMatches(entry, optionNames));\n const schema = variant?.response ?? contract.cli?.response ?? contract.response;\n const serialized = JSON.stringify(value);\n const wireValue = serialized === undefined ? value : JSON.parse(serialized);\n if (!Check(schema, wireValue)) throw new ContractResponseError(operationId, issues(schema, wireValue));\n return wireValue;\n}\n\nexport function availableOperations(context: { surface: ContractSurface; provider: ContractProvider }): readonly OperationContract[] {\n return operations.filter((entry) => entry.providers.includes(context.provider) && Boolean(entry[context.surface]));\n}\n\nexport function operationForMcp(name: string, provider: ContractProvider): OperationContract | undefined {\n return availableOperations({ surface: \"mcp\", provider }).find((entry) => entry.mcp?.name === name);\n}\n\nexport function operationForHttp(method: string, path: string): OperationContract | undefined {\n return availableOperations({ surface: \"http\", provider: \"gateway\" }).find((entry) => entry.http?.method === method && entry.http.path === path);\n}\n\nfunction cliVariantMatches(\n variant: CliCompatibilityVariant,\n optionNames: ReadonlySet<string>,\n): boolean {\n return variant.condition.kind === \"always\" || optionNames.has(variant.condition.option);\n}\n\nexport function operationForCli(\n command: string,\n provider: ContractProvider,\n optionNames: readonly string[] = [],\n): OperationContract | undefined {\n const selectedOptions = new Set(optionNames);\n return availableOperations({ surface: \"cli\", provider }).find((entry) =>\n entry.cli?.command === command ||\n entry.cli?.aliases?.includes(command) ||\n entry.cli?.variants?.some((variant) =>\n variant.command === command && cliVariantMatches(variant, selectedOptions)));\n}\n\nexport function capabilityDocument(context: { surface: ContractSurface; provider: ContractProvider; selectedProtocolVersion?: string; requestAuthority?: boolean; rowIsolation?: boolean } = { surface: \"http\", provider: \"gateway\" }) {\n const selectedProtocolVersion = context.selectedProtocolVersion ?? PROTOCOL_VERSION;\n return {\n protocolVersion: selectedProtocolVersion,\n currentProtocolVersion: PROTOCOL_VERSION,\n selectedProtocolVersion,\n supportedProtocolVersions: [...SUPPORTED_PROTOCOL_VERSIONS],\n scopeEnforcement: context.provider === \"gateway\" ? SCOPE_ENFORCEMENT : false,\n requestAuthority: context.provider === \"gateway\" && context.requestAuthority === true,\n rowIsolation: context.provider === \"gateway\" && context.requestAuthority === true && context.rowIsolation === true,\n authorizationModel: context.provider === \"gateway\"\n ? \"scoped-credential\"\n : context.provider === \"local\"\n ? \"process-identity\"\n : \"legacy-key\",\n surface: context.surface,\n provider: context.provider,\n operations: availableOperations(context).map(({ request: _request, response, providers: _providers, scopes, cli, ...entry }) => ({\n ...entry,\n ...(cli ? {\n cli: {\n command: cli.command,\n ...(cli.aliases ? { aliases: cli.aliases } : {}),\n options: cli.options,\n outputSchema: cli.response ?? response,\n ...(cli.variants ? {\n variants: cli.variants.map((variant) => ({\n command: variant.command,\n condition: variant.condition,\n routesTo: variant.routesTo,\n options: variant.options,\n outputSchema: variant.response,\n })),\n } : {}),\n },\n } : {}),\n requiredScopes: [...scopes],\n })),\n };\n}\n\nexport function negotiateProtocolVersion(value: string | string[] | undefined): string {\n const requested = Array.isArray(value) ? value[0] : value;\n if (requested === undefined || requested.trim() === \"\") return LEGACY_PROTOCOL_VERSION;\n if ((SUPPORTED_PROTOCOL_VERSIONS as readonly string[]).includes(requested.trim())) return requested.trim();\n const error = new Error(\"Unsupported Agent Bridge protocol version\") as Error & { status: number; code: string; supported: string };\n error.status = 426;\n error.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AAK,IAAI,MAAM,CAAC,IAAI;AACpD,MAAI,cAAc,UAAa,UAAU,KAAK,MAAM,GAAI,QAAO;AAC/D,MAAK,4BAAkD,SAAS,UAAU,KAAK,CAAC,EAAG,QAAO,UAAU,KAAK;AACzG,QAAM,QAAQ,IAAI,MAAM,2CAA2C;AACnE,QAAM,SAAS;AACf,QAAM,OAAO;AACb,QAAM,YAAY;AAClB,QAAM;AACR;","names":["operation","issues"]}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
SUPPORTED_PROTOCOL_HEADER,
|
|
10
10
|
SUPPORTED_PROTOCOL_VERSIONS,
|
|
11
11
|
parseResponse
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IHZFI7TH.js";
|
|
13
13
|
import {
|
|
14
14
|
cursorScope,
|
|
15
15
|
decodeCursor,
|
|
@@ -581,4 +581,4 @@ export {
|
|
|
581
581
|
BridgeHttpError,
|
|
582
582
|
HttpBridgeStore
|
|
583
583
|
};
|
|
584
|
-
//# sourceMappingURL=chunk-
|
|
584
|
+
//# sourceMappingURL=chunk-LAHNQZDN.js.map
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HttpBridgeStore,
|
|
4
4
|
LegacySupabaseRestStore
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LAHNQZDN.js";
|
|
6
6
|
import {
|
|
7
7
|
SQLiteEdgeStore,
|
|
8
8
|
SyncingBridgeStore
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SV3SVBYS.js";
|
|
10
10
|
import {
|
|
11
11
|
SQLiteBridgeStore
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DQOZJJZ2.js";
|
|
13
13
|
import {
|
|
14
14
|
securePrivatePath
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-GTK4KOED.js";
|
|
16
16
|
import {
|
|
17
17
|
BridgeService
|
|
18
18
|
} from "./chunk-4VB44KJU.js";
|
|
@@ -35,7 +35,10 @@ function createStore(config, options = {}) {
|
|
|
35
35
|
prepareStoreDirectory(config.edgeDatabasePath);
|
|
36
36
|
const remote = new HttpBridgeStore({ baseUrl: config.url, token: config.credential, principal: config.principal });
|
|
37
37
|
const edge = new SQLiteEdgeStore(config.edgeDatabasePath, { endpoint: config.url, principal: config.principal });
|
|
38
|
-
return new SyncingBridgeStore(edge, remote, config.principal, {
|
|
38
|
+
return new SyncingBridgeStore(edge, remote, config.principal, {
|
|
39
|
+
autoSync: options.autoSync,
|
|
40
|
+
edgeDrainLease: options.edgeDrainLease
|
|
41
|
+
});
|
|
39
42
|
}
|
|
40
43
|
return new LegacySupabaseRestStore(config.url, config.credential);
|
|
41
44
|
}
|
|
@@ -51,4 +54,4 @@ export {
|
|
|
51
54
|
createStore,
|
|
52
55
|
createClientRuntime
|
|
53
56
|
};
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-MCKKVNCE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client-runtime.ts"],"sourcesContent":["import { existsSync, mkdirSync } from \"node:fs\";\nimport { basename, dirname } from \"node:path\";\nimport { BridgeService } from \"./bridge-service.js\";\nimport type { BridgeStore } from \"./bridge-store.js\";\nimport { HttpBridgeStore } from \"./http-bridge-store.js\";\nimport { type EdgeDrainLease, SQLiteEdgeStore } from \"./sqlite-edge-store.js\";\nimport { SyncingBridgeStore } from \"./syncing-bridge-store.js\";\nimport { LegacySupabaseRestStore } from \"./legacy-supabase-store.js\";\nimport { SQLiteBridgeStore } from \"./sqlite-bridge-store.js\";\nimport type { ClientConfig } from \"./client-config.js\";\nimport { securePrivatePath } from \"./private-path.js\";\n\nexport interface ClientRuntime { config: ClientConfig; store: BridgeStore; service: BridgeService; close(): Promise<void>; }\nexport interface ClientRuntimeOptions {\n autoSync?: boolean;\n initializationMode?: \"active\" | \"passive\";\n edgeDrainLease?: EdgeDrainLease;\n}\n\nfunction prepareStoreDirectory(path: string): void {\n const directory = dirname(path);\n const existed = existsSync(directory);\n mkdirSync(directory, { recursive: true, mode: 0o700 });\n if (!existed || basename(directory) === \".agent-bridge\") securePrivatePath(directory, \"directory\");\n}\n\nexport function createStore(config: ClientConfig, options: ClientRuntimeOptions = {}): BridgeStore {\n if (config.provider === \"local\") {\n if (config.databasePath !== \":memory:\") prepareStoreDirectory(config.databasePath);\n return new SQLiteBridgeStore(config.databasePath);\n }\n if (config.provider === \"gateway\") {\n prepareStoreDirectory(config.edgeDatabasePath);\n const remote = new HttpBridgeStore({ baseUrl: config.url!, token: config.credential!, principal: config.principal });\n const edge = new SQLiteEdgeStore(config.edgeDatabasePath, { endpoint: config.url!, principal: config.principal });\n return new SyncingBridgeStore(edge, remote, config.principal, {\n autoSync: options.autoSync,\n edgeDrainLease: options.edgeDrainLease,\n });\n }\n return new LegacySupabaseRestStore(config.url!, config.credential!);\n}\n\nexport async function createClientRuntime(config: ClientConfig, options: ClientRuntimeOptions = {}): Promise<ClientRuntime> {\n const store = createStore(config, options);\n await store.initialize({ mode: options.initializationMode });\n return { config, store, service: new BridgeService(store), close: async () => { await store.close?.(); } };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,iBAAiB;AACtC,SAAS,UAAU,eAAe;AAkBlC,SAAS,sBAAsB,MAAoB;AACjD,QAAM,YAAY,QAAQ,IAAI;AAC9B,QAAM,UAAU,WAAW,SAAS;AACpC,YAAU,WAAW,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AACrD,MAAI,CAAC,WAAW,SAAS,SAAS,MAAM,gBAAiB,mBAAkB,WAAW,WAAW;AACnG;AAEO,SAAS,YAAY,QAAsB,UAAgC,CAAC,GAAgB;AACjG,MAAI,OAAO,aAAa,SAAS;AAC/B,QAAI,OAAO,iBAAiB,WAAY,uBAAsB,OAAO,YAAY;AACjF,WAAO,IAAI,kBAAkB,OAAO,YAAY;AAAA,EAClD;AACA,MAAI,OAAO,aAAa,WAAW;AACjC,0BAAsB,OAAO,gBAAgB;AAC7C,UAAM,SAAS,IAAI,gBAAgB,EAAE,SAAS,OAAO,KAAM,OAAO,OAAO,YAAa,WAAW,OAAO,UAAU,CAAC;AACnH,UAAM,OAAO,IAAI,gBAAgB,OAAO,kBAAkB,EAAE,UAAU,OAAO,KAAM,WAAW,OAAO,UAAU,CAAC;AAChH,WAAO,IAAI,mBAAmB,MAAM,QAAQ,OAAO,WAAW;AAAA,MAC5D,UAAU,QAAQ;AAAA,MAClB,gBAAgB,QAAQ;AAAA,IAC1B,CAAC;AAAA,EACH;AACA,SAAO,IAAI,wBAAwB,OAAO,KAAM,OAAO,UAAW;AACpE;AAEA,eAAsB,oBAAoB,QAAsB,UAAgC,CAAC,GAA2B;AAC1H,QAAM,QAAQ,YAAY,QAAQ,OAAO;AACzC,QAAM,MAAM,WAAW,EAAE,MAAM,QAAQ,mBAAmB,CAAC;AAC3D,SAAO,EAAE,QAAQ,OAAO,SAAS,IAAI,cAAc,KAAK,GAAG,OAAO,YAAY;AAAE,UAAM,MAAM,QAAQ;AAAA,EAAG,EAAE;AAC3G;","names":[]}
|
|
@@ -10,18 +10,18 @@ import {
|
|
|
10
10
|
isSupportedLocalSqliteSchemaContract,
|
|
11
11
|
sqliteSchemaContractHash,
|
|
12
12
|
verifySqliteHealth
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DQOZJJZ2.js";
|
|
14
14
|
import {
|
|
15
15
|
preparePrivateFileLocation,
|
|
16
16
|
preparePrivateSqliteLocation,
|
|
17
17
|
securePrivatePath,
|
|
18
18
|
securePrivateSqliteFiles,
|
|
19
19
|
verifyPrivatePathAccess
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GTK4KOED.js";
|
|
21
21
|
import {
|
|
22
22
|
NATIVE_DR_ADVISORY_LOCK_KEY,
|
|
23
23
|
rowIsolationReady
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6BTJE6D4.js";
|
|
25
25
|
|
|
26
26
|
// src/native-dr-bundle.ts
|
|
27
27
|
import { createHash } from "crypto";
|
|
@@ -88,12 +88,19 @@ var POSTGRES_SCHEMA_FIELDS = [
|
|
|
88
88
|
"claimedDeliveryCount",
|
|
89
89
|
"readinessAttestations"
|
|
90
90
|
];
|
|
91
|
-
var
|
|
91
|
+
var POSTGRES_LEGACY_EXCLUDED_DATA = [
|
|
92
92
|
"agent_bridge.agent_instances",
|
|
93
93
|
"agent_bridge.rate_limit_buckets",
|
|
94
94
|
"agent_bridge.request_authorities",
|
|
95
95
|
"agent_bridge.archive_transaction_authorizations"
|
|
96
96
|
];
|
|
97
|
+
var POSTGRES_EXCLUDED_DATA = [
|
|
98
|
+
...POSTGRES_LEGACY_EXCLUDED_DATA,
|
|
99
|
+
"agent_bridge.endpoint_migration_challenges"
|
|
100
|
+
];
|
|
101
|
+
function postgresExcludedDataForSchemaVersion(schemaVersion) {
|
|
102
|
+
return schemaVersion <= 17 ? POSTGRES_LEGACY_EXCLUDED_DATA : POSTGRES_EXCLUDED_DATA;
|
|
103
|
+
}
|
|
97
104
|
function validateSchema(kind, value) {
|
|
98
105
|
if (kind === "sqlite") {
|
|
99
106
|
const schema2 = exactObject(value, ["applicationId", "schemaContractSha256", "userVersion"], "DR SQLite schema");
|
|
@@ -106,7 +113,7 @@ function validateSchema(kind, value) {
|
|
|
106
113
|
}
|
|
107
114
|
assertString(schema.databaseName, "DR database name");
|
|
108
115
|
assertString(schema.pgDumpVersion, "DR pg_dump version");
|
|
109
|
-
if (!Array.isArray(schema.migrations) || schema.migrations.length > 1e4) throw new NativeDrBundleError("DR PostgreSQL migration inventory is invalid");
|
|
116
|
+
if (!Array.isArray(schema.migrations) || schema.migrations.length === 0 || schema.migrations.length > 1e4) throw new NativeDrBundleError("DR PostgreSQL migration inventory is invalid");
|
|
110
117
|
let priorVersion = 0;
|
|
111
118
|
for (const raw of schema.migrations) {
|
|
112
119
|
const migration = exactObject(raw, ["checksum", "name", "version"], "DR migration");
|
|
@@ -115,13 +122,17 @@ function validateSchema(kind, value) {
|
|
|
115
122
|
}
|
|
116
123
|
priorVersion = Number(migration.version);
|
|
117
124
|
}
|
|
125
|
+
if (priorVersion !== Number(schema.schemaVersion)) {
|
|
126
|
+
throw new NativeDrBundleError("DR PostgreSQL schema version does not match migrations");
|
|
127
|
+
}
|
|
118
128
|
if (!schema.tableCounts || typeof schema.tableCounts !== "object" || Array.isArray(schema.tableCounts)) throw new NativeDrBundleError("DR PostgreSQL table counts are invalid");
|
|
119
129
|
for (const [table, count] of Object.entries(schema.tableCounts)) {
|
|
120
130
|
if (!/^[a-z_][a-z0-9_]*\.[a-z_][a-z0-9_]*$/.test(table) || typeof count !== "string" || !/^(0|[1-9][0-9]*)$/.test(count)) {
|
|
121
131
|
throw new NativeDrBundleError("DR PostgreSQL table counts are invalid");
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
|
-
|
|
134
|
+
const excludedData = postgresExcludedDataForSchemaVersion(Number(schema.schemaVersion));
|
|
135
|
+
if (!Array.isArray(schema.excludedDataTables) || schema.excludedDataTables.length !== excludedData.length || schema.excludedDataTables.some((name, index) => name !== excludedData[index])) {
|
|
125
136
|
throw new NativeDrBundleError("DR PostgreSQL excluded-data inventory is invalid");
|
|
126
137
|
}
|
|
127
138
|
const readiness = exactObject(schema.readinessAttestations, [
|
|
@@ -453,12 +464,19 @@ function createBoundedToolOutput(maximumBytes) {
|
|
|
453
464
|
var POSTGRES_NATIVE_DR_ROLE_SCHEMA = "agent-bridge.postgres-native-dr-roles";
|
|
454
465
|
var POSTGRES_NATIVE_DR_ROLE_VERSION = 1;
|
|
455
466
|
var POSTGRES_NATIVE_DR_SERVICE = "agent_bridge_dr";
|
|
456
|
-
var
|
|
467
|
+
var POSTGRES_NATIVE_DR_LEGACY_EXCLUDED_DATA_TABLES = [
|
|
457
468
|
"agent_bridge.agent_instances",
|
|
458
469
|
"agent_bridge.rate_limit_buckets",
|
|
459
470
|
"agent_bridge.request_authorities",
|
|
460
471
|
"agent_bridge.archive_transaction_authorizations"
|
|
461
472
|
];
|
|
473
|
+
var POSTGRES_NATIVE_DR_EXCLUDED_DATA_TABLES = [
|
|
474
|
+
...POSTGRES_NATIVE_DR_LEGACY_EXCLUDED_DATA_TABLES,
|
|
475
|
+
"agent_bridge.endpoint_migration_challenges"
|
|
476
|
+
];
|
|
477
|
+
function excludedDataTablesForSchemaVersion(schemaVersion) {
|
|
478
|
+
return schemaVersion <= 17 ? POSTGRES_NATIVE_DR_LEGACY_EXCLUDED_DATA_TABLES : POSTGRES_NATIVE_DR_EXCLUDED_DATA_TABLES;
|
|
479
|
+
}
|
|
462
480
|
var SSL_PARAMETERS = /* @__PURE__ */ new Set([
|
|
463
481
|
"channel_binding",
|
|
464
482
|
"sslcert",
|
|
@@ -579,6 +597,9 @@ function createPostgresDrLibpqFiles(connectionUrl, directory) {
|
|
|
579
597
|
};
|
|
580
598
|
}
|
|
581
599
|
function buildPgDumpArgs(outputPath, snapshot, serviceName = POSTGRES_NATIVE_DR_SERVICE) {
|
|
600
|
+
return buildPgDumpArgsForTables(outputPath, snapshot, serviceName, POSTGRES_NATIVE_DR_EXCLUDED_DATA_TABLES);
|
|
601
|
+
}
|
|
602
|
+
function buildPgDumpArgsForTables(outputPath, snapshot, serviceName, excludedDataTables) {
|
|
582
603
|
assertSafeText(outputPath, "PostgreSQL dump path");
|
|
583
604
|
assertSafeText(snapshot, "PostgreSQL snapshot");
|
|
584
605
|
assertSafeText(serviceName, "PostgreSQL service name");
|
|
@@ -588,7 +609,7 @@ function buildPgDumpArgs(outputPath, snapshot, serviceName = POSTGRES_NATIVE_DR_
|
|
|
588
609
|
"--schema=agent_bridge",
|
|
589
610
|
"--no-tablespaces",
|
|
590
611
|
`--snapshot=${snapshot}`,
|
|
591
|
-
...
|
|
612
|
+
...excludedDataTables.map((table) => `--exclude-table-data=${table}`),
|
|
592
613
|
`--dbname=service=${serviceName}`
|
|
593
614
|
];
|
|
594
615
|
}
|
|
@@ -661,6 +682,29 @@ var POSTGRES_TOC_DESCRIPTORS = [
|
|
|
661
682
|
"ACL"
|
|
662
683
|
];
|
|
663
684
|
var POSTGRES_TOC_MAX_BYTES = 16 * 1024 * 1024;
|
|
685
|
+
function parsePostgresDumpTocBody(entry) {
|
|
686
|
+
let cursor = 0;
|
|
687
|
+
const readDigits = () => {
|
|
688
|
+
const start = cursor;
|
|
689
|
+
while (cursor < entry.length) {
|
|
690
|
+
const code = entry.charCodeAt(cursor);
|
|
691
|
+
if (code < 48 || code > 57) break;
|
|
692
|
+
cursor += 1;
|
|
693
|
+
}
|
|
694
|
+
return cursor > start;
|
|
695
|
+
};
|
|
696
|
+
const readSeparator = () => {
|
|
697
|
+
const start = cursor;
|
|
698
|
+
while (entry[cursor] === " " || entry[cursor] === " ") cursor += 1;
|
|
699
|
+
return cursor > start;
|
|
700
|
+
};
|
|
701
|
+
if (!readDigits() || entry[cursor] !== ";") return void 0;
|
|
702
|
+
cursor += 1;
|
|
703
|
+
if (!readSeparator() || !readDigits() || !readSeparator() || !readDigits() || !readSeparator()) {
|
|
704
|
+
return void 0;
|
|
705
|
+
}
|
|
706
|
+
return cursor < entry.length ? entry.slice(cursor) : void 0;
|
|
707
|
+
}
|
|
664
708
|
function validatePostgresDumpToc(text) {
|
|
665
709
|
if (Buffer.byteLength(text, "utf8") > POSTGRES_TOC_MAX_BYTES) {
|
|
666
710
|
throw new PostgresNativeDrError("PG_DUMP_TOC_INVALID", "PostgreSQL dump table of contents exceeds 16 MiB");
|
|
@@ -668,9 +712,8 @@ function validatePostgresDumpToc(text) {
|
|
|
668
712
|
const entries = text.split(/\r?\n/u).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith(";"));
|
|
669
713
|
if (entries.length === 0) throw new PostgresNativeDrError("PG_DUMP_TOC_INVALID", "PostgreSQL dump table of contents is empty");
|
|
670
714
|
for (const entry of entries) {
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
673
|
-
const body = match[1];
|
|
715
|
+
const body = parsePostgresDumpTocBody(entry);
|
|
716
|
+
if (body === void 0) throw new PostgresNativeDrError("PG_DUMP_TOC_INVALID", "PostgreSQL dump table of contents has an invalid record");
|
|
674
717
|
const descriptor = POSTGRES_TOC_DESCRIPTORS.find((candidate) => body.startsWith(`${candidate} `));
|
|
675
718
|
if (!descriptor) throw new PostgresNativeDrError("PG_DUMP_TOC_OUT_OF_SCOPE", "PostgreSQL dump contains an unsupported object kind");
|
|
676
719
|
const remainder = body.slice(descriptor.length + 1).split(/\s+/u);
|
|
@@ -1350,6 +1393,7 @@ async function collectSnapshotMetadata(client, checkRowReady) {
|
|
|
1350
1393
|
}
|
|
1351
1394
|
}
|
|
1352
1395
|
if (migrations.length === 0) throw new PostgresNativeDrError("SOURCE_SCHEMA_EMPTY", "source has no Agent Bridge migrations");
|
|
1396
|
+
const schemaVersion = Math.max(...migrations.map((migration) => migration.version));
|
|
1353
1397
|
const tableRows = await client.query(`
|
|
1354
1398
|
SELECT table_name AS "tableName" FROM information_schema.tables
|
|
1355
1399
|
WHERE table_schema='agent_bridge' AND table_type='BASE TABLE' ORDER BY table_name`);
|
|
@@ -1380,7 +1424,8 @@ async function collectSnapshotMetadata(client, checkRowReady) {
|
|
|
1380
1424
|
agent_bridge.portable_archive_attestation_definition() AS "portableArchiveDefinition"`);
|
|
1381
1425
|
const ready = readiness.rows[0];
|
|
1382
1426
|
const rowReady = await checkRowReady(client);
|
|
1383
|
-
|
|
1427
|
+
const authorityReady = await gatewayAuthorityReady(client, schemaVersion);
|
|
1428
|
+
if (!ready?.security || !rowReady || !ready.ownerControl || !ready.portableArchive || !authorityReady || typeof ready.securityDefinition !== "string" || typeof ready.rowIsolationDefinition !== "string" || typeof ready.ownerControlDefinition !== "string" || typeof ready.portableArchiveDefinition !== "string") {
|
|
1384
1429
|
throw new PostgresNativeDrError("SOURCE_NOT_READY", "source PostgreSQL schema failed readiness attestation");
|
|
1385
1430
|
}
|
|
1386
1431
|
return {
|
|
@@ -1397,6 +1442,105 @@ async function collectSnapshotMetadata(client, checkRowReady) {
|
|
|
1397
1442
|
}
|
|
1398
1443
|
};
|
|
1399
1444
|
}
|
|
1445
|
+
async function gatewayAuthorityReady(client, schemaVersion) {
|
|
1446
|
+
if (schemaVersion <= 16) return true;
|
|
1447
|
+
const result = await client.query(`
|
|
1448
|
+
WITH names AS (
|
|
1449
|
+
SELECT ('agent_bridge_runtime_' || substr(md5(current_database()),1,16))::name AS runtime_role,
|
|
1450
|
+
(SELECT nspowner FROM pg_catalog.pg_namespace WHERE nspname='agent_bridge') AS schema_owner
|
|
1451
|
+
) SELECT
|
|
1452
|
+
agent_bridge.gateway_authority_ready()
|
|
1453
|
+
AND EXISTS (
|
|
1454
|
+
SELECT 1
|
|
1455
|
+
FROM pg_catalog.pg_class relation
|
|
1456
|
+
JOIN pg_catalog.pg_namespace namespace ON namespace.oid=relation.relnamespace
|
|
1457
|
+
WHERE namespace.nspname='agent_bridge' AND relation.relname='gateway_authority'
|
|
1458
|
+
AND relation.relkind='r' AND relation.relowner=(SELECT schema_owner FROM names)
|
|
1459
|
+
AND NOT relation.relrowsecurity AND NOT relation.relforcerowsecurity
|
|
1460
|
+
)
|
|
1461
|
+
AND EXISTS (
|
|
1462
|
+
SELECT 1 FROM pg_catalog.pg_constraint table_constraint
|
|
1463
|
+
WHERE table_constraint.conrelid='agent_bridge.gateway_authority'::regclass
|
|
1464
|
+
AND table_constraint.conname='gateway_authority_singleton'
|
|
1465
|
+
AND table_constraint.contype='p'
|
|
1466
|
+
AND table_constraint.conkey::smallint[]=ARRAY[(SELECT attribute.attnum FROM pg_catalog.pg_attribute attribute
|
|
1467
|
+
WHERE attribute.attrelid='agent_bridge.gateway_authority'::regclass
|
|
1468
|
+
AND attribute.attname='singleton' AND attribute.attnum>0 AND NOT attribute.attisdropped)]
|
|
1469
|
+
)
|
|
1470
|
+
AND EXISTS (
|
|
1471
|
+
SELECT 1 FROM pg_catalog.pg_constraint table_constraint
|
|
1472
|
+
WHERE table_constraint.conrelid='agent_bridge.gateway_authority'::regclass
|
|
1473
|
+
AND table_constraint.conname='gateway_authority_singleton_true'
|
|
1474
|
+
AND table_constraint.contype='c'
|
|
1475
|
+
AND regexp_replace(
|
|
1476
|
+
pg_get_expr(table_constraint.conbin,table_constraint.conrelid),'[[:space:]()]','','g'
|
|
1477
|
+
)='singleton'
|
|
1478
|
+
)
|
|
1479
|
+
AND EXISTS (
|
|
1480
|
+
SELECT 1 FROM pg_catalog.pg_constraint table_constraint
|
|
1481
|
+
WHERE table_constraint.conrelid='agent_bridge.gateway_authority'::regclass
|
|
1482
|
+
AND table_constraint.conname='gateway_authority_id_unique'
|
|
1483
|
+
AND table_constraint.contype='u'
|
|
1484
|
+
AND table_constraint.conkey::smallint[]=ARRAY[(SELECT attribute.attnum FROM pg_catalog.pg_attribute attribute
|
|
1485
|
+
WHERE attribute.attrelid='agent_bridge.gateway_authority'::regclass
|
|
1486
|
+
AND attribute.attname='authority_id' AND attribute.attnum>0 AND NOT attribute.attisdropped)]
|
|
1487
|
+
)
|
|
1488
|
+
AND EXISTS (
|
|
1489
|
+
SELECT 1
|
|
1490
|
+
FROM pg_catalog.pg_trigger trigger
|
|
1491
|
+
JOIN pg_catalog.pg_proc trigger_function ON trigger_function.oid=trigger.tgfoid
|
|
1492
|
+
JOIN pg_catalog.pg_namespace trigger_namespace ON trigger_namespace.oid=trigger_function.pronamespace
|
|
1493
|
+
WHERE trigger.tgrelid='agent_bridge.gateway_authority'::regclass
|
|
1494
|
+
AND trigger.tgname='gateway_authority_immutable'
|
|
1495
|
+
AND NOT trigger.tgisinternal AND trigger.tgenabled='O'
|
|
1496
|
+
AND (trigger.tgtype::integer & 1)=0
|
|
1497
|
+
AND (trigger.tgtype::integer & 2)=2
|
|
1498
|
+
AND (trigger.tgtype::integer & 56)=56
|
|
1499
|
+
AND trigger_function.proname='reject_gateway_authority_mutation'
|
|
1500
|
+
AND trigger_namespace.nspname='agent_bridge'
|
|
1501
|
+
AND trigger_function.proowner=(SELECT schema_owner FROM names)
|
|
1502
|
+
AND NOT trigger_function.prosecdef
|
|
1503
|
+
AND coalesce(trigger_function.proconfig @> ARRAY['search_path=""'],false)
|
|
1504
|
+
)
|
|
1505
|
+
AND EXISTS (
|
|
1506
|
+
SELECT 1 FROM pg_catalog.pg_proc procedure
|
|
1507
|
+
WHERE procedure.oid='agent_bridge.gateway_authority_ready()'::regprocedure
|
|
1508
|
+
AND procedure.prosecdef AND procedure.provolatile='s'
|
|
1509
|
+
AND procedure.proowner=(SELECT schema_owner FROM names)
|
|
1510
|
+
AND coalesce(procedure.proconfig @> ARRAY['search_path=""'],false)
|
|
1511
|
+
)
|
|
1512
|
+
AND EXISTS (
|
|
1513
|
+
SELECT 1 FROM pg_catalog.pg_proc procedure
|
|
1514
|
+
WHERE procedure.oid='agent_bridge.open_request_authority_bound(uuid,text,uuid)'::regprocedure
|
|
1515
|
+
AND procedure.prosecdef AND procedure.provolatile='v'
|
|
1516
|
+
AND procedure.proowner=(SELECT schema_owner FROM names)
|
|
1517
|
+
AND coalesce(procedure.proconfig @> ARRAY['search_path=""'],false)
|
|
1518
|
+
)
|
|
1519
|
+
AND NOT EXISTS (
|
|
1520
|
+
SELECT 1
|
|
1521
|
+
FROM unnest(ARRAY[
|
|
1522
|
+
'SELECT','INSERT','UPDATE','DELETE','TRUNCATE','REFERENCES','TRIGGER'
|
|
1523
|
+
]) privilege(value)
|
|
1524
|
+
WHERE has_table_privilege((SELECT runtime_role FROM names),
|
|
1525
|
+
'agent_bridge.gateway_authority',privilege.value)
|
|
1526
|
+
OR has_table_privilege('public','agent_bridge.gateway_authority',privilege.value)
|
|
1527
|
+
)
|
|
1528
|
+
AND NOT EXISTS (
|
|
1529
|
+
SELECT 1
|
|
1530
|
+
FROM unnest(ARRAY['SELECT','INSERT','UPDATE','REFERENCES']) privilege(value)
|
|
1531
|
+
WHERE has_any_column_privilege((SELECT runtime_role FROM names),
|
|
1532
|
+
'agent_bridge.gateway_authority',privilege.value)
|
|
1533
|
+
OR has_any_column_privilege('public','agent_bridge.gateway_authority',privilege.value)
|
|
1534
|
+
)
|
|
1535
|
+
AND has_function_privilege((SELECT runtime_role FROM names),
|
|
1536
|
+
'agent_bridge.gateway_authority_ready()','EXECUTE')
|
|
1537
|
+
AND has_function_privilege((SELECT runtime_role FROM names),
|
|
1538
|
+
'agent_bridge.open_request_authority_bound(uuid,text,uuid)','EXECUTE')
|
|
1539
|
+
AND NOT has_function_privilege('public','agent_bridge.gateway_authority_ready()','EXECUTE')
|
|
1540
|
+
AND NOT has_function_privilege('public',
|
|
1541
|
+
'agent_bridge.open_request_authority_bound(uuid,text,uuid)','EXECUTE') AS ready`);
|
|
1542
|
+
return result.rows[0]?.ready === true;
|
|
1543
|
+
}
|
|
1400
1544
|
function createPrivateEmptyFile(path) {
|
|
1401
1545
|
const descriptor = openSync2(path, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL, 384);
|
|
1402
1546
|
closeSync2(descriptor);
|
|
@@ -1434,10 +1578,16 @@ async function backupPostgresNativeDr(options) {
|
|
|
1434
1578
|
if (!snapshot) throw new PostgresNativeDrError("SNAPSHOT_EXPORT_FAILED", "PostgreSQL did not export a disaster recovery snapshot");
|
|
1435
1579
|
const metadata = await collectSnapshotMetadata(source, deps.checkRowIsolationReady);
|
|
1436
1580
|
const major = serverMajor(metadata.serverVersionNum);
|
|
1581
|
+
const schemaVersion = Math.max(...metadata.migrations.map((migration) => migration.version));
|
|
1582
|
+
const excludedDataTables = excludedDataTablesForSchemaVersion(schemaVersion);
|
|
1437
1583
|
const beforeInventory = await collectPostgresRoleInventory(source, metadata.databaseName);
|
|
1438
1584
|
const canonicalRoles = canonicalPostgresRoleInventory(beforeInventory);
|
|
1439
1585
|
const tools = await checkedTools(major, libpq.environment, options.toolDirectory, deps);
|
|
1440
|
-
const dump = await deps.runTool(
|
|
1586
|
+
const dump = await deps.runTool(
|
|
1587
|
+
tools.pgDump,
|
|
1588
|
+
buildPgDumpArgsForTables(dumpPath, snapshot, libpq.serviceName, excludedDataTables),
|
|
1589
|
+
libpq.environment
|
|
1590
|
+
);
|
|
1441
1591
|
assertToolSucceeded(dump, "PG_DUMP_FAILED", "pg_dump");
|
|
1442
1592
|
verifyPrivatePathAccess(dumpPath, "file");
|
|
1443
1593
|
if (statSync(dumpPath).size === 0) throw new PostgresNativeDrError("PG_DUMP_EMPTY", "pg_dump produced an empty file");
|
|
@@ -1459,7 +1609,6 @@ async function backupPostgresNativeDr(options) {
|
|
|
1459
1609
|
transactionOpen = false;
|
|
1460
1610
|
await source.query("SELECT pg_catalog.pg_advisory_unlock($1)", [NATIVE_DR_ADVISORY_LOCK_KEY]);
|
|
1461
1611
|
lockHeld = false;
|
|
1462
|
-
const schemaVersion = Math.max(...metadata.migrations.map((migration) => migration.version));
|
|
1463
1612
|
const result = {
|
|
1464
1613
|
backupId: validateBackupId(options.backupId ?? deps.randomId()),
|
|
1465
1614
|
createdAt: deps.now().toISOString(),
|
|
@@ -1471,7 +1620,7 @@ async function backupPostgresNativeDr(options) {
|
|
|
1471
1620
|
schemaVersion,
|
|
1472
1621
|
migrations: metadata.migrations,
|
|
1473
1622
|
tableCounts: metadata.tableCounts,
|
|
1474
|
-
excludedDataTables: [...
|
|
1623
|
+
excludedDataTables: [...excludedDataTables],
|
|
1475
1624
|
claimedDeliveryCount: metadata.claimedDeliveryCount,
|
|
1476
1625
|
pgDumpVersion: tools.pgDumpVersion,
|
|
1477
1626
|
roleInventorySha256: sha256(canonicalRoles),
|
|
@@ -1558,10 +1707,11 @@ function validatePostgresNativeDrSchema(value) {
|
|
|
1558
1707
|
throw new PostgresNativeDrError("INVALID_MANIFEST", "PostgreSQL table count inventory is invalid");
|
|
1559
1708
|
}
|
|
1560
1709
|
}
|
|
1561
|
-
|
|
1710
|
+
const excludedDataTables = excludedDataTablesForSchemaVersion(value.schemaVersion);
|
|
1711
|
+
for (const table of ["agent_bridge.deliveries", "agent_bridge.delivery_events", ...excludedDataTables]) {
|
|
1562
1712
|
if (!(table in value.tableCounts)) throw new PostgresNativeDrError("INVALID_MANIFEST", `PostgreSQL table count is missing for ${table}`);
|
|
1563
1713
|
}
|
|
1564
|
-
if (JSON.stringify(value.excludedDataTables) !== JSON.stringify(
|
|
1714
|
+
if (JSON.stringify(value.excludedDataTables) !== JSON.stringify(excludedDataTables)) {
|
|
1565
1715
|
throw new PostgresNativeDrError("INVALID_MANIFEST", "PostgreSQL excluded table inventory is invalid");
|
|
1566
1716
|
}
|
|
1567
1717
|
if (!/^(?:0|[1-9][0-9]*)$/u.test(value.claimedDeliveryCount)) throw new PostgresNativeDrError("INVALID_MANIFEST", "PostgreSQL claimed delivery count is invalid");
|
|
@@ -1671,7 +1821,7 @@ async function targetTableCounts(client) {
|
|
|
1671
1821
|
}
|
|
1672
1822
|
function expectedRestoredTableCounts(schema) {
|
|
1673
1823
|
const expected = { ...schema.tableCounts };
|
|
1674
|
-
for (const table of
|
|
1824
|
+
for (const table of excludedDataTablesForSchemaVersion(schema.schemaVersion)) expected[table] = "0";
|
|
1675
1825
|
const deliveryEvents = expected["agent_bridge.delivery_events"];
|
|
1676
1826
|
if (deliveryEvents === void 0) throw new PostgresNativeDrError("INVALID_MANIFEST", "PostgreSQL delivery event count is missing");
|
|
1677
1827
|
expected["agent_bridge.delivery_events"] = (BigInt(deliveryEvents) + BigInt(schema.claimedDeliveryCount)).toString();
|
|
@@ -1852,11 +2002,13 @@ async function restorePostgresNativeDrInternal(options) {
|
|
|
1852
2002
|
agent_bridge.portable_archive_attestation_definition() AS "portableArchiveDefinition"`);
|
|
1853
2003
|
const ready = readiness.rows[0];
|
|
1854
2004
|
const restoredRowReady = await deps.checkRowIsolationReady(target);
|
|
2005
|
+
const restoredGatewayAuthorityReady = await gatewayAuthorityReady(target, schema.schemaVersion);
|
|
1855
2006
|
const failedReadiness = [
|
|
1856
2007
|
!ready?.security ? "security" : void 0,
|
|
1857
2008
|
!restoredRowReady ? "row-isolation" : void 0,
|
|
1858
2009
|
!ready?.ownerControl ? "owner-control" : void 0,
|
|
1859
|
-
!ready?.portableArchive ? "portable-archive" : void 0
|
|
2010
|
+
!ready?.portableArchive ? "portable-archive" : void 0,
|
|
2011
|
+
!restoredGatewayAuthorityReady ? "gateway-authority" : void 0
|
|
1860
2012
|
].filter(Boolean);
|
|
1861
2013
|
if (failedReadiness.length > 0) {
|
|
1862
2014
|
throw new PostgresNativeDrError("RESTORE_NOT_READY", `restored PostgreSQL schema failed readiness attestation: ${failedReadiness.join(", ")}`);
|
|
@@ -2396,6 +2548,7 @@ export {
|
|
|
2396
2548
|
POSTGRES_NATIVE_DR_ROLE_SCHEMA,
|
|
2397
2549
|
POSTGRES_NATIVE_DR_ROLE_VERSION,
|
|
2398
2550
|
POSTGRES_NATIVE_DR_SERVICE,
|
|
2551
|
+
POSTGRES_NATIVE_DR_LEGACY_EXCLUDED_DATA_TABLES,
|
|
2399
2552
|
POSTGRES_NATIVE_DR_EXCLUDED_DATA_TABLES,
|
|
2400
2553
|
PostgresNativeDrError,
|
|
2401
2554
|
createPostgresDrLibpqFiles,
|
|
@@ -2425,4 +2578,4 @@ export {
|
|
|
2425
2578
|
restoreLocalSqlite,
|
|
2426
2579
|
SQLITE_EDGE_APPLICATION_ID
|
|
2427
2580
|
};
|
|
2428
|
-
//# sourceMappingURL=chunk-
|
|
2581
|
+
//# sourceMappingURL=chunk-PDIHDBP3.js.map
|