@rowan-agent/agent 0.15.1 → 0.15.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.
Files changed (2) hide show
  1. package/dist/index.js +30 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2512,12 +2512,22 @@ function createToolResultContent(result) {
2512
2512
  }
2513
2513
  ];
2514
2514
  }
2515
- function createRouteToolResultContent(toolCall, error) {
2515
+ function createRouteToolResultContent(toolCall, error, executionContext) {
2516
+ const result = error ? { ok: false, error } : { ok: true };
2517
+ if (!error && executionContext) {
2518
+ const { completedPhases, phaseTransitions } = executionContext;
2519
+ if (completedPhases && completedPhases.length > 0) {
2520
+ result.completed_phases = completedPhases;
2521
+ }
2522
+ if (phaseTransitions && phaseTransitions.length > 0) {
2523
+ result.route_history = phaseTransitions.map(({ from, to }) => `${from} \u2192 ${to}`);
2524
+ }
2525
+ }
2516
2526
  return [
2517
2527
  {
2518
2528
  type: "tool_result",
2519
2529
  toolUseId: toolCall.id,
2520
- content: error ? JSON.stringify({ ok: false, error }) : '{"ok": true}',
2530
+ content: JSON.stringify(result),
2521
2531
  ...error ? { isError: true } : {}
2522
2532
  }
2523
2533
  ];
@@ -2561,11 +2571,13 @@ async function executePhaseWithModel(ctx) {
2561
2571
  };
2562
2572
  for (const toolCall of collected.toolCalls) {
2563
2573
  if (toolCall.name !== PhaseRouteTool) continue;
2574
+ const hasOrdinaryTools = collected.toolCalls.some((candidate) => candidate.name !== PhaseRouteTool);
2564
2575
  const messageId = ctx.messageManager.start(
2565
2576
  "tool",
2566
2577
  createRouteToolResultContent(
2567
2578
  toolCall,
2568
- collected.toolCalls.some((candidate) => candidate.name !== PhaseRouteTool) ? "Route must be called separately after ordinary tools finish; this route decision was ignored." : void 0
2579
+ hasOrdinaryTools ? "Route must be called separately after ordinary tools finish; this route decision was ignored." : void 0,
2580
+ !hasOrdinaryTools ? { completedPhases: ctx.completedPhases, phaseTransitions: ctx.state.metrics.phaseTransitions } : void 0
2569
2581
  ),
2570
2582
  {
2571
2583
  phase: ctx.phase.name
@@ -2617,6 +2629,7 @@ async function runPhaseLoop(config, state, registry) {
2617
2629
  let previousPhaseInputMsgId;
2618
2630
  let previousResults = resumingSuspendedRun ? state.continuation?.previousResults?.map((result) => ({ ...result })) ?? [] : [];
2619
2631
  let pendingInstruction = resumingSuspendedRun ? state.continuation?.pendingInstruction : void 0;
2632
+ const completedPhases = [];
2620
2633
  const availablePhases = [];
2621
2634
  for (const [, phase] of registry.phases) {
2622
2635
  availablePhases.push({
@@ -2657,7 +2670,16 @@ async function runPhaseLoop(config, state, registry) {
2657
2670
  parallelTasks.set(instanceId, { promise, phaseId: target.phase });
2658
2671
  }
2659
2672
  const successfulResults = await waitForBackgroundTasks(parallelTasks);
2660
- previousResults = successfulResults.map((r) => ({ name: r.instanceId, output: r.payload }));
2673
+ previousResults = successfulResults.map((r) => ({
2674
+ name: r.instanceId,
2675
+ output: {
2676
+ message: r.content,
2677
+ ...r.payload !== void 0 ? { payload: r.payload } : {}
2678
+ }
2679
+ }));
2680
+ for (const r of successfulResults) {
2681
+ completedPhases.push(r.phaseId);
2682
+ }
2661
2683
  pendingInstruction = void 0;
2662
2684
  };
2663
2685
  if (!resumingSuspendedRun && state.entryPhases && state.entryPhases.length > 0) {
@@ -2842,7 +2864,7 @@ async function runPhaseLoop(config, state, registry) {
2842
2864
  previousResults = [];
2843
2865
  pendingInstruction = void 0;
2844
2866
  }
2845
- const runtime = { phase, config, state, execution, messageManager, registry, context: phaseContext };
2867
+ const runtime = { phase, config, state, execution, messageManager, registry, context: phaseContext, completedPhases };
2846
2868
  let output = await executePhase(runtime);
2847
2869
  delete state.initialPhasePayload;
2848
2870
  delete state.entryPhases;
@@ -2882,6 +2904,9 @@ async function runPhaseLoop(config, state, registry) {
2882
2904
  if (output.status) {
2883
2905
  await execution.reportStatus(output.status);
2884
2906
  }
2907
+ if (output.route !== "continue") {
2908
+ completedPhases.push(currentPhaseId);
2909
+ }
2885
2910
  if (phase.name === STOP_PHASE_ID) {
2886
2911
  removePhaseMessage(config.context.messages, previousPhaseMsgId);
2887
2912
  removePhaseMessage(config.context.messages, previousPhaseInputMsgId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowan-agent/agent",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",