@creatornader/agent-bridge 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +150 -1
  2. package/README.md +239 -5
  3. package/ROADMAP.md +59 -7
  4. package/SECURITY.md +55 -5
  5. package/SKILL.md +103 -0
  6. package/dist/archive.d.ts +2 -2
  7. package/dist/archive.js +2 -2
  8. package/dist/{bridge-service-hX1ZQp4W.d.ts → bridge-service-YTjGr91A.d.ts} +1 -1
  9. package/dist/{bridge-store-DPVSCwfs.d.ts → bridge-store-Boaj-ZbO.d.ts} +2 -0
  10. package/dist/bridge.d.ts +17 -7
  11. package/dist/bridge.js +15 -7
  12. package/dist/{chunk-WAI2IYIQ.js → chunk-3YHVUPU2.js} +48 -5
  13. package/dist/chunk-3YHVUPU2.js.map +1 -0
  14. package/dist/{chunk-45BZGB77.js → chunk-6BTJE6D4.js} +168 -7
  15. package/dist/chunk-6BTJE6D4.js.map +1 -0
  16. package/dist/{chunk-5GMB3A77.js → chunk-DQOZJJZ2.js} +22 -10
  17. package/dist/chunk-DQOZJJZ2.js.map +1 -0
  18. package/dist/{chunk-NCO7RLBM.js → chunk-GTK4KOED.js} +108 -8
  19. package/dist/chunk-GTK4KOED.js.map +1 -0
  20. package/dist/{chunk-GADH244D.js → chunk-IHZFI7TH.js} +12 -4
  21. package/dist/chunk-IHZFI7TH.js.map +1 -0
  22. package/dist/{chunk-CEXBMOI5.js → chunk-LAHNQZDN.js} +2 -2
  23. package/dist/{chunk-UAHMP6GC.js → chunk-MCKKVNCE.js} +9 -6
  24. package/dist/chunk-MCKKVNCE.js.map +1 -0
  25. package/dist/{chunk-MBPZXTJA.js → chunk-PDIHDBP3.js} +173 -20
  26. package/dist/chunk-PDIHDBP3.js.map +1 -0
  27. package/dist/{chunk-Q6PPMXJC.js → chunk-SV3SVBYS.js} +377 -21
  28. package/dist/chunk-SV3SVBYS.js.map +1 -0
  29. package/dist/{chunk-SPSMZOCJ.js → chunk-SYGONYMM.js} +4 -4
  30. package/dist/{chunk-A6W4QALF.js → chunk-TC6A7GMF.js} +2 -2
  31. package/dist/cli.js +5865 -436
  32. package/dist/cli.js.map +1 -1
  33. package/dist/client-runtime.d.ts +4 -2
  34. package/dist/client-runtime.js +6 -6
  35. package/dist/contracts/generate.js +1 -1
  36. package/dist/dr.d.ts +9 -2
  37. package/dist/dr.js +6 -4
  38. package/dist/{gateway-CggQ8vTC.d.ts → gateway-BQHpV-MZ.d.ts} +27 -3
  39. package/dist/gateway-main.js +69 -5
  40. package/dist/gateway-main.js.map +1 -1
  41. package/dist/gateway.d.ts +3 -3
  42. package/dist/gateway.js +2 -2
  43. package/dist/index.js +7 -7
  44. package/dist/{postgres-bridge-store-Bfd3hRId.d.ts → postgres-bridge-store-WASumj26.d.ts} +1 -1
  45. package/dist/server.js +7 -7
  46. package/dist/sqlite-edge-store-Bc15DvpX.d.ts +148 -0
  47. package/dist/sqlite.d.ts +19 -80
  48. package/dist/sqlite.js +11 -3
  49. package/docs/architecture-v2.md +256 -10
  50. package/docs/decisions/0004-client-lifecycle-and-endpoint-migration.md +204 -0
  51. package/docs/deployment.md +205 -0
  52. package/docs/troubleshooting.md +23 -0
  53. package/llms.txt +67 -0
  54. package/openapi/agent-bridge-v2.openapi.json +1023 -0
  55. package/package.json +6 -2
  56. package/schemas/agent-bridge-v2.capabilities.json +24 -0
  57. package/schemas/agent-bridge-v2.mcp.json +6 -0
  58. package/schemas/agent-bridge-v2.schema.json +163 -0
  59. package/sql/migrations/017_gateway_authority_binding.sql +99 -0
  60. package/sql/migrations/018_endpoint_migration_challenges.sql +1028 -0
  61. package/sql/migrations/019_endpoint_migration_same_successor.sql +324 -0
  62. package/dist/chunk-45BZGB77.js.map +0 -1
  63. package/dist/chunk-5GMB3A77.js.map +0 -1
  64. package/dist/chunk-GADH244D.js.map +0 -1
  65. package/dist/chunk-MBPZXTJA.js.map +0 -1
  66. package/dist/chunk-NCO7RLBM.js.map +0 -1
  67. package/dist/chunk-Q6PPMXJC.js.map +0 -1
  68. package/dist/chunk-UAHMP6GC.js.map +0 -1
  69. package/dist/chunk-WAI2IYIQ.js.map +0 -1
  70. /package/dist/{chunk-CEXBMOI5.js.map → chunk-LAHNQZDN.js.map} +0 -0
  71. /package/dist/{chunk-SPSMZOCJ.js.map → chunk-SYGONYMM.js.map} +0 -0
  72. /package/dist/{chunk-A6W4QALF.js.map → chunk-TC6A7GMF.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creatornader/agent-bridge",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Durable, pull-first mailbox and work-delivery control plane for AI agents across runtimes, sessions, and machines.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -87,13 +87,17 @@
87
87
  "pretest": "npm run build",
88
88
  "test": "vitest run",
89
89
  "test:built": "vitest run",
90
+ "test:postgres:contract": "vitest run test/postgres_integration.test.ts --maxWorkers=1 --hookTimeout=60000",
91
+ "test:postgres:preflight": "node scripts/postgres-preflight.mjs",
92
+ "test:postgres:preflight:full": "node scripts/postgres-preflight.mjs --full",
93
+ "test:windows:contract": "vitest run test/private-path.test.ts test/windows-native-smoke.test.ts --maxWorkers=1 --testTimeout=180000 -t \"applies and verifies native Windows file and directory ACLs|recovers an (enrollment|client-operation) subsystem lock\" && vitest run test/client-maintenance.test.ts --maxWorkers=1 --testTimeout=180000",
90
94
  "typecheck": "tsc --noEmit",
91
95
  "contracts:generate": "npm run build --silent && npm run contracts:generate:built",
92
96
  "contracts:generate:built": "node dist/contracts/generate.js",
93
97
  "contracts:check": "npm run build --silent && npm run contracts:check:built",
94
98
  "contracts:check:built": "node dist/contracts/generate.js --check",
95
99
  "check": "npm run typecheck && npm run build && npm run contracts:check:built && npm run test:built",
96
- "check:windows": "npm run typecheck && npm run build && npm run contracts:check:built && vitest run --maxWorkers=2 --testTimeout=90000"
100
+ "check:windows": "npm run typecheck && npm run build && npm run contracts:check:built && vitest run --maxWorkers=2 --testTimeout=90000 --exclude test/private-path.test.ts --exclude test/client-maintenance.test.ts --exclude test/cli.test.ts"
97
101
  },
