@senpi/runtime 1.1.0-dev.runtime-phase-2.20260511162328 → 1.1.0-dev.runtime-phase-2.20260511191318
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/runtime/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAKpE,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/runtime/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAKpE,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAmBD,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAiD1E;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,mBAAmB,CAyEnG"}
|
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger.js";
|
|
2
2
|
const logger = createLogger("[senpi-core][notifications]");
|
|
3
|
+
// Decision-error → user-facing chat message.
|
|
4
|
+
//
|
|
5
|
+
// The runtime catches errors from the LLM-decision call (openclaw-llm-decision.ts:
|
|
6
|
+
// throws on token-missing, on non-2xx HTTP, and on body.ok=false) and passes
|
|
7
|
+
// err.message here. Network-level failures (fetch() rejecting) also reach this
|
|
8
|
+
// with the underlying error string.
|
|
9
|
+
//
|
|
10
|
+
// Discriminators: HTTP status prefix + presence of a structured tool_error body
|
|
11
|
+
// + node fetch error markers. The mapping below is intentionally specific per
|
|
12
|
+
// failure mode so the chat reader can tell apart:
|
|
13
|
+
// - infrastructure unreachable vs misconfigured,
|
|
14
|
+
// - signal dropped because the AI model timed out vs the AI model errored vs
|
|
15
|
+
// OpenClaw itself returned an unexpected error.
|
|
16
|
+
// Auth (401/403) is intentionally NOT handled separately — the runtime plugin
|
|
17
|
+
// and the gateway it calls share the same process env and the same token, so
|
|
18
|
+
// 401/403 is unreachable in practice; if it ever fires, the generic fallback
|
|
19
|
+
// at the bottom surfaces the raw message.
|
|
3
20
|
export function formatDecisionErrorNotification(rawMessage) {
|
|
4
21
|
const s = rawMessage;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (/OpenClaw gateway error \(401\)|OpenClaw gateway error \(403\)/.test(s))
|
|
8
|
-
return "Senpi: OpenClaw gateway rejected (auth). Check OPENCLAW_GATEWAY_TOKEN.";
|
|
9
|
-
if (/OpenClaw gateway error \(5\d\d\)/.test(s))
|
|
10
|
-
return "Senpi: OpenClaw gateway error (5xx). Try again later.";
|
|
11
|
-
if (/gateway token not configured|OPENCLAW_GATEWAY_TOKEN/.test(s))
|
|
22
|
+
// Token missing at config-time — fires before any HTTP call, so check first.
|
|
23
|
+
if (/gateway token not configured|OPENCLAW_GATEWAY_TOKEN/.test(s)) {
|
|
12
24
|
return "Senpi: OpenClaw gateway token not configured. Set OPENCLAW_GATEWAY_TOKEN.";
|
|
25
|
+
}
|
|
26
|
+
// (1) OpenClaw Gateway not reachable — fetch() rejected before getting a
|
|
27
|
+
// response. Node's undici fetch surfaces these as "fetch failed" with the
|
|
28
|
+
// underlying SystemError code in .cause; the action runner stringifies it
|
|
29
|
+
// so the code marker usually lands in the message.
|
|
30
|
+
if (/^fetch failed$|fetch failed:|ECONNREFUSED|ECONNRESET|ETIMEDOUT|ENOTFOUND|EAI_AGAIN/.test(s)) {
|
|
31
|
+
return "Senpi: OpenClaw Gateway is unreachable.";
|
|
32
|
+
}
|
|
33
|
+
// (2) Endpoint missing — plugin not installed at this path, or version mismatch.
|
|
34
|
+
if (/OpenClaw gateway error \(404\)/.test(s)) {
|
|
35
|
+
return "Senpi: OpenClaw is missing the plugin endpoint. Please reinstall the plugin.";
|
|
36
|
+
}
|
|
37
|
+
// (3) AI model timed out — OpenClaw's llm-task tool returns 408 when it hits
|
|
38
|
+
// its own per-call cap; the gateway returns 504 when the upstream call exceeded
|
|
39
|
+
// the gateway's frame timeout. AbortError covers cancellation paths that may
|
|
40
|
+
// be added at the runtime side in the future.
|
|
41
|
+
if (/OpenClaw gateway error \(408\)|OpenClaw gateway error \(504\)|AbortError|operation was aborted/.test(s)) {
|
|
42
|
+
return "Senpi: Signal Dropped - AI model didn't respond in 90 seconds.";
|
|
43
|
+
}
|
|
44
|
+
// (4) AI model failed — HTTP 5xx whose body carries a structured tool_error
|
|
45
|
+
// (today's case: Gemini overload → llm-task wraps as `{"ok":false,
|
|
46
|
+
// "error":{"type":"tool_error","message":"tool execution failed"}}` →
|
|
47
|
+
// gateway returns HTTP 500), OR HTTP 200 with body.ok=false from the same
|
|
48
|
+
// tool layer ("OpenClaw gateway rejected request: ...").
|
|
49
|
+
if ((/OpenClaw gateway error \(5\d\d\)/.test(s) && /"type":\s*"tool_error"/.test(s)) ||
|
|
50
|
+
/OpenClaw gateway rejected request/.test(s)) {
|
|
51
|
+
return "Senpi: Signal Dropped - AI model failed to respond.";
|
|
52
|
+
}
|
|
53
|
+
// (5) Any other 5xx — gateway-frame error or unparseable body.
|
|
54
|
+
if (/OpenClaw gateway error \(5\d\d\)/.test(s)) {
|
|
55
|
+
return "Senpi: Signal Dropped - OpenClaw hit an unexpected error.";
|
|
56
|
+
}
|
|
57
|
+
// Last-resort generic prefix — surfaces the underlying message so operators
|
|
58
|
+
// can still diagnose unknown failure modes from the chat.
|
|
13
59
|
return `Senpi: Trading decision failed — ${s}`;
|
|
14
60
|
}
|
|
15
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/runtime/notifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG,YAAY,CAAC,6BAA6B,CAAC,CAAC;AAU3D,MAAM,UAAU,+BAA+B,CAAC,UAAkB;IAChE,MAAM,CAAC,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../src/runtime/notifications.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,MAAM,GAAG,YAAY,CAAC,6BAA6B,CAAC,CAAC;AAU3D,6CAA6C;AAC7C,EAAE;AACF,mFAAmF;AACnF,6EAA6E;AAC7E,+EAA+E;AAC/E,oCAAoC;AACpC,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,kDAAkD;AAClD,mDAAmD;AACnD,+EAA+E;AAC/E,oDAAoD;AACpD,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,0CAA0C;AAC1C,MAAM,UAAU,+BAA+B,CAAC,UAAkB;IAChE,MAAM,CAAC,GAAG,UAAU,CAAC;IAErB,6EAA6E;IAC7E,IAAI,qDAAqD,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,OAAO,2EAA2E,CAAC;IACrF,CAAC;IAED,yE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