@agent-os-sdk/client 0.3.0 → 0.3.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.
Files changed (41) hide show
  1. package/dist/client/AgentOsClient.d.ts +2 -0
  2. package/dist/client/AgentOsClient.d.ts.map +1 -1
  3. package/dist/client/AgentOsClient.js +6 -3
  4. package/dist/client/raw.d.ts +25 -0
  5. package/dist/client/raw.d.ts.map +1 -1
  6. package/dist/client/raw.js +61 -0
  7. package/dist/generated/openapi.d.ts +156 -26
  8. package/dist/generated/openapi.d.ts.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/modules/builder.d.ts +19 -4
  13. package/dist/modules/builder.d.ts.map +1 -1
  14. package/dist/modules/builder.js +21 -30
  15. package/dist/modules/catalog.d.ts +104 -0
  16. package/dist/modules/catalog.d.ts.map +1 -0
  17. package/dist/modules/catalog.js +92 -0
  18. package/dist/modules/graphs.d.ts +7 -0
  19. package/dist/modules/graphs.d.ts.map +1 -1
  20. package/dist/modules/graphs.js +1 -0
  21. package/dist/modules/metrics.d.ts +7 -3
  22. package/dist/modules/metrics.d.ts.map +1 -1
  23. package/dist/modules/metrics.js +10 -7
  24. package/dist/modules/runs.d.ts +1 -3
  25. package/dist/modules/runs.d.ts.map +1 -1
  26. package/dist/modules/runs.js +12 -28
  27. package/dist/sse/client.d.ts +26 -1
  28. package/dist/sse/client.d.ts.map +1 -1
  29. package/dist/sse/client.js +36 -11
  30. package/package.json +51 -50
  31. package/src/client/AgentOsClient.ts +6 -3
  32. package/src/client/raw.ts +74 -0
  33. package/src/generated/openapi.ts +156 -26
  34. package/src/generated/swagger.json +144 -82
  35. package/src/index.ts +1 -0
  36. package/src/modules/builder.ts +35 -32
  37. package/src/modules/catalog.ts +155 -0
  38. package/src/modules/graphs.ts +7 -0
  39. package/src/modules/metrics.ts +10 -3
  40. package/src/modules/runs.ts +12 -28
  41. package/src/sse/client.ts +43 -14
@@ -6,15 +6,11 @@
6
6
  * - list* for collections
7
7
  * - create*, update*, delete* for mutations
8
8
  */
