@runtypelabs/sdk 1.13.0 → 1.13.3
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 +48 -20
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.mjs +48 -20
- 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,
|
|
@@ -6037,12 +6067,6 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6037
6067
|
if ((state.consecutiveBlockedVerificationSessions || 0) >= 2 && state.verificationRequired) {
|
|
6038
6068
|
state.verificationRequired = false;
|
|
6039
6069
|
state.lastVerificationPassed = true;
|
|
6040
|
-
if (!state.planWritten) {
|
|
6041
|
-
state.planWritten = true;
|
|
6042
|
-
}
|
|
6043
|
-
if (!state.bestCandidateVerified) {
|
|
6044
|
-
state.bestCandidateVerified = true;
|
|
6045
|
-
}
|
|
6046
6070
|
}
|
|
6047
6071
|
const modelKey = options.model || "default";
|
|
6048
6072
|
if (!state.costByModel) state.costByModel = {};
|
|
@@ -6089,7 +6113,13 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6089
6113
|
consecutiveServerNetworkErrors = 0;
|
|
6090
6114
|
}
|
|
6091
6115
|
const detectedTaskCompletion = this.detectTaskCompletion(sessionResult.result);
|
|
6092
|
-
const
|
|
6116
|
+
const completionCheckState = phaseAtSessionStart && phaseAtSessionStart !== state.workflowPhase ? { ...state, workflowPhase: phaseAtSessionStart } : state;
|
|
6117
|
+
const acceptedTaskCompletion = detectedTaskCompletion && this.canAcceptTaskCompletion(
|
|
6118
|
+
sessionResult.result,
|
|
6119
|
+
completionCheckState,
|
|
6120
|
+
sessionTrace,
|
|
6121
|
+
workflow
|
|
6122
|
+
);
|
|
6093
6123
|
if (detectedTaskCompletion && !acceptedTaskCompletion) {
|
|
6094
6124
|
state.lastCompletionRejectionReason = this.computeCompletionRejectionReason(state, sessionTrace);
|
|
6095
6125
|
if (state.verificationRequired && !state.lastVerificationPassed && !sessionTrace.verificationPassed && !sessionTrace.verificationAttempted) {
|
|
@@ -6097,12 +6127,6 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6097
6127
|
if ((state.consecutiveBlockedVerificationSessions || 0) >= 2) {
|
|
6098
6128
|
state.verificationRequired = false;
|
|
6099
6129
|
state.lastVerificationPassed = true;
|
|
6100
|
-
if (!state.planWritten) {
|
|
6101
|
-
state.planWritten = true;
|
|
6102
|
-
}
|
|
6103
|
-
if (!state.bestCandidateVerified) {
|
|
6104
|
-
state.bestCandidateVerified = true;
|
|
6105
|
-
}
|
|
6106
6130
|
}
|
|
6107
6131
|
}
|
|
6108
6132
|
} else {
|
|
@@ -6115,7 +6139,11 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6115
6139
|
state.consecutiveEmptySessions = (state.consecutiveEmptySessions || 0) + 1;
|
|
6116
6140
|
}
|
|
6117
6141
|
if (sessionResult.stopReason === "complete" && !detectedTaskCompletion) {
|
|
6118
|
-
|
|
6142
|
+
const currentPhase = workflow.phases.find((p) => p.name === state.workflowPhase);
|
|
6143
|
+
const gatesSatisfied = currentPhase?.canAcceptCompletion ? currentPhase.canAcceptCompletion(state, sessionTrace) : true;
|
|
6144
|
+
if (gatesSatisfied) {
|
|
6145
|
+
state.status = "complete";
|
|
6146
|
+
}
|
|
6119
6147
|
} else if (sessionResult.stopReason === "error") {
|
|
6120
6148
|
if (_AgentsEndpoint.isRetryableSessionError(sessionResult.error) && consecutiveServerNetworkErrors < maxServerNetworkRetries) {
|
|
6121
6149
|
consecutiveServerNetworkErrors++;
|
|
@@ -6416,7 +6444,7 @@ Do NOT redo any of the above work.`
|
|
|
6416
6444
|
}
|
|
6417
6445
|
buildCompactHistoryMessages(state, userContent, compactInstructions, mode = "auto") {
|
|
6418
6446
|
const summary = this.generateCompactSummary(state, compactInstructions);
|
|
6419
|
-
const prefix = mode === "forced" ?
|
|
6447
|
+
const prefix = mode === "forced" ? this.getForcedCompactionSummaryPrefix(state) : _AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX;
|
|
6420
6448
|
return [
|
|
6421
6449
|
{
|
|
6422
6450
|
role: "system",
|
|
@@ -6435,7 +6463,7 @@ Do NOT redo any of the above work.`
|
|
|
6435
6463
|
isCompactHistoryMessageSet(messages) {
|
|
6436
6464
|
if (messages.length === 0) return false;
|
|
6437
6465
|
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.
|
|
6466
|
+
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
6467
|
}
|
|
6440
6468
|
/**
|
|
6441
6469
|
* Generate a compact summary of prior work for continuation context.
|
|
@@ -6674,7 +6702,7 @@ Do NOT redo any of the above work.`
|
|
|
6674
6702
|
const replayHistoryMessages = this.sanitizeReplayHistoryMessages(
|
|
6675
6703
|
continuationContext.previousMessages
|
|
6676
6704
|
);
|
|
6677
|
-
const continuationGuardrail =
|
|
6705
|
+
const continuationGuardrail = this.buildContinuationGuardrail(state);
|
|
6678
6706
|
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
6707
|
const userMessage = continuationContext.newUserMessage || defaultContinueMessage;
|
|
6680
6708
|
const userContent = [
|
|
@@ -6926,7 +6954,8 @@ Do NOT redo any of the above work.`
|
|
|
6926
6954
|
}
|
|
6927
6955
|
};
|
|
6928
6956
|
_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX = "You are continuing a long-running task. Here is a compact summary of prior work:";
|
|
6929
|
-
_AgentsEndpoint.
|
|
6957
|
+
_AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously saved task. Here is a summary of prior work:";
|
|
6958
|
+
_AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously completed task. Here is a summary of prior work:";
|
|
6930
6959
|
/** Error message patterns from server-side sessions that indicate a transient network failure
|
|
6931
6960
|
* (e.g. AI provider connection dropped). These are retried automatically. */
|
|
6932
6961
|
_AgentsEndpoint.RETRYABLE_SESSION_ERROR_PATTERNS = [
|
|
@@ -8303,4 +8332,3 @@ var ClientEvalBuilder = class extends EvalBuilder {
|
|
|
8303
8332
|
sanitizeTaskSlug,
|
|
8304
8333
|
streamEvents
|
|
8305
8334
|
});
|
|
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,
|
|
@@ -5967,12 +5997,6 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
5967
5997
|
if ((state.consecutiveBlockedVerificationSessions || 0) >= 2 && state.verificationRequired) {
|
|
5968
5998
|
state.verificationRequired = false;
|
|
5969
5999
|
state.lastVerificationPassed = true;
|
|
5970
|
-
if (!state.planWritten) {
|
|
5971
|
-
state.planWritten = true;
|
|
5972
|
-
}
|
|
5973
|
-
if (!state.bestCandidateVerified) {
|
|
5974
|
-
state.bestCandidateVerified = true;
|
|
5975
|
-
}
|
|
5976
6000
|
}
|
|
5977
6001
|
const modelKey = options.model || "default";
|
|
5978
6002
|
if (!state.costByModel) state.costByModel = {};
|
|
@@ -6019,7 +6043,13 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6019
6043
|
consecutiveServerNetworkErrors = 0;
|
|
6020
6044
|
}
|
|
6021
6045
|
const detectedTaskCompletion = this.detectTaskCompletion(sessionResult.result);
|
|
6022
|
-
const
|
|
6046
|
+
const completionCheckState = phaseAtSessionStart && phaseAtSessionStart !== state.workflowPhase ? { ...state, workflowPhase: phaseAtSessionStart } : state;
|
|
6047
|
+
const acceptedTaskCompletion = detectedTaskCompletion && this.canAcceptTaskCompletion(
|
|
6048
|
+
sessionResult.result,
|
|
6049
|
+
completionCheckState,
|
|
6050
|
+
sessionTrace,
|
|
6051
|
+
workflow
|
|
6052
|
+
);
|
|
6023
6053
|
if (detectedTaskCompletion && !acceptedTaskCompletion) {
|
|
6024
6054
|
state.lastCompletionRejectionReason = this.computeCompletionRejectionReason(state, sessionTrace);
|
|
6025
6055
|
if (state.verificationRequired && !state.lastVerificationPassed && !sessionTrace.verificationPassed && !sessionTrace.verificationAttempted) {
|
|
@@ -6027,12 +6057,6 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6027
6057
|
if ((state.consecutiveBlockedVerificationSessions || 0) >= 2) {
|
|
6028
6058
|
state.verificationRequired = false;
|
|
6029
6059
|
state.lastVerificationPassed = true;
|
|
6030
|
-
if (!state.planWritten) {
|
|
6031
|
-
state.planWritten = true;
|
|
6032
|
-
}
|
|
6033
|
-
if (!state.bestCandidateVerified) {
|
|
6034
|
-
state.bestCandidateVerified = true;
|
|
6035
|
-
}
|
|
6036
6060
|
}
|
|
6037
6061
|
}
|
|
6038
6062
|
} else {
|
|
@@ -6045,7 +6069,11 @@ var _AgentsEndpoint = class _AgentsEndpoint {
|
|
|
6045
6069
|
state.consecutiveEmptySessions = (state.consecutiveEmptySessions || 0) + 1;
|
|
6046
6070
|
}
|
|
6047
6071
|
if (sessionResult.stopReason === "complete" && !detectedTaskCompletion) {
|
|
6048
|
-
|
|
6072
|
+
const currentPhase = workflow.phases.find((p) => p.name === state.workflowPhase);
|
|
6073
|
+
const gatesSatisfied = currentPhase?.canAcceptCompletion ? currentPhase.canAcceptCompletion(state, sessionTrace) : true;
|
|
6074
|
+
if (gatesSatisfied) {
|
|
6075
|
+
state.status = "complete";
|
|
6076
|
+
}
|
|
6049
6077
|
} else if (sessionResult.stopReason === "error") {
|
|
6050
6078
|
if (_AgentsEndpoint.isRetryableSessionError(sessionResult.error) && consecutiveServerNetworkErrors < maxServerNetworkRetries) {
|
|
6051
6079
|
consecutiveServerNetworkErrors++;
|
|
@@ -6346,7 +6374,7 @@ Do NOT redo any of the above work.`
|
|
|
6346
6374
|
}
|
|
6347
6375
|
buildCompactHistoryMessages(state, userContent, compactInstructions, mode = "auto") {
|
|
6348
6376
|
const summary = this.generateCompactSummary(state, compactInstructions);
|
|
6349
|
-
const prefix = mode === "forced" ?
|
|
6377
|
+
const prefix = mode === "forced" ? this.getForcedCompactionSummaryPrefix(state) : _AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX;
|
|
6350
6378
|
return [
|
|
6351
6379
|
{
|
|
6352
6380
|
role: "system",
|
|
@@ -6365,7 +6393,7 @@ Do NOT redo any of the above work.`
|
|
|
6365
6393
|
isCompactHistoryMessageSet(messages) {
|
|
6366
6394
|
if (messages.length === 0) return false;
|
|
6367
6395
|
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.
|
|
6396
|
+
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
6397
|
}
|
|
6370
6398
|
/**
|
|
6371
6399
|
* Generate a compact summary of prior work for continuation context.
|
|
@@ -6604,7 +6632,7 @@ Do NOT redo any of the above work.`
|
|
|
6604
6632
|
const replayHistoryMessages = this.sanitizeReplayHistoryMessages(
|
|
6605
6633
|
continuationContext.previousMessages
|
|
6606
6634
|
);
|
|
6607
|
-
const continuationGuardrail =
|
|
6635
|
+
const continuationGuardrail = this.buildContinuationGuardrail(state);
|
|
6608
6636
|
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
6637
|
const userMessage = continuationContext.newUserMessage || defaultContinueMessage;
|
|
6610
6638
|
const userContent = [
|
|
@@ -6856,7 +6884,8 @@ Do NOT redo any of the above work.`
|
|
|
6856
6884
|
}
|
|
6857
6885
|
};
|
|
6858
6886
|
_AgentsEndpoint.AUTO_COMPACT_SUMMARY_PREFIX = "You are continuing a long-running task. Here is a compact summary of prior work:";
|
|
6859
|
-
_AgentsEndpoint.
|
|
6887
|
+
_AgentsEndpoint.RESUMED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously saved task. Here is a summary of prior work:";
|
|
6888
|
+
_AgentsEndpoint.COMPLETED_COMPACT_SUMMARY_PREFIX = "You are continuing a previously completed task. Here is a summary of prior work:";
|
|
6860
6889
|
/** Error message patterns from server-side sessions that indicate a transient network failure
|
|
6861
6890
|
* (e.g. AI provider connection dropped). These are retried automatically. */
|
|
6862
6891
|
_AgentsEndpoint.RETRYABLE_SESSION_ERROR_PATTERNS = [
|
|
@@ -8232,4 +8261,3 @@ export {
|
|
|
8232
8261
|
sanitizeTaskSlug,
|
|
8233
8262
|
streamEvents
|
|
8234
8263
|
};
|
|
8235
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED