@leemour/cli-messaging 0.88.0 → 0.89.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/dist/cli/bot/port.d.ts +29 -0
- package/dist/cli/bot/port.d.ts.map +1 -0
- package/dist/cli/bot/port.js +2 -0
- package/dist/cli/bot/port.js.map +1 -0
- package/dist/cli/bot/registry.d.ts +37 -0
- package/dist/cli/bot/registry.d.ts.map +1 -0
- package/dist/cli/bot/registry.js +94 -0
- package/dist/cli/bot/registry.js.map +1 -0
- package/dist/cli/bot/token.d.ts +25 -0
- package/dist/cli/bot/token.d.ts.map +1 -0
- package/dist/cli/bot/token.js +36 -0
- package/dist/cli/bot/token.js.map +1 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/messenger/after.d.ts +18 -5
- package/dist/cli/messenger/after.d.ts.map +1 -1
- package/dist/cli/messenger/after.js +19 -31
- package/dist/cli/messenger/after.js.map +1 -1
- package/dist/cli/messenger/conversations-command.d.ts +10 -0
- package/dist/cli/messenger/conversations-command.d.ts.map +1 -0
- package/dist/cli/messenger/conversations-command.js +101 -0
- package/dist/cli/messenger/conversations-command.js.map +1 -0
- package/dist/cli/messenger/messages-command.d.ts.map +1 -1
- package/dist/cli/messenger/messages-command.js +6 -7
- package/dist/cli/messenger/messages-command.js.map +1 -1
- package/dist/cli/messenger/server-command.d.ts.map +1 -1
- package/dist/cli/messenger/server-command.js +18 -9
- package/dist/cli/messenger/server-command.js.map +1 -1
- package/dist/cli/messenger/store-maintenance-command.d.ts.map +1 -1
- package/dist/cli/messenger/store-maintenance-command.js +34 -0
- package/dist/cli/messenger/store-maintenance-command.js.map +1 -1
- package/dist/conversations/link.d.ts +2 -2
- package/dist/conversations/link.d.ts.map +1 -1
- package/dist/conversations/link.js +6 -4
- package/dist/conversations/link.js.map +1 -1
- package/dist/domain/models.d.ts +2 -0
- package/dist/domain/models.d.ts.map +1 -1
- package/dist/mcp/confirm.js +1 -1
- package/dist/mcp/confirm.js.map +1 -1
- package/dist/mcp/tool.d.ts +2 -0
- package/dist/mcp/tool.d.ts.map +1 -1
- package/dist/mcp/tool.js +2 -0
- package/dist/mcp/tool.js.map +1 -1
- package/dist/mcp/tools/chats.d.ts.map +1 -1
- package/dist/mcp/tools/chats.js +13 -8
- package/dist/mcp/tools/chats.js.map +1 -1
- package/dist/mcp/tools/conversations.d.ts +5 -0
- package/dist/mcp/tools/conversations.d.ts.map +1 -0
- package/dist/mcp/tools/conversations.js +56 -0
- package/dist/mcp/tools/conversations.js.map +1 -0
- package/dist/mcp/tools/inbox.js +3 -3
- package/dist/mcp/tools/inbox.js.map +1 -1
- package/dist/mcp/tools/messages-send.js +4 -4
- package/dist/mcp/tools/messages-send.js.map +1 -1
- package/dist/mcp/tools/messages.d.ts.map +1 -1
- package/dist/mcp/tools/messages.js +25 -18
- package/dist/mcp/tools/messages.js.map +1 -1
- package/dist/mcp/tools/review.d.ts.map +1 -1
- package/dist/mcp/tools/review.js +3 -3
- package/dist/mcp/tools/review.js.map +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +2 -0
- package/dist/mcp/tools.js.map +1 -1
- package/dist/parity/bin.js +15 -2
- package/dist/parity/bin.js.map +1 -1
- package/dist/parity/index.d.ts +1 -0
- package/dist/parity/index.d.ts.map +1 -1
- package/dist/parity/index.js +1 -0
- package/dist/parity/index.js.map +1 -1
- package/dist/parity/wording.d.ts +7 -0
- package/dist/parity/wording.d.ts.map +1 -0
- package/dist/parity/wording.js +31 -0
- package/dist/parity/wording.js.map +1 -0
- package/dist/sends/permissions.js +1 -1
- package/dist/sends/permissions.js.map +1 -1
- package/dist/services/conversations.d.ts +45 -0
- package/dist/services/conversations.d.ts.map +1 -0
- package/dist/services/conversations.js +92 -0
- package/dist/services/conversations.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -1
- package/dist/store/sqlite/conversations.d.ts +45 -0
- package/dist/store/sqlite/conversations.d.ts.map +1 -0
- package/dist/store/sqlite/conversations.js +309 -0
- package/dist/store/sqlite/conversations.js.map +1 -0
- package/dist/store/sqlite/messages.d.ts.map +1 -1
- package/dist/store/sqlite/messages.js +2 -0
- package/dist/store/sqlite/messages.js.map +1 -1
- package/dist/store/sqlite/reads.d.ts +50 -0
- package/dist/store/sqlite/reads.d.ts.map +1 -1
- package/dist/store/sqlite/reads.js +2 -1
- package/dist/store/sqlite/reads.js.map +1 -1
- package/dist/store/sqlite/search.d.ts +33 -0
- package/dist/store/sqlite/search.d.ts.map +1 -1
- package/dist/store/store.d.ts +70 -0
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +46 -0
- package/dist/store/store.js.map +1 -1
- package/package.json +1 -1
- package/parity.json +43 -17
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { Provider } from "../../domain/models.js";
|
|
3
|
+
import type { AppIdentity } from "../app.js";
|
|
4
|
+
import type { MessengerCore } from "../messenger/port.js";
|
|
5
|
+
import type { GlobalFlags, ResolveOptions, Settings } from "../settings.js";
|
|
6
|
+
import type { ChatRegistry } from "./registry.js";
|
|
7
|
+
import type { BotTokenStore } from "./token.js";
|
|
8
|
+
/**
|
|
9
|
+
* The part of the personal core a bot can do. It grows as bot commands move here; a bot never gets
|
|
10
|
+
* `chats` or `history` from this type, because neither Bot API lists a bot's chats.
|
|
11
|
+
*/
|
|
12
|
+
export type BotAdapter = Pick<MessengerCore, "me" | "close">;
|
|
13
|
+
/** What one messenger CLI hands the shared bot commands. */
|
|
14
|
+
export interface BotMessenger {
|
|
15
|
+
app: AppIdentity;
|
|
16
|
+
/** How the store tells this messenger's bots from its personal accounts: `max-bot`, `telegram-bot`. */
|
|
17
|
+
provider: Provider;
|
|
18
|
+
/** The messenger's own name, as its users write it — `MAX`, `Telegram`. */
|
|
19
|
+
name?: string;
|
|
20
|
+
/** Called with `kind: "bot"`. */
|
|
21
|
+
resolveSettings: (flags: GlobalFlags, options?: ResolveOptions) => Settings;
|
|
22
|
+
/** A client for this token; `stop` ends a command that runs until told to, and its request in flight. */
|
|
23
|
+
connect: (command: Command, token: string, stop?: AbortSignal) => Promise<BotAdapter>;
|
|
24
|
+
/** Where the token lives; the shared `BotTokenStore` when unset. A CLI's tests put their own here. */
|
|
25
|
+
tokenStore?: (command: Command, profile: string) => BotTokenStore;
|
|
26
|
+
/** The chats the bot has seen; the shared `ChatRegistry` when unset. */
|
|
27
|
+
registry?: (command: Command, profile: string) => ChatRegistry;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=port.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port.d.ts","sourceRoot":"","sources":["../../../src/cli/bot/port.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;AAE5D,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,WAAW,CAAA;IAChB,uGAAuG;IACvG,QAAQ,EAAE,QAAQ,CAAA;IAClB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,eAAe,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,QAAQ,CAAA;IAC3E,yGAAyG;IACzG,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IACrF,sGAAsG;IACtG,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,aAAa,CAAA;IACjE,wEAAwE;IACxE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,YAAY,CAAA;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../../src/cli/bot/port.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Chat } from "../../domain/models.js";
|
|
2
|
+
import type { AppIdentity } from "../app.js";
|
|
3
|
+
export interface SeenChat extends Chat {
|
|
4
|
+
firstSeenAt: string;
|
|
5
|
+
lastSeenAt: string;
|
|
6
|
+
}
|
|
7
|
+
/** Everything this machine keeps about its bots: seen chats, recipients, the send journal. */
|
|
8
|
+
export declare const botsDirectory: (app: AppIdentity, env?: NodeJS.ProcessEnv) => string;
|
|
9
|
+
/** One bot's files. The names are what max-cli has always used: a moved path would lose a recipient list, and with it the limit. */
|
|
10
|
+
export declare const botFiles: (app: AppIdentity, profile: string, env?: NodeJS.ProcessEnv) => {
|
|
11
|
+
registry: string;
|
|
12
|
+
recipients: string;
|
|
13
|
+
journal: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The chats this bot has seen, because neither MAX's nor Telegram's Bot API has a call that lists them.
|
|
17
|
+
*
|
|
18
|
+
* State, not cache: the messenger cannot give it back, so clearing a cache must not take it. Titles
|
|
19
|
+
* are in it, hence 0600.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ChatRegistry {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(app: AppIdentity, profile: string, env?: NodeJS.ProcessEnv);
|
|
24
|
+
list(): SeenChat[];
|
|
25
|
+
/** The bot's own user id, once any command has learned it — the key its messages are stored under. */
|
|
26
|
+
botId(): string | undefined;
|
|
27
|
+
rememberBot(id: string): void;
|
|
28
|
+
/** Makes this bot known to `bot list` before it has seen any chat. */
|
|
29
|
+
touch(): void;
|
|
30
|
+
/** Newer facts win; a chat seen only as an id keeps the title it had. */
|
|
31
|
+
observe(chats: readonly (Partial<Chat> & {
|
|
32
|
+
id: string;
|
|
33
|
+
})[], now?: Date): void;
|
|
34
|
+
}
|
|
35
|
+
/** Every profile that has ever kept a registry — the bots this machine has used. */
|
|
36
|
+
export declare const registryProfiles: (app: AppIdentity, env?: NodeJS.ProcessEnv) => string[];
|
|
37
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/cli/bot/registry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,WAAW,QAAS,SAAQ,IAAI;IACpC,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,8FAA8F;AAC9F,eAAO,MAAM,aAAa,QAAS,WAAW,QAAO,MAAM,CAAC,UAAU,KAAiB,MACC,CAAA;AAExF,oIAAoI;AACpI,eAAO,MAAM,QAAQ,QAAS,WAAW,WAAW,MAAM,QAAO,MAAM,CAAC,UAAU;IAG9E,QAAQ;IACR,UAAU;IACV,OAAO;CAEV,CAAA;AAED;;;;;GAKG;AACH,qBAAa,YAAY;;IAGvB,YAAY,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,EAElF;IAED,IAAI,IAAI,QAAQ,EAAE,CAGjB;IAED,sGAAsG;IACtG,KAAK,IAAI,MAAM,GAAG,SAAS,CAG1B;IAED,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAG5B;IAED,sEAAsE;IACtE,KAAK,IAAI,IAAI,CAEZ;IAED,yEAAyE;IACzE,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,EAAE,GAAG,GAAE,IAAiB,GAAG,IAAI,CAuBxF;CAeF;AAED,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,QAAS,WAAW,QAAO,MAAM,CAAC,UAAU,KAAiB,MAAM,EAO/F,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resolvePaths, writeSecurely } from "@leemour/cli-core";
|
|
4
|
+
/** Everything this machine keeps about its bots: seen chats, recipients, the send journal. */
|
|
5
|
+
export const botsDirectory = (app, env = process.env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "bots");
|
|
6
|
+
/** One bot's files. The names are what max-cli has always used: a moved path would lose a recipient list, and with it the limit. */
|
|
7
|
+
export const botFiles = (app, profile, env = process.env) => {
|
|
8
|
+
const directory = botsDirectory(app, env);
|
|
9
|
+
return {
|
|
10
|
+
registry: join(directory, `${profile}.json`),
|
|
11
|
+
recipients: join(directory, "recipients", `${profile}.json`),
|
|
12
|
+
journal: join(directory, "sends", `${profile}.jsonl`),
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The chats this bot has seen, because neither MAX's nor Telegram's Bot API has a call that lists them.
|
|
17
|
+
*
|
|
18
|
+
* State, not cache: the messenger cannot give it back, so clearing a cache must not take it. Titles
|
|
19
|
+
* are in it, hence 0600.
|
|
20
|
+
*/
|
|
21
|
+
export class ChatRegistry {
|
|
22
|
+
#path;
|
|
23
|
+
constructor(app, profile, env = process.env) {
|
|
24
|
+
this.#path = botFiles(app, profile, env).registry;
|
|
25
|
+
}
|
|
26
|
+
list() {
|
|
27
|
+
const { chats } = this.#read();
|
|
28
|
+
return Array.isArray(chats) ? chats : [];
|
|
29
|
+
}
|
|
30
|
+
/** The bot's own user id, once any command has learned it — the key its messages are stored under. */
|
|
31
|
+
botId() {
|
|
32
|
+
const { botId } = this.#read();
|
|
33
|
+
return typeof botId === "string" ? botId : undefined;
|
|
34
|
+
}
|
|
35
|
+
rememberBot(id) {
|
|
36
|
+
const file = this.#read();
|
|
37
|
+
if (file.botId !== id)
|
|
38
|
+
this.#write({ ...file, botId: id });
|
|
39
|
+
}
|
|
40
|
+
/** Makes this bot known to `bot list` before it has seen any chat. */
|
|
41
|
+
touch() {
|
|
42
|
+
if (!existsSync(this.#path))
|
|
43
|
+
writeSecurely(this.#path, `${JSON.stringify({ chats: [] }, null, 2)}\n`, 0o600);
|
|
44
|
+
}
|
|
45
|
+
/** Newer facts win; a chat seen only as an id keeps the title it had. */
|
|
46
|
+
observe(chats, now = new Date()) {
|
|
47
|
+
if (chats.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
const byId = new Map(this.list().map((chat) => [chat.id, chat]));
|
|
50
|
+
const at = now.toISOString();
|
|
51
|
+
for (const chat of chats) {
|
|
52
|
+
const known = byId.get(chat.id);
|
|
53
|
+
const defined = Object.fromEntries(Object.entries(chat).filter(([, value]) => value !== undefined && value !== null));
|
|
54
|
+
byId.set(chat.id, {
|
|
55
|
+
title: null,
|
|
56
|
+
kind: "unknown",
|
|
57
|
+
unreadCount: null,
|
|
58
|
+
lastMessageAt: null,
|
|
59
|
+
participantsCount: null,
|
|
60
|
+
...known,
|
|
61
|
+
...defined,
|
|
62
|
+
id: chat.id,
|
|
63
|
+
firstSeenAt: known?.firstSeenAt ?? at,
|
|
64
|
+
lastSeenAt: at,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
this.#write({ ...this.#read(), chats: [...byId.values()] });
|
|
68
|
+
}
|
|
69
|
+
#read() {
|
|
70
|
+
if (!existsSync(this.#path))
|
|
71
|
+
return {};
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(readFileSync(this.#path, "utf8"));
|
|
74
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
#write(file) {
|
|
81
|
+
writeSecurely(this.#path, `${JSON.stringify(file, null, 2)}\n`, 0o600);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** Every profile that has ever kept a registry — the bots this machine has used. */
|
|
85
|
+
export const registryProfiles = (app, env = process.env) => {
|
|
86
|
+
const directory = botsDirectory(app, env);
|
|
87
|
+
if (!existsSync(directory))
|
|
88
|
+
return [];
|
|
89
|
+
return readdirSync(directory, { withFileTypes: true })
|
|
90
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
91
|
+
.map((entry) => entry.name)
|
|
92
|
+
.map((name) => name.slice(0, -".json".length));
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/cli/bot/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAS/D,8FAA8F;AAC9F,MAA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EAAY,EAAE;IACnG,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACzC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,EAAE,CAAA;IACrC,OAAO,WAAW,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SACjE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SAC1B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AAClD,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CredentialSource, type KeyringStore } from "@leemour/cli-core";
|
|
2
|
+
import { type AppIdentity } from "../app.js";
|
|
3
|
+
export interface BotTokenStoreOptions {
|
|
4
|
+
app: AppIdentity;
|
|
5
|
+
profile: string;
|
|
6
|
+
env?: NodeJS.ProcessEnv;
|
|
7
|
+
keyring?: KeyringStore;
|
|
8
|
+
configDir?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A bot token per profile, beside — never inside — the personal session: keyring account
|
|
12
|
+
* `bot:<profile>` under the app's own service, `<PREFIX>_BOT_TOKEN`, then a 0600 file.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BotTokenStore {
|
|
15
|
+
#private;
|
|
16
|
+
readonly profile: string;
|
|
17
|
+
constructor({ app, profile, env, keyring, configDir }: BotTokenStoreOptions);
|
|
18
|
+
read(): {
|
|
19
|
+
token: string;
|
|
20
|
+
source: CredentialSource;
|
|
21
|
+
} | undefined;
|
|
22
|
+
write(token: string): CredentialSource;
|
|
23
|
+
remove(): CredentialSource[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/cli/bot/token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,YAAY,EAGlB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,WAAW,CAAA;AAErD,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,WAAW,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;IACvB,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,qBAAa,aAAa;;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAIxB,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,GAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,oBAAoB,EAaxF;IAED,IAAI,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,gBAAgB,CAAA;KAAE,GAAG,SAAS,CAG9D;IAED,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAErC;IAED,MAAM,IAAI,gBAAgB,EAAE,CAE3B;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Credentials, pathsAreOverridden, resolvePaths, } from "@leemour/cli-core";
|
|
2
|
+
import { envName } from "../app.js";
|
|
3
|
+
/**
|
|
4
|
+
* A bot token per profile, beside — never inside — the personal session: keyring account
|
|
5
|
+
* `bot:<profile>` under the app's own service, `<PREFIX>_BOT_TOKEN`, then a 0600 file.
|
|
6
|
+
*/
|
|
7
|
+
export class BotTokenStore {
|
|
8
|
+
profile;
|
|
9
|
+
#account;
|
|
10
|
+
#credentials;
|
|
11
|
+
constructor({ app, profile, env = process.env, keyring, configDir }) {
|
|
12
|
+
const where = { appName: app.appName, prefix: app.envPrefix, env };
|
|
13
|
+
this.profile = profile;
|
|
14
|
+
this.#account = `bot:${profile}`;
|
|
15
|
+
this.#credentials = new Credentials({
|
|
16
|
+
configDir: configDir ?? resolvePaths(where).config,
|
|
17
|
+
service: app.appName,
|
|
18
|
+
envVar: envName(app, "BOT_TOKEN"),
|
|
19
|
+
isolated: pathsAreOverridden(where),
|
|
20
|
+
...(keyring ? { keyring } : {}),
|
|
21
|
+
env,
|
|
22
|
+
warn: (message) => process.stderr.write(`${message}\n`),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
read() {
|
|
26
|
+
const stored = this.#credentials.read(this.#account);
|
|
27
|
+
return stored ? { token: stored.secret, source: stored.source } : undefined;
|
|
28
|
+
}
|
|
29
|
+
write(token) {
|
|
30
|
+
return this.#credentials.write(this.#account, token);
|
|
31
|
+
}
|
|
32
|
+
remove() {
|
|
33
|
+
return this.#credentials.remove(this.#account);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/cli/bot/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAEX,kBAAkB,EAClB,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAoB,OAAO,EAAE,MAAM,WAAW,CAAA;AAUrD;;;GAGG;AACH,MAAM,OAAO,aAAa;IACf,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,YAAY,CAAa;IAElC,YAAY,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAwB;QACvF,MAAM,KAAK,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,S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{ momentOf } from "../services/moment.js";
|
|
4
4
|
export { maskedAccount } from "../services/people.js";
|
|
5
5
|
export { type AppIdentity, envName } from "./app.js";
|
|
6
|
+
export type { BotAdapter, BotMessenger } from "./bot/port.js";
|
|
7
|
+
export { botFiles, botsDirectory, ChatRegistry, registryProfiles, type SeenChat } from "./bot/registry.js";
|
|
8
|
+
export { BotTokenStore, type BotTokenStoreOptions } from "./bot/token.js";
|
|
6
9
|
export { CONTRACT, commandsCommand } from "./commands-command.js";
|
|
7
10
|
export { configCommand } from "./config-command.js";
|
|
8
11
|
export { type BaseContext, type BaseEnvironment, baseContext, environmentOf, outputFor, provide, } from "./context.js";
|
|
@@ -16,6 +19,7 @@ export { markReadCommand } from "./messenger/chats-read-command.js";
|
|
|
16
19
|
export { completeCommand } from "./messenger/complete-command.js";
|
|
17
20
|
export { contactsCommand } from "./messenger/contacts-command.js";
|
|
18
21
|
export { type ConnectOptions, type Fetching, type Messenger, type MessengerContext, messengerContext, } from "./messenger/context.js";
|
|
22
|
+
export { conversationsCommand } from "./messenger/conversations-command.js";
|
|
19
23
|
export { doctorCommand } from "./messenger/doctor-command.js";
|
|
20
24
|
export { recipientsCommand, sendsCommand } from "./messenger/guard-commands.js";
|
|
21
25
|
export { inboxCommand } from "./messenger/inbox.js";
|
package/dist/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,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EAAE,MAAM,aAAa,CAAA;AAChF,OAAO,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,MAAM,EACN,iBAAiB,GAClB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAC/G,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,gBAAgB,EAChB,KAAK,YAAY,EACjB,WAAW,EACX,KAAK,YAAY,GAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,OAAO,EACP,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,QAAQ,EACR,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,KAAK,WAAW,EAChB,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,aAAa,EACb,KAAK,EACL,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,MAAM,EACX,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/cli/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export { INBOX_CHATS, newIn, REVIEW_CHATS, reviewIn, unanswered, unreadIn } from
|
|
|
3
3
|
export { momentOf } from "../services/moment.js";
|
|
4
4
|
export { maskedAccount } from "../services/people.js";
|
|
5
5
|
export { envName } from "./app.js";
|
|
6
|
+
export { botFiles, botsDirectory, ChatRegistry, registryProfiles } from "./bot/registry.js";
|
|
7
|
+
export { BotTokenStore } from "./bot/token.js";
|
|
6
8
|
export { CONTRACT, commandsCommand } from "./commands-command.js";
|
|
7
9
|
export { configCommand } from "./config-command.js";
|
|
8
10
|
export { baseContext, environmentOf, outputFor, provide, } from "./context.js";
|
|
@@ -16,6 +18,7 @@ export { markReadCommand } from "./messenger/chats-read-command.js";
|
|
|
16
18
|
export { completeCommand } from "./messenger/complete-command.js";
|
|
17
19
|
export { contactsCommand } from "./messenger/contacts-command.js";
|
|
18
20
|
export { messengerContext, } from "./messenger/context.js";
|
|
21
|
+
export { conversationsCommand } from "./messenger/conversations-command.js";
|
|
19
22
|
export { doctorCommand } from "./messenger/doctor-command.js";
|
|
20
23
|
export { recipientsCommand, sendsCommand } from "./messenger/guard-commands.js";
|
|
21
24
|
export { inboxCommand } from "./messenger/inbox.js";
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAoB,OAAO,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,KAA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AAW,GAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,cAAc,EACd,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,UAAU,EACV,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAGL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EAGR,aAAa,EACb,KAAK,EAKL,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import type { After } from "./port.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export interface ListStart {
|
|
3
|
+
beforeId?: string;
|
|
4
|
+
beforeTime?: string;
|
|
5
|
+
afterId?: string;
|
|
6
|
+
afterTime?: string;
|
|
7
|
+
}
|
|
8
|
+
/** How each starting point is spelled where it was typed: `--before-id` on the command line, `before_id` in MCP. */
|
|
9
|
+
export type Spell = (key: keyof ListStart) => string;
|
|
10
|
+
export declare const flagOf: Spell;
|
|
11
|
+
/**
|
|
12
|
+
* A list reads one way from one place: at most one starting point. Ids are opaque to us, so
|
|
13
|
+
* `afterId` is never read as a time, however it looks.
|
|
14
|
+
*/
|
|
15
|
+
export declare const listStart: (start: ListStart, spell?: Spell) => {
|
|
16
|
+
after?: After;
|
|
17
|
+
before?: string;
|
|
18
|
+
beforeTime?: number;
|
|
19
|
+
};
|
|
7
20
|
//# sourceMappingURL=after.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"after.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/after.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEtC,
|
|
1
|
+
{"version":3,"file":"after.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/after.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,oHAAoH;AACpH,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,MAAM,SAAS,KAAK,MAAM,CAAA;AAEpD,eAAO,MAAM,MAAM,EAAE,KAAqF,CAAA;AAI1G;;;GAGG;AACH,eAAO,MAAM,SAAS,UACb,SAAS,UACT,KAAK,KACX;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAgBvD,CAAA"}
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
import { CliError } from "@leemour/cli-core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export const afterOf = (reference, flag = "--after") => {
|
|
5
|
-
const wanted = reference.trim();
|
|
6
|
-
if (isMoment(wanted))
|
|
7
|
-
return { time: momentOf(wanted, flag) };
|
|
8
|
-
if (!isId(wanted)) {
|
|
9
|
-
throw new CliError("validation_error", `${flag} takes a message id, an ISO 8601 time or 30m, 2h, 1d ago — not "${wanted}"`);
|
|
10
|
-
}
|
|
11
|
-
return { id: wanted };
|
|
12
|
-
};
|
|
2
|
+
import { momentOf } from "../../services/moment.js";
|
|
3
|
+
export const flagOf = (key) => `--${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}`;
|
|
13
4
|
const isId = (value) => value !== "" && !/[\s\p{Cc}]/u.test(value);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export const listStart = (beforeId, afterId, afterTime, beforeTime) => {
|
|
21
|
-
const given = [
|
|
22
|
-
beforeId === undefined ? undefined : "--before-id",
|
|
23
|
-
beforeTime === undefined ? undefined : "--before-time",
|
|
24
|
-
afterId === undefined ? undefined : "--after-id",
|
|
25
|
-
afterTime === undefined ? undefined : "--after-time",
|
|
26
|
-
].filter((flag) => flag !== undefined);
|
|
5
|
+
/**
|
|
6
|
+
* A list reads one way from one place: at most one starting point. Ids are opaque to us, so
|
|
7
|
+
* `afterId` is never read as a time, however it looks.
|
|
8
|
+
*/
|
|
9
|
+
export const listStart = (start, spell = flagOf) => {
|
|
10
|
+
const given = Object.keys(start).filter((key) => start[key] !== undefined);
|
|
27
11
|
if (given.length > 1) {
|
|
28
|
-
throw new CliError("validation_error", `${given.join(" and ")} are two starting points; give one of them`);
|
|
12
|
+
throw new CliError("validation_error", `${given.map(spell).join(" and ")} are two starting points; give one of them`);
|
|
29
13
|
}
|
|
14
|
+
const { beforeId, beforeTime, afterId, afterTime } = start;
|
|
15
|
+
if (beforeTime !== undefined)
|
|
16
|
+
return { beforeTime: momentOf(beforeTime, spell("beforeTime")) };
|
|
30
17
|
if (afterTime !== undefined)
|
|
31
|
-
return { time: momentOf(afterTime, "
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
return { after: { time: momentOf(afterTime, spell("afterTime")) } };
|
|
19
|
+
const id = (beforeId ?? afterId)?.trim();
|
|
20
|
+
if (id === undefined)
|
|
21
|
+
return {};
|
|
22
|
+
const key = beforeId === undefined ? "afterId" : "beforeId";
|
|
35
23
|
if (!isId(id))
|
|
36
|
-
throw new CliError("validation_error",
|
|
37
|
-
return { id };
|
|
24
|
+
throw new CliError("validation_error", `${spell(key)} takes a message id — not "${start[key]}"`);
|
|
25
|
+
return key === "beforeId" ? { before: id } : { after: { id } };
|
|
38
26
|
};
|
|
39
27
|
//# sourceMappingURL=after.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"after.js","sourceRoot":"","sources":["../../../src/cli/messenger/after.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"after.js","sourceRoot":"","sources":["../../../src/cli/messenger/after.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAanD,MAAM,CAAC,MAAM,MAAM,GAAU,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAA;AAE1G,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,KAAK,GAAU,MAAM,EACoC,EAAE;IAC3D,MAAM,KAAK,GAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAyB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAA;IACnG,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,QAAQ,CAChB,kBAAkB,EAClB,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,4CAA4C,CAC9E,CAAA;IACH,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;IAC1D,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,CAAA;IAC9F,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAA;IAChG,MAAM,EAAE,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,CAAA;IACxC,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAC/B,MAAM,GAAG,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;IAC3D,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,8BAA8B,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC/G,OAAO,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAA;AAChE,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { type Messenger } from "./context.js";
|
|
3
|
+
/**
|
|
4
|
+
* `conversations`: the threads inside a group chat, found by rules over the stored messages — replies,
|
|
5
|
+
* mentions, one sender's messages in a row. From the store alone; nothing is built until asked (phase 3).
|
|
6
|
+
*/
|
|
7
|
+
export declare const conversationsCommand: (messenger: Messenger) => Command;
|
|
8
|
+
/** `messages links`: why a message sits where it does in its conversation. */
|
|
9
|
+
export declare const linksCommand: (messenger: Messenger) => Command;
|
|
10
|
+
//# sourceMappingURL=conversations-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations-command.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/conversations-command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,cAAc,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,cAAe,SAAS,KAAG,OA6E3D,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,YAAY,cAAe,SAAS,KAAG,OAwB9C,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CliError } from "@leemour/cli-core";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { renderMessages } from "../../render/messages.js";
|
|
4
|
+
import { momentOf } from "../../services/moment.js";
|
|
5
|
+
import { positiveCount } from "../paging.js";
|
|
6
|
+
import { messengerContext } from "./context.js";
|
|
7
|
+
/**
|
|
8
|
+
* `conversations`: the threads inside a group chat, found by rules over the stored messages — replies,
|
|
9
|
+
* mentions, one sender's messages in a row. From the store alone; nothing is built until asked (phase 3).
|
|
10
|
+
*/
|
|
11
|
+
export const conversationsCommand = (messenger) => {
|
|
12
|
+
const conversations = new Command("conversations").description("the conversations inside a chat, found in the stored messages by replies, mentions and who wrote next");
|
|
13
|
+
conversations
|
|
14
|
+
.command("build")
|
|
15
|
+
.description("find a chat's conversations in what the store holds, replacing the last build; never asks the messenger")
|
|
16
|
+
.requiredOption("--chat <chat>", messenger.chatArgument)
|
|
17
|
+
.action(async function () {
|
|
18
|
+
const { chat } = this.opts();
|
|
19
|
+
const context = messengerContext(this, messenger);
|
|
20
|
+
const built = await context.withServices((services) => services.conversations.build(chat));
|
|
21
|
+
if (context.format === "pretty") {
|
|
22
|
+
context.streams.data(`${built.messages} messages → ${built.conversations} conversations, ${built.links} links (rules v${built.rulesVersion})\n`);
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
context.renderer.result(built);
|
|
26
|
+
});
|
|
27
|
+
conversations
|
|
28
|
+
.command("list")
|
|
29
|
+
.description("a chat's conversations, the newest first: when, how many messages, how many people")
|
|
30
|
+
.requiredOption("--chat <chat>", messenger.chatArgument)
|
|
31
|
+
.option("--since-time <time>", "only those that started at this ISO 8601 time, or 30m / 2h / 1d ago, or later")
|
|
32
|
+
.option("--limit <n>", "how many", positiveCount("--limit"))
|
|
33
|
+
.action(async function () {
|
|
34
|
+
const { chat, sinceTime: since } = this.opts();
|
|
35
|
+
const context = messengerContext(this, messenger);
|
|
36
|
+
const { limit } = context.settings;
|
|
37
|
+
const page = await context.withServices((services) => services.conversations.list(chat, {
|
|
38
|
+
limit,
|
|
39
|
+
...(since === undefined ? {} : { since: new Date(momentOf(since, "--since-time")).toISOString() }),
|
|
40
|
+
}));
|
|
41
|
+
if (context.format === "pretty") {
|
|
42
|
+
context.streams.data(page.items.map((one) => `${line(one)}\n`).join(""));
|
|
43
|
+
if (page.items.length === 0)
|
|
44
|
+
context.renderer.note("no conversations in that window");
|
|
45
|
+
}
|
|
46
|
+
else if (context.format === "jsonl")
|
|
47
|
+
context.renderer.stream(page.items);
|
|
48
|
+
else
|
|
49
|
+
context.renderer.result({ items: page.items, limit, hasMore: page.hasMore });
|
|
50
|
+
});
|
|
51
|
+
conversations
|
|
52
|
+
.command("show")
|
|
53
|
+
.description("one conversation's messages, oldest first — by its id, or the one a message is in")
|
|
54
|
+
.argument("<conversation>", `a conversation id from \`conversations list\`; or ${messenger.chatArgument}, with a message`)
|
|
55
|
+
.argument("[message]", "a message id in that chat: show the conversation it is in")
|
|
56
|
+
.action(async function (first, message) {
|
|
57
|
+
const context = messengerContext(this, messenger);
|
|
58
|
+
if (message === undefined && !/^\d+$/.test(first)) {
|
|
59
|
+
throw new CliError("validation_error", "a conversation id is a number; for a chat, name a message too");
|
|
60
|
+
}
|
|
61
|
+
const { summary, messages } = await context.withServices((services) => services.conversations.show(message === undefined ? { id: first } : { chat: first, message }));
|
|
62
|
+
if (context.format === "pretty") {
|
|
63
|
+
context.streams.data(`${line(summary)}\n\n${renderMessages(messages, {
|
|
64
|
+
color: context.color,
|
|
65
|
+
verbosity: context.settings.detail,
|
|
66
|
+
senderColors: context.settings.senderColors,
|
|
67
|
+
profile: context.profile,
|
|
68
|
+
provider: messenger.provider,
|
|
69
|
+
locale: messenger.app.locale,
|
|
70
|
+
})}`);
|
|
71
|
+
}
|
|
72
|
+
else if (context.format === "jsonl")
|
|
73
|
+
context.renderer.stream(messages);
|
|
74
|
+
else
|
|
75
|
+
context.renderer.result({ ...summary, messages });
|
|
76
|
+
});
|
|
77
|
+
return conversations;
|
|
78
|
+
};
|
|
79
|
+
/** `messages links`: why a message sits where it does in its conversation. */
|
|
80
|
+
export const linksCommand = (messenger) => new Command("links")
|
|
81
|
+
.description("why a message is in its conversation: each link it has, and the chain of answers back to the start")
|
|
82
|
+
.argument("<chat>", messenger.chatArgument)
|
|
83
|
+
.argument("<message>", "the message id")
|
|
84
|
+
.action(async function (chat, message) {
|
|
85
|
+
const context = messengerContext(this, messenger);
|
|
86
|
+
const found = await context.withServices((services) => services.conversations.links(chat, message));
|
|
87
|
+
if (context.format !== "pretty") {
|
|
88
|
+
context.renderer.result(found);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (found.links.length === 0) {
|
|
92
|
+
context.renderer.note("no links: it starts a conversation, or the chat is not built — `conversations build`");
|
|
93
|
+
}
|
|
94
|
+
context.streams.data(found.links
|
|
95
|
+
.map((link) => `${link.chosen ? "→" : " "} ${link.parentId ?? "(starts)"} ${link.source} ${link.kind} ` +
|
|
96
|
+
`${link.confidence} ${link.method}${link.stale ? " stale" : ""}\n`)
|
|
97
|
+
.join("") + (found.chain.length > 0 ? `chain: ${[message, ...found.chain].join(" ← ")}\n` : ""));
|
|
98
|
+
});
|
|
99
|
+
const line = (one) => `${one.id} ${one.firstAt.slice(0, 16).replace("T", " ")}–${one.lastAt.slice(11, 16)} ` +
|
|
100
|
+
`${one.messageCount} messages · ${one.senders} people · from message ${one.firstMessageId}`;
|
|
101
|
+
//# sourceMappingURL=conversations-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations-command.js","sourceRoot":"","sources":["../../../src/cli/messenger/conversations-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAkB,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAoB,EAAW,EAAE;IACpE,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,WAAW,CAC5D,uGAAuG,CACxG,CAAA;IAED,aAAa;SACV,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CACV,yGAAyG,CAC1G;SACA,cAAc,CAAC,eAAe,EAAE,SAAS,CAAC,YAAY,CAAC;SACvD,MAAM,CAAC,KAAK;QACX,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAAoB,CAAA;QAC9C,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QACjD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC1F,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,CAAC,OAAO,CAAC,IAAI,CAClB,GAAG,KAAK,CAAC,QAAQ,eAAe,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AAC,IAAI;IACxF,GAAG,GAAG,CAAC,YAAY,eAAe,GAAG,CAAC,OAAO,0BAA0B,GAAG,CAAC,cAAc,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages-command.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/messages-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"messages-command.d.ts","sourceRoot":"","sources":["../../../src/cli/messenger/messages-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,cAAc,CAAA;AAmB/D,6FAA6F;AAC7F,eAAO,MAAM,eAAe,cAAe,SAAS,KAAG,OAiLtD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,cAAe,SAAS,KAAG,OAqB7C,CAAA"}
|