@evalops/maestro 0.10.29 → 0.10.31
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/agent/compaction/cut-points.d.ts +157 -0
- package/dist/agent/compaction/cut-points.d.ts.map +1 -0
- package/dist/agent/compaction/cut-points.js +341 -0
- package/dist/agent/compaction/cut-points.js.map +1 -0
- package/dist/agent/compaction.d.ts +4 -144
- package/dist/agent/compaction.d.ts.map +1 -1
- package/dist/agent/compaction.js +5 -340
- package/dist/agent/compaction.js.map +1 -1
- package/dist/agent/transport/events.d.ts +23 -0
- package/dist/agent/transport/events.d.ts.map +1 -0
- package/dist/agent/transport/events.js +69 -0
- package/dist/agent/transport/events.js.map +1 -0
- package/dist/agent/transport.d.ts.map +1 -1
- package/dist/agent/transport.js +1 -68
- package/dist/agent/transport.js.map +1 -1
- package/dist/cli.js +247 -203
- package/dist/node_modules/@evalops/contracts/package.json +1 -1
- package/dist/node_modules/@evalops/tui/package.json +1 -1
- package/dist/server/agent-runtime-ledger.d.ts +18 -3
- package/dist/server/agent-runtime-ledger.d.ts.map +1 -1
- package/dist/server/agent-runtime-ledger.js +45 -1
- package/dist/server/agent-runtime-ledger.js.map +1 -1
- package/dist/tools/parallel-ripgrep.d.ts.map +1 -1
- package/dist/tools/parallel-ripgrep.js +1 -10
- package/dist/tools/parallel-ripgrep.js.map +1 -1
- package/dist/tools/ripgrep-utils.d.ts +1 -0
- package/dist/tools/ripgrep-utils.d.ts.map +1 -1
- package/dist/tools/ripgrep-utils.js +9 -0
- package/dist/tools/ripgrep-utils.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +4 -4
- package/dist/tools/search.js.map +1 -1
- package/dist/version.json +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -64435,34 +64435,6 @@ var init_semantic_judge = __esm2(() => {
|
|
|
64435
64435
|
init_logger();
|
|
64436
64436
|
logger50 = createLogger("safety:semantic-judge");
|
|
64437
64437
|
});
|
|
64438
|
-
function normalizeSkillArtifactMetadata(value) {
|
|
64439
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
64440
|
-
return;
|
|
64441
|
-
}
|
|
64442
|
-
const candidate = value;
|
|
64443
|
-
if (typeof candidate.name !== "string" || candidate.name.trim().length === 0 || typeof candidate.hash !== "string" || candidate.hash.trim().length === 0 || typeof candidate.source !== "string" || candidate.source.trim().length === 0) {
|
|
64444
|
-
return;
|
|
64445
|
-
}
|
|
64446
|
-
return {
|
|
64447
|
-
name: candidate.name.trim(),
|
|
64448
|
-
hash: candidate.hash.trim(),
|
|
64449
|
-
source: candidate.source.trim(),
|
|
64450
|
-
...typeof candidate.artifactId === "string" && candidate.artifactId.trim().length > 0 ? { artifactId: candidate.artifactId.trim() } : {},
|
|
64451
|
-
...typeof candidate.version === "string" && candidate.version.trim().length > 0 ? { version: candidate.version.trim() } : {},
|
|
64452
|
-
...typeof candidate.sourcePath === "string" && candidate.sourcePath.trim().length > 0 ? { sourcePath: candidate.sourcePath.trim() } : {},
|
|
64453
|
-
...typeof candidate.scope === "string" && candidate.scope.trim().length > 0 ? { scope: candidate.scope.trim() } : {},
|
|
64454
|
-
...typeof candidate.workspaceId === "string" && candidate.workspaceId.trim().length > 0 ? { workspaceId: candidate.workspaceId.trim() } : {},
|
|
64455
|
-
...typeof candidate.ownerId === "string" && candidate.ownerId.trim().length > 0 ? { ownerId: candidate.ownerId.trim() } : {}
|
|
64456
|
-
};
|
|
64457
|
-
}
|
|
64458
|
-
function getSkillArtifactMetadataFromDetails(details) {
|
|
64459
|
-
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
64460
|
-
return;
|
|
64461
|
-
}
|
|
64462
|
-
return normalizeSkillArtifactMetadata(details.skillMetadata);
|
|
64463
|
-
}
|
|
64464
|
-
var init_artifact_metadata = () => {
|
|
64465
|
-
};
|
|
64466
64438
|
function isReadOnlyTool(toolName, annotations, _source) {
|
|
64467
64439
|
if (annotations?.readOnlyHint === true) {
|
|
64468
64440
|
return true;
|
|
@@ -72154,6 +72126,95 @@ async function* createProviderStream(model, context2, options, reasoning) {
|
|
|
72154
72126
|
}
|
|
72155
72127
|
throw new Error(`Unsupported API: ${model.api}`);
|
|
72156
72128
|
}
|
|
72129
|
+
function normalizeSkillArtifactMetadata(value) {
|
|
72130
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
72131
|
+
return;
|
|
72132
|
+
}
|
|
72133
|
+
const candidate = value;
|
|
72134
|
+
if (typeof candidate.name !== "string" || candidate.name.trim().length === 0 || typeof candidate.hash !== "string" || candidate.hash.trim().length === 0 || typeof candidate.source !== "string" || candidate.source.trim().length === 0) {
|
|
72135
|
+
return;
|
|
72136
|
+
}
|
|
72137
|
+
return {
|
|
72138
|
+
name: candidate.name.trim(),
|
|
72139
|
+
hash: candidate.hash.trim(),
|
|
72140
|
+
source: candidate.source.trim(),
|
|
72141
|
+
...typeof candidate.artifactId === "string" && candidate.artifactId.trim().length > 0 ? { artifactId: candidate.artifactId.trim() } : {},
|
|
72142
|
+
...typeof candidate.version === "string" && candidate.version.trim().length > 0 ? { version: candidate.version.trim() } : {},
|
|
72143
|
+
...typeof candidate.sourcePath === "string" && candidate.sourcePath.trim().length > 0 ? { sourcePath: candidate.sourcePath.trim() } : {},
|
|
72144
|
+
...typeof candidate.scope === "string" && candidate.scope.trim().length > 0 ? { scope: candidate.scope.trim() } : {},
|
|
72145
|
+
...typeof candidate.workspaceId === "string" && candidate.workspaceId.trim().length > 0 ? { workspaceId: candidate.workspaceId.trim() } : {},
|
|
72146
|
+
...typeof candidate.ownerId === "string" && candidate.ownerId.trim().length > 0 ? { ownerId: candidate.ownerId.trim() } : {}
|
|
72147
|
+
};
|
|
72148
|
+
}
|
|
72149
|
+
function getSkillArtifactMetadataFromDetails(details) {
|
|
72150
|
+
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
72151
|
+
return;
|
|
72152
|
+
}
|
|
72153
|
+
return normalizeSkillArtifactMetadata(details.skillMetadata);
|
|
72154
|
+
}
|
|
72155
|
+
var init_artifact_metadata = () => {
|
|
72156
|
+
};
|
|
72157
|
+
var AgentEventQueue = class {
|
|
72158
|
+
events = [];
|
|
72159
|
+
pending;
|
|
72160
|
+
wake;
|
|
72161
|
+
push(event) {
|
|
72162
|
+
this.events.push(event);
|
|
72163
|
+
if (this.wake) {
|
|
72164
|
+
const wake = this.wake;
|
|
72165
|
+
this.pending = void 0;
|
|
72166
|
+
this.wake = void 0;
|
|
72167
|
+
wake();
|
|
72168
|
+
}
|
|
72169
|
+
}
|
|
72170
|
+
shift() {
|
|
72171
|
+
return this.events.shift();
|
|
72172
|
+
}
|
|
72173
|
+
wait() {
|
|
72174
|
+
if (this.events.length > 0) {
|
|
72175
|
+
return Promise.resolve();
|
|
72176
|
+
}
|
|
72177
|
+
if (!this.pending) {
|
|
72178
|
+
this.pending = new Promise((resolve192) => {
|
|
72179
|
+
this.wake = resolve192;
|
|
72180
|
+
});
|
|
72181
|
+
}
|
|
72182
|
+
return this.pending;
|
|
72183
|
+
}
|
|
72184
|
+
clearPendingWaiter() {
|
|
72185
|
+
this.pending = void 0;
|
|
72186
|
+
this.wake = void 0;
|
|
72187
|
+
}
|
|
72188
|
+
};
|
|
72189
|
+
function isDynamicToolApprovalEvent(event) {
|
|
72190
|
+
return event.type === "action_approval_required" || event.type === "action_approval_resolved";
|
|
72191
|
+
}
|
|
72192
|
+
function getGovernedToolResultEventMetadata(details) {
|
|
72193
|
+
if (!details || typeof details !== "object") {
|
|
72194
|
+
return {};
|
|
72195
|
+
}
|
|
72196
|
+
const governedOutcome = details.governedOutcome;
|
|
72197
|
+
if (!governedOutcome || typeof governedOutcome !== "object") {
|
|
72198
|
+
return {};
|
|
72199
|
+
}
|
|
72200
|
+
const normalized = governedOutcome;
|
|
72201
|
+
const classification = typeof normalized.classification === "string" ? normalized.classification : void 0;
|
|
72202
|
+
const errorCode = typeof normalized.code === "string" && normalized.code.trim().length > 0 ? normalized.code.trim() : classification;
|
|
72203
|
+
const approvalRequestId = typeof normalized.approvalRequestId === "string" && normalized.approvalRequestId.trim().length > 0 ? normalized.approvalRequestId.trim() : void 0;
|
|
72204
|
+
return {
|
|
72205
|
+
errorCode,
|
|
72206
|
+
approvalRequestId,
|
|
72207
|
+
governedOutcome: classification
|
|
72208
|
+
};
|
|
72209
|
+
}
|
|
72210
|
+
function getSkillToolResultEventMetadata(details) {
|
|
72211
|
+
return {
|
|
72212
|
+
skillMetadata: getSkillArtifactMetadataFromDetails(details)
|
|
72213
|
+
};
|
|
72214
|
+
}
|
|
72215
|
+
var init_events = __esm2(() => {
|
|
72216
|
+
init_artifact_metadata();
|
|
72217
|
+
});
|
|
72157
72218
|
function stripTrailingSlashes2(value) {
|
|
72158
72219
|
return value.replace(/\/+$/u, "");
|
|
72159
72220
|
}
|
|
@@ -83730,64 +83791,6 @@ async function waitForNextExecutionOrUpdate(pendingExecutions, updateQueue) {
|
|
|
83730
83791
|
}
|
|
83731
83792
|
return next;
|
|
83732
83793
|
}
|
|
83733
|
-
var AgentEventQueue = class {
|
|
83734
|
-
events = [];
|
|
83735
|
-
pending;
|
|
83736
|
-
wake;
|
|
83737
|
-
push(event) {
|
|
83738
|
-
this.events.push(event);
|
|
83739
|
-
if (this.wake) {
|
|
83740
|
-
const wake = this.wake;
|
|
83741
|
-
this.pending = void 0;
|
|
83742
|
-
this.wake = void 0;
|
|
83743
|
-
wake();
|
|
83744
|
-
}
|
|
83745
|
-
}
|
|
83746
|
-
shift() {
|
|
83747
|
-
return this.events.shift();
|
|
83748
|
-
}
|
|
83749
|
-
wait() {
|
|
83750
|
-
if (this.events.length > 0) {
|
|
83751
|
-
return Promise.resolve();
|
|
83752
|
-
}
|
|
83753
|
-
if (!this.pending) {
|
|
83754
|
-
this.pending = new Promise((resolve202) => {
|
|
83755
|
-
this.wake = resolve202;
|
|
83756
|
-
});
|
|
83757
|
-
}
|
|
83758
|
-
return this.pending;
|
|
83759
|
-
}
|
|
83760
|
-
clearPendingWaiter() {
|
|
83761
|
-
this.pending = void 0;
|
|
83762
|
-
this.wake = void 0;
|
|
83763
|
-
}
|
|
83764
|
-
};
|
|
83765
|
-
function isDynamicToolApprovalEvent(event) {
|
|
83766
|
-
return event.type === "action_approval_required" || event.type === "action_approval_resolved";
|
|
83767
|
-
}
|
|
83768
|
-
function getGovernedToolResultEventMetadata(details) {
|
|
83769
|
-
if (!details || typeof details !== "object") {
|
|
83770
|
-
return {};
|
|
83771
|
-
}
|
|
83772
|
-
const governedOutcome = details.governedOutcome;
|
|
83773
|
-
if (!governedOutcome || typeof governedOutcome !== "object") {
|
|
83774
|
-
return {};
|
|
83775
|
-
}
|
|
83776
|
-
const normalized = governedOutcome;
|
|
83777
|
-
const classification = typeof normalized.classification === "string" ? normalized.classification : void 0;
|
|
83778
|
-
const errorCode = typeof normalized.code === "string" && normalized.code.trim().length > 0 ? normalized.code.trim() : classification;
|
|
83779
|
-
const approvalRequestId = typeof normalized.approvalRequestId === "string" && normalized.approvalRequestId.trim().length > 0 ? normalized.approvalRequestId.trim() : void 0;
|
|
83780
|
-
return {
|
|
83781
|
-
errorCode,
|
|
83782
|
-
approvalRequestId,
|
|
83783
|
-
governedOutcome: classification
|
|
83784
|
-
};
|
|
83785
|
-
}
|
|
83786
|
-
function getSkillToolResultEventMetadata(details) {
|
|
83787
|
-
return {
|
|
83788
|
-
skillMetadata: getSkillArtifactMetadataFromDetails(details)
|
|
83789
|
-
};
|
|
83790
|
-
}
|
|
83791
83794
|
var ProviderTransport = class _ProviderTransport {
|
|
83792
83795
|
options;
|
|
83793
83796
|
workflowState = new WorkflowStateTracker();
|
|
@@ -85352,11 +85355,11 @@ var init_transport = __esm2(() => {
|
|
|
85352
85355
|
init_safety_middleware();
|
|
85353
85356
|
init_semantic_judge();
|
|
85354
85357
|
init_workflow_state();
|
|
85355
|
-
init_artifact_metadata();
|
|
85356
85358
|
init_parallel_execution();
|
|
85357
85359
|
init_cost_tracker();
|
|
85358
85360
|
init_training();
|
|
85359
85361
|
init_keys();
|
|
85362
|
+
init_events();
|
|
85360
85363
|
init_reusable_tool_results();
|
|
85361
85364
|
init_tool_execution();
|
|
85362
85365
|
init_tool_safety_pipeline();
|
|
@@ -94851,7 +94854,6 @@ var init_compaction_cleanup = __esm2(() => {
|
|
|
94851
94854
|
logger89 = createLogger("compaction-cleanup");
|
|
94852
94855
|
cleanupHandlers = /* @__PURE__ */ new Map();
|
|
94853
94856
|
});
|
|
94854
|
-
var SESSION_START_INITIAL_USER_METADATA_KIND = "session_start_initial_user";
|
|
94855
94857
|
function calculateContextTokens(usage4) {
|
|
94856
94858
|
return usage4.input + usage4.output + usage4.cacheRead + usage4.cacheWrite;
|
|
94857
94859
|
}
|
|
@@ -94864,6 +94866,107 @@ function getAssistantUsage(msg) {
|
|
|
94864
94866
|
}
|
|
94865
94867
|
return null;
|
|
94866
94868
|
}
|
|
94869
|
+
function getLastAssistantUsage(messages) {
|
|
94870
|
+
for (let i2 = messages.length - 1; i2 >= 0; i2--) {
|
|
94871
|
+
const usage4 = getAssistantUsage(messages[i2]);
|
|
94872
|
+
if (usage4)
|
|
94873
|
+
return usage4;
|
|
94874
|
+
}
|
|
94875
|
+
return null;
|
|
94876
|
+
}
|
|
94877
|
+
function findTurnBoundaries(messages, startIndex, endIndex) {
|
|
94878
|
+
const boundaries = [];
|
|
94879
|
+
for (let i2 = startIndex; i2 < endIndex; i2++) {
|
|
94880
|
+
if (messages[i2].role === "user") {
|
|
94881
|
+
boundaries.push(i2);
|
|
94882
|
+
}
|
|
94883
|
+
}
|
|
94884
|
+
return boundaries;
|
|
94885
|
+
}
|
|
94886
|
+
function findCutPoint(messages, startIndex, endIndex, keepRecentTokens) {
|
|
94887
|
+
const boundaries = findTurnBoundaries(messages, startIndex, endIndex);
|
|
94888
|
+
if (boundaries.length === 0) {
|
|
94889
|
+
return startIndex;
|
|
94890
|
+
}
|
|
94891
|
+
const assistantUsages = [];
|
|
94892
|
+
for (let i2 = endIndex - 1; i2 >= startIndex; i2--) {
|
|
94893
|
+
const usage4 = getAssistantUsage(messages[i2]);
|
|
94894
|
+
if (usage4) {
|
|
94895
|
+
assistantUsages.push({
|
|
94896
|
+
index: i2,
|
|
94897
|
+
tokens: calculateContextTokens(usage4)
|
|
94898
|
+
});
|
|
94899
|
+
}
|
|
94900
|
+
}
|
|
94901
|
+
if (assistantUsages.length === 0) {
|
|
94902
|
+
return boundaries[boundaries.length - 1];
|
|
94903
|
+
}
|
|
94904
|
+
const newestTokens = assistantUsages[0].tokens;
|
|
94905
|
+
let cutIndex = startIndex;
|
|
94906
|
+
for (let i2 = 1; i2 < assistantUsages.length; i2++) {
|
|
94907
|
+
const tokenDiff = newestTokens - assistantUsages[i2].tokens;
|
|
94908
|
+
if (tokenDiff >= keepRecentTokens) {
|
|
94909
|
+
const lastKeptAssistantIndex = assistantUsages[i2 - 1].index;
|
|
94910
|
+
for (let b = boundaries.length - 1; b >= 0; b--) {
|
|
94911
|
+
const boundary = boundaries[b];
|
|
94912
|
+
if (boundary !== void 0 && boundary <= lastKeptAssistantIndex) {
|
|
94913
|
+
cutIndex = boundary;
|
|
94914
|
+
break;
|
|
94915
|
+
}
|
|
94916
|
+
}
|
|
94917
|
+
break;
|
|
94918
|
+
}
|
|
94919
|
+
}
|
|
94920
|
+
return cutIndex;
|
|
94921
|
+
}
|
|
94922
|
+
function adjustBoundaryForToolResults(messages, boundary) {
|
|
94923
|
+
let adjusted = boundary;
|
|
94924
|
+
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
94925
|
+
const missingToolCalls = /* @__PURE__ */ new Set();
|
|
94926
|
+
const processAssistantMessage = (message) => {
|
|
94927
|
+
if (message.role !== "assistant")
|
|
94928
|
+
return;
|
|
94929
|
+
const content = message.content;
|
|
94930
|
+
if (!content)
|
|
94931
|
+
return;
|
|
94932
|
+
for (const part of content) {
|
|
94933
|
+
if (part?.type === "toolCall") {
|
|
94934
|
+
seenToolCalls.add(part.id);
|
|
94935
|
+
if (missingToolCalls.has(part.id)) {
|
|
94936
|
+
missingToolCalls.delete(part.id);
|
|
94937
|
+
}
|
|
94938
|
+
}
|
|
94939
|
+
}
|
|
94940
|
+
};
|
|
94941
|
+
const processToolResultMessage = (message) => {
|
|
94942
|
+
if (message.role !== "toolResult")
|
|
94943
|
+
return;
|
|
94944
|
+
const toolCallId2 = message.toolCallId;
|
|
94945
|
+
if (!seenToolCalls.has(toolCallId2)) {
|
|
94946
|
+
missingToolCalls.add(toolCallId2);
|
|
94947
|
+
}
|
|
94948
|
+
};
|
|
94949
|
+
for (const message of messages.slice(adjusted)) {
|
|
94950
|
+
processAssistantMessage(message);
|
|
94951
|
+
processToolResultMessage(message);
|
|
94952
|
+
}
|
|
94953
|
+
while (missingToolCalls.size > 0 && adjusted > 0) {
|
|
94954
|
+
adjusted -= 1;
|
|
94955
|
+
const candidate = messages[adjusted];
|
|
94956
|
+
processAssistantMessage(candidate);
|
|
94957
|
+
processToolResultMessage(candidate);
|
|
94958
|
+
}
|
|
94959
|
+
return adjusted;
|
|
94960
|
+
}
|
|
94961
|
+
var DEFAULT_COMPACTION_SETTINGS;
|
|
94962
|
+
var init_cut_points = __esm2(() => {
|
|
94963
|
+
DEFAULT_COMPACTION_SETTINGS = {
|
|
94964
|
+
enabled: true,
|
|
94965
|
+
reserveTokens: 16384,
|
|
94966
|
+
keepRecentTokens: 2e4
|
|
94967
|
+
};
|
|
94968
|
+
});
|
|
94969
|
+
var SESSION_START_INITIAL_USER_METADATA_KIND = "session_start_initial_user";
|
|
94867
94970
|
function shouldSkipAssistantCompactionMessage(message) {
|
|
94868
94971
|
return message.role === "assistant" && (message.stopReason === "aborted" || message.stopReason === "error");
|
|
94869
94972
|
}
|
|
@@ -95560,98 +95663,6 @@ function truncateSummaryInputForOverflowRetry(messages, overflowErrorMessage) {
|
|
|
95560
95663
|
};
|
|
95561
95664
|
return preamble ? [preamble, markerMessage, ...truncatedBody] : [markerMessage, ...truncatedBody];
|
|
95562
95665
|
}
|
|
95563
|
-
function getLastAssistantUsage(messages) {
|
|
95564
|
-
for (let i2 = messages.length - 1; i2 >= 0; i2--) {
|
|
95565
|
-
const usage4 = getAssistantUsage(messages[i2]);
|
|
95566
|
-
if (usage4)
|
|
95567
|
-
return usage4;
|
|
95568
|
-
}
|
|
95569
|
-
return null;
|
|
95570
|
-
}
|
|
95571
|
-
function findTurnBoundaries(messages, startIndex, endIndex) {
|
|
95572
|
-
const boundaries = [];
|
|
95573
|
-
for (let i2 = startIndex; i2 < endIndex; i2++) {
|
|
95574
|
-
if (messages[i2].role === "user") {
|
|
95575
|
-
boundaries.push(i2);
|
|
95576
|
-
}
|
|
95577
|
-
}
|
|
95578
|
-
return boundaries;
|
|
95579
|
-
}
|
|
95580
|
-
function findCutPoint(messages, startIndex, endIndex, keepRecentTokens) {
|
|
95581
|
-
const boundaries = findTurnBoundaries(messages, startIndex, endIndex);
|
|
95582
|
-
if (boundaries.length === 0) {
|
|
95583
|
-
return startIndex;
|
|
95584
|
-
}
|
|
95585
|
-
const assistantUsages = [];
|
|
95586
|
-
for (let i2 = endIndex - 1; i2 >= startIndex; i2--) {
|
|
95587
|
-
const usage4 = getAssistantUsage(messages[i2]);
|
|
95588
|
-
if (usage4) {
|
|
95589
|
-
assistantUsages.push({
|
|
95590
|
-
index: i2,
|
|
95591
|
-
tokens: calculateContextTokens(usage4)
|
|
95592
|
-
});
|
|
95593
|
-
}
|
|
95594
|
-
}
|
|
95595
|
-
if (assistantUsages.length === 0) {
|
|
95596
|
-
return boundaries[boundaries.length - 1];
|
|
95597
|
-
}
|
|
95598
|
-
const newestTokens = assistantUsages[0].tokens;
|
|
95599
|
-
let cutIndex = startIndex;
|
|
95600
|
-
for (let i2 = 1; i2 < assistantUsages.length; i2++) {
|
|
95601
|
-
const tokenDiff = newestTokens - assistantUsages[i2].tokens;
|
|
95602
|
-
if (tokenDiff >= keepRecentTokens) {
|
|
95603
|
-
const lastKeptAssistantIndex = assistantUsages[i2 - 1].index;
|
|
95604
|
-
for (let b = boundaries.length - 1; b >= 0; b--) {
|
|
95605
|
-
const boundary = boundaries[b];
|
|
95606
|
-
if (boundary !== void 0 && boundary <= lastKeptAssistantIndex) {
|
|
95607
|
-
cutIndex = boundary;
|
|
95608
|
-
break;
|
|
95609
|
-
}
|
|
95610
|
-
}
|
|
95611
|
-
break;
|
|
95612
|
-
}
|
|
95613
|
-
}
|
|
95614
|
-
return cutIndex;
|
|
95615
|
-
}
|
|
95616
|
-
function adjustBoundaryForToolResults(messages, boundary) {
|
|
95617
|
-
let adjusted = boundary;
|
|
95618
|
-
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
95619
|
-
const missingToolCalls = /* @__PURE__ */ new Set();
|
|
95620
|
-
const processAssistantMessage = (message) => {
|
|
95621
|
-
if (message.role !== "assistant")
|
|
95622
|
-
return;
|
|
95623
|
-
const content = message.content;
|
|
95624
|
-
if (!content)
|
|
95625
|
-
return;
|
|
95626
|
-
for (const part of content) {
|
|
95627
|
-
if (part?.type === "toolCall") {
|
|
95628
|
-
seenToolCalls.add(part.id);
|
|
95629
|
-
if (missingToolCalls.has(part.id)) {
|
|
95630
|
-
missingToolCalls.delete(part.id);
|
|
95631
|
-
}
|
|
95632
|
-
}
|
|
95633
|
-
}
|
|
95634
|
-
};
|
|
95635
|
-
const processToolResultMessage = (message) => {
|
|
95636
|
-
if (message.role !== "toolResult")
|
|
95637
|
-
return;
|
|
95638
|
-
const toolCallId2 = message.toolCallId;
|
|
95639
|
-
if (!seenToolCalls.has(toolCallId2)) {
|
|
95640
|
-
missingToolCalls.add(toolCallId2);
|
|
95641
|
-
}
|
|
95642
|
-
};
|
|
95643
|
-
for (const message of messages.slice(adjusted)) {
|
|
95644
|
-
processAssistantMessage(message);
|
|
95645
|
-
processToolResultMessage(message);
|
|
95646
|
-
}
|
|
95647
|
-
while (missingToolCalls.size > 0 && adjusted > 0) {
|
|
95648
|
-
adjusted -= 1;
|
|
95649
|
-
const candidate = messages[adjusted];
|
|
95650
|
-
processAssistantMessage(candidate);
|
|
95651
|
-
processToolResultMessage(candidate);
|
|
95652
|
-
}
|
|
95653
|
-
return adjusted;
|
|
95654
|
-
}
|
|
95655
95666
|
function buildSummarizationPrompt(customInstructions) {
|
|
95656
95667
|
if (customInstructions) {
|
|
95657
95668
|
return `${SUMMARIZATION_PROMPT}
|
|
@@ -96003,7 +96014,6 @@ ${previousSummary}`,
|
|
|
96003
96014
|
};
|
|
96004
96015
|
}
|
|
96005
96016
|
var logger90;
|
|
96006
|
-
var DEFAULT_COMPACTION_SETTINGS;
|
|
96007
96017
|
var COMPACTION_RESUME_PROMPT = "Use the above summary to resume the plan from where we left off.";
|
|
96008
96018
|
var MAX_COMPACTION_OVERFLOW_RETRIES = 3;
|
|
96009
96019
|
var PREVIOUS_SUMMARY_PREFIX = `Previous session summary:
|
|
@@ -96035,15 +96045,12 @@ var init_compaction = __esm2(() => {
|
|
|
96035
96045
|
init_path_validation();
|
|
96036
96046
|
init_compaction_cleanup();
|
|
96037
96047
|
init_compaction_hooks();
|
|
96048
|
+
init_cut_points();
|
|
96049
|
+
init_cut_points();
|
|
96038
96050
|
init_compaction_restoration();
|
|
96039
96051
|
init_context_overflow();
|
|
96040
96052
|
init_plan_mode();
|
|
96041
96053
|
logger90 = createLogger("agent:compaction");
|
|
96042
|
-
DEFAULT_COMPACTION_SETTINGS = {
|
|
96043
|
-
enabled: true,
|
|
96044
|
-
reserveTokens: 16384,
|
|
96045
|
-
keepRecentTokens: 2e4
|
|
96046
|
-
};
|
|
96047
96054
|
});
|
|
96048
96055
|
var exports_task_budget_access = {};
|
|
96049
96056
|
__export2(exports_task_budget_access, {
|
|
@@ -142452,8 +142459,8 @@ ${renderCard([
|
|
|
142452
142459
|
const summary2 = buildDiffSummary(diffValue);
|
|
142453
142460
|
sections.push(summary2);
|
|
142454
142461
|
const diffLines22 = highlightCodeLines(diffValue, "diff");
|
|
142455
|
-
const
|
|
142456
|
-
const renderedLines =
|
|
142462
|
+
const shouldCompact2 = diffStyle === "auto" && terminalWidth < 90;
|
|
142463
|
+
const renderedLines = shouldCompact2 ? clampAnsiLines(diffLines22.slice(0, 80).concat(diffLines22.length > 80 ? [`${theme.fg("dim", "... truncated ...")}`] : []), maxDiffWidth) : clampAnsiLines(diffLines22, maxDiffWidth);
|
|
142457
142464
|
sections.push(renderedLines.join(`
|
|
142458
142465
|
`));
|
|
142459
142466
|
} else if (typeof context2.args?.before === "string" && typeof context2.args?.after === "string") {
|
|
@@ -160145,6 +160152,15 @@ function toArray(value) {
|
|
|
160145
160152
|
}
|
|
160146
160153
|
return Array.isArray(value) ? value : [value];
|
|
160147
160154
|
}
|
|
160155
|
+
function shellQuoteArg(value) {
|
|
160156
|
+
if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {
|
|
160157
|
+
return value;
|
|
160158
|
+
}
|
|
160159
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
160160
|
+
}
|
|
160161
|
+
function formatRipgrepCommand(args) {
|
|
160162
|
+
return ["rg", ...args].map(shellQuoteArg).join(" ");
|
|
160163
|
+
}
|
|
160148
160164
|
async function runRipgrep(args, signal, cwd) {
|
|
160149
160165
|
const child = spawn17("rg", args, {
|
|
160150
160166
|
cwd: cwd ?? process.cwd(),
|
|
@@ -160235,15 +160251,6 @@ var init_ripgrep_utils = __esm2(() => {
|
|
|
160235
160251
|
}), { minItems: 1 })
|
|
160236
160252
|
]));
|
|
160237
160253
|
});
|
|
160238
|
-
function shellQuoteArg(value) {
|
|
160239
|
-
if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {
|
|
160240
|
-
return value;
|
|
160241
|
-
}
|
|
160242
|
-
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
160243
|
-
}
|
|
160244
|
-
function formatRipgrepCommand(args) {
|
|
160245
|
-
return ["rg", ...args].map(shellQuoteArg).join(" ");
|
|
160246
|
-
}
|
|
160247
160254
|
function mergeRanges(ranges) {
|
|
160248
160255
|
const sorted = [...ranges].sort((a, b) => a.start - b.start);
|
|
160249
160256
|
const merged = [];
|
|
@@ -160742,20 +160749,20 @@ Examples:
|
|
|
160742
160749
|
} else {
|
|
160743
160750
|
args.push(".");
|
|
160744
160751
|
}
|
|
160752
|
+
const command = formatRipgrepCommand(args);
|
|
160745
160753
|
let result2;
|
|
160746
160754
|
try {
|
|
160747
160755
|
result2 = await runRipgrep(args, signal, commandCwd);
|
|
160748
160756
|
} catch (error) {
|
|
160749
160757
|
const reason = error instanceof Error ? error.message : `Unknown error: ${String(error)}`;
|
|
160750
|
-
return respond.
|
|
160758
|
+
return respond.error(`ripgrep failed
|
|
160751
160759
|
|
|
160752
|
-
${reason}`).detail({ command
|
|
160760
|
+
${reason}`).detail({ command, cwd: commandCwd });
|
|
160753
160761
|
}
|
|
160754
160762
|
if (result2.exitCode === 2) {
|
|
160755
160763
|
const message = result2.stderr.trim() || result2.stdout.trim();
|
|
160756
160764
|
throw new Error(message.length > 0 ? message : "ripgrep exited with an error");
|
|
160757
160765
|
}
|
|
160758
|
-
const command = ["rg", ...args].join(" ");
|
|
160759
160766
|
if (result2.exitCode === 1 || result2.stdout.trim().length === 0) {
|
|
160760
160767
|
const detailFormat = outputMode === "files" ? "files" : outputMode === "count" ? "count" : format;
|
|
160761
160768
|
return respond.text("No matches found.").detail({ command, cwd: commandCwd, format: detailFormat });
|
|
@@ -196854,6 +196861,32 @@ function waitTypeForEntry(kind, timelineItem) {
|
|
|
196854
196861
|
return "AGENT_RUN_WAIT_TYPE_INPUT";
|
|
196855
196862
|
return "AGENT_RUN_WAIT_TYPE_APPROVAL";
|
|
196856
196863
|
}
|
|
196864
|
+
function firstEvidenceIdForEvent(event, kind) {
|
|
196865
|
+
return event.evidence.find((anchor) => anchor.kind === kind)?.id;
|
|
196866
|
+
}
|
|
196867
|
+
function hasCorrelation(correlation) {
|
|
196868
|
+
return Object.values(correlation).some((value) => typeof value === "string" && value.length > 0);
|
|
196869
|
+
}
|
|
196870
|
+
function correlationForEvent(event, timelineItem) {
|
|
196871
|
+
const pendingRequestId = timelineItem?.pendingRequestId ?? firstEvidenceIdForEvent(event, "pending_request");
|
|
196872
|
+
const approvalRequestId = timelineItem?.approvalRequestId ?? firstEvidenceIdForEvent(event, "approval_request");
|
|
196873
|
+
const toolExecutionId = timelineItem?.toolExecutionId ?? firstEvidenceIdForEvent(event, "tool_execution");
|
|
196874
|
+
const artifactId = timelineItem?.artifactId ?? firstEvidenceIdForEvent(event, "artifact");
|
|
196875
|
+
const agentRunId = timelineItem?.agentRunId ?? firstEvidenceIdForEvent(event, "agent_run");
|
|
196876
|
+
const parentAgentRunId = timelineItem?.parentAgentRunId ?? firstEvidenceIdForEvent(event, "parent_agent_run");
|
|
196877
|
+
const childAgentRunId = timelineItem?.childAgentRunId ?? firstEvidenceIdForEvent(event, "child_agent_run");
|
|
196878
|
+
const correlation = {
|
|
196879
|
+
...pendingRequestId ? { pendingRequestId } : {},
|
|
196880
|
+
...timelineItem?.pendingRequestKind ? { pendingRequestKind: timelineItem.pendingRequestKind } : {},
|
|
196881
|
+
...approvalRequestId ? { approvalRequestId } : {},
|
|
196882
|
+
...toolExecutionId ? { toolExecutionId } : {},
|
|
196883
|
+
...artifactId ? { artifactId } : {},
|
|
196884
|
+
...agentRunId ? { agentRunId } : {},
|
|
196885
|
+
...parentAgentRunId ? { parentAgentRunId } : {},
|
|
196886
|
+
...childAgentRunId ? { childAgentRunId } : {}
|
|
196887
|
+
};
|
|
196888
|
+
return hasCorrelation(correlation) ? correlation : void 0;
|
|
196889
|
+
}
|
|
196857
196890
|
function buildLedgerEntries(timeline, trajectory) {
|
|
196858
196891
|
const timelineItemsById = new Map(timeline.items.map((item) => [item.id, item]));
|
|
196859
196892
|
return trajectory.events.map((event) => {
|
|
@@ -196862,6 +196895,7 @@ function buildLedgerEntries(timeline, trajectory) {
|
|
|
196862
196895
|
const timelineItemId = timelineIdForEvent(event);
|
|
196863
196896
|
const timelineItem = timelineItemId ? timelineItemsById.get(timelineItemId) : void 0;
|
|
196864
196897
|
const waitType = waitTypeForEntry(kind, timelineItem);
|
|
196898
|
+
const correlation = correlationForEvent(event, timelineItem);
|
|
196865
196899
|
return {
|
|
196866
196900
|
id: `ledger:${event.id}`,
|
|
196867
196901
|
sequence: event.sequence,
|
|
@@ -196880,6 +196914,7 @@ function buildLedgerEntries(timeline, trajectory) {
|
|
|
196880
196914
|
...event.summary ? { summary: event.summary } : {},
|
|
196881
196915
|
relatedIds: event.relatedIds ?? [],
|
|
196882
196916
|
evidence: event.evidence,
|
|
196917
|
+
...correlation ? { correlation } : {},
|
|
196883
196918
|
platformShape: {
|
|
196884
196919
|
stepKind: stepKindForEntry(kind, event),
|
|
196885
196920
|
workItemKind: workItemKindForEntry(kind),
|
|
@@ -196961,7 +196996,8 @@ function workItemPayloadForEntry(sessionId, entry2) {
|
|
|
196961
196996
|
...entry2.timelineItemId ? { timelineItemId: entry2.timelineItemId } : {},
|
|
196962
196997
|
...entry2.toolName ? { toolName: entry2.toolName } : {},
|
|
196963
196998
|
...entry2.summary ? { summary: entry2.summary } : {},
|
|
196964
|
-
...entry2.relatedIds.length > 0 ? { relatedIds: entry2.relatedIds } : {}
|
|
196999
|
+
...entry2.relatedIds.length > 0 ? { relatedIds: entry2.relatedIds } : {},
|
|
197000
|
+
...entry2.correlation ? { correlation: entry2.correlation } : {}
|
|
196965
197001
|
};
|
|
196966
197002
|
}
|
|
196967
197003
|
function terminalEntry(entries) {
|
|
@@ -196988,6 +197024,11 @@ function terminalOperation(runId, entries) {
|
|
|
196988
197024
|
payload: {
|
|
196989
197025
|
state: succeeded ? "succeeded" : "failed",
|
|
196990
197026
|
timestamp: terminal.timestamp,
|
|
197027
|
+
ledgerEntryId: terminal.id,
|
|
197028
|
+
trajectoryEventId: terminal.trajectoryEventId,
|
|
197029
|
+
eventType: terminal.type,
|
|
197030
|
+
title: terminal.title,
|
|
197031
|
+
evidenceRefs: evidenceRefsForEntry(terminal),
|
|
196991
197032
|
...succeeded ? {} : {
|
|
196992
197033
|
reason: `Terminal ledger entry ended in ${terminal.state} state.`
|
|
196993
197034
|
}
|
|
@@ -197023,7 +197064,8 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
|
|
|
197023
197064
|
}
|
|
197024
197065
|
];
|
|
197025
197066
|
for (const entry2 of entries) {
|
|
197026
|
-
const
|
|
197067
|
+
const correlation = entry2.correlation ?? {};
|
|
197068
|
+
const toolExecutionId = correlation.toolExecutionId ?? firstEvidenceId2(entry2, "tool_execution");
|
|
197027
197069
|
const evidenceRefs = evidenceRefsForEntry(entry2);
|
|
197028
197070
|
const waitId = entry2.platformShape.waitType ? entry2.id : void 0;
|
|
197029
197071
|
operations.push({
|
|
@@ -197050,6 +197092,7 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
|
|
|
197050
197092
|
title: entry2.title,
|
|
197051
197093
|
timestamp: entry2.timestamp,
|
|
197052
197094
|
...waitId ? { waitId } : {},
|
|
197095
|
+
...correlation,
|
|
197053
197096
|
...toolExecutionId ? { toolExecutionId } : {},
|
|
197054
197097
|
evidenceRefs,
|
|
197055
197098
|
completionGate: "maestro_agent_runtime_ledger_recorded",
|
|
@@ -197065,7 +197108,8 @@ function buildPromotionPlan(runId, sessionId, generatedAt, entries) {
|
|
|
197065
197108
|
waitId: entry2.id,
|
|
197066
197109
|
waitType: entry2.platformShape.waitType,
|
|
197067
197110
|
title: entry2.title,
|
|
197068
|
-
timestamp: entry2.timestamp
|
|
197111
|
+
timestamp: entry2.timestamp,
|
|
197112
|
+
...correlation
|
|
197069
197113
|
}
|
|
197070
197114
|
});
|
|
197071
197115
|
}
|
|
@@ -7,6 +7,16 @@ export declare const AGENT_RUNTIME_PROMOTION_PLAN_SCHEMA = "evalops.maestro.agen
|
|
|
7
7
|
export type AgentRuntimeLedgerEntryKind = "run" | "message" | "model_call" | "tool_call" | "tool_result" | "wait" | "checkpoint" | "artifact" | "evidence" | "governance" | "context" | "child_run" | "runtime";
|
|
8
8
|
export type AgentRuntimeLedgerState = "pending" | "running" | "waiting" | "blocked" | "succeeded" | "failed" | "cancelled" | "skipped";
|
|
9
9
|
type AgentRuntimePromotionStepState = Exclude<AgentRuntimeLedgerState, "blocked">;
|
|
10
|
+
export interface AgentRuntimeLedgerCorrelation {
|
|
11
|
+
pendingRequestId?: string;
|
|
12
|
+
pendingRequestKind?: ComposerRunTimelineItem["pendingRequestKind"];
|
|
13
|
+
approvalRequestId?: string;
|
|
14
|
+
toolExecutionId?: string;
|
|
15
|
+
artifactId?: string;
|
|
16
|
+
agentRunId?: string;
|
|
17
|
+
parentAgentRunId?: string;
|
|
18
|
+
childAgentRunId?: string;
|
|
19
|
+
}
|
|
10
20
|
export interface AgentRuntimeLedgerEntry {
|
|
11
21
|
id: string;
|
|
12
22
|
sequence: number;
|
|
@@ -25,6 +35,7 @@ export interface AgentRuntimeLedgerEntry {
|
|
|
25
35
|
summary?: string;
|
|
26
36
|
relatedIds: string[];
|
|
27
37
|
evidence: AgentTrajectoryEvent["evidence"];
|
|
38
|
+
correlation?: AgentRuntimeLedgerCorrelation;
|
|
28
39
|
platformShape: {
|
|
29
40
|
stepKind: string;
|
|
30
41
|
workItemKind: string;
|
|
@@ -106,11 +117,10 @@ export type AgentRuntimePromotionOperation = {
|
|
|
106
117
|
title: string;
|
|
107
118
|
timestamp: string;
|
|
108
119
|
waitId?: string;
|
|
109
|
-
toolExecutionId?: string;
|
|
110
120
|
evidenceRefs?: string[];
|
|
111
121
|
completionGate?: string;
|
|
112
122
|
payload?: Record<string, unknown>;
|
|
113
|
-
};
|
|
123
|
+
} & AgentRuntimeLedgerCorrelation;
|
|
114
124
|
} | {
|
|
115
125
|
operation: "wait_run";
|
|
116
126
|
id: string;
|
|
@@ -120,7 +130,7 @@ export type AgentRuntimePromotionOperation = {
|
|
|
120
130
|
waitType: string;
|
|
121
131
|
title: string;
|
|
122
132
|
timestamp: string;
|
|
123
|
-
};
|
|
133
|
+
} & AgentRuntimeLedgerCorrelation;
|
|
124
134
|
} | {
|
|
125
135
|
operation: "complete_run" | "fail_run";
|
|
126
136
|
id: string;
|
|
@@ -128,6 +138,11 @@ export type AgentRuntimePromotionOperation = {
|
|
|
128
138
|
state: "succeeded" | "failed";
|
|
129
139
|
timestamp: string;
|
|
130
140
|
reason?: string;
|
|
141
|
+
ledgerEntryId: string;
|
|
142
|
+
trajectoryEventId: string;
|
|
143
|
+
eventType: string;
|
|
144
|
+
title: string;
|
|
145
|
+
evidenceRefs: string[];
|
|
131
146
|
};
|
|
132
147
|
};
|
|
133
148
|
export interface BuildAgentRuntimeLedgerOptions {
|