@lightcone-ai/daemon 0.9.79 → 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.
- package/mcp-servers/mysql/index.js +13 -5
- package/mcp-servers/mysql/manifest.json +16 -0
- package/mcp-servers/official/company-fundamentals/index.js +34 -0
- package/mcp-servers/official/company-fundamentals/manifest.json +14 -0
- package/mcp-servers/official/compliance-check/index.js +49 -0
- package/mcp-servers/official/compliance-check/manifest.json +14 -0
- package/mcp-servers/official/industry-report/index.js +34 -0
- package/mcp-servers/official/industry-report/manifest.json +14 -0
- package/mcp-servers/official/market-data-query/index.js +34 -0
- package/mcp-servers/official/market-data-query/manifest.json +14 -0
- package/mcp-servers/official/portfolio-analysis/index.js +74 -0
- package/mcp-servers/official/portfolio-analysis/manifest.json +14 -0
- package/mcp-servers/official/portfolio-read/index.js +34 -0
- package/mcp-servers/official/portfolio-read/manifest.json +14 -0
- package/mcp-servers/official/research-fetch/index.js +35 -0
- package/mcp-servers/official/research-fetch/manifest.json +14 -0
- package/mcp-servers/official/risk-metrics/index.js +34 -0
- package/mcp-servers/official/risk-metrics/manifest.json +14 -0
- package/mcp-servers/official-common/fixtures.js +273 -0
- package/mcp-servers/official-common/server.js +34 -0
- package/mcp-servers/platform/manifest.json +15 -0
- package/mcp-servers/portfolio-analysis/core.js +592 -0
- package/mcp-servers/portfolio-analysis/index.js +45 -0
- package/mcp-servers/portfolio-analysis/package-lock.json +1139 -0
- package/mcp-servers/portfolio-analysis/package.json +10 -0
- package/mcp-servers/portfolio-read/core.js +330 -0
- package/mcp-servers/portfolio-read/index.js +127 -0
- package/mcp-servers/portfolio-read/package-lock.json +1243 -0
- package/mcp-servers/portfolio-read/package.json +11 -0
- package/mcp-servers/publisher/index.js +14 -14
- package/mcp-servers/publisher/manifest.json +16 -0
- package/package.json +1 -1
- package/src/agent-manager.js +761 -188
- package/src/chat-bridge.js +567 -92
- package/src/connection.js +1 -1
- package/src/drivers/claude.js +48 -45
- package/src/drivers/codex.js +110 -8
- package/src/drivers/kimi.js +80 -35
- package/src/governance-state.js +89 -0
- package/src/index.js +34 -16
- package/src/lease-window.js +8 -0
- package/src/mcp-config.js +52 -23
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
|
-
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
25
|
-
const 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
|
-
|
|
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',
|
|
75
|
+
process.on('SIGINT', () => { shutdown('SIGINT'); });
|
|
58
76
|
process.on('SIGTERM', () => { shutdown('SIGTERM'); });
|
|
59
|
-
process.on('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
|
-
|
|
5
|
-
|
|
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,16 +46,27 @@ function resolveSkillArg(arg, config) {
|
|
|
18
46
|
return arg;
|
|
19
47
|
}
|
|
20
48
|
|
|
21
|
-
function baseEnvForServer(serverKey, { serverUrl, authToken, agentId,
|
|
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 (
|
|
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,
|
|
30
|
-
|
|
69
|
+
WORKSPACE_ID: workspaceId ?? '',
|
|
31
70
|
WORKSPACE_DIR: workspaceDir,
|
|
32
71
|
};
|
|
33
72
|
}
|
|
@@ -36,10 +75,9 @@ function baseEnvForServer(serverKey, { serverUrl, authToken, agentId, teamId, wo
|
|
|
36
75
|
|
|
37
76
|
export function buildSkillMcpServers({
|
|
38
77
|
skills,
|
|
39
|
-
credentialGrants,
|
|
40
78
|
config,
|
|
41
79
|
agentId,
|
|
42
|
-
|
|
80
|
+
workspaceId,
|
|
43
81
|
workspaceDir,
|
|
44
82
|
serverUrl,
|
|
45
83
|
authToken,
|
|
@@ -63,19 +101,10 @@ export function buildSkillMcpServers({
|
|
|
63
101
|
args: resolvedArgs,
|
|
64
102
|
env: {
|
|
65
103
|
...resolvedEnv,
|
|
66
|
-
...baseEnvForServer(mc.server, { serverUrl, authToken, agentId,
|
|
104
|
+
...baseEnvForServer(mc.server, { serverUrl, authToken, agentId, workspaceId, workspaceDir }),
|
|
67
105
|
},
|
|
68
106
|
};
|
|
69
107
|
}
|
|
70
108
|
|
|
71
|
-
for (const skill of (skills ?? [])) {
|
|
72
|
-
if (!skill.mcpConfig?.platform) continue;
|
|
73
|
-
const grant = (credentialGrants ?? []).find(g => g.platform === skill.mcpConfig.platform);
|
|
74
|
-
if (!grant) continue;
|
|
75
|
-
const serverKey = skill.mcpConfig.server;
|
|
76
|
-
if (!mcpServers[serverKey]) continue;
|
|
77
|
-
mcpServers[serverKey].env = { ...(mcpServers[serverKey].env ?? {}), ...(grant.envVars ?? {}) };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
109
|
return mcpServers;
|
|
81
110
|
}
|