@creatornader/agent-bridge 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +86 -4
  2. package/README.md +567 -55
  3. package/ROADMAP.md +114 -0
  4. package/SECURITY.md +90 -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 +3555 -214
  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 +394 -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/decisions/0003-host-adapters-and-consumer-instance-keys.md +88 -0
  77. package/docs/ecosystem.md +86 -0
  78. package/docs/postmortems/2026-07-08-wrapper-source-drift.md +82 -0
  79. package/docs/troubleshooting.md +89 -0
  80. package/llms.txt +107 -6
  81. package/openapi/agent-bridge-v2.openapi.json +9610 -0
  82. package/package.json +24 -4
  83. package/schemas/agent-bridge-v2.capabilities.json +1829 -0
  84. package/schemas/agent-bridge-v2.mcp.json +2074 -0
  85. package/schemas/agent-bridge-v2.schema.json +4560 -0
  86. package/sql/migrations/008_message_projects.sql +36 -0
  87. package/sql/migrations/009_mailbox_query_indexes.sql +28 -0
  88. package/sql/migrations/010_publisher_delivery_policy.sql +210 -0
  89. package/sql/migrations/011_credential_security.sql +875 -0
  90. package/sql/migrations/012_request_authority.sql +177 -0
  91. package/sql/migrations/013_row_isolation.sql +495 -0
  92. package/sql/migrations/014_owner_control_plane.sql +1641 -0
  93. package/sql/migrations/015_portable_archives.sql +1813 -0
  94. package/sql/migrations/016_native_dr_fence.sql +1005 -0
  95. package/bin/CLAUDE.md +0 -11
  96. package/dist/bridge-domain-BcnBeHOn.d.ts +0 -97
  97. package/dist/bridge-store-BuGjxTn4.d.ts +0 -61
  98. package/dist/chunk-4KAOBC5X.js.map +0 -1
  99. package/dist/chunk-6MAZ6YLZ.js +0 -146
  100. package/dist/chunk-6MAZ6YLZ.js.map +0 -1
  101. package/dist/chunk-AXL2I7FH.js.map +0 -1
  102. package/dist/chunk-BV6W4AJK.js +0 -211
  103. package/dist/chunk-BV6W4AJK.js.map +0 -1
  104. package/dist/chunk-CKSKUBDQ.js +0 -153
  105. package/dist/chunk-CKSKUBDQ.js.map +0 -1
  106. package/dist/chunk-JOUBDRYX.js +0 -272
  107. package/dist/chunk-JOUBDRYX.js.map +0 -1
  108. package/dist/chunk-JTC5YURG.js +0 -49
  109. package/dist/chunk-JTC5YURG.js.map +0 -1
  110. package/dist/chunk-O26W5QHS.js +0 -409
  111. package/dist/chunk-O26W5QHS.js.map +0 -1
  112. package/dist/chunk-WEULPMUY.js +0 -988
  113. package/dist/chunk-WEULPMUY.js.map +0 -1
  114. package/dist/chunk-YD6YJATN.js.map +0 -1
  115. package/dist/gateway-BULozv3K.d.ts +0 -54
