@capybara-hq/kernel 0.1.0-rc.74 → 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 +3 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/devices/device-projects.service.js +4 -4
- package/dist/devices/devices.service.d.ts +15 -12
- package/dist/devices/devices.service.js +25 -19
- package/dist/dial-in/machines.d.ts +3 -15
- package/dist/dial-in/machines.js +4 -60
- package/dist/http/meta.controller.d.ts +0 -1
- package/dist/http/meta.controller.js +2 -6
- package/dist/sandbox/device-sandbox.d.ts +16 -2
- package/dist/sandbox/device-sandbox.js +13 -5
- 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 +4 -0
- package/dist/sandbox/permission-facts.js +6 -1
- package/dist/sandbox/review/permission-candidate.d.ts +12 -7
- package/dist/sandbox/review/permission-candidate.js +28 -7
- package/dist/setup/setup-guides.service.d.ts +1 -2
- package/dist/setup/setup-guides.service.js +1 -4
- package/dist/shares/sweep.job.d.ts +2 -0
- package/dist/shares/sweep.job.js +3 -1
- package/package.json +2 -2
package/bootstrap.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "1c9b0dd4ae64d1f199afa3a17d35de4810ab08e5"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "device-local",
|
|
99
99
|
"source": "npm",
|
|
100
100
|
"npm": "@capybara-hq/plugin-device-local",
|
|
101
|
-
"version": "0.1.0-rc.
|
|
102
|
-
"integrity": "sha512
|
|
101
|
+
"version": "0.1.0-rc.5",
|
|
102
|
+
"integrity": "sha512-HaR5VFeK2AqMy4EM6glwGd0cZtgjMMS8AsOqimUCYPMT/eubrP/VuxB3eAFpR007xvommVIv5jd5XnXLbiYanw==",
|
|
103
103
|
"required": false,
|
|
104
104
|
"scope": "all"
|
|
105
105
|
},
|
|
@@ -203,7 +203,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
203
203
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
204
204
|
export declare const HOST_VERSIONS: {
|
|
205
205
|
readonly kernel: string;
|
|
206
|
-
readonly sdk: "0.1.0-rc.
|
|
206
|
+
readonly sdk: "0.1.0-rc.60";
|
|
207
207
|
};
|
|
208
208
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
209
209
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -483,14 +483,14 @@ async function listFailure(e, r, path, signal, logUnavailable) {
|
|
|
483
483
|
const passed = passThrough(e);
|
|
484
484
|
if (passed !== undefined)
|
|
485
485
|
return passed;
|
|
486
|
-
// 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
|
|
487
488
|
if (isProjectPathRefusedError(e)) {
|
|
488
489
|
return new ApiError("device.project_refused", e.reason.en, [{ reason: e.reason }]);
|
|
489
490
|
}
|
|
490
|
-
const why = e instanceof ToolError ? ` (${clipped(e.message)})` : "";
|
|
491
491
|
// the owner browse scope refusing the path is the device refusing it (gate on only)
|
|
492
492
|
if (r.browse && isSandboxScopeDeniedError(e)) {
|
|
493
|
-
return new ApiError("device.project_outside_mode", `The device refused ${clipped(path)}: it is outside what the device lets a project reach
|
|
493
|
+
return new ApiError("device.project_outside_mode", `The device refused ${clipped(path)}: it is outside what the device lets a project reach`);
|
|
494
494
|
}
|
|
495
495
|
let st;
|
|
496
496
|
try {
|
|
@@ -506,7 +506,7 @@ async function listFailure(e, r, path, signal, logUnavailable) {
|
|
|
506
506
|
if (st === null)
|
|
507
507
|
return pathMissing(path);
|
|
508
508
|
return new ApiError("device.project_path_unreadable", st.isDir
|
|
509
|
-
? `${clipped(path)} is a directory the device cannot read
|
|
509
|
+
? `${clipped(path)} is a directory the device cannot read`
|
|
510
510
|
: `${clipped(path)} is a file, not a directory`);
|
|
511
511
|
}
|
|
512
512
|
const relativeTo = (base, path) => path === base ? "" : posix.relative(base, path);
|
|
@@ -357,18 +357,21 @@ export declare class DevicesService {
|
|
|
357
357
|
*/
|
|
358
358
|
lockNetworkAddSubject(orgId: string, accountId: string, deviceId: string): Promise<void>;
|
|
359
359
|
/**
|
|
360
|
-
* Adds `hosts` to one of the person's devices' own network list: a network approval decided
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
360
|
+
* Adds `hosts` to one of the person's devices' own network list: a network approval decided "add
|
|
361
|
+
* to this device's list" (`via`: where it was decided). In a caller's transaction (the approval
|
|
362
|
+
* decision's) it joins it and requires the authority locks of that prelude already held there
|
|
363
|
+
* (platform and org shared, the device exclusive: {@link lockNetworkAddSubject} in the caller's
|
|
364
|
+
* ordered prelude; else it throws before locking or writing anything; the membership and device
|
|
365
|
+
* rows are locked again in the body); with no transaction it takes that prelude itself
|
|
366
|
+
* ({@link withOrderedLocks}). It takes no distributed lock. The write is a network change like `PATCH`
|
|
367
|
+
* ({@link networkLocked}: audited `device.network_changed` from → to, listed as a recent change,
|
|
368
|
+
* the device epoch bumped and the instance marked for its next use). Refuses with
|
|
369
|
+
* `device.network_not_allowed`, writing nothing, unless the stored network is `allowlist` with a
|
|
370
|
+
* host list of its own (a device following its org's hosts already allows every host its list
|
|
371
|
+
* could name) and every host may join that list (`deviceListAddRefusal`); its detail `reason`
|
|
372
|
+
* says which (`network_closed`, `follows_org`, `host_not_addable`), for the decision's copy.
|
|
373
|
+
* Hosts its list already covers change nothing; own hosts the org's hosts no longer cover (in
|
|
374
|
+
* effect nowhere) leave the list with the addition.
|
|
372
375
|
*/
|
|
373
376
|
addNetworkHostsIn(orgId: string, accountId: string, deviceId: string, hosts: string[], via: "web" | "im"): Promise<void>;
|
|
374
377
|
/** {@link addNetworkHostsIn} under the locks of its prelude (naming them again re-checks). */
|
|
@@ -25,10 +25,10 @@ import { assertNotSharedAdmission, currentStore, TransactionHost, withOrderedLoc
|
|
|
25
25
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
26
26
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
27
27
|
import { DeviceReports } from "../sandbox/device-reports.js";
|
|
28
|
-
import { hostGrantable } from "../sandbox/device-sandbox.js";
|
|
28
|
+
import { deviceSideLayer, hostGrantable } from "../sandbox/device-sandbox.js";
|
|
29
29
|
import { oweDeviceDestroy, SandboxJobs } from "../sandbox/jobs.js";
|
|
30
30
|
import { coversHost } from "../sandbox/modes.js";
|
|
31
|
-
import {
|
|
31
|
+
import { assertAuthorityWriteHeld } from "../sandbox/permission-authority-lock.js";
|
|
32
32
|
import { hostsNarrowed, needsOpenNetwork, PermissionCeilingWrites, } from "../sandbox/permission-ceiling-writes.js";
|
|
33
33
|
import { ownNetwork, PermissionFacts } from "../sandbox/permission-facts.js";
|
|
34
34
|
import { DeviceProviders, servesDialIn } from "../sandbox/providers.js";
|
|
@@ -439,7 +439,7 @@ let DevicesService = class DevicesService {
|
|
|
439
439
|
}),
|
|
440
440
|
]);
|
|
441
441
|
if (to.mode === "open" && next.box.networkMode !== "open")
|
|
442
|
-
throw new ApiError("device.network_not_allowed", `The open network is not allowed for this device: ${networkLayerText(next.box.layer.network)} limits it to ${next.box.networkCeiling === "none" ? "no network" : "the allowlist"}`);
|
|
442
|
+
throw new ApiError("device.network_not_allowed", `The open network is not allowed for this device: ${networkLayerText(next.box.layer.network)} limits it to ${next.box.networkCeiling === "none" ? "no network" : "the allowlist"}${deviceSideLayer(next.box.layer.network) && next.changeHint ? ` (to change this, as the device's provider says: ${next.changeHint.trim().replace(/\.$/, "")})` : ""}`);
|
|
443
443
|
// a device's own list only narrows its org's hosts, whatever the network in effect now
|
|
444
444
|
const outside = to.hosts.filter((h) => !next.orgHosts.some((p) => coversHost(p.toLowerCase(), h)));
|
|
445
445
|
if (outside.length > 0)
|
|
@@ -504,22 +504,26 @@ let DevicesService = class DevicesService {
|
|
|
504
504
|
await this.lockNetworkSubject(orgId, accountId, deviceId);
|
|
505
505
|
}
|
|
506
506
|
/**
|
|
507
|
-
* Adds `hosts` to one of the person's devices' own network list: a network approval decided
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
507
|
+
* Adds `hosts` to one of the person's devices' own network list: a network approval decided "add
|
|
508
|
+
* to this device's list" (`via`: where it was decided). In a caller's transaction (the approval
|
|
509
|
+
* decision's) it joins it and requires the authority locks of that prelude already held there
|
|
510
|
+
* (platform and org shared, the device exclusive: {@link lockNetworkAddSubject} in the caller's
|
|
511
|
+
* ordered prelude; else it throws before locking or writing anything; the membership and device
|
|
512
|
+
* rows are locked again in the body); with no transaction it takes that prelude itself
|
|
513
|
+
* ({@link withOrderedLocks}). It takes no distributed lock. The write is a network change like `PATCH`
|
|
514
|
+
* ({@link networkLocked}: audited `device.network_changed` from → to, listed as a recent change,
|
|
515
|
+
* the device epoch bumped and the instance marked for its next use). Refuses with
|
|
516
|
+
* `device.network_not_allowed`, writing nothing, unless the stored network is `allowlist` with a
|
|
517
|
+
* host list of its own (a device following its org's hosts already allows every host its list
|
|
518
|
+
* could name) and every host may join that list (`deviceListAddRefusal`); its detail `reason`
|
|
519
|
+
* says which (`network_closed`, `follows_org`, `host_not_addable`), for the decision's copy.
|
|
520
|
+
* Hosts its list already covers change nothing; own hosts the org's hosts no longer cover (in
|
|
521
|
+
* effect nowhere) leave the list with the addition.
|
|
519
522
|
*/
|
|
520
523
|
async addNetworkHostsIn(orgId, accountId, deviceId, hosts, via) {
|
|
521
524
|
if (currentStore() !== undefined) {
|
|
522
|
-
|
|
525
|
+
// every authority level the prelude takes: platform and org shared, the device exclusive
|
|
526
|
+
assertAuthorityWriteHeld({ orgId, deviceId }, "device");
|
|
523
527
|
await this.addNetworkHostsLocked(orgId, accountId, deviceId, hosts, via);
|
|
524
528
|
return;
|
|
525
529
|
}
|
|
@@ -536,9 +540,9 @@ let DevicesService = class DevicesService {
|
|
|
536
540
|
.executeTakeFirstOrThrow();
|
|
537
541
|
const own = ownNetwork(row);
|
|
538
542
|
if (own.networkMode === "none")
|
|
539
|
-
throw new ApiError("device.network_not_allowed", "Network access is turned off for this device's sandbox; its owner changes that on the device page");
|
|
543
|
+
throw new ApiError("device.network_not_allowed", "Network access is turned off for this device's sandbox; its owner changes that on the device page", [{ reason: "network_closed" }]);
|
|
540
544
|
if (own.networkMode !== "allowlist" || own.networkHosts.length === 0)
|
|
541
|
-
throw new ApiError("device.network_not_allowed", "This device has no host list of its own: it follows its organization's hosts, which already include every host its list could name; an organization admin adds another host to the organization's device network list");
|
|
545
|
+
throw new ApiError("device.network_not_allowed", "This device has no host list of its own: it follows its organization's hosts, which already include every host its list could name; an organization admin adds another host to the organization's device network list", [{ reason: "follows_org" }]);
|
|
542
546
|
const wanted = [...new Set(hosts.map((h) => h.toLowerCase()))];
|
|
543
547
|
for (const host of wanted) {
|
|
544
548
|
const invalid = validateAllowHost(host);
|
|
@@ -551,7 +555,7 @@ let DevicesService = class DevicesService {
|
|
|
551
555
|
for (const host of wanted) {
|
|
552
556
|
const why = facts.listAddRefusal(host);
|
|
553
557
|
if (why !== null)
|
|
554
|
-
throw new ApiError("device.network_not_allowed", `${host} cannot be added to this device's network list: ${why}
|
|
558
|
+
throw new ApiError("device.network_not_allowed", `${host} cannot be added to this device's network list: ${why}`, [{ reason: "host_not_addable" }]);
|
|
555
559
|
}
|
|
556
560
|
const covers = (list, h) => list.some((p) => coversHost(p.toLowerCase(), h));
|
|
557
561
|
// own hosts the org dropped since are in effect nowhere: they would refuse the new list
|
|
@@ -1143,6 +1147,8 @@ function networkLayerText(layer) {
|
|
|
1143
1147
|
return "the organization (an org admin)";
|
|
1144
1148
|
case "provider":
|
|
1145
1149
|
return "its sandbox provider";
|
|
1150
|
+
case "owner":
|
|
1151
|
+
return "the owner of the machine it runs on";
|
|
1146
1152
|
default:
|
|
1147
1153
|
return "its owner";
|
|
1148
1154
|
}
|
|
@@ -3,7 +3,6 @@ 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
5
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
6
|
-
import { DeviceProviders } from "../sandbox/providers.js";
|
|
7
6
|
import { DialInRelay } from "./relay.js";
|
|
8
7
|
/** The machine credential's prefix (`cap_dev_` plus 32 random bytes, base64url). */
|
|
9
8
|
export declare const MACHINE_CREDENTIAL_PREFIX = "cap_dev_";
|
|
@@ -57,8 +56,7 @@ export declare class DialInMachines {
|
|
|
57
56
|
private readonly bus;
|
|
58
57
|
private readonly log;
|
|
59
58
|
private readonly ceilings;
|
|
60
|
-
|
|
61
|
-
constructor(db: KernelDb, txHost: TransactionHost, relay: Pick<DialInRelay, "stop">, bus: ExtensionContext["bus"], log: Pick<KernelLogger, "warn">, ceilings: PermissionCeilingWrites, providers: Pick<DeviceProviders, "forDevice">);
|
|
59
|
+
constructor(db: KernelDb, txHost: TransactionHost, relay: Pick<DialInRelay, "stop">, bus: ExtensionContext["bus"], log: Pick<KernelLogger, "warn">, ceilings: PermissionCeilingWrites);
|
|
62
60
|
/**
|
|
63
61
|
* A new machine for the device and its credential (returned once). Revokes the
|
|
64
62
|
* device's active machine first. Joins the caller's transaction (the device confirmation),
|
|
@@ -113,19 +111,11 @@ export declare class DialInMachines {
|
|
|
113
111
|
}): Promise<void>;
|
|
114
112
|
/** Marks the machine seen (a ping); writes at most once every 60 seconds. */
|
|
115
113
|
touch(machineId: string): Promise<void>;
|
|
116
|
-
/**
|
|
117
|
-
* Disconnects the machine of one of the person's own live dial-in devices, whatever its
|
|
118
|
-
* provider: revokes it and audits `device.machine_revoked`. No route calls it (the device page
|
|
119
|
-
* no longer disconnects a machine; deleting the device revokes it, {@link revokeActive}); the
|
|
120
|
-
* kernel tests revoke a connected machine with it. Anyone else's device, a cloud one or a
|
|
121
|
-
* missing one → `device.not_found`; no machine connected is a no-op.
|
|
122
|
-
*/
|
|
123
|
-
revoke(orgId: string, accountId: string, deviceId: string, actorTokenId?: string): Promise<void>;
|
|
124
114
|
/**
|
|
125
115
|
* Revokes the device's active machine, if any, in the caller's transaction, and after the
|
|
126
116
|
* commit tells it to stop (not when `replaced`) and closes its connection for `reason`. Returns
|
|
127
|
-
* the revoked machine's id. Used by {@link issue} (`replaced`)
|
|
128
|
-
*
|
|
117
|
+
* the revoked machine's id. Used by {@link issue} (`replaced`) and the device's deletion
|
|
118
|
+
* (`deleted`).
|
|
129
119
|
*/
|
|
130
120
|
revokeActive(deviceId: string, reason: MachineRevocationReason): Promise<string | null>;
|
|
131
121
|
/**
|
|
@@ -133,8 +123,6 @@ export declare class DialInMachines {
|
|
|
133
123
|
* same post-commit disconnect as a replacement (no stop frame). True when it was active.
|
|
134
124
|
*/
|
|
135
125
|
revokeMachine(machineId: string): Promise<boolean>;
|
|
136
|
-
/** Whether a machine ever signed in to the device (revoked or not). */
|
|
137
|
-
private everSignedIn;
|
|
138
126
|
/** The device's active machine, or null. */
|
|
139
127
|
activeFor(deviceId: string): Promise<ActiveMachine | null>;
|
|
140
128
|
/**
|
package/dist/dial-in/machines.js
CHANGED
|
@@ -11,8 +11,6 @@ import { randomBytes } from "node:crypto";
|
|
|
11
11
|
import { isDeviceBootId } from "@capybara-hq/plugin-sdk/device-protocol";
|
|
12
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
|
-
import { deviceNotFound } from "../devices/errors.js";
|
|
15
|
-
import { audit } from "../identity/audit.js";
|
|
16
14
|
import { sha256Hex } from "../identity/hash.js";
|
|
17
15
|
import { afterCommit } from "../infra/database/after-commit.js";
|
|
18
16
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -20,7 +18,6 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
20
18
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
21
19
|
import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
|
|
22
20
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
23
|
-
import { DeviceProviders, servesDialIn } from "../sandbox/providers.js";
|
|
24
21
|
import { deviceRevokedTopic } from "./keys.js";
|
|
25
22
|
import { DialInRelay } from "./relay.js";
|
|
26
23
|
/** The machine credential's prefix (`cap_dev_` plus 32 random bytes, base64url). */
|
|
@@ -44,15 +41,13 @@ let DialInMachines = class DialInMachines {
|
|
|
44
41
|
bus;
|
|
45
42
|
log;
|
|
46
43
|
ceilings;
|
|
47
|
-
|
|
48
|
-
constructor(db, txHost, relay, bus, log, ceilings, providers) {
|
|
44
|
+
constructor(db, txHost, relay, bus, log, ceilings) {
|
|
49
45
|
this.db = db;
|
|
50
46
|
this.txHost = txHost;
|
|
51
47
|
this.relay = relay;
|
|
52
48
|
this.bus = bus;
|
|
53
49
|
this.log = log;
|
|
54
50
|
this.ceilings = ceilings;
|
|
55
|
-
this.providers = providers;
|
|
56
51
|
}
|
|
57
52
|
/**
|
|
58
53
|
* A new machine for the device and its credential (returned once). Revokes the
|
|
@@ -196,48 +191,11 @@ let DialInMachines = class DialInMachines {
|
|
|
196
191
|
]))
|
|
197
192
|
.execute();
|
|
198
193
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Disconnects the machine of one of the person's own live dial-in devices, whatever its
|
|
201
|
-
* provider: revokes it and audits `device.machine_revoked`. No route calls it (the device page
|
|
202
|
-
* no longer disconnects a machine; deleting the device revokes it, {@link revokeActive}); the
|
|
203
|
-
* kernel tests revoke a connected machine with it. Anyone else's device, a cloud one or a
|
|
204
|
-
* missing one → `device.not_found`; no machine connected is a no-op.
|
|
205
|
-
*/
|
|
206
|
-
async revoke(orgId, accountId, deviceId, actorTokenId) {
|
|
207
|
-
const env = await this.db
|
|
208
|
-
.selectFrom("devices")
|
|
209
|
-
.select(["id", "provider"])
|
|
210
|
-
.where("id", "=", deviceId)
|
|
211
|
-
.where("org_id", "=", orgId)
|
|
212
|
-
.where("owner_kind", "=", "personal")
|
|
213
|
-
.where("owner_account_id", "=", accountId)
|
|
214
|
-
.where("deleted_at", "is", null)
|
|
215
|
-
.forNoKeyUpdate()
|
|
216
|
-
.executeTakeFirst();
|
|
217
|
-
if (!env)
|
|
218
|
-
throw deviceNotFound();
|
|
219
|
-
// a dial-in device: its provider serves the dial-in channel, or a machine signed in to it
|
|
220
|
-
// (its provider may be unloaded here, and the person disconnects anyway)
|
|
221
|
-
const p = this.providers.forDevice(env.provider);
|
|
222
|
-
if (!(p !== undefined && servesDialIn(p)) && !(await this.everSignedIn(deviceId)))
|
|
223
|
-
throw deviceNotFound();
|
|
224
|
-
const machineId = await this.revokeActive(deviceId, "revoked");
|
|
225
|
-
if (machineId === null)
|
|
226
|
-
return;
|
|
227
|
-
await audit(this.db.db, {
|
|
228
|
-
actorAccountId: accountId,
|
|
229
|
-
...(actorTokenId !== undefined && { actorTokenId }),
|
|
230
|
-
orgId,
|
|
231
|
-
action: "device.machine_revoked",
|
|
232
|
-
target: deviceId,
|
|
233
|
-
detail: { machineId },
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
194
|
/**
|
|
237
195
|
* Revokes the device's active machine, if any, in the caller's transaction, and after the
|
|
238
196
|
* commit tells it to stop (not when `replaced`) and closes its connection for `reason`. Returns
|
|
239
|
-
* the revoked machine's id. Used by {@link issue} (`replaced`)
|
|
240
|
-
*
|
|
197
|
+
* the revoked machine's id. Used by {@link issue} (`replaced`) and the device's deletion
|
|
198
|
+
* (`deleted`).
|
|
241
199
|
*/
|
|
242
200
|
async revokeActive(deviceId, reason) {
|
|
243
201
|
const device = await this.db
|
|
@@ -287,16 +245,6 @@ let DialInMachines = class DialInMachines {
|
|
|
287
245
|
afterCommit(() => this.disconnect(deviceId, machineId, "revoked", { stop: false }));
|
|
288
246
|
return true;
|
|
289
247
|
}
|
|
290
|
-
/** Whether a machine ever signed in to the device (revoked or not). */
|
|
291
|
-
async everSignedIn(deviceId) {
|
|
292
|
-
const row = await this.db
|
|
293
|
-
.selectFrom("device_machines")
|
|
294
|
-
.select("id")
|
|
295
|
-
.where("device_id", "=", deviceId)
|
|
296
|
-
.limit(1)
|
|
297
|
-
.executeTakeFirst();
|
|
298
|
-
return row !== undefined;
|
|
299
|
-
}
|
|
300
248
|
/** The device's active machine, or null. */
|
|
301
249
|
async activeFor(deviceId) {
|
|
302
250
|
const r = await this.db
|
|
@@ -358,9 +306,6 @@ __decorate([
|
|
|
358
306
|
__decorate([
|
|
359
307
|
Transactional()
|
|
360
308
|
], DialInMachines.prototype, "recordConnect", null);
|
|
361
|
-
__decorate([
|
|
362
|
-
Transactional()
|
|
363
|
-
], DialInMachines.prototype, "revoke", null);
|
|
364
309
|
__decorate([
|
|
365
310
|
Transactional()
|
|
366
311
|
], DialInMachines.prototype, "revokeActive", null);
|
|
@@ -374,8 +319,7 @@ DialInMachines = __decorate([
|
|
|
374
319
|
__param(2, Inject(DialInRelay)),
|
|
375
320
|
__param(3, Inject(KERNEL_BUS)),
|
|
376
321
|
__param(4, Inject(KERNEL_LOGGER)),
|
|
377
|
-
__param(5, Inject(PermissionCeilingWrites))
|
|
378
|
-
__param(6, Inject(DeviceProviders))
|
|
322
|
+
__param(5, Inject(PermissionCeilingWrites))
|
|
379
323
|
], DialInMachines);
|
|
380
324
|
export { DialInMachines };
|
|
381
325
|
/** Two machine rows (or a login) name the same machine: same name, OS and arch. */
|
|
@@ -27,13 +27,11 @@ export const MetaResponseSchema = z.object({
|
|
|
27
27
|
protocols: z.object({
|
|
28
28
|
/**
|
|
29
29
|
* The `capybara-device` protocol majors the loaded dial-in providers speak (their
|
|
30
|
-
* `permissions.dialIn.protocol`); without any, the SDK's major
|
|
30
|
+
* `permissions.dialIn.protocol`); without any, the SDK's major.
|
|
31
31
|
*/
|
|
32
32
|
device: z.object({ min: z.number().int(), max: z.number().int() }),
|
|
33
33
|
}),
|
|
34
34
|
features: z.object({
|
|
35
|
-
/** A dial-in provider speaking `capybara-device/<major>` (device-local) is loaded. */
|
|
36
|
-
localDevices: z.boolean(),
|
|
37
35
|
appSignIn: z.boolean(),
|
|
38
36
|
/** App ids a push provider covers with the providers that do; `[]` without `http.publicUrl`. */
|
|
39
37
|
push: z.array(z.object({ appId: z.string(), providers: z.array(z.string()) })),
|
|
@@ -77,8 +75,7 @@ let MetaController = class MetaController {
|
|
|
77
75
|
this.iconUrl("favicon"),
|
|
78
76
|
]);
|
|
79
77
|
const appSignIn = Boolean(config.http.publicUrl);
|
|
80
|
-
//
|
|
81
|
-
// (device-local); the shells offer "connect this machine" only then.
|
|
78
|
+
// The capybara-device majors the loaded dial-in providers (device-local) speak.
|
|
82
79
|
const devices = deviceProtocolRange(this.dialIn.loaded().map((p) => p.protocol));
|
|
83
80
|
return {
|
|
84
81
|
name: config.platform.name ?? null,
|
|
@@ -88,7 +85,6 @@ let MetaController = class MetaController {
|
|
|
88
85
|
device: devices ?? { min: DEVICE_PROTOCOL_VERSION, max: DEVICE_PROTOCOL_VERSION },
|
|
89
86
|
},
|
|
90
87
|
features: {
|
|
91
|
-
localDevices: devices !== null,
|
|
92
88
|
// The authorize route answers app_auth.unavailable without http.publicUrl.
|
|
93
89
|
appSignIn,
|
|
94
90
|
// A push message carries the deployment origin, which needs http.publicUrl.
|
|
@@ -10,8 +10,17 @@ import type { SandboxBoundary, SandboxPermissionSupport } from "@capybara-hq/plu
|
|
|
10
10
|
*/
|
|
11
11
|
/** The sandbox network: the open public internet or an allowlist. `allowlist` is narrower. */
|
|
12
12
|
export type DeviceNetworkMode = "open" | "allowlist";
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The layer that set a ceiling, named by a disabled option and an actionable error. `owner` is the
|
|
15
|
+
* owner of the machine the device runs on, when its provider says that owner keeps the crossing
|
|
16
|
+
* closed (`SandboxPermissionSupport.limitedBy`); `provider` is the provider's own limit.
|
|
17
|
+
*/
|
|
18
|
+
export type DeviceSandboxLayer = "platform" | "org" | "device" | "owner" | "provider";
|
|
19
|
+
/**
|
|
20
|
+
* Whether a ceiling's layer is the device's side (its provider, or the owner of the machine it
|
|
21
|
+
* runs on): it clamps the sandbox network, never what an org allows per call.
|
|
22
|
+
*/
|
|
23
|
+
export declare const deviceSideLayer: (layer: DeviceSandboxLayer | null | undefined) => boolean;
|
|
15
24
|
/**
|
|
16
25
|
* The platform's device sandbox settings, as the settings reader returns them (env > file / Nacos >
|
|
17
26
|
* the super admin's stored choice > default `allowed`, `open`, `open`).
|
|
@@ -71,6 +80,11 @@ export interface DeviceSandboxProviderLayer {
|
|
|
71
80
|
perOperationHosts: boolean;
|
|
72
81
|
};
|
|
73
82
|
outsideSandbox: boolean;
|
|
83
|
+
/** Who keeps a closed crossing closed when not the provider itself (support `limitedBy`). */
|
|
84
|
+
limitedBy?: {
|
|
85
|
+
outsideSandbox?: "owner";
|
|
86
|
+
openPublic?: "owner";
|
|
87
|
+
};
|
|
74
88
|
}
|
|
75
89
|
/** The effective device sandbox: the same under every permission profile. */
|
|
76
90
|
export interface DeviceSandbox {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { coversHost, orgEffectiveHosts } from "./modes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a ceiling's layer is the device's side (its provider, or the owner of the machine it
|
|
4
|
+
* runs on): it clamps the sandbox network, never what an org allows per call.
|
|
5
|
+
*/
|
|
6
|
+
export const deviceSideLayer = (layer) => layer === "provider" || layer === "owner";
|
|
2
7
|
/**
|
|
3
8
|
* The hosts of `a` the list `b` covers and the hosts of `b` that `a` covers (wildcards included),
|
|
4
9
|
* lowercased, deduplicated and sorted: never wider than either list.
|
|
@@ -43,9 +48,11 @@ export function effectiveDeviceSandbox(platform, org, device, provider) {
|
|
|
43
48
|
? "platform"
|
|
44
49
|
: org.outsideSandbox === "off"
|
|
45
50
|
? "org"
|
|
46
|
-
:
|
|
51
|
+
: instance
|
|
47
52
|
? "provider"
|
|
48
|
-
:
|
|
53
|
+
: !provider.outsideSandbox
|
|
54
|
+
? (provider.limitedBy?.outsideSandbox ?? "provider")
|
|
55
|
+
: null;
|
|
49
56
|
// the network ceiling: platform, then org, then what the provider can enforce
|
|
50
57
|
let ceiling;
|
|
51
58
|
let networkLayer = null;
|
|
@@ -69,7 +76,7 @@ export function effectiveDeviceSandbox(platform, org, device, provider) {
|
|
|
69
76
|
}
|
|
70
77
|
else if (ceiling === "open" && !provider.network.openPublic) {
|
|
71
78
|
ceiling = "allowlist";
|
|
72
|
-
networkLayer = "provider";
|
|
79
|
+
networkLayer = provider.limitedBy?.openPublic ?? "provider";
|
|
73
80
|
}
|
|
74
81
|
// the device's choice, else the org default, else the platform default; then the ceiling
|
|
75
82
|
const chosen = device.networkMode ?? org.deviceNetwork?.default ?? platform.settings.network.default;
|
|
@@ -116,6 +123,7 @@ export function providerLayerOf(support) {
|
|
|
116
123
|
boundary: support.boundary,
|
|
117
124
|
network: { ...support.network },
|
|
118
125
|
outsideSandbox: support.outsideSandbox,
|
|
126
|
+
...(support.limitedBy !== undefined && { limitedBy: { ...support.limitedBy } }),
|
|
119
127
|
};
|
|
120
128
|
return {
|
|
121
129
|
boundary: "instance",
|
|
@@ -131,7 +139,7 @@ export function hostGrantCeiling(box, platform, org) {
|
|
|
131
139
|
return { kind: "hosts", hosts: [] };
|
|
132
140
|
// the platform's or org's allowlist ceiling is hard; a provider that cannot enforce the open
|
|
133
141
|
// network clamps the sandbox network, not what an org allows per call
|
|
134
|
-
const hard = box.networkCeiling === "allowlist" && box.layer?.network
|
|
142
|
+
const hard = box.networkCeiling === "allowlist" && !deviceSideLayer(box.layer?.network);
|
|
135
143
|
return hard || platform.orgHosts === "within"
|
|
136
144
|
? { kind: "hosts", hosts: orgHostsOf(platform, org) }
|
|
137
145
|
: {
|
|
@@ -169,7 +177,7 @@ export function hostGrantRefusal(host, box, platform, org) {
|
|
|
169
177
|
return "network access is turned off for this device's sandbox";
|
|
170
178
|
if (box.boundary === "instance" || box.perCallHosts === false)
|
|
171
179
|
return `a host cannot be granted per call on this device; add ${host} to the device's network list`;
|
|
172
|
-
return (box.networkCeiling === "allowlist" && box.layer?.network
|
|
180
|
+
return (box.networkCeiling === "allowlist" && !deviceSideLayer(box.layer?.network)) ||
|
|
173
181
|
ceiling.kind === "any"
|
|
174
182
|
? `an organization admin adds ${host} to the organization's device network list`
|
|
175
183
|
: `${host} is outside the platform's host list; a super admin adds the host`;
|
|
@@ -495,6 +495,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
|
|
|
495
495
|
layer: sandbox.layer.outsideSandbox,
|
|
496
496
|
boundary: sandbox.boundary,
|
|
497
497
|
description: base.description,
|
|
498
|
+
changeHint: base.changeHint,
|
|
498
499
|
})
|
|
499
500
|
: null;
|
|
500
501
|
const vector = await this.epochs.readLocked(subject);
|
|
@@ -568,7 +569,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
|
|
|
568
569
|
*/
|
|
569
570
|
async baseScopeLocked(input) {
|
|
570
571
|
const { orgId, deviceId } = input;
|
|
571
|
-
const { policy, sandbox, hostCeiling, hostRefusal, description } = await this.facts.readDevice(orgId, deviceId);
|
|
572
|
+
const { policy, sandbox, hostCeiling, hostRefusal, description, changeHint } = await this.facts.readDevice(orgId, deviceId);
|
|
572
573
|
const { workingRoot, projectRoot } = await this.workingRootOf(input);
|
|
573
574
|
const grant = input.runId
|
|
574
575
|
? await this.grants.forExec({ orgId, deviceId, runId: input.runId })
|
|
@@ -581,6 +582,7 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
|
|
|
581
582
|
return {
|
|
582
583
|
policy,
|
|
583
584
|
description,
|
|
585
|
+
changeHint,
|
|
584
586
|
workingRoot,
|
|
585
587
|
projectRoot,
|
|
586
588
|
grant,
|
|
@@ -36,3 +36,9 @@ export declare class PermissionAuthorityLock {
|
|
|
36
36
|
}
|
|
37
37
|
/** The current transaction holds this authority lock (exclusively when asked); else throws. */
|
|
38
38
|
export declare function assertAuthorityHeld(kind: AuthorityLevel, id: string, exclusive?: boolean): void;
|
|
39
|
+
/**
|
|
40
|
+
* The current transaction holds every authority lock a write of `level` on `subject` takes
|
|
41
|
+
* ({@link PermissionAuthorityLock.acquire}): each level above `level` (shared or stronger) and
|
|
42
|
+
* `level` itself exclusively; else throws before the caller writes anything.
|
|
43
|
+
*/
|
|
44
|
+
export declare function assertAuthorityWriteHeld(subject: AuthoritySubject, level: AuthorityLevel): void;
|
|
@@ -145,3 +145,17 @@ export function assertAuthorityHeld(kind, id, exclusive = false) {
|
|
|
145
145
|
if (!held || (exclusive && held !== "exclusive"))
|
|
146
146
|
throw new Error("The matching authority lock is required");
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* The current transaction holds every authority lock a write of `level` on `subject` takes
|
|
150
|
+
* ({@link PermissionAuthorityLock.acquire}): each level above `level` (shared or stronger) and
|
|
151
|
+
* `level` itself exclusively; else throws before the caller writes anything.
|
|
152
|
+
*/
|
|
153
|
+
export function assertAuthorityWriteHeld(subject, level) {
|
|
154
|
+
const entries = authorityEntries(subject);
|
|
155
|
+
const stop = entries.findIndex(([l]) => l === level);
|
|
156
|
+
if (stop < 0)
|
|
157
|
+
throw new Error("The changed authority level is missing");
|
|
158
|
+
entries.slice(0, stop + 1).forEach(([l, id], i) => {
|
|
159
|
+
assertAuthorityHeld(l, id, i === stop);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
@@ -47,6 +47,8 @@ export declare class PermissionFacts {
|
|
|
47
47
|
hostRefusal: (host: string) => string | null;
|
|
48
48
|
/** The provider's description of the device (its stored report, English), or null. */
|
|
49
49
|
description: string | null;
|
|
50
|
+
/** How to change the device's limits, in its provider's words (stored report, English). */
|
|
51
|
+
changeHint: string | null;
|
|
50
52
|
}>;
|
|
51
53
|
/**
|
|
52
54
|
* The effective device sandbox (approval-only profiles design, "Settings model"): the platform,
|
|
@@ -83,6 +85,8 @@ export declare class PermissionFacts {
|
|
|
83
85
|
/** Why a host cannot be added to the device's own network list ({@link deviceListAddRefusal}). */
|
|
84
86
|
listAddRefusal: (host: string) => string | null;
|
|
85
87
|
description: string | null;
|
|
88
|
+
/** How to change the device's limits, in its provider's words (English), or null. */
|
|
89
|
+
changeHint: string | null;
|
|
86
90
|
/**
|
|
87
91
|
* The device's network is an allowlist with a host list of its own: only then can a host
|
|
88
92
|
* join that list (`DevicesService.addNetworkHostsIn`); a device following its org's hosts
|
|
@@ -73,6 +73,8 @@ let PermissionFacts = class PermissionFacts {
|
|
|
73
73
|
hostRefusal: sandbox.refusal,
|
|
74
74
|
/** The provider's description of the device (its stored report, English), or null. */
|
|
75
75
|
description: sandbox.description,
|
|
76
|
+
/** How to change the device's limits, in its provider's words (stored report, English). */
|
|
77
|
+
changeHint: sandbox.changeHint,
|
|
76
78
|
};
|
|
77
79
|
}
|
|
78
80
|
/**
|
|
@@ -131,6 +133,7 @@ let PermissionFacts = class PermissionFacts {
|
|
|
131
133
|
...(org.deviceNetwork !== undefined && { deviceNetwork: org.deviceNetwork }),
|
|
132
134
|
};
|
|
133
135
|
const box = effectiveDeviceSandbox(platform, orgLayer, device, providerLayerOf(support));
|
|
136
|
+
const report = storedReport(row?.report);
|
|
134
137
|
const hostCeiling = hostGrantCeiling(box, platform, orgLayer);
|
|
135
138
|
return {
|
|
136
139
|
box,
|
|
@@ -140,7 +143,9 @@ let PermissionFacts = class PermissionFacts {
|
|
|
140
143
|
refusal: (host) => hostGrantRefusal(host, box, platform, orgLayer),
|
|
141
144
|
/** Why a host cannot be added to the device's own network list ({@link deviceListAddRefusal}). */
|
|
142
145
|
listAddRefusal: (host) => deviceListAddRefusal(host, box, platform, orgLayer),
|
|
143
|
-
description:
|
|
146
|
+
description: report?.description.en ?? null,
|
|
147
|
+
/** How to change the device's limits, in its provider's words (English), or null. */
|
|
148
|
+
changeHint: report?.changeHint?.en ?? null,
|
|
144
149
|
/**
|
|
145
150
|
* The device's network is an allowlist with a host list of its own: only then can a host
|
|
146
151
|
* join that list (`DevicesService.addNetworkHostsIn`); a device following its org's hosts
|
|
@@ -36,27 +36,32 @@ export declare const ESCALATION_JUSTIFICATION_MISSING_TEXT = "This Bash call ask
|
|
|
36
36
|
/** Why an escalation cannot be reviewed: an unattended run (no one can approve it). */
|
|
37
37
|
export declare const ESCALATION_UNATTENDED_WHY = "this is an unattended run (a scheduled task) where no one can approve running outside the sandbox";
|
|
38
38
|
/**
|
|
39
|
-
* Why an escalation cannot be reviewed because
|
|
40
|
-
*
|
|
39
|
+
* Why an escalation cannot be reviewed because the device's provider does not allow running
|
|
40
|
+
* outside its sandbox now, with the provider's own description of the device and how to change it
|
|
41
|
+
* (its report's `description` and `changeHint`).
|
|
41
42
|
*/
|
|
43
|
+
export declare const escalationDeviceOffWhy: (description: string | null, changeHint?: string | null) => string;
|
|
42
44
|
/**
|
|
43
|
-
* Why an escalation cannot be reviewed because the
|
|
44
|
-
* outside
|
|
45
|
+
* Why an escalation cannot be reviewed because the owner of the machine the device runs on keeps
|
|
46
|
+
* running outside the sandbox off (the provider names that layer, support `limitedBy`), with the
|
|
47
|
+
* provider's description of the device and how to change it.
|
|
45
48
|
*/
|
|
46
|
-
export declare const
|
|
49
|
+
export declare const escalationOwnerOffWhy: (description: string | null, changeHint?: string | null) => string;
|
|
47
50
|
export declare const ESCALATION_ORG_OFF_WHY = "running commands outside the sandbox is off in this organization; an organization admin can allow running outside the sandbox";
|
|
48
51
|
export declare const ESCALATION_PLATFORM_OFF_WHY = "running commands outside the sandbox is off on this platform; a super admin can allow running outside the sandbox";
|
|
49
52
|
export declare const ESCALATION_NO_OUTSIDE_WHY = "this device is an instance that is itself the sandbox, so this device has no outside of its sandbox to run a command in";
|
|
50
53
|
/**
|
|
51
54
|
* The refusal text of an escalation that a layer's outside-sandbox setting blocks, the same for
|
|
52
55
|
* every provider: an instance-boundary provider has no outside at all, whichever layer is off;
|
|
53
|
-
* otherwise the platform or the org names who lifts it, and
|
|
54
|
-
* allow it now says so with
|
|
56
|
+
* otherwise the platform or the org names who lifts it, and the owner of the machine or a provider
|
|
57
|
+
* whose support does not allow it now says so with the device's report (`description`, and
|
|
58
|
+
* `changeHint`: how to change it, in the provider's words).
|
|
55
59
|
*/
|
|
56
60
|
export declare const escalationCeilingWhy: (input: {
|
|
57
61
|
layer: DeviceSandboxLayer | null;
|
|
58
62
|
boundary: "operation" | "instance";
|
|
59
63
|
description?: string | null;
|
|
64
|
+
changeHint?: string | null;
|
|
60
65
|
}) => string;
|
|
61
66
|
/** Why an escalation cannot be reviewed: the runtime cannot run a command outside its sandbox now. */
|
|
62
67
|
export declare const escalationRuntimeWhy: (reason: string) => string;
|
|
@@ -80,22 +80,41 @@ export const ESCALATION_JUSTIFICATION_MISSING_TEXT = 'This Bash call asked to ru
|
|
|
80
80
|
/** Why an escalation cannot be reviewed: an unattended run (no one can approve it). */
|
|
81
81
|
export const ESCALATION_UNATTENDED_WHY = "this is an unattended run (a scheduled task) where no one can approve running outside the sandbox";
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
83
|
+
* The device's own words appended to a refusal that cites its report: its description (what the
|
|
84
|
+
* device may do now) and its change hint (who changes that and how), each without a final period,
|
|
85
|
+
* as one parenthesis-free tail of a clause.
|
|
85
86
|
*/
|
|
87
|
+
function reportTail(description, changeHint) {
|
|
88
|
+
const clean = (t) => t.trim().replace(/\.$/, "");
|
|
89
|
+
const parts = [
|
|
90
|
+
...(description ? [`: ${clean(description)}`] : []),
|
|
91
|
+
...(changeHint
|
|
92
|
+
? [` (to change this, as the device's provider says: ${clean(changeHint)})`]
|
|
93
|
+
: []),
|
|
94
|
+
];
|
|
95
|
+
return parts.join("");
|
|
96
|
+
}
|
|
86
97
|
/**
|
|
87
98
|
* Why an escalation cannot be reviewed because the device's provider does not allow running
|
|
88
|
-
* outside its sandbox now, with the provider's own description of the device
|
|
99
|
+
* outside its sandbox now, with the provider's own description of the device and how to change it
|
|
100
|
+
* (its report's `description` and `changeHint`).
|
|
101
|
+
*/
|
|
102
|
+
export const escalationDeviceOffWhy = (description, changeHint = null) => `this device's provider does not allow running outside the sandbox now${reportTail(description, changeHint)}`;
|
|
103
|
+
/**
|
|
104
|
+
* Why an escalation cannot be reviewed because the owner of the machine the device runs on keeps
|
|
105
|
+
* running outside the sandbox off (the provider names that layer, support `limitedBy`), with the
|
|
106
|
+
* provider's description of the device and how to change it.
|
|
89
107
|
*/
|
|
90
|
-
export const
|
|
108
|
+
export const escalationOwnerOffWhy = (description, changeHint = null) => `the owner of the machine this device runs on does not allow running outside the sandbox on it now${reportTail(description, changeHint)}`;
|
|
91
109
|
export const ESCALATION_ORG_OFF_WHY = "running commands outside the sandbox is off in this organization; an organization admin can allow running outside the sandbox";
|
|
92
110
|
export const ESCALATION_PLATFORM_OFF_WHY = "running commands outside the sandbox is off on this platform; a super admin can allow running outside the sandbox";
|
|
93
111
|
export const ESCALATION_NO_OUTSIDE_WHY = "this device is an instance that is itself the sandbox, so this device has no outside of its sandbox to run a command in";
|
|
94
112
|
/**
|
|
95
113
|
* The refusal text of an escalation that a layer's outside-sandbox setting blocks, the same for
|
|
96
114
|
* every provider: an instance-boundary provider has no outside at all, whichever layer is off;
|
|
97
|
-
* otherwise the platform or the org names who lifts it, and
|
|
98
|
-
* allow it now says so with
|
|
115
|
+
* otherwise the platform or the org names who lifts it, and the owner of the machine or a provider
|
|
116
|
+
* whose support does not allow it now says so with the device's report (`description`, and
|
|
117
|
+
* `changeHint`: how to change it, in the provider's words).
|
|
99
118
|
*/
|
|
100
119
|
export const escalationCeilingWhy = (input) => {
|
|
101
120
|
if (input.boundary === "instance")
|
|
@@ -105,8 +124,10 @@ export const escalationCeilingWhy = (input) => {
|
|
|
105
124
|
return ESCALATION_PLATFORM_OFF_WHY;
|
|
106
125
|
case "org":
|
|
107
126
|
return ESCALATION_ORG_OFF_WHY;
|
|
127
|
+
case "owner":
|
|
128
|
+
return escalationOwnerOffWhy(input.description ?? null, input.changeHint ?? null);
|
|
108
129
|
default:
|
|
109
|
-
return escalationDeviceOffWhy(input.description ?? null);
|
|
130
|
+
return escalationDeviceOffWhy(input.description ?? null, input.changeHint ?? null);
|
|
110
131
|
}
|
|
111
132
|
};
|
|
112
133
|
/** Why an escalation cannot be reviewed: the runtime cannot run a command outside its sandbox now. */
|
|
@@ -85,8 +85,7 @@ export declare const setupWebPath: {
|
|
|
85
85
|
template: (itemId: string) => string;
|
|
86
86
|
};
|
|
87
87
|
/**
|
|
88
|
-
* The blocks of a rendered guide as one Markdown document (checks as `- [check <id>]` lines
|
|
89
|
-
* actions as `- [shell action <action>]` lines).
|
|
88
|
+
* The blocks of a rendered guide as one Markdown document (checks as `- [check <id>]` lines).
|
|
90
89
|
*/
|
|
91
90
|
export declare function guideMarkdown(title: string, blocks: readonly SetupGuideBlock[]): string;
|
|
92
91
|
/**
|
|
@@ -46,8 +46,7 @@ function fenceFor(text) {
|
|
|
46
46
|
return "`".repeat(Math.max(3, longest + 1));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* The blocks of a rendered guide as one Markdown document (checks as `- [check <id>]` lines
|
|
50
|
-
* actions as `- [shell action <action>]` lines).
|
|
49
|
+
* The blocks of a rendered guide as one Markdown document (checks as `- [check <id>]` lines).
|
|
51
50
|
*/
|
|
52
51
|
export function guideMarkdown(title, blocks) {
|
|
53
52
|
const parts = [`# ${title}`];
|
|
@@ -56,8 +55,6 @@ export function guideMarkdown(title, blocks) {
|
|
|
56
55
|
parts.push(b.text.trimEnd());
|
|
57
56
|
else if (b.kind === "check")
|
|
58
57
|
parts.push(`- [check ${b.id}] ${b.label}`);
|
|
59
|
-
else if (b.kind === "shell-action")
|
|
60
|
-
parts.push(`- [shell action ${b.action}] ${b.label}`);
|
|
61
58
|
else {
|
|
62
59
|
const fence = fenceFor(b.text);
|
|
63
60
|
const code = `${fence}${b.language}\n${b.text.replace(/\n$/, "")}\n${fence}`;
|
|
@@ -7,6 +7,8 @@ import { StorageService } from "../storage/storage.service.js";
|
|
|
7
7
|
import { ShareObjects } from "./share-objects.js";
|
|
8
8
|
/** The daily share sweep's name (scheduler key and lock; no `:`). */
|
|
9
9
|
export declare const SHARE_SWEEP_JOB = "share-sweep";
|
|
10
|
+
/** When the daily share sweep runs (the deployment's time zone). */
|
|
11
|
+
export declare const SHARE_SWEEP_CRON = "40 3 * * *";
|
|
10
12
|
/** What one sweep did (logged; returned for tests). */
|
|
11
13
|
export interface ShareSweepResult {
|
|
12
14
|
/** Shares revoked with `creator_lost_access` (their snapshots owed for deletion). */
|
package/dist/shares/sweep.job.js
CHANGED
|
@@ -22,6 +22,8 @@ import { revokeSharesIn } from "./revoke.js";
|
|
|
22
22
|
import { ShareObjects, shareObjectKey, shareRefreshLockKey, } from "./share-objects.js";
|
|
23
23
|
/** The daily share sweep's name (scheduler key and lock; no `:`). */
|
|
24
24
|
export const SHARE_SWEEP_JOB = "share-sweep";
|
|
25
|
+
/** When the daily share sweep runs (the deployment's time zone). */
|
|
26
|
+
export const SHARE_SWEEP_CRON = "40 3 * * *";
|
|
25
27
|
/** Rows per batch (one transaction per batch of revokes; one query per batch of reads). */
|
|
26
28
|
const BATCH = 200;
|
|
27
29
|
/** Snapshots of shares expired or revoked longer ago than this are deleted (rows kept). */
|
|
@@ -312,7 +314,7 @@ let ShareSweepJob = class ShareSweepJob {
|
|
|
312
314
|
}
|
|
313
315
|
};
|
|
314
316
|
__decorate([
|
|
315
|
-
LockedCron(
|
|
317
|
+
LockedCron(SHARE_SWEEP_CRON, { name: SHARE_SWEEP_JOB })
|
|
316
318
|
], ShareSweepJob.prototype, "sweep", null);
|
|
317
319
|
__decorate([
|
|
318
320
|
Transactional()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.75",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.60"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|