@wirecat/cli-core 0.692.0 → 0.694.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 +85 -0
- package/README.md +1 -1
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/calendar/prepare.d.ts +11 -0
- package/dist/cli/bot/api-http.d.ts +4 -1
- package/dist/cli/bot/api-http.js +17 -4
- package/dist/cli/bot/api-input.d.ts +4 -0
- package/dist/cli/bot/api-input.js +9 -0
- package/dist/cli/bot/api.d.ts +4 -0
- package/dist/cli/bot/api.js +16 -2
- package/dist/cli/documents/words.d.ts +1 -1
- package/dist/cli/envelope.d.ts +22 -0
- package/dist/cli/index.d.ts +6 -4
- package/dist/cli/index.js +6 -4
- package/dist/cli/oauth-session.d.ts +60 -0
- package/dist/cli/oauth-session.js +224 -0
- package/dist/cli/service-api-call.d.ts +2 -1
- package/dist/cli/service-api-call.js +4 -6
- package/dist/cli/service-api-manifest.d.ts +10 -10
- package/dist/cli/service-api-manifest.js +37 -33
- package/dist/cli/service-api.d.ts +17 -2
- package/dist/cli/service-api.js +42 -24
- package/dist/cli/token-session.d.ts +33 -0
- package/dist/cli/token-session.js +121 -0
- package/dist/crm/index.d.ts +2 -1
- package/dist/crm/index.js +1 -0
- package/dist/crm/manifest/manifest.d.ts +19 -0
- package/dist/crm/manifest/manifest.js +6 -1
- package/dist/crm/manifest/map.d.ts +5 -0
- package/dist/crm/manifest/map.js +21 -15
- package/dist/crm/manifest/paths.d.ts +11 -0
- package/dist/crm/manifest/paths.js +161 -0
- package/dist/crm/manifest/source.js +105 -34
- package/dist/manifest/index.d.ts +53 -0
- package/dist/manifest/index.js +61 -0
- package/dist/search/lucene/plain.js +2 -1
- package/dist/services/metadata.d.ts +1 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,91 @@ 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.694.0 — 17.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A generated `api` command uploads a file's bytes.** For an operation whose body is an upload, as Petstore 3's
|
|
13
|
+
`application/octet-stream` image, `--body-file <path>` (or `-` for stdin) sends the file as it is, with the
|
|
14
|
+
operation's content type; such a command has no `--body`. A file in the CLI's own folders is refused, as for a JSON
|
|
15
|
+
body. Needs cli-base 0.112.0, whose generator reads such a body.
|
|
16
|
+
- **`serviceApiOperations(manifest)`** lists the operations the `api` group offers and why it leaves out the rest, so
|
|
17
|
+
a CLI's test runs exactly the commands that exist. `sendsBytes(operation)`, `readApiBytes(path)` and
|
|
18
|
+
`unsendableBody(operation)` are exported beside it.
|
|
19
|
+
- **`serviceApiCommand` and `serviceApiCall` take no `token` for a CLI without sign-in.** Left out, no call carries a
|
|
20
|
+
token, whatever the spec says; a CLI made with cli-template's `--sign-in none` passes none.
|
|
21
|
+
|
|
22
|
+
### Changed — may break callers
|
|
23
|
+
|
|
24
|
+
- **A call sends no token where the spec names no sign-in.** The `api` group and `serviceApiCall` now follow cli-base's
|
|
25
|
+
`signInRequirements`: the operation's own `security`, else the document's, and nothing when neither says anything.
|
|
26
|
+
Before, a manifest without `securitySchemes`, or an operation without requirements, got `Authorization: Bearer
|
|
27
|
+
<token>`. A CLI whose spec omits its sign-in now gets the service's refusal (401): generate with `auth`
|
|
28
|
+
(`{ securitySchemes, security, reason }`) to name it. A Discovery manifest gets its OAuth from cli-base 0.112.0's
|
|
29
|
+
generator; regenerate before taking this version.
|
|
30
|
+
- **An operation whose body is neither JSON nor an upload's bytes, such as a multipart form, is no longer offered.**
|
|
31
|
+
It always failed when run; now `api list` leaves it out and `api show <operation>` says why.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- **A search field whose value starts with a minus reads as that value**: `chat:-1001234567890 budget` searches the
|
|
36
|
+
group with that id, as `chat:"-1001234567890"` did. It was refused as `query.invalid-syntax`, though the CLIs print
|
|
37
|
+
a group's id with its minus. A minus before a bare word still means NOT.
|
|
38
|
+
|
|
39
|
+
## 0.693.0 — 17.11.2026
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- **`@wirecat/cli-core/manifest`: `defineCli` and `parseCliConfig`, the shape of `wirecat.config.ts`.** One file names
|
|
44
|
+
the CLI (command, package, environment prefix, service, owner), its API description (an https URL), its sign-in
|
|
45
|
+
(`none`, `token`, or `oauth2-pkce` with the options `oauthPreset` takes), its category (cli-template's, or `other`)
|
|
46
|
+
and, for a CRM, its source. cli-template's `new --from-config` builds a CLI from it. Each error names the field; the
|
|
47
|
+
source is checked against the generated API by `parseCrmManifest`.
|
|
48
|
+
- **`crmManifestProblems(manifest, api, definitions)` checks every path a CRM manifest reads against what each
|
|
49
|
+
operation answers**, from the generated `definitions`: a misspelt or moved field is named with its operation and the
|
|
50
|
+
field it likely meant, before a sync runs. A part of a schema that says nothing passes.
|
|
51
|
+
- **A CRM manifest's `hooks.enrich`** reads more for a whole page before the map, in one batch request (HubSpot's
|
|
52
|
+
associations, which its search does not answer).
|
|
53
|
+
- **`optional` on a manifest kind:** the service refusing it (a plan or scope without it) is a gap with the manifest's
|
|
54
|
+
text and scope, and the other kinds still sync. A refusal part way through the id pass still fails it, so no unread row
|
|
55
|
+
is taken as deleted. Each gap is said once per call.
|
|
56
|
+
- **`select.max`:** `{select}` always asks for every mapped field, then the account's own while they fit; the count left
|
|
57
|
+
out is a gap, so an account with hundreds of custom fields still syncs.
|
|
58
|
+
- **A CRM source from a manifest: `crmSourceFromManifest(manifest, { api, call, hooks })` in `@wirecat/cli-core/crm`.**
|
|
59
|
+
A CLI with an OpenAPI spec describes its CRM as data: per kind, the operations (by their generated id) that list
|
|
60
|
+
every row, read changes after `{since}` (in the query or the body), list every id and read one record, and where each
|
|
61
|
+
shared field sits in the answer (a path, `first`, `join`, `all`, `each`, `map`, a constant or a function). The engine
|
|
62
|
+
pages by each operation's own `pagination` (or, for a change read sorted by modified time, by `keyset`: from the
|
|
63
|
+
last row's time, `reset` past the service's cap), keeps `<page>@<round start>` page tokens, re-reads a 10-minute overlap,
|
|
64
|
+
spends the run's budget after the first request, answers a 403 or 404 on `get` with null, asks a service that names
|
|
65
|
+
its returned fields (`"{select}"`) for only the mapped ones and the account's own, and leaves out a field the answer
|
|
66
|
+
did not carry, so the stored copy keeps it. Pipelines, custom field definitions and users are described the same
|
|
67
|
+
way; `hooks.after` corrects one record (async, with the metered call) and `hooks.extend` adds or replaces any `CrmSource` method.
|
|
68
|
+
`parseCrmManifest` checks the shape, every operation id (a read only) and every mapped field, and names the field at fault and the operation a typo
|
|
69
|
+
meant. See [docs/dev/CRM.md](docs/dev/CRM.md#a-source-from-a-manifest).
|
|
70
|
+
- `serviceApiCall({ manifest, service, fetch, token })` in `@wirecat/cli-core/cli`: one read operation of a generated
|
|
71
|
+
manifest sent as the `api` group sends it (request, sign-in header, redirect rule, run record, refusals), for code
|
|
72
|
+
that is not a command.
|
|
73
|
+
- **`oauthPreset(flow, options)`: an installed app's browser sign-in from the flow a spec declares.**
|
|
74
|
+
`oauthFlowOf(manifest)` reads the OpenAPI authorization code flow; a GraphQL service writes the same object by hand.
|
|
75
|
+
Each scope the CLI asks for must be one the flow lists, with a "did you mean" for a typo. The redirect stays the
|
|
76
|
+
CLI's choice: the spec cannot say which one the app registered. A sign-in URL that is not https is refused, and
|
|
77
|
+
`rotating` marks a provider that sends a new refresh token on each refresh, so a run with moved folders never
|
|
78
|
+
refreshes it.
|
|
79
|
+
- **`oauthSessionCommand(options)`: the shared `session start | status | end | list` for a browser sign-in.** PKCE on
|
|
80
|
+
the loopback, the CLI's `verify` and `claim` before anything is kept, refreshes under one lock, `--no-browser` and
|
|
81
|
+
`--credential-storage file`, which also forgets an older keyring copy. In a run with moved folders, `session end`
|
|
82
|
+
says the owner's sign-in stays.
|
|
83
|
+
- **A generated `api` group signs in with an API key in the query** (`apiKey` with `in: query`), as it already did
|
|
84
|
+
with one in a header. The key goes on every page of `--all`, a next link included, and never follows a redirect.
|
|
85
|
+
The run record keeps only the path template, so the key never lands in a file. Where an operation also takes a
|
|
86
|
+
header or a bearer token, that one is sent: a URL can be kept by a proxy or a server log.
|
|
87
|
+
- **`signRequest(manifest, operation, request, token)`** signs one request the way the `api` group and
|
|
88
|
+
`serviceApiCall` do.
|
|
89
|
+
- **`tokenSessionCommand(options)`: the shared `session start | status | end | list`** for a service signed in with one
|
|
90
|
+
token. The CLI gives its `verify` (ask the service whose the token is); the token is read hidden or from stdin,
|
|
91
|
+
checked, and only then kept in the keyring or a private file. It replaces each token CLI's own `session.ts`.
|
|
92
|
+
|
|
8
93
|
## 0.692.0 — 17.11.2026
|
|
9
94
|
|
|
10
95
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/WireCatLabs/cli-core/main/docs/images/cli-core-banner.png" alt="cli-core:
|
|
2
|
+
<img src="https://raw.githubusercontent.com/WireCatLabs/cli-core/main/docs/images/cli-core-banner.png" alt="cli-core: the foundation for agent-ready CLIs" width="100%">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
# @wirecat/cli-core
|
|
@@ -24,12 +24,12 @@ export interface DailyArchiveTimerInput {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const dailyArchiveTimer: (input: DailyArchiveTimerInput) => DailyArchiveTimer;
|
|
26
26
|
export declare const manageDailyArchiveTimer: (plan: DailyArchiveTimer, action: "install" | "start" | "stop" | "status" | "uninstall", system: Pick<ServerSystem, "platform" | "run">, env: NodeJS.ProcessEnv, signal?: AbortSignal) => Promise<{
|
|
27
|
+
action?: undefined;
|
|
27
28
|
name: string;
|
|
28
29
|
installed: boolean;
|
|
29
30
|
active: boolean;
|
|
30
31
|
servicePath: string;
|
|
31
32
|
timerPath: string;
|
|
32
|
-
action?: undefined;
|
|
33
33
|
} | {
|
|
34
34
|
active?: undefined;
|
|
35
35
|
name: string;
|
|
@@ -153,5 +153,16 @@ export declare const eventPreparation: (details: EventDetails, options: Preparat
|
|
|
153
153
|
} | undefined;
|
|
154
154
|
ms: number;
|
|
155
155
|
} | undefined;
|
|
156
|
+
query?: {
|
|
157
|
+
chat?: {
|
|
158
|
+
word: string;
|
|
159
|
+
chat_id: string;
|
|
160
|
+
title: string | null;
|
|
161
|
+
} | undefined;
|
|
162
|
+
respelled?: {
|
|
163
|
+
word: string;
|
|
164
|
+
tried: string[];
|
|
165
|
+
}[] | undefined;
|
|
166
|
+
} | undefined;
|
|
156
167
|
}, "accounts" | "complete" | "issues" | "truncated">;
|
|
157
168
|
}>;
|
|
@@ -7,7 +7,8 @@ export interface HttpApiRequest {
|
|
|
7
7
|
method: string;
|
|
8
8
|
url: URL;
|
|
9
9
|
headers: Headers;
|
|
10
|
-
|
|
10
|
+
/** JSON text, or an upload's bytes. */
|
|
11
|
+
body?: string | Uint8Array<ArrayBuffer>;
|
|
11
12
|
/** `manual` for a request whose sign-in header a redirect to another host would carry along. */
|
|
12
13
|
redirect?: "follow" | "manual" | "error";
|
|
13
14
|
}
|
|
@@ -34,6 +35,8 @@ export interface HttpApiExecutorOptions {
|
|
|
34
35
|
failure?: (status: number, answer: unknown, operation: ManifestOperation) => CliError | undefined;
|
|
35
36
|
maxBytes?: number;
|
|
36
37
|
}
|
|
38
|
+
/** Why the generated command cannot send the operation's body, or `undefined` when it can: JSON, or an upload's bytes. */
|
|
39
|
+
export declare const unsendableBody: (operation: ManifestOperation) => string | undefined;
|
|
37
40
|
/** One generated HTTP operation and its flags as the request they stand for; nothing is sent. */
|
|
38
41
|
export declare const httpApiRequest: (operation: ManifestOperation, input: ApiCommandInput, baseUrl: string) => HttpApiRequest;
|
|
39
42
|
/** What one exchange needs: the service's name, the fetch, its own refusals and the answer's size limit. */
|
package/dist/cli/bot/api-http.js
CHANGED
|
@@ -3,7 +3,7 @@ import { providerWaitMs, readJsonResponse, statusToCode } from "@wirecat/cli-bas
|
|
|
3
3
|
import { providerRequest } from "../command-runs.js";
|
|
4
4
|
import { outputFor } from "../context.js";
|
|
5
5
|
import { itemOf, renderAnswer } from "../envelope.js";
|
|
6
|
-
import { parseApiJson } from "./api-input.js";
|
|
6
|
+
import { parseApiJson, sendsBytes } from "./api-input.js";
|
|
7
7
|
const LARGEST_ANSWER = 16 * 1024 * 1024;
|
|
8
8
|
/** `new URL` folds a `.` or `..` segment into its parent, so such an id would reach another endpoint. */
|
|
9
9
|
const segment = (name, value) => {
|
|
@@ -11,13 +11,20 @@ const segment = (name, value) => {
|
|
|
11
11
|
throw new CliError("validation_error", `${name} must name one item; an empty, "." or ".." id is refused`);
|
|
12
12
|
return encodeURIComponent(value);
|
|
13
13
|
};
|
|
14
|
+
/** Why the generated command cannot send the operation's body, or `undefined` when it can: JSON, or an upload's bytes. */
|
|
15
|
+
export const unsendableBody = (operation) => {
|
|
16
|
+
const type = operation.request?.contentType;
|
|
17
|
+
return type === undefined || sendsBytes(operation)
|
|
18
|
+
? undefined
|
|
19
|
+
: `it sends ${type}, which the generated command cannot send`;
|
|
20
|
+
};
|
|
14
21
|
/** One generated HTTP operation and its flags as the request they stand for; nothing is sent. */
|
|
15
22
|
export const httpApiRequest = (operation, input, baseUrl) => {
|
|
16
23
|
const { binding } = operation;
|
|
17
24
|
if (binding.kind !== "http")
|
|
18
25
|
throw new CliError("configuration_error", `${operation.command} is not an HTTP operation`);
|
|
19
|
-
if (operation
|
|
20
|
-
throw new CliError("validation_error", `${operation.command} sends ${operation.request
|
|
26
|
+
if (unsendableBody(operation))
|
|
27
|
+
throw new CliError("validation_error", `${operation.command} sends ${operation.request?.contentType}, which the generated command cannot send; nothing was sent`, { sent: false });
|
|
21
28
|
if (operation.response?.sensitive)
|
|
22
29
|
throw new CliError("validation_error", `${operation.command} answers with a credential, which the generated command never prints; nothing was sent`, { sent: false });
|
|
23
30
|
if (Object.keys(input.fields).length > 0)
|
|
@@ -36,13 +43,19 @@ export const httpApiRequest = (operation, input, baseUrl) => {
|
|
|
36
43
|
url.searchParams.set(name, raw);
|
|
37
44
|
}
|
|
38
45
|
const headers = new Headers(input.headers);
|
|
46
|
+
headers.set("accept", "application/json");
|
|
47
|
+
if (sendsBytes(operation)) {
|
|
48
|
+
if (input.bytes === undefined)
|
|
49
|
+
return { method: binding.method, url, headers };
|
|
50
|
+
headers.set("content-type", operation.request?.contentType);
|
|
51
|
+
return { method: binding.method, url, headers, body: input.bytes };
|
|
52
|
+
}
|
|
39
53
|
const body = input.body?.trim() ? input.body : undefined;
|
|
40
54
|
// The command's checkBody may not parse the body; text that is not JSON never reaches the service.
|
|
41
55
|
if (body !== undefined)
|
|
42
56
|
parseApiJson(body);
|
|
43
57
|
if (body !== undefined)
|
|
44
58
|
headers.set("content-type", "application/json");
|
|
45
|
-
headers.set("accept", "application/json");
|
|
46
59
|
return { method: binding.method, url, headers, ...(body === undefined ? {} : { body }) };
|
|
47
60
|
};
|
|
48
61
|
/** `/v1/pages/{page_id}` → `/v1/pages/:page_id`: the run record keeps the template, never an id. */
|
|
@@ -3,6 +3,10 @@ import * as v from "valibot";
|
|
|
3
3
|
export declare const apiFlagOf: (name: string) => string;
|
|
4
4
|
export declare const apiOptionKey: (name: string) => string;
|
|
5
5
|
export declare const checkApiParameter: (name: string, node: SchemaNode, raw: string, schemas: Readonly<Record<string, v.GenericSchema>>) => string | undefined;
|
|
6
|
+
/** An upload sent as the bytes themselves, as the spec types a binary body: `application/octet-stream`, `image/png`. */
|
|
7
|
+
export declare const sendsBytes: (operation: ManifestOperation) => boolean;
|
|
8
|
+
/** The file `--body-file` names, `-` for stdin, as the bytes an upload sends. */
|
|
9
|
+
export declare const readApiBytes: (path: string, read?: (path: string | number) => Uint8Array<ArrayBuffer>) => Uint8Array<ArrayBuffer>;
|
|
6
10
|
export declare const readApiBody: (options: {
|
|
7
11
|
body?: string;
|
|
8
12
|
bodyFile?: string;
|
|
@@ -55,6 +55,15 @@ export const checkApiParameter = (name, node, raw, schemas) => {
|
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
const JSON_BODY = /[/+]json\s*(;|$)/i;
|
|
59
|
+
const FORM_BODY = /^(multipart\/form-data|application\/x-www-form-urlencoded)\s*(;|$)/i;
|
|
60
|
+
/** An upload sent as the bytes themselves, as the spec types a binary body: `application/octet-stream`, `image/png`. */
|
|
61
|
+
export const sendsBytes = (operation) => {
|
|
62
|
+
const type = operation.request?.contentType;
|
|
63
|
+
return type !== undefined && !JSON_BODY.test(type) && !FORM_BODY.test(type);
|
|
64
|
+
};
|
|
65
|
+
/** The file `--body-file` names, `-` for stdin, as the bytes an upload sends. */
|
|
66
|
+
export const readApiBytes = (path, read = (from) => new Uint8Array(readFileSync(from))) => read(path === "-" ? 0 : path);
|
|
58
67
|
export const readApiBody = (options, read = (path) => readFileSync(path, "utf8")) => {
|
|
59
68
|
if (options.body !== undefined && options.bodyFile !== undefined) {
|
|
60
69
|
throw new CliError("validation_error", "--body and --body-file both given; pick one");
|
package/dist/cli/bot/api.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface ApiCommandInput {
|
|
|
6
6
|
headers: Record<string, string>;
|
|
7
7
|
fields: Record<string, string>;
|
|
8
8
|
body?: string;
|
|
9
|
+
/** An upload's bytes, from `--body-file`. */
|
|
10
|
+
bytes?: Uint8Array<ArrayBuffer>;
|
|
9
11
|
bodySource?: "argument" | "stdin" | "file";
|
|
10
12
|
tokenProfile?: string;
|
|
11
13
|
}
|
|
@@ -19,6 +21,8 @@ export interface ApiCommands {
|
|
|
19
21
|
body?: string;
|
|
20
22
|
bodyFile?: string;
|
|
21
23
|
}) => string | undefined;
|
|
24
|
+
/** An upload's file, `-` for stdin. */
|
|
25
|
+
readBytes?: (command: Command, path: string) => Uint8Array<ArrayBuffer>;
|
|
22
26
|
execute: (command: Command, operation: ManifestOperation, input: ApiCommandInput) => Promise<void>;
|
|
23
27
|
}
|
|
24
28
|
export declare const generatedApiCommand: (api: ApiCommands) => Command;
|
package/dist/cli/bot/api.js
CHANGED
|
@@ -3,7 +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 { REMOTE_READ, REMOTE_WRITE } from "../effects.js";
|
|
6
|
-
import { apiFlagOf, apiOptionKey, readApiBody } from "./api-input.js";
|
|
6
|
+
import { apiFlagOf, apiOptionKey, readApiBody, readApiBytes, sendsBytes } from "./api-input.js";
|
|
7
7
|
export const generatedApiCommand = (api) => {
|
|
8
8
|
const group = new Command("api").description(api.description ?? "every operation of the official Bot API, generated from its schema");
|
|
9
9
|
group.option("--store-token <profile>", "keep a returned authentication token only in this bot profile's OS keyring; never print it");
|
|
@@ -20,7 +20,10 @@ export const generatedApiCommand = (api) => {
|
|
|
20
20
|
const option = new Option(`--${apiFlagOf(parameter.name)} <value>`, parameter.description?.split("\n")[0] ?? parameter.name);
|
|
21
21
|
command.addOption(parameter.required && parameter.in !== "body" ? option.makeOptionMandatory() : option);
|
|
22
22
|
}
|
|
23
|
-
if (operation.request) {
|
|
23
|
+
if (operation.request && sendsBytes(operation)) {
|
|
24
|
+
command.option("--body-file <path>", `the file to upload, sent as ${operation.request.contentType}; - is stdin`);
|
|
25
|
+
}
|
|
26
|
+
else if (operation.request) {
|
|
24
27
|
// A field the schema marks secret may ride in an inline body, and the flags never see it.
|
|
25
28
|
command.addOption(secretInput(new Option("--body <json>", "the request body as JSON; - reads it from stdin")));
|
|
26
29
|
command.option("--body-file <path>", "the request body from a JSON file; - is stdin");
|
|
@@ -57,6 +60,17 @@ export const generatedApiCommand = (api) => {
|
|
|
57
60
|
target[parameter.name] = raw;
|
|
58
61
|
}
|
|
59
62
|
await api.before?.(this, operation);
|
|
63
|
+
if (sendsBytes(operation)) {
|
|
64
|
+
const path = options.bodyFile;
|
|
65
|
+
if (path === undefined && operation.request?.required)
|
|
66
|
+
throw new CliError("validation_error", `${operation.command} uploads a file: give --body-file <path>, or - for stdin`);
|
|
67
|
+
if (path !== undefined) {
|
|
68
|
+
input.bytes = (api.readBytes ?? ((_command, from) => readApiBytes(from)))(this, path);
|
|
69
|
+
input.bodySource = path === "-" ? "stdin" : "file";
|
|
70
|
+
}
|
|
71
|
+
await api.execute(this, operation, input);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
60
74
|
const text = (api.readBody ?? ((_command, body) => readApiBody(body)))(this, options);
|
|
61
75
|
if (options.body !== undefined)
|
|
62
76
|
input.bodySource = options.body === "-" ? "stdin" : "argument";
|
|
@@ -58,8 +58,8 @@ 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
|
-
next?: undefined;
|
|
62
61
|
missing?: undefined;
|
|
62
|
+
next?: undefined;
|
|
63
63
|
meta?: undefined;
|
|
64
64
|
} | {
|
|
65
65
|
missing: {
|
package/dist/cli/envelope.d.ts
CHANGED
|
@@ -115,6 +115,17 @@ export declare const answerSchema: (item?: v.GenericSchema) => v.UnionSchema<[v.
|
|
|
115
115
|
}, undefined>, undefined>;
|
|
116
116
|
readonly ms: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
117
117
|
}, undefined>, undefined>;
|
|
118
|
+
readonly query: v.OptionalSchema<v.StrictObjectSchema<{
|
|
119
|
+
readonly chat: v.OptionalSchema<v.StrictObjectSchema<{
|
|
120
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
121
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
122
|
+
readonly title: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
123
|
+
}, undefined>, undefined>;
|
|
124
|
+
readonly respelled: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
125
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
126
|
+
readonly tried: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
127
|
+
}, undefined>, undefined>, undefined>;
|
|
128
|
+
}, undefined>, undefined>;
|
|
118
129
|
}, undefined>;
|
|
119
130
|
}, undefined>, v.StrictObjectSchema<{
|
|
120
131
|
readonly item: v.GenericSchema;
|
|
@@ -184,6 +195,17 @@ export declare const answerSchema: (item?: v.GenericSchema) => v.UnionSchema<[v.
|
|
|
184
195
|
}, undefined>, undefined>;
|
|
185
196
|
readonly ms: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
186
197
|
}, undefined>, undefined>;
|
|
198
|
+
readonly query: v.OptionalSchema<v.StrictObjectSchema<{
|
|
199
|
+
readonly chat: v.OptionalSchema<v.StrictObjectSchema<{
|
|
200
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
201
|
+
readonly chat_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
202
|
+
readonly title: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
203
|
+
}, undefined>, undefined>;
|
|
204
|
+
readonly respelled: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
205
|
+
readonly word: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
206
|
+
readonly tried: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
207
|
+
}, undefined>, undefined>, undefined>;
|
|
208
|
+
}, undefined>, undefined>;
|
|
187
209
|
}, undefined>;
|
|
188
210
|
}, undefined>], undefined>;
|
|
189
211
|
/**
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -60,8 +60,8 @@ export { askBeforeWrite } from "./ask-before-write.js";
|
|
|
60
60
|
export { actorOf } from "./author.js";
|
|
61
61
|
export { type BaseStagesCommandOptions, baseStagesCommand } from "./base-stages-command.js";
|
|
62
62
|
export type { ApiCommandInput, ApiCommands } from "./bot/api.js";
|
|
63
|
-
export { type HttpApiExecutorOptions, type HttpApiRequest, httpApiExecutor, httpApiRequest } from "./bot/api-http.js";
|
|
64
|
-
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
63
|
+
export { type HttpApiExecutorOptions, type HttpApiRequest, httpApiExecutor, httpApiRequest, unsendableBody, } from "./bot/api-http.js";
|
|
64
|
+
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
65
65
|
export { prepareRpcApiBody, type RpcApiBody } from "./bot/api-rpc.js";
|
|
66
66
|
export { type BotContext, botContext, botWords } from "./bot/context.js";
|
|
67
67
|
export { type BotCopy, botCopy } from "./bot/copy.js";
|
|
@@ -140,6 +140,7 @@ export { type Saving, stored } from "./messenger/stored.js";
|
|
|
140
140
|
export { dateOrNone } from "./messenger/tasks-command.js";
|
|
141
141
|
export { MODEL_CATALOGUE_QUERY, type ModelCatalogueOptions } from "./model-catalogue-command.js";
|
|
142
142
|
export { writeNewFile } from "./new-file.js";
|
|
143
|
+
export { type OAuthEnvironment, type OAuthPreset, type OAuthPresetOptions, type OAuthSessionOptions, oauthFlowOf, oauthPreset, oauthSessionCommand, } from "./oauth-session.js";
|
|
143
144
|
export { pagingOf, positiveCount, window, withPaging } from "./paging.js";
|
|
144
145
|
export { type CommandPermissions, type ConditionalKey, commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, type PermissionKeyOf, type PermissionKeySource, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
|
|
145
146
|
export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
|
|
@@ -152,9 +153,9 @@ export { fieldsOf, projectFields } from "./result-fields.js";
|
|
|
152
153
|
export { HARNESSES, type Harness, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
|
|
153
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";
|
|
154
155
|
export { deniedKinds, deniedKindsOf, type LeftOut, type SearchedKind } from "./search-left-out.js";
|
|
155
|
-
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, serviceApiKeys, serviceApiPermissions, } from "./service-api.js";
|
|
156
|
+
export { type BodyPermission, type ServiceApiOptions, type ServiceApiPermissionsInput, serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
156
157
|
export { type ServiceApiCall, type ServiceApiCallOptions, serviceApiCall } from "./service-api-call.js";
|
|
157
|
-
export { manifestBaseUrl, type ServiceApiManifest } from "./service-api-manifest.js";
|
|
158
|
+
export { manifestBaseUrl, type ServiceApiManifest, signRequest } from "./service-api-manifest.js";
|
|
158
159
|
export { type DeclaredSetting, type SettingRow, settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
159
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";
|
|
160
161
|
export { type PermissionAnswer, readSetupAnswers, type SetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
@@ -166,4 +167,5 @@ export { type StoreInfo, sharedStoreCommand, storeInfo, storeInfoCommand } from
|
|
|
166
167
|
export { type RecoveryCheck, type RecoveryRun, recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
167
168
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
168
169
|
export type { TemplatesOptions } from "./templates-command.js";
|
|
170
|
+
export { type TokenSessionOptions, tokenSessionCommand } from "./token-session.js";
|
|
169
171
|
export { restartServers, type UpgradeContext } from "./upgrade-command.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -53,8 +53,8 @@ export { openAppStore } from "./app-store.js";
|
|
|
53
53
|
export { askBeforeWrite } from "./ask-before-write.js";
|
|
54
54
|
export { actorOf } from "./author.js";
|
|
55
55
|
export { baseStagesCommand } from "./base-stages-command.js";
|
|
56
|
-
export { httpApiExecutor, httpApiRequest } from "./bot/api-http.js";
|
|
57
|
-
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
56
|
+
export { httpApiExecutor, httpApiRequest, unsendableBody, } from "./bot/api-http.js";
|
|
57
|
+
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, readApiBytes, sendsBytes, } from "./bot/api-input.js";
|
|
58
58
|
export { prepareRpcApiBody } from "./bot/api-rpc.js";
|
|
59
59
|
export { botContext, botWords } from "./bot/context.js";
|
|
60
60
|
export { botCopy } from "./bot/copy.js";
|
|
@@ -129,6 +129,7 @@ export { stored } from "./messenger/stored.js";
|
|
|
129
129
|
export { dateOrNone } from "./messenger/tasks-command.js";
|
|
130
130
|
export { MODEL_CATALOGUE_QUERY } from "./model-catalogue-command.js";
|
|
131
131
|
export { writeNewFile } from "./new-file.js";
|
|
132
|
+
export { oauthFlowOf, oauthPreset, oauthSessionCommand, } from "./oauth-session.js";
|
|
132
133
|
export { pagingOf, positiveCount, window, withPaging } from "./paging.js";
|
|
133
134
|
export { commandPathKey, commandPermissions, knownBeside, knownPermissionKeys, refuseUnknownPermissionKeys, unknownPermissionIssues, unknownPermissionKeys, } from "./permission-keys.js";
|
|
134
135
|
export { asFirstWord, commandWords, liftProfile, profileFree, refuseCommandName, rootOf, runGroup, takesProfile, usableProfileName, } from "./profile.js";
|
|
@@ -141,9 +142,9 @@ export { fieldsOf, projectFields } from "./result-fields.js";
|
|
|
141
142
|
export { HARNESSES, harnessesOn, harnessInfo, harnessOfArgv, isHarness, reportsCost, } from "./schedule/harnesses.js";
|
|
142
143
|
export { agentSchedule, backfillScheduleRun, pauseSchedule, removeSchedule, runScheduleNow, SCHEDULE_SETTINGS, scheduleLimitsOf, scheduleState, slotsOfAt, writeSchedule, } from "./schedule/schedule-command.js";
|
|
143
144
|
export { deniedKinds, deniedKindsOf } from "./search-left-out.js";
|
|
144
|
-
export { serviceApiKeys, serviceApiPermissions, } from "./service-api.js";
|
|
145
|
+
export { serviceApiKeys, serviceApiOperations, serviceApiPermissions, } from "./service-api.js";
|
|
145
146
|
export { serviceApiCall } from "./service-api-call.js";
|
|
146
|
-
export { manifestBaseUrl } from "./service-api-manifest.js";
|
|
147
|
+
export { manifestBaseUrl, signRequest } from "./service-api-manifest.js";
|
|
147
148
|
export { settingRows, withSettingDefaults } from "./setting-defaults.js";
|
|
148
149
|
export { count, first, flag, fromFile, NONE_NAMED, namedProfile, plain, settingsFor, } from "./settings.js";
|
|
149
150
|
export { readSetupAnswers, setupPermissionCeiling } from "./setup-answers.js";
|
|
@@ -154,4 +155,5 @@ export { runnable, withSafety } from "./steps.js";
|
|
|
154
155
|
export { sharedStoreCommand, storeInfo, storeInfoCommand } from "./store-info.js";
|
|
155
156
|
export { recoveryNotes, storeRecoverCommand, storeRecoveryCheck, storeRecoveryRun, } from "./store-recover.js";
|
|
156
157
|
export { changeStoreSetting, isStoreSetting, STORE_SETTINGS, storeSettings } from "./store-settings.js";
|
|
158
|
+
export { tokenSessionCommand } from "./token-session.js";
|
|
157
159
|
export { restartServers } from "./upgrade-command.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { OAuthFlow } from "@wirecat/cli-base/codegen";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import type { OAuthClient, OAuthProvider } from "../oauth/provider.js";
|
|
4
|
+
import type { AppIdentity } from "../ports/app.js";
|
|
5
|
+
import type { EventSink } from "../runs/events.js";
|
|
6
|
+
import { type BaseEnvironment } from "./context.js";
|
|
7
|
+
import type { ServiceApiManifest } from "./service-api-manifest.js";
|
|
8
|
+
import type { GlobalFlags, ResolveOptions, Settings } from "./settings.js";
|
|
9
|
+
/** The authorization code flow an OpenAPI spec declares; a GraphQL service (Linear) writes the same object by hand. */
|
|
10
|
+
export declare const oauthFlowOf: (manifest: ServiceApiManifest, scheme?: string) => OAuthFlow;
|
|
11
|
+
export interface OAuthPresetOptions {
|
|
12
|
+
/** A short word, part of the keyring account: `attio`. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** The name people know: `Attio`. */
|
|
15
|
+
name: string;
|
|
16
|
+
client: OAuthClient;
|
|
17
|
+
/** What the CLI asks for; each must be one the flow lists. */
|
|
18
|
+
scopes: readonly string[];
|
|
19
|
+
/** The spec cannot say which redirect the app registered; a provider that wants an exact one needs `relay`. */
|
|
20
|
+
redirect: OAuthProvider["redirect"];
|
|
21
|
+
revokeUrl?: string;
|
|
22
|
+
authorizeParams?: Record<string, string>;
|
|
23
|
+
/** The provider sends a new refresh token on each refresh; a run with moved folders then never refreshes. */
|
|
24
|
+
rotating?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface OAuthPreset {
|
|
27
|
+
provider: OAuthProvider;
|
|
28
|
+
scopes: readonly string[];
|
|
29
|
+
rotating: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** An installed app's sign-in (authorization code with PKCE) from the flow a spec declares, and the scopes it asks. */
|
|
32
|
+
export declare const oauthPreset: (flow: OAuthFlow, options: OAuthPresetOptions) => OAuthPreset;
|
|
33
|
+
/** What the CLI's entry hands `run()` beside cli-core's own; a test hands a fake service and browser. */
|
|
34
|
+
export interface OAuthEnvironment extends BaseEnvironment {
|
|
35
|
+
fetch?: typeof fetch;
|
|
36
|
+
/** Gets the command, so the entry opens nothing under `--json`, `--no-input`, CI or without a terminal. */
|
|
37
|
+
openBrowser?: (url: string, command?: Command) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface OAuthSessionOptions {
|
|
40
|
+
app: AppIdentity;
|
|
41
|
+
resolveSettings: (flags: GlobalFlags, options?: ResolveOptions) => Settings;
|
|
42
|
+
/** The preset's `id` and `name`: `session list` and `status` read the sign-in without choosing a client. */
|
|
43
|
+
providerId: string;
|
|
44
|
+
service: string;
|
|
45
|
+
/** From `oauthPreset`; the client is the CLI's own choice (a flag, a variable, the config, WireCat's app). */
|
|
46
|
+
preset: (command: Command) => OAuthPreset;
|
|
47
|
+
/** Asks the service whose the access token is; `id` names the account, `account` is what start and status show. */
|
|
48
|
+
verify: (command: Command, accessToken: string, events: EventSink) => Promise<{
|
|
49
|
+
id: string;
|
|
50
|
+
account: Readonly<Record<string, unknown>>;
|
|
51
|
+
}>;
|
|
52
|
+
/** Runs before anything is saved; by default only remembers the account. A CLI that refuses a taken one throws. */
|
|
53
|
+
claim?: (env: NodeJS.ProcessEnv, profile: string, id: string) => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `session start | status | end | list` for a service signed in in the browser (WC-SECR-22): PKCE on the loopback,
|
|
57
|
+
* the account checked before the tokens are kept, refreshes under one lock, and a run with moved folders that never
|
|
58
|
+
* removes the owner's sign-in.
|
|
59
|
+
*/
|
|
60
|
+
export declare const oauthSessionCommand: (options: OAuthSessionOptions) => Command;
|