@mimikkai/opencode-mimikkai-connect 1.0.0 → 1.0.2
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 +20 -107
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,126 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
OpenCode plugin for MimikkAi — device authorization flow + LiteLLM gateway integration.
|
|
4
4
|
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
- [OpenCode](https://opencode.ai) installed
|
|
8
|
-
- [Bun](https://bun.sh) for building
|
|
9
|
-
- A MimikkAi account (register at [panel.mimikkai.ru](https://panel.mimikkai.ru))
|
|
10
|
-
|
|
11
5
|
## Installation
|
|
12
6
|
|
|
13
7
|
```shell
|
|
14
|
-
|
|
15
|
-
bun run build
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Configuration
|
|
19
|
-
|
|
20
|
-
Add the plugin to your `opencode.json`:
|
|
21
|
-
|
|
22
|
-
```json
|
|
23
|
-
{
|
|
24
|
-
"plugin": ["opencode-mimikkai-connect"]
|
|
25
|
-
}
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Authentication Flow
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
User runs `opencode auth login`
|
|
32
|
-
│
|
|
33
|
-
▼
|
|
34
|
-
┌─────────────────────────────┐
|
|
35
|
-
│ Device Authorization │
|
|
36
|
-
│ POST /api/auth/device/ │
|
|
37
|
-
│ authorize │
|
|
38
|
-
└────────────┬────────────────┘
|
|
39
|
-
│
|
|
40
|
-
▼
|
|
41
|
-
Browser opens:
|
|
42
|
-
panel.mimikkai.ru/device?code=AB12-CD34
|
|
43
|
-
│
|
|
44
|
-
▼
|
|
45
|
-
┌─────────────────────────────┐
|
|
46
|
-
│ Poll for token │
|
|
47
|
-
│ POST /api/auth/device/ │
|
|
48
|
-
│ token (every 5s) │
|
|
49
|
-
│ 202 → pending │
|
|
50
|
-
│ 200 → { token, user } │
|
|
51
|
-
└────────────┬────────────────┘
|
|
52
|
-
│
|
|
53
|
-
▼
|
|
54
|
-
┌─────────────────────────────┐
|
|
55
|
-
│ Fetch LiteLLM virtual key │
|
|
56
|
-
│ GraphQL → userViewer │
|
|
57
|
-
│ → litellmVirtualKey (sk-) │
|
|
58
|
-
└────────────┬────────────────┘
|
|
59
|
-
│
|
|
60
|
-
▼
|
|
61
|
-
┌─────────────────────────────┐
|
|
62
|
-
│ Save to storage │
|
|
63
|
-
│ ~/.config/opencode/ │
|
|
64
|
-
│ mimikkai.json │
|
|
65
|
-
└────────────┬────────────────┘
|
|
66
|
-
│
|
|
67
|
-
▼
|
|
68
|
-
┌─────────────────────────────┐
|
|
69
|
-
│ Register provider + models │
|
|
70
|
-
│ @ai-sdk/openai-compatible │
|
|
71
|
-
│ → litellm.mimikkai.ru/v1 │
|
|
72
|
-
│ → /model/info │
|
|
73
|
-
└─────────────────────────────┘
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
77
|
-
|
|
78
|
-
1. Run `opencode auth login` and select **Device Authorization**
|
|
79
|
-
2. A browser opens — confirm the displayed code
|
|
80
|
-
3. The plugin fetches your LiteLLM virtual key and syncs available models
|
|
81
|
-
4. Select a MimikkAi model in OpenCode's model picker
|
|
82
|
-
|
|
83
|
-
## Architecture
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
src/
|
|
87
|
-
├── constants.ts ← Mimikkai endpoints (service, panel, litellm)
|
|
88
|
-
├── mimikkai.ts ← API client (device auth, GraphQL, /model/info)
|
|
89
|
-
├── storage.ts ← Token storage (~/.config/opencode/mimikkai.json)
|
|
90
|
-
├── logger.ts ← Configurable structured logging (LOG_LEVEL env)
|
|
91
|
-
├── index.ts ← Plugin entry (auth hook + config hook + dispose)
|
|
92
|
-
└── test/
|
|
93
|
-
├── mimikkai.test.ts ← API client tests (24 tests)
|
|
94
|
-
└── storage.test.ts ← Storage tests (8 tests)
|
|
8
|
+
opencode plugin @mimikkai/opencode-mimikkai-connect
|
|
95
9
|
```
|
|
96
10
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
- **Sanctum token → LiteLLM key exchange**: The Sanctum token (`1|abc...`) from auth is exchanged for a LiteLLM virtual key (`sk-...`) via GraphQL. Only the `sk-` key is used for API requests.
|
|
100
|
-
- **Key refresh on every config hook**: The `config` hook re-fetches the LiteLLM key on each invocation using the stored Sanctum token, falling back to the cached key if the refresh fails.
|
|
101
|
-
- **Token validation on startup**: The `loader` validates the Sanctum token via `userViewer` GraphQL query before using the stored LiteLLM key.
|
|
102
|
-
- **Far-future expiry**: The OAuth callback returns a 1-year expiry since Sanctum tokens don't have a known short TTL.
|
|
103
|
-
|
|
104
|
-
## Troubleshooting
|
|
105
|
-
|
|
106
|
-
### "LiteLLM virtual key is missing or masked"
|
|
107
|
-
|
|
108
|
-
The backend returned a masked key (containing `...`). This happens when the key hasn't been fully provisioned. Try logging out and back in:
|
|
11
|
+
## Authentication
|
|
109
12
|
|
|
110
13
|
```shell
|
|
111
|
-
|
|
14
|
+
# Login via device authorization
|
|
15
|
+
opencode providers login --provider mimikkai-connect --method "Device Authorization"
|
|
16
|
+
|
|
17
|
+
# Or use the interactive flow
|
|
112
18
|
opencode auth login
|
|
113
19
|
```
|
|
114
20
|
|
|
115
|
-
|
|
21
|
+
A browser opens — confirm the displayed code. The plugin fetches your LiteLLM virtual key and syncs available models automatically.
|
|
22
|
+
|
|
23
|
+
## CLI Commands
|
|
116
24
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
25
|
+
| Command | Description |
|
|
26
|
+
|---------|-------------|
|
|
27
|
+
| `opencode plugin @mimikkai/opencode-mimikkai-connect` | Install the plugin |
|
|
28
|
+
| `opencode providers login --provider mimikkai-connect --method "Device Authorization"` | Authenticate with MimikkAi |
|
|
29
|
+
| `opencode providers logout mimikkai-connect` | Remove stored credentials |
|
|
30
|
+
| `opencode providers list` | List configured providers |
|
|
121
31
|
|
|
122
|
-
|
|
32
|
+
## Environment Variables
|
|
123
33
|
|
|
124
|
-
|
|
34
|
+
| Variable | Default | Description |
|
|
35
|
+
|----------|---------|-------------|
|
|
36
|
+
| `LOG_LEVEL` | `warn` | Set to `debug` for verbose logging |
|
|
37
|
+
| `OPENCODE_CONFIG_DIR` | `~/.config/opencode` | Config directory path |
|
|
125
38
|
|
|
126
39
|
## License
|
|
127
40
|
|