@open-wa/create 5.9.7 → 5.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/create",
3
- "version": "5.9.7",
3
+ "version": "5.10.0",
4
4
  "description": "Create an open-wa Easy API or SDK project",
5
5
  "type": "module",
6
6
  "bin": {
package/src/options.js CHANGED
@@ -27,6 +27,7 @@ export const choices = {
27
27
  };
28
28
 
29
29
  export const pluginChoices = [
30
+ { value: 'jev', label: 'Jev chat assistant', description: 'Choose chat actions and respond to text messages, with shared context for Voxtral.', package: '@open-wa/integration-jev', modes: ['easy-api', 'sdk'] },
30
31
  { value: 'voxtral', label: 'Voxtral', description: 'A conversational voice assistant using your Mistral account.', package: '@open-wa/integration-voxtral', modes: ['easy-api', 'sdk'] },
31
32
  { value: 'webhook', label: 'Webhooks', description: 'Forward WhatsApp events to your HTTP endpoint.', package: '@open-wa/integration-webhook', modes: ['easy-api', 'sdk'] },
32
33
  { value: 'chatwoot', label: 'Chatwoot', description: 'Connect a Chatwoot inbox through Easy API webhook routes.', package: '@open-wa/integration-chatwoot', modes: ['easy-api'] },
@@ -39,7 +40,7 @@ export const flags = {
39
40
  mode: { key: 'mode', description: 'easy-api or sdk' },
40
41
  language: { key: 'language', description: 'js or ts' },
41
42
  browser: { key: 'browser', description: 'auto, system-chrome, chrome or chromium' },
42
- plugins: { key: 'plugins', description: 'Comma-separated voxtral, webhook, chatwoot; or none' },
43
+ plugins: { key: 'plugins', description: 'Comma-separated jev, voxtral, webhook, chatwoot; or none' },
43
44
  'voxtral-mode': { key: 'voxtralMode', description: 'voice-notes, calls or both' },
44
45
  };
45
46
 
package/src/templates.js CHANGED
@@ -20,8 +20,10 @@ export function renderProject(input) {
20
20
  if (calling) { config.push(' licenseKey: process.env.OPENWA_LICENSE_KEY || undefined,'); env.push('# Calling-enabled open-wa license', 'OPENWA_LICENSE_KEY='); }
21
21
  if (options.plugins.length) {
22
22
  config.push(` plugins: ${JSON.stringify(options.plugins.map(id => pluginChoices.find(plugin => plugin.value === id).package))},`, ' pluginConfig: {');
23
+ if (options.plugins.some(id => ['jev', 'voxtral'].includes(id))) env.push('# Mistral API key for answer generation and optional Voxtral audio', 'MISTRAL_API_KEY=', '# Jev API key for decisions and chat actions', 'JEV_API_KEY=');
23
24
  for (const id of options.plugins) {
24
- if (id === 'voxtral') { config.push(` voxtral: { mode: '${options.voxtralMode}' },`); env.push('# Mistral API key for Voxtral', 'MISTRAL_API_KEY='); }
25
+ if (id === 'voxtral') config.push(` voxtral: { mode: '${options.voxtralMode}' },`);
26
+ if (id === 'jev') config.push(' jev: {},');
25
27
  if (id === 'webhook') {
26
28
  config.push(" webhook: { url: process.env.WEBHOOK_URL, events: ['message.received'] },");
27
29
  env.push('# HTTPS endpoint receiving WhatsApp message events', 'WEBHOOK_URL=');
@@ -35,7 +37,8 @@ export function renderProject(input) {
35
37
  }
36
38
  const typeImport = ext === 'ts' ? "import type { CreateOptions } from '@open-wa/wa-automate';\n" : '';
37
39
  const configSource = `import { existsSync } from 'node:fs';\n${typeImport}\nif (existsSync('.env')) process.loadEnvFile('.env');\n\nexport default {\n${config.join('\n')}\n}${ext === 'ts' ? ' satisfies CreateOptions' : ''};\n`;
38
- const entry = options.mode === 'easy-api' ? undefined : `import { create } from '@open-wa/wa-automate';\nimport config from './${configName}';\n\nconst client = await create(config);\nconsole.log('WhatsApp is ready. Send !ping from another account.');\n\nclient.onMessage(async message => {\n if (!message.fromMe && message.body === '!ping') {\n await client.sendText(message.from, 'pong');\n }\n});\n\nfor (const signal of ['SIGINT', 'SIGTERM']${ext === 'ts' ? ' as const' : ''}) {\n process.once(signal, () => {\n void client.stop(signal).catch(console.error);\n });\n}\n`;
40
+ const assistant = options.plugins.includes('jev');
41
+ const entry = options.mode === 'easy-api' ? undefined : `import { create } from '@open-wa/wa-automate';\nimport config from './${configName}';\n\nconst client = await create(config);\n${assistant ? "console.log('WhatsApp is ready. Send a message from another account to talk to Jev.');" : "console.log('WhatsApp is ready. Send !ping from another account.');\n\nclient.onMessage(async message => {\n if (!message.fromMe && message.body === '!ping') {\n await client.sendText(message.from, 'pong');\n }\n});"}\n\nfor (const signal of ['SIGINT', 'SIGTERM']${ext === 'ts' ? ' as const' : ''}) {\n process.once(signal, () => {\n void client.stop(signal).catch(console.error);\n });\n}\n`;
39
42
  const manifest = {
40
43
  name: projectName, version: '0.0.0', private: true, type: 'module',
41
44
  scripts: { start: options.mode === 'easy-api' ? 'wa-automate' : `node index.${ext}` },
@@ -43,7 +46,7 @@ export function renderProject(input) {
43
46
  dependencies: { '@open-wa/wa-automate': packageJson.version },
44
47
  ...(ext === 'ts' ? { devDependencies: { '@types/node': '^22.0.0', typescript: '^5.9.0' } } : {}),
45
48
  };
46
- const readme = `# ${projectName}\n\n${options.mode === 'easy-api' ? 'An open-wa Easy API project with the Neo dashboard.' : 'A persistent open-wa SDK bot. Send !ping to receive pong.'}\n\n## Start\n\nUse Node.js 22.21.1 or newer. ${options.install ? 'Dependencies are installed by the initializer.' : 'Run npm install first.'}\n${env.length ? '\nCopy .env.example to .env and fill in the values for your selected integrations.\n' : ''}\n\`\`\`bash\nnpm start\n\`\`\`\n\nLink WhatsApp using the QR code. Stop with Ctrl+C.\n${options.mode === 'easy-api' ? '\nOpen http://127.0.0.1:8080/dashboard/ for Neo and http://127.0.0.1:8080/api-docs/ for the HTTP API.\n' : '\nAdd your handlers in index.' + ext + '. SDK mode runs your code without an HTTP server or Neo dashboard. Choose Easy API if you want those controls.\n'}\n## Configuration\n\nEdit ${configName}. ${options.mode === 'sdk' ? 'The bot imports this file and passes its settings to create().' : 'Easy API discovers this file automatically.'}\n\nThe browser choice is ${options.browser}. Browser downloads and selected plugins are installed only when needed at startup and reused later.\n${calling ? '\nVoxtral calls require a calling-enabled open-wa license in OPENWA_LICENSE_KEY.\n' : ''}\nLocal .env files, dependency folders and session data are ignored by Git.\n\n[Setup guide](https://openwa.dev/docs/getting-started/initializer) · [Configure a project](https://openwa.dev/new)\n`;
49
+ const readme = `# ${projectName}\n\n${options.mode === 'easy-api' ? 'An open-wa Easy API project with the Neo dashboard.' : assistant ? 'A persistent open-wa SDK chat assistant powered by Jev.' : 'A persistent open-wa SDK bot. Send !ping to receive pong.'}\n\n## Start\n\nUse Node.js 22.21.1 or newer. ${options.install ? 'Dependencies are installed by the initializer.' : 'Run npm install first.'}\n${env.length ? '\nCopy .env.example to .env and fill in the values for your selected integrations.\n' : ''}\n\`\`\`bash\nnpm start\n\`\`\`\n\nLink WhatsApp using the QR code. Stop with Ctrl+C.\n${options.mode === 'easy-api' ? '\nOpen http://127.0.0.1:8080/dashboard/ for Neo and http://127.0.0.1:8080/api-docs/ for the HTTP API.\n' : '\nAdd your handlers in index.' + ext + '. SDK mode runs your code without an HTTP server or Neo dashboard. Choose Easy API if you want those controls.\n'}\n## Configuration\n\nEdit ${configName}. ${options.mode === 'sdk' ? 'The bot imports this file and passes its settings to create().' : 'Easy API discovers this file automatically.'}\n\nThe browser choice is ${options.browser}. Browser downloads and selected plugins are installed only when needed at startup and reused later.\n${calling ? '\nVoxtral calls require a calling-enabled open-wa license in OPENWA_LICENSE_KEY.\n' : ''}\nLocal .env files, dependency folders and session data are ignored by Git.\n\n[Setup guide](https://openwa.dev/docs/getting-started/initializer) · [Configure a project](https://openwa.dev/new)\n`;
47
50
  /** @type {Record<string, string>} */
48
51
  const files = {
49
52
  'package.json': `${JSON.stringify(manifest, null, 2)}\n`,