98
102
  "dependencies": {
99
103
  "@modelcontextprotocol/sdk": "^1.12.1",
@@ -88,6 +88,12 @@
88
88
  "legacy-supabase"
89
89
  ]
90
90
  },
91
+ "grantedScopes": {
92
+ "type": "array",
93
+ "items": {
94
+ "type": "string"
95
+ }
96
+ },
91
97
  "operations": {
92
98
  "type": "array",
93
99
  "items": {
@@ -134,6 +140,24 @@
134
140
  "status:read"
135
141
  ]
136
142
  },
143
+ {
144
+ "id": "issue_endpoint_migration_challenge",
145
+ "summary": "Issue a short-lived endpoint migration challenge commitment.",
146
+ "http": {
147
+ "method": "POST",
148
+ "path": "/v2/endpoint-migration-challenges"
149
+ },
150
+ "requiredScopes": []
151
+ },
152
+ {
153
+ "id": "consume_endpoint_migration_challenge",
154
+ "summary": "Consume a short-lived endpoint migration challenge commitment.",
155
+ "http": {
156
+ "method": "POST",
157
+ "path": "/v2/endpoint-migration-challenges/consume"
158
+ },
159
+ "requiredScopes": []
160
+ },
137
161
  {
138
162
  "id": "gateway_metrics",
139
163
  "summary": "Read Prometheus gateway counters.",
@@ -77,6 +77,12 @@
77
77
  "legacy-supabase"
78
78
  ]
