roe-typescript 0.1.2 → 1.0.0
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 +48 -7
- package/dist/api/agents.d.ts +40 -27
- package/dist/api/agents.js +222 -112
- package/dist/api/policies.d.ts +15 -9
- package/dist/api/policies.js +75 -31
- package/dist/api/users.d.ts +18 -0
- package/dist/api/users.js +17 -0
- package/dist/client.d.ts +6 -2
- package/dist/client.js +17 -5
- package/dist/exceptions.js +8 -0
- package/dist/generated/client.d.ts +12 -0
- package/dist/generated/client.js +55 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +9 -5
- package/dist/models/file.d.ts +17 -0
- package/dist/models/file.js +36 -0
- package/dist/models/job.d.ts +30 -6
- package/dist/models/job.js +130 -37
- package/dist/utils/dynamicInputs.d.ts +30 -0
- package/dist/utils/dynamicInputs.js +114 -0
- package/dist/utils/middleware.d.ts +6 -0
- package/dist/utils/middleware.js +80 -0
- package/package.json +6 -6
- package/dist/models/agent.d.ts +0 -78
- package/dist/models/agent.js +0 -40
- package/dist/models/policy.d.ts +0 -19
- package/dist/models/policy.js +0 -1
- package/dist/models/responses.d.ts +0 -71
- package/dist/models/responses.js +0 -36
- package/dist/models/user.d.ts +0 -6
- package/dist/models/user.js +0 -1
- package/dist/utils/httpClient.d.ts +0 -30
- package/dist/utils/httpClient.js +0 -229
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript/Node SDK for the [Roe AI](https://www.roe-ai.com/) API.
|
|
4
4
|
|
|
5
|
+
> **v1.0.0** — `RoeHTTPClient`/axios were replaced by the generated
|
|
6
|
+
> `openapi-fetch` client exposed as `client.raw`; use `components["schemas"]`
|
|
7
|
+
> (or inferred types from the wrappers) where you need response shapes from
|
|
8
|
+
> the OpenAPI definitions. Highlights and migration notes across releases live
|
|
9
|
+
> in **[CHANGELOG.md](CHANGELOG.md)**.
|
|
10
|
+
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
7
13
|
```bash
|
|
@@ -37,6 +43,47 @@ export ROE_API_KEY="your-api-key"
|
|
|
37
43
|
export ROE_ORGANIZATION_ID="your-org-uuid"
|
|
38
44
|
```
|
|
39
45
|
|
|
46
|
+
## Job Result Inspection
|
|
47
|
+
|
|
48
|
+
After waiting for a job, you can inspect its outcome using the `JobStatus` enum:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { JobStatus } from "roe-typescript";
|
|
52
|
+
|
|
53
|
+
const result = await job.wait();
|
|
54
|
+
|
|
55
|
+
if (result.status === JobStatus.SUCCESS || result.status === JobStatus.CACHED) {
|
|
56
|
+
for (const output of result.outputs) {
|
|
57
|
+
console.log(`${output.key}: ${output.value}`);
|
|
58
|
+
}
|
|
59
|
+
} else if (result.status === JobStatus.CANCELLED) {
|
|
60
|
+
console.log("Job was cancelled");
|
|
61
|
+
} else if (result.status === JobStatus.FAILURE) {
|
|
62
|
+
console.log("Error:", result.error_message);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Available fields
|
|
66
|
+
result.status // JobStatus enum value (PENDING, STARTED, RETRY, SUCCESS, FAILURE, CANCELLED, CACHED) or null
|
|
67
|
+
result.error_message // Error string or null
|
|
68
|
+
result.outputs // AgentDatum[] from components["schemas"]["AgentDatum"]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Raw API Access
|
|
72
|
+
|
|
73
|
+
The generated raw client is exposed as `client.raw`:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { RoeClient } from "roe-typescript";
|
|
77
|
+
|
|
78
|
+
const client = new RoeClient({
|
|
79
|
+
apiKey: "your-api-key",
|
|
80
|
+
organizationId: "your-org-uuid",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const response = await client.raw.GET("/v1/users/current_user/");
|
|
84
|
+
console.log(response.response.status);
|
|
85
|
+
```
|
|
86
|
+
|
|
40
87
|
## Full Example
|
|
41
88
|
|
|
42
89
|
Create an agent that extracts structured data from websites:
|
|
@@ -86,13 +133,6 @@ for (const output of result.outputs) {
|
|
|
86
133
|
console.log(JSON.stringify(JSON.parse(output.value), null, 2));
|
|
87
134
|
}
|
|
88
135
|
|
|
89
|
-
// Download saved references (screenshots, HTML, markdown)
|
|
90
|
-
import { getJobReferences } from "roe-typescript";
|
|
91
|
-
for (const ref of getJobReferences(result)) {
|
|
92
|
-
const content = await client.agents.jobs.downloadReference(job.id, ref.resource_id);
|
|
93
|
-
// Save content as needed
|
|
94
|
-
}
|
|
95
|
-
|
|
96
136
|
// Cleanup
|
|
97
137
|
await client.agents.delete(agent.id);
|
|
98
138
|
```
|
|
@@ -432,3 +472,4 @@ const agent = await client.agents.create({
|
|
|
432
472
|
|
|
433
473
|
- [Roe AI](https://www.roe-ai.com/)
|
|
434
474
|
- [API Docs](https://docs.roe-ai.com)
|
|
475
|
+
- [Changelog](CHANGELOG.md)
|
package/dist/api/agents.d.ts
CHANGED
|
@@ -1,87 +1,100 @@
|
|
|
1
|
-
import { RoeConfig } from "../config.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AgentInputDefinition, AgentVersionWithApi, BaseAgentWithApi } from "../models/agent.js";
|
|
1
|
+
import type { RoeConfig } from "../config.js";
|
|
2
|
+
import type { RoeRawClient } from "../generated/client.js";
|
|
3
|
+
import type { components } from "../generated/schema.js";
|
|
5
4
|
import { Job, JobBatch } from "../models/job.js";
|
|
5
|
+
type BaseAgent = components["schemas"]["BaseAgent"];
|
|
6
|
+
type PaginatedBaseAgentList = components["schemas"]["PaginatedBaseAgentList"];
|
|
7
|
+
type AgentVersion = components["schemas"]["AgentVersion"];
|
|
8
|
+
type AgentJobStatus = components["schemas"]["AgentJobStatus"];
|
|
9
|
+
type AgentJobResultItem = components["schemas"]["AgentJobResultItem"];
|
|
10
|
+
type AgentJobDeleteDataResponse = components["schemas"]["AgentJobDeleteDataResponse"];
|
|
11
|
+
type AgentDatum = components["schemas"]["AgentDatum"];
|
|
6
12
|
export declare class AgentVersionsAPI {
|
|
7
13
|
private readonly agentsApi;
|
|
8
14
|
constructor(agentsApi: AgentsAPI);
|
|
9
|
-
private get
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
private get raw();
|
|
16
|
+
private get organizationId();
|
|
17
|
+
list(agentId: string): Promise<AgentVersion[]>;
|
|
18
|
+
retrieve(agentId: string, versionId: string, getSupportsEval?: boolean): Promise<AgentVersion>;
|
|
19
|
+
retrieveCurrent(agentId: string): Promise<AgentVersion>;
|
|
13
20
|
create(params: {
|
|
14
21
|
agentId: string;
|
|
15
|
-
inputDefinitions?:
|
|
22
|
+
inputDefinitions?: Array<Record<string, unknown>>;
|
|
16
23
|
engineConfig?: Record<string, unknown>;
|
|
17
24
|
versionName?: string;
|
|
18
25
|
description?: string;
|
|
19
|
-
}): Promise<
|
|
26
|
+
}): Promise<AgentVersion>;
|
|
20
27
|
update(agentId: string, versionId: string, updates: {
|
|
21
28
|
versionName?: string;
|
|
22
29
|
description?: string;
|
|
23
30
|
}): Promise<void>;
|
|
24
31
|
delete(agentId: string, versionId: string): Promise<void>;
|
|
25
|
-
private wrap;
|
|
26
32
|
}
|
|
27
33
|
export declare class AgentJobsAPI {
|
|
28
34
|
private readonly agentsApi;
|
|
29
35
|
private static MAX_BATCH_SIZE;
|
|
30
36
|
constructor(agentsApi: AgentsAPI);
|
|
31
|
-
private get
|
|
37
|
+
private get raw();
|
|
38
|
+
private get organizationId();
|
|
32
39
|
retrieveStatus(jobId: string): Promise<AgentJobStatus>;
|
|
33
|
-
retrieveResult(jobId: string): Promise<
|
|
34
|
-
retrieveStatusMany(jobIds: string[]): Promise<
|
|
35
|
-
retrieveResultMany(jobIds: string[]): Promise<
|
|
40
|
+
retrieveResult(jobId: string): Promise<components["schemas"]["AgentJobResultResponse"]>;
|
|
41
|
+
retrieveStatusMany(jobIds: string[]): Promise<AgentJobStatus[]>;
|
|
42
|
+
retrieveResultMany(jobIds: string[]): Promise<AgentJobResultItem[]>;
|
|
36
43
|
downloadReference(jobId: string, resourceId: string, asAttachment?: boolean): Promise<Buffer>;
|
|
37
|
-
|
|
44
|
+
cancel(jobId: string): Promise<void>;
|
|
45
|
+
cancelAll(agentId: string): Promise<void>;
|
|
46
|
+
deleteData(jobId: string): Promise<AgentJobDeleteDataResponse>;
|
|
38
47
|
private iterChunks;
|
|
39
48
|
}
|
|
40
49
|
export declare class AgentsAPI {
|
|
41
50
|
readonly config: RoeConfig;
|
|
42
|
-
readonly
|
|
51
|
+
readonly raw: RoeRawClient;
|
|
43
52
|
private static MAX_BATCH_SIZE;
|
|
44
53
|
readonly versions: AgentVersionsAPI;
|
|
45
54
|
readonly jobs: AgentJobsAPI;
|
|
46
|
-
constructor(config: RoeConfig,
|
|
47
|
-
private wrapBase;
|
|
55
|
+
constructor(config: RoeConfig, raw: RoeRawClient);
|
|
48
56
|
list(params?: {
|
|
49
57
|
page?: number;
|
|
50
58
|
pageSize?: number;
|
|
51
|
-
}): Promise<
|
|
52
|
-
retrieve(agentId: string): Promise<
|
|
59
|
+
}): Promise<PaginatedBaseAgentList>;
|
|
60
|
+
retrieve(agentId: string): Promise<BaseAgent>;
|
|
53
61
|
create(params: {
|
|
54
62
|
name: string;
|
|
55
63
|
engineClassId: string;
|
|
56
|
-
inputDefinitions?:
|
|
64
|
+
inputDefinitions?: Array<Record<string, unknown>>;
|
|
57
65
|
engineConfig?: Record<string, unknown>;
|
|
58
66
|
versionName?: string;
|
|
59
67
|
description?: string;
|
|
60
|
-
}): Promise<
|
|
68
|
+
}): Promise<BaseAgent>;
|
|
61
69
|
update(agentId: string, updates: {
|
|
62
70
|
name?: string;
|
|
63
71
|
disableCache?: boolean;
|
|
64
72
|
cacheFailedJobs?: boolean;
|
|
65
|
-
}): Promise<
|
|
73
|
+
}): Promise<BaseAgent>;
|
|
66
74
|
delete(agentId: string): Promise<void>;
|
|
67
|
-
duplicate(agentId: string): Promise<
|
|
75
|
+
duplicate(agentId: string): Promise<AgentVersion>;
|
|
68
76
|
run(params: {
|
|
69
77
|
agentId: string;
|
|
70
78
|
inputs: Record<string, unknown>;
|
|
71
79
|
timeoutSeconds?: number;
|
|
80
|
+
metadata?: Record<string, unknown>;
|
|
72
81
|
}): Promise<Job>;
|
|
73
82
|
runMany(params: {
|
|
74
83
|
agentId: string;
|
|
75
84
|
batchInputs: Record<string, unknown>[];
|
|
76
85
|
timeoutSeconds?: number;
|
|
86
|
+
metadata?: Record<string, unknown>;
|
|
77
87
|
}): Promise<JobBatch>;
|
|
78
|
-
runSync(agentId: string, inputs: Record<string, unknown>): Promise<AgentDatum[]>;
|
|
88
|
+
runSync(agentId: string, inputs: Record<string, unknown>, metadata?: Record<string, unknown>): Promise<AgentDatum[]>;
|
|
79
89
|
runVersion(params: {
|
|
80
90
|
agentId: string;
|
|
81
91
|
versionId: string;
|
|
82
92
|
inputs: Record<string, unknown>;
|
|
83
93
|
timeoutSeconds?: number;
|
|
94
|
+
metadata?: Record<string, unknown>;
|
|
84
95
|
}): Promise<Job>;
|
|
85
|
-
runVersionSync(agentId: string, versionId: string, inputs: Record<string, unknown>): Promise<AgentDatum[]>;
|
|
96
|
+
runVersionSync(agentId: string, versionId: string, inputs: Record<string, unknown>, metadata?: Record<string, unknown>): Promise<AgentDatum[]>;
|
|
97
|
+
private extractJobId;
|
|
86
98
|
private iterChunks;
|
|
87
99
|
}
|
|
100
|
+
export {};
|