@workclaw/openclaw-workchat 1.0.0 → 1.0.4
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/README.md +210 -210
- package/index.js +49568 -0
- package/index.ts +19 -19
- package/openclaw.plugin.json +25 -25
- package/package.json +64 -63
- package/src/api/api.ts +260 -260
- package/src/api/types.ts +56 -56
- package/src/auth/accounts.ts +279 -290
- package/src/auth/bind-agent.ts +52 -70
- package/src/auth/login-qr-terminal.ts +16 -16
- package/src/auth/login-qr.ts +477 -475
- package/src/auth/pairing.ts +133 -133
- package/src/channel.ts +282 -282
- package/src/compat.ts +75 -75
- package/src/config/config-schema.ts +29 -29
- package/src/messaging/debug-mode.ts +57 -57
- package/src/messaging/error-notice.ts +30 -30
- package/src/messaging/inbound.ts +174 -174
- package/src/messaging/markdown-filter.ts +361 -361
- package/src/messaging/outbound-hooks.ts +84 -84
- package/src/messaging/process-message.ts +530 -530
- package/src/messaging/send.ts +119 -119
- package/src/messaging/slash-commands.ts +105 -105
- package/src/monitor/monitor.ts +261 -261
- package/src/storage/state-dir.ts +11 -11
- package/src/util/logger.ts +147 -147
- package/src/util/random.ts +9 -9
- package/src/util/redact.ts +39 -39
- package/src/vendor.d.ts +10 -10
package/src/auth/bind-agent.ts
CHANGED
|
@@ -1,70 +1,52 @@
|
|
|
1
|
-
import { logger } from "../util/logger.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// falls back to the account's userId, but writing it keeps parity with the
|
|
54
|
-
// zhixiaotu reference plugin).
|
|
55
|
-
if (userId) {
|
|
56
|
-
try {
|
|
57
|
-
const { registerUserInFrameworkStore } = await import("./pairing.js");
|
|
58
|
-
await registerUserInFrameworkStore({ accountId, userId });
|
|
59
|
-
} catch (err) {
|
|
60
|
-
logger.warn(`bindAgentToAccount: allowFrom registration failed: ${String(err)}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
logger.info(
|
|
65
|
-
`bindAgentToAccount: accountId=${accountId} agentId=${agentId} userId=${userId || "(none)"} (apiKey NOT written — env-injected)`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Alias used by the binding listener path. */
|
|
70
|
-
export const bindAgentToAccountFromBinding = bindAgentToAccount;
|
|
1
|
+
import { logger } from "../util/logger.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Complete the binding on the plugin side.
|
|
5
|
+
*
|
|
6
|
+
* The account payload (agentId/userId) lives exclusively in the plugin's
|
|
7
|
+
* private state dir (`state/openclaw-workchat/accounts/`) — weixin-style. The
|
|
8
|
+
* caller (binding listener / monitor INIT_AGENT handling) persists it via
|
|
9
|
+
* saveWorkChatAccount + registerWorkChatAccountId before calling this.
|
|
10
|
+
*
|
|
11
|
+
* This function only bumps `channelConfigUpdatedAt` in openclaw.json so the
|
|
12
|
+
* gateway reloads config from disk and restarts the channel with the fresh
|
|
13
|
+
* private-dir account data. Writing account entries into
|
|
14
|
+
* channels.openclaw-workchat.accounts here would race the desktop configSync
|
|
15
|
+
* (which rebuilds that field) and orphan the credentials/
|
|
16
|
+
* <account>-allowFrom.json files — the gateway's startup migration treats
|
|
17
|
+
* those as a fatal unresolved state.
|
|
18
|
+
*/
|
|
19
|
+
export async function bindAgentToAccount(
|
|
20
|
+
accountId: string,
|
|
21
|
+
agentId: string,
|
|
22
|
+
userId?: string,
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
// Persist the binding user in the framework allowFrom store so command
|
|
25
|
+
// authorization has an explicit source of truth (the inbound path also
|
|
26
|
+
// falls back to the account's userId, but writing it keeps parity with the
|
|
27
|
+
// zhixiaotu reference plugin).
|
|
28
|
+
if (userId) {
|
|
29
|
+
try {
|
|
30
|
+
const { registerUserInFrameworkStore } = await import("./pairing.js");
|
|
31
|
+
await registerUserInFrameworkStore({ accountId, userId });
|
|
32
|
+
} catch (err) {
|
|
33
|
+
logger.warn(`bindAgentToAccount: allowFrom registration failed: ${String(err)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Trigger the channel hot reload; account data itself stays in the private
|
|
38
|
+
// state dir (already persisted by the caller before this runs).
|
|
39
|
+
try {
|
|
40
|
+
const { triggerWorkChatChannelReload } = await import("./accounts.js");
|
|
41
|
+
await triggerWorkChatChannelReload();
|
|
42
|
+
} catch (err) {
|
|
43
|
+
logger.warn(`bindAgentToAccount: channel reload trigger failed: ${String(err)}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
logger.info(
|
|
47
|
+
`bindAgentToAccount: accountId=${accountId} agentId=${agentId} userId=${userId || "(none)"} (private-dir only; apiKey NOT written — env-injected)`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Alias used by the binding listener path. */
|
|
52
|
+
export const bindAgentToAccountFromBinding = bindAgentToAccount;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Terminal QR display for the CLI `openclaw channels login` flow.
|
|
3
|
-
* Mirrors the weixin plugin's displayQRCode: render with qrcode-terminal when
|
|
4
|
-
* available, always fall back to printing the raw link.
|
|
5
|
-
*/
|
|
6
|
-
export async function displayQRCode(qrcodeUrl: string): Promise<void> {
|
|
7
|
-
try {
|
|
8
|
-
const qrterm = await import("qrcode-terminal");
|
|
9
|
-
qrterm.default.generate(qrcodeUrl, { small: true });
|
|
10
|
-
process.stdout.write(`若二维码未能显示或无法使用,你可以访问以下链接以继续:\n`);
|
|
11
|
-
process.stdout.write(`${qrcodeUrl}\n`);
|
|
12
|
-
} catch {
|
|
13
|
-
process.stdout.write(`若二维码未能显示或无法使用,你可以访问以下链接以继续:\n`);
|
|
14
|
-
process.stdout.write(`${qrcodeUrl}\n`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Terminal QR display for the CLI `openclaw channels login` flow.
|
|
3
|
+
* Mirrors the weixin plugin's displayQRCode: render with qrcode-terminal when
|
|
4
|
+
* available, always fall back to printing the raw link.
|
|
5
|
+
*/
|
|
6
|
+
export async function displayQRCode(qrcodeUrl: string): Promise<void> {
|
|
7
|
+
try {
|
|
8
|
+
const qrterm = await import("qrcode-terminal");
|
|
9
|
+
qrterm.default.generate(qrcodeUrl, { small: true });
|
|
10
|
+
process.stdout.write(`若二维码未能显示或无法使用,你可以访问以下链接以继续:\n`);
|
|
11
|
+
process.stdout.write(`${qrcodeUrl}\n`);
|
|
12
|
+
} catch {
|
|
13
|
+
process.stdout.write(`若二维码未能显示或无法使用,你可以访问以下链接以继续:\n`);
|
|
14
|
+
process.stdout.write(`${qrcodeUrl}\n`);
|
|
15
|
+
}
|
|
16
|
+
}
|