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,17 @@
|
|
|
1
|
+
import { CLI_VERSION } from "../version.js";
|
|
2
|
+
import { registerProgramCommands } from "./command-registry.js";
|
|
3
|
+
import { configureProgramHelp } from "./help.js";
|
|
4
|
+
import { registerPreActionHooks } from "./preaction.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/program/build-program.ts
|
|
8
|
+
function buildProgram() {
|
|
9
|
+
const program = new Command();
|
|
10
|
+
configureProgramHelp(program, CLI_VERSION);
|
|
11
|
+
registerPreActionHooks(program, CLI_VERSION);
|
|
12
|
+
registerProgramCommands(program);
|
|
13
|
+
return program;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { buildProgram };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { registerConfigCli } from "./register.config.js";
|
|
2
|
+
import { registerConfigureCommand } from "./register.configure.js";
|
|
3
|
+
import { registerDashboardCommand } from "./register.dashboard.js";
|
|
4
|
+
import { registerSetupCommand } from "./register.setup.js";
|
|
5
|
+
import { registerStartCommand } from "./register.start.js";
|
|
6
|
+
import { registerSubCliCommands } from "./register.subclis.js";
|
|
7
|
+
import { registerTuiCommand } from "./register.tui.js";
|
|
8
|
+
import { registerUpdateCommand } from "./register.update.js";
|
|
9
|
+
|
|
10
|
+
//#region src/cli/program/command-registry.ts
|
|
11
|
+
function registerProgramCommands(program, argv = process.argv) {
|
|
12
|
+
registerStartCommand(program);
|
|
13
|
+
registerTuiCommand(program);
|
|
14
|
+
registerSetupCommand(program);
|
|
15
|
+
registerConfigureCommand(program);
|
|
16
|
+
registerConfigCli(program);
|
|
17
|
+
registerDashboardCommand(program);
|
|
18
|
+
registerUpdateCommand(program);
|
|
19
|
+
registerSubCliCommands(program, argv);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { registerProgramCommands };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isRich, theme } from "../../terminal/theme.js";
|
|
2
|
+
import { formatDocsLink } from "../../terminal/links.js";
|
|
3
|
+
import { formatCliBannerLine, hasEmittedCliBanner } from "../banner.js";
|
|
4
|
+
import { replaceCliName, resolveCliName } from "../cli-name.js";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/program/help.ts
|
|
7
|
+
const CLI_NAME = resolveCliName();
|
|
8
|
+
const EXAMPLES = [
|
|
9
|
+
["milady", "Start Milady in the interactive TUI."],
|
|
10
|
+
["milady start", "Start the classic runtime/chat loop."],
|
|
11
|
+
["milady dashboard", "Open the Control UI in your browser."],
|
|
12
|
+
["milady setup", "Initialize ~/.milady/milady.json and the agent workspace."],
|
|
13
|
+
["milady config get agents.defaults.model.primary", "Read a config value."],
|
|
14
|
+
["milady models", "Show configured model providers."],
|
|
15
|
+
["milady plugins list", "List available plugins."],
|
|
16
|
+
["milady update", "Check for and install the latest version."],
|
|
17
|
+
["milady update channel beta", "Switch to the beta release channel."]
|
|
18
|
+
];
|
|
19
|
+
function configureProgramHelp(program, programVersion) {
|
|
20
|
+
program.name(CLI_NAME).description("").version(programVersion, "-v, --version").option("--verbose", "Enable informational runtime logs").option("--debug", "Enable debug-level runtime logs").option("--dev", "Dev profile: isolate state under ~/.milady-dev with separate config and ports").option("--profile <name>", "Use a named profile (isolates MILADY_STATE_DIR/MILADY_CONFIG_PATH under ~/.milady-<name>)");
|
|
21
|
+
program.option("--no-color", "Disable ANSI colors", false);
|
|
22
|
+
program.configureHelp({
|
|
23
|
+
optionTerm: (option) => theme.option(option.flags),
|
|
24
|
+
subcommandTerm: (cmd) => theme.command(cmd.name())
|
|
25
|
+
});
|
|
26
|
+
program.configureOutput({
|
|
27
|
+
writeOut: (str) => {
|
|
28
|
+
const colored = str.replace(/^Usage:/gm, theme.heading("Usage:")).replace(/^Options:/gm, theme.heading("Options:")).replace(/^Commands:/gm, theme.heading("Commands:"));
|
|
29
|
+
process.stdout.write(colored);
|
|
30
|
+
},
|
|
31
|
+
writeErr: (str) => process.stderr.write(str),
|
|
32
|
+
outputError: (str, write) => write(theme.error(str))
|
|
33
|
+
});
|
|
34
|
+
program.addHelpText("beforeAll", () => {
|
|
35
|
+
if (hasEmittedCliBanner()) return "";
|
|
36
|
+
return `\n${formatCliBannerLine(programVersion, { richTty: isRich() })}\n`;
|
|
37
|
+
});
|
|
38
|
+
const fmtExamples = EXAMPLES.map(([cmd, desc]) => ` ${theme.command(replaceCliName(cmd, CLI_NAME))}\n ${theme.muted(desc)}`).join("\n");
|
|
39
|
+
program.addHelpText("afterAll", ({ command }) => {
|
|
40
|
+
if (command !== program) return "";
|
|
41
|
+
const docs = formatDocsLink("/cli", "docs.milady.ai/cli");
|
|
42
|
+
return `\n${theme.heading("Examples:")}\n${fmtExamples}\n\n${theme.muted("Docs:")} ${docs}\n`;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { configureProgramHelp };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isTruthyEnvValue, setVerbose } from "../../utils/globals.js";
|
|
2
|
+
import { getCommandPath, getVerboseFlag, hasHelpOrVersion } from "../argv.js";
|
|
3
|
+
import { emitCliBanner } from "../banner.js";
|
|
4
|
+
import { resolveCliName } from "../cli-name.js";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/program/preaction.ts
|
|
7
|
+
function setProcessTitleForCommand(actionCommand) {
|
|
8
|
+
let current = actionCommand;
|
|
9
|
+
while (current.parent?.parent) current = current.parent;
|
|
10
|
+
const name = current.name();
|
|
11
|
+
const cliName = resolveCliName();
|
|
12
|
+
if (!name || name === cliName) return;
|
|
13
|
+
process.title = `${cliName}-${name}`;
|
|
14
|
+
}
|
|
15
|
+
function registerPreActionHooks(program, programVersion) {
|
|
16
|
+
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
17
|
+
setProcessTitleForCommand(actionCommand);
|
|
18
|
+
const argv = process.argv;
|
|
19
|
+
if (hasHelpOrVersion(argv)) return;
|
|
20
|
+
const commandPath = getCommandPath(argv, 2);
|
|
21
|
+
if (!(isTruthyEnvValue(process.env.MILADY_HIDE_BANNER) || commandPath[0] === "update" || commandPath[0] === "completion")) {
|
|
22
|
+
emitCliBanner(programVersion);
|
|
23
|
+
const { scheduleUpdateNotification } = await import("../../services/update-notifier.js");
|
|
24
|
+
scheduleUpdateNotification();
|
|
25
|
+
}
|
|
26
|
+
const verbose = getVerboseFlag(argv, { includeDebug: true });
|
|
27
|
+
setVerbose(verbose);
|
|
28
|
+
if (!verbose) process.env.NODE_NO_WARNINGS ??= "1";
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { registerPreActionHooks };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { theme } from "../../terminal/theme.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/program/register.config.ts
|
|
4
|
+
function registerConfigCli(program) {
|
|
5
|
+
const config = program.command("config").description("Config helpers (get/path)");
|
|
6
|
+
config.command("get <key>").description("Get a config value").action(async (key) => {
|
|
7
|
+
const { loadMiladyConfig } = await import("../../config/config.js");
|
|
8
|
+
let miladyConfig;
|
|
9
|
+
try {
|
|
10
|
+
miladyConfig = loadMiladyConfig();
|
|
11
|
+
} catch (err) {
|
|
12
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
13
|
+
console.error(`[milady] Could not load config: ${detail}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const parts = key.split(".");
|
|
17
|
+
let value = miladyConfig;
|
|
18
|
+
for (const part of parts) if (value && typeof value === "object") value = value[part];
|
|
19
|
+
else {
|
|
20
|
+
value = void 0;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
if (value === void 0) console.log(`${theme.muted("(not set)")}`);
|
|
24
|
+
else console.log(typeof value === "object" ? JSON.stringify(value, null, 2) : String(value));
|
|
25
|
+
});
|
|
26
|
+
config.command("path").description("Print the resolved config file path").action(async () => {
|
|
27
|
+
const { resolveConfigPath } = await import("../../config/paths.js");
|
|
28
|
+
console.log(resolveConfigPath());
|
|
29
|
+
});
|
|
30
|
+
config.command("show").description("Display all configuration values grouped by section").option("-a, --all", "Include advanced/hidden fields").option("--json", "Output as raw JSON").action(async (opts) => {
|
|
31
|
+
const { loadMiladyConfig } = await import("../../config/config.js");
|
|
32
|
+
const { buildConfigSchema } = await import("../../config/schema.js");
|
|
33
|
+
let config;
|
|
34
|
+
try {
|
|
35
|
+
config = loadMiladyConfig();
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error(theme.error(`Could not load config: ${err instanceof Error ? err.message : String(err)}`));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
if (opts.json) {
|
|
41
|
+
console.log(JSON.stringify(config, null, 2));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const { uiHints } = buildConfigSchema();
|
|
45
|
+
displayConfig(config, uiHints, { showAdvanced: !!opts.all });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Flatten a nested object to dot-notation keys.
|
|
50
|
+
*/
|
|
51
|
+
function flattenConfig(obj, prefix = "") {
|
|
52
|
+
const result = {};
|
|
53
|
+
if (obj === null || typeof obj !== "object") return { [prefix]: obj };
|
|
54
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
55
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
56
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) Object.assign(result, flattenConfig(value, path));
|
|
57
|
+
else result[path] = value;
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Infer a group name from a key path (e.g., "gateway.auth.token" → "Gateway").
|
|
63
|
+
*/
|
|
64
|
+
function inferGroup(key) {
|
|
65
|
+
const segments = key.split(".");
|
|
66
|
+
if (segments.length === 0) return "General";
|
|
67
|
+
const first = segments[0];
|
|
68
|
+
return first.charAt(0).toUpperCase() + first.slice(1);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Display config values grouped by section.
|
|
72
|
+
*/
|
|
73
|
+
function displayConfig(config, uiHints, opts) {
|
|
74
|
+
const flat = flattenConfig(config);
|
|
75
|
+
const groups = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const [key, value] of Object.entries(flat)) {
|
|
77
|
+
const hint = uiHints[key];
|
|
78
|
+
if (hint?.hidden) continue;
|
|
79
|
+
if (!opts.showAdvanced && hint?.advanced) continue;
|
|
80
|
+
const group = hint?.group ?? inferGroup(key);
|
|
81
|
+
if (!groups.has(group)) groups.set(group, []);
|
|
82
|
+
groups.get(group)?.push([key, value]);
|
|
83
|
+
}
|
|
84
|
+
const sortedGroups = Array.from(groups.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
85
|
+
for (const [groupName, fields] of sortedGroups) {
|
|
86
|
+
console.log(`\n${theme.heading(groupName)}`);
|
|
87
|
+
for (const [key, value] of fields) {
|
|
88
|
+
const hint = uiHints[key];
|
|
89
|
+
const label = hint?.label ?? key;
|
|
90
|
+
const isSensitive = hint?.sensitive ?? false;
|
|
91
|
+
const isSet = value !== void 0 && value !== null && value !== "";
|
|
92
|
+
let displayValue;
|
|
93
|
+
if (!isSet) displayValue = theme.muted("(not set)");
|
|
94
|
+
else if (isSensitive) displayValue = theme.muted("●●●●●●●●");
|
|
95
|
+
else if (typeof value === "object") displayValue = JSON.stringify(value);
|
|
96
|
+
else displayValue = String(value);
|
|
97
|
+
const help = hint?.help ? ` ${theme.muted(`(${hint.help})`)}` : "";
|
|
98
|
+
const paddedLabel = label.padEnd(24);
|
|
99
|
+
console.log(` ${theme.accent(paddedLabel)} ${displayValue}${help}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
console.log();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { registerConfigCli };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { theme } from "../../terminal/theme.js";
|
|
2
|
+
import { formatDocsLink } from "../../terminal/links.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/program/register.configure.ts
|
|
5
|
+
function registerConfigureCommand(program) {
|
|
6
|
+
program.command("configure").description("Configuration guidance").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/configuration", "docs.milady.ai/configuration")}\n`).action(() => {
|
|
7
|
+
console.log(`\n${theme.heading("Milady Configuration")}\n`);
|
|
8
|
+
console.log("Set values with:");
|
|
9
|
+
console.log(` ${theme.command("milady config get <key>")} Read a config value`);
|
|
10
|
+
console.log(` Edit ~/.milady/milady.json directly for full control.\n`);
|
|
11
|
+
console.log("Common environment variables:");
|
|
12
|
+
console.log(` ${theme.command("ANTHROPIC_API_KEY")} Anthropic (Claude)`);
|
|
13
|
+
console.log(` ${theme.command("OPENAI_API_KEY")} OpenAI (GPT)`);
|
|
14
|
+
console.log(` ${theme.command("AI_GATEWAY_API_KEY")} Vercel AI Gateway`);
|
|
15
|
+
console.log(` ${theme.command("GEMINI_API_KEY")} Google (Gemini)\n`);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { registerConfigureCommand };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { theme } from "../../terminal/theme.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/program/register.dashboard.ts
|
|
4
|
+
async function isPortListening(port, host = "127.0.0.1", timeoutMs = 800) {
|
|
5
|
+
const net = await import("node:net");
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
const socket = new net.Socket();
|
|
8
|
+
socket.setTimeout(timeoutMs);
|
|
9
|
+
socket.once("connect", () => {
|
|
10
|
+
socket.destroy();
|
|
11
|
+
resolve(true);
|
|
12
|
+
});
|
|
13
|
+
socket.once("timeout", () => {
|
|
14
|
+
socket.destroy();
|
|
15
|
+
resolve(false);
|
|
16
|
+
});
|
|
17
|
+
socket.once("error", () => {
|
|
18
|
+
socket.destroy();
|
|
19
|
+
resolve(false);
|
|
20
|
+
});
|
|
21
|
+
socket.connect(port, host);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async function openInBrowser(url) {
|
|
25
|
+
const { spawn } = await import("node:child_process");
|
|
26
|
+
const isWin = process.platform === "win32";
|
|
27
|
+
const child = spawn(process.platform === "darwin" ? "open" : isWin ? "cmd" : "xdg-open", isWin ? [
|
|
28
|
+
"/c",
|
|
29
|
+
"start",
|
|
30
|
+
"",
|
|
31
|
+
url
|
|
32
|
+
] : [url], { stdio: "ignore" });
|
|
33
|
+
child.on("error", () => {
|
|
34
|
+
console.log(theme.warn("Could not open browser automatically."));
|
|
35
|
+
console.log(`${theme.muted("Open manually:")} ${url}`);
|
|
36
|
+
});
|
|
37
|
+
child.unref();
|
|
38
|
+
}
|
|
39
|
+
const DEFAULT_PORT = 2138;
|
|
40
|
+
const APP_DEV_PORT = 2138;
|
|
41
|
+
function registerDashboardCommand(program) {
|
|
42
|
+
program.command("dashboard").description("Open the Control UI in your browser").option("--port <port>", "Server port to check", String(DEFAULT_PORT)).option("--url <url>", "Server URL (overrides --port)").action(async (opts) => {
|
|
43
|
+
const rawPort = Number(opts.port ?? DEFAULT_PORT);
|
|
44
|
+
const port = Number.isFinite(rawPort) && rawPort > 0 && rawPort <= 65535 ? rawPort : DEFAULT_PORT;
|
|
45
|
+
if (opts.url) {
|
|
46
|
+
console.log(`${theme.muted("→")} Opening Control UI: ${opts.url}`);
|
|
47
|
+
openInBrowser(opts.url);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (await isPortListening(port)) {
|
|
51
|
+
const url = `http://localhost:${port}`;
|
|
52
|
+
console.log(`${theme.muted("→")} Opening Control UI: ${url}`);
|
|
53
|
+
openInBrowser(url);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (await isPortListening(APP_DEV_PORT)) {
|
|
57
|
+
const url = `http://localhost:${APP_DEV_PORT}`;
|
|
58
|
+
console.log(`${theme.muted("→")} Opening Control UI (dev server): ${url}`);
|
|
59
|
+
openInBrowser(url);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`${theme.muted("→")} Server not running on port ${port}; starting app dev server…`);
|
|
63
|
+
const path = await import("node:path");
|
|
64
|
+
const fs = await import("node:fs");
|
|
65
|
+
const { resolveMiladyPackageRootSync } = await import("../../utils/milady-root.js");
|
|
66
|
+
const pkgRoot = resolveMiladyPackageRootSync({
|
|
67
|
+
cwd: process.cwd(),
|
|
68
|
+
argv1: process.argv[1],
|
|
69
|
+
moduleUrl: import.meta.url
|
|
70
|
+
});
|
|
71
|
+
if (!pkgRoot) {
|
|
72
|
+
console.log(theme.error("Could not locate milady package root."));
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const appDir = path.join(pkgRoot, "apps", "app");
|
|
77
|
+
if (!fs.existsSync(path.join(appDir, "package.json"))) {
|
|
78
|
+
console.log(theme.error("App UI is not available in this installation."));
|
|
79
|
+
console.log(theme.muted("The app dev server requires a development checkout."));
|
|
80
|
+
console.log(theme.muted("Start the agent with `milady start` and use the API at http://localhost:31337"));
|
|
81
|
+
process.exitCode = 1;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const { spawn } = await import("node:child_process");
|
|
85
|
+
const child = spawn("npx", ["vite"], {
|
|
86
|
+
cwd: appDir,
|
|
87
|
+
stdio: [
|
|
88
|
+
"ignore",
|
|
89
|
+
"pipe",
|
|
90
|
+
"pipe"
|
|
91
|
+
],
|
|
92
|
+
env: { ...process.env }
|
|
93
|
+
});
|
|
94
|
+
let opened = false;
|
|
95
|
+
const tryOpen = () => {
|
|
96
|
+
if (opened) return;
|
|
97
|
+
opened = true;
|
|
98
|
+
const devUrl = `http://localhost:${APP_DEV_PORT}`;
|
|
99
|
+
console.log(`${theme.muted("→")} Opening Control UI: ${devUrl}`);
|
|
100
|
+
openInBrowser(devUrl);
|
|
101
|
+
};
|
|
102
|
+
child.stdout?.on("data", (chunk) => {
|
|
103
|
+
const text = chunk.toString();
|
|
104
|
+
process.stdout.write(text);
|
|
105
|
+
if (!opened && text.includes("Local:")) tryOpen();
|
|
106
|
+
});
|
|
107
|
+
child.stderr?.on("data", (chunk) => {
|
|
108
|
+
process.stderr.write(chunk.toString());
|
|
109
|
+
});
|
|
110
|
+
child.on("error", (err) => {
|
|
111
|
+
console.log(theme.error(`Failed to start app dev server: ${err.message}`));
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
});
|
|
114
|
+
setTimeout(tryOpen, 1e4);
|
|
115
|
+
const cleanup = () => {
|
|
116
|
+
child.kill("SIGTERM");
|
|
117
|
+
};
|
|
118
|
+
process.on("SIGINT", cleanup);
|
|
119
|
+
process.on("SIGTERM", cleanup);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { registerDashboardCommand };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/cli/program/register.models.ts
|
|
2
|
+
function registerModelsCli(program) {
|
|
3
|
+
program.command("models").description("Show configured model providers").action(() => {
|
|
4
|
+
const envKeys = [
|
|
5
|
+
["ANTHROPIC_API_KEY", "Anthropic (Claude)"],
|
|
6
|
+
["OPENAI_API_KEY", "OpenAI (GPT)"],
|
|
7
|
+
["AI_GATEWAY_API_KEY", "Vercel AI Gateway"],
|
|
8
|
+
["GEMINI_API_KEY", "Google (Gemini)"],
|
|
9
|
+
["GROQ_API_KEY", "Groq"],
|
|
10
|
+
["XAI_API_KEY", "xAI (Grok)"],
|
|
11
|
+
["OPENROUTER_API_KEY", "OpenRouter"],
|
|
12
|
+
["OLLAMA_BASE_URL", "Ollama (local)"]
|
|
13
|
+
];
|
|
14
|
+
console.log("[milady] Model providers:");
|
|
15
|
+
for (const [key, name] of envKeys) {
|
|
16
|
+
const status = process.env[key] ? "configured" : "not set";
|
|
17
|
+
console.log(` ${name}: ${status}`);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { registerModelsCli };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { theme } from "../../terminal/theme.js";
|
|
2
|
+
import { formatDocsLink } from "../../terminal/links.js";
|
|
3
|
+
import { runCommandWithRuntime } from "../cli-utils.js";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/program/register.setup.ts
|
|
6
|
+
const defaultRuntime = {
|
|
7
|
+
error: console.error,
|
|
8
|
+
exit: process.exit
|
|
9
|
+
};
|
|
10
|
+
function registerSetupCommand(program) {
|
|
11
|
+
program.command("setup").description("Initialize ~/.milady/milady.json and the agent workspace").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/getting-started/setup", "docs.milady.ai/getting-started/setup")}\n`).option("--workspace <dir>", "Agent workspace directory").action(async (opts) => {
|
|
12
|
+
await runCommandWithRuntime(defaultRuntime, async () => {
|
|
13
|
+
const { loadMiladyConfig } = await import("../../config/config.js");
|
|
14
|
+
const { ensureAgentWorkspace, resolveDefaultAgentWorkspaceDir } = await import("../../providers/workspace.js");
|
|
15
|
+
let config = {};
|
|
16
|
+
try {
|
|
17
|
+
config = loadMiladyConfig();
|
|
18
|
+
console.log(`${theme.success("✓")} Config loaded`);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
if (err.code === "ENOENT") console.log(`${theme.muted("→")} No config found, using defaults`);
|
|
21
|
+
else throw err;
|
|
22
|
+
}
|
|
23
|
+
const agents = config.agents;
|
|
24
|
+
const workspaceDir = opts.workspace ?? agents?.defaults?.workspace ?? resolveDefaultAgentWorkspaceDir();
|
|
25
|
+
await ensureAgentWorkspace({
|
|
26
|
+
dir: workspaceDir,
|
|
27
|
+
ensureBootstrapFiles: true
|
|
28
|
+
});
|
|
29
|
+
console.log(`${theme.success("✓")} Agent workspace ready: ${workspaceDir}`);
|
|
30
|
+
console.log(`\n${theme.success("Setup complete.")}`);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { registerSetupCommand };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { theme } from "../../terminal/theme.js";
|
|
2
|
+
import { formatDocsLink } from "../../terminal/links.js";
|
|
3
|
+
import { runCommandWithRuntime } from "../cli-utils.js";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/program/register.start.ts
|
|
6
|
+
const defaultRuntime = {
|
|
7
|
+
error: console.error,
|
|
8
|
+
exit: process.exit
|
|
9
|
+
};
|
|
10
|
+
async function startAction() {
|
|
11
|
+
await runCommandWithRuntime(defaultRuntime, async () => {
|
|
12
|
+
const { startEliza } = await import("../../runtime/eliza.js");
|
|
13
|
+
await startEliza({ serverOnly: true });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function registerStartCommand(program) {
|
|
17
|
+
program.command("start").description("Start the ElizaOS agent runtime").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/getting-started", "docs.milady.ai/getting-started")}\n`).action(startAction);
|
|
18
|
+
program.command("run").description("Alias for start").action(startAction);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { registerStartCommand };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isTruthyEnvValue } from "../../utils/globals.js";
|
|
2
|
+
import { buildParseArgv, getPrimaryCommand, hasHelpOrVersion } from "../argv.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/program/register.subclis.ts
|
|
5
|
+
function resolveActionArgs(command) {
|
|
6
|
+
return command?.args ?? [];
|
|
7
|
+
}
|
|
8
|
+
const entries = [{
|
|
9
|
+
name: "plugins",
|
|
10
|
+
description: "Plugin management (ElizaOS plugins)",
|
|
11
|
+
register: async (program) => {
|
|
12
|
+
(await import("../plugins-cli.js")).registerPluginsCli(program);
|
|
13
|
+
}
|
|
14
|
+
}, {
|
|
15
|
+
name: "models",
|
|
16
|
+
description: "Model configuration",
|
|
17
|
+
register: async (program) => {
|
|
18
|
+
(await import("./register.models.js")).registerModelsCli(program);
|
|
19
|
+
}
|
|
20
|
+
}];
|
|
21
|
+
function removeCommand(program, command) {
|
|
22
|
+
const commands = program.commands;
|
|
23
|
+
const index = commands.indexOf(command);
|
|
24
|
+
if (index >= 0) commands.splice(index, 1);
|
|
25
|
+
}
|
|
26
|
+
async function registerSubCliByName(program, name) {
|
|
27
|
+
const entry = entries.find((e) => e.name === name);
|
|
28
|
+
if (!entry) return false;
|
|
29
|
+
const existing = program.commands.find((cmd) => cmd.name() === entry.name);
|
|
30
|
+
if (existing) removeCommand(program, existing);
|
|
31
|
+
await entry.register(program);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
function registerLazyCommand(program, entry) {
|
|
35
|
+
const placeholder = program.command(entry.name).description(entry.description);
|
|
36
|
+
placeholder.allowUnknownOption(true);
|
|
37
|
+
placeholder.allowExcessArguments(true);
|
|
38
|
+
placeholder.action(async (...actionArgs) => {
|
|
39
|
+
removeCommand(program, placeholder);
|
|
40
|
+
await entry.register(program);
|
|
41
|
+
const actionCommand = actionArgs.at(-1);
|
|
42
|
+
const rawArgs = (actionCommand?.parent ?? program).rawArgs;
|
|
43
|
+
const actionArgsList = resolveActionArgs(actionCommand);
|
|
44
|
+
const fallbackArgv = actionCommand?.name() ? [actionCommand.name(), ...actionArgsList] : actionArgsList;
|
|
45
|
+
const parseArgv = buildParseArgv({
|
|
46
|
+
programName: program.name(),
|
|
47
|
+
rawArgs,
|
|
48
|
+
fallbackArgv
|
|
49
|
+
});
|
|
50
|
+
await program.parseAsync(parseArgv);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function registerSubCliCommands(program, argv = process.argv) {
|
|
54
|
+
if (isTruthyEnvValue(process.env.MILADY_DISABLE_LAZY_SUBCOMMANDS)) {
|
|
55
|
+
for (const entry of entries) entry.register(program);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!hasHelpOrVersion(argv)) {
|
|
59
|
+
const primary = getPrimaryCommand(argv);
|
|
60
|
+
const entry = primary ? entries.find((e) => e.name === primary) : void 0;
|
|
61
|
+
if (entry) {
|
|
62
|
+
registerLazyCommand(program, entry);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const entry of entries) registerLazyCommand(program, entry);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { registerSubCliByName, registerSubCliCommands };
|