@efengx/openclaw-channel-dragon 0.5.24 → 0.5.26
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/components/channel/ChannelComponent.js +13 -2
- package/dist/index.js +56 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -262,16 +262,27 @@ export class ChannelComponent {
|
|
|
262
262
|
logger?.error?.(`[Dragon Plugin] Failed to read real error from session file: ${fsErr}`);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
+
// Check for insufficient spending cap/quota error and provide a friendly Chinese message
|
|
266
|
+
const lowerError = resolvedErrorMessage.toLowerCase();
|
|
267
|
+
const isSpendCapExceeded = lowerError.includes("spending cap") ||
|
|
268
|
+
lowerError.includes("spend cap") ||
|
|
269
|
+
lowerError.includes("resource_exhausted") ||
|
|
270
|
+
lowerError.includes("quota exceeded") ||
|
|
271
|
+
lowerError.includes("exceeded its monthly spending cap");
|
|
272
|
+
let friendlyMessage = `⚠️ OpenClaw Error: ${resolvedErrorMessage}`;
|
|
273
|
+
if (isSpendCapExceeded) {
|
|
274
|
+
friendlyMessage = "⚠️ 您的 Google Gemini API Key 已达到月度限额(Spending Cap)或余额不足,请前往 AI Studio (https://aistudio.google.com/) 调整限制或更新支付信息。";
|
|
275
|
+
}
|
|
265
276
|
// Report the actual failure via progress and reply
|
|
266
277
|
await progress({
|
|
267
278
|
kind: 'assistant',
|
|
268
279
|
phase: 'error',
|
|
269
280
|
status: 'failed',
|
|
270
281
|
title: '生成回复失败',
|
|
271
|
-
detail: resolvedErrorMessage,
|
|
282
|
+
detail: isSpendCapExceeded ? "大模型账户额度或余额不足" : resolvedErrorMessage,
|
|
272
283
|
});
|
|
273
284
|
await this.telemetry.reportReply({
|
|
274
|
-
content:
|
|
285
|
+
content: friendlyMessage,
|
|
275
286
|
sessionId,
|
|
276
287
|
source: "telemetry_deliver",
|
|
277
288
|
msgId: replyMsgId,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineChannelPluginEntry, createChatChannelPlugin, createChannelPluginBase } from "openclaw/plugin-sdk/core";
|
|
1
|
+
import { defineChannelPluginEntry, createChatChannelPlugin, createChannelPluginBase, buildChannelOutboundSessionRoute } from "openclaw/plugin-sdk/core";
|
|
2
2
|
import { createRawChannelSendResultAdapter } from "openclaw/plugin-sdk/channel-send-result";
|
|
3
3
|
import * as InfraRuntime from "openclaw/plugin-sdk/infra-runtime";
|
|
4
4
|
import { ServiceContainer } from "./core/ServiceContainer.js";
|
|
@@ -86,6 +86,61 @@ const plugin = createChatChannelPlugin({
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
+
messaging: {
|
|
90
|
+
targetPrefixes: ["dragon-workbench", "dragon"],
|
|
91
|
+
normalizeTarget: (raw) => {
|
|
92
|
+
let target = raw || "";
|
|
93
|
+
for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
|
|
94
|
+
if (target.startsWith(prefix)) {
|
|
95
|
+
target = target.substring(prefix.length);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return target ? `dragon-workbench-${target}` : "";
|
|
99
|
+
},
|
|
100
|
+
resolveOutboundSessionRoute: (params) => {
|
|
101
|
+
let target = params.target || "";
|
|
102
|
+
for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
|
|
103
|
+
if (target.startsWith(prefix)) {
|
|
104
|
+
target = target.substring(prefix.length);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (!target)
|
|
108
|
+
return null;
|
|
109
|
+
return buildChannelOutboundSessionRoute({
|
|
110
|
+
cfg: params.cfg,
|
|
111
|
+
agentId: params.agentId,
|
|
112
|
+
channel: channelId,
|
|
113
|
+
accountId: params.accountId,
|
|
114
|
+
peer: {
|
|
115
|
+
kind: "direct",
|
|
116
|
+
id: target
|
|
117
|
+
},
|
|
118
|
+
chatType: "direct",
|
|
119
|
+
from: `dragon-workbench-${target}`,
|
|
120
|
+
to: `dragon-workbench-${target}`
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
targetResolver: {
|
|
124
|
+
looksLikeId: (raw) => {
|
|
125
|
+
return raw.startsWith("dragon-workbench-") || raw.startsWith("session-");
|
|
126
|
+
},
|
|
127
|
+
hint: "<sessionId>",
|
|
128
|
+
resolveTarget: async ({ input }) => {
|
|
129
|
+
let sessionId = input;
|
|
130
|
+
for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
|
|
131
|
+
if (sessionId.startsWith(prefix)) {
|
|
132
|
+
sessionId = sessionId.substring(prefix.length);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
to: `dragon-workbench-${sessionId}`,
|
|
137
|
+
kind: "direct",
|
|
138
|
+
display: `Dragon Workbench User (${sessionId})`,
|
|
139
|
+
source: "normalized"
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
89
144
|
},
|
|
90
145
|
outbound: {
|
|
91
146
|
attachedResults: createRawChannelSendResultAdapter({
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const dragonChannelPluginVersion = "0.5.
|
|
1
|
+
export declare const dragonChannelPluginVersion = "0.5.26";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const dragonChannelPluginVersion = "0.5.
|
|
1
|
+
export const dragonChannelPluginVersion = "0.5.26";
|