sim 2.1.7 → 2.1.8-dev.94.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 (55) hide show
  1. package/README.md +1 -18
  2. package/dist/auth/device-flow.d.ts +38 -0
  3. package/dist/commands/auth.d.ts +5 -0
  4. package/dist/commands/configure.d.ts +2 -0
  5. package/dist/commands/credentials.d.ts +3 -0
  6. package/dist/commands/protocol/chat.d.ts +11 -0
  7. package/dist/commands/protocol/files-get.d.ts +25 -0
  8. package/dist/commands/protocol/files-upload.d.ts +2 -0
  9. package/dist/commands/protocol/index.d.ts +3 -0
  10. package/dist/commands/protocol/knowledge-document-upload.d.ts +2 -0
  11. package/dist/commands/protocol/logs-follow.d.ts +39 -0
  12. package/dist/commands/protocol/resource-directory.d.ts +24 -0
  13. package/dist/commands/protocol/result.d.ts +2 -0
  14. package/dist/commands/protocol/tables-import.d.ts +2 -0
  15. package/dist/commands/protocol/workflow-run-follow.d.ts +56 -0
  16. package/dist/commands/protocol/workflow-run-get.d.ts +15 -0
  17. package/dist/commands/protocol/workflow-run-wait.d.ts +3 -0
  18. package/dist/commands/secrets.d.ts +3 -0
  19. package/dist/config/index.d.ts +2 -0
  20. package/dist/config/ini.d.ts +111 -0
  21. package/dist/config/paths.d.ts +10 -0
  22. package/dist/config/profile.d.ts +158 -0
  23. package/dist/context.d.ts +21 -0
  24. package/dist/contract/commands.d.ts +14 -0
  25. package/dist/contract/types.d.ts +292 -0
  26. package/dist/embed-context.d.ts +83 -0
  27. package/dist/embed-output.d.ts +15 -0
  28. package/dist/generated/v2-api.d.ts +12969 -0
  29. package/dist/helpers.d.ts +9 -0
  30. package/dist/http/client.d.ts +166 -0
  31. package/dist/http/environment.d.ts +32 -0
  32. package/dist/index.js +895 -1115
  33. package/dist/output/presentation.d.ts +4 -0
  34. package/dist/output/render.d.ts +60 -0
  35. package/dist/output/terminal-text.d.ts +17 -0
  36. package/dist/output/trace.d.ts +3 -0
  37. package/dist/program.d.ts +21 -0
  38. package/dist/runtime/build.d.ts +38 -0
  39. package/dist/runtime/derive.d.ts +20 -0
  40. package/dist/runtime/execute.d.ts +30 -0
  41. package/dist/runtime/naming.d.ts +25 -0
  42. package/dist/runtime/options.d.ts +7 -0
  43. package/dist/runtime/renamed.d.ts +20 -0
  44. package/dist/runtime/request.d.ts +109 -0
  45. package/dist/runtime/result.d.ts +50 -0
  46. package/dist/runtime/types.d.ts +23 -0
  47. package/dist/runtime.d.ts +4 -0
  48. package/dist/runtime.js +16832 -0
  49. package/dist/terminal/secret-input.d.ts +15 -0
  50. package/dist/terminal.d.ts +6 -0
  51. package/dist/transfer/local-file.d.ts +16 -0
  52. package/dist/transfer/streaming-upload.d.ts +16 -0
  53. package/dist/transfer/upload-session.d.ts +18 -0
  54. package/dist/version.d.ts +10 -0
  55. package/package.json +15 -2
