@pithy-sh/core 0.10.0 → 0.11.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 (180) hide show
  1. package/dist/access/access.d.ts +172 -0
  2. package/dist/access/access.d.ts.map +1 -0
  3. package/dist/access/access.js +147 -0
  4. package/dist/access/acting.d.ts +49 -0
  5. package/dist/access/acting.d.ts.map +1 -0
  6. package/dist/access/acting.js +21 -0
  7. package/dist/access/policyCheck.d.ts +33 -0
  8. package/dist/access/policyCheck.d.ts.map +1 -0
  9. package/dist/access/policyCheck.js +48 -0
  10. package/dist/access/usage.d.ts +83 -0
  11. package/dist/access/usage.d.ts.map +1 -0
  12. package/dist/access/usage.js +104 -0
  13. package/dist/access/visibility.d.ts +66 -0
  14. package/dist/access/visibility.d.ts.map +1 -0
  15. package/dist/access/visibility.js +86 -0
  16. package/dist/audit/auditEvent.d.ts +5 -0
  17. package/dist/audit/auditEvent.d.ts.map +1 -1
  18. package/dist/audit/auditEvent.js +2 -0
  19. package/dist/capability/bindings.d.ts +47 -2
  20. package/dist/capability/bindings.d.ts.map +1 -1
  21. package/dist/capability/bindings.js +117 -7
  22. package/dist/capability/capability.d.ts +98 -28
  23. package/dist/capability/capability.d.ts.map +1 -1
  24. package/dist/capability/manifest.d.ts +2 -1
  25. package/dist/capability/manifest.d.ts.map +1 -1
  26. package/dist/capability/manifest.js +1 -1
  27. package/dist/capability/settings.d.ts +86 -2
  28. package/dist/capability/settings.d.ts.map +1 -1
  29. package/dist/capability/settings.js +80 -1
  30. package/dist/cli/commandCatalog.generated.d.ts +184 -22
  31. package/dist/cli/commandCatalog.generated.d.ts.map +1 -1
  32. package/dist/cli/commandCatalog.generated.js +196 -22
  33. package/dist/cli/commandFacts.d.ts +1 -1
  34. package/dist/cli/commandFacts.d.ts.map +1 -1
  35. package/dist/cli/commandFacts.js +1 -0
  36. package/dist/controlPlane/capability.d.ts.map +1 -1
  37. package/dist/controlPlane/capability.js +12 -2
  38. package/dist/controlPlane/context.d.ts +5 -0
  39. package/dist/controlPlane/context.d.ts.map +1 -1
  40. package/dist/controlPlane/context.js +3 -1
  41. package/dist/controlPlane/data/connection.d.ts +47 -0
  42. package/dist/controlPlane/data/connection.d.ts.map +1 -1
  43. package/dist/controlPlane/data/connection.js +55 -1
  44. package/dist/controlPlane/http/cors.d.ts +4 -4
  45. package/dist/controlPlane/http/cors.js +4 -4
  46. package/dist/controlPlane/http/guard.d.ts +11 -0
  47. package/dist/controlPlane/http/guard.d.ts.map +1 -1
  48. package/dist/controlPlane/http/guard.js +17 -1
  49. package/dist/controlPlane/http/handlers.d.ts +60 -0
  50. package/dist/controlPlane/http/handlers.d.ts.map +1 -1
  51. package/dist/controlPlane/http/handlers.js +31 -2
  52. package/dist/controlPlane/http/readiness.d.ts +33 -0
  53. package/dist/controlPlane/http/readiness.d.ts.map +1 -0
  54. package/dist/controlPlane/http/readiness.js +39 -0
  55. package/dist/controlPlane/http/responses.d.ts +147 -0
  56. package/dist/controlPlane/http/responses.d.ts.map +1 -1
  57. package/dist/controlPlane/http/responses.js +61 -4
  58. package/dist/controlPlane/http/routes.d.ts +1 -0
  59. package/dist/controlPlane/http/routes.d.ts.map +1 -1
  60. package/dist/controlPlane/http/routes.js +17 -3
  61. package/dist/controlPlane/http/verify.d.ts.map +1 -1
  62. package/dist/controlPlane/http/verify.js +2 -1
  63. package/dist/controlPlane/migrationState/migrationState.d.ts +102 -0
  64. package/dist/controlPlane/migrationState/migrationState.d.ts.map +1 -0
  65. package/dist/controlPlane/migrationState/migrationState.js +142 -0
  66. package/dist/controlPlane/migrations/0003_connection_principal.d.ts +21 -0
  67. package/dist/controlPlane/migrations/0003_connection_principal.d.ts.map +1 -0
  68. package/dist/controlPlane/migrations/0003_connection_principal.js +33 -0
  69. package/dist/controlPlane/scope/scope.d.ts +13 -2
  70. package/dist/controlPlane/scope/scope.d.ts.map +1 -1
  71. package/dist/controlPlane/scope/scope.js +14 -3
  72. package/dist/createBackend.d.ts.map +1 -1
  73. package/dist/createBackend.js +7 -2
  74. package/dist/createEntrypoint.d.ts.map +1 -1
  75. package/dist/createEntrypoint.js +5 -3
  76. package/dist/entitlement/allowance.d.ts +25 -0
  77. package/dist/entitlement/allowance.d.ts.map +1 -0
  78. package/dist/entitlement/allowance.js +80 -0
  79. package/dist/entitlement/entitlement.d.ts +41 -0
  80. package/dist/entitlement/entitlement.d.ts.map +1 -1
  81. package/dist/entitlement/meter.d.ts +57 -0
  82. package/dist/entitlement/meter.d.ts.map +1 -0
  83. package/dist/entitlement/meter.js +13 -0
  84. package/dist/error/http.d.ts +144 -0
  85. package/dist/error/http.d.ts.map +1 -1
  86. package/dist/error/payload.d.ts +288 -0
  87. package/dist/error/payload.d.ts.map +1 -1
  88. package/dist/error/payload.js +100 -4
  89. package/dist/http/authContext.d.ts +7 -0
  90. package/dist/http/authContext.d.ts.map +1 -1
  91. package/dist/http/authContext.js +8 -1
  92. package/dist/http/scopeGates.d.ts +20 -0
  93. package/dist/http/scopeGates.d.ts.map +1 -0
  94. package/dist/http/scopeGates.js +36 -0
  95. package/dist/index.d.ts +1 -1
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +2 -2
  98. package/dist/logger/record.d.ts +84 -0
  99. package/dist/logger/record.d.ts.map +1 -1
  100. package/dist/migrations/capabilitySets.d.ts +23 -0
  101. package/dist/migrations/capabilitySets.d.ts.map +1 -0
  102. package/dist/migrations/capabilitySets.js +74 -0
  103. package/dist/migrations/registry.d.ts +26 -0
  104. package/dist/migrations/registry.d.ts.map +1 -1
  105. package/dist/migrations/registry.js +38 -7
  106. package/dist/migrations/state.d.ts +60 -0
  107. package/dist/migrations/state.d.ts.map +1 -0
  108. package/dist/migrations/state.js +46 -0
  109. package/dist/naming/feature.d.ts +27 -5
  110. package/dist/naming/feature.d.ts.map +1 -1
  111. package/dist/naming/feature.js +36 -6
  112. package/dist/naming/limits.d.ts +47 -3
  113. package/dist/naming/limits.d.ts.map +1 -1
  114. package/dist/naming/limits.js +47 -3
  115. package/dist/naming/provisionScope.d.ts +6 -0
  116. package/dist/naming/provisionScope.d.ts.map +1 -1
  117. package/dist/naming/provisionScope.js +8 -3
  118. package/dist/naming/resourceNames.d.ts +21 -2
  119. package/dist/naming/resourceNames.d.ts.map +1 -1
  120. package/dist/naming/resourceNames.js +21 -3
  121. package/dist/seed/writeD1.d.ts +7 -1
  122. package/dist/seed/writeD1.d.ts.map +1 -1
  123. package/dist/seed/writeD1.js +9 -3
  124. package/dist/seed/writeKv.d.ts +2 -0
  125. package/dist/seed/writeKv.d.ts.map +1 -1
  126. package/dist/seed/writeKv.js +6 -2
  127. package/dist/version.generated.d.ts +1 -1
  128. package/dist/version.generated.js +1 -1
  129. package/dist/worker/serviceLoopback.d.ts +36 -0
  130. package/dist/worker/serviceLoopback.d.ts.map +1 -0
  131. package/dist/worker/serviceLoopback.js +74 -0
  132. package/dist/workflow/faults.d.ts +12 -1
  133. package/dist/workflow/faults.d.ts.map +1 -1
  134. package/dist/workflow/faults.js +22 -15
  135. package/package.json +2 -2
  136. package/src/access/access.ts +298 -0
  137. package/src/access/acting.ts +59 -0
  138. package/src/access/policyCheck.ts +77 -0
  139. package/src/access/usage.ts +141 -0
  140. package/src/access/visibility.ts +109 -0
  141. package/src/audit/auditEvent.ts +4 -0
  142. package/src/capability/bindings.ts +159 -13
  143. package/src/capability/capability.ts +99 -29
  144. package/src/capability/settings.ts +146 -2
  145. package/src/cli/commandCatalog.generated.ts +212 -22
  146. package/src/cli/commandFacts.ts +1 -0
  147. package/src/controlPlane/capability.ts +25 -1
  148. package/src/controlPlane/context.ts +4 -0
  149. package/src/controlPlane/data/connection.ts +90 -0
  150. package/src/controlPlane/http/cors.ts +4 -4
  151. package/src/controlPlane/http/guard.ts +21 -0
  152. package/src/controlPlane/http/handlers.ts +41 -0
  153. package/src/controlPlane/http/readiness.ts +50 -0
  154. package/src/controlPlane/http/responses.ts +140 -2
  155. package/src/controlPlane/http/routes.ts +25 -1
  156. package/src/controlPlane/http/verify.ts +2 -0
  157. package/src/controlPlane/migrationState/migrationState.ts +200 -0
  158. package/src/controlPlane/migrations/0003_connection_principal.ts +37 -0
  159. package/src/controlPlane/scope/scope.ts +14 -2
  160. package/src/createBackend.ts +24 -6
  161. package/src/createEntrypoint.ts +9 -3
  162. package/src/entitlement/allowance.ts +85 -0
  163. package/src/entitlement/entitlement.ts +38 -0
  164. package/src/entitlement/meter.ts +69 -0
  165. package/src/error/payload.ts +211 -4
  166. package/src/http/authContext.ts +13 -1
  167. package/src/http/scopeGates.ts +34 -0
  168. package/src/index.ts +1 -0
  169. package/src/migrations/capabilitySets.ts +87 -0
  170. package/src/migrations/registry.ts +46 -2
  171. package/src/migrations/state.ts +94 -0
  172. package/src/naming/feature.ts +46 -7
  173. package/src/naming/limits.ts +35 -3
  174. package/src/naming/provisionScope.ts +19 -1
  175. package/src/naming/resourceNames.ts +52 -5
  176. package/src/seed/writeD1.ts +13 -4
  177. package/src/seed/writeKv.ts +6 -2
  178. package/src/version.generated.ts +1 -1
  179. package/src/worker/serviceLoopback.ts +105 -0
  180. package/src/workflow/faults.ts +51 -24
