@leemour/cli-messaging 0.89.0 → 0.91.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 +1 -1
- package/dist/background/units.d.ts +7 -0
- package/dist/background/units.d.ts.map +1 -1
- package/dist/background/units.js +3 -2
- package/dist/background/units.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/messenger/archive-commands.d.ts.map +1 -1
- package/dist/cli/messenger/archive-commands.js +29 -1
- package/dist/cli/messenger/archive-commands.js.map +1 -1
- package/dist/cli/messenger/server-command.d.ts +37 -6
- package/dist/cli/messenger/server-command.d.ts.map +1 -1
- package/dist/cli/messenger/server-command.js +100 -59
- package/dist/cli/messenger/server-command.js.map +1 -1
- package/dist/cli/messenger/stored.d.ts.map +1 -1
- package/dist/cli/messenger/stored.js +7 -1
- package/dist/cli/messenger/stored.js.map +1 -1
- package/dist/mcp/tools/messages-actions.js +2 -2
- package/dist/mcp/tools/messages-actions.js.map +1 -1
- package/dist/services/archive.d.ts +7 -0
- package/dist/services/archive.d.ts.map +1 -1
- package/dist/services/archive.js +1 -0
- package/dist/services/archive.js.map +1 -1
- package/dist/store/sqlite/chats.d.ts +9 -0
- package/dist/store/sqlite/chats.d.ts.map +1 -1
- package/dist/store/sqlite/chats.js +42 -5
- package/dist/store/sqlite/chats.js.map +1 -1
- package/dist/store/store.d.ts +12 -0
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +16 -0
- package/dist/store/store.js.map +1 -1
- package/package.json +1 -1
- package/parity.json +21 -4
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ provider has travels in `providerMetadata`.
|
|
|
20
20
|
| `.` | `Chat`, `Message`, `Contact`, `Page`… · `formatLocator` / `parseLocator` · `renderMessages` · `pickChat` / `pickPerson` |
|
|
21
21
|
| `./store` | `openCache` — `node:sqlite` under Node, `bun:sqlite` under Bun, WAL and a busy timeout on both · `openStore` — the shared message store, every method async: one file for every messenger (`MESSAGING_STORE` overrides where), forward-only migrations with `min_compatible`, every sender an identity with a person of their own, edits kept as revisions, a message by its id, deletions kept as tombstones, trigram search · `find` — by text, by sender, or both; `together` for the chats where every sender wrote, `perChat` to cap each chat · `savePeople` and `people` — usernames and bot flags, and a `PeopleLookup` for `pickPerson` |
|
|
22
22
|
| `./sends` | the send guard: a level per command path (`permissions`: deny, readonly, ask, allow — `readOnly` and `allow` read as levels), a recipient list, an hourly limit, and a journal of every attempt that never holds the text; `newSendId` for a send's identity across retries |
|
|
23
|
-
| `./cli` | the command skeleton: `run` (never throws, returns an exit code), the global flags, `settingsFor` (flag → environment → file → default, one strict file schema with each CLI's own fields), the profile as the first word, `--timeout` that closes what a command holds, paging, and run records: `--record` keeps a run's ids and timings (never content), a failure is kept unless `--no-record`, and `runsCommand` gives `runs list\|show\|path` · `configCommand(app, config)` shows and changes the settings with where each came from · `completeCommand(messenger, config)` gives shell completion, chat ids from the store and never a connection · `doctorCommand(messenger)` reports the installation's state from disk (the store, the account, sends, runs, the messenger's own checks), and connects only with `--online`; `doctor report create` writes that, the failed run and the recent sends to a file with every id a label · `skillCommand(app, url)` prints the CLI's own SKILL.md for an agent (`skill show`) · `commandsCommand(app)` describes every command as JSON, with `contract` (`CONTRACT`, the major version of the output types) and which commands write · the shared read commands: a CLI describes its messenger once (`Messenger`: its app, a `connect` that returns a `MessengerAdapter`, how `me` maps to a chat) and gets `accountCommand`, `chatsCommand` (`list`, `show`), `contactsCommand` (`list`, `show`) `recipientsCommand`, `sendsCommand`, `watchCommand` (new messages as they arrive, `--jsonl`, until Ctrl-C or `--timeout`; `--events` adds edits, deletions and reactions, each kept in the store), `storeCommand` (the local store: `store fetch` puts a chat's history into it, resumable, FloodWait-aware, `--since` to stop at a time, `--background` for a detached job that `store jobs list|show|cancel` follow, `--estimate` to only price what is left from the store alone; `store status` what it holds; `store export` a chat's messages out of it, as JSON or `--format markdown`; `store info`, `store check`, `store migrate`, `store backup` and `store restore` look after the file itself — its size and schema, whether it is healthy and which chats are behind, bringing it up to this build, and a copy to go back to), `inboxCommand` (other people's unread messages in every chat, or with `--new` what arrived since the last check — each message once, the point moved only by a run that printed; copied from max-cli), `serveCommand` (keeps the store current until stopped — one per profile by a lock file, catch-up on, started by a person, `server start` or a unit), `serverCommand` (`server start|stop|restart|status|logs`: `serve` in the background, as max-cli's `server`; `install|uninstall` add a systemd user unit or a launchd agent per profile, and `install` starts nothing), and `messagesCommand` (`list`, `show`, `context`, `search` over the store by any three letters inside a word, or `--regex`, `send` through the send guard (`--reply-to`, `--silent`, `--no-preview`, `--md`, `--file` and `--photo` with the text as the caption, and `--at` to send later, with `scheduled` listing the queue), `edit` of the owner's own message, `forward` to another chat and `pin`/`unpin` through it too (the adapter's optional `edit`, `forward`, `pin` and `unpin`), and `delete` — at most 10, for the owner unless `--for-everyone`; it asks first by default, and `--allow-dangerous` is the yes · `reactionsCommand` (`add`, `remove`: the owner's reaction on a message, through the guard; the adapter's optional `react`) · `pollsCommand` (`show` a poll with its answer ids, `vote` by id or `--retract`, `close` the owner's own, `create` one — a vote guarded as a reaction, closing as an edit, a new poll as a message with a send id); a `msg:` locator names a message) — every read saved to the store, `--offline` answered from it, each call a run event · `mcpCommand(messenger)` serves the profile to an agent over MCP on stdin and stdout (copied from max-cli: one connection held for minutes, one call at a time, read tools named `<cli>_<command words>` answering what `--json` prints, `<cli>_status` without connecting; the write tools — `<cli>_messages_send`, `_edit`, `_forward`, `_pin`, `_unpin`, `_delete`, `<cli>_reactions_add`, `_remove`, `<cli>_chats_mark_read`, `<cli>_polls_vote`, `_close` and `_create` — are offered by the profile's `permissions` and run through the same guard as their commands; a write at level `ask` shows the owner a form first (`--allow-dangerous` or `--yes` skips it), `--confirm-send` puts every write through the form, and `messages_delete` never deletes for everyone), and `mcp config` prints the entry for a desktop client |
|
|
23
|
+
| `./cli` | the command skeleton: `run` (never throws, returns an exit code), the global flags, `settingsFor` (flag → environment → file → default, one strict file schema with each CLI's own fields), the profile as the first word, `--timeout` that closes what a command holds, paging, and run records: `--record` keeps a run's ids and timings (never content), a failure is kept unless `--no-record`, and `runsCommand` gives `runs list\|show\|path` · `configCommand(app, config)` shows and changes the settings with where each came from · `completeCommand(messenger, config)` gives shell completion, chat ids from the store and never a connection · `doctorCommand(messenger)` reports the installation's state from disk (the store, the account, sends, runs, the messenger's own checks), and connects only with `--online`; `doctor report create` writes that, the failed run and the recent sends to a file with every id a label · `skillCommand(app, url)` prints the CLI's own SKILL.md for an agent (`skill show`) · `commandsCommand(app)` describes every command as JSON, with `contract` (`CONTRACT`, the major version of the output types) and which commands write · the shared read commands: a CLI describes its messenger once (`Messenger`: its app, a `connect` that returns a `MessengerAdapter`, how `me` maps to a chat) and gets `accountCommand`, `chatsCommand` (`list`, `show`), `contactsCommand` (`list`, `show`) `recipientsCommand`, `sendsCommand`, `watchCommand` (new messages as they arrive, `--jsonl`, until Ctrl-C or `--timeout`; `--events` adds edits, deletions and reactions, each kept in the store), `storeCommand` (the local store: `store fetch` puts a chat's history into it, resumable, FloodWait-aware, `--since` to stop at a time, `--background` for a detached job that `store jobs list|show|cancel` follow, `--estimate` to only price what is left from the store alone; `store status` what it holds; `store export` a chat's messages out of it, as JSON or `--format markdown`; `store clear --left` deletes the chats the account has left; `store info`, `store check`, `store migrate`, `store backup` and `store restore` look after the file itself — its size and schema, whether it is healthy and which chats are behind, bringing it up to this build, and a copy to go back to), `inboxCommand` (other people's unread messages in every chat, or with `--new` what arrived since the last check — each message once, the point moved only by a run that printed; copied from max-cli), `serveCommand` (keeps the store current until stopped — one per profile by a lock file, catch-up on, started by a person, `server start` or a unit), `serverCommand` (`server start|stop|restart|status|logs`: `serve` in the background, as max-cli's `server`; `install|uninstall` add a systemd user unit or a launchd agent per profile, and `install` starts nothing), and `messagesCommand` (`list`, `show`, `context`, `search` over the store by any three letters inside a word, or `--regex`, `send` through the send guard (`--reply-to`, `--silent`, `--no-preview`, `--md`, `--file` and `--photo` with the text as the caption, and `--at` to send later, with `scheduled` listing the queue), `edit` of the owner's own message, `forward` to another chat and `pin`/`unpin` through it too (the adapter's optional `edit`, `forward`, `pin` and `unpin`), and `delete` — at most 10, for the owner unless `--for-everyone`; it asks first by default, and `--allow-dangerous` is the yes · `reactionsCommand` (`add`, `remove`: the owner's reaction on a message, through the guard; the adapter's optional `react`) · `pollsCommand` (`show` a poll with its answer ids, `vote` by id or `--retract`, `close` the owner's own, `create` one — a vote guarded as a reaction, closing as an edit, a new poll as a message with a send id); a `msg:` locator names a message) — every read saved to the store, `--offline` answered from it, each call a run event · `mcpCommand(messenger)` serves the profile to an agent over MCP on stdin and stdout (copied from max-cli: one connection held for minutes, one call at a time, read tools named `<cli>_<command words>` answering what `--json` prints, `<cli>_status` without connecting; the write tools — `<cli>_messages_send`, `_edit`, `_forward`, `_pin`, `_unpin`, `_delete`, `<cli>_reactions_add`, `_remove`, `<cli>_chats_mark_read`, `<cli>_polls_vote`, `_close` and `_create` — are offered by the profile's `permissions` and run through the same guard as their commands; a write at level `ask` shows the owner a form first (`--allow-dangerous` or `--yes` skips it), `--confirm-send` puts every write through the form, and `messages_delete` never deletes for everyone), and `mcp config` prints the entry for a desktop client |
|
|
24
24
|
|
|
25
25
|
⚠ **Errors are recognised by shape, not by class** (`isCliFailure`). A package linked during
|
|
26
26
|
development brings its own copy of cli-core, and an error built by one copy is not an `instanceof`
|
|
@@ -9,6 +9,13 @@ export interface Unit {
|
|
|
9
9
|
/** What the unit runs, and the variables it runs with. */
|
|
10
10
|
command: string[];
|
|
11
11
|
environment: Record<string, string>;
|
|
12
|
+
/** What the server does, for `systemctl status` and the agent list. */
|
|
13
|
+
purpose?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Exit codes that must not start it again — a refused login retried every 30 s is a login per
|
|
16
|
+
* retry. launchd cannot leave out single codes, so with any of these its agent does not restart.
|
|
17
|
+
*/
|
|
18
|
+
noRestartOn?: number[];
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Only the variables that say **where** the files are travel into the unit: a unit written from a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/background/units.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../src/background/units.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAS,WAAW,OAAO,MAAM,CAAC,UAAU,KAAG,MAAM,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AW,QAAS,WAAW,UAAU,YAAY,OAAO,MAAM,CAAC,UAAU,KAAG,QAI5F,CAAA"}
|
package/dist/background/units.js
CHANGED
|
@@ -39,13 +39,14 @@ export const systemd = (app, system, env) => {
|
|
|
39
39
|
},
|
|
40
40
|
text: (unit) => [
|
|
41
41
|
"[Unit]",
|
|
42
|
-
`Description=${app.command} serve — keep the local message archive current (profile ${unit.profile})`,
|
|
42
|
+
`Description=${app.command} serve — ${unit.purpose ?? "keep the local message archive current"} (profile ${unit.profile})`,
|
|
43
43
|
"",
|
|
44
44
|
"[Service]",
|
|
45
45
|
`ExecStart=${unit.command.map((word) => systemdQuote(word, { command: true })).join(" ")}`,
|
|
46
46
|
...Object.entries(unit.environment).map(([name, value]) => `Environment=${systemdQuote(`${name}=${value}`)}`),
|
|
47
47
|
"Restart=on-failure",
|
|
48
48
|
"RestartSec=30",
|
|
49
|
+
...(unit.noRestartOn?.length ? [`RestartPreventExitStatus=${unit.noRestartOn.join(" ")}`] : []),
|
|
49
50
|
"",
|
|
50
51
|
"[Install]",
|
|
51
52
|
"WantedBy=default.target",
|
|
@@ -113,7 +114,7 @@ export const launchd = (app, system, env) => {
|
|
|
113
114
|
// launchd loads every agent here at login; disabled, it waits for `server start` to enable it.
|
|
114
115
|
" <key>Disabled</key><true/>",
|
|
115
116
|
" <key>RunAtLoad</key><true/>",
|
|
116
|
-
" <key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>",
|
|
117
|
+
...(unit.noRestartOn?.length ? [] : [" <key>KeepAlive</key><dict><key>SuccessfulExit</key><false/></dict>"]),
|
|
117
118
|
" <key>ThrottleInterval</key><integer>30</integer>",
|
|
118
119
|
` <key>StandardOutPath</key><string>${xml(unit.logPath ?? "")}</string>`,
|
|
119
120
|
` <key>StandardErrorPath</key><string>${xml(unit.logPath ?? "")}</string>`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/background/units.ts"],"names":[],"mappings":"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AO,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;IACjE,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;IAClE,OAAO,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AAC7B,CAAC,CAAA"}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type { AccountTools, After, ChatReading, Download, GroupModeration, LiveU
|
|
|
35
35
|
export { reactionsCommand } from "./messenger/reactions-command.js";
|
|
36
36
|
export { reviewCommand } from "./messenger/review.js";
|
|
37
37
|
export { serveCommand, servingProfiles } from "./messenger/serve-command.js";
|
|
38
|
-
export { type ServerSystem, serverCommand } from "./messenger/server-command.js";
|
|
38
|
+
export { type Running, type ServerOptions, type ServerProcess, type ServerSystem, serverCommand, } from "./messenger/server-command.js";
|
|
39
39
|
export { topicsCommand } from "./messenger/topics-command.js";
|
|
40
40
|
export { watchCommand } from "./messenger/watch-command.js";
|
|
41
41
|
export { listed, renderList, renderPage, window, withPaging } from "./paging.js";
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,KAAK,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACpD,YAAY,EAAE,UAAU,EAAE,YAA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,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/cli/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export { pollsCommand } from "./messenger/polls-command.js";
|
|
|
33
33
|
export { reactionsCommand } from "./messenger/reactions-command.js";
|
|
34
34
|
export { reviewCommand } from "./messenger/review.js";
|
|
35
35
|
export { serveCommand, servingProfiles } from "./messenger/serve-command.js";
|
|
36
|
-
export { serverCommand } from "./messenger/server-command.js";
|
|
36
|
+
export { serverCommand, } from "./messenger/server-command.js";
|
|
37
37
|
export { topicsCommand } from "./messenger/topics-command.js";
|
|
38
38
|
export { watchCommand } from "./messenger/watch-command.js";
|
|
39
39
|
export { listed, renderList, renderPage, window, withPaging } from "./paging.js";
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAoB,OAAO,EAAE,MAAM,UAAU,CAAA;AAEpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAiB,MAAM,mBAAmB,CAAA;AAC1G,OAAO,EAAE,aAAa,EAA6B,MAAM,gBAAgB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAGL,WAAW,EACX,aAAa,EACb,SAAS,EACT,OAAO,GACR,M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,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,iBAAiB,GAClB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAgE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC/G,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAIL,gBAAgB,EAEhB,WAAW,GAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAGL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EAGR,aAAa,EACb,KAAK,EAKL,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/archive-commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,cAAc,CAAA;AAG/D,oHAAoH;AACpH,eAAO,MAAM,YAAY,cAAe,SAAS,KAAG,
|
|
1
|
+
{"version":3,"file":"archive-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/archive-commands.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,cAAc,CAAA;AAG/D,oHAAoH;AACpH,eAAO,MAAM,YAAY,cAAe,SAAS,KAAG,OAUnD,CAAA"}
|
|
@@ -16,7 +16,8 @@ export const storeCommand = (messenger) => {
|
|
|
16
16
|
.addCommand(statusCommand(messenger))
|
|
17
17
|
.addCommand(fetchCommand(messenger))
|
|
18
18
|
.addCommand(jobsCommand(messenger))
|
|
19
|
-
.addCommand(exportCommand(messenger))
|
|
19
|
+
.addCommand(exportCommand(messenger))
|
|
20
|
+
.addCommand(clearCommand(messenger));
|
|
20
21
|
for (const command of storeMaintenanceCommands(messenger))
|
|
21
22
|
store.addCommand(command);
|
|
22
23
|
return store;
|
|
@@ -35,6 +36,33 @@ const statusCommand = (messenger) => new Command("status")
|
|
|
35
36
|
if (rows.length === 0)
|
|
36
37
|
context.renderer.note("the store holds no messages for this profile yet");
|
|
37
38
|
});
|
|
39
|
+
/**
|
|
40
|
+
* Deletes from the store, which is the archive: only what `--left` names, and only with
|
|
41
|
+
* `--allow-dangerous`, since a chat the account left cannot be fetched again. Emptying the whole
|
|
42
|
+
* store is not offered.
|
|
43
|
+
*/
|
|
44
|
+
const clearCommand = (messenger) => new Command("clear")
|
|
45
|
+
.description("delete from the store the chats this account has left, with their messages")
|
|
46
|
+
.option("--left", "the chats this account has left — the only thing this clears")
|
|
47
|
+
.option("--allow-dangerous", "yes, delete — it cannot be undone, and a chat you left cannot be fetched again")
|
|
48
|
+
.action(async function () {
|
|
49
|
+
const { left, allowDangerous } = this.opts();
|
|
50
|
+
if (!left) {
|
|
51
|
+
throw new CliError("validation_error", "say what to clear: --left, the chats this account has left — emptying the whole store is not offered");
|
|
52
|
+
}
|
|
53
|
+
const context = messengerContext(this, messenger);
|
|
54
|
+
const found = await context.withServices((services) => services.archive.left());
|
|
55
|
+
if (found.chats > 0 && !allowDangerous) {
|
|
56
|
+
throw new CliError("confirmation_required", `this deletes ${found.chats} chat(s) this account has left and their ${found.messages} message(s) ` +
|
|
57
|
+
"from the store, and it cannot be undone — add --allow-dangerous to go ahead");
|
|
58
|
+
}
|
|
59
|
+
const cleared = found.chats > 0 ? await context.withServices((services) => services.archive.left({ clear: true })) : found;
|
|
60
|
+
context.renderer.result({ cleared: cleared.chats > 0, ...cleared });
|
|
61
|
+
if (cleared.chats === 0)
|
|
62
|
+
context.renderer.note("the store holds no chats this account has left");
|
|
63
|
+
else
|
|
64
|
+
context.renderer.success(`deleted ${cleared.chats} chat(s) and ${cleared.messages} message(s)`);
|
|
65
|
+
});
|
|
38
66
|
/**
|
|
39
67
|
* One chat's stored messages, oldest first — `--jsonl` for a file or a pipe, one message per line,
|
|
40
68
|
* `--format markdown` for a transcript a person reads.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive-commands.js","sourceRoot":"","sources":["../../../src/cli/messenger/archive-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAkB,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAA;AAEzE,oHAAoH;AACpH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAoB,EAAW,EAAE;IAC5D,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;SAC/B,WA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AAO,CAAC,KAAK;YACpB,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;YAClC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY;YAC3C,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,QAAQ,EAAE,SAAS,CAAC,QAAQ;YAC5B,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM;SAC7B,CAAC,CACH,CAAA;IACH,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,WAAW,CAAC,CAAA;AACtD,CAAC,CAAC,CAAA"}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { type
|
|
2
|
+
import { type ServerSystem } from "../../background/system.js";
|
|
3
|
+
import { type Unit } from "../../background/units.js";
|
|
4
|
+
import { type Messenger, type MessengerContext } from "./context.js";
|
|
3
5
|
export type { Ran, ServerSystem } from "../../background/system.js";
|
|
6
|
+
/** A running server, as its CLI can tell. */
|
|
7
|
+
export interface Running {
|
|
8
|
+
pid: number;
|
|
9
|
+
startedAt: string;
|
|
10
|
+
connected: boolean;
|
|
11
|
+
connectedAt?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
/** The server says a command that needed it started it (max); `start` takes its place. */
|
|
14
|
+
byCommand?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** How a CLI finds, starts and stops its server. Without one, `server` uses tg's: the lock file and a signal. */
|
|
17
|
+
export interface ServerProcess {
|
|
18
|
+
probe: () => Promise<Running | undefined>;
|
|
19
|
+
/** Starts `serve` apart from this process with `args` and the variables in `env` added; its PID. Throws when it cannot start now. */
|
|
20
|
+
launch: (args: string[], env: Record<string, string>) => number;
|
|
21
|
+
/** Asks it to stop; `server` then waits for its PID to be gone. */
|
|
22
|
+
stop: (running: Running) => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export interface ServerOptions {
|
|
25
|
+
process?: (context: MessengerContext, system: ServerSystem, logPath: string) => ServerProcess;
|
|
26
|
+
/** Where a server started without a unit writes its log. tg's: `<state>/serve/<profile>.log`. */
|
|
27
|
+
logPath?: (context: MessengerContext) => string;
|
|
28
|
+
/** The words after the CLI's own entry that run `serve` in the foreground — what a unit runs. */
|
|
29
|
+
serveArgv?: string[];
|
|
30
|
+
/** `start` and `restart` take `--idle <duration>` and hand it to `serve`. */
|
|
31
|
+
idle?: boolean;
|
|
32
|
+
unit?: Pick<Unit, "purpose" | "noRestartOn">;
|
|
33
|
+
}
|
|
4
34
|
/**
|
|
5
|
-
* `serve` in the background
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
35
|
+
* `serve` in the background: `start`, `stop`, `restart`, `status`, `logs`. Without a unit, `start`
|
|
36
|
+
* runs `serve` as a process of its own; with one — `install`, a systemd user unit or a launchd
|
|
37
|
+
* agent — it goes through systemd or launchd. **Nothing starts until `start` is typed** (NEED-9):
|
|
38
|
+
* `install` only writes the file. What the server does stays each CLI's; `options.process` says how
|
|
39
|
+
* to find, start and stop it.
|
|
9
40
|
*/
|
|
10
|
-
export declare const serverCommand: (messenger: Messenger) => Command;
|
|
41
|
+
export declare const serverCommand: (messenger: Messenger, options?: ServerOptions) => Command;
|
|
11
42
|
//# sourceMappingURL=server-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-command.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/server-command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"server-command.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/server-command.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAwC,KAAK,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAK3F,OAAO,EAAE,KAAK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@ -8,6 +8,7 @@ import { thisMachine } from "../../background/system.js";
|
|
|
8
8
|
import { locationVariables, platformFor, tail } from "../../background/units.js";
|
|
9
9
|
import { environmentOf } from "../context.js";
|
|
10
10
|
import { listed } from "../paging.js";
|
|
11
|
+
import { parseDuration } from "../settings.js";
|
|
11
12
|
import { messengerContext } from "./context.js";
|
|
12
13
|
/** How many looks, a pause apart, `start` gives `serve` to connect — about 30 seconds on a real machine. */
|
|
13
14
|
const LOOKS = 120;
|
|
@@ -19,27 +20,57 @@ const clock = (iso) => {
|
|
|
19
20
|
const time = when.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
|
|
20
21
|
return when.toDateString() === new Date().toDateString() ? time : `${when.toLocaleDateString("sv-SE")} ${time}`;
|
|
21
22
|
};
|
|
23
|
+
const lockProcess = (app, marker, serveArgv) => (context, system, logPath) => ({
|
|
24
|
+
probe: async () => {
|
|
25
|
+
const held = readLock(lockPath(app, context.profile, context.env));
|
|
26
|
+
if (!held || !alive(held.pid))
|
|
27
|
+
return undefined;
|
|
28
|
+
return {
|
|
29
|
+
pid: held.pid,
|
|
30
|
+
startedAt: held.startedAt,
|
|
31
|
+
connected: held.listeningAt !== undefined,
|
|
32
|
+
...(held.listeningAt ? { connectedAt: held.listeningAt } : {}),
|
|
33
|
+
...(held.version ? { version: held.version } : {}),
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
launch: (args, env) => {
|
|
37
|
+
// A shell's --timeout default would end a server meant to outlive the shell.
|
|
38
|
+
const { [`${app.envPrefix}_TIMEOUT`]: _timeout, ...inherited } = context.env;
|
|
39
|
+
return system.spawn([...serveArgv, ...args], { ...inherited, [`${app.envPrefix}_PROFILE`]: context.profile, ...env }, logPath);
|
|
40
|
+
},
|
|
41
|
+
stop: async ({ pid }) => {
|
|
42
|
+
if (!carries(pid, marker)) {
|
|
43
|
+
throw new CliError("validation_error", `serve for profile ${context.profile} (PID ${pid}) was not started by \`${app.command} server start\` — stop it where it runs`);
|
|
44
|
+
}
|
|
45
|
+
process.kill(pid, "SIGTERM");
|
|
46
|
+
},
|
|
47
|
+
});
|
|
22
48
|
/**
|
|
23
|
-
* `serve` in the background
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* `
|
|
49
|
+
* `serve` in the background: `start`, `stop`, `restart`, `status`, `logs`. Without a unit, `start`
|
|
50
|
+
* runs `serve` as a process of its own; with one — `install`, a systemd user unit or a launchd
|
|
51
|
+
* agent — it goes through systemd or launchd. **Nothing starts until `start` is typed** (NEED-9):
|
|
52
|
+
* `install` only writes the file. What the server does stays each CLI's; `options.process` says how
|
|
53
|
+
* to find, start and stop it.
|
|
27
54
|
*/
|
|
28
|
-
export const serverCommand = (messenger) => {
|
|
55
|
+
export const serverCommand = (messenger, options = {}) => {
|
|
29
56
|
const { app } = messenger;
|
|
30
57
|
const command = new Command("server").description(`\`${app.command} serve\` in the background: start, stop, restart, status, logs; install adds a systemd or launchd unit`);
|
|
31
58
|
const marker = (profile) => `${app.envPrefix}_SERVER=${profile}`;
|
|
59
|
+
const serveArgv = options.serveArgv ?? ["serve"];
|
|
32
60
|
const prepare = (self) => {
|
|
33
61
|
const context = messengerContext(self, messenger);
|
|
34
62
|
const system = environmentOf(self).system ?? thisMachine();
|
|
35
63
|
const platform = platformFor(app, system, context.env);
|
|
36
64
|
const state = resolvePaths({ appName: app.appName, prefix: app.envPrefix, env: context.env }).state;
|
|
65
|
+
const logPath = options.logPath?.(context) ?? join(state, "serve", `${context.profile}.log`);
|
|
37
66
|
const unit = platform.unit({
|
|
38
67
|
profile: context.profile,
|
|
39
|
-
command: [...system.entry,
|
|
68
|
+
command: [...system.entry, ...serveArgv],
|
|
40
69
|
environment: { [`${app.envPrefix}_PROFILE`]: context.profile, ...locationVariables(app, context.env) },
|
|
41
|
-
logPath
|
|
70
|
+
logPath,
|
|
71
|
+
...options.unit,
|
|
42
72
|
});
|
|
73
|
+
const server = (options.process ?? lockProcess(app, marker(context.profile), serveArgv))(context, system, logPath);
|
|
43
74
|
const each = async (argvs) => {
|
|
44
75
|
for (const argv of argvs) {
|
|
45
76
|
const ran = await system.run(argv, context.env);
|
|
@@ -47,39 +78,39 @@ export const serverCommand = (messenger) => {
|
|
|
47
78
|
throw new CliError("configuration_error", `${argv.join(" ")} failed: ${ran.stderr.trim()}`);
|
|
48
79
|
}
|
|
49
80
|
};
|
|
50
|
-
const lock = () => {
|
|
51
|
-
const held = readLock(lockPath(app, unit.profile, context.env));
|
|
52
|
-
return held && alive(held.pid) ? held : undefined;
|
|
53
|
-
};
|
|
54
81
|
const say = (value, lines) => {
|
|
55
82
|
if (context.format === "pretty")
|
|
56
83
|
context.streams.data(lines.join("\n"));
|
|
57
84
|
else
|
|
58
85
|
context.renderer.result(value);
|
|
59
86
|
};
|
|
60
|
-
return { context, system, platform, unit,
|
|
87
|
+
return { context, system, platform, unit, server, each, say };
|
|
61
88
|
};
|
|
62
89
|
const installed = (unit) => {
|
|
63
90
|
if (!existsSync(unit.path)) {
|
|
64
91
|
throw new CliError("not_found", `no unit for profile ${unit.profile} — \`${app.command} server install\` writes it`);
|
|
65
92
|
}
|
|
66
93
|
};
|
|
67
|
-
const byOf = async ({ platform, unit },
|
|
68
|
-
if (existsSync(unit.path) && (await platform.state(unit)).pid ===
|
|
94
|
+
const byOf = async ({ platform, unit }, running) => {
|
|
95
|
+
if (existsSync(unit.path) && (await platform.state(unit)).pid === running.pid)
|
|
69
96
|
return "unit";
|
|
70
|
-
|
|
97
|
+
if (running.byCommand)
|
|
98
|
+
return "command";
|
|
99
|
+
return carries(running.pid, marker(unit.profile)) ? "server" : "hand";
|
|
71
100
|
};
|
|
72
101
|
const how = (by, unit) => by === "unit"
|
|
73
102
|
? `under ${unit.path.endsWith(".plist") ? "launchd" : "systemd"} (${unit.name})`
|
|
74
103
|
: by === "server"
|
|
75
104
|
? `started by \`${app.command} server start\``
|
|
76
|
-
:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
: by === "command"
|
|
106
|
+
? `started by a ${app.command} command that needed it — it stops once unused`
|
|
107
|
+
: `started by hand — \`${app.command} server stop\` leaves it alone`;
|
|
108
|
+
const start = async (prepared, args) => {
|
|
109
|
+
const { system, platform, unit, server, each, say } = prepared;
|
|
110
|
+
const before = await server.probe();
|
|
111
|
+
if (before && !before.byCommand) {
|
|
112
|
+
say({ profile: unit.profile, started: false, running: true, pid: before.pid, startedAt: before.startedAt }, [
|
|
113
|
+
`Already serving profile ${unit.profile} since ${clock(before.startedAt)} (PID ${before.pid}).`,
|
|
83
114
|
]);
|
|
84
115
|
return;
|
|
85
116
|
}
|
|
@@ -90,17 +121,24 @@ export const serverCommand = (messenger) => {
|
|
|
90
121
|
by = "unit";
|
|
91
122
|
}
|
|
92
123
|
else {
|
|
93
|
-
// A shell's --timeout default would end a server meant to outlive the shell.
|
|
94
|
-
const { [`${app.envPrefix}_TIMEOUT`]: _timeout, ...inherited } = context.env;
|
|
95
124
|
const [name = "", value = ""] = marker(unit.profile).split("=");
|
|
96
|
-
spawned =
|
|
125
|
+
spawned = server.launch(args, { [name]: value });
|
|
97
126
|
by = "server";
|
|
98
127
|
}
|
|
99
128
|
for (let look = 0; look < LOOKS; look++) {
|
|
100
|
-
const now =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
const now = await server.probe();
|
|
130
|
+
// A server a command started answers until the new one takes its place.
|
|
131
|
+
if (now?.connected && now.pid !== before?.pid) {
|
|
132
|
+
say({
|
|
133
|
+
profile: unit.profile,
|
|
134
|
+
started: true,
|
|
135
|
+
by,
|
|
136
|
+
pid: now.pid,
|
|
137
|
+
startedAt: now.startedAt,
|
|
138
|
+
...(now.connectedAt ? { connectedAt: now.connectedAt } : {}),
|
|
139
|
+
log: unit.logPath,
|
|
140
|
+
}, [
|
|
141
|
+
`Started: serving profile ${unit.profile} (PID ${now.pid}), connected${now.connectedAt ? ` since ${clock(now.connectedAt)}` : ""}, ${how(by, unit)}.`,
|
|
104
142
|
`Its log: ${app.command} server logs`,
|
|
105
143
|
]);
|
|
106
144
|
return;
|
|
@@ -108,66 +146,69 @@ export const serverCommand = (messenger) => {
|
|
|
108
146
|
const gone = spawned !== undefined ? !alive(spawned) : look > 8 && !(await platform.state(unit)).active;
|
|
109
147
|
if (gone) {
|
|
110
148
|
const last = (by === "unit" ? await platform.logs(unit, 5) : tail(unit.logPath, 5)).trim();
|
|
111
|
-
throw new CliError("provider_unavailable", `serve stopped before it was
|
|
149
|
+
throw new CliError("provider_unavailable", `serve stopped before it was connected${last ? `:\n${last}` : ""}`);
|
|
112
150
|
}
|
|
113
151
|
await system.pause();
|
|
114
152
|
}
|
|
115
|
-
throw new CliError("timeout", `serve is running but not
|
|
153
|
+
throw new CliError("timeout", `serve is running but not connected yet — \`${app.command} server status\`, \`${app.command} server logs\``);
|
|
116
154
|
};
|
|
117
155
|
const stop = async (prepared) => {
|
|
118
|
-
const { platform, unit,
|
|
156
|
+
const { platform, unit, server, each, say, system } = prepared;
|
|
119
157
|
if (existsSync(unit.path) && (await platform.state(unit)).active) {
|
|
120
158
|
await each(platform.stop(unit));
|
|
121
159
|
say({ profile: unit.profile, stopped: true, by: "unit" }, [`Stopped ${unit.name}.`]);
|
|
122
160
|
return;
|
|
123
161
|
}
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
162
|
+
const running = await server.probe();
|
|
163
|
+
if (!running) {
|
|
126
164
|
say({ profile: unit.profile, stopped: false }, [`Nothing to stop: profile ${unit.profile} is not being served.`]);
|
|
127
165
|
return;
|
|
128
166
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
process.kill(held.pid, "SIGTERM");
|
|
133
|
-
for (let look = 0; look < LOOKS && alive(held.pid); look++)
|
|
167
|
+
const by = await byOf(prepared, running);
|
|
168
|
+
await server.stop(running);
|
|
169
|
+
for (let look = 0; look < LOOKS && alive(running.pid); look++)
|
|
134
170
|
await system.pause();
|
|
135
|
-
say({ profile: unit.profile, stopped: true, by
|
|
136
|
-
`Stopped serving profile ${unit.profile} (PID ${
|
|
171
|
+
say({ profile: unit.profile, stopped: true, by, pid: running.pid }, [
|
|
172
|
+
`Stopped serving profile ${unit.profile} (PID ${running.pid}).`,
|
|
137
173
|
]);
|
|
138
174
|
};
|
|
139
|
-
|
|
175
|
+
const idleArgs = (self) => {
|
|
176
|
+
const { idle } = self.opts();
|
|
177
|
+
if (idle === undefined)
|
|
178
|
+
return [];
|
|
179
|
+
parseDuration(idle, "--idle");
|
|
180
|
+
return ["--idle", idle];
|
|
181
|
+
};
|
|
182
|
+
const withIdle = (sub) => options.idle ? sub.option("--idle <duration>", "stop after this long with nobody using it — 15m, 1h") : sub;
|
|
183
|
+
withIdle(command
|
|
140
184
|
.command("start")
|
|
141
|
-
.description("start serve in the background — through the unit if one is installed — and answer once it
|
|
142
|
-
|
|
143
|
-
await start(prepare(this));
|
|
185
|
+
.description("start serve in the background — through the unit if one is installed — and answer once it connects")).action(async function () {
|
|
186
|
+
await start(prepare(this), idleArgs(this));
|
|
144
187
|
});
|
|
145
188
|
command
|
|
146
189
|
.command("stop")
|
|
147
|
-
.description("stop
|
|
190
|
+
.description("stop this profile's serve — through the unit if it runs under one")
|
|
148
191
|
.action(async function () {
|
|
149
192
|
await stop(prepare(this));
|
|
150
193
|
});
|
|
151
|
-
command
|
|
152
|
-
|
|
153
|
-
.description("stop it and start it again")
|
|
154
|
-
.action(async function () {
|
|
194
|
+
withIdle(command.command("restart").description("stop it and start it again")).action(async function () {
|
|
195
|
+
const args = idleArgs(this);
|
|
155
196
|
const prepared = prepare(this);
|
|
156
197
|
await stop({ ...prepared, say: () => { } });
|
|
157
|
-
await start(prepared);
|
|
198
|
+
await start(prepared, args);
|
|
158
199
|
});
|
|
159
200
|
command
|
|
160
201
|
.command("status")
|
|
161
202
|
.description("whether serve runs for this profile, since when, who started it, and the unit if there is one")
|
|
162
203
|
.action(async function () {
|
|
163
204
|
const prepared = prepare(this);
|
|
164
|
-
const { context, platform, unit,
|
|
205
|
+
const { context, platform, unit, server, say } = prepared;
|
|
165
206
|
const isInstalled = existsSync(unit.path);
|
|
166
207
|
const state = isInstalled ? await platform.state(unit) : { loaded: false, active: false };
|
|
167
|
-
const held =
|
|
208
|
+
const held = await server.probe();
|
|
168
209
|
const by = held ? await byOf(prepared, held) : null;
|
|
169
210
|
const left = held ? undefined : readLock(lockPath(app, unit.profile, context.env));
|
|
170
|
-
//
|
|
211
|
+
// An update leaves a running serve on the old code.
|
|
171
212
|
const outdated = held?.version && held.version !== app.version
|
|
172
213
|
? `It runs ${app.command} ${held.version}, and ${app.command} is now ${app.version} — \`${app.command} server restart\`.`
|
|
173
214
|
: undefined;
|
|
@@ -183,8 +224,8 @@ export const serverCommand = (messenger) => {
|
|
|
183
224
|
? {
|
|
184
225
|
pid: held.pid,
|
|
185
226
|
startedAt: held.startedAt,
|
|
186
|
-
connected: held.
|
|
187
|
-
...(held.
|
|
227
|
+
connected: held.connected,
|
|
228
|
+
...(held.connectedAt ? { connectedAt: held.connectedAt } : {}),
|
|
188
229
|
by,
|
|
189
230
|
}
|
|
190
231
|
: {}),
|
|
@@ -195,9 +236,9 @@ export const serverCommand = (messenger) => {
|
|
|
195
236
|
unit: { name: unit.name, path: unit.path, installed: isInstalled, ...state },
|
|
196
237
|
}, [
|
|
197
238
|
held
|
|
198
|
-
? held.
|
|
199
|
-
? `Serving profile ${unit.profile} since ${clock(held.startedAt)} (PID ${held.pid}),
|
|
200
|
-
: `Starting profile ${unit.profile} since ${clock(held.startedAt)} (PID ${held.pid}) — not
|
|
239
|
+
? held.connected
|
|
240
|
+
? `Serving profile ${unit.profile} since ${clock(held.startedAt)} (PID ${held.pid}), connected${held.connectedAt ? ` since ${clock(held.connectedAt)}` : ""}, ${how(by ?? "hand", unit)}.`
|
|
241
|
+
: `Starting profile ${unit.profile} since ${clock(held.startedAt)} (PID ${held.pid}) — not connected yet, ${how(by ?? "hand", unit)}.`
|
|
201
242
|
: `Not serving profile ${unit.profile}.${isInstalled && state.detail?.startsWith("failed") ? ` The unit failed — \`${app.command} server logs\`.` : ""}`,
|
|
202
243
|
...(left
|
|
203
244
|
? [
|