sim 2.1.8-dev.94.1 → 2.1.8-preview.100.1

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.
Files changed (56) hide show
  1. package/README.md +52 -20
  2. package/THIRD_PARTY_LICENSES +42 -0
  3. package/dist/index.js +3713 -1160
  4. package/package.json +6 -16
  5. package/dist/auth/device-flow.d.ts +0 -38
  6. package/dist/commands/auth.d.ts +0 -5
  7. package/dist/commands/configure.d.ts +0 -2
  8. package/dist/commands/credentials.d.ts +0 -3
  9. package/dist/commands/protocol/chat.d.ts +0 -11
  10. package/dist/commands/protocol/files-get.d.ts +0 -25
  11. package/dist/commands/protocol/files-upload.d.ts +0 -2
  12. package/dist/commands/protocol/index.d.ts +0 -3
  13. package/dist/commands/protocol/knowledge-document-upload.d.ts +0 -2
  14. package/dist/commands/protocol/logs-follow.d.ts +0 -39
  15. package/dist/commands/protocol/resource-directory.d.ts +0 -24
  16. package/dist/commands/protocol/result.d.ts +0 -2
  17. package/dist/commands/protocol/tables-import.d.ts +0 -2
  18. package/dist/commands/protocol/workflow-run-follow.d.ts +0 -56
  19. package/dist/commands/protocol/workflow-run-get.d.ts +0 -15
  20. package/dist/commands/protocol/workflow-run-wait.d.ts +0 -3
  21. package/dist/commands/secrets.d.ts +0 -3
  22. package/dist/config/index.d.ts +0 -2
  23. package/dist/config/ini.d.ts +0 -111
  24. package/dist/config/paths.d.ts +0 -10
  25. package/dist/config/profile.d.ts +0 -158
  26. package/dist/context.d.ts +0 -21
  27. package/dist/contract/commands.d.ts +0 -14
  28. package/dist/contract/types.d.ts +0 -292
  29. package/dist/embed-context.d.ts +0 -83
  30. package/dist/embed-output.d.ts +0 -15
  31. package/dist/generated/v2-api.d.ts +0 -12969
  32. package/dist/helpers.d.ts +0 -9
  33. package/dist/http/client.d.ts +0 -166
  34. package/dist/http/environment.d.ts +0 -32
  35. package/dist/output/presentation.d.ts +0 -4
  36. package/dist/output/render.d.ts +0 -60
  37. package/dist/output/terminal-text.d.ts +0 -17
  38. package/dist/output/trace.d.ts +0 -3
  39. package/dist/program.d.ts +0 -21
  40. package/dist/runtime/build.d.ts +0 -38
  41. package/dist/runtime/derive.d.ts +0 -20
  42. package/dist/runtime/execute.d.ts +0 -30
  43. package/dist/runtime/naming.d.ts +0 -25
  44. package/dist/runtime/options.d.ts +0 -7
  45. package/dist/runtime/renamed.d.ts +0 -20
  46. package/dist/runtime/request.d.ts +0 -109
  47. package/dist/runtime/result.d.ts +0 -50
  48. package/dist/runtime/types.d.ts +0 -23
  49. package/dist/runtime.d.ts +0 -4
  50. package/dist/runtime.js +0 -16832
  51. package/dist/terminal/secret-input.d.ts +0 -15
  52. package/dist/terminal.d.ts +0 -6
  53. package/dist/transfer/local-file.d.ts +0 -16
  54. package/dist/transfer/streaming-upload.d.ts +0 -16
  55. package/dist/transfer/upload-session.d.ts +0 -18
  56. package/dist/version.d.ts +0 -10
