@creatornader/agent-bridge 0.2.0 → 0.3.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +63 -1
  2. package/README.md +467 -29
  3. package/ROADMAP.md +104 -0
  4. package/SECURITY.md +73 -0
  5. package/SKILL.md +68 -2
  6. package/bin/agent-bridge +2 -2
  7. package/clients/claude-desktop.json +3 -1
  8. package/dist/archive.d.ts +163 -0
  9. package/dist/archive.js +50 -0
  10. package/dist/archive.js.map +1 -0
  11. package/dist/bridge-domain-CBX3IVqC.d.ts +153 -0
  12. package/dist/{bridge-service-CfqMcMAn.d.ts → bridge-service-hX1ZQp4W.d.ts} +15 -5
  13. package/dist/bridge-store-DPVSCwfs.d.ts +102 -0
  14. package/dist/bridge.d.ts +76 -17
  15. package/dist/bridge.js +52 -24
  16. package/dist/chunk-2DFNOLMO.js +618 -0
  17. package/dist/chunk-2DFNOLMO.js.map +1 -0
  18. package/dist/{chunk-KVR4JBRF.js → chunk-2EVLG3YA.js} +2 -2
  19. package/dist/{chunk-KVR4JBRF.js.map → chunk-2EVLG3YA.js.map} +1 -1
  20. package/dist/chunk-45BZGB77.js +709 -0
  21. package/dist/chunk-45BZGB77.js.map +1 -0
  22. package/dist/chunk-4VB44KJU.js +230 -0
  23. package/dist/chunk-4VB44KJU.js.map +1 -0
  24. package/dist/chunk-5GMB3A77.js +1013 -0
  25. package/dist/chunk-5GMB3A77.js.map +1 -0
  26. package/dist/chunk-A6W4QALF.js +1258 -0
  27. package/dist/chunk-A6W4QALF.js.map +1 -0
  28. package/dist/chunk-BZLMF5O5.js +328 -0
  29. package/dist/chunk-BZLMF5O5.js.map +1 -0
  30. package/dist/{chunk-AXL2I7FH.js → chunk-CEXBMOI5.js} +240 -79
  31. package/dist/chunk-CEXBMOI5.js.map +1 -0
  32. package/dist/chunk-GADH244D.js +527 -0
  33. package/dist/chunk-GADH244D.js.map +1 -0
  34. package/dist/chunk-MBPZXTJA.js +2428 -0
  35. package/dist/chunk-MBPZXTJA.js.map +1 -0
  36. package/dist/chunk-NCO7RLBM.js +146 -0
  37. package/dist/chunk-NCO7RLBM.js.map +1 -0
  38. package/dist/chunk-Q6PPMXJC.js +1050 -0
  39. package/dist/chunk-Q6PPMXJC.js.map +1 -0
  40. package/dist/{chunk-4KAOBC5X.js → chunk-SPSMZOCJ.js} +190 -165
  41. package/dist/chunk-SPSMZOCJ.js.map +1 -0
  42. package/dist/chunk-UAHMP6GC.js +54 -0
  43. package/dist/chunk-UAHMP6GC.js.map +1 -0
  44. package/dist/{chunk-YD6YJATN.js → chunk-VOQIDTCJ.js} +4 -2
  45. package/dist/chunk-VOQIDTCJ.js.map +1 -0
  46. package/dist/chunk-WAI2IYIQ.js +554 -0
  47. package/dist/chunk-WAI2IYIQ.js.map +1 -0
  48. package/dist/cli.d.ts +2 -1
  49. package/dist/cli.js +3577 -250
  50. package/dist/cli.js.map +1 -1
  51. package/dist/client-config.d.ts +1 -1
  52. package/dist/client-config.js +1 -1
  53. package/dist/client-runtime.d.ts +10 -6
  54. package/dist/client-runtime.js +9 -6
  55. package/dist/contracts/generate.d.ts +2 -0
  56. package/dist/contracts/generate.js +247 -0
  57. package/dist/contracts/generate.js.map +1 -0
  58. package/dist/dr.d.ts +324 -0
  59. package/dist/dr.js +124 -0
  60. package/dist/dr.js.map +1 -0
  61. package/dist/gateway-CggQ8vTC.d.ts +78 -0
  62. package/dist/gateway-main.js +190 -8
  63. package/dist/gateway-main.js.map +1 -1
  64. package/dist/gateway.d.ts +4 -3
  65. package/dist/gateway.js +4 -3
  66. package/dist/index.js +11 -8
  67. package/dist/index.js.map +1 -1
  68. package/dist/postgres-bridge-store-Bfd3hRId.d.ts +49 -0
  69. package/dist/server.d.ts +3 -2
  70. package/dist/server.js +13 -8
  71. package/dist/sqlite.d.ts +94 -12
  72. package/dist/sqlite.js +7 -4
  73. package/docs/architecture-v2.md +375 -0
  74. package/docs/decisions/0001-protocol-layers-and-acknowledgment-semantics.md +85 -0
  75. package/docs/decisions/0002-canonical-operation-contract-registry.md +46 -0
  76. package/docs/ecosystem.md +54 -0
  77. package/docs/postmortems/2026-07-08-wrapper-source-drift.md +82 -0
  78. package/docs/troubleshooting.md +89 -0
  79. package/llms.txt +96 -4
  80. package/openapi/agent-bridge-v2.openapi.json +9610 -0
  81. package/package.json +24 -4
  82. package/schemas/agent-bridge-v2.capabilities.json +1829 -0
  83. package/schemas/agent-bridge-v2.mcp.json +2074 -0
  84. package/schemas/agent-bridge-v2.schema.json +4560 -0
  85. package/sql/migrations/008_message_projects.sql +36 -0
  86. package/sql/migrations/009_mailbox_query_indexes.sql +28 -0
  87. package/sql/migrations/010_publisher_delivery_policy.sql +210 -0
  88. package/sql/migrations/011_credential_security.sql +875 -0
  89. package/sql/migrations/012_request_authority.sql +177 -0
  90. package/sql/migrations/013_row_isolation.sql +495 -0
  91. package/sql/migrations/014_owner_control_plane.sql +1641 -0
  92. package/sql/migrations/015_portable_archives.sql +1813 -0
  93. package/sql/migrations/016_native_dr_fence.sql +1005 -0
  94. package/bin/CLAUDE.md +0 -11
  95. package/dist/bridge-domain-BcnBeHOn.d.ts +0 -97
  96. package/dist/bridge-store-BuGjxTn4.d.ts +0 -61
  97. package/dist/chunk-4KAOBC5X.js.map +0 -1
  98. package/dist/chunk-6MAZ6YLZ.js +0 -146
  99. package/dist/chunk-6MAZ6YLZ.js.map +0 -1
  100. package/dist/chunk-AXL2I7FH.js.map +0 -1
  101. package/dist/chunk-BV6W4AJK.js +0 -211
  102. package/dist/chunk-BV6W4AJK.js.map +0 -1
  103. package/dist/chunk-CKSKUBDQ.js +0 -153
  104. package/dist/chunk-CKSKUBDQ.js.map +0 -1
  105. package/dist/chunk-JOUBDRYX.js +0 -272
  106. package/dist/chunk-JOUBDRYX.js.map +0 -1
  107. package/dist/chunk-JTC5YURG.js +0 -49
  108. package/dist/chunk-JTC5YURG.js.map +0 -1
  109. package/dist/chunk-O26W5QHS.js +0 -409
  110. package/dist/chunk-O26W5QHS.js.map +0 -1
  111. package/dist/chunk-WEULPMUY.js +0 -988
  112. package/dist/chunk-WEULPMUY.js.map +0 -1
  113. package/dist/chunk-YD6YJATN.js.map +0 -1
  114. package/dist/gateway-BULozv3K.d.ts +0 -54
