@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
|
@@ -18,16 +18,16 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
18
18
|
import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
|
|
19
19
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
20
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
21
|
+
import { hostGrantable, hostGrantCeiling, } from "../sandbox/device-sandbox.js";
|
|
22
|
+
import { keepOrgLegacyKeysInStep, orgDeviceSandboxOf, readDeviceSandboxSettingsView, } from "../sandbox/device-sandbox-settings.js";
|
|
21
23
|
import { coversHost, orgCloudMode, orgEffectiveHosts, orgHostOutsideCeiling, } from "../sandbox/modes.js";
|
|
22
|
-
import { isExecutionMethod } from "../sandbox/operation-authority-types.js";
|
|
23
24
|
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
24
|
-
import { localMachineRoots, needsFullCeiling, needsWiderDeviceCeiling, PermissionCeilingWrites, } from "../sandbox/permission-ceiling-writes.js";
|
|
25
|
-
import { narrowedOrgFullAccess, readDevicesFullAccess, } from "../sandbox/platform-full-access.js";
|
|
25
|
+
import { cloudDevicesFollowingDefault, hostsNarrowed, localMachineRoots, needsFullCeiling, needsOpenNetwork, needsWiderDeviceCeiling, PermissionCeilingWrites, } from "../sandbox/permission-ceiling-writes.js";
|
|
26
26
|
import { readExternalSharing, readShareMaxExpiry, } from "../shares/settings.js";
|
|
27
27
|
import { assertThemeOnIn } from "../themes/theme-state.js";
|
|
28
28
|
import { IanaTimeZone } from "../time-zone.js";
|
|
29
29
|
import { mergeArrangement, OrgUiArrangementPatchSchema, UiArrangementSchema, } from "../ui/arrangement.js";
|
|
30
|
-
import {
|
|
30
|
+
import { DeviceNetworkSettingSchema, invalidDeviceNetwork, } from "./device-network-setting.js";
|
|
31
31
|
import { OrgLock, OrgLockModule } from "./org-lock.js";
|
|
32
32
|
/**
|
|
33
33
|
* Org settings (`capybara.orgs.settings` jsonb). Read leniently: a missing or invalid field reads
|
|
@@ -42,13 +42,16 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
|
|
|
42
42
|
* execution). An invalid stored value reads as `ask` (narrower, never wider) and is logged.
|
|
43
43
|
* - `wakeOnBackgroundTask`: the org's override of `runtime.wakeOnBackgroundTask` (absent follows
|
|
44
44
|
* the deployment), see {@link effectiveWakeOnBackgroundTask}.
|
|
45
|
-
* - `
|
|
46
|
-
*
|
|
47
|
-
* invalid stored value reads as `off` (narrower, never wider).
|
|
48
|
-
* platform is `off` is refused.
|
|
49
|
-
* - `
|
|
50
|
-
*
|
|
51
|
-
* `
|
|
45
|
+
* - `outsideSandbox`: whether devices of the org may be granted running a call outside their
|
|
46
|
+
* sandbox (approval-only profiles design, replacing `fullAccess`); absent follows the platform's
|
|
47
|
+
* `devices.outsideSandbox`, and an invalid stored value reads as `off` (narrower, never wider).
|
|
48
|
+
* Setting `allowed` while the platform is `off` is refused.
|
|
49
|
+
* - `deviceNetwork`: the org's device sandbox network, its default and ceiling and its hosts as a
|
|
50
|
+
* delta over the platform's allowlist ({@link DeviceNetworkSettingSchema}, replacing
|
|
51
|
+
* `cloudNetwork`). An invalid stored value reads as the empty allowlist (narrower, never wider);
|
|
52
|
+
* a default or ceiling above the platform's ceiling is refused.
|
|
53
|
+
* Old keys are read and kept in step until the permission configuration publication converts
|
|
54
|
+
* them ({@link orgDeviceSandboxOf}).
|
|
52
55
|
* - `platformTool`: the `Platform` builtin for the whole org (Platform tool spec §3): `on`,
|
|
53
56
|
* `read-only` (writes listed as unavailable) or `off` (default `on`).
|
|
54
57
|
* - `timeZone`: the org's default time zone (IANA; absent = UTC) for senders without one of their
|
|
@@ -60,12 +63,12 @@ import { OrgLock, OrgLockModule } from "./org-lock.js";
|
|
|
60
63
|
* - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
|
|
61
64
|
* not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
|
|
62
65
|
*/
|
|
63
|
-
export {
|
|
66
|
+
export { DeviceNetworkSettingSchema, invalidDeviceNetwork, ORG_SANDBOX_ALLOW_HOSTS_MAX, } from "./device-network-setting.js";
|
|
64
67
|
/**
|
|
65
|
-
* The org's
|
|
66
|
-
* `devices.
|
|
68
|
+
* The org's outside-sandbox ceiling: `allowed` or `off`; absent follows the platform's
|
|
69
|
+
* `devices.outsideSandbox`. An invalid stored value reads as `off` (narrower, never wider).
|
|
67
70
|
*/
|
|
68
|
-
export const
|
|
71
|
+
export const OutsideSandboxSetting = z.enum([
|
|
69
72
|
"allowed",
|
|
70
73
|
"off",
|
|
71
74
|
]);
|
|
@@ -150,10 +153,10 @@ export const OrgSettingsSchema = z.object({
|
|
|
150
153
|
/** Absent = `allow`; an invalid stored value reads as `ask` (narrower, never wider). */
|
|
151
154
|
sandboxToolPolicy: z.enum(["allow", "ask"]).default("allow").catch("ask"),
|
|
152
155
|
platformTool: z.enum(["on", "read-only", "off"]).default("on").catch("on"),
|
|
153
|
-
/** The org's
|
|
154
|
-
|
|
155
|
-
/** The org's
|
|
156
|
-
|
|
156
|
+
/** The org's outside-sandbox ceiling; absent follows the platform. */
|
|
157
|
+
outsideSandbox: OutsideSandboxSetting.optional().catch("off"),
|
|
158
|
+
/** The org's device sandbox network; absent follows the platform. */
|
|
159
|
+
deviceNetwork: DeviceNetworkSettingSchema.optional().catch(invalidDeviceNetwork),
|
|
157
160
|
/** Overrides `runtime.wakeOnBackgroundTask`; absent follows the deployment. */
|
|
158
161
|
wakeOnBackgroundTask: z.boolean().optional().catch(undefined),
|
|
159
162
|
/** The org's default time zone (run context spec §3.3); absent = UTC. */
|
|
@@ -199,15 +202,16 @@ export const OrgSettingsPatchSchema = z
|
|
|
199
202
|
/** null clears (follow the deployment again). */
|
|
200
203
|
wakeOnBackgroundTask: z.boolean().nullable().optional(),
|
|
201
204
|
/**
|
|
202
|
-
* The org's
|
|
203
|
-
* platform is `off` -> 400 `org.
|
|
205
|
+
* The org's outside-sandbox ceiling; null clears it (follow the platform). `allowed` while the
|
|
206
|
+
* platform is `off` -> 400 `org.outside_sandbox_not_allowed`.
|
|
204
207
|
*/
|
|
205
|
-
|
|
208
|
+
outsideSandbox: OutsideSandboxSetting.nullable().optional(),
|
|
206
209
|
/**
|
|
207
|
-
* The org's
|
|
208
|
-
*
|
|
210
|
+
* The org's device sandbox network, replaced whole (fields left out follow the platform); null
|
|
211
|
+
* clears it. A default or ceiling above the platform's ceiling -> 400 `org.network_not_allowed`.
|
|
212
|
+
* Through the Platform tool or an API token it may only narrow.
|
|
209
213
|
*/
|
|
210
|
-
|
|
214
|
+
deviceNetwork: DeviceNetworkSettingSchema.nullable().optional(),
|
|
211
215
|
/** The org's default time zone (IANA); null clears it (UTC). */
|
|
212
216
|
timeZone: IanaTimeZone.nullable().optional(),
|
|
213
217
|
/**
|
|
@@ -255,22 +259,26 @@ export function effectiveSandboxLimits(deployment, override) {
|
|
|
255
259
|
...(override?.memoryMb !== undefined && { memoryMb: override.memoryMb }),
|
|
256
260
|
};
|
|
257
261
|
}
|
|
258
|
-
/** Compare by value (`
|
|
262
|
+
/** Compare by value (`deviceNetwork` is an object); the schema fixes the key order. */
|
|
259
263
|
const sameSettings = (a, b) => JSON.stringify(OrgSettingsSchema.parse(a)) === JSON.stringify(OrgSettingsSchema.parse(b));
|
|
260
264
|
const asObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
261
265
|
/**
|
|
262
|
-
* Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}).
|
|
263
|
-
*
|
|
264
|
-
* publication has not converted yet ({@link
|
|
266
|
+
* Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}).
|
|
267
|
+
* `outsideSandbox` and `deviceNetwork` are read over the new and the old keys the permission
|
|
268
|
+
* configuration publication has not converted yet ({@link orgDeviceSandboxOf}; fail closed).
|
|
265
269
|
*/
|
|
266
270
|
export function parseOrgSettings(raw) {
|
|
267
271
|
const stored = asObject(raw);
|
|
268
272
|
const settings = OrgSettingsSchema.parse(stored);
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
delete settings.
|
|
273
|
+
const { outsideSandbox, deviceNetwork } = orgDeviceSandboxOf(stored);
|
|
274
|
+
if (outsideSandbox === undefined)
|
|
275
|
+
delete settings.outsideSandbox;
|
|
272
276
|
else
|
|
273
|
-
settings.
|
|
277
|
+
settings.outsideSandbox = outsideSandbox;
|
|
278
|
+
if (deviceNetwork === undefined)
|
|
279
|
+
delete settings.deviceNetwork;
|
|
280
|
+
else
|
|
281
|
+
settings.deviceNetwork = deviceNetwork;
|
|
274
282
|
return settings;
|
|
275
283
|
}
|
|
276
284
|
/** The org's stored settings jsonb, read live; undefined when the org is missing or deleted. */
|
|
@@ -333,7 +341,8 @@ export function logUnreadableSecuritySettings(log, orgId, raw) {
|
|
|
333
341
|
log("org settings: stored scheduledTasks.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
|
|
334
342
|
}
|
|
335
343
|
}
|
|
336
|
-
const
|
|
344
|
+
const outsideSandboxNotAllowed = (message) => new ApiError("org.outside_sandbox_not_allowed", message);
|
|
345
|
+
const networkNotAllowed = (message, field) => new ApiError("org.network_not_allowed", message, [{ path: `deviceNetwork.${field}` }]);
|
|
337
346
|
const externalSharingNotAllowed = (message) => new ApiError("org.external_sharing_not_allowed", message);
|
|
338
347
|
/** Whether a stored settings object holds an `externalSharing` this version reads as `off`. */
|
|
339
348
|
export function invalidStoredExternalSharing(raw) {
|
|
@@ -345,28 +354,51 @@ export function invalidStoredPromptSuggestions(raw) {
|
|
|
345
354
|
const v = asObject(raw).promptSuggestions;
|
|
346
355
|
return v !== undefined && !PromptSuggestionsSetting.safeParse(v).success;
|
|
347
356
|
}
|
|
348
|
-
/** Whether a stored settings object holds
|
|
349
|
-
export function
|
|
350
|
-
const v = asObject(raw).
|
|
351
|
-
return v !== undefined && !
|
|
357
|
+
/** Whether a stored settings object holds an `outsideSandbox` this version reads as `off`. */
|
|
358
|
+
export function invalidStoredOutsideSandbox(raw) {
|
|
359
|
+
const v = asObject(raw).outsideSandbox;
|
|
360
|
+
return v !== undefined && !OutsideSandboxSetting.safeParse(v).success;
|
|
361
|
+
}
|
|
362
|
+
/** Whether a stored settings object holds a `deviceNetwork` this version reads as an empty allowlist. */
|
|
363
|
+
export function invalidStoredDeviceNetwork(raw) {
|
|
364
|
+
const v = asObject(raw).deviceNetwork;
|
|
365
|
+
return v !== undefined && !DeviceNetworkSettingSchema.safeParse(v).success;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Whether `next`'s default or ceiling (absent: follow the platform, read as open, the widest the
|
|
369
|
+
* platform may relax to) opens where `prev`'s is the allowlist.
|
|
370
|
+
*/
|
|
371
|
+
export function deviceNetworkModeWidens(prev, next) {
|
|
372
|
+
const mode = (v) => v ?? "open";
|
|
373
|
+
if (mode(next?.ceiling) === "open" && mode(prev?.ceiling) !== "open")
|
|
374
|
+
return "ceiling";
|
|
375
|
+
if (mode(next?.default) === "open" && mode(prev?.default) !== "open")
|
|
376
|
+
return "default";
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
/** The org's effective network default and ceiling: its own, within the platform's. */
|
|
380
|
+
export function effectiveOrgNetwork(platform, org) {
|
|
381
|
+
const ceiling = platform.ceiling === "allowlist" || org?.ceiling === "allowlist" ? "allowlist" : "open";
|
|
382
|
+
const def = ceiling === "allowlist" ? "allowlist" : (org?.default ?? platform.default);
|
|
383
|
+
return { default: def, ceiling };
|
|
352
384
|
}
|
|
353
|
-
/**
|
|
354
|
-
export function
|
|
355
|
-
|
|
356
|
-
|
|
385
|
+
/** Which effective field opens from `a` to `b`, if any. */
|
|
386
|
+
export function effectiveNetworkWidens(a, b) {
|
|
387
|
+
if (a.ceiling === "allowlist" && b.ceiling === "open")
|
|
388
|
+
return "ceiling";
|
|
389
|
+
if (a.default === "allowlist" && b.default === "open")
|
|
390
|
+
return "default";
|
|
391
|
+
return null;
|
|
357
392
|
}
|
|
358
393
|
/**
|
|
359
|
-
* Whether `next` (absent: follow the platform)
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
394
|
+
* Whether `next`'s hosts (absent: follow the platform) widen `prev`'s (org egress ceiling spec
|
|
395
|
+
* §D3), both normalized (base platform, empty lists): base none to platform; with base platform,
|
|
396
|
+
* dropping one of the stored exclusions; an extra host no stored extra covers. Over-strict on
|
|
397
|
+
* purpose: moving to base none with a platform entry as an extra is a narrowing these rules refuse
|
|
398
|
+
* (a token cannot pin a platform host the platform may drop later).
|
|
364
399
|
*/
|
|
365
|
-
export function
|
|
366
|
-
const mode = (v) => v?.mode ?? "open";
|
|
400
|
+
export function deviceNetworkHostsWiden(prev, next) {
|
|
367
401
|
const base = (v) => v?.base ?? "platform";
|
|
368
|
-
if (mode(next) === "open" && mode(prev) !== "open")
|
|
369
|
-
return true;
|
|
370
402
|
if (base(next) === "platform" && base(prev) === "none")
|
|
371
403
|
return true;
|
|
372
404
|
if (base(next) === "platform") {
|
|
@@ -377,7 +409,7 @@ export function cloudNetworkWidens(prev, next) {
|
|
|
377
409
|
const prevExtra = (prev?.extraHosts ?? []).map((h) => h.toLowerCase());
|
|
378
410
|
return (next?.extraHosts ?? []).some((h) => !prevExtra.some((p) => coversHost(p, h.toLowerCase())));
|
|
379
411
|
}
|
|
380
|
-
/**
|
|
412
|
+
/** Org settings: read and update (an update needs `org.update`, re-checks the role under the lock and is audited). */
|
|
381
413
|
let OrgSettingsService = class OrgSettingsService {
|
|
382
414
|
db;
|
|
383
415
|
txHost;
|
|
@@ -387,8 +419,8 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
387
419
|
log;
|
|
388
420
|
constructor(db, txHost, orgLock,
|
|
389
421
|
/**
|
|
390
|
-
* The deployment config: `sandbox.limits` and the platform's
|
|
391
|
-
* (`devices.
|
|
422
|
+
* The deployment config: `sandbox.limits` and the platform's device sandbox settings
|
|
423
|
+
* (`devices.outsideSandbox`, `devices.network`; the org may follow them, never exceed them).
|
|
392
424
|
*/
|
|
393
425
|
config, ceilings, log) {
|
|
394
426
|
this.db = db;
|
|
@@ -398,12 +430,12 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
398
430
|
this.ceilings = ceilings;
|
|
399
431
|
this.log = log;
|
|
400
432
|
}
|
|
401
|
-
/** Parses stored settings, warning when an invalid `
|
|
402
|
-
* `
|
|
433
|
+
/** Parses stored settings, warning when an invalid `outsideSandbox` narrows to `off`, an
|
|
434
|
+
* invalid `deviceNetwork` to an empty allowlist, or a security setting reads narrower
|
|
403
435
|
* ({@link logUnreadableSecuritySettings}, warn). */
|
|
404
436
|
parseStored(orgId, raw) {
|
|
405
|
-
if (
|
|
406
|
-
this.log?.warn("org settings: stored
|
|
437
|
+
if (invalidStoredOutsideSandbox(raw)) {
|
|
438
|
+
this.log?.warn("org settings: stored outsideSandbox is invalid; it reads as off", { orgId });
|
|
407
439
|
}
|
|
408
440
|
if (invalidStoredExternalSharing(raw)) {
|
|
409
441
|
this.log?.warn("org settings: stored externalSharing is invalid; it reads as off", { orgId });
|
|
@@ -413,8 +445,8 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
413
445
|
orgId,
|
|
414
446
|
});
|
|
415
447
|
}
|
|
416
|
-
if (
|
|
417
|
-
this.log?.warn("org settings: stored
|
|
448
|
+
if (invalidStoredDeviceNetwork(raw)) {
|
|
449
|
+
this.log?.warn("org settings: stored deviceNetwork is invalid; it reads as an empty allowlist", {
|
|
418
450
|
orgId,
|
|
419
451
|
});
|
|
420
452
|
}
|
|
@@ -423,11 +455,11 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
423
455
|
logUnreadableSecuritySettings((m, f) => log.warn(m, f), orgId, raw);
|
|
424
456
|
return parseOrgSettings(raw);
|
|
425
457
|
}
|
|
426
|
-
/**
|
|
458
|
+
/** The deployment defaults (what "follow the platform" means on the settings page). */
|
|
427
459
|
async deployment() {
|
|
428
460
|
const lim = this.config.get().sandbox.limits;
|
|
429
|
-
const [
|
|
430
|
-
|
|
461
|
+
const [deviceSandbox, attribution, compaction, externalSharing, shareMaxExpiry, promptSuggestions,] = await Promise.all([
|
|
462
|
+
readDeviceSandboxSettingsView(this.db.db, this.config, this.log),
|
|
431
463
|
readPlatformAttribution(this.db.db, this.config, this.log),
|
|
432
464
|
readPlatformCompactionSettings(this.db.db),
|
|
433
465
|
readExternalSharing(this.db.db, this.config, this.log),
|
|
@@ -435,8 +467,9 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
435
467
|
readPromptSuggestions(this.db.db, this.log),
|
|
436
468
|
]);
|
|
437
469
|
return {
|
|
438
|
-
|
|
439
|
-
|
|
470
|
+
outsideSandbox: deviceSandbox.outsideSandbox,
|
|
471
|
+
deviceNetwork: {
|
|
472
|
+
...deviceSandbox.network,
|
|
440
473
|
allowHosts: [...lim.allowHosts],
|
|
441
474
|
orgHosts: lim.orgHosts,
|
|
442
475
|
off: lim.egress === "none",
|
|
@@ -465,14 +498,14 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
465
498
|
return effectivePromptSuggestions(platform, parseOrgSettings(row.settings).promptSuggestions);
|
|
466
499
|
}
|
|
467
500
|
/**
|
|
468
|
-
* The org's effective sandbox
|
|
469
|
-
*
|
|
501
|
+
* The org's effective sandbox network (spec §D3): its mode and the hosts, from the platform's
|
|
502
|
+
* `sandbox.limits` and the org's stored delta.
|
|
470
503
|
*/
|
|
471
504
|
effectiveNetwork(settings) {
|
|
472
505
|
const lim = this.config.get().sandbox.limits;
|
|
473
506
|
return {
|
|
474
|
-
mode: orgCloudMode(lim, settings.
|
|
475
|
-
hosts: orgEffectiveHosts(lim, settings.
|
|
507
|
+
mode: orgCloudMode(lim, settings.deviceNetwork),
|
|
508
|
+
hosts: orgEffectiveHosts(lim, settings.deviceNetwork),
|
|
476
509
|
};
|
|
477
510
|
}
|
|
478
511
|
/** 组织实际生效的沙箱 cpu / 内存(只读;由超级管理员在部署设置里覆盖)。 */
|
|
@@ -498,14 +531,21 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
498
531
|
}
|
|
499
532
|
/**
|
|
500
533
|
* The refusals of {@link update} that need no read of the org (the Platform tool's precheck):
|
|
501
|
-
*
|
|
534
|
+
* running outside the sandbox where the platform turned it off, a network default or ceiling
|
|
535
|
+
* above the platform's ceiling, external sharing where the platform denies it.
|
|
502
536
|
*/
|
|
503
537
|
async check(patch) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (platform.permission === "off") {
|
|
508
|
-
throw
|
|
538
|
+
if (patch.outsideSandbox === "allowed" || patch.deviceNetwork != null) {
|
|
539
|
+
const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
|
|
540
|
+
// allowing outside-sandbox runs where the platform turned them off is wider than it allows
|
|
541
|
+
if (patch.outsideSandbox === "allowed" && platform.outsideSandbox.permission === "off") {
|
|
542
|
+
throw outsideSandboxNotAllowed("The platform does not allow running outside the sandbox; a super admin must allow it in the admin console settings first");
|
|
543
|
+
}
|
|
544
|
+
const net = patch.deviceNetwork;
|
|
545
|
+
if (net != null && platform.network.ceiling === "allowlist") {
|
|
546
|
+
for (const field of ["ceiling", "default"])
|
|
547
|
+
if (net[field] === "open")
|
|
548
|
+
throw networkNotAllowed(`The platform limits device networks to the allowlist, so the organization's network ${field} cannot be open; a super admin sets devices.network.ceiling`, field);
|
|
509
549
|
}
|
|
510
550
|
}
|
|
511
551
|
if (patch.externalSharing === "on") {
|
|
@@ -516,23 +556,20 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
516
556
|
}
|
|
517
557
|
}
|
|
518
558
|
/**
|
|
519
|
-
* Under `sandbox.limits.orgHosts: within` (spec §D2), refuses
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
559
|
+
* Under `sandbox.limits.orgHosts: within` (spec §D2), refuses an extra host outside the
|
|
560
|
+
* platform's allowlist that the org did not store. Stored values are sent back as they are (the
|
|
561
|
+
* PATCH replaces `deviceNetwork` whole) and have no effect under the ceiling (they are filtered on
|
|
562
|
+
* read), so they never block a write. Whether the network may be open is the network ceiling's
|
|
563
|
+
* (`devices.network.ceiling`, {@link check}), not `orgHosts`'.
|
|
524
564
|
*/
|
|
525
565
|
assertWithinCeiling(before, patch) {
|
|
526
|
-
const cn = patch.
|
|
566
|
+
const cn = patch.deviceNetwork;
|
|
527
567
|
if (cn == null)
|
|
528
568
|
return;
|
|
529
569
|
const lim = this.config.get().sandbox.limits;
|
|
530
570
|
if (lim.orgHosts !== "within")
|
|
531
571
|
return;
|
|
532
|
-
|
|
533
|
-
throw new ApiError("org.sandbox_egress_not_allowed", "The platform limits sandbox networks to its allowlist; the open cloud network is not available", [{ reason: "open_not_allowed" }]);
|
|
534
|
-
}
|
|
535
|
-
const stored = new Set(before.cloudNetwork?.extraHosts ?? []);
|
|
572
|
+
const stored = new Set(before.deviceNetwork?.extraHosts ?? []);
|
|
536
573
|
const outside = (cn.extraHosts ?? []).filter((h) => !stored.has(h) && orgHostOutsideCeiling(lim, h));
|
|
537
574
|
if (outside.length > 0) {
|
|
538
575
|
throw new ApiError("org.sandbox_egress_not_allowed", `The platform limits sandbox hosts to its allowlist; ask a super admin to add ${outside.join(", ")} to sandbox.limits.allowHosts`, [{ reason: "outside_ceiling", hosts: outside }]);
|
|
@@ -542,43 +579,55 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
542
579
|
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
543
580
|
auditDetail,
|
|
544
581
|
/**
|
|
545
|
-
* `onlyNarrows` (the Platform tool, API tokens): refuse
|
|
582
|
+
* `onlyNarrows` (the Platform tool, API tokens): refuse an `outsideSandbox`, `deviceNetwork` or
|
|
546
583
|
* `externalSharing` change that widens (see {@link assertOnlyNarrows}); only a person in a
|
|
547
584
|
* session widens.
|
|
548
585
|
*/
|
|
549
586
|
opts) {
|
|
550
587
|
await this.check(patch);
|
|
551
|
-
// the org row, then (for a
|
|
588
|
+
// the org row, then (for a device sandbox change) the org's permission authority lock:
|
|
552
589
|
// the ordered prelude, so inside a run's fence (the Platform tool's `org-settings.update`) they
|
|
553
590
|
// precede the conversation rows; the patch decides the lock, so nothing can change it
|
|
554
591
|
return withOrderedLocks(() => this.lockFor(orgId, patch, actorAccountId), () => this.updateIn(orgId, patch, actorAccountId, actorTokenId, auditDetail, opts));
|
|
555
592
|
}
|
|
556
593
|
async lockFor(orgId, patch, actorAccountId) {
|
|
557
594
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "org.update");
|
|
558
|
-
if (patch.
|
|
595
|
+
if (patch.outsideSandbox !== undefined || patch.deviceNetwork !== undefined)
|
|
559
596
|
await this.ceilings.lock({ orgId }, "org");
|
|
560
597
|
}
|
|
561
598
|
/**
|
|
562
|
-
* Refuses a patch that widens the org's sandbox (
|
|
563
|
-
*
|
|
564
|
-
* - `
|
|
565
|
-
* platform); clearing it follows the platform too, never wider than the platform allows
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
599
|
+
* Refuses a patch that widens the org's sandbox (only a person widens it, never the Platform tool
|
|
600
|
+
* or an API token):
|
|
601
|
+
* - `outsideSandbox`: `allowed` where the organization runs `off` (an absent value follows the
|
|
602
|
+
* platform); clearing it follows the platform too, never wider than the platform allows
|
|
603
|
+
* (`org.outside_sandbox_not_allowed`);
|
|
604
|
+
* - `deviceNetwork`: compared as stored deltas, never as effective values (under the kill switch
|
|
605
|
+
* or a platform ceiling the effective values hide a widening that takes effect when the
|
|
606
|
+
* platform relaxes, org egress ceiling spec §D3): a default or ceiling opened
|
|
607
|
+
* ({@link deviceNetworkModeWidens}, `org.network_not_allowed`) or wider hosts
|
|
608
|
+
* ({@link deviceNetworkHostsWiden}, `org.sandbox_egress_not_allowed`);
|
|
569
609
|
* - `externalSharing`: `on` where the org is off (absent = off).
|
|
570
610
|
*/
|
|
571
611
|
async assertOnlyNarrows(before, patch) {
|
|
572
|
-
if (patch.
|
|
573
|
-
const platform = await
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
612
|
+
if (patch.outsideSandbox !== undefined) {
|
|
613
|
+
const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
|
|
614
|
+
const was = before.outsideSandbox ?? platform.outsideSandbox.permission;
|
|
615
|
+
const next = patch.outsideSandbox === null ? platform.outsideSandbox.permission : patch.outsideSandbox;
|
|
616
|
+
if (was !== "allowed" && next === "allowed") {
|
|
617
|
+
throw outsideSandboxNotAllowed("Allowing devices to run outside the sandbox needs a person in the organization settings.");
|
|
577
618
|
}
|
|
578
619
|
}
|
|
579
|
-
if (patch.
|
|
580
|
-
|
|
581
|
-
|
|
620
|
+
if (patch.deviceNetwork !== undefined) {
|
|
621
|
+
const next = patch.deviceNetwork ?? undefined;
|
|
622
|
+
// the stored delta (a widening that takes effect when the platform relaxes) and the
|
|
623
|
+
// effective value (an absent field follows the platform's) must both not open
|
|
624
|
+
const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
|
|
625
|
+
const field = deviceNetworkModeWidens(before.deviceNetwork, next) ??
|
|
626
|
+
effectiveNetworkWidens(effectiveOrgNetwork(platform.network, before.deviceNetwork), effectiveOrgNetwork(platform.network, next));
|
|
627
|
+
if (field !== null)
|
|
628
|
+
throw networkNotAllowed(`Opening the organization's network ${field} needs a person in the organization settings.`, field);
|
|
629
|
+
if (deviceNetworkHostsWiden(before.deviceNetwork, next))
|
|
630
|
+
throw new ApiError("org.sandbox_egress_not_allowed", "Widening the organization's device network hosts needs a person in the organization settings.");
|
|
582
631
|
}
|
|
583
632
|
if (patch.externalSharing === "on" && before.externalSharing !== "on") {
|
|
584
633
|
throw externalSharingNotAllowed("Turning external sharing on needs a person in the organization settings on the web; an API token or the Platform tool may only turn it off.");
|
|
@@ -602,7 +651,7 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
602
651
|
await this.assertOnlyNarrows(before, patch);
|
|
603
652
|
const changes = Object.fromEntries(Object.entries(patch)
|
|
604
653
|
.filter(([, v]) => v !== undefined)
|
|
605
|
-
// null clears
|
|
654
|
+
// null clears outsideSandbox / deviceNetwork / wakeOnBackgroundTask (follow the deployment
|
|
606
655
|
// again), externalSharing (off) and promptSuggestions (follow the platform)
|
|
607
656
|
.map(([k, v]) => [k, v === null ? undefined : v]));
|
|
608
657
|
const arrangementPatch = patch.uiArrangement;
|
|
@@ -629,17 +678,15 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
629
678
|
if (Object.keys(after.uiArrangement).length === 0)
|
|
630
679
|
delete after.uiArrangement;
|
|
631
680
|
}
|
|
632
|
-
//
|
|
633
|
-
// publication converts
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
|
|
637
|
-
if (
|
|
638
|
-
after.
|
|
639
|
-
if (after.
|
|
640
|
-
delete after.
|
|
641
|
-
if (after.cloudNetwork === undefined)
|
|
642
|
-
delete after.cloudNetwork;
|
|
681
|
+
// Stored old keys (`autoMode`, `fullAccess`, `cloudNetwork`) are never dropped here: only the
|
|
682
|
+
// permission configuration publication converts them (a mismatch window before activation
|
|
683
|
+
// keeps them). `before` already reads them narrowed (orgDeviceSandboxOf), so a write that does
|
|
684
|
+
// not choose a value stores what every reader already sees (never refused, never wider), and
|
|
685
|
+
// the old keys are carried in step below.
|
|
686
|
+
if (after.outsideSandbox === undefined)
|
|
687
|
+
delete after.outsideSandbox;
|
|
688
|
+
if (after.deviceNetwork === undefined)
|
|
689
|
+
delete after.deviceNetwork;
|
|
643
690
|
if (after.wakeOnBackgroundTask === undefined)
|
|
644
691
|
delete after.wakeOnBackgroundTask;
|
|
645
692
|
if (after.timeZone === undefined)
|
|
@@ -670,14 +717,11 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
670
717
|
if (patch.theme?.id != null && patch.theme.id !== before.theme?.id) {
|
|
671
718
|
await assertThemeOnIn(this.db.db, orgId, patch.theme.id);
|
|
672
719
|
}
|
|
673
|
-
// Merge with the stored value: keep the keys this version does not know (a cleared
|
|
674
|
-
//
|
|
675
|
-
const { autoMode: _legacyAutoMode, fullAccess:
|
|
676
|
-
const written = {
|
|
677
|
-
|
|
678
|
-
...after,
|
|
679
|
-
...(legacy && after.fullAccess !== undefined && { autoMode: after.fullAccess }),
|
|
680
|
-
};
|
|
720
|
+
// Merge with the stored value: keep the keys this version does not know (a cleared
|
|
721
|
+
// outsideSandbox / deviceNetwork is not kept; the old keys are rewritten in step)
|
|
722
|
+
const { autoMode: _legacyAutoMode, fullAccess: _legacyFullAccess, cloudNetwork: _legacyNetwork, outsideSandbox: _oldOutside, deviceNetwork: _oldNetwork, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, externalSharing: _oldExternalSharing, promptSuggestions: _oldPromptSuggestions, ...rest } = stored;
|
|
723
|
+
const written = { ...rest, ...after };
|
|
724
|
+
keepOrgLegacyKeysInStep(written, stored);
|
|
681
725
|
// An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
|
|
682
726
|
// list keeps it unreadable (never healed to "nothing forbidden"); saving the list fixes it
|
|
683
727
|
if (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools === undefined) {
|
|
@@ -700,24 +744,44 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
700
744
|
target: orgId,
|
|
701
745
|
detail: { before, after, ...(repairs && { repaired: true }), ...auditDetail },
|
|
702
746
|
});
|
|
703
|
-
if (patch.
|
|
747
|
+
if (patch.outsideSandbox !== undefined || patch.deviceNetwork !== undefined) {
|
|
748
|
+
// the consent reset follows the effective values as every reader sees them (re-read from
|
|
749
|
+
// what was written, within the platform), so a widening the platform hides resets nothing
|
|
750
|
+
const platform = await readDeviceSandboxSettingsView(this.db.db, this.config, this.log);
|
|
751
|
+
const effOutside = (o) => platform.outsideSandbox.permission === "off" ? "off" : (o.outsideSandbox ?? "allowed");
|
|
752
|
+
const reread = parseOrgSettings(written);
|
|
753
|
+
const prevNet = effectiveOrgNetwork(platform.network, before.deviceNetwork);
|
|
754
|
+
const nextNet = effectiveOrgNetwork(platform.network, reread.deviceNetwork);
|
|
755
|
+
// only a widening resets Full consent (running outside allowed again, a network or host
|
|
756
|
+
// list opening): a narrowing keeps what the consent covered
|
|
757
|
+
const resetConsent = (effOutside(before) === "off" && effOutside(reread) === "allowed") ||
|
|
758
|
+
effectiveNetworkWidens(prevNet, nextNet) !== null ||
|
|
759
|
+
deviceNetworkHostsWiden(before.deviceNetwork, reread.deviceNetwork);
|
|
704
760
|
const machineRoots = await localMachineRoots(this.db.db, orgId);
|
|
761
|
+
// a network ceiling narrowed to the allowlist takes running open-network work; a default
|
|
762
|
+
// narrowed to the allowlist takes it from the cloud devices that follow the default
|
|
763
|
+
const networkNarrowed = prevNet.ceiling === "open" && nextNet.ceiling === "allowlist";
|
|
764
|
+
const following = !networkNarrowed && prevNet.default === "open" && nextNet.default === "allowlist"
|
|
765
|
+
? await cloudDevicesFollowingDefault(this.db.db, orgId)
|
|
766
|
+
: null;
|
|
767
|
+
// the per-call hosts the org's new ceiling still allows (its hard allowlist ceiling and its
|
|
768
|
+
// exclusions): an independent grant keeps a removed host only within it
|
|
769
|
+
const lim = this.config.get().sandbox.limits;
|
|
770
|
+
const grantCeiling = hostGrantCeiling({ boundary: "operation", networkMode: "allowlist", networkCeiling: nextNet.ceiling }, lim, reread.deviceNetwork === undefined ? {} : { deviceNetwork: reread.deviceNetwork }, null);
|
|
771
|
+
const orgHosts = orgEffectiveHosts(lim, reread.deviceNetwork);
|
|
705
772
|
await this.ceilings.publishLocked({ orgId }, "org", (scope, row) => {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
773
|
+
if (needsOpenNetwork(scope) &&
|
|
774
|
+
(networkNarrowed || following?.has(row.device_id) === true))
|
|
775
|
+
return true;
|
|
776
|
+
// outside off takes escalated work and restricted work outside the machine's roots;
|
|
777
|
+
// anything else still goes through the host check below
|
|
778
|
+
if (after.outsideSandbox === "off" &&
|
|
709
779
|
needsWiderDeviceCeiling(scope, machineRoots.get(row.device_id)))
|
|
710
780
|
return true;
|
|
711
781
|
if (needsFullCeiling(scope))
|
|
712
|
-
return after.
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
scope.network.kind !== "allowlist")
|
|
716
|
-
return false;
|
|
717
|
-
const hosts = this.effectiveNetwork(after).hosts;
|
|
718
|
-
return scope.network.hosts.some((host) => !hosts.some((pattern) => coversHost(pattern, host)) &&
|
|
719
|
-
!(this.effectiveNetwork(after).mode === "open" && row.granted_hosts.includes(host)));
|
|
720
|
-
}, before.fullAccess !== after.fullAccess);
|
|
782
|
+
return after.outsideSandbox === "off";
|
|
783
|
+
return hostsNarrowed(scope, row, orgHosts, (host) => hostGrantable(grantCeiling, host));
|
|
784
|
+
}, resetConsent);
|
|
721
785
|
}
|
|
722
786
|
return viewOf(after, written);
|
|
723
787
|
}
|
|
@@ -741,7 +805,7 @@ OrgSettingsService = __decorate([
|
|
|
741
805
|
export { OrgSettingsService };
|
|
742
806
|
/**
|
|
743
807
|
* The one {@link OrgSettingsService}: the orgs module re-exports it, and the catalog imports it
|
|
744
|
-
* directly (approving a network request writes the org's
|
|
808
|
+
* directly (approving a network request writes the org's device network) without a cycle through
|
|
745
809
|
* OrgsModule.
|
|
746
810
|
*/
|
|
747
811
|
let OrgSettingsModule = class OrgSettingsModule {
|
package/dist/overrides.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { AGENT_LOOP_FACTORY, type AgentLoopFactory } from "./runtime/run-steps.j
|
|
|
27
27
|
import { RUN_HOOKS, type RunHooks } from "./runtime/run-worker.js";
|
|
28
28
|
import { SUBAGENT_MESSAGES_HOOKS, type SubagentMessagesHooks } from "./runtime/subagents/messages.js";
|
|
29
29
|
import { SANDBOX_LEASE_TIMINGS, type SandboxLeaseTimings } from "./sandbox/leases.js";
|
|
30
|
+
import { PERMISSION_AUTO_GRANT_HOOKS, type PermissionAutoGrantHooks } from "./sandbox/permission-auto-grants.js";
|
|
30
31
|
import { PERMISSION_CONTEXT_ACTIVATION } from "./sandbox/permission-context-types.js";
|
|
31
32
|
import { SETUP_CHECK_TIMEOUT } from "./setup/setup-checks.service.js";
|
|
32
33
|
import { TOOL_PIPELINE_HOOKS, type ToolPipelineHooks } from "./tools/pipeline.js";
|
|
@@ -69,7 +70,9 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
|
69
70
|
* - `APP_INTERCEPTOR`: one more global interceptor (a probe of the matched routes);
|
|
70
71
|
* - `PERMISSION_CONTEXT_ACTIVATION`: the recorded permission context producers (the request
|
|
71
72
|
* boundary and the managed device context writer); production leaves them on, and a test may
|
|
72
|
-
* turn them off to exercise the dormant state
|
|
73
|
+
* turn them off to exercise the dormant state;
|
|
74
|
+
* - `PERMISSION_AUTO_GRANT_HOOKS`: a barrier after a Full access auto-grant's precheck (two
|
|
75
|
+
* replicas racing the same crossing).
|
|
73
76
|
*/
|
|
74
77
|
interface KernelSeams {
|
|
75
78
|
[AGENT_LOOP_FACTORY]: AgentLoopFactory;
|
|
@@ -102,6 +105,7 @@ interface KernelSeams {
|
|
|
102
105
|
[EXTENSION_NET_SEAMS]: ExtensionNetSeams;
|
|
103
106
|
[APP_INTERCEPTOR]: NestInterceptor;
|
|
104
107
|
[PERMISSION_CONTEXT_ACTIVATION]: boolean;
|
|
108
|
+
[PERMISSION_AUTO_GRANT_HOOKS]: PermissionAutoGrantHooks;
|
|
105
109
|
}
|
|
106
110
|
/**
|
|
107
111
|
* A seam of the kernel's own tests (`KernelAppOptions.overrides`): a value for one of the named
|
package/dist/overrides.js
CHANGED
|
@@ -24,6 +24,7 @@ import { AGENT_LOOP_FACTORY } from "./runtime/run-steps.js";
|
|
|
24
24
|
import { RUN_HOOKS } from "./runtime/run-worker.js";
|
|
25
25
|
import { SUBAGENT_MESSAGES_HOOKS, } from "./runtime/subagents/messages.js";
|
|
26
26
|
import { SANDBOX_LEASE_TIMINGS } from "./sandbox/leases.js";
|
|
27
|
+
import { PERMISSION_AUTO_GRANT_HOOKS, } from "./sandbox/permission-auto-grants.js";
|
|
27
28
|
import { PERMISSION_CONTEXT_ACTIVATION } from "./sandbox/permission-context-types.js";
|
|
28
29
|
import { SETUP_CHECK_TIMEOUT } from "./setup/setup-checks.service.js";
|
|
29
30
|
import { TOOL_PIPELINE_HOOKS } from "./tools/pipeline.js";
|
|
@@ -59,6 +60,7 @@ const SEAM_TOKENS = [
|
|
|
59
60
|
EXTENSION_NET_SEAMS,
|
|
60
61
|
APP_INTERCEPTOR,
|
|
61
62
|
PERMISSION_CONTEXT_ACTIVATION,
|
|
63
|
+
PERMISSION_AUTO_GRANT_HOOKS,
|
|
62
64
|
];
|
|
63
65
|
const allSeamsListed = true;
|
|
64
66
|
void allSeamsListed;
|
|
@@ -334,7 +334,7 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
334
334
|
{
|
|
335
335
|
route: "POST /api/v1/orgs/:orgId/devices/:id/policy",
|
|
336
336
|
category: "human-only",
|
|
337
|
-
reason: "A person
|
|
337
|
+
reason: "A person narrows their own machine's sandbox (hosts, network, running outside the sandbox) on its device page; widening happens on the machine, never through an agent",
|
|
338
338
|
},
|
|
339
339
|
{
|
|
340
340
|
route: "POST /api/v1/device/authorize",
|