@wirecat/cli-core 0.698.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 +11 -0
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +2 -2
- package/dist/cli/profile-token.d.ts +1 -1
- package/dist/cli/service-api-call.d.ts +6 -1
- package/dist/cli/service-api-call.js +6 -0
- package/dist/cli/token-session.d.ts +17 -0
- package/dist/cli/token-session.js +20 -0
- package/dist/errors/reasons.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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
|
+
|
|
8
19
|
## 0.698.0 — 18.11.2026
|
|
9
20
|
|
|
10
21
|
### Added
|
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";
|
|
@@ -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
|
}
|
|
@@ -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
|
/**
|
|
@@ -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;
|
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/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",
|