@skillcdn/console 0.5.0 → 0.5.2
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 +87 -12
- package/SKILLCDN.md +3 -3
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +7 -6
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +9 -7
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +8 -6
- package/dist/api.js.map +1 -1
- package/dist/charts.d.ts +103 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +182 -0
- package/dist/charts.js.map +1 -0
- package/dist/cli/cli.d.ts +58 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1742 -472
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command-words.d.ts +20 -0
- package/dist/cli/command-words.d.ts.map +1 -0
- package/dist/cli/command-words.js +51 -0
- package/dist/cli/command-words.js.map +1 -0
- package/dist/cli/credentials.d.ts +54 -5
- package/dist/cli/credentials.d.ts.map +1 -1
- package/dist/cli/credentials.js +126 -20
- package/dist/cli/credentials.js.map +1 -1
- package/dist/cli/directory.d.ts +19 -4
- package/dist/cli/directory.d.ts.map +1 -1
- package/dist/cli/directory.js +16 -8
- package/dist/cli/directory.js.map +1 -1
- package/dist/cli/format.d.ts +70 -9
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +267 -40
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +13 -4
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +101 -58
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/machine-check.d.ts +36 -0
- package/dist/cli/machine-check.d.ts.map +1 -0
- package/dist/cli/machine-check.js +151 -0
- package/dist/cli/machine-check.js.map +1 -0
- package/dist/cli/main.js +76 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/pack.d.ts +69 -60
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +241 -270
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-check.d.ts +42 -0
- package/dist/cli/plugin-check.d.ts.map +1 -1
- package/dist/cli/plugin-check.js +221 -36
- package/dist/cli/plugin-check.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts +6 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +21 -4
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/plugin-main.js +1 -0
- package/dist/cli/plugin-main.js.map +1 -1
- package/dist/cli/runner-host.d.ts +7 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +2 -0
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/cli/secret-notes.d.ts +8 -0
- package/dist/cli/secret-notes.d.ts.map +1 -0
- package/dist/cli/secret-notes.js +48 -0
- package/dist/cli/secret-notes.js.map +1 -0
- package/dist/cli/serve.d.ts +33 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +252 -3
- package/dist/cli/serve.js.map +1 -1
- package/dist/client.d.ts +54 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +77 -80
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +164 -8
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +588 -151
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +1 -1
- package/dist/components/agents.js.map +1 -1
- package/dist/components/board.d.ts.map +1 -1
- package/dist/components/board.js +3 -2
- package/dist/components/board.js.map +1 -1
- package/dist/components/categories.js +1 -1
- package/dist/components/categories.js.map +1 -1
- package/dist/components/charts.d.ts +157 -0
- package/dist/components/charts.d.ts.map +1 -0
- package/dist/components/charts.js +182 -0
- package/dist/components/charts.js.map +1 -0
- package/dist/components/decision-list.d.ts.map +1 -1
- package/dist/components/decision-list.js +1 -1
- package/dist/components/decision-list.js.map +1 -1
- package/dist/components/desk-records.d.ts +102 -0
- package/dist/components/desk-records.d.ts.map +1 -0
- package/dist/components/desk-records.js +221 -0
- package/dist/components/desk-records.js.map +1 -0
- package/dist/components/desk.d.ts +85 -0
- package/dist/components/desk.d.ts.map +1 -0
- package/dist/components/desk.js +135 -0
- package/dist/components/desk.js.map +1 -0
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +7 -3
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/goals.d.ts +2 -0
- package/dist/components/goals.d.ts.map +1 -1
- package/dist/components/goals.js +1 -1
- package/dist/components/goals.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +14 -6
- package/dist/components/home.js.map +1 -1
- package/dist/components/icon.d.ts +31 -0
- package/dist/components/icon.d.ts.map +1 -0
- package/dist/components/icon.js +169 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/markdown.d.ts +6 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +10 -2
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/people.js +1 -1
- package/dist/components/people.js.map +1 -1
- package/dist/components/plugin-frame.d.ts.map +1 -1
- package/dist/components/plugin-frame.js +7 -0
- package/dist/components/plugin-frame.js.map +1 -1
- package/dist/components/plugin-settings.d.ts.map +1 -1
- package/dist/components/plugin-settings.js +54 -3
- package/dist/components/plugin-settings.js.map +1 -1
- package/dist/components/projects.d.ts +17 -4
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +51 -12
- package/dist/components/projects.js.map +1 -1
- package/dist/components/rules.d.ts +8 -10
- package/dist/components/rules.d.ts.map +1 -1
- package/dist/components/rules.js +35 -13
- package/dist/components/rules.js.map +1 -1
- package/dist/components/sessions.d.ts.map +1 -1
- package/dist/components/sessions.js +3 -2
- package/dist/components/sessions.js.map +1 -1
- package/dist/components/setup.d.ts +9 -3
- package/dist/components/setup.d.ts.map +1 -1
- package/dist/components/setup.js +12 -6
- package/dist/components/setup.js.map +1 -1
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +3 -2
- package/dist/components/shell.js.map +1 -1
- package/dist/components/tokens.js +1 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/ui.d.ts +5 -2
- package/dist/components/ui.d.ts.map +1 -1
- package/dist/components/ui.js +10 -7
- package/dist/components/ui.js.map +1 -1
- package/dist/connect-page.js +1 -1
- package/dist/connect-page.js.map +1 -1
- package/dist/console.css +1172 -106
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +52 -39
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +32 -33
- package/dist/data.js.map +1 -1
- package/dist/desk-page.d.ts +38 -0
- package/dist/desk-page.d.ts.map +1 -0
- package/dist/desk-page.js +184 -0
- package/dist/desk-page.js.map +1 -0
- package/dist/desk-records-page.d.ts +18 -0
- package/dist/desk-records-page.d.ts.map +1 -0
- package/dist/desk-records-page.js +130 -0
- package/dist/desk-records-page.js.map +1 -0
- package/dist/desk-records.d.ts +247 -0
- package/dist/desk-records.d.ts.map +1 -0
- package/dist/desk-records.js +543 -0
- package/dist/desk-records.js.map +1 -0
- package/dist/desk.d.ts +122 -0
- package/dist/desk.d.ts.map +1 -0
- package/dist/desk.js +211 -0
- package/dist/desk.js.map +1 -0
- package/dist/feed-stream.d.ts +39 -0
- package/dist/feed-stream.d.ts.map +1 -0
- package/dist/feed-stream.js +117 -0
- package/dist/feed-stream.js.map +1 -0
- package/dist/home-tiles.d.ts +19 -3
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +147 -42
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +228 -6
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +309 -9
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +366 -85
- package/dist/i18n/ko.js.map +1 -1
- package/dist/i18n/particles.d.ts +7 -0
- package/dist/i18n/particles.d.ts.map +1 -0
- package/dist/i18n/particles.js +72 -0
- package/dist/i18n/particles.js.map +1 -0
- package/dist/icons/glyphs.d.ts +605 -0
- package/dist/icons/glyphs.d.ts.map +1 -0
- package/dist/icons/glyphs.js +104 -0
- package/dist/icons/glyphs.js.map +1 -0
- package/dist/icons/index.d.ts +59 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +157 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +20 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +20 -0
- package/dist/limits.js.map +1 -1
- package/dist/marks.d.ts +9 -0
- package/dist/marks.d.ts.map +1 -1
- package/dist/marks.js +9 -0
- package/dist/marks.js.map +1 -1
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +5 -5
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/context.d.ts +42 -11
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +2 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +2 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/manifest.d.ts +13 -0
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +30 -3
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +55 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +37 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/plugin/sandbox.d.ts.map +1 -1
- package/dist/plugin/sandbox.js +4 -1
- package/dist/plugin/sandbox.js.map +1 -1
- package/dist/plugin/testing.d.ts +6 -2
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +52 -10
- package/dist/plugin/testing.js.map +1 -1
- package/dist/plugin/web.d.ts +3 -0
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +5 -1
- package/dist/plugin/web.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/records.d.ts +283 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +543 -0
- package/dist/records.js.map +1 -0
- package/dist/routes.d.ts +3 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +3 -1
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +30 -11
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +98 -45
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +32 -21
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/awake.d.ts +35 -0
- package/dist/runner/awake.d.ts.map +1 -0
- package/dist/runner/awake.js +95 -0
- package/dist/runner/awake.js.map +1 -0
- package/dist/runner/claude.d.ts +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +100 -18
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +20 -17
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +5 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +9 -0
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts +43 -2
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +168 -13
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/process.d.ts.map +1 -1
- package/dist/runner/process.js +11 -4
- package/dist/runner/process.js.map +1 -1
- package/dist/runner/redact.d.ts +39 -4
- package/dist/runner/redact.d.ts.map +1 -1
- package/dist/runner/redact.js +81 -5
- package/dist/runner/redact.js.map +1 -1
- package/dist/runner/runner.d.ts +28 -3
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +371 -54
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +10 -4
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/task-scheduler.d.ts +20 -0
- package/dist/runner/task-scheduler.d.ts.map +1 -1
- package/dist/runner/task-scheduler.js +34 -4
- package/dist/runner/task-scheduler.js.map +1 -1
- package/dist/runner/types.d.ts +51 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +26 -0
- package/dist/runner/types.js.map +1 -1
- package/dist/runner.d.ts +6 -6
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +5 -5
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +603 -6
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +156 -20
- package/dist/schemas.js.map +1 -1
- package/dist/services.d.ts +22 -5
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +41 -17
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +17 -4
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +48 -41
- package/dist/setup-guide.js.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +5 -1
- package/dist/tokens.js.map +1 -1
- package/dist/vocabulary.d.ts +21 -3
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +19 -3
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +73 -44
- package/docs/specs/plugins.md +40 -22
- package/docs/specs/records.md +113 -0
- package/docs/specs/rest.md +30 -21
- package/docs/specs/runner.md +46 -22
- package/package.json +11 -2
- package/skills/building-a-console/SKILL.md +4 -4
- package/skills/building-a-plugin/SKILL.md +6 -6
- package/skills/deploying-a-console/SKILL.md +4 -4
- package/skills/deploying-a-console/references/resources.md +41 -4
- package/skills/deploying-a-console/references/running-it-again.md +3 -2
- package/skills/keeping-a-desk/SKILL.md +133 -0
- package/skills/keeping-a-desk/collections.md +96 -0
- package/skills/planning-the-board/SKILL.md +14 -18
- package/skills/planning-the-board/references/a-task.md +2 -2
- package/skills/planning-the-board/references/project-rules.md +13 -14
- package/skills/planning-the-board/references/setting-up.md +15 -13
- package/skills/running-an-agent/SKILL.md +47 -56
- package/skills/working-the-board/SKILL.md +63 -44
- package/skills/working-the-board/references/terms.md +9 -5
- package/skills/working-the-board/references/the-pack.md +12 -10
- package/skills/working-the-board/references/the-sentence.md +2 -2
- package/src/agent-page.tsx +16 -2
- package/src/api.ts +109 -3
- package/src/charts.ts +250 -0
- package/src/cli/cli.ts +2226 -580
- package/src/cli/command-words.ts +56 -0
- package/src/cli/credentials.ts +181 -20
- package/src/cli/directory.ts +28 -10
- package/src/cli/format.ts +332 -49
- package/src/cli/help.ts +113 -57
- package/src/cli/machine-check.ts +223 -0
- package/src/cli/main.ts +72 -2
- package/src/cli/pack.ts +333 -372
- package/src/cli/plugin-check.ts +275 -34
- package/src/cli/plugin-cli.ts +28 -4
- package/src/cli/plugin-main.ts +1 -0
- package/src/cli/runner-host.ts +8 -0
- package/src/cli/secret-notes.ts +63 -0
- package/src/cli/serve.ts +295 -2
- package/src/client.ts +215 -177
- package/src/components/agent-page.tsx +1044 -281
- package/src/components/agents.tsx +9 -5
- package/src/components/board.tsx +3 -15
- package/src/components/categories.tsx +2 -2
- package/src/components/charts.tsx +680 -0
- package/src/components/decision-list.tsx +11 -7
- package/src/components/desk-records.tsx +724 -0
- package/src/components/desk.tsx +471 -0
- package/src/components/event-feed.tsx +12 -3
- package/src/components/goals.tsx +33 -25
- package/src/components/home.tsx +42 -6
- package/src/components/icon.tsx +337 -0
- package/src/components/markdown.tsx +22 -2
- package/src/components/people.tsx +1 -1
- package/src/components/plugin-frame.tsx +7 -0
- package/src/components/plugin-settings.tsx +171 -12
- package/src/components/projects.tsx +68 -17
- package/src/components/rules.tsx +94 -34
- package/src/components/sessions.tsx +2 -13
- package/src/components/setup.tsx +20 -5
- package/src/components/shell.tsx +3 -20
- package/src/components/tokens.tsx +1 -1
- package/src/components/ui.tsx +16 -8
- package/src/connect-page.tsx +1 -1
- package/src/console.tsx +104 -62
- package/src/data.ts +37 -34
- package/src/desk-page.tsx +332 -0
- package/src/desk-records-page.tsx +256 -0
- package/src/desk-records.ts +808 -0
- package/src/desk.ts +329 -0
- package/src/feed-stream.ts +144 -0
- package/src/home-tiles.ts +170 -46
- package/src/i18n/en.ts +323 -11
- package/src/i18n/ko.ts +378 -87
- package/src/i18n/particles.ts +79 -0
- package/src/icons/glyphs.ts +112 -0
- package/src/icons/index.ts +195 -0
- package/src/index.ts +125 -0
- package/src/limits.ts +20 -0
- package/src/marks.ts +12 -0
- package/src/onboarding.ts +14 -6
- package/src/plugin/context.ts +55 -12
- package/src/plugin/limits.ts +2 -0
- package/src/plugin/manifest.ts +38 -2
- package/src/plugin/rest-schemas.ts +41 -0
- package/src/plugin/sandbox.ts +4 -1
- package/src/plugin/testing.ts +63 -12
- package/src/plugin/web.ts +9 -2
- package/src/plugin.ts +2 -0
- package/src/records.ts +702 -0
- package/src/routes.ts +3 -1
- package/src/rules.ts +108 -47
- package/src/runner/acp.ts +49 -30
- package/src/runner/awake.ts +135 -0
- package/src/runner/claude.ts +131 -26
- package/src/runner/codex.ts +37 -26
- package/src/runner/config.ts +9 -0
- package/src/runner/desk.ts +200 -15
- package/src/runner/process.ts +11 -4
- package/src/runner/redact.ts +92 -6
- package/src/runner/runner.ts +457 -56
- package/src/runner/slack.ts +10 -4
- package/src/runner/task-scheduler.ts +36 -4
- package/src/runner/types.ts +67 -1
- package/src/runner.ts +27 -2
- package/src/schemas.ts +177 -18
- package/src/services.ts +55 -16
- package/src/setup-guide.ts +49 -40
- package/src/styles/README.md +16 -5
- package/src/styles/base.css +17 -0
- package/src/styles/console.css +10 -0
- package/src/styles/drawn-by-pages.json +1 -1
- package/src/styles/pages/agents.css +103 -1
- package/src/styles/pages/board.css +0 -10
- package/src/styles/pages/calendar.css +1 -1
- package/src/styles/pages/connect.css +0 -10
- package/src/styles/pages/decisions.css +3 -1
- package/src/styles/pages/desk.css +126 -0
- package/src/styles/pages/documents.css +5 -0
- package/src/styles/pages/feed.css +5 -2
- package/src/styles/pages/home.css +5 -0
- package/src/styles/pages/roadmap.css +2 -2
- package/src/styles/pages/settings.css +11 -0
- package/src/styles/pages/task.css +0 -20
- package/src/styles/pages/thread.css +1 -1
- package/src/styles/parts/bars.css +80 -0
- package/src/styles/parts/calendar.css +1 -1
- package/src/styles/parts/callout.css +1 -0
- package/src/styles/parts/chart.css +173 -0
- package/src/styles/parts/detail.css +22 -0
- package/src/styles/parts/empty.css +2 -0
- package/src/styles/parts/eyebrow.css +1 -1
- package/src/styles/parts/facts.css +1 -1
- package/src/styles/parts/figures.css +65 -0
- package/src/styles/parts/form.css +2 -1
- package/src/styles/parts/icon.css +191 -0
- package/src/styles/parts/input.css +14 -4
- package/src/styles/parts/legend.css +48 -0
- package/src/styles/parts/mark.css +36 -0
- package/src/styles/parts/menu.css +1 -7
- package/src/styles/parts/page.css +1 -1
- package/src/styles/parts/panel.css +10 -0
- package/src/styles/parts/person.css +5 -2
- package/src/styles/parts/progress.css +5 -2
- package/src/styles/parts/rows.css +1 -0
- package/src/styles/parts/series.css +32 -0
- package/src/styles/parts/settings.css +5 -0
- package/src/styles/parts/share.css +25 -0
- package/src/styles/parts/spark.css +23 -0
- package/src/styles/parts/stat.css +69 -0
- package/src/styles/tokens.css +31 -10
- package/src/tokens.ts +5 -1
- package/src/vocabulary.ts +25 -3
- package/template/desk-web/README.md +8 -0
- package/template/desk-web/index.html +13 -0
- package/template/desk-web/package.json +25 -0
- package/template/desk-web/src/main.tsx +24 -0
- package/template/desk-web/src/page.tsx +51 -0
- package/template/desk-web/tsconfig.json +16 -0
- package/template/desk-web/vite.config.ts +15 -0
package/src/cli/serve.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import { createReadStream } from "node:fs";
|
|
2
|
+
import { readFile, realpath, stat } from "node:fs/promises";
|
|
1
3
|
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
|
|
4
|
+
import { basename, extname, join, sep } from "node:path";
|
|
2
5
|
import { Readable } from "node:stream";
|
|
3
6
|
import { pipeline } from "node:stream/promises";
|
|
4
7
|
import type { ReadableStream as NodeReadableStream } from "node:stream/web";
|
|
5
8
|
import type { FetchLike } from "../client.js";
|
|
9
|
+
import { isLfsPointer, MAX_LFS_POINTER_BYTES } from "../records.js";
|
|
6
10
|
import type { WebRoot } from "../web.js";
|
|
7
11
|
|
|
8
12
|
// A console of a person's own, served from their machine (ADR-0014): the files of a build, and
|
|
9
13
|
// everything under /api/ carried to the organization's console with the token the command
|
|
10
14
|
// keeps. The page and the API share one origin on the loopback, so the page needs no token and
|
|
11
15
|
// the organization's console no allowance: it sees a token's requests, as it sees the command's.
|
|
16
|
+
// Beside them, where the command is told of one, the records of a desk under /records/
|
|
17
|
+
// (ADR-0117): the files a desk keeps of what its member made, for the desk's pages to show.
|
|
12
18
|
|
|
13
19
|
/** Where the command listens when nothing is said: next to the api role's 11199 and the dev UI's 11198. */
|
|
14
20
|
export const DEFAULT_SERVE_PORT = 11197;
|
|
@@ -26,6 +32,8 @@ export interface ServeOptions {
|
|
|
26
32
|
readonly port: number;
|
|
27
33
|
/** The build to serve, or none: then only the API is here, for a development server to send it to. */
|
|
28
34
|
readonly web?: WebRoot | undefined;
|
|
35
|
+
/** The records of a desk to serve under `/records/`, or none: then nothing is there. */
|
|
36
|
+
readonly records?: RecordsRoot | undefined;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
export type ServeHandler = (request: Request) => Promise<Response>;
|
|
@@ -110,11 +118,28 @@ function fromOwnPage(request: Request, origin: string): boolean {
|
|
|
110
118
|
return from === null || from === origin;
|
|
111
119
|
}
|
|
112
120
|
|
|
121
|
+
/**
|
|
122
|
+
* The files a plugin's frame is made of (docs/specs/plugins.md, "The frame"): a file of a
|
|
123
|
+
* plugin's bundle at its version, and the console's stylesheet and faces for frames. The
|
|
124
|
+
* console answers them to anyone, with no session, and marks them for any origin to read: a
|
|
125
|
+
* frame is sandboxed, its origin opaque, so that what it asks of the address its document was
|
|
126
|
+
* read from reaches the browser as another site's request. The path as the browser's address
|
|
127
|
+
* holds it, dot segments resolved: a plugin's key, `web`, a version, and a file under it.
|
|
128
|
+
*/
|
|
129
|
+
const FRAME_FILE =
|
|
130
|
+
/^\/api\/v1\/(?:plugin-runtime\/[^/]|plugins\/[a-z][a-z0-9-]{1,31}\/web\/[^/]+\/[^/])/;
|
|
131
|
+
|
|
132
|
+
/** Whether a request reads a file of a plugin's frame: a `GET` of such a path, and nothing else. */
|
|
133
|
+
const readsFrameFile = (request: Request, url: URL): boolean =>
|
|
134
|
+
request.method === "GET" && FRAME_FILE.test(url.pathname);
|
|
135
|
+
|
|
113
136
|
async function forward(
|
|
114
137
|
request: Request,
|
|
115
138
|
url: URL,
|
|
116
139
|
upstream: string,
|
|
117
140
|
options: ServeOptions,
|
|
141
|
+
/** Whether the request is carried with the person's token: not what the console answers to anyone. */
|
|
142
|
+
asPerson = true,
|
|
118
143
|
): Promise<Response> {
|
|
119
144
|
const headers = new Headers();
|
|
120
145
|
request.headers.forEach((value, name) => {
|
|
@@ -122,7 +147,9 @@ async function forward(
|
|
|
122
147
|
headers.set(name, value);
|
|
123
148
|
}
|
|
124
149
|
});
|
|
125
|
-
|
|
150
|
+
if (asPerson) {
|
|
151
|
+
headers.set("authorization", `Bearer ${options.token}`);
|
|
152
|
+
}
|
|
126
153
|
headers.set("accept-encoding", "identity");
|
|
127
154
|
const referrer = loopbackReferrer(request);
|
|
128
155
|
if (referrer !== undefined) {
|
|
@@ -152,9 +179,251 @@ async function forward(
|
|
|
152
179
|
return new Response(answer.body, { status: answer.status, headers: out });
|
|
153
180
|
}
|
|
154
181
|
|
|
182
|
+
/** What a desk's records are served under, beside the build and the API (ADR-0117). */
|
|
183
|
+
export const RECORDS_PREFIX = "/records";
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* What a page shows in place, by its extension: the records' own JSON, a picture, a video, a
|
|
187
|
+
* sound and a PDF, each under its own content type. An SVG is not among them: a picture that
|
|
188
|
+
* may carry a script is answered as a picture and as a download at once, under a policy that
|
|
189
|
+
* runs nothing, so that a page shows it and nothing opens it as a document of the pages'
|
|
190
|
+
* origin. Anything else is handed over as a download.
|
|
191
|
+
*/
|
|
192
|
+
const SHOWN_IN_PLACE: Readonly<Record<string, string>> = {
|
|
193
|
+
".json": "application/json; charset=utf-8",
|
|
194
|
+
".png": "image/png",
|
|
195
|
+
".jpg": "image/jpeg",
|
|
196
|
+
".jpeg": "image/jpeg",
|
|
197
|
+
".webp": "image/webp",
|
|
198
|
+
".gif": "image/gif",
|
|
199
|
+
".avif": "image/avif",
|
|
200
|
+
".mp4": "video/mp4",
|
|
201
|
+
".m4v": "video/mp4",
|
|
202
|
+
".webm": "video/webm",
|
|
203
|
+
".mov": "video/quicktime",
|
|
204
|
+
".ogv": "video/ogg",
|
|
205
|
+
".mp3": "audio/mpeg",
|
|
206
|
+
".m4a": "audio/mp4",
|
|
207
|
+
".aac": "audio/aac",
|
|
208
|
+
".wav": "audio/wav",
|
|
209
|
+
".ogg": "audio/ogg",
|
|
210
|
+
".oga": "audio/ogg",
|
|
211
|
+
".flac": "audio/flac",
|
|
212
|
+
".pdf": "application/pdf",
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export class RecordsRootError extends Error {
|
|
216
|
+
constructor(message: string, options?: { readonly cause?: unknown }) {
|
|
217
|
+
super(message, options);
|
|
218
|
+
this.name = "RecordsRootError";
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface RecordsRoot {
|
|
223
|
+
/** Whether the directory is there now: a desk keeps nothing until its member asks (ADR-0122). */
|
|
224
|
+
there(): Promise<boolean>;
|
|
225
|
+
/** The file a request under `/records/` asks for, or the refusal that says why not. */
|
|
226
|
+
respond(request: Request): Promise<Response>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A file's name as a download is called by it, in the one spelling every browser reads. */
|
|
230
|
+
function downloadAs(name: string): string {
|
|
231
|
+
const spelled = encodeURIComponent(name).replace(
|
|
232
|
+
/['()*]/g,
|
|
233
|
+
(character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`,
|
|
234
|
+
);
|
|
235
|
+
return `attachment; filename*=UTF-8''${spelled}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The part of a file a request asks for: one range of bytes, as a player asks for a video from
|
|
240
|
+
* where it is looked at. Nothing for a request that names none, several, or another unit, which
|
|
241
|
+
* is answered with the whole file; `null` for a range the file does not have.
|
|
242
|
+
*/
|
|
243
|
+
function rangeOf(
|
|
244
|
+
header: string | null,
|
|
245
|
+
size: number,
|
|
246
|
+
): { readonly start: number; readonly end: number } | undefined | null {
|
|
247
|
+
const found = header === null ? null : /^bytes=(\d*)-(\d*)$/.exec(header.trim());
|
|
248
|
+
if (found === null) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
const [, from = "", to = ""] = found;
|
|
252
|
+
if (from === "") {
|
|
253
|
+
// The last bytes of the file, as many as are asked for.
|
|
254
|
+
const length = Number(to);
|
|
255
|
+
if (to === "") {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
return length === 0 || size === 0 ? null : { start: Math.max(0, size - length), end: size - 1 };
|
|
259
|
+
}
|
|
260
|
+
const start = Number(from);
|
|
261
|
+
if (start >= size) {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
const end = to === "" ? size - 1 : Math.min(Number(to), size - 1);
|
|
265
|
+
return end < start ? undefined : { start, end };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The records of a desk, served to the desk's pages (ADR-0117): every file read when it is
|
|
270
|
+
* asked for, so that a record an agent just wrote is what the page shows, and never kept by the
|
|
271
|
+
* browser. `GET` alone. A path names a file under the directory and nothing else: no part of it
|
|
272
|
+
* is empty, `.` or `..`, begins with a full stop, ends with one or with a space, or holds what
|
|
273
|
+
* a file system reads as more than a name; a link that leads out of the directory leads
|
|
274
|
+
* nowhere; a folder is not listed. A file that is a git LFS pointer is refused by name, since
|
|
275
|
+
* what would be shown is not the file.
|
|
276
|
+
*
|
|
277
|
+
* A directory that is not there yet is no error (ADR-0122): a desk has its `records/` once it
|
|
278
|
+
* keeps something, and its pages are served before that. Such a directory holds nothing, and
|
|
279
|
+
* is looked for again at each request, so that the first thing kept is served with no restart.
|
|
280
|
+
* What is there and is no directory is refused before anything is served.
|
|
281
|
+
*/
|
|
282
|
+
export async function loadRecordsRoot(directory: string): Promise<RecordsRoot> {
|
|
283
|
+
/** The directory as it is now, links followed; nothing where it is not there yet. */
|
|
284
|
+
const rootNow = async (): Promise<string | undefined> => {
|
|
285
|
+
let root: string;
|
|
286
|
+
try {
|
|
287
|
+
root = await realpath(directory);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
if (
|
|
290
|
+
typeof error === "object" &&
|
|
291
|
+
error !== null &&
|
|
292
|
+
"code" in error &&
|
|
293
|
+
error.code === "ENOENT"
|
|
294
|
+
) {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
throw new RecordsRootError(`${directory} cannot be read`, { cause: error });
|
|
298
|
+
}
|
|
299
|
+
if (!(await stat(root)).isDirectory()) {
|
|
300
|
+
throw new RecordsRootError(`${directory} is there and is not a directory`);
|
|
301
|
+
}
|
|
302
|
+
return root;
|
|
303
|
+
};
|
|
304
|
+
// Said before anything is served: a file where the records are to be is a mistake to say now.
|
|
305
|
+
await rootNow();
|
|
306
|
+
/** The directory at the moment of a request: nothing where it is not one then, whatever it was. */
|
|
307
|
+
const rootThen = (): Promise<string | undefined> => rootNow().catch(() => undefined);
|
|
308
|
+
const headers = {
|
|
309
|
+
"cache-control": "no-store",
|
|
310
|
+
"x-content-type-options": "nosniff",
|
|
311
|
+
"cross-origin-resource-policy": "same-origin",
|
|
312
|
+
};
|
|
313
|
+
const notFound = (): Response =>
|
|
314
|
+
json(404, "records.not_found", "No file of the records is at this path.");
|
|
315
|
+
|
|
316
|
+
const fileAt = async (root: string, pathname: string): Promise<string | undefined> => {
|
|
317
|
+
const parts: string[] = [];
|
|
318
|
+
for (const raw of pathname.slice(RECORDS_PREFIX.length + 1).split("/")) {
|
|
319
|
+
let part: string;
|
|
320
|
+
try {
|
|
321
|
+
part = decodeURIComponent(raw);
|
|
322
|
+
} catch {
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
if (
|
|
326
|
+
part.length === 0 ||
|
|
327
|
+
part.startsWith(".") ||
|
|
328
|
+
part.endsWith(".") ||
|
|
329
|
+
part.trim() !== part ||
|
|
330
|
+
/[\\/:*?"<>|]/.test(part) ||
|
|
331
|
+
[...part].some((character) => (character.codePointAt(0) ?? 0) < 0x20)
|
|
332
|
+
) {
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
parts.push(part);
|
|
336
|
+
}
|
|
337
|
+
try {
|
|
338
|
+
// Where the path leads, links followed: a file inside the directory, or nothing.
|
|
339
|
+
const file = await realpath(join(root, ...parts));
|
|
340
|
+
return file.startsWith(`${root}${sep}`) ? file : undefined;
|
|
341
|
+
} catch {
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const respond = async (request: Request): Promise<Response> => {
|
|
347
|
+
if (request.method !== "GET") {
|
|
348
|
+
const refused = json(405, "records.read_only", "The records are read here, and only read.");
|
|
349
|
+
refused.headers.set("allow", "GET");
|
|
350
|
+
return refused;
|
|
351
|
+
}
|
|
352
|
+
const { pathname } = new URL(request.url);
|
|
353
|
+
const root = await rootThen();
|
|
354
|
+
const file =
|
|
355
|
+
root !== undefined && pathname.startsWith(`${RECORDS_PREFIX}/`)
|
|
356
|
+
? await fileAt(root, pathname)
|
|
357
|
+
: undefined;
|
|
358
|
+
if (file === undefined) {
|
|
359
|
+
return notFound();
|
|
360
|
+
}
|
|
361
|
+
let size: number;
|
|
362
|
+
try {
|
|
363
|
+
const info = await stat(file);
|
|
364
|
+
if (!info.isFile()) {
|
|
365
|
+
return notFound();
|
|
366
|
+
}
|
|
367
|
+
size = info.size;
|
|
368
|
+
} catch {
|
|
369
|
+
return notFound();
|
|
370
|
+
}
|
|
371
|
+
if (size <= MAX_LFS_POINTER_BYTES && isLfsPointer(await readFile(file, "utf8"))) {
|
|
372
|
+
return json(
|
|
373
|
+
409,
|
|
374
|
+
"records.not_fetched",
|
|
375
|
+
"This file is a git LFS pointer: the file itself was not fetched on this machine. git lfs pull in the desk fetches it.",
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
const kind = extname(file).toLowerCase();
|
|
379
|
+
const shown = SHOWN_IN_PLACE[kind];
|
|
380
|
+
const said: Record<string, string> = {
|
|
381
|
+
...headers,
|
|
382
|
+
"accept-ranges": "bytes",
|
|
383
|
+
...(shown !== undefined
|
|
384
|
+
? { "content-type": shown }
|
|
385
|
+
: kind === ".svg"
|
|
386
|
+
? {
|
|
387
|
+
"content-type": "image/svg+xml",
|
|
388
|
+
"content-disposition": downloadAs(basename(file)),
|
|
389
|
+
"content-security-policy": "sandbox",
|
|
390
|
+
}
|
|
391
|
+
: {
|
|
392
|
+
"content-type": "application/octet-stream",
|
|
393
|
+
"content-disposition": downloadAs(basename(file)),
|
|
394
|
+
}),
|
|
395
|
+
};
|
|
396
|
+
const range = rangeOf(request.headers.get("range"), size);
|
|
397
|
+
if (range === null) {
|
|
398
|
+
return new Response(null, {
|
|
399
|
+
status: 416,
|
|
400
|
+
headers: { ...headers, "content-range": `bytes */${size}` },
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
if (size === 0) {
|
|
404
|
+
return new Response(null, { status: 200, headers: { ...said, "content-length": "0" } });
|
|
405
|
+
}
|
|
406
|
+
const { start, end } = range ?? { start: 0, end: size - 1 };
|
|
407
|
+
return new Response(
|
|
408
|
+
Readable.toWeb(createReadStream(file, { start, end })) as unknown as ReadableStream,
|
|
409
|
+
{
|
|
410
|
+
status: range === undefined ? 200 : 206,
|
|
411
|
+
headers: {
|
|
412
|
+
...said,
|
|
413
|
+
"content-length": String(end - start + 1),
|
|
414
|
+
...(range === undefined ? {} : { "content-range": `bytes ${start}-${end}/${size}` }),
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
);
|
|
418
|
+
};
|
|
419
|
+
return { there: async () => (await rootThen()) !== undefined, respond };
|
|
420
|
+
}
|
|
421
|
+
|
|
155
422
|
/**
|
|
156
423
|
* What the command answers: the API carried to the console with the token, for the page's own
|
|
157
|
-
* requests; the
|
|
424
|
+
* requests; the files of a plugin's frame carried with none, for whatever page asks, since a
|
|
425
|
+
* frame's origin is no page's; a desk's records under `/records/`, for the same pages and no
|
|
426
|
+
* other site's; the build's files and its page for everything else, when there is a build; and
|
|
158
427
|
* nothing to a request whose host is not this loopback, which is a page elsewhere whose name
|
|
159
428
|
* was made to resolve here.
|
|
160
429
|
*/
|
|
@@ -171,6 +440,12 @@ export function createServeHandler(options: ServeOptions): ServeHandler {
|
|
|
171
440
|
return plain(421, "This address is not the console's.");
|
|
172
441
|
}
|
|
173
442
|
if (url.pathname === "/api" || url.pathname.startsWith("/api/")) {
|
|
443
|
+
// A file of a plugin's frame is read whatever page asks, the frame itself first, and
|
|
444
|
+
// never with the person's token: it is public at the console, so that no other site's
|
|
445
|
+
// page reaches anything of the person's through it.
|
|
446
|
+
if (readsFrameFile(request, url)) {
|
|
447
|
+
return forward(request, url, upstream, options, false);
|
|
448
|
+
}
|
|
174
449
|
if (!fromOwnPage(request, `http://${url.host}`)) {
|
|
175
450
|
return json(
|
|
176
451
|
403,
|
|
@@ -180,6 +455,24 @@ export function createServeHandler(options: ServeOptions): ServeHandler {
|
|
|
180
455
|
}
|
|
181
456
|
return forward(request, url, upstream, options);
|
|
182
457
|
}
|
|
458
|
+
// A desk's records, or the word that none are served: never the build's page, which a
|
|
459
|
+
// page that asked for a file would take for one.
|
|
460
|
+
if (url.pathname === RECORDS_PREFIX || url.pathname.startsWith(`${RECORDS_PREFIX}/`)) {
|
|
461
|
+
if (!fromOwnPage(request, `http://${url.host}`)) {
|
|
462
|
+
return json(
|
|
463
|
+
403,
|
|
464
|
+
"auth.forbidden_origin",
|
|
465
|
+
"This request must come from the console's own pages.",
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
return options.records === undefined
|
|
469
|
+
? json(
|
|
470
|
+
404,
|
|
471
|
+
"records.not_served",
|
|
472
|
+
"No records are served here. console serve --records <dir> serves a desk's.",
|
|
473
|
+
)
|
|
474
|
+
: options.records.respond(request);
|
|
475
|
+
}
|
|
183
476
|
if (options.web !== undefined) {
|
|
184
477
|
const answer = await options.web.respond(request);
|
|
185
478
|
if (answer !== undefined) {
|