@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.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
AgentsEndpoint: () => AgentsEndpoint,
|
|
27
27
|
AgentsNamespace: () => AgentsNamespace,
|
|
28
28
|
AnalyticsEndpoint: () => AnalyticsEndpoint,
|
|
29
|
+
ApiKeyRequestsEndpoint: () => ApiKeyRequestsEndpoint,
|
|
29
30
|
ApiKeysEndpoint: () => ApiKeysEndpoint,
|
|
30
31
|
BatchBuilder: () => BatchBuilder,
|
|
31
32
|
BatchesNamespace: () => BatchesNamespace,
|
|
@@ -46,6 +47,8 @@ __export(index_exports, {
|
|
|
46
47
|
EvalRunner: () => EvalRunner,
|
|
47
48
|
EvalSuitesNamespace: () => EvalSuitesNamespace,
|
|
48
49
|
EvalsNamespace: () => EvalsNamespace,
|
|
50
|
+
ExecutionsEndpoint: () => ExecutionsEndpoint,
|
|
51
|
+
ExecutionsNamespace: () => ExecutionsNamespace,
|
|
49
52
|
FlowBuilder: () => FlowBuilder,
|
|
50
53
|
FlowDriftError: () => FlowDriftError,
|
|
51
54
|
FlowEnsureConflictError: () => FlowEnsureConflictError,
|
|
@@ -137,6 +140,7 @@ __export(index_exports, {
|
|
|
137
140
|
getDefaultPlanPath: () => getDefaultPlanPath,
|
|
138
141
|
getLikelySupportingCandidatePaths: () => getLikelySupportingCandidatePaths,
|
|
139
142
|
interpolateWorkflowTemplate: () => interpolateWorkflowTemplate,
|
|
143
|
+
isCatalogClientToolRef: () => isCatalogClientToolRef,
|
|
140
144
|
isDiscoveryToolName: () => isDiscoveryToolName,
|
|
141
145
|
isMarathonArtifactPath: () => isMarathonArtifactPath,
|
|
142
146
|
isPreservationSensitiveTask: () => isPreservationSensitiveTask,
|
|
@@ -404,7 +408,8 @@ function createAgentEventTranslator() {
|
|
|
404
408
|
agentName: data.agentName,
|
|
405
409
|
maxTurns: data.maxTurns,
|
|
406
410
|
startedAt: data.startedAt,
|
|
407
|
-
config: data.config
|
|
411
|
+
config: data.config,
|
|
412
|
+
resumed: data.resumed
|
|
408
413
|
})
|
|
409
414
|
];
|
|
410
415
|
case "turn_start":
|
|
@@ -542,6 +547,10 @@ function createAgentEventTranslator() {
|
|
|
542
547
|
toolName: data.toolName,
|
|
543
548
|
success: data.success,
|
|
544
549
|
result: data.result,
|
|
550
|
+
// A failure's reason travels on the frame's `error` field — the
|
|
551
|
+
// only carrier for complete-only failures like the MCP discovery
|
|
552
|
+
// connection pseudo-tool, which no longer emits an `error` frame.
|
|
553
|
+
error: str(data.error),
|
|
545
554
|
executionTime: data.executionTime
|
|
546
555
|
})
|
|
547
556
|
];
|
|
@@ -1403,6 +1412,24 @@ var FlowBuilder = class {
|
|
|
1403
1412
|
);
|
|
1404
1413
|
return this;
|
|
1405
1414
|
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Add a bounded do-while loop step.
|
|
1417
|
+
*/
|
|
1418
|
+
loop(config) {
|
|
1419
|
+
this.addStep(
|
|
1420
|
+
"loop",
|
|
1421
|
+
config.name,
|
|
1422
|
+
{
|
|
1423
|
+
steps: config.steps,
|
|
1424
|
+
until: config.until,
|
|
1425
|
+
maxIterations: config.maxIterations,
|
|
1426
|
+
iterationVariable: config.iterationVariable
|
|
1427
|
+
},
|
|
1428
|
+
config.enabled,
|
|
1429
|
+
config.when
|
|
1430
|
+
);
|
|
1431
|
+
return this;
|
|
1432
|
+
}
|
|
1406
1433
|
/**
|
|
1407
1434
|
* Add a search step
|
|
1408
1435
|
*/
|
|
@@ -3225,6 +3252,24 @@ var RuntypeFlowBuilder = class {
|
|
|
3225
3252
|
);
|
|
3226
3253
|
return this;
|
|
3227
3254
|
}
|
|
3255
|
+
/**
|
|
3256
|
+
* Add a bounded do-while loop step.
|
|
3257
|
+
*/
|
|
3258
|
+
loop(config) {
|
|
3259
|
+
this.addStep(
|
|
3260
|
+
"loop",
|
|
3261
|
+
config.name,
|
|
3262
|
+
{
|
|
3263
|
+
steps: config.steps,
|
|
3264
|
+
until: config.until,
|
|
3265
|
+
maxIterations: config.maxIterations,
|
|
3266
|
+
iterationVariable: config.iterationVariable
|
|
3267
|
+
},
|
|
3268
|
+
config.enabled,
|
|
3269
|
+
config.when
|
|
3270
|
+
);
|
|
3271
|
+
return this;
|
|
3272
|
+
}
|
|
3228
3273
|
/**
|
|
3229
3274
|
* Add a search step
|
|
3230
3275
|
*/
|
|
@@ -5151,6 +5196,16 @@ var AgentsNamespace = class {
|
|
|
5151
5196
|
}
|
|
5152
5197
|
};
|
|
5153
5198
|
|
|
5199
|
+
// src/executions-namespace.ts
|
|
5200
|
+
var ExecutionsNamespace = class {
|
|
5201
|
+
constructor(getClient) {
|
|
5202
|
+
this.getClient = getClient;
|
|
5203
|
+
}
|
|
5204
|
+
getStatus(executionId) {
|
|
5205
|
+
return this.getClient().getExecutionStatus(executionId);
|
|
5206
|
+
}
|
|
5207
|
+
};
|
|
5208
|
+
|
|
5154
5209
|
// src/tools-ensure.ts
|
|
5155
5210
|
function normalizeToolDefinition(definition) {
|
|
5156
5211
|
const parametersSchema = isPlainObject(definition.parametersSchema) ? normalizeValue(definition.parametersSchema) : {};
|
|
@@ -5895,6 +5950,11 @@ function transformQueryParams(params) {
|
|
|
5895
5950
|
return result;
|
|
5896
5951
|
}
|
|
5897
5952
|
|
|
5953
|
+
// src/types.ts
|
|
5954
|
+
function isCatalogClientToolRef(entry) {
|
|
5955
|
+
return entry.catalog === "runtype-mcp";
|
|
5956
|
+
}
|
|
5957
|
+
|
|
5898
5958
|
// src/dispatch-request.ts
|
|
5899
5959
|
function normalizeDispatchMessageContent(content) {
|
|
5900
5960
|
if (Array.isArray(content) && content.some(
|
|
@@ -5919,6 +5979,9 @@ function normalizeDispatchRequest(request6) {
|
|
|
5919
5979
|
content: normalizeDispatchMessageContent(message.content)
|
|
5920
5980
|
}));
|
|
5921
5981
|
const clientTools = request6.clientTools?.map((tool) => {
|
|
5982
|
+
if (isCatalogClientToolRef(tool)) {
|
|
5983
|
+
return tool;
|
|
5984
|
+
}
|
|
5922
5985
|
if (tool.parametersSchema.type !== "object") {
|
|
5923
5986
|
throw new Error(`Client tool "${tool.name}" parametersSchema.type must be "object"`);
|
|
5924
5987
|
}
|
|
@@ -5974,11 +6037,11 @@ var RuntypeClient = class {
|
|
|
5974
6037
|
/**
|
|
5975
6038
|
* Generic POST request
|
|
5976
6039
|
*/
|
|
5977
|
-
async post(path, data) {
|
|
6040
|
+
async post(path, data, extraHeaders) {
|
|
5978
6041
|
const url = this.buildUrl(path);
|
|
5979
6042
|
const response = await this.makeRequest(url, {
|
|
5980
6043
|
method: "POST",
|
|
5981
|
-
headers: this.headers,
|
|
6044
|
+
headers: { ...this.headers, ...extraHeaders },
|
|
5982
6045
|
body: data ? JSON.stringify(data) : void 0
|
|
5983
6046
|
});
|
|
5984
6047
|
return this.transformResponse(response);
|
|
@@ -6071,6 +6134,21 @@ var RuntypeClient = class {
|
|
|
6071
6134
|
}
|
|
6072
6135
|
});
|
|
6073
6136
|
}
|
|
6137
|
+
/** Start a normalized dispatch and return a durable handle immediately. */
|
|
6138
|
+
async dispatchAsync(config) {
|
|
6139
|
+
const normalized = normalizeDispatchRequest(config);
|
|
6140
|
+
return this.post(
|
|
6141
|
+
"/dispatch",
|
|
6142
|
+
{
|
|
6143
|
+
...normalized,
|
|
6144
|
+
options: { ...normalized.options, streamResponse: false }
|
|
6145
|
+
},
|
|
6146
|
+
{ Prefer: "respond-async" }
|
|
6147
|
+
);
|
|
6148
|
+
}
|
|
6149
|
+
async getExecutionStatus(executionId) {
|
|
6150
|
+
return this.get(`/executions/${encodeURIComponent(executionId)}/status`);
|
|
6151
|
+
}
|
|
6074
6152
|
/**
|
|
6075
6153
|
* Build full URL with query parameters
|
|
6076
6154
|
*/
|
|
@@ -6345,6 +6423,10 @@ var Runtype = class {
|
|
|
6345
6423
|
static get agents() {
|
|
6346
6424
|
return new AgentsNamespace(() => this.getClient());
|
|
6347
6425
|
}
|
|
6426
|
+
/** Poll durable handles returned by asynchronous execute operations. */
|
|
6427
|
+
static get executions() {
|
|
6428
|
+
return new ExecutionsNamespace(() => this.getClient());
|
|
6429
|
+
}
|
|
6348
6430
|
/**
|
|
6349
6431
|
* Tools namespace - Tool config-as-code (define / ensure / pull)
|
|
6350
6432
|
*
|
|
@@ -6437,7 +6519,7 @@ var Runtype = class {
|
|
|
6437
6519
|
|
|
6438
6520
|
// src/version.ts
|
|
6439
6521
|
var FALLBACK_VERSION = "0.0.0";
|
|
6440
|
-
var SDK_VERSION = "9.
|
|
6522
|
+
var SDK_VERSION = "9.2.0".length > 0 ? "9.2.0" : FALLBACK_VERSION;
|
|
6441
6523
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
6442
6524
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
6443
6525
|
|
|
@@ -8820,9 +8902,72 @@ var CollectionsEndpoint = class {
|
|
|
8820
8902
|
return this.client.get("/collections/types.d.ts");
|
|
8821
8903
|
}
|
|
8822
8904
|
};
|
|
8905
|
+
var ApiKeyRequestsEndpoint = class {
|
|
8906
|
+
constructor(client) {
|
|
8907
|
+
this.client = client;
|
|
8908
|
+
}
|
|
8909
|
+
/**
|
|
8910
|
+
* File a request. Nothing is minted; the response carries the request, the
|
|
8911
|
+
* browser handoff a human must complete, and a suggested poll interval.
|
|
8912
|
+
*/
|
|
8913
|
+
async create(data) {
|
|
8914
|
+
return this.client.post("/api-keys/requests", data);
|
|
8915
|
+
}
|
|
8916
|
+
/**
|
|
8917
|
+
* Read one request — poll this for the approval decision.
|
|
8918
|
+
*
|
|
8919
|
+
* The route answers with the `{ request, handoff? }` envelope (the handoff is
|
|
8920
|
+
* present only while a human still has to act), so unwrap it the way `list()`
|
|
8921
|
+
* unwraps `{ requests }`. Returning the envelope raw types as `ApiKeyRequest`
|
|
8922
|
+
* but has no `status`, which silently reads as `undefined` in every caller's
|
|
8923
|
+
* state machine rather than failing anywhere near here.
|
|
8924
|
+
*/
|
|
8925
|
+
async get(requestId) {
|
|
8926
|
+
const response = await this.client.get(
|
|
8927
|
+
`/api-keys/requests/${requestId}`
|
|
8928
|
+
);
|
|
8929
|
+
return response.request;
|
|
8930
|
+
}
|
|
8931
|
+
/**
|
|
8932
|
+
* Read one request together with its browser handoff. Same route as `get()`;
|
|
8933
|
+
* use this when re-raising the approval prompt for a request this process did
|
|
8934
|
+
* not file (the handoff is absent once the request leaves `pending`).
|
|
8935
|
+
*/
|
|
8936
|
+
async getWithHandoff(requestId) {
|
|
8937
|
+
return this.client.get(`/api-keys/requests/${requestId}`);
|
|
8938
|
+
}
|
|
8939
|
+
/**
|
|
8940
|
+
* List requests for the account. Clerk-session surface (the human review
|
|
8941
|
+
* queue); an API key sees only its own requests.
|
|
8942
|
+
*/
|
|
8943
|
+
async list(params) {
|
|
8944
|
+
const response = await this.client.get(
|
|
8945
|
+
"/api-keys/requests",
|
|
8946
|
+
params
|
|
8947
|
+
);
|
|
8948
|
+
return response.requests;
|
|
8949
|
+
}
|
|
8950
|
+
/**
|
|
8951
|
+
* Redeem an approved request. The key is minted here and returned exactly
|
|
8952
|
+
* once: `delivery: 'inline'` (the API default) puts the plaintext in
|
|
8953
|
+
* `apiKey`; `delivery: 'secret'` stores it as a Runtype secret and returns
|
|
8954
|
+
* only a `{{secret:KEY}}` reference in `secretRef`. Claiming twice is a 409.
|
|
8955
|
+
*/
|
|
8956
|
+
async claim(requestId, data) {
|
|
8957
|
+
return this.client.post(
|
|
8958
|
+
`/api-keys/requests/${requestId}/claim`,
|
|
8959
|
+
data
|
|
8960
|
+
);
|
|
8961
|
+
}
|
|
8962
|
+
/** Withdraw a pending request you filed. Cannot be undone. */
|
|
8963
|
+
async cancel(requestId) {
|
|
8964
|
+
return this.client.post(`/api-keys/requests/${requestId}/cancel`);
|
|
8965
|
+
}
|
|
8966
|
+
};
|
|
8823
8967
|
var ApiKeysEndpoint = class {
|
|
8824
8968
|
constructor(client) {
|
|
8825
8969
|
this.client = client;
|
|
8970
|
+
this.requests = new ApiKeyRequestsEndpoint(client);
|
|
8826
8971
|
}
|
|
8827
8972
|
/**
|
|
8828
8973
|
* List all API keys for the authenticated user
|
|
@@ -9077,6 +9222,18 @@ var DispatchEndpoint = class {
|
|
|
9077
9222
|
}
|
|
9078
9223
|
});
|
|
9079
9224
|
}
|
|
9225
|
+
/** Start a dispatch and return its durable execution handle immediately. */
|
|
9226
|
+
async executeAsync(data) {
|
|
9227
|
+
const normalized = normalizeDispatchRequest(data);
|
|
9228
|
+
return this.client.post(
|
|
9229
|
+
"/dispatch",
|
|
9230
|
+
{
|
|
9231
|
+
...normalized,
|
|
9232
|
+
options: { ...normalized.options, streamResponse: false }
|
|
9233
|
+
},
|
|
9234
|
+
{ Prefer: "respond-async" }
|
|
9235
|
+
);
|
|
9236
|
+
}
|
|
9080
9237
|
/**
|
|
9081
9238
|
* Dispatch with streaming response
|
|
9082
9239
|
*/
|
|
@@ -9144,6 +9301,16 @@ var DispatchEndpoint = class {
|
|
|
9144
9301
|
return applyGeneratedRuntimeToolProposalToDispatchRequest(request6, proposal, options);
|
|
9145
9302
|
}
|
|
9146
9303
|
};
|
|
9304
|
+
var ExecutionsEndpoint = class {
|
|
9305
|
+
constructor(client) {
|
|
9306
|
+
this.client = client;
|
|
9307
|
+
}
|
|
9308
|
+
async getStatus(executionId) {
|
|
9309
|
+
return this.client.get(
|
|
9310
|
+
`/executions/${encodeURIComponent(executionId)}/status`
|
|
9311
|
+
);
|
|
9312
|
+
}
|
|
9313
|
+
};
|
|
9147
9314
|
var ChatEndpoint = class {
|
|
9148
9315
|
constructor(client) {
|
|
9149
9316
|
this.client = client;
|
|
@@ -9833,6 +10000,14 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
9833
10000
|
streamResponse: false
|
|
9834
10001
|
});
|
|
9835
10002
|
}
|
|
10003
|
+
/** Start an agent execution and return its durable handle immediately. */
|
|
10004
|
+
async executeAsync(id, data) {
|
|
10005
|
+
return this.client.post(
|
|
10006
|
+
`/agents/${id}/execute`,
|
|
10007
|
+
{ ...data, streamResponse: false },
|
|
10008
|
+
{ Prefer: "respond-async" }
|
|
10009
|
+
);
|
|
10010
|
+
}
|
|
9836
10011
|
/**
|
|
9837
10012
|
* Execute an agent with streaming response
|
|
9838
10013
|
*
|
|
@@ -10005,7 +10180,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
10005
10180
|
...callbacks,
|
|
10006
10181
|
onAgentStart: (event) => {
|
|
10007
10182
|
lastSeenExecutionId = event.executionId;
|
|
10008
|
-
callbacks?.onAgentStart?.(event);
|
|
10183
|
+
if (!event.resumed) callbacks?.onAgentStart?.(event);
|
|
10009
10184
|
},
|
|
10010
10185
|
onTurnDelta: (event) => {
|
|
10011
10186
|
if (event.contentType === "text") {
|
|
@@ -12999,9 +13174,7 @@ function assertTurnScopedLocalTools(localTools) {
|
|
|
12999
13174
|
);
|
|
13000
13175
|
}
|
|
13001
13176
|
if (entry.parametersSchema.type !== "object") {
|
|
13002
|
-
throw new Error(
|
|
13003
|
-
`Turn-scoped local tool "${name}" parametersSchema.type must be "object"`
|
|
13004
|
-
);
|
|
13177
|
+
throw new Error(`Turn-scoped local tool "${name}" parametersSchema.type must be "object"`);
|
|
13005
13178
|
}
|
|
13006
13179
|
}
|
|
13007
13180
|
}
|
|
@@ -13037,6 +13210,7 @@ var RuntypeClient2 = class {
|
|
|
13037
13210
|
this.modelConfigs = new ModelConfigsEndpoint(this);
|
|
13038
13211
|
this.providerKeys = new ProviderKeysEndpoint(this);
|
|
13039
13212
|
this.dispatch = new DispatchEndpoint(this);
|
|
13213
|
+
this.executions = new ExecutionsEndpoint(this);
|
|
13040
13214
|
this.chat = new ChatEndpoint(this);
|
|
13041
13215
|
this.users = new UsersEndpoint(this);
|
|
13042
13216
|
this.analytics = new AnalyticsEndpoint(this);
|
|
@@ -13304,11 +13478,11 @@ var RuntypeClient2 = class {
|
|
|
13304
13478
|
/**
|
|
13305
13479
|
* Generic POST request
|
|
13306
13480
|
*/
|
|
13307
|
-
async post(path, data) {
|
|
13481
|
+
async post(path, data, extraHeaders) {
|
|
13308
13482
|
const url = this.buildUrl(path);
|
|
13309
13483
|
const response = await this.makeRequest(url, {
|
|
13310
13484
|
method: "POST",
|
|
13311
|
-
headers: this.headers,
|
|
13485
|
+
headers: { ...this.headers, ...extraHeaders },
|
|
13312
13486
|
body: data ? JSON.stringify(transformRequest(data)) : void 0
|
|
13313
13487
|
});
|
|
13314
13488
|
return transformResponse(response);
|
|
@@ -13903,6 +14077,12 @@ var CONDITIONAL_FIELDS = [
|
|
|
13903
14077
|
{ key: "trueSteps", format: "value" },
|
|
13904
14078
|
{ key: "falseSteps", format: "value" }
|
|
13905
14079
|
];
|
|
14080
|
+
var LOOP_FIELDS = [
|
|
14081
|
+
{ key: "steps", format: "value" },
|
|
14082
|
+
{ key: "until", format: "template" },
|
|
14083
|
+
{ key: "maxIterations", format: "raw" },
|
|
14084
|
+
{ key: "iterationVariable", format: "json" }
|
|
14085
|
+
];
|
|
13906
14086
|
var SEARCH_FIELDS = [
|
|
13907
14087
|
{ key: "provider", format: "json" },
|
|
13908
14088
|
{ key: "query", format: "template" },
|
|
@@ -14194,6 +14374,7 @@ var STEP_FIELD_REGISTRY = {
|
|
|
14194
14374
|
"transform-data": TRANSFORM_DATA_FIELDS,
|
|
14195
14375
|
"set-variable": SET_VARIABLE_FIELDS,
|
|
14196
14376
|
conditional: CONDITIONAL_FIELDS,
|
|
14377
|
+
loop: LOOP_FIELDS,
|
|
14197
14378
|
search: SEARCH_FIELDS,
|
|
14198
14379
|
"send-email": SEND_EMAIL_FIELDS,
|
|
14199
14380
|
"send-stream": SEND_STREAM_FIELDS,
|
|
@@ -14228,6 +14409,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
14228
14409
|
"transform-data": "transformData",
|
|
14229
14410
|
template: "template",
|
|
14230
14411
|
conditional: "conditional",
|
|
14412
|
+
loop: "loop",
|
|
14231
14413
|
"set-variable": "setVariable",
|
|
14232
14414
|
"upsert-record": "upsertRecord",
|
|
14233
14415
|
"update-record": "updateRecord",
|
|
@@ -14256,6 +14438,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
14256
14438
|
AgentsEndpoint,
|
|
14257
14439
|
AgentsNamespace,
|
|
14258
14440
|
AnalyticsEndpoint,
|
|
14441
|
+
ApiKeyRequestsEndpoint,
|
|
14259
14442
|
ApiKeysEndpoint,
|
|
14260
14443
|
BatchBuilder,
|
|
14261
14444
|
BatchesNamespace,
|
|
@@ -14276,6 +14459,8 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
14276
14459
|
EvalRunner,
|
|
14277
14460
|
EvalSuitesNamespace,
|
|
14278
14461
|
EvalsNamespace,
|
|
14462
|
+
ExecutionsEndpoint,
|
|
14463
|
+
ExecutionsNamespace,
|
|
14279
14464
|
FlowBuilder,
|
|
14280
14465
|
FlowDriftError,
|
|
14281
14466
|
FlowEnsureConflictError,
|
|
@@ -14367,6 +14552,7 @@ var STEP_TYPE_TO_METHOD = {
|
|
|
14367
14552
|
getDefaultPlanPath,
|
|
14368
14553
|
getLikelySupportingCandidatePaths,
|
|
14369
14554
|
interpolateWorkflowTemplate,
|
|
14555
|
+
isCatalogClientToolRef,
|
|
14370
14556
|
isDiscoveryToolName,
|
|
14371
14557
|
isMarathonArtifactPath,
|
|
14372
14558
|
isPreservationSensitiveTask,
|