@runtypelabs/sdk 1.12.0 → 1.13.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.cjs +43 -7
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +43 -7
- package/package.json +1 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -5085,6 +5085,35 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5085
5085
|
}
|
|
5086
5086
|
return true;
|
|
5087
5087
|
}
|
|
5088
|
+
getForcedCompactionSummaryPrefix(state) {
|
|
5089
|
+
return state.status === "complete" ? _AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX : _AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX;
|
|
5090
|
+
}
|
|
5091
|
+
buildContinuationGuardrail(state) {
|
|
5092
|
+
if (state.status === "complete") {
|
|
5093
|
+
return "IMPORTANT: You are continuing a previously completed task. The conversation above shows your prior work. Do NOT redo any of it. Build on what was already accomplished. If there is nothing new to do, respond with TASK_COMPLETE.";
|
|
5094
|
+
}
|
|
5095
|
+
return "IMPORTANT: You are continuing a previously saved task. The conversation above shows your prior work. Do NOT redo any of it. Build on what was already accomplished.";
|
|
5096
|
+
}
|
|
5097
|
+
isExecutionLikePhase(phaseName, workflow, state) {
|
|
5098
|
+
if (!phaseName) return false;
|
|
5099
|
+
const normalizedPhase = phaseName.trim().toLowerCase();
|
|
5100
|
+
if (!normalizedPhase || normalizedPhase === "complete") {
|
|
5101
|
+
return false;
|
|
5102
|
+
}
|
|
5103
|
+
if (normalizedPhase === "execution") {
|
|
5104
|
+
return true;
|
|
5105
|
+
}
|
|
5106
|
+
const currentIndex = workflow.phases.findIndex((phase) => phase.name === phaseName);
|
|
5107
|
+
const executionIndex = workflow.phases.findIndex(
|
|
5108
|
+
(phase) => phase.name.trim().toLowerCase() === "execution"
|
|
5109
|
+
);
|
|
5110
|
+
if (currentIndex >= 0 && executionIndex >= 0 && currentIndex >= executionIndex) {
|
|
5111
|
+
return true;
|
|
5112
|
+
}
|
|
5113
|
+
return Boolean(
|
|
5114
|
+
state.planWritten && normalizedPhase !== "research" && normalizedPhase !== "planning"
|
|
5115
|
+
);
|
|
5116
|
+
}
|
|
5088
5117
|
computeCompletionRejectionReason(state, trace) {
|
|
5089
5118
|
const reasons = [];
|
|
5090
5119
|
if (!state.planWritten) {
|
|
@@ -5472,7 +5501,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5472
5501
|
trace.writeCountByPath[normalizedPathArg] = (trace.writeCountByPath[normalizedPathArg] || 0) + 1;
|
|
5473
5502
|
if (normalizedPlanPath && normalizedPathArg === normalizedPlanPath) {
|
|
5474
5503
|
trace.planWritten = true;
|
|
5475
|
-
} else if (state.workflowPhase
|
|
5504
|
+
} else if (this.isExecutionLikePhase(state.workflowPhase, workflow, state)) {
|
|
5476
5505
|
trace.executionFileWritten = true;
|
|
5477
5506
|
trace.verificationPassed = false;
|
|
5478
5507
|
if (!this.isMarathonArtifactPath(normalizedPathArg)) {
|
|
@@ -5845,6 +5874,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5845
5874
|
}
|
|
5846
5875
|
}
|
|
5847
5876
|
for (let session = 0; session < maxSessions; session++) {
|
|
5877
|
+
const phaseAtSessionStart = state.workflowPhase;
|
|
5848
5878
|
const sessionTrace = this.createEmptyToolTrace();
|
|
5849
5879
|
const sessionLocalTools = this.wrapLocalToolsForTrace(
|
|
5850
5880
|
options.localTools,
|
|
@@ -6089,7 +6119,13 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6089
6119
|
consecutiveServerNetworkErrors = 0;
|
|
6090
6120
|
}
|
|
6091
6121
|
const detectedTaskCompletion = this.detectTaskCompletion(sessionResult.result);
|
|
6092
|
-
const
|
|
6122
|
+
const completionCheckState = phaseAtSessionStart && phaseAtSessionStart !== state.workflowPhase ? { ...state, workflowPhase: phaseAtSessionStart } : state;
|
|
6123
|
+
const acceptedTaskCompletion = detectedTaskCompletion && this.canAcceptTaskCompletion(
|
|
6124
|
+
sessionResult.result,
|
|
6125
|
+
completionCheckState,
|
|
6126
|
+
sessionTrace,
|
|
6127
|
+
workflow
|
|
6128
|
+
);
|
|
6093
6129
|
if (detectedTaskCompletion && !acceptedTaskCompletion) {
|
|
6094
6130
|
state.lastCompletionRejectionReason = this.computeCompletionRejectionReason(state, sessionTrace);
|
|
6095
6131
|
if (state.verificationRequired && !state.lastVerificationPassed && !sessionTrace.verificationPassed && !sessionTrace.verificationAttempted) {
|
|
@@ -6416,7 +6452,7 @@ Do NOT redo any of the above work.`
|
|
|
6416
6452
|
}
|
|
6417
6453
|
buildCompactHistoryMessages(state, userContent, compactInstructions, mode = "auto") {
|
|
6418
6454
|
const summary = this.generateCompactSummary(state, compactInstructions);
|
|
6419
|
-
const prefix = mode === "forced" ?
|
|
6455
|
+
const prefix = mode === "forced" ? this.getForcedCompactionSummaryPrefix(state) : _AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX;
|
|
6420
6456
|
return [
|
|
6421
6457
|
{
|
|
6422
6458
|
role: "system",
|
|
@@ -6435,7 +6471,7 @@ Do NOT redo any of the above work.`
|
|
|
6435
6471
|
isCompactHistoryMessageSet(messages) {
|
|
6436
6472
|
if (messages.length === 0) return false;
|
|
6437
6473
|
const firstMessage = messages[0];
|
|
6438
|
-
return firstMessage?.role === "system" && typeof firstMessage.content === "string" && (firstMessage.content.startsWith(_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX) || firstMessage.content.startsWith(_AgentsEndpoint.
|
|
6474
|
+
return firstMessage?.role === "system" && typeof firstMessage.content === "string" && (firstMessage.content.startsWith(_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX) || firstMessage.content.startsWith(_AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX) || firstMessage.content.startsWith(_AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX));
|
|
6439
6475
|
}
|
|
6440
6476
|
/**
|
|
6441
6477
|
* Generate a compact summary of prior work for continuation context.
|
|
@@ -6674,7 +6710,7 @@ Do NOT redo any of the above work.`
|
|
|
6674
6710
|
const replayHistoryMessages = this.sanitizeReplayHistoryMessages(
|
|
6675
6711
|
continuationContext.previousMessages
|
|
6676
6712
|
);
|
|
6677
|
-
const continuationGuardrail =
|
|
6713
|
+
const continuationGuardrail = this.buildContinuationGuardrail(state);
|
|
6678
6714
|
const defaultContinueMessage = "Continue the task. Review your prior work above and proceed with any remaining work. If everything is already complete, respond with TASK_COMPLETE.";
|
|
6679
6715
|
const userMessage = continuationContext.newUserMessage || defaultContinueMessage;
|
|
6680
6716
|
const userContent = [
|
|
@@ -6926,7 +6962,8 @@ Do NOT redo any of the above work.`
|
|
|
6926
6962
|
}
|
|
6927
6963
|
};
|
|
6928
6964
|
_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX = "You are continuing a long-running task. Here is a compact summary of prior work:";
|
|
6929
|
-
_AgentsEndpoint.
|
|
6965
|
+
_AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously saved task. Here is a summary of prior work:";
|
|
6966
|
+
_AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously completed task. Here is a summary of prior work:";
|
|
6930
6967
|
/** Error message patterns from server-side sessions that indicate a transient network failure
|
|
6931
6968
|
* (e.g. AI provider connection dropped). These are retried automatically. */
|
|
6932
6969
|
_AgentsEndpoint.RETRYABLE_SESSION_ERROR_PATTERNS = [
|
|
@@ -8303,4 +8340,3 @@ var ClientEvalBuilder = class extends EvalBuilder {
|
|
|
8303
8340
|
sanitizeTaskSlug,
|
|
8304
8341
|
streamEvents
|
|
8305
8342
|
});
|
|
8306
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -118,6 +118,10 @@ interface RuntypeRecord {
|
|
|
118
118
|
keyCount: number;
|
|
119
119
|
updatedAt: string;
|
|
120
120
|
};
|
|
121
|
+
messages?: Array<{
|
|
122
|
+
role: 'user' | 'assistant';
|
|
123
|
+
content: string | unknown[];
|
|
124
|
+
}> | null;
|
|
121
125
|
availableFields?: string[];
|
|
122
126
|
userId: string;
|
|
123
127
|
createdAt: string;
|
|
@@ -394,7 +398,7 @@ interface BuiltInTool {
|
|
|
394
398
|
id: string;
|
|
395
399
|
name: string;
|
|
396
400
|
description: string;
|
|
397
|
-
category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api';
|
|
401
|
+
category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api' | 'data_management';
|
|
398
402
|
providers: string[];
|
|
399
403
|
parametersSchema: JSONSchema;
|
|
400
404
|
defaultConfig?: JsonObject;
|
|
@@ -4570,7 +4574,8 @@ interface Agent {
|
|
|
4570
4574
|
declare class AgentsEndpoint {
|
|
4571
4575
|
private client;
|
|
4572
4576
|
private static readonly AUTO_COMPACT_SUMMARY_PREFIX;
|
|
4573
|
-
private static readonly
|
|
4577
|
+
private static readonly RESUMED_COMPACT_SUMMARY_PREFIX;
|
|
4578
|
+
private static readonly COMPLETED_COMPACT_SUMMARY_PREFIX;
|
|
4574
4579
|
constructor(client: ApiClient);
|
|
4575
4580
|
/**
|
|
4576
4581
|
* List all agents for the authenticated user
|
|
@@ -4719,6 +4724,9 @@ declare class AgentsEndpoint {
|
|
|
4719
4724
|
private hasSufficientResearchEvidence;
|
|
4720
4725
|
private buildEffectiveSessionOutput;
|
|
4721
4726
|
private canAcceptTaskCompletion;
|
|
4727
|
+
private getForcedCompactionSummaryPrefix;
|
|
4728
|
+
private buildContinuationGuardrail;
|
|
4729
|
+
private isExecutionLikePhase;
|
|
4722
4730
|
private computeCompletionRejectionReason;
|
|
4723
4731
|
private summarizeUnknownForTrace;
|
|
4724
4732
|
private summarizeTextBlockForTrace;
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,10 @@ interface RuntypeRecord {
|
|
|
118
118
|
keyCount: number;
|
|
119
119
|
updatedAt: string;
|
|
120
120
|
};
|
|
121
|
+
messages?: Array<{
|
|
122
|
+
role: 'user' | 'assistant';
|
|
123
|
+
content: string | unknown[];
|
|
124
|
+
}> | null;
|
|
121
125
|
availableFields?: string[];
|
|
122
126
|
userId: string;
|
|
123
127
|
createdAt: string;
|
|
@@ -394,7 +398,7 @@ interface BuiltInTool {
|
|
|
394
398
|
id: string;
|
|
395
399
|
name: string;
|
|
396
400
|
description: string;
|
|
397
|
-
category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api';
|
|
401
|
+
category: 'image_generation' | 'web_search' | 'web_scraping' | 'code_execution' | 'file_operations' | 'data_analysis' | 'knowledge_retrieval' | 'text_to_speech' | 'voice_processing' | 'third_party_api' | 'data_management';
|
|
398
402
|
providers: string[];
|
|
399
403
|
parametersSchema: JSONSchema;
|
|
400
404
|
defaultConfig?: JsonObject;
|
|
@@ -4570,7 +4574,8 @@ interface Agent {
|
|
|
4570
4574
|
declare class AgentsEndpoint {
|
|
4571
4575
|
private client;
|
|
4572
4576
|
private static readonly AUTO_COMPACT_SUMMARY_PREFIX;
|
|
4573
|
-
private static readonly
|
|
4577
|
+
private static readonly RESUMED_COMPACT_SUMMARY_PREFIX;
|
|
4578
|
+
private static readonly COMPLETED_COMPACT_SUMMARY_PREFIX;
|
|
4574
4579
|
constructor(client: ApiClient);
|
|
4575
4580
|
/**
|
|
4576
4581
|
* List all agents for the authenticated user
|
|
@@ -4719,6 +4724,9 @@ declare class AgentsEndpoint {
|
|
|
4719
4724
|
private hasSufficientResearchEvidence;
|
|
4720
4725
|
private buildEffectiveSessionOutput;
|
|
4721
4726
|
private canAcceptTaskCompletion;
|
|
4727
|
+
private getForcedCompactionSummaryPrefix;
|
|
4728
|
+
private buildContinuationGuardrail;
|
|
4729
|
+
private isExecutionLikePhase;
|
|
4722
4730
|
private computeCompletionRejectionReason;
|
|
4723
4731
|
private summarizeUnknownForTrace;
|
|
4724
4732
|
private summarizeTextBlockForTrace;
|
package/dist/index.mjs
CHANGED
|
@@ -5015,6 +5015,35 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5015
5015
|
}
|
|
5016
5016
|
return true;
|
|
5017
5017
|
}
|
|
5018
|
+
getForcedCompactionSummaryPrefix(state) {
|
|
5019
|
+
return state.status === "complete" ? _AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX : _AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX;
|
|
5020
|
+
}
|
|
5021
|
+
buildContinuationGuardrail(state) {
|
|
5022
|
+
if (state.status === "complete") {
|
|
5023
|
+
return "IMPORTANT: You are continuing a previously completed task. The conversation above shows your prior work. Do NOT redo any of it. Build on what was already accomplished. If there is nothing new to do, respond with TASK_COMPLETE.";
|
|
5024
|
+
}
|
|
5025
|
+
return "IMPORTANT: You are continuing a previously saved task. The conversation above shows your prior work. Do NOT redo any of it. Build on what was already accomplished.";
|
|
5026
|
+
}
|
|
5027
|
+
isExecutionLikePhase(phaseName, workflow, state) {
|
|
5028
|
+
if (!phaseName) return false;
|
|
5029
|
+
const normalizedPhase = phaseName.trim().toLowerCase();
|
|
5030
|
+
if (!normalizedPhase || normalizedPhase === "complete") {
|
|
5031
|
+
return false;
|
|
5032
|
+
}
|
|
5033
|
+
if (normalizedPhase === "execution") {
|
|
5034
|
+
return true;
|
|
5035
|
+
}
|
|
5036
|
+
const currentIndex = workflow.phases.findIndex((phase) => phase.name === phaseName);
|
|
5037
|
+
const executionIndex = workflow.phases.findIndex(
|
|
5038
|
+
(phase) => phase.name.trim().toLowerCase() === "execution"
|
|
5039
|
+
);
|
|
5040
|
+
if (currentIndex >= 0 && executionIndex >= 0 && currentIndex >= executionIndex) {
|
|
5041
|
+
return true;
|
|
5042
|
+
}
|
|
5043
|
+
return Boolean(
|
|
5044
|
+
state.planWritten && normalizedPhase !== "research" && normalizedPhase !== "planning"
|
|
5045
|
+
);
|
|
5046
|
+
}
|
|
5018
5047
|
computeCompletionRejectionReason(state, trace) {
|
|
5019
5048
|
const reasons = [];
|
|
5020
5049
|
if (!state.planWritten) {
|
|
@@ -5402,7 +5431,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5402
5431
|
trace.writeCountByPath[normalizedPathArg] = (trace.writeCountByPath[normalizedPathArg] || 0) + 1;
|
|
5403
5432
|
if (normalizedPlanPath && normalizedPathArg === normalizedPlanPath) {
|
|
5404
5433
|
trace.planWritten = true;
|
|
5405
|
-
} else if (state.workflowPhase
|
|
5434
|
+
} else if (this.isExecutionLikePhase(state.workflowPhase, workflow, state)) {
|
|
5406
5435
|
trace.executionFileWritten = true;
|
|
5407
5436
|
trace.verificationPassed = false;
|
|
5408
5437
|
if (!this.isMarathonArtifactPath(normalizedPathArg)) {
|
|
@@ -5775,6 +5804,7 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5775
5804
|
}
|
|
5776
5805
|
}
|
|
5777
5806
|
for (let session = 0; session < maxSessions; session++) {
|
|
5807
|
+
const phaseAtSessionStart = state.workflowPhase;
|
|
5778
5808
|
const sessionTrace = this.createEmptyToolTrace();
|
|
5779
5809
|
const sessionLocalTools = this.wrapLocalToolsForTrace(
|
|
5780
5810
|
options.localTools,
|
|
@@ -6019,7 +6049,13 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6019
6049
|
consecutiveServerNetworkErrors = 0;
|
|
6020
6050
|
}
|
|
6021
6051
|
const detectedTaskCompletion = this.detectTaskCompletion(sessionResult.result);
|
|
6022
|
-
const
|
|
6052
|
+
const completionCheckState = phaseAtSessionStart && phaseAtSessionStart !== state.workflowPhase ? { ...state, workflowPhase: phaseAtSessionStart } : state;
|
|
6053
|
+
const acceptedTaskCompletion = detectedTaskCompletion && this.canAcceptTaskCompletion(
|
|
6054
|
+
sessionResult.result,
|
|
6055
|
+
completionCheckState,
|
|
6056
|
+
sessionTrace,
|
|
6057
|
+
workflow
|
|
6058
|
+
);
|
|
6023
6059
|
if (detectedTaskCompletion && !acceptedTaskCompletion) {
|
|
6024
6060
|
state.lastCompletionRejectionReason = this.computeCompletionRejectionReason(state, sessionTrace);
|
|
6025
6061
|
if (state.verificationRequired && !state.lastVerificationPassed && !sessionTrace.verificationPassed && !sessionTrace.verificationAttempted) {
|
|
@@ -6346,7 +6382,7 @@ Do NOT redo any of the above work.`
|
|
|
6346
6382
|
}
|
|
6347
6383
|
buildCompactHistoryMessages(state, userContent, compactInstructions, mode = "auto") {
|
|
6348
6384
|
const summary = this.generateCompactSummary(state, compactInstructions);
|
|
6349
|
-
const prefix = mode === "forced" ?
|
|
6385
|
+
const prefix = mode === "forced" ? this.getForcedCompactionSummaryPrefix(state) : _AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX;
|
|
6350
6386
|
return [
|
|
6351
6387
|
{
|
|
6352
6388
|
role: "system",
|
|
@@ -6365,7 +6401,7 @@ Do NOT redo any of the above work.`
|
|
|
6365
6401
|
isCompactHistoryMessageSet(messages) {
|
|
6366
6402
|
if (messages.length === 0) return false;
|
|
6367
6403
|
const firstMessage = messages[0];
|
|
6368
|
-
return firstMessage?.role === "system" && typeof firstMessage.content === "string" && (firstMessage.content.startsWith(_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX) || firstMessage.content.startsWith(_AgentsEndpoint.
|
|
6404
|
+
return firstMessage?.role === "system" && typeof firstMessage.content === "string" && (firstMessage.content.startsWith(_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX) || firstMessage.content.startsWith(_AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX) || firstMessage.content.startsWith(_AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX));
|
|
6369
6405
|
}
|
|
6370
6406
|
/**
|
|
6371
6407
|
* Generate a compact summary of prior work for continuation context.
|
|
@@ -6604,7 +6640,7 @@ Do NOT redo any of the above work.`
|
|
|
6604
6640
|
const replayHistoryMessages = this.sanitizeReplayHistoryMessages(
|
|
6605
6641
|
continuationContext.previousMessages
|
|
6606
6642
|
);
|
|
6607
|
-
const continuationGuardrail =
|
|
6643
|
+
const continuationGuardrail = this.buildContinuationGuardrail(state);
|
|
6608
6644
|
const defaultContinueMessage = "Continue the task. Review your prior work above and proceed with any remaining work. If everything is already complete, respond with TASK_COMPLETE.";
|
|
6609
6645
|
const userMessage = continuationContext.newUserMessage || defaultContinueMessage;
|
|
6610
6646
|
const userContent = [
|
|
@@ -6856,7 +6892,8 @@ Do NOT redo any of the above work.`
|
|
|
6856
6892
|
}
|
|
6857
6893
|
};
|
|
6858
6894
|
_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX = "You are continuing a long-running task. Here is a compact summary of prior work:";
|
|
6859
|
-
_AgentsEndpoint.
|
|
6895
|
+
_AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously saved task. Here is a summary of prior work:";
|
|
6896
|
+
_AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously completed task. Here is a summary of prior work:";
|
|
6860
6897
|
/** Error message patterns from server-side sessions that indicate a transient network failure
|
|
6861
6898
|
* (e.g. AI provider connection dropped). These are retried automatically. */
|
|
6862
6899
|
_AgentsEndpoint.RETRYABLE_SESSION_ERROR_PATTERNS = [
|
|
@@ -8232,4 +8269,3 @@ export {
|
|
|
8232
8269
|
sanitizeTaskSlug,
|
|
8233
8270
|
streamEvents
|
|
8234
8271
|
};
|
|
8235
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED