@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,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threads Module - Fully Typed
|
|
3
|
+
*
|
|
4
|
+
* Naming conventions:
|
|
5
|
+
* - get* for singular items
|
|
6
|
+
* - list* for collections
|
|
7
|
+
* - create*, update*, delete* for mutations
|
|
8
|
+
*
|
|
9
|
+
* Convenience aliases are provided for common access patterns.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
13
|
+
import type { PaginationParams, PaginatedResponse } from "../client/helpers.js";
|
|
14
|
+
|
|
15
|
+
// Response types
|
|
16
|
+
export interface Thread {
|
|
17
|
+
id: string;
|
|
18
|
+
workspace_id: string;
|
|
19
|
+
tenant_id: string;
|
|
20
|
+
channel?: string;
|
|
21
|
+
external_conversation_id?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
created_at: string;
|
|
24
|
+
updated_at: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ThreadState {
|
|
28
|
+
thread_id: string;
|
|
29
|
+
values: Record<string, unknown>;
|
|
30
|
+
next?: string[];
|
|
31
|
+
tasks?: unknown[];
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface ThreadHistory {
|
|
36
|
+
thread_id: string;
|
|
37
|
+
checkpoints: unknown[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ThreadMessage {
|
|
41
|
+
id: string;
|
|
42
|
+
thread_id: string;
|
|
43
|
+
role: "human" | "assistant" | "system" | "developer";
|
|
44
|
+
content: string;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
created_at: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ThreadRun {
|
|
50
|
+
run_id: string;
|
|
51
|
+
thread_id: string;
|
|
52
|
+
agent_id: string;
|
|
53
|
+
status: string;
|
|
54
|
+
created_at: string;
|
|
55
|
+
completed_at?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type ThreadListResponse = PaginatedResponse<Thread>;
|
|
59
|
+
export type ThreadMessagesResponse = PaginatedResponse<ThreadMessage>;
|
|
60
|
+
export type ThreadRunsResponse = PaginatedResponse<ThreadRun>;
|
|
61
|
+
|
|
62
|
+
export interface ThreadSearchResponse {
|
|
63
|
+
items: Thread[];
|
|
64
|
+
total: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ThreadPruneResponse {
|
|
68
|
+
deleted_count: number;
|
|
69
|
+
thread_ids: string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export class ThreadsModule {
|
|
73
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
74
|
+
|
|
75
|
+
// ======================== CRUD ========================
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create a new thread.
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const { data: thread } = await client.threads.create();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
async create(body?: {
|
|
85
|
+
channel?: string;
|
|
86
|
+
external_conversation_id?: string;
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
}): Promise<APIResponse<Thread>> {
|
|
89
|
+
return this.client.POST<Thread>("/v1/api/threads", {
|
|
90
|
+
body: body ?? {},
|
|
91
|
+
headers: this.headers(),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get a thread by ID.
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const { data: thread } = await client.threads.get("thread-uuid");
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
async get(threadId: string): Promise<APIResponse<Thread>> {
|
|
103
|
+
return this.client.GET<Thread>("/v1/api/threads/{id}", {
|
|
104
|
+
params: { path: { id: threadId } },
|
|
105
|
+
headers: this.headers(),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* List all threads.
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const { data } = await client.threads.list({ limit: 20 });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
async list(params?: PaginationParams & {
|
|
117
|
+
workspace_id?: string;
|
|
118
|
+
}): Promise<APIResponse<ThreadListResponse>> {
|
|
119
|
+
return this.client.GET<ThreadListResponse>("/v1/api/threads", {
|
|
120
|
+
params: { query: params },
|
|
121
|
+
headers: this.headers(),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Delete a thread.
|
|
127
|
+
*/
|
|
128
|
+
async delete(threadId: string): Promise<APIResponse<void>> {
|
|
129
|
+
return this.client.DELETE<void>("/v1/api/threads/{id}", {
|
|
130
|
+
params: { path: { id: threadId } },
|
|
131
|
+
headers: this.headers(),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ======================== State ========================
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Get the current state of a thread.
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const { data: state } = await client.threads.getState("thread-uuid");
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
async getState(threadId: string): Promise<APIResponse<ThreadState>> {
|
|
145
|
+
return this.client.GET<ThreadState>("/v1/api/threads/{id}/state", {
|
|
146
|
+
params: { path: { id: threadId } },
|
|
147
|
+
headers: this.headers(),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Alias: threads.state() -> threads.getState() */
|
|
152
|
+
state = (threadId: string) => this.getState(threadId);
|
|
153
|
+
|
|
154
|
+
// ======================== History ========================
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Get the history of a thread.
|
|
158
|
+
*/
|
|
159
|
+
async getHistory(threadId: string): Promise<APIResponse<ThreadHistory>> {
|
|
160
|
+
return this.client.GET<ThreadHistory>("/v1/api/threads/{id}/history", {
|
|
161
|
+
params: { path: { id: threadId } },
|
|
162
|
+
headers: this.headers(),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Alias: threads.history() -> threads.getHistory() */
|
|
167
|
+
history = (threadId: string) => this.getHistory(threadId);
|
|
168
|
+
|
|
169
|
+
// ======================== Runs ========================
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get runs for a thread.
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const { data } = await client.threads.getRuns("thread-uuid");
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
async getRuns(threadId: string, params?: PaginationParams & {
|
|
179
|
+
status?: string
|
|
180
|
+
}): Promise<APIResponse<ThreadRunsResponse>> {
|
|
181
|
+
return this.client.GET<ThreadRunsResponse>("/v1/api/threads/{id}/runs", {
|
|
182
|
+
params: { path: { id: threadId }, query: params },
|
|
183
|
+
headers: this.headers(),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Alias: threads.runs() -> threads.getRuns() */
|
|
188
|
+
runs = (threadId: string, params?: PaginationParams & { status?: string }) =>
|
|
189
|
+
this.getRuns(threadId, params);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Create a run within a thread.
|
|
193
|
+
*/
|
|
194
|
+
async createRun(threadId: string, body: {
|
|
195
|
+
agent_id: string;
|
|
196
|
+
input?: unknown;
|
|
197
|
+
idempotency_key?: string;
|
|
198
|
+
}): Promise<APIResponse<ThreadRun>> {
|
|
199
|
+
return this.client.POST<ThreadRun>("/v1/api/threads/{id}/runs", {
|
|
200
|
+
params: { path: { id: threadId } },
|
|
201
|
+
body,
|
|
202
|
+
headers: this.headers(),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ======================== Messages ========================
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get messages in a thread.
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const { data } = await client.threads.getMessages("thread-uuid");
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
async getMessages(threadId: string, params?: PaginationParams): Promise<APIResponse<ThreadMessagesResponse>> {
|
|
216
|
+
return this.client.GET<ThreadMessagesResponse>("/v1/api/threads/{id}/messages", {
|
|
217
|
+
params: { path: { id: threadId }, query: params },
|
|
218
|
+
headers: this.headers(),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Alias: threads.messages() -> threads.getMessages() */
|
|
223
|
+
messages = (threadId: string, params?: PaginationParams) => this.getMessages(threadId, params);
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Add a message to a thread.
|
|
227
|
+
*/
|
|
228
|
+
async addMessage(threadId: string, body: {
|
|
229
|
+
role?: "human" | "system" | "developer";
|
|
230
|
+
content: string;
|
|
231
|
+
metadata?: Record<string, unknown>;
|
|
232
|
+
}): Promise<APIResponse<ThreadMessage>> {
|
|
233
|
+
return this.client.POST<ThreadMessage>("/v1/api/threads/{id}/messages", {
|
|
234
|
+
params: { path: { id: threadId } },
|
|
235
|
+
body,
|
|
236
|
+
headers: this.headers(),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ======================== Search ========================
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Search threads.
|
|
244
|
+
*/
|
|
245
|
+
async search(body: {
|
|
246
|
+
workspace_id?: string;
|
|
247
|
+
agent_id?: string;
|
|
248
|
+
created_after?: string;
|
|
249
|
+
created_before?: string;
|
|
250
|
+
sort_by?: string;
|
|
251
|
+
sort_desc?: boolean;
|
|
252
|
+
} & PaginationParams): Promise<APIResponse<ThreadSearchResponse>> {
|
|
253
|
+
return this.client.POST<ThreadSearchResponse>("/v1/api/threads/search", {
|
|
254
|
+
body,
|
|
255
|
+
headers: this.headers(),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ======================== Copy/Fork ========================
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Copy/fork a thread.
|
|
263
|
+
*/
|
|
264
|
+
async copy(threadId: string, options?: { copy_history?: boolean }): Promise<APIResponse<Thread>> {
|
|
265
|
+
return this.client.POST<Thread>("/v1/api/threads/{id}/copy", {
|
|
266
|
+
params: { path: { id: threadId } },
|
|
267
|
+
body: options ?? {},
|
|
268
|
+
headers: this.headers(),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ======================== Prune ========================
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Prune old threads.
|
|
276
|
+
*/
|
|
277
|
+
async prune(body: {
|
|
278
|
+
workspace_id?: string;
|
|
279
|
+
older_than_days?: number;
|
|
280
|
+
dry_run?: boolean;
|
|
281
|
+
} & PaginationParams): Promise<APIResponse<ThreadPruneResponse>> {
|
|
282
|
+
return this.client.POST<ThreadPruneResponse>("/v1/api/threads/prune", {
|
|
283
|
+
body,
|
|
284
|
+
headers: this.headers(),
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
export interface Tool {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
parameters?: Record<string, unknown>;
|
|
12
|
+
required_credentials?: string[];
|
|
13
|
+
is_builtin: boolean;
|
|
14
|
+
created_at?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ToolListResponse {
|
|
18
|
+
items: Tool[];
|
|
19
|
+
total: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ToolCallResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
output?: unknown;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class ToolsModule {
|
|
29
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* List all available tools.
|
|
33
|
+
*/
|
|
34
|
+
async list(params?: {
|
|
35
|
+
category?: string;
|
|
36
|
+
limit?: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
}): Promise<APIResponse<ToolListResponse>> {
|
|
39
|
+
return this.client.GET<ToolListResponse>("/v1/api/tools", {
|
|
40
|
+
params: { query: params },
|
|
41
|
+
headers: this.headers(),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get a tool by name.
|
|
47
|
+
*/
|
|
48
|
+
async get(toolName: string): Promise<APIResponse<Tool>> {
|
|
49
|
+
return this.client.GET<Tool>("/v1/api/tools/{name}", {
|
|
50
|
+
params: { path: { name: toolName } },
|
|
51
|
+
headers: this.headers(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Call a tool directly (testing).
|
|
57
|
+
*/
|
|
58
|
+
async call(toolName: string, args: unknown): Promise<APIResponse<ToolCallResult>> {
|
|
59
|
+
return this.client.POST<ToolCallResult>("/v1/api/tools/{name}/call", {
|
|
60
|
+
params: { path: { name: toolName } },
|
|
61
|
+
body: { arguments: args },
|
|
62
|
+
headers: this.headers(),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traces Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
export type SpanData = components["schemas"]["SpanData"];
|
|
8
|
+
type BatchIngestRequest = components["schemas"]["BatchIngestRequest"];
|
|
9
|
+
type AddFeedbackRequest = components["schemas"]["AddFeedbackRequest"];
|
|
10
|
+
|
|
11
|
+
export interface FeedbackRequest {
|
|
12
|
+
span_id: string;
|
|
13
|
+
score?: string;
|
|
14
|
+
comment?: string;
|
|
15
|
+
corrections?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Trace {
|
|
19
|
+
trace_id: string;
|
|
20
|
+
run_id?: string;
|
|
21
|
+
root_span_id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
status: "ok" | "error" | "pending";
|
|
24
|
+
start_time: string;
|
|
25
|
+
end_time?: string;
|
|
26
|
+
duration_ms?: number;
|
|
27
|
+
span_count: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Span {
|
|
31
|
+
trace_id: string;
|
|
32
|
+
span_id: string;
|
|
33
|
+
parent_span_id?: string;
|
|
34
|
+
name: string;
|
|
35
|
+
kind: string;
|
|
36
|
+
status: string;
|
|
37
|
+
status_message?: string;
|
|
38
|
+
start_time_unix_nano: number;
|
|
39
|
+
end_time_unix_nano?: number;
|
|
40
|
+
run_id?: string;
|
|
41
|
+
attributes?: Record<string, unknown>;
|
|
42
|
+
events?: unknown[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TraceListResponse {
|
|
46
|
+
items: Trace[];
|
|
47
|
+
total: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface SpanListResponse {
|
|
51
|
+
items: Span[];
|
|
52
|
+
total: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface TraceDetail extends Trace {
|
|
56
|
+
spans: Span[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export class TracesModule {
|
|
60
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* List traces.
|
|
64
|
+
*/
|
|
65
|
+
async list(params?: {
|
|
66
|
+
run_id?: string;
|
|
67
|
+
from?: string;
|
|
68
|
+
to?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
}): Promise<APIResponse<TraceListResponse>> {
|
|
72
|
+
return this.client.GET<TraceListResponse>("/v1/api/traces", {
|
|
73
|
+
params: { query: params },
|
|
74
|
+
headers: this.headers(),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get a trace by ID.
|
|
80
|
+
*/
|
|
81
|
+
async get(traceId: string): Promise<APIResponse<TraceDetail>> {
|
|
82
|
+
return this.client.GET<TraceDetail>("/v1/api/traces/{id}", {
|
|
83
|
+
params: { path: { id: traceId } },
|
|
84
|
+
headers: this.headers(),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get spans for a trace.
|
|
90
|
+
*/
|
|
91
|
+
async getSpans(traceId: string): Promise<APIResponse<SpanListResponse>> {
|
|
92
|
+
return this.client.GET<SpanListResponse>("/v1/api/traces/{id}/spans", {
|
|
93
|
+
params: { path: { id: traceId } },
|
|
94
|
+
headers: this.headers(),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Ingest spans (batch).
|
|
100
|
+
*/
|
|
101
|
+
async ingest(spans: SpanData[]): Promise<APIResponse<void>> {
|
|
102
|
+
return this.client.POST<void>("/v1/api/traces/ingest", {
|
|
103
|
+
body: { spans },
|
|
104
|
+
headers: this.headers(),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Add feedback to a span.
|
|
110
|
+
*/
|
|
111
|
+
async addFeedback(feedback: FeedbackRequest): Promise<APIResponse<void>> {
|
|
112
|
+
return this.client.POST<void>("/v1/api/traces/feedback", {
|
|
113
|
+
body: feedback,
|
|
114
|
+
headers: this.headers(),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triggers Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
type UpdateTriggerRequest = components["schemas"]["UpdateTriggerRequest"];
|
|
8
|
+
|
|
9
|
+
export interface Trigger {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
workspace_id: string;
|
|
13
|
+
agent_id: string;
|
|
14
|
+
agent_version_id?: string;
|
|
15
|
+
trigger_type: "webhook" | "schedule" | "event";
|
|
16
|
+
config?: Record<string, unknown>;
|
|
17
|
+
webhook_url?: string;
|
|
18
|
+
webhook_secret?: string;
|
|
19
|
+
is_active: boolean;
|
|
20
|
+
created_at: string;
|
|
21
|
+
updated_at: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface TriggerListResponse {
|
|
25
|
+
items: Trigger[];
|
|
26
|
+
total: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TriggerInvokeResponse {
|
|
30
|
+
run_id: string;
|
|
31
|
+
triggered_at: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class TriggersModule {
|
|
35
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* List all triggers.
|
|
39
|
+
*/
|
|
40
|
+
async list(params?: {
|
|
41
|
+
workspace_id?: string;
|
|
42
|
+
agent_id?: string;
|
|
43
|
+
trigger_type?: string;
|
|
44
|
+
limit?: number;
|
|
45
|
+
offset?: number;
|
|
46
|
+
}): Promise<APIResponse<TriggerListResponse>> {
|
|
47
|
+
return this.client.GET<TriggerListResponse>("/v1/api/triggers", {
|
|
48
|
+
params: { query: params },
|
|
49
|
+
headers: this.headers(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get a trigger by ID.
|
|
55
|
+
*/
|
|
56
|
+
async get(triggerId: string): Promise<APIResponse<Trigger>> {
|
|
57
|
+
return this.client.GET<Trigger>("/v1/api/triggers/{id}", {
|
|
58
|
+
params: { path: { id: triggerId } },
|
|
59
|
+
headers: this.headers(),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create a new trigger.
|
|
65
|
+
*/
|
|
66
|
+
async create(body: {
|
|
67
|
+
name: string;
|
|
68
|
+
agent_id: string;
|
|
69
|
+
agent_version_id?: string;
|
|
70
|
+
trigger_type: "webhook" | "schedule" | "event";
|
|
71
|
+
config?: Record<string, unknown>;
|
|
72
|
+
}): Promise<APIResponse<Trigger>> {
|
|
73
|
+
return this.client.POST<Trigger>("/v1/api/triggers", {
|
|
74
|
+
body,
|
|
75
|
+
headers: this.headers(),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Update a trigger.
|
|
81
|
+
*/
|
|
82
|
+
async update(triggerId: string, body: {
|
|
83
|
+
name?: string;
|
|
84
|
+
is_active?: boolean;
|
|
85
|
+
}): Promise<APIResponse<Trigger>> {
|
|
86
|
+
return this.client.PUT<Trigger>("/v1/api/triggers/{id}", {
|
|
87
|
+
params: { path: { id: triggerId } },
|
|
88
|
+
body,
|
|
89
|
+
headers: this.headers(),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Delete a trigger.
|
|
95
|
+
*/
|
|
96
|
+
async delete(triggerId: string): Promise<APIResponse<void>> {
|
|
97
|
+
return this.client.DELETE<void>("/v1/api/triggers/{id}", {
|
|
98
|
+
params: { path: { id: triggerId } },
|
|
99
|
+
headers: this.headers(),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Invoke a trigger manually.
|
|
105
|
+
*/
|
|
106
|
+
async invoke(triggerId: string, payload?: unknown): Promise<APIResponse<TriggerInvokeResponse>> {
|
|
107
|
+
return this.client.POST<TriggerInvokeResponse>("/v1/api/triggers/{id}/invoke", {
|
|
108
|
+
params: { path: { id: triggerId } },
|
|
109
|
+
body: { payload },
|
|
110
|
+
headers: this.headers(),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage Module - Fully Typed
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
6
|
+
|
|
7
|
+
export interface UsageQuota {
|
|
8
|
+
resource: string;
|
|
9
|
+
limit: number;
|
|
10
|
+
used: number;
|
|
11
|
+
remaining: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UsageResponse {
|
|
15
|
+
workspace_id: string;
|
|
16
|
+
period_start: string;
|
|
17
|
+
period_end: string;
|
|
18
|
+
quotas: UsageQuota[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class UsageModule {
|
|
22
|
+
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get current usage and quotas.
|
|
26
|
+
*/
|
|
27
|
+
async get(): Promise<APIResponse<UsageResponse>> {
|
|
28
|
+
return this.client.GET<UsageResponse>("/v1/api/usage", {
|
|
29
|
+
headers: this.headers(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|