@deepraxis/sdk 0.0.0-stage → 0.1.0-dev.ea77ce8

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.
Files changed (64) hide show
  1. package/LICENSE +202 -0
  2. package/METHODS.md +1126 -0
  3. package/README.md +279 -2
  4. package/dist/automation.d.ts +151 -0
  5. package/dist/automation.js +8 -0
  6. package/dist/core/bindings.d.ts +25 -0
  7. package/dist/core/bindings.js +45 -0
  8. package/dist/core/client.d.ts +15 -0
  9. package/dist/core/client.js +15 -0
  10. package/dist/core/credentials.d.ts +14 -0
  11. package/dist/core/credentials.js +33 -0
  12. package/dist/core/errors.d.ts +38 -0
  13. package/dist/core/errors.js +60 -0
  14. package/dist/core/multipart.d.ts +2 -0
  15. package/dist/core/multipart.js +25 -0
  16. package/dist/core/pagination.d.ts +12 -0
  17. package/dist/core/pagination.js +26 -0
  18. package/dist/core/retry.d.ts +13 -0
  19. package/dist/core/retry.js +56 -0
  20. package/dist/core/sse.d.ts +13 -0
  21. package/dist/core/sse.js +67 -0
  22. package/dist/core/transport.d.ts +36 -0
  23. package/dist/core/transport.js +121 -0
  24. package/dist/generated/client/client.gen.d.ts +2 -0
  25. package/dist/generated/client/client.gen.js +216 -0
  26. package/dist/generated/client/index.d.ts +10 -0
  27. package/dist/generated/client/index.js +6 -0
  28. package/dist/generated/client/types.gen.d.ts +120 -0
  29. package/dist/generated/client/types.gen.js +2 -0
  30. package/dist/generated/client/utils.gen.d.ts +37 -0
  31. package/dist/generated/client/utils.gen.js +228 -0
  32. package/dist/generated/client.gen.d.ts +12 -0
  33. package/dist/generated/client.gen.js +3 -0
  34. package/dist/generated/core/auth.gen.d.ts +25 -0
  35. package/dist/generated/core/auth.gen.js +14 -0
  36. package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
  37. package/dist/generated/core/bodySerializer.gen.js +57 -0
  38. package/dist/generated/core/params.gen.d.ts +43 -0
  39. package/dist/generated/core/params.gen.js +109 -0
  40. package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
  41. package/dist/generated/core/pathSerializer.gen.js +106 -0
  42. package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
  43. package/dist/generated/core/queryKeySerializer.gen.js +92 -0
  44. package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
  45. package/dist/generated/core/serverSentEvents.gen.js +132 -0
  46. package/dist/generated/core/types.gen.d.ts +83 -0
  47. package/dist/generated/core/types.gen.js +2 -0
  48. package/dist/generated/core/utils.gen.d.ts +19 -0
  49. package/dist/generated/core/utils.gen.js +87 -0
  50. package/dist/generated/index.d.ts +2 -0
  51. package/dist/generated/index.js +2 -0
  52. package/dist/generated/sdk.gen.d.ts +2172 -0
  53. package/dist/generated/sdk.gen.js +6579 -0
  54. package/dist/generated/types.gen.d.ts +56802 -0
  55. package/dist/generated/types.gen.js +2 -0
  56. package/dist/helpers/application-publish.d.ts +41 -0
  57. package/dist/helpers/application-publish.js +116 -0
  58. package/dist/index.d.ts +9 -0
  59. package/dist/index.js +5 -0
  60. package/dist/operations.generated.d.ts +10965 -0
  61. package/dist/operations.generated.js +13837 -0
  62. package/dist/resources.generated.d.ts +3852 -0
  63. package/dist/resources.generated.js +724 -0
  64. package/package.json +50 -4
