@wirecat/cli-core 0.600.0 → 0.601.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/calendar/cli/search-all.js +9 -2
  3. package/dist/cli/app-doctor-command.js +18 -10
  4. package/dist/cli/bot/api-input.js +8 -2
  5. package/dist/cli/context.d.ts +2 -0
  6. package/dist/cli/contract-templates.js +2 -1
  7. package/dist/cli/effects.d.ts +5 -0
  8. package/dist/cli/effects.js +5 -0
  9. package/dist/cli/index.d.ts +2 -1
  10. package/dist/cli/index.js +2 -1
  11. package/dist/cli/messenger/search-answers.d.ts +5 -1
  12. package/dist/cli/messenger/search-answers.js +4 -1
  13. package/dist/cli/new-file.d.ts +2 -0
  14. package/dist/cli/new-file.js +13 -0
  15. package/dist/cli/program.js +3 -0
  16. package/dist/cli/search-left-out.d.ts +27 -0
  17. package/dist/cli/search-left-out.js +31 -0
  18. package/dist/crm/cli/index.js +2 -7
  19. package/dist/crm/cli/search-all.js +17 -2
  20. package/dist/crm/index.d.ts +1 -1
  21. package/dist/crm/index.js +1 -1
  22. package/dist/crm/writes.d.ts +17 -0
  23. package/dist/crm/writes.js +31 -16
  24. package/dist/errors/reasons.js +15 -0
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/meetings/cli/index.d.ts +14 -0
  28. package/dist/meetings/cli/index.js +18 -6
  29. package/dist/meetings/index.d.ts +1 -1
  30. package/dist/meetings/mcp/index.d.ts +15 -15
  31. package/dist/meetings/pull.d.ts +13 -1
  32. package/dist/meetings/pull.js +34 -8
  33. package/dist/meetings/source.d.ts +5 -0
  34. package/dist/resolve.d.ts +2 -2
  35. package/dist/resolve.js +4 -3
  36. package/dist/services/search-all.d.ts +3 -0
  37. package/dist/services/search-all.js +1 -0
  38. package/dist/speech/local.d.ts +2 -1
  39. package/dist/speech/local.js +12 -1
  40. package/dist/speech/recognize.d.ts +2 -0
  41. package/dist/speech/recognize.js +15 -0
  42. package/dist/store/decision-requests.d.ts +10 -0
  43. package/dist/store/decision-requests.js +16 -0
  44. package/dist/store/index.d.ts +2 -0
  45. package/dist/store/index.js +1 -0
  46. package/dist/store/sqlite/deals.d.ts +3 -1
  47. package/dist/store/sqlite/deals.js +2 -2
  48. package/dist/store/sqlite/decision-requests.d.ts +59 -0
  49. package/dist/store/sqlite/decision-requests.js +111 -0
  50. package/dist/store/sqlite/manifest.js +2 -0
  51. package/dist/store/sqlite/migrations.generated.js +12 -0
  52. package/dist/store/sqlite/schema/decision-requests.d.ts +233 -0
  53. package/dist/store/sqlite/schema/decision-requests.js +20 -0
  54. package/dist/store/sqlite/schema.d.ts +1 -0
  55. package/dist/store/sqlite/schema.js +1 -0
  56. package/dist/store/store.d.ts +3 -0
  57. package/dist/store/store.js +5 -0
  58. package/package.json +2 -2
@@ -367,14 +367,14 @@ export const dealOperationsOver = (context) => {
367
367
  .all(status, status, project, project, stage, stage, pipeline, pipeline, organization?.id ?? null, organization?.id ?? null, own, provider, provider, account, ...by.params, limit, Math.max(0, Math.trunc(filter.offset ?? 0)))
368
368
  .map(itemOf(kind));
369
369
  },
