roe-typescript 1.0.803 → 1.1.1

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
@@ -2,9 +2,11 @@
2
2
 
3
3
  TypeScript/Node SDK for the [Roe](https://www.roe-ai.com/) API.
4
4
 
5
- > **v1.0.802** — Version synchronization across roe-python / roe-typescript /
6
- > roe-golang. No major-version migration; the public SDK packages now share a
7
- > single 1.0.x patch counter driven by the SDK OpenAPI spec.
5
+ <!-- ROE-SDK:RELEASE-BANNER:START -->
6
+ > **v1.1.1** - SDK operation coverage is synchronized across Python,
7
+ > TypeScript, and Go. See `SDK_EXAMPLES.md` for copy-ready examples and use
8
+ > cases.
9
+ <!-- ROE-SDK:RELEASE-BANNER:END -->
8
10
 
9
11
  > **v1.0.80** — `RoeHTTPClient`/axios were replaced by the generated
10
12
  > `openapi-fetch` client exposed as `client.raw`; use `components["schemas"]`
@@ -123,9 +125,9 @@ console.log(response.response.status);
123
125
  ```
124
126
 
125
127
  <!-- ROE-SDK:GENERATED-FRIENDLY-APIS:START -->
126
- ## Generated Friendly APIs
128
+ ## SDK Operation Groups
127
129
 
128
- This block is synced from `roe-main/roe-sdk/sdk_contract.yml` during SDK fan-out.
130
+ Common operations are available directly on the SDK client.
129
131
 
130
132
  ```typescript
131
133
  const engines = await client.discovery.listAgentEngineTypes();
@@ -520,6 +522,16 @@ const agent = await client.agents.create({
520
522
  | AML Investigation | `AMLInvestigationEngine` |
521
523
  | Fraud Investigation | `FraudInvestigationEngine` |
522
524
 
525
+ ## Development
526
+
527
+ Before opening a PR, format and lint the codebase by running:
528
+
529
+ ```bash
530
+ ./roe-cli format
531
+ ```
532
+
533
+ CI runs the same checks (`biome ci`) on every pull request and on merges to `main`, and they must pass before a PR can be merged.
534
+
523
535
  ## Links
524
536
 
525
537
  - [Roe](https://www.roe-ai.com/)
@@ -5,7 +5,8 @@ import { Job, JobBatch } from "../models/job.js";
5
5
  type BaseAgent = components["schemas"]["BaseAgent"];
6
6
  type PaginatedBaseAgentList = components["schemas"]["PaginatedBaseAgentList"];
7
7
  type AgentVersion = components["schemas"]["AgentVersion"];
8
- type AgentJobStatus = components["schemas"]["AgentJobStatus"];
8
+ type AgentJobStatus = components["schemas"]["AgentJobSingleStatus"];
9
+ type AgentJobBatchStatus = components["schemas"]["AgentJobStatus"];
9
10
  type AgentJobResultItem = components["schemas"]["AgentJobResultItem"];
10
11
  type AgentJobDeleteDataResponse = components["schemas"]["AgentJobDeleteDataResponse"];
11
12
  type AgentDatum = components["schemas"]["AgentDatum"];
@@ -38,7 +39,7 @@ export declare class AgentJobsAPI {
38
39
  private get organizationId();
39
40
  retrieveStatus(jobId: string): Promise<AgentJobStatus>;
40
41
  retrieveResult(jobId: string): Promise<components["schemas"]["AgentJobResultResponse"]>;
41
- retrieveStatusMany(jobIds: string[]): Promise<AgentJobStatus[]>;
42
+ retrieveStatusMany(jobIds: string[]): Promise<AgentJobBatchStatus[]>;
42
43
  retrieveResultMany(jobIds: string[]): Promise<AgentJobResultItem[]>;
43
44
  downloadReference(jobId: string, resourceId: string, asAttachment?: boolean): Promise<Buffer>;
44
45
  cancel(jobId: string): Promise<void>;
@@ -83,7 +84,6 @@ export declare class AgentsAPI {
83
84
  agentId: string;
84
85
  batchInputs: Record<string, unknown>[];
85
86
  timeoutSeconds?: number;
86
- metadata?: Record<string, unknown>;
87
87
  }): Promise<JobBatch>;
88
88
  runSync(agentId: string, inputs: Record<string, unknown>, metadata?: Record<string, unknown>): Promise<AgentDatum[]>;
89
89
  runVersion(params: {
@@ -1,7 +1,7 @@
1
- import { isUuidString } from "../utils/fileDetection.js";
2
- import { postDynamicInputs } from "../utils/dynamicInputs.js";
3
1
  import { BadRequestError, RoeAPIException } from "../exceptions.js";
4
2
  import { Job, JobBatch } from "../models/job.js";
3
+ import { postDynamicInputs } from "../utils/dynamicInputs.js";
4
+ import { isUuidString } from "../utils/fileDetection.js";
5
5
  function validateUuid(value, fieldName) {
6
6
  if (!isUuidString(value)) {
7
7
  throw new BadRequestError(`Invalid ${fieldName}: "${value}" is not a valid UUID`, 400);
@@ -30,7 +30,9 @@ export class AgentVersionsAPI {
30
30
  async retrieve(agentId, versionId, getSupportsEval) {
31
31
  validateUuid(agentId, "agentId");
32
32
  validateUuid(versionId, "versionId");
33
- const query = { organization_id: this.organizationId };
33
+ const query = {
34
+ organization_id: this.organizationId,
35
+ };
34
36
  if (getSupportsEval !== undefined)
35
37
  query.get_supports_eval = String(getSupportsEval).toLowerCase();
36
38
  const { data } = await this.raw.GET("/v1/agents/{agent_id}/versions/{agent_version_id}/", {
@@ -154,11 +156,12 @@ export class AgentJobsAPI {
154
156
  params: { query: { organization_id: this.organizationId } },
155
157
  body: { job_ids: chunk },
156
158
  });
157
- if (Array.isArray(data)) {
158
- results.push(...data);
159
+ const payload = data;
160
+ if (Array.isArray(payload)) {
161
+ results.push(...payload);
159
162
  }
160
- else if (data?.results) {
161
- results.push(...data.results);
163
+ else if (payload?.results) {
164
+ results.push(...payload.results);
162
165
  }
163
166
  }
164
167
  return results;
@@ -168,7 +171,9 @@ export class AgentJobsAPI {
168
171
  // The endpoint streams binary; openapi-fetch's typed GET expects a JSON
169
172
  // response per the spec, so we use parseAs:"arrayBuffer" to skip JSON
170
173
  // parsing and read raw bytes.
171
- const query = { organization_id: this.organizationId };
174
+ const query = {
175
+ organization_id: this.organizationId,
176
+ };
172
177
  if (asAttachment)
173
178
  query.download = "true";
174
179
  const result = await this.raw.GET("/v1/agents/jobs/{agent_job_id}/references/{resource_id}/", {
@@ -304,7 +309,11 @@ export class AgentsAPI {
304
309
  validateUuid(params.agentId, "agentId");
305
310
  const response = await postDynamicInputs(this.raw, "/v1/agents/run/{agent_id}/async/", { agent_id: params.agentId }, { organization_id: this.config.organizationId }, params.inputs, params.metadata, this.config.maxRetries);
306
311
  const jobId = this.extractJobId(response);
307
- return new Job({ agentsApi: this, jobId, timeoutSeconds: params.timeoutSeconds });
312
+ return new Job({
313
+ agentsApi: this,
314
+ jobId,
315
+ timeoutSeconds: params.timeoutSeconds,
316
+ });
308
317
  }
309
318
  async runMany(params) {
310
319
  validateUuid(params.agentId, "agentId");
@@ -312,17 +321,12 @@ export class AgentsAPI {
312
321
  for (const chunk of this.iterChunks(params.batchInputs, AgentsAPI.MAX_BATCH_SIZE)) {
313
322
  if (!chunk.length)
314
323
  continue;
315
- // Generated request type only models { inputs }, but the backend also
316
- // accepts a sibling `metadata` field — attach it via a serializer cast.
317
- const body = { inputs: chunk };
318
- if (params.metadata !== undefined)
319
- body.metadata = params.metadata;
320
324
  const { data } = await this.raw.POST("/v1/agents/run/{agent_id}/async/many/", {
321
325
  params: {
322
326
  path: { agent_id: params.agentId },
323
327
  query: { organization_id: this.config.organizationId },
324
328
  },
325
- body: body,
329
+ body: { inputs: chunk },
326
330
  });
327
331
  const ids = Array.isArray(data) ? data : [];
328
332
  for (const jobId of ids) {
@@ -332,7 +336,11 @@ export class AgentsAPI {
332
336
  allJobIds.push(jobId);
333
337
  }
334
338
  }
335
- return new JobBatch({ agentsApi: this, jobIds: allJobIds, timeoutSeconds: params.timeoutSeconds });
339
+ return new JobBatch({
340
+ agentsApi: this,
341
+ jobIds: allJobIds,
342
+ timeoutSeconds: params.timeoutSeconds,
343
+ });
336
344
  }
337
345
  async runSync(agentId, inputs, metadata) {
338
346
  validateUuid(agentId, "agentId");
@@ -343,7 +351,11 @@ export class AgentsAPI {
343
351
  validateUuid(params.versionId, "versionId");
344
352
  const response = await postDynamicInputs(this.raw, "/v1/agents/run/{agent_id}/versions/{agent_version_id}/async/", { agent_id: params.agentId, agent_version_id: params.versionId }, { organization_id: this.config.organizationId }, params.inputs, params.metadata, this.config.maxRetries);
345
353
  const jobId = this.extractJobId(response);
346
- return new Job({ agentsApi: this, jobId, timeoutSeconds: params.timeoutSeconds });
354
+ return new Job({
355
+ agentsApi: this,
356
+ jobId,
357
+ timeoutSeconds: params.timeoutSeconds,
358
+ });
347
359
  }
348
360
  async runVersionSync(agentId, versionId, inputs, metadata) {
349
361
  validateUuid(agentId, "agentId");
@@ -8,6 +8,8 @@ export declare class DiscoveryAPI {
8
8
  readonly raw: RoeRawClient;
9
9
  /** API for discovering valid agent engine types and model IDs. */
10
10
  constructor(config: RoeConfig, raw: RoeRawClient);
11
+ protected get rawClient(): RoeRawClient;
12
+ protected get organizationId(): string;
11
13
  /** Return production engine_class_id values accepted by agent creation. */
12
14
  listAgentEngineTypes(): Promise<AgentEngineTypeList>;
13
15
  /** Return non-deprecated model IDs accepted in engine_config.model. */
@@ -8,6 +8,12 @@ export class DiscoveryAPI {
8
8
  this.config = config;
9
9
  this.raw = raw;
10
10
  }
11
+ get rawClient() {
12
+ return this.raw;
13
+ }
14
+ get organizationId() {
15
+ return this.config.organizationId;
16
+ }
11
17
  /** Return production engine_class_id values accepted by agent creation. */
12
18
  async listAgentEngineTypes() {
13
19
  const result = await this.raw.GET("/v1/agents/types/");
@@ -1,18 +1,22 @@
1
- import { RoeConfig } from "../config.js";
1
+ import type { RoeConfig } from "../config.js";
2
2
  import type { RoeRawClient } from "../generated/client.js";
3
3
  import type { components } from "../generated/schema.js";
4
- type Policy = components["schemas"]["Policy"];
5
4
  type CreatePolicy = components["schemas"]["CreatePolicy"];
6
- type UpdatePolicy = components["schemas"]["UpdatePolicy"];
7
- type PolicyVersion = components["schemas"]["PolicyVersion"];
8
5
  type PaginatedPolicyList = components["schemas"]["PaginatedPolicyList"];
6
+ type Policy = components["schemas"]["Policy"];
7
+ type PolicyVersion = components["schemas"]["PolicyVersion"];
8
+ type UpdatePolicy = components["schemas"]["UpdatePolicy"];
9
9
  export declare class PolicyVersionsAPI {
10
10
  private readonly policiesApi;
11
+ /** API for managing the versions of a policy. */
11
12
  constructor(policiesApi: PoliciesAPI);
12
- private get raw();
13
- private get organizationId();
13
+ protected get rawClient(): RoeRawClient;
14
+ protected get organizationId(): string;
15
+ /** List all versions of a policy. */
14
16
  list(policyId: string): Promise<PolicyVersion[]>;
17
+ /** Retrieve a single policy version. */
15
18
  retrieve(policyId: string, versionId: string): Promise<PolicyVersion>;
19
+ /** Create a new version of a policy. */
16
20
  create(params: {
17
21
  policyId: string;
18
22
  content: Record<string, unknown>;
@@ -23,23 +27,31 @@ export declare class PolicyVersionsAPI {
23
27
  export declare class PoliciesAPI {
24
28
  readonly config: RoeConfig;
25
29
  readonly raw: RoeRawClient;
30
+ /** API for managing Roe policies and their versions. */
26
31
  readonly versions: PolicyVersionsAPI;
27
32
  constructor(config: RoeConfig, raw: RoeRawClient);
33
+ protected get rawClient(): RoeRawClient;
34
+ protected get organizationId(): string;
35
+ /** List policies in the organization (paginated). */
28
36
  list(params?: {
29
37
  page?: number;
30
38
  pageSize?: number;
31
39
  }): Promise<PaginatedPolicyList>;
40
+ /** Retrieve a single policy by ID. */
32
41
  retrieve(policyId: string): Promise<Policy>;
42
+ /** Create a new policy together with its first version. */
33
43
  create(params: {
34
44
  name: string;
35
45
  content: Record<string, unknown>;
36
46
  description?: string;
37
47
  versionName?: string;
38
48
  }): Promise<CreatePolicy>;
49
+ /** Update mutable fields of a policy. */
39
50
  update(policyId: string, updates: {
40
51
  name?: string;
41
52
  description?: string;
42
53
  }): Promise<UpdatePolicy>;
54
+ /** Delete a policy. */
43
55
  delete(policyId: string): Promise<void>;
44
56
  }
45
57
  export {};
@@ -1,38 +1,40 @@
1
- import { isUuidString } from "../utils/fileDetection.js";
1
+ // Auto-generated friendly API facades for the Roe SDK.
2
+ // Generated by scripts/generate-sdk from openapi/wrappers.yml.
3
+ // Do not edit by hand.
2
4
  import { BadRequestError, RoeAPIException } from "../exceptions.js";
3
- /**
4
- * Validates that a value is a valid UUID string.
5
- * @throws BadRequestError if the value is not a valid UUID
6
- */
5
+ import { isUuidString } from "../utils/fileDetection.js";
7
6
  function validateUuid(value, fieldName) {
8
7
  if (!isUuidString(value)) {
9
8
  throw new BadRequestError(`Invalid ${fieldName}: "${value}" is not a valid UUID`, 400);
10
9
  }
11
10
  }
12
11
  export class PolicyVersionsAPI {
12
+ /** API for managing the versions of a policy. */
13
13
  constructor(policiesApi) {
14
14
  this.policiesApi = policiesApi;
15
15
  }
16
- get raw() {
16
+ get rawClient() {
17
17
  return this.policiesApi.raw;
18
18
  }
19
19
  get organizationId() {
20
20
  return this.policiesApi.config.organizationId;
21
21
  }
22
+ /** List all versions of a policy. */
22
23
  async list(policyId) {
23
24
  validateUuid(policyId, "policyId");
24
- const { data } = await this.raw.GET("/v1/policies/{policy_id}/versions/", {
25
+ const { data } = await this.rawClient.GET("/v1/policies/{policy_id}/versions/", {
25
26
  params: {
26
27
  path: { policy_id: policyId },
27
28
  query: { organization_id: this.organizationId },
28
29
  },
29
30
  });
30
- return data?.results ?? [];
31
+ return (data?.results ?? []);
31
32
  }
33
+ /** Retrieve a single policy version. */
32
34
  async retrieve(policyId, versionId) {
33
35
  validateUuid(policyId, "policyId");
34
36
  validateUuid(versionId, "versionId");
35
- const { data } = await this.raw.GET("/v1/policies/{policy_id}/versions/{version_id}/", {
37
+ const { data } = await this.rawClient.GET("/v1/policies/{policy_id}/versions/{version_id}/", {
36
38
  params: {
37
39
  path: { policy_id: policyId, version_id: versionId },
38
40
  query: { organization_id: this.organizationId },
@@ -40,18 +42,21 @@ export class PolicyVersionsAPI {
40
42
  });
41
43
  return data;
42
44
  }
45
+ /** Create a new version of a policy. */
43
46
  async create(params) {
44
47
  validateUuid(params.policyId, "policyId");
45
- if (params.baseVersionId !== undefined)
48
+ if (params.baseVersionId != null)
46
49
  validateUuid(params.baseVersionId, "baseVersionId");
47
50
  const body = {
48
51
  content: params.content,
52
+ ...(params.versionName !== undefined
53
+ ? { version_name: params.versionName }
54
+ : {}),
55
+ ...(params.baseVersionId !== undefined
56
+ ? { base_version_id: params.baseVersionId }
57
+ : {}),
49
58
  };
50
- if (params.versionName !== undefined)
51
- body.version_name = params.versionName;
52
- if (params.baseVersionId !== undefined)
53
- body.base_version_id = params.baseVersionId;
54
- const { data } = await this.raw.POST("/v1/policies/{policy_id}/versions/", {
59
+ const { data } = await this.rawClient.POST("/v1/policies/{policy_id}/versions/", {
55
60
  params: {
56
61
  path: { policy_id: params.policyId },
57
62
  query: { organization_id: this.organizationId },
@@ -61,7 +66,6 @@ export class PolicyVersionsAPI {
61
66
  if (!data?.id) {
62
67
  throw new RoeAPIException(`Unexpected response from server: ${JSON.stringify(data)}`);
63
68
  }
64
- // POST returns a partial CreatePolicyVersion; re-fetch to get the full version.
65
69
  return this.retrieve(params.policyId, data.id);
66
70
  }
67
71
  }
@@ -71,28 +75,39 @@ export class PoliciesAPI {
71
75
  this.raw = raw;
72
76
  this.versions = new PolicyVersionsAPI(this);
73
77
  }
78
+ get rawClient() {
79
+ return this.raw;
80
+ }
81
+ get organizationId() {
82
+ return this.config.organizationId;
83
+ }
84
+ /** List policies in the organization (paginated). */
74
85
  async list(params) {
75
- const { data } = await this.raw.GET("/v1/policies/", {
86
+ const { data } = await this.rawClient.GET("/v1/policies/", {
76
87
  params: {
77
88
  query: {
78
- organization_id: this.config.organizationId,
79
- page: params?.page,
80
- page_size: params?.pageSize,
89
+ organization_id: this.organizationId,
90
+ ...(params?.page !== undefined ? { page: params?.page } : {}),
91
+ ...(params?.pageSize !== undefined
92
+ ? { page_size: params?.pageSize }
93
+ : {}),
81
94
  },
82
95
  },
83
96
  });
84
97
  return data;
85
98
  }
99
+ /** Retrieve a single policy by ID. */
86
100
  async retrieve(policyId) {
87
101
  validateUuid(policyId, "policyId");
88
- const { data } = await this.raw.GET("/v1/policies/{id}/", {
102
+ const { data } = await this.rawClient.GET("/v1/policies/{id}/", {
89
103
  params: {
90
104
  path: { id: policyId },
91
- query: { organization_id: this.config.organizationId },
105
+ query: { organization_id: this.organizationId },
92
106
  },
93
107
  });
94
108
  return data;
95
109
  }
110
+ /** Create a new policy together with its first version. */
96
111
  async create(params) {
97
112
  const body = {
98
113
  name: params.name,
@@ -100,34 +115,37 @@ export class PoliciesAPI {
100
115
  description: params.description ?? "",
101
116
  version_name: params.versionName ?? "version 1",
102
117
  };
103
- const { data } = await this.raw.POST("/v1/policies/", {
104
- params: { query: { organization_id: this.config.organizationId } },
118
+ const { data } = await this.rawClient.POST("/v1/policies/", {
119
+ params: { query: { organization_id: this.organizationId } },
105
120
  body,
106
121
  });
107
122
  return data;
108
123
  }
124
+ /** Update mutable fields of a policy. */
109
125
  async update(policyId, updates) {
110
126
  validateUuid(policyId, "policyId");
111
- const body = {};
112
- if (updates.name !== undefined)
113
- body.name = updates.name;
114
- if (updates.description !== undefined)
115
- body.description = updates.description;
116
- const { data } = await this.raw.PATCH("/v1/policies/{id}/", {
127
+ const body = {
128
+ ...(updates.name !== undefined ? { name: updates.name } : {}),
129
+ ...(updates.description !== undefined
130
+ ? { description: updates.description }
131
+ : {}),
132
+ };
133
+ const { data } = await this.rawClient.PATCH("/v1/policies/{id}/", {
117
134
  params: {
118
135
  path: { id: policyId },
119
- query: { organization_id: this.config.organizationId },
136
+ query: { organization_id: this.organizationId },
120
137
  },
121
138
  body,
122
139
  });
123
140
  return data;
124
141
  }
142
+ /** Delete a policy. */
125
143
  async delete(policyId) {
126
144
  validateUuid(policyId, "policyId");
127
- await this.raw.DELETE("/v1/policies/{id}/", {
145
+ await this.rawClient.DELETE("/v1/policies/{id}/", {
128
146
  params: {
129
147
  path: { id: policyId },
130
- query: { organization_id: this.config.organizationId },
148
+ query: { organization_id: this.organizationId },
131
149
  },
132
150
  });
133
151
  }
@@ -15,6 +15,8 @@ export declare class TablesAPI {
15
15
  readonly raw: RoeRawClient;
16
16
  /** API for uploading CSV files into Roe tables. */
17
17
  constructor(config: RoeConfig, raw: RoeRawClient);
18
+ protected get rawClient(): RoeRawClient;
19
+ protected get organizationId(): string;
18
20
  /** Upload a CSV file and create a Roe table. */
19
21
  upload(params: TableUploadParams): Promise<TableUploadResponse>;
20
22
  }
@@ -9,6 +9,12 @@ export class TablesAPI {
9
9
  this.config = config;
10
10
  this.raw = raw;
11
11
  }
12
+ get rawClient() {
13
+ return this.raw;
14
+ }
15
+ get organizationId() {
16
+ return this.config.organizationId;
17
+ }
12
18
  /** Upload a CSV file and create a Roe table. */
13
19
  async upload(params) {
14
20
  const inputs = {
package/dist/auth.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RoeConfig } from "./config.js";
1
+ import type { RoeConfig } from "./config.js";
2
2
  export declare class RoeAuth {
3
3
  private readonly config;
4
4
  constructor(config: RoeConfig);
package/dist/auth.js CHANGED
@@ -1,6 +1,6 @@
1
- import { readFileSync } from "fs";
2
- import { fileURLToPath } from "url";
3
- import { dirname, join } from "path";
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
4
  // Resolve the package's own version at runtime so the User-Agent doesn't
5
5
  // silently drift across releases when the auto-release pipeline bumps
6
6
  // package.json without touching this file. Falls back to "0.0.0" if the
package/dist/client.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { AgentsAPI } from "./api/agents.js";
2
1
  import { type GeneratedApis } from "./api/_generated.js";
2
+ import { AgentsAPI } from "./api/agents.js";
3
3
  import { PoliciesAPI } from "./api/policies.js";
4
4
  import { UsersAPI } from "./api/users.js";
5
5
  import { RoeAuth } from "./auth.js";
6
- import { RoeConfig, RoeConfigInput } from "./config.js";
6
+ import { RoeConfig, type RoeConfigInput } from "./config.js";
7
7
  import { type RoeRawClient } from "./generated/client.js";
8
8
  export declare class RoeClient {
9
9
  readonly config: RoeConfig;
package/dist/client.js CHANGED
@@ -1,5 +1,5 @@
1
- import { AgentsAPI } from "./api/agents.js";
2
1
  import { createGeneratedApis } from "./api/_generated.js";
2
+ import { AgentsAPI } from "./api/agents.js";
3
3
  import { PoliciesAPI } from "./api/policies.js";
4
4
  import { UsersAPI } from "./api/users.js";
5
5
  import { RoeAuth } from "./auth.js";
package/dist/config.js CHANGED
@@ -11,7 +11,9 @@ export class RoeConfig {
11
11
  const organizationId = input.organizationId ?? process.env.ROE_ORGANIZATION_ID;
12
12
  const baseUrl = input.baseUrl ?? process.env.ROE_BASE_URL ?? "https://api.roe-ai.com";
13
13
  // Parse ROE_TIMEOUT with NaN check to avoid poisoning timeoutMs
14
- const timeoutSecondsEnvRaw = process.env.ROE_TIMEOUT ? Number(process.env.ROE_TIMEOUT) : undefined;
14
+ const timeoutSecondsEnvRaw = process.env.ROE_TIMEOUT
15
+ ? Number(process.env.ROE_TIMEOUT)
16
+ : undefined;
15
17
  const timeoutSecondsEnv = timeoutSecondsEnvRaw !== undefined && !Number.isNaN(timeoutSecondsEnvRaw)
16
18
  ? timeoutSecondsEnvRaw
17
19
  : undefined;
@@ -70,7 +70,9 @@ export function extractErrorMessage(data, statusCode) {
70
70
  const firstError = obj.errors[0];
71
71
  if (typeof firstError === "string")
72
72
  return firstError;
73
- if (typeof firstError === "object" && firstError !== null && typeof firstError.message === "string") {
73
+ if (typeof firstError === "object" &&
74
+ firstError !== null &&
75
+ typeof firstError.message === "string") {
74
76
  return firstError.message;
75
77
  }
76
78
  }
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export { RoeClient } from "./client.js";
2
- export { RoeConfig } from "./config.js";
3
- export type { RoeConfigInput } from "./config.js";
4
- export { RoeAuth } from "./auth.js";
5
- export { createRoeRawClient } from "./generated/client.js";
6
- export type { RoeApiComponents, RoeApiPaths, RoeRawClient } from "./generated/client.js";
7
- export type { components, paths } from "./generated/schema.js";
8
- export * from "./exceptions.js";
9
1
  export * from "./api/_generated.js";
10
2
  export * from "./api/agents.js";
11
3
  export * from "./api/policies.js";
12
4
  export * from "./api/users.js";
13
- export { Job, JobBatch, JobStatus } from "./models/job.js";
14
- export type { JobResult, JobBatchItem } from "./models/job.js";
5
+ export { RoeAuth } from "./auth.js";
6
+ export { RoeClient } from "./client.js";
7
+ export type { RoeConfigInput } from "./config.js";
8
+ export { RoeConfig } from "./config.js";
9
+ export * from "./exceptions.js";
10
+ export type { RoeApiComponents, RoeApiPaths, RoeRawClient, } from "./generated/client.js";
11
+ export { createRoeRawClient } from "./generated/client.js";
12
+ export type { components, paths } from "./generated/schema.js";
15
13
  export { FileUpload } from "./models/file.js";
14
+ export type { JobBatchItem, JobResult } from "./models/job.js";
15
+ export { Job, JobBatch, JobStatus } from "./models/job.js";
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- export { RoeClient } from "./client.js";
2
- export { RoeConfig } from "./config.js";
3
- export { RoeAuth } from "./auth.js";
4
- export { createRoeRawClient } from "./generated/client.js";
5
- export * from "./exceptions.js";
6
1
  export * from "./api/_generated.js";
7
2
  export * from "./api/agents.js";
8
3
  export * from "./api/policies.js";
9
4
  export * from "./api/users.js";
10
- export { Job, JobBatch, JobStatus } from "./models/job.js";
5
+ export { RoeAuth } from "./auth.js";
6
+ export { RoeClient } from "./client.js";
7
+ export { RoeConfig } from "./config.js";
8
+ export * from "./exceptions.js";
9
+ export { createRoeRawClient } from "./generated/client.js";
11
10
  export { FileUpload } from "./models/file.js";
11
+ export { Job, JobBatch, JobStatus } from "./models/job.js";
12
12
  // Hand-written response models removed in v1.0 (Agent, BaseAgent, Policy, PolicyVersion,
13
13
  // AgentVersion, AgentDatum, AgentJobResult, AgentJobStatus, Reference, JobDataDeleteResponse,
14
14
  // PaginatedResponse, UserInfo). Import the generated equivalents instead, e.g.:
@@ -1,5 +1,5 @@
1
- import fs from "fs";
2
- import path from "path";
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
3
  import mime from "mime-types";
4
4
  import { BadRequestError } from "../exceptions.js";
5
5
  /** Maximum file size: 2GB (aligned with main-roe backend) */
@@ -89,7 +89,9 @@ export class FileUpload {
89
89
  for await (const chunk of this.file) {
90
90
  chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
91
91
  }
92
- this._streamBlob = new Blob([Buffer.concat(chunks)], { type: this.effectiveMimeType });
92
+ this._streamBlob = new Blob([Buffer.concat(chunks)], {
93
+ type: this.effectiveMimeType,
94
+ });
93
95
  return this._streamBlob;
94
96
  }
95
97
  throw new Error("No file source available");
@@ -1,4 +1,4 @@
1
- import { AgentsAPI } from "../api/agents.js";
1
+ import type { AgentsAPI } from "../api/agents.js";
2
2
  import type { components } from "../generated/schema.js";
3
3
  export declare enum JobStatus {
4
4
  PENDING = 0,
@@ -9,7 +9,7 @@ export declare enum JobStatus {
9
9
  CANCELLED = 5,
10
10
  CACHED = 6
11
11
  }
12
- type AgentJobStatus = components["schemas"]["AgentJobStatus"];
12
+ type AgentJobStatus = components["schemas"]["AgentJobSingleStatus"];
13
13
  type AgentJobResultResponse = components["schemas"]["AgentJobResultResponse"];
14
14
  type AgentJobResultItem = components["schemas"]["AgentJobResultItem"];
15
15
  type AgentDatum = components["schemas"]["AgentDatum"];
@@ -81,7 +81,11 @@ export class JobBatch {
81
81
  }
82
82
  }
83
83
  get jobs() {
84
- return this.jobIds.map((id) => new Job({ agentsApi: this.agentsApi, jobId: id, timeoutSeconds: this.timeoutSeconds }));
84
+ return this.jobIds.map((id) => new Job({
85
+ agentsApi: this.agentsApi,
86
+ jobId: id,
87
+ timeoutSeconds: this.timeoutSeconds,
88
+ }));
85
89
  }
86
90
  async wait(params) {
87
91
  const intervalSeconds = params?.intervalSeconds ?? 5;
@@ -96,8 +100,6 @@ export class JobBatch {
96
100
  const statusBatch = await this.agentsApi.jobs.retrieveStatusMany(pending);
97
101
  const completedIds = [];
98
102
  for (const status of statusBatch) {
99
- // The bulk status endpoint returns AgentJobStatus[]; the schema lacks an `id`
100
- // field on each, but the backend includes it in practice — extract via cast.
101
103
  const id = status.id;
102
104
  if (!id) {
103
105
  throw new Error("AgentJobStatus response is missing an `id` field; backend schema may have changed");
@@ -113,15 +115,16 @@ export class JobBatch {
113
115
  this.statuses[id] = {
114
116
  id,
115
117
  status: code,
116
- timestamp: status.timestamp,
117
- error_message: status.error_message,
118
+ timestamp: status.timestamp ?? 0,
119
+ error_message: status.error_message ?? undefined,
118
120
  };
119
121
  }
120
122
  }
121
123
  if (completedIds.length) {
122
124
  let resultBatch;
123
125
  try {
124
- resultBatch = await this.agentsApi.jobs.retrieveResultMany(completedIds);
126
+ resultBatch =
127
+ await this.agentsApi.jobs.retrieveResultMany(completedIds);
125
128
  }
126
129
  catch (err) {
127
130
  // Only synthesize for failed/cancelled — can't fake results for success/cached
@@ -147,7 +150,8 @@ export class JobBatch {
147
150
  }
148
151
  for (const res of resultBatch) {
149
152
  const jobStatus = res.status ?? this.statuses[res.id]?.status ?? null;
150
- const isFailed = jobStatus === JobStatus.FAILURE || jobStatus === JobStatus.CANCELLED;
153
+ const isFailed = jobStatus === JobStatus.FAILURE ||
154
+ jobStatus === JobStatus.CANCELLED;
151
155
  if (!res.agent_id || !res.agent_version_id) {
152
156
  if (!isFailed) {
153
157
  const id = res.id ?? "unknown";
@@ -192,7 +196,12 @@ export class JobBatch {
192
196
  async retrieveStatus() {
193
197
  const statusMap = {};
194
198
  const toQuery = [];
195
- const TERMINAL = new Set([JobStatus.SUCCESS, JobStatus.CACHED, JobStatus.FAILURE, JobStatus.CANCELLED]);
199
+ const TERMINAL = new Set([
200
+ JobStatus.SUCCESS,
201
+ JobStatus.CACHED,
202
+ JobStatus.FAILURE,
203
+ JobStatus.CANCELLED,
204
+ ]);
196
205
  for (const id of this.jobIds) {
197
206
  const cached = this.statuses[id];
198
207
  if (cached !== undefined && TERMINAL.has(cached.status)) {
@@ -213,8 +222,8 @@ export class JobBatch {
213
222
  const js = {
214
223
  id,
215
224
  status: s.status,
216
- timestamp: s.timestamp,
217
- error_message: s.error_message,
225
+ timestamp: s.timestamp ?? 0,
226
+ error_message: s.error_message ?? undefined,
218
227
  };
219
228
  this.statuses[id] = js;
220
229
  statusMap[id] = js;
@@ -27,7 +27,8 @@ export async function classifyInputs(inputs) {
27
27
  files[key] = value;
28
28
  continue;
29
29
  }
30
- if (typeof value === "object" && typeof value.pipe === "function") {
30
+ if (typeof value === "object" &&
31
+ typeof value.pipe === "function") {
31
32
  files[key] = new FileUpload({ file: value });
32
33
  continue;
33
34
  }
@@ -110,5 +111,6 @@ export async function postDynamicInputs(raw, path, pathParams, queryParams, inpu
110
111
  throw err;
111
112
  }
112
113
  }
113
- throw lastErr ?? new Error("postDynamicInputs exhausted retries without producing an error");
114
+ throw (lastErr ??
115
+ new Error("postDynamicInputs exhausted retries without producing an error"));
114
116
  }
@@ -1,4 +1,4 @@
1
- import fs from "fs";
1
+ import fs from "node:fs";
2
2
  const uuidRegex = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;
3
3
  export function isUuidString(value) {
4
4
  return typeof value === "string" && uuidRegex.test(value);
@@ -1,5 +1,5 @@
1
1
  import type { Middleware } from "openapi-fetch";
2
- import { RoeAuth } from "../auth.js";
2
+ import type { RoeAuth } from "../auth.js";
3
3
  export declare function shouldBypassRetry(request: Request): boolean;
4
4
  export declare function authMiddleware(auth: RoeAuth): Middleware;
5
5
  export declare function retryMiddleware(maxRetries: number): Middleware;
@@ -1,4 +1,4 @@
1
- import { extractErrorMessage, getExceptionForStatusCode } from "../exceptions.js";
1
+ import { extractErrorMessage, getExceptionForStatusCode, } from "../exceptions.js";
2
2
  const RETRY_BYPASS_HEADER = "x-roe-retry-bypass";
3
3
  export function shouldBypassRetry(request) {
4
4
  if (request.headers.get(RETRY_BYPASS_HEADER))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roe-typescript",
3
- "version": "1.0.803",
3
+ "version": "1.1.1",
4
4
  "description": "TypeScript SDK for the Roe API (feature parity with roe-python).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,6 +13,8 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "tsc -p tsconfig.json",
16
+ "format": "biome check --write .",
17
+ "format:check": "biome ci .",
16
18
  "generate-sdk": "bash scripts/generate-sdk",
17
19
  "lint": "tsc --noEmit",
18
20
  "test": "vitest run tests/unit --passWithNoTests",
@@ -23,9 +25,10 @@
23
25
  "mime-types": "^2.1.35",
24
26
  "openapi-fetch": "^0.13.8",
25
27
  "undici": "^6.25.0",
26
- "uuid": "^11.0.3"
28
+ "uuid": "^11.1.1"
27
29
  },
28
30
  "devDependencies": {
31
+ "@biomejs/biome": "2.4.9",
29
32
  "@types/mime-types": "^2.1.4",
30
33
  "@types/node": "^22.9.0",
31
34
  "@types/uuid": "^10.0.0",