@capybara-hq/kernel 0.1.0-rc.73 → 0.1.0-rc.75
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 +5 -5
- package/dist/catalog/admin-catalog.schemas.d.ts +3 -1
- package/dist/catalog/admin-catalog.schemas.js +6 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.schemas.d.ts +3 -1
- package/dist/catalog/org-catalog.schemas.js +3 -1
- package/dist/catalog/plugin-package.js +7 -5
- package/dist/catalog/reserved-names.js +3 -9
- package/dist/channels/actions.js +4 -0
- package/dist/channels/cards.d.ts +10 -7
- package/dist/channels/cards.js +23 -12
- package/dist/channels/phrases.d.ts +24 -2
- package/dist/channels/phrases.js +12 -2
- package/dist/ctx/secrets.d.ts +4 -2
- package/dist/ctx/secrets.js +19 -5
- package/dist/db/kernel-schema.d.ts +14 -0
- package/dist/devices/conversation-devices.d.ts +3 -2
- package/dist/devices/conversation-devices.js +9 -4
- package/dist/devices/device-projects.service.d.ts +22 -27
- package/dist/devices/device-projects.service.js +39 -44
- package/dist/devices/devices.controller.d.ts +3 -5
- package/dist/devices/devices.controller.js +4 -17
- package/dist/devices/devices.schemas.d.ts +1 -1
- package/dist/devices/devices.schemas.js +1 -1
- package/dist/devices/devices.service.d.ts +75 -52
- package/dist/devices/devices.service.js +166 -95
- package/dist/devices/project-rules.d.ts +6 -8
- package/dist/devices/project-rules.js +5 -11
- package/dist/dial-in/auth.service.js +1 -1
- package/dist/dial-in/machines.d.ts +4 -15
- package/dist/dial-in/machines.js +4 -59
- package/dist/errors.d.ts +8 -3
- package/dist/errors.js +8 -3
- package/dist/extensions/admin-ops.js +2 -1
- package/dist/extensions/bootstrap-extra.d.ts +11 -1
- package/dist/extensions/bootstrap-extra.js +21 -1
- package/dist/extensions/bootstrap-manifest.d.ts +14 -0
- package/dist/extensions/bootstrap-manifest.js +23 -0
- package/dist/extensions/bootstrap-packages.d.ts +87 -0
- package/dist/extensions/bootstrap-packages.js +263 -0
- package/dist/extensions/bootstrap.d.ts +27 -71
- package/dist/extensions/bootstrap.js +85 -329
- package/dist/extensions/guide-places.d.ts +9 -0
- package/dist/extensions/guide-places.js +32 -22
- package/dist/extensions/plugin-guides.d.ts +20 -2
- package/dist/extensions/plugin-guides.js +39 -14
- package/dist/http/meta.controller.d.ts +0 -1
- package/dist/http/meta.controller.js +2 -6
- package/dist/identity/sso-paths.d.ts +7 -0
- package/dist/identity/sso-paths.js +13 -0
- package/dist/identity/sso.js +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +2 -2
- package/dist/platform/exclusions.js +2 -7
- package/dist/platform/ops/devices.ops.js +11 -7
- package/dist/platform/ops/setup.ops.js +1 -1
- package/dist/runtime/project/knowledge.service.js +6 -5
- package/dist/sandbox/device-sandbox.d.ts +27 -2
- package/dist/sandbox/device-sandbox.js +42 -5
- package/dist/sandbox/modes.d.ts +16 -4
- package/dist/sandbox/modes.js +12 -0
- package/dist/sandbox/operation-authority.js +3 -1
- package/dist/sandbox/permission-authority-lock.d.ts +6 -0
- package/dist/sandbox/permission-authority-lock.js +14 -0
- package/dist/sandbox/permission-facts.d.ts +16 -2
- package/dist/sandbox/permission-facts.js +20 -5
- package/dist/sandbox/review/permission-candidate.d.ts +12 -7
- package/dist/sandbox/review/permission-candidate.js +28 -7
- package/dist/sandbox/sandbox.service.d.ts +18 -11
- package/dist/sandbox/sandbox.service.js +51 -24
- package/dist/setup/setup-guides.service.d.ts +3 -4
- package/dist/setup/setup-guides.service.js +2 -5
- package/dist/shares/sweep.job.d.ts +2 -0
- package/dist/shares/sweep.job.js +3 -1
- package/dist/tools/approvals.service.d.ts +31 -11
- package/dist/tools/approvals.service.js +55 -19
- package/dist/tools/builtins/sandbox/common.d.ts +2 -2
- package/dist/tools/builtins/sandbox/common.js +2 -2
- package/dist/tools/network-asks.d.ts +103 -20
- package/dist/tools/network-asks.js +133 -18
- package/dist/tools/pipeline.d.ts +5 -0
- package/dist/tools/pipeline.js +15 -8
- package/package.json +3 -3
- package/src/migrations/0178_bootstrap_run_extra.sql +17 -0
|
@@ -2,13 +2,12 @@ import { ApiError } from "../errors.js";
|
|
|
2
2
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
3
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
4
|
import type { KernelLogger } from "../log.js";
|
|
5
|
-
import type { SandboxMode } from "../sandbox/modes.js";
|
|
6
5
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
7
6
|
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
8
7
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
9
8
|
import { DeviceAccess } from "./access.js";
|
|
10
9
|
import { type DeviceProjectScope } from "./project-rules.js";
|
|
11
|
-
export {
|
|
10
|
+
export type { DeviceProjectScope } from "./project-rules.js";
|
|
12
11
|
/** The most projects one device keeps (project root §4.1). */
|
|
13
12
|
export declare const MAX_DEVICE_PROJECTS = 100;
|
|
14
13
|
/** A project as the web and the Platform tool see it. */
|
|
@@ -20,16 +19,12 @@ export interface DeviceProjectView {
|
|
|
20
19
|
}
|
|
21
20
|
/** `GET /devices/:id/projects`. */
|
|
22
21
|
export interface DeviceProjectList {
|
|
23
|
-
/** The projects the device's current mode can read (the others are kept, only hidden). */
|
|
24
|
-
projects: DeviceProjectView[];
|
|
25
|
-
/** How many stored projects the current mode hides. */
|
|
26
|
-
hidden: number;
|
|
27
|
-
/** The mode the device runs at now. */
|
|
28
|
-
mode: SandboxMode;
|
|
29
22
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
23
|
+
* Every stored project (none when the device offers no projects): the kernel hides none, the
|
|
24
|
+
* provider refuses what it will not serve.
|
|
32
25
|
*/
|
|
26
|
+
projects: DeviceProjectView[];
|
|
27
|
+
/** The base a relative path is resolved against: the home the provider reports, else the workspace. */
|
|
33
28
|
base: string | null;
|
|
34
29
|
/** The device offers projects (a machine announcing `projects`, a provider with list / scan). */
|
|
35
30
|
supported: boolean;
|
|
@@ -45,18 +40,16 @@ export interface DeviceProjectCandidateView {
|
|
|
45
40
|
/** `GET /devices/:id/projects/candidates`. */
|
|
46
41
|
export interface DeviceProjectCandidates {
|
|
47
42
|
candidates: DeviceProjectCandidateView[];
|
|
48
|
-
mode: SandboxMode;
|
|
49
43
|
base: string | null;
|
|
50
44
|
supported: boolean;
|
|
51
45
|
}
|
|
52
46
|
/**
|
|
53
47
|
* A device's projects (project root design §4.1, §4.2, §6): kept in `device_projects`, keyed by the
|
|
54
48
|
* device's id, written only here. Only the device's owner reads or changes them (anyone else gets
|
|
55
|
-
* `device.not_found`).
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* it with `list`, the suggestions with `scan`, both carrying the current mode, both outside any
|
|
49
|
+
* `device.not_found`). Paths are relative to the base (the home the provider reports, else the
|
|
50
|
+
* workspace); the kernel narrows none below it, only refuses one above the owner's home. The
|
|
51
|
+
* provider is the authority on what it serves: adding asks it with `list` (it may refuse a path
|
|
52
|
+
* with a reason, `device.project_refused`), the suggestions with `scan`, both outside any
|
|
60
53
|
* transaction; the insert then runs in its own, with uniqueness from the primary key.
|
|
61
54
|
*/
|
|
62
55
|
export declare class DeviceProjectsService {
|
|
@@ -72,11 +65,11 @@ export declare class DeviceProjectsService {
|
|
|
72
65
|
constructor(db: KernelDb, txHost: TransactionHost, sandbox: Pick<SandboxService, "withSandbox" | "withBrowse" | "ensureRunningForOwner">, access: Pick<DeviceAccess, "usable">, facts: Pick<PermissionFacts, "resolveProjectForBinding" | "projectMatches" | "projectScope">, ceilings: PermissionCeilingWrites, log: Pick<KernelLogger, "warn">,
|
|
73
66
|
/** The paired activation gate: once on, every device read is an owner browse. */
|
|
74
67
|
activation?: boolean | undefined);
|
|
75
|
-
/**
|
|
68
|
+
/** Every stored project; see {@link DeviceProjectList}. */
|
|
76
69
|
list(orgId: string, accountId: string, deviceId: string): Promise<DeviceProjectList>;
|
|
77
70
|
/**
|
|
78
|
-
* The picker's suggestions: one `scan` of the base
|
|
79
|
-
*
|
|
71
|
+
* The picker's suggestions: one `scan` of the base (never file contents). A device that offers
|
|
72
|
+
* no projects suggests none.
|
|
80
73
|
*/
|
|
81
74
|
candidates(orgId: string, accountId: string, deviceId: string, signal?: AbortSignal): Promise<DeviceProjectCandidates>;
|
|
82
75
|
/**
|
|
@@ -88,12 +81,14 @@ export declare class DeviceProjectsService {
|
|
|
88
81
|
/** {@link checkAdd}, answering the scope it read. */
|
|
89
82
|
private precheck;
|
|
90
83
|
/**
|
|
91
|
-
* Adds a project: `path` is resolved against the base
|
|
92
|
-
*
|
|
84
|
+
* Adds a project: `path` is resolved against the base (the home the provider reports, else the
|
|
85
|
+
* workspace) and must not lie above the owner's home ({@link aboveHome},
|
|
93
86
|
* `device.project_path_too_broad`); `name` defaults to the directory's basename. The device is
|
|
94
87
|
* asked `list(path, { limit: 1 })` first, outside any transaction: an answer (even no entries)
|
|
95
|
-
* is a readable directory, null a missing one,
|
|
96
|
-
*
|
|
88
|
+
* is a readable directory, null a missing one, a `ProjectPathRefusedError` the provider refusing
|
|
89
|
+
* it with a reason (`device.project_refused`), another error a file, an unreadable path or one
|
|
90
|
+
* the device's browse scope refused; each is a readable refusal. Then the insert, serialized per
|
|
91
|
+
* device.
|
|
97
92
|
*/
|
|
98
93
|
add(orgId: string, accountId: string, deviceId: string, input: {
|
|
99
94
|
path: string;
|
|
@@ -113,10 +108,10 @@ export declare class DeviceProjectsService {
|
|
|
113
108
|
private removeIn;
|
|
114
109
|
/**
|
|
115
110
|
* The project a new conversation of `accountId` binds to (project root §4.3): one of the
|
|
116
|
-
* owner's device's projects
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
111
|
+
* owner's device's projects. Refused with `device.not_found` (not the caller's device),
|
|
112
|
+
* `device.projects_unsupported`, `device.project_not_found` or `device.project_path_too_broad`.
|
|
113
|
+
* Reads only (the caller's transaction, if any); the device is not asked: its provider enforces
|
|
114
|
+
* what it serves on every access anyway.
|
|
120
115
|
*/
|
|
121
116
|
resolveForBinding(orgId: string, deviceId: string, accountId: string, name: string): Promise<{
|
|
122
117
|
name: string;
|
|
@@ -22,15 +22,14 @@ import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
|
22
22
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
23
23
|
import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
|
|
24
24
|
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
25
|
-
import {
|
|
25
|
+
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
26
26
|
import { SandboxProviderUnreachableError } from "../sandbox/unreachable.js";
|
|
27
27
|
import { DeviceAccess } from "./access.js";
|
|
28
|
-
import { projectsUnsupported } from "./errors.js";
|
|
29
|
-
import { baseOf, clipped, nameInvalid, nameTaken, outsideMode, tooBroad,
|
|
28
|
+
import { deviceNotFound, projectsUnsupported } from "./errors.js";
|
|
29
|
+
import { baseOf, clipped, nameInvalid, nameTaken, outsideMode, tooBroad, } from "./project-rules.js";
|
|
30
30
|
// a path above the owner's home is never stored as a project: the working root would fall back for
|
|
31
31
|
// it anyway (project root §4.3), so both use the one rule; the home itself may be one
|
|
32
32
|
import { aboveHome } from "./working-root.js";
|
|
33
|
-
export { withinMode } from "./project-rules.js";
|
|
34
33
|
/** The most projects one device keeps (project root §4.1). */
|
|
35
34
|
export const MAX_DEVICE_PROJECTS = 100;
|
|
36
35
|
/**
|
|
@@ -68,11 +67,10 @@ function browseReader(b, workspace) {
|
|
|
68
67
|
/**
|
|
69
68
|
* A device's projects (project root design §4.1, §4.2, §6): kept in `device_projects`, keyed by the
|
|
70
69
|
* device's id, written only here. Only the device's owner reads or changes them (anyone else gets
|
|
71
|
-
* `device.not_found`).
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* it with `list`, the suggestions with `scan`, both carrying the current mode, both outside any
|
|
70
|
+
* `device.not_found`). Paths are relative to the base (the home the provider reports, else the
|
|
71
|
+
* workspace); the kernel narrows none below it, only refuses one above the owner's home. The
|
|
72
|
+
* provider is the authority on what it serves: adding asks it with `list` (it may refuse a path
|
|
73
|
+
* with a reason, `device.project_refused`), the suggestions with `scan`, both outside any
|
|
76
74
|
* transaction; the insert then runs in its own, with uniqueness from the primary key.
|
|
77
75
|
*/
|
|
78
76
|
let DeviceProjectsService = class DeviceProjectsService {
|
|
@@ -96,7 +94,7 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
96
94
|
this.log = log;
|
|
97
95
|
this.activation = activation;
|
|
98
96
|
}
|
|
99
|
-
/**
|
|
97
|
+
/** Every stored project; see {@link DeviceProjectList}. */
|
|
100
98
|
async list(orgId, accountId, deviceId) {
|
|
101
99
|
const scope = await this.scope(orgId, accountId, deviceId);
|
|
102
100
|
const rows = await this.db
|
|
@@ -106,28 +104,26 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
106
104
|
.orderBy("name")
|
|
107
105
|
.execute();
|
|
108
106
|
// a device that offers no projects offers none of the stored ones either
|
|
109
|
-
const
|
|
107
|
+
const listed = scope.supported ? rows : [];
|
|
110
108
|
return {
|
|
111
|
-
projects:
|
|
109
|
+
projects: listed.map((r) => ({
|
|
112
110
|
name: r.name,
|
|
113
111
|
path: r.path,
|
|
114
112
|
createdAt: r.created_at.toISOString(),
|
|
115
113
|
})),
|
|
116
|
-
hidden: rows.length - visible.length,
|
|
117
|
-
mode: scope.mode,
|
|
118
114
|
base: baseOf(scope),
|
|
119
115
|
supported: scope.supported,
|
|
120
116
|
};
|
|
121
117
|
}
|
|
122
118
|
/**
|
|
123
|
-
* The picker's suggestions: one `scan` of the base
|
|
124
|
-
*
|
|
119
|
+
* The picker's suggestions: one `scan` of the base (never file contents). A device that offers
|
|
120
|
+
* no projects suggests none.
|
|
125
121
|
*/
|
|
126
122
|
async candidates(orgId, accountId, deviceId, signal = new AbortController().signal) {
|
|
127
123
|
// ownership is the scope's; whether the provider can serve the device is withSandbox's
|
|
128
124
|
const scope = await this.scope(orgId, accountId, deviceId);
|
|
129
125
|
if (!scope.supported) {
|
|
130
|
-
return { candidates: [],
|
|
126
|
+
return { candidates: [], base: baseOf(scope), supported: false };
|
|
131
127
|
}
|
|
132
128
|
return this.onDevice(orgId, accountId, deviceId, scope, signal, async (r, sig) => {
|
|
133
129
|
const workspace = r.workspace;
|
|
@@ -147,11 +143,10 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
147
143
|
this.log.warn("device projects: the device could not scan", { deviceId, err: e });
|
|
148
144
|
throw unavailable(e);
|
|
149
145
|
}
|
|
150
|
-
// the device's answer is checked again: inside the base
|
|
146
|
+
// the device's answer is checked again: inside the base, a valid name, bounded
|
|
151
147
|
const candidates = found
|
|
152
148
|
.filter((c) => validateSandboxPathShape(c.path).length === 0 &&
|
|
153
149
|
(c.path === base || c.path.startsWith(base === "/" ? "/" : `${base}/`)) &&
|
|
154
|
-
withinMode(scope, c.path, workspace) &&
|
|
155
150
|
isDeviceProjectName(c.suggestedName))
|
|
156
151
|
.slice(0, MAX_DEVICE_SCAN_RESULTS)
|
|
157
152
|
.map((c) => ({
|
|
@@ -159,7 +154,7 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
159
154
|
relativePath: relativeTo(base, c.path),
|
|
160
155
|
suggestedName: c.suggestedName,
|
|
161
156
|
}));
|
|
162
|
-
return { candidates,
|
|
157
|
+
return { candidates, base, supported: true };
|
|
163
158
|
});
|
|
164
159
|
}
|
|
165
160
|
/**
|
|
@@ -190,12 +185,14 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
190
185
|
return scope;
|
|
191
186
|
}
|
|
192
187
|
/**
|
|
193
|
-
* Adds a project: `path` is resolved against the base
|
|
194
|
-
*
|
|
188
|
+
* Adds a project: `path` is resolved against the base (the home the provider reports, else the
|
|
189
|
+
* workspace) and must not lie above the owner's home ({@link aboveHome},
|
|
195
190
|
* `device.project_path_too_broad`); `name` defaults to the directory's basename. The device is
|
|
196
191
|
* asked `list(path, { limit: 1 })` first, outside any transaction: an answer (even no entries)
|
|
197
|
-
* is a readable directory, null a missing one,
|
|
198
|
-
*
|
|
192
|
+
* is a readable directory, null a missing one, a `ProjectPathRefusedError` the provider refusing
|
|
193
|
+
* it with a reason (`device.project_refused`), another error a file, an unreadable path or one
|
|
194
|
+
* the device's browse scope refused; each is a readable refusal. Then the insert, serialized per
|
|
195
|
+
* device.
|
|
199
196
|
*/
|
|
200
197
|
async add(orgId, accountId, deviceId, input, actorTokenId, auditDetail, signal = new AbortController().signal) {
|
|
201
198
|
const scope = await this.precheck(orgId, accountId, deviceId, input.name);
|
|
@@ -203,8 +200,7 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
203
200
|
// started): against the last known base; the held instance's base is checked again inside
|
|
204
201
|
const early = baseOf(scope);
|
|
205
202
|
const path = trimSlash(posix.normalize(posix.join(early, input.path === "" ? "." : input.path)));
|
|
206
|
-
|
|
207
|
-
if (withinMode(scope, path) && aboveHome(path, scope.home))
|
|
203
|
+
if (aboveHome(path, scope.home))
|
|
208
204
|
throw tooBroad(path);
|
|
209
205
|
const resolved = await this.onDevice(orgId, accountId, deviceId, scope, signal, async (r, sig) => {
|
|
210
206
|
const path = resolve(scope, r.workspace, input.path);
|
|
@@ -219,7 +215,7 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
219
215
|
answer = await list(path, 1, sig);
|
|
220
216
|
}
|
|
221
217
|
catch (e) {
|
|
222
|
-
throw await listFailure(e, r, path,
|
|
218
|
+
throw await listFailure(e, r, path, sig, (err, statErr) => this.log.warn("device projects: the device could not list", {
|
|
223
219
|
deviceId,
|
|
224
220
|
err,
|
|
225
221
|
statErr,
|
|
@@ -317,10 +313,10 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
317
313
|
}
|
|
318
314
|
/**
|
|
319
315
|
* The project a new conversation of `accountId` binds to (project root §4.3): one of the
|
|
320
|
-
* owner's device's projects
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
316
|
+
* owner's device's projects. Refused with `device.not_found` (not the caller's device),
|
|
317
|
+
* `device.projects_unsupported`, `device.project_not_found` or `device.project_path_too_broad`.
|
|
318
|
+
* Reads only (the caller's transaction, if any); the device is not asked: its provider enforces
|
|
319
|
+
* what it serves on every access anyway.
|
|
324
320
|
*/
|
|
325
321
|
async resolveForBinding(orgId, deviceId, accountId, name) {
|
|
326
322
|
return this.facts.resolveProjectForBinding(orgId, deviceId, accountId, name);
|
|
@@ -435,15 +431,14 @@ const limitReached = () => new ApiError("device.project_limit_reached", `This de
|
|
|
435
431
|
const trimSlash = (path) => path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
|
|
436
432
|
/**
|
|
437
433
|
* The absolute path of `relative` against the scope's base (the home its provider reported, else
|
|
438
|
-
* the instance's `workspace`), normalized; refused when the result is not a valid path
|
|
439
|
-
*
|
|
434
|
+
* the instance's `workspace`), normalized; refused when the result is not a valid device path or
|
|
435
|
+
* lies above the owner's home. Where a project may lie below that is the provider's rule.
|
|
440
436
|
*/
|
|
441
437
|
function resolve(scope, workspace, relative) {
|
|
442
438
|
const base = baseOf(scope, workspace);
|
|
443
439
|
const path = trimSlash(posix.normalize(posix.join(base, relative === "" ? "." : relative)));
|
|
444
|
-
if (validateSandboxPathShape(path).length > 0
|
|
445
|
-
throw outsideMode(path
|
|
446
|
-
}
|
|
440
|
+
if (validateSandboxPathShape(path).length > 0)
|
|
441
|
+
throw outsideMode(path);
|
|
447
442
|
if (aboveHome(path, scope.home))
|
|
448
443
|
throw tooBroad(path);
|
|
449
444
|
return path;
|
|
@@ -478,24 +473,24 @@ const pathMissing = (path) => new ApiError("device.project_path_missing", `${cli
|
|
|
478
473
|
/**
|
|
479
474
|
* What a failed `list(path)` becomes. A provider's `ProjectPathRefusedError` is
|
|
480
475
|
* `device.project_refused` with its reason; the owner browse scope refusing the path is the
|
|
481
|
-
* device refusing it (`device.project_outside_mode
|
|
482
|
-
* an unreadable directory from a failure on the device, so the
|
|
483
|
-
* or a directory it cannot list is the path's problem (422 `device.project_path_unreadable`), a
|
|
476
|
+
* device refusing it (`device.project_outside_mode`, the browse scope gives no reason). Any other
|
|
477
|
+
* error alone cannot tell a file or an unreadable directory from a failure on the device, so the
|
|
478
|
+
* device is asked `stat(path)`: a file or a directory it cannot list is the path's problem (422 `device.project_path_unreadable`), a
|
|
484
479
|
* missing path `device.project_path_missing`, and a `stat` that fails too means the device could
|
|
485
480
|
* not be asked (503 `device.projects_unavailable`).
|
|
486
481
|
*/
|
|
487
|
-
async function listFailure(e, r, path,
|
|
482
|
+
async function listFailure(e, r, path, signal, logUnavailable) {
|
|
488
483
|
const passed = passThrough(e);
|
|
489
484
|
if (passed !== undefined)
|
|
490
485
|
return passed;
|
|
491
|
-
// the provider refusing the directory states its reason (shown to the person, en + zh)
|
|
486
|
+
// the provider refusing the directory states its reason (shown to the person, en + zh); any
|
|
487
|
+
// other text from the machine is not trusted and never reaches the person
|
|
492
488
|
if (isProjectPathRefusedError(e)) {
|
|
493
489
|
return new ApiError("device.project_refused", e.reason.en, [{ reason: e.reason }]);
|
|
494
490
|
}
|
|
495
|
-
const why = e instanceof ToolError ? ` (${clipped(e.message)})` : "";
|
|
496
491
|
// the owner browse scope refusing the path is the device refusing it (gate on only)
|
|
497
492
|
if (r.browse && isSandboxScopeDeniedError(e)) {
|
|
498
|
-
return new ApiError("device.project_outside_mode", `The device refused ${clipped(path)}
|
|
493
|
+
return new ApiError("device.project_outside_mode", `The device refused ${clipped(path)}: it is outside what the device lets a project reach`);
|
|
499
494
|
}
|
|
500
495
|
let st;
|
|
501
496
|
try {
|
|
@@ -511,7 +506,7 @@ async function listFailure(e, r, path, mode, signal, logUnavailable) {
|
|
|
511
506
|
if (st === null)
|
|
512
507
|
return pathMissing(path);
|
|
513
508
|
return new ApiError("device.project_path_unreadable", st.isDir
|
|
514
|
-
? `${clipped(path)} is a directory the device cannot read
|
|
509
|
+
? `${clipped(path)} is a directory the device cannot read`
|
|
515
510
|
: `${clipped(path)} is a file, not a directory`);
|
|
516
511
|
}
|
|
517
512
|
const relativeTo = (base, path) => path === base ? "" : posix.relative(base, path);
|
|
@@ -10,11 +10,12 @@ import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type De
|
|
|
10
10
|
* Phase 1 has personal cloud devices only, each visible to its owner alone: another member
|
|
11
11
|
* gets 404 `device.not_found`.
|
|
12
12
|
* - `GET /` → `{ items, defaultId, lastUsedId, providers, defaultProvider }` (`providers`: the
|
|
13
|
-
* device providers on in the org, `{ plugin, displayName }`; `defaultProvider`: the one a device
|
|
13
|
+
* device providers on in the org, `{ plugin, displayName, description, dialIn, guide }`; `defaultProvider`: the one a device
|
|
14
14
|
* gets when none is named, null when none serves the org);
|
|
15
15
|
* - `POST / { name, provider? }` → 201 `{ device }`, bound for life to `provider` (one of
|
|
16
16
|
* `providers`, else 400 `validation_failed` at `provider`) or the default provider (none: 400
|
|
17
|
-
* `device.provider_required
|
|
17
|
+
* `device.provider_required`; a dial-in provider: 409 `device.provider_dial_in`, its devices are
|
|
18
|
+
* made by the machine); `GET /:id` → `{ device }`;
|
|
18
19
|
* - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets its sandbox network
|
|
19
20
|
* (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design, "Settings
|
|
20
21
|
* model") within its org's and the platform's ceilings (400 `device.network_not_allowed` above
|
|
@@ -23,8 +24,6 @@ import { type DeviceCreateBody, type DeviceParams, type DevicePatchBody, type De
|
|
|
23
24
|
* - `DELETE /:id` → 202 (destroyed by a job after the response);
|
|
24
25
|
* - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
|
|
25
26
|
* starts empty; 409 `device.files_on_device` when its provider's report offers no reset);
|
|
26
|
-
* - `DELETE /:id/machine` → 204: a dial-in device's machine is disconnected (its credential
|
|
27
|
-
* revoked; it must sign in again);
|
|
28
27
|
* - a device's projects (project root design §4.1, §4.2), owner only (anyone else:
|
|
29
28
|
* `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
|
|
30
29
|
* `GET /:id/projects/candidates` → the device's suggestions under its base;
|
|
@@ -47,7 +46,6 @@ export declare class DevicesController {
|
|
|
47
46
|
}>;
|
|
48
47
|
remove(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
|
|
49
48
|
resetFiles(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
|
|
50
|
-
revokeMachine(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<void>;
|
|
51
49
|
listProjects(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectList>;
|
|
52
50
|
projectCandidates(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectCandidates>;
|
|
53
51
|
addProject(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>, body: z.infer<typeof DeviceProjectAddBody>): Promise<{
|
|
@@ -20,11 +20,12 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DeviceProject
|
|
|
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
22
|
* - `GET /` → `{ items, defaultId, lastUsedId, providers, defaultProvider }` (`providers`: the
|
|
23
|
-
* device providers on in the org, `{ plugin, displayName }`; `defaultProvider`: the one a device
|
|
23
|
+
* device providers on in the org, `{ plugin, displayName, description, dialIn, guide }`; `defaultProvider`: the one a device
|
|
24
24
|
* gets when none is named, null when none serves the org);
|
|
25
25
|
* - `POST / { name, provider? }` → 201 `{ device }`, bound for life to `provider` (one of
|
|
26
26
|
* `providers`, else 400 `validation_failed` at `provider`) or the default provider (none: 400
|
|
27
|
-
* `device.provider_required
|
|
27
|
+
* `device.provider_required`; a dial-in provider: 409 `device.provider_dial_in`, its devices are
|
|
28
|
+
* made by the machine); `GET /:id` → `{ device }`;
|
|
28
29
|
* - `PATCH /:id { name?, network? }` → `{ device }`: renames it and sets its sandbox network
|
|
29
30
|
* (`{ mode: open | allowlist | none | null, hosts? }`, approval-only profiles design, "Settings
|
|
30
31
|
* model") within its org's and the platform's ceilings (400 `device.network_not_allowed` above
|
|
@@ -33,8 +34,6 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DeviceProject
|
|
|
33
34
|
* - `DELETE /:id` → 202 (destroyed by a job after the response);
|
|
34
35
|
* - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
|
|
35
36
|
* starts empty; 409 `device.files_on_device` when its provider's report offers no reset);
|
|
36
|
-
* - `DELETE /:id/machine` → 204: a dial-in device's machine is disconnected (its credential
|
|
37
|
-
* revoked; it must sign in again);
|
|
38
37
|
* - a device's projects (project root design §4.1, §4.2), owner only (anyone else:
|
|
39
38
|
* `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
|
|
40
39
|
* `GET /:id/projects/candidates` → the device's suggestions under its base;
|
|
@@ -50,7 +49,7 @@ let DevicesController = class DevicesController {
|
|
|
50
49
|
}
|
|
51
50
|
async list(principal, org) {
|
|
52
51
|
const p = requireUser(principal);
|
|
53
|
-
return this.devices.list(org.orgId, p.account.id);
|
|
52
|
+
return this.devices.list(org.orgId, p.account.id, org.role);
|
|
54
53
|
}
|
|
55
54
|
async create(principal, org, body) {
|
|
56
55
|
const p = requireUser(principal);
|
|
@@ -82,10 +81,6 @@ let DevicesController = class DevicesController {
|
|
|
82
81
|
const p = requireUser(principal);
|
|
83
82
|
await this.devices.resetFiles(org.orgId, p.account.id, params.id, patTokenId(p));
|
|
84
83
|
}
|
|
85
|
-
async revokeMachine(principal, org, params) {
|
|
86
|
-
const p = requireUser(principal);
|
|
87
|
-
await this.devices.revokeMachine(org.orgId, p.account.id, params.id, patTokenId(p));
|
|
88
|
-
}
|
|
89
84
|
async listProjects(principal, org, params) {
|
|
90
85
|
const p = requireUser(principal);
|
|
91
86
|
return this.projects.list(org.orgId, p.account.id, params.id);
|
|
@@ -149,14 +144,6 @@ __decorate([
|
|
|
149
144
|
__param(1, CurrentOrg()),
|
|
150
145
|
__param(2, ZParam(DeviceParamsDto))
|
|
151
146
|
], DevicesController.prototype, "resetFiles", null);
|
|
152
|
-
__decorate([
|
|
153
|
-
Delete(":id/machine"),
|
|
154
|
-
HttpCode(204),
|
|
155
|
-
OrgAction("agents.use"),
|
|
156
|
-
__param(0, CurrentPrincipal()),
|
|
157
|
-
__param(1, CurrentOrg()),
|
|
158
|
-
__param(2, ZParam(DeviceParamsDto))
|
|
159
|
-
], DevicesController.prototype, "revokeMachine", null);
|
|
160
147
|
__decorate([
|
|
161
148
|
Get(":id/projects"),
|
|
162
149
|
OrgAction("agents.use"),
|
|
@@ -2,6 +2,6 @@ import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The devices routes the Platform operations mirror (`check:platform-ops` keys). `PATCH /devices/:id`
|
|
4
4
|
* ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
|
|
5
|
-
* (a
|
|
5
|
+
* (a device's network, narrow only).
|
|
6
6
|
*/
|
|
7
7
|
export declare const DEVICE_ROUTES: readonly RouteSchemas[];
|
|
@@ -2,7 +2,7 @@ import { DeviceCreateBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody,
|
|
|
2
2
|
/**
|
|
3
3
|
* The devices routes the Platform operations mirror (`check:platform-ops` keys). `PATCH /devices/:id`
|
|
4
4
|
* ({@link DevicePatchBody}) is mirrored by `devices.rename` (the name) and `devices.set-network`
|
|
5
|
-
* (a
|
|
5
|
+
* (a device's network, narrow only).
|
|
6
6
|
*/
|
|
7
7
|
export const DEVICE_ROUTES = [
|
|
8
8
|
{ route: "GET /api/v1/orgs/:orgId/devices" },
|