@aivin-labs/cli 1.0.13 → 1.0.24

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.
Files changed (73) hide show
  1. package/README.md +325 -304
  2. package/bin/cli.mjs +97 -18
  3. package/bin/lib/localPreview.mjs +437 -0
  4. package/bin/lib/openFile.mjs +235 -0
  5. package/bin/lib/previewCache.mjs +71 -0
  6. package/bin/lib/remote/atomicFile.mjs +32 -0
  7. package/bin/lib/remote/autoStart.mjs +2 -1
  8. package/bin/lib/remote/autoUpdate.mjs +153 -129
  9. package/bin/lib/remote/callLedger.mjs +21 -0
  10. package/bin/lib/remote/cdpPolicy.mjs +14 -2
  11. package/bin/lib/remote/client.mjs +1025 -889
  12. package/bin/lib/remote/codingAgents.mjs +2 -2
  13. package/bin/lib/remote/constants.mjs +263 -251
  14. package/bin/lib/remote/credentials.mjs +81 -4
  15. package/bin/lib/remote/daemonLock.mjs +57 -17
  16. package/bin/lib/remote/desktop/castInput.mjs +98 -0
  17. package/bin/lib/remote/desktop/desktopCast.mjs +337 -198
  18. package/bin/lib/remote/desktop/desktopCastCaptureSource.mjs +598 -0
  19. package/bin/lib/remote/desktop/desktopCastSource.mjs +880 -514
  20. package/bin/lib/remote/desktop/desktopWebRtc.mjs +251 -95
  21. package/bin/lib/remote/desktop/fileAssociation.mjs +108 -0
  22. package/bin/lib/remote/desktop/index.mjs +21 -7
  23. package/bin/lib/remote/desktop/linuxTraySource.mjs +1 -8
  24. package/bin/lib/remote/desktop/macTraySource.mjs +0 -2
  25. package/bin/lib/remote/desktop/strings.mjs +28 -2
  26. package/bin/lib/remote/desktop/traySource.mjs +380 -16
  27. package/bin/lib/remote/desktop/webrtcRuntime.mjs +137 -0
  28. package/bin/lib/remote/desktop/webrtcWorker.mjs +183 -0
  29. package/bin/lib/remote/deviceProfile.mjs +2 -4
  30. package/bin/lib/remote/fileIndexer.mjs +30 -14
  31. package/bin/lib/remote/folderRules.mjs +3 -0
  32. package/bin/lib/remote/gitSafe.mjs +31 -0
  33. package/bin/lib/remote/gui/index.mjs +66 -24
  34. package/bin/lib/remote/gui/officeHostSource.mjs +635 -393
  35. package/bin/lib/remote/gui/windowsHost.mjs +3 -1
  36. package/bin/lib/remote/gui/windowsHostSource.mjs +291 -60
  37. package/bin/lib/remote/httpTransfer.mjs +64 -3
  38. package/bin/lib/remote/localPolicy.mjs +73 -7
  39. package/bin/lib/remote/mascot/ask.mjs +956 -768
  40. package/bin/lib/remote/mascot/askBlocksSource.mjs +286 -0
  41. package/bin/lib/remote/mascot/askHostSource.mjs +658 -530
  42. package/bin/lib/remote/mascot/blocks.mjs +201 -0
  43. package/bin/lib/remote/mascot/bot.mjs +26 -2
  44. package/bin/lib/remote/mascot/chartLayout.mjs +382 -0
  45. package/bin/lib/remote/mascot/diagramRender.mjs +154 -0
  46. package/bin/lib/remote/mascot/emojiSource.mjs +273 -0
  47. package/bin/lib/remote/mascot/fileChips.mjs +62 -0
  48. package/bin/lib/remote/mascot/hostSource.mjs +328 -49
  49. package/bin/lib/remote/mascot/hotkey.mjs +31 -7
  50. package/bin/lib/remote/mascot/images.mjs +111 -0
  51. package/bin/lib/remote/mascot/index.mjs +663 -493
  52. package/bin/lib/remote/mascot/lucideIcons.mjs +32 -0
  53. package/bin/lib/remote/mascot/mermaidBundle.mjs +28 -0
  54. package/bin/lib/remote/mascot/mood.mjs +57 -0
  55. package/bin/lib/remote/mascot/rigSource.mjs +643 -609
  56. package/bin/lib/remote/mascot/safeUrl.mjs +29 -0
  57. package/bin/lib/remote/mascot/strings.mjs +459 -375
  58. package/bin/lib/remote/mascot/ui.mjs +27 -7
  59. package/bin/lib/remote/multiUser.mjs +7 -2
  60. package/bin/lib/remote/notify.mjs +4 -1
  61. package/bin/lib/remote/office/index.mjs +12 -6
  62. package/bin/lib/remote/processes.mjs +5 -2
  63. package/bin/lib/remote/sandbox.mjs +26 -0
  64. package/bin/lib/remote/secretPaths.mjs +21 -0
  65. package/bin/lib/remote/tokenRotation.mjs +28 -0
  66. package/bin/lib/remote/toolHandlers.mjs +79 -15
  67. package/bin/lib/remote/watchBatcher.mjs +56 -0
  68. package/bin/lib/selfUpdate.mjs +12 -2
  69. package/bin/lib/update/binarySwap.mjs +15 -1
  70. package/bin/lib/update/state.mjs +10 -0
  71. package/docs/CLI.md +1545 -1504
  72. package/docs/media/aivin-ecosystem.jpg +0 -0
  73. package/package.json +75 -71
