Compare commits
83
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b2273419f | ||
|
|
82a643c4ed | ||
|
|
049f2e3f9d | ||
|
|
07d22d2df6 | ||
|
|
35c9345a62 | ||
|
|
daef7c25a9 | ||
|
|
a5057a4545 | ||
|
|
c0daa1e69a | ||
|
|
ce0dc28922 | ||
|
|
845f92a234 | ||
|
|
38edeef6c9 | ||
|
|
1d3b2499cc | ||
|
|
6a0973d55a | ||
|
|
297c79fbad | ||
|
|
2889b712bc | ||
|
|
10eae62ad6 | ||
|
|
8c47e66c22 | ||
|
|
835d7a8db5 | ||
|
|
ee5e4c4be0 | ||
|
|
2d1dd7331e | ||
|
|
2c16cba1b3 | ||
|
|
09ba48cfd4 | ||
|
|
ba4252baed | ||
|
|
69666bdb20 | ||
|
|
464997b729 | ||
|
|
69fea785a4 | ||
|
|
a6c18654b3 | ||
|
|
64fca67024 | ||
|
|
808907585c | ||
|
|
d0930caa42 | ||
|
|
1bac35d599 | ||
|
|
c334c49301 | ||
|
|
1adb0090b7 | ||
|
|
3660dae16b | ||
|
|
5e64928654 | ||
|
|
9c113eb077 | ||
|
|
bb62bc05fc | ||
|
|
beefb19928 | ||
|
|
1a4a11178e | ||
|
|
4ca7cfaf48 | ||
|
|
7e2d6a1678 | ||
|
|
2d4ac34360 | ||
|
|
74724d8284 | ||
|
|
61f0aebd2d | ||
|
|
1aad290af4 | ||
|
|
e8f697a739 | ||
|
|
398dc63e8a | ||
|
|
0a2a8564aa | ||
|
|
6ca7f2eb4a | ||
|
|
19592b890f | ||
|
|
57ab2166cb | ||
|
|
52fcecb8df | ||
|
|
43b1a7c4da | ||
|
|
e788fd916d | ||
|
|
33ec85fb00 | ||
|
|
34106363c1 | ||
|
|
a3d72f7232 | ||
|
|
f9f30f7c1a | ||
|
|
39e39ba3b2 | ||
|
|
4c6e8998fe | ||
|
|
5a1cac3c83 | ||
|
|
d2fafa8b65 | ||
|
|
895e1d116d | ||
|
|
2164ae776d | ||
|
|
0d3da375de | ||
|
|
5e1657904c | ||
|
|
e640293f68 | ||
|
|
a17db8e395 | ||
|
|
eafb3b317d | ||
|
|
28b50aa0a1 | ||
|
|
7144d7d703 | ||
|
|
83731e3b50 | ||
|
|
091959e796 | ||
|
|
b0a33ad8b3 | ||
|
|
9bfc49c0dc | ||
|
|
dd7d62105a | ||
|
|
297e85f632 | ||
|
|
6f3df355f3 | ||
|
|
a7d9595984 | ||
|
|
61ed068e37 | ||
|
|
0f02e79398 | ||
|
|
05141af8fe | ||
|
|
57e627bad0 |
No files matched your search
@@ -10,6 +10,7 @@
|
|||||||
|-------|-----|
|
|-------|-----|
|
||||||
| [`agent-arka/`](agent-arka/) | Agent Arka: демон + **веб-дашборд** (`http://127.0.0.1:4545`), установщик и пакеты |
|
| [`agent-arka/`](agent-arka/) | Agent Arka: демон + **веб-дашборд** (`http://127.0.0.1:4545`), установщик и пакеты |
|
||||||
| [`opencode/`](opencode/) | Провайдер OpenCode **Arka-AI**: установщик, плагин, skill, каталог чат-моделей |
|
| [`opencode/`](opencode/) | Провайдер OpenCode **Arka-AI**: установщик, плагин, skill, каталог чат-моделей |
|
||||||
|
| [`multica/`](multica/) | **Multica fork CLI**: daemon c поддержкой agent-arka, установщик |
|
||||||
|
|
||||||
Agent Arka (веб-интерфейс), Linux / WSL:
|
Agent Arka (веб-интерфейс), Linux / WSL:
|
||||||
|
|
||||||
@@ -35,3 +36,17 @@ irm https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/install-arka-pro
|
|||||||
```
|
```
|
||||||
|
|
||||||
Подробности: [opencode/README.md](opencode/README.md) — Windows, Desktop, установка из чата OpenCode.
|
Подробности: [opencode/README.md](opencode/README.md) — Windows, Desktop, установка из чата OpenCode.
|
||||||
|
|
||||||
|
Multica fork CLI, macOS / Linux / WSL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
Multica fork CLI, Windows (PowerShell):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
irm https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.ps1 | iex
|
||||||
|
```
|
||||||
|
|
||||||
|
Подробности: [multica/README.md](multica/README.md).
|
||||||
+7
-16
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
Исходники приватны: [`arka/agent-arka`](https://git.arka-ai.ru/arka/agent-arka). Сборки и этот установщик публичные, без токена.
|
Исходники приватны: [`arka/agent-arka`](https://git.arka-ai.ru/arka/agent-arka). Сборки и этот установщик публичные, без токена.
|
||||||
|
|
||||||
Версия пакета: **2026.9.1**.
|
Версия пакета: **2026.10.30**.
|
||||||
|
|
||||||
## Установка (Linux / WSL)
|
## Установка (Linux / WSL)
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/agent-arka/install
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/agent-arka/install.sh \
|
curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/agent-arka/install.sh \
|
||||||
| AGENT_ARKA_VERSION=2026.9.1 bash
|
| AGENT_ARKA_VERSION=2026.10.30 bash
|
||||||
```
|
```
|
||||||
|
|
||||||
Не стартовать демон:
|
Не стартовать демон:
|
||||||
@@ -57,7 +57,7 @@ ARKA_API_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKL
|
|||||||
|
|
||||||
## Windows (desktop)
|
## Windows (desktop)
|
||||||
|
|
||||||
Скачайте `Agent Arka_*_x64-setup.exe` с [страницы релиза](https://git.arka-ai.ru/arka/public/releases/tag/agent-arka-v2026.9.1).
|
Скачайте `Agent Arka_*_x64-setup.exe` с [страницы релиза](https://git.arka-ai.ru/arka/public/releases/tag/agent-arka-v2026.10.30).
|
||||||
|
|
||||||
- Установщик **не подписан**. SmartScreen: «Подробнее» → «Выполнить в любом случае».
|
- Установщик **не подписан**. SmartScreen: «Подробнее» → «Выполнить в любом случае».
|
||||||
- При первой установке нужен интернет: подтягивается WebView2 Evergreen, если его ещё нет.
|
- При первой установке нужен интернет: подтягивается WebView2 Evergreen, если его ещё нет.
|
||||||
@@ -72,8 +72,9 @@ ARKA_API_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZ234567ABCDEFGHIJKL
|
|||||||
| `agent-arka-*-linux-x86_64.tar.gz` | Linux / WSL, x86_64 (glibc ≥ 2.35) |
|
| `agent-arka-*-linux-x86_64.tar.gz` | Linux / WSL, x86_64 (glibc ≥ 2.35) |
|
||||||
| `agent-arka-*-linux-aarch64.tar.gz` | Linux aarch64 — Armbian / pc162 (PocketClaw, sunxi64), Orange Pi, Ampere (glibc ≥ 2.35) |
|
| `agent-arka-*-linux-aarch64.tar.gz` | Linux aarch64 — Armbian / pc162 (PocketClaw, sunxi64), Orange Pi, Ampere (glibc ≥ 2.35) |
|
||||||
| `Agent Arka_*_x64-setup.exe` | Windows 10/11 x64, desktop (NSIS) |
|
| `Agent Arka_*_x64-setup.exe` | Windows 10/11 x64, desktop (NSIS) |
|
||||||
|
| `Agent Arka_*_aarch64.dmg` | macOS Apple Silicon (arm64), desktop |
|
||||||
|
|
||||||
macOS native (DMG) в этом публичном релизе нет. Установщик на Darwin завершится ошибкой скачивания tarball.
|
macOS — только Apple Silicon (arm64), в виде `Agent Arka_*_aarch64.dmg`. Интел (x86_64) версии нет. Установщик на Darwin из tarball завершится ошибкой скачивания — используйте DMG.
|
||||||
|
|
||||||
## Команды после установки
|
## Команды после установки
|
||||||
|
|
||||||
@@ -97,16 +98,6 @@ agent-arka doctor
|
|||||||
|
|
||||||
Пароль вкладки Password — аварийный (`dashboard_user = operator`). Init печатает его один раз.
|
Пароль вкладки Password — аварийный (`dashboard_user = operator`). Init печатает его один раз.
|
||||||
|
|
||||||
## Сборка из исходников (если нет пакета под вашу OS)
|
|
||||||
|
|
||||||
Репозиторий приватный. У кого есть доступ:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cargo install --git ssh://git@git.arka-ai.ru:4001/arka/agent-arka.git librefang-cli --bin agent-arka
|
|
||||||
agent-arka init --quick
|
|
||||||
agent-arka start
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Agent Arka — web UI and Windows desktop
|
# Agent Arka — web UI and Windows desktop
|
||||||
@@ -121,11 +112,11 @@ Then open [http://127.0.0.1:4545](http://127.0.0.1:4545) and use **Arka AI** to
|
|||||||
|
|
||||||
On **pc162** (Armbian aarch64, PocketClaw) the same command fetches `linux-aarch64`.
|
On **pc162** (Armbian aarch64, PocketClaw) the same command fetches `linux-aarch64`.
|
||||||
|
|
||||||
On Windows, download `Agent Arka_*_x64-setup.exe` from <https://git.arka-ai.ru/arka/public/releases/tag/agent-arka-v2026.9.1>.
|
On Windows, download `Agent Arka_*_x64-setup.exe` from <https://git.arka-ai.ru/arka/public/releases/tag/agent-arka-v2026.10.30>.
|
||||||
The installer is unsigned: SmartScreen → More info → Run anyway.
|
The installer is unsigned: SmartScreen → More info → Run anyway.
|
||||||
First install needs network for the WebView2 Evergreen bootstrapper.
|
First install needs network for the WebView2 Evergreen bootstrapper.
|
||||||
|
|
||||||
Pin a version with `AGENT_ARKA_VERSION=2026.9.1`. Skip autostart with `AGENT_ARKA_AUTO_START=0`.
|
Pin a version with `AGENT_ARKA_VERSION=2026.10.30`. Skip autostart with `AGENT_ARKA_AUTO_START=0`.
|
||||||
|
|
||||||
Put `ARKA_API_KEY` in `~/.agent-arka/secrets.env` (or `~/.librefang/secrets.env` if that home already exists). Create a key at [arka-ai.ru](https://arka-ai.ru).
|
Put `ARKA_API_KEY` in `~/.agent-arka/secrets.env` (or `~/.librefang/secrets.env` if that home already exists). Create a key at [arka-ai.ru](https://arka-ai.ru).
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,14 @@
|
|||||||
# AGENT_ARKA_INIT 1 to run `agent-arka init --quick` when no config.toml exists (default: 1)
|
# AGENT_ARKA_INIT 1 to run `agent-arka init --quick` when no config.toml exists (default: 1)
|
||||||
# LIBREFANG_* names for the same keys still work.
|
# LIBREFANG_* names for the same keys still work.
|
||||||
|
|
||||||
|
# Fail with a clear hint when piped into POSIX `sh` (dash) — this script needs
|
||||||
|
# bash (pipefail, [[ ]], indirect expansion). `curl … | bash`, not `| sh`.
|
||||||
|
if [ -z "${BASH_VERSION:-}" ]; then
|
||||||
|
echo "Agent Arka installer needs bash. Run:" >&2
|
||||||
|
echo " curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/agent-arka/install.sh | bash" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
PUBLIC_API="${AGENT_ARKA_PUBLIC_API:-https://git.arka-ai.ru/api/v1}"
|
PUBLIC_API="${AGENT_ARKA_PUBLIC_API:-https://git.arka-ai.ru/api/v1}"
|
||||||
@@ -149,6 +157,19 @@ ensure_path() {
|
|||||||
warn "Added ${bindir} to PATH in ${rc} (open a new shell, or: source ${rc})"
|
warn "Added ${bindir} to PATH in ${rc} (open a new shell, or: source ${rc})"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Normalize a CalVer "YYYY.M.D" into a single sortable integer (YYYYMMDD pads).
|
||||||
|
ver_cmp_key() {
|
||||||
|
printf '%s' "$1" | awk -F. '{ printf "%04d%02d%02d", $1, $2, $3 }' 2>/dev/null || printf '%s' 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Installed version, or empty when there is no binary/detectable version.
|
||||||
|
installed_version() {
|
||||||
|
local bin="$1" out
|
||||||
|
[[ -x "$bin" ]] || return 1
|
||||||
|
out=$("$bin" --version 2>/dev/null | head -n 1) || return 1
|
||||||
|
printf '%s\n' "$out" | grep -oE '[0-9]{4}\.[0-9]+(\.[0-9]+)?' | tail -n 1
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
printf '%s\n' "${C_BOLD}Agent Arka${C_RESET} — web dashboard installer"
|
printf '%s\n' "${C_BOLD}Agent Arka${C_RESET} — web dashboard installer"
|
||||||
command -v curl >/dev/null 2>&1 || die "curl is required"
|
command -v curl >/dev/null 2>&1 || die "curl is required"
|
||||||
@@ -175,6 +196,31 @@ main() {
|
|||||||
info "Latest: ${version}"
|
info "Latest: ${version}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Update handling: detect an existing install and skip / stop / back it up.
|
||||||
|
local existing
|
||||||
|
existing=$(installed_version "${bindir}/agent-arka" 2>/dev/null || true)
|
||||||
|
if [[ -n "$existing" ]]; then
|
||||||
|
local ek tk
|
||||||
|
ek=$(ver_cmp_key "$existing")
|
||||||
|
tk=$(ver_cmp_key "$version")
|
||||||
|
if [[ "$ek" == "$tk" ]]; then
|
||||||
|
info "Already up to date: agent-arka ${existing} (target ${version})"
|
||||||
|
ensure_path "$bindir"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [[ "$ek" -gt "$tk" ]]; then
|
||||||
|
warn "Downgrading ${existing} -> ${version}"
|
||||||
|
else
|
||||||
|
info "Upgrading ${existing} -> ${version}"
|
||||||
|
fi
|
||||||
|
# Bring the running daemon down before replacing the binary.
|
||||||
|
if AGENT_ARKA_HOME="${HOME_DIR}" LIBREFANG_HOME="${HOME_DIR}" "${bindir}/agent-arka" stop >/dev/null 2>&1; then
|
||||||
|
ok "Stopped running agent-arka ${existing}"
|
||||||
|
fi
|
||||||
|
# Keep a rollback copy of the current binary.
|
||||||
|
cp -f "${bindir}/agent-arka" "${bindir}/agent-arka.previous" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
local tag="${TAG_PREFIX}${version}"
|
local tag="${TAG_PREFIX}${version}"
|
||||||
local asset="agent-arka-${version}-${PLATFORM}.tar.gz"
|
local asset="agent-arka-${version}-${PLATFORM}.tar.gz"
|
||||||
local url="${PUBLIC_DL}/${tag}/${asset}"
|
local url="${PUBLIC_DL}/${tag}/${asset}"
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# arka-search-mcp
|
||||||
|
|
||||||
|
A tiny **MCP stdio server** that exposes Arka web **search** and **fetch** to any
|
||||||
|
MCP-capable agent harness (opencode, Hermes, DeepSeek Harness, Claude Code, …).
|
||||||
|
|
||||||
|
Backend: `https://search.arka-ai.ru` (Arka ops) — self-hosted SearXNG behind an
|
||||||
|
authenticated gateway that resolves `ARKA_API_KEY → billing account`, applies
|
||||||
|
per-account rate limits, and runs an SSRF-guarded reader.
|
||||||
|
|
||||||
|
Agent Arka itself does **not** need this shim — it talks to the gateway directly
|
||||||
|
via the built-in `http_compat` MCP transport. See the setup doc.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Node.js ≥ 18 (uses global `fetch`).
|
||||||
|
- An Arka API key in `ARKA_API_KEY` (the key Agent Arka stores for inference;
|
||||||
|
obtained via SSO / trial provisioning).
|
||||||
|
|
||||||
|
## Environment
|
||||||
|
|
||||||
|
| Variable | Default | Meaning |
|
||||||
|
|---|---|---|
|
||||||
|
| `ARKA_API_KEY` | — (**required**) | Arka API key; sent as `X-Api-Key`. |
|
||||||
|
| `ARKA_SEARCH_URL` | `https://search.arka-ai.ru` | Gateway base URL. |
|
||||||
|
| `ARKA_SEARCH_UA` | `arka-search-mcp/1.0` | User-Agent. |
|
||||||
|
|
||||||
|
## Tools
|
||||||
|
|
||||||
|
| Tool | Arguments | Returns |
|
||||||
|
|---|---|---|
|
||||||
|
| `web_search` | `q` (required), `language`, `categories`, `pageno`, `time_range` | SearXNG JSON `{ query, results: [{ title, url, content, engine }] }` |
|
||||||
|
| `web_fetch` | `url` (required) | `{ title, content (Markdown), url, final_url, content_type, bytes, truncated }` |
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://git.arka-ai.ru/arka/public.git
|
||||||
|
# or copy just this directory
|
||||||
|
# server: /path/to/arka-search-mcp/server.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Zero dependencies — run it directly with `node server.js`.
|
||||||
|
|
||||||
|
## Manual smoke test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
printf '%s\n' \
|
||||||
|
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18"}}' \
|
||||||
|
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
|
||||||
|
'{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"web_search","arguments":{"q":"Arka AI"}}}' \
|
||||||
|
| ARKA_API_KEY="$ARKA_API_KEY" node server.js
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "arka-search-mcp",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"description": "MCP stdio server exposing Arka web search + fetch (https://search.arka-ai.ru) to any MCP-capable agent harness.",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"arka-search-mcp": "server.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const readline = require('readline');
|
||||||
|
|
||||||
|
const BASE = (process.env.ARKA_SEARCH_URL || 'https://search.arka-ai.ru').replace(/\/+$/, '');
|
||||||
|
const KEY = process.env.ARKA_API_KEY || process.env.ARKA_SEARCH_TOKEN || '';
|
||||||
|
const UA = process.env.ARKA_SEARCH_UA || 'arka-search-mcp/1.0';
|
||||||
|
|
||||||
|
const DEFAULT_PROTOCOL = '2025-06-18';
|
||||||
|
|
||||||
|
const TOOLS = [
|
||||||
|
{
|
||||||
|
name: 'web_search',
|
||||||
|
description:
|
||||||
|
'Search the web via Arka (self-hosted SearXNG). Returns ranked results with title, url and snippet.',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
q: { type: 'string', description: 'Search query' },
|
||||||
|
language: { type: 'string', description: 'Language hint, e.g. ru, en' },
|
||||||
|
categories: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'general, news, images, it, science, ...',
|
||||||
|
},
|
||||||
|
pageno: { type: 'integer', description: '1-based page number' },
|
||||||
|
time_range: { type: 'string', description: 'day | week | month | year' },
|
||||||
|
},
|
||||||
|
required: ['q'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'web_fetch',
|
||||||
|
description:
|
||||||
|
'Fetch a URL through Arka and return its readable content as Markdown (SSRF-guarded).',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
url: { type: 'string', description: 'Absolute http(s) URL' },
|
||||||
|
},
|
||||||
|
required: ['url'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function send(msg) {
|
||||||
|
process.stdout.write(JSON.stringify(msg) + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function reply(id, result) {
|
||||||
|
send({ jsonrpc: '2.0', id, result });
|
||||||
|
}
|
||||||
|
|
||||||
|
function replyError(id, code, message) {
|
||||||
|
send({ jsonrpc: '2.0', id, error: { code, message } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function callGateway(path, params) {
|
||||||
|
if (!KEY) {
|
||||||
|
throw new Error('ARKA_API_KEY is not set in the server environment');
|
||||||
|
}
|
||||||
|
const url = new URL(BASE + path);
|
||||||
|
for (const [k, v] of Object.entries(params)) {
|
||||||
|
if (v !== undefined && v !== null && v !== '') url.searchParams.set(k, String(v));
|
||||||
|
}
|
||||||
|
const res = await fetch(url, {
|
||||||
|
headers: {
|
||||||
|
'x-api-key': KEY,
|
||||||
|
accept: 'application/json',
|
||||||
|
'user-agent': UA,
|
||||||
|
},
|
||||||
|
signal: AbortSignal.timeout(25000),
|
||||||
|
});
|
||||||
|
const text = await res.text();
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Arka search ${res.status}: ${text.slice(0, 400)}`);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function callTool(name, args) {
|
||||||
|
if (name === 'web_search') {
|
||||||
|
return callGateway('/search', {
|
||||||
|
q: args.q,
|
||||||
|
language: args.language,
|
||||||
|
categories: args.categories,
|
||||||
|
pageno: args.pageno,
|
||||||
|
time_range: args.time_range,
|
||||||
|
format: 'json',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (name === 'web_fetch') {
|
||||||
|
return callGateway('/fetch', { url: args.url });
|
||||||
|
}
|
||||||
|
throw new Error('Unknown tool: ' + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handle(msg) {
|
||||||
|
const id = msg.id;
|
||||||
|
const method = msg.method;
|
||||||
|
|
||||||
|
if (method === 'initialize') {
|
||||||
|
const requested = msg.params && msg.params.protocolVersion;
|
||||||
|
reply(id, {
|
||||||
|
protocolVersion: requested || DEFAULT_PROTOCOL,
|
||||||
|
capabilities: { tools: { listChanged: false } },
|
||||||
|
serverInfo: { name: 'arka-search', version: '1.0.0' },
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof method === 'string' && method.startsWith('notifications/')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method === 'ping') {
|
||||||
|
reply(id, {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method === 'tools/list') {
|
||||||
|
reply(id, { tools: TOOLS });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method === 'tools/call') {
|
||||||
|
const name = msg.params && msg.params.name;
|
||||||
|
const args = (msg.params && msg.params.arguments) || {};
|
||||||
|
try {
|
||||||
|
const text = await callTool(name, args);
|
||||||
|
reply(id, { content: [{ type: 'text', text }] });
|
||||||
|
} catch (err) {
|
||||||
|
reply(id, {
|
||||||
|
content: [{ type: 'text', text: String((err && err.message) || err) }],
|
||||||
|
isError: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id !== undefined && id !== null) {
|
||||||
|
replyError(id, -32601, 'Method not found: ' + method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rl = readline.createInterface({ input: process.stdin });
|
||||||
|
rl.on('line', (line) => {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (!trimmed) return;
|
||||||
|
let msg;
|
||||||
|
try {
|
||||||
|
msg = JSON.parse(trimmed);
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handle(msg).catch((err) => {
|
||||||
|
if (msg && msg.id !== undefined && msg.id !== null) {
|
||||||
|
replyError(msg.id, -32603, String((err && err.message) || err));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# Multica fork CLI (Arka)
|
||||||
|
|
||||||
|
Кастомный билд CLI Multica от Arka: поддержка **agent-arka** runtime (провайдер
|
||||||
|
`agent-arka` на `plan.arka-ai.ru`), Arka SSO, русская локализация. Скачивается
|
||||||
|
из публичных релизов этого репозитория; токен не нужен.
|
||||||
|
|
||||||
|
## Установка
|
||||||
|
|
||||||
|
macOS / Linux / WSL:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows (PowerShell):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
irm https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.ps1 | iex
|
||||||
|
```
|
||||||
|
|
||||||
|
Бинарь ставится в `/usr/local/bin` (или `~/.local/bin`), на Windows — в
|
||||||
|
`~\.multica\bin`, и добавляется в `PATH`.
|
||||||
|
|
||||||
|
## Подключение к серверу
|
||||||
|
|
||||||
|
```bash
|
||||||
|
multica setup self-host \
|
||||||
|
--server-url https://plan.arka-ai.ru \
|
||||||
|
--app-url https://plan.arka-ai.ru
|
||||||
|
```
|
||||||
|
|
||||||
|
Команда настроит CLI, откроет браузер для входа и запустит daemon.
|
||||||
|
|
||||||
|
## Проверка
|
||||||
|
|
||||||
|
```bash
|
||||||
|
multica version # 0.6.2-arka
|
||||||
|
multica daemon status # running; агенты включают agent-arka
|
||||||
|
```
|
||||||
|
|
||||||
|
Проверить, что бинарь умеет agent-arka:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
multica daemon probe-runtimes
|
||||||
|
# provider_summary должен содержать "agent-arka"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Пин версии
|
||||||
|
|
||||||
|
```bash
|
||||||
|
MULTICA_VERSION=0.6.2-arka curl -fsSL .../multica/install.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
## Релизы
|
||||||
|
|
||||||
|
Бинари публикуются в [релизах](https://git.arka-ai.ru/arka/public/releases/tag/multica-v0.6.2-arka):
|
||||||
|
`multica-cli-<version>-linux-{amd64,arm64}.tar.gz`,
|
||||||
|
`multica-cli-<version>-darwin-{amd64,arm64}.tar.gz`,
|
||||||
|
`multica-cli-<version>-windows-amd64.zip`, `checksums.txt`.
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
# Multica fork CLI — Windows installer
|
||||||
|
#
|
||||||
|
# Installs the fork-built `multica.exe` CLI (with agent-arka runtime support,
|
||||||
|
# Arka SSO, Russian i18n) from arka/public releases.
|
||||||
|
#
|
||||||
|
# irm https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.ps1 | iex
|
||||||
|
#
|
||||||
|
# Environment:
|
||||||
|
# $env:MULTICA_VERSION pin a release (e.g. 0.6.1-arka). Default: newest multica-v* on git.arka-ai.ru/arka/public
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
$PublicApi = if ($env:MULTICA_PUBLIC_API) { $env:MULTICA_PUBLIC_API } else { "https://git.arka-ai.ru/api/v1" }
|
||||||
|
$PublicDl = if ($env:MULTICA_PUBLIC_DL) { $env:MULTICA_PUBLIC_DL } else { "https://git.arka-ai.ru/arka/public/releases/download" }
|
||||||
|
$Repo = "arka/public"
|
||||||
|
$TagPrefix = "multica-v"
|
||||||
|
|
||||||
|
$BinDir = Join-Path $env:USERPROFILE ".multica\bin"
|
||||||
|
|
||||||
|
function Write-Info { Write-Host "==> $args" -ForegroundColor Cyan }
|
||||||
|
function Write-Ok { Write-Host "OK $args" -ForegroundColor Green }
|
||||||
|
function Write-Warn { Write-Host "WARN $args" -ForegroundColor Yellow }
|
||||||
|
function Write-Fail { Write-Host "FAIL $args" -ForegroundColor Red; exit 1 }
|
||||||
|
|
||||||
|
function Get-WindowsCliArch {
|
||||||
|
$arch = $env:PROCESSOR_ARCHITECTURE
|
||||||
|
if ($arch -eq "AMD64" -or $arch -eq "x86_64") { return "amd64" }
|
||||||
|
if ($arch -eq "ARM64") { return "arm64" }
|
||||||
|
Write-Fail "Unsupported architecture: $arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-LatestMulticaVersion {
|
||||||
|
$url = "$PublicApi/repos/$Repo/releases?limit=50"
|
||||||
|
try {
|
||||||
|
$releases = Invoke-RestMethod -Uri $url -UseBasicParsing -ErrorAction Stop
|
||||||
|
} catch {
|
||||||
|
Write-Fail "Cannot list releases at $url : $_"
|
||||||
|
}
|
||||||
|
$tags = $releases | Where-Object { $_.tag_name -like "$TagPrefix*" } | ForEach-Object { $_.tag_name }
|
||||||
|
if (-not $tags) { Write-Fail "No ${TagPrefix}* releases on $Repo yet" }
|
||||||
|
$latest = $tags | Sort-Object -Descending | Select-Object -First 1
|
||||||
|
return $latest.Substring($TagPrefix.Length)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Add-ToUserPath {
|
||||||
|
param([string]$Dir)
|
||||||
|
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
if ($currentPath -and $currentPath.Split(";") -contains $Dir) { return }
|
||||||
|
$newPath = if ($currentPath) { "$currentPath;$Dir" } else { $Dir }
|
||||||
|
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
|
||||||
|
if ($env:Path -notlike "*$Dir*") {
|
||||||
|
$env:Path = "$Dir;$env:Path"
|
||||||
|
}
|
||||||
|
Write-Ok "Added $Dir to user PATH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not [Environment]::Is64BitOperatingSystem) {
|
||||||
|
Write-Fail "Multica requires a 64-bit Windows installation."
|
||||||
|
}
|
||||||
|
|
||||||
|
$arch = Get-WindowsCliArch
|
||||||
|
|
||||||
|
$version = if ($env:MULTICA_VERSION) { $env:MULTICA_VERSION.TrimStart("v").TrimStart($TagPrefix) } else { Get-LatestMulticaVersion }
|
||||||
|
Write-Info "Installing Multica fork CLI ${version} (windows-$arch)..."
|
||||||
|
|
||||||
|
$asset = "multica-cli-$version-windows-$arch.zip"
|
||||||
|
$url = "$PublicDl/$TagPrefix$version/$asset"
|
||||||
|
$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) "multica-install"
|
||||||
|
|
||||||
|
if (Test-Path $tmpDir) { Remove-Item $tmpDir -Recurse -Force }
|
||||||
|
New-Item -ItemType Directory -Path $tmpDir | Out-Null
|
||||||
|
|
||||||
|
Write-Info "Downloading $url ..."
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $url -OutFile (Join-Path $tmpDir "multica.zip") -UseBasicParsing
|
||||||
|
} catch {
|
||||||
|
Remove-Item $tmpDir -Recurse -Force
|
||||||
|
Write-Fail "Failed to download CLI binary: $_"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Verify SHA256 checksum
|
||||||
|
$checksumUrl = "$PublicDl/$TagPrefix$version/checksums.txt"
|
||||||
|
try {
|
||||||
|
$checksums = Invoke-WebRequest -Uri $checksumUrl -UseBasicParsing -ErrorAction Stop
|
||||||
|
$checksumContent = if ($checksums.Content -is [byte[]]) {
|
||||||
|
[System.Text.Encoding]::UTF8.GetString($checksums.Content)
|
||||||
|
} else {
|
||||||
|
[string]$checksums.Content
|
||||||
|
}
|
||||||
|
$zipFile = Join-Path $tmpDir "multica.zip"
|
||||||
|
$actualHash = (Get-FileHash -Path $zipFile -Algorithm SHA256).Hash.ToLower()
|
||||||
|
$expectedLine = ($checksumContent -split "`r?`n") | Where-Object { $_ -match [regex]::Escape($asset) } | Select-Object -First 1
|
||||||
|
if ($expectedLine) {
|
||||||
|
$expectedHash = ($expectedLine -split "\s+")[0].ToLower()
|
||||||
|
if ($actualHash -ne $expectedHash) {
|
||||||
|
Remove-Item $tmpDir -Recurse -Force
|
||||||
|
Write-Fail "Checksum verification failed. Expected: $expectedHash, Got: $actualHash"
|
||||||
|
}
|
||||||
|
Write-Ok "Checksum verified"
|
||||||
|
} else {
|
||||||
|
Write-Warn "Could not find checksum entry for $asset - skipping verification."
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Warn "Could not download checksums.txt - skipping verification."
|
||||||
|
}
|
||||||
|
|
||||||
|
Expand-Archive -Path (Join-Path $tmpDir "multica.zip") -DestinationPath $tmpDir -Force
|
||||||
|
|
||||||
|
if (-not (Test-Path $BinDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
$exeSrc = Join-Path $tmpDir "multica.exe"
|
||||||
|
if (-not (Test-Path $exeSrc)) {
|
||||||
|
$exeSrc = Get-ChildItem -Path $tmpDir -Filter "multica.exe" -Recurse | Select-Object -First 1 -ExpandProperty FullName
|
||||||
|
}
|
||||||
|
if (-not $exeSrc -or -not (Test-Path $exeSrc)) {
|
||||||
|
Remove-Item $tmpDir -Recurse -Force
|
||||||
|
Write-Fail "multica.exe not found in downloaded archive."
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item $exeSrc (Join-Path $BinDir "multica.exe") -Force
|
||||||
|
Remove-Item $tmpDir -Recurse -Force
|
||||||
|
|
||||||
|
Add-ToUserPath $BinDir
|
||||||
|
Write-Ok "Multica CLI installed to $BinDir\multica.exe"
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " Next — connect to your Multica server:"
|
||||||
|
Write-Host " multica setup self-host"
|
||||||
|
Write-Host " Or for this instance:"
|
||||||
|
Write-Host " multica setup self-host --server-url https://plan.arka-ai.ru --app-url https://plan.arka-ai.ru"
|
||||||
|
Write-Host ""
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Multica fork CLI — installer (Linux / macOS / WSL).
|
||||||
|
#
|
||||||
|
# Installs the fork-built `multica` CLI (with agent-arka runtime support, Arka
|
||||||
|
# SSO, Russian i18n) from arka/public releases.
|
||||||
|
#
|
||||||
|
# curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.sh | bash
|
||||||
|
#
|
||||||
|
# Environment:
|
||||||
|
# MULTICA_VERSION pin a release (e.g. 0.6.1-arka). Default: newest multica-v* on git.arka-ai.ru/arka/public
|
||||||
|
# MULTICA_BIN_DIR install dir (default: /usr/local/bin, else ~/.local/bin)
|
||||||
|
# NO_COLOR 1 to disable color output
|
||||||
|
|
||||||
|
if [ -z "${BASH_VERSION:-}" ]; then
|
||||||
|
echo "The Multica installer needs bash. Run:" >&2
|
||||||
|
echo " curl -fsSL https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.sh | bash" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PUBLIC_API="${MULTICA_PUBLIC_API:-https://git.arka-ai.ru/api/v1}"
|
||||||
|
PUBLIC_DL="${MULTICA_PUBLIC_DL:-https://git.arka-ai.ru/arka/public/releases/download}"
|
||||||
|
REPO="arka/public"
|
||||||
|
TAG_PREFIX="multica-v"
|
||||||
|
|
||||||
|
if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then
|
||||||
|
C_GREEN=$'\033[32m'; C_YELLOW=$'\033[33m'; C_RED=$'\033[31m'; C_BOLD=$'\033[1m'; C_RESET=$'\033[0m'
|
||||||
|
else
|
||||||
|
C_GREEN=''; C_YELLOW=''; C_RED=''; C_BOLD=''; C_RESET=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
info() { printf '%s\n' "$*"; }
|
||||||
|
ok() { printf '%s✓%s %s\n' "$C_GREEN" "$C_RESET" "$*"; }
|
||||||
|
warn() { printf '%s⚠%s %s\n' "$C_YELLOW" "$C_RESET" "$*"; }
|
||||||
|
die() { printf '%s✗%s %s\n' "$C_RED" "$C_RESET" "$*" >&2; exit 1; }
|
||||||
|
|
||||||
|
_mc_tmp=""
|
||||||
|
cleanup() { [[ -n "${_mc_tmp:-}" ]] && rm -rf "$_mc_tmp"; }
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
detect_platform() {
|
||||||
|
local os arch
|
||||||
|
os=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
arch=$(uname -m)
|
||||||
|
case "$arch" in
|
||||||
|
x86_64|amd64) arch="amd64" ;;
|
||||||
|
aarch64|arm64) arch="arm64" ;;
|
||||||
|
*) die "Unsupported architecture: $arch" ;;
|
||||||
|
esac
|
||||||
|
case "$os" in
|
||||||
|
linux) PLATFORM="linux-${arch}" ;;
|
||||||
|
darwin) PLATFORM="darwin-${arch}" ;;
|
||||||
|
mingw*|msys*|cygwin*)
|
||||||
|
die "This curl installer is for Linux/macOS/WSL. On Windows run the PowerShell installer instead:"$'\n'" irm https://git.arka-ai.ru/arka/public/raw/branch/main/multica/install.ps1 | iex"
|
||||||
|
;;
|
||||||
|
*) die "Unsupported OS: $os" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch_latest_version() {
|
||||||
|
local json tags
|
||||||
|
json=$(curl -fsSL "${PUBLIC_API}/repos/${REPO}/releases?limit=50") || die "Cannot list releases at ${PUBLIC_API}/repos/${REPO}/releases"
|
||||||
|
tags=$(printf '%s' "$json" | grep -oE '"tag_name":[[:space:]]*"'"${TAG_PREFIX}"'[^"]+"' | sed 's/.*"'"${TAG_PREFIX}"'//;s/"$//' || true)
|
||||||
|
if [[ -z "$tags" ]]; then
|
||||||
|
die "No ${TAG_PREFIX}* releases on ${REPO} yet"
|
||||||
|
fi
|
||||||
|
printf '%s\n' "$tags" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
sha256_file() {
|
||||||
|
if command -v sha256sum >/dev/null 2>&1; then
|
||||||
|
sha256sum "$1" | awk '{print $1}'
|
||||||
|
elif command -v shasum >/dev/null 2>&1; then
|
||||||
|
shasum -a 256 "$1" | awk '{print $1}'
|
||||||
|
else
|
||||||
|
die "Need sha256sum or shasum"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_path() {
|
||||||
|
local bindir="$1"
|
||||||
|
case ":$PATH:" in
|
||||||
|
*":${bindir}:"*) return 0 ;;
|
||||||
|
esac
|
||||||
|
local line="export PATH=\"${bindir}:\$PATH\""
|
||||||
|
local rc
|
||||||
|
for rc in "${HOME}/.zprofile" "${HOME}/.zshrc" "${HOME}/.bash_profile" "${HOME}/.bashrc" "${HOME}/.profile"; do
|
||||||
|
[[ -f "$rc" ]] || continue
|
||||||
|
if grep -Fqs "$bindir" "$rc"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ -n "${SHELL:-}" && "${SHELL}" == *zsh* ]]; then
|
||||||
|
rc="${HOME}/.zshrc"
|
||||||
|
else
|
||||||
|
rc="${HOME}/.bashrc"
|
||||||
|
[[ -f "$rc" ]] || rc="${HOME}/.profile"
|
||||||
|
fi
|
||||||
|
printf '\n# Multica CLI\n%s\n' "$line" >>"$rc"
|
||||||
|
warn "Added ${bindir} to PATH in ${rc} (open a new shell, or: source ${rc})"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
printf '%s\n' "${C_BOLD}Multica${C_RESET} — fork CLI installer (agent-arka support)"
|
||||||
|
command -v curl >/dev/null 2>&1 || die "curl is required"
|
||||||
|
command -v tar >/dev/null 2>&1 || die "tar is required"
|
||||||
|
|
||||||
|
detect_platform
|
||||||
|
|
||||||
|
local version
|
||||||
|
if [[ -n "${MULTICA_VERSION:-}" ]]; then
|
||||||
|
version="${MULTICA_VERSION#v}"
|
||||||
|
version="${version#multica-v}"
|
||||||
|
info "Using pinned version ${version}"
|
||||||
|
else
|
||||||
|
info "Resolving latest Multica release…"
|
||||||
|
version=$(fetch_latest_version)
|
||||||
|
info "Latest: ${version}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local asset="multica-cli-${version}-${PLATFORM}.tar.gz"
|
||||||
|
local url="${PUBLIC_DL}/${TAG_PREFIX}${version}/${asset}"
|
||||||
|
|
||||||
|
_mc_tmp=$(mktemp -d)
|
||||||
|
info "Downloading ${url} ..."
|
||||||
|
curl -fsSL "$url" -o "$_mc_tmp/multica.tar.gz" || die "Failed to download ${asset}"
|
||||||
|
|
||||||
|
info "Verifying checksum …"
|
||||||
|
local expected actual
|
||||||
|
expected=$(curl -fsSL "${PUBLIC_DL}/${TAG_PREFIX}${version}/checksums.txt" | awk -v a="$asset" '$2==a {print $1; exit}' 2>/dev/null || true)
|
||||||
|
actual=$(sha256_file "$_mc_tmp/multica.tar.gz")
|
||||||
|
if [[ -n "$expected" ]]; then
|
||||||
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
die "Checksum mismatch for ${asset}: expected ${expected}, got ${actual}"
|
||||||
|
fi
|
||||||
|
ok "Checksum verified"
|
||||||
|
else
|
||||||
|
warn "No checksum entry for ${asset}; skipping verification"
|
||||||
|
fi
|
||||||
|
|
||||||
|
tar -xzf "$_mc_tmp/multica.tar.gz" -C "$_mc_tmp" multica || die "Failed to extract multica"
|
||||||
|
|
||||||
|
local bindir
|
||||||
|
if [[ -n "${MULTICA_BIN_DIR:-}" ]]; then
|
||||||
|
bindir="${MULTICA_BIN_DIR}"
|
||||||
|
elif [[ -w /usr/local/bin ]]; then
|
||||||
|
bindir="/usr/local/bin"
|
||||||
|
elif command -v sudo >/dev/null 2>&1; then
|
||||||
|
bindir="/usr/local/bin"
|
||||||
|
else
|
||||||
|
bindir="${HOME}/.local/bin"
|
||||||
|
fi
|
||||||
|
mkdir -p "$bindir"
|
||||||
|
|
||||||
|
if [[ ! -w "$bindir" ]]; then
|
||||||
|
sudo mv "$_mc_tmp/multica" "$bindir/multica" || die "Cannot write to ${bindir}"
|
||||||
|
else
|
||||||
|
mv "$_mc_tmp/multica" "$bindir/multica"
|
||||||
|
fi
|
||||||
|
chmod +x "$bindir/multica"
|
||||||
|
ensure_path "$bindir"
|
||||||
|
|
||||||
|
ok "Multica CLI ${version} installed to ${bindir}/multica"
|
||||||
|
rm -rf "$_mc_tmp"; _mc_tmp=""
|
||||||
|
|
||||||
|
printf '\n'
|
||||||
|
printf ' Next — connect to your Multica server:\n'
|
||||||
|
printf ' multica setup self-host\n'
|
||||||
|
printf ' Or for this instance:\n'
|
||||||
|
printf ' multica setup self-host --server-url https://plan.arka-ai.ru --app-url https://plan.arka-ai.ru\n'
|
||||||
|
printf '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
+26
-5
@@ -6,7 +6,18 @@ Arka AI — OpenAI-совместимый API (`https://api.arka-ai.ru/v1`). В
|
|||||||
|
|
||||||
Нужен [API-ключ Arka AI](https://arka-ai.ru/docs/account/api-keys). Секрет ключа показывается **один раз** при создании.
|
Нужен [API-ключ Arka AI](https://arka-ai.ru/docs/account/api-keys). Секрет ключа показывается **один раз** при создании.
|
||||||
|
|
||||||
Плагин один и тот же для **терминала (CLI)** и **OpenCode Desktop** (окно + тот же sidecar). Меняется только способ запуска установщика и то, как в процесс попадает ключ.
|
Один установщик работает для **терминала (CLI)** и **OpenCode Desktop** (окно + тот же sidecar). Меняется только способ запуска установщика и то, как в процесс попадает ключ.
|
||||||
|
|
||||||
|
## Поколения OpenCode (1.x и 2.x)
|
||||||
|
|
||||||
|
OpenCode 2.x сменил API плагинов: старый плагин провайдера в 2.x **не загружается**. Поэтому установщик сам определяет поколение (`opencode --version`) и ставит нужный механизм:
|
||||||
|
|
||||||
|
| OpenCode | Где живёт провайдер | Список моделей |
|
||||||
|
|---|---|---|
|
||||||
|
| **1.x** | плагин `plugins/arka-ai.ts` (инжектит провайдера через `config`-хук) | динамический (публичный каталог, кэш 24 ч) |
|
||||||
|
| **2.x** | статический блок `providers["Arka-AI"]` в `opencode.jsonc` | статический (обновляется `--refresh`) |
|
||||||
|
|
||||||
|
Определить вручную: `opencode --version` печатает `1.x.y` на 1.x и `opencode v2.x.y` на 2.x. Принудительно: `--gen 1` / `--gen 2` (или `OPENCODE_GEN=1|2`). Если `opencode` ещё не установлен — по умолчанию ставится вариант для 2.x.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -127,7 +138,8 @@ powershell -ExecutionPolicy Bypass -Command "iwr -useb https://git.arka-ai.ru/ar
|
|||||||
|
|
||||||
| Куда | Что |
|
| Куда | Что |
|
||||||
|------|-----|
|
|------|-----|
|
||||||
| `~/.config/opencode/plugins/arka-ai.ts` (Windows: `%USERPROFILE%\.config\opencode\plugins\arka-ai.ts`) | Плагин провайдера **Arka-AI** |
|
| `~/.config/opencode/plugins/arka-ai.ts` (Windows: `%USERPROFILE%\.config\opencode\plugins\arka-ai.ts`) | Плагин провайдера **Arka-AI** — **только OpenCode 1.x** |
|
||||||
|
| `~/.config/opencode/opencode.jsonc` → `providers["Arka-AI"]` | Провайдер **Arka-AI** — **OpenCode 2.x** (статические модели + `baseURL` + ключ; плагин не нужен) |
|
||||||
| `…/skills/arka-provider/SKILL.md` | Skill: как обновить каталог и сменить модель |
|
| `…/skills/arka-provider/SKILL.md` | Skill: как обновить каталог и сменить модель |
|
||||||
| `…/.arka-api-key` | Ключ для CLI и Desktop (GUI без login-shell) |
|
| `…/.arka-api-key` | Ключ для CLI и Desktop (GUI без login-shell) |
|
||||||
| `~/.bashrc` / `.zshrc` / `.profile` | `export ARKA_API_KEY=…` (только POSIX-установщик) |
|
| `~/.bashrc` / `.zshrc` / `.profile` | `export ARKA_API_KEY=…` (только POSIX-установщик) |
|
||||||
@@ -162,6 +174,14 @@ powershell -ExecutionPolicy Bypass -Command "iwr -useb https://git.arka-ai.ru/ar
|
|||||||
|
|
||||||
## Обновить каталог
|
## Обновить каталог
|
||||||
|
|
||||||
|
**OpenCode 2.x** (статический список): перегенерировать модели из каталога, ничего больше не трогая:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash install-arka-provider.sh --refresh
|
||||||
|
```
|
||||||
|
|
||||||
|
**OpenCode 1.x** (динамический каталог): сбросить кэш —
|
||||||
|
|
||||||
macOS / Linux:
|
macOS / Linux:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -196,6 +216,7 @@ curl -sS https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.jso
|
|||||||
| Модели есть, запросы 401 | Файл `.arka-api-key`; на Windows — User env и трей; Desktop не читает bashrc |
|
| Модели есть, запросы 401 | Файл `.arka-api-key`; на Windows — User env и трей; Desktop не читает bashrc |
|
||||||
| Каталог не меняется | Удалить кэш `arka-ai-models.json` и рестарт |
|
| Каталог не меняется | Удалить кэш `arka-ai-models.json` и рестарт |
|
||||||
| Ошибка импорта плагина | Снова запустить установщик |
|
| Ошибка импорта плагина | Снова запустить установщик |
|
||||||
|
| В логе `failed to load plugin … arka-ai.ts` (OpenCode 2.x) | Плагин 1.x несовместим с 2.x; запустить установщик ещё раз (на 2.x он отключит плагин и запишет `providers["Arka-AI"]`) |
|
||||||
| `curl` / `irm` отдаёт HTML | Нужен путь `/raw/branch/main/…`, не страница репозитория |
|
| `curl` / `irm` отдаёт HTML | Нужен путь `/raw/branch/main/…`, не страница репозитория |
|
||||||
| Поставили в WSL, Desktop пустой | Native Windows Desktop смотрит в `%USERPROFILE%\.config\opencode`, не в home WSL — ставьте `.ps1` |
|
| Поставили в WSL, Desktop пустой | Native Windows Desktop смотрит в `%USERPROFILE%\.config\opencode`, не в home WSL — ставьте `.ps1` |
|
||||||
| Плагин в `%APPDATA%\opencode`, эффекта нет | Нужен `%USERPROFILE%\.config\opencode` |
|
| Плагин в `%APPDATA%\opencode`, эффекта нет | Нужен `%USERPROFILE%\.config\opencode` |
|
||||||
@@ -206,9 +227,9 @@ curl -sS https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.jso
|
|||||||
|
|
||||||
| Файл | Назначение |
|
| Файл | Назначение |
|
||||||
|------|------------|
|
|------|------------|
|
||||||
| `install-arka-provider.sh` | Установщик для macOS, Linux, WSL, Git Bash |
|
| `install-arka-provider.sh` | Установщик для macOS, Linux, WSL, Git Bash (определяет поколение opencode) |
|
||||||
| `install-arka-provider.ps1` | Установщик для Windows (CLI и Desktop) |
|
| `install-arka-provider.ps1` | Установщик для Windows (CLI и Desktop; определяет поколение) |
|
||||||
| `plugins/arka-ai.ts` | Исходник плагина (встроен в оба установщика) |
|
| `plugins/arka-ai.ts` | Исходник плагина провайдера — **OpenCode 1.x** (встроен в установщики) |
|
||||||
| `skills/arka-provider/SKILL.md` | Исходник skill (встроен в оба установщика) |
|
| `skills/arka-provider/SKILL.md` | Исходник skill (встроен в оба установщика) |
|
||||||
| `catalog.json` | Каталог чат-моделей, обновляется ежедневно в 05:00 по Москве |
|
| `catalog.json` | Каталог чат-моделей, обновляется ежедневно в 05:00 по Москве |
|
||||||
| `README.md` | Эта страница — можно копировать в раздел «агентные помощники» на arka-ai.ru |
|
| `README.md` | Эта страница — можно копировать в раздел «агентные помощники» на arka-ai.ru |
|
||||||
|
|||||||
+65
-37
@@ -1,14 +1,22 @@
|
|||||||
{
|
{
|
||||||
"updated_at": "2026-09-29T23:00:01Z",
|
"updated_at": "2026-11-04T23:00:01Z",
|
||||||
"source": "https://api.arka-ai.ru/v1/models",
|
"source": "https://api.arka-ai.ru/v1/models",
|
||||||
"raw_count": 216,
|
"raw_count": 224,
|
||||||
"chat_count": 110,
|
"chat_count": 117,
|
||||||
"object": "list",
|
"object": "list",
|
||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"id": "ACE-Step-v1-3.5B",
|
"id": "ACE-Step-v1-3.5B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "APUS-OpenJev-v1-4B",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "APUS-OpenJev-v1-9B",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "Align-DS-V",
|
"id": "Align-DS-V",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -18,17 +26,17 @@
|
|||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "Atria-dawn-cmy2-v1",
|
"id": "Atria-Dawn-Preview",
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Atria-dawn-v2",
|
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "AutoGLM-Phone-9B-Multilingual",
|
"id": "AutoGLM-Phone-9B-Multilingual",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "Bespoke-Nimble-9B",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "DeepSeek-Prover-V2-7B",
|
"id": "DeepSeek-Prover-V2-7B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -49,10 +57,6 @@
|
|||||||
"id": "DeepSeek-R1-Distill-Qwen-7B",
|
"id": "DeepSeek-R1-Distill-Qwen-7B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "DeepSeek-V3.2",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "DeepSeek-V4-Pro",
|
"id": "DeepSeek-V4-Pro",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -61,6 +65,10 @@
|
|||||||
"id": "DeepSeek-V4-Pro-0813",
|
"id": "DeepSeek-V4-Pro-0813",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "DeepSeek-V4.1-Flash-1017",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "DianJin-R1-32B",
|
"id": "DianJin-R1-32B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -93,10 +101,6 @@
|
|||||||
"id": "GLM-4-9B-0414",
|
"id": "GLM-4-9B-0414",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "GLM-4.7",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "GLM-5",
|
"id": "GLM-5",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -117,6 +121,10 @@
|
|||||||
"id": "GLM-5.3-Flash",
|
"id": "GLM-5.3-Flash",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "GigaAM-v3",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "HY-MT1.5-7B",
|
"id": "HY-MT1.5-7B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -149,6 +157,14 @@
|
|||||||
"id": "InfiniteTalk",
|
"id": "InfiniteTalk",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "Intern-Decision-4B",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "Intern-S2",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "InternVL2-8B",
|
"id": "InternVL2-8B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -202,7 +218,7 @@
|
|||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "MiniMax-M2.1",
|
"id": "MiniMax-H3",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -217,6 +233,10 @@
|
|||||||
"id": "MiniMax-M3",
|
"id": "MiniMax-M3",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "NeoHorse-Jev-4B",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "PDF-Extract-Kit-1.0",
|
"id": "PDF-Extract-Kit-1.0",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -273,38 +293,18 @@
|
|||||||
"id": "Qwen3-Coder-Next",
|
"id": "Qwen3-Coder-Next",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "Qwen3-Next-80B-A3B-Instruct",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "Qwen3-Next-80B-A3B-Thinking",
|
"id": "Qwen3-Next-80B-A3B-Thinking",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "Qwen3-VL-235B-A22B-Instruct",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "Qwen3-VL-235B-A22B-Thinking",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "Qwen3-VL-30B-A3B-Instruct",
|
"id": "Qwen3-VL-30B-A3B-Instruct",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "Qwen3-VL-32B-Instruct",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "Qwen3-VL-32B-Thinking",
|
"id": "Qwen3-VL-32B-Thinking",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"id": "Qwen3-VL-8B-Thinking",
|
|
||||||
"object": "model"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"id": "Qwen3.5-122B-A10B",
|
"id": "Qwen3.5-122B-A10B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -345,6 +345,10 @@
|
|||||||
"id": "Qwen3.7-Plus",
|
"id": "Qwen3.7-Plus",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "Qwen3.8-Omni-Flash",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "Qwen3Guard-Gen-0.6B",
|
"id": "Qwen3Guard-Gen-0.6B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -361,6 +365,10 @@
|
|||||||
"id": "SeedVR2-3B",
|
"id": "SeedVR2-3B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "SemIf-OpenJev-4B",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "Sinong1.0-32B",
|
"id": "Sinong1.0-32B",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -385,6 +393,10 @@
|
|||||||
"id": "deepseek-v4-flash-0731",
|
"id": "deepseek-v4-flash-0731",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "deepseek-v4.1-flash",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "gemma-4-26B-A4B-it",
|
"id": "gemma-4-26B-A4B-it",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -409,6 +421,10 @@
|
|||||||
"id": "kimi-k3",
|
"id": "kimi-k3",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "laya-multilingual",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "nonescape-v0",
|
"id": "nonescape-v0",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -417,6 +433,10 @@
|
|||||||
"id": "qwen-flash",
|
"id": "qwen-flash",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "qwen-max",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "qwen-plus-2025-12-01",
|
"id": "qwen-plus-2025-12-01",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
@@ -444,6 +464,14 @@
|
|||||||
{
|
{
|
||||||
"id": "qwen3.8-max-0902",
|
"id": "qwen3.8-max-0902",
|
||||||
"object": "model"
|
"object": "model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "tongyi-xiaomi-analysis-flash",
|
||||||
|
"object": "model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "tongyi-xiaomi-analysis-pro",
|
||||||
|
"object": "model"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# install-arka-provider.ps1 — OpenCode Arka-AI provider for Windows
|
# install-arka-provider.ps1 — OpenCode Arka-AI provider for Windows (CLI and
|
||||||
# (CLI and Desktop). Idempotent. Canonical files also live next to this script.
|
# Desktop). Idempotent. Detects the opencode generation:
|
||||||
|
# * 1.x -> installs the provider plugin (plugins\arka-ai.ts)
|
||||||
|
# * 2.x -> writes providers["Arka-AI"] into opencode.jsonc (no plugin; 2.x
|
||||||
|
# changed the plugin API, so the 1.x plugin no longer loads there)
|
||||||
#
|
#
|
||||||
# One-liner (PowerShell):
|
# One-liner (PowerShell):
|
||||||
# irm https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/install-arka-provider.ps1 | iex
|
# irm https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/install-arka-provider.ps1 | iex
|
||||||
@@ -8,16 +11,24 @@
|
|||||||
# iwr -useb URL -OutFile $env:TEMP\install-arka.ps1
|
# iwr -useb URL -OutFile $env:TEMP\install-arka.ps1
|
||||||
# powershell -ExecutionPolicy Bypass -File $env:TEMP\install-arka.ps1 -Key $env:ARKA_API_KEY -SetDefault DeepSeek-V4-Pro
|
# powershell -ExecutionPolicy Bypass -File $env:TEMP\install-arka.ps1 -Key $env:ARKA_API_KEY -SetDefault DeepSeek-V4-Pro
|
||||||
#
|
#
|
||||||
|
# Force a generation / refresh models:
|
||||||
|
# powershell -ExecutionPolicy Bypass -File install-arka-provider.ps1 -Gen 2
|
||||||
|
# powershell -ExecutionPolicy Bypass -File install-arka-provider.ps1 -Refresh
|
||||||
|
#
|
||||||
# cmd.exe:
|
# cmd.exe:
|
||||||
# powershell -NoProfile -ExecutionPolicy Bypass -Command "irm URL | iex"
|
# powershell -NoProfile -ExecutionPolicy Bypass -Command "irm URL | iex"
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[string]$Key,
|
[string]$Key,
|
||||||
[string]$SetDefault
|
[string]$SetDefault,
|
||||||
|
[ValidateSet('1','2')][string]$Gen,
|
||||||
|
[switch]$Refresh
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$CatalogUrl = 'https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json'
|
||||||
|
$ApiUrl = 'https://api.arka-ai.ru/v1'
|
||||||
if (-not $Key) { $Key = $env:ARKA_API_KEY }
|
if (-not $Key) { $Key = $env:ARKA_API_KEY }
|
||||||
|
|
||||||
function Get-ConfigDir {
|
function Get-ConfigDir {
|
||||||
@@ -36,11 +47,43 @@ function Get-InstallDirs {
|
|||||||
return $dirs
|
return $dirs
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $Key) {
|
function Get-Gen {
|
||||||
|
if ($Gen) { return $Gen }
|
||||||
|
if ($env:OPENCODE_GEN) { return $env:OPENCODE_GEN }
|
||||||
|
try {
|
||||||
|
$v = (& opencode --version 2>$null | Select-Object -First 1)
|
||||||
|
if ($v -match '(\d+)') {
|
||||||
|
if ([int]$Matches[1] -ge 2) { return '2' } else { return '1' }
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-CatalogIds {
|
||||||
|
try {
|
||||||
|
$cat = Invoke-RestMethod -Uri $CatalogUrl -TimeoutSec 25
|
||||||
|
return @($cat.data | ForEach-Object { $_.id } | Where-Object { $_ })
|
||||||
|
} catch {
|
||||||
|
try {
|
||||||
|
$m = Invoke-RestMethod -Uri "$ApiUrl/models" -TimeoutSec 25
|
||||||
|
return @($m.data | ForEach-Object { $_.id } | Where-Object { $_ })
|
||||||
|
} catch { return @() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$gen = Get-Gen
|
||||||
|
if (-not $gen) {
|
||||||
|
Write-Warning 'could not detect opencode version (opencode not on PATH?); defaulting to generation 2. Use -Gen 1 for opencode 1.x.'
|
||||||
|
$gen = '2'
|
||||||
|
}
|
||||||
|
Write-Host "==> opencode generation: $gen"
|
||||||
|
|
||||||
|
if (-not $Key -and -not $Refresh) {
|
||||||
$entered = Read-Host 'ARKA_API_KEY (leave blank to skip)'
|
$entered = Read-Host 'ARKA_API_KEY (leave blank to skip)'
|
||||||
if ($entered) { $Key = $entered }
|
if ($entered) { $Key = $entered }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --- embedded 1.x plugin ------------------------------------------------
|
||||||
$plugin = @'
|
$plugin = @'
|
||||||
import { homedir } from "node:os"
|
import { homedir } from "node:os"
|
||||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
||||||
@@ -79,7 +122,6 @@ function readApiKey(): string | undefined {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ids that must always be exposed, even if the filter would drop them.
|
|
||||||
const FORCED_MODELS = [
|
const FORCED_MODELS = [
|
||||||
"DeepSeek-V4-Pro",
|
"DeepSeek-V4-Pro",
|
||||||
"deepseek-v4-flash-0731",
|
"deepseek-v4-flash-0731",
|
||||||
@@ -89,9 +131,6 @@ const FORCED_MODELS = [
|
|||||||
"GLM-5.3",
|
"GLM-5.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
// Heuristic: drop non-chat models (TTS/ASR/image/video/OCR/embeddings/rerankers…)
|
|
||||||
// from the catalog so they don't clutter the /models picker.
|
|
||||||
// Keep in sync with scripts/sync-catalog.py
|
|
||||||
const NON_CHAT = new RegExp(
|
const NON_CHAT = new RegExp(
|
||||||
[
|
[
|
||||||
"tts", "asr", "audio", "speech", "voice", "whisper", "sensevoice",
|
"tts", "asr", "audio", "speech", "voice", "whisper", "sensevoice",
|
||||||
@@ -192,11 +231,6 @@ export default async function ArkaAIProviderPlugin() {
|
|||||||
cfg.provider ??= {}
|
cfg.provider ??= {}
|
||||||
const prev = cfg.provider[PROVIDER_ID] ?? {}
|
const prev = cfg.provider[PROVIDER_ID] ?? {}
|
||||||
|
|
||||||
// Static models from opencode.json act as a fallback; the fetched
|
|
||||||
// catalog is layered on top so the configured default model never
|
|
||||||
// disappears even if the catalog drops it.
|
|
||||||
// apiKey from env or ~/.config/opencode/.arka-api-key so Desktop /
|
|
||||||
// Windows GUI works without a login-shell export.
|
|
||||||
cfg.provider[PROVIDER_ID] = {
|
cfg.provider[PROVIDER_ID] = {
|
||||||
name: "Arka-AI",
|
name: "Arka-AI",
|
||||||
api: API_URL,
|
api: API_URL,
|
||||||
@@ -216,62 +250,42 @@ export default async function ArkaAIProviderPlugin() {
|
|||||||
$skill = @'
|
$skill = @'
|
||||||
---
|
---
|
||||||
name: arka-provider
|
name: arka-provider
|
||||||
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config. Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config (1.x and 2.x). Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Arka-AI provider
|
# Arka-AI provider
|
||||||
|
|
||||||
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
||||||
It is wired up locally with a plugin + a static `provider` block in
|
The mechanism depends on the opencode generation:
|
||||||
`~/.config/opencode/opencode.json`.
|
|
||||||
|
|
||||||
## How it works
|
| opencode | provider lives in | models |
|
||||||
|
|----------|-------------------|--------|
|
||||||
|
| **1.x** | plugin `~/.config/opencode/plugins/arka-ai.ts` (injects via the `config` hook) | dynamic (public catalog, cached 24h) |
|
||||||
|
| **2.x** | static `providers["Arka-AI"]` block in `opencode.jsonc` | static list (refresh via the installer) |
|
||||||
|
|
||||||
- Plugin: `~/.config/opencode/plugins/arka-ai.ts`
|
`opencode --version` prints `1.x.y` on 1.x and `opencode v2.x.y` on 2.x. The
|
||||||
- On startup it loads the published chat catalog
|
installer detects this. (2.x changed the plugin API: a 1.x plugin no longer
|
||||||
`https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json`
|
loads, so the static block is used and the stale plugin is disabled.)
|
||||||
(no API key; refreshed daily at 05:00 Europe/Moscow).
|
|
||||||
- If that fetch fails, it falls back to `https://api.arka-ai.ru/v1/models`
|
|
||||||
and filters out non-chat models (TTS/ASR/image/video/OCR/embedding/reranker/…)
|
|
||||||
via a heuristic regex so the `/models` picker stays clean.
|
|
||||||
- Caches the result at `~/.cache/opencode/arka-ai-models.json` (TTL 24h).
|
|
||||||
- Injects the provider into config via the `config` hook, layered over the
|
|
||||||
static block in `opencode.json`.
|
|
||||||
- Static block (`opencode.json` → `provider["Arka-AI"]`) holds
|
|
||||||
`name`, `api`, `env`, and a small fallback `models` map that is used when the
|
|
||||||
catalog is unreachable.
|
|
||||||
- Inference uses `ARKA_API_KEY` (env) or `~/.config/opencode/.arka-api-key`
|
|
||||||
(so OpenCode Desktop / Windows GUI works without a login shell).
|
|
||||||
|
|
||||||
## Refresh the model list
|
- 1.x: key from `ARKA_API_KEY` env or `~/.config/opencode/.arka-api-key`.
|
||||||
|
- 2.x: `providers["Arka-AI"]` with `package @opencode/ai/providers/openai-compatible`,
|
||||||
Catalog ~216 raw models / ~116 chat; the public snapshot updates at 05:00
|
`settings.baseURL https://api.arka-ai.ru/v1`, `settings.apiKey`, and a `models` map.
|
||||||
Europe/Moscow. Changes land in opencode only after cache expiry + restart
|
Refresh models: re-run the installer (`-Refresh` on Windows).
|
||||||
(config is not hot-reloaded).
|
|
||||||
|
|
||||||
1. `rm -f ~/.cache/opencode/arka-ai-models.json`
|
|
||||||
2. Restart opencode (or run `opencode` again) — the plugin re-fetches on the
|
|
||||||
next cold start.
|
|
||||||
|
|
||||||
Optionally inspect the live API (no key required for listing):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -sS https://api.arka-ai.ru/v1/models | python3 -m json.tool
|
|
||||||
curl -sS https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json | python3 -m json.tool
|
|
||||||
```
|
|
||||||
|
|
||||||
## Change default model
|
## Change default model
|
||||||
|
|
||||||
Edit `opencode.json` → `"model": "Arka-AI/<model-id>"`. Use the IDs exactly as
|
`"model": "Arka-AI/<model-id>"` in the config file (IDs exactly as in the catalog).
|
||||||
returned by the catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`,
|
|
||||||
`Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
|
||||||
|
|
||||||
## Adjust filtering
|
## Adjust filtering
|
||||||
|
|
||||||
Edit `NON_CHAT` (regex) or `FORCED_MODELS` in the plugin file **and** the same
|
`NON_CHAT` / `FORCED_MODELS` live in the 1.x plugin, the installer's 2.x
|
||||||
lists in `scripts/sync-catalog.py` in `arka/public`, then re-run the installer
|
generator, and `scripts/sync-catalog.py` — keep them in lockstep.
|
||||||
and restart. `FORCED_MODELS` keeps must-have chat models even if the heuristic
|
|
||||||
would drop them.
|
## Probing plan coverage
|
||||||
|
|
||||||
|
The public catalog lists every platform model, not your plan's allow-list.
|
||||||
|
Out-of-plan calls return `400 … does not support using vendor "arka"`. The
|
||||||
|
allow-list lives only in the admin console.
|
||||||
'@
|
'@
|
||||||
|
|
||||||
$dirs = Get-InstallDirs
|
$dirs = Get-InstallDirs
|
||||||
@@ -280,12 +294,9 @@ foreach ($conf in $dirs) {
|
|||||||
$skillDir = Join-Path $conf 'skills\arka-provider'
|
$skillDir = Join-Path $conf 'skills\arka-provider'
|
||||||
New-Item -ItemType Directory -Force -Path $pluginDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $pluginDir | Out-Null
|
||||||
New-Item -ItemType Directory -Force -Path $skillDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $skillDir | Out-Null
|
||||||
$pluginPath = Join-Path $pluginDir 'arka-ai.ts'
|
|
||||||
$skillPath = Join-Path $skillDir 'SKILL.md'
|
[System.IO.File]::WriteAllText((Join-Path $skillDir 'SKILL.md'), $skill.TrimStart() + "`n")
|
||||||
[System.IO.File]::WriteAllText($pluginPath, $plugin.TrimStart() + "`n")
|
Write-Host "==> skill $(Join-Path $skillDir 'SKILL.md')"
|
||||||
[System.IO.File]::WriteAllText($skillPath, $skill.TrimStart() + "`n")
|
|
||||||
Write-Host "==> plugin $pluginPath"
|
|
||||||
Write-Host "==> skill $skillPath"
|
|
||||||
|
|
||||||
if ($Key) {
|
if ($Key) {
|
||||||
$keyFile = Join-Path $conf '.arka-api-key'
|
$keyFile = Join-Path $conf '.arka-api-key'
|
||||||
@@ -293,17 +304,73 @@ foreach ($conf in $dirs) {
|
|||||||
Write-Host "==> key $keyFile"
|
Write-Host "==> key $keyFile"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($SetDefault) {
|
if ($gen -eq '1' -and -not $Refresh) {
|
||||||
$confFile = Join-Path $conf 'opencode.json'
|
$pluginPath = Join-Path $pluginDir 'arka-ai.ts'
|
||||||
Write-Host "==> default Arka-AI/$SetDefault in $confFile"
|
[System.IO.File]::WriteAllText($pluginPath, $plugin.TrimStart() + "`n")
|
||||||
|
Write-Host "==> plugin $pluginPath"
|
||||||
|
if ($SetDefault) {
|
||||||
|
$confFile = Join-Path $conf 'opencode.json'
|
||||||
|
$data = $null
|
||||||
|
if (Test-Path $confFile) { $data = Get-Content -Raw -Encoding UTF8 $confFile | ConvertFrom-Json }
|
||||||
|
if (-not $data) { $data = New-Object psobject }
|
||||||
|
$data | Add-Member -NotePropertyName '$schema' -NotePropertyValue 'https://opencode.ai/config.json' -Force
|
||||||
|
$data | Add-Member -NotePropertyName model -NotePropertyValue ("Arka-AI/" + $SetDefault) -Force
|
||||||
|
($data | ConvertTo-Json -Depth 40) + "`n" | Out-File -FilePath $confFile -Encoding utf8
|
||||||
|
Write-Host "==> default Arka-AI/$SetDefault in $confFile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($gen -eq '2') {
|
||||||
|
# Disable a stale 1.x plugin so 2.x doesn't spam load errors.
|
||||||
|
$stale = Join-Path $pluginDir 'arka-ai.ts'
|
||||||
|
if (Test-Path $stale) {
|
||||||
|
Move-Item -Force $stale "$stale.disabled"
|
||||||
|
Write-Host "==> disabled stale 1.x plugin ($stale.disabled)"
|
||||||
|
}
|
||||||
|
|
||||||
|
$confFile = Join-Path $conf 'opencode.jsonc'
|
||||||
|
if (-not (Test-Path $confFile)) {
|
||||||
|
$alt = Join-Path $conf 'opencode.json'
|
||||||
|
if (Test-Path $alt) { $confFile = $alt }
|
||||||
|
}
|
||||||
|
|
||||||
$data = $null
|
$data = $null
|
||||||
if (Test-Path $confFile) {
|
if (Test-Path $confFile) {
|
||||||
$data = Get-Content -Raw -Encoding UTF8 $confFile | ConvertFrom-Json
|
$raw = Get-Content -Raw -Encoding UTF8 $confFile
|
||||||
|
$stripped = (($raw -split "`n") | Where-Object { $_ -notmatch '^\s*//' }) -join "`n"
|
||||||
|
try { $data = $stripped | ConvertFrom-Json } catch { $data = $null }
|
||||||
}
|
}
|
||||||
if (-not $data) { $data = New-Object psobject }
|
if (-not $data) { $data = New-Object psobject }
|
||||||
$data | Add-Member -NotePropertyName '$schema' -NotePropertyValue 'https://opencode.ai/config.json' -Force
|
if (-not $data.PSObject.Properties['$schema']) {
|
||||||
$data | Add-Member -NotePropertyName model -NotePropertyValue ("Arka-AI/" + $SetDefault) -Force
|
$data | Add-Member -NotePropertyName '$schema' -NotePropertyValue 'https://opencode.ai/config.json' -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
$providers = $data.providers
|
||||||
|
if (-not $providers) { $providers = New-Object psobject; $data | Add-Member -NotePropertyName providers -NotePropertyValue $providers -Force }
|
||||||
|
$prov = $providers.'Arka-AI'
|
||||||
|
if (-not $prov) { $prov = New-Object psobject; $providers | Add-Member -NotePropertyName 'Arka-AI' -NotePropertyValue $prov -Force }
|
||||||
|
$prov | Add-Member -NotePropertyName name -NotePropertyValue 'Arka-AI' -Force
|
||||||
|
$prov | Add-Member -NotePropertyName package -NotePropertyValue '@opencode/ai/providers/openai-compatible' -Force
|
||||||
|
$prov | Add-Member -NotePropertyName env -NotePropertyValue @('ARKA_API_KEY') -Force
|
||||||
|
|
||||||
|
$settings = New-Object psobject
|
||||||
|
$settings | Add-Member -NotePropertyName baseURL -NotePropertyValue $ApiUrl -Force
|
||||||
|
if ($Key) { $settings | Add-Member -NotePropertyName apiKey -NotePropertyValue $Key -Force }
|
||||||
|
$prov | Add-Member -NotePropertyName settings -NotePropertyValue $settings -Force
|
||||||
|
|
||||||
|
$ids = Get-CatalogIds
|
||||||
|
if ($ids.Count -gt 0) {
|
||||||
|
$models = [ordered]@{}
|
||||||
|
foreach ($id in $ids) { $models[$id] = @{ name = $id } }
|
||||||
|
$prov | Add-Member -NotePropertyName models -NotePropertyValue $models -Force
|
||||||
|
Write-Host "==> models $($ids.Count) chat models"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($SetDefault) {
|
||||||
|
$data | Add-Member -NotePropertyName model -NotePropertyValue ("Arka-AI/" + $SetDefault) -Force
|
||||||
|
}
|
||||||
|
|
||||||
($data | ConvertTo-Json -Depth 40) + "`n" | Out-File -FilePath $confFile -Encoding utf8
|
($data | ConvertTo-Json -Depth 40) + "`n" | Out-File -FilePath $confFile -Encoding utf8
|
||||||
|
Write-Host "==> providers['Arka-AI'] in $confFile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,17 +378,21 @@ if ($Key) {
|
|||||||
$env:ARKA_API_KEY = $Key
|
$env:ARKA_API_KEY = $Key
|
||||||
try {
|
try {
|
||||||
[Environment]::SetEnvironmentVariable('ARKA_API_KEY', $Key, 'User')
|
[Environment]::SetEnvironmentVariable('ARKA_API_KEY', $Key, 'User')
|
||||||
Write-Host '==> User environment ARKA_API_KEY (Desktop / GUI pick this up after a full restart)'
|
Write-Host '==> User environment ARKA_API_KEY (CLI/Desktop pick it up after a full restart)'
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "could not set User environment variable: $_"
|
Write-Warning "could not set User environment variable: $_"
|
||||||
}
|
}
|
||||||
} else {
|
} elseif (-not $Refresh) {
|
||||||
Write-Warning 'no ARKA_API_KEY; Desktop will not be able to call models until you set it'
|
Write-Warning 'no ARKA_API_KEY; Desktop will not be able to call models until you set it'
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ''
|
Write-Host ''
|
||||||
Write-Host 'Done.'
|
Write-Host "Done (opencode generation $gen)."
|
||||||
Write-Host 'Next:'
|
Write-Host 'Next:'
|
||||||
Write-Host ' 1. Fully quit OpenCode CLI *and* OpenCode Desktop (tray icon too), then start again.'
|
Write-Host ' 1. Fully quit OpenCode CLI *and* OpenCode Desktop (tray icon too), then start again.'
|
||||||
Write-Host ' 2. /models — provider Arka-AI should appear (~116 chat models).'
|
Write-Host ' 2. /models — provider Arka-AI should appear.'
|
||||||
Write-Host ' 3. Refresh later: delete %USERPROFILE%\.cache\opencode\arka-ai-models.json and restart.'
|
if ($gen -eq '2') {
|
||||||
|
Write-Host ' 3. Refresh models later: re-run this installer with -Refresh.'
|
||||||
|
} else {
|
||||||
|
Write-Host ' 3. Refresh later: delete %USERPROFILE%\.cache\opencode\arka-ai-models.json and restart.'
|
||||||
|
}
|
||||||
+272
-112
@@ -3,39 +3,49 @@
|
|||||||
# install-arka-provider.sh — one-shot installer for the arka-ai.ru LLM provider
|
# install-arka-provider.sh — one-shot installer for the arka-ai.ru LLM provider
|
||||||
# in a fresh opencode install.
|
# in a fresh opencode install.
|
||||||
#
|
#
|
||||||
# It is fully self-contained: it embeds the provider plugin and the companion
|
# Works with BOTH opencode generations, detected automatically:
|
||||||
# skill, writes them into ~/.config/opencode, and persists ARKA_API_KEY.
|
# * opencode 1.x -> installs a plugin (plugins/arka-ai.ts) that injects the
|
||||||
|
# provider + catalog dynamically via the `config` hook.
|
||||||
|
# * opencode 2.x -> writes a static `providers["Arka-AI"]` block into the
|
||||||
|
# config (package openai-compatible + baseURL + models).
|
||||||
|
# opencode 2.x changed the plugin API, so the 1.x plugin
|
||||||
|
# no longer loads there; the static block needs no plugin.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# bash install-arka-provider.sh # prompt for API key
|
# bash install-arka-provider.sh # prompt for API key
|
||||||
# ARKA_API_KEY=xxx bash install-arka-provider.sh # key from env (no prompt)
|
# ARKA_API_KEY=xxx bash install-arka-provider.sh # key from env (no prompt)
|
||||||
# bash install-arka-provider.sh --key xxx --set-default DeepSeek-V4-Pro
|
# bash install-arka-provider.sh --key xxx --set-default DeepSeek-V4-Pro
|
||||||
|
# bash install-arka-provider.sh --refresh # refresh the model list
|
||||||
|
# bash install-arka-provider.sh --gen 2 # force generation (1|2)
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# --key KEY ARKA_API_KEY to persist (default: $ARKA_API_KEY, else prompt)
|
# --key KEY ARKA_API_KEY to persist (default: $ARKA_API_KEY, else prompt)
|
||||||
# --set-default MODEL also set "model": "Arka-AI/<MODEL>" in opencode.json
|
# --set-default MODEL also set "model": "Arka-AI/<MODEL>"
|
||||||
|
# --gen {1|2} force opencode generation (default: detect)
|
||||||
|
# --refresh only refresh the model list, keep everything else
|
||||||
# -h, --help show this help
|
# -h, --help show this help
|
||||||
#
|
#
|
||||||
# Idempotent: safe to run multiple times. Overwrites plugin/skill with the
|
# Idempotent: safe to run multiple times. Never clobbers unrelated config keys.
|
||||||
# embedded versions; never clobbers an existing opencode.json (only upserts the
|
|
||||||
# requested default model). Makes no network calls.
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
usage() {
|
usage() { sed -n '2,30p' "$0"; }
|
||||||
sed -n '2,21p' "$0"
|
|
||||||
}
|
|
||||||
|
|
||||||
KEY=""
|
KEY=""
|
||||||
MODEL=""
|
MODEL=""
|
||||||
|
GEN=""
|
||||||
|
REFRESH=0
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--key) KEY="$2"; shift 2 ;;
|
--key) KEY="$2"; shift 2 ;;
|
||||||
--key=*) KEY="${1#*=}"; shift ;;
|
--key=*) KEY="${1#*=}"; shift ;;
|
||||||
--set-default) MODEL="$2"; shift 2 ;;
|
--set-default) MODEL="$2"; shift 2 ;;
|
||||||
--set-default=*) MODEL="${1#*=}"; shift ;;
|
--set-default=*) MODEL="${1#*=}"; shift ;;
|
||||||
-h|--help) usage; exit 0 ;;
|
--gen) GEN="$2"; shift 2 ;;
|
||||||
|
--gen=*) GEN="${1#*=}"; shift ;;
|
||||||
|
--refresh) REFRESH=1; shift ;;
|
||||||
|
-h|--help) usage; exit 0 ;;
|
||||||
*) printf 'unknown option: %s\n' "$1" >&2; usage; exit 1 ;;
|
*) printf 'unknown option: %s\n' "$1" >&2; usage; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -43,11 +53,134 @@ done
|
|||||||
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opencode"
|
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opencode"
|
||||||
PLUGIN_DIR="$CONF_DIR/plugins"
|
PLUGIN_DIR="$CONF_DIR/plugins"
|
||||||
SKILL_DIR="$CONF_DIR/skills/arka-provider"
|
SKILL_DIR="$CONF_DIR/skills/arka-provider"
|
||||||
|
CATALOG_URL="https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json"
|
||||||
|
API_URL="https://api.arka-ai.ru/v1"
|
||||||
|
|
||||||
mkdir -p "$PLUGIN_DIR" "$SKILL_DIR" "$HOME"
|
mkdir -p "$PLUGIN_DIR" "$SKILL_DIR" "$HOME"
|
||||||
|
|
||||||
echo "==> writing provider plugin to $PLUGIN_DIR/arka-ai.ts"
|
# --- detect the opencode generation ------------------------------------
|
||||||
cat > "$PLUGIN_DIR/arka-ai.ts" <<'PLUGIN'
|
detect_gen() {
|
||||||
|
local v major
|
||||||
|
if [ -n "${OPENCODE_GEN:-}" ]; then echo "$OPENCODE_GEN"; return; fi
|
||||||
|
v="$(opencode --version 2>/dev/null | head -1 || true)"
|
||||||
|
major="$(printf '%s' "$v" | grep -oE '[0-9]+' | head -1 || true)"
|
||||||
|
if [ -z "$major" ]; then echo ""; return; fi
|
||||||
|
if [ "$major" -ge 2 ] 2>/dev/null; then echo 2; else echo 1; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# On --refresh, trust what is actually installed over a possibly-absent/other
|
||||||
|
# `opencode` binary on PATH.
|
||||||
|
if [ -z "$GEN" ] && [ "$REFRESH" -eq 1 ]; then
|
||||||
|
for f in "$CONF_DIR/opencode.jsonc" "$CONF_DIR/opencode.json"; do
|
||||||
|
if [ -f "$f" ] && grep -q '"Arka-AI"' "$f" 2>/dev/null; then GEN=2; break; fi
|
||||||
|
done
|
||||||
|
[ -z "$GEN" ] && [ -f "$PLUGIN_DIR/arka-ai.ts" ] && GEN=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$GEN" ]; then GEN="$(detect_gen)"; fi
|
||||||
|
if [ -z "$GEN" ]; then
|
||||||
|
printf '!! could not detect opencode version (is `opencode` on PATH?)\n' >&2
|
||||||
|
printf '!! defaulting to generation 2; pass --gen 1 for opencode 1.x\n' >&2
|
||||||
|
GEN=2
|
||||||
|
fi
|
||||||
|
case "$GEN" in 1|2) ;; *) printf 'invalid --gen %s (want 1 or 2)\n' "$GEN" >&2; exit 1 ;; esac
|
||||||
|
echo "==> opencode generation: $GEN"
|
||||||
|
|
||||||
|
# --- companion skill (shared by both generations) ----------------------
|
||||||
|
write_skill() {
|
||||||
|
echo "==> writing companion skill to $SKILL_DIR/SKILL.md"
|
||||||
|
cat > "$SKILL_DIR/SKILL.md" <<'SKILL'
|
||||||
|
---
|
||||||
|
name: arka-provider
|
||||||
|
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config (1.x and 2.x). Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Arka-AI provider
|
||||||
|
|
||||||
|
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
||||||
|
It is wired up locally. **The mechanism depends on the opencode generation:**
|
||||||
|
|
||||||
|
| opencode | provider lives in | models |
|
||||||
|
|----------|-------------------|--------|
|
||||||
|
| **1.x** | plugin `~/.config/opencode/plugins/arka-ai.ts` (injects via the `config` hook) | dynamic (public catalog, cached 24h) |
|
||||||
|
| **2.x** | static `providers["Arka-AI"]` block in `~/.config/opencode/opencode.jsonc` | static list (refresh by re-running the installer) |
|
||||||
|
|
||||||
|
`opencode --version` prints `1.x.y` on 1.x and `opencode v2.x.y` on 2.x.
|
||||||
|
The installer detects this and writes the right thing. (2.x changed the plugin
|
||||||
|
API: a 1.x plugin no longer loads — it must export `{ id, setup }` — so the 1.x
|
||||||
|
plugin is disabled and the static block is used instead.)
|
||||||
|
|
||||||
|
## 1.x — plugin (dynamic catalog)
|
||||||
|
|
||||||
|
- Plugin `plugins/arka-ai.ts` loads the published chat catalog
|
||||||
|
(`…/opencode/catalog.json`, no key, refreshed daily 05:00 Europe/Moscow), falls
|
||||||
|
back to `/v1/models`, filters non-chat models, caches at
|
||||||
|
`~/.cache/opencode/arka-ai-models.json` (TTL 24h), and injects the provider.
|
||||||
|
- Key: `ARKA_API_KEY` env or `~/.config/opencode/.arka-api-key`.
|
||||||
|
|
||||||
|
## 2.x — static config
|
||||||
|
|
||||||
|
- `opencode.jsonc` → `providers["Arka-AI"]`:
|
||||||
|
```jsonc
|
||||||
|
{
|
||||||
|
"providers": {
|
||||||
|
"Arka-AI": {
|
||||||
|
"name": "Arka-AI",
|
||||||
|
"package": "@opencode/ai/providers/openai-compatible",
|
||||||
|
"env": ["ARKA_API_KEY"],
|
||||||
|
"settings": { "baseURL": "https://api.arka-ai.ru/v1", "apiKey": "…" },
|
||||||
|
"models": { "DeepSeek-V4-Pro": { "name": "DeepSeek-V4-Pro" } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- The model list is static — refresh it after catalog changes:
|
||||||
|
```bash
|
||||||
|
bash install-arka-provider.sh --refresh
|
||||||
|
```
|
||||||
|
(re-fetches catalog.json and rewrites only `providers["Arka-AI"].models`).
|
||||||
|
|
||||||
|
## Change default model
|
||||||
|
|
||||||
|
`"model": "Arka-AI/<model-id>"` in the config file. Use IDs exactly as in the
|
||||||
|
catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`, `Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
||||||
|
|
||||||
|
## Adjust filtering
|
||||||
|
|
||||||
|
`NON_CHAT` / `FORCED_MODELS` live in **three** places kept in lockstep:
|
||||||
|
`opencode/plugins/arka-ai.ts` (1.x), the installer's inline generator (2.x), and
|
||||||
|
`opencode/scripts/sync-catalog.py` (which rebuilds `catalog.json`). Edit all
|
||||||
|
three, re-run the installer, restart.
|
||||||
|
|
||||||
|
## Probing plan coverage
|
||||||
|
|
||||||
|
The public catalog lists every platform model, not your plan's allow-list.
|
||||||
|
Out-of-plan calls return `400 … does not support using vendor "arka"`. The
|
||||||
|
allow-list lives only in the admin console (`/admin/data/subscriptions/<id>/edit`).
|
||||||
|
Optional curated picker: `ARKA_PLAN_MODELS="…"` (1.x plugin only).
|
||||||
|
SKILL
|
||||||
|
}
|
||||||
|
write_skill
|
||||||
|
|
||||||
|
# --- refresh-only mode -------------------------------------------------
|
||||||
|
if [ "$REFRESH" -eq 1 ]; then
|
||||||
|
if [ "$GEN" = 1 ]; then
|
||||||
|
rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/opencode/arka-ai-models.json" 2>/dev/null || true
|
||||||
|
echo "==> cleared arka-ai-models.json cache; restart opencode to refetch."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# generation 2: regenerate the static models block in place
|
||||||
|
echo "==> refreshing Arka-AI models (generation 2)"
|
||||||
|
MODEL="__KEEP__"
|
||||||
|
# fall through to the generation-2 config writer below
|
||||||
|
fi
|
||||||
|
|
||||||
|
# =======================================================================
|
||||||
|
# Generation 1 — plugin
|
||||||
|
# =======================================================================
|
||||||
|
if [ "$GEN" = 1 ] && [ "$REFRESH" -eq 0 ]; then
|
||||||
|
echo "==> writing provider plugin to $PLUGIN_DIR/arka-ai.ts"
|
||||||
|
cat > "$PLUGIN_DIR/arka-ai.ts" <<'PLUGIN'
|
||||||
import { homedir } from "node:os"
|
import { homedir } from "node:os"
|
||||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
@@ -97,7 +230,7 @@ const FORCED_MODELS = [
|
|||||||
|
|
||||||
// Heuristic: drop non-chat models (TTS/ASR/image/video/OCR/embeddings/rerankers…)
|
// Heuristic: drop non-chat models (TTS/ASR/image/video/OCR/embeddings/rerankers…)
|
||||||
// from the catalog so they don't clutter the /models picker.
|
// from the catalog so they don't clutter the /models picker.
|
||||||
// Keep in sync with scripts/sync-catalog.py
|
// Keep in sync with scripts/sync-catalog.py and the installer's 2.x generator.
|
||||||
const NON_CHAT = new RegExp(
|
const NON_CHAT = new RegExp(
|
||||||
[
|
[
|
||||||
"tts", "asr", "audio", "speech", "voice", "whisper", "sensevoice",
|
"tts", "asr", "audio", "speech", "voice", "whisper", "sensevoice",
|
||||||
@@ -218,125 +351,152 @@ export default async function ArkaAIProviderPlugin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PLUGIN
|
PLUGIN
|
||||||
|
fi
|
||||||
|
|
||||||
echo "==> writing companion skill to $SKILL_DIR/SKILL.md"
|
# =======================================================================
|
||||||
cat > "$SKILL_DIR/SKILL.md" <<'SKILL'
|
# Generation 2 — static providers block
|
||||||
---
|
# =======================================================================
|
||||||
name: arka-provider
|
if [ "$GEN" = 2 ] || [ "$REFRESH" -eq 1 ]; then
|
||||||
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config. Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
# Disable a stale 1.x plugin so 2.x doesn't spam load errors.
|
||||||
---
|
if [ -f "$PLUGIN_DIR/arka-ai.ts" ]; then
|
||||||
|
echo "==> disabling stale 1.x plugin (opencode 2.x cannot load it)"
|
||||||
|
mv "$PLUGIN_DIR/arka-ai.ts" "$PLUGIN_DIR/arka-ai.ts.disabled"
|
||||||
|
fi
|
||||||
|
|
||||||
# Arka-AI provider
|
CATALOG_TMP="$(mktemp)"; trap 'rm -f "$CATALOG_TMP"' EXIT
|
||||||
|
echo "==> fetching chat catalog $CATALOG_URL"
|
||||||
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
if ! curl -fsSL "$CATALOG_URL" -o "$CATALOG_TMP" 2>/dev/null || [ ! -s "$CATALOG_TMP" ]; then
|
||||||
It is wired up locally with a plugin + a static `provider` block in
|
echo "==> catalog fetch failed; falling back to $API_URL/models"
|
||||||
`~/.config/opencode/opencode.json`.
|
curl -fsSL "$API_URL/models" -o "$CATALOG_TMP" 2>/dev/null || : > "$CATALOG_TMP"
|
||||||
|
fi
|
||||||
## How it works
|
fi
|
||||||
|
|
||||||
- Plugin: `~/.config/opencode/plugins/arka-ai.ts`
|
|
||||||
- On startup it loads the published chat catalog
|
|
||||||
`https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json`
|
|
||||||
(no API key; refreshed daily at 05:00 Europe/Moscow).
|
|
||||||
- If that fetch fails, it falls back to `https://api.arka-ai.ru/v1/models`
|
|
||||||
and filters out non-chat models (TTS/ASR/image/video/OCR/embedding/reranker/…)
|
|
||||||
via a heuristic regex so the `/models` picker stays clean.
|
|
||||||
- Caches the result at `~/.cache/opencode/arka-ai-models.json` (TTL 24h).
|
|
||||||
- Injects the provider into config via the `config` hook, layered over the
|
|
||||||
static block in `opencode.json`.
|
|
||||||
- Static block (`opencode.json` → `provider["Arka-AI"]`) holds
|
|
||||||
`name`, `api`, `env`, and a small fallback `models` map that is used when the
|
|
||||||
catalog is unreachable.
|
|
||||||
- Inference uses `ARKA_API_KEY` (env) or `~/.config/opencode/.arka-api-key`
|
|
||||||
(so OpenCode Desktop / Windows GUI works without a login shell).
|
|
||||||
|
|
||||||
## Refresh the model list
|
|
||||||
|
|
||||||
Catalog ~216 raw models / ~116 chat; the public snapshot updates at 05:00
|
|
||||||
Europe/Moscow. Changes land in opencode only after cache expiry + restart
|
|
||||||
(config is not hot-reloaded).
|
|
||||||
|
|
||||||
1. `rm -f ~/.cache/opencode/arka-ai-models.json`
|
|
||||||
2. Restart opencode (or run `opencode` again) — the plugin re-fetches on the
|
|
||||||
next cold start.
|
|
||||||
|
|
||||||
Optionally inspect the live API (no key required for listing):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -sS https://api.arka-ai.ru/v1/models | python3 -m json.tool
|
|
||||||
curl -sS https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json | python3 -m json.tool
|
|
||||||
```
|
|
||||||
|
|
||||||
## Change default model
|
|
||||||
|
|
||||||
Edit `opencode.json` → `"model": "Arka-AI/<model-id>"`. Use the IDs exactly as
|
|
||||||
returned by the catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`,
|
|
||||||
`Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
|
||||||
|
|
||||||
## Adjust filtering
|
|
||||||
|
|
||||||
Edit `NON_CHAT` (regex) or `FORCED_MODELS` in the plugin file **and** the same
|
|
||||||
lists in `scripts/sync-catalog.py` in `arka/public`, then re-run the installer
|
|
||||||
and restart. `FORCED_MODELS` keeps must-have chat models even if the heuristic
|
|
||||||
would drop them.
|
|
||||||
SKILL
|
|
||||||
|
|
||||||
# --- API key -----------------------------------------------------------
|
# --- API key -----------------------------------------------------------
|
||||||
|
if [ "$REFRESH" -eq 0 ]; then
|
||||||
if [ -z "$KEY" ]; then
|
if [ -z "$KEY" ]; then
|
||||||
read -rsp "ARKA_API_KEY (leave blank to skip): " KEY || true
|
read -rsp "ARKA_API_KEY (leave blank to skip): " KEY || true
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$KEY" ]; then
|
||||||
if [ -n "$KEY" ]; then
|
RC=""
|
||||||
RC=""
|
for f in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
|
||||||
for f in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
|
if [ -f "$f" ]; then RC="$f"; break; fi
|
||||||
if [ -f "$f" ]; then RC="$f"; break; fi
|
done
|
||||||
done
|
RC="${RC:-$HOME/.bashrc}"
|
||||||
RC="${RC:-$HOME/.bashrc}"
|
touch "$RC"
|
||||||
touch "$RC"
|
if grep -q 'ARKA_API_KEY' "$RC"; then
|
||||||
if grep -q 'ARKA_API_KEY' "$RC"; then
|
echo "==> ARKA_API_KEY already present in $RC (skipped)"
|
||||||
echo "==> ARKA_API_KEY already present in $RC (skipped)"
|
else
|
||||||
|
printf '\n# opencode Arka-AI provider\nexport ARKA_API_KEY="%s"\n' "$KEY" >> "$RC"
|
||||||
|
echo "==> wrote ARKA_API_KEY to $RC"
|
||||||
|
fi
|
||||||
|
export ARKA_API_KEY="$KEY"
|
||||||
|
printf '%s\n' "$KEY" > "$CONF_DIR/.arka-api-key"
|
||||||
|
chmod 600 "$CONF_DIR/.arka-api-key" 2>/dev/null || true
|
||||||
|
echo "==> wrote API key to $CONF_DIR/.arka-api-key"
|
||||||
else
|
else
|
||||||
printf '\n# opencode Arka-AI provider\nexport ARKA_API_KEY="%s"\n' "$KEY" >> "$RC"
|
echo "==> warning: no ARKA_API_KEY set; export it (or re-run with --key) so requests authenticate" >&2
|
||||||
echo "==> wrote ARKA_API_KEY to $RC"
|
|
||||||
fi
|
fi
|
||||||
export ARKA_API_KEY="$KEY"
|
|
||||||
KEY_FILE="$CONF_DIR/.arka-api-key"
|
|
||||||
printf '%s\n' "$KEY" > "$KEY_FILE"
|
|
||||||
chmod 600 "$KEY_FILE" 2>/dev/null || true
|
|
||||||
echo "==> wrote API key to $KEY_FILE (CLI + Desktop)"
|
|
||||||
else
|
|
||||||
echo "==> warning: no ARKA_API_KEY set; export it in your shell before starting opencode" >&2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- default model (optional) ------------------------------------------
|
# --- generation 2: write/refresh the providers block -------------------
|
||||||
|
if [ "$GEN" = 2 ]; then
|
||||||
|
CONF=""
|
||||||
|
for f in "$CONF_DIR/opencode.jsonc" "$CONF_DIR/opencode.json"; do
|
||||||
|
[ -f "$f" ] && { CONF="$f"; break; }
|
||||||
|
done
|
||||||
|
CONF="${CONF:-$CONF_DIR/opencode.jsonc}"
|
||||||
|
|
||||||
if [ -n "$MODEL" ]; then
|
echo "==> writing providers[\"Arka-AI\"] to $CONF"
|
||||||
|
KEY_PRESENT="$([ -n "${KEY:-}" ] && echo 1 || echo 0)"
|
||||||
|
# If --refresh without --key, reuse the stored key file.
|
||||||
|
if [ "$KEY_PRESENT" = 0 ] && [ -s "$CONF_DIR/.arka-api-key" ]; then
|
||||||
|
KEY="$(cat "$CONF_DIR/.arka-api-key")"; KEY_PRESENT=1
|
||||||
|
fi
|
||||||
|
python3 - "$CONF" "$CATALOG_TMP" "${MODEL:-}" "$KEY_PRESENT" "${KEY:-}" <<'PY'
|
||||||
|
import json, os, re, sys
|
||||||
|
|
||||||
|
path, catalog, model, have_key, key = sys.argv[1:6]
|
||||||
|
data = {}
|
||||||
|
if os.path.exists(path):
|
||||||
|
txt = open(path, encoding="utf-8").read()
|
||||||
|
try:
|
||||||
|
data = json.loads(re.sub(r"(?m)//.*$", "", txt))
|
||||||
|
except Exception:
|
||||||
|
data = {}
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
data.setdefault("$schema", "https://opencode.ai/config.json")
|
||||||
|
|
||||||
|
ids = []
|
||||||
|
try:
|
||||||
|
payload = json.load(open(catalog, encoding="utf-8"))
|
||||||
|
ids = [m["id"] for m in payload.get("data", []) if m.get("id")]
|
||||||
|
except Exception:
|
||||||
|
ids = []
|
||||||
|
|
||||||
|
prov = data.setdefault("providers", {}).setdefault("Arka-AI", {})
|
||||||
|
prov["name"] = "Arka-AI"
|
||||||
|
prov["package"] = "@opencode/ai/providers/openai-compatible"
|
||||||
|
prov["env"] = ["ARKA_API_KEY"]
|
||||||
|
settings = prov.setdefault("settings", {})
|
||||||
|
settings["baseURL"] = "https://api.arka-ai.ru/v1"
|
||||||
|
if have_key == "1" and key:
|
||||||
|
settings["apiKey"] = key
|
||||||
|
if ids:
|
||||||
|
prov["models"] = {i: {"name": i} for i in ids}
|
||||||
|
|
||||||
|
if model and model != "__KEEP__":
|
||||||
|
data["model"] = model
|
||||||
|
|
||||||
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||||
|
f.write("\n")
|
||||||
|
os.chmod(path, 0o600)
|
||||||
|
print("models:", len(prov.get("models", {})), "key:", "yes" if settings.get("apiKey") else "no")
|
||||||
|
PY
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- generation 1: optional default model ------------------------------
|
||||||
|
if [ "$GEN" = 1 ] && [ -n "$MODEL" ]; then
|
||||||
CONF="$CONF_DIR/opencode.json"
|
CONF="$CONF_DIR/opencode.json"
|
||||||
echo "==> setting default model Arka-AI/$MODEL in $CONF"
|
echo "==> setting default model Arka-AI/$MODEL in $CONF"
|
||||||
python3 - "$CONF" "Arka-AI/$MODEL" <<'PY'
|
python3 - "$CONF" "Arka-AI/$MODEL" <<'PY'
|
||||||
import json, os, sys
|
import json, os, sys
|
||||||
|
|
||||||
path, model = sys.argv[1], sys.argv[2]
|
path, model = sys.argv[1], sys.argv[2]
|
||||||
data = {}
|
data = {}
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
with open(path) as f:
|
try:
|
||||||
data = json.load(f)
|
data = json.load(open(path))
|
||||||
|
except Exception:
|
||||||
|
data = {}
|
||||||
data.setdefault("$schema", "https://opencode.ai/config.json")
|
data.setdefault("$schema", "https://opencode.ai/config.json")
|
||||||
data["model"] = model
|
data["model"] = model
|
||||||
with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
json.dump(data, f, indent=2)
|
json.dump(data, f, indent=2); f.write("\n")
|
||||||
f.write("\n")
|
|
||||||
PY
|
PY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Done."
|
if [ "$REFRESH" -eq 1 ]; then
|
||||||
echo " - provider plugin: $PLUGIN_DIR/arka-ai.ts"
|
echo "Done. Model list refreshed. Restart opencode to pick it up."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Done (opencode generation $GEN)."
|
||||||
|
if [ "$GEN" = 1 ]; then
|
||||||
|
echo " - provider plugin: $PLUGIN_DIR/arka-ai.ts"
|
||||||
|
else
|
||||||
|
echo " - provider config: $CONF (providers[\"Arka-AI\"])"
|
||||||
|
fi
|
||||||
echo " - skill: $SKILL_DIR/SKILL.md"
|
echo " - skill: $SKILL_DIR/SKILL.md"
|
||||||
echo
|
echo
|
||||||
echo "Next steps:"
|
echo "Next steps:"
|
||||||
echo " 1. Fully quit and restart OpenCode (CLI or Desktop). Plugins load only at startup."
|
echo " 1. Fully quit and restart OpenCode (CLI or Desktop) — config/plugins load at startup."
|
||||||
echo " 2. Run /models — the Arka-AI catalog (~116 chat models) loads on first start."
|
echo " 2. /models → provider Arka-AI."
|
||||||
echo " 3. Optional: refresh catalog later with: rm -f ~/.cache/opencode/arka-ai-models.json"
|
if [ "$GEN" = 2 ]; then
|
||||||
|
echo " 3. After catalog changes: bash install-arka-provider.sh --refresh"
|
||||||
|
else
|
||||||
|
echo " 3. After catalog changes: rm -f ~/.cache/opencode/arka-ai-models.json"
|
||||||
|
fi
|
||||||
@@ -1,58 +1,68 @@
|
|||||||
---
|
---
|
||||||
name: arka-provider
|
name: arka-provider
|
||||||
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config. Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config (1.x and 2.x). Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
||||||
---
|
---
|
||||||
|
|
||||||
# Arka-AI provider
|
# Arka-AI provider
|
||||||
|
|
||||||
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
||||||
It is wired up locally with a plugin + a static `provider` block in
|
It is wired up locally. **The mechanism depends on the opencode generation:**
|
||||||
`~/.config/opencode/opencode.json`.
|
|
||||||
|
|
||||||
## How it works
|
| opencode | provider lives in | models |
|
||||||
|
|----------|-------------------|--------|
|
||||||
|
| **1.x** | plugin `~/.config/opencode/plugins/arka-ai.ts` (injects via the `config` hook) | dynamic (public catalog, cached 24h) |
|
||||||
|
| **2.x** | static `providers["Arka-AI"]` block in `~/.config/opencode/opencode.jsonc` | static list (refresh by re-running the installer) |
|
||||||
|
|
||||||
- Plugin: `~/.config/opencode/plugins/arka-ai.ts`
|
`opencode --version` prints `1.x.y` on 1.x and `opencode v2.x.y` on 2.x.
|
||||||
- On startup it loads the published chat catalog
|
The installer detects this and writes the right thing. (2.x changed the plugin
|
||||||
`https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json`
|
API: a 1.x plugin no longer loads — it must export `{ id, setup }` — so the 1.x
|
||||||
(no API key; refreshed daily at 05:00 Europe/Moscow).
|
plugin is disabled and the static block is used instead.)
|
||||||
- If that fetch fails, it falls back to `https://api.arka-ai.ru/v1/models`
|
|
||||||
and filters out non-chat models (TTS/ASR/image/video/OCR/embedding/reranker/…)
|
|
||||||
via a heuristic regex so the `/models` picker stays clean.
|
|
||||||
- Caches the result at `~/.cache/opencode/arka-ai-models.json` (TTL 24h).
|
|
||||||
- Injects the provider into config via the `config` hook, layered over the
|
|
||||||
static block in `opencode.json`.
|
|
||||||
- Static block (`opencode.json` → `provider["Arka-AI"]`) holds
|
|
||||||
`name`, `api`, `env`, and a small fallback `models` map that is used when the
|
|
||||||
catalog is unreachable.
|
|
||||||
- Inference uses `ARKA_API_KEY` (env) or `~/.config/opencode/.arka-api-key`
|
|
||||||
(so OpenCode Desktop / Windows GUI works without a login shell).
|
|
||||||
|
|
||||||
## Refresh the model list
|
## 1.x — plugin (dynamic catalog)
|
||||||
|
|
||||||
Catalog ~216 raw models / ~116 chat; the public snapshot updates at 05:00
|
- Plugin `plugins/arka-ai.ts` loads the published chat catalog
|
||||||
Europe/Moscow. Changes land in opencode only after cache expiry + restart
|
(`…/opencode/catalog.json`, no key, refreshed daily 05:00 Europe/Moscow), falls
|
||||||
(config is not hot-reloaded).
|
back to `/v1/models`, filters non-chat models, caches at
|
||||||
|
`~/.cache/opencode/arka-ai-models.json` (TTL 24h), and injects the provider.
|
||||||
|
- Key: `ARKA_API_KEY` env or `~/.config/opencode/.arka-api-key`.
|
||||||
|
|
||||||
1. `rm -f ~/.cache/opencode/arka-ai-models.json`
|
## 2.x — static config
|
||||||
2. Restart opencode (or run `opencode` again) — the plugin re-fetches on the
|
|
||||||
next cold start.
|
|
||||||
|
|
||||||
Optionally inspect the live API (no key required for listing):
|
- `opencode.jsonc` → `providers["Arka-AI"]`:
|
||||||
|
```jsonc
|
||||||
```bash
|
{
|
||||||
curl -sS https://api.arka-ai.ru/v1/models | python3 -m json.tool
|
"providers": {
|
||||||
curl -sS https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json | python3 -m json.tool
|
"Arka-AI": {
|
||||||
```
|
"name": "Arka-AI",
|
||||||
|
"package": "@opencode/ai/providers/openai-compatible",
|
||||||
|
"env": ["ARKA_API_KEY"],
|
||||||
|
"settings": { "baseURL": "https://api.arka-ai.ru/v1", "apiKey": "…" },
|
||||||
|
"models": { "DeepSeek-V4-Pro": { "name": "DeepSeek-V4-Pro" } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- The model list is static — refresh it after catalog changes:
|
||||||
|
```bash
|
||||||
|
bash install-arka-provider.sh --refresh
|
||||||
|
```
|
||||||
|
(re-fetches catalog.json and rewrites only `providers["Arka-AI"].models`).
|
||||||
|
|
||||||
## Change default model
|
## Change default model
|
||||||
|
|
||||||
Edit `opencode.json` → `"model": "Arka-AI/<model-id>"`. Use the IDs exactly as
|
`"model": "Arka-AI/<model-id>"` in the config file. Use IDs exactly as in the
|
||||||
returned by the catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`,
|
catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`, `Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
||||||
`Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
|
||||||
|
|
||||||
## Adjust filtering
|
## Adjust filtering
|
||||||
|
|
||||||
Edit `NON_CHAT` (regex) or `FORCED_MODELS` in the plugin file **and** the same
|
`NON_CHAT` / `FORCED_MODELS` live in **three** places kept in lockstep:
|
||||||
lists in `scripts/sync-catalog.py` in `arka/public`, then re-run the installer
|
`opencode/plugins/arka-ai.ts` (1.x), the installer's inline generator (2.x), and
|
||||||
and restart. `FORCED_MODELS` keeps must-have chat models even if the heuristic
|
`opencode/scripts/sync-catalog.py` (which rebuilds `catalog.json`). Edit all
|
||||||
would drop them.
|
three, re-run the installer, restart.
|
||||||
|
|
||||||
|
## Probing plan coverage
|
||||||
|
|
||||||
|
The public catalog lists every platform model, not your plan's allow-list.
|
||||||
|
Out-of-plan calls return `400 … does not support using vendor "arka"`. The
|
||||||
|
allow-list lives only in the admin console (`/admin/data/subscriptions/<id>/edit`).
|
||||||
|
Optional curated picker: `ARKA_PLAN_MODELS="…"` (1.x plugin only).
|
||||||
Reference in new issue
Block a user