@heyamiko/openclaw-plugin 0.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/README.md +200 -0
- package/contracts/channel-config.schema.json +87 -0
- package/contracts/platform-ack.schema.json +25 -0
- package/contracts/platform-events.schema.json +87 -0
- package/contracts/platform-outbound.schema.json +47 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/src/accounts.d.ts +30 -0
- package/dist/src/accounts.d.ts.map +1 -0
- package/dist/src/accounts.js +115 -0
- package/dist/src/accounts.js.map +1 -0
- package/dist/src/api.d.ts +13 -0
- package/dist/src/api.d.ts.map +1 -0
- package/dist/src/api.js +45 -0
- package/dist/src/api.js.map +1 -0
- package/dist/src/channel.d.ts +174 -0
- package/dist/src/channel.d.ts.map +1 -0
- package/dist/src/channel.js +140 -0
- package/dist/src/channel.js.map +1 -0
- package/dist/src/config-schema.d.ts +92 -0
- package/dist/src/config-schema.d.ts.map +1 -0
- package/dist/src/config-schema.js +17 -0
- package/dist/src/config-schema.js.map +1 -0
- package/dist/src/monitor.d.ts +19 -0
- package/dist/src/monitor.d.ts.map +1 -0
- package/dist/src/monitor.js +432 -0
- package/dist/src/monitor.js.map +1 -0
- package/dist/src/reply-prefix.d.ts +12 -0
- package/dist/src/reply-prefix.d.ts.map +1 -0
- package/dist/src/reply-prefix.js +8 -0
- package/dist/src/reply-prefix.js.map +1 -0
- package/dist/src/runtime.d.ts +57 -0
- package/dist/src/runtime.d.ts.map +1 -0
- package/dist/src/runtime.js +28 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/send.d.ts +8 -0
- package/dist/src/send.d.ts.map +1 -0
- package/dist/src/send.js +51 -0
- package/dist/src/send.js.map +1 -0
- package/dist/src/status.d.ts +19 -0
- package/dist/src/status.d.ts.map +1 -0
- package/dist/src/status.js +51 -0
- package/dist/src/status.js.map +1 -0
- package/dist/src/types.d.ts +79 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/openclaw.plugin.json +51 -0
- package/package.json +73 -0
- package/skills/amiko/SKILL.md +287 -0
- package/skills/amiko/cli.js +521 -0
- package/skills/amiko/lib.js +634 -0
- package/skills/composio/SKILL.md +102 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export const DEFAULT_ACCOUNT_ID = "main";
|
|
2
|
+
export const DEFAULT_PLATFORM_API_BASE_URL = "https://platform.heyamiko.com";
|
|
3
|
+
export const DEFAULT_CHAT_API_BASE_URL = "https://api.amiko.app";
|
|
4
|
+
export function normalizeAccountId(id) {
|
|
5
|
+
return id.toLowerCase().trim();
|
|
6
|
+
}
|
|
7
|
+
function normalizeBaseUrl(url, fallback) {
|
|
8
|
+
const value = String(url || "").trim();
|
|
9
|
+
if (!value)
|
|
10
|
+
return fallback;
|
|
11
|
+
return value.replace(/\/+$/, "").replace(/\/api$/, "");
|
|
12
|
+
}
|
|
13
|
+
function getAccountEntries(amiko) {
|
|
14
|
+
if (!amiko?.accounts || Object.keys(amiko.accounts).length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
return Object.entries(amiko.accounts).map(([accountId, config]) => [
|
|
18
|
+
normalizeAccountId(accountId),
|
|
19
|
+
config,
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
export function listAmikoAccountIds(cfg) {
|
|
23
|
+
const amiko = cfg.channels?.amiko;
|
|
24
|
+
const accounts = getAccountEntries(amiko);
|
|
25
|
+
if (accounts.length === 0)
|
|
26
|
+
return [DEFAULT_ACCOUNT_ID];
|
|
27
|
+
return accounts.map(([accountId]) => accountId).sort();
|
|
28
|
+
}
|
|
29
|
+
export function resolveDefaultAmikoAccountId(cfg) {
|
|
30
|
+
const amiko = cfg.channels?.amiko;
|
|
31
|
+
if (!amiko)
|
|
32
|
+
return DEFAULT_ACCOUNT_ID;
|
|
33
|
+
if (amiko.defaultAccount)
|
|
34
|
+
return normalizeAccountId(amiko.defaultAccount);
|
|
35
|
+
const accounts = getAccountEntries(amiko);
|
|
36
|
+
if (accounts.length === 0)
|
|
37
|
+
return DEFAULT_ACCOUNT_ID;
|
|
38
|
+
const hasMain = accounts.some(([accountId]) => accountId === DEFAULT_ACCOUNT_ID);
|
|
39
|
+
if (hasMain)
|
|
40
|
+
return DEFAULT_ACCOUNT_ID;
|
|
41
|
+
return accounts
|
|
42
|
+
.map(([accountId]) => accountId)
|
|
43
|
+
.sort()[0] ?? DEFAULT_ACCOUNT_ID;
|
|
44
|
+
}
|
|
45
|
+
export function resolveAmikoAccountConfig(amiko, accountId) {
|
|
46
|
+
const normalizedAccountId = normalizeAccountId(accountId);
|
|
47
|
+
if (!amiko.accounts || Object.keys(amiko.accounts).length === 0) {
|
|
48
|
+
return {
|
|
49
|
+
name: amiko.name,
|
|
50
|
+
enabled: amiko.enabled,
|
|
51
|
+
twinId: amiko.twinId,
|
|
52
|
+
token: amiko.token,
|
|
53
|
+
platformApiBaseUrl: amiko.platformApiBaseUrl ?? amiko.apiBaseUrl,
|
|
54
|
+
chatApiBaseUrl: amiko.chatApiBaseUrl ?? amiko.apiBaseUrl,
|
|
55
|
+
apiBaseUrl: amiko.apiBaseUrl,
|
|
56
|
+
webhookPath: amiko.webhookPath,
|
|
57
|
+
webhookSecret: amiko.webhookSecret,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const accountMap = Object.fromEntries(getAccountEntries(amiko));
|
|
61
|
+
const perAccount = accountMap[normalizedAccountId] ?? {};
|
|
62
|
+
return {
|
|
63
|
+
name: perAccount.name ?? amiko.name,
|
|
64
|
+
enabled: perAccount.enabled ?? amiko.enabled,
|
|
65
|
+
twinId: perAccount.twinId ?? amiko.twinId,
|
|
66
|
+
token: perAccount.token ?? amiko.token,
|
|
67
|
+
platformApiBaseUrl: perAccount.platformApiBaseUrl ??
|
|
68
|
+
perAccount.apiBaseUrl ??
|
|
69
|
+
amiko.platformApiBaseUrl ??
|
|
70
|
+
amiko.apiBaseUrl,
|
|
71
|
+
chatApiBaseUrl: perAccount.chatApiBaseUrl ??
|
|
72
|
+
perAccount.apiBaseUrl ??
|
|
73
|
+
amiko.chatApiBaseUrl ??
|
|
74
|
+
amiko.apiBaseUrl,
|
|
75
|
+
apiBaseUrl: perAccount.apiBaseUrl ?? amiko.apiBaseUrl,
|
|
76
|
+
webhookPath: perAccount.webhookPath ?? amiko.webhookPath,
|
|
77
|
+
webhookSecret: perAccount.webhookSecret ?? amiko.webhookSecret,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function resolveAmikoAccount(params) {
|
|
81
|
+
const { cfg, accountId } = params;
|
|
82
|
+
const normalizedAccountId = normalizeAccountId(accountId);
|
|
83
|
+
const amiko = cfg.channels?.amiko ?? {};
|
|
84
|
+
const config = resolveAmikoAccountConfig(amiko, normalizedAccountId);
|
|
85
|
+
if (!config.twinId?.trim()) {
|
|
86
|
+
throw new Error(`Amiko account "${normalizedAccountId}" has no twinId configured`);
|
|
87
|
+
}
|
|
88
|
+
if (!config.token?.trim()) {
|
|
89
|
+
throw new Error(`Amiko account "${normalizedAccountId}" has no token configured`);
|
|
90
|
+
}
|
|
91
|
+
const platformApiBaseUrl = normalizeBaseUrl(config.platformApiBaseUrl ?? config.apiBaseUrl, DEFAULT_PLATFORM_API_BASE_URL);
|
|
92
|
+
const chatApiBaseUrl = normalizeBaseUrl(config.chatApiBaseUrl ?? config.apiBaseUrl, DEFAULT_CHAT_API_BASE_URL);
|
|
93
|
+
return {
|
|
94
|
+
accountId: normalizedAccountId,
|
|
95
|
+
twinId: config.twinId,
|
|
96
|
+
name: config.name,
|
|
97
|
+
enabled: config.enabled !== false,
|
|
98
|
+
token: config.token,
|
|
99
|
+
platformApiBaseUrl,
|
|
100
|
+
chatApiBaseUrl,
|
|
101
|
+
config,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function listEnabledAmikoAccounts(cfg) {
|
|
105
|
+
return listAmikoAccountIds(cfg).filter((id) => {
|
|
106
|
+
try {
|
|
107
|
+
const account = resolveAmikoAccount({ cfg, accountId: id });
|
|
108
|
+
return account.enabled;
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/accounts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,+BAA+B,CAAC;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEjE,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAC3C,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAuB,EAAE,QAAgB;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAmB;IAC5C,IAAI,CAAC,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS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kB;QAClB,cAAc;QACd,MAAM;KACP,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,GAA2C;IAClF,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE;QAC5C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,mBAAmB,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;YAC5D,OAAO,OAAO,CAAC,OAAO,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AmikoOutboundPayload, AmikoOutboundResponse } from "./types.js";
|
|
2
|
+
export type AmikoApiOptions = {
|
|
3
|
+
chatApiBaseUrl: string;
|
|
4
|
+
token: string;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class AmikoApiError extends Error {
|
|
8
|
+
readonly statusCode: number;
|
|
9
|
+
readonly retriable: boolean;
|
|
10
|
+
constructor(message: string, statusCode: number, retriable: boolean);
|
|
11
|
+
}
|
|
12
|
+
export declare function sendAmikoOutbound(options: AmikoApiOptions, payload: AmikoOutboundPayload): Promise<AmikoOutboundResponse>;
|
|
13
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,eAAe,GAAG;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,aAAc,SAAQ,KAAK;aAGpB,UAAU,EAAE,MAAM;aAClB,SAAS,EAAE,OAAO;gBAFlC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,OAAO;CAKrC;AAoCD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,CAMhC"}
|
package/dist/src/api.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class AmikoApiError extends Error {
|
|
2
|
+
statusCode;
|
|
3
|
+
retriable;
|
|
4
|
+
constructor(message, statusCode, retriable) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.retriable = retriable;
|
|
8
|
+
this.name = "AmikoApiError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function apiRequest(method, url, options, body) {
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const timeoutId = setTimeout(() => controller.abort(), options.timeoutMs ?? 10_000);
|
|
14
|
+
try {
|
|
15
|
+
const res = await fetch(url, {
|
|
16
|
+
method,
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${options.token}`,
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
Accept: "application/json",
|
|
21
|
+
},
|
|
22
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
23
|
+
signal: controller.signal,
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
const text = await res.text().catch(() => "");
|
|
27
|
+
const retriable = res.status === 429 || res.status >= 500;
|
|
28
|
+
throw new AmikoApiError(`HTTP ${res.status}: ${text}`, res.status, retriable);
|
|
29
|
+
}
|
|
30
|
+
if (res.status === 204)
|
|
31
|
+
return undefined;
|
|
32
|
+
return res.json();
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
clearTimeout(timeoutId);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function sendAmikoOutbound(options, payload) {
|
|
39
|
+
const url = `${options.chatApiBaseUrl}/api/internal/openclaw/amiko/messages`;
|
|
40
|
+
console.log(`[amiko:api] sendAmikoOutbound POST ${url} conversationId=${payload.conversationId}`);
|
|
41
|
+
const result = await apiRequest("POST", url, options, payload);
|
|
42
|
+
console.log(`[amiko:api] sendAmikoOutbound response:`, result);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGpB;IACA;IAHlB,YACE,OAAe,EACC,UAAkB,EAClB,SAAkB;QAElC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,eAAU,GAAV,UAAU,CAAQ;QAClB,cAAS,GAAT,SAAS,CAAS;QAGlC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,KAAK,UAAU,UAAU,CACvB,MAAsB,EACtB,GAAW,EACX,OAAwB,EACxB,IAAc;IAEd,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC,CAAC;IAEpF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,MAAM;YACN,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,OAAO,CAAC,KAAK,EAAE;gBACxC,cAAc,EAAE,kBAAkB;gBAClC,MAAM,EAAE,kBAAkB;aAC3B;YACD,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YAC3D,MAAM,EAAE,UAAU,CAAC,MAAM;SAC1B,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC;YAC1D,MAAM,IAAI,aAAa,CAAC,QAAQ,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,SAAc,CAAC;QAC9C,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;IAClC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAwB,EACxB,OAA6B;IAE7B,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,cAAc,uCAAuC,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,sCAAsC,GAAG,mBAAmB,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,MAAM,UAAU,CAAwB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { ResolvedAmikoAccount } from "./types.js";
|
|
2
|
+
export declare const amikoPlugin: {
|
|
3
|
+
id: string;
|
|
4
|
+
meta: {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
selectionLabel: string;
|
|
8
|
+
docsPath: string;
|
|
9
|
+
blurb: string;
|
|
10
|
+
order: number;
|
|
11
|
+
};
|
|
12
|
+
capabilities: {
|
|
13
|
+
chatTypes: readonly ["direct", "group"];
|
|
14
|
+
media: boolean;
|
|
15
|
+
reactions: boolean;
|
|
16
|
+
threads: boolean;
|
|
17
|
+
polls: boolean;
|
|
18
|
+
nativeCommands: boolean;
|
|
19
|
+
blockStreaming: boolean;
|
|
20
|
+
};
|
|
21
|
+
reload: {
|
|
22
|
+
configPrefixes: string[];
|
|
23
|
+
};
|
|
24
|
+
configSchema: import("zod").ZodObject<{
|
|
25
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
26
|
+
enabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
27
|
+
twinId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
28
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
29
|
+
platformApiBaseUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
30
|
+
chatApiBaseUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
31
|
+
apiBaseUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
32
|
+
webhookPath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
33
|
+
webhookSecret: import("zod").ZodOptional<import("zod").ZodString>;
|
|
34
|
+
} & {
|
|
35
|
+
accounts: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
36
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
37
|
+
enabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
38
|
+
twinId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
39
|
+
token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
40
|
+
platformApiBaseUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
41
|
+
chatApiBaseUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
42
|
+
apiBaseUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
43
|
+
webhookPath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
44
|
+
webhookSecret: import("zod").ZodOptional<import("zod").ZodString>;
|
|
45
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
46
|
+
name?: string;
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
twinId?: string;
|
|
49
|
+
token?: string;
|
|
50
|
+
platformApiBaseUrl?: string;
|
|
51
|
+
chatApiBaseUrl?: string;
|
|
52
|
+
apiBaseUrl?: string;
|
|
53
|
+
webhookPath?: string;
|
|
54
|
+
webhookSecret?: string;
|
|
55
|
+
}, {
|
|
56
|
+
name?: string;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
twinId?: string;
|
|
59
|
+
token?: string;
|
|
60
|
+
platformApiBaseUrl?: string;
|
|
61
|
+
chatApiBaseUrl?: string;
|
|
62
|
+
apiBaseUrl?: string;
|
|
63
|
+
webhookPath?: string;
|
|
64
|
+
webhookSecret?: string;
|
|
65
|
+
}>>>;
|
|
66
|
+
defaultAccount: import("zod").ZodOptional<import("zod").ZodString>;
|
|
67
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
68
|
+
name?: string;
|
|
69
|
+
enabled?: boolean;
|
|
70
|
+
twinId?: string;
|
|
71
|
+
token?: string;
|
|
72
|
+
platformApiBaseUrl?: string;
|
|
73
|
+
chatApiBaseUrl?: string;
|
|
74
|
+
apiBaseUrl?: string;
|
|
75
|
+
webhookPath?: string;
|
|
76
|
+
webhookSecret?: string;
|
|
77
|
+
accounts?: Record<string, {
|
|
78
|
+
name?: string;
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
twinId?: string;
|
|
81
|
+
token?: string;
|
|
82
|
+
platformApiBaseUrl?: string;
|
|
83
|
+
chatApiBaseUrl?: string;
|
|
84
|
+
apiBaseUrl?: string;
|
|
85
|
+
webhookPath?: string;
|
|
86
|
+
webhookSecret?: string;
|
|
87
|
+
}>;
|
|
88
|
+
defaultAccount?: string;
|
|
89
|
+
}, {
|
|
90
|
+
name?: string;
|
|
91
|
+
enabled?: boolean;
|
|
92
|
+
twinId?: string;
|
|
93
|
+
token?: string;
|
|
94
|
+
platformApiBaseUrl?: string;
|
|
95
|
+
chatApiBaseUrl?: string;
|
|
96
|
+
apiBaseUrl?: string;
|
|
97
|
+
webhookPath?: string;
|
|
98
|
+
webhookSecret?: string;
|
|
99
|
+
accounts?: Record<string, {
|
|
100
|
+
name?: string;
|
|
101
|
+
enabled?: boolean;
|
|
102
|
+
twinId?: string;
|
|
103
|
+
token?: string;
|
|
104
|
+
platformApiBaseUrl?: string;
|
|
105
|
+
chatApiBaseUrl?: string;
|
|
106
|
+
apiBaseUrl?: string;
|
|
107
|
+
webhookPath?: string;
|
|
108
|
+
webhookSecret?: string;
|
|
109
|
+
}>;
|
|
110
|
+
defaultAccount?: string;
|
|
111
|
+
}>;
|
|
112
|
+
config: {
|
|
113
|
+
listAccountIds(cfg: unknown): string[];
|
|
114
|
+
resolveAccount(cfg: unknown, accountId: string): ResolvedAmikoAccount;
|
|
115
|
+
defaultAccountId(cfg: unknown): string;
|
|
116
|
+
isConfigured(account: ResolvedAmikoAccount): boolean;
|
|
117
|
+
describeAccount(account: ResolvedAmikoAccount): import("./status.js").AccountSnapshot;
|
|
118
|
+
inspectAccount(cfg: unknown, accountId: string): Record<string, unknown>;
|
|
119
|
+
};
|
|
120
|
+
security: {
|
|
121
|
+
resolveDmPolicy(_params: {
|
|
122
|
+
account: ResolvedAmikoAccount;
|
|
123
|
+
}): {
|
|
124
|
+
policy: "open";
|
|
125
|
+
allowFrom: string[];
|
|
126
|
+
allowFromPath: string;
|
|
127
|
+
approveHint: string;
|
|
128
|
+
normalizeEntry: (e: string) => string;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
groups: {
|
|
132
|
+
resolveRequireMention(): boolean;
|
|
133
|
+
};
|
|
134
|
+
outbound: {
|
|
135
|
+
deliveryMode: "direct";
|
|
136
|
+
textChunkLimit: number;
|
|
137
|
+
chunkerMode: "markdown";
|
|
138
|
+
sendText({ to, text, account }: {
|
|
139
|
+
to: string;
|
|
140
|
+
text: string;
|
|
141
|
+
account: ResolvedAmikoAccount;
|
|
142
|
+
cfg: unknown;
|
|
143
|
+
accountId: string;
|
|
144
|
+
}): Promise<import("./types.js").AmikoSendResult>;
|
|
145
|
+
sendMedia({ to, text, mediaUrl, account }: {
|
|
146
|
+
to: string;
|
|
147
|
+
text: string;
|
|
148
|
+
mediaUrl: string;
|
|
149
|
+
cfg: unknown;
|
|
150
|
+
accountId: string;
|
|
151
|
+
account: ResolvedAmikoAccount;
|
|
152
|
+
}): Promise<import("./types.js").AmikoSendResult>;
|
|
153
|
+
};
|
|
154
|
+
status: {
|
|
155
|
+
probeAccount({ account }: {
|
|
156
|
+
account: ResolvedAmikoAccount;
|
|
157
|
+
}): Promise<import("./status.js").ProbeResult>;
|
|
158
|
+
buildAccountSnapshot({ account }: {
|
|
159
|
+
account: ResolvedAmikoAccount;
|
|
160
|
+
runtime: unknown;
|
|
161
|
+
}): import("./status.js").AccountSnapshot;
|
|
162
|
+
};
|
|
163
|
+
gateway: {
|
|
164
|
+
startAccount(ctx: {
|
|
165
|
+
account: ResolvedAmikoAccount;
|
|
166
|
+
accountId: string;
|
|
167
|
+
cfg: unknown;
|
|
168
|
+
runtime: any;
|
|
169
|
+
abortSignal: AbortSignal;
|
|
170
|
+
setStatus: (patch: any) => void;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAmBvD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA6BA,OAAO;4BAIP,OAAO,aAAa,MAAM,GAAG,oBAAoB;8BAI/C,OAAO,GAAG,MAAM;8BAIhB,oBAAoB,GAAG,OAAO;iCAI3B,oBAAoB;4BAIzB,OAAO,aAAa,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;iCAM/C;YAAE,OAAO,EAAE,oBAAoB,CAAA;SAAE;;;;;gCAMlC,MAAM;;;;iCAML,OAAO;;;;;;wCAUM;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,oBAAoB,CAAC;YAAC,GAAG,EAAE,OAAO,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE;mDAIjF;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,OAAO,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,oBAAoB,CAAA;SAAE;;;kCAM/H;YAAE,OAAO,EAAE,oBAAoB,CAAA;SAAE;0CAI/B;YAAE,OAAO,EAAE,oBAAoB,CAAC;YAAC,OAAO,EAAE,OAAO,CAAA;SAAE;;;0BAM7D;YACtB,OAAO,EAAE,oBAAoB,CAAC;YAC9B,SAAS,EAAE,MAAM,CAAC;YAClB,GAAG,EAAE,OAAO,CAAC;YACb,OAAO,EAAE,GAAG,CAAC;YACb,WAAW,EAAE,WAAW,CAAC;YACzB,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;SACjC;;CAwDJ,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AmikoConfigSchema } from "./config-schema.js";
|
|
2
|
+
import { listAmikoAccountIds, resolveAmikoAccount, resolveDefaultAmikoAccountId, } from "./accounts.js";
|
|
3
|
+
import { sendTextAmiko, sendMediaAmiko } from "./send.js";
|
|
4
|
+
import { probeAmikoAccount, buildAmikoAccountSnapshot, inspectAmikoAccount } from "./status.js";
|
|
5
|
+
import { getAmikoRuntime, setWebhookDispatcher } from "./runtime.js";
|
|
6
|
+
// Local builds use zod v3 while the runtime SDK may use a newer zod type surface.
|
|
7
|
+
// Keep this wrapper as a pass-through so the plugin stays buildable across both.
|
|
8
|
+
function buildChannelConfigSchema(schema) {
|
|
9
|
+
return schema;
|
|
10
|
+
}
|
|
11
|
+
const activeRouteUnregisters = new Map();
|
|
12
|
+
export const amikoPlugin = {
|
|
13
|
+
id: "amiko",
|
|
14
|
+
meta: {
|
|
15
|
+
id: "amiko",
|
|
16
|
+
label: "Amiko",
|
|
17
|
+
selectionLabel: "Amiko (Webhook)",
|
|
18
|
+
docsPath: "/channels/amiko",
|
|
19
|
+
blurb: "Connect OpenClaw to Amiko platform for direct and group chat via webhook.",
|
|
20
|
+
order: 90,
|
|
21
|
+
},
|
|
22
|
+
capabilities: {
|
|
23
|
+
chatTypes: ["direct", "group"],
|
|
24
|
+
media: true,
|
|
25
|
+
reactions: false,
|
|
26
|
+
threads: false,
|
|
27
|
+
polls: false,
|
|
28
|
+
nativeCommands: false,
|
|
29
|
+
blockStreaming: false,
|
|
30
|
+
},
|
|
31
|
+
reload: {
|
|
32
|
+
configPrefixes: ["channels.amiko"],
|
|
33
|
+
},
|
|
34
|
+
configSchema: buildChannelConfigSchema(AmikoConfigSchema),
|
|
35
|
+
config: {
|
|
36
|
+
listAccountIds(cfg) {
|
|
37
|
+
return listAmikoAccountIds(cfg);
|
|
38
|
+
},
|
|
39
|
+
resolveAccount(cfg, accountId) {
|
|
40
|
+
return resolveAmikoAccount({ cfg: cfg, accountId });
|
|
41
|
+
},
|
|
42
|
+
defaultAccountId(cfg) {
|
|
43
|
+
return resolveDefaultAmikoAccountId(cfg);
|
|
44
|
+
},
|
|
45
|
+
isConfigured(account) {
|
|
46
|
+
return Boolean(account.token?.trim());
|
|
47
|
+
},
|
|
48
|
+
describeAccount(account) {
|
|
49
|
+
return buildAmikoAccountSnapshot(account);
|
|
50
|
+
},
|
|
51
|
+
inspectAccount(cfg, accountId) {
|
|
52
|
+
return inspectAmikoAccount(resolveAmikoAccount({ cfg: cfg, accountId }));
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
security: {
|
|
56
|
+
resolveDmPolicy(_params) {
|
|
57
|
+
return {
|
|
58
|
+
policy: "open",
|
|
59
|
+
allowFrom: ["*"],
|
|
60
|
+
allowFromPath: "channels.amiko.accounts",
|
|
61
|
+
approveHint: "DM and group access are controlled by Amiko conversations.",
|
|
62
|
+
normalizeEntry: (e) => e.trim(),
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
groups: {
|
|
67
|
+
resolveRequireMention() {
|
|
68
|
+
return true;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
outbound: {
|
|
72
|
+
deliveryMode: "direct",
|
|
73
|
+
textChunkLimit: 4_000,
|
|
74
|
+
chunkerMode: "markdown",
|
|
75
|
+
async sendText({ to, text, account }) {
|
|
76
|
+
return sendTextAmiko(to, text, account);
|
|
77
|
+
},
|
|
78
|
+
async sendMedia({ to, text, mediaUrl, account }) {
|
|
79
|
+
return sendMediaAmiko(to, text, mediaUrl, undefined, account);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
status: {
|
|
83
|
+
async probeAccount({ account }) {
|
|
84
|
+
return probeAmikoAccount(account);
|
|
85
|
+
},
|
|
86
|
+
buildAccountSnapshot({ account }) {
|
|
87
|
+
return buildAmikoAccountSnapshot(account);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
gateway: {
|
|
91
|
+
async startAccount(ctx) {
|
|
92
|
+
try {
|
|
93
|
+
const runtime = getAmikoRuntime();
|
|
94
|
+
const { monitorAmikoProvider } = await import("./monitor.js");
|
|
95
|
+
const handle = await monitorAmikoProvider({
|
|
96
|
+
account: ctx.account,
|
|
97
|
+
config: ctx.cfg,
|
|
98
|
+
runtime,
|
|
99
|
+
abortSignal: ctx.abortSignal,
|
|
100
|
+
statusSink: (patch) => ctx.setStatus({ accountId: ctx.accountId, ...patch }),
|
|
101
|
+
});
|
|
102
|
+
const routeKey = `${ctx.accountId}:${handle.webhookPath}`;
|
|
103
|
+
const prevUnregister = activeRouteUnregisters.get(routeKey);
|
|
104
|
+
if (prevUnregister) {
|
|
105
|
+
prevUnregister();
|
|
106
|
+
activeRouteUnregisters.delete(routeKey);
|
|
107
|
+
}
|
|
108
|
+
setWebhookDispatcher(handle.webhookPath, handle.handler);
|
|
109
|
+
activeRouteUnregisters.set(routeKey, () => {
|
|
110
|
+
setWebhookDispatcher(handle.webhookPath, null);
|
|
111
|
+
});
|
|
112
|
+
let stopped = false;
|
|
113
|
+
const stop = () => {
|
|
114
|
+
if (stopped)
|
|
115
|
+
return;
|
|
116
|
+
stopped = true;
|
|
117
|
+
const unregister = activeRouteUnregisters.get(routeKey);
|
|
118
|
+
unregister?.();
|
|
119
|
+
activeRouteUnregisters.delete(routeKey);
|
|
120
|
+
handle.stop();
|
|
121
|
+
};
|
|
122
|
+
if (ctx.abortSignal.aborted) {
|
|
123
|
+
stop();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
await new Promise((resolve) => {
|
|
127
|
+
ctx.abortSignal.addEventListener("abort", () => {
|
|
128
|
+
stop();
|
|
129
|
+
resolve();
|
|
130
|
+
}, { once: true });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
console.error(`[amiko:startAccount] FAILED for account=${ctx.accountId}:`, err);
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/channel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAA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CAAC,CAAC;gBAEH,IAAI,OAAO,GAAG,KAAK,CAAC;gBACpB,MAAM,IAAI,GAAG,GAAG,EAAE;oBAChB,IAAI,OAAO;wBAAE,OAAO;oBACpB,OAAO,GAAG,IAAI,CAAC;oBACf,MAAM,UAAU,GAAG,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;oBACxD,UAAU,EAAE,EAAE,CAAC;oBACf,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAChB,CAAC,CAAC;gBAEF,IAAI,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;oBAC5B,IAAI,EAAE,CAAC;oBACP,OAAO;gBACT,CAAC;gBAED,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAClC,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAC9B,OAAO,EACP,GAAG,EAAE;wBACH,IAAI,EAAE,CAAC;wBACP,OAAO,EAAE,CAAC;oBACZ,CAAC,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,CACf,CAAC;gBACJ,CAAC,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,2CAA2C,GAAG,CAAC,SAAS,GAAG,EAAE,GAAG,CAAC,CAAC;gBAChF,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AmikoConfigSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodOptional<z.ZodString>;
|
|
4
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
+
twinId: z.ZodOptional<z.ZodString>;
|
|
6
|
+
token: z.ZodOptional<z.ZodString>;
|
|
7
|
+
platformApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
8
|
+
chatApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
9
|
+
apiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
10
|
+
webhookPath: z.ZodOptional<z.ZodString>;
|
|
11
|
+
webhookSecret: z.ZodOptional<z.ZodString>;
|
|
12
|
+
} & {
|
|
13
|
+
accounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
14
|
+
name: z.ZodOptional<z.ZodString>;
|
|
15
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
twinId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
token: z.ZodOptional<z.ZodString>;
|
|
18
|
+
platformApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
19
|
+
chatApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
20
|
+
apiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
21
|
+
webhookPath: z.ZodOptional<z.ZodString>;
|
|
22
|
+
webhookSecret: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
name?: string;
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
twinId?: string;
|
|
27
|
+
token?: string;
|
|
28
|
+
platformApiBaseUrl?: string;
|
|
29
|
+
chatApiBaseUrl?: string;
|
|
30
|
+
apiBaseUrl?: string;
|
|
31
|
+
webhookPath?: string;
|
|
32
|
+
webhookSecret?: string;
|
|
33
|
+
}, {
|
|
34
|
+
name?: string;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
twinId?: string;
|
|
37
|
+
token?: string;
|
|
38
|
+
platformApiBaseUrl?: string;
|
|
39
|
+
chatApiBaseUrl?: string;
|
|
40
|
+
apiBaseUrl?: string;
|
|
41
|
+
webhookPath?: string;
|
|
42
|
+
webhookSecret?: string;
|
|
43
|
+
}>>>;
|
|
44
|
+
defaultAccount: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
name?: string;
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
twinId?: string;
|
|
49
|
+
token?: string;
|
|
50
|
+
platformApiBaseUrl?: string;
|
|
51
|
+
chatApiBaseUrl?: string;
|
|
52
|
+
apiBaseUrl?: string;
|
|
53
|
+
webhookPath?: string;
|
|
54
|
+
webhookSecret?: string;
|
|
55
|
+
accounts?: Record<string, {
|
|
56
|
+
name?: string;
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
twinId?: string;
|
|
59
|
+
token?: string;
|
|
60
|
+
platformApiBaseUrl?: string;
|
|
61
|
+
chatApiBaseUrl?: string;
|
|
62
|
+
apiBaseUrl?: string;
|
|
63
|
+
webhookPath?: string;
|
|
64
|
+
webhookSecret?: string;
|
|
65
|
+
}>;
|
|
66
|
+
defaultAccount?: string;
|
|
67
|
+
}, {
|
|
68
|
+
name?: string;
|
|
69
|
+
enabled?: boolean;
|
|
70
|
+
twinId?: string;
|
|
71
|
+
token?: string;
|
|
72
|
+
platformApiBaseUrl?: string;
|
|
73
|
+
chatApiBaseUrl?: string;
|
|
74
|
+
apiBaseUrl?: string;
|
|
75
|
+
webhookPath?: string;
|
|
76
|
+
webhookSecret?: string;
|
|
77
|
+
accounts?: Record<string, {
|
|
78
|
+
name?: string;
|
|
79
|
+
enabled?: boolean;
|
|
80
|
+
twinId?: string;
|
|
81
|
+
token?: string;
|
|
82
|
+
platformApiBaseUrl?: string;
|
|
83
|
+
chatApiBaseUrl?: string;
|
|
84
|
+
apiBaseUrl?: string;
|
|
85
|
+
webhookPath?: string;
|
|
86
|
+
webhookSecret?: string;
|
|
87
|
+
}>;
|
|
88
|
+
defaultAccount?: string;
|
|
89
|
+
}>;
|
|
90
|
+
export type AmikoConfigInput = z.input<typeof AmikoConfigSchema>;
|
|
91
|
+
export type AmikoConfigOutput = z.output<typeof AmikoConfigSchema>;
|
|
92
|
+
//# sourceMappingURL=config-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.d.ts","sourceRoot":"","sources":["../../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG5B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACjE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const amikoAccountSchema = z.object({
|
|
3
|
+
name: z.string().optional(),
|
|
4
|
+
enabled: z.boolean().optional(),
|
|
5
|
+
twinId: z.string().optional(),
|
|
6
|
+
token: z.string().optional(),
|
|
7
|
+
platformApiBaseUrl: z.string().url().optional(),
|
|
8
|
+
chatApiBaseUrl: z.string().url().optional(),
|
|
9
|
+
apiBaseUrl: z.string().url().optional(),
|
|
10
|
+
webhookPath: z.string().optional(),
|
|
11
|
+
webhookSecret: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
export const AmikoConfigSchema = amikoAccountSchema.extend({
|
|
14
|
+
accounts: z.record(z.string(), amikoAccountSchema).optional(),
|
|
15
|
+
defaultAccount: z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC3C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IACzD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,kBAAkB,CAAC,CAAC,QAAQ,EAAE;IAC7D,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResolvedAmikoAccount } from "./types.js";
|
|
2
|
+
import type { PluginRuntime } from "./runtime.js";
|
|
3
|
+
import type { ProbeResult } from "./status.js";
|
|
4
|
+
export type MonitorOptions = {
|
|
5
|
+
account: ResolvedAmikoAccount;
|
|
6
|
+
config: unknown;
|
|
7
|
+
runtime: PluginRuntime;
|
|
8
|
+
abortSignal: AbortSignal;
|
|
9
|
+
statusSink: (patch: Partial<ProbeResult> & {
|
|
10
|
+
accountId: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export type MonitorHandle = {
|
|
14
|
+
stop: () => void;
|
|
15
|
+
webhookPath: string;
|
|
16
|
+
handler: (req: any, res: any) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export declare function monitorAmikoProvider(options: MonitorOptions): Promise<MonitorHandle>;
|
|
19
|
+
//# sourceMappingURL=monitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../src/monitor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAA0C,MAAM,YAAY,CAAC;AAC/F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC3E,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD,CAAC;AA2dF,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAuE1F"}
|