@creatornader/agent-bridge 0.5.2 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +57 -1
  2. package/README.md +59 -34
  3. package/ROADMAP.md +74 -17
  4. package/SECURITY.md +6 -5
  5. package/SKILL.md +4 -1
  6. package/dist/archive.d.ts +2 -2
  7. package/dist/{bridge-service-CNBKdYXh.d.ts → bridge-service-DjSYfjKt.d.ts} +4 -2
  8. package/dist/{bridge-store-ByJ6CaJk.d.ts → bridge-store-Bi_LCX8e.d.ts} +5 -1
  9. package/dist/bridge.d.ts +9 -37
  10. package/dist/bridge.js +6 -10
  11. package/dist/chunk-23UDQZMT.js +54 -0
  12. package/dist/chunk-23UDQZMT.js.map +1 -0
  13. package/dist/{chunk-AWE3DFZV.js → chunk-4V2PFJEF.js} +11 -4
  14. package/dist/chunk-4V2PFJEF.js.map +1 -0
  15. package/dist/{chunk-E4OWHGUE.js → chunk-63JKCBC6.js} +10 -8
  16. package/dist/chunk-63JKCBC6.js.map +1 -0
  17. package/dist/chunk-6ZOLE3E3.js +242 -0
  18. package/dist/chunk-6ZOLE3E3.js.map +1 -0
  19. package/dist/chunk-7B3XRRNI.js +27 -0
  20. package/dist/chunk-7B3XRRNI.js.map +1 -0
  21. package/dist/{chunk-7VJI2MXI.js → chunk-IF5OKPBK.js} +32 -14
  22. package/dist/chunk-IF5OKPBK.js.map +1 -0
  23. package/dist/{chunk-QPC6JHA3.js → chunk-IXNQG4SB.js} +12 -16
  24. package/dist/chunk-IXNQG4SB.js.map +1 -0
  25. package/dist/{chunk-HUHG7XTB.js → chunk-JIRNR75D.js} +30 -193
  26. package/dist/chunk-JIRNR75D.js.map +1 -0
  27. package/dist/{chunk-JUTJRAMA.js → chunk-LF37B6KL.js} +6 -4
  28. package/dist/chunk-LF37B6KL.js.map +1 -0
  29. package/dist/{chunk-2EVLG3YA.js → chunk-UKFRCP6X.js} +10 -7
  30. package/dist/chunk-UKFRCP6X.js.map +1 -0
  31. package/dist/{chunk-SN7PIVDF.js → chunk-ZUZ7TCIH.js} +13 -1
  32. package/dist/{chunk-SN7PIVDF.js.map → chunk-ZUZ7TCIH.js.map} +1 -1
  33. package/dist/cli.js +45 -40
  34. package/dist/cli.js.map +1 -1
  35. package/dist/client-config.d.ts +1 -1
  36. package/dist/client-config.js +1 -1
  37. package/dist/client-runtime.d.ts +3 -3
  38. package/dist/client-runtime.js +5 -5
  39. package/dist/contracts/generate.js +3 -3
  40. package/dist/contracts/generate.js.map +1 -1
  41. package/dist/dr.d.ts +8 -0
  42. package/dist/dr.js +1 -1
  43. package/dist/{gateway-CW-61lvs.d.ts → gateway-DWZ3pX48.d.ts} +7 -2
  44. package/dist/gateway-main.js +12 -3
  45. package/dist/gateway-main.js.map +1 -1
  46. package/dist/gateway.d.ts +3 -3
  47. package/dist/gateway.js +3 -3
  48. package/dist/index.js +8 -7
  49. package/dist/index.js.map +1 -1
  50. package/dist/{postgres-bridge-store-C9KG9Z69.d.ts → postgres-bridge-store-ChoOuFEY.d.ts} +1 -1
  51. package/dist/server.d.ts +0 -2
  52. package/dist/server.js +8 -7
  53. package/dist/{sqlite-edge-store-CdMIOrho.d.ts → sqlite-edge-store-BAFUeysk.d.ts} +1 -1
  54. package/dist/sqlite.d.ts +7 -3
  55. package/dist/sqlite.js +1 -1
  56. package/docs/architecture-v2.md +26 -14
  57. package/docs/decisions/0001-protocol-layers-and-acknowledgment-semantics.md +2 -1
  58. package/docs/decisions/0002-canonical-operation-contract-registry.md +11 -1
  59. package/docs/decisions/0005-retire-direct-supabase-runtime.md +52 -0
  60. package/docs/deployment.md +41 -17
  61. package/docs/ecosystem.md +6 -4
  62. package/docs/troubleshooting.md +15 -0
  63. package/llms.txt +4 -4
  64. package/openapi/agent-bridge-v2.openapi.json +11 -6
  65. package/package.json +5 -3
  66. package/schemas/agent-bridge-v2.capabilities.json +11 -5
  67. package/schemas/agent-bridge-v2.mcp.json +13 -12
  68. package/schemas/agent-bridge-v2.schema.json +26 -24
  69. package/scripts/gateway-release-check.mjs +92 -0
  70. package/dist/chunk-2EVLG3YA.js.map +0 -1
  71. package/dist/chunk-7VJI2MXI.js.map +0 -1
  72. package/dist/chunk-AWE3DFZV.js.map +0 -1
  73. package/dist/chunk-E4OWHGUE.js.map +0 -1
  74. package/dist/chunk-HUHG7XTB.js.map +0 -1
  75. package/dist/chunk-JUTJRAMA.js.map +0 -1
  76. package/dist/chunk-QPC6JHA3.js.map +0 -1
  77. package/dist/chunk-Z6JP6MYD.js +0 -584
  78. package/dist/chunk-Z6JP6MYD.js.map +0 -1