79
79
  },
80
+ "grantedScopes": {
81
+ "type": "array",
82
+ "items": {
83
+ "type": "string"
84
+ }
85
+ },
80
86
  "operations": {
81
87
  "type": "array",
82
88
  "items": {
@@ -338,6 +338,12 @@
338
338
  "legacy-supabase"
339
339
  ]
340
340
  },
341
+ "grantedScopes": {
342
+ "type": "array",
343
+ "items": {
344
+ "type": "string"
345
+ }
346
+ },
341
347
  "operations": {
342
348
  "type": "array",
343
349
  "items": {
@@ -432,6 +438,12 @@
432
438
  "legacy-supabase"
433
439
  ]
434
440
  },
441
+ "grantedScopes": {
442
+ "type": "array",
443
+ "items": {
444
+ "type": "string"
445
+ }
446
+ },
435
447
  "operations": {
436
448
  "type": "array",
437
449
  "items": {
@@ -586,6 +598,12 @@
586
598
  }
587
599
  ]
588
600
  },
601
+ "gatewayAuthorityId": {
602
+ "type": "string"
603
+ },
604
+ "credentialId": {
605
+ "type": "string"
606
+ },
589
607
  "principal": {
590
608
  "type": "object",
591
609
  "required": [
@@ -605,6 +623,111 @@
605
623
  },
606
624
  "additionalProperties": true
607
625
  },
626
+ "issue_endpoint_migration_challengeRequest": {
627
+ "type": "object",
628
+ "required": [
629
+ "challenge",
630
+ "expectedGatewayAuthorityId",
631
+ "verifierCredentialId"
632
+ ],
633
+ "properties": {
634
+ "challenge": {
635
+ "type": "string",
636
+ "pattern": "^[0-9a-f]{64}$"
637
+ },
638
+ "expectedGatewayAuthorityId": {
639
+ "type": "string",
640
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
641
+ },
642
+ "verifierCredentialId": {
643
+ "type": "string",
644
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
645
+ }
646
+ },
647
+ "additionalProperties": false
648
+ },
649
+ "issue_endpoint_migration_challengeResponse": {
650
+ "type": "object",
651
+ "required": [
652
+ "gatewayAuthorityId",
653
+ "issuerCredentialId",
654
+ "verifierCredentialId",
655
+ "expiresAt"
656
+ ],
657
+ "properties": {
658
+ "gatewayAuthorityId": {
659
+ "type": "string"
660
+ },
661
+ "issuerCredentialId": {
662
+ "type": "string"
663
+ },
664
+ "verifierCredentialId": {
665
+ "type": "string"
666
+ },
667
+ "expiresAt": {
668
+ "type": "string"
669
+ }
670
+ },
671
+ "additionalProperties": false
672
+ },
673
+ "consume_endpoint_migration_challengeRequest": {
674
+ "type": "object",
675
+ "required": [
676
+ "challenge",
677
+ "expectedGatewayAuthorityId",
678
+ "issuerCredentialId"
679
+ ],
680
+ "properties": {
681
+ "challenge": {
682
+ "type": "string",
683
+ "pattern": "^[0-9a-f]{64}$"
684
+ },
685
+ "expectedGatewayAuthorityId": {
686
+ "type": "string",
687
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
688
+ },
689
+ "issuerCredentialId": {
690
+ "type": "string",
691
+ "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
692
+ }
693
+ },
694
+ "additionalProperties": false
695
+ },
696
+ "consume_endpoint_migration_challengeResponse": {
697
+ "type": "object",
698
+ "required": [
699
+ "gatewayAuthorityId",
700
+ "issuerCredentialId",
701
+ "verifierCredentialId",
702
+ "expiresAt",
703
+ "consumed"
704
+ ],
705
+ "properties": {
706
+ "gatewayAuthorityId": {
707
+ "type": "string"
708
+ },
709
+ "issuerCredentialId": {
710
+ "type": "string"
711
+ },
712
+ "verifierCredentialId": {
713
+ "type": "string"
714
+ },
715
+ "expiresAt": {
716
+ "anyOf": [
717
+ {
718
+ "type": "string"
719
+ },
720
+ {
721
+ "type": "null"
722
+ }
723
+ ]
724
+ },
725
+ "consumed": {
726
+ "type": "boolean"
727
+ }
728
+ },
729
+ "additionalProperties": false
730
+ },
608
731
  "client_statusRequest": {
609
732
  "type": "object",
610
733
  "properties": {},
@@ -834,6 +957,12 @@
834
957
  }
