@jdg-keyforge/protocol 0.9.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 +33 -4
- 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/hello.d.ts +1 -1
- package/package.json +1 -1
- package/src/common.ts +33 -4
- package/src/events/action_invoked.ts +63 -0
- package/src/index.ts +1 -0
- package/src/methods/hello.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
|
*/
|
|
@@ -268,6 +283,23 @@ export interface ParamSpec {
|
|
|
268
283
|
*/
|
|
269
284
|
placeholder?: string;
|
|
270
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
|
+
}
|
|
271
303
|
/**
|
|
272
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.
|
|
273
305
|
*
|
|
@@ -279,10 +311,7 @@ export interface PluginManifest {
|
|
|
279
311
|
* Manifest format version. Currently 1; bumped if the manifest shape changes.
|
|
280
312
|
*/
|
|
281
313
|
manifest_version: 1;
|
|
282
|
-
|
|
283
|
-
* 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.
|
|
284
|
-
*/
|
|
285
|
-
id: string;
|
|
314
|
+
id: PluginID2;
|
|
286
315
|
/**
|
|
287
316
|
* Human-friendly plugin name for the UI.
|
|
288
317
|
*/
|
|
@@ -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';
|
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
|
/**
|
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.
|
|
@@ -271,6 +286,23 @@ export interface ParamSpec {
|
|
|
271
286
|
*/
|
|
272
287
|
placeholder?: string;
|
|
273
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
|
+
}
|
|
274
306
|
/**
|
|
275
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.
|
|
276
308
|
*
|
|
@@ -282,10 +314,7 @@ export interface PluginManifest {
|
|
|
282
314
|
* Manifest format version. Currently 1; bumped if the manifest shape changes.
|
|
283
315
|
*/
|
|
284
316
|
manifest_version: 1;
|
|
285
|
-
|
|
286
|
-
* 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.
|
|
287
|
-
*/
|
|
288
|
-
id: string;
|
|
317
|
+
id: PluginID2;
|
|
289
318
|
/**
|
|
290
319
|
* Human-friendly plugin name for the UI.
|
|
291
320
|
*/
|
|
@@ -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';
|
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
|
/**
|