theclawbay 0.3.21 → 0.3.23
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/dist/commands/logout.js +9 -15
- package/dist/commands/setup.js +43 -19
- package/package.json +1 -1
package/dist/commands/logout.js
CHANGED
|
@@ -13,22 +13,20 @@ const codex_model_cache_migration_1 = require("../lib/codex-model-cache-migratio
|
|
|
13
13
|
const paths_1 = require("../lib/config/paths");
|
|
14
14
|
const OPENAI_PROVIDER_ID = "openai";
|
|
15
15
|
const DEFAULT_PROVIDER_ID = "theclawbay";
|
|
16
|
-
const LEGACY_PROVIDER_ID = "codex-lb";
|
|
17
16
|
const WAN_PROVIDER_ID = "theclawbay-wan";
|
|
18
17
|
const MANAGED_START = "# theclawbay-managed:start";
|
|
19
18
|
const MANAGED_END = "# theclawbay-managed:end";
|
|
20
19
|
const SHELL_START = "# theclawbay-shell-managed:start";
|
|
21
20
|
const SHELL_END = "# theclawbay-shell-managed:end";
|
|
22
21
|
const ENV_FILE = node_path_1.default.join(node_os_1.default.homedir(), ".config", "theclawbay", "env");
|
|
23
|
-
const ENV_KEY_NAME = "
|
|
22
|
+
const ENV_KEY_NAME = "THECLAWBAY_API_KEY";
|
|
24
23
|
const MIGRATION_STATE_FILE = node_path_1.default.join(paths_1.codexDir, "theclawbay.migration.json");
|
|
25
24
|
const HISTORY_PROVIDER_NEUTRALIZE_SOURCES = new Set([
|
|
26
25
|
OPENAI_PROVIDER_ID,
|
|
27
26
|
WAN_PROVIDER_ID,
|
|
28
27
|
DEFAULT_PROVIDER_ID,
|
|
29
|
-
LEGACY_PROVIDER_ID,
|
|
30
28
|
]);
|
|
31
|
-
const HISTORY_PROVIDER_DB_MIGRATE_SOURCES = [DEFAULT_PROVIDER_ID, WAN_PROVIDER_ID
|
|
29
|
+
const HISTORY_PROVIDER_DB_MIGRATE_SOURCES = [DEFAULT_PROVIDER_ID, WAN_PROVIDER_ID];
|
|
32
30
|
const TRAE_PATCH_MARKER = "theclawbay-trae-patch";
|
|
33
31
|
const TRAE_BUNDLE_BACKUP_SUFFIX = ".theclawbay-managed-backup";
|
|
34
32
|
function removeManagedBlock(source, start, end) {
|
|
@@ -74,7 +72,7 @@ function removeTopLevelProviderSelection(source) {
|
|
|
74
72
|
filtered.push(line);
|
|
75
73
|
continue;
|
|
76
74
|
}
|
|
77
|
-
if (match[1] === DEFAULT_PROVIDER_ID
|
|
75
|
+
if (match[1] === DEFAULT_PROVIDER_ID)
|
|
78
76
|
continue;
|
|
79
77
|
filtered.push(line);
|
|
80
78
|
}
|
|
@@ -135,7 +133,6 @@ async function cleanupCodexConfig() {
|
|
|
135
133
|
let next = existing;
|
|
136
134
|
next = removeManagedBlock(next, MANAGED_START, MANAGED_END);
|
|
137
135
|
next = removeProviderTable(next, DEFAULT_PROVIDER_ID);
|
|
138
|
-
next = removeProviderTable(next, LEGACY_PROVIDER_ID);
|
|
139
136
|
next = removeTopLevelProviderSelection(next);
|
|
140
137
|
return writeIfChanged(configPath, next, existing);
|
|
141
138
|
}
|
|
@@ -181,7 +178,7 @@ async function cleanupOpenClawConfig() {
|
|
|
181
178
|
let changed = false;
|
|
182
179
|
const modelsRoot = objectRecordOr(doc.models, {});
|
|
183
180
|
const providersRoot = objectRecordOr(modelsRoot.providers, {});
|
|
184
|
-
for (const id of [DEFAULT_PROVIDER_ID
|
|
181
|
+
for (const id of [DEFAULT_PROVIDER_ID]) {
|
|
185
182
|
if (id in providersRoot) {
|
|
186
183
|
delete providersRoot[id];
|
|
187
184
|
changed = true;
|
|
@@ -193,8 +190,7 @@ async function cleanupOpenClawConfig() {
|
|
|
193
190
|
const defaultsRoot = objectRecordOr(agentsRoot.defaults, {});
|
|
194
191
|
const modelRoot = objectRecordOr(defaultsRoot.model, {});
|
|
195
192
|
const primary = modelRoot.primary;
|
|
196
|
-
if (typeof primary === "string" &&
|
|
197
|
-
(primary.startsWith(`${DEFAULT_PROVIDER_ID}/`) || primary.startsWith(`${LEGACY_PROVIDER_ID}/`))) {
|
|
193
|
+
if (typeof primary === "string" && primary.startsWith(`${DEFAULT_PROVIDER_ID}/`)) {
|
|
198
194
|
delete modelRoot.primary;
|
|
199
195
|
changed = true;
|
|
200
196
|
}
|
|
@@ -220,7 +216,7 @@ async function cleanupOpenCodeConfig() {
|
|
|
220
216
|
}
|
|
221
217
|
let changed = false;
|
|
222
218
|
const providerRoot = objectRecordOr(doc.provider, {});
|
|
223
|
-
for (const id of [DEFAULT_PROVIDER_ID
|
|
219
|
+
for (const id of [DEFAULT_PROVIDER_ID]) {
|
|
224
220
|
if (id in providerRoot) {
|
|
225
221
|
delete providerRoot[id];
|
|
226
222
|
changed = true;
|
|
@@ -228,8 +224,7 @@ async function cleanupOpenCodeConfig() {
|
|
|
228
224
|
}
|
|
229
225
|
doc.provider = providerRoot;
|
|
230
226
|
const model = doc.model;
|
|
231
|
-
if (typeof model === "string" &&
|
|
232
|
-
(model.startsWith(`${DEFAULT_PROVIDER_ID}/`) || model.startsWith(`${LEGACY_PROVIDER_ID}/`))) {
|
|
227
|
+
if (typeof model === "string" && model.startsWith(`${DEFAULT_PROVIDER_ID}/`)) {
|
|
233
228
|
delete doc.model;
|
|
234
229
|
changed = true;
|
|
235
230
|
}
|
|
@@ -252,7 +247,7 @@ async function cleanupKiloConfig() {
|
|
|
252
247
|
}
|
|
253
248
|
let changed = false;
|
|
254
249
|
const providerRoot = objectRecordOr(doc.provider, {});
|
|
255
|
-
for (const id of [DEFAULT_PROVIDER_ID
|
|
250
|
+
for (const id of [DEFAULT_PROVIDER_ID]) {
|
|
256
251
|
if (id in providerRoot) {
|
|
257
252
|
delete providerRoot[id];
|
|
258
253
|
changed = true;
|
|
@@ -260,8 +255,7 @@ async function cleanupKiloConfig() {
|
|
|
260
255
|
}
|
|
261
256
|
doc.provider = providerRoot;
|
|
262
257
|
const model = doc.model;
|
|
263
|
-
if (typeof model === "string" &&
|
|
264
|
-
(model.startsWith(`${DEFAULT_PROVIDER_ID}/`) || model.startsWith(`${LEGACY_PROVIDER_ID}/`))) {
|
|
258
|
+
if (typeof model === "string" && model.startsWith(`${DEFAULT_PROVIDER_ID}/`)) {
|
|
265
259
|
delete doc.model;
|
|
266
260
|
changed = true;
|
|
267
261
|
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
6
7
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
7
8
|
const node_os_1 = __importDefault(require("node:os"));
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -19,7 +20,6 @@ const config_1 = require("../lib/managed/config");
|
|
|
19
20
|
const errors_1 = require("../lib/managed/errors");
|
|
20
21
|
const DEFAULT_BACKEND_URL = "https://theclawbay.com";
|
|
21
22
|
const DEFAULT_PROVIDER_ID = "theclawbay";
|
|
22
|
-
const LEGACY_PROVIDER_ID = "codex-lb";
|
|
23
23
|
const CLI_HTTP_USER_AGENT = "theclawbay-cli";
|
|
24
24
|
const DEFAULT_CODEX_MODEL = "gpt-5.4";
|
|
25
25
|
const DEFAULT_OPENCLAW_MODEL = "gpt-5.4";
|
|
@@ -58,7 +58,7 @@ const MODEL_DISPLAY_NAMES = {
|
|
|
58
58
|
"gpt-5.1-codex": "GPT-5.1 Codex",
|
|
59
59
|
"gpt-5.1": "GPT-5.1",
|
|
60
60
|
};
|
|
61
|
-
const ENV_KEY_NAME = "
|
|
61
|
+
const ENV_KEY_NAME = "THECLAWBAY_API_KEY";
|
|
62
62
|
const ENV_FILE = node_path_1.default.join(node_os_1.default.homedir(), ".config", "theclawbay", "env");
|
|
63
63
|
const MIGRATION_STATE_FILE = node_path_1.default.join(paths_1.codexDir, "theclawbay.migration.json");
|
|
64
64
|
const MANAGED_START = "# theclawbay-managed:start";
|
|
@@ -66,8 +66,8 @@ const MANAGED_END = "# theclawbay-managed:end";
|
|
|
66
66
|
const SHELL_START = "# theclawbay-shell-managed:start";
|
|
67
67
|
const SHELL_END = "# theclawbay-shell-managed:end";
|
|
68
68
|
const OPENCLAW_PROVIDER_ID = DEFAULT_PROVIDER_ID;
|
|
69
|
-
const HISTORY_PROVIDER_NEUTRALIZE_SOURCES = new Set(["openai", "theclawbay-wan", DEFAULT_PROVIDER_ID
|
|
70
|
-
const HISTORY_PROVIDER_DB_MIGRATE_SOURCES = ["openai", "theclawbay-wan"
|
|
69
|
+
const HISTORY_PROVIDER_NEUTRALIZE_SOURCES = new Set(["openai", "theclawbay-wan", DEFAULT_PROVIDER_ID]);
|
|
70
|
+
const HISTORY_PROVIDER_DB_MIGRATE_SOURCES = ["openai", "theclawbay-wan"];
|
|
71
71
|
const OPTIONAL_SETUP_CLIENT_IDS = ["openclaw", "opencode", "kilo", "trae"];
|
|
72
72
|
const TRAE_PATCH_MARKER = "theclawbay-trae-patch";
|
|
73
73
|
const TRAE_BUNDLE_BACKUP_SUFFIX = ".theclawbay-managed-backup";
|
|
@@ -95,10 +95,45 @@ function localAppDataDir() {
|
|
|
95
95
|
return process.env.LOCALAPPDATA;
|
|
96
96
|
return node_path_1.default.join(node_os_1.default.homedir(), "AppData", "Local");
|
|
97
97
|
}
|
|
98
|
+
const TRAE_BUNDLE_RELATIVE_PATH = node_path_1.default.join("resources", "app", "node_modules", "@byted-icube", "ai-modules-chat", "dist", "index.js");
|
|
99
|
+
function appendTraeBundlePath(basePath) {
|
|
100
|
+
if (basePath.toLowerCase().endsWith(node_path_1.default.normalize(TRAE_BUNDLE_RELATIVE_PATH).toLowerCase())) {
|
|
101
|
+
return basePath;
|
|
102
|
+
}
|
|
103
|
+
return node_path_1.default.join(basePath, TRAE_BUNDLE_RELATIVE_PATH);
|
|
104
|
+
}
|
|
105
|
+
function traeBundleCandidateRoots() {
|
|
106
|
+
const candidates = new Set();
|
|
107
|
+
if (process.env.THECLAWBAY_TRAE_PATH?.trim()) {
|
|
108
|
+
candidates.add(process.env.THECLAWBAY_TRAE_PATH.trim());
|
|
109
|
+
}
|
|
110
|
+
const localPrograms = node_path_1.default.join(localAppDataDir(), "Programs");
|
|
111
|
+
candidates.add(node_path_1.default.join(localPrograms, "Trae"));
|
|
112
|
+
for (const envKey of ["ProgramFiles", "ProgramFiles(x86)"]) {
|
|
113
|
+
const root = process.env[envKey]?.trim();
|
|
114
|
+
if (root)
|
|
115
|
+
candidates.add(node_path_1.default.join(root, "Trae"));
|
|
116
|
+
}
|
|
117
|
+
if ((0, node_fs_1.existsSync)(localPrograms)) {
|
|
118
|
+
for (const entry of (0, node_fs_1.readdirSync)(localPrograms, { withFileTypes: true })) {
|
|
119
|
+
if (!entry.isDirectory())
|
|
120
|
+
continue;
|
|
121
|
+
if (!entry.name.toLowerCase().includes("trae"))
|
|
122
|
+
continue;
|
|
123
|
+
candidates.add(node_path_1.default.join(localPrograms, entry.name));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return Array.from(candidates);
|
|
127
|
+
}
|
|
98
128
|
function traeBundlePath() {
|
|
99
129
|
if (node_os_1.default.platform() !== "win32")
|
|
100
130
|
return null;
|
|
101
|
-
|
|
131
|
+
for (const candidateRoot of traeBundleCandidateRoots()) {
|
|
132
|
+
const bundlePath = appendTraeBundlePath(candidateRoot);
|
|
133
|
+
if ((0, node_fs_1.existsSync)(bundlePath))
|
|
134
|
+
return bundlePath;
|
|
135
|
+
}
|
|
136
|
+
return appendTraeBundlePath(node_path_1.default.join(localAppDataDir(), "Programs", "Trae"));
|
|
102
137
|
}
|
|
103
138
|
function traeBundleBackupPath(bundlePath) {
|
|
104
139
|
return `${bundlePath}${TRAE_BUNDLE_BACKUP_SUFFIX}`;
|
|
@@ -392,7 +427,6 @@ async function writeCodexConfig(params) {
|
|
|
392
427
|
const proxyRoot = `${trimTrailingSlash(params.backendUrl)}/api/codex-auth/v1/proxy`;
|
|
393
428
|
let next = existing;
|
|
394
429
|
next = removeManagedBlock(next, MANAGED_START, MANAGED_END);
|
|
395
|
-
next = removeProviderTable(next, LEGACY_PROVIDER_ID);
|
|
396
430
|
next = removeProviderTable(next, DEFAULT_PROVIDER_ID);
|
|
397
431
|
next = upsertFirstKeyLine(next, "model_provider", `"${DEFAULT_PROVIDER_ID}"`);
|
|
398
432
|
next = upsertFirstKeyLine(next, "model", `"${params.model}"`);
|
|
@@ -484,9 +518,8 @@ function runOpenClawConfigCommand(args) {
|
|
|
484
518
|
function isOpenClawMissingApiKeyEnvError(error) {
|
|
485
519
|
if (!(error instanceof Error))
|
|
486
520
|
return false;
|
|
487
|
-
return (error.message.includes(
|
|
488
|
-
|
|
489
|
-
error.message.includes(`models.providers.${OPENCLAW_PROVIDER_ID}.apiKey`)));
|
|
521
|
+
return (error.message.includes(`Missing env var "${ENV_KEY_NAME}"`) &&
|
|
522
|
+
error.message.includes(`models.providers.${OPENCLAW_PROVIDER_ID}.apiKey`));
|
|
490
523
|
}
|
|
491
524
|
function resolveOpenClawPrimaryModel(params) {
|
|
492
525
|
const hasStableDefault = params.models.some((entry) => entry.id === DEFAULT_OPENCLAW_MODEL);
|
|
@@ -523,9 +556,6 @@ async function patchOpenClawConfigFile(params) {
|
|
|
523
556
|
const modelsRoot = objectRecordOr(doc.models, {});
|
|
524
557
|
modelsRoot.mode = "merge";
|
|
525
558
|
const providersRoot = objectRecordOr(modelsRoot.providers, {});
|
|
526
|
-
if (LEGACY_PROVIDER_ID !== OPENCLAW_PROVIDER_ID && LEGACY_PROVIDER_ID in providersRoot) {
|
|
527
|
-
delete providersRoot[LEGACY_PROVIDER_ID];
|
|
528
|
-
}
|
|
529
559
|
providersRoot[OPENCLAW_PROVIDER_ID] = provider;
|
|
530
560
|
modelsRoot.providers = providersRoot;
|
|
531
561
|
doc.models = modelsRoot;
|
|
@@ -580,9 +610,6 @@ async function writeOpenCodeConfig(params) {
|
|
|
580
610
|
}
|
|
581
611
|
}
|
|
582
612
|
const providerRoot = objectRecordOr(doc.provider, {});
|
|
583
|
-
if (LEGACY_PROVIDER_ID !== DEFAULT_PROVIDER_ID && LEGACY_PROVIDER_ID in providerRoot) {
|
|
584
|
-
delete providerRoot[LEGACY_PROVIDER_ID];
|
|
585
|
-
}
|
|
586
613
|
providerRoot[DEFAULT_PROVIDER_ID] = {
|
|
587
614
|
npm: "@ai-sdk/openai-compatible",
|
|
588
615
|
name: DEFAULT_PROVIDER_ID,
|
|
@@ -619,9 +646,6 @@ async function writeKiloConfig(params) {
|
|
|
619
646
|
}
|
|
620
647
|
}
|
|
621
648
|
const providerRoot = objectRecordOr(doc.provider, {});
|
|
622
|
-
if (LEGACY_PROVIDER_ID !== DEFAULT_PROVIDER_ID && LEGACY_PROVIDER_ID in providerRoot) {
|
|
623
|
-
delete providerRoot[LEGACY_PROVIDER_ID];
|
|
624
|
-
}
|
|
625
649
|
providerRoot[DEFAULT_PROVIDER_ID] = {
|
|
626
650
|
npm: "@ai-sdk/openai-compatible",
|
|
627
651
|
name: DEFAULT_PROVIDER_ID,
|
|
@@ -904,7 +928,7 @@ class SetupCommand extends base_command_1.BaseCommand {
|
|
|
904
928
|
else {
|
|
905
929
|
this.log("- Codex login state: no change.");
|
|
906
930
|
}
|
|
907
|
-
this.log("Next: restart terminal/VS Code window only if you rely on
|
|
931
|
+
this.log("Next: restart terminal/VS Code window only if you rely on the The Claw Bay API key in your own scripts.");
|
|
908
932
|
});
|
|
909
933
|
}
|
|
910
934
|
}
|