package/README.md CHANGED
@@ -1,304 +1,325 @@
1
- # @aivin-labs/cli
2
-
3
- Building an AI agent that does real work — one that calls an LLM, reasons over your data, uses
4
- tools, and knows when to hand a decision back to a human — usually means weeks of infrastructure
5
- before you write a single line of business logic: a service to host it, an SDK to wire the model
6
- calls, auth, queues, logging, a deploy pipeline. [Aivin](https://aivin.cloud) exists to collapse
7
- that. Describe what you want built, and get back a real, typed, callable, observable service in
8
- minutes — not sprints.
9
-
10
- `@aivin-labs/cli` is your entry point into that platform, and your main tool for working inside
11
- the Aivin ecosystem day to day. Instead of hand-rolling a service, you run `aivin init`, describe
12
- what the plugin should do, and get a real, deployable TypeScript project — hot-reloading local dev
13
- server, typed input/output, and a one-command path to production included. Everything after that —
14
- testing, logs, connectors, MCP integrations, agents, automation — is one more `aivin` command
15
- away, so you can build agentic applications that plug straight into the platform without ever
16
- leaving your terminal or editor.
17
-
18
- This package is the interactive tooling only; the plugin runtime library your generated code
19
- actually imports at runtime is
20
- [`@aivin-labs/sdk`](https://www.npmjs.com/package/@aivin-labs/sdk) (`ai`, `vector`, `store`, ...),
21
- installed automatically as a dependency of every project this CLI scaffolds. See
22
- [Relationship to @aivin-labs/sdk](#relationship-to-aivin-labssdk) below for how the two packages
23
- divide responsibilities.
24
-
25
- ## The Aivin ecosystem
26
-
27
- Aivin isn't just a place to host one function — it's a small, composable ecosystem for agentic
28
- software, and this CLI is how you reach every piece of it:
29
-
30
- - **Plugins** — the core unit of work: a typed function (`main(mission, input, ctx)`), deployed as
31
- its own container, callable by name, and searchable by every other plugin or agent in your org
32
- (`aivin plugin search`, `call()` from the SDK). Write one by hand (`aivin create`), have AI
33
- generate it from a description (`aivin init` / `aivin plugin make`), or convert an existing
34
- project into one in place (`aivin plugin convert`).
35
- - **MCP proxies** — wrap any [Model Context Protocol](https://modelcontextprotocol.io) server's
36
- tools, resources, or prompts as first-class Aivin plugins with zero code (`aivin mcp <url>`),
37
- so the growing MCP ecosystem becomes instantly usable by your agents.
38
- - **Connectors** — shared OAuth apps and credential namespaces (`aivin connector`), so ten plugins
39
- that all need "the org's Slack" don't each prompt the user for a separate login.
40
- - **AI Staff agents** — persistent, nameable agents you target with a mission, that use your
41
- plugins as tools and can pause to ask a human for input mid-task (HIL). Install one from the
42
- marketplace or build your own (`aivin agent`, `aivin do`).
43
- - **Automation jobs** — recurring, scheduled work described in plain language
44
- (`aivin do job "..."`) — no cron syntax to write.
45
- - **AI Browser** — a self-correcting agent that drives a real browser, yours or a server-side one,
46
- to complete a goal end-to-end (`aivin browser`).
47
- - **Workspaces, projects, and tasks** — the organizing structure everything above lives in, plus a
48
- lightweight task tracker (`aivin task`) for the human side of the work.
49
- - **Plugin Marketplace** — plugins and MCP proxies you build here aren't limited to your own org:
50
- submit them for community review and publish to Aivin's public Plugin Marketplace
51
- (`aivin mcp <url> --publish`), so the AI capabilities you develop become reusable building
52
- blocks other teams on the platform can search for and call, not just your own.
53
- - **Local, agent-supervised execution** — this CLI is also how Aivin reaches onto *your* machine to
54
- get real work done, always under an explicit mission and never as open-ended remote access:
55
- `aivin browser` drives a dedicated local browser profile (your own cookies/logins, isolated from
56
- your daily-driver browser) so an agent can act on real logged-in sites, and `aivin start` can run
57
- your plugin code inside a sandboxed `worker_threads.Worker` (`AIVIN_SANDBOX_WORKER=true`) with no
58
- direct access to secrets or the filesystem. Every run stays scoped to the mission that started
59
- it, with human-in-the-loop checkpoints (HIL) whenever an agent needs your go-ahead.
60
-
61
- Put together: you describe the outcome you want, and Aivin's building blocks — plugins, agents,
62
- connectors, MCP tools — compose into it. `aivin` is how you author, test, and ship each of those
63
- pieces from your own terminal, on top of whatever editor/CI workflow you already use.
64
-
65
- ## Table of contents
66
-
67
- - [The Aivin ecosystem](#the-aivin-ecosystem)
68
- - [Install](#install)
69
- - [Quick start](#quick-start)
70
- - [Aivin mascot on Windows](#aivin-mascot-on-windows)
71
- - [What you get from a scaffold](#what-you-get-from-a-scaffold)
72
- - [Command overview](#command-overview)
73
- - [Environment variables](#environment-variables)
74
- - [Documentation](#documentation)
75
- - [Relationship to @aivin-labs/sdk](#relationship-to-aivin-labssdk)
76
- - [Development](#development)
77
- - [License](#license)
78
-
79
- ## Install
80
-
81
- ```bash
82
- npm install -g @aivin-labs/cli
83
- aivin --version
84
- ```
85
-
86
- Requires Node.js ≥ 22.0.0 — the SDK relies on Node's native TypeScript execution to load
87
- `src/main.ts` directly, with no separate build step. `aivin start`/`aivin test` check this up
88
- front and fail with a clear message (not a cryptic loader error) if your Node is too old.
89
-
90
- ### Install without Node.js (connect a computer to Aivin)
91
-
92
- Single-file builds are served from **https://get.aivin.vn** (mirrored on
93
- [GitHub Releases](https://github.com/aivin-labs/cli/releases)) together with `SHA256SUMS`. The
94
- installers pick the right build, verify its checksum, check it starts, and put `aivin` first on
95
- your PATH:
96
-
97
- ```powershell
98
- # Windows 10/11 (PowerShell 5.1 or 7), x64 or ARM64
99
- irm https://get.aivin.vn/install.ps1 | iex
100
- ```
101
-
102
- ```bash
103
- # macOS (Intel / Apple Silicon) and Linux (x64 / arm64, glibc or musl)
104
- curl -fsSL https://get.aivin.vn/install.sh | sh
105
- # Alpine / systems without curl
106
- wget -qO- https://get.aivin.vn/install.sh | sh
107
- ```
108
-
109
- | Platform | Build |
110
- |---|---|
111
- | Windows x64 / ARM64 | `aivin-windows-x64.exe` (baseline, no AVX2 needed) / `aivin-windows-arm64.exe` |
112
- | macOS Intel / Apple Silicon | `aivin-darwin-x64` (baseline) / `aivin-darwin-arm64` (ad-hoc signed) |
113
- | Linux glibc x64 / arm64 | `aivin-linux-x64` (baseline) / `aivin-linux-arm64` |
114
- | Linux musl (Alpine) x64 / arm64 | `aivin-linux-x64-musl` / `aivin-linux-arm64-musl` — needs `libstdc++ libgcc`, which the installer adds with `apk` when it can |
115
-
116
- In Aivin, **chat box → Browser menu → Add this computer** prints the same one-liner with a
117
- one-time pairing code, so the computer is installed and connected in one step
118
- (`aivin remote start --code <code>`).
119
-
120
- When the chat has a computer selected, AI Browser work on websites runs in a Chrome/Edge window
121
- on that computer. If you enabled **"Allow remote debugging for this browser instance"** in your
122
- everyday browser (`chrome://inspect/#remote-debugging`, Edge: `edge://inspect` → Remote debugging),
123
- the AI works in THAT browser with all your existing logins: click "Allow" once when it asks; the AI
124
- opens its own tabs in the background and can only watch (never drive, close or read cookies of) the
125
- tabs you opened. Otherwise it uses Aivin's own window (profile `~/.aivin/browser-profile`, shared with
126
- `aivin browser` — log in once per site). `--separate-browser` always uses Aivin's own window.
127
- Downloads land in `~/Downloads/Aivin`; when the AI needs you (login, 2FA, approval) you get an OS
128
- notification. `aivin remote start --no-browser` turns this off.
129
- Every tunnel goes through a CDP filter on this computer: no `file://` / `chrome://` pages, no picking local files, downloads only into
130
- `~/Downloads/Aivin` (executables are cancelled). `aivin remote pause` now also cancels running commands and closes AI browser tabs.
131
-
132
- Releasing: `npm run build:binary` (Bun, all 8 builds into `dist/`), then on the host behind
133
- Cloudflare `npm run get:publish && npm run get:up` (nginx `deploy/get/`, versioned folders +
134
- `latest.txt`). Pushing a `v*` tag also builds and attaches everything to a GitHub Release
135
- (`.github/workflows/release.yml`).
136
-
137
- ## Quick start
138
-
139
- ```bash
140
- aivin init my-plugin # ask what the plugin should do, scaffold + generate working code
141
- cd my-plugin && npm install
142
-
143
- aivin start # run it locally - gRPC server + an HTTP test shim on :4001
144
-
145
- aivin login # save an API key (once per machine)
146
- aivin test # verify on a non-production instance first
147
- aivin deploy # ship it
148
- ```
149
-
150
- `aivin init` asks what the plugin should do, then scaffolds the project **and** generates real
151
- working code from that description in one step. Prefer a blank scaffold you write by hand?
152
- `aivin create my-plugin` does just the scaffolding, no AI step. Already have a project instead of
153
- a description? `aivin plugin convert` turns an existing directory into a plugin in place.
154
-
155
- ## Aivin mascot on Windows
156
-
157
- <p align="center">
158
- <img src="docs/media/aivin-mascot-live.gif" alt="The current live Aivin mascot showing chat, file drag and attached-file states" width="480" />
159
- </p>
160
-
161
- When Aivin Remote is running on Windows, a small animated Aivin mascot can float above your apps.
162
- It shows whether Aivin is idle, working, thinking, waiting for you, done, paused, offline, or has hit
163
- an error. Hover or click it to type a question, use its microphone for a live voice conversation,
164
- right-click for the activity panel, or drop local files onto it to attach them to your next message.
165
- The mascot stays out of Aivin screenshots and moves aside while the agent controls another window.
166
- The animation above is captured from the current WPF interface: it shows a chat, the drag target and
167
- the tray holding files already attached to the next message.
168
-
169
- ```bash
170
- aivin remote start # start the listener and mascot
171
- aivin ui # show the mascot and open its ask box
172
- aivin ui --demo # preview all mascot animations
173
- aivin remote mascot off # turn it off persistently
174
- aivin remote mascot on # enable it for the next listener start
175
- ```
176
-
177
- Turning it off from the activity panel plays a short fade-and-slide exit animation while the Remote
178
- listener continues in the background. See the dedicated [Aivin mascot guide](docs/AIVIN_MASCOT.md)
179
- for interactions, voice and keyboard shortcuts, states, privacy behavior, and troubleshooting.
180
-
181
- ### How Remote connects Aivin to computers
182
-
183
- ![Aivin Platform routes authenticated work to listeners on selected computers; each listener applies local policy and returns progress and results](docs/media/aivin-remote-architecture.svg)
184
-
185
- Each paired computer opens its own authenticated outbound connection to Aivin Platform. The
186
- platform routes a chat or mission to the selected computer; its listener applies local policy,
187
- requests approval for protected actions, runs the allowed local tools, and sends progress and
188
- results back. The mascot talks to the listener on the same computer—it is not a separate remote
189
- control channel.
190
-
191
- ## What you get from a scaffold
192
-
193
- Both `aivin init` and `aivin create` produce the same project shape (`init` additionally writes
194
- `src/service.ts` — see [CLI.md](docs/CLI.md#aivin-init-name)):
195
-
196
- ```
197
- my-plugin/
198
- ├── manifest.json # shared fields + plugins[] - identity, input/output schema, triggers
199
- ├── src/
200
- │ └── main.ts # (+ service.ts, if you used `aivin init`)
201
- ├── package.json # depends only on @aivin-labs/sdk; "start" runs `aivin-server` directly
202
- ├── tsconfig.json # editor/type-checking config, not used to build anything at deploy time
203
- ├── AGENTS.md # orientation for a coding agent (Claude Code, Cursor, ...) in this project
204
- ├── test/ # a real, runnable example test using createMockSDK
205
- ├── .env # local-only config (SDK_ENDPOINT, etc.)
206
- └── .gitignore
207
- ```
208
-
209
- `manifest.json`'s `description` is what the AI planner reads to decide when to use your plugin —
210
- fill it in precisely. Full field reference lives in
211
- [MANIFEST.md (sdk repo)](https://github.com/aivin-labs/AIVIN-SDK/blob/main/docs/MANIFEST.md).
212
-
213
- ## Command overview
214
-
215
- Every command supports `--help` for its full flag list (`aivin <command> --help`). This table is
216
- a map — see [docs/CLI.md](docs/CLI.md) for the complete reference, including exact flags,
217
- examples, and behavior notes for each one.
218
-
219
- | Command | What it does |
220
- | --- | --- |
221
- | `aivin init [name]` | Scaffold a plugin **and** AI-generate its code from a description, in one step |
222
- | `aivin create [name]` | Scaffold a blank plugin project, no AI step |
223
- | `aivin validate` | Validate `manifest.json` (or `--json`/`--stdin`) without touching the network |
224
- | `aivin start` | Run the plugin locally (real gRPC server + `:4001` HTTP test shim), with hot-reload |
225
- | `aivin deploy` | Deploy the current plugin to your org |
226
- | `aivin test` | Deploy to a non-production instance, then smoke-test it and save a report |
227
- | `aivin plugin search <query>` | Search the platform's plugin ecosystem for something to reuse |
228
- | `aivin plugin info <id>` | Show one plugin's detail directly by id, no search query needed |
229
- | `aivin plugin ask [mission]` | One-shot: auto-pick the best-matching plugin for a mission and trigger it, like an agent would |
230
- | `aivin plugin make <description>` | AI-generate `src/main.ts` from a natural-language description |
231
- | `aivin plugin convert [hint]` | Turn an existing project in the current directory into a plugin |
232
- | `aivin plugin trigger [mission] [input]` | Invoke a deployed plugin for real and print the result |
233
- | `aivin plugin logs [pluginId]` | Tail a deployed plugin's live console output |
234
- | `aivin connector` | Register/search/list reusable OAuth or credential-form connectors |
235
- | `aivin pluginstore` | Attach a self-hosted `aivin-service` worker to your org as a plugin store |
236
- | `aivin mcp <url>` | Scan an MCP server and convert everything it finds into deployed plugin(s) |
237
- | `aivin mcp create <name>` | Scaffold a single manifest-only plugin that proxies one MCP tool/resource/prompt |
238
- | `aivin login [baseUrl]` | Log in and save an API key for this machine (browser flow by default) |
239
- | `aivin whoami` | Show which account is logged in on this machine |
240
- | `aivin key` | Manage named API keys (`gen` / `revoke` / `list`) for your account |
241
- | `aivin browser [mission]` | Run an AI Browser mission, driving a real local or server-side browser |
242
- | `aivin remote start` | Connect this computer to Aivin and show the Windows mascot when enabled |
243
- | `aivin ui` | Show the Windows mascot with its ask box, or preview its animations with `--demo` |
244
- | `aivin do [agentNickname] [mission]` | Have an AI Staff agent work toward a goal in the background |
245
- | `aivin do job [description]` | Create a recurring automation job from a plain-language description |
246
- | `aivin task [description]` | Create, list, get, update, or delete tasks in a project |
247
- | `aivin workspace` | Browse your workspaces/projects and pick one for `--workspace`/`--project` |
248
- | `aivin agent` | Search, install, create, and publish AI Staff agents |
249
- | `aivin project` | Create, rename, and delete projects within a workspace |
250
-
251
- ## Environment variables
252
-
253
- Most projects never need any of these — `aivin login` saves your key once, machine-wide, and
254
- sensible defaults cover local development. Set them in a project's `.env` (or your shell) to
255
- override:
256
-
257
- | Variable | Used by | Default |
258
- | --- | --- | --- |
259
- | `SDK_ENDPOINT` | SDK calls, `aivin start` | `sdk.aivin.cloud:443` |
260
- | `AIVIN_BASE_URL` | `deploy`, `test`, `plugin make/convert/trigger`, `login --basic` | `https://api.aivin.cloud` |
261
- | `AIVIN_WEB_URL` | `login` (browser flow) | `https://brain.aivin.cloud` |
262
- | `LOCAL_TEST_PORT` | `aivin start` | `4001` |
263
- | `LOCAL_TEST_HOST` | `aivin start` | `127.0.0.1` (loopback-only — `/invoke` has no auth) |
264
- | `AIVIN_SANDBOX_WORKER` | `aivin start`, deployed containers | `false` |
265
-
266
- Full descriptions and when you'd actually touch each one: [CLI.md#environment-variables](docs/CLI.md#environment-variables).
267
-
268
- ## Documentation
269
-
270
- - [docs/AIVIN_MASCOT.md](docs/AIVIN_MASCOT.md) — the Windows mascot: interaction, voice,
271
- animation states, shortcuts, privacy, controls, and troubleshooting.
272
- - [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) — the full narrative walkthrough: scaffold,
273
- write, test, deploy, and use a plugin from the CLI, plus everything else `aivin` drives (tasks,
274
- AI Browser missions, workspaces, agents).
275
- - [docs/CLI.md](docs/CLI.md) — every command, flag, and environment variable, for lookup.
276
- - [docs/CHANGELOG.md](docs/CHANGELOG.md) — release history.
277
- - [`@aivin-labs/sdk`'s own docs](https://github.com/aivin-labs/AIVIN-SDK/tree/main/docs) — the SDK
278
- API your plugin code calls (`ai`, `vector`, `store`, ...), `manifest.json`'s field reference, and
279
- `ctx`. This package doesn't duplicate that content.
280
-
281
- ## Relationship to @aivin-labs/sdk
282
-
283
- - **This package (`@aivin-labs/cli`)** is dev tooling: it never runs inside a deployed plugin
284
- container, only on your machine (or CI). Its own `aivin --version` is independent of whatever
285
- `@aivin-labs/sdk` version a given plugin project has installed.
286
- - **`@aivin-labs/sdk`** is the runtime library (`import { ai, ... } from '@aivin-labs/sdk'`) and
287
- also ships `bin/server.mjs` (exposed as the `aivin-server` binary) — the actual process a
288
- deployed plugin container runs via `npm start`. `aivin start`/`aivin test` resolve and run this
289
- binary from the **current project's own** installed `@aivin-labs/sdk`, not from this CLI's
290
- install location, so a scaffolded project's `package.json` depends on `@aivin-labs/sdk` directly
291
- and never needs this CLI package installed inside the container.
292
-
293
- ## Development
294
-
295
- ```bash
296
- npm install
297
- npm run lint # eslint .
298
- npm run format # prettier --write .
299
- npm test # node --test test/cli.validate.test.mjs
300
- ```
301
-
302
- ## License
303
-
304
- MIT
1
+ <div align="center">
2
+
3
+ # ⚡ @aivin-labs/cli
4
+
5
+ **The Command-Line Gateway to AIVIN Bot & The Agentic Ecosystem**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@aivin-labs/cli?style=flat-square&color=blue&logo=npm)](https://www.npmjs.com/package/@aivin-labs/cli)
8
+ [![Node.js](https://img.shields.io/badge/Node.js-%E2%89%A522.0.0-339933?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Native%20Exec-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
10
+ [![MCP Ready](https://img.shields.io/badge/MCP-Protocol%20Ready-purple?style=flat-square)](https://modelcontextprotocol.io)
11
+ [![Platform](https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux-lightgrey?style=flat-square)](#install-without-nodejs-connect-a-computer-to-aivin)
12
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
13
+
14
+ <p align="center">
15
+ Building an autonomous AI agent that does real work usually requires weeks of plumbing before business logic: servers, model routing, queues, auth, and sandboxes. <b>Aivin collapses that into minutes.</b>
16
+ </p>
17
+
18
+ [The Aivin Ecosystem](#the-aivin-ecosystem) •
19
+ [AIVIN Bot in Action](#aivin-bot-capabilities-via-cli) •
20
+ [Architecture](#how-the-cli-powers-aivin-bot) •
21
+ [Installation](#install) •
22
+ [Quick Start](#quick-start) •
23
+ [Windows Mascot](#aivin-mascot-on-windows) •
24
+ [Command Reference](#command-overview)
25
+
26
+ ---
27
+
28
+ </div>
29
+
30
+ ## The Aivin Ecosystem
31
+
32
+ <p align="center">
33
+ <img src="docs/media/aivin-ecosystem.jpg" alt="AIVIN Agentic Ecosystem Overview" width="800" />
34
+ </p>
35
+
36
+ `@aivin-labs/cli` is your day-to-day command center for interacting with **AIVIN Bot** and developing on the [Aivin Platform](https://aivin.cloud). Run `aivin init`, describe what you need in plain words, and get back a fully typed TypeScript project with a hot-reloading dev server, typed schemas, and single-command deployment to production.
37
+
38
+ Aivin is a modular, composable ecosystem for agentic software:
39
+
40
+ - **AIVIN Bot & AI Staff** — Persistent, goal-driven agents that reason over private data, use plugins as tools, and pause for human approval (HIL) mid-task.
41
+ - **Typed Plugins** — The core unit of work: a typed function (`main(mission, input, ctx)`) deployed in its own isolated container, searchable and callable by any agent across your organization.
42
+ - **Model Context Protocol (MCP)** — Wrap any [MCP](https://modelcontextprotocol.io) server's tools, resources, or prompts as first-class Aivin plugins with zero code (`aivin mcp <url>`).
43
+ - **Autonomous AI Browser** — A self-correcting agent driving a real browser (locally or server-side) with vision and DOM reasoning to accomplish tasks end-to-end (`aivin browser`).
44
+ - **Local Machine Supervised Execution** — Pair your local computer with AIVIN Bot (`aivin remote start`), allowing the bot to interact with logged-in web applications safely under explicit mission scopes.
45
+ - **Natural Language Automation** — Schedule recurring background tasks using plain English (`aivin do job "..."`) without ever touching cron syntax.
46
+ - **Plugin Marketplace** — Publish and share plugins or MCP proxies with team members or the public ecosystem (`aivin mcp <url> --publish`).
47
+
48
+ ---
49
+
50
+ ## AIVIN Bot Capabilities via CLI
51
+
52
+ The CLI brings the full power of **AIVIN Bot** directly into your terminal workflows:
53
+
54
+ ```mermaid
55
+ flowchart TD
56
+ CLIUser(["Terminal / Developer"]) --> Command["aivin CLI Commands"]
57
+
58
+ subgraph BotActions["AIVIN Bot Actions"]
59
+ Command -->|"aivin do [agent] [mission]"| AgentTask["AI Staff Goal Execution"]
60
+ Command -->|"aivin plugin ask [mission]"| AutoMatch["Auto-Pick & Execute Best Plugin"]
61
+ Command -->|"aivin browser [mission]"| WebTask["Autonomous Web Navigation"]
62
+ Command -->|"aivin do job [description]"| AutoJob["Natural Language Scheduled Cron"]
63
+ end
64
+
65
+ subgraph RemoteSupervision["Supervised Local Execution"]
66
+ Command -->|"aivin remote start"| RemoteTunnel["Secure Outbound Tunnel"]
67
+ RemoteTunnel --> LocalBrowser["Isolated Browser Profile (~/.aivin)"]
68
+ RemoteTunnel --> DesktopMascot["Windows Interactive Floating Mascot"]
69
+ RemoteTunnel --> CDPFilter["CDP Safety Filter: Block Local Files & Executables"]
70
+ end
71
+
72
+ subgraph Extensibility["Zero-Code Tooling"]
73
+ Command -->|"aivin mcp <url>"| MCPProxy["Auto-Convert MCP Server to Plugin"]
74
+ Command -->|"aivin init <name>"| AIScaffold["AI-Generated Typed Plugin Project"]
75
+ Command -->|"aivin deploy"| Marketplace["Deploy to Organization / Marketplace"]
76
+ end
77
+ ```
78
+
79
+ ### 1. Goal-Driven Staff Agents (`aivin do`)
80
+ Dispatch an objective directly to an AI Staff agent. The agent breaks down the mission, queries relevant documents, invokes available plugins, and reports back:
81
+ ```bash
82
+ aivin do researcher "Summarize key changes in our compliance policy and compare with last quarter"
83
+ ```
84
+
85
+ ### 2. Autonomous AI Browser (`aivin browser`)
86
+ Drive a dedicated browser session locally or server-side:
87
+ ```bash
88
+ aivin browser "Open site X, navigate to billing, and download the latest tax statement"
89
+ ```
90
+
91
+ ### 3. Natural Language Scheduled Automation (`aivin do job`)
92
+ Define recurring background tasks in plain English:
93
+ ```bash
94
+ aivin do job "Every Monday at 9:00 AM, query pending PRs and notify our team Slack channel"
95
+ ```
96
+
97
+ ### 4. Smart Plugin Matching (`aivin plugin ask`)
98
+ Pass an open-ended mission, and AIVIN Bot automatically searches your organization's catalog, selects the best-matching plugin, executes it with the required input, and prints the result:
99
+ ```bash
100
+ aivin plugin ask "Convert the quarterly sales data in data.csv into an executive summary table"
101
+ ```
102
+
103
+ ---
104
+
105
+ ## How the CLI Powers AIVIN Bot
106
+
107
+ ```mermaid
108
+ sequenceDiagram
109
+ autonumber
110
+ actor Dev as Developer
111
+ participant CLI as aivin CLI
112
+ participant Cloud as AIVIN Platform / Bot
113
+ participant Browser as Local Browser Window
114
+ participant Target as Target Web / SaaS
115
+
116
+ Dev->>CLI: aivin remote start --code <code>
117
+ CLI->>Cloud: Authenticate and establish outbound tunnel
118
+ Cloud-->>CLI: Machine connected to AIVIN Bot
119
+
120
+ Dev->>Cloud: Assign web mission via Chat or CLI
121
+ Cloud->>CLI: Route browser action to paired computer
122
+ CLI->>Browser: Launch isolated profile with existing user cookies
123
+ Browser->>Target: Navigate and execute steps
124
+ opt Requires 2FA or Human Checkpoint
125
+ CLI->>Dev: Native desktop notification / Mascot alert
126
+ Dev->>Browser: Complete 2FA prompt
127
+ end
128
+ Browser->>Target: Finalize download or update
129
+ CLI-->>Cloud: Mission complete & report progress
130
+ Cloud-->>Dev: Return finalized result
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Install
136
+
137
+ ### Global Installation via npm
138
+
139
+ ```bash
140
+ npm install -g @aivin-labs/cli
141
+ aivin --version
142
+ ```
143
+
144
+ > **Requirement**: Node.js **≥ 22.0.0**. The CLI leverages Node's native TypeScript execution to run `src/main.ts` directly with zero compile steps.
145
+
146
+ ---
147
+
148
+ ### Install without Node.js (Connect a Computer to Aivin)
149
+
150
+ Self-contained standalone single-file binaries are available for every major operating system:
151
+
152
+ ```powershell
153
+ # Windows 10/11 (PowerShell 5.1 or 7), x64 or ARM64
154
+ irm https://get.aivin.vn/install.ps1 | iex
155
+ ```
156
+
157
+ ```bash
158
+ # macOS (Intel / Apple Silicon) and Linux (x64 / arm64)
159
+ curl -fsSL https://get.aivin.vn/install.sh | sh
160
+ ```
161
+
162
+ | Platform | Binary Build |
163
+ | :--- | :--- |
164
+ | **Windows x64 / ARM64** | `aivin-windows-x64.exe` / `aivin-windows-arm64.exe` |
165
+ | **macOS Intel / Apple Silicon** | `aivin-darwin-x64` / `aivin-darwin-arm64` |
166
+ | **Linux glibc x64 / arm64** | `aivin-linux-x64` / `aivin-linux-arm64` |
167
+ | **Linux musl (Alpine)** | `aivin-linux-x64-musl` / `aivin-linux-arm64-musl` |
168
+
169
+ In Aivin Web, clicking **Chat box → Browser menu → Add this computer** prints a one-liner with a one-time pairing code (`aivin remote start --code <code>`).
170
+
171
+ ---
172
+
173
+ ## Quick Start
174
+
175
+ ```bash
176
+ # 1. Scaffold a new plugin and generate working code from description
177
+ aivin init invoice-parser
178
+ cd invoice-parser && npm install
179
+
180
+ # 2. Run locally with hot-reloading (gRPC server + HTTP test shim on :4001)
181
+ aivin start
182
+
183
+ # 3. Log in to Aivin Platform
184
+ aivin login
185
+
186
+ # 4. Verify on non-production instance
187
+ aivin test
188
+
189
+ # 5. Ship to your organization
190
+ aivin deploy
191
+ ```
192
+
193
+ Prefer a blank scaffold without AI-generated code? Use `aivin create my-plugin`.
194
+ Have an existing project you want to wrap? `aivin plugin convert` converts it in place.
195
+
196
+ ---
197
+
198
+ ## Aivin Mascot on Windows
199
+
200
+ <p align="center">
201
+ <img src="docs/media/aivin-mascot-live.gif" alt="The live Aivin mascot showing chat, file drag, and attached-file states" width="480" />
202
+ </p>
203
+
204
+ When Aivin Remote is running on Windows, an interactive animated **Aivin Mascot** floats smoothly above your desktop windows:
205
+
206
+ ```bash
207
+ aivin remote start # start remote listener and show mascot
208
+ aivin ui # open mascot ask box
209
+ aivin ui --demo # preview all mascot animations
210
+ aivin remote mascot off # disable mascot persistently
211
+ aivin remote mascot on # re-enable mascot for next start
212
+ ```
213
+
214
+ - **Visual State Indicators**: Displays real-time states (idle, working, thinking, waiting for approval, paused, offline, error).
215
+ - **Interactive Controls**: Click to open quick ask box, talk using live voice chat, or drag-and-drop local files directly onto the mascot to attach them to your next prompt.
216
+ - **Screen-Aware**: Automatically moves aside and hides itself during agent screenshot captures.
217
+
218
+ ### How Remote Connects Aivin to Local Computers
219
+
220
+ <p align="center">
221
+ <img src="docs/media/aivin-remote-architecture.svg" alt="Aivin Platform routes authenticated work to listeners on selected computers; each listener applies local policy and returns progress and results" width="760" />
222
+ </p>
223
+
224
+ Each paired computer opens its own authenticated outbound connection to Aivin Platform. The platform routes a chat or mission to the selected computer; its listener applies local policy, requests approval for protected actions, runs the allowed local tools, and sends progress and results back. The mascot talks to the listener on the same computer—it is not a separate remote control channel.
225
+
226
+ ---
227
+
228
+ ## What You Get from a Scaffold
229
+
230
+ Every plugin scaffolded via `aivin init` or `aivin create` has a clear, standardized structure:
231
+
232
+ ```text
233
+ my-plugin/
234
+ ├── manifest.json # Identity, I/O JSON Schema, triggers & AI descriptions
235
+ ├── src/
236
+ │ ├── main.ts # Typed entrypoint: main(mission, input, ctx)
237
+ │ └── service.ts # Core business logic generated by AIVIN Bot
238
+ ├── package.json # Depends strictly on @aivin-labs/sdk
239
+ ├── tsconfig.json # Native TypeScript execution config
240
+ ├── AGENTS.md # Orientation guide for coding agents (Cursor, Claude Code)
241
+ ├── test/ # Runnable integration tests with createMockSDK
242
+ └── .env # Local development overrides
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Command Overview
248
+
249
+ | Command | Action |
250
+ | :--- | :--- |
251
+ | `aivin init [name]` | Scaffold a plugin **and** AI-generate working code from your description |
252
+ | `aivin create [name]` | Scaffold a clean, blank plugin project without AI code generation |
253
+ | `aivin validate` | Validate `manifest.json` schema without network calls |
254
+ | `aivin start` | Run plugin locally (gRPC server + `:4001` HTTP test shim) with hot reload |
255
+ | `aivin deploy` | Deploy the current plugin to your organization's workspace |
256
+ | `aivin test` | Deploy to a staging instance, run smoke tests, and print report |
257
+ | `aivin plugin search <query>` | Search your organization and public marketplace for reusable plugins |
258
+ | `aivin plugin ask [mission]` | Auto-select the best matching plugin and execute it against a mission |
259
+ | `aivin plugin trigger [mission] [input]` | Directly invoke a deployed plugin with payload and inspect output |
260
+ | `aivin plugin logs [pluginId]` | Stream live console output from a deployed plugin |
261
+ | `aivin connector` | Manage shared OAuth credentials and authentication namespaces |
262
+ | `aivin mcp <url>` | Scan any MCP server and instantly deploy all its tools as Aivin plugins |
263
+ | `aivin browser [mission]` | Launch an autonomous AI Browser mission driving a local or cloud browser |
264
+ | `aivin remote start` | Connect this computer to Aivin Platform with local CDP safety filters |
265
+ | `aivin ui` | Show the Windows desktop mascot or preview animations with `--demo` |
266
+ | `aivin do [agent] [mission]` | Dispatch a goal to an AI Staff agent to run in the background |
267
+ | `aivin do job [description]` | Create a recurring background automation job using plain English |
268
+ | `aivin task [description]` | Create, update, or track tasks within your active workspace |
269
+ | `aivin workspace` | Switch between organizations, workspaces, and projects |
270
+ | `aivin agent` | Search, install, create, or publish AI Staff agents |
271
+
272
+ ---
273
+
274
+ ## Relationship to @aivin-labs/sdk
275
+
276
+ - **`@aivin-labs/cli`** is developer tooling: It runs locally on your workstation or in CI environments. It is never bundled into your deployed container.
277
+ - **`@aivin-labs/sdk`** is the runtime library imported in code (`import { ai, vector, store } from '@aivin-labs/sdk'`). It provides the runtime server (`aivin-server`) executed inside deployed plugin containers.
278
+
279
+ ---
280
+
281
+ ## Environment Variables
282
+
283
+ | Variable | Target | Default |
284
+ | :--- | :--- | :--- |
285
+ | `SDK_ENDPOINT` | SDK gRPC connection | `sdk.aivin.cloud:443` |
286
+ | `AIVIN_BASE_URL` | API endpoints (`deploy`, `test`, `login`) | `https://api.aivin.cloud` |
287
+ | `AIVIN_WEB_URL` | Web dashboard & browser login | `https://brain.aivin.cloud` |
288
+ | `LOCAL_TEST_PORT` | Local test HTTP port (`aivin start`) | `4001` |
289
+ | `LOCAL_TEST_HOST` | Local test bind host | `127.0.0.1` |
290
+ | `AIVIN_SANDBOX_WORKER` | Isolated thread execution | `false` |
291
+
292
+ ---
293
+
294
+ ## Documentation
295
+
296
+ - [docs/AIVIN_MASCOT.md](docs/AIVIN_MASCOT.md) — The Windows desktop mascot: interactions, animations, shortcuts, privacy, and controls.
297
+ - [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md) — Complete walkthrough: scaffold, develop, test, and deploy plugins and agents.
298
+ - [docs/CLI.md](docs/CLI.md) — Comprehensive command and flag reference manual.
299
+ - [docs/CHANGELOG.md](docs/CHANGELOG.md) — Version release history.
300
+ - [`@aivin-labs/sdk` Docs](https://github.com/aivin-labs/AIVIN-SDK/tree/main/docs) — Runtime SDK documentation (`ai`, `vector`, `store`).
301
+
302
+ ---
303
+
304
+ ## Development
305
+
306
+ ```bash
307
+ npm install
308
+ npm run lint # eslint .
309
+ npm run format # prettier --write .
310
+ npm test # node --test test/cli.validate.test.mjs
311
+ ```
312
+
313
+ ---
314
+
315
+ ## License
316
+
317
+ MIT License. See [LICENSE](LICENSE) for details.
318
+
319
+ ---
320
+
321
+ <div align="center">
322
+
323
+ Built for developers who want AI agents to do real, dependable work.
324
+
325
+ </div>