@wirecat/cli-core 0.673.0 → 0.675.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 +63 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/config-command.d.ts +6 -0
- package/dist/cli/config-command.js +1 -1
- package/dist/cli/first-run.js +2 -1
- package/dist/cli/help/sections.js +1 -0
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/messenger/projects-command.js +12 -4
- package/dist/cli/messenger/search-command.js +3 -1
- package/dist/cli/option-hints.d.ts +2 -0
- package/dist/cli/option-hints.js +4 -2
- package/dist/cli/project-evidence.js +1 -1
- package/dist/cli/project-status.js +1 -1
- package/dist/cli/settings.d.ts +1 -0
- package/dist/cli/settings.js +6 -3
- package/dist/cli/setup-command.d.ts +4 -0
- package/dist/cli/setup-command.js +394 -0
- package/dist/cli/shared-command-exports.d.ts +6 -0
- package/dist/cli/shared-command-exports.js +2 -0
- package/dist/cli/unknown-profile.js +1 -1
- package/dist/crm/cli/index.js +1 -0
- package/dist/entities/recorded-meeting.d.ts +2 -0
- package/dist/entities/recorded-meeting.js +3 -0
- package/dist/errors/reasons.js +7 -0
- package/dist/kit/index.d.ts +1 -0
- package/dist/kit/index.js +1 -0
- package/dist/meetings/answers.d.ts +1 -0
- package/dist/meetings/index.d.ts +3 -2
- package/dist/meetings/index.js +2 -1
- package/dist/meetings/item.d.ts +17 -1
- package/dist/meetings/item.js +16 -0
- package/dist/meetings/model.d.ts +23 -0
- package/dist/meetings/model.js +2 -1
- package/dist/meetings/pull.js +1 -0
- package/dist/meetings/store.d.ts +1 -1
- package/dist/oauth/storage.js +3 -1
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/person-meetings.d.ts +3 -0
- package/dist/services/person-meetings.js +3 -1
- package/dist/services/project-purposes.d.ts +1 -1
- package/dist/services/project-purposes.js +2 -2
- package/dist/setup/answers.d.ts +58 -0
- package/dist/setup/answers.js +194 -0
- package/dist/setup/define.d.ts +60 -0
- package/dist/setup/define.js +214 -0
- package/dist/setup/document.d.ts +205 -0
- package/dist/setup/document.js +215 -0
- package/dist/setup/files.d.ts +6 -0
- package/dist/setup/files.js +46 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/people.d.ts +14 -0
- package/dist/store/people.js +8 -1
- package/dist/store/sqlite/facts.d.ts +28 -4
- package/dist/store/sqlite/facts.js +56 -6
- package/dist/store/sqlite/identity-rekey.d.ts +46 -0
- package/dist/store/sqlite/identity-rekey.js +191 -0
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/meeting-reads.js +1 -1
- package/dist/store/sqlite/meeting-values.d.ts +2 -1
- package/dist/store/sqlite/meeting-values.js +23 -1
- package/dist/store/sqlite/meetings.js +10 -3
- package/dist/store/sqlite/migrations.generated.js +9 -0
- package/dist/store/sqlite/note-search.js +2 -2
- package/dist/store/sqlite/notes.d.ts +3 -1
- package/dist/store/sqlite/notes.js +8 -6
- package/dist/store/sqlite/schema.d.ts +153 -0
- package/dist/store/sqlite/schema.js +12 -0
- package/dist/store/sqlite/things.d.ts +2 -0
- package/dist/store/sqlite/things.js +5 -0
- package/dist/store/sqlite/vectors.js +5 -3
- package/dist/terminal/sign-in-steps.d.ts +12 -1
- package/dist/terminal/sign-in-steps.js +3 -3
- package/package.json +2 -2
- package/parity.json +3 -3
|
@@ -1335,5 +1335,14 @@ export const GENERATED = [
|
|
|
1335
1335
|
"CREATE TRIGGER person_kind_identity_au AFTER UPDATE OF provider, external_id, name, username, phone, email, bot ON identities\nWHEN OLD.provider IS NOT NEW.provider OR OLD.external_id IS NOT NEW.external_id OR OLD.name IS NOT NEW.name OR OLD.username IS NOT NEW.username OR OLD.phone IS NOT NEW.phone OR OLD.email IS NOT NEW.email OR OLD.bot IS NOT NEW.bot BEGIN\n UPDATE persons SET kind = NULL WHERE kind IS NOT NULL AND id IN (SELECT person_id FROM identity_links WHERE identity_id = NEW.id);\nEND;",
|
|
1336
1336
|
"UPDATE persons SET kind = NULL WHERE kind IS NOT NULL AND trim(coalesce(name, '')) = '';"
|
|
1337
1337
|
]
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
"name": "20261113154357_version-67-fact-removals-call-fields",
|
|
1341
|
+
"statements": [
|
|
1342
|
+
"CREATE TABLE `fact_removals` (\n\t`id` integer PRIMARY KEY,\n\t`fact_id` integer NOT NULL,\n\t`subject` text,\n\t`removed_by` text NOT NULL,\n\t`bot` text,\n\t`reason` text,\n\t`removed_at` integer NOT NULL\n);",
|
|
1343
|
+
"ALTER TABLE `meetings` ADD `direction` text;",
|
|
1344
|
+
"ALTER TABLE `meetings` ADD `client_phone` text;",
|
|
1345
|
+
"CREATE INDEX `fact_removals_by_removed_at` ON `fact_removals` (`removed_at`);"
|
|
1346
|
+
]
|
|
1338
1347
|
}
|
|
1339
1348
|
];
|
|
@@ -93,7 +93,7 @@ export const searchNotes = (context, query) => {
|
|
|
93
93
|
return {
|
|
94
94
|
items: rows.slice(offset, offset + query.limit).map((row) => {
|
|
95
95
|
const found = read[row.type === "document" ? "document" : "note"].get(row.id);
|
|
96
|
-
const note = row.type === "document" ? documentOf(found) : noteOf(found);
|
|
96
|
+
const note = row.type === "document" ? documentOf(found) : noteOf(found, context.database);
|
|
97
97
|
return {
|
|
98
98
|
ref: note.ref,
|
|
99
99
|
note,
|
|
@@ -348,7 +348,7 @@ export const noteSearchOver = (context) => {
|
|
|
348
348
|
const drain = () => drainNoteIndex(database, stemmerFor);
|
|
349
349
|
const read = (type, id) => {
|
|
350
350
|
const row = database.prepare(`SELECT * FROM ${type === "document" ? "documents" : "notes"} WHERE id = ?`).get(id);
|
|
351
|
-
return row ? (type === "document" ? documentOf(row) : noteOf(row)) : undefined;
|
|
351
|
+
return row ? (type === "document" ? documentOf(row) : noteOf(row, database)) : undefined;
|
|
352
352
|
};
|
|
353
353
|
const live = (folderIds, source, withInternal = false) => {
|
|
354
354
|
const folders = folderIds?.length ? JSON.stringify(folderIds) : null;
|
|
@@ -45,6 +45,8 @@ export interface Note {
|
|
|
45
45
|
contentHash: string | null;
|
|
46
46
|
revision: number;
|
|
47
47
|
exportPath: string | null;
|
|
48
|
+
/** A note's first `about`, kept on the note and not among its links; `null` for a document or a note to self. */
|
|
49
|
+
subject: string | null;
|
|
48
50
|
/**
|
|
49
51
|
* When the source dates the note: a local file's front matter date or modification time, a Drive file's last
|
|
50
52
|
* edit; `null` when the source gave none. `createdAt` and `updatedAt` are the store's own times.
|
|
@@ -211,7 +213,7 @@ export declare const keepRevision: (database: CacheDatabase, row: Row, at: numbe
|
|
|
211
213
|
changes: number;
|
|
212
214
|
};
|
|
213
215
|
export declare const documentOf: (row: Row) => Note;
|
|
214
|
-
export declare const noteOf: (row: Row) => Note;
|
|
216
|
+
export declare const noteOf: (row: Row, database: CacheDatabase) => Note;
|
|
215
217
|
/** A document or note row by its typed reference, or `undefined`. */
|
|
216
218
|
export declare const noteRowOf: (database: CacheDatabase, reference: string) => Note | undefined;
|
|
217
219
|
/** The row a reference names, refused when the store holds none. */
|
|
@@ -23,7 +23,7 @@ import { dateFileNotes } from "./note-dates.js";
|
|
|
23
23
|
import { holdingText } from "./note-index.js";
|
|
24
24
|
import { addTags, ensureTag, labelsOf } from "./tags.js";
|
|
25
25
|
import { oneOf, textOf } from "./text-input.js";
|
|
26
|
-
import { thingOf } from "./things.js";
|
|
26
|
+
import { referenceUnlessOwner, thingOf } from "./things.js";
|
|
27
27
|
import { write } from "./transaction.js";
|
|
28
28
|
import { trigramPart } from "./trigram-match.js";
|
|
29
29
|
export const NOTE_FORMATS = ["obsidian", "markdown"];
|
|
@@ -43,6 +43,7 @@ export const keepRevision = (database, row, at) => database
|
|
|
43
43
|
export const documentOf = (row) => ({
|
|
44
44
|
id: String(row.id),
|
|
45
45
|
ref: `document:${row.id}`,
|
|
46
|
+
subject: null,
|
|
46
47
|
source: "file",
|
|
47
48
|
folderId: String(row.account_id),
|
|
48
49
|
path: String(row.external_id),
|
|
@@ -57,9 +58,10 @@ export const documentOf = (row) => ({
|
|
|
57
58
|
updatedAt: iso(row.updated_at),
|
|
58
59
|
deletedAt: optionalIso(row.deleted_at),
|
|
59
60
|
});
|
|
60
|
-
export const noteOf = (row) => ({
|
|
61
|
+
export const noteOf = (row, database) => ({
|
|
61
62
|
id: String(row.id),
|
|
62
63
|
ref: `note:${row.id}`,
|
|
64
|
+
subject: referenceUnlessOwner(database, { type: String(row.notable_type), id: Number(row.notable_id) }),
|
|
63
65
|
source: "internal",
|
|
64
66
|
folderId: null,
|
|
65
67
|
path: null,
|
|
@@ -80,7 +82,7 @@ export const noteRowOf = (database, reference) => {
|
|
|
80
82
|
if (thing?.type === "document")
|
|
81
83
|
return documentOf(database.prepare("SELECT * FROM documents WHERE id = ?").get(thing.id));
|
|
82
84
|
if (thing?.type === "note")
|
|
83
|
-
return noteOf(database.prepare("SELECT * FROM notes WHERE id = ?").get(thing.id));
|
|
85
|
+
return noteOf(database.prepare("SELECT * FROM notes WHERE id = ?").get(thing.id), database);
|
|
84
86
|
return undefined;
|
|
85
87
|
};
|
|
86
88
|
/** The row a reference names, refused when the store holds none. */
|
|
@@ -534,7 +536,7 @@ export const notesStoreOver = (context) => {
|
|
|
534
536
|
const id = Number(row?.id);
|
|
535
537
|
for (const reference of about.slice(1))
|
|
536
538
|
insertLink(context, { from: `note:${id}`, to: reference, kind: "about", origin: "owner" });
|
|
537
|
-
return noteOf(noteRow(String(id)));
|
|
539
|
+
return noteOf(noteRow(String(id)), database);
|
|
538
540
|
}),
|
|
539
541
|
note: async (reference) => anyNote(reference),
|
|
540
542
|
resolveNote: async (reference) => {
|
|
@@ -583,7 +585,7 @@ export const notesStoreOver = (context) => {
|
|
|
583
585
|
`AND (? IS NULL OR (n.notable_type = ? AND n.notable_id IN (SELECT value FROM json_each(?))) OR EXISTS (SELECT 1 FROM links l WHERE l.from_type = 'note' AND l.from_id = n.id AND l.kind = ${linkKind("about")} AND l.to_type = ? AND l.to_id IN (SELECT value FROM json_each(?)))) ` +
|
|
584
586
|
`${noteText ? `AND ${noteText.sql} ` : ""}ORDER BY n.created_at DESC, n.id DESC LIMIT ?`)
|
|
585
587
|
.all(aboutType, aboutType, aboutId, aboutType, aboutId, ...(noteText?.params ?? []), limit + offset + 1)
|
|
586
|
-
.map(noteOf);
|
|
588
|
+
.map((row) => noteOf(row, database));
|
|
587
589
|
const all = [...files, ...written].sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.ref.localeCompare(a.ref));
|
|
588
590
|
return { items: all.slice(offset, offset + limit), hasMore: all.length > offset + limit };
|
|
589
591
|
},
|
|
@@ -612,7 +614,7 @@ export const notesStoreOver = (context) => {
|
|
|
612
614
|
database
|
|
613
615
|
.prepare("INSERT INTO note_revisions (note_id, body, revision, created_at) VALUES (?, ?, ?, ?)")
|
|
614
616
|
.run(Number(bare), String(found.body), revision, now());
|
|
615
|
-
return noteOf(noteRow(bare));
|
|
617
|
+
return noteOf(noteRow(bare), database);
|
|
616
618
|
}),
|
|
617
619
|
removeNote: async (id) => write(database, () => {
|
|
618
620
|
if (id.startsWith("document:"))
|
|
@@ -10579,6 +10579,38 @@ export declare const meetings: import("drizzle-orm/sqlite-core").SQLiteTableWith
|
|
|
10579
10579
|
identity: undefined;
|
|
10580
10580
|
generated: undefined;
|
|
10581
10581
|
}, {}>;
|
|
10582
|
+
direction: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
10583
|
+
name: string;
|
|
10584
|
+
tableName: "meetings";
|
|
10585
|
+
dataType: "string";
|
|
10586
|
+
data: string;
|
|
10587
|
+
driverParam: string;
|
|
10588
|
+
notNull: false;
|
|
10589
|
+
hasDefault: false;
|
|
10590
|
+
isPrimaryKey: false;
|
|
10591
|
+
isAutoincrement: false;
|
|
10592
|
+
hasRuntimeDefault: false;
|
|
10593
|
+
enumValues: [string, ...string[]];
|
|
10594
|
+
baseColumn: never;
|
|
10595
|
+
identity: undefined;
|
|
10596
|
+
generated: undefined;
|
|
10597
|
+
}, {}>;
|
|
10598
|
+
clientPhone: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
10599
|
+
name: string;
|
|
10600
|
+
tableName: "meetings";
|
|
10601
|
+
dataType: "string";
|
|
10602
|
+
data: string;
|
|
10603
|
+
driverParam: string;
|
|
10604
|
+
notNull: false;
|
|
10605
|
+
hasDefault: false;
|
|
10606
|
+
isPrimaryKey: false;
|
|
10607
|
+
isAutoincrement: false;
|
|
10608
|
+
hasRuntimeDefault: false;
|
|
10609
|
+
enumValues: [string, ...string[]];
|
|
10610
|
+
baseColumn: never;
|
|
10611
|
+
identity: undefined;
|
|
10612
|
+
generated: undefined;
|
|
10613
|
+
}, {}>;
|
|
10582
10614
|
};
|
|
10583
10615
|
dialect: 'sqlite';
|
|
10584
10616
|
isAlias: false;
|
|
@@ -13992,6 +14024,127 @@ export declare const facts: import("drizzle-orm/sqlite-core").SQLiteTableWithCol
|
|
|
13992
14024
|
dialect: 'sqlite';
|
|
13993
14025
|
isAlias: false;
|
|
13994
14026
|
}>;
|
|
14027
|
+
/** One row per removed fact: that it was removed, by whom, when and why; never its text or value. */
|
|
14028
|
+
export declare const factRemovals: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
14029
|
+
name: "fact_removals";
|
|
14030
|
+
schema: undefined;
|
|
14031
|
+
columns: {
|
|
14032
|
+
id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14033
|
+
name: string;
|
|
14034
|
+
tableName: "fact_removals";
|
|
14035
|
+
dataType: "number int53";
|
|
14036
|
+
data: number;
|
|
14037
|
+
driverParam: number;
|
|
14038
|
+
notNull: true;
|
|
14039
|
+
hasDefault: true;
|
|
14040
|
+
isPrimaryKey: true;
|
|
14041
|
+
isAutoincrement: false;
|
|
14042
|
+
hasRuntimeDefault: false;
|
|
14043
|
+
enumValues: undefined;
|
|
14044
|
+
baseColumn: never;
|
|
14045
|
+
identity: undefined;
|
|
14046
|
+
generated: undefined;
|
|
14047
|
+
}, {}>;
|
|
14048
|
+
factId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14049
|
+
name: string;
|
|
14050
|
+
tableName: "fact_removals";
|
|
14051
|
+
dataType: "number int53";
|
|
14052
|
+
data: number;
|
|
14053
|
+
driverParam: number;
|
|
14054
|
+
notNull: true;
|
|
14055
|
+
hasDefault: false;
|
|
14056
|
+
isPrimaryKey: false;
|
|
14057
|
+
isAutoincrement: false;
|
|
14058
|
+
hasRuntimeDefault: false;
|
|
14059
|
+
enumValues: undefined;
|
|
14060
|
+
baseColumn: never;
|
|
14061
|
+
identity: undefined;
|
|
14062
|
+
generated: undefined;
|
|
14063
|
+
}, {}>;
|
|
14064
|
+
subject: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14065
|
+
name: string;
|
|
14066
|
+
tableName: "fact_removals";
|
|
14067
|
+
dataType: "string";
|
|
14068
|
+
data: string;
|
|
14069
|
+
driverParam: string;
|
|
14070
|
+
notNull: false;
|
|
14071
|
+
hasDefault: false;
|
|
14072
|
+
isPrimaryKey: false;
|
|
14073
|
+
isAutoincrement: false;
|
|
14074
|
+
hasRuntimeDefault: false;
|
|
14075
|
+
enumValues: [string, ...string[]];
|
|
14076
|
+
baseColumn: never;
|
|
14077
|
+
identity: undefined;
|
|
14078
|
+
generated: undefined;
|
|
14079
|
+
}, {}>;
|
|
14080
|
+
removedBy: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14081
|
+
name: string;
|
|
14082
|
+
tableName: "fact_removals";
|
|
14083
|
+
dataType: "string";
|
|
14084
|
+
data: string;
|
|
14085
|
+
driverParam: string;
|
|
14086
|
+
notNull: true;
|
|
14087
|
+
hasDefault: false;
|
|
14088
|
+
isPrimaryKey: false;
|
|
14089
|
+
isAutoincrement: false;
|
|
14090
|
+
hasRuntimeDefault: false;
|
|
14091
|
+
enumValues: [string, ...string[]];
|
|
14092
|
+
baseColumn: never;
|
|
14093
|
+
identity: undefined;
|
|
14094
|
+
generated: undefined;
|
|
14095
|
+
}, {}>;
|
|
14096
|
+
bot: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14097
|
+
name: string;
|
|
14098
|
+
tableName: "fact_removals";
|
|
14099
|
+
dataType: "string";
|
|
14100
|
+
data: string;
|
|
14101
|
+
driverParam: string;
|
|
14102
|
+
notNull: false;
|
|
14103
|
+
hasDefault: false;
|
|
14104
|
+
isPrimaryKey: false;
|
|
14105
|
+
isAutoincrement: false;
|
|
14106
|
+
hasRuntimeDefault: false;
|
|
14107
|
+
enumValues: [string, ...string[]];
|
|
14108
|
+
baseColumn: never;
|
|
14109
|
+
identity: undefined;
|
|
14110
|
+
generated: undefined;
|
|
14111
|
+
}, {}>;
|
|
14112
|
+
reason: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14113
|
+
name: string;
|
|
14114
|
+
tableName: "fact_removals";
|
|
14115
|
+
dataType: "string";
|
|
14116
|
+
data: string;
|
|
14117
|
+
driverParam: string;
|
|
14118
|
+
notNull: false;
|
|
14119
|
+
hasDefault: false;
|
|
14120
|
+
isPrimaryKey: false;
|
|
14121
|
+
isAutoincrement: false;
|
|
14122
|
+
hasRuntimeDefault: false;
|
|
14123
|
+
enumValues: [string, ...string[]];
|
|
14124
|
+
baseColumn: never;
|
|
14125
|
+
identity: undefined;
|
|
14126
|
+
generated: undefined;
|
|
14127
|
+
}, {}>;
|
|
14128
|
+
removedAt: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
14129
|
+
name: string;
|
|
14130
|
+
tableName: "fact_removals";
|
|
14131
|
+
dataType: "number int53";
|
|
14132
|
+
data: number;
|
|
14133
|
+
driverParam: number;
|
|
14134
|
+
notNull: true;
|
|
14135
|
+
hasDefault: false;
|
|
14136
|
+
isPrimaryKey: false;
|
|
14137
|
+
isAutoincrement: false;
|
|
14138
|
+
hasRuntimeDefault: false;
|
|
14139
|
+
enumValues: undefined;
|
|
14140
|
+
baseColumn: never;
|
|
14141
|
+
identity: undefined;
|
|
14142
|
+
generated: undefined;
|
|
14143
|
+
}, {}>;
|
|
14144
|
+
};
|
|
14145
|
+
dialect: 'sqlite';
|
|
14146
|
+
isAlias: false;
|
|
14147
|
+
}>;
|
|
13995
14148
|
/** An invoice the owner issued or received; its total is the sum of its lines, its status follows allocations. */
|
|
13996
14149
|
export declare const invoices: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
13997
14150
|
name: "invoices";
|
|
@@ -1077,6 +1077,8 @@ export const meetings = sqliteTable("meetings", {
|
|
|
1077
1077
|
deletedAt: integer("deleted_at"),
|
|
1078
1078
|
titleFolded: text("title_folded"),
|
|
1079
1079
|
joinKey: text("join_key"),
|
|
1080
|
+
direction: text("direction"),
|
|
1081
|
+
clientPhone: text("client_phone"),
|
|
1080
1082
|
}, (table) => [
|
|
1081
1083
|
unique().on(table.accountId, table.externalId),
|
|
1082
1084
|
index("meetings_by_join_key").on(table.joinKey).where(sql `join_key IS NOT NULL`),
|
|
@@ -1410,6 +1412,16 @@ export const facts = sqliteTable("facts", {
|
|
|
1410
1412
|
index("facts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1411
1413
|
index("facts_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1412
1414
|
]);
|
|
1415
|
+
/** One row per removed fact: that it was removed, by whom, when and why; never its text or value. */
|
|
1416
|
+
export const factRemovals = sqliteTable("fact_removals", {
|
|
1417
|
+
id: integer("id").primaryKey(),
|
|
1418
|
+
factId: integer("fact_id").notNull(),
|
|
1419
|
+
subject: text("subject"),
|
|
1420
|
+
removedBy: text("removed_by").notNull(),
|
|
1421
|
+
bot: text("bot"),
|
|
1422
|
+
reason: text("reason"),
|
|
1423
|
+
removedAt: integer("removed_at").notNull(),
|
|
1424
|
+
}, (table) => [index("fact_removals_by_removed_at").on(table.removedAt)]);
|
|
1413
1425
|
/** An invoice the owner issued or received; its total is the sum of its lines, its status follows allocations. */
|
|
1414
1426
|
export const invoices = sqliteTable("invoices", {
|
|
1415
1427
|
id: integer("id").primaryKey(),
|
|
@@ -17,6 +17,8 @@ export declare const thingOf: (database: CacheDatabase, reference: Reference | s
|
|
|
17
17
|
/** Mail that memo saved before it wrote the mail tables is still messages, so the caller falls back to them. */
|
|
18
18
|
export declare const emailOf: (database: CacheDatabase, account: string, thread: string, email: string) => Thing | undefined;
|
|
19
19
|
export declare const emailThreadOf: (database: CacheDatabase, account: string, thread: string) => Thing | undefined;
|
|
20
|
+
/** `referenceOfThing`, but `null` for the owner's own person and for a row that is gone. */
|
|
21
|
+
export declare const referenceUnlessOwner: (database: CacheDatabase, thing: Thing) => string | null;
|
|
20
22
|
/** The reference people and agents read for a row; `undefined` once the row is gone. */
|
|
21
23
|
export declare const referenceOfThing: (database: CacheDatabase, thing: Thing) => string | undefined;
|
|
22
24
|
export declare const stateOfThing: (database: CacheDatabase, thing: Thing | undefined) => ThingState;
|
|
@@ -106,6 +106,11 @@ export const emailThreadOf = (database, account, thread) => {
|
|
|
106
106
|
.get(account, thread);
|
|
107
107
|
return row ? { type: "email_thread", id: Number(row.id) } : undefined;
|
|
108
108
|
};
|
|
109
|
+
/** `referenceOfThing`, but `null` for the owner's own person and for a row that is gone. */
|
|
110
|
+
export const referenceUnlessOwner = (database, thing) => {
|
|
111
|
+
const owner = thing.type === "person" && database.prepare("SELECT owner FROM persons WHERE id = ?").get(thing.id)?.owner;
|
|
112
|
+
return owner ? null : (referenceOfThing(database, thing) ?? null);
|
|
113
|
+
};
|
|
109
114
|
/** The reference people and agents read for a row; `undefined` once the row is gone. */
|
|
110
115
|
export const referenceOfThing = (database, thing) => {
|
|
111
116
|
if (["meeting", "meeting_transcript", "meeting_transcript_row"].includes(thing.type)) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { chunkHash, chunkTextOf } from "../../conversations/chunks.js";
|
|
2
2
|
import { sql } from "./drizzle/core.js";
|
|
3
3
|
import { ensureVectorIndex, searchIndex, unitVector } from "./vector-index.js";
|
|
4
|
+
/** No planner statistics in the store: without CROSS JOIN SQLite reads every chunk of the store, of every chat. */
|
|
4
5
|
const currentChunks = (chatKey) => sql `SELECT k.content_hash, k.chunkable_id AS conversation_id, r.first_message_id,
|
|
5
|
-
r.last_message_id, r.text_start, r.text_end FROM
|
|
6
|
-
JOIN
|
|
6
|
+
r.last_message_id, r.text_start, r.text_end FROM conversations c
|
|
7
|
+
CROSS JOIN chunks k ON k.chunkable_type = 'conversation' AND k.chunkable_id = c.id
|
|
8
|
+
JOIN chunk_messages r ON r.chunk_id = k.id
|
|
7
9
|
WHERE c.chat_id = ${chatKey}
|
|
8
10
|
AND c.build = (SELECT s.current_build FROM conversation_state s WHERE s.chat_id = ${chatKey})`;
|
|
9
11
|
/**
|
|
@@ -308,7 +310,7 @@ export const readiness = ({ orm }, chatKey, model) => {
|
|
|
308
310
|
JOIN conversations c ON c.id = cm.conversation_id AND c.build = ${build}
|
|
309
311
|
WHERE m.chat_id = ${chatKey} AND (m.deleted_at IS NOT NULL OR ${editedSince(sql `m.id`)})),
|
|
310
312
|
stale AS (SELECT DISTINCT k.content_hash AS hash FROM changed g
|
|
311
|
-
JOIN chunks k ON k.chunkable_type = 'conversation' AND k.chunkable_id = g.conversation_id
|
|
313
|
+
CROSS JOIN chunks k ON k.chunkable_type = 'conversation' AND k.chunkable_id = g.conversation_id
|
|
312
314
|
JOIN chunk_messages r ON r.chunk_id = k.id
|
|
313
315
|
JOIN messages f ON f.id = r.first_message_id JOIN messages l ON l.id = r.last_message_id
|
|
314
316
|
WHERE (g.sent_at, g.id) >= (f.sent_at, f.id) AND (g.sent_at, g.id) <= (l.sent_at, l.id)),
|
|
@@ -20,6 +20,8 @@ export interface SignInStepsOptions {
|
|
|
20
20
|
/** `--answer-stdin`. */
|
|
21
21
|
answers: boolean;
|
|
22
22
|
input?: NodeJS.ReadableStream;
|
|
23
|
+
/** The run's one reader of stdin, when the command read a line of its own first (`setup run`'s answers). */
|
|
24
|
+
lines?: (signal?: AbortSignal) => Promise<string>;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
27
|
* A sign-in told as JSON lines on the diagnostic stream, for a window to draw instead of a terminal: `open_url`,
|
|
@@ -35,4 +37,13 @@ export interface SignInSteps {
|
|
|
35
37
|
/** A `signal` that aborts withdraws the question: the caller got its answer another way (a browser callback). */
|
|
36
38
|
ask: (need: Need, signal?: AbortSignal) => Promise<string>;
|
|
37
39
|
}
|
|
38
|
-
export declare const signInSteps: ({ diagnostic, json, answers, input }: SignInStepsOptions) => SignInSteps;
|
|
40
|
+
export declare const signInSteps: ({ diagnostic, json, answers, input, lines, }: SignInStepsOptions) => SignInSteps;
|
|
41
|
+
/**
|
|
42
|
+
* One reader for the whole run, so a second answer that arrived with the first is not lost. It reads only while a
|
|
43
|
+
* question waits and pauses stdin between them, so a pipe the caller keeps open does not hold the process after the
|
|
44
|
+
* last answer.
|
|
45
|
+
*/
|
|
46
|
+
export declare const lineReader: (input: NodeJS.ReadableStream & {
|
|
47
|
+
ref?: () => void;
|
|
48
|
+
unref?: () => void;
|
|
49
|
+
}) => (signal?: AbortSignal) => Promise<string>;
|
|
@@ -8,11 +8,11 @@ import { stepLines } from "./step-lines.js";
|
|
|
8
8
|
* gets today, and only a caller that holds stdin open and answers each `needs` line (WireCat Desktop) passes it.
|
|
9
9
|
*/
|
|
10
10
|
export const answerStdinOption = () => new Option("--answer-stdin", "with --json and no terminal: print each question as a `needs` line on stderr and read its answer, one line, from stdin");
|
|
11
|
-
export const signInSteps = ({ diagnostic, json, answers, input = process.stdin }) => {
|
|
11
|
+
export const signInSteps = ({ diagnostic, json, answers, input = process.stdin, lines, }) => {
|
|
12
12
|
if (answers && !json)
|
|
13
13
|
throw new CliError("validation_error", "--answer-stdin needs --json");
|
|
14
14
|
const emit = stepLines(diagnostic, json);
|
|
15
|
-
const next = answers ? lineReader(input) : undefined;
|
|
15
|
+
const next = answers ? (lines ?? lineReader(input)) : undefined;
|
|
16
16
|
return {
|
|
17
17
|
json,
|
|
18
18
|
answers,
|
|
@@ -35,7 +35,7 @@ export const signInSteps = ({ diagnostic, json, answers, input = process.stdin }
|
|
|
35
35
|
* question waits and pauses stdin between them, so a pipe the caller keeps open does not hold the process after the
|
|
36
36
|
* last answer.
|
|
37
37
|
*/
|
|
38
|
-
const lineReader = (input) => {
|
|
38
|
+
export const lineReader = (input) => {
|
|
39
39
|
const decoder = new StringDecoder("utf8");
|
|
40
40
|
let buffered = "";
|
|
41
41
|
let ended = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.675.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":
|
|
18
|
+
"speaks": 67,
|
|
19
19
|
"minCompatible": 56
|
|
20
20
|
}
|
|
21
21
|
},
|
package/parity.json
CHANGED
|
@@ -869,7 +869,7 @@
|
|
|
869
869
|
"value": "<url>",
|
|
870
870
|
"meaning": "the tunnel's https address: the browser apps reach mcp serve --http through it, a messenger delivers to bot watch"
|
|
871
871
|
},
|
|
872
|
-
"--
|
|
872
|
+
"--purposes": {
|
|
873
873
|
"value": "<purposes>",
|
|
874
874
|
"meaning": "the linked chats' purposes to read, comma-separated, or all; a chat left out is counted"
|
|
875
875
|
},
|
|
@@ -3832,7 +3832,7 @@
|
|
|
3832
3832
|
"--limit": "all",
|
|
3833
3833
|
"--max-pages": "all",
|
|
3834
3834
|
"--no-catch-up": "all",
|
|
3835
|
-
"--
|
|
3835
|
+
"--purposes": "all",
|
|
3836
3836
|
"--since-time": "all",
|
|
3837
3837
|
"--sync-first": "all",
|
|
3838
3838
|
"--sync-time": "all"
|
|
@@ -3846,7 +3846,7 @@
|
|
|
3846
3846
|
"options": {
|
|
3847
3847
|
"--before-time": "all",
|
|
3848
3848
|
"--context-query": "all",
|
|
3849
|
-
"--
|
|
3849
|
+
"--purposes": "all",
|
|
3850
3850
|
"--since-time": "all"
|
|
3851
3851
|
}
|
|
3852
3852
|
},
|