agent-messenger 2.0.0 → 2.1.0
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/.claude-plugin/marketplace.json +14 -1
- package/.claude-plugin/plugin.json +4 -2
- package/README.md +33 -29
- package/dist/package.json +10 -2
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +3 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/webex/app-config.d.ts +7 -0
- package/dist/src/platforms/webex/app-config.d.ts.map +1 -0
- package/dist/src/platforms/webex/app-config.js +20 -0
- package/dist/src/platforms/webex/app-config.js.map +1 -0
- package/dist/src/platforms/webex/cli.d.ts +5 -0
- package/dist/src/platforms/webex/cli.d.ts.map +1 -0
- package/dist/src/platforms/webex/cli.js +32 -0
- package/dist/src/platforms/webex/cli.js.map +1 -0
- package/dist/src/platforms/webex/client.d.ts +45 -0
- package/dist/src/platforms/webex/client.d.ts.map +1 -0
- package/dist/src/platforms/webex/client.js +175 -0
- package/dist/src/platforms/webex/client.js.map +1 -0
- package/dist/src/platforms/webex/commands/auth.d.ts +15 -0
- package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/auth.js +124 -0
- package/dist/src/platforms/webex/commands/auth.js.map +1 -0
- package/dist/src/platforms/webex/commands/index.d.ts +6 -0
- package/dist/src/platforms/webex/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/index.js +6 -0
- package/dist/src/platforms/webex/commands/index.js.map +1 -0
- package/dist/src/platforms/webex/commands/member.d.ts +7 -0
- package/dist/src/platforms/webex/commands/member.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/member.js +34 -0
- package/dist/src/platforms/webex/commands/member.js.map +1 -0
- package/dist/src/platforms/webex/commands/message.d.ts +26 -0
- package/dist/src/platforms/webex/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/message.js +153 -0
- package/dist/src/platforms/webex/commands/message.js.map +1 -0
- package/dist/src/platforms/webex/commands/snapshot.d.ts +9 -0
- package/dist/src/platforms/webex/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/snapshot.js +72 -0
- package/dist/src/platforms/webex/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/webex/commands/space.d.ts +11 -0
- package/dist/src/platforms/webex/commands/space.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/space.js +59 -0
- package/dist/src/platforms/webex/commands/space.js.map +1 -0
- package/dist/src/platforms/webex/credential-manager.d.ts +23 -0
- package/dist/src/platforms/webex/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/webex/credential-manager.js +148 -0
- package/dist/src/platforms/webex/credential-manager.js.map +1 -0
- package/dist/src/platforms/webex/ensure-auth.d.ts +2 -0
- package/dist/src/platforms/webex/ensure-auth.d.ts.map +1 -0
- package/dist/src/platforms/webex/ensure-auth.js +20 -0
- package/dist/src/platforms/webex/ensure-auth.js.map +1 -0
- package/dist/src/platforms/webex/index.d.ts +6 -0
- package/dist/src/platforms/webex/index.d.ts.map +1 -0
- package/dist/src/platforms/webex/index.js +5 -0
- package/dist/src/platforms/webex/index.js.map +1 -0
- package/dist/src/platforms/webex/types.d.ts +124 -0
- package/dist/src/platforms/webex/types.d.ts.map +1 -0
- package/dist/src/platforms/webex/types.js +63 -0
- package/dist/src/platforms/webex/types.js.map +1 -0
- package/dist/src/tui/adapters/webex-adapter.d.ts +14 -0
- package/dist/src/tui/adapters/webex-adapter.d.ts.map +1 -0
- package/dist/src/tui/adapters/webex-adapter.js +79 -0
- package/dist/src/tui/adapters/webex-adapter.js.map +1 -0
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +2 -0
- package/dist/src/tui/app.js.map +1 -1
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/webex.mdx +291 -0
- package/docs/content/docs/sdk/meta.json +1 -1
- package/docs/content/docs/sdk/webex.mdx +260 -0
- package/docs/content/docs/tui.mdx +4 -3
- package/docs/src/app/page.tsx +2 -2
- package/package.json +10 -2
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +1 -1
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +386 -0
- package/skills/agent-webex/references/authentication.md +318 -0
- package/skills/agent-webex/references/common-patterns.md +723 -0
- package/skills/agent-webex/templates/monitor-space.sh +165 -0
- package/skills/agent-webex/templates/post-message.sh +170 -0
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/cli.ts +4 -0
- package/src/platforms/webex/app-config.test.ts +98 -0
- package/src/platforms/webex/app-config.ts +31 -0
- package/src/platforms/webex/cli.test.ts +58 -0
- package/src/platforms/webex/cli.ts +39 -0
- package/src/platforms/webex/client.test.ts +429 -0
- package/src/platforms/webex/client.ts +247 -0
- package/src/platforms/webex/commands/auth.test.ts +222 -0
- package/src/platforms/webex/commands/auth.ts +180 -0
- package/src/platforms/webex/commands/index.ts +5 -0
- package/src/platforms/webex/commands/member.test.ts +103 -0
- package/src/platforms/webex/commands/member.ts +45 -0
- package/src/platforms/webex/commands/message.test.ts +231 -0
- package/src/platforms/webex/commands/message.ts +204 -0
- package/src/platforms/webex/commands/snapshot.test.ts +96 -0
- package/src/platforms/webex/commands/snapshot.ts +91 -0
- package/src/platforms/webex/commands/space.test.ts +206 -0
- package/src/platforms/webex/commands/space.ts +74 -0
- package/src/platforms/webex/credential-manager.test.ts +314 -0
- package/src/platforms/webex/credential-manager.ts +197 -0
- package/src/platforms/webex/ensure-auth.test.ts +85 -0
- package/src/platforms/webex/ensure-auth.ts +19 -0
- package/src/platforms/webex/index.test.ts +25 -0
- package/src/platforms/webex/index.ts +17 -0
- package/src/platforms/webex/types.test.ts +307 -0
- package/src/platforms/webex/types.ts +127 -0
- package/src/tui/adapters/webex-adapter.ts +103 -0
- package/src/tui/app.ts +2 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { getWebexAppCredentials } from './app-config.js';
|
|
6
|
+
import { WebexConfigSchema } from './types.js';
|
|
7
|
+
const OAUTH_DEVICE_AUTHORIZE_URL = 'https://webexapis.com/v1/device/authorize';
|
|
8
|
+
const OAUTH_DEVICE_TOKEN_URL = 'https://webexapis.com/v1/device/token';
|
|
9
|
+
const OAUTH_TOKEN_URL = 'https://webexapis.com/v1/access_token';
|
|
10
|
+
const OAUTH_SCOPES = 'spark:all';
|
|
11
|
+
export { OAUTH_SCOPES };
|
|
12
|
+
export class WebexCredentialManager {
|
|
13
|
+
configDir;
|
|
14
|
+
credentialsPath;
|
|
15
|
+
constructor(configDir) {
|
|
16
|
+
this.configDir = configDir ?? join(homedir(), '.config', 'agent-messenger');
|
|
17
|
+
this.credentialsPath = join(this.configDir, 'webex-credentials.json');
|
|
18
|
+
}
|
|
19
|
+
async loadConfig() {
|
|
20
|
+
if (!existsSync(this.credentialsPath))
|
|
21
|
+
return null;
|
|
22
|
+
const content = await readFile(this.credentialsPath, 'utf-8');
|
|
23
|
+
const result = WebexConfigSchema.safeParse(JSON.parse(content));
|
|
24
|
+
if (!result.success)
|
|
25
|
+
return null;
|
|
26
|
+
return result.data;
|
|
27
|
+
}
|
|
28
|
+
async saveConfig(config) {
|
|
29
|
+
await mkdir(this.configDir, { recursive: true });
|
|
30
|
+
const tmpPath = `${this.credentialsPath}.tmp`;
|
|
31
|
+
await writeFile(tmpPath, JSON.stringify(config, null, 2), {
|
|
32
|
+
encoding: 'utf-8',
|
|
33
|
+
mode: 0o600,
|
|
34
|
+
});
|
|
35
|
+
await rename(tmpPath, this.credentialsPath);
|
|
36
|
+
}
|
|
37
|
+
async getToken(clientId, clientSecret) {
|
|
38
|
+
const config = await this.loadConfig();
|
|
39
|
+
if (!config)
|
|
40
|
+
return null;
|
|
41
|
+
if (config.tokenType === 'manual') {
|
|
42
|
+
return config.accessToken;
|
|
43
|
+
}
|
|
44
|
+
if (config.expiresAt < Date.now() + 5 * 60 * 1000) {
|
|
45
|
+
const builtinCreds = getWebexAppCredentials();
|
|
46
|
+
const resolvedClientId = clientId ?? config.clientId ?? builtinCreds.clientId;
|
|
47
|
+
const resolvedClientSecret = clientSecret ?? config.clientSecret ?? builtinCreds.clientSecret;
|
|
48
|
+
const refreshed = await this.refreshToken(config.refreshToken, resolvedClientId, resolvedClientSecret);
|
|
49
|
+
if (refreshed)
|
|
50
|
+
return refreshed.accessToken;
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return config.accessToken;
|
|
54
|
+
}
|
|
55
|
+
async refreshToken(refreshToken, clientId, clientSecret) {
|
|
56
|
+
try {
|
|
57
|
+
const response = await fetch(OAUTH_TOKEN_URL, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
60
|
+
body: new URLSearchParams({
|
|
61
|
+
grant_type: 'refresh_token',
|
|
62
|
+
client_id: clientId,
|
|
63
|
+
client_secret: clientSecret,
|
|
64
|
+
refresh_token: refreshToken,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok)
|
|
68
|
+
return null;
|
|
69
|
+
const data = (await response.json());
|
|
70
|
+
const config = {
|
|
71
|
+
accessToken: data.access_token,
|
|
72
|
+
refreshToken: data.refresh_token,
|
|
73
|
+
expiresAt: Date.now() + data.expires_in * 1000,
|
|
74
|
+
};
|
|
75
|
+
await this.saveConfig(config);
|
|
76
|
+
return config;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async requestDeviceCode(clientId, scopes) {
|
|
83
|
+
const response = await fetch(OAUTH_DEVICE_AUTHORIZE_URL, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
86
|
+
body: new URLSearchParams({
|
|
87
|
+
client_id: clientId,
|
|
88
|
+
scope: scopes ?? OAUTH_SCOPES,
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
const errorBody = await response.text();
|
|
93
|
+
throw new Error(`Device authorization failed: ${response.status} ${errorBody}`);
|
|
94
|
+
}
|
|
95
|
+
const data = (await response.json());
|
|
96
|
+
return {
|
|
97
|
+
deviceCode: data.device_code,
|
|
98
|
+
userCode: data.user_code,
|
|
99
|
+
verificationUri: data.verification_uri,
|
|
100
|
+
verificationUriComplete: data.verification_uri_complete,
|
|
101
|
+
expiresIn: data.expires_in,
|
|
102
|
+
interval: data.interval,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async pollDeviceToken(deviceCode, interval, expiresIn, clientId, clientSecret) {
|
|
106
|
+
const basicAuth = btoa(`${clientId}:${clientSecret ?? ''}`);
|
|
107
|
+
const deadline = Date.now() + expiresIn * 1000;
|
|
108
|
+
while (Date.now() < deadline) {
|
|
109
|
+
await new Promise((resolve) => setTimeout(resolve, interval * 1000));
|
|
110
|
+
const response = await fetch(OAUTH_DEVICE_TOKEN_URL, {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: {
|
|
113
|
+
Authorization: `Basic ${basicAuth}`,
|
|
114
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
115
|
+
},
|
|
116
|
+
body: new URLSearchParams({
|
|
117
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
118
|
+
device_code: deviceCode,
|
|
119
|
+
client_id: clientId,
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
if (response.ok) {
|
|
123
|
+
const data = (await response.json());
|
|
124
|
+
const config = {
|
|
125
|
+
accessToken: data.access_token,
|
|
126
|
+
refreshToken: data.refresh_token,
|
|
127
|
+
expiresAt: Date.now() + data.expires_in * 1000,
|
|
128
|
+
};
|
|
129
|
+
return config;
|
|
130
|
+
}
|
|
131
|
+
if (response.status === 428)
|
|
132
|
+
continue;
|
|
133
|
+
const errorBody = (await response.json().catch(() => null));
|
|
134
|
+
const errorDesc = errorBody?.errors?.[0]?.description ?? '';
|
|
135
|
+
if (errorDesc.includes('authorization_pending') || errorDesc.includes('slow_down')) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
throw new Error(`Device token exchange failed: ${response.status} ${errorDesc}`);
|
|
139
|
+
}
|
|
140
|
+
throw new Error('Device authorization timed out');
|
|
141
|
+
}
|
|
142
|
+
async clearCredentials() {
|
|
143
|
+
if (existsSync(this.credentialsPath)) {
|
|
144
|
+
await rm(this.credentialsPath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=credential-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../../src/platforms/webex/credential-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,iBAAiB,E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AAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI;iBAC/C,CAAA;gBAED,OAAO,MAAM,CAAA;YACf,CAAC;YAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;gBAAE,SAAQ;YAErC,MAAM,SAAS,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAElD,CAAA;YACR,MAAM,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,IAAI,EAAE,CAAA;YAE3D,IAAI,SAAS,CAAC,QAAQ,CAAC,uBAAuB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACnF,SAAQ;YACV,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC,CAAA;QAClF,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YACrC,MAAM,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-auth.d.ts","sourceRoot":"","sources":["../../../../src/platforms/webex/ensure-auth.ts"],"names":[],"mappings":"AAGA,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAerD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WebexClient } from './client.js';
|
|
2
|
+
import { WebexCredentialManager } from './credential-manager.js';
|
|
3
|
+
export async function ensureWebexAuth() {
|
|
4
|
+
try {
|
|
5
|
+
const credManager = new WebexCredentialManager();
|
|
6
|
+
const config = await credManager.loadConfig();
|
|
7
|
+
if (!config)
|
|
8
|
+
return;
|
|
9
|
+
const token = await credManager.getToken(config.clientId, config.clientSecret);
|
|
10
|
+
if (!token)
|
|
11
|
+
return;
|
|
12
|
+
const client = new WebexClient();
|
|
13
|
+
await client.login({ token });
|
|
14
|
+
await client.testAuth();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Intentionally silent — best-effort preflight that should not block commands
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ensure-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-auth.js","sourceRoot":"","sources":["../../../../src/platforms/webex/ensure-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,sBAAsB,EAAE,CAAA;QAChD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,CAAA;QAC7C,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;QAC9E,IAAI,CAAC,KAAK;YAAE,OAAM;QAElB,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;QAChC,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC7B,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;IACzB,CAAC;IAAC,MAAM,CAAC;QACP,8EAA8E;IAChF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { WebexClient } from './client.js';
|
|
2
|
+
export { WebexCredentialManager } from './credential-manager.js';
|
|
3
|
+
export { WebexError } from './types.js';
|
|
4
|
+
export type { WebexConfig, WebexMembership, WebexMessage, WebexPerson, WebexSpace, } from './types.js';
|
|
5
|
+
export { WebexConfigSchema, WebexMembershipSchema, WebexMessageSchema, WebexPersonSchema, WebexSpaceSchema, } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/platforms/webex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,YAAY,EACV,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,EACX,UAAU,GACX,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WebexClient } from './client.js';
|
|
2
|
+
export { WebexCredentialManager } from './credential-manager.js';
|
|
3
|
+
export { WebexError } from './types.js';
|
|
4
|
+
export { WebexConfigSchema, WebexMembershipSchema, WebexMessageSchema, WebexPersonSchema, WebexSpaceSchema, } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platforms/webex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAQpC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface WebexSpace {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
type: 'group' | 'direct';
|
|
6
|
+
isLocked: boolean;
|
|
7
|
+
teamId?: string;
|
|
8
|
+
lastActivity: string;
|
|
9
|
+
created: string;
|
|
10
|
+
creatorId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface WebexMessage {
|
|
13
|
+
id: string;
|
|
14
|
+
roomId: string;
|
|
15
|
+
roomType: 'group' | 'direct';
|
|
16
|
+
text?: string;
|
|
17
|
+
markdown?: string;
|
|
18
|
+
html?: string;
|
|
19
|
+
files?: string[];
|
|
20
|
+
personId: string;
|
|
21
|
+
personEmail: string;
|
|
22
|
+
created: string;
|
|
23
|
+
parentId?: string;
|
|
24
|
+
mentionedPeople?: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface WebexPerson {
|
|
27
|
+
id: string;
|
|
28
|
+
emails: string[];
|
|
29
|
+
displayName: string;
|
|
30
|
+
nickName?: string;
|
|
31
|
+
firstName?: string;
|
|
32
|
+
lastName?: string;
|
|
33
|
+
avatar?: string;
|
|
34
|
+
orgId: string;
|
|
35
|
+
type: 'person' | 'bot';
|
|
36
|
+
created: string;
|
|
37
|
+
}
|
|
38
|
+
export interface WebexMembership {
|
|
39
|
+
id: string;
|
|
40
|
+
roomId: string;
|
|
41
|
+
personId: string;
|
|
42
|
+
personEmail: string;
|
|
43
|
+
personDisplayName: string;
|
|
44
|
+
isModerator: boolean;
|
|
45
|
+
created: string;
|
|
46
|
+
}
|
|
47
|
+
export interface WebexConfig {
|
|
48
|
+
accessToken: string;
|
|
49
|
+
refreshToken: string;
|
|
50
|
+
expiresAt: number;
|
|
51
|
+
clientId?: string;
|
|
52
|
+
clientSecret?: string;
|
|
53
|
+
tokenType?: 'oauth' | 'manual';
|
|
54
|
+
}
|
|
55
|
+
export declare class WebexError extends Error {
|
|
56
|
+
code: string;
|
|
57
|
+
constructor(message: string, code: string);
|
|
58
|
+
}
|
|
59
|
+
export declare const WebexSpaceSchema: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
title: z.ZodString;
|
|
62
|
+
type: z.ZodEnum<{
|
|
63
|
+
group: "group";
|
|
64
|
+
direct: "direct";
|
|
65
|
+
}>;
|
|
66
|
+
isLocked: z.ZodBoolean;
|
|
67
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
68
|
+
lastActivity: z.ZodString;
|
|
69
|
+
created: z.ZodString;
|
|
70
|
+
creatorId: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export declare const WebexMessageSchema: z.ZodObject<{
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
roomId: z.ZodString;
|
|
75
|
+
roomType: z.ZodEnum<{
|
|
76
|
+
group: "group";
|
|
77
|
+
direct: "direct";
|
|
78
|
+
}>;
|
|
79
|
+
text: z.ZodOptional<z.ZodString>;
|
|
80
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
81
|
+
html: z.ZodOptional<z.ZodString>;
|
|
82
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
personId: z.ZodString;
|
|
84
|
+
personEmail: z.ZodString;
|
|
85
|
+
created: z.ZodString;
|
|
86
|
+
parentId: z.ZodOptional<z.ZodString>;
|
|
87
|
+
mentionedPeople: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export declare const WebexPersonSchema: z.ZodObject<{
|
|
90
|
+
id: z.ZodString;
|
|
91
|
+
emails: z.ZodArray<z.ZodString>;
|
|
92
|
+
displayName: z.ZodString;
|
|
93
|
+
nickName: z.ZodOptional<z.ZodString>;
|
|
94
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
95
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
96
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
97
|
+
orgId: z.ZodString;
|
|
98
|
+
type: z.ZodEnum<{
|
|
99
|
+
bot: "bot";
|
|
100
|
+
person: "person";
|
|
101
|
+
}>;
|
|
102
|
+
created: z.ZodString;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
export declare const WebexMembershipSchema: z.ZodObject<{
|
|
105
|
+
id: z.ZodString;
|
|
106
|
+
roomId: z.ZodString;
|
|
107
|
+
personId: z.ZodString;
|
|
108
|
+
personEmail: z.ZodString;
|
|
109
|
+
personDisplayName: z.ZodString;
|
|
110
|
+
isModerator: z.ZodBoolean;
|
|
111
|
+
created: z.ZodString;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
export declare const WebexConfigSchema: z.ZodObject<{
|
|
114
|
+
accessToken: z.ZodString;
|
|
115
|
+
refreshToken: z.ZodString;
|
|
116
|
+
expiresAt: z.ZodNumber;
|
|
117
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
118
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
119
|
+
tokenType: z.ZodOptional<z.ZodEnum<{
|
|
120
|
+
manual: "manual";
|
|
121
|
+
oauth: "oauth";
|
|
122
|
+
}>>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/platforms/webex/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAA;IACxB,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EA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AM,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAC/B;AAED,qBAAa,UAAW,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAA;gBAEA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;iBAS3B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;iBAa7B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;iBAW5B,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;iBAQhC,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;iBAO5B,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export class WebexError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(message, code) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'WebexError';
|
|
7
|
+
this.code = code;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const WebexSpaceSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
title: z.string(),
|
|
13
|
+
type: z.enum(['group', 'direct']),
|
|
14
|
+
isLocked: z.boolean(),
|
|
15
|
+
teamId: z.string().optional(),
|
|
16
|
+
lastActivity: z.string(),
|
|
17
|
+
created: z.string(),
|
|
18
|
+
creatorId: z.string(),
|
|
19
|
+
});
|
|
20
|
+
export const WebexMessageSchema = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
roomId: z.string(),
|
|
23
|
+
roomType: z.enum(['group', 'direct']),
|
|
24
|
+
text: z.string().optional(),
|
|
25
|
+
markdown: z.string().optional(),
|
|
26
|
+
html: z.string().optional(),
|
|
27
|
+
files: z.array(z.string()).optional(),
|
|
28
|
+
personId: z.string(),
|
|
29
|
+
personEmail: z.string(),
|
|
30
|
+
created: z.string(),
|
|
31
|
+
parentId: z.string().optional(),
|
|
32
|
+
mentionedPeople: z.array(z.string()).optional(),
|
|
33
|
+
});
|
|
34
|
+
export const WebexPersonSchema = z.object({
|
|
35
|
+
id: z.string(),
|
|
36
|
+
emails: z.array(z.string()),
|
|
37
|
+
displayName: z.string(),
|
|
38
|
+
nickName: z.string().optional(),
|
|
39
|
+
firstName: z.string().optional(),
|
|
40
|
+
lastName: z.string().optional(),
|
|
41
|
+
avatar: z.string().optional(),
|
|
42
|
+
orgId: z.string(),
|
|
43
|
+
type: z.enum(['person', 'bot']),
|
|
44
|
+
created: z.string(),
|
|
45
|
+
});
|
|
46
|
+
export const WebexMembershipSchema = z.object({
|
|
47
|
+
id: z.string(),
|
|
48
|
+
roomId: z.string(),
|
|
49
|
+
personId: z.string(),
|
|
50
|
+
personEmail: z.string(),
|
|
51
|
+
personDisplayName: z.string(),
|
|
52
|
+
isModerator: z.boolean(),
|
|
53
|
+
created: z.string(),
|
|
54
|
+
});
|
|
55
|
+
export const WebexConfigSchema = z.object({
|
|
56
|
+
accessToken: z.string(),
|
|
57
|
+
refreshToken: z.string(),
|
|
58
|
+
expiresAt: z.number(),
|
|
59
|
+
clientId: z.string().optional(),
|
|
60
|
+
clientSecret: z.string().optional(),
|
|
61
|
+
tokenType: z.enum(['oauth', 'manual']).optional(),
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/platforms/webex/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA4DvB,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,IAAI,CAAQ;IAEZ,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,IAAI,GAA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AAE,CAAC,CAAC,MAAM,EAAE;IACxB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;CAClD,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthHint, AuthIO, PlatformAdapter, UnifiedChannel, UnifiedMessage } from './types.js';
|
|
2
|
+
export declare class WebexAdapter implements PlatformAdapter {
|
|
3
|
+
readonly name = "Webex";
|
|
4
|
+
private client;
|
|
5
|
+
private personEmail;
|
|
6
|
+
login(): Promise<void>;
|
|
7
|
+
getChannels(): Promise<UnifiedChannel[]>;
|
|
8
|
+
getMessages(channelId: string, limit?: number): Promise<UnifiedMessage[]>;
|
|
9
|
+
sendMessage(channelId: string, text: string): Promise<void>;
|
|
10
|
+
getAuthHint(): AuthHint;
|
|
11
|
+
authenticate(io: AuthIO): Promise<void>;
|
|
12
|
+
private ensureClient;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=webex-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webex-adapter.d.ts","sourceRoot":"","sources":["../../../../src/tui/adapters/webex-adapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEhG,qBAAa,YAAa,YAAW,eAAe;IAClD,QAAQ,CAAC,IAAI,WAAU;IAEvB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,WAAW,CAAsB;IAEnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtB,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IASxC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAcrE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjE,WAAW,IAAI,QAAQ;IAOjB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B7C,OAAO,CAAC,YAAY;CAKrB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { exec } from 'node:child_process';
|
|
2
|
+
import { WebexClient } from '../../platforms/webex/client.js';
|
|
3
|
+
import { WebexCredentialManager } from '../../platforms/webex/credential-manager.js';
|
|
4
|
+
import { getWebexAppCredentials } from '../../platforms/webex/app-config.js';
|
|
5
|
+
export class WebexAdapter {
|
|
6
|
+
name = 'Webex';
|
|
7
|
+
client = null;
|
|
8
|
+
personEmail = null;
|
|
9
|
+
async login() {
|
|
10
|
+
const client = new WebexClient();
|
|
11
|
+
await client.login();
|
|
12
|
+
const me = await client.testAuth();
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.personEmail = me.emails[0] ?? null;
|
|
15
|
+
}
|
|
16
|
+
async getChannels() {
|
|
17
|
+
this.ensureClient();
|
|
18
|
+
const spaces = await this.client.listSpaces();
|
|
19
|
+
return spaces.map((space) => ({
|
|
20
|
+
id: space.id,
|
|
21
|
+
name: space.title,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
async getMessages(channelId, limit = 50) {
|
|
25
|
+
this.ensureClient();
|
|
26
|
+
const messages = await this.client.listMessages(channelId, { max: limit });
|
|
27
|
+
return messages
|
|
28
|
+
.map((msg) => ({
|
|
29
|
+
id: msg.id,
|
|
30
|
+
channelId: msg.roomId,
|
|
31
|
+
author: msg.personEmail,
|
|
32
|
+
content: msg.text ?? '',
|
|
33
|
+
timestamp: msg.created,
|
|
34
|
+
}))
|
|
35
|
+
.reverse();
|
|
36
|
+
}
|
|
37
|
+
async sendMessage(channelId, text) {
|
|
38
|
+
this.ensureClient();
|
|
39
|
+
await this.client.sendMessage(channelId, text);
|
|
40
|
+
}
|
|
41
|
+
getAuthHint() {
|
|
42
|
+
return {
|
|
43
|
+
command: 'agent-webex auth login',
|
|
44
|
+
description: 'Authenticate with Cisco Webex using OAuth Device Grant. Run the command below to start.',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async authenticate(io) {
|
|
48
|
+
const credManager = new WebexCredentialManager();
|
|
49
|
+
const { clientId, clientSecret } = getWebexAppCredentials();
|
|
50
|
+
io.print('Starting Webex OAuth Device Grant flow...');
|
|
51
|
+
const device = await credManager.requestDeviceCode(clientId);
|
|
52
|
+
io.print(`\nOpen this URL in your browser:\n ${device.verificationUriComplete}`);
|
|
53
|
+
io.print(`\nOr go to ${device.verificationUri} and enter code: ${device.userCode}`);
|
|
54
|
+
openBrowser(device.verificationUriComplete);
|
|
55
|
+
io.print('\nWaiting for authorization...');
|
|
56
|
+
const config = await credManager.pollDeviceToken(device.deviceCode, device.interval, device.expiresIn, clientId, clientSecret);
|
|
57
|
+
await credManager.saveConfig(config);
|
|
58
|
+
const client = new WebexClient();
|
|
59
|
+
await client.login({ token: config.accessToken });
|
|
60
|
+
const me = await client.testAuth();
|
|
61
|
+
this.client = client;
|
|
62
|
+
this.personEmail = me.emails[0] ?? null;
|
|
63
|
+
io.print(`\nAuthenticated as ${me.displayName} (${this.personEmail})`);
|
|
64
|
+
}
|
|
65
|
+
ensureClient() {
|
|
66
|
+
if (!this.client) {
|
|
67
|
+
throw new Error('Not logged in. Call login() first.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function openBrowser(url) {
|
|
72
|
+
const command = process.platform === 'darwin'
|
|
73
|
+
? `open "${url}"`
|
|
74
|
+
: process.platform === 'win32'
|
|
75
|
+
? `start "" "${url}"`
|
|
76
|
+
: `xdg-open "${url}"`;
|
|
77
|
+
exec(command);
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=webex-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webex-adapter.js","sourceRoot":"","sources":["../../../../src/tui/adapters/webex-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAIrE,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,OAAO,CAAA;IAEf,MAAM,GAAuB,IAAI,CAAA;IACjC,WAAW,GAAkB,IAAI,CAAA;IAEzC,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;QAChC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACpB,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,WAAW;QACf,IAAI,CAAC,YAAY,EAAE,CAAA;QACnB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAO,CAAC,UAAU,EAAE,CAAA;QAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC5B,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,KAAK;SAClB,CAAC,CAAC,CAAA;IACL,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAiB,EAAE,KAAK,GAAG,EAAE;QAC7C,IAAI,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tui/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/tui/app.ts"],"names":[],"mappings":"AA8BA,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAopB/C"}
|
package/dist/src/tui/app.js
CHANGED
|
@@ -2,6 +2,7 @@ import blessed from 'blessed';
|
|
|
2
2
|
import { SlackAdapter } from './adapters/slack-adapter.js';
|
|
3
3
|
import { DiscordAdapter } from './adapters/discord-adapter.js';
|
|
4
4
|
import { TeamsAdapter } from './adapters/teams-adapter.js';
|
|
5
|
+
import { WebexAdapter } from './adapters/webex-adapter.js';
|
|
5
6
|
import { TelegramAdapter } from './adapters/telegram-adapter.js';
|
|
6
7
|
import { WhatsAppAdapter } from './adapters/whatsapp-adapter.js';
|
|
7
8
|
import { LineAdapter } from './adapters/line-adapter.js';
|
|
@@ -20,6 +21,7 @@ export async function createApp() {
|
|
|
20
21
|
{ adapter: new SlackAdapter(), label: 'Slack', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|
|
21
22
|
{ adapter: new DiscordAdapter(), label: 'Discord', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|
|
22
23
|
{ adapter: new TeamsAdapter(), label: 'Teams', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|
|
24
|
+
{ adapter: new WebexAdapter(), label: 'Webex', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|
|
23
25
|
{ adapter: new TelegramAdapter(), label: 'Telegram', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|
|
24
26
|
{ adapter: new WhatsAppAdapter(), label: 'WhatsApp', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|
|
25
27
|
{ adapter: new LineAdapter(), label: 'LINE', enabled: false, channels: null, workspaces: null, listening: false, lastChannelId: null },
|