@mitsein-ai/cli 0.1.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/README.md +142 -0
- package/dist/index.js +143 -0
- package/package.json +49 -0
- package/src/commands/agent.ts +91 -0
- package/src/commands/api-auto.ts +245 -0
- package/src/commands/auth-browser.ts +126 -0
- package/src/commands/auth-device.ts +97 -0
- package/src/commands/auth-internal.ts +49 -0
- package/src/commands/auth.ts +105 -0
- package/src/commands/command-opts.ts +41 -0
- package/src/commands/dev.ts +100 -0
- package/src/commands/messages.ts +61 -0
- package/src/commands/project.ts +77 -0
- package/src/commands/run.ts +134 -0
- package/src/commands/thread.ts +187 -0
- package/src/commands/version.ts +17 -0
- package/src/core/client.ts +201 -0
- package/src/core/config.ts +26 -0
- package/src/core/credentials.ts +173 -0
- package/src/core/errors.ts +76 -0
- package/src/core/openapi.ts +182 -0
- package/src/core/output.ts +59 -0
- package/src/core/sse.ts +135 -0
- package/src/core/waiters-output.ts +95 -0
- package/src/core/waiters.ts +169 -0
- package/src/index.ts +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# @mitsein-ai/cli
|
|
2
|
+
|
|
3
|
+
Mitsein CLI — internal dev tool for agent verification and workflow automation.
|
|
4
|
+
|
|
5
|
+
TypeScript rewrite of `backend/apps/mitsein-cli/` (Python), ported to the Bun monorepo.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# From npm (once published)
|
|
11
|
+
bunx @mitsein-ai/cli --help
|
|
12
|
+
|
|
13
|
+
# From monorepo
|
|
14
|
+
cd bun-workspace/apps/mitsein-cli
|
|
15
|
+
bun install
|
|
16
|
+
bun run src/index.ts --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Check backend health
|
|
23
|
+
mitsein dev health
|
|
24
|
+
|
|
25
|
+
# Print dev token
|
|
26
|
+
mitsein dev token
|
|
27
|
+
|
|
28
|
+
# List threads
|
|
29
|
+
mitsein thread list
|
|
30
|
+
|
|
31
|
+
# Send a message and stream the agent run
|
|
32
|
+
mitsein thread send <thread_id> "Hello" --stream
|
|
33
|
+
|
|
34
|
+
# Auto-generated API commands from OpenAPI
|
|
35
|
+
mitsein api list-tags
|
|
36
|
+
mitsein api list-ops threads
|
|
37
|
+
mitsein api threads list-threads
|
|
38
|
+
|
|
39
|
+
# Login
|
|
40
|
+
mitsein auth login
|
|
41
|
+
mitsein auth login --device-code
|
|
42
|
+
mitsein auth whoami
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Commands
|
|
46
|
+
|
|
47
|
+
| Command | Description |
|
|
48
|
+
|---------|-------------|
|
|
49
|
+
| `mitsein version` | Print CLI version |
|
|
50
|
+
| `mitsein dev health` | Check backend health (`GET /health`) |
|
|
51
|
+
| `mitsein dev token` | Print resolved dev token |
|
|
52
|
+
| `mitsein dev openapi` | Load and cache OpenAPI spec |
|
|
53
|
+
| `mitsein api list-tags` | List available API tags |
|
|
54
|
+
| `mitsein api list-ops <tag>` | List operations for a tag |
|
|
55
|
+
| `mitsein api <tag> <operation>` | Execute an API operation |
|
|
56
|
+
| `mitsein thread list` | List threads |
|
|
57
|
+
| `mitsein thread get <id>` | Get thread details |
|
|
58
|
+
| `mitsein thread create` | Create a new thread |
|
|
59
|
+
| `mitsein thread history <id>` | Show message history |
|
|
60
|
+
| `mitsein thread send <id> <msg>` | Send message + start agent run |
|
|
61
|
+
| `mitsein run list <thread_id>` | List agent runs |
|
|
62
|
+
| `mitsein run get <run_id>` | Get run status |
|
|
63
|
+
| `mitsein run tail <run_id>` | Stream events (like `tail -f`) |
|
|
64
|
+
| `mitsein run wait <run_id>` | Block until run completes |
|
|
65
|
+
| `mitsein run cancel <run_id>` | Cancel a running agent |
|
|
66
|
+
| `mitsein messages list <id>` | List messages (no agent) |
|
|
67
|
+
| `mitsein messages send <id> <msg>` | Add message (no agent) |
|
|
68
|
+
| `mitsein agent invoke <id> <prompt>` | Message + agent start |
|
|
69
|
+
| `mitsein project list` | List projects |
|
|
70
|
+
| `mitsein project get <id>` | Get project details |
|
|
71
|
+
| `mitsein project delete <id>` | Delete a project |
|
|
72
|
+
| `mitsein auth login` | Browser or device-code login |
|
|
73
|
+
| `mitsein auth logout` | Remove saved credentials |
|
|
74
|
+
| `mitsein auth whoami` | Show current identity |
|
|
75
|
+
|
|
76
|
+
## Global Flags
|
|
77
|
+
|
|
78
|
+
| Flag | Description |
|
|
79
|
+
|------|-------------|
|
|
80
|
+
| `--endpoint <url>` | API base URL (default: `http://localhost:8000`) |
|
|
81
|
+
| `--token <token>` | Bearer token |
|
|
82
|
+
| `--profile <name>` | Profile name (default: `e2e`) |
|
|
83
|
+
| `--real` | Use real account for dev token |
|
|
84
|
+
| `--json` | Machine-readable JSON output |
|
|
85
|
+
| `--debug` | Log HTTP details to stderr |
|
|
86
|
+
| `--timeout <sec>` | HTTP timeout (0 = no timeout, default: `30`) |
|
|
87
|
+
|
|
88
|
+
## Architecture
|
|
89
|
+
|
|
90
|
+
### Credential Provider Chain
|
|
91
|
+
|
|
92
|
+
Same 4-step chain as the Python CLI:
|
|
93
|
+
|
|
94
|
+
1. **ExplicitFlagProvider** — `--token` / `--endpoint`
|
|
95
|
+
2. **EnvProvider** — `MITSEIN_TOKEN` / `MITSEIN_API_URL`
|
|
96
|
+
3. **OAuthProvider** — `~/.mitsein/oauth/<profile>.json`
|
|
97
|
+
4. **DevTokenProvider** — `scripts/dev-token.sh` (localhost only)
|
|
98
|
+
|
|
99
|
+
### Thread Send Modes
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Fire-and-forget (default)
|
|
103
|
+
mitsein thread send <id> "msg"
|
|
104
|
+
|
|
105
|
+
# Wait for completion
|
|
106
|
+
mitsein thread send <id> "msg" --wait
|
|
107
|
+
|
|
108
|
+
# Stream events in real-time
|
|
109
|
+
mitsein thread send <id> "msg" --stream
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### OpenAPI Auto-Commands
|
|
113
|
+
|
|
114
|
+
The `api` command dynamically generates subcommands from the backend's OpenAPI spec:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
mitsein api list-tags # See available tags
|
|
118
|
+
mitsein api threads list-threads # Auto-generated from spec
|
|
119
|
+
mitsein api threads list-threads --body '{"limit": 10}'
|
|
120
|
+
mitsein api threads list-threads --body @payload.json
|
|
121
|
+
echo '{}' | mitsein api threads list-threads --body-stdin
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
bun run typecheck # TypeScript check
|
|
128
|
+
bun test # Run tests (43 tests)
|
|
129
|
+
bun run build # Build single binary
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Migration Status
|
|
133
|
+
|
|
134
|
+
| Phase | Content | Status |
|
|
135
|
+
|-------|---------|--------|
|
|
136
|
+
| P1 | Project skeleton + core layer | ✅ Done |
|
|
137
|
+
| P2 | Extended core + API auto commands | ✅ Done |
|
|
138
|
+
| P3 | Thread + run + messages commands | ✅ Done |
|
|
139
|
+
| P4 | Agent + project + auth commands | ✅ Done |
|
|
140
|
+
| P5 | npm publish + docs | ✅ Done |
|
|
141
|
+
|
|
142
|
+
RFC: [II95V6](https://gitee.com/mitsein/mitsein/issues/II95V6)
|