@senpi-ai/runtime 3.0.13 → 3.0.35
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/README.md +7 -4
- package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
- package/dist/actions/close-position/close-position.action.js +2 -7
- package/dist/actions/close-position/close-position.action.js.map +1 -1
- package/dist/actions/decision-error-notification.d.ts +35 -0
- package/dist/actions/decision-error-notification.d.ts.map +1 -0
- package/dist/actions/decision-error-notification.js +58 -0
- package/dist/actions/decision-error-notification.js.map +1 -0
- package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
- package/dist/actions/open-position/open-position.action.js +50 -7
- package/dist/actions/open-position/open-position.action.js.map +1 -1
- package/dist/actions/types.d.ts +2 -0
- package/dist/actions/types.d.ts.map +1 -1
- package/dist/approvals/approval-store.d.ts +35 -0
- package/dist/approvals/approval-store.d.ts.map +1 -0
- package/dist/approvals/approval-store.js +87 -0
- package/dist/approvals/approval-store.js.map +1 -0
- package/dist/approvals/manifest.d.ts +47 -0
- package/dist/approvals/manifest.d.ts.map +1 -0
- package/dist/approvals/manifest.js +90 -0
- package/dist/approvals/manifest.js.map +1 -0
- package/dist/approvals/telemetry.d.ts +41 -0
- package/dist/approvals/telemetry.d.ts.map +1 -0
- package/dist/approvals/telemetry.js +35 -0
- package/dist/approvals/telemetry.js.map +1 -0
- package/dist/approvals/tool-approval-gate.d.ts +96 -0
- package/dist/approvals/tool-approval-gate.d.ts.map +1 -0
- package/dist/approvals/tool-approval-gate.js +233 -0
- package/dist/approvals/tool-approval-gate.js.map +1 -0
- package/dist/approvals/tool-approvals-manifest.json +27 -0
- package/dist/cli/guide-commands.d.ts.map +1 -1
- package/dist/cli/guide-commands.js +6 -7
- package/dist/cli/guide-commands.js.map +1 -1
- package/dist/cli/senpi-cli-config.d.ts +0 -17
- package/dist/cli/senpi-cli-config.d.ts.map +1 -1
- package/dist/cli/senpi-cli-config.js +0 -30
- package/dist/cli/senpi-cli-config.js.map +1 -1
- package/dist/cli/senpi-config-commands.d.ts +1 -1
- package/dist/cli/senpi-config-commands.d.ts.map +1 -1
- package/dist/cli/senpi-config-commands.js +1 -16
- package/dist/cli/senpi-config-commands.js.map +1 -1
- package/dist/constants/dsl/index.d.ts +1 -5
- package/dist/constants/dsl/index.d.ts.map +1 -1
- package/dist/constants/dsl/index.js +1 -5
- package/dist/constants/dsl/index.js.map +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts +1 -1
- package/dist/dsl/engine-client/event-mapping.d.ts.map +1 -1
- package/dist/dsl/engine-client/event-mapping.js +6 -0
- package/dist/dsl/engine-client/event-mapping.js.map +1 -1
- package/dist/dsl/events/build-closed-event.d.ts +1 -1
- package/dist/dsl/events/build-closed-event.js +1 -1
- package/dist/dsl/events/handlers.js +1 -1
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +5 -3
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/dsl/notifications/format-utils.d.ts +1 -11
- package/dist/dsl/notifications/format-utils.d.ts.map +1 -1
- package/dist/dsl/notifications/format-utils.js +1 -48
- package/dist/dsl/notifications/format-utils.js.map +1 -1
- package/dist/dsl/notifications/formatter.d.ts +17 -28
- package/dist/dsl/notifications/formatter.d.ts.map +1 -1
- package/dist/dsl/notifications/formatter.js +46 -129
- package/dist/dsl/notifications/formatter.js.map +1 -1
- package/dist/dsl/notifications/index.d.ts +2 -10
- package/dist/dsl/notifications/index.d.ts.map +1 -1
- package/dist/dsl/notifications/index.js +127 -50
- package/dist/dsl/notifications/index.js.map +1 -1
- package/dist/dsl/notifications/raise-correlator.d.ts +87 -0
- package/dist/dsl/notifications/raise-correlator.d.ts.map +1 -0
- package/dist/dsl/notifications/raise-correlator.js +136 -0
- package/dist/dsl/notifications/raise-correlator.js.map +1 -0
- package/dist/dsl/notifications/stop-raise-ratchet.d.ts +76 -0
- package/dist/dsl/notifications/stop-raise-ratchet.d.ts.map +1 -0
- package/dist/dsl/notifications/stop-raise-ratchet.js +113 -0
- package/dist/dsl/notifications/stop-raise-ratchet.js.map +1 -0
- package/dist/dsl/plugin/index.d.ts.map +1 -1
- package/dist/dsl/plugin/index.js +0 -27
- package/dist/dsl/plugin/index.js.map +1 -1
- package/dist/dsl/plugin/options.d.ts +3 -7
- package/dist/dsl/plugin/options.d.ts.map +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -142
- package/dist/index.js.map +1 -1
- package/dist/prompt/session-context-seed-hook.d.ts +11 -0
- package/dist/prompt/session-context-seed-hook.d.ts.map +1 -0
- package/dist/prompt/session-context-seed-hook.js +99 -0
- package/dist/prompt/session-context-seed-hook.js.map +1 -0
- package/dist/runtime/auto-update/coordinator.d.ts +39 -15
- package/dist/runtime/auto-update/coordinator.d.ts.map +1 -1
- package/dist/runtime/auto-update/coordinator.js +152 -34
- package/dist/runtime/auto-update/coordinator.js.map +1 -1
- package/dist/runtime/auto-update/gateway-restart.d.ts +4 -4
- package/dist/runtime/auto-update/gateway-restart.js +4 -4
- package/dist/runtime/auto-update/types.d.ts +1 -0
- package/dist/runtime/auto-update/types.d.ts.map +1 -1
- package/dist/runtime/auto-update/types.js.map +1 -1
- package/dist/runtime/backend-pause-registry.d.ts +38 -0
- package/dist/runtime/backend-pause-registry.d.ts.map +1 -0
- package/dist/runtime/backend-pause-registry.js +51 -0
- package/dist/runtime/backend-pause-registry.js.map +1 -0
- package/dist/runtime/create-action-context.d.ts.map +1 -1
- package/dist/runtime/create-action-context.js +1 -0
- package/dist/runtime/create-action-context.js.map +1 -1
- package/dist/runtime/create-runtime-context.d.ts +1 -0
- package/dist/runtime/create-runtime-context.d.ts.map +1 -1
- package/dist/runtime/create-runtime-context.js +3 -0
- package/dist/runtime/create-runtime-context.js.map +1 -1
- package/dist/runtime/decision-errors.d.ts +46 -53
- package/dist/runtime/decision-errors.d.ts.map +1 -1
- package/dist/runtime/decision-errors.js +72 -111
- package/dist/runtime/decision-errors.js.map +1 -1
- package/dist/runtime/notifications.d.ts +37 -16
- package/dist/runtime/notifications.d.ts.map +1 -1
- package/dist/runtime/notifications.js +211 -67
- package/dist/runtime/notifications.js.map +1 -1
- package/dist/runtime/runtime.d.ts +16 -2
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +109 -31
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/strategy-lifecycle.d.ts +23 -9
- package/dist/runtime/strategy-lifecycle.d.ts.map +1 -1
- package/dist/runtime/strategy-lifecycle.js +90 -38
- package/dist/runtime/strategy-lifecycle.js.map +1 -1
- package/dist/runtime/supervisor/long-running-supervisor.js +3 -3
- package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
- package/dist/runtime-api/lifecycle.d.ts +1 -1
- package/dist/runtime-api/lifecycle.js +1 -1
- package/dist/scanners/providers/client.d.ts.map +1 -1
- package/dist/scanners/providers/client.js +4 -1
- package/dist/scanners/providers/client.js.map +1 -1
- package/dist/scanners/providers/factory.d.ts.map +1 -1
- package/dist/scanners/providers/factory.js +43 -2
- package/dist/scanners/providers/factory.js.map +1 -1
- package/dist/scanners/runtime-module.d.ts.map +1 -1
- package/dist/scanners/runtime-module.js +35 -0
- package/dist/scanners/runtime-module.js.map +1 -1
- package/dist/scripts/run-dsl-standalone-live.d.ts +8 -6
- package/dist/scripts/run-dsl-standalone-live.d.ts.map +1 -1
- package/dist/scripts/run-dsl-standalone-live.js +26 -25
- package/dist/scripts/run-dsl-standalone-live.js.map +1 -1
- package/dist/senpi/client.d.ts.map +1 -1
- package/dist/senpi/client.js +10 -3
- package/dist/senpi/client.js.map +1 -1
- package/dist/senpi/tool-errors.d.ts +30 -0
- package/dist/senpi/tool-errors.d.ts.map +1 -0
- package/dist/senpi/tool-errors.js +87 -0
- package/dist/senpi/tool-errors.js.map +1 -0
- package/dist/senpi/types.d.ts +4 -0
- package/dist/senpi/types.d.ts.map +1 -1
- package/dist/skills-manager/coordinator.d.ts +2 -2
- package/dist/skills-manager/coordinator.js +2 -2
- package/dist/telemetry/metrics.d.ts +11 -0
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +22 -0
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +21 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/types/dsl/index.d.ts +14 -1
- package/dist/types/dsl/index.d.ts.map +1 -1
- package/dist/types/notification.d.ts +102 -1
- package/dist/types/notification.d.ts.map +1 -1
- package/dist/types/notification.js +80 -1
- package/dist/types/notification.js.map +1 -1
- package/dist/types/runtime.d.ts +13 -0
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/session-context.d.ts +19 -0
- package/dist/types/session-context.d.ts.map +1 -0
- package/dist/types/session-context.js +20 -0
- package/dist/types/session-context.js.map +1 -0
- package/dist/utils/event-catalog.d.ts +103 -2
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +28 -0
- package/dist/utils/event-catalog.js.map +1 -1
- package/dist/utils/logger.d.ts +2 -18
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +2 -40
- package/dist/utils/logger.js.map +1 -1
- package/openclaw.plugin.json +10 -1
- package/package.json +3 -2
- package/dist/actions/notifications/formatter.d.ts +0 -39
- package/dist/actions/notifications/formatter.d.ts.map +0 -1
- package/dist/actions/notifications/formatter.js +0 -68
- package/dist/actions/notifications/formatter.js.map +0 -1
- package/dist/actions/notifications/index.d.ts +0 -37
- package/dist/actions/notifications/index.d.ts.map +0 -1
- package/dist/actions/notifications/index.js +0 -89
- package/dist/actions/notifications/index.js.map +0 -1
- package/dist/dsl/notifications/close-resolver.d.ts +0 -92
- package/dist/dsl/notifications/close-resolver.d.ts.map +0 -1
- package/dist/dsl/notifications/close-resolver.js +0 -309
- package/dist/dsl/notifications/close-resolver.js.map +0 -1
- package/dist/dsl/notifications/types.d.ts +0 -27
- package/dist/dsl/notifications/types.d.ts.map +0 -1
- package/dist/dsl/notifications/types.js +0 -5
- package/dist/dsl/notifications/types.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Classification of LLM-decision failures into
|
|
2
|
+
* Classification of LLM-decision failures into a stable code, a retry flag, and
|
|
3
|
+
* a two-bucket user-facing message.
|
|
3
4
|
*
|
|
4
5
|
* ## Why this module exists
|
|
5
6
|
*
|
|
@@ -9,21 +10,25 @@
|
|
|
9
10
|
* need to make decisions from that string:
|
|
10
11
|
*
|
|
11
12
|
* 1. The **notification layer** ({@link formatDecisionErrorNotification} in
|
|
12
|
-
* `notifications.ts`) — what to tell the skill author
|
|
13
|
+
* `notifications.ts`) — what to tell the skill author.
|
|
13
14
|
* 2. The **decision client** (`openclaw-llm-decision.ts`) — whether a retry can
|
|
14
15
|
* plausibly succeed.
|
|
15
16
|
*
|
|
16
|
-
* ##
|
|
17
|
+
* ## Two pieces
|
|
17
18
|
*
|
|
18
|
-
* 1. {@link
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* 1. {@link DECISION_ERROR_TABLE} — the ordered matchers (raw string → code)
|
|
20
|
+
* and the `retryable` flag. Per-code detail is preserved here for logs and
|
|
21
|
+
* telemetry, even though the two consumers above only see the collapsed
|
|
22
|
+
* bucket.
|
|
23
|
+
* 2. {@link classifyDecisionError} — walks the table, then renders the
|
|
24
|
+
* user-facing message from {@link DECISION_ERROR_BUCKET_COPY}, keyed only
|
|
25
|
+
* by `retryable` (see {@link decisionErrorBucket}). Author-facing copy
|
|
26
|
+
* does not vary by code — dozens of failure-mode-specific messages proved
|
|
27
|
+
* to be more than users act on; the two buckets are "this will likely
|
|
28
|
+
* sort itself out" vs. "this needs you to look at it."
|
|
24
29
|
*
|
|
25
|
-
* To change
|
|
26
|
-
*
|
|
30
|
+
* To change matching or retry behavior: edit {@link DECISION_ERROR_TABLE}.
|
|
31
|
+
* To change user-facing wording: edit {@link DECISION_ERROR_BUCKET_COPY}.
|
|
27
32
|
*
|
|
28
33
|
* ## Where the raw strings come from
|
|
29
34
|
*
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
* `tool_error` matches {@link DecisionErrorCode.ProviderError}; on newer gateways
|
|
49
54
|
* the specific code matches.
|
|
50
55
|
*/
|
|
56
|
+
import type { NotificationCopy } from "../types/notification.js";
|
|
51
57
|
/** Stable identifier for each classified LLM-decision failure mode. */
|
|
52
58
|
export declare enum DecisionErrorCode {
|
|
53
59
|
/** Gateway auth token missing in env/config — thrown before any HTTP call. */
|
|
@@ -87,33 +93,12 @@ export declare enum DecisionErrorCode {
|
|
|
87
93
|
/** No matcher matched — surfaces the raw message so operators can still diagnose. */
|
|
88
94
|
Unknown = "UNKNOWN"
|
|
89
95
|
}
|
|
90
|
-
/**
|
|
91
|
-
* The single catalog of every user-facing message, keyed by {@link DecisionErrorCode}.
|
|
92
|
-
*
|
|
93
|
-
* Templates use `{token}` placeholders, filled by the matching entry's `vars`
|
|
94
|
-
* function in {@link DECISION_ERROR_TABLE} (e.g. `{name}` = action name, `{model}`,
|
|
95
|
-
* `{list}`, `{errors}`, `{level}`, `{hint}`, `{providerModel}`, `{raw}`). A `{token}`
|
|
96
|
-
* with no supplied value is left verbatim so a missing var is visible, not silent.
|
|
97
|
-
*
|
|
98
|
-
* **This is the only place to edit copy.** Nothing else hardcodes a message.
|
|
99
|
-
*/
|
|
100
|
-
export declare const DECISION_ERROR_MESSAGES: Record<DecisionErrorCode, string>;
|
|
101
|
-
/**
|
|
102
|
-
* Plugin-side context the gateway error string does not carry but the message
|
|
103
|
-
* needs (e.g. the action's YAML name, the configured `decision_model`).
|
|
104
|
-
*/
|
|
105
|
-
export interface DecisionErrorContext {
|
|
106
|
-
/** The failing action's `name` from the runtime YAML (the `{name}` placeholder). */
|
|
107
|
-
actionName?: string;
|
|
108
|
-
/** The action's configured `decision_model` (fallback for the `{model}` placeholder). */
|
|
109
|
-
model?: string;
|
|
110
|
-
}
|
|
111
96
|
/** Result of classifying a raw LLM-decision error string. */
|
|
112
97
|
export interface ClassifiedDecisionError {
|
|
113
98
|
code: DecisionErrorCode;
|
|
114
99
|
/** Whether a retry of the `llm-task` call can plausibly succeed. */
|
|
115
100
|
retryable: boolean;
|
|
116
|
-
/** User-facing message
|
|
101
|
+
/** User-facing notification message (the bucket's in-app text — see {@link decisionErrorBucket}). */
|
|
117
102
|
userMessage: string;
|
|
118
103
|
}
|
|
119
104
|
/** One row of {@link DECISION_ERROR_TABLE}. */
|
|
@@ -121,40 +106,48 @@ interface DecisionErrorEntry {
|
|
|
121
106
|
code: DecisionErrorCode;
|
|
122
107
|
/**
|
|
123
108
|
* Tested against the raw error string. Returning a {@link RegExpMatchArray}
|
|
124
|
-
* (truthy) or `true` counts as a match; `null`/`false` means no match.
|
|
125
|
-
* groups are forwarded to {@link DecisionErrorEntry.vars} as `caps`.
|
|
109
|
+
* (truthy) or `true` counts as a match; `null`/`false` means no match.
|
|
126
110
|
*/
|
|
127
111
|
match: (raw: string) => RegExpMatchArray | boolean | null;
|
|
128
112
|
retryable: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Optional: produces the `{token}` substitutions for this code's catalog entry.
|
|
131
|
-
* Omit for static messages.
|
|
132
|
-
* @param caps - Capture groups from {@link DecisionErrorEntry.match}, or `null`.
|
|
133
|
-
* @param ctx - Plugin-side context (action name, configured model).
|
|
134
|
-
* @param raw - The original raw error string.
|
|
135
|
-
*/
|
|
136
|
-
vars?: (caps: RegExpMatchArray | null, ctx: DecisionErrorContext, raw: string) => Record<string, string>;
|
|
137
113
|
}
|
|
138
114
|
/**
|
|
139
|
-
* Ordered classification table — matchers + retry flag
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* {@link
|
|
115
|
+
* Ordered classification table — matchers + retry flag. First match wins, so
|
|
116
|
+
* keep specific matchers above generic ones (e.g. `LlmEmptyOutput` before the
|
|
117
|
+
* catch-all `ProviderError`, since both can appear inside a `"rejected
|
|
118
|
+
* request: ..."` wrapper). `code` and `retryable` are the source of truth for
|
|
119
|
+
* logs/telemetry; user-facing copy lives in {@link DECISION_ERROR_BUCKET_COPY}.
|
|
144
120
|
*/
|
|
145
121
|
export declare const DECISION_ERROR_TABLE: readonly DecisionErrorEntry[];
|
|
122
|
+
/**
|
|
123
|
+
* The two user-facing buckets every decision error collapses into. A code's
|
|
124
|
+
* long tail of remediation detail (which YAML field, which host setting) is
|
|
125
|
+
* useful in logs but not something most users act on; retryable vs. not is
|
|
126
|
+
* the one distinction that changes what the user should expect next.
|
|
127
|
+
*/
|
|
128
|
+
export type DecisionErrorBucket = "transient" | "attention";
|
|
129
|
+
/**
|
|
130
|
+
* Map a classified error to its user-facing bucket. Its own code→bucket mapping,
|
|
131
|
+
* independent of `retryable`: the infra-blip codes in {@link TRANSIENT_BUCKET_CODES}
|
|
132
|
+
* are "transient" regardless of their retry flag; everything else follows
|
|
133
|
+
* `retryable` (retryable → transient, else the author-attention bucket).
|
|
134
|
+
*/
|
|
135
|
+
export declare function decisionErrorBucket(code: DecisionErrorCode, retryable: boolean): DecisionErrorBucket;
|
|
136
|
+
/** Label-free copy for each bucket — the emit site applies the `[strategy]` prefix. */
|
|
137
|
+
export declare const DECISION_ERROR_BUCKET_COPY: Record<DecisionErrorBucket, NotificationCopy>;
|
|
146
138
|
/**
|
|
147
139
|
* Classify a raw LLM-decision error string into a {@link ClassifiedDecisionError}.
|
|
148
140
|
*
|
|
149
|
-
* Walks {@link DECISION_ERROR_TABLE} in order; the first matching entry wins
|
|
150
|
-
*
|
|
151
|
-
*
|
|
141
|
+
* Walks {@link DECISION_ERROR_TABLE} in order; the first matching entry wins,
|
|
142
|
+
* giving `code` + `retryable` (preserved for logs/telemetry). If nothing
|
|
143
|
+
* matches, returns {@link DecisionErrorCode.Unknown} (not retryable). The
|
|
144
|
+
* user-facing `userMessage` is always the collapsed bucket's in-app copy from
|
|
145
|
+
* {@link DECISION_ERROR_BUCKET_COPY} — it does not vary by code.
|
|
152
146
|
*
|
|
153
147
|
* @param rawMessage - The error string thrown by the decision client (may embed an
|
|
154
148
|
* OpenClaw gateway message). Non-string / empty inputs are coerced safely.
|
|
155
|
-
* @param ctx - Optional plugin-side context for placeholders the gateway can't supply.
|
|
156
149
|
*/
|
|
157
|
-
export declare function classifyDecisionError(rawMessage: string
|
|
150
|
+
export declare function classifyDecisionError(rawMessage: string): ClassifiedDecisionError;
|
|
158
151
|
/**
|
|
159
152
|
* Convenience predicate for retry wiring: `true` when a retry of the failed
|
|
160
153
|
* `llm-task` call can plausibly succeed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-errors.d.ts","sourceRoot":"","sources":["../../src/runtime/decision-errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"decision-errors.d.ts","sourceRoot":"","sources":["../../src/runtime/decision-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,uEAAuE;AACvE,oBAAY,iBAAiB;IAC3B,8EAA8E;IAC9E,mBAAmB,0BAA0B;IAC7C,2EAA2E;IAC3E,kBAAkB,wBAAwB;IAC1C,mFAAmF;IACnF,qBAAqB,4BAA4B;IACjD,mFAAmF;IACnF,cAAc,oBAAoB;IAClC,uEAAuE;IACvE,uBAAuB,8BAA8B;IACrD,wEAAwE;IACxE,eAAe,sBAAsB;IACrC,qFAAqF;IACrF,oBAAoB,2BAA2B;IAC/C,4FAA4F;IAC5F,cAAc,qBAAqB;IACnC,gFAAgF;IAChF,cAAc,qBAAqB;IACnC,+DAA+D;IAC/D,iBAAiB,wBAAwB;IACzC,6EAA6E;IAC7E,aAAa,mBAAmB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M-decision failures into
|
|
2
|
+
* Classification of LLM-decision failures into a stable code, a retry flag, and
|
|
3
|
+
* a two-bucket user-facing message.
|
|
3
4
|
*
|
|
4
5
|
* ## Why this module exists
|
|
5
6
|
*
|
|
@@ -9,21 +10,25 @@
|
|
|
9
10
|
* need to make decisions from that string:
|
|
10
11
|
*
|
|
11
12
|
* 1. The **notification layer** ({@link formatDecisionErrorNotification} in
|
|
12
|
-
* `notifications.ts`) — what to tell the skill author
|
|
13
|
+
* `notifications.ts`) — what to tell the skill author.
|
|
13
14
|
* 2. The **decision client** (`openclaw-llm-decision.ts`) — whether a retry can
|
|
14
15
|
* plausibly succeed.
|
|
15
16
|
*
|
|
16
|
-
* ##
|
|
17
|
+
* ## Two pieces
|
|
17
18
|
*
|
|
18
|
-
* 1. {@link
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* 1. {@link DECISION_ERROR_TABLE} — the ordered matchers (raw string → code)
|
|
20
|
+
* and the `retryable` flag. Per-code detail is preserved here for logs and
|
|
21
|
+
* telemetry, even though the two consumers above only see the collapsed
|
|
22
|
+
* bucket.
|
|
23
|
+
* 2. {@link classifyDecisionError} — walks the table, then renders the
|
|
24
|
+
* user-facing message from {@link DECISION_ERROR_BUCKET_COPY}, keyed only
|
|
25
|
+
* by `retryable` (see {@link decisionErrorBucket}). Author-facing copy
|
|
26
|
+
* does not vary by code — dozens of failure-mode-specific messages proved
|
|
27
|
+
* to be more than users act on; the two buckets are "this will likely
|
|
28
|
+
* sort itself out" vs. "this needs you to look at it."
|
|
24
29
|
*
|
|
25
|
-
* To change
|
|
26
|
-
*
|
|
30
|
+
* To change matching or retry behavior: edit {@link DECISION_ERROR_TABLE}.
|
|
31
|
+
* To change user-facing wording: edit {@link DECISION_ERROR_BUCKET_COPY}.
|
|
27
32
|
*
|
|
28
33
|
* ## Where the raw strings come from
|
|
29
34
|
*
|
|
@@ -89,79 +94,11 @@ export var DecisionErrorCode;
|
|
|
89
94
|
DecisionErrorCode["Unknown"] = "UNKNOWN";
|
|
90
95
|
})(DecisionErrorCode || (DecisionErrorCode = {}));
|
|
91
96
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* with no supplied value is left verbatim so a missing var is visible, not silent.
|
|
98
|
-
*
|
|
99
|
-
* **This is the only place to edit copy.** Nothing else hardcodes a message.
|
|
100
|
-
*/
|
|
101
|
-
export const DECISION_ERROR_MESSAGES = {
|
|
102
|
-
[DecisionErrorCode.GatewayTokenMissing]: "Senpi: OpenClaw gateway token not configured. Set OPENCLAW_GATEWAY_TOKEN.",
|
|
103
|
-
[DecisionErrorCode.GatewayUnreachable]: "Senpi: OpenClaw Gateway is unreachable.",
|
|
104
|
-
[DecisionErrorCode.PluginEndpointMissing]: "Senpi: OpenClaw is missing the plugin endpoint. Please reinstall the plugin.",
|
|
105
|
-
[DecisionErrorCode.PromptRequired]: "Your agent can't trade until its template is fixed. Action `{name}` in your runtime YAML is " +
|
|
106
|
-
"missing a `decision_prompt`. To recover: delete this runtime, ask your OpenClaw agent to add a " +
|
|
107
|
-
"`decision_prompt` to that action, and install it again. If you didn't write this skill, contact " +
|
|
108
|
-
"Senpi support.",
|
|
109
|
-
[DecisionErrorCode.ProviderModelUnresolved]: "Your agent can't trade because the AI model `{model}` isn't recognized by your OpenClaw host. " +
|
|
110
|
-
"To recover: delete this runtime, set a valid `decision_model` in your runtime YAML, and install it " +
|
|
111
|
-
"again. If you didn't write this skill, contact Senpi support.",
|
|
112
|
-
[DecisionErrorCode.ModelNotAllowed]: "Your agent can't trade because `{model}` isn't on your OpenClaw host's allowed-models list. " +
|
|
113
|
-
"Allowed: `{list}`. To recover: pick a model from the allowed list (delete the runtime, edit " +
|
|
114
|
-
"`decision_model` in the runtime YAML, install again) or add it to your host's allowedModels config.",
|
|
115
|
-
[DecisionErrorCode.InputNotSerializable]: "Your agent hit an internal bug while building the AI request (data wasn't serializable). Please " +
|
|
116
|
-
"report this to Senpi support — it isn't something you can fix from your side.",
|
|
117
|
-
[DecisionErrorCode.LlmEmptyOutput]: "Your agent dropped one signal because the AI model returned no answer. This is usually a safety " +
|
|
118
|
-
"filter or a transient model quirk. If it keeps happening, try a different `decision_model` in your " +
|
|
119
|
-
"runtime YAML (delete the runtime, edit, reinstall) or rephrase your `decision_prompt` to be less " +
|
|
120
|
-
"ambiguous.",
|
|
121
|
-
[DecisionErrorCode.LlmInvalidJson]: "Your agent dropped one signal because the AI model's reply wasn't valid JSON — usually a truncation " +
|
|
122
|
-
"or a prompt that didn't force JSON output. To recover: tighten your `decision_prompt` in the runtime " +
|
|
123
|
-
"YAML to require strict JSON, then delete and reinstall the runtime. If you didn't write this skill, " +
|
|
124
|
-
"contact Senpi support.",
|
|
125
|
-
[DecisionErrorCode.LlmSchemaMismatch]: "Your agent dropped one signal because the AI model's reply was valid JSON but didn't match the " +
|
|
126
|
-
"expected shape: `{errors}`. To recover: tweak your `decision_prompt` so the model returns the " +
|
|
127
|
-
"required fields, or have your OpenClaw agent loosen the schema (delete the runtime, edit the YAML, " +
|
|
128
|
-
"reinstall). If you didn't write this skill, contact Senpi support.",
|
|
129
|
-
[DecisionErrorCode.ProviderError]: "Your agent dropped one signal because the AI provider rejected the call (e.g. rate limit or outage). " +
|
|
130
|
-
"Usually transient — the next signal often goes through. If it keeps happening, try switching " +
|
|
131
|
-
"providers or using a different `decision_model` in your runtime YAML.",
|
|
132
|
-
[DecisionErrorCode.Timeout]: "Your agent dropped one signal because the AI model didn't reply in 90 seconds. This is usually " +
|
|
133
|
-
"transient — the next signal often goes through. If it keeps happening, switch to a faster " +
|
|
134
|
-
"`decision_model` in your runtime YAML (delete the runtime, edit, reinstall).",
|
|
135
|
-
[DecisionErrorCode.EmbeddedAgentUnavailable]: "Your agent dropped one signal because OpenClaw's internal LLM helper failed to load on your host. " +
|
|
136
|
-
"This usually means the OpenClaw install is corrupted or partially upgraded. To recover: reinstall " +
|
|
137
|
-
"OpenClaw on your host (or upgrade to the latest version — this error no longer exists in v2026.5.7+). " +
|
|
138
|
-
"If it keeps happening after reinstall, contact Senpi support.",
|
|
139
|
-
[DecisionErrorCode.InvalidThinkingLevel]: "Your agent's runtime YAML uses an unknown thinking level (`{level}`). Valid options: `{hint}`. " +
|
|
140
|
-
"To recover: delete this runtime, set `thinking` to a valid value in the runtime YAML, and install it " +
|
|
141
|
-
"again. If you didn't write this skill, contact Senpi support.",
|
|
142
|
-
[DecisionErrorCode.ThinkingLevelUnsupported]: "Your agent's model (`{providerModel}`) doesn't support the thinking level `{level}`. Supported for " +
|
|
143
|
-
"this model: `{hint}`. To recover: delete this runtime, change either the model or the thinking level " +
|
|
144
|
-
"in the runtime YAML, and install it again.",
|
|
145
|
-
[DecisionErrorCode.PluginResponseShape]: "Your agent hit an internal bug parsing the AI model's response. Please report this to Senpi support " +
|
|
146
|
-
"— it isn't something you can fix from your side.",
|
|
147
|
-
[DecisionErrorCode.OpenClawUnexpected]: "Senpi: Signal Dropped - OpenClaw hit an unexpected error.",
|
|
148
|
-
[DecisionErrorCode.Unknown]: "Senpi: Trading decision failed — {raw}",
|
|
149
|
-
};
|
|
150
|
-
/** Trim a captured token; falls back to `fallback` when empty/absent. */
|
|
151
|
-
function clean(value, fallback) {
|
|
152
|
-
const t = value?.trim();
|
|
153
|
-
return t && t.length > 0 ? t : fallback;
|
|
154
|
-
}
|
|
155
|
-
/** Fill `{token}` placeholders from `vars`; unknown tokens are left verbatim. */
|
|
156
|
-
function renderTemplate(template, vars) {
|
|
157
|
-
return template.replace(/\{(\w+)\}/g, (whole, key) => Object.prototype.hasOwnProperty.call(vars, key) ? vars[key] : whole);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Ordered classification table — matchers + retry flag + template-variable logic.
|
|
161
|
-
* First match wins, so keep specific matchers above generic ones (e.g.
|
|
162
|
-
* `LlmEmptyOutput` before the catch-all `ProviderError`, since both can appear
|
|
163
|
-
* inside a `"rejected request: ..."` wrapper). Copy lives in
|
|
164
|
-
* {@link DECISION_ERROR_MESSAGES}, not here.
|
|
97
|
+
* Ordered classification table — matchers + retry flag. First match wins, so
|
|
98
|
+
* keep specific matchers above generic ones (e.g. `LlmEmptyOutput` before the
|
|
99
|
+
* catch-all `ProviderError`, since both can appear inside a `"rejected
|
|
100
|
+
* request: ..."` wrapper). `code` and `retryable` are the source of truth for
|
|
101
|
+
* logs/telemetry; user-facing copy lives in {@link DECISION_ERROR_BUCKET_COPY}.
|
|
165
102
|
*/
|
|
166
103
|
export const DECISION_ERROR_TABLE = [
|
|
167
104
|
// ── Pre-HTTP / infra (not retryable) ──────────────────────────────────────
|
|
@@ -185,22 +122,16 @@ export const DECISION_ERROR_TABLE = [
|
|
|
185
122
|
code: DecisionErrorCode.PromptRequired,
|
|
186
123
|
match: (s) => /prompt required/i.test(s),
|
|
187
124
|
retryable: false,
|
|
188
|
-
vars: (_caps, ctx) => ({ name: clean(ctx.actionName, "<name>") }),
|
|
189
125
|
},
|
|
190
126
|
{
|
|
191
127
|
code: DecisionErrorCode.ProviderModelUnresolved,
|
|
192
128
|
match: (s) => s.match(/provider\/model could not be resolved \(provider=(.*?), model=(.*?)\)/),
|
|
193
129
|
retryable: false,
|
|
194
|
-
vars: (caps, ctx) => ({ model: clean(caps?.[2], clean(ctx.model, "your configured model")) }),
|
|
195
130
|
},
|
|
196
131
|
{
|
|
197
132
|
code: DecisionErrorCode.ModelNotAllowed,
|
|
198
133
|
match: (s) => s.match(/Model not allowed by llm-task plugin config:\s*([^.]+)\.\s*Allowed models:\s*([^"}]+)/),
|
|
199
134
|
retryable: false,
|
|
200
|
-
vars: (caps, ctx) => ({
|
|
201
|
-
model: clean(caps?.[1], clean(ctx.model, "that model")),
|
|
202
|
-
list: clean(caps?.[2], "(see your host's allowedModels config)"),
|
|
203
|
-
}),
|
|
204
135
|
},
|
|
205
136
|
{
|
|
206
137
|
code: DecisionErrorCode.InputNotSerializable,
|
|
@@ -225,27 +156,17 @@ export const DECISION_ERROR_TABLE = [
|
|
|
225
156
|
code: DecisionErrorCode.LlmSchemaMismatch,
|
|
226
157
|
match: (s) => s.match(/LLM JSON did not match schema:\s*([^"}]+)/),
|
|
227
158
|
retryable: false,
|
|
228
|
-
vars: (caps) => ({ errors: clean(caps?.[1], "(schema validation failed)") }),
|
|
229
159
|
},
|
|
230
160
|
// ── Thinking-level misconfig (v2026.5.7+, not retryable) ──────────────────
|
|
231
161
|
{
|
|
232
162
|
code: DecisionErrorCode.InvalidThinkingLevel,
|
|
233
163
|
match: (s) => s.match(/Invalid thinking level "(.*?)"\.\s*Use one of:\s*([^"}]+?)\./),
|
|
234
164
|
retryable: false,
|
|
235
|
-
vars: (caps) => ({
|
|
236
|
-
level: clean(caps?.[1], "that value"),
|
|
237
|
-
hint: clean(caps?.[2], "the supported levels"),
|
|
238
|
-
}),
|
|
239
165
|
},
|
|
240
166
|
{
|
|
241
167
|
code: DecisionErrorCode.ThinkingLevelUnsupported,
|
|
242
168
|
match: (s) => s.match(/Thinking level "(.*?)" is not supported for (.+?)\.\s*Use one of:\s*([^"}]+?)\./),
|
|
243
169
|
retryable: false,
|
|
244
|
-
vars: (caps, ctx) => ({
|
|
245
|
-
level: clean(caps?.[1], "that level"),
|
|
246
|
-
providerModel: clean(caps?.[2], clean(ctx.model, "this model")),
|
|
247
|
-
hint: clean(caps?.[3], "the supported levels"),
|
|
248
|
-
}),
|
|
249
170
|
},
|
|
250
171
|
// ── Host/load failure (not retryable) ─────────────────────────────────────
|
|
251
172
|
{
|
|
@@ -284,35 +205,75 @@ export const DECISION_ERROR_TABLE = [
|
|
|
284
205
|
retryable: false,
|
|
285
206
|
},
|
|
286
207
|
];
|
|
208
|
+
/**
|
|
209
|
+
* Codes that take the TRANSIENT user-facing bucket even though they are not
|
|
210
|
+
* retryable. These are infrastructure blips, not author-action-needed:
|
|
211
|
+
* - {@link DecisionErrorCode.Timeout} — marked non-retryable only so a retry
|
|
212
|
+
* doesn't stall the serial signal queue (we already waited the full window);
|
|
213
|
+
* nothing the author can fix, and the next signal will likely go through.
|
|
214
|
+
* - {@link DecisionErrorCode.GatewayUnreachable} — a connection blip (refused /
|
|
215
|
+
* reset / DNS); transient by nature.
|
|
216
|
+
*
|
|
217
|
+
* The bucket is deliberately keyed on the CODE, not on `retryable`, so routing
|
|
218
|
+
* these to "transient" copy does not change queue/retry behavior (see
|
|
219
|
+
* {@link isRetryableDecisionError}, which stays keyed on `retryable`).
|
|
220
|
+
*/
|
|
221
|
+
const TRANSIENT_BUCKET_CODES = new Set([
|
|
222
|
+
DecisionErrorCode.Timeout,
|
|
223
|
+
DecisionErrorCode.GatewayUnreachable,
|
|
224
|
+
]);
|
|
225
|
+
/**
|
|
226
|
+
* Map a classified error to its user-facing bucket. Its own code→bucket mapping,
|
|
227
|
+
* independent of `retryable`: the infra-blip codes in {@link TRANSIENT_BUCKET_CODES}
|
|
228
|
+
* are "transient" regardless of their retry flag; everything else follows
|
|
229
|
+
* `retryable` (retryable → transient, else the author-attention bucket).
|
|
230
|
+
*/
|
|
231
|
+
export function decisionErrorBucket(code, retryable) {
|
|
232
|
+
if (TRANSIENT_BUCKET_CODES.has(code))
|
|
233
|
+
return "transient";
|
|
234
|
+
return retryable ? "transient" : "attention";
|
|
235
|
+
}
|
|
236
|
+
/** Label-free copy for each bucket — the emit site applies the `[strategy]` prefix. */
|
|
237
|
+
export const DECISION_ERROR_BUCKET_COPY = {
|
|
238
|
+
transient: {
|
|
239
|
+
pushTitle: "⚠️ Signal skipped",
|
|
240
|
+
pushBody: "Skipped a signal (transient) — still running, next one will go",
|
|
241
|
+
inApp: "⚠️ Skipped one trade signal — a brief issue deciding the trade. Still running; it'll take the next one. " +
|
|
242
|
+
"We've logged it — contact support and we'll help fix it.",
|
|
243
|
+
},
|
|
244
|
+
attention: {
|
|
245
|
+
pushTitle: "⚠️ Needs attention",
|
|
246
|
+
pushBody: "Your strategy needs attention before it can trade",
|
|
247
|
+
inApp: "⚠️ Your strategy needs attention before it can trade. We've logged it — contact support and we'll help fix it.",
|
|
248
|
+
},
|
|
249
|
+
};
|
|
287
250
|
/**
|
|
288
251
|
* Classify a raw LLM-decision error string into a {@link ClassifiedDecisionError}.
|
|
289
252
|
*
|
|
290
|
-
* Walks {@link DECISION_ERROR_TABLE} in order; the first matching entry wins
|
|
291
|
-
*
|
|
292
|
-
*
|
|
253
|
+
* Walks {@link DECISION_ERROR_TABLE} in order; the first matching entry wins,
|
|
254
|
+
* giving `code` + `retryable` (preserved for logs/telemetry). If nothing
|
|
255
|
+
* matches, returns {@link DecisionErrorCode.Unknown} (not retryable). The
|
|
256
|
+
* user-facing `userMessage` is always the collapsed bucket's in-app copy from
|
|
257
|
+
* {@link DECISION_ERROR_BUCKET_COPY} — it does not vary by code.
|
|
293
258
|
*
|
|
294
259
|
* @param rawMessage - The error string thrown by the decision client (may embed an
|
|
295
260
|
* OpenClaw gateway message). Non-string / empty inputs are coerced safely.
|
|
296
|
-
* @param ctx - Optional plugin-side context for placeholders the gateway can't supply.
|
|
297
261
|
*/
|
|
298
|
-
export function classifyDecisionError(rawMessage
|
|
262
|
+
export function classifyDecisionError(rawMessage) {
|
|
299
263
|
const raw = typeof rawMessage === "string" ? rawMessage : String(rawMessage ?? "");
|
|
300
264
|
for (const entry of DECISION_ERROR_TABLE) {
|
|
301
|
-
|
|
302
|
-
if (!result)
|
|
265
|
+
if (!entry.match(raw))
|
|
303
266
|
continue;
|
|
304
|
-
const caps = Array.isArray(result) ? result : null;
|
|
305
|
-
const vars = entry.vars ? entry.vars(caps, ctx, raw) : {};
|
|
306
267
|
return {
|
|
307
268
|
code: entry.code,
|
|
308
269
|
retryable: entry.retryable,
|
|
309
|
-
userMessage:
|
|
270
|
+
userMessage: DECISION_ERROR_BUCKET_COPY[decisionErrorBucket(entry.code, entry.retryable)].inApp,
|
|
310
271
|
};
|
|
311
272
|
}
|
|
312
273
|
return {
|
|
313
274
|
code: DecisionErrorCode.Unknown,
|
|
314
275
|
retryable: false,
|
|
315
|
-
userMessage:
|
|
276
|
+
userMessage: DECISION_ERROR_BUCKET_COPY[decisionErrorBucket(DecisionErrorCode.Unknown, false)].inApp,
|
|
316
277
|
};
|
|
317
278
|
}
|
|
318
279
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decision-errors.js","sourceRoot":"","sources":["../../src/runtime/decision-errors.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"decision-errors.js","sourceRoot":"","sources":["../../src/runtime/decision-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAIH,uEAAuE;AACvE,MAAM,CAAN,IAAY,iBAqCX;AArCD,WAAY,iBAAiB;IAC3B,8EAA8E;IAC9E,kEAA6C,CAAA;IAC7C,2EAA2E;IAC3E,+DAA0C,CAAA;IAC1C,mFAAmF;IACnF,sEAAiD,CAAA;IACjD,mFAAmF;IACnF,uDAAkC,CAAA;IAClC,uEAAuE;IACvE,0EAAqD,CAAA;IACrD,wEAAwE;IACxE,0DAAqC,CAAA;IACrC,qFAAqF;IACrF,oEAA+C,CAAA;IAC/C,4FAA4F;IAC5F,wDAAmC,CAAA;IACnC,gFAAgF;IAChF,wDAAmC,CAAA;IACnC,+DAA+D;IAC/D,8DAAyC,CAAA;IACzC,6EAA6E;IAC7E,qDAAgC,CAAA;IAChC,wFAAwF;IACxF,wCAAmB,CAAA;IACnB,yFAAyF;IACzF,4EAAuD,CAAA;IACvD,gFAAgF;IAChF,oEAA+C,CAAA;IAC/C,kFAAkF;IAClF,4EAAuD,CAAA;IACvD,yFAAyF;IACzF,kEAA6C,CAAA;IAC7C,0DAA0D;IAC1D,+DAA0C,CAAA;IAC1C,qFAAqF;IACrF,wCAAmB,CAAA;AACrB,CAAC,EArCW,iBAAiB,KAAjB,iBAAiB,QAqC5B;AAsBD;;;;;;GAMG;AACH,MA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
|
import type { NotificationService } from "../types/notification.js";
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Production ingest endpoint, used when neither `options.ingest_url` nor
|
|
4
|
+
* `NOTIFICATIONS_INGEST_URL` supplies one. The typical deployment IS production,
|
|
5
|
+
* so the runtime boots and delivers with zero notification config; non-prod
|
|
6
|
+
* environments must set the env var to point at their own ingest endpoint.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_INGEST_URL = "https://notifications.prod.senpi.ai/notify";
|
|
4
9
|
export interface NotificationServiceOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
/** Override for the `NOTIFICATIONS_INGEST_URL` env (tests / non-standard hosting). */
|
|
11
|
+
ingest_url?: string;
|
|
12
|
+
/** The runtime's own Senpi auth token (MCP bearer). Doubles as the ingest-endpoint
|
|
13
|
+
* bearer credential and, via its `senpi_user_id` claim, the recipient every
|
|
14
|
+
* outgoing notification is stamped with. */
|
|
15
|
+
senpi_auth_token?: string;
|
|
16
|
+
/** Override the per-request timeout in ms (tests). */
|
|
17
|
+
ingest_timeout_ms?: number;
|
|
9
18
|
[key: string]: unknown;
|
|
10
19
|
}
|
|
11
20
|
/**
|
|
12
|
-
* Map a raw LLM-decision error string to
|
|
21
|
+
* Map a raw LLM-decision error string to a user-facing notification message.
|
|
13
22
|
*
|
|
14
|
-
* Thin wrapper over {@link classifyDecisionError} —
|
|
23
|
+
* Thin wrapper over {@link classifyDecisionError} — the two-bucket copy and the
|
|
15
24
|
* failure-mode lookup live in `decision-errors.ts` (the single source of truth
|
|
16
25
|
* shared with the retry logic in `openclaw-llm-decision.ts`). The runtime catches
|
|
17
26
|
* errors from the LLM-decision call and passes `err.message` here.
|
|
18
27
|
*
|
|
19
28
|
* @param rawMessage - Error message thrown by the decision client (may embed an
|
|
20
29
|
* OpenClaw gateway message).
|
|
21
|
-
* @param ctx - Optional plugin-side context (action name, configured model) for
|
|
22
|
-
* placeholders the gateway error string cannot supply.
|
|
23
30
|
*/
|
|
24
|
-
export declare function formatDecisionErrorNotification(rawMessage: string
|
|
31
|
+
export declare function formatDecisionErrorNotification(rawMessage: string): string;
|
|
25
32
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
33
|
+
* User-facing alert when the backend rejects orders because the strategy is
|
|
34
|
+
* paused or closed on Senpi. Fired once when the backend-pause registry arms
|
|
35
|
+
* (open-position action); subsequent signals are skipped until the registry's
|
|
36
|
+
* recheck window elapses, so the copy must not promise instant resumption.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatBackendPausedNotification(address: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Create the runtime's notification service. Every notification is delivered by
|
|
41
|
+
* POSTing the full structured envelope to the authenticated notification-ingest
|
|
42
|
+
* endpoint — there is no other delivery path. The endpoint resolves in order:
|
|
43
|
+
* `options.ingest_url`, then `NOTIFICATIONS_INGEST_URL`, then the production
|
|
44
|
+
* default ({@link DEFAULT_INGEST_URL}), so the URL can never be missing. A missing
|
|
45
|
+
* auth token is still a startup error (thrown here, not discovered later as
|
|
46
|
+
* silent notification loss), so callers must construct this before a runtime
|
|
47
|
+
* starts trading, not lazily on first notify.
|
|
48
|
+
*
|
|
49
|
+
* Failure paths inside this service log at warn, not error: a delivery failure is a
|
|
50
|
+
* handled, degraded condition — the caller's notify() contract is fire-and-forget and
|
|
51
|
+
* the next notification retries the transport fresh.
|
|
31
52
|
*/
|
|
32
53
|
export declare function createNotificationService(options?: NotificationServiceOptions): NotificationService;
|
|
33
54
|
//# sourceMappingURL=notifications.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/runtime/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../src/runtime/notifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyC,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AA+B3G;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,+CAA+C,CAAC;AAE/E,MAAM,WAAW,0BAA0B;IACzC,sFAAsF;IACtF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;gDAE4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1E;AAqGD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOvE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,mBAAmB,CA0GnG"}
|