@aivin-labs/cli 1.0.0 → 1.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aivin Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -141,6 +141,8 @@ examples, and behavior notes for each one.
141
141
  | `aivin deploy` | Deploy the current plugin to your org |
142
142
  | `aivin test` | Deploy to a non-production instance, then smoke-test it and save a report |
143
143
  | `aivin plugin search <query>` | Search the platform's plugin ecosystem for something to reuse |
144
+ | `aivin plugin info <id>` | Show one plugin's detail directly by id, no search query needed |
145
+ | `aivin plugin ask [mission]` | One-shot: auto-pick the best-matching plugin for a mission and trigger it, like an agent would |
144
146
  | `aivin plugin make <description>` | AI-generate `src/main.ts` from a natural-language description |
145
147
  | `aivin plugin convert [hint]` | Turn an existing project in the current directory into a plugin |
146
148
  | `aivin plugin trigger [mission] [input]` | Invoke a deployed plugin for real and print the result |
package/bin/cli.mjs CHANGED
@@ -22,10 +22,10 @@ import { requireArg } from './lib/util.mjs';
22
22
  import { readStdin, createFromJSON, createInteractive, validatePluginConfig, validateMcpProxyConfig } from './lib/scaffold.mjs';
23
23
  import { buildDeploymentPayload, deployPlugin, incrementVersion } from './lib/deploy.mjs';
24
24
  import { initInteractive, makePluginFromDescription, convertExistingProject } from './lib/codegen.mjs';
25
- import { searchPlugins, streamPluginLogs, triggerPlugin } from './lib/pluginTrigger.mjs';
25
+ import { searchPlugins, showPluginInfo, askPlugin, streamPluginLogs, triggerPlugin, deletePluginCmd } from './lib/pluginTrigger.mjs';
26
26
  import { connectorAuthHeaders, connectorBaseUrl, listConnectors, registerConnector, searchConnectors } from './lib/connectors.mjs';
27
- import { attachStore, createStore, deleteStore, detachStore, listStores, setStoreEnabled } from './lib/store.mjs';
28
- import { buildMcpManifest, createMcpProxyPlugin, scanAndPublishMcp } from './lib/mcpProxy.mjs';
27
+ import { attachStore, createStore, deleteStore, detachStore, listStores, removeNode, setStoreEnabled } from './lib/store.mjs';
28
+ import { buildMcpManifest, parseMcpArgs, guessConnectorQueryFromEnvVarName, createMcpProxyPlugin, scanAndPublishMcp } from './lib/mcpProxy.mjs';
29
29
  import {
30
30
  saveGlobalApiKey,
31
31
  browserLogin,
@@ -336,6 +336,7 @@ program
336
336
  )
337
337
  .option('--workspace <id>', 'Workspace id to run the smoke test against (default: auto-picks your first one)')
338
338
  .option('--no-smoke-test', 'Only deploy - skip the generated-input invoke test and report')
