@runtypelabs/sdk 6.4.0 → 6.5.1

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
@@ -26,6 +26,8 @@ var UNIFIED_EVENT_TYPES = /* @__PURE__ */ new Set([
26
26
  "artifact_update",
27
27
  "artifact_complete",
28
28
  "source",
29
+ "state_snapshot",
30
+ "state_delta",
29
31
  "tool_start",
30
32
  "tool_input_delta",
31
33
  "tool_input_complete",
@@ -178,9 +180,10 @@ function createFlowEventTranslator() {
178
180
  pageOrigin: data.pageOrigin
179
181
  })
180
182
  ];
181
- // Channels/markers/tool-family/approval/skip/source/custom/ping the flow
182
- // consumer never read → no callback event. (A non-terminal `error` is only
183
- // produced on agent streams; dropping it here avoids a false flow_error.)
183
+ // Channels/markers/tool-family/approval/skip/source/state/custom/ping the
184
+ // flow consumer never read → no callback event. (A non-terminal `error` is
185
+ // only produced on agent streams; dropping it here avoids a false
186
+ // flow_error.)
184
187
  default:
185
188
  return [];
186
189
  }
@@ -483,8 +486,9 @@ function createAgentEventTranslator() {
483
486
  case "ping":
484
487
  return [compact({ type: "agent_ping", executionId, seq, timestamp: data.timestamp })];
485
488
  // turn/text/reasoning open+close markers, step_*, artifact_*, source,
486
- // custom (fallback beat / routing), and the skill-fold result envelope
487
- // the SDK never consumed no callback event.
489
+ // state_snapshot/state_delta (agent-state channel with no stable SDK
490
+ // callback), custom (fallback beat / routing), and the skill-fold result
491
+ // envelope the SDK never consumed → no callback event.
488
492
  default:
489
493
  return [];
490
494
  }
@@ -5861,19 +5865,35 @@ var RuntypeClient = class {
5861
5865
  * normalization the `DispatchEndpoint` applies, with no per-builder call.
5862
5866
  */
5863
5867
  async dispatch(config) {
5868
+ const normalized = normalizeDispatchRequest(config);
5869
+ const request6 = transformRequest({
5870
+ ...normalized,
5871
+ options: {
5872
+ ...normalized.options,
5873
+ streamResponse: true
5874
+ }
5875
+ });
5864
5876
  return this.requestStream("/dispatch", {
5865
5877
  method: "POST",
5866
- body: JSON.stringify(transformRequest(normalizeDispatchRequest(config)))
5878
+ body: JSON.stringify(request6)
5867
5879
  });
5868
5880
  }
5869
5881
  /**
5870
5882
  * Dispatch flow execution (non-streaming JSON).
5871
5883
  *
5872
5884
  * The non-streaming sibling of {@link dispatch}; it normalizes to the same
5873
- * canonical wire contract so builders never post a raw, un-normalized body.
5885
+ * canonical wire contract so builders never post a raw, un-normalized body,
5886
+ * and pins `streamResponse: false` so the server returns buffered JSON.
5874
5887
  */
5875
5888
  async dispatchJson(config) {
5876
- return this.post("/dispatch", normalizeDispatchRequest(config));
5889
+ const normalized = normalizeDispatchRequest(config);
5890
+ return this.post("/dispatch", {
5891
+ ...normalized,
5892
+ options: {
5893
+ ...normalized.options,
5894
+ streamResponse: false
5895
+ }
5896
+ });
5877
5897
  }
5878
5898
  /**
5879
5899
  * Build full URL with query parameters
@@ -6241,7 +6261,7 @@ var Runtype = class {
6241
6261
 
6242
6262
  // src/version.ts
6243
6263
  var FALLBACK_VERSION = "0.0.0";
6244
- var SDK_VERSION = "6.4.0".length > 0 ? "6.4.0" : FALLBACK_VERSION;
6264
+ var SDK_VERSION = "6.5.1".length > 0 ? "6.5.1" : FALLBACK_VERSION;
6245
6265
  var RUNTYPE_CLIENT_KIND = "sdk";
6246
6266
  var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
6247
6267
 
@@ -8790,34 +8810,52 @@ var DispatchEndpoint = class {
8790
8810
  * Dispatch: create and/or execute flows on records atomically
8791
8811
  */
8792
8812
  async execute(data) {
8793
- return this.client.post("/dispatch", normalizeDispatchRequest(data));
8813
+ const normalized = normalizeDispatchRequest(data);
8814
+ return this.client.post("/dispatch", {
8815
+ ...normalized,
8816
+ options: {
8817
+ ...normalized.options,
8818
+ streamResponse: false
8819
+ }
8820
+ });
8794
8821
  }
8795
8822
  /**
8796
8823
  * Dispatch with streaming response
8797
8824
  */
8798
8825
  async executeStream(data) {
8826
+ const normalized = normalizeDispatchRequest(data);
8799
8827
  return this.client.requestStream("/dispatch", {
8800
8828
  method: "POST",
8801
- body: JSON.stringify(normalizeDispatchRequest(data))
8829
+ body: JSON.stringify({
8830
+ ...normalized,
8831
+ options: {
8832
+ ...normalized.options,
8833
+ streamResponse: true
8834
+ }
8835
+ })
8802
8836
  });
8803
8837
  }
8804
8838
  /**
8805
8839
  * Resume paused flow execution
8806
- * API expects snake_case field names
8840
+ * Uses buffered JSON when streamResponse is omitted.
8807
8841
  *
8808
- * @param data.execution_id - The execution ID to resume
8809
- * @param data.tool_outputs - Tool outputs to inject into the flow
8810
- * @param data.stream_response - Whether to stream the response
8842
+ * @param data.executionId - The execution ID to resume
8843
+ * @param data.toolOutputs - Tool outputs to inject into the flow
8844
+ * @param data.streamResponse - Whether to stream the response (defaults to false)
8811
8845
  * @param data.messages - Optional messages to override the original dispatch messages
8812
8846
  */
8813
8847
  async resume(data) {
8814
- if (data.streamResponse) {
8848
+ const request6 = {
8849
+ ...data,
8850
+ streamResponse: data.streamResponse ?? false
8851
+ };
8852
+ if (request6.streamResponse) {
8815
8853
  return this.client.requestStream("/dispatch/resume", {
8816
8854
  method: "POST",
8817
- body: JSON.stringify(data)
8855
+ body: JSON.stringify(request6)
8818
8856
  });
8819
8857
  }
8820
- return this.client.post("/dispatch/resume", data);
8858
+ return this.client.post("/dispatch/resume", request6);
8821
8859
  }
8822
8860
  /**
8823
8861
  * Evaluate a model-proposed runtime tool against a configurable allowlist policy.
@@ -8913,6 +8951,12 @@ var AnalyticsEndpoint = class {
8913
8951
  async getModelUsage(params) {
8914
8952
  return this.client.get("/model-usage", params);
8915
8953
  }
8954
+ /**
8955
+ * Get execution and platform-spend usage grouped by projected product end user.
8956
+ */
8957
+ async getEndUserUsage(params) {
8958
+ return this.client.get("/analytics/end-user-usage", params);
8959
+ }
8916
8960
  };
8917
8961
  var FlowStepsEndpoint = class {
8918
8962
  constructor(client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/sdk",
3
- "version": "6.4.0",
3
+ "version": "6.5.1",
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",