@deepraxis/sdk 0.1.1-dev.ddaf60a → 0.1.1-dev.df2f02a
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/METHODS.md +113 -20
- package/dist/core/binary-operations.d.ts +3 -0
- package/dist/core/binary-operations.js +14 -0
- package/dist/core/credentials.d.ts +16 -6
- package/dist/core/credentials.js +24 -5
- package/dist/core/transport.js +8 -4
- package/dist/generated/binary-operations.gen.d.ts +3 -0
- package/dist/generated/binary-operations.gen.js +14 -0
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/sdk.gen.d.ts +190 -58
- package/dist/generated/sdk.gen.js +465 -72
- package/dist/generated/types.gen.d.ts +9950 -3260
- package/dist/helpers/application-publish.js +16 -2
- package/dist/helpers/browser-connect-error.d.ts +28 -0
- package/dist/helpers/browser-connect-error.js +74 -0
- package/dist/helpers/browser-connect.d.ts +2 -0
- package/dist/helpers/browser-connect.js +36 -42
- package/dist/helpers/browser-decisions.d.ts +13 -0
- package/dist/helpers/browser-decisions.js +11 -0
- package/dist/helpers/browser-documentation.d.ts +1 -1
- package/dist/helpers/browser-documentation.js +4 -2
- package/dist/operations.generated.js +1018 -251
- package/dist/resources.generated.d.ts +1843 -336
- package/dist/resources.generated.js +65 -12
- package/package.json +1 -1
package/METHODS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SDK methods
|
|
2
2
|
|
|
3
|
-
Generated by `bun run generate`.
|
|
3
|
+
Generated by `bun run generate`. 865 HTTP operations, plus product aliases. Version segments and path parameters are omitted from resource names. Inputs use typed `{ path, query, body, headers }` options. Collections form nested resource objects; POST actions retain their verb. Naming rules are documented in `scripts/resources.ts`; semantic exceptions and aliases with reasons are in `scripts/naming-overrides.ts`.
|
|
4
4
|
|
|
5
5
|
`always` returns an AsyncIterable; `optional` streams with `{ stream: true }`; `yes` pagination returns a Page. Only `{ data, next_cursor }` + `cursor` query contracts are automatically paginated.
|
|
6
6
|
|
|
@@ -17,7 +17,9 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
17
17
|
| list | GET | `/agent/v1/agents` | no | no |
|
|
18
18
|
| retrieve | GET | `/agent/v1/agents/{agent_id}` | no | no |
|
|
19
19
|
| retrieveAppearance | GET | `/agent/v1/agents/{agent_id}/appearance` | no | no |
|
|
20
|
+
| retrieveEmbedPolicy | GET | `/agent/v1/agents/{agent_id}/embed_policy` | no | no |
|
|
20
21
|
| update | POST | `/agent/v1/agents/{agent_id}` | no | no |
|
|
22
|
+
| updateEmbedPolicy | POST | `/agent/v1/agents/{agent_id}/embed_policy` | no | no |
|
|
21
23
|
|
|
22
24
|
### agent.agents.consolidations
|
|
23
25
|
|
|
@@ -35,25 +37,6 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
35
37
|
| retrieve | GET | `/agent/v1/agents/{agent_id}/customers/{customer_id}` | no | no |
|
|
36
38
|
| retrieveDeletion | GET | `/agent/v1/agents/{agent_id}/customers/{customer_id}/deletion` | no | no |
|
|
37
39
|
|
|
38
|
-
### agent.agents.customers.auth.accessTokens
|
|
39
|
-
|
|
40
|
-
| Method | HTTP | Path | Streaming | Pagination |
|
|
41
|
-
|---|---|---|---|---|
|
|
42
|
-
| create | POST | `/agent/v1/agents/{agent_id}/customers/auth/access_tokens` | no | no |
|
|
43
|
-
| deleteCurrent | DELETE | `/agent/v1/agents/{agent_id}/customers/auth/access_tokens/current` | no | no |
|
|
44
|
-
|
|
45
|
-
### agent.agents.customers.auth.accessTokens.renew
|
|
46
|
-
|
|
47
|
-
| Method | HTTP | Path | Streaming | Pagination |
|
|
48
|
-
|---|---|---|---|---|
|
|
49
|
-
| create | POST | `/agent/v1/agents/{agent_id}/customers/auth/access_tokens/renew` | no | no |
|
|
50
|
-
|
|
51
|
-
### agent.agents.customers.auth.grantCodes
|
|
52
|
-
|
|
53
|
-
| Method | HTTP | Path | Streaming | Pagination |
|
|
54
|
-
|---|---|---|---|---|
|
|
55
|
-
| create | POST | `/agent/v1/agents/{agent_id}/customers/auth/grant_codes` | no | no |
|
|
56
|
-
|
|
57
40
|
### agent.agents.customers.block
|
|
58
41
|
|
|
59
42
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -86,6 +69,13 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
86
69
|
|---|---|---|---|---|
|
|
87
70
|
| list | GET | `/agent/v1/agents/{agent_id}/inbox/letters` | no | no |
|
|
88
71
|
|
|
72
|
+
### agent.agents.phone
|
|
73
|
+
|
|
74
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
75
|
+
|---|---|---|---|---|
|
|
76
|
+
| release | POST | `/agent/v1/agents/{agent_id}/phone/release` | no | no |
|
|
77
|
+
| retrieve | GET | `/agent/v1/agents/{agent_id}/phone` | no | no |
|
|
78
|
+
|
|
89
79
|
### agent.agents.unarchive
|
|
90
80
|
|
|
91
81
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -123,6 +113,7 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
123
113
|
|---|---|---|---|---|
|
|
124
114
|
| list | GET | `/agent/v1/computers/{computer_id}/files` | no | no |
|
|
125
115
|
| retrieveContent | GET | `/agent/v1/computers/{computer_id}/files/content` | no | no |
|
|
116
|
+
| retrievePreview | GET | `/agent/v1/computers/{computer_id}/files/preview` | no | no |
|
|
126
117
|
|
|
127
118
|
### agent.computers.files.convert
|
|
128
119
|
|
|
@@ -197,6 +188,12 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
197
188
|
| retrieveContext | GET | `/agent/v1/sessions/{session_id}/context` | no | no |
|
|
198
189
|
| update | POST | `/agent/v1/sessions/{session_id}` | no | no |
|
|
199
190
|
|
|
191
|
+
### agent.sessions.agentVersion
|
|
192
|
+
|
|
193
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
194
|
+
|---|---|---|---|---|
|
|
195
|
+
| create | POST | `/agent/v1/sessions/{session_id}/agent_version` | no | no |
|
|
196
|
+
|
|
200
197
|
### agent.sessions.artifacts
|
|
201
198
|
|
|
202
199
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -231,6 +228,12 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
231
228
|
| send | POST | `/agent/v1/sessions/{session_id}/events` | no | no |
|
|
232
229
|
| stream | GET | `/agent/v1/sessions/{session_id}/events/stream` | always | no |
|
|
233
230
|
|
|
231
|
+
### agent.sessions.name
|
|
232
|
+
|
|
233
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
234
|
+
|---|---|---|---|---|
|
|
235
|
+
| create | POST | `/agent/v1/sessions/{session_id}/name` | no | no |
|
|
236
|
+
|
|
234
237
|
### agent.sessions.requests
|
|
235
238
|
|
|
236
239
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -298,6 +301,18 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
298
301
|
|---|---|---|---|---|
|
|
299
302
|
| list | GET | `/agent/v1/toolsets` | no | no |
|
|
300
303
|
|
|
304
|
+
### agent.uploads
|
|
305
|
+
|
|
306
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
307
|
+
|---|---|---|---|---|
|
|
308
|
+
| create | POST | `/agent/v1/uploads` | no | no |
|
|
309
|
+
|
|
310
|
+
### agent.uploads.contentUrl
|
|
311
|
+
|
|
312
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
313
|
+
|---|---|---|---|---|
|
|
314
|
+
| create | POST | `/agent/v1/uploads/{file_id}/content_url` | no | no |
|
|
315
|
+
|
|
301
316
|
## application
|
|
302
317
|
|
|
303
318
|
### application.assets.upload
|
|
@@ -580,6 +595,14 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
580
595
|
| list | GET | `/automation/v1/workflows/{ns}/{name}/versions` | no | yes |
|
|
581
596
|
| retrieve | GET | `/automation/v1/workflows/{ns}/{name}/versions/{version}` | no | no |
|
|
582
597
|
|
|
598
|
+
## billing
|
|
599
|
+
|
|
600
|
+
### billing.prices
|
|
601
|
+
|
|
602
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
603
|
+
|---|---|---|---|---|
|
|
604
|
+
| list | GET | `/billing/v1/prices` | no | no |
|
|
605
|
+
|
|
583
606
|
## browser
|
|
584
607
|
|
|
585
608
|
### browser.connect
|
|
@@ -992,6 +1015,7 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
992
1015
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
993
1016
|
|---|---|---|---|---|
|
|
994
1017
|
| abandon | POST | `/devops/v1/changes/{id}:abandon` | no | no |
|
|
1018
|
+
| gitCredential | POST | `/devops/v1/changes/{id}:gitCredential` | no | no |
|
|
995
1019
|
| markLastSlice | POST | `/devops/v1/changes/{id}:markLastSlice` | no | no |
|
|
996
1020
|
| openPullRequest | POST | `/devops/v1/changes/{id}:openPullRequest` | no | no |
|
|
997
1021
|
| retrieve | GET | `/devops/v1/changes/{id}` | no | no |
|
|
@@ -1201,6 +1225,7 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1201
1225
|
|
|
1202
1226
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
1203
1227
|
|---|---|---|---|---|
|
|
1228
|
+
| close | POST | `/devops/v1/pull-requests/{id}:close` | no | no |
|
|
1204
1229
|
| merge | POST | `/devops/v1/pull-requests/{id}:merge` | no | no |
|
|
1205
1230
|
| recordVerdict | POST | `/devops/v1/pull-requests/{id}:recordVerdict` | no | no |
|
|
1206
1231
|
| rerunGate | POST | `/devops/v1/pull-requests/{id}:rerunGate` | no | no |
|
|
@@ -1561,6 +1586,18 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
1561
1586
|
| list | GET | `/media/v1/libraries/{library_id}/understandings` | no | yes |
|
|
1562
1587
|
| retrieveFailureSummary | GET | `/media/v1/libraries/{library_id}/understandings/failure_summary` | no | no |
|
|
1563
1588
|
|
|
1589
|
+
### media.libraries.voices
|
|
1590
|
+
|
|
1591
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1592
|
+
|---|---|---|---|---|
|
|
1593
|
+
| create | POST | `/media/v1/libraries/{library_id}/voices` | no | no |
|
|
1594
|
+
|
|
1595
|
+
### media.libraries.voices.designs
|
|
1596
|
+
|
|
1597
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
1598
|
+
|---|---|---|---|---|
|
|
1599
|
+
| create | POST | `/media/v1/libraries/{library_id}/voices/designs` | no | no |
|
|
1600
|
+
|
|
1564
1601
|
### media.speech
|
|
1565
1602
|
|
|
1566
1603
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -2019,6 +2056,30 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
2019
2056
|
|---|---|---|---|---|
|
|
2020
2057
|
| retrieve | GET | `/registry/v1/packages/{package_id}` | no | no |
|
|
2021
2058
|
|
|
2059
|
+
### registry.packages.git
|
|
2060
|
+
|
|
2061
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2062
|
+
|---|---|---|---|---|
|
|
2063
|
+
| retrieveLog | GET | `/registry/v1/packages/{package_id}/git/log` | no | no |
|
|
2064
|
+
|
|
2065
|
+
### registry.packages.git.commits
|
|
2066
|
+
|
|
2067
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2068
|
+
|---|---|---|---|---|
|
|
2069
|
+
| retrieve | GET | `/registry/v1/packages/{package_id}/git/commits/{sha}` | no | no |
|
|
2070
|
+
|
|
2071
|
+
### registry.packages.git.files
|
|
2072
|
+
|
|
2073
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2074
|
+
|---|---|---|---|---|
|
|
2075
|
+
| retrieve | GET | `/registry/v1/packages/{package_id}/git/files/{path}` | no | no |
|
|
2076
|
+
|
|
2077
|
+
### registry.packages.git.trees
|
|
2078
|
+
|
|
2079
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2080
|
+
|---|---|---|---|---|
|
|
2081
|
+
| retrieve | GET | `/registry/v1/packages/{package_id}/git/trees/{sha}` | no | no |
|
|
2082
|
+
|
|
2022
2083
|
### registry.packages.installations
|
|
2023
2084
|
|
|
2024
2085
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -2066,6 +2127,33 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
2066
2127
|
|
|
2067
2128
|
## sandbox
|
|
2068
2129
|
|
|
2130
|
+
### sandbox.byod.devices
|
|
2131
|
+
|
|
2132
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2133
|
+
|---|---|---|---|---|
|
|
2134
|
+
| list | GET | `/sandbox/v1/byod/devices` | no | no |
|
|
2135
|
+
| retrieve | GET | `/sandbox/v1/byod/devices/{deviceID}` | no | no |
|
|
2136
|
+
| update | PATCH | `/sandbox/v1/byod/devices/{deviceID}` | no | no |
|
|
2137
|
+
|
|
2138
|
+
### sandbox.byod.devices.disconnect
|
|
2139
|
+
|
|
2140
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2141
|
+
|---|---|---|---|---|
|
|
2142
|
+
| create | POST | `/sandbox/v1/byod/devices/{deviceID}/disconnect` | no | no |
|
|
2143
|
+
|
|
2144
|
+
### sandbox.byod.pairings
|
|
2145
|
+
|
|
2146
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2147
|
+
|---|---|---|---|---|
|
|
2148
|
+
| create | POST | `/sandbox/v1/byod/pairings` | no | no |
|
|
2149
|
+
| retrieve | GET | `/sandbox/v1/byod/pairings/{code}` | no | no |
|
|
2150
|
+
|
|
2151
|
+
### sandbox.byod.pairings.claim
|
|
2152
|
+
|
|
2153
|
+
| Method | HTTP | Path | Streaming | Pagination |
|
|
2154
|
+
|---|---|---|---|---|
|
|
2155
|
+
| create | POST | `/sandbox/v1/byod/pairings/{code}/claim` | no | no |
|
|
2156
|
+
|
|
2069
2157
|
### sandbox.events.sandboxes
|
|
2070
2158
|
|
|
2071
2159
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
@@ -2076,6 +2164,7 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
2076
2164
|
|
|
2077
2165
|
| Method | HTTP | Path | Streaming | Pagination |
|
|
2078
2166
|
|---|---|---|---|---|
|
|
2167
|
+
| act | POST | `/sandbox/v1/sandboxes/{sandboxID}/act` | no | no |
|
|
2079
2168
|
| connect | POST | `/sandbox/v1/sandboxes/{sandboxID}/connect` | no | no |
|
|
2080
2169
|
| create | POST | `/sandbox/v1/sandboxes` | no | no |
|
|
2081
2170
|
| delete | DELETE | `/sandbox/v1/sandboxes/{sandboxID}` | no | no |
|
|
@@ -2618,7 +2707,10 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
2618
2707
|
|
|
2619
2708
|
| Operation | Reason |
|
|
2620
2709
|
|---|---|
|
|
2710
|
+
| agent.agents.updateEmbedPolicy | The embed policy is a singleton of the agent; POST updates it in part, so it pairs with retrieveEmbedPolicy as agents.updateEmbedPolicy rather than a nested embedPolicy collection create. |
|
|
2621
2711
|
| agent.agents.events.send | ADR-123 (#1550): the agent-subject door fires the session events operation, so it takes the same product verb as sessions.events.send; the path alone would derive events.create. |
|
|
2712
|
+
| agent.agents.phone.retrieve | ticket-3311: reading the agent's cloud phone is agents.phone.retrieve; the path alone would derive agents.retrievePhone, which does not name the sub-resource. |
|
|
2713
|
+
| agent.agents.phone.release | ticket-3311: release is the act on the agent's cloud phone (the row is marked, then the cron archives and kills it); the path alone would derive agents.phone.release.create. |
|
|
2622
2714
|
| agent.sessions.events.send | Events submit session input; the product verb is send rather than create. |
|
|
2623
2715
|
| automation.hooks.send | Delivers a payload to a trigger's secret webhook URL; it sends an event rather than updating a hook resource. |
|
|
2624
2716
|
| automation.scripts.distTags.set | A dist-tag assigns a version to a name; use npm vocabulary set rather than update. |
|
|
@@ -2667,6 +2759,7 @@ Multipart request bodies expand plain objects into bracketed fields (for example
|
|
|
2667
2759
|
| media.images.generate | ADR-094 §9 names image generation images.generate; the URL mounts it under a library, but generation is an operation on images and the path alone would derive a generations collection create. |
|
|
2668
2760
|
| media.videos.generate | ADR-094 §2/§9 names video generation videos.generate beside images.generate; the URL mounts it under a library, but generation is an operation on videos and the path alone would derive a generations collection create. The unqualified videos resource is the video lane, distinct from the batch and legacy job resources. |
|
|
2669
2761
|
| meta.docs.search | Documentation keyword search is an operation on docs, not a nested collection. |
|
|
2762
|
+
| sandbox.sandboxes.act | ticket-3311: act is the one display door of an addressed phone sandbox; the URL spells the operation but the generic post rule would derive sandboxes.create, colliding with createSandbox. |
|
|
2670
2763
|
| sandbox.sandboxes.commands.run | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
2671
2764
|
| sandbox.sandboxes.files.remove | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
2672
2765
|
| sandbox.sandboxes.files.read | Sandbox data operations use the E2B SDK verb while preserving URL resource nesting. |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as sdk from "../generated/sdk.gen.js";
|
|
2
|
+
import { binaryOperations } from "../generated/binary-operations.gen.js";
|
|
3
|
+
/**
|
|
4
|
+
* The generated SDK operations whose success response the OpenAPI declares as binary bytes
|
|
5
|
+
* (generated from the spec into `binary-operations.gen.ts`). Resolved by function identity, so
|
|
6
|
+
* wrapping, renaming or minification cannot change the answer.
|
|
7
|
+
*/
|
|
8
|
+
const binary = new Set(binaryOperations
|
|
9
|
+
.map(name => sdk[name])
|
|
10
|
+
.filter((operation) => typeof operation === 'function'));
|
|
11
|
+
/** Whether this operation's 200 response is the declared bytes of the resource, not a JSON body. */
|
|
12
|
+
export function isBinaryOperation(operation) {
|
|
13
|
+
return binary.has(operation);
|
|
14
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Default credential chain
|
|
3
|
-
* the PRAXIS_API_TOKEN environment variable
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Default credential chain (ticket-5367, ADR-098 §2, ADR-157), the same rule as the `praxis` CLI:
|
|
3
|
+
* 1. the PRAXIS_API_TOKEN environment variable;
|
|
4
|
+
* 2. PRAXIS_CWD set: `$PRAXIS_CWD/.praxis/credentials/<env>.json` and nothing else — no file there means no token,
|
|
5
|
+
* never the home's login and never a parent directory's;
|
|
6
|
+
* 3. otherwise the home: `~/.praxis/credentials/<env>.json`, and while that file is absent the legacy
|
|
7
|
+
* `~/.praxis/cli/<env>.json` that `praxis login` wrote before ADR-157 and the platform still writes for a
|
|
8
|
+
* managed login.
|
|
9
|
+
* Resolved at call time so a token the platform renewed in the file is picked up by an already-running process.
|
|
7
10
|
*/
|
|
8
11
|
export interface ResolvedCredentials {
|
|
9
12
|
token?: string;
|
|
@@ -17,7 +20,14 @@ type ReadFile = (path: string) => string | null;
|
|
|
17
20
|
* applies. A PRAXIS_ENV that is not a plain name is no environment at all and is ignored. Pure.
|
|
18
21
|
*/
|
|
19
22
|
export declare function credentialsEnv(env: Env): string;
|
|
20
|
-
/** The
|
|
23
|
+
/** The credential file of one directory: `<dir>/.praxis/credentials/<env>.json`. Pure. */
|
|
24
|
+
export declare function credentialsFileIn(dir: string, env: Env): string;
|
|
25
|
+
/**
|
|
26
|
+
* The credential files this process reads, in order (ADR-157): a PRAXIS_CWD directory is the only one when named;
|
|
27
|
+
* otherwise the home's file and then its legacy login file. Empty without a home directory. Pure.
|
|
28
|
+
*/
|
|
29
|
+
export declare function credentialsPaths(env: Env): string[];
|
|
30
|
+
/** The first file this process would read (the one `praxis login` writes). Null without a home directory. Pure. */
|
|
21
31
|
export declare function credentialsPath(env: Env): string | null;
|
|
22
32
|
export declare function resolveDefaultCredentials(env?: Env, readFile?: ReadFile): ResolvedCredentials;
|
|
23
33
|
export {};
|
package/dist/core/credentials.js
CHANGED
|
@@ -27,18 +27,37 @@ export function credentialsEnv(env) {
|
|
|
27
27
|
}
|
|
28
28
|
return 'production';
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const trimSlashes = (path) => path.replace(/[/\\]+$/, '') || path;
|
|
31
|
+
/** The credential file of one directory: `<dir>/.praxis/credentials/<env>.json`. Pure. */
|
|
32
|
+
export function credentialsFileIn(dir, env) {
|
|
33
|
+
return `${trimSlashes(dir)}/.praxis/credentials/${credentialsEnv(env)}.json`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The credential files this process reads, in order (ADR-157): a PRAXIS_CWD directory is the only one when named;
|
|
37
|
+
* otherwise the home's file and then its legacy login file. Empty without a home directory. Pure.
|
|
38
|
+
*/
|
|
39
|
+
export function credentialsPaths(env) {
|
|
40
|
+
const named = nonEmpty(env.PRAXIS_CWD);
|
|
41
|
+
if (named)
|
|
42
|
+
return [credentialsFileIn(named, env)];
|
|
32
43
|
const home = nonEmpty(env.HOME) ?? nonEmpty(env.USERPROFILE);
|
|
33
|
-
return home ? `${home
|
|
44
|
+
return home ? [credentialsFileIn(home, env), `${trimSlashes(home)}/.praxis/cli/${credentialsEnv(env)}.json`] : [];
|
|
45
|
+
}
|
|
46
|
+
/** The first file this process would read (the one `praxis login` writes). Null without a home directory. Pure. */
|
|
47
|
+
export function credentialsPath(env) {
|
|
48
|
+
return credentialsPaths(env)[0] ?? null;
|
|
34
49
|
}
|
|
35
50
|
export function resolveDefaultCredentials(env = globalThis.process?.env ?? {}, readFile = defaultReadFile) {
|
|
36
51
|
const envToken = nonEmpty(env.PRAXIS_API_TOKEN);
|
|
37
52
|
const envUrl = nonEmpty(env.PRAXIS_API_URL);
|
|
38
53
|
if (envToken)
|
|
39
54
|
return { token: envToken, ...(envUrl ? { apiUrl: envUrl } : {}) };
|
|
40
|
-
|
|
41
|
-
const
|
|
55
|
+
let text = null;
|
|
56
|
+
for (const path of credentialsPaths(env)) {
|
|
57
|
+
text = readFile(path);
|
|
58
|
+
if (text)
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
42
61
|
if (!text)
|
|
43
62
|
return envUrl ? { apiUrl: envUrl } : {};
|
|
44
63
|
try {
|
package/dist/core/transport.js
CHANGED
|
@@ -3,6 +3,7 @@ import { PraxisError, PraxisTimeoutError } from "./errors.js";
|
|
|
3
3
|
import { abortable, fetchWithRetry } from "./retry.js";
|
|
4
4
|
import { parseSSE } from "./sse.js";
|
|
5
5
|
import { resolveDefaultCredentials } from "./credentials.js";
|
|
6
|
+
import { isBinaryOperation } from "./binary-operations.js";
|
|
6
7
|
/** Our own per-call keys, beyond what the generated hey-api client accepts. */
|
|
7
8
|
const SDK_OPTION_KEYS = ['timeoutMs', 'maxRetries', 'stream', 'lastEventId'];
|
|
8
9
|
/** Every key of the generated client's per-call RequestOptions (request parts, fetch/RequestInit, serializers,
|
|
@@ -55,7 +56,7 @@ export class Transport {
|
|
|
55
56
|
if (!Number.isSafeInteger(retries) || retries < 0)
|
|
56
57
|
throw new RangeError('maxRetries must be a non-negative integer');
|
|
57
58
|
}
|
|
58
|
-
scope(options, streaming) {
|
|
59
|
+
scope(operation, options, streaming) {
|
|
59
60
|
assertKnownOptions(options);
|
|
60
61
|
const timeoutMs = options.timeoutMs ?? Math.max(this.config.timeoutMs, serverDeadlineMs(options));
|
|
61
62
|
const maxRetries = options.maxRetries ?? this.config.maxRetries;
|
|
@@ -98,7 +99,10 @@ export class Transport {
|
|
|
98
99
|
}
|
|
99
100
|
return {
|
|
100
101
|
signal,
|
|
101
|
-
|
|
102
|
+
// A binary operation is parsed as a Blob whatever the server says in Content-Type: the runtime
|
|
103
|
+
// value must match the declared `Blob | File`, and JSON bytes must survive as bytes.
|
|
104
|
+
options: { ...options, headers: Object.fromEntries(headers), client, signal, throwOnError: true, responseStyle: 'fields',
|
|
105
|
+
...(streaming ? { parseAs: 'stream' } : isBinaryOperation(operation) ? { parseAs: 'blob' } : {}) },
|
|
102
106
|
close() { clearTimeout(timer); external?.removeEventListener('abort', abort); },
|
|
103
107
|
};
|
|
104
108
|
}
|
|
@@ -107,7 +111,7 @@ export class Transport {
|
|
|
107
111
|
}
|
|
108
112
|
/** Internal helper access to response metadata, with the same request policy. */
|
|
109
113
|
async requestWithResponse(operation, options = {}) {
|
|
110
|
-
const scope = this.scope(options, false);
|
|
114
|
+
const scope = this.scope(operation, options, false);
|
|
111
115
|
try {
|
|
112
116
|
const result = await abortable(operation(scope.options), scope.signal);
|
|
113
117
|
return { data: result.data, response: result.response };
|
|
@@ -117,7 +121,7 @@ export class Transport {
|
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
123
|
async *stream(operation, options = {}) {
|
|
120
|
-
const scope = this.scope(options, true);
|
|
124
|
+
const scope = this.scope(operation, options, true);
|
|
121
125
|
try {
|
|
122
126
|
const result = await abortable(operation(scope.options), scope.signal);
|
|
123
127
|
if (!result.response.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase().includes('text/event-stream')) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Generated by scripts/resources.ts. DO NOT EDIT.
|
|
2
|
+
/** Exported SDK operations whose 2xx response the OpenAPI declares as binary bytes: the core
|
|
3
|
+
* transport resolves them to a Blob whatever the response Content-Type says. */
|
|
4
|
+
export const binaryOperations = [
|
|
5
|
+
'browserGetSessionFrame',
|
|
6
|
+
'computersFilesContent',
|
|
7
|
+
'createAudioSpeech',
|
|
8
|
+
'downloadVideoContent',
|
|
9
|
+
'fileRetrieveFileContent',
|
|
10
|
+
'registryGitFilesRetrieve',
|
|
11
|
+
'registryPackagesVersionsArchive',
|
|
12
|
+
'registryPackagesVersionsFilesRetrieve',
|
|
13
|
+
'skillsVersionsDownload',
|
|
14
|
+
];
|