@tetherto/mdk-skill 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.
- package/LICENSE +202 -0
- package/README.md +133 -0
- package/dist/skills/mdk/SKILL.md +114 -0
- package/dist/skills/mdk/references/architecture.md +89 -0
- package/dist/skills/mdk/references/glossary.md +27 -0
- package/dist/skills/mdk/references/mdk-contract.schema.json +138 -0
- package/dist/skills/mdk/references/package-index.md +53 -0
- package/dist/skills/mdk/references/protocol.md +95 -0
- package/dist/skills/mdk-create-app/SKILL.md +231 -0
- package/dist/skills/mdk-deployment/SKILL.md +161 -0
- package/dist/skills/mdk-gateway-plugin/SKILL.md +192 -0
- package/dist/skills/mdk-gateway-plugin/references/controller-patterns.md +99 -0
- package/dist/skills/mdk-gateway-plugin/references/plugin-authoring.md +121 -0
- package/dist/skills/mdk-publish-security/SKILL.md +177 -0
- package/dist/skills/mdk-publish-security/references/vuln-classes.md +151 -0
- package/dist/skills/mdk-publish-security/scripts/scan-packages.mjs +544 -0
- package/dist/skills/mdk-site-sizing/SKILL.md +160 -0
- package/dist/skills/mdk-site-sizing/eval/held-out.json +104 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-100devices-2workers-mixed.json +24 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-100devices-2workers.json +23 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-10devices-1workers.json +23 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-15devices-2workers.json +24 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-200devices-4workers.json +23 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-500devices-4workers.json +23 -0
- package/dist/skills/mdk-site-sizing/eval/profiles/cap-50devices-2workers.json +23 -0
- package/dist/skills/mdk-site-sizing/references/envelope.json +284 -0
- package/dist/skills/mdk-site-sizing/references/envelope.md +42 -0
- package/dist/skills/mdk-site-sizing/scripts/compile-envelope.mjs +45 -0
- package/dist/skills/mdk-site-sizing/scripts/eval-held-out.mjs +50 -0
- package/dist/skills/mdk-site-sizing/scripts/lib.mjs +591 -0
- package/dist/skills/mdk-site-sizing/scripts/parse-site.mjs +25 -0
- package/dist/skills/mdk-site-sizing/scripts/size-site.mjs +49 -0
- package/dist/skills/mdk-ui-component/SKILL.md +207 -0
- package/dist/skills/mdk-ui-component/references/page-recipe.md +78 -0
- package/dist/skills/mdk-ui-component/references/ui-registry.json +1 -0
- package/dist/skills/mdk-worker-plugin/SKILL.md +198 -0
- package/dist/skills/mdk-worker-plugin/assets/mdk-contract.template.json +45 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/README.md +93 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/mdk-contract.json +26 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/mock/server.js +93 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/package.json +23 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/smoke.config.js +41 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/client.js +47 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/commands/reboot.js +5 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/commands/set-power-mode.js +10 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/telemetry/hashrate-rt.js +5 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/telemetry/power-mode.js +5 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/telemetry/power.js +5 -0
- package/dist/skills/mdk-worker-plugin/assets/worker-template/src/telemetry/temperature.js +5 -0
- package/dist/skills/mdk-worker-plugin/references/contract-authoring.md +135 -0
- package/dist/skills/mdk-worker-plugin/references/device-families.md +96 -0
- package/dist/skills/mdk-worker-plugin/references/local-testing.md +134 -0
- package/dist/skills/mdk-worker-plugin/references/mdk-contract.schema.json +138 -0
- package/dist/skills/mdk-worker-plugin/references/worker-base-api.md +152 -0
- package/dist/skills/mdk-worker-plugin/scripts/validate-contract.mjs +129 -0
- package/dist/skills/mdk-worker-plugin/scripts/worker-smoke.mjs +256 -0
- package/package.json +47 -1
- package/src/assemble.mjs +11 -0
- package/src/index.d.ts +57 -0
- package/src/index.mjs +254 -0
- package/src/install.mjs +57 -0
- package/src/sources.map.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Tether
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @tetherto/mdk-skill
|
|
2
|
+
|
|
3
|
+
The **MDK Developer Skill suite**: version-controlled procedural context, in
|
|
4
|
+
the universal Agent Skills format (`SKILL.md`), that makes any
|
|
5
|
+
skills-compatible coding agent (Cursor, Claude Code, …) fluent in MDK
|
|
6
|
+
conventions the moment the repo is cloned.
|
|
7
|
+
|
|
8
|
+
The suite ships eight flat skills: the `mdk` router plus full workflows for
|
|
9
|
+
device Workers, app routes served through the Gateway, MDK Apps, UI pages, stack deployment, site sizing
|
|
10
|
+
from a measured envelope, and the pre-publish security audit. Composite prompts (e.g. "create a UI to show
|
|
11
|
+
\<metric\> for \<device family\>") are routed as an ordered chain in
|
|
12
|
+
[`mdk/SKILL.md`](./src/skills/mdk/SKILL.md).
|
|
13
|
+
|
|
14
|
+
Consumers install the suite with `mdk skill add`; see the
|
|
15
|
+
[agent skills guide](../../docs/guides/ui/agent-skills.md). The rest of this
|
|
16
|
+
README is for working on the suite itself.
|
|
17
|
+
|
|
18
|
+
## Layout
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
src/
|
|
22
|
+
├── skills/ # Suite content (flat: one dir per skill), hand-authored except where noted
|
|
23
|
+
│ ├── mdk/ # Router + suite-wide references/
|
|
24
|
+
│ ├── mdk-worker-plugin/ # Worker plugin workflow + scripts/assets
|
|
25
|
+
│ ├── mdk-gateway-plugin/ # App route table + controllers workflow (scaffold via `mdk create app`)
|
|
26
|
+
│ ├── mdk-create-app/ # MDK App workflow (package layout, manifest, plugin, UI; `mdk create app`)
|
|
27
|
+
│ ├── mdk-ui-component/ # Dashboard page workflow + ui-registry (generated)
|
|
28
|
+
│ ├── mdk-deployment/ # mdk.yaml / mdk run workflow
|
|
29
|
+
│ ├── mdk-site-sizing/ # Size a site from a description + measured envelope
|
|
30
|
+
│ └── mdk-publish-security/ # Pre-publish security audit: tarball scan + 18-class review
|
|
31
|
+
├── sources.map.json # Source-of-truth -> bundle mapping (contract schema comes from backend/core/mdk-worker)
|
|
32
|
+
├── index.mjs # Programmatic entry point (assemble / installSkills)
|
|
33
|
+
├── index.d.ts # TypeScript types for the entry point
|
|
34
|
+
├── assemble.mjs # CLI wrapper -> dist/skills/
|
|
35
|
+
└── install.mjs # CLI wrapper: dist/skills/* -> .cursor|.claude/skills/
|
|
36
|
+
dist/skills/ # Assembled suite — build output, gitignored, never hand-edited
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
[`skills/mdk-ui-component/references/ui-registry.json`](./src/skills/mdk-ui-component/references/ui-registry.json) is generated, not hand-authored. It is a verbatim copy of the devkit's
|
|
40
|
+
`dist/registry.json`, written by [`docs/scripts/sync-ui-registry.mjs`](../../docs/scripts/sync-ui-registry.mjs). Regenerate it with
|
|
41
|
+
`npm run generate:ui-registry` from the repo root, which rebuilds the devkit registry and rewrites this file. Hand-edits do not survive the next run,
|
|
42
|
+
and a stale copy tells coding agents to use component props that no longer exist. The
|
|
43
|
+
`docs-freshness` workflow watches this file and its devkit source on PRs and
|
|
44
|
+
fails the check when it drifts. The job summary shows what differs; fix it by running `npm run generate:ui-registry` (or
|
|
45
|
+
`npm run regenerate-docs`) and committing the result.
|
|
46
|
+
|
|
47
|
+
Skills are assembled and installed **flat** — clients discover
|
|
48
|
+
`<skills-dir>/<name>/SKILL.md` one level deep, and each skill's `description`
|
|
49
|
+
frontmatter is its routing trigger. Copied artifacts (the Worker template, the
|
|
50
|
+
contract schema) are taken from their owning packages by [`assemble.mjs`](./src/assemble.mjs), never
|
|
51
|
+
hand-maintained, so the bundle cannot drift from the source of truth.
|
|
52
|
+
|
|
53
|
+
## Build and install
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
node src/assemble.mjs # build dist/skills/ (also runs on npm prepack)
|
|
57
|
+
npm run install:skills # assemble + copy into the enclosing repo's
|
|
58
|
+
# .cursor/skills/ and .claude/skills/ (gitignored)
|
|
59
|
+
node src/install.mjs --client cursor # one client only
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Programmatic API
|
|
63
|
+
|
|
64
|
+
Consume the package (e.g. from the MDK CLI) instead of shelling out to the
|
|
65
|
+
scripts. Resolution goes through node/npm, so it works both as a published
|
|
66
|
+
dependency and as a local workspace package.
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import { installSkills } from '@tetherto/mdk-skill'
|
|
70
|
+
|
|
71
|
+
// Copies the assembled skills into <target>/.cursor/skills and/or
|
|
72
|
+
// <target>/.claude/skills. Assembles on demand inside the monorepo.
|
|
73
|
+
// Stale MDK-shipped skills (renamed or dropped since the last install) are
|
|
74
|
+
// removed; each `installed` entry lists them in `removed`. Skills without the
|
|
75
|
+
// `suite: mdk-developer-skill` frontmatter stamp are never touched, and a
|
|
76
|
+
// same-named one is reported in `skipped`.
|
|
77
|
+
const { skills, installed, skipped } = installSkills({ client: 'all', target: process.cwd() })
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Install safety: it throws if `.cursor`, `.claude` or their `skills` dir under
|
|
81
|
+
the target is a symlink, and it only replaces an existing `<skills-dir>/<name>`
|
|
82
|
+
whose `SKILL.md` carries `metadata.suite: mdk-developer-skill`. Symlinked or
|
|
83
|
+
foreign skill dirs with a suite skill's name are left alone, listed in
|
|
84
|
+
`skipped`, and reported through `onWarn` (default `console.warn`).
|
|
85
|
+
|
|
86
|
+
Also exported: `assemble()`, `isAssembled()`, `canAssemble()`, and `CLIENT_DIRS`.
|
|
87
|
+
|
|
88
|
+
## Try it — routing prompts
|
|
89
|
+
|
|
90
|
+
Open the repo in a skills-aware agent after installing, then check that each
|
|
91
|
+
prompt activates the matching skills:
|
|
92
|
+
|
|
93
|
+
| Example prompt | Skills it should invoke |
|
|
94
|
+
| ----------------------------------------------------------- | ----------------------------------- |
|
|
95
|
+
| "Add a new power meter Worker for our site" | `mdk-worker-plugin` |
|
|
96
|
+
| "I need to integrate a new miner device into MDK" | `mdk-worker-plugin` |
|
|
97
|
+
| "Author an mdk-contract.json for a temperature sensor" | `mdk-worker-plugin` |
|
|
98
|
+
| "Build a plugin that aggregates hashrate across all miners" | `mdk-gateway-plugin` |
|
|
99
|
+
| "Add a cross-Worker endpoint that rolls up a site summary" | `mdk-gateway-plugin` |
|
|
100
|
+
| "Create a dashboard widget that shows live telemetry from a Worker" | `mdk-ui-component` (and `mdk-gateway-plugin` if no `/api` route yet) |
|
|
101
|
+
| "Create a UI to show \<metric\> for \<device family\>" | discover → `mdk-gateway-plugin` → `mdk-deployment` → `mdk-ui-component` |
|
|
102
|
+
| "How do I deploy the MDK stack?" | `mdk-deployment` |
|
|
103
|
+
| "Size this site: 80 Whatsminer M56S on a 16-core NVMe box" | `mdk-site-sizing` |
|
|
104
|
+
| "Security check the packages before we publish to npm" | `mdk-publish-security` |
|
|
105
|
+
| "Create an MDK app called sentinel" | `mdk-create-app` |
|
|
106
|
+
| "What is MDK and how is it structured?" | `mdk` (router) |
|
|
107
|
+
|
|
108
|
+
## Verify the device-Worker skill
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# contract validation (exit 0/1); add --schema-only to skip the semantic checks
|
|
112
|
+
node dist/skills/mdk-worker-plugin/scripts/validate-contract.mjs \
|
|
113
|
+
packages/cli/templates/worker/mdk-contract.json
|
|
114
|
+
|
|
115
|
+
# in-process smoke: telemetry sweep + command bounds, no Kernel, no DHT
|
|
116
|
+
node dist/skills/mdk-worker-plugin/scripts/worker-smoke.mjs <worker-dir>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The end-to-end proof of the skill is scaffolding a new Worker from
|
|
120
|
+
[`dist/skills/mdk-worker-plugin/SKILL.md`](./src/skills/mdk-worker-plugin/SKILL.md) alone — contract validation, smoke
|
|
121
|
+
pass, and brittle unit tests all green before the Worker ever meets a Kernel.
|
|
122
|
+
|
|
123
|
+
## Verify the site-sizing skill
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# compile eval/profiles into references/envelope.json, then the held-out bar
|
|
127
|
+
npm test --workspace=@tetherto/mdk-skill
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The bar: the Skill's recommendations match the measured envelope on a held-out
|
|
131
|
+
set of site descriptions. `eval-held-out.mjs` parses each case in
|
|
132
|
+
[`src/skills/mdk-site-sizing/eval/held-out.json`](./src/skills/mdk-site-sizing/eval/held-out.json)
|
|
133
|
+
and exits 0 only when every recommendation matches.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mdk
|
|
3
|
+
description: >
|
|
4
|
+
Build on the MDK (Mining Device Kit) platform. Use whenever a task mentions
|
|
5
|
+
MDK, the Kernel, a Worker, a Worker Plugin, mdk-contract.json,
|
|
6
|
+
@tetherto/mdk-* packages, a miner / power meter / sensor / container
|
|
7
|
+
integration, a cross-worker aggregation endpoint, a UI component for
|
|
8
|
+
Worker/plugin data, or deploying an MDK stack.
|
|
9
|
+
metadata:
|
|
10
|
+
suite: mdk-developer-skill
|
|
11
|
+
mdk_version: "0.5.0"
|
|
12
|
+
license: Apache-2.0
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Building on MDK
|
|
16
|
+
|
|
17
|
+
MDK is a P2P mining device management platform layered as:
|
|
18
|
+
**Consumers → Gateway (or the standalone MCP server) → Kernel → Workers → Devices**.
|
|
19
|
+
|
|
20
|
+
The Kernel ([`backend/core/kernel`](../../../../../backend/core/kernel/README.md)) discovers Workers over the Hyperswarm DHT,
|
|
21
|
+
pulls telemetry, dispatches commands, and monitors health. Workers
|
|
22
|
+
([`backend/workers/`](../../../../../backend/workers/README.md)) are device-protocol adapters: a **Worker Plugin**, either
|
|
23
|
+
a directory-loaded package (`mdk-contract.json` + `src/` handlers, hosted on
|
|
24
|
+
`WorkerRuntimeV2` — the shape `mdk create worker` scaffolds) or the older
|
|
25
|
+
`{ contract, dir, connect }` + handler-module shape hosted on the generic
|
|
26
|
+
`WorkerRuntime` ([`backend/core/mdk-worker`](../../../../../backend/core/mdk-worker/index.js); both shapes are documented in
|
|
27
|
+
[`../mdk-worker-plugin/references/worker-base-api.md`](../mdk-worker-plugin/references/worker-base-api.md)).
|
|
28
|
+
All Kernel ↔ Worker communication is MDK Protocol envelopes over
|
|
29
|
+
`@hyperswarm/rpc` — never direct method calls.
|
|
30
|
+
|
|
31
|
+
Load [`references/architecture.md`](./references/architecture.md) when you need the module-level picture, and
|
|
32
|
+
[`references/protocol.md`](./references/protocol.md) before touching anything that sends or receives
|
|
33
|
+
envelopes. [`references/package-index.md`](./references/package-index.md) maps every package name to its actual
|
|
34
|
+
folder. [`references/glossary.md`](./references/glossary.md) decodes the terminology.
|
|
35
|
+
|
|
36
|
+
## Route to the right skill
|
|
37
|
+
|
|
38
|
+
Skills are installed as flat siblings — each row names a skill directory next
|
|
39
|
+
to this one. **Read this table first** on every MDK task; many user prompts
|
|
40
|
+
need more than one skill in order.
|
|
41
|
+
|
|
42
|
+
### Single-skill tasks
|
|
43
|
+
|
|
44
|
+
| Task purpose | Use skill | Read first |
|
|
45
|
+
| -------------------------------- | ------------------------------------ | ----------------------- |
|
|
46
|
+
| Integrate a new device (miner, power meter, sensor, container) | `mdk-worker-plugin` | [`references/protocol.md`](./references/protocol.md) |
|
|
47
|
+
| Add / change a Gateway aggregation HTTP endpoint only | `mdk-gateway-plugin` | Worker `mdk-contract.json` |
|
|
48
|
+
| Scaffold a new MDK App package ready to publish | `mdk-create-app` | [`mdk-create-app/SKILL.md`](../mdk-create-app/SKILL.md) |
|
|
49
|
+
| Build a UI page/widget for an **existing** `/api/...` route | `mdk-ui-component` | [`mdk-ui-component/references/ui-registry.json`](../mdk-ui-component/references/ui-registry.json) |
|
|
50
|
+
| Deploy / run / register apps in `mdk.yaml` | `mdk-deployment` | project `mdk.yaml` |
|
|
51
|
+
| Size a site from a description (Workers, host tier, envelope) | `mdk-site-sizing` | [`mdk-site-sizing/references/envelope.json`](../mdk-site-sizing/references/envelope.json) |
|
|
52
|
+
| Security-audit packages before an npm publish | `mdk-publish-security` | [`mdk-publish-security/references/vuln-classes.md`](../mdk-publish-security/references/vuln-classes.md) |
|
|
53
|
+
|
|
54
|
+
### Composite prompts (use multiple skills, in order)
|
|
55
|
+
|
|
56
|
+
Prompts like **"create a UI to show \<metric\> for a \<device\>"** are
|
|
57
|
+
**not** UI-only. Follow this chain:
|
|
58
|
+
|
|
59
|
+
| Step | Skill | What you do |
|
|
60
|
+
| ---- | -------------------------------- | ------------------------------------- |
|
|
61
|
+
| 1 | *(discovery)* | Resolve each `mdk.yaml` → `spec.workers[].package` to its `mdk-contract.json` at the package root (or legacy `plugin/mdk-contract.json`); confirm the telemetry channel, unit, and brand/fingerprint exist |
|
|
62
|
+
| 2 | `mdk-gateway-plugin` | If no Gateway route returns that shaped metric, `mdk create app <name>` (scaffolds + registers under `mdk.yaml` → `spec.apps`; manifest rules in `mdk-create-app`) then write the controller + `plugin/mdk-plugin.json` |
|
|
63
|
+
| 3 | `mdk-deployment` | Restart with `mdk run` (or `mdk run app <name>`) as needed |
|
|
64
|
+
| 4 | `mdk-ui-component` | Hook (`useQuery`) → presentational panel → thin page → `routes.ts`; props from [`ui-registry.json`](../mdk-ui-component/references/ui-registry.json) only |
|
|
65
|
+
| 5 | `mdk-deployment` | Verify with `curl` + running dashboard |
|
|
66
|
+
|
|
67
|
+
Skip step 2–3 when the route already exists and returns the right JSON.
|
|
68
|
+
Skip step 1's device work — if the Worker/channel is missing, insert
|
|
69
|
+
`mdk-worker-plugin` **before** step 2.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
User: "show / UI / dashboard for <metric> on <device family>"
|
|
73
|
+
│
|
|
74
|
+
▼
|
|
75
|
+
Contract exists? ──no──► mdk-worker-plugin ──┐
|
|
76
|
+
│ yes │
|
|
77
|
+
▼ ▼
|
|
78
|
+
/api route exists? ──no──► mdk-gateway-plugin ──► mdk-deployment
|
|
79
|
+
│ yes │
|
|
80
|
+
▼ ▼
|
|
81
|
+
mdk-ui-component ◄──────────────────────────┘
|
|
82
|
+
│
|
|
83
|
+
▼
|
|
84
|
+
mdk-deployment (smoke: curl + UI)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Quick examples
|
|
88
|
+
|
|
89
|
+
| User says | Skills (ordered) |
|
|
90
|
+
| ------------------------------------------------------ | ---------------------------------------- |
|
|
91
|
+
| "Create a UI to show \<metric\> for \<device family\>" | discover contract → `mdk-gateway-plugin` → `mdk-deployment` → `mdk-ui-component` |
|
|
92
|
+
| "Add a fleet-wide rollup API" | `mdk-gateway-plugin` → `mdk-deployment` |
|
|
93
|
+
| "Chart the existing `/api/...` in the dashboard" | `mdk-ui-component` |
|
|
94
|
+
| "Integrate a new Modbus meter" | `mdk-worker-plugin` |
|
|
95
|
+
| "Start Kernel + Worker + Gateway" | `mdk-deployment` |
|
|
96
|
+
| "Size this site / how many Workers for N miners" | `mdk-site-sizing` |
|
|
97
|
+
| "Audit the packages before we publish" | `mdk-publish-security` |
|
|
98
|
+
|
|
99
|
+
## Non-negotiable invariants
|
|
100
|
+
|
|
101
|
+
- **Workers never call the Kernel.** The protocol is unidirectional: the
|
|
102
|
+
Kernel pulls (`telemetry.pull`, `state.pull`, `health.ping`) and pushes
|
|
103
|
+
commands (`command.request`). A Worker only ever answers `handleRequest`.
|
|
104
|
+
- **`mdk-contract.json` is the single source of truth** for a Worker's
|
|
105
|
+
telemetry, commands, health states and error codes. Validate it against
|
|
106
|
+
`references/mdk-contract.schema.json` (the Kernel terminates Workers whose
|
|
107
|
+
capability payload is malformed, and rejects commands not declared in it).
|
|
108
|
+
- **Never add transport-level envelope fields.** The envelope is exactly
|
|
109
|
+
`{ id, version, type, action, sender, target, deviceId, timestamp, payload }`
|
|
110
|
+
— extend `payload` instead.
|
|
111
|
+
- **Use canonical `@tetherto/mdk-*` names only** — the full list lives in
|
|
112
|
+
[`references/package-index.md`](./references/package-index.md).
|
|
113
|
+
- **Never invent UI prop names or telemetry fields** — registry + contracts
|
|
114
|
+
only (`mdk-ui-component` / `mdk-gateway-plugin`).
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# MDK architecture
|
|
2
|
+
|
|
3
|
+
Load this when you need to know which module owns a behavior, or where a
|
|
4
|
+
request travels between a consumer and a physical device.
|
|
5
|
+
|
|
6
|
+
## Layers
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
Consumers (UI, CLI, agents)
|
|
10
|
+
│ HTTP / @tetherto/mdk-client
|
|
11
|
+
Gateway (backend/core/gateway, boot glue in backend/core/mdk)
|
|
12
|
+
│ MDK envelopes over HRPC
|
|
13
|
+
Kernel (backend/core/kernel)
|
|
14
|
+
│ MDK envelopes over HRPC ('mdk' method), discovery via Hyperswarm DHT
|
|
15
|
+
Workers — WorkerRuntime/WorkerRuntimeV2 hosting a Worker Plugin (backend/core/mdk-worker + backend/workers/*)
|
|
16
|
+
│ vendor protocol: CGMiner TCP, HTTP JSON, Modbus TCP, MQTT…
|
|
17
|
+
Devices (miners, power meters, sensors, containers)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Kernel modules ([`backend/core/kernel/lib/modules/`](../../../../../../backend/core/kernel/lib/modules/))
|
|
21
|
+
|
|
22
|
+
Each module has one job and modules never cross-call, they interact through the interfaces they expose:
|
|
23
|
+
|
|
24
|
+
| Module | Job |
|
|
25
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| `worker-registry` | `deviceId` → `workerId` → channel mapping; source of truth for routability; explicit state transition table |
|
|
27
|
+
| `command-dispatcher` | Validates a command against the Worker's declared capabilities (name, param types, `min`/`max` bounds → `ERR_PARAM_RANGE`) and routes it |
|
|
28
|
+
| `command-state-machine` | Command lifecycle with explicit transition table; every mutation is WAL'd before it takes effect; emits `command:done` |
|
|
29
|
+
| `telemetry-collector` | Pull-based: sends `telemetry.pull`, returns the raw Worker payload |
|
|
30
|
+
| `health-monitor` | Ping-based (`health.ping`); updates registry health state only |
|
|
31
|
+
| `scheduler` | Drives the periodic pull/ping cadences |
|
|
32
|
+
| `action-manager` / `action-caller` | Write-action approval lifecycle (`action.push`, `action.vote`, …) between Gateway and Kernel |
|
|
33
|
+
|
|
34
|
+
The protocol layer ([`backend/core/kernel/lib/protocol/`](../../../../../../backend/core/kernel/lib/protocol/)) owns the envelope
|
|
35
|
+
([`envelope.js`](../../../../../../backend/core/kernel/lib/protocol/envelope.js)), the action set ([`actions.js`](../../../../../../backend/core/kernel/lib/protocol/actions.js)) and per-action payload
|
|
36
|
+
validators ([`schemas.js`](../../../../../../backend/core/kernel/lib/protocol/schemas.js)); [`protocol.md`](./protocol.md) documents these in full.
|
|
37
|
+
|
|
38
|
+
## Worker side
|
|
39
|
+
|
|
40
|
+
Two Worker Plugin shapes exist side by side, hosted on two runtime classes
|
|
41
|
+
that share the same envelope dispatch, DHT discovery, and Kernel-facing
|
|
42
|
+
protocol. Details for both: [`../../mdk-worker-plugin/references/worker-base-api.md`](../../mdk-worker-plugin/references/worker-base-api.md).
|
|
43
|
+
|
|
44
|
+
A module-exporting Worker package ships a **Worker Plugin** — `plugin/index.js`
|
|
45
|
+
exporting `{ contract, dir, connect, disconnect? }` — plus plain device-client
|
|
46
|
+
code in `lib/`. It never subclasses anything and never depends on the runtime.
|
|
47
|
+
`WorkerRuntime` ([`backend/core/mdk-worker/lib/worker-runtime.js`](../../../../../../backend/core/mdk-worker/lib/worker-runtime.js)) is the
|
|
48
|
+
generic host: it loads the plugin (eagerly requiring every handler declared in
|
|
49
|
+
the contract), opens one frozen context `{ deviceId, device, config, services }`
|
|
50
|
+
per device via `connect()`, answers the `'mdk'` HRPC method by dispatching
|
|
51
|
+
envelopes to handlers, and announces itself on the Kernel's DHT topic. One
|
|
52
|
+
runtime hosts N same-type devices; a device whose `connect()` fails is held
|
|
53
|
+
`offline` (requests return `ERR_DEVICE_UNAVAILABLE`) without affecting
|
|
54
|
+
siblings. This is the shape every currently shipped device family
|
|
55
|
+
(`backend/workers/miners/*`, `power-meter/*`, `containers/*`, `minerpools/*`,
|
|
56
|
+
`temperature/*`) still uses.
|
|
57
|
+
|
|
58
|
+
A directory-loaded Worker package ships no module of its own: just
|
|
59
|
+
`mdk-contract.json` at its root plus the handler files it declares under
|
|
60
|
+
`src/` — no `plugin/index.js`, no `connect()`/`disconnect()`. `WorkerRuntimeV2`
|
|
61
|
+
([`backend/core/mdk-worker/lib/worker-runtime-v2.js`](../../../../../../backend/core/mdk-worker/lib/worker-runtime-v2.js))
|
|
62
|
+
takes the package's directory in place of a plugin object, and handlers are
|
|
63
|
+
plain `async (params) => result` functions that read their device from the
|
|
64
|
+
ambient `@tetherto/mdk-worker/device` module instead of a `ctx` argument.
|
|
65
|
+
There is no boot-time probe and no offline state: every device reports
|
|
66
|
+
`online` immediately, and an unreachable one surfaces as an error inside the
|
|
67
|
+
telemetry payload instead. This is the shape `mdk create worker` scaffolds
|
|
68
|
+
today; the scaffold itself, [`packages/cli/templates/worker/`](../../../../../cli/templates/worker/README.md), is the reference
|
|
69
|
+
implementation in this repo.
|
|
70
|
+
|
|
71
|
+
## Discovery and request flow
|
|
72
|
+
|
|
73
|
+
1. A caller boots `WorkerRuntime` or `WorkerRuntimeV2` with a `kernelTopic`;
|
|
74
|
+
the runtime joins that Hyperswarm topic in server mode and writes its HRPC
|
|
75
|
+
public key to every incoming connection.
|
|
76
|
+
2. The Kernel connects to topic peers, learns the Worker's key, then sends
|
|
77
|
+
`identity.request` and `capability.request`; the registry records the
|
|
78
|
+
Worker's devices and its published contract (handler paths stripped).
|
|
79
|
+
3. The scheduler then drives `telemetry.pull` / `state.pull` / `health.ping`
|
|
80
|
+
on a cadence; consumers trigger `command.request` through the Gateway (agents through the standalone MCP server).
|
|
81
|
+
4. Commands flow Gateway (or MCP server) → dispatcher (capability + bounds validation) →
|
|
82
|
+
state machine (WAL) → Worker → `command.result` back up.
|
|
83
|
+
|
|
84
|
+
## Where things run
|
|
85
|
+
|
|
86
|
+
[`examples/mvp-site/start.js`](../../../../../../examples/mvp-site/start.js) boots the whole picture as PM2-supervised processes:
|
|
87
|
+
mock devices, Kernel, real Workers, Gateway, MCP server and UI. To host a single Worker
|
|
88
|
+
in-process with no Kernel, `mdk validate worker --path . --smoke` runs it against the
|
|
89
|
+
simulator its `smoke.config.js` starts; [`local-testing.md`](../../mdk-worker-plugin/references/local-testing.md) shows a minimal caller.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
| Term | Meaning |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| **MDK** | Mining Device Kit — the whole platform: Kernel, Workers, Gateway, client, UI toolkit. |
|
|
6
|
+
| **Kernel** | The orchestration core ([`backend/core/kernel`](../../../../../../backend/core/kernel/README.md), `@tetherto/mdk-kernel`): discovery, telemetry pulls, command dispatch, health. |
|
|
7
|
+
| **Worker** | A device-type adapter process: `WorkerRuntime` or `WorkerRuntimeV2` hosting a Worker Plugin, speaking MDK envelopes upward and the vendor protocol downward. |
|
|
8
|
+
| **Worker Plugin** | What a Worker package ships, one of two shapes: the older `plugin/index.js` exporting `{ contract, dir, connect, disconnect? }` plus handler modules under `plugin/src/` (every currently shipped device family), or a directory-loaded package exporting no module of its own — just `mdk-contract.json` at its root plus `src/` handlers (the shape `mdk create worker` scaffolds). Neither subclasses the runtime. |
|
|
9
|
+
| **WorkerRuntime** | Generic plugin host ([`backend/core/mdk-worker`](../../../../../../backend/core/mdk-worker/index.js)) for the module-exporting shape: loads the plugin, owns device contexts via `connect()`, answers envelopes over HRPC, announces on the DHT. |
|
|
10
|
+
| **WorkerRuntimeV2** | Host for the directory-loaded shape ([`backend/core/mdk-worker/lib/worker-runtime-v2.js`](../../../../../../backend/core/mdk-worker/lib/worker-runtime-v2.js)): takes a package directory instead of a plugin object, has no `connect()`/boot-time probe/offline state, and builds one plugin instance per device via `createInstance`. Shares envelope dispatch and DHT discovery with `WorkerRuntime`. |
|
|
11
|
+
| **Contract** (`mdk-contract.json`) | A Worker's single source of truth: metadata, telemetry channels, commands (with param types/bounds), health states, error codes. Simultaneously machine-validation input and AI context. |
|
|
12
|
+
| **Published contract** | The contract as returned on `capability.response` — a copy with internal `handler` paths stripped. |
|
|
13
|
+
| **Envelope** | The nine-field MDK Protocol message ([`protocol.md`](./protocol.md)). |
|
|
14
|
+
| **Action** | The envelope's verb, e.g. `telemetry.pull`, `command.request` ([`backend/core/kernel/lib/protocol/actions.js`](../../../../../../backend/core/kernel/lib/protocol/actions.js)). |
|
|
15
|
+
| **Channel** | One declared telemetry entry; pulled individually via `query.type = '<name>'` or all together via `type: 'metrics'`. |
|
|
16
|
+
| **Handler** | A plugin module mapped from a contract entry, never seeing envelopes or transport: `async (ctx, params) => result` on `WorkerRuntime`, or plain `async (params) => result` on `WorkerRuntimeV2` (no `ctx`). |
|
|
17
|
+
| **ctx** | `WorkerRuntime`'s frozen per-device handler context `{ deviceId, device, config, services }`; `device` is whatever `connect()` returned. `WorkerRuntimeV2` handlers have no `ctx` — see **Ambient device module**. |
|
|
18
|
+
| **connect / disconnect** | `WorkerRuntime`-only plugin lifecycle: `connect(config, { deviceId })` builds (and probes) a device client; failing devices are held `offline`. Directory-loaded (`WorkerRuntimeV2`) plugins have neither. |
|
|
19
|
+
| **Ambient device module** (`@tetherto/mdk-worker/device`) | What a `WorkerRuntimeV2` handler `require()`s to reach its own device: `{ id, opts, env, config, logger }`. Intercepted before real module resolution, scoped to one device via a private per-device module registry. |
|
|
20
|
+
| **Device** | One physical unit (a miner, a meter…) addressed by `deviceId`; a Worker owns its `deviceIds` exclusively. |
|
|
21
|
+
| **`kernelTopic`** | The Hyperswarm DHT topic a Kernel listens on; Workers join it (server mode) to be discovered. |
|
|
22
|
+
| **HRPC** | `@hyperswarm/rpc` — the transport; Workers expose one `'mdk'` method that takes and returns serialized envelopes. |
|
|
23
|
+
| **Worker-infra services** | Optional process-owned services (logs, settings, stats, comments, provisioning…) injected as `opts.services`; served as built-in telemetry types / commands ahead of plugin handlers. |
|
|
24
|
+
| **Mock** | A vendor-firmware simulator (per-worker `mock/server.js`, shared framework in [`backend/workers/mock/`](../../../../../../backend/workers/mock/README.md)) so Workers run without hardware. |
|
|
25
|
+
| **Gateway** | HTTP boundary in front of the Kernel ([`backend/core/gateway`](../../../../../../backend/core/gateway/README.md)) for UI/HTTP consumers; AI agents reach Kernel through the standalone MCP server instead. |
|
|
26
|
+
| **WAL** | Write-ahead log in the Kernel's command state machine: every state mutation is logged before it takes effect. |
|
|
27
|
+
| **Family** | A device category + vendor line (Whatsminer, Antminer, ABB…) under `backend/workers/<category>/<family>/`. |
|