@joingonka/setup 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +46 -0
- package/dist/adapters/claude-code.d.ts +3 -0
- package/dist/adapters/claude-code.d.ts.map +1 -0
- package/dist/adapters/claude-code.js +70 -0
- package/dist/adapters/claude-code.js.map +1 -0
- package/dist/adapters/cline.d.ts +3 -0
- package/dist/adapters/cline.d.ts.map +1 -0
- package/dist/adapters/cline.js +43 -0
- package/dist/adapters/cline.js.map +1 -0
- package/dist/adapters/openclaw.d.ts +3 -0
- package/dist/adapters/openclaw.d.ts.map +1 -0
- package/dist/adapters/openclaw.js +159 -0
- package/dist/adapters/openclaw.js.map +1 -0
- package/dist/adapters/registry.d.ts +24 -0
- package/dist/adapters/registry.d.ts.map +1 -0
- package/dist/adapters/registry.js +25 -0
- package/dist/adapters/registry.js.map +1 -0
- package/dist/adapters/types.d.ts +51 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +10 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +55 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.d.ts +98 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +117 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/fs-ops.d.ts +28 -0
- package/dist/core/fs-ops.d.ts.map +1 -0
- package/dist/core/fs-ops.js +63 -0
- package/dist/core/fs-ops.js.map +1 -0
- package/dist/core/merge.d.ts +62 -0
- package/dist/core/merge.d.ts.map +1 -0
- package/dist/core/merge.js +98 -0
- package/dist/core/merge.js.map +1 -0
- package/dist/core/prompt.d.ts +8 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +29 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/validate.d.ts +12 -0
- package/dist/core/validate.d.ts.map +1 -0
- package/dist/core/validate.js +22 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/run.d.ts +24 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +65 -0
- package/dist/run.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 JoinGonka
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @joingonka/setup
|
|
2
|
+
|
|
3
|
+
Установщик «в одну команду», настраивающий агентные AI-инструменты на [JoinGonka Gateway](https://gate.joingonka.ai) — децентрализованный AI-инференс сети Gonka.
|
|
4
|
+
|
|
5
|
+
Поддерживаемые инструменты:
|
|
6
|
+
|
|
7
|
+
| Инструмент | Формат | Куда пишет |
|
|
8
|
+
|--------------|----------------------|---------------------------------------------|
|
|
9
|
+
| Claude Code | JSON | `~/.claude/settings.json` (или local) |
|
|
10
|
+
| OpenClaw | YAML | `~/.openclaw/config.yaml` |
|
|
11
|
+
| Cline | инструкции (UI) | ничего не пишет — выводит значения для ввода |
|
|
12
|
+
|
|
13
|
+
## Использование
|
|
14
|
+
|
|
15
|
+
Интерактивно:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @joingonka/setup
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Установщик спросит инструмент и API-ключ (`jg-...`), сделает бэкап существующего конфига и аккуратно допишет только нужные поля, сохранив ваши настройки.
|
|
22
|
+
|
|
23
|
+
Неинтерактивно (ключ — только через переменную окружения, никогда аргументом):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
JOINGONKA_API_KEY=jg-your-key npx @joingonka/setup --tool openclaw --non-interactive
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Опции
|
|
30
|
+
|
|
31
|
+
- `--tool <claude-code|openclaw|cline>` — какой инструмент настроить (без флага спросит интерактивно).
|
|
32
|
+
- `--scope <user|local>` — глобально (`user`, по умолчанию) или в текущем проекте (`local`).
|
|
33
|
+
- `--model <id|kimi>` — модель: по умолчанию Qwen3-235B, `kimi` → Kimi K2.6, либо явный id модели.
|
|
34
|
+
- `--non-interactive` — без промптов; ключ берётся из `JOINGONKA_API_KEY`.
|
|
35
|
+
|
|
36
|
+
## Где взять ключ
|
|
37
|
+
|
|
38
|
+
Зарегистрируйтесь на [gate.joingonka.ai/register](https://gate.joingonka.ai/register), получите бесплатные токены на тест и скопируйте ключ (`jg-...`) из Dashboard.
|
|
39
|
+
|
|
40
|
+
## Безопасность
|
|
41
|
+
|
|
42
|
+
API-ключ не принимается аргументом командной строки (он попал бы в историю shell и в список процессов). Только password-промпт или переменная окружения `JOINGONKA_API_KEY`.
|
|
43
|
+
|
|
44
|
+
## Лицензия
|
|
45
|
+
|
|
46
|
+
Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.d.ts","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAkC,MAAM,YAAY,CAAC;AAkD1E,eAAO,MAAM,iBAAiB,EAAE,OAM/B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Адаптер Claude Code — JSON-конфиг.
|
|
3
|
+
*
|
|
4
|
+
* Цель: прописать в settings.json две переменные окружения, которые
|
|
5
|
+
* перенаправляют Claude Code на JoinGonka Gateway:
|
|
6
|
+
* env.ANTHROPIC_AUTH_TOKEN — наш jg-ключ
|
|
7
|
+
* env.ANTHROPIC_BASE_URL — BASE_URL (БЕЗ /v1; Claude сам добавит /v1/messages)
|
|
8
|
+
*
|
|
9
|
+
* Имя именно ANTHROPIC_AUTH_TOKEN (не _API_KEY) — паритет с уже
|
|
10
|
+
* опубликованным пакетом @joingonka/claude-code. НЕ менять.
|
|
11
|
+
*
|
|
12
|
+
* Пути:
|
|
13
|
+
* user → ~/.claude/settings.json
|
|
14
|
+
* local → <cwd>/.claude/settings.local.json
|
|
15
|
+
*/
|
|
16
|
+
import { join } from 'node:path';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
import { BASE_URL } from '../constants.js';
|
|
19
|
+
import { readRaw, backup, atomicWrite } from '../core/fs-ops.js';
|
|
20
|
+
import { mergeJson } from '../core/merge.js';
|
|
21
|
+
/** Разрешение пути: homedir()/cwd() читаются В МОМЕНТ ВЫЗОВА (тесты подменяют HOME/cwd). */
|
|
22
|
+
function resolvePath(scope) {
|
|
23
|
+
if (scope === 'user') {
|
|
24
|
+
return join(homedir(), '.claude', 'settings.json');
|
|
25
|
+
}
|
|
26
|
+
return join(process.cwd(), '.claude', 'settings.local.json');
|
|
27
|
+
}
|
|
28
|
+
async function apply(input) {
|
|
29
|
+
const configPath = resolvePath(input.scope);
|
|
30
|
+
// Читаем существующее (если есть) и бэкапим перед перезаписью.
|
|
31
|
+
// Бэкап делаем ВСЕГДА при наличии файла — даже если JSON битый,
|
|
32
|
+
// чтобы пользователь не потерял свои данные безвозвратно.
|
|
33
|
+
const raw = readRaw(configPath);
|
|
34
|
+
const backupPath = backup(configPath);
|
|
35
|
+
let existing = {};
|
|
36
|
+
if (raw != null) {
|
|
37
|
+
try {
|
|
38
|
+
existing = JSON.parse(raw);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Битый JSON → стартуем со свежего объекта (mergeJson отбросит не-объект)
|
|
42
|
+
existing = {};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const merged = mergeJson(existing, {
|
|
46
|
+
env: {
|
|
47
|
+
ANTHROPIC_AUTH_TOKEN: input.apiKey,
|
|
48
|
+
ANTHROPIC_BASE_URL: BASE_URL,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
await atomicWrite(configPath, JSON.stringify(merged, null, 2) + '\n');
|
|
52
|
+
return {
|
|
53
|
+
configPath,
|
|
54
|
+
backupPath,
|
|
55
|
+
wrote: true,
|
|
56
|
+
messages: [
|
|
57
|
+
`Configured ${configPath}`,
|
|
58
|
+
`Base URL: ${BASE_URL}`,
|
|
59
|
+
'Restart Claude Code to apply the new configuration.',
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export const claudeCodeAdapter = {
|
|
64
|
+
id: 'claude-code',
|
|
65
|
+
label: 'Claude Code (Anthropic API)',
|
|
66
|
+
format: 'json',
|
|
67
|
+
resolvePath,
|
|
68
|
+
apply,
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=claude-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code.js","sourceRoot":"","sources":["../../src/adapters/claude-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,4FAA4F;AAC5F,SAAS,WAAW,CAAC,KAAY;IAC/B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,qBAAqB,CAAC,CAAC;AAC/D,CAAC;AAED,KAAK,U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AAkC,MAAM,YAAY,CAAC;AAwB1E,eAAO,MAAM,YAAY,EAAE,OAM1B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Адаптер Cline — instructions-only.
|
|
3
|
+
*
|
|
4
|
+
* Cline настраивается через UI расширения VS Code (панель API Configuration),
|
|
5
|
+
* а не через файл конфигурации на диске, который мы могли бы безопасно
|
|
6
|
+
* редактировать. Поэтому адаптер ничего не пишет: resolvePath()→null,
|
|
7
|
+
* apply() возвращает wrote:false и готовые значения для ручного ввода.
|
|
8
|
+
*
|
|
9
|
+
* Значения — для варианта «OpenAI Compatible» (рекомендуемый в knowledge):
|
|
10
|
+
* API Provider: OpenAI Compatible
|
|
11
|
+
* Base URL: BASE_URL_OPENAI (С /v1)
|
|
12
|
+
* API Key: <jg-ключ>
|
|
13
|
+
* Model ID: <модель>
|
|
14
|
+
*/
|
|
15
|
+
import { BASE_URL_OPENAI } from '../constants.js';
|
|
16
|
+
/** Cline не пишет файл — путь всегда null. */
|
|
17
|
+
function resolvePath(_scope) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
async function apply(input) {
|
|
21
|
+
return {
|
|
22
|
+
configPath: null,
|
|
23
|
+
backupPath: null,
|
|
24
|
+
wrote: false,
|
|
25
|
+
messages: [
|
|
26
|
+
'Cline is configured in the VS Code extension UI (no file is written).',
|
|
27
|
+
'Open the Cline panel → Settings (gear) → API Configuration and set:',
|
|
28
|
+
' API Provider: OpenAI Compatible',
|
|
29
|
+
` Base URL: ${BASE_URL_OPENAI}`,
|
|
30
|
+
` API Key: ${input.apiKey}`,
|
|
31
|
+
` Model ID: ${input.model}`,
|
|
32
|
+
'Then click "Test connection" — it should pass in 1-3 seconds.',
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export const clineAdapter = {
|
|
37
|
+
id: 'cline',
|
|
38
|
+
label: 'Cline (VS Code, OpenAI-compatible)',
|
|
39
|
+
format: 'instructions',
|
|
40
|
+
resolvePath,
|
|
41
|
+
apply,
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=cline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cline.js","sourceRoot":"","sources":["../../src/adapters/cline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,8CAA8C;AAC9C,SAAS,WAAW,CAAC,MAAa;IAChC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,KAAK,UAAU,KAAK,CAAC,KAAiB;IACpC,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE;YACR,uEAAuE;YACvE,qEAAqE;YACrE,mCAAmC;YACnC,mBAAmB,eAAe,EAAE;YACpC,mBAAmB,KAAK,CAAC,MAAM,EAAE;YACjC,mBAAmB,KAAK,CAAC,KAAK,EAAE;YAChC,+DAA+D;SAChE;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAY;IACnC,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,oCAAoC;IAC3C,MAAM,EAAE,cAAc;IACtB,WAAW;IACX,KAAK;CACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw.d.ts","sourceRoot":"","sources":["../../src/adapters/openclaw.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAE,OAAO,EAAkC,MAAM,YAAY,CAAC;AAuI1E,eAAO,MAAM,eAAe,EAAE,OAM7B,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Адаптер OpenClaw — JSON-конфиг ~/.openclaw/openclaw.json.
|
|
3
|
+
*
|
|
4
|
+
* Реальный OpenClaw хранит конфигурацию в JSON с вложенной структурой:
|
|
5
|
+
* models.providers.<id> — каталог провайдеров (baseUrl/api/apiKey/models[])
|
|
6
|
+
* agents.defaults — primary-модель и алиасы (agents.defaults.models)
|
|
7
|
+
*
|
|
8
|
+
* Что прописываем (провайдер `gonka`, OpenAI-режим через /v1/chat/completions):
|
|
9
|
+
* models.providers.gonka = {
|
|
10
|
+
* baseUrl: BASE_URL_OPENAI (С /v1 — OpenAI-совместимый клиент),
|
|
11
|
+
* api: "openai-completions",
|
|
12
|
+
* apiKey: "GONKA_API_KEY" // ← ИМЯ env-переменной, НЕ сам секрет
|
|
13
|
+
* models: [ 6 записей: 3 базовых + 3 :online ]
|
|
14
|
+
* }
|
|
15
|
+
* (поле `auth` НЕ пишем — как GonkaGate в OpenAI-режиме)
|
|
16
|
+
* agents.defaults.model.primary = "gonka/moonshotai/Kimi-K2.6" (только если не задан)
|
|
17
|
+
* agents.defaults.models[<ref>] = { alias } для трёх базовых моделей
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ Безопасность: реальный ключ jg-... в файл НЕ пишется. В конфиг идёт лишь
|
|
20
|
+
* ИМЯ переменной окружения (GONKA_API_KEY), а пользователю возвращается
|
|
21
|
+
* инструкция `export GONKA_API_KEY=jg-...`. Так секрет не оседает на диске
|
|
22
|
+
* в общедоступном (для процессов пользователя) JSON.
|
|
23
|
+
*
|
|
24
|
+
* Слияние НЕ разрушает чужие данные: другие провайдеры, чужие поля внутри
|
|
25
|
+
* нашего провайдера, чужие алиасы и пользовательский primary сохраняются
|
|
26
|
+
* (deepMergeJson + upsertById, primary ставится только при отсутствии).
|
|
27
|
+
*
|
|
28
|
+
* Путь один для обоих scope: OpenClaw читает глобальный конфиг. Env
|
|
29
|
+
* OPENCLAW_CONFIG_PATH (если задан) переопределяет путь.
|
|
30
|
+
*/
|
|
31
|
+
import { join } from 'node:path';
|
|
32
|
+
import { homedir } from 'node:os';
|
|
33
|
+
import { BASE_URL_OPENAI, OPENCLAW_PROVIDER_ID, OPENCLAW_PROVIDER_API, OPENCLAW_API_KEY_ENV, OPENCLAW_MODELS, OPENCLAW_DEFAULT_PRIMARY, openclawModelEntry, openclawModelRef, } from '../constants.js';
|
|
34
|
+
import { readRaw, backup, atomicWrite } from '../core/fs-ops.js';
|
|
35
|
+
import { deepMergeJson, upsertById } from '../core/merge.js';
|
|
36
|
+
/** Права на файл конфига — только владелец (rw-------). */
|
|
37
|
+
const OWNER_ONLY_MODE = 0o600;
|
|
38
|
+
/**
|
|
39
|
+
* Разрешение пути:
|
|
40
|
+
* 1. env OPENCLAW_CONFIG_PATH (trim, непустой) — приоритет;
|
|
41
|
+
* 2. иначе ~/.openclaw/openclaw.json.
|
|
42
|
+
* homedir()/env читаются В МОМЕНТ ВЫЗОВА (тесты подменяют HOME/env).
|
|
43
|
+
*/
|
|
44
|
+
function resolvePath(_scope) {
|
|
45
|
+
const fromEnv = process.env.OPENCLAW_CONFIG_PATH;
|
|
46
|
+
if (typeof fromEnv === 'string' && fromEnv.trim() !== '') {
|
|
47
|
+
return fromEnv.trim();
|
|
48
|
+
}
|
|
49
|
+
return join(homedir(), '.openclaw', 'openclaw.json');
|
|
50
|
+
}
|
|
51
|
+
/** Безопасный доступ к вложенному plain-объекту (undefined, если не объект). */
|
|
52
|
+
function asObject(value) {
|
|
53
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
54
|
+
? value
|
|
55
|
+
: undefined;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Строит итоговый конфиг из существующего объекта, не разрушая чужие данные.
|
|
59
|
+
*
|
|
60
|
+
* Шаги:
|
|
61
|
+
* - upsert наших 6 моделей в существующий models[] провайдера gonka по id;
|
|
62
|
+
* - deep-merge провайдера gonka (baseUrl/api/apiKey + смерженный models);
|
|
63
|
+
* - deep-merge алиасов в agents.defaults.models;
|
|
64
|
+
* - primary в agents.defaults.model.primary — ТОЛЬКО если ещё не задан.
|
|
65
|
+
*/
|
|
66
|
+
function buildConfig(existing) {
|
|
67
|
+
// 1. Каталог моделей: стартуем с существующего массива провайдера (если есть)
|
|
68
|
+
// и upsert-им наши записи по id — повторный apply не плодит дубли.
|
|
69
|
+
const existingProvider = asObject(asObject(asObject(existing.models)?.providers)?.[OPENCLAW_PROVIDER_ID]);
|
|
70
|
+
const existingModels = Array.isArray(existingProvider?.models)
|
|
71
|
+
? existingProvider.models
|
|
72
|
+
: [];
|
|
73
|
+
let models = existingModels;
|
|
74
|
+
for (const spec of OPENCLAW_MODELS) {
|
|
75
|
+
models = upsertById(models, { id: spec.id, ...openclawModelEntry(spec) });
|
|
76
|
+
}
|
|
77
|
+
// 2. Патч провайдера + агентов (deep-merge сохранит чужие провайдеры/алиасы).
|
|
78
|
+
const patch = {
|
|
79
|
+
models: {
|
|
80
|
+
providers: {
|
|
81
|
+
[OPENCLAW_PROVIDER_ID]: {
|
|
82
|
+
baseUrl: BASE_URL_OPENAI,
|
|
83
|
+
api: OPENCLAW_PROVIDER_API,
|
|
84
|
+
// apiKey = ИМЯ env-переменной (НЕ секрет): см. шапку файла.
|
|
85
|
+
// Поле `auth` намеренно не пишем (OpenAI-режим, как GonkaGate).
|
|
86
|
+
apiKey: OPENCLAW_API_KEY_ENV,
|
|
87
|
+
models,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
agents: {
|
|
92
|
+
defaults: {
|
|
93
|
+
models: Object.fromEntries(OPENCLAW_MODELS.filter((m) => m.aliasFor).map((m) => [
|
|
94
|
+
openclawModelRef(m.id),
|
|
95
|
+
{ alias: m.aliasFor },
|
|
96
|
+
])),
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
const merged = deepMergeJson(existing, patch);
|
|
101
|
+
// 3. primary — только если пользователь ещё не задал свой.
|
|
102
|
+
const defaults = asObject(asObject(merged.agents)?.defaults) ?? {};
|
|
103
|
+
const modelBlock = asObject(defaults.model) ?? {};
|
|
104
|
+
if (typeof modelBlock.primary !== 'string' || modelBlock.primary.trim() === '') {
|
|
105
|
+
const agents = asObject(merged.agents) ?? {};
|
|
106
|
+
merged.agents = {
|
|
107
|
+
...agents,
|
|
108
|
+
defaults: {
|
|
109
|
+
...defaults,
|
|
110
|
+
model: { ...modelBlock, primary: OPENCLAW_DEFAULT_PRIMARY },
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return merged;
|
|
115
|
+
}
|
|
116
|
+
async function apply(input) {
|
|
117
|
+
const configPath = resolvePath(input.scope);
|
|
118
|
+
// Читаем существующее (если есть) и бэкапим ВСЕГДА при наличии файла —
|
|
119
|
+
// даже если JSON битый, чтобы пользователь не потерял данные безвозвратно.
|
|
120
|
+
const raw = readRaw(configPath);
|
|
121
|
+
const backupPath = backup(configPath);
|
|
122
|
+
let existing = {};
|
|
123
|
+
if (raw != null) {
|
|
124
|
+
try {
|
|
125
|
+
const parsed = JSON.parse(raw);
|
|
126
|
+
existing = asObject(parsed) ?? {};
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// Битый JSON → стартуем со свежего объекта (бэкап уже сделан).
|
|
130
|
+
existing = {};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const config = buildConfig(existing);
|
|
134
|
+
// Записываем с правами 0o600 (в файле — имена env, но конфиг приватный).
|
|
135
|
+
await atomicWrite(configPath, JSON.stringify(config, null, 2) + '\n', OWNER_ONLY_MODE);
|
|
136
|
+
return {
|
|
137
|
+
configPath,
|
|
138
|
+
backupPath,
|
|
139
|
+
wrote: true,
|
|
140
|
+
messages: [
|
|
141
|
+
`Configured ${configPath}`,
|
|
142
|
+
`Base URL: ${BASE_URL_OPENAI}`,
|
|
143
|
+
`Default model: ${OPENCLAW_DEFAULT_PRIMARY}`,
|
|
144
|
+
'',
|
|
145
|
+
'Your API key is read from an environment variable (not stored in the config).',
|
|
146
|
+
`Set it in your shell, then restart OpenClaw:`,
|
|
147
|
+
` export ${OPENCLAW_API_KEY_ENV}=${input.apiKey}`,
|
|
148
|
+
`To persist it, add that line to your ~/.bashrc or ~/.zshrc.`,
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export const openclawAdapter = {
|
|
153
|
+
id: 'openclaw',
|
|
154
|
+
label: 'OpenClaw (OpenAI-compatible)',
|
|
155
|
+
format: 'json',
|
|
156
|
+
resolvePath,
|
|
157
|
+
apply,
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=openclaw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw.js","sourceRoot":"","sources":["../../src/adapters/openclaw.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAG9E,2DAA2D;AAC3D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B;;;;;GAKG;AACH,SAAS,WAAW,CAAC,MAAa;IAChC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IACjD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AAED,gFAAgF;AAChF,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,O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QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,+DAA+D;YAC/D,QAAQ,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAErC,yEAAyE;IACzE,MAAM,WAAW,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,CAAC;IAEvF,OAAO;QACL,UAAU;QACV,UAAU;QACV,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE;YACR,cAAc,UAAU,EAAE;YAC1B,aAAa,eAAe,EAAE;YAC9B,kBAAkB,wBAAwB,EAAE;YAC5C,EAAE;YACF,+EAA+E;YAC/E,8CAA8C;YAC9C,YAAY,oBAAoB,IAAI,KAAK,CAAC,MAAM,EAAE;YAClD,6DAA6D;SAC9D;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAY;IACtC,EAAE,EAAE,UAAU;IACd,KAAK,EAAE,8BAA8B;IACrC,MAAM,EAAE,MAAM;IACd,WAAW;IACX,KAAK;CACN,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Реестр адаптеров — единая точка регистрации поддерживаемых инструментов.
|
|
3
|
+
*
|
|
4
|
+
* Оркестратор (run.ts) и CLI обращаются к инструментам только через этот
|
|
5
|
+
* реестр: getAdapter(id) для выбранного инструмента, listTools() для меню.
|
|
6
|
+
* Добавить инструмент = импортировать его адаптер и дописать в `adapters`.
|
|
7
|
+
*/
|
|
8
|
+
import type { Adapter } from './types.js';
|
|
9
|
+
/** Идентификаторы поддерживаемых инструментов. */
|
|
10
|
+
export type ToolId = 'claude-code' | 'openclaw' | 'cline';
|
|
11
|
+
/** Карта id → адаптер. */
|
|
12
|
+
export declare const adapters: Record<ToolId, Adapter>;
|
|
13
|
+
/**
|
|
14
|
+
* Возвращает адаптер по id или undefined, если id неизвестен.
|
|
15
|
+
* Вызывающий код сам решает, как реагировать на undefined
|
|
16
|
+
* (CLI — внятная ошибка со списком допустимых значений).
|
|
17
|
+
*/
|
|
18
|
+
export declare function getAdapter(id: string): Adapter | undefined;
|
|
19
|
+
/** Список инструментов для меню выбора: { value, name }. */
|
|
20
|
+
export declare function listTools(): Array<{
|
|
21
|
+
value: ToolId;
|
|
22
|
+
name: string;
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/adapters/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAK1C,kDAAkD;AAClD,MAAM,MAAM,MAAM,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1D,0BAA0B;AAC1B,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAI5C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE1D;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,IAAI,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAKlE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { claudeCodeAdapter } from './claude-code.js';
|
|
2
|
+
import { openclawAdapter } from './openclaw.js';
|
|
3
|
+
import { clineAdapter } from './cline.js';
|
|
4
|
+
/** Карта id → адаптер. */
|
|
5
|
+
export const adapters = {
|
|
6
|
+
'claude-code': claudeCodeAdapter,
|
|
7
|
+
openclaw: openclawAdapter,
|
|
8
|
+
cline: clineAdapter,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Возвращает адаптер по id или undefined, если id неизвестен.
|
|
12
|
+
* Вызывающий код сам решает, как реагировать на undefined
|
|
13
|
+
* (CLI — внятная ошибка со списком допустимых значений).
|
|
14
|
+
*/
|
|
15
|
+
export function getAdapter(id) {
|
|
16
|
+
return adapters[id];
|
|
17
|
+
}
|
|
18
|
+
/** Список инструментов для меню выбора: { value, name }. */
|
|
19
|
+
export function listTools() {
|
|
20
|
+
return Object.keys(adapters).map((id) => ({
|
|
21
|
+
value: id,
|
|
22
|
+
name: adapters[id].label,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/adapters/registry.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK1C,0BAA0B;AAC1B,MAAM,CAAC,MAAM,QAAQ,GAA4B;IAC/C,aAAa,EAAE,iBAAiB;IAChC,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,YAAY;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,QAAQ,CAAC,EAAY,CAAC,CAAC;AAChC,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,SAAS;IACvB,OAAQ,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACtD,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK;KACzB,CAAC,CAAC,CAAC;AACN,CAAC"}
|