@synap-core/workspace-templates 0.34.0 → 0.36.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 CHANGED
@@ -325,6 +325,80 @@ meta:
325
325
  on serve); the pod keeps it in `workspaces.settings.intent`. A space with no declared intent gets one inferred at
326
326
  read time (the profiles there that declare a lifecycle and hold things), never stored.
327
327
 
328
+ ## Capabilities that run on a computer
329
+
330
+ Some capabilities run on one of the person's computers (a Mac, a Linux box), not on the pod: ffmpeg, a local
331
+ transcriber, a downloader. The person picks the computer, says yes once per tool per computer, and `synap worker`
332
+ on that computer installs, checks and removes the tool from the manifest, with no AI in the loop (decision
333
+ 168f34db). The rules live in `schema/computer.ts` (mirroring the backend leaf `@synap-core/types/capability-manifest`);
334
+ the four media capabilities in `capabilities/media-*.capability.json` are the reference.
335
+
336
+ **One model, two kinds.** What an installation is comes from the manifest, never from a field you set
337
+ (`installKind`):
338
+
339
+ | | a **tool** | a **service** |
340
+ |---|---|---|
341
+ | What the computer runs | a program installed by per-OS steps | containers |
342
+ | Declared by | `install.<os>`, `verify.<os>`, `uninstall.<os>` | `services[]`: image by digest, ports on 127.0.0.1, health, limits |
343
+ | Platforms | any of `darwin`, `linux`, `win32` | `linux` only, with `placement.requires.runtimes.docker` |
344
+ | Example | `media-ffmpeg` | (none yet) |
345
+
346
+ Both at once is refused. Every computer capability carries:
347
+ - **`placement`**: `runsOn: ["computer"]`, `platforms` (Node's `process.platform` / `process.arch`; the UI says
348
+ Mac, Linux, Windows), `labels` (`gpu?` ranks, `gpu` filters), `requires` (other catalog capabilities, runtimes
349
+ such as `uv` or `python`), and an optional pod `fallback` with its price, only ever offered per tool, never used
350
+ silently (decision 6).
351
+ - **`licence`**, an SPDX expression shown on the install card. A GPL tool is installed from its source, never
352
+ bundled with Synap (`bundled: true` with a GPL licence is refused, decision 4). An OS whose tool has another
353
+ licence says so in `install.<os>.licence` (Robust Video Matting is GPL-3.0 on Linux).
354
+ - **`permissions`**: the folders, hosts and devices the tool touches.
355
+
356
+ **A tool's steps are data.** Each step is a package manager (`brew`, `apt`, `dnf`, `winget`, `uv`, `pip`, `npm`),
357
+ a `download`, or a `script`. Commands are argv arrays, never shell lines, and paths use the placeholders the
358
+ computer fills: `{home}`, `{brewPrefix}`, `{tools}`, `{models}`, `{workdir}`, `{fixture}`.
359
+ - A download by url is pinned by its `sha256` (a model by `id` comes from its hub). Pin a dated build, never a
360
+ `latest` link: `media-ffmpeg` pins BtbN's month-end build.
361
+ - A script is pinned by its `sha256`, declares `elevation: "never"` (no sudo, no admin prompt in v1) and is
362
+ shown to the person before it runs. `synap catalog validate` hashes every inlined script (`script-sha256`).
363
+ - `install.<os>.bins` pins each program to a path, so PATH order never decides which ffmpeg runs.
364
+ - `verify.<os>` is an argv, what it must print, the regex group that is the version (`captureVersion`) and an
365
+ optional `smoke` run that proves the tool works; `reverifyEvery` (default `P7D`) says when to check again.
366
+ - **Windows** steps may ship, but the picker hides Windows until they have been tried on a real machine
367
+ (decision 5): validate flags each one (`computer-untested-os`, a warning).
368
+
369
+ **Recipes are stored config.** `media-ffmpeg` does every effect through one verb with a recipe library in
370
+ `spec.recipes` (reframe, loudness, silence cut, word captions, grade, crossfade, overlay, background replace,
371
+ slideshow, GIF/WebP, keyframes, platform exports). A recipe is:
372
+
373
+ ```jsonc
374
+ {
375
+ "name": "loudness-normalize", // kebab-case, unique in the capability
376
+ "description": "Two-pass loudness normalisation to -14 LUFS.",
377
+ "params": { // typed; each required or with a default
378
+ "in": { "type": "file", "description": "The video to work on.", "required": true },
379
+ "out": { "type": "output", "description": "Where the result is written.", "required": true },
380
+ "target": { "type": "number", "description": "Integrated loudness in LUFS.", "default": -14 }
381
+ },
382
+ "steps": [ // argv templates; program = a pinned bin, or python
383
+ { "program": "python", "args": ["{script:loudnorm2pass.py}", "{bin:ffmpeg}", "{in}", "{out}", "{target}"] }
384
+ ],
385
+ "scripts": [{ "name": "loudnorm2pass.py", "sha256": "<64 hex>", "source": "#!/usr/bin/env python3\n…" }],
386
+ "needs": { "filters": ["loudnorm"] }, // what the computer's ffmpeg must have
387
+ "gotchas": ["Normalise after the mix, as the last audio step."]
388
+ }
389
+ ```
390
+
391
+ - Placeholders in `args`: a declared param, `{workdir}`, `{script:<file>}` (a script the recipe ships) and
392
+ `{bin:<program>}` (a program pinned in `install.<os>.bins` on every OS the capability lists).
393
+ - A value spliced into a larger argument (a filter graph) may not carry the graph's syntax; a list of files
394
+ is only ever a whole argument. `renderRecipe` (`schema/recipe.ts`) is the ONE way a recipe becomes argv, for
395
+ the runner and the tests alike.
396
+ - **Your own recipes** take the same shape. Where they are stored on the pod (and that the verb looks for yours
397
+ by name first) is plan b647769e wave 5: not built yet.
398
+ - Tests: `schema/recipe.test.ts` renders every recipe of every capability with sample params (a new recipe
399
+ joins by existing); `scripts/catalog-lib.computer.test.ts` proves each manifest rule. Neither runs ffmpeg:
400
+ a recipe is tried on a Mac and on the devbox before it is listed.
401
+
328
402
  ## 4. The ONE command set
