@nowcrew/daemon 0.5.28 → 0.5.30
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/README.md +4 -0
- package/dist/attachments.js +196 -0
- package/dist/bound-im-decision.js +22 -0
- package/dist/completion-retransmitter.js +77 -0
- package/dist/computer-cli.js +274 -0
- package/dist/computer-profile-lock.js +395 -0
- package/dist/computer-profile.js +364 -0
- package/dist/computer-service.js +358 -0
- package/dist/config.js +82 -0
- package/dist/console-collapse.js +13 -0
- package/dist/console-formatter.js +77 -0
- package/dist/console-payload.js +73 -0
- package/dist/console.js +329 -0
- package/dist/daemon-startup-error.js +30 -0
- package/dist/execution-backend.js +44 -0
- package/dist/execution-event-limit.js +64 -0
- package/dist/execution-journal-lock.js +421 -0
- package/dist/execution-journal.js +716 -0
- package/dist/execution-protocol.js +342 -0
- package/dist/execution-recovery.js +95 -0
- package/dist/execution-runner.js +659 -0
- package/dist/execution-supervisor-child.js +236 -0
- package/dist/execution-supervisor.js +316 -0
- package/dist/execution-telemetry-journal.js +71 -0
- package/dist/external-output.js +114 -0
- package/dist/i18n.js +64 -0
- package/dist/json-result.js +27 -0
- package/dist/list-models.js +92 -0
- package/dist/local-executor.js +439 -0
- package/dist/log-format.js +10 -0
- package/dist/machine-info.js +124 -0
- package/dist/main.js +118 -0
- package/dist/normalize.js +170 -0
- package/dist/origin-decision.js +44 -0
- package/dist/platform.js +8 -0
- package/dist/prompt.js +307 -0
- package/dist/provider-env.js +90 -0
- package/dist/runner.js +234 -0
- package/dist/runtime-cancellation.js +74 -0
- package/dist/runtime-capabilities.js +43 -0
- package/dist/runtime-path.js +60 -0
- package/dist/runtimes/claude.js +51 -0
- package/dist/runtimes/codex-app-server-runner.js +541 -0
- package/dist/runtimes/codex-deepseek-catalog.js +7 -0
- package/dist/runtimes/codex-deepseek-config.js +50 -0
- package/dist/runtimes/codex.js +53 -0
- package/dist/runtimes/kimi-acp-runner.js +364 -0
- package/dist/runtimes/kimi.js +45 -0
- package/dist/runtimes/progress-watchdog.js +26 -0
- package/dist/scheduled-report.js +51 -0
- package/dist/scheduled-run-report.js +57 -0
- package/dist/serve-lifecycle.js +82 -0
- package/dist/serve.js +868 -0
- package/dist/session.js +82 -0
- package/dist/shared-execution-slots.js +68 -0
- package/dist/shutdown-deadline.js +32 -0
- package/dist/skill-preview.js +21 -0
- package/dist/skills.js +56 -0
- package/dist/slog.js +228 -0
- package/dist/supervised-runtime.js +104 -0
- package/dist/token.js +24 -0
- package/dist/unified-diff.js +84 -0
- package/dist/websocket-shutdown.js +53 -0
- package/dist/win32-job-object.js +193 -0
- package/dist/workspace-fs.js +80 -0
- package/dist/workspace-import.js +127 -0
- package/dist/workspace.js +148 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { dslog, flushSlog } from "./slog.js";
|
|
2
|
+
function defaultDiagnose(diagnostic) {
|
|
3
|
+
const fields = {
|
|
4
|
+
signal: diagnostic.signal,
|
|
5
|
+
stage: diagnostic.stage,
|
|
6
|
+
active_execution_count: diagnostic.activeExecutionCount,
|
|
7
|
+
active_legacy_count: diagnostic.activeLegacyCount,
|
|
8
|
+
deadline_ms: diagnostic.deadlineMs,
|
|
9
|
+
...(diagnostic.error === undefined ? {} : { error: diagnostic.error }),
|
|
10
|
+
};
|
|
11
|
+
try {
|
|
12
|
+
dslog(diagnostic.stage === "failed" ? "daemon.shutdown_failed" : "daemon.shutdown", `daemon shutdown ${diagnostic.stage}`, { level: diagnostic.stage === "failed" ? "ERROR" : "INFO", ...fields });
|
|
13
|
+
process.stderr.write(`${JSON.stringify({
|
|
14
|
+
level: diagnostic.stage === "failed" ? "ERROR" : "INFO",
|
|
15
|
+
event_type: diagnostic.stage === "failed" ? "daemon.shutdown_failed" : "daemon.shutdown",
|
|
16
|
+
...fields,
|
|
17
|
+
})}\n`);
|
|
18
|
+
}
|
|
19
|
+
catch { /* shutdown diagnostics must never interrupt cleanup */ }
|
|
20
|
+
}
|
|
21
|
+
export async function runServeLifecycle(service, dependencies = {}) {
|
|
22
|
+
const signals = dependencies.signals ?? process;
|
|
23
|
+
const flush = dependencies.flush ?? flushSlog;
|
|
24
|
+
const diagnose = dependencies.diagnose ?? defaultDiagnose;
|
|
25
|
+
let receivedSignal = null;
|
|
26
|
+
let resolveSignal;
|
|
27
|
+
const signalReceived = new Promise((resolve) => { resolveSignal = resolve; });
|
|
28
|
+
const receive = (signal) => {
|
|
29
|
+
if (receivedSignal !== null)
|
|
30
|
+
return;
|
|
31
|
+
receivedSignal = signal;
|
|
32
|
+
resolveSignal(signal);
|
|
33
|
+
};
|
|
34
|
+
const onSigint = () => receive("SIGINT");
|
|
35
|
+
const onSigterm = () => receive("SIGTERM");
|
|
36
|
+
signals.on("SIGINT", onSigint);
|
|
37
|
+
signals.on("SIGTERM", onSigterm);
|
|
38
|
+
try {
|
|
39
|
+
try {
|
|
40
|
+
await service.ready;
|
|
41
|
+
}
|
|
42
|
+
catch (readyError) {
|
|
43
|
+
try {
|
|
44
|
+
await service.stop();
|
|
45
|
+
}
|
|
46
|
+
catch { /* preserve the readiness error */ }
|
|
47
|
+
try {
|
|
48
|
+
await flush();
|
|
49
|
+
}
|
|
50
|
+
catch { /* slog is best effort */ }
|
|
51
|
+
throw readyError;
|
|
52
|
+
}
|
|
53
|
+
const signal = await signalReceived;
|
|
54
|
+
const snapshot = service.shutdownSnapshot();
|
|
55
|
+
diagnose({ signal, stage: "stopping", ...snapshot });
|
|
56
|
+
let stopError;
|
|
57
|
+
try {
|
|
58
|
+
await service.stop();
|
|
59
|
+
diagnose({ signal, stage: "completed", ...snapshot });
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
stopError = error;
|
|
63
|
+
diagnose({
|
|
64
|
+
signal,
|
|
65
|
+
stage: "failed",
|
|
66
|
+
error: error instanceof Error ? error.message : String(error),
|
|
67
|
+
...snapshot,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
await flush();
|
|
72
|
+
}
|
|
73
|
+
catch { /* slog owns its own spool fallback */ }
|
|
74
|
+
if (stopError !== undefined)
|
|
75
|
+
throw stopError;
|
|
76
|
+
return { signal };
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
signals.off("SIGINT", onSigint);
|
|
80
|
+
signals.off("SIGTERM", onSigterm);
|
|
81
|
+
}
|
|
82
|
+
}
|