@agent-os-sdk/client 0.3.0 → 0.3.1
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/AgentOsClient.js +3 -3
- package/dist/client/raw.d.ts +25 -0
- package/dist/client/raw.d.ts.map +1 -1
- package/dist/client/raw.js +61 -0
- package/dist/generated/openapi.d.ts +156 -26
- package/dist/generated/openapi.d.ts.map +1 -1
- package/dist/modules/builder.d.ts +10 -4
- package/dist/modules/builder.d.ts.map +1 -1
- package/dist/modules/builder.js +21 -30
- package/dist/modules/metrics.d.ts +7 -3
- package/dist/modules/metrics.d.ts.map +1 -1
- package/dist/modules/metrics.js +10 -7
- package/dist/modules/runs.d.ts +1 -3
- package/dist/modules/runs.d.ts.map +1 -1
- package/dist/modules/runs.js +12 -28
- package/dist/sse/client.d.ts +26 -1
- package/dist/sse/client.d.ts.map +1 -1
- package/dist/sse/client.js +36 -11
- package/package.json +51 -50
- package/src/client/AgentOsClient.ts +3 -3
- package/src/client/raw.ts +74 -0
- package/src/generated/openapi.ts +156 -26
- package/src/generated/swagger.json +144 -82
- package/src/modules/builder.ts +25 -32
- package/src/modules/metrics.ts +10 -3
- package/src/modules/runs.ts +12 -28
- package/src/sse/client.ts +43 -14
|
@@ -1222,6 +1222,50 @@
|
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
1224
|
},
|
|
1225
|
+
"/v1/api/catalog/nodes": {
|
|
1226
|
+
"get": {
|
|
1227
|
+
"tags": [
|
|
1228
|
+
"Catalog"
|
|
1229
|
+
],
|
|
1230
|
+
"summary": "Get the Node Catalog (v1).",
|
|
1231
|
+
"parameters": [
|
|
1232
|
+
{
|
|
1233
|
+
"name": "version",
|
|
1234
|
+
"in": "query",
|
|
1235
|
+
"schema": {
|
|
1236
|
+
"type": "string"
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
],
|
|
1240
|
+
"responses": {
|
|
1241
|
+
"200": {
|
|
1242
|
+
"description": "OK"
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
},
|
|
1247
|
+
"/v1/api/triggers/templates": {
|
|
1248
|
+
"get": {
|
|
1249
|
+
"tags": [
|
|
1250
|
+
"Catalog"
|
|
1251
|
+
],
|
|
1252
|
+
"summary": "Get the Trigger Templates Catalog (v1).",
|
|
1253
|
+
"parameters": [
|
|
1254
|
+
{
|
|
1255
|
+
"name": "version",
|
|
1256
|
+
"in": "query",
|
|
1257
|
+
"schema": {
|
|
1258
|
+
"type": "string"
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
],
|
|
1262
|
+
"responses": {
|
|
1263
|
+
"200": {
|
|
1264
|
+
"description": "OK"
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1225
1269
|
"/v1/api/workspaces/{workspaceId}/runs/{runId}/checkpoints": {
|
|
1226
1270
|
"get": {
|
|
1227
1271
|
"tags": [
|
|
@@ -5233,7 +5277,17 @@
|
|
|
5233
5277
|
"tags": [
|
|
5234
5278
|
"Tools"
|
|
5235
5279
|
],
|
|
5236
|
-
"summary": "List all tool definitions.",
|
|
5280
|
+
"summary": "List all tool definitions.\nSupports ?version=1 for canonical ToolCatalog format.",
|
|
5281
|
+
"parameters": [
|
|
5282
|
+
{
|
|
5283
|
+
"name": "version",
|
|
5284
|
+
"in": "query",
|
|
5285
|
+
"schema": {
|
|
5286
|
+
"type": "string",
|
|
5287
|
+
"default": "1"
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
],
|
|
5237
5291
|
"responses": {
|
|
5238
5292
|
"200": {
|
|
5239
5293
|
"description": "OK"
|
|
@@ -5246,7 +5300,17 @@
|
|
|
5246
5300
|
"tags": [
|
|
5247
5301
|
"Tools"
|
|
5248
5302
|
],
|
|
5249
|
-
"summary": "List all tool definitions.",
|
|
5303
|
+
"summary": "List all tool definitions.\nSupports ?version=1 for canonical ToolCatalog format.",
|
|
5304
|
+
"parameters": [
|
|
5305
|
+
{
|
|
5306
|
+
"name": "version",
|
|
5307
|
+
"in": "query",
|
|
5308
|
+
"schema": {
|
|
5309
|
+
"type": "string",
|
|
5310
|
+
"default": "1"
|
|
5311
|
+
}
|
|
5312
|
+
}
|
|
5313
|
+
],
|
|
5250
5314
|
"responses": {
|
|
5251
5315
|
"200": {
|
|
5252
5316
|
"description": "OK"
|
|
@@ -5826,25 +5890,13 @@
|
|
|
5826
5890
|
}
|
|
5827
5891
|
}
|
|
5828
5892
|
},
|
|
5829
|
-
"/v1/api/
|
|
5893
|
+
"/v1/api/vector-stores": {
|
|
5830
5894
|
"post": {
|
|
5831
5895
|
"tags": [
|
|
5832
5896
|
"VectorStores"
|
|
5833
5897
|
],
|
|
5834
5898
|
"summary": "Creates a new vector store for semantic document search.",
|
|
5835
5899
|
"description": "Creates a vector store with the specified embedding configuration.\nThe store is ready to accept file attachments immediately after creation.\n\n**Default Configuration:**\n- Provider: `openai`\n- Model: `text-embedding-3-small`\n- Dimension: `1536`",
|
|
5836
|
-
"parameters": [
|
|
5837
|
-
{
|
|
5838
|
-
"name": "workspaceId",
|
|
5839
|
-
"in": "path",
|
|
5840
|
-
"description": "The workspace to create the vector store in.",
|
|
5841
|
-
"required": true,
|
|
5842
|
-
"schema": {
|
|
5843
|
-
"type": "string",
|
|
5844
|
-
"format": "uuid"
|
|
5845
|
-
}
|
|
5846
|
-
}
|
|
5847
|
-
],
|
|
5848
5900
|
"requestBody": {
|
|
5849
5901
|
"description": "Vector store configuration.",
|
|
5850
5902
|
"content": {
|
|
@@ -5876,6 +5928,16 @@
|
|
|
5876
5928
|
}
|
|
5877
5929
|
}
|
|
5878
5930
|
},
|
|
5931
|
+
"401": {
|
|
5932
|
+
"description": "Authentication or Workspace context required.",
|
|
5933
|
+
"content": {
|
|
5934
|
+
"application/json": {
|
|
5935
|
+
"schema": {
|
|
5936
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
5937
|
+
}
|
|
5938
|
+
}
|
|
5939
|
+
}
|
|
5940
|
+
},
|
|
5879
5941
|
"404": {
|
|
5880
5942
|
"description": "Workspace not found.",
|
|
5881
5943
|
"content": {
|
|
@@ -5894,15 +5956,6 @@
|
|
|
5894
5956
|
],
|
|
5895
5957
|
"summary": "List vector stores in a workspace.",
|
|
5896
5958
|
"parameters": [
|
|
5897
|
-
{
|
|
5898
|
-
"name": "workspaceId",
|
|
5899
|
-
"in": "path",
|
|
5900
|
-
"required": true,
|
|
5901
|
-
"schema": {
|
|
5902
|
-
"type": "string",
|
|
5903
|
-
"format": "uuid"
|
|
5904
|
-
}
|
|
5905
|
-
},
|
|
5906
5959
|
{
|
|
5907
5960
|
"name": "limit",
|
|
5908
5961
|
"in": "query",
|
|
@@ -5935,26 +5988,27 @@
|
|
|
5935
5988
|
}
|
|
5936
5989
|
}
|
|
5937
5990
|
}
|
|
5991
|
+
},
|
|
5992
|
+
"401": {
|
|
5993
|
+
"description": "Unauthorized",
|
|
5994
|
+
"content": {
|
|
5995
|
+
"application/json": {
|
|
5996
|
+
"schema": {
|
|
5997
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
}
|
|
5938
6001
|
}
|
|
5939
6002
|
}
|
|
5940
6003
|
}
|
|
5941
6004
|
},
|
|
5942
|
-
"/v1/api/
|
|
6005
|
+
"/v1/api/vector-stores/{vectorStoreId}": {
|
|
5943
6006
|
"get": {
|
|
5944
6007
|
"tags": [
|
|
5945
6008
|
"VectorStores"
|
|
5946
6009
|
],
|
|
5947
6010
|
"summary": "Get a vector store by ID.",
|
|
5948
6011
|
"parameters": [
|
|
5949
|
-
{
|
|
5950
|
-
"name": "workspaceId",
|
|
5951
|
-
"in": "path",
|
|
5952
|
-
"required": true,
|
|
5953
|
-
"schema": {
|
|
5954
|
-
"type": "string",
|
|
5955
|
-
"format": "uuid"
|
|
5956
|
-
}
|
|
5957
|
-
},
|
|
5958
6012
|
{
|
|
5959
6013
|
"name": "vectorStoreId",
|
|
5960
6014
|
"in": "path",
|
|
@@ -5976,6 +6030,16 @@
|
|
|
5976
6030
|
}
|
|
5977
6031
|
}
|
|
5978
6032
|
},
|
|
6033
|
+
"401": {
|
|
6034
|
+
"description": "Unauthorized",
|
|
6035
|
+
"content": {
|
|
6036
|
+
"application/json": {
|
|
6037
|
+
"schema": {
|
|
6038
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
}
|
|
6042
|
+
},
|
|
5979
6043
|
"404": {
|
|
5980
6044
|
"description": "Not Found",
|
|
5981
6045
|
"content": {
|
|
@@ -5994,15 +6058,6 @@
|
|
|
5994
6058
|
],
|
|
5995
6059
|
"summary": "Delete a vector store.",
|
|
5996
6060
|
"parameters": [
|
|
5997
|
-
{
|
|
5998
|
-
"name": "workspaceId",
|
|
5999
|
-
"in": "path",
|
|
6000
|
-
"required": true,
|
|
6001
|
-
"schema": {
|
|
6002
|
-
"type": "string",
|
|
6003
|
-
"format": "uuid"
|
|
6004
|
-
}
|
|
6005
|
-
},
|
|
6006
6061
|
{
|
|
6007
6062
|
"name": "vectorStoreId",
|
|
6008
6063
|
"in": "path",
|
|
@@ -6017,6 +6072,16 @@
|
|
|
6017
6072
|
"204": {
|
|
6018
6073
|
"description": "No Content"
|
|
6019
6074
|
},
|
|
6075
|
+
"401": {
|
|
6076
|
+
"description": "Unauthorized",
|
|
6077
|
+
"content": {
|
|
6078
|
+
"application/json": {
|
|
6079
|
+
"schema": {
|
|
6080
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
},
|
|
6020
6085
|
"404": {
|
|
6021
6086
|
"description": "Not Found",
|
|
6022
6087
|
"content": {
|
|
@@ -6030,22 +6095,13 @@
|
|
|
6030
6095
|
}
|
|
6031
6096
|
}
|
|
6032
6097
|
},
|
|
6033
|
-
"/v1/api/
|
|
6098
|
+
"/v1/api/vector-stores/{vectorStoreId}/files": {
|
|
6034
6099
|
"post": {
|
|
6035
6100
|
"tags": [
|
|
6036
6101
|
"VectorStores"
|
|
6037
6102
|
],
|
|
6038
6103
|
"summary": "Attach a file to a vector store for embedding.",
|
|
6039
6104
|
"parameters": [
|
|
6040
|
-
{
|
|
6041
|
-
"name": "workspaceId",
|
|
6042
|
-
"in": "path",
|
|
6043
|
-
"required": true,
|
|
6044
|
-
"schema": {
|
|
6045
|
-
"type": "string",
|
|
6046
|
-
"format": "uuid"
|
|
6047
|
-
}
|
|
6048
|
-
},
|
|
6049
6105
|
{
|
|
6050
6106
|
"name": "vectorStoreId",
|
|
6051
6107
|
"in": "path",
|
|
@@ -6086,6 +6142,16 @@
|
|
|
6086
6142
|
}
|
|
6087
6143
|
}
|
|
6088
6144
|
},
|
|
6145
|
+
"401": {
|
|
6146
|
+
"description": "Unauthorized",
|
|
6147
|
+
"content": {
|
|
6148
|
+
"application/json": {
|
|
6149
|
+
"schema": {
|
|
6150
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
6151
|
+
}
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
},
|
|
6089
6155
|
"404": {
|
|
6090
6156
|
"description": "Not Found",
|
|
6091
6157
|
"content": {
|
|
@@ -6099,7 +6165,7 @@
|
|
|
6099
6165
|
}
|
|
6100
6166
|
}
|
|
6101
6167
|
},
|
|
6102
|
-
"/v1/api/
|
|
6168
|
+
"/v1/api/vector-stores/{vectorStoreId}/query": {
|
|
6103
6169
|
"post": {
|
|
6104
6170
|
"tags": [
|
|
6105
6171
|
"VectorStores"
|
|
@@ -6107,16 +6173,6 @@
|
|
|
6107
6173
|
"summary": "Performs semantic similarity search against the vector store.",
|
|
6108
6174
|
"description": "Executes a cosine similarity search to find document chunks most relevant\nto the query. Results are ranked by similarity score.\n\n**Note:** The query is automatically embedded using the store's configured\nembedding provider before search.\n\n**Example Request:**\n```json\n{\n \"query\": \"How do I configure authentication?\",\n \"top_k\": 5,\n \"min_score\": 0.7\n}\n```",
|
|
6109
6175
|
"parameters": [
|
|
6110
|
-
{
|
|
6111
|
-
"name": "workspaceId",
|
|
6112
|
-
"in": "path",
|
|
6113
|
-
"description": "The workspace containing the vector store.",
|
|
6114
|
-
"required": true,
|
|
6115
|
-
"schema": {
|
|
6116
|
-
"type": "string",
|
|
6117
|
-
"format": "uuid"
|
|
6118
|
-
}
|
|
6119
|
-
},
|
|
6120
6176
|
{
|
|
6121
6177
|
"name": "vectorStoreId",
|
|
6122
6178
|
"in": "path",
|
|
@@ -6159,6 +6215,16 @@
|
|
|
6159
6215
|
}
|
|
6160
6216
|
}
|
|
6161
6217
|
},
|
|
6218
|
+
"401": {
|
|
6219
|
+
"description": "Authentication or Workspace context required.",
|
|
6220
|
+
"content": {
|
|
6221
|
+
"application/json": {
|
|
6222
|
+
"schema": {
|
|
6223
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
6224
|
+
}
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
},
|
|
6162
6228
|
"404": {
|
|
6163
6229
|
"description": "Vector store not found.",
|
|
6164
6230
|
"content": {
|
|
@@ -6172,22 +6238,13 @@
|
|
|
6172
6238
|
}
|
|
6173
6239
|
}
|
|
6174
6240
|
},
|
|
6175
|
-
"/v1/api/
|
|
6241
|
+
"/v1/api/vector-stores/{vectorStoreId}/bind-agent": {
|
|
6176
6242
|
"post": {
|
|
6177
6243
|
"tags": [
|
|
6178
6244
|
"VectorStores"
|
|
6179
6245
|
],
|
|
6180
6246
|
"summary": "Bind a vector store to an agent.",
|
|
6181
6247
|
"parameters": [
|
|
6182
|
-
{
|
|
6183
|
-
"name": "workspaceId",
|
|
6184
|
-
"in": "path",
|
|
6185
|
-
"required": true,
|
|
6186
|
-
"schema": {
|
|
6187
|
-
"type": "string",
|
|
6188
|
-
"format": "uuid"
|
|
6189
|
-
}
|
|
6190
|
-
},
|
|
6191
6248
|
{
|
|
6192
6249
|
"name": "vectorStoreId",
|
|
6193
6250
|
"in": "path",
|
|
@@ -6221,6 +6278,16 @@
|
|
|
6221
6278
|
"204": {
|
|
6222
6279
|
"description": "No Content"
|
|
6223
6280
|
},
|
|
6281
|
+
"401": {
|
|
6282
|
+
"description": "Unauthorized",
|
|
6283
|
+
"content": {
|
|
6284
|
+
"application/json": {
|
|
6285
|
+
"schema": {
|
|
6286
|
+
"$ref": "#/components/schemas/ProblemDetails"
|
|
6287
|
+
}
|
|
6288
|
+
}
|
|
6289
|
+
}
|
|
6290
|
+
},
|
|
6224
6291
|
"404": {
|
|
6225
6292
|
"description": "Not Found",
|
|
6226
6293
|
"content": {
|
|
@@ -6934,14 +7001,6 @@
|
|
|
6934
7001
|
"CreateAgentRequest": {
|
|
6935
7002
|
"type": "object",
|
|
6936
7003
|
"properties": {
|
|
6937
|
-
"tenant_id": {
|
|
6938
|
-
"type": "string",
|
|
6939
|
-
"format": "uuid"
|
|
6940
|
-
},
|
|
6941
|
-
"workspace_id": {
|
|
6942
|
-
"type": "string",
|
|
6943
|
-
"format": "uuid"
|
|
6944
|
-
},
|
|
6945
7004
|
"name": {
|
|
6946
7005
|
"type": "string",
|
|
6947
7006
|
"nullable": true
|
|
@@ -8716,6 +8775,9 @@
|
|
|
8716
8775
|
{
|
|
8717
8776
|
"name": "Builder"
|
|
8718
8777
|
},
|
|
8778
|
+
{
|
|
8779
|
+
"name": "Catalog"
|
|
8780
|
+
},
|
|
8719
8781
|
{
|
|
8720
8782
|
"name": "Checkpoints"
|
|
8721
8783
|
},
|
package/src/modules/builder.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Flow: Frontend → CP:5000/v1/api/builder/{agentId}/chat → DP:8001/v1/internal/builder/{agentId}/chat
|
|
9
9
|
*
|
|
10
|
+
* ALL HTTP goes through rawClient - no direct fetch calls.
|
|
11
|
+
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```ts
|
|
12
14
|
* const client = new AgentOsClient({ ... })
|
|
@@ -25,7 +27,8 @@
|
|
|
25
27
|
* ```
|
|
26
28
|
*/
|
|
27
29
|
|
|
28
|
-
import {
|
|
30
|
+
import type { RawClient, APIResponse } from "../client/raw.js";
|
|
31
|
+
import type { SSEOptions } from "../sse/client.js";
|
|
29
32
|
|
|
30
33
|
export type BuilderChatRequest = {
|
|
31
34
|
message: string;
|
|
@@ -55,36 +58,29 @@ export type BuilderChatResponse = {
|
|
|
55
58
|
};
|
|
56
59
|
|
|
57
60
|
export class BuilderModule {
|
|
58
|
-
constructor(
|
|
59
|
-
private baseUrl: string,
|
|
60
|
-
private headers: () => Record<string, string>
|
|
61
|
-
) { }
|
|
61
|
+
constructor(private client: RawClient) { }
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Stream chat with meta-agent (SSE).
|
|
65
65
|
* Returns async generator of events.
|
|
66
|
+
*
|
|
67
|
+
* Uses rawClient.streamPost() - headers resolved asynchronously.
|
|
66
68
|
*/
|
|
67
69
|
async *chat(
|
|
68
70
|
agentId: string,
|
|
69
71
|
request: BuilderChatRequest,
|
|
70
72
|
options?: SSEOptions
|
|
71
73
|
): AsyncGenerator<BuilderStreamEvent> {
|
|
72
|
-
// Use
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers: {
|
|
78
|
-
"Content-Type": "application/json",
|
|
79
|
-
Accept: "text/event-stream",
|
|
80
|
-
...this.headers(),
|
|
81
|
-
},
|
|
82
|
-
body: JSON.stringify(request),
|
|
74
|
+
// Use rawClient.streamPost() - ALL auth headers resolved automatically
|
|
75
|
+
const response = await this.client.streamPost("/v1/api/builder/{agentId}/chat", {
|
|
76
|
+
params: { path: { agentId } },
|
|
77
|
+
body: request,
|
|
83
78
|
signal: options?.signal,
|
|
84
79
|
});
|
|
85
80
|
|
|
86
81
|
if (!response.ok) {
|
|
87
|
-
|
|
82
|
+
const errorText = await response.text();
|
|
83
|
+
throw new Error(`Builder chat failed: ${response.status} - ${errorText}`);
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
if (!response.body) {
|
|
@@ -133,29 +129,26 @@ export class BuilderModule {
|
|
|
133
129
|
|
|
134
130
|
/**
|
|
135
131
|
* Sync chat with meta-agent (no streaming).
|
|
132
|
+
*
|
|
133
|
+
* Uses rawClient.POST() - headers resolved asynchronously.
|
|
136
134
|
*/
|
|
137
135
|
async chatSync(
|
|
138
136
|
agentId: string,
|
|
139
137
|
request: BuilderChatRequest
|
|
140
138
|
): Promise<BuilderChatResponse> {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...this.headers(),
|
|
149
|
-
},
|
|
150
|
-
body: JSON.stringify(request),
|
|
151
|
-
});
|
|
139
|
+
const { data, error } = await this.client.POST<BuilderChatResponse>(
|
|
140
|
+
"/v1/api/builder/{agentId}/chat/sync",
|
|
141
|
+
{
|
|
142
|
+
params: { path: { agentId } },
|
|
143
|
+
body: request,
|
|
144
|
+
}
|
|
145
|
+
);
|
|
152
146
|
|
|
153
|
-
if (
|
|
154
|
-
|
|
155
|
-
throw new Error(`Builder chat failed: ${response.status} - ${error}`);
|
|
147
|
+
if (error) {
|
|
148
|
+
throw new Error(`Builder chat failed: ${error.code} - ${error.message}`);
|
|
156
149
|
}
|
|
157
150
|
|
|
158
|
-
return
|
|
151
|
+
return data!;
|
|
159
152
|
}
|
|
160
153
|
|
|
161
154
|
/**
|
package/src/modules/metrics.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Metrics Module - Fully Typed
|
|
3
|
+
*
|
|
4
|
+
* ALL HTTP goes through rawClient - no direct fetch calls.
|
|
3
5
|
*/
|
|
4
6
|
|
|
7
|
+
import type { RawClient } from "../client/raw.js";
|
|
8
|
+
|
|
5
9
|
export interface MetricsResponse {
|
|
6
10
|
raw: string;
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export class MetricsModule {
|
|
10
|
-
constructor(private
|
|
14
|
+
constructor(private client: RawClient) { }
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* Get Prometheus metrics.
|
|
18
|
+
*
|
|
19
|
+
* Uses rawClient - headers resolved asynchronously.
|
|
14
20
|
*/
|
|
15
21
|
async get(): Promise<MetricsResponse> {
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
// Use streamGet for raw text response (metrics endpoint returns text/plain)
|
|
23
|
+
const response = await this.client.streamGet("/metrics", {
|
|
24
|
+
headers: { Accept: "text/plain" }
|
|
18
25
|
});
|
|
19
26
|
|
|
20
27
|
if (!response.ok) {
|
package/src/modules/runs.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type { RawClient, APIResponse, components } from "../client/raw.js";
|
|
11
11
|
import type { PaginationParams, PaginatedResponse } from "../client/helpers.js";
|
|
12
|
-
import {
|
|
12
|
+
import { parseSSE, type SSEEvent, type RunStreamEvent, type SSEOptions } from "../sse/client.js";
|
|
13
13
|
|
|
14
14
|
// Type aliases from OpenAPI
|
|
15
15
|
type WaitRunResponse = components["schemas"]["WaitRunResponse"];
|
|
@@ -91,11 +91,7 @@ export interface RunEventDto {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
export class RunsModule {
|
|
94
|
-
constructor(
|
|
95
|
-
private client: RawClient,
|
|
96
|
-
private baseUrl: string,
|
|
97
|
-
private headers: () => Record<string, string>
|
|
98
|
-
) { }
|
|
94
|
+
constructor(private client: RawClient) { }
|
|
99
95
|
|
|
100
96
|
// ======================== CRUD ========================
|
|
101
97
|
|
|
@@ -117,7 +113,6 @@ export class RunsModule {
|
|
|
117
113
|
}): Promise<APIResponse<CreateRunResponse>> {
|
|
118
114
|
return this.client.POST<CreateRunResponse>("/v1/api/runs", {
|
|
119
115
|
body,
|
|
120
|
-
headers: this.headers(),
|
|
121
116
|
});
|
|
122
117
|
}
|
|
123
118
|
|
|
@@ -127,7 +122,6 @@ export class RunsModule {
|
|
|
127
122
|
async get(runId: string): Promise<APIResponse<Run>> {
|
|
128
123
|
return this.client.GET<Run>("/v1/api/runs/{runId}", {
|
|
129
124
|
params: { path: { runId } },
|
|
130
|
-
headers: this.headers(),
|
|
131
125
|
});
|
|
132
126
|
}
|
|
133
127
|
|
|
@@ -141,7 +135,6 @@ export class RunsModule {
|
|
|
141
135
|
}): Promise<APIResponse<RunListResponse>> {
|
|
142
136
|
return this.client.GET<RunListResponse>("/v1/api/runs", {
|
|
143
137
|
params: { query: params },
|
|
144
|
-
headers: this.headers(),
|
|
145
138
|
});
|
|
146
139
|
}
|
|
147
140
|
|
|
@@ -158,7 +151,6 @@ export class RunsModule {
|
|
|
158
151
|
}): Promise<APIResponse<WaitRunResponse>> {
|
|
159
152
|
return this.client.POST<WaitRunResponse>("/v1/api/runs/wait", {
|
|
160
153
|
body,
|
|
161
|
-
headers: this.headers(),
|
|
162
154
|
});
|
|
163
155
|
}
|
|
164
156
|
|
|
@@ -171,7 +163,6 @@ export class RunsModule {
|
|
|
171
163
|
}): Promise<APIResponse<BatchRunResponse>> {
|
|
172
164
|
return this.client.POST<BatchRunResponse>("/v1/api/runs/batch", {
|
|
173
165
|
body,
|
|
174
|
-
headers: this.headers(),
|
|
175
166
|
});
|
|
176
167
|
}
|
|
177
168
|
|
|
@@ -182,7 +173,6 @@ export class RunsModule {
|
|
|
182
173
|
return this.client.POST<CancelRunResponse>("/v1/api/runs/{runId}/cancel", {
|
|
183
174
|
params: { path: { runId } },
|
|
184
175
|
body: { reason },
|
|
185
|
-
headers: this.headers(),
|
|
186
176
|
});
|
|
187
177
|
}
|
|
188
178
|
|
|
@@ -212,7 +202,6 @@ export class RunsModule {
|
|
|
212
202
|
return this.client.POST<Run>("/v1/api/runs/{runId}/resume", {
|
|
213
203
|
params: { path: { runId } },
|
|
214
204
|
body,
|
|
215
|
-
headers: this.headers(),
|
|
216
205
|
});
|
|
217
206
|
}
|
|
218
207
|
|
|
@@ -222,7 +211,6 @@ export class RunsModule {
|
|
|
222
211
|
async rerun(runId: string): Promise<APIResponse<CreateRunResponse>> {
|
|
223
212
|
return this.client.POST<CreateRunResponse>("/v1/api/runs/{runId}/rerun", {
|
|
224
213
|
params: { path: { runId } },
|
|
225
|
-
headers: this.headers(),
|
|
226
214
|
});
|
|
227
215
|
}
|
|
228
216
|
|
|
@@ -259,7 +247,6 @@ export class RunsModule {
|
|
|
259
247
|
mode: options?.mode,
|
|
260
248
|
reason: options?.reason
|
|
261
249
|
},
|
|
262
|
-
headers: this.headers(),
|
|
263
250
|
});
|
|
264
251
|
}
|
|
265
252
|
|
|
@@ -275,7 +262,6 @@ export class RunsModule {
|
|
|
275
262
|
async getEvents(runId: string, params?: PaginationParams): Promise<APIResponse<RunEventsResponse>> {
|
|
276
263
|
return this.client.GET<RunEventsResponse>("/v1/api/runs/{runId}/events", {
|
|
277
264
|
params: { path: { runId }, query: params },
|
|
278
|
-
headers: this.headers(),
|
|
279
265
|
});
|
|
280
266
|
}
|
|
281
267
|
|
|
@@ -315,7 +301,6 @@ export class RunsModule {
|
|
|
315
301
|
limit: params?.limit ?? 100
|
|
316
302
|
}
|
|
317
303
|
},
|
|
318
|
-
headers: this.headers(),
|
|
319
304
|
});
|
|
320
305
|
}
|
|
321
306
|
|
|
@@ -327,7 +312,6 @@ export class RunsModule {
|
|
|
327
312
|
async getCheckpoints(runId: string): Promise<APIResponse<CheckpointListResponse>> {
|
|
328
313
|
return this.client.GET<CheckpointListResponse>("/v1/api/runs/{runId}/checkpoints", {
|
|
329
314
|
params: { path: { runId } },
|
|
330
|
-
headers: this.headers(),
|
|
331
315
|
});
|
|
332
316
|
}
|
|
333
317
|
|
|
@@ -345,12 +329,12 @@ export class RunsModule {
|
|
|
345
329
|
* }
|
|
346
330
|
* ```
|
|
347
331
|
*/
|
|
348
|
-
stream(runId: string, options?: SSEOptions): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
headers: { ...this.headers(), ...options?.headers },
|
|
332
|
+
async *stream(runId: string, options?: SSEOptions): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
333
|
+
const response = await this.client.streamGet("/v1/api/runs/{runId}/stream", {
|
|
334
|
+
params: { path: { runId } },
|
|
335
|
+
headers: options?.headers,
|
|
353
336
|
});
|
|
337
|
+
yield* parseSSE<RunStreamEvent>(response, { onOpen: options?.onOpen });
|
|
354
338
|
}
|
|
355
339
|
|
|
356
340
|
/**
|
|
@@ -385,11 +369,11 @@ export class RunsModule {
|
|
|
385
369
|
/**
|
|
386
370
|
* Join an existing run's stream (resume watching).
|
|
387
371
|
*/
|
|
388
|
-
join(runId: string, options?: SSEOptions): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
headers: { ...this.headers(), ...options?.headers },
|
|
372
|
+
async *join(runId: string, options?: SSEOptions): AsyncGenerator<SSEEvent<RunStreamEvent>> {
|
|
373
|
+
const response = await this.client.streamGet("/v1/api/runs/{runId}/join", {
|
|
374
|
+
params: { path: { runId } },
|
|
375
|
+
headers: options?.headers,
|
|
393
376
|
});
|
|
377
|
+
yield* parseSSE<RunStreamEvent>(response, { onOpen: options?.onOpen });
|
|
394
378
|
}
|
|
395
379
|
}
|