@capybara-hq/kernel 0.1.0-rc.68 → 0.1.0-rc.69

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 (215) hide show
  1. package/dist/admin/admin.module.js +2 -0
  2. package/dist/admin/health.service.d.ts +11 -4
  3. package/dist/admin/health.service.js +33 -17
  4. package/dist/background/poll.job.js +2 -2
  5. package/dist/background/tasks.service.d.ts +5 -5
  6. package/dist/background/tasks.service.js +9 -8
  7. package/dist/catalog/marketplaces.service.d.ts +1 -1
  8. package/dist/catalog/requests.service.js +1 -1
  9. package/dist/config/schema.d.ts +1 -1
  10. package/dist/config/schema.js +9 -9
  11. package/dist/conversations/conversations.controller.d.ts +8 -3
  12. package/dist/conversations/conversations.controller.js +8 -3
  13. package/dist/conversations/conversations.service.d.ts +33 -15
  14. package/dist/conversations/conversations.service.js +60 -10
  15. package/dist/conversations/events.d.ts +21 -41
  16. package/dist/conversations/events.js +57 -31
  17. package/dist/conversations/permission-profiles.controller.d.ts +6 -4
  18. package/dist/conversations/permission-profiles.service.d.ts +6 -4
  19. package/dist/ctx/create-ctx.d.ts +20 -1
  20. package/dist/ctx/create-ctx.js +77 -6
  21. package/dist/ctx/device-provider-check.d.ts +6 -2
  22. package/dist/ctx/device-provider-check.js +17 -2
  23. package/dist/db/kernel-schema.d.ts +10 -48
  24. package/dist/devices/access.d.ts +3 -4
  25. package/dist/devices/access.js +3 -4
  26. package/dist/devices/conversation-devices.d.ts +1 -3
  27. package/dist/devices/conversation-devices.js +2 -7
  28. package/dist/devices/device-projects.service.js +24 -29
  29. package/dist/devices/device-provider-selection.d.ts +5 -6
  30. package/dist/devices/device-provider-selection.js +8 -9
  31. package/dist/devices/devices.controller.d.ts +8 -21
  32. package/dist/devices/devices.controller.js +9 -34
  33. package/dist/devices/devices.module.js +6 -4
  34. package/dist/devices/devices.schemas.d.ts +1 -5
  35. package/dist/devices/devices.schemas.js +1 -5
  36. package/dist/devices/devices.service.d.ts +84 -147
  37. package/dist/devices/devices.service.js +134 -229
  38. package/dist/devices/dto.d.ts +5 -32
  39. package/dist/devices/dto.js +5 -37
  40. package/dist/devices/errors.d.ts +6 -5
  41. package/dist/devices/errors.js +7 -8
  42. package/dist/devices/project-rules.d.ts +9 -11
  43. package/dist/devices/project-rules.js +7 -7
  44. package/dist/devices/working-root.d.ts +3 -6
  45. package/dist/devices/working-root.js +3 -8
  46. package/dist/dial-in/access.d.ts +23 -0
  47. package/dist/dial-in/access.js +64 -0
  48. package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +12 -6
  49. package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +30 -15
  50. package/dist/dial-in/auth.module.d.ts +7 -0
  51. package/dist/dial-in/auth.module.js +27 -0
  52. package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +42 -13
  53. package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +83 -32
  54. package/dist/dial-in/dial-in.module.d.ts +9 -0
  55. package/dist/dial-in/dial-in.module.js +37 -0
  56. package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
  57. package/dist/{local-devices → dial-in}/dto.js +14 -2
  58. package/dist/dial-in/envelope.d.ts +95 -0
  59. package/dist/dial-in/envelope.js +89 -0
  60. package/dist/dial-in/gateway.d.ts +214 -0
  61. package/dist/{local-devices/local-device-gateway.js → dial-in/gateway.js} +337 -181
  62. package/dist/dial-in/handlers.d.ts +47 -0
  63. package/dist/dial-in/handlers.js +84 -0
  64. package/dist/dial-in/machines.d.ts +155 -0
  65. package/dist/dial-in/machines.js +383 -0
  66. package/dist/dial-in/relay.d.ts +135 -0
  67. package/dist/dial-in/relay.js +444 -0
  68. package/dist/dial-in/relay.module.d.ts +7 -0
  69. package/dist/dial-in/relay.module.js +24 -0
  70. package/dist/{local-devices/device-routes.d.ts → dial-in/routes.d.ts} +19 -11
  71. package/dist/{local-devices/device-routes.js → dial-in/routes.js} +45 -25
  72. package/dist/{local-devices → dial-in}/targets.d.ts +3 -18
  73. package/dist/{local-devices → dial-in}/targets.js +3 -48
  74. package/dist/errors.d.ts +8 -27
  75. package/dist/errors.js +8 -27
  76. package/dist/extensions/bootstrap.d.ts +5 -0
  77. package/dist/extensions/bootstrap.js +10 -1
  78. package/dist/extensions/extensions.module.js +6 -0
  79. package/dist/extensions/host.d.ts +6 -0
  80. package/dist/extensions/host.js +12 -2
  81. package/dist/extensions/permission-set.d.ts +15 -1
  82. package/dist/extensions/permission-set.js +11 -1
  83. package/dist/extensions/permission-view.d.ts +1 -1
  84. package/dist/extensions/permission-view.js +4 -1
  85. package/dist/http/api.module.js +4 -4
  86. package/dist/http/gateway-routes.d.ts +1 -1
  87. package/dist/http/gateway-routes.js +1 -1
  88. package/dist/http/meta.controller.js +1 -1
  89. package/dist/identity/settings.d.ts +1 -1
  90. package/dist/identity/settings.js +6 -8
  91. package/dist/infra/config/kernel-config.service.js +2 -2
  92. package/dist/infra/outbox/registry.d.ts +0 -14
  93. package/dist/infra/outbox/registry.js +0 -15
  94. package/dist/infra/throttler/named-throttlers.d.ts +1 -1
  95. package/dist/infra/throttler/named-throttlers.js +1 -1
  96. package/dist/kernel.module.js +0 -3
  97. package/dist/orgs/settings.service.js +5 -10
  98. package/dist/overrides.d.ts +0 -4
  99. package/dist/overrides.js +0 -2
  100. package/dist/platform/exclusions.js +5 -5
  101. package/dist/platform/ops/admin.ops.js +1 -1
  102. package/dist/platform/ops/conversations.ops.js +5 -2
  103. package/dist/platform/ops/devices.ops.js +11 -24
  104. package/dist/platform/ops/inbox.ops.js +1 -1
  105. package/dist/roles/gateway-role.d.ts +3 -3
  106. package/dist/roles/gateway-role.js +4 -4
  107. package/dist/roles/gateway.module.d.ts +1 -1
  108. package/dist/roles/gateway.module.js +5 -5
  109. package/dist/runtime/context/device-paths.d.ts +4 -1
  110. package/dist/runtime/context/permission-profile.js +5 -5
  111. package/dist/runtime/maintenance.d.ts +2 -5
  112. package/dist/runtime/maintenance.js +9 -19
  113. package/dist/runtime/project/knowledge.js +4 -5
  114. package/dist/runtime/project/knowledge.service.js +2 -1
  115. package/dist/sandbox/cloud-permission-snapshot.d.ts +1 -1
  116. package/dist/sandbox/cloud-permission-snapshot.js +1 -3
  117. package/dist/sandbox/device-reports.d.ts +74 -14
  118. package/dist/sandbox/device-reports.js +190 -33
  119. package/dist/sandbox/device-reports.module.d.ts +7 -0
  120. package/dist/sandbox/device-reports.module.js +25 -0
  121. package/dist/sandbox/device-sandbox.d.ts +39 -41
  122. package/dist/sandbox/device-sandbox.js +44 -83
  123. package/dist/sandbox/kernel-read.d.ts +2 -2
  124. package/dist/sandbox/legacy-retirement.d.ts +11 -59
  125. package/dist/sandbox/legacy-retirement.js +34 -186
  126. package/dist/sandbox/legacy-retirement.module.d.ts +2 -2
  127. package/dist/sandbox/legacy-retirement.module.js +2 -2
  128. package/dist/sandbox/managed-device-context.d.ts +16 -4
  129. package/dist/sandbox/managed-device-context.js +25 -8
  130. package/dist/sandbox/managed-device-context.module.js +4 -0
  131. package/dist/sandbox/modes.d.ts +3 -12
  132. package/dist/sandbox/modes.js +2 -14
  133. package/dist/{local-devices → sandbox}/network-grants.d.ts +2 -21
  134. package/dist/{local-devices → sandbox}/network-grants.js +4 -49
  135. package/dist/sandbox/operation-authority-types.d.ts +2 -1
  136. package/dist/sandbox/operation-authority.d.ts +6 -20
  137. package/dist/sandbox/operation-authority.js +43 -104
  138. package/dist/sandbox/operation-authority.module.js +1 -1
  139. package/dist/sandbox/operation-intents.d.ts +4 -1
  140. package/dist/sandbox/operation-intents.js +11 -2
  141. package/dist/sandbox/operation-reconcile.job.js +2 -4
  142. package/dist/sandbox/permission-availability.d.ts +6 -7
  143. package/dist/sandbox/permission-availability.js +7 -10
  144. package/dist/sandbox/permission-call-grants.d.ts +2 -1
  145. package/dist/sandbox/permission-call-grants.js +1 -7
  146. package/dist/sandbox/permission-call-types.d.ts +4 -4
  147. package/dist/sandbox/permission-ceiling-writes.d.ts +7 -23
  148. package/dist/sandbox/permission-ceiling-writes.js +8 -35
  149. package/dist/sandbox/permission-config-publication.d.ts +9 -1
  150. package/dist/sandbox/permission-config-publication.js +29 -21
  151. package/dist/sandbox/permission-context-types.d.ts +17 -10
  152. package/dist/sandbox/permission-facts.d.ts +98 -95
  153. package/dist/sandbox/permission-facts.js +160 -314
  154. package/dist/sandbox/permission-instance-writes.d.ts +23 -37
  155. package/dist/sandbox/permission-instance-writes.js +44 -121
  156. package/dist/sandbox/permission-runtime-reports.d.ts +38 -30
  157. package/dist/sandbox/permission-runtime-reports.js +105 -122
  158. package/dist/sandbox/providers.d.ts +26 -38
  159. package/dist/sandbox/providers.js +36 -18
  160. package/dist/sandbox/request-not-sent.d.ts +2 -13
  161. package/dist/sandbox/request-not-sent.js +2 -13
  162. package/dist/sandbox/review/permission-candidate.d.ts +13 -8
  163. package/dist/sandbox/review/permission-candidate.js +38 -48
  164. package/dist/sandbox/sandbox.module.js +7 -3
  165. package/dist/sandbox/sandbox.service.d.ts +49 -59
  166. package/dist/sandbox/sandbox.service.js +139 -259
  167. package/dist/schedules/fire.d.ts +15 -6
  168. package/dist/schedules/fire.js +27 -13
  169. package/dist/schedules/grant-rules.js +1 -1
  170. package/dist/schedules/scheduled-tasks.service.d.ts +0 -7
  171. package/dist/schedules/scheduled-tasks.service.js +1 -4
  172. package/dist/schedules/schedules.module.js +5 -3
  173. package/dist/skills/invoke.d.ts +1 -1
  174. package/dist/skills/invoke.js +2 -3
  175. package/dist/tools/approvals.service.d.ts +8 -5
  176. package/dist/tools/approvals.service.js +5 -5
  177. package/dist/tools/builtins/sandbox/bash.js +1 -2
  178. package/dist/tools/builtins/sandbox/common.d.ts +15 -9
  179. package/dist/tools/builtins/sandbox/common.js +37 -38
  180. package/dist/tools/network-asks.d.ts +19 -22
  181. package/dist/tools/network-asks.js +15 -21
  182. package/dist/tools/pipeline.d.ts +6 -7
  183. package/dist/tools/pipeline.js +17 -21
  184. package/dist/tools/tools.module.js +3 -7
  185. package/package.json +3 -4
  186. package/src/migrations/0177_dial_in_contract.sql +32 -0
  187. package/dist/local-devices/device-auth.module.d.ts +0 -7
  188. package/dist/local-devices/device-auth.module.js +0 -25
  189. package/dist/local-devices/device-policy.service.d.ts +0 -213
  190. package/dist/local-devices/device-policy.service.js +0 -605
  191. package/dist/local-devices/instance-bindings.d.ts +0 -82
  192. package/dist/local-devices/instance-bindings.js +0 -307
  193. package/dist/local-devices/local-device-gateway.d.ts +0 -153
  194. package/dist/local-devices/local-device-provider.d.ts +0 -122
  195. package/dist/local-devices/local-device-provider.js +0 -326
  196. package/dist/local-devices/local-devices.module.d.ts +0 -31
  197. package/dist/local-devices/local-devices.module.js +0 -100
  198. package/dist/local-devices/machines.d.ts +0 -211
  199. package/dist/local-devices/machines.js +0 -766
  200. package/dist/local-devices/owner-report.d.ts +0 -81
  201. package/dist/local-devices/owner-report.js +0 -150
  202. package/dist/local-devices/owner-reports.d.ts +0 -48
  203. package/dist/local-devices/owner-reports.js +0 -208
  204. package/dist/local-devices/policy-op-jobs.d.ts +0 -15
  205. package/dist/local-devices/policy-op-jobs.js +0 -12
  206. package/dist/local-devices/policy-summary.d.ts +0 -102
  207. package/dist/local-devices/policy-summary.js +0 -155
  208. package/dist/local-devices/relay.d.ts +0 -166
  209. package/dist/local-devices/relay.js +0 -559
  210. package/dist/tools/device-op-resolver.d.ts +0 -34
  211. package/dist/tools/device-op-resolver.js +0 -120
  212. /package/dist/{local-devices → dial-in}/keys.d.ts +0 -0
  213. /package/dist/{local-devices → dial-in}/keys.js +0 -0
  214. /package/dist/{local-devices → sandbox}/network-grants.module.d.ts +0 -0
  215. /package/dist/{local-devices → sandbox}/network-grants.module.js +0 -0
