limixbot 0.3.85 → 0.3.86
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/assets/{ActivityPanel-CY3DMVp-.js → ActivityPanel-C0N31D_v.js} +1 -1
- package/dist/assets/{App-DI8W0_B1.js → App-BDTHNRl7.js} +11 -11
- package/dist/assets/{AppEventEditor-C9Qgmcqo.js → AppEventEditor-wbd7oe4q.js} +1 -1
- package/dist/assets/{BotSettingsDialog-N3rwg9CM.js → BotSettingsDialog-BiEfrj2H.js} +1 -1
- package/dist/assets/{BrowserPanel-C9z6ln50.js → BrowserPanel-Do9iNIyw.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-DElUoXDu.js → BrowserProfilesManager-BiBqKZwC.js} +1 -1
- package/dist/assets/{CloudAddDialog-CRpjAGCj.js → CloudAddDialog-CKmTgchu.js} +1 -1
- package/dist/assets/{ComputerFilesPane-BDJLywsp.js → ComputerFilesPane-DtCLL7ZP.js} +1 -1
- package/dist/assets/{ComputerPanel-Duwmvh1w.js → ComputerPanel-BNs-QIR7.js} +2 -2
- package/dist/assets/{DataPanel-B3lK9PV5.js → DataPanel-BlXwlic5.js} +1 -1
- package/dist/assets/{DesktopViewer-DucsZp1P.js → DesktopViewer-Djph1nIH.js} +1 -1
- package/dist/assets/{FilesView-DxB66Gnb.js → FilesView-BbU1wdOU.js} +1 -1
- package/dist/assets/{GrokMoveDialog-k_oT2YNk.js → GrokMoveDialog-B3X4Xnep.js} +1 -1
- package/dist/assets/{InspectorPanel-CO62b8Q8.js → InspectorPanel-35qhRYgv.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-DhkUasuz.js → KeyboardShortcutsModal-DN69HH_b.js} +1 -1
- package/dist/assets/{LiveDesktop-DYWwUKmp.js → LiveDesktop-BTnWrZwb.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-B4zzvT6u.js → LocalVmWorkspace-C5UYCDDh.js} +1 -1
- package/dist/assets/{MacLocalControl-WEcE5FU_.js → MacLocalControl-C3BZAwAB.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-CTQI00z9.js → MarkdownFilePreview-CeleU4l2.js} +1 -1
- package/dist/assets/{MenuMotion-Cl1BSA8W.js → MenuMotion-DXmV1A0P.js} +1 -1
- package/dist/assets/{NewBotDialog-DlwcOejs.js → NewBotDialog-CjGoCysC.js} +1 -1
- package/dist/assets/{PhoneAppDialog-B1_HpF1k.js → PhoneAppDialog-B2Q41-1w.js} +1 -1
- package/dist/assets/{PlacesRail-CAIFKxcp.js → PlacesRail-CVOnEMR5.js} +1 -1
- package/dist/assets/{PluginsPanel--rjuQ0H6.js → PluginsPanel-6cmDsRRD.js} +1 -1
- package/dist/assets/{ProIntroduction-CdOsoSZM.js → ProIntroduction-DPlttMD9.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-Csolmca6.js → RemoteAgentSettingsPanel-DUXcAxB1.js} +1 -1
- package/dist/assets/{RoomPanel-BaFLHtNj.js → RoomPanel-B8g5zZCP.js} +1 -1
- package/dist/assets/{RoutinesPage-iMqTJGOf.js → RoutinesPage-CGjiBIPJ.js} +1 -1
- package/dist/assets/{SettingsModal-BtDWTzKq.js → SettingsModal-BmV8D1Iq.js} +1 -1
- package/dist/assets/{ShareTeamDialog-DtbT-j7j.js → ShareTeamDialog-B9zzS5Yd.js} +1 -1
- package/dist/assets/{SignedInSites-Dbs3HG-Q.js → SignedInSites-xGMVYJdT.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-DQlHm6J-.js → TeamLibraryPanel-1Rqfrp9b.js} +1 -1
- package/dist/assets/{TeamMapPage-kr5Oy3kJ.js → TeamMapPage-Dub1Xv-5.js} +1 -1
- package/dist/assets/{TriggersPage-EdBOOViK.js → TriggersPage-BtK1XNiN.js} +1 -1
- package/dist/assets/{VisibilitySection-D7kyfsMI.js → VisibilitySection-D1UPuFkz.js} +1 -1
- package/dist/assets/{WebhookTrigger-CjsooYKr.js → WebhookTrigger-IRadfxLj.js} +1 -1
- package/dist/assets/{WorksOnGrid-C-09lH3E.js → WorksOnGrid-CT4zH_WK.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-DQc35yUD.js → abnfDiagram-YUKMZFIV-Be9BN_xa.js} +1 -1
- package/dist/assets/{activity-Dg618nNT.js → activity-BwMrqPLx.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-BWLmVb0p.js → architectureDiagram-47P4ROYG-C67U_9yb.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-D8Lymdty.js → blockDiagram-E7TT5TSB-WmA-_q1P.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-CqBonRGR.js → c4Diagram-CRA5TL53-BMDuqS9x.js} +1 -1
- package/dist/assets/{calendar-days-27drhnjb.js → calendar-days-CUQrlbLv.js} +1 -1
- package/dist/assets/channel-DIo-ZJ19.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-ChgEJxQ5.js → chunk-2Q5K7J3B-vJwrxPLO.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-DfPS9PdA.js → chunk-5VM5RSS4-DRCV5Bne.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-DkiHHZ8j.js → chunk-7TKQ45FW-1il9v5VM.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-DRfAiJSk.js → chunk-AW2ZBBNX-DcPxLj1j.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-CdfnnJAQ.js → chunk-FVRAUYC3-x3Mdw8qs.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-Dnh0-Y52.js → chunk-HTAEGDNF-D9lRVC8e.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-8lxnA6bi.js → chunk-JWPE2WC7-BraJp1-J.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-BIzq4Y-p.js → chunk-KQW6MTUR-DuINW02F.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-DRs7oDfQ.js → chunk-XXDRQBXY-BtHHbi20.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-RBLGePAK.js → classDiagram-v2-K4WV4PDN-Clr8IMyl.js} +1 -1
- package/dist/assets/{coins-C03ikkSY.js → coins-C_lWvLvT.js} +1 -1
- package/dist/assets/{core-5NPWYsa0.js → core-lc8-4wg5.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BUzR1SjN.js → cose-bilkent-JH36ORCC-CIukmiZL.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-CkfAwvzQ.js → cynefin-EF2NZ3EQ-C-vrc30o.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-yivOd-Z-.js → cynefinDiagram-3GCD6N5R-PkdFrHke.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-DhYpXfrc.js → dagre-W4DXFKR2-Cy5Jkb7s.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-BinJfjKp.js → diagram-2UJZ2QOL-DGKa5cO5.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-CCfBmpAm.js → diagram-OVF4WLC6-CaillioZ.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-CGA_sfaF.js → diagram-PFPMY2P6-Bu6g4AZX.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-DJAerOP7.js → diagram-UMYRVEAY-C2orLKNL.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-DPtRam5_.js → diagram-YEKJPTXX-CMeHTJdB.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-Bf_aLf0C.js → diagram-ZIFT7M5P-qWxpdmSS.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-Cv84sRvv.js → ebnfDiagram-VR2GEFS7-BQX2zEHg.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-CvR8VpdS.js → elk-IJKZMXRS-CYhbWg-4.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-CBcxNnSV.js → erDiagram-O2IAPWRE-Cqqb5bGQ.js} +1 -1
- package/dist/assets/{file-up-BCABGJwK.js → file-up-nJUmIjDH.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-CilpbI81.js → flowDiagram-OXPTDLAJ-BBq3XUB5.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-BKGrXVBk.js → ganttDiagram-R7TSEDQI-D25MX6zY.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-156g_l6W.js → gitGraphDiagram-XJZIOB7I-ou5ncO3K.js} +1 -1
- package/dist/assets/{import-name-D5boWNNJ.js → import-name-B3gGTeai.js} +1 -1
- package/dist/assets/{index-Bpm_5xjV.js → index-CVgqqlDu.js} +3 -3
- package/dist/assets/{index-EzRA1IPJ.js → index-DpciIGCi.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-Dl2TtZUV.js → infoDiagram-5W2HQ5XZ-Cahu-oQL.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-DNL9hgrO.js → ishikawaDiagram-K3B6WC7H-xMLRE4L4.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-Crken5SK.js → journeyDiagram-COXZFDF6-BwnTEAYv.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-CF0XCeak.js → kanban-definition-P3RFRI5V-BZaJ1rD6.js} +1 -1
- package/dist/assets/{mcp-servers-fxhSbAs2.js → mcp-servers-Db2ktl_X.js} +1 -1
- package/dist/assets/{mermaid.core-D6KTFPnQ.js → mermaid.core-DBvGiCxh.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-D8slW4Bp.js → mindmap-definition-LZFPQGKD-Bsu5sUld.js} +1 -1
- package/dist/assets/{minimize-Z4D-5y66.js → minimize-BXym8B0g.js} +1 -1
- package/dist/assets/{monitor-B1CfPgTM.js → monitor-C-PvtRc4.js} +1 -1
- package/dist/assets/{new-bot-DqeQOWb_.js → new-bot-J_GHcWiv.js} +1 -1
- package/dist/assets/{org-library-B3JevYPk.js → org-library-CMG3lV4U.js} +1 -1
- package/dist/assets/{package-format-DeLYSyIb.js → package-format-Brxt3-jh.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-CFUn9jSb.js → pegDiagram-BGZESJAR-HNSF_tvB.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-CTiSsNhc.js → pieDiagram-CAPJLFHJ-CBatNjVS.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-C0Jkn5WF.js → quadrantDiagram-GDMTTRAM-CvFqYHok.js} +1 -1
- package/dist/assets/{rail-Ccbcb3BL.js → rail-DliYKeDs.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-D_IpHeXW.js → railroadDiagram-SM67HX2B-3d2v_-Mv.js} +1 -1
- package/dist/assets/{remote-desktop-panel-DWLI0Q3h.js → remote-desktop-panel-DvLQHBzD.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-CB21o-IH.js → requirementDiagram-X7JNWC4A-C4Tbnv_e.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-CMw7Vupi.js → sankeyDiagram-UM26HJRW-Q5Hef_p7.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-BkTujesZ.js → sequenceDiagram-ZO4K6R2Y-CKNRbUND.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-m0eF2BDH.js → sizeCapture-INFHLROL-Dx93i-be.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-DWt2k1xB.js → stateDiagram-v2-TBUQTH76-DIaTG0Vg.js} +1 -1
- package/dist/assets/styles-D27-oaxn.css +1 -0
- package/dist/assets/{styles-mQkR4Dk7.js → styles-DC3YSQcr.js} +2 -2
- package/dist/assets/{swimlanes-N4OXWK64-DDKG7xji.js → swimlanes-N4OXWK64-BEj9jVV4.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-B3VhkwE_.js +8 -0
- package/dist/assets/{team-share-BFEeBdTy.js → team-share-BDOQZT8B.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-F-4Q6Pp2.js → timeline-definition-YOQAKGHF-D_NLSsxI.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-IapiCDZW.js → usecaseDiagram-VIAY4XPW-5oEC8l_Q.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-DmmEitR0.js → vennDiagram-BLWOH2XV-5xA577_Z.js} +1 -1
- package/dist/assets/{vi-D7L34hOg.js → vi-M-swYqLe.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-BLk95K7j.js → wardleyDiagram-YMQ3BMBF-DyLjuMue.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-BEmo1yQH.js → xychartDiagram-TAQBALBS-BFGifxIO.js} +1 -1
- package/dist/index.html +18 -4
- package/dist/rail.html +5 -5
- package/dist-server/cloud-home-start.js +4 -3
- package/dist-server/index.js +806 -799
- package/dist-server/package.json +1 -1
- package/dist-server/server/bot-api-host.js +30 -14
- package/dist-server/server/bot-channels/engine.js +17 -4
- package/dist-server/server/bot-channels/zalo-media.js +39 -0
- package/dist-server/server/bot-channels/zalo.js +10 -1
- package/dist-server/server/cloud-computer-tools.js +1 -1
- package/dist-server/server/cloud-home-start.js +1 -0
- package/dist-server/server/plan-usage.js +1 -1
- package/dist-server/shared/provider-icon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/channel-CWZV0evK.js +0 -1
- package/dist/assets/styles-jaNBMg3t.css +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-DfVFf-EU.js +0 -8
package/dist-server/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"0.3.
|
|
1
|
+
{"type":"module","version":"0.3.86"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The Bot API's two sides. Outside: `POST /hooks/api/bots/<id>/messages` on the webhook receiver, a bearer key, a
|
|
2
|
-
// message in, the bot's reply out; the turn it starts is outside work (the "api" trigger), so it never acts for the
|
|
3
|
-
// person, is told the message came from outside, and anything that needs an approval waits for the person in the thread.
|
|
4
|
-
// Inside: the app's routes to switch it on, mint a key and switch it off, open only to whoever may edit the bot.
|
|
5
1
|
import { z } from "zod";
|
|
6
2
|
import { redactSecretsInText } from "../shared/redact.js";
|
|
7
3
|
import { BOT_API_UPGRADE, botApiEndpoint } from "../shared/bot-api.js";
|
|
@@ -68,6 +64,13 @@ function replyText(lines) {
|
|
|
68
64
|
return "";
|
|
69
65
|
return redactSecretsInText(picked.map((line) => line.text.trim()).join("\n\n"));
|
|
70
66
|
}
|
|
67
|
+
function messagesAfter(lines, id) {
|
|
68
|
+
const start = lines.findIndex(line => line.id === id);
|
|
69
|
+
if (start < 0)
|
|
70
|
+
return [];
|
|
71
|
+
const end = lines.findIndex((line, index) => index > start && line.role === "user");
|
|
72
|
+
return lines.slice(start + 1, end < 0 ? undefined : end);
|
|
73
|
+
}
|
|
71
74
|
export function createBotApiHost(deps) {
|
|
72
75
|
const manager = deps.manager ?? new BotApiManager();
|
|
73
76
|
const waitMs = deps.waitMs ?? BOT_API_DEFAULT_WAIT_MS;
|
|
@@ -108,7 +111,17 @@ export function createBotApiHost(deps) {
|
|
|
108
111
|
return { thread: threadId, status: "working" };
|
|
109
112
|
return { reply: replyText(after), thread: threadId };
|
|
110
113
|
}
|
|
111
|
-
|
|
114
|
+
function mediaPrompt(text, file) {
|
|
115
|
+
if (!file)
|
|
116
|
+
return text;
|
|
117
|
+
const path = file.path.replaceAll("&", "&").replaceAll('"', """);
|
|
118
|
+
return text + '\n\n<attached-' + file.kind + ' path="' + path + '" />';
|
|
119
|
+
}
|
|
120
|
+
function replyMedia(lines) {
|
|
121
|
+
const reply = lines.findLast(line => line.role === "bot" && line.kind === "text");
|
|
122
|
+
return reply?.attachments?.filter((file) => (file.kind === "image" && !file.fromTool) || (file.kind === "file" && file.mime === "video/mp4")) ?? [];
|
|
123
|
+
}
|
|
124
|
+
async function runCall(botId, call, turnStarted, channel) {
|
|
112
125
|
const store = deps.store;
|
|
113
126
|
let threadId = call.thread;
|
|
114
127
|
if (threadId !== undefined) {
|
|
@@ -135,13 +148,13 @@ export function createBotApiHost(deps) {
|
|
|
135
148
|
store.patchTask(botId, threadId, { botApi: true, outside: true });
|
|
136
149
|
}
|
|
137
150
|
const receivedAt = Date.now();
|
|
138
|
-
const userMessage = store.appendMessage(threadId, { role: "user", kind: "text", text: message, via: "api" });
|
|
139
|
-
const after = () =>
|
|
151
|
+
const userMessage = store.appendMessage(threadId, { role: "user", kind: "text", text: message, via: "api", ...(channel?.attachment ? { attachments: [channel.attachment] } : {}) });
|
|
152
|
+
const after = () => messagesAfter(store.messagesFor(threadId), userMessage.id);
|
|
140
153
|
let settled;
|
|
141
154
|
let dispatchError;
|
|
142
155
|
markRunning(botId, threadId, true);
|
|
143
156
|
try {
|
|
144
|
-
await deps.startTurn(botId, botApiPrompt(message, receivedAt), {
|
|
157
|
+
await deps.startTurn(botId, mediaPrompt(botApiPrompt(message, receivedAt), channel?.attachment), {
|
|
145
158
|
threadId, automationSource: "api", unattended: true, userMessage,
|
|
146
159
|
onSettled: (outcome) => { settled = outcome; markRunning(botId, threadId, false); },
|
|
147
160
|
onDispatchError: (message) => { dispatchError = message; markRunning(botId, threadId, false); },
|
|
@@ -171,6 +184,7 @@ export function createBotApiHost(deps) {
|
|
|
171
184
|
return { status: 202, body: { thread: threadId, status: "needs_approval" } };
|
|
172
185
|
if (!settled.ok)
|
|
173
186
|
fail(502, COULD_NOT_ANSWER, settled.text);
|
|
187
|
+
channel?.collect(replyMedia(after()));
|
|
174
188
|
return { status: 200, body: { reply: replyText(after()), thread: threadId } };
|
|
175
189
|
}
|
|
176
190
|
/** Limix: a message from a chat channel this server itself reads (server/bot-channels), never from an outside caller. The
|
|
@@ -181,9 +195,10 @@ export function createBotApiHost(deps) {
|
|
|
181
195
|
if (!input.owner) {
|
|
182
196
|
if (!deps.canConfine(botId))
|
|
183
197
|
fail(403, CANNOT_CONFINE);
|
|
184
|
-
|
|
198
|
+
let attachments = [];
|
|
199
|
+
const answer = await runCall(botId, { message: input.text, ...(input.threadId ? { thread: input.threadId } : {}), wait: Math.round((input.waitMs ?? 600_000) / 1000) }, () => { }, { attachment: input.attachment, collect(files) { attachments = files; } });
|
|
185
200
|
const body = answer.body;
|
|
186
|
-
return { threadId: body.thread, reply: body.reply ?? "", ...(body.status ? { status: body.status } : {}) };
|
|
201
|
+
return { threadId: body.thread, ...(attachments.length ? { attachments } : {}), reply: body.reply ?? "", ...(body.status ? { status: body.status } : {}) };
|
|
187
202
|
}
|
|
188
203
|
let threadId = input.threadId;
|
|
189
204
|
const known = threadId ? store.taskByThread(botId, threadId) : undefined;
|
|
@@ -199,13 +214,13 @@ export function createBotApiHost(deps) {
|
|
|
199
214
|
fail(404, "no such bot");
|
|
200
215
|
threadId = task.threadId;
|
|
201
216
|
}
|
|
202
|
-
const userMessage = store.appendMessage(threadId, { role: "user", kind: "text", text: input.text });
|
|
203
|
-
const after = () =>
|
|
217
|
+
const userMessage = store.appendMessage(threadId, { role: "user", kind: "text", text: input.text, ...(input.attachment ? { attachments: [input.attachment] } : {}) });
|
|
218
|
+
const after = () => messagesAfter(store.messagesFor(threadId), userMessage.id);
|
|
204
219
|
let settled;
|
|
205
220
|
let dispatchError;
|
|
206
221
|
markRunning(botId, threadId, true);
|
|
207
222
|
try {
|
|
208
|
-
await deps.startTurn(botId, input.text, {
|
|
223
|
+
await deps.startTurn(botId, mediaPrompt(input.text, input.attachment), {
|
|
209
224
|
threadId, unattended: true, userMessage,
|
|
210
225
|
onSettled: (outcome) => { settled = outcome; markRunning(botId, threadId, false); },
|
|
211
226
|
onDispatchError: (message) => { dispatchError = message; markRunning(botId, threadId, false); },
|
|
@@ -229,7 +244,8 @@ export function createBotApiHost(deps) {
|
|
|
229
244
|
}
|
|
230
245
|
if (!settled.ok)
|
|
231
246
|
fail(502, COULD_NOT_ANSWER, settled.text);
|
|
232
|
-
|
|
247
|
+
const attachments = replyMedia(after());
|
|
248
|
+
return { threadId, reply: replyText(after()), ...(attachments.length ? { attachments } : {}) };
|
|
233
249
|
}
|
|
234
250
|
const door = async (req, res, url) => {
|
|
235
251
|
const match = PUBLIC_PATH.exec(url.pathname);
|
|
@@ -192,7 +192,7 @@ export function createBotChannels(deps) {
|
|
|
192
192
|
if (!entry)
|
|
193
193
|
return;
|
|
194
194
|
const send = (body) => reply(adapter, botId, session, message.chatId, body);
|
|
195
|
-
const command = /^\/(\w+)(?:@\w+)?(?:\s+(.*))?$/s.exec(message.text.trim());
|
|
195
|
+
const command = message.media ? null : /^\/(\w+)(?:@\w+)?(?:\s+(.*))?$/s.exec(message.text.trim());
|
|
196
196
|
if (command?.[1] === "start" && !command[2])
|
|
197
197
|
return void await send(say.start);
|
|
198
198
|
if (command?.[1] === "link") {
|
|
@@ -215,17 +215,30 @@ export function createBotChannels(deps) {
|
|
|
215
215
|
patch(kind, botId, (current) => { const chats = { ...current.chats }; delete chats[conversation]; return { ...current, chats }; });
|
|
216
216
|
return void await send(say.fresh);
|
|
217
217
|
}
|
|
218
|
-
if (!message.text.trim())
|
|
218
|
+
if (!message.text.trim() && !message.loadMedia)
|
|
219
219
|
return void await send(say.textOnly);
|
|
220
220
|
const pulse = () => void session.typing?.(message.chatId).catch(() => { });
|
|
221
221
|
pulse();
|
|
222
222
|
const typing = setInterval(pulse, 4_000);
|
|
223
223
|
try {
|
|
224
224
|
const known = read(kind).bots[botId]?.chats[conversation];
|
|
225
|
-
|
|
225
|
+
let attachment;
|
|
226
|
+
try {
|
|
227
|
+
attachment = await message.loadMedia?.();
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return void await send("Bot chưa đọc được tệp này. Bạn hãy gửi lại ảnh JPG, PNG, WebP (tối đa 10 MB) hoặc video MP4 (tối đa 32 MB).");
|
|
231
|
+
}
|
|
232
|
+
const answer = await deps.ask(botId, { text: message.text || (attachment?.kind === "image" ? "Ảnh gửi qua Zalo" : "Video gửi qua Zalo"), ...(attachment ? { attachment } : {}), ...(known ? { threadId: known } : {}), title: `${adapter.label} · ${message.from.name}`, owner });
|
|
226
233
|
patch(kind, botId, (current) => ({ ...current, chats: { ...current.chats, [conversation]: answer.threadId } }));
|
|
227
234
|
clearInterval(typing);
|
|
228
|
-
|
|
235
|
+
const sendMedia = session.sendMedia;
|
|
236
|
+
const media = sendMedia ? answer.attachments ?? [] : [];
|
|
237
|
+
if (sendMedia)
|
|
238
|
+
for (const file of media)
|
|
239
|
+
await paced(adapter, botId, () => sendMedia(message.chatId, file));
|
|
240
|
+
if (answer.reply.trim() || !media.length)
|
|
241
|
+
await send(answer.reply.trim() || (answer.status === "needs_approval" ? say.approval : answer.status === "working" ? say.working : say.empty));
|
|
229
242
|
}
|
|
230
243
|
catch (error) {
|
|
231
244
|
log(`${kind}: ${failure(error)}`);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Readable } from "node:stream";
|
|
2
|
+
import { basename, dirname } from "node:path";
|
|
3
|
+
import { lstat, readFile } from "node:fs/promises";
|
|
4
|
+
import { imageDimensions } from "../../shared/provider-icon.js";
|
|
5
|
+
import { ATTACHMENTS_DIR, IMAGE_MAX_BYTES, saveFile, saveImage } from "../attachments.js";
|
|
6
|
+
import { fetchPublicPage } from "../wait-probes.js";
|
|
7
|
+
const VIDEO_LIMIT = 32 * 1024 * 1024;
|
|
8
|
+
export async function receiveZaloMedia(url, photo) {
|
|
9
|
+
const limit = photo ? IMAGE_MAX_BYTES : VIDEO_LIMIT;
|
|
10
|
+
const target = new URL(url);
|
|
11
|
+
if (target.protocol !== "https:" || !/(^|\.)(zaloapp\.com|zalo\.me|zdn\.vn|zadn\.vn|zalo\.vn)$/.test(target.hostname))
|
|
12
|
+
throw Error("Unsupported Zalo media address");
|
|
13
|
+
const page = await fetchPublicPage(url, { maxBytes: limit + 1, timeoutMs: 30000, maxRedirects: 0 });
|
|
14
|
+
if (!page.ok || !page.body.length || page.body.length > limit)
|
|
15
|
+
throw Error("Zalo media unavailable");
|
|
16
|
+
if (photo) {
|
|
17
|
+
const mime = ["image/jpeg", "image/png", "image/webp"].find(type => imageDimensions(page.body, type));
|
|
18
|
+
if (!mime)
|
|
19
|
+
throw Error("Unsupported image");
|
|
20
|
+
const { path } = saveImage(page.body, mime);
|
|
21
|
+
return { kind: "image", path, mime };
|
|
22
|
+
}
|
|
23
|
+
if (page.body.toString("ascii", 4, 8) !== "ftyp")
|
|
24
|
+
throw Error("Unsupported video");
|
|
25
|
+
const file = await saveFile(Readable.from([page.body]), "video.mp4", "video/mp4", { expectedBytes: page.body.length });
|
|
26
|
+
return { kind: "file", path: file.path, name: file.name, mime: file.mime };
|
|
27
|
+
}
|
|
28
|
+
export async function zaloUpload(file) {
|
|
29
|
+
if (dirname(file.path) !== ATTACHMENTS_DIR || !/^[0-9a-f-]{36}\.(jpg|png|webp|mp4)$/.test(basename(file.path)))
|
|
30
|
+
throw Error("Unsupported attachment");
|
|
31
|
+
const stat = await lstat(file.path);
|
|
32
|
+
if (!stat.isFile() || stat.size > (file.kind === "image" ? IMAGE_MAX_BYTES : VIDEO_LIMIT))
|
|
33
|
+
throw Error("Attachment unavailable");
|
|
34
|
+
const data = await readFile(file.path);
|
|
35
|
+
const dimensions = file.kind === "image" ? imageDimensions(data, file.mime) : undefined;
|
|
36
|
+
if (file.kind === "image" && !dimensions)
|
|
37
|
+
throw Error("Unsupported image");
|
|
38
|
+
return { data, filename: basename(file.path), metadata: { ...dimensions, totalSize: data.length } };
|
|
39
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// scanning a QR code, and the session cookies are what this server keeps, sealed. Zalo allows one web session per account,
|
|
3
3
|
// so opening Zalo Web elsewhere ends this one (close code 3000).
|
|
4
4
|
import { ChannelError } from "./engine.js";
|
|
5
|
+
import { receiveZaloMedia, zaloUpload } from "./zalo-media.js";
|
|
5
6
|
const USER = 0, GROUP = 1;
|
|
6
7
|
const loadZcaJs = async () => {
|
|
7
8
|
const { Zalo } = (await import("zca-js"));
|
|
@@ -59,11 +60,15 @@ export function zaloAdapter(load = loadZcaJs) {
|
|
|
59
60
|
if (!direct && !tag)
|
|
60
61
|
return;
|
|
61
62
|
const content = event.data.content;
|
|
63
|
+
const data = content && typeof content === "object" ? content : {};
|
|
64
|
+
const photo = event.data.msgType === "chat.photo";
|
|
65
|
+
const attachmentUrl = (photo || event.data.msgType === "chat.video.msg") && typeof data.href === "string" ? data.href : undefined;
|
|
62
66
|
const said = typeof content !== "string" ? "" : tag && !direct ? content.slice(0, tag.pos) + content.slice(tag.pos + tag.len) : content;
|
|
63
67
|
const message = {
|
|
64
68
|
id: String(event.data.msgId), chatId: `${direct ? "u" : "g"}:${event.threadId}`, direct,
|
|
65
69
|
from: { id: String(event.data.uidFrom), name: event.data.dName || String(event.data.uidFrom) },
|
|
66
|
-
text: said.trim(),
|
|
70
|
+
text: said.trim() || (attachmentUrl && typeof data.title === "string" ? data.title : ""),
|
|
71
|
+
...(attachmentUrl ? { loadMedia: () => receiveZaloMedia(attachmentUrl, photo) } : {}),
|
|
67
72
|
...(typeof content === "string" ? {} : { media: true }),
|
|
68
73
|
};
|
|
69
74
|
io.deliver(message);
|
|
@@ -76,6 +81,10 @@ export function zaloAdapter(load = loadZcaJs) {
|
|
|
76
81
|
const target = thread(chatId);
|
|
77
82
|
await api.sendMessage({ msg: text }, target.id, target.type).catch((error) => { throw new ChannelError("retry", `Zalo: ${error instanceof Error ? error.message : String(error)}`); });
|
|
78
83
|
},
|
|
84
|
+
sendMedia: async (chatId, file) => {
|
|
85
|
+
const target = thread(chatId);
|
|
86
|
+
await api.sendMessage({ msg: "", attachments: await zaloUpload(file) }, target.id, target.type);
|
|
87
|
+
},
|
|
79
88
|
typing: async (chatId) => { const target = thread(chatId); await api.sendTypingEvent(target.id, target.type); },
|
|
80
89
|
};
|
|
81
90
|
},
|
|
@@ -94,7 +94,7 @@ export async function runCloudComputerTool(cfg, boxId, name, args, signal, folde
|
|
|
94
94
|
command = `${mouse} mousedown 1 mousemove --sync ${a.to_x} ${a.to_y} mouseup 1`;
|
|
95
95
|
break;
|
|
96
96
|
case "type_text":
|
|
97
|
-
command = `printf %s ${quote(Buffer.from(String(a.text)).toString("base64"))} | base64 -d | xclip -selection clipboard && xdotool key --clearmodifiers ctrl+v`;
|
|
97
|
+
command = `printf %s ${quote(Buffer.from(String(a.text)).toString("base64"))} | base64 -d | xclip -selection clipboard >/dev/null 2>&1 && xdotool key --clearmodifiers ctrl+v`;
|
|
98
98
|
break;
|
|
99
99
|
case "key_press":
|
|
100
100
|
command = `xdotool key --clearmodifiers ${quote(String(a.key))}`;
|
|
@@ -236,6 +236,7 @@ export function cloudHomeChildEnvironments(config, env, home) {
|
|
|
236
236
|
PATH: env.PATH ?? "/usr/local/bin:/usr/bin:/bin", HOME: "/tmp/omb-edge",
|
|
237
237
|
XDG_DATA_HOME: "/tmp/omb-edge/data", XDG_CONFIG_HOME: "/tmp/omb-edge/config",
|
|
238
238
|
OMB_CLOUD_PUBLIC_HOST: cloudHomeHost(config),
|
|
239
|
+
...(env.OMB_LIMIX_DESKTOP_STREAM === "desktop:7001" ? { OMB_LIMIX_DESKTOP_STREAM: "desktop:7001" } : {}),
|
|
239
240
|
// A plan whose home sleeps: requests wait this long for the server while it starts (deploy/fly/Caddyfile). Unset: 0s.
|
|
240
241
|
OMB_CLOUD_EDGE_HOLD: edgeHold(env.OMB_CLOUD_EDGE_HOLD),
|
|
241
242
|
...edgeClientAddress(env),
|
|
@@ -56,7 +56,7 @@ export function planAccountsFromInstances(instances) {
|
|
|
56
56
|
environment: { ...entry.environment },
|
|
57
57
|
...(configDir ? { configDir } : {}),
|
|
58
58
|
// Reading ~/.codex/auth.json for a ChatGPT-plan provider would report (and hold it on) another account's limit.
|
|
59
|
-
...(config?.authMode === "chatgpt-plan" || (driver === "claude" && config?.usageMeter === false) ? { noUsage: true } : {}),
|
|
59
|
+
...(config?.authMode === "chatgpt-plan" || (driver === "codex" && config?.endpoint) || (driver === "claude" && config?.usageMeter === false) ? { noUsage: true } : {}),
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
return accounts;
|
|
@@ -25,7 +25,7 @@ function decodedBase64Bytes(value) {
|
|
|
25
25
|
const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
|
|
26
26
|
return Math.floor(value.length * 3 / 4) - padding;
|
|
27
27
|
}
|
|
28
|
-
function imageDimensions(bytes, mime) {
|
|
28
|
+
export function imageDimensions(bytes, mime) {
|
|
29
29
|
const u16be = (offset) => bytes[offset] * 256 + bytes[offset + 1];
|
|
30
30
|
const u16le = (offset) => bytes[offset] + bytes[offset + 1] * 256;
|
|
31
31
|
const u24le = (offset) => bytes[offset] + bytes[offset + 1] * 256 + bytes[offset + 2] * 65536;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,C as n}from"./mermaid.core-D6KTFPnQ.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|