@agent-os-sdk/client 0.1.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 +71 -0
- package/dist/client/AgentOsClient.d.ts +161 -0
- package/dist/client/AgentOsClient.d.ts.map +1 -0
- package/dist/client/AgentOsClient.js +217 -0
- package/dist/client/helpers.d.ts +63 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +55 -0
- package/dist/client/raw.d.ts +138 -0
- package/dist/client/raw.d.ts.map +1 -0
- package/dist/client/raw.js +97 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +1 -0
- package/dist/generated/openapi.d.ts +6810 -0
- package/dist/generated/openapi.d.ts.map +1 -0
- package/dist/generated/openapi.js +5 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/modules/a2a.d.ts +48 -0
- package/dist/modules/a2a.d.ts.map +1 -0
- package/dist/modules/a2a.js +37 -0
- package/dist/modules/agents.d.ts +137 -0
- package/dist/modules/agents.d.ts.map +1 -0
- package/dist/modules/agents.js +154 -0
- package/dist/modules/audit.d.ts +55 -0
- package/dist/modules/audit.d.ts.map +1 -0
- package/dist/modules/audit.js +38 -0
- package/dist/modules/builder.d.ts +65 -0
- package/dist/modules/builder.d.ts.map +1 -0
- package/dist/modules/builder.js +119 -0
- package/dist/modules/checkpoints.d.ts +53 -0
- package/dist/modules/checkpoints.d.ts.map +1 -0
- package/dist/modules/checkpoints.js +39 -0
- package/dist/modules/credentials.d.ts +89 -0
- package/dist/modules/credentials.d.ts.map +1 -0
- package/dist/modules/credentials.js +79 -0
- package/dist/modules/crons.d.ts +72 -0
- package/dist/modules/crons.d.ts.map +1 -0
- package/dist/modules/crons.js +66 -0
- package/dist/modules/dlq.d.ts +60 -0
- package/dist/modules/dlq.d.ts.map +1 -0
- package/dist/modules/dlq.js +56 -0
- package/dist/modules/evaluation.d.ts +119 -0
- package/dist/modules/evaluation.d.ts.map +1 -0
- package/dist/modules/evaluation.js +96 -0
- package/dist/modules/files.d.ts +68 -0
- package/dist/modules/files.d.ts.map +1 -0
- package/dist/modules/files.js +66 -0
- package/dist/modules/graphs.d.ts +51 -0
- package/dist/modules/graphs.d.ts.map +1 -0
- package/dist/modules/graphs.js +29 -0
- package/dist/modules/info.d.ts +27 -0
- package/dist/modules/info.d.ts.map +1 -0
- package/dist/modules/info.js +27 -0
- package/dist/modules/knowledge.d.ts +91 -0
- package/dist/modules/knowledge.d.ts.map +1 -0
- package/dist/modules/knowledge.js +80 -0
- package/dist/modules/mcp.d.ts +39 -0
- package/dist/modules/mcp.d.ts.map +1 -0
- package/dist/modules/mcp.js +38 -0
- package/dist/modules/me.d.ts +27 -0
- package/dist/modules/me.d.ts.map +1 -0
- package/dist/modules/me.js +19 -0
- package/dist/modules/members.d.ts +77 -0
- package/dist/modules/members.d.ts.map +1 -0
- package/dist/modules/members.js +77 -0
- package/dist/modules/metrics.d.ts +16 -0
- package/dist/modules/metrics.d.ts.map +1 -0
- package/dist/modules/metrics.js +24 -0
- package/dist/modules/playground.d.ts +42 -0
- package/dist/modules/playground.d.ts.map +1 -0
- package/dist/modules/playground.js +48 -0
- package/dist/modules/prompts.d.ts +87 -0
- package/dist/modules/prompts.d.ts.map +1 -0
- package/dist/modules/prompts.js +87 -0
- package/dist/modules/runs.d.ts +181 -0
- package/dist/modules/runs.d.ts.map +1 -0
- package/dist/modules/runs.js +187 -0
- package/dist/modules/store.d.ts +37 -0
- package/dist/modules/store.d.ts.map +1 -0
- package/dist/modules/store.js +48 -0
- package/dist/modules/tenants.d.ts +42 -0
- package/dist/modules/tenants.d.ts.map +1 -0
- package/dist/modules/tenants.js +45 -0
- package/dist/modules/threads.d.ts +181 -0
- package/dist/modules/threads.d.ts.map +1 -0
- package/dist/modules/threads.js +178 -0
- package/dist/modules/tools.d.ts +44 -0
- package/dist/modules/tools.d.ts.map +1 -0
- package/dist/modules/tools.js +39 -0
- package/dist/modules/traces.d.ts +79 -0
- package/dist/modules/traces.d.ts.map +1 -0
- package/dist/modules/traces.js +56 -0
- package/dist/modules/triggers.d.ts +71 -0
- package/dist/modules/triggers.d.ts.map +1 -0
- package/dist/modules/triggers.js +67 -0
- package/dist/modules/usage.d.ts +26 -0
- package/dist/modules/usage.d.ts.map +1 -0
- package/dist/modules/usage.js +19 -0
- package/dist/modules/vectorStores.d.ts +97 -0
- package/dist/modules/vectorStores.d.ts.map +1 -0
- package/dist/modules/vectorStores.js +87 -0
- package/dist/modules/workspaces.d.ts +52 -0
- package/dist/modules/workspaces.d.ts.map +1 -0
- package/dist/modules/workspaces.js +59 -0
- package/dist/sse/client.d.ts +62 -0
- package/dist/sse/client.d.ts.map +1 -0
- package/dist/sse/client.js +66 -0
- package/package.json +50 -0
- package/src/client/AgentOsClient.ts +269 -0
- package/src/client/helpers.ts +98 -0
- package/src/client/raw.ts +241 -0
- package/src/generated/index.ts +2 -0
- package/src/generated/openapi.ts +6810 -0
- package/src/generated/swagger.json +8549 -0
- package/src/index.ts +161 -0
- package/src/modules/a2a.ts +64 -0
- package/src/modules/agents.ts +229 -0
- package/src/modules/audit.ts +74 -0
- package/src/modules/builder.ts +166 -0
- package/src/modules/checkpoints.ts +78 -0
- package/src/modules/credentials.ts +144 -0
- package/src/modules/crons.ts +114 -0
- package/src/modules/dlq.ts +93 -0
- package/src/modules/evaluation.ts +189 -0
- package/src/modules/files.ts +112 -0
- package/src/modules/graphs.ts +50 -0
- package/src/modules/info.ts +35 -0
- package/src/modules/knowledge.ts +147 -0
- package/src/modules/mcp.ts +59 -0
- package/src/modules/me.ts +32 -0
- package/src/modules/members.ts +117 -0
- package/src/modules/metrics.ts +27 -0
- package/src/modules/playground.ts +68 -0
- package/src/modules/prompts.ts +147 -0
- package/src/modules/runs.ts +277 -0
- package/src/modules/store.ts +65 -0
- package/src/modules/tenants.ts +67 -0
- package/src/modules/threads.ts +287 -0
- package/src/modules/tools.ts +65 -0
- package/src/modules/traces.ts +117 -0
- package/src/modules/triggers.ts +113 -0
- package/src/modules/usage.ts +32 -0
- package/src/modules/vectorStores.ts +160 -0
- package/src/modules/workspaces.ts +89 -0
- package/src/sse/client.ts +100 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
type CreatePromptRequest = components["schemas"]["CreatePromptRequest"];
|
|
8
|
+
type CreatePromptVersionRequest = components["schemas"]["CreatePromptVersionRequest"];
|
|
9
|
+
|
|
10
|
+
export interface Prompt {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
workspace_id: string;
|
|
15
|
+
tenant_id: string;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
versions?: PromptVersion[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PromptVersion {
|
|
22
|
+
id: string;
|
|
23
|
+
prompt_id: string;
|
|
24
|
+
version: number;
|
|
25
|
+
template: string;
|
|
26
|
+
input_schema?: Record<string, unknown>;
|
|
27
|
+
output_schema?: Record<string, unknown>;
|
|
28
|
+
is_live: boolean;
|
|
29
|
+
created_at: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PromptListResponse {
|
|
33
|
+
items: Prompt[];
|
|
34
|
+
total: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface PromptVersionListResponse {
|
|
38
|
+
items: PromptVersion[];
|
|
39
|
+
total: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RenderPromptResponse {
|
|
43
|
+
rendered: string;
|
|
44
|
+
input_used: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class PromptsModule {
|
|
48
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* List all prompts.
|
|
52
|
+
*/
|
|
53
|
+
async list(params?: {
|
|
54
|
+
workspace_id?: string;
|
|
55
|
+
limit?: number;
|
|
56
|
+
offset?: number;
|
|
57
|
+
}): Promise<APIResponse<PromptListResponse>> {
|
|
58
|
+
return this.client.GET<PromptListResponse>("/v1/api/prompts", {
|
|
59
|
+
params: { query: params },
|
|
60
|
+
headers: this.headers(),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get a prompt by ID.
|
|
66
|
+
*/
|
|
67
|
+
async get(promptId: string): Promise<APIResponse<Prompt>> {
|
|
68
|
+
return this.client.GET<Prompt>("/v1/api/prompts/{id}", {
|
|
69
|
+
params: { path: { id: promptId } },
|
|
70
|
+
headers: this.headers(),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Create a new prompt.
|
|
76
|
+
*/
|
|
77
|
+
async create(body: {
|
|
78
|
+
name: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
template?: string;
|
|
81
|
+
input_schema?: Record<string, unknown>;
|
|
82
|
+
}): Promise<APIResponse<Prompt>> {
|
|
83
|
+
return this.client.POST<Prompt>("/v1/api/prompts", {
|
|
84
|
+
body,
|
|
85
|
+
headers: this.headers(),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Delete a prompt.
|
|
91
|
+
*/
|
|
92
|
+
async delete(promptId: string): Promise<APIResponse<void>> {
|
|
93
|
+
return this.client.DELETE<void>("/v1/api/prompts/{id}", {
|
|
94
|
+
params: { path: { id: promptId } },
|
|
95
|
+
headers: this.headers(),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ======================== Versions ========================
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* List all versions of a prompt.
|
|
103
|
+
*/
|
|
104
|
+
async listVersions(promptId: string): Promise<APIResponse<PromptVersionListResponse>> {
|
|
105
|
+
return this.client.GET<PromptVersionListResponse>("/v1/api/prompts/{id}/versions", {
|
|
106
|
+
params: { path: { id: promptId } },
|
|
107
|
+
headers: this.headers(),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Create a new version.
|
|
113
|
+
*/
|
|
114
|
+
async createVersion(promptId: string, body: {
|
|
115
|
+
template: string;
|
|
116
|
+
input_schema?: Record<string, unknown>;
|
|
117
|
+
output_schema?: Record<string, unknown>;
|
|
118
|
+
}): Promise<APIResponse<PromptVersion>> {
|
|
119
|
+
return this.client.POST<PromptVersion>("/v1/api/prompts/{id}/versions", {
|
|
120
|
+
params: { path: { id: promptId } },
|
|
121
|
+
body,
|
|
122
|
+
headers: this.headers(),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Set the live version.
|
|
128
|
+
*/
|
|
129
|
+
async setLiveVersion(promptId: string, versionNumber: number): Promise<APIResponse<void>> {
|
|
130
|
+
return this.client.POST<void>("/v1/api/prompts/{id}/set-live", {
|
|
131
|
+
params: { path: { id: promptId } },
|
|
132
|
+
body: { version_number: versionNumber },
|
|
133
|
+
headers: this.headers(),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Render a prompt with variables.
|
|
139
|
+
*/
|
|
140
|
+
async render(promptId: string, variables: Record<string, unknown>): Promise<APIResponse<RenderPromptResponse>> {
|
|
141
|
+
return this.client.POST<RenderPromptResponse>("/v1/api/prompts/{id}/render", {
|
|
142
|
+
params: { path: { id: promptId } },
|
|
143
|
+
body: { variables },
|
|
144
|
+
headers: this.headers(),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs Module - Core execution API (Fully Typed)
|
|
3
|
+
*
|
|
4
|
+
* Naming conventions:
|
|
5
|
+
* - get* for singular items
|
|
6
|
+
* - list* for collections
|
|
7
|
+
* - create*, update*, delete* for mutations
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
11
|
+
import type { PaginationParams, PaginatedResponse } from "../client/helpers.js";
|
|
12
|
+
import { streamSSE, type SSEEvent, type RunStreamEvent, type SSEOptions } from "../sse/client.js";
|
|
13
|
+
|
|
14
|
+
// Type aliases from OpenAPI
|
|
15
|
+
type WaitRunResponse = components["schemas"]["WaitRunResponse"];
|
|
16
|
+
type BatchRunResponse = components["schemas"]["BatchRunResponse"];
|
|
17
|
+
type CancelRunResponse = components["schemas"]["CancelRunResponse"];
|
|
18
|
+
type CheckpointListResponse = components["schemas"]["CheckpointListResponse"];
|
|
19
|
+
|
|
20
|
+
// Response types
|
|
21
|
+
export interface Run {
|
|
22
|
+
run_id: string;
|
|
23
|
+
status: "pending" | "running" | "completed" | "failed" | "cancelled" | "waiting_input";
|
|
24
|
+
thread_id?: string;
|
|
25
|
+
agent_id: string;
|
|
26
|
+
agent_version_id?: string;
|
|
27
|
+
tenant_id: string;
|
|
28
|
+
workspace_id: string;
|
|
29
|
+
input?: unknown;
|
|
30
|
+
output?: unknown;
|
|
31
|
+
error?: unknown;
|
|
32
|
+
created_at: string;
|
|
33
|
+
started_at?: string;
|
|
34
|
+
completed_at?: string;
|
|
35
|
+
duration_ms?: number;
|
|
36
|
+
reused?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface RunEvent {
|
|
40
|
+
id: string;
|
|
41
|
+
run_id: string;
|
|
42
|
+
event_type: string;
|
|
43
|
+
node?: string;
|
|
44
|
+
data?: unknown;
|
|
45
|
+
timestamp: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface CreateRunResponse {
|
|
49
|
+
run_id: string;
|
|
50
|
+
status: string;
|
|
51
|
+
reused?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type RunListResponse = PaginatedResponse<Run>;
|
|
55
|
+
export type RunEventsResponse = PaginatedResponse<RunEvent>;
|
|
56
|
+
|
|
57
|
+
export class RunsModule {
|
|
58
|
+
constructor(
|
|
59
|
+
private client: RawClient,
|
|
60
|
+
private baseUrl: string,
|
|
61
|
+
private headers: () => Record<string, string>
|
|
62
|
+
) { }
|
|
63
|
+
|
|
64
|
+
// ======================== CRUD ========================
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create a new run.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const { data } = await client.runs.create({
|
|
71
|
+
* agent_id: "agent-uuid",
|
|
72
|
+
* input: { message: "Hello" }
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
async create(body: {
|
|
77
|
+
agent_id: string;
|
|
78
|
+
thread?: { thread_id?: string } | { new_thread: true };
|
|
79
|
+
input?: unknown;
|
|
80
|
+
idempotency_key?: string;
|
|
81
|
+
}): Promise<APIResponse<CreateRunResponse>> {
|
|
82
|
+
return this.client.POST<CreateRunResponse>("/v1/api/runs", {
|
|
83
|
+
body,
|
|
84
|
+
headers: this.headers(),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get a run by ID.
|
|
90
|
+
*/
|
|
91
|
+
async get(runId: string): Promise<APIResponse<Run>> {
|
|
92
|
+
return this.client.GET<Run>("/v1/api/runs/{runId}", {
|
|
93
|
+
params: { path: { runId } },
|
|
94
|
+
headers: this.headers(),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* List runs with optional filters.
|
|
100
|
+
*/
|
|
101
|
+
async list(params?: PaginationParams & {
|
|
102
|
+
thread_id?: string;
|
|
103
|
+
agent_id?: string;
|
|
104
|
+
status?: string;
|
|
105
|
+
}): Promise<APIResponse<RunListResponse>> {
|
|
106
|
+
return this.client.GET<RunListResponse>("/v1/api/runs", {
|
|
107
|
+
params: { query: params },
|
|
108
|
+
headers: this.headers(),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ======================== Execution ========================
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Wait for run completion synchronously.
|
|
116
|
+
*/
|
|
117
|
+
async wait(body: {
|
|
118
|
+
agent_id: string;
|
|
119
|
+
thread?: { thread_id?: string } | { new_thread: true };
|
|
120
|
+
input?: unknown;
|
|
121
|
+
timeout_seconds?: number;
|
|
122
|
+
}): Promise<APIResponse<WaitRunResponse>> {
|
|
123
|
+
return this.client.POST<WaitRunResponse>("/v1/api/runs/wait", {
|
|
124
|
+
body,
|
|
125
|
+
headers: this.headers(),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Create batch runs.
|
|
131
|
+
*/
|
|
132
|
+
async batch(body: {
|
|
133
|
+
agent_id: string;
|
|
134
|
+
inputs: Array<{ input: unknown; idempotency_key?: string }>;
|
|
135
|
+
}): Promise<APIResponse<BatchRunResponse>> {
|
|
136
|
+
return this.client.POST<BatchRunResponse>("/v1/api/runs/batch", {
|
|
137
|
+
body,
|
|
138
|
+
headers: this.headers(),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Cancel a running run.
|
|
144
|
+
*/
|
|
145
|
+
async cancel(runId: string, reason?: string): Promise<APIResponse<CancelRunResponse>> {
|
|
146
|
+
return this.client.POST<CancelRunResponse>("/v1/api/runs/{runId}/cancel", {
|
|
147
|
+
params: { path: { runId } },
|
|
148
|
+
body: { reason },
|
|
149
|
+
headers: this.headers(),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Resume a run waiting for human input (HITL).
|
|
155
|
+
*/
|
|
156
|
+
async resume(runId: string, input: unknown): Promise<APIResponse<Run>> {
|
|
157
|
+
return this.client.POST<Run>("/v1/api/runs/{runId}/resume", {
|
|
158
|
+
params: { path: { runId } },
|
|
159
|
+
body: { input },
|
|
160
|
+
headers: this.headers(),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Rerun from start (stateless).
|
|
166
|
+
*/
|
|
167
|
+
async rerun(runId: string): Promise<APIResponse<CreateRunResponse>> {
|
|
168
|
+
return this.client.POST<CreateRunResponse>("/v1/api/runs/{runId}/rerun", {
|
|
169
|
+
params: { path: { runId } },
|
|
170
|
+
headers: this.headers(),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Replay from checkpoint (stateful).
|
|
176
|
+
*/
|
|
177
|
+
async replay(runId: string, checkpointId?: string, mode?: "best_effort" | "deterministic"): Promise<APIResponse<CreateRunResponse>> {
|
|
178
|
+
return this.client.POST<CreateRunResponse>("/v1/api/runs/{runId}/replay", {
|
|
179
|
+
params: { path: { runId } },
|
|
180
|
+
body: { checkpoint_id: checkpointId, mode },
|
|
181
|
+
headers: this.headers(),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ======================== Events ========================
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Get run events for timeline (paged, no SSE).
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* const { data } = await client.runs.getEvents("run-uuid");
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
async getEvents(runId: string, params?: PaginationParams): Promise<APIResponse<RunEventsResponse>> {
|
|
195
|
+
return this.client.GET<RunEventsResponse>("/v1/api/runs/{runId}/events", {
|
|
196
|
+
params: { path: { runId }, query: params },
|
|
197
|
+
headers: this.headers(),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Alias: runs.events() -> runs.getEvents() */
|
|
202
|
+
events = (runId: string, params?: PaginationParams) => this.getEvents(runId, params);
|
|
203
|
+
|
|
204
|
+
// ======================== Checkpoints ========================
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Get checkpoints for a run.
|
|
208
|
+
*/
|
|
209
|
+
async getCheckpoints(runId: string): Promise<APIResponse<CheckpointListResponse>> {
|
|
210
|
+
return this.client.GET<CheckpointListResponse>("/v1/api/runs/{runId}/checkpoints", {
|
|
211
|
+
params: { path: { runId } },
|
|
212
|
+
headers: this.headers(),
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Alias: runs.checkpoints() -> runs.getCheckpoints() */
|
|
217
|
+
checkpoints = (runId: string) => this.getCheckpoints(runId);
|
|
218
|
+
|
|
219
|
+
// ======================== STREAMING ========================
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Stream run events via SSE.
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* for await (const event of client.runs.stream("run-uuid")) {
|
|
226
|
+
* console.log(event.data);
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
stream(runId: string, options?: SSEOptions): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
231
|
+
const url = `${this.baseUrl}/v1/api/runs/${runId}/stream`;
|
|
232
|
+
return streamSSE<RunStreamEvent>(url, {
|
|
233
|
+
...options,
|
|
234
|
+
headers: { ...this.headers(), ...options?.headers },
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Create run and stream output.
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* for await (const event of client.runs.createAndStream({
|
|
243
|
+
* agent_id: "...",
|
|
244
|
+
* input: { message: "Hello" }
|
|
245
|
+
* })) {
|
|
246
|
+
* console.log(event);
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
async *createAndStream(
|
|
251
|
+
body: {
|
|
252
|
+
agent_id: string;
|
|
253
|
+
thread?: { thread_id?: string } | { new_thread: true };
|
|
254
|
+
input?: unknown;
|
|
255
|
+
},
|
|
256
|
+
options?: SSEOptions
|
|
257
|
+
): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
258
|
+
const { data, error } = await this.create(body);
|
|
259
|
+
if (error || !data) {
|
|
260
|
+
throw new Error(`Failed to create run: ${JSON.stringify(error)}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const runId = data.run_id;
|
|
264
|
+
yield* this.stream(runId, options);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Join an existing run's stream (resume watching).
|
|
269
|
+
*/
|
|
270
|
+
join(runId: string, options?: SSEOptions): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
271
|
+
const url = `${this.baseUrl}/v1/api/runs/${runId}/join`;
|
|
272
|
+
return streamSSE<RunStreamEvent>(url, {
|
|
273
|
+
...options,
|
|
274
|
+
headers: { ...this.headers(), ...options?.headers },
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
type StoreValueRequest = components["schemas"]["StoreValueRequest"];
|
|
8
|
+
|
|
9
|
+
export interface StoreValue {
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
ttl_seconds?: number;
|
|
13
|
+
created_at: string;
|
|
14
|
+
expires_at?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface StoreKeysResponse {
|
|
18
|
+
keys: string[];
|
|
19
|
+
total: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class StoreModule {
|
|
23
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get a value by key.
|
|
27
|
+
*/
|
|
28
|
+
async get(key: string): Promise<APIResponse<StoreValue>> {
|
|
29
|
+
return this.client.GET<StoreValue>("/v1/api/store/{key}", {
|
|
30
|
+
params: { path: { key } },
|
|
31
|
+
headers: this.headers(),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Set a value.
|
|
37
|
+
*/
|
|
38
|
+
async set(key: string, value: string, ttlSeconds?: number): Promise<APIResponse<StoreValue>> {
|
|
39
|
+
return this.client.PUT<StoreValue>("/v1/api/store/{key}", {
|
|
40
|
+
params: { path: { key } },
|
|
41
|
+
body: { value, ttl_seconds: ttlSeconds },
|
|
42
|
+
headers: this.headers(),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Delete a value.
|
|
48
|
+
*/
|
|
49
|
+
async delete(key: string): Promise<APIResponse<void>> {
|
|
50
|
+
return this.client.DELETE<void>("/v1/api/store/{key}", {
|
|
51
|
+
params: { path: { key } },
|
|
52
|
+
headers: this.headers(),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* List all keys.
|
|
58
|
+
*/
|
|
59
|
+
async listKeys(prefix?: string): Promise<APIResponse<StoreKeysResponse>> {
|
|
60
|
+
return this.client.GET<StoreKeysResponse>("/v1/api/store", {
|
|
61
|
+
params: { query: { prefix } },
|
|
62
|
+
headers: this.headers(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenants Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
type UpdateTenantRequest = components["schemas"]["UpdateTenantRequest"];
|
|
8
|
+
|
|
9
|
+
export interface Tenant {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
owner_id?: string;
|
|
14
|
+
settings?: Record<string, unknown>;
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TenantListResponse {
|
|
20
|
+
items: Tenant[];
|
|
21
|
+
total: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class TenantsModule {
|
|
25
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get the current tenant.
|
|
29
|
+
*/
|
|
30
|
+
async get(): Promise<APIResponse<Tenant>> {
|
|
31
|
+
return this.client.GET<Tenant>("/v1/api/tenants/current", {
|
|
32
|
+
headers: this.headers(),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Update the current tenant.
|
|
38
|
+
*/
|
|
39
|
+
async update(body: {
|
|
40
|
+
name?: string;
|
|
41
|
+
slug?: string;
|
|
42
|
+
}): Promise<APIResponse<Tenant>> {
|
|
43
|
+
return this.client.PUT<Tenant>("/v1/api/tenants/current", {
|
|
44
|
+
body,
|
|
45
|
+
headers: this.headers(),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get tenant settings.
|
|
51
|
+
*/
|
|
52
|
+
async getSettings(): Promise<APIResponse<Record<string, unknown>>> {
|
|
53
|
+
return this.client.GET<Record<string, unknown>>("/v1/api/tenants/current/settings", {
|
|
54
|
+
headers: this.headers(),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Update tenant settings.
|
|
60
|
+
*/
|
|
61
|
+
async updateSettings(settings: Record<string, unknown>): Promise<APIResponse<void>> {
|
|
62
|
+
return this.client.PUT<void>("/v1/api/tenants/current/settings", {
|
|
63
|
+
body: settings,
|
|
64
|
+
headers: this.headers(),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|