dispach 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 +596 -0
- package/dist/App-dxqm39zx.js +11 -0
- package/dist/App-dxqm39zx.js.map +25 -0
- package/dist/ConfigEditor-7v5nebvy.js +6 -0
- package/dist/ConfigEditor-7v5nebvy.js.map +11 -0
- package/dist/KeyProbe-vjhmdpx6.js +5 -0
- package/dist/KeyProbe-vjhmdpx6.js.map +11 -0
- package/dist/Picker-jxaesaxy.js +5 -0
- package/dist/Picker-jxaesaxy.js.map +10 -0
- package/dist/SessionPicker-z2t0p4b5.js +5 -0
- package/dist/SessionPicker-z2t0p4b5.js.map +11 -0
- package/dist/SkillBrowser-yyf2gy0q.js +5 -0
- package/dist/SkillBrowser-yyf2gy0q.js.map +11 -0
- package/dist/WizardApp-12ndxgqv.js +5 -0
- package/dist/WizardApp-12ndxgqv.js.map +13 -0
- package/dist/agents.d.ts +9 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/browse.d.ts +63 -0
- package/dist/browse.d.ts.map +1 -0
- package/dist/client.d.ts +25 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +34 -0
- package/dist/client.js.map +11 -0
- package/dist/components/App.d.ts +28 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/Banner.d.ts +16 -0
- package/dist/components/Banner.d.ts.map +1 -0
- package/dist/components/Brandmark.d.ts +31 -0
- package/dist/components/Brandmark.d.ts.map +1 -0
- package/dist/components/CheckList.d.ts +38 -0
- package/dist/components/CheckList.d.ts.map +1 -0
- package/dist/components/CommandOutput.d.ts +29 -0
- package/dist/components/CommandOutput.d.ts.map +1 -0
- package/dist/components/ConfigEditor.d.ts +64 -0
- package/dist/components/ConfigEditor.d.ts.map +1 -0
- package/dist/components/HistorySearch.d.ts +23 -0
- package/dist/components/HistorySearch.d.ts.map +1 -0
- package/dist/components/KeyProbe.d.ts +36 -0
- package/dist/components/KeyProbe.d.ts.map +1 -0
- package/dist/components/LineCursor.d.ts +55 -0
- package/dist/components/LineCursor.d.ts.map +1 -0
- package/dist/components/Live.d.ts +17 -0
- package/dist/components/Live.d.ts.map +1 -0
- package/dist/components/Palette.d.ts +21 -0
- package/dist/components/Palette.d.ts.map +1 -0
- package/dist/components/Picker.d.ts +23 -0
- package/dist/components/Picker.d.ts.map +1 -0
- package/dist/components/Prompt.d.ts +20 -0
- package/dist/components/Prompt.d.ts.map +1 -0
- package/dist/components/Screen.d.ts +39 -0
- package/dist/components/Screen.d.ts.map +1 -0
- package/dist/components/SelectList.d.ts +34 -0
- package/dist/components/SelectList.d.ts.map +1 -0
- package/dist/components/SessionPicker.d.ts +26 -0
- package/dist/components/SessionPicker.d.ts.map +1 -0
- package/dist/components/SkillBrowser.d.ts +39 -0
- package/dist/components/SkillBrowser.d.ts.map +1 -0
- package/dist/components/Spinner.d.ts +13 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/StatusBar.d.ts +11 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/SummaryCard.d.ts +11 -0
- package/dist/components/SummaryCard.d.ts.map +1 -0
- package/dist/components/TextField.d.ts +39 -0
- package/dist/components/TextField.d.ts.map +1 -0
- package/dist/components/Transcript.d.ts +23 -0
- package/dist/components/Transcript.d.ts.map +1 -0
- package/dist/components/WizardApp.d.ts +18 -0
- package/dist/components/WizardApp.d.ts.map +1 -0
- package/dist/components/WizardFrame.d.ts +19 -0
- package/dist/components/WizardFrame.d.ts.map +1 -0
- package/dist/config-yz0nz51b.js +24 -0
- package/dist/config-yz0nz51b.js.map +10 -0
- package/dist/config.d.ts +71 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/credential-wgt4gvcz.js +19 -0
- package/dist/credential-wgt4gvcz.js.map +10 -0
- package/dist/credential.d.ts +68 -0
- package/dist/credential.d.ts.map +1 -0
- package/dist/daemon.d.ts +47 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/editor.d.ts +81 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/hooks/useElapsed.d.ts +10 -0
- package/dist/hooks/useElapsed.d.ts.map +1 -0
- package/dist/hooks/useTerminalSize.d.ts +14 -0
- package/dist/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/hooks/useTurn.d.ts +41 -0
- package/dist/hooks/useTurn.d.ts.map +1 -0
- package/dist/index-2cvtz0fy.js +903 -0
- package/dist/index-2cvtz0fy.js.map +194 -0
- package/dist/index-3nwfz9jq.js +12 -0
- package/dist/index-3nwfz9jq.js.map +11 -0
- package/dist/index-6b7qvh1x.js +6 -0
- package/dist/index-6b7qvh1x.js.map +10 -0
- package/dist/index-6z0yr17z.js +12 -0
- package/dist/index-6z0yr17z.js.map +11 -0
- package/dist/index-7da4fqcr.js +7 -0
- package/dist/index-7da4fqcr.js.map +11 -0
- package/dist/index-8bmhd2hj.js +6 -0
- package/dist/index-8bmhd2hj.js.map +10 -0
- package/dist/index-9d011p3q.js +6 -0
- package/dist/index-9d011p3q.js.map +10 -0
- package/dist/index-9f9pp2ef.js +6 -0
- package/dist/index-9f9pp2ef.js.map +10 -0
- package/dist/index-9nsfs0vy.js +6 -0
- package/dist/index-9nsfs0vy.js.map +10 -0
- package/dist/index-9pj1ws0p.js +77 -0
- package/dist/index-9pj1ws0p.js.map +12 -0
- package/dist/index-b5wwtxzk.js +66 -0
- package/dist/index-b5wwtxzk.js.map +12 -0
- package/dist/index-b8zwg8a3.js +6 -0
- package/dist/index-b8zwg8a3.js.map +10 -0
- package/dist/index-bry9bzt3.js +427 -0
- package/dist/index-bry9bzt3.js.map +11 -0
- package/dist/index-bwckzbf8.js +6 -0
- package/dist/index-bwckzbf8.js.map +10 -0
- package/dist/index-cx3vz7sf.js +6 -0
- package/dist/index-cx3vz7sf.js.map +11 -0
- package/dist/index-e8n70sgj.js +6 -0
- package/dist/index-e8n70sgj.js.map +11 -0
- package/dist/index-fvhg0xyd.js +167 -0
- package/dist/index-fvhg0xyd.js.map +19 -0
- package/dist/index-gbnc99j8.js +14 -0
- package/dist/index-gbnc99j8.js.map +13 -0
- package/dist/index-h2yds678.js +7 -0
- package/dist/index-h2yds678.js.map +11 -0
- package/dist/index-j97vttdt.js +10 -0
- package/dist/index-j97vttdt.js.map +10 -0
- package/dist/index-jk0def33.js +6 -0
- package/dist/index-jk0def33.js.map +12 -0
- package/dist/index-jym27m75.js +6 -0
- package/dist/index-jym27m75.js.map +10 -0
- package/dist/index-mgdgx22q.js +10 -0
- package/dist/index-mgdgx22q.js.map +10 -0
- package/dist/index-mrtb5y08.js +6 -0
- package/dist/index-mrtb5y08.js.map +11 -0
- package/dist/index-my5cjx00.js +6 -0
- package/dist/index-my5cjx00.js.map +10 -0
- package/dist/index-qc2vrq9z.js +7 -0
- package/dist/index-qc2vrq9z.js.map +11 -0
- package/dist/index-rqbtm761.js +6 -0
- package/dist/index-rqbtm761.js.map +10 -0
- package/dist/index-rqzg861g.js +6 -0
- package/dist/index-rqzg861g.js.map +10 -0
- package/dist/index-t1xvacym.js +6 -0
- package/dist/index-t1xvacym.js.map +11 -0
- package/dist/index-xgqzk5cq.js +9 -0
- package/dist/index-xgqzk5cq.js.map +12 -0
- package/dist/index-xqyms08r.js +6 -0
- package/dist/index-xqyms08r.js.map +10 -0
- package/dist/index-yr25dnf5.js +6 -0
- package/dist/index-yr25dnf5.js.map +10 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +527 -0
- package/dist/index.js.map +48 -0
- package/dist/init.d.ts +34 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/keymap.d.ts +126 -0
- package/dist/keymap.d.ts.map +1 -0
- package/dist/keys.d.ts +17 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/lib/ambient.d.ts +69 -0
- package/dist/lib/ambient.d.ts.map +1 -0
- package/dist/lib/args.d.ts +33 -0
- package/dist/lib/args.d.ts.map +1 -0
- package/dist/lib/bootstrap.d.ts +84 -0
- package/dist/lib/bootstrap.d.ts.map +1 -0
- package/dist/lib/browse.d.ts +89 -0
- package/dist/lib/browse.d.ts.map +1 -0
- package/dist/lib/browser.d.ts +55 -0
- package/dist/lib/browser.d.ts.map +1 -0
- package/dist/lib/chat-frame.d.ts +156 -0
- package/dist/lib/chat-frame.d.ts.map +1 -0
- package/dist/lib/clipboard.d.ts +32 -0
- package/dist/lib/clipboard.d.ts.map +1 -0
- package/dist/lib/commands.d.ts +26 -0
- package/dist/lib/commands.d.ts.map +1 -0
- package/dist/lib/composer.d.ts +85 -0
- package/dist/lib/composer.d.ts.map +1 -0
- package/dist/lib/config-apply.d.ts +51 -0
- package/dist/lib/config-apply.d.ts.map +1 -0
- package/dist/lib/config-editor.d.ts +113 -0
- package/dist/lib/config-editor.d.ts.map +1 -0
- package/dist/lib/config-env.d.ts +110 -0
- package/dist/lib/config-env.d.ts.map +1 -0
- package/dist/lib/config-rows.d.ts +37 -0
- package/dist/lib/config-rows.d.ts.map +1 -0
- package/dist/lib/config-view.d.ts +133 -0
- package/dist/lib/config-view.d.ts.map +1 -0
- package/dist/lib/confirm.d.ts +86 -0
- package/dist/lib/confirm.d.ts.map +1 -0
- package/dist/lib/const.d.ts +213 -0
- package/dist/lib/const.d.ts.map +1 -0
- package/dist/lib/csi.d.ts +70 -0
- package/dist/lib/csi.d.ts.map +1 -0
- package/dist/lib/curated.d.ts +44 -0
- package/dist/lib/curated.d.ts.map +1 -0
- package/dist/lib/daemon-plan.d.ts +151 -0
- package/dist/lib/daemon-plan.d.ts.map +1 -0
- package/dist/lib/dotenv-edit.d.ts +30 -0
- package/dist/lib/dotenv-edit.d.ts.map +1 -0
- package/dist/lib/env.d.ts +10 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/exit.d.ts +170 -0
- package/dist/lib/exit.d.ts.map +1 -0
- package/dist/lib/help.d.ts +10 -0
- package/dist/lib/help.d.ts.map +1 -0
- package/dist/lib/init-flow.d.ts +539 -0
- package/dist/lib/init-flow.d.ts.map +1 -0
- package/dist/lib/init-skills.d.ts +46 -0
- package/dist/lib/init-skills.d.ts.map +1 -0
- package/dist/lib/keyboard.d.ts +76 -0
- package/dist/lib/keyboard.d.ts.map +1 -0
- package/dist/lib/keys-view.d.ts +57 -0
- package/dist/lib/keys-view.d.ts.map +1 -0
- package/dist/lib/launchd.d.ts +151 -0
- package/dist/lib/launchd.d.ts.map +1 -0
- package/dist/lib/lifecycle.d.ts +126 -0
- package/dist/lib/lifecycle.d.ts.map +1 -0
- package/dist/lib/log-follow.d.ts +71 -0
- package/dist/lib/log-follow.d.ts.map +1 -0
- package/dist/lib/mouse.d.ts +84 -0
- package/dist/lib/mouse.d.ts.map +1 -0
- package/dist/lib/multiselect.d.ts +37 -0
- package/dist/lib/multiselect.d.ts.map +1 -0
- package/dist/lib/origins.d.ts +40 -0
- package/dist/lib/origins.d.ts.map +1 -0
- package/dist/lib/output.d.ts +29 -0
- package/dist/lib/output.d.ts.map +1 -0
- package/dist/lib/palette.d.ts +69 -0
- package/dist/lib/palette.d.ts.map +1 -0
- package/dist/lib/probe.d.ts +158 -0
- package/dist/lib/probe.d.ts.map +1 -0
- package/dist/lib/providers.d.ts +63 -0
- package/dist/lib/providers.d.ts.map +1 -0
- package/dist/lib/provision.d.ts +163 -0
- package/dist/lib/provision.d.ts.map +1 -0
- package/dist/lib/remove-plan.d.ts +120 -0
- package/dist/lib/remove-plan.d.ts.map +1 -0
- package/dist/lib/render.d.ts +78 -0
- package/dist/lib/render.d.ts.map +1 -0
- package/dist/lib/resume.d.ts +69 -0
- package/dist/lib/resume.d.ts.map +1 -0
- package/dist/lib/rows.d.ts +69 -0
- package/dist/lib/rows.d.ts.map +1 -0
- package/dist/lib/sandbox.d.ts +101 -0
- package/dist/lib/sandbox.d.ts.map +1 -0
- package/dist/lib/schema.d.ts +491 -0
- package/dist/lib/schema.d.ts.map +1 -0
- package/dist/lib/screen.d.ts +102 -0
- package/dist/lib/screen.d.ts.map +1 -0
- package/dist/lib/scroll.d.ts +64 -0
- package/dist/lib/scroll.d.ts.map +1 -0
- package/dist/lib/select.d.ts +23 -0
- package/dist/lib/select.d.ts.map +1 -0
- package/dist/lib/service-env.d.ts +38 -0
- package/dist/lib/service-env.d.ts.map +1 -0
- package/dist/lib/service.d.ts +102 -0
- package/dist/lib/service.d.ts.map +1 -0
- package/dist/lib/session-commands.d.ts +229 -0
- package/dist/lib/session-commands.d.ts.map +1 -0
- package/dist/lib/session-key.d.ts +55 -0
- package/dist/lib/session-key.d.ts.map +1 -0
- package/dist/lib/sessions-view.d.ts +31 -0
- package/dist/lib/sessions-view.d.ts.map +1 -0
- package/dist/lib/source-cache.d.ts +105 -0
- package/dist/lib/source-cache.d.ts.map +1 -0
- package/dist/lib/source.d.ts +281 -0
- package/dist/lib/source.d.ts.map +1 -0
- package/dist/lib/sources.d.ts +107 -0
- package/dist/lib/sources.d.ts.map +1 -0
- package/dist/lib/spawn.d.ts +56 -0
- package/dist/lib/spawn.d.ts.map +1 -0
- package/dist/lib/stdin-tap.d.ts +41 -0
- package/dist/lib/stdin-tap.d.ts.map +1 -0
- package/dist/lib/subcommand.d.ts +57 -0
- package/dist/lib/subcommand.d.ts.map +1 -0
- package/dist/lib/systemd.d.ts +60 -0
- package/dist/lib/systemd.d.ts.map +1 -0
- package/dist/lib/templates.d.ts +35 -0
- package/dist/lib/templates.d.ts.map +1 -0
- package/dist/lib/terminal.d.ts +98 -0
- package/dist/lib/terminal.d.ts.map +1 -0
- package/dist/lib/text-selection.d.ts +75 -0
- package/dist/lib/text-selection.d.ts.map +1 -0
- package/dist/lib/theme.d.ts +90 -0
- package/dist/lib/theme.d.ts.map +1 -0
- package/dist/lib/types.d.ts +467 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/warnings.d.ts +79 -0
- package/dist/lib/warnings.d.ts.map +1 -0
- package/dist/lib/width.d.ts +39 -0
- package/dist/lib/width.d.ts.map +1 -0
- package/dist/lib/wizard.d.ts +95 -0
- package/dist/lib/wizard.d.ts.map +1 -0
- package/dist/lib/wordmark.d.ts +60 -0
- package/dist/lib/wordmark.d.ts.map +1 -0
- package/dist/lib/wrap.d.ts +74 -0
- package/dist/lib/wrap.d.ts.map +1 -0
- package/dist/memory.d.ts +25 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/model.d.ts +47 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/plugins.d.ts +15 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/remove.d.ts +52 -0
- package/dist/remove.d.ts.map +1 -0
- package/dist/run.d.ts +42 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/schedules.d.ts +41 -0
- package/dist/schedules.d.ts.map +1 -0
- package/dist/serve.d.ts +41 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/sessions.d.ts +13 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/skills.d.ts +80 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/soul.d.ts +19 -0
- package/dist/soul.d.ts.map +1 -0
- package/dist/sources.d.ts +32 -0
- package/dist/sources.d.ts.map +1 -0
- package/dist/start.d.ts +26 -0
- package/dist/start.d.ts.map +1 -0
- package/dist/stop.d.ts +58 -0
- package/dist/stop.d.ts.map +1 -0
- package/dist/terminal-setup.d.ts +31 -0
- package/dist/terminal-setup.d.ts.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/transcript.d.ts +124 -0
- package/dist/transcript.d.ts.map +1 -0
- package/dist/validate.d.ts +36 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/web-w7r68df1.js +14 -0
- package/dist/web-w7r68df1.js.map +11 -0
- package/dist/web.d.ts +36 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +33 -0
- package/dist/wire.js.map +10 -0
- package/dist/workspace.d.ts +19 -0
- package/dist/workspace.d.ts.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether this process asks the terminal for enhanced keys, and what it asks for.
|
|
3
|
+
*
|
|
4
|
+
* ## Why there is anything to ask for
|
|
5
|
+
*
|
|
6
|
+
* Ink 7.1 ships a complete kitty-keyboard-protocol parser — `parse-keypress.js` decodes `CSI u`, and
|
|
7
|
+
* `Key` carries `super`, `hyper`, `home` and `end` — and **none of it runs unless a caller opts in**:
|
|
8
|
+
*
|
|
9
|
+
* initKittyKeyboard() {
|
|
10
|
+
* // Protocol is opt-in: if kittyKeyboard is not specified, do nothing
|
|
11
|
+
* if (!this.options.kittyKeyboard) return
|
|
12
|
+
*
|
|
13
|
+
* That single `return` is why `⌥r` typed `®` into the message instead of unfolding the reasoning block,
|
|
14
|
+
* and why `cmd+←` word-moved instead of jumping to the start of the line: without the protocol, `⌥`
|
|
15
|
+
* depends on a terminal setting that is off by default in Warp, and `super` cannot be expressed by any
|
|
16
|
+
* legacy escape sequence at all — Ink's legacy branch folds it into `meta` (`modifier & 10`, bit 8 being
|
|
17
|
+
* super and bit 2 alt), so the two chords become the same keystroke.
|
|
18
|
+
*
|
|
19
|
+
* ## Why both flags
|
|
20
|
+
*
|
|
21
|
+
* `disambiguateEscapeCodes` alone fixes the letter chords: `⌥r` arrives as `CSI 114;3u`, which Ink reports
|
|
22
|
+
* as `input "r"` with `meta` set — exactly the shape `keymap.ts` already matched, which is why turning
|
|
23
|
+
* this on required no change to a single binding. It is **not** enough for `cmd+←`: an arrow with a
|
|
24
|
+
* modifier comes back as `CSI 1;9D`, and Ink's kitty branch for special keys (`kittySpecialKeyRe`)
|
|
25
|
+
* *requires* the `:eventType` field, so without `reportEventTypes` the sequence falls through to the
|
|
26
|
+
* legacy path and the super bit is folded away again.
|
|
27
|
+
*
|
|
28
|
+
* The cost of that second flag is stated where it is paid: Ink passes `eventType` through untouched and
|
|
29
|
+
* filters nothing, so `keymap.ts` drops `release` or every enhanced chord fires twice.
|
|
30
|
+
*
|
|
31
|
+
* ## Why `enabled` rather than `auto`, measured
|
|
32
|
+
*
|
|
33
|
+
* `auto` is the careful-looking option: Ink writes `CSI ? u`, waits **200 ms**, and enables only if the
|
|
34
|
+
* terminal answers. It was the first choice here and it loses the race. In a real Warp session the reply
|
|
35
|
+
* arrived *after* the window closed — visible in `keys` as `bytes 1b 5b 3f 30 75` resolving to an insert,
|
|
36
|
+
* because Ink strips the answer only while it is still listening. So the protocol stayed **off** on a
|
|
37
|
+
* terminal that plainly supports it, and every option-letter chord went on depending on Warp's
|
|
38
|
+
* *Left/Right Option Key is Meta* setting, which is off by default. That is the reported bug, one layer
|
|
39
|
+
* down from where it looked like it was.
|
|
40
|
+
*
|
|
41
|
+
* `enabled` pushes `CSI > flags u` without asking. The cost is bounded by how terminals treat private-mode
|
|
42
|
+
* sequences they do not know — they discard them — and the pop on the way out is the same shape. It is
|
|
43
|
+
* also no longer load-bearing: `lib/csi.ts` reads modifiers off the bytes, so a terminal that ignores the
|
|
44
|
+
* push still gets working cmd chords. The protocol now buys the *letter* chords, and losing it silently
|
|
45
|
+
* costs those rather than everything.
|
|
46
|
+
*
|
|
47
|
+
* The override stays for the case neither argument covers: a terminal that accepts the push and then
|
|
48
|
+
* implements it badly. The reference CLI carries the same hatch (`CLAUDE_CODE_DISABLE_MOUSE`), and a
|
|
49
|
+
* switch nobody can reach is not a hatch.
|
|
50
|
+
*/
|
|
51
|
+
export interface KeyboardOptions {
|
|
52
|
+
readonly kittyKeyboard?: {
|
|
53
|
+
readonly mode: "auto" | "enabled" | "disabled";
|
|
54
|
+
/**
|
|
55
|
+
* The property is readonly; the array is not, because Ink's own `flags` is a mutable
|
|
56
|
+
* `KittyFlagName[]` and under `exactOptionalPropertyTypes` a `readonly` array does not satisfy
|
|
57
|
+
* it. Nothing is shared as a result — `keyboardOptions` builds a fresh array on every call, which
|
|
58
|
+
* is what makes the mutable type harmless rather than a hole.
|
|
59
|
+
*/
|
|
60
|
+
readonly flags: ("disambiguateEscapeCodes" | "reportEventTypes")[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* One answer for every surface that mounts Ink, and the teardown registered with it.
|
|
65
|
+
*
|
|
66
|
+
* Every one of them reads keys, so a per-surface decision would mean the chat honoured `cmd+←` and the
|
|
67
|
+
* settings editor did not — and the *next* surface would forget entirely. `inSession` on `CommandSpec` is
|
|
68
|
+
* the same shape: derived once so a new caller cannot drift.
|
|
69
|
+
*
|
|
70
|
+
* It marks rather than merely returning, which is why it is not called `keyboardOptions`: asking for the
|
|
71
|
+
* protocol and arranging to withdraw it are one decision, and six call sites each remembering to do the
|
|
72
|
+
* second is six chances to leave a terminal reporting `CSI u` at somebody's shell. Ink withdraws it on
|
|
73
|
+
* unmount by itself; the mark covers the signal path, which is the one Ink cannot see.
|
|
74
|
+
*/
|
|
75
|
+
export declare function negotiateKeyboard(disabled?: boolean): KeyboardOptions;
|
|
76
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/lib/keyboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAaH,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE;QACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;QAC9C;;;;;WAKG;QACH,QAAQ,CAAC,KAAK,EAAE,CAAC,yBAAyB,GAAG,kBAAkB,CAAC,EAAE,CAAA;KACrE,CAAA;CACJ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,eAAe,CAarE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a keystroke actually was, rendered for a person to paste into a bug report.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists
|
|
5
|
+
*
|
|
6
|
+
* CLAUDE.md's rule is that a key chord is verified against a real terminal and never against the parser,
|
|
7
|
+
* and for ten rounds of TUI work there was no way to do that: the only instrument was Ink reporting *a*
|
|
8
|
+
* key, which says nothing about the bytes a terminal sent. So `⌥r` was documented, bound, handled, and
|
|
9
|
+
* silently arriving as the composed character `®`, and every round diagnosed it by guessing.
|
|
10
|
+
*
|
|
11
|
+
* A probe ends that. It prints the bytes, Ink's reading of them, and the intent this repo's own keymap
|
|
12
|
+
* resolved — three layers, so a failure names which one is wrong instead of leaving three suspects.
|
|
13
|
+
*
|
|
14
|
+
* Pure, so every line of it is asserted without a terminal. The component around it does nothing but
|
|
15
|
+
* mount a `useInput` and hand what arrives to these functions.
|
|
16
|
+
*/
|
|
17
|
+
import type { Intent, KeyState } from "#lib/types";
|
|
18
|
+
/** One keystroke, as all three layers saw it. */
|
|
19
|
+
export interface Keystroke {
|
|
20
|
+
/**
|
|
21
|
+
* What the terminal actually wrote, tapped off stdin.
|
|
22
|
+
*
|
|
23
|
+
* Distinct from `input` because for a special key they differ completely: `CSI 1;9:1D` reaches a
|
|
24
|
+
* handler as `input: ""` with flags set, so a probe reporting only `input` prints an empty byte row
|
|
25
|
+
* for every arrow, Home, and cmd chord — the exact keys worth probing. Measured under a pty, not
|
|
26
|
+
* reasoned about.
|
|
27
|
+
*/
|
|
28
|
+
readonly bytes: string;
|
|
29
|
+
/** What Ink handed the handler. Empty for a special key, which is itself the point. */
|
|
30
|
+
readonly input: string;
|
|
31
|
+
readonly key: KeyState;
|
|
32
|
+
readonly intent: Intent;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The bytes, in hex, as UTF-8 — which is what the terminal actually wrote.
|
|
36
|
+
*
|
|
37
|
+
* Not `charCodeAt`: that reports UTF-16 code units, so a composed `®` or an emoji would print a number
|
|
38
|
+
* no terminal ever sent. The point of a byte probe is the bytes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function hexOf(text: string): string;
|
|
41
|
+
/** The modifier and key flags Ink set, named. Empty when it set none, which is itself information. */
|
|
42
|
+
export declare function flagsOf(key: KeyState): string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the keystroke is evidence that the kitty protocol negotiated.
|
|
45
|
+
*
|
|
46
|
+
* Ink does not expose whether its handshake succeeded, and asking the terminal a second time from here
|
|
47
|
+
* would be a different question than the one Ink asked. So this reports *evidence* rather than a claim:
|
|
48
|
+
* `super` cannot be expressed without the protocol, and an `eventType` only arrives under
|
|
49
|
+
* `reportEventTypes`. Either one proves it is on. Neither one appearing proves nothing either way, which
|
|
50
|
+
* the verdict below says in as many words rather than defaulting to "off".
|
|
51
|
+
*/
|
|
52
|
+
export declare function provesProtocol(key: KeyState): boolean;
|
|
53
|
+
/** What can honestly be said about the protocol, given what has been pressed so far. */
|
|
54
|
+
export declare function protocolVerdict(seen: readonly Keystroke[], asked: boolean): string;
|
|
55
|
+
/** One keystroke as three labelled lines, deepest layer last. */
|
|
56
|
+
export declare function keystrokeRows(stroke: Keystroke): readonly string[];
|
|
57
|
+
//# sourceMappingURL=keys-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys-view.d.ts","sourceRoot":"","sources":["../../src/lib/keys-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAElD,iDAAiD;AACjD,MAAM,WAAW,SAAS;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1C;AAED,sGAAsG;AACtG,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAyB7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAErD;AAED,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAMlF;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,MAAM,EAAE,CAelE"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* launchd, as string transformations. Pure: no `node:*`, no `process`, no subprocess.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is text in, text out — a plist rendered from a plan, and `launchctl` output
|
|
5
|
+
* parsed into facts. That is what lets every plist key and every status decode be unit-tested
|
|
6
|
+
* without installing a service on the machine running the tests, and it is why `service.ts`, which
|
|
7
|
+
* actually shells out, contains almost no logic.
|
|
8
|
+
*
|
|
9
|
+
* ## The counter-example this file was written against
|
|
10
|
+
*
|
|
11
|
+
* `~/Library/LaunchAgents/ai.openclaw.gateway.plist`, on the author's machine, from the gateway
|
|
12
|
+
* this runtime replaces. Three things it gets wrong, each reproduced here as a rule:
|
|
13
|
+
*
|
|
14
|
+
* 1. **It stores a live token as a literal string** in a `-rw-r--r--` file, and `launchctl print`
|
|
15
|
+
* echoes `EnvironmentVariables` in plaintext to anything running as that user. Hard rule 10 says
|
|
16
|
+
* secrets are env var *names* in config, never values, and a plist is config. So `renderPlist`
|
|
17
|
+
* *throws* on a key outside `PLIST_ENV_ALLOWED` rather than trusting whoever builds the plan.
|
|
18
|
+
* 2. **It runs a Homebrew interpreter against an nvm-installed script.** It works by accident and
|
|
19
|
+
* dies when either moves. Interpreter and script are both resolved absolutely, by the caller,
|
|
20
|
+
* and recorded.
|
|
21
|
+
* 3. **`KeepAlive: true`.** At the time of writing that job reports `runs = 2463`,
|
|
22
|
+
* `last exit code = 1`, and a 57 MB stderr log containing one sentence repeated every ten
|
|
23
|
+
* seconds. The message is a good one — it names the cause and offers two remedies. It was
|
|
24
|
+
* simply written somewhere nobody looks, thousands of times. See `KEEP_ALIVE`.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Environment keys a generated service definition may carry — **moved to `service-env.ts`**.
|
|
28
|
+
*
|
|
29
|
+
* The systemd renderer needs the identical list: `systemctl show` exposes `Environment=` exactly as
|
|
30
|
+
* `launchctl print` exposes `EnvironmentVariables`, so a second copy is how one manager comes to
|
|
31
|
+
* permit a variable the other refuses, and the dangerous direction is the one that silently permits
|
|
32
|
+
* more. Re-exported under the old name so every existing caller is unchanged.
|
|
33
|
+
*/
|
|
34
|
+
export { serviceEnvAllowed as plistEnvAllowed } from "#lib/service-env";
|
|
35
|
+
/**
|
|
36
|
+
* Restart on a crash signal, and on nothing else.
|
|
37
|
+
*
|
|
38
|
+
* The whole crash-loop answer, and it is structural rather than advisory. A deliberate non-zero
|
|
39
|
+
* exit means the configuration is wrong — a manifest that will not load, a missing credential, a
|
|
40
|
+
* port already taken — and relaunching that thirty times an hour produces the 57 MB log described
|
|
41
|
+
* above. Under `Crashed` the job stops once, with the reason on disk, and `daemon status` says so.
|
|
42
|
+
*
|
|
43
|
+
* This is only safe because of a property the runtime already has: `ChannelHub.start()` catches
|
|
44
|
+
* each transport's failure and boots anyway, so a Telegram outage or a rejected token never ends
|
|
45
|
+
* the process. A non-zero exit therefore really is a misconfiguration and never a transient.
|
|
46
|
+
*
|
|
47
|
+
* The trade, stated rather than discovered: an uncaught exception also stops the service instead of
|
|
48
|
+
* looping. A loud stop is the better failure — this codebase's whole objection to the OpenClaw job
|
|
49
|
+
* is that nobody was ever told.
|
|
50
|
+
*/
|
|
51
|
+
export declare const KEEP_ALIVE: {
|
|
52
|
+
readonly Crashed: true;
|
|
53
|
+
};
|
|
54
|
+
/** launchd's default is 10s. Higher, because a restart loop should cost less while it lasts. */
|
|
55
|
+
export declare const THROTTLE_SECONDS = 30;
|
|
56
|
+
/**
|
|
57
|
+
* SIGTERM to SIGKILL. Must exceed the runtime's own stop deadline, or the reaper that kills
|
|
58
|
+
* backgrounded `exec` children never finishes and they outlive the service.
|
|
59
|
+
*/
|
|
60
|
+
export declare const EXIT_TIMEOUT_SECONDS = 30;
|
|
61
|
+
export interface ServicePlan {
|
|
62
|
+
readonly label: string;
|
|
63
|
+
readonly programArguments: readonly string[];
|
|
64
|
+
readonly workingDirectory: string;
|
|
65
|
+
readonly stdoutPath: string;
|
|
66
|
+
readonly stderrPath: string;
|
|
67
|
+
readonly environment: Readonly<Record<string, string>>;
|
|
68
|
+
/** Rendered into an XML comment. launchd has no `Comment` key — OpenClaw's is inert. */
|
|
69
|
+
readonly provenance: readonly string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The old name, kept as an alias so nothing that caught it stops catching it.
|
|
73
|
+
*
|
|
74
|
+
* The class itself is `ServiceSecretError` in `service-env.ts` — one error for two renderers, for
|
|
75
|
+
* the reason the allowlist is one list.
|
|
76
|
+
*/
|
|
77
|
+
export { ServiceSecretError as PlistSecretError } from "#lib/service-env";
|
|
78
|
+
/**
|
|
79
|
+
* `<slug>.agent.<id>` — the **retired** per-agent label.
|
|
80
|
+
*
|
|
81
|
+
* Kept, and now only for retirement: one service hosts every agent, so this is what a bare
|
|
82
|
+
* `daemon install` looks for in order to clean it up. Leaving a per-agent unit installed beside the
|
|
83
|
+
* server unit is a broken state rather than a redundant one — both claim the same lease, so the
|
|
84
|
+
* server reports that agent as served elsewhere indefinitely with nothing looking wrong.
|
|
85
|
+
*
|
|
86
|
+
* ⚠️ **`launchctl enable` is the only thing that clears an orphaned `disable` row**, and no verb
|
|
87
|
+
* deletes it. Deleting the plist leaves `<slug>.agent.<id> => disabled` in
|
|
88
|
+
* `/var/db/com.apple.xpc.launchd/` forever, so a future job reusing that label installs cleanly,
|
|
89
|
+
* reports success and silently never starts. Retirement is therefore `bootout` + `enable` + `rm`,
|
|
90
|
+
* in that order, and never just `rm`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function labelFor(slug: string, agentId: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* `<slug>.server` — the one unit.
|
|
95
|
+
*
|
|
96
|
+
* One service for the host rather than one per agent, because per-agent on/off is durable *state*
|
|
97
|
+
* (16.3's `agent_state`) and not a unit: `stop milo` leaves the host serving everything else, which
|
|
98
|
+
* a unit-per-agent cannot express without N processes contending for one port.
|
|
99
|
+
*/
|
|
100
|
+
export declare function serverLabel(slug: string): string;
|
|
101
|
+
export declare function escapeXml(value: string): string;
|
|
102
|
+
export declare function renderPlist(plan: ServicePlan, envPrefix: string): string;
|
|
103
|
+
export interface ListEntry {
|
|
104
|
+
readonly pid?: number;
|
|
105
|
+
/** Raw wait status, exactly as the column carries it. Decode with `decodeWaitStatus`. */
|
|
106
|
+
readonly status: number;
|
|
107
|
+
readonly label: string;
|
|
108
|
+
}
|
|
109
|
+
/** `launchctl list` — tab-separated `PID / Status / Label`, `-` for an absent pid. */
|
|
110
|
+
export declare function parseLaunchctlList(text: string): readonly ListEntry[];
|
|
111
|
+
export interface PrintFacts {
|
|
112
|
+
readonly pid?: number;
|
|
113
|
+
readonly runs?: number;
|
|
114
|
+
/** **Already decoded** by launchctl. Never pass this through `decodeWaitStatus`. */
|
|
115
|
+
readonly lastExitCode?: number;
|
|
116
|
+
readonly jobState?: string;
|
|
117
|
+
readonly stdoutPath?: string;
|
|
118
|
+
readonly stderrPath?: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `launchctl print gui/$UID/<label>` — the only form carrying `runs`, which is what makes a
|
|
122
|
+
* restart loop visible rather than merely a stopped job.
|
|
123
|
+
*
|
|
124
|
+
* Deliberately does **not** surface the `EnvironmentVariables` block it walks past. That output
|
|
125
|
+
* echoes every value in plaintext, and a parser that lifted them into a struct would be one
|
|
126
|
+
* `--json` away from writing somebody's bot token into a log file.
|
|
127
|
+
*/
|
|
128
|
+
export declare function parseLaunchctlPrint(text: string): PrintFacts;
|
|
129
|
+
export interface WaitStatus {
|
|
130
|
+
readonly exitCode?: number;
|
|
131
|
+
readonly signal?: number;
|
|
132
|
+
readonly signalName?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Decode `launchctl list`'s status column — and only that column.
|
|
136
|
+
*
|
|
137
|
+
* It is a raw `wait(2)` status: `256` means exit code 1, and a negative value names the signal that
|
|
138
|
+
* killed the job. `launchctl print`'s `last exit code` is *already decoded*, and putting it through
|
|
139
|
+
* here turns exit 1 into exit 0 — a broken service reported as a clean stop. Two sources, two
|
|
140
|
+
* code paths, on purpose.
|
|
141
|
+
*/
|
|
142
|
+
export declare function decodeWaitStatus(raw: number): WaitStatus;
|
|
143
|
+
/**
|
|
144
|
+
* `launchctl print-disabled gui/$UID` → the labels explicitly disabled.
|
|
145
|
+
*
|
|
146
|
+
* Required, not optional. A disabled job is simply absent from `launchctl list`, so without this
|
|
147
|
+
* "you stopped it" and "it failed and was removed" are the same observation — and `disable`
|
|
148
|
+
* persists across boots, which is how a reinstall silently never starts.
|
|
149
|
+
*/
|
|
150
|
+
export declare function parseDisabled(text: string): readonly string[];
|
|
151
|
+
//# sourceMappingURL=launchd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launchd.d.ts","sourceRoot":"","sources":["../../src/lib/launchd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU;;CAA6B,CAAA;AAEpD,gGAAgG;AAChG,eAAO,MAAM,gBAAgB,KAAK,CAAA;AAClC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACtD,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAA;CACzC;AAED;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEzE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAuDxE;AAID,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,yFAAyF;IACzF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACzB;AAED,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAerE;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,oFAAoF;IACpF,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAyB5D;AAED,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC/B;AAWD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAUxD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAO7D"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reaching a running host, and reading the durable on/off switch.
|
|
3
|
+
*
|
|
4
|
+
* Shared by `serve`, `stop` and `start`, because all three ask the same two questions and a second
|
|
5
|
+
* answer to either is a disagreement waiting to happen: *which agents is this sandbox supposed to
|
|
6
|
+
* run*, and *where is the process already running them*.
|
|
7
|
+
*
|
|
8
|
+
* **Why an HTTP request rather than a signal.** Since one process hosts several agents, stopping
|
|
9
|
+
* one by signalling the lease holder takes every other agent in that process down with it. A signal
|
|
10
|
+
* also cannot name an agent. So `stop` posts to the host, which disposes exactly one — and the
|
|
11
|
+
* address comes off the lease row rather than from a manifest, because `--port` overrides the file,
|
|
12
|
+
* `--port 0` picks one at random and a container republishes it. Guessing 7420 is how a second host
|
|
13
|
+
* on 7421 becomes invisible to the one command that must never miss it.
|
|
14
|
+
*
|
|
15
|
+
* **The fallback is the old behaviour, not an error.** A lease with no address is a `run` REPL or an
|
|
16
|
+
* embedded runtime — real states, serving no HTTP — and those are still stopped by signalling the
|
|
17
|
+
* process, which is what `stop` did for every lease before any of this existed.
|
|
18
|
+
*/
|
|
19
|
+
import { type LeaseRecord } from "@dispach/core";
|
|
20
|
+
/** An agent the sandbox holds, with the durable switch resolved. */
|
|
21
|
+
export interface HostableAgent {
|
|
22
|
+
readonly agentId: string;
|
|
23
|
+
readonly manifestPath: string;
|
|
24
|
+
readonly enabled: boolean;
|
|
25
|
+
/** Why it was switched off, when somebody said. */
|
|
26
|
+
readonly reason?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The manifests a bare `serve` should host, and the ones it should not.
|
|
30
|
+
*
|
|
31
|
+
* A listing rather than a filter, because the caller has to *report* what it is skipping: an agent
|
|
32
|
+
* missing from a banner with no line explaining it is the "I set this up and it is not running"
|
|
33
|
+
* failure the switch exists to make explicable.
|
|
34
|
+
*
|
|
35
|
+
* Broken entries are dropped here rather than surfaced, and that is the one thing this hides: a
|
|
36
|
+
* directory whose header will not parse has no id, so there is nothing to look the state up by and
|
|
37
|
+
* nothing to serve. the agents listing is what shows those, and it shows them already.
|
|
38
|
+
*/
|
|
39
|
+
export declare function hostableAgents(paths: readonly string[], env: Readonly<Record<string, string | undefined>>, store?: string): Promise<readonly HostableAgent[]>;
|
|
40
|
+
/** The durable switch, written from a command rather than through a host. */
|
|
41
|
+
export declare function writeAgentState(agentId: string, enabled: boolean, reason?: string, store?: string): Promise<void>;
|
|
42
|
+
/** Whether this agent is switched off, and why. */
|
|
43
|
+
export declare function agentStateOf(agentId: string, store?: string): Promise<{
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
reason?: string;
|
|
46
|
+
} | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* The live process serving this agent, if there is one.
|
|
49
|
+
*
|
|
50
|
+
* Liveness is re-checked here rather than trusted from the row, for the recorded reason: a boot
|
|
51
|
+
* that fails *after* claiming leaves a lease seconds old with no process under it, and anything
|
|
52
|
+
* reading a lease to decide what to do has to probe rather than believe the heartbeat.
|
|
53
|
+
*/
|
|
54
|
+
export declare function liveHostOf(agentId: string, store?: string): Promise<LeaseRecord | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Any live host with an HTTP address, for `start`.
|
|
57
|
+
*
|
|
58
|
+
* **Not `liveHostOf(agentId)`, and that is the whole reason this exists.** A stopped agent has no
|
|
59
|
+
* lease — `dispose` released it — so looking for "the host holding this agent" finds nothing and
|
|
60
|
+
* `start` would report that nothing was running while a host sat there ready to adopt it. Found by
|
|
61
|
+
* running the pair in order rather than by reading either one.
|
|
62
|
+
*
|
|
63
|
+
* With several hosts this asks the first by agent id. Nondeterministic and harmless: any host can
|
|
64
|
+
* serve any agent in the sandbox, and one that cannot look the manifest up answers `501` rather
|
|
65
|
+
* than failing quietly.
|
|
66
|
+
*/
|
|
67
|
+
export declare function anyLiveHost(store?: string): Promise<LeaseRecord | undefined>;
|
|
68
|
+
/** Every live lease, for the commands that report on the whole sandbox. */
|
|
69
|
+
export declare function liveHosts(store?: string): Promise<readonly LeaseRecord[]>;
|
|
70
|
+
/**
|
|
71
|
+
* The credential a running host will want, best effort.
|
|
72
|
+
*
|
|
73
|
+
* The manifest's live env is the authority — that is where `serve` itself read the token from — so
|
|
74
|
+
* this loads it. When the load fails it falls back to the process environment under the brand's
|
|
75
|
+
* default variable, because the common reason for a failed load is a missing *model* key and
|
|
76
|
+
* refusing to stop an agent over that would be absurd. A wrong or absent token is not silent: the
|
|
77
|
+
* request comes back `401` and the caller says which variable to set.
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* The agent id a manifest declares, without loading it.
|
|
81
|
+
*
|
|
82
|
+
* `readManifestHeader` rather than `loadManifest` for the reason `lib/sandbox.ts` already records:
|
|
83
|
+
* loading checks that the key variables are set, so a *lookup* built on it fails exactly when the
|
|
84
|
+
* agent is misconfigured — which is when you most need to name it. Here that would mean `run` and
|
|
85
|
+
* `web` refusing to find a host for an agent whose `.env` is incomplete.
|
|
86
|
+
*/
|
|
87
|
+
export declare function agentIdFor(manifestPath: string | undefined): string;
|
|
88
|
+
export declare function hostToken(manifestPath: string): string | undefined;
|
|
89
|
+
export interface HostReply {
|
|
90
|
+
readonly ok: boolean;
|
|
91
|
+
readonly status: number;
|
|
92
|
+
/** The server's own `error.message`, when it sent one. */
|
|
93
|
+
readonly detail?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The parsed success body, for the callers that need one.
|
|
96
|
+
*
|
|
97
|
+
* `stop` and `start` only ever asked whether it worked, so this was discarded. Minting a
|
|
98
|
+
* credential is the first caller that needs what came back — the secret is printed **once** and
|
|
99
|
+
* exists nowhere else, so throwing the body away would make the command useless.
|
|
100
|
+
*/
|
|
101
|
+
readonly body?: unknown;
|
|
102
|
+
/** The server's `error.hint`, which is the half a person acts on. */
|
|
103
|
+
readonly hint?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* POST to a running host, with a bounded wait.
|
|
107
|
+
*
|
|
108
|
+
* Bounded because the alternative is a stop command that hangs on a wedged host, and the whole
|
|
109
|
+
* brief for `stop` is that a person reaching for it is not in a position to go investigating. A
|
|
110
|
+
* timeout falls through to the process-level stop, which is the thing that works on a host that has
|
|
111
|
+
* stopped answering.
|
|
112
|
+
*/
|
|
113
|
+
export declare function postToHost(lease: LeaseRecord, path: string, body: Readonly<Record<string, unknown>>, manifestPath?: string): Promise<HostReply>;
|
|
114
|
+
/**
|
|
115
|
+
* Any method against a running host, with the same bound and the same error shape.
|
|
116
|
+
*
|
|
117
|
+
* `postToHost` is this with `POST` and a body; both exist because a `GET` with a `content-type` and
|
|
118
|
+
* an empty body is a request some proxies mangle, and because the one-method version read better at
|
|
119
|
+
* the four call sites that had it. This is what `credential list` and `credential revoke` need.
|
|
120
|
+
*/
|
|
121
|
+
export declare function callHost(lease: LeaseRecord, method: string, path: string, manifestPath?: string): Promise<HostReply>;
|
|
122
|
+
/** The sandbox manifest declaring this id, for the host's `resolveAgent` lookup. */
|
|
123
|
+
export declare function manifestForId(agentId: string, env?: Readonly<Record<string, string | undefined>>): string | undefined;
|
|
124
|
+
/** The directory an agent's manifest sits in, for messages that name a `.env`. */
|
|
125
|
+
export declare function agentDirOf(manifestPath: string): string;
|
|
126
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/lib/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAEH,KAAK,WAAW,EAKnB,MAAM,eAAe,CAAA;AAItB,oEAAoE;AACpE,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,mDAAmD;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAChC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACjD,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAuCnC;AAmCD,6EAA6E;AAC7E,wBAAsB,eAAe,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,mDAAmD;AACnD,wBAAsB,YAAY,CAC9B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CAM5D;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC5B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAOlC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGlF;AAED,2EAA2E;AAC3E,wBAAsB,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC,CAU/E;AAED;;;;;;;;GAQG;AACH;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAInE;AAED,wBAAgB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASlE;AAED,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC5B,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,SAAS,CAAC,CAuCpB;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC1B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,SAAS,CAAC,CA4BpB;AAKD,oFAAoF;AACpF,wBAAgB,aAAa,CACzB,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GACnD,MAAM,GAAG,SAAS,CAKpB;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Following a log file that something else is writing.
|
|
3
|
+
*
|
|
4
|
+
* `daemon logs --follow` printed a tail and then a hint telling you to run `tail -f` yourself, which is
|
|
5
|
+
* a flag documenting its own absence. Two things make the real implementation worth a module rather than
|
|
6
|
+
* a few lines inline.
|
|
7
|
+
*
|
|
8
|
+
* **A service log is truncated, not rotated.** `daemon logs --truncate` empties the file in place,
|
|
9
|
+
* because launchd holds the descriptor and deleting it leaves output flowing into a deleted inode — disk
|
|
10
|
+
* consumed, `ls` showing nothing. So a follower has to notice the file getting *shorter* and start again
|
|
11
|
+
* from the beginning; an offset carried blindly across a truncation reads garbage or, more often,
|
|
12
|
+
* silently nothing ever again.
|
|
13
|
+
*
|
|
14
|
+
* **The decision is arithmetic and the reading is not.** `nextRead` is a pure function over two numbers
|
|
15
|
+
* and holds everything worth asserting; `followLogs` is the loop, with its clock and its streams passed
|
|
16
|
+
* in so a test can drive it against a temp directory in milliseconds.
|
|
17
|
+
*
|
|
18
|
+
* Polled rather than watched. `fs.watch` on macOS reports appends by another process unreliably, and a
|
|
19
|
+
* follower that misses the line you are waiting for is worse than one that arrives 300 ms late — the
|
|
20
|
+
* whole reason somebody is watching a log is that they do not trust what they are being told.
|
|
21
|
+
*/
|
|
22
|
+
export interface ReadStep {
|
|
23
|
+
/** Byte offset to read from. */
|
|
24
|
+
readonly from: number;
|
|
25
|
+
/** Byte offset to read to. Equal to `from` when there is nothing new. */
|
|
26
|
+
readonly to: number;
|
|
27
|
+
/** The file got shorter, so this is a fresh start rather than a continuation. */
|
|
28
|
+
readonly truncated: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What to read next, given where we stopped and how big the file is now.
|
|
32
|
+
*
|
|
33
|
+
* A file that shrank was emptied under us: read it from the start and say so, because the alternative —
|
|
34
|
+
* carrying the old offset — means never printing another line and never explaining why.
|
|
35
|
+
*
|
|
36
|
+
* The blind spot, stated rather than wished away: a rewrite to *exactly* the same byte count reads as
|
|
37
|
+
* "nothing new", because size is the only signal. Every size-based follower has this, `tail -f`
|
|
38
|
+
* included, and the case that actually happens is caught — `--truncate` writes an empty file, and zero
|
|
39
|
+
* is shorter than anything. A test asserts the blind spot so nobody discovers it as a mystery.
|
|
40
|
+
*/
|
|
41
|
+
export declare function nextRead(offset: number, size: number): ReadStep;
|
|
42
|
+
export interface FollowSource {
|
|
43
|
+
readonly path: string;
|
|
44
|
+
/** Printed above a chunk when the source changes — `stderr`, `stdout`. */
|
|
45
|
+
readonly label: string;
|
|
46
|
+
}
|
|
47
|
+
export interface FollowIO {
|
|
48
|
+
/** Bytes currently in the file, or `undefined` if it does not exist yet. */
|
|
49
|
+
sizeOf(path: string): number | undefined;
|
|
50
|
+
read(path: string, from: number, to: number): string;
|
|
51
|
+
write(text: string): void;
|
|
52
|
+
/** Resolves after `ms`, or immediately once the follow has been asked to stop. */
|
|
53
|
+
wait(ms: number): Promise<void>;
|
|
54
|
+
/** Checked between polls. The caller owns whatever sets it — a signal, a keypress, a test. */
|
|
55
|
+
stopped(): boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Follow every source until asked to stop.
|
|
59
|
+
*
|
|
60
|
+
* Starting offsets come from the caller, which is what lets `daemon logs` print its tail with the
|
|
61
|
+
* existing code and then continue from exactly where that ended — rather than reprinting it, or skipping
|
|
62
|
+
* whatever arrived between the two.
|
|
63
|
+
*
|
|
64
|
+
* A label is printed only when the source changes. Following one file is the common case and a banner on
|
|
65
|
+
* every chunk of it is noise; following two, the switch is the only thing that needs saying.
|
|
66
|
+
*/
|
|
67
|
+
export declare function followLogs(sources: readonly FollowSource[], io: FollowIO, options: {
|
|
68
|
+
readonly offsets: Readonly<Record<string, number>>;
|
|
69
|
+
readonly intervalMs: number;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
//# sourceMappingURL=log-follow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-follow.d.ts","sourceRoot":"","sources":["../../src/lib/log-follow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,QAAQ;IACrB,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC9B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAG/D;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,QAAQ;IACrB,4EAA4E;IAC5E,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACxC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACpD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,kFAAkF;IAClF,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,8FAA8F;IAC9F,OAAO,IAAI,OAAO,CAAA;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC5B,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC7F,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wheel scrolling on the alternate screen. Pure, so a mouse report is arithmetic rather than a guess.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this needs a guard rather than only a parser
|
|
5
|
+
*
|
|
6
|
+
* Ink does not know about mouse reports. Measured against a real pty with tracking on: a wheel notch
|
|
7
|
+
* arrived as the literal text `ESC[<64;10;5M`, fell through the keymap to the insert branch, and was typed
|
|
8
|
+
* into the message — twice, because two notches are two reports. So recognising a report is not an
|
|
9
|
+
* optimisation here; every report a terminal can send has to be claimed, wheel and click alike, or the
|
|
10
|
+
* feature's cost is garbage in somebody's message.
|
|
11
|
+
*
|
|
12
|
+
* A chunk can carry several reports. A fast scroll sends one per notch and the runtime coalesces them, so
|
|
13
|
+
* the count matters: honouring one report per chunk makes a flick of the wheel move a single row and reads
|
|
14
|
+
* as the wheel not working.
|
|
15
|
+
*
|
|
16
|
+
* ## The trade this makes, stated
|
|
17
|
+
*
|
|
18
|
+
* Tracking is what stops the terminal handling the mouse itself, so **drag-selecting text with the mouse
|
|
19
|
+
* stops working while a session is mounted**. Every terminal worth naming lets you hold shift to bypass
|
|
20
|
+
* tracking and select natively, which is why the key list says so rather than leaving it to be discovered.
|
|
21
|
+
*
|
|
22
|
+
* Two encodings are recognised. SGR (`ESC [ < b ; x ; y M`) is what we ask for and what any terminal from
|
|
23
|
+
* the last decade replies with; X10 (`ESC [ M` and three raw bytes) is the fallback a terminal that ignored
|
|
24
|
+
* the SGR request will use, and its bytes are frequently above 127 — so leaving it unclaimed would put
|
|
25
|
+
* unprintable characters into a message on exactly the terminals least able to say why.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Button tracking, drag tracking, and SGR encoding.
|
|
29
|
+
*
|
|
30
|
+
* 1000 reports press and release and is the least that reports the wheel at all. **1002 adds motion while a
|
|
31
|
+
* button is held**, and without it a drag is not reported — which is why selecting text was not merely
|
|
32
|
+
* disabled but unreachable: the events never arrived. 1003 (motion with no button) is deliberately absent,
|
|
33
|
+
* because it makes the terminal send a report for every pixel of idle pointer movement and nothing here
|
|
34
|
+
* wants hover.
|
|
35
|
+
*
|
|
36
|
+
* Set low-to-high and reset high-to-low, so a terminal that only understands some of them is left in a
|
|
37
|
+
* state we asked for rather than a partial one.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ENABLE_MOUSE = "\u001B[?1000h\u001B[?1002h\u001B[?1006h";
|
|
40
|
+
/** Reversed on the way out, so a terminal is left handling its own mouse again. */
|
|
41
|
+
export declare const DISABLE_MOUSE = "\u001B[?1006l\u001B[?1002l\u001B[?1000l";
|
|
42
|
+
/**
|
|
43
|
+
* Rows one notch of the wheel moves.
|
|
44
|
+
*
|
|
45
|
+
* Three, which is the line-scroll every desktop uses. One row per notch is technically a scroll and feels
|
|
46
|
+
* like the wheel is broken; a whole page per notch overshoots what somebody is looking for.
|
|
47
|
+
*/
|
|
48
|
+
export declare const WHEEL_ROWS = 3;
|
|
49
|
+
/** Which gesture a report describes. */
|
|
50
|
+
export type MouseKind = "wheel" | "press" | "drag" | "release";
|
|
51
|
+
/** Where a report happened, in **zero-based** screen cells. */
|
|
52
|
+
export interface MousePoint {
|
|
53
|
+
readonly column: number;
|
|
54
|
+
readonly row: number;
|
|
55
|
+
}
|
|
56
|
+
export interface MouseInput {
|
|
57
|
+
/**
|
|
58
|
+
* Rows to move: negative up, positive down, zero for a report that is not the wheel.
|
|
59
|
+
*
|
|
60
|
+
* Zero is *not* "no report" — a click is a report with no scroll in it, and it still has to be
|
|
61
|
+
* swallowed. The `undefined` return is what means "no report".
|
|
62
|
+
*/
|
|
63
|
+
readonly rows: number;
|
|
64
|
+
/**
|
|
65
|
+
* The last gesture in the chunk, and where it happened. `undefined` when nothing positional was in it.
|
|
66
|
+
*
|
|
67
|
+
* The *last* rather than every one, because a drag arrives as a stream of motion reports and only the
|
|
68
|
+
* newest position matters — a selection follows the pointer, it does not retrace it. The wheel is the
|
|
69
|
+
* exception and is summed instead, which is why `rows` is separate: a flick coalesces several notches
|
|
70
|
+
* into one chunk and honouring only the last would move a single row.
|
|
71
|
+
*/
|
|
72
|
+
readonly at?: MousePoint;
|
|
73
|
+
readonly kind?: MouseKind;
|
|
74
|
+
/** Held modifiers, from SGR's button bits. Shift is what extends a selection from a click. */
|
|
75
|
+
readonly shift?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* What a chunk of input means to the mouse, or `undefined` if it holds no mouse report at all.
|
|
79
|
+
*
|
|
80
|
+
* Returning `undefined` rather than a zero is what keeps a keystroke a keystroke: every other branch of
|
|
81
|
+
* the keymap runs only when this says nothing.
|
|
82
|
+
*/
|
|
83
|
+
export declare function mouseInput(input: string): MouseInput | undefined;
|
|
84
|
+
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouse.d.ts","sourceRoot":"","sources":["../../src/lib/mouse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,4CAA4C,CAAA;AACrE,mFAAmF;AACnF,eAAO,MAAM,aAAa,4CAA4C,CAAA;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,IAAI,CAAA;AA4B3B,wCAAwC;AACxC,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAE9D,+DAA+D;AAC/D,MAAM,WAAW,UAAU;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,UAAU;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,UAAU,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;IACzB,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CA2ChE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The multi-select reducer: move a cursor, toggle rows, read back what was chosen.
|
|
3
|
+
*
|
|
4
|
+
* Pure, and PURE-listed for the same reason `select.ts` is — one `useInput` per screen root over a pure
|
|
5
|
+
* keymap and a pure reducer, so the behaviour is unit-testable without mounting Ink and the component
|
|
6
|
+
* cannot grow a second copy of the rules.
|
|
7
|
+
*
|
|
8
|
+
* `chosen` is a sorted index array rather than a `Set`, and that is deliberate: it makes the state
|
|
9
|
+
* structurally comparable in a test (`toEqual`), keeps React's identity checks honest, and fixes the
|
|
10
|
+
* install order to the order shown on screen — which is what somebody expects after ticking four boxes
|
|
11
|
+
* top to bottom.
|
|
12
|
+
*
|
|
13
|
+
* Rows that are group headings are not selectable, so `count` alone is not enough: the reducer needs to
|
|
14
|
+
* know which indices are real. `selectable` is passed in rather than derived, because the same reducer
|
|
15
|
+
* serves a flat list (every row selectable) and a grouped one.
|
|
16
|
+
*/
|
|
17
|
+
import { type SelectMove, type SelectState } from "#lib/select";
|
|
18
|
+
export interface MultiSelectState {
|
|
19
|
+
readonly cursor: SelectState;
|
|
20
|
+
/** Indices into the full row list, ascending. */
|
|
21
|
+
readonly chosen: readonly number[];
|
|
22
|
+
}
|
|
23
|
+
export type MultiSelectAction = {
|
|
24
|
+
readonly kind: "move";
|
|
25
|
+
readonly move: SelectMove;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: "toggle";
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: "all";
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "none";
|
|
32
|
+
};
|
|
33
|
+
export declare function startMultiSelect(count: number): MultiSelectState;
|
|
34
|
+
export declare function reduceMultiSelect(state: MultiSelectState, action: MultiSelectAction, selectable: readonly boolean[]): MultiSelectState;
|
|
35
|
+
/** Where the cursor should start: the first selectable row, never a heading. */
|
|
36
|
+
export declare function firstSelectable(selectable: readonly boolean[]): number;
|
|
37
|
+
//# sourceMappingURL=multiselect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiselect.d.ts","sourceRoot":"","sources":["../../src/lib/multiselect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAc,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAE3E,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CACrC;AAED,MAAM,MAAM,iBAAiB,GACvB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/B,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAEhE;AAwDD,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,SAAS,OAAO,EAAE,GAC/B,gBAAgB,CA8BlB;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,UAAU,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAGtE"}
|