@lightcone-ai/daemon 0.15.0 → 0.15.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightcone-ai/daemon",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -0,0 +1,18 @@
1
+ function normalizeInteger(value, fallback = null) {
2
+ const parsed = Number.parseInt(String(value ?? ''), 10);
3
+ if (!Number.isFinite(parsed)) return fallback;
4
+ return parsed;
5
+ }
6
+
7
+ export function resolveDurationMs(phase, fallback = 0) {
8
+ const parsed = normalizeInteger(phase?.duration_ms, null);
9
+ if (parsed !== null && parsed >= 0) return parsed;
10
+
11
+ const dwellMs = normalizeInteger(phase?.dwell_ms, null);
12
+ if (dwellMs !== null && dwellMs >= 0) return dwellMs;
13
+
14
+ const secs = Number(phase?.duration_s);
15
+ if (Number.isFinite(secs) && secs >= 0) return Math.round(secs * 1000);
16
+
17
+ return fallback;
18
+ }
@@ -0,0 +1,43 @@
1
+ import { resolveDurationMs } from './phase-duration.js';
2
+ import { normalizePlanPhases } from './plan-executor.js';
3
+
4
+ export function estimatePlanDurationMs(plan = {}) {
5
+ let phases = [];
6
+ try {
7
+ phases = normalizePlanPhases(plan);
8
+ } catch {
9
+ phases = [];
10
+ }
11
+
12
+ return phases.reduce((total, phase) => {
13
+ const action = String(phase?.action ?? phase?.visual_action?.type ?? '').trim().toLowerCase();
14
+ const durationMs = resolveDurationMs(phase, Number.NaN);
15
+ const dwellMs = Number(phase?.dwell_ms);
16
+ const transitionMs = Number(phase?.transition_ms ?? phase?.visual_action?.transition_ms);
17
+ const effectiveHoldMs = Number.isFinite(dwellMs) && dwellMs > 0
18
+ ? dwellMs
19
+ : durationMs;
20
+
21
+ if (action === 'hold' && Number.isFinite(effectiveHoldMs) && effectiveHoldMs > 0) {
22
+ return total + effectiveHoldMs;
23
+ }
24
+ if (action === 'linear_scroll_during') {
25
+ if (Number.isFinite(effectiveHoldMs) && effectiveHoldMs > 0) return total + effectiveHoldMs;
26
+ return total + 1200;
27
+ }
28
+ if (action === 'scroll_to_dwell' || action === 'cursor_focus' || action === 'scroll_back') {
29
+ let next = total;
30
+ if (Number.isFinite(transitionMs) && transitionMs > 0) next += transitionMs;
31
+ if (Number.isFinite(effectiveHoldMs) && effectiveHoldMs > 0) next += effectiveHoldMs;
32
+ if (next === total) next += 1200;
33
+ return next;
34
+ }
35
+ if (Number.isFinite(transitionMs) && transitionMs > 0) {
36
+ return total + transitionMs;
37
+ }
38
+ if (Number.isFinite(durationMs) && durationMs > 0) {
39
+ return total + durationMs;
40
+ }
41
+ return total + 800;
42
+ }, 0);
43
+ }
@@ -649,12 +649,16 @@ export class AgentManager {
649
649
  }
650
650
  }
651
651
 
652
+ const resolvedDirectiveEnvVars = normalizeObject(
653
+ this._replaceDirectiveValue(normalizeObject(directive?.env_vars), baseReplacements)
654
+ );
655
+
652
656
  const env = {
653
657
  ...process.env,
654
658
  FORCE_COLOR: '0',
655
659
  NO_COLOR: '1',
656
660
  ...Object.fromEntries(
657
- Object.entries(normalizeObject(directive?.env_vars)).map(([k, v]) => [k, String(v ?? '')])
661
+ Object.entries(resolvedDirectiveEnvVars).map(([k, v]) => [k, String(v ?? '')])
658
662
  ),
659
663
  };
660
664
 
package/src/connection.js CHANGED
@@ -69,7 +69,7 @@ export class DaemonConnection {
69
69
  let msg;
70
70
  try { msg = JSON.parse(raw.toString()); }
71
71
  catch { return; }
72
- if (msg.type !== 'pong') {
72
+ if (msg.type !== 'pong' && msg.type !== 'ping') {
73
73
  console.log(`[Connection] ← ${msg.type}${msg.agentId ? ` agent=${msg.agentId.slice(0,8)}` : ''}${msg.workspaceId ? ` workspace=${msg.workspaceId.slice(0,8)}` : ''}${msg.seq != null ? ` seq=${msg.seq}` : ''}`);
74
74
  }
75
75
  this.onMessage(msg);