package/dist/cli.js CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ legacyContextMetadata,
4
+ legacyNumericMessageId
5
+ } from "./chunk-23UDQZMT.js";
2
6
  import {
3
7
  PortableArchiveError,
4
8
  PortableArchiveFile,
@@ -10,23 +14,20 @@ import {
10
14
  import {
11
15
  readClientConfigFile,
12
16
  resolveClientConfig
13
- } from "./chunk-2EVLG3YA.js";
17
+ } from "./chunk-UKFRCP6X.js";
14
18
  import {
15
19
  createClientRuntime
16
- } from "./chunk-QPC6JHA3.js";
20
+ } from "./chunk-IXNQG4SB.js";
17
21
  import {
18
22
  BridgeHttpError,
19
- HttpBridgeStore,
20
- LegacySupabaseError,
21
- legacyContextMetadata,
22
- legacyNumericMessageId
23
- } from "./chunk-Z6JP6MYD.js";
23
+ HttpBridgeStore
24
+ } from "./chunk-6ZOLE3E3.js";
24
25
  import {
25
26
  SQLiteEdgeStore,
26
27
  SyncingBridgeStore,
27
28
  edgeScopeKey,
28
29
  inspectEdgeScopeReadOnly
29
- } from "./chunk-SN7PIVDF.js";
30
+ } from "./chunk-ZUZ7TCIH.js";
30
31
  import {
31
32
  NativeDrBundleError,
32
33
  NativeDrBundleReader,
@@ -41,7 +42,7 @@ import {
41
42
  verifyNativeDrBundle,
42
43
  verifyPostgresNativeDrArtifacts,
43
44
  writeNativeDrBundle
44
- } from "./chunk-7VJI2MXI.js";
45
+ } from "./chunk-IF5OKPBK.js";
45
46
  import "./chunk-IVG4XWWS.js";
46
47
  import {
47
48
  PrivatePathError,
@@ -50,18 +51,21 @@ import {
50
51
  securePrivatePath,
51
52
  verifyPrivatePathAccess
52
53
  } from "./chunk-GTK4KOED.js";
54
+ import {
55
+ packageVersion
56
+ } from "./chunk-7B3XRRNI.js";
53
57
  import {
54
58
  loadMigrationPlan,
55
59
  runMigrations
56
60
  } from "./chunk-QNXHDOJ5.js";
57
61
  import "./chunk-VOQIDTCJ.js";
58
- import "./chunk-AWE3DFZV.js";
62
+ import "./chunk-4V2PFJEF.js";
59
63
  import {
60
64
  capabilityDocument,
61
65
  operationForCli,
62
66
  parseCliResponse,
63
67
  validateRequest
64
- } from "./chunk-E4OWHGUE.js";
68
+ } from "./chunk-63JKCBC6.js";
65
69
  import "./chunk-BZLMF5O5.js";
