milaidy 1.0.0

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.
Files changed (253) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +538 -0
  3. package/dist/argv-CfSowvEA.js +63 -0
  4. package/dist/config-B-mboG4v.js +4 -0
  5. package/dist/eliza-CPJjgw-e.js +1491 -0
  6. package/dist/eliza.js +2192 -0
  7. package/dist/entry.js +232 -0
  8. package/dist/index.js +209 -0
  9. package/dist/links-BFKlWqSe.js +15 -0
  10. package/dist/paths-D_yh1DEJ.js +69 -0
  11. package/dist/plugins-cli-B7kSre2c.js +134 -0
  12. package/dist/program-6KwWwKKh.js +510 -0
  13. package/dist/register.agents-CPVmSjMG.js +17 -0
  14. package/dist/register.browser-B2ooXxNx.js +15 -0
  15. package/dist/register.channels-CMYQ6K6Y.js +42 -0
  16. package/dist/register.cron-D91lY1_Y.js +9 -0
  17. package/dist/register.devices-rU5I5L_y.js +13 -0
  18. package/dist/register.gateway-82SLAvw3.js +22 -0
  19. package/dist/register.hooks-B_XTBEkt.js +9 -0
  20. package/dist/register.logs-BgEGcPd8.js +10 -0
  21. package/dist/register.models-BJt9eVgZ.js +26 -0
  22. package/dist/register.nodes-B5xY1s8a.js +9 -0
  23. package/dist/register.skills-SFQqYIhg.js +10 -0
  24. package/dist/register.subclis-uF_AsbWR.js +187 -0
  25. package/dist/run-main-XODklzS-.js +56 -0
  26. package/dist/theme-DBvtuGeq.js +36 -0
  27. package/dist/utils-C1AUpp_V.js +42 -0
  28. package/dist/version-Cpn3yr5D.js +26 -0
  29. package/dist/workspace-Co3Wul2D.js +206 -0
  30. package/dist/workspace-DCA6MNVK.js +350 -0
  31. package/docs/.i18n/README.md +31 -0
  32. package/docs/.i18n/glossary.zh-CN.json +210 -0
  33. package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
  34. package/docs/CNAME +1 -0
  35. package/docs/automation/cron-jobs.md +468 -0
  36. package/docs/automation/cron-vs-heartbeat.md +254 -0
  37. package/docs/automation/gmail-pubsub.md +256 -0
  38. package/docs/automation/poll.md +69 -0
  39. package/docs/automation/webhook.md +163 -0
  40. package/docs/bedrock.md +176 -0
  41. package/docs/brave-search.md +41 -0
  42. package/docs/broadcast-groups.md +442 -0
  43. package/docs/cli/acp.md +170 -0
  44. package/docs/cli/agent.md +24 -0
  45. package/docs/cli/agents.md +75 -0
  46. package/docs/cli/approvals.md +50 -0
  47. package/docs/cli/browser.md +107 -0
  48. package/docs/cli/channels.md +79 -0
  49. package/docs/cli/config.md +50 -0
  50. package/docs/cli/configure.md +33 -0
  51. package/docs/cli/cron.md +42 -0
  52. package/docs/cli/dashboard.md +16 -0
  53. package/docs/cli/devices.md +67 -0
  54. package/docs/cli/directory.md +63 -0
  55. package/docs/cli/dns.md +23 -0
  56. package/docs/cli/docs.md +15 -0
  57. package/docs/cli/doctor.md +41 -0
  58. package/docs/cli/gateway.md +199 -0
  59. package/docs/cli/health.md +21 -0
  60. package/docs/cli/hooks.md +291 -0
  61. package/docs/cli/index.md +1029 -0
  62. package/docs/cli/logs.md +24 -0
  63. package/docs/cli/memory.md +45 -0
  64. package/docs/cli/message.md +239 -0
  65. package/docs/cli/models.md +79 -0
  66. package/docs/cli/node.md +112 -0
  67. package/docs/cli/nodes.md +73 -0
  68. package/docs/cli/onboard.md +29 -0
  69. package/docs/cli/pairing.md +21 -0
  70. package/docs/cli/plugins.md +62 -0
  71. package/docs/cli/reset.md +17 -0
  72. package/docs/cli/sandbox.md +152 -0
  73. package/docs/cli/security.md +26 -0
  74. package/docs/cli/sessions.md +16 -0
  75. package/docs/cli/setup.md +29 -0
  76. package/docs/cli/skills.md +26 -0
  77. package/docs/cli/status.md +26 -0
  78. package/docs/cli/system.md +60 -0
  79. package/docs/cli/tui.md +23 -0
  80. package/docs/cli/uninstall.md +17 -0
  81. package/docs/cli/update.md +98 -0
  82. package/docs/cli/voicecall.md +34 -0
  83. package/docs/cli/webhooks.md +25 -0
  84. package/docs/concepts/agent-loop.md +146 -0
  85. package/docs/concepts/agent-workspace.md +229 -0
  86. package/docs/concepts/agent.md +122 -0
  87. package/docs/concepts/architecture.md +129 -0
  88. package/docs/concepts/channel-routing.md +114 -0
  89. package/docs/concepts/compaction.md +61 -0
  90. package/docs/concepts/context.md +159 -0
  91. package/docs/concepts/features.md +53 -0
  92. package/docs/concepts/group-messages.md +84 -0
  93. package/docs/concepts/groups.md +373 -0
  94. package/docs/concepts/markdown-formatting.md +130 -0
  95. package/docs/concepts/memory.md +546 -0
  96. package/docs/concepts/messages.md +154 -0
  97. package/docs/concepts/model-failover.md +149 -0
  98. package/docs/concepts/model-providers.md +315 -0
  99. package/docs/concepts/models.md +208 -0
  100. package/docs/concepts/multi-agent.md +376 -0
  101. package/docs/concepts/oauth.md +145 -0
  102. package/docs/concepts/plugins.md +454 -0
  103. package/docs/concepts/presence.md +102 -0
  104. package/docs/concepts/queue.md +89 -0
  105. package/docs/concepts/retry.md +69 -0
  106. package/docs/concepts/secrets.md +300 -0
  107. package/docs/concepts/session-pruning.md +122 -0
  108. package/docs/concepts/session-tool.md +193 -0
  109. package/docs/concepts/session.md +188 -0
  110. package/docs/concepts/sessions.md +10 -0
  111. package/docs/concepts/skills.md +392 -0
  112. package/docs/concepts/streaming.md +135 -0
  113. package/docs/concepts/system-prompt.md +114 -0
  114. package/docs/concepts/timezone.md +91 -0
  115. package/docs/concepts/typebox.md +289 -0
  116. package/docs/concepts/typing-indicators.md +68 -0
  117. package/docs/concepts/usage-tracking.md +35 -0
  118. package/docs/custom.css +4 -0
  119. package/docs/date-time.md +128 -0
  120. package/docs/debugging.md +162 -0
  121. package/docs/docs.json +1599 -0
  122. package/docs/environment.md +81 -0
  123. package/docs/hooks.md +876 -0
  124. package/docs/index.md +179 -0
  125. package/docs/install/ansible.md +208 -0
  126. package/docs/install/bun.md +59 -0
  127. package/docs/install/development-channels.md +75 -0
  128. package/docs/install/docker.md +567 -0
  129. package/docs/install/index.md +185 -0
  130. package/docs/install/installer.md +123 -0
  131. package/docs/install/migrating.md +192 -0
  132. package/docs/install/nix.md +96 -0
  133. package/docs/install/node.md +78 -0
  134. package/docs/install/uninstall.md +128 -0
  135. package/docs/install/updating.md +228 -0
  136. package/docs/logging.md +350 -0
  137. package/docs/multi-agent-sandbox-tools.md +395 -0
  138. package/docs/network.md +54 -0
  139. package/docs/nodes/audio.md +114 -0
  140. package/docs/nodes/camera.md +156 -0
  141. package/docs/nodes/images.md +72 -0
  142. package/docs/nodes/index.md +341 -0
  143. package/docs/nodes/location-command.md +113 -0
  144. package/docs/nodes/media-understanding.md +379 -0
  145. package/docs/nodes/talk.md +90 -0
  146. package/docs/nodes/voicewake.md +65 -0
  147. package/docs/northflank.mdx +53 -0
  148. package/docs/perplexity.md +80 -0
  149. package/docs/platforms/android.md +129 -0
  150. package/docs/platforms/digitalocean.md +262 -0
  151. package/docs/platforms/exe-dev.md +125 -0
  152. package/docs/platforms/fly.md +486 -0
  153. package/docs/platforms/gcp.md +503 -0
  154. package/docs/platforms/hetzner.md +330 -0
  155. package/docs/platforms/index.md +53 -0
  156. package/docs/platforms/ios.md +106 -0
  157. package/docs/platforms/linux.md +94 -0
  158. package/docs/platforms/mac/bundled-gateway.md +73 -0
  159. package/docs/platforms/mac/canvas.md +125 -0
  160. package/docs/platforms/mac/child-process.md +69 -0
  161. package/docs/platforms/mac/dev-setup.md +102 -0
  162. package/docs/platforms/mac/health.md +34 -0
  163. package/docs/platforms/mac/icon.md +31 -0
  164. package/docs/platforms/mac/logging.md +57 -0
  165. package/docs/platforms/mac/menu-bar.md +81 -0
  166. package/docs/platforms/mac/peekaboo.md +65 -0
  167. package/docs/platforms/mac/permissions.md +44 -0
  168. package/docs/platforms/mac/release.md +85 -0
  169. package/docs/platforms/mac/remote.md +83 -0
  170. package/docs/platforms/mac/signing.md +47 -0
  171. package/docs/platforms/mac/skills.md +33 -0
  172. package/docs/platforms/mac/voice-overlay.md +60 -0
  173. package/docs/platforms/mac/voicewake.md +67 -0
  174. package/docs/platforms/mac/webchat.md +41 -0
  175. package/docs/platforms/mac/xpc.md +61 -0
  176. package/docs/platforms/macos-vm.md +281 -0
  177. package/docs/platforms/macos.md +203 -0
  178. package/docs/platforms/oracle.md +303 -0
  179. package/docs/platforms/raspberry-pi.md +358 -0
  180. package/docs/platforms/windows.md +159 -0
  181. package/docs/plugin.md +651 -0
  182. package/docs/plugins/agent-tools.md +99 -0
  183. package/docs/plugins/manifest.md +71 -0
  184. package/docs/plugins/voice-call.md +273 -0
  185. package/docs/plugins/zalouser.md +70 -0
  186. package/docs/providers/anthropic.md +152 -0
  187. package/docs/providers/claude-max-api-proxy.md +148 -0
  188. package/docs/providers/cloudflare-ai-gateway.md +71 -0
  189. package/docs/providers/deepgram.md +93 -0
  190. package/docs/providers/glm.md +33 -0
  191. package/docs/providers/index.md +63 -0
  192. package/docs/providers/minimax.md +208 -0
  193. package/docs/providers/models.md +51 -0
  194. package/docs/providers/moonshot.md +142 -0
  195. package/docs/providers/ollama.md +223 -0
  196. package/docs/providers/openai.md +62 -0
  197. package/docs/providers/opencode.md +36 -0
  198. package/docs/providers/openrouter.md +37 -0
  199. package/docs/providers/qwen.md +53 -0
  200. package/docs/providers/synthetic.md +99 -0
  201. package/docs/providers/venice.md +267 -0
  202. package/docs/providers/vercel-ai-gateway.md +50 -0
  203. package/docs/providers/xiaomi.md +64 -0
  204. package/docs/providers/zai.md +36 -0
  205. package/docs/railway.mdx +99 -0
  206. package/docs/reference/templates/AGENTS.md +9 -0
  207. package/docs/reference/templates/BOOTSTRAP.md +3 -0
  208. package/docs/reference/templates/HEARTBEAT.md +3 -0
  209. package/docs/reference/templates/IDENTITY.md +3 -0
  210. package/docs/reference/templates/TOOLS.md +3 -0
  211. package/docs/reference/templates/USER.md +3 -0
  212. package/docs/render.mdx +165 -0
  213. package/docs/start/docs-directory.md +63 -0
  214. package/docs/start/getting-started.md +212 -0
  215. package/docs/start/milaidy.md +247 -0
  216. package/docs/start/onboarding.md +258 -0
  217. package/docs/start/pairing.md +86 -0
  218. package/docs/start/quickstart.md +81 -0
  219. package/docs/start/setup.md +149 -0
  220. package/docs/start/showcase.md +416 -0
  221. package/docs/start/wizard.md +418 -0
  222. package/docs/testing.md +368 -0
  223. package/docs/token-use.md +112 -0
  224. package/docs/tools/agent-send.md +53 -0
  225. package/docs/tools/apply-patch.md +50 -0
  226. package/docs/tools/browser-linux-troubleshooting.md +139 -0
  227. package/docs/tools/browser-login.md +68 -0
  228. package/docs/tools/browser.md +576 -0
  229. package/docs/tools/chrome-extension.md +178 -0
  230. package/docs/tools/clawhub.md +257 -0
  231. package/docs/tools/creating-skills.md +54 -0
  232. package/docs/tools/elevated.md +57 -0
  233. package/docs/tools/exec-approvals.md +246 -0
  234. package/docs/tools/exec.md +179 -0
  235. package/docs/tools/firecrawl.md +61 -0
  236. package/docs/tools/index.md +508 -0
  237. package/docs/tools/llm-task.md +115 -0
  238. package/docs/tools/reactions.md +22 -0
  239. package/docs/tools/skills-config.md +76 -0
  240. package/docs/tools/skills.md +300 -0
  241. package/docs/tools/slash-commands.md +196 -0
  242. package/docs/tools/subagents.md +151 -0
  243. package/docs/tools/thinking.md +73 -0
  244. package/docs/tools/web.md +261 -0
  245. package/docs/tui.md +159 -0
  246. package/docs/vps.md +43 -0
  247. package/docs/web/control-ui.md +221 -0
  248. package/docs/web/dashboard.md +46 -0
  249. package/docs/web/index.md +116 -0
  250. package/docs/web/webchat.md +49 -0
  251. package/milaidy.mjs +14 -0
  252. package/package.json +271 -0
  253. package/skills/.cache/catalog.json +88519 -0