9
- import { streamSSE } from "../sse/client.js";
9
+ import { parseSSE } from "../sse/client.js";
10
10
  export class RunsModule {
11
11
  client;
12
- baseUrl;
13
- headers;
14
- constructor(client, baseUrl, headers) {
12
+ constructor(client) {
15
13
  this.client = client;
16
- this.baseUrl = baseUrl;
17
- this.headers = headers;
18
14
  }
19
15
  // ======================== CRUD ========================
20
16
  /**
@@ -30,7 +26,6 @@ export class RunsModule {
30
26
  async create(body) {
31
27
  return this.client.POST("/v1/api/runs", {
32
28
  body,
33
- headers: this.headers(),
34
29
  });
35
30
  }
36
31
  /**
@@ -39,7 +34,6 @@ export class RunsModule {
39
34
  async get(runId) {
40
35
  return this.client.GET("/v1/api/runs/{runId}", {
41
36
  params: { path: { runId } },
42
- headers: this.headers(),
43
37
  });
44
38
  }
45
39
  /**
@@ -48,7 +42,6 @@ export class RunsModule {
48
42
  async list(params) {
49
43
  return this.client.GET("/v1/api/runs", {
50
44
  params: { query: params },
51
- headers: this.headers(),
52
45
  });
53
46
  }
54
47
  // ======================== Execution ========================
@@ -58,7 +51,6 @@ export class RunsModule {
58
51
  async wait(body) {
59
52
  return this.client.POST("/v1/api/runs/wait", {
60
53
  body,
61
- headers: this.headers(),
62
54
  });
63
55
  }
64
56
  /**
@@ -67,7 +59,6 @@ export class RunsModule {
67
59
  async batch(body) {
68
60
  return this.client.POST("/v1/api/runs/batch", {
69
61
  body,
70
- headers: this.headers(),
71
62
  });
72
63
  }
73
64
  /**
@@ -77,7 +68,6 @@ export class RunsModule {
77
68
  return this.client.POST("/v1/api/runs/{runId}/cancel", {
78
69
  params: { path: { runId } },
79
70
  body: { reason },
80
- headers: this.headers(),
81
71
  });
82
72
  }
83
73
  /**
@@ -106,7 +96,6 @@ export class RunsModule {
106
96
  return this.client.POST("/v1/api/runs/{runId}/resume", {
107
97
  params: { path: { runId } },
108
98
  body,
109
- headers: this.headers(),
110
99
  });
111
100
  }
112
101
  /**
@@ -115,7 +104,6 @@ export class RunsModule {
115
104
  async rerun(runId) {
116
105
  return this.client.POST("/v1/api/runs/{runId}/rerun", {
117
106
  params: { path: { runId } },
118
- headers: this.headers(),
119
107
  });
120
108
  }
121
109
  /**
@@ -144,7 +132,6 @@ export class RunsModule {
144
132
  mode: options?.mode,
145
133
  reason: options?.reason
146
134
  },
147
- headers: this.headers(),
148
135
  });
149
136
  }
150
137
  // ======================== Events ========================
@@ -158,7 +145,6 @@ export class RunsModule {
158
145
  async getEvents(runId, params) {
159
146
  return this.client.GET("/v1/api/runs/{runId}/events", {
160
147
  params: { path: { runId }, query: params },
161
- headers: this.headers(),
162
148
  });
163
149
  }
164
150
  /** Alias: runs.events() -> runs.getEvents() */
@@ -193,7 +179,6 @@ export class RunsModule {
193
179
  limit: params?.limit ?? 100
194
180
  }
195
181
  },
196
- headers: this.headers(),
197
182
  });
198
183
  }
199
184
  // ======================== Checkpoints ========================