@@ -148,6 +148,34 @@ const COMMANDS = {
148
148
  },
149
149
  "groups": []
150
150
  },
151
+ "completion": {
152
+ "positionals": [{
153
+ "name": "shell",
154
+ "required": false,
155
+ "variadic": false
156
+ }],
157
+ "flags": {
158
+ "--remove": {
159
+ "type": "boolean",
160
+ "required": false,
161
+ "repeatable": false
162
+ },
163
+ "--status": {
164
+ "type": "boolean",
165
+ "required": false,
166
+ "repeatable": false
167
+ },
168
+ "--json": {
169
+ "type": "boolean",
170
+ "required": false,
171
+ "repeatable": false
172
+ }
173
+ },
174
+ "groups": [{
175
+ "kind": "atMostOne",
176
+ "flags": ["--remove", "--status"]
177
+ }]
178
+ },
151
179
  "contract": {
152
180
  "positionals": [],
153
181
  "flags": {
@@ -238,6 +266,16 @@ const COMMANDS = {
238
266
  "type": "string",
239
267
  "required": false,
240
268
  "repeatable": false
269
+ },
270
+ "--purpose": {
271
+ "type": "string",
272
+ "required": false,
273
+ "repeatable": false
274
+ },
275
+ "--kind": {
276
+ "type": "string",
277
+ "required": false,
278
+ "repeatable": false
241
279
  }
242
280
  },
243
281
  "groups": [
@@ -259,13 +297,20 @@ const COMMANDS = {
259
297
  "needs": ["--public-key"],
260
298
  "any": false
261
299
  },
300
+ {
301
+ "kind": "requires",
302
+ "flag": "--kind",
303
+ "needs": ["--public-key"],
304
+ "any": false
305
+ },
262
306
  {
263
307
  "kind": "requires",
264
308
  "flag": "--update",
265
309
  "needs": [
266
310
  "--worker-url",
267
311
  "--scope",
268
- "--public-key"
312
+ "--public-key",
313
+ "--purpose"
269
314
  ],
270
315
  "any": true
271
316
  }
@@ -980,11 +1025,6 @@ const COMMANDS = {
980
1025
  "required": false,
981
1026
  "repeatable": false
982
1027
  },
983
- "--api-token": {
984
- "type": "string",
985
- "required": false,
986
- "repeatable": false
987
- },
988
1028
  "--r2-access-key-id": {
989
1029
  "type": "string",
990
1030
  "required": false,
@@ -995,11 +1035,6 @@ const COMMANDS = {
995
1035
  "required": false,
996
1036
  "repeatable": false
997
1037
  },
998
- "--r2-api-token": {
999
- "type": "string",
1000
- "required": false,
1001
- "repeatable": false
1002
- },
1003
1038
  "--json": {
1004
1039
  "type": "boolean",
1005
1040
  "required": false,
@@ -1354,6 +1389,28 @@ const COMMANDS = {
1354
1389
  },
1355
1390
  "groups": []
1356
1391
  },
1392
+ "secrets tables": {
1393
+ "positionals": [],
1394
+ "flags": {
1395
+ "--env": {
1396
+ "type": "string",
1397
+ "required": false,
1398
+ "repeatable": false,
1399
+ "default": "dev"
1400
+ },
1401
+ "--worker": {
1402
+ "type": "string",
1403
+ "required": false,
1404
+ "repeatable": false
1405
+ },
1406
+ "--json": {
1407
+ "type": "boolean",
1408
+ "required": false,
1409
+ "repeatable": false
1410
+ }
1411
+ },
1412
+ "groups": []
1413
+ },
1357
1414
  "secrets update": {
1358
1415
  "positionals": [{
1359
1416
  "name": "name",
@@ -1452,6 +1509,27 @@ const COMMANDS = {
1452
1509
  },
1453
1510
  "groups": []
1454
1511
  },
1512
+ "setup": {
1513
+ "positionals": [],
1514
+ "flags": {
1515
+ "--skip-install": {
1516
+ "type": "boolean",
1517
+ "required": false,
1518
+ "repeatable": false
1519
+ },
1520
+ "--dry-run": {
1521
+ "type": "boolean",
1522
+ "required": false,
1523
+ "repeatable": false
1524
+ },
1525
+ "--json": {
1526
+ "type": "boolean",
1527
+ "required": false,
1528
+ "repeatable": false
1529
+ }
1530
+ },
1531
+ "groups": []
1532
+ },
1455
1533
  "storage deprovision": {
1456
1534
  "positionals": [],
1457
1535
  "flags": {
@@ -1491,11 +1569,6 @@ const COMMANDS = {
1491
1569
  "required": false,
1492
1570
  "repeatable": false
1493
1571
  },
1494
- "--api-token": {
1495
- "type": "string",
1496
- "required": false,
1497
- "repeatable": false
1498
- },
1499
1572
  "--r2-access-key-id": {
1500
1573
  "type": "string",
1501
1574
  "required": false,
@@ -1872,6 +1945,32 @@ const COMMANDS = {
1872
1945
  },
1873
1946
  "groups": []
1874
1947
  },
1948
+ "token forget": {
1949
+ "positionals": [{
1950
+ "name": "profile",
1951
+ "required": true,
1952
+ "variadic": false
1953
+ }],
1954
+ "flags": {
1955
+ "--env": {
1956
+ "type": "string",
1957
+ "required": false,
1958
+ "repeatable": false,
1959
+ "default": "dev"
1960
+ },
1961
+ "--force": {
1962
+ "type": "boolean",
1963
+ "required": false,
1964
+ "repeatable": false
1965
+ },
1966
+ "--json": {
1967
+ "type": "boolean",
1968
+ "required": false,
1969
+ "repeatable": false
1970
+ }
1971
+ },
1972
+ "groups": []
1973
+ },
1875
1974
  "token list": {
1876
1975
  "positionals": [],
1877
1976
  "flags": {
@@ -1930,7 +2029,12 @@ const COMMANDS = {
1930
2029
  "vectorize:write",
1931
2030
  "ai:read",
1932
2031
  "zone:read",
1933
- "routes:write"
2032
+ "routes:write",
2033
+ "analytics:read",
2034
+ "images:write",
2035
+ "stream:write",
2036
+ "queues:write",
2037
+ "artifacts:write"
1934
2038
  ]
1935
2039
  },
1936
2040
  "--json": {
@@ -2003,7 +2107,12 @@ const COMMANDS = {
2003
2107
  "vectorize:write",
2004
2108
  "ai:read",
2005
2109
  "zone:read",
2006
- "routes:write"
2110
+ "routes:write",
2111
+ "analytics:read",
2112
+ "images:write",
2113
+ "stream:write",
2114
+ "queues:write",
2115
+ "artifacts:write"
2007
2116
  ]
2008
2117
  },
2009
2118
  "--keep-previous": {
@@ -2282,6 +2391,32 @@ const COMMANDS = {
2282
2391
  },
2283
2392
  "groups": []
2284
2393
  },
2394
+ "worker bind": {
2395
+ "positionals": [],
2396
+ "flags": {
2397
+ "--from": {
2398
+ "type": "string",
2399
+ "required": false,
2400
+ "repeatable": false
2401
+ },
2402
+ "--to": {
2403
+ "type": "string",
2404
+ "required": false,
2405
+ "repeatable": false
2406
+ },
2407
+ "--binding": {
2408
+ "type": "string",
2409
+ "required": false,
2410
+ "repeatable": false
2411
+ },
2412
+ "--json": {
2413
+ "type": "boolean",
2414
+ "required": false,
2415
+ "repeatable": false
2416
+ }
2417
+ },
2418
+ "groups": []
2419
+ },
2285
2420
  "worker list": {
2286
2421
  "positionals": [],
2287
2422
  "flags": { "--json": {
@@ -2306,15 +2441,25 @@ const COMMANDS = {
2306
2441
  },
2307
2442
  "worker rename": {
2308
2443
  "positionals": [{
2309
- "name": "from",
2310
- "required": true,
2444
+ "name": "old",
2445
+ "required": false,
2311
2446
  "variadic": false
2312
2447
  }, {
2313
- "name": "to",
2314
- "required": true,
2448
+ "name": "new",
2449
+ "required": false,
2315
2450
  "variadic": false
2316
2451
  }],
2317
2452
  "flags": {
2453
+ "--from": {
2454
+ "type": "string",
2455
+ "required": false,
2456
+ "repeatable": false
2457
+ },
2458
+ "--to": {
2459
+ "type": "string",
2460
+ "required": false,
2461
+ "repeatable": false
2462
+ },
2318
2463
  "--force": {
2319
2464
  "type": "boolean",
2320
2465
  "required": false,
@@ -2353,6 +2498,35 @@ const COMMANDS = {
2353
2498
  }
2354
2499
  },
2355
2500
  "groups": []
2501
+ },
2502
+ "worker unbind": {
2503
+ "positionals": [],
2504
+ "flags": {
2505
+ "--from": {
2506
+ "type": "string",
2507
+ "required": false,
2508
+ "repeatable": false
2509
+ },
2510
+ "--to": {
2511
+ "type": "string",
2512
+ "required": false,
2513
+ "repeatable": false
2514
+ },
2515
+ "--binding": {
2516
+ "type": "string",
2517
+ "required": false,
2518
+ "repeatable": false
2519
+ },
2520
+ "--json": {
2521
+ "type": "boolean",
2522
+ "required": false,
2523
+ "repeatable": false
2524
+ }
2525
+ },
2526
+ "groups": [{
2527
+ "kind": "exactlyOne",
2528
+ "flags": ["--to", "--binding"]
2529
+ }]
2356
2530
  }
2357
2531
  };
2358
2532
  /** The flags every command takes, answered before any command runs. */
@@ -31,7 +31,7 @@ export type WorkerScopedPath = (typeof WORKER_SCOPED)[number];
31
31
  * The commands that take `--worker` and do not need it: each fans out over every Worker, or falls back to the
32
32
  * first that answers, and the flag narrows.
33
33
  */
34
- export declare const WORKER_NARROWS: readonly ["contract", "dashboard disconnect", "dashboard revoke-key", "dashboard rotate", "dashboard status", "doctor", "env", "init", "migrate", "seed", "support deprovision", "upgrade"];
34
+ export declare const WORKER_NARROWS: readonly ["contract", "dashboard disconnect", "dashboard revoke-key", "dashboard rotate", "dashboard status", "doctor", "env", "init", "migrate", "secrets tables", "seed", "support deprovision", "upgrade"];
35
35
  /**
36
36
  * A command only a person runs, at a terminal, where the Worker is asked for. `pithy remove` refuses every run
37
37
  * that cannot ask (`core/person_required`).
@@ -1 +1 @@
1
- {"version":3,"file":"commandFacts.d.ts","sourceRoot":"","sources":["../../src/cli/commandFacts.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,YACxB,KAAK,EACL,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB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O,MAAM,gBAAgB,YAC3B,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,CAChB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,uBAAuB,YAAI,MAAM,EAAE,YAAY,CAAU,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;wBACnB,WAAW;mBAChB,sBAAsB;;;;CAI8B,CAAC;AAE7D,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,gCAAqE,CAAC;AAEhH;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,gCAAqE,CAAC;AAE3G;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAEnG,CAAC"}
@@ -57,6 +57,7 @@ const WORKER_NARROWS = [
57
57
  "env",
58
58
  "init",
59
59
  "migrate",
60
+ "secrets tables",
60
61
  "seed",
61
62
  "support deprovision",
62
63
  "upgrade"
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/controlPlane/capability.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAuC,MAAM,0BAA0B,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAWnF,OAAO,EACL,wBAAwB,EAIzB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;GASG;AACH,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAEjD,MAAM,MAAM,mBAA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E,mBAAwB,GAAG,sBAAsB,CAoLtF;AAED,4GAA4G;AAC5G,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
@@ -6,11 +6,13 @@ import "../worker/identity.js";
6
6
  import { ControlPlaneConfig } from "./config/config.js";
7
7
  import { ControlPlaneConnection } from "./data/connection.js";
8
8
  import { CONTROL_PLANE_CONNECTIONS_TABLE, controlPlaneTables } from "./data/tables.js";
9
- import { capabilityHealthSources } from "./discovery/health.js";
9
+ import { capabilityHealthSources, defineCapabilityHealth } from "./discovery/health.js";
10
10
  import { createControlPlaneVerifier } from "./http/guard.js";
11
+ import { MIGRATION_HEALTH_KEYS, composeMigrationDatabases, readMigrationHealth } from "./migrationState/migrationState.js";
11
12
  import { controlPlaneRouteDescriptors, registerControlPlaneRoutes } from "./http/routes.js";
12
13
  import { controlplane_0001_init } from "./migrations/0001_init.js";
13
14
  import { controlplane_0002_management_origin } from "./migrations/0002_management_origin.js";
15
+ import { controlplane_0003_connection_principal } from "./migrations/0003_connection_principal.js";
14
16
  import { d1ReplayGuard } from "./replay/d1Guard.js";
15
17
  import { CONTROL_PLANE_KV_BINDING, controlPlaneKvNamespaces, kvReplayGuard } from "./replay/kvGuard.js";
16
18
  //#region src/controlPlane/capability.ts
@@ -52,7 +54,8 @@ function controlplane(options = {}) {
52
54
  const config = ControlPlaneConfig.parse(options);
53
55
  const migrations = {
54
56
  "0001_init": controlplane_0001_init,
55
- "0002_management_origin": controlplane_0002_management_origin
57
+ "0002_management_origin": controlplane_0002_management_origin,
58
+ "0003_connection_principal": controlplane_0003_connection_principal
56
59
  };
57
60
  const requiredBindings = [{
58
61
  type: "d1",
@@ -83,6 +86,7 @@ function controlplane(options = {}) {
83
86
  });
84
87
  let composed = [];
85
88
  let health = /* @__PURE__ */ new Map();
89
+ let migrationDatabases = [];
86
90
  return {
87
91
  ...defineCapability({
88
92
  name: "controlplane",
@@ -98,6 +102,10 @@ function controlplane(options = {}) {
98
102
  } },
99
103
  kvNamespaces: usesKvReplay ? controlPlaneKvNamespaces(config.jtiTtlSeconds) : {},
100
104
  adminRoutes: controlPlaneRouteDescriptors(config.basePath),
105
+ health: defineCapabilityHealth({
106
+ keys: MIGRATION_HEALTH_KEYS,
107
+ read: (c) => readMigrationHealth(c.env, migrationDatabases)
108
+ }),
101
109
  compose: ({ capabilities }) => {
102
110
  composed = capabilities.map((cap) => ({
103
111
  name: cap.name,
@@ -109,6 +117,7 @@ function controlplane(options = {}) {
109
117
  config: { ...cap.manifestConfig?.values ?? {} }
110
118
  }));
111
119
  health = capabilityHealthSources(capabilities);
120
+ migrationDatabases = composeMigrationDatabases(capabilities);
112
121
  },
113
122
  middleware: [(app) => {
114
123
  app.use("*", async (c, next) => {
@@ -135,6 +144,7 @@ function controlplane(options = {}) {
135
144
  database,
136
145
  composedCapabilities: () => composed,
137
146
  composedHealth: () => health,
147
+ composedMigrations: () => migrationDatabases,
138
148
  now
139
149
  });
140
150
  }
@@ -24,6 +24,11 @@ export declare const ControlPlaneContext: z.ZodObject<{
24
24
  grantedScopes: z.ZodArray<z.ZodString>;
25
25
  keyId: z.ZodString;
26
26
  tokenId: z.ZodString;
27
+ actorKind: z.ZodNullable<z.ZodEnum<{
28
+ agent: "agent";
29
+ dashboard: "dashboard";
30
+ script: "script";
31
+ }>>;
27
32
  }, z.core.$strip>;
28
33
  export type ControlPlaneContext = z.output<typeof ControlPlaneContext>;
29
34
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/controlPlane/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;iBAyC7B,CAAC;AACJ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/controlPlane/context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;iBA4C7B,CAAC;AACJ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
  import { ControlPlaneScope } from "./scope/scope.js";
4
+ import { ControlPlaneActorKind } from "./data/connection.js";
4
5
  import { z } from "zod";
5
6
  //#region src/controlPlane/context.ts
6
7
  /**
@@ -25,7 +26,8 @@ const ControlPlaneContext = z.object({
25
26
  scope: ControlPlaneScope.describe("The single scope this token was minted for. One call, one operation — a token carrying the whole grant would make every call as dangerous as the most dangerous one."),
26
27
  grantedScopes: z.array(ControlPlaneScope).describe("Every scope the adopter granted this connection, read from their own row. The authority: a scope absent here is denied however the token is written."),
27
28
  keyId: z.string().describe("Which registered key verified this call. Recorded so a rotation can be traced through the trail, and so a key still in use is visible before it is expired."),
28
- tokenId: z.string().describe("The token's `jti`, already claimed in the replay set. Recorded to tie one audit event to one call.")
29
+ tokenId: z.string().describe("The token's `jti`, already claimed in the replay set. Recorded to tie one audit event to one call."),
30
+ actorKind: ControlPlaneActorKind.nullable().describe("What kind of client the connection is for — `agent`, `dashboard` or `script` — read from the adopter's own row, never from the token. The gate stamps it onto every control-plane audit row this call writes. Null for a connection registered before the kind was recorded (#721).")
29
31
  }).describe("The verified control-plane caller for one request. Never an AuthContext: a management client is not a user of the adopter's app.");
30
32
  //#endregion
31
33
  export { ControlPlaneContext };
@@ -37,6 +37,46 @@ export declare const RegisteredKey: z.ZodObject<{
37
37
  revokedAt: z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodDate]>, z.ZodDate>>;
38
38
  }, z.core.$strip>;
39
39
  export type RegisteredKey = z.output<typeof RegisteredKey>;
40
+ /**
41
+ * What kind of client a connection is for (#721): `agent`, `dashboard` or `script`.
42
+ *
43
+ * The audit trail's `actorType: "control-plane"` names all three identically, and the questions asked
44
+ * after an incident are exactly the ones that tell them apart — was it a person at the dashboard, a
45
+ * script somebody wrote, or an agent running unattended. So the kind is recorded on the connection when
46
+ * it is registered and stamped from there onto every row its calls write.
47
+ *
48
+ * It follows the path, never a guess: the device-code flow is a dashboard, always, and a key the
49
+ * operator registered themselves is whichever of the other two they say, out loud, with `--kind`.
50
+ */
51
+ export declare const ControlPlaneActorKind: z.ZodEnum<{
52
+ agent: "agent";
53
+ dashboard: "dashboard";
54
+ script: "script";
55
+ }>;
56
+ export type ControlPlaneActorKind = z.output<typeof ControlPlaneActorKind>;
57
+ /**
58
+ * Who sanctioned a connection: the email address of the signed-in Cloudflare session that registered it.
59
+ *
60
+ * **A plain string, deliberately not a reference.** An adopter's `pithy_auth_users` are their customers,
61
+ * and the operator who registers a connection is their staff, so a join into the organization model would
62
+ * be empty for most of them. A string is readable by anybody, and matchable against a directory where the
63
+ * operator is in one.
64
+ *
65
+ * **Derived, never asserted.** No flag supplies it; the CLI reads it from `GET /user` under the session.
66
+ */
67
+ export declare const ConnectionPrincipal: z.ZodEmail;
68
+ export type ConnectionPrincipal = z.output<typeof ConnectionPrincipal>;
69
+ /** The longest purpose a connection may carry. One line on a review screen, with room to say what it does. */
70
+ export declare const MAX_CONNECTION_PURPOSE = 200;
71
+ /**
72
+ * What a connection is for, in the words of whoever registered it (#721).
73
+ *
74
+ * **Required at registration, and refused when absent**, because a review listing credentials by key id
75
+ * cannot support the decision it exists for. **Untrusted input**: a customer writes it and something else
76
+ * renders it, so it is validated on the way in, and again on every read of the row.
77
+ */
78
+ export declare const ConnectionPurpose: z.ZodString;
79
+ export type ConnectionPurpose = z.output<typeof ConnectionPurpose>;
40
80
  /**
41
81
  * One management-client connection — the row in `pithy_controlplane_connections`.
42
82
  *
@@ -52,6 +92,13 @@ export declare const ControlPlaneConnection: z.ZodObject<{
52
92
  workerUrl: z.ZodURL;
53
93
  basePath: z.ZodDefault<z.ZodString>;
54
94
  managementOrigin: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
95
+ authorizedBy: z.ZodDefault<z.ZodNullable<z.ZodEmail>>;
96
+ actorKind: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
97
+ agent: "agent";
98
+ dashboard: "dashboard";
99
+ script: "script";
100
+ }>>>;
101
+ purpose: z.ZodDefault<z.ZodNullable<z.ZodString>>;
55
102
  scopes: z.ZodCodec<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodArray<z.ZodString>>;
56
103
  keys: z.ZodCodec<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
57
104
  keyId: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/controlPlane/data/connection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;GASG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB;;;;iBAgBoF,CAAC;AAClH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;iBAoBoF,CAAC;AAC/G,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDhC,CAAC;AACJ,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC7E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO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@ -35,6 +35,57 @@ const RegisteredKey = z.object({
35
35
  revokedAt: JsonDate.nullable().describe("When this key was revoked outright, or null. Revocation ignores `validUntil` and takes effect immediately — it is the adopter's unilateral control, and it must not wait for a window to close.")
36
36
  }).describe("One registered public key with its validity window. Two live at once during a rotation overlap.");
37
37
  /**
38
+ * What kind of client a connection is for (#721): `agent`, `dashboard` or `script`.
39
+ *
40
+ * The audit trail's `actorType: "control-plane"` names all three identically, and the questions asked
41
+ * after an incident are exactly the ones that tell them apart — was it a person at the dashboard, a
42
+ * script somebody wrote, or an agent running unattended. So the kind is recorded on the connection when
43
+ * it is registered and stamped from there onto every row its calls write.
44
+ *
45
+ * It follows the path, never a guess: the device-code flow is a dashboard, always, and a key the
46
+ * operator registered themselves is whichever of the other two they say, out loud, with `--kind`.
47
+ */
48
+ const ControlPlaneActorKind = z.enum([
49
+ "agent",
50
+ "dashboard",
51
+ "script"
52
+ ]).describe("What kind of client a connection is for: `agent` (an automated client acting on its own judgment, often unattended), `dashboard` (a management dashboard a person drives, registered through the device-code flow), or `script` (an operator's own automation, doing one fixed thing).");
53
+ /**
54
+ * Who sanctioned a connection: the email address of the signed-in Cloudflare session that registered it.
55
+ *
56
+ * **A plain string, deliberately not a reference.** An adopter's `pithy_auth_users` are their customers,
57
+ * and the operator who registers a connection is their staff, so a join into the organization model would
58
+ * be empty for most of them. A string is readable by anybody, and matchable against a directory where the
59
+ * operator is in one.
60
+ *
61
+ * **Derived, never asserted.** No flag supplies it; the CLI reads it from `GET /user` under the session.
62
+ */
63
+ const ConnectionPrincipal = z.email().max(254).describe("The email address of the person who sanctioned this connection, read from their signed-in Cloudflare session at registration. Never typed, so never asserted.");
64
+ /** The longest purpose a connection may carry. One line on a review screen, with room to say what it does. */
65
+ const MAX_CONNECTION_PURPOSE = 200;
66
+ /**
67
+ * Characters a purpose may not carry: every C0 and C1 control (so no terminal escape, no newline and no
68
+ * carriage return), the Unicode line and paragraph separators, every `Bidi_Control` character — the
69
+ * embeddings, overrides and isolates, and the LRM, RLM and ALM marks — that lets text render in a
70
+ * different order from the one it is stored in, and the invisible zero-width space, word joiner and
71
+ * byte-order mark that split a word without showing it. The zero-width joiner and non-joiner stay: Persian
72
+ * and the Indic scripts cannot be written without them.
73
+ *
74
+ * Each of those is a way for a sentence to look like something else once it reaches a renderer: a line
75
+ * in `pithy dashboard status` forged beneath the real one, a screen cleared, a scope name read backwards.
76
+ * Escaping them at every renderer is a promise each renderer has to keep. Refusing them at the boundary
77
+ * is one promise, kept here.
78
+ */
79
+ const UNRENDERABLE = /[\p{Cc}\p{Bidi_Control}\u2028\u2029\u200B\u2060\uFEFF]/u;
80
+ /**
81
+ * What a connection is for, in the words of whoever registered it (#721).
82
+ *
83
+ * **Required at registration, and refused when absent**, because a review listing credentials by key id
84
+ * cannot support the decision it exists for. **Untrusted input**: a customer writes it and something else
85
+ * renders it, so it is validated on the way in, and again on every read of the row.
86
+ */
87
+ const ConnectionPurpose = z.string().trim().min(1, "Say what this client is for.").max(200, `A purpose is 200 characters at most.`).refine((purpose) => !UNRENDERABLE.test(purpose), "A purpose is one line of plain text: no control, bidi or invisible characters.").describe(`What this connection's client is for, in the registering operator's words — one line of plain text, 200 characters at most, with no control, bidi or invisible characters. Written by a customer and rendered elsewhere, so validated at the boundary.`);
88
+ /**
38
89
  * One management-client connection — the row in `pithy_controlplane_connections`.
39
90
  *
40
91
  * Keys are a versioned JSON column rather than a child table for two reasons. **Rotation becomes one
@@ -49,10 +100,13 @@ const ControlPlaneConnection = z.object({
49
100
  workerUrl: z.url().describe("This environment's deployed Worker URL, captured at connect. The address the management client calls; re-pointed by `pithy dashboard connect --update` when a custom domain or a rename moves it."),
50
101
  basePath: z.string().min(1).default("/control-plane").describe("Where this Worker mounts the control-plane seam, captured at connect from its resolved config. Stored beside `workerUrl` because the two together fully determine the manifest address — and this is the one part of it a client cannot discover, since it *is* the manifest's own address. Defaulted rather than required so a connection registered before the column existed still parses, reading as the default it was necessarily using."),
51
102
  managementOrigin: z.url().nullable().default(null).describe("Where the management client that registered this connection answers — the origin the CLI calls for a verify, a rotation or a disconnect. Stored because it is not derivable: `issuer` is what that client *signs as*, and nothing says a dashboard's API answers at its own `iss`. Null for a connection registered before this column, which reads as the issuer rather than as the hosted dashboard — an older row is still a row about somebody's own deployment. Nothing on the Worker's side reads it; verification cares about `issuer` alone."),
103
+ authorizedBy: ConnectionPrincipal.nullable().default(null).describe("Who sanctioned this connection: the email of the signed-in Cloudflare session that registered it, never a flag. Null for a connection registered before principals were recorded (#721), which keeps working and reads as exactly that; registering again is the only way to set it."),
104
+ actorKind: ControlPlaneActorKind.nullable().default(null).describe("What kind of client this connection is for — `agent`, `dashboard` or `script` — stamped onto every audit row its calls write so the trail can tell them apart. Null for a connection registered before it was recorded."),
105
+ purpose: ConnectionPurpose.nullable().default(null).describe("What this connection's client is for, in the registering operator's words. Required at registration and editable with `pithy dashboard connect --update --purpose`; null only for a connection registered before it was recorded."),
52
106
  scopes: sqliteJson(z.array(ControlPlaneScope)).describe("The operations this connection was granted, stored and enforced on the adopter's side. Enforced only by the caller, a scope would not be a limit at all."),
53
107
  keys: sqliteJson(z.array(RegisteredKey)).describe("Every key this connection may sign with, current and superseded. One JSON column rather than a child table, so a rotation is one atomic UPDATE and verification is one read."),
54
108
  createdAt: SQLiteDate.describe("When the connection was registered. Ms-epoch in SQLite, a Date in TypeScript."),
55
109
  updatedAt: SQLiteDate.describe("When the row last changed — a key registered or expired, or the Worker URL re-pointed.")
56
110
  }).describe("One management-client connection: its identity, the environment and URL it is bound to, the operations it was granted, and its versioned public keys.");
57
111
  //#endregion
58
- export { ControlPlaneConnection, Ed25519PublicJwk, RegisteredKey };
112
+ export { ConnectionPrincipal, ConnectionPurpose, ControlPlaneActorKind, ControlPlaneConnection, Ed25519PublicJwk, MAX_CONNECTION_PURPOSE, RegisteredKey };
@@ -93,10 +93,10 @@ export declare function corsMiddleware(entry: CorsSurfaceEntry, origins: Readonl
93
93
  /**
94
94
  * Mount one `app.use(path, …)` per entry.
95
95
  *
96
- * **Called from the capability's `middleware` hook, never its `routes` hook, and that is load-bearing.**
97
- * `createBackend` runs every capability's `middleware` hook before **any** capability's `routes` hook
98
- * (`createBackend.ts:262-267`), which is what makes this independent of the order an adopter happens to
99
- * list their capabilities in.
96
+ * **Called from `createBackend` ahead of every capability's `middleware`, never from a `routes` hook,
97
+ * and that is load-bearing.** Registered there, it is independent of the order an adopter happens to
98
+ * list their capabilities in, and it can put a header on whatever a capability's middleware or a
99
+ * readiness guard short-circuits.
100
100
  *
101
101
  * From `routes` it looks like it works and does not. The preflight still answers — an `OPTIONS` has no
102
102
  * route handler to lose to, so this `use` is the only thing that matches it — but a capability composed
@@ -170,10 +170,10 @@ function corsMiddleware(entry, origins, maxAgeSeconds) {
170
170
  /**
171
171
  * Mount one `app.use(path, …)` per entry.
172
172
  *
173
- * **Called from the capability's `middleware` hook, never its `routes` hook, and that is load-bearing.**
174
- * `createBackend` runs every capability's `middleware` hook before **any** capability's `routes` hook
175
- * (`createBackend.ts:262-267`), which is what makes this independent of the order an adopter happens to
176
- * list their capabilities in.
173
+ * **Called from `createBackend` ahead of every capability's `middleware`, never from a `routes` hook,
174
+ * and that is load-bearing.** Registered there, it is independent of the order an adopter happens to
175
+ * list their capabilities in, and it can put a header on whatever a capability's middleware or a
176
+ * readiness guard short-circuits.
177
177
  *
178
178
  * From `routes` it looks like it works and does not. The preflight still answers — an `OPTIONS` has no
179
179
  * route handler to lose to, so this `use` is the only thing that matches it — but a capability composed