chrome-openclaw-sider 1.0.2 → 1.0.26
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 +11 -1
- package/README.zh_CN.md +8 -6
- package/dist/index.d.ts +12 -0
- package/{index.ts → dist/index.js} +24 -17
- package/dist/setup-entry.d.ts +18 -0
- package/dist/setup-entry.js +8 -0
- package/dist/src/account.d.ts +54 -0
- package/{src/account.ts → dist/src/account.js} +70 -160
- package/dist/src/auth.d.ts +30 -0
- package/{src/auth.ts → dist/src/auth.js} +61 -128
- package/dist/src/auto-title.d.ts +20 -0
- package/dist/src/auto-title.js +22 -0
- package/dist/src/channel-auto-title.d.ts +23 -0
- package/dist/src/channel-auto-title.js +77 -0
- package/dist/src/channel-builders.d.ts +105 -0
- package/dist/src/channel-builders.js +238 -0
- package/dist/src/channel-hooks.d.ts +30 -0
- package/dist/src/channel-hooks.js +331 -0
- package/dist/src/channel-monitor.d.ts +34 -0
- package/dist/src/channel-monitor.js +341 -0
- package/dist/src/channel-relay.d.ts +117 -0
- package/dist/src/channel-relay.js +573 -0
- package/dist/src/channel-runtime.d.ts +32 -0
- package/dist/src/channel-runtime.js +85 -0
- package/dist/src/channel-send-result.d.ts +19 -0
- package/dist/src/channel-send-result.js +126 -0
- package/dist/src/channel-session-model.d.ts +19 -0
- package/dist/src/channel-session-model.js +244 -0
- package/dist/src/channel-state.d.ts +92 -0
- package/dist/src/channel-state.js +471 -0
- package/dist/src/channel-streaming.d.ts +117 -0
- package/dist/src/channel-streaming.js +645 -0
- package/dist/src/channel-types.d.ts +207 -0
- package/dist/src/channel-types.js +40 -0
- package/dist/src/channel-typing.d.ts +17 -0
- package/dist/src/channel-typing.js +79 -0
- package/dist/src/channel-util.d.ts +78 -0
- package/dist/src/channel-util.js +524 -0
- package/dist/src/channel.d.ts +14 -0
- package/dist/src/channel.js +1023 -0
- package/dist/src/config.d.ts +18 -0
- package/dist/src/config.js +38 -0
- package/dist/src/inbound-media.d.ts +37 -0
- package/{src/inbound-media.ts → dist/src/inbound-media.js} +33 -81
- package/dist/src/media-upload.d.ts +86 -0
- package/dist/src/media-upload.js +1222 -0
- package/dist/src/setup-core.d.ts +72 -0
- package/{src/setup-core.ts → dist/src/setup-core.js} +106 -194
- package/dist/src/user-agent.d.ts +4 -0
- package/dist/src/user-agent.js +6 -0
- package/openclaw.plugin.json +86 -0
- package/package.json +9 -13
- package/setup-entry.ts +0 -6
- package/src/channel.ts +0 -3862
- package/src/config.ts +0 -29
- package/src/media-upload.ts +0 -983
- package/src/remote-browser-support.ts +0 -64
- package/src/user-agent.ts +0 -17
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ npx -y @sider-ai/chrome-openclaw-sider-cli install
|
|
|
14
14
|
```
|
|
15
15
|
================================
|
|
16
16
|
|
|
17
|
+
This convenience command downloads and executes the installer CLI from npm at runtime. If you prefer a more reviewable path, use the manual `openclaw plugins install/update` commands below instead.
|
|
18
|
+
|
|
17
19
|
You can also paste this command into the OpenClaw chat box and ask OpenClaw to install it for you. This will install or update the plugin and automatically start terminal pairing.
|
|
18
20
|
|
|
19
21
|
## 【【【 Manual installation 】】】
|
|
@@ -62,4 +64,12 @@ After entering the pairing code, restart the gateway in Terminal:
|
|
|
62
64
|
```bash
|
|
63
65
|
openclaw gateway restart
|
|
64
66
|
```
|
|
65
|
-
================================
|
|
67
|
+
================================
|
|
68
|
+
|
|
69
|
+
## Data Handling / Security / Privacy
|
|
70
|
+
|
|
71
|
+
- The plugin sends Sider conversation content, assistant replies, streaming events, tool-call status, and uploaded attachments to Sider/selfclaw endpoints so Sider can render and route the chat.
|
|
72
|
+
- Pairing or setup exchanges persist the resulting long-lived `token` into your local OpenClaw config at `~/.openclaw/openclaw.json`.
|
|
73
|
+
- When you send a local attachment, the plugin may read files from OpenClaw media roots in order to upload them to Sider. When Sider sends attachments inbound, the plugin may download and save them into OpenClaw-managed media storage.
|
|
74
|
+
- Install and pair this plugin only if you trust the Sider service and are comfortable with the relevant chat content and attachments being transmitted to it.
|
|
75
|
+
- Runtime environment variables: `SIDER_BASE_URL` overrides the default API base URL, and `SIDER_SETUP_TOKEN` provides a setup-token fallback for the default account.
|
package/README.zh_CN.md
CHANGED
|
@@ -16,6 +16,8 @@ OpenClaw 官方 Sider 渠道插件,用于在 Sider 中连接 OpenClaw。
|
|
|
16
16
|
npx -y @sider-ai/chrome-openclaw-sider-cli install
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
这个便捷命令会在运行时从 npm 下载并执行安装 CLI。若你希望安装过程更可审查,可改用下面的 `openclaw plugins install/update` 手动命令。
|
|
20
|
+
|
|
19
21
|
它会自动安装或更新插件,并立即进入终端配对流程。
|
|
20
22
|
|
|
21
23
|
## 手动安装
|
|
@@ -92,13 +94,13 @@ openclaw channels login --channel chrome-openclaw-sider
|
|
|
92
94
|
openclaw gateway restart
|
|
93
95
|
```
|
|
94
96
|
|
|
95
|
-
##
|
|
97
|
+
## Data handling / Security / Privacy
|
|
96
98
|
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
- `
|
|
99
|
+
- 插件会把 Sider 会话消息、助手回复、流式事件、工具调用状态以及用户发送的附件传到 Sider/selfclaw 接口,用于聊天展示与路由。
|
|
100
|
+
- 配对或 setup token 换取成功后,长期 `token` 会写回本地 OpenClaw 配置文件 `~/.openclaw/openclaw.json`。
|
|
101
|
+
- 当你发送本地附件时,插件可能会读取 OpenClaw media roots 下的文件并上传到 Sider。收到 Sider 发来的附件时,插件也可能会把文件下载到 OpenClaw 管理的媒体存储中。
|
|
102
|
+
- 只有在你信任 Sider 服务,并接受相关聊天内容和附件会被传输到该服务时,才建议安装和配对这个插件。
|
|
103
|
+
- 运行时环境变量:`SIDER_BASE_URL` 可覆盖默认 API base(`https://sider.ai/api/claw/self`),`SIDER_SETUP_TOKEN` 可作为默认账号的 setup token fallback。
|
|
102
104
|
|
|
103
105
|
## 说明
|
|
104
106
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as openclaw_plugin_sdk_plugin_entry from 'openclaw/plugin-sdk/plugin-entry';
|
|
2
|
+
import { OpenClawPluginApi } from 'openclaw/plugin-sdk/plugin-entry';
|
|
3
|
+
|
|
4
|
+
declare const plugin: {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
configSchema: openclaw_plugin_sdk_plugin_entry.OpenClawPluginConfigSchema;
|
|
9
|
+
register(api: OpenClawPluginApi): void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { plugin as default };
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
|
|
2
1
|
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
2
|
import { listSiderAccountIds, readSiderAccountConfig } from "./src/account.js";
|
|
4
3
|
import { createSiderAuthSetupService, setSiderAuthRuntime } from "./src/auth.js";
|
|
5
4
|
import {
|
|
6
5
|
emitSiderToolHookEvent,
|
|
6
|
+
recordSiderAgentEnd,
|
|
7
7
|
recordSiderLlmOutputUsage,
|
|
8
8
|
recordSiderPersistedAgentMessage,
|
|
9
9
|
siderPlugin,
|
|
10
|
-
setSiderRuntime
|
|
10
|
+
setSiderRuntime
|
|
11
11
|
} from "./src/channel.js";
|
|
12
12
|
import { SIDER_PLUGIN_DESCRIPTION, SIDER_PLUGIN_ID, SIDER_PLUGIN_NAME } from "./src/config.js";
|
|
13
|
-
import { registerSiderRemoteBrowserSupport } from "./src/remote-browser-support.js";
|
|
14
|
-
|
|
15
13
|
const plugin = {
|
|
16
14
|
id: SIDER_PLUGIN_ID,
|
|
17
15
|
name: SIDER_PLUGIN_NAME,
|
|
18
16
|
description: SIDER_PLUGIN_DESCRIPTION,
|
|
19
17
|
configSchema: emptyPluginConfigSchema(),
|
|
20
|
-
register(api
|
|
18
|
+
register(api) {
|
|
21
19
|
setSiderRuntime(api.runtime);
|
|
22
20
|
setSiderAuthRuntime(api.runtime);
|
|
23
21
|
api.registerChannel({ plugin: siderPlugin });
|
|
@@ -28,13 +26,12 @@ const plugin = {
|
|
|
28
26
|
const account = readSiderAccountConfig(cfg, accountId);
|
|
29
27
|
return {
|
|
30
28
|
enabled: account.enabled,
|
|
31
|
-
setupToken: account.setupToken?.trim() ||
|
|
32
|
-
token: account.token?.trim() ||
|
|
29
|
+
setupToken: account.setupToken?.trim() || void 0,
|
|
30
|
+
token: account.token?.trim() || void 0
|
|
33
31
|
};
|
|
34
|
-
}
|
|
35
|
-
})
|
|
32
|
+
}
|
|
33
|
+
})
|
|
36
34
|
);
|
|
37
|
-
registerSiderRemoteBrowserSupport(api);
|
|
38
35
|
api.on("before_tool_call", async (event, ctx) => {
|
|
39
36
|
await emitSiderToolHookEvent({
|
|
40
37
|
sessionKey: ctx.sessionKey,
|
|
@@ -42,7 +39,7 @@ const plugin = {
|
|
|
42
39
|
toolName: event.toolName ?? ctx.toolName,
|
|
43
40
|
toolCallId: event.toolCallId ?? ctx.toolCallId,
|
|
44
41
|
runId: event.runId ?? ctx.runId,
|
|
45
|
-
params: event.params
|
|
42
|
+
params: event.params
|
|
46
43
|
});
|
|
47
44
|
});
|
|
48
45
|
api.on("after_tool_call", async (event, ctx) => {
|
|
@@ -55,13 +52,13 @@ const plugin = {
|
|
|
55
52
|
params: event.params,
|
|
56
53
|
result: event.result,
|
|
57
54
|
error: event.error,
|
|
58
|
-
durationMs: event.durationMs
|
|
55
|
+
durationMs: event.durationMs
|
|
59
56
|
});
|
|
60
57
|
});
|
|
61
58
|
api.on("before_message_write", (event, ctx) => {
|
|
62
59
|
recordSiderPersistedAgentMessage({
|
|
63
60
|
sessionKey: ctx.sessionKey,
|
|
64
|
-
message: event.message
|
|
61
|
+
message: event.message
|
|
65
62
|
});
|
|
66
63
|
});
|
|
67
64
|
api.on("llm_output", (event, ctx) => {
|
|
@@ -71,10 +68,20 @@ const plugin = {
|
|
|
71
68
|
provider: event.provider,
|
|
72
69
|
model: event.model,
|
|
73
70
|
usage: event.usage,
|
|
74
|
-
lastAssistant: event.lastAssistant
|
|
71
|
+
lastAssistant: event.lastAssistant
|
|
75
72
|
});
|
|
76
73
|
});
|
|
77
|
-
|
|
74
|
+
api.on("agent_end", (event, ctx) => {
|
|
75
|
+
recordSiderAgentEnd({
|
|
76
|
+
runId: ctx.runId,
|
|
77
|
+
success: event.success,
|
|
78
|
+
error: event.error,
|
|
79
|
+
messages: event.messages
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var index_default = plugin;
|
|
85
|
+
export {
|
|
86
|
+
index_default as default
|
|
78
87
|
};
|
|
79
|
-
|
|
80
|
-
export default plugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as openclaw_plugin_sdk_core from 'openclaw/plugin-sdk/core';
|
|
2
|
+
import { ResolvedSiderAccount } from './src/account.js';
|
|
3
|
+
export { siderPlugin } from './src/channel.js';
|
|
4
|
+
import 'openclaw/plugin-sdk/setup';
|
|
5
|
+
import './src/auth.js';
|
|
6
|
+
import 'openclaw/plugin-sdk';
|
|
7
|
+
import 'openclaw/plugin-sdk/plugin-entry';
|
|
8
|
+
import './src/auto-title.js';
|
|
9
|
+
import './src/channel-runtime.js';
|
|
10
|
+
import 'ws';
|
|
11
|
+
import './src/channel-types.js';
|
|
12
|
+
import './src/channel-hooks.js';
|
|
13
|
+
|
|
14
|
+
declare const _default: {
|
|
15
|
+
plugin: openclaw_plugin_sdk_core.ChannelPlugin<ResolvedSiderAccount>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { _default as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineSetupPluginEntry } from "openclaw/plugin-sdk/core";
|
|
2
|
+
import { siderPlugin } from "./src/channel.js";
|
|
3
|
+
import { siderPlugin as siderPlugin2 } from "./src/channel.js";
|
|
4
|
+
var setup_entry_default = defineSetupPluginEntry(siderPlugin);
|
|
5
|
+
export {
|
|
6
|
+
setup_entry_default as default,
|
|
7
|
+
siderPlugin2 as siderPlugin
|
|
8
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { OpenClawConfig, ChannelSetupWizard } from 'openclaw/plugin-sdk/setup';
|
|
2
|
+
import { SiderSetupConfigSnapshot } from './auth.js';
|
|
3
|
+
import { SiderAutoTitleConfig } from './auto-title.js';
|
|
4
|
+
import 'openclaw/plugin-sdk';
|
|
5
|
+
import 'openclaw/plugin-sdk/plugin-entry';
|
|
6
|
+
|
|
7
|
+
type SiderAccountConfig = {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
name?: string;
|
|
10
|
+
setupToken?: string;
|
|
11
|
+
token?: string;
|
|
12
|
+
autoTitle?: SiderAutoTitleConfig;
|
|
13
|
+
defaultTo?: string;
|
|
14
|
+
connectTimeoutMs?: number;
|
|
15
|
+
sendTimeoutMs?: number;
|
|
16
|
+
reconnectDelayMs?: number;
|
|
17
|
+
};
|
|
18
|
+
type ResolvedSiderAccount = {
|
|
19
|
+
accountId: string;
|
|
20
|
+
name: string;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
gatewayUrl: string;
|
|
23
|
+
relayId: string;
|
|
24
|
+
token?: string;
|
|
25
|
+
defaultTo?: string;
|
|
26
|
+
connectTimeoutMs: number;
|
|
27
|
+
sendTimeoutMs: number;
|
|
28
|
+
reconnectDelayMs: number;
|
|
29
|
+
configured: boolean;
|
|
30
|
+
config: SiderAccountConfig;
|
|
31
|
+
};
|
|
32
|
+
declare function readSiderAccountConfig(cfg: OpenClawConfig, accountId?: string | null): SiderSetupConfigSnapshot & SiderAccountConfig;
|
|
33
|
+
declare function resolveSiderAccount(cfg: OpenClawConfig, accountId?: string | null): ResolvedSiderAccount;
|
|
34
|
+
declare function listSiderAccountIds(cfg: OpenClawConfig): string[];
|
|
35
|
+
declare const siderSetupWizard: ChannelSetupWizard;
|
|
36
|
+
declare function describeSiderAccountConfigurationError(account: ResolvedSiderAccount): string;
|
|
37
|
+
declare function isSiderAccountBootstrappable(account: ResolvedSiderAccount): boolean;
|
|
38
|
+
declare function resolveManagedSiderAccount(params: {
|
|
39
|
+
cfg: OpenClawConfig;
|
|
40
|
+
accountId?: string | null;
|
|
41
|
+
}): Promise<ResolvedSiderAccount>;
|
|
42
|
+
declare function normalizeSiderMessagingTarget(raw: string): string | undefined;
|
|
43
|
+
declare function looksLikeSiderTargetId(raw: string, normalized?: string): boolean;
|
|
44
|
+
declare function resolveOutboundSessionId(params: {
|
|
45
|
+
account: ResolvedSiderAccount;
|
|
46
|
+
to?: string;
|
|
47
|
+
}): string;
|
|
48
|
+
declare function extractSiderToolSend(args: Record<string, unknown>): {
|
|
49
|
+
to: string;
|
|
50
|
+
accountId?: string;
|
|
51
|
+
threadId?: string;
|
|
52
|
+
} | null;
|
|
53
|
+
|
|
54
|
+
export { type ResolvedSiderAccount, type SiderAccountConfig, describeSiderAccountConfigurationError, extractSiderToolSend, isSiderAccountBootstrappable, listSiderAccountIds, looksLikeSiderTargetId, normalizeSiderMessagingTarget, readSiderAccountConfig, resolveManagedSiderAccount, resolveOutboundSessionId, resolveSiderAccount, siderSetupWizard };
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
|
2
2
|
import {
|
|
3
3
|
createStandardChannelSetupStatus,
|
|
4
|
-
setSetupChannelEnabled
|
|
5
|
-
type ChannelSetupWizard,
|
|
6
|
-
type OpenClawConfig,
|
|
4
|
+
setSetupChannelEnabled
|
|
7
5
|
} from "openclaw/plugin-sdk/setup";
|
|
8
6
|
import {
|
|
9
7
|
ensureSiderAccountSetup,
|
|
10
8
|
isSiderAccountSetupPending,
|
|
11
9
|
resolveSiderBaseUrl,
|
|
12
|
-
resolveSiderSetupToken
|
|
13
|
-
type SiderSetupConfigSnapshot,
|
|
10
|
+
resolveSiderSetupToken
|
|
14
11
|
} from "./auth.js";
|
|
15
12
|
import { SIDER_CHANNEL_ID, SIDER_CHANNEL_LABEL } from "./config.js";
|
|
16
13
|
import {
|
|
@@ -20,52 +17,14 @@ import {
|
|
|
20
17
|
getSiderSetupChannelId,
|
|
21
18
|
requestSiderPairing,
|
|
22
19
|
SiderPairingExpiredError,
|
|
23
|
-
waitForSiderPairing
|
|
20
|
+
waitForSiderPairing
|
|
24
21
|
} from "./setup-core.js";
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
export type SiderAccountConfig = {
|
|
31
|
-
enabled?: boolean;
|
|
32
|
-
name?: string;
|
|
33
|
-
setupToken?: string;
|
|
34
|
-
sessionId?: string;
|
|
35
|
-
subscribeSessionIds?: string[];
|
|
36
|
-
relayId?: string;
|
|
37
|
-
token?: string;
|
|
38
|
-
defaultTo?: string;
|
|
39
|
-
connectTimeoutMs?: number;
|
|
40
|
-
sendTimeoutMs?: number;
|
|
41
|
-
reconnectDelayMs?: number;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type SiderChannelConfig = SiderAccountConfig & {
|
|
45
|
-
accounts?: Record<string, SiderAccountConfig>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export type ResolvedSiderAccount = {
|
|
49
|
-
accountId: string;
|
|
50
|
-
name: string;
|
|
51
|
-
enabled: boolean;
|
|
52
|
-
gatewayUrl: string;
|
|
53
|
-
sessionId?: string;
|
|
54
|
-
subscribeSessionIds?: string[];
|
|
55
|
-
relayId: string;
|
|
56
|
-
token?: string;
|
|
57
|
-
defaultTo?: string;
|
|
58
|
-
connectTimeoutMs: number;
|
|
59
|
-
sendTimeoutMs: number;
|
|
60
|
-
reconnectDelayMs: number;
|
|
61
|
-
configured: boolean;
|
|
62
|
-
config: SiderAccountConfig;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const siderEphemeralRelayIds = new Map<string, string>();
|
|
22
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 8e3;
|
|
23
|
+
const DEFAULT_SEND_TIMEOUT_MS = 12e3;
|
|
24
|
+
const DEFAULT_RECONNECT_DELAY_MS = 2e3;
|
|
25
|
+
const siderEphemeralRelayIds = /* @__PURE__ */ new Map();
|
|
66
26
|
const setupChannel = getSiderSetupChannelId();
|
|
67
|
-
|
|
68
|
-
function resolveEphemeralRelayId(accountId: string): string {
|
|
27
|
+
function resolveEphemeralRelayId(accountId) {
|
|
69
28
|
const existing = siderEphemeralRelayIds.get(accountId);
|
|
70
29
|
if (existing) {
|
|
71
30
|
return existing;
|
|
@@ -74,81 +33,52 @@ function resolveEphemeralRelayId(accountId: string): string {
|
|
|
74
33
|
siderEphemeralRelayIds.set(accountId, created);
|
|
75
34
|
return created;
|
|
76
35
|
}
|
|
77
|
-
|
|
78
|
-
function normalizeTimeout(raw: unknown, fallback: number): number {
|
|
36
|
+
function normalizeTimeout(raw, fallback) {
|
|
79
37
|
if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) {
|
|
80
38
|
return fallback;
|
|
81
39
|
}
|
|
82
40
|
return Math.floor(raw);
|
|
83
41
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (Array.isArray(raw)) {
|
|
87
|
-
const values = Array.from(
|
|
88
|
-
new Set(raw.filter((item): item is string => typeof item === "string").map((item) => item.trim()).filter(Boolean)),
|
|
89
|
-
);
|
|
90
|
-
return values.length > 0 ? values : undefined;
|
|
91
|
-
}
|
|
92
|
-
if (typeof raw === "string" && raw.trim()) {
|
|
93
|
-
return [raw.trim()];
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
42
|
+
function getSiderConfig(cfg) {
|
|
43
|
+
return cfg.channels?.[SIDER_CHANNEL_ID] ?? {};
|
|
96
44
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
45
|
+
function hasConfiguredAccountFields(accountCfg) {
|
|
46
|
+
if (!accountCfg) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return accountCfg.enabled !== void 0 || Boolean(accountCfg.name?.trim()) || Boolean(accountCfg.setupToken?.trim()) || Boolean(accountCfg.token?.trim()) || accountCfg.autoTitle !== void 0 || Boolean(accountCfg.defaultTo?.trim()) || accountCfg.connectTimeoutMs !== void 0 || accountCfg.sendTimeoutMs !== void 0 || accountCfg.reconnectDelayMs !== void 0;
|
|
100
50
|
}
|
|
101
|
-
|
|
102
|
-
export function readSiderAccountConfig(
|
|
103
|
-
cfg: OpenClawConfig,
|
|
104
|
-
accountId?: string | null,
|
|
105
|
-
): SiderSetupConfigSnapshot & SiderAccountConfig {
|
|
51
|
+
function readSiderAccountConfig(cfg, accountId) {
|
|
106
52
|
const id = normalizeAccountId(accountId) ?? DEFAULT_ACCOUNT_ID;
|
|
107
53
|
const channelCfg = getSiderConfig(cfg);
|
|
108
|
-
return id === DEFAULT_ACCOUNT_ID ? channelCfg :
|
|
54
|
+
return id === DEFAULT_ACCOUNT_ID ? channelCfg : channelCfg.accounts?.[id] ?? {};
|
|
109
55
|
}
|
|
110
|
-
|
|
111
|
-
export function resolveSiderAccount(
|
|
112
|
-
cfg: OpenClawConfig,
|
|
113
|
-
accountId?: string | null,
|
|
114
|
-
): ResolvedSiderAccount {
|
|
56
|
+
function resolveSiderAccount(cfg, accountId) {
|
|
115
57
|
const id = normalizeAccountId(accountId) ?? DEFAULT_ACCOUNT_ID;
|
|
116
58
|
const accountCfg = readSiderAccountConfig(cfg, id);
|
|
117
59
|
const gatewayUrl = resolveSiderBaseUrl();
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const token = accountCfg.token?.trim() || undefined;
|
|
122
|
-
const defaultTo = accountCfg.defaultTo?.trim() || (sessionId ? `session:${sessionId}` : undefined);
|
|
123
|
-
|
|
60
|
+
const relayId = resolveEphemeralRelayId(id);
|
|
61
|
+
const token = accountCfg.token?.trim() || void 0;
|
|
62
|
+
const defaultTo = accountCfg.defaultTo?.trim() || void 0;
|
|
124
63
|
return {
|
|
125
64
|
accountId: id,
|
|
126
65
|
name: accountCfg.name?.trim() || id,
|
|
127
66
|
enabled: accountCfg.enabled !== false,
|
|
128
67
|
gatewayUrl,
|
|
129
|
-
sessionId,
|
|
130
|
-
subscribeSessionIds,
|
|
131
68
|
relayId,
|
|
132
69
|
token,
|
|
133
70
|
defaultTo,
|
|
134
71
|
connectTimeoutMs: normalizeTimeout(accountCfg.connectTimeoutMs, DEFAULT_CONNECT_TIMEOUT_MS),
|
|
135
72
|
sendTimeoutMs: normalizeTimeout(accountCfg.sendTimeoutMs, DEFAULT_SEND_TIMEOUT_MS),
|
|
136
73
|
reconnectDelayMs: normalizeTimeout(accountCfg.reconnectDelayMs, DEFAULT_RECONNECT_DELAY_MS),
|
|
137
|
-
configured: Boolean(token
|
|
138
|
-
config: accountCfg
|
|
74
|
+
configured: Boolean(token),
|
|
75
|
+
config: accountCfg
|
|
139
76
|
};
|
|
140
77
|
}
|
|
141
|
-
|
|
142
|
-
export function listSiderAccountIds(cfg: OpenClawConfig): string[] {
|
|
78
|
+
function listSiderAccountIds(cfg) {
|
|
143
79
|
const channelCfg = getSiderConfig(cfg);
|
|
144
|
-
const ids = new Set
|
|
145
|
-
if (
|
|
146
|
-
channelCfg.enabled !== undefined ||
|
|
147
|
-
channelCfg.setupToken ||
|
|
148
|
-
channelCfg.token ||
|
|
149
|
-
channelCfg.sessionId ||
|
|
150
|
-
channelCfg.relayId
|
|
151
|
-
) {
|
|
80
|
+
const ids = /* @__PURE__ */ new Set();
|
|
81
|
+
if (hasConfiguredAccountFields(channelCfg)) {
|
|
152
82
|
ids.add(DEFAULT_ACCOUNT_ID);
|
|
153
83
|
}
|
|
154
84
|
for (const id of Object.keys(channelCfg.accounts ?? {})) {
|
|
@@ -156,8 +86,7 @@ export function listSiderAccountIds(cfg: OpenClawConfig): string[] {
|
|
|
156
86
|
}
|
|
157
87
|
return ids.size > 0 ? Array.from(ids) : [DEFAULT_ACCOUNT_ID];
|
|
158
88
|
}
|
|
159
|
-
|
|
160
|
-
function isSiderConfiguredForSetup(cfg: OpenClawConfig): boolean {
|
|
89
|
+
function isSiderConfiguredForSetup(cfg) {
|
|
161
90
|
return listSiderAccountIds(cfg).some((accountId) => {
|
|
162
91
|
const account = resolveSiderAccount(cfg, accountId);
|
|
163
92
|
if (account.configured) {
|
|
@@ -166,8 +95,7 @@ function isSiderConfiguredForSetup(cfg: OpenClawConfig): boolean {
|
|
|
166
95
|
return Boolean(resolveSiderSetupToken(accountId, readSiderAccountConfig(cfg, accountId)));
|
|
167
96
|
});
|
|
168
97
|
}
|
|
169
|
-
|
|
170
|
-
export const siderSetupWizard: ChannelSetupWizard = {
|
|
98
|
+
const siderSetupWizard = {
|
|
171
99
|
channel: setupChannel,
|
|
172
100
|
status: createStandardChannelSetupStatus({
|
|
173
101
|
channelLabel: SIDER_CHANNEL_LABEL,
|
|
@@ -178,23 +106,22 @@ export const siderSetupWizard: ChannelSetupWizard = {
|
|
|
178
106
|
configuredScore: 1,
|
|
179
107
|
unconfiguredScore: 0,
|
|
180
108
|
includeStatusLine: true,
|
|
181
|
-
resolveConfigured: ({ cfg }) => isSiderConfiguredForSetup(cfg)
|
|
109
|
+
resolveConfigured: ({ cfg }) => isSiderConfiguredForSetup(cfg)
|
|
182
110
|
}),
|
|
183
111
|
credentials: [],
|
|
184
112
|
finalize: async ({ cfg, accountId, prompter }) => {
|
|
185
|
-
for (
|
|
113
|
+
for (; ; ) {
|
|
186
114
|
const pairing = await requestSiderPairing();
|
|
187
115
|
await prompter.note(
|
|
188
116
|
formatSiderPairingInstructions({ pairingCode: pairing.pairingCode }),
|
|
189
|
-
"Sider pairing"
|
|
117
|
+
"Sider pairing"
|
|
190
118
|
);
|
|
191
|
-
|
|
192
119
|
const progress = prompter.progress("Waiting for connection...");
|
|
193
120
|
const reportPendingUpdate = createSiderPairingPendingUpdateReporter({
|
|
194
121
|
pairingCode: pairing.pairingCode,
|
|
195
122
|
report: (message) => {
|
|
196
123
|
progress.update(message);
|
|
197
|
-
}
|
|
124
|
+
}
|
|
198
125
|
});
|
|
199
126
|
try {
|
|
200
127
|
const paired = await waitForSiderPairing({
|
|
@@ -202,29 +129,28 @@ export const siderSetupWizard: ChannelSetupWizard = {
|
|
|
202
129
|
onPending: reportPendingUpdate,
|
|
203
130
|
onRetryableError: (message) => {
|
|
204
131
|
progress.update(message);
|
|
205
|
-
}
|
|
132
|
+
}
|
|
206
133
|
});
|
|
207
134
|
progress.stop("Connected.");
|
|
208
|
-
|
|
209
135
|
await prompter.note(
|
|
210
136
|
"Connected! You can now chat with me in the browser Side Panel.",
|
|
211
|
-
"Sider connected"
|
|
137
|
+
"Sider connected"
|
|
212
138
|
);
|
|
213
139
|
return {
|
|
214
140
|
cfg: applySiderSetupAccountConfig({
|
|
215
141
|
cfg,
|
|
216
142
|
accountId,
|
|
217
143
|
input: {
|
|
218
|
-
token: paired.token
|
|
219
|
-
}
|
|
220
|
-
})
|
|
144
|
+
token: paired.token
|
|
145
|
+
}
|
|
146
|
+
})
|
|
221
147
|
};
|
|
222
148
|
} catch (error) {
|
|
223
149
|
if (error instanceof SiderPairingExpiredError) {
|
|
224
150
|
progress.stop("Pairing code expired.");
|
|
225
151
|
await prompter.note(
|
|
226
152
|
"Pairing code expired.\nGenerating a new code...",
|
|
227
|
-
"Sider pairing"
|
|
153
|
+
"Sider pairing"
|
|
228
154
|
);
|
|
229
155
|
continue;
|
|
230
156
|
}
|
|
@@ -233,37 +159,22 @@ export const siderSetupWizard: ChannelSetupWizard = {
|
|
|
233
159
|
}
|
|
234
160
|
}
|
|
235
161
|
},
|
|
236
|
-
disable: (cfg) => setSetupChannelEnabled(cfg, setupChannel, false)
|
|
162
|
+
disable: (cfg) => setSetupChannelEnabled(cfg, setupChannel, false)
|
|
237
163
|
};
|
|
238
|
-
|
|
239
|
-
export function describeSiderAccountConfigurationError(account: ResolvedSiderAccount): string {
|
|
164
|
+
function describeSiderAccountConfigurationError(account) {
|
|
240
165
|
if (isSiderAccountSetupPending(account.accountId)) {
|
|
241
|
-
return
|
|
242
|
-
`sider account "${account.accountId}" is waiting for setup token exchange; ` +
|
|
243
|
-
`selfclaw registration is still in progress`
|
|
244
|
-
);
|
|
166
|
+
return `sider account "${account.accountId}" is waiting for setup token exchange; selfclaw registration is still in progress`;
|
|
245
167
|
}
|
|
246
|
-
const missing
|
|
168
|
+
const missing = [];
|
|
247
169
|
if (!account.token?.trim()) {
|
|
248
170
|
missing.push("token");
|
|
249
171
|
}
|
|
250
|
-
|
|
251
|
-
missing.push("relayId");
|
|
252
|
-
}
|
|
253
|
-
return (
|
|
254
|
-
`sider account "${account.accountId}" is not configured: missing ${missing.join("/") || "token/relayId"}; ` +
|
|
255
|
-
`run \`openclaw channels login --channel ${SIDER_CHANNEL_ID}\` or configure a token`
|
|
256
|
-
);
|
|
172
|
+
return `sider account "${account.accountId}" is not configured: missing ${missing.join("/") || "token"}; run \`openclaw channels login --channel ${SIDER_CHANNEL_ID}\` or configure a token`;
|
|
257
173
|
}
|
|
258
|
-
|
|
259
|
-
export function isSiderAccountBootstrappable(account: ResolvedSiderAccount): boolean {
|
|
174
|
+
function isSiderAccountBootstrappable(account) {
|
|
260
175
|
return Boolean(resolveSiderSetupToken(account.accountId, account.config));
|
|
261
176
|
}
|
|
262
|
-
|
|
263
|
-
export async function resolveManagedSiderAccount(params: {
|
|
264
|
-
cfg: OpenClawConfig;
|
|
265
|
-
accountId?: string | null;
|
|
266
|
-
}): Promise<ResolvedSiderAccount> {
|
|
177
|
+
async function resolveManagedSiderAccount(params) {
|
|
267
178
|
const initial = resolveSiderAccount(params.cfg, params.accountId);
|
|
268
179
|
if (!initial.enabled) {
|
|
269
180
|
return initial;
|
|
@@ -275,12 +186,11 @@ export async function resolveManagedSiderAccount(params: {
|
|
|
275
186
|
const nextCfg = await ensureSiderAccountSetup({
|
|
276
187
|
cfg: params.cfg,
|
|
277
188
|
accountId: initial.accountId,
|
|
278
|
-
getAccountSetupConfig: readSiderAccountConfig
|
|
189
|
+
getAccountSetupConfig: readSiderAccountConfig
|
|
279
190
|
});
|
|
280
191
|
return resolveSiderAccount(nextCfg, initial.accountId);
|
|
281
192
|
}
|
|
282
|
-
|
|
283
|
-
function parseSessionTarget(raw: string): string {
|
|
193
|
+
function parseSessionTarget(raw) {
|
|
284
194
|
const trimmed = raw.trim();
|
|
285
195
|
if (!trimmed) {
|
|
286
196
|
throw new Error("Missing sider session target");
|
|
@@ -294,17 +204,15 @@ function parseSessionTarget(raw: string): string {
|
|
|
294
204
|
}
|
|
295
205
|
return trimmed;
|
|
296
206
|
}
|
|
297
|
-
|
|
298
|
-
export function normalizeSiderMessagingTarget(raw: string): string | undefined {
|
|
207
|
+
function normalizeSiderMessagingTarget(raw) {
|
|
299
208
|
const trimmed = raw.trim();
|
|
300
209
|
if (!trimmed) {
|
|
301
|
-
return
|
|
210
|
+
return void 0;
|
|
302
211
|
}
|
|
303
212
|
const withoutProviderPrefix = trimmed.replace(/^sider:/i, "").trim();
|
|
304
|
-
return withoutProviderPrefix ||
|
|
213
|
+
return withoutProviderPrefix || void 0;
|
|
305
214
|
}
|
|
306
|
-
|
|
307
|
-
export function looksLikeSiderTargetId(raw: string, normalized?: string): boolean {
|
|
215
|
+
function looksLikeSiderTargetId(raw, normalized) {
|
|
308
216
|
const candidate = (normalized ?? raw ?? "").trim();
|
|
309
217
|
if (!candidate) {
|
|
310
218
|
return false;
|
|
@@ -315,25 +223,16 @@ export function looksLikeSiderTargetId(raw: string, normalized?: string): boolea
|
|
|
315
223
|
}
|
|
316
224
|
return !/\s/.test(candidate);
|
|
317
225
|
}
|
|
318
|
-
|
|
319
|
-
export function resolveOutboundSessionId(params: {
|
|
320
|
-
account: ResolvedSiderAccount;
|
|
321
|
-
to?: string;
|
|
322
|
-
}): string {
|
|
226
|
+
function resolveOutboundSessionId(params) {
|
|
323
227
|
const target = params.to?.trim() || params.account.defaultTo?.trim() || "";
|
|
324
228
|
if (!target) {
|
|
325
229
|
throw new Error(
|
|
326
|
-
`sider account "${params.account.accountId}" missing target; set 'to' or channels.${SIDER_CHANNEL_ID}.defaultTo
|
|
230
|
+
`sider account "${params.account.accountId}" missing target; set 'to' or channels.${SIDER_CHANNEL_ID}.defaultTo`
|
|
327
231
|
);
|
|
328
232
|
}
|
|
329
233
|
return parseSessionTarget(target);
|
|
330
234
|
}
|
|
331
|
-
|
|
332
|
-
export function extractSiderToolSend(args: Record<string, unknown>): {
|
|
333
|
-
to: string;
|
|
334
|
-
accountId?: string;
|
|
335
|
-
threadId?: string;
|
|
336
|
-
} | null {
|
|
235
|
+
function extractSiderToolSend(args) {
|
|
337
236
|
const action = typeof args.action === "string" ? args.action.trim() : "";
|
|
338
237
|
if (action !== "sendAttachment" && action !== "send") {
|
|
339
238
|
return null;
|
|
@@ -342,9 +241,20 @@ export function extractSiderToolSend(args: Record<string, unknown>): {
|
|
|
342
241
|
if (!to) {
|
|
343
242
|
return null;
|
|
344
243
|
}
|
|
345
|
-
const accountId =
|
|
346
|
-
|
|
347
|
-
const threadId =
|
|
348
|
-
typeof args.threadId === "string" && args.threadId.trim() ? args.threadId.trim() : undefined;
|
|
244
|
+
const accountId = typeof args.accountId === "string" && args.accountId.trim() ? args.accountId.trim() : void 0;
|
|
245
|
+
const threadId = typeof args.threadId === "string" && args.threadId.trim() ? args.threadId.trim() : void 0;
|
|
349
246
|
return { to, accountId, threadId };
|
|
350
247
|
}
|
|
248
|
+
export {
|
|
249
|
+
describeSiderAccountConfigurationError,
|
|
250
|
+
extractSiderToolSend,
|
|
251
|
+
isSiderAccountBootstrappable,
|
|
252
|
+
listSiderAccountIds,
|
|
253
|
+
looksLikeSiderTargetId,
|
|
254
|
+
normalizeSiderMessagingTarget,
|
|
255
|
+
readSiderAccountConfig,
|
|
256
|
+
resolveManagedSiderAccount,
|
|
257
|
+
resolveOutboundSessionId,
|
|
258
|
+
resolveSiderAccount,
|
|
259
|
+
siderSetupWizard
|
|
260
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OpenClawConfig, PluginRuntime } from 'openclaw/plugin-sdk';
|
|
2
|
+
import { OpenClawPluginService } from 'openclaw/plugin-sdk/plugin-entry';
|
|
3
|
+
|
|
4
|
+
declare const SIDER_AUTH_EXCHANGE_API_PATH = "/v1/claws/register";
|
|
5
|
+
type SiderSetupConfigSnapshot = {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
setupToken?: string;
|
|
8
|
+
token?: string;
|
|
9
|
+
};
|
|
10
|
+
type SiderAuthSetupServiceParams = {
|
|
11
|
+
listAccountIds: (cfg: OpenClawConfig) => string[];
|
|
12
|
+
getAccountSetupConfig: (cfg: OpenClawConfig, accountId: string) => SiderSetupConfigSnapshot;
|
|
13
|
+
};
|
|
14
|
+
declare function resolveSiderBaseUrl(): string;
|
|
15
|
+
declare function resolveSiderApiUrl(pathname: string): string;
|
|
16
|
+
declare function formatAuthorizationHeader(token: string): string;
|
|
17
|
+
declare function appendTokenQuery(url: string, token?: string): string;
|
|
18
|
+
declare function cloneOpenClawConfig(cfg: OpenClawConfig): OpenClawConfig;
|
|
19
|
+
declare function resolveWritableSiderAccountConfig(cfg: OpenClawConfig, accountId: string): Record<string, unknown>;
|
|
20
|
+
declare function setSiderAuthRuntime(runtime: PluginRuntime): void;
|
|
21
|
+
declare function resolveSiderSetupToken(accountId: string, snapshot?: SiderSetupConfigSnapshot): string | undefined;
|
|
22
|
+
declare function isSiderAccountSetupPending(accountId: string): boolean;
|
|
23
|
+
declare function ensureSiderAccountSetup(params: {
|
|
24
|
+
cfg: OpenClawConfig;
|
|
25
|
+
accountId: string;
|
|
26
|
+
getAccountSetupConfig: (cfg: OpenClawConfig, accountId: string) => SiderSetupConfigSnapshot;
|
|
27
|
+
}): Promise<OpenClawConfig>;
|
|
28
|
+
declare function createSiderAuthSetupService(params: SiderAuthSetupServiceParams): OpenClawPluginService;
|
|
29
|
+
|
|
30
|
+
export { SIDER_AUTH_EXCHANGE_API_PATH, type SiderSetupConfigSnapshot, appendTokenQuery, cloneOpenClawConfig, createSiderAuthSetupService, ensureSiderAccountSetup, formatAuthorizationHeader, isSiderAccountSetupPending, resolveSiderApiUrl, resolveSiderBaseUrl, resolveSiderSetupToken, resolveWritableSiderAccountConfig, setSiderAuthRuntime };
|