package/CHANGELOG.md CHANGED
@@ -6,6 +6,85 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.1] - 2026-07-15
10
+
11
+ ### Added
12
+
13
+ - Add `agent-bridge --version` and `agent-bridge -V` commands that print the
14
+ installed package version without loading backend configuration.
15
+
16
+ ### Changed
17
+
18
+ - Clarify the boundary between agent harnesses, host applications, host adapters, and
19
+ MCP, CLI, HTTPS, and Node library access. Define `AGENT_BRIDGE_INSTANCE` as the
20
+ stable consumer key used for cursor paths, leases, and presence. Supported installers
21
+ generate this key, while direct clients may supply it. Document the released
22
+ no-instance fallbacks and the fact that the key is not a unique live process or
23
+ session.
24
+ - Require manual release recovery to run the workflow at the tag it publishes so npm
25
+ provenance identifies the checked-out release source.
26
+
27
+ ## [0.3.0] - 2026-07-15
28
+
29
+ ### Control, portability, and recovery
30
+
31
+ #### Added
32
+
33
+ - Additive PostgreSQL migration 014 with database-specific owner, operator, and auditor roles. Protected SQL functions register operator and auditor logins in an append-only membership ledger. Owner functions provision more than one principal per workspace, rotate or revoke credentials with exact concurrent replay, and expose bounded keyset inventory without credential hashes. Rotation checks its requested workspace and principal under the predecessor row lock and returns the canonical identity. Fixed-origin expression indexes serve global and workspace inventory. The migration refuses critical dependency or privilege drift before recording a scoped catalog attestation. PostgreSQL 15, 16, 17, and 18 use separately certified prerequisite digests; unknown future majors fail closed.
34
+ - Offline `agent-bridge owner` commands for provisioning, inventory, rotation, and revocation through a dedicated operator database URL. Provision and rotation use private, revisioned enrollment files with an exclusive operation lock and compare-and-swap transitions. The client installer consumes those files without putting raw credentials in command arguments. Rotation requires exact predecessor metadata and live host registration before replacing one backend file.
35
+ - Canonical portable workspace archives for local SQLite and shared PostgreSQL stores. `agent-bridge archive export`, `verify`, and dry-run-first `import` move immutable messages and read receipts without copying delivery, presence, credential, control, or security state. The package exports the provider-neutral archive API from `@creatornader/agent-bridge/archive`.
36
+ - Native SQLite and PostgreSQL disaster recovery through `agent-bridge dr backup`, `verify`, and `restore`. The common private bundle records provider-specific schema metadata and hashes. Local backup uses SQLite's online backup API and rejects gateway edge stores. PostgreSQL backup captures the schema, bounded role inventory, memberships, default privileges, readiness attestations, and recoverable data across PostgreSQL 15 through 18. The package exports the DR API from `@creatornader/agent-bridge/dr`.
37
+
38
+ #### Security
39
+
40
+ - Enrollment files use exclusive creation, owner-only directories and files, confined paths, component and directory identity checks, symlink refusal, durable atomic state transitions, and a current-user Windows ACL. Before applying that ACL, Windows paths must be owned by the current account SID or the active token's default owner SID. The code then sets and verifies the account SID as owner with one protected FullControl rule. Verification-only paths must already satisfy the final policy. Node identity checks and native reparse attributes reject symlinks, junctions, other reparse objects, and path replacement around DACL validation. Stale lock recovery is explicit and requires same-host metadata, a minimum age, and proof that the recorded process has stopped. Deletion results distinguish a retained file, a missing file, a durable unlink, and an unlink whose directory durability could not be proved. PostgreSQL receives only the locally computed token hash. Owner JSON and errors exclude the raw token, token hash, SQL text, and operator connection URL.
41
+ - New raw credential inserts default to no scopes. Owner mutations derive actors from the database session and never return, audit, or expose credential digest material in any PostgreSQL error property. External control fields reject null required values, surrounding whitespace, control characters, and values over 128 characters. Runtime readiness rejects uncertified PostgreSQL majors, unregistered control-role holders, registered members with unrelated inherited authority, downstream role delegation, protected-object grants to untrusted roles, unsafe future-object defaults, and exact prerequisite drift. Protected operations, registration, and revocation use a member-global lock before capability locks, so opposite capability changes do not deadlock and stale `SET ROLE` sessions cannot continue after revocation. Issued credential identity, scopes, labels, expiry, and replacement lineage are immutable. Migration 014 preserves lifecycle operations for credentials created under migration 013.
42
+ - Portable export files use owner-only creation, atomic no-replace publication by default, and durable file and directory synchronization. Export audits complete after publication; failures use bounded abandonment codes. Import verifies three passes through one descriptor and limits batches by count and 4 MiB of canonical data. The caller-attested SHA-256 digest detects byte changes but provides neither encryption nor authentication. PostgreSQL archive commands accept authority only from `AGENT_BRIDGE_ARCHIVE_DATABASE_URL`.
43
+ - Portable v1 accepts only current domain records. New API writes use lowercase UUIDs. Archives require lowercase UUIDs and six-digit UTC timestamps without trimming, deduplicating, defaulting, or rewriting message content. Legacy or direct rows outside the domain require native database recovery.
44
+ - Export request IDs are caller-visible, embedded as `exportRequestId` in the digest-bound header, and returned by verification and import. Import request IDs remain independent destination operation identifiers. Completed retries verify terminal metadata, while started retries reconcile only a matching retained file through the verified descriptor. Deterministic adjacent recovery artifacts derive from the export ID. Force replacement uses a durable private backup and reports restored, retained, publication-unknown, durability-unknown, and audit-unknown outcomes without hiding recovery paths.
45
+ - Native DR uses owner-only paths, exclusive staging files, no-replace publication, same-descriptor extraction, and deterministic recovery names. PostgreSQL URLs are environment-only. Restore requires a fresh same-name, same-major target and explicit acceptance of executable source SQL. It recreates external principals as `NOLOGIN`, validates counts and readiness attestations, normalizes claimed leases, and disables the target after a partial failure. The bundle hash detects changed bytes but provides neither encryption nor source authentication. Windows success results state that parent-directory durability is unavailable instead of claiming a flush the platform cannot prove through Node.
46
+
47
+ ### Protocol and delivery
48
+
49
+ #### Added
50
+
51
+ - Canonical TypeBox-backed v2 operation registry with deterministic JSON Schema 2020-12, OpenAPI 3.1.2, MCP manifest, and capability artifacts.
52
+ - Surface-aware capability discovery over authenticated HTTP, MCP, and CLI. HTTP 2.1 is current, while upgraded gateways preserve the released headerless and explicit 2.0 response shapes.
53
+ - Closed structural request validation before domain semantics, additive response parsing, artifact drift checks, and exact legacy MCP schema fixtures.
54
+ - Object response envelopes for MCP and HTTP 2.1 delivery claims and controls. HTTP 2.0 and the unversioned CLI retain their released direct or null delivery results.
55
+ - Optional client-generated message IDs across CLI, MCP, and HTTP, including exact idempotent replay.
56
+ - Canonical gateway credential scopes, compatibility-safe migration 011, immutable replacement lineage, revocation helpers, and provider-specific capability truth.
57
+ - Database-timed credential-wide and operation rate buckets with append-only scope, rate, replacement, and revocation security events.
58
+ - Transaction-bound PostgreSQL request authority (migration 012). Node hashes credentials, PostgreSQL derives identity and scopes, and one client and transaction carry security accounting and request-local store operations. Domain savepoints preserve expected security effects when mutations fail. Ambiguous commits are never retried. Production gateway capabilities report request authority without claiming row isolation.
59
+ - Forced PostgreSQL row isolation on the five domain tables (migration 013), with database-specific no-login owner roles, transaction-bound context policies, publisher and recipient lifecycle separation, immutable publisher bindings, and a protected catalog attestation. Gateway capabilities report row isolation only after live readiness checks pass.
60
+
61
+ - Immutable publisher-owned delivery policies with mailbox and leased modes. Leased delivery adds priority claims, monotonic cycle counters, publisher cancel and requeue controls, and authorized audit pagination. PostgreSQL migration 010 and the SQLite initializer upgrade existing stores. Legacy mode rejects leased policy.
62
+
63
+ - Caller-bound `inbox`, `sent`, and `all` mailbox history plus `any`, `unread`, and `read` receipt state across MCP, CLI, HTTP, PostgreSQL, SQLite, legacy, and offline gateway mode.
64
+ - Scope-bound v2 cursors with temporary v1 cursor compatibility and authoritative edge-cache backfill after the visibility contract upgrade.
65
+ - Deprecated arbitrary-principal receipt filters. The CLI checks compatibility assertions before opening storage or contacting a gateway, and server surfaces reject mismatches before querying message storage.
66
+ - Optional immutable project labels across local, gateway, legacy, CLI, and MCP message paths, with exact project reads and unfiltered cross-project reads.
67
+ - Additive PostgreSQL migration 008, safe local and edge SQLite upgrades, and an owner-only dry-run-first legacy project reconciliation command.
68
+
69
+ - Offline inbox and pending fallback now label degraded cache data and unknown acknowledgement state; long-lived MCP clients replay with cancellable bounded backoff and expose manual `sync`.
70
+ - CLI health separates local edge health from remote gateway reachability, and unknown publication outcomes retry idempotently.
71
+ - Passive `status` no longer starts synchronization or probes remote providers. `doctor` now reports named checks and exits 0, 2, or 1 for ok, degraded, or failed. Queue diagnostics distinguish due, scheduled, and leased work. They retain blocked outbox evidence after later successful synchronization.
72
+
73
+ #### Changed
74
+
75
+ - The pre-1.0 client status contract now has four states: `ok`, `unknown`, `degraded`, and `failed`. Named checks are required. Scripts that assumed only `ok` or `degraded` must handle the two new states. Passive status still exits 0.
76
+
77
+ - New 2.1 clients require complete 2.1 negotiation before mutation and reject headerless or selected 2.0 gateways instead of downgrading. Gateways must be upgraded before 2.1 clients.
78
+ - Capability output distinguishes current, selected, and supported protocol versions. Primary OpenAPI operations require 2.1. Embedded 2.0 vendor extensions contain limited compatibility schema metadata, not a second OpenAPI description.
79
+ - Consumer-side `maxAttempts` on claim and `retryPolicy` on nack are validated but ignored for one compatibility release. Stored publisher policy now controls retry and exhaustion.
80
+ - Gateway authorization now checks scopes and rate policy before reading request bodies. Scope and rate errors use structured details, and missing security state fails closed.
81
+
82
+ #### Security
83
+
84
+ - Existing credentials retain full compatibility access without lifecycle metadata changes. New direct SQL inserts default to no scopes; owner provisioning assigns an immutable named scope set.
85
+ - Credential grace can only shorten a predecessor after replacement. Ordinary expiry and revocation cannot be extended or bypassed.
86
+ - Database policies isolate workspaces and principals. Lease transitions and target-to-delivery membership remain service-enforced. Gateway logins must not be superusers or hold `BYPASSRLS`.
87
+
9
88
  ## [0.2.0] - 2026-07-14
