@wirecat/cli-core 0.618.0 → 0.619.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 +339 -1
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES +3 -0
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/background/deliver.d.ts +5 -2
- package/dist/background/deliver.js +30 -12
- package/dist/background/report/render.d.ts +3 -1
- package/dist/background/report/render.js +3 -1
- package/dist/calendar/cli/answers.d.ts +1 -0
- package/dist/calendar/cli/answers.js +6 -1
- package/dist/calendar/cli/index.js +2 -14
- package/dist/calendar/cli/people-link.d.ts +3 -0
- package/dist/calendar/cli/people-link.js +23 -0
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/index.js +1 -1
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/cli/base-stages-command.d.ts +22 -0
- package/dist/cli/base-stages-command.js +174 -0
- package/dist/cli/command-runs.d.ts +2 -0
- package/dist/cli/command-runs.js +3 -1
- package/dist/cli/config-command.js +6 -1
- package/dist/cli/context.js +1 -0
- package/dist/cli/group-lock.d.ts +42 -0
- package/dist/cli/group-lock.js +130 -0
- package/dist/cli/index.d.ts +7 -2
- package/dist/cli/index.js +7 -2
- package/dist/cli/messenger/backfill-command.js +27 -15
- package/dist/cli/messenger/contacts-command.js +10 -3
- package/dist/cli/messenger/context.js +1 -0
- package/dist/cli/messenger/doctor-command.js +3 -1
- package/dist/cli/messenger/models-command.js +1 -1
- package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
- package/dist/cli/messenger/store-maintenance-command.js +9 -4
- package/dist/cli/model-catalogue-command.d.ts +3 -1
- package/dist/cli/model-catalogue-command.js +46 -2
- package/dist/cli/profile.d.ts +8 -0
- package/dist/cli/profile.js +25 -0
- package/dist/cli/program.js +2 -0
- package/dist/cli/runs/search-query.d.ts +1 -1
- package/dist/cli/runs/search-query.js +4 -0
- package/dist/cli/runs/search.d.ts +5 -1
- package/dist/cli/runs/search.js +12 -1
- package/dist/cli/search-left-out.d.ts +6 -1
- package/dist/cli/search-left-out.js +9 -4
- package/dist/cli/settings.d.ts +8 -0
- package/dist/cli/settings.js +17 -2
- package/dist/cli/shared-command-exports.d.ts +16 -0
- package/dist/cli/store-recover.d.ts +3 -3
- package/dist/cli/store-recover.js +26 -26
- package/dist/cli/store-settings.d.ts +2 -0
- package/dist/cli/store-settings.js +37 -9
- package/dist/crm/cli/index.js +38 -6
- package/dist/crm/group-hint.d.ts +8 -0
- package/dist/crm/group-hint.js +13 -0
- package/dist/crm/source.d.ts +12 -1
- package/dist/crm/sync.d.ts +31 -2
- package/dist/crm/sync.js +110 -3
- package/dist/crm/testing/acme-scenario.d.ts +40 -0
- package/dist/crm/testing/acme-scenario.js +170 -0
- package/dist/crm/testing/index.d.ts +1 -0
- package/dist/crm/testing/index.js +1 -0
- package/dist/crm/testing/source-contract.js +12 -0
- package/dist/crm/testing/source.d.ts +2 -0
- package/dist/crm/testing/source.js +1 -0
- package/dist/domain/addresses.d.ts +13 -0
- package/dist/domain/addresses.js +63 -0
- package/dist/domain/categories.d.ts +3 -0
- package/dist/domain/categories.js +2 -0
- package/dist/domain/crm.d.ts +23 -0
- package/dist/domain/crm.js +7 -0
- package/dist/domain/mentions.d.ts +2 -12
- package/dist/domain/mentions.js +2 -19
- package/dist/domain/orders.d.ts +8 -1
- package/dist/domain/orders.js +6 -2
- package/dist/domain/phones.d.ts +26 -0
- package/dist/domain/phones.js +48 -0
- package/dist/domain/record-types.d.ts +1 -1
- package/dist/domain/record-types.js +1 -0
- package/dist/domain/records.d.ts +5 -0
- package/dist/domain/ref-summaries.d.ts +39 -0
- package/dist/domain/ref-summaries.js +51 -3
- package/dist/domain/relations.d.ts +12 -2
- package/dist/domain/relations.js +14 -3
- package/dist/domain/vcard.d.ts +2 -2
- package/dist/domain/vcard.js +4 -10
- package/dist/embeddings/models.d.ts +11 -3
- package/dist/embeddings/models.js +28 -4
- package/dist/entities/business-context.d.ts +149 -0
- package/dist/entities/business-context.js +192 -0
- package/dist/entities/contact-activity.d.ts +2 -0
- package/dist/entities/contact-activity.js +7 -1
- package/dist/entities/contact-context.d.ts +157 -0
- package/dist/entities/contact-context.js +2 -0
- package/dist/entities/deal.d.ts +10 -0
- package/dist/entities/deal.js +2 -0
- package/dist/entities/index.d.ts +23 -3
- package/dist/entities/index.js +5 -0
- package/dist/entities/mention.d.ts +4 -3
- package/dist/entities/mention.js +2 -1
- package/dist/entities/message-transfer.d.ts +4 -2
- package/dist/entities/message-transfer.js +2 -2
- package/dist/entities/model.d.ts +2 -2
- package/dist/entities/model.js +1 -1
- package/dist/entities/relationship.d.ts +4 -0
- package/dist/entities/relationship.js +4 -0
- package/dist/errors/reasons.js +37 -4
- package/dist/fetch/page.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/meetings/context-store.d.ts +2 -0
- package/dist/meetings/findings-rules.d.ts +4 -0
- package/dist/meetings/findings-rules.js +5 -2
- package/dist/meetings/result-items.d.ts +1 -0
- package/dist/meetings/result-items.js +1 -0
- package/dist/models/index.js +22 -5
- package/dist/runs/events.d.ts +11 -1
- package/dist/runs/events.js +3 -1
- package/dist/runs/log-attributes.js +4 -0
- package/dist/runs/log-events.js +2 -0
- package/dist/runs/recording.d.ts +3 -0
- package/dist/runs/recording.js +36 -12
- package/dist/runs/run.d.ts +12 -3
- package/dist/runs/run.js +32 -13
- package/dist/search/account-list.d.ts +6 -0
- package/dist/search/account-list.js +9 -3
- package/dist/search/groups.d.ts +68 -0
- package/dist/search/groups.js +172 -0
- package/dist/services/account-groups.d.ts +28 -0
- package/dist/services/account-groups.js +89 -0
- package/dist/services/archive.d.ts +7 -1
- package/dist/services/archive.js +19 -3
- package/dist/services/business-context.d.ts +113 -0
- package/dist/services/business-context.js +156 -0
- package/dist/services/communications.d.ts +50 -0
- package/dist/services/communications.js +140 -0
- package/dist/services/deal-context.d.ts +90 -0
- package/dist/services/deal-context.js +131 -0
- package/dist/services/deps.d.ts +2 -0
- package/dist/services/enrichment.d.ts +7 -2
- package/dist/services/enrichment.js +46 -5
- package/dist/services/events-search.js +2 -1
- package/dist/services/group-guard.d.ts +28 -0
- package/dist/services/group-guard.js +131 -0
- package/dist/services/index.d.ts +15 -2
- package/dist/services/index.js +9 -2
- package/dist/services/ingest.d.ts +12 -0
- package/dist/services/ingest.js +4 -0
- package/dist/services/meaning-model.d.ts +7 -0
- package/dist/services/meaning-model.js +20 -0
- package/dist/services/meeting-context.d.ts +6 -1
- package/dist/services/meeting-context.js +12 -5
- package/dist/services/message-resolution.js +2 -3
- package/dist/services/messages-meaning.js +4 -5
- package/dist/services/messages-search.d.ts +5 -1
- package/dist/services/messages-search.js +1 -1
- package/dist/services/model-downloads.d.ts +1 -1
- package/dist/services/model-downloads.js +6 -4
- package/dist/services/money-context.d.ts +73 -0
- package/dist/services/money-context.js +77 -0
- package/dist/services/notes-search.d.ts +4 -1
- package/dist/services/notes-search.js +19 -7
- package/dist/services/organization-context.d.ts +80 -0
- package/dist/services/organization-context.js +154 -0
- package/dist/services/people.d.ts +22 -6
- package/dist/services/people.js +38 -8
- package/dist/services/person-business.d.ts +43 -0
- package/dist/services/person-business.js +67 -0
- package/dist/services/person-context.d.ts +9 -1
- package/dist/services/person-context.js +5 -3
- package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
- package/dist/services/proposals/kinds/identity-link.js +48 -0
- package/dist/services/proposals/kinds/orders.js +1 -1
- package/dist/services/proposals/registry.js +2 -0
- package/dist/services/search-kind.d.ts +12 -5
- package/dist/services/search-kind.js +49 -10
- package/dist/services/text-model-choice.js +1 -1
- package/dist/store/accounts.d.ts +18 -0
- package/dist/store/accounts.js +18 -3
- package/dist/store/damage.d.ts +43 -10
- package/dist/store/damage.js +119 -36
- package/dist/store/decisions.js +3 -1
- package/dist/store/evidence-findings.d.ts +14 -0
- package/dist/store/evidence-findings.js +2 -0
- package/dist/store/exports.d.ts +2 -1
- package/dist/store/identity-links.d.ts +92 -0
- package/dist/store/identity-links.js +6 -0
- package/dist/store/index.d.ts +11 -5
- package/dist/store/index.js +5 -2
- package/dist/store/journal.d.ts +10 -0
- package/dist/store/journal.js +33 -0
- package/dist/store/marks.d.ts +19 -1
- package/dist/store/marks.js +23 -1
- package/dist/store/people.d.ts +22 -0
- package/dist/store/people.js +15 -1
- package/dist/store/sqlite/accounts.js +2 -0
- package/dist/store/sqlite/base-stages.d.ts +122 -0
- package/dist/store/sqlite/base-stages.js +443 -0
- package/dist/store/sqlite/base-suggest.d.ts +13 -0
- package/dist/store/sqlite/base-suggest.js +62 -0
- package/dist/store/sqlite/business-contracts.js +10 -1
- package/dist/store/sqlite/crm-settings.d.ts +12 -2
- package/dist/store/sqlite/crm-settings.js +56 -13
- package/dist/store/sqlite/crm.d.ts +13 -1
- package/dist/store/sqlite/crm.js +20 -4
- package/dist/store/sqlite/deals.d.ts +33 -0
- package/dist/store/sqlite/deals.js +42 -4
- package/dist/store/sqlite/decision-requests.js +7 -3
- package/dist/store/sqlite/email-index.js +8 -4
- package/dist/store/sqlite/evidence-findings.js +29 -5
- package/dist/store/sqlite/findings-core.js +4 -2
- package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
- package/dist/store/sqlite/identity-link-rows.js +146 -0
- package/dist/store/sqlite/identity-proposals.d.ts +53 -0
- package/dist/store/sqlite/identity-proposals.js +234 -0
- package/dist/store/sqlite/knowledge.js +2 -2
- package/dist/store/sqlite/link-kinds.d.ts +1 -0
- package/dist/store/sqlite/link-kinds.js +1 -0
- package/dist/store/sqlite/link-row.d.ts +6 -0
- package/dist/store/sqlite/link-row.js +35 -0
- package/dist/store/sqlite/link-source.d.ts +10 -0
- package/dist/store/sqlite/link-source.js +16 -0
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/meeting-context-links.js +9 -6
- package/dist/store/sqlite/memories.js +9 -7
- package/dist/store/sqlite/mentions.d.ts +4 -1
- package/dist/store/sqlite/mentions.js +14 -9
- package/dist/store/sqlite/migrations.generated.js +8 -0
- package/dist/store/sqlite/notes.d.ts +1 -2
- package/dist/store/sqlite/notes.js +4 -29
- package/dist/store/sqlite/open-store.js +3 -0
- package/dist/store/sqlite/open.js +11 -2
- package/dist/store/sqlite/orders.d.ts +2 -0
- package/dist/store/sqlite/orders.js +9 -3
- package/dist/store/sqlite/organization-categories.d.ts +18 -0
- package/dist/store/sqlite/organization-categories.js +34 -0
- package/dist/store/sqlite/organizations.d.ts +5 -1
- package/dist/store/sqlite/organizations.js +14 -4
- package/dist/store/sqlite/person-links.d.ts +19 -4
- package/dist/store/sqlite/person-links.js +49 -11
- package/dist/store/sqlite/person-match-scan.d.ts +13 -0
- package/dist/store/sqlite/person-match-scan.js +251 -0
- package/dist/store/sqlite/person-matcher.d.ts +16 -0
- package/dist/store/sqlite/person-matcher.js +32 -0
- package/dist/store/sqlite/proposed-actions.js +6 -0
- package/dist/store/sqlite/record-matching.d.ts +2 -8
- package/dist/store/sqlite/record-matching.js +8 -40
- package/dist/store/sqlite/record-projectors-phone.js +2 -1
- package/dist/store/sqlite/record-relationships.d.ts +52 -0
- package/dist/store/sqlite/record-relationships.js +243 -0
- package/dist/store/sqlite/record-run.d.ts +5 -0
- package/dist/store/sqlite/record-run.js +62 -2
- package/dist/store/sqlite/record-writes.d.ts +1 -1
- package/dist/store/sqlite/record-writes.js +4 -2
- package/dist/store/sqlite/records.js +27 -2
- package/dist/store/sqlite/ref-accounts.d.ts +13 -0
- package/dist/store/sqlite/ref-accounts.js +117 -0
- package/dist/store/sqlite/ref-summaries.js +5 -1
- package/dist/store/sqlite/relation-list.d.ts +4 -1
- package/dist/store/sqlite/relation-list.js +18 -2
- package/dist/store/sqlite/relation-proposals.d.ts +6 -0
- package/dist/store/sqlite/relation-proposals.js +3 -0
- package/dist/store/sqlite/relation-roles.js +12 -6
- package/dist/store/sqlite/reported-relations.d.ts +11 -1
- package/dist/store/sqlite/reported-relations.js +59 -18
- package/dist/store/sqlite/schema.d.ts +32 -0
- package/dist/store/sqlite/schema.js +3 -0
- package/dist/store/sqlite/transaction.js +11 -1
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/dist/store/write-events.d.ts +18 -0
- package/dist/store/write-events.js +88 -0
- package/package.json +3 -3
- package/parity.json +11 -4
- package/schemas/records-envelope.v1.schema.json +3 -0
|
@@ -14,7 +14,7 @@ import { openStore } from "../store/store.js";
|
|
|
14
14
|
export const useTextModel = async (id, { env, command }) => {
|
|
15
15
|
const model = textModel(id, env);
|
|
16
16
|
if (!isTextModelInstalled(model, textModelsDirectory(env)))
|
|
17
|
-
throw new CliError("not_found", `${model.id} is not downloaded — \`${command} models download ${model.id}
|
|
17
|
+
throw new CliError("not_found", `${model.id} is not downloaded — \`${command} models download ${model.id}\` first`, { reason: "model.not-downloaded", model: model.id });
|
|
18
18
|
const previous = chosenTextModel(env).id;
|
|
19
19
|
const before = textModels(env).find((one) => one.id === previous);
|
|
20
20
|
const toEmbed = previous === model.id ? 0 : before ? await missingVectors(before, model, env) : null;
|
package/dist/store/accounts.d.ts
CHANGED
|
@@ -17,6 +17,17 @@ export interface AccountAccounts {
|
|
|
17
17
|
*/
|
|
18
18
|
purge(key: AccountKey): Promise<void>;
|
|
19
19
|
}
|
|
20
|
+
export interface AccountGroupChange {
|
|
21
|
+
/** Read against the group's entries inside the write, so a move sees what is saved at that moment. */
|
|
22
|
+
remove?: {
|
|
23
|
+
group: string;
|
|
24
|
+
drop: (entry: string) => boolean;
|
|
25
|
+
};
|
|
26
|
+
add?: {
|
|
27
|
+
group: string;
|
|
28
|
+
entry: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
export interface AccountsStore extends AccountAccounts {
|
|
21
32
|
/** Every account of every messenger the file holds, by messenger then id. */
|
|
22
33
|
accounts(): Promise<AccountKey[]>;
|
|
@@ -26,6 +37,13 @@ export interface AccountsStore extends AccountAccounts {
|
|
|
26
37
|
accountGroups(): Promise<AccountGroups>;
|
|
27
38
|
/** Saves one group's entries; `undefined` removes the group. */
|
|
28
39
|
saveAccountGroup(name: string, members: string[] | undefined): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Takes entries out of one group and puts an entry into another in one write, so a move is never half done. A
|
|
42
|
+
* group left empty stays, to be filled again; an entry already there is not added twice.
|
|
43
|
+
*/
|
|
44
|
+
changeAccountGroups(change: AccountGroupChange): Promise<{
|
|
45
|
+
removed: string[];
|
|
46
|
+
}>;
|
|
29
47
|
/** Per app command, each profile's account: how `--source max:default` finds a profile of another app. */
|
|
30
48
|
profiles(): Promise<Profiles>;
|
|
31
49
|
/** Records which account a profile of `app` is; a no-op when the store already says so. */
|
package/dist/store/accounts.js
CHANGED
|
@@ -31,6 +31,9 @@ export const accountAccountsOver = (context) => {
|
|
|
31
31
|
};
|
|
32
32
|
export const accountsStoreOver = (context, keyed) => {
|
|
33
33
|
const { database } = context;
|
|
34
|
+
const saveGroups = (groups) => database
|
|
35
|
+
.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)")
|
|
36
|
+
.run(ACCOUNT_GROUPS, JSON.stringify(groups), context.now());
|
|
34
37
|
return {
|
|
35
38
|
...keyed,
|
|
36
39
|
accounts: async () => accounts.heldAccounts(context),
|
|
@@ -46,9 +49,21 @@ export const accountsStoreOver = (context, keyed) => {
|
|
|
46
49
|
delete groups[name];
|
|
47
50
|
else
|
|
48
51
|
groups[name] = members;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
saveGroups(groups);
|
|
53
|
+
}),
|
|
54
|
+
changeAccountGroups: async ({ remove, add }) => write(database, () => {
|
|
55
|
+
const groups = accountGroupsOf(database);
|
|
56
|
+
const saved = remove && Object.hasOwn(groups, remove.group) ? (groups[remove.group] ?? []) : [];
|
|
57
|
+
const removed = remove ? saved.filter(remove.drop) : [];
|
|
58
|
+
if (remove && removed.length)
|
|
59
|
+
groups[remove.group] = saved.filter((entry) => !removed.includes(entry));
|
|
60
|
+
if (add) {
|
|
61
|
+
const entries = Object.hasOwn(groups, add.group) ? (groups[add.group] ?? []) : [];
|
|
62
|
+
groups[add.group] = entries.includes(add.entry) ? entries : [...entries, add.entry];
|
|
63
|
+
}
|
|
64
|
+
if (removed.length || add)
|
|
65
|
+
saveGroups(groups);
|
|
66
|
+
return { removed };
|
|
52
67
|
}),
|
|
53
68
|
};
|
|
54
69
|
};
|
package/dist/store/damage.d.ts
CHANGED
|
@@ -1,21 +1,54 @@
|
|
|
1
1
|
import type { StoreHealth } from "./health.js";
|
|
2
|
-
import type { DamageMark } from "./marks.js";
|
|
2
|
+
import type { DamageMark, JournalMark } from "./marks.js";
|
|
3
|
+
/** One cause the evidence allows, and the one command that tells more about it. */
|
|
4
|
+
export interface DamageCause {
|
|
5
|
+
cause: string;
|
|
6
|
+
check: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RecoveryStep {
|
|
9
|
+
command: string;
|
|
10
|
+
why: string;
|
|
11
|
+
/** Replaces the store or stops a process: an app copies it for the owner to run rather than running it. */
|
|
12
|
+
destructive: boolean;
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* What a damaged store means, in the owner's words: one structure the CLIs render and the desktop app can show as it
|
|
5
|
-
* is. Built from
|
|
16
|
+
* is. Built from what was already found, so it never reads the damaged file again.
|
|
6
17
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
investigate: string[];
|
|
18
|
+
export interface StoreDamageReport {
|
|
19
|
+
whatHappened: string;
|
|
20
|
+
likelyCauses: DamageCause[];
|
|
11
21
|
impact: string[];
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
externalDataSafe: string;
|
|
23
|
+
lastOkAt: string | null;
|
|
24
|
+
loss: string;
|
|
25
|
+
/** The first stops the writers, the last is the deep check. */
|
|
26
|
+
steps: RecoveryStep[];
|
|
27
|
+
}
|
|
28
|
+
export interface DamageFindings {
|
|
29
|
+
health: StoreHealth;
|
|
30
|
+
/** The CLI's command, which the steps name: `mail`. */
|
|
31
|
+
command: string;
|
|
32
|
+
mark?: DamageMark | null;
|
|
33
|
+
journal?: JournalMark | null;
|
|
34
|
+
lastOkAt?: string | null;
|
|
35
|
+
holders?: {
|
|
36
|
+
pid: number;
|
|
37
|
+
name: string;
|
|
38
|
+
}[] | null;
|
|
39
|
+
timers?: string[] | null;
|
|
40
|
+
sqlite3Usable?: boolean;
|
|
14
41
|
}
|
|
15
42
|
/**
|
|
16
43
|
* Tables a recovery rebuilds from the others: search indexes, the vector index, what the indexing finds, and the
|
|
17
44
|
* vectors, which a search by meaning computes again for any text that has none.
|
|
18
45
|
*/
|
|
19
46
|
export declare const isDerivedTable: (table: string, searchIndexes: readonly string[]) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
export declare const
|
|
47
|
+
/** How much may be gone and since when: nothing records a row that damage takes (BUG-627). */
|
|
48
|
+
export declare const lossUnknown: (lastOkAt: string | null | undefined, gone?: boolean) => string;
|
|
49
|
+
/**
|
|
50
|
+
* The report for whatever was found, or null when the store is healthy and nothing was seen. `mark`: a run saw the
|
|
51
|
+
* damage; the quick check reads too little to see it, so it alone can make a store damaged. `journal`: the store's
|
|
52
|
+
* journal file went away under a run, which can lose writes even when every page still reads.
|
|
53
|
+
*/
|
|
54
|
+
export declare const storeDamageReport: ({ health, command, mark, journal, lastOkAt, holders, timers, sqlite3Usable, }: DamageFindings) => StoreDamageReport | null;
|
package/dist/store/damage.js
CHANGED
|
@@ -9,9 +9,34 @@ export const isDerivedTable = (table, searchIndexes) => DERIVED.has(table) ||
|
|
|
9
9
|
searchIndexes.some((index) => table === index || table.startsWith(`${index}_`));
|
|
10
10
|
const WIRECAT_UNITS = ["memo-*", "mail-*", "tg-*", "max-*", "wirecat-*"];
|
|
11
11
|
const seen = (mark) => `\`${mark.command}\` found the store damaged at ${mark.at} (${mark.error})`;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const journalSeen = (store, { seen, command, at }) => {
|
|
13
|
+
const wal = `${store.replace(/^.*\//, "")}-wal`;
|
|
14
|
+
return seen === "shm-without-wal"
|
|
15
|
+
? `the store's journal file (${wal}) was missing when \`${command}\` opened the store at ${at}: another program deleted it, or a tool crashed while closing`
|
|
16
|
+
: `the store's journal file (${wal}) was deleted or replaced by another program while \`${command}\` had the store open (${at})`;
|
|
17
|
+
};
|
|
18
|
+
/** How much may be gone and since when: nothing records a row that damage takes (BUG-627). */
|
|
19
|
+
export const lossUnknown = (lastOkAt, gone = false) => {
|
|
20
|
+
const since = lastOkAt
|
|
21
|
+
? `since the last deep check that passed (${lastOkAt})`
|
|
22
|
+
: "since the store was made (no deep check that passed is on record)";
|
|
23
|
+
return (`${gone ? "more rows may be gone" : "how many rows were lost is unknown"}: ` +
|
|
24
|
+
`damage can take rows written ${since} without leaving a trace; a sync fetches again what the servers still hold`);
|
|
25
|
+
};
|
|
26
|
+
const stopWriters = (timers) => ({
|
|
27
|
+
command: timers?.length
|
|
28
|
+
? `systemctl --user stop ${timers.join(" ")}`
|
|
29
|
+
: `systemctl --user stop ${WIRECAT_UNITS.map((unit) => `'${unit}'`).join(" ")}`,
|
|
30
|
+
why: "a tool that writes while the store is recovered damages the new file too",
|
|
31
|
+
destructive: false,
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* The report for whatever was found, or null when the store is healthy and nothing was seen. `mark`: a run saw the
|
|
35
|
+
* damage; the quick check reads too little to see it, so it alone can make a store damaged. `journal`: the store's
|
|
36
|
+
* journal file went away under a run, which can lose writes even when every page still reads.
|
|
37
|
+
*/
|
|
38
|
+
export const storeDamageReport = ({ health, command, mark = null, journal = null, lastOkAt = null, holders = null, timers = null, sqlite3Usable = true, }) => {
|
|
39
|
+
if (health.ok && !mark && !journal)
|
|
15
40
|
return null;
|
|
16
41
|
const indexNames = (health.searchIndexes ?? []).map((index) => index.name);
|
|
17
42
|
const badIndexes = (health.searchIndexes ?? []).filter((index) => !index.ok).map((index) => index.name);
|
|
@@ -20,17 +45,21 @@ export const explainDamage = (health, command, mark = null) => {
|
|
|
20
45
|
const derived = [...new Set([...tables.filter((table) => isDerivedTable(table, indexNames)), ...badIndexes])];
|
|
21
46
|
const unopened = health.error !== undefined;
|
|
22
47
|
const json = (health.invalidJson ?? []).map(({ table, column }) => `${table}.${column}`);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
const damaged = !health.ok || mark !== null;
|
|
49
|
+
const folder = health.path.replace(/\/[^/]*$/, "");
|
|
50
|
+
const checked = !damaged
|
|
51
|
+
? `every page of the store reads, but ${journalSeen(health.path, journal)}; what was written into it may be lost`
|
|
52
|
+
: health.ok
|
|
53
|
+
? `${seen(mark)}; the quick check reads too little to see it, and a deep check that passes clears it`
|
|
54
|
+
: unopened
|
|
55
|
+
? `the store file cannot be opened: ${health.error}`
|
|
56
|
+
: health.checked === "quick"
|
|
57
|
+
? "the store file's header or schema is damaged"
|
|
58
|
+
: `the store file is damaged: ${health.problems ?? 0} problems` +
|
|
59
|
+
(sources.length ? ` in the data of ${named(sources)}` : "") +
|
|
60
|
+
(derived.length ? `${sources.length ? ", and" : " in"} the search data of ${named(derived)}` : "") +
|
|
61
|
+
(json.length ? `; values that are not valid JSON in ${named(json)}` : "");
|
|
62
|
+
const whatHappened = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
|
|
34
63
|
const impact = [
|
|
35
64
|
...(sources.length
|
|
36
65
|
? [`some rows of ${named(sources)} cannot be read; a recovery keeps every row it can read and names the rest`]
|
|
@@ -41,30 +70,84 @@ export const explainDamage = (health, command, mark = null) => {
|
|
|
41
70
|
...(json.length
|
|
42
71
|
? [`a read of a row with a broken JSON value fails ("malformed JSON"); a recovery clears those values`]
|
|
43
72
|
: []),
|
|
44
|
-
|
|
45
|
-
? "
|
|
46
|
-
:
|
|
73
|
+
...(!damaged
|
|
74
|
+
? ["everything works; rows written while the journal was gone may be missing, and a sync fetches them again"]
|
|
75
|
+
: mark
|
|
76
|
+
? [
|
|
77
|
+
"reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered",
|
|
78
|
+
]
|
|
79
|
+
: ["reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"]),
|
|
80
|
+
];
|
|
81
|
+
const likelyCauses = [
|
|
82
|
+
...(journal
|
|
83
|
+
? [{ cause: journalSeen(health.path, journal), check: `ls -li --time-style=full-iso ${folder}/` }]
|
|
84
|
+
: []),
|
|
85
|
+
...(holders?.length
|
|
86
|
+
? [
|
|
87
|
+
{
|
|
88
|
+
cause: `two programs wrote the file without seeing each other: ${holders.map(({ name, pid }) => `${name} (process ${pid})`).join(", ")} still ${holders.length === 1 ? "has" : "have"} it open`,
|
|
89
|
+
check: `fuser -v ${health.path}`,
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
: []),
|
|
93
|
+
...(damaged
|
|
94
|
+
? [
|
|
95
|
+
{
|
|
96
|
+
cause: "the computer lost power or crashed while a tool was writing",
|
|
97
|
+
check: `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`,
|
|
98
|
+
},
|
|
99
|
+
{ cause: "the disk filled up while a tool was writing", check: `df -h ${folder}` },
|
|
100
|
+
{
|
|
101
|
+
cause: "the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
|
|
102
|
+
check: `findmnt -T ${folder}`,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
cause: "a fault of the disk itself",
|
|
106
|
+
check: "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata",
|
|
107
|
+
},
|
|
108
|
+
]
|
|
109
|
+
: []),
|
|
110
|
+
];
|
|
111
|
+
const steps = [
|
|
112
|
+
stopWriters(timers),
|
|
113
|
+
...(holders ?? []).map(({ pid, name }) => ({
|
|
114
|
+
command: `kill ${pid}`,
|
|
115
|
+
why: `${name} (process ${pid}) has the store open`,
|
|
116
|
+
destructive: true,
|
|
117
|
+
})),
|
|
118
|
+
...(damaged && !sqlite3Usable
|
|
119
|
+
? [
|
|
120
|
+
{
|
|
121
|
+
command: "sudo apt install sqlite3",
|
|
122
|
+
why: "the recovery copies rows with the sqlite3 program, 3.43 or newer (on macOS: brew install sqlite)",
|
|
123
|
+
destructive: false,
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
: []),
|
|
127
|
+
...(damaged
|
|
128
|
+
? [
|
|
129
|
+
{
|
|
130
|
+
command: `${command} store recover run`,
|
|
131
|
+
why: "copies every readable row into a new file and puts it in place of the store; the damaged file is " +
|
|
132
|
+
"kept beside it, and it prints the syncs that fetch again what was lost",
|
|
133
|
+
destructive: true,
|
|
134
|
+
},
|
|
135
|
+
]
|
|
136
|
+
: []),
|
|
137
|
+
{
|
|
138
|
+
command: `${command} store recover`,
|
|
139
|
+
why: "checks every page again; a check that passes lifts the damage mark",
|
|
140
|
+
destructive: false,
|
|
141
|
+
},
|
|
47
142
|
];
|
|
48
143
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"the computer lost power or crashed, or the disk filled up, while a tool was writing",
|
|
52
|
-
"the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
|
|
53
|
-
"a fault of the disk itself",
|
|
54
|
-
],
|
|
55
|
-
investigate: [
|
|
56
|
-
`journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`,
|
|
57
|
-
"journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata",
|
|
58
|
-
`df -h ${health.path.replace(/\/[^/]*$/, "")}`,
|
|
59
|
-
...(health.checked === "quick" || health.ok ? [`${command} store recover`] : []),
|
|
60
|
-
],
|
|
144
|
+
whatHappened,
|
|
145
|
+
likelyCauses,
|
|
61
146
|
impact,
|
|
62
|
-
|
|
63
|
-
"so whatever is lost here can be fetched again by a sync",
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"run the fetch commands it prints, then start the timers again",
|
|
68
|
-
],
|
|
147
|
+
externalDataSafe: "only this computer's copy is damaged: Telegram, MAX, WhatsApp, the mail servers and Google Drive keep their " +
|
|
148
|
+
"own data, so whatever is lost here can be fetched again by a sync",
|
|
149
|
+
lastOkAt,
|
|
150
|
+
loss: lossUnknown(lastOkAt),
|
|
151
|
+
steps,
|
|
69
152
|
};
|
|
70
153
|
};
|
package/dist/store/decisions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { MEETING_FINDINGS_KIND } from "../meetings/index.js";
|
|
3
|
+
import { IDENTITY_LINK_KIND } from "./identity-links.js";
|
|
3
4
|
import { MAIL_FINDINGS_KIND } from "./mail-findings.js";
|
|
4
5
|
import { SOURCE_REVIEW_KIND } from "./source-review.js";
|
|
5
6
|
/** An agent's suggested close of a task: kept on the task, not in `proposed_actions`. */
|
|
@@ -12,7 +13,8 @@ export const DEFAULT_DECISION_POLICY = { agentDecisions: false, ruleProposalsOwn
|
|
|
12
13
|
export const isOwnerOnlyKind = (kind) => kind === MAIL_FINDINGS_KIND ||
|
|
13
14
|
kind === MEETING_FINDINGS_KIND ||
|
|
14
15
|
kind === TASK_CLOSE_KIND ||
|
|
15
|
-
kind === SOURCE_REVIEW_KIND
|
|
16
|
+
kind === SOURCE_REVIEW_KIND ||
|
|
17
|
+
kind === IDENTITY_LINK_KIND;
|
|
16
18
|
/**
|
|
17
19
|
* The one check every decide path runs before it confirms or rejects a proposal. `null` means allowed. Every Claude
|
|
18
20
|
* Code session is the bot `claude-code`, so comparing bot names keeps one session from deciding another's proposal.
|
|
@@ -25,6 +25,8 @@ export interface EvidenceFindingsBatch {
|
|
|
25
25
|
input: FindingsInput;
|
|
26
26
|
fingerprint: string;
|
|
27
27
|
status: "proposed" | "reviewed";
|
|
28
|
+
/** Only the owner decides it, whatever `agent_decisions` says: it was staged so, or it records a payment. */
|
|
29
|
+
ownerOnly: boolean;
|
|
28
30
|
author: {
|
|
29
31
|
type: "person" | "bot";
|
|
30
32
|
id: string;
|
|
@@ -43,11 +45,23 @@ export interface EvidenceFindingsBatch {
|
|
|
43
45
|
* Cited facts and follow-ups about one project from stored messages, mail and documents, staged by an agent for
|
|
44
46
|
* review. A sibling of meeting findings: the same rules, evidence checked against the current stored text.
|
|
45
47
|
*/
|
|
48
|
+
/** A stored record as a findings batch cites it: the text a quote must be in, and the fingerprint staging checks. */
|
|
49
|
+
export interface CitableRecord {
|
|
50
|
+
reference: string;
|
|
51
|
+
fingerprint: string;
|
|
52
|
+
title: string | null;
|
|
53
|
+
text: string;
|
|
54
|
+
}
|
|
46
55
|
export interface EvidenceFindingsStore {
|
|
56
|
+
/** `ownerOnly` keeps every agent from deciding the batch, whatever `agent_decisions` says. */
|
|
47
57
|
stage(input: FindingsInput, agent: {
|
|
48
58
|
bot: string;
|
|
49
59
|
model?: string;
|
|
60
|
+
}, options?: {
|
|
61
|
+
ownerOnly?: boolean;
|
|
50
62
|
}): Promise<EvidenceFindingsBatch>;
|
|
63
|
+
/** A `msg:`, `document:` or `note:` record as staging reads it; `null` when it is not stored. */
|
|
64
|
+
citable(reference: string): Promise<CitableRecord | null>;
|
|
51
65
|
get(id: string): Promise<EvidenceFindingsBatch>;
|
|
52
66
|
list(options?: {
|
|
53
67
|
project?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { formatLocator, parseLocator } from "../domain/locator.js";
|
|
3
3
|
import { validateFindings } from "../meetings/index.js";
|
|
4
|
+
import { QUOTE_LIMIT } from "./sqlite/evidence-signature.js";
|
|
4
5
|
import { entryAmount } from "./sqlite/payment-entries.js";
|
|
5
6
|
export const EVIDENCE_FINDINGS_KIND = "evidence_findings";
|
|
6
7
|
const reference = (raw) => {
|
|
@@ -21,6 +22,7 @@ export const validateEvidenceFindings = (input) => {
|
|
|
21
22
|
reference,
|
|
22
23
|
anySubject: true,
|
|
23
24
|
payments: true,
|
|
25
|
+
quotes: QUOTE_LIMIT,
|
|
24
26
|
});
|
|
25
27
|
// Refused at staging rather than when the owner accepts, which would fail the whole batch.
|
|
26
28
|
for (const finding of valid.findings)
|
package/dist/store/exports.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BUSINESS_KINDS, type BusinessKind } from "../domain/business.js";
|
|
2
2
|
export type { CounterField, CounterObservations, CounterState } from "../domain/counters.js";
|
|
3
3
|
export type { RetentionOptions } from "../domain/retention.js";
|
|
4
|
-
export type { AccountAccounts, AccountsStore } from "./accounts.js";
|
|
4
|
+
export type { AccountAccounts, AccountGroupChange, AccountsStore } from "./accounts.js";
|
|
5
5
|
export type { AccountAttachments, AttachmentsStore } from "./attachments.js";
|
|
6
6
|
export type { ChatsStore, LeftChat, LeftChats } from "./chats.js";
|
|
7
7
|
export type { ConversationsStore } from "./conversations.js";
|
|
@@ -18,6 +18,7 @@ export { accountGroupsOf } from "./sqlite/account-groups.js";
|
|
|
18
18
|
export type { AdminStoreRequest, AdminStoreResult } from "./sqlite/admin-statistics.js";
|
|
19
19
|
export { type AttachmentTextEntry, type AttachmentView, attachmentColumns, type FileAttachment, resetAttachmentWords, type TextOrigin, } from "./sqlite/attachment-texts.js";
|
|
20
20
|
export { pendingNormalization } from "./sqlite/backfill.js";
|
|
21
|
+
export type { BaseScope, BaseSet, BaseStagesStore, StageMapping } from "./sqlite/base-stages.js";
|
|
21
22
|
export { BUSINESS_FIND_MAX, type BusinessHit, type BusinessSearch, type BusinessSearchStore, type BusinessSource, } from "./sqlite/business-search.js";
|
|
22
23
|
export type { ChatRekey, ChatRekeys } from "./sqlite/chat-rekey.js";
|
|
23
24
|
export { CHAT_COLUMNS, TRACKED_CHAT_COLUMNS, titlePart } from "./sqlite/chats.js";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Decider, Proposer } from "./decisions.js";
|
|
2
|
+
import type { Author } from "./sqlite/memories.js";
|
|
3
|
+
import type { IdentityRef } from "./types.js";
|
|
4
|
+
export declare const IDENTITY_LINK_KIND = "identity_link";
|
|
5
|
+
/**
|
|
6
|
+
* Why two people may be one: an agent said so, they share a phone or an address with others, or a meeting guest typed
|
|
7
|
+
* an address another person has.
|
|
8
|
+
*/
|
|
9
|
+
export declare const IDENTITY_LINK_SIGNALS: readonly ["agent", "phone", "email", "guest-email"];
|
|
10
|
+
export type IdentityLinkSignal = (typeof IDENTITY_LINK_SIGNALS)[number];
|
|
11
|
+
/** An `identity_link` proposal's payload. */
|
|
12
|
+
export interface IdentityLinkPayload {
|
|
13
|
+
/** `provider:id` of the identity that would move. */
|
|
14
|
+
identity: string;
|
|
15
|
+
/** `provider:id` of an identity of the person it would join; `null` for a person known by name only. */
|
|
16
|
+
with: string | null;
|
|
17
|
+
/** The person `identity` is on and the one it would join, as uids when it was proposed. */
|
|
18
|
+
persons: [string, string];
|
|
19
|
+
/** Each person's identities when it was proposed, so a confirm after either changed is refused. */
|
|
20
|
+
sides: [string, string];
|
|
21
|
+
/** `person` joins the two people; `identity` moves only `identity`, leaving the rest of its person. */
|
|
22
|
+
joins: "person" | "identity";
|
|
23
|
+
signal: IdentityLinkSignal;
|
|
24
|
+
score: number | null;
|
|
25
|
+
/** Every person the signal points at, the two included, when it points at more than two. */
|
|
26
|
+
candidates?: string[];
|
|
27
|
+
evidence: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface IdentityLinkInput {
|
|
30
|
+
identity: IdentityRef;
|
|
31
|
+
with: IdentityRef;
|
|
32
|
+
signal: IdentityLinkSignal;
|
|
33
|
+
by: Author;
|
|
34
|
+
reason?: string;
|
|
35
|
+
score?: number;
|
|
36
|
+
evidence?: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface IdentityLinkDecision {
|
|
39
|
+
confirm: boolean;
|
|
40
|
+
/** `"owner"` only on a path that established the owner decides; an agent is refused whatever the policy says. */
|
|
41
|
+
by: Decider;
|
|
42
|
+
reason?: string;
|
|
43
|
+
}
|
|
44
|
+
/** One `identity_link`, naming the people as they are now, not as they were when it was proposed. */
|
|
45
|
+
export interface IdentityLinkRow {
|
|
46
|
+
id: string;
|
|
47
|
+
status: "proposed" | "confirmed" | "rejected";
|
|
48
|
+
/** `person:<uid>` of the person `identity` is on, then of the one it would join. */
|
|
49
|
+
persons: [string, string];
|
|
50
|
+
identity: string;
|
|
51
|
+
with: string | null;
|
|
52
|
+
joins: IdentityLinkPayload["joins"];
|
|
53
|
+
signal: IdentityLinkSignal;
|
|
54
|
+
score: number | null;
|
|
55
|
+
candidates: string[];
|
|
56
|
+
reason: string | null;
|
|
57
|
+
evidence: string[];
|
|
58
|
+
proposedBy: Proposer;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
}
|
|
61
|
+
export interface IdentityLinkFilter {
|
|
62
|
+
/** Only the proposals naming this person, or anyone merged into them, as they are now. */
|
|
63
|
+
person?: string;
|
|
64
|
+
/** `proposed` unless named. */
|
|
65
|
+
status?: IdentityLinkRow["status"] | "all";
|
|
66
|
+
limit: number;
|
|
67
|
+
offset: number;
|
|
68
|
+
}
|
|
69
|
+
/** What one pass of the people matcher did. */
|
|
70
|
+
export interface MatchScan {
|
|
71
|
+
/** Every identity was read, not only those changed since the last pass. */
|
|
72
|
+
full: boolean;
|
|
73
|
+
/** People joined without asking: the same personal address, or a phone exactly two people have. */
|
|
74
|
+
merged: {
|
|
75
|
+
into: string;
|
|
76
|
+
from: string;
|
|
77
|
+
signal: "same-email" | "same-phone";
|
|
78
|
+
}[];
|
|
79
|
+
/** Proposals opened, or open ones met again. */
|
|
80
|
+
proposed: {
|
|
81
|
+
id: string;
|
|
82
|
+
persons: [string, string];
|
|
83
|
+
signal: IdentityLinkSignal;
|
|
84
|
+
opened: boolean;
|
|
85
|
+
}[];
|
|
86
|
+
/** Pairs left apart, with why: the owner separated or rejected them, or too many people share the value. */
|
|
87
|
+
skipped: {
|
|
88
|
+
persons: string[];
|
|
89
|
+
signal: string;
|
|
90
|
+
reason: string;
|
|
91
|
+
}[];
|
|
92
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const IDENTITY_LINK_KIND = "identity_link";
|
|
2
|
+
/**
|
|
3
|
+
* Why two people may be one: an agent said so, they share a phone or an address with others, or a meeting guest typed
|
|
4
|
+
* an address another person has.
|
|
5
|
+
*/
|
|
6
|
+
export const IDENTITY_LINK_SIGNALS = ["agent", "phone", "email", "guest-email"];
|
package/dist/store/index.d.ts
CHANGED
|
@@ -10,18 +10,19 @@ export type { FindingEvidence, FindingOutcome, MeetingFactFinding, MeetingFindin
|
|
|
10
10
|
export { PAYMENT_DIRECTIONS, PAYMENT_STATES, type Payment, paymentTitle, validatePayment } from "../meetings/index.js";
|
|
11
11
|
export { CLOSED_STATES, isClosedState, PRIORITY_LABELS, type PriorityLabel, priorityLabel, priorityOf, priorityOption, TASK_STATES, type TaskState, } from "../tasks/index.js";
|
|
12
12
|
export type { AccountMail, AccountMeetings, AccountStore } from "./account-store.js";
|
|
13
|
-
export { type
|
|
13
|
+
export { type DamageCause, type DamageFindings, type RecoveryStep, type StoreDamageReport, storeDamageReport, } from "./damage.js";
|
|
14
14
|
export { CALLBACK_PREFIX, callbackDataOf, DECISION_ACTIONS, DECISION_TTL_MS, type DecisionAction, isDecisionToken, parseCallbackData, } from "./decision-requests.js";
|
|
15
15
|
export { assertMayDecide, DEFAULT_DECISION_POLICY, type Decider, type DecisionPolicy, isOwnerOnlyKind, mayDecide, type Proposer, type Refusal, } from "./decisions.js";
|
|
16
16
|
export type { DocumentTransferOptions, DocumentTransferPreview, DocumentTransferReceipt, } from "./document-transfer/index.js";
|
|
17
17
|
export { applyDocumentTransfer, previewDocumentTransfer } from "./document-transfer/index.js";
|
|
18
18
|
export type { CacheDatabase, CacheStatement, OpenDatabase, SqlValue } from "./driver.js";
|
|
19
19
|
export { PRAGMAS } from "./driver.js";
|
|
20
|
-
export { EVIDENCE_FINDINGS_KIND, type EvidenceFindingsBatch, type EvidenceFindingsDecider, type EvidenceFindingsReceipt, type EvidenceFindingsStore, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
20
|
+
export { type CitableRecord, EVIDENCE_FINDINGS_KIND, type EvidenceFindingsBatch, type EvidenceFindingsDecider, type EvidenceFindingsReceipt, type EvidenceFindingsStore, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
21
21
|
export { type DamagedTable, type InvalidJson, QUICK_HEALTH_CHECKS, type SearchIndexHealth, type StoreHealth, storeHealth, } from "./health.js";
|
|
22
|
+
export { IDENTITY_LINK_KIND, IDENTITY_LINK_SIGNALS, type IdentityLinkDecision, type IdentityLinkFilter, type IdentityLinkInput, type IdentityLinkPayload, type IdentityLinkRow, type IdentityLinkSignal, type MatchScan, } from "./identity-links.js";
|
|
22
23
|
export { ORGANIZATIONS_QUERY, organization, PROJECTS_QUERY, project, REMINDERS_QUERY, reminder, } from "./knowledge-query.js";
|
|
23
24
|
export { MAIL_FINDINGS_KIND, type MailFindingsBatch, type MailFindingsCheck, type MailFindingsStore, } from "./mail-findings.js";
|
|
24
|
-
export { clearDamageMark, type DamageMark, damageMarkPath, type HealthMark, healthMarkPath, markStoreDamaged, readDamageMark, readHealthMark, recordDeepCheck, } from "./marks.js";
|
|
25
|
+
export { clearDamageMark, type DamageMark, damageMarkPath, type HealthMark, healthMarkPath, type JournalMark, journalMarkPath, markStoreDamaged, readDamageMark, readHealthMark, readJournalMark, recordDeepCheck, } from "./marks.js";
|
|
25
26
|
export type { MeetingFindingsBatch, MeetingFindingsStore } from "./meeting-findings.js";
|
|
26
27
|
export { MIGRATIONS, type Migration, migrate } from "./migrations.js";
|
|
27
28
|
export { openCache } from "./open.js";
|
|
@@ -37,6 +38,8 @@ export { ADDED_KINDS, type AddedSource, type AddedSourceContent, type AddedSourc
|
|
|
37
38
|
export type { AgentAction, AgentActionInput, AgentActionsStore } from "./sqlite/agent-actions.js";
|
|
38
39
|
export { resetAttachmentWords } from "./sqlite/attachment-texts.js";
|
|
39
40
|
export { backfillNormalized, pendingNormalization } from "./sqlite/backfill.js";
|
|
41
|
+
export type { BaseColumn, BaseScope, BaseSet, BaseStagesStore, MappingFilter, StageMapping, StageName, } from "./sqlite/base-stages.js";
|
|
42
|
+
export { baseSettingKey } from "./sqlite/base-suggest.js";
|
|
40
43
|
export type { BotUpdate, BotUpdateStore } from "./sqlite/bot-updates.js";
|
|
41
44
|
export type { Contract, ContractFields, ContractFilter, ContractInput, ContractsStore, ContractUpdate, } from "./sqlite/business-contracts.js";
|
|
42
45
|
export type { BusinessHit, BusinessSearch, BusinessSearchStore, BusinessSource } from "./sqlite/business-search.js";
|
|
@@ -46,11 +49,12 @@ export { CATALOG_QUERY } from "./sqlite/catalog.js";
|
|
|
46
49
|
export type { ChatMetadata } from "./sqlite/chats.js";
|
|
47
50
|
export { type CrmCopies, type CrmRelationIssue, type CrmSaved, type CrmSkipped, crmIdentityId } from "./sqlite/crm.js";
|
|
48
51
|
export { COMPANY_TYPE_MEANINGS, type CompanyTypeMeaning, CRM_LINK_MODES, type CrmLinkMode, crmSettingKey, } from "./sqlite/crm-settings.js";
|
|
49
|
-
export type { Deal, DealFilter, DealInput, DealPerson, DealScope, DealsStore, FunnelStage, Pipeline, PipelineInput, PipelineReport, PipelineStage, } from "./sqlite/deals.js";
|
|
52
|
+
export type { Deal, DealFilter, DealInput, DealPerson, DealScope, DealsStore, FunnelStage, Pipeline, PipelineInput, PipelineReport, PipelineStage, StageChange, } from "./sqlite/deals.js";
|
|
50
53
|
export type { DecisionMessage, DecisionPress, DecisionRefusal, DecisionRequest, DecisionRequestInput, DecisionRequestStore, TakeResult, } from "./sqlite/decision-requests.js";
|
|
51
54
|
export type { Email, EmailAddress, EmailAttachment, EmailFacts, EmailFilter, EmailInput, EmailInThread, EmailLocationInput, EmailRecipient, EmailRef, EmailThread, EmailVectorHit, FolderEmail, Mailbox, MailboxInput, MailFilter, MailStore, PartialEmail, SenderScore, ThreadDetails, ThreadSave, } from "./sqlite/emails.js";
|
|
52
55
|
export { EVENT_FIELDS, type EventChunkToEmbed, type EventHit, type EventQuery, type EventSearch, type NearestEvent, } from "./sqlite/event-search.js";
|
|
53
56
|
export type { EvidenceInput, EvidenceMetadata } from "./sqlite/evidence-signature.js";
|
|
57
|
+
export { QUOTE_LIMIT, quoteKept } from "./sqlite/evidence-signature.js";
|
|
54
58
|
export type { EvidenceSource } from "./sqlite/evidence-sources.js";
|
|
55
59
|
export type { Fact, FactInput, FactsStore } from "./sqlite/facts.js";
|
|
56
60
|
export type { FileListQuery, FilesStore, StoredFile } from "./sqlite/files.js";
|
|
@@ -71,11 +75,13 @@ export type { NoteIndexState } from "./sqlite/note-index.js";
|
|
|
71
75
|
export { type NearestNote, NOTE_FIELDS, type NoteChunkToEmbed, type NoteHit, type NoteQuery, type NoteSearch, } from "./sqlite/note-search.js";
|
|
72
76
|
export type { FileNoteInput, Link, LinkInput, LinkListFilter, Note, NoteFolder, NotesStore, NoteTag, } from "./sqlite/notes.js";
|
|
73
77
|
export type { Order, OrderDetail, OrderFilter, OrderInput, OrdersStore } from "./sqlite/orders.js";
|
|
78
|
+
export type { OrganizationFilter } from "./sqlite/organization-categories.js";
|
|
74
79
|
export { DEFAULT_OWNER_LANGUAGES, ownerLanguages } from "./sqlite/owner-languages.js";
|
|
75
80
|
export { mergeId, type PersonMerge, parseMergeId } from "./sqlite/person-merges.js";
|
|
76
81
|
export type { PrivateContact, PrivateContactNote } from "./sqlite/private-people.js";
|
|
77
82
|
export type { Product, ProductFilter, ProductInput, ProductsStore, ProductUpdate } from "./sqlite/products.js";
|
|
78
83
|
export { assertGenericAction, PROPOSAL_STATUSES, type ProposalInput, type ProposedAction, type ProposedActionsStore, proposerOfAction, } from "./sqlite/proposed-actions.js";
|
|
84
|
+
export type { RelationshipCounts } from "./sqlite/record-relationships.js";
|
|
79
85
|
export { type FlaggedRecord, type IncomingRelation, type MappedRecord, type MatchRun, type RecordKey, type RecordStore, type RecordsRun, type RunItem, type RunOptions, type SourceRecord, type SourceRecordRelation, type Unmatched, waitingPointer, } from "./sqlite/records.js";
|
|
80
86
|
export type { RelationFilter, RelationList, RelationListItem } from "./sqlite/relation-list.js";
|
|
81
87
|
export type { LinkDecision, RelationUpdate } from "./sqlite/relation-proposals.js";
|
|
@@ -105,4 +111,4 @@ export type { TagPreflight, VocabularyAlias, VocabularyAliasReceipt, VocabularyA
|
|
|
105
111
|
export type { Wallet, WalletFilter, WalletInput, WalletsStore, WalletUpdate } from "./sqlite/wallets.js";
|
|
106
112
|
export type { BoardCounts, BoardOptions, EditedTask, MovedSubtask, NewWorkTask, RevisionCheck, TaskAssignment, TaskDetails, TaskEvent, TaskFields, TaskMove, TaskMoved, TaskRole, TaskType, WorkTaskType, } from "./sqlite/work-tasks.js";
|
|
107
113
|
export { TASK_EVENT_KINDS, TASK_ROLES } from "./sqlite/work-tasks.js";
|
|
108
|
-
export { type AccountAccounts, type AccountAttachments, type AccountCounters, type AccountKey, type AccountMentions, type AccountMessageFilter, type AccountMessages, type AccountPeople, type AccountsStore, type AccountVectors, type AttachmentsStore, type AttachmentTextEntry, type AttachmentView, type ChatStats, type ChatsStore, type ConversationsStore, type CountersStore, type DeletionScope, type Delta, type FileAttachment, type IdentityRef, type IngestedVia, type LinkedIdentity, type LinkOptions, MENTION_QUERY, MENTION_STATUSES, type MentionsStore, type MessageFilter, type MessageStore, type MessagesStore, OTHER_SOURCES, openStore, type PeopleStore, type PersonFacts, type PersonRecord, type QueriesStore, type Range, type RankedEvidence, type RankedStoreFound, type RankedStoreRow, type RankingEvidenceItem, type RankingEvidenceRequest, type RankingRequest, type RosterStore, type SearchCommand, type SearchesStore, type SearchIndexStore, type SearchRecord, type StoredAccount, type StoredChatFilter, type StoredHit, type StoredSearch, type StoredTag, type StoreOptions, type SyncStore, type TagFilter, type TagsStore, type TagTarget, type TaskAnalysisMark, type TaskAnalysisMarkWrite, type TaskTagTarget, type TextOrigin, type VectorsStore, } from "./store.js";
|
|
114
|
+
export { type AccountAccounts, type AccountAttachments, type AccountCounters, type AccountGroupChange, type AccountKey, type AccountMentions, type AccountMessageFilter, type AccountMessages, type AccountPeople, type AccountsStore, type AccountVectors, type AttachmentsStore, type AttachmentTextEntry, type AttachmentView, type ChatStats, type ChatsStore, type ConversationsStore, type CountersStore, type DeletionScope, type Delta, type FileAttachment, type IdentityRef, type IngestedVia, type LinkedIdentity, type LinkOptions, MENTION_QUERY, MENTION_STATUSES, type MentionsStore, type MessageFilter, type MessageStore, type MessagesStore, OTHER_SOURCES, openStore, type PeopleStore, type PersonFacts, type PersonRecord, type QueriesStore, type Range, type RankedEvidence, type RankedStoreFound, type RankedStoreRow, type RankingEvidenceItem, type RankingEvidenceRequest, type RankingRequest, type RosterStore, type SearchCommand, type SearchesStore, type SearchIndexStore, type SearchRecord, type StoredAccount, type StoredChatFilter, type StoredHit, type StoredSearch, type StoredTag, type StoreOptions, type SyncStore, type TagFilter, type TagsStore, type TagTarget, type TaskAnalysisMark, type TaskAnalysisMarkWrite, type TaskTagTarget, type TextOrigin, type VectorsStore, } from "./store.js";
|
package/dist/store/index.js
CHANGED
|
@@ -4,16 +4,17 @@ export { createTagRedirectIndex } from "../domain/tag-redirects.js";
|
|
|
4
4
|
export { note } from "../entities/note.js";
|
|
5
5
|
export { PAYMENT_DIRECTIONS, PAYMENT_STATES, paymentTitle, validatePayment } from "../meetings/index.js";
|
|
6
6
|
export { CLOSED_STATES, isClosedState, PRIORITY_LABELS, priorityLabel, priorityOf, priorityOption, TASK_STATES, } from "../tasks/index.js";
|
|
7
|
-
export {
|
|
7
|
+
export { storeDamageReport, } from "./damage.js";
|
|
8
8
|
export { CALLBACK_PREFIX, callbackDataOf, DECISION_ACTIONS, DECISION_TTL_MS, isDecisionToken, parseCallbackData, } from "./decision-requests.js";
|
|
9
9
|
export { assertMayDecide, DEFAULT_DECISION_POLICY, isOwnerOnlyKind, mayDecide, } from "./decisions.js";
|
|
10
10
|
export { applyDocumentTransfer, previewDocumentTransfer } from "./document-transfer/index.js";
|
|
11
11
|
export { PRAGMAS } from "./driver.js";
|
|
12
12
|
export { EVIDENCE_FINDINGS_KIND, validateEvidenceFindings, } from "./evidence-findings.js";
|
|
13
13
|
export { QUICK_HEALTH_CHECKS, storeHealth, } from "./health.js";
|
|
14
|
+
export { IDENTITY_LINK_KIND, IDENTITY_LINK_SIGNALS, } from "./identity-links.js";
|
|
14
15
|
export { ORGANIZATIONS_QUERY, organization, PROJECTS_QUERY, project, REMINDERS_QUERY, reminder, } from "./knowledge-query.js";
|
|
15
16
|
export { MAIL_FINDINGS_KIND, } from "./mail-findings.js";
|
|
16
|
-
export { clearDamageMark, damageMarkPath, healthMarkPath, markStoreDamaged, readDamageMark, readHealthMark, recordDeepCheck, } from "./marks.js";
|
|
17
|
+
export { clearDamageMark, damageMarkPath, healthMarkPath, journalMarkPath, markStoreDamaged, readDamageMark, readHealthMark, readJournalMark, recordDeepCheck, } from "./marks.js";
|
|
17
18
|
export { MIGRATIONS, migrate } from "./migrations.js";
|
|
18
19
|
export { openCache } from "./open.js";
|
|
19
20
|
export { storePath } from "./path.js";
|
|
@@ -26,11 +27,13 @@ export { SOURCE_REVIEW_CAUSES, SOURCE_REVIEW_KIND, } from "./source-review.js";
|
|
|
26
27
|
export { ADDED_KINDS, addedSourceKeyOf, } from "./sqlite/added-sources.js";
|
|
27
28
|
export { resetAttachmentWords } from "./sqlite/attachment-texts.js";
|
|
28
29
|
export { backfillNormalized, pendingNormalization } from "./sqlite/backfill.js";
|
|
30
|
+
export { baseSettingKey } from "./sqlite/base-suggest.js";
|
|
29
31
|
export { BUSINESS_FIND_MAX } from "./sqlite/business-search.js";
|
|
30
32
|
export { CATALOG_QUERY } from "./sqlite/catalog.js";
|
|
31
33
|
export { crmIdentityId } from "./sqlite/crm.js";
|
|
32
34
|
export { COMPANY_TYPE_MEANINGS, CRM_LINK_MODES, crmSettingKey, } from "./sqlite/crm-settings.js";
|
|
33
35
|
export { EVENT_FIELDS, } from "./sqlite/event-search.js";
|
|
36
|
+
export { QUOTE_LIMIT, quoteKept } from "./sqlite/evidence-signature.js";
|
|
34
37
|
export { IMPORTED_DOCUMENT_QUERY } from "./sqlite/imported-documents.js";
|
|
35
38
|
export { ORGANIZATION_KINDS, PROJECT_TYPES, SCOPES } from "./sqlite/knowledge.js";
|
|
36
39
|
export { NOTE_FIELDS, } from "./sqlite/note-search.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CacheDatabase } from "./driver.js";
|
|
2
|
+
/** Before the open. SQLite creates `-wal` before `-shm` and deletes it after, so it never leaves `-shm` alone itself. */
|
|
3
|
+
export declare const noteShmWithoutWal: (store: string, command: string) => void;
|
|
4
|
+
export declare const watchJournal: (database: CacheDatabase, store: string, command: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Called before each outermost commit. A connection keeps writing into a `-wal` that was unlinked under it while the
|
|
7
|
+
* next process starts a fresh one, and the two journals then overwrite each other's pages: refusing the commit is
|
|
8
|
+
* the only point at which this process can still keep out of it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const checkJournal: (database: CacheDatabase) => void;
|