pulseed 0.4.0 → 0.4.1
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/dist/base/state/state-manager-goal-write.d.ts +22 -0
- package/dist/base/state/state-manager-goal-write.d.ts.map +1 -0
- package/dist/base/state/state-manager-goal-write.js +74 -0
- package/dist/base/state/state-manager-goal-write.js.map +1 -0
- package/dist/base/state/state-manager-wal.d.ts +11 -0
- package/dist/base/state/state-manager-wal.d.ts.map +1 -0
- package/dist/base/state/state-manager-wal.js +89 -0
- package/dist/base/state/state-manager-wal.js.map +1 -0
- package/dist/base/state/state-manager.d.ts +1 -4
- package/dist/base/state/state-manager.d.ts.map +1 -1
- package/dist/base/state/state-manager.js +18 -127
- package/dist/base/state/state-manager.js.map +1 -1
- package/dist/interface/chat/chat-runner.d.ts +1 -1
- package/dist/interface/chat/event-subscriber.d.ts +4 -0
- package/dist/interface/chat/event-subscriber.d.ts.map +1 -1
- package/dist/interface/chat/event-subscriber.js +49 -2
- package/dist/interface/chat/event-subscriber.js.map +1 -1
- package/dist/interface/chat/tend-command.d.ts +1 -1
- package/dist/interface/cli/cli-command-registry.js +1 -1
- package/dist/interface/cli/cli-command-registry.js.map +1 -1
- package/dist/interface/cli/commands/chat.js +2 -2
- package/dist/interface/cli/commands/daemon.d.ts.map +1 -1
- package/dist/interface/cli/commands/daemon.js +87 -44
- package/dist/interface/cli/commands/daemon.js.map +1 -1
- package/dist/interface/cli/commands/schedule.js +2 -2
- package/dist/interface/cli/commands/setup/steps-runtime.js +1 -1
- package/dist/interface/cli/ensure-api-key.d.ts +4 -1
- package/dist/interface/cli/ensure-api-key.d.ts.map +1 -1
- package/dist/interface/cli/ensure-api-key.js +52 -15
- package/dist/interface/cli/ensure-api-key.js.map +1 -1
- package/dist/interface/tui/app.d.ts +1 -1
- package/dist/interface/tui/chat/scroll.d.ts +14 -0
- package/dist/interface/tui/chat/scroll.d.ts.map +1 -0
- package/dist/interface/tui/chat/scroll.js +46 -0
- package/dist/interface/tui/chat/scroll.js.map +1 -0
- package/dist/interface/tui/chat/suggestions.d.ts +8 -0
- package/dist/interface/tui/chat/suggestions.d.ts.map +1 -0
- package/dist/interface/tui/chat/suggestions.js +112 -0
- package/dist/interface/tui/chat/suggestions.js.map +1 -0
- package/dist/interface/tui/chat/types.d.ts +31 -0
- package/dist/interface/tui/chat/types.d.ts.map +1 -0
- package/dist/interface/tui/chat/types.js +2 -0
- package/dist/interface/tui/chat/types.js.map +1 -0
- package/dist/interface/tui/chat/viewport.d.ts +3 -0
- package/dist/interface/tui/chat/viewport.d.ts.map +1 -0
- package/dist/interface/tui/chat/viewport.js +78 -0
- package/dist/interface/tui/chat/viewport.js.map +1 -0
- package/dist/interface/tui/chat.d.ts +5 -49
- package/dist/interface/tui/chat.d.ts.map +1 -1
- package/dist/interface/tui/chat.js +7 -236
- package/dist/interface/tui/chat.js.map +1 -1
- package/dist/interface/tui/entry.js +3 -3
- package/dist/interface/tui/use-loop.d.ts +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts +3 -0
- package/dist/orchestrator/execution/task/task-lifecycle.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-lifecycle.js +3 -0
- package/dist/orchestrator/execution/task/task-lifecycle.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-rules.d.ts.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-rules.js +34 -2
- package/dist/orchestrator/execution/task/task-verifier-rules.js.map +1 -1
- package/dist/orchestrator/execution/task/task-verifier-types.d.ts +2 -0
- package/dist/orchestrator/execution/task/task-verifier-types.d.ts.map +1 -1
- package/dist/orchestrator/loop/checkpoint-manager-loop.d.ts +1 -1
- package/dist/orchestrator/loop/checkpoint-manager-loop.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop/capability.d.ts +22 -0
- package/dist/orchestrator/loop/core-loop/capability.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/capability.js +151 -0
- package/dist/orchestrator/loop/core-loop/capability.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/contracts.d.ts +245 -0
- package/dist/orchestrator/loop/core-loop/contracts.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/contracts.js +40 -0
- package/dist/orchestrator/loop/core-loop/contracts.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/control.d.ts +27 -0
- package/dist/orchestrator/loop/core-loop/control.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/control.js +72 -0
- package/dist/orchestrator/loop/core-loop/control.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/learning.d.ts +31 -0
- package/dist/orchestrator/loop/core-loop/learning.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/learning.js +92 -0
- package/dist/orchestrator/loop/core-loop/learning.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/preparation.d.ts +63 -0
- package/dist/orchestrator/loop/core-loop/preparation.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/preparation.js +362 -0
- package/dist/orchestrator/loop/core-loop/preparation.js.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts +29 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.d.ts.map +1 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.js +674 -0
- package/dist/orchestrator/loop/core-loop/task-cycle.js.map +1 -0
- package/dist/orchestrator/loop/core-loop-capability.d.ts +1 -24
- package/dist/orchestrator/loop/core-loop-capability.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop-capability.js +1 -153
- package/dist/orchestrator/loop/core-loop-capability.js.map +1 -1
- package/dist/orchestrator/loop/core-loop-learning.d.ts +1 -34
- package/dist/orchestrator/loop/core-loop-learning.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop-learning.js +1 -95
- package/dist/orchestrator/loop/core-loop-learning.js.map +1 -1
- package/dist/orchestrator/loop/core-loop-phases-b.d.ts +1 -31
- package/dist/orchestrator/loop/core-loop-phases-b.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop-phases-b.js +1 -669
- package/dist/orchestrator/loop/core-loop-phases-b.js.map +1 -1
- package/dist/orchestrator/loop/core-loop-phases-c.d.ts +1 -26
- package/dist/orchestrator/loop/core-loop-phases-c.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop-phases-c.js +1 -71
- package/dist/orchestrator/loop/core-loop-phases-c.js.map +1 -1
- package/dist/orchestrator/loop/core-loop-phases.d.ts +1 -68
- package/dist/orchestrator/loop/core-loop-phases.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop-phases.js +1 -367
- package/dist/orchestrator/loop/core-loop-phases.js.map +1 -1
- package/dist/orchestrator/loop/core-loop-types.d.ts +1 -244
- package/dist/orchestrator/loop/core-loop-types.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop-types.js +1 -39
- package/dist/orchestrator/loop/core-loop-types.js.map +1 -1
- package/dist/orchestrator/loop/core-loop.d.ts +3 -3
- package/dist/orchestrator/loop/core-loop.d.ts.map +1 -1
- package/dist/orchestrator/loop/core-loop.js +6 -6
- package/dist/orchestrator/loop/core-loop.js.map +1 -1
- package/dist/orchestrator/loop/loop-report-helper.d.ts +1 -1
- package/dist/orchestrator/loop/loop-report-helper.d.ts.map +1 -1
- package/dist/orchestrator/loop/parallel-dispatch.d.ts +2 -2
- package/dist/orchestrator/loop/parallel-dispatch.d.ts.map +1 -1
- package/dist/orchestrator/loop/post-loop-hooks.d.ts +1 -1
- package/dist/orchestrator/loop/post-loop-hooks.d.ts.map +1 -1
- package/dist/orchestrator/loop/tree-loop-runner.d.ts +1 -1
- package/dist/orchestrator/loop/tree-loop-runner.d.ts.map +1 -1
- package/dist/orchestrator/loop/tree-loop-runner.js +1 -1
- package/dist/orchestrator/loop/tree-loop-runner.js.map +1 -1
- package/dist/platform/dream/dream-schedule-suggestions.d.ts +1 -1
- package/dist/platform/drive/drive-system.d.ts +8 -0
- package/dist/platform/drive/drive-system.d.ts.map +1 -1
- package/dist/platform/drive/drive-system.js +39 -22
- package/dist/platform/drive/drive-system.js.map +1 -1
- package/dist/platform/observation/engine/observe-context.d.ts +4 -0
- package/dist/platform/observation/engine/observe-context.d.ts.map +1 -0
- package/dist/platform/observation/engine/observe-context.js +26 -0
- package/dist/platform/observation/engine/observe-context.js.map +1 -0
- package/dist/platform/observation/engine/observe-datasource-stage.d.ts +33 -0
- package/dist/platform/observation/engine/observe-datasource-stage.d.ts.map +1 -0
- package/dist/platform/observation/engine/observe-datasource-stage.js +66 -0
- package/dist/platform/observation/engine/observe-datasource-stage.js.map +1 -0
- package/dist/platform/observation/engine/observe-llm-stage.d.ts +25 -0
- package/dist/platform/observation/engine/observe-llm-stage.d.ts.map +1 -0
- package/dist/platform/observation/engine/observe-llm-stage.js +79 -0
- package/dist/platform/observation/engine/observe-llm-stage.js.map +1 -0
- package/dist/platform/observation/engine/observe-precheck.d.ts +21 -0
- package/dist/platform/observation/engine/observe-precheck.d.ts.map +1 -0
- package/dist/platform/observation/engine/observe-precheck.js +51 -0
- package/dist/platform/observation/engine/observe-precheck.js.map +1 -0
- package/dist/platform/observation/engine/observe-self-report.d.ts +18 -0
- package/dist/platform/observation/engine/observe-self-report.d.ts.map +1 -0
- package/dist/platform/observation/engine/observe-self-report.js +26 -0
- package/dist/platform/observation/engine/observe-self-report.js.map +1 -0
- package/dist/platform/observation/engine/observe-tool-stage.d.ts +21 -0
- package/dist/platform/observation/engine/observe-tool-stage.d.ts.map +1 -0
- package/dist/platform/observation/engine/observe-tool-stage.js +49 -0
- package/dist/platform/observation/engine/observe-tool-stage.js.map +1 -0
- package/dist/platform/observation/observation-engine.d.ts.map +1 -1
- package/dist/platform/observation/observation-engine.js +67 -246
- package/dist/platform/observation/observation-engine.js.map +1 -1
- package/dist/prompt/context-assembler.d.ts +61 -13
- package/dist/prompt/context-assembler.d.ts.map +1 -1
- package/dist/prompt/context-assembler.js +18 -3
- package/dist/prompt/context-assembler.js.map +1 -1
- package/dist/runtime/approval-broker.d.ts.map +1 -1
- package/dist/runtime/approval-broker.js +1 -0
- package/dist/runtime/approval-broker.js.map +1 -1
- package/dist/runtime/command-dispatcher.d.ts +35 -0
- package/dist/runtime/command-dispatcher.d.ts.map +1 -0
- package/dist/runtime/command-dispatcher.js +145 -0
- package/dist/runtime/command-dispatcher.js.map +1 -0
- package/dist/runtime/daemon/client.d.ts +67 -0
- package/dist/runtime/daemon/client.d.ts.map +1 -0
- package/dist/runtime/daemon/client.js +330 -0
- package/dist/runtime/daemon/client.js.map +1 -0
- package/dist/runtime/daemon/health.d.ts +31 -0
- package/dist/runtime/daemon/health.d.ts.map +1 -0
- package/dist/runtime/daemon/health.js +113 -0
- package/dist/runtime/daemon/health.js.map +1 -0
- package/dist/runtime/daemon/index.d.ts +9 -0
- package/dist/runtime/daemon/index.d.ts.map +1 -0
- package/dist/runtime/daemon/index.js +8 -0
- package/dist/runtime/daemon/index.js.map +1 -0
- package/dist/runtime/daemon/maintenance.d.ts +47 -0
- package/dist/runtime/daemon/maintenance.d.ts.map +1 -0
- package/dist/runtime/daemon/maintenance.js +230 -0
- package/dist/runtime/daemon/maintenance.js.map +1 -0
- package/dist/runtime/daemon/persistence.d.ts +20 -0
- package/dist/runtime/daemon/persistence.d.ts.map +1 -0
- package/dist/runtime/daemon/persistence.js +112 -0
- package/dist/runtime/daemon/persistence.js.map +1 -0
- package/dist/runtime/daemon/runner-lifecycle.d.ts +29 -0
- package/dist/runtime/daemon/runner-lifecycle.d.ts.map +1 -0
- package/dist/runtime/daemon/runner-lifecycle.js +56 -0
- package/dist/runtime/daemon/runner-lifecycle.js.map +1 -0
- package/dist/runtime/daemon/runner.d.ts +229 -0
- package/dist/runtime/daemon/runner.d.ts.map +1 -0
- package/dist/runtime/daemon/runner.js +875 -0
- package/dist/runtime/daemon/runner.js.map +1 -0
- package/dist/runtime/daemon/runtime-ownership.d.ts +30 -0
- package/dist/runtime/daemon/runtime-ownership.d.ts.map +1 -0
- package/dist/runtime/daemon/runtime-ownership.js +132 -0
- package/dist/runtime/daemon/runtime-ownership.js.map +1 -0
- package/dist/runtime/daemon/signals.d.ts +17 -0
- package/dist/runtime/daemon/signals.d.ts.map +1 -0
- package/dist/runtime/daemon/signals.js +31 -0
- package/dist/runtime/daemon/signals.js.map +1 -0
- package/dist/runtime/daemon/types.d.ts +8 -0
- package/dist/runtime/daemon/types.d.ts.map +1 -0
- package/dist/runtime/daemon/types.js +2 -0
- package/dist/runtime/daemon/types.js.map +1 -0
- package/dist/runtime/daemon-client.d.ts +1 -55
- package/dist/runtime/daemon-client.d.ts.map +1 -1
- package/dist/runtime/daemon-client.js +1 -297
- package/dist/runtime/daemon-client.js.map +1 -1
- package/dist/runtime/daemon-health.d.ts +1 -30
- package/dist/runtime/daemon-health.d.ts.map +1 -1
- package/dist/runtime/daemon-health.js +1 -112
- package/dist/runtime/daemon-health.js.map +1 -1
- package/dist/runtime/daemon-runner-lifecycle.d.ts +2 -0
- package/dist/runtime/daemon-runner-lifecycle.d.ts.map +1 -0
- package/dist/runtime/daemon-runner-lifecycle.js +2 -0
- package/dist/runtime/daemon-runner-lifecycle.js.map +1 -0
- package/dist/runtime/daemon-runner.d.ts +1 -231
- package/dist/runtime/daemon-runner.d.ts.map +1 -1
- package/dist/runtime/daemon-runner.js +1 -1042
- package/dist/runtime/daemon-runner.js.map +1 -1
- package/dist/runtime/daemon-runtime-ownership.d.ts +2 -0
- package/dist/runtime/daemon-runtime-ownership.d.ts.map +1 -0
- package/dist/runtime/daemon-runtime-ownership.js +2 -0
- package/dist/runtime/daemon-runtime-ownership.js.map +1 -0
- package/dist/runtime/daemon-signals.d.ts +1 -16
- package/dist/runtime/daemon-signals.d.ts.map +1 -1
- package/dist/runtime/daemon-signals.js +1 -30
- package/dist/runtime/daemon-signals.js.map +1 -1
- package/dist/runtime/event/dispatcher.d.ts +34 -0
- package/dist/runtime/event/dispatcher.d.ts.map +1 -0
- package/dist/runtime/event/dispatcher.js +124 -0
- package/dist/runtime/event/dispatcher.js.map +1 -0
- package/dist/runtime/event/index.d.ts +5 -0
- package/dist/runtime/event/index.d.ts.map +1 -0
- package/dist/runtime/event/index.js +5 -0
- package/dist/runtime/event/index.js.map +1 -0
- package/dist/runtime/event/server-snapshot-reader.d.ts +31 -0
- package/dist/runtime/event/server-snapshot-reader.d.ts.map +1 -0
- package/dist/runtime/event/server-snapshot-reader.js +94 -0
- package/dist/runtime/event/server-snapshot-reader.js.map +1 -0
- package/dist/runtime/event/server-sse.d.ts +25 -0
- package/dist/runtime/event/server-sse.d.ts.map +1 -0
- package/dist/runtime/event/server-sse.js +149 -0
- package/dist/runtime/event/server-sse.js.map +1 -0
- package/dist/runtime/event/server.d.ts +114 -0
- package/dist/runtime/event/server.d.ts.map +1 -0
- package/dist/runtime/event/server.js +651 -0
- package/dist/runtime/event/server.js.map +1 -0
- package/dist/runtime/event-dispatcher.d.ts +2 -0
- package/dist/runtime/event-dispatcher.d.ts.map +1 -0
- package/dist/runtime/event-dispatcher.js +2 -0
- package/dist/runtime/event-dispatcher.js.map +1 -0
- package/dist/runtime/event-server-snapshot-reader.d.ts +2 -0
- package/dist/runtime/event-server-snapshot-reader.d.ts.map +1 -0
- package/dist/runtime/event-server-snapshot-reader.js +2 -0
- package/dist/runtime/event-server-snapshot-reader.js.map +1 -0
- package/dist/runtime/event-server-sse.d.ts +2 -0
- package/dist/runtime/event-server-sse.d.ts.map +1 -0
- package/dist/runtime/event-server-sse.js +2 -0
- package/dist/runtime/event-server-sse.js.map +1 -0
- package/dist/runtime/event-server.d.ts +1 -91
- package/dist/runtime/event-server.d.ts.map +1 -1
- package/dist/runtime/event-server.js +1 -698
- package/dist/runtime/event-server.js.map +1 -1
- package/dist/runtime/executor/loop-supervisor.d.ts +9 -5
- package/dist/runtime/executor/loop-supervisor.d.ts.map +1 -1
- package/dist/runtime/executor/loop-supervisor.js +59 -76
- package/dist/runtime/executor/loop-supervisor.js.map +1 -1
- package/dist/runtime/gateway/http-channel-adapter.d.ts +1 -1
- package/dist/runtime/plugin-loader.d.ts +1 -1
- package/dist/runtime/queue/index.d.ts +0 -4
- package/dist/runtime/queue/index.d.ts.map +1 -1
- package/dist/runtime/queue/index.js +0 -2
- package/dist/runtime/queue/index.js.map +1 -1
- package/dist/runtime/queue/journal-backed-queue.d.ts.map +1 -1
- package/dist/runtime/queue/journal-backed-queue.js +2 -0
- package/dist/runtime/queue/journal-backed-queue.js.map +1 -1
- package/dist/runtime/schedule/engine-layers.d.ts +44 -0
- package/dist/runtime/schedule/engine-layers.d.ts.map +1 -0
- package/dist/runtime/schedule/engine-layers.js +433 -0
- package/dist/runtime/schedule/engine-layers.js.map +1 -0
- package/dist/runtime/schedule/engine.d.ts +82 -0
- package/dist/runtime/schedule/engine.d.ts.map +1 -0
- package/dist/runtime/schedule/engine.js +480 -0
- package/dist/runtime/schedule/engine.js.map +1 -0
- package/dist/runtime/schedule/index.d.ts +5 -0
- package/dist/runtime/schedule/index.d.ts.map +1 -0
- package/dist/runtime/schedule/index.js +5 -0
- package/dist/runtime/schedule/index.js.map +1 -0
- package/dist/runtime/schedule/presets.d.ts +536 -0
- package/dist/runtime/schedule/presets.d.ts.map +1 -0
- package/dist/runtime/schedule/presets.js +166 -0
- package/dist/runtime/schedule/presets.js.map +1 -0
- package/dist/runtime/schedule/source.d.ts +65 -0
- package/dist/runtime/schedule/source.d.ts.map +1 -0
- package/dist/runtime/schedule/source.js +16 -0
- package/dist/runtime/schedule/source.js.map +1 -0
- package/dist/runtime/schedule-engine-layers.d.ts +1 -43
- package/dist/runtime/schedule-engine-layers.d.ts.map +1 -1
- package/dist/runtime/schedule-engine-layers.js +1 -432
- package/dist/runtime/schedule-engine-layers.js.map +1 -1
- package/dist/runtime/schedule-engine.d.ts +1 -81
- package/dist/runtime/schedule-engine.d.ts.map +1 -1
- package/dist/runtime/schedule-engine.js +1 -479
- package/dist/runtime/schedule-engine.js.map +1 -1
- package/dist/runtime/schedule-presets.d.ts +1 -535
- package/dist/runtime/schedule-presets.d.ts.map +1 -1
- package/dist/runtime/schedule-presets.js +1 -165
- package/dist/runtime/schedule-presets.js.map +1 -1
- package/dist/runtime/schedule-source.d.ts +1 -64
- package/dist/runtime/schedule-source.d.ts.map +1 -1
- package/dist/runtime/schedule-source.js +1 -15
- package/dist/runtime/schedule-source.js.map +1 -1
- package/dist/runtime/types/daemon.d.ts.map +1 -1
- package/dist/runtime/types/daemon.js +2 -1
- package/dist/runtime/types/daemon.js.map +1 -1
- package/dist/runtime/watchdog.d.ts +44 -0
- package/dist/runtime/watchdog.d.ts.map +1 -0
- package/dist/runtime/watchdog.js +185 -0
- package/dist/runtime/watchdog.js.map +1 -0
- package/dist/tools/builtin/index.d.ts +1 -1
- package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.d.ts +1 -1
- package/dist/tools/schedule/CreateScheduleTool/CreateScheduleTool.js +1 -1
- package/dist/tools/schedule/GetScheduleTool/GetScheduleTool.d.ts +1 -1
- package/dist/tools/schedule/ListSchedulesTool/ListSchedulesTool.d.ts +1 -1
- package/dist/tools/schedule/PauseScheduleTool/PauseScheduleTool.d.ts +1 -1
- package/dist/tools/schedule/RemoveScheduleTool/RemoveScheduleTool.d.ts +1 -1
- package/dist/tools/schedule/ResumeScheduleTool/ResumeScheduleTool.d.ts +1 -1
- package/dist/tools/schedule/UpdateScheduleTool/UpdateScheduleTool.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,298 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// Client library for connecting to PulSeed daemon's EventServer.
|
|
4
|
-
// Receives events via SSE, sends commands via REST.
|
|
5
|
-
import http from "node:http";
|
|
6
|
-
import { DEFAULT_PORT } from "./port-utils.js";
|
|
7
|
-
export class DaemonClient {
|
|
8
|
-
config;
|
|
9
|
-
handlers = new Map();
|
|
10
|
-
sseRequest = null;
|
|
11
|
-
reconnectAttempts = 0;
|
|
12
|
-
reconnectTimer = null;
|
|
13
|
-
connected = false;
|
|
14
|
-
stopped = false;
|
|
15
|
-
lastEventId = null;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
this.config = {
|
|
18
|
-
host: config.host,
|
|
19
|
-
port: config.port,
|
|
20
|
-
reconnectInterval: config.reconnectInterval ?? 3000,
|
|
21
|
-
maxReconnectAttempts: config.maxReconnectAttempts ?? 10,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
// ─── SSE Connection ───
|
|
25
|
-
connect() {
|
|
26
|
-
this.stopped = false;
|
|
27
|
-
this.connectSSE();
|
|
28
|
-
}
|
|
29
|
-
connectSSE() {
|
|
30
|
-
if (this.stopped)
|
|
31
|
-
return;
|
|
32
|
-
const headers = {
|
|
33
|
-
Accept: "text/event-stream",
|
|
34
|
-
"Cache-Control": "no-cache",
|
|
35
|
-
};
|
|
36
|
-
if (this.lastEventId) {
|
|
37
|
-
headers["Last-Event-ID"] = this.lastEventId;
|
|
38
|
-
}
|
|
39
|
-
const req = http.get({
|
|
40
|
-
hostname: this.config.host,
|
|
41
|
-
port: this.config.port,
|
|
42
|
-
path: "/stream",
|
|
43
|
-
headers,
|
|
44
|
-
}, (res) => {
|
|
45
|
-
if (res.statusCode !== 200) {
|
|
46
|
-
res.resume();
|
|
47
|
-
this.scheduleReconnect();
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.connected = true;
|
|
51
|
-
this.reconnectAttempts = 0;
|
|
52
|
-
this.emit("_connected", { timestamp: new Date().toISOString() });
|
|
53
|
-
let buffer = "";
|
|
54
|
-
res.setEncoding("utf-8");
|
|
55
|
-
res.on("data", (chunk) => {
|
|
56
|
-
buffer += chunk;
|
|
57
|
-
const parts = buffer.split("\n\n");
|
|
58
|
-
buffer = parts.pop() ?? "";
|
|
59
|
-
for (const part of parts) {
|
|
60
|
-
this.parseSSEMessage(part);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
res.on("end", () => {
|
|
64
|
-
this.connected = false;
|
|
65
|
-
this.emit("_disconnected", {});
|
|
66
|
-
this.scheduleReconnect();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
req.on("error", () => {
|
|
70
|
-
this.connected = false;
|
|
71
|
-
this.scheduleReconnect();
|
|
72
|
-
});
|
|
73
|
-
this.sseRequest = req;
|
|
74
|
-
}
|
|
75
|
-
parseSSEMessage(raw) {
|
|
76
|
-
let id = "";
|
|
77
|
-
let event = "message";
|
|
78
|
-
let data = "";
|
|
79
|
-
for (const line of raw.split("\n")) {
|
|
80
|
-
if (line.startsWith("id: ")) {
|
|
81
|
-
id = line.slice(4);
|
|
82
|
-
}
|
|
83
|
-
else if (line.startsWith("event: ")) {
|
|
84
|
-
event = line.slice(7);
|
|
85
|
-
}
|
|
86
|
-
else if (line.startsWith("data: ")) {
|
|
87
|
-
data += line.slice(6);
|
|
88
|
-
}
|
|
89
|
-
else if (line.startsWith(": ")) {
|
|
90
|
-
// Comment (keepalive), ignore
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (id)
|
|
94
|
-
this.lastEventId = id;
|
|
95
|
-
if (!data && event === "message")
|
|
96
|
-
return;
|
|
97
|
-
let parsed;
|
|
98
|
-
try {
|
|
99
|
-
parsed = JSON.parse(data);
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
parsed = data;
|
|
103
|
-
}
|
|
104
|
-
this.emit(event, parsed);
|
|
105
|
-
}
|
|
106
|
-
scheduleReconnect() {
|
|
107
|
-
if (this.stopped)
|
|
108
|
-
return;
|
|
109
|
-
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
110
|
-
this.emit("_reconnect_failed", { attempts: this.reconnectAttempts });
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
this.reconnectAttempts++;
|
|
114
|
-
const delay = Math.min(this.config.reconnectInterval * Math.pow(1.5, this.reconnectAttempts - 1), 30_000);
|
|
115
|
-
this.reconnectTimer = setTimeout(() => this.connectSSE(), delay);
|
|
116
|
-
}
|
|
117
|
-
disconnect() {
|
|
118
|
-
this.stopped = true;
|
|
119
|
-
this.connected = false;
|
|
120
|
-
if (this.reconnectTimer) {
|
|
121
|
-
clearTimeout(this.reconnectTimer);
|
|
122
|
-
this.reconnectTimer = null;
|
|
123
|
-
}
|
|
124
|
-
if (this.sseRequest) {
|
|
125
|
-
this.sseRequest.destroy();
|
|
126
|
-
this.sseRequest = null;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
isConnected() {
|
|
130
|
-
return this.connected;
|
|
131
|
-
}
|
|
132
|
-
// ─── Event Handling ───
|
|
133
|
-
on(event, handler) {
|
|
134
|
-
if (!this.handlers.has(event)) {
|
|
135
|
-
this.handlers.set(event, new Set());
|
|
136
|
-
}
|
|
137
|
-
this.handlers.get(event).add(handler);
|
|
138
|
-
}
|
|
139
|
-
off(event, handler) {
|
|
140
|
-
this.handlers.get(event)?.delete(handler);
|
|
141
|
-
}
|
|
142
|
-
emit(event, data) {
|
|
143
|
-
const handlers = this.handlers.get(event);
|
|
144
|
-
if (handlers) {
|
|
145
|
-
for (const handler of handlers) {
|
|
146
|
-
try {
|
|
147
|
-
handler(data);
|
|
148
|
-
}
|
|
149
|
-
catch {
|
|
150
|
-
// Don't let handler errors break the event loop
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
// Also emit to wildcard listeners
|
|
155
|
-
const wildcardHandlers = this.handlers.get("*");
|
|
156
|
-
if (wildcardHandlers) {
|
|
157
|
-
for (const handler of wildcardHandlers) {
|
|
158
|
-
try {
|
|
159
|
-
handler({ type: event, data });
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
// ignore
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// ─── REST Commands ───
|
|
168
|
-
async startGoal(goalId) {
|
|
169
|
-
return this.post(`/goals/${encodeURIComponent(goalId)}/start`, {});
|
|
170
|
-
}
|
|
171
|
-
async stopGoal(goalId) {
|
|
172
|
-
return this.post(`/goals/${encodeURIComponent(goalId)}/stop`, {});
|
|
173
|
-
}
|
|
174
|
-
async approve(goalId, requestId, approved) {
|
|
175
|
-
return this.post(`/goals/${encodeURIComponent(goalId)}/approve`, { requestId, approved });
|
|
176
|
-
}
|
|
177
|
-
async chat(goalId, message) {
|
|
178
|
-
return this.post(`/goals/${encodeURIComponent(goalId)}/chat`, { message });
|
|
179
|
-
}
|
|
180
|
-
async getStatus() {
|
|
181
|
-
return this.get("/daemon/status");
|
|
182
|
-
}
|
|
183
|
-
async getGoals() {
|
|
184
|
-
return this.get("/goals");
|
|
185
|
-
}
|
|
186
|
-
async getGoal(goalId) {
|
|
187
|
-
return this.get(`/goals/${encodeURIComponent(goalId)}`);
|
|
188
|
-
}
|
|
189
|
-
async healthCheck() {
|
|
190
|
-
try {
|
|
191
|
-
await this.get("/health");
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
catch {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
// ─── HTTP Helpers ───
|
|
199
|
-
get(path) {
|
|
200
|
-
return new Promise((resolve, reject) => {
|
|
201
|
-
const req = http.get({ hostname: this.config.host, port: this.config.port, path }, (res) => {
|
|
202
|
-
let body = "";
|
|
203
|
-
res.setEncoding("utf-8");
|
|
204
|
-
res.on("data", (chunk) => { body += chunk; });
|
|
205
|
-
res.on("end", () => {
|
|
206
|
-
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
207
|
-
try {
|
|
208
|
-
resolve(JSON.parse(body));
|
|
209
|
-
}
|
|
210
|
-
catch {
|
|
211
|
-
resolve(body);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
reject(new Error(`HTTP ${res.statusCode}: ${body}`));
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
req.on("error", reject);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
post(path, data) {
|
|
223
|
-
return new Promise((resolve, reject) => {
|
|
224
|
-
const body = JSON.stringify(data);
|
|
225
|
-
const req = http.request({
|
|
226
|
-
hostname: this.config.host,
|
|
227
|
-
port: this.config.port,
|
|
228
|
-
path,
|
|
229
|
-
method: "POST",
|
|
230
|
-
headers: {
|
|
231
|
-
"Content-Type": "application/json",
|
|
232
|
-
"Content-Length": Buffer.byteLength(body),
|
|
233
|
-
},
|
|
234
|
-
}, (res) => {
|
|
235
|
-
let responseBody = "";
|
|
236
|
-
res.setEncoding("utf-8");
|
|
237
|
-
res.on("data", (chunk) => { responseBody += chunk; });
|
|
238
|
-
res.on("end", () => {
|
|
239
|
-
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
240
|
-
try {
|
|
241
|
-
resolve(JSON.parse(responseBody));
|
|
242
|
-
}
|
|
243
|
-
catch {
|
|
244
|
-
resolve({ ok: true });
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
reject(new Error(`HTTP ${res.statusCode}: ${responseBody}`));
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
req.on("error", reject);
|
|
253
|
-
req.write(body);
|
|
254
|
-
req.end();
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
// ─── Convenience: detect running daemon ───
|
|
259
|
-
export async function isDaemonRunning(baseDir) {
|
|
260
|
-
const fs = await import("node:fs/promises");
|
|
261
|
-
const path = await import("node:path");
|
|
262
|
-
// DEFAULT_PORT imported from port-utils
|
|
263
|
-
try {
|
|
264
|
-
const statePath = path.join(baseDir, "daemon-state.json");
|
|
265
|
-
const raw = await fs.readFile(statePath, "utf-8");
|
|
266
|
-
const state = JSON.parse(raw);
|
|
267
|
-
if (state.status !== "running" || !state.pid) {
|
|
268
|
-
return { running: false, port: DEFAULT_PORT };
|
|
269
|
-
}
|
|
270
|
-
// Check if PID is actually alive
|
|
271
|
-
try {
|
|
272
|
-
process.kill(state.pid, 0);
|
|
273
|
-
}
|
|
274
|
-
catch {
|
|
275
|
-
return { running: false, port: DEFAULT_PORT };
|
|
276
|
-
}
|
|
277
|
-
// Try to read daemon config for port
|
|
278
|
-
let port = DEFAULT_PORT;
|
|
279
|
-
try {
|
|
280
|
-
const configPath = path.join(baseDir, "daemon.json");
|
|
281
|
-
const configRaw = await fs.readFile(configPath, "utf-8");
|
|
282
|
-
const config = JSON.parse(configRaw);
|
|
283
|
-
if (config.event_server_port)
|
|
284
|
-
port = config.event_server_port;
|
|
285
|
-
}
|
|
286
|
-
catch {
|
|
287
|
-
// Use default port
|
|
288
|
-
}
|
|
289
|
-
// Verify EventServer is actually responding
|
|
290
|
-
const client = new DaemonClient({ host: "127.0.0.1", port });
|
|
291
|
-
const healthy = await client.healthCheck();
|
|
292
|
-
return { running: healthy, port };
|
|
293
|
-
}
|
|
294
|
-
catch {
|
|
295
|
-
return { running: false, port: DEFAULT_PORT };
|
|
296
|
-
}
|
|
297
|
-
}
|
|
1
|
+
export * from "./daemon/client.js";
|
|
298
2
|
//# sourceMappingURL=daemon-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-client.js","sourceRoot":"","sources":["../../src/runtime/daemon-client.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"daemon-client.js","sourceRoot":"","sources":["../../src/runtime/daemon-client.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* daemon-health.ts
|
|
3
|
-
*
|
|
4
|
-
* Standalone utilities for daemon log rotation and adaptive sleep calculation.
|
|
5
|
-
* Extracted from DaemonRunner to keep daemon-runner.ts focused on the loop.
|
|
6
|
-
*/
|
|
7
|
-
import type { Logger } from "./logger.js";
|
|
8
|
-
export interface AdaptiveSleepConfig {
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
min_interval_ms: number;
|
|
11
|
-
max_interval_ms: number;
|
|
12
|
-
night_start_hour: number;
|
|
13
|
-
night_end_hour: number;
|
|
14
|
-
night_multiplier: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Rotate the main log file if it exceeds the configured size limit.
|
|
18
|
-
* Renames pulseed.log to pulseed.<timestamp>.log and keeps at most maxFiles rotated files.
|
|
19
|
-
* Called at daemon startup.
|
|
20
|
-
*/
|
|
21
|
-
export declare function rotateDaemonLog(logPath: string, logDir: string, maxSizeBytes: number, maxFiles: number, logger: Logger): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Remove oldest rotated log files, keeping at most maxFiles.
|
|
24
|
-
*/
|
|
25
|
-
export declare function pruneRotatedDaemonLogs(logDir: string, maxFiles: number): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Calculate the adaptive sleep interval based on time-of-day, urgency, and activity.
|
|
28
|
-
* Returns baseInterval unchanged if adaptive_sleep is disabled.
|
|
29
|
-
*/
|
|
30
|
-
export declare function calculateAdaptiveInterval(baseInterval: number, goalsActivatedThisCycle: number, maxGapScore: number, consecutiveIdleCycles: number, cfg: AdaptiveSleepConfig): number;
|
|
1
|
+
export * from "./daemon/health.js";
|
|
31
2
|
//# sourceMappingURL=daemon-health.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-health.d.ts","sourceRoot":"","sources":["../../src/runtime/daemon-health.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"daemon-health.d.ts","sourceRoot":"","sources":["../../src/runtime/daemon-health.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,113 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* daemon-health.ts
|
|
3
|
-
*
|
|
4
|
-
* Standalone utilities for daemon log rotation and adaptive sleep calculation.
|
|
5
|
-
* Extracted from DaemonRunner to keep daemon-runner.ts focused on the loop.
|
|
6
|
-
*/
|
|
7
|
-
import * as fsp from "node:fs/promises";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
// ─── Log Rotation ───
|
|
10
|
-
/**
|
|
11
|
-
* Rotate the main log file if it exceeds the configured size limit.
|
|
12
|
-
* Renames pulseed.log to pulseed.<timestamp>.log and keeps at most maxFiles rotated files.
|
|
13
|
-
* Called at daemon startup.
|
|
14
|
-
*/
|
|
15
|
-
export async function rotateDaemonLog(logPath, logDir, maxSizeBytes, maxFiles, logger) {
|
|
16
|
-
try {
|
|
17
|
-
// Check if log file exists and exceeds size limit
|
|
18
|
-
let stat;
|
|
19
|
-
try {
|
|
20
|
-
stat = await fsp.stat(logPath);
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// File doesn't exist — nothing to rotate
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
if (stat.size < maxSizeBytes)
|
|
27
|
-
return;
|
|
28
|
-
// Rotate: rename current log with timestamp suffix
|
|
29
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
30
|
-
const rotatedName = `pulseed.${timestamp}.log`;
|
|
31
|
-
const rotatedPath = path.join(logDir, rotatedName);
|
|
32
|
-
await fsp.rename(logPath, rotatedPath);
|
|
33
|
-
logger.info("Log file rotated", {
|
|
34
|
-
rotated_to: rotatedName,
|
|
35
|
-
size_bytes: stat.size,
|
|
36
|
-
});
|
|
37
|
-
// Prune old rotated files: keep only the most recent maxFiles
|
|
38
|
-
await pruneRotatedDaemonLogs(logDir, maxFiles);
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Non-fatal — rotation failures should not prevent daemon startup
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Remove oldest rotated log files, keeping at most maxFiles.
|
|
46
|
-
*/
|
|
47
|
-
export async function pruneRotatedDaemonLogs(logDir, maxFiles) {
|
|
48
|
-
try {
|
|
49
|
-
const entries = await fsp.readdir(logDir);
|
|
50
|
-
// Rotated files match: pulseed.<timestamp>.log (not pulseed.log itself)
|
|
51
|
-
const rotated = entries
|
|
52
|
-
.filter((f) => /^pulseed\..+\.log$/.test(f) && f !== "pulseed.log")
|
|
53
|
-
.sort(); // ISO timestamps sort lexicographically = chronologically
|
|
54
|
-
// Remove oldest files beyond maxFiles
|
|
55
|
-
const excess = rotated.length - maxFiles;
|
|
56
|
-
if (excess <= 0)
|
|
57
|
-
return;
|
|
58
|
-
for (let i = 0; i < excess; i++) {
|
|
59
|
-
await fsp.unlink(path.join(logDir, rotated[i]));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch {
|
|
63
|
-
// Non-fatal
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// ─── Adaptive Sleep ───
|
|
67
|
-
/**
|
|
68
|
-
* Calculate the adaptive sleep interval based on time-of-day, urgency, and activity.
|
|
69
|
-
* Returns baseInterval unchanged if adaptive_sleep is disabled.
|
|
70
|
-
*/
|
|
71
|
-
export function calculateAdaptiveInterval(baseInterval, goalsActivatedThisCycle, maxGapScore, consecutiveIdleCycles, cfg) {
|
|
72
|
-
if (!cfg.enabled)
|
|
73
|
-
return baseInterval;
|
|
74
|
-
// 1. Time-of-day factor
|
|
75
|
-
const hour = new Date().getHours();
|
|
76
|
-
const { night_start_hour, night_end_hour, night_multiplier } = cfg;
|
|
77
|
-
let timeOfDayFactor;
|
|
78
|
-
if (night_start_hour > night_end_hour) {
|
|
79
|
-
// Spans midnight: night is [night_start_hour, 24) ∪ [0, night_end_hour)
|
|
80
|
-
timeOfDayFactor = (hour >= night_start_hour || hour < night_end_hour) ? night_multiplier : 1.0;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// Same-day range
|
|
84
|
-
timeOfDayFactor = (hour >= night_start_hour && hour < night_end_hour) ? night_multiplier : 1.0;
|
|
85
|
-
}
|
|
86
|
-
// 2. Urgency factor
|
|
87
|
-
let urgencyFactor;
|
|
88
|
-
if (maxGapScore >= 0.8) {
|
|
89
|
-
urgencyFactor = 0.5;
|
|
90
|
-
}
|
|
91
|
-
else if (maxGapScore >= 0.5) {
|
|
92
|
-
urgencyFactor = 0.75;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
urgencyFactor = 1.0;
|
|
96
|
-
}
|
|
97
|
-
// 3. Activity factor
|
|
98
|
-
let activityFactor;
|
|
99
|
-
if (goalsActivatedThisCycle > 0) {
|
|
100
|
-
activityFactor = 0.75;
|
|
101
|
-
}
|
|
102
|
-
else if (consecutiveIdleCycles >= 5) {
|
|
103
|
-
activityFactor = 1.5;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
activityFactor = 1.0;
|
|
107
|
-
}
|
|
108
|
-
// 4. Apply factors and clamp
|
|
109
|
-
const effective = baseInterval * timeOfDayFactor * urgencyFactor * activityFactor;
|
|
110
|
-
const clamped = Math.max(cfg.min_interval_ms, Math.min(cfg.max_interval_ms, effective));
|
|
111
|
-
return Math.round(clamped);
|
|
112
|
-
}
|
|
1
|
+
export * from "./daemon/health.js";
|
|
113
2
|
//# sourceMappingURL=daemon-health.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-health.js","sourceRoot":"","sources":["../../src/runtime/daemon-health.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"daemon-health.js","sourceRoot":"","sources":["../../src/runtime/daemon-health.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-runner-lifecycle.d.ts","sourceRoot":"","sources":["../../src/runtime/daemon-runner-lifecycle.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-runner-lifecycle.js","sourceRoot":"","sources":["../../src/runtime/daemon-runner-lifecycle.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|