@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/agents.ts
DELETED
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agents Module - Fully Typed
|
|
3
|
-
*
|
|
4
|
-
* Naming conventions:
|
|
5
|
-
* - get* for singular items: getAgent(id)
|
|
6
|
-
* - list* for collections: listAgents()
|
|
7
|
-
* - create*, update*, delete* for mutations
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { PaginatedResponse, PaginationParams } from "../client/helpers.js";
|
|
11
|
-
import type { APIResponse, components, RawClient } from "../client/raw.js";
|
|
12
|
-
|
|
13
|
-
// Type aliases for this module
|
|
14
|
-
|
|
15
|
-
type AgentSchema = components["schemas"]["AgentExportAgent"];
|
|
16
|
-
// Bundle types from schema
|
|
17
|
-
type AgentBundleSchema = components["schemas"]["AgentExportBundle"];
|
|
18
|
-
|
|
19
|
-
// Response types
|
|
20
|
-
export interface Agent {
|
|
21
|
-
id: string;
|
|
22
|
-
name: string;
|
|
23
|
-
workspace_id: string;
|
|
24
|
-
tenant_id: string;
|
|
25
|
-
created_at: string;
|
|
26
|
-
updated_at: string;
|
|
27
|
-
live_bundle_id?: string | null;
|
|
28
|
-
// Dashboard fields (P1 fix)
|
|
29
|
-
status?: "live" | "draft";
|
|
30
|
-
has_draft?: boolean;
|
|
31
|
-
last_run_id?: string | null;
|
|
32
|
-
last_run_status?: string | null;
|
|
33
|
-
last_run_at?: string | null;
|
|
34
|
-
metadata?: any | null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface AgentBundle extends AgentBundleSchema { }
|
|
38
|
-
|
|
39
|
-
export interface ImportAgentResponse {
|
|
40
|
-
agent_id: string;
|
|
41
|
-
message: string;
|
|
42
|
-
versions_imported: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface AgentGraphResponse {
|
|
46
|
-
mermaid?: string;
|
|
47
|
-
json?: unknown;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface GraphValidationResponse {
|
|
51
|
-
valid: boolean;
|
|
52
|
-
errors?: string[];
|
|
53
|
-
warnings?: string[];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface PublishPreviewIssue {
|
|
57
|
-
code: string;
|
|
58
|
-
message: string;
|
|
59
|
-
severity: string;
|
|
60
|
-
path?: string;
|
|
61
|
-
node_id?: string;
|
|
62
|
-
hint?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface PublishPreviewValidationResult {
|
|
66
|
-
valid: boolean;
|
|
67
|
-
errors: PublishPreviewIssue[];
|
|
68
|
-
warnings: PublishPreviewIssue[];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface PublishPreviewCapabilityItem {
|
|
72
|
-
node_id: string;
|
|
73
|
-
capability_ref: string;
|
|
74
|
-
capability_version: string;
|
|
75
|
-
execution_binding: string;
|
|
76
|
-
required_credentials: string[];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface PublishPreviewBindingItem {
|
|
80
|
-
binding_key: string;
|
|
81
|
-
status: "bound" | "missing" | "ambiguous";
|
|
82
|
-
required_by_capabilities: string[];
|
|
83
|
-
credential_instance_refs: string[];
|
|
84
|
-
credential_type_refs: string[];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface PublishPreviewDraftDiff {
|
|
88
|
-
added_node_ids: string[];
|
|
89
|
-
removed_node_ids: string[];
|
|
90
|
-
modified_node_ids: string[];
|
|
91
|
-
added_capability_refs: string[];
|
|
92
|
-
removed_capability_refs: string[];
|
|
93
|
-
binding_keys_impacted: string[];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface PublishPreviewResponse {
|
|
97
|
-
agent_id: string;
|
|
98
|
-
draft_ir_revision: string;
|
|
99
|
-
ready: boolean;
|
|
100
|
-
validation_result: PublishPreviewValidationResult;
|
|
101
|
-
capabilities: PublishPreviewCapabilityItem[];
|
|
102
|
-
bindings: PublishPreviewBindingItem[];
|
|
103
|
-
draft_diff: PublishPreviewDraftDiff;
|
|
104
|
-
blockers: PublishPreviewIssue[];
|
|
105
|
-
warnings: PublishPreviewIssue[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface AgentPublishHistoryChangeSummary {
|
|
109
|
-
added_capability_refs: string[];
|
|
110
|
-
removed_capability_refs: string[];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface AgentPublishHistoryItem {
|
|
114
|
-
release_id: string;
|
|
115
|
-
agent_id: string;
|
|
116
|
-
bundle_id: string;
|
|
117
|
-
previous_bundle_id?: string | null;
|
|
118
|
-
graph_version?: string | null;
|
|
119
|
-
runtime_package_hash: string;
|
|
120
|
-
content_hash: string;
|
|
121
|
-
action: "publish" | "rollback";
|
|
122
|
-
activated: boolean;
|
|
123
|
-
is_live: boolean;
|
|
124
|
-
status: "live" | "historical";
|
|
125
|
-
actor: string;
|
|
126
|
-
published_at: string;
|
|
127
|
-
reason?: string | null;
|
|
128
|
-
label?: string | null;
|
|
129
|
-
summary: string;
|
|
130
|
-
change_summary: AgentPublishHistoryChangeSummary;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface AgentPublishHistoryResponse {
|
|
134
|
-
agent_id: string;
|
|
135
|
-
live_bundle_id?: string | null;
|
|
136
|
-
items: AgentPublishHistoryItem[];
|
|
137
|
-
count: number;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface RollbackAgentRequest {
|
|
141
|
-
target_bundle_id: string;
|
|
142
|
-
reason?: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface AgentRollbackResponse {
|
|
146
|
-
agent_id: string;
|
|
147
|
-
live_bundle_id: string;
|
|
148
|
-
rollback_release: AgentPublishHistoryItem;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface AgentDraftIrResponse {
|
|
152
|
-
id: string;
|
|
153
|
-
name: string;
|
|
154
|
-
draft_ir_revision?: string | null;
|
|
155
|
-
draftIrRevision?: string | null;
|
|
156
|
-
draft_updated_at?: string | null;
|
|
157
|
-
draftUpdatedAt?: string | null;
|
|
158
|
-
live_bundle_id?: string | null;
|
|
159
|
-
liveBundleId?: string | null;
|
|
160
|
-
etag?: string;
|
|
161
|
-
e_tag?: string;
|
|
162
|
-
eTag?: string;
|
|
163
|
-
ir_json?: Record<string, unknown> | null;
|
|
164
|
-
irJson?: Record<string, unknown> | null;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export interface UpsertAgentCredentialBindingRequest {
|
|
168
|
-
credential_instance_ref: string;
|
|
169
|
-
binding_key: string;
|
|
170
|
-
priority?: number;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export interface AgentCredentialBindingUpsertResponse {
|
|
174
|
-
id: string;
|
|
175
|
-
updated: boolean;
|
|
176
|
-
agent_id: string;
|
|
177
|
-
binding_key: string;
|
|
178
|
-
priority: number;
|
|
179
|
-
credential_instance_ref: string;
|
|
180
|
-
credential_type_ref: string;
|
|
181
|
-
credential_type_key: string;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export interface AgentCredentialBinding {
|
|
185
|
-
id: string;
|
|
186
|
-
agent_id: string;
|
|
187
|
-
binding_key: string;
|
|
188
|
-
priority: number;
|
|
189
|
-
credential_instance_ref: string;
|
|
190
|
-
credential_type_ref: string;
|
|
191
|
-
credential_type_key: string;
|
|
192
|
-
credential_name: string;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export interface AgentCredentialBindingListResponse {
|
|
196
|
-
items: AgentCredentialBinding[];
|
|
197
|
-
count: number;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export type AgentListResponse = PaginatedResponse<Agent>;
|
|
201
|
-
|
|
202
|
-
export interface AgentRuntimeContext {
|
|
203
|
-
agent_id: string;
|
|
204
|
-
context_key: string;
|
|
205
|
-
version_key: string;
|
|
206
|
-
version_number: number;
|
|
207
|
-
content_sha256: string;
|
|
208
|
-
content_length: number;
|
|
209
|
-
content: string;
|
|
210
|
-
updated_at: string;
|
|
211
|
-
source?: string | null;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface AgentRuntimeContextListResponse {
|
|
215
|
-
items: AgentRuntimeContext[];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export interface UpsertAgentRuntimeContextRequest {
|
|
219
|
-
content: string;
|
|
220
|
-
source?: string | null;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export class AgentsModule {
|
|
224
|
-
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
225
|
-
|
|
226
|
-
// ======================== CRUD ========================
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* List all agents in the workspace.
|
|
230
|
-
* @example
|
|
231
|
-
* ```ts
|
|
232
|
-
* const { data } = await client.agents.list({ limit: 10 });
|
|
233
|
-
* data?.items.forEach(agent => console.log(agent.name));
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
async list(params?: PaginationParams & {
|
|
237
|
-
workspace_id?: string;
|
|
238
|
-
}): Promise<APIResponse<AgentListResponse>> {
|
|
239
|
-
return this.client.GET<AgentListResponse>("/v1/api/agents", {
|
|
240
|
-
params: { query: params },
|
|
241
|
-
headers: this.headers(),
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Get a single agent by ID.
|
|
247
|
-
* @example
|
|
248
|
-
* ```ts
|
|
249
|
-
* const { data: agent } = await client.agents.get("agent-uuid");
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
async get(agentId: string): Promise<APIResponse<Agent>> {
|
|
253
|
-
return this.client.GET<Agent>("/v1/api/agents/{agentId}", {
|
|
254
|
-
params: { path: { agentId } },
|
|
255
|
-
headers: this.headers(),
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Create a new agent.
|
|
261
|
-
* Backend only accepts `name` per CreateAgentRequest DTO.
|
|
262
|
-
* @example
|
|
263
|
-
* ```ts
|
|
264
|
-
* const { data: agent } = await client.agents.create({ name: "My Agent" });
|
|
265
|
-
*
|
|
266
|
-
* // With idempotency (safe to retry)
|
|
267
|
-
* const { data: agent } = await client.agents.create({
|
|
268
|
-
* name: "My Agent",
|
|
269
|
-
* idempotency_key: "unique-key"
|
|
270
|
-
* });
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
async create(body: {
|
|
274
|
-
name: string;
|
|
275
|
-
metadata?: any | null;
|
|
276
|
-
/** Idempotency key for safe retries. When set, duplicate requests with the same key return 409 Conflict. */
|
|
277
|
-
idempotency_key?: string;
|
|
278
|
-
}): Promise<APIResponse<Agent>> {
|
|
279
|
-
const headers: Record<string, string> = { ...this.headers() };
|
|
280
|
-
if (body.idempotency_key) {
|
|
281
|
-
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return this.client.POST<Agent>("/v1/api/agents", {
|
|
285
|
-
body: {
|
|
286
|
-
name: body.name,
|
|
287
|
-
metadata: body.metadata
|
|
288
|
-
},
|
|
289
|
-
headers,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Update an existing agent.
|
|
295
|
-
* Uses PATCH per backend AgentsController.
|
|
296
|
-
*/
|
|
297
|
-
async update(agentId: string, body: {
|
|
298
|
-
name?: string;
|
|
299
|
-
live_bundle_id?: string;
|
|
300
|
-
metadata?: any | null;
|
|
301
|
-
}): Promise<APIResponse<Agent>> {
|
|
302
|
-
return this.client.PATCH<Agent>("/v1/api/agents/{id}", {
|
|
303
|
-
params: { path: { id: agentId } },
|
|
304
|
-
body,
|
|
305
|
-
headers: this.headers(),
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Delete an agent.
|
|
311
|
-
*/
|
|
312
|
-
async delete(agentId: string): Promise<APIResponse<void>> {
|
|
313
|
-
return this.client.DELETE<void>("/v1/api/agents/{agentId}", {
|
|
314
|
-
params: { path: { agentId } },
|
|
315
|
-
headers: this.headers(),
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// ======================== Runtime Contexts ========================
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* List current runtime contexts for an agent.
|
|
323
|
-
*/
|
|
324
|
-
async listRuntimeContexts(agentId: string): Promise<APIResponse<AgentRuntimeContextListResponse>> {
|
|
325
|
-
return this.client.GET<AgentRuntimeContextListResponse>("/v1/api/agents/{agentId}/runtime-contexts", {
|
|
326
|
-
params: { path: { agentId } },
|
|
327
|
-
headers: this.headers(),
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Get the current runtime context for a given key.
|
|
333
|
-
*/
|
|
334
|
-
async getRuntimeContext(agentId: string, contextKey: string): Promise<APIResponse<AgentRuntimeContext>> {
|
|
335
|
-
return this.client.GET<AgentRuntimeContext>("/v1/api/agents/{agentId}/runtime-contexts/{contextKey}", {
|
|
336
|
-
params: { path: { agentId, contextKey } },
|
|
337
|
-
headers: this.headers(),
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Create or update the current runtime context for a given key.
|
|
343
|
-
*/
|
|
344
|
-
async upsertRuntimeContext(
|
|
345
|
-
agentId: string,
|
|
346
|
-
contextKey: string,
|
|
347
|
-
body: UpsertAgentRuntimeContextRequest
|
|
348
|
-
): Promise<APIResponse<AgentRuntimeContext>> {
|
|
349
|
-
return this.client.PUT<AgentRuntimeContext>("/v1/api/agents/{agentId}/runtime-contexts/{contextKey}", {
|
|
350
|
-
params: { path: { agentId, contextKey } },
|
|
351
|
-
body: {
|
|
352
|
-
content: body.content,
|
|
353
|
-
source: body.source ?? null,
|
|
354
|
-
},
|
|
355
|
-
headers: this.headers(),
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// ======================== Portability ========================
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Export an agent as a JSON bundle.
|
|
363
|
-
*/
|
|
364
|
-
async export(agentId: string): Promise<APIResponse<AgentBundle>> {
|
|
365
|
-
return this.client.GET<AgentBundle>("/v1/api/agents/{id}/export", {
|
|
366
|
-
params: { path: { id: agentId } },
|
|
367
|
-
headers: this.headers(),
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Import an agent bundle.
|
|
373
|
-
*/
|
|
374
|
-
async import(bundle: AgentBundle): Promise<APIResponse<ImportAgentResponse>> {
|
|
375
|
-
return this.client.POST<ImportAgentResponse>("/v1/api/agents/import", {
|
|
376
|
-
body: bundle,
|
|
377
|
-
headers: this.headers(),
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// ======================== Graph ========================
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Get the graph for an agent (Mermaid or JSON).
|
|
385
|
-
*/
|
|
386
|
-
async getGraph(agentId: string, format?: "mermaid" | "json"): Promise<APIResponse<AgentGraphResponse>> {
|
|
387
|
-
return this.client.GET<AgentGraphResponse>("/v1/api/agents/{agentId}/graph", {
|
|
388
|
-
params: { path: { agentId }, query: { format } },
|
|
389
|
-
headers: this.headers(),
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/** Alias for getGraph (convenience) */
|
|
394
|
-
graph = (agentId: string, format?: "mermaid" | "json") => this.getGraph(agentId, format);
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Validate the graph configuration.
|
|
398
|
-
*/
|
|
399
|
-
async validateGraph(agentId: string): Promise<APIResponse<GraphValidationResponse>> {
|
|
400
|
-
return this.client.POST<GraphValidationResponse>("/v1/api/agents/{agentId}/graph/validate", {
|
|
401
|
-
params: { path: { agentId } },
|
|
402
|
-
headers: this.headers(),
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
async getPublishPreview(
|
|
407
|
-
agentId: string,
|
|
408
|
-
irJson?: Record<string, unknown>
|
|
409
|
-
): Promise<APIResponse<PublishPreviewResponse>> {
|
|
410
|
-
if (irJson) {
|
|
411
|
-
return this.client.POST<PublishPreviewResponse>("/v1/api/agents/{id}/publish-preview", {
|
|
412
|
-
params: { path: { id: agentId } },
|
|
413
|
-
body: { ir_json: irJson } as any,
|
|
414
|
-
headers: this.headers(),
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
return this.client.GET<PublishPreviewResponse>("/v1/api/agents/{id}/publish-preview", {
|
|
419
|
-
params: { path: { id: agentId } },
|
|
420
|
-
headers: this.headers(),
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// ======================== Draft IR ========================
|
|
425
|
-
|
|
426
|
-
async getDraftIr(agentId: string): Promise<APIResponse<AgentDraftIrResponse>> {
|
|
427
|
-
return this.client.GET<AgentDraftIrResponse>("/v1/api/agents/{id}/draft/ir", {
|
|
428
|
-
params: { path: { id: agentId } },
|
|
429
|
-
headers: this.headers(),
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
async updateDraftIr(
|
|
434
|
-
agentId: string,
|
|
435
|
-
irJson: Record<string, unknown>,
|
|
436
|
-
options?: { if_match?: string }
|
|
437
|
-
): Promise<APIResponse<AgentDraftIrResponse>> {
|
|
438
|
-
const headers: Record<string, string> = { ...this.headers() };
|
|
439
|
-
if (options?.if_match) {
|
|
440
|
-
headers["If-Match"] = options.if_match;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
const response = await this.client.PUT<AgentDraftIrResponse | { data?: AgentDraftIrResponse }>("/v1/api/agents/{id}/draft/ir", {
|
|
444
|
-
params: { path: { id: agentId } },
|
|
445
|
-
body: {
|
|
446
|
-
ir_json: irJson,
|
|
447
|
-
} as any,
|
|
448
|
-
headers,
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
const unwrapped =
|
|
452
|
-
response.data &&
|
|
453
|
-
typeof response.data === "object" &&
|
|
454
|
-
"data" in response.data &&
|
|
455
|
-
typeof (response.data as { data?: unknown }).data === "object"
|
|
456
|
-
? ((response.data as { data?: AgentDraftIrResponse }).data ?? undefined)
|
|
457
|
-
: (response.data as AgentDraftIrResponse | undefined);
|
|
458
|
-
|
|
459
|
-
return {
|
|
460
|
-
...response,
|
|
461
|
-
data: unwrapped,
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
// ======================== Publishing ========================
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Publish the committed agent artifact pointed to by the current authoring revision.
|
|
469
|
-
* The client does not send authoring JSON anymore.
|
|
470
|
-
* @param agentId The agent UUID
|
|
471
|
-
* @param options Optional settings: version_label for tagging, set_as_live to make this the active version, idempotency_key for safe retries
|
|
472
|
-
* @returns Bundle response with version details
|
|
473
|
-
* @example
|
|
474
|
-
* ```ts
|
|
475
|
-
* const { data: bundle } = await client.agents.publish(agentId, {
|
|
476
|
-
* idempotency_key: "publish-unique-key"
|
|
477
|
-
* });
|
|
478
|
-
* ```
|
|
479
|
-
*/
|
|
480
|
-
async publish(
|
|
481
|
-
agentId: string,
|
|
482
|
-
options?: {
|
|
483
|
-
version_label?: string | null;
|
|
484
|
-
set_as_live?: boolean;
|
|
485
|
-
required_tools?: string[];
|
|
486
|
-
/** Idempotency key for safe retries */
|
|
487
|
-
idempotency_key?: string;
|
|
488
|
-
}
|
|
489
|
-
): Promise<APIResponse<components["schemas"]["BundleResponse"]>> {
|
|
490
|
-
const headers: Record<string, string> = { ...this.headers() };
|
|
491
|
-
if (options?.idempotency_key) {
|
|
492
|
-
headers["X-Idempotency-Key"] = options.idempotency_key;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
return this.client.POST<components["schemas"]["BundleResponse"]>("/v1/api/agents/{id}/publish", {
|
|
496
|
-
params: { path: { id: agentId } },
|
|
497
|
-
body: {
|
|
498
|
-
version_label: options?.version_label ?? null,
|
|
499
|
-
set_as_live: options?.set_as_live ?? true,
|
|
500
|
-
required_tools: options?.required_tools ?? []
|
|
501
|
-
} as any,
|
|
502
|
-
headers
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
async listPublishes(agentId: string): Promise<APIResponse<AgentPublishHistoryResponse>> {
|
|
507
|
-
return this.client.GET<AgentPublishHistoryResponse>("/v1/api/agents/{id}/publishes", {
|
|
508
|
-
params: { path: { id: agentId } },
|
|
509
|
-
headers: this.headers(),
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
async rollback(
|
|
514
|
-
agentId: string,
|
|
515
|
-
body: RollbackAgentRequest
|
|
516
|
-
): Promise<APIResponse<AgentRollbackResponse>> {
|
|
517
|
-
return this.client.POST<AgentRollbackResponse>("/v1/api/agents/{id}/rollback", {
|
|
518
|
-
params: { path: { id: agentId } },
|
|
519
|
-
body,
|
|
520
|
-
headers: this.headers(),
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// ======================== Bundles ========================
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* Get the manifest for a specific bundle.
|
|
528
|
-
* Returns artifact metadata only.
|
|
529
|
-
* @example
|
|
530
|
-
* ```ts
|
|
531
|
-
* const { data } = await client.agents.getBundleManifest(agentId, bundleId);
|
|
532
|
-
* console.log(data?.artifact_hash);
|
|
533
|
-
* ```
|
|
534
|
-
*/
|
|
535
|
-
async getBundleManifest(agentId: string, bundleId: string): Promise<APIResponse<BundleManifestResponse>> {
|
|
536
|
-
return this.client.GET<BundleManifestResponse>("/v1/api/agents/{agentId}/bundles/{bundleId}/manifest", {
|
|
537
|
-
params: { path: { agentId, bundleId } },
|
|
538
|
-
headers: this.headers(),
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* Get Mermaid diagram for a specific bundle graph.
|
|
544
|
-
*/
|
|
545
|
-
async getBundleMermaid(agentId: string, bundleId: string): Promise<APIResponse<BundleMermaidResponse>> {
|
|
546
|
-
return this.client.GET<BundleMermaidResponse>("/v1/api/agents/{agentId}/bundles/{bundleId}/graph/mermaid", {
|
|
547
|
-
params: { path: { agentId, bundleId } },
|
|
548
|
-
headers: this.headers(),
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Creates or updates an agent credential binding by binding key.
|
|
554
|
-
*/
|
|
555
|
-
async upsertCredentialBinding(
|
|
556
|
-
agentId: string,
|
|
557
|
-
body: UpsertAgentCredentialBindingRequest
|
|
558
|
-
): Promise<APIResponse<AgentCredentialBindingUpsertResponse>> {
|
|
559
|
-
return this.client.POST<AgentCredentialBindingUpsertResponse>("/v1/api/agents/{id}/credential-bindings", {
|
|
560
|
-
params: { path: { id: agentId } },
|
|
561
|
-
body: {
|
|
562
|
-
credential_instance_ref: body.credential_instance_ref,
|
|
563
|
-
binding_key: body.binding_key,
|
|
564
|
-
priority: body.priority ?? 0,
|
|
565
|
-
},
|
|
566
|
-
headers: this.headers(),
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Lists credential bindings for an agent.
|
|
572
|
-
*/
|
|
573
|
-
async listCredentialBindings(
|
|
574
|
-
agentId: string
|
|
575
|
-
): Promise<APIResponse<AgentCredentialBindingListResponse>> {
|
|
576
|
-
return this.client.GET<AgentCredentialBindingListResponse>("/v1/api/agents/{id}/credential-bindings", {
|
|
577
|
-
params: { path: { id: agentId } },
|
|
578
|
-
headers: this.headers(),
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
// Bundle manifest response type
|
|
585
|
-
export interface BundleManifestResponse {
|
|
586
|
-
agent_id: string;
|
|
587
|
-
bundle_id: string;
|
|
588
|
-
agent_name: string;
|
|
589
|
-
artifact_uri?: string;
|
|
590
|
-
artifact_hash?: string;
|
|
591
|
-
content_hash?: string;
|
|
592
|
-
format?: string;
|
|
593
|
-
schema_version?: string;
|
|
594
|
-
created_at?: string;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
export interface BundleMermaidResponse {
|
|
598
|
-
bundle_id: string;
|
|
599
|
-
agent_id: string;
|
|
600
|
-
mermaid: string;
|
|
601
|
-
format?: string;
|
|
602
|
-
node_count?: number;
|
|
603
|
-
edge_count?: number;
|
|
604
|
-
}
|
package/src/modules/apiTokens.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import type { APIResponse, RawClient } from "../client/raw.js";
|
|
3
|
-
|
|
4
|
-
export interface ApiToken {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
token_prefix: string;
|
|
8
|
-
scopes: string[];
|
|
9
|
-
created_at: string;
|
|
10
|
-
expires_at?: string | null;
|
|
11
|
-
last_used_at?: string | null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ApiTokenSecret extends ApiToken {
|
|
15
|
-
token: string; // The full secret, only returned once
|
|
16
|
-
workspace_id: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface CreateTokenRequest {
|
|
20
|
-
name: string;
|
|
21
|
-
scopes?: string[];
|
|
22
|
-
expires_at?: string | null;
|
|
23
|
-
environment?: "live" | "test";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface RotateTokenResponse extends ApiTokenSecret {
|
|
27
|
-
rotated_from: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ScopeInfo {
|
|
31
|
-
key: string;
|
|
32
|
-
description: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ScopeListResponse {
|
|
36
|
-
scopes: ScopeInfo[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class ApiTokensModule {
|
|
40
|
-
private client: RawClient;
|
|
41
|
-
|
|
42
|
-
constructor(client: RawClient) {
|
|
43
|
-
this.client = client;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private headers() {
|
|
47
|
-
return {
|
|
48
|
-
"Content-Type": "application/json",
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* List all API tokens for the current workspace.
|
|
54
|
-
*/
|
|
55
|
-
async list(): Promise<APIResponse<{ tokens: ApiToken[] }>> {
|
|
56
|
-
return this.client.GET<{ tokens: ApiToken[] }>("/v1/api/tokens", {
|
|
57
|
-
headers: this.headers(),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Create a new API token.
|
|
63
|
-
* The full token secret is only returned in this response.
|
|
64
|
-
*/
|
|
65
|
-
async create(body: CreateTokenRequest): Promise<APIResponse<ApiTokenSecret>> {
|
|
66
|
-
return this.client.POST<ApiTokenSecret>("/v1/api/tokens", {
|
|
67
|
-
body,
|
|
68
|
-
headers: this.headers(),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* List all available scopes.
|
|
74
|
-
*/
|
|
75
|
-
async listScopes(): Promise<APIResponse<ScopeListResponse>> {
|
|
76
|
-
return this.client.GET<ScopeListResponse>("/v1/api/tokens/available-scopes", {
|
|
77
|
-
headers: this.headers(),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Revoke an API token immediately.
|
|
83
|
-
*/
|
|
84
|
-
async revoke(id: string): Promise<APIResponse<{ message: string }>> {
|
|
85
|
-
return this.client.DELETE<{ message: string }>("/v1/api/tokens/{id}", {
|
|
86
|
-
params: { path: { id } },
|
|
87
|
-
headers: this.headers(),
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Rotate a token (revoke old, create new).
|
|
93
|
-
* Returns the new token secret.
|
|
94
|
-
*/
|
|
95
|
-
async rotate(id: string): Promise<APIResponse<RotateTokenResponse>> {
|
|
96
|
-
return this.client.POST<RotateTokenResponse>("/v1/api/tokens/{id}/rotate", {
|
|
97
|
-
params: { path: { id } },
|
|
98
|
-
headers: this.headers(),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|