370
- find: ({ words, anyWord, accounts, limit }) => {
370
+ find: ({ words, anyWord, accounts, kinds = DEAL_KINDS, limit }) => {
371
371
  const wanted = [...new Set(words.map((word) => fold(word).trim()).filter(Boolean))];
372
372
  if (!wanted.length)
373
373
  return [];
374
374
  const most = Math.min(Math.max(limit ?? 100, 1), 500);
375
375
  const within = accounts?.map(({ provider, account }) => `${provider}\u0000${account}`);
376
376
  // Titles are short and a CRM holds thousands, not millions: folding them here is cheaper than a word index.
377
- const found = DEAL_KINDS.flatMap((kind) => database
377
+ const found = kinds.flatMap((kind) => database
378
378
  .prepare(`SELECT d.id, d.title, d.updated_at, a.provider, a.external_id AS account FROM ${TABLES[kind]} d ` +
379
379
  "LEFT JOIN accounts a ON a.id = d.account_id WHERE d.deleted_at IS NULL")
380
380
  .all()
@@ -0,0 +1,59 @@
1
+ import { type DecisionAction } from "../decision-requests.js";
2
+ import type { StoreContext } from "./open.js";
3
+ /** The message a set of buttons is on. */
4
+ export interface DecisionMessage {
5
+ channel: string;
6
+ botProfile: string;
7
+ chatId: string;
8
+ messageId: string;
9
+ }
10
+ export interface DecisionRequestInput extends DecisionMessage {
11
+ proposalId: string;
12
+ batchDigest: string;
13
+ ownerUserId: string;
14
+ /** One button each, in this order; no action twice. */
15
+ actions: readonly DecisionAction[];
16
+ }
17
+ export interface DecisionRequest extends DecisionMessage {
18
+ proposalId: string;
19
+ action: DecisionAction;
20
+ batchDigest: string;
21
+ ownerUserId: string;
22
+ createdAt: number;
23
+ expiresAt: number;
24
+ }
25
+ /** Where and by whom the press came; every part must equal what the button was sent with. */
26
+ export interface DecisionPress {
27
+ botProfile: string;
28
+ chatId: string;
29
+ messageId: string;
30
+ ownerUserId: string;
31
+ }
32
+ export type DecisionRefusal = "decision.token-unknown" | "decision.token-used" | "decision.token-cancelled" | "decision.token-expired" | "decision.token-mismatch";
33
+ export type TakeResult = {
34
+ ok: true;
35
+ request: DecisionRequest;
36
+ cancelled: number;
37
+ } | {
38
+ ok: false;
39
+ reason: DecisionRefusal;
40
+ };
41
+ export interface DecisionRequestStore {
42
+ /** One token per action, for one message; the tokens are returned once and kept only as digests. */
43
+ create(input: DecisionRequestInput): {
44
+ action: DecisionAction;
45
+ token: string;
46
+ }[];
47
+ /**
48
+ * Uses a token once and cancels the message's other open tokens in the same transaction. A token for another
49
+ * bot, chat, message or owner is refused as a mismatch before its state is looked at, and stays open.
50
+ */
51
+ take(token: string, expect: DecisionPress): TakeResult;
52
+ /** Cancels every open token, of one bot when given; for turning the feature off. Returns how many. */
53
+ cancelOpen(scope?: Partial<Pick<DecisionMessage, "channel" | "botProfile">>): number;
54
+ /** Deletes rows that expired, were used or were cancelled more than 30 days before `at`; returns how many. */
55
+ prune(at?: number): number;
56
+ /** The open (unused, uncancelled, unexpired) buttons of a message, oldest first. */
57
+ open(message: DecisionMessage): DecisionRequest[];
58
+ }
59
+ export declare const decisionRequestStoreOver: ({ database, now }: StoreContext) => DecisionRequestStore;
@@ -0,0 +1,111 @@
1
+ import { createHash, randomBytes } from "node:crypto";
2
+ import { CliError } from "@wirecat/cli-base";
3
+ import { DECISION_ACTIONS, DECISION_TTL_MS, isDecisionToken } from "../decision-requests.js";
4
+ import { write } from "./transaction.js";
5
+ const digestOf = (token) => createHash("sha256").update(token).digest("hex");
6
+ const newToken = () => randomBytes(16).toString("base64url");
7
+ const requestOf = (row) => ({
8
+ proposalId: row.proposal_id,
9
+ action: row.action,
10
+ batchDigest: row.batch_digest,
11
+ channel: row.channel,
12
+ botProfile: row.bot_profile,
13
+ chatId: row.chat_id,
14
+ messageId: row.message_id,
15
+ ownerUserId: row.owner_user_id,
16
+ createdAt: row.created_at,
17
+ expiresAt: row.expires_at,
18
+ });
19
+ const PRUNE_AFTER_MS = 30 * 24 * 60 * 60 * 1000;
20
+ const SAME_MESSAGE = "channel=? AND bot_profile=? AND chat_id=? AND message_id=?";
21
+ const OPEN = "used_at IS NULL AND cancelled_at IS NULL";
22
+ export const decisionRequestStoreOver = ({ database, now }) => {
23
+ const refusal = (row, at) => {
24
+ if (!row)
25
+ return "decision.token-unknown";
26
+ if (row.used_at !== null)
27
+ return "decision.token-used";
28
+ if (row.cancelled_at !== null)
29
+ return "decision.token-cancelled";
30
+ if (row.expires_at <= at)
31
+ return "decision.token-expired";
32
+ return undefined;
33
+ };
34
+ return {
35
+ create: (input) => {
36
+ const { actions, ...fields } = input;
37
+ const text = [
38
+ fields.proposalId,
39
+ fields.batchDigest,
40
+ fields.channel,
41
+ fields.botProfile,
42
+ fields.chatId,
43
+ fields.messageId,
44
+ fields.ownerUserId,
45
+ ];
46
+ if (text.some((value) => typeof value !== "string" || value === ""))
47
+ throw new CliError("validation_error", "a decision request needs its batch, message and owner", {
48
+ reason: "decision.request-invalid",
49
+ });
50
+ if (actions.length === 0 ||
51
+ new Set(actions).size !== actions.length ||
52
+ actions.some((action) => !DECISION_ACTIONS.includes(action)))
53
+ throw new CliError("validation_error", "a decision request needs distinct, known actions", {
54
+ reason: "decision.request-invalid",
55
+ });
56
+ const at = now();
57
+ return write(database, () => actions.map((action) => {
58
+ const token = newToken();
59
+ database
60
+ .prepare(`INSERT INTO decision_requests (token_digest, proposal_id, action, batch_digest, channel, bot_profile,
61
+ chat_id, message_id, owner_user_id, created_at, expires_at) VALUES (?,?,?,?,?,?,?,?,?,?,?)`)
62
+ .run(digestOf(token), fields.proposalId, action, fields.batchDigest, fields.channel, fields.botProfile, fields.chatId, fields.messageId, fields.ownerUserId, at, at + DECISION_TTL_MS);
63
+ return { action, token };
64
+ }));
65
+ },
66
+ take: (token, expect) => {
67
+ if (!isDecisionToken(token))
68
+ return { ok: false, reason: "decision.token-unknown" };
69
+ const digest = digestOf(token);
70
+ return write(database, () => {
71
+ const at = now();
72
+ const row = database.prepare("SELECT * FROM decision_requests WHERE token_digest=?").get(digest);
73
+ if (!row)
74
+ return { ok: false, reason: "decision.token-unknown" };
75
+ if (expect.botProfile !== row.bot_profile ||
76
+ expect.chatId !== row.chat_id ||
77
+ expect.messageId !== row.message_id ||
78
+ expect.ownerUserId !== row.owner_user_id)
79
+ return { ok: false, reason: "decision.token-mismatch" };
80
+ const reason = refusal(row, at);
81
+ if (reason)
82
+ return { ok: false, reason };
83
+ database.prepare("UPDATE decision_requests SET used_at=? WHERE id=?").run(at, row.id);
84
+ const { changes } = database
85
+ .prepare(`UPDATE decision_requests SET cancelled_at=? WHERE ${SAME_MESSAGE} AND id<>? AND ${OPEN}`)
86
+ .run(at, row.channel, row.bot_profile, row.chat_id, row.message_id, row.id);
87
+ return { ok: true, request: requestOf(row), cancelled: Number(changes) };
88
+ });
89
+ },
90
+ cancelOpen: (scope = {}) => {
91
+ const filters = [];
92
+ const values = [];
93
+ if (scope.channel !== undefined) {
94
+ filters.push("channel=?");
95
+ values.push(scope.channel);
96
+ }
97
+ if (scope.botProfile !== undefined) {
98
+ filters.push("bot_profile=?");
99
+ values.push(scope.botProfile);
100
+ }
101
+ const where = [OPEN, ...filters].join(" AND ");
102
+ return write(database, () => Number(database.prepare(`UPDATE decision_requests SET cancelled_at=? WHERE ${where}`).run(now(), ...values).changes));
103
+ },
104
+ prune: (at = now()) => write(database, () => Number(database
105
+ .prepare(`DELETE FROM decision_requests WHERE expires_at < ?1 OR used_at < ?1 OR cancelled_at < ?1`)
106
+ .run(at - PRUNE_AFTER_MS).changes)),
107
+ open: (message) => database
108
+ .prepare(`SELECT * FROM decision_requests WHERE ${SAME_MESSAGE} AND ${OPEN} AND expires_at>? ORDER BY id`)
109
+ .all(message.channel, message.botProfile, message.chatId, message.messageId, now()).map(requestOf),
110
+ };
111
+ };
@@ -111,6 +111,8 @@ export const MANIFEST = [
111
111
  { name: "20261106010507_version-52-deals-rules", version: 52, minCompatible: 34 },
112
112
  { name: "20261106165009_version-53-crm-pipelines", version: 53, minCompatible: 34 },
113
113
  { name: "20261106225547_version-54-crm-fields", version: 54, minCompatible: 34 },
114
+ { name: "20261107032742_version-55-decision-requests", version: 55, minCompatible: 34 },
115
+ { name: "20261107043407_version-55-decision-requests-index", version: 55, minCompatible: 34 },
114
116
  ];
115
117
  export const generatedMigrations = (manifest = MANIFEST, generated = GENERATED) => {
116
118
  const migrations = [];
@@ -1048,5 +1048,17 @@ export const GENERATED = [
1048
1048
  "statements": [
1049
1049
  "CREATE TABLE `crm_fields` (\n\t`id` integer PRIMARY KEY,\n\t`account_id` integer NOT NULL,\n\t`kind` text NOT NULL,\n\t`code` text NOT NULL,\n\t`label` text,\n\t`type` text NOT NULL,\n\t`multiple` integer NOT NULL,\n\t`filterable` integer NOT NULL,\n\t`options` text,\n\t`position` integer NOT NULL,\n\t`created_at` integer NOT NULL,\n\t`updated_at` integer NOT NULL,\n\t`deleted_at` integer,\n\tCONSTRAINT `fk_crm_fields_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`),\n\tCONSTRAINT `crm_fields_account_id_kind_code_unique` UNIQUE(`account_id`,`kind`,`code`)\n);"
1050
1050
  ]
1051
+ },
1052
+ {
1053
+ "name": "20261107032742_version-55-decision-requests",
1054
+ "statements": [
1055
+ "CREATE TABLE `decision_requests` (\n\t`id` integer PRIMARY KEY,\n\t`token_digest` text NOT NULL UNIQUE,\n\t`proposal_id` text NOT NULL,\n\t`action` text NOT NULL,\n\t`batch_digest` text NOT NULL,\n\t`channel` text NOT NULL,\n\t`bot_profile` text NOT NULL,\n\t`chat_id` text NOT NULL,\n\t`message_id` text NOT NULL,\n\t`owner_user_id` text NOT NULL,\n\t`created_at` integer NOT NULL,\n\t`expires_at` integer NOT NULL,\n\t`used_at` integer,\n\t`cancelled_at` integer\n);"
1056
+ ]
1057
+ },
1058
+ {
1059
+ "name": "20261107043407_version-55-decision-requests-index",
1060
+ "statements": [
1061
+ "CREATE INDEX `decision_requests_by_channel_bot_profile_chat_id_message_id` ON `decision_requests` (`channel`,`bot_profile`,`chat_id`,`message_id`);"
1062
+ ]
1051
1063
  }
1052
1064
  ];
@@ -0,0 +1,233 @@
1
+ /** One button of a message that asks the owner to decide a batch; only the token's digest is kept. */
2
+ export declare const decisionRequests: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
3
+ name: "decision_requests";
4
+ schema: undefined;
5
+ columns: {
6
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
7
+ name: string;
8
+ tableName: "decision_requests";
9
+ dataType: "number int53";
10
+ data: number;
11
+ driverParam: number;
12
+ notNull: true;
13
+ hasDefault: true;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: undefined;
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}>;
22
+ tokenDigest: import("drizzle-orm/sqlite-core").SQLiteColumn<{
23
+ name: string;
24
+ tableName: "decision_requests";
25
+ dataType: "string";
26
+ data: string;
27
+ driverParam: string;
28
+ notNull: true;
29
+ hasDefault: false;
30
+ isPrimaryKey: false;
31
+ isAutoincrement: false;
32
+ hasRuntimeDefault: false;
33
+ enumValues: [string, ...string[]];
34
+ baseColumn: never;
35
+ identity: undefined;
36
+ generated: undefined;
37
+ }, {}>;
38
+ proposalId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
39
+ name: string;
40
+ tableName: "decision_requests";
41
+ dataType: "string";
42
+ data: string;
43
+ driverParam: string;
44
+ notNull: true;
45
+ hasDefault: false;
46
+ isPrimaryKey: false;
47
+ isAutoincrement: false;
48
+ hasRuntimeDefault: false;
49
+ enumValues: [string, ...string[]];
50
+ baseColumn: never;
51
+ identity: undefined;
52
+ generated: undefined;
53
+ }, {}>;
54
+ action: import("drizzle-orm/sqlite-core").SQLiteColumn<{
55
+ name: string;
56
+ tableName: "decision_requests";
57
+ dataType: "string";
58
+ data: string;
59
+ driverParam: string;
60
+ notNull: true;
61
+ hasDefault: false;
62
+ isPrimaryKey: false;
63
+ isAutoincrement: false;
64
+ hasRuntimeDefault: false;
65
+ enumValues: [string, ...string[]];
66
+ baseColumn: never;
67
+ identity: undefined;
68
+ generated: undefined;
69
+ }, {}>;
70
+ batchDigest: import("drizzle-orm/sqlite-core").SQLiteColumn<{
71
+ name: string;
72
+ tableName: "decision_requests";
73
+ dataType: "string";
74
+ data: string;
75
+ driverParam: string;
76
+ notNull: true;
77
+ hasDefault: false;
78
+ isPrimaryKey: false;
79
+ isAutoincrement: false;
80
+ hasRuntimeDefault: false;
81
+ enumValues: [string, ...string[]];
82
+ baseColumn: never;
83
+ identity: undefined;
84
+ generated: undefined;
85
+ }, {}>;
86
+ channel: import("drizzle-orm/sqlite-core").SQLiteColumn<{
87
+ name: string;
88
+ tableName: "decision_requests";
89
+ dataType: "string";
90
+ data: string;
91
+ driverParam: string;
92
+ notNull: true;
93
+ hasDefault: false;
94
+ isPrimaryKey: false;
95
+ isAutoincrement: false;
96
+ hasRuntimeDefault: false;
97
+ enumValues: [string, ...string[]];
98
+ baseColumn: never;
99
+ identity: undefined;
100
+ generated: undefined;
101
+ }, {}>;
102
+ botProfile: import("drizzle-orm/sqlite-core").SQLiteColumn<{
103
+ name: string;
104
+ tableName: "decision_requests";
105
+ dataType: "string";
106
+ data: string;
107
+ driverParam: string;
108
+ notNull: true;
109
+ hasDefault: false;
110
+ isPrimaryKey: false;
111
+ isAutoincrement: false;
112
+ hasRuntimeDefault: false;
113
+ enumValues: [string, ...string[]];
114
+ baseColumn: never;
115
+ identity: undefined;
116
+ generated: undefined;
117
+ }, {}>;
118
+ chatId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
119
+ name: string;
120
+ tableName: "decision_requests";
121
+ dataType: "string";
122
+ data: string;
123
+ driverParam: string;
124
+ notNull: true;
125
+ hasDefault: false;
126
+ isPrimaryKey: false;
127
+ isAutoincrement: false;
128
+ hasRuntimeDefault: false;
129
+ enumValues: [string, ...string[]];
130
+ baseColumn: never;
131
+ identity: undefined;
132
+ generated: undefined;
133
+ }, {}>;
134
+ messageId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
135
+ name: string;
136
+ tableName: "decision_requests";
137
+ dataType: "string";
138
+ data: string;
139
+ driverParam: string;
140
+ notNull: true;
141
+ hasDefault: false;
142
+ isPrimaryKey: false;
143
+ isAutoincrement: false;
144
+ hasRuntimeDefault: false;
145
+ enumValues: [string, ...string[]];
146
+ baseColumn: never;
147
+ identity: undefined;
148
+ generated: undefined;
149
+ }, {}>;
150
+ ownerUserId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
151
+ name: string;
152
+ tableName: "decision_requests";
153
+ dataType: "string";
154
+ data: string;
155
+ driverParam: string;
156
+ notNull: true;
157
+ hasDefault: false;
158
+ isPrimaryKey: false;
159
+ isAutoincrement: false;
160
+ hasRuntimeDefault: false;
161
+ enumValues: [string, ...string[]];
162
+ baseColumn: never;
163
+ identity: undefined;
164
+ generated: undefined;
165
+ }, {}>;
166
+ createdAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
167
+ name: string;
168
+ tableName: "decision_requests";
169
+ dataType: "number int53";
170
+ data: number;
171
+ driverParam: number;
172
+ notNull: true;
173
+ hasDefault: false;
174
+ isPrimaryKey: false;
175
+ isAutoincrement: false;
176
+ hasRuntimeDefault: false;
177
+ enumValues: undefined;
178
+ baseColumn: never;
179
+ identity: undefined;
180
+ generated: undefined;
181
+ }, {}>;
182
+ expiresAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
183
+ name: string;
184
+ tableName: "decision_requests";
185
+ dataType: "number int53";
186
+ data: number;
187
+ driverParam: number;
188
+ notNull: true;
189
+ hasDefault: false;
190
+ isPrimaryKey: false;
191
+ isAutoincrement: false;
192
+ hasRuntimeDefault: false;
193
+ enumValues: undefined;
194
+ baseColumn: never;
195
+ identity: undefined;
196
+ generated: undefined;
197
+ }, {}>;
198
+ usedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
199
+ name: string;
200
+ tableName: "decision_requests";
201
+ dataType: "number int53";
202
+ data: number;
203
+ driverParam: number;
204
+ notNull: false;
205
+ hasDefault: false;
206
+ isPrimaryKey: false;
207
+ isAutoincrement: false;
208
+ hasRuntimeDefault: false;
209
+ enumValues: undefined;
210
+ baseColumn: never;
211
+ identity: undefined;
212
+ generated: undefined;
213
+ }, {}>;
214
+ cancelledAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
215
+ name: string;
216
+ tableName: "decision_requests";
217
+ dataType: "number int53";
218
+ data: number;
219
+ driverParam: number;
220
+ notNull: false;
221
+ hasDefault: false;
222
+ isPrimaryKey: false;
223
+ isAutoincrement: false;
224
+ hasRuntimeDefault: false;
225
+ enumValues: undefined;
226
+ baseColumn: never;
227
+ identity: undefined;
228
+ generated: undefined;
229
+ }, {}>;
230
+ };
231
+ dialect: 'sqlite';
232
+ isAlias: false;
233
+ }>;
@@ -0,0 +1,20 @@
1
+ import { index, integer, sqliteTable, text } from "../drizzle/core.js";
2
+ /** One button of a message that asks the owner to decide a batch; only the token's digest is kept. */
3
+ export const decisionRequests = sqliteTable("decision_requests", {
4
+ id: integer("id").primaryKey(),
5
+ tokenDigest: text("token_digest").notNull().unique(),
6
+ proposalId: text("proposal_id").notNull(),
7
+ action: text("action").notNull(),
8
+ batchDigest: text("batch_digest").notNull(),
9
+ channel: text("channel").notNull(),
10
+ botProfile: text("bot_profile").notNull(),
11
+ chatId: text("chat_id").notNull(),
12
+ messageId: text("message_id").notNull(),
13
+ ownerUserId: text("owner_user_id").notNull(),
14
+ createdAt: integer("created_at").notNull(),
15
+ expiresAt: integer("expires_at").notNull(),
16
+ usedAt: integer("used_at"),
17
+ cancelledAt: integer("cancelled_at"),
18
+ }, (table) => [
19
+ index("decision_requests_by_channel_bot_profile_chat_id_message_id").on(table.channel, table.botProfile, table.chatId, table.messageId),
20
+ ]);
@@ -16759,6 +16759,7 @@ export declare const crmFields: import("drizzle-orm/sqlite-core").SQLiteTableWit
16759
16759
  dialect: 'sqlite';
