@agent-os-sdk/client 0.4.4 → 0.4.6

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.
@@ -58,6 +58,10 @@ export interface GraphValidationResponse {
58
58
 
59
59
  export type AgentListResponse = PaginatedResponse<Agent>;
60
60
 
61
+ // Draft types
62
+ export type AgentDraftResponse = components["schemas"]["AgentDraftResponse"];
63
+ export type UpdateDraftGraphRequest = components["schemas"]["UpdateDraftGraphRequest"];
64
+
61
65
  export class AgentsModule {
62
66
  constructor(private client: RawClient, private headers: () => Record<string, string>) { }
63
67
 
@@ -187,5 +191,37 @@ export class AgentsModule {
187
191
  });
188
192
  }
189
193
 
194
+ /**
195
+ * Update the draft graph for an agent (autosave).
196
+ * @param agentId The agent UUID
197
+ * @param graph_json The graph specification
198
+ * @param expected_ticks The expected ticks for optimistic concurrency (from If-Match)
199
+ */
200
+ async updateDraftGraph(
201
+ agentId: string,
202
+ graph_json: Record<string, unknown>,
203
+ expected_ticks: number | null
204
+ ): Promise<APIResponse<components["schemas"]["AgentDraftResponse"]>> {
205
+ // Construct If-Match header
206
+ // If expected_ticks is null, we don't send header (or send something else? Logic says If-Match required if strictly following docs)
207
+ // But docs say: "Requires If-Match header with ETag from previous GET/PUT".
208
+ // If client passes 0, we send "agentId:0".
209
+ // If client passes null, maybe it's a force overwrite or initial save? UseCase handles logic.
210
+ // We will strictly set If-Match if expected_ticks is number.
211
+
212
+ const headers = this.headers();
213
+ if (expected_ticks !== null && expected_ticks !== undefined) {
214
+ headers["If-Match"] = `"${agentId}:${expected_ticks}"`;
215
+ }
216
+
217
+ return this.client.PUT<components["schemas"]["AgentDraftResponse"]>("/v1/api/agents/{id}/draft/graph", {
218
+ params: { path: { id: agentId } },
219
+ body: {
220
+ graph_json
221
+ } as components["schemas"]["UpdateDraftGraphRequest"],
222
+ headers
223
+ });
224
+ }
225
+
190
226
 
191
227
  }