@automagik/omni 2.260317.2 → 2.260320.1
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/index.js +38 -16
- package/dist/resolve.d.ts.map +1 -1
- package/dist/server/index.js +406 -304
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -27774,7 +27774,7 @@ import { fileURLToPath } from "url";
|
|
|
27774
27774
|
// package.json
|
|
27775
27775
|
var package_default = {
|
|
27776
27776
|
name: "@automagik/omni",
|
|
27777
|
-
version: "2.
|
|
27777
|
+
version: "2.260320.1",
|
|
27778
27778
|
description: "LLM-optimized CLI for Omni v2",
|
|
27779
27779
|
type: "module",
|
|
27780
27780
|
bin: {
|
|
@@ -28174,24 +28174,33 @@ async function resolveRecipient(input) {
|
|
|
28174
28174
|
async function resolveMessageId(input, chatId) {
|
|
28175
28175
|
if (UUID_RE.test(input))
|
|
28176
28176
|
return input;
|
|
28177
|
+
const isHex = /^[0-9a-f]{2,}$/i.test(input);
|
|
28177
28178
|
if (!chatId) {
|
|
28178
|
-
if (
|
|
28179
|
+
if (isHex) {
|
|
28179
28180
|
error(`Cannot resolve message ID prefix "${input}" without chat context. Provide full UUID or use --chat <id> option.`);
|
|
28180
28181
|
}
|
|
28181
28182
|
error(`Invalid message ID: "${input}". Must be a valid UUID.`);
|
|
28182
28183
|
}
|
|
28183
|
-
|
|
28184
|
-
|
|
28185
|
-
|
|
28186
|
-
|
|
28187
|
-
|
|
28188
|
-
|
|
28189
|
-
|
|
28190
|
-
|
|
28184
|
+
if (isHex) {
|
|
28185
|
+
let messages = [];
|
|
28186
|
+
try {
|
|
28187
|
+
const client = getClient();
|
|
28188
|
+
messages = await client.chats.getMessages(chatId, { limit: 100 });
|
|
28189
|
+
} catch (err) {
|
|
28190
|
+
warn(`Message search failed for chat "${chatId}": ${String(err)}`);
|
|
28191
|
+
}
|
|
28192
|
+
if (messages.length > 0) {
|
|
28193
|
+
const matches = messages.filter((m) => m.id.toLowerCase().startsWith(input.toLowerCase()));
|
|
28194
|
+
if (matches.length === 1)
|
|
28195
|
+
return matches[0].id;
|
|
28196
|
+
if (matches.length > 1) {
|
|
28197
|
+
const ids = matches.map((m) => ` ${m.id.slice(0, 8)}`).join(`
|
|
28191
28198
|
`);
|
|
28192
|
-
|
|
28199
|
+
error(`Ambiguous ID prefix "${input}" matches ${matches.length} messages:
|
|
28193
28200
|
${ids}`);
|
|
28201
|
+
}
|
|
28194
28202
|
}
|
|
28203
|
+
return input;
|
|
28195
28204
|
}
|
|
28196
28205
|
error(`No message found matching "${input}" in chat ${chatId}`);
|
|
28197
28206
|
}
|
|
@@ -33921,7 +33930,7 @@ function createMessagesCommand() {
|
|
|
33921
33930
|
});
|
|
33922
33931
|
messages.command("edit <messageId>").description("Edit a previously sent message").requiredOption("--instance <id>", "Instance ID").requiredOption("--chat <chatJid>", "Chat JID where the message was sent").requiredOption("--text <text>", "New text content").action(async (messageId, options) => {
|
|
33923
33932
|
try {
|
|
33924
|
-
const resolvedMessageId = await resolveMessageId(messageId);
|
|
33933
|
+
const resolvedMessageId = await resolveMessageId(messageId, options.chat);
|
|
33925
33934
|
const instanceId = await resolveInstanceId(options.instance);
|
|
33926
33935
|
const _cfg = (await Promise.resolve().then(() => (init_config(), exports_config))).loadConfig();
|
|
33927
33936
|
const baseUrl = _cfg.apiUrl ?? "http://localhost:8882";
|
|
@@ -41077,6 +41086,19 @@ async function executeLogAction(config2, context, _deps) {
|
|
|
41077
41086
|
};
|
|
41078
41087
|
}
|
|
41079
41088
|
}
|
|
41089
|
+
function extractMessages(context) {
|
|
41090
|
+
if (context.debounce?.messages && context.debounce.messages.length > 0) {
|
|
41091
|
+
const messages = context.debounce.messages.map((m2) => m2.text).filter((t) => !!t);
|
|
41092
|
+
if (messages.length === 0) {
|
|
41093
|
+
return { error: "no text content found in debounced messages" };
|
|
41094
|
+
}
|
|
41095
|
+
return messages;
|
|
41096
|
+
}
|
|
41097
|
+
const messageContent = context.payload.content ?? context.payload.text ?? "";
|
|
41098
|
+
if (!messageContent)
|
|
41099
|
+
return { error: "message content not found in payload" };
|
|
41100
|
+
return [messageContent];
|
|
41101
|
+
}
|
|
41080
41102
|
function extractAgentCallContext(config2, context) {
|
|
41081
41103
|
const instanceId = config2.providerId ? substituteTemplate(config2.providerId, context) : context.payload.instanceId;
|
|
41082
41104
|
if (!instanceId) {
|
|
@@ -41090,9 +41112,9 @@ function extractAgentCallContext(config2, context) {
|
|
|
41090
41112
|
return { error: "chatId not found in payload" };
|
|
41091
41113
|
if (!senderId)
|
|
41092
41114
|
return { error: "senderId not found in payload" };
|
|
41093
|
-
const
|
|
41094
|
-
if (
|
|
41095
|
-
return
|
|
41115
|
+
const messagesResult = extractMessages(context);
|
|
41116
|
+
if ("error" in messagesResult)
|
|
41117
|
+
return messagesResult;
|
|
41096
41118
|
const agentId = substituteTemplate(config2.agentId, context);
|
|
41097
41119
|
if (!agentId)
|
|
41098
41120
|
return { error: "agentId is required" };
|
|
@@ -41103,7 +41125,7 @@ function extractAgentCallContext(config2, context) {
|
|
|
41103
41125
|
chatId,
|
|
41104
41126
|
senderId,
|
|
41105
41127
|
senderName,
|
|
41106
|
-
messages:
|
|
41128
|
+
messages: messagesResult
|
|
41107
41129
|
}
|
|
41108
41130
|
};
|
|
41109
41131
|
}
|
package/dist/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BtE;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BlE;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MA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