@deepraxis/sdk 0.1.1-dev.f8aa5de → 0.1.1-dev.fee48ec

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **Models, agents, sandboxes, search, data and automation, typed end to end.**
6
6
 
7
- The official TypeScript SDK for [知行云 Praxis](https://deepraxis.com), the cloud where AI agents are built, run and hosted.
7
+ The official TypeScript SDK for [Praxis](https://deepraxis.com), the cloud where AI agents are built, run and hosted.
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/@deepraxis/sdk?label=npm&color=2e8555)](https://www.npmjs.com/package/@deepraxis/sdk)
10
10
  [![Bundle size](https://img.shields.io/bundlephobia/minzip/@deepraxis/sdk?color=2e8555)](https://bundlephobia.com/package/@deepraxis/sdk)
@@ -33,7 +33,7 @@ console.log(completion.choices[0]?.message.content);
33
33
  ## Why this SDK
34
34
 
35
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
36
+ browsers, web search, databases, knowledge bases, files, media, automation and hosted
37
37
  applications, generated from the same contract as the API.
38
38
  - **Types from the contract.** Every path, query, body and response is typed, including the
39
39
  events of each stream, so your editor knows what comes back.
@@ -55,7 +55,7 @@ server. You need a Praxis account; sign up at [deepraxis.com](https://deepraxis.
55
55
  const praxis = new Praxis({
56
56
  apiKey: process.env.PRAXIS_API_KEY!,
57
57
  baseUrl: 'https://api.deepraxis.com', // default
58
- timeoutMs: 60_000, // default; the whole call, body included
58
+ timeoutMs: 600_000, // default (10 minutes, as the OpenAI and Anthropic SDKs); the whole call, body included
59
59
  maxRetries: 2, // default
60
60
  // fetch: customFetch, // bring your own fetch
61
61
  });
@@ -276,5 +276,5 @@ sandboxes, search, data, automation and the rest of the platform.
276
276
 
277
277
  [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). Copyright 2026 南京深度实践人工智能科技有限公司 (Deepractice).
278
278
 
279
- "Praxis", "知行云" and "Deepraxis" are trademarks of Deepractice; the license does not grant
279
+ "Praxis" and "Deepraxis" are trademarks of Deepractice; the license does not grant
280
280
  rights to use them.
@@ -96,6 +96,33 @@ export declare function createAutomationClient(options: PraxisOptions): {
96
96
  restore: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsRestoreData>) => Promise<import("./generated/types.gen.js").AutomationDefinition>;
97
97
  retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsGetData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
98
98
  update: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsPatchData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
99
+ vaults: {
100
+ delete: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsVaultsDeleteData>) => Promise<void>;
101
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsVaultsListData>) => Promise<{
102
+ data: Array<{
103
+ alias: string;
104
+ vault: {
105
+ id: string;
106
+ name: string;
107
+ };
108
+ secrets: Array<{
109
+ name: string;
110
+ }>;
111
+ secrets_unavailable?: true;
112
+ }>;
113
+ }>;
114
+ set: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsVaultsSetData>) => Promise<{
115
+ alias: string;
116
+ vault: {
117
+ id: string;
118
+ name: string;
119
+ };
120
+ secrets: Array<{
121
+ name: string;
122
+ }>;
123
+ secrets_unavailable?: true;
124
+ }>;
125
+ };
99
126
  versions: {
100
127
  create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsPublishData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
101
128
  deprecate: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationScriptsDeprecateData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
@@ -143,6 +170,33 @@ export declare function createAutomationClient(options: PraxisOptions): {
143
170
  restore: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsRestoreData>) => Promise<import("./generated/types.gen.js").AutomationDefinition>;
144
171
  retrieve: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsGetData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
145
172
  update: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsPatchData>) => Promise<import("./generated/types.gen.js").AutomationDefinitionDetail>;
173
+ vaults: {
174
+ delete: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsVaultsDeleteData>) => Promise<void>;
175
+ list: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsVaultsListData>) => Promise<{
176
+ data: Array<{
177
+ alias: string;
178
+ vault: {
179
+ id: string;
180
+ name: string;
181
+ };
182
+ secrets: Array<{
183
+ name: string;
184
+ }>;
185
+ secrets_unavailable?: true;
186
+ }>;
187
+ }>;
188
+ set: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsVaultsSetData>) => Promise<{
189
+ alias: string;
190
+ vault: {
191
+ id: string;
192
+ name: string;
193
+ };
194
+ secrets: Array<{
195
+ name: string;
196
+ }>;
197
+ secrets_unavailable?: true;
198
+ }>;
199
+ };
146
200
  versions: {
147
201
  create: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsPublishData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
148
202
  deprecate: (options: import("./core/transport.js").CallOptions<import("./generated/types.gen.js").AutomationWorkflowsDeprecateData>) => Promise<import("./generated/types.gen.js").AutomationVersion>;
@@ -1,3 +1,4 @@
1
+ import { type SandboxTemplateBuildInput, type SandboxTemplateBuildResult } from "../helpers/sandbox-templates.js";
1
2
  import { type UploadFileOptions, type UploadedFile } from '../helpers/file-upload.js';
2
3
  import { resourceFactories } from '../resources.generated.js';
3
4
  import { type PraxisOptions } from './transport.js';
@@ -7,7 +8,12 @@ import { type CountInput, type CountResult } from '../helpers/database-count.js'
7
8
  type Resources = {
8
9
  readonly [K in keyof typeof resourceFactories]: ReturnType<(typeof resourceFactories)[K]>;
9
10
  };
10
- export interface Praxis extends Omit<Resources, 'application' | 'browser' | 'database' | 'file'> {
11
+ export interface Praxis extends Omit<Resources, 'application' | 'browser' | 'database' | 'file' | 'sandbox'> {
12
+ readonly sandbox: Omit<Resources['sandbox'], 'templates'> & {
13
+ templates: Resources['sandbox']['templates'] & {
14
+ build(input: SandboxTemplateBuildInput): Promise<SandboxTemplateBuildResult>;
15
+ };
16
+ };
11
17
  readonly browser: Resources['browser'] & {
12
18
  connect(options?: BrowserConnectOptions): Promise<PraxisBrowser>;
13
19
  };
@@ -1,3 +1,4 @@
1
+ import { buildSandboxTemplate } from "../helpers/sandbox-templates.js";
1
2
  import { uploadFile } from "../helpers/file-upload.js";
2
3
  import { resourceFactories } from "../resources.generated.js";
3
4
  import { Transport } from "./transport.js";
@@ -10,6 +11,8 @@ export class Praxis {
10
11
  for (const [name, create] of Object.entries(resourceFactories)) {
11
12
  const resource = create(transport);
12
13
  // Assemble before sealing the resource property; never replace a readonly SDK resource.
14
+ if (name === 'sandbox')
15
+ Object.assign(resource.templates, { build: (input) => buildSandboxTemplate(this, input) });
13
16
  if (name === 'file')
14
17
  Object.assign(resource, { uploadFile: (file, options) => uploadFile(this, file, options) });
15
18
  if (name === 'database')
@@ -9,6 +9,9 @@ export interface ProblemDetails {
9
9
  requestId?: string;
10
10
  message?: string;
11
11
  param?: string | null;
12
+ /** ticket-681 — the documentation page the failure points at, and the exact section to read. */
13
+ docUrl?: string;
14
+ describe?: string;
12
15
  raw?: unknown;
13
16
  }
14
17
  /** Pure normalization shared by HTTP clients and the automation call ledger.
@@ -26,6 +29,9 @@ export declare class PraxisError extends Error {
26
29
  readonly errors: unknown[];
27
30
  readonly requestId?: string;
28
31
  readonly param?: string | null;
32
+ /** ticket-681 — the documented page and the exact section an agent should read to fix the call. */
33
+ readonly docUrl?: string;
34
+ readonly describe?: string;
29
35
  readonly raw?: unknown;
30
36
  constructor(problem?: ProblemDetails, options?: ErrorOptions);
31
37
  static fromResponse(response: Response, body: unknown): PraxisError;
@@ -16,6 +16,9 @@ export function problemFrom(status, headers, body, statusText) {
16
16
  param: typeof param === 'string' ? param : param === null || nested.param === null ? null : undefined,
17
17
  errors: Array.isArray(value.errors) ? value.errors : [],
18
18
  requestId: headers.get('x-request-id') ?? string(value.requestId) ?? string(value.request_id),
19
+ // Both spellings reach here: the own face writes snake_case, an in-process problem keeps docUrl.
20
+ docUrl: string(nested.doc_url) ?? string(value.doc_url) ?? string(nested.docUrl) ?? string(value.docUrl),
21
+ describe: string(nested.describe) ?? string(value.describe),
19
22
  raw: body,
20
23
  };
21
24
  }
@@ -28,6 +31,9 @@ export class PraxisError extends Error {
28
31
  errors;
29
32
  requestId;
30
33
  param;
34
+ /** ticket-681 — the documented page and the exact section an agent should read to fix the call. */
35
+ docUrl;
36
+ describe;
31
37
  raw;
32
38
  constructor(problem = {}, options) {
33
39
  super(problem.message ?? problem.detail ?? problem.title ?? `Praxis request failed${problem.status ? ` (${problem.status})` : ''}`, options);
@@ -40,6 +46,8 @@ export class PraxisError extends Error {
40
46
  this.errors = problem.errors ?? [];
41
47
  this.requestId = problem.requestId;
42
48
  this.param = problem.param;
49
+ this.docUrl = problem.docUrl;
50
+ this.describe = problem.describe;
43
51
  this.raw = problem.raw;
44
52
  }
45
53
  static fromResponse(response, body) {
@@ -25,6 +25,15 @@ type InternalOptions = RequestOptions & {
25
25
  query?: unknown;
26
26
  lastEventId?: string;
27
27
  };
28
+ /** Margin over a server-side execution deadline: the response still has to travel back after it. */
29
+ export declare const SERVER_DEADLINE_MARGIN_MS = 30000;
30
+ /**
31
+ * A request body that carries its own execution deadline (`timeoutMs`, as in sandbox commands.run) is
32
+ * waited for at least that long plus a margin, so the client never gives up before the server answers.
33
+ */
34
+ export declare function serverDeadlineMs(options: {
35
+ body?: unknown;
36
+ }): number;
28
37
  export declare class Transport {
29
38
  private readonly config;
30
39
  constructor(options: PraxisOptions);
@@ -32,10 +32,21 @@ function assertKnownOptions(options) {
32
32
  detail: `Unrecognised option ${stray.length > 1 ? 'keys' : 'key'} ${names}. Request parameters are not flat: put each under \`query\` (GET/DELETE: filters, pagination), \`path\` (URL segments) or \`body\` (POST/PATCH/PUT payload), e.g. call({ query: { ${stray[0]} } }) or call({ body: { ${stray[0]} } }). Common top-level keys: path, query, body, headers, signal, timeoutMs, maxRetries.`,
33
33
  });
34
34
  }
35
+ /** Margin over a server-side execution deadline: the response still has to travel back after it. */
36
+ export const SERVER_DEADLINE_MARGIN_MS = 30_000;
37
+ /**
38
+ * A request body that carries its own execution deadline (`timeoutMs`, as in sandbox commands.run) is
39
+ * waited for at least that long plus a margin, so the client never gives up before the server answers.
40
+ */
41
+ export function serverDeadlineMs(options) {
42
+ const body = options.body;
43
+ const deadline = body && typeof body === 'object' ? body.timeoutMs : undefined;
44
+ return typeof deadline === 'number' && Number.isFinite(deadline) && deadline > 0 ? deadline + SERVER_DEADLINE_MARGIN_MS : 0;
45
+ }
35
46
  export class Transport {
36
47
  config;
37
48
  constructor(options) {
38
- this.config = { timeoutMs: 60_000, maxRetries: 2, fetch: globalThis.fetch, ...options };
49
+ this.config = { timeoutMs: 600_000, maxRetries: 2, fetch: globalThis.fetch, ...options };
39
50
  this.validate(this.config.timeoutMs, this.config.maxRetries);
40
51
  }
41
52
  validate(timeout, retries) {
@@ -46,7 +57,7 @@ export class Transport {
46
57
  }
47
58
  scope(options, streaming) {
48
59
  assertKnownOptions(options);
49
- const timeoutMs = options.timeoutMs ?? this.config.timeoutMs;
60
+ const timeoutMs = options.timeoutMs ?? Math.max(this.config.timeoutMs, serverDeadlineMs(options));
50
61
  const maxRetries = options.maxRetries ?? this.config.maxRetries;
51
62
  this.validate(timeoutMs, maxRetries);
52
63
  const controller = new AbortController();