16760
16760
  isAlias: false;
16761
16761
  }>;
16762
+ export { decisionRequests } from "./schema/decision-requests.js";
16762
16763
  /** What a source said about one of its records, as it said it: the layer under the entity an import makes. */
16763
16764
  export declare const records: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
16764
16765
  name: "records";
@@ -1679,6 +1679,7 @@ export const crmFields = sqliteTable("crm_fields", {
1679
1679
  updatedAt: integer("updated_at").notNull(),
1680
1680
  deletedAt: integer("deleted_at"),
1681
1681
  }, (table) => [unique().on(table.accountId, table.kind, table.code)]);
1682
+ export { decisionRequests } from "./schema/decision-requests.js";
1682
1683
  /** What a source said about one of its records, as it said it: the layer under the entity an import makes. */
1683
1684
  export const records = sqliteTable("records", {
1684
1685
  id: integer("id").primaryKey(),
@@ -24,6 +24,7 @@ import { type BotUpdateStore } from "./sqlite/bot-updates.js";
24
24
  import { type CatalogStore } from "./sqlite/catalog.js";
25
25
  import { type CrmCopies } from "./sqlite/crm.js";
26
26
  import { type DealsStore } from "./sqlite/deals.js";
27
+ import { type DecisionRequestStore } from "./sqlite/decision-requests.js";
27
28
  import { type MailStore } from "./sqlite/emails.js";
28
29
  import { type EventSearch } from "./sqlite/event-search.js";
29
30
  import { type FactsStore } from "./sqlite/facts.js";
@@ -111,6 +112,8 @@ export interface MessageStore {
111
112
  readonly deals: DealsStore;
112
113
  /** A CRM account's pipelines, deals, leads, contacts and companies, written as the CRM has them. */
113
114
  readonly crm: CrmCopies;
115
+ /** The one-time keys behind the buttons of a message that asks the owner to decide a batch. */
116
+ readonly decisionRequests: DecisionRequestStore;
114
117
  /** What each import said, by the source's identity; `ingest` (services) is the way in. */
115
118
  readonly records: RecordStore;
116
119
  /** What agents concluded: summaries, digests, facts, preferences, each with evidence and a scope. */
@@ -21,6 +21,7 @@ import { catalogStoreOver } from "./sqlite/catalog.js";
21
21
  import { contextEvidenceOver, contextIndexOver, contextRecordsOver } from "./sqlite/context-evidence.js";
22
22
  import { crmCopiesOver } from "./sqlite/crm.js";
23
23
  import { dealsStoreOver } from "./sqlite/deals.js";
24
+ import { decisionRequestStoreOver } from "./sqlite/decision-requests.js";
24
25
  import { mailStoreOver } from "./sqlite/emails.js";
25
26
  import { eventSearchOver } from "./sqlite/event-search.js";
26
27
  import { evidenceFindingsStoreOver } from "./sqlite/evidence-findings.js";
@@ -122,6 +123,7 @@ const storeOver = (context) => {
122
123
  const orders = once(() => ordersStoreOver(context));
123
124
  const deals = once(() => dealsStoreOver(context));
124
125
  const crm = once(() => crmCopiesOver(context, accountPeopleOver(context)));
126
+ const decisionRequests = once(() => decisionRequestStoreOver(context));
125
127
  const records = once(() => recordStoreOver(context));
126
128
  const memories = once(() => memoriesStoreOver(context));
127
129
  const proposedActions = once(() => proposedActionsStoreOver(context));
@@ -238,6 +240,9 @@ const storeOver = (context) => {
238
240
  get crm() {
239
241
  return crm();
240
242
  },
243
+ get decisionRequests() {
244
+ return decisionRequests();
245
+ },
241
246
  get records() {
242
247
  return records();
243
248
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-core",
3
- "version": "0.600.0",
3
+ "version": "0.601.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",
@@ -15,7 +15,7 @@
15
15
  "type": "module",
16
16
  "wirecat": {
17
17
  "store": {
18
- "speaks": 54,
18
+ "speaks": 55,
19
19
  "minCompatible": 34
20
20
  }
21
21
  },