@capybara-hq/kernel 0.1.0-rc.132 → 0.1.0-rc.134

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 (173) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.js +3 -0
  3. package/dist/admin/admin.schemas.d.ts +4 -0
  4. package/dist/admin/health.service.d.ts +2 -2
  5. package/dist/admin/health.service.js +6 -2
  6. package/dist/admin/setup.service.js +6 -1
  7. package/dist/agents/agents.controller.js +3 -2
  8. package/dist/agents/agents.service.d.ts +2 -0
  9. package/dist/agents/agents.service.js +7 -0
  10. package/dist/automations/events/trigger-events.service.d.ts +13 -1
  11. package/dist/automations/events/trigger-events.service.js +27 -14
  12. package/dist/catalog/catalog.service.d.ts +2 -0
  13. package/dist/catalog/catalog.service.js +28 -5
  14. package/dist/catalog/marketplace-fetch.d.ts +2 -0
  15. package/dist/catalog/marketplace-fetch.js +15 -0
  16. package/dist/catalog/marketplaces.service.d.ts +4 -4
  17. package/dist/catalog/marketplaces.service.js +3 -2
  18. package/dist/catalog/owned-items.d.ts +2 -0
  19. package/dist/catalog/owned-items.js +30 -31
  20. package/dist/catalog/ownership.js +40 -38
  21. package/dist/catalog/plugin-import.d.ts +3 -4
  22. package/dist/catalog/plugin-import.js +50 -1
  23. package/dist/catalog/plugin-upgrade.d.ts +8 -0
  24. package/dist/catalog/plugin-upgrade.js +95 -7
  25. package/dist/catalog/publisher-policy.d.ts +9 -0
  26. package/dist/catalog/publisher-policy.js +12 -0
  27. package/dist/catalog/unshare.js +66 -58
  28. package/dist/client/client-access.service.js +5 -3
  29. package/dist/config/schema.d.ts +1 -0
  30. package/dist/config/schema.js +8 -1
  31. package/dist/conversations/conversations.controller.js +4 -14
  32. package/dist/conversations/conversations.service.d.ts +14 -0
  33. package/dist/conversations/conversations.service.js +20 -2
  34. package/dist/ctx/create-ctx.d.ts +15 -2
  35. package/dist/ctx/create-ctx.js +195 -79
  36. package/dist/ctx/durable-cancellation.d.ts +3 -0
  37. package/dist/ctx/durable-cancellation.js +8 -0
  38. package/dist/ctx/durable-effects.service.d.ts +81 -0
  39. package/dist/ctx/durable-effects.service.js +316 -0
  40. package/dist/ctx/durable-envelope.d.ts +24 -0
  41. package/dist/ctx/durable-envelope.js +80 -0
  42. package/dist/ctx/durable-failure.d.ts +7 -0
  43. package/dist/ctx/durable-failure.js +32 -0
  44. package/dist/ctx/durable-job.d.ts +9 -0
  45. package/dist/ctx/durable-job.js +2 -0
  46. package/dist/ctx/durable-keys.d.ts +27 -0
  47. package/dist/ctx/durable-keys.js +138 -0
  48. package/dist/ctx/durable-relay.d.ts +29 -0
  49. package/dist/ctx/durable-relay.js +250 -0
  50. package/dist/ctx/queue.d.ts +2 -0
  51. package/dist/ctx/queue.js +25 -15
  52. package/dist/db/extension-db.js +2 -0
  53. package/dist/db/extension-handoff-schema.d.ts +6 -0
  54. package/dist/db/extension-handoff-schema.js +72 -0
  55. package/dist/db/extension-rls-predicate.d.ts +1 -0
  56. package/dist/db/extension-rls-predicate.js +8 -0
  57. package/dist/db/extension-schema-transfer.d.ts +1 -1
  58. package/dist/db/extension-schema-transfer.js +18 -6
  59. package/dist/db/kernel-schema.d.ts +64 -0
  60. package/dist/db/migrator.js +6 -13
  61. package/dist/db/pool.d.ts +2 -2
  62. package/dist/db/pool.js +2 -2
  63. package/dist/db/sql-statements.d.ts +3 -0
  64. package/dist/db/sql-statements.js +15 -5
  65. package/dist/device-access/device-access.module.js +12 -2
  66. package/dist/device-access/device-access.service.d.ts +30 -2
  67. package/dist/device-access/device-access.service.js +38 -4
  68. package/dist/device-access/host-gate.d.ts +45 -0
  69. package/dist/device-access/host-gate.js +92 -0
  70. package/dist/device-access/host-service-stop-sweep.d.ts +33 -0
  71. package/dist/device-access/host-service-stop-sweep.js +112 -0
  72. package/dist/device-access/host-service-stop.d.ts +78 -0
  73. package/dist/device-access/host-service-stop.js +144 -0
  74. package/dist/device-access/host-services.d.ts +211 -0
  75. package/dist/device-access/host-services.js +803 -0
  76. package/dist/device-access/person-handles.d.ts +10 -0
  77. package/dist/device-access/person-handles.js +25 -0
  78. package/dist/device-access/service-events.d.ts +199 -0
  79. package/dist/device-access/service-events.js +704 -0
  80. package/dist/device-access/token.d.ts +5 -0
  81. package/dist/device-access/token.js +5 -0
  82. package/dist/devices/devices.service.js +3 -0
  83. package/dist/dial-in/access.d.ts +5 -5
  84. package/dist/dial-in/access.js +19 -12
  85. package/dist/dial-in/gateway.js +6 -2
  86. package/dist/dial-in/machines.d.ts +9 -2
  87. package/dist/dial-in/machines.js +27 -4
  88. package/dist/erasure/device-cleanup.js +12 -0
  89. package/dist/erasure/org-catalog.js +2 -2
  90. package/dist/erasure/org-rules.js +10 -0
  91. package/dist/errors.d.ts +2 -0
  92. package/dist/errors.js +2 -0
  93. package/dist/extensions/admin-ops.js +8 -2
  94. package/dist/extensions/deployed-snapshots.d.ts +4 -1
  95. package/dist/extensions/deployed-snapshots.js +7 -2
  96. package/dist/extensions/extensions.module.js +10 -0
  97. package/dist/extensions/host.d.ts +12 -2
  98. package/dist/extensions/host.js +44 -22
  99. package/dist/extensions/instance.d.ts +5 -0
  100. package/dist/extensions/instance.js +10 -0
  101. package/dist/extensions/ledger.d.ts +1 -1
  102. package/dist/extensions/lifecycle-hooks.js +3 -3
  103. package/dist/extensions/org-config.js +6 -1
  104. package/dist/extensions/permission-set.d.ts +7 -0
  105. package/dist/extensions/permission-set.js +10 -0
  106. package/dist/extensions/permission-view.d.ts +1 -1
  107. package/dist/extensions/permission-view.js +10 -1
  108. package/dist/extensions/sources.d.ts +1 -0
  109. package/dist/extensions/sources.js +9 -0
  110. package/dist/git/tickets.js +32 -27
  111. package/dist/http/app.js +5 -3
  112. package/dist/identity/accounts.d.ts +6 -1
  113. package/dist/identity/accounts.js +11 -2
  114. package/dist/identity/api-tokens.js +7 -6
  115. package/dist/identity/settings.d.ts +9 -1
  116. package/dist/identity/settings.js +16 -1
  117. package/dist/inbox/inbox-items.service.d.ts +5 -0
  118. package/dist/inbox/inbox-items.service.js +57 -33
  119. package/dist/inbox/org-notices.js +3 -2
  120. package/dist/index.d.ts +1 -0
  121. package/dist/index.js +1 -0
  122. package/dist/infra/database/extension-effect-key-lock.d.ts +10 -0
  123. package/dist/infra/database/extension-effect-key-lock.js +69 -0
  124. package/dist/infra/database/extension-handoff.d.ts +27 -0
  125. package/dist/infra/database/extension-handoff.js +113 -0
  126. package/dist/infra/database/scoped-dialect.d.ts +3 -2
  127. package/dist/infra/database/scoped-dialect.js +260 -72
  128. package/dist/infra/database/startup-activation-transaction.d.ts +2 -0
  129. package/dist/infra/database/startup-activation-transaction.js +3 -2
  130. package/dist/infra/outbox/outbox.dispatcher.d.ts +6 -1
  131. package/dist/infra/outbox/outbox.dispatcher.js +64 -4
  132. package/dist/infra/outbox/outbox.module.js +2 -0
  133. package/dist/infra/outbox/registry.d.ts +40 -0
  134. package/dist/infra/outbox/registry.js +42 -0
  135. package/dist/infra/queue/queue-names.d.ts +1 -1
  136. package/dist/infra/queue/queue-names.js +1 -0
  137. package/dist/infra/queue/run-job.d.ts +4 -1
  138. package/dist/infra/queue/run-job.js +10 -2
  139. package/dist/kernel.js +1 -0
  140. package/dist/kernel.module.js +3 -0
  141. package/dist/orgs/offboarding.js +18 -9
  142. package/dist/orgs/orgs.service.js +16 -0
  143. package/dist/orgs/settings.service.js +3 -0
  144. package/dist/packages/npm-publish-keys.json +27 -0
  145. package/dist/packages/official-publisher.d.ts +19 -0
  146. package/dist/packages/official-publisher.js +152 -0
  147. package/dist/packages/provenance.d.ts +7 -0
  148. package/dist/packages/provenance.js +22 -19
  149. package/dist/packages/sigstore-trusted-root.json +126 -0
  150. package/dist/platform/ops/admin.ops.js +2 -1
  151. package/dist/platform/ops/orgs.ops.js +1 -0
  152. package/dist/roles/worker-role.d.ts +6 -3
  153. package/dist/roles/worker-role.js +12 -4
  154. package/dist/roles/worker.module.js +9 -0
  155. package/dist/runtime/maintenance.d.ts +5 -2
  156. package/dist/runtime/maintenance.js +18 -4
  157. package/dist/sandbox/device-reports.d.ts +4 -4
  158. package/dist/sandbox/device-reports.js +40 -30
  159. package/dist/sandbox/device-services.d.ts +2 -1
  160. package/dist/sandbox/device-services.js +5 -1
  161. package/dist/sandbox/permission-ceiling-writes.d.ts +8 -0
  162. package/dist/sandbox/permission-ceiling-writes.js +21 -0
  163. package/dist/sandbox/permission-config-publication.js +5 -1
  164. package/dist/themes/theme-state.js +24 -13
  165. package/dist/tools/call-scope.d.ts +6 -0
  166. package/dist/tools/call-scope.js +22 -0
  167. package/dist/tools/registry.js +20 -2
  168. package/dist/ui/views.js +36 -8
  169. package/package.json +9 -4
  170. package/src/migrations/0222_device_host_services.sql +27 -0
  171. package/src/migrations/0223_device_service_events.sql +54 -0
  172. package/src/migrations/0224_cache_conversation_rls_settings.sql +33 -0
  173. package/src/migrations/0225_extension_effect_receipts.sql +25 -0
