@wirecat/cli-core 0.641.0 → 0.643.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 +218 -0
- package/dist/analysis/provider.d.ts +1 -1
- package/dist/analysis/provider.js +2 -1
- package/dist/attachments/gateway-ocr.js +13 -8
- package/dist/attachments/ocr.js +27 -18
- package/dist/attachments/picture-reading.d.ts +51 -0
- package/dist/attachments/picture-reading.js +207 -0
- package/dist/background/backfill.d.ts +4 -2
- package/dist/background/backfill.js +3 -3
- package/dist/background/schedules.d.ts +28 -2
- package/dist/background/schedules.js +73 -20
- package/dist/background/units.d.ts +2 -0
- package/dist/background/units.js +8 -9
- package/dist/calendar/cli/index.js +10 -2
- package/dist/calendar/feeds.js +2 -2
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/calendar/server-search.js +2 -2
- package/dist/calendar/source.d.ts +4 -3
- package/dist/calendar/sync.js +12 -10
- package/dist/calendar/testing/source-contract.js +5 -4
- package/dist/calendar/testing/source.js +3 -2
- package/dist/cli/ai-model-command.js +6 -3
- package/dist/cli/analysis-choice.js +20 -4
- package/dist/cli/complete-command.d.ts +23 -0
- package/dist/cli/complete-command.js +80 -0
- package/dist/cli/context.js +7 -1
- package/dist/cli/effects.d.ts +2 -0
- package/dist/cli/effects.js +2 -0
- package/dist/cli/enrichment-consents-command.js +2 -0
- package/dist/cli/envelope.js +6 -1
- package/dist/cli/help/first-screen.js +5 -0
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.js +2 -1
- package/dist/cli/list-query.d.ts +3 -1
- package/dist/cli/list-query.js +5 -3
- package/dist/cli/local-only-command.d.ts +10 -0
- package/dist/cli/local-only-command.js +112 -0
- package/dist/cli/messenger/backfill-command.js +1 -1
- package/dist/cli/messenger/chat-queries.js +2 -1
- package/dist/cli/messenger/complete-command.d.ts +4 -7
- package/dist/cli/messenger/complete-command.js +31 -98
- package/dist/cli/messenger/contacts-command.js +4 -0
- package/dist/cli/messenger/conversations-command.js +1 -1
- package/dist/cli/messenger/guard-commands.js +1 -1
- package/dist/cli/messenger/images-command.js +32 -0
- package/dist/cli/messenger/list-result-queries.d.ts +1 -0
- package/dist/cli/messenger/list-result-queries.js +2 -1
- package/dist/cli/messenger/mentions-command.js +3 -3
- package/dist/cli/messenger/message-items.js +1 -0
- package/dist/cli/messenger/messages-command.js +7 -6
- package/dist/cli/messenger/people-queries.d.ts +2 -2
- package/dist/cli/messenger/people-queries.js +4 -4
- package/dist/cli/messenger/replies-consents-command.js +12 -6
- package/dist/cli/messenger/search-answers.js +2 -2
- package/dist/cli/messenger/search-command.js +3 -3
- package/dist/cli/messenger/searches-command.js +1 -1
- package/dist/cli/messenger/store-maintenance-command.js +4 -0
- package/dist/cli/messenger/tasks-analysis-command.js +1 -1
- package/dist/cli/messenger/tasks-command.js +2 -2
- package/dist/cli/model-catalogue-command.js +4 -0
- package/dist/cli/picture-reading-command.d.ts +12 -0
- package/dist/cli/picture-reading-command.js +82 -0
- package/dist/cli/program.d.ts +6 -0
- package/dist/cli/program.js +28 -2
- package/dist/cli/schedule/agent-start.d.ts +23 -0
- package/dist/cli/schedule/agent-start.js +115 -0
- package/dist/cli/schedule/harnesses.d.ts +203 -0
- package/dist/cli/schedule/harnesses.js +278 -0
- package/dist/cli/schedule/schedule-command.d.ts +9 -5
- package/dist/cli/schedule/schedule-command.js +89 -79
- package/dist/cli/search-harder-consents-command.js +16 -1
- package/dist/cli/shared-command-exports.d.ts +186 -0
- package/dist/cli/shared-command-exports.js +2 -0
- package/dist/cli/untrusted-marks.d.ts +25 -0
- package/dist/cli/untrusted-marks.js +102 -0
- package/dist/crm/cli/index.d.ts +1 -0
- package/dist/crm/cli/index.js +6 -5
- package/dist/crm/cli/store.d.ts +30 -0
- package/dist/crm/cli/store.js +63 -0
- package/dist/crm/source.d.ts +6 -4
- package/dist/crm/sync.js +10 -6
- package/dist/crm/testing/source-contract.js +9 -7
- package/dist/crm/testing/source.js +6 -2
- package/dist/crm/testing/sync-contract.js +4 -4
- package/dist/crm/writes.d.ts +5 -2
- package/dist/crm/writes.js +1 -1
- package/dist/documents.d.ts +2 -1
- package/dist/documents.js +2 -1
- package/dist/domain/addresses.d.ts +2 -0
- package/dist/domain/addresses.js +7 -0
- package/dist/domain/attachments.d.ts +2 -0
- package/dist/domain/attachments.js +2 -1
- package/dist/domain/models.d.ts +2 -0
- package/dist/embeddings/remote.d.ts +2 -1
- package/dist/embeddings/remote.js +5 -3
- package/dist/entities/attachment-results.d.ts +3 -0
- package/dist/entities/attachment-results.js +3 -0
- package/dist/entities/attachment.d.ts +2 -0
- package/dist/entities/attachment.js +8 -1
- package/dist/entities/hit.d.ts +1 -0
- package/dist/entities/index.d.ts +21 -4
- package/dist/entities/index.js +3 -2
- package/dist/entities/list-results.d.ts +33 -5
- package/dist/entities/list-results.js +33 -5
- package/dist/errors/reasons.js +38 -1
- package/dist/mail/cli/index.js +7 -6
- package/dist/mcp/agent.d.ts +2 -1
- package/dist/mcp/agent.js +5 -0
- package/dist/mcp/app-server.js +10 -0
- package/dist/mcp/surface.d.ts +7 -2
- package/dist/mcp/surface.js +49 -10
- package/dist/meetings/cli/index.js +6 -1
- package/dist/meetings/mcp/index.js +6 -3
- package/dist/meetings/participant-search.d.ts +2 -2
- package/dist/meetings/project-discovery.d.ts +1 -1
- package/dist/meetings/project-evidence-answer.js +2 -2
- package/dist/meetings/reads.d.ts +2 -2
- package/dist/meetings/reads.js +6 -6
- package/dist/meetings/store.d.ts +2 -1
- package/dist/meetings/testing/contract.js +6 -6
- package/dist/meetings/testing/memory.js +7 -2
- package/dist/models/ai.d.ts +17 -4
- package/dist/models/ai.js +22 -14
- package/dist/models/anthropic.js +15 -9
- package/dist/models/endpoint.d.ts +5 -0
- package/dist/models/endpoint.js +13 -0
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +14 -4
- package/dist/models/local-only.d.ts +17 -0
- package/dist/models/local-only.js +42 -0
- package/dist/models/openai.js +24 -11
- package/dist/models/purpose.d.ts +24 -0
- package/dist/models/purpose.js +26 -0
- package/dist/models/types.d.ts +8 -0
- package/dist/models/types.js +11 -1
- package/dist/ports/app.d.ts +17 -1
- package/dist/ports/app.js +63 -3
- package/dist/replies/rendering.js +10 -10
- package/dist/search/lucene/plain.js +45 -3
- package/dist/search/lucene/registry.d.ts +15 -4
- package/dist/search/lucene/registry.js +70 -12
- package/dist/search/lucene/types.d.ts +2 -0
- package/dist/search/lucene/types.js +12 -0
- package/dist/sends/upload.d.ts +8 -1
- package/dist/sends/upload.js +35 -14
- package/dist/services/account-groups.d.ts +11 -0
- package/dist/services/account-groups.js +29 -0
- package/dist/services/agenda.js +1 -0
- package/dist/services/attachments.d.ts +18 -4
- package/dist/services/attachments.js +66 -15
- package/dist/services/conversations.d.ts +2 -4
- package/dist/services/conversations.js +1 -1
- package/dist/services/deal-context.js +5 -5
- package/dist/services/documents/ingestion.js +3 -3
- package/dist/services/documents/knowledge.d.ts +6 -6
- package/dist/services/documents/knowledge.js +1 -2
- package/dist/services/embeddings-maintenance.js +4 -1
- package/dist/services/enrichment.d.ts +1 -1
- package/dist/services/enrichment.js +27 -0
- package/dist/services/events-search.d.ts +3 -3
- package/dist/services/events-search.js +7 -7
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/meeting-model.js +1 -1
- package/dist/services/meeting-project-discovery.js +1 -1
- package/dist/services/message-resolution.js +10 -3
- package/dist/services/messages-search.js +6 -4
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/notes-search.d.ts +3 -3
- package/dist/services/notes-search.js +3 -3
- package/dist/services/organization-context.js +12 -9
- package/dist/services/people.d.ts +2 -0
- package/dist/services/people.js +4 -2
- package/dist/services/pictures.d.ts +9 -0
- package/dist/services/pictures.js +34 -28
- package/dist/services/project-status/index.js +1 -1
- package/dist/services/project-status/signals/payments.js +4 -2
- package/dist/services/project-status/signals/promises.js +5 -2
- package/dist/services/proposals/kinds/action.js +1 -1
- package/dist/services/proposals/kinds/fact.js +1 -1
- package/dist/services/proposals/kinds/findings.d.ts +2 -1
- package/dist/services/proposals/kinds/findings.js +12 -5
- package/dist/services/proposals/kinds/identity-link.js +1 -1
- package/dist/services/proposals/kinds/identity-split.js +1 -1
- package/dist/services/proposals/kinds/key-document.js +1 -1
- package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
- package/dist/services/proposals/kinds/mail-findings.js +11 -5
- package/dist/services/proposals/kinds/meeting-findings.js +10 -4
- package/dist/services/proposals/kinds/memory.js +1 -1
- package/dist/services/proposals/kinds/organization.js +1 -1
- package/dist/services/proposals/kinds/relationship-update.js +1 -1
- package/dist/services/proposals/kinds/relationship.js +1 -1
- package/dist/services/proposals/kinds/shared.d.ts +3 -2
- package/dist/services/proposals/kinds/shared.js +4 -4
- package/dist/services/proposals/kinds/source-review.js +1 -1
- package/dist/services/proposals/kinds/task-close.js +2 -2
- package/dist/services/proposals/registry.js +1 -1
- package/dist/services/proposals/types.d.ts +2 -1
- package/dist/services/search-all-business.js +3 -4
- package/dist/services/search-all.js +13 -14
- package/dist/services/search-harder.d.ts +11 -1
- package/dist/services/search-harder.js +38 -5
- package/dist/services/searches.d.ts +2 -4
- package/dist/services/searches.js +1 -4
- package/dist/services/stored-project-gathering.js +6 -1
- package/dist/services/tags.d.ts +2 -4
- package/dist/services/tags.js +1 -1
- package/dist/services/tasks.d.ts +1 -1
- package/dist/services/tasks.js +4 -3
- package/dist/speech/openai.js +2 -0
- package/dist/speech/transcribe.d.ts +5 -2
- package/dist/speech/transcribe.js +14 -5
- package/dist/store/account-store.d.ts +2 -1
- package/dist/store/account-store.js +3 -1
- package/dist/store/accounts.d.ts +2 -0
- package/dist/store/accounts.js +8 -0
- package/dist/store/chats.d.ts +5 -0
- package/dist/store/chats.js +4 -0
- package/dist/store/evidence-findings.d.ts +9 -0
- package/dist/store/exports.d.ts +1 -1
- package/dist/store/exports.js +1 -1
- package/dist/store/identity-links.d.ts +3 -1
- package/dist/store/mail-findings.d.ts +9 -0
- package/dist/store/meeting-findings.d.ts +9 -0
- package/dist/store/searches.d.ts +3 -2
- package/dist/store/sqlite/accounts.js +37 -0
- package/dist/store/sqlite/agent-actions.d.ts +2 -1
- package/dist/store/sqlite/agent-actions.js +10 -4
- package/dist/store/sqlite/business-contracts.d.ts +3 -1
- package/dist/store/sqlite/business-contracts.js +7 -3
- package/dist/store/sqlite/business-search.d.ts +2 -1
- package/dist/store/sqlite/business-search.js +6 -4
- package/dist/store/sqlite/deals.d.ts +6 -4
- package/dist/store/sqlite/deals.js +12 -7
- package/dist/store/sqlite/evidence-findings.js +78 -9
- package/dist/store/sqlite/facts.d.ts +2 -1
- package/dist/store/sqlite/facts.js +6 -2
- package/dist/store/sqlite/finance.d.ts +4 -2
- package/dist/store/sqlite/finance.js +13 -6
- package/dist/store/sqlite/findings-core.d.ts +56 -2
- package/dist/store/sqlite/findings-core.js +109 -22
- package/dist/store/sqlite/identities.d.ts +4 -0
- package/dist/store/sqlite/identities.js +12 -3
- package/dist/store/sqlite/identity-proposals.js +34 -4
- package/dist/store/sqlite/lucene-fields.d.ts +2 -0
- package/dist/store/sqlite/lucene-fields.js +28 -2
- package/dist/store/sqlite/lucene.js +21 -10
- package/dist/store/sqlite/mail-findings.js +60 -22
- package/dist/store/sqlite/meeting-findings.js +53 -7
- package/dist/store/sqlite/meeting-participant-search.js +4 -5
- package/dist/store/sqlite/meetings.js +7 -3
- package/dist/store/sqlite/memories.d.ts +4 -2
- package/dist/store/sqlite/memories.js +13 -6
- package/dist/store/sqlite/money-transactions.d.ts +3 -1
- package/dist/store/sqlite/money-transactions.js +7 -3
- package/dist/store/sqlite/name-traces.d.ts +3 -3
- package/dist/store/sqlite/name-traces.js +29 -2
- package/dist/store/sqlite/orders.d.ts +3 -1
- package/dist/store/sqlite/orders.js +5 -2
- package/dist/store/sqlite/people-list.js +67 -22
- package/dist/store/sqlite/person-match-scan.d.ts +3 -1
- package/dist/store/sqlite/person-match-scan.js +97 -7
- package/dist/store/sqlite/products.d.ts +3 -1
- package/dist/store/sqlite/products.js +5 -2
- package/dist/store/sqlite/proposed-actions.d.ts +2 -1
- package/dist/store/sqlite/proposed-actions.js +7 -3
- package/dist/store/sqlite/query-filter.d.ts +4 -0
- package/dist/store/sqlite/query-filter.js +14 -0
- package/dist/store/sqlite/reads.d.ts +1 -0
- package/dist/store/sqlite/reads.js +14 -0
- package/dist/store/sqlite/records.d.ts +3 -1
- package/dist/store/sqlite/records.js +7 -5
- package/dist/store/sqlite/rows-page.d.ts +3 -0
- package/dist/store/sqlite/rows-page.js +4 -0
- package/dist/store/sqlite/searches.d.ts +2 -1
- package/dist/store/sqlite/searches.js +3 -1
- package/dist/store/sqlite/subscriptions.d.ts +5 -2
- package/dist/store/sqlite/subscriptions.js +13 -6
- package/dist/store/sqlite/task-board.js +27 -0
- package/dist/store/sqlite/task-find.d.ts +15 -0
- package/dist/store/sqlite/task-find.js +1 -0
- package/dist/store/sqlite/wallets.d.ts +3 -1
- package/dist/store/sqlite/wallets.js +7 -3
- package/dist/store/sqlite/work-tasks.d.ts +3 -11
- package/dist/store/sqlite/work-tasks.js +8 -4
- package/package.json +2 -2
- package/parity.json +24 -0
|
@@ -54,7 +54,7 @@ export const keyDocumentKind = (store) => {
|
|
|
54
54
|
stored: ["key_document"],
|
|
55
55
|
list: async (filter) => {
|
|
56
56
|
const status = storedStatus(filter);
|
|
57
|
-
const stored = await store.proposedActions.list({
|
|
57
|
+
const { items: stored } = await store.proposedActions.list({
|
|
58
58
|
kinds: ["key_document"],
|
|
59
59
|
...(status === undefined ? {} : { status }),
|
|
60
60
|
...pushed(filter),
|
|
@@ -4,6 +4,6 @@ import type { ProposalKind } from "../types.js";
|
|
|
4
4
|
* What an agent read in new mail, one batch per mailbox and run. Only the owner decides it — mail is text a stranger
|
|
5
5
|
* wrote, so an agent that read it must not also approve what it made of it: an agent's confirmation is refused
|
|
6
6
|
* whatever `agent_decisions` says. Confirming accepts the parts named, or every finding not
|
|
7
|
-
* rejected before; the rest
|
|
7
|
+
* rejected before; the rest wait. Rejecting turns down what still waits.
|
|
8
8
|
*/
|
|
9
9
|
export declare const mailFindingsKind: (store: Pick<MessageStore, "mailFindings" | "proposedActions">) => ProposalKind;
|
|
@@ -28,7 +28,7 @@ const summaryOf = (finding) => {
|
|
|
28
28
|
};
|
|
29
29
|
const rowOf = (batch, createdAt) => {
|
|
30
30
|
const findings = batch.input.findings;
|
|
31
|
-
const outcome = (id) => batch.receipt?.items.find((item) => item.id === id)?.status ?? null;
|
|
31
|
+
const outcome = (id) => (batch.receipt?.items ?? batch.decided).find((item) => item.id === id)?.status ?? null;
|
|
32
32
|
const project = findings.flatMap((finding) => ("project" in finding && finding.project ? [finding.project] : []))[0] ?? null;
|
|
33
33
|
return {
|
|
34
34
|
id: batch.id,
|
|
@@ -56,7 +56,7 @@ const rowOf = (batch, createdAt) => {
|
|
|
56
56
|
* What an agent read in new mail, one batch per mailbox and run. Only the owner decides it — mail is text a stranger
|
|
57
57
|
* wrote, so an agent that read it must not also approve what it made of it: an agent's confirmation is refused
|
|
58
58
|
* whatever `agent_decisions` says. Confirming accepts the parts named, or every finding not
|
|
59
|
-
* rejected before; the rest
|
|
59
|
+
* rejected before; the rest wait. Rejecting turns down what still waits.
|
|
60
60
|
*/
|
|
61
61
|
export const mailFindingsKind = (store) => {
|
|
62
62
|
const created = async (batch) => rowOf(batch, (await store.proposedActions.get(batch.id)).createdAt);
|
|
@@ -75,7 +75,7 @@ export const mailFindingsKind = (store) => {
|
|
|
75
75
|
limit: 50,
|
|
76
76
|
offset,
|
|
77
77
|
});
|
|
78
|
-
for (const row of kept(await Promise.all(page.items.map(created)), { ...filter, limit: 50 }))
|
|
78
|
+
for (const row of kept(await Promise.all(page.items.map(created)), { ...filter, limit: 50 }).items)
|
|
79
79
|
rows.push(row);
|
|
80
80
|
if (!page.hasMore)
|
|
81
81
|
break;
|
|
@@ -85,12 +85,18 @@ export const mailFindingsKind = (store) => {
|
|
|
85
85
|
get: async (id) => created(await store.mailFindings.get(id)),
|
|
86
86
|
decide: async (id, { confirm, by, parts }) => {
|
|
87
87
|
const batch = await store.mailFindings.get(id);
|
|
88
|
-
|
|
88
|
+
// A finding this batch already decided keeps its outcome; a confirm with no names takes what still waits.
|
|
89
|
+
const turnedDown = new Set([
|
|
90
|
+
...batch.previous.filter((one) => one.status === "rejected").map((one) => one.id),
|
|
91
|
+
...batch.decided.map((one) => one.id),
|
|
92
|
+
]);
|
|
89
93
|
const accept = !confirm
|
|
90
94
|
? []
|
|
91
95
|
: (parts ?? batch.input.findings.map((finding) => finding.id).filter((one) => !turnedDown.has(one)));
|
|
92
96
|
const reviewed = await store.mailFindings.review(id, { fingerprint: batch.fingerprint, accept, by });
|
|
93
|
-
const made = (reviewed.receipt?.items ??
|
|
97
|
+
const made = (reviewed.receipt?.items ?? reviewed.decided).flatMap((item) => item.status === "accepted" && item.reference && !item.reused && accept.includes(item.id)
|
|
98
|
+
? [item.reference]
|
|
99
|
+
: []);
|
|
94
100
|
return { id, kind: "mail_findings", status: accept.length ? "confirmed" : "rejected", made };
|
|
95
101
|
},
|
|
96
102
|
};
|
|
@@ -6,7 +6,7 @@ import { kept } from "./shared.js";
|
|
|
6
6
|
const rowOf = (action, batch) => {
|
|
7
7
|
const findings = batch.input.findings;
|
|
8
8
|
const projects = [...new Set(findings.map((one) => ("project" in one ? one.project : undefined)))];
|
|
9
|
-
const outcome = (id) => batch.receipt?.items.find((item) => item.id === id)?.status ?? null;
|
|
9
|
+
const outcome = (id) => (batch.receipt?.items ?? batch.decided).find((item) => item.id === id)?.status ?? null;
|
|
10
10
|
const references = [...new Set(findings.flatMap((finding) => finding.evidence.map((one) => one.reference)))];
|
|
11
11
|
return {
|
|
12
12
|
id: action.id,
|
|
@@ -46,7 +46,7 @@ export const meetingFindingsKind = (store) => {
|
|
|
46
46
|
parts: true,
|
|
47
47
|
ownerOnly: true,
|
|
48
48
|
list: async (filter) => {
|
|
49
|
-
const actions = await store.proposedActions.list({
|
|
49
|
+
const { items: actions } = await store.proposedActions.list({
|
|
50
50
|
kinds: [MEETING_FINDINGS_KIND],
|
|
51
51
|
...((filter.status ?? "proposed") === "proposed" ? { status: "proposed" } : {}),
|
|
52
52
|
...(filter.by === undefined ? {} : { proposedBy: filter.by }),
|
|
@@ -61,12 +61,18 @@ export const meetingFindingsKind = (store) => {
|
|
|
61
61
|
},
|
|
62
62
|
decide: async (id, { confirm, by, parts }) => {
|
|
63
63
|
const { account, batch } = await batchOf(await store.proposedActions.get(id));
|
|
64
|
-
|
|
64
|
+
// A finding this batch already decided keeps its outcome; a confirm with no names takes what still waits.
|
|
65
|
+
const turnedDown = new Set([
|
|
66
|
+
...batch.previous.filter((one) => one.status === "rejected").map((one) => one.id),
|
|
67
|
+
...batch.decided.map((one) => one.id),
|
|
68
|
+
]);
|
|
65
69
|
const accept = !confirm
|
|
66
70
|
? []
|
|
67
71
|
: (parts ?? batch.input.findings.map((finding) => finding.id).filter((one) => !turnedDown.has(one)));
|
|
68
72
|
const reviewed = await store.meetingFindings.review(account, id, { fingerprint: batch.fingerprint, accept, by });
|
|
69
|
-
const made = (reviewed.receipt?.items ??
|
|
73
|
+
const made = (reviewed.receipt?.items ?? reviewed.decided).flatMap((item) => item.status === "accepted" && item.reference && !item.reused && accept.includes(item.id)
|
|
74
|
+
? [item.reference]
|
|
75
|
+
: []);
|
|
70
76
|
return { id, kind: "meeting_findings", status: accept.length ? "confirmed" : "rejected", made };
|
|
71
77
|
},
|
|
72
78
|
};
|
|
@@ -28,7 +28,7 @@ export const memoryKind = (store) => ({
|
|
|
28
28
|
prefix: "memory",
|
|
29
29
|
list: async (filter) => {
|
|
30
30
|
const status = filter.status ?? "proposed";
|
|
31
|
-
const memories = await store.memories.list({
|
|
31
|
+
const { items: memories } = await store.memories.list({
|
|
32
32
|
...pushed(filter),
|
|
33
33
|
...(status === "all" ? {} : { status: status === "rejected" ? "stale" : status }),
|
|
34
34
|
});
|
|
@@ -29,7 +29,7 @@ export const organizationKind = (store) => ({
|
|
|
29
29
|
stored: [ORGANIZATION_ADD_KIND, ORGANIZATION_RENAME_KIND],
|
|
30
30
|
list: async (filter) => {
|
|
31
31
|
const status = storedStatus(filter);
|
|
32
|
-
const actions = await store.proposedActions.list({
|
|
32
|
+
const { items: actions } = await store.proposedActions.list({
|
|
33
33
|
kinds: [ORGANIZATION_ADD_KIND, ORGANIZATION_RENAME_KIND],
|
|
34
34
|
...(status === undefined ? {} : { status }),
|
|
35
35
|
...pushed(filter),
|
|
@@ -29,7 +29,7 @@ export const relationshipUpdateKind = (store) => ({
|
|
|
29
29
|
stored: [KIND],
|
|
30
30
|
list: async (filter) => {
|
|
31
31
|
const status = storedStatus(filter);
|
|
32
|
-
const stored = await store.proposedActions.list({
|
|
32
|
+
const { items: stored } = await store.proposedActions.list({
|
|
33
33
|
kinds: [KIND],
|
|
34
34
|
...(status === undefined ? {} : { status }),
|
|
35
35
|
...pushed(filter),
|
|
@@ -61,7 +61,7 @@ export const relationshipKind = (store) => {
|
|
|
61
61
|
stored: ["relationship"],
|
|
62
62
|
list: async (filter) => {
|
|
63
63
|
const status = storedStatus(filter);
|
|
64
|
-
const stored = await store.proposedActions.list({
|
|
64
|
+
const { items: stored } = await store.proposedActions.list({
|
|
65
65
|
kinds: ["relationship"],
|
|
66
66
|
...(status === undefined ? {} : { status }),
|
|
67
67
|
...pushed(filter),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
1
2
|
import type { DecidedType } from "../../../domain/record-types.js";
|
|
2
3
|
import type { Proposer } from "../../../store/decisions.js";
|
|
3
4
|
import type { Decision, ProposalFilter, ProposalKind, ProposalRow } from "../types.js";
|
|
@@ -9,7 +10,7 @@ export declare const proposerOfAuthor: (author: {
|
|
|
9
10
|
kind: "agent" | "rule" | null;
|
|
10
11
|
}) => Proposer;
|
|
11
12
|
/** What a kind keeps of the rows it read: the filter's status and proposer, newest first, at most `limit`. */
|
|
12
|
-
export declare const kept: (rows: ProposalRow[], filter: ProposalFilter) => ProposalRow
|
|
13
|
+
export declare const kept: (rows: ProposalRow[], filter: ProposalFilter) => ListResult<ProposalRow>;
|
|
13
14
|
/** The filters every store list takes, so a page is filled by the query and not cut after it. */
|
|
14
15
|
export declare const pushed: (filter: ProposalFilter) => {
|
|
15
16
|
project?: string | undefined;
|
|
@@ -44,7 +45,7 @@ export declare const reviewedKind: <T>(spec: {
|
|
|
44
45
|
type: DecidedType;
|
|
45
46
|
list: (options: ReturnType<typeof pushed> & {
|
|
46
47
|
review?: "proposed" | "confirmed" | "rejected";
|
|
47
|
-
}) => Promise<T
|
|
48
|
+
}) => Promise<ListResult<T>>;
|
|
48
49
|
get: (id: string) => Promise<T>;
|
|
49
50
|
row: (entry: T) => ProposalRow;
|
|
50
51
|
decide: (id: string, confirm: boolean, decision: Pick<Decision, "by" | "reason">) => Promise<string>;
|
|
@@ -19,11 +19,11 @@ const byMatches = (row, by) => {
|
|
|
19
19
|
/** What a kind keeps of the rows it read: the filter's status and proposer, newest first, at most `limit`. */
|
|
20
20
|
export const kept = (rows, filter) => {
|
|
21
21
|
const status = filter.status ?? "proposed";
|
|
22
|
-
|
|
22
|
+
const matching = rows
|
|
23
23
|
.filter((row) => (status === "all" || row.status === status) && byMatches(row, filter.by))
|
|
24
24
|
.filter((row) => filter.project === undefined || row.project === filter.project)
|
|
25
|
-
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
|
26
|
-
|
|
25
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
26
|
+
return { items: matching.slice(0, filter.limit), hasMore: matching.length > filter.limit };
|
|
27
27
|
};
|
|
28
28
|
/** The filters every store list takes, so a page is filled by the query and not cut after it. */
|
|
29
29
|
export const pushed = (filter) => ({
|
|
@@ -73,7 +73,7 @@ export const reviewedKind = (spec) => ({
|
|
|
73
73
|
list: async (filter) => {
|
|
74
74
|
const status = filter.status ?? "proposed";
|
|
75
75
|
const entries = await spec.list({ ...pushed(filter), ...(status === "all" ? {} : { review: status }) });
|
|
76
|
-
return kept(entries.map(spec.row), filter);
|
|
76
|
+
return kept(entries.items.map(spec.row), filter);
|
|
77
77
|
},
|
|
78
78
|
get: async (id) => spec.row(await spec.get(id)),
|
|
79
79
|
decide: async (id, { confirm, by, reason }) => {
|
|
@@ -30,7 +30,7 @@ export const sourceReviewKind = (store) => ({
|
|
|
30
30
|
ownerOnly: true,
|
|
31
31
|
list: async (filter) => {
|
|
32
32
|
const status = storedStatus(filter);
|
|
33
|
-
const stored = await store.proposedActions.list({
|
|
33
|
+
const { items: stored } = await store.proposedActions.list({
|
|
34
34
|
kinds: [SOURCE_REVIEW_KIND],
|
|
35
35
|
...(status === undefined ? {} : { status }),
|
|
36
36
|
...pushed(filter),
|
|
@@ -42,8 +42,8 @@ export const taskCloseKind = (store) => {
|
|
|
42
42
|
ownerOnly: true,
|
|
43
43
|
list: async (filter) => {
|
|
44
44
|
if ((filter.status ?? "proposed") !== "proposed" && filter.status !== "all")
|
|
45
|
-
return [];
|
|
46
|
-
const tasks = await store.tasks.find({
|
|
45
|
+
return { items: [], hasMore: false };
|
|
46
|
+
const { items: tasks } = await store.tasks.find({
|
|
47
47
|
status: "open",
|
|
48
48
|
where: { sql: "t.close_suggested_as IS NOT NULL", params: [] },
|
|
49
49
|
limit: filter.offset + filter.limit,
|
|
@@ -62,7 +62,7 @@ export const emptyProposalRegistry = (store) => {
|
|
|
62
62
|
throw new CliError("validation_error", "a proposal list takes a nonnegative offset");
|
|
63
63
|
const asked = filter.kinds === undefined ? kinds : kinds.filter((kind) => filter.kinds?.includes(kind.kind));
|
|
64
64
|
const wide = { ...filter, offset: 0, limit: filter.offset + filter.limit + 1 };
|
|
65
|
-
const rows = (await Promise.all(asked.map(async (kind) => (await kind.list(wide)).map((row) => marked(kind, row)))))
|
|
65
|
+
const rows = (await Promise.all(asked.map(async (kind) => (await kind.list(wide)).items.map((row) => marked(kind, row)))))
|
|
66
66
|
.flat()
|
|
67
67
|
.filter((row) => filter.via === undefined || row.evidence.includes(filter.via));
|
|
68
68
|
rows.sort((a, b) => b.createdAt.localeCompare(a.createdAt) || b.id.localeCompare(a.id));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
1
2
|
import type { Decider, Proposer, Refusal } from "../../store/decisions.js";
|
|
2
3
|
export interface ProposalRow {
|
|
3
4
|
/** `17070` for a stored proposal; `fact:512`, `memory:88`, `link:17` and `key:9` for the kinds kept elsewhere. */
|
|
@@ -71,7 +72,7 @@ export interface ProposalKind {
|
|
|
71
72
|
/** Only the owner decides it, whatever the host's `agent_decisions` says. */
|
|
72
73
|
readonly ownerOnly?: boolean;
|
|
73
74
|
/** Bounded: at most `offset + limit` rows, newest first. */
|
|
74
|
-
list(filter: ProposalFilter): Promise<ProposalRow
|
|
75
|
+
list(filter: ProposalFilter): Promise<ListResult<ProposalRow>>;
|
|
75
76
|
get(id: string): Promise<ProposalRow>;
|
|
76
77
|
/** Called only after `mayDecide` allowed it. */
|
|
77
78
|
decide(id: string, decision: Decision): Promise<Decided>;
|
|
@@ -11,14 +11,13 @@ export const BUSINESS_WORDS_ONLY = "invoices, payments, orders, contracts, subsc
|
|
|
11
11
|
const placeOf = ({ source, imported }) => source ?? (imported === undefined ? OWN_BUSINESS : { provider: imported, account: "" });
|
|
12
12
|
/** The `business` lane: numbers and names folded in memory, each hit titled as its ref reads everywhere else. */
|
|
13
13
|
export const searchBusiness = async (store, { words, anyWord, window, accounts, }) => {
|
|
14
|
-
const asked = Math.min(window + 1, BUSINESS_FIND_MAX);
|
|
15
14
|
const found = await store.business.find({
|
|
16
15
|
words,
|
|
17
16
|
anyWord,
|
|
18
|
-
limit:
|
|
17
|
+
limit: Math.min(window, BUSINESS_FIND_MAX),
|
|
19
18
|
...(accounts === undefined ? {} : { accounts }),
|
|
20
19
|
});
|
|
21
|
-
const page = found.
|
|
20
|
+
const page = found.items;
|
|
22
21
|
const titles = await store.refs.summaries(page.map(({ ref }) => ref));
|
|
23
22
|
return {
|
|
24
23
|
items: page.map((hit) => ({
|
|
@@ -32,7 +31,7 @@ export const searchBusiness = async (store, { words, anyWord, window, accounts,
|
|
|
32
31
|
...(hit.source === undefined ? {} : { sourceRecord: hit.source }),
|
|
33
32
|
foundBy: ["title"],
|
|
34
33
|
})),
|
|
35
|
-
hasMore: found.
|
|
34
|
+
hasMore: found.hasMore,
|
|
36
35
|
read: accounts ?? [...(await store.business.accounts()), OWN_BUSINESS],
|
|
37
36
|
};
|
|
38
37
|
};
|
|
@@ -54,7 +54,7 @@ export const titleWords = (text, refused = "deals and leads are found by the wor
|
|
|
54
54
|
const clauses = root.kind === "boolean" ? root.clauses : [{ node: root, occur: "must" }];
|
|
55
55
|
const words = clauses.map(({ node, occur }) => occur !== "must_not" &&
|
|
56
56
|
node.kind === "predicate" &&
|
|
57
|
-
node.field === "text" &&
|
|
57
|
+
(node.field === "text" || node.field === "title") &&
|
|
58
58
|
(node.operator === "term" || node.operator === "phrase")
|
|
59
59
|
? // A title holds "invoice", not the question mark of "invoice?".
|
|
60
60
|
node.value.replace(/\?+$/u, "") || node.value
|
|
@@ -249,15 +249,15 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
249
249
|
...(request.timezone === undefined ? {} : { timezone: request.timezone }),
|
|
250
250
|
...(request.env === undefined ? {} : { env: request.env }),
|
|
251
251
|
});
|
|
252
|
-
hasMore ||= found.
|
|
252
|
+
hasMore ||= found.hasMore;
|
|
253
253
|
notes = {
|
|
254
254
|
by: found.by,
|
|
255
255
|
...(found.meaning_skipped === undefined ? {} : { meaningSkipped: found.meaning_skipped }),
|
|
256
256
|
};
|
|
257
|
-
for (const hit of found.
|
|
257
|
+
for (const hit of found.items)
|
|
258
258
|
if (hit.meaning_score !== undefined)
|
|
259
259
|
cosines.set(hit.ref, hit.meaning_score);
|
|
260
|
-
lists.push(found.
|
|
260
|
+
lists.push(found.items.map((hit) => ({
|
|
261
261
|
kind: hit.kind ?? "note",
|
|
262
262
|
ref: hit.ref,
|
|
263
263
|
provider: hit.provider ?? "notes",
|
|
@@ -291,15 +291,15 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
291
291
|
...(request.timezone === undefined ? {} : { timezone: request.timezone }),
|
|
292
292
|
...(request.signal === undefined ? {} : { signal: request.signal }),
|
|
293
293
|
});
|
|
294
|
-
hasMore ||= found.
|
|
294
|
+
hasMore ||= found.hasMore;
|
|
295
295
|
events = {
|
|
296
296
|
by: found.by,
|
|
297
297
|
...(found.meaning_skipped === undefined ? {} : { meaningSkipped: found.meaning_skipped }),
|
|
298
298
|
};
|
|
299
|
-
for (const hit of found.
|
|
299
|
+
for (const hit of found.items)
|
|
300
300
|
if (hit.meaning_score !== undefined)
|
|
301
301
|
cosines.set(hit.ref, hit.meaning_score);
|
|
302
|
-
lists.push(found.
|
|
302
|
+
lists.push(found.items.map((hit) => ({
|
|
303
303
|
kind: "event",
|
|
304
304
|
ref: hit.ref,
|
|
305
305
|
provider: hit.provider ?? "calendar",
|
|
@@ -313,10 +313,6 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
313
313
|
accounts.push(...read.map(({ provider, account }) => ({ resource, provider, account })));
|
|
314
314
|
}
|
|
315
315
|
else if (resource === "crm") {
|
|
316
|
-
// `plainQuery` made `stage:won` a phrase, which would find nothing and still call the answer complete.
|
|
317
|
-
const field = /(?:^|\s)[+-]?(stage|status|pipeline):/iu.exec(asked.text)?.[1]?.toLowerCase();
|
|
318
|
-
if (field)
|
|
319
|
-
throw new CliError("validation_error", `deals and leads are not searched by ${field}; list them by it with \`deals list ${field}:<value>\``);
|
|
320
316
|
const { words, anyWord } = titleWords(request.text);
|
|
321
317
|
const chosen = scope?.crm;
|
|
322
318
|
const found = await store.deals.find({
|
|
@@ -324,11 +320,14 @@ export const searchAll = async (store, account, asked, messenger = {}, searchMes
|
|
|
324
320
|
anyWord: anyWord || discover,
|
|
325
321
|
...(request.exact ? { exact: true } : {}),
|
|
326
322
|
...(request.crmKinds === undefined ? {} : { kinds: request.crmKinds }),
|
|
327
|
-
limit: Math.min(depth
|
|
323
|
+
limit: Math.min(depth, 500),
|
|
328
324
|
...(chosen === undefined ? {} : { accounts: chosen }),
|
|
329
325
|
});
|
|
330
|
-
hasMore ||= found.
|
|
331
|
-
|
|
326
|
+
hasMore ||= found.hasMore;
|
|
327
|
+
const titled = /(?:^|[\s(+])title:/u.test(request.text);
|
|
328
|
+
lists.push(found.items
|
|
329
|
+
.filter((deal) => !titled || deal.matched.includes("title"))
|
|
330
|
+
.map((deal) => ({
|
|
332
331
|
kind: deal.kind,
|
|
333
332
|
ref: deal.ref,
|
|
334
333
|
provider: deal.account?.provider ?? "crm",
|
|
@@ -12,6 +12,11 @@ export declare const HARDER_MODELS: Readonly<Record<EnrichmentProvider, string>>
|
|
|
12
12
|
/** The search lab's setup (cli-testing search-lab, "Haiku rerank"): the top 30, each cut to 400 characters. */
|
|
13
13
|
export declare const HARDER_CANDIDATES = 30;
|
|
14
14
|
export declare const HARDER_CHARS = 400;
|
|
15
|
+
/** A hosted model answers in 1 to 2 s; a model on this computer's CPU can take tens of seconds for 30 hits. */
|
|
16
|
+
export declare const HARDER_TIMEOUT_S: {
|
|
17
|
+
readonly hosted: 5;
|
|
18
|
+
readonly local: 60;
|
|
19
|
+
};
|
|
15
20
|
declare const Setting: v.StrictObjectSchema<{
|
|
16
21
|
readonly provider: v.PicklistSchema<readonly ["openai", "anthropic"], undefined>;
|
|
17
22
|
readonly model: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 200, undefined>]>;
|
|
@@ -23,7 +28,11 @@ export type HarderSetting = v.InferOutput<typeof Setting>;
|
|
|
23
28
|
/** The owner's consent, or `undefined`: no section means `--harder` sends nothing. */
|
|
24
29
|
export declare const readHarderSetting: (env: NodeJS.ProcessEnv) => HarderSetting | undefined;
|
|
25
30
|
export declare const writeHarderSetting: (env: NodeJS.ProcessEnv, setting: HarderSetting | undefined) => void;
|
|
26
|
-
|
|
31
|
+
/** The owner's time limit in seconds, or `undefined` for the default by where the model runs. */
|
|
32
|
+
export declare const readHarderTimeout: (env: NodeJS.ProcessEnv) => number | undefined;
|
|
33
|
+
export declare const writeHarderTimeout: (env: NodeJS.ProcessEnv, seconds: number | undefined) => void;
|
|
34
|
+
export declare const harderTimeoutSeconds: (env: NodeJS.ProcessEnv, endpoint: string) => number;
|
|
35
|
+
export declare const HARDER_REASON_IDS: readonly ["harder.no-consent", "harder.no-key", "harder.bad-setting", "harder.local-only", "harder.address-refused", "harder.later-page", "harder.too-few", "harder.timeout", "harder.key-rejected", "harder.unreachable", "harder.rate-limited", "harder.bad-reply", "harder.error"];
|
|
27
36
|
export type HarderReasonId = (typeof HARDER_REASON_IDS)[number];
|
|
28
37
|
/** What `--harder` did: `applied` only when the model's order replaced the plain one. */
|
|
29
38
|
export interface HarderResult {
|
|
@@ -70,6 +79,7 @@ export type HarderAccess = {
|
|
|
70
79
|
model: string;
|
|
71
80
|
endpoint: string;
|
|
72
81
|
custom: boolean;
|
|
82
|
+
timeoutMs: number;
|
|
73
83
|
key?: string;
|
|
74
84
|
} | {
|
|
75
85
|
ready: false;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
+
import { modelAddressAllowed, onThisComputer } from "../models/endpoint.js";
|
|
3
4
|
import { modelGateway } from "../models/index.js";
|
|
5
|
+
import { localOnly } from "../models/local-only.js";
|
|
4
6
|
import { readSharedSection, writeSharedSection } from "../store/shared-config.js";
|
|
5
7
|
import { keyLookup, keyVariable } from "./enrichment.js";
|
|
6
8
|
import { costOf, enrichmentEndpoint, enrichmentSettingPath, MODEL_CHOICE, } from "./enrichment-setting.js";
|
|
@@ -16,7 +18,9 @@ export const HARDER_MODELS = {
|
|
|
16
18
|
/** The search lab's setup (cli-testing search-lab, "Haiku rerank"): the top 30, each cut to 400 characters. */
|
|
17
19
|
export const HARDER_CANDIDATES = 30;
|
|
18
20
|
export const HARDER_CHARS = 400;
|
|
19
|
-
|
|
21
|
+
/** A hosted model answers in 1 to 2 s; a model on this computer's CPU can take tens of seconds for 30 hits. */
|
|
22
|
+
export const HARDER_TIMEOUT_S = { hosted: 5, local: 60 };
|
|
23
|
+
const TIMEOUT_SECTION = "search_harder_timeout_s";
|
|
20
24
|
const Setting = v.strictObject({
|
|
21
25
|
...MODEL_CHOICE,
|
|
22
26
|
/** When the owner agreed that a `--harder` search sends its question and hits; the setting exists only with it. */
|
|
@@ -34,10 +38,22 @@ export const readHarderSetting = (env) => {
|
|
|
34
38
|
return checked.output;
|
|
35
39
|
};
|
|
36
40
|
export const writeHarderSetting = (env, setting) => writeSharedSection(enrichmentSettingPath(env), SECTION, setting === undefined ? undefined : v.parse(Setting, setting));
|
|
41
|
+
// Its own key beside search_harder: an older tool reads that section strictly and would refuse a new field in it.
|
|
42
|
+
const Timeout = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(600));
|
|
43
|
+
/** The owner's time limit in seconds, or `undefined` for the default by where the model runs. */
|
|
44
|
+
export const readHarderTimeout = (env) => {
|
|
45
|
+
const value = readSharedSection(enrichmentSettingPath(env), TIMEOUT_SECTION);
|
|
46
|
+
const checked = v.safeParse(Timeout, value);
|
|
47
|
+
return checked.success ? checked.output : undefined;
|
|
48
|
+
};
|
|
49
|
+
export const writeHarderTimeout = (env, seconds) => writeSharedSection(enrichmentSettingPath(env), TIMEOUT_SECTION, seconds === undefined ? undefined : v.parse(Timeout, seconds));
|
|
50
|
+
export const harderTimeoutSeconds = (env, endpoint) => readHarderTimeout(env) ?? (onThisComputer(endpoint) ? HARDER_TIMEOUT_S.local : HARDER_TIMEOUT_S.hosted);
|
|
37
51
|
export const HARDER_REASON_IDS = [
|
|
38
52
|
"harder.no-consent",
|
|
39
53
|
"harder.no-key",
|
|
40
54
|
"harder.bad-setting",
|
|
55
|
+
"harder.local-only",
|
|
56
|
+
"harder.address-refused",
|
|
41
57
|
"harder.later-page",
|
|
42
58
|
"harder.too-few",
|
|
43
59
|
"harder.timeout",
|
|
@@ -87,7 +103,9 @@ const REASON_TEXT = {
|
|
|
87
103
|
"harder.bad-setting": "the search_harder setting cannot be read; nothing was sent",
|
|
88
104
|
"harder.later-page": "--harder reorders the first page only; nothing was sent",
|
|
89
105
|
"harder.too-few": "fewer than two hits to reorder; nothing was sent",
|
|
90
|
-
"harder.
|
|
106
|
+
"harder.address-refused": "the address is plain http to another computer: use https, or http only on this computer; nothing was sent",
|
|
107
|
+
"harder.local-only": "local only is on and the model is not on this computer; nothing was sent",
|
|
108
|
+
"harder.timeout": "the model did not answer within the time limit",
|
|
91
109
|
"harder.key-rejected": "the provider refused the key",
|
|
92
110
|
"harder.unreachable": "the provider could not be reached",
|
|
93
111
|
"harder.rate-limited": "the provider's rate limit was reached",
|
|
@@ -135,6 +153,15 @@ export const harderAccess = ({ env, command, ...options }) => {
|
|
|
135
153
|
endpoint: enrichmentEndpoint(setting),
|
|
136
154
|
custom: setting.base_url !== undefined,
|
|
137
155
|
};
|
|
156
|
+
if (!modelAddressAllowed(chosen.endpoint))
|
|
157
|
+
return {
|
|
158
|
+
ready: false,
|
|
159
|
+
...chosen,
|
|
160
|
+
reason_id: "harder.address-refused",
|
|
161
|
+
reason: REASON_TEXT["harder.address-refused"],
|
|
162
|
+
};
|
|
163
|
+
if (!onThisComputer(chosen.endpoint) && localOnly(env))
|
|
164
|
+
return { ready: false, ...chosen, reason_id: "harder.local-only", reason: REASON_TEXT["harder.local-only"] };
|
|
138
165
|
let key;
|
|
139
166
|
try {
|
|
140
167
|
key = keyLookup({ env, ...options }, setting)?.key;
|
|
@@ -155,17 +182,23 @@ export const harderAccess = ({ env, command, ...options }) => {
|
|
|
155
182
|
reason_id: "harder.no-key",
|
|
156
183
|
reason: `no ${setting.provider} key: \`${tool} models keys set ${setting.provider}\` or set ${keyVariable(setting.provider)}; nothing was sent`,
|
|
157
184
|
};
|
|
158
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
ready: true,
|
|
187
|
+
...chosen,
|
|
188
|
+
timeoutMs: options.timeoutMs ?? harderTimeoutSeconds(env, chosen.endpoint) * 1000,
|
|
189
|
+
...(key === undefined ? {} : { key }),
|
|
190
|
+
};
|
|
159
191
|
};
|
|
160
|
-
/** One call to the model under the
|
|
192
|
+
/** One call to the model under the time limit; a failure comes back as its reason, never thrown. */
|
|
161
193
|
const ask = async (access, options, request) => {
|
|
162
194
|
const limit = new AbortController();
|
|
163
|
-
const timer = setTimeout(() => limit.abort(),
|
|
195
|
+
const timer = setTimeout(() => limit.abort(), access.timeoutMs);
|
|
164
196
|
const gateway = modelGateway({
|
|
165
197
|
resolve: () => ({ provider: access.provider, model: access.model, baseUrl: access.endpoint }),
|
|
166
198
|
consent: (_request, chosen) => chosen.provider === access.provider && chosen.baseUrl === access.endpoint,
|
|
167
199
|
key: () => access.key,
|
|
168
200
|
signal: limit.signal,
|
|
201
|
+
env: options.env,
|
|
169
202
|
...(options.adapters ? { adapters: options.adapters } : {}),
|
|
170
203
|
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
171
204
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
1
2
|
import type * as v from "valibot";
|
|
2
3
|
import type { savedSearch } from "../entities/saved-search.js";
|
|
3
4
|
import type { StoredSearch } from "../store/store.js";
|
|
@@ -19,10 +20,7 @@ export interface SearchesService {
|
|
|
19
20
|
}): Promise<StoredSearch>;
|
|
20
21
|
show(reference: string): Promise<StoredSearch>;
|
|
21
22
|
list(): Promise<StoredSearch[]>;
|
|
22
|
-
history(limit: number, offset?: number): Promise<
|
|
23
|
-
items: StoredSearch[];
|
|
24
|
-
has_more: boolean;
|
|
25
|
-
}>;
|
|
23
|
+
history(limit: number, offset?: number): Promise<ListResult<StoredSearch>>;
|
|
26
24
|
delete(reference: string): Promise<StoredSearch>;
|
|
27
25
|
clear(): Promise<{
|
|
28
26
|
cleared: number;
|
|
@@ -101,10 +101,7 @@ export const searchesService = (deps) => {
|
|
|
101
101
|
}),
|
|
102
102
|
show: (reference) => inStore((store) => found(store, reference)),
|
|
103
103
|
list: () => inStore((store) => store.searches.savedSearches(MESSAGE_SEARCH_COMMANDS)),
|
|
104
|
-
history: (limit, offset = 0) => inStore(
|
|
105
|
-
const rows = await store.searches.searchHistory(limit, offset, MESSAGE_SEARCH_COMMANDS);
|
|
106
|
-
return { items: rows.slice(0, limit), has_more: rows.length > limit };
|
|
107
|
-
}),
|
|
104
|
+
history: (limit, offset = 0) => inStore((store) => store.searches.searchHistory(limit, offset, MESSAGE_SEARCH_COMMANDS)),
|
|
108
105
|
delete: (reference) => inStore(async (store) => store.searches.deleteSearch((await found(store, reference)).id)),
|
|
109
106
|
clear: () => inStore(async (store) => ({ cleared: await store.searches.clearSearchHistory(MESSAGE_SEARCH_COMMANDS) })),
|
|
110
107
|
resolve: (reference, { text: words, ...typed }) => inStore(async (store) => {
|
|
@@ -103,7 +103,12 @@ const LINKED_CHATS = 16;
|
|
|
103
103
|
const CORE_LIMIT = 16;
|
|
104
104
|
/** Pending `member-of` proposals to the project, oldest first, so a cut at a limit always drops the same ones. */
|
|
105
105
|
const proposedLinksOf = async (store, project) => {
|
|
106
|
-
const stored = await store.proposedActions.list({
|
|
106
|
+
const { items: stored } = await store.proposedActions.list({
|
|
107
|
+
kinds: ["relationship"],
|
|
108
|
+
status: "proposed",
|
|
109
|
+
project,
|
|
110
|
+
limit: 500,
|
|
111
|
+
});
|
|
107
112
|
const proposals = stored
|
|
108
113
|
.flatMap((action) => {
|
|
109
114
|
const payload = action.payload;
|
package/dist/services/tags.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type QueryAst } from "@wirecat/cli-base/query";
|
|
2
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
2
3
|
import type * as v from "valibot";
|
|
3
4
|
import type { Id } from "../domain/models.js";
|
|
4
5
|
import { type TagType } from "../domain/tags.js";
|
|
@@ -40,10 +41,7 @@ export interface TagsService {
|
|
|
40
41
|
query?: QueryAst;
|
|
41
42
|
limit: number;
|
|
42
43
|
offset: number;
|
|
43
|
-
}): Promise<
|
|
44
|
-
items: TaggingItem[];
|
|
45
|
-
has_more: boolean;
|
|
46
|
-
}>;
|
|
44
|
+
}): Promise<ListResult<TaggingItem>>;
|
|
47
45
|
}
|
|
48
46
|
export type TaggingItem = v.InferOutput<typeof tagging>;
|
|
49
47
|
export declare const TAGGING_QUERY: {
|
package/dist/services/tags.js
CHANGED
|
@@ -98,7 +98,7 @@ export const tagsService = (deps) => {
|
|
|
98
98
|
...(where ? { where } : {}),
|
|
99
99
|
window: { limit: limit + 1, offset },
|
|
100
100
|
});
|
|
101
|
-
return { items: rows.slice(0, limit).map((one) => taggingOf(account, one)),
|
|
101
|
+
return { items: rows.slice(0, limit).map((one) => taggingOf(account, one)), hasMore: rows.length > limit };
|
|
102
102
|
}),
|
|
103
103
|
};
|
|
104
104
|
};
|
package/dist/services/tasks.d.ts
CHANGED
package/dist/services/tasks.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isLocator, parseLocator } from "../domain/locator.js";
|
|
|
4
4
|
import { formatReference } from "../domain/references.js";
|
|
5
5
|
import { task as taskEntity } from "../entities/task.js";
|
|
6
6
|
import { certaintyOf, TASK_RELATION_KINDS, } from "../store/index.js";
|
|
7
|
-
import { queryFilter } from "../store/store.js";
|
|
7
|
+
import { foldedWords, queryFilter } from "../store/store.js";
|
|
8
8
|
import { createTaskService, isClosedState, TASK_KINDS, TASK_STATES, } from "../tasks/index.js";
|
|
9
9
|
import { storedChatId } from "./message-resolution.js";
|
|
10
10
|
import { categorize, taskCategoryOf } from "./task-categories.js";
|
|
@@ -17,6 +17,7 @@ export const TASK_QUERY = {
|
|
|
17
17
|
backend: "sql",
|
|
18
18
|
fields: queryFieldsOf(taskEntity, {
|
|
19
19
|
exclude: ["ref", "description", "project", "account", "priority", "parent", "claimed_until", "close_suggestion"],
|
|
20
|
+
text: ["title"],
|
|
20
21
|
relations: {
|
|
21
22
|
close: {
|
|
22
23
|
type: "enum",
|
|
@@ -81,7 +82,7 @@ const taskColumns = (groups, tags) => ({
|
|
|
81
82
|
key: { type: "kw", sql: "t.key" },
|
|
82
83
|
category: { type: "kw", sql: "t.category" },
|
|
83
84
|
tag: { where: (node) => tags.get(node.value) ?? { sql: "0", params: [] } },
|
|
84
|
-
title:
|
|
85
|
+
title: foldedWords("t.title_folded"),
|
|
85
86
|
kind: { type: "enum", sql: "t.type" },
|
|
86
87
|
state: { type: "enum", sql: "t.status" },
|
|
87
88
|
origin: { type: "enum", sql: "t.source" },
|
|
@@ -235,7 +236,7 @@ export const tasksService = (deps, categories) => {
|
|
|
235
236
|
const shown = rows.slice(0, limit);
|
|
236
237
|
return {
|
|
237
238
|
items: shown.map((row) => taskItem(account, row)),
|
|
238
|
-
|
|
239
|
+
hasMore: rows.length > limit,
|
|
239
240
|
...(previews ? { previews: await Promise.all(shown.map(({ task }) => taskView(store, account, task))) } : {}),
|
|
240
241
|
};
|
|
241
242
|
}),
|
package/dist/speech/openai.js
CHANGED
|
@@ -2,6 +2,7 @@ import { setTimeout as wait } from "node:timers/promises";
|
|
|
2
2
|
import { backoffMs, CliError, DEFAULT_RETRY } from "@wirecat/cli-base";
|
|
3
3
|
import { providerWaitMs } from "@wirecat/cli-base/http";
|
|
4
4
|
import { OPENAI_URL } from "../embeddings/remote.js";
|
|
5
|
+
import { refuseModelAddress } from "../models/local-only.js";
|
|
5
6
|
import { filesPresent, modelsDirectory, vadPath } from "./install.js";
|
|
6
7
|
import { OPENAI_TRANSCRIBE_MODEL, VAD } from "./models.js";
|
|
7
8
|
import { SAMPLE_RATE, toModelRate } from "./recognize.js";
|
|
@@ -161,6 +162,7 @@ const checkKeywords = (keywords = []) => {
|
|
|
161
162
|
* dialogue by `start`. `gpt-transcribe` gives no timestamps of its own, so the times are the detector's.
|
|
162
163
|
*/
|
|
163
164
|
export const transcribeOpenAI = async (audio, options) => {
|
|
165
|
+
refuseModelAddress(options.env ?? process.env, options.baseUrl ?? OPENAI_URL, "audio");
|
|
164
166
|
if (!options.apiKey)
|
|
165
167
|
throw new CliError("authentication_error", "no OpenAI key — `models keys set openai`, or OPENAI_API_KEY", {
|
|
166
168
|
reason: "transcription.no-key",
|