@wirecat/cli-core 0.744.0 → 0.746.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 +42 -0
- package/dist/cli/bot/api.js +2 -0
- package/dist/cli/compact.js +5 -0
- package/dist/cli/documents/file-conflicts.js +2 -2
- package/dist/cli/documents/file-mirrors.js +24 -3
- package/dist/cli/documents/index.d.ts +1 -1
- package/dist/cli/documents/index.js +1 -1
- package/dist/cli/documents/knowledge.js +7 -15
- package/dist/cli/documents/words.d.ts +2 -2
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/messenger/account-command.js +4 -43
- package/dist/cli/messenger/session-commands.d.ts +9 -0
- package/dist/cli/messenger/session-commands.js +98 -0
- package/dist/cli/program.js +4 -1
- package/dist/cli/shared-command-exports.d.ts +1 -0
- package/dist/cli/shared-command-exports.js +2 -0
- package/dist/cli/untrusted-marks.d.ts +25 -3
- package/dist/cli/untrusted-marks.js +53 -6
- package/dist/search/respell.d.ts +8 -2
- package/dist/search/respell.js +72 -7
- package/dist/store/sqlite/memories.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,48 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.746.0 — 24.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`messengerSessionCommands(messenger)` gives a messenger `session status` and `session list`** (WC-ACCT-12), to
|
|
13
|
+
mount beside its own `session start` and `session end`. `session list` takes no profile and answers what
|
|
14
|
+
`account list` answers, from this computer alone. `session status` says whether the profile has a session here and
|
|
15
|
+
the account it was logged in as; `--check` asks the messenger whose the session is, without the phone number.
|
|
16
|
+
`account list` stays as it is.
|
|
17
|
+
- **`*` in an untrusted path, for an object whose keys differ.** `properties.*.name` marks `name` under each property,
|
|
18
|
+
and `properties.*` every string under `properties`, at any depth. `API_UNTRUSTED`, for a CLI's own raw call such as
|
|
19
|
+
`api call`, is exported from `@wirecat/cli-core/documents/cli` ([DOCUMENTS.md](docs/dev/DOCUMENTS.md)).
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **Every `api <operation>` answer, `mirrors preview` and `mirrors conflicts list` are marked untrusted for a
|
|
24
|
+
scheduled agent.** In a run locked read-only with a mark, each generated `api` operation marks every string of the
|
|
25
|
+
provider's answer, with no code in the CLI; an object's keys stay as they are. `mirrors preview` marks the files its
|
|
26
|
+
plan names and `mirrors conflicts list` each conflict's path. Elsewhere the answers are unchanged. A CLI that wrapped
|
|
27
|
+
its `api` operations with its own list now has it added to every string ([DOCUMENTS.md](docs/dev/DOCUMENTS.md)). A marked text cut short in compact
|
|
28
|
+
output keeps its closing marker.
|
|
29
|
+
- **A marked value an agent copies into the next command works.** A locked run takes each block of its own mark off
|
|
30
|
+
the command's arguments, so a marked id, path or property name reads as the text inside. A block of another mark
|
|
31
|
+
stays as typed. A body read from a file or stdin is not changed.
|
|
32
|
+
|
|
33
|
+
## 0.745.0 — 24.11.2026
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- `search all` and `deals list` find a CRM record whose Cyrillic name is typed in Latin: `finpoint` and `finpoynt` find
|
|
38
|
+
ФинПоинт, marked as corrected to `финпоинт`. Only a Cyrillic spelling the store holds as it is counts, so `cement`
|
|
39
|
+
does not turn into цемент. Message search reads a Latin word the same way (#3285).
|
|
40
|
+
- **Memories, facts and the names a provider shows for a document's accounts are marked untrusted for a scheduled
|
|
41
|
+
agent.** In a run locked read-only with a mark, `memories list|show|search` and `facts list|show` mark each one's
|
|
42
|
+
`text`, `identities list` marks an account's `name` and its person's `name`, and `documents context` marks the same
|
|
43
|
+
in its `memories`, `facts` and `people`. A model's memory repeats the words of whoever wrote the document, so an
|
|
44
|
+
instruction planted there would reach the agent unmarked. Elsewhere the answers are unchanged. A CLI with its own
|
|
45
|
+
copies of these commands wraps them with the new `KNOWLEDGE_UNTRUSTED` and `IDENTITY_UNTRUSTED` from
|
|
46
|
+
`@wirecat/cli-core/documents/cli` ([DOCUMENTS.md](docs/dev/DOCUMENTS.md)).
|
|
47
|
+
- **`memories search` in a documents CLI finds a memory added with `memories add`.** The search reads its index
|
|
48
|
+
read-only and only a writable open builds it, so a new memory stayed unfound. Adding one now indexes it.
|
|
49
|
+
|
|
8
50
|
## 0.744.0 — 24.11.2026
|
|
9
51
|
|
|
10
52
|
### Fixed
|
package/dist/cli/bot/api.js
CHANGED
|
@@ -3,6 +3,7 @@ import { annotate } from "@wirecat/cli-base/commands";
|
|
|
3
3
|
import { Command, Option } from "commander";
|
|
4
4
|
import { secretInput } from "../../runs/run-context.js";
|
|
5
5
|
import { NO_EFFECTS, REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
6
|
+
import { API_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
6
7
|
import { apiFlagOf, apiJson, apiOptionKey, graphqlVariables, readApiBody, readApiBytes, sendsBytes, } from "./api-input.js";
|
|
7
8
|
/**
|
|
8
9
|
* The words after `api`: `contacts-list` in the group `contacts` is `contacts list`, `move-page` in `pages` keeps its
|
|
@@ -55,6 +56,7 @@ export const generatedApiCommand = (api) => {
|
|
|
55
56
|
command.addOption(secretInput(new Option("--body <json>", "the request body as JSON; - reads it from stdin")));
|
|
56
57
|
command.option("--body-file <path>", "the request body from a JSON file; - is stdin");
|
|
57
58
|
}
|
|
59
|
+
marksUntrusted(command, API_UNTRUSTED);
|
|
58
60
|
annotate(command, {
|
|
59
61
|
origin: "generated",
|
|
60
62
|
api_operation: operation.id,
|
package/dist/cli/compact.js
CHANGED
|
@@ -147,9 +147,14 @@ const firstSet = (item, field, column) => fieldsOfColumn(field)
|
|
|
147
147
|
const sourceOf = (item, column) => fieldsOfColumn(column.field).find((path) => printable(at(item, path), column));
|
|
148
148
|
// Whitespace runs become one space and control or direction characters show, so a text cannot start a row of its own.
|
|
149
149
|
const clean = (text) => visibleControls(text.replace(/\s+/g, " ").trim());
|
|
150
|
+
const BLOCK = /^(⟦untrusted:([0-9a-f]{16}) [^⟦⟧]*⟧)([^⟦⟧]*)(⟦\/untrusted:\2⟧)$/su;
|
|
150
151
|
const cut = (text, chars) => {
|
|
151
152
|
if (chars <= 0)
|
|
152
153
|
return text;
|
|
154
|
+
// A marked text loses its inside, never its closing marker, or the rest of the row would read as inside it.
|
|
155
|
+
const block = BLOCK.exec(text);
|
|
156
|
+
if (block)
|
|
157
|
+
return `${block[1]}${cut(block[3] ?? "", chars)}${block[4]}`;
|
|
153
158
|
const letters = Array.from(text);
|
|
154
159
|
return letters.length <= chars ? text : `${letters.slice(0, chars).join("")}…(+${letters.length - chars})`;
|
|
155
160
|
};
|
|
@@ -32,10 +32,10 @@ export const fileConflictsCommand = (helpers) => {
|
|
|
32
32
|
.summary("files changed on both sides that a sync could not merge")
|
|
33
33
|
.description(`files changed on both sides that a sync could not merge: list them, show the three versions and the lines ` +
|
|
34
34
|
`that conflict, and resolve each by keeping a side or giving the final file`)
|
|
35
|
-
.addCommand(annotate(new Command("list"), {
|
|
35
|
+
.addCommand(marksUntrusted(annotate(new Command("list"), {
|
|
36
36
|
effects: LOCAL_READ,
|
|
37
37
|
examples: [`${app} personal mirrors conflicts list --json`],
|
|
38
|
-
})
|
|
38
|
+
}), ["path"])
|
|
39
39
|
.summary("list the conflicts the last sync left")
|
|
40
40
|
.description("list the conflicts each mirror's last sync left, with why and when it found them")
|
|
41
41
|
.argument("[id]", `${ID}; every mirror of the profile when omitted`)
|
|
@@ -18,6 +18,7 @@ import { FETCH, LOCAL_READ, LOCAL_WRITE, ownerOnlyOption, REMOTE_READ, REMOTE_WR
|
|
|
18
18
|
import { itemOf, jsonlRecords, listOf, snakeKeys } from "../envelope.js";
|
|
19
19
|
import { commandPath } from "../list-query.js";
|
|
20
20
|
import { terminalAsker } from "../messenger/ask.js";
|
|
21
|
+
import { marksUntrusted } from "../untrusted-marks.js";
|
|
21
22
|
import { fileConflictsCommand } from "./file-conflicts.js";
|
|
22
23
|
/** A mirror with the account it was added for: a sync signed in to another account is refused. */
|
|
23
24
|
const SavedMirror = v.strictObject({
|
|
@@ -29,6 +30,23 @@ const SavedMirror = v.strictObject({
|
|
|
29
30
|
});
|
|
30
31
|
const ID = "mirror id from mirrors list";
|
|
31
32
|
const PATH = "the file's path inside the mirror, like notes/plan.md";
|
|
33
|
+
// A mirror's own path is the owner's folder; the files in it and their new names are whoever shares the remote's.
|
|
34
|
+
const PREVIEW_UNTRUSTED = [
|
|
35
|
+
"uploaded",
|
|
36
|
+
"downloaded",
|
|
37
|
+
"merged",
|
|
38
|
+
"rewritten",
|
|
39
|
+
"adopted",
|
|
40
|
+
"trashed.path",
|
|
41
|
+
"renamed.from",
|
|
42
|
+
"renamed.to",
|
|
43
|
+
"plan.path",
|
|
44
|
+
"plan.to",
|
|
45
|
+
"unknown.path",
|
|
46
|
+
"errors.path",
|
|
47
|
+
"conflicts.path",
|
|
48
|
+
"conflicts.remote_changed_by",
|
|
49
|
+
];
|
|
32
50
|
/** The engine's refusals of a whole run, which a sync ends with instead of the generic partial one. */
|
|
33
51
|
const STOPS = new Set(["mirror.too-many-deletions", "mirror.too-many-replacements", "mirror.no-space"]);
|
|
34
52
|
const errorOf = (error) => isCliError(error) ? error : new CliError("provider_error", error instanceof Error ? error.message : String(error));
|
|
@@ -455,13 +473,16 @@ export const fileMirrorsCommand = (helpers) => {
|
|
|
455
473
|
remote_checked: item.remote_checked,
|
|
456
474
|
}))));
|
|
457
475
|
});
|
|
458
|
-
const previewCommand = () => annotate(new Command("preview"), {
|
|
476
|
+
const previewCommand = () => marksUntrusted(annotate(new Command("preview"), {
|
|
459
477
|
effects: REMOTE_READ,
|
|
460
478
|
offline: false,
|
|
461
479
|
// Listing a big remote can take minutes: it stops before its deadline (5 min, 45 s over MCP) and says so.
|
|
462
480
|
cooperative: true,
|
|
463
|
-
examples: [
|
|
464
|
-
|
|
481
|
+
examples: [
|
|
482
|
+
`${CLI} personal mirrors preview --json`,
|
|
483
|
+
`${CLI} personal mirrors preview 1a2b3c4d --keep ${REMOTE}`,
|
|
484
|
+
],
|
|
485
|
+
}), PREVIEW_UNTRUSTED)
|
|
465
486
|
.summary(`list ${service} and show what mirrors sync would do`)
|
|
466
487
|
.description(`list ${service} and show what mirrors sync would do: each upload, download, merge, rename, trash and ` +
|
|
467
488
|
"conflict; nothing is changed on either side")
|
|
@@ -8,7 +8,7 @@ import { type DocumentMirrorCommands } from "./mirrors.js";
|
|
|
8
8
|
import { type DocumentSearchCommands } from "./search.js";
|
|
9
9
|
import { type DocumentSyncCommands } from "./sync.js";
|
|
10
10
|
import type { DocumentWords } from "./words.js";
|
|
11
|
-
export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
11
|
+
export { API_UNTRUSTED, DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, IDENTITY_UNTRUSTED, KNOWLEDGE_UNTRUSTED, marksUntrusted, } from "../untrusted-marks.js";
|
|
12
12
|
export { addDocumentCatalogCommands, CATALOG_FIELDS, type CatalogTree, type CatalogTreeSource, catalogId, catalogOutput, catalogSource, catalogTree, type DocumentCatalog, type DocumentCatalogCommands, type DocumentCatalogStores, } from "./catalog.js";
|
|
13
13
|
export { addLocalDocumentCommands, type ImportedDocument, type LocalDocumentCommands } from "./documents.js";
|
|
14
14
|
export { type FileConflictCommands, type FileConflictConnection, fileConflictsCommand } from "./file-conflicts.js";
|
|
@@ -6,7 +6,7 @@ import { addDocumentKnowledgeCommands } from "./knowledge.js";
|
|
|
6
6
|
import { addDocumentMirrorCommands } from "./mirrors.js";
|
|
7
7
|
import { addDocumentSearchCommand } from "./search.js";
|
|
8
8
|
import { addDocumentSyncCommands } from "./sync.js";
|
|
9
|
-
export { DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
9
|
+
export { API_UNTRUSTED, DOCUMENT_CONTEXT_UNTRUSTED, DOCUMENT_UNTRUSTED, IDENTITY_UNTRUSTED, KNOWLEDGE_UNTRUSTED, marksUntrusted, } from "../untrusted-marks.js";
|
|
10
10
|
export { addDocumentCatalogCommands, CATALOG_FIELDS, catalogId, catalogOutput, catalogSource, catalogTree, } from "./catalog.js";
|
|
11
11
|
export { addLocalDocumentCommands } from "./documents.js";
|
|
12
12
|
export { fileConflictsCommand } from "./file-conflicts.js";
|
|
@@ -7,7 +7,7 @@ import { honoursDryRun } from "../dry-run-guard.js";
|
|
|
7
7
|
import { LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE } from "../effects.js";
|
|
8
8
|
import { itemOf, listOf } from "../envelope.js";
|
|
9
9
|
import { queryHelp, queryTerms, withQuery } from "../list-query.js";
|
|
10
|
-
import { DOCUMENT_CONTEXT_UNTRUSTED, marksUntrusted } from "../untrusted-marks.js";
|
|
10
|
+
import { DOCUMENT_CONTEXT_UNTRUSTED, IDENTITY_UNTRUSTED, KNOWLEDGE_UNTRUSTED, marksUntrusted, } from "../untrusted-marks.js";
|
|
11
11
|
import { bindQuery, documentQueries, FACT_QUERY, factItem, identityRow, linkRow, MEMORY_QUERY, MEMORY_SEARCH_QUERY, memoryItem, memorySearch, tagRow, termsOf, } from "./queries.js";
|
|
12
12
|
import { allOf, documentsGroup, examples, positive, wordsOf } from "./words.js";
|
|
13
13
|
const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
@@ -119,10 +119,7 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
119
119
|
.addOption(new Option("--kind <kind>", "what kind of memory it is").choices(MEMORY_KINDS).default("summary"))
|
|
120
120
|
.option("--supersedes <ref>", "a memory:<id> about the same document that this one replaces")
|
|
121
121
|
.action(async (doc, body, args) => output(itemOf(memoryItem(await run(doc, (k, p, ref) => k.addMemory(p, ref, { body, ...args, status: "proposed", author: author() }))))));
|
|
122
|
-
withQuery(examples(annotate(memories.command("list"), { effects: LOCAL_READ }).description("list a document's memories"), [
|
|
123
|
-
`${prefix} memories list DOC_ID scope:work`,
|
|
124
|
-
`${prefix} memories list DOC_ID kind:preference status:confirmed`,
|
|
125
|
-
]).argument("<document>", documentArgument), MEMORY_QUERY)
|
|
122
|
+
withQuery(examples(marksUntrusted(annotate(memories.command("list"), { effects: LOCAL_READ }), KNOWLEDGE_UNTRUSTED).description("list a document's memories"), [`${prefix} memories list DOC_ID scope:work`, `${prefix} memories list DOC_ID kind:preference status:confirmed`]).argument("<document>", documentArgument), MEMORY_QUERY)
|
|
126
123
|
.option("--limit <n>", "how many memories to return", positive, 50)
|
|
127
124
|
.action(async (doc, words, { limit }) => {
|
|
128
125
|
const terms = queryTerms(words, MEMORY_QUERY, "memories list");
|
|
@@ -139,11 +136,11 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
139
136
|
stale: "mark a memory as out of date",
|
|
140
137
|
};
|
|
141
138
|
for (const [action, description] of Object.entries(memoryActions))
|
|
142
|
-
examples(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`${prefix} memories ${action} DOC_ID memory:MEMORY_ID`])
|
|
139
|
+
examples(marksUntrusted(annotate(memories.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }), KNOWLEDGE_UNTRUSTED).description(description), [`${prefix} memories ${action} DOC_ID memory:MEMORY_ID`])
|
|
143
140
|
.argument("<document>", documentArgument)
|
|
144
141
|
.argument("<memory>", memoryArgument)
|
|
145
142
|
.action(async (doc, memoryRef) => output(itemOf(memoryItem(await run(doc, (k, p, ref) => action === "show" ? k.memory(p, ref, memoryRef) : k.memory(p, ref, memoryRef, action, decider()))))));
|
|
146
|
-
const search = examples(annotate(memories.command("search"), { effects: LOCAL_READ }).description("search a document's memories by words"), [`${prefix} memories search DOC_ID reviews scope:work`, `${prefix} memories search DOC_ID "async reviews"`])
|
|
143
|
+
const search = examples(marksUntrusted(annotate(memories.command("search"), { effects: LOCAL_READ }), KNOWLEDGE_UNTRUSTED).description("search a document's memories by words"), [`${prefix} memories search DOC_ID reviews scope:work`, `${prefix} memories search DOC_ID "async reviews"`])
|
|
147
144
|
.argument("<document>", documentArgument)
|
|
148
145
|
.argument("<query...>", "words to look for, and scope:personal or scope:work — the fields are below")
|
|
149
146
|
.allowUnknownOption()
|
|
@@ -194,10 +191,7 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
194
191
|
by: author(),
|
|
195
192
|
...(occurredTime === undefined ? {} : { occurredAt: occurredTime }),
|
|
196
193
|
}))))));
|
|
197
|
-
withQuery(examples(annotate(facts.command("list"), { effects: LOCAL_READ }).description("list a document's facts"), [
|
|
198
|
-
`${prefix} facts list DOC_ID status:proposed`,
|
|
199
|
-
`${prefix} facts list DOC_ID kind:decision`,
|
|
200
|
-
]).argument("<document>", documentArgument), FACT_QUERY)
|
|
194
|
+
withQuery(examples(marksUntrusted(annotate(facts.command("list"), { effects: LOCAL_READ }), KNOWLEDGE_UNTRUSTED).description("list a document's facts"), [`${prefix} facts list DOC_ID status:proposed`, `${prefix} facts list DOC_ID kind:decision`]).argument("<document>", documentArgument), FACT_QUERY)
|
|
201
195
|
.option("--limit <n>", "how many facts to return", positive, 50)
|
|
202
196
|
.action(async (doc, words, { limit }) => {
|
|
203
197
|
const terms = queryTerms(words, FACT_QUERY, "facts list");
|
|
@@ -213,14 +207,12 @@ const addDocumentKnowledgeCommandsDefinition = (program, helpers) => {
|
|
|
213
207
|
reverse: "an accepted decision no longer holds, and nothing replaced it",
|
|
214
208
|
};
|
|
215
209
|
for (const [action, description] of Object.entries(factActions))
|
|
216
|
-
examples(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }).description(description), [`${prefix} facts ${action} DOC_ID fact:FACT_ID`])
|
|
210
|
+
examples(marksUntrusted(annotate(facts.command(action), { effects: action === "show" ? LOCAL_READ : LOCAL_WRITE }), KNOWLEDGE_UNTRUSTED).description(description), [`${prefix} facts ${action} DOC_ID fact:FACT_ID`])
|
|
217
211
|
.argument("<document>", documentArgument)
|
|
218
212
|
.argument("<fact>", factArgument)
|
|
219
213
|
.action(async (doc, factRef) => output(itemOf(factItem(await run(doc, (k, p, ref) => action === "show" ? k.fact(p, ref, factRef) : k.fact(p, ref, factRef, action, decider()))))));
|
|
220
214
|
const identities = annotate(program.command("identities"), { effects: LOCAL_READ }).description(text.identities);
|
|
221
|
-
bindQuery(examples(annotate(identities.command("list"), { effects: LOCAL_READ }).description(text.identitiesList), [
|
|
222
|
-
`${prefix} identities list DOC_ID`,
|
|
223
|
-
]).argument("<document>", documentArgument), queries.identities, identityRow).action(async (doc, words) => {
|
|
215
|
+
bindQuery(examples(marksUntrusted(annotate(identities.command("list"), { effects: LOCAL_READ }), IDENTITY_UNTRUSTED).description(text.identitiesList), [`${prefix} identities list DOC_ID`]).argument("<document>", documentArgument), queries.identities, identityRow).action(async (doc, words) => {
|
|
224
216
|
const filter = termsOf(words, queries.identities, "identities list");
|
|
225
217
|
output(itemOf(await run(doc, (k, p, ref) => k.people(p, ref, filter))));
|
|
226
218
|
});
|
|
@@ -58,9 +58,9 @@ export interface CopyAge {
|
|
|
58
58
|
}
|
|
59
59
|
export declare const ageOf: (lastSync: string | undefined, now?: number) => CopyAge;
|
|
60
60
|
export declare const staleCopy: (provider: string, lastSync: string | undefined, now?: number) => {
|
|
61
|
-
|
|
62
|
-
meta?: undefined;
|
|
61
|
+
missing?: undefined;
|
|
63
62
|
next?: undefined;
|
|
63
|
+
meta?: undefined;
|
|
64
64
|
} | {
|
|
65
65
|
missing: {
|
|
66
66
|
field: string;
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -162,7 +162,7 @@ export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults
|
|
|
162
162
|
export { type Config, type Configuration, count, first, flag, fromFile, type GlobalFlags, NONE_NAMED, namedProfile, type ProfileKind, plain, type ResolveOptions, type Settings, type SettingsExtension, type SettingsExtensionContext, type Source, settingsFor, } from "./settings.js";
|
|
163
163
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
164
164
|
export { AGENTS, type Agent, agentFor, screenFor } from "./setup-screen.js";
|
|
165
|
-
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, addStoreMaintenanceCommands, appCompleteCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, serviceApiCommand, setupCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
165
|
+
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, addStoreMaintenanceCommands, appCompleteCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, messengerSessionCommands, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, serviceApiCommand, setupCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
166
166
|
export { assertSharedContracts, customizeSharedCommand, hasSharedContract, overrideSharedContract, type SharedContractOverride, sharedContractOverrides, sharedContracts, } from "./shared-contracts.js";
|
|
167
167
|
export { runnable, withSafety } from "./steps.js";
|
|
168
168
|
export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -151,7 +151,7 @@ export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
|
151
151
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
152
152
|
export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
153
153
|
export { AGENTS, agentFor, screenFor } from "./setup-screen.js";
|
|
154
|
-
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, addStoreMaintenanceCommands, appCompleteCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, serviceApiCommand, setupCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
154
|
+
export { accountCommand, addMeetingBatchCommand, addMeetingPreparationCommand, addMeetingProjectCandidatesCommand, addMeetingSeriesInventoryCommand, addStoreMaintenanceCommands, appCompleteCommand, appDoctorCommand, appMcpCommand, attachmentsCommand, botAdminsCommand, botCommand, botMcpCommand, botMembersCommand, botMessagesCommand, callsCommand, chatsCommand, commandsCommand, completeCommand, configCommand, contactsCommand, conversationsCommand, deleteCommand, doctorCommand, editCommand, floodCommand, forwardCommand, generatedApiCommand, guideCommand, imagesCommand, inboxCommand, markReadCommand, mcpCommand, mentionsCommand, messagesCommand, messengerSessionCommands, metadataCommand, modelCatalogueCommand, modelsCommand, pinCommand, pollsCommand, projectsCommand, reactionsCommand, recipientsCommand, repliesCommand, reviewCommand, runsCommand, scheduleCommand, scheduleCommandFor, searchCommand, searchesCommand, sendCommand, sendsCommand, serveCommand, serverCommand, serviceApiCommand, setupCommand, skillCommand, starCommands, statsCommand, stickersCommand, storeCommand, tagsCommand, tasksCommand, tasksStatsCommand, templatesCommand, topicsCommand, unpinCommand, upgradeCommand, watchCommand, } from "./shared-command-exports.js";
|
|
155
155
|
export { assertSharedContracts, customizeSharedCommand, hasSharedContract, overrideSharedContract, sharedContractOverrides, sharedContracts, } from "./shared-contracts.js";
|
|
156
156
|
export { runnable, withSafety } from "./steps.js";
|
|
157
157
|
export { sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
1
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
2
|
import { Command } from "commander";
|
|
4
3
|
import { withoutPhone } from "../../services/people.js";
|
|
5
|
-
import { storePath } from "../../store/path.js";
|
|
6
|
-
import { openStore } from "../../store/store.js";
|
|
7
4
|
import { accountRemoveCommand } from "../account-remove.js";
|
|
8
5
|
import { accountRenameCommand } from "../account-rename.js";
|
|
9
6
|
import { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
10
7
|
import { itemOf, renderAnswer } from "../envelope.js";
|
|
11
|
-
import {
|
|
12
|
-
import { NONE_NAMED } from "../settings.js";
|
|
8
|
+
import { withQuery } from "../list-query.js";
|
|
13
9
|
import { ACCOUNT_PROFILES_QUERY } from "./account-profile-query.js";
|
|
14
10
|
import { accountSessionsCommand } from "./account-sessions-command.js";
|
|
15
|
-
import { recalledAccount } from "./accounts.js";
|
|
16
11
|
import { photoHelp, readProfilePhoto } from "./admin-commands.js";
|
|
17
|
-
import { accountAnswer, renderItem
|
|
12
|
+
import { accountAnswer, renderItem } from "./chat-answers.js";
|
|
18
13
|
import { messengerContext } from "./context.js";
|
|
19
14
|
import { hideNever } from "./lacks.js";
|
|
20
15
|
import { privacyCommand } from "./records-command.js";
|
|
16
|
+
import { listProfiles } from "./session-commands.js";
|
|
21
17
|
export const accountCommand = (messenger) => {
|
|
22
18
|
const tool = `${messenger.app.command} personal`;
|
|
23
19
|
const account = new Command("account")
|
|
@@ -27,42 +23,7 @@ export const accountCommand = (messenger) => {
|
|
|
27
23
|
.description("every account profile on this computer, and the account each is logged in as; a name that is only a bot " +
|
|
28
24
|
"is left out (`bot list` has it), one that is a bot too says `bot: true`; asks the messenger nothing")
|
|
29
25
|
.action(async function (words) {
|
|
30
|
-
|
|
31
|
-
const context = messengerContext(this, messenger, { needsProfile: false });
|
|
32
|
-
const { app, provider } = messenger;
|
|
33
|
-
const current = context.settings.sources.profile === NONE_NAMED ? undefined : context.settings.profile;
|
|
34
|
-
const { profilesHere, accountProfiles = profilesHere, botProfiles = [] } = context.settings;
|
|
35
|
-
const isAccount = (profile) => accountProfiles.includes(profile) || messenger.profileState?.(profile, context.env) === "signed-in";
|
|
36
|
-
const profiles = [
|
|
37
|
-
...new Set([...(current === undefined ? [] : [current]), ...profilesHere.filter(isAccount)]),
|
|
38
|
-
]
|
|
39
|
-
.filter((profile) => terms.get("profile") === undefined || profile === terms.get("profile"))
|
|
40
|
-
.filter((profile) => terms.get("current") === undefined ||
|
|
41
|
-
(profile === current) === (terms.get("current")?.toLowerCase() === "true"))
|
|
42
|
-
.sort();
|
|
43
|
-
const store = existsSync(storePath(context.env))
|
|
44
|
-
? await openStore({ env: context.env }).catch(() => undefined)
|
|
45
|
-
: undefined;
|
|
46
|
-
try {
|
|
47
|
-
const items = [];
|
|
48
|
-
for (const profile of profiles) {
|
|
49
|
-
const key = recalledAccount(app, provider, profile, context.env);
|
|
50
|
-
items.push({
|
|
51
|
-
profile,
|
|
52
|
-
current: profile === current,
|
|
53
|
-
account: key?.account ?? null,
|
|
54
|
-
name: key && store ? await store.accounts.accountName(key) : null,
|
|
55
|
-
...(messenger.profileState
|
|
56
|
-
? { signed_in: messenger.profileState(profile, context.env) !== "signed-out" }
|
|
57
|
-
: {}),
|
|
58
|
-
...(botProfiles.includes(profile) ? { bot: true } : {}),
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
renderAnswer(this, context, wholeList("account list", items));
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
await store?.close();
|
|
65
|
-
}
|
|
26
|
+
await listProfiles(this, messenger, words, "account list");
|
|
66
27
|
}))
|
|
67
28
|
.addCommand(annotate(new Command("show"), {
|
|
68
29
|
effects: REMOTE_READ,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { type Messenger } from "./context.js";
|
|
3
|
+
/** What `account list` and `session list` answer: the profiles here and the account each is logged in as. */
|
|
4
|
+
export declare const listProfiles: (command: Command, messenger: Messenger, words: string[], label: string) => Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* `session status` and `session list`, for a messenger's own `session` group beside its `start` and `end`
|
|
7
|
+
* (WC-ACCT-12). Both read this computer; only `status --check` asks the messenger.
|
|
8
|
+
*/
|
|
9
|
+
export declare const messengerSessionCommands: (messenger: Messenger) => Command[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { withoutPhone } from "../../services/people.js";
|
|
5
|
+
import { storePath } from "../../store/path.js";
|
|
6
|
+
import { openStore } from "../../store/store.js";
|
|
7
|
+
import { LOCAL_READ, REMOTE_READ } from "../effects.js";
|
|
8
|
+
import { itemOf, renderAnswer } from "../envelope.js";
|
|
9
|
+
import { queryTerms, withQuery } from "../list-query.js";
|
|
10
|
+
import { profileFree } from "../profile.js";
|
|
11
|
+
import { NONE_NAMED } from "../settings.js";
|
|
12
|
+
import { ACCOUNT_PROFILES_QUERY } from "./account-profile-query.js";
|
|
13
|
+
import { recalledAccount } from "./accounts.js";
|
|
14
|
+
import { accountAnswer, wholeList } from "./chat-answers.js";
|
|
15
|
+
import { messengerContext } from "./context.js";
|
|
16
|
+
const storeOf = async (env) => existsSync(storePath(env)) ? await openStore({ env }).catch(() => undefined) : undefined;
|
|
17
|
+
/** What `account list` and `session list` answer: the profiles here and the account each is logged in as. */
|
|
18
|
+
export const listProfiles = async (command, messenger, words, label) => {
|
|
19
|
+
const terms = queryTerms(words, ACCOUNT_PROFILES_QUERY, label);
|
|
20
|
+
const context = messengerContext(command, messenger, { needsProfile: false });
|
|
21
|
+
const { app, provider } = messenger;
|
|
22
|
+
const current = context.settings.sources.profile === NONE_NAMED ? undefined : context.settings.profile;
|
|
23
|
+
const { profilesHere, accountProfiles = profilesHere, botProfiles = [] } = context.settings;
|
|
24
|
+
const isAccount = (profile) => accountProfiles.includes(profile) || messenger.profileState?.(profile, context.env) === "signed-in";
|
|
25
|
+
const profiles = [...new Set([...(current === undefined ? [] : [current]), ...profilesHere.filter(isAccount)])]
|
|
26
|
+
.filter((profile) => terms.get("profile") === undefined || profile === terms.get("profile"))
|
|
27
|
+
.filter((profile) => terms.get("current") === undefined ||
|
|
28
|
+
(profile === current) === (terms.get("current")?.toLowerCase() === "true"))
|
|
29
|
+
.sort();
|
|
30
|
+
const store = await storeOf(context.env);
|
|
31
|
+
try {
|
|
32
|
+
const items = [];
|
|
33
|
+
for (const profile of profiles) {
|
|
34
|
+
const key = recalledAccount(app, provider, profile, context.env);
|
|
35
|
+
items.push({
|
|
36
|
+
profile,
|
|
37
|
+
current: profile === current,
|
|
38
|
+
account: key?.account ?? null,
|
|
39
|
+
name: key && store ? await store.accounts.accountName(key) : null,
|
|
40
|
+
...(messenger.profileState ? { signed_in: messenger.profileState(profile, context.env) !== "signed-out" } : {}),
|
|
41
|
+
...(botProfiles.includes(profile) ? { bot: true } : {}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
renderAnswer(command, context, wholeList(label, items));
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
await store?.close();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* `session status` and `session list`, for a messenger's own `session` group beside its `start` and `end`
|
|
52
|
+
* (WC-ACCT-12). Both read this computer; only `status --check` asks the messenger.
|
|
53
|
+
*/
|
|
54
|
+
export const messengerSessionCommands = (messenger) => {
|
|
55
|
+
const cli = messenger.app.command;
|
|
56
|
+
const status = annotate(new Command("status"), {
|
|
57
|
+
effects: REMOTE_READ,
|
|
58
|
+
examples: [`${cli} personal session status`, `${cli} personal session status --check --json`],
|
|
59
|
+
})
|
|
60
|
+
.summary("show whether this profile is logged in, and as whom")
|
|
61
|
+
.description("show whether this profile has a session on this computer and the account it was logged in as; " +
|
|
62
|
+
"--check asks the messenger whose the session is, without the phone number (`account show` has it)")
|
|
63
|
+
.option("--check", "ask the messenger whether the session still works, and whose it is")
|
|
64
|
+
.action(async function ({ check }) {
|
|
65
|
+
const context = messengerContext(this, messenger);
|
|
66
|
+
const { profile, env } = context;
|
|
67
|
+
const { botProfiles = [] } = context.settings;
|
|
68
|
+
const key = recalledAccount(messenger.app, messenger.provider, profile, env);
|
|
69
|
+
const state = messenger.profileState?.(profile, env);
|
|
70
|
+
const signedIn = state === undefined ? key !== undefined : state !== "signed-out";
|
|
71
|
+
const bot = botProfiles.includes(profile) ? { bot: true } : {};
|
|
72
|
+
if (!check || !signedIn) {
|
|
73
|
+
const store = key ? await storeOf(env) : undefined;
|
|
74
|
+
try {
|
|
75
|
+
const name = key && store ? await store.accounts.accountName(key) : null;
|
|
76
|
+
renderAnswer(this, context, itemOf({ profile, signed_in: signedIn, account: key?.account ?? null, name, ...bot, verified: false }));
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
await store?.close();
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const me = await context.withMessenger((connection) => connection.me());
|
|
84
|
+
const { id, ...who } = accountAnswer(messenger.provider, withoutPhone(me));
|
|
85
|
+
renderAnswer(this, context, itemOf({ profile, signed_in: true, account: id, ...who, ...bot, verified: true }));
|
|
86
|
+
});
|
|
87
|
+
const list = profileFree(withQuery(annotate(new Command("list"), {
|
|
88
|
+
effects: LOCAL_READ,
|
|
89
|
+
examples: [`${cli} session list`, `${cli} session list --json`],
|
|
90
|
+
}), ACCOUNT_PROFILES_QUERY))
|
|
91
|
+
.summary("list the profiles on this computer and the account each is logged in as")
|
|
92
|
+
.description("every account profile on this computer, and the account each is logged in as; a name that is only a bot " +
|
|
93
|
+
"is left out (`bot list` has it), one that is a bot too says `bot: true`; asks the messenger nothing")
|
|
94
|
+
.action(async function (words) {
|
|
95
|
+
await listProfiles(this, messenger, words, "session list");
|
|
96
|
+
});
|
|
97
|
+
return [status, list];
|
|
98
|
+
};
|
package/dist/cli/program.js
CHANGED
|
@@ -45,6 +45,7 @@ import { skillSourceOf } from "./skill-command.js";
|
|
|
45
45
|
import { refreshSkills, skipsSkillRefresh } from "./skill-refresh.js";
|
|
46
46
|
import { commandAt, failureSteps, lineOf, typedCommandPath, withLines } from "./steps.js";
|
|
47
47
|
import { isSignIn, unknownProfile } from "./unknown-profile.js";
|
|
48
|
+
import { untrustedMarkOf, withoutRunMarks } from "./untrusted-marks.js";
|
|
48
49
|
const OUTPUT_OPTIONS = [
|
|
49
50
|
["output", "--output"],
|
|
50
51
|
["outputDir", "--output-dir"],
|
|
@@ -173,7 +174,9 @@ export const run = async (argv, definition, options = {}) => {
|
|
|
173
174
|
return code;
|
|
174
175
|
};
|
|
175
176
|
const isMachine = (words) => words.some((word) => word === "--json" || word.startsWith("--json=") || word === "--jsonl" || word === COMPACT_FLAG);
|
|
176
|
-
const runOnce = async (
|
|
177
|
+
const runOnce = async (typed, definition, options) => {
|
|
178
|
+
const mark = untrustedMarkOf(definition.app, options.env ?? process.env);
|
|
179
|
+
const argv = mark ? typed.map((arg) => withoutRunMarks(arg, mark)) : typed;
|
|
177
180
|
const streams = options.streams ?? processStreams;
|
|
178
181
|
if (!options.streams)
|
|
179
182
|
quietBrokenPipes();
|
|
@@ -787,6 +787,7 @@ export declare const addMeetingSeriesInventoryCommand: (program: import("command
|
|
|
787
787
|
output: (answer: Awaited<ReturnType<typeof import("./meeting-series-inventory-read.js").readMeetingSeriesInventory>>) => void;
|
|
788
788
|
}) => import("commander").Command;
|
|
789
789
|
export declare const accountCommand: (messenger: import("./index.js").Messenger) => import("commander").Command;
|
|
790
|
+
export declare const messengerSessionCommands: (messenger: import("./index.js").Messenger) => import("commander").Command[];
|
|
790
791
|
export declare const storeCommand: (messenger: import("./index.js").Messenger) => import("commander").Command;
|
|
791
792
|
export declare const attachmentsCommand: (messenger: import("./index.js").Messenger) => import("commander").Command;
|
|
792
793
|
export declare const chatsCommand: (messenger: import("./index.js").Messenger) => import("commander").Command;
|
|
@@ -47,6 +47,7 @@ import { searchCommand as searchCommandDefinition } from "./messenger/search-com
|
|
|
47
47
|
import { searchesCommand as searchesCommandDefinition } from "./messenger/searches-command.js";
|
|
48
48
|
import { serveCommand as serveCommandDefinition } from "./messenger/serve-command.js";
|
|
49
49
|
import { serverCommand as serverCommandDefinition } from "./messenger/server-command.js";
|
|
50
|
+
import { messengerSessionCommands as messengerSessionCommandsDefinition } from "./messenger/session-commands.js";
|
|
50
51
|
import { statsCommand as statsCommandDefinition } from "./messenger/stats-command.js";
|
|
51
52
|
import { addStoreMaintenanceCommands as addStoreMaintenanceCommandsDefinition } from "./messenger/store-maintenance-command.js";
|
|
52
53
|
import { tagsCommand as tagsCommandDefinition } from "./messenger/tags-command.js";
|
|
@@ -81,6 +82,7 @@ export const addMeetingPreparationCommand = sharedCommand(addMeetingPreparationC
|
|
|
81
82
|
export const addMeetingProjectCandidatesCommand = sharedCommand(addMeetingProjectCandidatesCommandDefinition);
|
|
82
83
|
export const addMeetingSeriesInventoryCommand = sharedCommand(addMeetingSeriesInventoryCommandDefinition);
|
|
83
84
|
export const accountCommand = sharedCommand(accountCommandDefinition);
|
|
85
|
+
export const messengerSessionCommands = sharedCommand(messengerSessionCommandsDefinition);
|
|
84
86
|
export const storeCommand = sharedCommand(storeCommandDefinition);
|
|
85
87
|
export const attachmentsCommand = sharedCommand(attachmentsCommandDefinition);
|
|
86
88
|
export const chatsCommand = sharedCommand(chatsCommandDefinition);
|
|
@@ -9,6 +9,16 @@ export declare const untrustedMarkOf: (app: AppIdentity, env: NodeJS.ProcessEnv)
|
|
|
9
9
|
export declare const runMarkOf: (command: Command) => string | undefined;
|
|
10
10
|
/** Other people's text between the run's markers, with every bracket and the mark taken out, so it can close none. */
|
|
11
11
|
export declare const marked: (text: string, mark: string, source: string, id?: string) => string;
|
|
12
|
+
/**
|
|
13
|
+
* The argument with each block of the run's own mark taken off, so a marked name or id an agent copies from one answer
|
|
14
|
+
* into the next command reads as the text inside. A block of another mark stays as it is.
|
|
15
|
+
*/
|
|
16
|
+
export declare const withoutRunMarks: (text: string, mark: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* A raw provider answer's untrusted fields: every string in it. Its shape is the provider's, and every name, title and
|
|
19
|
+
* text in it can be someone else's, so a list of paths would miss what the CLI did not foresee.
|
|
20
|
+
*/
|
|
21
|
+
export declare const API_UNTRUSTED: readonly ["item.*", "items.*"];
|
|
12
22
|
/**
|
|
13
23
|
* The answer with each field an object names in its `untrusted` list between the run's markers, at any depth. Other
|
|
14
24
|
* fields, and the shape, stay as they are.
|
|
@@ -30,11 +40,23 @@ export declare const CONTACT_UNTRUSTED: readonly ["description", "chats.title"];
|
|
|
30
40
|
*/
|
|
31
41
|
export declare const DOCUMENT_UNTRUSTED: readonly ["name", "title", "path", "text", "description", "excerpt", "target_text", "targetText"];
|
|
32
42
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
43
|
+
* A memory's or a fact's text about a document. A model's repeats the words of whoever wrote the document, and the
|
|
44
|
+
* store cannot tell which text an owner or an agent copied from it, so every one is marked.
|
|
45
|
+
*/
|
|
46
|
+
export declare const KNOWLEDGE_UNTRUSTED: readonly ["text"];
|
|
47
|
+
/** The accounts a provider shows on a document: the names their holders chose, and the person named after one. */
|
|
48
|
+
export declare const IDENTITY_UNTRUSTED: readonly ["name"];
|
|
49
|
+
/**
|
|
50
|
+
* `documents context`: the document, the links written in it, the memories and facts about it and the provider's
|
|
51
|
+
* names of its accounts. The notes and tags beside it are the owner's own, as a note is in `search notes`, so a bare
|
|
52
|
+
* `text` or `title` would mark them too.
|
|
35
53
|
*/
|
|
36
54
|
export declare const DOCUMENT_CONTEXT_UNTRUSTED: string[];
|
|
37
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. A
|
|
57
|
+
* `*` in a path stands for every key of an object, as a database's own property names; a path ending in `*` marks
|
|
58
|
+
* every string under it. A path starts with a field's name: a leading `*` would mark the answer's envelope too.
|
|
59
|
+
*/
|
|
38
60
|
export declare const marksUntrusted: <T extends Command>(command: T, fields?: readonly string[]) => T;
|
|
39
61
|
export declare const untrustedFieldsOf: (command: Command) => readonly string[] | undefined;
|
|
40
62
|
/** The answer with each of `fields` marked wherever an object in it has that path. */
|
|
@@ -27,6 +27,15 @@ const idOf = (value) => {
|
|
|
27
27
|
const id = value.ref ?? value.id;
|
|
28
28
|
return typeof id === "string" || typeof id === "number" ? String(id) : undefined;
|
|
29
29
|
};
|
|
30
|
+
const everyStringAt = (value, mark, source, id) => {
|
|
31
|
+
if (Array.isArray(value))
|
|
32
|
+
return value.map((one) => everyStringAt(one, mark, source, id));
|
|
33
|
+
if (value === null || typeof value !== "object")
|
|
34
|
+
return markAt(value, [], mark, source, id);
|
|
35
|
+
const record = value;
|
|
36
|
+
const own = idOf(record) ?? id;
|
|
37
|
+
return Object.fromEntries(Object.entries(record).map(([key, child]) => [key, everyStringAt(child, mark, source, own)]));
|
|
38
|
+
};
|
|
30
39
|
const markAt = (value, path, mark, source, id) => {
|
|
31
40
|
if (Array.isArray(value))
|
|
32
41
|
return value.map((one) => markAt(one, path, mark, source, id));
|
|
@@ -35,14 +44,29 @@ const markAt = (value, path, mark, source, id) => {
|
|
|
35
44
|
return typeof value === "string" && !value.startsWith(`${OPEN}untrusted:${mark} `)
|
|
36
45
|
? marked(value, mark, source, id)
|
|
37
46
|
: value;
|
|
47
|
+
if (path.length === 1 && path[0] === "*")
|
|
48
|
+
return everyStringAt(value, mark, source, id);
|
|
38
49
|
if (value === null || typeof value !== "object")
|
|
39
50
|
return value;
|
|
40
51
|
const [key = "", ...rest] = path;
|
|
41
52
|
const record = value;
|
|
53
|
+
const own = idOf(record) ?? id;
|
|
54
|
+
if (key === "*")
|
|
55
|
+
return Object.fromEntries(Object.entries(record).map(([name, child]) => [name, markAt(child, rest, mark, source, own)]));
|
|
42
56
|
if (!(key in record))
|
|
43
57
|
return value;
|
|
44
|
-
return { ...record, [key]: markAt(record[key], rest, mark, source,
|
|
58
|
+
return { ...record, [key]: markAt(record[key], rest, mark, source, own) };
|
|
45
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* The argument with each block of the run's own mark taken off, so a marked name or id an agent copies from one answer
|
|
62
|
+
* into the next command reads as the text inside. A block of another mark stays as it is.
|
|
63
|
+
*/
|
|
64
|
+
export const withoutRunMarks = (text, mark) => text.replace(new RegExp(`${OPEN}untrusted:${mark}(?: [^${OPEN}${CLOSE}]*)?${CLOSE}|${OPEN}/untrusted:${mark}${CLOSE}`, "gu"), "");
|
|
65
|
+
/**
|
|
66
|
+
* A raw provider answer's untrusted fields: every string in it. Its shape is the provider's, and every name, title and
|
|
67
|
+
* text in it can be someone else's, so a list of paths would miss what the CLI did not foresee.
|
|
68
|
+
*/
|
|
69
|
+
export const API_UNTRUSTED = ["item.*", "items.*"];
|
|
46
70
|
/**
|
|
47
71
|
* The answer with each field an object names in its `untrusted` list between the run's markers, at any depth. Other
|
|
48
72
|
* fields, and the shape, stay as they are.
|
|
@@ -105,14 +129,37 @@ export const DOCUMENT_UNTRUSTED = [
|
|
|
105
129
|
"targetText",
|
|
106
130
|
];
|
|
107
131
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
132
|
+
* A memory's or a fact's text about a document. A model's repeats the words of whoever wrote the document, and the
|
|
133
|
+
* store cannot tell which text an owner or an agent copied from it, so every one is marked.
|
|
134
|
+
*/
|
|
135
|
+
export const KNOWLEDGE_UNTRUSTED = ["text"];
|
|
136
|
+
/** The accounts a provider shows on a document: the names their holders chose, and the person named after one. */
|
|
137
|
+
export const IDENTITY_UNTRUSTED = ["name"];
|
|
138
|
+
/**
|
|
139
|
+
* `documents context`: the document, the links written in it, the memories and facts about it and the provider's
|
|
140
|
+
* names of its accounts. The notes and tags beside it are the owner's own, as a note is in `search notes`, so a bare
|
|
141
|
+
* `text` or `title` would mark them too.
|
|
110
142
|
*/
|
|
111
|
-
export const DOCUMENT_CONTEXT_UNTRUSTED = [
|
|
143
|
+
export const DOCUMENT_CONTEXT_UNTRUSTED = [
|
|
144
|
+
"document.title",
|
|
145
|
+
"document.text",
|
|
146
|
+
"document.path",
|
|
147
|
+
"links.targetText",
|
|
148
|
+
"memories.text",
|
|
149
|
+
"facts.text",
|
|
150
|
+
"people.items.name",
|
|
151
|
+
"people.items.person.name",
|
|
152
|
+
];
|
|
112
153
|
const DECLARED = new WeakMap();
|
|
113
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Declares the fields of a read's answer that hold other people's text, at any depth, for a scheduled agent's run. A
|
|
156
|
+
* `*` in a path stands for every key of an object, as a database's own property names; a path ending in `*` marks
|
|
157
|
+
* every string under it. A path starts with a field's name: a leading `*` would mark the answer's envelope too.
|
|
158
|
+
*/
|
|
114
159
|
export const marksUntrusted = (command, fields = MESSAGE_UNTRUSTED) => {
|
|
115
|
-
|
|
160
|
+
// A CLI's own list on a raw api operation adds to every string, as drive's, notion's and ydisk's did before it.
|
|
161
|
+
const raw = DECLARED.get(command) === API_UNTRUSTED;
|
|
162
|
+
DECLARED.set(command, raw ? [...new Set([...API_UNTRUSTED, ...fields])] : fields);
|
|
116
163
|
return command;
|
|
117
164
|
};
|
|
118
165
|
export const untrustedFieldsOf = (command) => DECLARED.get(command);
|
package/dist/search/respell.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type Vocabulary } from "./correct.js";
|
|
2
2
|
/** A Cyrillic word as Latin letters, the way a Latin name is written in Russian («хецнер», «ноксвел» for noxvel). */
|
|
3
3
|
export declare const latinSpellings: (word: string) => string[];
|
|
4
|
+
/**
|
|
5
|
+
* A Latin word as Cyrillic letters, the way a Russian name is typed in Latin («finpoint», «finpoynt» for ФинПоинт).
|
|
6
|
+
* A lone `y` may be и, й or ы, so each is tried, for up to three of them.
|
|
7
|
+
*/
|
|
8
|
+
export declare const cyrillicSpellings: (word: string) => string[];
|
|
4
9
|
/**
|
|
5
10
|
* For each word no message holds, not even as the beginning of a longer one, the words the store does hold that it
|
|
6
|
-
* may stand for: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
7
|
-
* nearest known spellings (up to two edits, as `correctWords` allows). A word
|
|
11
|
+
* may stand for. A Cyrillic word: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
12
|
+
* none, its own nearest known spellings (up to two edits, as `correctWords` allows). A Latin word: its Cyrillic
|
|
13
|
+
* spelling when the store holds it as it is, else its own nearest spellings. A word any message holds is left alone, so a
|
|
8
14
|
* correct word never turns into another.
|
|
9
15
|
*/
|
|
10
16
|
export declare const respelled: (vocabulary: Vocabulary, words: string[]) => Promise<Map<string, string[]>>;
|
package/dist/search/respell.js
CHANGED
|
@@ -40,10 +40,67 @@ export const latinSpellings = (word) => {
|
|
|
40
40
|
const plain = [...normalize(word)].map((letter) => LATIN[letter] ?? letter).join("");
|
|
41
41
|
return [...new Set([plain, plain.replaceAll("ks", "x")])];
|
|
42
42
|
};
|
|
43
|
+
// Longest first, so "shch" is read before "sh" and "s".
|
|
44
|
+
const CYRILLIC = Object.entries({
|
|
45
|
+
shch: "щ",
|
|
46
|
+
sch: "щ",
|
|
47
|
+
zh: "ж",
|
|
48
|
+
kh: "х",
|
|
49
|
+
ts: "ц",
|
|
50
|
+
ch: "ч",
|
|
51
|
+
sh: "ш",
|
|
52
|
+
yu: "ю",
|
|
53
|
+
ya: "я",
|
|
54
|
+
yo: "е",
|
|
55
|
+
y: "ы",
|
|
56
|
+
a: "а",
|
|
57
|
+
b: "б",
|
|
58
|
+
c: "к",
|
|
59
|
+
d: "д",
|
|
60
|
+
e: "е",
|
|
61
|
+
f: "ф",
|
|
62
|
+
g: "г",
|
|
63
|
+
h: "х",
|
|
64
|
+
i: "и",
|
|
65
|
+
j: "дж",
|
|
66
|
+
k: "к",
|
|
67
|
+
l: "л",
|
|
68
|
+
m: "м",
|
|
69
|
+
n: "н",
|
|
70
|
+
o: "о",
|
|
71
|
+
p: "п",
|
|
72
|
+
q: "к",
|
|
73
|
+
r: "р",
|
|
74
|
+
s: "с",
|
|
75
|
+
t: "т",
|
|
76
|
+
u: "у",
|
|
77
|
+
v: "в",
|
|
78
|
+
w: "в",
|
|
79
|
+
x: "кс",
|
|
80
|
+
z: "з",
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* A Latin word as Cyrillic letters, the way a Russian name is typed in Latin («finpoint», «finpoynt» for ФинПоинт).
|
|
84
|
+
* A lone `y` may be и, й or ы, so each is tried, for up to three of them.
|
|
85
|
+
*/
|
|
86
|
+
export const cyrillicSpellings = (word) => {
|
|
87
|
+
const latin = normalize(word);
|
|
88
|
+
if (!/^[a-z]+$/.test(latin) || latin.split("y").length > 4)
|
|
89
|
+
return [];
|
|
90
|
+
let spellings = [""];
|
|
91
|
+
for (let at = 0; at < latin.length;) {
|
|
92
|
+
const [from, to] = CYRILLIC.find(([one]) => latin.startsWith(one, at)) ?? [latin[at], latin[at]];
|
|
93
|
+
const letters = from === "y" ? ["и", "й", "ы"] : [to];
|
|
94
|
+
spellings = spellings.flatMap((start) => letters.map((letter) => start + letter));
|
|
95
|
+
at += from.length;
|
|
96
|
+
}
|
|
97
|
+
return spellings;
|
|
98
|
+
};
|
|
43
99
|
/**
|
|
44
100
|
* For each word no message holds, not even as the beginning of a longer one, the words the store does hold that it
|
|
45
|
-
* may stand for: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
46
|
-
* nearest known spellings (up to two edits, as `correctWords` allows). A word
|
|
101
|
+
* may stand for. A Cyrillic word: its Latin spelling or the nearest known spellings of that, and only when there are
|
|
102
|
+
* none, its own nearest known spellings (up to two edits, as `correctWords` allows). A Latin word: its Cyrillic
|
|
103
|
+
* spelling when the store holds it as it is, else its own nearest spellings. A word any message holds is left alone, so a
|
|
47
104
|
* correct word never turns into another.
|
|
48
105
|
*/
|
|
49
106
|
export const respelled = async (vocabulary, words) => {
|
|
@@ -51,11 +108,19 @@ export const respelled = async (vocabulary, words) => {
|
|
|
51
108
|
const found = new Map();
|
|
52
109
|
for (const word of words.filter((one) => !known.has(one))) {
|
|
53
110
|
const latin = latinSpellings(word);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
111
|
+
if (latin.length) {
|
|
112
|
+
const held = await vocabulary.knownTerms(latin);
|
|
113
|
+
const nearLatin = await correctWords(vocabulary, latin.filter((one) => !held.has(one)));
|
|
114
|
+
const asLatin = [...new Set([...held, ...[...nearLatin.values()].flat()])];
|
|
115
|
+
// A Latin name found in Latin letters says what the word was; its Cyrillic neighbours are then other words.
|
|
116
|
+
const forms = asLatin.length ? asLatin : ((await correctWords(vocabulary, [word])).get(normalize(word)) ?? []);
|
|
117
|
+
if (forms.length)
|
|
118
|
+
found.set(word, forms);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
// Only a Cyrillic word held exactly as typed: one near it is often a translation, not the name («cement», цемент).
|
|
122
|
+
const held = [...(await vocabulary.knownTerms(cyrillicSpellings(word)))];
|
|
123
|
+
const forms = held.length ? held : ((await correctWords(vocabulary, [word])).get(normalize(word)) ?? []);
|
|
59
124
|
if (forms.length)
|
|
60
125
|
found.set(word, forms);
|
|
61
126
|
}
|
|
@@ -244,6 +244,8 @@ export const memoriesStoreOver = (context) => {
|
|
|
244
244
|
}
|
|
245
245
|
return made;
|
|
246
246
|
});
|
|
247
|
+
// A read-only open never builds the index, so a memory added from a CLI would stay unfound by its search.
|
|
248
|
+
drainCorpus(database, CORPORA.memory, stemmerFor);
|
|
247
249
|
return memoryOf(rowOf(`memory:${id}`));
|
|
248
250
|
};
|
|
249
251
|
/** Applies a pending correction; only the owner retires a confirmed memory, whatever `agent_decisions` says. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.746.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|