@lightcone-ai/daemon 0.23.1 → 0.23.3

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.
@@ -21,6 +21,11 @@ import { z } from 'zod';
21
21
  const SERVER_URL = process.env.SERVER_URL ?? '';
22
22
  const MACHINE_API_KEY = process.env.MACHINE_API_KEY ?? '';
23
23
  const AGENT_ID = process.env.AGENT_ID ?? '';
24
+ // Daemon sets LIGHTCONE_AGENT_RUNTIME (claude / codex / kimi) when it
25
+ // spawns the MCP server, so the server-side handler can route to a
26
+ // vision/LLM backend matching the calling agent's own LLM stack
27
+ // (avoid e.g. a codex agent silently using a claude vision call).
28
+ const AGENT_RUNTIME = process.env.LIGHTCONE_AGENT_RUNTIME ?? '';
24
29
 
25
30
  function toTextContent(payload) {
26
31
  let text;
@@ -37,12 +42,16 @@ async function forwardToServer(serverId, toolName, args) {
37
42
  throw new Error('thin-proxy missing SERVER_URL / MACHINE_API_KEY / AGENT_ID env');
38
43
  }
39
44
  const url = `${SERVER_URL}/internal/agent/${encodeURIComponent(AGENT_ID)}/mcp/${encodeURIComponent(serverId)}/${encodeURIComponent(toolName)}`;
45
+ const headers = {
46
+ 'Content-Type': 'application/json',
47
+ 'Authorization': `Bearer ${MACHINE_API_KEY}`,
48
+ };
49
+ if (AGENT_RUNTIME) {
50
+ headers['X-Lightcone-Agent-Runtime'] = AGENT_RUNTIME;
51
+ }
40
52
  const res = await fetch(url, {
41
53
  method: 'POST',
42
- headers: {
43
- 'Content-Type': 'application/json',
44
- 'Authorization': `Bearer ${MACHINE_API_KEY}`,
45
- },
54
+ headers,
46
55
  body: JSON.stringify(args ?? {}),
47
56
  });
48
57
  let body = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.23.1",
3
+ "version": "0.23.3",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -707,6 +707,12 @@ export class AgentManager {
707
707
 
708
708
  _buildCodexMcpArgs(mcpServers) {
709
709
  const args = [];
710
+ // Codex's default tool_timeout_sec for MCP tool calls is short (~120s).
711
+ // Fine for fast tools, but kills slow vision/analysis tools — notably
712
+ // `page-understanding/analyze_page` which takes 5-10 min on long
713
+ // mp.weixin articles. Apply a 900s ceiling to every MCP server here;
714
+ // fast tools return well within this, slow tools stop getting killed.
715
+ const TOOL_TIMEOUT_SEC = 900;
710
716
  for (const [serverKey, server] of Object.entries(mcpServers)) {
711
717
  const normalizedKey = String(serverKey ?? '').trim();
712
718
  if (!normalizedKey) continue;
@@ -722,6 +728,7 @@ export class AgentManager {
722
728
  '-c', `mcp_servers.${keyExpr}.command=${commandExpr}`,
723
729
  '-c', `mcp_servers.${keyExpr}.args=${argsExpr}`,
724
730
  '-c', `mcp_servers.${keyExpr}.enabled=true`,
731
+ '-c', `mcp_servers.${keyExpr}.tool_timeout_sec=${TOOL_TIMEOUT_SEC}`,
725
732
  );
726
733
  if (server.required === true) {
727
734
  args.push('-c', `mcp_servers.${keyExpr}.required=true`);
@@ -788,6 +795,16 @@ export class AgentManager {
788
795
  '${WECHAT_MP_PROFILE_DIR}': path.join(profileRoot, `wechat_mp-${userId}`),
789
796
  };
790
797
  const mcpServers = this._resolveDirectiveMcpServers(directive, baseReplacements);
798
+ // Inject LIGHTCONE_AGENT_RUNTIME into every MCP server's env so that
799
+ // server-side handlers (reached via thin-proxy) can route to a backend
800
+ // matching the calling agent's own LLM stack. Example: analyze_page
801
+ // uses this to pick codex vision for codex agents and claude vision
802
+ // for claude agents — avoiding cross-vendor spawn chains.
803
+ for (const server of Object.values(mcpServers)) {
804
+ if (server && typeof server === 'object') {
805
+ server.env = { ...(server.env ?? {}), LIGHTCONE_AGENT_RUNTIME: runtime };
806
+ }
807
+ }
791
808
 
792
809
  if (runtime === 'codex') {
793
810
  const mcpKeys = Object.keys(mcpServers);
@@ -214,13 +214,6 @@ export function buildCodexSpawn({
214
214
  authToken: config.authToken || machineApiKey,
215
215
  });
216
216
 
217
- // Codex's default tool_timeout_sec for MCP tool calls is 60-120s. That's
218
- // fine for fast tools (chat, db, etc) but breaks slow vision/analysis
219
- // tools — notably `page-understanding/analyze_page` which takes 5-10 min
220
- // on long mp.weixin articles (4 chunks × 1.6MB PNG → Claude vision OCR).
221
- // Apply a generous 900s ceiling to every skill MCP server. Fast tools
222
- // return well within this; slow tools no longer get prematurely killed.
223
- const SKILL_TOOL_TIMEOUT_SEC = 900;
224
217
  for (const [serverKey, mc] of Object.entries(skillMcpServers)) {
225
218
  const keyExpr = formatCodexServerKey(serverKey);
226
219
  if (!keyExpr) continue;
@@ -229,16 +222,14 @@ export function buildCodexSpawn({
229
222
  args.push(
230
223
  '-c', `mcp_servers.${keyExpr}.command=${quote('env')}`,
231
224
  '-c', `mcp_servers.${keyExpr}.args=${quote([...envPairs, mc.command, ...(mc.args ?? [])])}`,
232
- '-c', `mcp_servers.${keyExpr}.enabled=true`,
233
- '-c', `mcp_servers.${keyExpr}.tool_timeout_sec=${SKILL_TOOL_TIMEOUT_SEC}`
225
+ '-c', `mcp_servers.${keyExpr}.enabled=true`
234
226
  );
235
227
  continue;
236
228
  }
237
229
  args.push(
238
230
  '-c', `mcp_servers.${keyExpr}.command=${quote(mc.command)}`,
239
231
  '-c', `mcp_servers.${keyExpr}.args=${quote(mc.args ?? [])}`,
240
- '-c', `mcp_servers.${keyExpr}.enabled=true`,
241
- '-c', `mcp_servers.${keyExpr}.tool_timeout_sec=${SKILL_TOOL_TIMEOUT_SEC}`
232
+ '-c', `mcp_servers.${keyExpr}.enabled=true`
242
233
  );
243
234
  }
244
235