@tropass/connect 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +62 -0
- package/dist/bin/tropass-connect.d.ts +2 -0
- package/dist/bin/tropass-connect.js +8 -0
- package/dist/bin/tropass-connect.js.map +1 -0
- package/dist/skills/agent-response-display/SKILL.md +111 -0
- package/dist/skills/tropass-gateway/SKILL.md +52 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +52 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/constants.d.ts +8 -0
- package/dist/src/constants.js +9 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/installer.d.ts +4 -0
- package/dist/src/installer.js +171 -0
- package/dist/src/installer.js.map +1 -0
- package/dist/src/installers/cli.d.ts +6 -0
- package/dist/src/installers/cli.js +40 -0
- package/dist/src/installers/cli.js.map +1 -0
- package/dist/src/installers/opencode.d.ts +2 -0
- package/dist/src/installers/opencode.js +159 -0
- package/dist/src/installers/opencode.js.map +1 -0
- package/dist/src/installers/shared.d.ts +7 -0
- package/dist/src/installers/shared.js +43 -0
- package/dist/src/installers/shared.js.map +1 -0
- package/dist/src/installers/types.d.ts +9 -0
- package/dist/src/installers/types.js +2 -0
- package/dist/src/installers/types.js.map +1 -0
- package/dist/src/interactive-installer.d.ts +15 -0
- package/dist/src/interactive-installer.js +138 -0
- package/dist/src/interactive-installer.js.map +1 -0
- package/dist/src/logging.d.ts +1 -0
- package/dist/src/logging.js +5 -0
- package/dist/src/logging.js.map +1 -0
- package/dist/src/path-utils.d.ts +3 -0
- package/dist/src/path-utils.js +43 -0
- package/dist/src/path-utils.js.map +1 -0
- package/dist/src/spawn.d.ts +5 -0
- package/dist/src/spawn.js +13 -0
- package/dist/src/spawn.js.map +1 -0
- package/dist/src/types.d.ts +50 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/uvx.d.ts +2 -0
- package/dist/src/uvx.js +33 -0
- package/dist/src/uvx.js.map +1 -0
- package/dist/tools/tropass-provider.js +57 -0
- package/dist/tools/tropass.mjs +257 -0
- package/dist/tools/wait_for_model_task.py +24 -0
- package/dist/tools/wait_for_model_task.ts +51 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tropass
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Tropass Connect
|
|
2
|
+
|
|
3
|
+
[`@tropass/connect`](https://www.npmjs.com/package/@tropass/connect) подключает агентскую среду [OpenCode](https://opencode.ai/) к платформе [Tropass](https://тропасс.рф/) за одну команду. После установки агент может вызывать ML-модели через MCP, использовать LLM Tropass и работать со структурированными результатами моделей.
|
|
4
|
+
|
|
5
|
+
## Быстрый старт
|
|
6
|
+
|
|
7
|
+
Понадобятся:
|
|
8
|
+
|
|
9
|
+
- [Node.js](https://nodejs.org/en/download) 22 или новее;
|
|
10
|
+
- [OpenCode](https://opencode.ai/docs/#install) 1.17.16 или новее;
|
|
11
|
+
- [API-токен Tropass](https://ядро.тропасс.рф/api-keys).
|
|
12
|
+
|
|
13
|
+
Запустите установщик в терминале:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx -y @tropass/connect@latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Выберите область установки, введите API-токен и перезапустите OpenCode. По умолчанию установщик предлагает глобальную настройку для текущего пользователя.
|
|
20
|
+
|
|
21
|
+
## Возможности
|
|
22
|
+
|
|
23
|
+
- **ML-модели через MCP.** Агент получает доступ к моделям Tropass, подбирает подходящий инструмент, проверяет его аргументы и дожидается результата.
|
|
24
|
+
- **LLM-провайдер Tropass.** Список доступных моделей загружается из LLM-шлюза при запуске OpenCode. Моделью по умолчанию становится `GLM-5.2`, если она доступна, иначе первая модель из списка.
|
|
25
|
+
- **Инструкции для агента.** Установщик добавляет skills для вызова моделей и обработки текстов, графиков, медиа и вложений в их ответах.
|
|
26
|
+
- **Статистика токенов.** Команда `/usage` показывает недельный расход, остаток и время обновления лимита без запроса к LLM.
|
|
27
|
+
- **Обновления.** При запуске OpenCode плагин предлагает установить новую версию или напомнить о ней через 24 часа.
|
|
28
|
+
- **Бережная настройка.** Повторная установка обновляет интеграцию Tropass, сохраняя остальные разделы конфигурации OpenCode.
|
|
29
|
+
|
|
30
|
+
Адреса MCP- и LLM-шлюзов заполняются автоматически. При необходимости их можно переопределить флагами `--url` / `--llm-url` (или переменными окружения `TROPASS_MCP_URL` / `TROPASS_LLM_URL`).
|
|
31
|
+
|
|
32
|
+
## Установка
|
|
33
|
+
|
|
34
|
+
Глобальная установка делает Tropass доступным во всех проектах текущего пользователя:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx -y @tropass/connect@latest opencode --global
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Проектная установка настраивает только текущий рабочий каталог:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx -y @tropass/connect@latest opencode --local
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> При проектной установке `opencode.json` и `.opencode/tropass.mjs` содержат API-токен. Не добавляйте эти файлы в публичный репозиторий.
|
|
47
|
+
|
|
48
|
+
### Асинхронные задачи моделей
|
|
49
|
+
|
|
50
|
+
[uv](https://docs.astral.sh/uv/getting-started/installation/) опционален. Если команда `uvx` доступна, длительные задачи моделей запускаются асинхронно, а агент ожидает их завершения отдельным инструментом. Без `uvx` установка продолжится, а модели будут работать в синхронном режиме.
|
|
51
|
+
|
|
52
|
+
Чтобы переключиться на асинхронный режим, установите `uv`, убедитесь, что `uvx` доступен в новом терминале, и повторите установку.
|
|
53
|
+
|
|
54
|
+
Полный список параметров:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx -y @tropass/connect@latest --help
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Лицензия
|
|
61
|
+
|
|
62
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { main } from "../src/cli.js";
|
|
3
|
+
main().catch((error) => {
|
|
4
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
5
|
+
process.stderr.write(`[tropass-connect] критическая ошибка: ${detail}\n`);
|
|
6
|
+
process.exit(1);
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=tropass-connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tropass-connect.js","sourceRoot":"","sources":["../../bin/tropass-connect.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,MAAM,IAAI,CAAC,CAAC;IAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-response-display
|
|
3
|
+
description: Interpret Tropass MCP/ML agent response schemas for UI display. Use when parsing, validating, rendering, transforming, debugging, or designing frontend/backend handling for AgentResponse, AgentPanelOutput, AgentPrimaryData, AgentPlotData, descriptions, media, attachments, panel ordering, chart data, or streamed panel results.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agent Response Display
|
|
7
|
+
|
|
8
|
+
Interpret Tropass MCP/ML agent responses as ordered UI panels. Use `structuredContent` as the source of truth; use text content only as serialized fallback JSON.
|
|
9
|
+
|
|
10
|
+
## Response model
|
|
11
|
+
|
|
12
|
+
Treat `AgentResponse.panel_items` as the display surface. Each `AgentPanelOutput` is one panel:
|
|
13
|
+
|
|
14
|
+
- `ml_model_task_id`: task/group identifier for logs, tracing, and deduplication.
|
|
15
|
+
- `panel_output_name`: user-facing panel title.
|
|
16
|
+
- `panel_type`: rendering hint, not a closed enum. Always keep a generic fallback.
|
|
17
|
+
- `primary_data`: optional structured visual data.
|
|
18
|
+
- `descriptions`: ordered text blocks.
|
|
19
|
+
- `attachments`: downloadable/supporting files.
|
|
20
|
+
- `panel_show_order`: optional preferred order.
|
|
21
|
+
- `is_last_panel`: stream/completion marker, not a visual panel type.
|
|
22
|
+
|
|
23
|
+
## Panel ordering
|
|
24
|
+
|
|
25
|
+
Render panels in stable order:
|
|
26
|
+
|
|
27
|
+
1. Panels with `panel_show_order` come first, sorted ascending.
|
|
28
|
+
2. Panels with the same `panel_show_order` keep their original response order.
|
|
29
|
+
3. Panels without `panel_show_order` keep their original response order after ordered panels.
|
|
30
|
+
4. Do not use `is_last_panel` for visual sorting.
|
|
31
|
+
|
|
32
|
+
## Display mapping
|
|
33
|
+
|
|
34
|
+
Normalize panels into a frontend-friendly shape before rendering:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
type DisplayPanel = {
|
|
38
|
+
taskId: string;
|
|
39
|
+
title: string;
|
|
40
|
+
panelType: string;
|
|
41
|
+
order: number | null;
|
|
42
|
+
descriptions: DisplayDescription[];
|
|
43
|
+
chart: DisplayChart | null;
|
|
44
|
+
media: DisplayMedia[];
|
|
45
|
+
attachments: DisplayMedia[];
|
|
46
|
+
isLastPanel: boolean;
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Prefer field-preserving transforms over lossy stringification. Keep unknown fields available in debug logs when useful.
|
|
51
|
+
|
|
52
|
+
## Descriptions
|
|
53
|
+
|
|
54
|
+
Render `descriptions` in response order. Use `description_type` as a formatting hint. If the type is unknown or unsupported, render `content` as plain text. Never drop description content only because its type is unfamiliar.
|
|
55
|
+
|
|
56
|
+
## Chart data
|
|
57
|
+
|
|
58
|
+
`primary_data.plot_data` describes chart-ready data:
|
|
59
|
+
|
|
60
|
+
- `x_axis_values`: category, datetime, numeric, or mixed x-axis labels.
|
|
61
|
+
- `series_data[*].legend_name`: legend label.
|
|
62
|
+
- `series_data[*].plot_values`: numeric y-values.
|
|
63
|
+
- `x_axis_split_value`: optional grouping, split, or annotation value.
|
|
64
|
+
|
|
65
|
+
Render a chart only when at least one series has at least one numeric value. Validate every series against `x_axis_values`:
|
|
66
|
+
|
|
67
|
+
- If lengths match, render normally.
|
|
68
|
+
- If lengths differ, truncate that series to the shorter length for display and log a non-blocking diagnostic.
|
|
69
|
+
- If `x_axis_values` is empty but a series has values, generate positional labels only as a fallback.
|
|
70
|
+
- If no valid series remains, skip the chart and render other panel content.
|
|
71
|
+
|
|
72
|
+
Do not assume `x_axis_split_value` is a date. Use it only when the chart component supports a separator, marker, or grouping label.
|
|
73
|
+
|
|
74
|
+
## Media and attachments
|
|
75
|
+
|
|
76
|
+
`primary_data.media` is inline panel media. `attachments` are supporting files or downloads.
|
|
77
|
+
|
|
78
|
+
For browser UI:
|
|
79
|
+
|
|
80
|
+
- Prefer `s3_url` for display, preview, and download links.
|
|
81
|
+
- Use `file_name` as visible label or download filename.
|
|
82
|
+
- Use `mime_type` to choose image, video, audio, document, or generic file rendering.
|
|
83
|
+
- Treat `local_abs_path` as backend/internal metadata. Do not expose it as a browser URL.
|
|
84
|
+
|
|
85
|
+
If `s3_url` is missing or empty, show a disabled item or omit the preview and log diagnostics according to local product conventions.
|
|
86
|
+
|
|
87
|
+
## Fallback behavior
|
|
88
|
+
|
|
89
|
+
Never crash on partial or unfamiliar responses:
|
|
90
|
+
|
|
91
|
+
- Empty `panel_items`: show the product's empty result state.
|
|
92
|
+
- Missing `primary_data`: render descriptions and attachments.
|
|
93
|
+
- Descriptions only: render a text panel.
|
|
94
|
+
- Chart only: render a chart panel.
|
|
95
|
+
- Media only: render a media gallery.
|
|
96
|
+
- Unknown `panel_type`: render a generic panel using all available content.
|
|
97
|
+
- Empty panel content: render the title only if useful, otherwise suppress the panel and log diagnostics.
|
|
98
|
+
- Multiple `is_last_panel=true`: treat the latest received panel as the stream completion signal and log diagnostics.
|
|
99
|
+
|
|
100
|
+
## Implementation checks
|
|
101
|
+
|
|
102
|
+
When writing display code or tests, cover:
|
|
103
|
+
|
|
104
|
+
- stable `panel_show_order` sorting;
|
|
105
|
+
- unknown `panel_type` fallback;
|
|
106
|
+
- missing `primary_data`;
|
|
107
|
+
- chart x/y length mismatch;
|
|
108
|
+
- empty chart series;
|
|
109
|
+
- media and attachments using `s3_url`, not `local_abs_path`;
|
|
110
|
+
- unknown `description_type`;
|
|
111
|
+
- streamed responses where final completion is marked by `is_last_panel`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tropass-gateway
|
|
3
|
+
description: Use when calling Tropass ML models through the Tropass MCP server, selecting models, preparing model inputs, handling file URL arguments, or interpreting model results.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tropass Gateway MCP
|
|
7
|
+
|
|
8
|
+
Use the Tropass MCP server to call ML models. Model calls return a task immediately; results are fetched separately.
|
|
9
|
+
|
|
10
|
+
## Tool discovery
|
|
11
|
+
|
|
12
|
+
- Call `tools/list` only on first Tropass use in the session, when `initialize.result.capabilities.tools.listChanged` is `true`, after token/environment changes, or after an unknown tool error.
|
|
13
|
+
- Do not call `tools/list` before every model call.
|
|
14
|
+
- Do not rely on memorized tool names. Tool names are generated by the gateway.
|
|
15
|
+
|
|
16
|
+
## Tool selection
|
|
17
|
+
|
|
18
|
+
- Select models by `title`, `description`, and `inputSchema`.
|
|
19
|
+
- If several tools match equally, ask the user which model to use.
|
|
20
|
+
- If the requested model is missing, refresh the tool list once before concluding it is unavailable.
|
|
21
|
+
|
|
22
|
+
## Arguments
|
|
23
|
+
|
|
24
|
+
- Validate arguments against `inputSchema`.
|
|
25
|
+
- Send only properties defined in the schema.
|
|
26
|
+
- Required fields must be present.
|
|
27
|
+
- Respect `enum`, `minimum`, and `maximum`.
|
|
28
|
+
- For file-like inputs, pass arrays of existing Tropass/S3 file URLs.
|
|
29
|
+
- Do not pass local file paths or arbitrary external URLs as file inputs.
|
|
30
|
+
|
|
31
|
+
## Model call flow
|
|
32
|
+
|
|
33
|
+
This depends on the `Tropass-Model-Call-Version` header the installer wrote into the MCP server config.
|
|
34
|
+
|
|
35
|
+
With version `1` (synchronous, used when `uvx` is unavailable) the model tool blocks and returns the final result payload itself. There is no `task_id` and no `wait_for_model_task` tool — steps 1-4 below do not apply; read the result straight from `structuredContent`.
|
|
36
|
+
|
|
37
|
+
With version `2` (asynchronous, the default):
|
|
38
|
+
|
|
39
|
+
1. Call the model tool. The response is `structuredContent` with `{task_id, status: "distributed"}`. The model is now running.
|
|
40
|
+
2. Store `task_id` from the response.
|
|
41
|
+
3. Call the `wait_for_model_task` tool with `arguments: {task_id}`. This tool blocks until the task completes and returns the final result payload directly — no manual polling needed.
|
|
42
|
+
4. If `wait_for_model_task` returns an error, surface it to the user. Do not retry in a loop.
|
|
43
|
+
- 404: `task_id` is invalid or belongs to another user.
|
|
44
|
+
- Timeout: task did not complete within the deadline.
|
|
45
|
+
- Processing error: model execution failed.
|
|
46
|
+
|
|
47
|
+
## Results
|
|
48
|
+
|
|
49
|
+
- Prefer `structuredContent` as the source of truth.
|
|
50
|
+
- Treat text `content` as serialized fallback JSON.
|
|
51
|
+
- If `isError` is true, surface the error directly.
|
|
52
|
+
- Do not retry rate-limit errors in a loop.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function main(): Promise<void>;
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { Command, CommanderError, Help } from "commander";
|
|
3
|
+
import { TROPASS_URL } from "./constants.js";
|
|
4
|
+
import { runInstall } from "./installer.js";
|
|
5
|
+
import { logError } from "./logging.js";
|
|
6
|
+
export async function main() {
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
await runInstallCommand(args[0] === "install" ? args.slice(1) : args, "tropass-connect");
|
|
9
|
+
}
|
|
10
|
+
async function runInstallCommand(args, commandName) {
|
|
11
|
+
const command = createInstallCommand(commandName).exitOverride();
|
|
12
|
+
try {
|
|
13
|
+
await command.parseAsync(args, { from: "user" });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof CommanderError && error.exitCode === 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
logError("ошибка установки", error);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function createInstallCommand(commandName) {
|
|
24
|
+
return new Command()
|
|
25
|
+
.name(commandName)
|
|
26
|
+
.description(`Подключает агентскую среду к Tropass.\nTropass: ${TROPASS_URL}`)
|
|
27
|
+
.argument("[client]", "агентская среда: opencode")
|
|
28
|
+
.option("--config <path>", "путь к файлу конфигурации MCP")
|
|
29
|
+
.option("--url <url>", "базовый URL шлюза моделей Tropass")
|
|
30
|
+
.option("--llm-url <url>", "URL LLM-шлюза Tropass")
|
|
31
|
+
.option("--token <token>", "API-токен Tropass")
|
|
32
|
+
.option("--scope <scope>", "область установки: global или project")
|
|
33
|
+
.option("--global", "установить для текущего пользователя")
|
|
34
|
+
.option("--local", "установить для текущего проекта")
|
|
35
|
+
.option("--project <dir>", "каталог проекта для локальной конфигурации")
|
|
36
|
+
.option("-y, --yes", "принять значения по умолчанию, кроме токена")
|
|
37
|
+
.helpOption("-h, --help", "показать справку")
|
|
38
|
+
.configureHelp({
|
|
39
|
+
formatHelp: (command, helper) => new Help().formatHelp(command, helper)
|
|
40
|
+
.replace("Usage:", "Использование:")
|
|
41
|
+
.replace("Arguments:", "Аргументы:")
|
|
42
|
+
.replace("Options:", "Параметры:")
|
|
43
|
+
})
|
|
44
|
+
.action(async (client, options) => {
|
|
45
|
+
const rawOptions = { ...options };
|
|
46
|
+
if (client !== undefined) {
|
|
47
|
+
rawOptions.client = client;
|
|
48
|
+
}
|
|
49
|
+
await runInstall(rawOptions);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAA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EAAE,mBAAmB,CAAC;SAC9C,MAAM,CAAC,iBAAiB,EAAE,uCAAuC,CAAC;SAClE,MAAM,CAAC,UAAU,EAAE,sCAAsC,CAAC;SAC1D,MAAM,CAAC,SAAS,EAAE,iCAAiC,CAAC;SACpD,MAAM,CAAC,iBAAiB,EAAE,4CAA4C,CAAC;SACvE,MAAM,CAAC,WAAW,EAAE,6CAA6C,CAAC;SAClE,UAAU,CAAC,YAAY,EAAE,kBAAkB,CAAC;SAC5C,aAAa,CAAC;QACb,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC;aACpE,OAAO,CAAC,QAAQ,EAAE,gBAAgB,CAAC;aACnC,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC;aACnC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC;KACrC,CAAC;SACD,MAAM,CAAC,KAAK,EAAE,MAA0B,EAAE,OAA0B,EAAE,EAAE;QACvE,MAAM,UAAU,GAAsB,EAAE,GAAG,OAAO,EAAE,CAAC;QACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;QAC7B,CAAC;QACD,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const DEFAULT_MCP_URL = "https://\u0430\u043F\u0438.\u0442\u0440\u043E\u043F\u0430\u0441\u0441.\u0440\u0444/mcp";
|
|
2
|
+
export declare const TROPASS_URL = "https://\u0442\u0440\u043E\u043F\u0430\u0441\u0441.\u0440\u0444/";
|
|
3
|
+
export declare const LLM_GATEWAY_URL = "https://\u0430\u043F\u0438.\u043B\u043B\u043C.\u0442\u0440\u043E\u043F\u0430\u0441\u0441.\u0440\u0444/v1";
|
|
4
|
+
export declare const DEFAULT_TOKEN_HEADER = "Authorization";
|
|
5
|
+
export declare const MCP_MODEL_CALL_VERSION_HEADER = "Tropass-Model-Call-Version";
|
|
6
|
+
export declare const ASYNC_MODEL_CALL_VERSION = "2";
|
|
7
|
+
export declare const SYNC_MODEL_CALL_VERSION = "1";
|
|
8
|
+
export declare const SUPPORTED_INSTALL_CLIENTS: Set<"opencode">;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const DEFAULT_MCP_URL = "https://апи.тропасс.рф/mcp";
|
|
2
|
+
export const TROPASS_URL = "https://тропасс.рф/";
|
|
3
|
+
export const LLM_GATEWAY_URL = "https://апи.ллм.тропасс.рф/v1";
|
|
4
|
+
export const DEFAULT_TOKEN_HEADER = "Authorization";
|
|
5
|
+
export const MCP_MODEL_CALL_VERSION_HEADER = "Tropass-Model-Call-Version";
|
|
6
|
+
export const ASYNC_MODEL_CALL_VERSION = "2";
|
|
7
|
+
export const SYNC_MODEL_CALL_VERSION = "1";
|
|
8
|
+
export const SUPPORTED_INSTALL_CLIENTS = new Set(["opencode"]);
|
|
9
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,4BAA4B,CAAC;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAC;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,+BAA+B,CAAC;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;AACpD,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAgB,CAAC,UAAU,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InstallResult, InstallScope, RawInstallOptions } from "./types.js";
|
|
2
|
+
export declare function runInstall(rawOptions?: RawInstallOptions): Promise<void>;
|
|
3
|
+
export declare function installTropass(rawOptions: RawInstallOptions): InstallResult;
|
|
4
|
+
export declare function resolveDefaultScope(): InstallScope;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { ASYNC_MODEL_CALL_VERSION, DEFAULT_MCP_URL, LLM_GATEWAY_URL, SUPPORTED_INSTALL_CLIENTS, SYNC_MODEL_CALL_VERSION } from "./constants.js";
|
|
4
|
+
import { runInteractiveInstaller, writeInstallResult } from "./interactive-installer.js";
|
|
5
|
+
import { opencodeInstaller } from "./installers/opencode.js";
|
|
6
|
+
import { findUvx } from "./uvx.js";
|
|
7
|
+
import { expandHome, resolveOpenCodeConfigPath } from "./path-utils.js";
|
|
8
|
+
export async function runInstall(rawOptions = {}) {
|
|
9
|
+
const options = normalizeInstallOptions(rawOptions);
|
|
10
|
+
const client = validateInstallClient(options.client ?? "opencode");
|
|
11
|
+
const scope = options.scope !== undefined
|
|
12
|
+
? validateInstallScope(options.scope)
|
|
13
|
+
: options.yes
|
|
14
|
+
? resolveDefaultScope()
|
|
15
|
+
: undefined;
|
|
16
|
+
const interactiveOptions = await runInteractiveInstaller({
|
|
17
|
+
...options,
|
|
18
|
+
client,
|
|
19
|
+
scope
|
|
20
|
+
});
|
|
21
|
+
writeInstallResult(installTropass({
|
|
22
|
+
...options,
|
|
23
|
+
...interactiveOptions
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
export function installTropass(rawOptions) {
|
|
27
|
+
const options = validateInstallOptions(normalizeInstallOptions(rawOptions));
|
|
28
|
+
const configPath = resolveConfigPath(options);
|
|
29
|
+
opencodeInstaller.installConfig({ ...options, mcpUrl: normalizeMcpUrl(options.mcpUrl) }, configPath);
|
|
30
|
+
opencodeInstaller.installProvider(options, configPath);
|
|
31
|
+
const skillPaths = opencodeInstaller.installSkills(resolveSkillsPath(options));
|
|
32
|
+
const uvxCommand = options.uvxCommand;
|
|
33
|
+
const toolPaths = uvxCommand
|
|
34
|
+
? opencodeInstaller.installTools(resolveToolsPath(options), normalizeMcpUrl(options.mcpUrl), options.apiToken, uvxCommand)
|
|
35
|
+
: [];
|
|
36
|
+
const removedToolPaths = uvxCommand
|
|
37
|
+
? []
|
|
38
|
+
: opencodeInstaller.removeTools(resolveToolsPath(options));
|
|
39
|
+
const pluginPaths = opencodeInstaller.installPlugins(path.dirname(resolveToolsPath(options)), configPath, options);
|
|
40
|
+
return {
|
|
41
|
+
client: options.client,
|
|
42
|
+
scope: options.scope,
|
|
43
|
+
configPath,
|
|
44
|
+
skillPaths,
|
|
45
|
+
toolPaths,
|
|
46
|
+
removedToolPaths,
|
|
47
|
+
pluginPaths,
|
|
48
|
+
modelCallVersion: options.modelCallVersion,
|
|
49
|
+
...(uvxCommand && { uvxCommand })
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function normalizeInstallOptions(options) {
|
|
53
|
+
const configPath = options.config ?? options.configPath;
|
|
54
|
+
const apiToken = options.token ?? options.apiToken ?? process.env.TROPASS_API_TOKEN;
|
|
55
|
+
const scope = normalizeScopeOption(options);
|
|
56
|
+
const normalizedOptions = {
|
|
57
|
+
mcpUrl: options.url ?? options.mcpUrl ?? process.env.TROPASS_MCP_URL ?? DEFAULT_MCP_URL,
|
|
58
|
+
llmUrl: normalizeLlmUrl(options.llmUrl ?? options.llmGatewayUrl ?? process.env.TROPASS_LLM_URL ?? LLM_GATEWAY_URL),
|
|
59
|
+
projectDir: options.project ?? options.projectDir ?? process.cwd(),
|
|
60
|
+
yes: Boolean(options.yes)
|
|
61
|
+
};
|
|
62
|
+
if (options.client !== undefined) {
|
|
63
|
+
normalizedOptions.client = options.client;
|
|
64
|
+
}
|
|
65
|
+
if (configPath !== undefined) {
|
|
66
|
+
normalizedOptions.configPath = configPath;
|
|
67
|
+
}
|
|
68
|
+
if (apiToken !== undefined) {
|
|
69
|
+
normalizedOptions.apiToken = apiToken;
|
|
70
|
+
}
|
|
71
|
+
if (scope !== undefined) {
|
|
72
|
+
normalizedOptions.scope = scope;
|
|
73
|
+
}
|
|
74
|
+
const uvxCommand = options.uvxCommand ?? findUvx();
|
|
75
|
+
if (uvxCommand !== undefined) {
|
|
76
|
+
normalizedOptions.uvxCommand = uvxCommand;
|
|
77
|
+
}
|
|
78
|
+
return normalizedOptions;
|
|
79
|
+
}
|
|
80
|
+
function validateInstallOptions(options) {
|
|
81
|
+
const client = validateInstallClient(options.client ?? "opencode");
|
|
82
|
+
if (!options.apiToken) {
|
|
83
|
+
throw new Error("Необходимо указать API-токен Tropass.");
|
|
84
|
+
}
|
|
85
|
+
if (!options.mcpUrl) {
|
|
86
|
+
throw new Error("Необходимо указать URL Tropass MCP.");
|
|
87
|
+
}
|
|
88
|
+
if (!options.llmUrl) {
|
|
89
|
+
throw new Error("Необходимо указать URL Tropass LLM.");
|
|
90
|
+
}
|
|
91
|
+
const scope = validateInstallScope(options.scope ?? resolveDefaultScope());
|
|
92
|
+
return {
|
|
93
|
+
...options,
|
|
94
|
+
client,
|
|
95
|
+
apiToken: options.apiToken,
|
|
96
|
+
scope,
|
|
97
|
+
modelCallVersion: options.uvxCommand ? ASYNC_MODEL_CALL_VERSION : SYNC_MODEL_CALL_VERSION
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function validateInstallClient(value) {
|
|
101
|
+
if (isInstallClient(value)) {
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`Клиент '${value}' не поддерживается. Доступные клиенты: ${[...SUPPORTED_INSTALL_CLIENTS].join(", ")}.`);
|
|
105
|
+
}
|
|
106
|
+
function normalizeScopeOption(options) {
|
|
107
|
+
if (options.global && options.local) {
|
|
108
|
+
throw new Error("Выберите только одну область установки: --global или --local.");
|
|
109
|
+
}
|
|
110
|
+
if (options.global) {
|
|
111
|
+
return "global";
|
|
112
|
+
}
|
|
113
|
+
if (options.local) {
|
|
114
|
+
return "project";
|
|
115
|
+
}
|
|
116
|
+
return options.scope;
|
|
117
|
+
}
|
|
118
|
+
export function resolveDefaultScope() {
|
|
119
|
+
return "global";
|
|
120
|
+
}
|
|
121
|
+
function validateInstallScope(value) {
|
|
122
|
+
if (value === "project" || value === "global") {
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
if (value === "local") {
|
|
126
|
+
return "project";
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`Область установки '${value}' не поддерживается. Используйте global или project.`);
|
|
129
|
+
}
|
|
130
|
+
function isInstallClient(value) {
|
|
131
|
+
return typeof value === "string" && SUPPORTED_INSTALL_CLIENTS.has(value);
|
|
132
|
+
}
|
|
133
|
+
function stripTrailingSlashes(value) {
|
|
134
|
+
return value.replace(/\/+$/, "");
|
|
135
|
+
}
|
|
136
|
+
function normalizeMcpUrl(value) {
|
|
137
|
+
const url = stripTrailingSlashes(value);
|
|
138
|
+
return !url || url.endsWith("/mcp") ? url : `${url}/mcp`;
|
|
139
|
+
}
|
|
140
|
+
function normalizeLlmUrl(value) {
|
|
141
|
+
const url = stripTrailingSlashes(value);
|
|
142
|
+
return !url || url.endsWith("/v1") ? url : `${url}/v1`;
|
|
143
|
+
}
|
|
144
|
+
function resolveConfigPath(options) {
|
|
145
|
+
if (options.configPath) {
|
|
146
|
+
return path.resolve(expandHome(options.configPath));
|
|
147
|
+
}
|
|
148
|
+
const projectDir = path.resolve(expandHome(options.projectDir));
|
|
149
|
+
return options.scope === "global" ? resolveOpenCodeConfigPath() : path.join(projectDir, "opencode.json");
|
|
150
|
+
}
|
|
151
|
+
function resolveSkillsPath(options) {
|
|
152
|
+
const projectDir = path.resolve(expandHome(options.projectDir));
|
|
153
|
+
if (options.scope !== "global") {
|
|
154
|
+
return path.join(projectDir, ".opencode", "skills");
|
|
155
|
+
}
|
|
156
|
+
if (options.configPath) {
|
|
157
|
+
return path.join(path.dirname(path.resolve(expandHome(options.configPath))), "skills");
|
|
158
|
+
}
|
|
159
|
+
return path.join(path.dirname(resolveOpenCodeConfigPath()), "skills");
|
|
160
|
+
}
|
|
161
|
+
function resolveToolsPath(options) {
|
|
162
|
+
const projectDir = path.resolve(expandHome(options.projectDir));
|
|
163
|
+
if (options.scope !== "global") {
|
|
164
|
+
return path.join(projectDir, ".opencode", "tools");
|
|
165
|
+
}
|
|
166
|
+
if (options.configPath) {
|
|
167
|
+
return path.join(path.dirname(path.resolve(expandHome(options.configPath))), "tools");
|
|
168
|
+
}
|
|
169
|
+
return path.join(path.dirname(resolveOpenCodeConfigPath()), "tools");
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=installer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/installer.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,UAAU,EACV,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAUzB,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,aAAgC,EAAE;IACjE,MAAM,OAAO,GAAG,uBAAuB,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,qBAAqB,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,KAAK,SAAS;QACv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O,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgC;IACxD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAChE,IAAI,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import childProcess from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
import { commandExists, describeSpawnFailure } from "../spawn.js";
|
|
6
|
+
export function runAgentCli(args, options = {}) {
|
|
7
|
+
const cwd = options.cwd ?? process.cwd();
|
|
8
|
+
const { command, commandArgs } = resolveCommand(args);
|
|
9
|
+
const result = childProcess.spawnSync(command, commandArgs, {
|
|
10
|
+
cwd,
|
|
11
|
+
env: options.env ? { ...process.env, ...options.env } : process.env,
|
|
12
|
+
encoding: "utf8",
|
|
13
|
+
stdio: "pipe",
|
|
14
|
+
});
|
|
15
|
+
if (result.status === 0) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`Ошибка opencode CLI: ${describeSpawnFailure(result)}`);
|
|
19
|
+
}
|
|
20
|
+
function resolveCommand(args) {
|
|
21
|
+
if (commandExists("opencode")) {
|
|
22
|
+
return { command: "opencode", commandArgs: args };
|
|
23
|
+
}
|
|
24
|
+
const localCommand = path.resolve("node_modules", ".bin", process.platform === "win32" ? "opencode.cmd" : "opencode");
|
|
25
|
+
if (fs.existsSync(localCommand) && process.platform !== "win32") {
|
|
26
|
+
return { command: localCommand, commandArgs: args };
|
|
27
|
+
}
|
|
28
|
+
if (process.platform === "win32") {
|
|
29
|
+
const npxCli = path.join(path.dirname(process.execPath), "node_modules", "npm", "bin", "npx-cli.js");
|
|
30
|
+
if (!fs.existsSync(npxCli)) {
|
|
31
|
+
throw new Error(`Не найден npx-cli.js: ${npxCli}`);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
command: process.execPath,
|
|
35
|
+
commandArgs: [npxCli, "-y", "opencode-ai@latest", ...args],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { command: "npx", commandArgs: ["-y", "opencode-ai@latest", ...args] };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/installers/cli.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAC,aAAa,EAAE,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAOhE,MAAM,UAAU,WAAW,CACzB,IAAc,EACd,UAA8B,EAAE;IAEhC,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