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.
Files changed (241) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +7 -0
  2. package/dist/actions/emote.js +64 -0
  3. package/dist/actions/restart.js +81 -0
  4. package/dist/actions/send-message.js +152 -0
  5. package/dist/agent-admin-routes.js +82 -0
  6. package/dist/agent-lifecycle-routes.js +79 -0
  7. package/dist/agent-transfer-routes.js +102 -0
  8. package/dist/api/agent-admin-routes.js +82 -0
  9. package/dist/api/agent-lifecycle-routes.js +79 -0
  10. package/dist/api/agent-transfer-routes.js +102 -0
  11. package/dist/api/apps-hyperscape-routes.js +58 -0
  12. package/dist/api/apps-routes.js +114 -0
  13. package/dist/api/auth-routes.js +56 -0
  14. package/dist/api/autonomy-routes.js +44 -0
  15. package/dist/api/bug-report-routes.js +111 -0
  16. package/dist/api/character-routes.js +195 -0
  17. package/dist/api/cloud-routes.js +330 -0
  18. package/dist/api/cloud-status-routes.js +155 -0
  19. package/dist/api/compat-utils.js +111 -0
  20. package/dist/api/database.js +735 -0
  21. package/dist/api/diagnostics-routes.js +205 -0
  22. package/dist/api/drop-service.js +134 -0
  23. package/dist/api/early-logs.js +86 -0
  24. package/dist/api/http-helpers.js +131 -0
  25. package/dist/api/knowledge-routes.js +534 -0
  26. package/dist/api/memory-bounds.js +71 -0
  27. package/dist/api/models-routes.js +28 -0
  28. package/dist/api/og-tracker.js +36 -0
  29. package/dist/api/permissions-routes.js +109 -0
  30. package/dist/api/plugin-validation.js +198 -0
  31. package/dist/api/provider-switch-config.js +41 -0
  32. package/dist/api/registry-routes.js +86 -0
  33. package/dist/api/registry-service.js +164 -0
  34. package/dist/api/sandbox-routes.js +1112 -0
  35. package/dist/api/server.js +7949 -0
  36. package/dist/api/subscription-routes.js +172 -0
  37. package/dist/api/terminal-run-limits.js +24 -0
  38. package/dist/api/training-routes.js +158 -0
  39. package/dist/api/trajectory-routes.js +300 -0
  40. package/dist/api/trigger-routes.js +246 -0
  41. package/dist/api/twitter-verify.js +134 -0
  42. package/dist/api/tx-service.js +108 -0
  43. package/dist/api/wallet-routes.js +266 -0
  44. package/dist/api/wallet.js +568 -0
  45. package/dist/api/whatsapp-routes.js +182 -0
  46. package/dist/api/zip-utils.js +109 -0
  47. package/dist/apps-hyperscape-routes.js +58 -0
  48. package/dist/apps-routes.js +114 -0
  49. package/dist/ascii.js +20 -0
  50. package/dist/auth/anthropic.js +44 -0
  51. package/dist/auth/apply-stealth.js +41 -0
  52. package/dist/auth/claude-code-stealth.js +78 -0
  53. package/dist/auth/credentials.js +156 -0
  54. package/dist/auth/index.js +5 -0
  55. package/dist/auth/openai-codex.js +66 -0
  56. package/dist/auth/types.js +9 -0
  57. package/dist/auth-routes.js +56 -0
  58. package/dist/autonomy-routes.js +44 -0
  59. package/dist/bug-report-routes.js +111 -0
  60. package/dist/build-info.json +6 -0
  61. package/dist/character-routes.js +195 -0
  62. package/dist/cli/argv.js +63 -0
  63. package/dist/cli/banner.js +34 -0
  64. package/dist/cli/cli-name.js +21 -0
  65. package/dist/cli/cli-utils.js +16 -0
  66. package/dist/cli/git-commit.js +78 -0
  67. package/dist/cli/parse-duration.js +15 -0
  68. package/dist/cli/plugins-cli.js +590 -0
  69. package/dist/cli/profile-utils.js +9 -0
  70. package/dist/cli/profile.js +95 -0
  71. package/dist/cli/program/build-program.js +17 -0
  72. package/dist/cli/program/command-registry.js +23 -0
  73. package/dist/cli/program/help.js +47 -0
  74. package/dist/cli/program/preaction.js +33 -0
  75. package/dist/cli/program/register.config.js +106 -0
  76. package/dist/cli/program/register.configure.js +20 -0
  77. package/dist/cli/program/register.dashboard.js +124 -0
  78. package/dist/cli/program/register.models.js +23 -0
  79. package/dist/cli/program/register.setup.js +36 -0
  80. package/dist/cli/program/register.start.js +22 -0
  81. package/dist/cli/program/register.subclis.js +70 -0
  82. package/dist/cli/program/register.tui.js +163 -0
  83. package/dist/cli/program/register.update.js +154 -0
  84. package/dist/cli/program.js +3 -0
  85. package/dist/cli/run-main.js +37 -0
  86. package/dist/cli/version.js +7 -0
  87. package/dist/cloud/validate-url.js +93 -0
  88. package/dist/cloud-routes.js +330 -0
  89. package/dist/cloud-status-routes.js +155 -0
  90. package/dist/compat-utils.js +111 -0
  91. package/dist/config/config.js +69 -0
  92. package/dist/config/env-vars.js +19 -0
  93. package/dist/config/includes.js +121 -0
  94. package/dist/config/object-utils.js +7 -0
  95. package/dist/config/paths.js +38 -0
  96. package/dist/config/plugin-auto-enable.js +231 -0
  97. package/dist/config/schema.js +864 -0
  98. package/dist/config/telegram-custom-commands.js +76 -0
  99. package/dist/config/zod-schema.agent-runtime.js +519 -0
  100. package/dist/config/zod-schema.core.js +538 -0
  101. package/dist/config/zod-schema.hooks.js +103 -0
  102. package/dist/config/zod-schema.js +488 -0
  103. package/dist/config/zod-schema.providers-core.js +785 -0
  104. package/dist/config/zod-schema.session.js +73 -0
  105. package/dist/core-plugins.js +37 -0
  106. package/dist/custom-actions.js +250 -0
  107. package/dist/database.js +735 -0
  108. package/dist/diagnostics/integration-observability.js +57 -0
  109. package/dist/diagnostics-routes.js +205 -0
  110. package/dist/drop-service.js +134 -0
  111. package/dist/early-logs.js +24 -0
  112. package/dist/eliza.js +2061 -0
  113. package/dist/emotes/catalog.js +271 -0
  114. package/dist/entry.js +40 -0
  115. package/dist/hooks/discovery.js +167 -0
  116. package/dist/hooks/eligibility.js +64 -0
  117. package/dist/hooks/index.js +4 -0
  118. package/dist/hooks/loader.js +147 -0
  119. package/dist/hooks/registry.js +55 -0
  120. package/dist/http-helpers.js +131 -0
  121. package/dist/index.js +49 -0
  122. package/dist/knowledge-routes.js +534 -0
  123. package/dist/memory-bounds.js +71 -0
  124. package/dist/milady-plugin.js +90 -0
  125. package/dist/models-routes.js +28 -0
  126. package/dist/onboarding-names.js +78 -0
  127. package/dist/onboarding-presets.js +922 -0
  128. package/dist/package.json +1 -0
  129. package/dist/permissions-routes.js +109 -0
  130. package/dist/plugin-validation.js +107 -0
  131. package/dist/plugins/whatsapp/actions.js +91 -0
  132. package/dist/plugins/whatsapp/index.js +16 -0
  133. package/dist/plugins/whatsapp/service.js +270 -0
  134. package/dist/provider-switch-config.js +41 -0
  135. package/dist/providers/admin-trust.js +46 -0
  136. package/dist/providers/autonomous-state.js +101 -0
  137. package/dist/providers/session-bridge.js +86 -0
  138. package/dist/providers/session-utils.js +36 -0
  139. package/dist/providers/simple-mode.js +50 -0
  140. package/dist/providers/ui-catalog.js +15 -0
  141. package/dist/providers/workspace-provider.js +93 -0
  142. package/dist/providers/workspace.js +348 -0
  143. package/dist/registry-routes.js +86 -0
  144. package/dist/registry-service.js +164 -0
  145. package/dist/restart.js +40 -0
  146. package/dist/runtime/core-plugins.js +37 -0
  147. package/dist/runtime/custom-actions.js +250 -0
  148. package/dist/runtime/eliza.js +2061 -0
  149. package/dist/runtime/embedding-manager-support.js +185 -0
  150. package/dist/runtime/embedding-manager.js +193 -0
  151. package/dist/runtime/embedding-presets.js +54 -0
  152. package/dist/runtime/embedding-state.js +8 -0
  153. package/dist/runtime/milady-plugin.js +90 -0
  154. package/dist/runtime/onboarding-names.js +78 -0
  155. package/dist/runtime/restart.js +40 -0
  156. package/dist/runtime/version.js +7 -0
  157. package/dist/sandbox-routes.js +1112 -0
  158. package/dist/security/audit-log.js +149 -0
  159. package/dist/security/network-policy.js +70 -0
  160. package/dist/server.js +7949 -0
  161. package/dist/services/agent-export.js +559 -0
  162. package/dist/services/app-manager.js +389 -0
  163. package/dist/services/browser-capture.js +86 -0
  164. package/dist/services/fallback-training-service.js +128 -0
  165. package/dist/services/mcp-marketplace.js +134 -0
  166. package/dist/services/plugin-installer.js +396 -0
  167. package/dist/services/plugin-manager-types.js +15 -0
  168. package/dist/services/registry-client-app-meta.js +144 -0
  169. package/dist/services/registry-client-endpoints.js +166 -0
  170. package/dist/services/registry-client-local.js +271 -0
  171. package/dist/services/registry-client-network.js +93 -0
  172. package/dist/services/registry-client-queries.js +70 -0
  173. package/dist/services/registry-client.js +157 -0
  174. package/dist/services/sandbox-engine.js +511 -0
  175. package/dist/services/sandbox-manager.js +297 -0
  176. package/dist/services/self-updater.js +175 -0
  177. package/dist/services/skill-catalog-client.js +119 -0
  178. package/dist/services/skill-marketplace.js +521 -0
  179. package/dist/services/stream-manager.js +236 -0
  180. package/dist/services/update-checker.js +121 -0
  181. package/dist/services/update-notifier.js +29 -0
  182. package/dist/services/version-compat.js +78 -0
  183. package/dist/services/whatsapp-pairing.js +196 -0
  184. package/dist/shared/ui-catalog-prompt.js +728 -0
  185. package/dist/subscription-routes.js +172 -0
  186. package/dist/terminal/links.js +19 -0
  187. package/dist/terminal/palette.js +14 -0
  188. package/dist/terminal/theme.js +25 -0
  189. package/dist/terminal-run-limits.js +24 -0
  190. package/dist/training-routes.js +158 -0
  191. package/dist/trajectory-routes.js +300 -0
  192. package/dist/trigger-routes.js +246 -0
  193. package/dist/triggers/action.js +218 -0
  194. package/dist/triggers/runtime.js +281 -0
  195. package/dist/triggers/scheduling.js +295 -0
  196. package/dist/triggers/types.js +5 -0
  197. package/dist/tui/components/assistant-message.js +76 -0
  198. package/dist/tui/components/chat-editor.js +34 -0
  199. package/dist/tui/components/embeddings-overlay.js +46 -0
  200. package/dist/tui/components/footer.js +60 -0
  201. package/dist/tui/components/index.js +15 -0
  202. package/dist/tui/components/modal-frame.js +45 -0
  203. package/dist/tui/components/modal-style.js +15 -0
  204. package/dist/tui/components/model-selector.js +70 -0
  205. package/dist/tui/components/pinned-chat-layout.js +46 -0
  206. package/dist/tui/components/plugins-endpoints-tab.js +196 -0
  207. package/dist/tui/components/plugins-installed-tab-view.js +69 -0
  208. package/dist/tui/components/plugins-installed-tab.js +319 -0
  209. package/dist/tui/components/plugins-overlay-catalog.js +81 -0
  210. package/dist/tui/components/plugins-overlay-data-api.js +21 -0
  211. package/dist/tui/components/plugins-overlay-data-shared.js +20 -0
  212. package/dist/tui/components/plugins-overlay-data.js +323 -0
  213. package/dist/tui/components/plugins-overlay.js +117 -0
  214. package/dist/tui/components/plugins-store-tab.js +148 -0
  215. package/dist/tui/components/settings-overlay.js +61 -0
  216. package/dist/tui/components/status-bar.js +64 -0
  217. package/dist/tui/components/tool-execution.js +68 -0
  218. package/dist/tui/components/user-message.js +22 -0
  219. package/dist/tui/eliza-tui-bridge.js +606 -0
  220. package/dist/tui/index.js +370 -0
  221. package/dist/tui/modal-presets.js +33 -0
  222. package/dist/tui/model-spec.js +46 -0
  223. package/dist/tui/sse-parser.js +78 -0
  224. package/dist/tui/theme.js +110 -0
  225. package/dist/tui/titlebar-spinner.js +62 -0
  226. package/dist/tui/tui-app.js +311 -0
  227. package/dist/tui/ws-client.js +215 -0
  228. package/dist/twitter-verify.js +134 -0
  229. package/dist/tx-service.js +108 -0
  230. package/dist/utils/exec-safety.js +17 -0
  231. package/dist/utils/globals.js +20 -0
  232. package/dist/utils/milady-root.js +61 -0
  233. package/dist/utils/number-parsing.js +37 -0
  234. package/dist/version-resolver.js +37 -0
  235. package/dist/version.js +7 -0
  236. package/dist/wallet-routes.js +266 -0
  237. package/dist/wallet.js +568 -0
  238. package/dist/whatsapp-routes.js +182 -0
  239. package/dist/zip-utils.js +109 -0
  240. package/milady.mjs +14 -0
  241. package/package.json +111 -0