package/ROADMAP.md ADDED
@@ -0,0 +1,104 @@
1
+ # Agent Bridge roadmap
2
+
3
+ Agent Bridge is working toward one specific role: durable messaging and work delivery
4
+ between agent runtimes that do not share a process, vendor, session, or machine.
5
+
6
+ This roadmap separates released behavior from code that has not reached a public
7
+ release. A merged implementation is not considered shipped until the package is
8
+ published and the supported clients pass a fresh end-to-end check.
9
+
10
+ ## Status
11
+
12
+ ### Released in 0.2.0
13
+
14
+ - Local SQLite and shared PostgreSQL storage behind provider-neutral interfaces.
15
+ - An authenticated HTTPS gateway and a named legacy Supabase adapter.
16
+ - Immutable messages, caller receipts, delivery leases, retries, dead letters, and
17
+ presence.
18
+ - Durable SQLite edge outbox and inbox cache for gateway clients.
19
+ - CLI, MCP, Codex, Claude Code, and Claude Desktop integration paths.
20
+
21
+ ### Implemented for the next release
22
+
23
+ - Caller-bound inbox, sent, and combined history with scope-bound cursors.
24
+ - Publisher-owned delivery policy, priority claims, cancel, requeue, and delivery event
25
+ inspection.
26
+ - Canonical TypeBox operation definitions that generate JSON Schema, OpenAPI, MCP, and
27
+ capability artifacts.
28
+ - Credential scopes, rate policy, transaction-bound PostgreSQL request authority, and
29
+ forced row isolation.
30
+ - Offline owner commands for credential provisioning, inventory, rotation, and
31
+ revocation.
32
+ - Claude Desktop registration with absolute launcher paths that do not depend on the
33
+ application's inherited shell `PATH`.
34
+ - Portable workspace archives across canonical SQLite and PostgreSQL stores.
35
+ - Native SQLite and PostgreSQL backup, verification, and restore.
36
+
37
+ ### Required before the next release is complete
38
+
39
+ - Merge the development branch through the protected-main checks.
40
+ - Publish the package through the configured npm OIDC workflow.
41
+ - Prove Codex, Claude Code, and Claude Desktop startup, send, receive, receipt, claim,
42
+ settlement, offline replay, and restart behavior against the released package.
43
+ - Move the project's own normal traffic to v2 while retaining a tested v1 rollback path.
44
+ - Replace remaining direct legacy table pollers with the v2 cursor protocol.
45
+ - Confirm the README, npm metadata, GitHub metadata, release notes, and package contents
46
+ match the released artifact.
47
+
48
+ ## Near-term work
49
+
50
+ ### Installation and operations
51
+
52
+ - Add client repair, update, uninstall, and registration diagnostics.
53
+ - Provide a Compose-based development deployment and a production deployment guide.
54
+ - Add endpoint migration tooling that does not strand an existing SQLite outbox.
55
+ - Publish a maintained client compatibility matrix.
56
+
57
+ ### Storage lifecycle and observability
58
+
59
+ - Define retention separately from logical message immutability.
60
+ - Add audited archive and purge operations for expired data.
61
+ - Bound edge caches and resolve abandoned outbox state.
62
+ - Add workspace quotas, principal limits, queue-depth diagnostics, and capacity alerts.
63
+ - Maintain credential use and administrative audit records without logging secrets.
64
+
65
+ ### Presence and wakeups
66
+
67
+ - Maintain heartbeat and expiry automatically for supported long-lived clients.
68
+ - Add wake adapters only where they reduce latency. Lost wakeups must never lose data.
69
+ - Keep cursored pull as the authoritative recovery path.
70
+
71
+ ### Failure and performance evidence
72
+
73
+ - Measure install-to-first-message time and local and gateway latency.
74
+ - Test concurrent claims, SQLite lock contention, queue growth, duplicate suppression,
75
+ lease expiry, and crash recovery.
76
+ - Exercise gateway restarts, database outages, network partitions, clock skew, cache
77
+ corruption, and interrupted migrations.
78
+ - Publish the test setup and results instead of making unsupported throughput claims.
79
+
80
+ ## Ecosystem work
81
+
82
+ - Build an agmsg adapter for send, inbox, history, claim, and settlement operations.
83
+ - Carry A2A envelopes without implementing a competing task state machine.
84
+ - Publish conformance fixtures and an adapter template.
85
+ - Add client libraries where real integrations need them.
86
+ - Expand runtime installers after each host has a stable configuration contract.
87
+
88
+ See [docs/ecosystem.md](docs/ecosystem.md) for the product boundary.
89
+
90
+ ## Project and community work
91
+
92
+ - Add contribution and support policies, issue templates, and a reviewable governance
93
+ path.
94
+ - Publish a local two-agent demo and a cross-machine recovery demo.
95
+ - Track completed cross-runtime deliveries and successful second-principal activation.
96
+ Any product telemetry must be opt-in.
97
+ - Review compatibility on every release and revisit interoperability choices each
98
+ quarter.
99
+
100
+ ## Deferred
101
+
102
+ JetStream or another required broker, a large dashboard, Kubernetes packaging, and
103
+ end-to-end payload encryption remain deferred until measurements or users justify the
104
+ extra operational and security work.
package/SECURITY.md ADDED
@@ -0,0 +1,73 @@
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ | Version | Security updates |
6
+ | --- | --- |
7
+ | 0.2.x | Supported until its successor is released |
8
+ | 0.1.x | Not supported |
9
+ | Unreleased development code | No public support guarantee |
10
+
11
+ Upgrade to the latest published package before reporting a defect that may already be
12
+ fixed. The npm package and GitHub release page are the public version authorities.
13
+
14
+ ## Report a vulnerability
15
+
16
+ Use [GitHub private vulnerability reporting](https://github.com/creatornader/agent-bridge/security/advisories/new).
17
+ Do not open a public issue for a suspected vulnerability.
18
+
19
+ Include the affected version, provider mode, operating system, reproduction steps, and
20
+ the security boundary that failed. Remove bearer tokens, raw credential files, database
21
+ URLs, message content, archive data, and disaster-recovery bundles. The maintainer will
22
+ coordinate disclosure and remediation through the private advisory.
23
+
24
+ ## Security boundaries
25
+
26
+ ### Local mode
27
+
28
+ Local mode relies on operating-system account isolation and private file permissions.
29
+ Anyone who can act as the same operating-system user can generally read or replace that
30
+ user's Agent Bridge state. Local mode is not a hostile multi-user boundary.
31
+
32
+ ### Gateway mode
33
+
34
+ Gateway credentials bind one workspace and principal. The gateway derives remote
35
+ identity from the credential, applies operation scopes and rate policy, and uses
36
+ transaction-bound PostgreSQL request authority. Production runtime roles must not be
37
+ superusers or hold `BYPASSRLS`. Put every non-loopback gateway behind TLS.
38
+
39
+ Keep the schema-owner, runtime, operator, archive, backup, and restore database
40
+ authorities separate. Do not copy one client's token or backend file into another
41
+ client's configuration.
42
+
43
+ ### Legacy Supabase mode
44
+
45
+ The legacy adapter keeps existing v1 deployments working, but its publishable key can
46
+ call the underlying PostgREST table and receipt RPC directly. Adapter checks therefore
47
+ provide cooperative behavior, not the same workspace and principal isolation as the
48
+ authenticated gateway. Do not use legacy mode as a hostile multi-tenant boundary.
49
+
50
+ ### Archives and disaster recovery
51
+
52
+ Portable archives and native DR bundles may contain message content, routing metadata,
53
+ credentials, or database state. Their hashes detect changed bytes. They do not encrypt
54
+ the files or authenticate their source. Store them as private data and transfer them
55
+ through a separately trusted channel.
56
+
57
+ PostgreSQL restore executes SQL from the source dump. Use
58
+ `--accept-source-sql-risk` only for a bundle from a trusted source. Never activate the
59
+ source and restored target as authorities at the same time.
60
+
61
+ ### Optional integrations
62
+
63
+ Agent Bridge does not require atrib or another provenance system. A signed wrapper is a
64
+ separate security and availability boundary. Keep a direct Agent Bridge path available
65
+ when wrapper health is uncertain.
66
+
67
+ ## Secret handling
68
+
69
+ - Pass gateway tokens through private enrollment or backend files, not shell arguments.
70
+ - Keep database URLs in the documented environment variables. Do not put them in CLI
71
+ arguments, logs, issues, or examples.
72
+ - Treat client backend files, enrollment files, archives, and DR bundles as secrets.
73
+ - Sanitize `doctor` output and logs before sharing them publicly.
package/SKILL.md CHANGED
@@ -5,10 +5,23 @@ description: Share context and reliable work between agents across runtimes and
5
5
 
6
6
  # Agent Bridge
7
7
 
8
+ Discover the active v2 operation contract with MCP `capabilities`, CLI `agent-bridge capabilities`, or authenticated `GET /v2/capabilities`. Released 2.0 clients continue to work after the gateway is upgraded. A new 2.1 client must receive complete, consistent negotiation headers that select and advertise 2.1 before it mutates remote state. If the probe is headerless, selects 2.0, or returns partial or contradictory headers, do not mutate. Upgrade the gateway first instead of downgrading the client.
9
+
8
10
  Use the Agent Bridge MCP tools for normal traffic. Let the active runtime supply its own identity. Do not pass a literal source unless a standalone CLI process has no configured identity.
9
11
 
12
+ If the MCP server is unavailable or disconnects, report the outage instead of implying
13
+ that a post, read, or acknowledgment succeeded. Run `agent-bridge doctor --json` from a
14
+ shell and follow [docs/troubleshooting.md](docs/troubleshooting.md). Reinstall the client
15
+ registration if its executable or environment is stale.
16
+
17
+ History defaults to `inbox` (broadcasts and messages targeted to your configured identity). Use `sent` for messages you published or `mailbox: all` for the union. Receipt state is caller-relative; use `unread` or `read` only with inbox. Deprecated `unacked_by` and `--unacked-by` values must equal your configured identity.
18
+
10
19
  At session start, call `get_context` with a small limit. Summarize relevant unacknowledged entries, then call `ack_context` with the IDs you handled.
11
20
 
21
+ In gateway mode, long-lived MCP clients sync automatically. Call the MCP `sync` tool to trigger bounded outbox replay and inbox cache refresh manually.
22
+
23
+ Use `agent-bridge status` for a passive operational snapshot. Do not use it as a connectivity probe. Unprobed remote reachability is unknown, not healthy. Use `agent-bridge doctor` for active checks. Doctor exits 0 when ok, 2 when degraded, and 1 when checks fail. Treat blocked outbox rows as intervention-required even if a later send or pull succeeded. Distinguish due, scheduled, and leased work.
24
+
12
25
  Post context as events happen when another agent would need the information later:
13
26
 
14
27
  - `goal-update`: material progress, decisions, or completed research
@@ -17,8 +30,61 @@ Post context as events happen when another agent would need the information late
17
30
  - `operational`: runtime and repository handoffs
18
31
  - `bridge-meta`: limitations or proposed improvements to Agent Bridge
19
32
 
20
- Use v2 delivery tools for executable work. A read receipt does not claim work. Claim a delivery before acting, renew long leases, acknowledge success, and negatively acknowledge retryable or dead work with a bounded error.
33
+ Use v2 delivery tools for executable work. MCP `ack_context` and CLI `acknowledge` write read receipts. MCP `acknowledge` and CLI `ack` settle claimed deliveries. A read receipt does not claim or settle work, and delivery settlement does not create a receipt.
34
+
35
+ Publish executable work with `deliveryPolicy`; consumers never select retry limits or backoff. Leased policy accepts `maxAttempts`, `retryBaseDelayMs`, `retryMaxDelayMs`, `retryJitterRatio`, and optional `notBefore`. Untargeted messages default to mailbox mode and targeted messages to leased mode. Only publishers cancel or requeue. Publishers and recipients can inspect delivery history. Requeue starts a new cycle without resetting lifetime attempts. Consumer `maxAttempts` on claim and `retryPolicy` on nack are validated but ignored for one compatibility release. External task completion stays outside Agent Bridge.
21
36
 
22
- Use `agent-bridge pending` as a cheap process gate before starting an agent. Exit 0 means unread context or due delivery work exists. Exit 1 means neither exists. Treat network errors as unknown state, not as an empty queue.
37
+ Claim a delivery before acting. Renew a long lease only to retain ownership. A lease extension does not report progress or success. Record external task completion through the application or A2A protocol, then settle the Agent Bridge delivery separately.
38
+
39
+ Use `agent-bridge pending` as a cheap process gate before starting an agent. Exit 0 means unread candidates or due delivery work are visible. Exit 1 means the authoritative state is empty. Exit 2 means the remote state is unknown. During a gateway outage, cached unacknowledged results are degraded candidates with unknown acknowledgement state.
23
40
 
24
41
  Keep side effects idempotent. Agent Bridge provides at-least-once delivery and idempotent message insertion, not exactly-once execution.
42
+
43
+ Owner administration is an offline operator task. Use `agent-bridge owner provision`,
44
+ `inventory`, `rotate`, or `revoke` with
45
+ `AGENT_BRIDGE_OPERATOR_DATABASE_URL`. Do not route these commands through MCP or
46
+ HTTP. Provision and rotation produce a private enrollment file. Pass that file to
47
+ `agent-bridge clients install <runtime> --enrollment-file <path>`; never copy its raw
48
+ token into an argument or another client's environment. If the owner process stops,
49
+ resume from the same file instead of generating a new token or request UUID.
50
+ If a crash leaves the adjacent enrollment lock, wait at least 60 seconds and pass
51
+ `--recover-lock` with the resume or install command. Recovery must prove that the
52
+ same-host process recorded in the lock has stopped. Never remove the lock manually.
53
+
54
+ Portable archive work is an offline operator task, not normal MCP traffic. Use
55
+ `agent-bridge archive export --provider local|postgres --workspace <workspace>
56
+ --output <file>` to create an archive, then run `agent-bridge archive verify --file
57
+ <file>` before moving or importing it. Archive files and their directories must satisfy
58
+ the current user's private-path policy. Import replays three bounded passes through one
59
+ open descriptor. It is a dry run unless `--apply` is explicit; `--dry-run` and
60
+ `--apply` cannot be combined. Provide `--workspace` on import when the destination must
61
+ match an expected tenant. PostgreSQL archive commands accept only
62
+ `AGENT_BRIDGE_ARCHIVE_DATABASE_URL`.
63
+ Portable v1 requires current-domain records, lowercase UUIDs, and six-digit UTC
64
+ timestamps. It does not repair legacy or direct database rows. Use native database
65
+ recovery for rows that fail export validation.
66
+ Set and retain `--request-id` for export. The archive header records it as
67
+ `exportRequestId`; verification and import return that provenance. An import
68
+ `--request-id` identifies the destination operation and is independent. Retry an
69
+ export ID only with the same private output file. The CLI verifies completed exports
70
+ and reconciles matching started exports without streaming a new snapshot. Temporary
71
+ and backup files have deterministic adjacent names derived from the export ID. Follow
72
+ returned recovery paths and audit status exactly when replacement, cleanup, or audit
73
+ completion is uncertain.
74
+ Do not treat the archive digest as encryption or authentication. Archives contain
75
+ messages and read receipts but exclude deliveries, events, presence, credentials,
76
+ control records, and security state.
77
+
78
+ Native DR is also an offline operator task. Use `agent-bridge dr backup|verify|restore`
79
+ for one complete SQLite or PostgreSQL authority. Local DR accepts the SQLite authority,
80
+ not the gateway edge store. PostgreSQL backup and restore authority come only from
81
+ `AGENT_BRIDGE_DR_SOURCE_DATABASE_URL` and
82
+ `AGENT_BRIDGE_DR_TARGET_DATABASE_URL`. PostgreSQL restore needs a fresh same-name,
83
+ same-major database, a superuser, an explicit request ID, and
84
+ `--accept-source-sql-risk`. Never activate the source and restored target together.
85
+ Treat the bundle as private database material; its hashes do not encrypt or authenticate
86
+ the source.
87
+
88
+ Use `project` only as an optional message label. Workspace remains the tenant and credential boundary. Omit a project filter to read labeled and unlabeled messages, or provide one for an exact match. Reusing a workspace/source idempotency key with a different project is a conflict.
89
+
90
+ For gateway mode, treat the credential-bound workspace and principal returned by the server as authoritative. Instance identifies one runtime of that same principal; it cannot select a workspace, agent, or scopes. A production gateway reports row isolation only when transaction-bound request authority and every database readiness check pass. RLS isolates workspace and principal rows. The service still enforces lease transitions and target-to-delivery membership.
package/bin/agent-bridge CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { runCli } from "../dist/cli.js";
2
+ import { formatCliError, runCli } from "../dist/cli.js";
3
3
 
4
4
  runCli().catch((error) => {
5
- process.stderr.write(`Error: ${error instanceof Error ? error.message : String(error)}\n`);
5
+ process.stderr.write(formatCliError(error));
6
6
  process.exitCode = 1;
7
7
  });
@@ -2,7 +2,8 @@
2
2
  "schema": "agent-bridge.runtime-manifest.v1",
3
3
  "runtime": "claude-desktop",
4
4
  "transport": "stdio",
5
- "command": "agent-bridge-mcp",
5
+ "command": "{{absoluteNodeExecutable}}",
6
+ "args": ["{{absoluteServerEntry}}"],
6
7
  "identity": { "source": "env", "variable": "AGENT_BRIDGE_AGENT", "required": true },
7
8
  "instance": { "source": "env", "variable": "AGENT_BRIDGE_INSTANCE", "required": true },
8
9
  "backendConfig": { "source": "env", "variable": "AGENT_BRIDGE_CONFIG", "perClient": true },
@@ -13,6 +14,7 @@
13
14
  "identityValue": "operator-selected",
14
15
  "instanceValue": "installer-generated",
15
16
  "backendConfigValue": "installer-generated",
17
+ "launchValue": "installer-resolved-absolute",
16
18
  "restartRequired": true
17
19
  },
