miladyai 2.0.0-alpha.27
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/_virtual/_rolldown/runtime.js +7 -0
- package/dist/actions/emote.js +64 -0
- package/dist/actions/restart.js +81 -0
- package/dist/actions/send-message.js +152 -0
- package/dist/agent-admin-routes.js +82 -0
- package/dist/agent-lifecycle-routes.js +79 -0
- package/dist/agent-transfer-routes.js +102 -0
- package/dist/api/agent-admin-routes.js +82 -0
- package/dist/api/agent-lifecycle-routes.js +79 -0
- package/dist/api/agent-transfer-routes.js +102 -0
- package/dist/api/apps-hyperscape-routes.js +58 -0
- package/dist/api/apps-routes.js +114 -0
- package/dist/api/auth-routes.js +56 -0
- package/dist/api/autonomy-routes.js +44 -0
- package/dist/api/bug-report-routes.js +111 -0
- package/dist/api/character-routes.js +195 -0
- package/dist/api/cloud-routes.js +330 -0
- package/dist/api/cloud-status-routes.js +155 -0
- package/dist/api/compat-utils.js +111 -0
- package/dist/api/database.js +735 -0
- package/dist/api/diagnostics-routes.js +205 -0
- package/dist/api/drop-service.js +134 -0
- package/dist/api/early-logs.js +86 -0
- package/dist/api/http-helpers.js +131 -0
- package/dist/api/knowledge-routes.js +534 -0
- package/dist/api/memory-bounds.js +71 -0
- package/dist/api/models-routes.js +28 -0
- package/dist/api/og-tracker.js +36 -0
- package/dist/api/permissions-routes.js +109 -0
- package/dist/api/plugin-validation.js +198 -0
- package/dist/api/provider-switch-config.js +41 -0
- package/dist/api/registry-routes.js +86 -0
- package/dist/api/registry-service.js +164 -0
- package/dist/api/sandbox-routes.js +1112 -0
- package/dist/api/server.js +7949 -0
- package/dist/api/subscription-routes.js +172 -0
- package/dist/api/terminal-run-limits.js +24 -0
- package/dist/api/training-routes.js +158 -0
- package/dist/api/trajectory-routes.js +300 -0
- package/dist/api/trigger-routes.js +246 -0
- package/dist/api/twitter-verify.js +134 -0
- package/dist/api/tx-service.js +108 -0
- package/dist/api/wallet-routes.js +266 -0
- package/dist/api/wallet.js +568 -0
- package/dist/api/whatsapp-routes.js +182 -0
- package/dist/api/zip-utils.js +109 -0
- package/dist/apps-hyperscape-routes.js +58 -0
- package/dist/apps-routes.js +114 -0
- package/dist/ascii.js +20 -0
- package/dist/auth/anthropic.js +44 -0
- package/dist/auth/apply-stealth.js +41 -0
- package/dist/auth/claude-code-stealth.js +78 -0
- package/dist/auth/credentials.js +156 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/openai-codex.js +66 -0
- package/dist/auth/types.js +9 -0
- package/dist/auth-routes.js +56 -0
- package/dist/autonomy-routes.js +44 -0
- package/dist/bug-report-routes.js +111 -0
- package/dist/build-info.json +6 -0
- package/dist/character-routes.js +195 -0
- package/dist/cli/argv.js +63 -0
- package/dist/cli/banner.js +34 -0
- package/dist/cli/cli-name.js +21 -0
- package/dist/cli/cli-utils.js +16 -0
- package/dist/cli/git-commit.js +78 -0
- package/dist/cli/parse-duration.js +15 -0
- package/dist/cli/plugins-cli.js +590 -0
- package/dist/cli/profile-utils.js +9 -0
- package/dist/cli/profile.js +95 -0
- package/dist/cli/program/build-program.js +17 -0
- package/dist/cli/program/command-registry.js +23 -0
- package/dist/cli/program/help.js +47 -0
- package/dist/cli/program/preaction.js +33 -0
- package/dist/cli/program/register.config.js +106 -0
- package/dist/cli/program/register.configure.js +20 -0
- package/dist/cli/program/register.dashboard.js +124 -0
- package/dist/cli/program/register.models.js +23 -0
- package/dist/cli/program/register.setup.js +36 -0
- package/dist/cli/program/register.start.js +22 -0
- package/dist/cli/program/register.subclis.js +70 -0
- package/dist/cli/program/register.tui.js +163 -0
- package/dist/cli/program/register.update.js +154 -0
- package/dist/cli/program.js +3 -0
- package/dist/cli/run-main.js +37 -0
- package/dist/cli/version.js +7 -0
- package/dist/cloud/validate-url.js +93 -0
- package/dist/cloud-routes.js +330 -0
- package/dist/cloud-status-routes.js +155 -0
- package/dist/compat-utils.js +111 -0
- package/dist/config/config.js +69 -0
- package/dist/config/env-vars.js +19 -0
- package/dist/config/includes.js +121 -0
- package/dist/config/object-utils.js +7 -0
- package/dist/config/paths.js +38 -0
- package/dist/config/plugin-auto-enable.js +231 -0
- package/dist/config/schema.js +864 -0
- package/dist/config/telegram-custom-commands.js +76 -0
- package/dist/config/zod-schema.agent-runtime.js +519 -0
- package/dist/config/zod-schema.core.js +538 -0
- package/dist/config/zod-schema.hooks.js +103 -0
- package/dist/config/zod-schema.js +488 -0
- package/dist/config/zod-schema.providers-core.js +785 -0
- package/dist/config/zod-schema.session.js +73 -0
- package/dist/core-plugins.js +37 -0
- package/dist/custom-actions.js +250 -0
- package/dist/database.js +735 -0
- package/dist/diagnostics/integration-observability.js +57 -0
- package/dist/diagnostics-routes.js +205 -0
- package/dist/drop-service.js +134 -0
- package/dist/early-logs.js +24 -0
- package/dist/eliza.js +2061 -0
- package/dist/emotes/catalog.js +271 -0
- package/dist/entry.js +40 -0
- package/dist/hooks/discovery.js +167 -0
- package/dist/hooks/eligibility.js +64 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/loader.js +147 -0
- package/dist/hooks/registry.js +55 -0
- package/dist/http-helpers.js +131 -0
- package/dist/index.js +49 -0
- package/dist/knowledge-routes.js +534 -0
- package/dist/memory-bounds.js +71 -0
- package/dist/milady-plugin.js +90 -0
- package/dist/models-routes.js +28 -0
- package/dist/onboarding-names.js +78 -0
- package/dist/onboarding-presets.js +922 -0
- package/dist/package.json +1 -0
- package/dist/permissions-routes.js +109 -0
- package/dist/plugin-validation.js +107 -0
- package/dist/plugins/whatsapp/actions.js +91 -0
- package/dist/plugins/whatsapp/index.js +16 -0
- package/dist/plugins/whatsapp/service.js +270 -0
- package/dist/provider-switch-config.js +41 -0
- package/dist/providers/admin-trust.js +46 -0
- package/dist/providers/autonomous-state.js +101 -0
- package/dist/providers/session-bridge.js +86 -0
- package/dist/providers/session-utils.js +36 -0
- package/dist/providers/simple-mode.js +50 -0
- package/dist/providers/ui-catalog.js +15 -0
- package/dist/providers/workspace-provider.js +93 -0
- package/dist/providers/workspace.js +348 -0
- package/dist/registry-routes.js +86 -0
- package/dist/registry-service.js +164 -0
- package/dist/restart.js +40 -0
- package/dist/runtime/core-plugins.js +37 -0
- package/dist/runtime/custom-actions.js +250 -0
- package/dist/runtime/eliza.js +2061 -0
- package/dist/runtime/embedding-manager-support.js +185 -0
- package/dist/runtime/embedding-manager.js +193 -0
- package/dist/runtime/embedding-presets.js +54 -0
- package/dist/runtime/embedding-state.js +8 -0
- package/dist/runtime/milady-plugin.js +90 -0
- package/dist/runtime/onboarding-names.js +78 -0
- package/dist/runtime/restart.js +40 -0
- package/dist/runtime/version.js +7 -0
- package/dist/sandbox-routes.js +1112 -0
- package/dist/security/audit-log.js +149 -0
- package/dist/security/network-policy.js +70 -0
- package/dist/server.js +7949 -0
- package/dist/services/agent-export.js +559 -0
- package/dist/services/app-manager.js +389 -0
- package/dist/services/browser-capture.js +86 -0
- package/dist/services/fallback-training-service.js +128 -0
- package/dist/services/mcp-marketplace.js +134 -0
- package/dist/services/plugin-installer.js +396 -0
- package/dist/services/plugin-manager-types.js +15 -0
- package/dist/services/registry-client-app-meta.js +144 -0
- package/dist/services/registry-client-endpoints.js +166 -0
- package/dist/services/registry-client-local.js +271 -0
- package/dist/services/registry-client-network.js +93 -0
- package/dist/services/registry-client-queries.js +70 -0
- package/dist/services/registry-client.js +157 -0
- package/dist/services/sandbox-engine.js +511 -0
- package/dist/services/sandbox-manager.js +297 -0
- package/dist/services/self-updater.js +175 -0
- package/dist/services/skill-catalog-client.js +119 -0
- package/dist/services/skill-marketplace.js +521 -0
- package/dist/services/stream-manager.js +236 -0
- package/dist/services/update-checker.js +121 -0
- package/dist/services/update-notifier.js +29 -0
- package/dist/services/version-compat.js +78 -0
- package/dist/services/whatsapp-pairing.js +196 -0
- package/dist/shared/ui-catalog-prompt.js +728 -0
- package/dist/subscription-routes.js +172 -0
- package/dist/terminal/links.js +19 -0
- package/dist/terminal/palette.js +14 -0
- package/dist/terminal/theme.js +25 -0
- package/dist/terminal-run-limits.js +24 -0
- package/dist/training-routes.js +158 -0
- package/dist/trajectory-routes.js +300 -0
- package/dist/trigger-routes.js +246 -0
- package/dist/triggers/action.js +218 -0
- package/dist/triggers/runtime.js +281 -0
- package/dist/triggers/scheduling.js +295 -0
- package/dist/triggers/types.js +5 -0
- package/dist/tui/components/assistant-message.js +76 -0
- package/dist/tui/components/chat-editor.js +34 -0
- package/dist/tui/components/embeddings-overlay.js +46 -0
- package/dist/tui/components/footer.js +60 -0
- package/dist/tui/components/index.js +15 -0
- package/dist/tui/components/modal-frame.js +45 -0
- package/dist/tui/components/modal-style.js +15 -0
- package/dist/tui/components/model-selector.js +70 -0
- package/dist/tui/components/pinned-chat-layout.js +46 -0
- package/dist/tui/components/plugins-endpoints-tab.js +196 -0
- package/dist/tui/components/plugins-installed-tab-view.js +69 -0
- package/dist/tui/components/plugins-installed-tab.js +319 -0
- package/dist/tui/components/plugins-overlay-catalog.js +81 -0
- package/dist/tui/components/plugins-overlay-data-api.js +21 -0
- package/dist/tui/components/plugins-overlay-data-shared.js +20 -0
- package/dist/tui/components/plugins-overlay-data.js +323 -0
- package/dist/tui/components/plugins-overlay.js +117 -0
- package/dist/tui/components/plugins-store-tab.js +148 -0
- package/dist/tui/components/settings-overlay.js +61 -0
- package/dist/tui/components/status-bar.js +64 -0
- package/dist/tui/components/tool-execution.js +68 -0
- package/dist/tui/components/user-message.js +22 -0
- package/dist/tui/eliza-tui-bridge.js +606 -0
- package/dist/tui/index.js +370 -0
- package/dist/tui/modal-presets.js +33 -0
- package/dist/tui/model-spec.js +46 -0
- package/dist/tui/sse-parser.js +78 -0
- package/dist/tui/theme.js +110 -0
- package/dist/tui/titlebar-spinner.js +62 -0
- package/dist/tui/tui-app.js +311 -0
- package/dist/tui/ws-client.js +215 -0
- package/dist/twitter-verify.js +134 -0
- package/dist/tx-service.js +108 -0
- package/dist/utils/exec-safety.js +17 -0
- package/dist/utils/globals.js +20 -0
- package/dist/utils/milady-root.js +61 -0
- package/dist/utils/number-parsing.js +37 -0
- package/dist/version-resolver.js +37 -0
- package/dist/version.js +7 -0
- package/dist/wallet-routes.js +266 -0
- package/dist/wallet.js +568 -0
- package/dist/whatsapp-routes.js +182 -0
- package/dist/zip-utils.js +109 -0
- package/milady.mjs +14 -0
- package/package.json +111 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { logger } from "@elizaos/core";
|
|
2
|
+
|
|
3
|
+
//#region src/hooks/registry.ts
|
|
4
|
+
const registry = /* @__PURE__ */ new Map();
|
|
5
|
+
/**
|
|
6
|
+
* Event keys: "command" matches all command events,
|
|
7
|
+
* "command:new" matches only /new.
|
|
8
|
+
*/
|
|
9
|
+
function registerHook(eventKey, handler) {
|
|
10
|
+
const handlers = registry.get(eventKey) ?? [];
|
|
11
|
+
handlers.push(handler);
|
|
12
|
+
registry.set(eventKey, handlers);
|
|
13
|
+
}
|
|
14
|
+
function clearHooks() {
|
|
15
|
+
registry.clear();
|
|
16
|
+
}
|
|
17
|
+
/** Dispatches to specific ("command:new") then general ("command") handlers. */
|
|
18
|
+
async function triggerHook(event) {
|
|
19
|
+
const specificKey = `${event.type}:${event.action}`;
|
|
20
|
+
const generalKey = event.type;
|
|
21
|
+
const handlers = [];
|
|
22
|
+
const specificHandlers = registry.get(specificKey);
|
|
23
|
+
if (specificHandlers) for (const handler of specificHandlers) handlers.push({
|
|
24
|
+
key: specificKey,
|
|
25
|
+
handler
|
|
26
|
+
});
|
|
27
|
+
const generalHandlers = registry.get(generalKey);
|
|
28
|
+
if (generalHandlers) for (const handler of generalHandlers) handlers.push({
|
|
29
|
+
key: generalKey,
|
|
30
|
+
handler
|
|
31
|
+
});
|
|
32
|
+
if (handlers.length === 0) return;
|
|
33
|
+
const errors = [];
|
|
34
|
+
for (const { key, handler } of handlers) try {
|
|
35
|
+
await handler(event);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
38
|
+
logger.error(`[hooks] Handler error for "${key}": ${error.message}`);
|
|
39
|
+
errors.push(error);
|
|
40
|
+
}
|
|
41
|
+
if (errors.length > 0) logger.warn(`[hooks] ${errors.length} hook handler(s) failed — errors were logged above`);
|
|
42
|
+
}
|
|
43
|
+
function createHookEvent(type, action, sessionKey, context = {}) {
|
|
44
|
+
return {
|
|
45
|
+
type,
|
|
46
|
+
action,
|
|
47
|
+
sessionKey,
|
|
48
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
49
|
+
messages: [],
|
|
50
|
+
context
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { clearHooks, createHookEvent, registerHook, triggerHook };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//#region src/api/http-helpers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Common request body size guard used across API/benchmark endpoints.
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_MAX_BODY_BYTES = 1048576;
|
|
6
|
+
function defaultTooLargeMessage(maxBytes, explicit) {
|
|
7
|
+
return explicit ?? `Request body exceeds maximum size (${maxBytes} bytes)`;
|
|
8
|
+
}
|
|
9
|
+
async function readRequestBodyBuffer(req, { maxBytes = DEFAULT_MAX_BODY_BYTES, returnNullOnError = false, returnNullOnTooLarge = false, destroyOnTooLarge = false, tooLargeMessage } = {}) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const chunks = [];
|
|
12
|
+
let totalBytes = 0;
|
|
13
|
+
let tooLarge = false;
|
|
14
|
+
let settled = false;
|
|
15
|
+
const message = defaultTooLargeMessage(maxBytes, tooLargeMessage);
|
|
16
|
+
const cleanup = () => {
|
|
17
|
+
req.off("data", onData);
|
|
18
|
+
req.off("end", onEnd);
|
|
19
|
+
req.off("error", onError);
|
|
20
|
+
};
|
|
21
|
+
const settle = (value) => {
|
|
22
|
+
if (settled) return;
|
|
23
|
+
settled = true;
|
|
24
|
+
cleanup();
|
|
25
|
+
resolve(value);
|
|
26
|
+
};
|
|
27
|
+
const fail = (err) => {
|
|
28
|
+
if (settled) return;
|
|
29
|
+
settled = true;
|
|
30
|
+
cleanup();
|
|
31
|
+
reject(err);
|
|
32
|
+
};
|
|
33
|
+
const onData = (chunk) => {
|
|
34
|
+
if (settled) return;
|
|
35
|
+
totalBytes += chunk.length;
|
|
36
|
+
if (totalBytes > maxBytes) {
|
|
37
|
+
tooLarge = true;
|
|
38
|
+
if (returnNullOnTooLarge) {
|
|
39
|
+
if (destroyOnTooLarge) req.destroy();
|
|
40
|
+
settle(null);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (destroyOnTooLarge) {
|
|
44
|
+
req.destroy();
|
|
45
|
+
fail(new Error(message));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
chunks.push(chunk);
|
|
51
|
+
};
|
|
52
|
+
const onEnd = () => {
|
|
53
|
+
if (settled) return;
|
|
54
|
+
if (tooLarge) {
|
|
55
|
+
if (returnNullOnTooLarge) {
|
|
56
|
+
settle(null);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
fail(new Error(message));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
settle(Buffer.concat(chunks));
|
|
63
|
+
};
|
|
64
|
+
const onError = (err) => {
|
|
65
|
+
if (returnNullOnError) {
|
|
66
|
+
settle(null);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
fail(err);
|
|
70
|
+
};
|
|
71
|
+
req.on("data", onData);
|
|
72
|
+
req.on("end", onEnd);
|
|
73
|
+
req.on("error", onError);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async function readRequestBody(req, options = {}) {
|
|
77
|
+
const { encoding = "utf-8", ...rawOptions } = options;
|
|
78
|
+
const body = await readRequestBodyBuffer(req, rawOptions);
|
|
79
|
+
if (body === null) return null;
|
|
80
|
+
return body.toString(encoding);
|
|
81
|
+
}
|
|
82
|
+
async function writeJsonResponse(res, body, status = 200) {
|
|
83
|
+
res.statusCode = status;
|
|
84
|
+
res.setHeader("Content-Type", "application/json");
|
|
85
|
+
res.end(JSON.stringify(body));
|
|
86
|
+
}
|
|
87
|
+
async function writeJsonError(res, message, status = 400) {
|
|
88
|
+
await writeJsonResponse(res, { error: message }, status);
|
|
89
|
+
}
|
|
90
|
+
function writeJsonResponseSafe(res, body, status = 200) {
|
|
91
|
+
writeJsonResponse(res, body, status).catch(() => {});
|
|
92
|
+
}
|
|
93
|
+
/** Shorthand responder for successful JSON payloads with safe fire-and-forget write. */
|
|
94
|
+
function sendJson(res, body, status = 200) {
|
|
95
|
+
writeJsonResponseSafe(res, body, status);
|
|
96
|
+
}
|
|
97
|
+
/** Shorthand responder for JSON error payloads with safe fire-and-forget write. */
|
|
98
|
+
function sendJsonError(res, message, status = 400) {
|
|
99
|
+
writeJsonErrorSafe(res, message, status);
|
|
100
|
+
}
|
|
101
|
+
function writeJsonErrorSafe(res, message, status = 400) {
|
|
102
|
+
writeJsonError(res, message, status).catch(() => {});
|
|
103
|
+
}
|
|
104
|
+
async function readJsonBody(req, res, { readErrorStatus = 413, nonObjectStatus = 400, parseErrorStatus = 400, readErrorMessage = "Failed to read request body", nonObjectMessage = "Request body must be a JSON object", parseErrorMessage = "Invalid JSON in request body", requireObject = true, ...readOptions } = {}) {
|
|
105
|
+
let raw;
|
|
106
|
+
try {
|
|
107
|
+
const body = await readRequestBody(req, readOptions);
|
|
108
|
+
if (body == null) {
|
|
109
|
+
await writeJsonError(res, readErrorMessage, readErrorStatus);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
raw = body;
|
|
113
|
+
} catch (err) {
|
|
114
|
+
await writeJsonError(res, err instanceof Error ? err.message : "Failed to read request body", readErrorStatus);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const parsed = JSON.parse(raw);
|
|
119
|
+
if (requireObject && (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))) {
|
|
120
|
+
await writeJsonError(res, nonObjectMessage, nonObjectStatus);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return parsed;
|
|
124
|
+
} catch {
|
|
125
|
+
await writeJsonError(res, parseErrorMessage, parseErrorStatus);
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { readJsonBody, readRequestBody, readRequestBodyBuffer, sendJson, sendJsonError };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/restart.ts
|
|
4
|
+
/**
|
|
5
|
+
* Restart infrastructure for Milady.
|
|
6
|
+
*
|
|
7
|
+
* Provides a pluggable restart handler so the restart action (and the
|
|
8
|
+
* `/api/agent/restart` endpoint) work in every host environment:
|
|
9
|
+
*
|
|
10
|
+
* - **CLI** (default): exits with {@link RESTART_EXIT_CODE} (75). The runner
|
|
11
|
+
* script (`scripts/run-node.mjs`) catches this, rebuilds if source files
|
|
12
|
+
* changed, and relaunches.
|
|
13
|
+
* - **Dev-server / API**: the host registers a handler via
|
|
14
|
+
* {@link setRestartHandler} that stops the current runtime, creates a new
|
|
15
|
+
* one, and hot-swaps references.
|
|
16
|
+
* - **Electron app**: the host registers a handler that calls
|
|
17
|
+
* `AgentManager.restart()`.
|
|
18
|
+
*
|
|
19
|
+
* @module restart
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Special exit code that tells the CLI runner to restart the process.
|
|
23
|
+
* Must stay in sync with `RESTART_EXIT_CODE` in `scripts/run-node.mjs`.
|
|
24
|
+
*/
|
|
25
|
+
const RESTART_EXIT_CODE = 75;
|
|
26
|
+
let _handler = () => {
|
|
27
|
+
process.exit(RESTART_EXIT_CODE);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Replace the active restart handler.
|
|
31
|
+
*
|
|
32
|
+
* Call this at startup in non-CLI environments (dev-server, Electron) to
|
|
33
|
+
* provide an in-process restart strategy.
|
|
34
|
+
*/
|
|
35
|
+
function setRestartHandler(handler) {
|
|
36
|
+
_handler = handler;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Trigger a restart. Delegates to whatever handler is currently registered.
|
|
40
|
+
*
|
|
41
|
+
* Safe to call from the restart action, the API endpoint, or any other code
|
|
42
|
+
* that needs to bounce the agent.
|
|
43
|
+
*/
|
|
44
|
+
function requestRestart(reason) {
|
|
45
|
+
return _handler(reason);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { RESTART_EXIT_CODE, requestRestart, setRestartHandler };
|