329
403
 
330
404
  **Landing on app-bases `main` IS publishing.** Every push to `main` runs CI (below),
@@ -0,0 +1,237 @@
1
+ {
2
+ "apiVersion": "synap/v1",
3
+ "kind": "capability",
4
+ "meta": {
5
+ "slug": "media-download",
6
+ "name": "Download videos on your computer",
7
+ "description": "Downloads a video or its audio from YouTube and over a thousand other sites onto your computer, with its subtitles, metadata and thumbnail. Only for content you own, are licensed to use, or use under fair use: downloading can breach a site's terms and the creator's copyright.",
8
+ "tags": [
9
+ "capability",
10
+ "media",
11
+ "video",
12
+ "computer"
13
+ ],
14
+ "isPublic": true
15
+ },
16
+ "spec": {
17
+ "key": "media-download",
18
+ "name": "Download videos on your computer",
19
+ "description": "yt-dlp (public domain, Unlicense) installed with uv as yt-dlp[default], which bundles yt-dlp-ejs for YouTube's JavaScript challenges; the challenges run on Node 22+, which the synap CLI already needs (--js-runtimes node). Needs media-ffmpeg to merge video and audio and extract audio. TERMS: downloading may breach a platform's terms of service and the creator's copyright; use it only for content you own, are licensed to use, or use under fair-use review, never as a re-upload pipeline.",
20
+ "licence": "Unlicense",
21
+ "placement": {
22
+ "runsOn": [
23
+ "computer"
24
+ ],
25
+ "prefer": [
26
+ "computer"
27
+ ],
28
+ "platforms": [
29
+ {
30
+ "os": "darwin",
31
+ "arch": [
32
+ "arm64",
33
+ "x64"
34
+ ]
35
+ },
36
+ {
37
+ "os": "linux",
38
+ "arch": [
39
+ "x64",
40
+ "arm64"
41
+ ]
42
+ },
43
+ {
44
+ "os": "win32",
45
+ "arch": [
46
+ "x64"
47
+ ]
48
+ }
49
+ ],
50
+ "requires": {
51
+ "capabilities": [
52
+ {
53
+ "slug": "media-ffmpeg"
54
+ }
55
+ ],
56
+ "runtimes": {
57
+ "uv": ">=0.5",
58
+ "node": ">=22"
59
+ }
60
+ }
61
+ },
62
+ "install": {
63
+ "darwin": {
64
+ "steps": [
65
+ {
66
+ "kind": "uv",
67
+ "action": "tool-install",
68
+ "package": "yt-dlp[default]"
69
+ }
70
+ ],
71
+ "bins": {
72
+ "yt-dlp": "{home}/.local/bin/yt-dlp"
73
+ }
74
+ },
75
+ "linux": {
76
+ "steps": [
77
+ {
78
+ "kind": "uv",
79
+ "action": "tool-install",
80
+ "package": "yt-dlp[default]"
81
+ }
82
+ ],
83
+ "bins": {
84
+ "yt-dlp": "{home}/.local/bin/yt-dlp"
85
+ }
86
+ },
87
+ "win32": {
88
+ "steps": [
89
+ {
90
+ "kind": "uv",
91
+ "action": "tool-install",
92
+ "package": "yt-dlp[default]"
93
+ }
94
+ ],
95
+ "bins": {
96
+ "yt-dlp": "{home}/.local/bin/yt-dlp.exe"
97
+ }
98
+ },
99
+ "elevation": "never",
100
+ "diskFreeMb": 200
101
+ },
102
+ "verify": {
103
+ "darwin": {
104
+ "command": [
105
+ "yt-dlp",
106
+ "--version"
107
+ ],
108
+ "expect": {
109
+ "exitCode": 0,
110
+ "stdoutMatches": "^(\\d{4}\\.\\d{2}\\.\\d{2}(?:\\.\\d+)?)"
111
+ },
112
+ "captureVersion": 1,
113
+ "smoke": {
114
+ "command": [
115
+ "yt-dlp",
116
+ "--js-runtimes",
117
+ "node",
118
+ "--simulate",
119
+ "--print",
120
+ "id",
121
+ "https://www.youtube.com/watch?v=jNQXAC9IVRw"
122
+ ],
123
+ "expect": {
124
+ "exitCode": 0,
125
+ "stdoutContains": "jNQXAC9IVRw"
126
+ }
127
+ }
128
+ },
129
+ "linux": {
130
+ "command": [
131
+ "yt-dlp",
132
+ "--version"
133
+ ],
134
+ "expect": {
135
+ "exitCode": 0,
136
+ "stdoutMatches": "^(\\d{4}\\.\\d{2}\\.\\d{2}(?:\\.\\d+)?)"
137
+ },
138
+ "captureVersion": 1,
139
+ "smoke": {
140
+ "command": [
141
+ "yt-dlp",
142
+ "--js-runtimes",
143
+ "node",
144
+ "--simulate",
145
+ "--print",
146
+ "id",
147
+ "https://www.youtube.com/watch?v=jNQXAC9IVRw"
148
+ ],
149
+ "expect": {
150
+ "exitCode": 0,
151
+ "stdoutContains": "jNQXAC9IVRw"
152
+ }
153
+ }
154
+ },
155
+ "win32": {
156
+ "command": [
157
+ "yt-dlp",
158
+ "--version"
159
+ ],
160
+ "expect": {
161
+ "exitCode": 0,
162
+ "stdoutMatches": "^(\\d{4}\\.\\d{2}\\.\\d{2}(?:\\.\\d+)?)"
163
+ },
164
+ "captureVersion": 1,
165
+ "smoke": {
166
+ "command": [
167
+ "yt-dlp",
168
+ "--js-runtimes",
169
+ "node",
170
+ "--simulate",
171
+ "--print",
172
+ "id",
173
+ "https://www.youtube.com/watch?v=jNQXAC9IVRw"
174
+ ],
175
+ "expect": {
176
+ "exitCode": 0,
177
+ "stdoutContains": "jNQXAC9IVRw"
178
+ }
179
+ }
180
+ },
181
+ "timeoutSec": 60,
182
+ "reverifyEvery": "P7D"
183
+ },
184
+ "uninstall": {
185
+ "darwin": {
186
+ "steps": [
187
+ {
188
+ "kind": "uv",
189
+ "action": "tool-uninstall",
190
+ "package": "yt-dlp"
191
+ }
192
+ ]
193
+ },
194
+ "linux": {
195
+ "steps": [
196
+ {
197
+ "kind": "uv",
198
+ "action": "tool-uninstall",
199
+ "package": "yt-dlp"
200
+ }
201
+ ]
202
+ },
203
+ "win32": {
204
+ "steps": [
205
+ {
206
+ "kind": "uv",
207
+ "action": "tool-uninstall",
208
+ "package": "yt-dlp"
209
+ }
210
+ ]
211
+ },
212
+ "keepUserData": true
213
+ },
214
+ "permissions": {
215
+ "filesystem": [
216
+ {
217
+ "path": "{workdir}",
218
+ "access": "rw"
219
+ }
220
+ ],
221
+ "network": [
222
+ "*"
223
+ ],
224
+ "devices": []
225
+ },
226
+ "skills": [
227
+ {
228
+ "name": "download-media",
229
+ "kind": "instruction",
230
+ "scope": "pod",
231
+ "description": "How to download a video or its audio with yt-dlp on the computer that has it, and the terms rule that comes first.",
232
+ "code": "# Download a video or its audio on this computer\n\n**First, the rule.** Downloading can breach a platform's terms of service and the creator's copyright. Download only what the person owns, is licensed to use, or uses under a fair-use review they have done. Never use it to re-upload someone else's video. When it is not clear, ask.\n\n1. Check the tool is here: `synap tools verify media-download`. Not installed: ask the person first.\n2. YouTube needs a JavaScript runtime to solve its challenges: always pass `--js-runtimes node` (Node 22 or later is on every computer that runs the synap CLI).\n3. Ask yt-dlp to print where the file landed: `--print after_move:filepath`.\n\n```\n# the best MP4 (H.264 + AAC), the easiest file to edit\nyt-dlp --js-runtimes node -t mp4 -P OUT_DIR -o \"%(upload_date>%Y-%m-%d)s %(title).80B [%(id)s].%(ext)s\" --print after_move:filepath URL\n# audio only, ready to transcribe (16 kHz mono WAV)\nyt-dlp --js-runtimes node -x --audio-format wav --postprocessor-args \"ExtractAudio:-ar 16000 -ac 1\" -P OUT_DIR URL\n# one section, with subtitles, metadata and the thumbnail\nyt-dlp --js-runtimes node -t mp4 --download-sections \"*00:01:10-00:02:05\" --write-subs --write-auto-subs --sub-langs \"en.*,fr.*\" --write-info-json --write-thumbnail -P OUT_DIR URL\n```\n\nStore the source URL with the file, so where it came from is never lost.\n\n**Gotchas**\n- yt-dlp merges video and audio with ffmpeg: media-ffmpeg must be installed on the same computer; pass `--ffmpeg-location` with its pinned path.\n- Logged-in content (`--cookies-from-browser firefox`) reads the person's browser cookies: only with their explicit yes, and with a dedicated account (a logged-in account can be rate-limited or banned). Chrome cookies often fail on Windows; prefer Firefox.\n- `.80B` in the name template cuts the title at 80 bytes, safe on every filesystem.\n"
233
+ }
234
+ ],
235
+ "provides": []
236
+ }
237
+ }