@jdg-keyforge/protocol 0.8.0 → 0.10.0
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/common.d.ts +163 -1
- package/dist/events/action_invoked.d.ts +60 -0
- package/dist/events/action_invoked.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/methods/create_profile.d.ts +1 -1
- package/dist/methods/duplicate_profile.d.ts +1 -1
- package/dist/methods/hello.d.ts +1 -1
- package/dist/methods/import_profile.d.ts +1 -1
- package/dist/methods/list_actions.d.ts +1 -4
- package/dist/methods/list_bindings.d.ts +1 -1
- package/dist/methods/list_profiles.d.ts +1 -1
- package/dist/methods/set_binding.d.ts +1 -1
- package/package.json +1 -1
- package/src/common.ts +163 -1
- package/src/events/action_invoked.ts +63 -0
- package/src/index.ts +1 -0
- package/src/methods/create_profile.ts +1 -1
- package/src/methods/duplicate_profile.ts +1 -1
- package/src/methods/hello.ts +1 -1
- package/src/methods/import_profile.ts +1 -1
- package/src/methods/list_actions.ts +1 -4
- package/src/methods/list_bindings.ts +1 -1
- package/src/methods/list_profiles.ts +1 -1
- package/src/methods/set_binding.ts +1 -1
package/dist/common.d.ts
CHANGED
|
@@ -24,6 +24,21 @@ export type InputKind = "key" | "encoder";
|
|
|
24
24
|
* via the `definition` "InputAction".
|
|
25
25
|
*/
|
|
26
26
|
export type InputAction = "press" | "release" | "rotate_cw" | "rotate_ccw" | "click";
|
|
27
|
+
/**
|
|
28
|
+
* Globally unique plugin identifier in reverse-DNS form (e.g. 'dev.jonidg.spotify'). Lowercase, at least two dot-separated segments, each starting with a letter. Used as the install folder name and as <plugin_id> in Action.type.
|
|
29
|
+
*
|
|
30
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
31
|
+
* via the `definition` "PluginID".
|
|
32
|
+
*/
|
|
33
|
+
export type PluginID = string;
|
|
34
|
+
/**
|
|
35
|
+
* Id of the plugin being launched (its manifest id).
|
|
36
|
+
*/
|
|
37
|
+
export type PluginID1 = string;
|
|
38
|
+
/**
|
|
39
|
+
* Globally unique reverse-DNS plugin id; install folder name and <plugin_id> in Action.type.
|
|
40
|
+
*/
|
|
41
|
+
export type PluginID2 = string;
|
|
27
42
|
/**
|
|
28
43
|
* Shared type definitions referenced by message schemas.
|
|
29
44
|
*/
|
|
@@ -57,7 +72,7 @@ export interface InputEvent {
|
|
|
57
72
|
*/
|
|
58
73
|
export interface Action {
|
|
59
74
|
/**
|
|
60
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
75
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
61
76
|
*/
|
|
62
77
|
type: string;
|
|
63
78
|
/**
|
|
@@ -243,3 +258,150 @@ export interface AutoSwitchRule {
|
|
|
243
258
|
*/
|
|
244
259
|
profile_id: string;
|
|
245
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Describes one action parameter so a client can render an input for it.
|
|
263
|
+
*
|
|
264
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
265
|
+
* via the `definition` "ParamSpec".
|
|
266
|
+
*/
|
|
267
|
+
export interface ParamSpec {
|
|
268
|
+
/**
|
|
269
|
+
* Param key written into Action.params. Unique within the action.
|
|
270
|
+
*/
|
|
271
|
+
name: string;
|
|
272
|
+
/**
|
|
273
|
+
* Human-friendly field label.
|
|
274
|
+
*/
|
|
275
|
+
label: string;
|
|
276
|
+
/**
|
|
277
|
+
* Param value type. Only 'string' in v1.
|
|
278
|
+
*/
|
|
279
|
+
type: "string";
|
|
280
|
+
required: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Optional placeholder/example shown in the input.
|
|
283
|
+
*/
|
|
284
|
+
placeholder?: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Connection info the daemon hands to a plugin process it spawns, serialized as JSON in the KEYFORGE_PLUGIN_INFO environment variable (an env var rather than CLI args, so the token is not visible in the process list). The plugin connects to ws_url, sends hello with client.name set to plugin_id, and must exit when that connection closes.
|
|
288
|
+
*
|
|
289
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
290
|
+
* via the `definition` "PluginLaunchInfo".
|
|
291
|
+
*/
|
|
292
|
+
export interface PluginLaunchInfo {
|
|
293
|
+
plugin_id: PluginID1;
|
|
294
|
+
/**
|
|
295
|
+
* WebSocket URL to connect to, including the per-plugin auth token as a query param. Treat it as a secret: the token identifies the plugin to the daemon and is distinct from the GUI's session token.
|
|
296
|
+
*/
|
|
297
|
+
ws_url: string;
|
|
298
|
+
/**
|
|
299
|
+
* Protocol major version the daemon speaks. The plugin sends it back in hello. Currently '1'.
|
|
300
|
+
*/
|
|
301
|
+
protocol_version: "1";
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Contents of the manifest.json file at the root of a plugin. A plugin is distributed as a '.keyforgeplugin' file: a zip archive with manifest.json at its root (no wrapping folder) plus every file the manifest references. The daemon installs it by extracting the archive into '<config dir>/plugins/<id>/', taking the id from the manifest. All file paths in the manifest (icon, and entrypoint paths containing '/') are relative to the plugin root, use '/' as separator, and must stay inside the plugin root: the daemon rejects '..' segments and any path or archive entry that escapes the root.
|
|
305
|
+
*
|
|
306
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
307
|
+
* via the `definition` "PluginManifest".
|
|
308
|
+
*/
|
|
309
|
+
export interface PluginManifest {
|
|
310
|
+
/**
|
|
311
|
+
* Manifest format version. Currently 1; bumped if the manifest shape changes.
|
|
312
|
+
*/
|
|
313
|
+
manifest_version: 1;
|
|
314
|
+
id: PluginID2;
|
|
315
|
+
/**
|
|
316
|
+
* Human-friendly plugin name for the UI.
|
|
317
|
+
*/
|
|
318
|
+
name: string;
|
|
319
|
+
/**
|
|
320
|
+
* Plugin version (SemVer 2.0).
|
|
321
|
+
*/
|
|
322
|
+
version: string;
|
|
323
|
+
/**
|
|
324
|
+
* Major version of the protocol the plugin speaks. Lets the daemon reject an incompatible plugin before spawning it. Currently '1'.
|
|
325
|
+
*/
|
|
326
|
+
protocol_version: "1";
|
|
327
|
+
/**
|
|
328
|
+
* Plugin author, shown in the UI.
|
|
329
|
+
*/
|
|
330
|
+
author?: string;
|
|
331
|
+
/**
|
|
332
|
+
* Short description of what the plugin does.
|
|
333
|
+
*/
|
|
334
|
+
description?: string;
|
|
335
|
+
/**
|
|
336
|
+
* URL of the plugin homepage or source repository.
|
|
337
|
+
*/
|
|
338
|
+
homepage?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Category the UI groups the plugin's actions under (e.g. 'Audio', 'Streaming').
|
|
341
|
+
*/
|
|
342
|
+
category?: string;
|
|
343
|
+
/**
|
|
344
|
+
* Path to the plugin icon, relative to the plugin root. No leading '/', no '\' and no ':'.
|
|
345
|
+
*/
|
|
346
|
+
icon?: string;
|
|
347
|
+
/**
|
|
348
|
+
* Command the daemon runs to start the plugin, per OS (keys match Go's GOOS). The plugin supports exactly the OSes listed here.
|
|
349
|
+
*/
|
|
350
|
+
entrypoint: {
|
|
351
|
+
darwin?: PluginCommand;
|
|
352
|
+
linux?: PluginCommand;
|
|
353
|
+
windows?: PluginCommand;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Actions the plugin exposes. Each becomes bindable as 'plugin.<id>.<action id>'.
|
|
357
|
+
*
|
|
358
|
+
* @minItems 1
|
|
359
|
+
*/
|
|
360
|
+
actions: [PluginAction, ...PluginAction[]];
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Executable plus arguments used to start a plugin process.
|
|
364
|
+
*
|
|
365
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
366
|
+
* via the `definition` "PluginCommand".
|
|
367
|
+
*/
|
|
368
|
+
export interface PluginCommand {
|
|
369
|
+
/**
|
|
370
|
+
* Executable to run. A path containing '/' is resolved relative to the plugin root; a bare name (e.g. 'node') is looked up on the PATH. Always use '/' as separator, also on Windows; absolute paths, '\' and ':' are not allowed.
|
|
371
|
+
*/
|
|
372
|
+
path: string;
|
|
373
|
+
/**
|
|
374
|
+
* Arguments passed to the executable.
|
|
375
|
+
*/
|
|
376
|
+
args?: string[];
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* An action a plugin exposes, declared in its manifest.
|
|
380
|
+
*
|
|
381
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
382
|
+
* via the `definition` "PluginAction".
|
|
383
|
+
*/
|
|
384
|
+
export interface PluginAction {
|
|
385
|
+
/**
|
|
386
|
+
* Action identifier, unique within the plugin. snake_case, no dots.
|
|
387
|
+
*/
|
|
388
|
+
id: string;
|
|
389
|
+
/**
|
|
390
|
+
* Human-friendly action name for the UI.
|
|
391
|
+
*/
|
|
392
|
+
name: string;
|
|
393
|
+
/**
|
|
394
|
+
* Optional longer description of what the action does.
|
|
395
|
+
*/
|
|
396
|
+
description?: string;
|
|
397
|
+
/**
|
|
398
|
+
* Input kinds the action can be bound to. Omitted means any kind.
|
|
399
|
+
*
|
|
400
|
+
* @minItems 1
|
|
401
|
+
*/
|
|
402
|
+
inputs?: [InputKind, ...InputKind[]];
|
|
403
|
+
/**
|
|
404
|
+
* Params this action accepts, in display order.
|
|
405
|
+
*/
|
|
406
|
+
params: ParamSpec[];
|
|
407
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Stable identifier for a HID device. Format: VID_<hex>_PID_<hex>[_<serial>].
|
|
8
|
+
*/
|
|
9
|
+
export type DeviceID = string;
|
|
10
|
+
/**
|
|
11
|
+
* Kind of physical input.
|
|
12
|
+
*/
|
|
13
|
+
export type InputKind = "key" | "encoder";
|
|
14
|
+
/**
|
|
15
|
+
* What happened on the input.
|
|
16
|
+
*/
|
|
17
|
+
export type InputAction = "press" | "release" | "rotate_cw" | "rotate_ccw" | "click";
|
|
18
|
+
/**
|
|
19
|
+
* Sent by the daemon to a single plugin connection (never broadcast) when a binding or macro step whose action is 'plugin.<plugin_id>.<action_id>' fires for that plugin. Fire-and-forget: the daemon does not wait for the plugin, so a failing plugin action cannot stop a macro it is part of.
|
|
20
|
+
*/
|
|
21
|
+
export interface EventActionInvoked {
|
|
22
|
+
data: {
|
|
23
|
+
/**
|
|
24
|
+
* Opaque id of the binding instance that fired: unique per binding and per macro step, and stable for as long as that binding exists (also across daemon restarts). Lets a plugin keep per-instance state, e.g. a toggle bound to two keys. Plugins must not parse it.
|
|
25
|
+
*/
|
|
26
|
+
context: string;
|
|
27
|
+
/**
|
|
28
|
+
* The plugin action to run.
|
|
29
|
+
*/
|
|
30
|
+
action: {
|
|
31
|
+
/**
|
|
32
|
+
* Action id as declared in the plugin manifest (PluginAction.id), without the 'plugin.<plugin_id>.' prefix.
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* Action.params from the binding, as configured by the user. Always present: {} when the binding has no params.
|
|
37
|
+
*/
|
|
38
|
+
params: {
|
|
39
|
+
[k: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
input?: InputEvent;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Hardware event that fired the binding (e.g. lets a plugin tell rotate_cw from rotate_ccw). Absent when the action was not fired by hardware (e.g. a test run from the GUI).
|
|
47
|
+
*/
|
|
48
|
+
export interface InputEvent {
|
|
49
|
+
device_id: DeviceID;
|
|
50
|
+
kind: InputKind;
|
|
51
|
+
/**
|
|
52
|
+
* Logical identifier of the input within the device (e.g. 'key_0x04', 'encoder_0'). Matches Device.inputs[].id.
|
|
53
|
+
*/
|
|
54
|
+
input_id: string;
|
|
55
|
+
action: InputAction;
|
|
56
|
+
/**
|
|
57
|
+
* Unix epoch in milliseconds when the event was captured by the daemon.
|
|
58
|
+
*/
|
|
59
|
+
timestamp_ms: number;
|
|
60
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,6 @@ export type { MethodRenameProfile } from './methods/rename_profile.js';
|
|
|
15
15
|
export type { MethodSetActiveProfile } from './methods/set_active_profile.js';
|
|
16
16
|
export type { MethodSetAutoSwitch } from './methods/set_auto_switch.js';
|
|
17
17
|
export type { MethodSetBinding } from './methods/set_binding.js';
|
|
18
|
+
export type { EventActionInvoked } from './events/action_invoked.js';
|
|
18
19
|
export type { EventActiveProfileChanged } from './events/active_profile_changed.js';
|
|
19
20
|
export type { EventInput } from './events/input.js';
|
|
@@ -56,7 +56,7 @@ export interface Binding {
|
|
|
56
56
|
*/
|
|
57
57
|
export interface Action {
|
|
58
58
|
/**
|
|
59
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
59
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
60
60
|
*/
|
|
61
61
|
type: string;
|
|
62
62
|
/**
|
|
@@ -60,7 +60,7 @@ export interface Binding {
|
|
|
60
60
|
*/
|
|
61
61
|
export interface Action {
|
|
62
62
|
/**
|
|
63
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
63
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
64
64
|
*/
|
|
65
65
|
type: string;
|
|
66
66
|
/**
|
package/dist/methods/hello.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface MethodHello {
|
|
|
30
30
|
*/
|
|
31
31
|
export interface PeerInfo {
|
|
32
32
|
/**
|
|
33
|
-
* Stable identifier of the peer implementation.
|
|
33
|
+
* Stable identifier of the peer implementation. A plugin must send its PluginID here; the daemon checks it against the plugin its auth token belongs to.
|
|
34
34
|
*/
|
|
35
35
|
name: string;
|
|
36
36
|
/**
|
|
@@ -56,7 +56,7 @@ export interface Binding {
|
|
|
56
56
|
*/
|
|
57
57
|
export interface Action {
|
|
58
58
|
/**
|
|
59
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
59
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
60
60
|
*/
|
|
61
61
|
type: string;
|
|
62
62
|
/**
|
|
@@ -44,13 +44,10 @@ export interface ActionDescriptor {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Describes one action parameter so a client can render an input for it.
|
|
47
|
-
*
|
|
48
|
-
* This interface was referenced by `MethodListActions`'s JSON-Schema
|
|
49
|
-
* via the `definition` "ParamSpec".
|
|
50
47
|
*/
|
|
51
48
|
export interface ParamSpec {
|
|
52
49
|
/**
|
|
53
|
-
* Param key written into Action.params.
|
|
50
|
+
* Param key written into Action.params. Unique within the action.
|
|
54
51
|
*/
|
|
55
52
|
name: string;
|
|
56
53
|
/**
|
|
@@ -40,7 +40,7 @@ export interface Binding {
|
|
|
40
40
|
*/
|
|
41
41
|
export interface Action {
|
|
42
42
|
/**
|
|
43
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
43
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
44
44
|
*/
|
|
45
45
|
type: string;
|
|
46
46
|
/**
|
|
@@ -61,7 +61,7 @@ export interface Binding {
|
|
|
61
61
|
*/
|
|
62
62
|
export interface Action {
|
|
63
63
|
/**
|
|
64
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
64
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
65
65
|
*/
|
|
66
66
|
type: string;
|
|
67
67
|
/**
|
|
@@ -37,7 +37,7 @@ export interface Binding {
|
|
|
37
37
|
*/
|
|
38
38
|
export interface Action {
|
|
39
39
|
/**
|
|
40
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
40
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
41
41
|
*/
|
|
42
42
|
type: string;
|
|
43
43
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdg-keyforge/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "TypeScript types for the KeyForge WebSocket protocol, generated from the canonical JSON Schema contracts.",
|
|
5
5
|
"keywords": ["keyforge", "protocol", "types", "json-schema", "websocket"],
|
|
6
6
|
"license": "Apache-2.0",
|
package/src/common.ts
CHANGED
|
@@ -26,6 +26,21 @@ export type InputKind = "key" | "encoder";
|
|
|
26
26
|
* via the `definition` "InputAction".
|
|
27
27
|
*/
|
|
28
28
|
export type InputAction = "press" | "release" | "rotate_cw" | "rotate_ccw" | "click";
|
|
29
|
+
/**
|
|
30
|
+
* Globally unique plugin identifier in reverse-DNS form (e.g. 'dev.jonidg.spotify'). Lowercase, at least two dot-separated segments, each starting with a letter. Used as the install folder name and as <plugin_id> in Action.type.
|
|
31
|
+
*
|
|
32
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
33
|
+
* via the `definition` "PluginID".
|
|
34
|
+
*/
|
|
35
|
+
export type PluginID = string;
|
|
36
|
+
/**
|
|
37
|
+
* Id of the plugin being launched (its manifest id).
|
|
38
|
+
*/
|
|
39
|
+
export type PluginID1 = string;
|
|
40
|
+
/**
|
|
41
|
+
* Globally unique reverse-DNS plugin id; install folder name and <plugin_id> in Action.type.
|
|
42
|
+
*/
|
|
43
|
+
export type PluginID2 = string;
|
|
29
44
|
|
|
30
45
|
/**
|
|
31
46
|
* Shared type definitions referenced by message schemas.
|
|
@@ -60,7 +75,7 @@ export interface InputEvent {
|
|
|
60
75
|
*/
|
|
61
76
|
export interface Action {
|
|
62
77
|
/**
|
|
63
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
78
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
64
79
|
*/
|
|
65
80
|
type: string;
|
|
66
81
|
/**
|
|
@@ -246,3 +261,150 @@ export interface AutoSwitchRule {
|
|
|
246
261
|
*/
|
|
247
262
|
profile_id: string;
|
|
248
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Describes one action parameter so a client can render an input for it.
|
|
266
|
+
*
|
|
267
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
268
|
+
* via the `definition` "ParamSpec".
|
|
269
|
+
*/
|
|
270
|
+
export interface ParamSpec {
|
|
271
|
+
/**
|
|
272
|
+
* Param key written into Action.params. Unique within the action.
|
|
273
|
+
*/
|
|
274
|
+
name: string;
|
|
275
|
+
/**
|
|
276
|
+
* Human-friendly field label.
|
|
277
|
+
*/
|
|
278
|
+
label: string;
|
|
279
|
+
/**
|
|
280
|
+
* Param value type. Only 'string' in v1.
|
|
281
|
+
*/
|
|
282
|
+
type: "string";
|
|
283
|
+
required: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Optional placeholder/example shown in the input.
|
|
286
|
+
*/
|
|
287
|
+
placeholder?: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Connection info the daemon hands to a plugin process it spawns, serialized as JSON in the KEYFORGE_PLUGIN_INFO environment variable (an env var rather than CLI args, so the token is not visible in the process list). The plugin connects to ws_url, sends hello with client.name set to plugin_id, and must exit when that connection closes.
|
|
291
|
+
*
|
|
292
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
293
|
+
* via the `definition` "PluginLaunchInfo".
|
|
294
|
+
*/
|
|
295
|
+
export interface PluginLaunchInfo {
|
|
296
|
+
plugin_id: PluginID1;
|
|
297
|
+
/**
|
|
298
|
+
* WebSocket URL to connect to, including the per-plugin auth token as a query param. Treat it as a secret: the token identifies the plugin to the daemon and is distinct from the GUI's session token.
|
|
299
|
+
*/
|
|
300
|
+
ws_url: string;
|
|
301
|
+
/**
|
|
302
|
+
* Protocol major version the daemon speaks. The plugin sends it back in hello. Currently '1'.
|
|
303
|
+
*/
|
|
304
|
+
protocol_version: "1";
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Contents of the manifest.json file at the root of a plugin. A plugin is distributed as a '.keyforgeplugin' file: a zip archive with manifest.json at its root (no wrapping folder) plus every file the manifest references. The daemon installs it by extracting the archive into '<config dir>/plugins/<id>/', taking the id from the manifest. All file paths in the manifest (icon, and entrypoint paths containing '/') are relative to the plugin root, use '/' as separator, and must stay inside the plugin root: the daemon rejects '..' segments and any path or archive entry that escapes the root.
|
|
308
|
+
*
|
|
309
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
310
|
+
* via the `definition` "PluginManifest".
|
|
311
|
+
*/
|
|
312
|
+
export interface PluginManifest {
|
|
313
|
+
/**
|
|
314
|
+
* Manifest format version. Currently 1; bumped if the manifest shape changes.
|
|
315
|
+
*/
|
|
316
|
+
manifest_version: 1;
|
|
317
|
+
id: PluginID2;
|
|
318
|
+
/**
|
|
319
|
+
* Human-friendly plugin name for the UI.
|
|
320
|
+
*/
|
|
321
|
+
name: string;
|
|
322
|
+
/**
|
|
323
|
+
* Plugin version (SemVer 2.0).
|
|
324
|
+
*/
|
|
325
|
+
version: string;
|
|
326
|
+
/**
|
|
327
|
+
* Major version of the protocol the plugin speaks. Lets the daemon reject an incompatible plugin before spawning it. Currently '1'.
|
|
328
|
+
*/
|
|
329
|
+
protocol_version: "1";
|
|
330
|
+
/**
|
|
331
|
+
* Plugin author, shown in the UI.
|
|
332
|
+
*/
|
|
333
|
+
author?: string;
|
|
334
|
+
/**
|
|
335
|
+
* Short description of what the plugin does.
|
|
336
|
+
*/
|
|
337
|
+
description?: string;
|
|
338
|
+
/**
|
|
339
|
+
* URL of the plugin homepage or source repository.
|
|
340
|
+
*/
|
|
341
|
+
homepage?: string;
|
|
342
|
+
/**
|
|
343
|
+
* Category the UI groups the plugin's actions under (e.g. 'Audio', 'Streaming').
|
|
344
|
+
*/
|
|
345
|
+
category?: string;
|
|
346
|
+
/**
|
|
347
|
+
* Path to the plugin icon, relative to the plugin root. No leading '/', no '\' and no ':'.
|
|
348
|
+
*/
|
|
349
|
+
icon?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Command the daemon runs to start the plugin, per OS (keys match Go's GOOS). The plugin supports exactly the OSes listed here.
|
|
352
|
+
*/
|
|
353
|
+
entrypoint: {
|
|
354
|
+
darwin?: PluginCommand;
|
|
355
|
+
linux?: PluginCommand;
|
|
356
|
+
windows?: PluginCommand;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Actions the plugin exposes. Each becomes bindable as 'plugin.<id>.<action id>'.
|
|
360
|
+
*
|
|
361
|
+
* @minItems 1
|
|
362
|
+
*/
|
|
363
|
+
actions: [PluginAction, ...PluginAction[]];
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Executable plus arguments used to start a plugin process.
|
|
367
|
+
*
|
|
368
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
369
|
+
* via the `definition` "PluginCommand".
|
|
370
|
+
*/
|
|
371
|
+
export interface PluginCommand {
|
|
372
|
+
/**
|
|
373
|
+
* Executable to run. A path containing '/' is resolved relative to the plugin root; a bare name (e.g. 'node') is looked up on the PATH. Always use '/' as separator, also on Windows; absolute paths, '\' and ':' are not allowed.
|
|
374
|
+
*/
|
|
375
|
+
path: string;
|
|
376
|
+
/**
|
|
377
|
+
* Arguments passed to the executable.
|
|
378
|
+
*/
|
|
379
|
+
args?: string[];
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* An action a plugin exposes, declared in its manifest.
|
|
383
|
+
*
|
|
384
|
+
* This interface was referenced by `CommonTypes`'s JSON-Schema
|
|
385
|
+
* via the `definition` "PluginAction".
|
|
386
|
+
*/
|
|
387
|
+
export interface PluginAction {
|
|
388
|
+
/**
|
|
389
|
+
* Action identifier, unique within the plugin. snake_case, no dots.
|
|
390
|
+
*/
|
|
391
|
+
id: string;
|
|
392
|
+
/**
|
|
393
|
+
* Human-friendly action name for the UI.
|
|
394
|
+
*/
|
|
395
|
+
name: string;
|
|
396
|
+
/**
|
|
397
|
+
* Optional longer description of what the action does.
|
|
398
|
+
*/
|
|
399
|
+
description?: string;
|
|
400
|
+
/**
|
|
401
|
+
* Input kinds the action can be bound to. Omitted means any kind.
|
|
402
|
+
*
|
|
403
|
+
* @minItems 1
|
|
404
|
+
*/
|
|
405
|
+
inputs?: [InputKind, ...InputKind[]];
|
|
406
|
+
/**
|
|
407
|
+
* Params this action accepts, in display order.
|
|
408
|
+
*/
|
|
409
|
+
params: ParamSpec[];
|
|
410
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
+
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
+
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Stable identifier for a HID device. Format: VID_<hex>_PID_<hex>[_<serial>].
|
|
10
|
+
*/
|
|
11
|
+
export type DeviceID = string;
|
|
12
|
+
/**
|
|
13
|
+
* Kind of physical input.
|
|
14
|
+
*/
|
|
15
|
+
export type InputKind = "key" | "encoder";
|
|
16
|
+
/**
|
|
17
|
+
* What happened on the input.
|
|
18
|
+
*/
|
|
19
|
+
export type InputAction = "press" | "release" | "rotate_cw" | "rotate_ccw" | "click";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Sent by the daemon to a single plugin connection (never broadcast) when a binding or macro step whose action is 'plugin.<plugin_id>.<action_id>' fires for that plugin. Fire-and-forget: the daemon does not wait for the plugin, so a failing plugin action cannot stop a macro it is part of.
|
|
23
|
+
*/
|
|
24
|
+
export interface EventActionInvoked {
|
|
25
|
+
data: {
|
|
26
|
+
/**
|
|
27
|
+
* Opaque id of the binding instance that fired: unique per binding and per macro step, and stable for as long as that binding exists (also across daemon restarts). Lets a plugin keep per-instance state, e.g. a toggle bound to two keys. Plugins must not parse it.
|
|
28
|
+
*/
|
|
29
|
+
context: string;
|
|
30
|
+
/**
|
|
31
|
+
* The plugin action to run.
|
|
32
|
+
*/
|
|
33
|
+
action: {
|
|
34
|
+
/**
|
|
35
|
+
* Action id as declared in the plugin manifest (PluginAction.id), without the 'plugin.<plugin_id>.' prefix.
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
/**
|
|
39
|
+
* Action.params from the binding, as configured by the user. Always present: {} when the binding has no params.
|
|
40
|
+
*/
|
|
41
|
+
params: {
|
|
42
|
+
[k: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
input?: InputEvent;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Hardware event that fired the binding (e.g. lets a plugin tell rotate_cw from rotate_ccw). Absent when the action was not fired by hardware (e.g. a test run from the GUI).
|
|
50
|
+
*/
|
|
51
|
+
export interface InputEvent {
|
|
52
|
+
device_id: DeviceID;
|
|
53
|
+
kind: InputKind;
|
|
54
|
+
/**
|
|
55
|
+
* Logical identifier of the input within the device (e.g. 'key_0x04', 'encoder_0'). Matches Device.inputs[].id.
|
|
56
|
+
*/
|
|
57
|
+
input_id: string;
|
|
58
|
+
action: InputAction;
|
|
59
|
+
/**
|
|
60
|
+
* Unix epoch in milliseconds when the event was captured by the daemon.
|
|
61
|
+
*/
|
|
62
|
+
timestamp_ms: number;
|
|
63
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -19,5 +19,6 @@ export type { MethodSetActiveProfile } from './methods/set_active_profile.js';
|
|
|
19
19
|
export type { MethodSetAutoSwitch } from './methods/set_auto_switch.js';
|
|
20
20
|
export type { MethodSetBinding } from './methods/set_binding.js';
|
|
21
21
|
|
|
22
|
+
export type { EventActionInvoked } from './events/action_invoked.js';
|
|
22
23
|
export type { EventActiveProfileChanged } from './events/active_profile_changed.js';
|
|
23
24
|
export type { EventInput } from './events/input.js';
|
|
@@ -59,7 +59,7 @@ export interface Binding {
|
|
|
59
59
|
*/
|
|
60
60
|
export interface Action {
|
|
61
61
|
/**
|
|
62
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
62
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
63
63
|
*/
|
|
64
64
|
type: string;
|
|
65
65
|
/**
|
|
@@ -63,7 +63,7 @@ export interface Binding {
|
|
|
63
63
|
*/
|
|
64
64
|
export interface Action {
|
|
65
65
|
/**
|
|
66
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
66
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
67
67
|
*/
|
|
68
68
|
type: string;
|
|
69
69
|
/**
|
package/src/methods/hello.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface MethodHello {
|
|
|
32
32
|
*/
|
|
33
33
|
export interface PeerInfo {
|
|
34
34
|
/**
|
|
35
|
-
* Stable identifier of the peer implementation.
|
|
35
|
+
* Stable identifier of the peer implementation. A plugin must send its PluginID here; the daemon checks it against the plugin its auth token belongs to.
|
|
36
36
|
*/
|
|
37
37
|
name: string;
|
|
38
38
|
/**
|
|
@@ -59,7 +59,7 @@ export interface Binding {
|
|
|
59
59
|
*/
|
|
60
60
|
export interface Action {
|
|
61
61
|
/**
|
|
62
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
62
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
63
63
|
*/
|
|
64
64
|
type: string;
|
|
65
65
|
/**
|
|
@@ -46,13 +46,10 @@ export interface ActionDescriptor {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Describes one action parameter so a client can render an input for it.
|
|
49
|
-
*
|
|
50
|
-
* This interface was referenced by `MethodListActions`'s JSON-Schema
|
|
51
|
-
* via the `definition` "ParamSpec".
|
|
52
49
|
*/
|
|
53
50
|
export interface ParamSpec {
|
|
54
51
|
/**
|
|
55
|
-
* Param key written into Action.params.
|
|
52
|
+
* Param key written into Action.params. Unique within the action.
|
|
56
53
|
*/
|
|
57
54
|
name: string;
|
|
58
55
|
/**
|
|
@@ -43,7 +43,7 @@ export interface Binding {
|
|
|
43
43
|
*/
|
|
44
44
|
export interface Action {
|
|
45
45
|
/**
|
|
46
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
46
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
47
47
|
*/
|
|
48
48
|
type: string;
|
|
49
49
|
/**
|
|
@@ -64,7 +64,7 @@ export interface Binding {
|
|
|
64
64
|
*/
|
|
65
65
|
export interface Action {
|
|
66
66
|
/**
|
|
67
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
67
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
68
68
|
*/
|
|
69
69
|
type: string;
|
|
70
70
|
/**
|
|
@@ -40,7 +40,7 @@ export interface Binding {
|
|
|
40
40
|
*/
|
|
41
41
|
export interface Action {
|
|
42
42
|
/**
|
|
43
|
-
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'.
|
|
43
|
+
* Action type. Built-ins are well-known; plugin actions use 'plugin.<plugin_id>.<action_id>'. Plugin ids are reverse-DNS (they contain dots) and action ids never do, so the action id is everything after the last dot.
|
|
44
44
|
*/
|
|
45
45
|
type: string;
|
|
46
46
|
/**
|