@runtypelabs/sdk 9.1.1 → 9.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
@@ -1220,6 +1220,24 @@ var FlowBuilder = class {
1220
1220
  );
1221
1221
  return this;
1222
1222
  }
1223
+ /**
1224
+ * Add a bounded do-while loop step.
1225
+ */
1226
+ loop(config) {
1227
+ this.addStep(
1228
+ "loop",
1229
+ config.name,
1230
+ {
1231
+ steps: config.steps,
1232
+ until: config.until,
1233
+ maxIterations: config.maxIterations,
1234
+ iterationVariable: config.iterationVariable
1235
+ },
1236
+ config.enabled,
1237
+ config.when
1238
+ );
1239
+ return this;
1240
+ }
1223
1241
  /**
1224
1242
  * Add a search step
1225
1243
  */
@@ -3042,6 +3060,24 @@ var RuntypeFlowBuilder = class {
3042
3060
  );
3043
3061
  return this;
3044
3062
  }
3063
+ /**
3064
+ * Add a bounded do-while loop step.
3065
+ */
3066
+ loop(config) {
3067
+ this.addStep(
3068
+ "loop",
3069
+ config.name,
3070
+ {
3071
+ steps: config.steps,
3072
+ until: config.until,
3073
+ maxIterations: config.maxIterations,
3074
+ iterationVariable: config.iterationVariable
3075
+ },
3076
+ config.enabled,
3077
+ config.when
3078
+ );
3079
+ return this;
3080
+ }
3045
3081
  /**
3046
3082
  * Add a search step
3047
3083
  */
@@ -4968,6 +5004,16 @@ var AgentsNamespace = class {
4968
5004
  }
4969
5005
  };
4970
5006
 
5007
+ // src/executions-namespace.ts
5008
+ var ExecutionsNamespace = class {
5009
+ constructor(getClient) {
5010
+ this.getClient = getClient;
5011
+ }
5012
+ getStatus(executionId) {
5013
+ return this.getClient().getExecutionStatus(executionId);
5014
+ }
5015
+ };
5016
+
4971
5017
  // src/tools-ensure.ts
