@wirecat/cli-core 0.705.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 +30 -0
- package/dist/cli/bot/api.d.ts +8 -0
- package/dist/cli/bot/api.js +31 -3
- package/dist/cli/index.d.ts +1 -1
- 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/service-api.js +65 -27
- 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/kit/fake.d.ts +2 -2
- package/dist/kit/fake.js +21 -0
- 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/messages.d.ts +31 -0
- package/dist/services/messages.js +62 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,36 @@ 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
|
+
|
|
8
38
|
## 0.705.0 — 19.11.2026
|
|
9
39
|
|
|
10
40
|
### Added
|
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
|
};
|
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";
|
|
@@ -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
|
+
});
|
package/dist/cli/service-api.js
CHANGED
|
@@ -7,7 +7,7 @@ import { keyedGuard } from "../sends/keyed-guard.js";
|
|
|
7
7
|
import { levelFor } from "../sends/permissions.js";
|
|
8
8
|
import { newOperationId } from "../sends/send-id.js";
|
|
9
9
|
import { refusedPlace } from "../sends/upload.js";
|
|
10
|
-
import { generatedApiCommand } from "./bot/api.js";
|
|
10
|
+
import { apiPathOf, generatedApiCommand } from "./bot/api.js";
|
|
11
11
|
import { httpApiExchange, httpApiRequest, unsendableBody } from "./bot/api-http.js";
|
|
12
12
|
import { apiJson, checkApiBody, checkApiParameter, graphqlVariables, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
13
13
|
import { baseContext, outputFor } from "./context.js";
|
|
@@ -34,7 +34,18 @@ export const serviceApiOperations = (manifest) => {
|
|
|
34
34
|
/** How far `--all` reads: a service that never stops paging must not run a command forever. */
|
|
35
35
|
const MOST_PAGES = 500;
|
|
36
36
|
const isObject = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
37
|
-
const keyOf = (operation) =>
|
|
37
|
+
const keyOf = (operation) => ["api", ...apiPathOf(operation)].join(".");
|
|
38
|
+
/** `contacts list`: what follows `api` on the command line. */
|
|
39
|
+
const pathOf = (operation) => apiPathOf(operation).join(" ");
|
|
40
|
+
/**
|
|
41
|
+
* The key a grouped operation had while `api` was flat, `api.contacts-list`. A profile that still names it keeps its
|
|
42
|
+
* hold on that one command: checked beside the new key, it only ever tightens. A group never takes an old command's
|
|
43
|
+
* name (the generator refuses it), so the old key never reaches past its command.
|
|
44
|
+
*/
|
|
45
|
+
const formerKeyOf = (operation) => {
|
|
46
|
+
const former = `api.${operation.command}`;
|
|
47
|
+
return former === keyOf(operation) ? undefined : former;
|
|
48
|
+
};
|
|
38
49
|
const permissionsOf = (operation) => operation.permissions ?? [];
|
|
39
50
|
/** By its method too: an override may have marked a DELETE as a plain write. */
|
|
40
51
|
const destructive = (operation) => operation.effect === "destructive" || (operation.binding.kind === "http" && operation.binding.method === "DELETE");
|
|
@@ -89,18 +100,28 @@ export const serviceApiKeys = (input, operation, call) => {
|
|
|
89
100
|
*/
|
|
90
101
|
export const serviceApiPermissions = (input) => {
|
|
91
102
|
const checks = new Map();
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
const former = [];
|
|
104
|
+
for (const operation of input.manifest.operations) {
|
|
105
|
+
const old = formerKeyOf(operation);
|
|
106
|
+
if (old)
|
|
107
|
+
former.push(old);
|
|
108
|
+
checks.set(pathOf(operation), [
|
|
94
109
|
...permissionsOf(operation).map((permission) => {
|
|
95
110
|
const when = whenOf(permission);
|
|
96
111
|
return when === undefined ? permission.key : { key: permission.key, when };
|
|
97
112
|
}),
|
|
98
113
|
...(input.bodyPermissions?.[operation.command] ?? []).map(({ key, when }) => ({ key, when })),
|
|
114
|
+
...(old ? [{ key: old, when: "while a profile still names this old key" }] : []),
|
|
99
115
|
]);
|
|
100
|
-
|
|
116
|
+
}
|
|
117
|
+
const keys = [
|
|
118
|
+
...new Set([...checks.values()]
|
|
119
|
+
.flat()
|
|
120
|
+
.flatMap((one) => (typeof one === "string" ? [one] : former.includes(one.key) ? [] : [one.key]))),
|
|
121
|
+
];
|
|
101
122
|
return {
|
|
102
|
-
extra: keys,
|
|
103
|
-
alsoChecks: (path) => (path[0] === "api"
|
|
123
|
+
extra: [...keys, ...former],
|
|
124
|
+
alsoChecks: (path) => (path[0] === "api" ? (checks.get(path.slice(1).join(" ")) ?? []) : []),
|
|
104
125
|
defaults: {
|
|
105
126
|
...Object.fromEntries(keys.map((key) => [key, "ask"])),
|
|
106
127
|
...Object.fromEntries(input.manifest.operations.filter(destructive).map((operation) => [keyOf(operation), "ask"])),
|
|
@@ -108,7 +129,8 @@ export const serviceApiPermissions = (input) => {
|
|
|
108
129
|
};
|
|
109
130
|
};
|
|
110
131
|
const rowOf = (operation) => ({
|
|
111
|
-
command: operation
|
|
132
|
+
command: pathOf(operation),
|
|
133
|
+
group: apiPathOf(operation).length > 1 ? apiPathOf(operation)[0] : null,
|
|
112
134
|
method: operation.binding.kind === "http" ? operation.binding.method : operation.binding.kind === "graphql" ? "POST" : "",
|
|
113
135
|
path: operation.binding.kind === "http"
|
|
114
136
|
? operation.binding.path
|
|
@@ -162,10 +184,11 @@ const serviceApiCore = (options) => {
|
|
|
162
184
|
...(options.failure ? { failure: options.failure } : {}),
|
|
163
185
|
});
|
|
164
186
|
const operationOf = (name) => {
|
|
165
|
-
const
|
|
187
|
+
const named = (one) => pathOf(one) === name || one.command === name || one.id === name;
|
|
188
|
+
const found = operations.find(named);
|
|
166
189
|
if (found)
|
|
167
190
|
return found;
|
|
168
|
-
const id = manifest.operations.find(
|
|
191
|
+
const id = manifest.operations.find(named)?.id ?? name;
|
|
169
192
|
const why = options.excluded?.find((one) => one.id === name) ?? left.find((one) => one.id === id);
|
|
170
193
|
throw new CliError("not_found", why
|
|
171
194
|
? `${name} is not offered: ${why.reason}`
|
|
@@ -228,11 +251,23 @@ const serviceApiCore = (options) => {
|
|
|
228
251
|
throw error;
|
|
229
252
|
}
|
|
230
253
|
};
|
|
231
|
-
|
|
254
|
+
/** The old flat key, when the profile names it: on a read only its refusal or its question applies. */
|
|
255
|
+
const formerKeys = (command, operation) => {
|
|
256
|
+
const former = formerKeyOf(operation);
|
|
257
|
+
if (!former)
|
|
258
|
+
return [];
|
|
259
|
+
const { settings, renderer } = baseContext(command, configuration.resolveSettings);
|
|
260
|
+
const level = settings.permissions[former];
|
|
261
|
+
if (level === undefined)
|
|
262
|
+
return [];
|
|
263
|
+
renderer.warn(`permissions name ${former}, the old key of api ${pathOf(operation)}: rename it to ${keyOf(operation)}`);
|
|
264
|
+
return operation.effect === "read" && level !== "deny" && level !== "ask" ? [] : [former];
|
|
265
|
+
};
|
|
266
|
+
return { operations, left, baseUrlOf, defaults, exchange, formerKeys, operationOf, readsFreely, signed, write };
|
|
232
267
|
};
|
|
233
268
|
export const serviceApiCommand = (options) => {
|
|
234
269
|
const { app, configuration } = options;
|
|
235
|
-
const { operations, baseUrlOf, exchange, operationOf, readsFreely, signed, write } = serviceApiCore(options);
|
|
270
|
+
const { operations, baseUrlOf, exchange, formerKeys, operationOf, readsFreely, signed, write } = serviceApiCore(options);
|
|
236
271
|
const send = async (command, operation, request) => (await exchange(command, operation, request)).answer;
|
|
237
272
|
let schemas;
|
|
238
273
|
const loaded = () => {
|
|
@@ -240,6 +275,9 @@ export const serviceApiCommand = (options) => {
|
|
|
240
275
|
throw new CliError("configuration_error", "the api schemas were not loaded before the command ran");
|
|
241
276
|
return schemas;
|
|
242
277
|
};
|
|
278
|
+
const load = async () => {
|
|
279
|
+
schemas ??= await options.schemas();
|
|
280
|
+
};
|
|
243
281
|
/** Every page, in one run; a next page outside the server's address is never sent the sign-in. */
|
|
244
282
|
const allPages = async (command, operation, input) => {
|
|
245
283
|
const pagination = operation.pagination;
|
|
@@ -281,7 +319,7 @@ export const serviceApiCommand = (options) => {
|
|
|
281
319
|
call = step.next.input;
|
|
282
320
|
}
|
|
283
321
|
});
|
|
284
|
-
renderAnswer(command, outputFor(command), listOf(`api ${operation
|
|
322
|
+
renderAnswer(command, outputFor(command), listOf(`api ${pathOf(operation)}`, { items, limit: items.length, has_more: false }));
|
|
285
323
|
};
|
|
286
324
|
const refuseOwnFiles = (command, path) => {
|
|
287
325
|
if (path === "-")
|
|
@@ -303,8 +341,13 @@ export const serviceApiCommand = (options) => {
|
|
|
303
341
|
refuseOwnFiles(command, path);
|
|
304
342
|
return readApiBytes(path);
|
|
305
343
|
},
|
|
344
|
+
configure: (command, operation) => {
|
|
345
|
+
if (operation.pagination && !operation.parameters.some(({ name }) => name === "all"))
|
|
346
|
+
command.option("--all", "read every page, as the API pages it");
|
|
347
|
+
command.hook("preAction", load);
|
|
348
|
+
},
|
|
306
349
|
execute: async (command, operation, input) => {
|
|
307
|
-
const extra = serviceApiKeys(options, operation, input);
|
|
350
|
+
const extra = [...serviceApiKeys(options, operation, input), ...formerKeys(command, operation)];
|
|
308
351
|
const read = readsFreely(command, operation, extra);
|
|
309
352
|
if (operation.pagination && command.opts().all === true) {
|
|
310
353
|
if (!read)
|
|
@@ -334,10 +377,12 @@ export const serviceApiCommand = (options) => {
|
|
|
334
377
|
});
|
|
335
378
|
const show = annotate(new Command("show"), {
|
|
336
379
|
effects: NO_EFFECTS,
|
|
337
|
-
examples: [
|
|
380
|
+
examples: [
|
|
381
|
+
`${app.command} api show ${operations[0] ? JSON.stringify(pathOf(operations[0])) : "<operation>"} --json`,
|
|
382
|
+
],
|
|
338
383
|
})
|
|
339
384
|
.description(`show one operation's parameters and request schema, without calling ${options.service}`)
|
|
340
|
-
.argument("<operation>", "the operation
|
|
385
|
+
.argument("<operation>", "the operation as api list prints it (quoted), its old name, or its operation id")
|
|
341
386
|
.action(async function (name) {
|
|
342
387
|
const operation = operationOf(name);
|
|
343
388
|
const definitions = await options.definitions();
|
|
@@ -346,15 +391,8 @@ export const serviceApiCommand = (options) => {
|
|
|
346
391
|
});
|
|
347
392
|
const group = annotate(new Command("api"), { effects: NO_EFFECTS }).description(`the raw ${options.service} API, one command per operation of its OpenAPI document`);
|
|
348
393
|
group.addCommand(list).addCommand(show);
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
};
|
|
352
|
-
for (const child of generated.commands) {
|
|
353
|
-
const operation = operations.find((one) => one.command === child.name());
|
|
354
|
-
if (operation?.pagination && !operation.parameters.some(({ name }) => name === "all"))
|
|
355
|
-
child.option("--all", "read every page, as the API pages it");
|
|
356
|
-
group.addCommand(child.hook("preAction", load));
|
|
357
|
-
}
|
|
394
|
+
for (const child of [...generated.commands])
|
|
395
|
+
group.addCommand(child);
|
|
358
396
|
return group;
|
|
359
397
|
};
|
|
360
398
|
// Code may pass a number, a boolean or a list where a person types text; the check reads the text it stands for.
|
|
@@ -375,7 +413,7 @@ const writerBody = (operation, input, schemas) => {
|
|
|
375
413
|
* can be asked. A read that no key guards goes through `serviceApiCall`.
|
|
376
414
|
*/
|
|
377
415
|
export const serviceApiWriter = (options) => {
|
|
378
|
-
const { baseUrlOf, operationOf, signed, write } = serviceApiCore(options);
|
|
416
|
+
const { baseUrlOf, formerKeys, operationOf, signed, write } = serviceApiCore(options);
|
|
379
417
|
return async (command, name, input, { confirmed } = {}) => {
|
|
380
418
|
const operation = operationOf(name);
|
|
381
419
|
// The api group offers only declared parameters; code must not reach further, as WordPress's `_method` turns a
|
|
@@ -401,6 +439,6 @@ export const serviceApiWriter = (options) => {
|
|
|
401
439
|
throw new CliError("validation_error", problem);
|
|
402
440
|
}
|
|
403
441
|
const request = await signed(command, operation, httpApiRequest(operation, writerBody(operation, input, schemas), baseUrlOf(command)));
|
|
404
|
-
return write(command, operation, extra, request, confirmed);
|
|
442
|
+
return write(command, operation, [...extra, ...formerKeys(command, operation)], request, confirmed);
|
|
405
443
|
};
|
|
406
444
|
};
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ import { member } from "./member.js";
|
|
|
52
52
|
import { memory } from "./memory.js";
|
|
53
53
|
import { mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, place } from "./mention.js";
|
|
54
54
|
import { message } from "./message.js";
|
|
55
|
-
import { messageDeletion, messagePin, messageStar } from "./message-change.js";
|
|
55
|
+
import { messageDeletion, messagePin, messageStar, scheduledCancellation, scheduledSend } from "./message-change.js";
|
|
56
56
|
import { messageContext } from "./message-context.js";
|
|
57
57
|
import { messageCounts } from "./message-counts.js";
|
|
58
58
|
import { messageLink } from "./message-link.js";
|
|
@@ -92,7 +92,7 @@ import { topic } from "./topic.js";
|
|
|
92
92
|
* subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
|
|
93
93
|
* is the target, not a description of today's output.
|
|
94
94
|
*/
|
|
95
|
-
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatSending, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
95
|
+
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatSending, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledCancellation, scheduledJob, scheduledSend, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
96
96
|
export declare const ENTITIES: {
|
|
97
97
|
readonly meeting_change: v.StrictObjectSchema<{
|
|
98
98
|
readonly action: v.PicklistSchema<["create", "update", "cancel"], undefined>;
|
|
@@ -2513,6 +2513,12 @@ export declare const ENTITIES: {
|
|
|
2513
2513
|
readonly deleted: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
2514
2514
|
readonly for_everyone: v.BooleanSchema<undefined>;
|
|
2515
2515
|
}, undefined>;
|
|
2516
|
+
readonly scheduled_cancellation: v.StrictObjectSchema<{
|
|
2517
|
+
readonly operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
2518
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
2519
|
+
readonly cancelled: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
2520
|
+
}, undefined>;
|
|
2521
|
+
readonly scheduled_send: v.StrictObjectSchema<import("./message-change.js").ScheduledSendEntries, undefined>;
|
|
2516
2522
|
readonly message_transcript: v.StrictObjectSchema<{
|
|
2517
2523
|
readonly message_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
2518
2524
|
readonly text: v.StringSchema<undefined>;
|
package/dist/entities/index.js
CHANGED
|
@@ -61,7 +61,7 @@ import { member } from "./member.js";
|
|
|
61
61
|
import { memory } from "./memory.js";
|
|
62
62
|
import { mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, place } from "./mention.js";
|
|
63
63
|
import { message } from "./message.js";
|
|
64
|
-
import { messageDeletion, messagePin, messageStar } from "./message-change.js";
|
|
64
|
+
import { messageDeletion, messagePin, messageStar, scheduledCancellation, scheduledSend } from "./message-change.js";
|
|
65
65
|
import { messageContext } from "./message-context.js";
|
|
66
66
|
import { messageCounts } from "./message-counts.js";
|
|
67
67
|
import { messageLink } from "./message-link.js";
|
|
@@ -101,7 +101,7 @@ import { topic } from "./topic.js";
|
|
|
101
101
|
* subset of its fields, never a renamed one. Commands move onto these one by one; until then, a schema
|
|
102
102
|
* is the target, not a description of today's output.
|
|
103
103
|
*/
|
|
104
|
-
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatSending, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledJob, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
104
|
+
export { account, accountChange, accountPrivacy, accountPrivacyChange, accountProfile, accountSession, adminReport, agenda, analysisConsent, analysisConsentRevocation, attachment, attachmentBytes, attachmentExtraction, attachmentTextChange, automaticTags, botAdmin, botMenuEntry, botProfile, botSeenChat, botTemplate, botWebhook, cachedChatMetadata, callRecord, chart, chat, chatAdminChange, chatArchive, chatCoverage, chatEvent, chatFolderChange, chatFolderOrder, chatFolderRemoval, chatGroupChange, chatInspection, chatInvite, chatInviteChange, chatMembersChange, chatMembersFetch, chatMetadata, chatMetadataRefresh, chatModeration, chatMuting, chatPin, chatRead, chatRemoval, chatRequestChange, chatRules, chatSender, chatSending, chatStats, chatTracking, chatUnread, contact, contactActivity, contactAlias, contactCheck, contactContext, contactImport, contactLookup, contactNote, contactNoteRemoval, contactPreparation, contactStateChange, contactSync, contactUpdate, conversation, conversationBatch, conversationBatchStatus, conversationBuildResult, conversationChange, conversationDetails, conversationEmbedding, conversationEmbeddingStatus, conversationHit, conversationPreparation, conversationReadiness, counterRefresh, counters, document, documentLink, endedAccountSessions, evidence, evidencePacket, fact, folder, hit, identity, imageEmbedding, inviteLink, job, joinRequest, linkedPerson, mailCounts, mediaArchive, mediaArchiveCheck, mediaArchiveMove, mediaArchiveTimer, meeting, meetingProjectCandidates, meetingSeriesInventory, member, memory, mention, mentionDecision, mentionDetails, mentionDomain, mentionRebuild, message, messageContext, messageCounts, messageDeletion, messageDownload, messageEvent, messageLink, messageLinks, messagePin, messageStar, messageSync, messageTranscript, messageWrite, model, modelKey, note, officialStats, organization, person, place, poll, pollChange, pollVote, project, ranking, reaction, reactionChange, recipient, recipientAdded, recipientChange, recipientOff, recipientRemoved, recordedRun, reference, relationship, reminder, removedModelKey, responseTimes, retention, runDetails, runHit, runLocation, savedSearch, scheduledCancellation, scheduledJob, scheduledSend, scheduleHarness, searchHistoryClear, sendAttempt, serveSummary, stickerInventory, storeBackup, storeChatStatus, storeCheck, storeClear, storeCopyRemoval, storeDecrypt, storedModelKey, storeExport, storeGapPlan, storeGapRepair, storeImport, storeInfo, storeJobCancel, storeJobClear, storeJobDetails, storeJobRetry, storeMigration, storeReindex, storeRepair, storeReset, storeRestore, storeTable, tagChange, tagging, task, taskAnalysis, taskAnalysisMark, taskCard, taskCategories, taskClosed, taskCreated, taskLinks, taskMerge, taskPair, taskScan, taskSimilar, taskStats, taskUnmerge, template, topic, topicIcon, trackedChat, trackedChatHistory, waitingChats, watchedMessage, watchItem, };
|
|
105
105
|
export const ENTITIES = {
|
|
106
106
|
sync_progress: syncProgress,
|
|
107
107
|
deal,
|
|
@@ -157,6 +157,8 @@ export const ENTITIES = {
|
|
|
157
157
|
message_pin: messagePin,
|
|
158
158
|
message_star: messageStar,
|
|
159
159
|
message_deletion: messageDeletion,
|
|
160
|
+
scheduled_cancellation: scheduledCancellation,
|
|
161
|
+
scheduled_send: scheduledSend,
|
|
160
162
|
message_transcript: messageTranscript,
|
|
161
163
|
message_links: messageLinks,
|
|
162
164
|
evidence_packet: evidencePacket,
|
|
@@ -17,3 +17,243 @@ export declare const messageDeletion: v.StrictObjectSchema<{
|
|
|
17
17
|
readonly deleted: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
18
18
|
readonly for_everyone: v.BooleanSchema<undefined>;
|
|
19
19
|
}, undefined>;
|
|
20
|
+
/** Scheduled ids, which are never the ids of sent messages. */
|
|
21
|
+
export declare const scheduledCancellation: v.StrictObjectSchema<{
|
|
22
|
+
readonly operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
23
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
24
|
+
readonly cancelled: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
25
|
+
}, undefined>;
|
|
26
|
+
declare const scheduledSendEntries: {
|
|
27
|
+
operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
28
|
+
chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
29
|
+
sent: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
30
|
+
messages: v.ArraySchema<v.StrictObjectSchema<{
|
|
31
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
32
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
33
|
+
readonly provider: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
34
|
+
readonly account: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
35
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
36
|
+
readonly chat_title: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
37
|
+
readonly sender_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
38
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
39
|
+
readonly sender_username: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
40
|
+
readonly sender_is_chat: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
41
|
+
readonly sender_is_me: v.BooleanSchema<undefined>;
|
|
42
|
+
readonly mentions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, undefined>;
|
|
43
|
+
readonly timestamp: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
44
|
+
readonly edited_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
45
|
+
readonly text: v.StringSchema<undefined>;
|
|
46
|
+
readonly transcript: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
47
|
+
readonly anchor: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
48
|
+
readonly excerpt: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
49
|
+
readonly matched_in: v.OptionalSchema<v.PicklistSchema<["text", "transcript", "filename", "file", "context", "picture"], undefined>, undefined>;
|
|
50
|
+
readonly score: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
51
|
+
readonly match: v.OptionalSchema<v.PicklistSchema<["words", "beginnings", "corrected"], undefined>, undefined>;
|
|
52
|
+
readonly corrections: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
53
|
+
readonly from: v.StringSchema<undefined>;
|
|
54
|
+
readonly to: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
55
|
+
}, undefined>, undefined>, undefined>;
|
|
56
|
+
readonly found_in: v.OptionalSchema<v.PicklistSchema<["archive", "server", "both"], undefined>, undefined>;
|
|
57
|
+
readonly discovery: v.OptionalSchema<v.StrictObjectSchema<{
|
|
58
|
+
readonly coverage: v.NumberSchema<undefined>;
|
|
59
|
+
readonly matched_terms: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
60
|
+
readonly missing_terms: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly parent: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
62
|
+
readonly found_by: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<["words", "meaning"], undefined>, undefined>, undefined>;
|
|
63
|
+
readonly reranker_score: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
64
|
+
}, undefined>, undefined>;
|
|
65
|
+
readonly context: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
66
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
67
|
+
readonly timestamp: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
68
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
69
|
+
readonly text: v.StringSchema<undefined>;
|
|
70
|
+
}, undefined>, undefined>, undefined>;
|
|
71
|
+
readonly follow_ups: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
72
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
73
|
+
readonly chat_title: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
74
|
+
readonly timestamp: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
75
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
+
readonly excerpt: v.StringSchema<undefined>;
|
|
77
|
+
}, undefined>, undefined>, undefined>;
|
|
78
|
+
readonly outgoing: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
79
|
+
readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
80
|
+
readonly message: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
81
|
+
readonly kind: v.StringSchema<undefined>;
|
|
82
|
+
readonly position: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
83
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
84
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
86
|
+
readonly mime: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
87
|
+
readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
88
|
+
readonly width: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
89
|
+
readonly height: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
90
|
+
readonly duration: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
91
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
92
|
+
readonly extraction: v.OptionalSchema<v.StrictObjectSchema<{
|
|
93
|
+
readonly origin: v.StringSchema<undefined>;
|
|
94
|
+
readonly extractor: v.StringSchema<undefined>;
|
|
95
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
96
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
97
|
+
}, undefined>, undefined>;
|
|
98
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
99
|
+
readonly contact: v.OptionalSchema<v.StrictObjectSchema<{
|
|
100
|
+
readonly name: v.StringSchema<undefined>;
|
|
101
|
+
readonly first_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
102
|
+
readonly last_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
103
|
+
readonly phone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
104
|
+
readonly user_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
105
|
+
}, undefined>, undefined>;
|
|
106
|
+
readonly buttons: v.OptionalSchema<v.ArraySchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
107
|
+
readonly kind: v.PicklistSchema<["callback", "link", "message", "chat", "contact", "location", "app", "clipboard", "other"], undefined>;
|
|
108
|
+
readonly text: v.StringSchema<undefined>;
|
|
109
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
110
|
+
}, undefined>, undefined>, undefined>, undefined>;
|
|
111
|
+
}, undefined>, undefined>;
|
|
112
|
+
readonly reply_to: v.NullableSchema<v.StrictObjectSchema<{
|
|
113
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
114
|
+
readonly sender_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
115
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
116
|
+
readonly timestamp: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
117
|
+
readonly text: v.StringSchema<undefined>;
|
|
118
|
+
readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
119
|
+
readonly message: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
120
|
+
readonly kind: v.StringSchema<undefined>;
|
|
121
|
+
readonly position: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
122
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
123
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
124
|
+
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
125
|
+
readonly mime: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
126
|
+
readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
127
|
+
readonly width: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
128
|
+
readonly height: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
129
|
+
readonly duration: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
130
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
131
|
+
readonly extraction: v.OptionalSchema<v.StrictObjectSchema<{
|
|
132
|
+
readonly origin: v.StringSchema<undefined>;
|
|
133
|
+
readonly extractor: v.StringSchema<undefined>;
|
|
134
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
135
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
136
|
+
}, undefined>, undefined>;
|
|
137
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
138
|
+
readonly contact: v.OptionalSchema<v.StrictObjectSchema<{
|
|
139
|
+
readonly name: v.StringSchema<undefined>;
|
|
140
|
+
readonly first_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
141
|
+
readonly last_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
142
|
+
readonly phone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
143
|
+
readonly user_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
144
|
+
}, undefined>, undefined>;
|
|
145
|
+
readonly buttons: v.OptionalSchema<v.ArraySchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
146
|
+
readonly kind: v.PicklistSchema<["callback", "link", "message", "chat", "contact", "location", "app", "clipboard", "other"], undefined>;
|
|
147
|
+
readonly text: v.StringSchema<undefined>;
|
|
148
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
149
|
+
}, undefined>, undefined>, undefined>, undefined>;
|
|
150
|
+
}, undefined>, undefined>;
|
|
151
|
+
readonly outgoing: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
152
|
+
}, undefined>, undefined>;
|
|
153
|
+
readonly reply_to_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
154
|
+
readonly forwarded_from: v.NullableSchema<v.StrictObjectSchema<{
|
|
155
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
156
|
+
readonly sender_id: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
157
|
+
readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
158
|
+
readonly timestamp: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
159
|
+
readonly text: v.StringSchema<undefined>;
|
|
160
|
+
readonly attachments: v.ArraySchema<v.StrictObjectSchema<{
|
|
161
|
+
readonly message: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
162
|
+
readonly kind: v.StringSchema<undefined>;
|
|
163
|
+
readonly position: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
164
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
165
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
166
|
+
readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
167
|
+
readonly mime: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
168
|
+
readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
169
|
+
readonly width: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
170
|
+
readonly height: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
171
|
+
readonly duration: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
172
|
+
readonly text: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
173
|
+
readonly extraction: v.OptionalSchema<v.StrictObjectSchema<{
|
|
174
|
+
readonly origin: v.StringSchema<undefined>;
|
|
175
|
+
readonly extractor: v.StringSchema<undefined>;
|
|
176
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
177
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
178
|
+
}, undefined>, undefined>;
|
|
179
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
180
|
+
readonly contact: v.OptionalSchema<v.StrictObjectSchema<{
|
|
181
|
+
readonly name: v.StringSchema<undefined>;
|
|
182
|
+
readonly first_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
183
|
+
readonly last_name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
184
|
+
readonly phone: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
185
|
+
readonly user_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
186
|
+
}, undefined>, undefined>;
|
|
187
|
+
readonly buttons: v.OptionalSchema<v.ArraySchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
188
|
+
readonly kind: v.PicklistSchema<["callback", "link", "message", "chat", "contact", "location", "app", "clipboard", "other"], undefined>;
|
|
189
|
+
readonly text: v.StringSchema<undefined>;
|
|
190
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
191
|
+
}, undefined>, undefined>, undefined>, undefined>;
|
|
192
|
+
}, undefined>, undefined>;
|
|
193
|
+
readonly outgoing: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
194
|
+
}, undefined>, undefined>;
|
|
195
|
+
readonly thread_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
196
|
+
readonly thread_root_id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
197
|
+
readonly reactions: v.OptionalSchema<v.NullableSchema<v.StrictObjectSchema<{
|
|
198
|
+
readonly counts: v.ArraySchema<v.StrictObjectSchema<{
|
|
199
|
+
readonly reaction: v.StringSchema<undefined>;
|
|
200
|
+
readonly count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
201
|
+
}, undefined>, undefined>;
|
|
202
|
+
readonly mine: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
203
|
+
readonly total: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
204
|
+
}, undefined>, undefined>, undefined>;
|
|
205
|
+
readonly scheduled_for: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
206
|
+
readonly starred: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
207
|
+
readonly delivery: v.OptionalSchema<v.PicklistSchema<["delivered", "read"], undefined>, undefined>;
|
|
208
|
+
readonly email: v.OptionalSchema<v.StrictObjectSchema<{
|
|
209
|
+
readonly subject: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
210
|
+
readonly from: v.NullableSchema<v.StrictObjectSchema<{
|
|
211
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
212
|
+
readonly address: v.StringSchema<undefined>;
|
|
213
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
214
|
+
}, undefined>, undefined>;
|
|
215
|
+
readonly to: v.ArraySchema<v.StrictObjectSchema<{
|
|
216
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
217
|
+
readonly address: v.StringSchema<undefined>;
|
|
218
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
219
|
+
}, undefined>, undefined>;
|
|
220
|
+
readonly cc: v.ArraySchema<v.StrictObjectSchema<{
|
|
221
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
222
|
+
readonly address: v.StringSchema<undefined>;
|
|
223
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
224
|
+
}, undefined>, undefined>;
|
|
225
|
+
readonly bcc: v.ArraySchema<v.StrictObjectSchema<{
|
|
226
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
227
|
+
readonly address: v.StringSchema<undefined>;
|
|
228
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
229
|
+
}, undefined>, undefined>;
|
|
230
|
+
readonly reply_addresses: v.ArraySchema<v.StrictObjectSchema<{
|
|
231
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
232
|
+
readonly address: v.StringSchema<undefined>;
|
|
233
|
+
readonly ref: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
234
|
+
}, undefined>, undefined>;
|
|
235
|
+
readonly labels: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
236
|
+
readonly thread: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
237
|
+
readonly read: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
238
|
+
readonly flagged: v.NullableSchema<v.BooleanSchema<undefined>, undefined>;
|
|
239
|
+
readonly sender_score: v.OptionalSchema<v.StrictObjectSchema<{
|
|
240
|
+
readonly score: v.NumberSchema<undefined>;
|
|
241
|
+
readonly signals: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
242
|
+
readonly demoted: v.OptionalSchema<v.LiteralSchema<true, undefined>, undefined>;
|
|
243
|
+
}, undefined>, undefined>;
|
|
244
|
+
readonly bulk: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
245
|
+
readonly list_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
246
|
+
readonly rule_id: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
247
|
+
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
248
|
+
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
249
|
+
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
250
|
+
}, undefined>, undefined>;
|
|
251
|
+
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
252
|
+
}, undefined>, undefined>;
|
|
253
|
+
};
|
|
254
|
+
type ScheduledSendEntriesOf = typeof scheduledSendEntries;
|
|
255
|
+
export interface ScheduledSendEntries extends ScheduledSendEntriesOf {
|
|
256
|
+
}
|
|
257
|
+
/** `sent` holds the scheduled ids; `messages` the messages as sent, with their new ids. */
|
|
258
|
+
export declare const scheduledSend: v.StrictObjectSchema<ScheduledSendEntries, undefined>;
|
|
259
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { id } from "./fields.js";
|
|
3
|
+
import { message } from "./message.js";
|
|
3
4
|
const operated = { operation_id: id, chat_id: id };
|
|
4
5
|
export const messagePin = v.strictObject({ ...operated, message_id: id, pinned: v.boolean() });
|
|
5
6
|
export const messageStar = v.strictObject({ ...operated, message_id: id, starred: v.boolean() });
|
|
6
7
|
export const messageDeletion = v.strictObject({ ...operated, deleted: v.array(id), for_everyone: v.boolean() });
|
|
8
|
+
/** Scheduled ids, which are never the ids of sent messages. */
|
|
9
|
+
export const scheduledCancellation = v.strictObject({ ...operated, cancelled: v.array(id) });
|
|
10
|
+
const scheduledSendEntries = { ...operated, sent: v.array(id), messages: v.array(message) };
|
|
11
|
+
/** `sent` holds the scheduled ids; `messages` the messages as sent, with their new ids. */
|
|
12
|
+
export const scheduledSend = v.strictObject(scheduledSendEntries);
|
package/dist/kit/fake.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AccountEditing, AccountTools, ChatFolders, ChatReading, ContactBook, GroupAdmin, GroupModeration, LiveUpdates, MessageEditing, MessageMedia, MessagePins, MessagePolls, MessageReactions, MessageStars, MessengerCore, PassiveUpdates, PushedHistory, ReadState, ScheduledMessages, ServerReads, TopicReadState } from "../ports/messenger.js";
|
|
1
|
+
import type { AccountEditing, AccountTools, ChatFolders, ChatReading, ContactBook, GroupAdmin, GroupModeration, LiveUpdates, MessageEditing, MessageMedia, MessagePins, MessagePolls, MessageReactions, MessageStars, MessengerCore, PassiveUpdates, PushedHistory, ReadState, ScheduledChanges, ScheduledMessages, ServerReads, TopicReadState } from "../ports/messenger.js";
|
|
2
2
|
import { type Seed } from "./seed.js";
|
|
3
3
|
/** Every group of the port, over memory. */
|
|
4
|
-
export type FakeAdapter = MessengerCore & ServerReads & ChatReading & MessageEditing & MessagePins & MessageStars & MessageReactions & ReadState & TopicReadState & MessagePolls & LiveUpdates & MessageMedia & ScheduledMessages & GroupModeration & AccountTools & GroupAdmin & ChatFolders & ContactBook & AccountEditing & Partial<PushedHistory> & Partial<PassiveUpdates>;
|
|
4
|
+
export type FakeAdapter = MessengerCore & ServerReads & ChatReading & MessageEditing & MessagePins & MessageStars & MessageReactions & ReadState & TopicReadState & MessagePolls & LiveUpdates & MessageMedia & ScheduledMessages & ScheduledChanges & GroupModeration & AccountTools & GroupAdmin & ChatFolders & ContactBook & AccountEditing & Partial<PushedHistory> & Partial<PassiveUpdates>;
|
|
5
5
|
export declare const fakeAdapter: (seed?: Seed, options?: {
|
|
6
6
|
feed?: boolean;
|
|
7
7
|
listen?: boolean;
|
package/dist/kit/fake.js
CHANGED
|
@@ -84,6 +84,12 @@ export const fakeAdapter = (seed = contractSeed(), options = {}) => {
|
|
|
84
84
|
return pickChat(reference, state.chats);
|
|
85
85
|
};
|
|
86
86
|
const messagesOf = (chatId) => state.messages.filter((message) => message.chatId === chatId);
|
|
87
|
+
const scheduledAt = (chatId, id) => {
|
|
88
|
+
const at = scheduled.findIndex((message) => message.chatId === chatId && message.id === id);
|
|
89
|
+
if (at === -1)
|
|
90
|
+
throw missing(`scheduled message ${id} in chat ${chatId}`);
|
|
91
|
+
return at;
|
|
92
|
+
};
|
|
87
93
|
const messageOf = (chatId, messageId) => {
|
|
88
94
|
const found = state.messages.find((message) => message.chatId === chatId && message.id === messageId);
|
|
89
95
|
if (!found)
|
|
@@ -360,6 +366,21 @@ export const fakeAdapter = (seed = contractSeed(), options = {}) => {
|
|
|
360
366
|
const chat = chatOf(reference);
|
|
361
367
|
return structuredClone(scheduled.filter((message) => message.chatId === chat.id));
|
|
362
368
|
},
|
|
369
|
+
cancelScheduled: async (chatId, ids) => {
|
|
370
|
+
for (const id of ids)
|
|
371
|
+
scheduled.splice(scheduledAt(chatId, id), 1);
|
|
372
|
+
},
|
|
373
|
+
editScheduled: async (chatId, id, { text, at }) => {
|
|
374
|
+
const message = scheduled[scheduledAt(chatId, id)];
|
|
375
|
+
if (text !== undefined)
|
|
376
|
+
message.text = text;
|
|
377
|
+
message.scheduledFor = at;
|
|
378
|
+
return structuredClone(message);
|
|
379
|
+
},
|
|
380
|
+
sendScheduled: async (chatId, ids) => ids.map((id) => {
|
|
381
|
+
const [waiting] = scheduled.splice(scheduledAt(chatId, id), 1);
|
|
382
|
+
return structuredClone(post(chatOf(chatId), waiting.text, { attachments: waiting.attachments }));
|
|
383
|
+
}),
|
|
363
384
|
members: async (reference, window) => {
|
|
364
385
|
const chat = chatOf(reference);
|
|
365
386
|
const ruling = admins.get(chat.id) ?? [];
|
package/dist/mcp/surface.js
CHANGED
|
@@ -80,7 +80,7 @@ export const search = (commands, query) => {
|
|
|
80
80
|
.filter((word) => word.length > 1 && !STOP_WORDS.has(word))
|
|
81
81
|
.map(stem)),
|
|
82
82
|
];
|
|
83
|
-
return all
|
|
83
|
+
return (all
|
|
84
84
|
.map((entry) => {
|
|
85
85
|
const fields = fieldsOf(entry[0], entry[1]);
|
|
86
86
|
const weights = words.map((word) => fields.reduce((best, [weight, known]) => (known.some((one) => sameWord(word, one)) ? Math.max(best, weight) : best), 0));
|
|
@@ -89,8 +89,11 @@ export const search = (commands, query) => {
|
|
|
89
89
|
return { entry, matched, rank: (exact ? 1000 : 0) + matched * 10 + weights.reduce((a, b) => a + b, 0) };
|
|
90
90
|
})
|
|
91
91
|
.filter(({ matched, rank }) => matched > 0 || rank >= 1000)
|
|
92
|
-
|
|
93
|
-
.
|
|
92
|
+
// A tie goes to the shorter name, which holds less the task did not ask for: `messages send` first.
|
|
93
|
+
.sort((a, b) => b.rank - a.rank ||
|
|
94
|
+
wordsOf(a.entry[0]).length - wordsOf(b.entry[0]).length ||
|
|
95
|
+
a.entry[0].localeCompare(b.entry[0]))
|
|
96
|
+
.map(({ entry }) => entry));
|
|
94
97
|
};
|
|
95
98
|
const nearest = (commands, asked) => {
|
|
96
99
|
const words = normal(asked).split(" ");
|
|
@@ -485,6 +485,25 @@ export interface ScheduledMessages {
|
|
|
485
485
|
/** Messages waiting to be sent later in a chat, soonest first, each with `scheduledFor`. */
|
|
486
486
|
scheduled(chat: string): Promise<Message[]>;
|
|
487
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* Changes to what `scheduled` lists. An id here is one `scheduled` gave: a scheduled message has ids of its own, and
|
|
490
|
+
* the same number in the chat's history is another, already sent message.
|
|
491
|
+
*/
|
|
492
|
+
export interface ScheduledChanges {
|
|
493
|
+
/** Takes them off the list unsent; nobody can get them back. */
|
|
494
|
+
cancelScheduled(chatId: Id, ids: Id[]): Promise<void>;
|
|
495
|
+
/**
|
|
496
|
+
* New text, a new time, or both; the answer is the message as it now waits. `at` is always given, the current time
|
|
497
|
+
* when only the text changes, as the messenger may take the id for a sent message's without it.
|
|
498
|
+
*/
|
|
499
|
+
editScheduled(chatId: Id, id: Id, change: {
|
|
500
|
+
text?: string;
|
|
501
|
+
formatting?: TextSpan[];
|
|
502
|
+
at: string;
|
|
503
|
+
}): Promise<Message>;
|
|
504
|
+
/** Sends them now; the answer is the messages as sent, with their new ids. */
|
|
505
|
+
sendScheduled(chatId: Id, ids: Id[]): Promise<Message[]>;
|
|
506
|
+
}
|
|
488
507
|
/** Who is in a group, who runs it, and who came and went. */
|
|
489
508
|
export interface GroupModeration {
|
|
490
509
|
/**
|
|
@@ -703,7 +722,7 @@ export interface AccountHealth {
|
|
|
703
722
|
* be held to all of it. A method added from now on goes into a group, never the core, and returns a
|
|
704
723
|
* promise: the wrappers time and pass it through without being told about it (`throughWrapper`).
|
|
705
724
|
*/
|
|
706
|
-
export interface MessengerAdapter extends MessengerCore, Partial<MarkdownFormatting>, Partial<HtmlFormatting>, Partial<ServerReads>, Partial<PersonProfiles>, Partial<ChatReading>, Partial<SenderSearch>, Partial<MessageSearch>, Partial<MessageEditing>, Partial<MessagePins>, Partial<MessageStars>, Partial<MessageReactions>, Partial<ReadState>, Partial<TopicReadState>, Partial<MessagePolls>, Partial<MessageButtons>, Partial<BotChats>, Partial<ThreadAddressing>, Partial<TopicHistory>, Partial<ForumControl>, Partial<TopicEditing>, Partial<LiveUpdates>, Partial<PassiveUpdates>, Partial<PushedHistory>, Partial<MessageMedia>, Partial<ScheduledMessages>, Partial<ChannelComments>, Partial<MessagePermalinks>, Partial<SenderIdentities>, Partial<GroupModeration>, Partial<AccountTools>, Partial<ProfilePhotos>, Partial<GroupAdmin>, Partial<JoinRequests>, Partial<InviteLinks>, Partial<ChatFolders>, Partial<ContactBook>, Partial<AccountEditing>, Partial<AccountRecords>, Partial<AccountSettings>, Partial<ChatDeletion>, Partial<AccountHealth>, Partial<OfficialStats> {
|
|
725
|
+
export interface MessengerAdapter extends MessengerCore, Partial<MarkdownFormatting>, Partial<HtmlFormatting>, Partial<ServerReads>, Partial<PersonProfiles>, Partial<ChatReading>, Partial<SenderSearch>, Partial<MessageSearch>, Partial<MessageEditing>, Partial<MessagePins>, Partial<MessageStars>, Partial<MessageReactions>, Partial<ReadState>, Partial<TopicReadState>, Partial<MessagePolls>, Partial<MessageButtons>, Partial<BotChats>, Partial<ThreadAddressing>, Partial<TopicHistory>, Partial<ForumControl>, Partial<TopicEditing>, Partial<LiveUpdates>, Partial<PassiveUpdates>, Partial<PushedHistory>, Partial<MessageMedia>, Partial<ScheduledMessages>, Partial<ScheduledChanges>, Partial<ChannelComments>, Partial<MessagePermalinks>, Partial<SenderIdentities>, Partial<GroupModeration>, Partial<AccountTools>, Partial<ProfilePhotos>, Partial<GroupAdmin>, Partial<JoinRequests>, Partial<InviteLinks>, Partial<ChatFolders>, Partial<ContactBook>, Partial<AccountEditing>, Partial<AccountRecords>, Partial<AccountSettings>, Partial<ChatDeletion>, Partial<AccountHealth>, Partial<OfficialStats> {
|
|
707
726
|
}
|
|
708
727
|
type Method = (...args: never[]) => unknown;
|
|
709
728
|
/**
|
|
@@ -2,7 +2,14 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
/** What a profile may do with one command path — the standard's "Permissions". */
|
|
3
3
|
export const LEVELS = ["deny", "readonly", "ask", "allow"];
|
|
4
4
|
/** The deletions nobody gets back: the word that skips their question is `--allow-dangerous`, never `--yes`. */
|
|
5
|
-
const DANGEROUS = new Set([
|
|
5
|
+
const DANGEROUS = new Set([
|
|
6
|
+
"messages.delete",
|
|
7
|
+
"messages.scheduled.cancel",
|
|
8
|
+
"bot.messages.delete",
|
|
9
|
+
"topics.delete",
|
|
10
|
+
"chats.delete",
|
|
11
|
+
"chats.clear",
|
|
12
|
+
]);
|
|
6
13
|
/** Deleting has its own word for "yes": the flag a person has to mean, not a habit (max-cli `NEED-238`). */
|
|
7
14
|
export const skipFlagFor = (key) => DANGEROUS.has(key) ? "--allow-dangerous" : "--yes";
|
|
8
15
|
/** Only what cannot be undone asks; the tool is meant to work without questions (owner, NEED-460). */
|
|
@@ -268,6 +275,9 @@ const NAMED_WRITE_KEYS = [
|
|
|
268
275
|
"messages.sync-first",
|
|
269
276
|
"messages.server-search",
|
|
270
277
|
"messages.press",
|
|
278
|
+
"messages.scheduled.cancel",
|
|
279
|
+
"messages.scheduled.edit",
|
|
280
|
+
"messages.scheduled.send",
|
|
271
281
|
"chats.start",
|
|
272
282
|
"chats.app",
|
|
273
283
|
"stats.messages.counters.sync",
|
|
@@ -257,6 +257,37 @@ export interface MessagesService {
|
|
|
257
257
|
messages: string[];
|
|
258
258
|
forEveryone: boolean;
|
|
259
259
|
}): Promise<Operated<Deletion>>;
|
|
260
|
+
/**
|
|
261
|
+
* The scheduled messages by the ids `scheduled` lists, each checked against that list first: the same number in the
|
|
262
|
+
* chat's history is another message. Cancelling counts as deleting, sending now as sending.
|
|
263
|
+
*/
|
|
264
|
+
cancelScheduled(request: {
|
|
265
|
+
chat: string;
|
|
266
|
+
ids: string[];
|
|
267
|
+
}): Promise<Operated<{
|
|
268
|
+
chatId: Id;
|
|
269
|
+
cancelled: Id[];
|
|
270
|
+
}>>;
|
|
271
|
+
/** New text, a new time (`at`), or both. */
|
|
272
|
+
editScheduled(request: {
|
|
273
|
+
chat: string;
|
|
274
|
+
id: string;
|
|
275
|
+
text?: string;
|
|
276
|
+
markdown?: boolean;
|
|
277
|
+
html?: boolean;
|
|
278
|
+
at?: string;
|
|
279
|
+
}): Promise<Operated<{
|
|
280
|
+
message: Message;
|
|
281
|
+
scheduledFor: string;
|
|
282
|
+
}>>;
|
|
283
|
+
sendScheduled(request: {
|
|
284
|
+
chat: string;
|
|
285
|
+
ids: string[];
|
|
286
|
+
}): Promise<Operated<{
|
|
287
|
+
chatId: Id;
|
|
288
|
+
sent: Id[];
|
|
289
|
+
messages: Message[];
|
|
290
|
+
}>>;
|
|
260
291
|
/** Guarded against the chat it goes to: that is where somebody new reads it. */
|
|
261
292
|
forward(target: MessageTarget & {
|
|
262
293
|
to: string;
|
|
@@ -22,6 +22,10 @@ import { searchServer, sourceKey, } from "./server-search.js";
|
|
|
22
22
|
import { readThreadContext, threadBounds } from "./thread-context.js";
|
|
23
23
|
/** max-cli's: many at once is what a ban for automation looks like. */
|
|
24
24
|
export const DELETE_AT_ONCE = 10;
|
|
25
|
+
const atOnce = (ids) => {
|
|
26
|
+
if (ids.length > DELETE_AT_ONCE)
|
|
27
|
+
throw new CliError("validation_error", `at most ${DELETE_AT_ONCE} messages at once, got ${ids.length}`);
|
|
28
|
+
};
|
|
25
29
|
/** Every write goes through the guard: asked before it goes, told after, on every outcome. */
|
|
26
30
|
/** Only a message with files says what can be linked of them. */
|
|
27
31
|
const filesOf = ({ attachments }) => {
|
|
@@ -69,6 +73,17 @@ export const messagesService = (deps) => {
|
|
|
69
73
|
})
|
|
70
74
|
.catch(() => undefined);
|
|
71
75
|
};
|
|
76
|
+
/** The chat and its scheduled messages by the ids asked for; an id it does not list is refused before any write. */
|
|
77
|
+
const waiting = async (connection, chat, ids) => {
|
|
78
|
+
const list = capability(connection, "scheduled", "list scheduled messages");
|
|
79
|
+
const { id: chatId } = await connection.resolve(chat);
|
|
80
|
+
const queued = await list(chatId);
|
|
81
|
+
const unknown = ids.filter((id) => !queued.some((message) => message.id === id));
|
|
82
|
+
if (unknown.length > 0)
|
|
83
|
+
throw new CliError("not_found", `nothing scheduled in this chat has the id ${unknown.join(", ")} — a scheduled message has an id of ` +
|
|
84
|
+
`its own, not the one of a sent message; \`messages scheduled ${chat}\` lists them`, { sent: false });
|
|
85
|
+
return { chatId, found: ids.map((id) => queued.find((message) => message.id === id)) };
|
|
86
|
+
};
|
|
72
87
|
const pinning = async ({ chat, message }, pinned, asked, requested) => {
|
|
73
88
|
const allowed = deps.messenger.pinDurations;
|
|
74
89
|
if (requested !== undefined && !allowed?.includes(requested))
|
|
@@ -398,6 +413,53 @@ export const messagesService = (deps) => {
|
|
|
398
413
|
await guardedWrite(guard, { operationId, chatId, kind: "delete", count: messages.length, forEveryone }, () => remove(chatId, messages, { forEveryone }));
|
|
399
414
|
return { operationId, chatId, deleted: messages, forEveryone };
|
|
400
415
|
},
|
|
416
|
+
cancelScheduled: async ({ chat, ids }) => {
|
|
417
|
+
atOnce(ids);
|
|
418
|
+
const connection = await deps.connection();
|
|
419
|
+
const cancel = capability(connection, "cancelScheduled", "cancel a scheduled message");
|
|
420
|
+
const { chatId } = await waiting(connection, chat, ids);
|
|
421
|
+
const operationId = newOperationId();
|
|
422
|
+
await guardedWrite(guard, { operationId, chatId, kind: "delete", key: "messages.scheduled.cancel", count: ids.length }, () => cancel(chatId, ids));
|
|
423
|
+
return { operationId, chatId, cancelled: ids };
|
|
424
|
+
},
|
|
425
|
+
editScheduled: async ({ chat, id, text: typed, markdown, html, at }) => {
|
|
426
|
+
if (typed === undefined && at === undefined)
|
|
427
|
+
throw new CliError("validation_error", "nothing to change — give the new text, --at-time, or both");
|
|
428
|
+
const connection = await deps.connection();
|
|
429
|
+
const edit = capability(connection, "editScheduled", "edit a scheduled message");
|
|
430
|
+
const prepared = typed === undefined ? undefined : await formatted(connection, typed, { markdown, html });
|
|
431
|
+
const change = prepared && (deps.agentText ? visibleFormattedText(prepared) : prepared);
|
|
432
|
+
if (change !== undefined && change.text.trim() === "")
|
|
433
|
+
throw new CliError("validation_error", "no new text — the marks leave nothing");
|
|
434
|
+
const { chatId, found: [current], } = await waiting(connection, chat, [id]);
|
|
435
|
+
const scheduledFor = at ?? current?.scheduledFor ?? current?.timestamp;
|
|
436
|
+
if (scheduledFor === undefined)
|
|
437
|
+
throw new CliError("invalid_response", "the scheduled message has no time");
|
|
438
|
+
const operationId = newOperationId();
|
|
439
|
+
const message = await guardedWrite(guard, {
|
|
440
|
+
operationId,
|
|
441
|
+
chatId,
|
|
442
|
+
kind: "edit",
|
|
443
|
+
key: "messages.scheduled.edit",
|
|
444
|
+
messageId: id,
|
|
445
|
+
scheduledFor,
|
|
446
|
+
...(change === undefined ? {} : { length: change.text.length }),
|
|
447
|
+
}, () => edit(chatId, id, {
|
|
448
|
+
at: scheduledFor,
|
|
449
|
+
...(change === undefined ? {} : { text: change.text }),
|
|
450
|
+
...(change === undefined || change.spans.length === 0 ? {} : { formatting: change.spans }),
|
|
451
|
+
}));
|
|
452
|
+
return { operationId, message, scheduledFor };
|
|
453
|
+
},
|
|
454
|
+
sendScheduled: async ({ chat, ids }) => {
|
|
455
|
+
atOnce(ids);
|
|
456
|
+
const connection = await deps.connection();
|
|
457
|
+
const send = capability(connection, "sendScheduled", "send a scheduled message now");
|
|
458
|
+
const { chatId } = await waiting(connection, chat, ids);
|
|
459
|
+
const operationId = newOperationId();
|
|
460
|
+
const messages = await guardedWrite(guard, { operationId, chatId, kind: "message", key: "messages.scheduled.send", count: ids.length }, () => send(chatId, ids));
|
|
461
|
+
return { operationId, chatId, sent: ids, messages };
|
|
462
|
+
},
|
|
401
463
|
forward: async ({ chat, message, to, silent, sendId, sendAs, threadId: typedThread }) => {
|
|
402
464
|
const connection = await deps.connection();
|
|
403
465
|
const forward = capability(connection, "forward", "forward a message");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.706.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
"@types/pngjs": "6.0.5",
|
|
327
327
|
"@types/ssh2": "1.15.5",
|
|
328
328
|
"@vitest/coverage-v8": "^5.0.5",
|
|
329
|
-
"@wirecat/cli-base": "0.
|
|
329
|
+
"@wirecat/cli-base": "0.122.0",
|
|
330
330
|
"@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
|
|
331
331
|
"ajv": "8.17.1",
|
|
332
332
|
"commander": "15.0.0",
|