@@ -0,0 +1,32 @@
1
+ -- Device provider phase 2 (dial-in contract): local device semantics leave the kernel for the
2
+ -- device-local plugin. The kernel keeps only a dial-in device's signed-in machine (its
3
+ -- credential and program facts); what the former local provider kept per machine, its instance
4
+ -- bindings and boot history, and the device's location column go.
5
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
6
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS features;
7
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
8
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS local_policy;
9
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
10
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS owner_report;
11
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
12
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS pending_policy_ops;
13
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
14
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS home;
15
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
16
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS roots;
17
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
18
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS mode;
19
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
20
+ ALTER TABLE device_machines DROP COLUMN IF EXISTS session_isolation;
21
+ -- The former @local provider kept nothing of its own (a local device's files live on its machine)
22
+ -- and no provider can destroy its instance rows any more: they go, so deleting such a device
23
+ -- settles at once. The device itself stays bound to @local (unavailable until its owner deletes it).
24
+ -- capybara:allow-destructive the @local provider is gone and held no resources; no loaded provider can ever destroy these rows
25
+ DELETE FROM device_instances WHERE provider = '@local';
26
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
27
+ DROP TABLE IF EXISTS device_machine_boots;
28
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
29
+ DROP TABLE IF EXISTS device_instance_bindings;
30
+ ALTER TABLE devices DROP CONSTRAINT IF EXISTS devices_source_check;
31
+ -- capybara:allow-destructive local device semantics moved to device-local; project not released, no compatibility layer
32
+ ALTER TABLE devices DROP COLUMN IF EXISTS source;
@@ -1,7 +0,0 @@
1
- /**
2
- * Device sign-in (environments spec §13.3): {@link DeviceAuthService} behind
3
- * `DeviceAuthController`. Kept apart from {@link LocalDevicesModule}, which `DevicesModule`
4
- * imports (deleting a device revokes its machine), while sign-in needs both.
5
- */
6
- export declare class DeviceAuthModule {
7
- }
@@ -1,25 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Module } from "@nestjs/common";
8
- import { DevicesModule } from "../devices/devices.module.js";
9
- import { DeviceAuthService } from "./device-auth.js";
10
- import { LocalDevicesModule } from "./local-devices.module.js";
11
- /**
12
- * Device sign-in (environments spec §13.3): {@link DeviceAuthService} behind
13
- * `DeviceAuthController`. Kept apart from {@link LocalDevicesModule}, which `DevicesModule`
14
- * imports (deleting a device revokes its machine), while sign-in needs both.
15
- */
16
- let DeviceAuthModule = class DeviceAuthModule {
17
- };
18
- DeviceAuthModule = __decorate([
19
- Module({
20
- imports: [LocalDevicesModule, DevicesModule],
21
- providers: [DeviceAuthService],
22
- exports: [DeviceAuthService],
23
- })
24
- ], DeviceAuthModule);
25
- export { DeviceAuthModule };
@@ -1,213 +0,0 @@
1
- import { type DeviceFeature, type DeviceLocalPolicySummary, type DeviceOwnerCeilingNarrowing, type DevicePolicyArgs, type LegacyDevicePolicyArgs, type LegacyDevicePolicyStatus } from "@capybara-hq/plugin-sdk";
2
- import { KernelConfigService } from "../infra/config/kernel-config.service.js";
3
- import { KernelDb } from "../infra/database/kernel-db.js";
4
- import { TransactionHost } from "../infra/database/transaction-host.js";
5
- import { OutboxService } from "../infra/outbox/outbox.service.js";
6
- import type { KernelLogger } from "../log.js";
7
- import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
8
- import { MachinesService } from "./machines.js";
9
- import { OwnerReports } from "./owner-reports.js";
10
- import { LocalDeviceRelay } from "./relay.js";
11
- /** How long the machine may take to apply a policy change. */
12
- export declare const POLICY_DEADLINE_MS = 30000;
13
- /** How long an op left `unknown` waits for the machine's hello to report it (from its intent). */
14
- export declare const UNKNOWN_OP_MS: number;
15
- /**
16
- * A policy change as callers ask for it (the op id and the source are added here): narrowings
17
- * only. Under device protocol 4 the deployment never widens a local device: its owner adds hosts,
18
- * opens the network or allows running outside the sandbox on the machine.
19
- */
20
- export interface PolicyChange {
21
- remove?: string[];
22
- ownerCeiling?: DeviceOwnerCeilingNarrowing;
23
- }
24
- /** Who asked for a change, for the device's local audit line (never a network ask). */
25
- export type PolicyChangeSource = Omit<LegacyDevicePolicyArgs["source"], "approvalId">;
26
- /**
27
- * Test seam (`KernelOverride`): called by {@link DevicePolicyService.send} right after the `policy`
28
- * op's call returned, before its outcome is recorded (by `apply` or a network ask's decision);
29
- * throwing stands for a crash between the call and the resolve transaction.
30
- * The kernel never provides it.
31
- */
32
- export declare const DEVICE_POLICY_AFTER_CALL: unique symbol;
33
- /** What became of a policy change. */
34
- export type PolicyChangeOutcome = {
35
- applied: true;
36
- policy: DeviceLocalPolicySummary;
37
- } | {
38
- applied: false;
39
- reason: "offline" | "refused" | "unsupported";
40
- message: string;
41
- };
42
- /**
43
- * An op whose intent is recorded ({@link DevicePolicyService.begin}): the call sends `args` to
44
- * the device's machine.
45
- */
46
- export interface PolicyIntent {
47
- orgId: string;
48
- deviceId: string;
49
- machineId: string;
50
- opId: string;
51
- args: DevicePolicyArgs;
52
- /**
53
- * The staged (protocol 4) connection the op goes to, when the device's machine is connected
54
- * over one: the op is sent as a v3 `policy` request fenced to it (not sent at all once it
55
- * changed), and its answer's owner report is recorded with its id. Absent: protocol 2.
56
- */
57
- connection?: {
58
- connectionId: string;
59
- maxFrameBytes: number;
60
- };
61
- }
62
- /**
63
- * What became of a sent op, as recorded by {@link DevicePolicyService.settleIn}: `applied` (with
64
- * the policy the machine wrote, when it said), `refused` (the machine's message), `not_received`
65
- * (the machine never got it and never will), `unknown` (no answer).
66
- */
67
- export type PolicyOpResult = {
68
- outcome: "applied";
69
- policy?: DeviceLocalPolicySummary;
70
- /** A staged (v3) answer's owner report: recorded before the outcome is accepted (B2). */
71
- ownerCeiling?: unknown;
72
- /** The authenticated connection the answer arrived on (recorded with the report). */
73
- connectionId?: string | null;
74
- } | {
75
- outcome: "refused";
76
- message: string;
77
- } | {
78
- outcome: "not_received";
79
- } | {
80
- outcome: "interrupted";
81
- } | {
82
- outcome: "unknown";
83
- };
84
- /** What a machine says of an op id ({@link DevicePolicyService.outcomeOf}). */
85
- export type PolicyOpStatus = (LegacyDevicePolicyStatus & {
86
- ownerCeiling?: unknown;
87
- connectionId?: string | null;
88
- }) | {
89
- outcome: "offline";
90
- };
91
- /**
92
- * Narrows a local device's policy on its machine (approval-only profiles design, "Settings model":
93
- * hosts removed, the network to the allowlist, no running outside the sandbox, the workspace
94
- * reach): the kernel→device `policy`
95
- * op over the {@link LocalDeviceRelay}. The machine is the authority: it refuses what its owner
96
- * forbids, validates every host and answers with the policy as written, which the kernel then
97
- * keeps on the active machine's row (§5.4).
98
- *
99
- * Intent first (transactional outbox spec §7): {@link begin} writes the intent in a transaction
100
- * before anything is sent (the entry on the machine row's `pending_policy_ops`, the audit
101
- * `device.policy_requested` and the `device-op-resolve` job owed for when the op can no longer
102
- * reach the machine); the call sends the op with its id (no transaction open); {@link settleIn}
103
- * records the outcome: `device.policy_changed` (applied), `device.policy_failed` (refused, never
104
- * received) or `device.policy_unknown` (no answer: the entry stays, `unknown`, for the machine's
105
- * next hello or the resolver). A crash between the call and the resolve transaction leaves the
106
- * intent and its owed job, whose resolver asks the machine what became of the op (never sends it
107
- * again). Callers decide who may change a device's policy (the device owner, in a signed-in
108
- * session); this service checks only that the device is a live device of the org.
109
- */
110
- export declare class DevicePolicyService {
111
- private readonly db;
112
- readonly txHost: TransactionHost;
113
- private readonly relay;
114
- private readonly machines;
115
- private readonly outbox;
116
- private readonly config;
117
- private readonly log;
118
- private readonly ceilings;
119
- private readonly owners;
120
- private readonly afterCall;
121
- constructor(db: KernelDb, txHost: TransactionHost, relay: Pick<LocalDeviceRelay, "call" | "callV3" | "holderLive" | "connection" | "stagedTransport">, machines: Pick<MachinesService, "activeFor">, outbox: Pick<OutboxService, "add">, config: Pick<KernelConfigService, "get">, log: Pick<KernelLogger, "warn">, ceilings: PermissionCeilingWrites, owners: Pick<OwnerReports, "recordLocked">, afterCall?: (opId: string) => void);
122
- /**
123
- * Changes the policy: {@link begin}, the call, then the outcome recorded in its own transaction
124
- * (no transaction may be open). Never throws for an offline machine, a refusal or a program
125
- * without the `policyOpId` feature (nothing is sent to it); a device that is not a live device
126
- * of `orgId` is `device.not_found`.
127
- */
128
- apply(input: {
129
- orgId: string;
130
- deviceId: string;
131
- change: PolicyChange;
132
- source: PolicyChangeSource;
133
- actorTokenId?: string;
134
- }): Promise<PolicyChangeOutcome>;
135
- /**
136
- * Checks the device and its machine, then records the intent in its own transaction: the entry
137
- * (`sent`) on the machine's row, the audit `device.policy_requested` and the `device-op-resolve`
138
- * job owed for when the op can no longer reach the machine. No transaction may be open (the
139
- * call follows). Returns the intent, or why nothing will be sent (offline, unsupported).
140
- */
141
- begin(input: {
142
- orgId: string;
143
- deviceId: string;
144
- change: PolicyChange;
145
- source: PolicyChangeSource;
146
- actorTokenId?: string;
147
- }): Promise<{
148
- intent: PolicyIntent;
149
- } | {
150
- outcome: PolicyChangeOutcome;
151
- }>;
152
- /**
153
- * Sends the intent's `policy` op (no transaction may be open) and classifies the answer:
154
- * applied; refused (the machine's local policy refused it: its message); anything else is
155
- * `unknown`, left to the resolver's `policyStatus`: no answer, and an answer the kernel cannot
156
- * trust to mean "not applied" (a result it cannot read, the machine's own error). `notFound`:
157
- * the device was deleted meanwhile (recorded as unknown; the caller throws `device.not_found`).
158
- */
159
- send(intent: PolicyIntent): Promise<{
160
- result: PolicyOpResult;
161
- outcome: PolicyChangeOutcome;
162
- notFound?: true;
163
- }>;
164
- /** The `policy` op's call and its classification ({@link send}). */
165
- private call;
166
- /** The authenticated connection a call goes to now, or null when unknown (M4). */
167
- private connectionIdOf;
168
- /**
169
- * What the machine says became of the op `opId` (a read-only `policyStatus`), or `offline` when
170
- * no replica holds its connection or it does not answer. Never sends the change.
171
- */
172
- outcomeOf(deviceId: string, opId: string): Promise<PolicyOpStatus>;
173
- /**
174
- * Records what became of the op `opId` of machine `machineId`, in the caller's transaction (the
175
- * machine's row locked): `applied` → the policy the machine wrote (when given) kept on the row,
176
- * the entry removed, `device.policy_changed` (`late` when the op was left `unknown`); `refused`,
177
- * `not_received` or `interrupted` → the entry removed, `device.policy_failed` (`reason` the
178
- * outcome); `unknown` → the entry kept, `unknown` until a day after its intent,
179
- * `device.policy_unknown` (once; ignored once a hello reported the op). Returns the outcome for
180
- * the caller, or null when the op has no live entry (resolved already, or expired: a no-op).
181
- */
182
- settleIn(ref: {
183
- machineId: string;
184
- opId: string;
185
- }, result: PolicyOpResult): Promise<PolicyChangeOutcome | null>;
186
- /** The active machine's features and policy summary (null when no machine is connected). */
187
- summary(deviceId: string): Promise<{
188
- features: DeviceFeature[];
189
- policy: DeviceLocalPolicySummary | null;
190
- } | null>;
191
- /**
192
- * How long after its intent an op can no longer reach the machine: the call's deadline, the
193
- * reconnect grace and the request list's margin (the relay's list TTL), plus 5 s. A machine
194
- * that does not know the op id by then never will.
195
- */
196
- resolveDelayMs(): number;
197
- /**
198
- * The ordered prelude of a transaction that records an op's outcome ({@link settleIn}) after it
199
- * locked other rows (a network ask's conversation, its approval, its run): the permission
200
- * authority lock of the machine's device, read without a lock first. The global order puts it
201
- * before every conversation row (`withOrderedLocks`); {@link settleIn} re-reads the machine
202
- * under it. A machine that is gone locks nothing (its settle is a no-op).
203
- */
204
- lockMachineDevice(machineId: string): Promise<void>;
205
- /** {@link settleIn} in its own transaction (the {@link apply} path). */
206
- private settle;
207
- /**
208
- * The intent transaction: locks the machine's row (still the device's active machine), appends
209
- * the entry (dropping the expired ones), audits `device.policy_requested` and owes the
210
- * `device-op-resolve` job. False when the machine was revoked meanwhile (nothing written).
211
- */
212
- private recordIntent;
213
- }