@@ -0,0 +1,101 @@
1
+ //#region src/providers/autonomous-state.ts
2
+ const MAX_CACHED_EVENTS = 240;
3
+ const cacheByAgentId = /* @__PURE__ */ new Map();
4
+ const lastHeartbeatByAgentId = /* @__PURE__ */ new Map();
5
+ function getRuntimeAgentId(runtime) {
6
+ return String(runtime.agentId);
7
+ }
8
+ function getAgentEventService(runtime) {
9
+ return runtime.getService("AGENT_EVENT");
10
+ }
11
+ function pushCachedEvent(agentId, event) {
12
+ const state = cacheByAgentId.get(agentId);
13
+ if (!state) return;
14
+ state.events.push(event);
15
+ if (state.events.length > MAX_CACHED_EVENTS) state.events.splice(0, state.events.length - MAX_CACHED_EVENTS);
16
+ }
17
+ function ensureAutonomousStateTracking(runtime) {
18
+ const agentId = getRuntimeAgentId(runtime);
19
+ const existing = cacheByAgentId.get(agentId);
20
+ if (existing && existing.runtime === runtime) return;
21
+ if (existing) {
22
+ existing.detach();
23
+ cacheByAgentId.delete(agentId);
24
+ lastHeartbeatByAgentId.delete(agentId);
25
+ }
26
+ const service = getAgentEventService(runtime);
27
+ if (!service) return;
28
+ const events = [];
29
+ const unsubscribeEvents = service.subscribe((event) => {
30
+ if (event.agentId && event.agentId !== agentId) return;
31
+ pushCachedEvent(agentId, event);
32
+ });
33
+ const unsubscribeHeartbeat = service.subscribeHeartbeat?.((heartbeat) => {
34
+ lastHeartbeatByAgentId.set(agentId, heartbeat);
35
+ });
36
+ const lastHeartbeat = service.getLastHeartbeat?.();
37
+ if (lastHeartbeat) lastHeartbeatByAgentId.set(agentId, lastHeartbeat);
38
+ cacheByAgentId.set(agentId, {
39
+ runtime,
40
+ events,
41
+ detach: () => {
42
+ unsubscribeEvents();
43
+ if (unsubscribeHeartbeat) unsubscribeHeartbeat();
44
+ }
45
+ });
46
+ }
47
+ function renderEventLine(event) {
48
+ const textValue = event.data.text;
49
+ const previewValue = event.data.preview;
50
+ const text = typeof textValue === "string" ? textValue.trim() : "";
51
+ const preview = typeof previewValue === "string" ? previewValue.trim() : "";
52
+ const body = text || preview || `${event.stream} event`;
53
+ return `- [${event.stream}] ${body}`;
54
+ }
55
+ function renderHeartbeatLine(heartbeat) {
56
+ const target = typeof heartbeat.to === "string" && heartbeat.to.trim() ? ` to ${heartbeat.to.trim()}` : "";
57
+ const preview = typeof heartbeat.preview === "string" && heartbeat.preview.trim() ? ` — ${heartbeat.preview.trim()}` : "";
58
+ return `- [heartbeat/${heartbeat.status}]${target}${preview}`;
59
+ }
60
+ function createAutonomousStateProvider() {
61
+ return {
62
+ name: "miladyAutonomousState",
63
+ description: "Recent autonomous loop activity (thoughts/actions/heartbeat) for context bridging.",
64
+ dynamic: true,
65
+ position: 10,
66
+ async get(runtime, _message, _state) {
67
+ ensureAutonomousStateTracking(runtime);
68
+ const agentId = getRuntimeAgentId(runtime);
69
+ const recent = cacheByAgentId.get(agentId)?.events.slice(-24) ?? [];
70
+ const activityLines = recent.filter((event) => event.stream === "assistant" || event.stream === "action" || event.stream === "tool").slice(-10).map(renderEventLine);
71
+ const service = getAgentEventService(runtime);
72
+ const heartbeat = lastHeartbeatByAgentId.get(agentId) ?? service?.getLastHeartbeat?.() ?? null;
73
+ const renderedLines = [...activityLines];
74
+ if (heartbeat) renderedLines.push(renderHeartbeatLine(heartbeat));
75
+ return {
76
+ text: renderedLines.length > 0 ? `Autonomous state snapshot:\n${renderedLines.join("\n")}` : "Autonomous state snapshot: no recent thought/action events.",
77
+ values: {
78
+ hasAutonomousState: renderedLines.length > 0,
79
+ autonomousEventsCount: recent.length,
80
+ heartbeatStatus: heartbeat?.status ?? ""
81
+ },
82
+ data: {
83
+ events: recent.slice(-10).map((event) => ({
84
+ runId: event.runId,
85
+ seq: event.seq,
86
+ stream: event.stream,
87
+ ts: event.ts
88
+ })),
89
+ heartbeat: heartbeat ? {
90
+ status: heartbeat.status,
91
+ ts: heartbeat.ts,
92
+ to: heartbeat.to ?? ""
93
+ } : null
94
+ }
95
+ };
96
+ }
97
+ };
98
+ }
99
+
100
+ //#endregion
101
+ export { createAutonomousStateProvider, ensureAutonomousStateTracking };
@@ -0,0 +1,86 @@
1
+ import * as elizaCore from "@elizaos/core";
2
+
3
+ //#region src/providers/session-bridge.ts
4
+ const coreSessionHelpers = elizaCore;
5
+ const channelType = coreSessionHelpers.ChannelType ?? {
6
+ DM: "DM",
7
+ SELF: "SELF",
8
+ GROUP: "GROUP"
9
+ };
10
+ function buildAgentMainSessionKey(params) {
11
+ if (typeof coreSessionHelpers.buildAgentMainSessionKey === "function") return coreSessionHelpers.buildAgentMainSessionKey(params);
12
+ return `agent:${params.agentId}:${params.mainKey}`;
13
+ }
14
+ function parseAgentSessionKey(key) {
15
+ if (typeof coreSessionHelpers.parseAgentSessionKey === "function") return coreSessionHelpers.parseAgentSessionKey(key);
16
+ }
17
+ /**
18
+ * Resolve an Milady session key from an ElizaOS room.
19
+ *
20
+ * DMs -> agent:{agentId}:main
21
+ * Groups -> agent:{agentId}:{channel}:group:{groupId}
22
+ * Channels -> agent:{agentId}:{channel}:channel:{channelId}
23
+ * Threads append :thread:{threadId}
24
+ */
25
+ function resolveSessionKeyFromRoom(agentId, room, meta) {
26
+ const channel = meta?.channel ?? room.source ?? "unknown";
27
+ if (room.type === channelType.DM || room.type === channelType.SELF) return buildAgentMainSessionKey({
28
+ agentId,
29
+ mainKey: "main"
30
+ });
31
+ const id = meta?.groupId ?? room.channelId ?? room.id;
32
+ const base = `agent:${agentId}:${channel}:${room.type === channelType.GROUP ? "group" : "channel"}:${id}`;
33
+ return meta?.threadId ? `${base}:thread:${meta.threadId}` : base;
34
+ }
35
+ function createSessionKeyProvider(options) {
36
+ const agentId = options?.defaultAgentId ?? "main";
37
+ return {
38
+ name: "miladySessionKey",
39
+ description: "Milady session key (DM/group/thread isolation)",
40
+ dynamic: true,
41
+ position: 5,
42
+ async get(runtime, message, _state) {
43
+ const meta = message.metadata ?? {};
44
+ const existing = typeof meta.sessionKey === "string" ? meta.sessionKey : void 0;
45
+ if (existing) {
46
+ const parsed = parseAgentSessionKey(existing);
47
+ return {
48
+ text: `Session: ${existing}`,
49
+ values: {
50
+ sessionKey: existing,
51
+ agentId: parsed?.agentId ?? agentId
52
+ },
53
+ data: { sessionKey: existing }
54
+ };
55
+ }
56
+ const room = await runtime.getRoom(message.roomId);
57
+ if (!room) {
58
+ const key = buildAgentMainSessionKey({
59
+ agentId,
60
+ mainKey: "main"
61
+ });
62
+ return {
63
+ text: `Session: ${key}`,
64
+ values: { sessionKey: key },
65
+ data: { sessionKey: key }
66
+ };
67
+ }
68
+ const key = resolveSessionKeyFromRoom(agentId, room, {
69
+ threadId: typeof meta.threadId === "string" ? meta.threadId : void 0,
70
+ groupId: typeof meta.groupId === "string" ? meta.groupId : void 0,
71
+ channel: (typeof meta.channel === "string" ? meta.channel : void 0) ?? room.source
72
+ });
73
+ return {
74
+ text: `Session: ${key}`,
75
+ values: {
76
+ sessionKey: key,
77
+ isGroup: room.type === channelType.GROUP
78
+ },
79
+ data: { sessionKey: key }
80
+ };
81
+ }
82
+ };
83
+ }
84
+
85
+ //#endregion
86
+ export { createSessionKeyProvider };
@@ -0,0 +1,36 @@
1
+ import * as os$1 from "node:os";
2
+ import * as path$1 from "node:path";
3
+
4
+ //#region src/providers/session-utils.ts
5
+ /**
6
+ * Session utility functions for milady plugin.
7
+ *
8
+ * These are simplified versions for use until @elizaos/core exports them.
9
+ */
10
+ const DEFAULT_AGENT_ID = "main";
11
+ /**
12
+ * Resolve the sessions directory for an agent.
13
+ */
14
+ function resolveAgentSessionsDir(agentId) {
15
+ const id = agentId ?? DEFAULT_AGENT_ID;
16
+ const stateDir = process.env.MILADY_STATE_DIR ?? path$1.join(os$1.homedir(), ".milady");
17
+ return path$1.join(stateDir, "agents", id, "sessions");
18
+ }
19
+ /**
20
+ * Resolve the default session store path.
21
+ */
22
+ function resolveDefaultSessionStorePath(agentId) {
23
+ return path$1.join(resolveAgentSessionsDir(agentId), "sessions.json");
24
+ }
25
+ /**
26
+ * Get session providers.
27
+ *
28
+ * Returns an empty array for now - session providers will be added
29
+ * when @elizaos/core exports them.
30
+ */
31
+ function getSessionProviders(_options) {
32
+ return [];
33
+ }
34
+
35
+ //#endregion
36
+ export { getSessionProviders, resolveDefaultSessionStorePath };
@@ -0,0 +1,50 @@
1
+ import { ChannelType } from "@elizaos/core";
2
+
3
+ //#region src/providers/simple-mode.ts
4
+ function resolveChannelProfile(message) {
5
+ const channelType = message.content?.channelType;
6
+ if (channelType === ChannelType.VOICE_DM || channelType === ChannelType.VOICE_GROUP) return "voice_fast";
7
+ if (channelType === ChannelType.GROUP) return "group_compact";
8
+ return "default_full";
9
+ }
10
+ function createChannelProfileProvider() {
11
+ return {
12
+ name: "miladyChannelProfile",
13
+ description: "Injects channel-derived execution profile guidance (voice/group/default).",
14
+ alwaysRun: true,
15
+ position: -50,
16
+ async get(_runtime, message, _state) {
17
+ const profile = resolveChannelProfile(message);
18
+ if (profile === "voice_fast") return {
19
+ text: [
20
+ "Execution profile: VOICE_FAST.",
21
+ "Prioritize low latency and conversational flow.",
22
+ "Keep tool/provider usage minimal and avoid unnecessary context expansion."
23
+ ].join(" "),
24
+ values: {
25
+ executionProfile: "voice_fast",
26
+ compactContext: true
27
+ },
28
+ data: { profile: "voice_fast" }
29
+ };
30
+ if (profile === "group_compact") return {
31
+ text: ["Execution profile: GROUP_COMPACT.", "Keep responses concise and context usage focused on the active group thread."].join(" "),
32
+ values: {
33
+ executionProfile: "group_compact",
34
+ compactContext: true
35
+ },
36
+ data: { profile: "group_compact" }
37
+ };
38
+ return {
39
+ values: {
40
+ executionProfile: "default_full",
41
+ compactContext: false
42
+ },
43
+ data: { profile: "default_full" }
44
+ };
45
+ }
46
+ };
47
+ }
48
+
49
+ //#endregion
50
+ export { createChannelProfileProvider };
@@ -0,0 +1,15 @@
1
+ import { COMPONENT_CATALOG } from "../shared/ui-catalog-prompt.js";
2
+ import { ChannelType } from "@elizaos/core";
3
+
4
+ //#region src/providers/ui-catalog.ts
5
+ const uiCatalogProvider = {
6
+ name: "uiCatalog",
7
+ get: async (_runtime, message, _state) => {
8
+ const channelType = message.content?.channelType;
9
+ if (!(channelType === ChannelType.DM || channelType === ChannelType.API || !channelType)) return { text: "" };
10
+ return { text: `Available UI Components:\n${Object.entries(COMPONENT_CATALOG).map(([name, meta]) => `- ${name}: ${meta.description}`).join("\n")}` };
11
+ }
12
+ };
13
+
14
+ //#endregion
15
+ export { uiCatalogProvider };
@@ -0,0 +1,93 @@
1
+ import { DEFAULT_AGENT_WORKSPACE_DIR, filterBootstrapFilesForSession, loadWorkspaceBootstrapFiles } from "./workspace.js";
2
+ import { ChannelType, logger } from "@elizaos/core";
3
+
4
+ //#region src/providers/workspace-provider.ts
5
+ /**
6
+ * Reads workspace bootstrap files and injects them into agent context.
7
+ *
8
+ * Also provides coding agent context enrichment: when coding-agent metadata
9
+ * is present on the inbound message, the provider appends a summary of the
10
+ * current coding session state (active iteration, recent errors, pending
11
+ * feedback) so the LLM has full awareness during the autonomous coding loop.
12
+ */
13
+ const DEFAULT_MAX_CHARS = 2e4;
14
+ /** Hard cap on total workspace context to prevent prompt explosion. */
15
+ const MAX_TOTAL_WORKSPACE_CHARS = 1e5;
16
+ const CACHE_TTL_MS = 6e4;
17
+ const cache = /* @__PURE__ */ new Map();
18
+ /** Maximum number of workspace directories to cache simultaneously. */
19
+ const MAX_CACHE_ENTRIES = 20;
20
+ async function getFiles(dir) {
21
+ const now = Date.now();
22
+ const entry = cache.get(dir);
23
+ if (entry && now - entry.at < CACHE_TTL_MS) return entry.files;
24
+ for (const [key, val] of cache) if (now - val.at >= CACHE_TTL_MS) cache.delete(key);
25
+ if (cache.size >= MAX_CACHE_ENTRIES) {
26
+ const oldest = cache.keys().next().value;
27
+ if (oldest) cache.delete(oldest);
28
+ }
29
+ const files = await loadWorkspaceBootstrapFiles(dir);
30
+ cache.set(dir, {
31
+ files,
32
+ at: now
33
+ });
34
+ return files;
35
+ }
36
+ /** @internal Exported for testing. */
37
+ function truncate(content, max) {
38
+ if (content.length <= max) return content;
39
+ return `${content.slice(0, max)}\n\n[... truncated at ${max.toLocaleString()} chars]`;
40
+ }
41
+ /** @internal Exported for testing. */
42
+ function buildContext(files, maxChars) {
43
+ const sections = [];
44
+ let totalChars = 0;
45
+ for (const f of files) {
46
+ if (f.missing || !f.content?.trim()) continue;
47
+ const trimmed = f.content.trim();
48
+ const text = truncate(trimmed, maxChars);
49
+ const tag = text.length > trimmed.length ? " [TRUNCATED]" : "";
50
+ const section = `### ${f.name}${tag}\n\n${text}`;
51
+ if (totalChars + section.length > MAX_TOTAL_WORKSPACE_CHARS && sections.length > 0) break;
52
+ sections.push(section);
53
+ totalChars += section.length;
54
+ }
55
+ if (sections.length === 0) return "";
56
+ return `## Project Context (Workspace)\n\n${sections.join("\n\n---\n\n")}`;
57
+ }
58
+ function createWorkspaceProvider(options) {
59
+ const dir = options?.workspaceDir ?? DEFAULT_AGENT_WORKSPACE_DIR;
60
+ const maxChars = options?.maxCharsPerFile ?? DEFAULT_MAX_CHARS;
61
+ return {
62
+ name: "workspaceContext",
63
+ description: "Workspace bootstrap files (AGENTS.md, TOOLS.md, IDENTITY.md, etc.) and coding agent context",
64
+ position: 10,
65
+ async get(_runtime, message, _state) {
66
+ const channelType = message.content?.channelType;
67
+ if (channelType === ChannelType.VOICE_DM || channelType === ChannelType.VOICE_GROUP) return {
68
+ text: "",
69
+ data: {
70
+ workspaceDir: dir,
71
+ skipped: "voice_channel"
72
+ }
73
+ };
74
+ try {
75
+ const allFiles = await getFiles(dir);
76
+ const meta = message.metadata;
77
+ return {
78
+ text: buildContext(filterBootstrapFilesForSession(allFiles, typeof meta?.sessionKey === "string" ? meta.sessionKey : void 0), maxChars),
79
+ data: { workspaceDir: dir }
80
+ };
81
+ } catch (err) {
82
+ logger.warn(`[workspace-provider] Failed to load workspace context: ${err instanceof Error ? err.message : err}`);
83
+ return {
84
+ text: `[Workspace context unavailable: ${err instanceof Error ? err.message : err}]`,
85
+ data: {}
86
+ };
87
+ }
88
+ }
89
+ };
90
+ }
91
+
92
+ //#endregion
93
+ export { createWorkspaceProvider };