@runtypelabs/sdk 9.1.0 → 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.cjs +196 -10
- package/dist/index.d.cts +661 -61
- package/dist/index.d.ts +661 -61
- package/dist/index.mjs +192 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -216,7 +216,8 @@ function createAgentEventTranslator() {
|
|
|
216
216
|
agentName: data.agentName,
|
|
217
217
|
maxTurns: data.maxTurns,
|
|
218
218
|
startedAt: data.startedAt,
|
|
219
|
-
config: data.config
|
|
219
|
+
config: data.config,
|
|
220
|
+
resumed: data.resumed
|
|
220
221
|
})
|
|
221
222
|
];
|
|
222
223
|
case "turn_start":
|
|
@@ -354,6 +355,10 @@ function createAgentEventTranslator() {
|
|
|
354
355
|
toolName: data.toolName,
|
|
355
356
|
success: data.success,
|
|
356
357
|
result: data.result,
|
|
358
|
+
// A failure's reason travels on the frame's `error` field — the
|
|
359
|
+
// only carrier for complete-only failures like the MCP discovery
|
|
360
|
+
// connection pseudo-tool, which no longer emits an `error` frame.
|
|
361
|
+
error: str(data.error),
|
|
357
362
|
executionTime: data.executionTime
|
|
358
363
|
})
|
|
359
364
|
];
|
|
@@ -1215,6 +1220,24 @@ var FlowBuilder = class {
|
|
|
1215
1220
|
);
|
|
1216
1221
|
return this;
|
|
1217
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
|
+
}
|
|
1218
1241
|
/**
|
|
1219
1242
|
* Add a search step
|
|
1220
1243
|
*/
|
|
@@ -3037,6 +3060,24 @@ var RuntypeFlowBuilder = class {
|
|
|
3037
3060
|
);
|
|
3038
3061
|
return this;
|
|
3039
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
|
+
}
|
|
3040
3081
|
/**
|
|
3041
3082
|
* Add a search step
|
|
3042
3083
|
*/
|
|
@@ -4963,6 +5004,16 @@ var AgentsNamespace = class {
|
|
|
4963
5004
|
}
|
|
4964
5005
|
};
|
|
4965
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
|
+
|
|
4966
5017
|
// src/tools-ensure.ts
|
|
4967
5018
|
function normalizeToolDefinition(definition) {
|
|
4968
5019
|
const parametersSchema = isPlainObject(definition.parametersSchema) ? normalizeValue(definition.parametersSchema) : {};
|
|
@@ -5707,6 +5758,11 @@ function transformQueryParams(params) {
|
|
|
5707
5758
|
return result;
|
|
5708
5759
|
}
|
|
5709
5760
|
|
|
5761
|
+
// src/types.ts
|
|
5762
|
+
function isCatalogClientToolRef(entry) {
|
|
5763
|
+
return entry.catalog === "runtype-mcp";
|
|
5764
|
+
}
|
|
5765
|
+
|
|
5710
5766
|
// src/dispatch-request.ts
|
|
5711
5767
|
function normalizeDispatchMessageContent(content) {
|
|
5712
5768
|
if (Array.isArray(content) && content.some(
|
|
@@ -5731,6 +5787,9 @@ function normalizeDispatchRequest(request6) {
|
|
|
5731
5787
|
content: normalizeDispatchMessageContent(message.content)
|
|
5732
5788
|
}));
|
|
5733
5789
|
const clientTools = request6.clientTools?.map((tool) => {
|
|
5790
|
+
if (isCatalogClientToolRef(tool)) {
|
|
5791
|
+
return tool;
|
|
5792
|
+
}
|
|
5734
5793
|
if (tool.parametersSchema.type !== "object") {
|
|
5735
5794
|
throw new Error(`Client tool "${tool.name}" parametersSchema.type must be "object"`);
|
|
5736
5795
|
}
|
|
@@ -5786,11 +5845,11 @@ var RuntypeClient = class {
|
|
|
5786
5845
|
/**
|
|
5787
5846
|
* Generic POST request
|
|
5788
5847
|
*/
|
|
5789
|
-
async post(path, data) {
|
|
5848
|
+
async post(path, data, extraHeaders) {
|
|
5790
5849
|
const url = this.buildUrl(path);
|
|
5791
5850
|
const response = await this.makeRequest(url, {
|
|
5792
5851
|
method: "POST",
|
|
5793
|
-
headers: this.headers,
|
|
5852
|
+
headers: { ...this.headers, ...extraHeaders },
|
|
5794
5853
|
body: data ? JSON.stringify(data) : void 0
|
|
5795
5854
|
});
|
|
5796
5855
|
return this.transformResponse(response);
|
|
@@ -5883,6 +5942,21 @@ var RuntypeClient = class {
|
|
|
5883
5942
|
}
|
|
5884
5943
|
});
|
|
5885
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
|
+
}
|
|
5886
5960
|
/**
|
|
5887
5961
|
* Build full URL with query parameters
|
|
5888
5962
|
*/
|
|
@@ -6157,6 +6231,10 @@ var Runtype = class {
|
|
|
6157
6231
|
static get agents() {
|
|
6158
6232
|
return new AgentsNamespace(() => this.getClient());
|
|
6159
6233
|
}
|
|
6234
|
+
/** Poll durable handles returned by asynchronous execute operations. */
|
|
6235
|
+
static get executions() {
|
|
6236
|
+
return new ExecutionsNamespace(() => this.getClient());
|
|
6237
|
+
}
|
|
6160
6238
|
/**
|
|
6161
6239
|
* Tools namespace - Tool config-as-code (define / ensure / pull)
|
|
6162
6240
|
*
|
|
@@ -6249,7 +6327,7 @@ var Runtype = class {
|
|
|
6249
6327
|
|
|
6250
6328
|
// src/version.ts
|
|
6251
6329
|
var FALLBACK_VERSION = "0.0.0";
|
|
6252
|
-
var SDK_VERSION = "9.
|
|
6330
|
+
var SDK_VERSION = "9.2.0".length > 0 ? "9.2.0" : FALLBACK_VERSION;
|
|
6253
6331
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
6254
6332
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
6255
6333
|
|
|
@@ -8632,9 +8710,72 @@ var CollectionsEndpoint = class {
|
|
|
8632
8710
|
return this.client.get("/collections/types.d.ts");
|
|
8633
8711
|
}
|
|
8634
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
|
+
};
|
|
8635
8775
|
var ApiKeysEndpoint = class {
|
|
8636
8776
|
constructor(client) {
|
|
8637
8777
|
this.client = client;
|
|
8778
|
+
this.requests = new ApiKeyRequestsEndpoint(client);
|
|
8638
8779
|
}
|
|
8639
8780
|
/**
|
|
8640
8781
|
* List all API keys for the authenticated user
|
|
@@ -8889,6 +9030,18 @@ var DispatchEndpoint = class {
|
|
|
8889
9030
|
}
|
|
8890
9031
|
});
|
|
8891
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
|
+
}
|
|
8892
9045
|
/**
|
|
8893
9046
|
* Dispatch with streaming response
|
|
8894
9047
|
*/
|
|
@@ -8956,6 +9109,16 @@ var DispatchEndpoint = class {
|
|
|
8956
9109
|
return applyGeneratedRuntimeToolProposalToDispatchRequest(request6, proposal, options);
|
|
8957
9110
|
}
|
|
8958
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
|
+
};
|
|
8959
9122
|
var ChatEndpoint = class {
|
|
8960
9123
|
constructor(client) {
|
|
8961
9124
|
this.client = client;
|
|
@@ -9645,6 +9808,14 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
9645
9808
|
streamResponse: false
|
|
9646
9809
|
});
|
|
9647
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
|
+
}
|
|
9648
9819
|
/**
|
|
9649
9820
|
* Execute an agent with streaming response
|
|
9650
9821
|
*
|
|
@@ -9817,7 +9988,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
9817
9988
|
...callbacks,
|
|
9818
9989
|
onAgentStart: (event) => {
|
|
9819
9990
|
lastSeenExecutionId = event.executionId;
|
|
9820
|
-
callbacks?.onAgentStart?.(event);
|
|
9991
|
+
if (!event.resumed) callbacks?.onAgentStart?.(event);
|
|
9821
9992
|
},
|
|
9822
9993
|
onTurnDelta: (event) => {
|
|
9823
9994
|
if (event.contentType === "text") {
|
|
@@ -12811,9 +12982,7 @@ function assertTurnScopedLocalTools(localTools) {
|
|
|
12811
12982
|
);
|
|
12812
12983
|
}
|
|
12813
12984
|
if (entry.parametersSchema.type !== "object") {
|
|
12814
|
-
throw new Error(
|
|
12815
|
-
`Turn-scoped local tool "${name}" parametersSchema.type must be "object"`
|
|
12816
|
-
);
|
|
12985
|
+
throw new Error(`Turn-scoped local tool "${name}" parametersSchema.type must be "object"`);
|
|
12817
12986
|
}
|
|
12818
12987
|
}
|
|
12819
12988
|
}
|
|
@@ -12849,6 +13018,7 @@ var RuntypeClient2 = class {
|
|
|
12849
13018
|
this.modelConfigs = new ModelConfigsEndpoint(this);
|
|
12850
13019
|
this.providerKeys = new ProviderKeysEndpoint(this);
|
|
12851
13020
|
this.dispatch = new DispatchEndpoint(this);
|
|
13021
|
+
this.executions = new ExecutionsEndpoint(this);
|
|
12852
13022
|
this.chat = new ChatEndpoint(this);
|
|
12853
13023
|
this.users = new UsersEndpoint(this);
|
|
12854
13024
|
this.analytics = new AnalyticsEndpoint(this);
|
|
@@ -13116,11 +13286,11 @@ var RuntypeClient2 = class {
|
|
|
13116
13286
|
/**
|
|
13117
13287
|
* Generic POST request
|
|
13118
13288
|
*/
|
|
13119
|
-
async post(path, data) {
|
|
13289
|
+
async post(path, data, extraHeaders) {
|
|
13120
13290
|
const url = this.buildUrl(path);
|
|
13121
13291
|
const response = await this.makeRequest(url, {
|
|
13122
13292
|
method: "POST",
|
|
13123
|
-
headers: this.headers,
|
|
13293
|
+
headers: { ...this.headers, ...extraHeaders },
|
|
13124
13294
|
body: data ? JSON.stringify(transformRequest(data)) : void 0
|
|
13125
13295
|
});
|
|
13126
13296
|
return transformResponse(response);
|
|
@@ -13715,6 +13885,12 @@ var CONDITIONAL_FIELDS = [
|
|
|
13715
13885
|
{ key: "trueSteps", format: "value" },
|
|
13716
13886
|
{ key: "falseSteps", format: "value" }
|
|
13717
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
|
+
];
|
|
13718
13894
|
var SEARCH_FIELDS = [
|
|
13719
13895
|
{ key: "provider", format: "json" },
|
|
13720
13896
|
{ key: "query", format: "template" },
|
|
@@ -14006,6 +14182,7 @@ var STEP_FIELD_REGISTRY = {
|
|
|
14006
14182
|
"transform-data": TRANSFORM_DATA_FIELDS,
|
|
14007
14183
|
"set-variable": SET_VARIABLE_FIELDS,
|
|
14008
14184
|
conditional: CONDITIONAL_FIELDS,
|
|
14185
|
+
loop: LOOP_FIELDS,
|
|
14009
14186
|
search: SEARCH_FIELDS,
|
|
14010
14187
|
"send-email": SEND_EMAIL_FIELDS,
|
|
14011
14188
|
"send-stream": SEND_STREAM_FIELDS,
|
|
@@ -14040,6 +14217,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
14040
14217
|
"transform-data": "transformData",
|
|
14041
14218
|
template: "template",
|
|
14042
14219
|
conditional: "conditional",
|
|
14220
|
+
loop: "loop",
|
|
14043
14221
|
"set-variable": "setVariable",
|
|
14044
14222
|
"upsert-record": "upsertRecord",
|
|
14045
14223
|
"update-record": "updateRecord",
|
|
@@ -14067,6 +14245,7 @@ export {
|
|
|
14067
14245
|
AgentsEndpoint,
|
|
14068
14246
|
AgentsNamespace,
|
|
14069
14247
|
AnalyticsEndpoint,
|
|
14248
|
+
ApiKeyRequestsEndpoint,
|
|
14070
14249
|
ApiKeysEndpoint,
|
|
14071
14250
|
BatchBuilder,
|
|
14072
14251
|
BatchesNamespace,
|
|
@@ -14087,6 +14266,8 @@ export {
|
|
|
14087
14266
|
EvalRunner,
|
|
14088
14267
|
EvalSuitesNamespace,
|
|
14089
14268
|
EvalsNamespace,
|
|
14269
|
+
ExecutionsEndpoint,
|
|
14270
|
+
ExecutionsNamespace,
|
|
14090
14271
|
FlowBuilder,
|
|
14091
14272
|
FlowDriftError,
|
|
14092
14273
|
FlowEnsureConflictError,
|
|
@@ -14178,6 +14359,7 @@ export {
|
|
|
14178
14359
|
getDefaultPlanPath,
|
|
14179
14360
|
getLikelySupportingCandidatePaths,
|
|
14180
14361
|
interpolateWorkflowTemplate,
|
|
14362
|
+
isCatalogClientToolRef,
|
|
14181
14363
|
isDiscoveryToolName,
|
|
14182
14364
|
isMarathonArtifactPath,
|
|
14183
14365
|
isPreservationSensitiveTask,
|
package/package.json
CHANGED