@@ -0,0 +1,350 @@
1
+ import { n as resolveUserPath } from "./utils-C1AUpp_V.js";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { isSubagentSessionKey } from "@elizaos/core";
5
+ import fs from "node:fs/promises";
6
+ import { spawn } from "node:child_process";
7
+ import fs$1 from "node:fs";
8
+ import { fileURLToPath } from "node:url";
9
+
10
+ //#region src/process/exec.ts
11
+ /**
12
+ * Runs a command with an optional timeout.
13
+ * Returns { code, stdout, stderr }.
14
+ * Rejects if the process cannot be spawned or the timeout fires.
15
+ */
16
+ function runCommandWithTimeout(argv, opts = {}) {
17
+ const [cmd, ...args] = argv;
18
+ if (!cmd) return Promise.reject(/* @__PURE__ */ new Error("runCommandWithTimeout: empty argv"));
19
+ return new Promise((resolve, reject) => {
20
+ const child = spawn(cmd, args, {
21
+ cwd: opts.cwd,
22
+ env: opts.env ?? process.env,
23
+ stdio: [
24
+ "ignore",
25
+ "pipe",
26
+ "pipe"
27
+ ]
28
+ });
29
+ const stdoutChunks = [];
30
+ const stderrChunks = [];
31
+ child.stdout.on("data", (chunk) => stdoutChunks.push(chunk));
32
+ child.stderr.on("data", (chunk) => stderrChunks.push(chunk));
33
+ let timedOut = false;
34
+ let timer;
35
+ if (opts.timeoutMs && opts.timeoutMs > 0) timer = setTimeout(() => {
36
+ timedOut = true;
37
+ child.kill("SIGKILL");
38
+ }, opts.timeoutMs);
39
+ child.on("error", (err) => {
40
+ if (timer) clearTimeout(timer);
41
+ reject(err);
42
+ });
43
+ child.on("close", (exitCode) => {
44
+ if (timer) clearTimeout(timer);
45
+ if (timedOut) {
46
+ reject(/* @__PURE__ */ new Error(`Command timed out after ${opts.timeoutMs}ms: ${argv.join(" ")}`));
47
+ return;
48
+ }
49
+ resolve({
50
+ code: exitCode ?? 1,
51
+ stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
52
+ stderr: Buffer.concat(stderrChunks).toString("utf-8")
53
+ });
54
+ });
55
+ });
56
+ }
57
+
58
+ //#endregion
59
+ //#region src/infra/milaidy-root.ts
60
+ const CORE_PACKAGE_NAMES = new Set(["milaidy"]);
61
+ async function readPackageName(dir) {
62
+ try {
63
+ const raw = await fs.readFile(path.join(dir, "package.json"), "utf-8");
64
+ const parsed = JSON.parse(raw);
65
+ return typeof parsed.name === "string" ? parsed.name : null;
66
+ } catch {
67
+ return null;
68
+ }
69
+ }
70
+ async function findPackageRoot(startDir, maxDepth = 12) {
71
+ let current = path.resolve(startDir);
72
+ for (let i = 0; i < maxDepth; i += 1) {
73
+ const name = await readPackageName(current);
74
+ if (name && CORE_PACKAGE_NAMES.has(name)) return current;
75
+ const parent = path.dirname(current);
76
+ if (parent === current) break;
77
+ current = parent;
78
+ }
79
+ return null;
80
+ }
81
+ function candidateDirsFromArgv1(argv1) {
82
+ const normalized = path.resolve(argv1);
83
+ const candidates = [path.dirname(normalized)];
84
+ const parts = normalized.split(path.sep);
85
+ const binIndex = parts.lastIndexOf(".bin");
86
+ if (binIndex > 0 && parts[binIndex - 1] === "node_modules") {
87
+ const binName = path.basename(normalized);
88
+ const nodeModulesDir = parts.slice(0, binIndex).join(path.sep);
89
+ candidates.push(path.join(nodeModulesDir, binName));
90
+ }
91
+ return candidates;
92
+ }
93
+ async function resolveMilaidyPackageRoot(opts) {
94
+ const candidates = [];
95
+ if (opts.moduleUrl) candidates.push(path.dirname(fileURLToPath(opts.moduleUrl)));
96
+ if (opts.argv1) candidates.push(...candidateDirsFromArgv1(opts.argv1));
97
+ if (opts.cwd) candidates.push(opts.cwd);
98
+ for (const candidate of candidates) {
99
+ const found = await findPackageRoot(candidate);
100
+ if (found) return found;
101
+ }
102
+ return null;
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/agents/workspace-templates.ts
107
+ const FALLBACK_TEMPLATE_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../docs/reference/templates");
108
+ let cachedTemplateDir;
109
+ let resolvingTemplateDir;
110
+ async function pathExists(candidate) {
111
+ try {
112
+ await fs.access(candidate);
113
+ return true;
114
+ } catch {
115
+ return false;
116
+ }
117
+ }
118
+ async function resolveWorkspaceTemplateDir(opts) {
119
+ if (cachedTemplateDir) return cachedTemplateDir;
120
+ if (resolvingTemplateDir) return resolvingTemplateDir;
121
+ resolvingTemplateDir = (async () => {
122
+ const moduleUrl = opts?.moduleUrl ?? import.meta.url;
123
+ const argv1 = opts?.argv1 ?? process.argv[1];
124
+ const cwd = opts?.cwd ?? process.cwd();
125
+ const packageRoot = await resolveMilaidyPackageRoot({
126
+ moduleUrl,
127
+ argv1,
128
+ cwd
129
+ });
130
+ const candidates = [
131
+ packageRoot ? path.join(packageRoot, "docs", "reference", "templates") : null,
132
+ cwd ? path.resolve(cwd, "docs", "reference", "templates") : null,
133
+ FALLBACK_TEMPLATE_DIR
134
+ ].filter(Boolean);
135
+ for (const candidate of candidates) if (await pathExists(candidate)) {
136
+ cachedTemplateDir = candidate;
137
+ return candidate;
138
+ }
139
+ cachedTemplateDir = candidates[0] ?? FALLBACK_TEMPLATE_DIR;
140
+ return cachedTemplateDir;
141
+ })();
142
+ try {
143
+ return await resolvingTemplateDir;
144
+ } finally {
145
+ resolvingTemplateDir = void 0;
146
+ }
147
+ }
148
+
149
+ //#endregion
150
+ //#region src/agents/workspace.ts
151
+ function resolveDefaultAgentWorkspaceDir(env = process.env, homedir = os.homedir) {
152
+ const profile = env.MILAIDY_PROFILE?.trim();
153
+ if (profile && profile.toLowerCase() !== "default") return path.join(homedir(), ".milaidy", `workspace-${profile}`);
154
+ return path.join(homedir(), ".milaidy", "workspace");
155
+ }
156
+ const DEFAULT_AGENT_WORKSPACE_DIR = resolveDefaultAgentWorkspaceDir();
157
+ const DEFAULT_AGENTS_FILENAME = "AGENTS.md";
158
+ const DEFAULT_TOOLS_FILENAME = "TOOLS.md";
159
+ const DEFAULT_IDENTITY_FILENAME = "IDENTITY.md";
160
+ const DEFAULT_USER_FILENAME = "USER.md";
161
+ const DEFAULT_HEARTBEAT_FILENAME = "HEARTBEAT.md";
162
+ const DEFAULT_BOOTSTRAP_FILENAME = "BOOTSTRAP.md";
163
+ const DEFAULT_MEMORY_FILENAME = "MEMORY.md";
164
+ const DEFAULT_MEMORY_ALT_FILENAME = "memory.md";
165
+ function stripFrontMatter(content) {
166
+ if (!content.startsWith("---")) return content;
167
+ const endIndex = content.indexOf("\n---", 3);
168
+ if (endIndex === -1) return content;
169
+ const start = endIndex + 4;
170
+ let trimmed = content.slice(start);
171
+ trimmed = trimmed.replace(/^\s+/, "");
172
+ return trimmed;
173
+ }
174
+ async function loadTemplate(name) {
175
+ const templateDir = await resolveWorkspaceTemplateDir();
176
+ const templatePath = path.join(templateDir, name);
177
+ try {
178
+ return stripFrontMatter(await fs.readFile(templatePath, "utf-8"));
179
+ } catch {
180
+ throw new Error(`Missing workspace template: ${name} (${templatePath}). Ensure docs/reference/templates are packaged.`);
181
+ }
182
+ }
183
+ async function writeFileIfMissing(filePath, content) {
184
+ try {
185
+ await fs.writeFile(filePath, content, {
186
+ encoding: "utf-8",
187
+ flag: "wx"
188
+ });
189
+ } catch (err) {
190
+ if (err.code !== "EEXIST") throw err;
191
+ }
192
+ }
193
+ async function hasGitRepo(dir) {
194
+ try {
195
+ await fs.stat(path.join(dir, ".git"));
196
+ return true;
197
+ } catch {
198
+ return false;
199
+ }
200
+ }
201
+ async function isGitAvailable() {
202
+ try {
203
+ return (await runCommandWithTimeout(["git", "--version"], { timeoutMs: 2e3 })).code === 0;
204
+ } catch {
205
+ return false;
206
+ }
207
+ }
208
+ async function ensureGitRepo(dir, isBrandNewWorkspace) {
209
+ if (!isBrandNewWorkspace) return;
210
+ if (await hasGitRepo(dir)) return;
211
+ if (!await isGitAvailable()) return;
212
+ try {
213
+ await runCommandWithTimeout(["git", "init"], {
214
+ cwd: dir,
215
+ timeoutMs: 1e4
216
+ });
217
+ } catch {}
218
+ }
219
+ async function ensureAgentWorkspace(params) {
220
+ const dir = resolveUserPath(params?.dir?.trim() ? params.dir.trim() : DEFAULT_AGENT_WORKSPACE_DIR);
221
+ await fs.mkdir(dir, { recursive: true });
222
+ if (!params?.ensureBootstrapFiles) return { dir };
223
+ const agentsPath = path.join(dir, DEFAULT_AGENTS_FILENAME);
224
+ const toolsPath = path.join(dir, DEFAULT_TOOLS_FILENAME);
225
+ const identityPath = path.join(dir, DEFAULT_IDENTITY_FILENAME);
226
+ const userPath = path.join(dir, DEFAULT_USER_FILENAME);
227
+ const heartbeatPath = path.join(dir, DEFAULT_HEARTBEAT_FILENAME);
228
+ const bootstrapPath = path.join(dir, DEFAULT_BOOTSTRAP_FILENAME);
229
+ const isBrandNewWorkspace = await (async () => {
230
+ const paths = [
231
+ agentsPath,
232
+ toolsPath,
233
+ identityPath,
234
+ userPath,
235
+ heartbeatPath
236
+ ];
237
+ return (await Promise.all(paths.map(async (p) => {
238
+ try {
239
+ await fs.access(p);
240
+ return true;
241
+ } catch {
242
+ return false;
243
+ }
244
+ }))).every((v) => !v);
245
+ })();
246
+ const agentsTemplate = await loadTemplate(DEFAULT_AGENTS_FILENAME);
247
+ const toolsTemplate = await loadTemplate(DEFAULT_TOOLS_FILENAME);
248
+ const identityTemplate = await loadTemplate(DEFAULT_IDENTITY_FILENAME);
249
+ const userTemplate = await loadTemplate(DEFAULT_USER_FILENAME);
250
+ const heartbeatTemplate = await loadTemplate(DEFAULT_HEARTBEAT_FILENAME);
251
+ const bootstrapTemplate = await loadTemplate(DEFAULT_BOOTSTRAP_FILENAME);
252
+ await writeFileIfMissing(agentsPath, agentsTemplate);
253
+ await writeFileIfMissing(toolsPath, toolsTemplate);
254
+ await writeFileIfMissing(identityPath, identityTemplate);
255
+ await writeFileIfMissing(userPath, userTemplate);
256
+ await writeFileIfMissing(heartbeatPath, heartbeatTemplate);
257
+ if (isBrandNewWorkspace) await writeFileIfMissing(bootstrapPath, bootstrapTemplate);
258
+ await ensureGitRepo(dir, isBrandNewWorkspace);
259
+ return {
260
+ dir,
261
+ agentsPath,
262
+ toolsPath,
263
+ identityPath,
264
+ userPath,
265
+ heartbeatPath,
266
+ bootstrapPath
267
+ };
268
+ }
269
+ async function resolveMemoryBootstrapEntries(resolvedDir) {
270
+ const candidates = [DEFAULT_MEMORY_FILENAME, DEFAULT_MEMORY_ALT_FILENAME];
271
+ const entries = [];
272
+ for (const name of candidates) {
273
+ const filePath = path.join(resolvedDir, name);
274
+ try {
275
+ await fs.access(filePath);
276
+ entries.push({
277
+ name,
278
+ filePath
279
+ });
280
+ } catch {}
281
+ }
282
+ if (entries.length <= 1) return entries;
283
+ const seen = /* @__PURE__ */ new Set();
284
+ const deduped = [];
285
+ for (const entry of entries) {
286
+ let key = entry.filePath;
287
+ try {
288
+ key = await fs.realpath(entry.filePath);
289
+ } catch {}
290
+ if (seen.has(key)) continue;
291
+ seen.add(key);
292
+ deduped.push(entry);
293
+ }
294
+ return deduped;
295
+ }
296
+ async function loadWorkspaceBootstrapFiles(dir) {
297
+ const resolvedDir = resolveUserPath(dir);
298
+ const entries = [
299
+ {
300
+ name: DEFAULT_AGENTS_FILENAME,
301
+ filePath: path.join(resolvedDir, DEFAULT_AGENTS_FILENAME)
302
+ },
303
+ {
304
+ name: DEFAULT_TOOLS_FILENAME,
305
+ filePath: path.join(resolvedDir, DEFAULT_TOOLS_FILENAME)
306
+ },
307
+ {
308
+ name: DEFAULT_IDENTITY_FILENAME,
309
+ filePath: path.join(resolvedDir, DEFAULT_IDENTITY_FILENAME)
310
+ },
311
+ {
312
+ name: DEFAULT_USER_FILENAME,
313
+ filePath: path.join(resolvedDir, DEFAULT_USER_FILENAME)
314
+ },
315
+ {
316
+ name: DEFAULT_HEARTBEAT_FILENAME,
317
+ filePath: path.join(resolvedDir, DEFAULT_HEARTBEAT_FILENAME)
318
+ },
319
+ {
320
+ name: DEFAULT_BOOTSTRAP_FILENAME,
321
+ filePath: path.join(resolvedDir, DEFAULT_BOOTSTRAP_FILENAME)
322
+ }
323
+ ];
324
+ entries.push(...await resolveMemoryBootstrapEntries(resolvedDir));
325
+ const result = [];
326
+ for (const entry of entries) try {
327
+ const content = await fs.readFile(entry.filePath, "utf-8");
328
+ result.push({
329
+ name: entry.name,
330
+ path: entry.filePath,
331
+ content,
332
+ missing: false
333
+ });
334
+ } catch {
335
+ result.push({
336
+ name: entry.name,
337
+ path: entry.filePath,
338
+ missing: true
339
+ });
340
+ }
341
+ return result;
342
+ }
343
+ const SUBAGENT_BOOTSTRAP_ALLOWLIST = new Set([DEFAULT_AGENTS_FILENAME, DEFAULT_TOOLS_FILENAME]);
344
+ function filterBootstrapFilesForSession(files, sessionKey) {
345
+ if (!sessionKey || !isSubagentSessionKey(sessionKey)) return files;
346
+ return files.filter((file) => SUBAGENT_BOOTSTRAP_ALLOWLIST.has(file.name));
347
+ }
348
+
349
+ //#endregion
350
+ export { DEFAULT_IDENTITY_FILENAME as a, DEFAULT_TOOLS_FILENAME as c, filterBootstrapFilesForSession as d, loadWorkspaceBootstrapFiles as f, DEFAULT_HEARTBEAT_FILENAME as i, DEFAULT_USER_FILENAME as l, DEFAULT_AGENT_WORKSPACE_DIR as n, DEFAULT_MEMORY_ALT_FILENAME as o, resolveDefaultAgentWorkspaceDir as p, DEFAULT_BOOTSTRAP_FILENAME as r, DEFAULT_MEMORY_FILENAME as s, DEFAULT_AGENTS_FILENAME as t, ensureAgentWorkspace as u };
@@ -0,0 +1,31 @@
1
+ # Milaidy docs i18n assets
2
+
3
+ This folder stores **generated** and **config** files for documentation translations.
4
+
5
+ ## Files
6
+
7
+ - `glossary.<lang>.json` — preferred term mappings (used in prompt guidance).
8
+ - `<lang>.tm.jsonl` — translation memory (cache) keyed by workflow + model + text hash.
9
+
10
+ ## Glossary format
11
+
12
+ `glossary.<lang>.json` is an array of entries:
13
+
14
+ ```json
15
+ {
16
+ "source": "troubleshooting",
17
+ "target": "故障排除",
18
+ "ignore_case": true,
19
+ "whole_word": false
20
+ }
21
+ ```
22
+
23
+ Fields:
24
+
25
+ - `source`: English (or source) phrase to prefer.
26
+ - `target`: preferred translation output.
27
+
28
+ ## Notes
29
+
30
+ - Glossary entries are passed to the model as **prompt guidance** (no deterministic rewrites).
31
+ - The translation memory is updated by `scripts/docs-i18n`.
@@ -0,0 +1,210 @@
1
+ [
2
+ {
3
+ "source": "Milaidy",
4
+ "target": "Milaidy"
5
+ },
6
+ {
7
+ "source": "Gateway",
8
+ "target": "Gateway 网关"
9
+ },
10
+ {
11
+ "source": "Pi",
12
+ "target": "Pi"
13
+ },
14
+ {
15
+ "source": "Skills",
16
+ "target": "Skills"
17
+ },
18
+ {
19
+ "source": "Skills config",
20
+ "target": "Skills 配置"
21
+ },
22
+ {
23
+ "source": "Skills Config",
24
+ "target": "Skills 配置"
25
+ },
26
+ {
27
+ "source": "local loopback",
28
+ "target": "local loopback"
29
+ },
30
+ {
31
+ "source": "Tailscale",
32
+ "target": "Tailscale"
33
+ },
34
+ {
35
+ "source": "Getting Started",
36
+ "target": "入门指南"
37
+ },
38
+ {
39
+ "source": "Getting started",
40
+ "target": "入门指南"
41
+ },
42
+ {
43
+ "source": "Quick start",
44
+ "target": "快速开始"
45
+ },
46
+ {
47
+ "source": "Quick Start",
48
+ "target": "快速开始"
49
+ },
50
+ {
51
+ "source": "Docs directory",
52
+ "target": "文档目录"
53
+ },
54
+ {
55
+ "source": "Credits",
56
+ "target": "致谢"
57
+ },
58
+ {
59
+ "source": "Features",
60
+ "target": "功能"
61
+ },
62
+ {
63
+ "source": "DMs",
64
+ "target": "私信"
65
+ },
66
+ {
67
+ "source": "DM",
68
+ "target": "私信"
69
+ },
70
+ {
71
+ "source": "sandbox",
72
+ "target": "沙箱"
73
+ },
74
+ {
75
+ "source": "Sandbox",
76
+ "target": "沙箱"
77
+ },
78
+ {
79
+ "source": "sandboxing",
80
+ "target": "沙箱隔离"
81
+ },
82
+ {
83
+ "source": "Sandboxing",
84
+ "target": "沙箱隔离"
85
+ },
86
+ {
87
+ "source": "sandboxed",
88
+ "target": "沙箱隔离"
89
+ },
90
+ {
91
+ "source": "Sandboxed",
92
+ "target": "沙箱隔离"
93
+ },
94
+ {
95
+ "source": "Sandboxing note",
96
+ "target": "沙箱注意事项"
97
+ },
98
+ {
99
+ "source": "Companion apps",
100
+ "target": "配套应用"
101
+ },
102
+ {
103
+ "source": "expected keys",
104
+ "target": "预期键名"
105
+ },
106
+ {
107
+ "source": "block streaming",
108
+ "target": "分块流式传输"
109
+ },
110
+ {
111
+ "source": "Block streaming",
112
+ "target": "分块流式传输"
113
+ },
114
+ {
115
+ "source": "Discovery + transports",
116
+ "target": "设备发现 + 传输协议"
117
+ },
118
+ {
119
+ "source": "Discovery",
120
+ "target": "设备发现"
121
+ },
122
+ {
123
+ "source": "Network model",
124
+ "target": "网络模型"
125
+ },
126
+ {
127
+ "source": "for full details",
128
+ "target": "了解详情"
129
+ },
130
+ {
131
+ "source": "First 60 seconds",
132
+ "target": "最初的六十秒"
133
+ },
134
+ {
135
+ "source": "Auth: where it lives (important)",
136
+ "target": "凭证:存储位置(重要)"
137
+ },
138
+ {
139
+ "source": "agent",
140
+ "target": "智能体"
141
+ },
142
+ {
143
+ "source": "channel",
144
+ "target": "渠道"
145
+ },
146
+ {
147
+ "source": "session",
148
+ "target": "会话"
149
+ },
150
+ {
151
+ "source": "provider",
152
+ "target": "提供商"
153
+ },
154
+ {
155
+ "source": "model",
156
+ "target": "模型"
157
+ },
158
+ {
159
+ "source": "tool",
160
+ "target": "工具"
161
+ },
162
+ {
163
+ "source": "CLI",
164
+ "target": "CLI"
165
+ },
166
+ {
167
+ "source": "install sanity",
168
+ "target": "安装完整性检查"
169
+ },
170
+ {
171
+ "source": "get unstuck",
172
+ "target": "解决问题"
173
+ },
174
+ {
175
+ "source": "troubleshooting",
176
+ "target": "故障排除"
177
+ },
178
+ {
179
+ "source": "FAQ",
180
+ "target": "常见问题"
181
+ },
182
+ {
183
+ "source": "onboarding",
184
+ "target": "新手引导"
185
+ },
186
+ {
187
+ "source": "Onboarding",
188
+ "target": "新手引导"
189
+ },
190
+ {
191
+ "source": "wizard",
192
+ "target": "向导"
193
+ },
194
+ {
195
+ "source": "environment variables",
196
+ "target": "环境变量"
197
+ },
198
+ {
199
+ "source": "environment variable",
200
+ "target": "环境变量"
201
+ },
202
+ {
203
+ "source": "env vars",
204
+ "target": "环境变量"
205
+ },
206
+ {
207
+ "source": "env var",
208
+ "target": "环境变量"
209
+ }
210
+ ]