@capybara-hq/kernel 0.1.0-rc.12 → 0.1.0-rc.14
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/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/admin-catalog.controller.d.ts +13 -2
- package/dist/catalog/admin-catalog.controller.js +24 -3
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +7 -0
- package/dist/catalog/catalog-content.d.ts +9 -1
- package/dist/catalog/catalog-content.js +2 -1
- package/dist/catalog/catalog-files.d.ts +3 -2
- package/dist/catalog/catalog-files.js +8 -5
- package/dist/catalog/component-scope.service.d.ts +14 -1
- package/dist/catalog/component-scope.service.js +12 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +5 -4
- package/dist/catalog/org-catalog.controller.js +5 -4
- package/dist/catalog/org-catalog.schemas.d.ts +18 -2
- package/dist/catalog/org-catalog.schemas.js +16 -2
- package/dist/catalog/org-catalog.service.js +8 -2
- package/dist/catalog/plugin-import.js +1 -1
- package/dist/catalog/plugin-package.js +37 -9
- package/dist/catalog/plugin-upgrade.d.ts +15 -1
- package/dist/catalog/plugin-upgrade.js +18 -5
- package/dist/channels/channels.module.js +2 -2
- package/dist/channels/connections.controller.d.ts +1 -1
- package/dist/channels/connections.controller.js +1 -1
- package/dist/channels/connections.service.d.ts +22 -5
- package/dist/channels/connections.service.js +56 -10
- 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/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- 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 +14 -14
- package/dist/conversations/conversations.service.js +19 -19
- 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 +1 -1
- package/dist/conversations/events.js +2 -2
- package/dist/ctx/create-ctx.d.ts +26 -3
- package/dist/ctx/create-ctx.js +134 -26
- package/dist/db/kernel-schema.d.ts +37 -25
- 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 +29 -25
- package/dist/errors.js +29 -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/guide-places.d.ts +66 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/host.d.ts +13 -2
- package/dist/extensions/host.js +27 -6
- package/dist/extensions/instance.d.ts +17 -2
- package/dist/extensions/instance.js +21 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/permission-set.d.ts +16 -2
- package/dist/extensions/permission-set.js +17 -3
- package/dist/extensions/permission-view.d.ts +10 -1
- package/dist/extensions/plugin-guides.d.ts +207 -54
- package/dist/extensions/plugin-guides.js +436 -165
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +1 -1
- package/dist/http/api.module.js +16 -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/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/throttler/named-throttlers.d.ts +4 -1
- package/dist/infra/throttler/named-throttlers.js +16 -1
- package/dist/infra/throttler/throttler.guard.js +1 -1
- 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/overrides.d.ts +3 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +48 -8
- package/dist/platform/operation.js +10 -2
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/connectors.ops.js +2 -0
- 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/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -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 +4 -2
- package/dist/platform/platform-ops.module.js +13 -5
- package/dist/platform/route-schemas.js +11 -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/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/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +295 -0
- package/dist/setup/oauth-token-probe.d.ts +47 -0
- package/dist/setup/oauth-token-probe.js +108 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- 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/connectors.controller.d.ts +28 -11
- package/dist/tools/connectors.controller.js +49 -14
- package/dist/tools/connectors.schemas.d.ts +4 -0
- package/dist/tools/connectors.schemas.js +4 -0
- package/dist/tools/connectors.service.d.ts +30 -2
- package/dist/tools/connectors.service.js +98 -3
- package/dist/tools/credentials.d.ts +20 -0
- package/dist/tools/credentials.js +90 -1
- package/dist/tools/oauth/tokens.d.ts +20 -0
- package/dist/tools/oauth/tokens.js +49 -24
- package/dist/tools/pipeline.js +4 -3
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/tools.module.js +3 -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/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -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
|
@@ -20,13 +20,13 @@ import { LIST_TTL_MARGIN_MS } from "./relay.js";
|
|
|
20
20
|
export const DEVICE_CLOSE = {
|
|
21
21
|
/** The kernel is shutting down: reconnect (another gateway replica takes over). */
|
|
22
22
|
shutdown: 1001,
|
|
23
|
-
/** A frame larger than `
|
|
23
|
+
/** A frame larger than `devices.local.maxFrameBytes` (sent by `ws` itself). */
|
|
24
24
|
tooBig: 1009,
|
|
25
25
|
/** The kernel failed (e.g. the database): reconnect. */
|
|
26
26
|
internal: 1011,
|
|
27
27
|
/** The lease was lost (renewal kept failing or the key was taken): reconnect. */
|
|
28
28
|
leaseLost: 4001,
|
|
29
|
-
/** A newer connection of the
|
|
29
|
+
/** A newer connection of the device took over: the program exits. */
|
|
30
30
|
replaced: 4002,
|
|
31
31
|
/** The machine's credential was revoked: the program exits. */
|
|
32
32
|
revoked: 4003,
|
|
@@ -45,7 +45,7 @@ export const CLAIM_TIMEOUT_MS = 5_000;
|
|
|
45
45
|
export const CLAIM_RETRY_MS = 250;
|
|
46
46
|
/** Traffic marks the machine seen at most this often per connection (the row has its own gate). */
|
|
47
47
|
const TOUCH_EVERY_MS = 30_000;
|
|
48
|
-
/** How often a held connection re-checks its credential (membership, org,
|
|
48
|
+
/** How often a held connection re-checks its credential (membership, org, device). */
|
|
49
49
|
const REAUTH_EVERY_MS = 60_000;
|
|
50
50
|
/**
|
|
51
51
|
* Puts a frame the holder popped but could not send back at the head of the list, keeping the
|
|
@@ -60,7 +60,7 @@ return 1
|
|
|
60
60
|
`;
|
|
61
61
|
/**
|
|
62
62
|
* Pops the next frame of the request list (`KEYS[1]`) and, when it is a `req`, marks it taken in
|
|
63
|
-
* the same step: `<ARGV[1]><id>` → the
|
|
63
|
+
* the same step: `<ARGV[1]><id>` → the device id `ARGV[2]`, for the reconnect grace
|
|
64
64
|
* `ARGV[3]` ms plus the request's deadline plus the margin `ARGV[4]` ms (ruling R20). Returns the
|
|
65
65
|
* frame, or false when the list is empty. A frame that is not JSON is returned as is (the caller
|
|
66
66
|
* drops it). The taken key cannot be declared in KEYS (its id is known only after the pop): like
|
|
@@ -79,7 +79,7 @@ return raw
|
|
|
79
79
|
`;
|
|
80
80
|
/**
|
|
81
81
|
* Accepts a result (ruling R20): only when its request is marked taken (`KEYS[1]`) for the
|
|
82
|
-
*
|
|
82
|
+
* device `ARGV[1]`. Stores the frame `ARGV[2]` under `KEYS[2]` for what is left of the taken
|
|
83
83
|
* mark's TTL (the caller's whole window, also after a reconnect) and clears the mark. Returns 1
|
|
84
84
|
* when stored, 0 otherwise.
|
|
85
85
|
*/
|
|
@@ -120,8 +120,8 @@ class DeviceConnection {
|
|
|
120
120
|
this.identity = identity;
|
|
121
121
|
this.credential = credential;
|
|
122
122
|
}
|
|
123
|
-
get
|
|
124
|
-
return this.identity.
|
|
123
|
+
get deviceId() {
|
|
124
|
+
return this.identity.deviceId;
|
|
125
125
|
}
|
|
126
126
|
start() {
|
|
127
127
|
const { socket } = this;
|
|
@@ -157,7 +157,7 @@ class DeviceConnection {
|
|
|
157
157
|
}
|
|
158
158
|
catch (e) {
|
|
159
159
|
this.gw.log.warn("device sent an invalid frame", {
|
|
160
|
-
|
|
160
|
+
deviceId: this.deviceId,
|
|
161
161
|
error: errMsg(e),
|
|
162
162
|
});
|
|
163
163
|
this.close(DEVICE_CLOSE.protocol, "invalid frame");
|
|
@@ -181,7 +181,7 @@ class DeviceConnection {
|
|
|
181
181
|
}
|
|
182
182
|
catch (e) {
|
|
183
183
|
this.gw.log.warn("could not record a device hello", {
|
|
184
|
-
|
|
184
|
+
deviceId: this.deviceId,
|
|
185
185
|
error: errMsg(e),
|
|
186
186
|
});
|
|
187
187
|
}
|
|
@@ -197,14 +197,14 @@ class DeviceConnection {
|
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* Stores one result and announces it (the relay's wire, relay.ts), only for a request taken for
|
|
200
|
-
* this
|
|
200
|
+
* this device (ruling R20); anything else is dropped.
|
|
201
201
|
*/
|
|
202
202
|
async store(res) {
|
|
203
203
|
try {
|
|
204
|
-
const stored = await this.gw.redis.eval(ACCEPT, 2, deviceTakenKey(res.id), deviceResKey(res.id), this.
|
|
204
|
+
const stored = await this.gw.redis.eval(ACCEPT, 2, deviceTakenKey(res.id), deviceResKey(res.id), this.deviceId, JSON.stringify(res));
|
|
205
205
|
if (Number(stored) !== 1) {
|
|
206
|
-
this.gw.log.warn("dropping a device result for a request not taken for its
|
|
207
|
-
|
|
206
|
+
this.gw.log.warn("dropping a device result for a request not taken for its device", {
|
|
207
|
+
deviceId: this.deviceId,
|
|
208
208
|
});
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
@@ -212,19 +212,19 @@ class DeviceConnection {
|
|
|
212
212
|
}
|
|
213
213
|
catch (e) {
|
|
214
214
|
this.gw.log.warn("could not store a device result", {
|
|
215
|
-
|
|
215
|
+
deviceId: this.deviceId,
|
|
216
216
|
error: errMsg(e),
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
|
-
* Claims the
|
|
221
|
+
* Claims the device's lease; true when this connection holds it. The newest connection
|
|
222
222
|
* wins (ruling R21): when another connection holds the lease, a takeover is published (the
|
|
223
223
|
* holder yields to any takeover) and the lease retried every {@link CLAIM_RETRY_MS} for
|
|
224
224
|
* {@link CLAIM_TIMEOUT_MS}, then 4409 (the program reconnects). A claimer never yields.
|
|
225
225
|
*/
|
|
226
226
|
async claim() {
|
|
227
|
-
const env = this.
|
|
227
|
+
const env = this.deviceId;
|
|
228
228
|
try {
|
|
229
229
|
// subscribed before claiming, so a takeover right after the claim is not missed
|
|
230
230
|
await this.subscribe(deviceTakeoverTopic(env), (p) => {
|
|
@@ -253,7 +253,7 @@ class DeviceConnection {
|
|
|
253
253
|
return false;
|
|
254
254
|
}
|
|
255
255
|
if (!lease) {
|
|
256
|
-
this.close(DEVICE_CLOSE.claimTimeout, "the
|
|
256
|
+
this.close(DEVICE_CLOSE.claimTimeout, "the device is held by another connection");
|
|
257
257
|
return false;
|
|
258
258
|
}
|
|
259
259
|
this.lease = lease;
|
|
@@ -276,7 +276,7 @@ class DeviceConnection {
|
|
|
276
276
|
if (this.state !== "holding")
|
|
277
277
|
return false;
|
|
278
278
|
this.gw.log.info("device connected", {
|
|
279
|
-
|
|
279
|
+
deviceId: env,
|
|
280
280
|
machineId: this.identity.machineId,
|
|
281
281
|
});
|
|
282
282
|
// what was queued while nobody held the machine
|
|
@@ -285,7 +285,7 @@ class DeviceConnection {
|
|
|
285
285
|
}
|
|
286
286
|
catch (e) {
|
|
287
287
|
this.gw.log.warn("could not claim a device connection", {
|
|
288
|
-
|
|
288
|
+
deviceId: env,
|
|
289
289
|
error: errMsg(e),
|
|
290
290
|
});
|
|
291
291
|
this.close(DEVICE_CLOSE.internal, "internal error");
|
|
@@ -306,17 +306,17 @@ class DeviceConnection {
|
|
|
306
306
|
.then(() => this.drainOnce())
|
|
307
307
|
.catch((e) => {
|
|
308
308
|
this.gw.log.warn("device request drain failed", {
|
|
309
|
-
|
|
309
|
+
deviceId: this.deviceId,
|
|
310
310
|
error: errMsg(e),
|
|
311
311
|
});
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
314
|
async drainOnce() {
|
|
315
|
-
const key = deviceReqKey(this.
|
|
315
|
+
const key = deviceReqKey(this.deviceId);
|
|
316
316
|
while (this.state === "holding") {
|
|
317
317
|
// no lease fencing needed: the pop is atomic, so each frame reaches one connection only, and
|
|
318
|
-
// a holder that lost its lease still talks to the
|
|
319
|
-
const raw = (await this.gw.redis.eval(TAKE, 1, key, DEVICE_TAKEN_PREFIX, this.
|
|
318
|
+
// a holder that lost its lease still talks to the device's own machine (or puts it back)
|
|
319
|
+
const raw = (await this.gw.redis.eval(TAKE, 1, key, DEVICE_TAKEN_PREFIX, this.deviceId, String(this.gw.graceMs()), String(LIST_TTL_MARGIN_MS)));
|
|
320
320
|
if (raw === null)
|
|
321
321
|
return;
|
|
322
322
|
let frame;
|
|
@@ -325,7 +325,7 @@ class DeviceConnection {
|
|
|
325
325
|
}
|
|
326
326
|
catch (e) {
|
|
327
327
|
this.gw.log.warn("dropping an invalid device request", {
|
|
328
|
-
|
|
328
|
+
deviceId: this.deviceId,
|
|
329
329
|
error: errMsg(e),
|
|
330
330
|
});
|
|
331
331
|
continue;
|
|
@@ -343,7 +343,7 @@ class DeviceConnection {
|
|
|
343
343
|
ok: false,
|
|
344
344
|
error: {
|
|
345
345
|
kind: "error",
|
|
346
|
-
message: "The request is larger than
|
|
346
|
+
message: "The request is larger than devices.local.maxFrameBytes",
|
|
347
347
|
},
|
|
348
348
|
});
|
|
349
349
|
continue;
|
|
@@ -363,7 +363,7 @@ class DeviceConnection {
|
|
|
363
363
|
if (this.state === "closed")
|
|
364
364
|
return;
|
|
365
365
|
if (this.missedPongs >= 2) {
|
|
366
|
-
this.gw.log.info("device connection missed two pongs", {
|
|
366
|
+
this.gw.log.info("device connection missed two pongs", { deviceId: this.deviceId });
|
|
367
367
|
this.socket.terminate();
|
|
368
368
|
void this.shutdown();
|
|
369
369
|
return;
|
|
@@ -378,7 +378,7 @@ class DeviceConnection {
|
|
|
378
378
|
void this.reauthenticate();
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
/** The credential still stands (membership, org and
|
|
381
|
+
/** The credential still stands (membership, org and device are read live). */
|
|
382
382
|
async reauthenticate() {
|
|
383
383
|
try {
|
|
384
384
|
const id = await this.gw.machines.authenticate(this.credential);
|
|
@@ -388,7 +388,7 @@ class DeviceConnection {
|
|
|
388
388
|
}
|
|
389
389
|
catch (e) {
|
|
390
390
|
this.gw.log.warn("could not re-check a device credential", {
|
|
391
|
-
|
|
391
|
+
deviceId: this.deviceId,
|
|
392
392
|
error: errMsg(e),
|
|
393
393
|
});
|
|
394
394
|
}
|
|
@@ -400,7 +400,7 @@ class DeviceConnection {
|
|
|
400
400
|
this.lastTouch = now;
|
|
401
401
|
this.gw.machines.touch(this.identity.machineId).catch((e) => {
|
|
402
402
|
this.gw.log.warn("could not mark a machine seen", {
|
|
403
|
-
|
|
403
|
+
deviceId: this.deviceId,
|
|
404
404
|
error: errMsg(e),
|
|
405
405
|
});
|
|
406
406
|
});
|
|
@@ -436,7 +436,7 @@ class DeviceConnection {
|
|
|
436
436
|
}
|
|
437
437
|
catch (e) {
|
|
438
438
|
this.gw.log.warn("could not release a device lease", {
|
|
439
|
-
|
|
439
|
+
deviceId: this.deviceId,
|
|
440
440
|
error: errMsg(e),
|
|
441
441
|
});
|
|
442
442
|
}
|
|
@@ -444,7 +444,7 @@ class DeviceConnection {
|
|
|
444
444
|
this.gw.forget(this);
|
|
445
445
|
if (lease) {
|
|
446
446
|
this.gw.log.info("device disconnected", {
|
|
447
|
-
|
|
447
|
+
deviceId: this.deviceId,
|
|
448
448
|
machineId: this.identity.machineId,
|
|
449
449
|
});
|
|
450
450
|
}
|
|
@@ -455,17 +455,17 @@ class DeviceConnection {
|
|
|
455
455
|
/**
|
|
456
456
|
* The gateway role's half of the device relay (environments spec §13.4): holds the WebSocket
|
|
457
457
|
* connections of connected machines (`GET /device/connect`, device-routes.ts). One connection per
|
|
458
|
-
*
|
|
459
|
-
* connection wins: it publishes `device.takeover.<
|
|
460
|
-
* holder drains `capk:device-req:<
|
|
461
|
-
* once after claiming and on every ping, marking each forwarded request taken for its
|
|
458
|
+
* device across replicas, under the lease `capk:device-lease:<deviceId>` (the newest
|
|
459
|
+
* connection wins: it publishes `device.takeover.<deviceId>` and the holder lets go). The
|
|
460
|
+
* holder drains `capk:device-req:<deviceId>` on every `device.req.<deviceId>` nudge,
|
|
461
|
+
* once after claiming and on every ping, marking each forwarded request taken for its device
|
|
462
462
|
* (`capk:device-taken:<id>`, TTL the reconnect grace plus the request's deadline plus a margin).
|
|
463
|
-
* A `res` is accepted only for a request taken for the socket's
|
|
463
|
+
* A `res` is accepted only for a request taken for the socket's device: it is stored under
|
|
464
464
|
* `capk:device-res:<id>` for the rest of that TTL and published on `device.res.<id>`.
|
|
465
|
-
* `device.revoked.<
|
|
465
|
+
* `device.revoked.<deviceId>` closes the connection of that machine only (ruling R16). The
|
|
466
466
|
* sockets are this process's own; everything other replicas need is in Redis.
|
|
467
467
|
*/
|
|
468
|
-
let
|
|
468
|
+
let LocalDeviceGateway = class LocalDeviceGateway {
|
|
469
469
|
machines;
|
|
470
470
|
locks;
|
|
471
471
|
bus;
|
|
@@ -486,13 +486,13 @@ let DeviceGateway = class DeviceGateway {
|
|
|
486
486
|
this.log = log;
|
|
487
487
|
}
|
|
488
488
|
graceMs() {
|
|
489
|
-
return this.config.get().
|
|
489
|
+
return this.config.get().devices.local.reconnectGraceSeconds * 1000;
|
|
490
490
|
}
|
|
491
491
|
leaseTtlMs() {
|
|
492
|
-
return this.config.get().
|
|
492
|
+
return this.config.get().devices.local.leaseTtlMs;
|
|
493
493
|
}
|
|
494
494
|
maxFrameBytes() {
|
|
495
|
-
return this.config.get().
|
|
495
|
+
return this.config.get().devices.local.maxFrameBytes;
|
|
496
496
|
}
|
|
497
497
|
/** Who a `Bearer` machine credential stands for, or null (checked before the upgrade). */
|
|
498
498
|
authenticate(credential) {
|
|
@@ -518,7 +518,7 @@ let DeviceGateway = class DeviceGateway {
|
|
|
518
518
|
await Promise.all([...this.connections].map((c) => c.close(DEVICE_CLOSE.shutdown, "shutting down")));
|
|
519
519
|
}
|
|
520
520
|
};
|
|
521
|
-
|
|
521
|
+
LocalDeviceGateway = __decorate([
|
|
522
522
|
Injectable(),
|
|
523
523
|
__param(0, Inject(MachinesService)),
|
|
524
524
|
__param(1, Inject(LockService)),
|
|
@@ -526,5 +526,5 @@ DeviceGateway = __decorate([
|
|
|
526
526
|
__param(3, Inject(REDIS)),
|
|
527
527
|
__param(4, Inject(KernelConfigService)),
|
|
528
528
|
__param(5, Inject(KERNEL_LOGGER))
|
|
529
|
-
],
|
|
530
|
-
export {
|
|
529
|
+
], LocalDeviceGateway);
|
|
530
|
+
export { LocalDeviceGateway };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExecResult, FileSystemHandle, SandboxHandle, SandboxLimits, SandboxProvider, SandboxRoots } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
3
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
4
|
-
import {
|
|
4
|
+
import { LocalDeviceRelay } from "./relay.js";
|
|
5
5
|
import { DeviceTargets } from "./targets.js";
|
|
6
6
|
/** Extra time the machine gets beyond a command's own timeout (spawn, output, the trip back). */
|
|
7
7
|
export declare const EXEC_DEADLINE_MARGIN_MS = 5000;
|
|
@@ -9,42 +9,42 @@ export declare const EXEC_DEADLINE_MARGIN_MS = 5000;
|
|
|
9
9
|
export declare const OP_DEADLINE_MS = 30000;
|
|
10
10
|
/**
|
|
11
11
|
* Room left in a frame for everything around a `readFile` result's base64 data (the `res`
|
|
12
|
-
* envelope): a read is clamped so the machine's answer fits `
|
|
12
|
+
* envelope): a read is clamped so the machine's answer fits `devices.local.maxFrameBytes`
|
|
13
13
|
* (ruling R26).
|
|
14
14
|
*/
|
|
15
15
|
export declare const FRAME_ENVELOPE_BYTES: number;
|
|
16
16
|
/** The most raw bytes whose base64 plus {@link FRAME_ENVELOPE_BYTES} fit in `maxFrameBytes`. */
|
|
17
17
|
export declare const maxReadBytes: (maxFrameBytes: number) => number;
|
|
18
18
|
/**
|
|
19
|
-
* The handle of an instance on a machine: the
|
|
20
|
-
*
|
|
19
|
+
* The handle of an instance on a machine: the device id (ruling R1: the relay is keyed by
|
|
20
|
+
* device), the roots the machine reported at `create`, and the org's effective limits at
|
|
21
21
|
* creation (for the record: every `exec` carries the org's limits read at that moment, ruling
|
|
22
22
|
* R27, so the machine intersects its local policy with the current egress).
|
|
23
23
|
*/
|
|
24
|
-
export interface
|
|
24
|
+
export interface LocalDeviceHandle extends SandboxHandle {
|
|
25
25
|
roots: SandboxRoots;
|
|
26
26
|
limits: SandboxLimits;
|
|
27
27
|
}
|
|
28
|
-
/** The
|
|
29
|
-
export declare const
|
|
28
|
+
/** The device id of a `cap-device-<deviceId>` name; undefined for any other name. */
|
|
29
|
+
export declare const deviceIdOfName: (name: string) => string | undefined;
|
|
30
30
|
/**
|
|
31
|
-
* The kernel-internal provider `@
|
|
32
|
-
*
|
|
33
|
-
* machine's
|
|
31
|
+
* The kernel-internal provider `@local` (environments spec §13.5): every operation runs on the
|
|
32
|
+
* device's connected machine through the {@link LocalDeviceRelay}. The file system is the
|
|
33
|
+
* machine's device directory (the program creates it on first use), so `createFileSystem`
|
|
34
34
|
* touches nothing; `suspend` and `destroy` do nothing (the machine is not the platform's to stop);
|
|
35
|
-
* deleting the
|
|
35
|
+
* deleting the device leaves the files on the machine where they are. Nothing here throws `device.offline` on the cleanup paths (ruling R9).
|
|
36
36
|
*
|
|
37
37
|
* The files on a machine are its owner's: `destroyFileSystem` (a files reset, the deletion sweep)
|
|
38
38
|
* does nothing; the deletion's `stop` comes from `MachinesService.revokeActive` (ruling R24).
|
|
39
39
|
*/
|
|
40
|
-
export declare class
|
|
40
|
+
export declare class LocalDeviceProvider implements SandboxProvider {
|
|
41
41
|
private readonly relay;
|
|
42
42
|
private readonly targets;
|
|
43
43
|
private readonly sandbox;
|
|
44
44
|
private readonly config;
|
|
45
45
|
readonly concurrentExec: true;
|
|
46
46
|
readonly sessionIsolation = false;
|
|
47
|
-
constructor(relay:
|
|
47
|
+
constructor(relay: LocalDeviceRelay, targets: Pick<DeviceTargets, "orgOf" | "machineRoots">, sandbox: Pick<SandboxService, "orgLimits">, config: Pick<KernelConfigService, "get">);
|
|
48
48
|
createFileSystem(args: {
|
|
49
49
|
name: string;
|
|
50
50
|
limits: SandboxLimits;
|
|
@@ -59,7 +59,7 @@ export declare class DeviceSandboxProvider implements SandboxProvider {
|
|
|
59
59
|
limits: SandboxLimits;
|
|
60
60
|
fileSystem: FileSystemHandle;
|
|
61
61
|
signal: AbortSignal;
|
|
62
|
-
}): Promise<
|
|
62
|
+
}): Promise<LocalDeviceHandle>;
|
|
63
63
|
/**
|
|
64
64
|
* Needs the machine online. `gone` (the kernel recreates the instance) when the active machine
|
|
65
65
|
* last reported other roots than the instance was created with (a new login into another
|
|
@@ -84,6 +84,6 @@ export declare class DeviceSandboxProvider implements SandboxProvider {
|
|
|
84
84
|
size: number;
|
|
85
85
|
isDir: boolean;
|
|
86
86
|
} | null>;
|
|
87
|
-
/** The org's effective limits now (ruling R27); a deleted
|
|
87
|
+
/** The org's effective limits now (ruling R27); a deleted device is not found. */
|
|
88
88
|
private currentLimits;
|
|
89
89
|
}
|
|
@@ -9,8 +9,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { deviceNotFound, SandboxService } from "../sandbox/sandbox.service.js";
|
|
13
|
+
import { deviceOffline, LocalDeviceRelay } from "./relay.js";
|
|
14
14
|
import { DeviceTargets, sameRoots } from "./targets.js";
|
|
15
15
|
/** Extra time the machine gets beyond a command's own timeout (spawn, output, the trip back). */
|
|
16
16
|
export const EXEC_DEADLINE_MARGIN_MS = 5000;
|
|
@@ -18,30 +18,30 @@ export const EXEC_DEADLINE_MARGIN_MS = 5000;
|
|
|
18
18
|
export const OP_DEADLINE_MS = 30_000;
|
|
19
19
|
/**
|
|
20
20
|
* Room left in a frame for everything around a `readFile` result's base64 data (the `res`
|
|
21
|
-
* envelope): a read is clamped so the machine's answer fits `
|
|
21
|
+
* envelope): a read is clamped so the machine's answer fits `devices.local.maxFrameBytes`
|
|
22
22
|
* (ruling R26).
|
|
23
23
|
*/
|
|
24
24
|
export const FRAME_ENVELOPE_BYTES = 64 * 1024;
|
|
25
25
|
/** The most raw bytes whose base64 plus {@link FRAME_ENVELOPE_BYTES} fit in `maxFrameBytes`. */
|
|
26
26
|
export const maxReadBytes = (maxFrameBytes) => Math.max(0, Math.floor((maxFrameBytes - FRAME_ENVELOPE_BYTES) / 4) * 3);
|
|
27
|
-
const NAME_PREFIX = "cap-
|
|
28
|
-
/** The
|
|
29
|
-
export const
|
|
27
|
+
const NAME_PREFIX = "cap-device-";
|
|
28
|
+
/** The device id of a `cap-device-<deviceId>` name; undefined for any other name. */
|
|
29
|
+
export const deviceIdOfName = (name) => name.startsWith(NAME_PREFIX) && name.length > NAME_PREFIX.length
|
|
30
30
|
? name.slice(NAME_PREFIX.length)
|
|
31
31
|
: undefined;
|
|
32
32
|
const rootsOf = (h) => h.roots;
|
|
33
33
|
const bytesOf = (b64) => new Uint8Array(Buffer.from(b64, "base64"));
|
|
34
34
|
/**
|
|
35
|
-
* The kernel-internal provider `@
|
|
36
|
-
*
|
|
37
|
-
* machine's
|
|
35
|
+
* The kernel-internal provider `@local` (environments spec §13.5): every operation runs on the
|
|
36
|
+
* device's connected machine through the {@link LocalDeviceRelay}. The file system is the
|
|
37
|
+
* machine's device directory (the program creates it on first use), so `createFileSystem`
|
|
38
38
|
* touches nothing; `suspend` and `destroy` do nothing (the machine is not the platform's to stop);
|
|
39
|
-
* deleting the
|
|
39
|
+
* deleting the device leaves the files on the machine where they are. Nothing here throws `device.offline` on the cleanup paths (ruling R9).
|
|
40
40
|
*
|
|
41
41
|
* The files on a machine are its owner's: `destroyFileSystem` (a files reset, the deletion sweep)
|
|
42
42
|
* does nothing; the deletion's `stop` comes from `MachinesService.revokeActive` (ruling R24).
|
|
43
43
|
*/
|
|
44
|
-
let
|
|
44
|
+
let LocalDeviceProvider = class LocalDeviceProvider {
|
|
45
45
|
relay;
|
|
46
46
|
targets;
|
|
47
47
|
sandbox;
|
|
@@ -56,9 +56,9 @@ let DeviceSandboxProvider = class DeviceSandboxProvider {
|
|
|
56
56
|
}
|
|
57
57
|
async createFileSystem(args) {
|
|
58
58
|
args.signal.throwIfAborted();
|
|
59
|
-
const id =
|
|
59
|
+
const id = deviceIdOfName(args.name);
|
|
60
60
|
if (id === undefined)
|
|
61
|
-
throw new Error(`not
|
|
61
|
+
throw new Error(`not a device name: ${args.name}`);
|
|
62
62
|
return { id };
|
|
63
63
|
}
|
|
64
64
|
/** The files are the machine owner's: nothing to do (ruling R24; never a `stop`). */
|
|
@@ -81,7 +81,7 @@ let DeviceSandboxProvider = class DeviceSandboxProvider {
|
|
|
81
81
|
async resume(h, signal) {
|
|
82
82
|
signal.throwIfAborted();
|
|
83
83
|
if (!(await this.relay.holderLive(h.id)))
|
|
84
|
-
throw
|
|
84
|
+
throw deviceOffline();
|
|
85
85
|
const had = rootsOf(h);
|
|
86
86
|
const now = await this.targets.machineRoots(h.id);
|
|
87
87
|
if (had === undefined || (now !== null && !sameRoots(had, now)))
|
|
@@ -122,7 +122,7 @@ let DeviceSandboxProvider = class DeviceSandboxProvider {
|
|
|
122
122
|
}
|
|
123
123
|
async readFile(h, path, opts) {
|
|
124
124
|
// the answer must fit one frame: a larger file comes back truncated (Deliver: too large)
|
|
125
|
-
const maxBytes = Math.min(opts.maxBytes, maxReadBytes(this.config.get().
|
|
125
|
+
const maxBytes = Math.min(opts.maxBytes, maxReadBytes(this.config.get().devices.local.maxFrameBytes));
|
|
126
126
|
const r = await this.relay.call(h.id, "readFile", { path, maxBytes }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal });
|
|
127
127
|
return r === null ? null : { data: bytesOf(r.dataB64), truncated: r.truncated };
|
|
128
128
|
}
|
|
@@ -133,19 +133,19 @@ let DeviceSandboxProvider = class DeviceSandboxProvider {
|
|
|
133
133
|
async stat(h, path, signal) {
|
|
134
134
|
return this.relay.call(h.id, "stat", { path }, { deadlineMs: OP_DEADLINE_MS, signal });
|
|
135
135
|
}
|
|
136
|
-
/** The org's effective limits now (ruling R27); a deleted
|
|
137
|
-
async currentLimits(
|
|
138
|
-
const orgId = await this.targets.orgOf(
|
|
136
|
+
/** The org's effective limits now (ruling R27); a deleted device is not found. */
|
|
137
|
+
async currentLimits(deviceId) {
|
|
138
|
+
const orgId = await this.targets.orgOf(deviceId);
|
|
139
139
|
if (orgId === null)
|
|
140
|
-
throw
|
|
140
|
+
throw deviceNotFound();
|
|
141
141
|
return this.sandbox.orgLimits(orgId);
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
|
-
|
|
144
|
+
LocalDeviceProvider = __decorate([
|
|
145
145
|
Injectable(),
|
|
146
|
-
__param(0, Inject(
|
|
146
|
+
__param(0, Inject(LocalDeviceRelay)),
|
|
147
147
|
__param(1, Inject(DeviceTargets)),
|
|
148
148
|
__param(2, Inject(SandboxService)),
|
|
149
149
|
__param(3, Inject(KernelConfigService))
|
|
150
|
-
],
|
|
151
|
-
export {
|
|
150
|
+
], LocalDeviceProvider);
|
|
151
|
+
export { LocalDeviceProvider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { SandboxProviders } from "../sandbox/providers.js";
|
|
3
|
+
import { LocalDeviceProvider } from "./local-device-provider.js";
|
|
4
|
+
/**
|
|
5
|
+
* Connected machines (environments spec §6, §13): the caller side of the device relay and the
|
|
6
|
+
* kernel-internal `@local` sandbox provider, registered with {@link SandboxProviders} on init, and
|
|
7
|
+
* the machines and their credentials ({@link MachinesService}).
|
|
8
|
+
* Imported on every role: any replica may run a sandbox operation on a local device
|
|
9
|
+
* (the socket itself is held by the gateway role).
|
|
10
|
+
*/
|
|
11
|
+
export declare class LocalDevicesModule implements OnModuleInit {
|
|
12
|
+
private readonly providers;
|
|
13
|
+
private readonly provider;
|
|
14
|
+
constructor(providers: SandboxProviders, provider: LocalDeviceProvider);
|
|
15
|
+
onModuleInit(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Module } from "@nestjs/common";
|
|
11
|
+
import { LOCAL_PROVIDER, SandboxProviders } from "../sandbox/providers.js";
|
|
12
|
+
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
13
|
+
import { LocalDeviceProvider } from "./local-device-provider.js";
|
|
14
|
+
import { MachinesService } from "./machines.js";
|
|
15
|
+
import { LocalDeviceRelay } from "./relay.js";
|
|
16
|
+
import { DeviceTargets } from "./targets.js";
|
|
17
|
+
/**
|
|
18
|
+
* Connected machines (environments spec §6, §13): the caller side of the device relay and the
|
|
19
|
+
* kernel-internal `@local` sandbox provider, registered with {@link SandboxProviders} on init, and
|
|
20
|
+
* the machines and their credentials ({@link MachinesService}).
|
|
21
|
+
* Imported on every role: any replica may run a sandbox operation on a local device
|
|
22
|
+
* (the socket itself is held by the gateway role).
|
|
23
|
+
*/
|
|
24
|
+
let LocalDevicesModule = class LocalDevicesModule {
|
|
25
|
+
providers;
|
|
26
|
+
provider;
|
|
27
|
+
constructor(providers, provider) {
|
|
28
|
+
this.providers = providers;
|
|
29
|
+
this.provider = provider;
|
|
30
|
+
}
|
|
31
|
+
onModuleInit() {
|
|
32
|
+
this.providers.register({ plugin: LOCAL_PROVIDER, impl: this.provider });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
LocalDevicesModule = __decorate([
|
|
36
|
+
Module({
|
|
37
|
+
imports: [SandboxModule],
|
|
38
|
+
providers: [DeviceTargets, LocalDeviceRelay, LocalDeviceProvider, MachinesService],
|
|
39
|
+
exports: [LocalDeviceRelay, LocalDeviceProvider, MachinesService],
|
|
40
|
+
}),
|
|
41
|
+
__param(0, Inject(SandboxProviders)),
|
|
42
|
+
__param(1, Inject(LocalDeviceProvider))
|
|
43
|
+
], LocalDevicesModule);
|
|
44
|
+
export { LocalDevicesModule };
|