@runinfra/sdk 0.1.3 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +210 -54
- package/README.md +324 -74
- package/dist/index.d.ts +565 -36
- package/dist/index.js +1103 -145
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,75 +3,231 @@
|
|
|
3
3
|
All notable changes to `@runinfra/sdk` are documented here. This project follows
|
|
4
4
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
5
|
|
|
6
|
+
## [0.3.2] - 2026-11-25
|
|
7
|
+
|
|
8
|
+
No change to the TypeScript SDK. The version moves with the Python SDK, whose standard transport now keeps its
|
|
9
|
+
connections open between calls.
|
|
10
|
+
|
|
11
|
+
## [0.3.1] - 2026-11-17
|
|
12
|
+
|
|
13
|
+
Read "Changed" before you upgrade. A stream now throws where it used to end
|
|
14
|
+
silently, the default timeouts are longer, and a call is no longer sent again
|
|
15
|
+
after a timeout.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **A stream throws where it used to end silently.** Iterating a
|
|
19
|
+
`RunInfraStream` throws `RunInfraStreamError` when the API reports a failure
|
|
20
|
+
on the open stream (a frame that holds an `error` object, or a
|
|
21
|
+
`response.failed` event on a Responses stream), and
|
|
22
|
+
`RunInfraStreamIncompleteError` when the body ends without its end marker
|
|
23
|
+
(`[DONE]` on a chat stream, `response.completed` on a Responses stream; an
|
|
24
|
+
empty or missing body counts, and so does a body that ends in the middle of
|
|
25
|
+
an event). Every event that came first is still yielded before the throw,
|
|
26
|
+
and leaving the loop early throws nothing. Before, both cases ended the loop
|
|
27
|
+
as if the answer were complete. Wrap the loop in `try`/`catch`, and keep a
|
|
28
|
+
partial answer only if it is useful to you.
|
|
29
|
+
- **A streamed call answered with JSON yields that answer once.** A streamed
|
|
30
|
+
call that repeats an `Idempotency-Key` the API has already answered gets one
|
|
31
|
+
JSON object back instead of an event stream (`Content-Type:
|
|
32
|
+
application/json`, `X-RunInfra-Idempotent-Replay: true`). The stream yields
|
|
33
|
+
that object once, marked `_idempotent_replay: true`, and ends quietly; it is
|
|
34
|
+
not reported as a cut stream. Any other successful answer that is JSON
|
|
35
|
+
instead of an event stream is yielded once in the same way, without the
|
|
36
|
+
mark. Before, such an answer ended the loop with no event. Check
|
|
37
|
+
`_idempotent_replay` on an event before you read deltas from it.
|
|
38
|
+
- **New default timeouts.** With no `timeoutMs`, a non-streamed call is given
|
|
39
|
+
750 seconds (was 120), and a streamed call 190 seconds to its response
|
|
40
|
+
headers and to each later read (was 120). The API allows a whole response up
|
|
41
|
+
to 740 seconds and a stream up to 180 seconds to its first token, and the old
|
|
42
|
+
default cut such calls off. A `timeoutMs` you set, on the client or on a
|
|
43
|
+
call, is used as before. A call that hangs now takes longer to fail unless
|
|
44
|
+
you set your own timeout.
|
|
45
|
+
- **On Node.js the built-in `fetch` still gives a non-streamed call at most
|
|
46
|
+
300 seconds to its response headers.** It gives up when no response headers
|
|
47
|
+
arrive within 300 seconds, whatever `timeoutMs` says, and a non-streamed
|
|
48
|
+
answer can keep its headers back until it is whole. Pass the client a
|
|
49
|
+
`fetch` that allows more, or stream an answer that may take longer.
|
|
50
|
+
- **No re-send after a timeout.** A call that runs out of time throws
|
|
51
|
+
`RunInfraTimeoutError` and is never sent again, whatever `maxRetries` says
|
|
52
|
+
and whether or not it carries an `idempotencyKey`. Before, a `GET` and a
|
|
53
|
+
keyed non-streamed call were sent again after the SDK's own timeout, while
|
|
54
|
+
the API could still be working on the first send. The error carries
|
|
55
|
+
`clientRequestId`, the `X-Client-Request-Id` the SDK sent. The runtime's
|
|
56
|
+
`fetch` giving up on the response headers or the body by its own clock, as
|
|
57
|
+
Node's does after 300 seconds, counts as a timeout too: it throws
|
|
58
|
+
`RunInfraTimeoutError` where it used to throw `RunInfraConnectionError`, and
|
|
59
|
+
the call is not sent again. A failure to connect is still a
|
|
60
|
+
`RunInfraConnectionError`, and a call that is safe to send again is still
|
|
61
|
+
sent again after one. A timeout while an open stream is read carries
|
|
62
|
+
`clientRequestId` too, and so does a timeout while the body of an audio
|
|
63
|
+
speech answer is read.
|
|
64
|
+
- **The retry rule follows what the API says.** Which calls may be sent again
|
|
65
|
+
has not changed: a `GET`, or a non-streamed chat, Responses or batch create
|
|
66
|
+
call that carries an `idempotencyKey`. For those calls:
|
|
67
|
+
- `x-should-retry` on the response and `error.retryable` in the error body
|
|
68
|
+
are obeyed. `false` stops the retry of a status that used to be retried.
|
|
69
|
+
`true` allows the retry of a status that used not to be.
|
|
70
|
+
- The wait is read from `Retry-After-Ms` first, then from `Retry-After`.
|
|
71
|
+
Before, `Retry-After-Ms` was not read.
|
|
72
|
+
- A `Retry-After` in whole seconds above 9007199254740991
|
|
73
|
+
(`Number.MAX_SAFE_INTEGER`) names no wait: the SDK's own backoff applies,
|
|
74
|
+
and `retryAfterMs` stays unset. So does a `Retry-After-Ms` with more
|
|
75
|
+
digits than a number can hold.
|
|
76
|
+
- A wait above 60 seconds is raised at once, with the wait on the error.
|
|
77
|
+
Before, the SDK slept a short backoff instead and sent the call again
|
|
78
|
+
sooner than the API asked. On a batch route the line stays 5 seconds for a
|
|
79
|
+
`503`, and a `409` stays final.
|
|
80
|
+
- The error body of a failed response is read before the SDK decides, where
|
|
81
|
+
it used to be dropped unread. Reading it counts against the call's timeout.
|
|
82
|
+
- **`retryAfterMs` is on every typed error whose response named a wait**,
|
|
83
|
+
whatever its status. Before, only `RateLimitError` and the batch routes'
|
|
84
|
+
refusals carried it. Code that reads `retryAfterMs === undefined` to tell a
|
|
85
|
+
rate limit from another error must test the class or the status instead.
|
|
86
|
+
- **`content` may be `null` in the types.** `ChatMessage.content` is now
|
|
87
|
+
`string | Array<...> | null` and may be left out, because an assistant
|
|
88
|
+
message that carries only tool calls has no content, and a stream delta's
|
|
89
|
+
`content` may be `null`. Code that passes `message.content` where a `string`
|
|
90
|
+
is required needs a check to compile. Nothing changes at run time.
|
|
91
|
+
- The package's homepage link points at the public TypeScript guide.
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
- `RunInfraStreamError` and `RunInfraStreamIncompleteError`, described above.
|
|
95
|
+
- `RunInfraError.retryable`: what the API said about asking again, when it
|
|
96
|
+
said it. `RunInfraError.clientRequestId`: set on a timeout.
|
|
97
|
+
- Chat request fields the API documents and the request type did not name:
|
|
98
|
+
`top_k`, `min_p`, `repetition_penalty`, `n`, `best_of`, `logit_bias`,
|
|
99
|
+
`parallel_tool_calls`, `reasoning_effort`, `reasoning`, `include_reasoning`,
|
|
100
|
+
`prompt_cache_key`, `service_tier`, `store`, `safety_identifier`,
|
|
101
|
+
`modalities`, `audio`, `prediction`, `verbosity`, `web_search_options`,
|
|
102
|
+
`moderation`, `functions`, and `function_call`. A request that names one is
|
|
103
|
+
no longer refused before it is sent. Each of them is still accepted in
|
|
104
|
+
`extraBody`, where it had to go before; naming one in both places is refused.
|
|
105
|
+
- Tool calls have a shape: `ChatMessage.tool_calls`
|
|
106
|
+
(`ChatCompletionMessageToolCall`), `ChatMessage.reasoning`, the `developer`
|
|
107
|
+
role, and `ChatToolMessage` for the message that answers a call by its
|
|
108
|
+
`tool_call_id`. On a stream, the delta types `tool_calls`
|
|
109
|
+
(`ChatCompletionStreamToolCallDelta`), `reasoning` and `role`, and each
|
|
110
|
+
choice types `index` and `finish_reason`.
|
|
111
|
+
|
|
112
|
+
## [0.3.0] - 2026-11-16
|
|
113
|
+
|
|
114
|
+
### Added
|
|
115
|
+
- `client.batches.create`, `client.batches.list`, `client.batches.retrieve`,
|
|
116
|
+
and `client.batches.cancel` for batch jobs, with the typed `BatchJob`,
|
|
117
|
+
`BatchJobDetail`, `BatchQuote`, and response envelopes. `create` sends
|
|
118
|
+
`idempotencyKey` as `Idempotency-Key`, is retried only when a key is given,
|
|
119
|
+
and never uses a default timeout below 30 seconds because the gateway tests
|
|
120
|
+
the destination before it answers.
|
|
121
|
+
- `verifyBatchDelivery` verifies a batch delivery posted to your own address
|
|
122
|
+
(Standard Webhooks signature over the raw body, compared in constant time)
|
|
123
|
+
and returns it as `BatchTestDelivery`, `BatchAnswerDelivery`, or
|
|
124
|
+
`BatchErrorDelivery`. The delivery's timestamp must be within 300 seconds of
|
|
125
|
+
the clock by default, so a captured delivery cannot be replayed later;
|
|
126
|
+
`toleranceSeconds` sets another tolerance and `toleranceSeconds: null` turns
|
|
127
|
+
the check off.
|
|
128
|
+
- Refusals of the batch routes are typed errors that keep the gateway's
|
|
129
|
+
`code`, `param`, and request id, plus `RunInfraError.reason` (the cause word
|
|
130
|
+
of `flex_not_available`) and `retryAfterMs` on every status that sends
|
|
131
|
+
`Retry-After`. A `409` from a batch route is a final refusal that is never
|
|
132
|
+
retried, and a `503` that asks for a wait above 5 seconds is raised at once
|
|
133
|
+
with that wait instead of being waited for. Errors and retries of every
|
|
134
|
+
other route are unchanged.
|
|
135
|
+
|
|
136
|
+
## [0.2.0] - 2026-06-15
|
|
137
|
+
|
|
138
|
+
### Added
|
|
139
|
+
- `InsufficientCreditsError` now exposes `currentBalanceCents`, `requiredCents`,
|
|
140
|
+
and `topupUrl` when the gateway includes them on a `402` response, so callers
|
|
141
|
+
can render a precise top-up prompt without parsing the message string.
|
|
142
|
+
|
|
143
|
+
### Changed
|
|
144
|
+
- `PermissionDeniedError.type` now preserves a specific gateway discriminator on
|
|
145
|
+
`403` responses (for example `byoc_plan_required` when a workspace below the
|
|
146
|
+
deploy tier calls a BYOC-deployed endpoint) instead of always reporting
|
|
147
|
+
`permission_denied`. Branch on `err.type` rather than scraping `err.message`.
|
|
148
|
+
|
|
149
|
+
## [0.1.5] - 2026-05-30
|
|
150
|
+
|
|
151
|
+
### Added
|
|
152
|
+
- Added examples for chat, Responses streaming, embeddings, model discovery,
|
|
153
|
+
and webhook verification.
|
|
154
|
+
- Clarified deployment requirements for image, audio, and co-located voice
|
|
155
|
+
pipeline helpers.
|
|
156
|
+
|
|
157
|
+
### Changed
|
|
158
|
+
- Clarified webhook helpers as local signature verification APIs. Webhook
|
|
159
|
+
delivery management remains outside the public SDK surface.
|
|
160
|
+
|
|
161
|
+
## [0.1.4] - 2026-05-23
|
|
162
|
+
|
|
163
|
+
### Added
|
|
164
|
+
- Added typed helpers for chat completions, Responses, embeddings, image
|
|
165
|
+
generation, text to speech, speech to text, model discovery, local webhook
|
|
166
|
+
signature verification, and co-located voice pipelines.
|
|
167
|
+
- Added OpenAI-style request fields for chat, Responses, embeddings, image
|
|
168
|
+
generation, TTS, and ASR helpers, including `extraBody` for deliberate JSON
|
|
169
|
+
gateway extensions.
|
|
170
|
+
- Added typed gateway errors for authentication, permissions, rate limits,
|
|
171
|
+
insufficient credits, deployment failures, missing models, timeouts,
|
|
172
|
+
connection failures, and malformed streams.
|
|
173
|
+
- Added request tracing through `X-Client-Request-Id`, response request IDs,
|
|
174
|
+
and idempotency keys for replay-safe chat and Responses requests.
|
|
175
|
+
|
|
176
|
+
### Changed
|
|
177
|
+
- Kept the public `client.webhooks` namespace focused on local signature
|
|
178
|
+
verification. Verification remains available through `verifySignature`,
|
|
179
|
+
`constructEvent`, `verifyWebhookSignature`, and `constructWebhookEvent`.
|
|
180
|
+
- Closed public request body types around supported fields so typos and
|
|
181
|
+
unsupported direct fields fail before a network request is sent.
|
|
182
|
+
- Closed ASR multipart requests around explicit file, filename, language,
|
|
183
|
+
prompt, temperature, and response-format fields.
|
|
184
|
+
- Documented the Responses helper as a chat-completions compatibility adapter
|
|
185
|
+
instead of full OpenAI Responses state.
|
|
186
|
+
- Kept charge-bearing retries conservative. Embeddings, images, streaming,
|
|
187
|
+
binary TTS, multipart ASR, and voice-pipeline requests are sent once even
|
|
188
|
+
when an idempotency key is provided.
|
|
189
|
+
|
|
190
|
+
### Security
|
|
191
|
+
- Hardened browser-runtime protection so secret API keys are not accepted in
|
|
192
|
+
public client bundles unless `dangerouslyAllowBrowser: true` is explicitly
|
|
193
|
+
set.
|
|
194
|
+
- Hardened API-key redaction in transport errors, response body errors, and
|
|
195
|
+
stream read errors.
|
|
196
|
+
- Limited the published package contents to the runtime SDK, type definitions,
|
|
197
|
+
README, changelog, license, and package metadata.
|
|
198
|
+
|
|
199
|
+
### Compatibility
|
|
200
|
+
- `UnsupportedOperationError` remains exported for older v0.1.x consumers, but
|
|
201
|
+
current public helpers do not raise it.
|
|
202
|
+
|
|
6
203
|
## [0.1.3] - 2026-05-23
|
|
7
204
|
|
|
8
205
|
### Security
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
browser worker runtimes unless explicitly allowed.
|
|
12
|
-
- Replaced trailing-slash URL regex normalization with a bounded loop to avoid
|
|
13
|
-
regex backtracking risk on adversarial base URLs.
|
|
206
|
+
- Improved server-side API key safeguards for browser-like runtimes.
|
|
207
|
+
- Improved custom base URL validation for untrusted input.
|
|
14
208
|
|
|
15
209
|
### Changed
|
|
16
|
-
-
|
|
17
|
-
dev requirements file, and pinned workflow actions to immutable commits.
|
|
18
|
-
- Made real publish dispatch default to dry-run and require an exact version
|
|
19
|
-
confirmation on `main`.
|
|
20
|
-
- Extended package verification to scan shipped files for source maps, local
|
|
21
|
-
machine paths, package tokens, private keys, and registry config leaks.
|
|
210
|
+
- Improved install consistency across the TypeScript and Python packages.
|
|
22
211
|
|
|
23
212
|
## [0.1.2] - 2026-05-23
|
|
24
213
|
|
|
25
214
|
### Changed
|
|
26
|
-
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
and long-lived registry-token regressions.
|
|
30
|
-
- Updated public docs to match the shipped voice pipeline helper: experimental,
|
|
31
|
-
pipeline-scoped, and not yet live-canary verified.
|
|
215
|
+
- Aligned TypeScript and Python package metadata for the same release.
|
|
216
|
+
- Clarified that the voice pipeline helper is a pipeline-scoped preview
|
|
217
|
+
surface.
|
|
32
218
|
|
|
33
219
|
## [0.1.1] - 2026-05-23
|
|
34
220
|
|
|
35
221
|
### Changed
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
222
|
+
- Used the proprietary license reference consistently across TypeScript and
|
|
223
|
+
Python packages.
|
|
224
|
+
- Updated repository and issue URLs to point at the public SDK repo.
|
|
225
|
+
- Clarified package status as beta while image and audio helpers remain
|
|
226
|
+
deployment-dependent preview surfaces.
|
|
40
227
|
|
|
41
228
|
### Added
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
- **`@experimental` JSDoc** on `client.images.*`, `client.audio.speech.*`, and
|
|
45
|
-
`client.audio.transcriptions.*` - these surfaces match the OpenAI HTTP
|
|
46
|
-
envelope but have not been verified end-to-end against a live deployed
|
|
47
|
-
pipeline in the public-gateway canary suite. Test against your own
|
|
48
|
-
deployments before using in production.
|
|
49
|
-
- This `CHANGELOG.md`.
|
|
50
|
-
|
|
51
|
-
### Provenance
|
|
52
|
-
This is the first release published via GitHub OIDC trusted publishing
|
|
53
|
-
(`.github/workflows/publish.yml` -> `npm` environment). The published
|
|
54
|
-
tarball includes a Sigstore-backed provenance attestation that ties the
|
|
55
|
-
release to a specific CI run. Verify with:
|
|
56
|
-
```bash
|
|
57
|
-
npm view @runinfra/sdk@0.1.1 dist.attestations
|
|
58
|
-
```
|
|
59
|
-
v0.1.0 was published from a local machine to bootstrap the Trusted Publisher
|
|
60
|
-
configuration and does not have provenance. All v0.1.1+ releases will.
|
|
61
|
-
|
|
62
|
-
### Known beta gaps
|
|
63
|
-
- Live-canary coverage is currently restricted to LLM + embeddings. Image,
|
|
64
|
-
TTS, and ASR surfaces are runnable but not yet verified end-to-end.
|
|
65
|
-
- Webhook delivery routes are not shipped; `client.webhooks.create` /
|
|
66
|
-
`.list()` throw `UnsupportedOperationError`. Local signature verification
|
|
67
|
-
(`verifySignature`, `constructEvent`) works.
|
|
68
|
-
- `client.voice.pipeline.create` posts audio to the pipeline-scoped `/pipeline` route.
|
|
69
|
-
It is experimental until live canary coverage is complete.
|
|
70
|
-
|
|
71
|
-
### Toward 1.0.0 GA
|
|
72
|
-
GA requires all 5 model modalities plus voice pipeline live-canary verified and
|
|
73
|
-
public-repo release gates that block stale, missing, or bypassed canary
|
|
74
|
-
evidence.
|
|
229
|
+
- Added the modality status section to the README.
|
|
230
|
+
- Added preview JSDoc annotations for deployment-dependent helpers.
|
|
75
231
|
|
|
76
232
|
## [0.1.0] - 2026-05-22
|
|
77
233
|
|