package/README.md CHANGED
@@ -1,3 +1,280 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # Praxis TypeScript SDK
4
+
5
+ **Models, agents, sandboxes, search, data and automation, typed end to end.**
6
+
7
+ The official TypeScript SDK for [知行云 Praxis](https://deepraxis.com), the cloud where AI agents are built, run and hosted.
8
+
9
+ [![npm](https://img.shields.io/npm/v/@deepraxis/sdk?label=npm&color=2e8555)](https://www.npmjs.com/package/@deepraxis/sdk)
10
+ [![Bundle size](https://img.shields.io/bundlephobia/minzip/@deepraxis/sdk?color=2e8555)](https://bundlephobia.com/package/@deepraxis/sdk)
11
+ [![License](https://img.shields.io/badge/license-Apache--2.0-2e8555)](https://www.apache.org/licenses/LICENSE-2.0)
12
+
13
+ [Website](https://deepraxis.com) · [Documentation](https://docs.deepraxis.com) · [API reference](https://docs.deepraxis.com/docs/api) · [Console](https://console.deepraxis.com)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ```ts
20
+ import { Praxis } from '@deepraxis/sdk';
21
+
22
+ const praxis = new Praxis({ apiKey: process.env.PRAXIS_API_KEY! });
23
+
24
+ const completion = await praxis.model.chat.completions.create({
25
+ body: {
26
+ model: 'deepseek-flash',
27
+ messages: [{ role: 'user', content: 'Hello!' }],
28
+ },
29
+ });
30
+ console.log(completion.choices[0]?.message.content);
31
+ ```
32
+
33
+ ## Why this SDK
34
+
35
+ - **The whole platform, one client.** About 350 operations across models, agents, sandboxes,
36
+ cloud browsers, web search, databases, knowledge bases, files, media, automation and hosted
37
+ applications, generated from the same contract as the API.
38
+ - **Types from the contract.** Every path, query, body and response is typed, including the
39
+ events of each stream, so your editor knows what comes back.
40
+ - **Zero dependencies, any runtime.** Plain `fetch`: Node.js 20+, Bun, Deno, Cloudflare Workers and
41
+ browsers, with nothing to polyfill.
42
+ - **Production behavior built in.** Timeouts, retries with backoff that honor `Retry-After`,
43
+ automatic pagination, cancellation and typed errors carrying a request id.
44
+
45
+ ## Install
46
+
47
+ ```sh
48
+ npm install @deepraxis/sdk # or: pnpm add / yarn add / bun add
49
+ ```
50
+
51
+ Create an API key in the [Console](https://console.deepraxis.com/keys) and keep it on the
52
+ server. You need a Praxis account; sign up at [deepraxis.com](https://deepraxis.com).
53
+
54
+ ```ts
55
+ const praxis = new Praxis({
56
+ apiKey: process.env.PRAXIS_API_KEY!,
57
+ baseUrl: 'https://api.deepraxis.com', // default
58
+ timeoutMs: 60_000, // default; the whole call, body included
59
+ maxRetries: 2, // default
60
+ // fetch: customFetch, // bring your own fetch
61
+ });
62
+ ```
63
+
64
+ Every method takes one typed object, `{ path, query, body, headers }`, plus optional `signal`,
65
+ `timeoutMs` and `maxRetries` for that call.
66
+
67
+ ## Examples
68
+
69
+ ### Stream a reply
70
+
71
+ ```ts
72
+ const stream = await praxis.model.chat.completions.create({
73
+ body: {
74
+ model: 'deepseek-flash',
75
+ messages: [{ role: 'user', content: 'Count to five' }],
76
+ },
77
+ stream: true,
78
+ });
79
+ for await (const chunk of stream) {
80
+ console.log(chunk.data);
81
+ }
82
+ ```
83
+
84
+ Methods that offer both JSON and server-sent events stream when you pass `stream: true` at the
85
+ top level. Breaking out of the loop cancels the request.
86
+
87
+ ### Run an agent
88
+
89
+ ```ts
90
+ const agent = await praxis.agent.agents.create({
91
+ body: {
92
+ name: 'helper',
93
+ model: { id: 'deepseek-flash' },
94
+ tools: [{ type: 'agent_toolset_20260401' }],
95
+ },
96
+ });
97
+ const { sessions } = praxis.agent;
98
+ const session = await sessions.create({
99
+ body: { agent: agent.id },
100
+ });
101
+ const path = { session_id: session.id };
102
+
103
+ await sessions.events.send({
104
+ path,
105
+ body: {
106
+ events: [{
107
+ type: 'user.message',
108
+ content: [{ type: 'text', text: 'What can you do?' }],
109
+ }],
110
+ },
111
+ });
112
+ for await (const event of sessions.events.stream({ path })) {
113
+ console.log(event.event, event.data);
114
+ }
115
+ ```
116
+
117
+ An agent is a reusable definition: model, instructions and tools. Each session is one
118
+ conversation with it, on its own machine.
119
+
120
+ ### Run code in a sandbox
121
+
122
+ ```ts
123
+ const { sandboxes } = praxis.sandbox;
124
+ const sandbox = await sandboxes.create({
125
+ body: { templateID: 'base' },
126
+ });
127
+ const result = await sandboxes.commands.run({
128
+ path: { sandbox_id: sandbox.sandboxID },
129
+ body: { cmd: "python3 -c 'print(6 * 7)'" },
130
+ });
131
+ console.log(result);
132
+ await sandboxes.delete({ path: { sandboxID: sandbox.sandboxID } });
133
+ ```
134
+
135
+ ### Search the web
136
+
137
+ ```ts
138
+ const { results } = await praxis.search.search.create({
139
+ body: { query: 'AI agent frameworks', max_results: 5 },
140
+ });
141
+ for (const r of results ?? []) console.log(r.title, r.url);
142
+ ```
143
+
144
+ ### Run a script and wait for it
145
+
146
+ ```ts
147
+ const run = await praxis.automation.runs.create({
148
+ body: {
149
+ source: `export default async (input: { n: number }) =>
150
+ ({ answer: input.n + 1 });`,
151
+ language: 'ts',
152
+ input: { n: 41 },
153
+ wait: 60,
154
+ },
155
+ headers: { 'Idempotency-Key': crypto.randomUUID() },
156
+ timeoutMs: 90_000,
157
+ });
158
+ console.log(run.status, run.output);
159
+ ```
160
+
161
+ `wait` is how long the server holds the request, in seconds. A run that is still going comes
162
+ back unfinished; read it again with `praxis.automation.runs.retrieve({ path: { id: run.id } })`.
163
+ A successful HTTP response does not mean the script succeeded, so check `status`.
164
+
165
+ ## Pagination
166
+
167
+ ```ts
168
+ const page = await praxis.automation.runs.list({
169
+ query: { limit: 20 },
170
+ });
171
+ console.log(page.data, page.next_cursor); // this page only
172
+ for await (const run of page) {
173
+ console.log(run.id); // every page, fetched as you go
174
+ }
175
+ const next = await page.nextPage(); // next Page, or null
176
+ ```
177
+
178
+ Lists with a `cursor` contract return a `Page`. Iteration keeps your filters, headers and
179
+ cancellation, and gives each page its own timeout. Other lists keep the response shape of their
180
+ API; [METHODS.md](https://unpkg.com/@deepraxis/sdk/METHODS.md) marks which is which.
181
+
182
+ ## Errors and retries
183
+
184
+ ```ts
185
+ import {
186
+ PraxisError, PraxisConnectionError, PraxisTimeoutError,
187
+ } from '@deepraxis/sdk';
188
+
189
+ try {
190
+ await praxis.automation.runs.list({ query: { limit: 0 } });
191
+ } catch (error) {
192
+ if (error instanceof PraxisTimeoutError) {
193
+ console.error('Request timed out');
194
+ } else if (error instanceof PraxisConnectionError) {
195
+ console.error('Connection failed');
196
+ } else if (error instanceof PraxisError) {
197
+ const { status, code, detail, requestId } = error;
198
+ console.error(status, code, detail, requestId);
199
+ } else {
200
+ throw error; // includes your own cancellation
201
+ }
202
+ }
203
+ ```
204
+
205
+ `PraxisError` carries the problem details of the response: `status`, `code`, `type`, `title`,
206
+ `detail`, `errors` and `requestId`. Quote the request id when you contact support.
207
+
208
+ The SDK retries 408, 429, 5xx and connection failures with exponential backoff and jitter, and
209
+ waits as long as `Retry-After` asks. **A POST is retried only when it has an `Idempotency-Key`**,
210
+ so a retry can never run an action twice. The call's timeout bounds the retries too.
211
+
212
+ ## Server-sent events
213
+
214
+ Streams such as `automation.runs.events`, `automation.runs.logs` and agent session events return
215
+ an `AsyncIterable` directly. Each frame has optional `id` and `event`; `data` is parsed as JSON
216
+ when possible. To resume after a disconnect, pass the last `id` you saw:
217
+
218
+ ```ts
219
+ let lastEventId: string | undefined;
220
+ const events = praxis.automation.runs.events({
221
+ path: { id: run.id },
222
+ lastEventId,
223
+ });
224
+ for await (const event of events) {
225
+ lastEventId = event.id ?? lastEventId;
226
+ console.log(event.event, event.data);
227
+ }
228
+ ```
229
+
230
+ `parseSSE` is exported for streams you read yourself.
231
+
232
+ ## Smaller bundles
233
+
234
+ Import one domain when that is all you need:
235
+
236
+ ```ts
237
+ import { createAutomationClient } from '@deepraxis/sdk/automation';
238
+
239
+ const automation = createAutomationClient({
240
+ apiKey: process.env.PRAXIS_API_KEY!,
241
+ });
242
+ const runs = await automation.runs.list();
243
+ ```
244
+
245
+ Schema types are available from `@deepraxis/sdk/types`.
246
+
247
+ ## Inside a Praxis script
248
+
249
+ Hosted automation scripts already have `praxis` and `call` in scope. Don't install the SDK there:
250
+
251
+ ```ts
252
+ export default async (input: { prompt: string }) => {
253
+ return await call('praxis/chat', {
254
+ model: 'deepseek-flash',
255
+ messages: [{ role: 'user', content: input.prompt }],
256
+ stream: false,
257
+ });
258
+ };
259
+ ```
260
+
261
+ ## Already using the OpenAI or Anthropic SDK?
262
+
263
+ Keep your code and point the official SDK at Praxis by changing `baseURL`, for example
264
+ `https://api.deepraxis.com/openai/v1` for the OpenAI SDK. The
265
+ [SDK cookbook](https://docs.deepraxis.com/docs/cookbook/sdk) has the details for OpenAI,
266
+ Anthropic, the Vercel AI SDK and LangChain. This SDK covers what those don't: agents,
267
+ sandboxes, search, data, automation and the rest of the platform.
268
+
269
+ ## Resources
270
+
271
+ - [Documentation](https://docs.deepraxis.com) and [API reference](https://docs.deepraxis.com/docs/api)
272
+ - [METHODS.md](https://unpkg.com/@deepraxis/sdk/METHODS.md): every method, its HTTP route, and whether it streams or paginates
273
+ - [Praxis CLI](https://www.npmjs.com/package/@deepraxis/cli): the same API from your terminal
274
+
275
+ ## License
276
+
277
+ [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). Copyright 2026 南京深度实践人工智能科技有限公司 (Deepractice).
278
+
279
+ "Praxis", "知行云" and "Deepraxis" are trademarks of Deepractice; the license does not grant
280
+ rights to use them.
@@ -0,0 +1,151 @@
1
+ import { type PraxisOptions } from './core/transport.js';
2
+ /** An automation-only entry point: other resource factories tree-shake away. */
3
+ export declare function createAutomationClient(options: PraxisOptions): {
4
+ actions: {
5
+ archive: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsArchiveData>) => Promise<import("./generated/types.gen.js").AutomationActionArchiveResult>;
6
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsCreateData>) => Promise<import("./generated/types.gen.js").AutomationActionDef>;
7
+ dependents: {
8
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsDependentsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationDependent>>;
9
+ };
10
+ invocations: {
11
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsInvocationsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationInvocation>>;
12
+ };
13
+ list: (options?: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsListData> | undefined) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationActionListItem>>;
14
+ restore: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsRestoreData>) => Promise<import("./generated/types.gen.js").AutomationActionDef>;
15
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsGetData>) => Promise<import("./generated/types.gen.js").AutomationActionDef>;
16
+ revisions: {
17
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsRevisionsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationRevisionSummary>>;
18
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsRevisionData>) => Promise<import("./generated/types.gen.js").AutomationRevisionListItem>;
19
+ };
20
+ rollback: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsRollbackData>) => Promise<import("./generated/types.gen.js").AutomationActionDef>;
21
+ update: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationActionsUpdateData>) => Promise<import("./generated/types.gen.js").AutomationActionUpdateResult>;
22
+ };
23
+ hooks: {
24
+ send: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationHooksReceiveData>) => Promise<import("./generated/types.gen.js").AutomationFiring>;
25
+ };
26
+ resolve: {
27
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationResolveResolveData>) => Promise<import("./generated/types.gen.js").AutomationResolveResult>;
28
+ };
29
+ runs: {
30
+ artifacts: {
31
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsArtifactsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationRunArtifact>>;
32
+ };
33
+ calls: {
34
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsCallsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationCall>>;
35
+ };
36
+ cancel: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsCancelData>) => Promise<import("./generated/types.gen.js").AutomationRun>;
37
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsCreateData>) => Promise<import("./generated/types.gen.js").AutomationRun>;
38
+ events: (options: import("./core/transport.js").StreamOptions<import("./generated/types.gen.js").AutomationRunsEventsData>) => AsyncIterable<import("./generated/types.gen.js").PraxisSdkSseGetAutomationV1RunsIdEvents>;
39
+ list: (options?: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsListData> | undefined) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationRun>>;
40
+ logs: (options: import("./core/transport.js").StreamOptions<import("./generated/types.gen.js").AutomationRunsLogsData>) => AsyncIterable<import("./generated/types.gen.js").PraxisSdkSseGetAutomationV1RunsIdLogs>;
41
+ rerun: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsRerunData>) => Promise<import("./generated/types.gen.js").AutomationRun>;
42
+ resume: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsResumeData>) => Promise<import("./generated/types.gen.js").AutomationRun>;
43
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsGetData>) => Promise<import("./generated/types.gen.js").AutomationExpandedRun>;
44
+ retrieveSource: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsSourceData>) => Promise<{
45
+ language: import("./generated/types.gen.js").AutomationSourceLanguage;
46
+ source: string;
47
+ sha256: string;
48
+ }>;
49
+ suspend: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsSuspendData>) => Promise<import("./generated/types.gen.js").AutomationRun>;
50
+ tasks: {
51
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsTasksData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationTask | import("./generated/types.gen.js").AutomationTaskGroup>>;
52
+ };
53
+ waits: {
54
+ complete: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsCompleteWaitData>) => Promise<{
55
+ id: string;
56
+ run_id: string;
57
+ kind: "event" | "timer" | "child";
58
+ state: "cancelled" | "open" | "resolved" | "expired";
59
+ task: null | {
60
+ reference: string;
61
+ name: string;
62
+ };
63
+ resume_at: null | string;
64
+ event_type: null | string;
65
+ child_run_id: null | string;
66
+ created_at: string;
67
+ expires_at: null | string;
68
+ resolved_at: null | string;
69
+ replayed: boolean;
70
+ }>;
71
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationRunsWaitsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationWait>>;
72
+ };
73
+ };
74
+ scripts: {
75
+ archive: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsArchiveData>) => Promise<import("./generated/types.gen.js").AutomationDefinition>;
76
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsCreateData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
77
+ distTags: {
78
+ delete: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsDeleteDistTagData>) => Promise<{
79
+ [key: string]: import("./generated/types.gen.js").AutomationDistTag;
80
+ }>;
81
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsDistTagsData>) => Promise<{
82
+ [key: string]: import("./generated/types.gen.js").AutomationDistTag;
83
+ }>;
84
+ set: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsSetDistTagData>) => Promise<{
85
+ [key: string]: import("./generated/types.gen.js").AutomationDistTag;
86
+ }>;
87
+ };
88
+ list: (options?: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsListData> | undefined) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationDefinition>>;
89
+ restore: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsRestoreData>) => Promise<import("./generated/types.gen.js").AutomationDefinition>;
90
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsGetData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
91
+ update: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsPatchData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
92
+ versions: {
93
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsPublishData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
94
+ deprecate: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsDeprecateData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
95
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsVersionsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationVersionListItem>>;
96
+ publish: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsPublishData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
97
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsVersionData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
98
+ };
99
+ };
100
+ targets: {
101
+ list: (options?: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTargetsTargetsData> | undefined) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationTargetHit>>;
102
+ };
103
+ triggers: {
104
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersCreateData>) => Promise<import("./generated/types.gen.js").AutomationTriggerCreateResult>;
105
+ delete: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersDeleteData>) => Promise<void>;
106
+ fire: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersFireData>) => Promise<import("./generated/types.gen.js").AutomationFiring>;
107
+ firings: {
108
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersFiringsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationFiring>>;
109
+ };
110
+ list: (options?: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersListData> | undefined) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationTrigger>>;
111
+ pause: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersPauseData>) => Promise<import("./generated/types.gen.js").AutomationTrigger>;
112
+ preview: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersPreviewData>) => Promise<import("./generated/types.gen.js").AutomationTriggerPreview>;
113
+ resume: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersResumeData>) => Promise<import("./generated/types.gen.js").AutomationTrigger>;
114
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersGetData>) => Promise<import("./generated/types.gen.js").AutomationTrigger>;
115
+ rotateWebhook: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersRotateWebhookData>) => Promise<import("./generated/types.gen.js").AutomationWebhookUrl>;
116
+ update: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationTriggersPatchData>) => Promise<import("./generated/types.gen.js").AutomationTrigger>;
117
+ };
118
+ validate: {
119
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationValidateValidateData>) => Promise<import("./generated/types.gen.js").AutomationValidateResult>;
120
+ };
121
+ workflows: {
122
+ archive: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsArchiveData>) => Promise<import("./generated/types.gen.js").AutomationDefinition>;
123
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsCreateData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
124
+ distTags: {
125
+ delete: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsDeleteDistTagData>) => Promise<{
126
+ [key: string]: import("./generated/types.gen.js").AutomationDistTag;
127
+ }>;
128
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsDistTagsData>) => Promise<{
129
+ [key: string]: import("./generated/types.gen.js").AutomationDistTag;
130
+ }>;
131
+ set: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsSetDistTagData>) => Promise<{
132
+ [key: string]: import("./generated/types.gen.js").AutomationDistTag;
133
+ }>;
134
+ };
135
+ list: (options?: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsListData> | undefined) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationDefinition>>;
136
+ restore: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsRestoreData>) => Promise<import("./generated/types.gen.js").AutomationDefinition>;
137
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsGetData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
138
+ update: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsPatchData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
139
+ versions: {
140
+ create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsPublishData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
141
+ deprecate: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsDeprecateData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
142
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsVersionsData>) => Promise<import("./automation.js").Page<import("./generated/types.gen.js").AutomationVersionListItem>>;
143
+ publish: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsPublishData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
144
+ retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsVersionData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
145
+ };
146
+ };
147
+ };
148
+ export { PraxisError, PraxisConnectionError, PraxisTimeoutError } from './core/errors.js';
149
+ export type { PraxisOptions, RequestOptions } from './core/transport.js';
150
+ export type { SSEEvent } from './core/sse.js';
151
+ export { Page } from './core/pagination.js';
@@ -0,0 +1,8 @@
1
+ import { createAutomation } from "./resources.generated.js";
2
+ import { Transport } from "./core/transport.js";
3
+ /** An automation-only entry point: other resource factories tree-shake away. */
4
+ export function createAutomationClient(options) {
5
+ return createAutomation(new Transport(options));
6
+ }
7
+ export { PraxisError, PraxisConnectionError, PraxisTimeoutError } from "./core/errors.js";
8
+ export { Page } from "./core/pagination.js";
@@ -0,0 +1,25 @@
1
+ import { Page } from './pagination.js';
2
+ import type { SSEEvent } from './sse.js';
3
+ import type { CallOptions, StreamOptions, Operation, Transport } from './transport.js';
4
+ type Args<D> = {} extends CallOptions<D> ? [options?: CallOptions<D>] : [options: CallOptions<D>];
5
+ type StreamArgs<D> = {} extends StreamOptions<D> ? [options?: StreamOptions<D>] : [options: StreamOptions<D>];
6
+ export declare function bind<D, R>(transport: Transport, operation: Operation): (...args: Args<D>) => Promise<R>;
7
+ export declare function bindStream<D, E extends SSEEvent = SSEEvent>(transport: Transport, operation: Operation): (...args: StreamArgs<D>) => AsyncIterable<E>;
8
+ export declare function bindPage<D, T>(transport: Transport, operation: Operation): (...args: Args<D>) => Promise<Page<T>>;
9
+ export interface MixedMethod<D, R, E extends SSEEvent = SSEEvent> {
10
+ (options: StreamOptions<D> & {
11
+ stream: true;
12
+ }): AsyncIterable<E>;
13
+ (...args: Args<D>): Promise<R>;
14
+ }
15
+ export declare function bindMixed<D, R, E extends SSEEvent = SSEEvent>(transport: Transport, operation: Operation): MixedMethod<D, R, E>;
16
+ /** Project only SDK parameter names; wire names remain hey-api's responsibility. */
17
+ type AliasMap = Record<string, Record<string, string>>;
18
+ type RenameFields<T, A> = T extends object ? {
19
+ [K in keyof T as K extends keyof A ? A[K] & string : K]: T[K];
20
+ } : T;
21
+ export type RenameParameters<D, A extends AliasMap> = {
22
+ [K in keyof D]: K extends keyof A ? RenameFields<D[K], A[K]> : D[K];
23
+ };
24
+ export declare function aliasOperation(operation: Operation, aliases: AliasMap): Operation;
25
+ export {};
@@ -0,0 +1,45 @@
1
+ import { Page } from "./pagination.js";
2
+ export function bind(transport, operation) {
3
+ return (...args) => transport.request(operation, args[0]);
4
+ }
5
+ export function bindStream(transport, operation) {
6
+ return (...args) => transport.stream(operation, args[0]);
7
+ }
8
+ export function bindPage(transport, operation) {
9
+ return async (...args) => {
10
+ const options = args[0] ?? {};
11
+ const load = async (cursor) => {
12
+ const query = 'query' in options ? options.query : {};
13
+ const value = await transport.request(operation, { ...options, query: { ...query, ...(cursor === undefined ? {} : { cursor }) } });
14
+ return new Page(value, load);
15
+ };
16
+ return load();
17
+ };
18
+ }
19
+ export function bindMixed(transport, operation) {
20
+ return ((options = {}) => {
21
+ if (!options.stream)
22
+ return transport.request(operation, options);
23
+ const body = 'body' in options && options.body && typeof options.body === 'object' ? { ...options.body, stream: true } : 'body' in options ? options.body : undefined;
24
+ return transport.stream(operation, { ...options, body });
25
+ });
26
+ }
27
+ export function aliasOperation(operation, aliases) {
28
+ return options => {
29
+ const mapped = { ...options };
30
+ for (const [location, names] of Object.entries(aliases)) {
31
+ if (!options[location])
32
+ continue;
33
+ mapped[location] = { ...options[location] };
34
+ for (const [wire, sdk] of Object.entries(names)) {
35
+ if (!Object.hasOwn(mapped[location], sdk))
36
+ continue;
37
+ if (Object.hasOwn(mapped[location], wire))
38
+ throw new TypeError(`Use only the SDK parameter ${location}.${sdk}`);
39
+ mapped[location][wire] = mapped[location][sdk];
40
+ delete mapped[location][sdk];
41
+ }
42
+ }
43
+ return operation(mapped);
44
+ };
45
+ }
@@ -0,0 +1,15 @@
1
+ import { resourceFactories } from '../resources.generated.js';
2
+ import { type PraxisOptions } from './transport.js';
3
+ import { type PublishInput, type PublishResult } from '../helpers/application-publish.js';
4
+ type Resources = {
5
+ readonly [K in keyof typeof resourceFactories]: ReturnType<(typeof resourceFactories)[K]>;
6
+ };
7
+ export interface Praxis extends Omit<Resources, 'application'> {
8
+ readonly application: Resources['application'] & {
9
+ publish(input: PublishInput): Promise<PublishResult>;
10
+ };
11
+ }
12
+ export declare class Praxis {
13
+ constructor(options: PraxisOptions);
14
+ }
15
+ export type { PraxisOptions, RequestOptions } from './transport.js';
@@ -0,0 +1,15 @@
1
+ import { resourceFactories } from "../resources.generated.js";
2
+ import { Transport } from "./transport.js";
3
+ import { publish } from "../helpers/application-publish.js";
4
+ export class Praxis {
5
+ constructor(options) {
6
+ const transport = new Transport(options);
7
+ for (const [name, create] of Object.entries(resourceFactories)) {
8
+ const resource = create(transport);
9
+ // Assemble before sealing the resource property; never replace a readonly SDK resource.
10
+ if (name === 'application')
11
+ Object.assign(resource, { publish: (input) => publish(this, input) });
12
+ Object.defineProperty(this, name, { value: resource, enumerable: true });
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Default credential chain for code running on a Praxis computer (ticket-5367):
3
+ * PRAXIS_API_TOKEN environment variable, then ~/.praxis/credentials. Resolved at call time so a
4
+ * token the platform renewed in the file is picked up by an already-running process.
5
+ */
6
+ export interface ResolvedCredentials {
7
+ token?: string;
8
+ apiUrl?: string;
9
+ }
10
+ type Env = Record<string, string | undefined>;
11
+ type ReadFile = (path: string) => string | null;
12
+ export declare function credentialsPath(env: Env): string | null;
13
+ export declare function resolveDefaultCredentials(env?: Env, readFile?: ReadFile): ResolvedCredentials;
14
+ export {};
@@ -0,0 +1,33 @@
1
+ const nonEmpty = (value) => typeof value === 'string' && value ? value : undefined;
2
+ function defaultReadFile(path) {
3
+ try {
4
+ const fs = globalThis.process?.getBuiltinModule?.('node:fs');
5
+ return fs ? fs.readFileSync(path, 'utf8') : null;
6
+ }
7
+ catch {
8
+ return null;
9
+ }
10
+ }
11
+ export function credentialsPath(env) {
12
+ const home = nonEmpty(env.HOME) ?? nonEmpty(env.USERPROFILE);
13
+ return home ? `${home.replace(/\/$/, '')}/.praxis/credentials` : null;
14
+ }
15
+ export function resolveDefaultCredentials(env = globalThis.process?.env ?? {}, readFile = defaultReadFile) {
16
+ const envToken = nonEmpty(env.PRAXIS_API_TOKEN);
17
+ const envUrl = nonEmpty(env.PRAXIS_API_URL);
18
+ if (envToken)
19
+ return { token: envToken, ...(envUrl ? { apiUrl: envUrl } : {}) };
20
+ const path = credentialsPath(env);
21
+ const text = path ? readFile(path) : null;
22
+ if (!text)
23
+ return envUrl ? { apiUrl: envUrl } : {};
24
+ try {
25
+ const file = JSON.parse(text);
26
+ const token = nonEmpty(file.token);
27
+ const apiUrl = envUrl ?? nonEmpty(file.api_url);
28
+ return { ...(token ? { token } : {}), ...(apiUrl ? { apiUrl } : {}) };
29
+ }
30
+ catch {
31
+ return envUrl ? { apiUrl: envUrl } : {};
32
+ }
33
+ }
@@ -0,0 +1,38 @@
1
+ /** RFC 9457 problem details, including Praxis's stable machine-readable code. */
2
+ export interface ProblemDetails {
3
+ status?: number;
4
+ code?: string;
5
+ type?: string;
6
+ title?: string;
7
+ detail?: string;
8
+ errors?: unknown[];
9
+ requestId?: string;
10
+ message?: string;
11
+ param?: string | null;
12
+ raw?: unknown;
13
+ }
14
+ /** Pure normalization shared by HTTP clients and the automation call ledger.
15
+ * Numeric transport codes (E2B's `code: 400`) are not domain error codes.
16
+ */
17
+ export declare function problemFrom(status: number, headers: Pick<Headers, 'get'>, body: unknown, statusText?: string): ProblemDetails & {
18
+ message: string;
19
+ };
20
+ export declare class PraxisError extends Error {
21
+ readonly status?: number;
22
+ readonly code?: string;
23
+ readonly type?: string;
24
+ readonly title?: string;
25
+ readonly detail?: string;
26
+ readonly errors: unknown[];
27
+ readonly requestId?: string;
28
+ readonly param?: string | null;
29
+ readonly raw?: unknown;
30
+ constructor(problem?: ProblemDetails, options?: ErrorOptions);
31
+ static fromResponse(response: Response, body: unknown): PraxisError;
32
+ }
33
+ export declare class PraxisConnectionError extends PraxisError {
34
+ constructor(cause?: unknown);
35
+ }
36
+ export declare class PraxisTimeoutError extends PraxisError {
37
+ constructor(timeoutMs: number);
38
+ }