@opencode/ai 0.0.0-dev-21382 → 0.0.0-dev-21387
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/dist/route/executor.js
CHANGED
|
@@ -6,19 +6,20 @@ import { Service } from "./executor-service.js";
|
|
|
6
6
|
export { Service } from "./executor-service.js";
|
|
7
7
|
const headerDetails = (headers) => Object.fromEntries(Object.entries(headers).map(([name, value]) => [name, String(value)]));
|
|
8
8
|
const normalizedHeaders = (headers) => Object.fromEntries(Object.entries(headers).map(([key, value]) => [key.toLowerCase(), value]));
|
|
9
|
+
const clampRetryAfterMs = (millis) => Math.min(Number.MAX_SAFE_INTEGER, Math.max(0, Math.ceil(millis)));
|
|
9
10
|
const retryAfterMs = (headers) => {
|
|
10
11
|
const millis = Number(headers["retry-after-ms"]);
|
|
11
12
|
if (Number.isFinite(millis))
|
|
12
|
-
return
|
|
13
|
+
return clampRetryAfterMs(millis);
|
|
13
14
|
const value = headers["retry-after"];
|
|
14
15
|
if (!value)
|
|
15
16
|
return undefined;
|
|
16
17
|
const seconds = Number(value);
|
|
17
18
|
if (Number.isFinite(seconds))
|
|
18
|
-
return
|
|
19
|
+
return clampRetryAfterMs(seconds * 1000);
|
|
19
20
|
const date = Date.parse(value);
|
|
20
21
|
if (!Number.isNaN(date))
|
|
21
|
-
return
|
|
22
|
+
return clampRetryAfterMs(date - Date.now());
|
|
22
23
|
return undefined;
|
|
23
24
|
};
|
|
24
25
|
const addRateLimitValue = (target, key, value) => {
|
package/dist/schema/errors.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ declare const HttpContext_base: Schema.Class<HttpContext, Schema.Struct<{
|
|
|
10
10
|
export declare class HttpContext extends HttpContext_base {
|
|
11
11
|
}
|
|
12
12
|
declare const HttpRateLimitDetails_base: Schema.Class<HttpRateLimitDetails, Schema.Struct<{
|
|
13
|
-
readonly retryAfterMs: Schema.optional<Schema.
|
|
13
|
+
readonly retryAfterMs: Schema.optional<Schema.Int>;
|
|
14
14
|
readonly limit: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
15
15
|
readonly remaining: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
16
16
|
readonly reset: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
@@ -80,7 +80,7 @@ declare const RateLimitError_base: Schema.Class<RateLimitError, Schema.TaggedStr
|
|
|
80
80
|
readonly body: Schema.optional<Schema.String>;
|
|
81
81
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
82
82
|
readonly cause: Schema.optional<Schema.Defect>;
|
|
83
|
-
readonly retryAfterMs: Schema.optional<Schema.
|
|
83
|
+
readonly retryAfterMs: Schema.optional<Schema.Int>;
|
|
84
84
|
readonly rateLimit: Schema.optional<typeof HttpRateLimitDetails>;
|
|
85
85
|
}>, import("effect/Cause").YieldableError>;
|
|
86
86
|
export declare class RateLimitError extends RateLimitError_base {
|
|
@@ -90,7 +90,7 @@ declare const QuotaExceededError_base: Schema.Class<QuotaExceededError, Schema.T
|
|
|
90
90
|
readonly body: Schema.optional<Schema.String>;
|
|
91
91
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
92
92
|
readonly cause: Schema.optional<Schema.Defect>;
|
|
93
|
-
readonly retryAfterMs: Schema.optional<Schema.
|
|
93
|
+
readonly retryAfterMs: Schema.optional<Schema.Int>;
|
|
94
94
|
}>, import("effect/Cause").YieldableError>;
|
|
95
95
|
export declare class QuotaExceededError extends QuotaExceededError_base {
|
|
96
96
|
}
|
|
@@ -107,7 +107,7 @@ declare const ProviderInternalError_base: Schema.Class<ProviderInternalError, Sc
|
|
|
107
107
|
readonly body: Schema.optional<Schema.String>;
|
|
108
108
|
readonly http: Schema.optional<typeof HttpContext>;
|
|
109
109
|
readonly cause: Schema.optional<Schema.Defect>;
|
|
110
|
-
readonly retryAfterMs: Schema.optional<Schema.
|
|
110
|
+
readonly retryAfterMs: Schema.optional<Schema.Int>;
|
|
111
111
|
}>, import("effect/Cause").YieldableError>;
|
|
112
112
|
export declare class ProviderInternalError extends ProviderInternalError_base {
|
|
113
113
|
}
|
package/dist/schema/errors.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import { NonNegativeInt } from "@opencode/schema";
|
|
2
3
|
import { Tool } from "@opencode/schema/tool";
|
|
3
4
|
import { ModelID, ProviderID, RouteID } from "./ids.js";
|
|
4
5
|
export const ProviderFailureClassification = Schema.Literals(["context-overflow", "payload-too-large"]);
|
|
@@ -9,7 +10,7 @@ export class HttpContext extends Schema.Class("AI.HttpContext")({
|
|
|
9
10
|
}) {
|
|
10
11
|
}
|
|
11
12
|
export class HttpRateLimitDetails extends Schema.Class("AI.HttpRateLimitDetails")({
|
|
12
|
-
retryAfterMs: Schema.optional(
|
|
13
|
+
retryAfterMs: Schema.optional(NonNegativeInt),
|
|
13
14
|
limit: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
14
15
|
remaining: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
15
16
|
reset: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
@@ -63,20 +64,20 @@ export class AuthenticationError extends Schema.TaggedError("AI.Error.Authentica
|
|
|
63
64
|
}
|
|
64
65
|
export class RateLimitError extends Schema.TaggedError("AI.Error.RateLimit")("RateLimit", {
|
|
65
66
|
...ReasonFields,
|
|
66
|
-
retryAfterMs: Schema.optional(
|
|
67
|
+
retryAfterMs: Schema.optional(NonNegativeInt),
|
|
67
68
|
rateLimit: Schema.optional(HttpRateLimitDetails),
|
|
68
69
|
}) {
|
|
69
70
|
}
|
|
70
71
|
export class QuotaExceededError extends Schema.TaggedError("AI.Error.QuotaExceeded")("QuotaExceeded", {
|
|
71
72
|
...ReasonFields,
|
|
72
|
-
retryAfterMs: Schema.optional(
|
|
73
|
+
retryAfterMs: Schema.optional(NonNegativeInt),
|
|
73
74
|
}) {
|
|
74
75
|
}
|
|
75
76
|
export class ContentPolicyError extends Schema.TaggedError("AI.Error.ContentPolicy")("ContentPolicy", ReasonFields) {
|
|
76
77
|
}
|
|
77
78
|
export class ProviderInternalError extends Schema.TaggedError("AI.Error.ProviderInternal")("ProviderInternal", {
|
|
78
79
|
...ReasonFields,
|
|
79
|
-
retryAfterMs: Schema.optional(
|
|
80
|
+
retryAfterMs: Schema.optional(NonNegativeInt),
|
|
80
81
|
}) {
|
|
81
82
|
}
|
|
82
83
|
export const TransportType = Schema.Literals(["http", "websocket"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-21387",
|
|
4
4
|
"name": "@opencode/ai",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@clack/prompts": "1.0.0-alpha.1",
|
|
36
36
|
"@effect/platform-node": "4.0.1",
|
|
37
|
-
"@opencode/http-recorder": "0.0.0-dev-
|
|
37
|
+
"@opencode/http-recorder": "0.0.0-dev-21387",
|
|
38
38
|
"@tsconfig/bun": "1.0.9",
|
|
39
39
|
"@types/bun": "1.4.0",
|
|
40
40
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@aws-sdk/credential-providers": "3.1057.0",
|
|
45
45
|
"@smithy/eventstream-codec": "4.2.14",
|
|
46
46
|
"@smithy/util-utf8": "4.2.2",
|
|
47
|
-
"@opencode/schema": "0.0.0-dev-
|
|
47
|
+
"@opencode/schema": "0.0.0-dev-21387",
|
|
48
48
|
"aws4fetch": "1.0.20",
|
|
49
49
|
"effect": "4.0.1",
|
|
50
50
|
"google-auth-library": "10.5.0"
|