@@ -203,7 +188,6 @@ export class RunsModule {
203
188
  async getCheckpoints(runId) {
204
189
  return this.client.GET("/v1/api/runs/{runId}/checkpoints", {
205
190
  params: { path: { runId } },
206
- headers: this.headers(),
207
191
  });
208
192
  }
209
193
  /** Alias: runs.checkpoints() -> runs.getCheckpoints() */
@@ -218,12 +202,12 @@ export class RunsModule {
218
202
  * }
219
203
  * ```
220
204
  */
221
- stream(runId, options) {
222
- const url = `${this.baseUrl}/v1/api/runs/${runId}/stream`;
223
- return streamSSE(url, {
224
- ...options,
225
- headers: { ...this.headers(), ...options?.headers },
205
+ async *stream(runId, options) {
206
+ const response = await this.client.streamGet("/v1/api/runs/{runId}/stream", {
207
+ params: { path: { runId } },
208
+ headers: options?.headers,
226
209
  });
210
+ yield* parseSSE(response, { onOpen: options?.onOpen });
227
211
  }
228
212
  /**
229
213
  * Create run and stream output.
@@ -248,11 +232,11 @@ export class RunsModule {
248
232
  /**
249
233
  * Join an existing run's stream (resume watching).
250
234
  */
251
- join(runId, options) {
252
- const url = `${this.baseUrl}/v1/api/runs/${runId}/join`;
253
- return streamSSE(url, {
254
- ...options,
255
- headers: { ...this.headers(), ...options?.headers },
235
+ async *join(runId, options) {
236
+ const response = await this.client.streamGet("/v1/api/runs/{runId}/join", {
237
+ params: { path: { runId } },
238
+ headers: options?.headers,
256
239
  });
240
+ yield* parseSSE(response, { onOpen: options?.onOpen });
257
241
  }
258
242
  }
@@ -2,6 +2,9 @@
2
2
  * Agent OS SDK - SSE Client
3
3
  *
4
4
  * Typed Server-Sent Events client for streaming endpoints.
5
+ *
6
+ * This module provides utilities for parsing SSE responses.
7
+ * The actual HTTP request should be made via rawClient.streamGet/streamPost.
5
8
  */
6
9
  export type SSEEvent<T = unknown> = {
7
10
  id?: string;
@@ -16,7 +19,29 @@ export type SSEOptions = {
16
19
  signal?: AbortSignal;
17
20
  };
18
21
  /**
19
- * Creates a typed SSE stream from a URL.
22
+ * Parse SSE events from a Response object.
23
+ * Use this with rawClient.streamGet() or rawClient.streamPost().
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const response = await client.streamGet("/v1/api/runs/{runId}/stream", {
28
+ * params: { path: { runId } }
29
+ * });
30
+ * for await (const event of parseSSE<RunStreamEvent>(response)) {
31
+ * console.log(event);
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function parseSSE<T>(response: Response, options?: {
36
+ onOpen?: () => void;
37
+ }): AsyncGenerator<SSEEvent<T>>;
38
+ /**
39
+ * Legacy streamSSE function - DEPRECATED.
40
+ * Use rawClient.streamGet() + parseSSE() instead.
41
+ *
42
+ * Kept for backward compatibility during migration.
43
+ *
44
+ * @deprecated Use rawClient.streamGet() + parseSSE() instead
20
45
  */
21
46
  export declare function streamSSE<T>(url: string, options?: SSEOptions): AsyncGenerator<SSEEvent<T>>;
22
47
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/sse/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG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7B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACpB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -2,26 +2,32 @@
2
2
  * Agent OS SDK - SSE Client
3
3
  *
4
4
  * Typed Server-Sent Events client for streaming endpoints.
5
+ *
6
+ * This module provides utilities for parsing SSE responses.
7
+ * The actual HTTP request should be made via rawClient.streamGet/streamPost.
5
8
  */
6
9
  /**
7
- * Creates a typed SSE stream from a URL.
10
+ * Parse SSE events from a Response object.
11
+ * Use this with rawClient.streamGet() or rawClient.streamPost().
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const response = await client.streamGet("/v1/api/runs/{runId}/stream", {
16
+ * params: { path: { runId } }
17
+ * });
18
+ * for await (const event of parseSSE<RunStreamEvent>(response)) {
19
+ * console.log(event);
20
+ * }
21
+ * ```
8
22
  */
9
- export async function* streamSSE(url, options = {}) {
10
- const response = await fetch(url, {
11
- method: "GET",
12
- headers: {
13
- Accept: "text/event-stream",
14
- ...options.headers,
15
- },
16
- signal: options.signal,
17
- });
23
+ export async function* parseSSE(response, options) {
18
24
  if (!response.ok) {
19
25
  throw new Error(`SSE connection failed: ${response.status}`);
20
26
  }
21
27
  if (!response.body) {
22
28
  throw new Error("No response body");
23
29
  }
24
- options.onOpen?.();
30
+ options?.onOpen?.();
25
31
  const reader = response.body.getReader();
26
32
  const decoder = new TextDecoder();
27
33
  let buffer = "";
@@ -64,3 +70,22 @@ export async function* streamSSE(url, options = {}) {
64
70
  reader.releaseLock();
65
71
  }
66
72
  }
73
+ /**
74
+ * Legacy streamSSE function - DEPRECATED.
75
+ * Use rawClient.streamGet() + parseSSE() instead.
76
+ *
77
+ * Kept for backward compatibility during migration.
78
+ *
79
+ * @deprecated Use rawClient.streamGet() + parseSSE() instead
80
+ */
81
+ export async function* streamSSE(url, options = {}) {
82
+ const response = await fetch(url, {
83
+ method: "GET",
84
+ headers: {
85
+ Accept: "text/event-stream",
86
+ ...options.headers,
87
+ },
88
+ signal: options.signal,
89
+ });
90
+ yield* parseSSE(response, { onOpen: options.onOpen });
91
+ }
package/package.json CHANGED
@@ -1,51 +1,52 @@
1
1
  {
2
- "name": "@agent-os-sdk/client",
3
- "version": "0.3.0",
4
- "description": "Official TypeScript SDK for Agent OS platform",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "import": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- }
14
- },
15
- "keywords": [
16
- "agent-os",
17
- "sdk",
18
- "ai",
19
- "agents",
20
- "typescript"
21
- ],
22
- "author": "Agent OS Team",
23
- "license": "MIT",
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/yuri12344/agent-os.git"
27
- },
28
- "publishConfig": {
29
- "access": "public"
30
- },
31
- "dependencies": {
32
- "openapi-fetch": "^0.13.0"
33
- },
34
- "devDependencies": {
35
- "openapi-typescript": "^7.4.0",
36
- "tsx": "^4.19.0",
37
- "typescript": "^5.5.0",
38
- "vitest": "^4.0.18"
39
- },
40
- "files": [
41
- "dist",
42
- "src"
43
- ],
44
- "scripts": {
45
- "generate": "tsx scripts/generate.ts",
46
- "build": "tsc",
47
- "dev": "tsc --watch",
48
- "test": "vitest run",
49
- "typecheck": "tsc --noEmit"
50
- }
51
- }
2
+ "name": "@agent-os-sdk/client",
3
+ "version": "0.3.2",
4
+ "description": "Official TypeScript SDK for Agent OS platform",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "generate": "tsx scripts/generate.ts",
17
+ "build": "tsc",
18
+ "dev": "tsc --watch",
19
+ "test": "vitest run",
20
+ "typecheck": "tsc --noEmit",
21
+ "prepublishOnly": "pnpm build"
22
+ },
23
+ "keywords": [
24
+ "agent-os",
25
+ "sdk",
26
+ "ai",
27
+ "agents",
28
+ "typescript"
29
+ ],
30
+ "author": "Agent OS Team",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/yuri12344/agent-os.git"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "dependencies": {
40
+ "openapi-fetch": "^0.13.0"
41
+ },
42
+ "devDependencies": {
43
+ "openapi-typescript": "^7.4.0",
44
+ "tsx": "^4.19.0",
45
+ "typescript": "^5.5.0",
46
+ "vitest": "^4.0.18"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "src"
51
+ ]
52
+ }
@@ -67,6 +67,7 @@ import { MeModule } from "../modules/me.js";
67
67
  import { InfoModule } from "../modules/info.js";