@@ -0,0 +1,4 @@
1
+ /** Embedded output is data; choose plain CLI styling without changing the host's Chalk. */
2
+ export declare function styles(): import("chalk").ChalkInstance;
3
+ /** A hosting server's terminal is never the embedded invocation's progress display. */
4
+ export declare function hasProgressTerminal(): boolean;
@@ -0,0 +1,60 @@
1
+ import type { OutputFormat } from '../config/index';
2
+ export interface Column<T> {
3
+ header: string;
4
+ value: (row: T) => string;
5
+ }
6
+ /**
7
+ * Removes terminal control sequences from a server-supplied string.
8
+ *
9
+ * Applied where API values become display text, so the colour the CLI adds
10
+ * afterwards still works — sanitizing the finished cell would strip our own
11
+ * formatting too.
12
+ */
13
+ export declare function sanitize(value: string): string;
14
+ /** Flattens untrusted terminal text into one compact, display-safe line. */
15
+ export declare function safeOneLine(value: string): string;
16
+ export declare function text(value: unknown): string;
17
+ /** ISO timestamps are the wire format everywhere; show them without the milliseconds. */
18
+ export declare function timestamp(value: string | null | undefined): string;
19
+ export declare function bool(value: boolean | null | undefined): string;
20
+ export declare function bytes(value: number | null | undefined): string;
21
+ export declare function duration(ms: number | null | undefined): string;
22
+ /**
23
+ * Visible width of a cell, ignoring ANSI colour codes.
24
+ *
25
+ * Padding on the raw string would count the escape sequences as characters and
26
+ * skew every coloured column, so widths are measured on the stripped text while
27
+ * the coloured text is what gets printed.
28
+ */
29
+ /**
30
+ * Visible width of a cell.
31
+ *
32
+ * Delegates to the grapheme-aware measurement: the previous implementation
33
+ * counted stripped string length, so emoji and East Asian characters measured
34
+ * as one column and mis-aligned every table containing them.
35
+ */
36
+ export declare function visibleWidth(value: string): number;
37
+ /**
38
+ * Prints a list in the profile's output format.
39
+ *
40
+ * `text` emits the table's cells tab-separated with no header and no colour —
41
+ * the shape `cut -f2` and `while read` expect. It uses the formatted cells
42
+ * rather than the raw values on purpose: it is a human-ish format for shell
43
+ * plumbing, and a raw ISO timestamp or byte count is worse in that context.
44
+ */
45
+ export declare function printList<T>(format: OutputFormat, rows: T[], columns: Column<T>[], raw?: unknown): void;
46
+ /**
47
+ * Prints a payload whose value IS the deliverable — `workflows export`, which
48
+ * is meant to be redirected to a file and fed back to `import`.
49
+ *
50
+ * `table` and `text` are display formats: they flatten, truncate and colour, so
51
+ * neither can round-trip a document. Rather than emit something that looks like
52
+ * an export but cannot be re-imported, those two fall back to JSON. Only `yaml`
53
+ * is honoured, because it round-trips.
54
+ */
55
+ export declare function printDocument(format: OutputFormat, raw: unknown): void;
56
+ /**
57
+ * Prints a single record: machine formats from the raw value, otherwise aligned
58
+ * lines. As in `printList`, only the `table` rendering is clamped.
59
+ */
60
+ export declare function printRecord(format: OutputFormat, fields: Array<[string, string]>, raw: unknown): void;
@@ -0,0 +1,17 @@
1
+ export declare function graphemes(value: string): Array<{
2
+ segment: string;
3
+ index: number;
4
+ }>;
5
+ /** First grapheme cluster of a string, or null when it is empty. */
6
+ export declare function firstGrapheme(value: string): string | null;
7
+ export declare function previousGraphemeIndex(value: string, cursor: number): number;
8
+ export declare function nextGraphemeIndex(value: string, cursor: number): number;
9
+ export declare function lineStart(value: string, cursor: number): number;
10
+ export declare function lineEnd(value: string, cursor: number): number;
11
+ export declare function displayWidth(value: string): number;
12
+ export declare function graphemeWidth(value: string): number;
13
+ export declare function isWideCodePoint(codePoint: number): boolean;
14
+ export declare function truncateDisplay(value: string, width: number): string;
15
+ export declare function tailToWidth(value: string, width: number): string;
16
+ /** Squares off a ragged art line so every box border starts at the same column. */
17
+ export declare function artPad(line: string, width: number): string;
@@ -0,0 +1,3 @@
1
+ import type { OutputFormat } from '../config/index';
2
+ /** Prints the complete recursive run trace for an explicitly expanded log. */
3
+ export declare function printTraceSpans(format: OutputFormat, traceSpans: unknown[]): void;
@@ -0,0 +1,21 @@
1
+ import { Command } from 'commander';
2
+ /** Root program description, shared by `--help` and the generated docs. */
3
+ export declare const PROGRAM_DESCRIPTION = "Talk to the Sim API from your terminal";
4
+ export declare const HELP_EPILOGUE = "\nProfiles work like the AWS CLI: settings live in ~/.sim/config, keys in\n~/.sim/credentials (0600), or under SIM_CONFIG_DIR when it is set. Select one\nwith -P, --profile, or SIM_PROFILE.\n\nWorkflow, knowledge-base and workspace IDs are bare UUIDs. Table IDs carry a\ntbl_ prefix and file IDs a wf_ one, so wf_ never names a workflow. An audit-log\nor custom-tool ID can open with a dash, which reads as a flag; put -- in front\nof it, as in sim audit-logs get -- -HlDcD1z76nK6R4crsUp0.\n\nExamples:\n $ sim login Authorize the default profile\n $ sim login --profile dev --endpoint http://localhost:3000\n $ sim profile add acme --workspace 7e2d9c14-6b83-4a55-8f01-c4d3e9a76b28\n $ sim workflows list\n $ sim logs list --level error --limit 20\n $ sim configure --set-output json Save a profile output default\n $ sim --output json tables get tbl_9f3c1a05d4b7426e8c2f0917ab35de64\n $ sim knowledge search --query \"refund policy\" --kb 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31\n $ sim workflows export 3a9e21d8-5f47-4c0b-b2ea-91d7c6034ef8 > wf.json\n $ sim workflows import --workflow @wf.json\n $ sim whoami --profile dev\n";
5
+ /**
6
+ * Assemble the complete command tree.
7
+ *
8
+ * Kept separate from the entrypoint so the documentation generator can walk the
9
+ * same tree the terminal parses. A generator that rebuilt the surface from the
10
+ * contract instead would be a second implementation of `buildGeneratedCommands`,
11
+ * free to drift from the one users actually run.
12
+ *
13
+ * `version` is optional because the generator reads the package metadata itself
14
+ * and the emitted pages must not carry a version that goes stale on every
15
+ * release.
16
+ */
17
+ export declare function buildProgram(options?: {
18
+ version?: boolean;
19
+ helpText?: string;
20
+ program?: Command;
21
+ }): Command;
@@ -0,0 +1,38 @@
1
+ import { Command } from 'commander';
2
+ import type { OperationSpec } from './types';
3
+ /**
4
+ * States the personal-key restriction the way every generated command states it.
5
+ *
6
+ * The suffix lives here, once, because a fully hand-written command renders its
7
+ * own `.description()` and never reaches the generated path — three commands
8
+ * (`secrets set`, `credentials create`, `credentials connect`/`reconnect`) sat
9
+ * beside siblings that carried the warning and silently read as accepting a
10
+ * workspace key. Taking the `OperationSpec` rather than a boolean means a
11
+ * caller has to name the operation it actually calls, so the two cannot drift.
12
+ */
13
+ export declare function describeOperation(operationSpec: OperationSpec, described: string): string;
14
+ /**
15
+ * Sweeps the assembled program for a flag the root already owns.
16
+ *
17
+ * `assertNoReservedFlags` runs while a generated leaf is configured, so it sees
18
+ * nothing that is attached by hand (`attachSecretCommands`,
19
+ * `attachProtocolCommands`, `attachCredentialCommands`) or added to a leaf
20
+ * after it is built. Walking the finished tree is what covers those.
21
+ */
22
+ export declare function assertNoReservedProgramFlags(program: Command): void;
23
+ /**
24
+ * Refuses `--help` typed after a command that does not exist.
25
+ *
26
+ * Commander answers a help flag before it looks at the operands, so `sim
27
+ * workspaces zzzz --help` printed the group's help and exited `0` while the
28
+ * same words without the flag exit `1`. A capability probe reading the exit
29
+ * code therefore concluded a command exists when it does not.
30
+ *
31
+ * Only pure dispatchers are guarded. A command that takes arguments or acts on
32
+ * its own (`sim files restore <fileId>`, `sim profiles`) legitimately sees an
33
+ * operand it did not register as a subcommand, and refusing there would break
34
+ * `--help` on argv the CLI accepts.
35
+ */
36
+ export declare function refuseHelpAfterUnknownCommand(program: Command): void;
37
+ /** Builds every JSON command described by the generated operation table. */
38
+ export declare function buildGeneratedCommands(): Command[];
@@ -0,0 +1,20 @@
1
+ import { type V2OperationName } from '../generated/v2-api';
2
+ /**
3
+ * Derives a command path from an operation's route.
4
+ *
5
+ * `<resource> [sub-resource] <verb>`, where the verb comes from the method and
6
+ * whether the path ends in a parameter (an item) or not (a collection). This
7
+ * covers 41 of the 47 operations; the rest are named in the CLI contract.
8
+ */
9
+ export declare function deriveCommandPath(operation: V2OperationName): string[];
10
+ /** `conflictTarget` → `conflict-target`. */
11
+ export declare function kebab(value: string): string;
12
+ /**
13
+ * `min-duration-ms` → `minDurationMs`, the key commander actually stores.
14
+ *
15
+ * Commander camelCases every multi-word flag when it builds its options object,
16
+ * so a lookup by the flag's own name finds nothing and the value is silently
17
+ * dropped — no error, the field just never reaches the API. Every read of a
18
+ * parsed flag has to go through this.
19
+ */
20
+ export declare function camel(flag: string): string;
@@ -0,0 +1,30 @@
1
+ import type { CommandSpec } from '../contract/types';
2
+ import type { V2OperationName } from '../generated/v2-api';
3
+ import type { OperationSpec } from './types';
4
+ /**
5
+ * Bulk operations that answer `200` even when they changed nothing.
6
+ *
7
+ * These endpoints are deliberately best-effort: they attempt every item, then
8
+ * report per-item outcomes in the payload. That is right for a partial
9
+ * success — some items really were deleted or moved — but a call that touched
10
+ * nothing at all is a failure the caller has to notice, and exiting `0` left
11
+ * `sim tables batch-delete --table-ids '["tbl_typo"]'` indistinguishable from a
12
+ * real deletion in a CI step.
13
+ *
14
+ * Only a total miss fails. A partial success still exits `0`: the payload names
15
+ * every item that did not make it, and failing the process there would break
16
+ * every caller that legitimately sweeps a list containing already-gone items.
17
+ */
18
+ /**
19
+ * Reads a bulk payload, and the request that produced it, for a total miss.
20
+ *
21
+ * The request is needed because not every bulk response reports the items it
22
+ * failed on: `bulkDeleteFiles` answers with a deleted count and nothing else,
23
+ * so the only place the number of items asked for exists is the body that was
24
+ * sent.
25
+ */
26
+ type BulkOutcomeCheck = (payload: Record<string, unknown>, body: Record<string, unknown> | undefined) => string | null;
27
+ export declare const BULK_OUTCOME_CHECKS: Readonly<Partial<Record<V2OperationName, BulkOutcomeCheck>>>;
28
+ /** Executes a parsed generated command, including cursor pagination. */
29
+ export declare function executeOperation(operation: V2OperationName, commandSpec: CommandSpec, operationSpec: OperationSpec, invocation: unknown[]): Promise<void>;
30
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { CommandSpec } from '../contract/types';
2
+ import type { V2OperationName } from '../generated/v2-api';
3
+ import type { OperationSpec } from './types';
4
+ /**
5
+ * The spelling a caller types for a wire field, or `null` when there is none.
6
+ *
7
+ * Resolved through the same helpers the command builder uses, never by
8
+ * kebab-casing the wire name: `folderPath` is typed `--folder` and
9
+ * `knowledgeBaseIds` is typed `--kb`, so a mechanical translation would name
10
+ * flags that do not exist — strictly worse than leaving the wire name alone.
11
+ */
12
+ export declare function spellingFor(operation: V2OperationName, commandSpec: CommandSpec, operationSpec: OperationSpec, field: string): string | null;
13
+ /**
14
+ * Restates a server validation error in the spellings the terminal accepts.
15
+ *
16
+ * The API names its own fields, correctly — `drop includeJobRuns` is right for
17
+ * an OpenAPI reader and untypeable here, where the flag is
18
+ * `--include-job-runs`. Applied at the one frame that still holds the
19
+ * operation, its command spec and its operation spec; by the time the error
20
+ * reaches the entrypoint that context is gone.
21
+ *
22
+ * A CLI-raised error (`status: 0`) is already phrased in flags and passes
23
+ * through untouched, as does anything that is not a `SimApiError`.
24
+ */
25
+ export declare function retypeApiError(error: unknown, operation: V2OperationName, commandSpec: CommandSpec, operationSpec: OperationSpec): unknown;
@@ -0,0 +1,7 @@
1
+ import { type Command } from 'commander';
2
+ import type { CommandSpec } from '../contract/types';
3
+ import type { V2OperationName } from '../generated/v2-api';
4
+ import type { OperationSpec } from './types';
5
+ export declare const DEFAULT_LIMIT = 100;
6
+ /** Adds request-field and safety options for one generated operation. */
7
+ export declare function addOperationOptions(command: Command, operation: V2OperationName, commandSpec: CommandSpec, operationSpec: OperationSpec): void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Support for spellings the CLI has moved on from.
3
+ *
4
+ * A rename is not an alias. {@link CommandSpec.aliases} are ergonomic shorthands
5
+ * — `ls`, `mv` — that the CLI wants people to use, so they appear in help. A
6
+ * renamed spelling is kept only so a script written against the old name keeps
7
+ * working: it stays out of help and out of the generated docs, and says once,
8
+ * on stderr, what to write instead.
9
+ *
10
+ * Warnings go to stderr rather than stdout because the old name is most likely
11
+ * to survive inside exactly the kind of script that pipes stdout into `jq`, and
12
+ * a deprecation notice in the middle of a JSON document is a worse bug than the
13
+ * one it reports.
14
+ */
15
+ /** Announces a command path that has been renamed, naming its current spelling. */
16
+ export declare function warnRenamedCommand(from: string, to: string): void;
17
+ /** Announces a flag that has been renamed, naming its current spelling. */
18
+ export declare function warnRenamedFlag(from: string, to: string): void;
19
+ /** Test seam: renames warn once per process, and each test needs a clean slate. */
20
+ export declare function resetRenameWarnings(): void;
@@ -0,0 +1,109 @@
1
+ import type { CommandSpec, FlagSpec } from '../contract/types';
2
+ import { type V2OperationName } from '../generated/v2-api';
3
+ import { type QueryValue } from '../http/client';
4
+ import type { OperationSpec } from './types';
5
+ /** One request field, as the generator describes it. */
6
+ export interface FieldSpec {
7
+ kind: 'string' | 'number' | 'integer' | 'boolean' | 'enum' | 'array' | 'object' | 'unknown';
8
+ required?: boolean;
9
+ values?: readonly string[];
10
+ default?: unknown;
11
+ /** The field's `.describe()` from the route contract, used as `--help` text. */
12
+ describe?: string;
13
+ }
14
+ /**
15
+ * The workspace never becomes a flag.
16
+ *
17
+ * It is the one field every workspace-scoped operation declares, and it comes
18
+ * from the profile — surfacing it as `--workspace-id` on 30-odd commands would
19
+ * duplicate the global `--workspace` and invite the two to disagree.
20
+ */
21
+ export declare const PROFILE_INJECTED_FIELD = "workspaceId";
22
+ /** Whether this path segment comes from the active profile's workspace. */
23
+ export declare function isProfileWorkspacePath(commandSpec: CommandSpec, param: string): boolean;
24
+ /**
25
+ * The slot a cursor-paginated operation carries its `cursor` field in.
26
+ *
27
+ * Pagination, not the name of a field, is what makes `limit` a page size. It
28
+ * lives here rather than beside its reader in `execute.ts` because `options.ts`
29
+ * has to ask the same question while it builds the flag, and importing
30
+ * `execute.ts` from `options.ts` would close a module cycle — `execute.ts`
31
+ * already reads `DEFAULT_LIMIT` from `options.ts`.
32
+ */
33
+ export declare function cursorSlot(operationSpec: Pick<OperationSpec, 'query' | 'body'>): 'query' | 'body' | null;
34
+ export declare function flagSpecFor(operation: V2OperationName, field: string): FlagSpec;
35
+ /**
36
+ * Long and short flags the root program has already claimed.
37
+ *
38
+ * Commander matches the root's own options across the whole of argv, including
39
+ * after a subcommand name, so a leaf that declares one of these never sees what
40
+ * the caller typed. The two failure modes differ only in how loud they are:
41
+ * `--version` and `--help` terminate, so `sim workflows rollback wf_1 --version
42
+ * 1` printed the CLI version and exited `0` without issuing a request; the
43
+ * root's value flags do not terminate, so a colliding leaf simply reads
44
+ * `undefined` and acts as though the flag were never typed.
45
+ */
46
+ export declare const RESERVED_PROGRAM_FLAGS: ReadonlySet<string>;
47
+ /** The flag name a field is exposed under, honouring any contract override. */
48
+ export declare function flagNameFor(operation: V2OperationName, field: string): string;
49
+ /** The named option used for a path parameter that is contextual rather than primary. */
50
+ export declare function pathFlagNameFor(commandSpec: CommandSpec, param: string): string;
51
+ export declare function takesJson(field: FieldSpec, flag: FlagSpec): boolean;
52
+ export declare function readArgumentSource(raw: string, flagName: string): Promise<{
53
+ text: string;
54
+ from: string;
55
+ }>;
56
+ /**
57
+ * Reads a primitive list from argv or a newline-delimited file.
58
+ *
59
+ * Exported for the one augmentation that has to read a list before the
60
+ * generated path does (`workflows runs get --select-output`), so a `@-` or
61
+ * `@path` source is read exactly once, by whichever of the two sees it first.
62
+ */
63
+ export declare function readListValues(raw: unknown, flagName: string): Promise<string[]>;
64
+ /**
65
+ * Rewrites one folder path into the API's canonical wire form.
66
+ *
67
+ * The wire form encodes each segment, so `/Folder 1` in the app is
68
+ * `/Folder%201` to the API — and typing the name you can see was rejected with
69
+ * a message that never said the word encoding. Splitting on `/` first is what
70
+ * keeps the separators: `encodeURIComponent` over the whole path would turn
71
+ * every one of them into `%2F` and address a single top-level folder whose name
72
+ * contains slashes.
73
+ *
74
+ * Decoding each segment before encoding it is what makes this idempotent, and
75
+ * it has to be: the encoded spelling is what the CLI prints today, what the
76
+ * README shows, and therefore what people will paste back. `/Folder 1` and
77
+ * `/Folder%201` must reach the same folder, and `%2520` is the failure to
78
+ * avoid. The limit of that rule is a folder whose name really contains a `%`
79
+ * followed by two hex digits — `100%20off` reads as `100 off`. A stray `%` is
80
+ * safe, because it fails to decode and is encoded literally, and the ambiguous
81
+ * name can always be typed in its encoded form (`100%2520off`).
82
+ */
83
+ export declare function encodeFolderPath(value: string): string;
84
+ /**
85
+ * Turns the string argv provides into the value the contract expects.
86
+ *
87
+ * Every failure names the flag rather than the field, because the flag is what
88
+ * the caller typed — and every one of these is caught before any request is
89
+ * made, so a typo costs nothing.
90
+ */
91
+ export declare function coerce(raw: unknown, field: FieldSpec, flag: FlagSpec, flagName: string): Promise<unknown>;
92
+ export interface BuiltRequest {
93
+ path: string;
94
+ query: Record<string, QueryValue>;
95
+ body: Record<string, unknown> | undefined;
96
+ /** Contract-declared request headers, absent when the operation declares none. */
97
+ headers?: Record<string, string>;
98
+ }
99
+ /**
100
+ * Assembles one operation's HTTP request from positional args, parsed flags,
101
+ * and the profile's workspace.
102
+ *
103
+ * Primary path params come from positional arguments in declared order. A
104
+ * contextual path param can instead come from a named option declared by the
105
+ * CLI contract. Every other field is looked up by its flag name in the slot the
106
+ * API contract declares it in, so a field that moved from query to body moves
107
+ * here on the next regeneration.
108
+ */
109
+ export declare function buildRequest(operation: V2OperationName, positional: string[], flags: Record<string, unknown>, workspaceId: string | null): Promise<BuiltRequest>;
@@ -0,0 +1,50 @@
1
+ import type { OutputFormat } from '../config/index';
2
+ import type { CommandSpec } from '../contract/types';
3
+ import type { V2OperationName } from '../generated/v2-api';
4
+ interface RenderResultOptions {
5
+ expandedTrace?: boolean;
6
+ }
7
+ /**
8
+ * Undoes the wire encoding of a folder path for the human formats.
9
+ *
10
+ * The inverse of `encodeFolderPath`, per segment for the same reason: `%2F` is
11
+ * a slash inside one folder's name, not a separator. A segment that fails to
12
+ * decode is shown as it arrived rather than dropped — the point is to show the
13
+ * name, and a malformed one is still the truth about what the server holds.
14
+ *
15
+ * A segment whose decoded name contains the separator is shown in wire form for
16
+ * the same reason: decoding it would print a root folder named `a/b` as
17
+ * `/a/b`, byte-identical to a folder `b` nested under `a` — and the printed
18
+ * path is what people paste back, so `folders delete` addressed the other
19
+ * folder. Rendering must not manufacture structure that is not there.
20
+ *
21
+ * Callers must reach this only from a `table` or `text` rendering path — the
22
+ * hand-written `ls` builds its own columns and so decodes through here directly.
23
+ * `json` and `yaml` render from the raw payload so that switching format never
24
+ * changes the data, and a script piping a path back needs the wire form.
25
+ */
26
+ export declare function decodeFolderPath(value: string): string;
27
+ export declare function renderPage(format: OutputFormat, rows: unknown[], spec: CommandSpec, envelope?: unknown, options?: {
28
+ truncated?: boolean;
29
+ }): void;
30
+ /**
31
+ * Carries a truncation stated on any page, not only the first.
32
+ *
33
+ * The envelope is otherwise the first page's, because a fact about the whole
34
+ * query (billing's `scope`) is stated once — but `toolNamesTruncated` is
35
+ * computed per page, so a walk that clipped on page 7 would have said nothing.
36
+ */
37
+ export declare function foldPageEnvelope(current: unknown, page: unknown): unknown;
38
+ /**
39
+ * States that the walk stopped at `--limit` while more pages remained.
40
+ *
41
+ * `sim tools list` answered 100 of 4708 rows with an exit code of 0 and nothing
42
+ * on stderr, in every format — indistinguishable from a complete inventory.
43
+ * Said whenever a cursor survives, including when the caller set a small limit:
44
+ * the answer is incomplete either way, and the caller who capped it is the one
45
+ * most likely to reuse the result as if it were whole.
46
+ */
47
+ export declare function writeCursorTruncation(count: number, truncated: boolean): void;
48
+ /** Renders one non-paginated operation result according to its CLI contract. */
49
+ export declare function renderResult(operation: V2OperationName, format: OutputFormat, raw: unknown, spec: CommandSpec, options?: RenderResultOptions, envelope?: unknown): void;
50
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { RequestOptions } from '../http/client';
2
+ import type { FieldSpec } from './request';
3
+ export interface OperationSpec {
4
+ method: NonNullable<RequestOptions['method']>;
5
+ path: string;
6
+ pathParams: readonly string[];
7
+ /** `.describe()` per path parameter, used as positional-argument help. */
8
+ pathParamDocs?: Record<string, string>;
9
+ query?: Record<string, FieldSpec>;
10
+ body?: Record<string, FieldSpec>;
11
+ /** Contract-declared request headers, minus any the CLI sets itself. */
12
+ headers?: Record<string, FieldSpec>;
13
+ opaqueBody?: boolean;
14
+ summary?: string;
15
+ /**
16
+ * The operation rejects a workspace API key; only a personal one works.
17
+ *
18
+ * Emitted by `scripts/generate-v2-cli-api.ts` from the OpenAPI description so
19
+ * `--help` states the restriction the caller would otherwise meet as a `403`.
20
+ */
21
+ personalKeyOnly?: true;
22
+ responseMode?: 'json' | 'binary' | 'stream';
23
+ }
@@ -0,0 +1,4 @@
1
+ export { Command } from 'commander';
2
+ export { SimApiError } from './http/client';
3
+ export { buildProgram } from './program';
4
+ export { runTerminalCli } from './terminal';