@runtypelabs/sdk 2.1.1 → 2.2.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 CHANGED
@@ -275,17 +275,20 @@ var init_stream_utils = __esm({
275
275
  // src/index.ts
276
276
  var index_exports = {};
277
277
  __export(index_exports, {
278
+ AgentVersionsEndpoint: () => AgentVersionsEndpoint,
278
279
  AgentsEndpoint: () => AgentsEndpoint,
279
280
  AnalyticsEndpoint: () => AnalyticsEndpoint,
280
281
  ApiKeysEndpoint: () => ApiKeysEndpoint,
281
282
  BatchBuilder: () => BatchBuilder,
282
283
  BatchesNamespace: () => BatchesNamespace,
284
+ BillingEndpoint: () => BillingEndpoint,
283
285
  ChatEndpoint: () => ChatEndpoint,
284
286
  ClientBatchBuilder: () => ClientBatchBuilder,
285
287
  ClientEvalBuilder: () => ClientEvalBuilder,
286
288
  ClientFlowBuilder: () => ClientFlowBuilder,
287
289
  ClientTokensEndpoint: () => ClientTokensEndpoint,
288
290
  ContextTemplatesEndpoint: () => ContextTemplatesEndpoint,
291
+ ConversationsEndpoint: () => ConversationsEndpoint,
289
292
  DispatchEndpoint: () => DispatchEndpoint,
290
293
  EvalBuilder: () => EvalBuilder,
291
294
  EvalEndpoint: () => EvalEndpoint,
@@ -294,8 +297,11 @@ __export(index_exports, {
294
297
  FlowBuilder: () => FlowBuilder,
295
298
  FlowResult: () => FlowResult,
296
299
  FlowStepsEndpoint: () => FlowStepsEndpoint,
300
+ FlowVersionsEndpoint: () => FlowVersionsEndpoint,
297
301
  FlowsEndpoint: () => FlowsEndpoint,
298
302
  FlowsNamespace: () => FlowsNamespace,
303
+ IntegrationsEndpoint: () => IntegrationsEndpoint,
304
+ LogsEndpoint: () => LogsEndpoint,
299
305
  ModelConfigsEndpoint: () => ModelConfigsEndpoint,
300
306
  PromptRunner: () => PromptRunner,
301
307
  PromptsEndpoint: () => PromptsEndpoint,
@@ -307,6 +313,9 @@ __export(index_exports, {
307
313
  RuntypeFlowBuilder: () => RuntypeFlowBuilder,
308
314
  STEP_FIELD_REGISTRY: () => STEP_FIELD_REGISTRY,
309
315
  STEP_TYPE_TO_METHOD: () => STEP_TYPE_TO_METHOD,
316
+ SchedulesEndpoint: () => SchedulesEndpoint,
317
+ SecretsEndpoint: () => SecretsEndpoint,
318
+ SurfacesEndpoint: () => SurfacesEndpoint,
310
319
  ToolsEndpoint: () => ToolsEndpoint,
311
320
  UsersEndpoint: () => UsersEndpoint,
312
321
  applyGeneratedRuntimeToolProposalToDispatchRequest: () => applyGeneratedRuntimeToolProposalToDispatchRequest,
@@ -7095,6 +7104,363 @@ _AgentsEndpoint.STOP_PHRASES = [
7095
7104
  "STATUS: COMPLETE"
7096
7105
  ];
7097
7106
  var AgentsEndpoint = _AgentsEndpoint;
7107
+ var SecretsEndpoint = class {
7108
+ constructor(client) {
7109
+ this.client = client;
7110
+ }
7111
+ /**
7112
+ * List all secrets (metadata only) for the authenticated user/org.
7113
+ */
7114
+ async list() {
7115
+ return this.client.get("/secrets");
7116
+ }
7117
+ /**
7118
+ * Get metadata for a single secret by ID.
7119
+ */
7120
+ async get(id) {
7121
+ const response = await this.client.get(`/secrets/${id}`);
7122
+ return response.data;
7123
+ }
7124
+ /**
7125
+ * Create a secret. Omitting `value` provisions a key with no value yet
7126
+ * (get-or-create semantics).
7127
+ */
7128
+ async create(data) {
7129
+ const response = await this.client.post("/secrets", data);
7130
+ return response.data;
7131
+ }
7132
+ /**
7133
+ * Update or rotate a secret. Pass `expectedVersion` for optimistic concurrency.
7134
+ */
7135
+ async update(id, data) {
7136
+ const response = await this.client.put(`/secrets/${id}`, data);
7137
+ return response.data;
7138
+ }
7139
+ /**
7140
+ * Delete a secret. Returns the number of tool configs that still reference it.
7141
+ */
7142
+ async delete(id) {
7143
+ return this.client.delete(`/secrets/${id}`);
7144
+ }
7145
+ /**
7146
+ * Check which of the given keys exist, are missing, or are revoked.
7147
+ */
7148
+ async check(keys) {
7149
+ return this.client.post("/secrets/check", { keys });
7150
+ }
7151
+ /**
7152
+ * Generate a dashboard URL for configuring missing secrets.
7153
+ */
7154
+ async setupUrl(data) {
7155
+ return this.client.post("/secrets/setup-url", data);
7156
+ }
7157
+ };
7158
+ var SchedulesEndpoint = class {
7159
+ constructor(client) {
7160
+ this.client = client;
7161
+ }
7162
+ /**
7163
+ * List schedules with cursor pagination. Filter by `search` (name) or `status`.
7164
+ */
7165
+ async list(params) {
7166
+ return this.client.get("/schedules", params);
7167
+ }
7168
+ /**
7169
+ * Get a single schedule by ID.
7170
+ */
7171
+ async get(id) {
7172
+ return this.client.get(`/schedules/${id}`);
7173
+ }
7174
+ /**
7175
+ * Create a schedule. Provide exactly one of `target.flowId` or `target.agentId`.
7176
+ */
7177
+ async create(data) {
7178
+ return this.client.post("/schedules", data);
7179
+ }
7180
+ /**
7181
+ * Update a schedule (partial update supported).
7182
+ */
7183
+ async update(id, data) {
7184
+ return this.client.put(`/schedules/${id}`, data);
7185
+ }
7186
+ /**
7187
+ * Delete a schedule.
7188
+ */
7189
+ async delete(id) {
7190
+ return this.client.delete(`/schedules/${id}`);
7191
+ }
7192
+ /**
7193
+ * Trigger an immediate execution, bypassing the schedule's normal timing.
7194
+ */
7195
+ async runNow(id) {
7196
+ return this.client.post(`/schedules/${id}/run-now`);
7197
+ }
7198
+ /**
7199
+ * Pause a schedule (prevents future executions until resumed).
7200
+ */
7201
+ async pause(id) {
7202
+ return this.client.post(`/schedules/${id}/pause`);
7203
+ }
7204
+ /**
7205
+ * Resume a paused schedule.
7206
+ */
7207
+ async resume(id) {
7208
+ return this.client.post(`/schedules/${id}/resume`);
7209
+ }
7210
+ /**
7211
+ * List the run history for a specific schedule.
7212
+ */
7213
+ async listRuns(id) {
7214
+ return this.client.get(`/schedules/${id}/runs`);
7215
+ }
7216
+ /**
7217
+ * Get statistics (success rate, average duration/cost, 7-day history) for a schedule.
7218
+ */
7219
+ async getStats(id) {
7220
+ return this.client.get(`/schedules/${id}/stats`);
7221
+ }
7222
+ /**
7223
+ * List all runs across every schedule the user owns.
7224
+ */
7225
+ async listAllRuns(params) {
7226
+ return this.client.get("/schedules/runs/all", params);
7227
+ }
7228
+ };
7229
+ var SurfacesEndpoint = class {
7230
+ constructor(client) {
7231
+ this.client = client;
7232
+ }
7233
+ /**
7234
+ * List surfaces with cursor pagination. Filter by `type`, `status`, or `environment`.
7235
+ */
7236
+ async list(params) {
7237
+ return this.client.get("/surfaces", params);
7238
+ }
7239
+ };
7240
+ var ConversationsEndpoint = class {
7241
+ constructor(client) {
7242
+ this.client = client;
7243
+ }
7244
+ /**
7245
+ * List conversations. Filter by source, surface, client token, or owner.
7246
+ *
7247
+ * Note: this endpoint returns a bespoke `{ conversations, pagination }`
7248
+ * envelope rather than the standard `{ data, pagination }` shape.
7249
+ */
7250
+ async list(params) {
7251
+ const query = {};
7252
+ if (params?.source !== void 0) query.source = params.source;
7253
+ if (params?.surfaceId !== void 0) query.surface_id = params.surfaceId;
7254
+ if (params?.clientTokenId !== void 0) query.client_token_id = params.clientTokenId;
7255
+ if (params?.ownerId !== void 0) query.ownerId = params.ownerId;
7256
+ if (params?.limit !== void 0) query.limit = params.limit;
7257
+ if (params?.cursor !== void 0) query.cursor = params.cursor;
7258
+ return this.client.get("/conversations", query);
7259
+ }
7260
+ /**
7261
+ * Get a single conversation (including its messages) by ID.
7262
+ */
7263
+ async get(id) {
7264
+ return this.client.get(`/conversations/${id}`);
7265
+ }
7266
+ /**
7267
+ * Create a conversation.
7268
+ */
7269
+ async create(data) {
7270
+ return this.client.post("/conversations", data ?? {});
7271
+ }
7272
+ /**
7273
+ * Update a conversation (title, model, system prompt, owner, metadata, messages).
7274
+ */
7275
+ async update(id, data) {
7276
+ return this.client.put(`/conversations/${id}`, data);
7277
+ }
7278
+ /**
7279
+ * Delete a conversation.
7280
+ */
7281
+ async delete(id) {
7282
+ return this.client.delete(`/conversations/${id}`);
7283
+ }
7284
+ };
7285
+ var LogsEndpoint = class {
7286
+ constructor(client) {
7287
+ this.client = client;
7288
+ }
7289
+ /**
7290
+ * Query logs with filtering and cursor pagination. Returns the
7291
+ * `{ success, data: { entries, pagination } }` envelope.
7292
+ */
7293
+ async list(params) {
7294
+ return this.client.get("/logs", params);
7295
+ }
7296
+ /**
7297
+ * Convenience wrapper around {@link list} that returns just the log entries.
7298
+ */
7299
+ async listEntries(params) {
7300
+ const response = await this.list(params);
7301
+ return response.data.entries;
7302
+ }
7303
+ /**
7304
+ * Get aggregate log statistics (counts by level/category, time-series histogram).
7305
+ */
7306
+ async getStats(params) {
7307
+ return this.client.get("/logs/stats", params);
7308
+ }
7309
+ /**
7310
+ * Get the trace tree for a single execution.
7311
+ */
7312
+ async traceExecution(executionId) {
7313
+ return this.client.get(`/logs/trace/execution/${executionId}`);
7314
+ }
7315
+ /**
7316
+ * Get the trace tree for a conversation (all executions within it).
7317
+ */
7318
+ async traceConversation(conversationId) {
7319
+ return this.client.get(`/logs/trace/conversation/${conversationId}`);
7320
+ }
7321
+ };
7322
+ var AgentVersionsEndpoint = class {
7323
+ constructor(client) {
7324
+ this.client = client;
7325
+ }
7326
+ /**
7327
+ * List versions for an agent, optionally filtered by version `type`.
7328
+ */
7329
+ async list(agentId, params) {
7330
+ return this.client.get(`/agent-versions/${agentId}`, params);
7331
+ }
7332
+ /**
7333
+ * Get the published version for an agent.
7334
+ */
7335
+ async getPublished(agentId) {
7336
+ return this.client.get(`/agent-versions/${agentId}/published`);
7337
+ }
7338
+ /**
7339
+ * Get a specific version of an agent.
7340
+ */
7341
+ async get(agentId, versionId) {
7342
+ return this.client.get(`/agent-versions/${agentId}/${versionId}`);
7343
+ }
7344
+ /**
7345
+ * Publish a version (promote it to the agent's published version).
7346
+ */
7347
+ async publish(agentId, versionId) {
7348
+ return this.client.post(`/agent-versions/${agentId}/publish`, {
7349
+ versionId
7350
+ });
7351
+ }
7352
+ };
7353
+ var FlowVersionsEndpoint = class {
7354
+ constructor(client) {
7355
+ this.client = client;
7356
+ }
7357
+ /**
7358
+ * List versions for a flow, optionally filtered by version `type`.
7359
+ */
7360
+ async list(flowId, params) {
7361
+ return this.client.get(`/flow-versions/${flowId}`, params);
7362
+ }
7363
+ /**
7364
+ * Get the published version for a flow.
7365
+ */
7366
+ async getPublished(flowId) {
7367
+ return this.client.get(`/flow-versions/${flowId}/published`);
7368
+ }
7369
+ /**
7370
+ * Get a specific version of a flow.
7371
+ */
7372
+ async get(flowId, versionId) {
7373
+ return this.client.get(`/flow-versions/${flowId}/${versionId}`);
7374
+ }
7375
+ /**
7376
+ * Publish a version (promote it to the flow's published version).
7377
+ */
7378
+ async publish(flowId, versionId) {
7379
+ return this.client.post(`/flow-versions/${flowId}/publish`, {
7380
+ versionId
7381
+ });
7382
+ }
7383
+ };
7384
+ var IntegrationsEndpoint = class {
7385
+ constructor(client) {
7386
+ this.client = client;
7387
+ }
7388
+ /**
7389
+ * List all integrations with the caller's per-integration configuration status.
7390
+ */
7391
+ async list(params) {
7392
+ return this.client.get("/integrations", params);
7393
+ }
7394
+ /**
7395
+ * Get a single integration by ID.
7396
+ */
7397
+ async get(integrationId) {
7398
+ return this.client.get(`/integrations/${integrationId}`);
7399
+ }
7400
+ /**
7401
+ * List integrations within a category (e.g. `slack`, `mcp`).
7402
+ */
7403
+ async listByCategory(category) {
7404
+ return this.client.get(
7405
+ `/integrations/category/${category}`
7406
+ );
7407
+ }
7408
+ /**
7409
+ * Per-environment credential status across the caller's integrations.
7410
+ */
7411
+ async getCredentialsStatus() {
7412
+ return this.client.get("/integrations/credentials-status");
7413
+ }
7414
+ /**
7415
+ * List all tools exposed across the caller's configured integrations.
7416
+ */
7417
+ async listTools() {
7418
+ return this.client.get("/integrations/tools");
7419
+ }
7420
+ /**
7421
+ * List the tools exposed by a single integration.
7422
+ */
7423
+ async getIntegrationTools(integrationId) {
7424
+ return this.client.get(
7425
+ `/integrations/${integrationId}/tools`
7426
+ );
7427
+ }
7428
+ /**
7429
+ * Get the definition of a single tool within an integration.
7430
+ */
7431
+ async getTool(integrationId, toolName) {
7432
+ return this.client.get(`/integrations/${integrationId}/tools/${toolName}`);
7433
+ }
7434
+ /**
7435
+ * Install a Slack integration from a completed OAuth handshake.
7436
+ */
7437
+ async installSlack(data) {
7438
+ return this.client.post("/integrations/slack/install", data);
7439
+ }
7440
+ };
7441
+ var BillingEndpoint = class {
7442
+ constructor(client) {
7443
+ this.client = client;
7444
+ }
7445
+ /**
7446
+ * Get the caller's subscription status, plan limits, and current usage.
7447
+ */
7448
+ async getStatus() {
7449
+ return this.client.get("/billing/status");
7450
+ }
7451
+ /**
7452
+ * Get the caller's credit grants and available/used totals.
7453
+ */
7454
+ async getCredits() {
7455
+ return this.client.get("/billing/credits");
7456
+ }
7457
+ /**
7458
+ * Get spend analytics. The window is controlled by `days` (1–365, defaults to 30).
7459
+ */
7460
+ async getSpendAnalytics(params) {
7461
+ return this.client.get("/billing/spend-analytics", params);
7462
+ }
7463
+ };
7098
7464
 
7099
7465
  // src/flow-builder.ts
7100
7466
  init_stream_utils();
@@ -7824,7 +8190,7 @@ var RuntypeClient2 = class {
7824
8190
  const baseUrl = config.baseUrl || "https://api.runtype.com";
7825
8191
  this.apiVersion = config.apiVersion || "v1";
7826
8192
  this.baseUrl = this.apiVersion ? `${baseUrl}/${this.apiVersion}` : baseUrl;
7827
- this.timeout = config.timeout || 3e4;
8193
+ this.timeout = config.timeout === void 0 ? 3e4 : config.timeout;
7828
8194
  this.headers = {
7829
8195
  "Content-Type": "application/json",
7830
8196
  ...config.headers || {}
@@ -7847,6 +8213,15 @@ var RuntypeClient2 = class {
7847
8213
  this.eval = new EvalEndpoint(this);
7848
8214
  this.clientTokens = new ClientTokensEndpoint(this);
7849
8215
  this.agents = new AgentsEndpoint(this);
8216
+ this.secrets = new SecretsEndpoint(this);
8217
+ this.schedules = new SchedulesEndpoint(this);
8218
+ this.surfaces = new SurfacesEndpoint(this);
8219
+ this.conversations = new ConversationsEndpoint(this);
8220
+ this.logs = new LogsEndpoint(this);
8221
+ this.agentVersions = new AgentVersionsEndpoint(this);
8222
+ this.flowVersions = new FlowVersionsEndpoint(this);
8223
+ this.integrations = new IntegrationsEndpoint(this);
8224
+ this.billing = new BillingEndpoint(this);
7850
8225
  }
7851
8226
  /**
7852
8227
  * Set the API key for authentication
@@ -7888,9 +8263,7 @@ var RuntypeClient2 = class {
7888
8263
  const options = (isOptionsObject(arg3) ? arg3 : arg4) ?? {};
7889
8264
  const scope = options.scope ?? "session";
7890
8265
  const isStreaming = !!callbacks;
7891
- const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter(
7892
- (entry) => hasToolEntryShape(entry[1])
7893
- ).map(([name, entry]) => ({
8266
+ const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter((entry) => hasToolEntryShape(entry[1])).map(([name, entry]) => ({
7894
8267
  name,
7895
8268
  description: entry.description,
7896
8269
  parametersSchema: entry.parametersSchema,
@@ -8157,14 +8530,14 @@ var RuntypeClient2 = class {
8157
8530
  * Make HTTP request with timeout and error handling
8158
8531
  */
8159
8532
  async makeRequest(url, options) {
8160
- const controller = new AbortController();
8161
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
8533
+ const controller = this.timeout === null ? null : new AbortController();
8534
+ const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
8162
8535
  try {
8163
8536
  const response = await fetch(url, {
8164
8537
  ...options,
8165
- signal: controller.signal
8538
+ ...controller ? { signal: controller.signal } : {}
8166
8539
  });
8167
- clearTimeout(timeoutId);
8540
+ if (timeoutId) clearTimeout(timeoutId);
8168
8541
  if (!response.ok) {
8169
8542
  throw await this.createApiError(response);
8170
8543
  }
@@ -8177,8 +8550,8 @@ var RuntypeClient2 = class {
8177
8550
  }
8178
8551
  return response.text();
8179
8552
  } catch (error) {
8180
- clearTimeout(timeoutId);
8181
- if (error instanceof Error && error.name === "AbortError") {
8553
+ if (timeoutId) clearTimeout(timeoutId);
8554
+ if (timeoutId && error instanceof Error && error.name === "AbortError") {
8182
8555
  throw new Error(`Request timeout after ${this.timeout}ms`);
8183
8556
  }
8184
8557
  throw error;
@@ -8188,21 +8561,21 @@ var RuntypeClient2 = class {
8188
8561
  * Make HTTP request that returns raw Response (for streaming)
8189
8562
  */
8190
8563
  async makeRawRequest(url, options) {
8191
- const controller = new AbortController();
8192
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
8564
+ const controller = this.timeout === null ? null : new AbortController();
8565
+ const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
8193
8566
  try {
8194
8567
  const response = await fetch(url, {
8195
8568
  ...options,
8196
- signal: controller.signal
8569
+ ...controller ? { signal: controller.signal } : {}
8197
8570
  });
8198
- clearTimeout(timeoutId);
8571
+ if (timeoutId) clearTimeout(timeoutId);
8199
8572
  if (!response.ok) {
8200
8573
  throw await this.createApiError(response);
8201
8574
  }
8202
8575
  return response;
8203
8576
  } catch (error) {
8204
- clearTimeout(timeoutId);
8205
- if (error instanceof Error && error.name === "AbortError") {
8577
+ if (timeoutId) clearTimeout(timeoutId);
8578
+ if (timeoutId && error instanceof Error && error.name === "AbortError") {
8206
8579
  throw new Error(`Request timeout after ${this.timeout}ms`);
8207
8580
  }
8208
8581
  throw error;
@@ -8781,17 +9154,20 @@ var STEP_TYPE_TO_METHOD = {
8781
9154
  };
8782
9155
  // Annotate the CommonJS export names for ESM import in node:
8783
9156
  0 && (module.exports = {
9157
+ AgentVersionsEndpoint,
8784
9158
  AgentsEndpoint,
8785
9159
  AnalyticsEndpoint,
8786
9160
  ApiKeysEndpoint,
8787
9161
  BatchBuilder,
8788
9162
  BatchesNamespace,
9163
+ BillingEndpoint,
8789
9164
  ChatEndpoint,
8790
9165
  ClientBatchBuilder,
8791
9166
  ClientEvalBuilder,
8792
9167
  ClientFlowBuilder,
8793
9168
  ClientTokensEndpoint,
8794
9169
  ContextTemplatesEndpoint,
9170
+ ConversationsEndpoint,
8795
9171
  DispatchEndpoint,
8796
9172
  EvalBuilder,
8797
9173
  EvalEndpoint,
@@ -8800,8 +9176,11 @@ var STEP_TYPE_TO_METHOD = {
8800
9176
  FlowBuilder,
8801
9177
  FlowResult,
8802
9178
  FlowStepsEndpoint,
9179
+ FlowVersionsEndpoint,
8803
9180
  FlowsEndpoint,
8804
9181
  FlowsNamespace,
9182
+ IntegrationsEndpoint,
9183
+ LogsEndpoint,
8805
9184
  ModelConfigsEndpoint,
8806
9185
  PromptRunner,
8807
9186
  PromptsEndpoint,
@@ -8813,6 +9192,9 @@ var STEP_TYPE_TO_METHOD = {
8813
9192
  RuntypeFlowBuilder,
8814
9193
  STEP_FIELD_REGISTRY,
8815
9194
  STEP_TYPE_TO_METHOD,
9195
+ SchedulesEndpoint,
9196
+ SecretsEndpoint,
9197
+ SurfacesEndpoint,
8816
9198
  ToolsEndpoint,
8817
9199
  UsersEndpoint,
8818
9200
  applyGeneratedRuntimeToolProposalToDispatchRequest,