@wirecat/cli-core 0.697.0 → 0.699.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 +74 -0
- package/dist/cli/documents/folders.d.ts +2 -0
- package/dist/cli/documents/library.d.ts +2 -0
- package/dist/cli/documents/library.js +5 -1
- package/dist/cli/documents/queries.d.ts +4 -0
- package/dist/cli/documents/queries.js +7 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +2 -2
- package/dist/cli/messenger/mcp-command.js +53 -4
- package/dist/cli/profile-token.d.ts +1 -1
- package/dist/cli/schedule/schedule-command.js +9 -4
- package/dist/cli/service-api-call.d.ts +6 -1
- package/dist/cli/service-api-call.js +6 -0
- package/dist/cli/service-api-manifest.js +18 -14
- package/dist/cli/token-session.d.ts +17 -0
- package/dist/cli/token-session.js +20 -0
- package/dist/conversations/link.d.ts +5 -2
- package/dist/conversations/link.js +27 -9
- package/dist/crm/manifest/map.d.ts +5 -1
- package/dist/crm/manifest/map.js +14 -8
- package/dist/crm/testing/manifest-fake.js +31 -2
- package/dist/errors/reasons.js +1 -0
- package/dist/manifest/index.d.ts +8 -0
- package/dist/manifest/index.js +8 -1
- package/dist/mcp/all-profiles.d.ts +9 -0
- package/dist/mcp/all-profiles.js +56 -14
- package/dist/ports/wirecat-tools.js +7 -0
- package/dist/store/sqlite/batches.js +5 -2
- package/dist/tracker/cli/index.d.ts +1 -1
- package/dist/tracker/cli/index.js +49 -36
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,80 @@ 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.699.0 — 18.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`manifestVerify` and `hostsFetch` in `@wirecat/cli-core/cli`**, so a CLI made from `wirecat.config.ts` keeps no
|
|
13
|
+
token check of its own. `manifestVerify` is `tokenSessionCommand`'s `verify` from the config's `auth.verify`: it sends
|
|
14
|
+
the one operation, refuses a token the answer does not call `active` (Attio answers a revoked key with 200), names a
|
|
15
|
+
missing id as the service's error, and keeps the id and the name when it is text. `hostsFetch(hosts, fetch)` reaches
|
|
16
|
+
only the CLI's hosts, over a test's fake when one is given.
|
|
17
|
+
- **`ProfileTokenStore` takes `keyring: undefined`**, so a CLI passes `baseContext`'s keyring as it is.
|
|
18
|
+
|
|
19
|
+
## 0.698.0 — 18.11.2026
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- **`folders list` of a documents CLI names each chosen folder.** A row has `name`, the folder's name when `folders add`
|
|
24
|
+
kept it, and `path` when the CLI gives `folderPath` to `documentLibraryCommands`. A folder shown only by its id
|
|
25
|
+
(ydisk's `resource_id`) now has words. A CLI that lists its own folders still answers `{ id }`.
|
|
26
|
+
- **ydisk joins `WIRECAT_TOOLS`.** Yandex Disk (`ydisk`, `@wirecat/yandex-disk-cli`) is on npm since 0.1.0, so every
|
|
27
|
+
CLI's first screen ("Works with") and first-run list of other WireCat tools now name it, and an upload refuses a file
|
|
28
|
+
from its folders (`yandex-disk-cli`, `YDISK_`) as it does for the other tools.
|
|
29
|
+
- **`auth.verify.active` in `wirecat.config.ts`** names where the token check's answer says the token still works.
|
|
30
|
+
Attio's `GET /v2/self` answers 200 `{ "active": false }` to an unknown, revoked or deleted token; a CLI can now
|
|
31
|
+
refuse that sign-in instead of failing on a missing id.
|
|
32
|
+
- **`valueAt` from `@wirecat/cli-core/manifest`** reads a dotted path into an answer as the source manifest does, so
|
|
33
|
+
a CLI's sign-in reads `auth.verify`'s paths the same way.
|
|
34
|
+
|
|
35
|
+
### Changed — may break callers
|
|
36
|
+
|
|
37
|
+
- **cli-core needs `@wirecat/cli-base` 0.117.0 or later**, whose command vocabulary has the tracker's nouns and whose
|
|
38
|
+
`signInPlace` and `fakeApi` know a Basic sign-in.
|
|
39
|
+
- **The tracker's commands follow the command vocabulary**, so `cli-dev lint` passes a tracker CLI (with cli-base
|
|
40
|
+
0.117.0, which has `issues`, `teams`, `states` and `labels`). Each list narrows by its query, as `deals list` does:
|
|
41
|
+
`issues list team:<id> project:<id> assignee:none state:<id> type:started label:<id>`, and `archived:include` on
|
|
42
|
+
every list, in place of `--team`, `--project`, `--assignee`, `--state`, `--type`, `--label` and `--archived`.
|
|
43
|
+
`type:` repeats for any of several types. `issues task` is `issues assign`: it makes the issue the owner's task
|
|
44
|
+
and changes nothing in the tracker; its `--due` reads times as `tasks --due` does (a day is its end, `3d` works). `issues search --any` is gone.
|
|
45
|
+
See [Trackers](docs/dev/TRACKER.md#commands).
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- **The `api` group tells a Basic scheme by its type, so a newer cli-base cannot change who signs.** cli-base #643
|
|
50
|
+
makes `signInPlace` sign Basic, and cli-core told Basic apart by `signInPlace` answering `undefined`. With that
|
|
51
|
+
cli-base, a call that offers Basic and a token would be signed with Basic, and a token without a user name would be
|
|
52
|
+
sent in base64, not refused with "run session start --login <name>". Both rules now hold with either cli-base.
|
|
53
|
+
- **A conversation never mixes the topics of a forum group.** A message's parent is a message of its own topic or
|
|
54
|
+
thread, or the thread's first message when that has text, as a WhatsApp community post its comments answer. In a
|
|
55
|
+
Telegram forum every message of a topic replies to the topic's empty first message: taken as a reply, it chained a
|
|
56
|
+
whole topic, and through those first messages' sender every topic, into one conversation, and its chunks mixed
|
|
57
|
+
topics. A messenger reply into another topic, an agent's answer naming one, and the rules never link across. The
|
|
58
|
+
linking-rules version is 6, so every chat built before reads as outdated and is rebuilt; a chunk whose text is
|
|
59
|
+
unchanged keeps its vector. `conversations batches next` now asks the agent about a message whose only reply is
|
|
60
|
+
one the build does not link.
|
|
61
|
+
- **A value the service cleared clears the stored copy.** A path past the end of a list, or under a `null` the
|
|
62
|
+
service sent, is now `null`, not "not sent": Attio's `values.job_title.0.value` on an empty list used to keep the
|
|
63
|
+
old position ([CRM.md](docs/dev/CRM.md#a-source-from-a-manifest)). Watch for: an `each` rule under such
|
|
64
|
+
a `null` now gives an empty list, so the record's links are cleared too.
|
|
65
|
+
- **`crmManifestFake` takes its own answer when a value is one of several types.** It wrote a mapped value into a
|
|
66
|
+
sample of the union's first branch, and its strict fake refused the row: every contract case of an Attio CLI
|
|
67
|
+
failed. The row is now sampled from the branch each mapped path needs, through objects, lists and `allOf`.
|
|
68
|
+
- **`<tool> mcp serve --profiles all` starts on a computer with no profile yet.** It answers the handshake and lists
|
|
69
|
+
the same tools a profile's own server lists (`<tool>_tools_search`, `<tool>_read`, and `<tool>_write` where a
|
|
70
|
+
command writes), each taking `profile`, and every call is refused with a `configuration_error` that names the
|
|
71
|
+
command to set up the first profile: `<tool> personal setup`, `<tool> personal session start` for a CLI that signs
|
|
72
|
+
in with a session, or `<tool> personal …` for one with neither. Before, it exited before the handshake, so
|
|
73
|
+
directories such as Glama, which start the server in an empty container to read its tools, marked WireCat servers
|
|
74
|
+
as not deployable. Nothing picks or makes a profile: which tools are listed never follows a profile's permissions,
|
|
75
|
+
so the list is built from the program itself. `mcp serve` with no profile named, and `--profiles` with a name that
|
|
76
|
+
does not exist, are still refused.
|
|
77
|
+
- **`schedule command` and `schedule agent` help no longer shows a messenger's commands in a CLI that is not a
|
|
78
|
+
messenger.** b24 showed `-- messages list <chat> --limit 50` and `b24 personal search messages 'date>1d'`, which it
|
|
79
|
+
does not have. A CLI with `messenger: false` now shows `-- doctor` and `b24 doctor`: these CLIs share no search or
|
|
80
|
+
sync command, and every CLI has `doctor`.
|
|
81
|
+
|
|
8
82
|
## 0.697.0 — 17.11.2026
|
|
9
83
|
|
|
10
84
|
### Added
|
|
@@ -12,6 +12,8 @@ export interface DocumentFolderCommands {
|
|
|
12
12
|
/** The selected profile's chosen folders, narrowed by `id:`. */
|
|
13
13
|
list(filter: Record<string, string>): {
|
|
14
14
|
id: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
path?: string;
|
|
15
17
|
}[];
|
|
16
18
|
/** Forgets the folder; answers its id. */
|
|
17
19
|
remove(input: string): string;
|
|
@@ -55,6 +55,8 @@ export interface DocumentLibraryOptions<M extends SourceFile> {
|
|
|
55
55
|
coverage: string;
|
|
56
56
|
/** The accounts a document names, for `identities list`; none when the provider shows none. */
|
|
57
57
|
people?: DocumentKnowledgePort["people"];
|
|
58
|
+
/** Where a chosen folder is at the provider, for `folders list`: a Disk path. Unset: the answer has no path. */
|
|
59
|
+
folderPath?(folder: M): string | undefined;
|
|
58
60
|
/** The CLI's own `folders browse`. */
|
|
59
61
|
browse?(folders: Command, tools: DocumentLibraryTools<M>): void;
|
|
60
62
|
}
|
|
@@ -297,7 +297,11 @@ export const documentLibraryCommands = (options) => {
|
|
|
297
297
|
},
|
|
298
298
|
list: (filter) => roots()
|
|
299
299
|
.filter((id) => filter.id === undefined || filter.id === id)
|
|
300
|
-
.map((id) =>
|
|
300
|
+
.map((id) => {
|
|
301
|
+
const file = files().folders().files?.[id];
|
|
302
|
+
const path = file ? options.folderPath?.(file) : undefined;
|
|
303
|
+
return { id, ...(file ? { name: file.name } : {}), ...(path ? { path } : {}) };
|
|
304
|
+
}),
|
|
301
305
|
remove: (input) => {
|
|
302
306
|
const id = options.idOf(input);
|
|
303
307
|
const chosen = files().folders();
|
|
@@ -5,6 +5,10 @@ import type { Fact, Memory } from "../../store/index.js";
|
|
|
5
5
|
import { type QueryWords } from "../list-query.js";
|
|
6
6
|
export declare const folderRow: v.StrictObjectSchema<{
|
|
7
7
|
readonly id: v.StringSchema<undefined>;
|
|
8
|
+
/** The folder as `folders add` named it; left out for a folder chosen before its name was kept. */
|
|
9
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
10
|
+
/** Where the provider says it is, when the CLI gives a `folderPath`: a Disk path. */
|
|
11
|
+
readonly path: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
8
12
|
}, undefined>;
|
|
9
13
|
export declare const mirrorRow: v.StrictObjectSchema<{
|
|
10
14
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -9,7 +9,13 @@ const registry = (entity, schema, native, examples) => ({
|
|
|
9
9
|
backend: "native",
|
|
10
10
|
fields: queryFieldsOf(schema, { native, examples }).map((field) => field.native ? { ...field, operators: ["term", "phrase"] } : field),
|
|
11
11
|
});
|
|
12
|
-
export const folderRow = v.strictObject({
|
|
12
|
+
export const folderRow = v.strictObject({
|
|
13
|
+
id: v.string(),
|
|
14
|
+
/** The folder as `folders add` named it; left out for a folder chosen before its name was kept. */
|
|
15
|
+
name: v.optional(v.string()),
|
|
16
|
+
/** Where the provider says it is, when the CLI gives a `folderPath`: a Disk path. */
|
|
17
|
+
path: v.optional(v.string()),
|
|
18
|
+
});
|
|
13
19
|
export const mirrorRow = v.strictObject({ id: v.string(), path: v.string(), folder: v.string() });
|
|
14
20
|
export const tagRow = v.strictObject({ tag: v.string() });
|
|
15
21
|
export const linkRow = v.looseObject({
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ export { HARNESSES, type Harness, harnessesOn, harnessInfo, harnessOfArgv, isHar
|
|
|
154
154
|
export { type AgentScheduleSpec, agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, type ScheduleHost, type ScheduleLimits, type ScheduleSite, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
155
155
|
export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
|
|
156
156
|
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
157
|
-
export { type ServiceApiCall, type ServiceApiCallOptions, serviceApiCall } from "./service-api-call.js";
|
|
157
|
+
export { hostsFetch, type ServiceApiCall, type ServiceApiCallOptions, serviceApiCall } from "./service-api-call.js";
|
|
158
158
|
export { manifestBaseUrl, type ServiceApiManifest, signRequest, siteValue } from "./service-api-manifest.js";
|
|
159
159
|
export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
160
160
|
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";
|
|
@@ -167,5 +167,5 @@ export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from
|
|
|
167
167
|
export { type RecoveryCheck, type RecoveryRun, recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
168
168
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
169
169
|
export type { TemplatesOptions } from "./templates-command.js";
|
|
170
|
-
export { signedInSite, type TokenSessionOptions, tokenSessionCommand } from "./token-session.js";
|
|
170
|
+
export { type ManifestVerifyOptions, manifestVerify, signedInSite, type TokenSessionOptions, tokenSessionCommand, } from "./token-session.js";
|
|
171
171
|
export { restartServers, type UpgradeContext } from "./upgrade-command.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -143,7 +143,7 @@ export { HARNESSES, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsC
|
|
|
143
143
|
export { agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
144
144
|
export { deniedKinds, deniedKindsOf } from "./search-left-out.js";
|
|
145
145
|
export { serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
146
|
-
export { serviceApiCall } from "./service-api-call.js";
|
|
146
|
+
export { hostsFetch, serviceApiCall } from "./service-api-call.js";
|
|
147
147
|
export { manifestBaseUrl, signRequest, siteValue } from "./service-api-manifest.js";
|
|
148
148
|
export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
149
149
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
@@ -155,5 +155,5 @@ export { runnable, withSafety } from "./steps.js";
|
|
|
155
155
|
export { sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
|
156
156
|
export { recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
157
157
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
158
|
-
export { signedInSite, tokenSessionCommand } from "./token-session.js";
|
|
158
|
+
export { manifestVerify, signedInSite, tokenSessionCommand, } from "./token-session.js";
|
|
159
159
|
export { restartServers } from "./upgrade-command.js";
|
|
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { realpathSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { CliError, resolvePaths, visibleControls } from "@wirecat/cli-base";
|
|
5
|
-
import { annotate } from "@wirecat/cli-base/commands";
|
|
5
|
+
import { annotate, describeProgram } from "@wirecat/cli-base/commands";
|
|
6
6
|
import { installerOf } from "@wirecat/cli-base/update";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
import { ATTACHMENT_LIMIT_ENV } from "../../attachments/limits.js";
|
|
@@ -10,7 +10,7 @@ import { mcpUrlOf, portOf, publicUrlOf } from "../../http/public-url.js";
|
|
|
10
10
|
import { httpLockFile } from "../../mcp/http/state.js";
|
|
11
11
|
import { envName } from "../../ports/app.js";
|
|
12
12
|
import { environmentOf } from "../context.js";
|
|
13
|
-
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE } from "../effects.js";
|
|
13
|
+
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE, readsOverMcpAt } from "../effects.js";
|
|
14
14
|
import { itemOf, renderAnswer } from "../envelope.js";
|
|
15
15
|
import { MCP_HTTP_DEFAULT_PORT, mcpServerCommand } from "../mcp-server-command.js";
|
|
16
16
|
import { rootOf } from "../profile.js";
|
|
@@ -325,8 +325,11 @@ const serveProfiles = async (self, context, host, flags, set) => {
|
|
|
325
325
|
throw new CliError("validation_error", `${bots.join(", ")} ${bots.length === 1 ? "is a bot profile" : "are bot profiles"}, served by \`${app.command} <profile> bot mcp serve\``);
|
|
326
326
|
// `all` reads the profiles again for each session, so one set up while the server runs appears.
|
|
327
327
|
const profiles = () => set.profiles().filter((profile) => state(profile) !== "bot");
|
|
328
|
-
|
|
329
|
-
|
|
328
|
+
// A directory starts the server in an empty container only to list its tools: it starts, and each call says how
|
|
329
|
+
// to set up a profile. Nothing here picks or makes one.
|
|
330
|
+
const setup = `no ${app.command} profile on this computer yet — set one up with \`${firstProfileCommand(self, app)}\` ` +
|
|
331
|
+
"(any name in place of personal), then connect again";
|
|
332
|
+
let catalogue;
|
|
330
333
|
const given = environmentOf(self).mcp ?? {};
|
|
331
334
|
const execPath = given.execPath ?? process.execPath;
|
|
332
335
|
const scriptPath = given.scriptPath ?? realpathSync(process.argv[1] ?? "");
|
|
@@ -340,6 +343,14 @@ const serveProfiles = async (self, context, host, flags, set) => {
|
|
|
340
343
|
signIn: (profile) => `profile ${profile} is not signed in — run \`${app.command} ${profile} setup\`, or sign in from WireCat Desktop, ` +
|
|
341
344
|
"then try again. If the owner did not choose this profile, ask which one.",
|
|
342
345
|
child: (profile) => ({ command: execPath, args: [scriptPath, profile, "mcp", "serve", ...tightened], env }),
|
|
346
|
+
catalogue: () => {
|
|
347
|
+
catalogue ??= catalogueOf(self, app);
|
|
348
|
+
catalogue.catch(() => {
|
|
349
|
+
catalogue = undefined;
|
|
350
|
+
});
|
|
351
|
+
return catalogue;
|
|
352
|
+
},
|
|
353
|
+
setup,
|
|
343
354
|
instructions: await host.instructions(profiles()),
|
|
344
355
|
note: (line) => context.renderer.note(line),
|
|
345
356
|
};
|
|
@@ -384,6 +395,44 @@ const serveProfiles = async (self, context, host, flags, set) => {
|
|
|
384
395
|
...(signal ? { signal } : {}),
|
|
385
396
|
});
|
|
386
397
|
};
|
|
398
|
+
/** `tg personal setup`, or `notion personal session start` for a CLI that signs in with a session. */
|
|
399
|
+
const firstProfileCommand = (self, app) => {
|
|
400
|
+
const root = rootOf(self);
|
|
401
|
+
if (root.commands.some((one) => one.name() === "setup"))
|
|
402
|
+
return `${app.command} personal setup`;
|
|
403
|
+
const session = root.commands.find((one) => one.name() === "session");
|
|
404
|
+
if (session?.commands.some((one) => one.name() === "start"))
|
|
405
|
+
return `${app.command} personal session start`;
|
|
406
|
+
return `${app.command} personal …`;
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* The tools a profile's server lists, built in this process from the program: which tools a server lists never
|
|
410
|
+
* follows a profile's permissions (they decide each command's availability inside the search), so no profile is
|
|
411
|
+
* needed, read or made.
|
|
412
|
+
*/
|
|
413
|
+
const catalogueOf = async (self, app) => {
|
|
414
|
+
const [{ McpServer }, { registerCommands }, { toolsFromCommands }, { listedTools }] = await Promise.all([
|
|
415
|
+
import("@modelcontextprotocol/server"),
|
|
416
|
+
import("../../mcp/surface.js"),
|
|
417
|
+
import("../../mcp/agent.js"),
|
|
418
|
+
import("../../mcp/all-profiles.js"),
|
|
419
|
+
]);
|
|
420
|
+
const root = rootOf(self);
|
|
421
|
+
const refuse = async () => {
|
|
422
|
+
throw new CliError("configuration_error", `no ${app.command} profile on this computer yet`);
|
|
423
|
+
};
|
|
424
|
+
const commands = Object.fromEntries(toolsFromCommands(describeProgram(root), {
|
|
425
|
+
includeUnavailable: true,
|
|
426
|
+
exclude: [["bot"], ["mcp"]],
|
|
427
|
+
fetchOnly: readsOverMcpAt(root),
|
|
428
|
+
}).map((one) => [
|
|
429
|
+
one.command,
|
|
430
|
+
{ title: one.title, description: one.description, writes: one.writes, input: one.input, run: refuse },
|
|
431
|
+
]));
|
|
432
|
+
const server = new McpServer({ name: app.command, version: app.version }, { capabilities: { tools: {} } });
|
|
433
|
+
registerCommands(server, app.command, commands, app.errors, undefined, app.messenger);
|
|
434
|
+
return listedTools(server);
|
|
435
|
+
};
|
|
387
436
|
const TAIL_LINES = 20;
|
|
388
437
|
const TAIL_BYTES = 2_000;
|
|
389
438
|
const TAIL_WAIT_MS = 500;
|
|
@@ -4,7 +4,7 @@ export type TokenStorage = "keyring" | "file";
|
|
|
4
4
|
export interface ProfileTokenStoreOptions {
|
|
5
5
|
app: AppIdentity;
|
|
6
6
|
env?: NodeJS.ProcessEnv;
|
|
7
|
-
keyring?: KeyringStore;
|
|
7
|
+
keyring?: KeyringStore | undefined;
|
|
8
8
|
/** Where the one warning about an unreachable keyring goes; stderr when left out. */
|
|
9
9
|
warn?: (message: string) => void;
|
|
10
10
|
}
|
|
@@ -107,9 +107,12 @@ const deliveryOf = ({ notifyOn, deliverTo }) => ({
|
|
|
107
107
|
...(deliverTo?.length ? { to: deliverTo } : {}),
|
|
108
108
|
});
|
|
109
109
|
/** What the schedule command needs of a CLI: who it is and, per command, where it prints and which profile runs. */
|
|
110
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* `skill show follow-ups` exists only for messenger CLIs. The others share no search or sync command, so their example
|
|
112
|
+
* names `doctor`, which every CLI has and which takes no profile there.
|
|
113
|
+
*/
|
|
111
114
|
const promptExample = (app) => app.messenger === false
|
|
112
|
-
? `
|
|
115
|
+
? `say what needs attention in this installation: ${app.command} doctor`
|
|
113
116
|
: `run the daily follow-up review: ${app.command} skill show follow-ups`;
|
|
114
117
|
/** The agent-schedule settings a host with `newMail` writes into its config file's top level (WC-CMD-30). */
|
|
115
118
|
export const SCHEDULE_SETTINGS = [
|
|
@@ -375,6 +378,8 @@ export const runScheduleNow = async (command, site, file, { routes, agentInput }
|
|
|
375
378
|
*/
|
|
376
379
|
export const scheduleCommandFor = ({ app, context: contextOf, newMail, agentInput, limits: configured, agentRuns = [], }) => {
|
|
377
380
|
const agentClis = [app, ...agentRuns];
|
|
381
|
+
const messenger = app.messenger !== false;
|
|
382
|
+
const commandExample = messenger ? "messages list <chat> --limit 50" : "doctor";
|
|
378
383
|
const command = new Command("schedule").description(`run a ${app.command} command or an agent later or on a timer (systemd, launchd, Task Scheduler); an agent cannot send`);
|
|
379
384
|
const prepare = (self, resolving = {}) => {
|
|
380
385
|
const context = contextOf(self, resolving);
|
|
@@ -462,9 +467,9 @@ export const scheduleCommandFor = ({ app, context: contextOf, newMail, agentInpu
|
|
|
462
467
|
`${app.command} personal schedule command morning-check --at 08:00 -- doctor`,
|
|
463
468
|
],
|
|
464
469
|
}))
|
|
465
|
-
.description(`run ${app.command} <args…> on a timer — reads save what they read, so this is how a chat's history fills the store`)
|
|
470
|
+
.description(`run ${app.command} <args…> on a timer — reads save what they read, so this is how ${messenger ? "a chat's history fills the store" : "the store stays current"}`)
|
|
466
471
|
.argument("<name>", "lowercase letters, digits and dashes")
|
|
467
|
-
.argument("<args...>", `the ${app.command} command after its name, e.g. --
|
|
472
|
+
.argument("<args...>", `the ${app.command} command after its name, e.g. -- ${commandExample}`)).action(async function (name, args) {
|
|
468
473
|
const { environment, save } = prepare(this);
|
|
469
474
|
if (args[0] === "schedule")
|
|
470
475
|
throw new CliError("validation_error", "a schedule cannot run schedule");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ManifestOperation } from "@wirecat/cli-base/codegen";
|
|
2
|
-
import type
|
|
2
|
+
import { type FetchLike } from "@wirecat/cli-base/http";
|
|
3
3
|
import type { ApiCommandInput } from "./bot/api.js";
|
|
4
4
|
import { type HttpApiSendOptions } from "./bot/api-http.js";
|
|
5
5
|
import { type ServiceApiManifest } from "./service-api-manifest.js";
|
|
@@ -21,6 +21,11 @@ export interface ServiceApiCallOptions {
|
|
|
21
21
|
headers?: (operation: ManifestOperation) => Record<string, string>;
|
|
22
22
|
failure?: HttpApiSendOptions["failure"];
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* A fetch that reaches only `hosts` (WC-CMD-32), over the fetch a test gives in its environment, or the network when
|
|
26
|
+
* none: a CLI passes `environment.fetch` as it is.
|
|
27
|
+
*/
|
|
28
|
+
export declare const hostsFetch: (hosts: readonly string[], fetch: FetchLike | undefined) => FetchLike;
|
|
24
29
|
/**
|
|
25
30
|
* The `api` group's request path for code that is not a command, such as a source read from a manifest: the same
|
|
26
31
|
* request building, sign-in header, redirect rule, run record and refusals as `serviceApiCommand`, without a guard. It
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { hostFetch } from "@wirecat/cli-base/http";
|
|
2
3
|
import { Command } from "commander";
|
|
3
4
|
import { httpApiRequest, httpApiSend } from "./bot/api-http.js";
|
|
4
5
|
import { manifestBaseUrl, signRequest } from "./service-api-manifest.js";
|
|
6
|
+
/**
|
|
7
|
+
* A fetch that reaches only `hosts` (WC-CMD-32), over the fetch a test gives in its environment, or the network when
|
|
8
|
+
* none: a CLI passes `environment.fetch` as it is.
|
|
9
|
+
*/
|
|
10
|
+
export const hostsFetch = (hosts, fetch) => hostFetch({ hosts, ...(fetch ? { fetch } : {}) });
|
|
5
11
|
// The run record and the fetch are the only things httpApiSend asks a command for, and a sync has no command of its own.
|
|
6
12
|
const NO_COMMAND = new Command("source");
|
|
7
13
|
/**
|
|
@@ -67,18 +67,19 @@ const serverValue = (name, value, code = "configuration_error") => {
|
|
|
67
67
|
* none: its security, its own or else the document's, is absent, as in a spec that says nothing about sign-in, or
|
|
68
68
|
* empty (`[]`, `[{}]`). An optional sign-in (`[{}, { oauth: [] }]`) still sends the token.
|
|
69
69
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
const isBasic = (scheme) => scheme.type === "http" && /^basic$/i.test(scheme.scheme ?? "");
|
|
71
|
+
// Told apart by the scheme, not by signInPlace: a newer cli-base signs Basic and an older one does not, and
|
|
72
|
+
// either may be installed. Neither refuses a token without a user name. The token is `<user>:<password>`, as
|
|
73
|
+
// `session start --login` keeps it.
|
|
74
|
+
const BASIC = {
|
|
75
|
+
in: "header",
|
|
76
|
+
name: "authorization",
|
|
77
|
+
value: (token) => {
|
|
78
|
+
if (!token.includes(":"))
|
|
79
|
+
throw new CliError("authentication_error", "this service signs in with a user name and a password: run session start --login <name>");
|
|
80
|
+
return `Basic ${Buffer.from(token).toString("base64")}`;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
82
83
|
const authOf = (manifest, operation) => {
|
|
83
84
|
const requirements = signInRequirements(operation, manifest.security);
|
|
84
85
|
if (!requirements)
|
|
@@ -86,8 +87,11 @@ const authOf = (manifest, operation) => {
|
|
|
86
87
|
const names = requirements.flatMap((one) => Object.keys(one));
|
|
87
88
|
const sendable = names.flatMap((name) => {
|
|
88
89
|
const scheme = manifest.securitySchemes?.[name];
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
if (!scheme)
|
|
91
|
+
return [];
|
|
92
|
+
const basic = isBasic(scheme);
|
|
93
|
+
const place = basic ? BASIC : signInPlace(scheme);
|
|
94
|
+
return place ? [{ place, basic }] : [];
|
|
91
95
|
});
|
|
92
96
|
// Basic only when nothing else is offered: it needs a user name a token sign-in does not keep.
|
|
93
97
|
const auth = (sendable.find((one) => one.place.in === "header" && !one.basic) ??
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { FetchLike } from "@wirecat/cli-base/http";
|
|
1
2
|
import { Command } from "commander";
|
|
3
|
+
import type { CliVerify } from "../manifest/index.js";
|
|
2
4
|
import type { AppIdentity } from "../ports/app.js";
|
|
3
5
|
import type { EventSink } from "../runs/events.js";
|
|
4
6
|
import { ProfileTokenStore, type TokenStorage } from "./profile-token.js";
|
|
7
|
+
import { type ServiceApiManifest } from "./service-api-manifest.js";
|
|
5
8
|
import type { GlobalFlags, ResolveOptions, Settings } from "./settings.js";
|
|
6
9
|
export interface TokenSessionOptions {
|
|
7
10
|
app: AppIdentity;
|
|
@@ -43,6 +46,20 @@ export interface TokenSessionOptions {
|
|
|
43
46
|
/** One sentence more for `session end --help`, such as what of the service's own tools it leaves alone. */
|
|
44
47
|
endNote?: string;
|
|
45
48
|
}
|
|
49
|
+
export interface ManifestVerifyOptions {
|
|
50
|
+
manifest: ServiceApiManifest;
|
|
51
|
+
/** The service's name in messages: "Attio". */
|
|
52
|
+
service: string;
|
|
53
|
+
/** The config's `auth.verify`: the operation, where its answer holds the id and a name, and whether it is live. */
|
|
54
|
+
verify: CliVerify;
|
|
55
|
+
/** The command's host-checked fetch, such as `hostsFetch(hosts, environment.fetch)`. */
|
|
56
|
+
fetch: (command: Command) => FetchLike;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `verify` for `tokenSessionCommand` from a config's `auth.verify`: the one operation is sent with the token, a token the
|
|
60
|
+
* answer does not call active is refused, and the account is the id and name the answer holds.
|
|
61
|
+
*/
|
|
62
|
+
export declare const manifestVerify: ({ manifest, service, verify, fetch }: ManifestVerifyOptions) => TokenSessionOptions["verify"];
|
|
46
63
|
export declare const storageOf: (raw: string) => TokenStorage;
|
|
47
64
|
/**
|
|
48
65
|
* `session start | status | end | list` for a service signed in with one token (WC-ACCT-12): the token is asked hidden
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
+
import { at as valueAt } from "../crm/manifest/map.js";
|
|
4
5
|
import { readSecret } from "../terminal/prompt.js";
|
|
5
6
|
import { baseContext, environmentOf, outputFor, secretInputOf } from "./context.js";
|
|
6
7
|
import { refuseOffline } from "./early-refusal.js";
|
|
@@ -9,7 +10,26 @@ import { itemOf, listOf, renderAnswer } from "./envelope.js";
|
|
|
9
10
|
import { profilesHere, rememberAccount } from "./messenger/accounts.js";
|
|
10
11
|
import { commandWords, profileFree, refuseCommandName, rootOf } from "./profile.js";
|
|
11
12
|
import { ProfileTokenStore } from "./profile-token.js";
|
|
13
|
+
import { serviceApiCall } from "./service-api-call.js";
|
|
12
14
|
import { siteValue } from "./service-api-manifest.js";
|
|
15
|
+
/**
|
|
16
|
+
* `verify` for `tokenSessionCommand` from a config's `auth.verify`: the one operation is sent with the token, a token the
|
|
17
|
+
* answer does not call active is refused, and the account is the id and name the answer holds.
|
|
18
|
+
*/
|
|
19
|
+
export const manifestVerify = ({ manifest, service, verify, fetch }) => async (command, token) => {
|
|
20
|
+
const call = serviceApiCall({ manifest, service, fetch: fetch(command), token: () => token });
|
|
21
|
+
const answer = await call(verify.operation, { path: {}, query: {}, headers: {}, fields: {} });
|
|
22
|
+
// A service such as Attio answers a revoked key with 200 and `active: false`, not with 401.
|
|
23
|
+
if (verify.active !== undefined && valueAt(answer, verify.active) !== true)
|
|
24
|
+
throw new CliError("authentication_error", `${service} does not accept this token; sign in again`);
|
|
25
|
+
const id = valueAt(answer, verify.id);
|
|
26
|
+
if (typeof id !== "string" && typeof id !== "number")
|
|
27
|
+
throw new CliError("provider_error", `${service} answered ${verify.operation} without ${verify.id}`, {
|
|
28
|
+
reason: "verify.no-id",
|
|
29
|
+
});
|
|
30
|
+
const name = verify.name === undefined ? undefined : valueAt(answer, verify.name);
|
|
31
|
+
return { id: String(id), account: { id: String(id), ...(typeof name === "string" ? { name } : {}) } };
|
|
32
|
+
};
|
|
13
33
|
export const storageOf = (raw) => {
|
|
14
34
|
if (raw === "keyring" || raw === "file")
|
|
15
35
|
return raw;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Id, Message } from "../domain/models.js";
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 5: a message longer than a chunk is split into overlapping pieces. 6: a message's parent is always in its own
|
|
4
|
+
* topic or thread, so a forum's topics are no longer one conversation. Builds before the current version are outdated.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RULES_VERSION = 6;
|
|
4
7
|
/** How far back a rule looks, in messages: 97% of reply parents sat within 50 in a measured group. */
|
|
5
8
|
export declare const LOOK_BACK = 50;
|
|
6
9
|
export type LinkInput = Pick<Message, "id" | "senderId" | "text" | "timestamp" | "replyToId" | "threadId" | "mentions"> & Partial<Pick<Message, "senderName">>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 5: a message longer than a chunk is split into overlapping pieces. 6: a message's parent is always in its own
|
|
3
|
+
* topic or thread, so a forum's topics are no longer one conversation. Builds before the current version are outdated.
|
|
4
|
+
*/
|
|
5
|
+
export const RULES_VERSION = 6;
|
|
3
6
|
/** How far back a rule looks, in messages: 97% of reply parents sat within 50 in a measured group. */
|
|
4
7
|
export const LOOK_BACK = 50;
|
|
5
8
|
// Tuned on the IRC dev split (bench/disentangle/sweep.ts); wider windows gained nothing.
|
|
@@ -13,32 +16,46 @@ export const linkMessages = (messages, { handles = new Map(), answers = new Map(
|
|
|
13
16
|
const links = [];
|
|
14
17
|
const parents = new Map();
|
|
15
18
|
const conversationOf = new Map();
|
|
19
|
+
const held = new Map();
|
|
16
20
|
const conversations = [];
|
|
17
21
|
const window = [];
|
|
18
22
|
for (const message of messages) {
|
|
19
23
|
check?.();
|
|
20
24
|
const found = [
|
|
21
|
-
...replyLink(message,
|
|
25
|
+
...replyLink(message, held),
|
|
22
26
|
...mentionLinks(message, window, handles),
|
|
23
27
|
...sameSenderLink(message, window),
|
|
24
28
|
];
|
|
25
29
|
links.push(...found);
|
|
26
|
-
const parent = choose(found, answers, message
|
|
30
|
+
const parent = choose(found, answers, message, held);
|
|
27
31
|
parents.set(message.id, parent);
|
|
28
32
|
const conversation = parent === null ? conversations.length : conversationOf.get(parent);
|
|
29
33
|
if (conversation === conversations.length)
|
|
30
34
|
conversations.push([]);
|
|
31
35
|
conversations[conversation]?.push(message.id);
|
|
32
36
|
conversationOf.set(message.id, conversation);
|
|
37
|
+
held.set(message.id, { threadId: message.threadId, text: message.text.trim() !== "" });
|
|
33
38
|
window.push(message);
|
|
34
39
|
if (window.length > LOOK_BACK)
|
|
35
40
|
window.shift();
|
|
36
41
|
}
|
|
37
42
|
return { links, parents, conversations };
|
|
38
43
|
};
|
|
39
|
-
const replyLink = (message, held) => message.replyToId !== undefined && held
|
|
44
|
+
const replyLink = (message, held) => message.replyToId !== undefined && inThread(held, message.replyToId, message)
|
|
40
45
|
? [link(message, message.replyToId, "provider", "reply", 1, "reply")]
|
|
41
46
|
: [];
|
|
47
|
+
/**
|
|
48
|
+
* Whether `id` may be the message's parent: a message of the same topic or thread, or the thread's own first
|
|
49
|
+
* message when it says something, as a WhatsApp community post its comments answer. A Telegram forum topic starts
|
|
50
|
+
* with an empty service message every message of the topic replies to: linked, it chained the whole topic, and
|
|
51
|
+
* through those first messages' sender every topic, into one conversation.
|
|
52
|
+
*/
|
|
53
|
+
const inThread = (held, id, message) => {
|
|
54
|
+
const parent = held.get(id);
|
|
55
|
+
if (!parent)
|
|
56
|
+
return false;
|
|
57
|
+
return parent.threadId === message.threadId || (id === message.threadId && parent.text);
|
|
58
|
+
};
|
|
42
59
|
const mentionLinks = (message, window, handles) => {
|
|
43
60
|
const links = [];
|
|
44
61
|
const people = new Set([...mentioned(message.text, handles)].flatMap((handle) => handles.get(handle) ?? []));
|
|
@@ -74,15 +91,16 @@ const mentioned = (text, handles) => {
|
|
|
74
91
|
return found;
|
|
75
92
|
};
|
|
76
93
|
/** The messenger's reply first, then the most confident rule; on a tie, the one found first. */
|
|
77
|
-
const choose = (links, answers,
|
|
94
|
+
const choose = (links, answers, message, held) => {
|
|
78
95
|
const provider = links.find((one) => one.source === "provider");
|
|
79
96
|
if (provider)
|
|
80
97
|
return provider.parentId;
|
|
81
|
-
// An answer naming a message this chat no longer holds,
|
|
82
|
-
|
|
98
|
+
// An answer naming a message this chat no longer holds, a later one or one in another topic leaves the choice
|
|
99
|
+
// to the rules.
|
|
100
|
+
const answer = answers.get(message.id);
|
|
83
101
|
if (answer === null)
|
|
84
102
|
return null;
|
|
85
|
-
if (answer !== undefined && held
|
|
103
|
+
if (answer !== undefined && inThread(held, answer, message))
|
|
86
104
|
return answer;
|
|
87
105
|
let best;
|
|
88
106
|
for (const one of links)
|
|
@@ -4,7 +4,11 @@ import type { CrmRule } from "./manifest.js";
|
|
|
4
4
|
/** The service sent nothing at this path: the field is left out, so the stored copy keeps what it held. */
|
|
5
5
|
export declare const MISSING: unique symbol;
|
|
6
6
|
type Read = unknown | typeof MISSING;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A dotted path; a number steps into a list (`results.0.id`), and `.` is the value itself. Past the end of a list the
|
|
9
|
+
* service sent, or under a `null` it sent, is "none" (`null`), not "not sent": a cleared value must clear the copy,
|
|
10
|
+
* as Attio's `values.job_title.0.value` on an empty list.
|
|
11
|
+
*/
|
|
8
12
|
export declare const at: (value: unknown, path: string) => unknown;
|
|
9
13
|
export declare const evaluate: (rule: CrmRule, raw: CrmRaw) => Read;
|
|
10
14
|
/** A time as epoch ms: ISO, epoch seconds, or epoch ms as digits in a string (HubSpot sends both forms). */
|
package/dist/crm/manifest/map.js
CHANGED
|
@@ -2,16 +2,22 @@ import { DEAL_STATUSES } from "../../domain/deals.js";
|
|
|
2
2
|
import { amountOf, crmValuesOf, epoch, fullName, id, isRaw, number, text } from "../values.js";
|
|
3
3
|
/** The service sent nothing at this path: the field is left out, so the stored copy keeps what it held. */
|
|
4
4
|
export const MISSING = Symbol("missing");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* A dotted path; a number steps into a list (`results.0.id`), and `.` is the value itself. Past the end of a list the
|
|
7
|
+
* service sent, or under a `null` it sent, is "none" (`null`), not "not sent": a cleared value must clear the copy,
|
|
8
|
+
* as Attio's `values.job_title.0.value` on an empty list.
|
|
9
|
+
*/
|
|
6
10
|
export const at = (value, path) => path === "."
|
|
7
11
|
? value
|
|
8
|
-
: path
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
?
|
|
12
|
-
:
|
|
13
|
-
? inner[key]
|
|
14
|
-
:
|
|
12
|
+
: path
|
|
13
|
+
.split(".")
|
|
14
|
+
.reduce((inner, key) => inner === null
|
|
15
|
+
? null
|
|
16
|
+
: Array.isArray(inner) && /^\d+$/.test(key)
|
|
17
|
+
? (inner[Number(key)] ?? null)
|
|
18
|
+
: isRaw(inner)
|
|
19
|
+
? inner[key]
|
|
20
|
+
: undefined, value);
|
|
15
21
|
const read = (raw, path) => {
|
|
16
22
|
const found = at(raw, path);
|
|
17
23
|
return found === undefined ? MISSING : found;
|
|
@@ -119,6 +119,33 @@ export const crmManifestFake = (input, options) => {
|
|
|
119
119
|
return undefined;
|
|
120
120
|
return ["string", "unknown"].includes(type) ? String(value) : undefined;
|
|
121
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* The schema with each union on the way to `keys` cut to the branch that has the rest of the path: a sample of the
|
|
124
|
+
* first branch of Attio's seventeen value types would carry another type's fields, and the strict fake refuses it.
|
|
125
|
+
*/
|
|
126
|
+
const narrowed = (node, keys) => {
|
|
127
|
+
if (keys.length === 0)
|
|
128
|
+
return node;
|
|
129
|
+
const found = resolve(node, definitions);
|
|
130
|
+
const [key, ...rest] = keys;
|
|
131
|
+
const fits = (one) => "node" in walk(one, keys.join("."), definitions);
|
|
132
|
+
switch (found.type) {
|
|
133
|
+
case "union": {
|
|
134
|
+
const branch = found.of.find(fits);
|
|
135
|
+
return branch ? narrowed(branch, keys) : node;
|
|
136
|
+
}
|
|
137
|
+
case "allOf":
|
|
138
|
+
return { ...found, of: found.of.map((one) => (fits(one) ? narrowed(one, keys) : one)) };
|
|
139
|
+
case "array":
|
|
140
|
+
return /^\d+$/.test(key) ? { ...found, items: narrowed(found.items, rest) } : node;
|
|
141
|
+
case "object": {
|
|
142
|
+
const inner = found.properties[key] ?? found.additionalProperties;
|
|
143
|
+
return inner ? { ...found, properties: { ...found.properties, [key]: narrowed(inner, rest) } } : node;
|
|
144
|
+
}
|
|
145
|
+
default:
|
|
146
|
+
return node;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
122
149
|
/** The object a dotted path ends in, with its last key and schema: what is missing is built from the schema's sample. */
|
|
123
150
|
const parentOf = (row, path, node) => {
|
|
124
151
|
const keys = path.split(".");
|
|
@@ -128,7 +155,7 @@ export const crmManifestFake = (input, options) => {
|
|
|
128
155
|
for (const [place, one] of keys.entries()) {
|
|
129
156
|
const inner = schema === undefined ? undefined : (step(schema, one, definitions) ?? undefined);
|
|
130
157
|
if (typeof here[one] !== "object" || here[one] === null) {
|
|
131
|
-
const made = sample(inner);
|
|
158
|
+
const made = sample(inner && narrowed(inner, [...keys.slice(place + 1), key]));
|
|
132
159
|
here[one] = typeof made === "object" && made !== null ? made : /^\d+$/.test(keys[place + 1] ?? key) ? [] : {};
|
|
133
160
|
}
|
|
134
161
|
here = here[one];
|
|
@@ -168,7 +195,9 @@ export const crmManifestFake = (input, options) => {
|
|
|
168
195
|
}
|
|
169
196
|
};
|
|
170
197
|
const rowOf = (node, rules, types, n, given) => {
|
|
171
|
-
|
|
198
|
+
// Sampled already cut to the branches the rules write into, so a list the first sample holds has the right type.
|
|
199
|
+
const paths = Object.values(rules).flatMap((rule) => pathOf(rule) ?? []);
|
|
200
|
+
const made = sample(node && paths.reduce((cut, path) => narrowed(cut, path.split(".")), node));
|
|
172
201
|
const row = isRaw(made) ? made : {};
|
|
173
202
|
for (const [field, rule] of Object.entries(rules)) {
|
|
174
203
|
const path = pathOf(rule);
|
package/dist/errors/reasons.js
CHANGED
|
@@ -63,6 +63,7 @@ const PROVIDER_API = [
|
|
|
63
63
|
validation("api.unknown-method", "the provider has no method by this name"),
|
|
64
64
|
["api.disabled", "configuration_error", "the provider's API is turned off for this OAuth project"],
|
|
65
65
|
["manifest.invalid", "configuration_error", "the source manifest does not match its shape or the generated API"],
|
|
66
|
+
["verify.no-id", "provider_error", "the answer to the sign-in check holds no account id where auth.verify says"],
|
|
66
67
|
["provider.usage-limit", "rate_limited", "the account's usage limit at the provider is reached; wait, do not retry"],
|
|
67
68
|
["access.denied", "permission_error", "the provider refused this account access to the item"],
|
|
68
69
|
["item.not-found", "not_found", "the provider has no item by this id, or this account cannot see it"],
|
package/dist/manifest/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CrmManifest } from "../crm/manifest/manifest.js";
|
|
2
2
|
import type { OAuthProvider } from "../oauth/provider.js";
|
|
3
3
|
import type { TrackerManifest } from "../tracker/manifest/manifest.js";
|
|
4
|
+
/** A dotted path into an answer, as the source manifest reads it: `auth.verify`'s `id`, `name` and `active`. */
|
|
5
|
+
export { at as valueAt } from "../crm/manifest/map.js";
|
|
4
6
|
/**
|
|
5
7
|
* The operation that answers whose the token is, and where its answer holds the account's id (and a name to show):
|
|
6
8
|
* `{ operation: "getV2Self", id: "workspace_id", name: "workspace_name" }`. `session start` checks a token with it.
|
|
@@ -9,6 +11,12 @@ export interface CliVerify {
|
|
|
9
11
|
operation: string;
|
|
10
12
|
id: string;
|
|
11
13
|
name?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Where the answer says the token still works, for a service that answers a dead token with success: Attio's
|
|
16
|
+
* `GET /v2/self` gives 200 `{ "active": false }` to an unknown, revoked or deleted token. Anything but `true` there is
|
|
17
|
+
* a refused sign-in.
|
|
18
|
+
*/
|
|
19
|
+
active?: string;
|
|
12
20
|
}
|
|
13
21
|
export type CliAuth = {
|
|
14
22
|
preset: "none";
|
package/dist/manifest/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
+
/** A dotted path into an answer, as the source manifest reads it: `auth.verify`'s `id`, `name` and `active`. */
|
|
4
|
+
export { at as valueAt } from "../crm/manifest/map.js";
|
|
3
5
|
export const CLI_CATEGORIES = [
|
|
4
6
|
"messenger",
|
|
5
7
|
"mail",
|
|
@@ -47,7 +49,12 @@ const httpsUrl = v.pipe(v.string(), v.check((text) => !/\s/.test(text), "an http
|
|
|
47
49
|
// A token handed back in the fragment (OAuth's implicit flow) would be committed too; a description needs none.
|
|
48
50
|
v.check((text) => !urlOf(text)?.hash, "an https URL without a #fragment"));
|
|
49
51
|
const dotPath = v.pipe(v.string(), v.regex(/^[^.\s]+(\.[^.\s]+)*$/, "a dot path into the answer, such as data.id"));
|
|
50
|
-
const verify = v.optional(v.strictObject({
|
|
52
|
+
const verify = v.optional(v.strictObject({
|
|
53
|
+
operation: v.pipe(v.string(), v.minLength(1)),
|
|
54
|
+
id: dotPath,
|
|
55
|
+
name: v.optional(dotPath),
|
|
56
|
+
active: v.optional(dotPath),
|
|
57
|
+
}));
|
|
51
58
|
const schema = v.strictObject({
|
|
52
59
|
identity: v.strictObject({
|
|
53
60
|
command: word,
|
|
@@ -21,6 +21,10 @@ export interface AllProfilesOptions {
|
|
|
21
21
|
/** How to sign a profile in, for the refusal of a call it cannot serve yet. */
|
|
22
22
|
signIn?: (profile: string) => string;
|
|
23
23
|
child: (profile: string) => ChildSpec;
|
|
24
|
+
/** The tools a profile's server would list, for a session that starts before any profile exists. */
|
|
25
|
+
catalogue?: () => Promise<readonly Tool[]>;
|
|
26
|
+
/** How to set up the first profile: every call of a session with no profile is refused with it. */
|
|
27
|
+
setup?: string;
|
|
24
28
|
instructions: string;
|
|
25
29
|
idleMs?: number;
|
|
26
30
|
/** A child's stderr, line by line; never this process's stdout, which carries the protocol. */
|
|
@@ -44,6 +48,11 @@ export declare const allProfilesServer: (options: AllProfilesOptions) => {
|
|
|
44
48
|
build: () => McpServer;
|
|
45
49
|
close: () => Promise<void>;
|
|
46
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* What a server answers to `tools/list`, asked in this process: the list for a session with no profile, which has no
|
|
53
|
+
* profile's server to ask.
|
|
54
|
+
*/
|
|
55
|
+
export declare const listedTools: (server: McpServer) => Promise<Tool[]>;
|
|
47
56
|
/** Over stdin and stdout until the client closes stdin or the process is told to stop; then the children close. */
|
|
48
57
|
export declare const serveAllProfilesOverStdio: (options: AllProfilesOptions, io?: {
|
|
49
58
|
stdin?: Readable;
|
package/dist/mcp/all-profiles.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
|
+
import { InMemoryTransport, McpServer } from "@modelcontextprotocol/server";
|
|
4
4
|
import { StdioServerTransport, serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
5
5
|
import { CliError, errorObjectOf, mcpErrorResult } from "@wirecat/cli-base";
|
|
6
6
|
import { CALLER_META_KEY, callerOf, PROXY_CLIENT_NAME } from "./caller.js";
|
|
@@ -157,15 +157,18 @@ export const withProfile = (tool, profiles, name, signedIn = () => true) => {
|
|
|
157
157
|
inputSchema: {
|
|
158
158
|
...tool.inputSchema,
|
|
159
159
|
properties: {
|
|
160
|
-
profile:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
profile: profiles.length === 0
|
|
161
|
+
? // An empty enum matches nothing, and a directory that checks the schema refuses the tool.
|
|
162
|
+
{
|
|
163
|
+
type: "string",
|
|
164
|
+
description: `Which ${name} account, by its profile. None is set up on this computer yet.`,
|
|
165
|
+
}
|
|
166
|
+
: {
|
|
167
|
+
type: "string",
|
|
168
|
+
enum: [...profiles],
|
|
169
|
+
oneOf: profiles.map((one) => ({ const: one, title: signedIn(one) ? one : `${one} — not signed in` })),
|
|
170
|
+
description: `Which ${name} account, by its profile. If the owner did not name one, ask which — never guess.${states}`,
|
|
171
|
+
},
|
|
169
172
|
...schema.properties,
|
|
170
173
|
},
|
|
171
174
|
required: ["profile", ...(schema.required ?? []).filter((field) => field !== "profile")],
|
|
@@ -197,11 +200,15 @@ export const allProfilesServer = (options) => {
|
|
|
197
200
|
const signedIn = (profile) => options.signedIn?.(profile) ?? true;
|
|
198
201
|
const build = () => {
|
|
199
202
|
const profiles = [...options.profiles()].sort();
|
|
200
|
-
const server = new McpServer({ name: options.command, version: options.version }, {
|
|
203
|
+
const server = new McpServer({ name: options.command, version: options.version }, {
|
|
204
|
+
capabilities: { tools: {} },
|
|
205
|
+
// Read per session, as the profiles are: clients cut the instructions short, so this line comes first.
|
|
206
|
+
instructions: profiles.length === 0 && options.setup
|
|
207
|
+
? `${options.setup.charAt(0).toUpperCase()}${options.setup.slice(1)}.\n${options.instructions}`
|
|
208
|
+
: options.instructions,
|
|
209
|
+
});
|
|
201
210
|
server.server.setRequestHandler("tools/list", async () => ({
|
|
202
|
-
tools: profiles.length === 0
|
|
203
|
-
? []
|
|
204
|
-
: (await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn)),
|
|
211
|
+
tools: (profiles.length === 0 ? ((await options.catalogue?.()) ?? []) : await tools(profiles)).map((one) => withProfile(one, profiles, options.name, signedIn)),
|
|
205
212
|
}));
|
|
206
213
|
const callers = {
|
|
207
214
|
env: options.env ?? process.env,
|
|
@@ -211,6 +218,8 @@ export const allProfilesServer = (options) => {
|
|
|
211
218
|
server.server.setRequestHandler("tools/call", async (request, ctx) => {
|
|
212
219
|
const { name, arguments: given = {}, _meta } = request.params;
|
|
213
220
|
const { profile, ...rest } = given;
|
|
221
|
+
if (profiles.length === 0)
|
|
222
|
+
return refusal("configuration_error", options.setup ?? `no ${options.command} profile on this computer yet.`);
|
|
214
223
|
if (typeof profile !== "string" || !profiles.includes(profile))
|
|
215
224
|
return refusal("validation_error", `${name} needs "profile", one of: ${profiles.join(", ")}. If the owner did not say which account, ask.`);
|
|
216
225
|
if (!signedIn(profile))
|
|
@@ -233,6 +242,39 @@ export const allProfilesServer = (options) => {
|
|
|
233
242
|
};
|
|
234
243
|
return { build, close: () => children.close() };
|
|
235
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* What a server answers to `tools/list`, asked in this process: the list for a session with no profile, which has no
|
|
247
|
+
* profile's server to ask.
|
|
248
|
+
*/
|
|
249
|
+
export const listedTools = async (server) => {
|
|
250
|
+
const [own, other] = InMemoryTransport.createLinkedPair();
|
|
251
|
+
const answers = new Map();
|
|
252
|
+
other.onmessage = (message) => {
|
|
253
|
+
const { id, result, error } = message;
|
|
254
|
+
if (typeof id === "number")
|
|
255
|
+
answers.get(id)?.(result, error);
|
|
256
|
+
};
|
|
257
|
+
const ask = (id, method, params) => new Promise((resolve, reject) => {
|
|
258
|
+
answers.set(id, (result, error) => error || !result ? reject(new Error(error?.message ?? `${method} had no answer`)) : resolve(result));
|
|
259
|
+
void other.send({ jsonrpc: "2.0", id, method, params });
|
|
260
|
+
});
|
|
261
|
+
await server.connect(own);
|
|
262
|
+
try {
|
|
263
|
+
await ask(1, "initialize", {
|
|
264
|
+
protocolVersion: PROTOCOL,
|
|
265
|
+
capabilities: {},
|
|
266
|
+
clientInfo: { name: PROXY_CLIENT_NAME, version: "1" },
|
|
267
|
+
});
|
|
268
|
+
await other.send({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
269
|
+
const answer = await ask(2, "tools/list", {});
|
|
270
|
+
if (!Array.isArray(answer.tools))
|
|
271
|
+
throw new Error("the catalogue server listed no tools");
|
|
272
|
+
return answer.tools;
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
await server.close();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
236
278
|
/** Over stdin and stdout until the client closes stdin or the process is told to stop; then the children close. */
|
|
237
279
|
export const serveAllProfilesOverStdio = async (options, io = {}) => {
|
|
238
280
|
const { build, close } = allProfilesServer(options);
|
|
@@ -78,4 +78,11 @@ export const WIRECAT_TOOLS = [
|
|
|
78
78
|
package: "@wirecat/notion-cli",
|
|
79
79
|
does: "Notion pages and databases as local text, searchable with your other WireCat data",
|
|
80
80
|
},
|
|
81
|
+
{
|
|
82
|
+
command: "ydisk",
|
|
83
|
+
appName: "yandex-disk-cli",
|
|
84
|
+
envPrefix: "YDISK",
|
|
85
|
+
package: "@wirecat/yandex-disk-cli",
|
|
86
|
+
does: "Yandex Disk folders as local text, searchable with your other WireCat data",
|
|
87
|
+
},
|
|
81
88
|
];
|
|
@@ -6,10 +6,13 @@ import { toIso } from "./values.js";
|
|
|
6
6
|
export const BATCH_CONTEXT = 50;
|
|
7
7
|
/**
|
|
8
8
|
* Phase 4 plan A2: a live message the agent is asked about — no reply the messenger itself records to a
|
|
9
|
-
* message held here
|
|
9
|
+
* message held here that the build links (`inThread` in conversations/link.ts), and no current agent answer.
|
|
10
|
+
* A stale answer makes it need the agent again.
|
|
10
11
|
*/
|
|
11
12
|
const replied = (m) => sql `EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
|
|
12
|
-
AND p.external_id = ${m}.reply_to_external_id AND p.deleted_at IS NULL
|
|
13
|
+
AND p.external_id = ${m}.reply_to_external_id AND p.deleted_at IS NULL
|
|
14
|
+
AND (p.thread_external_id IS ${m}.thread_external_id
|
|
15
|
+
OR (p.external_id = ${m}.thread_external_id AND trim(p.text) <> '')))`;
|
|
13
16
|
const needsAgent = (m) => sql `(
|
|
14
17
|
NOT ${replied(m)}
|
|
15
18
|
AND NOT EXISTS (SELECT 1 FROM message_links l WHERE l.message_id = ${m}.id AND l.source = 'agent'
|
|
@@ -20,5 +20,5 @@ export interface TrackerCommandOptions {
|
|
|
20
20
|
}) => Promise<TrackerRun>;
|
|
21
21
|
now?: () => number;
|
|
22
22
|
}
|
|
23
|
-
/** The tracker's commands: `sync`, `issues list|show|search|
|
|
23
|
+
/** The tracker's commands: `sync`, `issues list|show|search|assign`, and a `list` of each other kind. */
|
|
24
24
|
export declare const addTrackerCommands: (program: Command, options: TrackerCommandOptions) => void;
|
|
@@ -6,6 +6,8 @@ import { environmentOf, inCommandRun, outputFor, runBudgetOf } from "../../cli/c
|
|
|
6
6
|
import { honoursDryRun } from "../../cli/dry-run-guard.js";
|
|
7
7
|
import { FETCH, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "../../cli/effects.js";
|
|
8
8
|
import { itemOf, listOf, renderAnswer } from "../../cli/envelope.js";
|
|
9
|
+
import { listQuery, nativeTermLists, queryTerms, termField, typedQuery, withQuery } from "../../cli/list-query.js";
|
|
10
|
+
import { aheadOf } from "../../domain/moment.js";
|
|
9
11
|
import { STATE_TYPES, TRACKER_KINDS, } from "../../domain/tracker.js";
|
|
10
12
|
import { count, text } from "../../entities/fields.js";
|
|
11
13
|
import { syncTracker } from "../sync.js";
|
|
@@ -17,15 +19,28 @@ const integer = (most) => (value) => {
|
|
|
17
19
|
throw new InvalidArgumentError(`a whole number from 1 to ${most}`);
|
|
18
20
|
return number;
|
|
19
21
|
};
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const ARCHIVED = termField("archived", "enum", "archived:include", {
|
|
23
|
+
values: ["include"],
|
|
24
|
+
relation: "archived ones too; left out, only those not archived",
|
|
25
|
+
});
|
|
26
|
+
const listQueryOf = (kind) => ({
|
|
27
|
+
entity: `tracker_${kind}`,
|
|
28
|
+
backend: "native",
|
|
29
|
+
fields: [ARCHIVED],
|
|
30
|
+
});
|
|
31
|
+
/** What `issues list` narrows by: each by the tracker's id, as `issues show` and the lists name them. */
|
|
32
|
+
const ISSUES_QUERY = {
|
|
33
|
+
entity: "tracker_issue",
|
|
34
|
+
backend: "native",
|
|
35
|
+
fields: [
|
|
36
|
+
termField("team", "kw", "team:team-1", { relation: "the team's id, as teams list shows it" }),
|
|
37
|
+
termField("project", "kw", "project:project-1", { relation: "the project's id, as projects list shows it" }),
|
|
38
|
+
termField("assignee", "kw", "assignee:none", { relation: "the user's id, as users list shows it, or none" }),
|
|
39
|
+
termField("state", "kw", "state:state-1", { relation: "the state's id, as states list shows it" }),
|
|
40
|
+
termField("type", "enum", "type:started", { values: [...STATE_TYPES], relation: "repeat for any of several" }),
|
|
41
|
+
termField("label", "kw", "label:label-1", { relation: "the label's id, as labels list shows it" }),
|
|
42
|
+
ARCHIVED,
|
|
43
|
+
],
|
|
29
44
|
};
|
|
30
45
|
const TIMES = new Set(["createdAt", "updatedAt", "archivedAt", "completedAt", "canceledAt"]);
|
|
31
46
|
const snake = (name) => name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
@@ -167,24 +182,22 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
167
182
|
});
|
|
168
183
|
});
|
|
169
184
|
const issues = annotate(program.command("issues"), { effects: NO_EFFECTS }).description("the tracker's issues as last synced: state, team, project, assignee and labels");
|
|
170
|
-
example(paging(answerEntity(annotate(issues.command("list"), { effects: LOCAL_READ }), "tracker_issue", trackerView)
|
|
171
|
-
|
|
172
|
-
.
|
|
173
|
-
|
|
174
|
-
.
|
|
175
|
-
.
|
|
176
|
-
.
|
|
177
|
-
.option("--label <id>", "only issues with this label")
|
|
178
|
-
.option("--archived", "archived issues too")), "issues list --type started --type unstarted", "issues list --assignee none --json").action(async (opts, command) => {
|
|
185
|
+
example(paging(withQuery(answerEntity(annotate(issues.command("list"), { effects: LOCAL_READ }), "tracker_issue", trackerView), ISSUES_QUERY).description("issues copied from the tracker, newest change first; run sync to bring them up to date")), "issues list type:started", "issues list assignee:none --json").action(async (words, opts, command) => {
|
|
186
|
+
const lists = nativeTermLists(listQuery(typedQuery(words), ISSUES_QUERY, "issues list"), "issues list", ["type"]);
|
|
187
|
+
if ([...lists.values()].flat().some((one) => one.operator !== "term" && one.operator !== "phrase"))
|
|
188
|
+
throw new InvalidArgumentError("issues list takes field:value terms, each one whole value");
|
|
189
|
+
const types = (lists.get("type") ?? []).map((one) => one.value.toLowerCase());
|
|
190
|
+
const terms = new Map([...lists].filter(([field]) => field !== "type").map(([field, [one]]) => [field, one?.value]));
|
|
191
|
+
const assignee = terms.get("assignee")?.toLowerCase() === "none" ? "none" : terms.get("assignee");
|
|
179
192
|
await within(command, true, async (run) => {
|
|
180
193
|
const filter = {
|
|
181
|
-
...(
|
|
182
|
-
...(
|
|
183
|
-
...(
|
|
184
|
-
...(
|
|
185
|
-
...(
|
|
186
|
-
...(
|
|
187
|
-
...(
|
|
194
|
+
...(terms.has("team") ? { parent: terms.get("team") } : {}),
|
|
195
|
+
...(terms.has("project") ? { project: terms.get("project") } : {}),
|
|
196
|
+
...(assignee !== undefined ? { assignee: assignee === "none" ? null : assignee } : {}),
|
|
197
|
+
...(terms.has("state") ? { state: terms.get("state") } : {}),
|
|
198
|
+
...(types.length ? { stateTypes: types } : {}),
|
|
199
|
+
...(terms.has("label") ? { label: terms.get("label") } : {}),
|
|
200
|
+
...(terms.has("archived") ? { archived: true } : {}),
|
|
188
201
|
limit: opts.limit,
|
|
189
202
|
offset: (opts.page - 1) * opts.limit,
|
|
190
203
|
};
|
|
@@ -194,6 +207,7 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
194
207
|
limit: opts.limit,
|
|
195
208
|
page: opts.page,
|
|
196
209
|
has_more: found.hasMore,
|
|
210
|
+
...(words.length ? { args: { query: words } } : {}),
|
|
197
211
|
});
|
|
198
212
|
});
|
|
199
213
|
});
|
|
@@ -212,8 +226,7 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
212
226
|
});
|
|
213
227
|
example(paging(answerEntity(annotate(issues.command("search"), { effects: LOCAL_READ }), "tracker_hit", trackerView)
|
|
214
228
|
.description("find issues, projects and comments in the copy by their words")
|
|
215
|
-
.argument("<words...>", "every word must match; prefixes of three letters or more match too")
|
|
216
|
-
.option("--any", "any word may match")), 'issues search "invoice currency"').action(async (words, opts, command) => {
|
|
229
|
+
.argument("<words...>", "every word must match; prefixes of three letters or more match too")), 'issues search "invoice currency"').action(async (words, opts, command) => {
|
|
217
230
|
await within(command, true, async (run) => {
|
|
218
231
|
const found = await run.store.tracker.find({
|
|
219
232
|
words,
|
|
@@ -221,7 +234,6 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
221
234
|
kinds: ["issue", "project", "comment"],
|
|
222
235
|
limit: opts.limit,
|
|
223
236
|
offset: (opts.page - 1) * opts.limit,
|
|
224
|
-
...(opts.any ? { anyWord: true } : {}),
|
|
225
237
|
});
|
|
226
238
|
return listOf("issues search", {
|
|
227
239
|
items: found.items.map((hit) => viewOf(hit.item, { excerpt: hit.excerpt })),
|
|
@@ -232,15 +244,15 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
232
244
|
});
|
|
233
245
|
});
|
|
234
246
|
});
|
|
235
|
-
example(answerEntity(annotate(issues.command("
|
|
247
|
+
example(answerEntity(annotate(issues.command("assign"), { effects: LOCAL_WRITE }), "tracker_issue_task", trackerTask)
|
|
236
248
|
.description("make an issue the owner's task: the task points at the issue and copies none of its text; the same issue " +
|
|
237
249
|
"again answers its existing task")
|
|
238
250
|
.argument("<issue>", "the issue's key (ENG-12) or id")
|
|
239
|
-
.option("--due <
|
|
251
|
+
.option("--due <time>", "when it is due: an ISO 8601 time, a day, today, or 3d from now", (typed) => new Date(aheadOf(typed, "--due", Date.now(), { end: true }))), "issues assign ENG-12 --due 2026-12-01").action(async (reference, opts, command) => {
|
|
240
252
|
await within(command, false, async (run) => {
|
|
241
253
|
const { task, created } = await trackerIssueTask(run.store, run.account, reference, {
|
|
242
254
|
now: now(),
|
|
243
|
-
...(opts.due ? { dueAt:
|
|
255
|
+
...(opts.due ? { dueAt: opts.due } : {}),
|
|
244
256
|
});
|
|
245
257
|
return itemOf({ task_id: task.id, ...(task.key ? { key: task.key } : {}), issue: task.source, created });
|
|
246
258
|
});
|
|
@@ -253,14 +265,14 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
253
265
|
["label", "labels", "the tracker's labels"],
|
|
254
266
|
]) {
|
|
255
267
|
const group = annotate(program.command(plural), { effects: NO_EFFECTS }).description(what);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
const query = listQueryOf(kind);
|
|
269
|
+
example(paging(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), `tracker_${kind}`, trackerView), query).description(`${plural} copied from the tracker, newest change first`)), `${plural} list`, `${plural} list archived:include`).action(async (words, opts, command) => {
|
|
270
|
+
const terms = queryTerms(words, query, `${plural} list`);
|
|
259
271
|
await within(command, true, async (run) => {
|
|
260
272
|
const found = await run.store.tracker.list(run.account, kind, {
|
|
261
273
|
limit: opts.limit,
|
|
262
274
|
offset: (opts.page - 1) * opts.limit,
|
|
263
|
-
...(
|
|
275
|
+
...(terms.has("archived") ? { archived: true } : {}),
|
|
264
276
|
});
|
|
265
277
|
const people = kind === "user"
|
|
266
278
|
? new Map((await run.store.tracker.people(run.account, found.items.map((one) => one.record.externalId))).map((one) => [one.user, one.person]))
|
|
@@ -270,10 +282,11 @@ const addTrackerCommandsDefinition = (program, options) => {
|
|
|
270
282
|
limit: opts.limit,
|
|
271
283
|
page: opts.page,
|
|
272
284
|
has_more: found.hasMore,
|
|
285
|
+
...(words.length ? { args: { query: words } } : {}),
|
|
273
286
|
});
|
|
274
287
|
});
|
|
275
288
|
});
|
|
276
289
|
}
|
|
277
290
|
};
|
|
278
|
-
/** The tracker's commands: `sync`, `issues list|show|search|
|
|
291
|
+
/** The tracker's commands: `sync`, `issues list|show|search|assign`, and a `list` of each other kind. */
|
|
279
292
|
export const addTrackerCommands = honoursDryRun(sharedCommand(addTrackerCommandsDefinition));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.699.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",
|
|
@@ -313,7 +313,7 @@
|
|
|
313
313
|
"@types/pngjs": "6.0.5",
|
|
314
314
|
"@types/ssh2": "1.15.5",
|
|
315
315
|
"@vitest/coverage-v8": "^5.0.5",
|
|
316
|
-
"@wirecat/cli-base": "0.
|
|
316
|
+
"@wirecat/cli-base": "0.117.0",
|
|
317
317
|
"@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
|
|
318
318
|
"ajv": "8.17.1",
|
|
319
319
|
"commander": "15.0.0",
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
},
|
|
338
338
|
"peerDependencies": {
|
|
339
339
|
"@napi-rs/canvas": ">=0.1.69 <2",
|
|
340
|
-
"@wirecat/cli-base": ">=0.
|
|
340
|
+
"@wirecat/cli-base": ">=0.117.0 <1.0.0",
|
|
341
341
|
"commander": ">=15",
|
|
342
342
|
"mysql2": "^3.24.6",
|
|
343
343
|
"pg": "^8.23.1",
|