@elizaos/autonomous 2.0.0-alpha.10

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/LICENSE +21 -0
  2. package/package.json +270 -0
  3. package/src/actions/emote.ts +101 -0
  4. package/src/actions/restart.ts +101 -0
  5. package/src/actions/send-message.ts +168 -0
  6. package/src/actions/stream-control.ts +439 -0
  7. package/src/actions/switch-stream-source.ts +126 -0
  8. package/src/actions/terminal.ts +186 -0
  9. package/src/api/agent-admin-routes.ts +178 -0
  10. package/src/api/agent-lifecycle-routes.ts +129 -0
  11. package/src/api/agent-model.ts +143 -0
  12. package/src/api/agent-transfer-routes.ts +211 -0
  13. package/src/api/apps-routes.ts +210 -0
  14. package/src/api/auth-routes.ts +90 -0
  15. package/src/api/bsc-trade.ts +736 -0
  16. package/src/api/bug-report-routes.ts +161 -0
  17. package/src/api/character-routes.ts +421 -0
  18. package/src/api/cloud-billing-routes.ts +598 -0
  19. package/src/api/cloud-compat-routes.ts +192 -0
  20. package/src/api/cloud-routes.ts +529 -0
  21. package/src/api/cloud-status-routes.ts +234 -0
  22. package/src/api/compat-utils.ts +154 -0
  23. package/src/api/connector-health.ts +135 -0
  24. package/src/api/coordinator-wiring.ts +179 -0
  25. package/src/api/credit-detection.ts +47 -0
  26. package/src/api/database.ts +1357 -0
  27. package/src/api/diagnostics-routes.ts +389 -0
  28. package/src/api/drop-service.ts +205 -0
  29. package/src/api/early-logs.ts +111 -0
  30. package/src/api/http-helpers.ts +252 -0
  31. package/src/api/index.ts +85 -0
  32. package/src/api/knowledge-routes.ts +1189 -0
  33. package/src/api/knowledge-service-loader.ts +92 -0
  34. package/src/api/memory-bounds.ts +121 -0
  35. package/src/api/memory-routes.ts +349 -0
  36. package/src/api/merkle-tree.ts +239 -0
  37. package/src/api/models-routes.ts +72 -0
  38. package/src/api/nfa-routes.ts +169 -0
  39. package/src/api/nft-verify.ts +188 -0
  40. package/src/api/og-tracker.ts +72 -0
  41. package/src/api/parse-action-block.ts +145 -0
  42. package/src/api/permissions-routes.ts +222 -0
  43. package/src/api/plugin-validation.ts +355 -0
  44. package/src/api/provider-switch-config.ts +455 -0
  45. package/src/api/registry-routes.ts +165 -0
  46. package/src/api/registry-service.ts +292 -0
  47. package/src/api/route-helpers.ts +21 -0
  48. package/src/api/sandbox-routes.ts +1480 -0
  49. package/src/api/server.ts +17674 -0
  50. package/src/api/signal-routes.ts +265 -0
  51. package/src/api/stream-persistence.ts +297 -0
  52. package/src/api/stream-route-state.ts +48 -0
  53. package/src/api/stream-routes.ts +1046 -0
  54. package/src/api/stream-voice-routes.ts +208 -0
  55. package/src/api/streaming-text.ts +129 -0
  56. package/src/api/streaming-types.ts +23 -0
  57. package/src/api/subscription-routes.ts +283 -0
  58. package/src/api/terminal-run-limits.ts +31 -0
  59. package/src/api/training-backend-check.ts +40 -0
  60. package/src/api/training-routes.ts +314 -0
  61. package/src/api/training-service-like.ts +46 -0
  62. package/src/api/trajectory-routes.ts +714 -0
  63. package/src/api/trigger-routes.ts +438 -0
  64. package/src/api/twitter-verify.ts +226 -0
  65. package/src/api/tx-service.ts +193 -0
  66. package/src/api/wallet-dex-prices.ts +206 -0
  67. package/src/api/wallet-evm-balance.ts +989 -0
  68. package/src/api/wallet-routes.ts +505 -0
  69. package/src/api/wallet-rpc.ts +523 -0
  70. package/src/api/wallet-trading-profile.ts +694 -0
  71. package/src/api/wallet.ts +745 -0
  72. package/src/api/whatsapp-routes.ts +282 -0
  73. package/src/api/zip-utils.ts +130 -0
  74. package/src/auth/anthropic.ts +63 -0
  75. package/src/auth/apply-stealth.ts +38 -0
  76. package/src/auth/claude-code-stealth.ts +141 -0
  77. package/src/auth/credentials.ts +226 -0
  78. package/src/auth/index.ts +18 -0
  79. package/src/auth/openai-codex.ts +94 -0
  80. package/src/auth/types.ts +24 -0
  81. package/src/awareness/registry.ts +220 -0
  82. package/src/bin.ts +10 -0
  83. package/src/cli/index.ts +36 -0
  84. package/src/cli/parse-duration.ts +43 -0
  85. package/src/cloud/auth.test.ts +370 -0
  86. package/src/cloud/auth.ts +176 -0
  87. package/src/cloud/backup.test.ts +150 -0
  88. package/src/cloud/backup.ts +50 -0
  89. package/src/cloud/base-url.ts +45 -0
  90. package/src/cloud/bridge-client.test.ts +481 -0
  91. package/src/cloud/bridge-client.ts +307 -0
  92. package/src/cloud/cloud-manager.test.ts +223 -0
  93. package/src/cloud/cloud-manager.ts +151 -0
  94. package/src/cloud/cloud-proxy.test.ts +122 -0
  95. package/src/cloud/cloud-proxy.ts +52 -0
  96. package/src/cloud/index.ts +23 -0
  97. package/src/cloud/reconnect.test.ts +178 -0
  98. package/src/cloud/reconnect.ts +108 -0
  99. package/src/cloud/validate-url.test.ts +147 -0
  100. package/src/cloud/validate-url.ts +176 -0
  101. package/src/config/character-schema.ts +44 -0
  102. package/src/config/config.ts +149 -0
  103. package/src/config/env-vars.ts +86 -0
  104. package/src/config/includes.ts +196 -0
  105. package/src/config/index.ts +15 -0
  106. package/src/config/object-utils.ts +10 -0
  107. package/src/config/paths.ts +92 -0
  108. package/src/config/plugin-auto-enable.ts +520 -0
  109. package/src/config/schema.ts +1342 -0
  110. package/src/config/telegram-custom-commands.ts +99 -0
  111. package/src/config/types.agent-defaults.ts +342 -0
  112. package/src/config/types.agents.ts +112 -0
  113. package/src/config/types.gateway.ts +243 -0
  114. package/src/config/types.hooks.ts +124 -0
  115. package/src/config/types.messages.ts +201 -0
  116. package/src/config/types.milady.ts +791 -0
  117. package/src/config/types.tools.ts +416 -0
  118. package/src/config/types.ts +7 -0
  119. package/src/config/zod-schema.agent-runtime.ts +777 -0
  120. package/src/config/zod-schema.core.ts +778 -0
  121. package/src/config/zod-schema.hooks.ts +139 -0
  122. package/src/config/zod-schema.providers-core.ts +1126 -0
  123. package/src/config/zod-schema.session.ts +98 -0
  124. package/src/config/zod-schema.ts +865 -0
  125. package/src/contracts/apps.ts +46 -0
  126. package/src/contracts/awareness.ts +56 -0
  127. package/src/contracts/config.ts +172 -0
  128. package/src/contracts/drop.ts +21 -0
  129. package/src/contracts/index.ts +8 -0
  130. package/src/contracts/onboarding.ts +592 -0
  131. package/src/contracts/permissions.ts +52 -0
  132. package/src/contracts/verification.ts +9 -0
  133. package/src/contracts/wallet.ts +503 -0
  134. package/src/diagnostics/integration-observability.ts +132 -0
  135. package/src/emotes/catalog.ts +655 -0
  136. package/src/external-modules.d.ts +7 -0
  137. package/src/hooks/discovery.test.ts +357 -0
  138. package/src/hooks/discovery.ts +231 -0
  139. package/src/hooks/eligibility.ts +146 -0
  140. package/src/hooks/hooks.test.ts +320 -0
  141. package/src/hooks/index.ts +8 -0
  142. package/src/hooks/loader.test.ts +418 -0
  143. package/src/hooks/loader.ts +256 -0
  144. package/src/hooks/registry.test.ts +168 -0
  145. package/src/hooks/registry.ts +74 -0
  146. package/src/hooks/types.ts +121 -0
  147. package/src/index.ts +19 -0
  148. package/src/onboarding-presets.ts +828 -0
  149. package/src/plugins/custom-rtmp/index.ts +40 -0
  150. package/src/providers/admin-trust.ts +76 -0
  151. package/src/providers/session-bridge.ts +143 -0
  152. package/src/providers/session-utils.ts +42 -0
  153. package/src/providers/simple-mode.ts +113 -0
  154. package/src/providers/ui-catalog.ts +135 -0
  155. package/src/providers/workspace-provider.ts +213 -0
  156. package/src/providers/workspace.ts +497 -0
  157. package/src/runtime/agent-event-service.ts +57 -0
  158. package/src/runtime/cloud-onboarding.test.ts +489 -0
  159. package/src/runtime/cloud-onboarding.ts +408 -0
  160. package/src/runtime/core-plugins.ts +53 -0
  161. package/src/runtime/custom-actions.ts +605 -0
  162. package/src/runtime/eliza.ts +4941 -0
  163. package/src/runtime/embedding-presets.ts +73 -0
  164. package/src/runtime/index.ts +8 -0
  165. package/src/runtime/milady-plugin.ts +180 -0
  166. package/src/runtime/onboarding-names.ts +76 -0
  167. package/src/runtime/release-plugin-policy.ts +119 -0
  168. package/src/runtime/restart.ts +59 -0
  169. package/src/runtime/trajectory-persistence.ts +2584 -0
  170. package/src/runtime/version.ts +6 -0
  171. package/src/security/audit-log.ts +222 -0
  172. package/src/security/network-policy.ts +91 -0
  173. package/src/server/index.ts +6 -0
  174. package/src/services/agent-export.ts +976 -0
  175. package/src/services/app-manager.ts +755 -0
  176. package/src/services/browser-capture.ts +215 -0
  177. package/src/services/coding-agent-context.ts +355 -0
  178. package/src/services/fallback-training-service.ts +196 -0
  179. package/src/services/index.ts +17 -0
  180. package/src/services/mcp-marketplace.ts +327 -0
  181. package/src/services/plugin-manager-types.ts +185 -0
  182. package/src/services/privy-wallets.ts +352 -0
  183. package/src/services/registry-client-app-meta.ts +201 -0
  184. package/src/services/registry-client-endpoints.ts +253 -0
  185. package/src/services/registry-client-local.ts +485 -0
  186. package/src/services/registry-client-network.ts +173 -0
  187. package/src/services/registry-client-queries.ts +176 -0
  188. package/src/services/registry-client-types.ts +104 -0
  189. package/src/services/registry-client.ts +366 -0
  190. package/src/services/remote-signing-service.ts +261 -0
  191. package/src/services/sandbox-engine.ts +753 -0
  192. package/src/services/sandbox-manager.ts +503 -0
  193. package/src/services/self-updater.ts +213 -0
  194. package/src/services/signal-pairing.ts +189 -0
  195. package/src/services/signing-policy.ts +230 -0
  196. package/src/services/skill-catalog-client.ts +195 -0
  197. package/src/services/skill-marketplace.ts +909 -0
  198. package/src/services/stream-manager.ts +707 -0
  199. package/src/services/tts-stream-bridge.ts +465 -0
  200. package/src/services/update-checker.ts +163 -0
  201. package/src/services/version-compat.ts +367 -0
  202. package/src/services/whatsapp-pairing.ts +279 -0
  203. package/src/shared/ui-catalog-prompt.ts +1158 -0
  204. package/src/test-support/process-helpers.ts +35 -0
  205. package/src/test-support/route-test-helpers.ts +113 -0
  206. package/src/test-support/test-helpers.ts +304 -0
  207. package/src/testing/index.ts +3 -0
  208. package/src/triggers/action.ts +342 -0
  209. package/src/triggers/runtime.ts +432 -0
  210. package/src/triggers/scheduling.ts +472 -0
  211. package/src/triggers/types.ts +133 -0
  212. package/src/types/app-hyperscape-routes-shim.d.ts +29 -0
  213. package/src/types/external-modules.d.ts +7 -0
  214. package/src/utils/exec-safety.ts +23 -0
  215. package/src/utils/number-parsing.ts +112 -0
  216. package/src/utils/spoken-text.ts +65 -0
  217. package/src/version-resolver.ts +60 -0
  218. package/test/api/agent-admin-routes.test.ts +160 -0
  219. package/test/api/agent-lifecycle-routes.test.ts +164 -0
  220. package/test/api/agent-transfer-routes.test.ts +136 -0
  221. package/test/api/apps-routes.test.ts +140 -0
  222. package/test/api/auth-routes.test.ts +160 -0
  223. package/test/api/bug-report-routes.test.ts +88 -0
  224. package/test/api/knowledge-routes.test.ts +73 -0
  225. package/test/api/lifecycle.test.ts +342 -0
  226. package/test/api/memory-routes.test.ts +74 -0
  227. package/test/api/models-routes.test.ts +112 -0
  228. package/test/api/nfa-routes.test.ts +78 -0
  229. package/test/api/permissions-routes.test.ts +185 -0
  230. package/test/api/registry-routes.test.ts +157 -0
  231. package/test/api/signal-routes.test.ts +113 -0
  232. package/test/api/subscription-routes.test.ts +90 -0
  233. package/test/api/trigger-routes.test.ts +87 -0
  234. package/test/api/wallet-routes.observability.test.ts +191 -0
  235. package/test/api/wallet-routes.test.ts +502 -0
  236. package/test/diagnostics/integration-observability.test.ts +135 -0
  237. package/test/security/audit-log.test.ts +229 -0
  238. package/test/security/network-policy.test.ts +143 -0
  239. package/test/services/version-compat.test.ts +127 -0
  240. package/tsconfig.build.json +21 -0
  241. package/tsconfig.json +19 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Custom RTMP streaming destination plugin.
