@openape/ape-agent 2.9.1 → 2.9.2

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/bridge.mjs +24 -0
  2. package/package.json +4 -4
package/dist/bridge.mjs CHANGED
@@ -4711,6 +4711,8 @@ function createThrottle(fn, intervalMs) {
4711
4711
 
4712
4712
  // src/thread-session.ts
4713
4713
  var PATCH_INTERVAL_MS = 300;
4714
+ var NO_ACTIVITY_TIMEOUT_MS = 6e4;
4715
+ var NO_RESPONSE_MESSAGE = "(no response from the model backend \u2014 it may be unavailable or its API auth expired; nothing was changed, please retry)";
4714
4716
  var ThreadSession = class {
4715
4717
  constructor(deps) {
4716
4718
  this.deps = deps;
@@ -4772,6 +4774,18 @@ var ThreadSession = class {
4772
4774
  };
4773
4775
  const { systemPrompt, tools } = this.deps.resolveConfig();
4774
4776
  await this.backfillHistoryOnce(replyToMessageId, body);
4777
+ let sawActivity = false;
4778
+ let turnSettled = false;
4779
+ const settleOnce = () => {
4780
+ if (turnSettled) return true;
4781
+ turnSettled = true;
4782
+ return false;
4783
+ };
4784
+ const watchdog = setTimeout(() => {
4785
+ if (sawActivity || this.active !== turn || settleOnce()) return;
4786
+ this.deps.log(`turn watchdog: no model activity in ${NO_ACTIVITY_TIMEOUT_MS}ms \u2014 failing turn (room=${this.deps.roomId} thread=${this.deps.threadId})`);
4787
+ void this.failTurn(NO_RESPONSE_MESSAGE);
4788
+ }, NO_ACTIVITY_TIMEOUT_MS);
4775
4789
  try {
4776
4790
  const result = await runLoop({
4777
4791
  config: this.deps.runtimeConfig,
@@ -4782,11 +4796,13 @@ var ThreadSession = class {
4782
4796
  history: this.history,
4783
4797
  handlers: {
4784
4798
  onTextDelta: (delta) => {
4799
+ sawActivity = true;
4785
4800
  if (!this.active) return;
4786
4801
  this.active.accumulated += delta;
4787
4802
  this.active.throttle.schedule();
4788
4803
  },
4789
4804
  onToolCall: ({ name }) => {
4805
+ sawActivity = true;
4790
4806
  this.deps.log(`[${this.deps.roomId}/${this.deps.threadId.slice(0, 8)}] tool_call: ${name}`);
4791
4807
  void setStatus(`\u{1F527} ${name}`);
4792
4808
  },
@@ -4800,15 +4816,23 @@ var ThreadSession = class {
4800
4816
  }
4801
4817
  }
4802
4818
  });
4819
+ clearTimeout(watchdog);
4820
+ if (settleOnce()) return;
4803
4821
  this.history.push({ role: "user", content: body });
4804
4822
  if (result.finalMessage) {
4805
4823
  this.history.push({ role: "assistant", content: result.finalMessage });
4806
4824
  }
4807
4825
  if (result.status === "error") {
4808
4826
  this.deps.log(`runtime done with status=error (room=${this.deps.roomId} thread=${this.deps.threadId})`);
4827
+ if (!turn.accumulated) {
4828
+ await this.failTurn("(the model run ended with an error and produced no output \u2014 please retry)");
4829
+ return;
4830
+ }
4809
4831
  }
4810
4832
  await this.endTurn();
4811
4833
  } catch (err) {
4834
+ clearTimeout(watchdog);
4835
+ if (settleOnce()) return;
4812
4836
  const message = err instanceof Error ? err.message : String(err);
4813
4837
  this.deps.log(`runtime error (room=${this.deps.roomId} thread=${this.deps.threadId}): ${message}`);
4814
4838
  await this.failTurn(`(runtime error: ${message})`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openape/ape-agent",
3
- "version": "2.9.1",
3
+ "version": "2.9.2",
4
4
  "description": "OpenApe agent runtime: per-agent process that connects to chat.openape.ai, runs the LLM loop with tools + cron tasks, and streams replies back to owners.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,9 +23,9 @@
23
23
  "ofetch": "^1.4.1",
24
24
  "ws": "^8.18.0",
25
25
  "yaml": "^2.8.0",
26
- "@openape/apes": "1.29.1",
27
- "@openape/cli-auth": "0.5.0",
28
- "@openape/prompt-injection-detector": "0.1.0"
26
+ "@openape/apes": "1.30.0",
27
+ "@openape/prompt-injection-detector": "0.1.0",
28
+ "@openape/cli-auth": "0.5.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@antfu/eslint-config": "^7.6.1",