coze_lab 0.1.32 → 0.1.34
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/index.js +20 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5505,7 +5505,7 @@ function isOpenClawAlreadyInjected(configPath, pluginDir, token, workspaceId, ag
|
|
|
5505
5505
|
return JSON.stringify(existing) === JSON.stringify(desired);
|
|
5506
5506
|
}
|
|
5507
5507
|
|
|
5508
|
-
function writeOpenClawHook(token, workspaceId, agentId, cloud) {
|
|
5508
|
+
function writeOpenClawHook(token, workspaceId, agentId, cloud, force) {
|
|
5509
5509
|
const home = resolveHomeDir(cloud);
|
|
5510
5510
|
const configPath = path.join(home, '.openclaw', 'openclaw.json');
|
|
5511
5511
|
const pluginDir = path.join(home, '.cozeloop', 'openclaw-plugin');
|
|
@@ -5519,10 +5519,13 @@ function writeOpenClawHook(token, workspaceId, agentId, cloud) {
|
|
|
5519
5519
|
]);
|
|
5520
5520
|
}
|
|
5521
5521
|
|
|
5522
|
-
if (isOpenClawAlreadyInjected(configPath, pluginDir, token, workspaceId, agentId, cloud)) {
|
|
5522
|
+
if (!force && isOpenClawAlreadyInjected(configPath, pluginDir, token, workspaceId, agentId, cloud)) {
|
|
5523
5523
|
ok(`OpenClaw plugin already configured in ${configPath}`);
|
|
5524
5524
|
info('OpenClaw gateway restart skipped (configuration unchanged).');
|
|
5525
|
-
return { configPath, pluginDir, unchanged: true };
|
|
5525
|
+
return { configPath, pluginDir, unchanged: true, gatewayRestarted: false, gatewayRestartSkipped: true };
|
|
5526
|
+
}
|
|
5527
|
+
if (force) {
|
|
5528
|
+
info('OpenClaw force mode enabled; rewriting plugin files and reinstalling.');
|
|
5526
5529
|
}
|
|
5527
5530
|
|
|
5528
5531
|
// 1. Write plugin files to ~/.cozeloop/openclaw-plugin/
|
|
@@ -5591,11 +5594,11 @@ function writeOpenClawHook(token, workspaceId, agentId, cloud) {
|
|
|
5591
5594
|
info('Restarting OpenClaw gateway to apply hook changes...');
|
|
5592
5595
|
execSync('openclaw gateway restart', { stdio: 'pipe' });
|
|
5593
5596
|
ok('OpenClaw gateway restarted');
|
|
5597
|
+
return { configPath, pluginDir, gatewayRestarted: true };
|
|
5594
5598
|
} catch (e) {
|
|
5595
5599
|
warn(`gateway restart 失败,请手动执行: openclaw gateway restart(${e.message})`);
|
|
5600
|
+
return { configPath, pluginDir, gatewayRestarted: false, gatewayRestartError: e.message };
|
|
5596
5601
|
}
|
|
5597
|
-
|
|
5598
|
-
return { configPath, pluginDir };
|
|
5599
5602
|
}
|
|
5600
5603
|
|
|
5601
5604
|
// ─── 8. Auth — Device Code OAuth + token store ───────────────────────────────
|
|
@@ -6239,9 +6242,18 @@ function authStatus() {
|
|
|
6239
6242
|
const NEXT_STEP = {
|
|
6240
6243
|
'claude-code': 'Hook 已写入。Claude Code 会自动热重载 hooks,当前会话即刻生效,无需 /new 或重启。',
|
|
6241
6244
|
'codex': 'Hook 已写入。Codex 在会话启动时加载 hook,当前会话不会即时生效;请重开 Codex 会话(已配置 SessionStart hook,新会话自动加载)。',
|
|
6242
|
-
'openclaw': 'OpenClaw gateway 已自动重启,trace 即刻生效。',
|
|
6243
6245
|
};
|
|
6244
6246
|
|
|
6247
|
+
function openClawNextStep(written) {
|
|
6248
|
+
if (written?.gatewayRestarted) {
|
|
6249
|
+
return 'OpenClaw gateway 已自动重启,trace 即刻生效。';
|
|
6250
|
+
}
|
|
6251
|
+
if (written?.gatewayRestartSkipped) {
|
|
6252
|
+
return 'OpenClaw 配置未变化,gateway restart 已跳过。';
|
|
6253
|
+
}
|
|
6254
|
+
return 'OpenClaw gateway 未能自动重启;请手动执行 openclaw gateway restart 后生效。';
|
|
6255
|
+
}
|
|
6256
|
+
|
|
6245
6257
|
async function main() {
|
|
6246
6258
|
console.log('');
|
|
6247
6259
|
info(`CozeLoop Onboard CLI starting... (coze_lab v${PACKAGE_VERSION})`);
|
|
@@ -6415,7 +6427,7 @@ async function main() {
|
|
|
6415
6427
|
written = writeCodexHook(token, WORKSPACE_ID, pythonCmd, codexHome, args.cloud);
|
|
6416
6428
|
} else {
|
|
6417
6429
|
// openclaw:云端用 traceAgentIds allowlist 做 per-agent 放行。
|
|
6418
|
-
written = writeOpenClawHook(token, WORKSPACE_ID, args.agentId, args.cloud) || {};
|
|
6430
|
+
written = writeOpenClawHook(token, WORKSPACE_ID, args.agentId, args.cloud, args.force) || {};
|
|
6419
6431
|
}
|
|
6420
6432
|
// 走到这里说明 detectAgent / 环境检查 / 写 hook 配置全部成功 → 注入成功。
|
|
6421
6433
|
cloudResult.inject = 'ok';
|
|
@@ -6440,7 +6452,7 @@ async function main() {
|
|
|
6440
6452
|
summaryLines.push(`Config: ~/.openclaw/openclaw.json`);
|
|
6441
6453
|
}
|
|
6442
6454
|
summaryLines.push('');
|
|
6443
|
-
summaryLines.push(NEXT_STEP[agent]);
|
|
6455
|
+
summaryLines.push(agent === 'openclaw' ? openClawNextStep(written) : NEXT_STEP[agent]);
|
|
6444
6456
|
|
|
6445
6457
|
// Enterprise policy note for Claude Code
|
|
6446
6458
|
if (agent === 'claude-code') {
|