@rowan-agent/agent 0.15.0 → 0.15.1
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.js +32 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3280,8 +3280,15 @@ async function executeParallelPhase(config, state, registry, phase, payload, ins
|
|
|
3280
3280
|
const toolExecutionManager = createToolExecutionManager();
|
|
3281
3281
|
const execution = createPhaseExecution(config, state, phase, messageManager, toolExecutionManager, registry);
|
|
3282
3282
|
const runtime = { phase, config, state, execution, messageManager, registry, context: phaseContext };
|
|
3283
|
-
|
|
3283
|
+
let output = await executePhase(runtime);
|
|
3284
3284
|
if (phaseMsgId) removePhaseMessage(messages, phaseMsgId);
|
|
3285
|
+
if (config.afterPhase) {
|
|
3286
|
+
const extAfter = await config.afterPhase(phase.name, output);
|
|
3287
|
+
if (extAfter?.output) output = extAfter.output;
|
|
3288
|
+
}
|
|
3289
|
+
if (output.status) {
|
|
3290
|
+
await execution.reportStatus(output.status);
|
|
3291
|
+
}
|
|
3285
3292
|
const decision = output.toolCalls ? extractRouteCall(output.toolCalls) : void 0;
|
|
3286
3293
|
const resultPayload = decision?.decision[0]?.payload !== void 0 ? normalizePayload(decision.decision[0].payload) : output.payload;
|
|
3287
3294
|
return { instanceId, phaseId: phase.name, payload: resultPayload, content: output.message ?? `${phase.name} completed.` };
|
|
@@ -6532,7 +6539,30 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6532
6539
|
interactionAnswers: claim.run.interactionAnswers,
|
|
6533
6540
|
signal: controller.signal,
|
|
6534
6541
|
beforePhase: assembly.beforePhase,
|
|
6535
|
-
afterPhase:
|
|
6542
|
+
afterPhase: async (phaseId, output) => {
|
|
6543
|
+
const extAfter = assembly.afterPhase ? await assembly.afterPhase(phaseId, output) : {};
|
|
6544
|
+
const effectiveOutput = extAfter.output ?? output;
|
|
6545
|
+
if (!extAfter.abort && (phaseId === COMPACT_PHASE_ID || isCompactionOutcome(effectiveOutput.payload))) {
|
|
6546
|
+
const active = this.executions.get(run.id);
|
|
6547
|
+
if (active?.executionId === claim.execution.executionId && !this.cancellationRequested.has(run.id) && !controller.signal.aborted) {
|
|
6548
|
+
const summary = compactSummary(effectiveOutput.payload);
|
|
6549
|
+
const instructions = compactInstructions2(run) ?? compactOutputInstructions(effectiveOutput.payload);
|
|
6550
|
+
if (summary) {
|
|
6551
|
+
const covered = claim.history.at(-1);
|
|
6552
|
+
const record = {
|
|
6553
|
+
id: createId("compact"),
|
|
6554
|
+
agentId: run.agentId,
|
|
6555
|
+
summary,
|
|
6556
|
+
...covered ? { coveredThrough: { messageId: covered.id, sequence: covered.sequenceWithinRun } } : {},
|
|
6557
|
+
...instructions ? { instructions } : {},
|
|
6558
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6559
|
+
};
|
|
6560
|
+
await this.owned.commitContextCompaction(record);
|
|
6561
|
+
}
|
|
6562
|
+
}
|
|
6563
|
+
}
|
|
6564
|
+
return extAfter;
|
|
6565
|
+
},
|
|
6536
6566
|
beforePrompt: assembly.beforePrompt,
|
|
6537
6567
|
onPhaseEntered: async (phaseId) => {
|
|
6538
6568
|
const active = this.executions.get(run.id);
|
|
@@ -6639,14 +6669,6 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6639
6669
|
const compactResult = await executeModel(compactContext);
|
|
6640
6670
|
const summary = compactResult.type === "completed" ? compactSummary(compactResult.outcome.payload) : void 0;
|
|
6641
6671
|
if (summary) {
|
|
6642
|
-
const covered = claim.history.at(-1);
|
|
6643
|
-
await this.owned.commitContextCompaction({
|
|
6644
|
-
id: createId("compact"),
|
|
6645
|
-
agentId: run.agentId,
|
|
6646
|
-
summary,
|
|
6647
|
-
...covered ? { coveredThrough: { messageId: covered.id, sequence: covered.sequenceWithinRun } } : {},
|
|
6648
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6649
|
-
});
|
|
6650
6672
|
modelMessages = await this.owned.contextMessages(run.agentId);
|
|
6651
6673
|
executionContext = buildExecutionContext(modelMessages);
|
|
6652
6674
|
result = await executeModel(executionContext);
|
|
@@ -6695,22 +6717,6 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6695
6717
|
}
|
|
6696
6718
|
if (result.type === "completed") {
|
|
6697
6719
|
const output = latestAssistant(run, result.messages, modelMessages.length);
|
|
6698
|
-
if (controlKind === "compact" || isCompactionOutcome(result.outcome.payload)) {
|
|
6699
|
-
const summary = compactSummary(result.outcome.payload);
|
|
6700
|
-
const instructions = compactInstructions2(run) ?? compactOutputInstructions(result.outcome.payload);
|
|
6701
|
-
if (summary) {
|
|
6702
|
-
const covered = claim.history.at(-1);
|
|
6703
|
-
const record = {
|
|
6704
|
-
id: createId("compact"),
|
|
6705
|
-
agentId: run.agentId,
|
|
6706
|
-
summary,
|
|
6707
|
-
...covered ? { coveredThrough: { messageId: covered.id, sequence: covered.sequenceWithinRun } } : {},
|
|
6708
|
-
...instructions ? { instructions } : {},
|
|
6709
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6710
|
-
};
|
|
6711
|
-
await this.owned.commitContextCompaction(record);
|
|
6712
|
-
}
|
|
6713
|
-
}
|
|
6714
6720
|
await this.owned.commitOutcome({ runId: run.id, execution: claim.execution, expectedRevision: executionRevision, outcome: durableOutcome(result.outcome), ...output ? { output } : {} });
|
|
6715
6721
|
this.transientEvents.clear(run.id, claim.execution.executionId, true);
|
|
6716
6722
|
return;
|