@openclaw/zalouser 2026.5.2-beta.2 → 2026.5.3-beta.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/accounts-C00IMUgd.js +63 -0
- package/dist/accounts.runtime-uG7S8cXT.js +2 -0
- package/dist/api-BRwdUWuS.js +139 -0
- package/dist/api.js +7 -0
- package/dist/channel-ou_w_2j-.js +484 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-C9WxiAiR.js +25 -0
- package/dist/channel.setup-CiDeBFrn.js +10 -0
- package/dist/contract-api.js +3 -0
- package/dist/doctor-contract-DgqHp8E2.js +128 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/index.js +27 -0
- package/dist/monitor-Cg7K_s_s.js +705 -0
- package/dist/runtime-QNU7vLgI.js +106 -0
- package/dist/runtime-api.js +22 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/security-audit-BZLhil-V.js +34 -0
- package/dist/send-BsmySxe3.js +534 -0
- package/dist/session-route-C0-Xr8bt.js +92 -0
- package/dist/setup-core-CqipqY98.js +40 -0
- package/dist/setup-entry.js +11 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/setup-surface-NCOuKu-l.js +359 -0
- package/dist/shared-DSy8aIUx.js +120 -0
- package/dist/test-api.js +5 -0
- package/dist/zalo-js-CHCUlY3c.js +1279 -0
- package/package.json +15 -6
- package/api.ts +0 -9
- package/channel-plugin-api.ts +0 -3
- package/contract-api.ts +0 -2
- package/doctor-contract-api.ts +0 -1
- package/index.ts +0 -34
- package/runtime-api.ts +0 -67
- package/secret-contract-api.ts +0 -4
- package/setup-entry.ts +0 -9
- package/setup-plugin-api.ts +0 -2
- package/src/accounts.runtime.ts +0 -1
- package/src/accounts.test-mocks.ts +0 -14
- package/src/accounts.test.ts +0 -266
- package/src/accounts.ts +0 -131
- package/src/channel-api.ts +0 -20
- package/src/channel.adapters.ts +0 -391
- package/src/channel.directory.test.ts +0 -59
- package/src/channel.runtime.ts +0 -12
- package/src/channel.sendpayload.test.ts +0 -172
- package/src/channel.setup.test.ts +0 -33
- package/src/channel.setup.ts +0 -12
- package/src/channel.test.ts +0 -377
- package/src/channel.ts +0 -219
- package/src/config-schema.ts +0 -33
- package/src/directory.ts +0 -54
- package/src/doctor-contract.ts +0 -156
- package/src/doctor.test.ts +0 -77
- package/src/doctor.ts +0 -37
- package/src/group-policy.test.ts +0 -61
- package/src/group-policy.ts +0 -83
- package/src/message-sid.test.ts +0 -66
- package/src/message-sid.ts +0 -80
- package/src/monitor.account-scope.test.ts +0 -107
- package/src/monitor.group-gating.test.ts +0 -816
- package/src/monitor.send-mocks.ts +0 -20
- package/src/monitor.ts +0 -1044
- package/src/probe.test.ts +0 -60
- package/src/probe.ts +0 -35
- package/src/qr-temp-file.ts +0 -22
- package/src/reaction.test.ts +0 -19
- package/src/reaction.ts +0 -32
- package/src/runtime.ts +0 -9
- package/src/security-audit.test.ts +0 -80
- package/src/security-audit.ts +0 -71
- package/src/send.test.ts +0 -395
- package/src/send.ts +0 -272
- package/src/session-route.ts +0 -121
- package/src/setup-core.ts +0 -33
- package/src/setup-surface.test.ts +0 -363
- package/src/setup-surface.ts +0 -470
- package/src/setup-test-helpers.ts +0 -42
- package/src/shared.ts +0 -92
- package/src/status-issues.test.ts +0 -31
- package/src/status-issues.ts +0 -58
- package/src/test-helpers.ts +0 -26
- package/src/text-styles.test.ts +0 -203
- package/src/text-styles.ts +0 -540
- package/src/tool.test.ts +0 -212
- package/src/tool.ts +0 -210
- package/src/types.ts +0 -125
- package/src/zalo-js.credentials.test.ts +0 -465
- package/src/zalo-js.test-mocks.ts +0 -89
- package/src/zalo-js.ts +0 -1911
- package/src/zca-client.test.ts +0 -24
- package/src/zca-client.ts +0 -259
- package/src/zca-constants.ts +0 -55
- package/src/zca-js-exports.d.ts +0 -22
- package/test-api.ts +0 -21
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DEFAULT_ACCOUNT_ID, createAccountListHelpers, normalizeAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
|
|
2
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
|
3
|
+
//#region extensions/zalouser/src/accounts.ts
|
|
4
|
+
let zalouserAccountsRuntimePromise;
|
|
5
|
+
async function loadZalouserAccountsRuntime() {
|
|
6
|
+
zalouserAccountsRuntimePromise ??= import("./accounts.runtime-uG7S8cXT.js");
|
|
7
|
+
return await zalouserAccountsRuntimePromise;
|
|
8
|
+
}
|
|
9
|
+
const { listAccountIds: listZalouserAccountIds, resolveDefaultAccountId: resolveDefaultZalouserAccountId } = createAccountListHelpers("zalouser");
|
|
10
|
+
function mergeZalouserAccountConfig(cfg, accountId) {
|
|
11
|
+
const merged = resolveMergedAccountConfig({
|
|
12
|
+
channelConfig: cfg.channels?.zalouser,
|
|
13
|
+
accounts: (cfg.channels?.zalouser)?.accounts,
|
|
14
|
+
accountId,
|
|
15
|
+
omitKeys: ["defaultAccount"]
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
...merged,
|
|
19
|
+
groupPolicy: merged.groupPolicy ?? "allowlist"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function resolveProfile(config, accountId) {
|
|
23
|
+
if (config.profile?.trim()) return config.profile.trim();
|
|
24
|
+
if (process.env.ZALOUSER_PROFILE?.trim()) return process.env.ZALOUSER_PROFILE.trim();
|
|
25
|
+
if (process.env.ZCA_PROFILE?.trim()) return process.env.ZCA_PROFILE.trim();
|
|
26
|
+
if (accountId !== DEFAULT_ACCOUNT_ID) return accountId;
|
|
27
|
+
return "default";
|
|
28
|
+
}
|
|
29
|
+
function resolveZalouserAccountBase(params) {
|
|
30
|
+
const accountId = normalizeAccountId(params.accountId ?? resolveDefaultZalouserAccountId(params.cfg));
|
|
31
|
+
const baseEnabled = (params.cfg.channels?.zalouser)?.enabled !== false;
|
|
32
|
+
const merged = mergeZalouserAccountConfig(params.cfg, accountId);
|
|
33
|
+
return {
|
|
34
|
+
accountId,
|
|
35
|
+
enabled: baseEnabled && merged.enabled !== false,
|
|
36
|
+
merged,
|
|
37
|
+
profile: resolveProfile(merged, accountId)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function resolveZalouserAccountSync(params) {
|
|
41
|
+
const { accountId, enabled, merged, profile } = resolveZalouserAccountBase(params);
|
|
42
|
+
return {
|
|
43
|
+
accountId,
|
|
44
|
+
name: normalizeOptionalString(merged.name),
|
|
45
|
+
enabled,
|
|
46
|
+
profile,
|
|
47
|
+
authenticated: false,
|
|
48
|
+
config: merged
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function getZcaUserInfo(profile) {
|
|
52
|
+
const info = await (await loadZalouserAccountsRuntime()).getZaloUserInfo(profile);
|
|
53
|
+
if (!info) return null;
|
|
54
|
+
return {
|
|
55
|
+
userId: info.userId,
|
|
56
|
+
displayName: info.displayName
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function checkZcaAuthenticated(profile) {
|
|
60
|
+
return await (await loadZalouserAccountsRuntime()).checkZaloAuthenticated(profile);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { resolveZalouserAccountSync as a, resolveDefaultZalouserAccountId as i, getZcaUserInfo as n, listZalouserAccountIds as r, checkZcaAuthenticated as t };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import "./setup-surface-NCOuKu-l.js";
|
|
2
|
+
import "./setup-core-CqipqY98.js";
|
|
3
|
+
import { r as parseZalouserOutboundTarget } from "./session-route-C0-Xr8bt.js";
|
|
4
|
+
import "./channel-ou_w_2j-.js";
|
|
5
|
+
import "./security-audit-BZLhil-V.js";
|
|
6
|
+
import { i as listZaloFriendsMatching, n as getZaloUserInfo, s as listZaloGroupsMatching, t as checkZaloAuthenticated } from "./zalo-js-CHCUlY3c.js";
|
|
7
|
+
import "./channel.setup-CiDeBFrn.js";
|
|
8
|
+
import { i as sendMessageZalouser, n as sendImageZalouser, r as sendLinkZalouser } from "./send-BsmySxe3.js";
|
|
9
|
+
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
10
|
+
import { Type } from "typebox";
|
|
11
|
+
//#region extensions/zalouser/src/tool.ts
|
|
12
|
+
const ACTIONS = [
|
|
13
|
+
"send",
|
|
14
|
+
"image",
|
|
15
|
+
"link",
|
|
16
|
+
"friends",
|
|
17
|
+
"groups",
|
|
18
|
+
"me",
|
|
19
|
+
"status"
|
|
20
|
+
];
|
|
21
|
+
function stringEnum(values, options = {}) {
|
|
22
|
+
return Type.Unsafe({
|
|
23
|
+
type: "string",
|
|
24
|
+
enum: [...values],
|
|
25
|
+
...options
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const ZalouserToolSchema = Type.Object({
|
|
29
|
+
action: stringEnum(ACTIONS, { description: `Action to perform: ${ACTIONS.join(", ")}` }),
|
|
30
|
+
threadId: Type.Optional(Type.String({ description: "Thread ID for messaging" })),
|
|
31
|
+
message: Type.Optional(Type.String({ description: "Message text" })),
|
|
32
|
+
isGroup: Type.Optional(Type.Boolean({ description: "Is group chat" })),
|
|
33
|
+
profile: Type.Optional(Type.String({ description: "Profile name" })),
|
|
34
|
+
query: Type.Optional(Type.String({ description: "Search query" })),
|
|
35
|
+
url: Type.Optional(Type.String({ description: "URL for media/link" }))
|
|
36
|
+
}, { additionalProperties: false });
|
|
37
|
+
function json(payload) {
|
|
38
|
+
return {
|
|
39
|
+
content: [{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: JSON.stringify(payload, null, 2)
|
|
42
|
+
}],
|
|
43
|
+
details: payload
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function resolveAmbientZalouserTarget(context) {
|
|
47
|
+
const deliveryContext = context?.deliveryContext;
|
|
48
|
+
const rawTarget = deliveryContext?.to;
|
|
49
|
+
if ((deliveryContext?.channel === void 0 || deliveryContext.channel === "zalouser") && typeof rawTarget === "string" && rawTarget.trim()) try {
|
|
50
|
+
return parseZalouserOutboundTarget(rawTarget);
|
|
51
|
+
} catch {}
|
|
52
|
+
if (deliveryContext?.channel && deliveryContext.channel !== "zalouser") return {};
|
|
53
|
+
const ambientThreadId = deliveryContext?.threadId;
|
|
54
|
+
if (typeof ambientThreadId === "string" && ambientThreadId.trim()) return { threadId: ambientThreadId.trim() };
|
|
55
|
+
if (typeof ambientThreadId === "number" && Number.isFinite(ambientThreadId)) return { threadId: String(ambientThreadId) };
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
function resolveZalouserSendTarget(params, context) {
|
|
59
|
+
const explicitThreadId = typeof params.threadId === "string" ? params.threadId.trim() : "";
|
|
60
|
+
const ambientTarget = resolveAmbientZalouserTarget(context);
|
|
61
|
+
return {
|
|
62
|
+
threadId: explicitThreadId || ambientTarget.threadId,
|
|
63
|
+
isGroup: typeof params.isGroup === "boolean" ? params.isGroup : ambientTarget.isGroup
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async function executeZalouserTool(_toolCallId, params, _signal, _onUpdate, context) {
|
|
67
|
+
try {
|
|
68
|
+
switch (params.action) {
|
|
69
|
+
case "send": {
|
|
70
|
+
const target = resolveZalouserSendTarget(params, context);
|
|
71
|
+
if (!target.threadId || !params.message) throw new Error("threadId and message required for send action");
|
|
72
|
+
const result = await sendMessageZalouser(target.threadId, params.message, {
|
|
73
|
+
profile: params.profile,
|
|
74
|
+
isGroup: target.isGroup
|
|
75
|
+
});
|
|
76
|
+
if (!result.ok) throw new Error(result.error || "Failed to send message");
|
|
77
|
+
return json({
|
|
78
|
+
success: true,
|
|
79
|
+
messageId: result.messageId
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
case "image": {
|
|
83
|
+
const target = resolveZalouserSendTarget(params, context);
|
|
84
|
+
if (!target.threadId) throw new Error("threadId required for image action");
|
|
85
|
+
if (!params.url) throw new Error("url required for image action");
|
|
86
|
+
const result = await sendImageZalouser(target.threadId, params.url, {
|
|
87
|
+
profile: params.profile,
|
|
88
|
+
caption: params.message,
|
|
89
|
+
isGroup: target.isGroup
|
|
90
|
+
});
|
|
91
|
+
if (!result.ok) throw new Error(result.error || "Failed to send image");
|
|
92
|
+
return json({
|
|
93
|
+
success: true,
|
|
94
|
+
messageId: result.messageId
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
case "link": {
|
|
98
|
+
const target = resolveZalouserSendTarget(params, context);
|
|
99
|
+
if (!target.threadId || !params.url) throw new Error("threadId and url required for link action");
|
|
100
|
+
const result = await sendLinkZalouser(target.threadId, params.url, {
|
|
101
|
+
profile: params.profile,
|
|
102
|
+
caption: params.message,
|
|
103
|
+
isGroup: target.isGroup
|
|
104
|
+
});
|
|
105
|
+
if (!result.ok) throw new Error(result.error || "Failed to send link");
|
|
106
|
+
return json({
|
|
107
|
+
success: true,
|
|
108
|
+
messageId: result.messageId
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
case "friends": return json(await listZaloFriendsMatching(params.profile, params.query));
|
|
112
|
+
case "groups": return json(await listZaloGroupsMatching(params.profile, params.query));
|
|
113
|
+
case "me": return json(await getZaloUserInfo(params.profile) ?? { error: "Not authenticated" });
|
|
114
|
+
case "status": {
|
|
115
|
+
const authenticated = await checkZaloAuthenticated(params.profile);
|
|
116
|
+
return json({
|
|
117
|
+
authenticated,
|
|
118
|
+
output: authenticated ? "authenticated" : "not authenticated"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
params.action;
|
|
123
|
+
throw new Error(`Unknown action: ${String(params.action)}. Valid actions: send, image, link, friends, groups, me, status`);
|
|
124
|
+
}
|
|
125
|
+
} catch (err) {
|
|
126
|
+
return json({ error: formatErrorMessage(err) });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function createZalouserTool(context) {
|
|
130
|
+
return {
|
|
131
|
+
name: "zalouser",
|
|
132
|
+
label: "Zalo Personal",
|
|
133
|
+
description: "Send messages and access data via Zalo personal account. Actions: send (text message), image (send image URL), link (send link), friends (list/search friends), groups (list groups), me (profile info), status (auth check).",
|
|
134
|
+
parameters: ZalouserToolSchema,
|
|
135
|
+
execute: async (toolCallId, params, signal, onUpdate) => await executeZalouserTool(toolCallId, params, signal, onUpdate, context)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { createZalouserTool as t };
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { n as zalouserSetupWizard } from "./setup-surface-NCOuKu-l.js";
|
|
2
|
+
import { n as zalouserSetupAdapter, t as createZalouserSetupWizardProxy } from "./setup-core-CqipqY98.js";
|
|
3
|
+
import { t as zalouserPlugin } from "./channel-ou_w_2j-.js";
|
|
4
|
+
import { n as isZalouserMutableGroupEntry, t as collectZalouserSecurityAuditFindings } from "./security-audit-BZLhil-V.js";
|
|
5
|
+
import { t as zalouserSetupPlugin } from "./channel.setup-CiDeBFrn.js";
|
|
6
|
+
import { t as createZalouserTool } from "./api-BRwdUWuS.js";
|
|
7
|
+
export { collectZalouserSecurityAuditFindings, createZalouserSetupWizardProxy, createZalouserTool, isZalouserMutableGroupEntry, zalouserPlugin, zalouserSetupAdapter, zalouserSetupPlugin, zalouserSetupWizard };
|