@wirecat/cli-core 0.704.0 → 0.706.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/CHANGELOG.md +116 -0
- package/dist/cli/bot/api-http.d.ts +8 -2
- package/dist/cli/bot/api-http.js +20 -4
- package/dist/cli/bot/api.d.ts +8 -0
- package/dist/cli/bot/api.js +31 -3
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +3 -3
- package/dist/cli/messenger/lacks.js +3 -0
- package/dist/cli/messenger/messages-delete-command.js +30 -25
- package/dist/cli/messenger/messages-edit-command.js +2 -0
- package/dist/cli/messenger/messages-scheduled-command.js +110 -4
- package/dist/cli/messenger/store-maintenance-command.js +6 -2
- package/dist/cli/service-api-call.d.ts +13 -3
- package/dist/cli/service-api-call.js +19 -9
- package/dist/cli/service-api-manifest.d.ts +11 -2
- package/dist/cli/service-api-manifest.js +30 -9
- package/dist/cli/service-api.d.ts +14 -6
- package/dist/cli/service-api.js +198 -52
- package/dist/cli/token-session.d.ts +5 -2
- package/dist/cli/token-session.js +13 -4
- package/dist/content/cli/index.d.ts +33 -0
- package/dist/content/cli/index.js +368 -0
- package/dist/content/index.d.ts +8 -0
- package/dist/content/index.js +7 -0
- package/dist/content/manifest/index.d.ts +4 -0
- package/dist/content/manifest/index.js +4 -0
- package/dist/content/manifest/manifest.d.ts +92 -0
- package/dist/content/manifest/manifest.js +137 -0
- package/dist/content/manifest/map.d.ts +25 -0
- package/dist/content/manifest/map.js +94 -0
- package/dist/content/manifest/source.d.ts +41 -0
- package/dist/content/manifest/source.js +288 -0
- package/dist/content/manifest/writer.d.ts +26 -0
- package/dist/content/manifest/writer.js +133 -0
- package/dist/content/source.d.ts +64 -0
- package/dist/content/source.js +2 -0
- package/dist/content/sync.d.ts +61 -0
- package/dist/content/sync.js +387 -0
- package/dist/content/testing/index.d.ts +4 -0
- package/dist/content/testing/index.js +4 -0
- package/dist/content/testing/source-contract.d.ts +38 -0
- package/dist/content/testing/source-contract.js +274 -0
- package/dist/content/testing/source.d.ts +55 -0
- package/dist/content/testing/source.js +276 -0
- package/dist/content/testing/sync-contract.d.ts +10 -0
- package/dist/content/testing/sync-contract.js +172 -0
- package/dist/content/testing/write-contract.d.ts +14 -0
- package/dist/content/testing/write-contract.js +102 -0
- package/dist/content/writer.d.ts +64 -0
- package/dist/content/writer.js +38 -0
- package/dist/content/writes.d.ts +58 -0
- package/dist/content/writes.js +129 -0
- package/dist/documents/file-mirror-model.d.ts +3 -1
- package/dist/documents/index.d.ts +3 -3
- package/dist/documents/index.js +1 -1
- package/dist/domain/content.d.ts +102 -0
- package/dist/domain/content.js +11 -0
- package/dist/entities/index.d.ts +8 -2
- package/dist/entities/index.js +4 -2
- package/dist/entities/message-change.d.ts +240 -0
- package/dist/entities/message-change.js +6 -0
- package/dist/errors/reasons.js +14 -0
- package/dist/kit/fake.d.ts +2 -2
- package/dist/kit/fake.js +21 -0
- package/dist/manifest/index.d.ts +21 -7
- package/dist/manifest/index.js +7 -4
- package/dist/mcp/surface.js +6 -3
- package/dist/ports/messenger.d.ts +20 -1
- package/dist/sends/permissions.js +11 -1
- package/dist/services/documents/mirrors.d.ts +13 -1
- package/dist/services/documents/mirrors.js +12 -3
- package/dist/services/files/mirror.d.ts +20 -8
- package/dist/services/files/mirror.js +84 -27
- package/dist/services/files/versions.d.ts +17 -7
- package/dist/services/files/versions.js +56 -21
- package/dist/services/messages.d.ts +31 -0
- package/dist/services/messages.js +62 -0
- package/dist/store/exports.d.ts +1 -0
- package/dist/store/exports.js +1 -0
- package/dist/store/recover.js +2 -0
- package/dist/store/sqlite/account-purge.js +7 -0
- package/dist/store/sqlite/content.d.ts +100 -0
- package/dist/store/sqlite/content.js +375 -0
- package/dist/store/sqlite/entity-types.d.ts +1 -0
- package/dist/store/sqlite/entity-types.js +1 -0
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +26 -0
- package/dist/store/sqlite/schema.d.ts +1140 -0
- package/dist/store/sqlite/schema.js +100 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/package.json +12 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,122 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.706.0 — 19.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **The generated `api` group mounts subgroups: `api <group> <command>`.** An operation whose manifest names a `group`
|
|
13
|
+
(cli-base's `names.groups`) is mounted under it without the repeated word, so `contacts-list` in `contacts` is
|
|
14
|
+
`api contacts list`, checked against `api.contacts.list`; `api.contacts` covers the whole group. A profile that still
|
|
15
|
+
names the old flat key `api.contacts-list` keeps its hold on that one command: it is checked beside the new key, from
|
|
16
|
+
the command line and over MCP, warns to rename it, and only ever tightens. The old path `api contacts-list` stops
|
|
17
|
+
working. `api show` takes the path (quoted, `api show "contacts list"`), the old name or the operation id, and `api list` prints the path and the group.
|
|
18
|
+
A manifest without groups mounts flat, as before, so nothing changes until a CLI regenerates with groups and
|
|
19
|
+
releases the move as a breaking change.
|
|
20
|
+
- **Cancel, edit and send now a scheduled message: `messages scheduled cancel <chat> <scheduled-id...>`,
|
|
21
|
+
`messages scheduled edit <chat> <scheduled-id> [text] [--at-time <time>]` and
|
|
22
|
+
`messages scheduled send <chat> <scheduled-id...>`.** Before, a scheduled message could only be listed, and the
|
|
23
|
+
owner cancelled one in the app. A scheduled message has an id of its own: `messages edit` on it failed, and
|
|
24
|
+
`messages delete` with the same number would have deleted an old, sent message. Each command takes only the ids
|
|
25
|
+
`messages scheduled <chat>` lists and checks them against that list before anything changes; an unknown id is
|
|
26
|
+
`not_found` and points at the list. Cancelling counts and asks as a delete does (`--allow-dangerous` at an `ask`
|
|
27
|
+
level), sending now as a send. An edit with only `--at-time` keeps the text, and one with only the text keeps the
|
|
28
|
+
time. The keys are `messages.scheduled.cancel`, `.edit` and `.send`; the answers are the entities
|
|
29
|
+
`scheduled_cancellation`, `message_write` and `scheduled_send`. An adapter adds them through the optional port
|
|
30
|
+
group `ScheduledChanges` (`cancelScheduled`, `editScheduled`, `sendScheduled`); a messenger without it answers
|
|
31
|
+
"this messenger cannot …". Needs cli-base with `scheduled` as a resource word, for `cli-dev lint`.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **The MCP command search ranks the shorter name first on a tie**, so "send message" finds `messages send` before
|
|
36
|
+
`messages scheduled send`.
|
|
37
|
+
|
|
38
|
+
## 0.705.0 — 19.11.2026
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- **The first screen's "Works with" names `amo`** (amoCRM and Kommo, `@wirecat/amo-cli`), now that it is on npm.
|
|
43
|
+
- **The content category: posts and pages of a site such as WordPress, in the store.** Store version 71 adds
|
|
44
|
+
channels, authors, tags and categories, posts with their text as Markdown, the versions a sync or a write replaced,
|
|
45
|
+
metrics readings and a word index. `@wirecat/cli-core/content` has the `ContentSource` and `ContentWriter` ports,
|
|
46
|
+
`syncContent` (a trashed post stays with the status `trashed`, a post deleted for good is marked so only by a
|
|
47
|
+
complete id pass, and a pass is held when the sign-in read only part or the site moved), and `addContentCommands`:
|
|
48
|
+
`sync`, `posts list|show|search`, `authors list`, `terms list`, `channels list`, `metrics show`, and with writes
|
|
49
|
+
`posts create|update|publish|unpublish|schedule|delete`. Publishing asks first (`posts.publish`, the key the `api`
|
|
50
|
+
group checks), and so do an edit of a public post and a deletion past the trash (`posts.delete.force`).
|
|
51
|
+
- **`contentSourceFromManifest` and `contentWriterFromManifest`** build a content CLI's source and writer from
|
|
52
|
+
configuration over its generated `api` group. A WordPress manifest needs no hook. The category `content` joins
|
|
53
|
+
`wirecat.config`. See [Content](docs/dev/CONTENT.md).
|
|
54
|
+
- **`/content/testing`**: `contentSourceContract`, `contentSyncContract`, `contentWriteContract` and
|
|
55
|
+
`fakeContentSource`.
|
|
56
|
+
- **A file mirror keeps the remote content it replaces, too.** Before an upload overwrites a remote file, the old
|
|
57
|
+
content is kept in the mirror's version store, downloaded first when the store does not have it. A remote deletion
|
|
58
|
+
downloads nothing, since the provider's trash holds the file; its log entry says `oldIn: "remote-trash"` when the
|
|
59
|
+
store lacks the content. Each log entry says in `from` which side its `old` content came from. When the store
|
|
60
|
+
cannot keep a content, a full disk during the download included, the file fails with `mirror.version-not-kept`
|
|
61
|
+
and nothing is replaced; a remote file that changed since the listing fails with `mirror.remote-changed`
|
|
62
|
+
([DOCUMENTS.md](docs/dev/DOCUMENTS.md#sync-plain-files-with-a-provider)).
|
|
63
|
+
- **`skippedName` in `@wirecat/cli-core/documents`,** so a target skips `.git`, `node_modules` and editor leftovers
|
|
64
|
+
while it lists. `syncFileMirror` takes `hints` to name the app's own preview, repin and allow-deletions commands in
|
|
65
|
+
its messages.
|
|
66
|
+
- **`syncFileMirrors` and `restoreFileVersion` take the lock `acquireLock` returns.** Its `held()` is checked before
|
|
67
|
+
every write; a caller no longer keeps its own flag. A lock with `assertHeld` works as before.
|
|
68
|
+
- **`serviceApiWriter`: a write from code through the `api` group's own guard.** A content command that publishes or
|
|
69
|
+
deletes through a generated manifest now checks the same keys as `<cli> api <operation>`: `api.<operation>` and
|
|
70
|
+
every manifest key the call sets off (`posts.publish`, `posts.delete.force`), at the profile's levels, with the same
|
|
71
|
+
question and journal line. `confirmed` names keys the command already asked about in this run, so a person is
|
|
72
|
+
asked once; a `deny` or `readonly` on them still stops the write. The writer checks parameters and the body against
|
|
73
|
+
the schemas as the command does, and refuses a query parameter or header the operation does not declare (a
|
|
74
|
+
method override among them), so it reaches no further than the command.
|
|
75
|
+
- **`serviceApiCall(…).withHeaders` gives a read's response headers**, and `nextPage` takes them: a page style with
|
|
76
|
+
`pagesHeader` (WordPress's `X-WP-TotalPages`) stops at the last page instead of asking for one past the end, which
|
|
77
|
+
WordPress refuses. `items: ""` reads the answer itself as the list, and `start` is the first page's number, so
|
|
78
|
+
`api … --all` on such a read needs no `--page`. `nextPage`, `PageStep` and `underBase` are exported.
|
|
79
|
+
- **A manifest key can lift itself with `unless`.** WordPress publishes a scheduled post whose `date` moves into the
|
|
80
|
+
past; the generated key on `date` and `date_gmt` applies unless the call itself sets `status` to draft, pending or
|
|
81
|
+
private. Such a field counts once sent, `null` included, as WordPress resets a null date to now. A flag now counts in
|
|
82
|
+
the body or the query, as WordPress reads both.
|
|
83
|
+
- **`manifestVerify` checks a sign-in on the owner's own site.** For a service on the owner's site (WordPress), the
|
|
84
|
+
check goes to the site `session start --site` names, and its `fetch` gets that site, as its host is not among the
|
|
85
|
+
CLI's own. A `fetch` that takes one argument still works.
|
|
86
|
+
- **`wirecat.config.ts` takes `spec.kind: "wp-json"` (with the `spec.version` the index runs) and `auth.preset: "app-password"`** for a WordPress CLI made with
|
|
87
|
+
`new --from-config`.
|
|
88
|
+
|
|
89
|
+
### Changed — may break callers
|
|
90
|
+
|
|
91
|
+
- **`FileVersions` has `has(sha256)`, and `keep` takes a writer as well as a path.** Code that implements
|
|
92
|
+
`FileVersions` itself adds `has`; `fileVersions()` has both. `FileMirrorOptions.assertHeld` may return a promise.
|
|
93
|
+
- **`--all` refuses a next link outside the server's path.** A service whose links point to another path on the same
|
|
94
|
+
host (a `/v2` link from a `/v1` server) now stops with `invalid_response` instead of following it.
|
|
95
|
+
- **Requires `@wirecat/cli-base` 0.120.0** for the new page style fields and `unless`.
|
|
96
|
+
|
|
97
|
+
### Fixed
|
|
98
|
+
|
|
99
|
+
- **A raw read that names its command's read key is sent as a read.** A CLI can put `people.list` on `api
|
|
100
|
+
contacts-list`, so `people: deny` stops the raw read too (WC-PERM-22). Before, any key beyond `api.*` sent the read
|
|
101
|
+
the way a write goes, with an `operation_id` in the answer, and refused `--all`. Now `deny` refuses it, `allow`
|
|
102
|
+
sends it as a read with `--all`, and only `ask` keeps the write's path. Found by the hubspot-cli review.
|
|
103
|
+
- **A download that replaced a file is never reported as cut off.** Only a new file can be left partial, so only a
|
|
104
|
+
new file's interrupted download makes the path a conflict. A download that fails cleanly clears its pending entry
|
|
105
|
+
(kept while a partial copy could not be removed),
|
|
106
|
+
and a leftover temporary file under a symbolic link is left alone. The error for an empty local folder says what
|
|
107
|
+
to do: mount it, or add a file or remove the mirror's state when the files really were deleted.
|
|
108
|
+
- **A content source from a manifest pages by `nextPage` with the answer's headers.** Its own reader of the page count
|
|
109
|
+
is gone.
|
|
110
|
+
- **`session start --login` names where to make the password only at a terminal.** Piped in, as an agent or a test
|
|
111
|
+
signs in, the note stood before the JSON error on stderr.
|
|
112
|
+
|
|
113
|
+
### Security
|
|
114
|
+
|
|
115
|
+
- **A sign-in never leaves the server's path.** For a site under a path (`host/blog`, a WordPress multisite in
|
|
116
|
+
subfolders), `--all` refuses a next page outside the base URL's path, not only outside its origin, and the `api`
|
|
117
|
+
group, the writer and `serviceApiCall` refuse to sign a request outside it, and a signed request to a site (a server
|
|
118
|
+
with free variables) follows no redirect: its error names the address the site moved to, without its query.
|
|
119
|
+
`hostsFetch` takes a `credentialScope` that refuses a signed request outside it and drops the sign-in on a redirect
|
|
120
|
+
out of it (cli-base `hostFetch`).
|
|
121
|
+
- **`<PREFIX>_TOKEN_SITE` is cleaned as `--site` is.** `host/blog/..` was the root site of the same host, and the
|
|
122
|
+
password went there.
|
|
123
|
+
|
|
8
124
|
## 0.704.0 — 19.11.2026
|
|
9
125
|
|
|
10
126
|
### Added
|
|
@@ -42,9 +42,15 @@ export declare const httpApiRequest: (operation: ManifestOperation, input: ApiCo
|
|
|
42
42
|
/** What one exchange needs: the service's name, the fetch, its own refusals and the answer's size limit. */
|
|
43
43
|
export type HttpApiSendOptions = Pick<HttpApiExecutorOptions, "service" | "fetch" | "failure" | "maxBytes">;
|
|
44
44
|
/**
|
|
45
|
-
* Sends one request, records it in the run by its path template, never an id, and gives the parsed answer
|
|
46
|
-
*
|
|
45
|
+
* Sends one request, records it in the run by its path template, never an id, and gives the parsed answer with the
|
|
46
|
+
* response's headers, where a service may page (WordPress's `X-WP-TotalPages`). A write that got no answer is
|
|
47
|
+
* `outcome_unknown` (WC-LIFE-9); the service's own error text is never repeated (WC-SECR-6).
|
|
47
48
|
*/
|
|
49
|
+
export declare const httpApiExchange: (options: HttpApiSendOptions) => (command: Command, operation: ManifestOperation, request: HttpApiRequest) => Promise<{
|
|
50
|
+
answer: unknown;
|
|
51
|
+
headers: Headers;
|
|
52
|
+
}>;
|
|
53
|
+
/** `httpApiExchange`'s answer alone. */
|
|
48
54
|
export declare const httpApiSend: (options: HttpApiSendOptions) => (command: Command, operation: ManifestOperation, request: HttpApiRequest) => Promise<unknown>;
|
|
49
55
|
/**
|
|
50
56
|
* The `execute` of `generatedApiCommand` for any OpenAPI CLI: fills the path, adds the query, sends the JSON body
|
package/dist/cli/bot/api-http.js
CHANGED
|
@@ -131,10 +131,11 @@ const answerOf = async (response, maxBytes) => {
|
|
|
131
131
|
return readJsonResponse(response, { maxBytes });
|
|
132
132
|
};
|
|
133
133
|
/**
|
|
134
|
-
* Sends one request, records it in the run by its path template, never an id, and gives the parsed answer
|
|
135
|
-
*
|
|
134
|
+
* Sends one request, records it in the run by its path template, never an id, and gives the parsed answer with the
|
|
135
|
+
* response's headers, where a service may page (WordPress's `X-WP-TotalPages`). A write that got no answer is
|
|
136
|
+
* `outcome_unknown` (WC-LIFE-9); the service's own error text is never repeated (WC-SECR-6).
|
|
136
137
|
*/
|
|
137
|
-
export const
|
|
138
|
+
export const httpApiExchange = (options) => async (command, operation, request) => {
|
|
138
139
|
const writes = operation.effect !== "read";
|
|
139
140
|
const template = endpointOf(operation);
|
|
140
141
|
const end = providerRequest(`${request.method} ${template}`, undefined, {
|
|
@@ -177,13 +178,18 @@ export const httpApiSend = (options) => async (command, operation, request) => {
|
|
|
177
178
|
try {
|
|
178
179
|
const result = graphqlAnswer(options, operation, answer);
|
|
179
180
|
end({ status });
|
|
180
|
-
return result;
|
|
181
|
+
return { answer: result, headers: response.headers };
|
|
181
182
|
}
|
|
182
183
|
catch (error) {
|
|
183
184
|
end({ status, error });
|
|
184
185
|
throw error;
|
|
185
186
|
}
|
|
186
187
|
};
|
|
188
|
+
/** `httpApiExchange`'s answer alone. */
|
|
189
|
+
export const httpApiSend = (options) => {
|
|
190
|
+
const exchange = httpApiExchange(options);
|
|
191
|
+
return async (command, operation, request) => (await exchange(command, operation, request)).answer;
|
|
192
|
+
};
|
|
187
193
|
/**
|
|
188
194
|
* The `execute` of `generatedApiCommand` for any OpenAPI CLI: fills the path, adds the query, sends the JSON body
|
|
189
195
|
* with the caller's headers through the caller's fetch, and prints the answer. Nothing here retries: a write is
|
|
@@ -243,6 +249,16 @@ const refusal = (service, operation, response, writes) => {
|
|
|
243
249
|
reason: "access.denied",
|
|
244
250
|
status,
|
|
245
251
|
});
|
|
252
|
+
const location = status >= 300 && status < 400 ? response.headers.get("location") : null;
|
|
253
|
+
// A signed call follows no redirect, so it might take the sign-in elsewhere; the address shows where the site
|
|
254
|
+
// went. Its query is left out: it may carry a key.
|
|
255
|
+
if (location !== null) {
|
|
256
|
+
const to = URL.canParse(location, response.url || undefined)
|
|
257
|
+
? new URL(location, response.url || undefined)
|
|
258
|
+
: undefined;
|
|
259
|
+
const where = to ? `${to.origin}${to.pathname}` : "another address";
|
|
260
|
+
return new CliError(statusToCode(status), `${service} moved ${operation.command} to ${where} (HTTP ${status}); nothing was sent there`, { status, retryable: false });
|
|
261
|
+
}
|
|
246
262
|
return new CliError(statusToCode(status), `${service} refused ${operation.command} (HTTP ${status})`, {
|
|
247
263
|
status,
|
|
248
264
|
retryable: status >= 500,
|
package/dist/cli/bot/api.d.ts
CHANGED
|
@@ -26,5 +26,13 @@ export interface ApiCommands {
|
|
|
26
26
|
/** An upload's file, `-` for stdin. */
|
|
27
27
|
readBytes?: (command: Command, path: string) => Uint8Array<ArrayBuffer>;
|
|
28
28
|
execute: (command: Command, operation: ManifestOperation, input: ApiCommandInput) => Promise<void>;
|
|
29
|
+
/** Called with each operation's command once it is built, before it is mounted. */
|
|
30
|
+
configure?: (command: Command, operation: ManifestOperation) => void;
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* The words after `api`: `contacts-list` in the group `contacts` is `contacts list`, `move-page` in `pages` keeps its
|
|
34
|
+
* name, and an operation without a group stays `api <command>`. The same rule as cli-base's `apiCommandPath`; `group`
|
|
35
|
+
* is read as optional, so a manifest generated before groups mounts flat, as it always did.
|
|
36
|
+
*/
|
|
37
|
+
export declare const apiPathOf: (operation: ManifestOperation) => string[];
|
|
30
38
|
export declare const generatedApiCommand: (api: ApiCommands) => Command;
|
package/dist/cli/bot/api.js
CHANGED
|
@@ -2,19 +2,32 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { Command, Option } from "commander";
|
|
4
4
|
import { secretInput } from "../../runs/run-context.js";
|
|
5
|
-
import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
5
|
+
import { NO_EFFECTS, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
6
6
|
import { apiFlagOf, apiJson, apiOptionKey, graphqlVariables, readApiBody, readApiBytes, sendsBytes, } from "./api-input.js";
|
|
7
|
+
/**
|
|
8
|
+
* The words after `api`: `contacts-list` in the group `contacts` is `contacts list`, `move-page` in `pages` keeps its
|
|
9
|
+
* name, and an operation without a group stays `api <command>`. The same rule as cli-base's `apiCommandPath`; `group`
|
|
10
|
+
* is read as optional, so a manifest generated before groups mounts flat, as it always did.
|
|
11
|
+
*/
|
|
12
|
+
export const apiPathOf = (operation) => {
|
|
13
|
+
const { command, group } = operation;
|
|
14
|
+
if (!group)
|
|
15
|
+
return [command];
|
|
16
|
+
return [group, command.startsWith(`${group}-`) ? command.slice(group.length + 1) : command];
|
|
17
|
+
};
|
|
7
18
|
const scalarOf = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : undefined;
|
|
8
19
|
export const generatedApiCommand = (api) => {
|
|
9
20
|
const group = new Command("api").description(api.description ?? "every operation of the official Bot API, generated from its schema");
|
|
10
21
|
group.option("--store-token <profile>", "keep a returned authentication token only in this bot profile's OS keyring; never print it");
|
|
22
|
+
const subgroups = new Set();
|
|
11
23
|
for (const operation of api.operations) {
|
|
12
24
|
const binding = operation.binding.kind === "http"
|
|
13
25
|
? `${operation.binding.method} ${operation.binding.path}`
|
|
14
26
|
: operation.binding.kind === "graphql"
|
|
15
27
|
? `${operation.binding.operation} ${operation.binding.field}`
|
|
16
28
|
: operation.binding.name;
|
|
17
|
-
const
|
|
29
|
+
const path = apiPathOf(operation);
|
|
30
|
+
const command = annotate(new Command(path.at(-1)), {
|
|
18
31
|
effects: operation.effect === "read" ? REMOTE_READ : REMOTE_WRITE,
|
|
19
32
|
}).description(`${operation.summary ?? operation.id} — ${operation.effect} (${binding})`);
|
|
20
33
|
for (const parameter of operation.parameters) {
|
|
@@ -99,7 +112,22 @@ export const generatedApiCommand = (api) => {
|
|
|
99
112
|
input.body = body;
|
|
100
113
|
await api.execute(this, operation, input);
|
|
101
114
|
});
|
|
102
|
-
|
|
115
|
+
api.configure?.(command, operation);
|
|
116
|
+
const [first] = path;
|
|
117
|
+
const taken = group.commands.find((one) => one.name() === first);
|
|
118
|
+
// A command and a group of one name would put an operation under another's command, or answer with the wrong one.
|
|
119
|
+
if (taken && (path.length === 1 || !subgroups.has(taken)))
|
|
120
|
+
throw new CliError("configuration_error", `api ${first} is both a group and an operation: rename one`);
|
|
121
|
+
if (path.length === 1 || first === undefined) {
|
|
122
|
+
group.addCommand(command);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const subgroup = taken ?? annotate(new Command(first), { effects: NO_EFFECTS }).description(`the ${first} operations`);
|
|
126
|
+
if (!taken) {
|
|
127
|
+
subgroups.add(subgroup);
|
|
128
|
+
group.addCommand(subgroup);
|
|
129
|
+
}
|
|
130
|
+
subgroup.addCommand(command);
|
|
103
131
|
}
|
|
104
132
|
return group;
|
|
105
133
|
};
|
|
@@ -58,8 +58,8 @@ export interface CopyAge {
|
|
|
58
58
|
}
|
|
59
59
|
export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
|
|
60
60
|
export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
|
|
61
|
-
next?: undefined;
|
|
62
61
|
missing?: undefined;
|
|
62
|
+
next?: undefined;
|
|
63
63
|
meta?: undefined;
|
|
64
64
|
} | {
|
|
65
65
|
missing: {
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { registerLinkConversationsPrompt } from "../mcp/prompts.js";
|
|
|
22
22
|
export { agentBody, agentJson, agentResult, UNTRUSTED, UNTRUSTED_INSTRUCTION, UNTRUSTED_NEUTRAL } from "../mcp/text.js";
|
|
23
23
|
export { MEETING_RESULT_ENTITIES } from "../meetings/index.js";
|
|
24
24
|
export { type AppIdentity, envName, readOnlyLockOf, readOnlyRefusal } from "../ports/app.js";
|
|
25
|
-
export type { AccountEditing, AccountHealth, AccountRecords, AccountSettings, AccountStanding, AccountTools, After, BotChats, ChannelComments, ChatDeletion, ChatFolders, ChatReading, ContactBook, Download, ForumControl, ForumState, GroupAdmin, GroupModeration, HistoryBatch, HistoryBatchHandler, HistoryChatEvent, HistoryReaction, HistoryStar, HistoryVote, InviteLinks, JoinRequests, LiveUpdates, MessageButtons, MessageEditing, MessageMedia, MessagePermalinks, MessagePins, MessagePolls, MessageReactions, MessageSearch, MessageStars, MessengerAdapter, MessengerCore, NewPoll, OfficialStats, PassiveUpdates, PersonProfiles, ProfileChange, ProfilePhotos, PushedHistory, ReadState, RemoteFile, ScheduledMessages, SenderIdentities, SenderSearch, SendOptions, Sent, ServerQuery, ServerReads, ThreadAddressing, TopicEditing, TopicHistory, TopicReadState, Transcript, } from "../ports/messenger.js";
|
|
25
|
+
export type { AccountEditing, AccountHealth, AccountRecords, AccountSettings, AccountStanding, AccountTools, After, BotChats, ChannelComments, ChatDeletion, ChatFolders, ChatReading, ContactBook, Download, ForumControl, ForumState, GroupAdmin, GroupModeration, HistoryBatch, HistoryBatchHandler, HistoryChatEvent, HistoryReaction, HistoryStar, HistoryVote, InviteLinks, JoinRequests, LiveUpdates, MessageButtons, MessageEditing, MessageMedia, MessagePermalinks, MessagePins, MessagePolls, MessageReactions, MessageSearch, MessageStars, MessengerAdapter, MessengerCore, NewPoll, OfficialStats, PassiveUpdates, PersonProfiles, ProfileChange, ProfilePhotos, PushedHistory, ReadState, RemoteFile, ScheduledChanges, ScheduledMessages, SenderIdentities, SenderSearch, SendOptions, Sent, ServerQuery, ServerReads, ThreadAddressing, TopicEditing, TopicHistory, TopicReadState, Transcript, } from "../ports/messenger.js";
|
|
26
26
|
export type { Fetching, MediaOption, MessengerTraits } from "../ports/traits.js";
|
|
27
27
|
export { senderFacts } from "../replies/dry-run.js";
|
|
28
28
|
export { type ReplyRender, replyRenderer } from "../replies/rendering.js";
|
|
@@ -153,9 +153,9 @@ export { fieldsOf, projectFields } from "./result-fields.js";
|
|
|
153
153
|
export { HARNESSES, type Harness, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
|
|
154
154
|
export { type AgentScheduleSpec, agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, type ScheduleSite, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
155
155
|
export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
|
|
156
|
-
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
157
|
-
export { hostsFetch, type ServiceApiCall, type ServiceApiCallOptions, serviceApiCall } from "./service-api-call.js";
|
|
158
|
-
export { manifestBaseUrl, type ServiceApiManifest, signRequest, siteValue } from "./service-api-manifest.js";
|
|
156
|
+
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, type ServiceApiWrite, serviceApiKeys, serviceApiOperations, serviceApiPermissions, serviceApiWriter, } from "./service-api.js";
|
|
157
|
+
export { hostsFetch, type ServiceApiCall, type ServiceApiCallOptions, type ServiceApiCallWithHeaders, serviceApiCall, } from "./service-api-call.js";
|
|
158
|
+
export { manifestBaseUrl, nextPage, type PageStep, type ServiceApiManifest, signRequest, siteValue, underBase, } from "./service-api-manifest.js";
|
|
159
159
|
export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
160
160
|
export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
|
|
161
161
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -142,9 +142,9 @@ export { fieldsOf, projectFields } from "./result-fields.js";
|
|
|
142
142
|
export { HARNESSES, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
|
|
143
143
|
export { agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
144
144
|
export { deniedKinds, deniedKindsOf } from "./search-left-out.js";
|
|
145
|
-
export { serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
146
|
-
export { hostsFetch, serviceApiCall } from "./service-api-call.js";
|
|
147
|
-
export { manifestBaseUrl, signRequest, siteValue } from "./service-api-manifest.js";
|
|
145
|
+
export { serviceApiKeys, serviceApiOperations, serviceApiPermissions, serviceApiWriter, } from "./service-api.js";
|
|
146
|
+
export { hostsFetch, serviceApiCall, } from "./service-api-call.js";
|
|
147
|
+
export { manifestBaseUrl, nextPage, signRequest, siteValue, underBase, } from "./service-api-manifest.js";
|
|
148
148
|
export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
149
149
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
150
150
|
export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
@@ -22,6 +22,9 @@ export const COMMAND_NEEDS = {
|
|
|
22
22
|
"messages comments": ["comments", "read comments on a channel post"],
|
|
23
23
|
"messages pin": ["pin", "pin a message"],
|
|
24
24
|
"messages unpin": ["unpin", "unpin a message"],
|
|
25
|
+
"messages scheduled cancel": ["cancelScheduled", "cancel a scheduled message"],
|
|
26
|
+
"messages scheduled edit": ["editScheduled", "edit a scheduled message"],
|
|
27
|
+
"messages scheduled send": ["sendScheduled", "send a scheduled message now"],
|
|
25
28
|
};
|
|
26
29
|
/** The commands the store answers for a messenger whose history is pushed to it, so the method is not needed there. */
|
|
27
30
|
const STORE_ANSWERS = new Set(["chats events"]);
|
|
@@ -12,28 +12,33 @@ import { messengerContext } from "./context.js";
|
|
|
12
12
|
* question, and `--allow-dangerous` is the yes. For everyone only
|
|
13
13
|
* with `--for-everyone` (max-cli `NEED-239`), and never for an agent (NEED-1423).
|
|
14
14
|
*/
|
|
15
|
-
export const deleteCommand = (messenger) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
export const deleteCommand = (messenger) => {
|
|
16
|
+
const command = annotate(new Command("delete"), {
|
|
17
|
+
examples: [`${messenger.app.command} personal messages delete "Book club" 101`],
|
|
18
|
+
effects: REMOTE_WRITE,
|
|
19
|
+
output: { entity: "message_deletion" },
|
|
20
|
+
})
|
|
21
|
+
.description("delete messages for you only; with --for-everyone, for everyone in the chat")
|
|
22
|
+
.argument("<chat>", messenger.chatArgument)
|
|
23
|
+
.argument("<message...>", `the message ids, by spaces or commas, at most ${DELETE_AT_ONCE}`)
|
|
24
|
+
.addOption(ownerOnlyOption("--for-everyone", "delete for everyone in the chat, not only for you — they cannot get it back"))
|
|
25
|
+
.addOption(ownerOnlyOption("--allow-dangerous", "go ahead without the question an ask level puts before a deletion"))
|
|
26
|
+
.action(async function (chat, messages) {
|
|
27
|
+
const everyone = this.opts().forEveryone === true;
|
|
28
|
+
if (environmentOf(this).agent && (everyone || messenger.deleteForMe === false))
|
|
29
|
+
throw new CliError("permission_error", `${everyone ? "" : `${messenger.name ?? messenger.provider} deletes only for everyone, and `}an agent never ` +
|
|
30
|
+
`deletes for everyone — the owner can run \`${lineOf(this, "messages delete --for-everyone")}\``, { permission: "messages.delete", sent: false });
|
|
31
|
+
const ids = messages
|
|
32
|
+
.flatMap((one) => one.split(","))
|
|
33
|
+
.map((one) => one.trim())
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
if (ids.length === 0)
|
|
36
|
+
throw new CliError("validation_error", "no message id given — name the messages to delete", { sent: false });
|
|
37
|
+
const context = messengerContext(this, messenger);
|
|
38
|
+
const deleted = await context.withServices((services) => services.messages.delete({ chat, messages: ids, forEveryone: everyone }));
|
|
39
|
+
renderAnswer(this, context, itemOf(snakeKeys(deleted)));
|
|
40
|
+
});
|
|
41
|
+
if (messenger.scheduledSends !== false)
|
|
42
|
+
command.addHelpText("after", "\nA message waiting to be sent has an id of its own; cancel it with `messages scheduled cancel`.");
|
|
43
|
+
return command;
|
|
44
|
+
};
|
|
@@ -39,5 +39,7 @@ export const editCommand = (messenger) => {
|
|
|
39
39
|
});
|
|
40
40
|
if (messenger.html)
|
|
41
41
|
edit.option("--html", HTML_HELP);
|
|
42
|
+
if (messenger.scheduledSends !== false)
|
|
43
|
+
edit.addHelpText("after", "\nA message waiting to be sent has an id of its own; change it with `messages scheduled edit`.");
|
|
42
44
|
return edit;
|
|
43
45
|
};
|
|
@@ -1,19 +1,41 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
1
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
2
3
|
import { Command } from "commander";
|
|
4
|
+
import { sendTime } from "../../domain/send-time.js";
|
|
3
5
|
import { capability } from "../../ports/messenger.js";
|
|
4
6
|
import { renderMessages } from "../../render/messages.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import { DELETE_AT_ONCE } from "../../services/index.js";
|
|
8
|
+
import { ownerOnlyOption, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
9
|
+
import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
7
10
|
import { messengerContext } from "./context.js";
|
|
8
|
-
import { messageItems, selfOf, viewOf } from "./message-items.js";
|
|
11
|
+
import { messageItem, messageItems, selfOf, viewOf } from "./message-items.js";
|
|
12
|
+
import { afterWrite, writtenAnswer } from "./message-writes.js";
|
|
13
|
+
import { HTML_HELP } from "./messages-send-command.js";
|
|
14
|
+
import { readAll } from "./stdin.js";
|
|
15
|
+
const SCHEDULED_IDS = "the scheduled ids `messages scheduled <chat>` lists, by spaces or commas, " +
|
|
16
|
+
`at most ${DELETE_AT_ONCE}; never the id of a sent message`;
|
|
17
|
+
const SAME_NUMBER = "A scheduled message has an id of its own: the same number in the chat's history is another, sent message. " +
|
|
18
|
+
"Each id is checked against the scheduled list before anything changes.";
|
|
19
|
+
const idsOf = (typed) => {
|
|
20
|
+
const ids = typed
|
|
21
|
+
.flatMap((one) => one.split(","))
|
|
22
|
+
.map((one) => one.trim())
|
|
23
|
+
.filter(Boolean);
|
|
24
|
+
if (ids.length === 0)
|
|
25
|
+
throw new CliError("validation_error", "no scheduled id given — `messages scheduled <chat>` lists them", {
|
|
26
|
+
sent: false,
|
|
27
|
+
});
|
|
28
|
+
return ids;
|
|
29
|
+
};
|
|
9
30
|
/** Where to look after a scheduled send ended without an answer: repeating it would schedule a second one. */
|
|
10
31
|
export const scheduledCommand = (messenger) => {
|
|
11
32
|
const command = annotate(new Command("scheduled"), {
|
|
12
33
|
examples: [`${messenger.app.command} personal messages scheduled "Book club"`],
|
|
13
34
|
effects: REMOTE_READ,
|
|
14
35
|
})
|
|
15
|
-
.description("messages waiting to be sent later in a chat, soonest first
|
|
36
|
+
.description("messages waiting to be sent later in a chat, soonest first, with their scheduled ids")
|
|
16
37
|
.argument("<chat>", messenger.chatArgument)
|
|
38
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
17
39
|
.action(async function (chat) {
|
|
18
40
|
const context = messengerContext(this, messenger);
|
|
19
41
|
const { items, reader } = await context.withMessenger(async (connection) => ({
|
|
@@ -28,5 +50,89 @@ export const scheduledCommand = (messenger) => {
|
|
|
28
50
|
has_more: false,
|
|
29
51
|
}), () => renderMessages(items.map((one) => ({ ...one, timestamp: one.scheduledFor ?? one.timestamp })), viewOf(context, messenger)));
|
|
30
52
|
});
|
|
53
|
+
command.addCommand(cancelCommand(messenger));
|
|
54
|
+
command.addCommand(editCommand(messenger));
|
|
55
|
+
command.addCommand(sendNowCommand(messenger));
|
|
31
56
|
return annotate(command, { output: { entity: "message" } });
|
|
32
57
|
};
|
|
58
|
+
/** Nobody gets a cancelled message back, so it asks as a deletion does where the profile's level is `ask`. */
|
|
59
|
+
const cancelCommand = (messenger) => annotate(new Command("cancel"), {
|
|
60
|
+
examples: [`${messenger.app.command} personal messages scheduled cancel "Book club" 3`],
|
|
61
|
+
effects: REMOTE_WRITE,
|
|
62
|
+
output: { entity: "scheduled_cancellation" },
|
|
63
|
+
})
|
|
64
|
+
.description("cancel scheduled messages before they are sent; they cannot be got back")
|
|
65
|
+
.argument("<chat>", messenger.chatArgument)
|
|
66
|
+
.argument("<scheduled-id...>", SCHEDULED_IDS)
|
|
67
|
+
.addOption(ownerOnlyOption("--allow-dangerous", "go ahead without the question an ask level puts before a cancellation"))
|
|
68
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
69
|
+
.action(async function (chat, typed) {
|
|
70
|
+
const ids = idsOf(typed);
|
|
71
|
+
const context = messengerContext(this, messenger);
|
|
72
|
+
const cancelled = await context.withServices((services) => services.messages.cancelScheduled({ chat, ids }));
|
|
73
|
+
renderAnswer(this, context, itemOf(snakeKeys(cancelled)));
|
|
74
|
+
});
|
|
75
|
+
const editCommand = (messenger) => {
|
|
76
|
+
const edit = annotate(new Command("edit"), {
|
|
77
|
+
literal_after_dashes: true,
|
|
78
|
+
examples: [
|
|
79
|
+
`${messenger.app.command} personal messages scheduled edit "Book club" 3 "The meeting starts at 11."`,
|
|
80
|
+
`${messenger.app.command} personal messages scheduled edit "Book club" 3 --at-time 2026-12-01T09:00`,
|
|
81
|
+
],
|
|
82
|
+
effects: REMOTE_WRITE,
|
|
83
|
+
output: { entity: "message_write" },
|
|
84
|
+
})
|
|
85
|
+
.description("change the text or the time of a scheduled message before it is sent")
|
|
86
|
+
.argument("<chat>", messenger.chatArgument)
|
|
87
|
+
.argument("<scheduled-id>", "the scheduled id `messages scheduled <chat>` lists; never the id of a sent message")
|
|
88
|
+
.argument("[text]", "the new text; without it and without --at-time, read from stdin")
|
|
89
|
+
.option("--at-time <time>", "send it at this time instead: 2026-09-25T09:00 (local time), or 30m, 2h, 1d from now")
|
|
90
|
+
.option("--md", "read this messenger's Markdown; see its formatting guide for supported syntax")
|
|
91
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
92
|
+
.action(async function (chat, id, text) {
|
|
93
|
+
const context = messengerContext(this, messenger);
|
|
94
|
+
const { md: markdown, html, atTime } = this.opts();
|
|
95
|
+
const at = atTime === undefined ? undefined : sendTime(atTime);
|
|
96
|
+
const body = text ?? (at === undefined ? await readAll(context.stdin) : undefined);
|
|
97
|
+
if (body !== undefined && body.trim() === "")
|
|
98
|
+
throw new CliError("validation_error", "no new text — give it, pipe it in, or change only the time with --at-time");
|
|
99
|
+
const { edited, reader } = await context.withServices(async (services) => {
|
|
100
|
+
const edited = await services.messages.editScheduled({
|
|
101
|
+
chat,
|
|
102
|
+
id: id.trim(),
|
|
103
|
+
...(body === undefined ? {} : { text: body }),
|
|
104
|
+
...(markdown === true ? { markdown } : {}),
|
|
105
|
+
...(html === true ? { html } : {}),
|
|
106
|
+
...(at === undefined ? {} : { at }),
|
|
107
|
+
});
|
|
108
|
+
return afterWrite(edited, async () => ({ edited, reader: await services.messages.reader() }));
|
|
109
|
+
});
|
|
110
|
+
await afterWrite(edited, () => renderAnswer(this, context, writtenAnswer(edited, reader)));
|
|
111
|
+
});
|
|
112
|
+
if (messenger.html)
|
|
113
|
+
edit.option("--html", HTML_HELP);
|
|
114
|
+
return edit;
|
|
115
|
+
};
|
|
116
|
+
const sendNowCommand = (messenger) => annotate(new Command("send"), {
|
|
117
|
+
examples: [`${messenger.app.command} personal messages scheduled send "Book club" 3`],
|
|
118
|
+
effects: REMOTE_WRITE,
|
|
119
|
+
output: { entity: "scheduled_send" },
|
|
120
|
+
})
|
|
121
|
+
.description("deliver what is scheduled right away instead of at its time; each gets a new id")
|
|
122
|
+
.argument("<chat>", messenger.chatArgument)
|
|
123
|
+
.argument("<scheduled-id...>", SCHEDULED_IDS)
|
|
124
|
+
.addHelpText("after", `\n${SAME_NUMBER}`)
|
|
125
|
+
.action(async function (chat, typed) {
|
|
126
|
+
const ids = idsOf(typed);
|
|
127
|
+
const context = messengerContext(this, messenger);
|
|
128
|
+
const { done, reader } = await context.withServices(async (services) => {
|
|
129
|
+
const done = await services.messages.sendScheduled({ chat, ids });
|
|
130
|
+
return afterWrite(done, async () => ({ done, reader: await services.messages.reader() }));
|
|
131
|
+
});
|
|
132
|
+
await afterWrite(done, () => renderAnswer(this, context, itemOf({
|
|
133
|
+
operation_id: done.operationId,
|
|
134
|
+
chat_id: done.chatId,
|
|
135
|
+
sent: done.sent,
|
|
136
|
+
messages: done.messages.map((one) => messageItem(one, reader)),
|
|
137
|
+
})));
|
|
138
|
+
});
|
|
@@ -16,7 +16,7 @@ import { migrate } from "../../store/migrations.js";
|
|
|
16
16
|
import { openCache } from "../../store/open.js";
|
|
17
17
|
import { storePath } from "../../store/path.js";
|
|
18
18
|
import { deleteCopy, repairStore } from "../../store/repair.js";
|
|
19
|
-
import { drainNoteIndex, dropAllUnusedVectors, fillSearchIndex, fillStems, involvementStoreOver, noteIndexState, openSqlite, openStore, orphanPointers, pendingNormalization, resetAttachmentWords, resetCrmFileWords, resetNoteIndex, resetSearchIndex, resetStems, resetTrackerItemWords, rollBack, searchIndexState, stemmerCache, stemsState, vectorIndexCounts, } from "../../store/store.js";
|
|
19
|
+
import { drainNoteIndex, dropAllUnusedVectors, fillSearchIndex, fillStems, involvementStoreOver, noteIndexState, openSqlite, openStore, orphanPointers, pendingNormalization, resetAttachmentWords, resetContentPostWords, resetCrmFileWords, resetNoteIndex, resetSearchIndex, resetStems, resetTrackerItemWords, rollBack, searchIndexState, stemmerCache, stemsState, vectorIndexCounts, } from "../../store/store.js";
|
|
20
20
|
import { environmentOf, outputFor } from "../context.js";
|
|
21
21
|
import { destroysNothing, grantsAuthority, LOCAL_READ, LOCAL_WRITE } from "../effects.js";
|
|
22
22
|
import { itemOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
@@ -328,6 +328,7 @@ const inspect = (path) => reading(path, (database) => {
|
|
|
328
328
|
...(schema.version > 0 ? [["attachment_words", indexIntegrity(database, "attachment_words", 0)]] : []),
|
|
329
329
|
...(schema.version >= 68 ? [["crm_file_words", indexIntegrity(database, "crm_file_words", 0)]] : []),
|
|
330
330
|
...(schema.version >= 70 ? [["tracker_item_words", indexIntegrity(database, "tracker_item_words", 0)]] : []),
|
|
331
|
+
...(schema.version >= 71 ? [["content_post_words", indexIntegrity(database, "content_post_words", 0)]] : []),
|
|
331
332
|
]);
|
|
332
333
|
const size = bytesOf(path) + bytesOf(`${path}-wal`);
|
|
333
334
|
const { bavail, bsize } = statfsSync(dirname(path));
|
|
@@ -532,7 +533,10 @@ const reindexCommand = (owner) => destroysNothing(annotate(new Command("rebuild"
|
|
|
532
533
|
throw new CliError("validation_error", `the store is behind this build — \`${lineOf(this, "store migrate")}\` first`);
|
|
533
534
|
}
|
|
534
535
|
resetSearchIndex(database);
|
|
535
|
-
const fileTexts = resetAttachmentWords(database) +
|
|
536
|
+
const fileTexts = resetAttachmentWords(database) +
|
|
537
|
+
resetCrmFileWords(database) +
|
|
538
|
+
resetTrackerItemWords(database) +
|
|
539
|
+
resetContentPostWords(database);
|
|
536
540
|
const words = buildWordIndex(database, (note) => renderer.note(note));
|
|
537
541
|
return {
|
|
538
542
|
path,
|
|
@@ -5,6 +5,11 @@ import { type HttpApiSendOptions } from "./bot/api-http.js";
|
|
|
5
5
|
import { type ServiceApiManifest } from "./service-api-manifest.js";
|
|
6
6
|
/** One operation of the generated manifest, by its id, sent with the sign-in its security scheme names. */
|
|
7
7
|
export type ServiceApiCall = (operation: string, input: ApiCommandInput) => Promise<unknown>;
|
|
8
|
+
/** The same read, with the response's headers, where a service pages (WordPress's `X-WP-TotalPages`, for `nextPage`). */
|
|
9
|
+
export type ServiceApiCallWithHeaders = (operation: string, input: ApiCommandInput) => Promise<{
|
|
10
|
+
body: unknown;
|
|
11
|
+
headers: Headers;
|
|
12
|
+
}>;
|
|
8
13
|
export interface ServiceApiCallOptions {
|
|
9
14
|
manifest: ServiceApiManifest;
|
|
10
15
|
/** The service's name in messages: "HubSpot". */
|
|
@@ -25,10 +30,15 @@ export interface ServiceApiCallOptions {
|
|
|
25
30
|
* A fetch that reaches only `hosts` (WC-CMD-32), over the fetch a test gives in its environment, or the network when
|
|
26
31
|
* none: a CLI passes `environment.fetch` as it is.
|
|
27
32
|
*/
|
|
28
|
-
export declare const hostsFetch: (hosts: readonly string[], fetch: FetchLike | undefined
|
|
33
|
+
export declare const hostsFetch: (hosts: readonly string[], fetch: FetchLike | undefined,
|
|
34
|
+
/** Where the sign-in may go, for a site under a path (`https://host/blog/wp-json`): see cli-base `hostFetch`. */
|
|
35
|
+
credentialScope?: string) => FetchLike;
|
|
29
36
|
/**
|
|
30
37
|
* The `api` group's request path for code that is not a command, such as a source read from a manifest: the same
|
|
31
38
|
* request building, sign-in header, redirect rule, run record and refusals as `serviceApiCommand`, without a guard. It
|
|
32
|
-
* sends reads only; a write goes through the `api` group, where the profile's guard asks.
|
|
39
|
+
* sends reads only; a write goes through `serviceApiWriter` or the `api` group, where the profile's guard asks. A
|
|
40
|
+
* request is sent only under the server's address, path included: a site at `host/blog` never signs `host/other`.
|
|
33
41
|
*/
|
|
34
|
-
export declare const serviceApiCall: (options: ServiceApiCallOptions) => ServiceApiCall
|
|
42
|
+
export declare const serviceApiCall: (options: ServiceApiCallOptions) => ServiceApiCall & {
|
|
43
|
+
withHeaders: ServiceApiCallWithHeaders;
|
|
44
|
+
};
|