@agent-os-sdk/client 0.7.12 → 0.7.13
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/client/HttpRequestBuilder.d.ts +48 -0
- package/dist/client/HttpRequestBuilder.d.ts.map +1 -0
- package/dist/client/HttpRequestBuilder.js +73 -0
- package/dist/client/OperationContext.d.ts +19 -0
- package/dist/client/OperationContext.d.ts.map +1 -0
- package/dist/client/OperationContext.js +13 -0
- package/dist/client/OperationContextProvider.d.ts +54 -0
- package/dist/client/OperationContextProvider.d.ts.map +1 -0
- package/dist/client/OperationContextProvider.js +71 -0
- package/dist/client/raw.d.ts +31 -0
- package/dist/client/raw.d.ts.map +1 -1
- package/dist/client/raw.js +11 -6
- package/dist/client/sanitize.d.ts +19 -0
- package/dist/client/sanitize.d.ts.map +1 -0
- package/dist/client/sanitize.js +28 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/modules/agents.d.ts +22 -6
- package/dist/modules/agents.d.ts.map +1 -1
- package/dist/modules/agents.js +26 -7
- package/dist/modules/credentials.d.ts +1 -0
- package/dist/modules/credentials.d.ts.map +1 -1
- package/dist/modules/credentials.js +2 -1
- package/dist/modules/crons.d.ts +1 -0
- package/dist/modules/crons.d.ts.map +1 -1
- package/dist/modules/crons.js +2 -1
- package/dist/modules/triggers.d.ts +11 -0
- package/dist/modules/triggers.d.ts.map +1 -1
- package/dist/modules/triggers.js +17 -2
- package/package.json +52 -50
- package/src/client/HttpRequestBuilder.ts +102 -0
- package/src/client/OperationContext.ts +22 -0
- package/src/client/OperationContextProvider.ts +89 -0
- package/src/client/raw.ts +19 -8
- package/src/client/sanitize.ts +31 -0
- package/src/index.ts +15 -0
- package/src/modules/agents.ts +44 -14
- package/src/modules/credentials.ts +2 -1
- package/src/modules/crons.ts +2 -1
- package/src/modules/triggers.ts +21 -2
package/src/modules/agents.ts
CHANGED
|
@@ -20,12 +20,17 @@ type AgentBundleSchema = components["schemas"]["AgentExportBundle"];
|
|
|
20
20
|
export interface Agent {
|
|
21
21
|
id: string;
|
|
22
22
|
name: string;
|
|
23
|
-
description?: string;
|
|
24
23
|
workspace_id: string;
|
|
25
24
|
tenant_id: string;
|
|
26
25
|
created_at: string;
|
|
27
26
|
updated_at: string;
|
|
28
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;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export interface AgentBundle extends AgentBundleSchema { }
|
|
@@ -87,35 +92,44 @@ export class AgentsModule {
|
|
|
87
92
|
|
|
88
93
|
/**
|
|
89
94
|
* Create a new agent.
|
|
95
|
+
* Backend only accepts `name` per CreateAgentRequest DTO.
|
|
90
96
|
* @example
|
|
91
97
|
* ```ts
|
|
92
|
-
* const { data: agent } = await client.agents.create({
|
|
93
|
-
*
|
|
94
|
-
*
|
|
98
|
+
* const { data: agent } = await client.agents.create({ name: "My Agent" });
|
|
99
|
+
*
|
|
100
|
+
* // With idempotency (safe to retry)
|
|
101
|
+
* const { data: agent } = await client.agents.create({
|
|
102
|
+
* name: "My Agent",
|
|
103
|
+
* idempotency_key: "unique-key"
|
|
95
104
|
* });
|
|
96
105
|
* ```
|
|
97
106
|
*/
|
|
98
107
|
async create(body: {
|
|
99
108
|
name: string;
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
/** Idempotency key for safe retries. When set, duplicate requests with the same key return 409 Conflict. */
|
|
110
|
+
idempotency_key?: string;
|
|
102
111
|
}): Promise<APIResponse<Agent>> {
|
|
112
|
+
const headers: Record<string, string> = { ...this.headers() };
|
|
113
|
+
if (body.idempotency_key) {
|
|
114
|
+
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
115
|
+
}
|
|
116
|
+
|
|
103
117
|
return this.client.POST<Agent>("/v1/api/agents", {
|
|
104
|
-
body,
|
|
105
|
-
headers
|
|
118
|
+
body: { name: body.name },
|
|
119
|
+
headers,
|
|
106
120
|
});
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
/**
|
|
110
124
|
* Update an existing agent.
|
|
125
|
+
* Uses PATCH per backend AgentsController.
|
|
111
126
|
*/
|
|
112
127
|
async update(agentId: string, body: {
|
|
113
128
|
name?: string;
|
|
114
|
-
description?: string;
|
|
115
129
|
live_bundle_id?: string;
|
|
116
130
|
}): Promise<APIResponse<Agent>> {
|
|
117
|
-
return this.client.
|
|
118
|
-
params: { path: { agentId } },
|
|
131
|
+
return this.client.PATCH<Agent>("/v1/api/agents/{id}", {
|
|
132
|
+
params: { path: { id: agentId } },
|
|
119
133
|
body,
|
|
120
134
|
headers: this.headers(),
|
|
121
135
|
});
|
|
@@ -184,14 +198,30 @@ export class AgentsModule {
|
|
|
184
198
|
* Publish a new version (bundle) of the agent.
|
|
185
199
|
* @param agentId The agent UUID
|
|
186
200
|
* @param graph_spec The graph specification to publish
|
|
187
|
-
* @param options Optional settings: version_label for tagging, set_as_live to make this the active version
|
|
201
|
+
* @param options Optional settings: version_label for tagging, set_as_live to make this the active version, idempotency_key for safe retries
|
|
188
202
|
* @returns Bundle response with version details
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* const { data: bundle } = await client.agents.publish(agentId, graphSpec, {
|
|
206
|
+
* idempotency_key: "publish-unique-key"
|
|
207
|
+
* });
|
|
208
|
+
* ```
|
|
189
209
|
*/
|
|
190
210
|
async publish(
|
|
191
211
|
agentId: string,
|
|
192
212
|
graph_spec: Record<string, unknown>,
|
|
193
|
-
options?: {
|
|
213
|
+
options?: {
|
|
214
|
+
version_label?: string | null;
|
|
215
|
+
set_as_live?: boolean;
|
|
216
|
+
/** Idempotency key for safe retries */
|
|
217
|
+
idempotency_key?: string;
|
|
218
|
+
}
|
|
194
219
|
): Promise<APIResponse<components["schemas"]["BundleResponse"]>> {
|
|
220
|
+
const headers: Record<string, string> = { ...this.headers() };
|
|
221
|
+
if (options?.idempotency_key) {
|
|
222
|
+
headers["X-Idempotency-Key"] = options.idempotency_key;
|
|
223
|
+
}
|
|
224
|
+
|
|
195
225
|
return this.client.POST<components["schemas"]["BundleResponse"]>("/v1/api/agents/{id}/publish", {
|
|
196
226
|
params: { path: { id: agentId } },
|
|
197
227
|
body: {
|
|
@@ -199,7 +229,7 @@ export class AgentsModule {
|
|
|
199
229
|
version_label: options?.version_label ?? null,
|
|
200
230
|
set_as_live: options?.set_as_live ?? true
|
|
201
231
|
},
|
|
202
|
-
headers
|
|
232
|
+
headers
|
|
203
233
|
});
|
|
204
234
|
}
|
|
205
235
|
|
|
@@ -99,6 +99,7 @@ export class CredentialsModule {
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Update a credential.
|
|
102
|
+
* Uses PATCH per backend CredentialsController.
|
|
102
103
|
*/
|
|
103
104
|
async update(credentialId: string, body: {
|
|
104
105
|
name?: string;
|
|
@@ -106,7 +107,7 @@ export class CredentialsModule {
|
|
|
106
107
|
status?: string;
|
|
107
108
|
sharing_mode?: string;
|
|
108
109
|
}): Promise<APIResponse<Credential>> {
|
|
109
|
-
return this.client.
|
|
110
|
+
return this.client.PATCH<Credential>("/v1/api/credentials/{id}", {
|
|
110
111
|
params: { path: { id: credentialId } },
|
|
111
112
|
body,
|
|
112
113
|
headers: this.headers(),
|
package/src/modules/crons.ts
CHANGED
|
@@ -79,13 +79,14 @@ export class CronsModule {
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Update a cron job.
|
|
82
|
+
* Uses PATCH per backend CronsController.
|
|
82
83
|
*/
|
|
83
84
|
async update(cronId: string, body: {
|
|
84
85
|
schedule?: string;
|
|
85
86
|
enabled?: boolean;
|
|
86
87
|
input?: unknown;
|
|
87
88
|
}): Promise<APIResponse<CronJob>> {
|
|
88
|
-
return this.client.
|
|
89
|
+
return this.client.PATCH<CronJob>("/v1/api/crons/{id}", {
|
|
89
90
|
params: { path: { id: cronId } },
|
|
90
91
|
body,
|
|
91
92
|
headers: this.headers(),
|
package/src/modules/triggers.ts
CHANGED
|
@@ -150,6 +150,15 @@ export class TriggersModule {
|
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* Create a new trigger.
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const { data: trigger } = await client.triggers.create({
|
|
156
|
+
* name: "My Webhook",
|
|
157
|
+
* agent_id: "agent-uuid",
|
|
158
|
+
* trigger_type: "webhook",
|
|
159
|
+
* idempotency_key: "create-trigger-unique-key"
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
153
162
|
*/
|
|
154
163
|
async create(body: {
|
|
155
164
|
name: string;
|
|
@@ -157,10 +166,20 @@ export class TriggersModule {
|
|
|
157
166
|
trigger_type: string;
|
|
158
167
|
template_slug?: string;
|
|
159
168
|
config?: Record<string, unknown>;
|
|
169
|
+
/** Idempotency key for safe retries. When set, duplicate requests with the same key return 409 Conflict. */
|
|
170
|
+
idempotency_key?: string;
|
|
160
171
|
}): Promise<APIResponse<Trigger>> {
|
|
172
|
+
const headers: Record<string, string> = { ...this.headers() };
|
|
173
|
+
if (body.idempotency_key) {
|
|
174
|
+
headers["X-Idempotency-Key"] = body.idempotency_key;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Send body without idempotency_key (it's header-only)
|
|
178
|
+
const { idempotency_key, ...requestBody } = body;
|
|
179
|
+
|
|
161
180
|
return this.client.POST<Trigger>("/v1/api/triggers", {
|
|
162
|
-
body,
|
|
163
|
-
headers
|
|
181
|
+
body: requestBody,
|
|
182
|
+
headers,
|
|
164
183
|
});
|
|
165
184
|
}
|
|
166
185
|
|