@@ -1,292 +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
- /** Take a JSON string. Implied for object/array/unknown fields. */
59
- json?: boolean;
60
- /**
61
- * Accept a plain whole number and send the route's `{ type: 'rows', max: n }`.
62
- *
63
- * A deliberate one-off for `tables dispatches create --max-rows`: the only
64
- * request field in the CLI whose object shape holds exactly one free value,
65
- * because its `type` is a `z.literal('rows')`. Left as JSON, the flag made a
66
- * caller type `{"type":"rows","max":100}` — four tokens of ceremony to say
67
- * `100`, in a shape nothing in the terminal spells out. Not a general
68
- * value-transform hook: no second field wants one, and a second one arriving
69
- * is the point at which this should become one.
70
- */
71
- rowCap?: true;
72
- /** Overrides the help text otherwise taken from the OpenAPI description. */
73
- describe?: string;
74
- /**
75
- * Value sent when the caller passes nothing, in place of the server's default.
76
- *
77
- * For a command whose declared `columns` read a field the API only sends at a
78
- * heavier setting: `logs list` shows `workflow.name`, which `details=basic`
79
- * omits, so the primary debugging table had a permanently empty column. It is
80
- * a request default, not a flag default — whatever the caller types wins,
81
- * including a deliberate `--details basic`.
82
- */
83
- requestDefault?: string;
84
- /** Accepted values when the generated descriptor cannot recover an enum. */
85
- choices?: readonly string[];
86
- /**
87
- * Expose a string-backed API boolean as a conventional terminal toggle.
88
- *
89
- * A toggle declared here carries no generated `--no-<name>` twin by default,
90
- * because sending false is usually either meaningless — the server already
91
- * defaults the field to false — or rejected outright, as on a field the API
92
- * declares as `z.literal(true)`. {@link negatable} asks for the twin back on
93
- * the one kind of field where false is a real request.
94
- */
95
- boolean?: true;
96
- /**
97
- * Give a {@link boolean} toggle its `--no-<name>` twin after all.
98
- *
99
- * Withholding the twin is right for a one-way switch: most string-backed
100
- * toggles sit on a field the server already defaults to false, so a negation
101
- * would only restate the default, and on a `z.literal(true)` field it would
102
- * send a request the route rejects. `files list --recursive` is neither — the
103
- * API turns it on by itself as soon as a search is set, so without a spelling
104
- * for false there is no way to search one folder without descending into it.
105
- * Declared per flag rather than derived from the union's false spellings,
106
- * which every one of these toggles publishes whether or not sending one means
107
- * anything.
108
- */
109
- negatable?: true;
110
- /**
111
- * This field carries a folder path, so percent-encode each of its segments.
112
- *
113
- * The API's canonical folder path is percent-encoded per segment, which made
114
- * the terminal the only place a folder had to be spelled `/Folder%201`
115
- * instead of the `/Folder 1` shown everywhere else; typing what you see was
116
- * rejected with a message that never mentioned encoding. Marked rather than
117
- * inferred from the field's name: `files upload` and `knowledge documents
118
- * upload` take a `path` that is a LOCAL file, and encoding one of those would
119
- * break the read.
120
- */
121
- folderPath?: true;
122
- /**
123
- * Never expose this field as a flag, and never send it.
124
- *
125
- * For request fields the terminal cannot honor — `stream: true` switches the
126
- * response to SSE, which the JSON client would try to `JSON.parse`. Offering
127
- * the flag would advertise a mode that breaks; a bespoke streaming command
128
- * owns that instead.
129
- */
130
- omit?: boolean;
131
- /** Accept and send this generated field, but hide its low-level flag from help. */
132
- hidden?: boolean;
133
- }
134
- /** How a route path parameter is exposed as a required named option. */
135
- export interface PathFlagSpec {
136
- /** Flag name, kebab-case, without `--`. Defaults to the kebab-cased path parameter. */
137
- name?: string;
138
- /** Help placeholder without angle brackets. Defaults to `value`. */
139
- placeholder?: string;
140
- /** Short alias, e.g. `k` for `--kb`. */
141
- short?: string;
142
- /** One-line help for the scope selected by this path parameter. */
143
- describe?: string;
144
- }
145
- /** A column in table-mode output. */
146
- export interface ColumnSpec {
147
- /** Header, and the default path into the row when `value` is omitted. */
148
- header: string;
149
- /** Dot path into the row. Defaults to `header`. */
150
- path?: string;
151
- /**
152
- * Narrowest this column may lock to when a renderer fixes its widths before
153
- * it has seen the rows.
154
- *
155
- * `logs list` sizes every column from the page it is about to print, so it
156
- * never needs this. A follow cannot: it locks the widths on its first batch so
157
- * the stream reads as one table, and `logs follow -n 0` locks them on no rows
158
- * at all — every column collapsed to its header label, and a run id printed as
159
- * `9f…`. The floor is what the column's own rendering is known to need (a
160
- * timestamp is 19 characters, a run id 36), so it is stated here beside the
161
- * `format` that produces it rather than guessed by the renderer. Capped by the
162
- * renderer's own maximum cell width; a floor above that is a spec bug.
163
- */
164
- minWidth?: number;
165
- /**
166
- * Rendering hint; `auto` inspects the value.
167
- *
168
- * `folder-path` is the display half of `FlagSpec.folderPath`: it undoes the
169
- * wire encoding for the human formats, so a folder no longer prints as
170
- * `/cli-test-a/nested%20one` in the same row as the `nested one` the server
171
- * put in the adjacent name column.
172
- *
173
- * `score` fixes a similarity to four decimals. The raw double arrives as
174
- * `0.2818957269585687`, a nineteen-character column whose last dozen digits
175
- * cannot separate one result from another.
176
- */
177
- format?: 'auto' | 'timestamp' | 'bytes' | 'duration' | 'bool' | 'cost' | 'count' | 'trace-count' | 'folder-path' | 'score';
178
- }
179
- export interface BodyVariantSpec {
180
- /** User-facing flag name, without `--`. */
181
- name: string;
182
- /** Request-body property populated by this variant. */
183
- property: string;
184
- /** JSON shape accepted by this variant. */
185
- kind: 'object' | 'array';
186
- /** One-line help describing when to use this variant. */
187
- describe: string;
188
- }
189
- export interface CommandVariantSpec {
190
- /** Full alternate command path, such as `workflows mv`. */
191
- command: string;
192
- /** Request fields exposed as required positional arguments. */
193
- positionals?: readonly string[];
194
- /** Request fields available on this narrower command surface. */
195
- requestFields?: readonly string[];
196
- /** One-line help for the alternate command. */
197
- describe?: string;
198
- }
199
- export interface CommandSpec {
200
- /**
201
- * Command path, space-separated. Omit to accept the derived
202
- * `<resource> [sub-resource] <verb>` name.
203
- */
204
- command?: string;
205
- /** Run this operation when its top-level group is invoked without a subcommand. */
206
- groupDefault?: boolean;
207
- /** Alternate leaf command names, such as `ls` for `list`. */
208
- aliases?: readonly string[];
209
- /**
210
- * Full command paths this operation used to answer to, such as
211
- * `tables count create` before it became `tables rows count`.
212
- *
213
- * Unlike {@link aliases}, these are kept only so an existing script does not
214
- * break: each is hidden from help and from the generated docs, and warns on
215
- * stderr with the current spelling. Give the whole path, because a rename can
216
- * move a command between groups rather than just retitle its leaf.
217
- */
218
- renamedFrom?: readonly string[];
219
- /** Route path parameters exposed as required named options instead of positionals. */
220
- pathFlags?: Record<string, PathFlagSpec>;
221
- /** Friendly placeholders for route path parameters that remain positional. */
222
- pathArgumentNames?: Record<string, string>;
223
- /** Fill a `[workspaceId]` route segment from the active profile instead of an argument. */
224
- profileWorkspacePath?: boolean;
225
- /** Request fields exposed as required positional arguments, in order. */
226
- positionals?: readonly string[];
227
- /** Restrict this command to these request fields; profile fields remain implicit. */
228
- requestFields?: readonly string[];
229
- /** Additional command shapes backed by the same API operation. */
230
- variants?: readonly CommandVariantSpec[];
231
- /** One-line help. Falls back to the OpenAPI summary for the operation. */
232
- describe?: string;
233
- /** Per-field flag overrides, keyed by the contract's field name. */
234
- flags?: Record<string, FlagSpec>;
235
- /** Friendly mutually-exclusive flags for an otherwise opaque union body. */
236
- bodyVariants?: readonly BodyVariantSpec[];
237
- /** Columns for table output. Omit on non-list commands to print a record. */
238
- columns?: ColumnSpec[];
239
- /** Fields shown for a single record in human formats. Machine output stays raw. */
240
- fields?: ColumnSpec[];
241
- /** Add `--trace` to expand recursive trace spans in human-readable output. */
242
- expandedTrace?: boolean;
243
- /** Dot path to a nested result array rendered as the command's human list. */
244
- itemsPath?: string;
245
- /**
246
- * A page-envelope field that qualifies the whole list, stated once for the
247
- * human formats.
248
- *
249
- * `billing logs` answers a different question depending on the kind of API
250
- * key that asked — a personal key sees the caller's own events, a workspace
251
- * key the whole workspace ledger — and the response says which. The value
252
- * belongs to the query rather than to any row, so it is not a column; it goes
253
- * to stderr so that a `--output text` consumer cutting tab-separated fields
254
- * still reads only rows. `json` and `yaml` print the unwrapped `data` array
255
- * and so drop the field too, which is why the note is not limited to the
256
- * human formats — see `runtime/result`.
257
- */
258
- pageNote?: {
259
- path: string;
260
- label: string;
261
- };
262
- /** Allow an optional workspaceId field to omit the configured workspace filter. */
263
- allWorkspaces?: boolean;
264
- /**
265
- * Require `--yes`. The message should say what is about to be destroyed —
266
- * the point is that the caller can tell whether they meant it.
267
- */
268
- confirm?: string;
269
- /**
270
- * Discover table columns from inside this nested field as well as from the
271
- * row's own scalars.
272
- *
273
- * For rows whose real content sits in a wrapper the server chose — a table
274
- * row's user-defined cells live under `data` — the inferred columns would
275
- * otherwise be `id` and two timestamps, because a nested object cannot be a
276
- * column. Only meaningful when `columns` is absent.
277
- */
278
- expand?: string;
279
- /**
280
- * The response IS a document, not a record to look at.
281
- *
282
- * `workflows export` exists to be redirected into a file and fed back to
283
- * `import`, so a key/value view of it is wrong at any fidelity — the useful
284
- * artifact is the payload itself. Document commands emit raw JSON (or YAML
285
- * when the profile says so) whatever the profile's display format is.
286
- */
287
- document?: boolean;
288
- /** Keep the operation out of the CLI surface entirely. */
289
- hidden?: boolean;
290
- }
291
- /** The contract: operation name → how it appears in the terminal. */
292
- export type CliContract = Partial<Record<V2OperationName, CommandSpec>>;
@@ -1,83 +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
- stdout: EmbeddedOutput;
34
- stderr: EmbeddedOutput;
35
- /**
36
- * Reads bounded structured arguments from the caller's machine on demand.
37
- * The CLI owns path syntax; the host receives the resolved path without `@`.
38
- * An embedded invocation never falls back to the server's filesystem.
39
- */
40
- readFile?: (path: string) => Promise<string | Uint8Array>;
41
- /** File transfers use a snapshot; structured arguments use the separate bounded reader. */
42
- openFile?: (path: string) => Promise<EmbeddedFileSnapshot>;
43
- /**
44
- * Soft-fail exit code (a failed run outcome, `runs wait` timeout). Embedded
45
- * commands write here INSTEAD of process.exitCode: that global is shared, so
46
- * two parallel embedded invocations raced on it — one run could observe and
47
- * clear another's failure.
48
- */
49
- softExitCode?: number;
50
- /**
51
- * Where a download lands when embedded: the host writes to the caller's own machine
52
- * (through its file adapter), never to the server's disk. Resolves only after publication;
53
- * a refused or uncertain write throws. The host consumes or cancels the stream;
54
- * it must not buffer the complete download. Overwrite policy must hold atomically.
55
- */
56
- writeFile?: (path: string, content: ReadableStream<Uint8Array>, options: {
57
- overwrite: boolean;
58
- }) => Promise<void>;
59
- }
60
- /** The embedded-vs-standalone seam for soft-fail codes: context when embedded, global otherwise. */
61
- export declare function setSoftExitCode(code: number): void;
62
- export declare const embedStore: AsyncLocalStorage<EmbedContext>;
63
- /** Thrown in place of process.exit inside an embedded run. */
64
- export declare class EmbeddedExit extends Error {
65
- readonly code: number;
66
- constructor(code: number);
67
- }
68
- /**
69
- * The profile resolver consults this before touching env or config files: an
70
- * embedded run's identity comes entirely from the hosting server (it already
71
- * authenticated the caller and knows the workspace), never from profiles,
72
- * login state, or the host process env. Null outside an embedded run, which
73
- * keeps the installed CLI's behavior byte-identical.
74
- */
75
- export declare function embeddedProfile(): ResolvedProfile | null;
76
- /**
77
- * Output and process.exit shims, installed once, active only inside an embedded
78
- * run's async context. The CLI renders through console.log/error, commander and
79
- * chalk write straight to process.stdout/stderr, and a few commands exit
80
- * directly; all of it must land in the embed result instead of the host
81
- * server's stdout (or worse, the host process's lifetime).
82
- */
83
- export declare function installEmbedSinks(): void;
@@ -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
- }