@capybara-hq/kernel 0.1.0-rc.53 → 0.1.0-rc.55

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 (190) hide show
  1. package/dist/admin/admin.schemas.d.ts +11 -1
  2. package/dist/catalog/catalog.module.js +1 -1
  3. package/dist/catalog/marketplaces.service.d.ts +1 -1
  4. package/dist/catalog/requests.service.d.ts +5 -5
  5. package/dist/catalog/requests.service.js +9 -9
  6. package/dist/channels/cards.d.ts +4 -3
  7. package/dist/channels/cards.js +25 -16
  8. package/dist/channels/phrases.d.ts +15 -4
  9. package/dist/channels/phrases.js +15 -1
  10. package/dist/config/load.d.ts +26 -7
  11. package/dist/config/load.js +60 -9
  12. package/dist/config/permission-migration.d.ts +17 -9
  13. package/dist/config/permission-migration.js +60 -9
  14. package/dist/config/schema.d.ts +15 -1
  15. package/dist/config/schema.js +66 -11
  16. package/dist/conversations/events.d.ts +247 -5
  17. package/dist/conversations/events.js +127 -16
  18. package/dist/conversations/permission-profiles.controller.d.ts +12 -2
  19. package/dist/conversations/permission-profiles.service.d.ts +12 -2
  20. package/dist/conversations/permission-profiles.service.js +11 -4
  21. package/dist/db/kernel-schema.d.ts +18 -2
  22. package/dist/devices/device-projects.service.d.ts +1 -1
  23. package/dist/devices/device-projects.service.js +6 -6
  24. package/dist/devices/devices.controller.d.ts +10 -8
  25. package/dist/devices/devices.controller.js +14 -18
  26. package/dist/devices/devices.schemas.d.ts +5 -5
  27. package/dist/devices/devices.schemas.js +5 -5
  28. package/dist/devices/devices.service.d.ts +188 -175
  29. package/dist/devices/devices.service.js +284 -292
  30. package/dist/devices/dto.d.ts +43 -23
  31. package/dist/devices/dto.js +45 -49
  32. package/dist/devices/project-rules.d.ts +0 -10
  33. package/dist/devices/project-rules.js +0 -5
  34. package/dist/errors.d.ts +43 -19
  35. package/dist/errors.js +43 -19
  36. package/dist/evals/reconstruct.d.ts +12 -3
  37. package/dist/evals/reconstruct.js +10 -6
  38. package/dist/evals/recorded-permission-context.d.ts +6 -4
  39. package/dist/evals/recorded-permission-context.js +15 -9
  40. package/dist/evals/run-replay.d.ts +6 -1
  41. package/dist/evals/run-replay.js +7 -2
  42. package/dist/evals/worker.js +3 -1
  43. package/dist/http/api.module.js +8 -0
  44. package/dist/http/app.js +9 -0
  45. package/dist/http/meta.controller.d.ts +33 -0
  46. package/dist/http/meta.controller.js +72 -0
  47. package/dist/identity/app-auth.controller.d.ts +25 -0
  48. package/dist/identity/app-auth.controller.js +64 -0
  49. package/dist/identity/app-auth.d.ts +66 -0
  50. package/dist/identity/app-auth.js +203 -0
  51. package/dist/identity/app-auth.schemas.d.ts +47 -0
  52. package/dist/identity/app-auth.schemas.js +43 -0
  53. package/dist/identity/identity.module.d.ts +1 -1
  54. package/dist/identity/identity.module.js +4 -1
  55. package/dist/identity/settings.d.ts +45 -18
  56. package/dist/identity/settings.js +151 -51
  57. package/dist/infra/config/kernel-config.service.d.ts +1 -1
  58. package/dist/infra/config/kernel-config.service.js +19 -5
  59. package/dist/infra/outbox/registry.d.ts +14 -0
  60. package/dist/infra/outbox/registry.js +15 -0
  61. package/dist/infra/throttler/named-throttlers.d.ts +3 -2
  62. package/dist/infra/throttler/named-throttlers.js +14 -2
  63. package/dist/local-devices/device-auth.controller.d.ts +1 -1
  64. package/dist/local-devices/device-auth.controller.js +1 -1
  65. package/dist/local-devices/device-auth.d.ts +4 -4
  66. package/dist/local-devices/device-auth.js +1 -1
  67. package/dist/local-devices/device-policy.service.d.ts +18 -9
  68. package/dist/local-devices/device-policy.service.js +21 -61
  69. package/dist/local-devices/device-routes.d.ts +3 -1
  70. package/dist/local-devices/device-routes.js +15 -4
  71. package/dist/local-devices/instance-bindings.js +5 -2
  72. package/dist/local-devices/local-device-gateway.d.ts +2 -2
  73. package/dist/local-devices/local-device-gateway.js +3 -3
  74. package/dist/local-devices/local-device-provider.d.ts +4 -4
  75. package/dist/local-devices/local-device-provider.js +23 -9
  76. package/dist/local-devices/local-devices.module.d.ts +1 -1
  77. package/dist/local-devices/local-devices.module.js +1 -1
  78. package/dist/local-devices/machines.d.ts +40 -16
  79. package/dist/local-devices/machines.js +89 -61
  80. package/dist/local-devices/owner-report.d.ts +16 -14
  81. package/dist/local-devices/owner-report.js +24 -30
  82. package/dist/local-devices/owner-reports.js +26 -8
  83. package/dist/local-devices/policy-summary.d.ts +25 -44
  84. package/dist/local-devices/policy-summary.js +26 -71
  85. package/dist/local-devices/relay.d.ts +6 -6
  86. package/dist/local-devices/relay.js +10 -8
  87. package/dist/net/public-address.d.ts +1 -1
  88. package/dist/net/public-address.js +5 -2
  89. package/dist/orgs/device-network-setting.d.ts +82 -0
  90. package/dist/orgs/device-network-setting.js +142 -0
  91. package/dist/orgs/settings.service.d.ts +103 -66
  92. package/dist/orgs/settings.service.js +201 -137
  93. package/dist/overrides.d.ts +5 -1
  94. package/dist/overrides.js +2 -0
  95. package/dist/platform/exclusions.js +24 -1
  96. package/dist/platform/operation.js +2 -2
  97. package/dist/platform/ops/admin.ops.js +20 -11
  98. package/dist/platform/ops/devices.ops.js +70 -5
  99. package/dist/platform/ops/org-settings.ops.js +10 -6
  100. package/dist/platform/ops/orgs.ops.js +2 -1
  101. package/dist/platform/ops/platform-icons.ops.d.ts +14 -0
  102. package/dist/platform/ops/platform-icons.ops.js +117 -0
  103. package/dist/platform/platform-ops.module.d.ts +2 -1
  104. package/dist/platform/platform-ops.module.js +3 -0
  105. package/dist/platform/route-schemas.js +3 -0
  106. package/dist/runtime/context/permission-profile.d.ts +17 -8
  107. package/dist/runtime/context/permission-profile.js +126 -45
  108. package/dist/runtime/maintenance.d.ts +5 -2
  109. package/dist/runtime/maintenance.js +15 -4
  110. package/dist/runtime/permission-context.service.d.ts +1 -1
  111. package/dist/runtime/permission-context.service.js +5 -3
  112. package/dist/runtime/project/knowledge.d.ts +5 -4
  113. package/dist/runtime/project/knowledge.js +2 -1
  114. package/dist/runtime/project/knowledge.service.js +16 -13
  115. package/dist/sandbox/cloud-permission-snapshot.js +22 -3
  116. package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
  117. package/dist/sandbox/device-sandbox-settings.js +470 -0
  118. package/dist/sandbox/device-sandbox.d.ts +187 -0
  119. package/dist/sandbox/device-sandbox.js +236 -0
  120. package/dist/sandbox/held-operations.js +15 -7
  121. package/dist/sandbox/modes.d.ts +49 -24
  122. package/dist/sandbox/modes.js +27 -19
  123. package/dist/sandbox/operation-authority-types.d.ts +6 -5
  124. package/dist/sandbox/operation-authority-types.js +7 -8
  125. package/dist/sandbox/operation-authority.d.ts +23 -9
  126. package/dist/sandbox/operation-authority.js +179 -97
  127. package/dist/sandbox/permission-auto-grants.d.ts +42 -0
  128. package/dist/sandbox/permission-auto-grants.js +145 -0
  129. package/dist/sandbox/permission-call-grants.d.ts +12 -4
  130. package/dist/sandbox/permission-call-grants.js +84 -35
  131. package/dist/sandbox/permission-call-grants.module.js +10 -3
  132. package/dist/sandbox/permission-call-types.d.ts +39 -5
  133. package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
  134. package/dist/sandbox/permission-ceiling-writes.js +38 -4
  135. package/dist/sandbox/permission-config-publication.d.ts +44 -2
  136. package/dist/sandbox/permission-config-publication.js +230 -59
  137. package/dist/sandbox/permission-context-types.d.ts +2 -2
  138. package/dist/sandbox/permission-facts.d.ts +144 -15
  139. package/dist/sandbox/permission-facts.js +258 -70
  140. package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
  141. package/dist/sandbox/permission-runtime-reports.js +19 -29
  142. package/dist/sandbox/review/classifier.d.ts +8 -0
  143. package/dist/sandbox/review/classifier.js +10 -0
  144. package/dist/sandbox/review/permission-candidate.d.ts +69 -5
  145. package/dist/sandbox/review/permission-candidate.js +153 -30
  146. package/dist/sandbox/review/review.service.d.ts +19 -3
  147. package/dist/sandbox/review/review.service.js +59 -11
  148. package/dist/sandbox/review/rules.js +23 -3
  149. package/dist/sandbox/sandbox.service.d.ts +29 -11
  150. package/dist/sandbox/sandbox.service.js +51 -26
  151. package/dist/skills/invoke.js +3 -2
  152. package/dist/themes/platform-icon-objects.d.ts +51 -0
  153. package/dist/themes/platform-icon-objects.js +113 -0
  154. package/dist/themes/platform-icon-public.controller.d.ts +17 -0
  155. package/dist/themes/platform-icon-public.controller.js +58 -0
  156. package/dist/themes/platform-icon.controller.d.ts +22 -0
  157. package/dist/themes/platform-icon.controller.js +65 -0
  158. package/dist/themes/platform-icon.schemas.d.ts +48 -0
  159. package/dist/themes/platform-icon.schemas.js +53 -0
  160. package/dist/themes/platform-icon.service.d.ts +83 -0
  161. package/dist/themes/platform-icon.service.js +301 -0
  162. package/dist/themes/themes.module.d.ts +4 -1
  163. package/dist/themes/themes.module.js +9 -4
  164. package/dist/tools/approvals.service.d.ts +26 -116
  165. package/dist/tools/approvals.service.js +42 -346
  166. package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
  167. package/dist/tools/builtins/sandbox/bash.js +80 -28
  168. package/dist/tools/builtins/sandbox/common.d.ts +39 -14
  169. package/dist/tools/builtins/sandbox/common.js +47 -24
  170. package/dist/tools/builtins/sandbox/deliver.js +7 -4
  171. package/dist/tools/builtins/skill-load.d.ts +2 -2
  172. package/dist/tools/builtins/skill-load.js +4 -3
  173. package/dist/tools/device-op-resolver.d.ts +4 -10
  174. package/dist/tools/device-op-resolver.js +8 -19
  175. package/dist/tools/network-asks.d.ts +52 -15
  176. package/dist/tools/network-asks.js +55 -25
  177. package/dist/tools/pipeline.d.ts +26 -14
  178. package/dist/tools/pipeline.js +144 -61
  179. package/dist/tools/registry.d.ts +6 -0
  180. package/dist/tools/tools.module.js +1 -1
  181. package/package.json +4 -4
  182. package/src/migrations/0164_platform_icons.sql +10 -0
  183. package/src/migrations/0165_device_network_columns.sql +50 -0
  184. package/src/migrations/0166_permission_grant_full_access.sql +17 -0
  185. package/src/migrations/0167_device_network_backfill.sql +32 -0
  186. package/src/migrations/0168_binding_installed_connection.sql +6 -0
  187. package/dist/orgs/cloud-network-setting.d.ts +0 -33
  188. package/dist/orgs/cloud-network-setting.js +0 -47
  189. package/dist/sandbox/platform-full-access.d.ts +0 -110
  190. package/dist/sandbox/platform-full-access.js +0 -198
