sim 2.1.17 → 2.1.18-dev.130.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 (75) hide show
  1. package/dist/auth/device-flow.d.ts +39 -0
  2. package/dist/auth/oauth-flow.d.ts +119 -0
  3. package/dist/auth/refresh.d.ts +16 -0
  4. package/dist/commands/auth.d.ts +5 -0
  5. package/dist/commands/configure.d.ts +2 -0
  6. package/dist/commands/credentials.d.ts +3 -0
  7. package/dist/commands/protocol/chat.d.ts +11 -0
  8. package/dist/commands/protocol/files-get.d.ts +25 -0
  9. package/dist/commands/protocol/files-upload.d.ts +2 -0
  10. package/dist/commands/protocol/index.d.ts +3 -0
  11. package/dist/commands/protocol/knowledge-document-upload.d.ts +2 -0
  12. package/dist/commands/protocol/knowledge-export.d.ts +14 -0
  13. package/dist/commands/protocol/logs-follow.d.ts +39 -0
  14. package/dist/commands/protocol/resource-directory.d.ts +24 -0
  15. package/dist/commands/protocol/result.d.ts +2 -0
  16. package/dist/commands/protocol/tables-import.d.ts +2 -0
  17. package/dist/commands/protocol/workflow-run-follow.d.ts +56 -0
  18. package/dist/commands/protocol/workflow-run-get.d.ts +15 -0
  19. package/dist/commands/protocol/workflow-run-wait.d.ts +3 -0
  20. package/dist/commands/protocol/workspace-operation-wait.d.ts +14 -0
  21. package/dist/commands/secrets.d.ts +3 -0
  22. package/dist/commands/telemetry.d.ts +2 -0
  23. package/dist/commands/update.d.ts +2 -0
  24. package/dist/config/index.d.ts +2 -0
  25. package/dist/config/ini.d.ts +111 -0
  26. package/dist/config/json-file.d.ts +18 -0
  27. package/dist/config/paths.d.ts +29 -0
  28. package/dist/config/profile.d.ts +210 -0
  29. package/dist/context.d.ts +21 -0
  30. package/dist/contract/commands.d.ts +14 -0
  31. package/dist/contract/types.d.ts +306 -0
  32. package/dist/embed-context.d.ts +77 -0
  33. package/dist/embed-output.d.ts +15 -0
  34. package/dist/embed.d.ts +39 -0
  35. package/dist/environment.d.ts +22 -0
  36. package/dist/generated/v2-api.d.ts +15057 -0
  37. package/dist/helpers.d.ts +9 -0
  38. package/dist/http/client.d.ts +173 -0
  39. package/dist/http/environment.d.ts +24 -0
  40. package/dist/http/ndjson.d.ts +5 -0
  41. package/dist/index.js +809 -327
  42. package/dist/output/io.d.ts +5 -0
  43. package/dist/output/presentation.d.ts +4 -0
  44. package/dist/output/render.d.ts +60 -0
  45. package/dist/output/terminal-text.d.ts +17 -0
  46. package/dist/output/trace.d.ts +3 -0
  47. package/dist/output/truncation.d.ts +3 -0
  48. package/dist/program.d.ts +21 -0
  49. package/dist/runtime/build.d.ts +38 -0
  50. package/dist/runtime/derive.d.ts +20 -0
  51. package/dist/runtime/execute.d.ts +32 -0
  52. package/dist/runtime/naming.d.ts +25 -0
  53. package/dist/runtime/options.d.ts +9 -0
  54. package/dist/runtime/renamed.d.ts +6 -0
  55. package/dist/runtime/request.d.ts +110 -0
  56. package/dist/runtime/result.d.ts +41 -0
  57. package/dist/runtime/types.d.ts +23 -0
  58. package/dist/runtime.d.ts +5 -0
  59. package/dist/runtime.js +21854 -0
  60. package/dist/telemetry/client-info.d.ts +20 -0
  61. package/dist/telemetry/coding-agent.d.ts +31 -0
  62. package/dist/telemetry/index.d.ts +4 -0
  63. package/dist/telemetry/invocation.d.ts +98 -0
  64. package/dist/telemetry/policy.d.ts +38 -0
  65. package/dist/telemetry/state.d.ts +47 -0
  66. package/dist/telemetry/transport.d.ts +47 -0
  67. package/dist/terminal/secret-input.d.ts +15 -0
  68. package/dist/terminal.d.ts +7 -0
  69. package/dist/transfer/local-file.d.ts +16 -0
  70. package/dist/transfer/streaming-upload.d.ts +16 -0
  71. package/dist/transfer/upload-session.d.ts +18 -0
  72. package/dist/update/check.d.ts +53 -0
  73. package/dist/update/install.d.ts +20 -0
  74. package/dist/version.d.ts +10 -0
  75. package/package.json +12 -2
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Local copies of the shared helpers.
3
+ *
4
+ * `@sim/utils` is a private workspace package, so the published `sim` package
5
+ * cannot depend on it — importing it would resolve in the monorepo and fail for
6
+ * anyone installing from npm.
7
+ */
8
+ /** Resolves after `ms` milliseconds. */
9
+ export declare function sleep(ms: number): Promise<void>;
@@ -0,0 +1,173 @@
1
+ import type { ResolvedProfile, StoredOAuthCredential } from '../config/index';
2
+ /**
3
+ * A failure the CLI can explain. Anything thrown as a `SimApiError` is printed
4
+ * as a clean message and a non-zero exit; anything else escapes as a stack
5
+ * trace, which is the signal that the CLI itself is broken rather than the
6
+ * request.
7
+ */
8
+ export declare class SimApiError extends Error {
9
+ readonly status: number;
10
+ readonly code: string | null;
11
+ readonly details?: unknown;
12
+ readonly exitCode: number;
13
+ constructor(message: string, status: number, code?: string | null, details?: unknown, exitCode?: number);
14
+ }
15
+ /** `{ data, nextCursor }` — one page of a list. */
16
+ export interface V2Page<T> {
17
+ data: T[];
18
+ nextCursor: string | null;
19
+ }
20
+ export interface RequestAllPagesOptions extends Omit<RequestOptions, 'query'> {
21
+ query?: Record<string, QueryValue>;
22
+ /** Server page size; callers choose one accepted by the endpoint contract. */
23
+ pageSize: number;
24
+ /** Maximum items to return. Omit to follow the cursor through the full list. */
25
+ limit?: number;
26
+ }
27
+ export type QueryValue = string | number | boolean | null | undefined;
28
+ export type AuthRequirement = 'required' | 'optional';
29
+ export interface RequestOptions {
30
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
31
+ query?: Record<string, QueryValue>;
32
+ body?: unknown;
33
+ /** Contract-declared headers, e.g. the `upload-token` a transfer is bound to. */
34
+ headers?: Record<string, string>;
35
+ /** Cancels both the initial request and any subsequent streaming body read. */
36
+ signal?: AbortSignal;
37
+ /** Self-hosted, auth-disabled routes may deliberately omit a local API key. */
38
+ auth?: AuthRequirement;
39
+ }
40
+ export interface WorkspaceOptions {
41
+ auth?: AuthRequirement;
42
+ }
43
+ /**
44
+ * Joins an endpoint and a route into a request URL.
45
+ *
46
+ * Concatenation rather than `new URL(path, endpoint)`, which is the trap it
47
+ * exists to avoid: a leading-slash path is absolute, so `new URL()` resolves it
48
+ * against the endpoint's ORIGIN and silently drops any path the endpoint
49
+ * carries. A deployment served under a prefix — `https://host/sim` behind a
50
+ * proxy that fronts several apps — would have every request rewritten to
51
+ * `https://host/...`, losing the prefix that identifies it.
52
+ *
53
+ * Empty values are skipped rather than sent blank so an omitted optional
54
+ * parameter reads as absent, not as the empty string.
55
+ */
56
+ export declare function buildUrl(endpoint: string, path: string, query?: Record<string, QueryValue>): string;
57
+ /**
58
+ * Statuses `fetch` would otherwise follow for us, and must not.
59
+ *
60
+ * A 301/302/303 is rewritten to a bodyless GET per the Fetch spec, so an
61
+ * endpoint that redirects (an apex host pointing at `www.`, say) keeps every
62
+ * read working through its query string while every write silently arrives with
63
+ * no body — the endpoint looks correct and only writes fail. Following a
64
+ * redirect would also hand the API key to whatever origin `Location` names.
65
+ */
66
+ export declare const REDIRECT_STATUSES: Set<number>;
67
+ /** The one instruction that resolves an elapsed request bound, wherever it surfaces. */
68
+ export declare const RAISE_TIMEOUT_HINT = "Raise SIM_TIMEOUT_SECONDS, or set it to 0 to wait indefinitely.";
69
+ /**
70
+ * Whether this is the CLI's own request bound elapsing.
71
+ *
72
+ * `AbortSignal.timeout` raises `TimeoutError`, while a caller's cancel raises
73
+ * `AbortError` — so this distinguishes a bound the user can raise from a stop
74
+ * the user asked for, which must keep reading as a cancellation.
75
+ */
76
+ export declare function isRequestTimeout(error: unknown): boolean;
77
+ /** Formats nested validation issues as readable, path-aware lines. */
78
+ export declare function formatApiErrorDetails(details: unknown): string[];
79
+ /**
80
+ * Renews an OAuth login and returns the new pair; injected so the HTTP client
81
+ * does not import the OAuth flow, which imports the client.
82
+ */
83
+ export type OAuthRefresher = (profile: ResolvedProfile, current: StoredOAuthCredential) => Promise<StoredOAuthCredential>;
84
+ export interface SimClientOptions {
85
+ refreshOAuth?: OAuthRefresher;
86
+ }
87
+ export declare class SimClient {
88
+ private readonly profile;
89
+ private readonly options;
90
+ private oauth;
91
+ private refreshing;
92
+ constructor(profile: ResolvedProfile, options?: SimClientOptions);
93
+ private resolveCredential;
94
+ /**
95
+ * One refresh at a time per process, shared by every request that finds the
96
+ * token expiring; the cross-process half lives behind the refresher.
97
+ */
98
+ private refreshOAuth;
99
+ /**
100
+ * The workspace every workspace-scoped command defaults to.
101
+ *
102
+ * By default this checks the key first even though it does not need one:
103
+ * commands resolve the workspace while building their query, so without this
104
+ * a brand-new install is told to set a workspace when the actual first step
105
+ * is logging in. Auth-disabled self-hosted protocols opt out explicitly.
106
+ */
107
+ requireWorkspace(explicit?: string, options?: WorkspaceOptions): string;
108
+ /**
109
+ * Makes a request without consuming its body. Authentication is required
110
+ * unless a self-hosted protocol explicitly opts out.
111
+ *
112
+ * JSON commands use {@link request}; streaming and binary protocols keep the
113
+ * raw response so they can process bytes incrementally. HTTP failures still
114
+ * become the same structured `SimApiError` either way.
115
+ */
116
+ requestRaw(path: string, options?: RequestOptions): Promise<Response>;
117
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
118
+ private send;
119
+ /**
120
+ * Explains a redirect instead of following it, naming the endpoint to switch to.
121
+ *
122
+ * The destination comes from `Location` resolved against the request URL, so a
123
+ * relative target works and no string surgery is done on the configured
124
+ * endpoint. A `Location` that is missing or unparseable still has to produce a
125
+ * sentence — the redirect is the finding either way.
126
+ */
127
+ private toRedirectError;
128
+ }
129
+ /**
130
+ * The endpoint a redirect implies, or null when it implies no change.
131
+ *
132
+ * Strips the request's own path from the target rather than taking
133
+ * `target.origin`, so a self-hosted endpoint carrying a path prefix
134
+ * (`https://host/sim`) keeps it. Naming the bare origin would hand back a value
135
+ * that is not an API root, and following that advice would break a deployment
136
+ * that was only ever one hostname away from working.
137
+ *
138
+ * Null when the target resolves to the endpoint already configured — a
139
+ * trailing-slash or path-normalization redirect keeps the origin, and telling
140
+ * someone to set the value they already have explains nothing.
141
+ */
142
+ export declare function redirectEndpoint(endpoint: string, requestPath: string, target: URL): string | null;
143
+ export interface PageProgress {
144
+ /** Call once a further page is known to be coming, with the count so far. */
145
+ advance: (fetched: number) => void;
146
+ /** Erases the line, if anything was ever written to it. */
147
+ finish: () => void;
148
+ }
149
+ /**
150
+ * Reports cursor progress on stderr while a list keeps paging.
151
+ *
152
+ * A long cursor is many sequential requests and reads as a hang, so say so — but
153
+ * only on a terminal, and only on stderr, because stdout is what gets piped to
154
+ * `jq`.
155
+ *
156
+ * Shared because the CLI pages in two places: {@link requestAllPages} for the
157
+ * `ls` commands, and the contract-driven loop in `runtime/execute`, which also
158
+ * has to carry a cursor in the body. Only one of them had the writer, and it was
159
+ * not the one nearly every `list --limit 0` goes through.
160
+ */
161
+ export declare function pageProgress(): PageProgress;
162
+ /** Rejects cursor cycles before a pager repeats requests or returns an unusable continuation. */
163
+ export declare function assertCursorAdvances(cursor: string | null, seenCursors: Set<string>): void;
164
+ /** Follows a standard v2 cursor envelope without duplicating pagination loops. */
165
+ export declare function requestAllPages<T>(client: Pick<SimClient, 'request'>, path: string, options: RequestAllPagesOptions): Promise<T[]>;
166
+ /**
167
+ * Substitutes `[id]`-style path segments.
168
+ *
169
+ * Values are percent-encoded: table and workspace ids are opaque, and a `/` or
170
+ * `?` inside one would otherwise silently retarget the request at a different
171
+ * endpoint.
172
+ */
173
+ export declare function resolvePath(template: string, params?: Record<string, string>): string;
@@ -0,0 +1,24 @@
1
+ /** Test seam: notices are once-per-process, and each test needs a clean slate. */
2
+ export declare function resetEnvironmentNotices(): void;
3
+ /**
4
+ * Reports a proxy the request will not actually go through.
5
+ *
6
+ * Node's `fetch` ignores `HTTP(S)_PROXY` unless `NODE_USE_ENV_PROXY` opts in,
7
+ * and older releases ignore them outright — so on a network that only reaches
8
+ * the API through a proxy, every command fails to connect while the variable
9
+ * that would have fixed it is already set. The CLI cannot enable the support
10
+ * from inside the process (Node reads the flag at startup), so it says what to
11
+ * do instead of proxying itself, which would mean bundling an HTTP stack for a
12
+ * setting the platform now owns.
13
+ */
14
+ export declare function warnIfProxyIgnored(env?: NodeJS.ProcessEnv, version?: string): void;
15
+ /**
16
+ * Reports an API key about to cross the network in cleartext.
17
+ *
18
+ * A warning rather than a refusal: `http://` is the documented way to reach a
19
+ * local dev server, and an internal deployment terminating TLS at a gateway is
20
+ * a real deployment, not a mistake to block. Loopback is silent because that is
21
+ * the documented case; anything else means the key is on the wire in the clear,
22
+ * which is worth one line.
23
+ */
24
+ export declare function warnIfCredentialOverCleartext(endpoint: string, hasCredential: boolean): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Parses a newline-delimited JSON response incrementally and releases its
3
+ * reader when the consumer reaches a terminal event or stops early.
4
+ */
5
+ export declare function readNdjson(body: ReadableStream<Uint8Array> | null, protocol: string): AsyncGenerator<unknown>;