@myagentroam/agent 0.15.6 → 0.15.8
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.
|
@@ -41,6 +41,7 @@ export function collectExecCandidates(input, groups, existingTargets, candidateS
|
|
|
41
41
|
const lifecycle = selected.map((fact) => invocations.get(fact.callId));
|
|
42
42
|
const final = lifecycle.at(-1);
|
|
43
43
|
const evidenceSequence = final.group.result.record.sequence;
|
|
44
|
+
const terminalCallId = final.group.callId;
|
|
44
45
|
const replacements = [];
|
|
45
46
|
for (const invocation of lifecycle) {
|
|
46
47
|
if (invocation.group.evidenceOnly)
|
|
@@ -61,16 +62,17 @@ export function collectExecCandidates(input, groups, existingTargets, candidateS
|
|
|
61
62
|
providerAliasTargets: invocation.group.aliases
|
|
62
63
|
.map(({ record, message }) => targetFor(record, message))
|
|
63
64
|
.filter((target) => target !== undefined),
|
|
64
|
-
evidenceSequence
|
|
65
|
+
evidenceSequence,
|
|
66
|
+
terminalCallId
|
|
65
67
|
});
|
|
66
68
|
if (!existingTargets.has(contextGcTargetKey(resultTarget)))
|
|
67
69
|
replacements.push({
|
|
68
70
|
kind: 'EXEC_OUTPUT',
|
|
69
|
-
...(resultTarget.observationId ? { terminalCallId: final.group.callId } : {}),
|
|
70
71
|
callId: invocation.group.callId,
|
|
71
72
|
target: resultTarget,
|
|
72
73
|
replacementContent: contextGcExecOutputReplacement(invocation.result),
|
|
73
|
-
evidenceSequence
|
|
74
|
+
evidenceSequence,
|
|
75
|
+
terminalCallId
|
|
74
76
|
});
|
|
75
77
|
}
|
|
76
78
|
if (replacements.length === 0)
|
|
@@ -613,15 +613,12 @@ function replacementMatchesRecords(replacement, records, recordsBySequence, work
|
|
|
613
613
|
return (replacement.replacementContent ===
|
|
614
614
|
contextGcWebOutputReplacement(replacement.toolName, sourceEvidence.result.payload.content, sourceEvidence.completed.payload.truncated));
|
|
615
615
|
}
|
|
616
|
-
|
|
616
|
+
const result = execReplacementResult(replacement, source, records, recordsBySequence);
|
|
617
|
+
if (!result)
|
|
617
618
|
return false;
|
|
618
619
|
if (replacement.kind === 'TOOL_CALL_INPUT')
|
|
619
620
|
return isDeepStrictEqual(replacement.replacementArguments, contextGcExecInputReplacement(source.payload.arguments, replacement.toolName));
|
|
620
|
-
|
|
621
|
-
successfulToolEvidence(records, recordsBySequence, source.sequence, 'exec_wait', replacement.callId);
|
|
622
|
-
const result = normalizeContextGcExecResult(source.payload.content, targetEvidence?.completed.payload);
|
|
623
|
-
return (result !== undefined &&
|
|
624
|
-
replacement.replacementContent === contextGcExecOutputReplacement(result));
|
|
621
|
+
return replacement.replacementContent === contextGcExecOutputReplacement(result);
|
|
625
622
|
}
|
|
626
623
|
function toolNameForCallId(records, callId, beforeSequence) {
|
|
627
624
|
const call = modelToolCallForCallId(records, callId, beforeSequence);
|
|
@@ -777,15 +774,19 @@ function appliedPatchEvidenceForPath(records, recordsBySequence, evidenceSequenc
|
|
|
777
774
|
? { callId, file: { operation: file.operation } }
|
|
778
775
|
: undefined;
|
|
779
776
|
}
|
|
780
|
-
function
|
|
781
|
-
const
|
|
782
|
-
|
|
783
|
-
|
|
777
|
+
function execReplacementResult(replacement, source, records, recordsBySequence) {
|
|
778
|
+
const evidencePayload = recordsBySequence.get(replacement.evidenceSequence)?.payload;
|
|
779
|
+
// A Direct result identifies its own call; a cell result needs the nested call ID.
|
|
780
|
+
const terminalCallId = replacement.terminalCallId ?? (isRecord(evidencePayload) ? evidencePayload.callId : undefined);
|
|
781
|
+
if (typeof terminalCallId !== 'string' || !terminalCallId)
|
|
782
|
+
return undefined;
|
|
783
|
+
const evidence = successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'exec', terminalCallId) ??
|
|
784
|
+
successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'exec_wait', terminalCallId);
|
|
784
785
|
if (!evidence || !isRecord(evidence.call.payload) || !isRecord(evidence.result.payload))
|
|
785
|
-
return
|
|
786
|
+
return undefined;
|
|
786
787
|
const finalResult = normalizeContextGcExecResult(evidence.result.payload.content, evidence.completed.payload);
|
|
787
788
|
if (!finalResult || finalResult.status === 'running')
|
|
788
|
-
return
|
|
789
|
+
return undefined;
|
|
789
790
|
const targetCall = replacement.kind === 'TOOL_CALL_INPUT'
|
|
790
791
|
? source
|
|
791
792
|
: modelToolCallForCallId(records, replacement.callId, source.sequence);
|
|
@@ -795,33 +796,28 @@ function isSuccessfulExecLifecycleEvidence(replacement, source, records, records
|
|
|
795
796
|
targetCall.payload.role !== 'tool_call' ||
|
|
796
797
|
(targetCall.payload.name !== 'exec' && targetCall.payload.name !== 'exec_wait') ||
|
|
797
798
|
targetCall.payload.callId !== replacement.callId)
|
|
798
|
-
return
|
|
799
|
+
return undefined;
|
|
799
800
|
const targetResult = replacement.kind === 'EXEC_OUTPUT'
|
|
800
801
|
? source
|
|
801
802
|
: modelToolResultForCall(records, targetCall, evidence.result.sequence);
|
|
802
|
-
if (!targetResult)
|
|
803
|
-
return
|
|
803
|
+
if (!targetResult || !isRecord(targetResult.payload))
|
|
804
|
+
return undefined;
|
|
804
805
|
const targetEvidence = successfulToolEvidence(records, recordsBySequence, targetResult.sequence, targetCall.payload.name, replacement.callId);
|
|
805
806
|
if (!targetEvidence || targetEvidence.call.sequence !== targetCall.sequence)
|
|
806
|
-
return
|
|
807
|
+
return undefined;
|
|
808
|
+
const targetOutput = normalizeContextGcExecResult(targetResult.payload.content, targetEvidence.completed.payload);
|
|
807
809
|
if (targetEvidence.callId === evidence.callId)
|
|
808
|
-
return targetEvidence.call.sequence === evidence.call.sequence;
|
|
810
|
+
return targetEvidence.call.sequence === evidence.call.sequence ? targetOutput : undefined;
|
|
809
811
|
const evidenceInput = evidence.call.payload.arguments;
|
|
810
812
|
const targetInput = targetCall.payload.arguments;
|
|
811
813
|
if (!isRecord(evidenceInput) || !isRecord(targetInput))
|
|
812
|
-
return
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
814
|
+
return undefined;
|
|
815
|
+
const targetProcessId = typeof targetInput.processId === 'string' ? targetInput.processId : targetOutput?.processId;
|
|
816
|
+
return typeof targetProcessId === 'string' &&
|
|
817
|
+
targetProcessId === evidenceInput.processId &&
|
|
818
|
+
targetResult.sequence <= evidence.result.sequence
|
|
819
|
+
? targetOutput
|
|
816
820
|
: undefined;
|
|
817
|
-
const targetProcessId = typeof targetInput.processId === 'string'
|
|
818
|
-
? targetInput.processId
|
|
819
|
-
: typeof targetOutput?.processId === 'string'
|
|
820
|
-
? targetOutput.processId
|
|
821
|
-
: undefined;
|
|
822
|
-
return (typeof evidenceProcessId === 'string' &&
|
|
823
|
-
targetProcessId === evidenceProcessId &&
|
|
824
|
-
targetResult.sequence <= evidence.result.sequence);
|
|
825
821
|
}
|
|
826
822
|
function triggerMatchesRecords(records, recordsBySequence, payload) {
|
|
827
823
|
if (payload.trigger.usageSequence !== null &&
|
|
@@ -959,7 +955,8 @@ function isContextGcReplacement(value) {
|
|
|
959
955
|
'target',
|
|
960
956
|
'replacementArguments',
|
|
961
957
|
'providerAliasTargets',
|
|
962
|
-
'evidenceSequence'
|
|
958
|
+
'evidenceSequence',
|
|
959
|
+
'terminalCallId'
|
|
963
960
|
]) &&
|
|
964
961
|
value.target.role === 'tool_call' &&
|
|
965
962
|
(value.toolName === 'apply_patch' ||
|
|
@@ -968,6 +965,9 @@ function isContextGcReplacement(value) {
|
|
|
968
965
|
value.toolName === 'code_exec' ||
|
|
969
966
|
value.toolName === 'todo_write' ||
|
|
970
967
|
value.toolName === 'todo') &&
|
|
968
|
+
(value.terminalCallId === undefined ||
|
|
969
|
+
((value.toolName === 'exec' || value.toolName === 'exec_wait') &&
|
|
970
|
+
isNonemptyString(value.terminalCallId))) &&
|
|
971
971
|
value.target.toolName === value.toolName &&
|
|
972
972
|
Array.isArray(value.providerAliasTargets) &&
|
|
973
973
|
value.providerAliasTargets.every((target) => isContextGcTarget(target) &&
|
|
@@ -56,6 +56,7 @@ export type ContextGcReplacement = {
|
|
|
56
56
|
readonly replacementArguments: unknown;
|
|
57
57
|
readonly providerAliasTargets: readonly ContextGcTarget[];
|
|
58
58
|
readonly evidenceSequence: number;
|
|
59
|
+
readonly terminalCallId?: string;
|
|
59
60
|
} | {
|
|
60
61
|
readonly kind: 'EXEC_OUTPUT';
|
|
61
62
|
readonly terminalCallId?: string;
|