@wirecat/cli-core 0.556.0 → 0.558.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 +37 -0
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -1
- package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
- package/dist/domain/finance.d.ts +40 -0
- package/dist/domain/finance.js +39 -0
- package/dist/domain/money.d.ts +29 -0
- package/dist/domain/money.js +98 -0
- package/dist/domain/ref-summaries.js +2 -0
- package/dist/domain/references.d.ts +1 -1
- package/dist/domain/references.js +2 -0
- package/dist/entities/fact.d.ts +1 -12
- package/dist/entities/fact.js +0 -13
- package/dist/entities/index.d.ts +2 -12
- package/dist/entities/meeting-findings.d.ts +1 -1
- package/dist/errors/reasons.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/mail/cli/review.js +0 -1
- package/dist/meetings/findings-rules.d.ts +7 -4
- package/dist/meetings/findings-rules.js +11 -4
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/meetings/payment.d.ts +10 -6
- package/dist/meetings/payment.js +21 -6
- package/dist/services/project-status/index.d.ts +1 -1
- package/dist/services/project-status/index.js +7 -3
- package/dist/services/project-status/signals/payments.d.ts +3 -3
- package/dist/services/project-status/signals/payments.js +43 -17
- package/dist/services/proposals/kinds/finance.d.ts +4 -0
- package/dist/services/proposals/kinds/finance.js +40 -0
- package/dist/services/proposals/registry.js +3 -0
- package/dist/store/evidence-findings.js +16 -8
- package/dist/store/index.d.ts +2 -1
- package/dist/store/project-transfer/request.d.ts +1 -1
- package/dist/store/project-transfer/schema.d.ts +2 -2
- package/dist/store/project-transfer/snapshot-model.d.ts +2 -2
- package/dist/store/sqlite/entity-types.d.ts +2 -0
- package/dist/store/sqlite/entity-types.js +2 -0
- package/dist/store/sqlite/facts.d.ts +0 -13
- package/dist/store/sqlite/facts.js +5 -58
- package/dist/store/sqlite/finance.d.ts +203 -0
- package/dist/store/sqlite/finance.js +529 -0
- package/dist/store/sqlite/findings-core.js +5 -14
- package/dist/store/sqlite/knowledge.js +3 -1
- package/dist/store/sqlite/manifest.js +3 -0
- package/dist/store/sqlite/migrations.generated.js +43 -0
- package/dist/store/sqlite/open-store.js +2 -0
- package/dist/store/sqlite/payment-entries.d.ts +26 -0
- package/dist/store/sqlite/payment-entries.js +91 -0
- package/dist/store/sqlite/payment-facts.d.ts +12 -0
- package/dist/store/sqlite/payment-facts.js +92 -0
- package/dist/store/sqlite/project-transfer/snapshot.d.ts +1 -1
- package/dist/store/sqlite/ref-summaries.js +33 -0
- package/dist/store/sqlite/schema.d.ts +1043 -0
- package/dist/store/sqlite/schema.js +98 -0
- package/dist/store/sqlite/things.js +2 -0
- package/dist/store/store.d.ts +3 -1
- package/dist/store/store.js +5 -0
- package/package.json +1 -1
- package/dist/cli/payment-query.d.ts +0 -8
- package/dist/cli/payment-query.js +0 -27
|
@@ -1394,6 +1394,104 @@ export const facts = sqliteTable("facts", {
|
|
|
1394
1394
|
index("facts_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1395
1395
|
index("facts_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1396
1396
|
]);
|
|
1397
|
+
/** An invoice the owner issued or received; its total is the sum of its lines, its status follows allocations. */
|
|
1398
|
+
export const invoices = sqliteTable("invoices", {
|
|
1399
|
+
id: integer("id").primaryKey(),
|
|
1400
|
+
direction: text("direction").notNull(),
|
|
1401
|
+
number: text("number"),
|
|
1402
|
+
issuerType: text("issuer_type"),
|
|
1403
|
+
issuerId: integer("issuer_id"),
|
|
1404
|
+
counterpartyType: text("counterparty_type").notNull(),
|
|
1405
|
+
counterpartyId: integer("counterparty_id").notNull(),
|
|
1406
|
+
projectId: integer("project_id").references(() => projects.id),
|
|
1407
|
+
currency: text("currency").notNull(),
|
|
1408
|
+
/** Minor units of `currency`. */
|
|
1409
|
+
total: integer("total").notNull(),
|
|
1410
|
+
issueDate: text("issue_date"),
|
|
1411
|
+
dueDate: text("due_date"),
|
|
1412
|
+
status: text("status").notNull(),
|
|
1413
|
+
review: text("review").notNull(),
|
|
1414
|
+
authorType: text("author_type").notNull(),
|
|
1415
|
+
authorId: integer("author_id").notNull(),
|
|
1416
|
+
model: text("model"),
|
|
1417
|
+
confirmedByType: text("confirmed_by_type"),
|
|
1418
|
+
confirmedById: integer("confirmed_by_id"),
|
|
1419
|
+
source: text("source").notNull(),
|
|
1420
|
+
metadata: text("metadata"),
|
|
1421
|
+
createdAt: integer("created_at").notNull(),
|
|
1422
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1423
|
+
deletedAt: integer("deleted_at"),
|
|
1424
|
+
}, (table) => [
|
|
1425
|
+
index("invoices_by_issuer_type_issuer_id").on(table.issuerType, table.issuerId),
|
|
1426
|
+
index("invoices_by_counterparty_type_counterparty_id").on(table.counterpartyType, table.counterpartyId),
|
|
1427
|
+
index("invoices_by_project_id").on(table.projectId),
|
|
1428
|
+
index("invoices_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1429
|
+
index("invoices_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1430
|
+
]);
|
|
1431
|
+
export const invoiceLines = sqliteTable("invoice_lines", {
|
|
1432
|
+
id: integer("id").primaryKey(),
|
|
1433
|
+
invoiceId: integer("invoice_id")
|
|
1434
|
+
.notNull()
|
|
1435
|
+
.references(() => invoices.id),
|
|
1436
|
+
position: integer("position").notNull(),
|
|
1437
|
+
description: text("description").notNull(),
|
|
1438
|
+
/** A decimal as text: never a float. */
|
|
1439
|
+
quantity: text("quantity").notNull(),
|
|
1440
|
+
unitPrice: integer("unit_price"),
|
|
1441
|
+
amount: integer("amount").notNull(),
|
|
1442
|
+
createdAt: integer("created_at").notNull(),
|
|
1443
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1444
|
+
}, (table) => [unique().on(table.invoiceId, table.position)]);
|
|
1445
|
+
/** Money that moved to or from the owner, in minor units of its currency. */
|
|
1446
|
+
export const payments = sqliteTable("payments", {
|
|
1447
|
+
id: integer("id").primaryKey(),
|
|
1448
|
+
direction: text("direction").notNull(),
|
|
1449
|
+
payerType: text("payer_type"),
|
|
1450
|
+
payerId: integer("payer_id"),
|
|
1451
|
+
payeeType: text("payee_type"),
|
|
1452
|
+
payeeId: integer("payee_id"),
|
|
1453
|
+
amount: integer("amount").notNull(),
|
|
1454
|
+
currency: text("currency").notNull(),
|
|
1455
|
+
paymentDate: text("payment_date").notNull(),
|
|
1456
|
+
reference: text("reference"),
|
|
1457
|
+
projectId: integer("project_id").references(() => projects.id),
|
|
1458
|
+
review: text("review").notNull(),
|
|
1459
|
+
authorType: text("author_type").notNull(),
|
|
1460
|
+
authorId: integer("author_id").notNull(),
|
|
1461
|
+
model: text("model"),
|
|
1462
|
+
confirmedByType: text("confirmed_by_type"),
|
|
1463
|
+
confirmedById: integer("confirmed_by_id"),
|
|
1464
|
+
source: text("source").notNull(),
|
|
1465
|
+
metadata: text("metadata"),
|
|
1466
|
+
createdAt: integer("created_at").notNull(),
|
|
1467
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1468
|
+
deletedAt: integer("deleted_at"),
|
|
1469
|
+
}, (table) => [
|
|
1470
|
+
index("payments_by_payer_type_payer_id").on(table.payerType, table.payerId),
|
|
1471
|
+
index("payments_by_payee_type_payee_id").on(table.payeeType, table.payeeId),
|
|
1472
|
+
index("payments_by_project_id").on(table.projectId),
|
|
1473
|
+
index("payments_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1474
|
+
index("payments_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById),
|
|
1475
|
+
]);
|
|
1476
|
+
/** How much of a payment settles an invoice; triggers keep it within both and in one currency. */
|
|
1477
|
+
export const paymentAllocations = sqliteTable("payment_allocations", {
|
|
1478
|
+
id: integer("id").primaryKey(),
|
|
1479
|
+
paymentId: integer("payment_id")
|
|
1480
|
+
.notNull()
|
|
1481
|
+
.references(() => payments.id),
|
|
1482
|
+
invoiceId: integer("invoice_id")
|
|
1483
|
+
.notNull()
|
|
1484
|
+
.references(() => invoices.id),
|
|
1485
|
+
amount: integer("amount").notNull(),
|
|
1486
|
+
authorType: text("author_type").notNull(),
|
|
1487
|
+
authorId: integer("author_id").notNull(),
|
|
1488
|
+
createdAt: integer("created_at").notNull(),
|
|
1489
|
+
updatedAt: integer("updated_at").notNull(),
|
|
1490
|
+
}, (table) => [
|
|
1491
|
+
unique().on(table.paymentId, table.invoiceId),
|
|
1492
|
+
index("payment_allocations_by_invoice_id").on(table.invoiceId),
|
|
1493
|
+
index("payment_allocations_by_author_type_author_id").on(table.authorType, table.authorId),
|
|
1494
|
+
]);
|
|
1397
1495
|
export const proposedActions = sqliteTable("proposed_actions", {
|
|
1398
1496
|
id: integer("id").primaryKey(),
|
|
1399
1497
|
kind: text("kind").notNull(),
|
|
@@ -17,6 +17,8 @@ const REFERABLE = {
|
|
|
17
17
|
fact: { tombstone: true },
|
|
18
18
|
bot: { tombstone: false },
|
|
19
19
|
event: { tombstone: true },
|
|
20
|
+
invoice: { tombstone: true },
|
|
21
|
+
payment: { tombstone: true },
|
|
20
22
|
message: { tombstone: true },
|
|
21
23
|
email: { tombstone: true },
|
|
22
24
|
email_thread: { tombstone: true },
|
package/dist/store/store.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { type MailStore } from "./sqlite/emails.js";
|
|
|
25
25
|
import { type EventSearch } from "./sqlite/event-search.js";
|
|
26
26
|
import { type FactsStore } from "./sqlite/facts.js";
|
|
27
27
|
import { type FilesStore } from "./sqlite/files.js";
|
|
28
|
+
import { type FinanceStore } from "./sqlite/finance.js";
|
|
28
29
|
import { type InvolvementStore } from "./sqlite/involvements.js";
|
|
29
30
|
import { type KnowledgeStore } from "./sqlite/knowledge.js";
|
|
30
31
|
import { type MeetingVectors } from "./sqlite/meeting-vectors.js";
|
|
@@ -95,6 +96,8 @@ export interface MessageStore {
|
|
|
95
96
|
/** What any ref names, a page of them at a time: read once per page, never once per row. */
|
|
96
97
|
readonly refs: RefsStore;
|
|
97
98
|
readonly facts: FactsStore;
|
|
99
|
+
/** Invoices, payments and their allocations, in exact minor units; an agent's or an import's wait for the owner. */
|
|
100
|
+
readonly finance: FinanceStore;
|
|
98
101
|
/** What agents concluded: summaries, digests, facts, preferences, each with evidence and a scope. */
|
|
99
102
|
readonly memories: MemoriesStore;
|
|
100
103
|
/** What an agent wants done outside the store, waiting for the owner's approval. */
|
|
@@ -112,7 +115,6 @@ export interface MessageStore {
|
|
|
112
115
|
forAccount(key: AccountKey): AccountStore;
|
|
113
116
|
close(): Promise<void>;
|
|
114
117
|
}
|
|
115
|
-
export type { PaymentFilter } from "./sqlite/facts.js";
|
|
116
118
|
export type { ChatHistoryShape, StoredHistorySkip } from "./sqlite/history-skips.js";
|
|
117
119
|
export { BACKFILL_ON_OPEN, type StoreOptions } from "./sqlite/open-store.js";
|
|
118
120
|
export { fileFacts, readStoreTables, type TableKind } from "./sqlite/store-tables.js";
|
package/dist/store/store.js
CHANGED
|
@@ -24,6 +24,7 @@ import { eventSearchOver } from "./sqlite/event-search.js";
|
|
|
24
24
|
import { evidenceFindingsStoreOver } from "./sqlite/evidence-findings.js";
|
|
25
25
|
import { factsStoreOver } from "./sqlite/facts.js";
|
|
26
26
|
import { filesStoreOver } from "./sqlite/files.js";
|
|
27
|
+
import { financeStoreOver } from "./sqlite/finance.js";
|
|
27
28
|
import { involvementStoreOver } from "./sqlite/involvements.js";
|
|
28
29
|
import { knowledgeStoreOver } from "./sqlite/knowledge.js";
|
|
29
30
|
import { logPruner } from "./sqlite/log-pruning.js";
|
|
@@ -110,6 +111,7 @@ const storeOver = (context) => {
|
|
|
110
111
|
summaries: async (texts, options) => refSummariesOf(context.database, texts, options),
|
|
111
112
|
};
|
|
112
113
|
const facts = once(() => factsStoreOver(context));
|
|
114
|
+
const finance = once(() => financeStoreOver(context));
|
|
113
115
|
const memories = once(() => memoriesStoreOver(context));
|
|
114
116
|
const proposedActions = once(() => proposedActionsStoreOver(context));
|
|
115
117
|
const agentActions = once(() => agentActionsStoreOver(context, pruneLogsWhenDue));
|
|
@@ -210,6 +212,9 @@ const storeOver = (context) => {
|
|
|
210
212
|
get facts() {
|
|
211
213
|
return facts();
|
|
212
214
|
},
|
|
215
|
+
get finance() {
|
|
216
|
+
return finance();
|
|
217
|
+
},
|
|
213
218
|
get memories() {
|
|
214
219
|
return memories();
|
|
215
220
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.558.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",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PaymentFilter } from "../store/store.js";
|
|
2
|
-
/**
|
|
3
|
-
* The terms a facts list adds for payments. `state` is the payment's, not `status`, which stays the review status
|
|
4
|
-
* (proposed, accepted).
|
|
5
|
-
*/
|
|
6
|
-
export declare const PAYMENT_QUERY_FIELDS: import("@wirecat/cli-base/query").FieldSpec[];
|
|
7
|
-
/** The store's payment filter from `queryTerms`' answer; `undefined` when no payment term was given. */
|
|
8
|
-
export declare const paymentFilterOf: (terms: Map<string, string>) => PaymentFilter | undefined;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CliError } from "@wirecat/cli-base";
|
|
2
|
-
import { PAYMENT_DIRECTIONS, PAYMENT_STATES } from "../meetings/index.js";
|
|
3
|
-
import { termField } from "./list-query.js";
|
|
4
|
-
/**
|
|
5
|
-
* The terms a facts list adds for payments. `state` is the payment's, not `status`, which stays the review status
|
|
6
|
-
* (proposed, accepted).
|
|
7
|
-
*/
|
|
8
|
-
export const PAYMENT_QUERY_FIELDS = [
|
|
9
|
-
termField("open", "bool", "open:true"),
|
|
10
|
-
termField("direction", "enum", "direction:to_us", { values: PAYMENT_DIRECTIONS }),
|
|
11
|
-
termField("state", "enum", "state:paid", { values: PAYMENT_STATES }),
|
|
12
|
-
];
|
|
13
|
-
/** The store's payment filter from `queryTerms`' answer; `undefined` when no payment term was given. */
|
|
14
|
-
export const paymentFilterOf = (terms) => {
|
|
15
|
-
const open = terms.get("open");
|
|
16
|
-
const direction = terms.get("direction");
|
|
17
|
-
const state = terms.get("state");
|
|
18
|
-
if (open === undefined && direction === undefined && state === undefined)
|
|
19
|
-
return undefined;
|
|
20
|
-
if (open !== undefined && open !== "true" && open !== "false")
|
|
21
|
-
throw new CliError("validation_error", "open takes true or false");
|
|
22
|
-
return {
|
|
23
|
-
...(open === undefined ? {} : { open: open === "true" }),
|
|
24
|
-
...(direction === undefined ? {} : { direction }),
|
|
25
|
-
...(state === undefined ? {} : { state }),
|
|
26
|
-
};
|
|
27
|
-
};
|