@wirecat/cli-core 0.745.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 +25 -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/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 +15 -1
- package/dist/cli/untrusted-marks.js +33 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,31 @@ 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
|
+
|
|
8
33
|
## 0.745.0 — 24.11.2026
|
|
9
34
|
|
|
10
35
|
### 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, IDENTITY_UNTRUSTED, KNOWLEDGE_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, IDENTITY_UNTRUSTED, KNOWLEDGE_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";
|
|
@@ -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.
|
|
@@ -42,7 +52,11 @@ export declare const IDENTITY_UNTRUSTED: readonly ["name"];
|
|
|
42
52
|
* `text` or `title` would mark them too.
|
|
43
53
|
*/
|
|
44
54
|
export declare const DOCUMENT_CONTEXT_UNTRUSTED: string[];
|
|
45
|
-
/**
|
|
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
|
+
*/
|
|
46
60
|
export declare const marksUntrusted: <T extends Command>(command: T, fields?: readonly string[]) => T;
|
|
47
61
|
export declare const untrustedFieldsOf: (command: Command) => readonly string[] | undefined;
|
|
48
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.
|
|
@@ -127,9 +151,15 @@ export const DOCUMENT_CONTEXT_UNTRUSTED = [
|
|
|
127
151
|
"people.items.person.name",
|
|
128
152
|
];
|
|
129
153
|
const DECLARED = new WeakMap();
|
|
130
|
-
/**
|
|
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
|
+
*/
|
|
131
159
|
export const marksUntrusted = (command, fields = MESSAGE_UNTRUSTED) => {
|
|
132
|
-
|
|
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);
|
|
133
163
|
return command;
|
|
134
164
|
};
|
|
135
165
|
export const untrustedFieldsOf = (command) => DECLARED.get(command);
|
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",
|