@mimikkai/opencode-mimikkai-connect 1.0.0 → 1.0.1

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 (2) hide show
  1. package/README.md +6 -109
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,126 +2,23 @@
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
- bun install
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
- └─────────────────────────────┘
8
+ opencode plugin @mimikkai/opencode-mimikkai-connect
74
9
  ```
75
10
 
76
11
  ## Usage
77
12
 
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)
95
- ```
96
-
97
- ### Key Design Decisions
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:
109
-
110
13
  ```shell
111
- rm ~/.config/opencode/mimikkai.json
14
+ # Authenticate 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
- ### No models appear
116
-
117
- The plugin couldn't fetch models from `litellm.mimikkai.ru/model/info`. Check:
118
- 1. Your LiteLLM key is valid (`sk-` prefix)
119
- 2. Network connectivity to `litellm.mimikkai.ru`
120
- 3. Set `LOG_LEVEL=debug` for verbose logging
121
-
122
- ### Token expired
123
-
124
- If the Sanctum token expires, the `loader` will detect it and return empty, forcing re-authentication. Run `opencode auth login` again.
21
+ A browser opens — confirm the displayed code. The plugin fetches your LiteLLM virtual key and syncs available models automatically.
125
22
 
126
23
  ## License
127
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mimikkai/opencode-mimikkai-connect",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MimikkAi auth plugin for OpenCode — device authorization + LiteLLM gateway",
5
5
  "author": "dealenx",
6
6
  "license": "MIT",