@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.mjs CHANGED
@@ -7023,6 +7023,363 @@ _AgentsEndpoint.STOP_PHRASES = [
7023
7023
  "STATUS: COMPLETE"
7024
7024
  ];
7025
7025
  var AgentsEndpoint = _AgentsEndpoint;
7026
+ var SecretsEndpoint = class {
7027
+ constructor(client) {
7028
+ this.client = client;
7029
+ }
7030
+ /**
7031
+ * List all secrets (metadata only) for the authenticated user/org.
7032
+ */
7033
+ async list() {
7034
+ return this.client.get("/secrets");
7035
+ }
7036
+ /**
7037
+ * Get metadata for a single secret by ID.
7038
+ */
7039
+ async get(id) {
7040
+ const response = await this.client.get(`/secrets/${id}`);
7041
+ return response.data;
7042
+ }
7043
+ /**
7044
+ * Create a secret. Omitting `value` provisions a key with no value yet
7045
+ * (get-or-create semantics).
7046
+ */
7047
+ async create(data) {
7048
+ const response = await this.client.post("/secrets", data);
7049
+ return response.data;
7050
+ }
7051
+ /**
7052
+ * Update or rotate a secret. Pass `expectedVersion` for optimistic concurrency.
7053
+ */
7054
+ async update(id, data) {
7055
+ const response = await this.client.put(`/secrets/${id}`, data);
7056
+ return response.data;
7057
+ }
7058
+ /**
7059
+ * Delete a secret. Returns the number of tool configs that still reference it.
7060
+ */
7061
+ async delete(id) {
7062
+ return this.client.delete(`/secrets/${id}`);
7063
+ }
7064
+ /**
7065
+ * Check which of the given keys exist, are missing, or are revoked.
7066
+ */
7067
+ async check(keys) {
7068
+ return this.client.post("/secrets/check", { keys });
7069
+ }
7070
+ /**
7071
+ * Generate a dashboard URL for configuring missing secrets.
7072
+ */
7073
+ async setupUrl(data) {
7074
+ return this.client.post("/secrets/setup-url", data);
7075
+ }
7076
+ };
7077
+ var SchedulesEndpoint = class {
7078
+ constructor(client) {
7079
+ this.client = client;
7080
+ }
7081
+ /**
7082
+ * List schedules with cursor pagination. Filter by `search` (name) or `status`.
7083
+ */
7084
+ async list(params) {
7085
+ return this.client.get("/schedules", params);
7086
+ }
7087
+ /**
7088
+ * Get a single schedule by ID.
7089
+ */
7090
+ async get(id) {
7091
+ return this.client.get(`/schedules/${id}`);
7092
+ }
7093
+ /**
7094
+ * Create a schedule. Provide exactly one of `target.flowId` or `target.agentId`.
7095
+ */
7096
+ async create(data) {
7097
+ return this.client.post("/schedules", data);
7098
+ }
7099
+ /**
7100
+ * Update a schedule (partial update supported).
7101
+ */
7102
+ async update(id, data) {
7103
+ return this.client.put(`/schedules/${id}`, data);
7104
+ }
7105
+ /**
7106
+ * Delete a schedule.
7107
+ */
7108
+ async delete(id) {
7109
+ return this.client.delete(`/schedules/${id}`);
7110
+ }
7111
+ /**
7112
+ * Trigger an immediate execution, bypassing the schedule's normal timing.
7113
+ */
7114
+ async runNow(id) {
7115
+ return this.client.post(`/schedules/${id}/run-now`);
7116
+ }
7117
+ /**
7118
+ * Pause a schedule (prevents future executions until resumed).
7119
+ */
7120
+ async pause(id) {
7121
+ return this.client.post(`/schedules/${id}/pause`);
7122
+ }
7123
+ /**
7124
+ * Resume a paused schedule.
7125
+ */
7126
+ async resume(id) {
7127
+ return this.client.post(`/schedules/${id}/resume`);
7128
+ }
7129
+ /**
7130
+ * List the run history for a specific schedule.
7131
+ */
7132
+ async listRuns(id) {
7133
+ return this.client.get(`/schedules/${id}/runs`);
7134
+ }
7135
+ /**
7136
+ * Get statistics (success rate, average duration/cost, 7-day history) for a schedule.
7137
+ */
7138
+ async getStats(id) {
7139
+ return this.client.get(`/schedules/${id}/stats`);
7140
+ }
7141
+ /**
7142
+ * List all runs across every schedule the user owns.
7143
+ */
7144
+ async listAllRuns(params) {
7145
+ return this.client.get("/schedules/runs/all", params);
7146
+ }
7147
+ };
7148
+ var SurfacesEndpoint = class {
7149
+ constructor(client) {
7150
+ this.client = client;
7151
+ }
7152
+ /**
7153
+ * List surfaces with cursor pagination. Filter by `type`, `status`, or `environment`.
7154
+ */
7155
+ async list(params) {
7156
+ return this.client.get("/surfaces", params);
7157
+ }
7158
+ };
7159
+ var ConversationsEndpoint = class {
7160
+ constructor(client) {
7161
+ this.client = client;
7162
+ }
7163
+ /**
7164
+ * List conversations. Filter by source, surface, client token, or owner.
7165
+ *
7166
+ * Note: this endpoint returns a bespoke `{ conversations, pagination }`
7167
+ * envelope rather than the standard `{ data, pagination }` shape.
7168
+ */
7169
+ async list(params) {
7170
+ const query = {};
7171
+ if (params?.source !== void 0) query.source = params.source;
7172
+ if (params?.surfaceId !== void 0) query.surface_id = params.surfaceId;
7173
+ if (params?.clientTokenId !== void 0) query.client_token_id = params.clientTokenId;
7174
+ if (params?.ownerId !== void 0) query.ownerId = params.ownerId;
7175
+ if (params?.limit !== void 0) query.limit = params.limit;
7176
+ if (params?.cursor !== void 0) query.cursor = params.cursor;
7177
+ return this.client.get("/conversations", query);
7178
+ }
7179
+ /**
7180
+ * Get a single conversation (including its messages) by ID.
7181
+ */
7182
+ async get(id) {
7183
+ return this.client.get(`/conversations/${id}`);
7184
+ }
7185
+ /**
7186
+ * Create a conversation.
7187
+ */
7188
+ async create(data) {
7189
+ return this.client.post("/conversations", data ?? {});
7190
+ }
7191
+ /**
7192
+ * Update a conversation (title, model, system prompt, owner, metadata, messages).
7193
+ */
7194
+ async update(id, data) {
7195
+ return this.client.put(`/conversations/${id}`, data);
7196
+ }
7197
+ /**
7198
+ * Delete a conversation.
7199
+ */
7200
+ async delete(id) {
7201
+ return this.client.delete(`/conversations/${id}`);
7202
+ }
7203
+ };
7204
+ var LogsEndpoint = class {
7205
+ constructor(client) {
7206
+ this.client = client;
7207
+ }
7208
+ /**
7209
+ * Query logs with filtering and cursor pagination. Returns the
7210
+ * `{ success, data: { entries, pagination } }` envelope.
7211
+ */
7212
+ async list(params) {
7213
+ return this.client.get("/logs", params);
7214
+ }
7215
+ /**
7216
+ * Convenience wrapper around {@link list} that returns just the log entries.
7217
+ */
7218
+ async listEntries(params) {
7219
+ const response = await this.list(params);
7220
+ return response.data.entries;
7221
+ }
7222
+ /**
7223
+ * Get aggregate log statistics (counts by level/category, time-series histogram).
7224
+ */
7225
+ async getStats(params) {
7226
+ return this.client.get("/logs/stats", params);
7227
+ }
7228
+ /**
7229
+ * Get the trace tree for a single execution.
7230
+ */
7231
+ async traceExecution(executionId) {
7232
+ return this.client.get(`/logs/trace/execution/${executionId}`);
7233
+ }
7234
+ /**
7235
+ * Get the trace tree for a conversation (all executions within it).
7236
+ */
7237
+ async traceConversation(conversationId) {
7238
+ return this.client.get(`/logs/trace/conversation/${conversationId}`);
7239
+ }
7240
+ };
7241
+ var AgentVersionsEndpoint = class {
7242
+ constructor(client) {
7243
+ this.client = client;
7244
+ }
7245
+ /**
7246
+ * List versions for an agent, optionally filtered by version `type`.
7247
+ */
7248
+ async list(agentId, params) {
7249
+ return this.client.get(`/agent-versions/${agentId}`, params);
7250
+ }
7251
+ /**
7252
+ * Get the published version for an agent.
7253
+ */
7254
+ async getPublished(agentId) {
7255
+ return this.client.get(`/agent-versions/${agentId}/published`);
7256
+ }
7257
+ /**
7258
+ * Get a specific version of an agent.
7259
+ */
7260
+ async get(agentId, versionId) {
7261
+ return this.client.get(`/agent-versions/${agentId}/${versionId}`);
7262
+ }
7263
+ /**
7264
+ * Publish a version (promote it to the agent's published version).
7265
+ */
7266
+ async publish(agentId, versionId) {
7267
+ return this.client.post(`/agent-versions/${agentId}/publish`, {
7268
+ versionId
7269
+ });
7270
+ }
7271
+ };
7272
+ var FlowVersionsEndpoint = class {
7273
+ constructor(client) {
7274
+ this.client = client;
7275
+ }
7276
+ /**
7277
+ * List versions for a flow, optionally filtered by version `type`.
7278
+ */
7279
+ async list(flowId, params) {
7280
+ return this.client.get(`/flow-versions/${flowId}`, params);
7281
+ }
7282
+ /**
7283
+ * Get the published version for a flow.
7284
+ */
7285
+ async getPublished(flowId) {
7286
+ return this.client.get(`/flow-versions/${flowId}/published`);
7287
+ }
7288
+ /**
7289
+ * Get a specific version of a flow.
7290
+ */
7291
+ async get(flowId, versionId) {
7292
+ return this.client.get(`/flow-versions/${flowId}/${versionId}`);
7293
+ }
7294
+ /**
7295
+ * Publish a version (promote it to the flow's published version).
7296
+ */
7297
+ async publish(flowId, versionId) {
7298
+ return this.client.post(`/flow-versions/${flowId}/publish`, {
7299
+ versionId
7300
+ });
7301
+ }
7302
+ };
7303
+ var IntegrationsEndpoint = class {
7304
+ constructor(client) {
7305
+ this.client = client;
7306
+ }
7307
+ /**
7308
+ * List all integrations with the caller's per-integration configuration status.
7309
+ */
7310
+ async list(params) {
7311
+ return this.client.get("/integrations", params);
7312
+ }
7313
+ /**
7314
+ * Get a single integration by ID.
7315
+ */
7316
+ async get(integrationId) {
7317
+ return this.client.get(`/integrations/${integrationId}`);
7318
+ }
7319
+ /**
7320
+ * List integrations within a category (e.g. `slack`, `mcp`).
7321
+ */
7322
+ async listByCategory(category) {
7323
+ return this.client.get(
7324
+ `/integrations/category/${category}`
7325
+ );
7326
+ }
7327
+ /**
7328
+ * Per-environment credential status across the caller's integrations.
7329
+ */
7330
+ async getCredentialsStatus() {
7331
+ return this.client.get("/integrations/credentials-status");
7332
+ }
7333
+ /**
7334
+ * List all tools exposed across the caller's configured integrations.
7335
+ */
7336
+ async listTools() {
7337
+ return this.client.get("/integrations/tools");
7338
+ }
7339
+ /**
7340
+ * List the tools exposed by a single integration.
7341
+ */
7342
+ async getIntegrationTools(integrationId) {
7343
+ return this.client.get(
7344
+ `/integrations/${integrationId}/tools`
7345
+ );
7346
+ }
7347
+ /**
7348
+ * Get the definition of a single tool within an integration.
7349
+ */
7350
+ async getTool(integrationId, toolName) {
7351
+ return this.client.get(`/integrations/${integrationId}/tools/${toolName}`);
7352
+ }
7353
+ /**
7354
+ * Install a Slack integration from a completed OAuth handshake.
7355
+ */
7356
+ async installSlack(data) {
7357
+ return this.client.post("/integrations/slack/install", data);
7358
+ }
7359
+ };
7360
+ var BillingEndpoint = class {
7361
+ constructor(client) {
7362
+ this.client = client;
7363
+ }
7364
+ /**
7365
+ * Get the caller's subscription status, plan limits, and current usage.
7366
+ */
7367
+ async getStatus() {
7368
+ return this.client.get("/billing/status");
7369
+ }
7370
+ /**
7371
+ * Get the caller's credit grants and available/used totals.
7372
+ */
7373
+ async getCredits() {
7374
+ return this.client.get("/billing/credits");
7375
+ }
7376
+ /**
7377
+ * Get spend analytics. The window is controlled by `days` (1–365, defaults to 30).
7378
+ */
7379
+ async getSpendAnalytics(params) {
7380
+ return this.client.get("/billing/spend-analytics", params);
7381
+ }
7382
+ };
7026
7383
 
