@demicodes/agent 0.3.3 → 0.3.5

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.mjs +12 -4
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -925,6 +925,7 @@ var ProviderTurnLoop = class {
925
925
  let autoCompactions = 0;
926
926
  while (true) {
927
927
  throwIfAborted(this.host.currentSignal());
928
+ await this.host.materializePendingSteers();
928
929
  const steerContinuationBeforeStream = this.host.steerContinuationCount;
929
930
  const shouldAutoRecover = await this.streamProviderOnce();
930
931
  throwIfAborted(this.host.currentSignal());
@@ -1181,7 +1182,7 @@ var AgentSession = class AgentSession {
1181
1182
  static fromCheckpoint(params, options = {}) {
1182
1183
  if (params.checkpoint.harnessName !== params.runtime.harnessName) throw new Error(`AgentSession: checkpoint harness "${params.checkpoint.harnessName}" does not match "${params.runtime.harnessName}"`);
1183
1184
  const checkpoint = params.checkpoint;
1184
- return new AgentSession({
1185
+ const session = new AgentSession({
1185
1186
  provider: params.provider,
1186
1187
  model: checkpoint.model,
1187
1188
  cwd: checkpoint.cwd,
@@ -1189,6 +1190,11 @@ var AgentSession = class AgentSession {
1189
1190
  transcript: checkpoint.transcript,
1190
1191
  state: checkpoint.state
1191
1192
  }, options);
1193
+ for (const toolCall of session.transcriptLog.pendingToolCalls()) session.transcriptLog.completeToolCall(toolCall.toolUseId, [{
1194
+ type: "text",
1195
+ text: `Tool call interrupted: ${toolCall.toolName} (the process died before a result was recorded)`
1196
+ }], true);
1197
+ return session;
1192
1198
  }
1193
1199
  constructor(params, options = {}) {
1194
1200
  this.provider = params.provider;
@@ -1294,7 +1300,8 @@ var AgentSession = class AgentSession {
1294
1300
  runWithCompactingPhase: (fn) => self.runWithCompactingPhase(fn),
1295
1301
  commitTranscript: () => self.commitTranscript(),
1296
1302
  emit: (event) => self.emit(event),
1297
- materializeSteersArrivedSince: (count) => self.materializePendingSteersArrivedSince(count)
1303
+ materializeSteersArrivedSince: (count) => self.materializePendingSteersArrivedSince(count),
1304
+ materializePendingSteers: () => self.materializePendingSteersForCurrentTurn()
1298
1305
  };
1299
1306
  this.turnLoop = new ProviderTurnLoop(turnLoopHost);
1300
1307
  }
@@ -1647,13 +1654,13 @@ var AgentSession = class AgentSession {
1647
1654
  steerDelivery() {
1648
1655
  if (!this.activeTurnId || !this.currentAbortController || !this.activeTurnPhase) throw new Error("AgentSession: no active turn to steer");
1649
1656
  if (this.currentAbortController.signal.aborted) throw new Error("AgentSession: active turn is aborted");
1650
- if (this.activeTurnPhase === "compacting" || this.activeTurnPhase === "finalizing") throw new Error(`AgentSession: active turn cannot accept steering while ${this.activeTurnPhase}`);
1657
+ if (this.activeTurnPhase === "finalizing") throw new Error("AgentSession: active turn cannot accept steering while finalizing");
1651
1658
  const run = this.activeProviderRun;
1652
1659
  if (run?.steer) return {
1653
1660
  type: "provider",
1654
1661
  run
1655
1662
  };
1656
- if (this.activeTurnPhase === "tool_executing" || this.activeTurnPhase === "provider_streaming") return { type: "next_provider_continuation" };
1663
+ if (this.activeTurnPhase === "tool_executing" || this.activeTurnPhase === "provider_streaming" || this.activeTurnPhase === "compacting") return { type: "next_provider_continuation" };
1657
1664
  throw new Error("AgentSession: active turn cannot accept steering now");
1658
1665
  }
1659
1666
  enqueue(action) {
@@ -1760,6 +1767,7 @@ var AgentSession = class AgentSession {
1760
1767
  this.setPhase("compacting");
1761
1768
  this.activeTurnPhase = "compacting";
1762
1769
  await this.compaction.run();
1770
+ await this.materializePendingSteersForCurrentTurn();
1763
1771
  return;
1764
1772
  }
1765
1773
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/agent",
3
3
  "description": "Session runtime and transport-neutral client and server protocol for Demi.",
4
- "version": "0.3.3",
4
+ "version": "0.3.5",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@demicodes/core": "^0.3.2",
23
- "@demicodes/provider": "^0.4.0",
23
+ "@demicodes/provider": "^0.4.2",
24
24
  "@demicodes/shell": "^0.3.2",
25
25
  "@demicodes/utils": "^0.3.2"
26
26
  },