18
20
  "wakeModes": ["poll"],
@@ -0,0 +1,163 @@
1
+ import { J as JsonValue, i as MessagePriority, f as DeliveryPolicy } from './bridge-domain-CBX3IVqC.js';
2
+ import { P as PgQueryable } from './postgres-bridge-store-Bfd3hRId.js';
3
+ import './bridge-store-DPVSCwfs.js';
4
+
5
+ interface PortableArchiveMessage {
6
+ id: string;
7
+ project: string | null;
8
+ source: string;
9
+ type: string;
10
+ content: string;
11
+ contentType: string;
12
+ data: JsonValue | null;
13
+ targets: string[];
14
+ threadId: string | null;
15
+ replyToId: string | null;
16
+ correlationId: string | null;
17
+ causationId: string | null;
18
+ priority: MessagePriority;
19
+ expiresAt: string | null;
20
+ idempotencyKey: string | null;
21
+ atribReceiptId: string | null;
22
+ informedBy: string[];
23
+ metadata: JsonValue | null;
24
+ deliveryPolicy: DeliveryPolicy;
25
+ createdAt: string;
26
+ }
27
+ interface PortableArchiveReceipt {
28
+ messageId: string;
29
+ principal: string;
30
+ readAt: string;
31
+ }
32
+ /** In-memory helper used by format tests and small programmatic archives. Stores do not use it. */
33
+ interface PortableArchiveContents {
34
+ exportRequestId: string;
35
+ workspace: string;
36
+ messages: PortableArchiveMessage[];
37
+ receipts: PortableArchiveReceipt[];
38
+ digest?: string;
39
+ }
40
+ interface PortableArchiveMetadata {
41
+ exportRequestId: string;
42
+ workspace: string;
43
+ digest: string;
44
+ messageCount: number;
45
+ receiptCount: number;
46
+ }
47
+ type PortableArchiveAbandonCode = "stream_failed" | "snapshot_failed" | "publication_failed" | "audit_failed" | "not_published";
48
+ interface PortableArchiveExportSession {
49
+ messages(): AsyncIterable<PortableArchiveMessage>;
50
+ receipts(): AsyncIterable<PortableArchiveReceipt>;
51
+ complete(result: PortableArchiveMetadata & {
52
+ publishedAt: string;
53
+ }): Promise<void>;
54
+ reconcile(result: PortableArchiveMetadata & {
55
+ publishedAt: string;
56
+ }): Promise<void>;
57
+ abandon(reason: PortableArchiveAbandonCode): Promise<void>;
58
+ close(): Promise<void> | void;
59
+ }
60
+ type PortableArchiveExportStart = {
61
+ status: "active";
62
+ session: PortableArchiveExportSession;
63
+ replayed: boolean;
64
+ } | {
65
+ status: "completed";
66
+ metadata: PortableArchiveMetadata & {
67
+ publishedAt: string;
68
+ };
69
+ };
70
+ interface PortableArchiveImportPasses {
71
+ messageBatches(): AsyncIterable<readonly PortableArchiveMessage[]>;
72
+ receiptBatches(): AsyncIterable<readonly PortableArchiveReceipt[]>;
73
+ }
74
+ interface PortableArchiveResult {
75
+ requestId: string;
76
+ workspace: string;
77
+ digest: string;
78
+ apply: boolean;
79
+ messages: {
80
+ created: number;
81
+ replayed: number;
82
+ };
83
+ receipts: {
84
+ created: number;
85
+ replayed: number;
86
+ };
87
+ }
88
+ interface PortableArchiveStore {
89
+ beginExport(requestId: string, workspace: string): Promise<PortableArchiveExportStart>;
90
+ importWorkspace(requestId: string, metadata: PortableArchiveMetadata, passes: PortableArchiveImportPasses, options: {
91
+ apply: boolean;
92
+ }): Promise<PortableArchiveResult>;
93
+ close?(): Promise<void> | void;
94
+ }
95
+
96
+ declare const PORTABLE_ARCHIVE_FORMAT = "agent-bridge.portable-archive";
97
+ declare const PORTABLE_ARCHIVE_VERSION = 1;
98
+ declare const PORTABLE_ARCHIVE_MAX_LINE_BYTES: number;
99
+ declare const PORTABLE_ARCHIVE_MAX_BYTES: number;
100
+ declare const PORTABLE_ARCHIVE_BATCH_BYTES: number;
101
+ declare const PORTABLE_ARCHIVE_BATCH_ROWS = 1000;
102
+ declare class PortableArchiveError extends Error {
103
+ readonly code = "invalid_portable_archive";
104
+ constructor(message: string);
105
+ }
106
+ declare function canonicalJson(value: unknown): string;
107
+ declare function normalizeArchiveTimestamp(value: unknown, field: string): string;
108
+ declare function validateArchiveWorkspace(value: unknown): string;
109
+ declare function validatePortableArchiveRequestId(value: unknown): string;
110
+ declare function parsePortableArchiveMessage(value: unknown): PortableArchiveMessage;
111
+ declare function parsePortableArchiveReceipt(value: unknown): PortableArchiveReceipt;
112
+ declare function encodePortableArchive(contents: PortableArchiveContents): Buffer;
113
+ declare function decodePortableArchive(input: Uint8Array): PortableArchiveContents & {
114
+ digest: string;
115
+ };
116
+
117
+ declare class PortableArchiveFile implements PortableArchiveImportPasses {
118
+ readonly path: string;
119
+ private readonly descriptor;
120
+ private readonly identity;
121
+ private closed;
122
+ private verified?;
123
+ constructor(path: string);
124
+ private assertIdentity;
125
+ private lines;
126
+ private validatedRecords;
127
+ verify(): PortableArchiveMetadata;
128
+ proveDurable(): void;
129
+ messageBatches(): AsyncIterable<readonly PortableArchiveMessage[]>;
130
+ receiptBatches(): AsyncIterable<readonly PortableArchiveReceipt[]>;
131
+ close(): void;
132
+ }
133
+
134
+ declare function streamPortableArchive(session: PortableArchiveExportSession, workspaceValue: string, exportRequestIdValue: string, write: (bytes: Buffer) => void | Promise<void>): Promise<PortableArchiveMetadata>;
135
+ /** Small in-memory compatibility helper. It abandons the durable export audit. */
136
+ declare function exportPortableArchive(store: PortableArchiveStore, workspace: string, exportRequestIdValue: string): Promise<Buffer>;
137
+ /** Small in-memory compatibility helper. CLI imports use PortableArchiveFile instead. */
138
+ declare function importPortableArchive(store: PortableArchiveStore, bytes: Uint8Array, options: {
139
+ requestId: string;
140
+ apply?: boolean;
141
+ }): Promise<PortableArchiveResult>;
142
+
143
+ declare class SQLitePortableArchiveStore implements PortableArchiveStore {
144
+ private readonly path;
145
+ private readonly db;
146
+ constructor(path: string);
147
+ beginExport(requestIdValue: string, workspaceValue: string): Promise<PortableArchiveExportStart>;
148
+ importWorkspace(requestId: string, archive: PortableArchiveMetadata, passes: PortableArchiveImportPasses, options: {
149
+ apply: boolean;
150
+ }): Promise<PortableArchiveResult>;
151
+ close(): void;
152
+ }
153
+
154
+ declare class PostgresPortableArchiveStore implements PortableArchiveStore {
155
+ private readonly db;
156
+ constructor(db: PgQueryable);
157
+ beginExport(requestId: string, workspace: string): Promise<PortableArchiveExportStart>;
158
+ importWorkspace(requestId: string, metadata: PortableArchiveMetadata, passes: PortableArchiveImportPasses, options: {
159
+ apply: boolean;
160
+ }): Promise<PortableArchiveResult>;
161
+ }
162
+
163
+ export { PORTABLE_ARCHIVE_BATCH_BYTES, PORTABLE_ARCHIVE_BATCH_ROWS, PORTABLE_ARCHIVE_FORMAT, PORTABLE_ARCHIVE_MAX_BYTES, PORTABLE_ARCHIVE_MAX_LINE_BYTES, PORTABLE_ARCHIVE_VERSION, type PortableArchiveAbandonCode, type PortableArchiveContents, PortableArchiveError, type PortableArchiveExportSession, type PortableArchiveExportStart, PortableArchiveFile, type PortableArchiveImportPasses, type PortableArchiveMessage, type PortableArchiveMetadata, type PortableArchiveReceipt, type PortableArchiveResult, type PortableArchiveStore, PostgresPortableArchiveStore, SQLitePortableArchiveStore, canonicalJson, decodePortableArchive, encodePortableArchive, exportPortableArchive, importPortableArchive, normalizeArchiveTimestamp, parsePortableArchiveMessage, parsePortableArchiveReceipt, streamPortableArchive, validateArchiveWorkspace, validatePortableArchiveRequestId };
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ PORTABLE_ARCHIVE_BATCH_BYTES,
4
+ PORTABLE_ARCHIVE_BATCH_ROWS,
5
+ PORTABLE_ARCHIVE_FORMAT,
6
+ PORTABLE_ARCHIVE_MAX_BYTES,
7
+ PORTABLE_ARCHIVE_MAX_LINE_BYTES,
8
+ PORTABLE_ARCHIVE_VERSION,
9
+ PortableArchiveError,
10
+ PortableArchiveFile,
11
+ PostgresPortableArchiveStore,
12
+ SQLitePortableArchiveStore,
13
+ canonicalJson,
14
+ decodePortableArchive,
15
+ encodePortableArchive,
16
+ exportPortableArchive,
17
+ importPortableArchive,
18
+ normalizeArchiveTimestamp,
19
+ parsePortableArchiveMessage,
20
+ parsePortableArchiveReceipt,
21
+ streamPortableArchive,
22
+ validateArchiveWorkspace,
23
+ validatePortableArchiveRequestId
24
+ } from "./chunk-A6W4QALF.js";
25
+ import "./chunk-NCO7RLBM.js";
26
+ import "./chunk-BZLMF5O5.js";
27
+ export {
28
+ PORTABLE_ARCHIVE_BATCH_BYTES,
29
+ PORTABLE_ARCHIVE_BATCH_ROWS,
30
+ PORTABLE_ARCHIVE_FORMAT,
31
+ PORTABLE_ARCHIVE_MAX_BYTES,
32
+ PORTABLE_ARCHIVE_MAX_LINE_BYTES,
33
+ PORTABLE_ARCHIVE_VERSION,
34
+ PortableArchiveError,
35
+ PortableArchiveFile,
36
+ PostgresPortableArchiveStore,
37
+ SQLitePortableArchiveStore,
38
+ canonicalJson,
39
+ decodePortableArchive,
40
+ encodePortableArchive,
41
+ exportPortableArchive,
42
+ importPortableArchive,
43
+ normalizeArchiveTimestamp,
44
+ parsePortableArchiveMessage,
45
+ parsePortableArchiveReceipt,
46
+ streamPortableArchive,
47
+ validateArchiveWorkspace,
48
+ validatePortableArchiveRequestId
49
+ };
50
+ //# sourceMappingURL=archive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,153 @@
1
+ type JsonValue = null | boolean | number | string | JsonValue[] | {
2
+ [key: string]: JsonValue;
3
+ };
4
+ type DeliveryState = "pending" | "claimed" | "acked" | "retrying" | "dead" | "cancelled";
5
+ type MessagePriority = "info" | "high" | "urgent";
6
+ interface LeasedDeliveryPolicy {
7
+ mode: "leased";
8
+ maxAttempts: number;
9
+ retryBaseDelayMs: number;
10
+ retryMaxDelayMs: number;
11
+ retryJitterRatio: number;
12
+ notBefore?: string;
13
+ }
14
+ type DeliveryPolicy = {
15
+ mode: "mailbox";
16
+ } | LeasedDeliveryPolicy;
17
+ /** @deprecated Consumer retry policy is validated and ignored for one compatibility release. */
18
+ interface RetryPolicy {
19
+ maxAttempts: number;
20
+ baseDelayMs: number;
21
+ maxDelayMs: number;
22
+ jitterRatio: number;
23
+ }
24
+ type DeliveryAction = "created" | "claim" | "ack" | "nack_retry" | "nack_dead" | "lease_expired" | "attempts_exhausted" | "message_expired" | "cancel" | "requeue";
25
+ interface BridgePrincipal {
26
+ workspace: string;
27
+ agent: string;
28
+ instance?: string;
29
+ }
30
+ interface MessageDraft {
31
+ id?: string;
32
+ project?: string;
33
+ type: string;
34
+ content: string;
35
+ contentType?: string;
36
+ data?: JsonValue;
37
+ targets?: string[];
38
+ threadId?: string;
39
+ replyToId?: string;
40
+ correlationId?: string;
41
+ causationId?: string;
42
+ priority?: MessagePriority;
43
+ expiresAt?: string;
44
+ idempotencyKey?: string;
45
+ atribReceiptId?: string;
46
+ informedBy?: string[];
47
+ metadata?: JsonValue;
48
+ deliveryPolicy?: DeliveryPolicy | Record<string, unknown>;
49
+ }
50
+ interface BridgeMessage extends Required<Pick<MessageDraft, "id" | "type" | "content" | "contentType" | "targets" | "priority">> {
51
+ workspace: string;
52
+ project?: string;
53
+ source: string;
54
+ sequence: string;
55
+ createdAt: string;
56
+ data?: JsonValue;
57
+ threadId?: string;
58
+ replyToId?: string;
59
+ correlationId?: string;
60
+ causationId?: string;
61
+ expiresAt?: string;
62
+ idempotencyKey?: string;
63
+ atribReceiptId?: string;
64
+ informedBy?: string[];
65
+ metadata?: JsonValue;
66
+ deliveryPolicy: DeliveryPolicy;
67
+ }
68
+ interface BridgeDelivery {
69
+ id: string;
70
+ messageId: string;
71
+ workspace: string;
72
+ recipient: string;
73
+ state: DeliveryState;
74
+ attempt: number;
75
+ cycleAttempt: number;
76
+ requeueCount: number;
77
+ createdAt: string;
78
+ priorityRank: number;
79
+ availableAt: string;
80
+ leaseToken?: string;
81
+ leaseOwner?: string;
82
+ leaseExpiresAt?: string;
83
+ lastError?: string;
84
+ lastActor?: string;
85
+ lastAction: DeliveryAction;
86
+ }
87
+ interface BridgeDeliveryEvent {
88
+ sequence: string;
89
+ deliveryId: string;
90
+ messageId: string;
91
+ workspace: string;
92
+ recipient: string;
93
+ fromState?: DeliveryState;
94
+ toState: DeliveryState;
95
+ attempt: number;
96
+ cycleAttempt: number;
97
+ requeueCount: number;
98
+ leaseOwner?: string;
99
+ error?: string;
100
+ actor: string;
101
+ action: DeliveryAction;
102
+ createdAt: string;
103
+ }
104
+ interface AgentPresence {
105
+ workspace: string;
106
+ agent: string;
107
+ instance: string;
108
+ runtimeType?: string;
109
+ capabilities: string[];
110
+ leaseExpiresAt: string;
111
+ lastSeenAt: string;
112
+ }
113
+ declare class BridgeValidationError extends Error {
114
+ readonly code = "invalid_input";
115
+ }
116
+ declare class BridgePrincipalMismatchError extends Error {
117
+ readonly code = "principal_mismatch";
118
+ readonly status = 403;
119
+ }
120
+ declare class DeliveryStateConflictError extends Error {
121
+ readonly code = "delivery_state_conflict";
122
+ readonly status = 409;
123
+ }
124
+ declare function validateProject(value: unknown): string | undefined;
125
+ declare function uuidv7(now?: number): string;
126
+ declare function validatePrincipal(value: BridgePrincipal): BridgePrincipal;
127
+ declare function validateUuid(value: unknown, field: string): string;
128
+ declare function validateLeasedDeliveryPolicy(input?: Record<string, unknown>): LeasedDeliveryPolicy;
129
+ declare function validateDeliveryPolicy(input: Record<string, unknown> | null | undefined, targeted: boolean): DeliveryPolicy;
130
+ declare function validateMessageDraft(input: MessageDraft): Omit<BridgeMessage, "workspace" | "source" | "sequence" | "createdAt">;
131
+ interface CursorScopeQuery {
132
+ mailbox?: "inbox" | "sent" | "all";
133
+ receiptState?: "any" | "unread" | "read";
134
+ project?: string;
135
+ types?: string[];
136
+ includeExpired?: boolean;
137
+ source?: string;
138
+ since?: string;
139
+ threadId?: string;
140
+ }
141
+ declare function cursorScope(principal: BridgePrincipal, query: CursorScopeQuery): string;
142
+ declare function encodeCursor(sequence: string, scope?: string): string;
143
+ declare function decodeCursor(cursor: string | undefined, scope?: string): string | undefined;
144
+ declare function scopedCursorScope(kind: string, principal: BridgePrincipal, filters: JsonValue): string;
145
+ declare function encodeScopedCursor(scope: string, position: JsonValue): string;
146
+ declare function decodeScopedCursor(cursor: string | undefined, scope: string): JsonValue | undefined;
147
+ declare function validateDeliveryCursorPosition(position: JsonValue | undefined): {
148
+ createdAt: string;
149
+ id: string;
150
+ } | undefined;
151
+ declare function validateEventCursorPosition(position: JsonValue | undefined): string | undefined;
152
+
153
+ export { type AgentPresence as A, type BridgeDelivery as B, type DeliveryAction as D, type JsonValue as J, type LeasedDeliveryPolicy as L, type MessageDraft as M, type RetryPolicy as R, type BridgeDeliveryEvent as a, type BridgeMessage as b, type BridgePrincipal as c, BridgePrincipalMismatchError as d, BridgeValidationError as e, type DeliveryPolicy as f, type DeliveryState as g, DeliveryStateConflictError as h, type MessagePriority as i, cursorScope as j, decodeCursor as k, decodeScopedCursor as l, encodeCursor as m, encodeScopedCursor as n, validateDeliveryPolicy as o, validateEventCursorPosition as p, validateLeasedDeliveryPolicy as q, validateMessageDraft as r, scopedCursorScope as s, validatePrincipal as t, uuidv7 as u, validateDeliveryCursorPosition as v, validateProject as w, validateUuid as x };