@try-works/dsh-model-as-tool 0.0.0-stage → 0.1.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/README.md +245 -2
- package/catalog/desert-ant-models.json +629 -0
- package/catalog/playbooks.json +531 -0
- package/cordis.patch.yml +39 -0
- package/lib/adapters/index.d.ts +48 -0
- package/lib/adapters/index.d.ts.map +1 -0
- package/lib/adapters/index.js +67 -0
- package/lib/adapters/tongue.d.ts +23 -0
- package/lib/adapters/tongue.d.ts.map +1 -0
- package/lib/adapters/tongue.js +85 -0
- package/lib/adapters/types.d.ts +95 -0
- package/lib/adapters/types.d.ts.map +1 -0
- package/lib/adapters/types.js +85 -0
- package/lib/adapters/voz.d.ts +22 -0
- package/lib/adapters/voz.d.ts.map +1 -0
- package/lib/adapters/voz.js +90 -0
- package/lib/capability.d.ts +58 -0
- package/lib/capability.d.ts.map +1 -0
- package/lib/capability.js +175 -0
- package/lib/catalog.d.ts +37 -0
- package/lib/catalog.d.ts.map +1 -0
- package/lib/catalog.js +217 -0
- package/lib/index.d.ts +120 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +391 -0
- package/lib/playbook.d.ts +42 -0
- package/lib/playbook.d.ts.map +1 -0
- package/lib/playbook.js +65 -0
- package/lib/registrar.d.ts +59 -0
- package/lib/registrar.d.ts.map +1 -0
- package/lib/registrar.js +136 -0
- package/lib/skills.d.ts +25 -0
- package/lib/skills.d.ts.map +1 -0
- package/lib/skills.js +102 -0
- package/lib/state.d.ts +100 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +160 -0
- package/lib/transport.d.ts +158 -0
- package/lib/transport.d.ts.map +1 -0
- package/lib/transport.js +332 -0
- package/lib/types.d.ts +111 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/package.json +83 -4
package/README.md
CHANGED
|
@@ -1,3 +1,246 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-model-as-tool
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install on-device models as DSH tools and skills, with per-platform capability
|
|
4
|
+
gating. Ships with the [Desert Ant Labs](https://desertant.com/models/) catalog.
|
|
5
|
+
|
|
6
|
+
A DSH agent gets a real tool for every model that can run in its process, a
|
|
7
|
+
skill that teaches it *when* to reach for that tool, and an honest explanation
|
|
8
|
+
for every model that cannot run — instead of a tool that fails at call time.
|
|
9
|
+
|
|
10
|
+
## What it does
|
|
11
|
+
|
|
12
|
+
The plugin composes six layers:
|
|
13
|
+
|
|
14
|
+
1. **Catalog** (`catalog/desert-ant-models.json`) — all 18 Desert Ant models,
|
|
15
|
+
their inputs, outputs, language counts and the npm package that runs them.
|
|
16
|
+
2. **Capability resolver** (`src/capability.ts`) — decides, per model, whether it
|
|
17
|
+
can actually run *in this process*, and why not when it cannot.
|
|
18
|
+
3. **Adapters** (`src/adapters/`) — lazily import a model package and invoke it.
|
|
19
|
+
4. **Transports** (`src/transport.ts`) — reach a model this machine cannot run:
|
|
20
|
+
through the Desert Ant CLI, or through a bridge on a machine that can.
|
|
21
|
+
5. **Registrar** (`src/registrar.ts`) — turns each reachable model into a
|
|
22
|
+
`defineTool` definition registered on `ctx.tools`.
|
|
23
|
+
6. **Skills** (`src/skills.ts` + `catalog/playbooks.json`) — publishes one skill
|
|
24
|
+
per registered tool describing when to use it, when not to, and how.
|
|
25
|
+
|
|
26
|
+
Nothing is imported from a model package at plugin load, so a deployment that
|
|
27
|
+
installs none of them still starts cleanly and reports exactly what is missing.
|
|
28
|
+
|
|
29
|
+
## Tools it registers
|
|
30
|
+
|
|
31
|
+
| Tool | Model | Runs on Windows x64 | Notes |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `lang_detect` | Tongue | **yes** | Pure JavaScript, 2 MB model inside the package, no network |
|
|
34
|
+
| `transcribe_audio` | Voz | **yes** | Needs `onnxruntime-node`; ~349 MB weights download on first use |
|
|
35
|
+
| `model_tools` | — | yes | Lists every catalogued model, and installs/removes tools |
|
|
36
|
+
|
|
37
|
+
The other 16 catalog models are reported by `model_tools` with the exact reason
|
|
38
|
+
they cannot run, for example:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
- [unavailable] redact (`redact_pii`): On-device redaction that strips personal
|
|
42
|
+
data as you type, in 27 languages, with restore support.
|
|
43
|
+
why not: Redact has no prebuilt native build for win32-x64; @desert-ant-labs/redact/native
|
|
44
|
+
ships one for linux-x64, linux-arm64 and darwin-arm64 only.
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Reaching the other 16 models
|
|
48
|
+
|
|
49
|
+
A model only needs a route, not a rewrite. Two routes cover the rest.
|
|
50
|
+
|
|
51
|
+
### The CLI (macOS and Linux)
|
|
52
|
+
|
|
53
|
+
Every shipping model is `desertant <verb> … --json`, so wherever the CLI is
|
|
54
|
+
installed the plugin will drive it. Nothing to configure — it is detected on
|
|
55
|
+
PATH:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
curl -fsSL https://raw.githubusercontent.com/Desert-Ant-Labs/desert-ant-cli/main/install.sh | sh
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
That immediately makes Redact, Emo, Gist, Clear, Ear, Moderator, Shapes, Align,
|
|
62
|
+
Tongue and Voz callable on that machine.
|
|
63
|
+
|
|
64
|
+
### The bridge (an Apple machine, for Apple-only models)
|
|
65
|
+
|
|
66
|
+
Title and Uhm run only on Apple silicon. Run the reference bridge there and point
|
|
67
|
+
the plugin at it:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
# on the Mac
|
|
71
|
+
node scripts/desert-ant-bridge.mjs --token "$(openssl rand -hex 16)"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
- id: model-tools
|
|
76
|
+
config:
|
|
77
|
+
remote:
|
|
78
|
+
endpoint: http://mac-studio.local:8787
|
|
79
|
+
token: <the token>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`suggest_title` then registers here with `route: remote`, and the existing
|
|
83
|
+
catalog entry, parameter schema and skill apply unchanged. The bridge is a thin
|
|
84
|
+
wrapper over the CLI; it binds to loopback and requires a token. **The plugin
|
|
85
|
+
does not host anything** — the licence forbids re-hosting the models as a
|
|
86
|
+
service, so the bridge must be your own machine.
|
|
87
|
+
|
|
88
|
+
## Installing tools at run time
|
|
89
|
+
|
|
90
|
+
`model_tools` actions: `list`, `installed`, `describe <id>`, `enable <id>`,
|
|
91
|
+
`disable <id>`, `reset [<id>]`.
|
|
92
|
+
|
|
93
|
+
**Enable and disable are remembered across restarts.** A plugin `config` states
|
|
94
|
+
the *deployment* default; `enable`/`disable` record the *user's* choice on top of
|
|
95
|
+
it:
|
|
96
|
+
|
|
97
|
+
- `disable` always wins, so a user can turn off something the config ships.
|
|
98
|
+
- `enable` adds to the config selection, so a user can turn something on without
|
|
99
|
+
editing YAML.
|
|
100
|
+
- `reset` forgets the choice and makes the configuration authoritative again.
|
|
101
|
+
|
|
102
|
+
Choices are stored as JSON at `<DSH_HOME>/model-as-tool/state.json`, written
|
|
103
|
+
through a temporary file and a rename so a crash cannot leave a truncated
|
|
104
|
+
document that reads as "everything is gone".
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{ "enabled": ["voz"], "disabled": ["tongue"] }
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The plugin writes its own state file rather than rewriting your
|
|
111
|
+
`cordis.patch.yml`: a rewrite there would fight the profile's reload and could
|
|
112
|
+
clobber comments you wrote. Point it elsewhere with `stateFile`, or set
|
|
113
|
+
`persist: false` for the earlier session-scoped behaviour.
|
|
114
|
+
|
|
115
|
+
Enabling a model that cannot run here fails with the resolver's reason and
|
|
116
|
+
nothing is written — persisting a failed enable would install it silently on the
|
|
117
|
+
next start.
|
|
118
|
+
|
|
119
|
+
## Install
|
|
120
|
+
|
|
121
|
+
The package is a DSH bundle: `package.json` declares
|
|
122
|
+
`dsh.bundle.patch: ./cordis.patch.yml`, and that patch is the single `insert`
|
|
123
|
+
row a profile mounts. Install it with `plugin_manager`'s `install_bundle`
|
|
124
|
+
action, or copy the row from [`cordis.patch.yml`](cordis.patch.yml) into the
|
|
125
|
+
profile's own patch file.
|
|
126
|
+
|
|
127
|
+
The package builds itself on install: `prepare` runs `tsc` from `src/` into
|
|
128
|
+
`lib/`, which is the entry point `main` and `exports` advertise. A registry
|
|
129
|
+
tarball ships `lib/` prebuilt by `prepack`, so a consumer needs no toolchain.
|
|
130
|
+
|
|
131
|
+
Model packages are **optional dependencies**: install only the ones you want.
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm i @desert-ant-labs/tongue # language detection, works everywhere
|
|
135
|
+
npm i @desert-ant-labs/voz onnxruntime-node # transcription on Windows/Linux/macOS
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The plugin never bundles or re-hosts model weights.
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
npm install # devDependencies: tsc, tsx, and the two model packages
|
|
144
|
+
npm run link:dsh # point @deepseek-ai/* peers at a DSH checkout
|
|
145
|
+
npm run verify # typecheck -> build -> 35 tests -> built-artifact check
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`link:dsh` exists because `@deepseek-ai/*` are **peer** dependencies — DSH
|
|
149
|
+
supplies them at runtime, so locally they must be pointed at a checkout:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
node scripts/link-dsh.mjs --checkout /path/to/deepseek-harness
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Run it again after any `npm install`: npm prunes anything in `node_modules` it
|
|
156
|
+
does not own, which includes those links.
|
|
157
|
+
|
|
158
|
+
`npm run verify` ends with `verify:built`, which loads `lib/index.js` — resolved
|
|
159
|
+
through the package's own `main`, under plain Node with no TypeScript loader —
|
|
160
|
+
and runs a real inference. That is the artifact DSH loads, so it is the only
|
|
161
|
+
build whose behaviour proves the plugin is installable; passing tests against
|
|
162
|
+
`src/` under `tsx` does not.
|
|
163
|
+
|
|
164
|
+
| Command | Purpose |
|
|
165
|
+
| --- | --- |
|
|
166
|
+
| `npm run demo` | Mount the plugin on a real context and print what it registered |
|
|
167
|
+
| `npm run gating` | Print the resolved route for every catalogued model |
|
|
168
|
+
| `npm run gen-docs` | Regenerate the data-derived docs from the catalog |
|
|
169
|
+
| `npm run bridge` | Run the reference bridge for an Apple/Linux machine |
|
|
170
|
+
|
|
171
|
+
Tests always mount through `tests/helpers.ts`, which points the durable state at
|
|
172
|
+
a throwaway directory. That is not cosmetic: the plugin writes user choices into
|
|
173
|
+
`DSH_HOME` by default, so an unisolated test would edit the developer's real
|
|
174
|
+
configuration and a later test would read those edits as a user decision.
|
|
175
|
+
|
|
176
|
+
## Configuration
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
- id: model-tools
|
|
180
|
+
name: '@try-works/dsh-model-as-tool'
|
|
181
|
+
config:
|
|
182
|
+
models: [] # empty = every runnable model; or list ids, e.g. [tongue]
|
|
183
|
+
exclude: [] # ids to drop after `models`
|
|
184
|
+
exposeUnavailable: false # true registers tools that will fail at call time
|
|
185
|
+
registerSkills: true
|
|
186
|
+
registerControlTool: true
|
|
187
|
+
persist: true # remember enable/disable across restarts
|
|
188
|
+
# stateFile: /path/to/state.json # default <DSH_HOME>/model-as-tool/state.json
|
|
189
|
+
allowNpm: true # false forces the CLI/bridge routes
|
|
190
|
+
cli:
|
|
191
|
+
enabled: true # use the Desert Ant CLI when it is on PATH
|
|
192
|
+
command: desertant
|
|
193
|
+
remote:
|
|
194
|
+
endpoint: '' # a bridge on a machine that can run what this one cannot
|
|
195
|
+
token: ''
|
|
196
|
+
# catalogFile: /path/to/other-catalog.json
|
|
197
|
+
# playbookFile: /path/to/other-playbooks.json
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Platform support
|
|
201
|
+
|
|
202
|
+
This is the part that matters most, because Desert Ant's Node prebuilds cover
|
|
203
|
+
`linux-x64`, `linux-arm64` and `darwin-arm64` — **not `win32-x64`**.
|
|
204
|
+
|
|
205
|
+
| Tier | Models | How |
|
|
206
|
+
| --- | --- | --- |
|
|
207
|
+
| Runs in plain Node everywhere | Tongue | Pure JS, no WASM, no inference runtime |
|
|
208
|
+
| Runs where ONNX Runtime runs | Voz | `onnxruntime-node` ships win32-x64 binaries |
|
|
209
|
+
| Prebuilt for linux/darwin only | Redact, Emo, Gist, Clear, Ear, Moderator, Shapes, Align | `/native` subpath |
|
|
210
|
+
| Apple only (Core ML / MLX) | Title, Uhm | Swift SDK; no JS or Kotlin SDK |
|
|
211
|
+
| Closed beta, no SDK | Schemer, Toxic, Who, Eye, Face | Weights on Hugging Face, nothing ships them |
|
|
212
|
+
|
|
213
|
+
The browser/WASM entry of the LiteRT models explicitly refuses to run in plain
|
|
214
|
+
Node ("needs a browser/Worker environment"), so it is not a fallback.
|
|
215
|
+
|
|
216
|
+
## Licensing
|
|
217
|
+
|
|
218
|
+
The Desert Ant Labs models are under the
|
|
219
|
+
[Source-Available License 1.0](https://license.desertant.com/1.0) — not an
|
|
220
|
+
open-source license. Inference is unlimited and free below 100,000 monthly active
|
|
221
|
+
devices **per platform, per model**; above that a commercial license is required.
|
|
222
|
+
Attribution ("Powered by Desert Ant Labs", linked) is required, and the models
|
|
223
|
+
may not be redistributed or re-hosted as a standalone product or service.
|
|
224
|
+
|
|
225
|
+
That is exactly why this plugin is an installer/wrapper: it loads the official
|
|
226
|
+
npm packages locally and never ships, mirrors or proxies the weights.
|
|
227
|
+
|
|
228
|
+
## Tests
|
|
229
|
+
|
|
230
|
+
```sh
|
|
231
|
+
npm run verify # from the repository root
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The suite boots the plugin on a real Cordis context with the shipping
|
|
235
|
+
`ToolRuntime`, `SystemPrompt` and `SkillRegistry`, then drives the registered
|
|
236
|
+
tools through `ctx.tools.execute` — including a real Tongue inference. The
|
|
237
|
+
transport suite injects its command runner and HTTP poster, so the CLI and bridge
|
|
238
|
+
failure paths are covered without a process or a socket.
|
|
239
|
+
|
|
240
|
+
## Design notes
|
|
241
|
+
|
|
242
|
+
- See [docs/model-as-tool-architecture.md](../../docs/model-as-tool-architecture.md)
|
|
243
|
+
for the full design.
|
|
244
|
+
- See [docs/adding-a-model.md](../../docs/adding-a-model.md) to add a model.
|
|
245
|
+
- See [docs/model-tool-playbook.md](../../docs/model-tool-playbook.md) for the
|
|
246
|
+
per-model use cases, tool shapes and skill content.
|