@choiceopen/atomemo-plugin-sdk-js 0.3.0 → 0.3.2

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/dist/index.mjs CHANGED
@@ -68,11 +68,11 @@ function getEnv() {
68
68
  //#endregion
69
69
  //#region src/config.ts
70
70
  const ConfigSchema = z$1.object({
71
- auth: z$1.object({
71
+ auth: z$1.record(z$1.enum(["staging", "production"]), z$1.object({
72
72
  endpoint: z$1.url().optional(),
73
73
  access_token: z$1.string().optional()
74
- }).optional(),
75
- hub: z$1.object({ endpoint: z$1.url().optional() }).optional()
74
+ })).optional(),
75
+ hub: z$1.record(z$1.enum(["staging", "production"]), z$1.object({ endpoint: z$1.url().optional() })).optional()
76
76
  });
77
77
  const CONFIG_PATH = join(homedir(), ".choiceform", "atomemo.json");
78
78
  /**
@@ -131,22 +131,22 @@ const GetSessionResponseSchema = z$1.object({
131
131
  session: SessionSchema,
132
132
  user: UserSchema
133
133
  });
134
- const DEFAULT_ENDPOINT = "https://oneauth.choiceform.io";
134
+ const DEFAULT_ENDPOINT = "https://oneauth.atomemo.ai";
135
135
  /**
136
136
  * Fetches the current session and user information from the OneAuth API.
137
137
  *
138
138
  * @returns The session and user information.
139
139
  * @throws If the config file is missing, access token is missing, or the API request fails.
140
140
  */
141
- async function getSession() {
141
+ async function getSession(deployment) {
142
142
  const config = readConfig();
143
- if (!config?.auth?.access_token) throw new Error("Access token not found. Please ensure ~/.choiceform/atomemo.json contains auth.access_token");
144
- const endpoint = config.auth.endpoint || DEFAULT_ENDPOINT;
143
+ if (!config?.auth?.[deployment]?.access_token) throw new Error("Access token not found. Please ensure ~/.choiceform/atomemo.json contains auth.access_token");
144
+ const endpoint = config.auth?.[deployment]?.endpoint || DEFAULT_ENDPOINT;
145
145
  const url = new URL("/v1/auth/get-session", endpoint).toString();
146
146
  const response = await fetch(url, {
147
147
  method: "GET",
148
148
  headers: {
149
- Authorization: `Bearer ${config.auth.access_token}`,
149
+ Authorization: `Bearer ${config.auth?.[deployment]?.access_token}`,
150
150
  "Content-Type": "application/json"
151
151
  }
152
152
  });
@@ -294,10 +294,11 @@ const ToolInvokeMessage = z$1.object({
294
294
  * @returns An object containing methods to define providers and run the plugin process.
295
295
  */
296
296
  async function createPlugin(options) {
297
- const isDebugMode = getEnv().HUB_MODE === "debug";
297
+ const env = getEnv();
298
+ const isDebugMode = env.HUB_MODE === "debug";
298
299
  let user;
299
300
  if (isDebugMode) try {
300
- const session = await getSession();
301
+ const session = await getSession(env.HUB_WS_URL.includes("atomemo.ai") ? "production" : "staging");
301
302
  user = {
302
303
  name: session.user.name,
303
304
  email: session.user.email
@@ -343,7 +344,7 @@ async function createPlugin(options) {
343
344
  registry.register("model", definition);
344
345
  },
345
346
  run: async () => {
346
- const topic = isDebugMode ? `debug_plugin:${registry.plugin.name}` : `release_plugin:${registry.plugin.name}__${pluginDefinition.version}`;
347
+ const topic = isDebugMode ? `debug_plugin:${registry.plugin.name}` : `release_plugin:${registry.plugin.name}__${env.HUB_MODE}__${pluginDefinition.version}`;
347
348
  const { channel, dispose } = await transporter.connect(topic);
348
349
  if (isDebugMode) {
349
350
  const definition = registry.serialize().plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["z","z","z"],"sources":["../node_modules/es-toolkit/dist/predicate/isFunction.mjs","../node_modules/es-toolkit/dist/predicate/isNil.mjs","../node_modules/es-toolkit/dist/predicate/isString.mjs","../node_modules/es-toolkit/dist/util/invariant.mjs","../src/env.ts","../src/config.ts","../src/oneauth.ts","../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","function isString(value) {\n return typeof value === 'string';\n}\n\nexport { isString };\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 { isNil, isString } from \"es-toolkit/predicate\"\nimport z from \"zod\"\n\ndeclare module \"bun\" {\n interface Env {\n /** The Hub Server runtime mode. */\n readonly HUB_MODE: \"debug\" | \"release\"\n /** The URL of the Hub Server WebSocket. */\n readonly HUB_WS_URL: string | undefined\n /** Whether to enable debug mode. */\n readonly DEBUG: boolean\n /** The API key for the Hub Server. */\n readonly HUB_DEBUG_API_KEY: string | undefined\n }\n}\n\nconst EnvSchema = z.object({\n HUB_MODE: z.enum([\"debug\", \"release\"]).default(\"debug\").meta({\n description: `The Hub Server runtime mode. This will be \"debug\" by default.`,\n }),\n HUB_WS_URL: z.url({\n protocol: /wss?/,\n error: \"HUB_WS_URL must be a valid WebSocket URL.\",\n }),\n HUB_DEBUG_API_KEY: z\n .string({\n error: \"HUB_DEBUG_API_KEY must be a string.\",\n })\n .optional()\n .refine((value) => {\n return Bun.env.NODE_ENV === \"production\" || (isString(value) && value.length > 0)\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})\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(),\n expiresAt: z.string(),\n token: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n ipAddress: z.string().nullish(),\n userAgent: z.string().nullish(),\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(),\n name: z.string(),\n email: z.string(),\n emailVerified: z.boolean().optional(),\n image: z.string().nullish(),\n createdAt: z.string(),\n updatedAt: z.string(),\n role: z.string(),\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 referralCode: z.string(),\n referredBy: z.string().nullish(),\n metadata: z.record(z.string(), z.any()),\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","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 url = `${env.HUB_WS_URL}/${env.HUB_MODE}_socket`\n const socket = new Socket(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: Bun.env.NODE_ENV !== \"production\" ? { api_key: env.HUB_DEBUG_API_KEY } : undefined,\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\n if (Bun.env.NODE_ENV !== \"production\") {\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 }\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 { isNil } from \"es-toolkit\"\nimport { ZodError, z } from \"zod\"\nimport { getEnv } from \"./env\"\nimport { getSession } from \"./oneauth\"\nimport { createRegistry } from \"./registry\"\nimport { createTransporter, type TransporterOptions } from \"./transporter\"\n\nconst CredentialAuthenticateMessage = z.object({\n request_id: z.string(),\n credential: z.record(z.string(), z.any()),\n credential_name: z.string(),\n extra: z.record(z.string(), z.any()),\n})\n\nconst ToolInvokeMessage = z.object({\n request_id: z.string(),\n tool_name: z.string(),\n parameters: z.record(z.string(), z.any()),\n credentials: z.record(z.string(), z.any()).optional(),\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 const env = getEnv()\n const isDebugMode = env.HUB_MODE === \"debug\"\n\n let user: { name: string; email: string }\n\n if (isDebugMode) {\n try {\n const session = await getSession()\n user = { name: session.user.name, email: session.user.email }\n } catch (error) {\n console.error(\"Error fetching user session:\", error)\n process.exit(1)\n }\n } else {\n try {\n const raw = await Bun.file(\"definition.json\").json()\n const definition = z.looseObject({ author: z.string(), email: z.string() }).parse(raw)\n user = { name: definition.author, email: definition.email }\n } catch (error) {\n if (error instanceof ZodError) {\n console.error(z.prettifyError(error))\n } else {\n console.error(\"Error parsing definition.json:\", error)\n }\n process.exit(1)\n }\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 topic = isDebugMode\n ? `debug_plugin:${registry.plugin.name}`\n : `release_plugin:${registry.plugin.name}__${pluginDefinition.version}`\n const { channel, dispose } = await transporter.connect(topic)\n\n if (isDebugMode) {\n const definition = registry.serialize().plugin\n channel.push(\"register_plugin\", definition)\n await Bun.write(\"definition.json\", JSON.stringify(definition, null, 2))\n }\n\n channel.on(\"credential_auth_spec\", async (message) => {\n const request_id = message.request_id\n\n try {\n const event = CredentialAuthenticateMessage.parse(message)\n const definition = registry.resolve(\"credential\", event.credential_name)\n if (isNil(definition.authenticate)) {\n throw new Error(\"Credential authenticate method is not implemented\")\n }\n\n const AuthenticateMethodWrapper = CredentialDefinitionSchema.shape.authenticate.unwrap()\n const authenticate = AuthenticateMethodWrapper.implementAsync(definition.authenticate)\n\n const { credential, extra } = event\n const data = await authenticate({ args: { credential, extra } })\n\n channel.push(\"credential_auth_spec_response\", { request_id, data })\n } catch (error) {\n if (error instanceof Error) {\n channel.push(\"credential_auth_spec_error\", { request_id, ...error })\n } else {\n channel.push(\"credential_auth_spec_error\", {\n request_id,\n message: \"Unexpected Error\",\n })\n }\n }\n })\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 { credentials, parameters } = event\n const definition = registry.resolve(\"tool\", event.tool_name)\n\n const InvokeMethodWrapper = ToolDefinitionSchema.shape.invoke\n const invoke = InvokeMethodWrapper.implementAsync(definition.invoke)\n\n const data = await invoke({ args: { credentials, 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,2,3],"mappings":";;;;;;;;;;AAAA,SAAS,WAAW,OAAO;AACvB,QAAO,OAAO,UAAU;;;;;ACD5B,SAAS,MAAM,GAAG;AACd,QAAO,KAAK;;;;;ACDhB,SAAS,SAAS,OAAO;AACrB,QAAO,OAAO,UAAU;;;;;ACD5B,SAAS,UAAU,WAAW,SAAS;AACnC,KAAI,UACA;AAEJ,KAAI,OAAO,YAAY,SACnB,OAAM,IAAI,MAAM,QAAQ;AAE5B,OAAM;;;;;ACSV,MAAM,YAAY,EAAE,OAAO;CACzB,UAAU,EAAE,KAAK,CAAC,SAAS,UAAU,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,EAC3D,aAAa,iEACd,CAAC;CACF,YAAY,EAAE,IAAI;EAChB,UAAU;EACV,OAAO;EACR,CAAC;CACF,mBAAmB,EAChB,OAAO,EACN,OAAO,uCACR,CAAC,CACD,UAAU,CACV,QAAQ,UAAU;AACjB,SAAO,IAAI,IAAI,aAAa,gBAAiB,SAAS,MAAM,I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,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"}
1
+ {"version":3,"file":"index.mjs","names":["z","z","z"],"sources":["../node_modules/es-toolkit/dist/predicate/isFunction.mjs","../node_modules/es-toolkit/dist/predicate/isNil.mjs","../node_modules/es-toolkit/dist/predicate/isString.mjs","../node_modules/es-toolkit/dist/util/invariant.mjs","../src/env.ts","../src/config.ts","../src/oneauth.ts","../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","function isString(value) {\n return typeof value === 'string';\n}\n\nexport { isString };\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 { isNil, isString } from \"es-toolkit/predicate\"\nimport z from \"zod\"\n\ndeclare module \"bun\" {\n interface Env {\n /** The Hub Server runtime mode. */\n readonly HUB_MODE: \"debug\" | \"release\"\n /** The URL of the Hub Server WebSocket. */\n readonly HUB_WS_URL: string | undefined\n /** Whether to enable debug mode. */\n readonly DEBUG: boolean\n /** The API key for the Hub Server. */\n readonly HUB_DEBUG_API_KEY: string | undefined\n }\n}\n\nconst EnvSchema = z.object({\n HUB_MODE: z.enum([\"debug\", \"release\"]).default(\"debug\").meta({\n description: `The Hub Server runtime mode. This will be \"debug\" by default.`,\n }),\n HUB_WS_URL: z.url({\n protocol: /wss?/,\n error: \"HUB_WS_URL must be a valid WebSocket URL.\",\n }),\n HUB_DEBUG_API_KEY: z\n .string({\n error: \"HUB_DEBUG_API_KEY must be a string.\",\n })\n .optional()\n .refine((value) => {\n return Bun.env.NODE_ENV === \"production\" || (isString(value) && value.length > 0)\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})\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 .record(\n z.enum([\"staging\", \"production\"]),\n z.object({\n endpoint: z.url().optional(),\n access_token: z.string().optional(),\n }),\n )\n .optional(),\n hub: z\n .record(\n z.enum([\"staging\", \"production\"]),\n z.object({\n endpoint: z.url().optional(),\n }),\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(),\n expiresAt: z.string(),\n token: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n ipAddress: z.string().nullish(),\n userAgent: z.string().nullish(),\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(),\n name: z.string(),\n email: z.string(),\n emailVerified: z.boolean().optional(),\n image: z.string().nullish(),\n createdAt: z.string(),\n updatedAt: z.string(),\n role: z.string(),\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 referralCode: z.string(),\n referredBy: z.string().nullish(),\n metadata: z.record(z.string(), z.any()),\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.atomemo.ai\"\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(\n deployment: \"staging\" | \"production\",\n): Promise<GetSessionResponse> {\n const config = readConfig()\n\n if (!config?.auth?.[deployment]?.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?.[deployment]?.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?.[deployment]?.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","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 url = `${env.HUB_WS_URL}/${env.HUB_MODE}_socket`\n const socket = new Socket(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: Bun.env.NODE_ENV !== \"production\" ? { api_key: env.HUB_DEBUG_API_KEY } : undefined,\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\n if (Bun.env.NODE_ENV !== \"production\") {\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 }\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 { isNil } from \"es-toolkit\"\nimport { ZodError, z } from \"zod\"\nimport { getEnv } from \"./env\"\nimport { getSession } from \"./oneauth\"\nimport { createRegistry } from \"./registry\"\nimport { createTransporter, type TransporterOptions } from \"./transporter\"\n\nconst CredentialAuthenticateMessage = z.object({\n request_id: z.string(),\n credential: z.record(z.string(), z.any()),\n credential_name: z.string(),\n extra: z.record(z.string(), z.any()),\n})\n\nconst ToolInvokeMessage = z.object({\n request_id: z.string(),\n tool_name: z.string(),\n parameters: z.record(z.string(), z.any()),\n credentials: z.record(z.string(), z.any()).optional(),\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 const env = getEnv()\n const isDebugMode = env.HUB_MODE === \"debug\"\n\n let user: { name: string; email: string }\n\n if (isDebugMode) {\n try {\n const deployment = env.HUB_WS_URL.includes(\"atomemo.ai\") ? \"production\" : \"staging\"\n const session = await getSession(deployment)\n user = { name: session.user.name, email: session.user.email }\n } catch (error) {\n console.error(\"Error fetching user session:\", error)\n process.exit(1)\n }\n } else {\n try {\n const raw = await Bun.file(\"definition.json\").json()\n const definition = z.looseObject({ author: z.string(), email: z.string() }).parse(raw)\n user = { name: definition.author, email: definition.email }\n } catch (error) {\n if (error instanceof ZodError) {\n console.error(z.prettifyError(error))\n } else {\n console.error(\"Error parsing definition.json:\", error)\n }\n process.exit(1)\n }\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 topic = isDebugMode\n ? `debug_plugin:${registry.plugin.name}`\n : `release_plugin:${registry.plugin.name}__${env.HUB_MODE}__${pluginDefinition.version}`\n const { channel, dispose } = await transporter.connect(topic)\n\n if (isDebugMode) {\n const definition = registry.serialize().plugin\n channel.push(\"register_plugin\", definition)\n await Bun.write(\"definition.json\", JSON.stringify(definition, null, 2))\n }\n\n channel.on(\"credential_auth_spec\", async (message) => {\n const request_id = message.request_id\n\n try {\n const event = CredentialAuthenticateMessage.parse(message)\n const definition = registry.resolve(\"credential\", event.credential_name)\n if (isNil(definition.authenticate)) {\n throw new Error(\"Credential authenticate method is not implemented\")\n }\n\n const AuthenticateMethodWrapper = CredentialDefinitionSchema.shape.authenticate.unwrap()\n const authenticate = AuthenticateMethodWrapper.implementAsync(definition.authenticate)\n\n const { credential, extra } = event\n const data = await authenticate({ args: { credential, extra } })\n\n channel.push(\"credential_auth_spec_response\", { request_id, data })\n } catch (error) {\n if (error instanceof Error) {\n channel.push(\"credential_auth_spec_error\", { request_id, ...error })\n } else {\n channel.push(\"credential_auth_spec_error\", {\n request_id,\n message: \"Unexpected Error\",\n })\n }\n }\n })\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 { credentials, parameters } = event\n const definition = registry.resolve(\"tool\", event.tool_name)\n\n const InvokeMethodWrapper = ToolDefinitionSchema.shape.invoke\n const invoke = InvokeMethodWrapper.implementAsync(definition.invoke)\n\n const data = await invoke({ args: { credentials, 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,2,3],"mappings":";;;;;;;;;;AAAA,SAAS,WAAW,OAAO;AACvB,QAAO,OAAO,UAAU;;;;;ACD5B,SAAS,MAAM,GAAG;AACd,QAAO,KAAK;;;;;ACDhB,SAAS,SAAS,OAAO;AACrB,QAAO,OAAO,UAAU;;;;;ACD5B,SAAS,UAAU,WAAW,SAAS;AACnC,KAAI,UACA;AAEJ,KAAI,OAAO,YAAY,SACnB,OAAM,IAAI,MAAM,QAAQ;AAE5B,OAAM;;;;;ACSV,MAAM,YAAY,EAAE,OAAO;CACzB,UAAU,EAAE,KAAK,CAAC,SAAS,UAAU,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,EAC3D,aAAa,iEACd,CAAC;CACF,YAAY,EAAE,IAAI;EAChB,UAAU;EACV,OAAO;EACR,CAAC;CACF,mBAAmB,EAChB,OAAO,EACN,OAAO,uCACR,CAAC,CACD,UAAU,CACV,QAAQ,UAAU;AACjB,SAAO,IAAI,IAAI,aAAa,gBAAiB,SAAS,MAAM,IAAI,MAAM,SAAS;GAC/E,CACD,KAAK,EAAE,aAAa,kCAAkC,CAAC;CAC1D,OAAO,EACJ,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,UAAU,EAAE,KAAK;EAAC;EAAe;EAAc;EAAO,CAAC,CAAC,QAAQ,cAAc,CAAC,KAAK,EAClF,aAAa,gEACd,CAAC;CACH,CAAC;AAEF,IAAI;AAEJ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7C,IAAK,QAAQ,GAAG,QAAQ,QAAQ;KAChC;;EAEL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choiceopen/atomemo-plugin-sdk-js",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "JavaScript/TypeScript SDK for developing Choiceform Atomemo plugins",
5
5
  "homepage": "https://github.com/choice-open/atomemo-plugin-sdk-js#readme",
6
6
  "bugs": {