@addai/node 0.30.16-msp.5 → 0.30.16-msp.6

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.
@@ -14,7 +14,11 @@ export interface ClaudePrintInput {
14
14
  appendSystemPrompt?: string;
15
15
  /** Restrict to a specific set of tools (claude only). null/undefined = inherit. */
16
16
  allowedTools?: string[];
17
+ /** How long to wait for apps before the first model call. Unset = the CLI's default. */
18
+ mcpStartupWaitMs?: number;
17
19
  }
20
+ /** The child's environment. The wait is only set when asked for, so everyone else keeps the CLI's default. */
21
+ export declare function claudePrintEnv(mcpStartupWaitMs?: number, base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
18
22
  export type ClaudePrintInputBlock = {
19
23
  type: 'text';
20
24
  text: string;
@@ -5,6 +5,7 @@
5
5
  // our normalised RuntimeEvent shape, and resolves when the process exits.
6
6
  // No PTY needed — Claude detects non-TTY and runs headless.
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.claudePrintEnv = claudePrintEnv;
8
9
  exports.claudePrintInputMessage = claudePrintInputMessage;
9
10
  exports.blockDelta = blockDelta;
10
11
  exports.lineToEvents = lineToEvents;
@@ -14,6 +15,14 @@ const claude_binary_1 = require("./claude-binary");
14
15
  const win_1 = require("./win");
15
16
  const claude_system_prompt_1 = require("./claude-system-prompt");
16
17
  const prompt_transport_1 = require("./prompt-transport");
18
+ /** The child's environment. The wait is only set when asked for, so everyone else keeps the CLI's default. */
19
+ function claudePrintEnv(mcpStartupWaitMs, base = process.env) {
20
+ return {
21
+ ...base,
22
+ TERM: 'dumb',
23
+ ...(mcpStartupWaitMs != null ? { CLAUDE_CODE_MCP_STARTUP_WAIT_MS: String(mcpStartupWaitMs) } : {}),
24
+ };
25
+ }
17
26
  /** Stream JSON reaches stdin only; files never become command-line arguments. */
18
27
  function claudePrintInputMessage(prompt, blocks) {
19
28
  if (!Array.isArray(blocks) || blocks.length < 1 || blocks.length > 12 || !blocks.every(b => b && (b.type === 'text' && typeof b.text === 'string' || ['image', 'document'].includes(b.type) && 'source' in b && b.source?.type === 'base64' && typeof b.source.data === 'string' && /^[A-Za-z0-9+/]*={0,2}$/.test(b.source.data)
@@ -204,7 +213,7 @@ function spawnClaudePrint(input) {
204
213
  const inv = (0, win_1.resolveCliInvocation)(bin, transport.args);
205
214
  proc = (0, child_process_1.spawn)(inv.file, inv.args, {
206
215
  cwd: input.workingDirectory,
207
- env: { ...process.env, TERM: 'dumb' },
216
+ env: claudePrintEnv(input.mcpStartupWaitMs),
208
217
  stdio: (0, prompt_transport_1.stdioFor)(transport.stdin),
209
218
  // No console window. This is headless work on somebody's machine —
210
219
  // on Windows a spawn without this flashes a terminal every run.
@@ -30,6 +30,9 @@ export interface MspConfig {
30
30
  silence_minutes: number;
31
31
  backstop_hours: number;
32
32
  };
33
+ /** How long a Claude turn waits for its apps before the first model call.
34
+ * At 0 they keep connecting in the background. null leaves the CLI's default. */
35
+ mcp_startup_wait_ms: number | null;
33
36
  /** A few sentences on how the entity talks, for the line. */
34
37
  voice: string;
35
38
  }
@@ -71,6 +74,7 @@ export interface MspDecision {
71
74
  /** Jev says it approves or restarts work, so it stays on the chat's tier. */
72
75
  go_ahead: boolean;
73
76
  max_run: MspConfig['max_run'];
77
+ mcp_startup_wait_ms: MspConfig['mcp_startup_wait_ms'];
74
78
  fan_out: boolean;
75
79
  }
76
80
  /**
@@ -112,6 +112,7 @@ const DEFAULT_CONFIG = {
112
112
  announce: 'always',
113
113
  overrides: { 'think hard': 'max', 'ultrathink': 'max', 'quick one': 'quick' },
114
114
  max_run: { silence_minutes: 15, backstop_hours: 6 },
115
+ mcp_startup_wait_ms: null,
115
116
  voice: '',
116
117
  };
117
118
  // Luna is codex's fast one, Terra its balanced one, Sol its coding one and Astra
@@ -185,6 +186,9 @@ function parseConfig(raw, agent = 'claude') {
185
186
  silence_minutes: num(r.max_run?.silence_minutes, 1, 120, DEFAULT_CONFIG.max_run.silence_minutes),
186
187
  backstop_hours: num(r.max_run?.backstop_hours, 0.25, 24, DEFAULT_CONFIG.max_run.backstop_hours),
187
188
  },
189
+ mcp_startup_wait_ms: typeof r.mcp_startup_wait_ms === 'number'
190
+ ? Math.round(num(r.mcp_startup_wait_ms, 0, 60_000, 0))
191
+ : null,
188
192
  voice: str(r.voice, 600),
189
193
  };
190
194
  }
@@ -547,6 +551,7 @@ async function decide(opts) {
547
551
  continues: false,
548
552
  go_ahead: false,
549
553
  max_run: cfg.max_run,
554
+ mcp_startup_wait_ms: cfg.mcp_startup_wait_ms,
550
555
  fan_out: t ? cfg.tiers[t].fan_out === true : false,
551
556
  };
552
557
  };
@@ -592,6 +597,7 @@ async function decide(opts) {
592
597
  continues,
593
598
  go_ahead: goAhead,
594
599
  max_run: cfg.max_run,
600
+ mcp_startup_wait_ms: cfg.mcp_startup_wait_ms,
595
601
  fan_out: cfg.tiers[s.tier].fan_out === true,
596
602
  };
597
603
  if (!shouldAnnounce(cfg, last, decision))
@@ -643,6 +649,7 @@ async function decide(opts) {
643
649
  continues: false,
644
650
  go_ahead: false,
645
651
  max_run: cfg.max_run,
652
+ mcp_startup_wait_ms: cfg.mcp_startup_wait_ms,
646
653
  fan_out: cfg.tiers[s.tier].fan_out === true,
647
654
  };
648
655
  if (!shouldAnnounce(cfg, last, decision))
@@ -1700,6 +1700,7 @@ async function runClaudePrint(req, cwd, installed) {
1700
1700
  resumeSessionId: req.resume_session_id ?? undefined,
1701
1701
  appendSystemPrompt: (0, time_context_1.appendTimeContext)(req.system_prompt),
1702
1702
  allowedTools: req.allowed_tools ?? undefined,
1703
+ mcpStartupWaitMs: msp?.mcp_startup_wait_ms ?? undefined,
1703
1704
  });
1704
1705
  }
1705
1706
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@addai/node",
3
- "version": "0.30.16-msp.5",
3
+ "version": "0.30.16-msp.6",
4
4
  "description": "Daemon that pairs a machine with your +Ai account and runs Claude / Codex / Kimi / Gemini agents on its behalf. Reachable via Supabase from Vault, Entity Studio, or any other +Ai surface.",
5
5
  "license": "MIT",
6
6
  "keywords": [