@rowan-agent/agent 0.14.2 → 0.14.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 +7 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6624,7 +6624,7 @@ var AgentRuntime = class _AgentRuntime {
6624
6624
  const isToolCallInteraction = result.interactions?.some((i) => i.toolCallId !== void 0);
6625
6625
  const output = isToolCallInteraction ? void 0 : latestAssistant(
6626
6626
  run,
6627
- result.messages.slice(modelMessages.length),
6627
+ result.messages,
6628
6628
  modelMessages.length
6629
6629
  );
6630
6630
  const prompt = isToolCallInteraction ? void 0 : output ?? (result.interactions[0]?.prompt ? promptMessage(run, result.interactions[0].prompt, result.messages.length) : void 0);
@@ -6643,7 +6643,7 @@ var AgentRuntime = class _AgentRuntime {
6643
6643
  return;
6644
6644
  }
6645
6645
  if (result.type === "completed") {
6646
- const output = latestAssistant(run, result.messages.slice(modelMessages.length), modelMessages.length);
6646
+ const output = latestAssistant(run, result.messages, modelMessages.length);
6647
6647
  if (controlKind === "compact" || isCompactionOutcome(result.outcome.payload)) {
6648
6648
  const summary = compactSummary(result.outcome.payload);
6649
6649
  const instructions = compactInstructions2(run) ?? compactOutputInstructions(result.outcome.payload);
@@ -7344,10 +7344,10 @@ var DurableRun = class {
7344
7344
  function promptMessage(run, prompt, sequence) {
7345
7345
  return { id: createId("msg"), agentId: run.agentId, runId: run.id, role: "assistant", content: prompt, sequenceWithinRun: sequence, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
7346
7346
  }
7347
- function latestAssistant(run, messages, sequence, interrupted = false) {
7348
- const message = [...messages].reverse().find((candidate) => candidate.role === "assistant");
7347
+ function latestAssistant(run, messages, historyLength, interrupted = false) {
7348
+ const message = [...messages.slice(historyLength)].reverse().find((candidate) => candidate.role === "assistant");
7349
7349
  if (!message) return void 0;
7350
- return projectAssistantMessage(message, run.agentId, run.id, sequence, { interrupted });
7350
+ return projectAssistantMessage(message, run.agentId, run.id, historyLength, { interrupted });
7351
7351
  }
7352
7352
  function hasVisibleAssistantText(message) {
7353
7353
  return typeof message.content === "string" ? message.content.length > 0 : message.content.some((part) => part.type === "text" && part.text.length > 0);
@@ -8360,6 +8360,8 @@ var InMemoryStore = class _InMemoryStore {
8360
8360
  const run = this.requireRun(input.runId);
8361
8361
  if (input.expectedRevision !== void 0) this.assertRevision(run, input.expectedRevision);
8362
8362
  if (input.output !== void 0) {
8363
+ const existing = this.messages.get(input.output.id);
8364
+ if (existing && existing.runId !== run.id) throw new TypeError("cancelled output message id belongs to another Run");
8363
8365
  if (!isAssistantMessage(input.output) || input.output.agentId !== run.agentId || input.output.runId !== run.id || input.output.interrupted !== true) {
8364
8366
  throw new TypeError("cancelled output must be an interrupted AssistantMessage from this Run");
8365
8367
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowan-agent/agent",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",