@capybara-hq/kernel 0.1.0-rc.53 → 0.1.0-rc.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +15 -1
- package/dist/config/schema.js +66 -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 +18 -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 +43 -19
- package/dist/errors.js +43 -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/http/api.module.js +8 -0
- package/dist/http/app.js +9 -0
- package/dist/http/meta.controller.d.ts +33 -0
- package/dist/http/meta.controller.js +72 -0
- package/dist/identity/app-auth.controller.d.ts +25 -0
- package/dist/identity/app-auth.controller.js +64 -0
- package/dist/identity/app-auth.d.ts +66 -0
- package/dist/identity/app-auth.js +203 -0
- package/dist/identity/app-auth.schemas.d.ts +47 -0
- package/dist/identity/app-auth.schemas.js +43 -0
- package/dist/identity/identity.module.d.ts +1 -1
- package/dist/identity/identity.module.js +4 -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 +19 -5
- package/dist/infra/outbox/registry.d.ts +14 -0
- package/dist/infra/outbox/registry.js +15 -0
- package/dist/infra/throttler/named-throttlers.d.ts +3 -2
- package/dist/infra/throttler/named-throttlers.js +14 -2
- 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 +24 -1
- package/dist/platform/operation.js +2 -2
- 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/platform/ops/platform-icons.ops.d.ts +14 -0
- package/dist/platform/ops/platform-icons.ops.js +117 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +3 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/runtime/context/permission-profile.d.ts +17 -8
- package/dist/runtime/context/permission-profile.js +126 -45
- package/dist/runtime/maintenance.d.ts +5 -2
- package/dist/runtime/maintenance.js +15 -4
- 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/themes/platform-icon-objects.d.ts +51 -0
- package/dist/themes/platform-icon-objects.js +113 -0
- package/dist/themes/platform-icon-public.controller.d.ts +17 -0
- package/dist/themes/platform-icon-public.controller.js +58 -0
- package/dist/themes/platform-icon.controller.d.ts +22 -0
- package/dist/themes/platform-icon.controller.js +65 -0
- package/dist/themes/platform-icon.schemas.d.ts +48 -0
- package/dist/themes/platform-icon.schemas.js +53 -0
- package/dist/themes/platform-icon.service.d.ts +83 -0
- package/dist/themes/platform-icon.service.js +301 -0
- package/dist/themes/themes.module.d.ts +4 -1
- package/dist/themes/themes.module.js +9 -4
- 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/0164_platform_icons.sql +10 -0
- 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
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** The org device network allowlist's host limit. */
|
|
4
|
+
export const ORG_SANDBOX_ALLOW_HOSTS_MAX = 200;
|
|
5
|
+
/** One host list of the org's device network: at most {@link ORG_SANDBOX_ALLOW_HOSTS_MAX} valid, unique hosts. */
|
|
6
|
+
const orgHostList = (name) => z
|
|
7
|
+
.array(z.string())
|
|
8
|
+
.max(ORG_SANDBOX_ALLOW_HOSTS_MAX)
|
|
9
|
+
.superRefine((hosts, ctx) => {
|
|
10
|
+
hosts.forEach((h, i) => {
|
|
11
|
+
for (const message of validateAllowHost(h)) {
|
|
12
|
+
ctx.addIssue({ code: "custom", path: [i], message: `${h}: ${message}` });
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (new Set(hosts).size !== hosts.length) {
|
|
16
|
+
ctx.addIssue({ code: "custom", message: `${name} must not contain duplicates` });
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
.optional();
|
|
20
|
+
const Mode = z.enum(["open", "allowlist"]);
|
|
21
|
+
/**
|
|
22
|
+
* The org's device sandbox network (approval-only profiles design, "Settings model"), for local and
|
|
23
|
+
* cloud devices alike, with its hosts stored as a delta over the platform's
|
|
24
|
+
* `sandbox.limits.allowHosts`, never a copy of it, so platform changes keep reaching the org:
|
|
25
|
+
* - `default`: the network a device of the org gets when its owner chooses none (`open` or
|
|
26
|
+
* `allowlist`); absent follows the platform's `devices.network.default`.
|
|
27
|
+
* - `ceiling`: the widest network a device of the org may choose; absent follows the platform's
|
|
28
|
+
* `devices.network.ceiling`. Never above the platform's ceiling (`org.network_not_allowed`); a
|
|
29
|
+
* default above the ceiling is refused.
|
|
30
|
+
* - `base`: `platform` (the default: start from the platform's list) or `none` (only the org's own
|
|
31
|
+
* hosts).
|
|
32
|
+
* - `extraHosts`: hosts the org adds (ignored outside the platform list under `orgHosts: within`).
|
|
33
|
+
* - `excludedHosts`: platform entries the org drops (exact entries; any host is accepted, since the
|
|
34
|
+
* platform may drop an entry later).
|
|
35
|
+
* The effective hosts are `orgEffectiveHosts` in `sandbox/modes.ts`.
|
|
36
|
+
*/
|
|
37
|
+
export const DeviceNetworkSettingSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
default: Mode.optional(),
|
|
40
|
+
ceiling: Mode.optional(),
|
|
41
|
+
base: z.enum(["platform", "none"]).optional(),
|
|
42
|
+
extraHosts: orgHostList("extraHosts"),
|
|
43
|
+
excludedHosts: orgHostList("excludedHosts"),
|
|
44
|
+
})
|
|
45
|
+
.strict()
|
|
46
|
+
.superRefine((n, ctx) => {
|
|
47
|
+
if (n.default === "open" && n.ceiling === "allowlist")
|
|
48
|
+
ctx.addIssue({
|
|
49
|
+
code: "custom",
|
|
50
|
+
path: ["default"],
|
|
51
|
+
message: "default open is above ceiling allowlist; choose a default no wider than the ceiling",
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
/** What an invalid stored `deviceNetwork` reads as: the allowlist with no host (never wider). */
|
|
55
|
+
export const invalidDeviceNetwork = () => ({
|
|
56
|
+
default: "allowlist",
|
|
57
|
+
ceiling: "allowlist",
|
|
58
|
+
base: "none",
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* The org network shape before the approval-only profiles design (`cloudNetwork`), read only to
|
|
62
|
+
* convert it ({@link convertLegacyCloudNetwork}) and to keep it in step for replicas of the
|
|
63
|
+
* previous version until the permission configuration publication converts it.
|
|
64
|
+
*/
|
|
65
|
+
export const LegacyCloudNetworkSchema = z
|
|
66
|
+
.object({
|
|
67
|
+
mode: Mode.optional(),
|
|
68
|
+
base: z.enum(["platform", "none"]).optional(),
|
|
69
|
+
extraHosts: orgHostList("extraHosts"),
|
|
70
|
+
excludedHosts: orgHostList("excludedHosts"),
|
|
71
|
+
})
|
|
72
|
+
.strict();
|
|
73
|
+
/** Drops absent fields; an object with none left is `undefined` (follow the platform). */
|
|
74
|
+
function compact(n) {
|
|
75
|
+
const out = Object.fromEntries(Object.entries(n).filter(([, v]) => v !== undefined));
|
|
76
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The stored-key conversion of an org's old `cloudNetwork` (design, "Migration"): `mode:
|
|
80
|
+
* "allowlist"` becomes `ceiling: "allowlist"`, keeping `base`, `extraHosts` and `excludedHosts`;
|
|
81
|
+
* `mode: "open"` or absent becomes absent. An invalid old value converts to
|
|
82
|
+
* {@link invalidDeviceNetwork}, as it read before (never wider). `undefined` stays `undefined`.
|
|
83
|
+
*/
|
|
84
|
+
export function convertLegacyCloudNetwork(raw) {
|
|
85
|
+
if (raw === undefined)
|
|
86
|
+
return undefined;
|
|
87
|
+
const parsed = LegacyCloudNetworkSchema.safeParse(raw);
|
|
88
|
+
if (!parsed.success)
|
|
89
|
+
return invalidDeviceNetwork();
|
|
90
|
+
const { mode, ...hosts } = parsed.data;
|
|
91
|
+
return compact({ ...(mode === "allowlist" && { ceiling: "allowlist" }), ...hosts });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The old `cloudNetwork` that says no more than `n`, written next to `deviceNetwork` while the old
|
|
95
|
+
* key is still stored (replicas of the previous version read it): `mode: "allowlist"` when either
|
|
96
|
+
* the default or the ceiling is the allowlist (never wider for an old reader). `undefined` when `n`
|
|
97
|
+
* says nothing the old shape holds.
|
|
98
|
+
*/
|
|
99
|
+
export function legacyCloudNetworkOf(n) {
|
|
100
|
+
if (n === undefined)
|
|
101
|
+
return undefined;
|
|
102
|
+
const { default: def, ceiling, ...hosts } = n;
|
|
103
|
+
const out = {
|
|
104
|
+
...((def === "allowlist" || ceiling === "allowlist") && { mode: "allowlist" }),
|
|
105
|
+
...hosts,
|
|
106
|
+
};
|
|
107
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `n` with the ceiling (and an open default) narrowed to the allowlist: what an old `fullAccess:
|
|
111
|
+
* "off"` adds, since it kept every device of the org on the allowlist (never wider).
|
|
112
|
+
*/
|
|
113
|
+
export const withAllowlistCeiling = (n) => ({
|
|
114
|
+
...n,
|
|
115
|
+
...(n?.default !== undefined && { default: "allowlist" }),
|
|
116
|
+
ceiling: "allowlist",
|
|
117
|
+
});
|
|
118
|
+
const narrowerMode = (a, b) => a === "allowlist" || b === "allowlist" ? "allowlist" : (a ?? b);
|
|
119
|
+
/**
|
|
120
|
+
* A delta never wider than either `a` or `b` (absent: follow the platform), for two stored values
|
|
121
|
+
* that disagree (fail closed): the narrower default and ceiling, base `none` when either is, only
|
|
122
|
+
* the extra hosts both hold (each covering the other's exactly), and every exclusion of either.
|
|
123
|
+
* It may be narrower than both; it is only read while an old replica's write diverges.
|
|
124
|
+
*/
|
|
125
|
+
export function narrowerDeviceNetwork(a, b) {
|
|
126
|
+
if (a === undefined && b === undefined)
|
|
127
|
+
return undefined;
|
|
128
|
+
const ceiling = narrowerMode(a?.ceiling, b?.ceiling);
|
|
129
|
+
let def = narrowerMode(a?.default, b?.default);
|
|
130
|
+
if (ceiling === "allowlist" && def === "open")
|
|
131
|
+
def = "allowlist";
|
|
132
|
+
const extraA = new Set(a?.extraHosts ?? []);
|
|
133
|
+
const extra = (b?.extraHosts ?? []).filter((h) => extraA.has(h));
|
|
134
|
+
const excluded = [...new Set([...(a?.excludedHosts ?? []), ...(b?.excludedHosts ?? [])])];
|
|
135
|
+
return compact({
|
|
136
|
+
default: def,
|
|
137
|
+
ceiling,
|
|
138
|
+
base: a?.base === "none" || b?.base === "none" ? "none" : (a?.base ?? b?.base),
|
|
139
|
+
extraHosts: extra.length > 0 ? extra : undefined,
|
|
140
|
+
excludedHosts: excluded.length > 0 ? excluded : undefined,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
@@ -7,10 +7,11 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
7
7
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
8
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
9
9
|
import type { KernelLogger } from "../log.js";
|
|
10
|
+
import { type DeviceNetworkMode } from "../sandbox/device-sandbox.js";
|
|
11
|
+
import { type DevicesNetworkView, type DevicesOutsideSandboxView } from "../sandbox/device-sandbox-settings.js";
|
|
10
12
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
11
|
-
import { type DevicesFullAccessView } from "../sandbox/platform-full-access.js";
|
|
12
13
|
import { type ExternalSharingView } from "../shares/settings.js";
|
|
13
|
-
import { type
|
|
14
|
+
import { type DeviceNetworkSetting } from "./device-network-setting.js";
|
|
14
15
|
import { OrgLock } from "./org-lock.js";
|
|
15
16
|
/**
|
|
16
17
|
* Org settings (`capybara.orgs.settings` jsonb). Read leniently: a missing or invalid field reads
|
|
@@ -25,13 +26,16 @@ import { OrgLock } from "./org-lock.js";
|
|
|
25
26
|
* execution). An invalid stored value reads as `ask` (narrower, never wider) and is logged.
|
|
26
27
|
* - `wakeOnBackgroundTask`: the org's override of `runtime.wakeOnBackgroundTask` (absent follows
|
|
27
28
|
* the deployment), see {@link effectiveWakeOnBackgroundTask}.
|
|
28
|
-
* - `
|
|
29
|
-
*
|
|
30
|
-
* invalid stored value reads as `off` (narrower, never wider).
|
|
31
|
-
* platform is `off` is refused.
|
|
32
|
-
* - `
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
29
|
+
* - `outsideSandbox`: whether devices of the org may be granted running a call outside their
|
|
30
|
+
* sandbox (approval-only profiles design, replacing `fullAccess`); absent follows the platform's
|
|
31
|
+
* `devices.outsideSandbox`, and an invalid stored value reads as `off` (narrower, never wider).
|
|
32
|
+
* Setting `allowed` while the platform is `off` is refused.
|
|
33
|
+
* - `deviceNetwork`: the org's device sandbox network, its default and ceiling and its hosts as a
|
|
34
|
+
* delta over the platform's allowlist ({@link DeviceNetworkSettingSchema}, replacing
|
|
35
|
+
* `cloudNetwork`). An invalid stored value reads as the empty allowlist (narrower, never wider);
|
|
36
|
+
* a default or ceiling above the platform's ceiling is refused.
|
|
37
|
+
* Old keys are read and kept in step until the permission configuration publication converts
|
|
38
|
+
* them ({@link orgDeviceSandboxOf}).
|
|
35
39
|
* - `platformTool`: the `Platform` builtin for the whole org (Platform tool spec §3): `on`,
|
|
36
40
|
* `read-only` (writes listed as unavailable) or `off` (default `on`).
|
|
37
41
|
* - `timeZone`: the org's default time zone (IANA; absent = UTC) for senders without one of their
|
|
@@ -43,12 +47,12 @@ import { OrgLock } from "./org-lock.js";
|
|
|
43
47
|
* - `gitGateway`: the org's git gateway switch and host sources (sandbox git credentials spec §9);
|
|
44
48
|
* not in the PATCH yet; an invalid stored value reads as `{ enabled: false }` (fails closed).
|
|
45
49
|
*/
|
|
46
|
-
export { type
|
|
50
|
+
export { type DeviceNetworkSetting, DeviceNetworkSettingSchema, invalidDeviceNetwork, ORG_SANDBOX_ALLOW_HOSTS_MAX, } from "./device-network-setting.js";
|
|
47
51
|
/**
|
|
48
|
-
* The org's
|
|
49
|
-
* `devices.
|
|
52
|
+
* The org's outside-sandbox ceiling: `allowed` or `off`; absent follows the platform's
|
|
53
|
+
* `devices.outsideSandbox`. An invalid stored value reads as `off` (narrower, never wider).
|
|
50
54
|
*/
|
|
51
|
-
export declare const
|
|
55
|
+
export declare const OutsideSandboxSetting: z.ZodEnum<{
|
|
52
56
|
allowed: "allowed";
|
|
53
57
|
off: "off";
|
|
54
58
|
}>;
|
|
@@ -143,12 +147,16 @@ export declare const OrgSettingsSchema: z.ZodObject<{
|
|
|
143
147
|
on: "on";
|
|
144
148
|
"read-only": "read-only";
|
|
145
149
|
}>>>;
|
|
146
|
-
|
|
150
|
+
outsideSandbox: z.ZodCatch<z.ZodOptional<z.ZodEnum<{
|
|
147
151
|
allowed: "allowed";
|
|
148
152
|
off: "off";
|
|
149
153
|
}>>>;
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
deviceNetwork: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
155
|
+
default: z.ZodOptional<z.ZodEnum<{
|
|
156
|
+
allowlist: "allowlist";
|
|
157
|
+
open: "open";
|
|
158
|
+
}>>;
|
|
159
|
+
ceiling: z.ZodOptional<z.ZodEnum<{
|
|
152
160
|
allowlist: "allowlist";
|
|
153
161
|
open: "open";
|
|
154
162
|
}>>;
|
|
@@ -236,12 +244,16 @@ export declare const OrgSettingsPatchSchema: z.ZodObject<{
|
|
|
236
244
|
"read-only": "read-only";
|
|
237
245
|
}>>;
|
|
238
246
|
wakeOnBackgroundTask: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
239
|
-
|
|
247
|
+
outsideSandbox: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
240
248
|
allowed: "allowed";
|
|
241
249
|
off: "off";
|
|
242
250
|
}>>>;
|
|
243
|
-
|
|
244
|
-
|
|
251
|
+
deviceNetwork: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
252
|
+
default: z.ZodOptional<z.ZodEnum<{
|
|
253
|
+
allowlist: "allowlist";
|
|
254
|
+
open: "open";
|
|
255
|
+
}>>;
|
|
256
|
+
ceiling: z.ZodOptional<z.ZodEnum<{
|
|
245
257
|
allowlist: "allowlist";
|
|
246
258
|
open: "open";
|
|
247
259
|
}>>;
|
|
@@ -300,10 +312,10 @@ export declare function effectiveWakeOnBackgroundTask(deployment: boolean, org:
|
|
|
300
312
|
* setting `sandboxLimitOverrides[orgId]`) replaces the deployment's cpu / memoryMb; fields it does
|
|
301
313
|
* not give, disk and the network, stay as in `deployment`. Read only when an instance is created.
|
|
302
314
|
*/
|
|
303
|
-
export declare function effectiveSandboxLimits(deployment:
|
|
315
|
+
export declare function effectiveSandboxLimits<L extends SandboxLimits>(deployment: L, override: {
|
|
304
316
|
cpu?: number | undefined;
|
|
305
317
|
memoryMb?: number | undefined;
|
|
306
|
-
} | undefined):
|
|
318
|
+
} | undefined): L;
|
|
307
319
|
/** 组织设置 GET 带回的只读沙箱限额:实际生效值与来源(有超级管理员的覆盖为 `override`)。 */
|
|
308
320
|
export interface OrgSandboxLimits {
|
|
309
321
|
cpu: number;
|
|
@@ -317,14 +329,14 @@ export interface OrgEffectiveNetwork {
|
|
|
317
329
|
}
|
|
318
330
|
/** The deployment defaults the settings page shows for "follow the platform" (`GET` returns them). */
|
|
319
331
|
export interface OrgSettingsDeployment {
|
|
320
|
-
/** The platform's
|
|
321
|
-
|
|
332
|
+
/** The platform's outside-sandbox ceiling and where it comes from. */
|
|
333
|
+
outsideSandbox: DevicesOutsideSandboxView;
|
|
322
334
|
/**
|
|
323
|
-
* The platform's network: its
|
|
324
|
-
*
|
|
325
|
-
* `none`).
|
|
335
|
+
* The platform's device network: its default and ceiling with their sources, its allowlist
|
|
336
|
+
* (what an org's delta applies to), whether orgs may go beyond it (`sandbox.limits.orgHosts`)
|
|
337
|
+
* and the kill switch (`off`: `sandbox.limits.egress` is `none`).
|
|
326
338
|
*/
|
|
327
|
-
|
|
339
|
+
deviceNetwork: DevicesNetworkView & {
|
|
328
340
|
allowHosts: string[];
|
|
329
341
|
orgHosts: "extend" | "within";
|
|
330
342
|
off: boolean;
|
|
@@ -346,9 +358,9 @@ export interface OrgSettingsDeployment {
|
|
|
346
358
|
promptSuggestions: "on" | "off";
|
|
347
359
|
}
|
|
348
360
|
/**
|
|
349
|
-
* Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}).
|
|
350
|
-
*
|
|
351
|
-
* publication has not converted yet ({@link
|
|
361
|
+
* Parses the stored jsonb into settings (leniently, see {@link OrgSettingsSchema}).
|
|
362
|
+
* `outsideSandbox` and `deviceNetwork` are read over the new and the old keys the permission
|
|
363
|
+
* configuration publication has not converted yet ({@link orgDeviceSandboxOf}; fail closed).
|
|
352
364
|
*/
|
|
353
365
|
export declare function parseOrgSettings(raw: unknown): OrgSettings;
|
|
354
366
|
/** The org's stored settings jsonb, read live; undefined when the org is missing or deleted. */
|
|
@@ -383,70 +395,92 @@ export declare function logUnreadableSecuritySettings(log: (msg: string, fields:
|
|
|
383
395
|
export declare function invalidStoredExternalSharing(raw: unknown): boolean;
|
|
384
396
|
/** Whether a stored settings object holds a `promptSuggestions` this version reads as `off`. */
|
|
385
397
|
export declare function invalidStoredPromptSuggestions(raw: unknown): boolean;
|
|
386
|
-
/** Whether a stored settings object holds
|
|
387
|
-
export declare function
|
|
388
|
-
/** Whether a stored settings object holds a `
|
|
389
|
-
export declare function
|
|
398
|
+
/** Whether a stored settings object holds an `outsideSandbox` this version reads as `off`. */
|
|
399
|
+
export declare function invalidStoredOutsideSandbox(raw: unknown): boolean;
|
|
400
|
+
/** Whether a stored settings object holds a `deviceNetwork` this version reads as an empty allowlist. */
|
|
401
|
+
export declare function invalidStoredDeviceNetwork(raw: unknown): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Whether `next`'s default or ceiling (absent: follow the platform, read as open, the widest the
|
|
404
|
+
* platform may relax to) opens where `prev`'s is the allowlist.
|
|
405
|
+
*/
|
|
406
|
+
export declare function deviceNetworkModeWidens(prev: DeviceNetworkSetting | undefined, next: DeviceNetworkSetting | undefined): "default" | "ceiling" | null;
|
|
407
|
+
/** The org's effective network default and ceiling: its own, within the platform's. */
|
|
408
|
+
export declare function effectiveOrgNetwork(platform: {
|
|
409
|
+
default: DeviceNetworkMode;
|
|
410
|
+
ceiling: DeviceNetworkMode;
|
|
411
|
+
}, org: DeviceNetworkSetting | undefined): {
|
|
412
|
+
default: DeviceNetworkMode;
|
|
413
|
+
ceiling: DeviceNetworkMode;
|
|
414
|
+
};
|
|
415
|
+
/** Which effective field opens from `a` to `b`, if any. */
|
|
416
|
+
export declare function effectiveNetworkWidens(a: {
|
|
417
|
+
default: DeviceNetworkMode;
|
|
418
|
+
ceiling: DeviceNetworkMode;
|
|
419
|
+
}, b: {
|
|
420
|
+
default: DeviceNetworkMode;
|
|
421
|
+
ceiling: DeviceNetworkMode;
|
|
422
|
+
}): "default" | "ceiling" | null;
|
|
390
423
|
/**
|
|
391
|
-
* Whether `next` (absent: follow the platform)
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
424
|
+
* Whether `next`'s hosts (absent: follow the platform) widen `prev`'s (org egress ceiling spec
|
|
425
|
+
* §D3), both normalized (base platform, empty lists): base none to platform; with base platform,
|
|
426
|
+
* dropping one of the stored exclusions; an extra host no stored extra covers. Over-strict on
|
|
427
|
+
* purpose: moving to base none with a platform entry as an extra is a narrowing these rules refuse
|
|
428
|
+
* (a token cannot pin a platform host the platform may drop later).
|
|
396
429
|
*/
|
|
397
|
-
export declare function
|
|
398
|
-
/**
|
|
430
|
+
export declare function deviceNetworkHostsWiden(prev: DeviceNetworkSetting | undefined, next: DeviceNetworkSetting | undefined): boolean;
|
|
431
|
+
/** Org settings: read and update (an update needs `org.update`, re-checks the role under the lock and is audited). */
|
|
399
432
|
export declare class OrgSettingsService {
|
|
400
433
|
private readonly db;
|
|
401
434
|
readonly txHost: TransactionHost;
|
|
402
435
|
private readonly orgLock;
|
|
403
436
|
/**
|
|
404
|
-
* The deployment config: `sandbox.limits` and the platform's
|
|
405
|
-
* (`devices.
|
|
437
|
+
* The deployment config: `sandbox.limits` and the platform's device sandbox settings
|
|
438
|
+
* (`devices.outsideSandbox`, `devices.network`; the org may follow them, never exceed them).
|
|
406
439
|
*/
|
|
407
440
|
private readonly config;
|
|
408
441
|
private readonly ceilings;
|
|
409
442
|
private readonly log?;
|
|
410
443
|
constructor(db: KernelDb, txHost: TransactionHost, orgLock: OrgLock,
|
|
411
444
|
/**
|
|
412
|
-
* The deployment config: `sandbox.limits` and the platform's
|
|
413
|
-
* (`devices.
|
|
445
|
+
* The deployment config: `sandbox.limits` and the platform's device sandbox settings
|
|
446
|
+
* (`devices.outsideSandbox`, `devices.network`; the org may follow them, never exceed them).
|
|
414
447
|
*/
|
|
415
448
|
config: Pick<KernelConfigService, "get" | "fieldSource">, ceilings: PermissionCeilingWrites, log?: KernelLogger | undefined);
|
|
416
|
-
/** Parses stored settings, warning when an invalid `
|
|
417
|
-
* `
|
|
449
|
+
/** Parses stored settings, warning when an invalid `outsideSandbox` narrows to `off`, an
|
|
450
|
+
* invalid `deviceNetwork` to an empty allowlist, or a security setting reads narrower
|
|
418
451
|
* ({@link logUnreadableSecuritySettings}, warn). */
|
|
419
452
|
private parseStored;
|
|
420
|
-
/**
|
|
453
|
+
/** The deployment defaults (what "follow the platform" means on the settings page). */
|
|
421
454
|
deployment(): Promise<OrgSettingsDeployment>;
|
|
422
455
|
/** Whether prompt suggestions run for the org now: one read of the platform and of the org. */
|
|
423
456
|
promptSuggestionsEnabled(orgId: string): Promise<boolean>;
|
|
424
457
|
/**
|
|
425
|
-
* The org's effective sandbox
|
|
426
|
-
*
|
|
458
|
+
* The org's effective sandbox network (spec §D3): its mode and the hosts, from the platform's
|
|
459
|
+
* `sandbox.limits` and the org's stored delta.
|
|
427
460
|
*/
|
|
428
|
-
effectiveNetwork(settings: Pick<OrgSettings, "
|
|
461
|
+
effectiveNetwork(settings: Pick<OrgSettings, "deviceNetwork">): OrgEffectiveNetwork;
|
|
429
462
|
/** 组织实际生效的沙箱 cpu / 内存(只读;由超级管理员在部署设置里覆盖)。 */
|
|
430
463
|
sandboxLimits(orgId: string): Promise<OrgSandboxLimits>;
|
|
431
464
|
get(orgId: string): Promise<OrgSettingsView>;
|
|
432
465
|
/**
|
|
433
466
|
* The refusals of {@link update} that need no read of the org (the Platform tool's precheck):
|
|
434
|
-
*
|
|
467
|
+
* running outside the sandbox where the platform turned it off, a network default or ceiling
|
|
468
|
+
* above the platform's ceiling, external sharing where the platform denies it.
|
|
435
469
|
*/
|
|
436
470
|
check(patch: OrgSettingsPatch): Promise<void>;
|
|
437
471
|
/**
|
|
438
|
-
* Under `sandbox.limits.orgHosts: within` (spec §D2), refuses
|
|
439
|
-
*
|
|
440
|
-
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
472
|
+
* Under `sandbox.limits.orgHosts: within` (spec §D2), refuses an extra host outside the
|
|
473
|
+
* platform's allowlist that the org did not store. Stored values are sent back as they are (the
|
|
474
|
+
* PATCH replaces `deviceNetwork` whole) and have no effect under the ceiling (they are filtered on
|
|
475
|
+
* read), so they never block a write. Whether the network may be open is the network ceiling's
|
|
476
|
+
* (`devices.network.ceiling`, {@link check}), not `orgHosts`'.
|
|
443
477
|
*/
|
|
444
478
|
assertWithinCeiling(before: OrgSettings, patch: OrgSettingsPatch): void;
|
|
445
479
|
update(orgId: string, patch: OrgSettingsPatch, actorAccountId: string, actorTokenId?: string,
|
|
446
480
|
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
447
481
|
auditDetail?: Record<string, unknown>,
|
|
448
482
|
/**
|
|
449
|
-
* `onlyNarrows` (the Platform tool, API tokens): refuse
|
|
483
|
+
* `onlyNarrows` (the Platform tool, API tokens): refuse an `outsideSandbox`, `deviceNetwork` or
|
|
450
484
|
* `externalSharing` change that widens (see {@link assertOnlyNarrows}); only a person in a
|
|
451
485
|
* session widens.
|
|
452
486
|
*/
|
|
@@ -455,13 +489,16 @@ export declare class OrgSettingsService {
|
|
|
455
489
|
}): Promise<OrgSettingsView>;
|
|
456
490
|
private lockFor;
|
|
457
491
|
/**
|
|
458
|
-
* Refuses a patch that widens the org's sandbox (
|
|
459
|
-
*
|
|
460
|
-
* - `
|
|
461
|
-
* platform); clearing it follows the platform too, never wider than the platform allows
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
492
|
+
* Refuses a patch that widens the org's sandbox (only a person widens it, never the Platform tool
|
|
493
|
+
* or an API token):
|
|
494
|
+
* - `outsideSandbox`: `allowed` where the organization runs `off` (an absent value follows the
|
|
495
|
+
* platform); clearing it follows the platform too, never wider than the platform allows
|
|
496
|
+
* (`org.outside_sandbox_not_allowed`);
|
|
497
|
+
* - `deviceNetwork`: compared as stored deltas, never as effective values (under the kill switch
|
|
498
|
+
* or a platform ceiling the effective values hide a widening that takes effect when the
|
|
499
|
+
* platform relaxes, org egress ceiling spec §D3): a default or ceiling opened
|
|
500
|
+
* ({@link deviceNetworkModeWidens}, `org.network_not_allowed`) or wider hosts
|
|
501
|
+
* ({@link deviceNetworkHostsWiden}, `org.sandbox_egress_not_allowed`);
|
|
465
502
|
* - `externalSharing`: `on` where the org is off (absent = off).
|
|
466
503
|
*/
|
|
467
504
|
assertOnlyNarrows(before: OrgSettings, patch: OrgSettingsPatch): Promise<void>;
|
|
@@ -469,7 +506,7 @@ export declare class OrgSettingsService {
|
|
|
469
506
|
}
|
|
470
507
|
/**
|
|
471
508
|
* The one {@link OrgSettingsService}: the orgs module re-exports it, and the catalog imports it
|
|
472
|
-
* directly (approving a network request writes the org's
|
|
509
|
+
* directly (approving a network request writes the org's device network) without a cycle through
|
|
473
510
|
* OrgsModule.
|
|
474
511
|
*/
|
|
475
512
|
export declare class OrgSettingsModule {
|