@capybara-hq/kernel 0.1.0-rc.11 → 0.1.0-rc.13
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 +13 -0
- package/dist/agents/agent-lookup.d.ts +5 -0
- package/dist/agents/agent-lookup.js +15 -0
- package/dist/agents/agents.schemas.d.ts +3 -0
- package/dist/agents/agents.service.js +11 -1
- package/dist/agents/definition.d.ts +1 -0
- package/dist/agents/definition.js +7 -3
- package/dist/agents/org-templates.js +4 -0
- package/dist/agents/pending-connectors.service.js +1 -1
- package/dist/background/background.module.js +2 -2
- package/dist/background/launch-lock.d.ts +1 -1
- package/dist/background/launch-lock.js +1 -1
- package/dist/background/poll.job.d.ts +2 -2
- package/dist/background/poll.job.js +10 -10
- package/dist/background/stop.d.ts +1 -1
- package/dist/background/stop.js +3 -3
- package/dist/background/store.d.ts +5 -5
- package/dist/background/store.js +5 -5
- package/dist/background/tasks.service.d.ts +6 -6
- package/dist/background/tasks.service.js +13 -13
- package/dist/catalog/component-scope.controller.d.ts +18 -6
- package/dist/catalog/component-scope.controller.js +36 -13
- package/dist/catalog/component-scope.service.d.ts +11 -0
- package/dist/catalog/component-scope.service.js +4 -0
- package/dist/catalog/component-state.d.ts +8 -0
- package/dist/catalog/component-state.js +19 -11
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-import.js +4 -1
- package/dist/channels/channels.module.js +2 -2
- package/dist/channels/inbound.d.ts +8 -8
- package/dist/channels/inbound.js +31 -31
- package/dist/channels/phrases.d.ts +27 -27
- package/dist/channels/phrases.js +27 -27
- package/dist/config/docs.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +21 -21
- package/dist/conversations/conversations.controller.d.ts +11 -11
- package/dist/conversations/conversations.controller.js +15 -15
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.schemas.js +1 -1
- package/dist/conversations/conversations.service.d.ts +23 -14
- package/dist/conversations/conversations.service.js +28 -21
- package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
- package/dist/conversations/{environment-status.js → device-status.js} +18 -18
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +1 -1
- package/dist/conversations/events.d.ts +2 -1
- package/dist/conversations/events.js +2 -2
- package/dist/ctx/create-ctx.d.ts +10 -1
- package/dist/ctx/create-ctx.js +86 -25
- package/dist/db/kernel-schema.d.ts +39 -23
- package/dist/{environments → devices}/access.d.ts +19 -19
- package/dist/{environments → devices}/access.js +28 -28
- package/dist/devices/conversation-devices.d.ts +75 -0
- package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
- package/dist/devices/devices.controller.d.ts +36 -0
- package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
- package/dist/devices/devices.module.d.ts +5 -13
- package/dist/devices/devices.module.js +16 -29
- package/dist/devices/devices.schemas.d.ts +3 -0
- package/dist/devices/devices.schemas.js +14 -0
- package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
- package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
- package/dist/devices/dto.d.ts +13 -54
- package/dist/devices/dto.js +7 -39
- package/dist/devices/label.d.ts +11 -0
- package/dist/{environments → devices}/label.js +7 -7
- package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
- package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
- package/dist/errors.d.ts +27 -25
- package/dist/errors.js +27 -25
- package/dist/evals/recorded-tools.d.ts +2 -2
- package/dist/evals/recorded-tools.js +6 -6
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +2 -0
- package/dist/extensions/effective-config.d.ts +6 -0
- package/dist/extensions/effective-config.js +18 -7
- package/dist/extensions/host.d.ts +13 -2
- package/dist/extensions/host.js +24 -3
- package/dist/extensions/instance.d.ts +12 -1
- package/dist/extensions/instance.js +13 -0
- package/dist/extensions/permission-view.d.ts +10 -1
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +1 -1
- package/dist/http/api.module.js +10 -6
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/identity/settings.d.ts +32 -0
- package/dist/identity/settings.js +26 -2
- package/dist/infra/config/kernel-config.service.js +4 -4
- package/dist/kernel.module.js +3 -3
- package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
- package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
- package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
- package/dist/{devices → local-devices}/device-auth.js +51 -53
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/{devices → local-devices}/device-auth.module.js +5 -5
- package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
- package/dist/{devices → local-devices}/device-routes.js +2 -2
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/{devices → local-devices}/keys.d.ts +11 -11
- package/dist/{devices → local-devices}/keys.js +11 -11
- package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
- package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
- package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
- package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
- package/dist/local-devices/local-devices.module.d.ts +16 -0
- package/dist/local-devices/local-devices.module.js +44 -0
- package/dist/{devices → local-devices}/machines.d.ts +26 -26
- package/dist/{devices → local-devices}/machines.js +71 -71
- package/dist/{devices → local-devices}/relay.d.ts +15 -15
- package/dist/{devices → local-devices}/relay.js +55 -55
- package/dist/{devices → local-devices}/targets.d.ts +8 -8
- package/dist/{devices → local-devices}/targets.js +14 -14
- package/dist/orgs/offboarding.d.ts +6 -6
- package/dist/orgs/offboarding.js +12 -12
- package/dist/orgs/settings.service.d.ts +28 -0
- package/dist/orgs/settings.service.js +20 -1
- package/dist/platform/exclusions.js +48 -3
- package/dist/platform/operation.js +6 -2
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/agents.ops.js +19 -6
- package/dist/platform/ops/conversations.ops.d.ts +3 -3
- package/dist/platform/ops/conversations.ops.js +9 -9
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +311 -0
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/platform-ops.module.d.ts +3 -2
- package/dist/platform/platform-ops.module.js +8 -5
- package/dist/platform/route-schemas.js +6 -3
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/roles/worker.module.js +1 -1
- package/dist/runtime/context/build.d.ts +1 -1
- package/dist/runtime/context/build.js +6 -6
- package/dist/runtime/context/compaction.js +1 -1
- package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
- package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
- package/dist/runtime/maintenance.d.ts +1 -1
- package/dist/runtime/subagents/definition.d.ts +3 -2
- package/dist/runtime/subagents/definition.js +2 -1
- package/dist/sandbox/jobs.d.ts +13 -13
- package/dist/sandbox/jobs.js +20 -20
- package/dist/sandbox/leases.d.ts +9 -9
- package/dist/sandbox/leases.js +14 -14
- package/dist/sandbox/providers.d.ts +8 -8
- package/dist/sandbox/providers.js +8 -8
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +76 -76
- package/dist/sandbox/sandbox.service.js +230 -230
- package/dist/tools/builtins/builtin-tools.d.ts +2 -2
- package/dist/tools/builtins/builtin-tools.js +5 -5
- package/dist/tools/builtins/platform.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +6 -6
- package/dist/tools/builtins/sandbox/common.d.ts +25 -25
- package/dist/tools/builtins/sandbox/common.js +51 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
- package/dist/tools/builtins/sandbox/task-output.js +10 -10
- package/dist/tools/builtins/sandbox/task-stop.js +2 -2
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +1 -1
- package/dist/tools/builtins/skill-load.js +2 -2
- package/dist/tools/connector-account-policies.d.ts +51 -0
- package/dist/tools/connector-account-policies.js +165 -0
- package/dist/tools/connectors.controller.d.ts +35 -4
- package/dist/tools/connectors.controller.js +66 -7
- package/dist/tools/connectors.schemas.d.ts +11 -0
- package/dist/tools/connectors.schemas.js +11 -0
- package/dist/tools/connectors.service.d.ts +2 -0
- package/dist/tools/connectors.service.js +1 -0
- package/dist/tools/pipeline.d.ts +1 -1
- package/dist/tools/pipeline.js +4 -3
- package/dist/tools/policy.d.ts +23 -1
- package/dist/tools/policy.js +99 -24
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/tools.module.js +6 -3
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +74 -0
- package/dist/ui/arrangement.js +98 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +29 -14
- package/dist/ui/registry.js +31 -10
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +66 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +84 -18
- package/dist/ui/views.js +201 -38
- package/package.json +3 -3
- package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/dist/devices/device-auth.module.d.ts +0 -7
- package/dist/environments/conversation-environments.d.ts +0 -75
- package/dist/environments/dto.d.ts +0 -25
- package/dist/environments/dto.js +0 -12
- package/dist/environments/environments.controller.d.ts +0 -36
- package/dist/environments/environments.module.d.ts +0 -8
- package/dist/environments/environments.module.js +0 -31
- package/dist/environments/environments.schemas.d.ts +0 -3
- package/dist/environments/environments.schemas.js +0 -14
- package/dist/environments/label.d.ts +0 -11
- package/dist/platform/ops/environments.ops.d.ts +0 -26
- package/dist/platform/ops/environments.ops.js +0 -311
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { LocalizedName, SandboxLimits } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import { MachinesService } from "../devices/machines.js";
|
|
3
2
|
import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
4
3
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
5
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
6
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
6
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
7
|
+
import { MachinesService } from "../local-devices/machines.js";
|
|
8
8
|
import type { KernelLogger } from "../log.js";
|
|
9
9
|
import { SandboxJobs } from "../sandbox/jobs.js";
|
|
10
10
|
import { SandboxProviders } from "../sandbox/providers.js";
|
|
11
11
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
12
|
-
import {
|
|
13
|
-
/**
|
|
14
|
-
export interface
|
|
12
|
+
import { DeviceAccess } from "./access.js";
|
|
13
|
+
/** A device as its owner sees it (`GET /orgs/:orgId/devices`). */
|
|
14
|
+
export interface DeviceView {
|
|
15
15
|
id: string;
|
|
16
16
|
/**
|
|
17
|
-
* null for the default
|
|
18
|
-
* (shown as
|
|
17
|
+
* null for the default device (shown as 「个人设备」 / "Personal") and for a demoted default
|
|
18
|
+
* (shown as 「个人设备(Docker 沙箱)」 / "Personal (Docker sandbox)", from {@link demotedFrom}).
|
|
19
19
|
*/
|
|
20
20
|
name: string | null;
|
|
21
21
|
isDefault: boolean;
|
|
@@ -24,7 +24,7 @@ export interface EnvironmentView {
|
|
|
24
24
|
* demoted from, that extension's display name (null when it has none, e.g. uninstalled: show the
|
|
25
25
|
* id), and its place among the person's unnamed former defaults of that provider (1, 2, … by
|
|
26
26
|
* creation; a label shows " 2", " 3", … after the first). Switching back to that provider makes
|
|
27
|
-
* it the default again. null for every other
|
|
27
|
+
* it the default again. null for every other device.
|
|
28
28
|
*/
|
|
29
29
|
demotedFrom: {
|
|
30
30
|
provider: string;
|
|
@@ -32,16 +32,16 @@ export interface EnvironmentView {
|
|
|
32
32
|
ordinal: number;
|
|
33
33
|
} | null;
|
|
34
34
|
ownerKind: "personal";
|
|
35
|
-
/** `
|
|
36
|
-
source: "cloud" | "
|
|
35
|
+
/** `local`: a machine connected with capybara-device (provider `@local`). */
|
|
36
|
+
source: "cloud" | "local";
|
|
37
37
|
/** The provider keeping its files, or the one its first use will create them with. */
|
|
38
38
|
provider: string | null;
|
|
39
|
-
/** Its provider is there: the deployment's current cloud provider, or `@
|
|
39
|
+
/** Its provider is there: the deployment's current cloud provider, or `@local` registered. */
|
|
40
40
|
available: boolean;
|
|
41
|
-
/** A device
|
|
41
|
+
/** A local device: some replica holds its machine's connection now; null for cloud. */
|
|
42
42
|
online: boolean | null;
|
|
43
|
-
/** A device
|
|
44
|
-
machine:
|
|
43
|
+
/** A local device's connected machine (its unrevoked one); null for cloud or none. */
|
|
44
|
+
machine: DeviceMachineView | null;
|
|
45
45
|
sessionIsolation: boolean;
|
|
46
46
|
/** Its file system is gone at the provider; reset the files to use it again. */
|
|
47
47
|
filesLost: boolean;
|
|
@@ -49,12 +49,12 @@ export interface EnvironmentView {
|
|
|
49
49
|
status: "running" | "suspended";
|
|
50
50
|
lastUsedAt: string;
|
|
51
51
|
} | null;
|
|
52
|
-
/** The org's effective sandbox limits (phase 1
|
|
52
|
+
/** The org's effective sandbox limits (phase 1 devices use them unchanged, spec §8.4). */
|
|
53
53
|
limits: SandboxLimits;
|
|
54
54
|
createdAt: string;
|
|
55
55
|
}
|
|
56
|
-
/** The machine connected to a device
|
|
57
|
-
export interface
|
|
56
|
+
/** The machine connected to a local device, as its owner sees it. */
|
|
57
|
+
export interface DeviceMachineView {
|
|
58
58
|
id: string;
|
|
59
59
|
name: string;
|
|
60
60
|
os: string;
|
|
@@ -62,24 +62,24 @@ export interface EnvironmentMachineView {
|
|
|
62
62
|
programVersion: string | null;
|
|
63
63
|
lastSeenAt: string | null;
|
|
64
64
|
}
|
|
65
|
-
/** The list response: the person's live
|
|
66
|
-
export interface
|
|
67
|
-
items:
|
|
68
|
-
/** The person's default
|
|
65
|
+
/** The list response: the person's live devices in the org. */
|
|
66
|
+
export interface DeviceList {
|
|
67
|
+
items: DeviceView[];
|
|
68
|
+
/** The person's default device; null when there is none (no sandbox provider to make it). */
|
|
69
69
|
defaultId: string | null;
|
|
70
|
-
/** The
|
|
70
|
+
/** The device of the person's most recently updated conversation that has a live one. */
|
|
71
71
|
lastUsedId: string | null;
|
|
72
|
-
/** There is a current sandbox provider (new cloud
|
|
72
|
+
/** There is a current sandbox provider (new cloud devices can be made; ruling R4). */
|
|
73
73
|
cloudAvailable: boolean;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
* Personal
|
|
76
|
+
* Personal devices (spec 2026-11-07-environments-design §4.2 items 7, 12, 13; §6; §9):
|
|
77
77
|
* cloud ones on the deployment's sandbox provider and `device` ones on a connected machine; a
|
|
78
|
-
* person's
|
|
79
|
-
* `
|
|
78
|
+
* person's devices in an org, visible and usable only by their owner (anyone else gets
|
|
79
|
+
* `device.not_found`). Deleting one soft-deletes it and destroys its instance and files in a
|
|
80
80
|
* `sandbox-destroy-for` job after the commit.
|
|
81
81
|
*/
|
|
82
|
-
export declare class
|
|
82
|
+
export declare class DevicesService {
|
|
83
83
|
private readonly db;
|
|
84
84
|
readonly txHost: TransactionHost;
|
|
85
85
|
private readonly config;
|
|
@@ -92,39 +92,39 @@ export declare class EnvironmentsService {
|
|
|
92
92
|
/** Reads the device relay's lease (`online`). */
|
|
93
93
|
private readonly locks;
|
|
94
94
|
private readonly machines;
|
|
95
|
-
constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, providers: Pick<SandboxProviders, "cloud" | "forName">, sandbox: Pick<SandboxService, "orgLimits">, sandboxJobs: Pick<SandboxJobs, "destroy" | "resetFiles">, access: Pick<
|
|
95
|
+
constructor(db: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, providers: Pick<SandboxProviders, "cloud" | "forName">, sandbox: Pick<SandboxService, "orgLimits">, sandboxJobs: Pick<SandboxJobs, "destroy" | "resetFiles">, access: Pick<DeviceAccess, "usable">, displayNames: Pick<ExtensionDisplayNames, "many">, log: Pick<KernelLogger, "warn">,
|
|
96
96
|
/** Reads the device relay's lease (`online`). */
|
|
97
97
|
locks: Pick<LockService, "holderOf">, machines: Pick<MachinesService, "revoke" | "revokeActive">);
|
|
98
98
|
/**
|
|
99
|
-
* The person's live
|
|
100
|
-
* current sandbox provider the default
|
|
99
|
+
* The person's live devices in the org, the default first, then by creation. With a
|
|
100
|
+
* current sandbox provider the default device is created first if missing (its first need,
|
|
101
101
|
* spec §4.2 item 7; an existing one is only read).
|
|
102
102
|
*/
|
|
103
|
-
list(orgId: string, accountId: string): Promise<
|
|
104
|
-
/** One of the person's live
|
|
105
|
-
get(orgId: string, accountId: string, id: string): Promise<
|
|
103
|
+
list(orgId: string, accountId: string): Promise<DeviceList>;
|
|
104
|
+
/** One of the person's live devices; anyone else's (or a missing one) → `not_found`. */
|
|
105
|
+
get(orgId: string, accountId: string, id: string): Promise<DeviceView>;
|
|
106
106
|
/**
|
|
107
|
-
* A new personal cloud
|
|
108
|
-
* use). Needs a current sandbox provider (`
|
|
109
|
-
* (case-insensitive) → `
|
|
110
|
-
* default counts) → `
|
|
107
|
+
* A new personal cloud device, ready at once (its instance and files are made on first
|
|
108
|
+
* use). Needs a current sandbox provider (`device.unavailable`); a live name of the person's
|
|
109
|
+
* (case-insensitive) → `device.name_taken`; `devices.maxPersonal` live ones (the
|
|
110
|
+
* default counts) → `device.limit_reached`. Serialized per person by their membership row.
|
|
111
111
|
*/
|
|
112
112
|
create(orgId: string, accountId: string, input: {
|
|
113
113
|
name: string;
|
|
114
|
-
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<
|
|
114
|
+
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<DeviceView>;
|
|
115
115
|
private insert;
|
|
116
116
|
/**
|
|
117
|
-
* A new personal
|
|
117
|
+
* A new personal local device for a machine being connected (provider `@local`; the
|
|
118
118
|
* machine row is the caller's). Joins the caller's transaction (the device authorization's).
|
|
119
|
-
* Counted against `
|
|
120
|
-
* person's → `
|
|
119
|
+
* Counted against `devices.maxPersonal` (`device.limit_reached`); a live name of the
|
|
120
|
+
* person's → `device.name_taken`. Needs no cloud provider.
|
|
121
121
|
*/
|
|
122
|
-
|
|
122
|
+
createLocal(orgId: string, accountId: string, name: string): Promise<{
|
|
123
123
|
id: string;
|
|
124
124
|
}>;
|
|
125
125
|
/**
|
|
126
|
-
* Inserts a named personal
|
|
127
|
-
* and name checks, and audits `
|
|
126
|
+
* Inserts a named personal device under the person's membership lock, after the limit
|
|
127
|
+
* and name checks, and audits `device.created`. Runs in the caller's transaction.
|
|
128
128
|
*/
|
|
129
129
|
private insertNamed;
|
|
130
130
|
/**
|
|
@@ -133,54 +133,54 @@ export declare class EnvironmentsService {
|
|
|
133
133
|
* same {@link ApiError}s; a race still ends in `create`'s own refusal.
|
|
134
134
|
*/
|
|
135
135
|
checkCreate(orgId: string, accountId: string, name: string): Promise<void>;
|
|
136
|
-
/** How many of the person's conversations work in the
|
|
136
|
+
/** How many of the person's conversations work in the device (read only). */
|
|
137
137
|
boundConversations(orgId: string, accountId: string, id: string): Promise<number>;
|
|
138
138
|
/**
|
|
139
139
|
* The refusals {@link resetFiles} would raise (not found, its provider not current, a connected
|
|
140
|
-
*
|
|
140
|
+
* device), read only.
|
|
141
141
|
*/
|
|
142
142
|
checkReset(orgId: string, accountId: string, id: string): Promise<void>;
|
|
143
143
|
/** The refusals {@link rename} would raise, read without locks (see {@link checkCreate}). */
|
|
144
144
|
checkRename(orgId: string, accountId: string, id: string, name: string): Promise<void>;
|
|
145
145
|
/**
|
|
146
|
-
* Renames one of the person's live
|
|
146
|
+
* Renames one of the person's live devices (the default too); see {@link create}. A
|
|
147
147
|
* renamed former default is the person's own from then on: it loses its demotion mark, so a
|
|
148
148
|
* switch back to its provider no longer restores it.
|
|
149
149
|
*/
|
|
150
|
-
rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<
|
|
150
|
+
rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<DeviceView>;
|
|
151
151
|
private renameIn;
|
|
152
152
|
/**
|
|
153
|
-
* Deletes one of the person's live
|
|
153
|
+
* Deletes one of the person's live devices: soft delete, its IM default row cleared, and
|
|
154
154
|
* after the commit a `sandbox-destroy-for` job (the worker waits for running commands, then
|
|
155
155
|
* destroys the instance and the files). Conversations bound to it keep pointing at it; their
|
|
156
|
-
* sandbox tools then fail with `
|
|
156
|
+
* sandbox tools then fail with `device.not_found`. A local device's machine is
|
|
157
157
|
* revoked in the same transaction; after the commit it is told `stop { reason: "deleted" }`
|
|
158
158
|
* (while connected) and its connection is closed.
|
|
159
159
|
*/
|
|
160
160
|
remove(orgId: string, accountId: string, id: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
|
|
161
161
|
/**
|
|
162
|
-
* Disconnects the machine of one of the person's own
|
|
162
|
+
* Disconnects the machine of one of the person's own local devices (it must sign in
|
|
163
163
|
* again); see {@link MachinesService.revoke}.
|
|
164
164
|
*/
|
|
165
165
|
revokeMachine(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
|
|
166
166
|
/**
|
|
167
|
-
* Starts one of the person's
|
|
168
|
-
* `
|
|
169
|
-
* `sandbox-reset-files` job (deterministic id per
|
|
167
|
+
* Starts one of the person's devices over with empty files (after
|
|
168
|
+
* `device.files_lost`): records the request (audit), then, after the commit, enqueues the
|
|
169
|
+
* `sandbox-reset-files` job (deterministic id per device), whose worker waits for running
|
|
170
170
|
* commands and destroys any instance and the file system; the next use creates new ones. Its
|
|
171
|
-
* provider must be the current one (`
|
|
172
|
-
* are its machine owner's (`
|
|
171
|
+
* provider must be the current one (`device.unavailable`); a local device's files
|
|
172
|
+
* are its machine owner's (`device.files_on_device`). An enqueue failure is thrown
|
|
173
173
|
* (the request can be repeated: the reset is idempotent).
|
|
174
174
|
*/
|
|
175
175
|
resetFiles(orgId: string, accountId: string, id: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
|
|
176
176
|
/** The check and audit row of {@link resetFiles}, committed before the job is enqueued. */
|
|
177
177
|
private recordReset;
|
|
178
178
|
/**
|
|
179
|
-
* The person's default
|
|
179
|
+
* The person's default device in the org, created when missing (named by the UI, `name`
|
|
180
180
|
* NULL). An existing usable one is read without locking. A live default whose files or
|
|
181
181
|
* instance are kept by a provider that is not the current one (a provider switch, spec §4.2
|
|
182
182
|
* item 13) is stranded: it is demoted (marked with the provider it was demoted from; the UI
|
|
183
|
-
* names it
|
|
183
|
+
* names it 「个人设备(<provider display name>)」) and stays listed as unavailable and deletable.
|
|
184
184
|
* Its replacement is the person's former default demoted from the current provider when there
|
|
185
185
|
* is one (switching back restores it, with its files), else a fresh default. A live default
|
|
186
186
|
* not in use yet (no healthy files, no instance, none being created: {@link inUseForDefault})
|
|
@@ -189,7 +189,7 @@ export declare class EnvironmentsService {
|
|
|
189
189
|
* belongs to the provider holding its resources once it holds any, else to the one it was
|
|
190
190
|
* demoted from ({@link demotedProvider}), so one swapped out empty and used afterwards is
|
|
191
191
|
* labelled and restored by where its files are.
|
|
192
|
-
* All of it in one transaction: switching back and forth never adds
|
|
192
|
+
* All of it in one transaction: switching back and forth never adds devices.
|
|
193
193
|
*
|
|
194
194
|
* Replacing one first takes the person's membership row (`FOR SHARE`, after the org row), so an
|
|
195
195
|
* offboarding that removes them cannot leave a live default behind; not a member (any more) →
|
|
@@ -197,13 +197,13 @@ export declare class EnvironmentsService {
|
|
|
197
197
|
* defaults of the current provider are locked (`FOR NO KEY UPDATE`) and the live default re-read
|
|
198
198
|
* after them, the partial unique index on the live default makes a racing insert do nothing, and
|
|
199
199
|
* the select that follows reads the winner. Needs a current sandbox provider
|
|
200
|
-
* (`
|
|
201
|
-
* `
|
|
200
|
+
* (`device.unavailable`). It is the person's baseline, so it is created even at
|
|
201
|
+
* `devices.maxPersonal`.
|
|
202
202
|
*/
|
|
203
203
|
ensureDefault(orgId: string, accountId: string): Promise<string>;
|
|
204
204
|
private insertDefault;
|
|
205
205
|
/**
|
|
206
|
-
* Turns the live default into an ordinary
|
|
206
|
+
* Turns the live default into an ordinary device marked as demoted from `provider`; a name
|
|
207
207
|
* the person gave it stays. Runs under the person's membership lock and the default row's lock,
|
|
208
208
|
* before any other row becomes the default (the partial unique index).
|
|
209
209
|
*/
|
|
@@ -217,35 +217,35 @@ export declare class EnvironmentsService {
|
|
|
217
217
|
*/
|
|
218
218
|
private formerDefaults;
|
|
219
219
|
/**
|
|
220
|
-
* The person's IM default (what `/
|
|
220
|
+
* The person's IM default (what `/device` set): the device their next new IM conversation
|
|
221
221
|
* uses. Null when none was set, or the chosen one is deleted (the row is cleared with it).
|
|
222
222
|
*/
|
|
223
223
|
imDefault(orgId: string, accountId: string): Promise<string | null>;
|
|
224
224
|
/**
|
|
225
|
-
* Sets the person's IM default. Only one of their own live
|
|
226
|
-
* (`
|
|
227
|
-
* statement that re-checks the
|
|
225
|
+
* Sets the person's IM default. Only one of their own live devices in the org, usable now
|
|
226
|
+
* (`device.not_found` / `device.unavailable` otherwise); the row is written by one
|
|
227
|
+
* statement that re-checks the device is live. There is no row lock, so a delete racing
|
|
228
228
|
* past that check can leave a stale row; reads ignore it ({@link imDefault} joins on
|
|
229
229
|
* `deleted_at IS NULL`).
|
|
230
230
|
*/
|
|
231
|
-
setImDefault(orgId: string, accountId: string,
|
|
231
|
+
setImDefault(orgId: string, accountId: string, deviceId: string): Promise<void>;
|
|
232
232
|
/**
|
|
233
|
-
* The person's live default
|
|
233
|
+
* The person's live default device in the org, if any, with what decides its provider;
|
|
234
234
|
* `lock` takes its row (`FOR NO KEY UPDATE`; a racing demotion makes it read none).
|
|
235
235
|
*/
|
|
236
236
|
private defaultOf;
|
|
237
237
|
/** Its files or instance are kept by a provider that is not the current one. */
|
|
238
238
|
private stranded;
|
|
239
|
-
/** The person's live
|
|
239
|
+
/** The person's live devices (or the one `id`) as views. */
|
|
240
240
|
private views;
|
|
241
241
|
/**
|
|
242
|
-
* Serializes the person's
|
|
242
|
+
* Serializes the person's device writes in the org: the org row (`FOR SHARE`), then their
|
|
243
243
|
* membership row (`FOR NO KEY UPDATE`, or `FOR SHARE` with `mode` share: enough to keep the
|
|
244
244
|
* membership from being removed meanwhile), the order member removal locks them in. Not a
|
|
245
245
|
* member (any more) → `org.not_found`, as the org guard answers.
|
|
246
246
|
*/
|
|
247
247
|
private lockMember;
|
|
248
|
-
/** Locks one of the person's live
|
|
248
|
+
/** Locks one of the person's live devices (after their membership); else `not_found`. */
|
|
249
249
|
private lockOwn;
|
|
250
250
|
private assertNameFree;
|
|
251
251
|
}
|