@elizaos/agent 2.0.0-alpha.165 → 2.0.0-alpha.170

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.
@@ -1 +1 @@
1
- {"version":3,"file":"app-state.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/lifeops/app-state.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACxD,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC7D,CAAC;AAMF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,OAAO,CAAC,eAAe,CAAC,CAkB1B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,eAAe,CAAC,CAc1B"}
1
+ {"version":3,"file":"app-state.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/lifeops/app-state.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,KAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACxD,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;CAC7D,CAAC;AAMF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,gBAAgB,GAAG,IAAI,GAC/B,OAAO,CAAC,eAAe,CAAC,CAqB1B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,eAAe,CAAC,CAc1B"}
@@ -1,7 +1,7 @@
1
1
  import { logger } from "@elizaos/core";
2
2
  const LIFEOPS_APP_STATE_CACHE_KEY = "eliza:lifeops-app-state";
3
3
  const DEFAULT_LIFEOPS_APP_STATE = {
4
- enabled: false,
4
+ enabled: true,
5
5
  };
6
6
  export async function loadLifeOpsAppState(runtime) {
7
7
  if (!runtime) {
@@ -9,8 +9,11 @@ export async function loadLifeOpsAppState(runtime) {
9
9
  }
10
10
  try {
11
11
  const cached = await runtime.getCache(LIFEOPS_APP_STATE_CACHE_KEY);
12
+ if (cached == null) {
13
+ return DEFAULT_LIFEOPS_APP_STATE;
14
+ }
12
15
  return {
13
- enabled: cached?.enabled === true,
16
+ enabled: cached.enabled !== false,
14
17
  };
15
18
  }
16
19
  catch (error) {
@@ -1,13 +1,19 @@
1
- import type { IAgentRuntime, Memory } from "@elizaos/core";
2
- type RoleName = "OWNER" | "ADMIN" | "USER" | "GUEST";
3
- export type RoleCheckResult = {
4
- entityId: string;
5
- role: RoleName;
6
- isOwner: boolean;
7
- isAdmin: boolean;
8
- canManageRoles: boolean;
1
+ /**
2
+ * Selfcontrol role checking delegates to the core @elizaos/core roles module.
3
+ *
4
+ * Previously this was a full reimplementation that diverged from core,
5
+ * missing world-resolution fallbacks and silently swallowing errors.
6
+ * Now it's a thin adapter that re-exports the core checkSenderRole
7
+ * with the extra `hasPrivateAccess` field for backward compatibility.
8
+ *
9
+ * When the core module returns null (no world found for the message),
10
+ * we fall back to checking whether the sender matches the configured
11
+ * admin entity ID. This covers dashboard/terminal sessions where the
12
+ * world may not exist yet or the room has no worldId.
13
+ */
14
+ import { type IAgentRuntime, type Memory, type RoleCheckResult as CoreRoleCheckResult } from "@elizaos/core";
15
+ export type RoleCheckResult = CoreRoleCheckResult & {
9
16
  hasPrivateAccess: boolean;
10
17
  };
11
18
  export declare function checkSenderRole(runtime: IAgentRuntime, message: Memory): Promise<RoleCheckResult | null>;
12
- export {};
13
19
  //# sourceMappingURL=roles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/selfcontrol/roles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK3D,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAwBrD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAgRF,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAuCjC"}
1
+ {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../../../../../apps/app-lifeops/src/selfcontrol/roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,eAAe,IAAI,mBAAmB,EAE5C,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAiCjC"}
@@ -1,228 +1,41 @@
1
- const CANONICAL_OWNER_SETTING_KEY = "ELIZA_ADMIN_ENTITY_ID";
2
- const IDENTITY_LINK_TAG = "identity_link";
3
- function normalizeRole(role) {
4
- if (typeof role !== "string") {
5
- return "GUEST";
6
- }
7
- switch (role.toUpperCase()) {
8
- case "OWNER":
9
- return "OWNER";
10
- case "ADMIN":
11
- return "ADMIN";
12
- case "USER":
13
- return "USER";
14
- default:
15
- return "GUEST";
16
- }
17
- }
18
- function resolveCanonicalOwnerId(runtime, metadata) {
19
- if (typeof runtime.getSetting === "function") {
20
- const configured = runtime.getSetting(CANONICAL_OWNER_SETTING_KEY);
21
- if (typeof configured === "string" && configured.trim().length > 0) {
22
- return configured.trim();
23
- }
24
- }
25
- return metadata?.ownership?.ownerId ?? null;
26
- }
27
- async function resolveWorldForMessage(runtime, message) {
28
- const room = await runtime.getRoom(message.roomId);
29
- if (!room?.worldId) {
30
- return null;
31
- }
32
- const world = await runtime.getWorld(room.worldId);
33
- if (!world) {
34
- return null;
35
- }
36
- return (world.metadata ?? {});
37
- }
38
- function normalizeIdentityValue(value) {
39
- if (typeof value === "number" || typeof value === "bigint") {
40
- return String(value);
41
- }
42
- if (typeof value !== "string") {
43
- return null;
44
- }
45
- const normalized = value.trim();
46
- if (normalized.length === 0) {
47
- return null;
48
- }
49
- return normalized.toLowerCase();
50
- }
51
- function collectConnectorIdentities(metadata) {
52
- if (!metadata) {
53
- return [];
54
- }
55
- const identities = [];
56
- for (const [connector, rawConnectorData] of Object.entries(metadata)) {
57
- if (!rawConnectorData || typeof rawConnectorData !== "object") {
58
- continue;
59
- }
60
- const connectorData = rawConnectorData;
61
- const values = new Set();
62
- for (const field of ["id", "userId", "user_id", "fromId", "username"]) {
63
- const normalized = normalizeIdentityValue(connectorData[field]);
64
- if (normalized) {
65
- values.add(normalized);
66
- }
67
- }
68
- if (values.size > 0) {
69
- identities.push({ connector, values });
70
- }
71
- }
72
- return identities;
73
- }
74
- function extractLiveMessageMetadata(message) {
75
- const metadata = message.content?.metadata;
76
- if (metadata && typeof metadata === "object" && !Array.isArray(metadata)) {
77
- return metadata;
78
- }
79
- return undefined;
80
- }
81
- function extractMessageConnectorMetadata(message) {
82
- const metadata = message
83
- .metadata;
84
- if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
85
- return undefined;
86
- }
87
- const source = typeof message.content?.source === "string"
88
- ? message.content.source
89
- : undefined;
90
- const result = {};
91
- const fromId = metadata.fromId ??
92
- metadata.discordUserId ??
93
- metadata.telegramUserId ??
94
- metadata.userId ??
95
- metadata.id;
96
- const username = metadata.username ?? metadata.telegramUsername;
97
- if (source === "discord" ||
98
- typeof metadata.discordServerId === "string" ||
99
- typeof metadata.discordChannelId === "string") {
100
- result.discord = {
101
- userId: fromId,
102
- username,
103
- };
104
- }
105
- if (source === "telegram" ||
106
- typeof metadata.telegramChatId === "string" ||
107
- typeof metadata.telegramUserId === "string") {
108
- result.telegram = {
109
- id: fromId,
110
- username,
1
+ /**
2
+ * Selfcontrol role checking — delegates to the core @elizaos/core roles module.
3
+ *
4
+ * Previously this was a full reimplementation that diverged from core,
5
+ * missing world-resolution fallbacks and silently swallowing errors.
6
+ * Now it's a thin adapter that re-exports the core checkSenderRole
7
+ * with the extra `hasPrivateAccess` field for backward compatibility.
8
+ *
9
+ * When the core module returns null (no world found for the message),
10
+ * we fall back to checking whether the sender matches the configured
11
+ * admin entity ID. This covers dashboard/terminal sessions where the
12
+ * world may not exist yet or the room has no worldId.
13
+ */
14
+ import { checkSenderRole as coreCheckSenderRole, logger, resolveCanonicalOwnerId, } from "@elizaos/core";
15
+ export async function checkSenderRole(runtime, message) {
16
+ const result = await coreCheckSenderRole(runtime, message);
17
+ if (result) {
18
+ return {
19
+ ...result,
20
+ hasPrivateAccess: result.isAdmin,
111
21
  };
112
22
  }
113
- return Object.keys(result).length > 0 ? result : undefined;
114
- }
115
- function sharesConnectorIdentity(left, right) {
116
- if (!left || !right) {
117
- return false;
118
- }
119
- const leftIdentities = collectConnectorIdentities(left);
120
- const rightByConnector = new Map(collectConnectorIdentities(right).map((identity) => [
121
- identity.connector,
122
- identity.values,
123
- ]));
124
- for (const identity of leftIdentities) {
125
- const otherValues = rightByConnector.get(identity.connector);
126
- if (!otherValues) {
127
- continue;
128
- }
129
- for (const value of identity.values) {
130
- if (otherValues.has(value)) {
131
- return true;
132
- }
133
- }
134
- }
135
- return false;
136
- }
137
- async function getEntity(runtime, entityId) {
138
- if (typeof runtime.getEntityById !== "function") {
139
- return null;
140
- }
141
- const entity = await runtime.getEntityById(entityId);
142
- return entity ? entity : null;
143
- }
144
- function isConfirmedIdentityLink(relationship, senderEntityId, canonicalOwnerId) {
145
- if (!Array.isArray(relationship.tags)) {
146
- return false;
147
- }
148
- if (!relationship.tags.includes(IDENTITY_LINK_TAG)) {
149
- return false;
150
- }
151
- const status = normalizeIdentityValue(relationship.metadata?.status);
152
- if (status !== "confirmed") {
153
- return false;
154
- }
155
- return ((relationship.sourceEntityId === senderEntityId &&
156
- relationship.targetEntityId === canonicalOwnerId) ||
157
- (relationship.sourceEntityId === canonicalOwnerId &&
158
- relationship.targetEntityId === senderEntityId));
159
- }
160
- async function senderMatchesCanonicalOwner(runtime, message, canonicalOwnerId) {
23
+ // Fallback: no world found for this message's room. This happens for
24
+ // dashboard/terminal sessions where the world may not be set up yet.
25
+ // If the sender matches the configured canonical owner, grant OWNER.
26
+ const canonicalOwnerId = resolveCanonicalOwnerId(runtime);
161
27
  const senderEntityId = String(message.entityId);
162
- if (senderEntityId === canonicalOwnerId) {
163
- return true;
164
- }
165
- const ownerEntity = await getEntity(runtime, canonicalOwnerId);
166
- const ownerMetadata = ownerEntity?.metadata && typeof ownerEntity.metadata === "object"
167
- ? ownerEntity.metadata
168
- : undefined;
169
- if (ownerMetadata) {
170
- const senderEntity = await getEntity(runtime, senderEntityId);
171
- const senderMetadataCandidates = [
172
- extractMessageConnectorMetadata(message),
173
- extractLiveMessageMetadata(message),
174
- senderEntity?.metadata && typeof senderEntity.metadata === "object"
175
- ? senderEntity.metadata
176
- : undefined,
177
- ];
178
- for (const senderMetadata of senderMetadataCandidates) {
179
- if (sharesConnectorIdentity(senderMetadata, ownerMetadata)) {
180
- return true;
181
- }
182
- }
183
- }
184
- if (typeof runtime.getRelationships !== "function") {
185
- return false;
186
- }
187
- const relationships = (await runtime.getRelationships({
188
- entityIds: [senderEntityId],
189
- tags: [IDENTITY_LINK_TAG],
190
- }));
191
- return relationships.some((relationship) => isConfirmedIdentityLink(relationship, senderEntityId, canonicalOwnerId));
192
- }
193
- export async function checkSenderRole(runtime, message) {
194
- try {
195
- const metadata = await resolveWorldForMessage(runtime, message);
196
- if (!metadata) {
197
- return null;
198
- }
199
- const senderEntityId = String(message.entityId);
200
- const canonicalOwnerId = resolveCanonicalOwnerId(runtime, metadata);
201
- let role;
202
- if (canonicalOwnerId &&
203
- (await senderMatchesCanonicalOwner(runtime, message, canonicalOwnerId))) {
204
- role = "OWNER";
205
- }
206
- else {
207
- const storedRole = normalizeRole(metadata.roles?.[senderEntityId]);
208
- role =
209
- canonicalOwnerId &&
210
- storedRole === "OWNER" &&
211
- senderEntityId !== canonicalOwnerId
212
- ? "GUEST"
213
- : storedRole;
214
- }
215
- const isAdmin = role === "OWNER" || role === "ADMIN";
28
+ if (canonicalOwnerId && senderEntityId === canonicalOwnerId) {
29
+ logger.debug("[selfcontrol] No world for message room, but sender matches configured admin entity — granting OWNER");
216
30
  return {
217
31
  entityId: senderEntityId,
218
- role,
219
- isOwner: role === "OWNER",
220
- isAdmin,
221
- canManageRoles: isAdmin,
222
- hasPrivateAccess: isAdmin,
32
+ role: "OWNER",
33
+ isOwner: true,
34
+ isAdmin: true,
35
+ canManageRoles: true,
36
+ hasPrivateAccess: true,
223
37
  };
224
38
  }
225
- catch {
226
- return null;
227
- }
39
+ logger.debug("[selfcontrol] checkSenderRole returned null — no world found and sender does not match configured admin entity");
40
+ return null;
228
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/agent",
3
- "version": "2.0.0-alpha.165",
3
+ "version": "2.0.0-alpha.170",
4
4
  "description": "Standalone elizaOS-based agent and backend server package.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -451,15 +451,15 @@
451
451
  "@elizaos/app-steward": "^0.0.0",
452
452
  "@elizaos/app-task-coordinator": "^0.0.0",
453
453
  "@elizaos/app-training": "^0.0.1",
454
- "@elizaos/core": "^2.0.0-alpha.165",
454
+ "@elizaos/core": "^2.0.0-alpha.170",
455
455
  "@elizaos/plugin-agent-orchestrator": "^0.6.2-alpha.0",
456
456
  "@elizaos/plugin-ollama": "^2.0.0-alpha.14",
457
457
  "@elizaos/plugin-pdf": "^2.0.0-alpha.18",
458
458
  "@elizaos/plugin-solana": "1.2.6",
459
459
  "@elizaos/plugin-sql": "^2.0.0-alpha.19",
460
460
  "@elizaos/plugin-wechat": "^0.1.0",
461
- "@elizaos/shared": "^2.0.0-alpha.165",
462
- "@elizaos/skills": "^2.0.0-alpha.165",
461
+ "@elizaos/shared": "^2.0.0-alpha.170",
462
+ "@elizaos/skills": "^2.0.0-alpha.170",
463
463
  "@hapi/boom": "^10.0.1",
464
464
  "@noble/curves": "^2.0.1",
465
465
  "@whiskeysockets/baileys": "7.0.0-rc.9",
@@ -1 +1 @@
1
- {"version":3,"file":"core-plugins.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/core-plugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAA2B,CAAC;AAE9E,iGAAiG;AACjG,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAgBzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EA4BlD,CAAC"}
1
+ {"version":3,"file":"core-plugins.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/core-plugins.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAA2B,CAAC;AAE9E,iGAAiG;AACjG,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAiBzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EA4BlD,CAAC"}
@@ -20,6 +20,7 @@ export const CORE_PLUGINS = [
20
20
  "@elizaos/plugin-shell", // shell command execution
21
21
  "@elizaos/plugin-agent-skills", // skill execution and marketplace runtime
22
22
  "@elizaos/plugin-commands", // slash command handling (skills auto-register as /commands)
23
+ "@elizaos/app-lifeops", // LifeOps: personal ops — tasks, goals, calendar, inbox, browser companions, website blocking
23
24
  // Built-in runtime capabilities (no longer external plugins):
24
25
  // - experience, form, clipboard, personality: advanced capabilities (advancedCapabilities: true)
25
26
  // - trust: core capability (enableTrust: true)
@@ -34,7 +35,7 @@ export const CORE_PLUGINS = [
34
35
  export const OPTIONAL_CORE_PLUGINS = [
35
36
  // plugin-manager, secrets-manager, trust: now built-in core capabilities
36
37
  // Enable via character settings: ENABLE_PLUGIN_MANAGER, ENABLE_SECRETS_MANAGER, ENABLE_TRUST
37
- "@elizaos/app-lifeops", // LifeOps: browser companions + hosts-file website blocker
38
+ // "@elizaos/app-lifeops" moved to CORE_PLUGINS above
38
39
  "@elizaos/plugin-pdf", // PDF processing (published bundle broken in alpha.15)
39
40
  "@elizaos/plugin-cua", // CUA computer-use agent (cloud sandbox automation)
40
41
  "@elizaos/plugin-obsidian", // Obsidian vault CLI integration