@capybara-hq/kernel 0.1.0-rc.71 → 0.1.0-rc.73
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 +10 -1
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/dial-in/auth.controller.d.ts +1 -1
- package/dist/dial-in/auth.controller.js +1 -1
- package/dist/dial-in/auth.service.d.ts +4 -0
- package/dist/dial-in/auth.service.js +15 -1
- package/dist/dial-in/handlers.d.ts +10 -1
- package/dist/dial-in/handlers.js +14 -0
- package/dist/extensions/permission-set.d.ts +1 -1
- package/dist/extensions/permission-set.js +1 -1
- package/dist/http/api.module.js +3 -0
- package/dist/http/meta.controller.d.ts +11 -1
- package/dist/http/meta.controller.js +35 -5
- package/package.json +3 -3
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",
|
|
@@ -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.57";
|
|
207
207
|
};
|
|
208
208
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
209
209
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -12,7 +12,7 @@ import { type DeviceAuthorizeBody, type DeviceConfirmBody, type DeviceProvidersQ
|
|
|
12
12
|
* - `POST /authorize { name, os, arch, programVersion, protocol }` → `{ deviceCode, userCode,
|
|
13
13
|
* verificationUri, verificationUriComplete, interval, expiresIn }` (`device-authorize-ip`);
|
|
14
14
|
* - `POST /token { deviceCode }` → `{ credential, orgId, deviceId, connectUrl,
|
|
15
|
-
* reconnectGraceSeconds, maxFrameBytes, outsideSandbox }` once, else `device_sign_in.authorization_pending` / `device_sign_in.slow_down` /
|
|
15
|
+
* reconnectGraceSeconds, maxFrameBytes, outsideSandbox, deviceName, orgName }` once, else `device_sign_in.authorization_pending` / `device_sign_in.slow_down` /
|
|
16
16
|
* `device_sign_in.denied` / `device_sign_in.expired` (`device-token-ip`).
|
|
17
17
|
*
|
|
18
18
|
* The person's routes need a web session (the confirmation page `/device`); each try of a user
|
|
@@ -24,7 +24,7 @@ const CODE_THROTTLER = ["device-code-account"];
|
|
|
24
24
|
* - `POST /authorize { name, os, arch, programVersion, protocol }` → `{ deviceCode, userCode,
|
|
25
25
|
* verificationUri, verificationUriComplete, interval, expiresIn }` (`device-authorize-ip`);
|
|
26
26
|
* - `POST /token { deviceCode }` → `{ credential, orgId, deviceId, connectUrl,
|
|
27
|
-
* reconnectGraceSeconds, maxFrameBytes, outsideSandbox }` once, else `device_sign_in.authorization_pending` / `device_sign_in.slow_down` /
|
|
27
|
+
* reconnectGraceSeconds, maxFrameBytes, outsideSandbox, deviceName, orgName }` once, else `device_sign_in.authorization_pending` / `device_sign_in.slow_down` /
|
|
28
28
|
* `device_sign_in.denied` / `device_sign_in.expired` (`device-token-ip`).
|
|
29
29
|
*
|
|
30
30
|
* The person's routes need a web session (the confirmation page `/device`); each try of a user
|
|
@@ -63,6 +63,10 @@ export interface DeviceGrant extends Grant {
|
|
|
63
63
|
* does not allow it, even when the machine's owner ceiling does.
|
|
64
64
|
*/
|
|
65
65
|
outsideSandbox: "allowed" | "off";
|
|
66
|
+
/** The device's name (`devices.name`; null when it has none), for `capybara-device status`. */
|
|
67
|
+
deviceName: string | null;
|
|
68
|
+
/** The organization's name (`orgs.name`), for `capybara-device status`. */
|
|
69
|
+
orgName: string;
|
|
66
70
|
}
|
|
67
71
|
/** A user code as typed → `XXXX-XXXX`, or null when it cannot be one. */
|
|
68
72
|
export declare function normalizeUserCode(input: string): string | null;
|
|
@@ -188,9 +188,21 @@ let DialInAuthService = class DialInAuthService {
|
|
|
188
188
|
case "approved": {
|
|
189
189
|
const grant = JSON.parse(r[1]);
|
|
190
190
|
const dialIn = this.config.get().devices.dialIn;
|
|
191
|
-
const [deployment, settings] = await Promise.all([
|
|
191
|
+
const [deployment, settings, device, org] = await Promise.all([
|
|
192
192
|
readDeploymentDevicePolicy(this.db.db, this.config),
|
|
193
193
|
readOrgSettings(this.db.db, grant.orgId),
|
|
194
|
+
this.db.db
|
|
195
|
+
.selectFrom("devices")
|
|
196
|
+
.select("name")
|
|
197
|
+
.where("org_id", "=", grant.orgId)
|
|
198
|
+
.where("id", "=", grant.deviceId)
|
|
199
|
+
.executeTakeFirst(),
|
|
200
|
+
this.db.db
|
|
201
|
+
.selectFrom("orgs")
|
|
202
|
+
.select("name")
|
|
203
|
+
.where("id", "=", grant.orgId)
|
|
204
|
+
// the grant's org exists: the device row it names references it
|
|
205
|
+
.executeTakeFirstOrThrow(),
|
|
194
206
|
]);
|
|
195
207
|
return {
|
|
196
208
|
...grant,
|
|
@@ -200,6 +212,8 @@ let DialInAuthService = class DialInAuthService {
|
|
|
200
212
|
outsideSandbox: allowedDeviceMode(deployment.fullAccess, settings.outsideSandbox) === "auto"
|
|
201
213
|
? "allowed"
|
|
202
214
|
: "off",
|
|
215
|
+
deviceName: device?.name ?? null,
|
|
216
|
+
orgName: org.name,
|
|
203
217
|
};
|
|
204
218
|
}
|
|
205
219
|
case "slow_down":
|
|
@@ -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
|
|
@@ -119,7 +119,7 @@ export declare function buildPermissionSet(input: {
|
|
|
119
119
|
* `config.org.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
120
120
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
121
121
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
122
|
-
* `permissions.dialin:capybara-device/
|
|
122
|
+
* `permissions.dialin:capybara-device/6`.
|
|
123
123
|
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
124
124
|
*/
|
|
125
125
|
export declare function permissionKeys(set: PermissionSet): string[];
|
|
@@ -128,7 +128,7 @@ export function buildPermissionSet(input) {
|
|
|
128
128
|
* `config.org.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
129
129
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
130
130
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
131
|
-
* `permissions.dialin:capybara-device/
|
|
131
|
+
* `permissions.dialin:capybara-device/6`.
|
|
132
132
|
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
133
133
|
*/
|
|
134
134
|
export function permissionKeys(set) {
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.73",
|
|
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.57"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/ws": "^8.18.2",
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
78
|
+
"@capybara-hq/testing": "0.1.0-rc.36"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsc -b"
|