@runtypelabs/sdk 2.1.1 → 3.0.0
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/index.cjs +447 -45
- package/dist/index.d.cts +40254 -222
- package/dist/index.d.ts +40254 -222
- package/dist/index.mjs +438 -45
- package/package.json +7 -4
package/dist/index.cjs
CHANGED
|
@@ -23,9 +23,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
23
23
|
// src/stream-utils.ts
|
|
24
24
|
var stream_utils_exports = {};
|
|
25
25
|
__export(stream_utils_exports, {
|
|
26
|
+
flowErrorMessage: () => flowErrorMessage,
|
|
26
27
|
parseFinalBuffer: () => parseFinalBuffer,
|
|
27
28
|
parseSSEChunk: () => parseSSEChunk,
|
|
28
29
|
processStream: () => processStream,
|
|
30
|
+
stepDeltaText: () => stepDeltaText,
|
|
31
|
+
stepDisplayName: () => stepDisplayName,
|
|
29
32
|
streamEvents: () => streamEvents
|
|
30
33
|
});
|
|
31
34
|
function parseSSEChunk(chunk, buffer) {
|
|
@@ -146,7 +149,7 @@ async function processStream(response, callbacks = {}) {
|
|
|
146
149
|
try {
|
|
147
150
|
const event = JSON.parse(eventStr);
|
|
148
151
|
handleEvent(event, callbacks, results, flowSummary);
|
|
149
|
-
} catch
|
|
152
|
+
} catch {
|
|
150
153
|
console.warn("Failed to parse SSE event:", eventStr);
|
|
151
154
|
}
|
|
152
155
|
}
|
|
@@ -156,7 +159,7 @@ async function processStream(response, callbacks = {}) {
|
|
|
156
159
|
try {
|
|
157
160
|
const event = JSON.parse(finalEvent);
|
|
158
161
|
handleEvent(event, callbacks, results, flowSummary);
|
|
159
|
-
} catch
|
|
162
|
+
} catch {
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
} catch (error) {
|
|
@@ -178,6 +181,15 @@ async function processStream(response, callbacks = {}) {
|
|
|
178
181
|
success: flowSummary.success ?? true
|
|
179
182
|
};
|
|
180
183
|
}
|
|
184
|
+
function stepDeltaText(event) {
|
|
185
|
+
return event.text ?? event.delta ?? "";
|
|
186
|
+
}
|
|
187
|
+
function stepDisplayName(event) {
|
|
188
|
+
return event.name ?? event.stepName ?? "";
|
|
189
|
+
}
|
|
190
|
+
function flowErrorMessage(event) {
|
|
191
|
+
return typeof event.error === "string" ? event.error : JSON.stringify(event.error);
|
|
192
|
+
}
|
|
181
193
|
function handleEvent(event, callbacks, results, summary) {
|
|
182
194
|
switch (event.type) {
|
|
183
195
|
case "flow_start":
|
|
@@ -190,24 +202,26 @@ function handleEvent(event, callbacks, results, summary) {
|
|
|
190
202
|
callbacks.onStepStart?.(event);
|
|
191
203
|
break;
|
|
192
204
|
case "step_delta":
|
|
193
|
-
callbacks.onStepDelta?.(event
|
|
205
|
+
callbacks.onStepDelta?.(stepDeltaText(event), event);
|
|
194
206
|
break;
|
|
195
|
-
case "step_complete":
|
|
196
|
-
results.set(event
|
|
207
|
+
case "step_complete": {
|
|
208
|
+
results.set(stepDisplayName(event), event.result);
|
|
197
209
|
callbacks.onStepComplete?.(event.result, event);
|
|
198
210
|
break;
|
|
211
|
+
}
|
|
199
212
|
case "flow_complete":
|
|
200
213
|
summary.totalSteps = event.totalSteps;
|
|
201
214
|
summary.successfulSteps = event.successfulSteps;
|
|
202
215
|
summary.failedSteps = event.failedSteps;
|
|
203
216
|
summary.executionTime = event.executionTime;
|
|
204
|
-
summary.success = event.failedSteps === 0;
|
|
217
|
+
summary.success = event.success ?? (event.failedSteps ?? 0) === 0;
|
|
205
218
|
callbacks.onFlowComplete?.(event);
|
|
206
219
|
break;
|
|
207
|
-
case "flow_error":
|
|
220
|
+
case "flow_error": {
|
|
208
221
|
summary.success = false;
|
|
209
|
-
callbacks.onError?.(new Error(event
|
|
222
|
+
callbacks.onError?.(new Error(flowErrorMessage(event)));
|
|
210
223
|
break;
|
|
224
|
+
}
|
|
211
225
|
case "flow_await":
|
|
212
226
|
break;
|
|
213
227
|
case "step_await":
|
|
@@ -275,17 +289,20 @@ var init_stream_utils = __esm({
|
|
|
275
289
|
// src/index.ts
|
|
276
290
|
var index_exports = {};
|
|
277
291
|
__export(index_exports, {
|
|
292
|
+
AgentVersionsEndpoint: () => AgentVersionsEndpoint,
|
|
278
293
|
AgentsEndpoint: () => AgentsEndpoint,
|
|
279
294
|
AnalyticsEndpoint: () => AnalyticsEndpoint,
|
|
280
295
|
ApiKeysEndpoint: () => ApiKeysEndpoint,
|
|
281
296
|
BatchBuilder: () => BatchBuilder,
|
|
282
297
|
BatchesNamespace: () => BatchesNamespace,
|
|
298
|
+
BillingEndpoint: () => BillingEndpoint,
|
|
283
299
|
ChatEndpoint: () => ChatEndpoint,
|
|
284
300
|
ClientBatchBuilder: () => ClientBatchBuilder,
|
|
285
301
|
ClientEvalBuilder: () => ClientEvalBuilder,
|
|
286
302
|
ClientFlowBuilder: () => ClientFlowBuilder,
|
|
287
303
|
ClientTokensEndpoint: () => ClientTokensEndpoint,
|
|
288
304
|
ContextTemplatesEndpoint: () => ContextTemplatesEndpoint,
|
|
305
|
+
ConversationsEndpoint: () => ConversationsEndpoint,
|
|
289
306
|
DispatchEndpoint: () => DispatchEndpoint,
|
|
290
307
|
EvalBuilder: () => EvalBuilder,
|
|
291
308
|
EvalEndpoint: () => EvalEndpoint,
|
|
@@ -294,8 +311,11 @@ __export(index_exports, {
|
|
|
294
311
|
FlowBuilder: () => FlowBuilder,
|
|
295
312
|
FlowResult: () => FlowResult,
|
|
296
313
|
FlowStepsEndpoint: () => FlowStepsEndpoint,
|
|
314
|
+
FlowVersionsEndpoint: () => FlowVersionsEndpoint,
|
|
297
315
|
FlowsEndpoint: () => FlowsEndpoint,
|
|
298
316
|
FlowsNamespace: () => FlowsNamespace,
|
|
317
|
+
IntegrationsEndpoint: () => IntegrationsEndpoint,
|
|
318
|
+
LogsEndpoint: () => LogsEndpoint,
|
|
299
319
|
ModelConfigsEndpoint: () => ModelConfigsEndpoint,
|
|
300
320
|
PromptRunner: () => PromptRunner,
|
|
301
321
|
PromptsEndpoint: () => PromptsEndpoint,
|
|
@@ -307,6 +327,9 @@ __export(index_exports, {
|
|
|
307
327
|
RuntypeFlowBuilder: () => RuntypeFlowBuilder,
|
|
308
328
|
STEP_FIELD_REGISTRY: () => STEP_FIELD_REGISTRY,
|
|
309
329
|
STEP_TYPE_TO_METHOD: () => STEP_TYPE_TO_METHOD,
|
|
330
|
+
SchedulesEndpoint: () => SchedulesEndpoint,
|
|
331
|
+
SecretsEndpoint: () => SecretsEndpoint,
|
|
332
|
+
SurfacesEndpoint: () => SurfacesEndpoint,
|
|
310
333
|
ToolsEndpoint: () => ToolsEndpoint,
|
|
311
334
|
UsersEndpoint: () => UsersEndpoint,
|
|
312
335
|
applyGeneratedRuntimeToolProposalToDispatchRequest: () => applyGeneratedRuntimeToolProposalToDispatchRequest,
|
|
@@ -1025,22 +1048,24 @@ var RuntypeFlowBuilder = class {
|
|
|
1025
1048
|
onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
|
|
1026
1049
|
onError: (error) => callbacks?.onError?.(error)
|
|
1027
1050
|
};
|
|
1028
|
-
const { streamEvents: streamEvents2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
1051
|
+
const { streamEvents: streamEvents2, stepDeltaText: stepDeltaText2, stepDisplayName: stepDisplayName2, flowErrorMessage: flowErrorMessage2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
1029
1052
|
try {
|
|
1030
1053
|
for await (const event of streamEvents2(response)) {
|
|
1031
1054
|
const awaitEvent = event;
|
|
1032
1055
|
if (awaitEvent.type === "flow_await") {
|
|
1056
|
+
const prev = pausedState;
|
|
1033
1057
|
pausedState = {
|
|
1034
|
-
toolName: awaitEvent.toolName || "",
|
|
1035
|
-
parameters: awaitEvent.parameters,
|
|
1036
|
-
executionId: awaitEvent.executionId || ""
|
|
1058
|
+
toolName: awaitEvent.toolName || prev?.toolName || "",
|
|
1059
|
+
parameters: awaitEvent.parameters ?? prev?.parameters,
|
|
1060
|
+
executionId: awaitEvent.executionId || prev?.executionId || ""
|
|
1037
1061
|
};
|
|
1038
1062
|
}
|
|
1039
1063
|
if (awaitEvent.type === "step_await") {
|
|
1064
|
+
const prev = pausedState;
|
|
1040
1065
|
pausedState = {
|
|
1041
|
-
toolName: awaitEvent.toolName || "",
|
|
1042
|
-
parameters: awaitEvent.parameters,
|
|
1043
|
-
executionId: awaitEvent.executionId || ""
|
|
1066
|
+
toolName: awaitEvent.toolName || prev?.toolName || "",
|
|
1067
|
+
parameters: awaitEvent.parameters ?? prev?.parameters,
|
|
1068
|
+
executionId: awaitEvent.executionId || prev?.executionId || ""
|
|
1044
1069
|
};
|
|
1045
1070
|
}
|
|
1046
1071
|
switch (event.type) {
|
|
@@ -1051,10 +1076,10 @@ var RuntypeFlowBuilder = class {
|
|
|
1051
1076
|
wrappedCallbacks.onStepStart?.(event);
|
|
1052
1077
|
break;
|
|
1053
1078
|
case "step_delta":
|
|
1054
|
-
wrappedCallbacks.onStepDelta?.(event
|
|
1079
|
+
wrappedCallbacks.onStepDelta?.(stepDeltaText2(event), event);
|
|
1055
1080
|
break;
|
|
1056
1081
|
case "step_complete": {
|
|
1057
|
-
accumulatedSummary.results?.set(event
|
|
1082
|
+
accumulatedSummary.results?.set(stepDisplayName2(event), event.result);
|
|
1058
1083
|
wrappedCallbacks.onStepComplete?.(event.result, event);
|
|
1059
1084
|
break;
|
|
1060
1085
|
}
|
|
@@ -1062,7 +1087,7 @@ var RuntypeFlowBuilder = class {
|
|
|
1062
1087
|
wrappedCallbacks.onFlowComplete?.(event);
|
|
1063
1088
|
break;
|
|
1064
1089
|
case "flow_error":
|
|
1065
|
-
wrappedCallbacks.onError?.(new Error(event
|
|
1090
|
+
wrappedCallbacks.onError?.(new Error(flowErrorMessage2(event)));
|
|
1066
1091
|
break;
|
|
1067
1092
|
}
|
|
1068
1093
|
}
|
|
@@ -7095,6 +7120,363 @@ _AgentsEndpoint.STOP_PHRASES = [
|
|
|
7095
7120
|
"STATUS: COMPLETE"
|
|
7096
7121
|
];
|
|
7097
7122
|
var AgentsEndpoint = _AgentsEndpoint;
|
|
7123
|
+
var SecretsEndpoint = class {
|
|
7124
|
+
constructor(client) {
|
|
7125
|
+
this.client = client;
|
|
7126
|
+
}
|
|
7127
|
+
/**
|
|
7128
|
+
* List all secrets (metadata only) for the authenticated user/org.
|
|
7129
|
+
*/
|
|
7130
|
+
async list() {
|
|
7131
|
+
return this.client.get("/secrets");
|
|
7132
|
+
}
|
|
7133
|
+
/**
|
|
7134
|
+
* Get metadata for a single secret by ID.
|
|
7135
|
+
*/
|
|
7136
|
+
async get(id) {
|
|
7137
|
+
const response = await this.client.get(`/secrets/${id}`);
|
|
7138
|
+
return response.data;
|
|
7139
|
+
}
|
|
7140
|
+
/**
|
|
7141
|
+
* Create a secret. Omitting `value` provisions a key with no value yet
|
|
7142
|
+
* (get-or-create semantics).
|
|
7143
|
+
*/
|
|
7144
|
+
async create(data) {
|
|
7145
|
+
const response = await this.client.post("/secrets", data);
|
|
7146
|
+
return response.data;
|
|
7147
|
+
}
|
|
7148
|
+
/**
|
|
7149
|
+
* Update or rotate a secret. Pass `expectedVersion` for optimistic concurrency.
|
|
7150
|
+
*/
|
|
7151
|
+
async update(id, data) {
|
|
7152
|
+
const response = await this.client.put(`/secrets/${id}`, data);
|
|
7153
|
+
return response.data;
|
|
7154
|
+
}
|
|
7155
|
+
/**
|
|
7156
|
+
* Delete a secret. Returns the number of tool configs that still reference it.
|
|
7157
|
+
*/
|
|
7158
|
+
async delete(id) {
|
|
7159
|
+
return this.client.delete(`/secrets/${id}`);
|
|
7160
|
+
}
|
|
7161
|
+
/**
|
|
7162
|
+
* Check which of the given keys exist, are missing, or are revoked.
|
|
7163
|
+
*/
|
|
7164
|
+
async check(keys) {
|
|
7165
|
+
return this.client.post("/secrets/check", { keys });
|
|
7166
|
+
}
|
|
7167
|
+
/**
|
|
7168
|
+
* Generate a dashboard URL for configuring missing secrets.
|
|
7169
|
+
*/
|
|
7170
|
+
async setupUrl(data) {
|
|
7171
|
+
return this.client.post("/secrets/setup-url", data);
|
|
7172
|
+
}
|
|
7173
|
+
};
|
|
7174
|
+
var SchedulesEndpoint = class {
|
|
7175
|
+
constructor(client) {
|
|
7176
|
+
this.client = client;
|
|
7177
|
+
}
|
|
7178
|
+
/**
|
|
7179
|
+
* List schedules with cursor pagination. Filter by `search` (name) or `status`.
|
|
7180
|
+
*/
|
|
7181
|
+
async list(params) {
|
|
7182
|
+
return this.client.get("/schedules", params);
|
|
7183
|
+
}
|
|
7184
|
+
/**
|
|
7185
|
+
* Get a single schedule by ID.
|
|
7186
|
+
*/
|
|
7187
|
+
async get(id) {
|
|
7188
|
+
return this.client.get(`/schedules/${id}`);
|
|
7189
|
+
}
|
|
7190
|
+
/**
|
|
7191
|
+
* Create a schedule. Provide exactly one of `target.flowId` or `target.agentId`.
|
|
7192
|
+
*/
|
|
7193
|
+
async create(data) {
|
|
7194
|
+
return this.client.post("/schedules", data);
|
|
7195
|
+
}
|
|
7196
|
+
/**
|
|
7197
|
+
* Update a schedule (partial update supported).
|
|
7198
|
+
*/
|
|
7199
|
+
async update(id, data) {
|
|
7200
|
+
return this.client.put(`/schedules/${id}`, data);
|
|
7201
|
+
}
|
|
7202
|
+
/**
|
|
7203
|
+
* Delete a schedule.
|
|
7204
|
+
*/
|
|
7205
|
+
async delete(id) {
|
|
7206
|
+
return this.client.delete(`/schedules/${id}`);
|
|
7207
|
+
}
|
|
7208
|
+
/**
|
|
7209
|
+
* Trigger an immediate execution, bypassing the schedule's normal timing.
|
|
7210
|
+
*/
|
|
7211
|
+
async runNow(id) {
|
|
7212
|
+
return this.client.post(`/schedules/${id}/run-now`);
|
|
7213
|
+
}
|
|
7214
|
+
/**
|
|
7215
|
+
* Pause a schedule (prevents future executions until resumed).
|
|
7216
|
+
*/
|
|
7217
|
+
async pause(id) {
|
|
7218
|
+
return this.client.post(`/schedules/${id}/pause`);
|
|
7219
|
+
}
|
|
7220
|
+
/**
|
|
7221
|
+
* Resume a paused schedule.
|
|
7222
|
+
*/
|
|
7223
|
+
async resume(id) {
|
|
7224
|
+
return this.client.post(`/schedules/${id}/resume`);
|
|
7225
|
+
}
|
|
7226
|
+
/**
|
|
7227
|
+
* List the run history for a specific schedule.
|
|
7228
|
+
*/
|
|
7229
|
+
async listRuns(id) {
|
|
7230
|
+
return this.client.get(`/schedules/${id}/runs`);
|
|
7231
|
+
}
|
|
7232
|
+
/**
|
|
7233
|
+
* Get statistics (success rate, average duration/cost, 7-day history) for a schedule.
|
|
7234
|
+
*/
|
|
7235
|
+
async getStats(id) {
|
|
7236
|
+
return this.client.get(`/schedules/${id}/stats`);
|
|
7237
|
+
}
|
|
7238
|
+
/**
|
|
7239
|
+
* List all runs across every schedule the user owns.
|
|
7240
|
+
*/
|
|
7241
|
+
async listAllRuns(params) {
|
|
7242
|
+
return this.client.get("/schedules/runs/all", params);
|
|
7243
|
+
}
|
|
7244
|
+
};
|
|
7245
|
+
var SurfacesEndpoint = class {
|
|
7246
|
+
constructor(client) {
|
|
7247
|
+
this.client = client;
|
|
7248
|
+
}
|
|
7249
|
+
/**
|
|
7250
|
+
* List surfaces with cursor pagination. Filter by `type`, `status`, or `environment`.
|
|
7251
|
+
*/
|
|
7252
|
+
async list(params) {
|
|
7253
|
+
return this.client.get("/surfaces", params);
|
|
7254
|
+
}
|
|
7255
|
+
};
|
|
7256
|
+
var ConversationsEndpoint = class {
|
|
7257
|
+
constructor(client) {
|
|
7258
|
+
this.client = client;
|
|
7259
|
+
}
|
|
7260
|
+
/**
|
|
7261
|
+
* List conversations. Filter by source, surface, client token, or owner.
|
|
7262
|
+
*
|
|
7263
|
+
* Note: this endpoint returns a bespoke `{ conversations, pagination }`
|
|
7264
|
+
* envelope rather than the standard `{ data, pagination }` shape.
|
|
7265
|
+
*/
|
|
7266
|
+
async list(params) {
|
|
7267
|
+
const query = {};
|
|
7268
|
+
if (params?.source !== void 0) query.source = params.source;
|
|
7269
|
+
if (params?.surfaceId !== void 0) query.surface_id = params.surfaceId;
|
|
7270
|
+
if (params?.clientTokenId !== void 0) query.client_token_id = params.clientTokenId;
|
|
7271
|
+
if (params?.ownerId !== void 0) query.ownerId = params.ownerId;
|
|
7272
|
+
if (params?.limit !== void 0) query.limit = params.limit;
|
|
7273
|
+
if (params?.cursor !== void 0) query.cursor = params.cursor;
|
|
7274
|
+
return this.client.get("/conversations", query);
|
|
7275
|
+
}
|
|
7276
|
+
/**
|
|
7277
|
+
* Get a single conversation (including its messages) by ID.
|
|
7278
|
+
*/
|
|
7279
|
+
async get(id) {
|
|
7280
|
+
return this.client.get(`/conversations/${id}`);
|
|
7281
|
+
}
|
|
7282
|
+
/**
|
|
7283
|
+
* Create a conversation.
|
|
7284
|
+
*/
|
|
7285
|
+
async create(data) {
|
|
7286
|
+
return this.client.post("/conversations", data ?? {});
|
|
7287
|
+
}
|
|
7288
|
+
/**
|
|
7289
|
+
* Update a conversation (title, model, system prompt, owner, metadata, messages).
|
|
7290
|
+
*/
|
|
7291
|
+
async update(id, data) {
|
|
7292
|
+
return this.client.put(`/conversations/${id}`, data);
|
|
7293
|
+
}
|
|
7294
|
+
/**
|
|
7295
|
+
* Delete a conversation.
|
|
7296
|
+
*/
|
|
7297
|
+
async delete(id) {
|
|
7298
|
+
return this.client.delete(`/conversations/${id}`);
|
|
7299
|
+
}
|
|
7300
|
+
};
|
|
7301
|
+
var LogsEndpoint = class {
|
|
7302
|
+
constructor(client) {
|
|
7303
|
+
this.client = client;
|
|
7304
|
+
}
|
|
7305
|
+
/**
|
|
7306
|
+
* Query logs with filtering and cursor pagination. Returns the
|
|
7307
|
+
* `{ success, data: { entries, pagination } }` envelope.
|
|
7308
|
+
*/
|
|
7309
|
+
async list(params) {
|
|
7310
|
+
return this.client.get("/logs", params);
|
|
7311
|
+
}
|
|
7312
|
+
/**
|
|
7313
|
+
* Convenience wrapper around {@link list} that returns just the log entries.
|
|
7314
|
+
*/
|
|
7315
|
+
async listEntries(params) {
|
|
7316
|
+
const response = await this.list(params);
|
|
7317
|
+
return response.data.entries;
|
|
7318
|
+
}
|
|
7319
|
+
/**
|
|
7320
|
+
* Get aggregate log statistics (counts by level/category, time-series histogram).
|
|
7321
|
+
*/
|
|
7322
|
+
async getStats(params) {
|
|
7323
|
+
return this.client.get("/logs/stats", params);
|
|
7324
|
+
}
|
|
7325
|
+
/**
|
|
7326
|
+
* Get the trace tree for a single execution.
|
|
7327
|
+
*/
|
|
7328
|
+
async traceExecution(executionId) {
|
|
7329
|
+
return this.client.get(`/logs/trace/execution/${executionId}`);
|
|
7330
|
+
}
|
|
7331
|
+
/**
|
|
7332
|
+
* Get the trace tree for a conversation (all executions within it).
|
|
7333
|
+
*/
|
|
7334
|
+
async traceConversation(conversationId) {
|
|
7335
|
+
return this.client.get(`/logs/trace/conversation/${conversationId}`);
|
|
7336
|
+
}
|
|
7337
|
+
};
|
|
7338
|
+
var AgentVersionsEndpoint = class {
|
|
7339
|
+
constructor(client) {
|
|
7340
|
+
this.client = client;
|
|
7341
|
+
}
|
|
7342
|
+
/**
|
|
7343
|
+
* List versions for an agent, optionally filtered by version `type`.
|
|
7344
|
+
*/
|
|
7345
|
+
async list(agentId, params) {
|
|
7346
|
+
return this.client.get(`/agent-versions/${agentId}`, params);
|
|
7347
|
+
}
|
|
7348
|
+
/**
|
|
7349
|
+
* Get the published version for an agent.
|
|
7350
|
+
*/
|
|
7351
|
+
async getPublished(agentId) {
|
|
7352
|
+
return this.client.get(`/agent-versions/${agentId}/published`);
|
|
7353
|
+
}
|
|
7354
|
+
/**
|
|
7355
|
+
* Get a specific version of an agent.
|
|
7356
|
+
*/
|
|
7357
|
+
async get(agentId, versionId) {
|
|
7358
|
+
return this.client.get(`/agent-versions/${agentId}/${versionId}`);
|
|
7359
|
+
}
|
|
7360
|
+
/**
|
|
7361
|
+
* Publish a version (promote it to the agent's published version).
|
|
7362
|
+
*/
|
|
7363
|
+
async publish(agentId, versionId) {
|
|
7364
|
+
return this.client.post(`/agent-versions/${agentId}/publish`, {
|
|
7365
|
+
versionId
|
|
7366
|
+
});
|
|
7367
|
+
}
|
|
7368
|
+
};
|
|
7369
|
+
var FlowVersionsEndpoint = class {
|
|
7370
|
+
constructor(client) {
|
|
7371
|
+
this.client = client;
|
|
7372
|
+
}
|
|
7373
|
+
/**
|
|
7374
|
+
* List versions for a flow, optionally filtered by version `type`.
|
|
7375
|
+
*/
|
|
7376
|
+
async list(flowId, params) {
|
|
7377
|
+
return this.client.get(`/flow-versions/${flowId}`, params);
|
|
7378
|
+
}
|
|
7379
|
+
/**
|
|
7380
|
+
* Get the published version for a flow.
|
|
7381
|
+
*/
|
|
7382
|
+
async getPublished(flowId) {
|
|
7383
|
+
return this.client.get(`/flow-versions/${flowId}/published`);
|
|
7384
|
+
}
|
|
7385
|
+
/**
|
|
7386
|
+
* Get a specific version of a flow.
|
|
7387
|
+
*/
|
|
7388
|
+
async get(flowId, versionId) {
|
|
7389
|
+
return this.client.get(`/flow-versions/${flowId}/${versionId}`);
|
|
7390
|
+
}
|
|
7391
|
+
/**
|
|
7392
|
+
* Publish a version (promote it to the flow's published version).
|
|
7393
|
+
*/
|
|
7394
|
+
async publish(flowId, versionId) {
|
|
7395
|
+
return this.client.post(`/flow-versions/${flowId}/publish`, {
|
|
7396
|
+
versionId
|
|
7397
|
+
});
|
|
7398
|
+
}
|
|
7399
|
+
};
|
|
7400
|
+
var IntegrationsEndpoint = class {
|
|
7401
|
+
constructor(client) {
|
|
7402
|
+
this.client = client;
|
|
7403
|
+
}
|
|
7404
|
+
/**
|
|
7405
|
+
* List all integrations with the caller's per-integration configuration status.
|
|
7406
|
+
*/
|
|
7407
|
+
async list(params) {
|
|
7408
|
+
return this.client.get("/integrations", params);
|
|
7409
|
+
}
|
|
7410
|
+
/**
|
|
7411
|
+
* Get a single integration by ID.
|
|
7412
|
+
*/
|
|
7413
|
+
async get(integrationId) {
|
|
7414
|
+
return this.client.get(`/integrations/${integrationId}`);
|
|
7415
|
+
}
|
|
7416
|
+
/**
|
|
7417
|
+
* List integrations within a category (e.g. `slack`, `mcp`).
|
|
7418
|
+
*/
|
|
7419
|
+
async listByCategory(category) {
|
|
7420
|
+
return this.client.get(
|
|
7421
|
+
`/integrations/category/${category}`
|
|
7422
|
+
);
|
|
7423
|
+
}
|
|
7424
|
+
/**
|
|
7425
|
+
* Per-environment credential status across the caller's integrations.
|
|
7426
|
+
*/
|
|
7427
|
+
async getCredentialsStatus() {
|
|
7428
|
+
return this.client.get("/integrations/credentials-status");
|
|
7429
|
+
}
|
|
7430
|
+
/**
|
|
7431
|
+
* List all tools exposed across the caller's configured integrations.
|
|
7432
|
+
*/
|
|
7433
|
+
async listTools() {
|
|
7434
|
+
return this.client.get("/integrations/tools");
|
|
7435
|
+
}
|
|
7436
|
+
/**
|
|
7437
|
+
* List the tools exposed by a single integration.
|
|
7438
|
+
*/
|
|
7439
|
+
async getIntegrationTools(integrationId) {
|
|
7440
|
+
return this.client.get(
|
|
7441
|
+
`/integrations/${integrationId}/tools`
|
|
7442
|
+
);
|
|
7443
|
+
}
|
|
7444
|
+
/**
|
|
7445
|
+
* Get the definition of a single tool within an integration.
|
|
7446
|
+
*/
|
|
7447
|
+
async getTool(integrationId, toolName) {
|
|
7448
|
+
return this.client.get(`/integrations/${integrationId}/tools/${toolName}`);
|
|
7449
|
+
}
|
|
7450
|
+
/**
|
|
7451
|
+
* Install a Slack integration from a completed OAuth handshake.
|
|
7452
|
+
*/
|
|
7453
|
+
async installSlack(data) {
|
|
7454
|
+
return this.client.post("/integrations/slack/install", data);
|
|
7455
|
+
}
|
|
7456
|
+
};
|
|
7457
|
+
var BillingEndpoint = class {
|
|
7458
|
+
constructor(client) {
|
|
7459
|
+
this.client = client;
|
|
7460
|
+
}
|
|
7461
|
+
/**
|
|
7462
|
+
* Get the caller's subscription status, plan limits, and current usage.
|
|
7463
|
+
*/
|
|
7464
|
+
async getStatus() {
|
|
7465
|
+
return this.client.get("/billing/status");
|
|
7466
|
+
}
|
|
7467
|
+
/**
|
|
7468
|
+
* Get the caller's credit grants and available/used totals.
|
|
7469
|
+
*/
|
|
7470
|
+
async getCredits() {
|
|
7471
|
+
return this.client.get("/billing/credits");
|
|
7472
|
+
}
|
|
7473
|
+
/**
|
|
7474
|
+
* Get spend analytics. The window is controlled by `days` (1–365, defaults to 30).
|
|
7475
|
+
*/
|
|
7476
|
+
async getSpendAnalytics(params) {
|
|
7477
|
+
return this.client.get("/billing/spend-analytics", params);
|
|
7478
|
+
}
|
|
7479
|
+
};
|
|
7098
7480
|
|
|
7099
7481
|
// src/flow-builder.ts
|
|
7100
7482
|
init_stream_utils();
|
|
@@ -7824,7 +8206,7 @@ var RuntypeClient2 = class {
|
|
|
7824
8206
|
const baseUrl = config.baseUrl || "https://api.runtype.com";
|
|
7825
8207
|
this.apiVersion = config.apiVersion || "v1";
|
|
7826
8208
|
this.baseUrl = this.apiVersion ? `${baseUrl}/${this.apiVersion}` : baseUrl;
|
|
7827
|
-
this.timeout = config.timeout
|
|
8209
|
+
this.timeout = config.timeout === void 0 ? 3e4 : config.timeout;
|
|
7828
8210
|
this.headers = {
|
|
7829
8211
|
"Content-Type": "application/json",
|
|
7830
8212
|
...config.headers || {}
|
|
@@ -7847,6 +8229,15 @@ var RuntypeClient2 = class {
|
|
|
7847
8229
|
this.eval = new EvalEndpoint(this);
|
|
7848
8230
|
this.clientTokens = new ClientTokensEndpoint(this);
|
|
7849
8231
|
this.agents = new AgentsEndpoint(this);
|
|
8232
|
+
this.secrets = new SecretsEndpoint(this);
|
|
8233
|
+
this.schedules = new SchedulesEndpoint(this);
|
|
8234
|
+
this.surfaces = new SurfacesEndpoint(this);
|
|
8235
|
+
this.conversations = new ConversationsEndpoint(this);
|
|
8236
|
+
this.logs = new LogsEndpoint(this);
|
|
8237
|
+
this.agentVersions = new AgentVersionsEndpoint(this);
|
|
8238
|
+
this.flowVersions = new FlowVersionsEndpoint(this);
|
|
8239
|
+
this.integrations = new IntegrationsEndpoint(this);
|
|
8240
|
+
this.billing = new BillingEndpoint(this);
|
|
7850
8241
|
}
|
|
7851
8242
|
/**
|
|
7852
8243
|
* Set the API key for authentication
|
|
@@ -7888,9 +8279,7 @@ var RuntypeClient2 = class {
|
|
|
7888
8279
|
const options = (isOptionsObject(arg3) ? arg3 : arg4) ?? {};
|
|
7889
8280
|
const scope = options.scope ?? "session";
|
|
7890
8281
|
const isStreaming = !!callbacks;
|
|
7891
|
-
const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter(
|
|
7892
|
-
(entry) => hasToolEntryShape(entry[1])
|
|
7893
|
-
).map(([name, entry]) => ({
|
|
8282
|
+
const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter((entry) => hasToolEntryShape(entry[1])).map(([name, entry]) => ({
|
|
7894
8283
|
name,
|
|
7895
8284
|
description: entry.description,
|
|
7896
8285
|
parametersSchema: entry.parametersSchema,
|
|
@@ -7919,7 +8308,7 @@ var RuntypeClient2 = class {
|
|
|
7919
8308
|
onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
|
|
7920
8309
|
onError: (error) => callbacks?.onError?.(error)
|
|
7921
8310
|
};
|
|
7922
|
-
const { streamEvents: streamEvents2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
8311
|
+
const { streamEvents: streamEvents2, stepDeltaText: stepDeltaText2, stepDisplayName: stepDisplayName2, flowErrorMessage: flowErrorMessage2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
7923
8312
|
const summary = {
|
|
7924
8313
|
results: /* @__PURE__ */ new Map(),
|
|
7925
8314
|
success: true
|
|
@@ -7928,19 +8317,23 @@ var RuntypeClient2 = class {
|
|
|
7928
8317
|
for await (const event of streamEvents2(response)) {
|
|
7929
8318
|
if (event.type === "flow_await") {
|
|
7930
8319
|
const pausedEvent = event;
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
toolName: pausedEvent.toolName,
|
|
7934
|
-
executionId: pausedEvent.executionId
|
|
8320
|
+
const prev = pausedState;
|
|
8321
|
+
const next = {
|
|
8322
|
+
toolName: pausedEvent.toolName ?? prev?.toolName ?? "",
|
|
8323
|
+
executionId: pausedEvent.executionId ?? prev?.executionId ?? "",
|
|
8324
|
+
parameters: prev?.parameters
|
|
7935
8325
|
};
|
|
8326
|
+
pausedState = next;
|
|
7936
8327
|
}
|
|
7937
8328
|
if (event.type === "step_await") {
|
|
7938
8329
|
const pausedEvent = event;
|
|
7939
|
-
|
|
7940
|
-
|
|
8330
|
+
const prev = pausedState;
|
|
8331
|
+
const next = {
|
|
8332
|
+
toolName: typeof pausedEvent.toolName === "string" ? pausedEvent.toolName : prev?.toolName ?? "",
|
|
7941
8333
|
parameters: pausedEvent.parameters,
|
|
7942
|
-
executionId: pausedEvent.executionId
|
|
8334
|
+
executionId: typeof pausedEvent.executionId === "string" ? pausedEvent.executionId : prev?.executionId ?? ""
|
|
7943
8335
|
};
|
|
8336
|
+
pausedState = next;
|
|
7944
8337
|
}
|
|
7945
8338
|
switch (event.type) {
|
|
7946
8339
|
case "flow_start":
|
|
@@ -7950,10 +8343,10 @@ var RuntypeClient2 = class {
|
|
|
7950
8343
|
wrappedCallbacks.onStepStart?.(event);
|
|
7951
8344
|
break;
|
|
7952
8345
|
case "step_delta":
|
|
7953
|
-
wrappedCallbacks.onStepDelta?.(event
|
|
8346
|
+
wrappedCallbacks.onStepDelta?.(stepDeltaText2(event), event);
|
|
7954
8347
|
break;
|
|
7955
8348
|
case "step_complete": {
|
|
7956
|
-
summary.results?.set(event
|
|
8349
|
+
summary.results?.set(stepDisplayName2(event), event.result);
|
|
7957
8350
|
wrappedCallbacks.onStepComplete?.(event.result, event);
|
|
7958
8351
|
break;
|
|
7959
8352
|
}
|
|
@@ -7961,7 +8354,7 @@ var RuntypeClient2 = class {
|
|
|
7961
8354
|
wrappedCallbacks.onFlowComplete?.(event);
|
|
7962
8355
|
break;
|
|
7963
8356
|
case "flow_error":
|
|
7964
|
-
wrappedCallbacks.onError?.(new Error(event
|
|
8357
|
+
wrappedCallbacks.onError?.(new Error(flowErrorMessage2(event)));
|
|
7965
8358
|
break;
|
|
7966
8359
|
}
|
|
7967
8360
|
}
|
|
@@ -8157,14 +8550,14 @@ var RuntypeClient2 = class {
|
|
|
8157
8550
|
* Make HTTP request with timeout and error handling
|
|
8158
8551
|
*/
|
|
8159
8552
|
async makeRequest(url, options) {
|
|
8160
|
-
const controller = new AbortController();
|
|
8161
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
8553
|
+
const controller = this.timeout === null ? null : new AbortController();
|
|
8554
|
+
const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
|
|
8162
8555
|
try {
|
|
8163
8556
|
const response = await fetch(url, {
|
|
8164
8557
|
...options,
|
|
8165
|
-
signal: controller.signal
|
|
8558
|
+
...controller ? { signal: controller.signal } : {}
|
|
8166
8559
|
});
|
|
8167
|
-
clearTimeout(timeoutId);
|
|
8560
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8168
8561
|
if (!response.ok) {
|
|
8169
8562
|
throw await this.createApiError(response);
|
|
8170
8563
|
}
|
|
@@ -8177,8 +8570,8 @@ var RuntypeClient2 = class {
|
|
|
8177
8570
|
}
|
|
8178
8571
|
return response.text();
|
|
8179
8572
|
} catch (error) {
|
|
8180
|
-
clearTimeout(timeoutId);
|
|
8181
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
8573
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8574
|
+
if (timeoutId && error instanceof Error && error.name === "AbortError") {
|
|
8182
8575
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
8183
8576
|
}
|
|
8184
8577
|
throw error;
|
|
@@ -8188,21 +8581,21 @@ var RuntypeClient2 = class {
|
|
|
8188
8581
|
* Make HTTP request that returns raw Response (for streaming)
|
|
8189
8582
|
*/
|
|
8190
8583
|
async makeRawRequest(url, options) {
|
|
8191
|
-
const controller = new AbortController();
|
|
8192
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
8584
|
+
const controller = this.timeout === null ? null : new AbortController();
|
|
8585
|
+
const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
|
|
8193
8586
|
try {
|
|
8194
8587
|
const response = await fetch(url, {
|
|
8195
8588
|
...options,
|
|
8196
|
-
signal: controller.signal
|
|
8589
|
+
...controller ? { signal: controller.signal } : {}
|
|
8197
8590
|
});
|
|
8198
|
-
clearTimeout(timeoutId);
|
|
8591
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8199
8592
|
if (!response.ok) {
|
|
8200
8593
|
throw await this.createApiError(response);
|
|
8201
8594
|
}
|
|
8202
8595
|
return response;
|
|
8203
8596
|
} catch (error) {
|
|
8204
|
-
clearTimeout(timeoutId);
|
|
8205
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
8597
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8598
|
+
if (timeoutId && error instanceof Error && error.name === "AbortError") {
|
|
8206
8599
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
8207
8600
|
}
|
|
8208
8601
|
throw error;
|
|
@@ -8781,17 +9174,20 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
8781
9174
|
};
|
|
8782
9175
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8783
9176
|
0 && (module.exports = {
|
|
9177
|
+
AgentVersionsEndpoint,
|
|
8784
9178
|
AgentsEndpoint,
|
|
8785
9179
|
AnalyticsEndpoint,
|
|
8786
9180
|
ApiKeysEndpoint,
|
|
8787
9181
|
BatchBuilder,
|
|
8788
9182
|
BatchesNamespace,
|
|
9183
|
+
BillingEndpoint,
|
|
8789
9184
|
ChatEndpoint,
|
|
8790
9185
|
ClientBatchBuilder,
|
|
8791
9186
|
ClientEvalBuilder,
|
|
8792
9187
|
ClientFlowBuilder,
|
|
8793
9188
|
ClientTokensEndpoint,
|
|
8794
9189
|
ContextTemplatesEndpoint,
|
|
9190
|
+
ConversationsEndpoint,
|
|
8795
9191
|
DispatchEndpoint,
|
|
8796
9192
|
EvalBuilder,
|
|
8797
9193
|
EvalEndpoint,
|
|
@@ -8800,8 +9196,11 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
8800
9196
|
FlowBuilder,
|
|
8801
9197
|
FlowResult,
|
|
8802
9198
|
FlowStepsEndpoint,
|
|
9199
|
+
FlowVersionsEndpoint,
|
|
8803
9200
|
FlowsEndpoint,
|
|
8804
9201
|
FlowsNamespace,
|
|
9202
|
+
IntegrationsEndpoint,
|
|
9203
|
+
LogsEndpoint,
|
|
8805
9204
|
ModelConfigsEndpoint,
|
|
8806
9205
|
PromptRunner,
|
|
8807
9206
|
PromptsEndpoint,
|
|
@@ -8813,6 +9212,9 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
8813
9212
|
RuntypeFlowBuilder,
|
|
8814
9213
|
STEP_FIELD_REGISTRY,
|
|
8815
9214
|
STEP_TYPE_TO_METHOD,
|
|
9215
|
+
SchedulesEndpoint,
|
|
9216
|
+
SecretsEndpoint,
|
|
9217
|
+
SurfacesEndpoint,
|
|
8816
9218
|
ToolsEndpoint,
|
|
8817
9219
|
UsersEndpoint,
|
|
8818
9220
|
applyGeneratedRuntimeToolProposalToDispatchRequest,
|