@capybara-hq/kernel 0.1.0-rc.66 → 0.1.0-rc.67
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/bootstrap.json +0 -8
- package/dist/admin/admin.schemas.d.ts +3 -0
- package/dist/agents/admin-agents.d.ts +2 -2
- package/dist/agents/admin-agents.js +2 -1
- package/dist/agents/agent-lookup.js +2 -1
- package/dist/agents/agent-profile.service.d.ts +5 -2
- package/dist/agents/agent-profile.service.js +13 -2
- package/dist/agents/agents.controller.d.ts +4 -3
- package/dist/agents/agents.controller.js +7 -3
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.schemas.d.ts +6 -6
- package/dist/agents/agents.service.d.ts +23 -2
- package/dist/agents/agents.service.js +61 -6
- package/dist/agents/avatar-view.d.ts +8 -0
- package/dist/agents/avatar-view.js +12 -0
- package/dist/agents/profile.d.ts +38 -13
- package/dist/agents/profile.js +31 -20
- package/dist/background/poll.job.d.ts +1 -1
- package/dist/background/poll.job.js +8 -6
- package/dist/background/tasks.service.js +1 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/inbound.d.ts +2 -3
- package/dist/channels/inbound.js +2 -3
- package/dist/channels/phrases.d.ts +3 -3
- package/dist/channels/phrases.js +3 -3
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +14 -1
- package/dist/conversations/conversations.service.d.ts +4 -3
- package/dist/conversations/conversations.service.js +4 -2
- package/dist/ctx/create-ctx.js +5 -2
- package/dist/ctx/device-provider-check.d.ts +7 -0
- package/dist/ctx/device-provider-check.js +21 -0
- package/dist/db/kernel-schema.d.ts +7 -0
- package/dist/devices/access.d.ts +16 -46
- package/dist/devices/access.js +26 -62
- package/dist/devices/access.module.js +2 -2
- package/dist/devices/conversation-devices.d.ts +38 -18
- package/dist/devices/conversation-devices.js +69 -51
- package/dist/devices/default-provider-setting.d.ts +45 -0
- package/dist/devices/default-provider-setting.js +59 -0
- package/dist/devices/device-projects.service.js +7 -2
- package/dist/devices/device-provider-selection.d.ts +37 -0
- package/dist/devices/device-provider-selection.js +86 -0
- package/dist/devices/device-provider-selection.module.d.ts +3 -0
- package/dist/devices/device-provider-selection.module.js +22 -0
- package/dist/devices/devices.controller.d.ts +8 -5
- package/dist/devices/devices.controller.js +7 -4
- package/dist/devices/devices.module.js +3 -1
- package/dist/devices/devices.schemas.js +2 -2
- package/dist/devices/devices.service.d.ts +72 -83
- package/dist/devices/devices.service.js +139 -248
- package/dist/devices/dto.d.ts +9 -0
- package/dist/devices/dto.js +15 -2
- package/dist/devices/label.d.ts +3 -5
- package/dist/devices/label.js +3 -14
- package/dist/devices/legacy-cleanup.job.d.ts +2 -2
- package/dist/devices/legacy-cleanup.job.js +6 -6
- package/dist/errors.d.ts +15 -1
- package/dist/errors.js +15 -1
- package/dist/extensions/guide-places.d.ts +2 -1
- package/dist/extensions/guide-places.js +8 -2
- package/dist/extensions/locks.d.ts +1 -1
- package/dist/extensions/locks.js +1 -1
- package/dist/extensions/org-config.d.ts +20 -4
- package/dist/extensions/org-config.js +23 -6
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/permission-view.js +2 -2
- package/dist/extensions/plugin-guides.d.ts +1 -1
- package/dist/extensions/plugin-guides.js +11 -3
- package/dist/extensions/point-defaults.d.ts +14 -0
- package/dist/extensions/point-defaults.js +70 -47
- package/dist/extensions/resolve.js +7 -2
- package/dist/identity/settings.d.ts +8 -0
- package/dist/identity/settings.js +24 -1
- package/dist/infra/config/kernel-config.service.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.js +7 -6
- package/dist/local-devices/device-routes.d.ts +1 -1
- package/dist/local-devices/device-routes.js +1 -1
- package/dist/local-devices/local-device-provider.d.ts +14 -11
- package/dist/local-devices/local-device-provider.js +14 -0
- package/dist/local-devices/local-devices.module.d.ts +4 -4
- package/dist/local-devices/local-devices.module.js +5 -3
- package/dist/local-devices/owner-report.js +2 -1
- package/dist/local-devices/targets.d.ts +2 -0
- package/dist/local-devices/targets.js +10 -0
- package/dist/orgs/settings.service.d.ts +26 -1
- package/dist/orgs/settings.service.js +44 -3
- package/dist/platform/ops/admin.ops.js +8 -3
- package/dist/platform/ops/agents.ops.d.ts +6 -1
- package/dist/platform/ops/agents.ops.js +38 -11
- package/dist/platform/ops/devices.ops.js +25 -20
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/themes.ops.js +1 -1
- package/dist/runtime/plugin-context.service.js +1 -12
- package/dist/sandbox/cloud-permission-snapshot.d.ts +2 -2
- package/dist/sandbox/cloud-permission-snapshot.js +3 -3
- package/dist/sandbox/device-reports.d.ts +50 -0
- package/dist/sandbox/device-reports.js +157 -0
- package/dist/sandbox/held-operations.d.ts +8 -8
- package/dist/sandbox/leases.d.ts +1 -1
- package/dist/sandbox/leases.js +1 -1
- package/dist/sandbox/operation-authority.d.ts +5 -2
- package/dist/sandbox/operation-authority.js +12 -11
- package/dist/sandbox/operation-reconcile.job.d.ts +2 -2
- package/dist/sandbox/operation-reconcile.job.js +5 -5
- package/dist/sandbox/permission-availability.d.ts +2 -2
- package/dist/sandbox/permission-call-types.d.ts +5 -0
- package/dist/sandbox/permission-facts.d.ts +2 -2
- package/dist/sandbox/permission-facts.js +5 -5
- package/dist/sandbox/providers.d.ts +23 -24
- package/dist/sandbox/providers.js +38 -46
- package/dist/sandbox/providers.module.js +3 -3
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +7 -2
- package/dist/sandbox/sandbox.service.d.ts +95 -68
- package/dist/sandbox/sandbox.service.js +212 -208
- package/dist/setup/setup-guides.service.d.ts +4 -1
- package/dist/setup/setup-guides.service.js +6 -1
- package/dist/themes/avatar-preset-key.d.ts +6 -0
- package/dist/themes/avatar-preset-key.js +9 -0
- package/dist/themes/theme-state.d.ts +29 -1
- package/dist/themes/theme-state.js +40 -1
- package/dist/themes/themes.service.d.ts +28 -1
- package/dist/themes/themes.service.js +36 -2
- package/dist/tools/builtins/image/generate.d.ts +3 -0
- package/dist/tools/builtins/image/generate.js +21 -11
- package/dist/tools/builtins/image/index.d.ts +1 -1
- package/dist/tools/builtins/image/index.js +1 -1
- package/dist/tools/builtins/sandbox/common.d.ts +36 -12
- package/dist/tools/builtins/sandbox/common.js +62 -18
- package/dist/tools/builtins/sandbox/read.d.ts +5 -2
- package/dist/tools/builtins/sandbox/read.js +9 -6
- package/dist/tools/builtins/sandbox/task-output.d.ts +2 -2
- package/dist/tools/builtins/sandbox/task-output.js +6 -5
- package/dist/tools/builtins/skill-load.js +13 -4
- package/dist/until-aborted.d.ts +5 -0
- package/dist/until-aborted.js +16 -0
- package/package.json +4 -4
- package/src/migrations/0176_device_report.sql +6 -0
|
@@ -4,15 +4,18 @@ import { type Principal } from "../identity/principal.js";
|
|
|
4
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
5
|
import { type DeviceProjectCandidates, type DeviceProjectList, DeviceProjectsService, type DeviceProjectView } from "./device-projects.service.js";
|
|
6
6
|
import { type DeviceList, DevicesService, type DeviceView } from "./devices.service.js";
|
|
7
|
-
import { type
|
|
7
|
+
import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type DevicePolicyBody, type DeviceProjectAddBody, type DeviceProjectParams } from "./dto.js";
|
|
8
8
|
/**
|
|
9
9
|
* A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
|
|
10
10
|
* 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
|
|
11
11
|
* Phase 1 has personal cloud devices only, each visible to its owner alone: another member
|
|
12
12
|
* gets 404 `device.not_found`.
|
|
13
|
-
* - `GET /` → `{ items, defaultId, lastUsedId,
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* - `GET /` → `{ items, defaultId, lastUsedId, providers, defaultProvider }` (`providers`: the
|
|
14
|
+
* device providers on in the org, `{ plugin, displayName }`; `defaultProvider`: the one a device
|
|
15
|
+
* gets when none is named, null when none serves the org);
|
|
16
|
+
* - `POST / { name, provider? }` → 201 `{ device }`, bound for life to `provider` (one of
|
|
17
|
+
* `providers`, else 400 `validation_failed` at `provider`) or the default provider (none: 400
|
|
18
|
+
* `device.provider_required`); `GET /:id` → `{ device }`;
|
|
16
19
|
* - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets a cloud device's sandbox
|
|
17
20
|
* network (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design,
|
|
18
21
|
* "Settings model") within its org's and the platform's ceilings (400
|
|
@@ -43,7 +46,7 @@ export declare class DevicesController {
|
|
|
43
46
|
private readonly projects;
|
|
44
47
|
constructor(devices: DevicesService, projects: DeviceProjectsService);
|
|
45
48
|
list(principal: Principal, org: OrgContext): Promise<DeviceList>;
|
|
46
|
-
create(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
49
|
+
create(principal: Principal, org: OrgContext, body: z.infer<typeof DeviceCreateBody>): Promise<{
|
|
47
50
|
device: DeviceView;
|
|
48
51
|
}>;
|
|
49
52
|
get(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<{
|
|
@@ -19,9 +19,12 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyB
|
|
|
19
19
|
* 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
|
|
20
20
|
* Phase 1 has personal cloud devices only, each visible to its owner alone: another member
|
|
21
21
|
* gets 404 `device.not_found`.
|
|
22
|
-
* - `GET /` → `{ items, defaultId, lastUsedId,
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* - `GET /` → `{ items, defaultId, lastUsedId, providers, defaultProvider }` (`providers`: the
|
|
23
|
+
* device providers on in the org, `{ plugin, displayName }`; `defaultProvider`: the one a device
|
|
24
|
+
* gets when none is named, null when none serves the org);
|
|
25
|
+
* - `POST / { name, provider? }` → 201 `{ device }`, bound for life to `provider` (one of
|
|
26
|
+
* `providers`, else 400 `validation_failed` at `provider`) or the default provider (none: 400
|
|
27
|
+
* `device.provider_required`); `GET /:id` → `{ device }`;
|
|
25
28
|
* - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets a cloud device's sandbox
|
|
26
29
|
* network (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design,
|
|
27
30
|
* "Settings model") within its org's and the platform's ceilings (400
|
|
@@ -61,7 +64,7 @@ let DevicesController = class DevicesController {
|
|
|
61
64
|
async create(principal, org, body) {
|
|
62
65
|
const p = requireUser(principal);
|
|
63
66
|
return {
|
|
64
|
-
device: await this.devices.create(org.orgId, p.account.id, { name: body.name }, patTokenId(p)),
|
|
67
|
+
device: await this.devices.create(org.orgId, p.account.id, { name: body.name, ...(body.provider !== undefined && { provider: body.provider }) }, patTokenId(p)),
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
70
|
async get(principal, org, params) {
|
|
@@ -14,6 +14,7 @@ import { DeviceAccess } from "./access.js";
|
|
|
14
14
|
import { DeviceAccessModule } from "./access.module.js";
|
|
15
15
|
import { ConversationDevices } from "./conversation-devices.js";
|
|
16
16
|
import { DeviceProjectsService } from "./device-projects.service.js";
|
|
17
|
+
import { DeviceProviderSelectionModule } from "./device-provider-selection.module.js";
|
|
17
18
|
import { DevicesService } from "./devices.service.js";
|
|
18
19
|
/**
|
|
19
20
|
* Devices (spec 2026-11-07-environments-design): a person's devices
|
|
@@ -25,13 +26,14 @@ let DevicesModule = class DevicesModule {
|
|
|
25
26
|
};
|
|
26
27
|
DevicesModule = __decorate([
|
|
27
28
|
Module({
|
|
28
|
-
// ExtensionsModule: the provider display names
|
|
29
|
+
// ExtensionsModule: the provider display names; LocalDevicesModule: deleting
|
|
29
30
|
// a local device revokes its machine
|
|
30
31
|
imports: [
|
|
31
32
|
SandboxModule,
|
|
32
33
|
ExtensionsModule,
|
|
33
34
|
LocalDevicesModule,
|
|
34
35
|
DeviceAccessModule,
|
|
36
|
+
DeviceProviderSelectionModule,
|
|
35
37
|
PermissionFactsModule,
|
|
36
38
|
],
|
|
37
39
|
// SandboxFileReader lives here, not in SandboxModule: it needs ConversationDevices, and this
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeviceCreateBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody, DeviceProjectParams, } from "./dto.js";
|
|
2
2
|
/** The body of the excluded `POST /devices/:id/policy` route (human-only). */
|
|
3
3
|
export { DevicePolicyBody } from "./dto.js";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export { DevicePolicyBody } from "./dto.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export const DEVICE_ROUTES = [
|
|
12
12
|
{ route: "GET /api/v1/orgs/:orgId/devices" },
|
|
13
|
-
{ route: "POST /api/v1/orgs/:orgId/devices", body:
|
|
13
|
+
{ route: "POST /api/v1/orgs/:orgId/devices", body: DeviceCreateBody },
|
|
14
14
|
{ route: "GET /api/v1/orgs/:orgId/devices/:id", params: DeviceParams },
|
|
15
15
|
{
|
|
16
16
|
route: "PATCH /api/v1/orgs/:orgId/devices/:id",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeviceLocalPolicySummary, LocalizedName, SandboxBrowseScope, SandboxLimits, SandboxOperationScope } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import type { DeviceLocalPolicySummary, DeviceReport, LocalizedName, SandboxBrowseScope, SandboxLimits, SandboxOperationScope } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { type Selectable } from "kysely";
|
|
3
3
|
import type { SandboxOperationIntentsTable } from "../db/kernel-schema.js";
|
|
4
4
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
@@ -12,41 +12,32 @@ import { DevicePolicyService } from "../local-devices/device-policy.service.js";
|
|
|
12
12
|
import { MachinesService } from "../local-devices/machines.js";
|
|
13
13
|
import { type OwnerFacts } from "../local-devices/owner-report.js";
|
|
14
14
|
import type { DeviceModeLevel } from "../runtime/context/device-paths.js";
|
|
15
|
+
import { DeviceReports } from "../sandbox/device-reports.js";
|
|
15
16
|
import type { DeviceSandbox, DeviceSandboxLayer, HostGrantCeiling } from "../sandbox/device-sandbox.js";
|
|
16
17
|
import { SandboxJobs } from "../sandbox/jobs.js";
|
|
17
18
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
18
19
|
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
19
|
-
import { SandboxProviders } from "../sandbox/providers.js";
|
|
20
20
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
21
21
|
import { DeviceAccess } from "./access.js";
|
|
22
|
+
import { DeviceProviderSelection } from "./device-provider-selection.js";
|
|
22
23
|
/** A device as its owner sees it (`GET /orgs/:orgId/devices`). */
|
|
23
24
|
export interface DeviceView {
|
|
24
25
|
id: string;
|
|
25
|
-
/**
|
|
26
|
-
* null for the default device (shown as 「个人设备」 / "Personal") and for a demoted default
|
|
27
|
-
* (shown as 「个人设备(Docker 沙箱)」 / "Personal (Docker sandbox)", from {@link demotedFrom}).
|
|
28
|
-
*/
|
|
26
|
+
/** null for the default device (shown as the localized "Personal"). */
|
|
29
27
|
name: string | null;
|
|
30
28
|
isDefault: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* A former default demoted by a sandbox provider switch (spec §4.2 item 13): the provider it was
|
|
33
|
-
* demoted from, that extension's display name (null when it has none, e.g. uninstalled: show the
|
|
34
|
-
* id), and its place among the person's unnamed former defaults of that provider (1, 2, … by
|
|
35
|
-
* creation; a label shows " 2", " 3", … after the first). Switching back to that provider makes
|
|
36
|
-
* it the default again. null for every other device.
|
|
37
|
-
*/
|
|
38
|
-
demotedFrom: {
|
|
39
|
-
provider: string;
|
|
40
|
-
displayName: LocalizedName | null;
|
|
41
|
-
ordinal: number;
|
|
42
|
-
} | null;
|
|
43
29
|
ownerKind: "personal";
|
|
44
30
|
/** `local`: a machine connected with capybara-device (provider `@local`). */
|
|
45
31
|
source: "cloud" | "local";
|
|
46
|
-
/** The provider
|
|
32
|
+
/** The provider it is bound to for life (`devices.provider`). */
|
|
47
33
|
provider: string | null;
|
|
48
|
-
/** Its provider
|
|
34
|
+
/** Its provider serves the org now (on in the org; `@local`: registered). */
|
|
49
35
|
available: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* What its provider last reported about it (`devices.report`, the stored copy: never asked on
|
|
38
|
+
* the request path); null until a first report is stored. Kept while the provider is off.
|
|
39
|
+
*/
|
|
40
|
+
report: DeviceReport | null;
|
|
50
41
|
/** A local device: some replica holds its machine's connection now; null for cloud. */
|
|
51
42
|
online: boolean | null;
|
|
52
43
|
/** A local device's connected machine (its unrevoked one); null for cloud or none. */
|
|
@@ -238,16 +229,28 @@ export interface DeviceMachineView {
|
|
|
238
229
|
/** The list response: the person's live devices in the org. */
|
|
239
230
|
export interface DeviceList {
|
|
240
231
|
items: DeviceView[];
|
|
241
|
-
/** The person's default device; null when there is none (no
|
|
232
|
+
/** The person's default device; null when there is none (no default provider to make it). */
|
|
242
233
|
defaultId: string | null;
|
|
243
234
|
/** The device of the person's most recently updated conversation that has a live one. */
|
|
244
235
|
lastUsedId: string | null;
|
|
245
|
-
/**
|
|
246
|
-
|
|
236
|
+
/** The device providers on in the org now (a new device may name one), in name order. */
|
|
237
|
+
providers: DeviceProviderOption[];
|
|
238
|
+
/**
|
|
239
|
+
* The provider a new device gets when it names none: the org's (else the platform's) default,
|
|
240
|
+
* null when that serves the org no more or none is set (never another provider in its place).
|
|
241
|
+
*/
|
|
242
|
+
defaultProvider: string | null;
|
|
243
|
+
}
|
|
244
|
+
/** A device provider a new device may be created on ({@link DeviceList.providers}). */
|
|
245
|
+
export interface DeviceProviderOption {
|
|
246
|
+
plugin: string;
|
|
247
|
+
/** The extension's display name; null when it has none. */
|
|
248
|
+
displayName: LocalizedName | null;
|
|
247
249
|
}
|
|
248
250
|
/**
|
|
249
251
|
* Personal devices (spec 2026-11-07-environments-design §4.2 items 7, 12, 13; §6; §9):
|
|
250
|
-
* cloud ones
|
|
252
|
+
* cloud ones, each bound for life to the device provider it was created on (device-provider spec
|
|
253
|
+
* §6.1), and `local` ones on a connected machine; a
|
|
251
254
|
* person's devices in an org, visible and usable only by their owner (anyone else gets
|
|
252
255
|
* `device.not_found`). Deleting one soft-deletes it and owes the destruction of its instance and
|
|
253
256
|
* files (a `sandbox-destroy-for` job) in the same transaction.
|
|
@@ -256,62 +259,79 @@ export declare class DevicesService {
|
|
|
256
259
|
private readonly db;
|
|
257
260
|
readonly txHost: TransactionHost;
|
|
258
261
|
private readonly config;
|
|
259
|
-
private readonly
|
|
262
|
+
private readonly selection;
|
|
260
263
|
private readonly sandbox;
|
|
261
264
|
private readonly sandboxJobs;
|
|
262
265
|
/** Owes a deleted device's destruction in the delete's transaction. */
|
|
263
266
|
private readonly outbox;
|
|
264
267
|
private readonly access;
|
|
265
|
-
private readonly displayNames;
|
|
266
268
|
/** Reads the device relay's lease (`online`). */
|
|
267
269
|
private readonly locks;
|
|
268
270
|
private readonly machines;
|
|
269
271
|
private readonly policies;
|
|
270
272
|
private readonly ceilings;
|
|
271
273
|
private readonly facts;
|
|
272
|
-
|
|
274
|
+
private readonly displayNames;
|
|
275
|
+
/** Each device's stored provider report (read only; never asks the provider). */
|
|
276
|
+
private readonly reports;
|
|
277
|
+
constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get" | "fieldSource">, selection: Pick<DeviceProviderSelection, "onInOrg" | "isOnInOrg" | "defaultFor">, sandbox: Pick<SandboxService, "devicePolicy" | "deviceLimits" | "limitsState">, sandboxJobs: Pick<SandboxJobs, "resetFiles">,
|
|
273
278
|
/** Owes a deleted device's destruction in the delete's transaction. */
|
|
274
|
-
outbox: Pick<OutboxService, "add">, access: Pick<DeviceAccess, "usable">,
|
|
279
|
+
outbox: Pick<OutboxService, "add">, access: Pick<DeviceAccess, "usable">,
|
|
275
280
|
/** Reads the device relay's lease (`online`). */
|
|
276
|
-
locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">, policies: Pick<DevicePolicyService, "apply" | "summary">, ceilings: PermissionCeilingWrites, facts: Pick<PermissionFacts, "deviceSandbox" | "deviceSandboxFacts"
|
|
281
|
+
locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">, policies: Pick<DevicePolicyService, "apply" | "summary">, ceilings: PermissionCeilingWrites, facts: Pick<PermissionFacts, "deviceSandbox" | "deviceSandboxFacts">, displayNames: Pick<ExtensionDisplayNames, "many">,
|
|
282
|
+
/** Each device's stored provider report (read only; never asks the provider). */
|
|
283
|
+
reports: Pick<DeviceReports, "read">);
|
|
277
284
|
/**
|
|
278
|
-
* The person's live devices in the org, the default first, then by creation
|
|
279
|
-
*
|
|
280
|
-
* spec §4.2 item 7; an existing one
|
|
285
|
+
* The person's live devices in the org, the default first, then by creation, with the device
|
|
286
|
+
* providers on in the org and its default one. With a default provider serving the org the
|
|
287
|
+
* default device is created first if missing (its first need, spec §4.2 item 7; an existing one
|
|
288
|
+
* is only read, whatever its provider's state).
|
|
281
289
|
*/
|
|
282
290
|
list(orgId: string, accountId: string): Promise<DeviceList>;
|
|
283
291
|
/** One of the person's live devices; anyone else's (or a missing one) → `not_found`. */
|
|
284
292
|
get(orgId: string, accountId: string, id: string): Promise<DeviceView>;
|
|
285
293
|
/**
|
|
286
|
-
* A new personal cloud device, ready at once (its instance and files are made on first
|
|
287
|
-
*
|
|
288
|
-
* (
|
|
294
|
+
* A new personal cloud device, ready at once (its instance and files are made on first use),
|
|
295
|
+
* bound for life to `input.provider` or, without one, the org's default provider: a provider not
|
|
296
|
+
* on in the org (unknown, not loaded, off, kernel-internal) → `validation_failed` at `provider`;
|
|
297
|
+
* none named and no default serving the org → `device.provider_required`. A live name of the
|
|
298
|
+
* person's (case-insensitive) → `device.name_taken`; `devices.maxPersonal` live ones (the
|
|
289
299
|
* default counts) → `device.limit_reached`. Serialized per person by their membership row.
|
|
300
|
+
* Nothing is written before every refusal is past.
|
|
290
301
|
*/
|
|
291
302
|
create(orgId: string, accountId: string, input: {
|
|
292
303
|
name: string;
|
|
304
|
+
provider?: string;
|
|
293
305
|
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<DeviceView>;
|
|
306
|
+
/**
|
|
307
|
+
* The provider a new cloud device of `orgId` is bound to: `named` when it serves the org now
|
|
308
|
+
* (one of {@link DeviceProviderSelection.onInOrg}), else the org's default
|
|
309
|
+
* ({@link DeviceProviderSelection.defaultFor}) when none is named; never another one.
|
|
310
|
+
*/
|
|
311
|
+
private providerFor;
|
|
294
312
|
private insert;
|
|
295
313
|
/**
|
|
296
314
|
* A new personal local device for a machine being connected (provider `@local`; the
|
|
297
315
|
* machine row is the caller's). Joins the caller's transaction (the device authorization's).
|
|
298
316
|
* Counted against `devices.maxPersonal` (`device.limit_reached`); a live name of the
|
|
299
|
-
* person's → `device.name_taken`. Needs no
|
|
317
|
+
* person's → `device.name_taken`. Needs no device provider on in the org.
|
|
300
318
|
*/
|
|
301
319
|
createLocal(orgId: string, accountId: string, name: string): Promise<{
|
|
302
320
|
id: string;
|
|
303
321
|
}>;
|
|
304
322
|
/**
|
|
305
323
|
* Inserts a named personal device under the person's membership lock, after the limit
|
|
306
|
-
* and name checks, and audits `device.created
|
|
324
|
+
* and name checks, and audits `device.created` (with its provider). Runs in the caller's
|
|
325
|
+
* transaction.
|
|
307
326
|
*/
|
|
308
327
|
private insertNamed;
|
|
309
328
|
/**
|
|
310
329
|
* The refusals {@link create} would raise, read without locks or writes (a precheck before a
|
|
311
|
-
* confirmation card):
|
|
312
|
-
* same {@link ApiError}s; a race still ends in
|
|
330
|
+
* confirmation card): the provider (named and not on in the org, or none and no default), the
|
|
331
|
+
* person's limit, a name already taken. Throws the same {@link ApiError}s; a race still ends in
|
|
332
|
+
* `create`'s own refusal.
|
|
313
333
|
*/
|
|
314
|
-
checkCreate(orgId: string, accountId: string, name: string): Promise<void>;
|
|
334
|
+
checkCreate(orgId: string, accountId: string, name: string, provider?: string): Promise<void>;
|
|
315
335
|
/** How many of the person's conversations work in the device (read only). */
|
|
316
336
|
boundConversations(orgId: string, accountId: string, id: string): Promise<number>;
|
|
317
337
|
/**
|
|
@@ -437,46 +457,20 @@ export declare class DevicesService {
|
|
|
437
457
|
/** The check and audit row of {@link resetFiles}, committed before the job is enqueued. */
|
|
438
458
|
private recordReset;
|
|
439
459
|
/**
|
|
440
|
-
* The person's default device in the org
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
* Its replacement is the person's former default demoted from the current provider when there
|
|
446
|
-
* is one (switching back restores it, with its files), else a fresh default. A live default
|
|
447
|
-
* not in use yet (no healthy files, no instance, none being created: {@link inUseForDefault})
|
|
448
|
-
* is likewise swapped for a former default holding healthy files at the current provider; it is
|
|
449
|
-
* demoted (from the provider it was made under) so it can come back in turn. A former default
|
|
450
|
-
* belongs to the provider holding its resources once it holds any, else to the one it was
|
|
451
|
-
* demoted from ({@link demotedProvider}), so one swapped out empty and used afterwards is
|
|
452
|
-
* labelled and restored by where its files are.
|
|
453
|
-
* All of it in one transaction: switching back and forth never adds devices.
|
|
460
|
+
* The person's default device in the org: the live one if any, whatever its provider's state
|
|
461
|
+
* (a default whose provider is off stays the default, unavailable, never demoted or replaced),
|
|
462
|
+
* else a new default (named by the UI, `name` NULL) bound to the org's default provider
|
|
463
|
+
* ({@link DeviceProviderSelection.defaultFor}), else null (no default provider on in the org).
|
|
464
|
+
* An existing one is read without locking.
|
|
454
465
|
*
|
|
455
|
-
*
|
|
466
|
+
* Creating one first takes the person's membership row (`FOR SHARE`, after the org row), so an
|
|
456
467
|
* offboarding that removes them cannot leave a live default behind; not a member (any more) →
|
|
457
|
-
* `org.not_found`. Idempotent under concurrency: the
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
* the select that follows reads the winner. Needs a current sandbox provider
|
|
461
|
-
* (`device.unavailable`). It is the person's baseline, so it is created even at
|
|
462
|
-
* `devices.maxPersonal`.
|
|
463
|
-
*/
|
|
464
|
-
ensureDefault(orgId: string, accountId: string): Promise<string>;
|
|
465
|
-
private insertDefault;
|
|
466
|
-
/**
|
|
467
|
-
* Turns the live default into an ordinary device marked as demoted from `provider`; a name
|
|
468
|
-
* the person gave it stays. Runs under the person's membership lock and the default row's lock,
|
|
469
|
-
* before any other row becomes the default (the partial unique index).
|
|
468
|
+
* `org.not_found`. Idempotent under concurrency: the partial unique index on the live default
|
|
469
|
+
* makes a racing insert do nothing, and the select that follows reads the winner. It is the
|
|
470
|
+
* person's baseline, so it is created even at `devices.maxPersonal`.
|
|
470
471
|
*/
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
* The person's live former defaults of `provider` ({@link demotedProvider}: files or an instance
|
|
474
|
-
* kept by `provider`, or none and demoted from it), the ones holding healthy files first (lost
|
|
475
|
-
* files count as none), then the most recently used, then the most recently demoted. `lock`
|
|
476
|
-
* takes their rows (`FOR NO KEY UPDATE`, in id order, so racing replacements queue on the same
|
|
477
|
-
* rows).
|
|
478
|
-
*/
|
|
479
|
-
private formerDefaults;
|
|
472
|
+
ensureDefault(orgId: string, accountId: string): Promise<string | null>;
|
|
473
|
+
private insertDefault;
|
|
480
474
|
/**
|
|
481
475
|
* The person's IM default (what `/device` set): the device their next new IM conversation
|
|
482
476
|
* uses. Null when none was set, or the chosen one is deleted (the row is cleared with it).
|
|
@@ -490,13 +484,8 @@ export declare class DevicesService {
|
|
|
490
484
|
* `deleted_at IS NULL`).
|
|
491
485
|
*/
|
|
492
486
|
setImDefault(orgId: string, accountId: string, deviceId: string): Promise<void>;
|
|
493
|
-
/**
|
|
494
|
-
* The person's live default device in the org, if any, with what decides its provider;
|
|
495
|
-
* `lock` takes its row (`FOR NO KEY UPDATE`; a racing demotion makes it read none).
|
|
496
|
-
*/
|
|
487
|
+
/** The person's live default device in the org, if any. */
|
|
497
488
|
private defaultOf;
|
|
498
|
-
/** Its files or instance are kept by a provider that is not the current one. */
|
|
499
|
-
private stranded;
|
|
500
489
|
/** The person's live devices (or the one `id`) as views. */
|
|
501
490
|
private views;
|
|
502
491
|
/**
|