@runtypelabs/sdk 9.3.0 → 9.3.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/CHANGELOG.md +3441 -0
- package/dist/index.cjs +20 -80
- package/dist/index.d.cts +56 -626
- package/dist/index.d.ts +56 -626
- package/dist/index.mjs +20 -80
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -375,10 +375,7 @@ function createFlowEventTranslator() {
|
|
|
375
375
|
pageOrigin: data.pageOrigin
|
|
376
376
|
})
|
|
377
377
|
];
|
|
378
|
-
//
|
|
379
|
-
// flow consumer never read → no callback event. (A non-terminal `error` is
|
|
380
|
-
// only produced on agent streams; dropping it here avoids a false
|
|
381
|
-
// flow_error.)
|
|
378
|
+
// WHY(docs/why/packages/client/src.md#default-case-drops-events-the-flow-consumer-neve): Default case drops events the flow consumer never reads; a non-terminal error is agent-only, dropped here.
|
|
382
379
|
default:
|
|
383
380
|
return [];
|
|
384
381
|
}
|
|
@@ -550,9 +547,7 @@ function createAgentEventTranslator() {
|
|
|
550
547
|
toolName: data.toolName,
|
|
551
548
|
success: data.success,
|
|
552
549
|
result: data.result,
|
|
553
|
-
// A failure's reason travels on the
|
|
554
|
-
// only carrier for complete-only failures like the MCP discovery
|
|
555
|
-
// connection pseudo-tool, which no longer emits an `error` frame.
|
|
550
|
+
// WHY(docs/why/packages/client/src.md#a-failures-reason-travels-on-error-the-only-carr): A failure's reason travels on `error`, the only carrier for complete-only MCP discovery failures.
|
|
556
551
|
error: str(data.error),
|
|
557
552
|
executionTime: data.executionTime
|
|
558
553
|
})
|
|
@@ -689,10 +684,7 @@ function createAgentEventTranslator() {
|
|
|
689
684
|
];
|
|
690
685
|
case "ping":
|
|
691
686
|
return [compact({ type: "agent_ping", executionId, seq, timestamp: data.timestamp })];
|
|
692
|
-
//
|
|
693
|
-
// state_snapshot/state_delta (agent-state channel with no stable SDK
|
|
694
|
-
// callback), custom (fallback beat / routing), and the skill-fold result
|
|
695
|
-
// envelope the SDK never consumed → no callback event.
|
|
687
|
+
// WHY(docs/why/packages/client/src.md#default-case-lists-every-channel-type-the-sdk-ca): Default case lists every channel type the SDK callback surface never consumed, so it maps to nothing.
|
|
696
688
|
default:
|
|
697
689
|
return [];
|
|
698
690
|
}
|
|
@@ -1247,9 +1239,6 @@ var FlowBuilder = class {
|
|
|
1247
1239
|
);
|
|
1248
1240
|
return this;
|
|
1249
1241
|
}
|
|
1250
|
-
// ============================================================================
|
|
1251
|
-
// Step Methods
|
|
1252
|
-
// ============================================================================
|
|
1253
1242
|
/**
|
|
1254
1243
|
* Add a prompt step
|
|
1255
1244
|
*/
|
|
@@ -1748,9 +1737,6 @@ var FlowBuilder = class {
|
|
|
1748
1737
|
memorySummary(config) {
|
|
1749
1738
|
return this.addRawStep("memory-summary", config);
|
|
1750
1739
|
}
|
|
1751
|
-
// ============================================================================
|
|
1752
|
-
// Subagent Helpers
|
|
1753
|
-
// ============================================================================
|
|
1754
1740
|
/**
|
|
1755
1741
|
* Attach a subagent runtime tool to the most recent prompt step.
|
|
1756
1742
|
*
|
|
@@ -1845,9 +1831,6 @@ var FlowBuilder = class {
|
|
|
1845
1831
|
lastStep.config.tools = { ...existingTools, subagentConfig: opts };
|
|
1846
1832
|
return this;
|
|
1847
1833
|
}
|
|
1848
|
-
// ============================================================================
|
|
1849
|
-
// Build Method
|
|
1850
|
-
// ============================================================================
|
|
1851
1834
|
/**
|
|
1852
1835
|
* Build the final dispatch request configuration
|
|
1853
1836
|
*/
|
|
@@ -1938,9 +1921,6 @@ var FlowBuilder = class {
|
|
|
1938
1921
|
if (lastStep) lastStep.when = expression;
|
|
1939
1922
|
return this;
|
|
1940
1923
|
}
|
|
1941
|
-
// ============================================================================
|
|
1942
|
-
// Private Helpers
|
|
1943
|
-
// ============================================================================
|
|
1944
1924
|
addRawStep(type, config) {
|
|
1945
1925
|
const { name, enabled, when, ...stepConfig } = config;
|
|
1946
1926
|
this.addStep(type, name, stepConfig, enabled, when);
|
|
@@ -2144,7 +2124,6 @@ var CHECK_GRADER_KINDS = /* @__PURE__ */ new Set([
|
|
|
2144
2124
|
"length",
|
|
2145
2125
|
"latency",
|
|
2146
2126
|
"no_error",
|
|
2147
|
-
// Trace checks.
|
|
2148
2127
|
"called_tool",
|
|
2149
2128
|
"not_called_tool",
|
|
2150
2129
|
"used_no_tools",
|
|
@@ -2428,7 +2407,8 @@ function normalizeCaseInput(input, where) {
|
|
|
2428
2407
|
const mock = { toolName: m.toolName, output: m.output };
|
|
2429
2408
|
if (m.input !== void 0) mock.input = m.input;
|
|
2430
2409
|
if (typeof m.isError === "boolean") mock.isError = m.isError;
|
|
2431
|
-
if (typeof m.sourceToolExecutionId === "string")
|
|
2410
|
+
if (typeof m.sourceToolExecutionId === "string")
|
|
2411
|
+
mock.sourceToolExecutionId = m.sourceToolExecutionId;
|
|
2432
2412
|
if (typeof m.truncated === "boolean") mock.truncated = m.truncated;
|
|
2433
2413
|
return mock;
|
|
2434
2414
|
});
|
|
@@ -2533,7 +2513,7 @@ async function computeEvalContentHash(definition) {
|
|
|
2533
2513
|
name: c.name,
|
|
2534
2514
|
input: normalizeForHash(c.input),
|
|
2535
2515
|
...c.expected !== void 0 ? { expected: normalizeForHash(c.expected) } : {},
|
|
2536
|
-
// Grader order preserved on purpose
|
|
2516
|
+
// INVARIANT: Grader order is preserved on purpose; it maps to the result index.
|
|
2537
2517
|
expect: c.expect.map((g) => normalizeForHash(g))
|
|
2538
2518
|
}))
|
|
2539
2519
|
};
|
|
@@ -2739,8 +2719,7 @@ function defineFlow(input) {
|
|
|
2739
2719
|
return {
|
|
2740
2720
|
type: step.type,
|
|
2741
2721
|
name: step.name,
|
|
2742
|
-
// Explicit 1-based order
|
|
2743
|
-
// probe hash agrees with the server's persisted step order.
|
|
2722
|
+
// WHY(docs/why/packages/client/src.md#explicit-1-based-order-matches-the-flow-builders): Explicit 1-based order matches the flow builder's convention so the local hash agrees with the server
|
|
2744
2723
|
order: typeof step.order === "number" ? step.order : index + 1,
|
|
2745
2724
|
...step.enabled !== void 0 ? { enabled: step.enabled } : {},
|
|
2746
2725
|
...typeof step.when === "string" ? { when: step.when } : {},
|
|
@@ -3042,9 +3021,6 @@ var RuntypeFlowBuilder = class {
|
|
|
3042
3021
|
this.flowConfig = { name: "Untitled Flow" };
|
|
3043
3022
|
}
|
|
3044
3023
|
}
|
|
3045
|
-
// ============================================================================
|
|
3046
|
-
// Configuration Methods
|
|
3047
|
-
// ============================================================================
|
|
3048
3024
|
/**
|
|
3049
3025
|
* Set the record configuration
|
|
3050
3026
|
*/
|
|
@@ -3088,9 +3064,6 @@ var RuntypeFlowBuilder = class {
|
|
|
3088
3064
|
);
|
|
3089
3065
|
return this;
|
|
3090
3066
|
}
|
|
3091
|
-
// ============================================================================
|
|
3092
|
-
// Step Methods
|
|
3093
|
-
// ============================================================================
|
|
3094
3067
|
/**
|
|
3095
3068
|
* Add a prompt step
|
|
3096
3069
|
*/
|
|
@@ -3874,9 +3847,6 @@ var RuntypeFlowBuilder = class {
|
|
|
3874
3847
|
"Use Runtype.flows.virtual(...) or Runtype.flows.upsert(...) with inline steps to validate a flow before saving."
|
|
3875
3848
|
);
|
|
3876
3849
|
}
|
|
3877
|
-
// ============================================================================
|
|
3878
|
-
// Private Helpers
|
|
3879
|
-
// ============================================================================
|
|
3880
3850
|
/**
|
|
3881
3851
|
* Persisted flow protocol (APQ-style): send hash-only first, retry with
|
|
3882
3852
|
* full definition on FLOW_DEFINITION_REQUIRED. For non-upsert modes,
|
|
@@ -6239,9 +6209,6 @@ var RuntypeClient = class {
|
|
|
6239
6209
|
}
|
|
6240
6210
|
};
|
|
6241
6211
|
var Runtype = class {
|
|
6242
|
-
// ============================================================================
|
|
6243
|
-
// Global Configuration
|
|
6244
|
-
// ============================================================================
|
|
6245
6212
|
/**
|
|
6246
6213
|
* Configure the global Runtype client
|
|
6247
6214
|
*
|
|
@@ -6279,9 +6246,6 @@ var Runtype = class {
|
|
|
6279
6246
|
static createClient(config) {
|
|
6280
6247
|
return new RuntypeClient({ ...globalConfig, ...config });
|
|
6281
6248
|
}
|
|
6282
|
-
// ============================================================================
|
|
6283
|
-
// Static Namespaces
|
|
6284
|
-
// ============================================================================
|
|
6285
6249
|
/**
|
|
6286
6250
|
* Flows namespace - Build and execute flows
|
|
6287
6251
|
*
|
|
@@ -6523,7 +6487,7 @@ var Runtype = class {
|
|
|
6523
6487
|
|
|
6524
6488
|
// src/version.ts
|
|
6525
6489
|
var FALLBACK_VERSION = "0.0.0";
|
|
6526
|
-
var SDK_VERSION = "9.3.
|
|
6490
|
+
var SDK_VERSION = "9.3.1".length > 0 ? "9.3.1" : FALLBACK_VERSION;
|
|
6527
6491
|
var RUNTYPE_CLIENT_KIND = "sdk";
|
|
6528
6492
|
var SDK_USER_AGENT = `runtype-sdk/${SDK_VERSION} (typescript)`;
|
|
6529
6493
|
|
|
@@ -6617,8 +6581,7 @@ function withDetachedReconnect(response, reattach, options = {}) {
|
|
|
6617
6581
|
if (cancelled) break;
|
|
6618
6582
|
current = await reattach({
|
|
6619
6583
|
executionId: observed.executionId,
|
|
6620
|
-
//
|
|
6621
|
-
// that produced no cursor at all.
|
|
6584
|
+
// WHY(docs/why/packages/client/src.md#0-replays-the-whole-turn-the-fail-open-answer-fo): '0' replays the whole turn, the fail-open answer for a leg that produced no cursor.
|
|
6622
6585
|
after: observed.lastId ?? "0",
|
|
6623
6586
|
signal: abort.signal
|
|
6624
6587
|
});
|
|
@@ -6939,11 +6902,7 @@ function attachRuntimeToolsToDispatchRequest(request6, runtimeTools, options = {
|
|
|
6939
6902
|
...request6,
|
|
6940
6903
|
flow: {
|
|
6941
6904
|
...flow,
|
|
6942
|
-
//
|
|
6943
|
-
// `FlowStepDefinition[]`); only the prompt step's `config.tools` was
|
|
6944
|
-
// merged, so every step's `type` discriminant is preserved. The clone is
|
|
6945
|
-
// intentionally built as loose records to merge tool config opaquely, so
|
|
6946
|
-
// re-narrow to the typed step shape at this boundary.
|
|
6905
|
+
// WHY(docs/why/packages/client/src.md#clonedsteps-preserves-each-steps-type-discrimina): clonedSteps preserves each step's type discriminant; re-narrow from loose records here
|
|
6947
6906
|
steps: clonedSteps
|
|
6948
6907
|
}
|
|
6949
6908
|
};
|
|
@@ -8207,13 +8166,7 @@ function ensureDefaultWorkflowHooks() {
|
|
|
8207
8166
|
}
|
|
8208
8167
|
var defaultWorkflowConfig = {
|
|
8209
8168
|
name: "default",
|
|
8210
|
-
//
|
|
8211
|
-
// narration-only sessions ("I'll create the files now" with no tool calls)
|
|
8212
|
-
// escalate here even though the phase recovery conditions keyed on
|
|
8213
|
-
// hadTextOutput skip them: nudge after the first actionless session, signal
|
|
8214
|
-
// model escalation after the second (a no-op unless the caller configured a
|
|
8215
|
-
// fallback model), and stop as 'stalled' after the third — the same total
|
|
8216
|
-
// session budget as before stallPolicy existed.
|
|
8169
|
+
// WHY(docs/why/packages/client/src/workflows.md#empty-session-escalation-preserves-legacy-behavi): empty-session escalation preserves legacy behavior: nudge, then escalate, then stall after three
|
|
8217
8170
|
stallPolicy: { nudgeAfter: 1, escalateModelAfter: 2, stopAfter: 3 },
|
|
8218
8171
|
classifyVariant: "builtin:classify-task-variant",
|
|
8219
8172
|
bootstrap: "builtin:repo-bootstrap-discovery",
|
|
@@ -8241,16 +8194,14 @@ var defaultWorkflowConfig = {
|
|
|
8241
8194
|
transitionSummary: "builtin:planning-transition-summary",
|
|
8242
8195
|
recovery: "builtin:planning-recovery",
|
|
8243
8196
|
forceEndTurn: "builtin:planning-force-end-turn"
|
|
8244
|
-
// canAcceptCompletion intentionally absent
|
|
8245
|
-
// phase never defined it, and the SDK accepts completion when the slot
|
|
8246
|
-
// is undefined. Keep parity.
|
|
8197
|
+
// WHY(docs/why/packages/client/src/workflows.md#canacceptcompletion-is-intentionally-absent-for): canAcceptCompletion is intentionally absent for planning to keep parity with the hand-written phase
|
|
8247
8198
|
},
|
|
8248
8199
|
{
|
|
8249
8200
|
name: "execution",
|
|
8250
8201
|
description: "Execute the plan by editing target files",
|
|
8251
8202
|
instructions: "builtin:execution-instructions",
|
|
8252
8203
|
toolGuidance: "builtin:execution-tool-guidance",
|
|
8253
|
-
//
|
|
8204
|
+
// WHY(needs-review): execution never auto-advances; completion is agent-driven via TASK_COMPLETE
|
|
8254
8205
|
completionCriteria: { type: "never" },
|
|
8255
8206
|
intercept: "builtin:execution-guard",
|
|
8256
8207
|
recovery: "builtin:execution-recovery",
|
|
@@ -8420,11 +8371,11 @@ var deployWorkflow = {
|
|
|
8420
8371
|
name: "deploy",
|
|
8421
8372
|
phases: [scaffoldPhase, deployPhase],
|
|
8422
8373
|
classifyVariant: classifyVariant2,
|
|
8423
|
-
//
|
|
8374
|
+
// WHY(needs-review): no bootstrap context needed; this workflow doesn't search the repo
|
|
8424
8375
|
async generateBootstrapContext() {
|
|
8425
8376
|
return void 0;
|
|
8426
8377
|
},
|
|
8427
|
-
//
|
|
8378
|
+
// WHY(needs-review): no candidate block; this workflow doesn't edit repo files
|
|
8428
8379
|
buildCandidateBlock() {
|
|
8429
8380
|
return "";
|
|
8430
8381
|
}
|
|
@@ -9795,9 +9746,7 @@ var ClientTokensEndpoint = class {
|
|
|
9795
9746
|
if (params?.limit !== void 0) {
|
|
9796
9747
|
return {
|
|
9797
9748
|
clientTokens: response.clientTokens,
|
|
9798
|
-
// The
|
|
9799
|
-
// fallback mirrors the server's own envelope math so the paged
|
|
9800
|
-
// overload stays total against older API deployments.
|
|
9749
|
+
// WHY(docs/why/packages/client/src.md#the-fallback-mirrors-the-servers-own-envelope-ma): The fallback mirrors the server's own envelope math so paging stays correct against older API deployments.
|
|
9801
9750
|
pagination: response.pagination ?? {
|
|
9802
9751
|
limit: params.limit,
|
|
9803
9752
|
offset: params.offset ?? 0,
|
|
@@ -10549,8 +10498,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
10549
10498
|
iterations: 1,
|
|
10550
10499
|
stopReason: "end_turn",
|
|
10551
10500
|
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10552
|
-
//
|
|
10553
|
-
// cost still lands in marathon totals and budget accounting
|
|
10501
|
+
// WHY(docs/why/packages/client/src.md#carries-accumulated-spend-so-an-interrupted-sess): Carries accumulated spend so an interrupted session's cost still lands in totals
|
|
10554
10502
|
totalCost: lastKnownCost,
|
|
10555
10503
|
...lastKnownTokens ? { totalTokens: lastKnownTokens } : {},
|
|
10556
10504
|
finalOutput: [
|
|
@@ -10604,7 +10552,6 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
10604
10552
|
return null;
|
|
10605
10553
|
}
|
|
10606
10554
|
}
|
|
10607
|
-
// ─── Long-Task Agent Execution ───────────────────────────────────────
|
|
10608
10555
|
createEmptyToolTrace() {
|
|
10609
10556
|
return {
|
|
10610
10557
|
entries: [],
|
|
@@ -13379,12 +13326,7 @@ var RuntypeClient2 = class {
|
|
|
13379
13326
|
this.timeout = config.timeout === void 0 ? 3e4 : config.timeout;
|
|
13380
13327
|
this.headers = {
|
|
13381
13328
|
"Content-Type": "application/json",
|
|
13382
|
-
//
|
|
13383
|
-
// (see detectActorSource in apps/api/src/lib/audit-log.ts). Defaults come
|
|
13384
|
-
// first so callers that wrap this client with their own attribution — the
|
|
13385
|
-
// CLI sends `X-Runtype-Client: cli` + `runtype-cli/<v>` — override them.
|
|
13386
|
-
// `User-Agent` is a forbidden header in browsers and is silently dropped
|
|
13387
|
-
// there; `X-Runtype-Client` is the reliable cross-environment signal.
|
|
13329
|
+
// WHY(docs/why/packages/client/src.md#user-agent-is-a-forbidden-header-in-browsers-and): User-Agent is a forbidden header in browsers and is silently dropped; X-Runtype-Client is the reliable
|
|
13388
13330
|
"X-Runtype-Client": RUNTYPE_CLIENT_KIND,
|
|
13389
13331
|
"User-Agent": SDK_USER_AGENT,
|
|
13390
13332
|
...config.headers || {}
|
|
@@ -13445,8 +13387,7 @@ var RuntypeClient2 = class {
|
|
|
13445
13387
|
{
|
|
13446
13388
|
dispatch: (config) => this.dispatch.executeStream(config),
|
|
13447
13389
|
runWithLocalTools: (config, tools, callbacks, opts) => this.runWithLocalTools(config, tools, callbacks, opts),
|
|
13448
|
-
//
|
|
13449
|
-
// client's JSON POST transport (zero new HTTP plumbing).
|
|
13390
|
+
// WHY(docs/why/packages/client/src.md#clientflowbuilder-validate-reuses-the-clients-js): ClientFlowBuilder.validate() reuses the client's JSON POST transport instead of new HTTP plumbing.
|
|
13450
13391
|
post: (path, data) => this.post(path, data)
|
|
13451
13392
|
},
|
|
13452
13393
|
name
|
|
@@ -13700,8 +13641,7 @@ var RuntypeClient2 = class {
|
|
|
13700
13641
|
const response = await this.makeRequest(url, {
|
|
13701
13642
|
method: "POST",
|
|
13702
13643
|
headers,
|
|
13703
|
-
// TS 5.7 types Uint8Array over ArrayBufferLike, which no longer
|
|
13704
|
-
// overlaps DOM BodyInit; the runtime value is a valid fetch body.
|
|
13644
|
+
// WORKAROUND(docs/why/packages/client/src.md#ts-5-7-types-uint8array-over-arraybufferlike-whi): TS 5.7 types Uint8Array over ArrayBufferLike, which no longer overlaps DOM BodyInit, though the
|
|
13705
13645
|
body
|
|
13706
13646
|
});
|
|
13707
13647
|
return transformResponse(response);
|