@agent-os-sdk/client 0.5.0 → 0.5.2
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 +142 -14
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/agents.d.ts +0 -21
- package/dist/modules/agents.d.ts.map +1 -1
- package/dist/modules/agents.js +1 -37
- package/dist/modules/graphs.d.ts +103 -48
- package/dist/modules/graphs.d.ts.map +1 -1
- package/dist/modules/graphs.js +42 -4
- package/dist/modules/runs.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/generated/openapi.ts +142 -14
- package/src/generated/swagger.json +210 -8
- package/src/index.ts +15 -1
- package/src/modules/agents.ts +1 -57
- package/src/modules/graphs.ts +161 -37
package/src/modules/agents.ts
CHANGED
|
@@ -28,8 +28,6 @@ export interface Agent {
|
|
|
28
28
|
live_bundle_id?: string | null;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
31
|
export interface AgentBundle extends AgentBundleSchema { }
|
|
34
32
|
|
|
35
33
|
export interface ImportAgentResponse {
|
|
@@ -38,13 +36,6 @@ export interface ImportAgentResponse {
|
|
|
38
36
|
versions_imported: number;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
export interface ImportAgentResponse {
|
|
42
|
-
agent_id: string;
|
|
43
|
-
message: string;
|
|
44
|
-
versions_imported: number;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
39
|
export interface AgentGraphResponse {
|
|
49
40
|
mermaid?: string;
|
|
50
41
|
json?: unknown;
|
|
@@ -58,10 +49,6 @@ export interface GraphValidationResponse {
|
|
|
58
49
|
|
|
59
50
|
export type AgentListResponse = PaginatedResponse<Agent>;
|
|
60
51
|
|
|
61
|
-
// Draft types
|
|
62
|
-
export type AgentDraftResponse = components["schemas"]["AgentDraftResponse"];
|
|
63
|
-
export type UpdateDraftGraphRequest = components["schemas"]["UpdateDraftGraphRequest"];
|
|
64
|
-
|
|
65
52
|
export class AgentsModule {
|
|
66
53
|
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
67
54
|
|
|
@@ -191,50 +178,7 @@ export class AgentsModule {
|
|
|
191
178
|
});
|
|
192
179
|
}
|
|
193
180
|
|
|
194
|
-
|
|
195
|
-
* Get the draft graph for an agent (source of truth).
|
|
196
|
-
* Studio should use this instead of generating graphs locally.
|
|
197
|
-
* @param agentId The agent UUID
|
|
198
|
-
* @returns Draft response with graph_json and ETag for subsequent updates
|
|
199
|
-
*/
|
|
200
|
-
async getDraftGraph(agentId: string): Promise<APIResponse<components["schemas"]["AgentDraftResponse"]>> {
|
|
201
|
-
return this.client.GET<components["schemas"]["AgentDraftResponse"]>("/v1/api/agents/{id}/draft/graph", {
|
|
202
|
-
params: { path: { id: agentId } },
|
|
203
|
-
headers: this.headers(),
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Update the draft graph for an agent (autosave).
|
|
209
|
-
* @param agentId The agent UUID
|
|
210
|
-
* @param graph_json The graph specification
|
|
211
|
-
* @param expected_ticks The expected ticks for optimistic concurrency (from If-Match)
|
|
212
|
-
*/
|
|
213
|
-
async updateDraftGraph(
|
|
214
|
-
agentId: string,
|
|
215
|
-
graph_json: Record<string, unknown>,
|
|
216
|
-
expected_ticks: number | null
|
|
217
|
-
): Promise<APIResponse<components["schemas"]["AgentDraftResponse"]>> {
|
|
218
|
-
// Construct If-Match header
|
|
219
|
-
// If expected_ticks is null, we don't send header (or send something else? Logic says If-Match required if strictly following docs)
|
|
220
|
-
// But docs say: "Requires If-Match header with ETag from previous GET/PUT".
|
|
221
|
-
// If client passes 0, we send "agentId:0".
|
|
222
|
-
// If client passes null, maybe it's a force overwrite or initial save? UseCase handles logic.
|
|
223
|
-
// We will strictly set If-Match if expected_ticks is number.
|
|
224
|
-
|
|
225
|
-
const headers = this.headers();
|
|
226
|
-
if (expected_ticks !== null && expected_ticks !== undefined) {
|
|
227
|
-
headers["If-Match"] = `"${agentId}:${expected_ticks}"`;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return this.client.PUT<components["schemas"]["AgentDraftResponse"]>("/v1/api/agents/{id}/draft/graph", {
|
|
231
|
-
params: { path: { id: agentId } },
|
|
232
|
-
body: {
|
|
233
|
-
graph_json
|
|
234
|
-
} as components["schemas"]["UpdateDraftGraphRequest"],
|
|
235
|
-
headers
|
|
236
|
-
});
|
|
237
|
-
}
|
|
181
|
+
// ======================== Publishing ========================
|
|
238
182
|
|
|
239
183
|
/**
|
|
240
184
|
* Publish a new version (bundle) of the agent.
|
package/src/modules/graphs.ts
CHANGED
|
@@ -1,62 +1,186 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Graphs Module -
|
|
2
|
+
* Graphs Module - V2 Graph Specification Management
|
|
3
|
+
*
|
|
4
|
+
* Pure V2 contract - no legacy. All types namespaced with "Graphs" prefix.
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
|
-
import type { RawClient, APIResponse
|
|
7
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
// ============ Shared Types ============
|
|
10
|
+
|
|
11
|
+
export interface GraphsValidationMessage {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
path?: string;
|
|
15
|
+
node_id?: string;
|
|
16
|
+
severity?: "error" | "warning";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GraphsValidationResult {
|
|
8
20
|
valid: boolean;
|
|
9
|
-
errors?:
|
|
10
|
-
|
|
21
|
+
errors?: GraphsValidationMessage[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ============ GET /v2/api/graph/{agentId} ============
|
|
25
|
+
|
|
26
|
+
export interface GraphsGetResponse {
|
|
27
|
+
agent_id: string;
|
|
28
|
+
revision: string;
|
|
29
|
+
canonical_spec: unknown;
|
|
30
|
+
committed_at: string;
|
|
31
|
+
warnings?: GraphsValidationMessage[];
|
|
32
|
+
validation?: GraphsValidationResult;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ============ POST /v2/api/graph/commit ============
|
|
36
|
+
|
|
37
|
+
export interface GraphsCommitRequest {
|
|
38
|
+
agent_id: string;
|
|
39
|
+
proposed_spec: unknown;
|
|
40
|
+
expected_revision?: string;
|
|
41
|
+
source?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type GraphsCommitStatus = "committed" | "no_change";
|
|
45
|
+
|
|
46
|
+
export interface GraphsCommitResponse {
|
|
47
|
+
status: GraphsCommitStatus;
|
|
48
|
+
agent_id: string;
|
|
49
|
+
revision: string;
|
|
50
|
+
canonical_spec: unknown;
|
|
51
|
+
committed_at: string;
|
|
52
|
+
warnings?: GraphsValidationMessage[];
|
|
53
|
+
validation?: GraphsValidationResult;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 409 Conflict body (ProblemDetails.Extensions)
|
|
57
|
+
// Envelope around GET response - agent_id lives in current.agent_id
|
|
58
|
+
export interface GraphsConflictPayload {
|
|
59
|
+
hint: "reload_and_retry";
|
|
60
|
+
expected_revision: string;
|
|
61
|
+
current: GraphsGetResponse;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ============ GET /v2/api/graph/{agentId}/revisions ============
|
|
65
|
+
|
|
66
|
+
export interface GraphsRevisionSummary {
|
|
67
|
+
revision: string;
|
|
68
|
+
created_at: string;
|
|
69
|
+
source?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface GraphsRevisionsListResponse {
|
|
73
|
+
agent_id: string;
|
|
74
|
+
revisions: GraphsRevisionSummary[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ============ GET /v2/api/graph/{agentId}/revisions/{revision} ============
|
|
78
|
+
|
|
79
|
+
export interface GraphsRevisionResponse {
|
|
80
|
+
revision: string;
|
|
81
|
+
canonical_spec: unknown;
|
|
82
|
+
created_at: string;
|
|
83
|
+
source?: string;
|
|
84
|
+
warnings?: GraphsValidationMessage[];
|
|
85
|
+
validation?: GraphsValidationResult;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ============ Validation (DP) ============
|
|
89
|
+
|
|
90
|
+
export interface GraphsValidateRequest {
|
|
91
|
+
graph_spec: unknown;
|
|
92
|
+
normalize?: boolean;
|
|
93
|
+
catalog_versions?: Record<string, string>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface GraphsValidateResponse {
|
|
97
|
+
valid: boolean;
|
|
98
|
+
canonical_spec_json?: string;
|
|
99
|
+
mermaid?: string;
|
|
100
|
+
nodes?: string[];
|
|
101
|
+
edges?: [string, string][];
|
|
102
|
+
errors?: GraphsValidationMessage[];
|
|
103
|
+
warnings?: GraphsValidationMessage[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ============ Introspection (DP) ============
|
|
107
|
+
|
|
108
|
+
export interface GraphsIntrospectRequest {
|
|
109
|
+
agent_id?: string;
|
|
110
|
+
graph_spec?: unknown;
|
|
111
|
+
catalog_versions?: Record<string, string>;
|
|
11
112
|
}
|
|
12
113
|
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
114
|
+
export interface GraphsIntrospectResponse {
|
|
115
|
+
mermaid: string;
|
|
116
|
+
nodes: string[];
|
|
117
|
+
edges: [string, string][];
|
|
118
|
+
graph_type?: string;
|
|
17
119
|
}
|
|
18
120
|
|
|
121
|
+
// ============ Module ============
|
|
122
|
+
|
|
19
123
|
export class GraphsModule {
|
|
20
124
|
constructor(private client: RawClient, private headers: () => Record<string, string>) { }
|
|
21
125
|
|
|
126
|
+
// ============ V2 Graph Spec (CP) ============
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get current graph spec by revision.
|
|
130
|
+
* @returns 200 with graph spec, or 404 if not initialized
|
|
131
|
+
*/
|
|
132
|
+
async get(agentId: string): Promise<APIResponse<GraphsGetResponse>> {
|
|
133
|
+
return this.client.GET<GraphsGetResponse>(`/v2/api/graph/${agentId}`, {
|
|
134
|
+
headers: this.headers(),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Commit graph spec atomically.
|
|
140
|
+
* @returns 200 (committed/no_change), or 409 on conflict
|
|
141
|
+
*/
|
|
142
|
+
async commit(request: GraphsCommitRequest): Promise<APIResponse<GraphsCommitResponse>> {
|
|
143
|
+
return this.client.POST<GraphsCommitResponse>("/v2/api/graph/commit", {
|
|
144
|
+
body: request,
|
|
145
|
+
headers: this.headers(),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* List revision history for an agent.
|
|
151
|
+
*/
|
|
152
|
+
async listRevisions(agentId: string): Promise<APIResponse<GraphsRevisionsListResponse>> {
|
|
153
|
+
return this.client.GET<GraphsRevisionsListResponse>(`/v2/api/graph/${agentId}/revisions`, {
|
|
154
|
+
headers: this.headers(),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get a specific revision.
|
|
160
|
+
*/
|
|
161
|
+
async getRevision(agentId: string, revision: string): Promise<APIResponse<GraphsRevisionResponse>> {
|
|
162
|
+
return this.client.GET<GraphsRevisionResponse>(`/v2/api/graph/${agentId}/revisions/${revision}`, {
|
|
163
|
+
headers: this.headers(),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ============ Validation (DP proxy) ============
|
|
168
|
+
|
|
22
169
|
/**
|
|
23
170
|
* Validate a graph specification.
|
|
24
|
-
* Uses canonical GraphValidator for deep validation.
|
|
25
171
|
*/
|
|
26
|
-
async validate(body: {
|
|
27
|
-
|
|
28
|
-
type: string;
|
|
29
|
-
nodes: Array<{ id: string; type: string; label?: string }>;
|
|
30
|
-
edges: Array<{ from: string; to: string }>;
|
|
31
|
-
};
|
|
32
|
-
/** Catalog versions for referential integrity checks */
|
|
33
|
-
catalog_versions?: {
|
|
34
|
-
nodes: string;
|
|
35
|
-
tools: string;
|
|
36
|
-
triggers: string;
|
|
37
|
-
};
|
|
38
|
-
}): Promise<APIResponse<GraphValidationResult>> {
|
|
39
|
-
return this.client.POST<GraphValidationResult>("/v1/api/graphs/validate", {
|
|
172
|
+
async validate(body: GraphsValidateRequest): Promise<APIResponse<GraphsValidateResponse>> {
|
|
173
|
+
return this.client.POST<GraphsValidateResponse>("/v1/api/graphs/validate", {
|
|
40
174
|
body,
|
|
41
175
|
headers: this.headers(),
|
|
42
176
|
});
|
|
43
177
|
}
|
|
44
178
|
|
|
45
179
|
/**
|
|
46
|
-
* Introspect a graph
|
|
47
|
-
* Uses canonical GraphValidator with world-fixed context.
|
|
180
|
+
* Introspect a graph structure.
|
|
48
181
|
*/
|
|
49
|
-
async introspect(body: {
|
|
50
|
-
|
|
51
|
-
graph_spec?: Record<string, unknown>;
|
|
52
|
-
/** Catalog versions for deterministic introspection */
|
|
53
|
-
catalog_versions?: {
|
|
54
|
-
nodes: string;
|
|
55
|
-
tools: string;
|
|
56
|
-
triggers: string;
|
|
57
|
-
};
|
|
58
|
-
}): Promise<APIResponse<GraphIntrospectionResult>> {
|
|
59
|
-
return this.client.POST<GraphIntrospectionResult>("/v1/api/graphs/introspect", {
|
|
182
|
+
async introspect(body: GraphsIntrospectRequest): Promise<APIResponse<GraphsIntrospectResponse>> {
|
|
183
|
+
return this.client.POST<GraphsIntrospectResponse>("/v1/api/graphs/introspect", {
|
|
60
184
|
body,
|
|
61
185
|
headers: this.headers(),
|
|
62
186
|
});
|