@runtypelabs/sdk 4.8.1 → 4.9.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 +58 -3
- package/dist/index.d.cts +841 -1
- package/dist/index.d.ts +841 -1
- package/dist/index.mjs +58 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6217,6 +6217,8 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6217
6217
|
}
|
|
6218
6218
|
let currentBody = response.body;
|
|
6219
6219
|
let accumulatedOutput = "";
|
|
6220
|
+
let lastKnownCost = 0;
|
|
6221
|
+
let lastKnownTokens;
|
|
6220
6222
|
let pauseCount = 0;
|
|
6221
6223
|
let discoveryPauseCount = 0;
|
|
6222
6224
|
let consecutiveDiscoveryPauseCount = 0;
|
|
@@ -6234,6 +6236,15 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6234
6236
|
}
|
|
6235
6237
|
callbacks?.onTurnDelta?.(event);
|
|
6236
6238
|
},
|
|
6239
|
+
onTurnComplete: (event) => {
|
|
6240
|
+
if (typeof event.cost === "number") {
|
|
6241
|
+
lastKnownCost = event.cost;
|
|
6242
|
+
}
|
|
6243
|
+
if (event.tokens) {
|
|
6244
|
+
lastKnownTokens = event.tokens;
|
|
6245
|
+
}
|
|
6246
|
+
callbacks?.onTurnComplete?.(event);
|
|
6247
|
+
},
|
|
6237
6248
|
onAgentPaused: (event) => {
|
|
6238
6249
|
pausedEvent = event;
|
|
6239
6250
|
callbacks?.onAgentPaused?.(event);
|
|
@@ -6363,6 +6374,39 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6363
6374
|
callbacks?.onAgentComplete?.(forcedCompleteEvent);
|
|
6364
6375
|
return { completeEvent: forcedCompleteEvent, toolMessages };
|
|
6365
6376
|
}
|
|
6377
|
+
if (options?.shouldInterrupt?.()) {
|
|
6378
|
+
callbacks?.onLocalToolExecutionComplete?.({
|
|
6379
|
+
executionId,
|
|
6380
|
+
toolCallId: toolId,
|
|
6381
|
+
toolName,
|
|
6382
|
+
parameters: parsedParams,
|
|
6383
|
+
result: toolResult,
|
|
6384
|
+
success: true,
|
|
6385
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6386
|
+
durationMs: Date.now() - localExecutionStartedAtMs
|
|
6387
|
+
});
|
|
6388
|
+
const interruptCompleteEvent = {
|
|
6389
|
+
type: "agent_complete",
|
|
6390
|
+
executionId,
|
|
6391
|
+
seq: 0,
|
|
6392
|
+
agentId: id,
|
|
6393
|
+
success: true,
|
|
6394
|
+
iterations: 1,
|
|
6395
|
+
stopReason: "end_turn",
|
|
6396
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6397
|
+
// Carry the spend observed so far so the interrupted session's
|
|
6398
|
+
// cost still lands in marathon totals and budget accounting
|
|
6399
|
+
totalCost: lastKnownCost,
|
|
6400
|
+
...lastKnownTokens ? { totalTokens: lastKnownTokens } : {},
|
|
6401
|
+
finalOutput: [
|
|
6402
|
+
accumulatedOutput.trim(),
|
|
6403
|
+
"Session ended early: user steering was queued and will be delivered at the start of the next session."
|
|
6404
|
+
].filter(Boolean).join("\n\n"),
|
|
6405
|
+
duration: 0
|
|
6406
|
+
};
|
|
6407
|
+
callbacks?.onAgentComplete?.(interruptCompleteEvent);
|
|
6408
|
+
return { completeEvent: interruptCompleteEvent, toolMessages };
|
|
6409
|
+
}
|
|
6366
6410
|
const resumeResponse = await this.client.requestStream(`/agents/${id}/resume`, {
|
|
6367
6411
|
method: "POST",
|
|
6368
6412
|
body: JSON.stringify({
|
|
@@ -7428,6 +7472,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
7428
7472
|
if (session === 0 && !options.previousMessages) {
|
|
7429
7473
|
state.originalMessage = options.message;
|
|
7430
7474
|
}
|
|
7475
|
+
const queuedSteeringMessages = options.getQueuedUserMessages?.() ?? [];
|
|
7431
7476
|
const preparedSession = await this.prepareSessionContext(
|
|
7432
7477
|
options.message,
|
|
7433
7478
|
state,
|
|
@@ -7447,7 +7492,8 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
7447
7492
|
builtinToolSchemas,
|
|
7448
7493
|
onContextCompaction: options.onContextCompaction,
|
|
7449
7494
|
onContextNotice: options.onContextNotice
|
|
7450
|
-
}
|
|
7495
|
+
},
|
|
7496
|
+
queuedSteeringMessages
|
|
7451
7497
|
);
|
|
7452
7498
|
const { messages, requestContextManagement, pendingNativeCompactionEvent } = preparedSession;
|
|
7453
7499
|
let sessionResult;
|
|
@@ -7474,7 +7520,8 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
7474
7520
|
sessionLocalTools || options.localTools,
|
|
7475
7521
|
sessionCallbacks,
|
|
7476
7522
|
{
|
|
7477
|
-
onLocalToolResult: this.createLocalToolLoopGuard(state, sessionTrace, workflow)
|
|
7523
|
+
onLocalToolResult: this.createLocalToolLoopGuard(state, sessionTrace, workflow),
|
|
7524
|
+
shouldInterrupt: options.hasQueuedUserMessages
|
|
7478
7525
|
},
|
|
7479
7526
|
state.taskName
|
|
7480
7527
|
);
|
|
@@ -8150,7 +8197,7 @@ Do NOT redo any of the above work.`
|
|
|
8150
8197
|
);
|
|
8151
8198
|
return prepared.messages;
|
|
8152
8199
|
}
|
|
8153
|
-
async prepareSessionContext(originalMessage, state, sessionIndex, maxSessions, localToolNames, continuationContext, workflow, builtinToolIds, compactionOptions) {
|
|
8200
|
+
async prepareSessionContext(originalMessage, state, sessionIndex, maxSessions, localToolNames, continuationContext, workflow, builtinToolIds, compactionOptions, steeringMessages) {
|
|
8154
8201
|
const wf = workflow ?? defaultWorkflow;
|
|
8155
8202
|
const compactInstructions = compactionOptions?.compactInstructions;
|
|
8156
8203
|
const resolvedStrategy = continuationContext?.compact ? "summary_fallback" : this.resolveCompactStrategy(compactionOptions?.compactStrategy, compactionOptions?.model);
|
|
@@ -8235,6 +8282,11 @@ Do NOT redo any of the above work.`
|
|
|
8235
8282
|
const phaseBlock = ["", this.buildPhaseInstructions(state, wf)].join("\n");
|
|
8236
8283
|
const candidateBlock = wf.buildCandidateBlock?.(state) ?? "";
|
|
8237
8284
|
const multiSessionInstruction = `This is a multi-session task (session ${sessionIndex + 1}/${maxSessions}). When you have fully completed the task, end your response with TASK_COMPLETE on its own line.`;
|
|
8285
|
+
const steeringLines = steeringMessages && steeringMessages.length > 0 ? [
|
|
8286
|
+
"--- User steering (queued during the previous session) ---",
|
|
8287
|
+
...steeringMessages,
|
|
8288
|
+
""
|
|
8289
|
+
] : [];
|
|
8238
8290
|
if (continuationContext && sessionIndex === 0) {
|
|
8239
8291
|
const replayHistoryMessages = this.sanitizeReplayHistoryMessages(
|
|
8240
8292
|
continuationContext.previousMessages
|
|
@@ -8245,6 +8297,7 @@ Do NOT redo any of the above work.`
|
|
|
8245
8297
|
const userContent = [
|
|
8246
8298
|
continuationGuardrail,
|
|
8247
8299
|
"",
|
|
8300
|
+
...steeringLines,
|
|
8248
8301
|
userMessage,
|
|
8249
8302
|
phaseBlock,
|
|
8250
8303
|
toolsBlock,
|
|
@@ -8347,6 +8400,7 @@ Do NOT redo any of the above work.`
|
|
|
8347
8400
|
const recoveryMessage2 = this.buildStuckTurnRecoveryMessage(state, wf);
|
|
8348
8401
|
const rejectionNotice = state.lastCompletionRejectionReason ? `TASK_COMPLETE was rejected because: ${state.lastCompletionRejectionReason}. Address this before signaling completion again.` : void 0;
|
|
8349
8402
|
const continuationContent = [
|
|
8403
|
+
...steeringLines,
|
|
8350
8404
|
"Continue the task.",
|
|
8351
8405
|
phaseBlock,
|
|
8352
8406
|
toolsBlock,
|
|
@@ -8420,6 +8474,7 @@ Do NOT redo any of the above work.`
|
|
|
8420
8474
|
const recoveryMessage = this.buildStuckTurnRecoveryMessage(state, wf);
|
|
8421
8475
|
const fallbackRejectionNotice = state.lastCompletionRejectionReason ? `TASK_COMPLETE was rejected because: ${state.lastCompletionRejectionReason}. Address this before signaling completion again.` : void 0;
|
|
8422
8476
|
const content = [
|
|
8477
|
+
...steeringLines,
|
|
8423
8478
|
originalMessage,
|
|
8424
8479
|
phaseBlock,
|
|
8425
8480
|
toolsBlock,
|
package/package.json
CHANGED