835
958
  ]
836
959
  },
960
+ "gatewayAuthorityId": {
961
+ "type": "string"
962
+ },
963
+ "credentialId": {
964
+ "type": "string"
965
+ },
837
966
  "principal": {
838
967
  "type": "object",
839
968
  "required": [
@@ -927,6 +1056,7 @@
927
1056
  "idle",
928
1057
  "running",
929
1058
  "backoff",
1059
+ "paused",
930
1060
  "stopped",
931
1061
  "failed"
932
1062
  ]
@@ -936,6 +1066,19 @@
936
1066
  },
937
1067
  "remoteError": {
938
1068
  "type": "string"
1069
+ },
1070
+ "migrationState": {
1071
+ "enum": [
1072
+ "active",
1073
+ "draining",
1074
+ "retired"
1075
+ ]
1076
+ },
1077
+ "migrationOperationId": {
1078
+ "type": "string"
1079
+ },
1080
+ "migrationLeaseExpiresAt": {
1081
+ "type": "string"
939
1082
  }
940
1083
  },
941
1084
  "additionalProperties": true
@@ -1195,6 +1338,12 @@
1195
1338
  }
1196
1339
  ]
1197
1340
  },
1341
+ "gatewayAuthorityId": {
1342
+ "type": "string"
1343
+ },
1344
+ "credentialId": {
1345
+ "type": "string"
1346
+ },
1198
1347
  "principal": {
1199
1348
  "type": "object",
1200
1349
  "required": [
@@ -1288,6 +1437,7 @@
1288
1437
  "idle",
1289
1438
  "running",
1290
1439
  "backoff",
1440
+ "paused",
1291
1441
  "stopped",
1292
1442
  "failed"
1293
1443
  ]
@@ -1297,6 +1447,19 @@
1297
1447
  },
1298
1448
  "remoteError": {
1299
1449
  "type": "string"
1450
+ },
1451
+ "migrationState": {
1452
+ "enum": [
1453
+ "active",
1454
+ "draining",
1455
+ "retired"
1456
+ ]
1457
+ },
1458
+ "migrationOperationId": {
1459
+ "type": "string"
1460
+ },
1461
+ "migrationLeaseExpiresAt": {
1462
+ "type": "string"
1300
1463
  }
1301
1464
  },
1302
1465
  "additionalProperties": true
