@aivin-labs/cli 1.0.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/docs/CLI.md ADDED
@@ -0,0 +1,1079 @@
1
+ # 🖥️ CLI Reference
2
+
3
+ `aivin` is built on [Commander](https://github.com/tj/commander.js), so help is always available
4
+ without needing this doc:
5
+
6
+ ```bash
7
+ aivin --help # or: aivin help
8
+ aivin <command> --help # or: aivin help <command>
9
+ ```
10
+
11
+ Every command below is real - this is the exact output of `aivin --help` as of this CLI version.
12
+
13
+ ```
14
+ Usage: aivin [options] [command]
15
+
16
+ aivin CLI - scaffold, run, and deploy Aivin plugins
17
+
18
+ Options:
19
+ -V, --version output the version number
20
+ -h, --help display help for command
21
+
22
+ Commands:
23
+ create [options] [name] Create new plugin
24
+ init [options] [name] Set up a new plugin step by step: asks what it should do, then generates real working code from that description
25
+ validate [options] Validate manifest.json in the current directory (or --json/--stdin for scripted use)
26
+ start [options] Start plugin server
27
+ deploy Deploy plugin to your org on the Aivin server
28
+ test [options] Deploy to a non-production test instance, then smoke-test it with generated input and save a report to .test/
29
+ plugin AI-assisted plugin authoring
30
+ connector Register and discover reusable connectors (OAuth apps / credential-form namespaces)
31
+ pluginstore Self-hosted aivin-service worker (Docker) - attach it to your org as a plugin store
32
+ mcp [options] [url] MCP proxy plugins - wrap an external MCP server tool/resource/prompt, no code required
33
+ login [options] [baseUrl] Log in and save an API key for plugin deployment (opens your browser by default)
34
+ whoami Show which account is currently logged in on this machine (reads ~/.aivin/credentials - no server call)
35
+ key Manage named API keys for your account
36
+ browser [options] [mission] Run an AI Browser mission - by default opens/reuses a local browser window dedicated to AI Browser (own profile, own cookies - log in once, watch missions run live from then on); --remote uses a server-side browser instead
37
+ do [options] [agentNickname] [mission] Have <agentNickname> work toward a goal in the background - not a specific deployed plugin
38
+ task [options] [description] Create a new task from a plain-language description
39
+ workspace [options] Browse your workspaces and projects, and pick one to use with --workspace/--project
40
+ agent Search, install, create, and publish AI Staff agents
41
+ project Create, update, and delete projects within a workspace
42
+ help [command] display help for command
43
+ ```
44
+
45
+ ## `aivin init [name]`
46
+
47
+ The simplest way to start: asks what the plugin should do, then scaffolds the project **and**
48
+ generates real working code from that description in one step - no separate `aivin create` +
49
+ `aivin plugin make` needed.
50
+
51
+ ```bash
52
+ aivin init my-plugin
53
+ # ? Plugin name: my-plugin
54
+ # ? What should this plugin do? (be specific - this is what generates your code)
55
+ # > Summarize a support ticket and tag its urgency low/medium/high
56
+ ```
57
+
58
+ Options:
59
+
60
+ ```
61
+ Options:
62
+ --name <name> Plugin name (if not specified, will prompt)
63
+ --model <model> LLM model to use for generation
64
+ --provider <provider> LLM provider to use for generation
65
+ ```
66
+
67
+ Writes two source files instead of one, unlike `aivin create`:
68
+
69
+ - **`src/service.ts`** - the actual business logic, AI-generated from your description. A single
70
+ exported `execute(input, ctx)` that returns plain result data (or throws a plain `Error`) - no
71
+ `PluginResponse`/`PluginStatus` boilerplate to think about.
72
+ - **`src/main.ts`** - a thin, static wrapper (not AI-generated, doesn't change between runs). Calls
73
+ `execute()` and packages the result into the `PluginResponse` the platform expects. This filename
74
+ is fixed - the runtime always loads exactly `src/main.ts`, so it's never regenerated or renamed.
75
+
76
+ If code generation fails (network issue, `API_KEY` not set, etc.), `aivin init` still leaves you
77
+ with a working, deployable scaffold - it falls back to the same plain placeholder `aivin create`
78
+ writes, so nothing is left half-broken.
79
+
80
+ Regenerating later: `aivin plugin make "<new description>"` detects `src/service.ts` and targets it
81
+ instead of `src/main.ts`, so the split is preserved (see below).
82
+
83
+ Prefer no AI step at all? `aivin create` scaffolds the same project structure minus the generation -
84
+ one `src/main.ts` you write by hand.
85
+
86
+ ## `aivin create`
87
+
88
+ Scaffold a new plugin project (`manifest.json`, `src/main.ts`, `package.json`, `tsconfig.json`,
89
+ `.env`, `.gitignore`).
90
+
91
+ ```
92
+ Usage: aivin create [options] [name]
93
+
94
+ Options:
95
+ --json <config> JSON config (AI mode)
96
+ --stdin Read from stdin
97
+ --name <name> Plugin name (if not specified, will prompt)
98
+ --silent Silent mode
99
+ --json-output JSON output
100
+ ```
101
+
102
+ - `aivin create <name>` (or `--name <name>`) → creates a new `<name>/` subdirectory and scaffolds
103
+ into it, no name prompt (description still prompted).
104
+ - No name at all → interactive prompts for both name and description, scaffolding into the
105
+ **current** directory - `mkdir`/`cd` into your target folder yourself first.
106
+ - `--json '<config>'` / `--stdin` → non-interactive/scripted mode for AI tooling, also creates a
107
+ `<config.name>/` subdirectory. `config` needs at least `name` and `description`; anything else
108
+ (`input`, `output`, `trigger_type`, ...) is merged straight into the generated `manifest.json`.
109
+ `config` may also be a path to a JSON file.
110
+ - `--json-output` → prints a machine-readable `{ success, pluginDir, name, description, timestamp }`
111
+ result instead of the usual colored console output.
112
+
113
+ ```bash
114
+ aivin create my-plugin
115
+ aivin create --json '{"name":"my-plugin","description":"Summarize tickets"}'
116
+ ```
117
+
118
+ ## `aivin validate`
119
+
120
+ Validates a plugin config against the same rules `aivin create` enforces (name format, required
121
+ `description`, and - if present - `proxy_config` completeness for MCP proxy plugins). Doesn't touch
122
+ the network.
123
+
124
+ With no flags, validates `manifest.json` in the current directory - the common case:
125
+
126
+ ```bash
127
+ cd my-plugin
128
+ aivin validate
129
+ ```
130
+
131
+ ```
132
+ Options:
133
+ --json <config> JSON config, instead of reading manifest.json from the current directory
134
+ --stdin Read JSON config from stdin, instead of reading manifest.json
135
+ --json-output JSON output
136
+ ```
137
+
138
+ `--json`/`--stdin` remain for scripted/CI use where the config isn't a file on disk yet:
139
+
140
+ ```bash
141
+ aivin validate --json '{"name":"my-plugin","description":"x"}'
142
+ ```
143
+
144
+ ## `aivin start`
145
+
146
+ Runs the current plugin directory (must contain `manifest.json` and `src/main.ts`) against a real
147
+ local server - specifically, this project's own installed `@aivin-labs/sdk`'s `bin/server.mjs`
148
+ (resolved from *this project's* `node_modules`, not the CLI's own install location - if you see
149
+ "Could not find @aivin-labs/sdk installed", run `npm install` first). Starts:
150
+
151
+ 1. A real gRPC server (bind `0.0.0.0:50051`) - the same protocol the production host uses to
152
+ trigger your handler(s). You don't call this directly.
153
+ 2. In development (anything but `NODE_ENV=production`), an HTTP test shim on `:4001` (override with
154
+ `LOCAL_TEST_PORT`) for manual `curl` testing.
155
+
156
+ ```bash
157
+ aivin start
158
+ curl -X POST http://localhost:4001/invoke -H 'content-type: application/json' \
159
+ -d '{"input":{"text":"hello"}}'
160
+ ```
161
+
162
+ With more than one `plugins: []` entry, pass `mission` to pick which entry's `func` runs - it's
163
+ matched against each entry's `id`, falling back to `func` (a single-entry manifest, the scaffold
164
+ default, always resolves to its one entry - no `mission` needed):
165
+
166
+ ```bash
167
+ curl -X POST http://localhost:4001/invoke -H 'content-type: application/json' \
168
+ -d '{"mission":"summarize-ticket","input":{"text":"hello"}}'
169
+ ```
170
+
171
+ SDK calls made while running default to the **production** backend (`api.aivin.cloud`) if
172
+ `SDK_ENDPOINT` isn't set in `.env` - point it at a local/dev backend instead if you don't want
173
+ that (see [Environment variables](#environment-variables) below).
174
+
175
+ ### Hot-reload
176
+
177
+ Saving `src/**` or `manifest.json` re-imports the plugin in place - no more Ctrl+C + `aivin start`
178
+ again after every edit. Both the real gRPC server and the `:4001` HTTP test shim pick up the change
179
+ together. A broken save (syntax error, missing export) is reported and the *previous* working
180
+ version keeps serving until you fix it - a typo mid-edit doesn't kill the running server.
181
+
182
+ ```
183
+ ♻️ Reloaded (src/main.ts): my-plugin (My Plugin) v0.1.0
184
+ ```
185
+
186
+ On by default in development; disabled automatically inside a real deployed container (detected via
187
+ `SDK_SECRET_FILE`, which only a real deploy sets - `NODE_ENV=production` alone doesn't reliably mean
188
+ "deployed", the platform's own container build never sets it). This same file is also the
189
+ container's entrypoint in production, where the plugin source is also bind-mounted read-only, so
190
+ there'd be nothing for the watcher to see even without this check. Turn it off by hand with
191
+ `--no-watch` or `AIVIN_START_WATCH=false`.
192
+
193
+ ### Live per-call debugging: `--debug` / `--debug-json`
194
+
195
+ By default you only see a trace summary once the whole invocation finishes (`AIVIN_TRACE`, on by
196
+ default - see [Environment variables](#environment-variables)). To watch each `sdk.*` call as it
197
+ happens instead:
198
+
199
+ ```bash
200
+ aivin start --debug # human-readable: one line per call, live
201
+ aivin start --debug-json # same events, one JSON object per line - for a script/coding agent
202
+ # to parse instead of pattern-matching free text
203
+ ```
204
+
205
+ Both are `SDK_DEBUG=true`/`SDK_DEBUG=json` under the hood (settable directly if you're not going
206
+ through `aivin start`, e.g. inside `aivin test`'s smoke-test run). Each line/event covers exactly
207
+ one `sdk.*` call: `namespace`, `duration_ms`, `attempts`, `success`, `error` (if any).
208
+
209
+ ## `aivin deploy`
210
+
211
+ Deploys the plugin in the current directory (`manifest.json` + every project file except
212
+ `node_modules/`, `.git/`, `.tmp/`, `dist/`, `build/`, `.test/`, `.gitignore`, `yarn.lock`, and
213
+ `.env`) to `POST /plugins/deploy`. Always private to your org - there's no CLI-reachable "submit to
214
+ the public store" path for regular code/Docker plugins today (that only exists through the browser
215
+ CodeEditor's publish flow, a different runtime). **MCP proxy plugins are the one exception** -
216
+ `aivin mcp <url> --publish` (below) can submit those to the community store directly from the CLI.
217
+
218
+ - `manifest.json` is normally the default `{ ...commonFields, plugins: [...] }` shape (see
219
+ [MANIFEST.md#default-shape](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md#default-shape)) - common fields are copied onto each
220
+ entry in `plugins` before upload, and all entries deploy together, sharing one running
221
+ container. The legacy flat single-object shape is still accepted.
222
+ - If every entry's `manifest.proxy_config` is set (MCP proxy plugins - see `aivin mcp create`
223
+ below), no files are read or sent at all - just the manifest.
224
+ - `package-lock.json` is auto-generated (`npm install --package-lock-only`) before upload if missing
225
+ - the backend's build runs `npm ci`, which requires one.
226
+ - On success, auto-increments `manifest.json`'s patch version(s) and writes back the plugin id(s)
227
+ the server assigned.
228
+
229
+ ```bash
230
+ aivin deploy
231
+ ```
232
+
233
+ ## `aivin test`
234
+
235
+ Same payload/logic as `aivin deploy`, but against `POST /plugins/test/deploy` - a non-production
236
+ instance for verifying the plugin runs end-to-end on real infra (real container, real gRPC, real
237
+ the SDK) before anyone else can see it. This endpoint is blocked by the backend in production.
238
+
239
+ After a successful deploy, it also **smoke-tests** every non-proxy plugin entry: generates sample
240
+ input from `manifest.json`'s `input` schema (`POST /code/generate-sample-data`), invokes the plugin
241
+ for real (`POST /plugins/execute`) against a workspace, and writes a pass/fail report to
242
+ `.test/<timestamp>.json` in the project directory (also excluded from future deploy uploads).
243
+
244
+ **MCP proxy entries are skipped** - there's no generic "sample input" that makes sense for a tool
245
+ schema an external MCP server defines itself, so `aivin test` deploys them but runs no automated
246
+ invoke/report. Use `aivin plugin trigger --id <pluginId> -a "<prompt>"` (or the interactive "Test
247
+ now?" step `aivin mcp <url>` offers right after deploy) to test one by hand instead.
248
+
249
+ ```
250
+ Options:
251
+ --workspace <id> Workspace id to run the smoke test against (default: auto-picks your first one)
252
+ --no-smoke-test Only deploy - skip the generated-input invoke test and report
253
+ ```
254
+
255
+ ```bash
256
+ aivin test # deploy + smoke-test + report
257
+ aivin test --workspace <id> # smoke-test against a specific workspace
258
+ aivin test --no-smoke-test # deploy only, same as before this flag existed
259
+ ```
260
+
261
+ ## `aivin plugin make <description>`
262
+
263
+ AI-generates a plugin from a natural-language description, via `POST /code/generate-project` -
264
+ **complexity-adaptive**: the backend classifies the requirement first, and only escalates beyond a
265
+ single `src/main.ts` when it's genuinely complex.
266
+
267
+ ```
268
+ Options:
269
+ --model <model> LLM model to use for generation
270
+ --provider <provider> LLM provider to use for generation
271
+ ```
272
+
273
+ ```bash
274
+ aivin plugin make "Summarize a support ticket and tag its urgency"
275
+ ```
276
+
277
+ - **Simple/moderate** requirement (the common case): exactly one `src/main.ts`, one generation call
278
+ - unchanged from before. Same conventions as always (`main(mission, input, ctx)`,
279
+ `import { ai } from '@aivin-labs/sdk'`, `PluginResponse`).
280
+ - **Complex** requirement (several genuinely independent capabilities, or logic too large for one
281
+ flat function): the backend plans a small multi-file project first, generates each file, and - if
282
+ the plan calls for it - returns a [multi-function manifest](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md#multi-function-plugins)
283
+ fragment that replaces `manifest.json`'s `plugins[]` with one entry per capability.
284
+
285
+ Requires `manifest.json` to already exist (`aivin create` first).
286
+
287
+ ### Self-correction loop
288
+
289
+ Generation isn't one-shot, and for a multi-file plan it isn't one-file-at-a-time either: files with
290
+ no dependency on each other generate in parallel (only a file that genuinely needs to see another
291
+ one's content, per the plan's own `depends_on`, waits for it first). After writing every returned
292
+ file, if the project's own `typescript` devDependency is installed (`npm install` already run), the
293
+ whole project is type-checked with `tsc --noEmit`. Real compiler errors (exact
294
+ `file(line,col): error TSxxxx: ...` lines) are attributed back to whichever file they were reported
295
+ against and sent to the AI for a surgical fix - up to 2 rounds, across as many files as had errors:
296
+
297
+ ```
298
+ 🤖 Generating plugin
299
+ ✅ 2 file(s) generated (src/main.ts, src/lib/search.ts)
300
+ ⚠️ 2 compiler error(s) across 1 file(s) - asking the AI to fix...
301
+ ✅ Fixed - clean type-check after 1 attempt(s)
302
+ ```
303
+
304
+ If `node_modules` isn't installed yet, type-checking (and the self-correction it enables) is skipped
305
+ silently - run `npm install` first if you want it. If errors remain after both rounds, every file is
306
+ still written, with every remaining error printed for you to fix by hand.
307
+
308
+ Review generated code before relying on it either way - self-correction only catches what `tsc`
309
+ catches (type errors), not wrong business logic.
310
+
311
+ ## `aivin plugin convert [hint]`
312
+
313
+ Hands the existing project in the current directory to the backend's agentic project-conversion
314
+ pipeline instead of generating locally. Unlike `plugin make`/`plugin init` (a single AI call per
315
+ file, run entirely from what you pass it), this command:
316
+
317
+ 1. Uploads only the **directory tree** - paths and byte sizes, never file content - so the request
318
+ stays cheap no matter how large the project is.
319
+ 2. The backend scans it: it decides which files are actually worth reading (entry points,
320
+ `package.json`, anything name-suggestive of routes/tools/skills) and asks the CLI to read them
321
+ back one at a time, over the same socket connection `aivin plugin logs` uses.
322
+ 3. It plans a conversion - single `main()` vs. a [multi-function manifest](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md#multi-function-plugins)
323
+ (one `plugins[]` entry per independent capability), and which files to create vs. adapt in
324
+ place - detecting the project's shape (a plain script, an MCP server, an API backend with
325
+ routes, a Claude-style skill) from what it actually read, not a fixed regex. If the project isn't
326
+ TypeScript/JavaScript (Python, Go, ...), every file becomes a **port** (translated, not edited) -
327
+ the plan always uses `create` in that case, never `update`, since there's no existing `.ts` file
328
+ to adapt in place.
329
+ 4. It generates/updates each planned file, then **verifies with a real `tsc --noEmit` run** on your
330
+ machine (via the same tool-call channel) and self-corrects on real compiler errors, up to twice.
331
+
332
+ Every step prints live as it happens - this loop can take a while on a real project, so it's never
333
+ silent:
334
+
335
+ ```bash
336
+ cd your-existing-project
337
+ aivin plugin convert
338
+ # 📂 Scanning project tree...
339
+ # 142 file(s) in tree (content read on demand by the server, never uploaded up front)
340
+ # 🤖 Converting - this loops (scan → plan → generate → verify), watch for progress below...
341
+ #
342
+ # [10:32:01] Scanning project tree (142 entries)...
343
+ # [10:32:03] Reading 3 file(s): package.json, src/index.ts, src/tools/search.ts
344
+ # [10:32:07] Plan ready: mcp_server, 2 file(s) - Two independent MCP tools found (search, fetch);
345
+ # splitting into a multi-function manifest so each is separately callable.
346
+ # [10:32:15] Generating 2 file(s) in parallel: src/main.ts, src/lib/search.ts
347
+ # [10:32:22] Type-checking (attempt 1)...
348
+ # [10:32:23] Type-check clean
349
+ # [10:32:23] All required exports present
350
+ # [10:32:24] Running a smoke test with generated sample input (may make real SDK/AI calls using your credentials)...
351
+ # [10:32:31] Smoke test passed
352
+ # ✅ Conversion done (mcp_server, 2 file(s))
353
+ ```
354
+
355
+ The smoke test only runs if the type-check passed first (no point executing code that doesn't even
356
+ compile) and `@aivin-labs/sdk` is already installed locally (`npm install`) - skipped, not failed,
357
+ otherwise. It spawns the real plugin runtime on your machine on off-default ports (won't collide with
358
+ a real `aivin start`) with AI-generated sample input, so a plugin whose logic calls `ai.prompt()` or
359
+ other SDK methods will make a real call using your credentials during this step.
360
+
361
+ ```
362
+ Options:
363
+ --model <model> LLM model to use for generation
364
+ --provider <provider> LLM provider to use for generation
365
+ --force Re-run conversion even if src/main.ts already exists (e.g. redo a
366
+ previous bad/stale result)
367
+ ```
368
+
369
+ - No `manifest.json` needed first - if one doesn't exist, it's created from `package.json` (name,
370
+ description) or the directory name.
371
+ - Fails if `src/main.ts` already exists, unless `--force` is given - the plain (no-flag) case is
372
+ for a project that isn't a plugin yet; `--force` re-runs the whole scan/plan/generate/verify loop
373
+ against a project this command already converted before (the earlier plan turned out wrong, the
374
+ project changed since, whatever the reason) - `src/main.ts` isn't excluded from what gets scanned,
375
+ so the new plan is free to mark it `update`, and the usual per-file overwrite confirmation still
376
+ applies to it like any other existing file.
377
+ - `[hint]` is optional extra guidance, e.g. which function to focus on - passed straight to the
378
+ backend's planning step.
379
+ - If the plan is multi-function, `manifest.json`'s `plugins[]` is replaced with one entry per
380
+ planned capability (fresh local ids - `aivin deploy` still assigns the real ones).
381
+ - Requires a live connection to the Aivin server for the whole duration (it's not a local batch
382
+ job) - the socket is what lets the backend read files on demand and stream progress back.
383
+ - Only one conversion can run at a time per project - starting a second one against the same
384
+ project while the first is still running fails fast instead of racing both against the same
385
+ files. If the previous run's process died without cleanly finishing, this frees up on its own
386
+ within moments, not stuck for the full run duration.
387
+ - The whole run gives up after ~15 minutes regardless of how far it got, so a stuck step can't hold
388
+ the connection open forever.
389
+
390
+ ### Overwrite safety
391
+
392
+ Unlike `plugin make`, this command can touch files that **already exist** in your project - the
393
+ backend's plan may mark some as `update` (adapt in place) rather than `create` (new file):
394
+
395
+ - Before scanning starts, if the directory is a git repo with uncommitted changes, you're warned
396
+ and (in an interactive terminal) asked to confirm before continuing at all.
397
+ - Before any individual existing file is actually overwritten, you're prompted per-file (with a
398
+ quick `git status` hint - untracked vs. has uncommitted changes - when available) - declining
399
+ skips just that file, the rest of the conversion continues.
400
+ - Non-interactive runs (CI/scripts) can't prompt, so they proceed automatically - the decision is
401
+ still printed to the log either way, it's just not blocking.
402
+
403
+ Review the generated code before relying on it - self-correction only catches what `tsc` catches
404
+ (type errors), not wrong business logic, and the file/project-kind detection is a best effort, not
405
+ a guarantee.
406
+
407
+ ## `aivin plugin search <query>`
408
+
409
+ Searches the platform's plugin ecosystem before you write new logic - the same relevance-ranked
410
+ lookup the platform's own agent uses to auto-select a plugin for a mission (`GET /plugins/search`).
411
+ Doesn't need to be run from inside a plugin project.
412
+
413
+ ```bash
414
+ aivin plugin search "send a slack message"
415
+ ```
416
+
417
+ Options:
418
+
419
+ ```
420
+ Options:
421
+ --workspace <id> Restrict to plugins visible in this workspace (default: your whole org)
422
+ --limit <n> Max results to show
423
+ --plain Print a flat list instead of the interactive browser (for scripts/CI)
424
+ ```
425
+
426
+ In a real terminal, results open in an interactive browser: `↑`/`↓` to move between matches,
427
+ `space`/`enter` to open a plugin's detail view (full description, version, input/output schema),
428
+ `esc`/`backspace` to go back to the list, `q` to quit. Non-TTY contexts (scripts, CI, piped
429
+ output) or `--plain` fall back to a flat printed list.
430
+
431
+ Call one from your own plugin with `import { call } from '@aivin-labs/sdk'` then
432
+ `await call('<plugin_id>', params)`.
433
+
434
+ ## `aivin plugin trigger [mission] [input]`
435
+
436
+ Invokes an **already-deployed** plugin for real and prints the result - the same
437
+ `POST /plugins/execute` the platform's own Playground ("Thử nghiệm" tab) uses, so it exercises the
438
+ exact same code path a running agent would hit. Run it from the plugin's project directory -
439
+ `manifest.json` supplies the plugin id (`--func <name>` picks the entry for a multi-function
440
+ plugin) - or pass `--id` directly for a plugin with no local project directory (e.g. one built by
441
+ `aivin mcp <url>`, which deploys straight from a scan and never writes a `manifest.json` anywhere).
442
+
443
+ ```
444
+ Options:
445
+ -a, --auto <prompt> Natural-language prompt - the platform auto-maps it onto
446
+ the input schema for you
447
+ --id <pluginId> Plugin id to trigger directly - skips the local
448
+ manifest.json lookup entirely
449
+ --func <name> Which function to trigger, for a multi-function plugin
450
+ (matches name/func/id) - ignored when --id is given
451
+ --workspace <id> Workspace id to run against (default: auto-picks your
452
+ first one)
453
+ --agent <id> Agent id to run as, if the plugin needs one for
454
+ HIL/confirm behavior to be accurate
455
+ --watch-logs Also stream the plugin's own live console output inline
456
+ (same feed as `aivin plugin logs`) - no second terminal
457
+ needed. Requires permission to view that plugin's logs;
458
+ most store plugins from other orgs just fall back to
459
+ the REST result only.
460
+ --save Write this run's result to .test/trigger/<ts>.json
461
+ --compare <file> Diff this run against a previously --save'd file
462
+ ```
463
+
464
+ ```bash
465
+ # no local project directory - e.g. an MCP proxy plugin from `aivin mcp <url>`
466
+ aivin plugin trigger --id my-mcp-plugin-id -a "search for open issues about login"
467
+ ```
468
+
469
+ **Direct mode** - `<mission>` (becomes `main()`'s `mission` argument) and `<input>` (a JSON string,
470
+ becomes `main()`'s `input` argument) both required:
471
+
472
+ ```bash
473
+ aivin plugin trigger "summarize this" '{"text":"Aivin plugins are easy to write."}'
474
+ ```
475
+
476
+ **Auto mode** (`-a`/`--auto <prompt>`) - give it free text instead of structured JSON; the backend's
477
+ own input-mapping (`mapDataToSchema`, the same mechanism the Playground's chat-style tester uses)
478
+ maps it onto `manifest.json`'s `input` schema for you:
479
+
480
+ ```bash
481
+ aivin plugin trigger -a "Summarize this ticket: customer can't log in after the last update"
482
+ ```
483
+
484
+ `<input>` can still be given alongside `-a` for fields you want to force rather than let the AI
485
+ infer - explicit values win over auto-mapped ones per field.
486
+
487
+ What gets printed:
488
+ - `--- Log ---` - the backend's own mapping/execution stage messages (`processing_log`), if any.
489
+ This is **not** your plugin's own `console.log()` output from inside `main.ts` - it's everything
490
+ the HTTP response itself carries, printed after the call completes.
491
+ - `--- Auto-mapped input ---` - what `-a`'s prompt actually got mapped to (`mapped_arguments`),
492
+ only present in auto mode.
493
+ - `--- Result: <status> ---` - the plugin's real `status`/`message`/`error_code`/`data`.
494
+ - `--- Compare ---` (only with `--compare <file>`) - status + data diffed against the saved run.
495
+
496
+ Both the workspace lookup and the execute call have a client-side timeout (15s and 3 minutes) - a
497
+ hung backend fails with a clear error instead of `trigger` sitting there forever. Override the
498
+ execute one with `AIVIN_TRIGGER_TIMEOUT_MS` if you have a legitimately slow plugin.
499
+
500
+ ### Watching your plugin's own console output inline: `--watch-logs`
501
+
502
+ By default `trigger` only shows what's above - not the plugin's own `console.log()`/`sdk.log()`
503
+ calls from inside `main.ts`. Pass `--watch-logs` to subscribe to that live, over the same channel
504
+ `aivin plugin logs` uses, right before firing the call - one terminal instead of two:
505
+
506
+ ```bash
507
+ aivin plugin trigger --watch-logs "summarize this" '{"text":"..."}'
508
+ ```
509
+
510
+ This is permission-scoped server-side to plugins you can see the container logs for (your own or
511
+ your org's deployments). Triggering a plugin from the public store that some other org owns will
512
+ print `(--watch-logs: no live console output - ...)` and fall back to the REST result only - there's
513
+ no way around that from the CLI, raw container stdout isn't something the platform exposes across
514
+ org boundaries.
515
+
516
+ ### Turning ad-hoc tries into a regression check: `--save` / `--compare`
517
+
518
+ ```bash
519
+ aivin plugin trigger "summarize this" '{"text":"..."}' --save
520
+ # Saved: .test/trigger/2026-01-15T10-30-00-000Z.json
521
+
522
+ # ...later, after changing the plugin (or re-testing the same store plugin)...
523
+ aivin plugin trigger "summarize this" '{"text":"..."}' \
524
+ --compare .test/trigger/2026-01-15T10-30-00-000Z.json
525
+ ```
526
+
527
+ Lighter-weight than `aivin test`'s full deploy+smoke-test+report flow - useful for a quick "did this
528
+ still behave the same way" check on any plugin you can trigger, including ones you don't own.
529
+
530
+ ## `aivin plugin logs [pluginId]`
531
+
532
+ Tails an **already-deployed** plugin's own container stdout/stderr live - the same real-time feed
533
+ the platform's own Playground log panel uses. `pluginId` defaults to the current directory's
534
+ `manifest.json` id (`--func <name>` picks the entry for a multi-function plugin), so plain
535
+ `aivin plugin logs` works from inside the plugin's own project directory; pass an explicit id to
536
+ watch a plugin you're not standing inside.
537
+
538
+ ```
539
+ Options:
540
+ --func <name> Which function's id to resolve, for a multi-function plugin
541
+ (only used when pluginId is omitted)
542
+ ```
543
+
544
+ ```bash
545
+ aivin plugin logs
546
+ aivin plugin logs my-plugin-id
547
+ ```
548
+
549
+ Prints each line as it's written (`console.log` → gray, `console.error` → red), with a local
550
+ timestamp. Runs until you press Ctrl+C. If the container restarts (redeploy/crash) mid-stream,
551
+ the connection ends - re-run the command to resume watching.
552
+
553
+ ## `aivin connector`
554
+
555
+ Connectors are reusable OAuth apps / credential-form namespaces, referenced from `manifest.json`'s
556
+ `connection_id` field so multiple plugins can share one set of user-connected credentials instead
557
+ of each prompting for the same login separately. Check for an existing one before registering a
558
+ new namespace:
559
+
560
+ ```bash
561
+ aivin connector search "slack"
562
+ aivin connector list
563
+ ```
564
+
565
+ ```
566
+ Commands:
567
+ register Register a new connector namespace, interactively
568
+ search [options] [query] Search connectors for something to reuse instead of registering a new one
569
+ list [options] List connectors visible to your org
570
+ deprecate [id] Hide a connector you own from search/list without breaking plugins already using it
571
+ undeprecate [id] Make a previously-deprecated connector you own discoverable again
572
+
573
+ Options for search/list:
574
+ --limit <n> Max results to show (search)
575
+ --page <n> Page number (list)
576
+ --include-deprecated Also show your org's deprecated connectors, hidden by default (list)
577
+ --plain Print a flat list instead of the interactive browser - for scripts/CI (both)
578
+ ```
579
+
580
+ `aivin connector register` walks you through naming the namespace and picking the auth shape
581
+ (OAuth vs. a plain credential form) interactively - there's no non-interactive/scripted form, since
582
+ registering real OAuth app credentials isn't something to automate blindly. Once registered, put
583
+ the connector's id in your plugin's `manifest.json` as `connection_id` - see
584
+ [MANIFEST.md](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md#fields) (sdk
585
+ repo).
586
+
587
+ `aivin connector deprecate`/`undeprecate` only affect discoverability (search/list) - they never
588
+ break a plugin that's already using the connector's `connection_id`, so it's safe to deprecate one
589
+ you've replaced without migrating existing plugins first.
590
+
591
+ ## `aivin pluginstore`
592
+
593
+ Manages a **self-hosted `aivin-service` worker** (a Docker container you run yourself) attached to
594
+ your org as a *plugin store* - a piece of infrastructure your org's plugins can run against,
595
+ independent from Aivin's own hosted infra. A store can have multiple *nodes* (multiple machines
596
+ each running their own `aivin-service`, all attached to the same store) for redundancy/scale. This
597
+ is unrelated to the **Plugin Marketplace** (`aivin mcp <url> --publish` and the browser
598
+ CodeEditor's publish flow) - a plugin store is infrastructure you attach, not a place plugins get
599
+ published to.
600
+
601
+ ```
602
+ Commands:
603
+ create [options] [store_id] Create a new plugin store + attach this machine as its first node
604
+ attach [options] [store_id] Attach this machine as another node of an existing plugin store
605
+ ls List plugin stores visible to your org, with online/offline status per node
606
+ enable [store_id] Enable a store for your org (org admin only)
607
+ disable [store_id] Disable a store for your org without deleting it (org admin only)
608
+ rm [options] [store_id] Delete a store - revokes EVERY node attached to it, not just this machine (org admin only)
609
+ detach [options] Remove THIS machine's pairing only (local file only, no BE call)
610
+ ```
611
+
612
+ ```bash
613
+ aivin pluginstore create my-store --label "Production store"
614
+ aivin pluginstore ls
615
+ ```
616
+
617
+ `create`/`attach` both end by writing `worker-identity.json` into a data directory (default
618
+ `~/.aivin/service-data`, override with `--data-dir`) - the machine's actually-running
619
+ `aivin-service` process watches that directory (`fs.watch`) and pairs itself automatically the
620
+ moment the file appears. Neither command needs `aivin-service` to already be running, and neither
621
+ restarts any container - the CLI's job ends at writing the file; pairing itself is the worker's own
622
+ responsibility.
623
+
624
+ ```
625
+ Options (create):
626
+ --label <label> Display label for the store (defaults to store_id)
627
+ --node-label <label> Display label for this node/instance
628
+ --data-dir <path> Where to write worker-identity.json (default: ~/.aivin/service-data)
629
+
630
+ Options (attach):
631
+ --node-label <label> Display label for this node/instance
632
+ --data-dir <path> Where worker-identity.json is written (default: ~/.aivin/service-data)
633
+ ```
634
+
635
+ `aivin pluginstore detach` is the local-only inverse of `attach`/`create`: it deletes
636
+ `worker-identity.json` from this machine (`--data-dir` to point at a non-default location) without
637
+ calling the backend at all - the running `aivin-service` notices the file is gone and un-pairs on
638
+ its own. To actually revoke a node/store server-side (so it can't reattach with an old token), use
639
+ `aivin pluginstore rm` instead - **org admin only**, and destructive: it revokes every node attached
640
+ to the store, not just this machine, hence the `-y`/`--yes` flag to skip the confirmation prompt in
641
+ scripts.
642
+
643
+ `enable`/`disable` don't delete anything - they just toggle whether your org's plugins are allowed
644
+ to route to the store right now, so you can pull a store out of rotation (e.g. for maintenance)
645
+ without losing its configuration or having to re-attach nodes afterward.
646
+
647
+ ## `aivin mcp <url> [--publish|--private|--org]`
648
+
649
+ The one-shot path from "here's an [MCP](https://modelcontextprotocol.io) server" to deployed
650
+ plugin(s) - unlike `aivin mcp create` below (which scaffolds exactly 1 tool/resource/prompt you
651
+ already know the transport/command/name for), this scans a whole server and converts everything it
652
+ finds, interactively:
653
+
654
+ 1. **Scan** (`POST /plugins/scan-mcp`) - `<url>` can be a GitHub/GitLab repo, an npm/Smithery
655
+ package, or a live MCP server URL. Reads the repo/README or handshakes the live server directly.
656
+ 2. **Select** - checkbox prompt lists every tool/resource/prompt found (all checked by default);
657
+ space to toggle, enter to continue with only what you actually want as plugins.
658
+ 3. **Build manifests** (`POST /plugins/build-mcp-manifests`) - one `PluginManifest` per selected
659
+ item, generated server-side (not typed by hand like `aivin mcp create` requires).
660
+ 4. **Edit** (optional) - confirm prompt offers to rename/redescribe any of the generated plugins
661
+ before anything is deployed.
662
+ 5. **Deploy** (`POST /plugins/deploy`) - always org-scoped first, regardless of the visibility flag
663
+ below (there's no narrower per-workspace scope for plugins today).
664
+ 6. **Publish** (only with `--publish`) - submits each deployed plugin for community review
665
+ (`POST /plugins/store/submit`) - the backend re-verifies each one LIVE against the real MCP
666
+ server before it reaches the review queue, not just whatever got deployed (see the backend's own
667
+ `marketplace-catalog.md` docs, §"Tự submit plugin MCP lên store", for the full gate).
668
+ 7. Prints ready-to-run `aivin plugin trigger --id <id> -a "..."` / `aivin plugin logs <id>` for
669
+ every plugin deployed, and offers to run one right now, interactively - see
670
+ [`aivin test`](#aivin-test) above for why this exists (its automated smoke test skips proxy
671
+ plugins entirely).
672
+
673
+ ```
674
+ Options:
675
+ --publish Deploy to your org, then submit for community store review
676
+ (needs admin approval)
677
+ --private Deploy to your org only - default
678
+ --org Alias of --private - there is no narrower per-workspace scope today
679
+ ```
680
+
681
+ ```bash
682
+ aivin mcp https://github.com/example-org/example-mcp-server
683
+ aivin mcp https://github.com/example-org/example-mcp-server --publish
684
+ ```
685
+
686
+ ## `aivin mcp create <name>`
687
+
688
+ Scaffolds a **manifest-only** plugin (`proxy_config.type: "mcp"`) that proxies straight to an
689
+ external [MCP](https://modelcontextprotocol.io) server's tool/resource/prompt - no `src/main.ts`,
690
+ no `package.json`, nothing to run. `aivin deploy`/`aivin test` detect this automatically.
691
+
692
+ ```
693
+ Options:
694
+ --transport <transport> stdio | sse
695
+ --command <command> Command to launch the MCP server (stdio transport)
696
+ --args <args> Space-separated args for --command (stdio transport)
697
+ --url <url> Remote MCP server URL (sse transport)
698
+ --kind <kind> tool | resource | prompt (default: tool)
699
+ --tool-name <name> MCP tool name (kind=tool)
700
+ --resource-uri <uri> MCP resource URI (kind=resource)
701
+ --resource-mime-type <mime> MIME type of the resource (kind=resource)
702
+ --prompt-name <name> MCP prompt name (kind=prompt)
703
+ --description <description> Plugin description
704
+ --auth-secret-key <key> Name of the workspace secret to use as the Bearer
705
+ token, if the MCP server needs auth
706
+ ```
707
+
708
+ - No `--command`/`--url` → interactive prompts for everything.
709
+ - `--command`/`--url` given → fully non-interactive/scriptable. `--transport` and `--kind` are
710
+ inferred from whichever flags you pass (`--command` implies stdio, `--url` implies sse;
711
+ `--tool-name`/`--resource-uri`/`--prompt-name` each imply their own `--kind`) - spell them out
712
+ explicitly only if you're scripting this without any of those (unusual).
713
+
714
+ ```bash
715
+ # stdio (local command)
716
+ aivin mcp create fs-tools --command npx --args "-y @modelcontextprotocol/server-filesystem /data" \
717
+ --tool-name read_file --description "Read files via MCP"
718
+
719
+ # sse (remote server)
720
+ aivin mcp create doc-search --url https://example.com/mcp \
721
+ --tool-name search_docs --description "Search external docs via MCP"
722
+ ```
723
+
724
+ See [MANIFEST.md#mcp-proxy-plugins](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md#mcp-proxy-plugins) for the full `proxy_config`
725
+ field reference.
726
+
727
+ ## `aivin login`
728
+
729
+ Saves an API key **once, machine-wide**, to `~/.aivin/credentials` - not the current project's
730
+ `.env`. Logging in is a per-machine thing, not a per-project one, so you only need to run this once
731
+ regardless of how many plugin projects you work in - every project's `deploy`/`test`/`plugin make`
732
+ picks it up automatically.
733
+
734
+ ```
735
+ Options:
736
+ -k, --api-key <key> Set API key directly (skip login entirely)
737
+ --basic Log in with email/password directly in the terminal instead of a browser
738
+ --google Alias of the default browser flow - pick Google once the page opens
739
+ --client <client> Client/org id to use with --basic (default: "aivin.cloud")
740
+ ```
741
+
742
+ **Default (no flags) - browser flow, recommended:**
743
+
744
+ ```bash
745
+ aivin login
746
+ ```
747
+
748
+ Opens your default browser to the platform's actual login page (`https://brain.aivin.cloud`) with
749
+ a one-time state token and a `localhost` callback URL. Log in exactly the way you normally would in the
750
+ browser - custom-domain org, password, Google, OTP, whatever applies to your account. Once you
751
+ confirm on the "Aivin CLI wants to create an API Key" prompt that appears after login, a fresh key
752
+ is minted (named after this machine's hostname, replacing any previous key with that same name) and
753
+ handed back to a tiny local HTTP server the CLI started for this one request, then saved to
754
+ `~/.aivin/credentials`. The browser tab never shows you the raw key - only the CLI does.
755
+
756
+ `--google` doesn't change anything technically; it's just documentation that once the page opens
757
+ you can pick "Log in with Google" there, same as any other login on that page.
758
+
759
+ **`--basic` - no browser, terminal-only:**
760
+
761
+ ```bash
762
+ aivin login --basic
763
+ ```
764
+
765
+ Prompts for email/password directly and logs in against the default/shared client only (`--client`,
766
+ falls back to `"aivin.cloud"`). If your account belongs to a custom-domain organization, this won't
767
+ resolve that domain for you - use the default browser flow instead, which handles it the same way
768
+ the web login page does.
769
+
770
+ **Already have a key:**
771
+
772
+ ```bash
773
+ aivin login --api-key <key>
774
+ ```
775
+
776
+ Skips login entirely - just saves the given key to `~/.aivin/credentials`.
777
+
778
+ ## `aivin whoami`
779
+
780
+ Shows which account is currently active on this machine - reads `~/.aivin/credentials` straight
781
+ off disk, **no server call**, so it works offline and never fails due to a network/auth problem
782
+ (if anything, it's the fastest way to check that a previous `aivin login` actually saved
783
+ something).
784
+
785
+ ```bash
786
+ aivin whoami
787
+ ```
788
+
789
+ ```
790
+ ✅ Logged in
791
+ Email: jane@example.com
792
+ Name: Jane Doe
793
+ Org: Acme Inc
794
+ Server: https://api.aivin.cloud
795
+ Logged in at: 1/15/2026, 10:30:00 AM
796
+ ```
797
+
798
+ Email/name/org/login-time only exist at all if the currently-effective `API_KEY` is the exact one
799
+ `aivin login` saved (i.e. `~/.aivin/credentials`, the machine-wide default) - identity is captured
800
+ once, at login time, and cached alongside the key. If a project's own `.env` overrides `API_KEY`
801
+ with a different key, `whoami` says so explicitly instead of guessing:
802
+
803
+ ```
804
+ (API_KEY is from this project's .env, not `aivin login` - no recorded identity/login time)
805
+ ```
806
+
807
+ ## `aivin key`
808
+
809
+ Manages *named* API keys on your account - separate from the one machine-wide key `aivin login`
810
+ saves. Useful for giving a CI pipeline, a teammate's script, or any other caller its own key you can
811
+ revoke independently later.
812
+
813
+ ```
814
+ Commands:
815
+ gen [options] <name> Create (or replace) a named API key for your account - shown only once
816
+ revoke [options] <name> Revoke a named API key for your account
817
+ list [options] List API keys on your account
818
+ ```
819
+
820
+ ```bash
821
+ aivin key gen "ci-pipeline" # prompts for your account password, prints the new key once
822
+ aivin key gen "ci-pipeline" --save # also saves it to ~/.aivin/credentials as this machine's default
823
+ aivin key list # see what's on your account
824
+ aivin key revoke "ci-pipeline" # revoke it by name
825
+ ```
826
+
827
+ All three authenticate with the `API_KEY` `aivin login` already saved - no email/password prompt for
828
+ `list`/`revoke`. `gen` is the exception: it still asks for your **account password** (not email) as
829
+ a step-up check, since minting a new key from an existing one is the one action here that could
830
+ otherwise let an already-leaked key re-provision itself indefinitely even after you revoke it.
831
+ `list`/`revoke` only read or remove access, never grant it, so they need no such check.
832
+
833
+ `aivin key gen` replaces (not accumulates) any existing key with the same name, the same way
834
+ re-running `aivin login` replaces this machine's own key.
835
+
836
+ ## `aivin browser [mission]`
837
+
838
+ Runs an **AI Browser** mission - a multi-step, self-correcting agent that drives an actual browser
839
+ (not this plugin's code) to complete a goal. Two modes, picked by `--remote`:
840
+
841
+ ```
842
+ Options:
843
+ --remote Use a server-side pooled browser instead of your own local one (no
844
+ local browser needed, no cookies/logins carried over)
845
+ --debug-port <port> Local mode only: port to look for/launch your browser's remote
846
+ debugging on (default: 9222, auto-tries a few nearby ports if that
847
+ one is taken by something else)
848
+ --browser <edge|chrome> Local mode only: which browser to drive - default: auto-detects your
849
+ OS's actual default browser, falling back to whichever of Edge/Chrome
850
+ is installed
851
+ --url <url> Local mode only: open this URL before the mission starts, instead of a
852
+ blank page (auto-guessed for a few well-known sites mentioned by name
853
+ in the mission if omitted)
854
+ --workspace <id> Workspace id to run in (default: your personal workspace)
855
+ --project <id> Project id within the workspace (--remote only)
856
+ --agent <id> Agent id to run as (default: an auto-created/cached agent for local
857
+ mode, or the workspace's default agent for --remote)
858
+ --no-watch Fire the mission and return immediately - skip streaming live
859
+ progress and auto-opening the viewer
860
+ --view Just (re)open the fullscreen interactive viewer for whatever HIL
861
+ session is already active - no mission is started
862
+ ```
863
+
864
+ **Local mode (default)** - drives your own, already-running browser via its remote-debugging
865
+ protocol (CDP). Uses a dedicated Chrome/Edge profile (`~/.aivin/browser-profile`), not your regular
866
+ daily-driver profile - real cookies/logins persist there across runs, but the first time you use a
867
+ given site you'll need to log in once, same as opening it in a fresh browser. If nothing's
868
+ listening on the debug port yet, `aivin browser` prints the exact launch command for your OS/browser
869
+ instead of failing silently:
870
+
871
+ ```bash
872
+ aivin browser "Find the top 3 posts on Hacker News right now and summarize them"
873
+ ```
874
+
875
+ A live viewer window opens automatically once the mission needs human input (HIL) or, by default,
876
+ as soon as it starts - `--no-watch` skips this and just prints progress to the terminal instead.
877
+
878
+ **Remote mode (`--remote`)** - runs on a server-side pooled browser instead, no local browser
879
+ required, no cookies from your machine carried over. Useful for CI, headless environments, or
880
+ missions that don't need a logged-in session on a specific real account.
881
+
882
+ ```bash
883
+ aivin browser --remote "Check the current price of BTC on coinmarketcap.com"
884
+ ```
885
+
886
+ `aivin browser --view` alone (no mission) reopens the interactive viewer for whatever HIL session
887
+ is already active, without starting anything new - handy if you closed the auto-opened window by
888
+ accident.
889
+
890
+ ## `aivin do <agent_nickname> <mission>`
891
+
892
+ Has a specific agent start a background mission toward a free-text goal (`POST /agent/start-work`),
893
+ not a specific deployed plugin. The agent runs the mission on its own, checking in via the
894
+ progress stream (see below); this is the CLI-native equivalent of typing into the platform's chat
895
+ and choosing which AI Staff agent should handle it.
896
+
897
+ ```
898
+ Options:
899
+ --workspace <id> Workspace id to run in (default: your personal workspace)
900
+ --project <id> Project id within the workspace
901
+ --no-watch Fire the mission and return immediately - skip streaming live progress
902
+ ```
903
+
904
+ ```bash
905
+ aivin do supportbot "Summarize today's support tickets and post the summary to #digest"
906
+ ```
907
+
908
+ - `<agent_nickname>` is matched against the resolved workspace's already-installed agents (by
909
+ nickname, name, or id). Omit either argument and you'll be prompted interactively - the mission
910
+ prompt if only the agent is given, or a picker over the workspace's agents if only the mission is
911
+ given (in a non-interactive shell, both are required up front).
912
+ - If the nickname doesn't match anything in the workspace, or the workspace has no agents at all
913
+ yet, you're offered a choice: search & install one from the marketplace, or create a brand new
914
+ one - so `aivin do` never dead-ends on an empty workspace (see `aivin agent install`/`aivin agent
915
+ make` below, which this reuses).
916
+
917
+ By default it then streams the mission's live progress in the terminal (same realtime channel
918
+ `aivin plugin logs` uses under the hood) until the run finishes or you press Ctrl+C - pass
919
+ `--no-watch` to just fire it and return immediately instead.
920
+
921
+ If `--workspace` is omitted, it runs in your **personal workspace** (the platform always resolves
922
+ that first when no workspace is given).
923
+
924
+ ### `aivin do job <description>`
925
+
926
+ Creates a new **automation job** - recurring background work on a cron-style schedule, independent
927
+ of any single chat/mission invocation (`POST /automation/jobs/create`).
928
+
929
+ ```
930
+ Options:
931
+ --workspace <id> Workspace id to create the job in (default: your personal workspace)
932
+ --project <id> Project id within the workspace
933
+ --agent <id> Agent id the job runs as (default: the workspace's default agent)
934
+ --schedule <condition> Natural-language schedule, e.g. "every Monday at 9am" (default: let the
935
+ platform infer one)
936
+ ```
937
+
938
+ ```bash
939
+ aivin do job "Compile last week's support tickets into a summary and post it to #digest"
940
+ aivin do job "Send a daily standup reminder" --schedule "every weekday at 9am"
941
+ ```
942
+
943
+ If `--schedule` is omitted, the platform infers a cadence (or falls back to manual) from the
944
+ description itself - pass it explicitly if you already know the cadence, to skip the extra
945
+ inference call.
946
+
947
+ ## `aivin task [description]`
948
+
949
+ Creates a new task (`POST /task/create`) from a plain-language description - the description
950
+ becomes both the task's title (truncated if long) and its full content.
951
+
952
+ ```
953
+ Options:
954
+ --workspace <id> Workspace id to create the task in (default: your personal workspace)
955
+ --project <id> Project id within the workspace
956
+ --assignee <userId> User id to assign the task to (default: unassigned)
957
+ ```
958
+
959
+ ```bash
960
+ aivin task "Follow up with the customer about their refund request"
961
+ ```
962
+
963
+ `aivin task` also has subcommands for the rest of the task lifecycle:
964
+
965
+ ```
966
+ Commands:
967
+ list [options] List tasks in a project
968
+ mine [options] List tasks assigned to you in a project
969
+ get [id] Get a task by id
970
+ update [options] [id] Update a task
971
+ delete [id] Delete a task
972
+ ```
973
+
974
+ ```bash
975
+ aivin task list --status todo # list open tasks in your first project
976
+ aivin task list --project <id> --assignee <userId> # filter by project/assignee
977
+ aivin task mine # tasks assigned to you
978
+ aivin task get <id> # full task details (JSON)
979
+ aivin task update <id> --status done # move a task to done
980
+ aivin task update <id> --title "New title" --priority high
981
+ aivin task delete <id>
982
+ ```
983
+
984
+ `list`/`mine` are scoped to a single project (the backend's real `/task/:projectId/list` route) -
985
+ `--project` defaults to the resolved workspace's first project, and throws if it has none (a
986
+ Personal workspace typically has no projects; pass `--project <id>` explicitly, or run
987
+ `aivin workspace` to find one).
988
+
989
+ ## `aivin workspace`
990
+
991
+ Interactive picker: lists your workspaces (personal workspace first), lets you select one, then
992
+ lists that workspace's projects so you can pick the corresponding one - printing the resolved
993
+ `--workspace`/`--project` ids to pass to `aivin do`/`do job`/`task`.
994
+
995
+ ```
996
+ Options:
997
+ --plain Print a flat list instead of the interactive picker (for scripts/CI)
998
+ ```
999
+
1000
+ ```bash
1001
+ aivin workspace
1002
+ ```
1003
+
1004
+ Non-TTY contexts (scripts, CI, piped output) or `--plain` print a flat listing instead of the
1005
+ interactive prompts.
1006
+
1007
+ ## `aivin agent`
1008
+
1009
+ Search the AI Staff marketplace, install an agent into a workspace, create a brand new one, or
1010
+ publish one you own. `aivin do` calls into the same install/create flows automatically when it
1011
+ can't resolve `<agent_nickname>`.
1012
+
1013
+ ```
1014
+ Commands:
1015
+ search [options] [query] Search the AI Staff marketplace for an agent
1016
+ install [options] [query] Search the marketplace and install an agent into a workspace
1017
+ make [options] Create a brand new AI Staff agent
1018
+ publish [options] [agentId] Publish an agent you own to the marketplace
1019
+ ```
1020
+
1021
+ ```bash
1022
+ aivin agent search "customer support" # browse the marketplace
1023
+ aivin agent install "customer support" # search + pick + install into your personal workspace
1024
+ aivin agent install --workspace <id> # no query - opens the same interactive picker `aivin do` uses
1025
+ aivin agent make --name "Ada" --nickname ada --email ada@example.com --bio "Support triage bot"
1026
+ aivin agent publish <agentId> # make an agent you own visible in the marketplace
1027
+ ```
1028
+
1029
+ - `install`/`make` default to your personal workspace when `--workspace` is omitted.
1030
+ - `make` calls `POST /ai-staff/create`; passing the target workspace at creation time auto-installs
1031
+ the new agent there too (no separate `install` call needed).
1032
+ - `publish` is a two-step platform operation under the hood (`POST /ai-staff/update` with
1033
+ `is_published: true`, then `POST /ai-staff/push` to promote the workspace's local copy to the
1034
+ shared master) - both scoped to the workspace the agent actually lives/was authored in.
1035
+
1036
+ ## `aivin project`
1037
+
1038
+ Create, rename, or delete a project within a workspace (the backend has no separate "list projects"
1039
+ endpoint - use `aivin workspace` to browse a workspace's existing projects).
1040
+
1041
+ ```
1042
+ Commands:
1043
+ create [options] [name] Create a new project in a workspace
1044
+ update [options] [id] Update a project (currently: rename)
1045
+ delete [options] [id] Delete a project
1046
+ ```
1047
+
1048
+ ```bash
1049
+ aivin project create "Q3 Launch"
1050
+ aivin project update <id> --name "Q3 Launch (renamed)"
1051
+ aivin project delete <id>
1052
+ ```
1053
+
1054
+ All three default to your personal workspace when `--workspace` is omitted.
1055
+
1056
+ ## Environment variables
1057
+
1058
+ `aivin login` saves your key once to `~/.aivin/credentials` and every plugin project on the
1059
+ machine picks it up automatically - there's no per-project credential to manage.
1060
+
1061
+ | Variable | Used by | Default | When you'd touch it |
1062
+ | -------------------- | -------------------------------------------------- | ----------------------------- | ---------------------------------------------------------------- |
1063
+ | `SDK_ENDPOINT` | SDK calls, `aivin start` | `sdk.aivin.cloud:443` | Point `main()`'s SDK calls at a local/dev/staging backend instead of production. Staging: `beta-sdk.aivin.vn:50052` (dedicated Cloudflare Tunnel TLS port - production goes through a load balancer on the standard 443 port instead, a different setup). |
1064
+ | `AIVIN_BASE_URL` | `deploy`, `test`, `plugin make/convert/trigger`, `login --basic` | `https://api.aivin.cloud` | Only for a self-hosted or staging instance. Staging: `https://beta-api.aivin.vn`. |
1065
+ | `AIVIN_WEB_URL` | `login` (browser flow) | `https://brain.aivin.cloud` | Only for a self-hosted or staging instance. |
1066
+ | `LOCAL_TEST_PORT` | `aivin start` | `4001` | Only if `4001` is already taken on your machine. |
1067
+ | `LOCAL_TEST_HOST` | `aivin start` | `127.0.0.1` | Loopback-only by default (`/invoke` has no auth) - only widen this if you deliberately want another device on your network to reach it. See [sdk repo's SECURITY.md](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/SECURITY.md). |
1068
+ | `AIVIN_SANDBOX_WORKER` | `aivin start`, deployed containers | `false` | Set `true` to run `src/main.ts` inside an isolated `worker_threads.Worker` (no direct access to the container's secret, restricted fs/child_process) instead of loading it in-process. Off by default - see [sdk repo's worker-sandbox.md](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/draft/plugins/worker-sandbox.md). |
1069
+
1070
+ Everything else (`SDK_SECRET`, `SDK_GRPC_SERVER_BIND`, `SDK_GRPC_TLS`, `NODE_ENV`, ...) is
1071
+ either injected automatically inside a deployed container or has a working zero-config default -
1072
+ not something you're expected to set by hand.
1073
+
1074
+ ## See also
1075
+
1076
+ - [GETTING_STARTED.md](./GETTING_STARTED.md) - the narrative walkthrough these commands fit into
1077
+ - [MANIFEST.md (sdk repo)](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md) - every `manifest.json` field, including MCP proxy plugins
1078
+ - [PLUGIN_DEVELOPMENT_GUIDE.md (sdk repo)](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/PLUGIN_DEVELOPMENT_GUIDE.md) - writing and testing a handler
1079
+ - [SDK.md (sdk repo)](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/SDK.md) - everything the SDK exposes inside `main()`