339
+ .option('--verify-proxy', 'Also invoke MCP proxy entries for real (empty input) instead of skipping them - only use if you know the underlying tool(s) have no meaningful side effects')
339
340
  .action(async (options) => {
340
341
  try {
341
342
  await deployPlugin({
@@ -343,6 +344,7 @@ program
343
344
  label: 'Deploying to test instance',
344
345
  smokeTest: options.smokeTest !== false,
345
346
  workspaceOverride: options.workspace,
347
+ verifyProxy: options.verifyProxy,
346
348
  });
347
349
  } catch (error) {
348
350
  console.error(chalk.red('❌'), error.message);
@@ -356,11 +358,16 @@ pluginCommand
356
358
  .command('search [query]')
357
359
  .description("Search the platform's plugin ecosystem for something to reuse instead of writing it yourself")
358
360
  .option('--workspace <id>', 'Restrict to plugins visible in this workspace (default: your whole org)')
361
+ .option('--mcp <server_id>', 'List every tool/resource/prompt plugin generated from one MCP server (the id printed by `aivin mcp`/`aivin plugin search`, e.g. "modelcontextprotocol-servers-src-everything") instead of doing a text search')
362
+ .option('--store <store_id>', 'Restrict to plugins hosted on one self-hosted plugin store (the id printed by `aivin pluginstore ls`) - combines with the text query/--mcp, not a replacement for them')
359
363
  .option('--limit <n>', 'Max results to show')
360
364
  .option('--plain', 'Print a flat list instead of the interactive browser (for scripts/CI)')
361
365
  .action(async (query, options) => {
362
366
  try {
363
- query = await requireArg(query, { prompt: 'What are you looking for?', usage: 'Usage: aivin plugin search "<query>"' });
367
+ // --mcp is an exact-id lookup, not a text search - the query string is optional in that mode.
368
+ if (!options.mcp) {
369
+ query = await requireArg(query, { prompt: 'What are you looking for?', usage: 'Usage: aivin plugin search "<query>"' });
370
+ }
364
371
  await searchPlugins(query, options);
365
372
  } catch (error) {
366
373
  console.error(chalk.red('❌'), error.message);
@@ -368,6 +375,39 @@ pluginCommand
368
375
  }
369
376
  });
370
377
 
378
+ pluginCommand
379
+ .command('info <id>')
380
+ .description("Show one plugin's detail (input/output schema, setup needs) directly by id, no search query needed")
381
+ .option('--workspace <id>', 'Restrict to plugins visible in this workspace (default: your whole org)')
382
+ .option('--plain', 'Print flat instead of the interactive browser, if falling back to closest-match results')
383
+ .action(async (id, options) => {
384
+ try {
385
+ await showPluginInfo(id, options);
386
+ } catch (error) {
387
+ console.error(chalk.red('❌'), error.message);
388
+ process.exit(1);
389
+ }
390
+ });
391
+
392
+ pluginCommand
393
+ .command('ask [mission]')
394
+ .description('One-shot: search for the best-matching plugin for a plain-language mission and trigger it right away, like an agent would')
395
+ .option('--top <n>', 'How many candidates to consider/print as runner-up context (default 5) - only the top match is ever run')
396
+ .option('-i, --input <json>', 'Force specific fields (as JSON) alongside the auto-mapped ones - explicit fields win')
397
+ .option('--workspace <id>', 'Workspace id to search/run against (default: auto-picks your first one)')
398
+ .option('--agent <id>', 'Agent id to run as, if the plugin needs one for HIL/confirm behavior to be accurate')
399
+ .option('--watch-logs', "Also stream the chosen plugin's own live console output inline")
400
+ .option('--save', 'Write this run\'s result to .test/trigger/<timestamp>.json for later --compare')
401
+ .option('--compare <file>', 'Diff this run\'s result against a previously --save\'d .test/trigger/*.json file')
402
+ .action(async (mission, options) => {
403
+ try {
404
+ await askPlugin(mission, options);
405
+ } catch (error) {
406
+ console.error(chalk.red('❌'), error.message);
407
+ process.exit(1);
408
+ }
409
+ });
410
+
371
411
  pluginCommand
372
412
  .command('make [description]')
373
413
  .description('Generate src/main.ts from a natural-language business description')
@@ -431,6 +471,20 @@ pluginCommand
431
471
  }
432
472
  });
433
473
 
474
+ pluginCommand
475
+ .command('delete [id]')
476
+ .description("Delete a plugin you own, or every plugin from one batch deploy at once with --group <groupId> (e.g. everything `aivin mcp <url>` generated in one run - see the group_id it prints after deploying)")
477
+ .option('--group <groupId>', 'Delete every plugin sharing this group_id instead of a single plugin by id')
478
+ .option('-y, --yes', 'Skip the confirmation prompt (for scripts/CI)')
479
+ .action(async (id, options) => {
480
+ try {
481
+ await deletePluginCmd(id, options);
482
+ } catch (error) {
483
+ console.error(chalk.red('❌'), error.message);
484
+ process.exit(1);
485
+ }
486
+ });
487
+
434
488
  const connectorCommand = program.command('connector').description('Register and discover reusable connectors (OAuth apps / credential-form namespaces)');
435
489
 
436
490
  connectorCommand
@@ -591,6 +645,19 @@ pluginStoreCommand
591
645
  }
592
646
  });
593
647
 
648
+ pluginStoreCommand
649
+ .command('rm-node [store_id] [node_id]')
650
+ .description('Remove one node from a store (e.g. one that never came online) without touching its other nodes - org admin not required')
651
+ .option('-y, --yes', 'Skip the confirmation prompt')
652
+ .action(async (storeId, nodeId, options) => {
653
+ try {
654
+ await removeNode(storeId, nodeId, options);
655
+ } catch (error) {
656
+ console.error(chalk.red('❌'), error.message);
657
+ process.exit(1);
658
+ }
659
+ });
660
+
594
661
  pluginStoreCommand
