@lightcone-ai/daemon 0.15.61 → 0.15.63

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.
@@ -74,6 +74,10 @@ function getProfileDir(platform, credentialId = null) {
74
74
  return process.env[key] ?? null;
75
75
  }
76
76
 
77
+ function sessionKeyFor(platform, credentialId = null) {
78
+ return credentialId ? `${platform}:cred-${credentialId}` : platform;
79
+ }
80
+
77
81
  function getAdapterClass(platform) {
78
82
  const AdapterClass = ADAPTER_REGISTRY[platform];
79
83
  if (!AdapterClass) throw new Error(`Unknown platform: ${platform}`);
@@ -96,7 +100,7 @@ async function getAdapter(platform, credentialId = null) {
96
100
  }
97
101
  // Pool session by (platform, credentialId) when credential is specified — different
98
102
  // credentials on the same platform must NOT share a CDP session (D17 §6.6 isolation).
99
- const sessionKey = credentialId ? `${platform}:cred-${credentialId}` : platform;
103
+ const sessionKey = sessionKeyFor(platform, credentialId);
100
104
  const cdp = await getSession(sessionKey, profileDir);
101
105
  return createAdapter(platform, cdp);
102
106
  }
@@ -113,7 +117,7 @@ async function withPublisherProfile(platform, fn, credentialId = null) {
113
117
  owner: `publisher:${lockKey}`,
114
118
  timeoutMs: 30_000,
115
119
  staleMs: 20 * 60 * 1000,
116
- }, fn);
120
+ }, () => fn(profileDir));
117
121
  }
118
122
 
119
123
  async function api(method, path, body) {
@@ -474,22 +478,25 @@ server.tool(
474
478
 
475
479
  server.tool(
476
480
  'check_login_status',
477
- '检查指定平台的浏览器 Profile 是否仍处于登录状态。如果未登录,提示用户重新扫码连接。',
481
+ '检查指定平台账号的浏览器 Profile 是否仍处于登录状态。如果有多个账号,必须传真实 credential_id。',
478
482
  {
479
483
  platform: z.enum(['xhs', 'douyin', 'kuaishou', 'bilibili']).describe('目标平台'),
484
+ credential_id: z.string().optional().describe('可选。真实 credential UUID;多账号场景必须传入,检测会使用 ~/.lightcone/chrome-profiles/cred-{credential_id}。'),
480
485
  },
481
- async ({ platform }) => {
486
+ async ({ platform, credential_id }) => {
482
487
  const label = PLATFORM_LABELS[platform] ?? platform;
488
+ const sessionKey = sessionKeyFor(platform, credential_id ?? null);
483
489
  try {
484
- const { loggedIn, url, profileDir } = await withPublisherProfile(platform, async () => {
485
- const adapter = await getAdapter(platform);
486
- return adapter.checkLoginStatus();
487
- });
490
+ const { loggedIn, url, profileDir } = await withPublisherProfile(platform, async (resolvedProfileDir) => {
491
+ const adapter = await getAdapter(platform, credential_id ?? null);
492
+ const status = await adapter.checkLoginStatus();
493
+ return { ...status, profileDir: resolvedProfileDir };
494
+ }, credential_id ?? null);
488
495
  // Always close session after login check so the Chrome profile is free
489
496
  // for the daemon's publish job (which runs in a separate process)
490
- closeSession(platform);
497
+ closeSession(sessionKey);
491
498
  if (loggedIn) {
492
- return { content: [{ type: 'text', text: `✓ ${label} 已登录,可以发布内容。` }] };
499
+ return { content: [{ type: 'text', text: `✓ ${label} 已登录,可以发布内容。\nprofileDir=${profileDir}` }] };
493
500
  } else {
494
501
  return {
495
502
  content: [{ type: 'text', text: `${label} 未登录或登录已过期。\n调试信息: url=${url}\nprofileDir=${profileDir}\n请在「连接外部账号」中重新扫码连接。` }],
@@ -497,7 +504,7 @@ server.tool(
497
504
  };
498
505
  }
499
506
  } catch (err) {
500
- closeSession(platform);
507
+ closeSession(sessionKey);
501
508
  return { content: [{ type: 'text', text: `检查失败: ${err.message}` }], isError: true };
502
509
  }
503
510
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.15.61",
3
+ "version": "0.15.63",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -6,6 +6,7 @@ import {
6
6
  mkdirSync,
7
7
  readFileSync,
8
8
  readdirSync,
9
+ rmSync,
9
10
  statSync,
10
11
  unlinkSync,
11
12
  writeFileSync,
@@ -1529,7 +1529,7 @@ server.tool('request_approval',
1529
1529
  platform: z.string().describe('Target platform, e.g. "x", "xhs", "email"'),
1530
1530
  description: z.string().describe('Human-readable summary of what will happen if approved'),
1531
1531
  payload: z.record(z.any()).describe('Full action parameters (content, media_urls, etc.)'),
1532
- credential_id: z.string().optional().describe('Which credential ID to use for execution'),
1532
+ credential_id: z.string().optional().describe('Which account/credential to use. For publishing, prefer a workspace account_id or real credential UUID. Role aliases like primary/test are accepted only if they uniquely match a workspace account.'),
1533
1533
  },
1534
1534
  async ({ action_type, platform, description, payload, credential_id }) => {
1535
1535
  try {