@wirecat/cli-core 0.399.0 → 0.401.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 +111 -0
- package/README.md +1 -1
- package/dist/analysis/consents.d.ts +11 -6
- package/dist/analysis/consents.js +5 -2
- package/dist/cli/bot/mcp.js +2 -1
- package/dist/cli/bot/store.js +1 -1
- package/dist/cli/config-command.js +20 -1
- package/dist/cli/context.d.ts +2 -0
- package/dist/cli/context.js +1 -1
- package/dist/cli/effects.d.ts +4 -1
- package/dist/cli/effects.js +10 -2
- package/dist/cli/index.d.ts +3 -2
- package/dist/cli/index.js +3 -2
- package/dist/cli/json-fields.js +12 -1
- package/dist/cli/meeting-evidence-answer.d.ts +46 -0
- package/dist/cli/meeting-evidence-answer.js +22 -0
- package/dist/cli/meeting-preparation-answer.js +1 -13
- package/dist/cli/messenger/account-command.js +15 -6
- package/dist/cli/messenger/account-profile-query.d.ts +2 -0
- package/dist/cli/messenger/account-profile-query.js +13 -0
- package/dist/cli/messenger/account-sessions-command.js +1 -2
- package/dist/cli/messenger/admin-commands.js +12 -12
- package/dist/cli/messenger/admin-contacts-command.js +6 -3
- package/dist/cli/messenger/admin-folders-command.js +5 -5
- package/dist/cli/messenger/admin-moderation-command.js +4 -4
- package/dist/cli/messenger/admin-statistics-command.js +6 -14
- package/dist/cli/messenger/analysis-consents-query.d.ts +5 -0
- package/dist/cli/messenger/analysis-consents-query.js +20 -0
- package/dist/cli/messenger/archive-commands.js +3 -3
- package/dist/cli/messenger/attachments-command.js +3 -0
- package/dist/cli/messenger/backfill-command.js +5 -4
- package/dist/cli/messenger/chat-queries.d.ts +1 -0
- package/dist/cli/messenger/chat-queries.js +12 -2
- package/dist/cli/messenger/chats-command.js +2 -2
- package/dist/cli/messenger/chats-documents-command.js +7 -5
- package/dist/cli/messenger/chats-members-command.js +7 -3
- package/dist/cli/messenger/chats-read-command.js +1 -1
- package/dist/cli/messenger/chats-tracking-command.js +14 -6
- package/dist/cli/messenger/contacts-command.js +9 -5
- package/dist/cli/messenger/conversations-command.js +20 -16
- package/dist/cli/messenger/doctor-command.js +4 -1
- package/dist/cli/messenger/document-links-query.d.ts +2 -0
- package/dist/cli/messenger/document-links-query.js +9 -0
- package/dist/cli/messenger/download-command.js +1 -0
- package/dist/cli/messenger/flood-command.d.ts +2 -2
- package/dist/cli/messenger/flood-command.js +3 -3
- package/dist/cli/messenger/gaps-command.js +2 -2
- package/dist/cli/messenger/guard-commands.js +35 -13
- package/dist/cli/messenger/images-command.js +1 -0
- package/dist/cli/messenger/media-archive-command.js +2 -0
- package/dist/cli/messenger/media-archive-move-command.js +1 -0
- package/dist/cli/messenger/media-archive-timer-command.js +1 -1
- package/dist/cli/messenger/mentions-command.js +15 -2
- package/dist/cli/messenger/message-writes.d.ts +192 -2
- package/dist/cli/messenger/message-writes.js +6 -2
- package/dist/cli/messenger/messages-command.js +2 -0
- package/dist/cli/messenger/messages-delete-command.js +1 -0
- package/dist/cli/messenger/messages-edit-command.js +1 -0
- package/dist/cli/messenger/messages-evidence-command.js +3 -1
- package/dist/cli/messenger/messages-forward-command.js +1 -0
- package/dist/cli/messenger/messages-pin-command.js +3 -0
- package/dist/cli/messenger/messages-send-command.js +10 -6
- package/dist/cli/messenger/metadata-command.js +6 -1
- package/dist/cli/messenger/models-command.js +10 -5
- package/dist/cli/messenger/polls-command.js +4 -0
- package/dist/cli/messenger/private-people-command.js +3 -3
- package/dist/cli/messenger/rankings-command.js +6 -11
- package/dist/cli/messenger/reactions-command.js +2 -0
- package/dist/cli/messenger/recipients-query.d.ts +5 -0
- package/dist/cli/messenger/recipients-query.js +18 -0
- package/dist/cli/messenger/records-command.js +13 -8
- package/dist/cli/messenger/review.js +1 -1
- package/dist/cli/messenger/schedule-command.js +2 -2
- package/dist/cli/messenger/search-answers.js +2 -0
- package/dist/cli/messenger/search-command.js +3 -1
- package/dist/cli/messenger/searches-command.js +5 -1
- package/dist/cli/messenger/sends-query.d.ts +5 -0
- package/dist/cli/messenger/sends-query.js +33 -0
- package/dist/cli/messenger/serve-command.js +1 -0
- package/dist/cli/messenger/server-command.js +0 -3
- package/dist/cli/messenger/statistics-query.d.ts +14 -0
- package/dist/cli/messenger/statistics-query.js +143 -0
- package/dist/cli/messenger/stats-command.js +5 -5
- package/dist/cli/messenger/store-maintenance-command.js +10 -10
- package/dist/cli/messenger/stored.js +4 -1
- package/dist/cli/messenger/tags-command.js +7 -1
- package/dist/cli/messenger/tasks-command.js +57 -14
- package/dist/cli/messenger/transcribe-command.js +1 -0
- package/dist/cli/messenger/watch-answers.d.ts +6 -0
- package/dist/cli/messenger/watch-answers.js +69 -0
- package/dist/cli/messenger/watch-command.d.ts +1 -1
- package/dist/cli/messenger/watch-command.js +56 -7
- package/dist/cli/program.js +5 -1
- package/dist/cli/runs/command.js +25 -38
- package/dist/cli/runs/query.d.ts +5 -0
- package/dist/cli/runs/query.js +32 -0
- package/dist/cli/runs/search-command.d.ts +4 -0
- package/dist/cli/runs/search-command.js +27 -0
- package/dist/cli/runs/search-query.d.ts +4 -0
- package/dist/cli/runs/search-query.js +50 -0
- package/dist/cli/runs/search.d.ts +2 -1
- package/dist/cli/runs/search.js +6 -6
- package/dist/documents/index.d.ts +1 -0
- package/dist/documents/index.js +1 -0
- package/dist/domain/attachments.js +9 -1
- package/dist/domain/rankings-options.js +3 -3
- package/dist/entities/account-change.d.ts +89 -0
- package/dist/entities/account-change.js +20 -0
- package/dist/entities/account-profile.d.ts +7 -0
- package/dist/entities/account-profile.js +8 -0
- package/dist/entities/analysis-consent.d.ts +9 -0
- package/dist/entities/analysis-consent.js +4 -0
- package/dist/entities/attachment-results.d.ts +96 -0
- package/dist/entities/attachment-results.js +31 -0
- package/dist/entities/batch-result.d.ts +27 -0
- package/dist/entities/batch-result.js +18 -0
- package/dist/entities/chat-admin.d.ts +234 -0
- package/dist/entities/chat-admin.js +84 -0
- package/dist/entities/chat-change.d.ts +25 -0
- package/dist/entities/chat-change.js +11 -0
- package/dist/entities/chat-metadata.d.ts +34 -0
- package/dist/entities/chat-metadata.js +15 -0
- package/dist/entities/chat-moderation.d.ts +44 -0
- package/dist/entities/chat-moderation.js +37 -0
- package/dist/entities/chat-tracking.d.ts +26 -0
- package/dist/entities/chat-tracking.js +23 -0
- package/dist/entities/contact-activity.d.ts +52 -0
- package/dist/entities/contact-activity.js +42 -0
- package/dist/entities/contact-context.d.ts +1568 -0
- package/dist/entities/contact-context.js +191 -0
- package/dist/entities/contact-write.d.ts +22 -0
- package/dist/entities/contact-write.js +6 -0
- package/dist/entities/conversation-preparation.d.ts +63 -0
- package/dist/entities/conversation-preparation.js +23 -0
- package/dist/entities/conversation-results.d.ts +567 -0
- package/dist/entities/conversation-results.js +94 -0
- package/dist/entities/document-link.d.ts +13 -0
- package/dist/entities/document-link.js +11 -0
- package/dist/entities/extraction-report.d.ts +95 -0
- package/dist/entities/extraction-report.js +34 -0
- package/dist/entities/hit.d.ts +4 -0
- package/dist/entities/hit.js +4 -0
- package/dist/entities/image-embedding.d.ts +9 -0
- package/dist/entities/image-embedding.js +10 -0
- package/dist/entities/index.d.ts +8284 -1921
- package/dist/entities/index.js +178 -3
- package/dist/entities/listener.d.ts +2150 -0
- package/dist/entities/listener.js +46 -0
- package/dist/entities/media-archive.d.ts +43 -0
- package/dist/entities/media-archive.js +32 -0
- package/dist/entities/meeting-evidence.d.ts +86 -0
- package/dist/entities/meeting-evidence.js +25 -0
- package/dist/entities/meeting-preparation-parts.d.ts +14 -0
- package/dist/entities/meeting-preparation-parts.js +15 -13
- package/dist/entities/meeting-task-proposal.d.ts +14 -0
- package/dist/entities/meeting-task-proposal.js +19 -0
- package/dist/entities/meeting.d.ts +1 -1
- package/dist/entities/meeting.js +1 -1
- package/dist/entities/mention.d.ts +63 -0
- package/dist/entities/mention.js +44 -0
- package/dist/entities/message-change.d.ts +19 -0
- package/dist/entities/message-change.js +6 -0
- package/dist/entities/message-context.d.ts +617 -0
- package/dist/entities/message-context.js +20 -0
- package/dist/entities/message-read.d.ts +73 -0
- package/dist/entities/message-read.js +58 -0
- package/dist/entities/message-transfer.d.ts +379 -0
- package/dist/entities/message-transfer.js +83 -0
- package/dist/entities/message-write.d.ts +378 -0
- package/dist/entities/message-write.js +10 -0
- package/dist/entities/model-key.d.ts +14 -0
- package/dist/entities/model-key.js +10 -0
- package/dist/entities/poll.d.ts +40 -0
- package/dist/entities/poll.js +16 -0
- package/dist/entities/private-contact.d.ts +10 -0
- package/dist/entities/private-contact.js +4 -0
- package/dist/entities/reaction-change.d.ts +7 -0
- package/dist/entities/reaction-change.js +8 -0
- package/dist/entities/recipient.d.ts +29 -0
- package/dist/entities/recipient.js +11 -0
- package/dist/entities/recorded-run.d.ts +103 -0
- package/dist/entities/recorded-run.js +44 -0
- package/dist/entities/saved-search.d.ts +4 -0
- package/dist/entities/saved-search.js +2 -0
- package/dist/entities/send-attempt.d.ts +31 -0
- package/dist/entities/send-attempt.js +29 -0
- package/dist/entities/store-maintenance.d.ts +319 -0
- package/dist/entities/store-maintenance.js +145 -0
- package/dist/entities/store-records.d.ts +442 -0
- package/dist/entities/store-records.js +99 -0
- package/dist/entities/tag-change.d.ts +74 -0
- package/dist/entities/tag-change.js +31 -0
- package/dist/entities/task-pair.d.ts +31 -0
- package/dist/entities/task-pair.js +23 -0
- package/dist/entities/task-results.d.ts +524 -0
- package/dist/entities/task-results.js +142 -0
- package/dist/errors/reasons.js +3 -0
- package/dist/mcp/agent.d.ts +3 -1
- package/dist/mcp/agent.js +17 -10
- package/dist/mcp/bot/server.d.ts +2 -0
- package/dist/mcp/bot/server.js +1 -0
- package/dist/mcp/server.js +3 -1
- package/dist/mcp/tools/attachments.js +1 -0
- package/dist/meetings/cli/index.js +4 -2
- package/dist/meetings/cli/passage.js +1 -0
- package/dist/meetings/index.d.ts +2 -1
- package/dist/meetings/index.js +1 -0
- package/dist/meetings/links.d.ts +16 -0
- package/dist/meetings/read-answers.d.ts +185 -0
- package/dist/meetings/read-answers.js +213 -0
- package/dist/ports/messenger.d.ts +10 -1
- package/dist/runs/run.d.ts +10 -2
- package/dist/runs/run.js +11 -3
- package/dist/sends/guard.d.ts +1 -1
- package/dist/sends/guard.js +9 -5
- package/dist/sends/journal.d.ts +9 -2
- package/dist/sends/journal.js +9 -2
- package/dist/sends/permissions.d.ts +5 -1
- package/dist/sends/permissions.js +42 -2
- package/dist/sends/recipients.d.ts +8 -0
- package/dist/sends/recipients.js +9 -0
- package/dist/sends/upload.d.ts +4 -4
- package/dist/sends/upload.js +24 -20
- package/dist/services/admin-statistics.js +3 -3
- package/dist/services/chat-documents.d.ts +1 -0
- package/dist/services/chat-documents.js +9 -3
- package/dist/services/chats.d.ts +1 -1
- package/dist/services/chats.js +5 -2
- package/dist/services/documents/mirrors.d.ts +98 -0
- package/dist/services/documents/mirrors.js +144 -0
- package/dist/services/meeting-links.d.ts +2 -17
- package/dist/services/messages.js +1 -0
- package/dist/services/search-all-meetings.js +21 -8
- package/dist/services/task-rules.d.ts +1 -1
- package/dist/services/tasks.d.ts +2 -2
- package/dist/services/tasks.js +1 -1
- package/dist/store/exports.d.ts +1 -1
- package/dist/store/exports.js +1 -1
- package/dist/store/messages.d.ts +3 -1
- package/dist/store/messages.js +2 -2
- package/dist/store/roster.d.ts +4 -1
- package/dist/store/roster.js +2 -2
- package/dist/store/sqlite/chats.d.ts +12 -0
- package/dist/store/sqlite/chats.js +1 -0
- package/dist/store/sqlite/document-links.d.ts +1 -1
- package/dist/store/sqlite/document-links.js +5 -5
- package/dist/store/sqlite/drizzle/bun.js +3 -3
- package/dist/store/sqlite/drizzle/bun.js.map +1 -1
- package/dist/store/sqlite/drizzle/core.js +2 -2
- package/dist/store/sqlite/drizzle/core.js.map +1 -1
- package/dist/store/sqlite/drizzle/node.js +3 -3
- package/dist/store/sqlite/drizzle/node.js.map +1 -1
- package/dist/store/sqlite/drizzle/{shared-O7CTKP45.js → shared-HKXF6HKX.js} +57 -57
- package/dist/store/sqlite/drizzle/{shared-O7CTKP45.js.map → shared-HKXF6HKX.js.map} +1 -1
- package/dist/store/sqlite/involvements.js +2 -1
- package/dist/store/sqlite/roster.d.ts +2 -1
- package/dist/store/sqlite/roster.js +3 -2
- package/package.json +2 -2
- package/parity.json +14 -69
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineQuery, parseLucene, queryError, validateQuery } from "@wirecat/cli-base/query";
|
|
2
|
+
import { LIST_QUERY_GUIDE, termField, typedQuery } from "../list-query.js";
|
|
3
|
+
export const RUN_SEARCH_QUERY = defineQuery({
|
|
4
|
+
entity: "run",
|
|
5
|
+
backend: "native",
|
|
6
|
+
fields: [
|
|
7
|
+
termField("text", "kw", "text:timeout"),
|
|
8
|
+
termField("status", "enum", "status:failed", { values: ["success", "failed", "partial", "running"] }),
|
|
9
|
+
termField("error_code", "kw", "error_code:rate_limited"),
|
|
10
|
+
termField("operation", "kw", "operation:messages.download"),
|
|
11
|
+
termField("profile", "kw", "profile:work"),
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
export const runSearchFilter = (words) => {
|
|
15
|
+
const text = typedQuery(words).trim();
|
|
16
|
+
if (!text)
|
|
17
|
+
return {};
|
|
18
|
+
const context = { command: "search runs", guide: LIST_QUERY_GUIDE };
|
|
19
|
+
const ast = parseLucene(text, { defaultField: "text", ...context });
|
|
20
|
+
validateQuery(ast, RUN_SEARCH_QUERY, context);
|
|
21
|
+
const terms = [];
|
|
22
|
+
const fields = new Map();
|
|
23
|
+
const add = (node) => {
|
|
24
|
+
if (node.kind === "boolean") {
|
|
25
|
+
for (const clause of node.clauses) {
|
|
26
|
+
if (clause.occur !== "must")
|
|
27
|
+
queryError("query.unsupported-placement", clause.node.span, "run search takes terms joined by AND", context);
|
|
28
|
+
add(clause.node);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (node.operator !== "term" && node.operator !== "phrase")
|
|
33
|
+
queryError("query.unsupported-placement", node.span, "run search takes literal words and field:value terms", context);
|
|
34
|
+
if (node.field === "text")
|
|
35
|
+
terms.push(node.value);
|
|
36
|
+
else {
|
|
37
|
+
if (fields.has(node.field))
|
|
38
|
+
queryError("query.unsupported-placement", node.span, `${node.field} only once here`, context);
|
|
39
|
+
fields.set(node.field, node.value);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
add(ast.root);
|
|
43
|
+
return {
|
|
44
|
+
...(terms.length ? { terms } : {}),
|
|
45
|
+
...(fields.has("status") ? { status: fields.get("status")?.toLowerCase() } : {}),
|
|
46
|
+
...(fields.has("error_code") ? { errorCode: fields.get("error_code") } : {}),
|
|
47
|
+
...(fields.has("operation") ? { operation: fields.get("operation") } : {}),
|
|
48
|
+
...(fields.has("profile") ? { profile: fields.get("profile") } : {}),
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface RunSearch {
|
|
2
2
|
query?: string;
|
|
3
|
+
terms?: readonly string[];
|
|
3
4
|
status?: "success" | "failed" | "partial" | "running";
|
|
4
5
|
errorCode?: string;
|
|
5
6
|
operation?: string;
|
|
@@ -8,7 +9,7 @@ export interface RunSearch {
|
|
|
8
9
|
limit?: number;
|
|
9
10
|
page?: number;
|
|
10
11
|
}
|
|
11
|
-
export declare const searchRuns: (dir: string, { query, status, errorCode, operation, profile, since, limit, page }?: RunSearch) => {
|
|
12
|
+
export declare const searchRuns: (dir: string, { query, terms, status, errorCode, operation, profile, since, limit, page }?: RunSearch) => {
|
|
12
13
|
items: {
|
|
13
14
|
runId: string;
|
|
14
15
|
command: string;
|
package/dist/cli/runs/search.js
CHANGED
|
@@ -32,14 +32,14 @@ const safeEvent = (event) => Object.fromEntries(FIELDS.flatMap((name) => {
|
|
|
32
32
|
}
|
|
33
33
|
return typeof value === "string" || typeof value === "number" ? [[name, value]] : [];
|
|
34
34
|
}));
|
|
35
|
-
export const searchRuns = (dir, { query = "", status, errorCode, operation, profile, since, limit = 20, page = 1 } = {}) => {
|
|
35
|
+
export const searchRuns = (dir, { query = "", terms = [], status, errorCode, operation, profile, since, limit = 20, page = 1 } = {}) => {
|
|
36
36
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100 || !Number.isSafeInteger(page) || page < 1)
|
|
37
37
|
throw new CliError("validation_error", "run search uses a limit from 1 to 100 and a positive page");
|
|
38
38
|
const window = dateWindow(since === undefined ? {} : { sinceTime: since });
|
|
39
39
|
const from = window.since;
|
|
40
40
|
if (from !== undefined && !Number.isFinite(from))
|
|
41
41
|
throw new CliError("validation_error", "--since-time must be a valid date or ISO timestamp");
|
|
42
|
-
const
|
|
42
|
+
const needles = [...(query ? [query] : []), ...terms].map((term) => term.toLowerCase());
|
|
43
43
|
const offset = (page - 1) * limit;
|
|
44
44
|
const matches = [];
|
|
45
45
|
for (const run of listRuns(dir, from === undefined ? {} : { since: from })) {
|
|
@@ -51,11 +51,11 @@ export const searchRuns = (dir, { query = "", status, errorCode, operation, prof
|
|
|
51
51
|
run.errorCode === errorCode ||
|
|
52
52
|
run.partial?.failures.some((failure) => failure.errorCode === errorCode)) &&
|
|
53
53
|
!operation &&
|
|
54
|
-
(
|
|
54
|
+
needles.every((needle) => JSON.stringify(run).toLowerCase().includes(needle));
|
|
55
55
|
// A finished run lists its operations and codes, so a run that cannot match is never opened.
|
|
56
56
|
// One still running, or killed, has no such list and is read.
|
|
57
57
|
const ruledOut = !metadataMatch &&
|
|
58
|
-
|
|
58
|
+
needles.length === 0 &&
|
|
59
59
|
((operation !== undefined && run.operations !== undefined && !run.operations.includes(operation)) ||
|
|
60
60
|
(errorCode !== undefined && run.codes !== undefined && !run.codes.includes(errorCode)));
|
|
61
61
|
if (ruledOut)
|
|
@@ -64,7 +64,7 @@ export const searchRuns = (dir, { query = "", status, errorCode, operation, prof
|
|
|
64
64
|
const events = found ? readEvents(found.dir).map(safeEvent) : [];
|
|
65
65
|
const filtered = events.filter((event) => (!errorCode || event.error_code === errorCode || event.code === errorCode) &&
|
|
66
66
|
(!operation || event.operation === operation) &&
|
|
67
|
-
(
|
|
67
|
+
needles.every((needle) => JSON.stringify(event).toLowerCase().includes(needle)));
|
|
68
68
|
if (!metadataMatch && filtered.length === 0)
|
|
69
69
|
continue;
|
|
70
70
|
const metadata = {
|
|
@@ -110,7 +110,7 @@ export const searchRuns = (dir, { query = "", status, errorCode, operation, prof
|
|
|
110
110
|
};
|
|
111
111
|
};
|
|
112
112
|
/** A page of `searchRuns` in the list envelope; `args` are the search's own, so `page.next` reruns it. */
|
|
113
|
-
export const runsFound = (found, args) => listOf("runs
|
|
113
|
+
export const runsFound = (found, args) => listOf("search runs", {
|
|
114
114
|
items: found.items.map(snakeKeys),
|
|
115
115
|
limit: found.limit,
|
|
116
116
|
has_more: found.hasMore,
|
|
@@ -3,6 +3,7 @@ export { type Complete, extractMemories } from "../services/documents/extraction
|
|
|
3
3
|
export { documentIngestion, type IngestionOptions } from "../services/documents/ingestion.js";
|
|
4
4
|
export { type DocumentKnowledge, documentKnowledge } from "../services/documents/knowledge.js";
|
|
5
5
|
export { blocksMarkdown, inlineMarkdown, spliceMarkdown } from "../services/documents/markdown-splice.js";
|
|
6
|
+
export { conflictReport, fileMirrorState, type Mirror, type MirrorSyncOptions, mirrorId, mirrorStatus, syncMirrors, } from "../services/documents/mirrors.js";
|
|
6
7
|
export type { SyncOptions } from "../services/documents/ports.js";
|
|
7
8
|
export { extractDocumentMemories, type ImportedSource, type ProposalOptions } from "../services/documents/proposals.js";
|
|
8
9
|
export { type PushConflict, type PushOptions, type PushResult, planPush, pushDocuments, scanLocal, } from "../services/documents/push.js";
|
package/dist/documents/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { extractMemories } from "../services/documents/extraction.js";
|
|
|
3
3
|
export { documentIngestion } from "../services/documents/ingestion.js";
|
|
4
4
|
export { documentKnowledge } from "../services/documents/knowledge.js";
|
|
5
5
|
export { blocksMarkdown, inlineMarkdown, spliceMarkdown } from "../services/documents/markdown-splice.js";
|
|
6
|
+
export { conflictReport, fileMirrorState, mirrorId, mirrorStatus, syncMirrors, } from "../services/documents/mirrors.js";
|
|
6
7
|
export { extractDocumentMemories } from "../services/documents/proposals.js";
|
|
7
8
|
export { planPush, pushDocuments, scanLocal, } from "../services/documents/push.js";
|
|
8
9
|
export { syncDocuments } from "../services/documents/sync.js";
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/** Attachments that are never a file, so their messages cost no download request. */
|
|
2
|
-
export const NOT_FILES = new Set([
|
|
2
|
+
export const NOT_FILES = new Set([
|
|
3
|
+
"webpage",
|
|
4
|
+
"share",
|
|
5
|
+
"poll",
|
|
6
|
+
"location",
|
|
7
|
+
"contact",
|
|
8
|
+
"control",
|
|
9
|
+
"inline_keyboard",
|
|
10
|
+
]);
|
|
3
11
|
/** The stored kinds `has:<kind>` matches: MAX stores a file as `file`, Telegram as `document`. */
|
|
4
12
|
export const storedKinds = (kind) => (kind === "file" ? ["file", "document"] : [kind]);
|
|
5
13
|
/**
|
|
@@ -33,11 +33,11 @@ export const rankingOptions = (target, input) => {
|
|
|
33
33
|
const { measure, score, weights: given, minMessages } = input;
|
|
34
34
|
const messageKind = input.messageKind ?? "all";
|
|
35
35
|
if (!["all", "posts", "comments"].includes(messageKind))
|
|
36
|
-
invalid("
|
|
36
|
+
invalid("message_kind takes all, posts or comments");
|
|
37
37
|
if (target === "messages" && minMessages !== undefined)
|
|
38
|
-
invalid("
|
|
38
|
+
invalid("min_messages applies to stats contacts top");
|
|
39
39
|
if (minMessages !== undefined && (!Number.isSafeInteger(minMessages) || minMessages < 1))
|
|
40
|
-
invalid("
|
|
40
|
+
invalid("min_messages takes a positive integer");
|
|
41
41
|
if (measure !== undefined && !measures.includes(measure))
|
|
42
42
|
invalid(`--measure takes ${measures.join(", ")}`);
|
|
43
43
|
if (measure !== undefined && (score !== undefined || given !== undefined))
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const accountChange: v.StrictObjectSchema<{
|
|
3
|
+
readonly operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4
|
+
readonly account: Omit<v.StrictObjectSchema<{
|
|
5
|
+
readonly provider: v.StringSchema<undefined>;
|
|
6
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
7
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
8
|
+
readonly username: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
9
|
+
readonly phone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
10
|
+
readonly scope: v.OptionalSchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
|
|
11
|
+
}, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
|
|
12
|
+
readonly entries: Omit<{
|
|
13
|
+
readonly provider: v.StringSchema<undefined>;
|
|
14
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
15
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
16
|
+
readonly username: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
17
|
+
readonly phone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
18
|
+
readonly scope: v.OptionalSchema<v.PicklistSchema<["personal", "work"], undefined>, undefined>;
|
|
19
|
+
}, "provider" | "scope">;
|
|
20
|
+
readonly "~standard": v.StandardProps<{
|
|
21
|
+
id: string;
|
|
22
|
+
name: string | null;
|
|
23
|
+
username: string | null;
|
|
24
|
+
phone?: string | null | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string | null;
|
|
28
|
+
username: string | null;
|
|
29
|
+
phone?: string | null | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
32
|
+
id: string;
|
|
33
|
+
name: string | null;
|
|
34
|
+
username: string | null;
|
|
35
|
+
phone?: string | null | undefined;
|
|
36
|
+
}, v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.StringIssue>;
|
|
37
|
+
readonly "~types"?: {
|
|
38
|
+
readonly input: {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string | null;
|
|
41
|
+
username: string | null;
|
|
42
|
+
phone?: string | null | undefined;
|
|
43
|
+
};
|
|
44
|
+
readonly output: {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string | null;
|
|
47
|
+
username: string | null;
|
|
48
|
+
phone?: string | null | undefined;
|
|
49
|
+
};
|
|
50
|
+
readonly issue: v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.StringIssue;
|
|
51
|
+
} | undefined;
|
|
52
|
+
};
|
|
53
|
+
}, undefined>;
|
|
54
|
+
export declare const endedAccountSessions: v.StrictObjectSchema<{
|
|
55
|
+
readonly operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
56
|
+
readonly sessions: v.ArraySchema<v.StrictObjectSchema<{
|
|
57
|
+
readonly current: v.BooleanSchema<undefined>;
|
|
58
|
+
readonly client: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
59
|
+
readonly device: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
60
|
+
readonly location: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly last_active_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
62
|
+
readonly created_at: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>, undefined>;
|
|
63
|
+
}, undefined>, undefined>;
|
|
64
|
+
}, undefined>;
|
|
65
|
+
export declare const accountPrivacy: v.StrictObjectSchema<{
|
|
66
|
+
readonly find_by_phone: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
67
|
+
readonly phone_number: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
68
|
+
readonly calls: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
69
|
+
readonly chat_invites: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
70
|
+
readonly hide_online: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
71
|
+
readonly read_receipts: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
72
|
+
readonly profile_photo: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
73
|
+
readonly about: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
74
|
+
readonly last_seen: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
75
|
+
}, undefined>;
|
|
76
|
+
export declare const accountPrivacyChange: v.StrictObjectSchema<{
|
|
77
|
+
readonly operation_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
78
|
+
readonly privacy: v.StrictObjectSchema<{
|
|
79
|
+
readonly find_by_phone: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
80
|
+
readonly phone_number: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
81
|
+
readonly calls: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
82
|
+
readonly chat_invites: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody"], undefined>, undefined>;
|
|
83
|
+
readonly hide_online: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
84
|
+
readonly read_receipts: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
85
|
+
readonly profile_photo: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
86
|
+
readonly about: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
87
|
+
readonly last_seen: v.OptionalSchema<v.PicklistSchema<["everyone", "contacts", "nobody", "contacts_except"], undefined>, undefined>;
|
|
88
|
+
}, undefined>;
|
|
89
|
+
}, undefined>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { account } from "./account.js";
|
|
3
|
+
import { accountSession } from "./account-session.js";
|
|
4
|
+
import { id } from "./fields.js";
|
|
5
|
+
export const accountChange = v.strictObject({ operation_id: id, account: v.omit(account, ["provider", "scope"]) });
|
|
6
|
+
export const endedAccountSessions = v.strictObject({ operation_id: id, sessions: v.array(accountSession) });
|
|
7
|
+
const audience = v.picklist(["everyone", "contacts", "nobody"]);
|
|
8
|
+
const shownAudience = v.picklist(["everyone", "contacts", "nobody", "contacts_except"]);
|
|
9
|
+
export const accountPrivacy = v.strictObject({
|
|
10
|
+
find_by_phone: v.optional(audience),
|
|
11
|
+
phone_number: v.optional(audience),
|
|
12
|
+
calls: v.optional(audience),
|
|
13
|
+
chat_invites: v.optional(audience),
|
|
14
|
+
hide_online: v.optional(v.boolean()),
|
|
15
|
+
read_receipts: v.optional(v.boolean()),
|
|
16
|
+
profile_photo: v.optional(shownAudience),
|
|
17
|
+
about: v.optional(shownAudience),
|
|
18
|
+
last_seen: v.optional(shownAudience),
|
|
19
|
+
});
|
|
20
|
+
export const accountPrivacyChange = v.strictObject({ operation_id: id, privacy: accountPrivacy });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const accountProfile: v.StrictObjectSchema<{
|
|
3
|
+
readonly profile: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4
|
+
readonly current: v.BooleanSchema<undefined>;
|
|
5
|
+
readonly account: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
|
|
6
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
7
|
+
}, undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const analysisConsent: v.StrictObjectSchema<{
|
|
3
|
+
readonly chat: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4
|
+
readonly provider: v.StringSchema<undefined>;
|
|
5
|
+
readonly at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export declare const analysisConsentRevocation: v.StrictObjectSchema<{
|
|
8
|
+
readonly revoked: v.BooleanSchema<undefined>;
|
|
9
|
+
}, undefined>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/** Resource/image MCP responses put bytes in a separate content block; CLI JSON carries base64 here. */
|
|
3
|
+
export declare const attachmentBytes: v.StrictObjectSchema<{
|
|
4
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5
|
+
readonly attachment: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
6
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
7
|
+
readonly mime_type: v.StringSchema<undefined>;
|
|
8
|
+
readonly total_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
9
|
+
readonly sha256: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
10
|
+
readonly offset_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
11
|
+
readonly read_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
12
|
+
readonly next_offset_bytes: v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
13
|
+
readonly complete: v.BooleanSchema<undefined>;
|
|
14
|
+
readonly base64: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
15
|
+
readonly pdf: v.OptionalSchema<v.StrictObjectSchema<{
|
|
16
|
+
readonly page: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
17
|
+
readonly page_count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
18
|
+
readonly source_sha256: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
|
|
19
|
+
readonly source_bytes: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
20
|
+
}, undefined>, undefined>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
/** JSON reports all files and totals; JSONL streams each extraction item. */
|
|
23
|
+
export declare const attachmentExtraction: v.UnionSchema<[v.StrictObjectSchema<{
|
|
24
|
+
readonly extracted: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
25
|
+
readonly failed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
26
|
+
readonly needs_agent: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
27
|
+
readonly complete: v.BooleanSchema<undefined>;
|
|
28
|
+
readonly batch: v.OptionalSchema<v.StrictObjectSchema<{
|
|
29
|
+
readonly attempted: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
30
|
+
readonly succeeded: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
31
|
+
readonly failed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
32
|
+
readonly error_rate: v.NumberSchema<undefined>;
|
|
33
|
+
readonly failures: v.ArraySchema<v.StrictObjectSchema<{
|
|
34
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
35
|
+
readonly stage: v.StringSchema<undefined>;
|
|
36
|
+
readonly error: v.ObjectWithRestSchema<{
|
|
37
|
+
readonly code: v.StringSchema<undefined>;
|
|
38
|
+
readonly message: v.StringSchema<undefined>;
|
|
39
|
+
readonly retryable: v.BooleanSchema<undefined>;
|
|
40
|
+
readonly retry_after_ms: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
41
|
+
}, v.UnknownSchema, undefined>;
|
|
42
|
+
readonly attachment: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
43
|
+
}, undefined>, undefined>;
|
|
44
|
+
readonly stop_reason: v.OptionalSchema<v.PicklistSchema<["rate_limited", "authentication", "error_rate", "cancelled"], undefined>, undefined>;
|
|
45
|
+
readonly max_error_percent: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
46
|
+
}, undefined>, undefined>;
|
|
47
|
+
readonly unchanged: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
48
|
+
readonly not_downloaded: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
49
|
+
readonly unsupported: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
50
|
+
readonly engines_missing: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
51
|
+
readonly cursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
52
|
+
readonly files: v.ArraySchema<v.StrictObjectSchema<{
|
|
53
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
54
|
+
readonly attachment: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
55
|
+
readonly kind: v.StringSchema<undefined>;
|
|
56
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
57
|
+
readonly status: v.PicklistSchema<["extracted", "needs-agent", "unreadable", "engine-missing", "too-large", "missing"], undefined>;
|
|
58
|
+
readonly extractor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
59
|
+
readonly chars: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
60
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly pages: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
62
|
+
readonly ocr_pages: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
63
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
64
|
+
readonly issue: v.OptionalSchema<v.ObjectWithRestSchema<{
|
|
65
|
+
readonly code: v.StringSchema<undefined>;
|
|
66
|
+
readonly message: v.StringSchema<undefined>;
|
|
67
|
+
readonly retryable: v.BooleanSchema<undefined>;
|
|
68
|
+
readonly retry_after_ms: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
69
|
+
}, v.UnknownSchema, undefined>, undefined>;
|
|
70
|
+
}, undefined>, undefined>;
|
|
71
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
72
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
73
|
+
readonly attachment: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
74
|
+
readonly kind: v.StringSchema<undefined>;
|
|
75
|
+
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
+
readonly status: v.PicklistSchema<["extracted", "needs-agent", "unreadable", "engine-missing", "too-large", "missing"], undefined>;
|
|
77
|
+
readonly extractor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
78
|
+
readonly chars: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
79
|
+
readonly local_path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
80
|
+
readonly pages: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
81
|
+
readonly ocr_pages: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
82
|
+
readonly error: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
83
|
+
readonly issue: v.OptionalSchema<v.ObjectWithRestSchema<{
|
|
84
|
+
readonly code: v.StringSchema<undefined>;
|
|
85
|
+
readonly message: v.StringSchema<undefined>;
|
|
86
|
+
readonly retryable: v.BooleanSchema<undefined>;
|
|
87
|
+
readonly retry_after_ms: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
88
|
+
}, v.UnknownSchema, undefined>, undefined>;
|
|
89
|
+
}, undefined>], undefined>;
|
|
90
|
+
export declare const attachmentTextChange: v.StrictObjectSchema<{
|
|
91
|
+
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
92
|
+
readonly attachment: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
93
|
+
readonly origin: v.LiteralSchema<"agent", undefined>;
|
|
94
|
+
readonly chars: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
95
|
+
readonly replaced: v.NullableSchema<v.PicklistSchema<["extracted", "agent"], undefined>, undefined>;
|
|
96
|
+
}, undefined>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { extractionItem, extractionReport } from "./extraction-report.js";
|
|
3
|
+
import { count, reference, text } from "./fields.js";
|
|
4
|
+
const fingerprint = v.pipe(text, v.regex(/^[a-f0-9]{64}$/));
|
|
5
|
+
/** Resource/image MCP responses put bytes in a separate content block; CLI JSON carries base64 here. */
|
|
6
|
+
export const attachmentBytes = v.strictObject({
|
|
7
|
+
ref: reference,
|
|
8
|
+
attachment: count,
|
|
9
|
+
name: v.nullable(text),
|
|
10
|
+
mime_type: text,
|
|
11
|
+
total_bytes: count,
|
|
12
|
+
sha256: fingerprint,
|
|
13
|
+
offset_bytes: count,
|
|
14
|
+
read_bytes: count,
|
|
15
|
+
next_offset_bytes: v.nullable(count),
|
|
16
|
+
complete: v.boolean(),
|
|
17
|
+
base64: v.optional(text),
|
|
18
|
+
pdf: v.optional(v.strictObject({ page: count, page_count: count, source_sha256: fingerprint, source_bytes: count })),
|
|
19
|
+
});
|
|
20
|
+
/** JSON reports all files and totals; JSONL streams each extraction item. */
|
|
21
|
+
export const attachmentExtraction = v.union([
|
|
22
|
+
v.strictObject({ ...v.omit(extractionReport, ["items"]).entries, files: v.array(extractionItem) }),
|
|
23
|
+
extractionItem,
|
|
24
|
+
]);
|
|
25
|
+
export const attachmentTextChange = v.strictObject({
|
|
26
|
+
ref: reference,
|
|
27
|
+
attachment: count,
|
|
28
|
+
origin: v.literal("agent"),
|
|
29
|
+
chars: count,
|
|
30
|
+
replaced: v.nullable(v.picklist(["extracted", "agent"])),
|
|
31
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/** Per-item recovery retains the diagnostic fields the provider supplied. */
|
|
3
|
+
export declare const actionableError: v.ObjectWithRestSchema<{
|
|
4
|
+
readonly code: v.StringSchema<undefined>;
|
|
5
|
+
readonly message: v.StringSchema<undefined>;
|
|
6
|
+
readonly retryable: v.BooleanSchema<undefined>;
|
|
7
|
+
readonly retry_after_ms: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
8
|
+
}, v.UnknownSchema, undefined>;
|
|
9
|
+
export declare const batchResult: v.StrictObjectSchema<{
|
|
10
|
+
readonly attempted: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
11
|
+
readonly succeeded: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
12
|
+
readonly failed: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
13
|
+
readonly error_rate: v.NumberSchema<undefined>;
|
|
14
|
+
readonly failures: v.ArraySchema<v.StrictObjectSchema<{
|
|
15
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
16
|
+
readonly stage: v.StringSchema<undefined>;
|
|
17
|
+
readonly error: v.ObjectWithRestSchema<{
|
|
18
|
+
readonly code: v.StringSchema<undefined>;
|
|
19
|
+
readonly message: v.StringSchema<undefined>;
|
|
20
|
+
readonly retryable: v.BooleanSchema<undefined>;
|
|
21
|
+
readonly retry_after_ms: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
22
|
+
}, v.UnknownSchema, undefined>;
|
|
23
|
+
readonly attachment: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
24
|
+
}, undefined>, undefined>;
|
|
25
|
+
readonly stop_reason: v.OptionalSchema<v.PicklistSchema<["rate_limited", "authentication", "error_rate", "cancelled"], undefined>, undefined>;
|
|
26
|
+
readonly max_error_percent: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
27
|
+
}, undefined>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { count, id, text } from "./fields.js";
|
|
3
|
+
/** Per-item recovery retains the diagnostic fields the provider supplied. */
|
|
4
|
+
export const actionableError = v.objectWithRest({
|
|
5
|
+
code: text,
|
|
6
|
+
message: text,
|
|
7
|
+
retryable: v.boolean(),
|
|
8
|
+
retry_after_ms: v.optional(v.number()),
|
|
9
|
+
}, v.unknown());
|
|
10
|
+
export const batchResult = v.strictObject({
|
|
11
|
+
attempted: count,
|
|
12
|
+
succeeded: count,
|
|
13
|
+
failed: count,
|
|
14
|
+
error_rate: v.number(),
|
|
15
|
+
failures: v.array(v.strictObject({ id, stage: text, error: actionableError, attachment: v.optional(count) })),
|
|
16
|
+
stop_reason: v.optional(v.picklist(["rate_limited", "authentication", "error_rate", "cancelled"])),
|
|
17
|
+
max_error_percent: count,
|
|
18
|
+
});
|