4972
5018
  function normalizeToolDefinition(definition) {
4973
5019
  const parametersSchema = isPlainObject(definition.parametersSchema) ? normalizeValue(definition.parametersSchema) : {};
@@ -5712,6 +5758,11 @@ function transformQueryParams(params) {
5712
5758
  return result;
5713
5759
  }
5714
5760
 
5761
+ // src/types.ts
5762
+ function isCatalogClientToolRef(entry) {
5763
+ return entry.catalog === "runtype-mcp";
5764
+ }
5765
+
5715
5766
  // src/dispatch-request.ts
5716
5767
  function normalizeDispatchMessageContent(content) {
5717
5768
  if (Array.isArray(content) && content.some(
@@ -5736,6 +5787,9 @@ function normalizeDispatchRequest(request6) {
5736
5787
  content: normalizeDispatchMessageContent(message.content)
5737
5788
  }));
5738
5789
  const clientTools = request6.clientTools?.map((tool) => {
5790
+ if (isCatalogClientToolRef(tool)) {
5791
+ return tool;
5792
+ }
5739
5793
  if (tool.parametersSchema.type !== "object") {
5740
5794
  throw new Error(`Client tool "${tool.name}" parametersSchema.type must be "object"`);
5741
5795
  }
@@ -5791,11 +5845,11 @@ var RuntypeClient = class {
5791
5845
  /**
5792
5846
  * Generic POST request
5793
5847
  */
5794
- async post(path, data) {
5848
+ async post(path, data, extraHeaders) {
5795
5849
  const url = this.buildUrl(path);
5796
5850
  const response = await this.makeRequest(url, {
5797
5851
  method: "POST",
5798
- headers: this.headers,
5852
+ headers: { ...this.headers, ...extraHeaders },
5799
5853
  body: data ? JSON.stringify(data) : void 0
5800
5854
  });
5801
5855
  return this.transformResponse(response);
@@ -5888,6 +5942,21 @@ var RuntypeClient = class {
5888
5942
  }
5889
5943
  });
5890
5944
  }
5945
+ /** Start a normalized dispatch and return a durable handle immediately. */
5946
+ async dispatchAsync(config) {
5947
+ const normalized = normalizeDispatchRequest(config);
5948
+ return this.post(
5949
+ "/dispatch",
5950
+ {
5951
+ ...normalized,
5952
+ options: { ...normalized.options, streamResponse: false }
5953
+ },
5954
+ { Prefer: "respond-async" }
5955
+ );
5956
+ }
5957
+ async getExecutionStatus(executionId) {
5958
+ return this.get(`/executions/${encodeURIComponent(executionId)}/status`);
5959
+ }
5891
5960
  /**
5892
5961
  * Build full URL with query parameters
5893
5962
  */
@@ -6162,6 +6231,10 @@ var Runtype = class {
6162
6231
  static get agents() {
6163
6232
  return new AgentsNamespace(() => this.getClient());
6164
6233
  }
6234
+ /** Poll durable handles returned by asynchronous execute operations. */
6235
+ static get executions() {
6236
+ return new ExecutionsNamespace(() => this.getClient());
6237
+ }
6165
6238
  /**
6166
6239
  * Tools namespace - Tool config-as-code (define / ensure / pull)
6167
6240
  *
@@ -6254,7 +6327,7 @@ var Runtype = class {
6254
6327
 
6255
6328
  // src/version.ts
6256
6329
  var FALLBACK_VERSION = "0.0.0";
6257
- var SDK_VERSION = "9.1.1".length > 0 ? "9.1.1" : FALLBACK_VERSION;
6330
+ var SDK_VERSION = "9.2.0".length > 0 ? "9.2.0" : FALLBACK_VERSION;
6258
6331
  var RUNTYPE_CLIENT_KIND = "sdk";
6259
6332
  var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
6260
6333
 
@@ -8637,9 +8710,72 @@ var CollectionsEndpoint = class {
8637
8710
  return this.client.get("/collections/types.d.ts");
8638
8711
  }
8639
8712
  };
8713
+ var ApiKeyRequestsEndpoint = class {
8714
+ constructor(client) {
8715
+ this.client = client;
8716
+ }
8717
+ /**
8718
+ * File a request. Nothing is minted; the response carries the request, the
8719
+ * browser handoff a human must complete, and a suggested poll interval.
8720
+ */
8721
+ async create(data) {
8722
+ return this.client.post("/api-keys/requests", data);
8723
+ }
8724
+ /**
8725
+ * Read one request — poll this for the approval decision.
8726
+ *
8727
+ * The route answers with the `{ request, handoff? }` envelope (the handoff is
8728
+ * present only while a human still has to act), so unwrap it the way `list()`
8729
+ * unwraps `{ requests }`. Returning the envelope raw types as `ApiKeyRequest`
8730
+ * but has no `status`, which silently reads as `undefined` in every caller's
8731
+ * state machine rather than failing anywhere near here.
8732
+ */
8733
+ async get(requestId) {
8734
+ const response = await this.client.get(
8735
+ `/api-keys/requests/${requestId}`
8736
+ );
8737
+ return response.request;
8738
+ }
8739
+ /**
8740
+ * Read one request together with its browser handoff. Same route as `get()`;
8741
+ * use this when re-raising the approval prompt for a request this process did
8742
+ * not file (the handoff is absent once the request leaves `pending`).
8743
+ */
8744
+ async getWithHandoff(requestId) {
8745
+ return this.client.get(`/api-keys/requests/${requestId}`);
8746
+ }
8747
+ /**
8748
+ * List requests for the account. Clerk-session surface (the human review
8749
+ * queue); an API key sees only its own requests.
8750
+ */
8751
+ async list(params) {
8752
+ const response = await this.client.get(
8753
+ "/api-keys/requests",
8754
+ params
8755
+ );
8756
+ return response.requests;
8757
+ }
8758
+ /**
8759
+ * Redeem an approved request. The key is minted here and returned exactly
8760
+ * once: `delivery: 'inline'` (the API default) puts the plaintext in
8761
+ * `apiKey`; `delivery: 'secret'` stores it as a Runtype secret and returns
8762
+ * only a `{{secret:KEY}}` reference in `secretRef`. Claiming twice is a 409.
8763
+ */
8764
+ async claim(requestId, data) {
8765
+ return this.client.post(
8766
+ `/api-keys/requests/${requestId}/claim`,
8767
+ data
8768
+ );
8769
+ }
8770
+ /** Withdraw a pending request you filed. Cannot be undone. */
8771
+ async cancel(requestId) {
8772
+ return this.client.post(`/api-keys/requests/${requestId}/cancel`);
8773
+ }
8774
+ };
8640
8775
  var ApiKeysEndpoint = class {
8641
8776
  constructor(client) {
8642
8777
  this.client = client;
8778
+ this.requests = new ApiKeyRequestsEndpoint(client);
8643
8779
  }
8644
8780
  /**
8645
8781
  * List all API keys for the authenticated user
@@ -8894,6 +9030,18 @@ var DispatchEndpoint = class {
8894
9030
  }
8895
9031
  });
8896
9032
  }
9033
+ /** Start a dispatch and return its durable execution handle immediately. */
9034
+ async executeAsync(data) {
9035
+ const normalized = normalizeDispatchRequest(data);
9036
+ return this.client.post(
9037
+ "/dispatch",
9038
+ {
9039
+ ...normalized,
9040
+ options: { ...normalized.options, streamResponse: false }
9041
+ },
9042
+ { Prefer: "respond-async" }
9043
+ );
9044
+ }
8897
9045
  /**
8898
9046
  * Dispatch with streaming response
8899
9047
  */
@@ -8961,6 +9109,16 @@ var DispatchEndpoint = class {
8961
9109
  return applyGeneratedRuntimeToolProposalToDispatchRequest(request6, proposal, options);
8962
9110
  }
8963
9111
  };
9112
+ var ExecutionsEndpoint = class {
9113
+ constructor(client) {
9114
+ this.client = client;
9115
+ }
9116
+ async getStatus(executionId) {
9117
+ return this.client.get(
9118
+ `/executions/${encodeURIComponent(executionId)}/status`
9119
+ );
9120
+ }
9121
+ };
8964
9122
  var ChatEndpoint = class {
8965
9123
  constructor(client) {
8966
9124
  this.client = client;
@@ -9650,6 +9808,14 @@ var _AgentsEndpoint = class _AgentsEndpoint {
9650
9808
  streamResponse: false
9651
9809
  });
9652
9810
  }
9811
+ /** Start an agent execution and return its durable handle immediately. */
9812
+ async executeAsync(id, data) {
9813
+ return this.client.post(
9814
+ `/agents/${id}/execute`,
9815
+ { ...data, streamResponse: false },
9816
+ { Prefer: "respond-async" }
9817
+ );
9818
+ }
9653
9819
  /**
9654
9820
  * Execute an agent with streaming response
9655
9821
  *
@@ -12816,9 +12982,7 @@ function assertTurnScopedLocalTools(localTools) {
12816
12982
  );
12817
12983
  }
12818
12984
  if (entry.parametersSchema.type !== "object") {
12819
- throw new Error(
12820
- `Turn-scoped local tool "${name}" parametersSchema.type must be "object"`
12821
- );
12985
+ throw new Error(`Turn-scoped local tool "${name}" parametersSchema.type must be "object"`);
12822
12986
  }
12823
12987
  }
12824
12988
  }
@@ -12854,6 +13018,7 @@ var RuntypeClient2 = class {
12854
13018
  this.modelConfigs = new ModelConfigsEndpoint(this);
12855
13019
  this.providerKeys = new ProviderKeysEndpoint(this);
12856
13020
  this.dispatch = new DispatchEndpoint(this);
13021
+ this.executions = new ExecutionsEndpoint(this);
12857
13022
  this.chat = new ChatEndpoint(this);
12858
13023
  this.users = new UsersEndpoint(this);
12859
13024
  this.analytics = new AnalyticsEndpoint(this);
@@ -13121,11 +13286,11 @@ var RuntypeClient2 = class {
13121
13286
  /**
13122
13287
  * Generic POST request
13123
13288
  */
13124
- async post(path, data) {
13289
+ async post(path, data, extraHeaders) {
13125
13290
  const url = this.buildUrl(path);
13126
13291
  const response = await this.makeRequest(url, {
13127
13292
  method: "POST",
13128
- headers: this.headers,
13293
+ headers: { ...this.headers, ...extraHeaders },
13129
13294
  body: data ? JSON.stringify(transformRequest(data)) : void 0
13130
13295
  });
13131
13296
  return transformResponse(response);
@@ -13720,6 +13885,12 @@ var CONDITIONAL_FIELDS = [
13720
13885
  { key: "trueSteps", format: "value" },
13721
13886
  { key: "falseSteps", format: "value" }
13722
13887
  ];
13888
+ var LOOP_FIELDS = [
13889
+ { key: "steps", format: "value" },
13890
+ { key: "until", format: "template" },
13891
+ { key: "maxIterations", format: "raw" },
13892
+ { key: "iterationVariable", format: "json" }
13893
+ ];
13723
13894
  var SEARCH_FIELDS = [
13724
13895
  { key: "provider", format: "json" },
13725
13896
  { key: "query", format: "template" },
@@ -14011,6 +14182,7 @@ var STEP_FIELD_REGISTRY = {
14011
14182
  "transform-data": TRANSFORM_DATA_FIELDS,
14012
14183
  "set-variable": SET_VARIABLE_FIELDS,
14013
14184
  conditional: CONDITIONAL_FIELDS,
14185
+ loop: LOOP_FIELDS,
14014
14186
  search: SEARCH_FIELDS,
14015
14187
  "send-email": SEND_EMAIL_FIELDS,
14016
14188
  "send-stream": SEND_STREAM_FIELDS,
@@ -14045,6 +14217,7 @@ var STEP_TYPE_TO_METHOD = {
14045
14217
  "transform-data": "transformData",
14046
14218
  template: "template",
14047
14219
  conditional: "conditional",
14220
+ loop: "loop",
14048
14221
  "set-variable": "setVariable",
14049
14222
  "upsert-record": "upsertRecord",
14050
14223
  "update-record": "updateRecord",
@@ -14072,6 +14245,7 @@ export {
14072
14245
  AgentsEndpoint,
14073
14246
  AgentsNamespace,
14074
14247
  AnalyticsEndpoint,
14248
+ ApiKeyRequestsEndpoint,
14075
14249
  ApiKeysEndpoint,
14076
14250
  BatchBuilder,
14077
14251
  BatchesNamespace,
@@ -14092,6 +14266,8 @@ export {
14092
14266
  EvalRunner,
14093
14267
  EvalSuitesNamespace,
14094
14268
  EvalsNamespace,
14269
+ ExecutionsEndpoint,
14270
+ ExecutionsNamespace,
14095
14271
  FlowBuilder,
14096
14272
  FlowDriftError,
14097
14273
  FlowEnsureConflictError,
@@ -14183,6 +14359,7 @@ export {
14183
14359
  getDefaultPlanPath,
14184
14360
  getLikelySupportingCandidatePaths,
14185
14361
  interpolateWorkflowTemplate,
14362
+ isCatalogClientToolRef,
14186
14363
  isDiscoveryToolName,
14187
14364
  isMarathonArtifactPath,
14188
14365
  isPreservationSensitiveTask,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/sdk",
3
- "version": "9.1.1",
3
+ "version": "9.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",