66
70
 
67
71
  // src/cli.ts
@@ -1000,7 +1004,7 @@ function writeClientBackendConfig(runtime2, identity2, instance, options) {
1000
1004
  const inferredGateway = !configuredProvider && Boolean(
1001
1005
  env.AGENT_BRIDGE_TOKEN?.trim() || shared.AGENT_BRIDGE_TOKEN?.trim()
1002
1006
  );
1003
- const provider3 = configuredProvider === "legacy" || configuredProvider === "supabase" ? "legacy-supabase" : configuredProvider ?? (inferredGateway ? "gateway" : void 0);
1007
+ const provider3 = configuredProvider ?? (inferredGateway ? "gateway" : void 0);
1004
1008
  const clientToken = options.token?.trim() || env.AGENT_BRIDGE_CLIENT_TOKEN?.trim();
1005
1009
  if (provider3 === "gateway" && !clientToken) {
1006
1010
  throw new Error(
@@ -1028,7 +1032,6 @@ function writeClientBackendConfig(runtime2, identity2, instance, options) {
1028
1032
  AGENT_BRIDGE_WORKSPACE: resolved.principal.workspace,
1029
1033
  AGENT_BRIDGE_URL: resolved.url,
1030
1034
  AGENT_BRIDGE_TOKEN: resolved.provider === "gateway" ? resolved.credential : void 0,
1031
- AGENT_BRIDGE_KEY: resolved.provider === "legacy-supabase" ? resolved.credential : void 0,
1032
1035
  AGENT_BRIDGE_DB: resolved.provider === "local" ? resolved.databasePath : void 0,
1033
1036
  AGENT_BRIDGE_EDGE_DB: resolved.provider === "gateway" ? resolved.edgeDatabasePath : void 0,
1034
1037
  AGENT_BRIDGE_CREDENTIAL_ID: options.binding?.credentialId,
@@ -6227,7 +6230,16 @@ function edgeIdentity(path) {
6227
6230
  verifyPrivatePathAccess(path, "file");
6228
6231
  const details = lstatSync6(path);
6229
6232
  if (!details.isFile() || details.isSymbolicLink()) fail3("EDGE_ALIAS", "edge database is not a private regular file");
6230
- return { dev: details.dev, ino: details.ino };
6233
+ return { dev: details.dev, ino: details.ino, nlink: details.nlink };
6234
+ }
6235
+ function edgeIdentitiesAlias(left, right) {
6236
+ const leftHasFileId = left.dev !== 0 || left.ino !== 0;
6237
+ const rightHasFileId = right.dev !== 0 || right.ino !== 0;
6238
+ if (leftHasFileId && rightHasFileId) return left.dev === right.dev && left.ino === right.ino;
6239
+ if (left.nlink > 1 && right.nlink > 1) {
6240
+ fail3("EDGE_ALIAS", "edge file identity is ambiguous on this platform");
6241
+ }
6242
+ return false;
6231
6243
  }
6232
6244
  function managedEdgeCohort(metadata, edgePath, env, scopeKey) {
6233
6245
  const directory = dirname7(managedClientMetadataPath(metadata.runtime, metadata.instance, env));
@@ -6247,7 +6259,7 @@ function managedEdgeCohort(metadata, edgePath, env, scopeKey) {
6247
6259
  if (scopeKey !== void 0 && candidateScope !== scopeKey) continue;
6248
6260
  const candidateIdentity = edgeIdentity(candidateProjection.edgeDatabasePath);
6249
6261
  const samePath = resolve7(candidateProjection.edgeDatabasePath) === resolve7(edgePath);
6250
- const sameFile = edgePathIdentity !== null && candidateIdentity !== null && edgePathIdentity.dev === candidateIdentity.dev && edgePathIdentity.ino === candidateIdentity.ino;
6262
+ const sameFile = edgePathIdentity !== null && candidateIdentity !== null && edgeIdentitiesAlias(edgePathIdentity, candidateIdentity);
6251
6263
  if (samePath || sameFile) matches.push(candidate.backendConfigPath);
6252
6264
  } catch {
6253
6265
  fail3("SHARED_EDGE_COHORT", "managed edge cohort could not be inspected");
@@ -6418,7 +6430,7 @@ function assertDistinctEdges(sourcePath, targetPath, requirePresent = true) {
6418
6430
  const source = edgeIdentity(sourcePath);
6419
6431
  const target = edgeIdentity(targetPath);
6420
6432
  if (requirePresent && (!source || !target)) fail3("EDGE_ALIAS", "source and target edge paths must be initialized before mutation");
6421
- if (source && target && source.dev === target.dev && source.ino === target.ino) {
6433
+ if (source && target && edgeIdentitiesAlias(source, target)) {
6422
6434
  fail3("EDGE_ALIAS", "source and target edges must not alias the same file");
6423
6435
  }
6424
6436
  }
@@ -8570,9 +8582,10 @@ var SUPPORTED_OPTIONS = /* @__PURE__ */ new Set([
8570
8582
  "recover-lock",
8571
8583
  "scope-set",
8572
8584
  "workspace-name",
8573
- "exclusive-edge"
8585
+ "exclusive-edge",
8586
+ "queue-only"
8574
8587
  ]);
8575
- var BOOLEAN_OPTIONS2 = /* @__PURE__ */ new Set(["apply", "dead", "force", "invalidate-immediately", "json", "latest", "recover-lock", "exclusive-edge"]);
8588
+ var BOOLEAN_OPTIONS2 = /* @__PURE__ */ new Set(["apply", "dead", "force", "invalidate-immediately", "json", "latest", "recover-lock", "exclusive-edge", "queue-only"]);
8576
8589
  function parse5(argv) {
8577
8590
  const command = argv[0] ?? "help";
8578
8591
  const options = {};
@@ -8644,7 +8657,7 @@ function cliOutput(operationId, value, invocation) {
8644
8657
  output(parseCliResponse(operationId, value, invocation));
8645
8658
  }
8646
8659
  function failedClientStatus(config, error, failure) {
8647
- const schemaVersion = config.provider === "legacy-supabase" ? "legacy-v1" : config.provider === "gateway" ? "postgres-v2" : "local-v2";
8660
+ const schemaVersion = config.provider === "gateway" ? "postgres-v2" : "local-v2";
8648
8661
  const remote = config.provider === "local" || !failure.remoteAttempted ? null : false;
8649
8662
  const localHealthy = failure.component !== "local-store";
8650
8663
  const code = error && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : "diagnostics_failed";
@@ -8701,13 +8714,8 @@ function watchCursorPath(path, project) {
8701
8714
  const scope = createHash9("sha256").update(project).digest("hex").slice(0, 16);
8702
8715
  return `${path}.project-${scope}`;
8703
8716
  }
8704
- function packageVersion() {
8705
- const manifest = JSON.parse(readFileSync8(fileURLToPath2(new URL("../package.json", import.meta.url)), "utf8"));
8706
- if (typeof manifest.version !== "string" || !manifest.version) throw new Error("package version is unavailable");
8707
- return manifest.version;
8708
- }
8709
8717
  function help() {
8710
- process.stdout.write(`agent-bridge: provider-neutral agent messaging
8718
+ process.stdout.write(`agent-bridge: messaging and work handoff for AI agents
8711
8719
 
8712
8720
  Commands:
8713
8721
  init, doctor, status, capabilities, pending, migrate, reconcile-legacy-projects, sync, demo, join, presence
@@ -8774,7 +8782,7 @@ async function initialize(options) {
8774
8782
  }
8775
8783
  const values = {
8776
8784
  AGENT_BRIDGE_PROVIDER: provider3,
8777
- AGENT_BRIDGE_WORKSPACE: one(options, "workspace") ?? process.env.AGENT_BRIDGE_WORKSPACE ?? (provider3 === "legacy-supabase" || provider3 === "legacy" || provider3 === "supabase" ? "*" : "default"),
8785
+ AGENT_BRIDGE_WORKSPACE: one(options, "workspace") ?? process.env.AGENT_BRIDGE_WORKSPACE ?? "default",
8778
8786
  AGENT_BRIDGE_DB: one(options, "db") ?? process.env.AGENT_BRIDGE_DB,
8779
8787
  AGENT_BRIDGE_EDGE_DB: process.env.AGENT_BRIDGE_EDGE_DB,
8780
8788
  AGENT_BRIDGE_URL: one(options, "url") ?? process.env.AGENT_BRIDGE_URL,
@@ -8833,9 +8841,6 @@ function configFor(options, command) {
8833
8841
  if (config.provider === "gateway" && assertedWorkspace && assertedWorkspace !== config.principal.workspace) {
8834
8842
  throw new Error("--workspace must match the workspace bound to the gateway credential");
8835
8843
  }
8836
- if (config.provider === "legacy-supabase" && assertedWorkspace && assertedWorkspace !== "*") {
8837
- throw new Error("--workspace is not supported by the global legacy Supabase schema");
8838
- }
8839
8844
  if (config.provider === "local" && assertedWorkspace && assertedWorkspace !== config.principal.workspace) {
8840
8845
  return resolveClientConfig(
8841
8846
  { ...environment, AGENT_BRIDGE_WORKSPACE: assertedWorkspace },
@@ -9166,16 +9171,16 @@ async function runCli(argv = process.argv.slice(2)) {
9166
9171
  }
9167
9172
  let runtime2;
9168
9173
  try {
9174
+ const queueOnly = command === "send" && boolean(options, "queue-only");
9169
9175
  runtime2 = await createClientRuntime(config, {
9170
- autoSync: command !== "doctor" && command !== "status",
9176
+ autoSync: command !== "doctor" && command !== "status" && !queueOnly,
9171
9177
  initializationMode: command === "status" ? "passive" : "active"
9172
9178
  });
9173
9179
  } catch (error) {
9174
9180
  if (command !== "doctor" && command !== "status") throw error;
9175
- const remoteInitialization = command === "doctor" && config.provider === "legacy-supabase";
9176
9181
  failedClientStatus(config, error, {
9177
- component: remoteInitialization ? "remote" : "local-store",
9178
- remoteAttempted: remoteInitialization
9182
+ component: "local-store",
9183
+ remoteAttempted: false
9179
9184
  });
9180
9185
  process.exitCode = 1;
9181
9186
  return;
@@ -9185,15 +9190,15 @@ async function runCli(argv = process.argv.slice(2)) {
9185
9190
  validateRequest("client_status", {});
9186
9191
  const active = command === "doctor";
9187
9192
  try {
9188
- const diagnostics = await runtime2.store.diagnostics?.(config.principal, { mode: active ? "probe" : "snapshot" }) ?? { schemaVersion: config.provider === "legacy-supabase" ? "legacy-v1" : "local-v2", deliverySupported: false, pending: null, claimed: null, retrying: null, dead: null };
9189
- const remoteReachable = "remoteReachable" in diagnostics ? diagnostics.remoteReachable ?? null : active && config.provider === "legacy-supabase" ? true : null;
9193
+ const diagnostics = await runtime2.store.diagnostics?.(config.principal, { mode: active ? "probe" : "snapshot" }) ?? { schemaVersion: "local-v2", deliverySupported: false, pending: null, claimed: null, retrying: null, dead: null };
9194
+ const remoteReachable = "remoteReachable" in diagnostics ? diagnostics.remoteReachable ?? null : null;
9190
9195
  const checks = [{
9191
9196
  name: "local-store",
9192
9197
  status: "ok",
9193
9198
  message: "local diagnostics are readable"
9194
9199
  }];
9195
9200
  if (config.provider !== "local") {
9196
- const provider3 = config.provider === "gateway" ? "gateway" : "legacy provider";
9201
+ const provider3 = "gateway";
9197
9202
  const remoteError2 = "remoteError" in diagnostics && typeof diagnostics.remoteError === "string" ? diagnostics.remoteError : void 0;
9198
9203
  checks.push({
9199
9204
  name: "remote",
@@ -9263,7 +9268,7 @@ async function runCli(argv = process.argv.slice(2)) {
9263
9268
  if (command === "send") {
9264
9269
  const message = draft(options, positionals);
9265
9270
  validateRequest("publish_message", { ...message, source: one(options, "source") });
9266
- cliOutput("publish_message", await runtime2.service.publish(config.principal, message));
9271
+ cliOutput("publish_message", await runtime2.service.publish(config.principal, message, { queueOnly: boolean(options, "queue-only") }));
9267
9272
  return;
9268
9273
  }
9269
9274
  if (command === "join") {
@@ -9289,14 +9294,14 @@ async function runCli(argv = process.argv.slice(2)) {
9289
9294
  const query = validateRequest("history", { cursor: one(options, "cursor"), limit: integer(options, "limit", 20), types: list(options, "type").concat(list(options, "category")), source: one(options, "source"), project: one(options, "project"), since: since(options), mailbox: command === "inbox" ? "inbox" : command === "sent" ? "sent" : one(options, "mailbox"), receiptState: one(options, "receipt-state"), unacknowledgedBy: assertedUnackedBy, threadId: one(options, "thread-id"), latest: raw === "get" || boolean(options, "latest") });
9290
9295
  const page = await runtime2.service.history(config.principal, query);
9291
9296
  if (raw === "get") {
9292
- cliOutput("history", page.messages.map((message) => ({ id: config.provider === "legacy-supabase" ? Number(message.sequence) : message.id, source: message.source, category: message.type, content: message.content, priority: message.priority, project: message.project ?? null, metadata: legacyContextMetadata(message), created_at: message.createdAt })), { command: raw, optionNames: Object.keys(options) });
9297
+ cliOutput("history", page.messages.map((message) => ({ id: message.id, source: message.source, category: message.type, content: message.content, priority: message.priority, project: message.project ?? null, metadata: legacyContextMetadata(message), created_at: message.createdAt })), { command: raw, optionNames: Object.keys(options) });
9293
9298
  } else cliOutput("history", page);
9294
9299
  return;
9295
9300
  }
9296
9301
  if (command === "acknowledge" || command === "ack" && one(options, "ids")) {
9297
9302
  const rawIds = list(options, "ids");
9298
9303
  validateRequest("record_receipt", { messageIds: rawIds });
9299
- const acknowledged = config.provider === "legacy-supabase" && runtime2.store.recordLegacyReceipt && rawIds.every((id) => /^\d+$/.test(id)) ? await runtime2.store.recordLegacyReceipt(rawIds, config.principal.agent) : await runtime2.service.acknowledge(
9304
+ const acknowledged = await runtime2.service.acknowledge(
9300
9305
  config.principal,
9301
9306
  rawIds.map(legacyNumericMessageId)
9302
9307
  );
@@ -9374,7 +9379,7 @@ async function runCli(argv = process.argv.slice(2)) {
9374
9379
  saveCursor(checkpointPath, current);
9375
9380
  interval = page.messages.length ? baseInterval : Math.min(maxInterval, Math.max(baseInterval, interval * 2));
9376
9381
  } catch (error) {
9377
- const status = error instanceof BridgeHttpError || error instanceof LegacySupabaseError ? error.status : void 0;
9382
+ const status = error instanceof BridgeHttpError ? error.status : void 0;
9378
9383
  const retryable = status !== void 0 && (status === 0 || status === 408 || status === 425 || status === 429 || status >= 500);
9379
9384
  if (!retryable) throw error;
9380
9385
  interval = Math.min(maxInterval, Math.max(baseInterval, interval * 2));