595
662
  .command('detach')
596
663
  .description("Remove THIS machine's pairing only (local file only, no BE call) - the running aivin-service picks it up automatically")
@@ -613,6 +680,7 @@ mcpCommand
613
680
  .option('--publish', 'Deploy to your org, then submit for community store review (needs admin approval)')
614
681
  .option('--private', 'Deploy to your org only - default')
615
682
  .option('--org', 'Alias of --private - there is no narrower per-workspace scope today')
683
+ .option('--quiet', 'Skip live progress output while scanning (on by default otherwise)')
616
684
  .action(async (url, options) => {
617
685
  try {
618
686
  url = await requireArg(url, {
@@ -641,8 +709,10 @@ mcpCommand
641
709
  .option('--description <description>', 'Plugin description')
642
710
  .option(
643
711
  '--auth-secret-key <key>',
644
- 'Name of the workspace secret to use as the Bearer token, if the MCP server needs auth',
712
+ 'Name of the workspace secret to use as the token/credential, if the MCP server needs auth',
645
713
  )
714
+ .option('--auth-type <type>', 'auth_type value to send (default: "bearer" when --auth-secret-key is set) - check your backend for which values it supports')
715
+ .option('--connector <id>', "Existing connector id for this plugin's connection_id (readiness/\"needs login\" display only - does NOT inject anything into the running MCP server; run with no flags for the interactive per-variable auth setup that actually does)")
646
716
  .action(async (name, options) => {
647
717
  try {
648
718
  name = await requireArg(name, { prompt: 'Plugin name (lowercase letters, numbers, hyphens):', usage: 'Usage: aivin mcp create <name>' });
@@ -1231,7 +1301,7 @@ projectCommand
1231
1301
  }
1232
1302
  });
1233
1303
 
1234
- export { validatePluginConfig, incrementVersion, validateMcpProxyConfig, buildDeploymentPayload, buildMcpManifest };
1304
+ export { validatePluginConfig, incrementVersion, validateMcpProxyConfig, buildDeploymentPayload, buildMcpManifest, parseMcpArgs, guessConnectorQueryFromEnvVarName };
1235
1305
 
1236
1306
  // Only parse argv when run directly (`aivin ...` / `node bin/cli.mjs ...`),
1237
1307
  // not when this module is imported (e.g. by tests) - otherwise Commander
@@ -474,7 +474,9 @@ export async function runBrowserMissionLocal(mission, options) {
474
474
  if (interrupted) return;
475
475
  interrupted = true;
476
476
  console.log(chalk.yellow('\n\n⏹ Stopping... (requesting cancellation - may take a moment, one agentic step at a time)'));
477
- requestBrowserCancel(serverUrl, authHeaders).catch(() => {});
477
+ requestBrowserCancel(serverUrl, authHeaders).catch((e) =>
478
+ console.log(chalk.red(` ⚠️ Cancellation request failed to send (${e.message}) - the mission may keep running.`)),
479
+ );
478
480
  tunnel.close();
479
481
  console.log(chalk.gray(' The tab this mission was using is still open in your browser - close it yourself if you don\'t need it.'));
480
482
  };
@@ -569,7 +571,26 @@ export async function runBrowserMissionRemote(mission, options) {
569
571
  const threadId = result.data?.thread_id;
570
572
  console.log(chalk.gray(` Thread: ${threadId || 'unknown'}`));
571
573
 
572
- if (options.watch !== false && threadId) {
573
- await streamBrowserMissionLog(serverUrl, apiKey, threadId, tenantClient);
574
+ // Same cooperative-cancel wiring as the local-mode path above (requestBrowserCancel is
575
+ // tenant-scoped, not session/thread-scoped, so it applies here unchanged) - without this, Ctrl+C
576
+ // only stopped streamBrowserMissionLog's own SIGINT handler, which just disconnects the log
577
+ // socket and returns; the mission itself kept running server-side with nothing telling it to stop.
578
+ let interrupted = false;
579
+ const onSigint = () => {
580
+ if (interrupted) return;
581
+ interrupted = true;
582
+ console.log(chalk.yellow('\n\n⏹ Stopping... (requesting cancellation - may take a moment, one agentic step at a time)'));
583
+ requestBrowserCancel(serverUrl, authHeaders).catch((e) =>
584
+ console.log(chalk.red(` ⚠️ Cancellation request failed to send (${e.message}) - the mission may keep running.`)),
585
+ );
586
+ };
587
+ process.on('SIGINT', onSigint);
588
+
589
+ try {
590
+ if (options.watch !== false && threadId) {
591
+ await streamBrowserMissionLog(serverUrl, apiKey, threadId, tenantClient);
592
+ }
593
+ } finally {
594
+ process.off('SIGINT', onSigint);
574
595
  }
575
596
  }
@@ -210,6 +210,7 @@ export async function registerConnector() {
210
210
  );
211
211
  console.log(chalk.green(`\n✅ Registered connector "${res.data.connector.id}"`));
212
212
  console.log(chalk.gray(` Reference it from a plugin manifest's connection_id: "${res.data.connector.id}"`));
213
+ return res.data.connector;
213
214
  } catch (error) {
214
215
  const message = error.response?.data?.message?.message || error.response?.data?.message || error.message;
215
216
  throw new Error(`Register failed: ${message}`, { cause: error });
@@ -146,13 +146,51 @@ export async function smokeTestEntry(serverUrl, authHeaders, entry, workspaceId)
146
146
  return result;
147
147
  }
148
148
 
149
+ /**
150
+ * Invokes a proxy entry with empty input - `--verify-proxy` opt-in only counterpart to
151
+ * `smokeTestEntry`. Unlike code plugins, there's no AI-generated sample input to fall back on (a
152
+ * proxy's `input` schema is the generic `{ data: object }` passthrough - `generate-sample-data`
153
+ * has nothing meaningful to infer from that), so this sends an empty `arguments: {}` instead:
154
+ * enough to prove the MCP server is reachable and the tool/resource/prompt name resolves, without
155
+ * pretending to know what a "realistic" call looks like for an arbitrary external server.
156
+ */
157
+ export async function smokeTestProxyEntry(serverUrl, authHeaders, entry, workspaceId) {
158
+ const result = { plugin_id: entry.id, name: entry.name, func: entry.func || undefined };
159
+
160
+ const start = Date.now();
161
+ try {
162
+ const execRes = await axios.post(
163
+ `${serverUrl}/plugins/execute`,
164
+ { plugin_id: entry.id, arguments: {}, workspace_id: workspaceId, purpose: 'aivin test --verify-proxy - automated smoke test' },
165
+ authHeaders,
166
+ );
167
+ result.duration_ms = Date.now() - start;
168
+ result.response = execRes.data;
169
+ const status = String(execRes.data?.status || '').toLowerCase();
170
+ result.passed = ['success', 'waiting', 'needs_auth', 'hil_timeout'].includes(status) || execRes.data?.status === undefined;
171
+ } catch (error) {
172
+ result.duration_ms = Date.now() - start;
173
+ result.passed = false;
174
+ result.error = error.response?.data?.message || error.message;
175
+ }
176
+ return result;
177
+ }
178
+
149
179
  /**
150
180
  * Runs `smokeTestEntry` for every non-proxy entry and writes a JSON report to `.test/` in the
151
181
  * current project - one file per `aivin test` run, so you can diff/compare across runs.
182
+ *
183
+ * Proxy entries are skipped by default - calling an arbitrary external MCP server automatically,
184
+ * with no way to know whether that call is safe to repeat (an email-sending tool isn't idempotent
185
+ * the way a read-only one is), isn't something to do without the developer explicitly asking for
186
+ * it. `verifyProxy: true` (`aivin test --verify-proxy`) opts into `smokeTestProxyEntry` for those
187
+ * entries instead of skipping them - only pass it if you know what the underlying tool(s) do.
152
188
  */
153
- export async function runSmokeTest({ currentDir, serverUrl, apiKey, entries, isProxyPlugin, workspaceOverride }) {
154
- if (isProxyPlugin) {
155
- console.log(chalk.gray(' Proxy plugin - no generic smoke test to run (calls an external system, not your code).'));
189
+ export async function runSmokeTest({ currentDir, serverUrl, apiKey, entries, isProxyPlugin, workspaceOverride, verifyProxy }) {
190
+ const hasProxyEntries = entries.some((e) => e.proxy_config);
191
+
192
+ if (isProxyPlugin && !verifyProxy) {
193
+ console.log(chalk.gray(' Proxy plugin - no generic smoke test to run (calls an external system, not your code). Pass --verify-proxy to invoke it for real instead.'));
156
194
  return;
157
195
  }
158
196
 
@@ -175,6 +213,9 @@ export async function runSmokeTest({ currentDir, serverUrl, apiKey, entries, isP
175
213
  }
176
214
 
177
215
  console.log(chalk.blue('🧪 Running smoke test (generated input, real invoke)...'));
216
+ if (hasProxyEntries && verifyProxy) {
217
+ console.log(chalk.yellow('⚠️ --verify-proxy: invoking the real external MCP server(s) below with empty input - only use this if you know calling them has no meaningful side effects.'));
218
+ }
178
219
  // Give the container a moment to finish binding its gRPC server after the build/up completed.
179
220
  await new Promise((resolve) => setTimeout(resolve, 3000));
180
221
 
@@ -182,10 +223,27 @@ export async function runSmokeTest({ currentDir, serverUrl, apiKey, entries, isP
182
223
  for (const entry of entries) {
183
224
  // A mixed multi-function batch can have some proxy entries and some real-code entries (see
184
225
  // buildDeploymentPayload's doc comment) - the batch-level `isProxyPlugin` check above only
185
- // catches the all-proxy case, so skip proxy entries individually here too: they call an
186
- // external system, not your code, same reasoning as the early-return above.
226
+ // catches the all-proxy case, so every proxy entry is handled here individually too: they call
227
+ // an external system, not your code, same reasoning as the early-return above.
187
228
  if (entry.proxy_config) {
188
- console.log(chalk.gray(` ${entry.name} - proxy plugin, no generic smoke test to run`));
229
+ if (!verifyProxy) {
230
+ console.log(chalk.gray(` ${entry.name} - proxy plugin, no generic smoke test to run`));
231
+ continue;
232
+ }
233
+ // `request_hil` is set when the MCP server itself declared this tool destructive/non-readonly
234
+ // (see the backend's McpAdapter.annotationsSuggestHil, sourced from the MCP spec's own
235
+ // readOnlyHint/destructiveHint annotations) - a real signal from the tool's own author, not a
236
+ // guess. `--verify-proxy` already only exists for tools the caller has vetted as safe to call
237
+ // automatically; skip the ones the server itself flagged as NOT safe to call blind, even under
238
+ // that flag, rather than trusting the caller to have known this too.
239
+ if (entry.request_hil) {
240
+ console.log(chalk.yellow(` ${entry.name} - skipped: this tool is flagged destructive/non-readonly by the MCP server itself (request_hil) - verify it manually instead`));
241
+ continue;
242
+ }
243
+ const proxyResult = await smokeTestProxyEntry(serverUrl, authHeaders, entry, workspaceId);
244
+ results.push(proxyResult);
245
+ const proxyIcon = proxyResult.passed ? chalk.green('✅') : chalk.red('❌');
246
+ console.log(` ${proxyIcon} ${entry.name} (proxy) - ${proxyResult.passed ? `passed (${proxyResult.duration_ms}ms)` : `failed: ${proxyResult.error || 'unexpected status'}`}`);
189
247
  continue;
190
248
  }
191
249
  const result = await smokeTestEntry(serverUrl, authHeaders, entry, workspaceId);
@@ -211,7 +269,7 @@ export async function runSmokeTest({ currentDir, serverUrl, apiKey, entries, isP
211
269
  }
212
270
  }
213
271
 
214
- export async function deployPlugin({ endpointPath, label, smokeTest, workspaceOverride }) {
272
+ export async function deployPlugin({ endpointPath, label, smokeTest, workspaceOverride, verifyProxy }) {
215
273
  console.log(chalk.blue(`🚀 ${label}...`));
216
274
 
217
275
  const currentDir = process.cwd();
@@ -325,7 +383,7 @@ export async function deployPlugin({ endpointPath, label, smokeTest, workspaceOv
325
383
  }
326
384
 
327
385
  if (smokeTest) {
328
- await runSmokeTest({ currentDir, serverUrl, apiKey, entries, isProxyPlugin, workspaceOverride });
386
+ await runSmokeTest({ currentDir, serverUrl, apiKey, entries, isProxyPlugin, workspaceOverride, verifyProxy });
329
387
  }
330
388
  } catch (error) {
331
389
  clearInterval(loadingInterval);