@wirecat/cli-core 0.618.0 → 0.620.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 +453 -1
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES +3 -0
- 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/cli/search-all.d.ts +1 -1
- package/dist/calendar/cli/search-all.js +9 -10
- 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/calendar/prepare.js +1 -0
- package/dist/cli/base-stages-command.d.ts +22 -0
- package/dist/cli/base-stages-command.js +174 -0
- package/dist/cli/bot/buttons.d.ts +3 -0
- package/dist/cli/bot/buttons.js +24 -0
- package/dist/cli/bot/messages.js +14 -1
- package/dist/cli/bot/port.d.ts +8 -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/contract-templates.js +31 -2
- 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 +12 -4
- package/dist/cli/messenger/context.js +1 -0
- package/dist/cli/messenger/conversations-command.js +2 -1
- package/dist/cli/messenger/doctor-command.js +3 -1
- package/dist/cli/messenger/message-items.js +1 -1
- package/dist/cli/messenger/models-command.js +1 -1
- package/dist/cli/messenger/search-answers.d.ts +5 -5
- package/dist/cli/messenger/search-answers.js +9 -20
- package/dist/cli/messenger/search-command.d.ts +2 -2
- package/dist/cli/messenger/search-command.js +8 -18
- 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 +48 -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-harder-consents-command.d.ts +18 -0
- package/dist/cli/search-harder-consents-command.js +83 -0
- 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/steps.js +0 -6
- 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/cli/templates-command.js +4 -4
- package/dist/crm/cli/index.js +40 -8
- package/dist/crm/cli/search-all.js +7 -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/models.d.ts +2 -0
- 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 +160 -0
- package/dist/entities/contact-context.js +6 -0
- package/dist/entities/deal.d.ts +10 -0
- package/dist/entities/deal.js +2 -0
- package/dist/entities/hit.d.ts +9 -2
- package/dist/entities/hit.js +6 -2
- package/dist/entities/index.d.ts +32 -4
- 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 +39 -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/hit-query.d.ts +1 -1
- package/dist/meetings/hit-query.js +2 -2
- package/dist/meetings/index.d.ts +1 -0
- package/dist/meetings/index.js +1 -0
- package/dist/meetings/result-items.d.ts +1 -0
- package/dist/meetings/result-items.js +1 -0
- package/dist/meetings/store.d.ts +4 -0
- package/dist/meetings/store.js +2 -1
- package/dist/models/anthropic.js +5 -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/search/question-period.d.ts +10 -0
- package/dist/search/question-period.js +133 -0
- package/dist/sends/buttons.d.ts +2 -0
- package/dist/sends/buttons.js +6 -1
- 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 +12 -2
- package/dist/services/enrichment.js +47 -6
- 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 +19 -4
- package/dist/services/index.js +12 -3
- 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/messages.d.ts +1 -4
- package/dist/services/messages.js +0 -2
- package/dist/services/metadata.d.ts +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 +11 -1
- package/dist/services/person-context.js +25 -10
- package/dist/services/person-preparation.d.ts +5 -1
- package/dist/services/person-preparation.js +10 -3
- package/dist/services/person-timeline.d.ts +6 -1
- package/dist/services/person-timeline.js +10 -2
- 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-all-deprecated.d.ts +40 -0
- package/dist/services/search-all-deprecated.js +10 -0
- package/dist/services/search-all-meetings.d.ts +50 -52
- package/dist/services/search-all-meetings.js +265 -272
- package/dist/services/search-all.d.ts +34 -6
- package/dist/services/search-all.js +118 -24
- package/dist/services/search-harder.d.ts +64 -0
- package/dist/services/search-harder.js +194 -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/chats.d.ts +3 -1
- package/dist/store/chats.js +6 -0
- 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 +28 -2
- package/dist/store/people.js +15 -1
- package/dist/store/sqlite/accounts.js +2 -0
- package/dist/store/sqlite/added-sources.d.ts +15 -3
- package/dist/store/sqlite/added-sources.js +26 -5
- 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/chats.d.ts +2 -0
- package/dist/store/sqlite/chats.js +6 -0
- 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/involvements.d.ts +1 -1
- package/dist/store/sqlite/involvements.js +4 -2
- 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/meeting-hit-query.d.ts +5 -0
- package/dist/store/sqlite/meeting-hit-query.js +33 -0
- package/dist/store/sqlite/meeting-hit-search.js +10 -8
- package/dist/store/sqlite/meetings.js +1 -1
- 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 +8 -2
- package/dist/store/sqlite/notes.js +17 -34
- 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/person-preparation.d.ts +7 -3
- package/dist/store/sqlite/person-preparation.js +20 -6
- 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 +22 -4
- 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 +37 -16
- package/schemas/records-envelope.v1.schema.json +3 -0
|
@@ -11,6 +11,7 @@ import { withoutPhone } from "../../services/people.js";
|
|
|
11
11
|
import { CHAT_MESSAGES, CONTEXT_BYTES, CONTEXT_MESSAGES } from "../../services/person-context.js";
|
|
12
12
|
import { SCOPES, TIMELINE_ITEMS } from "../../services/person-timeline.js";
|
|
13
13
|
import { readSecret } from "../../terminal/prompt.js";
|
|
14
|
+
import { actorOf } from "../author.js";
|
|
14
15
|
import { secretInputOf } from "../context.js";
|
|
15
16
|
import { FETCH, LOCAL_WRITE, REMOTE_READ } from "../effects.js";
|
|
16
17
|
import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
@@ -190,7 +191,8 @@ export const contactsCommand = (messenger) => {
|
|
|
190
191
|
})
|
|
191
192
|
.summary("one person's activity across their linked identities")
|
|
192
193
|
.description("everything one person took part in, in every messenger linked to them — messages they wrote or were " +
|
|
193
|
-
"mentioned in, chats, mail, meetings, tasks — newest first, from the store;
|
|
194
|
+
"mentioned in, chats, mail, meetings, tasks — newest first, from the store; only in this account's scope, " +
|
|
195
|
+
"personal or work, and scope: of the other one is refused; never connects")
|
|
194
196
|
.argument("<person>", "their id, @username, or part of their name"), CONTACT_ACTIVITY_QUERY)
|
|
195
197
|
.option("--limit <n>", `at most this many; ${TIMELINE_ITEMS} if not given`, positiveCount("--limit"))
|
|
196
198
|
.option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it, with the same filters")
|
|
@@ -256,18 +258,24 @@ export const contactsCommand = (messenger) => {
|
|
|
256
258
|
.description("record that two people in the store are one person — the same name is never enough")
|
|
257
259
|
.argument("<person>", "their id, @username, or part of their name")
|
|
258
260
|
.argument("<other>", "the same in another messenger of the store, as <messenger>:<person> — max:Ana; me: it is you, as zoom:<id> me")
|
|
261
|
+
.option("--reason <text>", "why they are one person; an agent's link is a proposal and needs it")
|
|
259
262
|
.action(async function (person, other) {
|
|
260
263
|
const context = messengerContext(this, messenger);
|
|
261
|
-
const
|
|
264
|
+
const { reason } = this.opts();
|
|
265
|
+
const by = actorOf(this);
|
|
266
|
+
const linked = await context.withServices((services) => services.people.link(person, other, { by, reason }));
|
|
262
267
|
renderAnswer(this, context, itemOf(snakeKeys(linked)));
|
|
263
|
-
|
|
268
|
+
if (linked.proposal === undefined)
|
|
269
|
+
context.renderer.success(`${linked.identities.length} identities are now one person`);
|
|
270
|
+
else
|
|
271
|
+
context.renderer.note(`proposed as ${linked.proposal}: only the owner links them`);
|
|
264
272
|
});
|
|
265
273
|
annotate(contacts.command("unlink"), { effects: LOCAL_WRITE, output: { entity: "linked_person" } })
|
|
266
274
|
.description("undo contacts link for one identity: it is a person of its own again")
|
|
267
275
|
.argument("<person>", "their id, @username, or part of their name; <messenger>:<person> for another messenger")
|
|
268
276
|
.action(async function (person) {
|
|
269
277
|
const context = messengerContext(this, messenger);
|
|
270
|
-
renderAnswer(this, context, itemOf(snakeKeys(await context.withServices((services) => services.people.unlink(person)))));
|
|
278
|
+
renderAnswer(this, context, itemOf(snakeKeys(await context.withServices((services) => services.people.unlink(person, { by: actorOf(this) })))));
|
|
271
279
|
});
|
|
272
280
|
/**
|
|
273
281
|
* ⚠ **The number is asked for or piped, never an argument**: argv is read by `ps` and kept by shell
|
|
@@ -423,6 +423,7 @@ export const messengerContext = (command, messenger, resolving = {}) => {
|
|
|
423
423
|
history: base.settings.record,
|
|
424
424
|
searchCatchUp: base.settings.searchCatchUp,
|
|
425
425
|
...(base.settings.historyLimits ? { historyLimits: base.settings.historyLimits } : {}),
|
|
426
|
+
historyMuted: base.settings.historyMuted,
|
|
426
427
|
pictures: base.settings.pictureSearch,
|
|
427
428
|
reranker: base.settings.searchReranker,
|
|
428
429
|
guard,
|
|
@@ -4,6 +4,7 @@ import { Command, Option } from "commander";
|
|
|
4
4
|
import { analysisConsents } from "../../analysis/consents.js";
|
|
5
5
|
import { openAnalysis, providerIdentity } from "../../analysis/provider.js";
|
|
6
6
|
import { runAnalysis } from "../../analysis/runner.js";
|
|
7
|
+
import { DEFAULT_TEXT_MODEL } from "../../embeddings/models.js";
|
|
7
8
|
import { isLocal } from "../../embeddings/remote.js";
|
|
8
9
|
import { renderMessages } from "../../render/messages.js";
|
|
9
10
|
import { BATCH_SIZE, CONVERSATION_QUERY } from "../../services/conversations.js";
|
|
@@ -401,7 +402,7 @@ const chatOf = ({ chat }) => {
|
|
|
401
402
|
return chat;
|
|
402
403
|
};
|
|
403
404
|
const withModelOptions = (command) => command
|
|
404
|
-
.option("--model <model>",
|
|
405
|
+
.option("--model <model>", `local: a model id from \`models list\` (default: ${DEFAULT_TEXT_MODEL}); remote: the provider's model`)
|
|
405
406
|
.addOption(new Option("--embedding-provider <provider>", "embedding provider: local or openai; flags override profile settings"))
|
|
406
407
|
.option("--base-url <url>", "a server with OpenAI's /v1/embeddings: Gemini, Jina, or Ollama and LM Studio on this machine")
|
|
407
408
|
.option("--dims <n>", "remote: the vector size — needed with --base-url; shortens an OpenAI model's", positiveCount("--dims"));
|
|
@@ -71,7 +71,9 @@ export const damageNotes = (store) => {
|
|
|
71
71
|
`the deep check passed, so writes are allowed again: \`${cleared.command}\` had found the store damaged at ${cleared.at}`,
|
|
72
72
|
]
|
|
73
73
|
: []),
|
|
74
|
-
...(damage
|
|
74
|
+
...(damage
|
|
75
|
+
? [damage.what_happened, damage.external_data_safe, ...damage.steps.map(({ command }) => `next: ${command}`)]
|
|
76
|
+
: []),
|
|
75
77
|
];
|
|
76
78
|
};
|
|
77
79
|
const INCLUDES = [
|
|
@@ -20,7 +20,7 @@ const attachmentItem = (attachment) => defined({
|
|
|
20
20
|
phone: attachment.contact.phone,
|
|
21
21
|
user_id: attachment.contact.userId,
|
|
22
22
|
}),
|
|
23
|
-
buttons: attachment.buttons,
|
|
23
|
+
buttons: attachment.buttons?.map((row) => row.map(({ data: _data, ...button }) => button)),
|
|
24
24
|
});
|
|
25
25
|
const quotedItem = (quoted) => quoted === null
|
|
26
26
|
? null
|
|
@@ -185,7 +185,7 @@ export const modelsCommand = (messenger) => {
|
|
|
185
185
|
.summary("download and verify one speech, embedding or reranker model")
|
|
186
186
|
.description("download and verify one speech, embedding or reranker model: tens to hundreds of MB, each size in models list")
|
|
187
187
|
.argument("<model>", "a model id from models list")
|
|
188
|
-
.option("--accept-terms", "
|
|
188
|
+
.option("--accept-terms", "no longer needed; kept so older scripts still run")
|
|
189
189
|
.action(async function (id, options) {
|
|
190
190
|
if (orderedModels().some((model) => model.id === id))
|
|
191
191
|
return downloadAudioModel(this, messenger, id);
|
|
@@ -6,8 +6,8 @@ import type { ChatCoverage } from "../../services/chat-coverage.js";
|
|
|
6
6
|
import type { FoundMessage, SearchFound } from "../../services/messages.js";
|
|
7
7
|
import type { MeaningSkipped } from "../../services/messages-discovery.js";
|
|
8
8
|
import type { FoundNote, NotesFoundOf } from "../../services/notes-search.js";
|
|
9
|
-
import type { SearchAllItem } from "../../services/search-all.js";
|
|
10
|
-
import type {
|
|
9
|
+
import type { SearchAllFound, SearchAllItem } from "../../services/search-all.js";
|
|
10
|
+
import type { SearchAllIncludingMeetingsFound } from "../../services/search-all-deprecated.js";
|
|
11
11
|
import type { StoredHistorySkip } from "../../store/store.js";
|
|
12
12
|
import { type ListBody } from "../envelope.js";
|
|
13
13
|
/** What a source tool's `search all` reads: never mail, which is memo's (docs/dev/TOOL-BOUNDARIES.md). */
|
|
@@ -46,11 +46,11 @@ export declare const shownOf: (shown: number, offset: number, total: SearchTotal
|
|
|
46
46
|
/** `search messages` and `search mail`, CLI and MCP alike. */
|
|
47
47
|
export declare const messagesAnswer: (command: string, found: SearchFound, { limit, page, again }: Paging, query?: string, skips?: StoredHistorySkip[]) => ListBody<MessageHitItem>;
|
|
48
48
|
export declare const noteHitItem: (hit: FoundNote) => NoteHitItem;
|
|
49
|
-
export declare const allHitItem: (item: SearchAllItem
|
|
49
|
+
export declare const allHitItem: (item: SearchAllItem) => HitItem;
|
|
50
50
|
/** `search notes`, CLI and MCP alike. */
|
|
51
51
|
export declare const notesAnswer: (command: string, found: NotesFoundOf, { limit, page, again }: Paging, exact?: boolean) => ListBody<NoteHitItem>;
|
|
52
|
-
/** `search all`, CLI and MCP alike. A
|
|
53
|
-
export declare const allAnswer: (command: string, found: SearchAllIncludingMeetingsFound, { limit, page, again }: Paging, exact?: boolean, skips?: StoredHistorySkip[],
|
|
52
|
+
/** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. */
|
|
53
|
+
export declare const allAnswer: (command: string, found: SearchAllFound | SearchAllIncludingMeetingsFound, { limit, page, again }: Paging, exact?: boolean, skips?: StoredHistorySkip[],
|
|
54
54
|
/** Kinds the profile's levels kept out of the search, each with why. */
|
|
55
55
|
leftOut?: readonly {
|
|
56
56
|
why: string;
|
|
@@ -306,7 +306,9 @@ export const allHitItem = (item) => item.kind === "meeting"
|
|
|
306
306
|
excerpt: item.text,
|
|
307
307
|
offset_ms: item.startMs,
|
|
308
308
|
scope: item.scope,
|
|
309
|
+
found_by: item.foundBy,
|
|
309
310
|
id: String(item.id),
|
|
311
|
+
...(item.match === undefined ? {} : { match: item.match, corrections: item.corrections ?? [] }),
|
|
310
312
|
...(item.cueRef === undefined
|
|
311
313
|
? {}
|
|
312
314
|
: {
|
|
@@ -359,12 +361,11 @@ export const notesAnswer = (command, found, { limit, page, again }, exact = fals
|
|
|
359
361
|
...meaningGap(found.meaning_skipped, exact),
|
|
360
362
|
meta: metaOf(found.accounts, found.skipped),
|
|
361
363
|
});
|
|
362
|
-
/** `search all`, CLI and MCP alike. A
|
|
364
|
+
/** `search all`, CLI and MCP alike. A meeting account whose index is still being built says so. */
|
|
363
365
|
export const allAnswer = (command, found, { limit, page, again }, exact = false, skips = [],
|
|
364
366
|
/** Kinds the profile's levels kept out of the search, each with why. */
|
|
365
367
|
leftOut = []) => {
|
|
366
368
|
const limited = historyLimitGaps(skips);
|
|
367
|
-
const scan = found.meetings?.complete === false ? found.meetings : undefined;
|
|
368
369
|
const notes = meaningGap(found.notes?.meaningSkipped, exact);
|
|
369
370
|
const messages = messageMeaningGap(found.messages?.meaningSkipped, "found_by");
|
|
370
371
|
const archive = coverageGaps({ coverage: found.coverage }, found.items.length);
|
|
@@ -375,30 +376,18 @@ leftOut = []) => {
|
|
|
375
376
|
page: page ?? 1,
|
|
376
377
|
...(again ? { args: again } : {}),
|
|
377
378
|
next: [
|
|
378
|
-
...(scan
|
|
379
|
-
? [
|
|
380
|
-
nextStep("search.meetings", {
|
|
381
|
-
command,
|
|
382
|
-
args: { ...again, max_meetings: "all" },
|
|
383
|
-
values: { scanned: scan.meetingsScanned },
|
|
384
|
-
}),
|
|
385
|
-
]
|
|
386
|
-
: []),
|
|
387
379
|
...notes.next,
|
|
388
380
|
...messages.next.filter((step) => !notes.next.some((asked) => JSON.stringify(asked) === JSON.stringify(step))),
|
|
389
381
|
...archive.next,
|
|
390
382
|
...limited.next,
|
|
391
383
|
],
|
|
392
384
|
missing: [
|
|
393
|
-
...(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
},
|
|
400
|
-
]
|
|
401
|
-
: []),
|
|
385
|
+
...(Array.isArray(found.meetings) ? found.meetings : [])
|
|
386
|
+
.filter(({ indexing }) => indexing === "pending")
|
|
387
|
+
.map(({ provider, account }) => ({
|
|
388
|
+
field: "items",
|
|
389
|
+
why: `${provider}:${account}: meetings saved since its search index was last built are not found yet`,
|
|
390
|
+
})),
|
|
402
391
|
...notes.missing,
|
|
403
392
|
...messages.missing,
|
|
404
393
|
...archive.missing,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SearchAllItem } from "../../services/search-all.js";
|
|
3
3
|
import { type Messenger } from "./context.js";
|
|
4
4
|
import { type SourceSearched } from "./search-answers.js";
|
|
5
5
|
export declare const searchAllOnlyOf: (value: string, allowed?: readonly string[]) => SourceSearched[];
|
|
6
6
|
/** One `search all` hit as a person reads it. */
|
|
7
|
-
export declare const searchAllLine: (item:
|
|
7
|
+
export declare const searchAllLine: (item: SearchAllItem) => string;
|
|
8
8
|
/**
|
|
9
9
|
* `search all`'s scope, paging and matching options, the same in every CLI that mounts it (WC-ACCT-8): a messenger's
|
|
10
10
|
* and a calendar's.
|
|
@@ -22,44 +22,35 @@ export const searchAllOnlyOf = (value, allowed = SOURCE_SEARCHED) => {
|
|
|
22
22
|
throw new CliError("validation_error", "mail is searched by the separate memo CLI: install @wirecat/cli-memo, then `memo search mail …`");
|
|
23
23
|
const unknown = chosen.find((one) => !allowed.includes(one));
|
|
24
24
|
if (unknown !== undefined || chosen.length === 0)
|
|
25
|
-
throw new CliError("validation_error", `--only takes ${allowed.join(", ")}, separated by commas
|
|
25
|
+
throw new CliError("validation_error", `--only takes ${allowed.join(", ")}, separated by commas`);
|
|
26
26
|
return [...new Set(chosen)];
|
|
27
27
|
};
|
|
28
28
|
/** One `search all` hit as a person reads it. */
|
|
29
29
|
export const searchAllLine = (item) => item.kind === "meeting"
|
|
30
30
|
? `meeting · ${item.provider} · ${singleLine(item.title ?? "")} ${item.ref}\n ${item.timestamp ?? "time unknown"} ${singleLine(item.text).slice(0, 200)}\n`
|
|
31
31
|
: `${item.kind} · ${item.provider} · ${singleLine(item.title ?? "")} ${item.ref}${item.url ? `\n ${singleLine(item.url)}` : ""}\n ${item.timestamp}${item.from?.name ? ` ${singleLine(item.from.name)}` : ""} ${singleLine(item.text)}\n`;
|
|
32
|
-
const maxMeetingsOf = (value) => {
|
|
33
|
-
if (value === "all")
|
|
34
|
-
return "all";
|
|
35
|
-
if (!/^[1-9]\d*$/.test(value))
|
|
36
|
-
throw new CliError("validation_error", "--max-meetings takes a whole number from 1, or all");
|
|
37
|
-
return Number(value);
|
|
38
|
-
};
|
|
39
32
|
/**
|
|
40
33
|
* `search all`'s scope, paging and matching options, the same in every CLI that mounts it (WC-ACCT-8): a messenger's
|
|
41
34
|
* and a calendar's.
|
|
42
35
|
*/
|
|
43
36
|
/** `allowed`: the resources `--only` takes, a CRM CLI's with `crm`. */
|
|
44
37
|
export const searchAllOptions = (command, allowed = SOURCE_SEARCHED) => command
|
|
45
|
-
.option("--only <resources>", `only these resources, separated by commas: ${allowed.
|
|
46
|
-
"meetings when --source names a meeting account", (value) => searchAllOnlyOf(value, allowed))
|
|
38
|
+
.option("--only <resources>", `only these resources, separated by commas: ${allowed.join(", ")}`, (value) => searchAllOnlyOf(value, allowed))
|
|
47
39
|
.option("--source <accounts>", "only these accounts, separated by commas: provider:account as a hit shows it, a provider, a kind or " +
|
|
48
|
-
"group:<name>; each resource reads the ones of its kind
|
|
49
|
-
.option("--max-meetings <n>", "how many of the meeting account's meetings to look through, newest first, or all for every one (default 100)", maxMeetingsOf)
|
|
40
|
+
"group:<name>; each resource reads the ones of its kind")
|
|
50
41
|
.option("--limit <n>", "how many", positiveCount("--limit"))
|
|
51
42
|
.option("--page <n>", "which page, starting at 1", positiveCount("--page"))
|
|
52
43
|
.option("--exact", "bare words and quotes match their exact form only, as exact:word does")
|
|
53
44
|
.option("--timezone <zone>", "the IANA timezone for calendar date boundaries");
|
|
54
45
|
const allCommand = (messenger) => {
|
|
55
46
|
const command = annotate(new Command("all"), { effects: REMOTE_READ, partial: true })
|
|
56
|
-
.summary("search stored messages, notes, calendar events and
|
|
47
|
+
.summary("search stored messages, notes, calendar events and meetings")
|
|
57
48
|
.description((messenger.serverSearch
|
|
58
49
|
? "search messenger messages and notes in the local store, and by default the messenger's server for " +
|
|
59
50
|
"messages too (notes and events are local only; --backend archive or --offline keeps it to the local store)"
|
|
60
51
|
: "search messenger messages and notes in the local store") +
|
|
61
52
|
", calendar events when the store holds a calendar" +
|
|
62
|
-
", and
|
|
53
|
+
", and meeting transcripts, chat and summaries when it holds a meeting account — best match first; not mail (the separate memo CLI searches it: memo search mail), " +
|
|
63
54
|
"tasks, people, memories or projects. Use it when you do not know where something was written; search messages " +
|
|
64
55
|
"or notes reads one kind with all its fields")
|
|
65
56
|
.argument("<query...>", 'strict Lucene query: words, "phrases", AND/OR/NOT, field groups and date ranges')
|
|
@@ -68,10 +59,10 @@ const allCommand = (messenger) => {
|
|
|
68
59
|
--json: the list is items; each result's reference is ref, with its kind.`);
|
|
69
60
|
return backendOptions(annotate(searchAllOptions(command), { output: { entity: "hit" } }), messenger).action(async function (words) {
|
|
70
61
|
const context = messengerContext(this, messenger);
|
|
71
|
-
const { only, source,
|
|
62
|
+
const { only, source, limit: typed, page, exact, timezone, } = this.opts();
|
|
72
63
|
const limit = typed ?? context.settings.limit;
|
|
73
64
|
const offset = offsetOf(page, limit);
|
|
74
|
-
const found = await context.withServices((services) => services.messages.
|
|
65
|
+
const found = await context.withServices((services) => services.messages.searchAll({
|
|
75
66
|
text: words.join(" "),
|
|
76
67
|
limit,
|
|
77
68
|
...(offset === undefined ? {} : { offset }),
|
|
@@ -80,8 +71,8 @@ const allCommand = (messenger) => {
|
|
|
80
71
|
...backendRequest(this),
|
|
81
72
|
env: context.env,
|
|
82
73
|
only: only ?? SOURCE_SEARCHED,
|
|
74
|
+
...(only?.includes("meetings") ? { meetingsAsked: true } : {}),
|
|
83
75
|
...(source === undefined ? {} : { source }),
|
|
84
|
-
...(maxMeetings === undefined ? {} : { maxMeetings }),
|
|
85
76
|
}));
|
|
86
77
|
noteServer(context, found.server);
|
|
87
78
|
if (context.format === "pretty")
|
|
@@ -98,7 +89,6 @@ const allCommand = (messenger) => {
|
|
|
98
89
|
query: words.join(" "),
|
|
99
90
|
...(only === undefined ? {} : { only: only.join(",") }),
|
|
100
91
|
...(source === undefined ? {} : { source }),
|
|
101
|
-
...(maxMeetings === undefined ? {} : { max_meetings: maxMeetings }),
|
|
102
92
|
...(exact ? { exact: true } : {}),
|
|
103
93
|
...(timezone === undefined ? {} : { timezone }),
|
|
104
94
|
};
|
|
@@ -32,6 +32,7 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
|
|
|
32
32
|
run_id?: string;
|
|
33
33
|
error: string;
|
|
34
34
|
} | undefined;
|
|
35
|
+
journalMark?: import("../../store/marks.js").JournalMark | undefined;
|
|
35
36
|
damageMarkCleared?: {
|
|
36
37
|
at: string;
|
|
37
38
|
command: string;
|
|
@@ -39,7 +40,16 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
|
|
|
39
40
|
run_id?: string;
|
|
40
41
|
error: string;
|
|
41
42
|
} | undefined;
|
|
42
|
-
damage?:
|
|
43
|
+
damage?: {
|
|
44
|
+
whatHappened: string;
|
|
45
|
+
likelyCauses: import("../../store/damage.js").DamageCause[];
|
|
46
|
+
impact: string[];
|
|
47
|
+
externalDataSafe: string;
|
|
48
|
+
lastOkAt: string | null;
|
|
49
|
+
loss: string;
|
|
50
|
+
steps: import("../../store/damage.js").RecoveryStep[];
|
|
51
|
+
what: string;
|
|
52
|
+
} | undefined;
|
|
43
53
|
path: string;
|
|
44
54
|
exists: boolean;
|
|
45
55
|
schema: number;
|
|
@@ -66,6 +76,7 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
|
|
|
66
76
|
run_id?: string;
|
|
67
77
|
error: string;
|
|
68
78
|
} | undefined;
|
|
79
|
+
journalMark?: import("../../store/marks.js").JournalMark | undefined;
|
|
69
80
|
damageMarkCleared?: {
|
|
70
81
|
at: string;
|
|
71
82
|
command: string;
|
|
@@ -73,7 +84,16 @@ export declare const storeSummary: (env: NodeJS.ProcessEnv, { deep, command, ver
|
|
|
73
84
|
run_id?: string;
|
|
74
85
|
error: string;
|
|
75
86
|
} | undefined;
|
|
76
|
-
damage?:
|
|
87
|
+
damage?: {
|
|
88
|
+
whatHappened: string;
|
|
89
|
+
likelyCauses: import("../../store/damage.js").DamageCause[];
|
|
90
|
+
impact: string[];
|
|
91
|
+
externalDataSafe: string;
|
|
92
|
+
lastOkAt: string | null;
|
|
93
|
+
loss: string;
|
|
94
|
+
steps: import("../../store/damage.js").RecoveryStep[];
|
|
95
|
+
what: string;
|
|
96
|
+
} | undefined;
|
|
77
97
|
path: string;
|
|
78
98
|
exists: boolean;
|
|
79
99
|
error: string;
|
|
@@ -8,9 +8,9 @@ import { RULES_VERSION } from "../../conversations/link.js";
|
|
|
8
8
|
import { syncsOneChat } from "../../ports/traits.js";
|
|
9
9
|
import { isSealed, sealFile, unsealFile } from "../../sealed.js";
|
|
10
10
|
import { fileSchemaOf, SPEAKS, writableBy } from "../../store/compatibility.js";
|
|
11
|
-
import {
|
|
11
|
+
import { storeDamageReport } from "../../store/damage.js";
|
|
12
12
|
import { QUICK_HEALTH_CHECKS, storeHealth } from "../../store/health.js";
|
|
13
|
-
import { readDamageMark, readHealthMark, recordDeepCheck } from "../../store/marks.js";
|
|
13
|
+
import { readDamageMark, readHealthMark, readJournalMark, recordDeepCheck } from "../../store/marks.js";
|
|
14
14
|
import { migrate } from "../../store/migrations.js";
|
|
15
15
|
import { openCache } from "../../store/open.js";
|
|
16
16
|
import { storePath } from "../../store/path.js";
|
|
@@ -79,6 +79,7 @@ export const storeSummary = async (env, { deep = false, command, version } = {})
|
|
|
79
79
|
if (!existsSync(path))
|
|
80
80
|
return { path, exists: false };
|
|
81
81
|
const checked = await storeHealth(path, { deep });
|
|
82
|
+
const journal = readJournalMark(path);
|
|
82
83
|
const recorded = deep
|
|
83
84
|
? recordDeepCheck(path, checked, {
|
|
84
85
|
cli: command ?? "unknown",
|
|
@@ -100,13 +101,17 @@ export const storeSummary = async (env, { deep = false, command, version } = {})
|
|
|
100
101
|
? { damagedSearchIndexes: checked.searchIndexes.filter((index) => !index.ok).map((index) => index.name) }
|
|
101
102
|
: {}),
|
|
102
103
|
};
|
|
103
|
-
const damage = command
|
|
104
|
+
const damage = command
|
|
105
|
+
? storeDamageReport({ health: checked, command, mark, journal, lastOkAt: lastKnownGood })
|
|
106
|
+
: null;
|
|
104
107
|
const healthOf = {
|
|
105
108
|
health,
|
|
106
109
|
lastKnownGood,
|
|
107
110
|
...(mark ? { damageMark: withoutInode(mark) } : {}),
|
|
111
|
+
...(journal ? { journalMark: journal } : {}),
|
|
108
112
|
...(recorded?.cleared ? { damageMarkCleared: withoutInode(recorded.cleared) } : {}),
|
|
109
|
-
|
|
113
|
+
// `what` keeps memo's doctor, which reads it, compiling until it moves to `whatHappened`.
|
|
114
|
+
...(damage ? { damage: { what: damage.whatHappened, ...damage } } : {}),
|
|
110
115
|
};
|
|
111
116
|
try {
|
|
112
117
|
return await reading(path, (database) => {
|
|
@@ -13,8 +13,10 @@ export interface ModelCatalogueOptions {
|
|
|
13
13
|
* (memo): it changes the shared store for every CLI.
|
|
14
14
|
*/
|
|
15
15
|
enrichment?: boolean;
|
|
16
|
-
/** Where `models consents`
|
|
16
|
+
/** Where `models consents` and `models keys` keep the provider's key; the system keyring when absent. */
|
|
17
17
|
keyring?: KeyringStore;
|
|
18
|
+
/** Where `models keys set` reads the key; process.stdin when absent. */
|
|
19
|
+
stdin?: () => NodeJS.ReadableStream | undefined;
|
|
18
20
|
output: (answer: Body, command: Command) => void;
|
|
19
21
|
diagnostic: (line: string) => void;
|
|
20
22
|
jsonOption?: boolean;
|
|
@@ -4,16 +4,19 @@ import { annotate } from "@wirecat/cli-base/commands";
|
|
|
4
4
|
import { defineQuery } from "@wirecat/cli-base/query";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { isTextModelInstalled, textModelsDirectory } from "../embeddings/embed.js";
|
|
7
|
+
import { embeddingKeys } from "../embeddings/keys.js";
|
|
7
8
|
import { chosenTextModel, DEFAULT_TEXT_MODEL, textModel, textModels } from "../embeddings/models.js";
|
|
8
9
|
import { downloadTextModel } from "../services/model-downloads.js";
|
|
9
10
|
import { addCustomTextModel, useTextModel } from "../services/text-model-choice.js";
|
|
10
11
|
import { install, installedBytes, isInstalled, modelsDirectory } from "../speech/install.js";
|
|
11
12
|
import { DEFAULT_ORDER, orderedModels, speechModel } from "../speech/models.js";
|
|
13
|
+
import { readSecret } from "../terminal/prompt.js";
|
|
12
14
|
import { stepLines } from "../terminal/step-lines.js";
|
|
13
15
|
import { FETCH, grantsAuthority, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "./effects.js";
|
|
14
16
|
import { enrichmentConsentsCommand } from "./enrichment-consents-command.js";
|
|
15
17
|
import { itemOf, listOf } from "./envelope.js";
|
|
16
18
|
import { listQuery, nativeTerms, termField, typedQuery, withQuery } from "./list-query.js";
|
|
19
|
+
import { harderConsentsCommand } from "./search-harder-consents-command.js";
|
|
17
20
|
export const MODEL_CATALOGUE_QUERY = defineQuery({
|
|
18
21
|
entity: "model",
|
|
19
22
|
backend: "native",
|
|
@@ -70,7 +73,7 @@ export const modelCatalogueCommand = (app, options) => {
|
|
|
70
73
|
.description("download and verify one speech or embedding model")
|
|
71
74
|
.argument("<model>", "a model id from models list")
|
|
72
75
|
.option("--offline", "refuse a download that needs the network")
|
|
73
|
-
.option("--accept-terms", "
|
|
76
|
+
.option("--accept-terms", "no longer needed; kept so older scripts still run")
|
|
74
77
|
.action(async function (id, given) {
|
|
75
78
|
if (options.offline?.() || this.optsWithGlobals().offline)
|
|
76
79
|
throw new CliError("permission_error", "downloading a model needs the network; --offline was requested", {
|
|
@@ -138,13 +141,56 @@ export const modelCatalogueCommand = (app, options) => {
|
|
|
138
141
|
options.output(itemOf(textModelItem(model, env)), this);
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
|
-
if (options.enrichment === true)
|
|
144
|
+
if (options.enrichment === true) {
|
|
142
145
|
models.addCommand(enrichmentConsentsCommand(app, options));
|
|
146
|
+
models.addCommand(harderConsentsCommand(app, options));
|
|
147
|
+
models.addCommand(providerKeysCommand(app, options));
|
|
148
|
+
}
|
|
143
149
|
if (options.jsonOption)
|
|
144
150
|
for (const command of models.commands.flatMap((one) => (one.commands.length ? one.commands : [one])))
|
|
145
151
|
command.option("--json", "print JSON");
|
|
146
152
|
return models;
|
|
147
153
|
};
|
|
154
|
+
const PROVIDER = /^[a-z0-9][a-z0-9.:-]*$/;
|
|
155
|
+
const providerOf = (given) => {
|
|
156
|
+
const provider = given.trim().toLowerCase();
|
|
157
|
+
if (!PROVIDER.test(provider))
|
|
158
|
+
throw new CliError("validation_error", "name the provider: openai, anthropic, or the host of a --base-url server");
|
|
159
|
+
return provider;
|
|
160
|
+
};
|
|
161
|
+
/** The enrichment provider's key in the tool's keyring entry `embeddings:<provider>`; never printed, never an argument. */
|
|
162
|
+
const providerKeysCommand = (app, options) => {
|
|
163
|
+
const keys = new Command("keys").description("the API key write-time enrichment and search all --harder send with each request");
|
|
164
|
+
const store = () => embeddingKeys(app, options.env(), options.keyring);
|
|
165
|
+
grantsAuthority(annotate(keys.command("set"), {
|
|
166
|
+
effects: LOCAL_WRITE,
|
|
167
|
+
output: { entity: "model_key", view: "stored" },
|
|
168
|
+
examples: [`${app.command} models keys set openai < key.txt`],
|
|
169
|
+
}))
|
|
170
|
+
.argument("<provider>", "openai, anthropic, or the host of a --base-url server that wants a key")
|
|
171
|
+
.description("store a key, typed at a hidden prompt or piped on stdin — never as an argument")
|
|
172
|
+
.action(async function (given) {
|
|
173
|
+
const provider = providerOf(given);
|
|
174
|
+
const input = options.stdin?.();
|
|
175
|
+
const secret = (await readSecret(`API key for ${provider}: `, input ? { input } : {})).trim();
|
|
176
|
+
if (!secret)
|
|
177
|
+
throw new CliError("validation_error", "no key was given — nothing was stored");
|
|
178
|
+
options.output(itemOf({ provider, stored: true, source: store().write(provider, secret) }), this);
|
|
179
|
+
});
|
|
180
|
+
grantsAuthority(annotate(keys.command("remove"), {
|
|
181
|
+
effects: LOCAL_WRITE,
|
|
182
|
+
output: { entity: "model_key", view: "removed" },
|
|
183
|
+
examples: [`${app.command} models keys remove openai`],
|
|
184
|
+
}))
|
|
185
|
+
.argument("<provider>", "openai, anthropic, or a server's host")
|
|
186
|
+
.description("forget the stored key; a key in the environment stays")
|
|
187
|
+
.action(function (given) {
|
|
188
|
+
const provider = providerOf(given);
|
|
189
|
+
const removed = store().remove(provider);
|
|
190
|
+
options.output(itemOf({ provider, removed: removed.length > 0, from: removed }), this);
|
|
191
|
+
});
|
|
192
|
+
return keys;
|
|
193
|
+
};
|
|
148
194
|
const PROGRESS_EVERY_MS = 500;
|
|
149
195
|
/**
|
|
150
196
|
* `{"event":"progress","step":"download",…}` on stderr under --json, for a window to draw a bar by: at most every half
|
package/dist/cli/profile.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
|
+
import { type AppIdentity } from "../ports/app.js";
|
|
3
|
+
import type { RunGroup } from "../search/groups.js";
|
|
2
4
|
/** How the command line names this profile: always the first word, since none is assumed. */
|
|
3
5
|
export declare const asFirstWord: (profile: string) => string;
|
|
4
6
|
export declare const isProfileName: (word: string) => boolean;
|
|
@@ -27,6 +29,12 @@ export declare const liftProfile: (argv: string[], words: Set<string>, valued?:
|
|
|
27
29
|
profile?: string;
|
|
28
30
|
rest: string[];
|
|
29
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* The group a run reads, from the first word (`liftProfile` lifts it) or `<PREFIX>_GROUP`; `all`, the default, is
|
|
34
|
+
* every account, so no restriction. Under `<PREFIX>_GROUP_LOCK` any other group, `all` included, is refused, as the
|
|
35
|
+
* profile lock refuses another profile (WC-ACCT-5); a lock of `all` locks nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare const runGroup: (app: AppIdentity, env: NodeJS.ProcessEnv, word?: string) => RunGroup | undefined;
|
|
30
38
|
/** The root's options that take the next word as their value: `--timeout 30s`. */
|
|
31
39
|
export declare const valuedOptions: (program: Command) => Set<string>;
|
|
32
40
|
/**
|
package/dist/cli/profile.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { envName } from "../ports/app.js";
|
|
3
|
+
import { isGroupName } from "../search/account-list.js";
|
|
2
4
|
/** How the command line names this profile: always the first word, since none is assumed. */
|
|
3
5
|
export const asFirstWord = (profile) => `${profile} `;
|
|
4
6
|
/**
|
|
@@ -57,6 +59,29 @@ export const liftProfile = (argv, words, valued = new Set()) => {
|
|
|
57
59
|
return { rest: argv };
|
|
58
60
|
return { profile: first, rest: [...argv.slice(0, at), ...argv.slice(at + 1)] };
|
|
59
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* The group a run reads, from the first word (`liftProfile` lifts it) or `<PREFIX>_GROUP`; `all`, the default, is
|
|
64
|
+
* every account, so no restriction. Under `<PREFIX>_GROUP_LOCK` any other group, `all` included, is refused, as the
|
|
65
|
+
* profile lock refuses another profile (WC-ACCT-5); a lock of `all` locks nothing.
|
|
66
|
+
*/
|
|
67
|
+
export const runGroup = (app, env, word) => {
|
|
68
|
+
const GROUP = envName(app, "GROUP");
|
|
69
|
+
const LOCK = envName(app, "GROUP_LOCK");
|
|
70
|
+
const lock = env[LOCK]?.trim() || undefined;
|
|
71
|
+
const named = word ?? (env[GROUP]?.trim() || undefined);
|
|
72
|
+
const from = word === undefined ? GROUP : "first word";
|
|
73
|
+
for (const [name, origin] of [
|
|
74
|
+
[named, from],
|
|
75
|
+
[lock, LOCK],
|
|
76
|
+
])
|
|
77
|
+
if (name !== undefined && !isGroupName(name))
|
|
78
|
+
throw new CliError("validation_error", `"${name}" (${origin}) is not a group name — letters, digits, - and _, starting with a letter or a digit`);
|
|
79
|
+
if (lock === undefined || lock.toLowerCase() === "all")
|
|
80
|
+
return named === undefined || named.toLowerCase() === "all" ? undefined : { name: named, from, locked: false };
|
|
81
|
+
if (named !== undefined && named !== lock)
|
|
82
|
+
throw new CliError("permission_error", `this process is locked to group ${lock} (${LOCK}) — group "${named}" (${from}) is refused`);
|
|
83
|
+
return { name: lock, from: LOCK, locked: true };
|
|
84
|
+
};
|
|
60
85
|
/** The root's options that take the next word as their value: `--timeout 30s`. */
|
|
61
86
|
export const valuedOptions = (program) => new Set(program.options
|
|
62
87
|
.filter((option) => option.required)
|
package/dist/cli/program.js
CHANGED
|
@@ -25,6 +25,7 @@ import { admittedUnderLock, changesAuthorityAt, changesAuthorityNow, isLogin, is
|
|
|
25
25
|
import { itemOf, renderAnswer, snakeKeys } from "./envelope.js";
|
|
26
26
|
import { byteCount, DEFAULT_AGENT_COOPERATIVE_MS, DEFAULT_COMMAND_MS, DEFAULT_COOPERATIVE_MS, DEFAULT_OUTPUT_BYTES, DEFAULT_SYNC_MS, execution, } from "./execution.js";
|
|
27
27
|
import { setupAtStart } from "./first-run.js";
|
|
28
|
+
import { refuseOutsideGroup } from "./group-lock.js";
|
|
28
29
|
import { installHelp } from "./help/first-screen.js";
|
|
29
30
|
import { showInputFields } from "./input-fields.js";
|
|
30
31
|
import { MAX_BUFFERED_INPUT, provideInputPolicy } from "./input-policy.js";
|
|
@@ -321,6 +322,7 @@ const runOnce = async (argv, definition, options) => {
|
|
|
321
322
|
input,
|
|
322
323
|
terminal: !options.streams && input.isTTY === true && process.stderr.isTTY === true,
|
|
323
324
|
});
|
|
325
|
+
await refuseOutsideGroup(action, { app: definition.app, env: commandEnv });
|
|
324
326
|
if (lock && isLogin(action) && !flags.dryRun)
|
|
325
327
|
throw readOnlyRefusal(lock, "log in or out");
|
|
326
328
|
if (lock && isStoreChange(action) && !flags.dryRun)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type QueryWords } from "../list-query.js";
|
|
2
2
|
import type { RunSearch } from "./search.js";
|
|
3
3
|
export declare const RUN_SEARCH_QUERY: import("@wirecat/cli-base/query").QueryRegistry;
|
|
4
|
-
export declare const runSearchFilter: (words: QueryWords) => Pick<RunSearch, "terms" | "status" | "errorCode" | "operation" | "profile" | "since" | "until">;
|
|
4
|
+
export declare const runSearchFilter: (words: QueryWords) => Pick<RunSearch, "terms" | "status" | "errorCode" | "operation" | "profile" | "kind" | "table" | "since" | "until">;
|
|
@@ -15,6 +15,8 @@ export const RUN_SEARCH_QUERY = defineQuery({
|
|
|
15
15
|
termField("error_code", "kw", "error_code:rate_limited"),
|
|
16
16
|
termField("operation", "kw", "operation:messages.download"),
|
|
17
17
|
termField("profile", "kw", "profile:work"),
|
|
18
|
+
termField("kind", "kw", "kind:store"),
|
|
19
|
+
termField("table", "kw", "table:emails"),
|
|
18
20
|
],
|
|
19
21
|
});
|
|
20
22
|
export const runSearchFilter = (words) => {
|
|
@@ -62,5 +64,7 @@ export const runSearchFilter = (words) => {
|
|
|
62
64
|
...(fields.has("error_code") ? { errorCode: fields.get("error_code") } : {}),
|
|
63
65
|
...(fields.has("operation") ? { operation: fields.get("operation") } : {}),
|
|
64
66
|
...(fields.has("profile") ? { profile: fields.get("profile") } : {}),
|
|
67
|
+
...(fields.has("kind") ? { kind: fields.get("kind") } : {}),
|
|
68
|
+
...(fields.has("table") ? { table: fields.get("table") } : {}),
|
|
65
69
|
};
|
|
66
70
|
};
|
|
@@ -5,12 +5,16 @@ export interface RunSearch {
|
|
|
5
5
|
errorCode?: string;
|
|
6
6
|
operation?: string;
|
|
7
7
|
profile?: string;
|
|
8
|
+
/** An event's `kind`: `store` for the writes a run made to the store. */
|
|
9
|
+
kind?: string;
|
|
10
|
+
/** A store event's table. */
|
|
11
|
+
table?: string;
|
|
8
12
|
since?: string;
|
|
9
13
|
until?: string;
|
|
10
14
|
limit?: number;
|
|
11
15
|
page?: number;
|
|
12
16
|
}
|
|
13
|
-
export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, since, until, limit, page }?: RunSearch) => {
|
|
17
|
+
export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, kind, table, since, until, limit, page, }?: RunSearch) => {
|
|
14
18
|
items: {
|
|
15
19
|
runId: string;
|
|
16
20
|
command: string;
|