@@ -0,0 +1,126 @@
1
+ {
2
+ "mediaType": "application/vnd.dev.sigstore.trustedroot+json;version=0.1",
3
+ "tlogs": [
4
+ {
5
+ "baseUrl": "https://rekor.sigstore.dev",
6
+ "hashAlgorithm": "SHA2_256",
7
+ "publicKey": {
8
+ "rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2G2Y+2tabdTV5BcGiBIx0a9fAFwrkBbmLSGtks4L3qX6yYY0zufBnhC8Ur/iy55GhWP/9A/bY2LhC30M9+RYtw==",
9
+ "keyDetails": "PKIX_ECDSA_P256_SHA_256",
10
+ "validFor": {
11
+ "start": "2021-01-12T11:53:27Z"
12
+ }
13
+ },
14
+ "logId": {
15
+ "keyId": "wNI9atQGlz+VWfO6LRygH4QUfY/8W4RFwiT5i5WRgB0="
16
+ }
17
+ },
18
+ {
19
+ "baseUrl": "https://log2025-1.rekor.sigstore.dev",
20
+ "hashAlgorithm": "SHA2_256",
21
+ "publicKey": {
22
+ "rawBytes": "MCowBQYDK2VwAyEAt8rlp1knGwjfbcXAYPYAkn0XiLz1x8O4t0YkEhie244=",
23
+ "keyDetails": "PKIX_ED25519",
24
+ "validFor": {
25
+ "start": "2025-09-23T00:00:00Z"
26
+ }
27
+ },
28
+ "logId": {
29
+ "keyId": "zxGZFVvd0FEmjR8WrFwMdcAJ9vtaY/QXf44Y1wUeP6A="
30
+ }
31
+ }
32
+ ],
33
+ "certificateAuthorities": [
34
+ {
35
+ "subject": {
36
+ "organization": "sigstore.dev",
37
+ "commonName": "sigstore"
38
+ },
39
+ "uri": "https://fulcio.sigstore.dev",
40
+ "certChain": {
41
+ "certificates": [
42
+ {
43
+ "rawBytes": "MIIB+DCCAX6gAwIBAgITNVkDZoCiofPDsy7dfm6geLbuhzAKBggqhkjOPQQDAzAqMRUwEwYDVQQKEwxzaWdzdG9yZS5kZXYxETAPBgNVBAMTCHNpZ3N0b3JlMB4XDTIxMDMwNzAzMjAyOVoXDTMxMDIyMzAzMjAyOVowKjEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MREwDwYDVQQDEwhzaWdzdG9yZTB2MBAGByqGSM49AgEGBSuBBAAiA2IABLSyA7Ii5k+pNO8ZEWY0ylemWDowOkNa3kL+GZE5Z5GWehL9/A9bRNA3RbrsZ5i0JcastaRL7Sp5fp/jD5dxqc/UdTVnlvS16an+2Yfswe/QuLolRUCrcOE2+2iA5+tzd6NmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYEFMjFHQBBmiQpMlEk6w2uSu1KBtPsMB8GA1UdIwQYMBaAFMjFHQBBmiQpMlEk6w2uSu1KBtPsMAoGCCqGSM49BAMDA2gAMGUCMH8liWJfMui6vXXBhjDgY4MwslmN/TJxVe/83WrFomwmNf056y1X48F9c4m3a3ozXAIxAKjRay5/aj/jsKKGIkmQatjI8uupHr/+CxFvaJWmpYqNkLDGRU+9orzh5hI2RrcuaQ=="
44
+ }
45
+ ]
46
+ },
47
+ "validFor": {
48
+ "start": "2021-03-07T03:20:29Z",
49
+ "end": "2022-12-31T23:59:59.999Z"
50
+ }
51
+ },
52
+ {
53
+ "subject": {
54
+ "organization": "sigstore.dev",
55
+ "commonName": "sigstore"
56
+ },
57
+ "uri": "https://fulcio.sigstore.dev",
58
+ "certChain": {
59
+ "certificates": [
60
+ {
61
+ "rawBytes": "MIICGjCCAaGgAwIBAgIUALnViVfnU0brJasmRkHrn/UnfaQwCgYIKoZIzj0EAwMwKjEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MREwDwYDVQQDEwhzaWdzdG9yZTAeFw0yMjA0MTMyMDA2MTVaFw0zMTEwMDUxMzU2NThaMDcxFTATBgNVBAoTDHNpZ3N0b3JlLmRldjEeMBwGA1UEAxMVc2lnc3RvcmUtaW50ZXJtZWRpYXRlMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8RVS/ysH+NOvuDZyPIZtilgUF9NlarYpAd9HP1vBBH1U5CV77LSS7s0ZiH4nE7Hv7ptS6LvvR/STk798LVgMzLlJ4HeIfF3tHSaexLcYpSASr1kS0N/RgBJz/9jWCiXno3sweTAOBgNVHQ8BAf8EBAMCAQYwEwYDVR0lBAwwCgYIKwYBBQUHAwMwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU39Ppz1YkEZb5qNjpKFWixi4YZD8wHwYDVR0jBBgwFoAUWMAeX5FFpWapesyQoZMi0CrFxfowCgYIKoZIzj0EAwMDZwAwZAIwPCsQK4DYiZYDPIaDi5HFKnfxXx6ASSVmERfsynYBiX2X6SJRnZU84/9DZdnFvvxmAjBOt6QpBlc4J/0DxvkTCqpclvziL6BCCPnjdlIB3Pu3BxsPmygUY7Ii2zbdCdliiow="
62
+ },
63
+ {
64
+ "rawBytes": "MIIB9zCCAXygAwIBAgIUALZNAPFdxHPwjeDloDwyYChAO/4wCgYIKoZIzj0EAwMwKjEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MREwDwYDVQQDEwhzaWdzdG9yZTAeFw0yMTEwMDcxMzU2NTlaFw0zMTEwMDUxMzU2NThaMCoxFTATBgNVBAoTDHNpZ3N0b3JlLmRldjERMA8GA1UEAxMIc2lnc3RvcmUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAT7XeFT4rb3PQGwS4IajtLk3/OlnpgangaBclYpsYBr5i+4ynB07ceb3LP0OIOZdxexX69c5iVuyJRQ+Hz05yi+UF3uBWAlHpiS5sh0+H2GHE7SXrk1EC5m1Tr19L9gg92jYzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRYwB5fkUWlZql6zJChkyLQKsXF+jAfBgNVHSMEGDAWgBRYwB5fkUWlZql6zJChkyLQKsXF+jAKBggqhkjOPQQDAwNpADBmAjEAj1nHeXZp+13NWBNa+EDsDP8G1WWg1tCMWP/WHPqpaVo0jhsweNFZgSs0eE7wYI4qAjEA2WB9ot98sIkoF3vZYdd3/VtWB5b9TNMea7Ix/stJ5TfcLLeABLE4BNJOsQ4vnBHJ"
65
+ }
66
+ ]
67
+ },
68
+ "validFor": {
69
+ "start": "2022-04-13T20:06:15Z"
70
+ }
71
+ }
72
+ ],
73
+ "ctlogs": [
74
+ {
75
+ "baseUrl": "https://ctfe.sigstore.dev/test",
76
+ "hashAlgorithm": "SHA2_256",
77
+ "publicKey": {
78
+ "rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEbfwR+RJudXscgRBRpKX1XFDy3PyudDxz/SfnRi1fT8ekpfBd2O1uoz7jr3Z8nKzxA69EUQ+eFCFI3zeubPWU7w==",
79
+ "keyDetails": "PKIX_ECDSA_P256_SHA_256",
80
+ "validFor": {
81
+ "start": "2021-03-14T00:00:00Z",
82
+ "end": "2022-10-31T23:59:59.999Z"
83
+ }
84
+ },
85
+ "logId": {
86
+ "keyId": "CGCS8ChS/2hF0dFrJ4ScRWcYrBY9wzjSbea8IgY2b3I="
87
+ }
88
+ },
89
+ {
90
+ "baseUrl": "https://ctfe.sigstore.dev/2022",
91
+ "hashAlgorithm": "SHA2_256",
92
+ "publicKey": {
93
+ "rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEiPSlFi0CmFTfEjCUqF9HuCEcYXNKAaYalIJmBZ8yyezPjTqhxrKBpMnaocVtLJBI1eM3uXnQzQGAJdJ4gs9Fyw==",
94
+ "keyDetails": "PKIX_ECDSA_P256_SHA_256",
95
+ "validFor": {
96
+ "start": "2022-10-20T00:00:00Z"
97
+ }
98
+ },
99
+ "logId": {
100
+ "keyId": "3T0wasbHETJjGR4cmWc3AqJKXrjePK3/h4pygC8p7o4="
101
+ }
102
+ }
103
+ ],
104
+ "timestampAuthorities": [
105
+ {
106
+ "subject": {
107
+ "organization": "sigstore.dev",
108
+ "commonName": "sigstore-tsa-selfsigned"
109
+ },
110
+ "uri": "https://timestamp.sigstore.dev/api/v1/timestamp",
111
+ "certChain": {
112
+ "certificates": [
113
+ {
114
+ "rawBytes": "MIICEDCCAZagAwIBAgIUOhNULwyQYe68wUMvy4qOiyojiwwwCgYIKoZIzj0EAwMwOTEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MSAwHgYDVQQDExdzaWdzdG9yZS10c2Etc2VsZnNpZ25lZDAeFw0yNTA0MDgwNjU5NDNaFw0zNTA0MDYwNjU5NDNaMC4xFTATBgNVBAoTDHNpZ3N0b3JlLmRldjEVMBMGA1UEAxMMc2lnc3RvcmUtdHNhMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE4ra2Z8hKNig2T9kFjCAToGG30jky+WQv3BzL+mKvh1SKNR/UwuwsfNCg4sryoYAd8E6isovVA3M4aoNdm9QDi50Z8nTEyvqgfDPtTIwXItfiW/AFf1V7uwkbkAoj0xxco2owaDAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFIn9eUOHz9BlRsMCRscsc1t9tOsDMB8GA1UdIwQYMBaAFJjsAe9/u1H/1JUeb4qImFMHic6/MBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMIMAoGCCqGSM49BAMDA2gAMGUCMDtpsV/6KaO0qyF/UMsX2aSUXKQFdoGTptQGc0ftq1csulHPGG6dsmyMNd3JB+G3EQIxAOajvBcjpJmKb4Nv+2Taoj8Uc5+b6ih6FXCCKraSqupe07zqswMcXJTe1cExvHvvlw=="
115
+ },
116
+ {
117
+ "rawBytes": "MIIB9zCCAXygAwIBAgIUV7f0GLDOoEzIh8LXSW80OJiUp14wCgYIKoZIzj0EAwMwOTEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MSAwHgYDVQQDExdzaWdzdG9yZS10c2Etc2VsZnNpZ25lZDAeFw0yNTA0MDgwNjU5NDNaFw0zNTA0MDYwNjU5NDNaMDkxFTATBgNVBAoTDHNpZ3N0b3JlLmRldjEgMB4GA1UEAxMXc2lnc3RvcmUtdHNhLXNlbGZzaWduZWQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQUQNtfRT/ou3YATa6wB/kKTe70cfJwyRIBovMnt8RcJph/COE82uyS6FmppLLL1VBPGcPfpQPYJNXzWwi8icwhKQ6W/Qe2h3oebBb2FHpwNJDqo+TMaC/tdfkv/ElJB72jRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSY7AHvf7tR/9SVHm+KiJhTB4nOvzAKBggqhkjOPQQDAwNpADBmAjEAwGEGrfGZR1cen1R8/DTVMI943LssZmJRtDp/i7SfGHmGRP6gRbuj9vOK3b67Z0QQAjEAuT2H673LQEaHTcyQSZrkp4mX7WwkmF+sVbkYY5mXN+RMH13KUEHHOqASaemYWK/E"
118
+ }
119
+ ]
120
+ },
121
+ "validFor": {
122
+ "start": "2025-07-04T00:00:00Z"
123
+ }
124
+ }
125
+ ]
126
+ }
@@ -265,9 +265,10 @@ let AdminOperations = class AdminOperations {
265
265
  authz: { superAdmin: true },
266
266
  mirrors: ["PUT /api/v1/admin/settings"],
267
267
  // the per-org override records are orgs.set-limits (one org at a time); compaction is
268
- // changed in the admin console's settings page
268
+ // changed in the admin console's settings page, as is the publisher trust policy
269
269
  omits: [
270
270
  "confirmRetentionShortening",
271
+ "officialPublisherProof",
271
272
  "runConcurrencyOverrides",
272
273
  "sandboxLimitOverrides",
273
274
  "subagentLimitOverrides",
@@ -259,6 +259,7 @@ let OrgsOperations = class OrgsOperations {
259
259
  // one org's entries of the three override records, keyed by orgId; the deployment-wide
260
260
  // settings are admin.update-settings
261
261
  omits: [
262
+ "officialPublisherProof",
262
263
  "orgCreation",
263
264
  "runConcurrencyOverrides",
264
265
  "priceCurrency",
@@ -4,6 +4,7 @@ import { ChannelsProcessor } from "../channels/channels.module.js";
4
4
  import { ChannelOutbound } from "../channels/outbound.js";
5
5
  import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
6
6
  import { TitleQueue } from "../conversations/titles.js";
7
+ import { ServiceEventProcessor } from "../device-access/service-events.js";
7
8
  import { EvalsProcessor } from "../evals/evals.module.js";
8
9
  import { EvalWorker } from "../evals/worker.js";
9
10
  import { LifecycleHooksProcessor } from "../extensions/lifecycle-hooks.js";
@@ -49,13 +50,14 @@ export declare class WorkerRole {
49
50
  private readonly connectorToolsProcessor;
50
51
  private readonly templateConnectorsProcessor;
51
52
  private readonly toolWatchProcessor;
53
+ private readonly serviceEventProcessor;
52
54
  /** The startup config (the roles). */
53
55
  private readonly config;
54
56
  /** The run worker was started: the runs phase drains it. */
55
57
  private runsStarted;
56
58
  /** The eval worker was started: the runs phase drains it. */
57
59
  private evalsStarted;
58
- constructor(config: KernelConfigService, log: KernelLogger, intervals: LockedIntervalScheduler, scheduledRuns: ScheduledRuns, runWorker: RunWorker, evalWorker: EvalWorker, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelOutbound: ChannelOutbound, runsProcessor: RunsProcessor, subagentRunsProcessor: SubagentRunsProcessor, usageProcessor: UsageReportProcessor, titleProcessor: TitleProcessor, suggestionProcessor: PromptSuggestionProcessor, channelsProcessor: ChannelsProcessor, evalsProcessor: EvalsProcessor, maintenanceProcessor: MaintenanceProcessor, scopeProcessor: PluginScopeSyncProcessor, lifecycleProcessor: LifecycleHooksProcessor, pushProcessor: PushProcessor, connectorToolsProcessor: ConnectorToolsProcessor, templateConnectorsProcessor: TemplateConnectorsProcessor, toolWatchProcessor: ToolWatchProcessor);
60
+ constructor(config: KernelConfigService, log: KernelLogger, intervals: LockedIntervalScheduler, scheduledRuns: ScheduledRuns, runWorker: RunWorker, evalWorker: EvalWorker, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelOutbound: ChannelOutbound, runsProcessor: RunsProcessor, subagentRunsProcessor: SubagentRunsProcessor, usageProcessor: UsageReportProcessor, titleProcessor: TitleProcessor, suggestionProcessor: PromptSuggestionProcessor, channelsProcessor: ChannelsProcessor, evalsProcessor: EvalsProcessor, maintenanceProcessor: MaintenanceProcessor, scopeProcessor: PluginScopeSyncProcessor, lifecycleProcessor: LifecycleHooksProcessor, pushProcessor: PushProcessor, connectorToolsProcessor: ConnectorToolsProcessor, templateConnectorsProcessor: TemplateConnectorsProcessor, toolWatchProcessor: ToolWatchProcessor, serviceEventProcessor: ServiceEventProcessor);
59
61
  /**
60
62
  * Starts the queue consumers (after the extension load), then opens the schedules' start gate:
61
63
  * the cron and interval timers were armed at application bootstrap, but every tick before this
@@ -75,8 +77,9 @@ export declare class WorkerRole {
75
77
  /**
76
78
  * Closes the maintenance queue's worker, the plugin scope sync's (it stops between pairs), the
77
79
  * lifecycle hook deliveries' (calls in flight are aborted and retried), the push deliveries'
78
- * (sends in flight finish, each bounded by the send time limit) and the connector tool
79
- * listings' (each bounded by the tool timeout).
80
+ * (sends in flight finish, each bounded by the send time limit), the connector tool
81
+ * listings' (each bounded by the tool timeout) and the device service event deliveries' (calls in
82
+ * flight are aborted and retried).
80
83
  */
81
84
  closeMaintenance(): Promise<void>;
82
85
  }
@@ -14,6 +14,7 @@ import { ChannelsProcessor } from "../channels/channels.module.js";
14
14
  import { ChannelOutbound } from "../channels/outbound.js";
15
15
  import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
16
16
  import { TitleQueue } from "../conversations/titles.js";
17
+ import { ServiceEventProcessor } from "../device-access/service-events.js";
17
18
  import { EvalsProcessor } from "../evals/evals.module.js";
18
19
  import { EvalWorker } from "../evals/worker.js";
19
20
  import { LifecycleHooksProcessor } from "../extensions/lifecycle-hooks.js";
@@ -59,13 +60,14 @@ let WorkerRole = class WorkerRole {
59
60
  connectorToolsProcessor;
60
61
  templateConnectorsProcessor;
61
62
  toolWatchProcessor;
63
+ serviceEventProcessor;
62
64
  /** The startup config (the roles). */
63
65
  config;
64
66
  /** The run worker was started: the runs phase drains it. */
65
67
  runsStarted = false;
66
68
  /** The eval worker was started: the runs phase drains it. */
67
69
  evalsStarted = false;
68
- constructor(config, log, intervals, scheduledRuns, runWorker, evalWorker, usageReport, titles, suggestions, channelOutbound, runsProcessor, subagentRunsProcessor, usageProcessor, titleProcessor, suggestionProcessor, channelsProcessor, evalsProcessor, maintenanceProcessor, scopeProcessor, lifecycleProcessor, pushProcessor, connectorToolsProcessor, templateConnectorsProcessor, toolWatchProcessor) {
70
+ constructor(config, log, intervals, scheduledRuns, runWorker, evalWorker, usageReport, titles, suggestions, channelOutbound, runsProcessor, subagentRunsProcessor, usageProcessor, titleProcessor, suggestionProcessor, channelsProcessor, evalsProcessor, maintenanceProcessor, scopeProcessor, lifecycleProcessor, pushProcessor, connectorToolsProcessor, templateConnectorsProcessor, toolWatchProcessor, serviceEventProcessor) {
69
71
  this.log = log;
70
72
  this.intervals = intervals;
71
73
  this.scheduledRuns = scheduledRuns;
@@ -89,6 +91,7 @@ let WorkerRole = class WorkerRole {
89
91
  this.connectorToolsProcessor = connectorToolsProcessor;
90
92
  this.templateConnectorsProcessor = templateConnectorsProcessor;
91
93
  this.toolWatchProcessor = toolWatchProcessor;
94
+ this.serviceEventProcessor = serviceEventProcessor;
92
95
  this.config = config.get();
93
96
  }
94
97
  /**
@@ -112,6 +115,8 @@ let WorkerRole = class WorkerRole {
112
115
  // watched-wait polls (`cap-kernel-tool-watch`), after the extensions loaded their watchers
113
116
  this.toolWatchProcessor.start();
114
117
  this.templateConnectorsProcessor.start();
118
+ // device service events, after the extensions registered their handlers
119
+ this.serviceEventProcessor.start();
115
120
  this.channelOutbound.startWorker(this.channelsProcessor.worker);
116
121
  this.usageReport.startWorker(this.usageProcessor.worker);
117
122
  this.titles.startWorker(this.titleProcessor.worker);
@@ -141,8 +146,9 @@ let WorkerRole = class WorkerRole {
141
146
  /**
142
147
  * Closes the maintenance queue's worker, the plugin scope sync's (it stops between pairs), the
143
148
  * lifecycle hook deliveries' (calls in flight are aborted and retried), the push deliveries'
144
- * (sends in flight finish, each bounded by the send time limit) and the connector tool
145
- * listings' (each bounded by the tool timeout).
149
+ * (sends in flight finish, each bounded by the send time limit), the connector tool
150
+ * listings' (each bounded by the tool timeout) and the device service event deliveries' (calls in
151
+ * flight are aborted and retried).
146
152
  */
147
153
  async closeMaintenance() {
148
154
  await Promise.all([
@@ -153,6 +159,7 @@ let WorkerRole = class WorkerRole {
153
159
  this.connectorToolsProcessor.close(),
154
160
  this.toolWatchProcessor.close(),
155
161
  this.templateConnectorsProcessor.close(),
162
+ this.serviceEventProcessor.close(),
156
163
  ]);
157
164
  }
158
165
  };
@@ -181,6 +188,7 @@ WorkerRole = __decorate([
181
188
  __param(20, Inject(PushProcessor)),
182
189
  __param(21, Inject(ConnectorToolsProcessor)),
183
190
  __param(22, Inject(TemplateConnectorsProcessor)),
184
- __param(23, Inject(ToolWatchProcessor))
191
+ __param(23, Inject(ToolWatchProcessor)),
192
+ __param(24, Inject(ServiceEventProcessor))
185
193
  ], WorkerRole);
186
194
  export { WorkerRole };
@@ -23,7 +23,10 @@ import { AttachmentCleanupJob } from "../conversations/attachments.service.js";
23
23
  import { EventLogModule } from "../conversations/event-log.js";
24
24
  import { PromptSuggestionsModule } from "../conversations/prompt-suggestions.js";
25
25
  import { TitlesModule } from "../conversations/titles.js";
26
+ import { ExtensionEffectRelay } from "../ctx/durable-relay.js";
26
27
  import { ConversationNoticeSweepJob, ConversationNoticesModule, } from "../device-access/conversation-notice-delivery.js";
28
+ import { HostServiceStopSweepJob } from "../device-access/host-service-stop-sweep.js";
29
+ import { DeviceServiceEventWorkersModule } from "../device-access/service-events.js";
27
30
  import { DeviceSiteGrantsModule } from "../device-access/site-grants.module.js";
28
31
  import { ErasureModule } from "../erasure/erasure.module.js";
29
32
  import { ErasureSweep } from "../erasure/sweep.job.js";
@@ -102,6 +105,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
102
105
  // template connectors an org never had, owed by installs and extension switch-ons
103
106
  // (`cap-template-connectors`)
104
107
  TemplateConnectorsWorkersModule,
108
+ // device service event deliveries (`cap-device-service-events`) and their 5-minute sweep
109
+ DeviceServiceEventWorkersModule,
105
110
  // the domains the fixed-period jobs call
106
111
  RuntimeModule,
107
112
  RunJobsModule,
@@ -130,6 +135,7 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
130
135
  ConversationNoticesModule,
131
136
  ],
132
137
  providers: [
138
+ ExtensionEffectRelay,
133
139
  ...(operationalMetricsEnabled() ? [OperationalMetricsSampler] : []),
134
140
  // the one repair of a run nobody runs (transactional outbox spec §8.3)
135
141
  RunOrphanCheck,
@@ -145,6 +151,9 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
145
151
  BackgroundTaskPollJob,
146
152
  // owed conversation notices to devices' services (close tabs on delete design §4.3)
147
153
  ConversationNoticeSweepJob,
154
+ // owed host service stops of connected machines and deleted devices (local agents spec,
155
+ // call 5)
156
+ HostServiceStopSweepJob,
148
157
  // loopback port grants past their 24 hours (browser loopback port grants design §4)
149
158
  LoopbackExpiryJob,
150
159
  ToolJobs,
@@ -4,6 +4,7 @@ import { EventCoalescer } from "../automations/events/coalesce.js";
4
4
  import { TriggerDispatcher } from "../automations/events/dispatcher.js";
5
5
  import { AutomationFirer } from "../automations/fire.js";
6
6
  import { ConversationNoticeDelivery } from "../device-access/conversation-notice-delivery.js";
7
+ import { HostServiceAccess } from "../device-access/host-services.js";
7
8
  import { ErasureWorker } from "../erasure/worker.js";
8
9
  import { BlobObjects } from "../files/blob-objects.js";
9
10
  import { FileLibraryHashJob } from "../files/hash-job.js";
@@ -36,7 +37,8 @@ export declare const MAINTENANCE_CONCURRENCY = 5;
36
37
  * {@link BlobObjects}, `file-library-hash`, `file-library-hash-org` → {@link FileLibraryHashJob},
37
38
  * `platform-icon-delete` →
38
39
  * {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery},
39
- * `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
40
+ * `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}, `device-host-services-stop` →
41
+ * {@link HostServiceAccess}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
40
42
  * such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
41
43
  * maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
42
44
  * test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
@@ -64,9 +66,10 @@ export declare class MaintenanceProcessor extends WorkerHost<Worker> {
64
66
  private readonly idleCompaction;
65
67
  private readonly db;
66
68
  private readonly loopback;
69
+ private readonly hostServices;
67
70
  private readonly retention;
68
71
  private readonly erasure;
69
- constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem" | "revokeDeadHolder">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, automations: Pick<AutomationFirer, "fire" | "settle">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke" | "settleResumeProof">, blobObjects: Pick<BlobObjects, "deleteBlob" | "deleteStaging" | "releaseFile">, hashing: Pick<FileLibraryHashJob, "dispatch" | "runOrgBatch">, platformIcons: Pick<PlatformIconObjects, "deleteObject">, notices: Pick<ConversationNoticeDelivery, "attempt">, triggers: Pick<TriggerDispatcher, "dispatch">, coalescer: Pick<EventCoalescer, "flush">, idleCompaction: Pick<IdleCompactionJob, "fire">, db: KernelDb, loopback: Pick<LoopbackGrants, "refresh">, retention: Pick<RetentionWorker, "run">, erasure: Pick<ErasureWorker, "run">);
72
+ constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem" | "revokeDeadHolder">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, automations: Pick<AutomationFirer, "fire" | "settle">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke" | "settleResumeProof">, blobObjects: Pick<BlobObjects, "deleteBlob" | "deleteStaging" | "releaseFile">, hashing: Pick<FileLibraryHashJob, "dispatch" | "runOrgBatch">, platformIcons: Pick<PlatformIconObjects, "deleteObject">, notices: Pick<ConversationNoticeDelivery, "attempt">, triggers: Pick<TriggerDispatcher, "dispatch">, coalescer: Pick<EventCoalescer, "flush">, idleCompaction: Pick<IdleCompactionJob, "fire">, db: KernelDb, loopback: Pick<LoopbackGrants, "refresh">, hostServices: Pick<HostServiceAccess, "deliverOwedStops">, retention: Pick<RetentionWorker, "run">, erasure: Pick<ErasureWorker, "run">);
70
73
  process(job: Job, token?: string): Promise<void>;
71
74
  /** Starts consuming (worker role, after the extensions loaded; built with `autorun: false`). */
72
75
  start(): void;
@@ -19,6 +19,9 @@ import { EventLogModule } from "../conversations/event-log.js";
19
19
  import { resolveConversationOrg, resolveRunOrg } from "../conversations/job-org.js";
20
20
  import { ConversationNoticeDelivery, ConversationNoticesModule, NOTICE_PROMPT_TIMEOUT_MS, } from "../device-access/conversation-notice-delivery.js";
21
21
  import { CONVERSATION_NOTICE_JOB, } from "../device-access/conversation-notices.js";
22
+ import { ExtensionDeviceAccessModule } from "../device-access/device-access.module.js";
23
+ import { HOST_SERVICES_STOP_JOB, } from "../device-access/host-service-stop.js";
24
+ import { HostServiceAccess } from "../device-access/host-services.js";
22
25
  import { DATA_ERASURE_JOB } from "../erasure/jobs.js";
23
26
  import { ErasureWorker, ErasureWorkerModule } from "../erasure/worker.js";
24
27
  import { BLOB_DELETE_JOB, BlobObjects, BlobObjectsModule, FILE_RELEASE_JOB, FILE_STAGING_DELETE_JOB, } from "../files/blob-objects.js";
@@ -71,7 +74,8 @@ export const MAINTENANCE_CONCURRENCY = 5;
71
74
  * {@link BlobObjects}, `file-library-hash`, `file-library-hash-org` → {@link FileLibraryHashJob},
72
75
  * `platform-icon-delete` →
73
76
  * {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery},
74
- * `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
77
+ * `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}, `device-host-services-stop` →
78
+ * {@link HostServiceAccess}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
75
79
  * such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
76
80
  * maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
77
81
  * test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
@@ -99,9 +103,10 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
99
103
  idleCompaction;
100
104
  db;
101
105
  loopback;
106
+ hostServices;
102
107
  retention;
103
108
  erasure;
104
- constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, automations, scheduled, log, operations, blobObjects, hashing, platformIcons, notices, triggers, coalescer, idleCompaction, db, loopback, retention, erasure) {
109
+ constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, automations, scheduled, log, operations, blobObjects, hashing, platformIcons, notices, triggers, coalescer, idleCompaction, db, loopback, hostServices, retention, erasure) {
105
110
  super();
106
111
  this.permissionApprovals = permissionApprovals;
107
112
  this.waits = waits;
@@ -124,6 +129,7 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
124
129
  this.idleCompaction = idleCompaction;
125
130
  this.db = db;
126
131
  this.loopback = loopback;
132
+ this.hostServices = hostServices;
127
133
  this.retention = retention;
128
134
  this.erasure = erasure;
129
135
  }
@@ -305,6 +311,11 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
305
311
  case LOOPBACK_REFRESH_JOB:
306
312
  await this.loopback.refresh(job.data, AbortSignal.timeout(LOOPBACK_REFRESH_TIMEOUT_MS));
307
313
  return;
314
+ // a switched-off extension's host services on the machines that run them (local agents
315
+ // spec, call 5)
316
+ case HOST_SERVICES_STOP_JOB:
317
+ await this.hostServices.deliverOwedStops(job.data);
318
+ return;
308
319
  // a large idle conversation's compaction before its prompt cache expires (idle compaction §4.3)
309
320
  case IDLE_COMPACTION_JOB: {
310
321
  const data = job.data;
@@ -356,8 +367,9 @@ MaintenanceProcessor = __decorate([
356
367
  __param(18, Inject(IdleCompactionJob)),
357
368
  __param(19, Inject(KernelDb)),
358
369
  __param(20, Inject(LoopbackGrants)),
359
- __param(21, Inject(RetentionWorker)),
360
- __param(22, Inject(ErasureWorker))
370
+ __param(21, Inject(HostServiceAccess)),
371
+ __param(22, Inject(RetentionWorker)),
372
+ __param(23, Inject(ErasureWorker))
361
373
  ], MaintenanceProcessor);
362
374
  export { MaintenanceProcessor };
363
375
  /**
@@ -394,6 +406,8 @@ MaintenanceModule = __decorate([
394
406
  PlatformIconObjectsModule,
395
407
  // a deleted conversation's notice to its device's services
396
408
  ConversationNoticesModule,
409
+ // a switched-off extension's host services stop
410
+ ExtensionDeviceAccessModule,
397
411
  QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
398
412
  ],
399
413
  providers: [
@@ -68,10 +68,10 @@ export declare class DeviceReports {
68
68
  changed: boolean;
69
69
  }>;
70
70
  /**
71
- * `ctx.devices.reportChanged(deviceId)` of the extension `plugin`: `not-served` unless the
72
- * device is live and bound to `plugin` (the caller refuses it); otherwise reads the device's
73
- * report and permission support from `plugin` (its current instance's handle, if any) outside
74
- * any transaction and stores them as {@link refresh} does. Throws when the report cannot be read
71
+ * `ctx.devices.reportChanged(deviceId)` returns `not-served` unless the device is live, bound to
72
+ * `plugin`, and in the caller's org if the caller has an org scope. Reads the device's report and
73
+ * permission support from `plugin` (with its current instance's handle, if any) outside any
74
+ * transaction and stores them as {@link refresh} does. Throws when the report cannot be read
75
75
  * or does not pass, so the provider may tell again; a failed support read stores no support
76
76
  * (no crossing enforceable: revocation fails closed).
77
77
  */
@@ -11,6 +11,7 @@ import { parseDeviceReport, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable, Optional } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
13
  import { KernelDb } from "../infra/database/kernel-db.js";
14
+ import { asPlatform, currentScope, withOrgScope } from "../infra/database/org-scope.js";
14
15
  import { runOutsideTransaction, TransactionHost } from "../infra/database/transaction-host.js";
15
16
  import { Transactional } from "../infra/database/transactional.decorator.js";
16
17
  import { LockService } from "../infra/lock/lock.service.js";
@@ -132,42 +133,51 @@ let DeviceReports = class DeviceReports {
132
133
  }
133
134
  }
134
135
  /**
135
- * `ctx.devices.reportChanged(deviceId)` of the extension `plugin`: `not-served` unless the
136
- * device is live and bound to `plugin` (the caller refuses it); otherwise reads the device's
137
- * report and permission support from `plugin` (its current instance's handle, if any) outside
138
- * any transaction and stores them as {@link refresh} does. Throws when the report cannot be read
136
+ * `ctx.devices.reportChanged(deviceId)` returns `not-served` unless the device is live, bound to
137
+ * `plugin`, and in the caller's org if the caller has an org scope. Reads the device's report and
138
+ * permission support from `plugin` (with its current instance's handle, if any) outside any
139
+ * transaction and stores them as {@link refresh} does. Throws when the report cannot be read
139
140
  * or does not pass, so the provider may tell again; a failed support read stores no support
140
141
  * (no crossing enforceable: revocation fails closed).
141
142
  */
142
143
  async changed(plugin, deviceId, signal = new AbortController().signal) {
143
144
  return runOutsideTransaction(async () => {
144
- const device = await this.db
145
- .selectFrom("devices as d")
146
- .innerJoin("orgs as o", "o.id", "d.org_id")
147
- .select(["d.org_id", "d.provider"])
148
- .where("d.id", "=", deviceId)
149
- .where("d.deleted_at", "is", null)
150
- .where("o.deleted_at", "is", null)
151
- .executeTakeFirst();
152
- if (!device || device.provider !== plugin)
153
- return "not-served";
154
- const entry = this.providers.forDevice(plugin);
155
- if (!entry)
156
- throw new Error(`Device provider ${plugin} is not loaded on this replica`);
157
- const instance = await this.db
158
- .selectFrom("device_instances")
159
- .select("handle")
160
- .where("device_id", "=", deviceId)
161
- .where("org_id", "=", device.org_id)
162
- .where("provider", "=", plugin)
163
- .executeTakeFirst();
164
- const ref = {
165
- deviceId,
166
- orgId: device.org_id,
167
- handle: (instance?.handle ?? null),
145
+ const scope = currentScope();
146
+ const lookup = () => {
147
+ const query = this.db
148
+ .selectFrom("devices as d")
149
+ .innerJoin("orgs as o", "o.id", "d.org_id")
150
+ .select("d.org_id")
151
+ .where("d.id", "=", deviceId)
152
+ .where("d.provider", "=", plugin)
153
+ .where("d.deleted_at", "is", null)
154
+ .where("o.deleted_at", "is", null);
155
+ return (scope?.kind === "org" ? query.where("d.org_id", "=", scope.orgId) : query).executeTakeFirst();
168
156
  };
169
- const answer = await this.ask(entry, ref, signal, true);
170
- return (await this.store(plugin, ref, answer)).published ? "bumped" : "same";
157
+ const device = scope
158
+ ? await lookup()
159
+ : await asPlatform("resolve the org of a device served by the notifying provider", lookup);
160
+ if (!device)
161
+ return "not-served";
162
+ return withOrgScope(device.org_id, async () => {
163
+ const entry = this.providers.forDevice(plugin);
164
+ if (!entry)
165
+ throw new Error(`Device provider ${plugin} is not loaded on this replica`);
166
+ const instance = await this.db
167
+ .selectFrom("device_instances")
168
+ .select("handle")
169
+ .where("device_id", "=", deviceId)
170
+ .where("org_id", "=", device.org_id)
171
+ .where("provider", "=", plugin)
172
+ .executeTakeFirst();
173
+ const ref = {
174
+ deviceId,
175
+ orgId: device.org_id,
176
+ handle: (instance?.handle ?? null),
177
+ };
178
+ const answer = await this.ask(entry, ref, signal, true);
179
+ return (await this.store(plugin, ref, answer)).published ? "bumped" : "same";
180
+ });
171
181
  });
172
182
  }
173
183
  /**
@@ -64,7 +64,8 @@ export declare class DeviceServices {
64
64
  * Starts the service in the device, or finds it running (the provider keeps a running one).
65
65
  * With `ifRunning` it never starts one: a stopped service answers its `stopped` status, and the
66
66
  * provider gets only the name ({@link nameOnlySpec}), as with every ifRunning ensure. A spec
67
- * breaking {@link serviceSpecIssue} is refused before the device is touched.
67
+ * breaking {@link serviceSpecIssue}, or a host spec (`host` set: `host_not_declared`), is refused
68
+ * before the device is touched.
68
69
  */
69
70
  ensure(use: SandboxUseContext, spec: DeviceServiceSpec, signal: AbortSignal, opts?: {
70
71
  ifRunning?: boolean;
@@ -113,10 +113,14 @@ let DeviceServices = class DeviceServices {
113
113
  * Starts the service in the device, or finds it running (the provider keeps a running one).
114
114
  * With `ifRunning` it never starts one: a stopped service answers its `stopped` status, and the
115
115
  * provider gets only the name ({@link nameOnlySpec}), as with every ifRunning ensure. A spec
116
- * breaking {@link serviceSpecIssue} is refused before the device is touched.
116
+ * breaking {@link serviceSpecIssue}, or a host spec (`host` set: `host_not_declared`), is refused
117
+ * before the device is touched.
117
118
  */
118
119
  async ensure(use, spec, signal, opts = {}) {
119
120
  assertServiceSpec(spec);
121
+ // a host service starts only through its own admission (`HostServiceAccess`), never here
122
+ if (spec.host !== undefined)
123
+ throw new DeviceAccessError("host_not_declared", `The device service spec ${spec.name} sets host: a host service starts only through ensureHostService.`);
120
124
  return this.sandbox.withDeviceServices(use, requireServices, (h, p, sig) => {
121
125
  const ensure = p.ensureService;
122
126
  // read under the use and the set lock, so a grant committed before it is in the set
@@ -22,6 +22,14 @@ export declare class PermissionCeilingWrites {
22
22
  /** The platform writer excludes every descendant; only these environments changed Full reach. */
23
23
  invalidateDeviceConsentUnderPlatform(deviceIds: readonly string[], platformProfiles?: readonly PermissionProfile[]): Promise<void>;
24
24
  publishLocked(subject: AuthoritySubject, level: "platform" | "org" | "device" | "root", revoke?: boolean | ((scope: SandboxOperationScope | SandboxBrowseScope, row: Selectable<SandboxOperationIntentsTable>) => boolean), invalidateFullConsent?: boolean, refreshStartedServices?: boolean, platformProfiles?: readonly PermissionProfile[]): Promise<void>;
25
+ /**
26
+ * The host gate closed under the subject (local agents spec, call 1: a platform or org project
27
+ * reach cap narrowed below `machine`, or running outside the sandbox switched off there): every
28
+ * host service under it, a whole-machine escalation, is owed a stop in the writer's transaction,
29
+ * under the writer's exclusive lock of its level. The host gate refuses new ones once it
30
+ * commits, and its admission reads under the shared authority locks (`HostServiceGate.admit`).
31
+ */
32
+ oweHostServiceStopsLocked(subject: AuthoritySubject, level: "platform" | "org"): Promise<void>;
25
33
  /** Full access consent only grows where the org inherits the widened platform reach. */
26
34
  invalidateProjectReachWideningLocked(before: DeviceProjectReach, after: DeviceProjectReach, platformProfiles?: readonly PermissionProfile[]): Promise<void>;
27
35
  /** Selected profiles removed by an org or platform ceiling reset before the writer commits. */
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { narrowerProjectReach, } from "@capybara-hq/plugin-sdk";
11
11
  import { Inject, Injectable, Optional } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
+ import { oweHostServicesStop } from "../device-access/host-service-stop.js";
13
14
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
14
15
  import { KernelDb } from "../infra/database/kernel-db.js";
15
16
  import { asPlatform } from "../infra/database/org-scope.js";
@@ -122,6 +123,11 @@ let PermissionCeilingWrites = class PermissionCeilingWrites {
122
123
  rootConversationId: subject.rootConversationId,
123
124
  }),
124
125
  }, `c${level}-${id}-${epoch}`, refreshStartedServices);
126
+ // a project reach narrowed at the platform or the org (the writers pass it as
127
+ // `refreshStartedServices`) leaves it below `machine` for every device under the subject,
128
+ // which closes the host gate there
129
+ if (refreshStartedServices && (level === "platform" || level === "org"))
130
+ await this.oweHostServiceStopsLocked(subject, level);
125
131
  if (!revoke)
126
132
  return;
127
133
  // Acknowledged background starts stay revocable by every actual revoking writer (deletion is
@@ -170,6 +176,18 @@ let PermissionCeilingWrites = class PermissionCeilingWrites {
170
176
  });
171
177
  }
172
178
  }
179
+ /**
180
+ * The host gate closed under the subject (local agents spec, call 1: a platform or org project
181
+ * reach cap narrowed below `machine`, or running outside the sandbox switched off there): every
182
+ * host service under it, a whole-machine escalation, is owed a stop in the writer's transaction,
183
+ * under the writer's exclusive lock of its level. The host gate refuses new ones once it
184
+ * commits, and its admission reads under the shared authority locks (`HostServiceGate.admit`).
185
+ */
186
+ async oweHostServiceStopsLocked(subject, level) {
187
+ const orgId = level === "org" ? required(subject.orgId) : undefined;
188
+ this.locks.assertHeld(level, orgId ?? "platform", true);
189
+ await oweHostServicesStop(this.db.db, this.outbox, orgId === undefined ? {} : { orgId });
190
+ }
173
191
  /** Full access consent only grows where the org inherits the widened platform reach. */
174
192
  async invalidateProjectReachWideningLocked(before, after, platformProfiles) {
175
193
  if (narrowerProjectReach(before, after) === after)
@@ -293,6 +311,9 @@ __decorate([
293
311
  __decorate([
294
312
  Transactional({ propagation: "mandatory" })
295
313
  ], PermissionCeilingWrites.prototype, "publishLocked", null);
314
+ __decorate([
315
+ Transactional({ propagation: "mandatory" })
316
+ ], PermissionCeilingWrites.prototype, "oweHostServiceStopsLocked", null);
296
317
  __decorate([
297
318
  Transactional({ propagation: "mandatory" })
298
319
  ], PermissionCeilingWrites.prototype, "invalidateProjectReachWideningLocked", null);
@@ -159,10 +159,11 @@ let PermissionConfigPublication = class PermissionConfigPublication {
159
159
  const projection = permissionConfigProjection(this.config.get());
160
160
  const initialize = () => this.initializeLocked(projection, options.activation);
161
161
  if (options.startup) {
162
- const { url, connectTimeoutMs } = this.config.get().db;
162
+ const { url, connectTimeoutMs, rls } = this.config.get().db;
163
163
  return this.txHost.runStartupActivation(initialize, {
164
164
  connectionString: url,
165
165
  connectTimeoutMs,
166
+ rls,
166
167
  ...options.startup,
167
168
  });
168
169
  }
@@ -315,6 +316,9 @@ let PermissionConfigPublication = class PermissionConfigPublication {
315
316
  },
316
317
  // only a widening resets Full consent: a narrowing keeps what the consent covered
317
318
  (beforeMode === "off" && nextMode === "allowed") || networkWidened || hostsWidened, reachTightened, nextView.allowedProfiles.value);
319
+ // running outside the sandbox switched off closes the host gate on every device
320
+ if (beforeMode !== "off" && nextMode === "off")
321
+ await this.ceilings.oweHostServiceStopsLocked({}, "platform");
318
322
  if (beforeReach !== nextReach && !reachTightened)
319
323
  await this.ceilings.invalidateProjectReachWideningLocked(beforeReach, nextReach, nextView.allowedProfiles.value);
320
324
  return "activated";