7027
7384
  // src/flow-builder.ts
7028
7385
  init_stream_utils();
@@ -7752,7 +8109,7 @@ var RuntypeClient2 = class {
7752
8109
  const baseUrl = config.baseUrl || "https://api.runtype.com";
7753
8110
  this.apiVersion = config.apiVersion || "v1";
7754
8111
  this.baseUrl = this.apiVersion ? `${baseUrl}/${this.apiVersion}` : baseUrl;
7755
- this.timeout = config.timeout || 3e4;
8112
+ this.timeout = config.timeout === void 0 ? 3e4 : config.timeout;
7756
8113
  this.headers = {
7757
8114
  "Content-Type": "application/json",
7758
8115
  ...config.headers || {}
@@ -7775,6 +8132,15 @@ var RuntypeClient2 = class {
7775
8132
  this.eval = new EvalEndpoint(this);
7776
8133
  this.clientTokens = new ClientTokensEndpoint(this);
7777
8134
  this.agents = new AgentsEndpoint(this);
8135
+ this.secrets = new SecretsEndpoint(this);
8136
+ this.schedules = new SchedulesEndpoint(this);
8137
+ this.surfaces = new SurfacesEndpoint(this);
8138
+ this.conversations = new ConversationsEndpoint(this);
8139
+ this.logs = new LogsEndpoint(this);
8140
+ this.agentVersions = new AgentVersionsEndpoint(this);
8141
+ this.flowVersions = new FlowVersionsEndpoint(this);
8142
+ this.integrations = new IntegrationsEndpoint(this);
8143
+ this.billing = new BillingEndpoint(this);
7778
8144
  }
7779
8145
  /**
7780
8146
  * Set the API key for authentication
@@ -7816,9 +8182,7 @@ var RuntypeClient2 = class {
7816
8182
  const options = (isOptionsObject(arg3) ? arg3 : arg4) ?? {};
7817
8183
  const scope = options.scope ?? "session";
7818
8184
  const isStreaming = !!callbacks;
7819
- const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter(
7820
- (entry) => hasToolEntryShape(entry[1])
7821
- ).map(([name, entry]) => ({
8185
+ const derivedClientTools = scope === "turn" ? Object.entries(localTools).filter((entry) => hasToolEntryShape(entry[1])).map(([name, entry]) => ({
7822
8186
  name,
7823
8187
  description: entry.description,
7824
8188
  parametersSchema: entry.parametersSchema,
@@ -8085,14 +8449,14 @@ var RuntypeClient2 = class {
8085
8449
  * Make HTTP request with timeout and error handling
8086
8450
  */
8087
8451
  async makeRequest(url, options) {
8088
- const controller = new AbortController();
8089
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
8452
+ const controller = this.timeout === null ? null : new AbortController();
8453
+ const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
8090
8454
  try {
8091
8455
  const response = await fetch(url, {
8092
8456
  ...options,
8093
- signal: controller.signal
8457
+ ...controller ? { signal: controller.signal } : {}
8094
8458
  });
8095
- clearTimeout(timeoutId);
8459
+ if (timeoutId) clearTimeout(timeoutId);
8096
8460
  if (!response.ok) {
8097
8461
  throw await this.createApiError(response);
8098
8462
  }
@@ -8105,8 +8469,8 @@ var RuntypeClient2 = class {
8105
8469
  }
8106
8470
  return response.text();
8107
8471
  } catch (error) {
8108
- clearTimeout(timeoutId);
8109
- if (error instanceof Error && error.name === "AbortError") {
8472
+ if (timeoutId) clearTimeout(timeoutId);
8473
+ if (timeoutId && error instanceof Error && error.name === "AbortError") {
8110
8474
  throw new Error(`Request timeout after ${this.timeout}ms`);
8111
8475
  }
8112
8476
  throw error;
@@ -8116,21 +8480,21 @@ var RuntypeClient2 = class {
8116
8480
  * Make HTTP request that returns raw Response (for streaming)
8117
8481
  */
8118
8482
  async makeRawRequest(url, options) {
8119
- const controller = new AbortController();
8120
- const timeoutId = setTimeout(() => controller.abort(), this.timeout);
8483
+ const controller = this.timeout === null ? null : new AbortController();
8484
+ const timeoutId = controller && this.timeout !== null ? setTimeout(() => controller.abort(), this.timeout) : null;
8121
8485
  try {
8122
8486
  const response = await fetch(url, {
8123
8487
  ...options,
8124
- signal: controller.signal
8488
+ ...controller ? { signal: controller.signal } : {}
8125
8489
  });
8126
- clearTimeout(timeoutId);
8490
+ if (timeoutId) clearTimeout(timeoutId);
8127
8491
  if (!response.ok) {
8128
8492
  throw await this.createApiError(response);
8129
8493
  }
8130
8494
  return response;
8131
8495
  } catch (error) {
8132
- clearTimeout(timeoutId);
8133
- if (error instanceof Error && error.name === "AbortError") {
8496
+ if (timeoutId) clearTimeout(timeoutId);
8497
+ if (timeoutId && error instanceof Error && error.name === "AbortError") {
8134
8498
  throw new Error(`Request timeout after ${this.timeout}ms`);
8135
8499
  }
8136
8500
  throw error;
@@ -8708,17 +9072,20 @@ var STEP_TYPE_TO_METHOD = {
8708
9072
  "generate-pdf": "generatePdf"
8709
9073
  };
8710
9074
  export {
9075
+ AgentVersionsEndpoint,
8711
9076
  AgentsEndpoint,
8712
9077
  AnalyticsEndpoint,
8713
9078
  ApiKeysEndpoint,
8714
9079
  BatchBuilder,
8715
9080
  BatchesNamespace,
9081
+ BillingEndpoint,
8716
9082
  ChatEndpoint,
8717
9083
  ClientBatchBuilder,
8718
9084
  ClientEvalBuilder,
8719
9085
  ClientFlowBuilder,
8720
9086
  ClientTokensEndpoint,
8721
9087
  ContextTemplatesEndpoint,
9088
+ ConversationsEndpoint,
8722
9089
  DispatchEndpoint,
8723
9090
  EvalBuilder,
8724
9091
  EvalEndpoint,
@@ -8727,8 +9094,11 @@ export {
8727
9094
  FlowBuilder,
8728
9095
  FlowResult,
8729
9096
  FlowStepsEndpoint,
9097
+ FlowVersionsEndpoint,
8730
9098
  FlowsEndpoint,
8731
9099
  FlowsNamespace,
9100
+ IntegrationsEndpoint,
9101
+ LogsEndpoint,
8732
9102
  ModelConfigsEndpoint,
8733
9103
  PromptRunner,
8734
9104
  PromptsEndpoint,
@@ -8740,6 +9110,9 @@ export {
8740
9110
  RuntypeFlowBuilder,
8741
9111
  STEP_FIELD_REGISTRY,
8742
9112
  STEP_TYPE_TO_METHOD,
9113
+ SchedulesEndpoint,
9114
+ SecretsEndpoint,
9115
+ SurfacesEndpoint,
8743
9116
  ToolsEndpoint,
8744
9117
  UsersEndpoint,
8745
9118
  applyGeneratedRuntimeToolProposalToDispatchRequest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for the Runtype API with fluent methods. Use it to quickly realize AI products, agents, and workflows.",
6
6
  "main": "dist/index.cjs",
@@ -55,7 +55,7 @@
55
55
  "access": "public"
56
56
  },
57
57
  "engines": {
58
- "node": ">=18.0.0"
58
+ "node": ">=22.0.0"
59
59
  },
60
60
  "sideEffects": false,
61
61
  "scripts": {