@@ -0,0 +1,230 @@
1
+ import { z } from "zod";
2
+ import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
+ import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
4
+ import type { KernelLogger } from "../log.js";
5
+ import { type DeviceNetworkSetting } from "../orgs/device-network-setting.js";
6
+ import type { DeviceNetworkMode, DeviceSandboxSettings } from "./device-sandbox.js";
7
+ /**
8
+ * The platform's device sandbox settings (approval-only profiles design, "Settings model"): the
9
+ * outside-sandbox ceiling (`devices.outsideSandbox`) and the sandbox network's default and ceiling
10
+ * (`devices.network.default`, `devices.network.ceiling`). Each is both a startup config field and
11
+ * a deployment setting ({@link DEVICES_OUTSIDE_SANDBOX_SETTING}, {@link DEVICES_NETWORK_SETTING}),
12
+ * read live at every use: environment > config file / Nacos > the super admin's choice in the admin
13
+ * console > {@link DEVICE_SANDBOX_DEFAULTS}. A field set in the startup config is read-only in the
14
+ * admin console. An invalid stored value reads narrower with a warning (fail closed): `off`, and
15
+ * the allowlist.
16
+ *
17
+ * Before 0.1.0 the old keys are converted, never aliased: the deployment settings
18
+ * `devicesFullAccess` and `devicesAutoMode` and the org keys `fullAccess`, `autoMode` and
19
+ * `cloudNetwork` are read (the narrower wins) until the permission configuration publication
20
+ * converts them ({@link convertStoredPermissionKeys}); writes keep a still stored old key in step
21
+ * for replicas of the previous version. An old `off` kept every device on the allowlist, so it
22
+ * converts to `outsideSandbox: off` plus an allowlist network ceiling (never wider).
23
+ */
24
+ export type OutsideSandboxPermission = "allowed" | "off";
25
+ /** The `deployment_settings` key of the super admin's outside-sandbox choice. */
26
+ export declare const DEVICES_OUTSIDE_SANDBOX_SETTING = "devicesOutsideSandbox";
27
+ /** The `deployment_settings` key of the super admin's network choice. */
28
+ export declare const DEVICES_NETWORK_SETTING = "devicesNetwork";
29
+ /** The old key of the outside-sandbox choice (B1's Full switch), read only to convert it. */
30
+ export declare const LEGACY_DEVICES_FULL_ACCESS_SETTING = "devicesFullAccess";
31
+ /** The key B1 converted (the auto-mode switch), read only to convert it. */
32
+ export declare const LEGACY_DEVICES_AUTO_MODE_SETTING = "devicesAutoMode";
33
+ /** What a deployment with neither the startup config nor the stored choice says. */
34
+ export declare const DEVICE_SANDBOX_DEFAULTS: DeviceSandboxSettings;
35
+ /** The stored outside-sandbox choice: `permission` absent follows the default. */
36
+ export declare const DevicesOutsideSandboxStoredSchema: z.ZodObject<{
37
+ permission: z.ZodOptional<z.ZodEnum<{
38
+ allowed: "allowed";
39
+ off: "off";
40
+ }>>;
41
+ }, z.core.$strict>;
42
+ export type DevicesOutsideSandboxStored = z.infer<typeof DevicesOutsideSandboxStoredSchema>;
43
+ /** The stored network choice: a field absent follows the default. */
44
+ export declare const DevicesNetworkStoredSchema: z.ZodObject<{
45
+ default: z.ZodOptional<z.ZodEnum<{
46
+ allowlist: "allowlist";
47
+ open: "open";
48
+ }>>;
49
+ ceiling: z.ZodOptional<z.ZodEnum<{
50
+ allowlist: "allowlist";
51
+ open: "open";
52
+ }>>;
53
+ }, z.core.$strict>;
54
+ export type DevicesNetworkStored = z.infer<typeof DevicesNetworkStoredSchema>;
55
+ /** Both stored choices. */
56
+ export interface StoredDeviceSandbox {
57
+ outsideSandbox: DevicesOutsideSandboxStored;
58
+ network: DevicesNetworkStored;
59
+ }
60
+ /**
61
+ * A change of the stored outside-sandbox choice (`PUT /api/v1/admin/settings`
62
+ * `devicesOutsideSandbox`): `permission: null` clears it, back to the default `allowed`.
63
+ */
64
+ export declare const DEVICES_OUTSIDE_SANDBOX_PATCH: z.ZodObject<{
65
+ permission: z.ZodNullable<z.ZodEnum<{
66
+ allowed: "allowed";
67
+ off: "off";
68
+ }>>;
69
+ }, z.core.$strict>;
70
+ export type DevicesOutsideSandboxPatch = z.infer<typeof DEVICES_OUTSIDE_SANDBOX_PATCH>;
71
+ /**
72
+ * A change of the stored network choice (`devicesNetwork`): each given field replaces the stored
73
+ * one, null clears it (back to the default `open`); at least one field.
74
+ */
75
+ export declare const DEVICES_NETWORK_PATCH: z.ZodObject<{
76
+ default: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
77
+ allowlist: "allowlist";
78
+ open: "open";
79
+ }>>>;
80
+ ceiling: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
81
+ allowlist: "allowlist";
82
+ open: "open";
83
+ }>>>;
84
+ }, z.core.$strict>;
85
+ export type DevicesNetworkPatch = z.infer<typeof DEVICES_NETWORK_PATCH>;
86
+ /** Where an effective value comes from. */
87
+ export type DeviceSandboxSource = "env" | "file" | "nacos" | "db" | "default";
88
+ type ConfigSource = Exclude<DeviceSandboxSource, "db" | "default">;
89
+ /** The admin console's view of the outside-sandbox ceiling. */
90
+ export interface DevicesOutsideSandboxView {
91
+ permission: OutsideSandboxPermission;
92
+ source: DeviceSandboxSource;
93
+ }
94
+ /** The admin console's view of the network: effective values (the default within the ceiling). */
95
+ export interface DevicesNetworkView {
96
+ default: DeviceNetworkMode;
97
+ ceiling: DeviceNetworkMode;
98
+ sources: {
99
+ default: DeviceSandboxSource;
100
+ ceiling: DeviceSandboxSource;
101
+ };
102
+ }
103
+ export interface DeviceSandboxSettingsView {
104
+ outsideSandbox: DevicesOutsideSandboxView;
105
+ network: DevicesNetworkView;
106
+ }
107
+ /** The startup config's values and where each comes from (undefined: not set there). */
108
+ export interface ConfiguredDeviceSandbox {
109
+ outsideSandbox?: OutsideSandboxPermission | undefined;
110
+ networkDefault?: DeviceNetworkMode | undefined;
111
+ networkCeiling?: DeviceNetworkMode | undefined;
112
+ sources: {
113
+ outsideSandbox?: ConfigSource | undefined;
114
+ networkDefault?: ConfigSource | undefined;
115
+ networkCeiling?: ConfigSource | undefined;
116
+ };
117
+ }
118
+ /**
119
+ * Parses a stored outside-sandbox choice: missing -> `{}`; invalid -> `{ permission: "off" }` with
120
+ * a warning, narrower, never wider.
121
+ */
122
+ export declare function parseStoredDevicesOutsideSandbox(value: unknown, log?: Pick<KernelLogger, "warn">): DevicesOutsideSandboxStored;
123
+ /**
124
+ * Parses a stored network choice: missing -> `{}`; invalid -> the allowlist for both with a
125
+ * warning, narrower, never wider.
126
+ */
127
+ export declare function parseStoredDevicesNetwork(value: unknown, log?: Pick<KernelLogger, "warn">): DevicesNetworkStored;
128
+ /**
129
+ * Converts a stored old `devicesFullAccess` (`{ permission }`): the same permission, and an `off`
130
+ * also limits the network ceiling to the allowlist; an invalid value converts to `off` with a
131
+ * warning, never absent.
132
+ */
133
+ export declare function parseLegacyStoredDevicesFullAccess(value: unknown, log?: Pick<KernelLogger, "warn">): StoredDeviceSandbox;
134
+ /** Converts a stored old `devicesAutoMode` (`{ mode }`) like {@link parseLegacyStoredDevicesFullAccess}. */
135
+ export declare function parseLegacyStoredDevicesAutoMode(value: unknown, log?: Pick<KernelLogger, "warn">): StoredDeviceSandbox;
136
+ /** The stored outside-sandbox choice with `patch` applied (`permission: null` clears it). */
137
+ export declare function applyDevicesOutsideSandboxPatch(_stored: DevicesOutsideSandboxStored, patch: DevicesOutsideSandboxPatch): DevicesOutsideSandboxStored;
138
+ /** The stored network choice with `patch` applied (a null field clears it). */
139
+ export declare function applyDevicesNetworkPatch(stored: DevicesNetworkStored, patch: DevicesNetworkPatch): DevicesNetworkStored;
140
+ /**
141
+ * The narrower of two stored choices, field by field: `off` / `allowlist` when either says so;
142
+ * otherwise `a`'s value, else `b`'s (an absent value follows the default, the widest, so `allowed`
143
+ * or `open` over absent says the same and is kept, as a conversion must be exact).
144
+ */
145
+ export declare function narrowerStoredDeviceSandbox(a: StoredDeviceSandbox, b: StoredDeviceSandbox): StoredDeviceSandbox;
146
+ /**
147
+ * The effective settings and their sources, pure (the reader below adds the database read). The
148
+ * startup config fields are optional with no schema default, so a defined value with a source
149
+ * means the config sets it: it wins over the stored choice. The effective default never exceeds
150
+ * the effective ceiling (the narrower of the two is shown and applied).
151
+ */
152
+ export declare function resolveDeviceSandboxSettings(configured: ConfiguredDeviceSandbox, stored: StoredDeviceSandbox): DeviceSandboxSettingsView;
153
+ /** The plain settings of a view. */
154
+ export declare const deviceSandboxSettingsOf: (view: DeviceSandboxSettingsView) => DeviceSandboxSettings;
155
+ /** The startup config's values and sources. */
156
+ export declare function configuredDeviceSandbox(config: Pick<KernelConfigService, "get" | "fieldSource">): ConfiguredDeviceSandbox;
157
+ /**
158
+ * The old permission value written next to the new keys for replicas of the previous version
159
+ * (their Full switch): `allowed` only when running outside the sandbox is allowed AND the network
160
+ * ceiling is open, else `off`, so an old replica never reads Full where a new one keeps devices on
161
+ * the allowlist. `outside` absent with an open ceiling stays absent (follow the default).
162
+ */
163
+ export declare function legacyPermissionFor(outside: OutsideSandboxPermission | undefined, ceiling: DeviceNetworkMode | undefined): OutsideSandboxPermission | undefined;
164
+ /** The stored choices, read live (in the caller's transaction when there is one). */
165
+ export declare function readStoredDeviceSandbox(db: KernelSchemaDb, log?: Pick<KernelLogger, "warn">, configuredCeiling?: DeviceNetworkMode): Promise<StoredDeviceSandbox>;
166
+ /** The old platform keys still stored (a write then keeps them in step until they are converted). */
167
+ export declare function legacyPlatformKeysStored(db: KernelSchemaDb): Promise<string[]>;
168
+ /** The value an old platform key stores for `permission` (absent: follow the default). */
169
+ export declare const legacyPlatformValue: (key: string, permission: OutsideSandboxPermission | undefined) => unknown;
170
+ /**
171
+ * The platform's effective device sandbox settings with their sources, read live from PG at every
172
+ * use (so a change applies on every replica at once): see {@link resolveDeviceSandboxSettings}.
173
+ */
174
+ export declare function readDeviceSandboxSettingsView(db: KernelSchemaDb, config: Pick<KernelConfigService, "get" | "fieldSource">, log?: Pick<KernelLogger, "warn">): Promise<DeviceSandboxSettingsView>;
175
+ /** The platform's effective device sandbox settings (the layer `effectiveDeviceSandbox` takes). */
176
+ export declare function readDeviceSandboxSettings(db: KernelSchemaDb, config: Pick<KernelConfigService, "get" | "fieldSource">, log?: Pick<KernelLogger, "warn">): Promise<DeviceSandboxSettings>;
177
+ /** An org's stored device sandbox keys, as every reader sees them. */
178
+ export interface OrgDeviceSandboxStored {
179
+ outsideSandbox?: OutsideSandboxPermission | undefined;
180
+ deviceNetwork?: DeviceNetworkSetting | undefined;
181
+ }
182
+ /**
183
+ * An org's `outsideSandbox` and `deviceNetwork` read over the new and the old keys (fail closed).
184
+ * `deviceNetwork` present (a `{}` follow marker included) means this version wrote the settings:
185
+ * - absent: the old keys are all there is and convert in full (design, "Migration"):
186
+ * `fullAccess` / `autoMode` -> `outsideSandbox` (invalid: `off`), `cloudNetwork` ->
187
+ * {@link convertLegacyCloudNetwork}, and an old `off` also narrows the ceiling to the allowlist;
188
+ * - present: an old permission written in step ({@link legacyPermissionFor} `outsideSandbox` and
189
+ * the org's own ceiling; the platform's ceiling reaches old replicas through the platform's own
190
+ * old key) and a `cloudNetwork` written in step ({@link legacyCloudNetworkOf}) say nothing more;
191
+ * one that differs (an old replica wrote it) narrows as a conversion would.
192
+ */
193
+ export declare function orgDeviceSandboxOf(raw: unknown): OrgDeviceSandboxStored;
194
+ /** Whether an org's stored settings still hold an old permission key. */
195
+ export declare const orgLegacyKeysStored: (raw: unknown) => boolean;
196
+ /**
197
+ * The old org keys written next to the new ones while any of them is still stored (`written` is
198
+ * the settings object about to be stored; `stored` the one it replaces): `fullAccess` / `autoMode`
199
+ * carry {@link legacyPermissionFor} `outsideSandbox` and the org's ceiling, `cloudNetwork` carries
200
+ * {@link legacyCloudNetworkOf} `deviceNetwork`; a value that says nothing removes the old key.
201
+ * `deviceNetwork` cleared is stored as `{}`, the marker that this version wrote the settings.
202
+ */
203
+ export declare function keepOrgLegacyKeysInStep(written: Record<string, unknown>, stored: Record<string, unknown>): void;
204
+ /**
205
+ * Locks the org rows {@link convertStoredPermissionKeys} would convert, in id order, before the
206
+ * caller takes the platform authority write lock: the global lock order puts the org row before
207
+ * the permission authority locks (a fenced prelude holds an org row while it waits for its shared
208
+ * platform lock). The conversion itself then finds its rows already held.
209
+ */
210
+ export declare function lockOrgsWithStoredPermissionKeys(db: KernelSchemaDb): Promise<void>;
211
+ /** What the conversion needs of the startup config: the configured network ceiling. */
212
+ export interface PermissionKeyConversionContext {
213
+ configuredCeiling?: DeviceNetworkMode | undefined;
214
+ }
215
+ /**
216
+ * The conversion of the stored permission keys (design, "Migration"), run inside the permission
217
+ * configuration publication transaction under the platform authority write lock (which excludes
218
+ * every org and device writer; the caller locked the org rows to convert before it,
219
+ * {@link lockOrgsWithStoredPermissionKeys}), at every publication: old keys an old replica writes
220
+ * later are converted too. It stores exactly what every reader saw ({@link storedOf},
221
+ * {@link orgDeviceSandboxOf}), never wider, and removes the old keys:
222
+ * - the deployment settings `devicesAutoMode` / `devicesFullAccess` become `devicesOutsideSandbox`
223
+ * and `devicesNetwork` (an empty network removes the row);
224
+ * - every org's `autoMode` / `fullAccess` / `cloudNetwork` become `outsideSandbox` and
225
+ * `deviceNetwork` (absent stays absent: the org follows the platform).
226
+ * Each platform or org whose network an old `off` narrowed to the allowlist is named in one
227
+ * warning, with how to reopen it. Idempotent; never refuses.
228
+ */
229
+ export declare function convertStoredPermissionKeys(db: KernelSchemaDb, log?: Pick<KernelLogger, "warn">, context?: PermissionKeyConversionContext): Promise<void>;
230
+ export {};