@workerstack/clients 1.0.0-rc.26 → 1.0.0-rc.28
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/README.md +43 -43
- package/bin/{honey-clients.js → clients.js} +12 -12
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +14 -14
- package/dist/emit/cli/discovery.js +1 -1
- package/dist/emit/cli/install.js +2 -2
- package/dist/emit/cli/layout.js +1 -1
- package/dist/emit/cli/module.js +1 -1
- package/dist/emit/cli/release.js +1 -1
- package/dist/emit/csharp/errors.js +1 -1
- package/dist/emit/csharp/sdk-client.js +1 -1
- package/dist/emit/csharp/sdk-csproj.d.ts +1 -1
- package/dist/emit/csharp/sdk-csproj.js +2 -2
- package/dist/emit/csharp/sdk.d.ts +1 -1
- package/dist/emit/csharp/sdk.js +2 -2
- package/dist/emit/csharp/transport.js +2 -2
- package/dist/emit/csharp/types-record.d.ts +1 -1
- package/dist/emit/go/sdk-client.js +1 -1
- package/dist/emit/go/sdk.js +1 -1
- package/dist/emit/java/sdk-errors.js +5 -5
- package/dist/emit/java/sdk-op.d.ts +1 -1
- package/dist/emit/java/sdk.js +3 -3
- package/dist/emit/mcp/files.d.ts +1 -1
- package/dist/emit/mcp/mounted.js +2 -2
- package/dist/emit/mcp/runtime.js +1 -1
- package/dist/emit/mcp/server.js +1 -1
- package/dist/emit/python/errors.js +1 -1
- package/dist/emit/python/sdk-client.js +2 -2
- package/dist/emit/python/sdk-pyproject.js +4 -4
- package/dist/emit/python/sdk.d.ts +1 -1
- package/dist/emit/python/sdk.js +11 -11
- package/dist/emit/python/transport.js +1 -1
- package/dist/emit/rust/errors.js +2 -2
- package/dist/emit/rust/sdk-cargo.js +3 -3
- package/dist/emit/rust/sdk.d.ts +1 -1
- package/dist/emit/rust/sdk.js +2 -2
- package/dist/emit/shared/format.d.ts +1 -1
- package/dist/emit/shared/metadata.d.ts +1 -1
- package/dist/emit/shared/status-keys.d.ts +1 -1
- package/dist/emit/shared/status-keys.js +1 -1
- package/dist/emit/ts/app-client.js +2 -2
- package/dist/emit/ts/route-tree.d.ts +1 -1
- package/dist/emit/ts/route-tree.js +1 -12
- package/dist/emit/ts/sdk-types-preamble.js +16 -16
- package/dist/emit/ts/sdk-types.js +6 -6
- package/dist/emit/ts/tanstack-query.js +5 -5
- package/dist/emit/ts/type-gen.d.ts +4 -3
- package/dist/emit/ts/type-gen.js +86 -45
- package/dist/extract/chain.d.ts +10 -6
- package/dist/extract/chain.js +5 -19
- package/dist/extract/extract.d.ts +2 -2
- package/dist/extract/extract.js +40 -26
- package/dist/extract/serialize.js +1 -1
- package/dist/extract/walk.d.ts +15 -4
- package/dist/extract/walk.js +159 -15
- package/dist/gen/args.js +3 -3
- package/dist/gen/formatters.d.ts +6 -6
- package/dist/gen/formatters.js +7 -7
- package/dist/gen/process.d.ts +3 -3
- package/dist/gen/process.js +7 -7
- package/dist/gen/targets.d.ts +3 -3
- package/dist/gen/targets.js +3 -3
- package/dist/gen/write.d.ts +1 -1
- package/dist/gen/write.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ir/load.js +10 -10
- package/dist/ir/model.d.ts +6 -4
- package/dist/ir/sdk-model.d.ts +1 -1
- package/dist/ir/sdk-model.js +1 -1
- package/dist/ir/slots.d.ts +3 -3
- package/dist/ir/slots.js +12 -10
- package/dist/release/bootstrap.js +1 -1
- package/dist/release/bump-command.js +1 -1
- package/dist/release/cli.d.ts +4 -4
- package/dist/release/cli.js +6 -6
- package/dist/release/context.d.ts +1 -1
- package/dist/release/context.js +1 -1
- package/dist/release/digest.d.ts +1 -1
- package/dist/release/digest.js +2 -2
- package/dist/release/index.d.ts +1 -1
- package/dist/release/load.js +1 -1
- package/dist/release/manifest.js +1 -1
- package/dist/release/registries.js +3 -3
- package/dist/release/release-workflow.js +1 -1
- package/dist/release/spec-gate.d.ts +2 -2
- package/dist/release/spec-gate.js +2 -2
- package/dist/release/sync-command.d.ts +1 -1
- package/dist/release/sync-command.js +1 -1
- package/dist/release/sync-tree.js +1 -1
- package/dist/release/types.d.ts +6 -6
- package/dist/runtime/cli/body.go +1 -1
- package/dist/runtime/cli/config.go +3 -3
- package/dist/runtime/cli/discovery.go +1 -1
- package/dist/runtime/cli/format.go +1 -1
- package/dist/runtime/cli/log.go +1 -1
- package/dist/runtime/cli/output.go +1 -1
- package/dist/runtime/cli/params.go +1 -1
- package/dist/runtime/cli/run.go +1 -1
- package/dist/runtime/cli/socket.go +1 -1
- package/dist/runtime/cli/stream.go +1 -1
- package/dist/runtime/cli/target.go +1 -1
- package/dist/runtime/csharp/Adapters.cs +2 -2
- package/dist/runtime/csharp/Auth.cs +2 -2
- package/dist/runtime/csharp/Body.cs +3 -3
- package/dist/runtime/csharp/Config.cs +2 -2
- package/dist/runtime/csharp/Envelope.cs +3 -3
- package/dist/runtime/csharp/Errors.cs +10 -10
- package/dist/runtime/csharp/Events.cs +2 -2
- package/dist/runtime/csharp/Exchange.cs +4 -4
- package/dist/runtime/csharp/Handler.cs +3 -3
- package/dist/runtime/csharp/Hooks.cs +3 -3
- package/dist/runtime/csharp/Invalidation.cs +2 -2
- package/dist/runtime/csharp/Json.cs +2 -2
- package/dist/runtime/csharp/Log.cs +2 -2
- package/dist/runtime/csharp/Operation.cs +2 -2
- package/dist/runtime/csharp/Path.cs +2 -2
- package/dist/runtime/csharp/Query.cs +2 -2
- package/dist/runtime/csharp/Realtime.cs +2 -2
- package/dist/runtime/csharp/RealtimeLoop.cs +3 -3
- package/dist/runtime/csharp/Redirect.cs +2 -2
- package/dist/runtime/csharp/Result.cs +2 -2
- package/dist/runtime/csharp/Sse.cs +2 -2
- package/dist/runtime/csharp/Stale.cs +2 -2
- package/dist/runtime/csharp/Transport.cs +2 -2
- package/dist/runtime/csharp/TransportLongPoll.cs +2 -2
- package/dist/runtime/csharp/TransportSse.cs +2 -2
- package/dist/runtime/csharp/TransportWs.cs +2 -2
- package/dist/runtime/csharp/Wire.cs +2 -2
- package/dist/runtime/csharp/Ws.cs +2 -2
- package/dist/runtime/csharp/WsDial.cs +2 -2
- package/dist/runtime/go/auth.go +1 -1
- package/dist/runtime/go/body.go +2 -2
- package/dist/runtime/go/config.go +1 -1
- package/dist/runtime/go/errors.go +5 -5
- package/dist/runtime/go/export.go +10 -10
- package/dist/runtime/go/hooks.go +2 -2
- package/dist/runtime/go/invalidation.go +2 -2
- package/dist/runtime/go/log.go +1 -1
- package/dist/runtime/go/nullable.go +1 -1
- package/dist/runtime/go/options.go +1 -1
- package/dist/runtime/go/path.go +1 -1
- package/dist/runtime/go/query.go +2 -2
- package/dist/runtime/go/realtime.go +4 -4
- package/dist/runtime/go/realtime_loop.go +1 -1
- package/dist/runtime/go/redirect.go +2 -2
- package/dist/runtime/go/request.go +9 -9
- package/dist/runtime/go/result.go +2 -2
- package/dist/runtime/go/sse.go +3 -3
- package/dist/runtime/go/stale.go +1 -1
- package/dist/runtime/go/stream.go +2 -2
- package/dist/runtime/go/transport.go +2 -2
- package/dist/runtime/go/transport_longpoll.go +1 -1
- package/dist/runtime/go/transport_sse.go +2 -2
- package/dist/runtime/go/ws.go +1 -1
- package/dist/runtime/java/Answer.java +2 -2
- package/dist/runtime/java/ApiException.java +2 -2
- package/dist/runtime/java/BinaryBody.java +2 -2
- package/dist/runtime/java/Body.java +4 -4
- package/dist/runtime/java/Call.java +2 -2
- package/dist/runtime/java/CallLog.java +2 -2
- package/dist/runtime/java/ClientConfig.java +2 -2
- package/dist/runtime/java/ConnectionState.java +2 -2
- package/dist/runtime/java/Credential.java +2 -2
- package/dist/runtime/java/Deadline.java +2 -2
- package/dist/runtime/java/Decode.java +2 -2
- package/dist/runtime/java/Envelope.java +2 -2
- package/dist/runtime/java/ErrorEnvelope.java +3 -3
- package/dist/runtime/java/EventStream.java +2 -2
- package/dist/runtime/java/Exchange.java +2 -2
- package/dist/runtime/java/FilePart.java +2 -2
- package/dist/runtime/java/Flight.java +3 -3
- package/dist/runtime/java/Hooks.java +3 -3
- package/dist/runtime/java/Hops.java +2 -2
- package/dist/runtime/java/{HoneyException.java → HttpException.java} +4 -4
- package/dist/runtime/java/InvalidationConfig.java +2 -2
- package/dist/runtime/java/Json.java +3 -3
- package/dist/runtime/java/Keepalive.java +2 -2
- package/dist/runtime/java/LogEntry.java +2 -2
- package/dist/runtime/java/LongPollAdapter.java +2 -2
- package/dist/runtime/java/Operation.java +2 -2
- package/dist/runtime/java/Opt.java +2 -2
- package/dist/runtime/java/Pump.java +2 -2
- package/dist/runtime/java/RawResponse.java +2 -2
- package/dist/runtime/java/Realtime.java +2 -2
- package/dist/runtime/java/RealtimeLoop.java +4 -4
- package/dist/runtime/java/RedirectPolicy.java +2 -2
- package/dist/runtime/java/Redirects.java +2 -2
- package/dist/runtime/java/RequestContext.java +2 -2
- package/dist/runtime/java/RequestHook.java +2 -2
- package/dist/runtime/java/RequestOptions.java +2 -2
- package/dist/runtime/java/ResponseContext.java +2 -2
- package/dist/runtime/java/ResponseHook.java +2 -2
- package/dist/runtime/java/Result.java +2 -2
- package/dist/runtime/java/ResumableConnection.java +2 -2
- package/dist/runtime/java/SdkException.java +3 -3
- package/dist/runtime/java/Socket.java +2 -2
- package/dist/runtime/java/Sse.java +2 -2
- package/dist/runtime/java/SseAdapter.java +2 -2
- package/dist/runtime/java/SseEvent.java +2 -2
- package/dist/runtime/java/StaleMeta.java +2 -2
- package/dist/runtime/java/StaleTracker.java +2 -2
- package/dist/runtime/java/Transport.java +2 -2
- package/dist/runtime/java/TransportAdapter.java +2 -2
- package/dist/runtime/java/TransportConnection.java +2 -2
- package/dist/runtime/java/TransportKind.java +2 -2
- package/dist/runtime/java/TransportMessage.java +2 -2
- package/dist/runtime/java/TransportOptions.java +2 -2
- package/dist/runtime/java/TypedWebSocket.java +2 -2
- package/dist/runtime/java/UrlPath.java +2 -2
- package/dist/runtime/java/UrlQuery.java +2 -2
- package/dist/runtime/java/WsAdapter.java +2 -2
- package/dist/runtime/java/WsClose.java +2 -2
- package/dist/runtime/java/WsDial.java +2 -2
- package/dist/runtime/java/WsMessage.java +2 -2
- package/dist/runtime/mcp/call.ts +3 -3
- package/dist/runtime/mcp/result.ts +2 -2
- package/dist/runtime/python/__init__.py +1 -1
- package/dist/runtime/python/auth.py +1 -1
- package/dist/runtime/python/body.py +1 -1
- package/dist/runtime/python/config.py +1 -1
- package/dist/runtime/python/errors.py +11 -11
- package/dist/runtime/python/events.py +4 -4
- package/dist/runtime/python/exchange.py +1 -1
- package/dist/runtime/python/hooks.py +4 -4
- package/dist/runtime/python/invalidation.py +1 -1
- package/dist/runtime/python/log.py +1 -1
- package/dist/runtime/python/operation.py +1 -1
- package/dist/runtime/python/path.py +1 -1
- package/dist/runtime/python/query.py +1 -1
- package/dist/runtime/python/realtime.py +5 -5
- package/dist/runtime/python/redirect.py +1 -1
- package/dist/runtime/python/result.py +1 -1
- package/dist/runtime/python/send_async.py +4 -4
- package/dist/runtime/python/send_sync.py +3 -3
- package/dist/runtime/python/sse.py +1 -1
- package/dist/runtime/python/stale.py +1 -1
- package/dist/runtime/python/transport.py +1 -1
- package/dist/runtime/python/transport_longpoll.py +1 -1
- package/dist/runtime/python/transport_sse.py +1 -1
- package/dist/runtime/python/transport_ws.py +1 -1
- package/dist/runtime/python/ws.py +3 -3
- package/dist/runtime/rust/Cargo.lock +1 -1
- package/dist/runtime/rust/answer.rs +1 -1
- package/dist/runtime/rust/auth.rs +1 -1
- package/dist/runtime/rust/body.rs +2 -2
- package/dist/runtime/rust/call.rs +1 -1
- package/dist/runtime/rust/config.rs +1 -1
- package/dist/runtime/rust/envelope.rs +3 -3
- package/dist/runtime/rust/errors.rs +3 -3
- package/dist/runtime/rust/events.rs +1 -1
- package/dist/runtime/rust/exchange.rs +1 -1
- package/dist/runtime/rust/hooks.rs +1 -1
- package/dist/runtime/rust/invalidation.rs +1 -1
- package/dist/runtime/rust/log.rs +1 -1
- package/dist/runtime/rust/nullable.rs +1 -1
- package/dist/runtime/rust/path.rs +1 -1
- package/dist/runtime/rust/query.rs +1 -1
- package/dist/runtime/rust/realtime.rs +1 -1
- package/dist/runtime/rust/realtime_loop.rs +1 -1
- package/dist/runtime/rust/redirect.rs +1 -1
- package/dist/runtime/rust/request.rs +1 -1
- package/dist/runtime/rust/result.rs +1 -1
- package/dist/runtime/rust/sse.rs +1 -1
- package/dist/runtime/rust/stale.rs +1 -1
- package/dist/runtime/rust/transport.rs +1 -1
- package/dist/runtime/rust/transport_longpoll.rs +1 -1
- package/dist/runtime/rust/transport_sse.rs +1 -1
- package/dist/runtime/rust/transport_ws.rs +1 -1
- package/dist/runtime/rust/ws.rs +1 -1
- package/dist/runtime/ts/app-types.ts +5 -5
- package/dist/runtime/ts/app.ts +5 -5
- package/dist/runtime/ts/http.ts +3 -3
- package/dist/runtime/ts/path.ts +1 -1
- package/dist/runtime/ts/request.ts +1 -1
- package/dist/runtime/ts/sdk.ts +1 -1
- package/package.json +2 -29
package/dist/runtime/mcp/call.ts
CHANGED
|
@@ -146,15 +146,15 @@ export function bindTools(specs: readonly ToolSpec[], client: SdkClient, binding
|
|
|
146
146
|
})
|
|
147
147
|
const answer = (await send({ signal })) as Answer
|
|
148
148
|
const { status } = answer.response
|
|
149
|
-
if (answer.ok) return { ...successOf(spec, answer, scrub), _meta: { "
|
|
149
|
+
if (answer.ok) return { ...successOf(spec, answer, scrub), _meta: { "backend/status": status } }
|
|
150
150
|
/* an error status's JSON object body speaks for it, any other answer its error */
|
|
151
151
|
const { body } = answer.error as { body?: unknown }
|
|
152
152
|
const error = body && typeof body === "object" && !Array.isArray(body) ? body : answer.error
|
|
153
|
-
return { ...failureOf({ error, status }, scrub), _meta: { "
|
|
153
|
+
return { ...failureOf({ error, status }, scrub), _meta: { "backend/status": status } }
|
|
154
154
|
} catch (error) {
|
|
155
155
|
const status = (error as { status?: unknown } | null)?.status
|
|
156
156
|
return typeof status === "number"
|
|
157
|
-
? { ...failureOf({ error, status }, scrub), _meta: { "
|
|
157
|
+
? { ...failureOf({ error, status }, scrub), _meta: { "backend/status": status } }
|
|
158
158
|
: unanswered(error, scrub)
|
|
159
159
|
}
|
|
160
160
|
},
|
|
@@ -42,7 +42,7 @@ function bytesResult(bytes: Uint8Array, type: string, tool: string): ToolResult
|
|
|
42
42
|
content: [
|
|
43
43
|
kind === "image" || kind === "audio"
|
|
44
44
|
? { data, mimeType, type: kind }
|
|
45
|
-
: { resource: { blob: data, mimeType, uri: `
|
|
45
|
+
: { resource: { blob: data, mimeType, uri: `mcp://${tool}/result` }, type: "resource" },
|
|
46
46
|
],
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -65,7 +65,7 @@ export function successOf(
|
|
|
65
65
|
return { ...json(value), structuredContent: value as Record<string, unknown> }
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
/** The result of an `answer` outside 2xx: its status, with
|
|
68
|
+
/** The result of an `answer` outside 2xx: its status, with backend's error envelope its key and message, else its body. */
|
|
69
69
|
export function failureOf({ error, status }: { error: unknown; status: number }, scrub: Scrub): ToolResult {
|
|
70
70
|
if (error instanceof Error)
|
|
71
71
|
return json(scrub({ status, message: error.message, body: (error as { body?: unknown }).body }), true)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The vendored runtime, one module per concern."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The credential: the header that carries it, and the token, refreshed once for concurrent 401s.
|
|
3
3
|
``SDK`` takes a plain ``on_auth_expired`` (never a coroutine run on a thread of its own)."""
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""Every error the SDK raises."""
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
@@ -23,8 +23,8 @@ __all__ = [
|
|
|
23
23
|
"FieldError",
|
|
24
24
|
"ForbiddenError",
|
|
25
25
|
"GatewayTimeoutError",
|
|
26
|
-
"HoneyError",
|
|
27
26
|
"HookError",
|
|
27
|
+
"HttpError",
|
|
28
28
|
"InternalServerError",
|
|
29
29
|
"NotFoundError",
|
|
30
30
|
"PathParamError",
|
|
@@ -35,19 +35,19 @@ __all__ = [
|
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
class
|
|
38
|
+
class HttpError(Exception):
|
|
39
39
|
"""The base of every error the SDK raises."""
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
class ConfigError(
|
|
42
|
+
class ConfigError(HttpError):
|
|
43
43
|
"""A client or call that cannot be built: no usable base URL, or a header value no request carries."""
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
class PathParamError(
|
|
46
|
+
class PathParamError(HttpError):
|
|
47
47
|
"""A path parameter that is missing, or empty, ``.`` or ``..``: nothing is sent."""
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
class APIConnectionError(
|
|
50
|
+
class APIConnectionError(HttpError):
|
|
51
51
|
"""No answer: the connection failed, or the answer was cut off or too large."""
|
|
52
52
|
|
|
53
53
|
|
|
@@ -55,15 +55,15 @@ class APITimeoutError(APIConnectionError):
|
|
|
55
55
|
"""The call ran past its timeout."""
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
class CanceledError(
|
|
58
|
+
class CanceledError(HttpError):
|
|
59
59
|
"""The call's ``cancel`` event fired."""
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
class DecodeError(
|
|
62
|
+
class DecodeError(HttpError):
|
|
63
63
|
"""A success answer whose body is not what the operation declares."""
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
class HookError(
|
|
66
|
+
class HookError(HttpError):
|
|
67
67
|
"""A hook raised; its error is the cause."""
|
|
68
68
|
|
|
69
69
|
|
|
@@ -79,7 +79,7 @@ class FieldError(TypedDict, total=False):
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
class ErrorEnvelope(TypedDict, total=False):
|
|
82
|
-
"""
|
|
82
|
+
"""backend's error envelope: a view of the body's JSON object (empty for any other body), each member
|
|
83
83
|
as the server sent it; ``json.loads(e.body)`` holds the members it does not name."""
|
|
84
84
|
|
|
85
85
|
status: int
|
|
@@ -103,7 +103,7 @@ def sanitized(text: str) -> str:
|
|
|
103
103
|
return kept if len(kept) <= 512 else kept[:512] + "\u2026"
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
class APIStatusError(
|
|
106
|
+
class APIStatusError(HttpError):
|
|
107
107
|
"""An error status: its status, headers, body, envelope and message, and the error key the body
|
|
108
108
|
names (an ``ErrorKey`` member when the API declares it). ``str()`` is ``HTTP <status>: <message>``."""
|
|
109
109
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""An SSE operation's answer: the open stream's events, each one's data decoded. No timeout bounds it.
|
|
3
3
|
An event that does not decode, a cap or a failed read is raised once and ends it; the call's ``cancel``,
|
|
4
4
|
``aclose`` and a cancelled read end it, the cancelled read raising ``CancelledError``. Open it with
|
|
@@ -15,7 +15,7 @@ from typing import Generic, Self, TypeVar, cast
|
|
|
15
15
|
|
|
16
16
|
import httpx2
|
|
17
17
|
|
|
18
|
-
from .errors import APIConnectionError, CanceledError, DecodeError,
|
|
18
|
+
from .errors import APIConnectionError, CanceledError, DecodeError, HttpError, loads
|
|
19
19
|
from .exchange import shaped
|
|
20
20
|
from .sse import RawEvent, SseParser
|
|
21
21
|
|
|
@@ -82,7 +82,7 @@ class EventStream(Generic[T]):
|
|
|
82
82
|
weakref.finalize(self, dropped, self.chunks, response)
|
|
83
83
|
self.parser = SseParser()
|
|
84
84
|
self.pending: deque[RawEvent] = deque()
|
|
85
|
-
self.failure:
|
|
85
|
+
self.failure: HttpError | None = None
|
|
86
86
|
self.ended = False
|
|
87
87
|
self.delivered = ""
|
|
88
88
|
|
|
@@ -133,7 +133,7 @@ class EventStream(Generic[T]):
|
|
|
133
133
|
raise
|
|
134
134
|
|
|
135
135
|
async def end(
|
|
136
|
-
self, failure:
|
|
136
|
+
self, failure: HttpError | None, cause: Exception | None = None
|
|
137
137
|
) -> None:
|
|
138
138
|
if not self.ended:
|
|
139
139
|
if failure is not None:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The sans-IO core every call shares, whichever client sends it: the URL, the header layers (the
|
|
3
3
|
credential last), the idempotency key and request id, each redirect, the retry after a 401, and the
|
|
4
4
|
answer's error class and decoding. The shells only move bytes."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The caller's hooks, TypeScript parity: ``on_request`` before each send, ``on_response`` on each
|
|
3
3
|
answer, in order, sharing one ``state``; a hook that raises ends the call."""
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ from collections.abc import Awaitable, Callable, Mapping, Sequence
|
|
|
9
9
|
from dataclasses import dataclass, field
|
|
10
10
|
from typing import TYPE_CHECKING, Any, TypeVar
|
|
11
11
|
|
|
12
|
-
from .errors import ConfigError,
|
|
12
|
+
from .errors import ConfigError, HookError, HttpError
|
|
13
13
|
|
|
14
14
|
if TYPE_CHECKING:
|
|
15
15
|
from .config import ClientConfig
|
|
@@ -49,8 +49,8 @@ class ResponseContext:
|
|
|
49
49
|
state: dict[str, Any] = field(default_factory=dict, repr=False)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def wrapped(error: Exception, what: str = "hook") ->
|
|
53
|
-
return error if isinstance(error,
|
|
52
|
+
def wrapped(error: Exception, what: str = "hook") -> HttpError:
|
|
53
|
+
return error if isinstance(error, HttpError) else HookError(f"{what}: {error}")
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
def refuse_hooks(config: ClientConfig, sync: bool) -> None:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""A realtime operation's answer: a connection over a chain of transports (WebSocket, then SSE, then
|
|
3
3
|
long-poll) that reconnects after a drop and resumes past the last message it delivered."""
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ from .errors import (
|
|
|
16
16
|
APITimeoutError,
|
|
17
17
|
CanceledError,
|
|
18
18
|
DecodeError,
|
|
19
|
-
|
|
19
|
+
HttpError,
|
|
20
20
|
loads,
|
|
21
21
|
)
|
|
22
22
|
from .events import Cancel, raced
|
|
@@ -98,7 +98,7 @@ class ResumableConnection(Generic[T]):
|
|
|
98
98
|
for adapter in self.adapters:
|
|
99
99
|
try:
|
|
100
100
|
self.conn = await adapter.connect(self.url, self.opts)
|
|
101
|
-
except (
|
|
101
|
+
except (HttpError, OSError) as error:
|
|
102
102
|
if weight(error) == 6 and not refreshed:
|
|
103
103
|
refreshed = True
|
|
104
104
|
refresh = getattr(adapter, "refresh", None)
|
|
@@ -122,7 +122,7 @@ class ResumableConnection(Generic[T]):
|
|
|
122
122
|
full = min(base / 1000 * 2**self.attempts, 30.0)
|
|
123
123
|
await asyncio.sleep(full / 2 + JITTER.uniform(0, full / 2))
|
|
124
124
|
self.attempts += 1
|
|
125
|
-
with contextlib.suppress(
|
|
125
|
+
with contextlib.suppress(HttpError, OSError):
|
|
126
126
|
return await asyncio.wait_for(self.connect(), 30)
|
|
127
127
|
self.state = ConnectionState.DISCONNECTED
|
|
128
128
|
raise self.failure
|
|
@@ -148,7 +148,7 @@ class ResumableConnection(Generic[T]):
|
|
|
148
148
|
try:
|
|
149
149
|
message = await conn.recv()
|
|
150
150
|
failure: Exception = APIConnectionError("the connection ended")
|
|
151
|
-
except (
|
|
151
|
+
except (HttpError, OSError) as error:
|
|
152
152
|
message, failure = None, error
|
|
153
153
|
if message is not None:
|
|
154
154
|
return self.deliver(message)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""Which redirects a call follows (R2): the HTTP client never follows one itself. A hop to another
|
|
3
3
|
origin is followed only under ``"follow"``, stripped to the safe headers, and never carries a body."""
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The async shell: the core's hops sent with ``httpx2.AsyncClient``. An ``asyncio.Event`` ``cancel`` is
|
|
3
3
|
raced against each send; a ``threading.Event`` is checked between steps."""
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ import httpx2
|
|
|
9
9
|
|
|
10
10
|
from .auth import refresh_async
|
|
11
11
|
from .config import ClientConfig, Defaults
|
|
12
|
-
from .errors import APIConnectionError, APITimeoutError,
|
|
12
|
+
from .errors import APIConnectionError, APITimeoutError, HttpError
|
|
13
13
|
from .events import EventStream, raced
|
|
14
14
|
from .exchange import CallArgs, ClientCore, Exchange, HttpAnswer, failure
|
|
15
15
|
from .hooks import RequestContext, refuse_hooks, run_async
|
|
@@ -86,7 +86,7 @@ class AsyncTransport(ClientCore):
|
|
|
86
86
|
raise x.failure or failure(answer, self)
|
|
87
87
|
try:
|
|
88
88
|
x.fill(answer)
|
|
89
|
-
except
|
|
89
|
+
except HttpError:
|
|
90
90
|
await live.aclose()
|
|
91
91
|
raise
|
|
92
92
|
return live
|
|
@@ -101,7 +101,7 @@ class AsyncTransport(ClientCore):
|
|
|
101
101
|
fresh = await refresh_async(self.auth, hook, token)
|
|
102
102
|
if fresh is not None:
|
|
103
103
|
answer, live = await self.attempt(x, fresh, True)
|
|
104
|
-
except
|
|
104
|
+
except HttpError as error:
|
|
105
105
|
x.log.failed(error)
|
|
106
106
|
raise
|
|
107
107
|
except asyncio.CancelledError:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The blocking shell: the core's hops sent with ``httpx2.Client``; ``cancel`` is checked between steps."""
|
|
3
3
|
|
|
4
4
|
from typing import TypeVar, Unpack, cast
|
|
@@ -7,7 +7,7 @@ import httpx2
|
|
|
7
7
|
|
|
8
8
|
from .auth import refresh_sync
|
|
9
9
|
from .config import ClientConfig, Defaults
|
|
10
|
-
from .errors import APIConnectionError, APITimeoutError,
|
|
10
|
+
from .errors import APIConnectionError, APITimeoutError, HttpError
|
|
11
11
|
from .exchange import CallArgs, ClientCore, Exchange, HttpAnswer
|
|
12
12
|
from .hooks import refuse_hooks, run_sync
|
|
13
13
|
from .operation import Operation
|
|
@@ -44,7 +44,7 @@ class SyncTransport(ClientCore):
|
|
|
44
44
|
if hook is not None and x.retries(answer):
|
|
45
45
|
fresh = refresh_sync(self.auth, hook, token)
|
|
46
46
|
answer = answer if fresh is None else self.attempt(x, fresh, True)
|
|
47
|
-
except
|
|
47
|
+
except HttpError as error:
|
|
48
48
|
x.log.failed(error)
|
|
49
49
|
raise
|
|
50
50
|
return x.done(answer)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The WHATWG event-stream parser, over bytes: CRLF, LF or CR line ends; a blank line dispatches; a final
|
|
3
3
|
event without one is dropped; a sticky id (one holding NUL ignored); a digits-only ``retry``. A line is
|
|
4
4
|
capped at 1 MiB and an event's data at 8 MiB, in bytes, whatever the encoding."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""Staleness per ``METHOD /path`` selector, TypeScript parity: exact and pattern keys, a stale window,
|
|
3
3
|
eviction of the least recently staled at the cap, and a sequence so a read clears only what was staled
|
|
4
4
|
before it began. One tracker serves both clients; its lock is never held across an ``await``."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""The realtime transports: what an adapter implements (a caller's own included), the resume cursor each
|
|
3
3
|
dial sends, and the dial the default adapters share: every one through the client's exchange (its hooks,
|
|
4
4
|
log, 401 refresh and current token) with the call's path, query and headers, but a WebSocket's, which runs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @generated by
|
|
1
|
+
# @generated by clients. DO NOT EDIT.
|
|
2
2
|
"""A WebSocket operation's answer: the open socket, messages both ways, JSON on top. The socket lives in
|
|
3
3
|
a task of its own, so any task may use or close it; the call's ``cancel``, ``close`` and a cancelled read
|
|
4
4
|
end it. Open it with ``async with`` or call ``close()`` to free its connection; a dropped socket frees it
|
|
@@ -29,7 +29,7 @@ from .errors import (
|
|
|
29
29
|
APIConnectionError,
|
|
30
30
|
APITimeoutError,
|
|
31
31
|
CanceledError,
|
|
32
|
-
|
|
32
|
+
HttpError,
|
|
33
33
|
status_error,
|
|
34
34
|
)
|
|
35
35
|
from .events import Cancel, raced
|
|
@@ -248,7 +248,7 @@ async def open_socket(
|
|
|
248
248
|
task.cancel()
|
|
249
249
|
if isinstance(error, httpx2.TimeoutException):
|
|
250
250
|
raise APITimeoutError("the call ran past its timeout") from error
|
|
251
|
-
if isinstance(error,
|
|
251
|
+
if isinstance(error, HttpError) or not isinstance(error, Exception):
|
|
252
252
|
raise
|
|
253
253
|
raise APIConnectionError("the WebSocket handshake failed") from error
|
|
254
254
|
return TypedWebSocket(opened.result(), done, task, x.options.get("cancel"))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by
|
|
1
|
+
// @generated by clients. DO NOT EDIT.
|
|
2
2
|
//! How a method reads its answer (G16): JSON into its type, none as `()`, text as a `String`,
|
|
3
3
|
//! binary as bytes. An error status, and a 2xx that does not read (its body past the cap
|
|
4
4
|
//! included), fail with the answer; the call's style settles them (result.rs).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by
|
|
1
|
+
// @generated by clients. DO NOT EDIT.
|
|
2
2
|
//! A request body a method takes as bytes (G4): bytes in memory, or a stream sent as it is read.
|
|
3
3
|
|
|
4
4
|
use bytes::Bytes;
|
|
@@ -88,7 +88,7 @@ pub(crate) struct Multipart {
|
|
|
88
88
|
impl Multipart {
|
|
89
89
|
pub(crate) fn new() -> Self {
|
|
90
90
|
Multipart {
|
|
91
|
-
boundary: format!("
|
|
91
|
+
boundary: format!("clients-{}", crate::auth::new_v4()),
|
|
92
92
|
out: Vec::new(),
|
|
93
93
|
failed: None,
|
|
94
94
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by
|
|
1
|
+
// @generated by clients. DO NOT EDIT.
|
|
2
2
|
//! A method's call (Fb1): `.await` sends it (`IntoFuture`). The method copies its arguments into
|
|
3
3
|
//! the request up front and holds the client's `Arc`, so a `Call` borrows nothing: it can be stored,
|
|
4
4
|
//! moved or spawned. The overrides apply to this call alone. `S` is the client's style: `Throw`
|