@capybara-hq/kernel 0.1.0-rc.54 → 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.
- package/dist/admin/admin.schemas.d.ts +11 -1
- package/dist/catalog/catalog.module.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/requests.service.d.ts +5 -5
- package/dist/catalog/requests.service.js +9 -9
- package/dist/channels/cards.d.ts +4 -3
- package/dist/channels/cards.js +25 -16
- package/dist/channels/phrases.d.ts +15 -4
- package/dist/channels/phrases.js +15 -1
- package/dist/config/load.d.ts +26 -7
- package/dist/config/load.js +60 -9
- package/dist/config/permission-migration.d.ts +17 -9
- package/dist/config/permission-migration.js +60 -9
- package/dist/config/schema.d.ts +11 -1
- package/dist/config/schema.js +37 -11
- package/dist/conversations/events.d.ts +247 -5
- package/dist/conversations/events.js +127 -16
- package/dist/conversations/permission-profiles.controller.d.ts +12 -2
- package/dist/conversations/permission-profiles.service.d.ts +12 -2
- package/dist/conversations/permission-profiles.service.js +11 -4
- package/dist/db/kernel-schema.d.ts +8 -2
- package/dist/devices/device-projects.service.d.ts +1 -1
- package/dist/devices/device-projects.service.js +6 -6
- package/dist/devices/devices.controller.d.ts +10 -8
- package/dist/devices/devices.controller.js +14 -18
- package/dist/devices/devices.schemas.d.ts +5 -5
- package/dist/devices/devices.schemas.js +5 -5
- package/dist/devices/devices.service.d.ts +188 -175
- package/dist/devices/devices.service.js +284 -292
- package/dist/devices/dto.d.ts +43 -23
- package/dist/devices/dto.js +45 -49
- package/dist/devices/project-rules.d.ts +0 -10
- package/dist/devices/project-rules.js +0 -5
- package/dist/errors.d.ts +24 -19
- package/dist/errors.js +24 -19
- package/dist/evals/reconstruct.d.ts +12 -3
- package/dist/evals/reconstruct.js +10 -6
- package/dist/evals/recorded-permission-context.d.ts +6 -4
- package/dist/evals/recorded-permission-context.js +15 -9
- package/dist/evals/run-replay.d.ts +6 -1
- package/dist/evals/run-replay.js +7 -2
- package/dist/evals/worker.js +3 -1
- package/dist/identity/settings.d.ts +45 -18
- package/dist/identity/settings.js +151 -51
- package/dist/infra/config/kernel-config.service.d.ts +1 -1
- package/dist/infra/config/kernel-config.service.js +17 -5
- package/dist/local-devices/device-auth.controller.d.ts +1 -1
- package/dist/local-devices/device-auth.controller.js +1 -1
- package/dist/local-devices/device-auth.d.ts +4 -4
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +18 -9
- package/dist/local-devices/device-policy.service.js +21 -61
- package/dist/local-devices/device-routes.d.ts +3 -1
- package/dist/local-devices/device-routes.js +15 -4
- package/dist/local-devices/instance-bindings.js +5 -2
- package/dist/local-devices/local-device-gateway.d.ts +2 -2
- package/dist/local-devices/local-device-gateway.js +3 -3
- package/dist/local-devices/local-device-provider.d.ts +4 -4
- package/dist/local-devices/local-device-provider.js +23 -9
- package/dist/local-devices/local-devices.module.d.ts +1 -1
- package/dist/local-devices/local-devices.module.js +1 -1
- package/dist/local-devices/machines.d.ts +40 -16
- package/dist/local-devices/machines.js +89 -61
- package/dist/local-devices/owner-report.d.ts +16 -14
- package/dist/local-devices/owner-report.js +24 -30
- package/dist/local-devices/owner-reports.js +26 -8
- package/dist/local-devices/policy-summary.d.ts +25 -44
- package/dist/local-devices/policy-summary.js +26 -71
- package/dist/local-devices/relay.d.ts +6 -6
- package/dist/local-devices/relay.js +10 -8
- package/dist/net/public-address.d.ts +1 -1
- package/dist/net/public-address.js +5 -2
- package/dist/orgs/device-network-setting.d.ts +82 -0
- package/dist/orgs/device-network-setting.js +142 -0
- package/dist/orgs/settings.service.d.ts +103 -66
- package/dist/orgs/settings.service.js +201 -137
- package/dist/overrides.d.ts +5 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +1 -1
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/admin.ops.js +20 -11
- package/dist/platform/ops/devices.ops.js +70 -5
- package/dist/platform/ops/org-settings.ops.js +10 -6
- package/dist/platform/ops/orgs.ops.js +2 -1
- package/dist/runtime/context/permission-profile.d.ts +17 -8
- package/dist/runtime/context/permission-profile.js +126 -45
- package/dist/runtime/permission-context.service.d.ts +1 -1
- package/dist/runtime/permission-context.service.js +5 -3
- package/dist/runtime/project/knowledge.d.ts +5 -4
- package/dist/runtime/project/knowledge.js +2 -1
- package/dist/runtime/project/knowledge.service.js +16 -13
- package/dist/sandbox/cloud-permission-snapshot.js +22 -3
- package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
- package/dist/sandbox/device-sandbox-settings.js +470 -0
- package/dist/sandbox/device-sandbox.d.ts +187 -0
- package/dist/sandbox/device-sandbox.js +236 -0
- package/dist/sandbox/held-operations.js +15 -7
- package/dist/sandbox/modes.d.ts +49 -24
- package/dist/sandbox/modes.js +27 -19
- package/dist/sandbox/operation-authority-types.d.ts +6 -5
- package/dist/sandbox/operation-authority-types.js +7 -8
- package/dist/sandbox/operation-authority.d.ts +23 -9
- package/dist/sandbox/operation-authority.js +179 -97
- package/dist/sandbox/permission-auto-grants.d.ts +42 -0
- package/dist/sandbox/permission-auto-grants.js +145 -0
- package/dist/sandbox/permission-call-grants.d.ts +12 -4
- package/dist/sandbox/permission-call-grants.js +84 -35
- package/dist/sandbox/permission-call-grants.module.js +10 -3
- package/dist/sandbox/permission-call-types.d.ts +39 -5
- package/dist/sandbox/permission-ceiling-writes.d.ts +29 -3
- package/dist/sandbox/permission-ceiling-writes.js +38 -4
- package/dist/sandbox/permission-config-publication.d.ts +44 -2
- package/dist/sandbox/permission-config-publication.js +230 -59
- package/dist/sandbox/permission-context-types.d.ts +2 -2
- package/dist/sandbox/permission-facts.d.ts +144 -15
- package/dist/sandbox/permission-facts.js +258 -70
- package/dist/sandbox/permission-runtime-reports.d.ts +5 -4
- package/dist/sandbox/permission-runtime-reports.js +19 -29
- package/dist/sandbox/review/classifier.d.ts +8 -0
- package/dist/sandbox/review/classifier.js +10 -0
- package/dist/sandbox/review/permission-candidate.d.ts +69 -5
- package/dist/sandbox/review/permission-candidate.js +153 -30
- package/dist/sandbox/review/review.service.d.ts +19 -3
- package/dist/sandbox/review/review.service.js +59 -11
- package/dist/sandbox/review/rules.js +23 -3
- package/dist/sandbox/sandbox.service.d.ts +29 -11
- package/dist/sandbox/sandbox.service.js +51 -26
- package/dist/skills/invoke.js +3 -2
- package/dist/tools/approvals.service.d.ts +26 -116
- package/dist/tools/approvals.service.js +42 -346
- package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
- package/dist/tools/builtins/sandbox/bash.js +80 -28
- package/dist/tools/builtins/sandbox/common.d.ts +39 -14
- package/dist/tools/builtins/sandbox/common.js +47 -24
- package/dist/tools/builtins/sandbox/deliver.js +7 -4
- package/dist/tools/builtins/skill-load.d.ts +2 -2
- package/dist/tools/builtins/skill-load.js +4 -3
- package/dist/tools/device-op-resolver.d.ts +4 -10
- package/dist/tools/device-op-resolver.js +8 -19
- package/dist/tools/network-asks.d.ts +52 -15
- package/dist/tools/network-asks.js +55 -25
- package/dist/tools/pipeline.d.ts +26 -14
- package/dist/tools/pipeline.js +144 -61
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/tools.module.js +1 -1
- package/package.json +4 -4
- package/src/migrations/0165_device_network_columns.sql +50 -0
- package/src/migrations/0166_permission_grant_full_access.sql +17 -0
- package/src/migrations/0167_device_network_backfill.sql +32 -0
- package/src/migrations/0168_binding_installed_connection.sql +6 -0
- package/dist/orgs/cloud-network-setting.d.ts +0 -33
- package/dist/orgs/cloud-network-setting.js +0 -47
- package/dist/sandbox/platform-full-access.d.ts +0 -110
- package/dist/sandbox/platform-full-access.js +0 -198
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { DeviceLocalPolicySummary, LocalizedName, SandboxLimits } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import type { DeviceLocalPolicySummary, LocalizedName, SandboxBrowseScope, SandboxLimits, SandboxOperationScope } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type Selectable } from "kysely";
|
|
3
|
+
import type { SandboxOperationIntentsTable } from "../db/kernel-schema.js";
|
|
2
4
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
3
5
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
6
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -7,10 +9,12 @@ import { LockService } from "../infra/lock/lock.service.js";
|
|
|
7
9
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
8
10
|
import { DevicePolicyService } from "../local-devices/device-policy.service.js";
|
|
9
11
|
import { MachinesService } from "../local-devices/machines.js";
|
|
12
|
+
import { type OwnerFacts } from "../local-devices/owner-report.js";
|
|
10
13
|
import type { DeviceModeLevel } from "../runtime/context/device-paths.js";
|
|
14
|
+
import type { DeviceSandbox, DeviceSandboxLayer, HostGrantCeiling } from "../sandbox/device-sandbox.js";
|
|
11
15
|
import { SandboxJobs } from "../sandbox/jobs.js";
|
|
12
|
-
import { type DeviceNetwork, type EffectiveDevicePolicy, type NetworkKind, type OrgDeviceSettings, type SandboxMode } from "../sandbox/modes.js";
|
|
13
16
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
17
|
+
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
14
18
|
import { SandboxProviders } from "../sandbox/providers.js";
|
|
15
19
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
16
20
|
import { DeviceAccess } from "./access.js";
|
|
@@ -55,14 +59,14 @@ export interface DeviceView {
|
|
|
55
59
|
features: string[];
|
|
56
60
|
policy: DeviceLocalPolicySummary | null;
|
|
57
61
|
} | null;
|
|
58
|
-
/** Its
|
|
59
|
-
|
|
62
|
+
/** Its effective device sandbox, the same under every permission profile. */
|
|
63
|
+
sandbox: DeviceSandboxView;
|
|
60
64
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
65
|
+
* A local device's owner ceiling as its machine last reported it (read only): an authenticated
|
|
66
|
+
* report (`state: "report"`), a stale or conflicting one (`blocked`) or nothing readable
|
|
67
|
+
* (`missing`). `stale` is true while the machine is offline or the report is not current:
|
|
68
|
+
* last-known facts, never authority. null for a cloud device (it has no machine) and for a local
|
|
69
|
+
* one without a connected machine.
|
|
66
70
|
*/
|
|
67
71
|
ownerCeiling: DeviceOwnerCeilingView | null;
|
|
68
72
|
/**
|
|
@@ -79,151 +83,133 @@ export interface DeviceView {
|
|
|
79
83
|
lastUsedAt: string;
|
|
80
84
|
} | null;
|
|
81
85
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
86
|
+
* Its sandbox limits: the resources and network a cloud instance is created with; for a local
|
|
87
|
+
* device the network its commands carry (the machine intersects it with its owner's ceiling).
|
|
84
88
|
*/
|
|
85
89
|
limits: SandboxLimits;
|
|
86
90
|
createdAt: string;
|
|
87
91
|
}
|
|
88
|
-
/** {@link DeviceView.ownerCeiling}. */
|
|
89
|
-
export interface DeviceOwnerCeilingView {
|
|
90
|
-
state: "report" | "blocked" | "legacy" | "missing" | "cloud";
|
|
91
|
-
revision: string | null;
|
|
92
|
-
sequence: number | null;
|
|
93
|
-
/** The owner's ceiling as stored or reported (a cloud device: the raw B1 ceiling). */
|
|
94
|
-
fullAccess: boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Whether the owner's side allows Full access as the kernel applies it: a cloud device's ceiling
|
|
97
|
-
* narrowed by its old sandbox switch (`cloudChosenMode`); a local machine's derived mode
|
|
98
|
-
* (`ownerModeOf`: its report, else an older program's mode or isolation), as admission reads it.
|
|
99
|
-
* The platform and the org may still cut it ({@link DeviceModeView.allowedMode}).
|
|
100
|
-
*/
|
|
101
|
-
effectiveFullAccess: boolean;
|
|
102
|
-
/** Restricted project reach; a cloud device stays within its provisioned files (`workspace`). */
|
|
103
|
-
restrictedProjectReach: "workspace" | "os-user";
|
|
104
|
-
restrictedAllowedDomains: string[];
|
|
105
|
-
observedAt: string | null;
|
|
106
|
-
stale: boolean;
|
|
107
|
-
}
|
|
108
92
|
/**
|
|
109
|
-
*
|
|
93
|
+
* The effective device sandbox of a device as its owner sees it (approval-only profiles design,
|
|
94
|
+
* "Settings model" and "UI"): `effectiveDeviceSandbox` over the platform, org, device and provider
|
|
95
|
+
* layers.
|
|
110
96
|
*/
|
|
111
|
-
export interface
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
97
|
+
export interface DeviceSandboxView {
|
|
98
|
+
/** The sandbox network in effect: the open public internet, the allowlist, or closed. */
|
|
99
|
+
network: "open" | "allowlist" | "none";
|
|
100
|
+
/** The widest network the platform, the org and the provider leave this device. */
|
|
101
|
+
networkCeiling: "open" | "allowlist" | "none";
|
|
102
|
+
/** The allowlist hosts in effect (empty unless {@link network} is `allowlist`). */
|
|
103
|
+
hosts: string[];
|
|
104
|
+
/**
|
|
105
|
+
* The device's own network setting: a cloud device's stored choice (null follows its org), a
|
|
106
|
+
* local owner's reported network (null without a readable report).
|
|
107
|
+
*/
|
|
108
|
+
ownNetwork: "open" | "allowlist" | "none" | null;
|
|
109
|
+
/**
|
|
110
|
+
* The device's own host list, which only narrows the org's hosts: a local owner's
|
|
111
|
+
* `allowedDomains` (its machine's ceiling while its network is the allowlist), a cloud device's
|
|
112
|
+
* stored hosts (empty: it follows its org's hosts).
|
|
113
|
+
*/
|
|
114
|
+
allowedDomains: string[];
|
|
115
|
+
/** Whether a call may be granted escalation outside the sandbox (never on a cloud device). */
|
|
116
|
+
outsideSandbox: boolean;
|
|
117
|
+
/** How far restricted work may root outside the workspace. */
|
|
118
|
+
restrictedProjectReach: "workspace" | "os-user";
|
|
119
|
+
/** The layer that set each ceiling (a disabled option names it), or null when nothing did. */
|
|
120
|
+
layer: {
|
|
121
|
+
network: DeviceSandboxLayer | null;
|
|
122
|
+
outsideSandbox: DeviceSandboxLayer | null;
|
|
126
123
|
};
|
|
127
|
-
/** A local device: the mode its machine reported and its own sandbox-mode allowlist; null for cloud. */
|
|
128
|
-
local: {
|
|
129
|
-
reported: SandboxMode | null;
|
|
130
|
-
allowedDomains: string[];
|
|
131
|
-
} | null;
|
|
132
|
-
/**
|
|
133
|
-
* A cloud device: the network sandbox mode gives it, whatever mode it runs at now (the org's
|
|
134
|
-
* `cloudNetwork`, open by default; the kill switch empties it) within its {@link outerNetwork},
|
|
135
|
-
* so the page names exactly what turning Full access off reaches before it is done (hardening
|
|
136
|
-
* spec D3). Null for a local device.
|
|
137
|
-
*/
|
|
138
|
-
sandboxNetwork: {
|
|
139
|
-
kind: NetworkKind;
|
|
140
|
-
hosts: string[];
|
|
141
|
-
} | null;
|
|
142
|
-
/**
|
|
143
|
-
* A cloud device: the network Full access gives it (the open public network, or the kill
|
|
144
|
-
* switch's empty allowlist) within its {@link outerNetwork}. Null for a local device.
|
|
145
|
-
*/
|
|
146
|
-
fullNetwork: {
|
|
147
|
-
kind: NetworkKind;
|
|
148
|
-
hosts: string[];
|
|
149
|
-
} | null;
|
|
150
124
|
/**
|
|
151
|
-
* A cloud device's
|
|
152
|
-
*
|
|
153
|
-
*/
|
|
154
|
-
outerNetwork: {
|
|
155
|
-
kind: NetworkKind;
|
|
156
|
-
hosts: string[];
|
|
157
|
-
} | null;
|
|
158
|
-
/**
|
|
159
|
-
* A cloud device's instance runs another mode or network kind: its next use updates or recreates
|
|
160
|
-
* it, files kept (「下次使用时生效,文件保留」).
|
|
125
|
+
* A cloud device's instance runs another network: its next use updates or recreates it, files
|
|
126
|
+
* kept (the page says it applies on next use).
|
|
161
127
|
*/
|
|
162
128
|
pendingNextUse: boolean;
|
|
163
129
|
/**
|
|
164
130
|
* Its provider applies limits at its file system (`limitsApplyAt: "fileSystem"`) and the instance
|
|
165
|
-
* runs another
|
|
131
|
+
* runs another network: only a file reset applies it (the page says it applies after a reset).
|
|
166
132
|
*/
|
|
167
133
|
pendingFilesReset: boolean;
|
|
168
|
-
/** Its last {@link RECENT_POLICY_CHANGES}
|
|
169
|
-
recent:
|
|
134
|
+
/** Its last {@link RECENT_POLICY_CHANGES} setting changes, newest first. */
|
|
135
|
+
recent: DeviceSettingChangeView[];
|
|
136
|
+
}
|
|
137
|
+
/** {@link DeviceView.ownerCeiling}: a local machine's owner ceiling as reported. */
|
|
138
|
+
export interface DeviceOwnerCeilingView {
|
|
139
|
+
state: "report" | "blocked" | "missing";
|
|
140
|
+
revision: string | null;
|
|
141
|
+
sequence: number | null;
|
|
142
|
+
/** The owner allows running outside the sandbox (fail closed: false). */
|
|
143
|
+
outsideSandbox: boolean;
|
|
144
|
+
/** The owner's sandbox network (fail closed: `allowlist`). */
|
|
145
|
+
network: "open" | "allowlist";
|
|
146
|
+
/** The owner's sandbox allowlist: the machine's host ceiling while its network is `allowlist`. */
|
|
147
|
+
allowedDomains: string[];
|
|
148
|
+
restrictedProjectReach: "workspace" | "os-user";
|
|
149
|
+
observedAt: string | null;
|
|
150
|
+
stale: boolean;
|
|
170
151
|
}
|
|
171
|
-
/** How many recent
|
|
152
|
+
/** How many recent setting changes a device view lists. */
|
|
172
153
|
export declare const RECENT_POLICY_CHANGES = 10;
|
|
173
154
|
/**
|
|
174
|
-
* One
|
|
175
|
-
* - `policy` (`device.policy_changed`):
|
|
176
|
-
*
|
|
177
|
-
* answer never came (`device.policy_unknown`) or
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
155
|
+
* One setting change of a device, as its owner sees it on the device page:
|
|
156
|
+
* - `policy` (`device.policy_changed`): hosts removed from a local machine's allowlist by the
|
|
157
|
+
* platform (`web`, `im`), or added or removed on the machine by its owner (`device`,
|
|
158
|
+
* `capybara-device policy ...`); one sent whose answer never came (`device.policy_unknown`) or
|
|
159
|
+
* that failed (`device.policy_failed`) too;
|
|
160
|
+
* - `ceiling` (`device.owner_ceiling_changed`): a machine's owner ceiling changed, narrowed from the
|
|
161
|
+
* device page (`web`) or on the machine (`device`);
|
|
162
|
+
* - `network` (`device.network_changed`): a cloud device's sandbox network changed on its device
|
|
163
|
+
* page (`web`), through an API token (`token`), or by an agent's Platform tool call (`agent`).
|
|
182
164
|
*/
|
|
183
|
-
export interface
|
|
165
|
+
export interface DeviceSettingChangeView {
|
|
184
166
|
at: string;
|
|
185
|
-
kind: "policy" | "
|
|
167
|
+
kind: "policy" | "ceiling" | "network";
|
|
186
168
|
/** Hosts added to / removed from the local allowlist (`policy` only; else empty). */
|
|
187
169
|
add: string[];
|
|
188
170
|
remove: string[];
|
|
189
|
-
/** The
|
|
190
|
-
mode: {
|
|
191
|
-
from?: SandboxMode | null;
|
|
192
|
-
to: SandboxMode;
|
|
193
|
-
} | null;
|
|
194
|
-
/**
|
|
195
|
-
* The ceiling change (`ceiling` only; else null): Full access, and a machine's restricted project
|
|
196
|
-
* reach (a cloud device has none). `from` is null when the row does not say.
|
|
197
|
-
*/
|
|
171
|
+
/** The owner ceiling change (`ceiling` only; else null). `from` is null when the row does not say. */
|
|
198
172
|
ceiling: {
|
|
199
173
|
from: DeviceCeilingFacts | null;
|
|
200
174
|
to: DeviceCeilingFacts;
|
|
201
175
|
} | null;
|
|
176
|
+
/** The cloud network change (`network` only; else null). */
|
|
177
|
+
network: {
|
|
178
|
+
from: DeviceNetworkSetting;
|
|
179
|
+
to: DeviceNetworkSetting;
|
|
180
|
+
} | null;
|
|
202
181
|
/** The deciding account's display name (null when the account is gone). */
|
|
203
182
|
by: string | null;
|
|
204
|
-
/**
|
|
205
|
-
|
|
183
|
+
/**
|
|
184
|
+
* `device`: made or reported on the machine itself; `token`: through an API token; `agent`: an
|
|
185
|
+
* agent's Platform tool call.
|
|
186
|
+
*/
|
|
187
|
+
via: "web" | "im" | "device" | "token" | "agent";
|
|
206
188
|
/**
|
|
207
189
|
* What became of a `policy` change sent to the machine: `applied` (also every change made or
|
|
208
|
-
* reported on the machine, and every
|
|
190
|
+
* reported on the machine, and every other row); `unknown`, its answer never came, `failed`, the
|
|
209
191
|
* machine refused it, never received it or stopped while applying it.
|
|
210
192
|
*/
|
|
211
193
|
outcome: "applied" | "unknown" | "failed";
|
|
212
194
|
}
|
|
213
|
-
/** One side of a {@link
|
|
195
|
+
/** One side of a {@link DeviceSettingChangeView.ceiling} change. */
|
|
214
196
|
export interface DeviceCeilingFacts {
|
|
215
|
-
|
|
197
|
+
outsideSandbox: boolean;
|
|
216
198
|
restrictedProjectReach?: "workspace" | "os-user";
|
|
199
|
+
network?: "open" | "allowlist";
|
|
200
|
+
}
|
|
201
|
+
/** A cloud device's stored network setting: `mode` null follows its org. */
|
|
202
|
+
export interface DeviceNetworkSetting {
|
|
203
|
+
mode: "open" | "allowlist" | "none" | null;
|
|
204
|
+
hosts: string[];
|
|
217
205
|
}
|
|
218
|
-
/** A
|
|
206
|
+
/** A narrowing of a local device's policy by its owner (`POST /devices/:id/policy`). */
|
|
219
207
|
export interface DevicePolicyChange {
|
|
220
|
-
add?: string[] | undefined;
|
|
221
208
|
remove?: string[] | undefined;
|
|
222
|
-
/**
|
|
223
|
-
mode?: "sandbox" | undefined;
|
|
224
|
-
/** B2: narrow the owner ceiling (never widen; the schema refuses true and os-user). */
|
|
209
|
+
/** Narrow the owner ceiling (never widen; the schema refuses anything wider). */
|
|
225
210
|
ownerCeiling?: {
|
|
226
|
-
|
|
211
|
+
outsideSandbox?: false | undefined;
|
|
212
|
+
network?: "allowlist" | undefined;
|
|
227
213
|
restrictedProjectReach?: "workspace" | undefined;
|
|
228
214
|
} | undefined;
|
|
229
215
|
}
|
|
@@ -231,20 +217,13 @@ export interface DevicePolicyChange {
|
|
|
231
217
|
export interface DevicePatch {
|
|
232
218
|
name?: string;
|
|
233
219
|
/**
|
|
234
|
-
* A cloud device's
|
|
235
|
-
*
|
|
236
|
-
* hardening spec D2). Only a person in a web session sends it (the controller refuses a token).
|
|
237
|
-
* A local device refuses it here (`device.mode_on_device`, its mode is its machine's).
|
|
238
|
-
*/
|
|
239
|
-
mode?: "sandbox" | null;
|
|
240
|
-
/**
|
|
241
|
-
* B2: a cloud device's explicit Full ceiling. Narrowing applies; widening needs
|
|
242
|
-
* `confirmWidening` and stays bounded by the platform, the org and the outer network.
|
|
220
|
+
* A cloud device's sandbox network, within its org's and the platform's ceilings. A local
|
|
221
|
+
* device refuses it here (`device.ceiling_on_machine`).
|
|
243
222
|
*/
|
|
244
|
-
|
|
245
|
-
|
|
223
|
+
network?: {
|
|
224
|
+
mode: "open" | "allowlist" | "none" | null;
|
|
225
|
+
hosts?: string[] | undefined;
|
|
246
226
|
};
|
|
247
|
-
confirmWidening?: true;
|
|
248
227
|
}
|
|
249
228
|
/** The machine connected to a local device, as its owner sees it. */
|
|
250
229
|
export interface DeviceMachineView {
|
|
@@ -288,11 +267,12 @@ export declare class DevicesService {
|
|
|
288
267
|
private readonly machines;
|
|
289
268
|
private readonly policies;
|
|
290
269
|
private readonly ceilings;
|
|
270
|
+
private readonly facts;
|
|
291
271
|
constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get" | "fieldSource">, providers: Pick<SandboxProviders, "cloud" | "forName">, sandbox: Pick<SandboxService, "devicePolicy" | "deviceLimits" | "limitsState">, sandboxJobs: Pick<SandboxJobs, "resetFiles">,
|
|
292
272
|
/** Owes a deleted device's destruction in the delete's transaction. */
|
|
293
273
|
outbox: Pick<OutboxService, "add">, access: Pick<DeviceAccess, "usable">, displayNames: Pick<ExtensionDisplayNames, "many">,
|
|
294
274
|
/** Reads the device relay's lease (`online`). */
|
|
295
|
-
locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">, policies: Pick<DevicePolicyService, "apply" | "summary">, ceilings: PermissionCeilingWrites);
|
|
275
|
+
locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">, policies: Pick<DevicePolicyService, "apply" | "summary">, ceilings: PermissionCeilingWrites, facts: Pick<PermissionFacts, "deviceSandbox" | "deviceSandboxFacts">);
|
|
296
276
|
/**
|
|
297
277
|
* The person's live devices in the org, the default first, then by creation. With a
|
|
298
278
|
* current sandbox provider the default device is created first if missing (its first need,
|
|
@@ -348,23 +328,49 @@ export declare class DevicesService {
|
|
|
348
328
|
rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<DeviceView>;
|
|
349
329
|
private renameIn;
|
|
350
330
|
/**
|
|
351
|
-
* `PATCH /devices/:id`: renames one of the person's live devices ({@link rename}) and
|
|
352
|
-
* cloud device
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
331
|
+
* `PATCH /devices/:id`: renames one of the person's live devices ({@link rename}) and sets a
|
|
332
|
+
* cloud device's sandbox network ({@link networkLocked}), in one transaction. A network change
|
|
333
|
+
* takes the membership, the device row and the device's permission write lock as the ordered
|
|
334
|
+
* prelude (`withOrderedLocks`): inside a run's fence (`devices.set-network`) they follow the org
|
|
335
|
+
* row and precede the conversation rows. A local device's network lives on its machine
|
|
336
|
+
* (`device.ceiling_on_machine`). `narrowOnly` (an API token, the Platform tool): the network may
|
|
337
|
+
* only narrow, stored and effective.
|
|
338
|
+
*/
|
|
339
|
+
update(orgId: string, accountId: string, id: string, patch: DevicePatch, actorTokenId?: string, opts?: {
|
|
340
|
+
narrowOnly?: boolean;
|
|
341
|
+
auditDetail?: Record<string, unknown>;
|
|
342
|
+
}): Promise<DeviceView>;
|
|
343
|
+
/** The prelude of a network change: the membership, the device row, the device's write lock. */
|
|
344
|
+
private lockNetworkSubject;
|
|
358
345
|
private updateIn;
|
|
359
346
|
/**
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
|
|
365
|
-
|
|
347
|
+
* Checks a cloud network change without writing anything and without locks (the Platform
|
|
348
|
+
* tool's precheck): the device is the person's live cloud device, and the change stays within
|
|
349
|
+
* the ceilings and, with `narrowOnly`, only narrows. Throws what {@link update} would; the
|
|
350
|
+
* write re-checks under its locks.
|
|
351
|
+
*/
|
|
352
|
+
checkNetwork(orgId: string, accountId: string, id: string, network: NonNullable<DevicePatch["network"]>, narrowOnly: boolean): Promise<void>;
|
|
353
|
+
/**
|
|
354
|
+
* Decides a cloud network change (read only): the stored setting before and after, the
|
|
355
|
+
* effective device sandbox before and after (computed in memory from the patched setting), and
|
|
356
|
+
* whether it widens. Refuses, without writing: a local device (`device.ceiling_on_machine`),
|
|
357
|
+
* the open network above the ceilings or a host outside the org's list
|
|
358
|
+
* (`device.network_not_allowed`), and with `narrowOnly` a widening of the stored setting or of
|
|
359
|
+
* the effective network (`device.network_not_allowed`). Null when nothing changes.
|
|
360
|
+
*/
|
|
361
|
+
private planNetwork;
|
|
362
|
+
/**
|
|
363
|
+
* A cloud device's sandbox network (approval-only profiles design, "Settings model"), under the
|
|
364
|
+
* device authority writer held since the prelude: its owner chooses `open`, `allowlist` (its
|
|
365
|
+
* org's hosts, narrowed by its own list: a device list never adds a host; an empty one follows
|
|
366
|
+
* the org's hosts), `none` (closed) or null (follow the org), in both directions within the
|
|
367
|
+
* org's and the platform's ceilings ({@link planNetwork}). The write and its publication are one
|
|
368
|
+
* transaction: a narrowing bumps the device epoch and revokes the admitted or started work it
|
|
369
|
+
* takes ({@link networkNarrowingRevokes}; the revocations are owed through the outbox) and keeps
|
|
370
|
+
* Full consent; a widening resets Full consent with a `permission_profile_changed` event.
|
|
371
|
+
* Audited `device.network_changed` (`via`: `web`, `token` for an API token, or the agent's).
|
|
366
372
|
*/
|
|
367
|
-
private
|
|
373
|
+
private networkLocked;
|
|
368
374
|
/**
|
|
369
375
|
* How far restricted work may root outside the device's workspace now (B2): a local machine's
|
|
370
376
|
* owner reach within a platform and org that allow the wider device ceiling; a cloud device
|
|
@@ -372,11 +378,11 @@ export declare class DevicesService {
|
|
|
372
378
|
*/
|
|
373
379
|
projectReach(orgId: string, deviceId: string): Promise<"workspace" | "os-user">;
|
|
374
380
|
/**
|
|
375
|
-
* The
|
|
376
|
-
* spec §4.2): the
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
381
|
+
* The level a sandbox call in the device runs at now, for the model (legacy `device_paths`, auto
|
|
382
|
+
* mode spec §4.2): the kernel-internal tier (`SandboxMode`: a local machine's owner permission to
|
|
383
|
+
* run outside the sandbox, failing closed) with its device sandbox network, and a cloud device's
|
|
384
|
+
* pending file-reset state (the tier and network its instance still runs with). Null when the
|
|
385
|
+
* device is not a live device of the org.
|
|
380
386
|
*/
|
|
381
387
|
modeLevel(orgId: string, deviceId: string): Promise<DeviceModeLevel | null>;
|
|
382
388
|
/** Renames the device locked by {@link lockOwn} (`before`); see {@link rename}. */
|
|
@@ -403,14 +409,15 @@ export declare class DevicesService {
|
|
|
403
409
|
*/
|
|
404
410
|
revokeMachine(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
|
|
405
411
|
/**
|
|
406
|
-
* The owner
|
|
407
|
-
*
|
|
408
|
-
* answers with the policy as written. Anyone but the owner gets
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
412
|
+
* The owner narrows one of their own local devices' sandbox from the web (approval-only
|
|
413
|
+
* profiles design, "Settings model"): sent to the machine with the `policy` op, which is the
|
|
414
|
+
* authority and answers with the policy as written. Anyone but the owner gets
|
|
415
|
+
* `device.not_found`. The owner may remove hosts from the machine's allowlist and narrow its
|
|
416
|
+
* owner ceiling (no running outside the sandbox, the allowlist network, the workspace reach);
|
|
417
|
+
* widening happens on the machine only. The machine offline → `device.offline`; a cloud device
|
|
418
|
+
* or a program without the `policyOpId` feature → `device.policy_unsupported`; the machine's
|
|
419
|
+
* refusal → `device.policy_refused` with its message. Callers are human sessions only (no
|
|
420
|
+
* personal access token, no service token, no Platform op).
|
|
414
421
|
*/
|
|
415
422
|
changePolicy(orgId: string, account: {
|
|
416
423
|
id: string;
|
|
@@ -492,12 +499,10 @@ export declare class DevicesService {
|
|
|
492
499
|
/** The person's live devices (or the one `id`) as views. */
|
|
493
500
|
private views;
|
|
494
501
|
/**
|
|
495
|
-
* The last {@link RECENT_POLICY_CHANGES}
|
|
496
|
-
*
|
|
497
|
-
* `device.mode_changed`, `device.owner_ceiling_changed`), newest first, with the deciding
|
|
498
|
-
* account's display name.
|
|
502
|
+
* The last {@link RECENT_POLICY_CHANGES} setting changes of each device in the org (audit rows
|
|
503
|
+
* {@link SETTING_CHANGE_ACTIONS}), newest first, with the deciding account's display name.
|
|
499
504
|
*/
|
|
500
|
-
private
|
|
505
|
+
private recentChanges;
|
|
501
506
|
/**
|
|
502
507
|
* Serializes the person's device writes in the org: the org row (`FOR SHARE`), then their
|
|
503
508
|
* membership row (`FOR NO KEY UPDATE`, or `FOR SHARE` with `mode` share: enough to keep the
|
|
@@ -510,20 +515,28 @@ export declare class DevicesService {
|
|
|
510
515
|
private assertNameFree;
|
|
511
516
|
}
|
|
512
517
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
518
|
+
* Whether a cloud device's stored network setting widens from `a` to `b`, whatever the network in
|
|
519
|
+
* effect now (a stored widening takes effect when a ceiling opens later): a wider mode, where
|
|
520
|
+
* following the org (null) counts as wider than any explicit mode; or an explicit host list
|
|
521
|
+
* replaced by none of its own (follow the org's hosts) or gaining a host.
|
|
516
522
|
*/
|
|
517
|
-
export declare function
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
/**
|
|
529
|
-
|
|
523
|
+
export declare function storedNetworkWidens(a: DeviceNetworkSetting, b: DeviceNetworkSetting): boolean;
|
|
524
|
+
/**
|
|
525
|
+
* What a cloud device's new network takes from admitted or started work (`next`: its sandbox
|
|
526
|
+
* after the change): open-network work once it is no longer open, and allowlist work naming a host
|
|
527
|
+
* its new hosts no longer cover, unless an independent grant the new per-call ceiling still allows
|
|
528
|
+
* holds it (`hostsNarrowed`).
|
|
529
|
+
*/
|
|
530
|
+
export declare function networkNarrowingRevokes(next: {
|
|
531
|
+
box: Pick<DeviceSandbox, "networkMode" | "hosts">;
|
|
532
|
+
hostCeiling: HostGrantCeiling;
|
|
533
|
+
}, scope: SandboxOperationScope | SandboxBrowseScope, intent: Pick<Selectable<SandboxOperationIntentsTable>, "method" | "granted_hosts">): boolean;
|
|
534
|
+
/**
|
|
535
|
+
* The sandbox view of one device: its effective {@link DeviceSandbox} with its own network setting
|
|
536
|
+
* (`own`: a local machine's owner facts, a cloud device's stored choice) and the instance's pending
|
|
537
|
+
* change with the recent changes.
|
|
538
|
+
*/
|
|
539
|
+
export declare function sandboxViewOf(box: DeviceSandbox, own: Pick<OwnerFacts, "state" | "network" | "allowedDomains"> | {
|
|
540
|
+
networkMode: "open" | "allowlist" | "none" | null;
|
|
541
|
+
networkHosts: readonly string[];
|
|
542
|
+
}, extra: Pick<DeviceSandboxView, "pendingNextUse" | "pendingFilesReset" | "recent">): DeviceSandboxView;
|