@wirecat/cli-core 0.583.0 → 0.585.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 +24 -0
- package/dist/cli/messenger/store-maintenance-command.d.ts +1 -1
- package/dist/cli/schedule/schedule-command.js +28 -12
- package/dist/domain/deals.d.ts +20 -0
- package/dist/domain/deals.js +15 -0
- package/dist/domain/ref-summaries.js +1 -0
- package/dist/domain/references.d.ts +1 -1
- package/dist/domain/references.js +1 -0
- package/dist/entities/index.d.ts +8 -0
- package/dist/entities/list-results.d.ts +12 -0
- package/dist/entities/list-results.js +9 -0
- package/dist/errors/reasons.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/services/proposals/kinds/deals.d.ts +4 -0
- package/dist/services/proposals/kinds/deals.js +32 -0
- package/dist/services/proposals/registry.js +2 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/sqlite/deals.d.ts +104 -0
- package/dist/store/sqlite/deals.js +264 -0
- package/dist/store/sqlite/entity-types.d.ts +1 -0
- package/dist/store/sqlite/entity-types.js +1 -0
- package/dist/store/sqlite/finance.d.ts +3 -3
- package/dist/store/sqlite/knowledge.js +2 -1
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +21 -0
- package/dist/store/sqlite/ref-summaries.js +10 -0
- package/dist/store/sqlite/schema.d.ts +554 -0
- package/dist/store/sqlite/schema.js +52 -0
- package/dist/store/sqlite/things.js +1 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ shape of this file.
|
|
|
7
7
|
|
|
8
8
|
## Unreleased
|
|
9
9
|
|
|
10
|
+
## 0.585.0 — 06.11.2026
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Deals in the store (store version 52).** `store.deals` keeps the owner's sales pipelines (`pipelines`,
|
|
15
|
+
`pipeline_stages`, made by the owner only) and the deals in them (table `opportunities`, ref `deal:<id>`): title,
|
|
16
|
+
organization, project, stage, status `open`, `won` or `lost` kept apart from the stage, the expected amount in minor
|
|
17
|
+
units with its currency, the expected close day and the day it closed. The people on a deal are `related-to` links
|
|
18
|
+
with a role (`owner`, `contact`, `decision-maker`). The owner's deal is confirmed at once; an agent's is a `deal`
|
|
19
|
+
proposal only the owner decides. Only the owner moves a deal, within its own pipeline, or closes it.
|
|
20
|
+
|
|
21
|
+
## 0.584.0 — 06.11.2026
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **`schedule list` gives an agent schedule's cost caps.** `max_cost_usd` is the cap on one run (`--max-cost`, null
|
|
26
|
+
when none) and `max_cost_per_day_usd` the daily cap in force, the schedule's `--max-cost-per-day` or the config's
|
|
27
|
+
(0 for none), so a screen can show `$0.84 of $5.00`; the text line says `today $0.84 of $5.00`.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- **`schedule list`'s output schema describes what it prints.** `spent_today_usd`, and the last run's `cost_usd`
|
|
32
|
+
and `skipped`, were printed but missing from the strict `scheduled_job` schema.
|
|
33
|
+
|
|
10
34
|
## 0.583.0 — 05.11.2026
|
|
11
35
|
|
|
12
36
|
### Changed — may break callers
|
|
@@ -3,9 +3,9 @@ import type { CacheDatabase } from "../../store/driver.js";
|
|
|
3
3
|
import type { Messenger } from "./context.js";
|
|
4
4
|
/** `doctor`'s short summary of the store. Must answer for a broken file, so an error is a field. */
|
|
5
5
|
export declare const storeSummary: (env: NodeJS.ProcessEnv) => Promise<{
|
|
6
|
+
error?: undefined;
|
|
6
7
|
path: string;
|
|
7
8
|
exists: boolean;
|
|
8
|
-
error?: undefined;
|
|
9
9
|
} | {
|
|
10
10
|
path: string;
|
|
11
11
|
exists: boolean;
|
|
@@ -138,6 +138,12 @@ export const scheduleLimitsOf = (config) => {
|
|
|
138
138
|
const given = (limits) => Object.fromEntries(Object.entries(limits).filter(([, value]) => value !== undefined));
|
|
139
139
|
const shown = (argv) => argv.map((arg) => (arg === "" ? '""' : arg)).join(" ");
|
|
140
140
|
const usd = (value) => `$${value.toFixed(2)}`;
|
|
141
|
+
/** The per-run cap an agent schedule was made with (`--max-cost`, passed to claude as --max-budget-usd), or null. */
|
|
142
|
+
const runCapOf = (argv) => {
|
|
143
|
+
const at = argv.indexOf("--max-budget-usd");
|
|
144
|
+
const cap = at < 0 ? Number.NaN : Number(argv[at + 1]);
|
|
145
|
+
return Number.isFinite(cap) ? cap : null;
|
|
146
|
+
};
|
|
141
147
|
/**
|
|
142
148
|
* Runs the CLI's own commands, or an agent, later or on a timer — through systemd (Linux), launchd
|
|
143
149
|
* (macOS) or Task Scheduler (Windows). Every timer runs `schedule exec <file>`; the schedule file holds
|
|
@@ -184,19 +190,21 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, limits: c
|
|
|
184
190
|
* Why a run does not start now, or nothing: an agent whose runs reached the day's cost cap waits for tomorrow, and
|
|
185
191
|
* one gated on mail waits for mail past its holder's mark — on its timer, until enough of it waits.
|
|
186
192
|
*/
|
|
193
|
+
/** A schedule's own limits, else the config file's, else the defaults. */
|
|
194
|
+
const limitsOf = (self, schedule) => ({
|
|
195
|
+
...SCHEDULE_DEFAULTS,
|
|
196
|
+
...given(configured?.(self) ?? {}),
|
|
197
|
+
...given({
|
|
198
|
+
mailWaitMinutes: schedule.mailWaitMinutes,
|
|
199
|
+
mailBatch: schedule.mailBatch,
|
|
200
|
+
maxCostPerDay: schedule.maxCostPerDay,
|
|
201
|
+
}),
|
|
202
|
+
});
|
|
187
203
|
const waits = async (self, file, { timed }) => {
|
|
188
204
|
if (!existsSync(file))
|
|
189
205
|
return undefined;
|
|
190
206
|
const schedule = readSchedule(file);
|
|
191
|
-
const { mailWaitMinutes, mailBatch, maxCostPerDay } =
|
|
192
|
-
...SCHEDULE_DEFAULTS,
|
|
193
|
-
...given(configured?.(self) ?? {}),
|
|
194
|
-
...given({
|
|
195
|
-
mailWaitMinutes: schedule.mailWaitMinutes,
|
|
196
|
-
mailBatch: schedule.mailBatch,
|
|
197
|
-
maxCostPerDay: schedule.maxCostPerDay,
|
|
198
|
-
}),
|
|
199
|
-
};
|
|
207
|
+
const { mailWaitMinutes, mailBatch, maxCostPerDay } = limitsOf(self, schedule);
|
|
200
208
|
if (schedule.kind === "agent" && maxCostPerDay > 0) {
|
|
201
209
|
const spent = spentToday(file);
|
|
202
210
|
if (spent >= maxCostPerDay) {
|
|
@@ -342,7 +350,13 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, limits: c
|
|
|
342
350
|
kind: schedule.kind,
|
|
343
351
|
when: describeWhen(schedule.when),
|
|
344
352
|
last: lastRun(scheduleFile(state, schedule.name)) ?? null,
|
|
345
|
-
...(schedule.kind === "agent"
|
|
353
|
+
...(schedule.kind === "agent"
|
|
354
|
+
? {
|
|
355
|
+
spentTodayUsd: spentToday(scheduleFile(state, schedule.name)),
|
|
356
|
+
maxCostUsd: runCapOf(schedule.argv),
|
|
357
|
+
maxCostPerDayUsd: limitsOf(this, schedule).maxCostPerDay,
|
|
358
|
+
}
|
|
359
|
+
: {}),
|
|
346
360
|
}));
|
|
347
361
|
const answer = listOf("schedule list", {
|
|
348
362
|
items: rows.map((row) => snakeKeys(row)),
|
|
@@ -355,7 +369,7 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, limits: c
|
|
|
355
369
|
return "";
|
|
356
370
|
}
|
|
357
371
|
return rows
|
|
358
|
-
.map(({ name, kind, when, last, spentTodayUsd }) => [
|
|
372
|
+
.map(({ name, kind, when, last, spentTodayUsd, maxCostPerDayUsd }) => [
|
|
359
373
|
name,
|
|
360
374
|
kind,
|
|
361
375
|
when,
|
|
@@ -366,7 +380,9 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, limits: c
|
|
|
366
380
|
`${last.failures} in a row${last.reason ? `: ${last.reason}` : ""} — ${last.output}`
|
|
367
381
|
: "")
|
|
368
382
|
: "not run yet",
|
|
369
|
-
...(spentTodayUsd
|
|
383
|
+
...(spentTodayUsd
|
|
384
|
+
? [`today ${usd(spentTodayUsd)}${maxCostPerDayUsd ? ` of ${usd(maxCostPerDayUsd)}` : ""}`]
|
|
385
|
+
: []),
|
|
370
386
|
...(last?.skipped
|
|
371
387
|
? [`skipped ${last.skipped.at.slice(0, 16).replace("T", " ")}: ${last.skipped.why}`]
|
|
372
388
|
: []),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FinanceReview } from "./finance.js";
|
|
2
|
+
/** Whether a deal ended, kept apart from the stage it stands in. */
|
|
3
|
+
export declare const DEAL_STATUSES: readonly ["open", "won", "lost"];
|
|
4
|
+
/** The part a person plays on a deal: the owner's side runs it, the client's side talks or decides. */
|
|
5
|
+
export declare const DEAL_ROLES: readonly ["owner", "contact", "decision-maker"];
|
|
6
|
+
export type DealStatus = (typeof DEAL_STATUSES)[number];
|
|
7
|
+
export type DealRole = (typeof DEAL_ROLES)[number];
|
|
8
|
+
export interface DealTitleFields {
|
|
9
|
+
id: number;
|
|
10
|
+
title: string;
|
|
11
|
+
stage: string;
|
|
12
|
+
amount: number | null;
|
|
13
|
+
currency: string | null;
|
|
14
|
+
status: DealStatus;
|
|
15
|
+
review: FinanceReview;
|
|
16
|
+
}
|
|
17
|
+
/** "Site redesign · Proposal, 500 000.00 RUB": a ref summary's title, which `refLabel` prefixes. */
|
|
18
|
+
export declare const dealLine: (deal: DealTitleFields) => string;
|
|
19
|
+
/** "Deal Site redesign · Proposal, 500 000.00 RUB (won)". */
|
|
20
|
+
export declare const dealTitle: (deal: DealTitleFields) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moneyLabel } from "./money.js";
|
|
2
|
+
/** Whether a deal ended, kept apart from the stage it stands in. */
|
|
3
|
+
export const DEAL_STATUSES = ["open", "won", "lost"];
|
|
4
|
+
/** The part a person plays on a deal: the owner's side runs it, the client's side talks or decides. */
|
|
5
|
+
export const DEAL_ROLES = ["owner", "contact", "decision-maker"];
|
|
6
|
+
/** "Site redesign · Proposal, 500 000.00 RUB": a ref summary's title, which `refLabel` prefixes. */
|
|
7
|
+
export const dealLine = (deal) => {
|
|
8
|
+
const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
|
|
9
|
+
const notes = [deal.status === "open" ? null : deal.status, deal.review === "confirmed" ? null : deal.review]
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.join(", ");
|
|
12
|
+
return `${deal.title} · ${deal.stage}${money}${notes ? ` (${notes})` : ""}`;
|
|
13
|
+
};
|
|
14
|
+
/** "Deal Site redesign · Proposal, 500 000.00 RUB (won)". */
|
|
15
|
+
export const dealTitle = (deal) => `Deal ${dealLine(deal)}`;
|
|
@@ -33,7 +33,7 @@ export type Reference = {
|
|
|
33
33
|
* Things named by their store id (a task also by its key or the task package's id). `entity` is the name
|
|
34
34
|
* before organizations and projects: it still parses, so an old file's reference resolves as not found.
|
|
35
35
|
*/
|
|
36
|
-
export declare const SIMPLE_REFERENCES: readonly ["note", "document", "person", "organization", "project", "task", "memory", "fact", "bot", "event", "invoice", "payment", "order", "entity"];
|
|
36
|
+
export declare const SIMPLE_REFERENCES: readonly ["note", "document", "person", "organization", "project", "task", "memory", "fact", "bot", "event", "invoice", "payment", "order", "deal", "entity"];
|
|
37
37
|
export type SimpleReference = (typeof SIMPLE_REFERENCES)[number];
|
|
38
38
|
export type RefKindName = Exclude<Reference["type"], "entity">;
|
|
39
39
|
export interface RefKindSpec<R extends Reference = Reference> {
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -3979,7 +3979,15 @@ export declare const ENTITIES: {
|
|
|
3979
3979
|
readonly error_code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
3980
3980
|
readonly failing_since: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
3981
3981
|
readonly failures: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
3982
|
+
readonly cost_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
3983
|
+
readonly skipped: v.OptionalSchema<v.StrictObjectSchema<{
|
|
3984
|
+
readonly at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
3985
|
+
readonly why: v.StringSchema<undefined>;
|
|
3986
|
+
}, undefined>, undefined>;
|
|
3982
3987
|
}, undefined>, undefined>;
|
|
3988
|
+
readonly spent_today_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
3989
|
+
readonly max_cost_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
3990
|
+
readonly max_cost_per_day_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
3983
3991
|
}, undefined>;
|
|
3984
3992
|
readonly call_record: v.StrictObjectSchema<{
|
|
3985
3993
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
@@ -57,7 +57,19 @@ export declare const scheduledJob: v.StrictObjectSchema<{
|
|
|
57
57
|
readonly error_code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
58
58
|
readonly failing_since: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
59
59
|
readonly failures: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
60
|
+
readonly cost_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
61
|
+
/** The last time a run did not start, and why: the day's cost cap, or too little new mail. */
|
|
62
|
+
readonly skipped: v.OptionalSchema<v.StrictObjectSchema<{
|
|
63
|
+
readonly at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
64
|
+
readonly why: v.StringSchema<undefined>;
|
|
65
|
+
}, undefined>, undefined>;
|
|
60
66
|
}, undefined>, undefined>;
|
|
67
|
+
/** Agent schedules: what today's runs cost, in US dollars. */
|
|
68
|
+
readonly spent_today_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
69
|
+
/** Agent schedules: the cap on one run (`--max-cost`), null when none. */
|
|
70
|
+
readonly max_cost_usd: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
71
|
+
/** Agent schedules: the daily cap in force, the schedule's `--max-cost-per-day` or the config's; 0 for none. */
|
|
72
|
+
readonly max_cost_per_day_usd: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
61
73
|
}, undefined>;
|
|
62
74
|
export declare const botTemplate: v.StrictObjectSchema<{
|
|
63
75
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -41,7 +41,16 @@ export const scheduledJob = v.strictObject({
|
|
|
41
41
|
error_code: v.optional(text),
|
|
42
42
|
failing_since: v.optional(time),
|
|
43
43
|
failures: v.optional(v.number()),
|
|
44
|
+
cost_usd: v.optional(v.number()),
|
|
45
|
+
/** The last time a run did not start, and why: the day's cost cap, or too little new mail. */
|
|
46
|
+
skipped: v.optional(v.strictObject({ at: time, why: text })),
|
|
44
47
|
})),
|
|
48
|
+
/** Agent schedules: what today's runs cost, in US dollars. */
|
|
49
|
+
spent_today_usd: v.optional(v.number()),
|
|
50
|
+
/** Agent schedules: the cap on one run (`--max-cost`), null when none. */
|
|
51
|
+
max_cost_usd: v.optional(v.nullable(v.number())),
|
|
52
|
+
/** Agent schedules: the daily cap in force, the schedule's `--max-cost-per-day` or the config's; 0 for none. */
|
|
53
|
+
max_cost_per_day_usd: v.optional(v.number()),
|
|
45
54
|
});
|
|
46
55
|
export const botTemplate = v.strictObject({
|
|
47
56
|
name: v.nullable(text),
|
package/dist/errors/reasons.js
CHANGED
|
@@ -203,6 +203,14 @@ const OTHERS = [
|
|
|
203
203
|
validation("money.amount", "the amount is not a decimal string in the currency's scale"),
|
|
204
204
|
validation("money.currency", "the currency is not one the store keeps money in"),
|
|
205
205
|
validation("money.quantity", "the quantity is not a decimal above 0"),
|
|
206
|
+
validation("deal.closed", "a won, lost, rejected or deleted deal does not move or close again"),
|
|
207
|
+
validation("deal.field", "a field of the deal is not valid"),
|
|
208
|
+
["deal.owner-only", "permission_error", "only the owner moves or closes a deal, or makes a pipeline"],
|
|
209
|
+
validation("deal.ref", "the reference names no deal"),
|
|
210
|
+
validation("deal.stage", "no stage of that name, or a stage name more than one pipeline has"),
|
|
211
|
+
validation("pipeline.duplicate", "a pipeline of that name is already stored"),
|
|
212
|
+
validation("pipeline.field", "a pipeline needs a name and at least one stage, each named once"),
|
|
213
|
+
["pipeline.not-found", "not_found", "no stored pipeline has that name"],
|
|
206
214
|
validation("order.duplicate", "the shop's order with this number is already stored; change its status instead"),
|
|
207
215
|
validation("order.proposed", "the shop's order with this number already waits for the owner in a findings batch"),
|
|
208
216
|
validation("order.field", "a field of the order is not valid"),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { bareCheck, type CheckWords, checkWords } from "./domain/checks.js";
|
|
2
2
|
export type { CounterField, CounterObservation, CounterObservations, CounterState } from "./domain/counters.js";
|
|
3
3
|
export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
|
|
4
|
+
export { DEAL_ROLES, DEAL_STATUSES, type DealRole, type DealStatus } from "./domain/deals.js";
|
|
4
5
|
export { FINANCE_REVIEWS, type FinanceReview, INVOICE_DIRECTIONS, INVOICE_STATUSES, type InvoiceDirection, type InvoiceStatus, MONEY_DIRECTIONS, type MoneyDirection, } from "./domain/finance.js";
|
|
5
6
|
export { type FormattedText, type HtmlFormatting, type MarkdownFormatting, type TextSpan, validateFormattedText, } from "./domain/formatting.js";
|
|
6
7
|
export { formatLocator, isLocator, type MessageLocator, parseLocator } from "./domain/locator.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { bareCheck, checkWords } from "./domain/checks.js";
|
|
2
2
|
export { COUNTER_FIELDS, counterValue, observedCounters } from "./domain/counters.js";
|
|
3
|
+
export { DEAL_ROLES, DEAL_STATUSES } from "./domain/deals.js";
|
|
3
4
|
export { FINANCE_REVIEWS, INVOICE_DIRECTIONS, INVOICE_STATUSES, MONEY_DIRECTIONS, } from "./domain/finance.js";
|
|
4
5
|
export { validateFormattedText, } from "./domain/formatting.js";
|
|
5
6
|
export { formatLocator, isLocator, parseLocator } from "./domain/locator.js";
|
|
@@ -38,7 +38,6 @@ export declare const meetingTools: ({
|
|
|
38
38
|
max_read_bytes?: undefined;
|
|
39
39
|
cursor?: undefined;
|
|
40
40
|
} | {
|
|
41
|
-
limit?: undefined;
|
|
42
41
|
event_id?: undefined;
|
|
43
42
|
series_id?: undefined;
|
|
44
43
|
page?: undefined;
|
|
@@ -54,11 +53,11 @@ export declare const meetingTools: ({
|
|
|
54
53
|
format?: undefined;
|
|
55
54
|
transcript_id?: undefined;
|
|
56
55
|
query?: undefined;
|
|
56
|
+
limit?: undefined;
|
|
57
57
|
scan_limit?: undefined;
|
|
58
58
|
max_read_bytes?: undefined;
|
|
59
59
|
cursor?: undefined;
|
|
60
60
|
} | {
|
|
61
|
-
limit?: undefined;
|
|
62
61
|
event_id?: undefined;
|
|
63
62
|
series_id?: undefined;
|
|
64
63
|
page?: undefined;
|
|
@@ -76,11 +75,11 @@ export declare const meetingTools: ({
|
|
|
76
75
|
format?: undefined;
|
|
77
76
|
transcript_id?: undefined;
|
|
78
77
|
query?: undefined;
|
|
78
|
+
limit?: undefined;
|
|
79
79
|
scan_limit?: undefined;
|
|
80
80
|
max_read_bytes?: undefined;
|
|
81
81
|
cursor?: undefined;
|
|
82
82
|
} | {
|
|
83
|
-
limit?: undefined;
|
|
84
83
|
event_id?: undefined;
|
|
85
84
|
series_id?: undefined;
|
|
86
85
|
page?: undefined;
|
|
@@ -102,6 +101,7 @@ export declare const meetingTools: ({
|
|
|
102
101
|
minimum: number;
|
|
103
102
|
};
|
|
104
103
|
query?: undefined;
|
|
104
|
+
limit?: undefined;
|
|
105
105
|
scan_limit?: undefined;
|
|
106
106
|
max_read_bytes?: undefined;
|
|
107
107
|
cursor?: undefined;
|
|
@@ -188,7 +188,6 @@ export declare const meetingTools: ({
|
|
|
188
188
|
max_read_bytes?: undefined;
|
|
189
189
|
cursor?: undefined;
|
|
190
190
|
} | {
|
|
191
|
-
limit?: undefined;
|
|
192
191
|
event_id?: undefined;
|
|
193
192
|
series_id?: undefined;
|
|
194
193
|
page?: undefined;
|
|
@@ -204,11 +203,11 @@ export declare const meetingTools: ({
|
|
|
204
203
|
format?: undefined;
|
|
205
204
|
transcript_id?: undefined;
|
|
206
205
|
query?: undefined;
|
|
206
|
+
limit?: undefined;
|
|
207
207
|
scan_limit?: undefined;
|
|
208
208
|
max_read_bytes?: undefined;
|
|
209
209
|
cursor?: undefined;
|
|
210
210
|
} | {
|
|
211
|
-
limit?: undefined;
|
|
212
211
|
event_id?: undefined;
|
|
213
212
|
series_id?: undefined;
|
|
214
213
|
page?: undefined;
|
|
@@ -226,11 +225,11 @@ export declare const meetingTools: ({
|
|
|
226
225
|
format?: undefined;
|
|
227
226
|
transcript_id?: undefined;
|
|
228
227
|
query?: undefined;
|
|
228
|
+
limit?: undefined;
|
|
229
229
|
scan_limit?: undefined;
|
|
230
230
|
max_read_bytes?: undefined;
|
|
231
231
|
cursor?: undefined;
|
|
232
232
|
} | {
|
|
233
|
-
limit?: undefined;
|
|
234
233
|
event_id?: undefined;
|
|
235
234
|
series_id?: undefined;
|
|
236
235
|
page?: undefined;
|
|
@@ -252,6 +251,7 @@ export declare const meetingTools: ({
|
|
|
252
251
|
minimum: number;
|
|
253
252
|
};
|
|
254
253
|
query?: undefined;
|
|
254
|
+
limit?: undefined;
|
|
255
255
|
scan_limit?: undefined;
|
|
256
256
|
max_read_bytes?: undefined;
|
|
257
257
|
cursor?: undefined;
|
|
@@ -338,7 +338,6 @@ export declare const meetingTools: ({
|
|
|
338
338
|
max_read_bytes?: undefined;
|
|
339
339
|
cursor?: undefined;
|
|
340
340
|
} | {
|
|
341
|
-
limit?: undefined;
|
|
342
341
|
event_id?: undefined;
|
|
343
342
|
series_id?: undefined;
|
|
344
343
|
page?: undefined;
|
|
@@ -354,11 +353,11 @@ export declare const meetingTools: ({
|
|
|
354
353
|
format?: undefined;
|
|
355
354
|
transcript_id?: undefined;
|
|
356
355
|
query?: undefined;
|
|
356
|
+
limit?: undefined;
|
|
357
357
|
scan_limit?: undefined;
|
|
358
358
|
max_read_bytes?: undefined;
|
|
359
359
|
cursor?: undefined;
|
|
360
360
|
} | {
|
|
361
|
-
limit?: undefined;
|
|
362
361
|
event_id?: undefined;
|
|
363
362
|
series_id?: undefined;
|
|
364
363
|
page?: undefined;
|
|
@@ -376,11 +375,11 @@ export declare const meetingTools: ({
|
|
|
376
375
|
format?: undefined;
|
|
377
376
|
transcript_id?: undefined;
|
|
378
377
|
query?: undefined;
|
|
378
|
+
limit?: undefined;
|
|
379
379
|
scan_limit?: undefined;
|
|
380
380
|
max_read_bytes?: undefined;
|
|
381
381
|
cursor?: undefined;
|
|
382
382
|
} | {
|
|
383
|
-
limit?: undefined;
|
|
384
383
|
event_id?: undefined;
|
|
385
384
|
series_id?: undefined;
|
|
386
385
|
page?: undefined;
|
|
@@ -402,6 +401,7 @@ export declare const meetingTools: ({
|
|
|
402
401
|
minimum: number;
|
|
403
402
|
};
|
|
404
403
|
query?: undefined;
|
|
404
|
+
limit?: undefined;
|
|
405
405
|
scan_limit?: undefined;
|
|
406
406
|
max_read_bytes?: undefined;
|
|
407
407
|
cursor?: undefined;
|
|
@@ -488,7 +488,6 @@ export declare const meetingTools: ({
|
|
|
488
488
|
max_read_bytes?: undefined;
|
|
489
489
|
cursor?: undefined;
|
|
490
490
|
} | {
|
|
491
|
-
limit?: undefined;
|
|
492
491
|
event_id?: undefined;
|
|
493
492
|
series_id?: undefined;
|
|
494
493
|
page?: undefined;
|
|
@@ -504,11 +503,11 @@ export declare const meetingTools: ({
|
|
|
504
503
|
format?: undefined;
|
|
505
504
|
transcript_id?: undefined;
|
|
506
505
|
query?: undefined;
|
|
506
|
+
limit?: undefined;
|
|
507
507
|
scan_limit?: undefined;
|
|
508
508
|
max_read_bytes?: undefined;
|
|
509
509
|
cursor?: undefined;
|
|
510
510
|
} | {
|
|
511
|
-
limit?: undefined;
|
|
512
511
|
event_id?: undefined;
|
|
513
512
|
series_id?: undefined;
|
|
514
513
|
page?: undefined;
|
|
@@ -526,11 +525,11 @@ export declare const meetingTools: ({
|
|
|
526
525
|
format?: undefined;
|
|
527
526
|
transcript_id?: undefined;
|
|
528
527
|
query?: undefined;
|
|
528
|
+
limit?: undefined;
|
|
529
529
|
scan_limit?: undefined;
|
|
530
530
|
max_read_bytes?: undefined;
|
|
531
531
|
cursor?: undefined;
|
|
532
532
|
} | {
|
|
533
|
-
limit?: undefined;
|
|
534
533
|
event_id?: undefined;
|
|
535
534
|
series_id?: undefined;
|
|
536
535
|
page?: undefined;
|
|
@@ -552,6 +551,7 @@ export declare const meetingTools: ({
|
|
|
552
551
|
minimum: number;
|
|
553
552
|
};
|
|
554
553
|
query?: undefined;
|
|
554
|
+
limit?: undefined;
|
|
555
555
|
scan_limit?: undefined;
|
|
556
556
|
max_read_bytes?: undefined;
|
|
557
557
|
cursor?: undefined;
|
|
@@ -638,7 +638,6 @@ export declare const meetingTools: ({
|
|
|
638
638
|
max_read_bytes?: undefined;
|
|
639
639
|
cursor?: undefined;
|
|
640
640
|
} | {
|
|
641
|
-
limit?: undefined;
|
|
642
641
|
event_id?: undefined;
|
|
643
642
|
series_id?: undefined;
|
|
644
643
|
page?: undefined;
|
|
@@ -654,11 +653,11 @@ export declare const meetingTools: ({
|
|
|
654
653
|
format?: undefined;
|
|
655
654
|
transcript_id?: undefined;
|
|
656
655
|
query?: undefined;
|
|
656
|
+
limit?: undefined;
|
|
657
657
|
scan_limit?: undefined;
|
|
658
658
|
max_read_bytes?: undefined;
|
|
659
659
|
cursor?: undefined;
|
|
660
660
|
} | {
|
|
661
|
-
limit?: undefined;
|
|
662
661
|
event_id?: undefined;
|
|
663
662
|
series_id?: undefined;
|
|
664
663
|
page?: undefined;
|
|
@@ -676,11 +675,11 @@ export declare const meetingTools: ({
|
|
|
676
675
|
format?: undefined;
|
|
677
676
|
transcript_id?: undefined;
|
|
678
677
|
query?: undefined;
|
|
678
|
+
limit?: undefined;
|
|
679
679
|
scan_limit?: undefined;
|
|
680
680
|
max_read_bytes?: undefined;
|
|
681
681
|
cursor?: undefined;
|
|
682
682
|
} | {
|
|
683
|
-
limit?: undefined;
|
|
684
683
|
event_id?: undefined;
|
|
685
684
|
series_id?: undefined;
|
|
686
685
|
page?: undefined;
|
|
@@ -702,6 +701,7 @@ export declare const meetingTools: ({
|
|
|
702
701
|
minimum: number;
|
|
703
702
|
};
|
|
704
703
|
query?: undefined;
|
|
704
|
+
limit?: undefined;
|
|
705
705
|
scan_limit?: undefined;
|
|
706
706
|
max_read_bytes?: undefined;
|
|
707
707
|
cursor?: undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MessageStore } from "../../../store/index.js";
|
|
2
|
+
import type { ProposalKind } from "../types.js";
|
|
3
|
+
/** An agent's deal, by its own ref (`deal:12`) as orders are; only the owner decides it. */
|
|
4
|
+
export declare const dealKind: (store: Pick<MessageStore, "deals">) => ProposalKind;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { kept, proposerOfAuthor, pushed } from "./shared.js";
|
|
2
|
+
const rowOf = (deal) => ({
|
|
3
|
+
id: deal.ref,
|
|
4
|
+
kind: "deal",
|
|
5
|
+
status: deal.review,
|
|
6
|
+
project: deal.project,
|
|
7
|
+
subject: deal.ref,
|
|
8
|
+
object: deal.organization?.ref ?? null,
|
|
9
|
+
summary: `Deal ${deal.summary}`,
|
|
10
|
+
proposedBy: proposerOfAuthor(deal.author),
|
|
11
|
+
reason: deal.reason,
|
|
12
|
+
evidence: [],
|
|
13
|
+
score: null,
|
|
14
|
+
signals: null,
|
|
15
|
+
parts: null,
|
|
16
|
+
createdAt: deal.createdAt,
|
|
17
|
+
});
|
|
18
|
+
/** An agent's deal, by its own ref (`deal:12`) as orders are; only the owner decides it. */
|
|
19
|
+
export const dealKind = (store) => ({
|
|
20
|
+
kind: "deal",
|
|
21
|
+
prefix: "deal",
|
|
22
|
+
list: async (filter) => {
|
|
23
|
+
const status = filter.status ?? "proposed";
|
|
24
|
+
const deals = await store.deals.list({ ...pushed(filter), ...(status === "all" ? {} : { review: status }) });
|
|
25
|
+
return kept(deals.map(rowOf), filter);
|
|
26
|
+
},
|
|
27
|
+
get: async (id) => rowOf(await store.deals.get(id)),
|
|
28
|
+
decide: async (id, { confirm, by, reason }) => {
|
|
29
|
+
const deal = confirm ? await store.deals.confirm(id, by, reason) : await store.deals.reject(id, by, reason);
|
|
30
|
+
return { id, kind: "deal", status: confirm ? "confirmed" : "rejected", made: confirm ? [deal.ref] : [] };
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { mayDecide } from "../../store/decisions.js";
|
|
3
3
|
import { actionKind } from "./kinds/action.js";
|
|
4
|
+
import { dealKind } from "./kinds/deals.js";
|
|
4
5
|
import { factKind } from "./kinds/fact.js";
|
|
5
6
|
import { invoiceKind, paymentKind } from "./kinds/finance.js";
|
|
6
7
|
import { findingsKind } from "./kinds/findings.js";
|
|
@@ -135,6 +136,7 @@ export const proposalRegistry = (store) => {
|
|
|
135
136
|
invoiceKind(store),
|
|
136
137
|
paymentKind(store),
|
|
137
138
|
orderKind(store),
|
|
139
|
+
dealKind(store),
|
|
138
140
|
organizationKind(store),
|
|
139
141
|
memoryKind(store),
|
|
140
142
|
findingsKind(store),
|
package/dist/store/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export type { BotUpdate, BotUpdateStore } from "./sqlite/bot-updates.js";
|
|
|
34
34
|
export type { CatalogActor, CatalogEntry, CatalogInput, CatalogQuery, CatalogStore } from "./sqlite/catalog.js";
|
|
35
35
|
export { CATALOG_QUERY } from "./sqlite/catalog.js";
|
|
36
36
|
export type { ChatMetadata } from "./sqlite/chats.js";
|
|
37
|
+
export type { Deal, DealFilter, DealInput, DealPerson, DealsStore, Pipeline, PipelineStage, } from "./sqlite/deals.js";
|
|
37
38
|
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";
|
|
38
39
|
export { EVENT_FIELDS, type EventChunkToEmbed, type EventHit, type EventQuery, type EventSearch, type NearestEvent, } from "./sqlite/event-search.js";
|
|
39
40
|
export type { EvidenceSource } from "./sqlite/evidence-sources.js";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type DealRole, type DealStatus } from "../../domain/deals.js";
|
|
2
|
+
import { type FinanceReview } from "../../domain/finance.js";
|
|
3
|
+
import { type Decider } from "../decisions.js";
|
|
4
|
+
import { type ProposedByFilter } from "./actors.js";
|
|
5
|
+
import { type Party, type Reviewed, type Written } from "./finance.js";
|
|
6
|
+
import { type Author } from "./memories.js";
|
|
7
|
+
import type { StoreContext } from "./open.js";
|
|
8
|
+
export interface PipelineStage {
|
|
9
|
+
name: string;
|
|
10
|
+
position: number;
|
|
11
|
+
/** Open deals standing in it, the owner's and agents' not rejected. */
|
|
12
|
+
open: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Pipeline {
|
|
15
|
+
name: string;
|
|
16
|
+
stages: PipelineStage[];
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DealPerson extends Party {
|
|
20
|
+
role: DealRole;
|
|
21
|
+
}
|
|
22
|
+
export interface Deal extends Reviewed {
|
|
23
|
+
id: string;
|
|
24
|
+
ref: string;
|
|
25
|
+
title: string;
|
|
26
|
+
/** One line with stage, amount and status, as a list or the review inbox prints it. */
|
|
27
|
+
summary: string;
|
|
28
|
+
pipeline: string;
|
|
29
|
+
stage: string;
|
|
30
|
+
status: DealStatus;
|
|
31
|
+
organization: Party | null;
|
|
32
|
+
/** Both `null` when no amount is expected yet. */
|
|
33
|
+
currency: string | null;
|
|
34
|
+
amount: string | null;
|
|
35
|
+
/** `YYYY-MM-DD`: the day it is expected to close. */
|
|
36
|
+
closeDate: string | null;
|
|
37
|
+
/** `YYYY-MM-DD`: the day it was won or lost. */
|
|
38
|
+
closedDate: string | null;
|
|
39
|
+
/** Why it was won or lost, as the owner said when closing it. */
|
|
40
|
+
closedReason: string | null;
|
|
41
|
+
people: DealPerson[];
|
|
42
|
+
}
|
|
43
|
+
export interface DealInput extends Written {
|
|
44
|
+
title: string;
|
|
45
|
+
/** A stage's name; `pipeline` names its pipeline when more than one has a stage of that name. */
|
|
46
|
+
stage: string;
|
|
47
|
+
pipeline?: string;
|
|
48
|
+
organization?: string;
|
|
49
|
+
/** A decimal string in `currency`; give both or neither. */
|
|
50
|
+
amount?: string;
|
|
51
|
+
currency?: string;
|
|
52
|
+
closeDate?: string;
|
|
53
|
+
people?: {
|
|
54
|
+
person: string;
|
|
55
|
+
role: DealRole;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
58
|
+
export interface DealFilter {
|
|
59
|
+
status?: DealStatus;
|
|
60
|
+
/** A stage's or pipeline's name, in any letter case. */
|
|
61
|
+
stage?: string;
|
|
62
|
+
pipeline?: string;
|
|
63
|
+
project?: string;
|
|
64
|
+
organization?: string;
|
|
65
|
+
review?: FinanceReview;
|
|
66
|
+
proposedBy?: ProposedByFilter;
|
|
67
|
+
/** 1–500, 100 by default; newest written first. */
|
|
68
|
+
limit?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The owner's sales pipelines and the deals in them. The owner's deal is confirmed at once; an agent's waits as
|
|
72
|
+
* proposed for him, and only he decides it. Only the owner makes a pipeline, moves a deal or closes it.
|
|
73
|
+
*/
|
|
74
|
+
export interface DealsStore {
|
|
75
|
+
addPipeline(input: {
|
|
76
|
+
name: string;
|
|
77
|
+
stages: string[];
|
|
78
|
+
by: Author;
|
|
79
|
+
}): Promise<Pipeline>;
|
|
80
|
+
pipelines(): Promise<Pipeline[]>;
|
|
81
|
+
add(input: DealInput): Promise<Deal>;
|
|
82
|
+
get(reference: string): Promise<Deal>;
|
|
83
|
+
list(filter?: DealFilter): Promise<Deal[]>;
|
|
84
|
+
/** To another stage of the deal's own pipeline. */
|
|
85
|
+
move(reference: string, input: {
|
|
86
|
+
stage: string;
|
|
87
|
+
by: Author;
|
|
88
|
+
}): Promise<Deal>;
|
|
89
|
+
/** `date` is the day it closed, today when left out. */
|
|
90
|
+
close(reference: string, input: {
|
|
91
|
+
status: Exclude<DealStatus, "open">;
|
|
92
|
+
date?: string;
|
|
93
|
+
reason?: string;
|
|
94
|
+
by: Author;
|
|
95
|
+
}): Promise<Deal>;
|
|
96
|
+
confirm(reference: string, by: Decider, reason?: string): Promise<Deal>;
|
|
97
|
+
reject(reference: string, by: Decider, reason?: string): Promise<Deal>;
|
|
98
|
+
}
|
|
99
|
+
type DealOperations = {
|
|
100
|
+
[K in keyof DealsStore]: DealsStore[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => R : never;
|
|
101
|
+
};
|
|
102
|
+
export declare const dealOperationsOver: (context: StoreContext) => DealOperations;
|
|
103
|
+
export declare const dealsStoreOver: (context: StoreContext) => DealsStore;
|
|
104
|
+
export {};
|