@creatornader/agent-bridge 0.5.2 → 0.6.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 +41 -1
- package/README.md +34 -31
- package/ROADMAP.md +56 -15
- package/SECURITY.md +6 -5
- package/dist/archive.d.ts +2 -2
- package/dist/{bridge-service-CNBKdYXh.d.ts → bridge-service-DjSYfjKt.d.ts} +4 -2
- package/dist/{bridge-store-ByJ6CaJk.d.ts → bridge-store-Bi_LCX8e.d.ts} +5 -1
- package/dist/bridge.d.ts +9 -37
- package/dist/bridge.js +6 -10
- package/dist/chunk-23UDQZMT.js +54 -0
- package/dist/chunk-23UDQZMT.js.map +1 -0
- package/dist/{chunk-AWE3DFZV.js → chunk-4V2PFJEF.js} +11 -4
- package/dist/chunk-4V2PFJEF.js.map +1 -0
- package/dist/{chunk-E4OWHGUE.js → chunk-62C63PIE.js} +8 -8
- package/dist/chunk-62C63PIE.js.map +1 -0
- package/dist/{chunk-HUHG7XTB.js → chunk-AIALYLGQ.js} +30 -193
- package/dist/chunk-AIALYLGQ.js.map +1 -0
- package/dist/{chunk-JUTJRAMA.js → chunk-FGERNG4X.js} +3 -3
- package/dist/{chunk-7VJI2MXI.js → chunk-IF5OKPBK.js} +32 -14
- package/dist/chunk-IF5OKPBK.js.map +1 -0
- package/dist/{chunk-QPC6JHA3.js → chunk-IMJ47WO4.js} +12 -16
- package/dist/chunk-IMJ47WO4.js.map +1 -0
- package/dist/{chunk-2EVLG3YA.js → chunk-UKFRCP6X.js} +10 -7
- package/dist/chunk-UKFRCP6X.js.map +1 -0
- package/dist/chunk-WQ4I5XGF.js +242 -0
- package/dist/chunk-WQ4I5XGF.js.map +1 -0
- package/dist/{chunk-SN7PIVDF.js → chunk-ZUZ7TCIH.js} +13 -1
- package/dist/{chunk-SN7PIVDF.js.map → chunk-ZUZ7TCIH.js.map} +1 -1
- package/dist/cli.js +41 -34
- 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 +3 -3
- package/dist/client-runtime.js +5 -5
- package/dist/contracts/generate.js +2 -3
- package/dist/contracts/generate.js.map +1 -1
- package/dist/dr.d.ts +8 -0
- package/dist/dr.js +1 -1
- package/dist/{gateway-CW-61lvs.d.ts → gateway-BqmcKam8.d.ts} +2 -2
- package/dist/gateway-main.js +3 -3
- package/dist/gateway.d.ts +3 -3
- package/dist/gateway.js +3 -3
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/{postgres-bridge-store-C9KG9Z69.d.ts → postgres-bridge-store-ChoOuFEY.d.ts} +1 -1
- package/dist/server.d.ts +0 -2
- package/dist/server.js +8 -7
- package/dist/{sqlite-edge-store-CdMIOrho.d.ts → sqlite-edge-store-BAFUeysk.d.ts} +1 -1
- package/dist/sqlite.d.ts +7 -3
- package/dist/sqlite.js +1 -1
- package/docs/architecture-v2.md +22 -14
- package/docs/decisions/0001-protocol-layers-and-acknowledgment-semantics.md +2 -1
- package/docs/decisions/0002-canonical-operation-contract-registry.md +6 -1
- package/docs/decisions/0005-retire-direct-supabase-runtime.md +52 -0
- package/docs/deployment.md +17 -12
- package/docs/ecosystem.md +6 -4
- package/docs/troubleshooting.md +15 -0
- package/llms.txt +3 -3
- package/openapi/agent-bridge-v2.openapi.json +3 -6
- package/package.json +3 -3
- package/schemas/agent-bridge-v2.capabilities.json +4 -5
- package/schemas/agent-bridge-v2.mcp.json +6 -12
- package/schemas/agent-bridge-v2.schema.json +12 -24
- package/dist/chunk-2EVLG3YA.js.map +0 -1
- package/dist/chunk-7VJI2MXI.js.map +0 -1
- package/dist/chunk-AWE3DFZV.js.map +0 -1
- package/dist/chunk-E4OWHGUE.js.map +0 -1
- package/dist/chunk-HUHG7XTB.js.map +0 -1
- package/dist/chunk-QPC6JHA3.js.map +0 -1
- package/dist/chunk-Z6JP6MYD.js +0 -584
- package/dist/chunk-Z6JP6MYD.js.map +0 -1
- /package/dist/{chunk-JUTJRAMA.js.map → chunk-FGERNG4X.js.map} +0 -0
package/dist/client-config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as BridgePrincipal } from './bridge-domain-CBX3IVqC.js';
|
|
2
2
|
|
|
3
|
-
type ClientProvider = "local" | "gateway"
|
|
3
|
+
type ClientProvider = "local" | "gateway";
|
|
4
4
|
interface ClientEnvironment extends NodeJS.ProcessEnv {
|
|
5
5
|
AGENT_BRIDGE_PROVIDER?: string;
|
|
6
6
|
AGENT_BRIDGE_URL?: string;
|
package/dist/client-config.js
CHANGED
package/dist/client-runtime.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as BridgeService } from './bridge-service-
|
|
2
|
-
import { a as BridgeStore } from './bridge-store-
|
|
3
|
-
import { a as EdgeDrainLease } from './sqlite-edge-store-
|
|
1
|
+
import { B as BridgeService } from './bridge-service-DjSYfjKt.js';
|
|
2
|
+
import { a as BridgeStore } from './bridge-store-Bi_LCX8e.js';
|
|
3
|
+
import { a as EdgeDrainLease } from './sqlite-edge-store-BAFUeysk.js';
|
|
4
4
|
import { ClientConfig } from './client-config.js';
|
|
5
5
|
import './bridge-domain-CBX3IVqC.js';
|
|
6
6
|
|
package/dist/client-runtime.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createClientRuntime,
|
|
4
4
|
createStore
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-IMJ47WO4.js";
|
|
6
|
+
import "./chunk-WQ4I5XGF.js";
|
|
7
|
+
import "./chunk-ZUZ7TCIH.js";
|
|
8
8
|
import "./chunk-IVG4XWWS.js";
|
|
9
9
|
import "./chunk-GTK4KOED.js";
|
|
10
10
|
import "./chunk-VOQIDTCJ.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-4V2PFJEF.js";
|
|
12
|
+
import "./chunk-62C63PIE.js";
|
|
13
13
|
import "./chunk-BZLMF5O5.js";
|
|
14
14
|
export {
|
|
15
15
|
createClientRuntime,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SUPPORTED_PROTOCOL_VERSIONS,
|
|
12
12
|
capabilityDocument,
|
|
13
13
|
operations
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-62C63PIE.js";
|
|
15
15
|
|
|
16
16
|
// src/contracts/generate.ts
|
|
17
17
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -43,8 +43,7 @@ function objectWithout(schema, excluded) {
|
|
|
43
43
|
}
|
|
44
44
|
var scopeEnforcementByProvider = {
|
|
45
45
|
local: false,
|
|
46
|
-
gateway: SCOPE_ENFORCEMENT
|
|
47
|
-
"legacy-supabase": false
|
|
46
|
+
gateway: SCOPE_ENFORCEMENT
|
|
48
47
|
};
|
|
49
48
|
var schemas = {
|
|
50
49
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contracts/generate.ts","../../src/contracts/artifact-format.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { formatContractArtifact, normalizeContractArtifact } from \"./artifact-format.js\";\nimport {\n capabilityDocument,\n ErrorEnvelopeSchema,\n LegacyDeliverySchema,\n LegacyMessageDraftSchema,\n LegacyMessageSchema,\n LEGACY_PROTOCOL_VERSION,\n operations,\n PROTOCOL_HEADER,\n PROTOCOL_VERSION,\n SCOPE_ENFORCEMENT,\n SUPPORTED_PROTOCOL_HEADER,\n SUPPORTED_PROTOCOL_VERSIONS,\n} from \"./registry.js\";\n\nfunction clone<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nfunction objectWithout(schema: Record<string, any>, excluded: ReadonlySet<string>): Record<string, any> {\n const result = clone(schema);\n if (!result.properties) return result;\n result.properties = Object.fromEntries(Object.entries(result.properties).filter(([name]) => !excluded.has(name)));\n if (Array.isArray(result.required)) {\n result.required = result.required.filter((name: string) => !excluded.has(name));\n if (!result.required.length) delete result.required;\n }\n return result;\n}\n\nconst scopeEnforcementByProvider = {\n local: false,\n gateway: SCOPE_ENFORCEMENT,\n \"legacy-supabase\": false,\n};\n\nconst schemas = {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n $id: \"https://agent-bridge.dev/schemas/v2/operations.json\",\n title: \"Agent Bridge v2 operation contracts\",\n protocolVersion: PROTOCOL_VERSION,\n scopeEnforcementByProvider,\n $defs: {\n ErrorEnvelope: ErrorEnvelopeSchema,\n legacy20MessageDraft: LegacyMessageDraftSchema,\n legacy20Message: LegacyMessageSchema,\n legacy20Delivery: LegacyDeliverySchema,\n ...Object.fromEntries(operations.flatMap((operation) => [\n [`${operation.id}Request`, operation.request],\n [`${operation.id}Response`, operation.response],\n ...(operation.cli ? [[`${operation.id}CliResponse`, operation.cli.response ?? operation.response] as const] : []),\n ...(operation.cli?.variants?.map((variant) => [\n `${operation.id}CliVariant${variant.command.replace(/(^|[-_])(\\w)/g, (_match, _separator, character: string) => character.toUpperCase())}Response`,\n variant.response,\n ] as const) ?? []),\n ])),\n },\n};\n\nconst protocolHeaders = {\n [PROTOCOL_HEADER]: {\n description: \"Selected Agent Bridge protocol version.\",\n required: true,\n schema: { type: \"string\", enum: [...SUPPORTED_PROTOCOL_VERSIONS] },\n },\n [SUPPORTED_PROTOCOL_HEADER]: {\n description: \"Comma-separated protocol versions supported by this gateway.\",\n required: true,\n schema: { type: \"string\" },\n },\n};\n\nfunction errorResponse(description: string) {\n return {\n description,\n headers: protocolHeaders,\n content: { \"application/json\": { schema: { $ref: \"#/components/schemas/ErrorEnvelope\" } } },\n };\n}\n\nconst canonicalErrors = {\n \"400\": errorResponse(\"The request does not match the operation contract.\"),\n \"401\": errorResponse(\"The bearer credential is missing or invalid.\"),\n \"403\": errorResponse(\"The credential cannot access the requested principal or origin.\"),\n \"404\": errorResponse(\"The route or requested resource does not exist.\"),\n \"409\": errorResponse(\"The request conflicts with current delivery or idempotency state.\"),\n \"413\": errorResponse(\"The request body exceeds the configured limit.\"),\n \"415\": errorResponse(\"The request content type is not application/json.\"),\n \"426\": errorResponse(\"The requested protocol version is unsupported.\"),\n \"429\": errorResponse(\"The gateway has rate-limited the request.\"),\n \"500\": errorResponse(\"The gateway could not complete the request.\"),\n \"502\": errorResponse(\"The upstream response does not match the selected protocol contract.\"),\n \"503\": errorResponse(\"The backing service is unavailable.\"),\n \"504\": errorResponse(\"The request exceeded the gateway deadline.\"),\n};\n\nconst paths: Record<string, Record<string, unknown>> = {};\nfor (const operation of operations.filter((entry) => entry.http)) {\n const http = operation.http!;\n const pathItem = paths[http.path] ??= {};\n const pathNames = [...http.path.matchAll(/\\{([^}]+)\\}/g)].map((match) => match[1]!);\n const pathSet = new Set(pathNames);\n const request = clone(operation.request as Record<string, any>);\n const parameters: Array<Record<string, unknown>> = [{\n name: PROTOCOL_HEADER,\n in: \"header\",\n required: true,\n description: \"This OpenAPI operation describes protocol 2.1. Headerless protocol 2.0 uses the separate schemas named by x-agent-bridge-protocol-2.0.\",\n schema: { type: \"string\", enum: [PROTOCOL_VERSION] },\n }, ...pathNames.map((name) => ({\n name,\n in: \"path\",\n required: true,\n schema: request.properties?.[name] ?? { type: \"string\" },\n }))];\n\n if (http.method === \"GET\" && request.properties) {\n for (const [propertyName, propertySchema] of Object.entries(request.properties) as Array<[string, Record<string, any>]>) {\n if (pathSet.has(propertyName)) continue;\n const queryName = propertyName === \"types\" ? \"type\" : propertyName === \"states\" ? \"state\" : propertyName;\n const repeated = propertySchema.type === \"array\";\n parameters.push({\n name: queryName,\n in: \"query\",\n required: request.required?.includes(propertyName) ?? false,\n ...(repeated ? { style: \"form\", explode: true } : {}),\n schema: propertySchema,\n });\n for (const alias of http.queryAliases?.[propertyName] ?? []) {\n parameters.push({\n name: alias,\n in: \"query\",\n required: false,\n deprecated: true,\n description: `Compatibility alias for ${queryName}.`,\n schema: propertySchema,\n });\n }\n }\n }\n\n const contentType = http.responseContentType ?? \"application/json\";\n const successStatus = String(http.successStatus ?? 200);\n const successResponse = {\n description: \"Successful response.\",\n headers: protocolHeaders,\n content: { [contentType]: { schema: clone(operation.response) } },\n };\n const bodySchema = objectWithout(request, pathSet);\n const hasBodyFields = Object.keys(bodySchema.properties ?? {}).length > 0;\n const hasRequiredBodyFields = Array.isArray(bodySchema.required) && bodySchema.required.length > 0;\n pathItem[http.method.toLowerCase()] = {\n operationId: operation.id,\n summary: operation.summary,\n security: [{ bearerAuth: [] }],\n \"x-agent-bridge-required-scopes\": [...operation.scopes],\n \"x-agent-bridge-scope-enforcement\": SCOPE_ENFORCEMENT,\n ...(parameters.length ? { parameters } : {}),\n ...(http.method === \"POST\" && hasBodyFields ? {\n requestBody: {\n required: hasRequiredBodyFields,\n content: { \"application/json\": { schema: bodySchema } },\n },\n } : {}),\n responses: { [successStatus]: successResponse, ...canonicalErrors },\n };\n}\n\nconst openapi = {\n openapi: \"3.1.2\",\n info: {\n title: \"Agent Bridge Gateway\",\n version: PROTOCOL_VERSION,\n license: { name: \"Apache-2.0\", identifier: \"Apache-2.0\" },\n },\n servers: [{ url: \"/\" }],\n \"x-agent-bridge-protocol-versions\": [...SUPPORTED_PROTOCOL_VERSIONS],\n \"x-agent-bridge-openapi-protocol-version\": PROTOCOL_VERSION,\n \"x-agent-bridge-protocol-2.0\": {\n description: \"Limited schema metadata for the released headerless 0.2.0 compatibility contract derived from d8184fe. This is not a complete OpenAPI route description. It does not support project, deliveryPolicy, delivery management/listing, or current delivery bookkeeping fields.\",\n requestSchemas: { publish_message: \"#/x-agent-bridge-schemas-2.0/MessageDraft\" },\n responseSchemas: { message: \"#/x-agent-bridge-schemas-2.0/Message\", delivery: \"#/x-agent-bridge-schemas-2.0/Delivery\" },\n },\n \"x-agent-bridge-schemas-2.0\": {\n MessageDraft: LegacyMessageDraftSchema,\n Message: LegacyMessageSchema,\n Delivery: LegacyDeliverySchema,\n },\n \"x-agent-bridge-scope-enforcement\": SCOPE_ENFORCEMENT,\n paths,\n components: {\n schemas: { ErrorEnvelope: ErrorEnvelopeSchema },\n securitySchemes: { bearerAuth: { type: \"http\", scheme: \"bearer\" } },\n },\n};\n\nconst mcp = {\n schemaVersion: \"agent-bridge-mcp-manifest-v1\",\n protocolVersion: PROTOCOL_VERSION,\n scopeEnforcementByProvider,\n tools: operations.filter((entry) => entry.mcp).map((entry) => ({\n name: entry.mcp!.name,\n description: entry.summary,\n inputSchema: entry.request,\n outputSchema: entry.response,\n requiredScopes: entry.scopes,\n providers: entry.providers,\n })),\n};\n\nconst root = resolve(dirname(fileURLToPath(import.meta.url)), \"../..\");\nconst outputs = new Map([\n [resolve(root, \"schemas/agent-bridge-v2.schema.json\"), formatContractArtifact(schemas)],\n [resolve(root, \"openapi/agent-bridge-v2.openapi.json\"), formatContractArtifact(openapi)],\n [resolve(root, \"schemas/agent-bridge-v2.mcp.json\"), formatContractArtifact(mcp)],\n [resolve(root, \"schemas/agent-bridge-v2.capabilities.json\"), formatContractArtifact(capabilityDocument())],\n]);\nconst check = process.argv.includes(\"--check\");\nconst drift: string[] = [];\nfor (const [path, contents] of outputs) {\n if (check) {\n let current = \"\";\n try { current = readFileSync(path, \"utf8\"); } catch {}\n if (normalizeContractArtifact(current) !== normalizeContractArtifact(contents)) {\n drift.push(path.slice(root.length + 1));\n }\n } else {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, contents);\n }\n}\nif (drift.length) {\n for (const path of drift) process.stderr.write(`ERROR contract artifact drift: ${path}\\n`);\n process.exitCode = 1;\n} else {\n process.stdout.write(`contracts ${check ? \"match\" : \"generated\"}: ${outputs.size} artifacts, ${operations.length} operations\\n`);\n}\n","export function formatContractArtifact(value: unknown): string {\n return `${JSON.stringify(value, null, 2)}\\n`;\n}\n\nexport function normalizeContractAr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CAAC,QAAQ,MAAM,2CAA2C,GAAG,uBAAuB,mBAAmB,CAAC,CAAC;AAC3G,CAAC;AACD,IAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AAC7C,IAAM,QAAkB,CAAC;AACzB,WAAW,CAAC,MAAM,QAAQ,KAAK,SAAS;AACtC,MAAI,OAAO;AACT,QAAI,UAAU;AACd,QAAI;AAAE,gBAAU,aAAa,MAAM,MAAM;AAAA,IAAG,QAAQ;AAAA,IAAC;AACrD,QAAI,0BAA0B,OAAO,MAAM,0BAA0B,QAAQ,GAAG;AAC9E,YAAM,KAAK,KAAK,MAAM,KAAK,SAAS,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,OAAO;AACL,cAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5C,kBAAc,MAAM,QAAQ;AAAA,EAC9B;AACF;AACA,IAAI,MAAM,QAAQ;AAChB,aAAW,QAAQ,MAAO,SAAQ,OAAO,MAAM,kCAAkC,IAAI;AAAA,CAAI;AACzF,UAAQ,WAAW;AACrB,OAAO;AACL,UAAQ,OAAO,MAAM,aAAa,QAAQ,UAAU,WAAW,KAAK,QAAQ,IAAI,eAAe,WAAW,MAAM;AAAA,CAAe;AACjI;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/generate.ts","../../src/contracts/artifact-format.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { formatContractArtifact, normalizeContractArtifact } from \"./artifact-format.js\";\nimport {\n capabilityDocument,\n ErrorEnvelopeSchema,\n LegacyDeliverySchema,\n LegacyMessageDraftSchema,\n LegacyMessageSchema,\n LEGACY_PROTOCOL_VERSION,\n operations,\n PROTOCOL_HEADER,\n PROTOCOL_VERSION,\n SCOPE_ENFORCEMENT,\n SUPPORTED_PROTOCOL_HEADER,\n SUPPORTED_PROTOCOL_VERSIONS,\n} from \"./registry.js\";\n\nfunction clone<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nfunction objectWithout(schema: Record<string, any>, excluded: ReadonlySet<string>): Record<string, any> {\n const result = clone(schema);\n if (!result.properties) return result;\n result.properties = Object.fromEntries(Object.entries(result.properties).filter(([name]) => !excluded.has(name)));\n if (Array.isArray(result.required)) {\n result.required = result.required.filter((name: string) => !excluded.has(name));\n if (!result.required.length) delete result.required;\n }\n return result;\n}\n\nconst scopeEnforcementByProvider = {\n local: false,\n gateway: SCOPE_ENFORCEMENT,\n};\n\nconst schemas = {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n $id: \"https://agent-bridge.dev/schemas/v2/operations.json\",\n title: \"Agent Bridge v2 operation contracts\",\n protocolVersion: PROTOCOL_VERSION,\n scopeEnforcementByProvider,\n $defs: {\n ErrorEnvelope: ErrorEnvelopeSchema,\n legacy20MessageDraft: LegacyMessageDraftSchema,\n legacy20Message: LegacyMessageSchema,\n legacy20Delivery: LegacyDeliverySchema,\n ...Object.fromEntries(operations.flatMap((operation) => [\n [`${operation.id}Request`, operation.request],\n [`${operation.id}Response`, operation.response],\n ...(operation.cli ? [[`${operation.id}CliResponse`, operation.cli.response ?? operation.response] as const] : []),\n ...(operation.cli?.variants?.map((variant) => [\n `${operation.id}CliVariant${variant.command.replace(/(^|[-_])(\\w)/g, (_match, _separator, character: string) => character.toUpperCase())}Response`,\n variant.response,\n ] as const) ?? []),\n ])),\n },\n};\n\nconst protocolHeaders = {\n [PROTOCOL_HEADER]: {\n description: \"Selected Agent Bridge protocol version.\",\n required: true,\n schema: { type: \"string\", enum: [...SUPPORTED_PROTOCOL_VERSIONS] },\n },\n [SUPPORTED_PROTOCOL_HEADER]: {\n description: \"Comma-separated protocol versions supported by this gateway.\",\n required: true,\n schema: { type: \"string\" },\n },\n};\n\nfunction errorResponse(description: string) {\n return {\n description,\n headers: protocolHeaders,\n content: { \"application/json\": { schema: { $ref: \"#/components/schemas/ErrorEnvelope\" } } },\n };\n}\n\nconst canonicalErrors = {\n \"400\": errorResponse(\"The request does not match the operation contract.\"),\n \"401\": errorResponse(\"The bearer credential is missing or invalid.\"),\n \"403\": errorResponse(\"The credential cannot access the requested principal or origin.\"),\n \"404\": errorResponse(\"The route or requested resource does not exist.\"),\n \"409\": errorResponse(\"The request conflicts with current delivery or idempotency state.\"),\n \"413\": errorResponse(\"The request body exceeds the configured limit.\"),\n \"415\": errorResponse(\"The request content type is not application/json.\"),\n \"426\": errorResponse(\"The requested protocol version is unsupported.\"),\n \"429\": errorResponse(\"The gateway has rate-limited the request.\"),\n \"500\": errorResponse(\"The gateway could not complete the request.\"),\n \"502\": errorResponse(\"The upstream response does not match the selected protocol contract.\"),\n \"503\": errorResponse(\"The backing service is unavailable.\"),\n \"504\": errorResponse(\"The request exceeded the gateway deadline.\"),\n};\n\nconst paths: Record<string, Record<string, unknown>> = {};\nfor (const operation of operations.filter((entry) => entry.http)) {\n const http = operation.http!;\n const pathItem = paths[http.path] ??= {};\n const pathNames = [...http.path.matchAll(/\\{([^}]+)\\}/g)].map((match) => match[1]!);\n const pathSet = new Set(pathNames);\n const request = clone(operation.request as Record<string, any>);\n const parameters: Array<Record<string, unknown>> = [{\n name: PROTOCOL_HEADER,\n in: \"header\",\n required: true,\n description: \"This OpenAPI operation describes protocol 2.1. Headerless protocol 2.0 uses the separate schemas named by x-agent-bridge-protocol-2.0.\",\n schema: { type: \"string\", enum: [PROTOCOL_VERSION] },\n }, ...pathNames.map((name) => ({\n name,\n in: \"path\",\n required: true,\n schema: request.properties?.[name] ?? { type: \"string\" },\n }))];\n\n if (http.method === \"GET\" && request.properties) {\n for (const [propertyName, propertySchema] of Object.entries(request.properties) as Array<[string, Record<string, any>]>) {\n if (pathSet.has(propertyName)) continue;\n const queryName = propertyName === \"types\" ? \"type\" : propertyName === \"states\" ? \"state\" : propertyName;\n const repeated = propertySchema.type === \"array\";\n parameters.push({\n name: queryName,\n in: \"query\",\n required: request.required?.includes(propertyName) ?? false,\n ...(repeated ? { style: \"form\", explode: true } : {}),\n schema: propertySchema,\n });\n for (const alias of http.queryAliases?.[propertyName] ?? []) {\n parameters.push({\n name: alias,\n in: \"query\",\n required: false,\n deprecated: true,\n description: `Compatibility alias for ${queryName}.`,\n schema: propertySchema,\n });\n }\n }\n }\n\n const contentType = http.responseContentType ?? \"application/json\";\n const successStatus = String(http.successStatus ?? 200);\n const successResponse = {\n description: \"Successful response.\",\n headers: protocolHeaders,\n content: { [contentType]: { schema: clone(operation.response) } },\n };\n const bodySchema = objectWithout(request, pathSet);\n const hasBodyFields = Object.keys(bodySchema.properties ?? {}).length > 0;\n const hasRequiredBodyFields = Array.isArray(bodySchema.required) && bodySchema.required.length > 0;\n pathItem[http.method.toLowerCase()] = {\n operationId: operation.id,\n summary: operation.summary,\n security: [{ bearerAuth: [] }],\n \"x-agent-bridge-required-scopes\": [...operation.scopes],\n \"x-agent-bridge-scope-enforcement\": SCOPE_ENFORCEMENT,\n ...(parameters.length ? { parameters } : {}),\n ...(http.method === \"POST\" && hasBodyFields ? {\n requestBody: {\n required: hasRequiredBodyFields,\n content: { \"application/json\": { schema: bodySchema } },\n },\n } : {}),\n responses: { [successStatus]: successResponse, ...canonicalErrors },\n };\n}\n\nconst openapi = {\n openapi: \"3.1.2\",\n info: {\n title: \"Agent Bridge Gateway\",\n version: PROTOCOL_VERSION,\n license: { name: \"Apache-2.0\", identifier: \"Apache-2.0\" },\n },\n servers: [{ url: \"/\" }],\n \"x-agent-bridge-protocol-versions\": [...SUPPORTED_PROTOCOL_VERSIONS],\n \"x-agent-bridge-openapi-protocol-version\": PROTOCOL_VERSION,\n \"x-agent-bridge-protocol-2.0\": {\n description: \"Limited schema metadata for the released headerless 0.2.0 compatibility contract derived from d8184fe. This is not a complete OpenAPI route description. It does not support project, deliveryPolicy, delivery management/listing, or current delivery bookkeeping fields.\",\n requestSchemas: { publish_message: \"#/x-agent-bridge-schemas-2.0/MessageDraft\" },\n responseSchemas: { message: \"#/x-agent-bridge-schemas-2.0/Message\", delivery: \"#/x-agent-bridge-schemas-2.0/Delivery\" },\n },\n \"x-agent-bridge-schemas-2.0\": {\n MessageDraft: LegacyMessageDraftSchema,\n Message: LegacyMessageSchema,\n Delivery: LegacyDeliverySchema,\n },\n \"x-agent-bridge-scope-enforcement\": SCOPE_ENFORCEMENT,\n paths,\n components: {\n schemas: { ErrorEnvelope: ErrorEnvelopeSchema },\n securitySchemes: { bearerAuth: { type: \"http\", scheme: \"bearer\" } },\n },\n};\n\nconst mcp = {\n schemaVersion: \"agent-bridge-mcp-manifest-v1\",\n protocolVersion: PROTOCOL_VERSION,\n scopeEnforcementByProvider,\n tools: operations.filter((entry) => entry.mcp).map((entry) => ({\n name: entry.mcp!.name,\n description: entry.summary,\n inputSchema: entry.request,\n outputSchema: entry.response,\n requiredScopes: entry.scopes,\n providers: entry.providers,\n })),\n};\n\nconst root = resolve(dirname(fileURLToPath(import.meta.url)), \"../..\");\nconst outputs = new Map([\n [resolve(root, \"schemas/agent-bridge-v2.schema.json\"), formatContractArtifact(schemas)],\n [resolve(root, \"openapi/agent-bridge-v2.openapi.json\"), formatContractArtifact(openapi)],\n [resolve(root, \"schemas/agent-bridge-v2.mcp.json\"), formatContractArtifact(mcp)],\n [resolve(root, \"schemas/agent-bridge-v2.capabilities.json\"), formatContractArtifact(capabilityDocument())],\n]);\nconst check = process.argv.includes(\"--check\");\nconst drift: string[] = [];\nfor (const [path, contents] of outputs) {\n if (check) {\n let current = \"\";\n try { current = readFileSync(path, \"utf8\"); } catch {}\n if (normalizeContractArtifact(current) !== normalizeContractArtifact(contents)) {\n drift.push(path.slice(root.length + 1));\n }\n } else {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, contents);\n }\n}\nif (drift.length) {\n for (const path of drift) process.stderr.write(`ERROR contract artifact drift: ${path}\\n`);\n process.exitCode = 1;\n} else {\n process.stdout.write(`contracts ${check ? \"match\" : \"generated\"}: ${outputs.size} artifacts, ${operations.length} operations\\n`);\n}\n","export function formatContractArtifact(value: unknown): string {\n return `${JSON.stringify(value, null, 2)}\\n`;\n}\n\nexport function normalizeContractArtifact(contents: string): string {\n return contents.replace(/\\r\\n?/g, \"\\n\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,WAAW,cAAc,qBAAqB;AACvD,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;;;ACFvB,SAAS,uBAAuB,OAAwB;AAC7D,SAAO,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;AAAA;AAC1C;AAEO,SAAS,0BAA0B,UAA0B;AAClE,SAAO,SAAS,QAAQ,UAAU,IAAI;AACxC;;;ADaA,SAAS,MAAS,OAAa;AAC7B,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;AAEA,SAAS,cAAc,QAA6B,UAAoD;AACtG,QAAM,SAAS,MAAM,MAAM;AAC3B,MAAI,CAAC,OAAO,WAAY,QAAO;AAC/B,SAAO,aAAa,OAAO,YAAY,OAAO,QAAQ,OAAO,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAChH,MAAI,MAAM,QAAQ,OAAO,QAAQ,GAAG;AAClC,WAAO,WAAW,OAAO,SAAS,OAAO,CAAC,SAAiB,CAAC,SAAS,IAAI,IAAI,CAAC;AAC9E,QAAI,CAAC,OAAO,SAAS,OAAQ,QAAO,OAAO;AAAA,EAC7C;AACA,SAAO;AACT;AAEA,IAAM,6BAA6B;AAAA,EACjC,OAAO;AAAA,EACP,SAAS;AACX;AAEA,IAAM,UAAU;AAAA,EACd,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB;AAAA,EACA,OAAO;AAAA,IACL,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,GAAG,OAAO,YAAY,WAAW,QAAQ,CAAC,cAAc;AAAA,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,MAAM,kCAAkC,GAAG,uBAAuB,GAAG,CAAC;AAAA,EAC/E,CAAC,QAAQ,MAAM,2CAA2C,GAAG,uBAAuB,mBAAmB,CAAC,CAAC;AAC3G,CAAC;AACD,IAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AAC7C,IAAM,QAAkB,CAAC;AACzB,WAAW,CAAC,MAAM,QAAQ,KAAK,SAAS;AACtC,MAAI,OAAO;AACT,QAAI,UAAU;AACd,QAAI;AAAE,gBAAU,aAAa,MAAM,MAAM;AAAA,IAAG,QAAQ;AAAA,IAAC;AACrD,QAAI,0BAA0B,OAAO,MAAM,0BAA0B,QAAQ,GAAG;AAC9E,YAAM,KAAK,KAAK,MAAM,KAAK,SAAS,CAAC,CAAC;AAAA,IACxC;AAAA,EACF,OAAO;AACL,cAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5C,kBAAc,MAAM,QAAQ;AAAA,EAC9B;AACF;AACA,IAAI,MAAM,QAAQ;AAChB,aAAW,QAAQ,MAAO,SAAQ,OAAO,MAAM,kCAAkC,IAAI;AAAA,CAAI;AACzF,UAAQ,WAAW;AACrB,OAAO;AACL,UAAQ,OAAO,MAAM,aAAa,QAAQ,UAAU,WAAW,KAAK,QAAQ,IAAI,eAAe,WAAW,MAAM;AAAA,CAAe;AACjI;","names":[]}
|
package/dist/dr.d.ts
CHANGED
|
@@ -299,6 +299,10 @@ declare class PostgresNativeDrError extends Error {
|
|
|
299
299
|
restoreCompleted?: boolean;
|
|
300
300
|
recoveryPaths?: string[];
|
|
301
301
|
causeCode?: string;
|
|
302
|
+
roleMemberships?: Array<{
|
|
303
|
+
role: string;
|
|
304
|
+
member: string;
|
|
305
|
+
}>;
|
|
302
306
|
};
|
|
303
307
|
constructor(code: string, message: string, details?: {
|
|
304
308
|
residualRoleShells?: string[];
|
|
@@ -307,6 +311,10 @@ declare class PostgresNativeDrError extends Error {
|
|
|
307
311
|
restoreCompleted?: boolean;
|
|
308
312
|
recoveryPaths?: string[];
|
|
309
313
|
causeCode?: string;
|
|
314
|
+
roleMemberships?: Array<{
|
|
315
|
+
role: string;
|
|
316
|
+
member: string;
|
|
317
|
+
}>;
|
|
310
318
|
});
|
|
311
319
|
}
|
|
312
320
|
declare function createPostgresDrLibpqFiles(connectionUrl: string, directory: string): PostgresDrLibpqFiles;
|
package/dist/dr.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as node_http from 'node:http';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import { a as BridgeStore } from './bridge-store-
|
|
3
|
+
import { a as BridgeStore } from './bridge-store-Bi_LCX8e.js';
|
|
4
4
|
import { c as BridgePrincipal } from './bridge-domain-CBX3IVqC.js';
|
|
5
|
-
import { P as PgQueryable, b as PostgresBridgeStore } from './postgres-bridge-store-
|
|
5
|
+
import { P as PgQueryable, b as PostgresBridgeStore } from './postgres-bridge-store-ChoOuFEY.js';
|
|
6
6
|
|
|
7
7
|
declare const AUTHORIZATION_SCOPES: readonly ["deliveries:claim", "deliveries:manage", "deliveries:read", "deliveries:settle", "gateway:metrics", "messages:read", "messages:write", "presence:read", "presence:write", "receipts:write", "status:read"];
|
|
8
8
|
type AuthorizationScope = typeof AUTHORIZATION_SCOPES[number];
|
package/dist/gateway-main.js
CHANGED
|
@@ -12,9 +12,9 @@ import "./chunk-VOQIDTCJ.js";
|
|
|
12
12
|
import {
|
|
13
13
|
PostgresCredentialResolver,
|
|
14
14
|
createGateway
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-FGERNG4X.js";
|
|
16
|
+
import "./chunk-4V2PFJEF.js";
|
|
17
|
+
import "./chunk-62C63PIE.js";
|
|
18
18
|
import "./chunk-BZLMF5O5.js";
|
|
19
19
|
|
|
20
20
|
// src/gateway-main.ts
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'node:http';
|
|
2
|
-
import './bridge-store-
|
|
3
|
-
export { G as GatewayOptions, c as createGateway } from './gateway-
|
|
2
|
+
import './bridge-store-Bi_LCX8e.js';
|
|
3
|
+
export { G as GatewayOptions, c as createGateway } from './gateway-BqmcKam8.js';
|
|
4
4
|
import './bridge-domain-CBX3IVqC.js';
|
|
5
|
-
import './postgres-bridge-store-
|
|
5
|
+
import './postgres-bridge-store-ChoOuFEY.js';
|
package/dist/gateway.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createGateway
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-FGERNG4X.js";
|
|
5
|
+
import "./chunk-4V2PFJEF.js";
|
|
6
|
+
import "./chunk-62C63PIE.js";
|
|
7
7
|
import "./chunk-BZLMF5O5.js";
|
|
8
8
|
export {
|
|
9
9
|
createGateway
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
startServer
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-AIALYLGQ.js";
|
|
5
|
+
import "./chunk-23UDQZMT.js";
|
|
6
|
+
import "./chunk-UKFRCP6X.js";
|
|
7
|
+
import "./chunk-IMJ47WO4.js";
|
|
8
|
+
import "./chunk-WQ4I5XGF.js";
|
|
9
|
+
import "./chunk-ZUZ7TCIH.js";
|
|
9
10
|
import "./chunk-IVG4XWWS.js";
|
|
10
11
|
import "./chunk-GTK4KOED.js";
|
|
11
12
|
import "./chunk-VOQIDTCJ.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-4V2PFJEF.js";
|
|
14
|
+
import "./chunk-62C63PIE.js";
|
|
14
15
|
import "./chunk-BZLMF5O5.js";
|
|
15
16
|
|
|
16
17
|
// src/index.ts
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { startServer } from \"./server.js\";\n\nstartServer().catch((err) => {\n console.error(\"Failed to start agent-bridge MCP server:\", err);\n process.exit(1);\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { startServer } from \"./server.js\";\n\nstartServer().catch((err) => {\n console.error(\"Failed to start agent-bridge MCP server:\", err);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA,YAAY,EAAE,MAAM,CAAC,QAAQ;AAC3B,UAAQ,MAAM,4CAA4C,GAAG;AAC7D,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as BridgeMessage, c as BridgePrincipal, B as BridgeDelivery, R as RetryPolicy, a as BridgeDeliveryEvent, A as AgentPresence } from './bridge-domain-CBX3IVqC.js';
|
|
2
|
-
import { a as BridgeStore, I as InsertMessageResult, d as MessageQuery, M as MessagePage, C as ClaimOptions, c as DeliveryQuery, B as BridgeDiagnostics } from './bridge-store-
|
|
2
|
+
import { a as BridgeStore, I as InsertMessageResult, d as MessageQuery, M as MessagePage, C as ClaimOptions, c as DeliveryQuery, B as BridgeDiagnostics } from './bridge-store-Bi_LCX8e.js';
|
|
3
3
|
|
|
4
4
|
interface PgQueryable {
|
|
5
5
|
query<T extends Record<string, unknown> = Record<string, unknown>>(sql: string, values?: unknown[]): Promise<{
|
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -4,16 +4,17 @@ import {
|
|
|
4
4
|
configFromEnv,
|
|
5
5
|
createAgentBridgeServer,
|
|
6
6
|
startServer
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-AIALYLGQ.js";
|
|
8
|
+
import "./chunk-23UDQZMT.js";
|
|
9
|
+
import "./chunk-UKFRCP6X.js";
|
|
10
|
+
import "./chunk-IMJ47WO4.js";
|
|
11
|
+
import "./chunk-WQ4I5XGF.js";
|
|
12
|
+
import "./chunk-ZUZ7TCIH.js";
|
|
12
13
|
import "./chunk-IVG4XWWS.js";
|
|
13
14
|
import "./chunk-GTK4KOED.js";
|
|
14
15
|
import "./chunk-VOQIDTCJ.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-4V2PFJEF.js";
|
|
17
|
+
import "./chunk-62C63PIE.js";
|
|
17
18
|
import "./chunk-BZLMF5O5.js";
|
|
18
19
|
export {
|
|
19
20
|
MCP_IMPLEMENTATION_VERSION,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as BridgeMessage, c as BridgePrincipal } from './bridge-domain-CBX3IVqC.js';
|
|
2
|
-
import { d as MessageQuery, M as MessagePage } from './bridge-store-
|
|
2
|
+
import { d as MessageQuery, M as MessagePage } from './bridge-store-Bi_LCX8e.js';
|
|
3
3
|
|
|
4
4
|
type PendingMessage = Omit<BridgeMessage, "sequence" | "createdAt">;
|
|
5
5
|
interface EdgeScope {
|
package/dist/sqlite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as BridgePrincipal, B as BridgeDelivery, g as DeliveryState, R as RetryPolicy, A as AgentPresence, b as BridgeMessage, a as BridgeDeliveryEvent } from './bridge-domain-CBX3IVqC.js';
|
|
2
|
-
import { M as MessagePage, B as BridgeDiagnostics, I as InsertMessageResult, a as BridgeStore, d as MessageQuery, C as ClaimOptions, c as DeliveryQuery, b as DeliveryPage, D as DeliveryEventPage } from './bridge-store-
|
|
3
|
-
import { e as EdgeMigrationGateState, S as SQLiteEdgeStore, a as EdgeDrainLease, P as PendingMessage } from './sqlite-edge-store-
|
|
4
|
-
export { E as EdgeConflictError, b as EdgeEnqueueResult, c as EdgeMigrationDrainingError, d as EdgeMigrationGate, f as EdgeMigrationLeaseError, g as EdgeMigrationRetiredError, h as EdgeOutboxRecord, i as EdgeReadOnlyInspection, j as EdgeScope, k as EdgeStats, l as edgeMessageFingerprint, m as edgeScopeKey, n as inspectEdgeScopeReadOnly, s as stableIdempotency } from './sqlite-edge-store-
|
|
2
|
+
import { M as MessagePage, B as BridgeDiagnostics, I as InsertMessageResult, a as BridgeStore, d as MessageQuery, C as ClaimOptions, c as DeliveryQuery, b as DeliveryPage, D as DeliveryEventPage } from './bridge-store-Bi_LCX8e.js';
|
|
3
|
+
import { e as EdgeMigrationGateState, S as SQLiteEdgeStore, a as EdgeDrainLease, P as PendingMessage } from './sqlite-edge-store-BAFUeysk.js';
|
|
4
|
+
export { E as EdgeConflictError, b as EdgeEnqueueResult, c as EdgeMigrationDrainingError, d as EdgeMigrationGate, f as EdgeMigrationLeaseError, g as EdgeMigrationRetiredError, h as EdgeOutboxRecord, i as EdgeReadOnlyInspection, j as EdgeScope, k as EdgeStats, l as edgeMessageFingerprint, m as edgeScopeKey, n as inspectEdgeScopeReadOnly, s as stableIdempotency } from './sqlite-edge-store-BAFUeysk.js';
|
|
5
5
|
|
|
6
6
|
interface SyncInsertResult extends InsertMessageResult {
|
|
7
7
|
disposition: "committed" | "queued";
|
|
@@ -110,6 +110,10 @@ declare class SyncingBridgeStore implements BridgeStore {
|
|
|
110
110
|
private cancelled;
|
|
111
111
|
private flushOne;
|
|
112
112
|
insertMessage(message: PendingMessage): Promise<SyncInsertResult>;
|
|
113
|
+
enqueueMessage(message: PendingMessage): Promise<SyncInsertResult & {
|
|
114
|
+
disposition: "queued";
|
|
115
|
+
authoritative: false;
|
|
116
|
+
}>;
|
|
113
117
|
private pull;
|
|
114
118
|
sync(options?: {
|
|
115
119
|
maxPush?: number;
|
package/dist/sqlite.js
CHANGED
package/docs/architecture-v2.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# Agent Bridge v2 architecture
|
|
2
2
|
|
|
3
|
-
Status: living architecture for the 0.
|
|
3
|
+
Status: living architecture for the 0.6.x package line.
|
|
4
4
|
|
|
5
5
|
## Product boundary
|
|
6
6
|
|
|
7
|
-
Agent Bridge
|
|
7
|
+
Agent Bridge lets agents exchange messages and hand off work across clients, processes,
|
|
8
|
+
sessions, and machines. It supports two operating modes: local SQLite and the
|
|
9
|
+
authenticated PostgreSQL gateway.
|
|
8
10
|
|
|
9
11
|
History visibility is caller-relative. `inbox` is the default and preserves broadcast-plus-targeted visibility; `sent` is source equal to the caller; `all` is their union. Receipt state (`any`, `unread`, `read`) is valid only for inbox and is always evaluated for the authenticated caller. Opaque v2 cursors bind workspace, caller, mailbox, and normalized filters. Readers temporarily accept v1 sequence cursors but emit only v2. After an edge cache contract upgrade, the gateway resets the authoritative pull cursor and replays `all` visibility; the publication outbox is never treated as sent history.
|
|
10
12
|
|
|
11
|
-
These authorization guarantees apply to local v2 and the authenticated gateway.
|
|
13
|
+
These authorization guarantees apply to local v2 and the authenticated gateway.
|
|
12
14
|
|
|
13
15
|
- Local mode runs without an account or network connection.
|
|
14
16
|
- Shared mode uses a remote service so agents on different machines see the same history and delivery state.
|
|
@@ -29,7 +31,10 @@ PostgreSQL stores shared messages, identities, receipts, deliveries, and migrati
|
|
|
29
31
|
|
|
30
32
|
A standalone Agent Bridge API sits between remote clients and PostgreSQL. Clients authenticate to the API with scoped credentials. They do not receive a database password or rely on a shared Supabase publishable key for identity.
|
|
31
33
|
|
|
32
|
-
Supabase can
|
|
34
|
+
Supabase can host the database. Agent Bridge 0.6.0 removed the direct PostgREST runtime
|
|
35
|
+
adapter. Historical deployments migrate through the checked-in schema and ordered
|
|
36
|
+
PostgreSQL migrations described in
|
|
37
|
+
[ADR-0005](decisions/0005-retire-direct-supabase-runtime.md).
|
|
33
38
|
|
|
34
39
|
### Deployment separates schema and request authority
|
|
35
40
|
|
|
@@ -237,7 +242,7 @@ The v2 envelope uses fields that can be mapped to CloudEvents without changing s
|
|
|
237
242
|
|
|
238
243
|
A receipt records that a principal read a message.
|
|
239
244
|
|
|
240
|
-
A publisher stores an immutable `deliveryPolicy` with each message. Untargeted messages default to mailbox mode. Targeted messages default to leased mode with `maxAttempts: 5`, `retryBaseDelayMs: 1000`, `retryMaxDelayMs: 60000`, and `retryJitterRatio: 0.2`. Leased policy may also set `notBefore`. Mailbox messages create no deliveries
|
|
245
|
+
A publisher stores an immutable `deliveryPolicy` with each message. Untargeted messages default to mailbox mode. Targeted messages default to leased mode with `maxAttempts: 5`, `retryBaseDelayMs: 1000`, `retryMaxDelayMs: 60000`, and `retryJitterRatio: 0.2`. Leased policy may also set `notBefore`. Mailbox messages create no deliveries.
|
|
241
246
|
|
|
242
247
|
A leased delivery records executable work for a recipient. Its state is one of `pending`, `claimed`, `acked`, `retrying`, `dead`, or `cancelled`. `attempt` is lifetime-monotonic, while `cycleAttempt` resets on publisher requeue and `requeueCount` increments. Stored policy owns retry and exhaustion. Claims order due work by urgent, high, then info priority, followed by availability, message creation time, and the stable delivery ID tie-break. HTTP 2.1, MCP, and CLI may optionally identify one message. That form atomically selects only the eligible delivery for the authenticated recipient and scopes claim-time expiry and exhaustion maintenance to the same message. Omitting the filter preserves claim-next behavior. The frozen HTTP 2.0 request rejects the additive field.
|
|
243
248
|
|
|
@@ -253,7 +258,9 @@ The system promises at-least-once delivery. It does not promise exactly-once exe
|
|
|
253
258
|
|
|
254
259
|
Project participates in the idempotency fingerprint. Reads without a project filter span labeled and unlabeled messages inside the credential-bound workspace. An exact filter narrows that same cursor authority. Migration 008 adds the PostgreSQL column and index. Existing local and edge SQLite databases add their project columns during initialization. Migration 006 is not rewritten. A schema-owner command dry-runs or reconciles its rows into workspace `agent-bridge` in one transaction. It preserves IDs, timestamps, receipts, and row counts, and it verifies that no delivery exists before or after the change.
|
|
255
260
|
|
|
256
|
-
The
|
|
261
|
+
The historical Supabase schema has no tenant workspace column. Migration 006 maps its
|
|
262
|
+
global rows into canonical workspaces before gateway activation. A caller cannot use
|
|
263
|
+
the retired runtime shape to assign a workspace to those rows.
|
|
257
264
|
|
|
258
265
|
The delivery API supports:
|
|
259
266
|
|
|
@@ -274,9 +281,9 @@ Reads use an opaque cursor backed by the backend sequence number. UUIDv7 improve
|
|
|
274
281
|
|
|
275
282
|
During gateway outages, normal inbox and pending reads return the locally cached candidate set with explicit degraded and stale metadata. Because receipt state is remote authority and is not mirrored, an offline `unacknowledgedBy` result reports acknowledgement state as unknown; it must not be interpreted as proof that every returned message is unread.
|
|
276
283
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
284
|
+
Hooks, webhooks, and desktop notifications may wake a client. The client still pulls
|
|
285
|
+
from its last durable cursor. This closes notification gaps and makes reconnect
|
|
286
|
+
behavior testable.
|
|
280
287
|
|
|
281
288
|
### Identity is bound at the client boundary
|
|
282
289
|
|
|
@@ -311,7 +318,6 @@ Protocol logic depends on a `BridgeStore` interface, not a provider SDK. The ini
|
|
|
311
318
|
|
|
312
319
|
- SQLite for local mode and edge state.
|
|
313
320
|
- PostgreSQL for a standalone shared deployment.
|
|
314
|
-
- Supabase legacy REST for v1 compatibility during migration.
|
|
315
321
|
- Agent Bridge HTTP API for normal remote clients.
|
|
316
322
|
|
|
317
323
|
Host and wakeup adapters are independent from storage. A client manifest declares identity injection, supported wake modes, config locations, health checks, and install actions for Codex, Claude Code, Claude Desktop, OpenClaw, or a generic MCP client. The v1 manifest key named `runtime` identifies an installation target for compatibility. It does not identify a unique running process. The `codex` adapter configures the profile shared by the Codex CLI and the Codex surface in the ChatGPT desktop app. Scripts, CI jobs, daemons, and application services may instead call the CLI or HTTPS API or embed the Node library without pretending to be a harness adapter.
|
|
@@ -503,11 +509,14 @@ because an immutable read could miss uncheckpointed outbox state.
|
|
|
503
509
|
|
|
504
510
|
The MCP tools `post_context`, `get_context`, and `ack_context` remain available. Existing CLI verbs and flags remain accepted. Text responses remain present while v2 adds structured result data.
|
|
505
511
|
|
|
506
|
-
|
|
512
|
+
Migration 006 checks the historical Supabase schema, imports v1 records, and verifies
|
|
513
|
+
counts before activation. The reconciliation command can correct imported project
|
|
514
|
+
labels without reopening the retired runtime adapter. Secure shared mode cannot
|
|
515
|
+
silently inherit the old permissive RLS policies.
|
|
507
516
|
|
|
508
517
|
## Security boundary
|
|
509
518
|
|
|
510
|
-
Shared mode uses a token-authenticated API. The service stores only token hashes. Credentials bind a workspace and principal, carry canonical operation scopes, can expire, and can be revoked. Capabilities requires an active credential but no named scope. Local
|
|
519
|
+
Shared mode uses a token-authenticated API. The service stores only token hashes. Credentials bind a workspace and principal, carry canonical operation scopes, can expire, and can be revoked. Capabilities requires an active credential but no named scope. Local mode does not claim gateway scope enforcement.
|
|
511
520
|
|
|
512
521
|
Migration 011 grants every pre-migration credential the full compatibility scope set, including expired and revoked rows, without rewriting lifecycle metadata. Migration 014 preserves those rows but changes new raw inserts to empty scopes. Owner provisioning selects an immutable named scope set. Database constraints reject unknown, duplicated, or unsorted scopes.
|
|
513
522
|
|
|
@@ -640,7 +649,7 @@ The TypeBox 1.x registry validates closed requests before domain semantics. Resp
|
|
|
640
649
|
|
|
641
650
|
Compatibility is asymmetric. An upgraded gateway serves released headerless and explicit 2.0 clients. A new 2.1 client probes before mutation and accepts the gateway only when complete, consistent response headers select 2.1 and advertise 2.1 support. A headerless response, selected 2.0 response, or partial negotiation means the gateway must be upgraded. The client rejects mutation instead of using the d8184fe 2.0 contract. Deploy the gateway before 2.1 clients.
|
|
642
651
|
|
|
643
|
-
The OpenAPI paths describe protocol 2.1. Embedded 2.0 vendor extensions carry only the frozen compatibility schemas and metadata needed to document released clients; they do not form a second OpenAPI description. `npm run contracts:check` proves that JSON Schema 2020-12, OpenAPI 3.1.2, MCP manifest, and capability artifacts match the registry. All schema references are local. Protocol, npm package, MCP implementation, and migration versions are independent. Gateway scope enforcement comes from the registry. Provider-neutral artifacts report enforcement separately for gateway
|
|
652
|
+
The OpenAPI paths describe protocol 2.1. Embedded 2.0 vendor extensions carry only the frozen compatibility schemas and metadata needed to document released clients; they do not form a second OpenAPI description. `npm run contracts:check` proves that JSON Schema 2020-12, OpenAPI 3.1.2, MCP manifest, and capability artifacts match the registry. All schema references are local. Protocol, npm package, MCP implementation, and migration versions are independent. Gateway scope enforcement comes from the registry. Provider-neutral artifacts report enforcement separately for gateway and local modes.
|
|
644
653
|
|
|
645
654
|
The v2 implementation is not accepted until all of these checks pass:
|
|
646
655
|
|
|
@@ -670,7 +679,6 @@ End-to-end payload encryption needs a separate threat model and key-management d
|
|
|
670
679
|
- SQLite WAL-reset bug: <https://sqlite.org/forum/forumpost/0b7fd7f028>
|
|
671
680
|
- PostgreSQL row locking and `SKIP LOCKED`: <https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE>
|
|
672
681
|
- Supabase self-hosting responsibilities: <https://supabase.com/docs/guides/self-hosting>
|
|
673
|
-
- Supabase Realtime delivery limitations: <https://supabase.com/docs/reference/self-hosting-realtime>
|
|
674
682
|
- MCP tools specification: <https://modelcontextprotocol.io/specification/2025-11-25/server/tools>
|
|
675
683
|
- MCP transport specification: <https://modelcontextprotocol.io/specification/2025-11-25/basic/transports>
|
|
676
684
|
- UUIDv7: <https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-7>
|
|
@@ -16,7 +16,8 @@ Agent Bridge needs to serve agents across clients, sessions, processes, and mach
|
|
|
16
16
|
|
|
17
17
|
## Decision
|
|
18
18
|
|
|
19
|
-
Agent Bridge
|
|
19
|
+
Agent Bridge provides messaging and work delivery for intermittently connected agent
|
|
20
|
+
runtimes across tools, sessions, and machines.
|
|
20
21
|
|
|
21
22
|
Its protocol owns:
|
|
22
23
|
|
|
@@ -26,7 +26,11 @@ Compatibility runs in the other direction. An upgraded gateway continues to serv
|
|
|
26
26
|
|
|
27
27
|
The OpenAPI paths require protocol 2.1. The `x-agent-bridge-protocol-2.0` and `x-agent-bridge-schemas-2.0` vendor extensions provide limited metadata and frozen schemas for the released compatibility contract. They do not define a second set of paths or a separate OpenAPI description.
|
|
28
28
|
|
|
29
|
-
Capability documents are filtered by surface and provider. HTTP capability discovery
|
|
29
|
+
Capability documents are filtered by surface and provider. HTTP capability discovery
|
|
30
|
+
requires a valid credential but no named scope. Gateway operations enforce the scopes
|
|
31
|
+
declared by the registry, while local mode uses process identity and reports scope
|
|
32
|
+
enforcement as false. [ADR-0005](0005-retire-direct-supabase-runtime.md) removed the
|
|
33
|
+
legacy runtime provider from this contract.
|
|
30
34
|
|
|
31
35
|
Package version, MCP implementation version, Agent Bridge protocol version, and migration version remain independent. The MCP server reports the explicit `MCP_IMPLEMENTATION_VERSION` constant instead of the npm package version.
|
|
32
36
|
|
|
@@ -42,5 +46,6 @@ Package version, MCP implementation version, Agent Bridge protocol version, and
|
|
|
42
46
|
## Related
|
|
43
47
|
|
|
44
48
|
- [ADR-0001](0001-protocol-layers-and-acknowledgment-semantics.md) defines the protocol layers and acknowledgment meanings.
|
|
49
|
+
- [ADR-0005](0005-retire-direct-supabase-runtime.md) removes the direct Supabase runtime provider.
|
|
45
50
|
- [Architecture v2](../architecture-v2.md) describes the system that follows these decisions.
|
|
46
51
|
- The [README](../../README.md) documents public setup and upgrade behavior.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# ADR-0005: Retire the direct Supabase runtime
|
|
2
|
+
|
|
3
|
+
Status: accepted
|
|
4
|
+
|
|
5
|
+
Date: 2026-07-21
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
Early Agent Bridge releases could read and write `public.shared_context` through
|
|
10
|
+
Supabase PostgREST with a publishable key. That adapter kept the first deployment
|
|
11
|
+
working while the canonical protocol and gateway were built.
|
|
12
|
+
|
|
13
|
+
The adapter could not provide the gateway's security or delivery model. Its shared key
|
|
14
|
+
did not bind a principal or workspace. Its schema had no delivery leases, offline
|
|
15
|
+
outbox, presence, scoped credentials, or transaction-bound request authority. Keeping
|
|
16
|
+
it as a runtime provider also made every public contract describe a weaker third mode.
|
|
17
|
+
|
|
18
|
+
Supabase remains a useful managed PostgreSQL host. The problem is the direct client API,
|
|
19
|
+
not the database service.
|
|
20
|
+
|
|
21
|
+
## Decision
|
|
22
|
+
|
|
23
|
+
Agent Bridge 0.6.0 supports two runtime providers:
|
|
24
|
+
|
|
25
|
+
- `local`, backed by SQLite.
|
|
26
|
+
- `gateway`, backed by an authenticated Agent Bridge gateway with PostgreSQL authority
|
|
27
|
+
and a local SQLite edge store.
|
|
28
|
+
|
|
29
|
+
The package no longer exports or constructs the direct Supabase store. It rejects
|
|
30
|
+
`legacy`, `supabase`, `legacy-supabase`, and key-only configurations with an upgrade
|
|
31
|
+
message.
|
|
32
|
+
|
|
33
|
+
Historical migration support remains:
|
|
34
|
+
|
|
35
|
+
- `sql/setup.sql` records the v1 schema shape.
|
|
36
|
+
- Migration 006 imports `public.shared_context` rows and receipts.
|
|
37
|
+
- `reconcile-legacy-projects` repairs the imported workspace and project mapping.
|
|
38
|
+
- Released HTTP 2.0 and MCP compatibility tools remain independent protocol contracts.
|
|
39
|
+
|
|
40
|
+
## Consequences
|
|
41
|
+
|
|
42
|
+
Remote clients now use one authenticated boundary and one capability model. Supabase
|
|
43
|
+
deployments can continue to host the canonical PostgreSQL database without exposing
|
|
44
|
+
PostgREST to Agent Bridge clients.
|
|
45
|
+
|
|
46
|
+
Operators upgrading an old direct deployment must preserve the source, run the
|
|
47
|
+
historical import, provision principal-bound gateway credentials, and change client
|
|
48
|
+
configuration before installing 0.6.0. A running direct client cannot upgrade in place
|
|
49
|
+
without that provider change.
|
|
50
|
+
|
|
51
|
+
The removed adapter is not a promise to delete historical migration code. Migration
|
|
52
|
+
fixtures remain until the project adopts an explicit migration-support window.
|
package/docs/deployment.md
CHANGED
|
@@ -264,25 +264,30 @@ sender credential needs `messages:write` and `messages:read`. The receiver needs
|
|
|
264
264
|
|
|
265
265
|
Run the workflow only when the Fly app has exactly one gateway machine. The cycle job
|
|
266
266
|
restarts that machine and queries the Fly Machines API before and after. It fails
|
|
267
|
-
unless the machine ID stays fixed,
|
|
268
|
-
returns to `started`, and `/readyz` succeeds.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
267
|
+
unless the machine ID stays fixed, a later successful `start` event appears, the
|
|
268
|
+
machine returns to `started`, and `/readyz` succeeds. Fly documents `instance_id` as a
|
|
269
|
+
version changed by machine updates; a plain restart need not change it. This operation
|
|
270
|
+
changes production compute and requires environment approval. It does not migrate the
|
|
271
|
+
database or change secrets.
|
|
272
|
+
|
|
273
|
+
The sender first writes a leased publication to its private SQLite outbox without a
|
|
274
|
+
network request. It then synchronizes that row to the supplied gateway and repeats the
|
|
275
|
+
publication with the same idempotency key. The gateway origin, workspace, and principal
|
|
276
|
+
scope stay unchanged. A separate host finds the exact message through `proof-receiver`,
|
|
277
|
+
claims its delivery, and acknowledges it.
|
|
275
278
|
After the Fly machine cycle, the verifier uses a fresh instance key, edge database,
|
|
276
279
|
and cursor. It reads the immutable message and confirms that the prior delivery is
|
|
277
|
-
still `acked`.
|
|
280
|
+
still `acked`. The sender and receiver host evidence must differ. GitHub may reuse the
|
|
281
|
+
sender's hosted runner for the verifier, so the verifier proves fresh local state rather
|
|
282
|
+
than requiring a third physical host.
|
|
278
283
|
|
|
279
284
|
Each phase writes an `agent-bridge-production-proof-v1` receipt. The runner rejects
|
|
280
285
|
unknown fields at the phase boundary and checks every receipt before use. Receipts may
|
|
281
286
|
record IDs, timestamps, principal and workspace labels, the gateway origin, boolean
|
|
282
287
|
checks, and salted SHA-256 host evidence. They never record bearer values, database
|
|
283
|
-
URLs, environment values, message content, lease tokens, cursor files,
|
|
284
|
-
databases. Download all four workflow artifacts for the operator record. A
|
|
285
|
-
repository test still does not replace a completed external workflow run.
|
|
288
|
+
URLs, secret-bearing environment values, message content, lease tokens, cursor files,
|
|
289
|
+
or edge databases. Download all four workflow artifacts for the operator record. A
|
|
290
|
+
passing repository test still does not replace a completed external workflow run.
|
|
286
291
|
|
|
287
292
|
### Persistent data and backup
|
|
288
293
|
|