@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
package/dist/calendar/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type { CalendarAccessRole, CalendarInput, EntryAttachment, EntryAttachmen
|
|
|
2
2
|
export { expandSeries, localMoment, unexpandable } from "./expand.js";
|
|
3
3
|
export { type CalendarFeeds, FEED_LIMITS, FEED_PREFIX, type FeedLimits, type FeedRecord, type FeedRegistry, type FeedSyncStats, type FeedsSyncReport, feedAddress, fetchFeed, icsFeeds, isFeedCalendar, readFeed, syncWithFeeds, } from "./feeds.js";
|
|
4
4
|
export { type IcsEvent, type IcsOverride, type IcsRead, type IcsSkip, readIcs, writeIcs } from "./ics.js";
|
|
5
|
-
export { accountsMeta } from "./reads.js";
|
|
5
|
+
export { accountsMeta, EVENT_TYPES, EVENTS_QUERY, EVENTS_QUERY_NOTE, eventAnswer, eventOf, eventsAnswer, eventsFilter, type ReadAccount, sourceAccounts, } from "./reads.js";
|
|
6
6
|
export { repeatRule } from "./recurrence.js";
|
|
7
7
|
export type { BusyTimes, CalendarExpander, CalendarSource, CalendarSourceTraits, ChangePage, ChangeResult, FreeBusyRequest, SearchPage, SyncWindow, } from "./source.js";
|
|
8
8
|
export { type CalendarCursor, type CalendarSyncOptions, type CalendarSyncReport, type CalendarSyncResult, calendarStatus, calendarSyncWindow, type PendingRound, parseCalendarCursor, syncCalendars, } from "./sync.js";
|
package/dist/calendar/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { expandSeries, localMoment, unexpandable } from "./expand.js";
|
|
2
2
|
export { FEED_LIMITS, FEED_PREFIX, feedAddress, fetchFeed, icsFeeds, isFeedCalendar, readFeed, syncWithFeeds, } from "./feeds.js";
|
|
3
3
|
export { readIcs, writeIcs } from "./ics.js";
|
|
4
|
-
export { accountsMeta } from "./reads.js";
|
|
4
|
+
export { accountsMeta, EVENT_TYPES, EVENTS_QUERY, EVENTS_QUERY_NOTE, eventAnswer, eventOf, eventsAnswer, eventsFilter, sourceAccounts, } from "./reads.js";
|
|
5
5
|
export { repeatRule } from "./recurrence.js";
|
|
6
6
|
export { calendarStatus, calendarSyncWindow, parseCalendarCursor, syncCalendars, } from "./sync.js";
|
|
7
7
|
export { CALENDAR_WRITE_DEFAULTS, CALENDAR_WRITE_KEYS, calendarConflict, EVENTS_DELETE_SERIES_KEY, EVENTS_NOTIFY_KEY, EVENTS_REMIND_HOOK_KEY, } from "./writer.js";
|
|
@@ -10,13 +10,13 @@ export declare const calendarTools: ({
|
|
|
10
10
|
inputSchema: {
|
|
11
11
|
type: string;
|
|
12
12
|
properties: {
|
|
13
|
+
limit?: undefined;
|
|
13
14
|
account_id: {
|
|
14
15
|
type: string;
|
|
15
16
|
minimum: number;
|
|
16
17
|
};
|
|
17
18
|
query?: undefined;
|
|
18
19
|
timezone?: undefined;
|
|
19
|
-
limit?: undefined;
|
|
20
20
|
page?: undefined;
|
|
21
21
|
event?: undefined;
|
|
22
22
|
} | {
|
|
@@ -45,9 +45,9 @@ export declare const calendarTools: ({
|
|
|
45
45
|
};
|
|
46
46
|
event?: undefined;
|
|
47
47
|
} | {
|
|
48
|
+
limit?: undefined;
|
|
48
49
|
query?: undefined;
|
|
49
50
|
timezone?: undefined;
|
|
50
|
-
limit?: undefined;
|
|
51
51
|
page?: undefined;
|
|
52
52
|
event: {
|
|
53
53
|
type: string;
|
|
@@ -58,9 +58,9 @@ export declare const calendarTools: ({
|
|
|
58
58
|
minimum: number;
|
|
59
59
|
};
|
|
60
60
|
} | {
|
|
61
|
+
limit?: undefined;
|
|
61
62
|
query?: undefined;
|
|
62
63
|
timezone?: undefined;
|
|
63
|
-
limit?: undefined;
|
|
64
64
|
page?: undefined;
|
|
65
65
|
event?: undefined;
|
|
66
66
|
account_id?: undefined;
|
|
@@ -80,13 +80,13 @@ export declare const calendarTools: ({
|
|
|
80
80
|
inputSchema: {
|
|
81
81
|
type: string;
|
|
82
82
|
properties: {
|
|
83
|
+
limit?: undefined;
|
|
83
84
|
account_id: {
|
|
84
85
|
type: string;
|
|
85
86
|
minimum: number;
|
|
86
87
|
};
|
|
87
88
|
query?: undefined;
|
|
88
89
|
timezone?: undefined;
|
|
89
|
-
limit?: undefined;
|
|
90
90
|
page?: undefined;
|
|
91
91
|
event?: undefined;
|
|
92
92
|
} | {
|
|
@@ -115,9 +115,9 @@ export declare const calendarTools: ({
|
|
|
115
115
|
};
|
|
116
116
|
event?: undefined;
|
|
117
117
|
} | {
|
|
118
|
+
limit?: undefined;
|
|
118
119
|
query?: undefined;
|
|
119
120
|
timezone?: undefined;
|
|
120
|
-
limit?: undefined;
|
|
121
121
|
page?: undefined;
|
|
122
122
|
event: {
|
|
123
123
|
type: string;
|
|
@@ -128,9 +128,9 @@ export declare const calendarTools: ({
|
|
|
128
128
|
minimum: number;
|
|
129
129
|
};
|
|
130
130
|
} | {
|
|
131
|
+
limit?: undefined;
|
|
131
132
|
query?: undefined;
|
|
132
133
|
timezone?: undefined;
|
|
133
|
-
limit?: undefined;
|
|
134
134
|
page?: undefined;
|
|
135
135
|
event?: undefined;
|
|
136
136
|
account_id?: undefined;
|
|
@@ -150,13 +150,13 @@ export declare const calendarTools: ({
|
|
|
150
150
|
inputSchema: {
|
|
151
151
|
type: string;
|
|
152
152
|
properties: {
|
|
153
|
+
limit?: undefined;
|
|
153
154
|
account_id: {
|
|
154
155
|
type: string;
|
|
155
156
|
minimum: number;
|
|
156
157
|
};
|
|
157
158
|
query?: undefined;
|
|
158
159
|
timezone?: undefined;
|
|
159
|
-
limit?: undefined;
|
|
160
160
|
page?: undefined;
|
|
161
161
|
event?: undefined;
|
|
162
162
|
} | {
|
|
@@ -185,9 +185,9 @@ export declare const calendarTools: ({
|
|
|
185
185
|
};
|
|
186
186
|
event?: undefined;
|
|
187
187
|
} | {
|
|
188
|
+
limit?: undefined;
|
|
188
189
|
query?: undefined;
|
|
189
190
|
timezone?: undefined;
|
|
190
|
-
limit?: undefined;
|
|
191
191
|
page?: undefined;
|
|
192
192
|
event: {
|
|
193
193
|
type: string;
|
|
@@ -198,9 +198,9 @@ export declare const calendarTools: ({
|
|
|
198
198
|
minimum: number;
|
|
199
199
|
};
|
|
200
200
|
} | {
|
|
201
|
+
limit?: undefined;
|
|
201
202
|
query?: undefined;
|
|
202
203
|
timezone?: undefined;
|
|
203
|
-
limit?: undefined;
|
|
204
204
|
page?: undefined;
|
|
205
205
|
event?: undefined;
|
|
206
206
|
account_id?: undefined;
|
|
@@ -220,13 +220,13 @@ export declare const calendarTools: ({
|
|
|
220
220
|
inputSchema: {
|
|
221
221
|
type: string;
|
|
222
222
|
properties: {
|
|
223
|
+
limit?: undefined;
|
|
223
224
|
account_id: {
|
|
224
225
|
type: string;
|
|
225
226
|
minimum: number;
|
|
226
227
|
};
|
|
227
228
|
query?: undefined;
|
|
228
229
|
timezone?: undefined;
|
|
229
|
-
limit?: undefined;
|
|
230
230
|
page?: undefined;
|
|
231
231
|
event?: undefined;
|
|
232
232
|
} | {
|
|
@@ -255,9 +255,9 @@ export declare const calendarTools: ({
|
|
|
255
255
|
};
|
|
256
256
|
event?: undefined;
|
|
257
257
|
} | {
|
|
258
|
+
limit?: undefined;
|
|
258
259
|
query?: undefined;
|
|
259
260
|
timezone?: undefined;
|
|
260
|
-
limit?: undefined;
|
|
261
261
|
page?: undefined;
|
|
262
262
|
event: {
|
|
263
263
|
type: string;
|
|
@@ -268,9 +268,9 @@ export declare const calendarTools: ({
|
|
|
268
268
|
minimum: number;
|
|
269
269
|
};
|
|
270
270
|
} | {
|
|
271
|
+
limit?: undefined;
|
|
271
272
|
query?: undefined;
|
|
272
273
|
timezone?: undefined;
|
|
273
|
-
limit?: undefined;
|
|
274
274
|
page?: undefined;
|
|
275
275
|
event?: undefined;
|
|
276
276
|
account_id?: undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { AppIdentity } from "../ports/app.js";
|
|
3
|
+
import type { MessageStore } from "../store/store.js";
|
|
4
|
+
import type { AccountKey } from "../store/types.js";
|
|
5
|
+
import { type Body } from "./envelope.js";
|
|
6
|
+
export interface BaseStagesCommandOptions {
|
|
7
|
+
/** The run's environment, read for an agent's markers: an agent suggests mappings, the owner confirms and edits. */
|
|
8
|
+
env: () => NodeJS.ProcessEnv;
|
|
9
|
+
/** The store for one command; the command closes it once its answer is built. */
|
|
10
|
+
open: (command: Command) => Promise<MessageStore>;
|
|
11
|
+
output: (answer: Body, command: Command) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The CRM accounts the run may read and change, such as a group lock's; `undefined` for all. The owner's own
|
|
14
|
+
* pipelines are always in.
|
|
15
|
+
*/
|
|
16
|
+
accounts?: (store: MessageStore, command: Command) => Promise<readonly AccountKey[] | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `stages …`: the owner's base stages of deals and of leads, and the stages of every other pipeline mapped onto them. memo mounts it; a CRM
|
|
20
|
+
* CLI moves a card to a base stage with `deals move <ref> stage:<id>`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const baseStagesCommand: (app: AppIdentity, options: BaseStagesCommandOptions) => Command;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { Argument, Command, InvalidArgumentError, Option } from "commander";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import { DEAL_KINDS, STAGE_OUTCOMES } from "../domain/deals.js";
|
|
6
|
+
import { count, reference, text, untrusted } from "../entities/fields.js";
|
|
7
|
+
import { agentOf } from "../runs/run-context.js";
|
|
8
|
+
import { answerEntity } from "./answer-entity.js";
|
|
9
|
+
import { environmentOf } from "./context.js";
|
|
10
|
+
import { LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
11
|
+
import { itemOf, listOf, snakeKeys } from "./envelope.js";
|
|
12
|
+
import { queryTerms, termField, withQuery } from "./list-query.js";
|
|
13
|
+
const outcome = v.picklist(STAGE_OUTCOMES);
|
|
14
|
+
const kind = v.picklist(DEAL_KINDS);
|
|
15
|
+
const named = v.strictObject({ ref: reference, name: text });
|
|
16
|
+
const baseSet = v.strictObject({
|
|
17
|
+
kind,
|
|
18
|
+
/** `null`, with each stage's `ref`, only when a read-only store is read before the set's first use made it. */
|
|
19
|
+
pipeline: v.nullable(reference),
|
|
20
|
+
stages: v.array(v.strictObject({ ref: v.nullable(reference), name: text, position: count, outcome, open: count, mapped: count })),
|
|
21
|
+
unsorted: v.strictObject({ open: count, stages: count }),
|
|
22
|
+
});
|
|
23
|
+
const stageMapping = v.strictObject({
|
|
24
|
+
...named.entries,
|
|
25
|
+
position: count,
|
|
26
|
+
outcome,
|
|
27
|
+
external_id: v.nullable(text),
|
|
28
|
+
kind,
|
|
29
|
+
pipeline: reference,
|
|
30
|
+
pipeline_name: text,
|
|
31
|
+
account: v.nullable(v.strictObject({ provider: text, account: text })),
|
|
32
|
+
base_stage: v.nullable(named),
|
|
33
|
+
confirmed: v.boolean(),
|
|
34
|
+
open: count,
|
|
35
|
+
untrusted,
|
|
36
|
+
});
|
|
37
|
+
/** A CRM's users named its stages and pipelines; the base set's names are the owner's. */
|
|
38
|
+
const MAPPING_UNTRUSTED = ["name", "pipeline_name"];
|
|
39
|
+
/** What `stages list` narrows by. */
|
|
40
|
+
const MAPPING_QUERY = {
|
|
41
|
+
entity: "stage_mapping",
|
|
42
|
+
backend: "native",
|
|
43
|
+
fields: [
|
|
44
|
+
termField("kind", "enum", "kind:deal", { values: DEAL_KINDS }),
|
|
45
|
+
termField("pipeline", "kw", "pipeline:Sales", { relation: "pipeline:<id>, or a name only one pipeline has" }),
|
|
46
|
+
termField("confirmed", "bool", "confirmed:false"),
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
const position = (value) => {
|
|
50
|
+
if (!/^[1-9]\d*$/.test(value))
|
|
51
|
+
throw new InvalidArgumentError("expected a position from 1");
|
|
52
|
+
return Number(value);
|
|
53
|
+
};
|
|
54
|
+
const kindArgument = () => new Argument("<kind>", "deal or lead: which base set").choices(DEAL_KINDS);
|
|
55
|
+
/**
|
|
56
|
+
* `stages …`: the owner's base stages of deals and of leads, and the stages of every other pipeline mapped onto them. memo mounts it; a CRM
|
|
57
|
+
* CLI moves a card to a base stage with `deals move <ref> stage:<id>`.
|
|
58
|
+
*/
|
|
59
|
+
export const baseStagesCommand = (app, options) => {
|
|
60
|
+
const isAgent = (command) => Boolean(environmentOf(command).agent || agentOf(options.env()));
|
|
61
|
+
// A guard against a change by mistake, not a boundary, as the owner-only store settings are.
|
|
62
|
+
const ownerOnly = (command, what) => {
|
|
63
|
+
if (isAgent(command))
|
|
64
|
+
throw new CliError("permission_error", `${what} is the owner's to do, in a terminal: an agent's run is stopped from changing it by mistake`, { reason: "stage.owner-only" });
|
|
65
|
+
};
|
|
66
|
+
const run = async (command, work) => {
|
|
67
|
+
const store = await options.open(command);
|
|
68
|
+
let body;
|
|
69
|
+
try {
|
|
70
|
+
const accounts = await options.accounts?.(store, command);
|
|
71
|
+
body = await work(store, accounts === undefined ? {} : { accounts });
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await store.close();
|
|
75
|
+
}
|
|
76
|
+
options.output(body, command);
|
|
77
|
+
};
|
|
78
|
+
const stages = annotate(new Command("stages"), { effects: LOCAL_READ })
|
|
79
|
+
.description("the owner's base stages of deals and of leads, the columns of a board across every pipeline and CRM, and " +
|
|
80
|
+
"how each other pipeline's stage maps onto them")
|
|
81
|
+
.summary("base stages and the stages mapped onto them");
|
|
82
|
+
const leaf = (name, effects, summary, ...examples) => annotate(stages.command(name), {
|
|
83
|
+
effects,
|
|
84
|
+
examples: examples.map((line) => `${app.command} stages ${line}`),
|
|
85
|
+
}).summary(summary);
|
|
86
|
+
const setAnswer = (set) => itemOf(snakeKeys(set));
|
|
87
|
+
const setCommand = (name, summary, ...examples) => answerEntity(leaf(name, LOCAL_WRITE, summary, ...examples), "base_stage_set", baseSet)
|
|
88
|
+
.addArgument(kindArgument())
|
|
89
|
+
.hook("preAction", (_root, command) => ownerOnly(command, `stages ${name}`));
|
|
90
|
+
const mappingRow = (row) => ({ ...snakeKeys(row), untrusted: MAPPING_UNTRUSTED });
|
|
91
|
+
const baseStage = "the base stage, by its stage:<id> or its name";
|
|
92
|
+
answerEntity(leaf("show", LOCAL_READ, "a base set's columns with what each holds", "show deal", "show lead --json"), "base_stage_set", baseSet)
|
|
93
|
+
.description("the base set in order, with the open rows and mapped stages each column holds, and what is unsorted (unmapped " +
|
|
94
|
+
"or only suggested); the first use takes the owner's only own pipeline of the kind, or makes the default set in " +
|
|
95
|
+
"the owner's language; a read-only store shows that set without making it")
|
|
96
|
+
.addArgument(kindArgument())
|
|
97
|
+
.action(async (chosen, _opts, command) => {
|
|
98
|
+
await run(command, async (store, scope) => setAnswer(await store.baseStages.show(chosen, scope)));
|
|
99
|
+
});
|
|
100
|
+
setCommand("create", "add a stage to a base set", 'create deal "Demo"', 'create lead "Spam" lost')
|
|
101
|
+
.description("add a stage to the base set: an open one goes before the first won or lost stage, a won or lost one last; " +
|
|
102
|
+
"move puts it elsewhere")
|
|
103
|
+
.argument("<name>", "the stage's name, once in its set")
|
|
104
|
+
.addArgument(new Argument("[outcome]", "open, won or lost; open by default").choices(STAGE_OUTCOMES))
|
|
105
|
+
.action(async (chosen, name, given, _opts, command) => {
|
|
106
|
+
await run(command, async (store) => setAnswer(await store.baseStages.add(chosen, { name, ...(given === undefined ? {} : { outcome: given }) })));
|
|
107
|
+
});
|
|
108
|
+
setCommand("rename", "rename a base stage", 'rename deal Proposal "Quote sent"')
|
|
109
|
+
.description("rename a base stage; what maps to it stays mapped")
|
|
110
|
+
.argument("<stage>", baseStage)
|
|
111
|
+
.argument("<name>", "its new name")
|
|
112
|
+
.action(async (chosen, stage, name, _opts, command) => {
|
|
113
|
+
await run(command, async (store) => setAnswer(await store.baseStages.rename(chosen, stage, name)));
|
|
114
|
+
});
|
|
115
|
+
setCommand("move", "put a base stage at another place in its set", "move deal Negotiation 2")
|
|
116
|
+
.description("put a base stage at another place in its set; unconfirmed suggestions follow the new order")
|
|
117
|
+
.argument("<stage>", baseStage)
|
|
118
|
+
.argument("<position>", "its new place, from 1", position)
|
|
119
|
+
.action(async (chosen, stage, at, _opts, command) => {
|
|
120
|
+
await run(command, async (store) => setAnswer(await store.baseStages.move(chosen, stage, at)));
|
|
121
|
+
});
|
|
122
|
+
setCommand("remove", "take a stage out of a base set", "remove deal Negotiation")
|
|
123
|
+
.description("take a stage out of the base set: refused for the last of its outcome and for one the owner's own rows stood " +
|
|
124
|
+
"in; what was mapped to it waits for a new confirm")
|
|
125
|
+
.argument("<stage>", baseStage)
|
|
126
|
+
.action(async (chosen, stage, _opts, command) => {
|
|
127
|
+
await run(command, async (store) => setAnswer(await store.baseStages.remove(chosen, stage)));
|
|
128
|
+
});
|
|
129
|
+
withQuery(answerEntity(leaf("list", LOCAL_READ, "every mapped stage with its base stage, confirmed or suggested", "list confirmed:false", "list kind:deal pipeline:pipeline:3 --json"), "stage_mapping", stageMapping).description("every stage outside the base sets in scope, a CRM's or an own pipeline's, with the base stage it maps to, and whether the owner confirmed that or it is the " +
|
|
130
|
+
"store's suggestion"), MAPPING_QUERY).action(async (words, _opts, command) => {
|
|
131
|
+
const terms = queryTerms(words, MAPPING_QUERY, "stages list");
|
|
132
|
+
await run(command, async (store, scope) => {
|
|
133
|
+
const rows = await store.baseStages.mappings({
|
|
134
|
+
...scope,
|
|
135
|
+
...(terms.has("kind") ? { kind: terms.get("kind") } : {}),
|
|
136
|
+
...(terms.has("pipeline") ? { pipeline: terms.get("pipeline") } : {}),
|
|
137
|
+
});
|
|
138
|
+
const confirmed = terms.get("confirmed");
|
|
139
|
+
const shown = confirmed === undefined ? rows : rows.filter((row) => row.confirmed === (confirmed === "true"));
|
|
140
|
+
return listOf("stages list", {
|
|
141
|
+
items: shown.map(mappingRow),
|
|
142
|
+
limit: Math.max(1, shown.length),
|
|
143
|
+
page: 1,
|
|
144
|
+
has_more: false,
|
|
145
|
+
...(words.length ? { args: { query: words } } : {}),
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
answerEntity(leaf("set", LOCAL_WRITE, "map one stage onto a base stage, confirmed", "set stage:41 Proposal"), "stage_mapping", stageMapping)
|
|
150
|
+
.description("map one stage of a CRM or own pipeline onto a base stage of its kind, confirmed, so a later sync keeps it; an agent's run records " +
|
|
151
|
+
"it as a suggestion the owner confirms")
|
|
152
|
+
.argument("<stage>", "the stage, by its stage:<id> as stages list shows it")
|
|
153
|
+
.argument("<base-stage>", baseStage)
|
|
154
|
+
.action(async (stage, target, _opts, command) => {
|
|
155
|
+
await run(command, async (store, scope) => itemOf(mappingRow(await store.baseStages.map(stage, target, scope, { confirmed: !isAgent(command) }))));
|
|
156
|
+
});
|
|
157
|
+
answerEntity(leaf("confirm", LOCAL_WRITE, "confirm the suggested mappings of a pipeline, or of all", "confirm --pipeline pipeline:3", "confirm --all"), "stage_mapping_confirm", v.strictObject({ confirmed: count }))
|
|
158
|
+
.description("confirm every suggestion of one pipeline, or of all of them in scope, as it stands")
|
|
159
|
+
.option("--pipeline <pipeline>", "pipeline:<id>, or a name only one pipeline has")
|
|
160
|
+
.option("--all", "every pipeline in scope")
|
|
161
|
+
.addOption(new Option("--kind <kind>", "with --all: only deal or only lead stages").choices(DEAL_KINDS))
|
|
162
|
+
.action(async (opts, command) => {
|
|
163
|
+
ownerOnly(command, "stages confirm");
|
|
164
|
+
if ((opts.pipeline === undefined) === (opts.all !== true))
|
|
165
|
+
throw new CliError("validation_error", "give --pipeline <pipeline> or --all", { reason: "stage.base-field" });
|
|
166
|
+
await run(command, async (store, scope) => {
|
|
167
|
+
const target = opts.pipeline === undefined
|
|
168
|
+
? { all: true, ...(opts.kind === undefined ? {} : { kind: opts.kind }) }
|
|
169
|
+
: { pipeline: opts.pipeline };
|
|
170
|
+
return itemOf({ confirmed: await store.baseStages.confirm(target, scope) });
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return stages;
|
|
174
|
+
};
|
|
@@ -8,6 +8,7 @@ export interface SavedRunSettings {
|
|
|
8
8
|
record?: boolean | undefined;
|
|
9
9
|
keepRunsForDays?: number | undefined;
|
|
10
10
|
keepSuccessfulRunsForDays?: number | undefined;
|
|
11
|
+
keepStoreRunsForDays?: number | undefined;
|
|
11
12
|
runsSizeLimitMb?: number | undefined;
|
|
12
13
|
/** `record_input`: left out, the typed words are kept, secrets hidden. */
|
|
13
14
|
recordInput?: RecordInput | undefined;
|
|
@@ -17,6 +18,7 @@ export interface RunSettings {
|
|
|
17
18
|
keepFailedRuns: boolean;
|
|
18
19
|
keepRunsForDays: number;
|
|
19
20
|
keepSuccessfulRunsForDays: number;
|
|
21
|
+
keepStoreRunsForDays: number;
|
|
20
22
|
runsSizeLimitMb: number;
|
|
21
23
|
}
|
|
22
24
|
/**
|
package/dist/cli/command-runs.js
CHANGED
|
@@ -3,7 +3,7 @@ import { isCliError } from "@wirecat/cli-base";
|
|
|
3
3
|
import { metaOf } from "@wirecat/cli-base/commands";
|
|
4
4
|
import { providerErrorKey } from "../runs/events.js";
|
|
5
5
|
import { startRecording, wasSettled } from "../runs/recording.js";
|
|
6
|
-
import { KEEP_RUNS_FOR_DAYS, KEEP_SUCCESSFUL_RUNS_FOR_DAYS, RUNS_SIZE_LIMIT_MB } from "../runs/run.js";
|
|
6
|
+
import { KEEP_RUNS_FOR_DAYS, KEEP_STORE_RUNS_FOR_DAYS, KEEP_SUCCESSFUL_RUNS_FOR_DAYS, RUNS_SIZE_LIMIT_MB, } from "../runs/run.js";
|
|
7
7
|
import { keepsSuccess, runContextOf } from "../runs/run-context.js";
|
|
8
8
|
import { currentAttempt, runEvent } from "../runs/scope.js";
|
|
9
9
|
import { environmentOf } from "./context.js";
|
|
@@ -19,6 +19,7 @@ export const runSettings = (flag, saved = {}) => {
|
|
|
19
19
|
keepFailedRuns: record || flag !== false,
|
|
20
20
|
keepRunsForDays: saved.keepRunsForDays ?? KEEP_RUNS_FOR_DAYS,
|
|
21
21
|
keepSuccessfulRunsForDays: saved.keepSuccessfulRunsForDays ?? KEEP_SUCCESSFUL_RUNS_FOR_DAYS,
|
|
22
|
+
keepStoreRunsForDays: saved.keepStoreRunsForDays ?? KEEP_STORE_RUNS_FOR_DAYS,
|
|
22
23
|
runsSizeLimitMb: saved.runsSizeLimitMb ?? RUNS_SIZE_LIMIT_MB,
|
|
23
24
|
};
|
|
24
25
|
};
|
|
@@ -69,6 +70,7 @@ const tracker = (options, typed) => {
|
|
|
69
70
|
keepFailed: settings.keepFailedRuns,
|
|
70
71
|
keepDays: settings.keepRunsForDays,
|
|
71
72
|
keepSuccessDays: settings.keepSuccessfulRunsForDays,
|
|
73
|
+
keepStoreDays: settings.keepStoreRunsForDays,
|
|
72
74
|
maxBytes: settings.runsSizeLimitMb * 1024 * 1024,
|
|
73
75
|
trace: false,
|
|
74
76
|
format,
|
|
@@ -14,7 +14,7 @@ import { knownBeside, knownPermissionKeys, unknownPermissionIssues, } from "./pe
|
|
|
14
14
|
import { profileFree } from "./profile.js";
|
|
15
15
|
import { fromFile, NONE_NAMED } from "./settings.js";
|
|
16
16
|
import { nextStep } from "./steps.js";
|
|
17
|
-
import { changeStoreSetting, isStoreSetting, offersStoreSetting, storeSettings, storeSettingsOf, } from "./store-settings.js";
|
|
17
|
+
import { changeStoreSetting, isOwnerOnlyStoreSetting, isStoreSetting, offersStoreSetting, storeSettings, storeSettingsOf, } from "./store-settings.js";
|
|
18
18
|
export const configCommand = (app, config, { permissionKey = config.permissions, ownerOnly = {}, } = {}) => {
|
|
19
19
|
const command = new Command("config").description("the settings in force, and where each one came from");
|
|
20
20
|
// Only a messenger has bots, and with them the personal and bot sections of the file. Elsewhere the options stay
|
|
@@ -91,6 +91,11 @@ export const configCommand = (app, config, { permissionKey = config.permissions,
|
|
|
91
91
|
if (isStoreSetting(setting) && !offersStoreSetting(app, setting))
|
|
92
92
|
throw new CliError("validation_error", `no setting called "${setting}" here — it belongs to the messenger CLIs; one of: ${[...config.allSettings, ...storeSettingsOf(app)].join(", ")}`);
|
|
93
93
|
if (isStoreSetting(setting)) {
|
|
94
|
+
// A guard against a change by mistake, not a boundary: an agent can drop its markers or write the store file.
|
|
95
|
+
if (isOwnerOnlyStoreSetting(setting) && (environmentOf(this).agent || agentOf(env)))
|
|
96
|
+
throw new CliError("permission_error", `${setting} is the owner's to set, in a terminal: an agent's run is stopped from changing it by mistake`, {
|
|
97
|
+
setting,
|
|
98
|
+
});
|
|
94
99
|
if (everyone || personal || bot)
|
|
95
100
|
throw new CliError("validation_error", `${setting} is store-wide — --defaults, --personal and --bot do not apply`);
|
|
96
101
|
const lock = envName(app, "PROFILE_LOCK");
|
package/dist/cli/context.js
CHANGED
|
@@ -131,6 +131,7 @@ export const baseContext = (command, resolveSettings) => {
|
|
|
131
131
|
...(settings.keepSuccessfulRunsForDays === undefined
|
|
132
132
|
? {}
|
|
133
133
|
: { keepSuccessDays: settings.keepSuccessfulRunsForDays }),
|
|
134
|
+
...(settings.keepStoreRunsForDays === undefined ? {} : { keepStoreDays: settings.keepStoreRunsForDays }),
|
|
134
135
|
...(settings.runsSizeLimitMb === undefined ? {} : { maxBytes: settings.runsSizeLimitMb * 1024 * 1024 }),
|
|
135
136
|
processRun: !environment.agent,
|
|
136
137
|
format,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { type SimpleReference } from "../domain/references.js";
|
|
3
|
+
import { type AppIdentity } from "../ports/app.js";
|
|
4
|
+
import { type MessageStore } from "../store/store.js";
|
|
5
|
+
/**
|
|
6
|
+
* Marks a command, and every command under it, as one that keeps to the run's account group: it scopes its reads
|
|
7
|
+
* and writes with `scopeToGroup`. Under `<PREFIX>_GROUP_LOCK` every other command is refused (WC-ACCT-13).
|
|
8
|
+
*/
|
|
9
|
+
export declare const groupAware: <T extends Command>(command: T) => T;
|
|
10
|
+
export declare const isGroupAware: (command: Command) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* What a bare id names: a referenced thing's kind, a proposed action (`action`, as `actions confirm 17` takes it), or
|
|
13
|
+
* a proposal id of the review registry (`proposal`: `17070`, `17080/f1`, `link:17`, `fact:512`).
|
|
14
|
+
*/
|
|
15
|
+
export type RefKind = SimpleReference | "action" | "proposal";
|
|
16
|
+
/**
|
|
17
|
+
* The kind of thing a bare id names, per argument (by its name) or option (by its long flag):
|
|
18
|
+
* `refKinds(show, { organization: "organization", "--note": "note" })`. An argument or a `--<kind>` option named
|
|
19
|
+
* after a kind needs no entry. Under the lock a bare value there is checked as `<kind>:<value>`; a command that
|
|
20
|
+
* declares nothing has any other argument value refused, since what it names is unknown (`1e0`, `+1`, `link:1`).
|
|
21
|
+
* `{}` says no argument takes an id, so free text passes.
|
|
22
|
+
*/
|
|
23
|
+
export declare const refKinds: <T extends Command>(command: T, kinds: Readonly<Record<string, RefKind>>) => T;
|
|
24
|
+
/**
|
|
25
|
+
* Every reference typed into the run: each word of each argument and option value that is a reference, and each bare
|
|
26
|
+
* id in a position whose kind is known, as `<kind>:<id>`. `unknown` holds every other argument value of a command
|
|
27
|
+
* that declares no kinds.
|
|
28
|
+
*/
|
|
29
|
+
export declare const referencesIn: (command: Command) => {
|
|
30
|
+
references: string[];
|
|
31
|
+
unknown: string[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Under `<PREFIX>_GROUP_LOCK`, refuses a command that does not keep to a group, and a reference whose thing belongs
|
|
35
|
+
* only to accounts outside the group. A thing no account brought is the owner's and passes in every group, a note
|
|
36
|
+
* written in memo included; a person passes when one of their identities is in the group.
|
|
37
|
+
*/
|
|
38
|
+
export declare const refuseOutsideGroup: (command: Command, { app, env, store }: {
|
|
39
|
+
app: AppIdentity;
|
|
40
|
+
env: NodeJS.ProcessEnv;
|
|
41
|
+
store?: MessageStore;
|
|
42
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { INTERNAL_NOTES } from "../domain/providers.js";
|
|
3
|
+
import { looksLikeReference, SIMPLE_REFERENCES } from "../domain/references.js";
|
|
4
|
+
import { envName } from "../ports/app.js";
|
|
5
|
+
import { inGroupOf } from "../search/groups.js";
|
|
6
|
+
import { groupLockOf, listContextOf } from "../services/search-kind.js";
|
|
7
|
+
import { openStore } from "../store/store.js";
|
|
8
|
+
import { PROFILE_FREE } from "./profile.js";
|
|
9
|
+
const keepsToGroup = new WeakSet();
|
|
10
|
+
/**
|
|
11
|
+
* Marks a command, and every command under it, as one that keeps to the run's account group: it scopes its reads
|
|
12
|
+
* and writes with `scopeToGroup`. Under `<PREFIX>_GROUP_LOCK` every other command is refused (WC-ACCT-13).
|
|
13
|
+
*/
|
|
14
|
+
export const groupAware = (command) => {
|
|
15
|
+
keepsToGroup.add(command);
|
|
16
|
+
return command;
|
|
17
|
+
};
|
|
18
|
+
export const isGroupAware = (command) => {
|
|
19
|
+
let top;
|
|
20
|
+
for (let at = command; at?.parent; at = at.parent) {
|
|
21
|
+
if (keepsToGroup.has(at))
|
|
22
|
+
return true;
|
|
23
|
+
top = at;
|
|
24
|
+
}
|
|
25
|
+
return top !== undefined && PROFILE_FREE.has(top.name());
|
|
26
|
+
};
|
|
27
|
+
const valuesOf = (value) => typeof value === "string" ? [value] : Array.isArray(value) ? value.flatMap(valuesOf) : [];
|
|
28
|
+
const declared = new WeakMap();
|
|
29
|
+
/**
|
|
30
|
+
* The kind of thing a bare id names, per argument (by its name) or option (by its long flag):
|
|
31
|
+
* `refKinds(show, { organization: "organization", "--note": "note" })`. An argument or a `--<kind>` option named
|
|
32
|
+
* after a kind needs no entry. Under the lock a bare value there is checked as `<kind>:<value>`; a command that
|
|
33
|
+
* declares nothing has any other argument value refused, since what it names is unknown (`1e0`, `+1`, `link:1`).
|
|
34
|
+
* `{}` says no argument takes an id, so free text passes.
|
|
35
|
+
*/
|
|
36
|
+
export const refKinds = (command, kinds) => {
|
|
37
|
+
declared.set(command, kinds);
|
|
38
|
+
return command;
|
|
39
|
+
};
|
|
40
|
+
const isSimpleReference = (name) => SIMPLE_REFERENCES.includes(name);
|
|
41
|
+
const kindAt = (command, name, implicit) => declared.get(command)?.[name] ?? (isSimpleReference(implicit) ? implicit : undefined);
|
|
42
|
+
/**
|
|
43
|
+
* Every reference typed into the run: each word of each argument and option value that is a reference, and each bare
|
|
44
|
+
* id in a position whose kind is known, as `<kind>:<id>`. `unknown` holds every other argument value of a command
|
|
45
|
+
* that declares no kinds.
|
|
46
|
+
*/
|
|
47
|
+
export const referencesIn = (command) => {
|
|
48
|
+
const references = new Set();
|
|
49
|
+
const unknown = [];
|
|
50
|
+
const typed = (value, kind, onBare) => {
|
|
51
|
+
for (const word of value.split(/[\s,]+/).filter(Boolean)) {
|
|
52
|
+
const stored = /^([1-9]\d*)(?:\/[\w-]+)?$/.exec(word)?.[1];
|
|
53
|
+
const proposalKind = kind === "action" || kind === "proposal";
|
|
54
|
+
if (looksLikeReference(word) || (proposalKind && PROPOSAL_REF.test(word)))
|
|
55
|
+
references.add(word);
|
|
56
|
+
else if (proposalKind && stored)
|
|
57
|
+
references.add(`action:${stored}`);
|
|
58
|
+
// A key-document suggestion is a link between the document and its project, so both ends are checked.
|
|
59
|
+
else if (kind === "proposal" && /^key:[1-9]\d*$/.test(word))
|
|
60
|
+
references.add(`link:${word.slice(4)}`);
|
|
61
|
+
// A close suggestion is its task's, which the owner made; the task's evidence is stripped where it is shown.
|
|
62
|
+
else if (kind === "proposal" && word.startsWith("close:"))
|
|
63
|
+
references.add(`task:${word.slice(6)}`);
|
|
64
|
+
else if (kind !== undefined && kind !== "proposal" && !word.includes(":"))
|
|
65
|
+
references.add(`${kind}:${word}`);
|
|
66
|
+
else
|
|
67
|
+
onBare?.();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
command.registeredArguments.forEach((argument, at) => {
|
|
71
|
+
const name = argument.name();
|
|
72
|
+
const kind = kindAt(command, name, name);
|
|
73
|
+
for (const value of valuesOf(command.processedArgs[at] ?? command.args[at]))
|
|
74
|
+
typed(value, kind, () => {
|
|
75
|
+
// A proposal id of no kind the lock knows cannot be checked, so it is refused even where kinds are declared.
|
|
76
|
+
const named = `<${name}> ${value}`;
|
|
77
|
+
if ((!declared.has(command) || kind === "proposal") && !unknown.includes(named))
|
|
78
|
+
unknown.push(named);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
for (const option of command.options) {
|
|
82
|
+
const long = option.long ?? "";
|
|
83
|
+
for (const value of valuesOf(command.getOptionValue(option.attributeName())))
|
|
84
|
+
typed(value, kindAt(command, long, long.replace(/^--/, "")));
|
|
85
|
+
}
|
|
86
|
+
return { references: [...references], unknown };
|
|
87
|
+
};
|
|
88
|
+
const PROPOSAL_REF = /^(action|link):[1-9]\d*$/;
|
|
89
|
+
const pathOf = (command) => {
|
|
90
|
+
const words = [];
|
|
91
|
+
for (let at = command; at?.parent; at = at.parent)
|
|
92
|
+
words.unshift(at.name());
|
|
93
|
+
return words.join(" ");
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Under `<PREFIX>_GROUP_LOCK`, refuses a command that does not keep to a group, and a reference whose thing belongs
|
|
97
|
+
* only to accounts outside the group. A thing no account brought is the owner's and passes in every group, a note
|
|
98
|
+
* written in memo included; a person passes when one of their identities is in the group.
|
|
99
|
+
*/
|
|
100
|
+
export const refuseOutsideGroup = async (command, { app, env, store }) => {
|
|
101
|
+
const lock = groupLockOf(app, env);
|
|
102
|
+
if (lock === undefined)
|
|
103
|
+
return;
|
|
104
|
+
const locked = `this process is locked to group ${lock} (${envName(app, "GROUP_LOCK")})`;
|
|
105
|
+
if (!isGroupAware(command))
|
|
106
|
+
throw new CliError("permission_error", `${locked} — \`${app.command} ${pathOf(command)}\` does not keep to a group, so it does not run`, { group: lock });
|
|
107
|
+
const { references, unknown } = referencesIn(command);
|
|
108
|
+
if (unknown.length)
|
|
109
|
+
throw new CliError("permission_error", `${locked} — \`${app.command} ${pathOf(command)}\` takes ${unknown.join(", ")} as an id of a kind it does not ` +
|
|
110
|
+
"declare, so it cannot be checked against the group", { group: lock });
|
|
111
|
+
if (references.length === 0)
|
|
112
|
+
return;
|
|
113
|
+
const opened = store ?? (await openStore({ env, command: app.command, version: app.version }));
|
|
114
|
+
try {
|
|
115
|
+
const context = await listContextOf(opened, { provider: "notes", account: INTERNAL_NOTES }, app, undefined, env);
|
|
116
|
+
const inGroup = inGroupOf(context, lock);
|
|
117
|
+
for (const reference of references) {
|
|
118
|
+
const ends = await opened.refs.ends(reference);
|
|
119
|
+
if (ends?.some((end) => end.length > 0 && !end.some(inGroup)))
|
|
120
|
+
throw new CliError("permission_error", `${locked} — ${reference} belongs to an account outside it`, {
|
|
121
|
+
group: lock,
|
|
122
|
+
reference,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
finally {
|
|
127
|
+
if (!store)
|
|
128
|
+
await opened.close();
|
|
129
|
+
}
|
|
130
|
+
};
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { AI_ENTRIES, AI_SETTING_KEYS, type AISettings, resolveAISettings } from "../analysis/settings.js";
|
|
2
2
|
export { AGENT_INPUT_MAX_CHARS, type AgentCli, type AgentInput, readSchedule, SCHEDULE_DEFAULTS, scheduleFile, spentToday, } from "../background/schedules.js";
|
|
3
3
|
export { parseDuration } from "../domain/duration.js";
|
|
4
|
-
export { openOf, PROFILE_PLACEHOLDER, type ProfilesFor, type RefOpen, type RefSummary, refLabel, } from "../domain/ref-summaries.js";
|
|
4
|
+
export { openOf, PROFILE_PLACEHOLDER, type ProfilesFor, profilesOn, type RefOpen, type RefSummary, refLabel, storedProfilesFor, type WritesWith, writesWithOf, } from "../domain/ref-summaries.js";
|
|
5
|
+
/** The shared entities `person_context`, `organization_context`, `deal_context` and `deal_context.brief`. */
|
|
6
|
+
export { dealBrief as dealBriefSchema, dealContext as dealContextSchema, organizationContext as organizationContextSchema, personContext as personContextSchema, } from "../entities/business-context.js";
|
|
5
7
|
export { botTemplate } from "../entities/list-results.js";
|
|
6
8
|
export { syncProgress } from "../entities/store-records.js";
|
|
7
9
|
export { isCliFailure, isCommanderFailure, storeDamaged } from "../errors/failures.js";
|
|
@@ -49,6 +51,7 @@ export { answerEntity } from "./answer-entity.js";
|
|
|
49
51
|
export { type AppDoctorOptions, appDoctorReport } from "./app-doctor-command.js";
|
|
50
52
|
export type { AppMcpOptions } from "./app-mcp-command.js";
|
|
51
53
|
export { actorOf } from "./author.js";
|
|
54
|
+
export { type BaseStagesCommandOptions, baseStagesCommand } from "./base-stages-command.js";
|
|
52
55
|
export type { ApiCommandInput, ApiCommands } from "./bot/api.js";
|
|
53
56
|
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
54
57
|
export { prepareRpcApiBody, type RpcApiBody } from "./bot/api-rpc.js";
|
|
@@ -81,6 +84,7 @@ export { type AnswerOutput, answerSchema, type Body, type ItemBody, isBody, item
|
|
|
81
84
|
export { withAbort } from "./execution.js";
|
|
82
85
|
export { parseEvidenceFindingsJson, parseMailFindingsJson, parseMeetingFindingsJson, readMailFindingsJson, } from "./findings-input.js";
|
|
83
86
|
export { askSetupQuestions, asksAtStart, type FirstRun, type FirstRunIo, setupAtStart, systemLanguage, } from "./first-run.js";
|
|
87
|
+
export { groupAware, isGroupAware, type RefKind, referencesIn, refKinds, refuseOutsideGroup } from "./group-lock.js";
|
|
84
88
|
export { checkGuide, checkStep, type GuideOptions, type GuideReference, type GuideStep, loadScenarios, MEMO_SCENARIOS, type Scenario, shellProblems, } from "./guide.js";
|
|
85
89
|
export { type CommandHelp, commandHelp, commandHelpMarkdown, commandHelpText, exampleReport, type NextChoice, nextUsually, } from "./help/command-help.js";
|
|
86
90
|
export { commandsText } from "./help/commands-text.js";
|
|
@@ -122,7 +126,7 @@ export { MODEL_CATALOGUE_QUERY, type ModelCatalogueOptions } from "./model-catal
|
|
|
122
126
|
export { writeNewFile } from "./new-file.js";
|
|
123
127
|
export { positiveCount, window, withPaging } from "./paging.js";
|
|
124
128
|
export { type CommandPermissions, type ConditionalKey, commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, type PermissionKeyOf, type PermissionKeySource, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
|
|
125
|
-
export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, takesProfile, usableProfileName, } from "./profile.js";
|
|
129
|
+
export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
|
|
126
130
|
export { ProfileTokenStore, type ProfileTokenStoreOptions, type TokenStorage } from "./profile-token.js";
|
|
127
131
|
export { createProgram, type ProgramDefinition, type ProgramOptions, type RunOptions, run } from "./program.js";
|
|
128
132
|
export { type ProjectTextHints, projectAnswerParts, projectCutoffTime, projectEvidenceText, projectWindowOf, withSyncCommands, } from "./project-evidence.js";
|
|
@@ -130,6 +134,7 @@ export { type ProjectStatusHints, type ProjectStatusItem, projectStatusAnswer, p
|
|
|
130
134
|
export { STATUS_ROWS, STATUS_SIGNAL_ROWS } from "./project-status-rows.js";
|
|
131
135
|
export { fieldsOf, projectFields } from "./result-fields.js";
|
|
132
136
|
export { backfillScheduleRun, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, scheduleLimitsOf, } from "./schedule/schedule-command.js";
|
|
137
|
+
export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
|
|
133
138
|
export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
134
139
|
export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
|
|
135
140
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|