@@ -0,0 +1,99 @@
1
+ begin;
2
+
3
+ select pg_advisory_xact_lock(1646705660);
4
+
5
+ create table agent_bridge.gateway_authority (
6
+ singleton boolean not null default true,
7
+ authority_id uuid not null default gen_random_uuid(),
8
+ constraint gateway_authority_singleton primary key (singleton),
9
+ constraint gateway_authority_singleton_true check (singleton),
10
+ constraint gateway_authority_id_unique unique (authority_id)
11
+ );
12
+
13
+ insert into agent_bridge.gateway_authority(singleton) values (true);
14
+
15
+ create function agent_bridge.reject_gateway_authority_mutation()
16
+ returns trigger
17
+ language plpgsql set search_path = '' as $$
18
+ begin
19
+ raise exception 'gateway authority is immutable';
20
+ end
21
+ $$;
22
+
23
+ create trigger gateway_authority_immutable
24
+ before update or delete or truncate on agent_bridge.gateway_authority
25
+ for each statement execute function agent_bridge.reject_gateway_authority_mutation();
26
+
27
+ create function agent_bridge.gateway_authority_ready()
28
+ returns boolean
29
+ language sql stable security definer set search_path = '' as $$
30
+ select count(*)=1 and bool_and(singleton and authority_id is not null)
31
+ from agent_bridge.gateway_authority
32
+ $$;
33
+
34
+ create function agent_bridge.open_request_authority_bound(
35
+ requested_credential_id uuid,
36
+ credential_hash text,
37
+ requested_request_id uuid
38
+ ) returns table(
39
+ gateway_authority_id uuid,
40
+ credential_id uuid,
41
+ workspace_id text,
42
+ principal text,
43
+ scopes text[]
44
+ )
45
+ language plpgsql volatile security definer set search_path = '' as $$
46
+ declare
47
+ bound_gateway_authority_id uuid;
48
+ authority_credential_id uuid;
49
+ authority_workspace_id text;
50
+ authority_principal text;
51
+ authority_scopes text[];
52
+ begin
53
+ select authority_id into strict bound_gateway_authority_id
54
+ from agent_bridge.gateway_authority
55
+ where singleton;
56
+
57
+ select authority.credential_id,authority.workspace_id,authority.principal,authority.scopes
58
+ into authority_credential_id,authority_workspace_id,authority_principal,authority_scopes
59
+ from agent_bridge.open_request_authority(
60
+ requested_credential_id,credential_hash,requested_request_id
61
+ ) authority;
62
+
63
+ if not found then return; end if;
64
+
65
+ gateway_authority_id := bound_gateway_authority_id;
66
+ credential_id := authority_credential_id;
67
+ workspace_id := authority_workspace_id;
68
+ principal := authority_principal;
69
+ scopes := authority_scopes;
70
+ return next;
71
+ end
72
+ $$;
73
+
74
+ revoke all on agent_bridge.gateway_authority from public;
75
+ revoke all on function agent_bridge.reject_gateway_authority_mutation() from public;
76
+ revoke all on function agent_bridge.gateway_authority_ready() from public;
77
+ revoke all on function agent_bridge.open_request_authority_bound(uuid,text,uuid) from public;
78
+
79
+ do $roles$
80
+ declare
81
+ runtime_role text := 'agent_bridge_runtime_' || substr(md5(current_database()),1,16);
82
+ role_name text;
83
+ begin
84
+ foreach role_name in array array[runtime_role,'anon','authenticated'] loop
85
+ if exists (select 1 from pg_roles where rolname=role_name) then
86
+ execute format('revoke all on agent_bridge.gateway_authority from %I',role_name);
87
+ execute format('revoke all on function agent_bridge.gateway_authority_ready() from %I',role_name);
88
+ execute format('revoke all on function agent_bridge.open_request_authority_bound(uuid,text,uuid) from %I',role_name);
89
+ end if;
90
+ end loop;
91
+ execute format('grant execute on function agent_bridge.gateway_authority_ready() to %I',runtime_role);
92
+ execute format('grant execute on function agent_bridge.open_request_authority_bound(uuid,text,uuid) to %I',runtime_role);
93
+ end
94
+ $roles$;
95
+
96
+ insert into agent_bridge.schema_migrations(version,name,checksum)
97
+ values (17,'gateway_authority_binding','__AGENT_BRIDGE_MIGRATION_CHECKSUM__');
98
+
99
+ commit;