10
89
 
11
90
  ### Added
@@ -15,7 +94,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
15
94
  - SQLite gateway outbox, inbox cache, restart-safe synchronization, and explicit stale-cache results.
16
95
  - Cross-platform Node CLI with init, health, delivery, sync, presence, watch, migration, and client installation commands.
17
96
  - Cheap `pending` process gate for unread context or due delivery work.
18
- - Runtime manifests and native installers for Codex, Claude Code, and Claude Desktop.
97
+ - Host-adapter manifests and native installers for Codex, Claude Code, and Claude Desktop.
19
98
  - Runtime-neutral `SKILL.md` guidance and an `llms.txt` package map.
20
99
  - PostgreSQL migrations with checksum validation and runtime schema readiness checks.
21
100
  - Restricted PostgreSQL runtime grants separated from schema migration credentials.
@@ -23,8 +102,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
23
102
 
24
103
  ### Changed
25
104
 
26
- - Package identity is `@creatornader/agent-bridge` at version `0.2.0`. Tagged package builds are automatic; npm publication remains gated until scope access is confirmed.
27
- - Agent identity is process-scoped. Shared config no longer supplies `AGENT_BRIDGE_AGENT`.
105
+ - Package identity is `@creatornader/agent-bridge` at version `0.2.0`. The first npm publication was performed manually. OIDC trusted publishing was configured afterward for later releases.
106
+ - Agent principal is injected through the client process. Shared config no longer
107
+ supplies `AGENT_BRIDGE_AGENT`.
28
108
  - Exact idempotent replays deduplicate. Reusing a key for changed content returns a conflict.
29
109
  - Gateway clients authenticate through separate principal-bound credentials stored in owner-only client backend files.
30
110
  - Package-root imports expose the provider-neutral API without starting the MCP server.
@@ -56,5 +136,7 @@ First tagged release. Marks the point where agent-bridge has shipped its initial
56
136
  - Narrative-leak detection in CI + on commit via `creatornader/textleaks@v0.2.0` (renamed from leakguard).
57
137
 
58
138
  [0.1.0]: https://github.com/creatornader/agent-bridge/releases/tag/v0.1.0
59
- [Unreleased]: https://github.com/creatornader/agent-bridge/compare/v0.2.0...HEAD
139
+ [Unreleased]: https://github.com/creatornader/agent-bridge/compare/v0.3.1...HEAD
140
+ [0.3.1]: https://github.com/creatornader/agent-bridge/compare/v0.3.0...v0.3.1
141
+ [0.3.0]: https://github.com/creatornader/agent-bridge/compare/v0.2.0...v0.3.0
60
142
  [0.2.0]: https://github.com/creatornader/agent-bridge/compare/v0.1.0...v0.2.0