@opencode-ai/sdk 0.1.0-alpha.9 → 0.3.101
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/{internal/utils.d.mts.map → dist/gen/client/client.d.ts} +2 -1
- package/dist/gen/client/client.js +145 -0
- package/dist/gen/client/index.d.ts +7 -0
- package/dist/gen/client/index.js +4 -0
- package/dist/gen/client/types.d.ts +119 -0
- package/dist/gen/client/types.js +0 -0
- package/dist/gen/client/utils.d.ts +45 -0
- package/dist/gen/client/utils.js +284 -0
- package/dist/gen/client.gen.d.ts +12 -0
- package/dist/gen/client.gen.js +5 -0
- package/dist/gen/core/auth.d.ts +18 -0
- package/dist/gen/core/auth.js +13 -0
- package/dist/gen/core/bodySerializer.d.ts +17 -0
- package/dist/gen/core/bodySerializer.js +53 -0
- package/dist/gen/core/params.d.ts +33 -0
- package/dist/gen/core/params.js +87 -0
- package/dist/gen/core/pathSerializer.d.ts +33 -0
- package/dist/gen/core/pathSerializer.js +113 -0
- package/dist/gen/core/types.d.ts +78 -0
- package/dist/gen/core/types.js +0 -0
- package/dist/gen/sdk.gen.d.ts +149 -0
- package/dist/gen/sdk.gen.js +291 -0
- package/dist/gen/types.gen.d.ts +1308 -0
- package/dist/gen/types.gen.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -0
- package/package.json +12 -134
- package/CHANGELOG.md +0 -80
- package/LICENSE +0 -201
- package/README.md +0 -352
- package/api-promise.d.mts +0 -2
- package/api-promise.d.mts.map +0 -1
- package/api-promise.d.ts +0 -2
- package/api-promise.d.ts.map +0 -1
- package/api-promise.js +0 -6
- package/api-promise.js.map +0 -1
- package/api-promise.mjs +0 -2
- package/api-promise.mjs.map +0 -1
- package/client.d.mts +0 -185
- package/client.d.mts.map +0 -1
- package/client.d.ts +0 -185
- package/client.d.ts.map +0 -1
- package/client.js +0 -459
- package/client.js.map +0 -1
- package/client.mjs +0 -455
- package/client.mjs.map +0 -1
- package/core/api-promise.d.mts +0 -46
- package/core/api-promise.d.mts.map +0 -1
- package/core/api-promise.d.ts +0 -46
- package/core/api-promise.d.ts.map +0 -1
- package/core/api-promise.js +0 -74
- package/core/api-promise.js.map +0 -1
- package/core/api-promise.mjs +0 -70
- package/core/api-promise.mjs.map +0 -1
- package/core/error.d.mts +0 -46
- package/core/error.d.mts.map +0 -1
- package/core/error.d.ts +0 -46
- package/core/error.d.ts.map +0 -1
- package/core/error.js +0 -113
- package/core/error.js.map +0 -1
- package/core/error.mjs +0 -97
- package/core/error.mjs.map +0 -1
- package/core/resource.d.mts +0 -6
- package/core/resource.d.mts.map +0 -1
- package/core/resource.d.ts +0 -6
- package/core/resource.d.ts.map +0 -1
- package/core/resource.js +0 -11
- package/core/resource.js.map +0 -1
- package/core/resource.mjs +0 -7
- package/core/resource.mjs.map +0 -1
- package/core/uploads.d.mts +0 -3
- package/core/uploads.d.mts.map +0 -1
- package/core/uploads.d.ts +0 -3
- package/core/uploads.d.ts.map +0 -1
- package/core/uploads.js +0 -6
- package/core/uploads.js.map +0 -1
- package/core/uploads.mjs +0 -2
- package/core/uploads.mjs.map +0 -1
- package/error.d.mts +0 -2
- package/error.d.mts.map +0 -1
- package/error.d.ts +0 -2
- package/error.d.ts.map +0 -1
- package/error.js +0 -6
- package/error.js.map +0 -1
- package/error.mjs +0 -2
- package/error.mjs.map +0 -1
- package/index.d.mts +0 -6
- package/index.d.mts.map +0 -1
- package/index.d.ts +0 -6
- package/index.d.ts.map +0 -1
- package/index.js +0 -30
- package/index.js.map +0 -1
- package/index.mjs +0 -7
- package/index.mjs.map +0 -1
- package/internal/builtin-types.d.mts +0 -73
- package/internal/builtin-types.d.mts.map +0 -1
- package/internal/builtin-types.d.ts +0 -73
- package/internal/builtin-types.d.ts.map +0 -1
- package/internal/builtin-types.js +0 -4
- package/internal/builtin-types.js.map +0 -1
- package/internal/builtin-types.mjs +0 -3
- package/internal/builtin-types.mjs.map +0 -1
- package/internal/detect-platform.d.mts +0 -15
- package/internal/detect-platform.d.mts.map +0 -1
- package/internal/detect-platform.d.ts +0 -15
- package/internal/detect-platform.d.ts.map +0 -1
- package/internal/detect-platform.js +0 -162
- package/internal/detect-platform.js.map +0 -1
- package/internal/detect-platform.mjs +0 -157
- package/internal/detect-platform.mjs.map +0 -1
- package/internal/errors.d.mts +0 -3
- package/internal/errors.d.mts.map +0 -1
- package/internal/errors.d.ts +0 -3
- package/internal/errors.d.ts.map +0 -1
- package/internal/errors.js +0 -41
- package/internal/errors.js.map +0 -1
- package/internal/errors.mjs +0 -36
- package/internal/errors.mjs.map +0 -1
- package/internal/headers.d.mts +0 -20
- package/internal/headers.d.mts.map +0 -1
- package/internal/headers.d.ts +0 -20
- package/internal/headers.d.ts.map +0 -1
- package/internal/headers.js +0 -79
- package/internal/headers.js.map +0 -1
- package/internal/headers.mjs +0 -74
- package/internal/headers.mjs.map +0 -1
- package/internal/parse.d.mts +0 -12
- package/internal/parse.d.mts.map +0 -1
- package/internal/parse.d.ts +0 -12
- package/internal/parse.d.ts.map +0 -1
- package/internal/parse.js +0 -35
- package/internal/parse.js.map +0 -1
- package/internal/parse.mjs +0 -32
- package/internal/parse.mjs.map +0 -1
- package/internal/request-options.d.mts +0 -33
- package/internal/request-options.d.mts.map +0 -1
- package/internal/request-options.d.ts +0 -33
- package/internal/request-options.d.ts.map +0 -1
- package/internal/request-options.js +0 -14
- package/internal/request-options.js.map +0 -1
- package/internal/request-options.mjs +0 -10
- package/internal/request-options.mjs.map +0 -1
- package/internal/shim-types.d.mts +0 -17
- package/internal/shim-types.d.mts.map +0 -1
- package/internal/shim-types.d.ts +0 -17
- package/internal/shim-types.d.ts.map +0 -1
- package/internal/shim-types.js +0 -4
- package/internal/shim-types.js.map +0 -1
- package/internal/shim-types.mjs +0 -3
- package/internal/shim-types.mjs.map +0 -1
- package/internal/shims.d.mts +0 -20
- package/internal/shims.d.mts.map +0 -1
- package/internal/shims.d.ts +0 -20
- package/internal/shims.d.ts.map +0 -1
- package/internal/shims.js +0 -92
- package/internal/shims.js.map +0 -1
- package/internal/shims.mjs +0 -85
- package/internal/shims.mjs.map +0 -1
- package/internal/to-file.d.mts +0 -45
- package/internal/to-file.d.mts.map +0 -1
- package/internal/to-file.d.ts +0 -45
- package/internal/to-file.d.ts.map +0 -1
- package/internal/to-file.js +0 -91
- package/internal/to-file.js.map +0 -1
- package/internal/to-file.mjs +0 -88
- package/internal/to-file.mjs.map +0 -1
- package/internal/tslib.js +0 -81
- package/internal/tslib.mjs +0 -17
- package/internal/types.d.mts +0 -69
- package/internal/types.d.mts.map +0 -1
- package/internal/types.d.ts +0 -69
- package/internal/types.d.ts.map +0 -1
- package/internal/types.js +0 -4
- package/internal/types.js.map +0 -1
- package/internal/types.mjs +0 -3
- package/internal/types.mjs.map +0 -1
- package/internal/uploads.d.mts +0 -42
- package/internal/uploads.d.mts.map +0 -1
- package/internal/uploads.d.ts +0 -42
- package/internal/uploads.d.ts.map +0 -1
- package/internal/uploads.js +0 -141
- package/internal/uploads.js.map +0 -1
- package/internal/uploads.mjs +0 -131
- package/internal/uploads.mjs.map +0 -1
- package/internal/utils/base64.d.mts +0 -3
- package/internal/utils/base64.d.mts.map +0 -1
- package/internal/utils/base64.d.ts +0 -3
- package/internal/utils/base64.d.ts.map +0 -1
- package/internal/utils/base64.js +0 -38
- package/internal/utils/base64.js.map +0 -1
- package/internal/utils/base64.mjs +0 -33
- package/internal/utils/base64.mjs.map +0 -1
- package/internal/utils/bytes.d.mts +0 -4
- package/internal/utils/bytes.d.mts.map +0 -1
- package/internal/utils/bytes.d.ts +0 -4
- package/internal/utils/bytes.d.ts.map +0 -1
- package/internal/utils/bytes.js +0 -31
- package/internal/utils/bytes.js.map +0 -1
- package/internal/utils/bytes.mjs +0 -26
- package/internal/utils/bytes.mjs.map +0 -1
- package/internal/utils/env.d.mts +0 -9
- package/internal/utils/env.d.mts.map +0 -1
- package/internal/utils/env.d.ts +0 -9
- package/internal/utils/env.d.ts.map +0 -1
- package/internal/utils/env.js +0 -22
- package/internal/utils/env.js.map +0 -1
- package/internal/utils/env.mjs +0 -18
- package/internal/utils/env.mjs.map +0 -1
- package/internal/utils/log.d.mts +0 -37
- package/internal/utils/log.d.mts.map +0 -1
- package/internal/utils/log.d.ts +0 -37
- package/internal/utils/log.d.ts.map +0 -1
- package/internal/utils/log.js +0 -85
- package/internal/utils/log.js.map +0 -1
- package/internal/utils/log.mjs +0 -79
- package/internal/utils/log.mjs.map +0 -1
- package/internal/utils/path.d.mts +0 -15
- package/internal/utils/path.d.mts.map +0 -1
- package/internal/utils/path.d.ts +0 -15
- package/internal/utils/path.d.ts.map +0 -1
- package/internal/utils/path.js +0 -58
- package/internal/utils/path.js.map +0 -1
- package/internal/utils/path.mjs +0 -53
- package/internal/utils/path.mjs.map +0 -1
- package/internal/utils/sleep.d.mts +0 -2
- package/internal/utils/sleep.d.mts.map +0 -1
- package/internal/utils/sleep.d.ts +0 -2
- package/internal/utils/sleep.d.ts.map +0 -1
- package/internal/utils/sleep.js +0 -7
- package/internal/utils/sleep.js.map +0 -1
- package/internal/utils/sleep.mjs +0 -3
- package/internal/utils/sleep.mjs.map +0 -1
- package/internal/utils/uuid.d.mts +0 -5
- package/internal/utils/uuid.d.mts.map +0 -1
- package/internal/utils/uuid.d.ts +0 -5
- package/internal/utils/uuid.d.ts.map +0 -1
- package/internal/utils/uuid.js +0 -19
- package/internal/utils/uuid.js.map +0 -1
- package/internal/utils/uuid.mjs +0 -15
- package/internal/utils/uuid.mjs.map +0 -1
- package/internal/utils/values.d.mts +0 -18
- package/internal/utils/values.d.mts.map +0 -1
- package/internal/utils/values.d.ts +0 -18
- package/internal/utils/values.d.ts.map +0 -1
- package/internal/utils/values.js +0 -112
- package/internal/utils/values.js.map +0 -1
- package/internal/utils/values.mjs +0 -94
- package/internal/utils/values.mjs.map +0 -1
- package/internal/utils.d.mts +0 -7
- package/internal/utils.d.ts +0 -7
- package/internal/utils.d.ts.map +0 -1
- package/internal/utils.js +0 -11
- package/internal/utils.js.map +0 -1
- package/internal/utils.mjs +0 -8
- package/internal/utils.mjs.map +0 -1
- package/resource.d.mts +0 -2
- package/resource.d.mts.map +0 -1
- package/resource.d.ts +0 -2
- package/resource.d.ts.map +0 -1
- package/resource.js +0 -6
- package/resource.js.map +0 -1
- package/resource.mjs +0 -2
- package/resource.mjs.map +0 -1
- package/resources/app.d.mts +0 -38
- package/resources/app.d.mts.map +0 -1
- package/resources/app.d.ts +0 -38
- package/resources/app.d.ts.map +0 -1
- package/resources/app.js +0 -21
- package/resources/app.js.map +0 -1
- package/resources/app.mjs +0 -17
- package/resources/app.mjs.map +0 -1
- package/resources/config.d.mts +0 -304
- package/resources/config.d.mts.map +0 -1
- package/resources/config.d.ts +0 -304
- package/resources/config.d.ts.map +0 -1
- package/resources/config.js +0 -21
- package/resources/config.js.map +0 -1
- package/resources/config.mjs +0 -17
- package/resources/config.mjs.map +0 -1
- package/resources/event.d.mts +0 -120
- package/resources/event.d.mts.map +0 -1
- package/resources/event.d.ts +0 -120
- package/resources/event.d.ts.map +0 -1
- package/resources/event.js +0 -15
- package/resources/event.js.map +0 -1
- package/resources/event.mjs +0 -11
- package/resources/event.mjs.map +0 -1
- package/resources/file.d.mts +0 -17
- package/resources/file.d.mts.map +0 -1
- package/resources/file.d.ts +0 -17
- package/resources/file.d.ts.map +0 -1
- package/resources/file.js +0 -15
- package/resources/file.js.map +0 -1
- package/resources/file.mjs +0 -11
- package/resources/file.mjs.map +0 -1
- package/resources/index.d.mts +0 -7
- package/resources/index.d.mts.map +0 -1
- package/resources/index.d.ts +0 -7
- package/resources/index.d.ts.map +0 -1
- package/resources/index.js +0 -17
- package/resources/index.js.map +0 -1
- package/resources/index.mjs +0 -8
- package/resources/index.mjs.map +0 -1
- package/resources/session.d.mts +0 -207
- package/resources/session.d.mts.map +0 -1
- package/resources/session.d.ts +0 -207
- package/resources/session.d.ts.map +0 -1
- package/resources/session.js +0 -70
- package/resources/session.js.map +0 -1
- package/resources/session.mjs +0 -66
- package/resources/session.mjs.map +0 -1
- package/resources/shared.d.mts +0 -20
- package/resources/shared.d.mts.map +0 -1
- package/resources/shared.d.ts +0 -20
- package/resources/shared.d.ts.map +0 -1
- package/resources/shared.js +0 -4
- package/resources/shared.js.map +0 -1
- package/resources/shared.mjs +0 -3
- package/resources/shared.mjs.map +0 -1
- package/resources.d.mts +0 -2
- package/resources.d.mts.map +0 -1
- package/resources.d.ts +0 -2
- package/resources.d.ts.map +0 -1
- package/resources.js +0 -5
- package/resources.js.map +0 -1
- package/resources.mjs +0 -2
- package/resources.mjs.map +0 -1
- package/src/api-promise.ts +0 -2
- package/src/client.ts +0 -783
- package/src/core/README.md +0 -3
- package/src/core/api-promise.ts +0 -92
- package/src/core/error.ts +0 -130
- package/src/core/resource.ts +0 -11
- package/src/core/uploads.ts +0 -2
- package/src/error.ts +0 -2
- package/src/index.ts +0 -22
- package/src/internal/README.md +0 -3
- package/src/internal/builtin-types.ts +0 -93
- package/src/internal/detect-platform.ts +0 -196
- package/src/internal/errors.ts +0 -33
- package/src/internal/headers.ts +0 -97
- package/src/internal/parse.ts +0 -50
- package/src/internal/request-options.ts +0 -38
- package/src/internal/shim-types.ts +0 -26
- package/src/internal/shims.ts +0 -107
- package/src/internal/to-file.ts +0 -154
- package/src/internal/types.ts +0 -95
- package/src/internal/uploads.ts +0 -187
- package/src/internal/utils/base64.ts +0 -40
- package/src/internal/utils/bytes.ts +0 -32
- package/src/internal/utils/env.ts +0 -18
- package/src/internal/utils/log.ts +0 -126
- package/src/internal/utils/path.ts +0 -63
- package/src/internal/utils/sleep.ts +0 -3
- package/src/internal/utils/uuid.ts +0 -17
- package/src/internal/utils/values.ts +0 -105
- package/src/internal/utils.ts +0 -8
- package/src/lib/.keep +0 -4
- package/src/resource.ts +0 -2
- package/src/resources/app.ts +0 -59
- package/src/resources/config.ts +0 -390
- package/src/resources/event.ts +0 -171
- package/src/resources/file.ts +0 -24
- package/src/resources/index.ts +0 -40
- package/src/resources/session.ts +0 -355
- package/src/resources/shared.ts +0 -27
- package/src/resources.ts +0 -1
- package/src/tsconfig.json +0 -11
- package/src/uploads.ts +0 -2
- package/src/version.ts +0 -1
- package/uploads.d.mts +0 -2
- package/uploads.d.mts.map +0 -1
- package/uploads.d.ts +0 -2
- package/uploads.d.ts.map +0 -1
- package/uploads.js +0 -6
- package/uploads.js.map +0 -1
- package/uploads.mjs +0 -2
- package/uploads.mjs.map +0 -1
- package/version.d.mts +0 -2
- package/version.d.mts.map +0 -1
- package/version.d.ts +0 -2
- package/version.d.ts.map +0 -1
- package/version.js +0 -5
- package/version.js.map +0 -1
- package/version.mjs +0 -2
- package/version.mjs.map +0 -1
package/client.d.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import type { RequestInit, RequestInfo } from "./internal/builtin-types.js";
|
|
2
|
-
import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.js";
|
|
3
|
-
export type { Logger, LogLevel } from "./internal/utils/log.js";
|
|
4
|
-
import * as Opts from "./internal/request-options.js";
|
|
5
|
-
import * as Errors from "./core/error.js";
|
|
6
|
-
import * as Uploads from "./core/uploads.js";
|
|
7
|
-
import * as API from "./resources/index.js";
|
|
8
|
-
import { APIPromise } from "./core/api-promise.js";
|
|
9
|
-
import { App, AppInitResponse, AppResource } from "./resources/app.js";
|
|
10
|
-
import { Config, ConfigProvidersResponse, ConfigResource, Keybinds, McpLocal, McpRemote, Model, Provider } from "./resources/config.js";
|
|
11
|
-
import { Event, EventListResponse } from "./resources/event.js";
|
|
12
|
-
import { File, FileSearchParams, FileSearchResponse } from "./resources/file.js";
|
|
13
|
-
import { FilePart, Message, MessagePart, ReasoningPart, Session, SessionAbortResponse, SessionChatParams, SessionDeleteResponse, SessionInitParams, SessionInitResponse, SessionListResponse, SessionMessagesResponse, SessionResource, SessionSummarizeParams, SessionSummarizeResponse, SourceURLPart, StepStartPart, TextPart, ToolCall, ToolInvocationPart, ToolPartialCall, ToolResult } from "./resources/session.js";
|
|
14
|
-
import { type Fetch } from "./internal/builtin-types.js";
|
|
15
|
-
import { HeadersLike, NullableHeaders } from "./internal/headers.js";
|
|
16
|
-
import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js";
|
|
17
|
-
import { type LogLevel, type Logger } from "./internal/utils/log.js";
|
|
18
|
-
export interface ClientOptions {
|
|
19
|
-
/**
|
|
20
|
-
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
21
|
-
*
|
|
22
|
-
* Defaults to process.env['OPENCODE_BASE_URL'].
|
|
23
|
-
*/
|
|
24
|
-
baseURL?: string | null | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
27
|
-
* from the server before timing out a single request.
|
|
28
|
-
*
|
|
29
|
-
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
30
|
-
* much longer than this timeout before the promise succeeds or fails.
|
|
31
|
-
*/
|
|
32
|
-
timeout?: number | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Additional `RequestInit` options to be passed to `fetch` calls.
|
|
35
|
-
* Properties will be overridden by per-request `fetchOptions`.
|
|
36
|
-
*/
|
|
37
|
-
fetchOptions?: MergedRequestInit | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Specify a custom `fetch` function implementation.
|
|
40
|
-
*
|
|
41
|
-
* If not provided, we expect that `fetch` is defined globally.
|
|
42
|
-
*/
|
|
43
|
-
fetch?: Fetch | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* The maximum number of times that the client will retry a request in case of a
|
|
46
|
-
* temporary failure, like a network error or a 5XX error from the server.
|
|
47
|
-
*
|
|
48
|
-
* @default 2
|
|
49
|
-
*/
|
|
50
|
-
maxRetries?: number | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* Default headers to include with every request to the API.
|
|
53
|
-
*
|
|
54
|
-
* These can be removed in individual requests by explicitly setting the
|
|
55
|
-
* header to `null` in request options.
|
|
56
|
-
*/
|
|
57
|
-
defaultHeaders?: HeadersLike | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Default query parameters to include with every request to the API.
|
|
60
|
-
*
|
|
61
|
-
* These can be removed in individual requests by explicitly setting the
|
|
62
|
-
* param to `undefined` in request options.
|
|
63
|
-
*/
|
|
64
|
-
defaultQuery?: Record<string, string | undefined> | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Set the log level.
|
|
67
|
-
*
|
|
68
|
-
* Defaults to process.env['OPENCODE_LOG'] or 'warn' if it isn't set.
|
|
69
|
-
*/
|
|
70
|
-
logLevel?: LogLevel | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Set the logger.
|
|
73
|
-
*
|
|
74
|
-
* Defaults to globalThis.console.
|
|
75
|
-
*/
|
|
76
|
-
logger?: Logger | undefined;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* API Client for interfacing with the Opencode API.
|
|
80
|
-
*/
|
|
81
|
-
export declare class Opencode {
|
|
82
|
-
#private;
|
|
83
|
-
baseURL: string;
|
|
84
|
-
maxRetries: number;
|
|
85
|
-
timeout: number;
|
|
86
|
-
logger: Logger | undefined;
|
|
87
|
-
logLevel: LogLevel | undefined;
|
|
88
|
-
fetchOptions: MergedRequestInit | undefined;
|
|
89
|
-
private fetch;
|
|
90
|
-
protected idempotencyHeader?: string;
|
|
91
|
-
private _options;
|
|
92
|
-
/**
|
|
93
|
-
* API Client for interfacing with the Opencode API.
|
|
94
|
-
*
|
|
95
|
-
* @param {string} [opts.baseURL=process.env['OPENCODE_BASE_URL'] ?? http://localhost:54321] - Override the default base URL for the API.
|
|
96
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
97
|
-
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
98
|
-
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
99
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
100
|
-
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
101
|
-
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
102
|
-
*/
|
|
103
|
-
constructor({ baseURL, ...opts }?: ClientOptions);
|
|
104
|
-
/**
|
|
105
|
-
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
106
|
-
*/
|
|
107
|
-
withOptions(options: Partial<ClientOptions>): this;
|
|
108
|
-
protected defaultQuery(): Record<string, string | undefined> | undefined;
|
|
109
|
-
protected validateHeaders({ values, nulls }: NullableHeaders): void;
|
|
110
|
-
/**
|
|
111
|
-
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
112
|
-
*/
|
|
113
|
-
protected stringifyQuery(query: Record<string, unknown>): string;
|
|
114
|
-
private getUserAgent;
|
|
115
|
-
protected defaultIdempotencyKey(): string;
|
|
116
|
-
protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError;
|
|
117
|
-
buildURL(path: string, query: Record<string, unknown> | null | undefined, defaultBaseURL?: string | undefined): string;
|
|
118
|
-
/**
|
|
119
|
-
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
120
|
-
*/
|
|
121
|
-
protected prepareOptions(options: FinalRequestOptions): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* Used as a callback for mutating the given `RequestInit` object.
|
|
124
|
-
*
|
|
125
|
-
* This is useful for cases where you want to add certain headers based off of
|
|
126
|
-
* the request properties, e.g. `method` or `url`.
|
|
127
|
-
*/
|
|
128
|
-
protected prepareRequest(request: RequestInit, { url, options }: {
|
|
129
|
-
url: string;
|
|
130
|
-
options: FinalRequestOptions;
|
|
131
|
-
}): Promise<void>;
|
|
132
|
-
get<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
133
|
-
post<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
134
|
-
patch<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
135
|
-
put<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
136
|
-
delete<Rsp>(path: string, opts?: PromiseOrValue<RequestOptions>): APIPromise<Rsp>;
|
|
137
|
-
private methodRequest;
|
|
138
|
-
request<Rsp>(options: PromiseOrValue<FinalRequestOptions>, remainingRetries?: number | null): APIPromise<Rsp>;
|
|
139
|
-
private makeRequest;
|
|
140
|
-
fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
|
|
141
|
-
private shouldRetry;
|
|
142
|
-
private retryRequest;
|
|
143
|
-
private calculateDefaultRetryTimeoutMillis;
|
|
144
|
-
buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: {
|
|
145
|
-
retryCount?: number;
|
|
146
|
-
}): {
|
|
147
|
-
req: FinalizedRequestInit;
|
|
148
|
-
url: string;
|
|
149
|
-
timeout: number;
|
|
150
|
-
};
|
|
151
|
-
private buildHeaders;
|
|
152
|
-
private buildBody;
|
|
153
|
-
static Opencode: typeof Opencode;
|
|
154
|
-
static DEFAULT_TIMEOUT: number;
|
|
155
|
-
static OpencodeError: typeof Errors.OpencodeError;
|
|
156
|
-
static APIError: typeof Errors.APIError;
|
|
157
|
-
static APIConnectionError: typeof Errors.APIConnectionError;
|
|
158
|
-
static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError;
|
|
159
|
-
static APIUserAbortError: typeof Errors.APIUserAbortError;
|
|
160
|
-
static NotFoundError: typeof Errors.NotFoundError;
|
|
161
|
-
static ConflictError: typeof Errors.ConflictError;
|
|
162
|
-
static RateLimitError: typeof Errors.RateLimitError;
|
|
163
|
-
static BadRequestError: typeof Errors.BadRequestError;
|
|
164
|
-
static AuthenticationError: typeof Errors.AuthenticationError;
|
|
165
|
-
static InternalServerError: typeof Errors.InternalServerError;
|
|
166
|
-
static PermissionDeniedError: typeof Errors.PermissionDeniedError;
|
|
167
|
-
static UnprocessableEntityError: typeof Errors.UnprocessableEntityError;
|
|
168
|
-
static toFile: typeof Uploads.toFile;
|
|
169
|
-
event: API.Event;
|
|
170
|
-
app: API.AppResource;
|
|
171
|
-
file: API.File;
|
|
172
|
-
config: API.ConfigResource;
|
|
173
|
-
session: API.SessionResource;
|
|
174
|
-
}
|
|
175
|
-
export declare namespace Opencode {
|
|
176
|
-
export type RequestOptions = Opts.RequestOptions;
|
|
177
|
-
export { Event as Event, type EventListResponse as EventListResponse };
|
|
178
|
-
export { AppResource as AppResource, type App as App, type AppInitResponse as AppInitResponse };
|
|
179
|
-
export { File as File, type FileSearchResponse as FileSearchResponse, type FileSearchParams as FileSearchParams, };
|
|
180
|
-
export { ConfigResource as ConfigResource, type Config as Config, type Keybinds as Keybinds, type McpLocal as McpLocal, type McpRemote as McpRemote, type Model as Model, type Provider as Provider, type ConfigProvidersResponse as ConfigProvidersResponse, };
|
|
181
|
-
export { SessionResource as SessionResource, type FilePart as FilePart, type Message as Message, type MessagePart as MessagePart, type ReasoningPart as ReasoningPart, type Session as Session, type SourceURLPart as SourceURLPart, type StepStartPart as StepStartPart, type TextPart as TextPart, type ToolCall as ToolCall, type ToolInvocationPart as ToolInvocationPart, type ToolPartialCall as ToolPartialCall, type ToolResult as ToolResult, type SessionListResponse as SessionListResponse, type SessionDeleteResponse as SessionDeleteResponse, type SessionAbortResponse as SessionAbortResponse, type SessionInitResponse as SessionInitResponse, type SessionMessagesResponse as SessionMessagesResponse, type SessionSummarizeResponse as SessionSummarizeResponse, type SessionChatParams as SessionChatParams, type SessionInitParams as SessionInitParams, type SessionSummarizeParams as SessionSummarizeParams, };
|
|
182
|
-
export type ProviderAuthError = API.ProviderAuthError;
|
|
183
|
-
export type UnknownError = API.UnknownError;
|
|
184
|
-
}
|
|
185
|
-
//# sourceMappingURL=client.d.ts.map
|
package/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sour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AQ,IAAI,QAAQ,EACzB,KAAK,kBAAkB,IAAI,kBAAkB,EAC7C,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,UAAU,IAAI,UAAU,EAC7B,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,qBAAqB,IAAI,qBAAqB,EACnD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,sBAAsB,IAAI,sBAAsB,GACtD,CAAC;IAEF,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,iBAAiB,CAAC;IACtD,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;CAC7C"}
|
package/client.js
DELETED
|
@@ -1,459 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
var _Opencode_instances, _a, _Opencode_encoder, _Opencode_baseURLOverridden;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.Opencode = void 0;
|
|
6
|
-
const tslib_1 = require("./internal/tslib.js");
|
|
7
|
-
const uuid_1 = require("./internal/utils/uuid.js");
|
|
8
|
-
const values_1 = require("./internal/utils/values.js");
|
|
9
|
-
const sleep_1 = require("./internal/utils/sleep.js");
|
|
10
|
-
const errors_1 = require("./internal/errors.js");
|
|
11
|
-
const detect_platform_1 = require("./internal/detect-platform.js");
|
|
12
|
-
const Shims = tslib_1.__importStar(require("./internal/shims.js"));
|
|
13
|
-
const Opts = tslib_1.__importStar(require("./internal/request-options.js"));
|
|
14
|
-
const version_1 = require("./version.js");
|
|
15
|
-
const Errors = tslib_1.__importStar(require("./core/error.js"));
|
|
16
|
-
const Uploads = tslib_1.__importStar(require("./core/uploads.js"));
|
|
17
|
-
const API = tslib_1.__importStar(require("./resources/index.js"));
|
|
18
|
-
const api_promise_1 = require("./core/api-promise.js");
|
|
19
|
-
const app_1 = require("./resources/app.js");
|
|
20
|
-
const config_1 = require("./resources/config.js");
|
|
21
|
-
const event_1 = require("./resources/event.js");
|
|
22
|
-
const file_1 = require("./resources/file.js");
|
|
23
|
-
const session_1 = require("./resources/session.js");
|
|
24
|
-
const headers_1 = require("./internal/headers.js");
|
|
25
|
-
const env_1 = require("./internal/utils/env.js");
|
|
26
|
-
const log_1 = require("./internal/utils/log.js");
|
|
27
|
-
const values_2 = require("./internal/utils/values.js");
|
|
28
|
-
/**
|
|
29
|
-
* API Client for interfacing with the Opencode API.
|
|
30
|
-
*/
|
|
31
|
-
class Opencode {
|
|
32
|
-
/**
|
|
33
|
-
* API Client for interfacing with the Opencode API.
|
|
34
|
-
*
|
|
35
|
-
* @param {string} [opts.baseURL=process.env['OPENCODE_BASE_URL'] ?? http://localhost:54321] - Override the default base URL for the API.
|
|
36
|
-
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
37
|
-
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
38
|
-
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
39
|
-
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
40
|
-
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
41
|
-
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
42
|
-
*/
|
|
43
|
-
constructor({ baseURL = (0, env_1.readEnv)('OPENCODE_BASE_URL'), ...opts } = {}) {
|
|
44
|
-
_Opencode_instances.add(this);
|
|
45
|
-
_Opencode_encoder.set(this, void 0);
|
|
46
|
-
this.event = new API.Event(this);
|
|
47
|
-
this.app = new API.AppResource(this);
|
|
48
|
-
this.file = new API.File(this);
|
|
49
|
-
this.config = new API.ConfigResource(this);
|
|
50
|
-
this.session = new API.SessionResource(this);
|
|
51
|
-
const options = {
|
|
52
|
-
...opts,
|
|
53
|
-
baseURL: baseURL || `http://localhost:54321`,
|
|
54
|
-
};
|
|
55
|
-
this.baseURL = options.baseURL;
|
|
56
|
-
this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1 minute */;
|
|
57
|
-
this.logger = options.logger ?? console;
|
|
58
|
-
const defaultLogLevel = 'warn';
|
|
59
|
-
// Set default logLevel early so that we can log a warning in parseLogLevel.
|
|
60
|
-
this.logLevel = defaultLogLevel;
|
|
61
|
-
this.logLevel =
|
|
62
|
-
(0, log_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ??
|
|
63
|
-
(0, log_1.parseLogLevel)((0, env_1.readEnv)('OPENCODE_LOG'), "process.env['OPENCODE_LOG']", this) ??
|
|
64
|
-
defaultLogLevel;
|
|
65
|
-
this.fetchOptions = options.fetchOptions;
|
|
66
|
-
this.maxRetries = options.maxRetries ?? 2;
|
|
67
|
-
this.fetch = options.fetch ?? Shims.getDefaultFetch();
|
|
68
|
-
tslib_1.__classPrivateFieldSet(this, _Opencode_encoder, Opts.FallbackEncoder, "f");
|
|
69
|
-
this._options = options;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
73
|
-
*/
|
|
74
|
-
withOptions(options) {
|
|
75
|
-
return new this.constructor({
|
|
76
|
-
...this._options,
|
|
77
|
-
baseURL: this.baseURL,
|
|
78
|
-
maxRetries: this.maxRetries,
|
|
79
|
-
timeout: this.timeout,
|
|
80
|
-
logger: this.logger,
|
|
81
|
-
logLevel: this.logLevel,
|
|
82
|
-
fetch: this.fetch,
|
|
83
|
-
fetchOptions: this.fetchOptions,
|
|
84
|
-
...options,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
defaultQuery() {
|
|
88
|
-
return this._options.defaultQuery;
|
|
89
|
-
}
|
|
90
|
-
validateHeaders({ values, nulls }) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
95
|
-
*/
|
|
96
|
-
stringifyQuery(query) {
|
|
97
|
-
return Object.entries(query)
|
|
98
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
99
|
-
.map(([key, value]) => {
|
|
100
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
101
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
102
|
-
}
|
|
103
|
-
if (value === null) {
|
|
104
|
-
return `${encodeURIComponent(key)}=`;
|
|
105
|
-
}
|
|
106
|
-
throw new Errors.OpencodeError(`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
107
|
-
})
|
|
108
|
-
.join('&');
|
|
109
|
-
}
|
|
110
|
-
getUserAgent() {
|
|
111
|
-
return `${this.constructor.name}/JS ${version_1.VERSION}`;
|
|
112
|
-
}
|
|
113
|
-
defaultIdempotencyKey() {
|
|
114
|
-
return `stainless-node-retry-${(0, uuid_1.uuid4)()}`;
|
|
115
|
-
}
|
|
116
|
-
makeStatusError(status, error, message, headers) {
|
|
117
|
-
return Errors.APIError.generate(status, error, message, headers);
|
|
118
|
-
}
|
|
119
|
-
buildURL(path, query, defaultBaseURL) {
|
|
120
|
-
const baseURL = (!tslib_1.__classPrivateFieldGet(this, _Opencode_instances, "m", _Opencode_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL;
|
|
121
|
-
const url = (0, values_1.isAbsoluteURL)(path) ?
|
|
122
|
-
new URL(path)
|
|
123
|
-
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
124
|
-
const defaultQuery = this.defaultQuery();
|
|
125
|
-
if (!(0, values_2.isEmptyObj)(defaultQuery)) {
|
|
126
|
-
query = { ...defaultQuery, ...query };
|
|
127
|
-
}
|
|
128
|
-
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
129
|
-
url.search = this.stringifyQuery(query);
|
|
130
|
-
}
|
|
131
|
-
return url.toString();
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
135
|
-
*/
|
|
136
|
-
async prepareOptions(options) { }
|
|
137
|
-
/**
|
|
138
|
-
* Used as a callback for mutating the given `RequestInit` object.
|
|
139
|
-
*
|
|
140
|
-
* This is useful for cases where you want to add certain headers based off of
|
|
141
|
-
* the request properties, e.g. `method` or `url`.
|
|
142
|
-
*/
|
|
143
|
-
async prepareRequest(request, { url, options }) { }
|
|
144
|
-
get(path, opts) {
|
|
145
|
-
return this.methodRequest('get', path, opts);
|
|
146
|
-
}
|
|
147
|
-
post(path, opts) {
|
|
148
|
-
return this.methodRequest('post', path, opts);
|
|
149
|
-
}
|
|
150
|
-
patch(path, opts) {
|
|
151
|
-
return this.methodRequest('patch', path, opts);
|
|
152
|
-
}
|
|
153
|
-
put(path, opts) {
|
|
154
|
-
return this.methodRequest('put', path, opts);
|
|
155
|
-
}
|
|
156
|
-
delete(path, opts) {
|
|
157
|
-
return this.methodRequest('delete', path, opts);
|
|
158
|
-
}
|
|
159
|
-
methodRequest(method, path, opts) {
|
|
160
|
-
return this.request(Promise.resolve(opts).then((opts) => {
|
|
161
|
-
return { method, path, ...opts };
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
request(options, remainingRetries = null) {
|
|
165
|
-
return new api_promise_1.APIPromise(this, this.makeRequest(options, remainingRetries, undefined));
|
|
166
|
-
}
|
|
167
|
-
async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID) {
|
|
168
|
-
const options = await optionsInput;
|
|
169
|
-
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
170
|
-
if (retriesRemaining == null) {
|
|
171
|
-
retriesRemaining = maxRetries;
|
|
172
|
-
}
|
|
173
|
-
await this.prepareOptions(options);
|
|
174
|
-
const { req, url, timeout } = this.buildRequest(options, { retryCount: maxRetries - retriesRemaining });
|
|
175
|
-
await this.prepareRequest(req, { url, options });
|
|
176
|
-
/** Not an API request ID, just for correlating local log entries. */
|
|
177
|
-
const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0');
|
|
178
|
-
const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`;
|
|
179
|
-
const startTime = Date.now();
|
|
180
|
-
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] sending request`, (0, log_1.formatRequestDetails)({
|
|
181
|
-
retryOfRequestLogID,
|
|
182
|
-
method: options.method,
|
|
183
|
-
url,
|
|
184
|
-
options,
|
|
185
|
-
headers: req.headers,
|
|
186
|
-
}));
|
|
187
|
-
if (options.signal?.aborted) {
|
|
188
|
-
throw new Errors.APIUserAbortError();
|
|
189
|
-
}
|
|
190
|
-
const controller = new AbortController();
|
|
191
|
-
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(errors_1.castToError);
|
|
192
|
-
const headersTime = Date.now();
|
|
193
|
-
if (response instanceof Error) {
|
|
194
|
-
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
195
|
-
if (options.signal?.aborted) {
|
|
196
|
-
throw new Errors.APIUserAbortError();
|
|
197
|
-
}
|
|
198
|
-
// detect native connection timeout errors
|
|
199
|
-
// deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
|
|
200
|
-
// undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)"
|
|
201
|
-
// others do not provide enough information to distinguish timeouts from other connection errors
|
|
202
|
-
const isTimeout = (0, errors_1.isAbortError)(response) ||
|
|
203
|
-
/timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : ''));
|
|
204
|
-
if (retriesRemaining) {
|
|
205
|
-
(0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`);
|
|
206
|
-
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, (0, log_1.formatRequestDetails)({
|
|
207
|
-
retryOfRequestLogID,
|
|
208
|
-
url,
|
|
209
|
-
durationMs: headersTime - startTime,
|
|
210
|
-
message: response.message,
|
|
211
|
-
}));
|
|
212
|
-
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
|
|
213
|
-
}
|
|
214
|
-
(0, log_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`);
|
|
215
|
-
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, (0, log_1.formatRequestDetails)({
|
|
216
|
-
retryOfRequestLogID,
|
|
217
|
-
url,
|
|
218
|
-
durationMs: headersTime - startTime,
|
|
219
|
-
message: response.message,
|
|
220
|
-
}));
|
|
221
|
-
if (isTimeout) {
|
|
222
|
-
throw new Errors.APIConnectionTimeoutError();
|
|
223
|
-
}
|
|
224
|
-
throw new Errors.APIConnectionError({ cause: response });
|
|
225
|
-
}
|
|
226
|
-
const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`;
|
|
227
|
-
if (!response.ok) {
|
|
228
|
-
const shouldRetry = this.shouldRetry(response);
|
|
229
|
-
if (retriesRemaining && shouldRetry) {
|
|
230
|
-
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
|
|
231
|
-
// We don't need the body of this response.
|
|
232
|
-
await Shims.CancelReadableStream(response.body);
|
|
233
|
-
(0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
|
|
234
|
-
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
|
|
235
|
-
retryOfRequestLogID,
|
|
236
|
-
url: response.url,
|
|
237
|
-
status: response.status,
|
|
238
|
-
headers: response.headers,
|
|
239
|
-
durationMs: headersTime - startTime,
|
|
240
|
-
}));
|
|
241
|
-
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers);
|
|
242
|
-
}
|
|
243
|
-
const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
|
|
244
|
-
(0, log_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`);
|
|
245
|
-
const errText = await response.text().catch((err) => (0, errors_1.castToError)(err).message);
|
|
246
|
-
const errJSON = (0, values_1.safeJSON)(errText);
|
|
247
|
-
const errMessage = errJSON ? undefined : errText;
|
|
248
|
-
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_1.formatRequestDetails)({
|
|
249
|
-
retryOfRequestLogID,
|
|
250
|
-
url: response.url,
|
|
251
|
-
status: response.status,
|
|
252
|
-
headers: response.headers,
|
|
253
|
-
message: errMessage,
|
|
254
|
-
durationMs: Date.now() - startTime,
|
|
255
|
-
}));
|
|
256
|
-
const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers);
|
|
257
|
-
throw err;
|
|
258
|
-
}
|
|
259
|
-
(0, log_1.loggerFor)(this).info(responseInfo);
|
|
260
|
-
(0, log_1.loggerFor)(this).debug(`[${requestLogID}] response start`, (0, log_1.formatRequestDetails)({
|
|
261
|
-
retryOfRequestLogID,
|
|
262
|
-
url: response.url,
|
|
263
|
-
status: response.status,
|
|
264
|
-
headers: response.headers,
|
|
265
|
-
durationMs: headersTime - startTime,
|
|
266
|
-
}));
|
|
267
|
-
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
268
|
-
}
|
|
269
|
-
async fetchWithTimeout(url, init, ms, controller) {
|
|
270
|
-
const { signal, method, ...options } = init || {};
|
|
271
|
-
if (signal)
|
|
272
|
-
signal.addEventListener('abort', () => controller.abort());
|
|
273
|
-
const timeout = setTimeout(() => controller.abort(), ms);
|
|
274
|
-
const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
|
|
275
|
-
(typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
|
|
276
|
-
const fetchOptions = {
|
|
277
|
-
signal: controller.signal,
|
|
278
|
-
...(isReadableBody ? { duplex: 'half' } : {}),
|
|
279
|
-
method: 'GET',
|
|
280
|
-
...options,
|
|
281
|
-
};
|
|
282
|
-
if (method) {
|
|
283
|
-
// Custom methods like 'patch' need to be uppercased
|
|
284
|
-
// See https://github.com/nodejs/undici/issues/2294
|
|
285
|
-
fetchOptions.method = method.toUpperCase();
|
|
286
|
-
}
|
|
287
|
-
try {
|
|
288
|
-
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
289
|
-
return await this.fetch.call(undefined, url, fetchOptions);
|
|
290
|
-
}
|
|
291
|
-
finally {
|
|
292
|
-
clearTimeout(timeout);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
shouldRetry(response) {
|
|
296
|
-
// Note this is not a standard header.
|
|
297
|
-
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
298
|
-
// If the server explicitly says whether or not to retry, obey.
|
|
299
|
-
if (shouldRetryHeader === 'true')
|
|
300
|
-
return true;
|
|
301
|
-
if (shouldRetryHeader === 'false')
|
|
302
|
-
return false;
|
|
303
|
-
// Retry on request timeouts.
|
|
304
|
-
if (response.status === 408)
|
|
305
|
-
return true;
|
|
306
|
-
// Retry on lock timeouts.
|
|
307
|
-
if (response.status === 409)
|
|
308
|
-
return true;
|
|
309
|
-
// Retry on rate limits.
|
|
310
|
-
if (response.status === 429)
|
|
311
|
-
return true;
|
|
312
|
-
// Retry internal errors.
|
|
313
|
-
if (response.status >= 500)
|
|
314
|
-
return true;
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
async retryRequest(options, retriesRemaining, requestLogID, responseHeaders) {
|
|
318
|
-
let timeoutMillis;
|
|
319
|
-
// Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it.
|
|
320
|
-
const retryAfterMillisHeader = responseHeaders?.get('retry-after-ms');
|
|
321
|
-
if (retryAfterMillisHeader) {
|
|
322
|
-
const timeoutMs = parseFloat(retryAfterMillisHeader);
|
|
323
|
-
if (!Number.isNaN(timeoutMs)) {
|
|
324
|
-
timeoutMillis = timeoutMs;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
// About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
|
|
328
|
-
const retryAfterHeader = responseHeaders?.get('retry-after');
|
|
329
|
-
if (retryAfterHeader && !timeoutMillis) {
|
|
330
|
-
const timeoutSeconds = parseFloat(retryAfterHeader);
|
|
331
|
-
if (!Number.isNaN(timeoutSeconds)) {
|
|
332
|
-
timeoutMillis = timeoutSeconds * 1000;
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
timeoutMillis = Date.parse(retryAfterHeader) - Date.now();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
// If the API asks us to wait a certain amount of time (and it's a reasonable amount),
|
|
339
|
-
// just do what it says, but otherwise calculate a default
|
|
340
|
-
if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
|
|
341
|
-
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
342
|
-
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
343
|
-
}
|
|
344
|
-
await (0, sleep_1.sleep)(timeoutMillis);
|
|
345
|
-
return this.makeRequest(options, retriesRemaining - 1, requestLogID);
|
|
346
|
-
}
|
|
347
|
-
calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) {
|
|
348
|
-
const initialRetryDelay = 0.5;
|
|
349
|
-
const maxRetryDelay = 8.0;
|
|
350
|
-
const numRetries = maxRetries - retriesRemaining;
|
|
351
|
-
// Apply exponential backoff, but not more than the max.
|
|
352
|
-
const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay);
|
|
353
|
-
// Apply some jitter, take up to at most 25 percent of the retry time.
|
|
354
|
-
const jitter = 1 - Math.random() * 0.25;
|
|
355
|
-
return sleepSeconds * jitter * 1000;
|
|
356
|
-
}
|
|
357
|
-
buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
358
|
-
const options = { ...inputOptions };
|
|
359
|
-
const { method, path, query, defaultBaseURL } = options;
|
|
360
|
-
const url = this.buildURL(path, query, defaultBaseURL);
|
|
361
|
-
if ('timeout' in options)
|
|
362
|
-
(0, values_1.validatePositiveInteger)('timeout', options.timeout);
|
|
363
|
-
options.timeout = options.timeout ?? this.timeout;
|
|
364
|
-
const { bodyHeaders, body } = this.buildBody({ options });
|
|
365
|
-
const reqHeaders = this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount });
|
|
366
|
-
const req = {
|
|
367
|
-
method,
|
|
368
|
-
headers: reqHeaders,
|
|
369
|
-
...(options.signal && { signal: options.signal }),
|
|
370
|
-
...(globalThis.ReadableStream &&
|
|
371
|
-
body instanceof globalThis.ReadableStream && { duplex: 'half' }),
|
|
372
|
-
...(body && { body }),
|
|
373
|
-
...(this.fetchOptions ?? {}),
|
|
374
|
-
...(options.fetchOptions ?? {}),
|
|
375
|
-
};
|
|
376
|
-
return { req, url, timeout: options.timeout };
|
|
377
|
-
}
|
|
378
|
-
buildHeaders({ options, method, bodyHeaders, retryCount, }) {
|
|
379
|
-
let idempotencyHeaders = {};
|
|
380
|
-
if (this.idempotencyHeader && method !== 'get') {
|
|
381
|
-
if (!options.idempotencyKey)
|
|
382
|
-
options.idempotencyKey = this.defaultIdempotencyKey();
|
|
383
|
-
idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
|
|
384
|
-
}
|
|
385
|
-
const headers = (0, headers_1.buildHeaders)([
|
|
386
|
-
idempotencyHeaders,
|
|
387
|
-
{
|
|
388
|
-
Accept: 'application/json',
|
|
389
|
-
'User-Agent': this.getUserAgent(),
|
|
390
|
-
'X-Stainless-Retry-Count': String(retryCount),
|
|
391
|
-
...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
|
|
392
|
-
...(0, detect_platform_1.getPlatformHeaders)(),
|
|
393
|
-
},
|
|
394
|
-
this._options.defaultHeaders,
|
|
395
|
-
bodyHeaders,
|
|
396
|
-
options.headers,
|
|
397
|
-
]);
|
|
398
|
-
this.validateHeaders(headers);
|
|
399
|
-
return headers.values;
|
|
400
|
-
}
|
|
401
|
-
buildBody({ options: { body, headers: rawHeaders } }) {
|
|
402
|
-
if (!body) {
|
|
403
|
-
return { bodyHeaders: undefined, body: undefined };
|
|
404
|
-
}
|
|
405
|
-
const headers = (0, headers_1.buildHeaders)([rawHeaders]);
|
|
406
|
-
if (
|
|
407
|
-
// Pass raw type verbatim
|
|
408
|
-
ArrayBuffer.isView(body) ||
|
|
409
|
-
body instanceof ArrayBuffer ||
|
|
410
|
-
body instanceof DataView ||
|
|
411
|
-
(typeof body === 'string' &&
|
|
412
|
-
// Preserve legacy string encoding behavior for now
|
|
413
|
-
headers.values.has('content-type')) ||
|
|
414
|
-
// `Blob` is superset of `File`
|
|
415
|
-
body instanceof Blob ||
|
|
416
|
-
// `FormData` -> `multipart/form-data`
|
|
417
|
-
body instanceof FormData ||
|
|
418
|
-
// `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
419
|
-
body instanceof URLSearchParams ||
|
|
420
|
-
// Send chunked stream (each chunk has own `length`)
|
|
421
|
-
(globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) {
|
|
422
|
-
return { bodyHeaders: undefined, body: body };
|
|
423
|
-
}
|
|
424
|
-
else if (typeof body === 'object' &&
|
|
425
|
-
(Symbol.asyncIterator in body ||
|
|
426
|
-
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) {
|
|
427
|
-
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) };
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
return tslib_1.__classPrivateFieldGet(this, _Opencode_encoder, "f").call(this, { body, headers });
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
exports.Opencode = Opencode;
|
|
435
|
-
_a = Opencode, _Opencode_encoder = new WeakMap(), _Opencode_instances = new WeakSet(), _Opencode_baseURLOverridden = function _Opencode_baseURLOverridden() {
|
|
436
|
-
return this.baseURL !== 'http://localhost:54321';
|
|
437
|
-
};
|
|
438
|
-
Opencode.Opencode = _a;
|
|
439
|
-
Opencode.DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
440
|
-
Opencode.OpencodeError = Errors.OpencodeError;
|
|
441
|
-
Opencode.APIError = Errors.APIError;
|
|
442
|
-
Opencode.APIConnectionError = Errors.APIConnectionError;
|
|
443
|
-
Opencode.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
444
|
-
Opencode.APIUserAbortError = Errors.APIUserAbortError;
|
|
445
|
-
Opencode.NotFoundError = Errors.NotFoundError;
|
|
446
|
-
Opencode.ConflictError = Errors.ConflictError;
|
|
447
|
-
Opencode.RateLimitError = Errors.RateLimitError;
|
|
448
|
-
Opencode.BadRequestError = Errors.BadRequestError;
|
|
449
|
-
Opencode.AuthenticationError = Errors.AuthenticationError;
|
|
450
|
-
Opencode.InternalServerError = Errors.InternalServerError;
|
|
451
|
-
Opencode.PermissionDeniedError = Errors.PermissionDeniedError;
|
|
452
|
-
Opencode.UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
453
|
-
Opencode.toFile = Uploads.toFile;
|
|
454
|
-
Opencode.Event = event_1.Event;
|
|
455
|
-
Opencode.AppResource = app_1.AppResource;
|
|
456
|
-
Opencode.File = file_1.File;
|
|
457
|
-
Opencode.ConfigResource = config_1.ConfigResource;
|
|
458
|
-
Opencode.SessionResource = session_1.SessionResource;
|
|
459
|
-
//# sourceMappingURL=client.js.map
|