@lightcone-ai/daemon 0.9.78 → 0.10.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.
Files changed (43) hide show
  1. package/mcp-servers/mysql/index.js +13 -5
  2. package/mcp-servers/mysql/manifest.json +16 -0
  3. package/mcp-servers/official/company-fundamentals/index.js +34 -0
  4. package/mcp-servers/official/company-fundamentals/manifest.json +14 -0
  5. package/mcp-servers/official/compliance-check/index.js +49 -0
  6. package/mcp-servers/official/compliance-check/manifest.json +14 -0
  7. package/mcp-servers/official/industry-report/index.js +34 -0
  8. package/mcp-servers/official/industry-report/manifest.json +14 -0
  9. package/mcp-servers/official/market-data-query/index.js +34 -0
  10. package/mcp-servers/official/market-data-query/manifest.json +14 -0
  11. package/mcp-servers/official/portfolio-analysis/index.js +74 -0
  12. package/mcp-servers/official/portfolio-analysis/manifest.json +14 -0
  13. package/mcp-servers/official/portfolio-read/index.js +34 -0
  14. package/mcp-servers/official/portfolio-read/manifest.json +14 -0
  15. package/mcp-servers/official/research-fetch/index.js +35 -0
  16. package/mcp-servers/official/research-fetch/manifest.json +14 -0
  17. package/mcp-servers/official/risk-metrics/index.js +34 -0
  18. package/mcp-servers/official/risk-metrics/manifest.json +14 -0
  19. package/mcp-servers/official-common/fixtures.js +273 -0
  20. package/mcp-servers/official-common/server.js +34 -0
  21. package/mcp-servers/platform/manifest.json +15 -0
  22. package/mcp-servers/portfolio-analysis/core.js +592 -0
  23. package/mcp-servers/portfolio-analysis/index.js +45 -0
  24. package/mcp-servers/portfolio-analysis/package-lock.json +1139 -0
  25. package/mcp-servers/portfolio-analysis/package.json +10 -0
  26. package/mcp-servers/portfolio-read/core.js +330 -0
  27. package/mcp-servers/portfolio-read/index.js +127 -0
  28. package/mcp-servers/portfolio-read/package-lock.json +1243 -0
  29. package/mcp-servers/portfolio-read/package.json +11 -0
  30. package/mcp-servers/publisher/adapters/douyin.js +112 -20
  31. package/mcp-servers/publisher/index.js +84 -8
  32. package/mcp-servers/publisher/manifest.json +16 -0
  33. package/package.json +1 -1
  34. package/src/agent-manager.js +761 -187
  35. package/src/chat-bridge.js +567 -92
  36. package/src/connection.js +1 -1
  37. package/src/drivers/claude.js +48 -45
  38. package/src/drivers/codex.js +110 -7
  39. package/src/drivers/kimi.js +80 -34
  40. package/src/governance-state.js +89 -0
  41. package/src/index.js +34 -16
  42. package/src/lease-window.js +8 -0
  43. package/src/mcp-config.js +52 -21
package/src/index.js CHANGED
@@ -7,26 +7,44 @@ import { releaseProfileLocksForProcess } from './profile-lock.js';
7
7
 
8
8
  const { version } = createRequire(import.meta.url)('../package.json');
9
9
 
