@inetafrica/open-claudia 2.2.5 → 2.2.6
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/CHANGELOG.md +5 -0
- package/channels/kazee/adapter.js +58 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v2.2.6
|
|
4
|
+
- Kazee inbound photos: V2 socket emits attachments as `msg.media` (single) or `msg.medias` (array), not `msg.attachments`. The adapter now reads all three so images sent from Kazee web/mobile clients reach the bot instead of being silently dropped as zero-attachment text.
|
|
5
|
+
- Kazee outbound files: rewrote `sendFile` to (a) upload via `POST /chat/media/:chatId` with field `media` (the actual route; the old code POSTed to `/upload` with field `file` and 404'd), then (b) post the message via the V2 socket event `message:send` with `mediaIds: [<uploadedId>]` instead of REST `sendMessage` with `media_url`. The REST path is currently broken upstream — `Chat/send_message` calls `Media.create` without the required `chat`/`bucketName`/`fileName`/`minioPath` fields and 500s with `Failed to create media record`. Going via the socket handler reuses the already-saved Media doc and avoids the duplicate create.
|
|
6
|
+
- New `_socketEmit(event, payload, timeoutMs)` adapter helper that promisifies socket.io acks with a timeout, used by the new outbound path.
|
|
7
|
+
|
|
3
8
|
## v2.2.5
|
|
4
9
|
- Fix `/codex` resume crash: `buildCodexArgs` no longer appends `--add-dir <transcripts-dir>`, which the Codex CLI does not accept and which caused every `codex exec resume` invocation to exit 2 with `error: unexpected argument '--add-dir' found`. Transcript pointer is still injected into the prompt via `promptWithTranscriptPointer`.
|
|
5
10
|
- Backend-aware empty-output failure message: when a non-Claude backend exits with no assistant output, the reply now labels it correctly (`Codex` / `Cursor`) and points at the right diagnostic commands (`/codex_auth_status`, `/codex_login`, `/codex_setup_token`, or `agent login`) instead of always saying "Claude exited" and recommending Claude-only commands.
|
|
@@ -138,8 +138,14 @@ class KazeeAdapter {
|
|
|
138
138
|
raw: msg,
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
// chat-central V2 emits attached media on msg.medias (array) or
|
|
142
|
+
// msg.media (single). Older shapes used msg.attachments — keep that
|
|
143
|
+
// as a fallback for safety.
|
|
144
|
+
const rawMedia = (Array.isArray(msg.medias) && msg.medias.length)
|
|
145
|
+
? msg.medias
|
|
146
|
+
: (msg.media ? [msg.media] : (msg.attachments || []));
|
|
147
|
+
if (rawMedia.length) {
|
|
148
|
+
envelope.media = rawMedia.map((a) => {
|
|
143
149
|
let kind = a.type;
|
|
144
150
|
if (!kind) {
|
|
145
151
|
const mime = (a.mimeType || "").toLowerCase();
|
|
@@ -229,22 +235,37 @@ class KazeeAdapter {
|
|
|
229
235
|
try {
|
|
230
236
|
const buffer = fs.readFileSync(filePath);
|
|
231
237
|
const fileName = path.basename(filePath);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
// chat-central action `uploadMedia` is mounted at
|
|
239
|
+
// POST /chat/media/:chatId and expects the file under the `media`
|
|
240
|
+
// multipart field. It responds with { success, media: [<savedDoc>] }
|
|
241
|
+
// where each saved doc carries `_id` and a presigned `url`.
|
|
242
|
+
const upload = await this._uploadMultipart(
|
|
243
|
+
`/chat/media/${encodeURIComponent(channelId)}`,
|
|
244
|
+
{ media: { buffer, fileName } },
|
|
245
|
+
);
|
|
246
|
+
const savedMedia = Array.isArray(upload?.media) ? upload.media[0] : null;
|
|
247
|
+
const mediaId = savedMedia?._id;
|
|
248
|
+
if (!mediaId) {
|
|
249
|
+
console.error("Kazee upload returned no media id:", JSON.stringify(upload).slice(0, 300));
|
|
236
250
|
return false;
|
|
237
251
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
252
|
+
// Post the message via the v2 socket event `message:send`, which
|
|
253
|
+
// accepts `mediaIds` referencing already-saved Media docs. We avoid
|
|
254
|
+
// the REST sendMessage action because it tries to re-Media.create
|
|
255
|
+
// from media_url and that call omits required schema fields
|
|
256
|
+
// (chat/bucketName/fileName/minioPath) — it always 500s.
|
|
257
|
+
const payload = {
|
|
258
|
+
chatId: channelId,
|
|
259
|
+
content: caption || "",
|
|
242
260
|
type: this._kazeeFileType(fileName),
|
|
243
261
|
findMeCode: `oc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
244
|
-
|
|
245
|
-
attachments: [{ url, name: fileName }],
|
|
262
|
+
mediaIds: [mediaId],
|
|
246
263
|
};
|
|
247
|
-
await this.
|
|
264
|
+
const res = await this._socketEmit("message:send", payload, 30000);
|
|
265
|
+
if (res && res.code) {
|
|
266
|
+
console.error("Kazee message:send error:", res.code, res.message);
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
248
269
|
return true;
|
|
249
270
|
} catch (e) {
|
|
250
271
|
console.error("Kazee sendFile error:", e.message);
|
|
@@ -252,6 +273,30 @@ class KazeeAdapter {
|
|
|
252
273
|
}
|
|
253
274
|
}
|
|
254
275
|
|
|
276
|
+
// Promisified ack-style socket emit. chat-central v2 handlers respond
|
|
277
|
+
// either with a success body or an { code, message, action } error.
|
|
278
|
+
_socketEmit(event, payload, timeoutMs = 15000) {
|
|
279
|
+
return new Promise((resolve, reject) => {
|
|
280
|
+
const socket = this._socket;
|
|
281
|
+
if (!socket || !socket.connected) {
|
|
282
|
+
reject(new Error(`Kazee socket not connected for ${event}`));
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
let settled = false;
|
|
286
|
+
const timer = setTimeout(() => {
|
|
287
|
+
if (settled) return;
|
|
288
|
+
settled = true;
|
|
289
|
+
reject(new Error(`Kazee ${event} ack timeout`));
|
|
290
|
+
}, timeoutMs);
|
|
291
|
+
socket.emit(event, payload, (ack) => {
|
|
292
|
+
if (settled) return;
|
|
293
|
+
settled = true;
|
|
294
|
+
clearTimeout(timer);
|
|
295
|
+
resolve(ack);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
255
300
|
_kazeeFileType(fileName) {
|
|
256
301
|
const ext = path.extname(fileName).toLowerCase();
|
|
257
302
|
if ([".jpg", ".jpeg", ".png", ".gif", ".webp"].includes(ext)) return "image";
|
package/package.json
CHANGED