@wirecat/cli-core 0.696.0 → 0.698.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 +93 -0
- package/dist/cli/bot/api-http.d.ts +1 -1
- package/dist/cli/bot/api-http.js +77 -5
- package/dist/cli/bot/api-input.d.ts +5 -0
- package/dist/cli/bot/api-input.js +55 -0
- package/dist/cli/bot/api.d.ts +2 -0
- package/dist/cli/bot/api.js +12 -3
- package/dist/cli/documents/folders.d.ts +2 -0
- package/dist/cli/documents/library.d.ts +2 -0
- package/dist/cli/documents/library.js +5 -1
- package/dist/cli/documents/queries.d.ts +4 -0
- package/dist/cli/documents/queries.js +7 -1
- package/dist/cli/messenger/mcp-command.js +53 -4
- package/dist/cli/messenger/store-maintenance-command.js +3 -2
- package/dist/cli/schedule/schedule-command.js +9 -4
- package/dist/cli/service-api-manifest.js +25 -18
- package/dist/cli/service-api.js +6 -2
- package/dist/conversations/link.d.ts +5 -2
- package/dist/conversations/link.js +27 -9
- package/dist/crm/manifest/manifest.d.ts +2 -0
- package/dist/crm/manifest/manifest.js +2 -1
- package/dist/crm/manifest/map.d.ts +7 -2
- package/dist/crm/manifest/map.js +16 -9
- package/dist/crm/testing/manifest-fake.js +31 -2
- package/dist/domain/tracker.d.ts +100 -0
- package/dist/domain/tracker.js +28 -0
- package/dist/errors/reasons.js +1 -0
- package/dist/manifest/index.d.ts +17 -5
- package/dist/manifest/index.js +26 -8
- package/dist/mcp/all-profiles.d.ts +9 -0
- package/dist/mcp/all-profiles.js +56 -14
- package/dist/ports/wirecat-tools.js +7 -0
- package/dist/store/exports.d.ts +1 -0
- package/dist/store/exports.js +1 -0
- package/dist/store/recover.js +2 -0
- package/dist/store/sqlite/account-purge.js +1 -0
- package/dist/store/sqlite/batches.js +5 -2
- package/dist/store/sqlite/crm-files.d.ts +3 -0
- package/dist/store/sqlite/crm-files.js +2 -2
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +17 -0
- package/dist/store/sqlite/schema.d.ts +252 -0
- package/dist/store/sqlite/schema.js +28 -0
- package/dist/store/sqlite/tracker.d.ts +82 -0
- package/dist/store/sqlite/tracker.js +210 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/dist/tracker/cli/index.d.ts +24 -0
- package/dist/tracker/cli/index.js +292 -0
- package/dist/tracker/index.d.ts +8 -0
- package/dist/tracker/index.js +7 -0
- package/dist/tracker/manifest/manifest.d.ts +76 -0
- package/dist/tracker/manifest/manifest.js +139 -0
- package/dist/tracker/manifest/map.d.ts +10 -0
- package/dist/tracker/manifest/map.js +86 -0
- package/dist/tracker/manifest/source.d.ts +18 -0
- package/dist/tracker/manifest/source.js +174 -0
- package/dist/tracker/source.d.ts +55 -0
- package/dist/tracker/source.js +1 -0
- package/dist/tracker/sync.d.ts +60 -0
- package/dist/tracker/sync.js +254 -0
- package/dist/tracker/tasks.d.ts +18 -0
- package/dist/tracker/tasks.js +29 -0
- package/dist/tracker/testing/index.d.ts +2 -0
- package/dist/tracker/testing/index.js +2 -0
- package/dist/tracker/testing/source-contract.d.ts +46 -0
- package/dist/tracker/testing/source-contract.js +246 -0
- package/dist/tracker/testing/source.d.ts +31 -0
- package/dist/tracker/testing/source.js +141 -0
- package/package.json +12 -4
package/dist/mcp/all-profiles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
|
+
import { InMemoryTransport, McpServer } from "@modelcontextprotocol/server";
|
|
4
4
|
import { StdioServerTransport, serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
5
5
|
import { CliError, errorObjectOf, mcpErrorResult } from "@wirecat/cli-base";
|
|
6
6
|
import { CALLER_META_KEY, callerOf, PROXY_CLIENT_NAME } from "./caller.js";
|
|
@@ -157,15 +157,18 @@ export const withProfile = (tool, profiles, name, signedIn = () => true) => {
|
|
|
157
157
|
inputSchema: {
|
|
158
158
|
...tool.inputSchema,
|
|
159
159
|
properties: {
|
|
160
|
-
profile:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
profile: profiles.length === 0
|
|
161
|
+
? // An empty enum matches nothing, and a directory that checks the schema refuses the tool.
|
|
162
|
+
{
|
|
163
|
+
type: "string",
|
|
164
|
+
description: `Which ${name} account, by its profile. None is set up on this computer yet.`,
|
|
165
|
+
}
|
|
166
|
+
: {
|
|
167
|
+
type: "string",
|
|
168
|
+
enum: [...profiles],
|
|
169
|
+
oneOf: profiles.map((one) => ({ const: one, title: signedIn(one) ? one : `${one} — not signed in` })),
|
|
170
|
+
description: `Which ${name} account, by its profile. If the owner did not name one, ask which — never guess.${states}`,
|
|
171
|
+
},
|
|
169
172
|
...schema.properties,
|
|
170
173
|
},
|
|
171
174
|
required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")],
|
|
@@ -197,11 +200,15 @@ export const allProfilesServer = (options) => {
|
|
|
197
200
|
const signedIn = (profile) => options.signedIn?.(profile) ?? true;
|
|
198
201
|
const build = () => {
|
|
199
202
|
const profiles = [...options.profiles()].sort();
|
|
200
|
-
const server = new McpServer({ name: options.command, version: options.version }, {
|
|
203
|
+
const server = new McpServer({ name: options.command, version: options.version }, {
|
|
204
|
+
capabilities: { tools: {} },
|
|
205
|
+
// Read per session, as the profiles are: clients cut the instructions short, so this line comes first.
|
|
206
|
+
instructions: profiles.length === 0 && options.setup
|
|
207
|
+
? `${options.setup.charAt(0).toUpperCase()}${options.setup.slice(1)}.\n${options.instructions}`
|
|
208
|
+
: options.instructions,
|
|
209
|
+
});
|
|
201
210
|
server.server.setRequestHandler("tools/list", async () => ({
|
|
202
|
-
tools: profiles.length === 0
|
|
203
|
-
? []
|
|
204
|
-
: (await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn)),
|
|
211
|
+
tools: (profiles.length === 0 ? ((await options.catalogue?.()) ?? []) : await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn)),
|
|
205
212
|
}));
|
|
206
213
|
const callers = {
|
|
207
214
|
env: options.env ?? process.env,
|
|
@@ -211,6 +218,8 @@ export const allProfilesServer = (options) => {
|
|
|
211
218
|
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
212
219
|
const { name, arguments: given = {}, _meta } = request.params;
|
|
213
220
|
const { profile, ...rest } = given;
|
|
221
|
+
if (profiles.length === 0)
|
|
222
|
+
return refusal("configuration_error", options.setup ?? `no ${options.command} profile on this computer yet.`);
|
|
214
223
|
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
215
224
|
return refusal("validation_error", `${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
216
225
|
if (!signedIn(profile))
|
|
@@ -233,6 +242,39 @@ export const allProfilesServer = (options) => {
|
|
|
233
242
|
};
|
|
234
243
|
return { build, close: () => children.close() };
|
|
235
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* What a server answers to `tools/list`, asked in this process: the list for a session with no profile, which has no
|
|
247
|
+
* profile's server to ask.
|
|
248
|
+
*/
|
|
249
|
+
export const listedTools = async (server) => {
|
|
250
|
+
const [own, other] = InMemoryTransport.createLinkedPair();
|
|
251
|
+
const answers = new Map();
|
|
252
|
+
other.onmessage = (message) => {
|
|
253
|
+
const { id, result, error } = message;
|
|
254
|
+
if (typeof id === "number")
|
|
255
|
+
answers.get(id)?.(result, error);
|
|
256
|
+
};
|
|
257
|
+
const ask = (id, method, params) => new Promise((resolve, reject) => {
|
|
258
|
+
answers.set(id, (result, error) => error || !result ? reject(new Error(error?.message ?? `${method} had no answer`)) : resolve(result));
|
|
259
|
+
void other.send({ jsonrpc: "2.0", id, method, params });
|
|
260
|
+
});
|
|
261
|
+
await server.connect(own);
|
|
262
|
+
try {
|
|
263
|
+
await ask(1, "initialize", {
|
|
264
|
+
protocolVersion: PROTOCOL,
|
|
265
|
+
capabilities: {},
|
|
266
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" },
|
|
267
|
+
});
|
|
268
|
+
await other.send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
269
|
+
const answer = await ask(2, "tools/list", {});
|
|
270
|
+
if (!Array.isArray(answer.tools))
|
|
271
|
+
throw new Error("the catalogue server listed no tools");
|
|
272
|
+
return answer.tools;
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
await server.close();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
236
278
|
/** Over stdin and stdout until the client closes stdin or the process is told to stop; then the children close. */
|
|
237
279
|
export const serveAllProfilesOverStdio = async (options, io = {}) => {
|
|
238
280
|
const { build, close } = allProfilesServer(options);
|
|
@@ -78,4 +78,11 @@ export const WIRECAT_TOOLS = [
|
|
|
78
78
|
package: "@wirecat/notion-cli",
|
|
79
79
|
does: "Notion pages and databases as local text, searchable with your other WireCat data",
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
command: "ydisk",
|
|
83
|
+
appName: "yandex-disk-cli",
|
|
84
|
+
envPrefix: "YDISK",
|
|
85
|
+
package: "@wirecat/yandex-disk-cli",
|
|
86
|
+
does: "Yandex Disk folders as local text, searchable with your other WireCat data",
|
|
87
|
+
},
|
|
81
88
|
];
|
package/dist/store/exports.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export { DEFAULT_FIRST_PASS_PER_CHAT, firstPassPerChatOf, savedFirstPassPerChat
|
|
|
67
67
|
export { inboxKey } from "./sqlite/tasks.js";
|
|
68
68
|
export { storedTemplateBodies, type TemplateAddress } from "./sqlite/templates.js";
|
|
69
69
|
export { THREAD_COLUMNS } from "./sqlite/thread-columns.js";
|
|
70
|
+
export { resetTrackerItemWords, type TrackerFilter, type TrackerHit, type TrackerItem, type TrackerPerson, type TrackerSearch, type TrackerStore, } from "./sqlite/tracker.js";
|
|
70
71
|
export { dropAllUnusedVectors, vectorIndexCounts } from "./sqlite/vector-index.js";
|
|
71
72
|
export type { MatchPlace, ScoredHit } from "./sqlite/words.js";
|
|
72
73
|
export type { TaskDetails } from "./sqlite/work-tasks.js";
|
package/dist/store/exports.js
CHANGED
|
@@ -35,4 +35,5 @@ export { DEFAULT_FIRST_PASS_PER_CHAT, firstPassPerChatOf, savedFirstPassPerChat
|
|
|
35
35
|
export { inboxKey } from "./sqlite/tasks.js";
|
|
36
36
|
export { storedTemplateBodies } from "./sqlite/templates.js";
|
|
37
37
|
export { THREAD_COLUMNS } from "./sqlite/thread-columns.js";
|
|
38
|
+
export { resetTrackerItemWords, } from "./sqlite/tracker.js";
|
|
38
39
|
export { dropAllUnusedVectors, vectorIndexCounts } from "./sqlite/vector-index.js";
|
package/dist/store/recover.js
CHANGED
|
@@ -21,6 +21,7 @@ import { isDerivedTable } from "./sqlite/rollback-copy.js";
|
|
|
21
21
|
import { fillSearchIndex, resetSearchIndex } from "./sqlite/search-index.js";
|
|
22
22
|
import { stemmerCache } from "./sqlite/stems.js";
|
|
23
23
|
import { fillStems, resetStems } from "./sqlite/stems-fill.js";
|
|
24
|
+
import { resetTrackerItemWords } from "./sqlite/tracker.js";
|
|
24
25
|
import { fillVectorIndexes } from "./sqlite/vector-index.js";
|
|
25
26
|
/** `contentless_delete`, which every word index uses, came in SQLite 3.43. */
|
|
26
27
|
export const SQLITE3_MINIMUM = [3, 43, 0];
|
|
@@ -383,6 +384,7 @@ const FILLERS = {
|
|
|
383
384
|
},
|
|
384
385
|
attachment_words: (database) => void resetAttachmentWords(database),
|
|
385
386
|
crm_file_words: (database) => void resetCrmFileWords(database),
|
|
387
|
+
tracker_item_words: (database) => void resetTrackerItemWords(database),
|
|
386
388
|
attachment_name_words: (database) =>
|
|
387
389
|
// As migration 20 filled it: й and ё fold as the triggers fold them.
|
|
388
390
|
database.exec("INSERT INTO attachment_name_words (rowid, name) SELECT id, " +
|
|
@@ -97,6 +97,7 @@ export const purgeAccount = (context, accountKey) => {
|
|
|
97
97
|
purgeCrmCopies(database, accountKey);
|
|
98
98
|
orm.run(sql `DELETE FROM crm_fields WHERE account_id = ${accountKey}`);
|
|
99
99
|
orm.run(sql `DELETE FROM crm_files WHERE account_id = ${accountKey}`);
|
|
100
|
+
orm.run(sql `DELETE FROM tracker_items WHERE account_id = ${accountKey}`);
|
|
100
101
|
// An entity made from a record is the owner's and stays; only what the source said goes.
|
|
101
102
|
const recordsOf = sql `(SELECT id FROM records WHERE account_id = ${accountKey})`;
|
|
102
103
|
orm.run(sql `DELETE FROM record_relations WHERE record_id IN ${recordsOf} OR target_id IN ${recordsOf}`);
|
|
@@ -6,10 +6,13 @@ import { toIso } from "./values.js";
|
|
|
6
6
|
export const BATCH_CONTEXT = 50;
|
|
7
7
|
/**
|
|
8
8
|
* Phase 4 plan A2: a live message the agent is asked about — no reply the messenger itself records to a
|
|
9
|
-
* message held here
|
|
9
|
+
* message held here that the build links (`inThread` in conversations/link.ts), and no current agent answer.
|
|
10
|
+
* A stale answer makes it need the agent again.
|
|
10
11
|
*/
|
|
11
12
|
const replied = (m) => sql `EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
|
|
12
|
-
AND p.external_id = ${m}.reply_to_external_id AND p.deleted_at IS NULL
|
|
13
|
+
AND p.external_id = ${m}.reply_to_external_id AND p.deleted_at IS NULL
|
|
14
|
+
AND (p.thread_external_id IS ${m}.thread_external_id
|
|
15
|
+
OR (p.external_id = ${m}.thread_external_id AND trim(p.text) <> '')))`;
|
|
13
16
|
const needsAgent = (m) => sql `(
|
|
14
17
|
NOT ${replied(m)}
|
|
15
18
|
AND NOT EXISTS (SELECT 1 FROM message_links l WHERE l.message_id = ${m}.id AND l.source = 'agent'
|
|
@@ -65,6 +65,9 @@ export interface CrmFileStore {
|
|
|
65
65
|
/** The account's `files.*` settings, each its default unless the owner set one in range. */
|
|
66
66
|
limits(key: AccountKey): Promise<CrmFileLimits>;
|
|
67
67
|
}
|
|
68
|
+
/** One FTS5 phrase per word, quoted so no word is read as syntax; a word may start a longer one unless `exact`. */
|
|
69
|
+
export declare const matchOf: (words: readonly string[], anyWord: boolean, exact: boolean) => string | undefined;
|
|
70
|
+
export declare const excerptOf: (body: string, words: readonly string[]) => string;
|
|
68
71
|
/** `store rebuild`: the normalized copies follow the current normalizer, then the word index is filled again. */
|
|
69
72
|
export declare const resetCrmFileWords: (database: CacheDatabase) => number;
|
|
70
73
|
export declare const crmFilesOver: (context: StoreContext) => CrmFileStore;
|
|
@@ -31,7 +31,7 @@ const rowOf = (row) => ({
|
|
|
31
31
|
downloadedAt: Number(row.downloaded_at),
|
|
32
32
|
});
|
|
33
33
|
/** One FTS5 phrase per word, quoted so no word is read as syntax; a word may start a longer one unless `exact`. */
|
|
34
|
-
const matchOf = (words, anyWord, exact) => {
|
|
34
|
+
export const matchOf = (words, anyWord, exact) => {
|
|
35
35
|
const phrases = words
|
|
36
36
|
.map((word) => normalize(word).trim())
|
|
37
37
|
.filter(Boolean)
|
|
@@ -41,7 +41,7 @@ const matchOf = (words, anyWord, exact) => {
|
|
|
41
41
|
});
|
|
42
42
|
return phrases.length ? [...new Set(phrases)].join(anyWord ? " OR " : " AND ") : undefined;
|
|
43
43
|
};
|
|
44
|
-
const excerptOf = (body, words) => {
|
|
44
|
+
export const excerptOf = (body, words) => {
|
|
45
45
|
const folded = fold(body);
|
|
46
46
|
const at = words
|
|
47
47
|
.map((word) => folded.indexOf(fold(word).trim()))
|
|
@@ -136,6 +136,8 @@ export const MANIFEST = [
|
|
|
136
136
|
{ name: "20261116204204_version-68-crm-file-words", version: 68, minCompatible: 56 },
|
|
137
137
|
{ name: "20261117015456_version-69-conversation-readiness", version: 69, minCompatible: 56 },
|
|
138
138
|
{ name: "20261117015457_version-69-conversation-readiness-triggers", version: 69, minCompatible: 56 },
|
|
139
|
+
{ name: "20261117211410_version-70-tracker-items", version: 70, minCompatible: 56 },
|
|
140
|
+
{ name: "20261117211414_version-70-tracker-item-words", version: 70, minCompatible: 56 },
|
|
139
141
|
];
|
|
140
142
|
export const generatedMigrations = (manifest = MANIFEST, generated = GENERATED) => {
|
|
141
143
|
const migrations = [];
|
|
@@ -1381,5 +1381,22 @@ export const GENERATED = [
|
|
|
1381
1381
|
"-- A chat whose every chunk text already has a vector cannot gain from a new one: (model, content_hash) is unique.\nCREATE TRIGGER conversation_readiness_embedding_ai AFTER INSERT ON embeddings BEGIN\n DELETE FROM conversation_readiness WHERE model = NEW.model AND embedded_count < chunks;\nEND;",
|
|
1382
1382
|
"CREATE TRIGGER conversation_readiness_embedding_ad AFTER DELETE ON embeddings BEGIN\n DELETE FROM conversation_readiness WHERE model = OLD.model AND embedded_count > 0;\nEND;"
|
|
1383
1383
|
]
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
"name": "20261117211410_version-70-tracker-items",
|
|
1387
|
+
"statements": [
|
|
1388
|
+
"CREATE TABLE `tracker_items` (\n\t`id` integer PRIMARY KEY,\n\t`account_id` integer NOT NULL,\n\t`kind` text NOT NULL,\n\t`external_id` text NOT NULL,\n\t`parent_id` text,\n\t`title` text NOT NULL,\n\t`title_folded` text NOT NULL,\n\t`body` text,\n\t`normalized_text` text NOT NULL,\n\t`data` text NOT NULL,\n\t`source_created_at` integer,\n\t`source_updated_at` integer,\n\t`archived_at` integer,\n\t`deleted_at` integer,\n\t`synced_at` integer NOT NULL,\n\tCONSTRAINT `fk_tracker_items_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`),\n\tCONSTRAINT `tracker_items_account_id_kind_external_id_unique` UNIQUE(`account_id`,`kind`,`external_id`)\n);",
|
|
1389
|
+
"CREATE INDEX `tracker_items_by_account_id_kind_parent_id` ON `tracker_items` (`account_id`,`kind`,`parent_id`);"
|
|
1390
|
+
]
|
|
1391
|
+
},
|
|
1392
|
+
{
|
|
1393
|
+
"name": "20261117211414_version-70-tracker-item-words",
|
|
1394
|
+
"statements": [
|
|
1395
|
+
"-- Words of a tracker item's title and text, rowid = tracker_items.id: issues, projects and comments found by any word.\nCREATE VIRTUAL TABLE tracker_item_words USING fts5(\n normalized_text,\n content = '', contentless_delete = 1,\n tokenize = 'unicode61 remove_diacritics 2', prefix = '3');",
|
|
1396
|
+
"CREATE VIRTUAL TABLE tracker_item_words_vocab USING fts5vocab(tracker_item_words, 'col');",
|
|
1397
|
+
"CREATE TRIGGER tracker_item_words_ai AFTER INSERT ON tracker_items WHEN new.normalized_text <> '' BEGIN\n INSERT INTO tracker_item_words (rowid, normalized_text) VALUES (new.id, new.normalized_text);\nEND;",
|
|
1398
|
+
"CREATE TRIGGER tracker_item_words_au AFTER UPDATE OF normalized_text ON tracker_items\n WHEN old.normalized_text IS NOT new.normalized_text BEGIN\n DELETE FROM tracker_item_words WHERE rowid = old.id;\n INSERT INTO tracker_item_words (rowid, normalized_text)\n SELECT new.id, new.normalized_text WHERE new.normalized_text <> '';\nEND;",
|
|
1399
|
+
"CREATE TRIGGER tracker_item_words_ad AFTER DELETE ON tracker_items BEGIN\n DELETE FROM tracker_item_words WHERE rowid = old.id;\nEND;"
|
|
1400
|
+
]
|
|
1384
1401
|
}
|
|
1385
1402
|
];
|
|
@@ -23560,6 +23560,258 @@ export declare const conversationReadiness: import("drizzle-orm/sqlite-core").SQ
|
|
|
23560
23560
|
dialect: 'sqlite';
|
|
23561
23561
|
isAlias: false;
|
|
23562
23562
|
}>;
|
|
23563
|
+
/**
|
|
23564
|
+
* One team, user, workflow state, label, project, issue or comment of an issue tracker account, as last synced. The
|
|
23565
|
+
* columns are what lists, filters and search read; the rest of the record is `data`, JSON in the domain's field names.
|
|
23566
|
+
*/
|
|
23567
|
+
export declare const trackerItems: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
23568
|
+
name: "tracker_items";
|
|
23569
|
+
schema: undefined;
|
|
23570
|
+
columns: {
|
|
23571
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23572
|
+
name: string;
|
|
23573
|
+
tableName: "tracker_items";
|
|
23574
|
+
dataType: "number int53";
|
|
23575
|
+
data: number;
|
|
23576
|
+
driverParam: number;
|
|
23577
|
+
notNull: true;
|
|
23578
|
+
hasDefault: true;
|
|
23579
|
+
isPrimaryKey: true;
|
|
23580
|
+
isAutoincrement: false;
|
|
23581
|
+
hasRuntimeDefault: false;
|
|
23582
|
+
enumValues: undefined;
|
|
23583
|
+
baseColumn: never;
|
|
23584
|
+
identity: undefined;
|
|
23585
|
+
generated: undefined;
|
|
23586
|
+
}, {}>;
|
|
23587
|
+
accountId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23588
|
+
name: string;
|
|
23589
|
+
tableName: "tracker_items";
|
|
23590
|
+
dataType: "number int53";
|
|
23591
|
+
data: number;
|
|
23592
|
+
driverParam: number;
|
|
23593
|
+
notNull: true;
|
|
23594
|
+
hasDefault: false;
|
|
23595
|
+
isPrimaryKey: false;
|
|
23596
|
+
isAutoincrement: false;
|
|
23597
|
+
hasRuntimeDefault: false;
|
|
23598
|
+
enumValues: undefined;
|
|
23599
|
+
baseColumn: never;
|
|
23600
|
+
identity: undefined;
|
|
23601
|
+
generated: undefined;
|
|
23602
|
+
}, {}>;
|
|
23603
|
+
kind: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23604
|
+
name: string;
|
|
23605
|
+
tableName: "tracker_items";
|
|
23606
|
+
dataType: "string";
|
|
23607
|
+
data: string;
|
|
23608
|
+
driverParam: string;
|
|
23609
|
+
notNull: true;
|
|
23610
|
+
hasDefault: false;
|
|
23611
|
+
isPrimaryKey: false;
|
|
23612
|
+
isAutoincrement: false;
|
|
23613
|
+
hasRuntimeDefault: false;
|
|
23614
|
+
enumValues: [string, ...string[]];
|
|
23615
|
+
baseColumn: never;
|
|
23616
|
+
identity: undefined;
|
|
23617
|
+
generated: undefined;
|
|
23618
|
+
}, {}>;
|
|
23619
|
+
externalId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23620
|
+
name: string;
|
|
23621
|
+
tableName: "tracker_items";
|
|
23622
|
+
dataType: "string";
|
|
23623
|
+
data: string;
|
|
23624
|
+
driverParam: string;
|
|
23625
|
+
notNull: true;
|
|
23626
|
+
hasDefault: false;
|
|
23627
|
+
isPrimaryKey: false;
|
|
23628
|
+
isAutoincrement: false;
|
|
23629
|
+
hasRuntimeDefault: false;
|
|
23630
|
+
enumValues: [string, ...string[]];
|
|
23631
|
+
baseColumn: never;
|
|
23632
|
+
identity: undefined;
|
|
23633
|
+
generated: undefined;
|
|
23634
|
+
}, {}>;
|
|
23635
|
+
parentId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23636
|
+
name: string;
|
|
23637
|
+
tableName: "tracker_items";
|
|
23638
|
+
dataType: "string";
|
|
23639
|
+
data: string;
|
|
23640
|
+
driverParam: string;
|
|
23641
|
+
notNull: false;
|
|
23642
|
+
hasDefault: false;
|
|
23643
|
+
isPrimaryKey: false;
|
|
23644
|
+
isAutoincrement: false;
|
|
23645
|
+
hasRuntimeDefault: false;
|
|
23646
|
+
enumValues: [string, ...string[]];
|
|
23647
|
+
baseColumn: never;
|
|
23648
|
+
identity: undefined;
|
|
23649
|
+
generated: undefined;
|
|
23650
|
+
}, {}>;
|
|
23651
|
+
title: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23652
|
+
name: string;
|
|
23653
|
+
tableName: "tracker_items";
|
|
23654
|
+
dataType: "string";
|
|
23655
|
+
data: string;
|
|
23656
|
+
driverParam: string;
|
|
23657
|
+
notNull: true;
|
|
23658
|
+
hasDefault: false;
|
|
23659
|
+
isPrimaryKey: false;
|
|
23660
|
+
isAutoincrement: false;
|
|
23661
|
+
hasRuntimeDefault: false;
|
|
23662
|
+
enumValues: [string, ...string[]];
|
|
23663
|
+
baseColumn: never;
|
|
23664
|
+
identity: undefined;
|
|
23665
|
+
generated: undefined;
|
|
23666
|
+
}, {}>;
|
|
23667
|
+
titleFolded: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23668
|
+
name: string;
|
|
23669
|
+
tableName: "tracker_items";
|
|
23670
|
+
dataType: "string";
|
|
23671
|
+
data: string;
|
|
23672
|
+
driverParam: string;
|
|
23673
|
+
notNull: true;
|
|
23674
|
+
hasDefault: false;
|
|
23675
|
+
isPrimaryKey: false;
|
|
23676
|
+
isAutoincrement: false;
|
|
23677
|
+
hasRuntimeDefault: false;
|
|
23678
|
+
enumValues: [string, ...string[]];
|
|
23679
|
+
baseColumn: never;
|
|
23680
|
+
identity: undefined;
|
|
23681
|
+
generated: undefined;
|
|
23682
|
+
}, {}>;
|
|
23683
|
+
body: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23684
|
+
name: string;
|
|
23685
|
+
tableName: "tracker_items";
|
|
23686
|
+
dataType: "string";
|
|
23687
|
+
data: string;
|
|
23688
|
+
driverParam: string;
|
|
23689
|
+
notNull: false;
|
|
23690
|
+
hasDefault: false;
|
|
23691
|
+
isPrimaryKey: false;
|
|
23692
|
+
isAutoincrement: false;
|
|
23693
|
+
hasRuntimeDefault: false;
|
|
23694
|
+
enumValues: [string, ...string[]];
|
|
23695
|
+
baseColumn: never;
|
|
23696
|
+
identity: undefined;
|
|
23697
|
+
generated: undefined;
|
|
23698
|
+
}, {}>;
|
|
23699
|
+
normalizedText: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23700
|
+
name: string;
|
|
23701
|
+
tableName: "tracker_items";
|
|
23702
|
+
dataType: "string";
|
|
23703
|
+
data: string;
|
|
23704
|
+
driverParam: string;
|
|
23705
|
+
notNull: true;
|
|
23706
|
+
hasDefault: false;
|
|
23707
|
+
isPrimaryKey: false;
|
|
23708
|
+
isAutoincrement: false;
|
|
23709
|
+
hasRuntimeDefault: false;
|
|
23710
|
+
enumValues: [string, ...string[]];
|
|
23711
|
+
baseColumn: never;
|
|
23712
|
+
identity: undefined;
|
|
23713
|
+
generated: undefined;
|
|
23714
|
+
}, {}>;
|
|
23715
|
+
data: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23716
|
+
name: string;
|
|
23717
|
+
tableName: "tracker_items";
|
|
23718
|
+
dataType: "string";
|
|
23719
|
+
data: string;
|
|
23720
|
+
driverParam: string;
|
|
23721
|
+
notNull: true;
|
|
23722
|
+
hasDefault: false;
|
|
23723
|
+
isPrimaryKey: false;
|
|
23724
|
+
isAutoincrement: false;
|
|
23725
|
+
hasRuntimeDefault: false;
|
|
23726
|
+
enumValues: [string, ...string[]];
|
|
23727
|
+
baseColumn: never;
|
|
23728
|
+
identity: undefined;
|
|
23729
|
+
generated: undefined;
|
|
23730
|
+
}, {}>;
|
|
23731
|
+
sourceCreatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23732
|
+
name: string;
|
|
23733
|
+
tableName: "tracker_items";
|
|
23734
|
+
dataType: "number int53";
|
|
23735
|
+
data: number;
|
|
23736
|
+
driverParam: number;
|
|
23737
|
+
notNull: false;
|
|
23738
|
+
hasDefault: false;
|
|
23739
|
+
isPrimaryKey: false;
|
|
23740
|
+
isAutoincrement: false;
|
|
23741
|
+
hasRuntimeDefault: false;
|
|
23742
|
+
enumValues: undefined;
|
|
23743
|
+
baseColumn: never;
|
|
23744
|
+
identity: undefined;
|
|
23745
|
+
generated: undefined;
|
|
23746
|
+
}, {}>;
|
|
23747
|
+
sourceUpdatedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23748
|
+
name: string;
|
|
23749
|
+
tableName: "tracker_items";
|
|
23750
|
+
dataType: "number int53";
|
|
23751
|
+
data: number;
|
|
23752
|
+
driverParam: number;
|
|
23753
|
+
notNull: false;
|
|
23754
|
+
hasDefault: false;
|
|
23755
|
+
isPrimaryKey: false;
|
|
23756
|
+
isAutoincrement: false;
|
|
23757
|
+
hasRuntimeDefault: false;
|
|
23758
|
+
enumValues: undefined;
|
|
23759
|
+
baseColumn: never;
|
|
23760
|
+
identity: undefined;
|
|
23761
|
+
generated: undefined;
|
|
23762
|
+
}, {}>;
|
|
23763
|
+
archivedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23764
|
+
name: string;
|
|
23765
|
+
tableName: "tracker_items";
|
|
23766
|
+
dataType: "number int53";
|
|
23767
|
+
data: number;
|
|
23768
|
+
driverParam: number;
|
|
23769
|
+
notNull: false;
|
|
23770
|
+
hasDefault: false;
|
|
23771
|
+
isPrimaryKey: false;
|
|
23772
|
+
isAutoincrement: false;
|
|
23773
|
+
hasRuntimeDefault: false;
|
|
23774
|
+
enumValues: undefined;
|
|
23775
|
+
baseColumn: never;
|
|
23776
|
+
identity: undefined;
|
|
23777
|
+
generated: undefined;
|
|
23778
|
+
}, {}>;
|
|
23779
|
+
deletedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23780
|
+
name: string;
|
|
23781
|
+
tableName: "tracker_items";
|
|
23782
|
+
dataType: "number int53";
|
|
23783
|
+
data: number;
|
|
23784
|
+
driverParam: number;
|
|
23785
|
+
notNull: false;
|
|
23786
|
+
hasDefault: false;
|
|
23787
|
+
isPrimaryKey: false;
|
|
23788
|
+
isAutoincrement: false;
|
|
23789
|
+
hasRuntimeDefault: false;
|
|
23790
|
+
enumValues: undefined;
|
|
23791
|
+
baseColumn: never;
|
|
23792
|
+
identity: undefined;
|
|
23793
|
+
generated: undefined;
|
|
23794
|
+
}, {}>;
|
|
23795
|
+
syncedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
23796
|
+
name: string;
|
|
23797
|
+
tableName: "tracker_items";
|
|
23798
|
+
dataType: "number int53";
|
|
23799
|
+
data: number;
|
|
23800
|
+
driverParam: number;
|
|
23801
|
+
notNull: true;
|
|
23802
|
+
hasDefault: false;
|
|
23803
|
+
isPrimaryKey: false;
|
|
23804
|
+
isAutoincrement: false;
|
|
23805
|
+
hasRuntimeDefault: false;
|
|
23806
|
+
enumValues: undefined;
|
|
23807
|
+
baseColumn: never;
|
|
23808
|
+
identity: undefined;
|
|
23809
|
+
generated: undefined;
|
|
23810
|
+
}, {}>;
|
|
23811
|
+
};
|
|
23812
|
+
dialect: 'sqlite';
|
|
23813
|
+
isAlias: false;
|
|
23814
|
+
}>;
|
|
23563
23815
|
/** Settings of the store file itself, shared by every profile, tg and MAX — unlike a profile's config file. */
|
|
23564
23816
|
export declare const storeSettings: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
23565
23817
|
name: "store_settings";
|
|
@@ -2373,6 +2373,34 @@ export const conversationReadiness = sqliteTable("conversation_readiness", {
|
|
|
2373
2373
|
primaryKey({ columns: [table.chatId, table.model] }),
|
|
2374
2374
|
index("conversation_readiness_by_model").on(table.model),
|
|
2375
2375
|
]);
|
|
2376
|
+
/**
|
|
2377
|
+
* One team, user, workflow state, label, project, issue or comment of an issue tracker account, as last synced. The
|
|
2378
|
+
* columns are what lists, filters and search read; the rest of the record is `data`, JSON in the domain's field names.
|
|
2379
|
+
*/
|
|
2380
|
+
export const trackerItems = sqliteTable("tracker_items", {
|
|
2381
|
+
id: integer("id").primaryKey(),
|
|
2382
|
+
accountId: integer("account_id")
|
|
2383
|
+
.notNull()
|
|
2384
|
+
.references(() => accounts.id),
|
|
2385
|
+
kind: text("kind").notNull(),
|
|
2386
|
+
externalId: text("external_id").notNull(),
|
|
2387
|
+
/** A comment's issue, an issue's team, a state's or a label's team: the tracker's id. */
|
|
2388
|
+
parentId: text("parent_id"),
|
|
2389
|
+
title: text("title").notNull(),
|
|
2390
|
+
titleFolded: text("title_folded").notNull(),
|
|
2391
|
+
body: text("body"),
|
|
2392
|
+
normalizedText: text("normalized_text").notNull(),
|
|
2393
|
+
data: text("data").notNull(),
|
|
2394
|
+
sourceCreatedAt: integer("source_created_at"),
|
|
2395
|
+
sourceUpdatedAt: integer("source_updated_at"),
|
|
2396
|
+
archivedAt: integer("archived_at"),
|
|
2397
|
+
/** The tracker no longer lists it. */
|
|
2398
|
+
deletedAt: integer("deleted_at"),
|
|
2399
|
+
syncedAt: integer("synced_at").notNull(),
|
|
2400
|
+
}, (table) => [
|
|
2401
|
+
unique().on(table.accountId, table.kind, table.externalId),
|
|
2402
|
+
index("tracker_items_by_account_id_kind_parent_id").on(table.accountId, table.kind, table.parentId),
|
|
2403
|
+
]);
|
|
2376
2404
|
/** Settings of the store file itself, shared by every profile, tg and MAX — unlike a profile's config file. */
|
|
2377
2405
|
export const storeSettings = sqliteTable("store_settings", {
|
|
2378
2406
|
key: text("key").primaryKey(),
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type StateType, type TrackerKind, type TrackerRecords } from "../../domain/tracker.js";
|
|
2
|
+
import type { CacheDatabase } from "../driver.js";
|
|
3
|
+
import type { AccountKey } from "../types.js";
|
|
4
|
+
import type { StoreContext } from "./open.js";
|
|
5
|
+
/** One stored tracker record with what the store keeps beside it. */
|
|
6
|
+
export interface TrackerItem<K extends TrackerKind = TrackerKind> {
|
|
7
|
+
kind: K;
|
|
8
|
+
record: TrackerRecords[K];
|
|
9
|
+
/** The tracker no longer lists it. */
|
|
10
|
+
deletedAt: number | null;
|
|
11
|
+
syncedAt: number;
|
|
12
|
+
}
|
|
13
|
+
/** What `list` narrows to; an issue filter names the tracker's ids, as the records hold them. */
|
|
14
|
+
export interface TrackerFilter {
|
|
15
|
+
/** A comment's issue, an issue's, a state's or a label's team. */
|
|
16
|
+
parent?: string;
|
|
17
|
+
/** Issues only. */
|
|
18
|
+
assignee?: string | null;
|
|
19
|
+
project?: string;
|
|
20
|
+
state?: string;
|
|
21
|
+
/** Issues whose state is of one of these types. */
|
|
22
|
+
stateTypes?: readonly StateType[];
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Archived rows too; absent, only the live ones. */
|
|
25
|
+
archived?: boolean;
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TrackerHit {
|
|
30
|
+
account: AccountKey;
|
|
31
|
+
item: TrackerItem;
|
|
32
|
+
excerpt: string;
|
|
33
|
+
}
|
|
34
|
+
export interface TrackerSearch {
|
|
35
|
+
words: string[];
|
|
36
|
+
anyWord?: boolean;
|
|
37
|
+
exact?: boolean;
|
|
38
|
+
/** Absent: every tracker account's. */
|
|
39
|
+
accounts?: AccountKey[];
|
|
40
|
+
kinds?: readonly TrackerKind[];
|
|
41
|
+
limit?: number;
|
|
42
|
+
offset?: number;
|
|
43
|
+
}
|
|
44
|
+
/** A tracker user joined to the one person the store knows by the same e-mail. */
|
|
45
|
+
export interface TrackerPerson {
|
|
46
|
+
user: string;
|
|
47
|
+
person: string;
|
|
48
|
+
name: string | null;
|
|
49
|
+
}
|
|
50
|
+
export interface TrackerStore {
|
|
51
|
+
/**
|
|
52
|
+
* Upserts records of one kind; a field a record leaves out keeps its stored value, and a record listed again after
|
|
53
|
+
* the tracker stopped listing it comes back. Answers how many were written.
|
|
54
|
+
*/
|
|
55
|
+
save<K extends TrackerKind>(key: AccountKey, kind: K, records: readonly TrackerRecords[K][], now: number): Promise<number>;
|
|
56
|
+
/**
|
|
57
|
+
* After a complete list of the kind's ids: marks deleted every stored one the list lacks that has not been synced
|
|
58
|
+
* since `before`, so a row saved while the list was read is never taken for a deleted one. Answers how many.
|
|
59
|
+
*/
|
|
60
|
+
removeUnlisted(key: AccountKey, kind: TrackerKind, listed: readonly string[], before: number, now: number, options?: {
|
|
61
|
+
dryRun?: boolean;
|
|
62
|
+
}): Promise<number>;
|
|
63
|
+
get<K extends TrackerKind>(key: AccountKey, kind: K, externalId: string): Promise<TrackerItem<K> | undefined>;
|
|
64
|
+
/** An issue by its readable key (`ENG-12`), in any letter case. */
|
|
65
|
+
issueByKey(key: AccountKey, issueKey: string): Promise<TrackerItem<"issue"> | undefined>;
|
|
66
|
+
/** Live rows of a kind, newest change first; deleted ones never. */
|
|
67
|
+
list<K extends TrackerKind>(key: AccountKey, kind: K, filter?: TrackerFilter): Promise<{
|
|
68
|
+
items: TrackerItem<K>[];
|
|
69
|
+
hasMore: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
find(search: TrackerSearch): Promise<{
|
|
72
|
+
items: TrackerHit[];
|
|
73
|
+
hasMore: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
/** Live rows of the kind, archived ones included. */
|
|
76
|
+
count(key: AccountKey, kind: TrackerKind): Promise<number>;
|
|
77
|
+
/** The tracker users among `users` whose e-mail, in any letter case, an identity linked to one person has. */
|
|
78
|
+
people(key: AccountKey, users: readonly string[]): Promise<TrackerPerson[]>;
|
|
79
|
+
}
|
|
80
|
+
/** `store rebuild`: the normalized copies follow the current normalizer, then the word index is filled again. */
|
|
81
|
+
export declare const resetTrackerItemWords: (database: CacheDatabase) => number;
|
|
82
|
+
export declare const trackerStoreOver: (context: StoreContext) => TrackerStore;
|