@choiceopen/atomemo-plugin-sdk-js 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 ADDED
@@ -0,0 +1,37 @@
1
+ # Choiceform Atomemo Plugin JavaScript/TypeScript SDK
2
+
3
+ ## Development
4
+
5
+ - Install dependencies:
6
+
7
+ ```bash
8
+ bun install
9
+ ```
10
+
11
+ - Watch and rebuild in development
12
+
13
+ ```bash
14
+ bun run dev
15
+ ```
16
+
17
+ - Linting and formatting
18
+
19
+ ```bash
20
+ bun run check
21
+ ```
22
+
23
+ - Run the unit tests:
24
+
25
+ ```bash
26
+ bun run test
27
+ ```
28
+
29
+ - Build the library:
30
+
31
+ ```bash
32
+ bun run build
33
+ ```
34
+
35
+ ## Linting and formatting
36
+
37
+ This project uses Biome to provide unified linting and formatting, please install VS Code extension if you use VS Code to having the best DX support.
@@ -0,0 +1,55 @@
1
+ import "dotenv/config";
2
+ import { CredentialDefinitionSchema, ModelDefinitionSchema, ToolDefinitionSchema } from "@choiceopen/atomemo-plugin-schema/schemas";
3
+ import { z } from "zod";
4
+ import { Socket, SocketConnectOption } from "phoenix";
5
+ import { PluginDefinition } from "@choiceopen/atomemo-plugin-schema/types";
6
+
7
+ //#region src/transporter.d.ts
8
+ interface TransporterOptions extends Partial<Pick<SocketConnectOption, "heartbeatIntervalMs">> {
9
+ onOpen?: Parameters<Socket["onOpen"]>[0];
10
+ onClose?: Parameters<Socket["onClose"]>[0];
11
+ onError?: Parameters<Socket["onError"]>[0];
12
+ onMessage?: Parameters<Socket["onMessage"]>[0];
13
+ }
14
+ //#endregion
15
+ //#region src/plugin.d.ts
16
+ type CredentialDefinition = z.infer<typeof CredentialDefinitionSchema>;
17
+ type ToolDefinition = z.infer<typeof ToolDefinitionSchema>;
18
+ type ModelDefinition = z.infer<typeof ModelDefinitionSchema>;
19
+ /**
20
+ * Creates a new plugin instance with the specified options.
21
+ *
22
+ * @param options - The options for configuring the plugin instance.
23
+ * @returns An object containing methods to define providers and run the plugin process.
24
+ */
25
+ declare function createPlugin<Locales extends string[]>(options: PluginDefinition<Locales, TransporterOptions>): Promise<{
26
+ /**
27
+ * Adds a new credential definition in the registry.
28
+ *
29
+ * @param credential - The credential to add.
30
+ * @throws Error if the credential is not registered.
31
+ */
32
+ addCredential: (credential: CredentialDefinition) => void;
33
+ /**
34
+ * Adds a new tool definition in the registry.
35
+ *
36
+ * @param tool - The tool to add.
37
+ * @throws Error if the tool is not registered.
38
+ */
39
+ addTool: (tool: ToolDefinition) => void;
40
+ /**
41
+ * Adds a new model definition in the registry.
42
+ *
43
+ * @param model - The model to add.
44
+ * @throws Error if the model is not registered.
45
+ */
46
+ addModel: (model: ModelDefinition) => void;
47
+ /**
48
+ * Starts the plugin's main process. This establishes the transporter connection and
49
+ * sets up signal handlers for graceful shutdown on SIGINT and SIGTERM.
50
+ */
51
+ run: () => Promise<void>;
52
+ }>;
53
+ //#endregion
54
+ export { createPlugin };
55
+ //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs ADDED
@@ -0,0 +1,347 @@
1
+ import "dotenv/config";
2
+ import { CredentialDefinitionSchema, ModelDefinitionSchema, ToolDefinitionSchema } from "@choiceopen/atomemo-plugin-schema/schemas";
3
+ import z$1, { z } from "zod";
4
+ import { readFileSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
7
+ import chalk from "chalk";
8
+ import { Socket } from "phoenix";
9
+
10
+ //#region node_modules/es-toolkit/dist/predicate/isFunction.mjs
11
+ function isFunction(value) {
12
+ return typeof value === "function";
13
+ }
14
+
15
+ //#endregion
16
+ //#region node_modules/es-toolkit/dist/predicate/isNil.mjs
17
+ function isNil(x) {
18
+ return x == null;
19
+ }
20
+
21
+ //#endregion
22
+ //#region src/env.ts
23
+ const EnvSchema = z$1.object({
24
+ HUB_SERVER_WS_URL: z$1.url({
25
+ protocol: /wss?/,
26
+ error: "HUB_SERVER_WS_URL must be a valid WebSocket URL."
27
+ }),
28
+ DEBUG_API_KEY: z$1.string({ error: "DEBUG_API_KEY must be a string." }).meta({ description: `The API key for the Hub Server` }),
29
+ DEBUG: z$1.string().optional().transform((value) => {
30
+ return isNil(value) ? process.env.NODE_ENV !== "production" : value.toLowerCase() === "true";
31
+ }).meta({ description: `Whether to enable debug mode. This will be enabled automatically when NODE_ENV is not "production". The value must be "true" (case-insensitive) to enable debug mode, otherwise it will be treated as false.` }),
32
+ NODE_ENV: z$1.enum([
33
+ "development",
34
+ "production",
35
+ "test"
36
+ ]).default("development").meta({ description: `The environment mode. This will be "development" by default.` }),
37
+ ORGANIZATION_ID: z$1.string().optional().meta({ description: `The organization ID for the plugin.` })
38
+ });
39
+ let env;
40
+ function getEnv() {
41
+ if (isNil(env)) {
42
+ const result = EnvSchema.safeParse(process.env);
43
+ if (!result.success) {
44
+ console.error(z$1.prettifyError(result.error));
45
+ process.exit(1);
46
+ }
47
+ env = result.data;
48
+ }
49
+ return env;
50
+ }
51
+
52
+ //#endregion
53
+ //#region src/config.ts
54
+ const ConfigSchema = z.object({
55
+ auth: z.object({
56
+ endpoint: z.url().optional(),
57
+ access_token: z.string().optional()
58
+ }).optional(),
59
+ hub: z.object({ endpoint: z.url().optional() }).optional()
60
+ });
61
+ const CONFIG_PATH = join(homedir(), ".choiceform", "atomemo.json");
62
+ /**
63
+ * Reads and parses the atomemo.json config file from the user's home directory.
64
+ *
65
+ * @returns The parsed config object, or undefined if the file doesn't exist.
66
+ * @throws If the file exists but contains invalid JSON or doesn't match the schema.
67
+ */
68
+ function readConfig() {
69
+ try {
70
+ const content = readFileSync(CONFIG_PATH, "utf-8");
71
+ const json = JSON.parse(content);
72
+ return ConfigSchema.parse(json);
73
+ } catch (error) {
74
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return;
75
+ throw error;
76
+ }
77
+ }
78
+
79
+ //#endregion
80
+ //#region src/oneauth.ts
81
+ const SessionSchema = z.object({
82
+ id: z.string().optional(),
83
+ expiresAt: z.string(),
84
+ token: z.string(),
85
+ createdAt: z.string(),
86
+ updatedAt: z.string(),
87
+ ipAddress: z.string().optional(),
88
+ userAgent: z.string().optional(),
89
+ userId: z.string(),
90
+ impersonatedBy: z.string().nullish(),
91
+ activeOrganizationId: z.string().nullish(),
92
+ activeTeamId: z.string().nullish()
93
+ });
94
+ const UserSchema = z.object({
95
+ id: z.string().optional(),
96
+ name: z.string(),
97
+ email: z.string(),
98
+ emailVerified: z.boolean().optional(),
99
+ image: z.string().optional(),
100
+ createdAt: z.string(),
101
+ updatedAt: z.string(),
102
+ role: z.string().optional(),
103
+ banned: z.boolean().optional(),
104
+ banReason: z.string().nullish(),
105
+ banExpires: z.string().nullish(),
106
+ lastLoginMethod: z.string().optional(),
107
+ inherentOrganizationId: z.string(),
108
+ inherentTeamId: z.string(),
109
+ metadata: z.unknown().optional(),
110
+ stripeCustomerId: z.string().nullish()
111
+ });
112
+ const GetSessionResponseSchema = z.object({
113
+ session: SessionSchema,
114
+ user: UserSchema
115
+ });
116
+ const DEFAULT_ENDPOINT = "https://oneauth.choiceform.io";
117
+ /**
118
+ * Fetches the current session and user information from the OneAuth API.
119
+ *
120
+ * @returns The session and user information.
121
+ * @throws If the config file is missing, access token is missing, or the API request fails.
122
+ */
123
+ async function getSession() {
124
+ const config = readConfig();
125
+ if (!config?.auth?.access_token) throw new Error("Access token not found. Please ensure ~/.choiceform/atomemo.json contains auth.access_token");
126
+ const endpoint = config.auth.endpoint || DEFAULT_ENDPOINT;
127
+ const url = new URL("/v1/auth/get-session", endpoint).toString();
128
+ const response = await fetch(url, {
129
+ method: "GET",
130
+ headers: {
131
+ Authorization: `Bearer ${config.auth.access_token}`,
132
+ "Content-Type": "application/json"
133
+ }
134
+ });
135
+ if (!response.ok) {
136
+ const errorText = await response.text().catch(() => "Unknown error");
137
+ throw new Error(`OneAuth API request failed: ${response.status} ${response.statusText}. ${errorText}`);
138
+ }
139
+ const data = await response.json();
140
+ return GetSessionResponseSchema.parse(data);
141
+ }
142
+
143
+ //#endregion
144
+ //#region node_modules/es-toolkit/dist/util/invariant.mjs
145
+ function invariant(condition, message) {
146
+ if (condition) return;
147
+ if (typeof message === "string") throw new Error(message);
148
+ throw message;
149
+ }
150
+
151
+ //#endregion
152
+ //#region src/utils/serialize-feature.ts
153
+ /**
154
+ * Serializes a Feature object by removing any function-type properties.
155
+ *
156
+ * @param feature - The Feature object to serialize.
157
+ * @returns An object with only non-function properties of the Feature.
158
+ */
159
+ const serializeFeature = (feature) => {
160
+ return Object.keys(feature).reduce((finale, key) => {
161
+ const value = feature[key];
162
+ if (isFunction(value)) return finale;
163
+ return Object.assign(finale, { [key]: value });
164
+ }, {});
165
+ };
166
+
167
+ //#endregion
168
+ //#region src/registry.ts
169
+ function createRegistry(plugin) {
170
+ const store = {
171
+ plugin,
172
+ credential: /* @__PURE__ */ new Map(),
173
+ model: /* @__PURE__ */ new Map(),
174
+ tool: /* @__PURE__ */ new Map()
175
+ };
176
+ function register(type, feature) {
177
+ store[type].set(feature.name, feature);
178
+ }
179
+ function resolve(type, featureName) {
180
+ const feature = store[type].get(featureName);
181
+ invariant(feature, `Feature "${featureName}" not registered`);
182
+ return feature;
183
+ }
184
+ return {
185
+ plugin: store.plugin,
186
+ register,
187
+ resolve,
188
+ serialize: () => {
189
+ invariant(store.plugin, "Plugin is not registered");
190
+ return { plugin: Object.assign(store.plugin, {
191
+ credentials: Array.from(store.credential.values()).map(serializeFeature),
192
+ models: Array.from(store.model.values()).map(serializeFeature),
193
+ tools: Array.from(store.tool.values()).map(serializeFeature)
194
+ }) };
195
+ }
196
+ };
197
+ }
198
+
199
+ //#endregion
200
+ //#region src/transporter.ts
201
+ /**
202
+ * Creates a network transporter for communication with the Hub Server.
203
+ *
204
+ * @param options - The options for the transporter.
205
+ * @returns An object with a connect method to establish the connection and a dispose method to close it.
206
+ */
207
+ function createTransporter(options = {}) {
208
+ const env$1 = getEnv();
209
+ const socket = new Socket(env$1.HUB_SERVER_WS_URL, {
210
+ debug: env$1.DEBUG,
211
+ heartbeatIntervalMs: options.heartbeatIntervalMs ?? 30 * 1e3,
212
+ logger(kind, message, data) {
213
+ const timestamp = chalk.bgGrey(` ${(/* @__PURE__ */ new Date()).toLocaleString()} `);
214
+ const coloredKind = chalk.underline.bold.yellow(kind.toUpperCase());
215
+ const coloredMessage = message instanceof Object && "message" in message ? chalk.italic.red(message.message) : chalk.italic.dim(message);
216
+ const inspection = data ? Bun.inspect(data, { colors: true }) : "";
217
+ console.debug(`${timestamp} ${coloredKind} ${coloredMessage}`, inspection);
218
+ },
219
+ params: { api_key: env$1.DEBUG_API_KEY }
220
+ });
221
+ socket.onOpen(() => {
222
+ options.onOpen?.();
223
+ });
224
+ socket.onClose((event) => {
225
+ options.onClose?.(event);
226
+ });
227
+ socket.onError((error, transport, establishedConnections) => {
228
+ if (error instanceof ErrorEvent && error.message.includes("failed: Expected 101 status code")) {
229
+ console.error("Error: Can't connect to the Plugin Hub server.\n");
230
+ console.error("This is usually because the Debug API Key is missing or has expired.\n");
231
+ console.error("Run `atomemo plugin refresh-key` to get a new key.\n");
232
+ process.exit(1);
233
+ }
234
+ options.onError?.(error, transport, establishedConnections);
235
+ });
236
+ socket.onMessage((message) => {
237
+ options.onMessage?.(message);
238
+ });
239
+ socket.connect();
240
+ return { connect: (channelName) => {
241
+ return new Promise((resolve, reject) => {
242
+ const channel = socket.channel(channelName, {});
243
+ channel.join().receive("ok", (response) => {
244
+ socket.log("channel:joined", `Joined ${channelName} successfully`, response);
245
+ resolve({
246
+ channel,
247
+ dispose: () => {
248
+ channel.leave();
249
+ socket.disconnect();
250
+ process.exit(0);
251
+ }
252
+ });
253
+ }).receive("error", (response) => {
254
+ socket.log("channel:error", `Failed to join ${channelName}`, response);
255
+ reject(/* @__PURE__ */ new Error(`Failed to join ${channelName}: ${response.reason}`));
256
+ }).receive("timeout", (response) => {
257
+ socket.log("channel:timeout", `Timeout while joining ${channelName}`, response);
258
+ reject(/* @__PURE__ */ new Error(`Timeout while joining ${channelName}`));
259
+ });
260
+ });
261
+ } };
262
+ }
263
+
264
+ //#endregion
265
+ //#region src/plugin.ts
266
+ const ToolInvokeMessage = z.object({
267
+ request_id: z.string(),
268
+ plugin_name: z.string(),
269
+ tool_name: z.string(),
270
+ parameters: z.json()
271
+ });
272
+ /**
273
+ * Creates a new plugin instance with the specified options.
274
+ *
275
+ * @param options - The options for configuring the plugin instance.
276
+ * @returns An object containing methods to define providers and run the plugin process.
277
+ */
278
+ async function createPlugin(options) {
279
+ const env$1 = getEnv();
280
+ if (!env$1.ORGANIZATION_ID) {
281
+ console.error("DEBUG API Key is invalid. Please run `atomemo plugin refresh-key`");
282
+ process.exit(1);
283
+ }
284
+ let user;
285
+ try {
286
+ user = (await getSession()).user;
287
+ if (user.inherentOrganizationId !== env$1.ORGANIZATION_ID) {
288
+ console.info("Atomemo does not currently support developing plugins for other organizations. Please wait for official support.");
289
+ process.exit(0);
290
+ }
291
+ } catch (error) {
292
+ console.error("Failed to fetch session:", error instanceof Error ? error.message : error);
293
+ process.exit(1);
294
+ }
295
+ const { transporterOptions, version = process.env.npm_package_version, ...plugin } = options;
296
+ const registry = createRegistry(Object.assign(plugin, {
297
+ author: user.name,
298
+ email: user.email,
299
+ version
300
+ }));
301
+ const transporter = createTransporter(transporterOptions);
302
+ return {
303
+ addCredential: (credential) => {
304
+ const definition = CredentialDefinitionSchema.parse(credential);
305
+ registry.register("credential", definition);
306
+ },
307
+ addTool: (tool) => {
308
+ const definition = ToolDefinitionSchema.parse(tool);
309
+ registry.register("tool", definition);
310
+ },
311
+ addModel: (model) => {
312
+ const definition = ModelDefinitionSchema.parse(model);
313
+ registry.register("model", definition);
314
+ },
315
+ run: async () => {
316
+ const { channel, dispose } = await transporter.connect(`debug_plugin:${registry.plugin.name}`);
317
+ channel.push("register_plugin", registry.serialize().plugin);
318
+ channel.on("invoke_tool", async (message) => {
319
+ const request_id = message.request_id;
320
+ try {
321
+ const event = ToolInvokeMessage.parse(message);
322
+ const data = await registry.resolve("tool", event.tool_name).invoke({ args: event.parameters });
323
+ channel.push("invoke_tool_response", {
324
+ request_id,
325
+ data
326
+ });
327
+ } catch (error) {
328
+ if (error instanceof Error) channel.push("invoke_tool_error", {
329
+ request_id,
330
+ ...error
331
+ });
332
+ else channel.push("invoke_tool_error", {
333
+ request_id,
334
+ message: "Unexpected Error"
335
+ });
336
+ }
337
+ });
338
+ ["SIGINT", "SIGTERM"].forEach((signal) => {
339
+ process.on(signal, dispose);
340
+ });
341
+ }
342
+ };
343
+ }
344
+
345
+ //#endregion
346
+ export { createPlugin };
347
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["z","env","env"],"sources":["../node_modules/es-toolkit/dist/predicate/isFunction.mjs","../node_modules/es-toolkit/dist/predicate/isNil.mjs","../src/env.ts","../src/config.ts","../src/oneauth.ts","../node_modules/es-toolkit/dist/util/invariant.mjs","../src/utils/serialize-feature.ts","../src/registry.ts","../src/transporter.ts","../src/plugin.ts"],"sourcesContent":["function isFunction(value) {\n return typeof value === 'function';\n}\n\nexport { isFunction };\n","function isNil(x) {\n return x == null;\n}\n\nexport { isNil };\n","import { isNil } from \"es-toolkit/predicate\"\nimport z from \"zod\"\n\ndeclare module \"bun\" {\n interface Env {\n /** The URL of the Hub Server WebSocket. */\n readonly HUB_SERVER_WS_URL: string | undefined\n /** Whether to enable debug mode. */\n readonly DEBUG: boolean\n /** The API key for the Hub Server. */\n readonly DEBUG_API_KEY: string | undefined\n /** The organization ID for the plugin. */\n readonly ORGANIZATION_ID: string | undefined\n }\n}\n\nconst EnvSchema = z.object({\n HUB_SERVER_WS_URL: z.url({\n protocol: /wss?/,\n error: \"HUB_SERVER_WS_URL must be a valid WebSocket URL.\",\n }),\n DEBUG_API_KEY: z\n .string({\n error: \"DEBUG_API_KEY must be a string.\",\n })\n .meta({ description: `The API key for the Hub Server` }),\n DEBUG: z\n .string()\n .optional()\n .transform((value) => {\n return isNil(value) ? process.env.NODE_ENV !== \"production\" : value.toLowerCase() === \"true\"\n })\n .meta({\n description: `Whether to enable debug mode. This will be enabled automatically when NODE_ENV is not \"production\". The value must be \"true\" (case-insensitive) to enable debug mode, otherwise it will be treated as false.`,\n }),\n NODE_ENV: z.enum([\"development\", \"production\", \"test\"]).default(\"development\").meta({\n description: `The environment mode. This will be \"development\" by default.`,\n }),\n ORGANIZATION_ID: z\n .string()\n .optional()\n .meta({ description: `The organization ID for the plugin.` }),\n})\n\nlet env: z.infer<typeof EnvSchema> | undefined\n\nexport function getEnv() {\n if (isNil(env)) {\n const result = EnvSchema.safeParse(process.env)\n\n if (!result.success) {\n console.error(z.prettifyError(result.error))\n process.exit(1)\n }\n\n env = result.data\n }\n\n return env\n}\n","import { readFileSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { join } from \"node:path\"\nimport { z } from \"zod\"\n\nconst ConfigSchema = z.object({\n auth: z\n .object({\n endpoint: z.url().optional(),\n access_token: z.string().optional(),\n })\n .optional(),\n hub: z\n .object({\n endpoint: z.url().optional(),\n })\n .optional(),\n})\n\nexport type Config = z.infer<typeof ConfigSchema>\n\nconst CONFIG_PATH = join(homedir(), \".choiceform\", \"atomemo.json\")\n\n/**\n * Reads and parses the atomemo.json config file from the user's home directory.\n *\n * @returns The parsed config object, or undefined if the file doesn't exist.\n * @throws If the file exists but contains invalid JSON or doesn't match the schema.\n */\nexport function readConfig(): Config | undefined {\n try {\n const content = readFileSync(CONFIG_PATH, \"utf-8\")\n const json = JSON.parse(content)\n return ConfigSchema.parse(json)\n } catch (error) {\n if (error && typeof error === \"object\" && \"code\" in error && error.code === \"ENOENT\") {\n // File doesn't exist\n return undefined\n }\n // Re-throw other errors (parse errors, schema validation errors, etc.)\n throw error\n }\n}\n","import { z } from \"zod\"\nimport { readConfig } from \"./config\"\n\nconst SessionSchema = z.object({\n id: z.string().optional(),\n expiresAt: z.string(),\n token: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n ipAddress: z.string().optional(),\n userAgent: z.string().optional(),\n userId: z.string(),\n impersonatedBy: z.string().nullish(),\n activeOrganizationId: z.string().nullish(),\n activeTeamId: z.string().nullish(),\n})\n\nconst UserSchema = z.object({\n id: z.string().optional(),\n name: z.string(),\n email: z.string(),\n emailVerified: z.boolean().optional(),\n image: z.string().optional(),\n createdAt: z.string(),\n updatedAt: z.string(),\n role: z.string().optional(),\n banned: z.boolean().optional(),\n banReason: z.string().nullish(),\n banExpires: z.string().nullish(),\n lastLoginMethod: z.string().optional(),\n inherentOrganizationId: z.string(),\n inherentTeamId: z.string(),\n metadata: z.unknown().optional(),\n stripeCustomerId: z.string().nullish(),\n})\n\nconst GetSessionResponseSchema = z.object({\n session: SessionSchema,\n user: UserSchema,\n})\n\nexport type Session = z.infer<typeof SessionSchema>\nexport type User = z.infer<typeof UserSchema>\nexport type GetSessionResponse = z.infer<typeof GetSessionResponseSchema>\n\nconst DEFAULT_ENDPOINT = \"https://oneauth.choiceform.io\"\n\n/**\n * Fetches the current session and user information from the OneAuth API.\n *\n * @returns The session and user information.\n * @throws If the config file is missing, access token is missing, or the API request fails.\n */\nexport async function getSession(): Promise<GetSessionResponse> {\n const config = readConfig()\n\n if (!config?.auth?.access_token) {\n throw new Error(\n \"Access token not found. Please ensure ~/.choiceform/atomemo.json contains auth.access_token\",\n )\n }\n\n const endpoint = config.auth.endpoint || DEFAULT_ENDPOINT\n const url = new URL(\"/v1/auth/get-session\", endpoint).toString()\n\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${config.auth.access_token}`,\n \"Content-Type\": \"application/json\",\n },\n })\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => \"Unknown error\")\n throw new Error(\n `OneAuth API request failed: ${response.status} ${response.statusText}. ${errorText}`,\n )\n }\n\n const data = await response.json()\n return GetSessionResponseSchema.parse(data)\n}\n","function invariant(condition, message) {\n if (condition) {\n return;\n }\n if (typeof message === 'string') {\n throw new Error(message);\n }\n throw message;\n}\n\nexport { invariant };\n","import { isFunction } from \"es-toolkit/predicate\"\nimport type { JsonValue } from \"type-fest\"\n\n/**\n * Serializes a Feature object by removing any function-type properties.\n *\n * @param feature - The Feature object to serialize.\n * @returns An object with only non-function properties of the Feature.\n */\nexport const serializeFeature = (feature: Record<string, unknown>) => {\n return Object.keys(feature).reduce<Record<string, JsonValue>>((finale, key) => {\n const value = feature[key]\n\n if (isFunction(value)) {\n return finale\n }\n\n return Object.assign(finale, { [key]: value as JsonValue })\n }, {})\n}\n","import type {\n CredentialDefinitionSchema,\n ModelDefinitionSchema,\n ToolDefinitionSchema,\n} from \"@choiceopen/atomemo-plugin-schema/schemas\"\nimport type {\n DataSourceDefinition,\n PluginDefinition,\n} from \"@choiceopen/atomemo-plugin-schema/types\"\nimport { assert } from \"es-toolkit\"\nimport type { JsonValue, Simplify } from \"type-fest\"\nimport type { z } from \"zod\"\nimport type { TransporterOptions } from \"./transporter\"\nimport { serializeFeature } from \"./utils/serialize-feature\"\n\ntype PluginRegistry = Simplify<\n Omit<PluginDefinition<string[], TransporterOptions>, \"transporterOptions\">\n>\n\ntype CredentialDefinition = z.infer<typeof CredentialDefinitionSchema>\ntype ModelDefinition = z.infer<typeof ModelDefinitionSchema>\ntype ToolDefinition = z.infer<typeof ToolDefinitionSchema>\ntype Feature = CredentialDefinition | DataSourceDefinition | ModelDefinition | ToolDefinition\n\ninterface RegistryStore {\n plugin: PluginRegistry\n credential: Map<CredentialDefinition[\"name\"], CredentialDefinition>\n // data_source: Map<DataSourceDefinition[\"name\"], DataSourceDefinition>\n model: Map<ModelDefinition[\"name\"], ModelDefinition>\n tool: Map<ToolDefinition[\"name\"], ToolDefinition>\n}\n\nexport type FeatureType = keyof Pick<RegistryStore, \"credential\" | \"model\" | \"tool\">\n\nexport interface Registry {\n /**\n * The plugin metadata and definitions, excluding transporter options.\n */\n plugin: PluginRegistry\n\n /**\n * Registers a feature (credential, data source, model, or tool) into the registry.\n *\n * @param type - The type of the feature to register (\"credential\", \"data_source\", \"model\", or \"tool\").\n * @param feature - The feature definition to register.\n */\n register: {\n (type: \"credential\", feature: CredentialDefinition): void\n // (type: \"data_source\", feature: DataSourceDefinition): void\n (type: \"model\", feature: ModelDefinition): void\n (type: \"tool\", feature: ToolDefinition): void\n }\n\n /**\n * Resolves and retrieves a registered feature (credential, data source, model, or tool) by its type and name.\n *\n * @param type - The type of the feature (\"credential\", \"data_source\", \"model\", or \"tool\").\n * @param featureName - The name of the feature to resolve.\n * @returns The resolved feature definition.\n * @throws If the feature is not registered.\n */\n resolve: {\n (type: \"credential\", featureName: string): CredentialDefinition\n // (type: \"data_source\", featureName: string): DataSourceDefinition\n (type: \"model\", featureName: string): ModelDefinition\n (type: \"tool\", featureName: string): ToolDefinition\n }\n\n /**\n * Serializes the registry into a JSON-like object.\n *\n * @returns The serialized registry.\n */\n serialize: () => {\n plugin: PluginRegistry & Record<`${FeatureType}s`, Array<Record<string, JsonValue>>>\n }\n}\n\nexport function createRegistry(plugin: PluginRegistry): Registry {\n const store: RegistryStore = {\n plugin,\n credential: new Map(),\n // data_source: new Map(),\n model: new Map(),\n tool: new Map(),\n }\n\n function register(type: \"credential\", feature: CredentialDefinition): void\n // function register(type: \"data_source\", feature: DataSourceDefinition): void\n function register(type: \"model\", feature: ModelDefinition): void\n function register(type: \"tool\", feature: ToolDefinition): void\n // biome-ignore lint/suspicious/noExplicitAny: any is used to avoid type errors\n function register(type: FeatureType, feature: any): void {\n store[type].set(feature.name, feature)\n }\n\n function resolve(type: \"credential\", featureName: string): CredentialDefinition\n // function resolve(type: \"data_source\", featureName: string): DataSourceDefinition\n function resolve(type: \"model\", featureName: string): ModelDefinition\n function resolve(type: \"tool\", featureName: string): ToolDefinition\n function resolve(type: FeatureType, featureName: string): Feature {\n const feature = store[type].get(featureName)\n assert(feature, `Feature \"${featureName}\" not registered`)\n return feature\n }\n\n return {\n plugin: store.plugin,\n register,\n resolve,\n serialize: () => {\n assert(store.plugin, \"Plugin is not registered\")\n\n return {\n plugin: Object.assign(store.plugin, {\n credentials: Array.from(store.credential.values()).map(serializeFeature),\n // data_sources: Array.from(store.data_source.values()).map(serializeFeature),\n models: Array.from(store.model.values()).map(serializeFeature),\n tools: Array.from(store.tool.values()).map(serializeFeature),\n }),\n }\n },\n }\n}\n","import chalk from \"chalk\"\nimport { type Channel, Socket, type SocketConnectOption } from \"phoenix\"\nimport { getEnv } from \"./env\"\n\nexport interface TransporterOptions\n extends Partial<Pick<SocketConnectOption, \"heartbeatIntervalMs\">> {\n onOpen?: Parameters<Socket[\"onOpen\"]>[0]\n onClose?: Parameters<Socket[\"onClose\"]>[0]\n onError?: Parameters<Socket[\"onError\"]>[0]\n onMessage?: Parameters<Socket[\"onMessage\"]>[0]\n}\n\n/**\n * Creates a network transporter for communication with the Hub Server.\n *\n * @param options - The options for the transporter.\n * @returns An object with a connect method to establish the connection and a dispose method to close it.\n */\nexport function createTransporter(options: TransporterOptions = {}) {\n const env = getEnv()\n\n const socket = new Socket(env.HUB_SERVER_WS_URL, {\n debug: env.DEBUG,\n heartbeatIntervalMs: options.heartbeatIntervalMs ?? 30 * 1000,\n logger(kind, message: unknown, data) {\n const timestamp = chalk.bgGrey(` ${new Date().toLocaleString()} `)\n const coloredKind = chalk.underline.bold.yellow(kind.toUpperCase())\n const coloredMessage =\n message instanceof Object && \"message\" in message\n ? chalk.italic.red(message.message)\n : chalk.italic.dim(message)\n const inspection = data ? Bun.inspect(data, { colors: true }) : \"\"\n console.debug(`${timestamp} ${coloredKind} ${coloredMessage}`, inspection)\n },\n params: { api_key: env.DEBUG_API_KEY },\n })\n\n socket.onOpen(() => {\n options.onOpen?.()\n })\n\n socket.onClose((event) => {\n options.onClose?.(event)\n })\n\n socket.onError((error, transport, establishedConnections) => {\n if (error instanceof ErrorEvent && error.message.includes(\"failed: Expected 101 status code\")) {\n console.error(\"Error: Can't connect to the Plugin Hub server.\\n\")\n console.error(\"This is usually because the Debug API Key is missing or has expired.\\n\")\n console.error(\"Run `atomemo plugin refresh-key` to get a new key.\\n\")\n process.exit(1)\n }\n options.onError?.(error, transport, establishedConnections)\n })\n\n socket.onMessage((message) => {\n options.onMessage?.(message)\n })\n\n socket.connect()\n\n return {\n /**\n * Connects to the specified channel and returns a channel object and a dispose function.\n *\n * @returns An object with a channel property and a dispose function.\n */\n connect: (channelName: string) => {\n return new Promise<{ channel: Channel; dispose: () => void }>((resolve, reject) => {\n const channel = socket.channel(channelName, {})\n\n channel\n .join()\n .receive(\"ok\", (response) => {\n socket.log(\"channel:joined\", `Joined ${channelName} successfully`, response)\n\n resolve({\n channel,\n dispose: () => {\n channel.leave()\n socket.disconnect()\n process.exit(0)\n },\n })\n })\n .receive(\"error\", (response) => {\n socket.log(\"channel:error\", `Failed to join ${channelName}`, response)\n\n reject(new Error(`Failed to join ${channelName}: ${response.reason}`))\n })\n .receive(\"timeout\", (response) => {\n socket.log(\"channel:timeout\", `Timeout while joining ${channelName}`, response)\n reject(new Error(`Timeout while joining ${channelName}`))\n })\n })\n },\n }\n}\n","import {\n CredentialDefinitionSchema,\n ModelDefinitionSchema,\n ToolDefinitionSchema,\n} from \"@choiceopen/atomemo-plugin-schema/schemas\"\nimport type { PluginDefinition } from \"@choiceopen/atomemo-plugin-schema/types\"\nimport { z } from \"zod\"\nimport { getEnv } from \"./env\"\nimport { getSession } from \"./oneauth\"\nimport { createRegistry } from \"./registry\"\nimport { createTransporter, type TransporterOptions } from \"./transporter\"\n\nconst ToolInvokeMessage = z.object({\n request_id: z.string(),\n plugin_name: z.string(),\n tool_name: z.string(),\n parameters: z.json(),\n})\n\ntype CredentialDefinition = z.infer<typeof CredentialDefinitionSchema>\ntype ToolDefinition = z.infer<typeof ToolDefinitionSchema>\ntype ModelDefinition = z.infer<typeof ModelDefinitionSchema>\n\n/**\n * Creates a new plugin instance with the specified options.\n *\n * @param options - The options for configuring the plugin instance.\n * @returns An object containing methods to define providers and run the plugin process.\n */\nexport async function createPlugin<Locales extends string[]>(\n options: PluginDefinition<Locales, TransporterOptions>,\n) {\n // Validate organization ID before creating registry\n const env = getEnv()\n if (!env.ORGANIZATION_ID) {\n console.error(\"DEBUG API Key is invalid. Please run `atomemo plugin refresh-key`\")\n process.exit(1)\n }\n\n // Fetch user session and validate organization\n let user: { name: string; email: string; inherentOrganizationId?: string }\n try {\n const sessionData = await getSession()\n user = sessionData.user\n\n if (user.inherentOrganizationId !== env.ORGANIZATION_ID) {\n console.info(\n \"Atomemo does not currently support developing plugins for other organizations. Please wait for official support.\",\n )\n process.exit(0)\n }\n } catch (error) {\n console.error(\"Failed to fetch session:\", error instanceof Error ? error.message : error)\n process.exit(1)\n }\n\n // Merge user info into plugin options\n const { transporterOptions, version = process.env.npm_package_version, ...plugin } = options\n const pluginDefinition = Object.assign(plugin, {\n author: user.name,\n email: user.email,\n version,\n })\n\n const registry = createRegistry(pluginDefinition)\n const transporter = createTransporter(transporterOptions)\n\n return {\n /**\n * Adds a new credential definition in the registry.\n *\n * @param credential - The credential to add.\n * @throws Error if the credential is not registered.\n */\n addCredential: (credential: CredentialDefinition) => {\n const definition = CredentialDefinitionSchema.parse(credential)\n registry.register(\"credential\", definition)\n },\n\n /**\n * Adds a new tool definition in the registry.\n *\n * @param tool - The tool to add.\n * @throws Error if the tool is not registered.\n */\n addTool: (tool: ToolDefinition) => {\n const definition = ToolDefinitionSchema.parse(tool)\n registry.register(\"tool\", definition)\n },\n\n /**\n * Adds a new model definition in the registry.\n *\n * @param model - The model to add.\n * @throws Error if the model is not registered.\n */\n addModel: (model: ModelDefinition) => {\n const definition = ModelDefinitionSchema.parse(model)\n registry.register(\"model\", definition)\n },\n\n /**\n * Starts the plugin's main process. This establishes the transporter connection and\n * sets up signal handlers for graceful shutdown on SIGINT and SIGTERM.\n */\n run: async () => {\n const { channel, dispose } = await transporter.connect(`debug_plugin:${registry.plugin.name}`)\n\n channel.push(\"register_plugin\", registry.serialize().plugin)\n\n channel.on(\"invoke_tool\", async (message) => {\n const request_id = message.request_id\n\n try {\n const event = ToolInvokeMessage.parse(message)\n const tool = registry.resolve(\"tool\", event.tool_name)\n const data = await tool.invoke({ args: event.parameters })\n channel.push(\"invoke_tool_response\", { request_id, data })\n } catch (error) {\n if (error instanceof Error) {\n channel.push(\"invoke_tool_error\", { request_id, ...error })\n } else {\n channel.push(\"invoke_tool_error\", { request_id, message: \"Unexpected Error\" })\n }\n }\n })\n\n void [\"SIGINT\", \"SIGTERM\"].forEach((signal) => {\n void process.on(signal, dispose)\n })\n },\n }\n}\n"],"x_google_ignoreList":[0,1,5],"mappings":";;;;;;;;;;AAAA,SAAS,WAAW,OAAO;AACvB,QAAO,OAAO,UAAU;;;;;ACD5B,SAAS,MAAM,GAAG;AACd,QAAO,KAAK;;;;;ACehB,MAAM,YAAYA,IAAE,OAAO;CACzB,mBAAmBA,IAAE,IAAI;EACvB,UAAU;EACV,OAAO;EACR,CAAC;CACF,eAAeA,IACZ,OAAO,EACN,OAAO,mCACR,CAAC,CACD,KAAK,EAAE,aAAa,kCAAkC,CAAC;CAC1D,OAAOA,IACJ,QAAQ,CACR,UAAU,CACV,WAAW,UAAU;AACpB,SAAO,MAAM,MAAM,GAAG,QAAQ,IAAI,aAAa,eAAe,MAAM,aAAa,KAAK;GACtF,CACD,KAAK,EACJ,aAAa,gNACd,CAAC;CACJ,UAAUA,IAAE,KAAK;EAAC;EAAe;EAAc;EAAO,CAAC,CAAC,QAAQ,cAAc,CAAC,KAAK,EAClF,aAAa,gEACd,CAAC;CACF,iBAAiBA,IACd,QAAQ,CACR,UAAU,CACV,KAAK,EAAE,aAAa,uCAAuC,CAAC;CAChE,CAAC;AAEF,IAAI;AAEJ,SAAgB,SAAS;AACvB,KAAI,MAAM,IAAI,EAAE;EACd,MAAM,SAAS,UAAU,UAAU,QAAQ,IAAI;AAE/C,MAAI,CAAC,OAAO,SAAS;AACnB,WAAQ,MAAMA,IAAE,cAAc,OAAO,MAAM,CAAC;AAC5C,WAAQ,KAAK,EAAE;;AAGjB,QAAM,OAAO;;AAGf,QAAO;;;;;ACrDT,MAA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AAM,aAAa,QAAQ;AAE3B,QAAI;KACF,MAAM,QAAQ,kBAAkB,MAAM,QAAQ;KAE9C,MAAM,OAAO,MADA,SAAS,QAAQ,QAAQ,MAAM,UAAU,CAC9B,OAAO,EAAE,MAAM,MAAM,YAAY,CAAC;AAC1D,aAAQ,KAAK,wBAAwB;MAAE;MAAY;MAAM,CAAC;aACnD,OAAO;AACd,SAAI,iBAAiB,MACnB,SAAQ,KAAK,qBAAqB;MAAE;MAAY,GAAG;MAAO,CAAC;SAE3D,SAAQ,KAAK,qBAAqB;MAAE;MAAY,SAAS;MAAoB,CAAC;;KAGlF;AAEF,GAAK,CAAC,UAAU,UAAU,CAAC,SAAS,WAAW;AAC7C,IAAK,QAAQ,GAAG,QAAQ,QAAQ;KAChC;;EAEL"}
@@ -0,0 +1 @@
1
+ export * from "@choiceopen/atomemo-plugin-schema/types";
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ export { };
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@choiceopen/atomemo-plugin-sdk-js",
3
+ "version": "0.1.0",
4
+ "description": "JavaScript/TypeScript SDK for developing Choiceform Atomemo plugins",
5
+ "homepage": "https://github.com/choice-open/atomemo-plugin-sdk-js#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/choice-open/atomemo-plugin-sdk-js/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/choice-open/atomemo-plugin-sdk-js.git"
12
+ },
13
+ "license": "MIT",
14
+ "author": "Albert Yu <albert.yu@choiceform.com>",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "development": "./src/index.ts",
19
+ "default": "./dist/index.mjs"
20
+ },
21
+ "./types": {
22
+ "development": "./src/types.ts",
23
+ "default": "./dist/types.mjs"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsdown",
33
+ "check": "biome check --write",
34
+ "dev": "tsdown --watch",
35
+ "prepublishOnly": "bun run build",
36
+ "test": "bun test --dots",
37
+ "typecheck": "tsc --noEmit"
38
+ },
39
+ "dependencies": {
40
+ "@choiceopen/atomemo-plugin-schema": "^0.1.3",
41
+ "phoenix": "^1.8.3",
42
+ "pino": "^10.2.1",
43
+ "pino-pretty": "^13.1.3",
44
+ "type-fest": "^5.4.1"
45
+ },
46
+ "devDependencies": {
47
+ "@biomejs/biome": "^2.3.11",
48
+ "@types/bun": "^1.3.6",
49
+ "@types/phoenix": "^1.6.7",
50
+ "bumpp": "^10.4.0",
51
+ "chalk": "^5.6.2",
52
+ "dotenv": "^17.2.3",
53
+ "es-toolkit": "^1.44.0",
54
+ "tsdown": "^0.19.0",
55
+ "typescript": "^5.9.3",
56
+ "zod": "^4.3.5"
57
+ },
58
+ "peerDependencies": {
59
+ "chalk": "^5",
60
+ "dotenv": "^17",
61
+ "zod": "^4"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "chalk": {
65
+ "optional": false
66
+ },
67
+ "dotenv": {
68
+ "optional": false
69
+ },
70
+ "zod": {
71
+ "optional": false
72
+ }
73
+ },
74
+ "publishConfig": {
75
+ "access": "public",
76
+ "exports": {
77
+ ".": "./dist/index.mjs",
78
+ "./types": "./dist/types.mjs",
79
+ "./package.json": "./package.json"
80
+ }
81
+ }
82
+ }