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,182 @@
|
|
|
1
|
+
import { readJsonBody as readJsonBody$1, sendJson } from "./http-helpers.js";
|
|
2
|
+
import { WhatsAppPairingSession, sanitizeAccountId, whatsappAuthExists, whatsappLogout } from "./services/whatsapp-pairing.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/api/whatsapp-routes.ts
|
|
7
|
+
/**
|
|
8
|
+
* WhatsApp API routes: pair, status, stop, disconnect.
|
|
9
|
+
*
|
|
10
|
+
* Extracted from the main server handler for testability.
|
|
11
|
+
*/
|
|
12
|
+
const MAX_BODY_BYTES = 1048576;
|
|
13
|
+
/** Maximum concurrent pairing sessions to prevent resource exhaustion. */
|
|
14
|
+
const MAX_PAIRING_SESSIONS = 10;
|
|
15
|
+
async function readJsonBody(req, res) {
|
|
16
|
+
return readJsonBody$1(req, res, { maxBytes: MAX_BODY_BYTES });
|
|
17
|
+
}
|
|
18
|
+
function json(res, data, status = 200) {
|
|
19
|
+
sendJson(res, data, status);
|
|
20
|
+
}
|
|
21
|
+
/** Returns `true` if handled, `false` to fall through. */
|
|
22
|
+
async function handleWhatsAppRoute(req, res, pathname, method, state) {
|
|
23
|
+
if (!pathname.startsWith("/api/whatsapp")) return false;
|
|
24
|
+
if (method === "POST" && pathname === "/api/whatsapp/pair") {
|
|
25
|
+
const body = await readJsonBody(req, res);
|
|
26
|
+
let accountId;
|
|
27
|
+
try {
|
|
28
|
+
accountId = sanitizeAccountId(body && typeof body.accountId === "string" && body.accountId.trim() ? body.accountId.trim() : "default");
|
|
29
|
+
} catch (err) {
|
|
30
|
+
json(res, { error: err.message }, 400);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (!state.whatsappPairingSessions.has(accountId) && state.whatsappPairingSessions.size >= MAX_PAIRING_SESSIONS) {
|
|
34
|
+
json(res, { error: `Too many concurrent pairing sessions (max ${MAX_PAIRING_SESSIONS})` }, 429);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const authDir = path.join(state.workspaceDir, "whatsapp-auth", accountId);
|
|
38
|
+
state.whatsappPairingSessions?.get(accountId)?.stop();
|
|
39
|
+
const session = new WhatsAppPairingSession({
|
|
40
|
+
authDir,
|
|
41
|
+
accountId,
|
|
42
|
+
onEvent: (event) => {
|
|
43
|
+
state.broadcastWs?.(event);
|
|
44
|
+
if (event.status === "connected") {
|
|
45
|
+
if (!state.config.connectors) state.config.connectors = {};
|
|
46
|
+
state.config.connectors.whatsapp = {
|
|
47
|
+
...state.config.connectors.whatsapp ?? {},
|
|
48
|
+
authDir,
|
|
49
|
+
enabled: true
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
state.saveConfig();
|
|
53
|
+
} catch {}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
state.whatsappPairingSessions.set(accountId, session);
|
|
58
|
+
try {
|
|
59
|
+
await session.start();
|
|
60
|
+
json(res, {
|
|
61
|
+
ok: true,
|
|
62
|
+
accountId,
|
|
63
|
+
status: session.getStatus()
|
|
64
|
+
});
|
|
65
|
+
} catch (err) {
|
|
66
|
+
json(res, {
|
|
67
|
+
ok: false,
|
|
68
|
+
error: err instanceof Error ? err.message : String(err)
|
|
69
|
+
}, 500);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (method === "GET" && pathname === "/api/whatsapp/status") {
|
|
74
|
+
const url = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
75
|
+
let accountId;
|
|
76
|
+
try {
|
|
77
|
+
accountId = sanitizeAccountId(url.searchParams.get("accountId") || "default");
|
|
78
|
+
} catch (err) {
|
|
79
|
+
json(res, { error: err.message }, 400);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const session = state.whatsappPairingSessions?.get(accountId);
|
|
83
|
+
let serviceConnected = false;
|
|
84
|
+
let servicePhone = null;
|
|
85
|
+
if (state.runtime) try {
|
|
86
|
+
const waService = state.runtime.getService("whatsapp");
|
|
87
|
+
if (waService) {
|
|
88
|
+
serviceConnected = Boolean(waService.connected);
|
|
89
|
+
servicePhone = waService.phoneNumber ?? null;
|
|
90
|
+
}
|
|
91
|
+
} catch {}
|
|
92
|
+
json(res, {
|
|
93
|
+
accountId,
|
|
94
|
+
status: session?.getStatus() ?? "idle",
|
|
95
|
+
authExists: whatsappAuthExists(state.workspaceDir, accountId),
|
|
96
|
+
serviceConnected,
|
|
97
|
+
servicePhone
|
|
98
|
+
});
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
if (method === "POST" && pathname === "/api/whatsapp/pair/stop") {
|
|
102
|
+
const body = await readJsonBody(req, res);
|
|
103
|
+
let accountId;
|
|
104
|
+
try {
|
|
105
|
+
accountId = sanitizeAccountId(body && typeof body.accountId === "string" && body.accountId.trim() ? body.accountId.trim() : "default");
|
|
106
|
+
} catch (err) {
|
|
107
|
+
json(res, { error: err.message }, 400);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
const session = state.whatsappPairingSessions?.get(accountId);
|
|
111
|
+
if (session) {
|
|
112
|
+
session.stop();
|
|
113
|
+
state.whatsappPairingSessions?.delete(accountId);
|
|
114
|
+
}
|
|
115
|
+
json(res, {
|
|
116
|
+
ok: true,
|
|
117
|
+
accountId,
|
|
118
|
+
status: "idle"
|
|
119
|
+
});
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (method === "POST" && pathname === "/api/whatsapp/disconnect") {
|
|
123
|
+
const body = await readJsonBody(req, res);
|
|
124
|
+
let accountId;
|
|
125
|
+
try {
|
|
126
|
+
accountId = sanitizeAccountId(body && typeof body.accountId === "string" && body.accountId.trim() ? body.accountId.trim() : "default");
|
|
127
|
+
} catch (err) {
|
|
128
|
+
json(res, { error: err.message }, 400);
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
const session = state.whatsappPairingSessions?.get(accountId);
|
|
132
|
+
if (session) {
|
|
133
|
+
session.stop();
|
|
134
|
+
state.whatsappPairingSessions?.delete(accountId);
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
await whatsappLogout(state.workspaceDir, accountId);
|
|
138
|
+
} catch (logoutErr) {
|
|
139
|
+
console.warn(`[whatsapp] Logout failed for ${accountId}, deleting auth files directly:`, logoutErr instanceof Error ? logoutErr.message : String(logoutErr));
|
|
140
|
+
const authDir = path.join(state.workspaceDir, "whatsapp-auth", accountId);
|
|
141
|
+
try {
|
|
142
|
+
fs.rmSync(authDir, {
|
|
143
|
+
recursive: true,
|
|
144
|
+
force: true
|
|
145
|
+
});
|
|
146
|
+
} catch {}
|
|
147
|
+
}
|
|
148
|
+
if (state.config.connectors) {
|
|
149
|
+
delete state.config.connectors.whatsapp;
|
|
150
|
+
try {
|
|
151
|
+
state.saveConfig();
|
|
152
|
+
} catch {}
|
|
153
|
+
}
|
|
154
|
+
json(res, {
|
|
155
|
+
ok: true,
|
|
156
|
+
accountId
|
|
157
|
+
});
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* When WhatsApp is connected via QR code (Baileys auth on disk), mark the
|
|
164
|
+
* plugin entry as configured and clear validation errors so the UI doesn't
|
|
165
|
+
* show misleading "missing API key" warnings.
|
|
166
|
+
*/
|
|
167
|
+
function applyWhatsAppQrOverride(plugins, workspaceDir) {
|
|
168
|
+
try {
|
|
169
|
+
const waCredsPath = path.join(workspaceDir, "whatsapp-auth", "default", "creds.json");
|
|
170
|
+
if (fs.existsSync(waCredsPath)) {
|
|
171
|
+
const waPlugin = plugins.find((p) => p.id === "whatsapp");
|
|
172
|
+
if (waPlugin) {
|
|
173
|
+
waPlugin.validationErrors = [];
|
|
174
|
+
waPlugin.configured = true;
|
|
175
|
+
waPlugin.qrConnected = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} catch {}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//#endregion
|
|
182
|
+
export { applyWhatsAppQrOverride, handleWhatsAppRoute };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//#region src/api/zip-utils.ts
|
|
2
|
+
const CRC32_TABLE = new Uint32Array(256);
|
|
3
|
+
for (let i = 0; i < 256; i += 1) {
|
|
4
|
+
let crc = i;
|
|
5
|
+
for (let j = 0; j < 8; j += 1) if ((crc & 1) === 1) crc = crc >>> 1 ^ 3988292384;
|
|
6
|
+
else crc >>>= 1;
|
|
7
|
+
CRC32_TABLE[i] = crc >>> 0;
|
|
8
|
+
}
|
|
9
|
+
function normalizeZipEntryName(name) {
|
|
10
|
+
const normalized = name.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
11
|
+
if (!normalized) throw new Error("ZIP entry name cannot be empty");
|
|
12
|
+
if (normalized.includes("\0")) throw new Error("ZIP entry name contains invalid null byte");
|
|
13
|
+
const parts = normalized.split("/");
|
|
14
|
+
for (const part of parts) if (part === "." || part === "..") throw new Error(`ZIP entry name is not safe: ${name}`);
|
|
15
|
+
return normalized;
|
|
16
|
+
}
|
|
17
|
+
function toBuffer(data) {
|
|
18
|
+
if (Buffer.isBuffer(data)) return data;
|
|
19
|
+
if (typeof data === "string") return Buffer.from(data, "utf-8");
|
|
20
|
+
return Buffer.from(data);
|
|
21
|
+
}
|
|
22
|
+
function crc32(buffer) {
|
|
23
|
+
let crc = 4294967295;
|
|
24
|
+
for (const byte of buffer) {
|
|
25
|
+
const index = (crc ^ byte) & 255;
|
|
26
|
+
crc = crc >>> 8 ^ (CRC32_TABLE[index] ?? 0);
|
|
27
|
+
}
|
|
28
|
+
return (crc ^ 4294967295) >>> 0;
|
|
29
|
+
}
|
|
30
|
+
function toDosDateTime(date) {
|
|
31
|
+
const year = Math.min(Math.max(date.getFullYear(), 1980), 2107);
|
|
32
|
+
const month = Math.min(Math.max(date.getMonth() + 1, 1), 12);
|
|
33
|
+
const day = Math.min(Math.max(date.getDate(), 1), 31);
|
|
34
|
+
const hours = Math.min(Math.max(date.getHours(), 0), 23);
|
|
35
|
+
const minutes = Math.min(Math.max(date.getMinutes(), 0), 59);
|
|
36
|
+
const seconds = Math.min(Math.max(Math.floor(date.getSeconds() / 2), 0), 29);
|
|
37
|
+
const dosDate = year - 1980 << 9 | month << 5 | day;
|
|
38
|
+
const dosTime = hours << 11 | minutes << 5 | seconds;
|
|
39
|
+
return {
|
|
40
|
+
date: dosDate & 65535,
|
|
41
|
+
time: dosTime & 65535
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createZipArchive(entries) {
|
|
45
|
+
if (entries.length > 65535) throw new Error("ZIP export supports up to 65535 files");
|
|
46
|
+
const fileParts = [];
|
|
47
|
+
const centralDirectoryParts = [];
|
|
48
|
+
let offset = 0;
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const name = normalizeZipEntryName(entry.name);
|
|
51
|
+
const nameBuffer = Buffer.from(name, "utf-8");
|
|
52
|
+
const dataBuffer = toBuffer(entry.data);
|
|
53
|
+
const checksum = crc32(dataBuffer);
|
|
54
|
+
const { date, time } = toDosDateTime(entry.mtime ?? /* @__PURE__ */ new Date());
|
|
55
|
+
const localHeader = Buffer.alloc(30 + nameBuffer.length);
|
|
56
|
+
localHeader.writeUInt32LE(67324752, 0);
|
|
57
|
+
localHeader.writeUInt16LE(20, 4);
|
|
58
|
+
localHeader.writeUInt16LE(0, 6);
|
|
59
|
+
localHeader.writeUInt16LE(0, 8);
|
|
60
|
+
localHeader.writeUInt16LE(time, 10);
|
|
61
|
+
localHeader.writeUInt16LE(date, 12);
|
|
62
|
+
localHeader.writeUInt32LE(checksum, 14);
|
|
63
|
+
localHeader.writeUInt32LE(dataBuffer.length, 18);
|
|
64
|
+
localHeader.writeUInt32LE(dataBuffer.length, 22);
|
|
65
|
+
localHeader.writeUInt16LE(nameBuffer.length, 26);
|
|
66
|
+
localHeader.writeUInt16LE(0, 28);
|
|
67
|
+
nameBuffer.copy(localHeader, 30);
|
|
68
|
+
const centralHeader = Buffer.alloc(46 + nameBuffer.length);
|
|
69
|
+
centralHeader.writeUInt32LE(33639248, 0);
|
|
70
|
+
centralHeader.writeUInt16LE(20, 4);
|
|
71
|
+
centralHeader.writeUInt16LE(20, 6);
|
|
72
|
+
centralHeader.writeUInt16LE(0, 8);
|
|
73
|
+
centralHeader.writeUInt16LE(0, 10);
|
|
74
|
+
centralHeader.writeUInt16LE(time, 12);
|
|
75
|
+
centralHeader.writeUInt16LE(date, 14);
|
|
76
|
+
centralHeader.writeUInt32LE(checksum, 16);
|
|
77
|
+
centralHeader.writeUInt32LE(dataBuffer.length, 20);
|
|
78
|
+
centralHeader.writeUInt32LE(dataBuffer.length, 24);
|
|
79
|
+
centralHeader.writeUInt16LE(nameBuffer.length, 28);
|
|
80
|
+
centralHeader.writeUInt16LE(0, 30);
|
|
81
|
+
centralHeader.writeUInt16LE(0, 32);
|
|
82
|
+
centralHeader.writeUInt16LE(0, 34);
|
|
83
|
+
centralHeader.writeUInt16LE(0, 36);
|
|
84
|
+
centralHeader.writeUInt32LE(0, 38);
|
|
85
|
+
centralHeader.writeUInt32LE(offset, 42);
|
|
86
|
+
nameBuffer.copy(centralHeader, 46);
|
|
87
|
+
fileParts.push(localHeader, dataBuffer);
|
|
88
|
+
centralDirectoryParts.push(centralHeader);
|
|
89
|
+
offset += localHeader.length + dataBuffer.length;
|
|
90
|
+
}
|
|
91
|
+
const centralDirectory = Buffer.concat(centralDirectoryParts);
|
|
92
|
+
const endOfCentralDirectory = Buffer.alloc(22);
|
|
93
|
+
endOfCentralDirectory.writeUInt32LE(101010256, 0);
|
|
94
|
+
endOfCentralDirectory.writeUInt16LE(0, 4);
|
|
95
|
+
endOfCentralDirectory.writeUInt16LE(0, 6);
|
|
96
|
+
endOfCentralDirectory.writeUInt16LE(entries.length, 8);
|
|
97
|
+
endOfCentralDirectory.writeUInt16LE(entries.length, 10);
|
|
98
|
+
endOfCentralDirectory.writeUInt32LE(centralDirectory.length, 12);
|
|
99
|
+
endOfCentralDirectory.writeUInt32LE(offset, 16);
|
|
100
|
+
endOfCentralDirectory.writeUInt16LE(0, 20);
|
|
101
|
+
return Buffer.concat([
|
|
102
|
+
...fileParts,
|
|
103
|
+
centralDirectory,
|
|
104
|
+
endOfCentralDirectory
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { createZipArchive };
|
package/milady.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import module from "node:module";
|
|
4
|
+
|
|
5
|
+
// https://nodejs.org/api/module.html#module-compile-cache
|
|
6
|
+
if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
|
|
7
|
+
try {
|
|
8
|
+
module.enableCompileCache();
|
|
9
|
+
} catch {
|
|
10
|
+
// Ignore errors
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
await import("./dist/entry.js");
|
package/package.json
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "miladyai",
|
|
3
|
+
"version": "2.0.0-alpha.27",
|
|
4
|
+
"description": "Cute agents for the acceleration",
|
|
5
|
+
"homepage": "https://github.com/milady-ai/milady",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Milady AI",
|
|
8
|
+
"email": "hi@milady.ai"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/milady-ai/milady.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "build/src/index.js",
|
|
17
|
+
"bin": {
|
|
18
|
+
"milady": "milady.mjs"
|
|
19
|
+
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./cli-entry": "./milady.mjs",
|
|
23
|
+
"./eliza": "./dist/runtime/eliza.js"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@bufbuild/protobuf": "^2.11.0",
|
|
30
|
+
"@capacitor-community/electron": "^5.0.1",
|
|
31
|
+
"@clack/prompts": "^1.0.0",
|
|
32
|
+
"@elizaos/core": "next",
|
|
33
|
+
"@elizaos/plugin-agent-orchestrator": "next",
|
|
34
|
+
"@elizaos/plugin-agent-skills": "next",
|
|
35
|
+
"@elizaos/plugin-browser": "next",
|
|
36
|
+
"@elizaos/plugin-computeruse": "next",
|
|
37
|
+
"@elizaos/plugin-cron": "next",
|
|
38
|
+
"@elizaos/plugin-discord": "next",
|
|
39
|
+
"@elizaos/plugin-edge-tts": "next",
|
|
40
|
+
"@elizaos/plugin-elevenlabs": "next",
|
|
41
|
+
"@elizaos/plugin-elizacloud": "next",
|
|
42
|
+
"@elizaos/plugin-experience": "next",
|
|
43
|
+
"@elizaos/plugin-form": "next",
|
|
44
|
+
"@elizaos/plugin-google-genai": "next",
|
|
45
|
+
"@elizaos/plugin-groq": "next",
|
|
46
|
+
"@elizaos/plugin-knowledge": "next",
|
|
47
|
+
"@elizaos/plugin-local-embedding": "next",
|
|
48
|
+
"@elizaos/plugin-ollama": "next",
|
|
49
|
+
"@elizaos/plugin-openai": "next",
|
|
50
|
+
"@elizaos/plugin-openrouter": "next",
|
|
51
|
+
"@elizaos/plugin-pdf": "next",
|
|
52
|
+
"@elizaos/plugin-personality": "next",
|
|
53
|
+
"@elizaos/plugin-plugin-manager": "next",
|
|
54
|
+
"@elizaos/plugin-rolodex": "next",
|
|
55
|
+
"@elizaos/plugin-secrets-manager": "next",
|
|
56
|
+
"@elizaos/plugin-shell": "next",
|
|
57
|
+
"@elizaos/plugin-telegram": "next",
|
|
58
|
+
"@elizaos/plugin-todo": "next",
|
|
59
|
+
"@elizaos/plugin-trajectory-logger": "next",
|
|
60
|
+
"@elizaos/plugin-trust": "next",
|
|
61
|
+
"@elizaos/prompts": "next",
|
|
62
|
+
"@elizaos/sweagent-root": "next",
|
|
63
|
+
"@elizaos/tui": "next",
|
|
64
|
+
"@langchain/core": "^1.1.12",
|
|
65
|
+
"@langchain/textsplitters": "^1.0.1",
|
|
66
|
+
"@lunchtable/plugin-ltcg": "0.1.0",
|
|
67
|
+
"@mariozechner/pi-ai": "0.52.12",
|
|
68
|
+
"@mariozechner/pi-tui": "0.54.0",
|
|
69
|
+
"@noble/curves": "^2.0.1",
|
|
70
|
+
"adze": "^2.2.5",
|
|
71
|
+
"bonjour-service": "^1.3.0",
|
|
72
|
+
"chalk": "^5.4.1",
|
|
73
|
+
"chokidar": "~3.5.3",
|
|
74
|
+
"cli-highlight": "^2.1.11",
|
|
75
|
+
"coding-agent-adapters": "0.7.3",
|
|
76
|
+
"commander": "^14.0.0",
|
|
77
|
+
"cross-spawn": "^7.0.6",
|
|
78
|
+
"crypto-browserify": "^3.12.0",
|
|
79
|
+
"dedent": "^1.7.1",
|
|
80
|
+
"dotenv": "^17.2.3",
|
|
81
|
+
"drizzle-orm": "0.45.1",
|
|
82
|
+
"electron-is-dev": "~2.0.0",
|
|
83
|
+
"electron-serve": "~1.1.0",
|
|
84
|
+
"electron-unhandled": "~4.0.1",
|
|
85
|
+
"electron-updater": "^6.8.3",
|
|
86
|
+
"electron-window-state": "^5.0.3",
|
|
87
|
+
"ethers": "^6.16.0",
|
|
88
|
+
"fast-redact": "^3.5.0",
|
|
89
|
+
"file-type": "^21.3.0",
|
|
90
|
+
"git-workspace-service": "0.4.3",
|
|
91
|
+
"glob": "^13.0.0",
|
|
92
|
+
"handlebars": "^4.7.8",
|
|
93
|
+
"json5": "^2.2.3",
|
|
94
|
+
"markdown-it": "^14.1.0",
|
|
95
|
+
"node-llama-cpp": "^3.15.1",
|
|
96
|
+
"node-pty": "^1.1.0",
|
|
97
|
+
"pdfjs-dist": "^5.4.530",
|
|
98
|
+
"pg": "^8.16.3",
|
|
99
|
+
"pty-manager": "1.6.7",
|
|
100
|
+
"puppeteer-core": "^24.37.5",
|
|
101
|
+
"telegraf": "^4.16.3",
|
|
102
|
+
"unique-names-generator": "^4.7.1",
|
|
103
|
+
"whisper-node": "^1.1.1",
|
|
104
|
+
"@hapi/boom": "^10.0.1",
|
|
105
|
+
"@whiskeysockets/baileys": "7.0.0-rc.9",
|
|
106
|
+
"pino": "^10.3.1",
|
|
107
|
+
"qrcode": "^1.5.4",
|
|
108
|
+
"ws": "^8.19.0",
|
|
109
|
+
"zod": "^4.3.6"
|
|
110
|
+
}
|
|
111
|
+
}
|