68
68
  import { MetricsModule } from "../modules/metrics.js";
69
69
  import { GraphsModule } from "../modules/graphs.js";
70
+ import { CatalogModule } from "../modules/catalog.js";
70
71
 
71
72
  // Future modules (mocked)
72
73
  import { HandoffModule } from "../modules/handoff.js";
@@ -121,6 +122,7 @@ export class AgentOsClient {
121
122
  readonly info: InfoModule;
122
123
  readonly metrics: MetricsModule;
123
124
  readonly graphs: GraphsModule;
125
+ readonly catalog: CatalogModule;
124
126
 
125
127
  // Future modules (mocked)
126
128
  readonly handoff: HandoffModule;
@@ -167,13 +169,13 @@ export class AgentOsClient {
167
169
 
168
170
  // Initialize core modules
169
171
  this.agents = new AgentsModule(this._client, getHeaders);
170
- this.runs = new RunsModule(this._client, this._baseUrl, getHeaders);
172
+ this.runs = new RunsModule(this._client);
171
173
  this.threads = new ThreadsModule(this._client, getHeaders);
172
174
  this.tools = new ToolsModule(this._client, getHeaders);
173
175
  this.knowledge = new KnowledgeModule(this._client, getWorkspaceId, getHeaders);
174
176
  this.triggers = new TriggersModule(this._client, getHeaders);
175
177
  this.credentials = new CredentialsModule(this._client, getWorkspaceId, getHeaders);
176
- this.builder = new BuilderModule(this._baseUrl, getHeaders);
178
+ this.builder = new BuilderModule(this._client);
177
179
  this.members = new MembersModule(this._client, getHeaders);
178
180
  this.tenants = new TenantsModule(this._client, getHeaders);
179
181
  this.workspaces = new WorkspacesModule(this._client, getTenantId, getHeaders);
@@ -195,8 +197,9 @@ export class AgentOsClient {
195
197
  this.a2a = new A2aModule(this._client, getHeaders);
196
198
  this.me = new MeModule(this._client, getHeaders);
197
199
  this.info = new InfoModule(this._client, getHeaders);
198
- this.metrics = new MetricsModule(this._baseUrl, getHeaders);
200
+ this.metrics = new MetricsModule(this._client);
199
201
  this.graphs = new GraphsModule(this._client, getHeaders);
202
+ this.catalog = new CatalogModule(this._client);
200
203
 
201
204
  // Initialize future modules (mocked)
202
205
  this.handoff = new HandoffModule(this._client, getHeaders);
package/src/client/raw.ts CHANGED
@@ -151,6 +151,80 @@ export function createRawClient(options: ClientOptions) {
151
151
  request<T>("PATCH", path, opts),
152
152
  DELETE: <T>(path: string, opts?: Parameters<typeof request>[2]) =>
153
153
  request<T>("DELETE", path, opts),
154
+
155
+ /**
156
+ * Stream GET request - returns raw Response for SSE consumption.
157
+ * Headers are resolved asynchronously (includes Auth + Workspace).
158
+ */
159
+ streamGet: async (
160
+ path: string,
161
+ opts?: { params?: { path?: Record<string, string>; query?: Record<string, unknown> }; headers?: Record<string, string> }
162
+ ): Promise<Response> => {
163
+ let url = path;
164
+ if (opts?.params?.path) {
165
+ for (const [key, value] of Object.entries(opts.params.path)) {
166
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
167
+ }
168
+ }
169
+ if (opts?.params?.query) {
170
+ const query = new URLSearchParams();
171
+ for (const [key, value] of Object.entries(opts.params.query)) {
172
+ if (value !== undefined && value !== null) {
173
+ query.append(key, String(value));
174
+ }
175
+ }
176
+ const queryStr = query.toString();
177
+ if (queryStr) url += `?${queryStr}`;
178
+ }
179
+ const fullUrl = `${baseUrl}${url}`;
180
+ const dynamicHeaders = headerProvider ? await headerProvider() : {};
181
+ const headers: Record<string, string> = {
182
+ ...defaultHeaders,
183
+ ...dynamicHeaders,
184
+ Accept: "text/event-stream",
185
+ ...opts?.headers,
186
+ };
187
+ return fetch(fullUrl, { method: "GET", headers });
188
+ },
189
+
190
+ /**
191
+ * Stream POST request - returns raw Response for SSE consumption.
192
+ * Headers are resolved asynchronously (includes Auth + Workspace).
193
+ */
194
+ streamPost: async (
195
+ path: string,
196
+ opts?: {
197
+ params?: { path?: Record<string, string> };
198
+ body?: unknown;
199
+ headers?: Record<string, string>;
200
+ signal?: AbortSignal;
201
+ }
202
+ ): Promise<Response> => {
203
+ let url = path;
204
+ if (opts?.params?.path) {
205
+ for (const [key, value] of Object.entries(opts.params.path)) {
206
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
207
+ }
208
+ }
209
+ const fullUrl = `${baseUrl}${url}`;
210
+ const dynamicHeaders = headerProvider ? await headerProvider() : {};
211
+ const headers: Record<string, string> = {
212
+ ...defaultHeaders,
213
+ ...dynamicHeaders,
214
+ "Content-Type": "application/json",
215
+ Accept: "text/event-stream",
216
+ ...opts?.headers,
217
+ };
218
+ return fetch(fullUrl, {
219
+ method: "POST",
220
+ headers,
221
+ body: opts?.body ? JSON.stringify(opts.body) : undefined,
222
+ signal: opts?.signal,
223
+ });
224
+ },
225
+
226
+ /** Base URL for constructing full URLs when needed */
227
+ baseUrl,
154
228
  };
155
229
  }
156
230