sim 2.1.18-dev.133.1 → 2.1.18
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/dist/index.js +3654 -4127
- package/package.json +2 -12
- package/dist/auth/device-flow.d.ts +0 -39
- package/dist/auth/oauth-flow.d.ts +0 -119
- package/dist/auth/refresh.d.ts +0 -16
- package/dist/commands/auth.d.ts +0 -5
- package/dist/commands/configure.d.ts +0 -2
- package/dist/commands/credentials.d.ts +0 -3
- package/dist/commands/protocol/chat.d.ts +0 -11
- package/dist/commands/protocol/files-get.d.ts +0 -25
- package/dist/commands/protocol/files-upload.d.ts +0 -2
- package/dist/commands/protocol/index.d.ts +0 -3
- package/dist/commands/protocol/knowledge-document-upload.d.ts +0 -2
- package/dist/commands/protocol/knowledge-export.d.ts +0 -14
- package/dist/commands/protocol/logs-follow.d.ts +0 -39
- package/dist/commands/protocol/resource-directory.d.ts +0 -24
- package/dist/commands/protocol/result.d.ts +0 -2
- package/dist/commands/protocol/tables-import.d.ts +0 -2
- package/dist/commands/protocol/workflow-run-follow.d.ts +0 -56
- package/dist/commands/protocol/workflow-run-get.d.ts +0 -15
- package/dist/commands/protocol/workflow-run-wait.d.ts +0 -3
- package/dist/commands/protocol/workspace-operation-wait.d.ts +0 -14
- package/dist/commands/secrets.d.ts +0 -3
- package/dist/commands/telemetry.d.ts +0 -2
- package/dist/commands/update.d.ts +0 -2
- package/dist/config/index.d.ts +0 -2
- package/dist/config/ini.d.ts +0 -111
- package/dist/config/json-file.d.ts +0 -18
- package/dist/config/paths.d.ts +0 -29
- package/dist/config/profile.d.ts +0 -210
- package/dist/context.d.ts +0 -21
- package/dist/contract/commands.d.ts +0 -14
- package/dist/contract/types.d.ts +0 -306
- package/dist/embed-context.d.ts +0 -79
- package/dist/embed-output.d.ts +0 -15
- package/dist/embed.d.ts +0 -40
- package/dist/environment.d.ts +0 -22
- package/dist/generated/v2-api.d.ts +0 -15057
- package/dist/helpers.d.ts +0 -9
- package/dist/http/client.d.ts +0 -173
- package/dist/http/environment.d.ts +0 -24
- package/dist/http/ndjson.d.ts +0 -5
- package/dist/output/io.d.ts +0 -5
- package/dist/output/presentation.d.ts +0 -4
- package/dist/output/render.d.ts +0 -60
- package/dist/output/terminal-text.d.ts +0 -17
- package/dist/output/trace.d.ts +0 -3
- package/dist/output/truncation.d.ts +0 -3
- package/dist/program.d.ts +0 -21
- package/dist/runtime/build.d.ts +0 -38
- package/dist/runtime/derive.d.ts +0 -20
- package/dist/runtime/execute.d.ts +0 -32
- package/dist/runtime/naming.d.ts +0 -25
- package/dist/runtime/options.d.ts +0 -9
- package/dist/runtime/renamed.d.ts +0 -6
- package/dist/runtime/request.d.ts +0 -110
- package/dist/runtime/result.d.ts +0 -41
- package/dist/runtime/types.d.ts +0 -23
- package/dist/runtime.d.ts +0 -5
- package/dist/runtime.js +0 -21864
- package/dist/telemetry/client-info.d.ts +0 -20
- package/dist/telemetry/coding-agent.d.ts +0 -31
- package/dist/telemetry/index.d.ts +0 -4
- package/dist/telemetry/invocation.d.ts +0 -98
- package/dist/telemetry/policy.d.ts +0 -38
- package/dist/telemetry/state.d.ts +0 -47
- package/dist/telemetry/transport.d.ts +0 -47
- package/dist/terminal/secret-input.d.ts +0 -15
- package/dist/terminal.d.ts +0 -7
- package/dist/transfer/local-file.d.ts +0 -16
- package/dist/transfer/streaming-upload.d.ts +0 -16
- package/dist/transfer/upload-session.d.ts +0 -18
- package/dist/update/check.d.ts +0 -53
- package/dist/update/install.d.ts +0 -20
- package/dist/version.d.ts +0 -10
package/dist/config/profile.d.ts
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { ProfileConfigError } from './ini';
|
|
2
|
-
export declare const DEFAULT_PROFILE = "default";
|
|
3
|
-
/**
|
|
4
|
-
* The API host, which is the `www` one and not the apex.
|
|
5
|
-
*
|
|
6
|
-
* `sim.ai` answers `/api/**` with a 301 to `www.sim.ai`, and the CLI refuses to
|
|
7
|
-
* follow a redirect — a 301 rewrites a POST into a bodyless GET, so following
|
|
8
|
-
* one turns a write into a silent no-op and hands the API key to whatever host
|
|
9
|
-
* `Location` names. Defaulting to the apex therefore made every command fail
|
|
10
|
-
* for anyone who never set an endpoint, and before the refusal existed it was
|
|
11
|
-
* worse: reads succeeded while writes quietly did nothing.
|
|
12
|
-
*/
|
|
13
|
-
export declare const DEFAULT_ENDPOINT = "https://www.sim.ai";
|
|
14
|
-
/**
|
|
15
|
-
* Output formats, in the order `--help` lists them.
|
|
16
|
-
*
|
|
17
|
-
* `table` is for reading, `json`/`yaml` for piping into a parser, and `text` is
|
|
18
|
-
* the one for shell loops: tab-separated, no header, no colour, so `cut`/`awk`/
|
|
19
|
-
* `while read` work without a JSON tool on the box.
|
|
20
|
-
*/
|
|
21
|
-
export declare const OUTPUT_FORMATS: readonly ['table', 'json', 'yaml', 'text'];
|
|
22
|
-
export type OutputFormat = (typeof OUTPUT_FORMATS)[number];
|
|
23
|
-
export { FORBIDDEN_IN_VALUE, ProfileConfigError } from './ini';
|
|
24
|
-
/**
|
|
25
|
-
* Makes a rejected value safe to quote inside an error message.
|
|
26
|
-
*
|
|
27
|
-
* A message is one terminal line, so a value carrying a line break appends
|
|
28
|
-
* lines that read as the CLI's own output. Every message that interpolates text
|
|
29
|
-
* the CLI did not produce — a flag, an environment variable, a hand-edited
|
|
30
|
-
* setting — goes through this, so the rule does not have to be rediscovered at
|
|
31
|
-
* each new message.
|
|
32
|
-
*/
|
|
33
|
-
export declare function redact(value: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* A root flag typed with a value the CLI cannot use.
|
|
36
|
-
*
|
|
37
|
-
* Separate from the rest of {@link ProfileConfigError} so a caller that
|
|
38
|
-
* deliberately tolerates an unresolvable profile — `profiles` shows a broken
|
|
39
|
-
* one as a marked row rather than aborting, because that is the command you run
|
|
40
|
-
* *because* a profile is broken — can still refuse the caller's own argument.
|
|
41
|
-
* The class is the discriminator on purpose: matching the message text would
|
|
42
|
-
* stop working the first time the wording changes.
|
|
43
|
-
*/
|
|
44
|
-
export declare class ProfileOverrideError extends ProfileConfigError {
|
|
45
|
-
constructor(message: string);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The shape a newly created profile name has to have.
|
|
49
|
-
*
|
|
50
|
-
* Enforced only when a profile is being created. A name reaches the config file
|
|
51
|
-
* as part of a section header, and the file format has no escape syntax, so a
|
|
52
|
-
* name that carries a bracket or a line break would forge a header for another
|
|
53
|
-
* profile — the writer refuses that outright, and this pattern is the friendlier
|
|
54
|
-
* refusal that names the rule instead of the mechanism.
|
|
55
|
-
*/
|
|
56
|
-
export declare const PROFILE_NAME_PATTERN: RegExp;
|
|
57
|
-
/**
|
|
58
|
-
* Refuses a name for a profile that does not exist yet.
|
|
59
|
-
*
|
|
60
|
-
* Creation only, deliberately: a hand-written `[profile my stack]` predates this
|
|
61
|
-
* rule and must keep resolving, so the read path stays governed by
|
|
62
|
-
* {@link requireKnownProfile} alone.
|
|
63
|
-
*/
|
|
64
|
-
export declare function validateProfileName(name: string): void;
|
|
65
|
-
/**
|
|
66
|
-
* An OAuth login stored in the credentials file: the short-lived access token
|
|
67
|
-
* the API reads, the rotating refresh token that renews it, and when the
|
|
68
|
-
* access token lapses (epoch milliseconds).
|
|
69
|
-
*/
|
|
70
|
-
export interface StoredOAuthCredential {
|
|
71
|
-
accessToken: string;
|
|
72
|
-
refreshToken: string;
|
|
73
|
-
expiresAt: number;
|
|
74
|
-
/** Authorization server that minted the credential. */
|
|
75
|
-
issuer: string;
|
|
76
|
-
/** Stable across refresh rotation and replaced by a fresh login. */
|
|
77
|
-
loginId: string;
|
|
78
|
-
/** Scope last returned by the authorization server. */
|
|
79
|
-
scope: string;
|
|
80
|
-
}
|
|
81
|
-
/** What a credentials section holds for a profile, or `null` when it is logged out. */
|
|
82
|
-
export type StoredCredential = {
|
|
83
|
-
kind: 'api_key';
|
|
84
|
-
apiKey: string;
|
|
85
|
-
} | {
|
|
86
|
-
kind: 'oauth';
|
|
87
|
-
oauth: StoredOAuthCredential;
|
|
88
|
-
};
|
|
89
|
-
/** Everything a command needs to make a call, after the resolution chain runs. */
|
|
90
|
-
export interface ResolvedProfile {
|
|
91
|
-
name: string;
|
|
92
|
-
endpoint: string;
|
|
93
|
-
/** The profile whose credentials section authenticates this one (itself, or its `auth_profile`). */
|
|
94
|
-
authProfile: string;
|
|
95
|
-
/**
|
|
96
|
-
* An API key, from a flag, the environment, or the credentials file. Null
|
|
97
|
-
* when the profile authenticates through {@link oauth} instead — the two are
|
|
98
|
-
* exclusive: a stored OAuth login wins over a stored key, and an explicit
|
|
99
|
-
* `--api-key`/`SIM_API_KEY` wins over both.
|
|
100
|
-
*/
|
|
101
|
-
apiKey: string | null;
|
|
102
|
-
oauth: StoredOAuthCredential | null;
|
|
103
|
-
workspaceId: string | null;
|
|
104
|
-
output: OutputFormat;
|
|
105
|
-
/**
|
|
106
|
-
* Replaces global `fetch` for every request. Only an embedding server sets it, to
|
|
107
|
-
* answer its own v2 routes in-process; the installed CLI never does.
|
|
108
|
-
*/
|
|
109
|
-
transport?: typeof fetch;
|
|
110
|
-
signal?: AbortSignal;
|
|
111
|
-
/** Where each value came from, for `sim whoami` to explain surprising results. */
|
|
112
|
-
sources: {
|
|
113
|
-
endpoint: SettingSource;
|
|
114
|
-
/** Where the profile's credential came from, whichever kind it is. */
|
|
115
|
-
credential: SettingSource;
|
|
116
|
-
workspaceId: SettingSource;
|
|
117
|
-
output: SettingSource;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
export type SettingSource = 'flag' | 'env' | 'config' | 'credentials' | 'default' | 'unset';
|
|
121
|
-
export interface ProfileOverrides {
|
|
122
|
-
profile?: string;
|
|
123
|
-
endpoint?: string;
|
|
124
|
-
apiKey?: string;
|
|
125
|
-
workspaceId?: string;
|
|
126
|
-
output?: OutputFormat;
|
|
127
|
-
/**
|
|
128
|
-
* Skips the "does this profile exist?" check for the two commands that
|
|
129
|
-
* legitimately name a profile before it exists — `sim login --profile x` and
|
|
130
|
-
* `sim configure --profile x --set-…`, both of which create it.
|
|
131
|
-
*/
|
|
132
|
-
allowUnknownProfile?: boolean;
|
|
133
|
-
}
|
|
134
|
-
export declare function readConfigProfile(profile: string): Record<string, string>;
|
|
135
|
-
export declare function readCredentialsProfile(profile: string): Record<string, string>;
|
|
136
|
-
/**
|
|
137
|
-
* Resolves the one stored identity a profile authenticates through.
|
|
138
|
-
*
|
|
139
|
-
* Existing profiles authenticate through their same-named credentials section.
|
|
140
|
-
* A workspace alias may instead name one direct `auth_profile`; references are
|
|
141
|
-
* deliberately non-recursive so a hand-edited cycle or missing target fails
|
|
142
|
-
* with the setting that needs repair rather than surfacing later as "no key".
|
|
143
|
-
*/
|
|
144
|
-
export declare function resolveAuthenticationProfileName(profile: string): string;
|
|
145
|
-
/**
|
|
146
|
-
* Every profile named by either file, deduplicated and sorted.
|
|
147
|
-
*
|
|
148
|
-
* The name is taken verbatim from what follows `profile `, without a second
|
|
149
|
-
* trim. `configSectionName` builds the header back by prefixing `profile `, so
|
|
150
|
-
* trimming here made the two disagree for a hand-written `[profile padded]`:
|
|
151
|
-
* it listed and passed the "does this profile exist?" check as `padded`, while
|
|
152
|
-
* every read looked for `profile padded` and found nothing — so `-P padded`
|
|
153
|
-
* silently resolved to the built-in defaults, and the spelling that does name
|
|
154
|
-
* the section was refused as unknown. Reporting the padded name keeps the one
|
|
155
|
-
* that selects it the one that is shown, which is also how the credentials
|
|
156
|
-
* file's sections have always been listed.
|
|
157
|
-
*/
|
|
158
|
-
export declare function listProfiles(): string[];
|
|
159
|
-
/** Profiles that directly share the named profile's stored authentication. */
|
|
160
|
-
export declare function listAuthenticationDependents(authProfile: string): string[];
|
|
161
|
-
export declare function writeConfigProfile(profile: string, values: Record<string, string | null>): void;
|
|
162
|
-
/**
|
|
163
|
-
* Stores a login, replacing whatever the section held, or clears it with
|
|
164
|
-
* `null`. One profile holds one credential: writing an OAuth login removes a
|
|
165
|
-
* stored key and vice versa, so a profile can never resolve to a stale one.
|
|
166
|
-
*/
|
|
167
|
-
export declare function writeCredentialsProfile(profile: string, credential: StoredCredential | null): void;
|
|
168
|
-
/**
|
|
169
|
-
* The OAuth login a credentials section holds, or `null` when it holds none or
|
|
170
|
-
* only part of one. A hand-edited section missing its refresh token is treated
|
|
171
|
-
* as logged out rather than as a login that will fail on its first refresh.
|
|
172
|
-
*/
|
|
173
|
-
export declare function readStoredOAuth(credentials: Record<string, string>): StoredOAuthCredential | null;
|
|
174
|
-
/** The Better Auth issuer mounted below a resolved Sim endpoint. */
|
|
175
|
-
export declare function oauthIssuerForEndpoint(endpoint: string): string;
|
|
176
|
-
/** What the named profile's own credentials section holds. */
|
|
177
|
-
export declare function readStoredCredential(profile: string): StoredCredential | null;
|
|
178
|
-
/** Prevents two interactive sign-ins from minting credentials for one profile concurrently. */
|
|
179
|
-
export declare function withProfileLoginLease<T>(profile: string, work: () => Promise<T>): Promise<T>;
|
|
180
|
-
export declare function withCredentialsLock<T>(work: () => Promise<T>): Promise<T>;
|
|
181
|
-
/** Drops the profile from both files. Returns whether anything was removed. */
|
|
182
|
-
export declare function deleteProfile(profile: string): {
|
|
183
|
-
config: boolean;
|
|
184
|
-
credentials: boolean;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Validates an endpoint and strips its trailing slashes.
|
|
188
|
-
*
|
|
189
|
-
* The check has to live here rather than at the call sites because an endpoint
|
|
190
|
-
* reaches the HTTP client from four directions — `--endpoint`, `SIM_ENDPOINT`,
|
|
191
|
-
* `configure --set-endpoint`, and a hand-edited `~/.sim/config` — and an
|
|
192
|
-
* unparseable one escapes as a raw `TypeError: Invalid URL` stack trace from
|
|
193
|
-
* inside Node's URL parser instead of a CLI error.
|
|
194
|
-
*
|
|
195
|
-
* `source` names where the value came from, so the message points at the thing
|
|
196
|
-
* the user has to edit.
|
|
197
|
-
*/
|
|
198
|
-
export declare function normalizeEndpoint(endpoint: string, source: string): string;
|
|
199
|
-
/**
|
|
200
|
-
* Validates a workspace id on its way into the config file.
|
|
201
|
-
*
|
|
202
|
-
* The sibling of {@link normalizeEndpoint}, and for the same reason: a stored
|
|
203
|
-
* setting is read back as a real setting, so a value that could carry a line
|
|
204
|
-
* break would come back as an extra setting the user never typed — including an
|
|
205
|
-
* `endpoint`, which decides where the API key is sent. Only structure is
|
|
206
|
-
* checked, not the id's shape: ids are server-minted and the CLI has no business
|
|
207
|
-
* deciding what one may look like.
|
|
208
|
-
*/
|
|
209
|
-
export declare function normalizeWorkspaceId(workspaceId: string, source: string): string;
|
|
210
|
-
export declare function resolveProfile(overrides?: ProfileOverrides): ResolvedProfile;
|
package/dist/context.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
import { type OutputFormat, type ProfileOverrides, type ResolvedProfile } from './config/index';
|
|
3
|
-
import { SimClient } from './http/client';
|
|
4
|
-
/** Global flags, shared by every subcommand. */
|
|
5
|
-
export interface GlobalOptions {
|
|
6
|
-
profile?: string;
|
|
7
|
-
endpoint?: string;
|
|
8
|
-
workspace?: string;
|
|
9
|
-
output?: OutputFormat;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Commander stores globals on the root command, not on the leaf that ran, so a
|
|
13
|
-
* subcommand handler has to walk up to find them. `optsWithGlobals()` does that
|
|
14
|
-
* walk; reading `command.opts()` alone silently drops `--profile`.
|
|
15
|
-
*/
|
|
16
|
-
export declare function globalsOf(command: Command): GlobalOptions;
|
|
17
|
-
export declare function profileFrom(command: Command, extra?: ProfileOverrides): ResolvedProfile;
|
|
18
|
-
export declare function clientFrom(command: Command): {
|
|
19
|
-
client: SimClient;
|
|
20
|
-
profile: ResolvedProfile;
|
|
21
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CliContract } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* The CLI contract for the v2 surface.
|
|
4
|
-
*
|
|
5
|
-
* Read this as a diff against what is already derivable — an operation absent
|
|
6
|
-
* from this table still gets a command, built entirely from the generated
|
|
7
|
-
* operation table. Only the entries below needed a human.
|
|
8
|
-
*
|
|
9
|
-
* Derived by default:
|
|
10
|
-
* listTables → sim tables list
|
|
11
|
-
* getKnowledgeDocument → sim knowledge documents get <knowledgeBaseId> <documentId>
|
|
12
|
-
* upsertTableRow → sim tables upsert <tableId>
|
|
13
|
-
*/
|
|
14
|
-
export declare const CLI_CONTRACT: CliContract;
|
package/dist/contract/types.d.ts
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import type { V2OperationName } from '../generated/v2-api';
|
|
2
|
-
/**
|
|
3
|
-
* The CLI contract: how the terminal surface maps onto the v2 API.
|
|
4
|
-
*
|
|
5
|
-
* Most of a command is derivable and is NOT stated here. Method, path, path
|
|
6
|
-
* params, field types, enum values, defaults, and required-ness all come from
|
|
7
|
-
* the generated operation table, which comes from the Zod route contracts. The
|
|
8
|
-
* command name itself usually derives from `<resource> <sub-resource> <verb>`.
|
|
9
|
-
*
|
|
10
|
-
* This file carries only what a schema cannot say:
|
|
11
|
-
*
|
|
12
|
-
* - `command` — when the derived name collides or reads badly. REST overloads
|
|
13
|
-
* one path for single and bulk (`DELETE /rows` vs `DELETE /rows/[rowId]`), so
|
|
14
|
-
* those need a human to pick `delete` vs `batch-delete`.
|
|
15
|
-
* - `flags` — when a field's *type* misdescribes its *meaning*. `workflowIds`
|
|
16
|
-
* is `z.string()` that the route splits on commas; nothing in the schema says
|
|
17
|
-
* "list". Also friendlier aliases (`conflictTarget` → `--on`).
|
|
18
|
-
* - `pathFlags` — when a parent path segment is command context rather than the
|
|
19
|
-
* resource being acted on (`workflows runs get <runId> --workflow <id>`).
|
|
20
|
-
* - `pathArgumentNames` — when a route's generic `[id]` needs a clearer CLI
|
|
21
|
-
* placeholder (`<knowledgeBaseId>`).
|
|
22
|
-
* - `profileWorkspacePath` — when `[workspaceId]` is the active profile target,
|
|
23
|
-
* not a resource argument (`workspaces get`).
|
|
24
|
-
* - `columns` — which of a response's fields belong in a table. Editorial.
|
|
25
|
-
* - `confirm` — which operations are destructive enough to demand `--yes`.
|
|
26
|
-
*
|
|
27
|
-
* An operation with nothing unusual needs no entry at all.
|
|
28
|
-
*/
|
|
29
|
-
/** How one request field is exposed as a flag. */
|
|
30
|
-
export interface FlagSpec {
|
|
31
|
-
/** Flag name, kebab-case, without `--`. Defaults to the kebab-cased field name. */
|
|
32
|
-
name?: string;
|
|
33
|
-
/** Short alias, e.g. `w` for `--workspace`. */
|
|
34
|
-
short?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Flag names this field used to answer to, such as `predicate` before the
|
|
37
|
-
* count command's filter was spelled the same as its six siblings'.
|
|
38
|
-
*
|
|
39
|
-
* Kept only so an existing script does not break: hidden from help and from
|
|
40
|
-
* the generated docs, warns on stderr, and refuses when combined with the
|
|
41
|
-
* current spelling rather than silently picking one.
|
|
42
|
-
*/
|
|
43
|
-
renamedFrom?: readonly string[];
|
|
44
|
-
/**
|
|
45
|
-
* Accept one or more space-separated values, or `@path` / `@-` with one
|
|
46
|
-
* value per line.
|
|
47
|
-
*
|
|
48
|
-
* Only says that several values are allowed — how they reach the wire is
|
|
49
|
-
* decided by the field's kind, not here. A `string` field is one the route
|
|
50
|
-
* splits on commas (`workflowIds`), so the values are joined; anything else
|
|
51
|
-
* genuinely wants an array (`rowIds`, `knowledgeBaseIds`). Conflating the two
|
|
52
|
-
* turned multi-value `--kb` and `--row` into a single bogus value.
|
|
53
|
-
*
|
|
54
|
-
* Still needed on the string case because "this string is really a list" is
|
|
55
|
-
* invisible to any type-driven generator.
|
|
56
|
-
*/
|
|
57
|
-
list?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* The list's natural source is a manifest file, so `@path` / `@-` skip blank
|
|
60
|
-
* lines and `#` comments instead of refusing them.
|
|
61
|
-
*
|
|
62
|
-
* The shared reader treats a blank line as a typo, which is right for an id
|
|
63
|
-
* list. A dependency list is pasted from a requirements file or a lockfile,
|
|
64
|
-
* where blank lines and comments are how people structure it, and the API
|
|
65
|
-
* already ignores both — the terminal was the only surface that refused
|
|
66
|
-
* them. Inline argv values are untouched: an empty argument is still an
|
|
67
|
-
* error, and a literal `#` value can still be passed.
|
|
68
|
-
*/
|
|
69
|
-
manifest?: true;
|
|
70
|
-
/** Take a JSON string. Implied for object/array/unknown fields. */
|
|
71
|
-
json?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Accept a plain whole number and send the route's `{ type: 'rows', max: n }`.
|
|
74
|
-
*
|
|
75
|
-
* A deliberate one-off for `tables dispatches create --max-rows`: the only
|
|
76
|
-
* request field in the CLI whose object shape holds exactly one free value,
|
|
77
|
-
* because its `type` is a `z.literal('rows')`. Left as JSON, the flag made a
|
|
78
|
-
* caller type `{"type":"rows","max":100}` — four tokens of ceremony to say
|
|
79
|
-
* `100`, in a shape nothing in the terminal spells out. Not a general
|
|
80
|
-
* value-transform hook: no second field wants one, and a second one arriving
|
|
81
|
-
* is the point at which this should become one.
|
|
82
|
-
*/
|
|
83
|
-
rowCap?: true;
|
|
84
|
-
/** Overrides the help text otherwise taken from the OpenAPI description. */
|
|
85
|
-
describe?: string;
|
|
86
|
-
/**
|
|
87
|
-
* Value sent when the caller passes nothing, in place of the server's default.
|
|
88
|
-
*
|
|
89
|
-
* For a command whose declared `columns` read a field the API only sends at a
|
|
90
|
-
* heavier setting: `logs list` shows `workflow.name`, which `details=basic`
|
|
91
|
-
* omits, so the primary debugging table had a permanently empty column. It is
|
|
92
|
-
* a request default, not a flag default — whatever the caller types wins,
|
|
93
|
-
* including a deliberate `--details basic`.
|
|
94
|
-
*/
|
|
95
|
-
requestDefault?: string;
|
|
96
|
-
/** Accepted values when the generated descriptor cannot recover an enum. */
|
|
97
|
-
choices?: readonly string[];
|
|
98
|
-
/**
|
|
99
|
-
* Expose a string-backed API boolean as a conventional terminal toggle.
|
|
100
|
-
*
|
|
101
|
-
* A toggle declared here carries no generated `--no-<name>` twin by default,
|
|
102
|
-
* because sending false is usually either meaningless — the server already
|
|
103
|
-
* defaults the field to false — or rejected outright, as on a field the API
|
|
104
|
-
* declares as `z.literal(true)`. {@link negatable} asks for the twin back on
|
|
105
|
-
* the one kind of field where false is a real request.
|
|
106
|
-
*/
|
|
107
|
-
boolean?: true;
|
|
108
|
-
/**
|
|
109
|
-
* Give a {@link boolean} toggle its `--no-<name>` twin after all.
|
|
110
|
-
*
|
|
111
|
-
* Withholding the twin is right for a one-way switch: most string-backed
|
|
112
|
-
* toggles sit on a field the server already defaults to false, so a negation
|
|
113
|
-
* would only restate the default, and on a `z.literal(true)` field it would
|
|
114
|
-
* send a request the route rejects. `files list --recursive` is neither — the
|
|
115
|
-
* API turns it on by itself as soon as a search is set, so without a spelling
|
|
116
|
-
* for false there is no way to search one folder without descending into it.
|
|
117
|
-
* Declared per flag rather than derived from the union's false spellings,
|
|
118
|
-
* which every one of these toggles publishes whether or not sending one means
|
|
119
|
-
* anything.
|
|
120
|
-
*/
|
|
121
|
-
negatable?: true;
|
|
122
|
-
/**
|
|
123
|
-
* This field carries a folder path, so percent-encode each of its segments.
|
|
124
|
-
*
|
|
125
|
-
* The API's canonical folder path is percent-encoded per segment, which made
|
|
126
|
-
* the terminal the only place a folder had to be spelled `/Folder%201`
|
|
127
|
-
* instead of the `/Folder 1` shown everywhere else; typing what you see was
|
|
128
|
-
* rejected with a message that never mentioned encoding. Marked rather than
|
|
129
|
-
* inferred from the field's name: `files upload` and `knowledge documents
|
|
130
|
-
* upload` take a `path` that is a LOCAL file, and encoding one of those would
|
|
131
|
-
* break the read.
|
|
132
|
-
*/
|
|
133
|
-
folderPath?: true;
|
|
134
|
-
/**
|
|
135
|
-
* Never expose this field as a flag, and never send it.
|
|
136
|
-
*
|
|
137
|
-
* For request fields the terminal cannot honor — `stream: true` switches the
|
|
138
|
-
* response to SSE, which the JSON client would try to `JSON.parse`. Offering
|
|
139
|
-
* the flag would advertise a mode that breaks; a bespoke streaming command
|
|
140
|
-
* owns that instead.
|
|
141
|
-
*/
|
|
142
|
-
omit?: boolean;
|
|
143
|
-
/** Accept and send this generated field, but hide its low-level flag from help. */
|
|
144
|
-
hidden?: boolean;
|
|
145
|
-
}
|
|
146
|
-
/** How a route path parameter is exposed as a required named option. */
|
|
147
|
-
export interface PathFlagSpec {
|
|
148
|
-
/** Flag name, kebab-case, without `--`. Defaults to the kebab-cased path parameter. */
|
|
149
|
-
name?: string;
|
|
150
|
-
/** Help placeholder without angle brackets. Defaults to `value`. */
|
|
151
|
-
placeholder?: string;
|
|
152
|
-
/** Short alias, e.g. `k` for `--kb`. */
|
|
153
|
-
short?: string;
|
|
154
|
-
/** One-line help for the scope selected by this path parameter. */
|
|
155
|
-
describe?: string;
|
|
156
|
-
}
|
|
157
|
-
/** A column in table-mode output. */
|
|
158
|
-
export interface ColumnSpec {
|
|
159
|
-
/** Header, and the default path into the row when `value` is omitted. */
|
|
160
|
-
header: string;
|
|
161
|
-
/** Dot path into the row. Defaults to `header`. */
|
|
162
|
-
path?: string;
|
|
163
|
-
/**
|
|
164
|
-
* Narrowest this column may lock to when a renderer fixes its widths before
|
|
165
|
-
* it has seen the rows.
|
|
166
|
-
*
|
|
167
|
-
* `logs list` sizes every column from the page it is about to print, so it
|
|
168
|
-
* never needs this. A follow cannot: it locks the widths on its first batch so
|
|
169
|
-
* the stream reads as one table, and `logs follow -n 0` locks them on no rows
|
|
170
|
-
* at all — every column collapsed to its header label, and a run id printed as
|
|
171
|
-
* `9f…`. The floor is what the column's own rendering is known to need (a
|
|
172
|
-
* timestamp is 19 characters, a run id 36), so it is stated here beside the
|
|
173
|
-
* `format` that produces it rather than guessed by the renderer. Capped by the
|
|
174
|
-
* renderer's own maximum cell width; a floor above that is a spec bug.
|
|
175
|
-
*/
|
|
176
|
-
minWidth?: number;
|
|
177
|
-
/**
|
|
178
|
-
* Rendering hint; `auto` inspects the value.
|
|
179
|
-
*
|
|
180
|
-
* `folder-path` is the display half of `FlagSpec.folderPath`: it undoes the
|
|
181
|
-
* wire encoding for the human formats, so a folder no longer prints as
|
|
182
|
-
* `/cli-test-a/nested%20one` in the same row as the `nested one` the server
|
|
183
|
-
* put in the adjacent name column.
|
|
184
|
-
*
|
|
185
|
-
* `score` fixes a similarity to four decimals. The raw double arrives as
|
|
186
|
-
* `0.2818957269585687`, a nineteen-character column whose last dozen digits
|
|
187
|
-
* cannot separate one result from another.
|
|
188
|
-
*/
|
|
189
|
-
format?: 'auto' | 'timestamp' | 'bytes' | 'duration' | 'bool' | 'cost' | 'count' | 'trace-count' | 'folder-path' | 'score';
|
|
190
|
-
}
|
|
191
|
-
export interface BodyVariantSpec {
|
|
192
|
-
/** User-facing flag name, without `--`. */
|
|
193
|
-
name: string;
|
|
194
|
-
/** Request-body property populated by this variant. */
|
|
195
|
-
property: string;
|
|
196
|
-
/** JSON shape accepted by this variant. */
|
|
197
|
-
kind: 'object' | 'array';
|
|
198
|
-
/** One-line help describing when to use this variant. */
|
|
199
|
-
describe: string;
|
|
200
|
-
}
|
|
201
|
-
export interface CommandVariantSpec {
|
|
202
|
-
/** Full alternate command path, such as `workflows mv`. */
|
|
203
|
-
command: string;
|
|
204
|
-
/** Request fields exposed as required positional arguments. */
|
|
205
|
-
positionals?: readonly string[];
|
|
206
|
-
/** Request fields available on this narrower command surface. */
|
|
207
|
-
requestFields?: readonly string[];
|
|
208
|
-
/** One-line help for the alternate command. */
|
|
209
|
-
describe?: string;
|
|
210
|
-
}
|
|
211
|
-
export interface CommandSpec {
|
|
212
|
-
/**
|
|
213
|
-
* Command path, space-separated. Omit to accept the derived
|
|
214
|
-
* `<resource> [sub-resource] <verb>` name.
|
|
215
|
-
*/
|
|
216
|
-
command?: string;
|
|
217
|
-
/** Run this operation when its top-level group is invoked without a subcommand. */
|
|
218
|
-
groupDefault?: boolean;
|
|
219
|
-
/** Alternate leaf command names, such as `ls` for `list`. */
|
|
220
|
-
aliases?: readonly string[];
|
|
221
|
-
/**
|
|
222
|
-
* Full command paths this operation used to answer to, such as
|
|
223
|
-
* `tables count create` before it became `tables rows count`.
|
|
224
|
-
*
|
|
225
|
-
* Unlike {@link aliases}, these are kept only so an existing script does not
|
|
226
|
-
* break: each is hidden from help and from the generated docs, and warns on
|
|
227
|
-
* stderr with the current spelling. Give the whole path, because a rename can
|
|
228
|
-
* move a command between groups rather than just retitle its leaf.
|
|
229
|
-
*/
|
|
230
|
-
renamedFrom?: readonly string[];
|
|
231
|
-
/** Route path parameters exposed as required named options instead of positionals. */
|
|
232
|
-
pathFlags?: Record<string, PathFlagSpec>;
|
|
233
|
-
/** Friendly placeholders for route path parameters that remain positional. */
|
|
234
|
-
pathArgumentNames?: Record<string, string>;
|
|
235
|
-
/** Fill a `[workspaceId]` route segment from the active profile instead of an argument. */
|
|
236
|
-
profileWorkspacePath?: boolean;
|
|
237
|
-
/** Request fields exposed as required positional arguments, in order. */
|
|
238
|
-
positionals?: readonly string[];
|
|
239
|
-
/** Restrict this command to these request fields; profile fields remain implicit. */
|
|
240
|
-
requestFields?: readonly string[];
|
|
241
|
-
/** Additional command shapes backed by the same API operation. */
|
|
242
|
-
variants?: readonly CommandVariantSpec[];
|
|
243
|
-
/** One-line help. Falls back to the OpenAPI summary for the operation. */
|
|
244
|
-
describe?: string;
|
|
245
|
-
/** Per-field flag overrides, keyed by the contract's field name. */
|
|
246
|
-
flags?: Record<string, FlagSpec>;
|
|
247
|
-
/** Friendly mutually-exclusive flags for an otherwise opaque union body. */
|
|
248
|
-
bodyVariants?: readonly BodyVariantSpec[];
|
|
249
|
-
/** Columns for table output. Omit on non-list commands to print a record. */
|
|
250
|
-
columns?: ColumnSpec[];
|
|
251
|
-
/** Fields shown for a single record in human formats. Machine output stays raw. */
|
|
252
|
-
fields?: ColumnSpec[];
|
|
253
|
-
/** Add `--trace` to expand recursive trace spans in human-readable output. */
|
|
254
|
-
expandedTrace?: boolean;
|
|
255
|
-
/** Dot path to a nested result array rendered as the command's human list. */
|
|
256
|
-
itemsPath?: string;
|
|
257
|
-
/**
|
|
258
|
-
* A page-envelope field that qualifies the whole list, stated once for the
|
|
259
|
-
* human formats.
|
|
260
|
-
*
|
|
261
|
-
* `billing logs` answers a different question depending on the credential —
|
|
262
|
-
* an OAuth login or personal key sees the caller's own events, while a
|
|
263
|
-
* workspace key sees the whole workspace ledger. The response says which. The value
|
|
264
|
-
* belongs to the query rather than to any row, so it is not a column; it goes
|
|
265
|
-
* to stderr so that a `--output text` consumer cutting tab-separated fields
|
|
266
|
-
* still reads only rows. `json` and `yaml` print the unwrapped `data` array
|
|
267
|
-
* and so drop the field too, which is why the note is not limited to the
|
|
268
|
-
* human formats — see `runtime/result`.
|
|
269
|
-
*/
|
|
270
|
-
pageNote?: {
|
|
271
|
-
path: string;
|
|
272
|
-
label: string;
|
|
273
|
-
};
|
|
274
|
-
/** Allow an optional workspaceId field to omit the configured workspace filter. */
|
|
275
|
-
allWorkspaces?: boolean;
|
|
276
|
-
/**
|
|
277
|
-
* Require `--yes`. The message should say what is about to be destroyed —
|
|
278
|
-
* the point is that the caller can tell whether they meant it.
|
|
279
|
-
*/
|
|
280
|
-
confirm?: string;
|
|
281
|
-
/**
|
|
282
|
-
* Discover table columns from inside this nested field as well as from the
|
|
283
|
-
* row's own scalars.
|
|
284
|
-
*
|
|
285
|
-
* For rows whose real content sits in a wrapper the server chose — a table
|
|
286
|
-
* row's user-defined cells live under `data` — the inferred columns would
|
|
287
|
-
* otherwise be `id` and two timestamps, because a nested object cannot be a
|
|
288
|
-
* column. Only meaningful when `columns` is absent.
|
|
289
|
-
*/
|
|
290
|
-
expand?: string;
|
|
291
|
-
/**
|
|
292
|
-
* The response IS a document, not a record to look at.
|
|
293
|
-
*
|
|
294
|
-
* `workflows export` exists to be redirected into a file and fed back to
|
|
295
|
-
* `import`, so a key/value view of it is wrong at any fidelity — the useful
|
|
296
|
-
* artifact is the payload itself. Document commands emit raw JSON (or YAML
|
|
297
|
-
* when the profile says so) whatever the profile's display format is.
|
|
298
|
-
*/
|
|
299
|
-
document?: boolean;
|
|
300
|
-
/** Mutation returns a durable workspace operation and supports --wait. */
|
|
301
|
-
workspaceOperation?: boolean;
|
|
302
|
-
/** Keep the operation out of the CLI surface entirely. */
|
|
303
|
-
hidden?: boolean;
|
|
304
|
-
}
|
|
305
|
-
/** The contract: operation name → how it appears in the terminal. */
|
|
306
|
-
export type CliContract = Partial<Record<V2OperationName, CommandSpec>>;
|
package/dist/embed-context.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import type { ResolvedProfile } from './config/profile';
|
|
3
|
-
import type { EmbeddedOutput } from './embed-output';
|
|
4
|
-
/**
|
|
5
|
-
* The async-context plumbing for embedded (in-process) CLI runs, split from
|
|
6
|
-
* `embed.ts` so `config/profile.ts` can consult it without a runtime import
|
|
7
|
-
* cycle (this module imports nothing from the CLI beyond a type).
|
|
8
|
-
*/
|
|
9
|
-
export interface EmbeddedCliIdentity {
|
|
10
|
-
endpoint: string;
|
|
11
|
-
apiKey: string;
|
|
12
|
-
workspaceId?: string;
|
|
13
|
-
/**
|
|
14
|
-
* How requests reach the endpoint. A host that serves the v2 routes itself passes a
|
|
15
|
-
* transport that dispatches to them in-process, so an embedded run never leaves the
|
|
16
|
-
* server: no network hop, no proxy body ceiling, no per-key rate limit meant for
|
|
17
|
-
* callers on the wire. Absent, requests go over `fetch` like the installed CLI's.
|
|
18
|
-
*/
|
|
19
|
-
transport?: typeof fetch;
|
|
20
|
-
/** Cancellation belongs to this invocation, never to the hosting process. */
|
|
21
|
-
signal?: AbortSignal;
|
|
22
|
-
}
|
|
23
|
-
/** A host-owned immutable file, streamed once and released when the invocation ends. */
|
|
24
|
-
export interface EmbeddedFileSnapshot {
|
|
25
|
-
size: number;
|
|
26
|
-
/** The host's read lease also bounds outstanding upload requests. */
|
|
27
|
-
signal?: AbortSignal;
|
|
28
|
-
stream(): Promise<ReadableStream<Uint8Array>>;
|
|
29
|
-
dispose(): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
export interface EmbedContext {
|
|
32
|
-
identity: EmbeddedCliIdentity;
|
|
33
|
-
/** Absolute caller filesystem working directory; never inherited from the embedding server. */
|
|
34
|
-
workingDirectory?: string;
|
|
35
|
-
stdout: EmbeddedOutput;
|
|
36
|
-
stderr: EmbeddedOutput;
|
|
37
|
-
/**
|
|
38
|
-
* Reads bounded structured arguments from the caller's machine on demand.
|
|
39
|
-
* The CLI owns path syntax; the host receives the resolved path without `@`.
|
|
40
|
-
* An embedded invocation never falls back to the server's filesystem.
|
|
41
|
-
*/
|
|
42
|
-
readFile?: (path: string) => Promise<string | Uint8Array>;
|
|
43
|
-
/** File transfers use a snapshot; structured arguments use the separate bounded reader. */
|
|
44
|
-
openFile?: (path: string) => Promise<EmbeddedFileSnapshot>;
|
|
45
|
-
/**
|
|
46
|
-
* Soft-fail exit code (a failed run outcome, `runs wait` timeout). Embedded
|
|
47
|
-
* commands write here INSTEAD of process.exitCode: that global is shared, so
|
|
48
|
-
* two parallel embedded invocations raced on it — one run could observe and
|
|
49
|
-
* clear another's failure.
|
|
50
|
-
*/
|
|
51
|
-
softExitCode?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Where a download lands when embedded: the host writes to the caller's own machine
|
|
54
|
-
* (through its file adapter), never to the server's disk. Resolves only after publication;
|
|
55
|
-
* a refused or uncertain write throws. The host consumes or cancels the stream;
|
|
56
|
-
* it must not buffer the complete download. Overwrite policy must hold atomically.
|
|
57
|
-
*/
|
|
58
|
-
writeFile?: (path: string, content: ReadableStream<Uint8Array>, options: {
|
|
59
|
-
overwrite: boolean;
|
|
60
|
-
}) => Promise<void>;
|
|
61
|
-
}
|
|
62
|
-
/** The embedded-vs-standalone seam for soft-fail codes: context when embedded, global otherwise. */
|
|
63
|
-
export declare function setSoftExitCode(code: number): void;
|
|
64
|
-
export declare const embedStore: AsyncLocalStorage<EmbedContext>;
|
|
65
|
-
/** Thrown in place of process.exit inside an embedded run. */
|
|
66
|
-
export declare class EmbeddedExit extends Error {
|
|
67
|
-
readonly code: number;
|
|
68
|
-
constructor(code: number);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* The profile resolver consults this before touching env or config files: an
|
|
72
|
-
* embedded run's identity comes entirely from the hosting server (it already
|
|
73
|
-
* authenticated the caller and knows the workspace), never from profiles,
|
|
74
|
-
* login state, or the host process env. Null outside an embedded run, which
|
|
75
|
-
* keeps the installed CLI's behavior byte-identical.
|
|
76
|
-
*/
|
|
77
|
-
export declare function embeddedProfile(): ResolvedProfile | null;
|
|
78
|
-
/** Exits the terminal CLI without terminating an embedding host. */
|
|
79
|
-
export declare function exitCli(code: number): never;
|
package/dist/embed-output.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class EmbeddedOutputLimitError extends Error {
|
|
2
|
-
constructor();
|
|
3
|
-
}
|
|
4
|
-
/** Byte capture preserves write boundaries and bounds both bytes and allocation count. */
|
|
5
|
-
export declare class EmbeddedOutput {
|
|
6
|
-
private readonly blocks;
|
|
7
|
-
private pending;
|
|
8
|
-
private used;
|
|
9
|
-
private total;
|
|
10
|
-
limitError: EmbeddedOutputLimitError | undefined;
|
|
11
|
-
write(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
|
12
|
-
/** Error rendering and cleanup must still finish when diagnostic capture fills up. */
|
|
13
|
-
diagnostic(message: string): void;
|
|
14
|
-
text(): string;
|
|
15
|
-
}
|