coze_lab 0.1.8 → 0.1.10
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 +16 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4294,12 +4294,18 @@ const AGENT_CONFIG = {
|
|
|
4294
4294
|
},
|
|
4295
4295
|
};
|
|
4296
4296
|
|
|
4297
|
-
function detectAgent(agent) {
|
|
4297
|
+
function detectAgent(agent, cloud) {
|
|
4298
4298
|
const cfg = AGENT_CONFIG[agent];
|
|
4299
4299
|
// Check binary exists
|
|
4300
4300
|
try {
|
|
4301
4301
|
execSync(`which ${cfg.binary}`, { stdio: 'pipe' });
|
|
4302
4302
|
} catch {
|
|
4303
|
+
// 云端 sandbox 里 agent 由 coze-bridge 托管运行,binary 不一定在 PATH。
|
|
4304
|
+
// 配置 hook 不依赖 binary 可执行,所以云端只 warn 不退出。
|
|
4305
|
+
if (cloud) {
|
|
4306
|
+
warn(`${agent} binary 不在 PATH(云端托管,跳过检测)`);
|
|
4307
|
+
return 'cloud';
|
|
4308
|
+
}
|
|
4303
4309
|
errorBox([
|
|
4304
4310
|
`ERROR: ${agent} is not installed on this machine`,
|
|
4305
4311
|
'',
|
|
@@ -5172,21 +5178,23 @@ async function main() {
|
|
|
5172
5178
|
}
|
|
5173
5179
|
|
|
5174
5180
|
// Step 1: Authorize.
|
|
5175
|
-
// 云端(--cloud):token
|
|
5181
|
+
// 云端(--cloud):token 取自 sandbox 注入的环境变量,跳过 OAuth / credentials.json。
|
|
5182
|
+
// 云端真实变量名是 COZELOOP_API_TOKEN(兼容历史的 COZE_API_TOKEN)。
|
|
5176
5183
|
// 本地:load cached → refresh → device code。
|
|
5184
|
+
// 注意:workspace_id 始终用写死的 WORKSPACE_ID(团队固定上报 workspace),不读环境。
|
|
5177
5185
|
let token;
|
|
5178
5186
|
if (args.cloud) {
|
|
5179
|
-
info('Step 1/5:
|
|
5180
|
-
token = process.env.COZE_API_TOKEN;
|
|
5187
|
+
info('Step 1/5: 云端模式,从环境变量读取 COZELOOP_API_TOKEN...');
|
|
5188
|
+
token = process.env.COZELOOP_API_TOKEN || process.env.COZE_API_TOKEN;
|
|
5181
5189
|
if (!token) {
|
|
5182
5190
|
errorBox([
|
|
5183
|
-
'ERROR: --cloud 模式要求环境变量
|
|
5191
|
+
'ERROR: --cloud 模式要求环境变量 COZELOOP_API_TOKEN',
|
|
5184
5192
|
'',
|
|
5185
|
-
'云端 sandbox 应在进程环境中注入 COZE_API_TOKEN
|
|
5193
|
+
'云端 sandbox 应在进程环境中注入 COZELOOP_API_TOKEN(或 COZE_API_TOKEN)。',
|
|
5186
5194
|
'未检测到该变量,无法配置 trace 上报。',
|
|
5187
5195
|
]);
|
|
5188
5196
|
}
|
|
5189
|
-
ok('已从环境变量读取
|
|
5197
|
+
ok('已从环境变量读取 COZELOOP_API_TOKEN');
|
|
5190
5198
|
} else {
|
|
5191
5199
|
info('Step 1/5: 检查授权状态...');
|
|
5192
5200
|
token = await getValidToken();
|
|
@@ -5195,7 +5203,7 @@ async function main() {
|
|
|
5195
5203
|
|
|
5196
5204
|
// Step 2: Detect agent binary
|
|
5197
5205
|
info('Step 2/5: Detecting agent...');
|
|
5198
|
-
const version = detectAgent(agent);
|
|
5206
|
+
const version = detectAgent(agent, args.cloud);
|
|
5199
5207
|
console.log('');
|
|
5200
5208
|
|
|
5201
5209
|
// Step 3: Environment checks
|