@agent-os-sdk/client 0.9.25 → 0.9.27
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/dist/generated/openapi.d.ts +82 -0
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/templates.d.ts +23 -0
- package/dist/modules/templates.d.ts.map +1 -1
- package/dist/modules/templates.js +7 -0
- package/package.json +2 -2
- package/src/client/AgentOsClient.ts +0 -294
- package/src/client/HttpRequestBuilder.ts +0 -115
- package/src/client/OperationContext.ts +0 -22
- package/src/client/OperationContextProvider.ts +0 -89
- package/src/client/auth.ts +0 -136
- package/src/client/config.ts +0 -100
- package/src/client/helpers.ts +0 -98
- package/src/client/pagination.ts +0 -218
- package/src/client/raw.ts +0 -609
- package/src/client/retry.ts +0 -150
- package/src/client/sanitize.ts +0 -31
- package/src/client/timeout.ts +0 -59
- package/src/errors/factory.ts +0 -140
- package/src/errors/index.ts +0 -365
- package/src/generated/client.ts +0 -32
- package/src/generated/index.ts +0 -2
- package/src/generated/openapi.ts +0 -12302
- package/src/generated/swagger.json +0 -16851
- package/src/index.ts +0 -131
- package/src/modules/a2a.ts +0 -64
- package/src/modules/agents.ts +0 -604
- package/src/modules/apiTokens.ts +0 -101
- package/src/modules/approvals.ts +0 -151
- package/src/modules/audit.ts +0 -145
- package/src/modules/auth.ts +0 -33
- package/src/modules/catalog.ts +0 -241
- package/src/modules/chatwoot.ts +0 -242
- package/src/modules/checkpoints.ts +0 -87
- package/src/modules/contracts.ts +0 -80
- package/src/modules/credentials.ts +0 -216
- package/src/modules/crons.ts +0 -115
- package/src/modules/datasets.ts +0 -142
- package/src/modules/evaluation.ts +0 -269
- package/src/modules/files.ts +0 -208
- package/src/modules/improvements.ts +0 -71
- package/src/modules/info.ts +0 -143
- package/src/modules/me.ts +0 -74
- package/src/modules/members.ts +0 -199
- package/src/modules/memberships.ts +0 -42
- package/src/modules/metaAgent.ts +0 -131
- package/src/modules/metrics.ts +0 -34
- package/src/modules/observability.ts +0 -28
- package/src/modules/playground.ts +0 -68
- package/src/modules/presets.ts +0 -246
- package/src/modules/prompts.ts +0 -147
- package/src/modules/roles.ts +0 -112
- package/src/modules/runs.ts +0 -878
- package/src/modules/store.ts +0 -65
- package/src/modules/templates.ts +0 -40
- package/src/modules/tenants.ts +0 -79
- package/src/modules/threads.ts +0 -343
- package/src/modules/tools.ts +0 -91
- package/src/modules/traces.ts +0 -133
- package/src/modules/triggers.ts +0 -357
- package/src/modules/usage.ts +0 -117
- package/src/modules/vectorStores.ts +0 -257
- package/src/modules/workspaces.ts +0 -216
- package/src/sse/client.ts +0 -179
package/src/modules/store.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
}
|
package/src/modules/templates.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
2
|
-
|
|
3
|
-
export interface AuthoringTemplateSummary {
|
|
4
|
-
template_ref: string;
|
|
5
|
-
version: string;
|
|
6
|
-
display_name: string;
|
|
7
|
-
description?: string | null;
|
|
8
|
-
template_kind: string;
|
|
9
|
-
category: string;
|
|
10
|
-
editability_mode: string;
|
|
11
|
-
required_capability_refs: string[];
|
|
12
|
-
default_policy_refs?: Record<string, unknown> | null;
|
|
13
|
-
default_runtime_config_refs?: Record<string, unknown> | null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface AuthoringTemplateDetail extends AuthoringTemplateSummary {
|
|
17
|
-
base_agent_ir: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface AuthoringTemplateListResponse {
|
|
21
|
-
items: AuthoringTemplateSummary[];
|
|
22
|
-
total: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class TemplatesModule {
|
|
26
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) {}
|
|
27
|
-
|
|
28
|
-
async list(): Promise<APIResponse<AuthoringTemplateListResponse>> {
|
|
29
|
-
return this.client.GET<AuthoringTemplateListResponse>("/v1/api/templates", {
|
|
30
|
-
headers: this.headers(),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async get(templateRef: string): Promise<APIResponse<AuthoringTemplateDetail>> {
|
|
35
|
-
return this.client.GET<AuthoringTemplateDetail>("/v1/api/templates/{templateRef}", {
|
|
36
|
-
params: { path: { templateRef } },
|
|
37
|
-
headers: this.headers(),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
package/src/modules/tenants.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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
|
-
* List all tenants the user has access to.
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* List all tenants the user has access to.
|
|
32
|
-
*/
|
|
33
|
-
async list(): Promise<APIResponse<TenantListResponse>> {
|
|
34
|
-
return this.client.GET<TenantListResponse>("/v1/api/tenants", {
|
|
35
|
-
headers: this.headers(),
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the current tenant.
|
|
41
|
-
*/
|
|
42
|
-
async get(): Promise<APIResponse<Tenant>> {
|
|
43
|
-
return this.client.GET<Tenant>("/v1/api/tenants/current", {
|
|
44
|
-
headers: this.headers(),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Update the current tenant.
|
|
50
|
-
*/
|
|
51
|
-
async update(body: {
|
|
52
|
-
name?: string;
|
|
53
|
-
slug?: string;
|
|
54
|
-
}): Promise<APIResponse<Tenant>> {
|
|
55
|
-
return this.client.PUT<Tenant>("/v1/api/tenants/current", {
|
|
56
|
-
body,
|
|
57
|
-
headers: this.headers(),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get tenant settings.
|
|
63
|
-
*/
|
|
64
|
-
async getSettings(): Promise<APIResponse<Record<string, unknown>>> {
|
|
65
|
-
return this.client.GET<Record<string, unknown>>("/v1/api/tenants/current/settings", {
|
|
66
|
-
headers: this.headers(),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Update tenant settings.
|
|
72
|
-
*/
|
|
73
|
-
async updateSettings(settings: Record<string, unknown>): Promise<APIResponse<void>> {
|
|
74
|
-
return this.client.PUT<void>("/v1/api/tenants/current/settings", {
|
|
75
|
-
body: settings,
|
|
76
|
-
headers: this.headers(),
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
package/src/modules/threads.ts
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
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
|
-
* // With idempotency (safe to retry)
|
|
84
|
-
* const { data: thread } = await client.threads.create({
|
|
85
|
-
* idempotency_key: "my-unique-key"
|
|
86
|
-
* });
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
async create(body?: {
|
|
90
|
-
channel?: string;
|
|
91
|
-
external_conversation_id?: string;
|
|
92
|
-
metadata?: Record<string, unknown>;
|
|
93
|
-
/** Idempotency key for safe retries. When set, duplicate requests with the same key return the original response. */
|
|
94
|
-
idempotency_key?: string;
|
|
95
|
-
}): Promise<APIResponse<Thread>> {
|
|
96
|
-
// Send canonical X-Idempotency-Key header + body idempotency_key for backend contract parity.
|
|
97
|
-
const headers: Record<string, string> = { ...this.headers() };
|
|
98
|
-
if (body?.idempotency_key) {
|
|
99
|
-
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return this.client.POST<Thread>("/v1/api/threads", {
|
|
103
|
-
body: body ?? {},
|
|
104
|
-
headers,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get a thread by ID.
|
|
110
|
-
* @example
|
|
111
|
-
* ```ts
|
|
112
|
-
* const { data: thread } = await client.threads.get("thread-uuid");
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
async get(threadId: string): Promise<APIResponse<Thread>> {
|
|
116
|
-
return this.client.GET<Thread>("/v1/api/threads/{id}", {
|
|
117
|
-
params: { path: { id: threadId } },
|
|
118
|
-
headers: this.headers(),
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* List all threads.
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* const { data } = await client.threads.list({ limit: 20 });
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
async list(params?: PaginationParams & {
|
|
130
|
-
workspace_id?: string;
|
|
131
|
-
}): Promise<APIResponse<ThreadListResponse>> {
|
|
132
|
-
return this.client.GET<ThreadListResponse>("/v1/api/threads", {
|
|
133
|
-
params: { query: params },
|
|
134
|
-
headers: this.headers(),
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Iterate through all threads with automatic pagination.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```ts
|
|
143
|
-
* for await (const thread of client.threads.iterate()) {
|
|
144
|
-
* console.log(thread.id);
|
|
145
|
-
* }
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
async *iterate(
|
|
149
|
-
filters?: { workspace_id?: string },
|
|
150
|
-
options?: { pageSize?: number; maxItems?: number; signal?: AbortSignal }
|
|
151
|
-
): AsyncGenerator<Thread, void, unknown> {
|
|
152
|
-
const pageSize = options?.pageSize ?? 100;
|
|
153
|
-
const maxItems = options?.maxItems ?? Infinity;
|
|
154
|
-
let offset = 0;
|
|
155
|
-
let yielded = 0;
|
|
156
|
-
let hasMore = true;
|
|
157
|
-
|
|
158
|
-
while (hasMore && yielded < maxItems) {
|
|
159
|
-
if (options?.signal?.aborted) return;
|
|
160
|
-
|
|
161
|
-
const response = await this.list({
|
|
162
|
-
...filters,
|
|
163
|
-
limit: Math.min(pageSize, maxItems - yielded),
|
|
164
|
-
offset,
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
if (response.error) throw response.error;
|
|
168
|
-
const data = response.data!;
|
|
169
|
-
|
|
170
|
-
for (const thread of data.items) {
|
|
171
|
-
if (yielded >= maxItems) return;
|
|
172
|
-
yield thread;
|
|
173
|
-
yielded++;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
offset += data.items.length;
|
|
177
|
-
hasMore = offset < data.total && data.items.length > 0;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Delete a thread.
|
|
183
|
-
*/
|
|
184
|
-
async delete(threadId: string): Promise<APIResponse<void>> {
|
|
185
|
-
return this.client.DELETE<void>("/v1/api/threads/{id}", {
|
|
186
|
-
params: { path: { id: threadId } },
|
|
187
|
-
headers: this.headers(),
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ======================== State ========================
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Get the current state of a thread.
|
|
195
|
-
* @example
|
|
196
|
-
* ```ts
|
|
197
|
-
* const { data: state } = await client.threads.getState("thread-uuid");
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
async getState(threadId: string): Promise<APIResponse<ThreadState>> {
|
|
201
|
-
return this.client.GET<ThreadState>("/v1/api/threads/{id}/state", {
|
|
202
|
-
params: { path: { id: threadId } },
|
|
203
|
-
headers: this.headers(),
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/** Alias: threads.state() -> threads.getState() */
|
|
208
|
-
state = (threadId: string) => this.getState(threadId);
|
|
209
|
-
|
|
210
|
-
// ======================== History ========================
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Get the history of a thread.
|
|
214
|
-
*/
|
|
215
|
-
async getHistory(threadId: string): Promise<APIResponse<ThreadHistory>> {
|
|
216
|
-
return this.client.GET<ThreadHistory>("/v1/api/threads/{id}/history", {
|
|
217
|
-
params: { path: { id: threadId } },
|
|
218
|
-
headers: this.headers(),
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/** Alias: threads.history() -> threads.getHistory() */
|
|
223
|
-
history = (threadId: string) => this.getHistory(threadId);
|
|
224
|
-
|
|
225
|
-
// ======================== Runs ========================
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Get runs for a thread.
|
|
229
|
-
* @example
|
|
230
|
-
* ```ts
|
|
231
|
-
* const { data } = await client.threads.getRuns("thread-uuid");
|
|
232
|
-
* ```
|
|
233
|
-
*/
|
|
234
|
-
async getRuns(threadId: string, params?: PaginationParams & {
|
|
235
|
-
status?: string
|
|
236
|
-
}): Promise<APIResponse<ThreadRunsResponse>> {
|
|
237
|
-
return this.client.GET<ThreadRunsResponse>("/v1/api/threads/{id}/runs", {
|
|
238
|
-
params: { path: { id: threadId }, query: params },
|
|
239
|
-
headers: this.headers(),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/** Alias: threads.runs() -> threads.getRuns() */
|
|
244
|
-
runs = (threadId: string, params?: PaginationParams & { status?: string }) =>
|
|
245
|
-
this.getRuns(threadId, params);
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Create a run within a thread.
|
|
249
|
-
*/
|
|
250
|
-
async createRun(threadId: string, body: {
|
|
251
|
-
agent_id: string;
|
|
252
|
-
input?: unknown;
|
|
253
|
-
idempotency_key?: string;
|
|
254
|
-
}): Promise<APIResponse<ThreadRun>> {
|
|
255
|
-
return this.client.POST<ThreadRun>("/v1/api/threads/{id}/runs", {
|
|
256
|
-
params: { path: { id: threadId } },
|
|
257
|
-
body,
|
|
258
|
-
headers: this.headers(),
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ======================== Messages ========================
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Get messages in a thread.
|
|
266
|
-
* @example
|
|
267
|
-
* ```ts
|
|
268
|
-
* const { data } = await client.threads.getMessages("thread-uuid");
|
|
269
|
-
* ```
|
|
270
|
-
*/
|
|
271
|
-
async getMessages(threadId: string, params?: PaginationParams): Promise<APIResponse<ThreadMessagesResponse>> {
|
|
272
|
-
return this.client.GET<ThreadMessagesResponse>("/v1/api/threads/{id}/messages", {
|
|
273
|
-
params: { path: { id: threadId }, query: params },
|
|
274
|
-
headers: this.headers(),
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
/** Alias: threads.messages() -> threads.getMessages() */
|
|
279
|
-
messages = (threadId: string, params?: PaginationParams) => this.getMessages(threadId, params);
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Add a message to a thread.
|
|
283
|
-
*/
|
|
284
|
-
async addMessage(threadId: string, body: {
|
|
285
|
-
role?: "human" | "system" | "developer";
|
|
286
|
-
content: string;
|
|
287
|
-
metadata?: Record<string, unknown>;
|
|
288
|
-
}): Promise<APIResponse<ThreadMessage>> {
|
|
289
|
-
return this.client.POST<ThreadMessage>("/v1/api/threads/{id}/messages", {
|
|
290
|
-
params: { path: { id: threadId } },
|
|
291
|
-
body,
|
|
292
|
-
headers: this.headers(),
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// ======================== Search ========================
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Search threads.
|
|
300
|
-
*/
|
|
301
|
-
async search(body: {
|
|
302
|
-
workspace_id?: string;
|
|
303
|
-
agent_id?: string;
|
|
304
|
-
created_after?: string;
|
|
305
|
-
created_before?: string;
|
|
306
|
-
sort_by?: string;
|
|
307
|
-
sort_desc?: boolean;
|
|
308
|
-
} & PaginationParams): Promise<APIResponse<ThreadSearchResponse>> {
|
|
309
|
-
return this.client.POST<ThreadSearchResponse>("/v1/api/threads/search", {
|
|
310
|
-
body,
|
|
311
|
-
headers: this.headers(),
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// ======================== Copy/Fork ========================
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Copy/fork a thread.
|
|
319
|
-
*/
|
|
320
|
-
async copy(threadId: string, options?: { copy_history?: boolean }): Promise<APIResponse<Thread>> {
|
|
321
|
-
return this.client.POST<Thread>("/v1/api/threads/{id}/copy", {
|
|
322
|
-
params: { path: { id: threadId } },
|
|
323
|
-
body: options ?? {},
|
|
324
|
-
headers: this.headers(),
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// ======================== Prune ========================
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Prune old threads.
|
|
332
|
-
*/
|
|
333
|
-
async prune(body: {
|
|
334
|
-
workspace_id?: string;
|
|
335
|
-
older_than_days?: number;
|
|
336
|
-
dry_run?: boolean;
|
|
337
|
-
} & PaginationParams): Promise<APIResponse<ThreadPruneResponse>> {
|
|
338
|
-
return this.client.POST<ThreadPruneResponse>("/v1/api/threads/prune", {
|
|
339
|
-
body,
|
|
340
|
-
headers: this.headers(),
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
}
|
package/src/modules/tools.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
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 ToolDefinition {
|
|
23
|
-
capability_ref: string;
|
|
24
|
-
capability_version: string;
|
|
25
|
-
execution_binding: string;
|
|
26
|
-
slug?: string; // compatibility/display only
|
|
27
|
-
required_credentials: string[];
|
|
28
|
-
name: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
type: string;
|
|
31
|
-
version?: number;
|
|
32
|
-
input_schema?: Record<string, unknown>;
|
|
33
|
-
output_schema?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ToolDefinitionsResponse {
|
|
37
|
-
version: string;
|
|
38
|
-
tools: ToolDefinition[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface ToolCallResult {
|
|
42
|
-
success: boolean;
|
|
43
|
-
output?: unknown;
|
|
44
|
-
error?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class ToolsModule {
|
|
48
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* List all available tools.
|
|
52
|
-
*/
|
|
53
|
-
async list(params?: {
|
|
54
|
-
category?: string;
|
|
55
|
-
limit?: number;
|
|
56
|
-
offset?: number;
|
|
57
|
-
}): Promise<APIResponse<ToolListResponse>> {
|
|
58
|
-
return this.client.GET<ToolListResponse>("/v1/api/tools", {
|
|
59
|
-
params: { query: params },
|
|
60
|
-
headers: this.headers(),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get a tool by name.
|
|
66
|
-
*/
|
|
67
|
-
async get(toolName: string): Promise<APIResponse<Tool>> {
|
|
68
|
-
return this.client.GET<Tool>("/v1/api/tools/{name}", {
|
|
69
|
-
params: { path: { name: toolName } },
|
|
70
|
-
headers: this.headers(),
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async getDefinitions(version: string = "1"): Promise<APIResponse<ToolDefinitionsResponse>> {
|
|
75
|
-
return this.client.GET<ToolDefinitionsResponse>("/v1/api/tools/definitions", {
|
|
76
|
-
params: { query: { version } },
|
|
77
|
-
headers: this.headers(),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Call a tool directly (testing).
|
|
83
|
-
*/
|
|
84
|
-
async call(toolName: string, args: unknown): Promise<APIResponse<ToolCallResult>> {
|
|
85
|
-
return this.client.POST<ToolCallResult>("/v1/api/tools/{name}/call", {
|
|
86
|
-
params: { path: { name: toolName } },
|
|
87
|
-
body: { arguments: args },
|
|
88
|
-
headers: this.headers(),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|