@shadowob/openclaw-shadowob 1.1.0 → 1.1.3

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.
@@ -0,0 +1,175 @@
1
+ // src/config.ts
2
+ var DEFAULT_ACCOUNT_ID = "default";
3
+ function getShadowBlock(cfg) {
4
+ const channels = cfg.channels;
5
+ return channels?.shadowob ?? channels?.["openclaw-shadowob"];
6
+ }
7
+ function getAccountConfig(cfg, accountId) {
8
+ const shadow = getShadowBlock(cfg);
9
+ if (!shadow) return null;
10
+ const accounts = shadow.accounts;
11
+ if (accountId === DEFAULT_ACCOUNT_ID) {
12
+ const fromAccounts = accounts?.[DEFAULT_ACCOUNT_ID];
13
+ const baseLevel = {
14
+ token: typeof shadow.token === "string" ? shadow.token : void 0,
15
+ serverUrl: typeof shadow.serverUrl === "string" ? shadow.serverUrl : void 0,
16
+ enabled: typeof shadow.enabled === "boolean" ? shadow.enabled : void 0
17
+ };
18
+ const merged = {
19
+ ...fromAccounts,
20
+ // Base-level fields take precedence (convenience shorthand)
21
+ ...Object.fromEntries(Object.entries(baseLevel).filter(([, v]) => v !== void 0))
22
+ };
23
+ if (merged.token) {
24
+ return {
25
+ ...merged,
26
+ token: merged.token,
27
+ serverUrl: merged.serverUrl ?? "https://shadowob.com"
28
+ };
29
+ }
30
+ return fromAccounts ?? null;
31
+ }
32
+ return accounts?.[accountId] ?? null;
33
+ }
34
+ function listAccountIds(cfg) {
35
+ const shadow = getShadowBlock(cfg);
36
+ if (!shadow) return [];
37
+ const accounts = shadow.accounts;
38
+ const ids = [];
39
+ if (accounts) {
40
+ ids.push(...Object.keys(accounts));
41
+ }
42
+ const hasBaseLevelConfig = typeof shadow.token === "string" || typeof shadow.serverUrl === "string";
43
+ if (hasBaseLevelConfig && !ids.includes(DEFAULT_ACCOUNT_ID)) {
44
+ ids.push(DEFAULT_ACCOUNT_ID);
45
+ }
46
+ return ids;
47
+ }
48
+
49
+ // src/channel/account.ts
50
+ function resolveAccount(cfg, accountId) {
51
+ const account = getAccountConfig(cfg, accountId ?? DEFAULT_ACCOUNT_ID);
52
+ if (!account) {
53
+ return { token: "", serverUrl: "https://shadowob.com", enabled: false };
54
+ }
55
+ return account;
56
+ }
57
+ function inspectAccount(cfg, accountId) {
58
+ const account = getAccountConfig(cfg, accountId ?? DEFAULT_ACCOUNT_ID);
59
+ return {
60
+ enabled: account?.enabled !== false,
61
+ configured: !!account?.token?.trim(),
62
+ tokenStatus: account?.token?.trim() ? "available" : "missing"
63
+ };
64
+ }
65
+
66
+ // src/channel/setup.ts
67
+ var shadowPluginMeta = {
68
+ id: "shadowob",
69
+ label: "ShadowOwnBuddy",
70
+ selectionLabel: "ShadowOwnBuddy (Server)",
71
+ docsPath: "/channels/shadowob",
72
+ blurb: "Shadow server channel integration \u2014 chat with AI agents in Shadow channels",
73
+ aliases: ["shadow-server", "openclaw-shadowob"]
74
+ };
75
+ var shadowPluginCapabilities = {
76
+ chatTypes: ["channel", "thread", "direct"],
77
+ reactions: true,
78
+ threads: true,
79
+ media: true,
80
+ reply: true,
81
+ edit: true,
82
+ unsend: true
83
+ };
84
+ var shadowPluginConfig = {
85
+ listAccountIds: (cfg) => listAccountIds(cfg),
86
+ inspectAccount,
87
+ resolveAccount,
88
+ defaultAccountId: () => DEFAULT_ACCOUNT_ID,
89
+ isConfigured: (account) => !!account?.token?.trim(),
90
+ isEnabled: (account) => account?.enabled !== false,
91
+ describeAccount: (account) => ({
92
+ accountId: DEFAULT_ACCOUNT_ID,
93
+ enabled: account?.enabled !== false,
94
+ configured: !!account?.token?.trim()
95
+ })
96
+ };
97
+ var shadowPluginSetup = {
98
+ resolveAccountId: ({ accountId }) => accountId ?? DEFAULT_ACCOUNT_ID,
99
+ applyAccountConfig: ({ cfg }) => cfg
100
+ };
101
+ var shadowPluginConfigSchema = {
102
+ schema: {
103
+ type: "object",
104
+ properties: {
105
+ token: { type: "string", description: "Agent JWT token" },
106
+ serverUrl: { type: "string", description: "Shadow server URL" },
107
+ enabled: { type: "boolean" },
108
+ capabilities: {
109
+ type: "object",
110
+ additionalProperties: true,
111
+ properties: {
112
+ inlineButtons: {
113
+ anyOf: [
114
+ { type: "string", enum: ["off", "dm", "group", "all", "allowlist"] },
115
+ { type: "boolean" }
116
+ ]
117
+ },
118
+ interactive: { type: "boolean" },
119
+ forms: { type: "boolean" }
120
+ }
121
+ },
122
+ accounts: {
123
+ type: "object",
124
+ additionalProperties: {
125
+ type: "object",
126
+ properties: {
127
+ token: { type: "string" },
128
+ serverUrl: { type: "string" },
129
+ enabled: { type: "boolean" },
130
+ capabilities: {
131
+ type: "object",
132
+ additionalProperties: true
133
+ }
134
+ },
135
+ required: ["token", "serverUrl"]
136
+ }
137
+ }
138
+ }
139
+ },
140
+ uiHints: {
141
+ token: {
142
+ label: "Agent Token",
143
+ sensitive: true,
144
+ placeholder: "Paste the JWT token generated in Shadow -> Agents"
145
+ },
146
+ serverUrl: {
147
+ label: "Server URL",
148
+ placeholder: "https://shadowob.com"
149
+ },
150
+ enabled: {
151
+ label: "Enabled"
152
+ }
153
+ }
154
+ };
155
+ var shadowSetupPlugin = {
156
+ id: "shadowob",
157
+ meta: shadowPluginMeta,
158
+ capabilities: shadowPluginCapabilities,
159
+ config: shadowPluginConfig,
160
+ setup: shadowPluginSetup,
161
+ configSchema: shadowPluginConfigSchema
162
+ };
163
+
164
+ export {
165
+ DEFAULT_ACCOUNT_ID,
166
+ getAccountConfig,
167
+ listAccountIds,
168
+ resolveAccount,
169
+ shadowPluginMeta,
170
+ shadowPluginCapabilities,
171
+ shadowPluginConfig,
172
+ shadowPluginSetup,
173
+ shadowPluginConfigSchema,
174
+ shadowSetupPlugin
175
+ };