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,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 };
|