@tetherto/mdk-worker 0.0.0 → 0.12.1

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.
@@ -0,0 +1,138 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$comment": "This schema describes a static Worker Plugin contract. Runtime device IDs and connection configuration belong to the host process and are reported dynamically by WorkerRuntime identity responses; they are intentionally not embedded here.",
4
+ "title": "MDK Device-Lib Contract Schema",
5
+ "description": "Formal JSON Schema defining the unified programmatic and semantic capabilities contract for MDK device integration workers.",
6
+ "type": "object",
7
+ "required": [
8
+ "metadata",
9
+ "capabilities"
10
+ ],
11
+ "additionalProperties": false,
12
+ "properties": {
13
+ "$schema": { "type": "string" },
14
+ "metadata": {
15
+ "type": "object",
16
+ "description": "Identity and family metadata defining what the worker represents.",
17
+ "required": ["provider", "deviceFamily", "brand", "modelsSupported", "overview"],
18
+ "properties": {
19
+ "provider": { "type": "string", "description": "The corporate or individual provider behind the worker (e.g., 'microbt')." },
20
+ "deviceFamily": { "type": "string", "description": "The broad category of devices (e.g., 'miner', 'sensor', 'switchgear')." },
21
+ "brand": { "type": "string", "description": "The human-readable brand name of the device." },
22
+ "modelsSupported": {
23
+ "type": "array",
24
+ "items": { "type": "string" },
25
+ "description": "List of specific models this specific contract supports."
26
+ },
27
+ "overview": {
28
+ "type": "string",
29
+ "description": "Mandatory semantic overview. Used to instruct AI agents on the broad purpose and critical environmental constraints for this device group."
30
+ }
31
+ }
32
+ },
33
+ "capabilities": {
34
+ "type": "object",
35
+ "description": "The unified machine and semantic capabilities mapping for the device.",
36
+ "required": ["telemetry", "commands", "health", "errors"],
37
+ "properties": {
38
+ "telemetry": {
39
+ "type": "array",
40
+ "description": "Metrics continuously updated and read from the device. Natural semantic rules should be appended to the 'description' field.",
41
+ "items": {
42
+ "type": "object",
43
+ "required": ["name", "type", "handler", "description"],
44
+ "properties": {
45
+ "name": { "type": "string" },
46
+ "unit": { "type": "string" },
47
+ "type": { "type": "string", "enum": ["number", "string", "boolean", "object", "array"] },
48
+ "handler": { "type": "string", "description": "CommonJS handler path relative to the Worker Plugin directory. Removed from the contract published to Kernel." },
49
+ "description": { "type": "string", "description": "Human and AI readable metric description. Should include semantic boundaries (e.g., 'If 0, device is booting')." }
50
+ }
51
+ }
52
+ },
53
+ "commands": {
54
+ "type": "array",
55
+ "description": "Callable operations the device accepts.",
56
+ "items": {
57
+ "type": "object",
58
+ "required": ["name", "handler"],
59
+ "properties": {
60
+ "name": { "type": "string" },
61
+ "handler": { "type": "string", "description": "CommonJS handler path relative to the Worker Plugin directory. Removed from the contract published to Kernel." },
62
+ "description": { "type": "string", "description": "What the command does physically." },
63
+ "constraints": { "type": "string", "description": "Strict semantic limits (e.g., 'Do not call more than once every 15 minutes')." },
64
+ "examples": {
65
+ "type": "array",
66
+ "description": "Concrete AI instruction workflows for how to utilize this command optimally.",
67
+ "items": {
68
+ "type": "object",
69
+ "required": ["intent", "steps"],
70
+ "properties": {
71
+ "intent": { "type": "string", "description": "The goal or overarching reason for executing the workflow." },
72
+ "steps": { "type": "array", "items": { "type": "string" }, "description": "Step-by-step numbered execution plan for the AI." }
73
+ }
74
+ }
75
+ },
76
+ "params": {
77
+ "type": "array",
78
+ "description": "Input arguments required by the command.",
79
+ "items": {
80
+ "type": "object",
81
+ "required": ["name", "type"],
82
+ "properties": {
83
+ "name": { "type": "string" },
84
+ "type": { "type": "string", "enum": ["number", "string", "boolean", "object"] },
85
+ "required": { "type": "boolean", "description": "Whether the command handler requires this parameter." },
86
+ "enum": {
87
+ "type": "array",
88
+ "description": "Allowed values. WorkerRuntime rejects a command whose value is not listed (ERR_PARAM_ENUM) before the handler runs.",
89
+ "items": {}
90
+ },
91
+ "min": { "type": "number", "description": "Allowed minimum value (for numbers)." },
92
+ "max": { "type": "number", "description": "Allowed maximum value (for numbers)." }
93
+ }
94
+ }
95
+ },
96
+ "verify": {
97
+ "type": "object",
98
+ "description": "Device-state readback after the command settles. Kernel pulls the `telemetry` metric until it equals the request's `param` value (verification VERIFIED) or `withinMs` passes (UNVERIFIED).",
99
+ "required": ["telemetry", "param"],
100
+ "properties": {
101
+ "telemetry": { "type": "string", "description": "Name of a telemetry entry that reports the state this command sets." },
102
+ "param": { "type": "string", "description": "Name of the command param holding the requested value." },
103
+ "withinMs": { "type": "number", "minimum": 1, "description": "How long to keep reading back before UNVERIFIED. Default 60000." }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ },
109
+ "config": {
110
+ "type": "object",
111
+ "description": "Device configuration models.",
112
+ "properties": {
113
+ "schema": { "type": "string", "description": "Reference identifier for config payload shape." }
114
+ }
115
+ },
116
+ "health": {
117
+ "type": "object",
118
+ "description": "Standardized diagnostic mappings.",
119
+ "required": ["supportedStates"],
120
+ "properties": {
121
+ "supportedStates": { "type": "array", "items": { "type": "string" } },
122
+ "alerts": { "type": "array", "items": { "type": "string" } },
123
+ "troubleshooting": {
124
+ "type": "array",
125
+ "items": { "type": "string" },
126
+ "description": "Semantic AI reasoning array. Provides if-then remediation workflows for specific failures."
127
+ }
128
+ }
129
+ },
130
+ "errors": {
131
+ "type": "object",
132
+ "description": "Lookup table mapping specific device error codes to human/AI-readable text.",
133
+ "additionalProperties": { "type": "string" }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
package/package.json CHANGED
@@ -1 +1,59 @@
1
- {"name":"@tetherto/mdk-worker","version":"0.0.0"}
1
+ {
2
+ "name": "@tetherto/mdk-worker",
3
+ "version": "0.12.1",
4
+ "description": "MDK Worker Runtime — hosts a Worker Plugin's devices behind one HRPC channel to the Kernel",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "tether",
8
+ "mdk",
9
+ "worker"
10
+ ],
11
+ "author": "Tether",
12
+ "license": "Apache-2.0",
13
+ "engines": {
14
+ "node": ">=24"
15
+ },
16
+ "type": "commonjs",
17
+ "scripts": {
18
+ "lint": "standard",
19
+ "lint:fix": "standard --fix",
20
+ "test": "npm run lint && npm run test:unit && npm run test:integration",
21
+ "test:unit": "NODE_ENV=test brittle tests/unit/*.test.js",
22
+ "test:integration": "NODE_ENV=test brittle tests/integration/*.test.js",
23
+ "test:coverage": "NODE_ENV=test brittle --coverage 'tests/**/*.test.js'"
24
+ },
25
+ "dependencies": {
26
+ "@tetherto/mdk-kernel": "^0.12.1",
27
+ "@hyperswarm/rpc": "3.5.0",
28
+ "debug": "4.4.1",
29
+ "hyperdht": "6.34.1",
30
+ "hyperswarm": "4.17.0"
31
+ },
32
+ "devDependencies": {
33
+ "brittle": "3.18.0",
34
+ "standard": "17.1.2"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/tetherto/mdk.git",
39
+ "directory": "backend/core/mdk-worker"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "files": [
45
+ "index.js",
46
+ "device.js",
47
+ "lib/",
48
+ "mdk-contract.schema.json",
49
+ "README.md"
50
+ ],
51
+ "exports": {
52
+ ".": "./index.js",
53
+ "./device": "./device.js",
54
+ "./lib/module-context": "./lib/module-context.js",
55
+ "./lib/worker-runtime": "./lib/worker-runtime.js",
56
+ "./mdk-contract.schema.json": "./mdk-contract.schema.json",
57
+ "./package.json": "./package.json"
58
+ }
59
+ }