10
- // ── CLI args ──────────────────────────────────────────────────────────────────
11
- const args = process.argv.slice(2);
12
- let cliServerUrl = '';
13
- let cliApiKey = '';
14
-
15
- for (let i = 0; i < args.length; i++) {
16
- if (args[i] === '--server-url' && args[i + 1]) cliServerUrl = args[++i];
17
- if (args[i] === '--api-key' && args[i + 1]) cliApiKey = args[++i];
18
- if (args[i] === '--help' || args[i] === '-h') {
19
- console.log('Usage: lightcone-daemon --server-url <url> --api-key <key>');
20
- process.exit(0);
10
+ function parseArgs(raw) {
11
+ const opts = { _: [] };
12
+ for (let i = 0; i < raw.length; i++) {
13
+ const arg = raw[i];
14
+ if (arg.startsWith('--')) {
15
+ const next = raw[i + 1];
16
+ if (next && !next.startsWith('--')) {
17
+ opts[arg] = next;
18
+ i++;
19
+ } else {
20
+ opts[arg] = true;
21
+ }
22
+ } else {
23
+ opts._.push(arg);
24
+ }
21
25
  }
26
+ return opts;
27
+ }
28
+
29
+ function printUsage() {
30
+ console.log('Usage:');
31
+ console.log(' lightcone-daemon --server-url <url> --api-key <key>');
32
+ }
33
+
34
+ // ── CLI args ──────────────────────────────────────────────────────────────────
35
+ const argv = process.argv.slice(2);
36
+ const opts = parseArgs(argv);
37
+ if (opts['--help'] || opts['-h']) {
38
+ printUsage();
39
+ process.exit(0);
22
40
  }
23
41
 
24
- const SERVER_URL = cliServerUrl || process.env.SERVER_URL || 'http://localhost:8779';
25
- const MACHINE_API_KEY = cliApiKey || process.env.MACHINE_API_KEY || '';
42
+ const SERVER_URL = String(opts['--server-url'] || process.env.SERVER_URL || 'http://localhost:8779').trim();
43
+ const MACHINE_API_KEY = String(opts['--api-key'] || process.env.MACHINE_API_KEY || '').trim();
26
44
 
27
45
  if (!MACHINE_API_KEY) {
28
46
  console.error('Error: API key is required.');
29
- console.error('Usage: lightcone-daemon --server-url <url> --api-key <key>');
47
+ printUsage();
30
48
  process.exit(1);
31
49
  }
32
50
 
@@ -54,7 +72,7 @@ async function shutdown(signal) {
54
72
  process.exit(0);
55
73
  }
56
74
 
57
- process.on('SIGINT', () => { shutdown('SIGINT'); });
75
+ process.on('SIGINT', () => { shutdown('SIGINT'); });
58
76
  process.on('SIGTERM', () => { shutdown('SIGTERM'); });
59
- process.on('SIGHUP', () => { shutdown('SIGHUP'); });
77
+ process.on('SIGHUP', () => { shutdown('SIGHUP'); });
60
78
  process.on('exit', () => { releaseProfileLocksForProcess(); });
@@ -0,0 +1,8 @@
1
+ export function classifyLeaseWindow(validUntil, nowMs = Date.now(), graceMs = 5000) {
2
+ const validUntilMs = Date.parse(validUntil ?? '');
3
+ if (!Number.isFinite(validUntilMs)) return 'expired';
4
+ if (nowMs <= validUntilMs) return 'valid';
5
+ if (nowMs <= validUntilMs + Math.max(0, Number(graceMs) || 0)) return 'grace';
6
+ return 'expired';
7
+ }
8
+
package/src/mcp-config.js CHANGED
@@ -1,14 +1,42 @@
1
1
  import { profileDir } from './browser-login.js';
2
+ import { resolveMcpServerEntrypoint } from '../../src/mcp/registry.js';
3
+
4
+ const LEGACY_MCP_PATH_TOKENS = Object.freeze({
5
+ '{mysql_mcp_path}': 'mysql',
6
+ '{workspace_migrate_mcp_path}': 'workspace-migrate',
7
+ '{platform_mcp_path}': 'platform',
8
+ '{publisher_mcp_path}': 'publisher',
9
+ '{research_fetch_mcp_path}': 'research-fetch',
10
+ '{market_data_query_mcp_path}': 'market-data-query',
11
+ '{company_fundamentals_mcp_path}': 'company-fundamentals',
12
+ '{industry_report_mcp_path}': 'industry-report',
13
+ '{risk_metrics_mcp_path}': 'risk-metrics',
14
+ '{compliance_check_mcp_path}': 'compliance-check',
15
+ '{portfolio_read_mcp_path}': 'portfolio-read',
16
+ '{portfolio_analysis_mcp_path}': 'portfolio-analysis',
17
+ });
18
+
19
+ function resolveMcpPathToken(arg) {
20
+ if (typeof arg !== 'string') return null;
21
+
22
+ const trimmed = arg.trim();
23
+ if (!trimmed.startsWith('{') || !trimmed.endsWith('}')) return null;
24
+
25
+ const legacyId = LEGACY_MCP_PATH_TOKENS[trimmed] ?? null;
26
+ const dynamicMatch = trimmed.match(/^\{mcp_path:([a-z0-9][a-z0-9_-]*)\}$/i);
27
+ const serverId = legacyId ?? (dynamicMatch ? dynamicMatch[1].toLowerCase() : null);
28
+ if (!serverId) return null;
29
+
30
+ const entrypointPath = resolveMcpServerEntrypoint(serverId, { strict: true });
31
+ if (!entrypointPath) {
32
+ throw new Error(`MCP server '${serverId}' is not registered in manifest registry`);
33
+ }
34
+ return entrypointPath;
35
+ }
2
36
 
3
37
  function resolveSkillArg(arg, config) {
4
- if (arg === '{mysql_mcp_path}')
5
- return new URL('../../mcp-servers/mysql/index.js', import.meta.url).pathname;
6
- if (arg === '{workspace_migrate_mcp_path}')
7
- return new URL('../../mcp-servers/workspace-migrate/index.js', import.meta.url).pathname;
8
- if (arg === '{platform_mcp_path}')
9
- return new URL('../../mcp-servers/platform/index.js', import.meta.url).pathname;
10
- if (arg === '{publisher_mcp_path}')
11
- return new URL('../mcp-servers/publisher/index.js', import.meta.url).pathname;
38
+ const resolvedMcpPath = resolveMcpPathToken(arg);
39
+ if (resolvedMcpPath) return resolvedMcpPath;
12
40
  if (arg === '{xhs_profile_dir}')
13
41
  return profileDir('xhs', config.userId ?? 'default');
14
42
  if (arg === '{douyin_profile_dir}')
@@ -18,15 +46,27 @@ function resolveSkillArg(arg, config) {
18
46
  return arg;
19
47
  }
20
48
 
21
- function baseEnvForServer(serverKey, { serverUrl, authToken, agentId, workspaceDir }) {
49
+ function baseEnvForServer(serverKey, { serverUrl, authToken, agentId, workspaceId, workspaceDir }) {
22
50
  if (serverKey === 'workspace-migrate') {
23
51
  return { SERVER_URL: serverUrl, MACHINE_API_KEY: authToken, AGENT_ID: agentId };
24
52
  }
25
- if (serverKey === 'publisher' || serverKey === 'platform') {
53
+ if (
54
+ serverKey === 'publisher'
55
+ || serverKey === 'platform'
56
+ || serverKey === 'research-fetch'
57
+ || serverKey === 'market-data-query'
58
+ || serverKey === 'company-fundamentals'
59
+ || serverKey === 'industry-report'
60
+ || serverKey === 'risk-metrics'
61
+ || serverKey === 'compliance-check'
62
+ || serverKey === 'portfolio-read'
63
+ || serverKey === 'portfolio-analysis'
64
+ ) {
26
65
  return {
27
66
  SERVER_URL: serverUrl,
28
67
  MACHINE_API_KEY: authToken,
29
68
  AGENT_ID: agentId,
69
+ WORKSPACE_ID: workspaceId ?? '',
30
70
  WORKSPACE_DIR: workspaceDir,
31
71
  };
32
72
  }
@@ -35,9 +75,9 @@ function baseEnvForServer(serverKey, { serverUrl, authToken, agentId, workspaceD
35
75
 
36
76
  export function buildSkillMcpServers({
37
77
  skills,
38
- credentialGrants,
39
78
  config,
40
79
  agentId,
80
+ workspaceId,
41
81
  workspaceDir,
42
82
  serverUrl,
43
83
  authToken,
@@ -61,19 +101,10 @@ export function buildSkillMcpServers({
61
101
  args: resolvedArgs,
62
102
  env: {
63
103
  ...resolvedEnv,
64
- ...baseEnvForServer(mc.server, { serverUrl, authToken, agentId, workspaceDir }),
104
+ ...baseEnvForServer(mc.server, { serverUrl, authToken, agentId, workspaceId, workspaceDir }),
65
105
  },
66
106
  };
67
107
  }
68
108
 
69
- for (const skill of (skills ?? [])) {
70
- if (!skill.mcpConfig?.platform) continue;
71
- const grant = (credentialGrants ?? []).find(g => g.platform === skill.mcpConfig.platform);
72
- if (!grant) continue;
73
- const serverKey = skill.mcpConfig.server;
74
- if (!mcpServers[serverKey]) continue;
75
- mcpServers[serverKey].env = { ...(mcpServers[serverKey].env ?? {}), ...(grant.envVars ?? {}) };
76
- }
77
-
78
109
  return mcpServers;
79
110
  }