3
+ *
4
+ * The simplest streaming destination — reads RTMP URL and key directly
5
+ * from config. No platform API calls, no chat bridging.
6
+ */
7
+
8
+ import type { StreamingDestination } from "../../api/stream-routes";
9
+
10
+ export function createCustomRtmpDestination(config?: {
11
+ rtmpUrl?: string;
12
+ rtmpKey?: string;
13
+ }): StreamingDestination {
14
+ return {
15
+ id: "custom-rtmp",
16
+ name: "Custom RTMP",
17
+
18
+ async getCredentials() {
19
+ const rtmpUrl = (
20
+ config?.rtmpUrl ??
21
+ process.env.CUSTOM_RTMP_URL ??
22
+ ""
23
+ ).trim();
24
+ const rtmpKey = (
25
+ config?.rtmpKey ??
26
+ process.env.CUSTOM_RTMP_KEY ??
27
+ ""
28
+ ).trim();
29
+
30
+ if (!rtmpUrl || !rtmpKey) {
31
+ throw new Error(
32
+ "Custom RTMP requires rtmpUrl and rtmpKey in streaming.customRtmp config",
33
+ );
34
+ }
35
+ return { rtmpUrl, rtmpKey };
36
+ },
37
+ // No onStreamStart/onStreamStop — no platform to notify
38
+ // No chat polling — no platform chat
39
+ };
40
+ }
@@ -0,0 +1,76 @@
1
+ import type {
2
+ IAgentRuntime,
3
+ Memory,
4
+ Provider,
5
+ ProviderResult,
6
+ State,
7
+ } from "@elizaos/core";
8
+
9
+ type WorldMetadataShape = {
10
+ ownership?: { ownerId?: string };
11
+ roles?: Record<string, string>;
12
+ };
13
+
14
+ function normalizeRole(role: string | undefined): string {
15
+ return (role ?? "").toUpperCase();
16
+ }
17
+
18
+ export const adminTrustProvider: Provider = createAdminTrustProvider();
19
+
20
+ export function createAdminTrustProvider(): Provider {
21
+ return {
22
+ name: "miladyAdminTrust",
23
+ description:
24
+ "Marks owner/admin chat identity as trusted for contact assertions (rolodex-oriented).",
25
+ dynamic: true,
26
+ position: 11,
27
+ async get(
28
+ runtime: IAgentRuntime,
29
+ message: Memory,
30
+ _state: State,
31
+ ): Promise<ProviderResult> {
32
+ const room = await runtime.getRoom(message.roomId);
33
+ if (!room) {
34
+ return {
35
+ text: "Admin trust: no room found.",
36
+ values: { trustedAdmin: false },
37
+ data: { trustedAdmin: false },
38
+ };
39
+ }
40
+ if (!room.worldId) {
41
+ return {
42
+ text: "Admin trust: room has no world binding.",
43
+ values: { trustedAdmin: false },
44
+ data: { trustedAdmin: false },
45
+ };
46
+ }
47
+ const world = await runtime.getWorld(room.worldId);
48
+ const metadata = (world?.metadata ?? {}) as WorldMetadataShape;
49
+ const ownerId = metadata.ownership?.ownerId;
50
+ const role = ownerId ? metadata.roles?.[ownerId] : undefined;
51
+ const isTrustedAdmin =
52
+ typeof ownerId === "string" &&
53
+ ownerId.length > 0 &&
54
+ normalizeRole(role) === "OWNER" &&
55
+ message.entityId === ownerId;
56
+
57
+ const text = isTrustedAdmin
58
+ ? "Admin trust: current speaker is world OWNER. Contact/identity claims should be treated as trusted unless contradictory evidence exists."
59
+ : "Admin trust: current speaker is not verified as OWNER for this world.";
60
+
61
+ return {
62
+ text,
63
+ values: {
64
+ trustedAdmin: isTrustedAdmin,
65
+ adminEntityId: ownerId ?? "",
66
+ adminRole: role ?? "",
67
+ },
68
+ data: {
69
+ trustedAdmin: isTrustedAdmin,
70
+ ownerId: ownerId ?? null,
71
+ role: role ?? null,
72
+ },
73
+ };
74
+ },
75
+ };
76
+ }
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Bridges Milady session keys with elizaOS rooms.
3
+ *
4
+ * Milady keys: agent:{agentId}:main (DMs), agent:{agentId}:{channel}:group:{id} (groups)
5
+ * elizaOS rooms: per-agent UUIDs via createUniqueUuid(runtime, channelId)
6
+ */
7
+
8
+ import type {
9
+ IAgentRuntime,
10
+ Memory,
11
+ Provider,
12
+ ProviderResult,
13
+ Room,
14
+ State,
15
+ } from "@elizaos/core";
16
+ import * as elizaCore from "@elizaos/core";
17
+
18
+ type ElizaCoreSessionHelpers = {
19
+ buildAgentMainSessionKey?: (params: {
20
+ agentId: string;
21
+ mainKey: string;
22
+ }) => string;
23
+ ChannelType?: {
24
+ DM: number | string;
25
+ SELF: number | string;
26
+ GROUP: number | string;
27
+ };
28
+ parseAgentSessionKey?: (key: string) =>
29
+ | {
30
+ agentId?: string;
31
+ }
32
+ | undefined;
33
+ };
34
+
35
+ const coreSessionHelpers = elizaCore as ElizaCoreSessionHelpers;
36
+ // Fallback for when ChannelType is not exported by @elizaos/core (e.g. in tests)
37
+ const channelType = coreSessionHelpers.ChannelType ?? {
38
+ DM: "DM",
39
+ SELF: "SELF",
40
+ GROUP: "GROUP",
41
+ };
42
+
43
+ function buildAgentMainSessionKey(params: {
44
+ agentId: string;
45
+ mainKey: string;
46
+ }): string {
47
+ if (typeof coreSessionHelpers.buildAgentMainSessionKey === "function") {
48
+ return coreSessionHelpers.buildAgentMainSessionKey(params);
49
+ }
50
+ return `agent:${params.agentId}:${params.mainKey}`;
51
+ }
52
+
53
+ function parseAgentSessionKey(key: string):
54
+ | {
55
+ agentId?: string;
56
+ }
57
+ | undefined {
58
+ if (typeof coreSessionHelpers.parseAgentSessionKey === "function") {
59
+ return coreSessionHelpers.parseAgentSessionKey(key);
60
+ }
61
+ return undefined;
62
+ }
63
+
64
+ /**
65
+ * Resolve an Milady session key from an elizaOS room.
66
+ *
67
+ * DMs -> agent:{agentId}:main
68
+ * Groups -> agent:{agentId}:{channel}:group:{groupId}
69
+ * Channels -> agent:{agentId}:{channel}:channel:{channelId}
70
+ * Threads append :thread:{threadId}
71
+ */
72
+ export function resolveSessionKeyFromRoom(
73
+ agentId: string,
74
+ room: Room,
75
+ meta?: { threadId?: string; groupId?: string; channel?: string },
76
+ ): string {
77
+ const channel = meta?.channel ?? room.source ?? "unknown";
78
+
79
+ if (room.type === channelType.DM || room.type === channelType.SELF) {
80
+ return buildAgentMainSessionKey({ agentId, mainKey: "main" });
81
+ }
82
+
83
+ const id = meta?.groupId ?? room.channelId ?? room.id;
84
+ const kind = room.type === channelType.GROUP ? "group" : "channel";
85
+ const base = `agent:${agentId}:${channel}:${kind}:${id}`;
86
+ return meta?.threadId ? `${base}:thread:${meta.threadId}` : base;
87
+ }
88
+
89
+ export function createSessionKeyProvider(options?: {
90
+ defaultAgentId?: string;
91
+ }): Provider {
92
+ const agentId = options?.defaultAgentId ?? "main";
93
+
94
+ return {
95
+ name: "miladySessionKey",
96
+ description: "Milady session key (DM/group/thread isolation)",
97
+ dynamic: true,
98
+ position: 5,
99
+
100
+ async get(
101
+ runtime: IAgentRuntime,
102
+ message: Memory,
103
+ _state: State,
104
+ ): Promise<ProviderResult> {
105
+ const meta = (message.metadata ?? {}) as Record<string, unknown>;
106
+ const existing =
107
+ typeof meta.sessionKey === "string" ? meta.sessionKey : undefined;
108
+
109
+ if (existing) {
110
+ const parsed = parseAgentSessionKey(existing);
111
+ return {
112
+ text: `Session: ${existing}`,
113
+ values: { sessionKey: existing, agentId: parsed?.agentId ?? agentId },
114
+ data: { sessionKey: existing },
115
+ };
116
+ }
117
+
118
+ const room = await runtime.getRoom(message.roomId);
119
+ if (!room) {
120
+ const key = buildAgentMainSessionKey({ agentId, mainKey: "main" });
121
+ return {
122
+ text: `Session: ${key}`,
123
+ values: { sessionKey: key },
124
+ data: { sessionKey: key },
125
+ };
126
+ }
127
+
128
+ const key = resolveSessionKeyFromRoom(agentId, room, {
129
+ threadId: typeof meta.threadId === "string" ? meta.threadId : undefined,
130
+ groupId: typeof meta.groupId === "string" ? meta.groupId : undefined,
131
+ channel:
132
+ (typeof meta.channel === "string" ? meta.channel : undefined) ??
133
+ room.source,
134
+ });
135
+
136
+ return {
137
+ text: `Session: ${key}`,
138
+ values: { sessionKey: key, isGroup: room.type === channelType.GROUP },
139
+ data: { sessionKey: key },
140
+ };
141
+ },
142
+ };
143
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Session utility functions for milady plugin.
3
+ *
4
+ * These are simplified versions for use until @elizaos/core exports them.
5
+ */
6
+
7
+ import * as os from "node:os";
8
+ import * as path from "node:path";
9
+ import type { Provider } from "@elizaos/core";
10
+
11
+ const DEFAULT_AGENT_ID = "main";
12
+
13
+ /**
14
+ * Resolve the sessions directory for an agent.
15
+ */
16
+ function resolveAgentSessionsDir(agentId?: string): string {
17
+ const id = agentId ?? DEFAULT_AGENT_ID;
18
+ const stateDir =
19
+ process.env.MILADY_STATE_DIR ?? path.join(os.homedir(), ".milady");
20
+ return path.join(stateDir, "agents", id, "sessions");
21
+ }
22
+
23
+ /**
24
+ * Resolve the default session store path.
25
+ */
26
+ export function resolveDefaultSessionStorePath(agentId?: string): string {
27
+ return path.join(resolveAgentSessionsDir(agentId), "sessions.json");
28
+ }
29
+
30
+ /**
31
+ * Get session providers.
32
+ *
33
+ * Returns an empty array for now - session providers will be added
34
+ * when @elizaos/core exports them.
35
+ */
36
+ export function getSessionProviders(_options?: {
37
+ storePath?: string;
38
+ }): Provider[] {
39
+ // Session providers are not yet available in npm @elizaos/core.
40
+ // Return empty array to allow startup without session tracking.
41
+ return [];
42
+ }
@@ -0,0 +1,113 @@
1
+ import {
2
+ ChannelType,
3
+ type IAgentRuntime,
4
+ type Memory,
5
+ type Provider,
6
+ type ProviderResult,
7
+ type State,
8
+ } from "@elizaos/core";
9
+
10
+ export type ChannelExecutionProfile =
11
+ | "voice_fast"
12
+ | "text_fast"
13
+ | "group_compact"
14
+ | "default_full";
15
+
16
+ function resolveChannelProfile(message: Memory): ChannelExecutionProfile {
17
+ const content = message.content as Record<string, unknown> | undefined;
18
+ const channelType = content?.channelType;
19
+ const conversationMode =
20
+ typeof content?.conversationMode === "string"
21
+ ? content.conversationMode.toLowerCase()
22
+ : null;
23
+ if (
24
+ channelType === ChannelType.VOICE_DM ||
25
+ channelType === ChannelType.VOICE_GROUP
26
+ ) {
27
+ return "voice_fast";
28
+ }
29
+ if (channelType === ChannelType.GROUP) {
30
+ return "group_compact";
31
+ }
32
+ if (conversationMode === "simple") {
33
+ return "text_fast";
34
+ }
35
+ return "default_full";
36
+ }
37
+
38
+ export function createChannelProfileProvider(): Provider {
39
+ return {
40
+ name: "miladyChannelProfile",
41
+ description:
42
+ "Injects channel-derived execution profile guidance (voice/group/default).",
43
+ alwaysRun: true,
44
+ position: -50,
45
+ async get(
46
+ _runtime: IAgentRuntime,
47
+ message: Memory,
48
+ _state: State,
49
+ ): Promise<ProviderResult> {
50
+ const profile = resolveChannelProfile(message);
51
+
52
+ if (profile === "voice_fast") {
53
+ return {
54
+ text: [
55
+ "Execution profile: VOICE_FAST.",
56
+ "Prioritize low latency and conversational flow.",
57
+ "Keep tool/provider usage minimal and avoid unnecessary context expansion.",
58
+ ].join(" "),
59
+ values: {
60
+ executionProfile: "voice_fast",
61
+ compactContext: true,
62
+ },
63
+ data: {
64
+ profile: "voice_fast",
65
+ },
66
+ };
67
+ }
68
+
69
+ if (profile === "text_fast") {
70
+ return {
71
+ text: [
72
+ "Execution profile: TEXT_FAST.",
73
+ "Prioritize low latency for the current chat turn.",
74
+ "Keep tool/provider usage minimal and avoid unnecessary context expansion.",
75
+ ].join(" "),
76
+ values: {
77
+ executionProfile: "text_fast",
78
+ compactContext: true,
79
+ },
80
+ data: {
81
+ profile: "text_fast",
82
+ },
83
+ };
84
+ }
85
+
86
+ if (profile === "group_compact") {
87
+ return {
88
+ text: [
89
+ "Execution profile: GROUP_COMPACT.",
90
+ "Keep responses concise and context usage focused on the active group thread.",
91
+ ].join(" "),
92
+ values: {
93
+ executionProfile: "group_compact",
94
+ compactContext: true,
95
+ },
96
+ data: {
97
+ profile: "group_compact",
98
+ },
99
+ };
100
+ }
101
+
102
+ return {
103
+ values: {
104
+ executionProfile: "default_full",
105
+ compactContext: false,
106
+ },
107
+ data: {
108
+ profile: "default_full",
109
+ },
110
+ };
111
+ },
112
+ };
113
+ }
@@ -0,0 +1,135 @@
1
+ import {
2
+ ChannelType,
3
+ type IAgentRuntime,
4
+ type Memory,
5
+ type Provider,
6
+ type State,
7
+ } from "@elizaos/core";
8
+ import { COMPONENT_CATALOG } from "../shared/ui-catalog-prompt";
9
+
10
+ // Core components to describe in detail — subset to keep context short.
11
+ const DETAIL_COMPONENTS = new Set([
12
+ "Card",
13
+ "Stack",
14
+ "Grid",
15
+ "Text",
16
+ "Button",
17
+ "Input",
18
+ "Select",
19
+ "Textarea",
20
+ "Badge",
21
+ "Metric",
22
+ "Separator",
23
+ "Progress",
24
+ "Table",
25
+ "Alert",
26
+ "Tabs",
27
+ ]);
28
+
29
+ export const uiCatalogProvider: Provider = {
30
+ name: "uiCatalog",
31
+ dynamic: true,
32
+ relevanceKeywords: [
33
+ "plugin",
34
+ "plugins",
35
+ "install",
36
+ "setup",
37
+ "set up",
38
+ "configure",
39
+ "config",
40
+ "enable",
41
+ "disable",
42
+ "activate",
43
+ "connect",
44
+ "integration",
45
+ "help me",
46
+ "how do i",
47
+ "how to",
48
+ "show me",
49
+ "dashboard",
50
+ "form",
51
+ "table",
52
+ "chart",
53
+ "metrics",
54
+ "ui",
55
+ "interface",
56
+ "polymarket",
57
+ "discord",
58
+ "openai",
59
+ "anthropic",
60
+ "telegram",
61
+ "twitch",
62
+ "youtube",
63
+ "twitter",
64
+ "api key",
65
+ "credentials",
66
+ "secret",
67
+ ],
68
+ get: async (_runtime: IAgentRuntime, message: Memory, _state: State) => {
69
+ const channelType = message.content?.channelType;
70
+ const isAllowedChannel =
71
+ channelType === ChannelType.DM ||
72
+ channelType === ChannelType.API ||
73
+ !channelType;
74
+ if (!isAllowedChannel) {
75
+ return { text: "" };
76
+ }
77
+
78
+ // Build component summary — detailed for core set, brief for the rest.
79
+ const componentLines: string[] = [];
80
+ for (const [name, meta] of Object.entries(COMPONENT_CATALOG)) {
81
+ if (DETAIL_COMPONENTS.has(name)) {
82
+ const props = Object.entries(meta.props)
83
+ .map(([k, p]) => `${k}: ${p.type}${p.required ? " (required)" : ""}`)
84
+ .join(", ");
85
+ componentLines.push(
86
+ `- **${name}**: ${meta.description} [props: ${props}]`,
87
+ );
88
+ } else {
89
+ componentLines.push(`- ${name}: ${meta.description}`);
90
+ }
91
+ }
92
+
93
+ return {
94
+ text: `## Rich UI Output — you can render interactive components in your replies
95
+
96
+ ### Method 1 — Inline JSONL patches (for custom dashboards, forms, visualisations)
97
+ Emit RFC 6902 JSON patch lines INLINE in your response (no code fences, no markdown):
98
+ {"op":"add","path":"/root","value":"card-1"}
99
+ {"op":"add","path":"/elements/card-1","value":{"type":"Card","props":{"title":"Plugin Setup"},"children":["body-1"]}}
100
+ {"op":"add","path":"/elements/body-1","value":{"type":"Text","props":{"text":"Fill in the details below."},"children":[]}}
101
+
102
+ Rules:
103
+ - Always emit /root first, then /elements/<id>, then /state/<key>
104
+ - Each patch must be on its own line, valid JSON, no trailing text on that line
105
+ - Element IDs: unique kebab-case strings
106
+ - state binding: set statePath prop on Input/Select/Textarea to a dot-path key
107
+ - data binding in props: "$data.key.path" resolves from state at render time
108
+ - Use this method when the user needs a form, table, metrics view, or custom UI
109
+
110
+ ### Method 2 — [CONFIG:pluginId] marker (for plugin configuration forms)
111
+ Include EXACTLY this marker whenever a plugin is mentioned in any configuration, setup, or status context:
112
+ [CONFIG:pluginId]
113
+ Replace pluginId with the plugin's short ID (e.g. [CONFIG:polymarket], [CONFIG:discord], [CONFIG:anthropic], [CONFIG:openai], [CONFIG:twitch]).
114
+ The UI will auto-generate a full configuration form from the plugin's parameter schema.
115
+
116
+ **ALWAYS use [CONFIG:pluginId] when:**
117
+ - User mentions a plugin by name ("discord", "polymarket", "openai", etc.)
118
+ - User asks to show, view, check, set up, configure, enable, install, or activate a plugin
119
+ - You mention that a plugin needs credentials, secrets, or setup steps
120
+ - User asks "what plugins", "show me plugins", "check plugin status"
121
+ - You would otherwise say "you need to configure X" or "set up X first"
122
+
123
+ Do NOT describe configuration steps in text — just emit [CONFIG:pluginId] and let the UI handle it.
124
+
125
+ ### When to use rich UI
126
+ - Any plugin mentioned by name → Method 2 ([CONFIG:pluginId]) — always
127
+ - Forms, data entry, settings panels → Method 1 (JSONL patches with Input/Select)
128
+ - Tables, metrics, dashboards → Method 1 (Table/Metric/ProgressBar)
129
+ - Simple factual answers with no plugin/form involved → plain text only
130
+
131
+ ### Available components (${Object.keys(COMPONENT_CATALOG).length} total)
132
+ ${componentLines.join("\n")}`,
133
+ };
134
+ },
135
+ };