@myagentroam/agent 0.15.7 → 0.15.9

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)
@@ -40,6 +40,7 @@ export class SessionExecution {
40
40
  }
41
41
  stopSteer() {
42
42
  delete this.#bindings.steer;
43
+ this.#steerReady.resolve();
43
44
  }
44
45
  retireCompactRequests(reason) {
45
46
  this.compactRequests.close(reason);
@@ -50,7 +51,6 @@ export class SessionExecution {
50
51
  this.retireCompactRequests(reason);
51
52
  delete this.#bindings.appendedMessages;
52
53
  this.stopSteer();
53
- this.#steerReady.resolve();
54
54
  }
55
55
  detachToolSources() {
56
56
  delete this.#bindings.toolSources;
@@ -225,6 +225,8 @@ export class SessionExecution {
225
225
  if (full.type === 'execution.completed') {
226
226
  this.controller.signal.throwIfAborted();
227
227
  this.completionAdmitted = true;
228
+ // Handled input never binds steer; keep existing receipts available until teardown.
229
+ this.#steerReady.resolve();
228
230
  }
229
231
  if (full.type === 'execution.completed' ||
230
232
  full.type === 'execution.failed' ||
@@ -388,10 +390,12 @@ export class SessionExecution {
388
390
  }
389
391
  catch (error) {
390
392
  failed = true;
393
+ // Cleanup can release steer callers that interrupt this execution on fallback.
394
+ const cancelled = this.controller.signal.aborted;
391
395
  await input.beforeFailure(error);
392
396
  input.endParent();
393
397
  const finalAnswer = this.kind === 'compact' ? '' : (this.finalAnswer ?? '');
394
- if (this.controller.signal.aborted) {
398
+ if (cancelled) {
395
399
  await input.emit({ type: 'execution.cancelled' }).catch(() => undefined);
396
400
  return { executionId: this.executionId, status: 'cancelled', finalAnswer };
397
401
  }
@@ -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
- if (!isSuccessfulExecLifecycleEvidence(replacement, source, records, recordsBySequence))
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
- const targetEvidence = successfulToolEvidence(records, recordsBySequence, source.sequence, 'exec', replacement.callId) ??
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 isSuccessfulExecLifecycleEvidence(replacement, source, records, recordsBySequence) {
781
- const expectedTerminal = replacement.kind === 'EXEC_OUTPUT' ? replacement.terminalCallId : undefined;
782
- const evidence = successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'exec', expectedTerminal) ??
783
- successfulToolEvidence(records, recordsBySequence, replacement.evidenceSequence, 'exec_wait', expectedTerminal);
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 false;
786
+ return undefined;
786
787
  const finalResult = normalizeContextGcExecResult(evidence.result.payload.content, evidence.completed.payload);
787
788
  if (!finalResult || finalResult.status === 'running')
788
- return false;
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 false;
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 false;
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 false;
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 false;
813
- const evidenceProcessId = evidenceInput.processId;
814
- const targetOutput = isRecord(targetResult.payload) && targetEvidence
815
- ? normalizeContextGcExecResult(targetResult.payload.content, targetEvidence.completed.payload)
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.15.7",
3
+ "version": "0.15.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/myagentroam/mar.git",