@strayl/agent 0.1.9 → 0.1.10

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/agent.js CHANGED
@@ -7431,7 +7431,11 @@ var ContextManager = class {
7431
7431
  }
7432
7432
  maybeTriggerPreSummarization(client, emitter) {
7433
7433
  if (!this.shouldPreSummarize() || this.pendingSummary) return;
7434
- this.pendingSummary = this.createSummary(client).catch(() => "");
7434
+ this.pendingSummary = this.createSummary(client).catch((err) => {
7435
+ const msg = err instanceof Error ? err.message : String(err);
7436
+ emitter.emit({ type: "error", message: `Pre-summarization failed: ${msg}`, recoverable: true });
7437
+ return "";
7438
+ });
7435
7439
  }
7436
7440
  async applyPendingSummary(emitter) {
7437
7441
  if (!this.pendingSummary) return false;
@@ -7454,7 +7458,10 @@ var ContextManager = class {
7454
7458
  if (summary) {
7455
7459
  this.replaceSummarizedMessages(summary, emitter);
7456
7460
  }
7457
- } catch {
7461
+ } catch (err) {
7462
+ const msg = err instanceof Error ? err.message : String(err);
7463
+ emitter.emit({ type: "error", message: `Summarization failed, falling back to trim: ${msg}`, recoverable: true });
7464
+ this.applyTrim();
7458
7465
  }
7459
7466
  }
7460
7467
  async createSummary(client) {
@@ -12998,9 +13005,9 @@ var requestEnvVarTool = {
12998
13005
  // src/tools/external/database.ts
12999
13006
  async function dbFetch(path16, init, ctx) {
13000
13007
  const env = ctx.env;
13001
- if (env.STRAYL_LLM_DIRECT === "1") {
13008
+ if (env.STRAYL_LLM_DIRECT === "1" && env.STRAYL_AUTH_TOKEN) {
13002
13009
  const dbApiUrl = env.DB_API_URL ?? "https://db.strayl.dev";
13003
- const authToken = env.STRAYL_AUTH_TOKEN ?? "";
13010
+ const authToken = env.STRAYL_AUTH_TOKEN;
13004
13011
  const username2 = env.STRAYL_USERNAME ?? "";
13005
13012
  const projectSlug2 = env.STRAYL_PROJECT_SLUG ?? "";
13006
13013
  const url2 = `${dbApiUrl}/databases/${username2}/${projectSlug2}${path16}`;
@@ -13536,6 +13543,8 @@ async function runAgent(config) {
13536
13543
  });
13537
13544
  let iteration = 0;
13538
13545
  const maxIterations = config.maxIterations ?? 200;
13546
+ let consecutiveLLMErrors = 0;
13547
+ const MAX_CONSECUTIVE_LLM_ERRORS = 5;
13539
13548
  if (config.restoreCheckpoint) {
13540
13549
  const cp = config.restoreCheckpoint;
13541
13550
  context.restoreMessages(cp.messages);
@@ -13675,7 +13684,12 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
13675
13684
  }
13676
13685
  } catch (e) {
13677
13686
  const msg = e instanceof Error ? e.message : String(e);
13678
- emitter.emit({ type: "error", message: `LLM error: ${msg}`, recoverable: true });
13687
+ consecutiveLLMErrors++;
13688
+ if (consecutiveLLMErrors >= MAX_CONSECUTIVE_LLM_ERRORS) {
13689
+ emitter.emit({ type: "error", message: `LLM failed ${consecutiveLLMErrors} times in a row: ${msg}`, recoverable: false });
13690
+ break;
13691
+ }
13692
+ emitter.emit({ type: "error", message: `LLM error (${consecutiveLLMErrors}/${MAX_CONSECUTIVE_LLM_ERRORS}): ${msg}`, recoverable: true });
13679
13693
  context.addAssistant(`[Error communicating with model: ${msg}]`);
13680
13694
  continue;
13681
13695
  }
@@ -13687,6 +13701,7 @@ ${IMPLEMENTATION_MODE_PROMPT2}`);
13687
13701
  emitter.emit({ type: "session-end", usage: context.totalUsage(), exit_reason: "cancelled" });
13688
13702
  return;
13689
13703
  }
13704
+ consecutiveLLMErrors = 0;
13690
13705
  context.addAssistant(assistantText, completedToolCalls.length > 0 ? completedToolCalls : void 0);
13691
13706
  {
13692
13707
  const used = context.estimateTokens();
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "@strayl/agent",
3
- "version": "0.1.9",
4
- "type": "module",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "main": "dist/index.js",
9
- "files": [
10
- "dist",
11
- "skills"
12
- ],
13
- "scripts": {
14
- "build": "esbuild src/index.ts --bundle --platform=node --target=node20 --format=esm --outfile=dist/agent.js --external:fsevents",
15
- "dev": "tsx watch src/index.ts"
16
- },
17
- "dependencies": {
18
- "openai": "^5.8.0",
19
- "zod": "^3.25.67"
20
- },
21
- "devDependencies": {
22
- "esbuild": "^0.25.5",
23
- "tsx": "^4.19.4",
24
- "typescript": "^5.8.3",
25
- "@types/node": "^22.15.31"
26
- }
27
- }
1
+ {
2
+ "name": "@strayl/agent",
3
+ "version": "0.1.10",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "dist/index.js",
9
+ "files": [
10
+ "dist",
11
+ "skills"
12
+ ],
13
+ "scripts": {
14
+ "build": "esbuild src/index.ts --bundle --platform=node --target=node20 --format=esm --outfile=dist/agent.js --external:fsevents",
15
+ "dev": "tsx watch src/index.ts"
16
+ },
17
+ "dependencies": {
18
+ "openai": "^5.8.0",
19
+ "zod": "^3.25.67"
20
+ },
21
+ "devDependencies": {
22
+ "esbuild": "^0.25.5",
23
+ "tsx": "^4.19.4",
24
+ "typescript": "^5.8.3",
25
+ "@types/node": "^22.15.31"
26
+ }
27
+ }