@capybara-hq/kernel 0.1.0-rc.71 → 0.1.0-rc.72
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
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": "8f3fcf3ca8014008352ceeb8cee8ddfeff1909ec"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -94,6 +94,15 @@
|
|
|
94
94
|
"integrity": "sha512-cbxrv0s9YfMT8rw4TygcRYxrb6x0JPVF2WwtdQtT13lHsQmyOSxIT1GJAHxs5GxUZeRIwrt38AaIGXL/NIqvJA==",
|
|
95
95
|
"required": false
|
|
96
96
|
},
|
|
97
|
+
{
|
|
98
|
+
"name": "device-local",
|
|
99
|
+
"source": "npm",
|
|
100
|
+
"npm": "@capybara-hq/plugin-device-local",
|
|
101
|
+
"version": "0.1.0-rc.1",
|
|
102
|
+
"integrity": "sha512-Hf/yjU3T9M4v9yD4jg0rHwXBgJq3/TI4RngE+7bq6naItkPF7R6njJkYoJ+sMIhuT6S47/RT8fgdwrJsJc78dA==",
|
|
103
|
+
"required": false,
|
|
104
|
+
"scope": "all"
|
|
105
|
+
},
|
|
97
106
|
{
|
|
98
107
|
"name": "todo",
|
|
99
108
|
"source": "npm",
|
|
@@ -27,7 +27,7 @@ export declare class DialInHandlers {
|
|
|
27
27
|
private readonly providers;
|
|
28
28
|
private readonly selection;
|
|
29
29
|
private readonly registry;
|
|
30
|
-
constructor(kdb: KernelDb, providers: Pick<DeviceProviders, "forDevice">, selection: Pick<DeviceProviderSelection, "isOnInOrg" | "onInOrg">, registry: Pick<ExtensionRegistry, "current">);
|
|
30
|
+
constructor(kdb: KernelDb, providers: Pick<DeviceProviders, "forDevice" | "loaded">, selection: Pick<DeviceProviderSelection, "isOnInOrg" | "onInOrg">, registry: Pick<ExtensionRegistry, "current">);
|
|
31
31
|
forDevice(deviceId: string): Promise<DialInServing | DialInUnavailable>;
|
|
32
32
|
/**
|
|
33
33
|
* The dial-in providers that serve `orgId` now, each with the protocol its machines speak: the
|
|
@@ -38,6 +38,15 @@ export declare class DialInHandlers {
|
|
|
38
38
|
plugin: string;
|
|
39
39
|
protocol: string;
|
|
40
40
|
}[]>;
|
|
41
|
+
/**
|
|
42
|
+
* The dial-in providers loaded in this process, in any org or none, each with the protocol its
|
|
43
|
+
* machines speak (registry order). Read at every call; `GET /api/v1/meta` reports from it
|
|
44
|
+
* whether machines running `capybara-device` can connect at all.
|
|
45
|
+
*/
|
|
46
|
+
loaded(): {
|
|
47
|
+
plugin: string;
|
|
48
|
+
protocol: string;
|
|
49
|
+
}[];
|
|
41
50
|
/**
|
|
42
51
|
* The protocol a provider's machines speak, when it serves devices over the dial-in channel:
|
|
43
52
|
* its manifest's `permissions.dialIn.protocol` and a `DeviceProvider.dialIn` handler (an
|
package/dist/dial-in/handlers.js
CHANGED
|
@@ -63,6 +63,20 @@ let DialInHandlers = class DialInHandlers {
|
|
|
63
63
|
}
|
|
64
64
|
return out;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The dial-in providers loaded in this process, in any org or none, each with the protocol its
|
|
68
|
+
* machines speak (registry order). Read at every call; `GET /api/v1/meta` reports from it
|
|
69
|
+
* whether machines running `capybara-device` can connect at all.
|
|
70
|
+
*/
|
|
71
|
+
loaded() {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const e of this.providers.loaded()) {
|
|
74
|
+
const protocol = this.protocolOf(e);
|
|
75
|
+
if (protocol !== undefined)
|
|
76
|
+
out.push({ plugin: e.plugin, protocol });
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
66
80
|
/**
|
|
67
81
|
* The protocol a provider's machines speak, when it serves devices over the dial-in channel:
|
|
68
82
|
* its manifest's `permissions.dialIn.protocol` and a `DeviceProvider.dialIn` handler (an
|
package/dist/http/api.module.js
CHANGED
|
@@ -45,6 +45,7 @@ import { DevicesController } from "../devices/devices.controller.js";
|
|
|
45
45
|
import { DevicesModule } from "../devices/devices.module.js";
|
|
46
46
|
import { DialInAuthController } from "../dial-in/auth.controller.js";
|
|
47
47
|
import { DialInAuthModule } from "../dial-in/auth.module.js";
|
|
48
|
+
import { DialInModule } from "../dial-in/dial-in.module.js";
|
|
48
49
|
import { EvalsModule } from "../evals/evals.module.js";
|
|
49
50
|
import { EvalRunsController } from "../evals/runs.controller.js";
|
|
50
51
|
import { EvalSetsController } from "../evals/sets.controller.js";
|
|
@@ -239,6 +240,8 @@ ApiModule = __decorate([
|
|
|
239
240
|
BackgroundModule,
|
|
240
241
|
DevicesModule,
|
|
241
242
|
DialInAuthModule,
|
|
243
|
+
// the loaded dial-in providers GET /api/v1/meta reports (MetaController)
|
|
244
|
+
DialInModule,
|
|
242
245
|
RuntimeModule,
|
|
243
246
|
ChannelsModule,
|
|
244
247
|
EvalsModule,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { DialInHandlers } from "../dial-in/handlers.js";
|
|
2
3
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
4
|
import { PushProviderHost } from "../push/provider-host.js";
|
|
4
5
|
import { PlatformIconService } from "../themes/platform-icon.service.js";
|
|
@@ -28,12 +29,21 @@ export declare const MetaResponseSchema: z.ZodObject<{
|
|
|
28
29
|
appRedirectUris: z.ZodArray<z.ZodString>;
|
|
29
30
|
}, z.core.$strip>;
|
|
30
31
|
export type MetaResponse = z.infer<typeof MetaResponseSchema>;
|
|
32
|
+
/**
|
|
33
|
+
* The `capybara-device` majors the given dial-in protocols name (`<name>/<major>`, already checked
|
|
34
|
+
* against `DIAL_IN_PROTOCOL_RE` when the provider loaded), as a range; null when none does.
|
|
35
|
+
*/
|
|
36
|
+
export declare function deviceProtocolRange(protocols: readonly string[]): {
|
|
37
|
+
min: number;
|
|
38
|
+
max: number;
|
|
39
|
+
} | null;
|
|
31
40
|
/** `GET /api/v1/meta`: public, never cached, reveals only what a client needs before signing in. */
|
|
32
41
|
export declare class MetaController {
|
|
33
42
|
private readonly config;
|
|
34
43
|
private readonly icons;
|
|
35
44
|
private readonly push;
|
|
36
|
-
|
|
45
|
+
private readonly dialIn;
|
|
46
|
+
constructor(config: KernelConfigService, icons: PlatformIconService, push: PushProviderHost, dialIn: Pick<DialInHandlers, "loaded">);
|
|
37
47
|
meta(): Promise<MetaResponse>;
|
|
38
48
|
/** A customised platform icon's versioned URL (the one the manifest uses); null for the default. */
|
|
39
49
|
private iconUrl;
|
|
@@ -7,9 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { DEVICE_PROTOCOL_VERSION } from "@capybara-hq/plugin-sdk/device-protocol";
|
|
10
|
+
import { DEVICE_DIAL_IN_PROTOCOL, DEVICE_PROTOCOL_VERSION, } from "@capybara-hq/plugin-sdk/device-protocol";
|
|
11
11
|
import { Controller, Get, Header, Inject } from "@nestjs/common";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
+
import { DialInHandlers } from "../dial-in/handlers.js";
|
|
13
14
|
import { Public } from "../identity/principal.js";
|
|
14
15
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
15
16
|
import { PushProviderHost } from "../push/provider-host.js";
|
|
@@ -24,9 +25,14 @@ export const MetaResponseSchema = z.object({
|
|
|
24
25
|
favicon: z.string().nullable(),
|
|
25
26
|
}),
|
|
26
27
|
protocols: z.object({
|
|
28
|
+
/**
|
|
29
|
+
* The `capybara-device` protocol majors the loaded dial-in providers speak (their
|
|
30
|
+
* `permissions.dialIn.protocol`); without any, the SDK's major, and `localDevices` is false.
|
|
31
|
+
*/
|
|
27
32
|
device: z.object({ min: z.number().int(), max: z.number().int() }),
|
|
28
33
|
}),
|
|
29
34
|
features: z.object({
|
|
35
|
+
/** A dial-in provider speaking `capybara-device/<major>` (device-local) is loaded. */
|
|
30
36
|
localDevices: z.boolean(),
|
|
31
37
|
appSignIn: z.boolean(),
|
|
32
38
|
/** App ids a push provider covers with the providers that do; `[]` without `http.publicUrl`. */
|
|
@@ -35,15 +41,33 @@ export const MetaResponseSchema = z.object({
|
|
|
35
41
|
/** The redirect URIs app sign-in accepts (`auth.appRedirectUris`); [] while appSignIn is off. */
|
|
36
42
|
appRedirectUris: z.array(z.string()),
|
|
37
43
|
});
|
|
44
|
+
/** The protocol name `capybara-device` speaks (`capybara-device` of `capybara-device/<major>`). */
|
|
45
|
+
const DEVICE_PROTOCOL_NAME = DEVICE_DIAL_IN_PROTOCOL.slice(0, DEVICE_DIAL_IN_PROTOCOL.indexOf("/"));
|
|
46
|
+
/**
|
|
47
|
+
* The `capybara-device` majors the given dial-in protocols name (`<name>/<major>`, already checked
|
|
48
|
+
* against `DIAL_IN_PROTOCOL_RE` when the provider loaded), as a range; null when none does.
|
|
49
|
+
*/
|
|
50
|
+
export function deviceProtocolRange(protocols) {
|
|
51
|
+
const majors = protocols
|
|
52
|
+
.map((p) => p.split("/"))
|
|
53
|
+
.filter(([name]) => name === DEVICE_PROTOCOL_NAME)
|
|
54
|
+
.map(([, major]) => Number(major))
|
|
55
|
+
.filter((n) => Number.isInteger(n));
|
|
56
|
+
if (majors.length === 0)
|
|
57
|
+
return null;
|
|
58
|
+
return { min: Math.min(...majors), max: Math.max(...majors) };
|
|
59
|
+
}
|
|
38
60
|
/** `GET /api/v1/meta`: public, never cached, reveals only what a client needs before signing in. */
|
|
39
61
|
let MetaController = class MetaController {
|
|
40
62
|
config;
|
|
41
63
|
icons;
|
|
42
64
|
push;
|
|
43
|
-
|
|
65
|
+
dialIn;
|
|
66
|
+
constructor(config, icons, push, dialIn) {
|
|
44
67
|
this.config = config;
|
|
45
68
|
this.icons = icons;
|
|
46
69
|
this.push = push;
|
|
70
|
+
this.dialIn = dialIn;
|
|
47
71
|
}
|
|
48
72
|
async meta() {
|
|
49
73
|
const config = this.config.get();
|
|
@@ -53,13 +77,18 @@ let MetaController = class MetaController {
|
|
|
53
77
|
this.iconUrl("favicon"),
|
|
54
78
|
]);
|
|
55
79
|
const appSignIn = Boolean(config.http.publicUrl);
|
|
80
|
+
// Local devices exist only while a dial-in provider speaking capybara-device is loaded
|
|
81
|
+
// (device-local); the shells offer "connect this machine" only then.
|
|
82
|
+
const devices = deviceProtocolRange(this.dialIn.loaded().map((p) => p.protocol));
|
|
56
83
|
return {
|
|
57
84
|
name: config.platform.name ?? null,
|
|
58
85
|
icon: app,
|
|
59
86
|
icons: { app, maskable, favicon },
|
|
60
|
-
protocols: {
|
|
87
|
+
protocols: {
|
|
88
|
+
device: devices ?? { min: DEVICE_PROTOCOL_VERSION, max: DEVICE_PROTOCOL_VERSION },
|
|
89
|
+
},
|
|
61
90
|
features: {
|
|
62
|
-
localDevices:
|
|
91
|
+
localDevices: devices !== null,
|
|
63
92
|
// The authorize route answers app_auth.unavailable without http.publicUrl.
|
|
64
93
|
appSignIn,
|
|
65
94
|
// A push message carries the deployment origin, which needs http.publicUrl.
|
|
@@ -83,6 +112,7 @@ MetaController = __decorate([
|
|
|
83
112
|
Controller("api/v1/meta"),
|
|
84
113
|
__param(0, Inject(KernelConfigService)),
|
|
85
114
|
__param(1, Inject(PlatformIconService)),
|
|
86
|
-
__param(2, Inject(PushProviderHost))
|
|
115
|
+
__param(2, Inject(PushProviderHost)),
|
|
116
|
+
__param(3, Inject(DialInHandlers))
|
|
87
117
|
], MetaController);
|
|
88
118
|
export { MetaController };
|
package/package.json
CHANGED