@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.mjs
CHANGED
|
@@ -11,9 +11,12 @@ var __export = (target, all) => {
|
|
|
11
11
|
// src/stream-utils.ts
|
|
12
12
|
var stream_utils_exports = {};
|
|
13
13
|
__export(stream_utils_exports, {
|
|
14
|
+
flowErrorMessage: () => flowErrorMessage,
|
|
14
15
|
parseFinalBuffer: () => parseFinalBuffer,
|
|
15
16
|
parseSSEChunk: () => parseSSEChunk,
|
|
16
17
|
processStream: () => processStream,
|
|
18
|
+
stepDeltaText: () => stepDeltaText,
|
|
19
|
+
stepDisplayName: () => stepDisplayName,
|
|
17
20
|
streamEvents: () => streamEvents
|
|
18
21
|
});
|
|
19
22
|
function parseSSEChunk(chunk, buffer) {
|
|
@@ -134,7 +137,7 @@ async function processStream(response, callbacks = {}) {
|
|
|
134
137
|
try {
|
|
135
138
|
const event = JSON.parse(eventStr);
|
|
136
139
|
handleEvent(event, callbacks, results, flowSummary);
|
|
137
|
-
} catch
|
|
140
|
+
} catch {
|
|
138
141
|
console.warn("Failed to parse SSE event:", eventStr);
|
|
139
142
|
}
|
|
140
143
|
}
|
|
@@ -144,7 +147,7 @@ async function processStream(response, callbacks = {}) {
|
|
|
144
147
|
try {
|
|
145
148
|
const event = JSON.parse(finalEvent);
|
|
146
149
|
handleEvent(event, callbacks, results, flowSummary);
|
|
147
|
-
} catch
|
|
150
|
+
} catch {
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
153
|
} catch (error) {
|
|
@@ -166,6 +169,15 @@ async function processStream(response, callbacks = {}) {
|
|
|
166
169
|
success: flowSummary.success ?? true
|
|
167
170
|
};
|
|
168
171
|
}
|
|
172
|
+
function stepDeltaText(event) {
|
|
173
|
+
return event.text ?? event.delta ?? "";
|
|
174
|
+
}
|
|
175
|
+
function stepDisplayName(event) {
|
|
176
|
+
return event.name ?? event.stepName ?? "";
|
|
177
|
+
}
|
|
178
|
+
function flowErrorMessage(event) {
|
|
179
|
+
return typeof event.error === "string" ? event.error : JSON.stringify(event.error);
|
|
180
|
+
}
|
|
169
181
|
function handleEvent(event, callbacks, results, summary) {
|
|
170
182
|
switch (event.type) {
|
|
171
183
|
case "flow_start":
|
|
@@ -178,24 +190,26 @@ function handleEvent(event, callbacks, results, summary) {
|
|
|
178
190
|
callbacks.onStepStart?.(event);
|
|
179
191
|
break;
|
|
180
192
|
case "step_delta":
|
|
181
|
-
callbacks.onStepDelta?.(event
|
|
193
|
+
callbacks.onStepDelta?.(stepDeltaText(event), event);
|
|
182
194
|
break;
|
|
183
|
-
case "step_complete":
|
|
184
|
-
results.set(event
|
|
195
|
+
case "step_complete": {
|
|
196
|
+
results.set(stepDisplayName(event), event.result);
|
|
185
197
|
callbacks.onStepComplete?.(event.result, event);
|
|
186
198
|
break;
|
|
199
|
+
}
|
|
187
200
|
case "flow_complete":
|
|
188
201
|
summary.totalSteps = event.totalSteps;
|
|
189
202
|
summary.successfulSteps = event.successfulSteps;
|
|
190
203
|
summary.failedSteps = event.failedSteps;
|
|
191
204
|
summary.executionTime = event.executionTime;
|
|
192
|
-
summary.success = event.failedSteps === 0;
|
|
205
|
+
summary.success = event.success ?? (event.failedSteps ?? 0) === 0;
|
|
193
206
|
callbacks.onFlowComplete?.(event);
|
|
194
207
|
break;
|
|
195
|
-
case "flow_error":
|
|
208
|
+
case "flow_error": {
|
|
196
209
|
summary.success = false;
|
|
197
|
-
callbacks.onError?.(new Error(event
|
|
210
|
+
callbacks.onError?.(new Error(flowErrorMessage(event)));
|
|
198
211
|
break;
|
|
212
|
+
}
|
|
199
213
|
case "flow_await":
|
|
200
214
|
break;
|
|
201
215
|
case "step_await":
|
|
@@ -953,22 +967,24 @@ var RuntypeFlowBuilder = class {
|
|
|
953
967
|
onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
|
|
954
968
|
onError: (error) => callbacks?.onError?.(error)
|
|
955
969
|
};
|
|
956
|
-
const { streamEvents: streamEvents2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
970
|
+
const { streamEvents: streamEvents2, stepDeltaText: stepDeltaText2, stepDisplayName: stepDisplayName2, flowErrorMessage: flowErrorMessage2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
957
971
|
try {
|
|
958
972
|
for await (const event of streamEvents2(response)) {
|
|
959
973
|
const awaitEvent = event;
|
|
960
974
|
if (awaitEvent.type === "flow_await") {
|
|
975
|
+
const prev = pausedState;
|
|
961
976
|
pausedState = {
|
|
962
|
-
toolName: awaitEvent.toolName || "",
|
|
963
|
-
parameters: awaitEvent.parameters,
|
|
964
|
-
executionId: awaitEvent.executionId || ""
|
|
977
|
+
toolName: awaitEvent.toolName || prev?.toolName || "",
|
|
978
|
+
parameters: awaitEvent.parameters ?? prev?.parameters,
|
|
979
|
+
executionId: awaitEvent.executionId || prev?.executionId || ""
|
|
965
980
|
};
|
|
966
981
|
}
|
|
967
982
|
if (awaitEvent.type === "step_await") {
|
|
983
|
+
const prev = pausedState;
|
|
968
984
|
pausedState = {
|
|
969
|
-
toolName: awaitEvent.toolName || "",
|
|
970
|
-
parameters: awaitEvent.parameters,
|
|
971
|
-
executionId: awaitEvent.executionId || ""
|
|
985
|
+
toolName: awaitEvent.toolName || prev?.toolName || "",
|
|
986
|
+
parameters: awaitEvent.parameters ?? prev?.parameters,
|
|
987
|
+
executionId: awaitEvent.executionId || prev?.executionId || ""
|
|
972
988
|
};
|
|
973
989
|
}
|
|
974
990
|
switch (event.type) {
|
|
@@ -979,10 +995,10 @@ var RuntypeFlowBuilder = class {
|
|
|
979
995
|
wrappedCallbacks.onStepStart?.(event);
|
|
980
996
|
break;
|
|
981
997
|
case "step_delta":
|
|
982
|
-
wrappedCallbacks.onStepDelta?.(event
|
|
998
|
+
wrappedCallbacks.onStepDelta?.(stepDeltaText2(event), event);
|
|
983
999
|
break;
|
|
984
1000
|
case "step_complete": {
|
|
985
|
-
accumulatedSummary.results?.set(event
|
|
1001
|
+
accumulatedSummary.results?.set(stepDisplayName2(event), event.result);
|
|
986
1002
|
wrappedCallbacks.onStepComplete?.(event.result, event);
|
|
987
1003
|
break;
|
|
988
1004
|
}
|
|
@@ -990,7 +1006,7 @@ var RuntypeFlowBuilder = class {
|
|
|
990
1006
|
wrappedCallbacks.onFlowComplete?.(event);
|
|
991
1007
|
break;
|
|
992
1008
|
case "flow_error":
|
|
993
|
-
wrappedCallbacks.onError?.(new Error(event
|
|
1009
|
+
wrappedCallbacks.onError?.(new Error(flowErrorMessage2(event)));
|
|
994
1010
|
break;
|
|
995
1011
|
}
|
|
996
1012
|
}
|
|
@@ -7023,6 +7039,363 @@ _AgentsEndpoint.STOP_PHRASES = [
|
|
|
7023
7039
|
"STATUS: COMPLETE"
|
|
7024
7040
|
];
|
|
7025
7041
|
var AgentsEndpoint = _AgentsEndpoint;
|
|
7042
|
+
var SecretsEndpoint = class {
|
|
7043
|
+
constructor(client) {
|
|
7044
|
+
this.client = client;
|
|
7045
|
+
}
|
|
7046
|
+
/**
|
|
7047
|
+
* List all secrets (metadata only) for the authenticated user/org.
|
|
7048
|
+
*/
|
|
7049
|
+
async list() {
|
|
7050
|
+
return this.client.get("/secrets");
|
|
7051
|
+
}
|
|
7052
|
+
/**
|
|
7053
|
+
* Get metadata for a single secret by ID.
|
|
7054
|
+
*/
|
|
7055
|
+
async get(id) {
|
|
7056
|
+
const response = await this.client.get(`/secrets/${id}`);
|
|
7057
|
+
return response.data;
|
|
7058
|
+
}
|
|
7059
|
+
/**
|
|
7060
|
+
* Create a secret. Omitting `value` provisions a key with no value yet
|
|
7061
|
+
* (get-or-create semantics).
|
|
7062
|
+
*/
|
|
7063
|
+
async create(data) {
|
|
7064
|
+
const response = await this.client.post("/secrets", data);
|
|
7065
|
+
return response.data;
|
|
7066
|
+
}
|
|
7067
|
+
/**
|
|
7068
|
+
* Update or rotate a secret. Pass `expectedVersion` for optimistic concurrency.
|
|
7069
|
+
*/
|
|
7070
|
+
async update(id, data) {
|
|
7071
|
+
const response = await this.client.put(`/secrets/${id}`, data);
|
|
7072
|
+
return response.data;
|
|
7073
|
+
}
|
|
7074
|
+
/**
|
|
7075
|
+
* Delete a secret. Returns the number of tool configs that still reference it.
|
|
7076
|
+
*/
|
|
7077
|
+
async delete(id) {
|
|
7078
|
+
return this.client.delete(`/secrets/${id}`);
|
|
7079
|
+
}
|
|
7080
|
+
/**
|
|
7081
|
+
* Check which of the given keys exist, are missing, or are revoked.
|
|
7082
|
+
*/
|
|
7083
|
+
async check(keys) {
|
|
7084
|
+
return this.client.post("/secrets/check", { keys });
|
|
7085
|
+
}
|
|
7086
|
+
/**
|
|
7087
|
+
* Generate a dashboard URL for configuring missing secrets.
|
|
7088
|
+
*/
|
|
7089
|
+
async setupUrl(data) {
|
|
7090
|
+
return this.client.post("/secrets/setup-url", data);
|
|
7091
|
+
}
|
|
7092
|
+
};
|
|
7093
|
+
var SchedulesEndpoint = class {
|
|
7094
|
+
constructor(client) {
|
|
7095
|
+
this.client = client;
|
|
7096
|
+
}
|
|
7097
|
+
/**
|
|
7098
|
+
* List schedules with cursor pagination. Filter by `search` (name) or `status`.
|
|
7099
|
+
*/
|
|
7100
|
+
async list(params) {
|
|
7101
|
+
return this.client.get("/schedules", params);
|
|
7102
|
+
}
|
|
7103
|
+
/**
|
|
7104
|
+
* Get a single schedule by ID.
|
|
7105
|
+
*/
|
|
7106
|
+
async get(id) {
|
|
7107
|
+
return this.client.get(`/schedules/${id}`);
|
|
7108
|
+
}
|
|
7109
|
+
/**
|
|
7110
|
+
* Create a schedule. Provide exactly one of `target.flowId` or `target.agentId`.
|
|
7111
|
+
*/
|
|
7112
|
+
async create(data) {
|
|
7113
|
+
return this.client.post("/schedules", data);
|
|
7114
|
+
}
|
|
7115
|
+
/**
|
|
7116
|
+
* Update a schedule (partial update supported).
|
|
7117
|
+
*/
|
|
7118
|
+
async update(id, data) {
|
|
7119
|
+
return this.client.put(`/schedules/${id}`, data);
|
|
7120
|
+
}
|
|
7121
|
+
/**
|
|
7122
|
+
* Delete a schedule.
|
|
7123
|
+
*/
|
|
7124
|
+
async delete(id) {
|
|
7125
|
+
return this.client.delete(`/schedules/${id}`);
|
|
7126
|
+
}
|
|
7127
|
+
/**
|
|
7128
|
+
* Trigger an immediate execution, bypassing the schedule's normal timing.
|
|
7129
|
+
*/
|
|
7130
|
+
async runNow(id) {
|
|
7131
|
+
return this.client.post(`/schedules/${id}/run-now`);
|
|
7132
|
+
}
|
|
7133
|
+
/**
|
|
7134
|
+
* Pause a schedule (prevents future executions until resumed).
|
|
7135
|
+
*/
|
|
7136
|
+
async pause(id) {
|
|
7137
|
+
return this.client.post(`/schedules/${id}/pause`);
|
|
7138
|
+
}
|
|
7139
|
+
/**
|
|
7140
|
+
* Resume a paused schedule.
|
|
7141
|
+
*/
|
|
7142
|
+
async resume(id) {
|
|
7143
|
+
return this.client.post(`/schedules/${id}/resume`);
|
|
7144
|
+
}
|
|
7145
|
+
/**
|
|
7146
|
+
* List the run history for a specific schedule.
|
|
7147
|
+
*/
|
|
7148
|
+
async listRuns(id) {
|
|
7149
|
+
return this.client.get(`/schedules/${id}/runs`);
|
|
7150
|
+
}
|
|
7151
|
+
/**
|
|
7152
|
+
* Get statistics (success rate, average duration/cost, 7-day history) for a schedule.
|
|
7153
|
+
*/
|
|
7154
|
+
async getStats(id) {
|
|
7155
|
+
return this.client.get(`/schedules/${id}/stats`);
|
|
7156
|
+
}
|
|
7157
|
+
/**
|
|
7158
|
+
* List all runs across every schedule the user owns.
|
|
7159
|
+
*/
|
|
7160
|
+
async listAllRuns(params) {
|
|
7161
|
+
return this.client.get("/schedules/runs/all", params);
|
|
7162
|
+
}
|
|
7163
|
+
};
|
|
7164
|
+
var SurfacesEndpoint = class {
|
|
7165
|
+
constructor(client) {
|
|
7166
|
+
this.client = client;
|
|
7167
|
+
}
|
|
7168
|
+
/**
|
|
7169
|
+
* List surfaces with cursor pagination. Filter by `type`, `status`, or `environment`.
|
|
7170
|
+
*/
|
|
7171
|
+
async list(params) {
|
|
7172
|
+
return this.client.get("/surfaces", params);
|
|
7173
|
+
}
|
|
7174
|
+
};
|
|
7175
|
+
var ConversationsEndpoint = class {
|
|
7176
|
+
constructor(client) {
|
|
7177
|
+
this.client = client;
|
|
7178
|
+
}
|
|
7179
|
+
/**
|
|
7180
|
+
* List conversations. Filter by source, surface, client token, or owner.
|
|
7181
|
+
*
|
|
7182
|
+
* Note: this endpoint returns a bespoke `{ conversations, pagination }`
|
|
7183
|
+
* envelope rather than the standard `{ data, pagination }` shape.
|
|
7184
|
+
*/
|
|
7185
|
+
async list(params) {
|
|
7186
|
+
const query = {};
|
|
7187
|
+
if (params?.source !== void 0) query.source = params.source;
|
|
7188
|
+
if (params?.surfaceId !== void 0) query.surface_id = params.surfaceId;
|
|
7189
|
+
if (params?.clientTokenId !== void 0) query.client_token_id = params.clientTokenId;
|
|
7190
|
+
if (params?.ownerId !== void 0) query.ownerId = params.ownerId;
|
|
7191
|
+
if (params?.limit !== void 0) query.limit = params.limit;
|
|
7192
|
+
if (params?.cursor !== void 0) query.cursor = params.cursor;
|
|
7193
|
+
return this.client.get("/conversations", query);
|
|
7194
|
+
}
|
|
7195
|
+
/**
|
|
7196
|
+
* Get a single conversation (including its messages) by ID.
|
|
7197
|
+
*/
|
|
7198
|
+
async get(id) {
|
|
7199
|
+
return this.client.get(`/conversations/${id}`);
|
|
7200
|
+
}
|
|
7201
|
+
/**
|
|
7202
|
+
* Create a conversation.
|
|
7203
|
+
*/
|
|
7204
|
+
async create(data) {
|
|
7205
|
+
return this.client.post("/conversations", data ?? {});
|
|
7206
|
+
}
|
|
7207
|
+
/**
|
|
7208
|
+
* Update a conversation (title, model, system prompt, owner, metadata, messages).
|
|
7209
|
+
*/
|
|
7210
|
+
async update(id, data) {
|
|
7211
|
+
return this.client.put(`/conversations/${id}`, data);
|
|
7212
|
+
}
|
|
7213
|
+
/**
|
|
7214
|
+
* Delete a conversation.
|
|
7215
|
+
*/
|
|
7216
|
+
async delete(id) {
|
|
7217
|
+
return this.client.delete(`/conversations/${id}`);
|
|
7218
|
+
}
|
|
7219
|
+
};
|
|
7220
|
+
var LogsEndpoint = class {
|
|
7221
|
+
constructor(client) {
|
|
7222
|
+
this.client = client;
|
|
7223
|
+
}
|
|
7224
|
+
/**
|
|
7225
|
+
* Query logs with filtering and cursor pagination. Returns the
|
|
7226
|
+
* `{ success, data: { entries, pagination } }` envelope.
|
|
7227
|
+
*/
|
|
7228
|
+
async list(params) {
|
|
7229
|
+
return this.client.get("/logs", params);
|
|
7230
|
+
}
|
|
7231
|
+
/**
|
|
7232
|
+
* Convenience wrapper around {@link list} that returns just the log entries.
|
|
7233
|
+
*/
|
|
7234
|
+
async listEntries(params) {
|
|
7235
|
+
const response = await this.list(params);
|
|
7236
|
+
return response.data.entries;
|
|
7237
|
+
}
|
|
7238
|
+
/**
|
|
7239
|
+
* Get aggregate log statistics (counts by level/category, time-series histogram).
|
|
7240
|
+
*/
|
|
7241
|
+
async getStats(params) {
|
|
7242
|
+
return this.client.get("/logs/stats", params);
|
|
7243
|
+
}
|
|
7244
|
+
/**
|
|
7245
|
+
* Get the trace tree for a single execution.
|
|
7246
|
+
*/
|
|
7247
|
+
async traceExecution(executionId) {
|
|
7248
|
+
return this.client.get(`/logs/trace/execution/${executionId}`);
|
|
7249
|
+
}
|
|
7250
|
+
/**
|
|
7251
|
+
* Get the trace tree for a conversation (all executions within it).
|
|
7252
|
+
*/
|
|
7253
|
+
async traceConversation(conversationId) {
|
|
7254
|
+
return this.client.get(`/logs/trace/conversation/${conversationId}`);
|
|
7255
|
+
}
|
|
7256
|
+
};
|
|
7257
|
+
var AgentVersionsEndpoint = class {
|
|
7258
|
+
constructor(client) {
|
|
7259
|
+
this.client = client;
|
|
7260
|
+
}
|
|
7261
|
+
/**
|
|
7262
|
+
* List versions for an agent, optionally filtered by version `type`.
|
|
7263
|
+
*/
|
|
7264
|
+
async list(agentId, params) {
|
|
7265
|
+
return this.client.get(`/agent-versions/${agentId}`, params);
|
|
7266
|
+
}
|
|
7267
|
+
/**
|
|
7268
|
+
* Get the published version for an agent.
|
|
7269
|
+
*/
|
|
7270
|
+
async getPublished(agentId) {
|
|
7271
|
+
return this.client.get(`/agent-versions/${agentId}/published`);
|
|
7272
|
+
}
|
|
7273
|
+
/**
|
|
7274
|
+
* Get a specific version of an agent.
|
|
7275
|
+
*/
|
|
7276
|
+
async get(agentId, versionId) {
|
|
7277
|
+
return this.client.get(`/agent-versions/${agentId}/${versionId}`);
|
|
7278
|
+
}
|
|
7279
|
+
/**
|
|
7280
|
+
* Publish a version (promote it to the agent's published version).
|
|
7281
|
+
*/
|
|
7282
|
+
async publish(agentId, versionId) {
|
|
7283
|
+
return this.client.post(`/agent-versions/${agentId}/publish`, {
|
|
7284
|
+
versionId
|
|
7285
|
+
});
|
|
7286
|
+
}
|
|
7287
|
+
};
|
|
7288
|
+
var FlowVersionsEndpoint = class {
|
|
7289
|
+
constructor(client) {
|
|
7290
|
+
this.client = client;
|
|
7291
|
+
}
|
|
7292
|
+
/**
|
|
7293
|
+
* List versions for a flow, optionally filtered by version `type`.
|
|
7294
|
+
*/
|
|
7295
|
+
async list(flowId, params) {
|
|
7296
|
+
return this.client.get(`/flow-versions/${flowId}`, params);
|
|
7297
|
+
}
|
|
7298
|
+
/**
|
|
7299
|
+
* Get the published version for a flow.
|
|
7300
|
+
*/
|
|
7301
|
+
async getPublished(flowId) {
|
|
7302
|
+
return this.client.get(`/flow-versions/${flowId}/published`);
|
|
7303
|
+
}
|
|
7304
|
+
/**
|
|
7305
|
+
* Get a specific version of a flow.
|
|
7306
|
+
*/
|
|
7307
|
+
async get(flowId, versionId) {
|
|
7308
|
+
return this.client.get(`/flow-versions/${flowId}/${versionId}`);
|
|
7309
|
+
}
|
|
7310
|
+
/**
|
|
7311
|
+
* Publish a version (promote it to the flow's published version).
|
|
7312
|
+
*/
|
|
7313
|
+
async publish(flowId, versionId) {
|
|
7314
|
+
return this.client.post(`/flow-versions/${flowId}/publish`, {
|
|
7315
|
+
versionId
|
|
7316
|
+
});
|
|
7317
|
+
}
|
|
7318
|
+
};
|
|
7319
|
+
var IntegrationsEndpoint = class {
|
|
7320
|
+
constructor(client) {
|
|
7321
|
+
this.client = client;
|
|
7322
|
+
}
|
|
7323
|
+
/**
|
|
7324
|
+
* List all integrations with the caller's per-integration configuration status.
|
|
7325
|
+
*/
|
|
7326
|
+
async list(params) {
|
|
7327
|
+
return this.client.get("/integrations", params);
|
|
7328
|
+
}
|
|
7329
|
+
/**
|
|
7330
|
+
* Get a single integration by ID.
|
|
7331
|
+
*/
|
|
7332
|
+
async get(integrationId) {
|
|
7333
|
+
return this.client.get(`/integrations/${integrationId}`);
|
|
7334
|
+
}
|
|
7335
|
+
/**
|
|
7336
|
+
* List integrations within a category (e.g. `slack`, `mcp`).
|
|
7337
|
+
*/
|
|
7338
|
+
async listByCategory(category) {
|
|
7339
|
+
return this.client.get(
|
|
7340
|
+
`/integrations/category/${category}`
|
|
7341
|
+
);
|
|
7342
|
+
}
|
|
7343
|
+
/**
|
|
7344
|
+
* Per-environment credential status across the caller's integrations.
|
|
7345
|
+
*/
|
|
7346
|
+
async getCredentialsStatus() {
|
|
7347
|
+
return this.client.get("/integrations/credentials-status");
|
|
7348
|
+
}
|
|
7349
|
+
/**
|
|
7350
|
+
* List all tools exposed across the caller's configured integrations.
|
|
7351
|
+
*/
|
|
7352
|
+
async listTools() {
|
|
7353
|
+
return this.client.get("/integrations/tools");
|
|
7354
|
+
}
|
|
7355
|
+
/**
|
|
7356
|
+
* List the tools exposed by a single integration.
|
|
7357
|
+
*/
|
|
7358
|
+
async getIntegrationTools(integrationId) {
|
|
7359
|
+
return this.client.get(
|
|
7360
|
+
`/integrations/${integrationId}/tools`
|
|
7361
|
+
);
|
|
7362
|
+
}
|
|
7363
|
+
/**
|
|
7364
|
+
* Get the definition of a single tool within an integration.
|
|
7365
|
+
*/
|
|
7366
|
+
async getTool(integrationId, toolName) {
|
|
7367
|
+
return this.client.get(`/integrations/${integrationId}/tools/${toolName}`);
|
|
7368
|
+
}
|
|
7369
|
+
/**
|
|
7370
|
+
* Install a Slack integration from a completed OAuth handshake.
|
|
7371
|
+
*/
|
|
7372
|
+
async installSlack(data) {
|
|
7373
|
+
return this.client.post("/integrations/slack/install", data);
|
|
7374
|
+
}
|
|
7375
|
+
};
|
|
7376
|
+
var BillingEndpoint = class {
|
|
7377
|
+
constructor(client) {
|
|
7378
|
+
this.client = client;
|
|
7379
|
+
}
|
|
7380
|
+
/**
|
|
7381
|
+
* Get the caller's subscription status, plan limits, and current usage.
|
|
7382
|
+
*/
|
|
7383
|
+
async getStatus() {
|
|
7384
|
+
return this.client.get("/billing/status");
|
|
7385
|
+
}
|
|
7386
|
+
/**
|
|
7387
|
+
* Get the caller's credit grants and available/used totals.
|
|
7388
|
+
*/
|
|
7389
|
+
async getCredits() {
|
|
7390
|
+
return this.client.get("/billing/credits");
|
|
7391
|
+
}
|
|
7392
|
+
/**
|
|
7393
|
+
* Get spend analytics. The window is controlled by `days` (1–365, defaults to 30).
|
|
7394
|
+
*/
|
|
7395
|
+
async getSpendAnalytics(params) {
|
|
7396
|
+
return this.client.get("/billing/spend-analytics", params);
|
|
7397
|
+
}
|
|
7398
|
+
};
|
|
7026
7399
|
|
|
7027
7400
|
// src/flow-builder.ts
|
|
7028
7401
|
init_stream_utils();
|
|
@@ -7752,7 +8125,7 @@ var RuntypeClient2 = class {
|
|
|
7752
8125
|
const baseUrl = config.baseUrl || "https://api.runtype.com";
|
|
7753
8126
|
this.apiVersion = config.apiVersion || "v1";
|
|
7754
8127
|
this.baseUrl = this.apiVersion ? `${baseUrl}/${this.apiVersion}` : baseUrl;
|
|
7755
|
-
this.timeout = config.timeout
|
|
8128
|
+
this.timeout = config.timeout === void 0 ? 3e4 : config.timeout;
|
|
7756
8129
|
this.headers = {
|
|
7757
8130
|
"Content-Type": "application/json",
|
|
7758
8131
|
...config.headers || {}
|
|
@@ -7775,6 +8148,15 @@ var RuntypeClient2 = class {
|
|
|
7775
8148
|
this.eval = new EvalEndpoint(this);
|
|
7776
8149
|
this.clientTokens = new ClientTokensEndpoint(this);
|
|
7777
8150
|
this.agents = new AgentsEndpoint(this);
|
|
8151
|
+
this.secrets = new SecretsEndpoint(this);
|
|
8152
|
+
this.schedules = new SchedulesEndpoint(this);
|
|
8153
|
+
this.surfaces = new SurfacesEndpoint(this);
|
|
8154
|
+
this.conversations = new ConversationsEndpoint(this);
|
|
8155
|
+
this.logs = new LogsEndpoint(this);
|
|
8156
|
+
this.agentVersions = new AgentVersionsEndpoint(this);
|
|
8157
|
+
this.flowVersions = new FlowVersionsEndpoint(this);
|
|
8158
|
+
this.integrations = new IntegrationsEndpoint(this);
|
|
8159
|
+
this.billing = new BillingEndpoint(this);
|
|
7778
8160
|
}
|
|
7779
8161
|
/**
|
|
7780
8162
|
* Set the API key for authentication
|
|
@@ -7816,9 +8198,7 @@ var RuntypeClient2 = class {
|
|
|
7816
8198
|
const options = (isOptionsObject(arg3) ? arg3 : arg4) ?? {};
|
|
7817
8199
|
const scope = options.scope ?? "session";
|
|
7818
8200
|
const isStreaming = !!callbacks;
|
|
7819
|
-
const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter(
|
|
7820
|
-
(entry) => hasToolEntryShape(entry[1])
|
|
7821
|
-
).map(([name, entry]) => ({
|
|
8201
|
+
const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter((entry) => hasToolEntryShape(entry[1])).map(([name, entry]) => ({
|
|
7822
8202
|
name,
|
|
7823
8203
|
description: entry.description,
|
|
7824
8204
|
parametersSchema: entry.parametersSchema,
|
|
@@ -7847,7 +8227,7 @@ var RuntypeClient2 = class {
|
|
|
7847
8227
|
onFlowComplete: (event) => callbacks?.onFlowComplete?.(event),
|
|
7848
8228
|
onError: (error) => callbacks?.onError?.(error)
|
|
7849
8229
|
};
|
|
7850
|
-
const { streamEvents: streamEvents2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
8230
|
+
const { streamEvents: streamEvents2, stepDeltaText: stepDeltaText2, stepDisplayName: stepDisplayName2, flowErrorMessage: flowErrorMessage2 } = await Promise.resolve().then(() => (init_stream_utils(), stream_utils_exports));
|
|
7851
8231
|
const summary = {
|
|
7852
8232
|
results: /* @__PURE__ */ new Map(),
|
|
7853
8233
|
success: true
|
|
@@ -7856,19 +8236,23 @@ var RuntypeClient2 = class {
|
|
|
7856
8236
|
for await (const event of streamEvents2(response)) {
|
|
7857
8237
|
if (event.type === "flow_await") {
|
|
7858
8238
|
const pausedEvent = event;
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
toolName: pausedEvent.toolName,
|
|
7862
|
-
executionId: pausedEvent.executionId
|
|
8239
|
+
const prev = pausedState;
|
|
8240
|
+
const next = {
|
|
8241
|
+
toolName: pausedEvent.toolName ?? prev?.toolName ?? "",
|
|
8242
|
+
executionId: pausedEvent.executionId ?? prev?.executionId ?? "",
|
|
8243
|
+
parameters: prev?.parameters
|
|
7863
8244
|
};
|
|
8245
|
+
pausedState = next;
|
|
7864
8246
|
}
|
|
7865
8247
|
if (event.type === "step_await") {
|
|
7866
8248
|
const pausedEvent = event;
|
|
7867
|
-
|
|
7868
|
-
|
|
8249
|
+
const prev = pausedState;
|
|
8250
|
+
const next = {
|
|
8251
|
+
toolName: typeof pausedEvent.toolName === "string" ? pausedEvent.toolName : prev?.toolName ?? "",
|
|
7869
8252
|
parameters: pausedEvent.parameters,
|
|
7870
|
-
executionId: pausedEvent.executionId
|
|
8253
|
+
executionId: typeof pausedEvent.executionId === "string" ? pausedEvent.executionId : prev?.executionId ?? ""
|
|
7871
8254
|
};
|
|
8255
|
+
pausedState = next;
|
|
7872
8256
|
}
|
|
7873
8257
|
switch (event.type) {
|
|
7874
8258
|
case "flow_start":
|
|
@@ -7878,10 +8262,10 @@ var RuntypeClient2 = class {
|
|
|
7878
8262
|
wrappedCallbacks.onStepStart?.(event);
|
|
7879
8263
|
break;
|
|
7880
8264
|
case "step_delta":
|
|
7881
|
-
wrappedCallbacks.onStepDelta?.(event
|
|
8265
|
+
wrappedCallbacks.onStepDelta?.(stepDeltaText2(event), event);
|
|
7882
8266
|
break;
|
|
7883
8267
|
case "step_complete": {
|
|
7884
|
-
summary.results?.set(event
|
|
8268
|
+
summary.results?.set(stepDisplayName2(event), event.result);
|
|
7885
8269
|
wrappedCallbacks.onStepComplete?.(event.result, event);
|
|
7886
8270
|
break;
|
|
7887
8271
|
}
|
|
@@ -7889,7 +8273,7 @@ var RuntypeClient2 = class {
|
|
|
7889
8273
|
wrappedCallbacks.onFlowComplete?.(event);
|
|
7890
8274
|
break;
|
|
7891
8275
|
case "flow_error":
|
|
7892
|
-
wrappedCallbacks.onError?.(new Error(event
|
|
8276
|
+
wrappedCallbacks.onError?.(new Error(flowErrorMessage2(event)));
|
|
7893
8277
|
break;
|
|
7894
8278
|
}
|
|
7895
8279
|
}
|
|
@@ -8085,14 +8469,14 @@ var RuntypeClient2 = class {
|
|
|
8085
8469
|
* Make HTTP request with timeout and error handling
|
|
8086
8470
|
*/
|
|
8087
8471
|
async makeRequest(url, options) {
|
|
8088
|
-
const controller = new AbortController();
|
|
8089
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
8472
|
+
const controller = this.timeout === null ? null : new AbortController();
|
|
8473
|
+
const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
|
|
8090
8474
|
try {
|
|
8091
8475
|
const response = await fetch(url, {
|
|
8092
8476
|
...options,
|
|
8093
|
-
signal: controller.signal
|
|
8477
|
+
...controller ? { signal: controller.signal } : {}
|
|
8094
8478
|
});
|
|
8095
|
-
clearTimeout(timeoutId);
|
|
8479
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8096
8480
|
if (!response.ok) {
|
|
8097
8481
|
throw await this.createApiError(response);
|
|
8098
8482
|
}
|
|
@@ -8105,8 +8489,8 @@ var RuntypeClient2 = class {
|
|
|
8105
8489
|
}
|
|
8106
8490
|
return response.text();
|
|
8107
8491
|
} catch (error) {
|
|
8108
|
-
clearTimeout(timeoutId);
|
|
8109
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
8492
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8493
|
+
if (timeoutId && error instanceof Error && error.name === "AbortError") {
|
|
8110
8494
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
8111
8495
|
}
|
|
8112
8496
|
throw error;
|
|
@@ -8116,21 +8500,21 @@ var RuntypeClient2 = class {
|
|
|
8116
8500
|
* Make HTTP request that returns raw Response (for streaming)
|
|
8117
8501
|
*/
|
|
8118
8502
|
async makeRawRequest(url, options) {
|
|
8119
|
-
const controller = new AbortController();
|
|
8120
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
8503
|
+
const controller = this.timeout === null ? null : new AbortController();
|
|
8504
|
+
const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
|
|
8121
8505
|
try {
|
|
8122
8506
|
const response = await fetch(url, {
|
|
8123
8507
|
...options,
|
|
8124
|
-
signal: controller.signal
|
|
8508
|
+
...controller ? { signal: controller.signal } : {}
|
|
8125
8509
|
});
|
|
8126
|
-
clearTimeout(timeoutId);
|
|
8510
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8127
8511
|
if (!response.ok) {
|
|
8128
8512
|
throw await this.createApiError(response);
|
|
8129
8513
|
}
|
|
8130
8514
|
return response;
|
|
8131
8515
|
} catch (error) {
|
|
8132
|
-
clearTimeout(timeoutId);
|
|
8133
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
8516
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
8517
|
+
if (timeoutId && error instanceof Error && error.name === "AbortError") {
|
|
8134
8518
|
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
8135
8519
|
}
|
|
8136
8520
|
throw error;
|
|
@@ -8708,17 +9092,20 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
8708
9092
|
"generate-pdf": "generatePdf"
|
|
8709
9093
|
};
|
|
8710
9094
|
export {
|
|
9095
|
+
AgentVersionsEndpoint,
|
|
8711
9096
|
AgentsEndpoint,
|
|
8712
9097
|
AnalyticsEndpoint,
|
|
8713
9098
|
ApiKeysEndpoint,
|
|
8714
9099
|
BatchBuilder,
|
|
8715
9100
|
BatchesNamespace,
|
|
9101
|
+
BillingEndpoint,
|
|
8716
9102
|
ChatEndpoint,
|
|
8717
9103
|
ClientBatchBuilder,
|
|
8718
9104
|
ClientEvalBuilder,
|
|
8719
9105
|
ClientFlowBuilder,
|
|
8720
9106
|
ClientTokensEndpoint,
|
|
8721
9107
|
ContextTemplatesEndpoint,
|
|
9108
|
+
ConversationsEndpoint,
|
|
8722
9109
|
DispatchEndpoint,
|
|
8723
9110
|
EvalBuilder,
|
|
8724
9111
|
EvalEndpoint,
|
|
@@ -8727,8 +9114,11 @@ export {
|
|
|
8727
9114
|
FlowBuilder,
|
|
8728
9115
|
FlowResult,
|
|
8729
9116
|
FlowStepsEndpoint,
|
|
9117
|
+
FlowVersionsEndpoint,
|
|
8730
9118
|
FlowsEndpoint,
|
|
8731
9119
|
FlowsNamespace,
|
|
9120
|
+
IntegrationsEndpoint,
|
|
9121
|
+
LogsEndpoint,
|
|
8732
9122
|
ModelConfigsEndpoint,
|
|
8733
9123
|
PromptRunner,
|
|
8734
9124
|
PromptsEndpoint,
|
|
@@ -8740,6 +9130,9 @@ export {
|
|
|
8740
9130
|
RuntypeFlowBuilder,
|
|
8741
9131
|
STEP_FIELD_REGISTRY,
|
|
8742
9132
|
STEP_TYPE_TO_METHOD,
|
|
9133
|
+
SchedulesEndpoint,
|
|
9134
|
+
SecretsEndpoint,
|
|
9135
|
+
SurfacesEndpoint,
|
|
8743
9136
|
ToolsEndpoint,
|
|
8744
9137
|
UsersEndpoint,
|
|
8745
9138
|
applyGeneratedRuntimeToolProposalToDispatchRequest,
|