@elizaos/core 2.0.0-alpha.53 → 2.0.0-alpha.55

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 (44) hide show
  1. package/dist/advanced-capabilities/actions/addContact.d.ts.map +1 -1
  2. package/dist/advanced-capabilities/actions/removeContact.d.ts.map +1 -1
  3. package/dist/advanced-capabilities/actions/scheduleFollowUp.d.ts.map +1 -1
  4. package/dist/advanced-capabilities/actions/searchContacts.d.ts.map +1 -1
  5. package/dist/advanced-capabilities/actions/updateContact.d.ts.map +1 -1
  6. package/dist/advanced-capabilities/evaluators/relationshipExtraction.d.ts.map +1 -1
  7. package/dist/advanced-capabilities/providers/contacts.d.ts.map +1 -1
  8. package/dist/advanced-capabilities/providers/followUps.d.ts.map +1 -1
  9. package/dist/advanced-memory/evaluators/long-term-extraction.d.ts.map +1 -1
  10. package/dist/advanced-memory/evaluators/summarization.d.ts.map +1 -1
  11. package/dist/autonomy/routes.d.ts.map +1 -1
  12. package/dist/basic-capabilities/index.d.ts.map +1 -1
  13. package/dist/browser/index.browser.js +372 -406
  14. package/dist/browser/index.browser.js.map +27 -30
  15. package/dist/connection.d.ts +44 -0
  16. package/dist/connection.d.ts.map +1 -0
  17. package/dist/edge/index.d.ts +2 -0
  18. package/dist/edge/index.edge.js +118444 -0
  19. package/dist/edge/index.edge.js.map +791 -0
  20. package/dist/index.node.d.ts +3 -0
  21. package/dist/index.node.d.ts.map +1 -1
  22. package/dist/logger.d.ts.map +1 -1
  23. package/dist/node/index.node.js +945 -1876
  24. package/dist/node/index.node.js.map +34 -35
  25. package/dist/packages/typescript/tsconfig.tsbuildinfo +1 -1
  26. package/dist/provisioning.d.ts +54 -0
  27. package/dist/provisioning.d.ts.map +1 -0
  28. package/dist/runtime-composition.d.ts +117 -0
  29. package/dist/runtime-composition.d.ts.map +1 -0
  30. package/dist/runtime.d.ts +94 -93
  31. package/dist/runtime.d.ts.map +1 -1
  32. package/dist/services/pairing-integration.d.ts +1 -1
  33. package/dist/services/pairing-integration.d.ts.map +1 -1
  34. package/dist/services/pairing-migration.d.ts.map +1 -1
  35. package/dist/services/task.d.ts +6 -3
  36. package/dist/services/task.d.ts.map +1 -1
  37. package/dist/settings.d.ts.map +1 -1
  38. package/dist/types/plugin.d.ts +14 -1
  39. package/dist/types/plugin.d.ts.map +1 -1
  40. package/dist/types/runtime.d.ts +12 -6
  41. package/dist/types/runtime.d.ts.map +1 -1
  42. package/dist/types/service.d.ts +4 -3
  43. package/dist/types/service.d.ts.map +1 -1
  44. package/package.json +4 -4
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Agent provisioning: migrations, agent/entity/room setup, embedding dimension.
3
+ * Runs once at deploy/daemon boot; not part of runtime.initialize().
4
+ * Export from node entry point only (not browser/edge).
5
+ *
6
+ * WHY this module exists:
7
+ * - Keeps the runtime a lean request handler; heavy one-time setup lives here.
8
+ * - Edge and ephemeral runtimes can skip provisioning entirely (they don't import this).
9
+ * - Daemon entry points call provisionAgent() once after initialize().
10
+ */
11
+ import type { Character, UUID } from "./types";
12
+ import type { IDatabaseAdapter } from "./types/database";
13
+ import type { IAgentRuntime } from "./types/runtime";
14
+ export interface ProvisionAgentOptions {
15
+ /** Run plugin schema migrations (DDL). Default true for daemon. */
16
+ runMigrations?: boolean;
17
+ }
18
+ /**
19
+ * Run plugin migrations (DDL) using the runtime's adapter and registered plugins.
20
+ * WHY standalone: Migrations are a one-time bootstrap step; not part of initialize()
21
+ * so ephemeral/edge runtimes never run them. process.env guards allow safe use in Node only.
22
+ */
23
+ export declare function runPluginMigrations(runtime: IAgentRuntime): Promise<void>;
24
+ /**
25
+ * Ensure agent row exists, then entity, self-room, and self-participant.
26
+ * Uses batch adapter APIs (getAgentsByIds, createEntities, getRoomsByIds, etc.).
27
+ * WHY: Agent must exist before the runtime can store memories/tasks; self-room and
28
+ * participant are required for core conversation flow.
29
+ */
30
+ export declare function ensureAgentInfrastructure(runtime: IAgentRuntime): Promise<void>;
31
+ /**
32
+ * Set embedding dimension on the adapter from config (no LLM call).
33
+ * Uses EMBEDDING_DIMENSION setting if set; otherwise skips.
34
+ * WHY no LLM: Avoids a model call at boot; set EMBEDDING_DIMENSION in character
35
+ * settings when using this path. If unset, embedding search may fail until dimension is set.
36
+ */
37
+ export declare function ensureEmbeddingDimension(runtime: IAgentRuntime): Promise<void>;
38
+ /**
39
+ * Orchestrator: run migrations (optional), ensure agent/entity/room/participant, set embedding dimension.
40
+ * Call after runtime.initialize() in daemon mode.
41
+ * WHY separate from initialize(): Ephemeral and edge runtimes do not call this;
42
+ * only long-lived daemons run it once at boot.
43
+ */
44
+ export declare function provisionAgent(runtime: IAgentRuntime, options?: ProvisionAgentOptions): Promise<void>;
45
+ /**
46
+ * Read agent from DB and merge settings/secrets into the given character.
47
+ * Returns a new Character; does not mutate the input.
48
+ * If no agent exists in DB, returns the character unchanged.
49
+ * Call before constructing the runtime so the runtime gets merged settings.
50
+ * WHY before runtime: The runtime constructor does not touch the DB; the host
51
+ * loads DB-backed config once and passes the merged character in.
52
+ */
53
+ export declare function mergeDbSettings(character: Character, adapter: IDatabaseAdapter, agentId: UUID): Promise<Character>;
54
+ //# sourceMappingURL=provisioning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provisioning.d.ts","sourceRoot":"","sources":["../src/provisioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAS,SAAS,EAAa,IAAI,EAAE,MAAM,SAAS,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,MAAM,WAAW,qBAAqB;IACrC,mEAAmE;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CA2Df;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAyDf;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,aAAa,EACtB,OAAO,GAAE,qBAA0B,GACjC,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACpC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,IAAI,GACX,OAAO,CAAC,SAAS,CAAC,CAyDpB"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Runtime composition: building blocks for creating elizaOS runtimes.
3
+ *
4
+ * This module provides a small, composable API so hosts (daemon, cloud, serverless,
5
+ * milaidy, etc.) can set up runtimes without duplicating adapter creation, plugin
6
+ * resolution, or settings merge logic.
7
+ *
8
+ * **WHY a composition layer:** Different hosts need different flows (e.g. cloud may
9
+ * use its own adapter pool and skip createRuntimes), but they share the need to
10
+ * load characters, resolve plugins, create adapters before the runtime, and merge
11
+ * DB-backed settings. This module composes existing helpers so each host can use
12
+ * the pieces it needs.
13
+ *
14
+ * **Exports:**
15
+ * - loadCharacters(sources) – load from file paths or inline objects; returns Character[].
16
+ * - getBootstrapSettings(character) – flatten character + env for adapter factories (bootstrap only).
17
+ * - mergeSettingsInto(character, agentRecord) – pure merge of DB agent into character (for custom pipelines).
18
+ * - createRuntimes(characters, options?) – full pipeline: resolve plugins → adapters → merge DB settings → create/init runtimes; optional provision.
19
+ *
20
+ * **Settings divide:** Adapter factories receive only *bootstrap* settings (character + env).
21
+ * Runtime settings from the DB are merged *after* the adapter is created and used when
22
+ * constructing the runtime. WHY: You cannot load settings from the DB until the adapter
23
+ * is connected; bootstrap settings (e.g. POSTGRES_URL, PGLITE_DATA_DIR) are what you
24
+ * need to create the adapter in the first place.
25
+ */
26
+ import type { CharacterInput } from "./character";
27
+ import type { Character, IAgentRuntime, IDatabaseAdapter } from "./types";
28
+ import type { Plugin } from "./types/plugin";
29
+ /**
30
+ * Flatten character.settings, character.secrets, and env into a single Record<string, string>.
31
+ * Used when calling adapter factories (Plugin.adapter(agentId, settings)).
32
+ *
33
+ * **WHY bootstrap-only:** Adapter factories run *before* the database is connected. They
34
+ * cannot read runtime settings from the DB. Only settings available from character config
35
+ * and process.env (e.g. POSTGRES_URL, PGLITE_DATA_DIR, MONGODB_URI) are valid here. Runtime
36
+ * settings (API keys, model prefs, etc.) are merged later from the DB via mergeSettingsInto.
37
+ *
38
+ * **Merge order:** env first, then character.settings (excluding nested secrets object),
39
+ * then character.settings.secrets, then character.secrets. Later sources override earlier
40
+ * (character overrides env). WHY: Allows env defaults while letting character config override.
41
+ *
42
+ * @param character - Character to read settings and secrets from
43
+ * @param env - Environment record (defaults to process.env)
44
+ * @returns String-only record suitable for adapter factories
45
+ */
46
+ export declare function getBootstrapSettings(character: Character, env?: NodeJS.ProcessEnv): Record<string, string>;
47
+ /**
48
+ * Minimal shape of an agent record as returned from the database (e.g. getAgentsByIds).
49
+ * Used by mergeSettingsInto so callers can pass either a full Agent or a subset with
50
+ * settings/secrets. WHY loose type: Custom hosts (e.g. cloud) may have their own
51
+ * agent-like structures; this keeps the merge logic reusable.
52
+ */
53
+ export interface AgentRecordForMerge {
54
+ settings?: Record<string, unknown>;
55
+ secrets?: Record<string, unknown>;
56
+ }
57
+ /**
58
+ * Merge DB-backed agent settings and secrets into a character (pure, no DB call).
59
+ * Same merge order as mergeDbSettings in provisioning.ts: DB base, character overrides.
60
+ *
61
+ * **WHY exported:** Custom hosts (e.g. cloud with its own adapter pool and caching) may
62
+ * load agent records themselves and need to apply the same merge semantics without
63
+ * calling mergeDbSettings (which takes an adapter and does the DB fetch). This function
64
+ * is the pure merge step only.
65
+ *
66
+ * @param character - Character to merge into (not mutated)
67
+ * @param agentRecord - Agent record from DB (e.g. getAgentsByIds result item), or null
68
+ * @returns New character with merged settings and secrets
69
+ */
70
+ export declare function mergeSettingsInto(character: Character, agentRecord: AgentRecordForMerge | null): Character;
71
+ /**
72
+ * Load characters from file paths and/or inline character objects.
73
+ * Reuses loadCharacterFile, parseCharacter, importSecretsFromEnv, ensureEncryptionSalt,
74
+ * syncCharacterSecretsToEnv so behavior matches the rest of the codebase.
75
+ *
76
+ * **WHY accept mixed sources:** Daemons often load from files; programmatic hosts (e.g. cloud,
77
+ * serverless) may build character config in code. One API supports both.
78
+ *
79
+ * @param sources - File paths (string) or CharacterInput objects
80
+ * @returns Validated Character[] (empty array if sources is empty)
81
+ * @throws If a file path fails to load or an object fails validation (message includes path/details)
82
+ */
83
+ export declare function loadCharacters(sources: (string | CharacterInput)[]): Promise<Character[]>;
84
+ /** Options for createRuntimes. */
85
+ export interface CreateRuntimesOptions {
86
+ /** Override: use this adapter for all characters (skip adapter discovery). WHY: Cloud/custom hosts may manage their own adapter pool. */
87
+ adapter?: IDatabaseAdapter;
88
+ /** Extra plugins to include for all characters (merged with character.plugins). WHY: Hosts like milaidy add their own plugin without putting it in every character file. */
89
+ sharedPlugins?: Plugin[];
90
+ /** Run provisioning after init: migrations once per unique adapter, then ensureAgentInfrastructure + ensureEmbeddingDimension per runtime. Default false. WHY: Daemons need it once at boot; serverless/ephemeral usually skip. */
91
+ provision?: boolean;
92
+ /** Log level for created runtimes. */
93
+ logLevel?: "trace" | "debug" | "info" | "warn" | "error" | "fatal";
94
+ /** Extra settings applied to each runtime (e.g. MODEL_PROVIDER override). */
95
+ settings?: Record<string, string | boolean | number>;
96
+ }
97
+ /**
98
+ * Create runtimes from characters: resolve plugins once (batch), create adapters from
99
+ * plugin adapter factory, init adapters (deduped), batch merge DB settings per unique
100
+ * adapter, create AgentRuntime instances, initialize them, optionally provision.
101
+ *
102
+ * **WHY batch where possible:** Resolving plugins once for all characters avoids duplicate
103
+ * work and keeps dependency order consistent. getAgentsByIds is called once per unique
104
+ * adapter with all agent IDs for that adapter (not once per character). WHY: Fewer DB
105
+ * round-trips when multiple characters share the same DB.
106
+ *
107
+ * **Adapter discovery:** The first resolved plugin that defines an adapter factory
108
+ * (Plugin.adapter) is used. If options.adapter is set, that overrides and is used for
109
+ * all characters. WHY: One adapter per character is the common case; shared override
110
+ * supports custom pooling.
111
+ *
112
+ * @param characters - Validated characters (e.g. from loadCharacters)
113
+ * @param options - Optional adapter override, sharedPlugins, provision, logLevel, settings
114
+ * @returns Initialized IAgentRuntime[] (empty if characters is empty)
115
+ */
116
+ export declare function createRuntimes(characters: Character[], options?: CreateRuntimesOptions): Promise<IAgentRuntime[]>;
117
+ //# sourceMappingURL=runtime-composition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-composition.d.ts","sourceRoot":"","sources":["../src/runtime-composition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAWlD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQ7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CACnC,SAAS,EAAE,SAAS,EACpB,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0CxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAChC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,mBAAmB,GAAG,IAAI,GACrC,SAAS,CAuDX;AAwCD;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,GAClC,OAAO,CAAC,SAAS,EAAE,CAAC,CAkBtB;AAED,kCAAkC;AAClC,MAAM,WAAW,qBAAqB;IACrC,yIAAyI;IACzI,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,4KAA4K;IAC5K,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,mOAAmO;IACnO,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACnE,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CACnC,UAAU,EAAE,SAAS,EAAE,EACvB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,aAAa,EAAE,CAAC,CA8H1B"}
package/dist/runtime.d.ts CHANGED
@@ -2,7 +2,6 @@ import { type Action, type ActionResult, type Agent, ChannelType, type Character
2
2
  import type { IMessageService } from "./types/message-service";
3
3
  import type { RetryBackoffConfig, SchemaRow, StreamEvent } from "./types/state";
4
4
  import type { ToolPolicyConfig, ToolProfileId } from "./types/tools";
5
- import { PromptBatcher } from "./utils/prompt-batcher";
6
5
  export declare class Semaphore {
7
6
  private permits;
8
7
  private waiting;
@@ -33,17 +32,16 @@ export declare class AgentRuntime implements IAgentRuntime {
33
32
  private characterPlugins;
34
33
  private capabilityOptions;
35
34
  private actionPlanningOption?;
36
- private cachedEmbeddingDimension?;
37
35
  private llmModeOption?;
38
36
  private checkShouldRespondOption?;
39
37
  private isAnonymousCharacter;
40
38
  logger: import("./logger").Logger;
41
39
  enableAutonomy: boolean;
42
- /** When true, TaskService does not start a timer; host drives via runDueTasks(). WHY: no long-lived process in serverless. */
43
- serverless: boolean;
44
40
  private settings;
45
41
  private servicePromiseHandlers;
46
42
  private servicePromises;
43
+ /** In-flight service start promises; dedupes concurrent getService() for the same type. */
44
+ private startingServices;
47
45
  private serviceRegistrationStatus;
48
46
  initPromise: Promise<void>;
49
47
  private initResolver;
@@ -52,14 +50,17 @@ export declare class AgentRuntime implements IAgentRuntime {
52
50
  private currentActionContext?;
53
51
  private maxWorkingMemoryEntries;
54
52
  messageService: IMessageService | null;
55
- promptBatcher: PromptBatcher;
56
- constructor(opts?: {
53
+ companionUrl?: string;
54
+ /** Set when stop() has been called; prevents new service starts and use-after-stop. */
55
+ private stopped;
56
+ constructor(opts: {
57
57
  conversationLength?: number;
58
58
  agentId?: UUID;
59
59
  /** Optional character configuration. If not provided, an anonymous character is created. */
60
60
  character?: Character;
61
61
  plugins?: Plugin[];
62
62
  fetch?: typeof fetch;
63
+ /** Database adapter. Use InMemoryDatabaseAdapter for in-memory-only runs. WHY: Caller owns DB lifecycle; no plugin registration race; single source of truth. */
63
64
  adapter?: IDatabaseAdapter;
64
65
  settings?: RuntimeSettings;
65
66
  allAvailablePlugins?: Plugin[];
@@ -104,12 +105,8 @@ export declare class AgentRuntime implements IAgentRuntime {
104
105
  * Can be enabled at construction time or lazily via settings.
105
106
  */
106
107
  enableAutonomy?: boolean;
107
- /**
108
- * Serverless mode: when true, TaskService does not start its own timer.
109
- * Host must call taskService.runDueTasks() from cron or on each request.
110
- * WHY: serverless runtimes have no long-lived process; setInterval would be useless or harmful.
111
- */
112
- serverless?: boolean;
108
+ /** Optional URL of a long-lived companion runtime for fire-and-forget embedding/task work. WHY: Thin runtimes (e.g. serverless) delegate embeddings and task-dirty notifications without blocking. */
109
+ companionUrl?: string;
113
110
  });
114
111
  /**
115
112
  * Create a new run ID for tracking a sequence of model calls
@@ -130,12 +127,23 @@ export declare class AgentRuntime implements IAgentRuntime {
130
127
  getCurrentRunId(): UUID;
131
128
  registerPlugin(plugin: Plugin): Promise<void>;
132
129
  getAllServices(): Map<ServiceTypeName, Service[]>;
130
+ /**
131
+ * Stops all started services and clears runtime caches/handlers.
132
+ * For full teardown (including DB/adapter connection), call close() after stop().
133
+ */
133
134
  stop(): Promise<void>;
135
+ /**
136
+ * Slim init: register plugins, ensure adapter ready, create message service.
137
+ * Does NOT run migrations, agent/entity/room creation, or embedding dimension.
138
+ * WHY: Those belong to provisioning (once at daemon boot); edge/ephemeral skip them.
139
+ */
134
140
  initialize(options?: {
135
141
  skipMigrations?: boolean;
136
142
  /** Allow running without a persistent database adapter (benchmarks/tests). */
137
143
  allowNoDatabase?: boolean;
138
144
  }): Promise<void>;
145
+ private getBootstrapSettings;
146
+ registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
139
147
  runPluginMigrations(): Promise<void>;
140
148
  getConnection(): Promise<object>;
141
149
  setSetting(key: string, value: string | boolean | null, secret?: boolean): void;
@@ -170,7 +178,6 @@ export declare class AgentRuntime implements IAgentRuntime {
170
178
  * Priority: constructor option > character setting CHECK_SHOULD_RESPOND > default (true)
171
179
  */
172
180
  isCheckShouldRespondEnabled(): boolean;
173
- registerDatabaseAdapter(adapter: IDatabaseAdapter): void;
174
181
  /**
175
182
  * Get the messaging adapter if available
176
183
  *
@@ -196,7 +203,7 @@ export declare class AgentRuntime implements IAgentRuntime {
196
203
  providerPolicy?: ToolPolicyConfig;
197
204
  worldPolicy?: ToolPolicyConfig;
198
205
  roomPolicy?: ToolPolicyConfig;
199
- }): Action[];
206
+ }): Promise<Action[]>;
200
207
  /**
201
208
  * Check if a specific action is allowed by tool policy.
202
209
  *
@@ -211,10 +218,10 @@ export declare class AgentRuntime implements IAgentRuntime {
211
218
  providerPolicy?: ToolPolicyConfig;
212
219
  worldPolicy?: ToolPolicyConfig;
213
220
  roomPolicy?: ToolPolicyConfig;
214
- }): {
221
+ }): Promise<{
215
222
  allowed: boolean;
216
223
  reason: string;
217
- };
224
+ }>;
218
225
  registerEvaluator(evaluator: Evaluator): void;
219
226
  private updateActionPlan;
220
227
  private updateActionStep;
@@ -224,10 +231,10 @@ export declare class AgentRuntime implements IAgentRuntime {
224
231
  getActionResults(messageId: UUID): ActionResult[];
225
232
  evaluate(message: Memory, state: State, didRespond?: boolean, callback?: HandlerCallback, responses?: Memory[]): Promise<Evaluator[]>;
226
233
  ensureConnections(entities: Entity[], rooms: Room[], source: string, world: World): Promise<void>;
227
- ensureConnection({ entityId, roomId, worldId, worldName, userName, name, source, type, channelId, messageServerId, userId, metadata, }: {
234
+ ensureConnection(params: {
228
235
  entityId: UUID;
229
236
  roomId: UUID;
230
- worldId: UUID;
237
+ worldId?: UUID;
231
238
  worldName?: string;
232
239
  userName?: string;
233
240
  name?: string;
@@ -239,18 +246,15 @@ export declare class AgentRuntime implements IAgentRuntime {
239
246
  metadata?: Record<string, JsonValue>;
240
247
  }): Promise<void>;
241
248
  ensureParticipantInRoom(entityId: UUID, roomId: UUID): Promise<void>;
242
- getParticipantsForEntities(entityIds: UUID[]): Promise<Participant[]>;
243
- getParticipantsForRooms(roomIds: UUID[]): Promise<Array<{
244
- roomId: UUID;
245
- entityIds: UUID[];
246
- }>>;
247
249
  getParticipantsForEntity(entityId: UUID): Promise<Participant[]>;
250
+ getParticipantsForEntities(entityIds: UUID[]): Promise<Participant[]>;
248
251
  getParticipantsForRoom(roomId: UUID): Promise<UUID[]>;
252
+ getParticipantsForRooms(roomIds: UUID[]): Promise<import("./types/database").ParticipantsForRoomsResult>;
253
+ isRoomParticipant(roomId: UUID, entityId: UUID): Promise<boolean>;
249
254
  areRoomParticipants(pairs: Array<{
250
255
  roomId: UUID;
251
256
  entityId: UUID;
252
257
  }>): Promise<boolean[]>;
253
- isRoomParticipant(roomId: UUID, entityId: UUID): Promise<boolean>;
254
258
  addParticipant(entityId: UUID, roomId: UUID): Promise<boolean>;
255
259
  createRoomParticipants(entityIds: UUID[], roomId: UUID): Promise<UUID[]>;
256
260
  /**
@@ -269,28 +273,34 @@ export declare class AgentRuntime implements IAgentRuntime {
269
273
  */
270
274
  ensureRoomExists({ id, name, source, type, channelId, messageServerId, worldId, metadata, }: Room): Promise<void>;
271
275
  composeState(message: Memory, includeList?: string[] | null, onlyInclude?: boolean, skipCache?: boolean): Promise<State>;
272
- getService<T extends Service = Service>(serviceName: ServiceTypeName | string): T | null;
276
+ /** WHY lazy: Service is started on first getService() so unused features don't pay startup cost; callers must await getService(). */
277
+ /** Dedupes concurrent getService() for the same type via startingServices so only one start runs. */
278
+ private _ensureServiceStarted;
279
+ /** Runs one service start; used by _ensureServiceStarted with startingServices dedupe. */
280
+ private _runServiceStart;
281
+ /** Returns the service instance or null; starts the service on first call (lazy). Always await. */
282
+ getService<T extends Service = Service>(serviceName: ServiceTypeName | string): Promise<T | null>;
273
283
  /**
274
284
  * Type-safe service getter that ensures the correct service type is returned
275
285
  * @template T - The expected service class type
276
286
  * @param serviceName - The service type name
277
287
  * @returns The service instance with proper typing, or null if not found
278
288
  */
279
- getTypedService<T extends Service = Service>(serviceName: ServiceTypeName | string): T | null;
289
+ getTypedService<T extends Service = Service>(serviceName: ServiceTypeName | string): Promise<T | null>;
280
290
  /**
281
291
  * Get all services of a specific type
282
292
  * @template T - The expected service class type
283
293
  * @param serviceName - The service type name
284
294
  * @returns Array of service instances with proper typing
285
295
  */
286
- getServicesByType<T extends Service = Service>(serviceName: ServiceTypeName | string): T[];
296
+ getServicesByType<T extends Service = Service>(serviceName: ServiceTypeName | string): Promise<T[]>;
287
297
  /**
288
- * Get all registered service types
298
+ * Get all registered service types (includes lazy-registered, not yet started)
289
299
  * @returns Array of registered service type names
290
300
  */
291
301
  getRegisteredServiceTypes(): ServiceTypeName[];
292
302
  /**
293
- * Check if a service type is registered
303
+ * Check if a service type is registered (class registered; may not be started yet)
294
304
  * @param serviceType - The service type to check
295
305
  * @returns true if the service is registered
296
306
  */
@@ -390,6 +400,23 @@ export declare class AgentRuntime implements IAgentRuntime {
390
400
  abortSignal?: AbortSignal;
391
401
  };
392
402
  }): Promise<Record<string, unknown> | null>;
403
+ private flattenSchemaRows;
404
+ private schemaHasNestedStructure;
405
+ private renderXmlSchemaExample;
406
+ private renderJsonSchemaExample;
407
+ private buildJsonExampleValue;
408
+ private buildJsonExampleValueAtDepth;
409
+ private validateResponseAgainstSchema;
410
+ private validateSchemaValue;
411
+ private validateSchemaValueAtDepth;
412
+ private buildValidationOutputInstructions;
413
+ private getEffectiveSchemaValueType;
414
+ private collectSchemaDefinitionWarnings;
415
+ private collectSchemaSpecWarnings;
416
+ private buildSchemaMetricKey;
417
+ private serializeSchemaMetricRow;
418
+ private serializeSchemaMetricSpec;
419
+ private serializeSchemaMetricSpecAtDepth;
393
420
  /**
394
421
  * Calculate retry backoff delay.
395
422
  */
@@ -424,23 +451,6 @@ export declare class AgentRuntime implements IAgentRuntime {
424
451
  * This recursively unwraps them up to a reasonable depth limit.
425
452
  */
426
453
  private normalizeStructuredResponse;
427
- private flattenSchemaRows;
428
- private schemaHasNestedStructure;
429
- private renderXmlSchemaExample;
430
- private renderJsonSchemaExample;
431
- private buildJsonExampleValue;
432
- private buildJsonExampleValueAtDepth;
433
- private validateResponseAgainstSchema;
434
- private validateSchemaValue;
435
- private validateSchemaValueAtDepth;
436
- private buildValidationOutputInstructions;
437
- private getEffectiveSchemaValueType;
438
- private collectSchemaDefinitionWarnings;
439
- private collectSchemaSpecWarnings;
440
- private buildSchemaMetricKey;
441
- private serializeSchemaMetricRow;
442
- private serializeSchemaMetricSpec;
443
- private serializeSchemaMetricSpecAtDepth;
444
454
  registerEvent<T extends keyof EventPayloadMap>(event: T, handler: EventHandler<T>): void;
445
455
  registerEvent<P extends EventPayload = EventPayload>(event: string, handler: (params: P) => Promise<void>): void;
446
456
  getEvent(event: string): ((params: EventPayloadMap[keyof EventPayloadMap] | EventPayload) => Promise<void>)[] | undefined;
@@ -450,6 +460,9 @@ export declare class AgentRuntime implements IAgentRuntime {
450
460
  getTaskWorker(name: string): TaskWorker | undefined;
451
461
  get db(): object;
452
462
  init(): Promise<void>;
463
+ /**
464
+ * Closes the database adapter. Call after stop() for full teardown (stops services then closes DB/connection).
465
+ */
453
466
  close(): Promise<void>;
454
467
  getAgent(agentId: UUID): Promise<Agent | null>;
455
468
  getAgents(): Promise<Partial<Agent>[]>;
@@ -468,17 +481,24 @@ export declare class AgentRuntime implements IAgentRuntime {
468
481
  deleteAgents(agentIds: UUID[]): Promise<boolean>;
469
482
  ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
470
483
  getEntityById(entityId: UUID): Promise<Entity | null>;
471
- getEntitiesForRooms(roomIds: UUID[], includeComponents?: boolean): Promise<Array<{
472
- roomId: UUID;
473
- entities: Entity[];
474
- }>>;
484
+ getEntitiesForRooms(roomIds: UUID[], includeComponents?: boolean): Promise<import("./types/database").EntitiesForRoomsResult>;
475
485
  getEntitiesForRoom(roomId: UUID, includeComponents?: boolean): Promise<Entity[]>;
476
486
  createEntity(entity: Entity): Promise<boolean>;
477
487
  createEntities(entities: Entity[]): Promise<UUID[]>;
478
488
  upsertEntities(entities: Entity[]): Promise<void>;
479
- getComponentsForEntities(entityIds: UUID[], worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
480
489
  getComponents(entityId: UUID, worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
490
+ getComponentsByNaturalKeys(keys: Array<{
491
+ entityId: UUID;
492
+ type: string;
493
+ worldId?: UUID;
494
+ sourceEntityId?: UUID;
495
+ }>): Promise<(Component | null)[]>;
496
+ getComponentsForEntities(entityIds: UUID[], worldId?: UUID, sourceEntityId?: UUID): Promise<Component[]>;
481
497
  addEmbeddingToMemory(memory: Memory): Promise<Memory>;
498
+ /**
499
+ * Queue a memory for embedding generation. If companionUrl is set, POSTs to companion
500
+ * and returns without waiting (fire-and-forget). WHY: Thin runtime doesn't block on embedding.
501
+ */
482
502
  queueEmbeddingGeneration(memory: Memory, priority?: "high" | "normal" | "low"): Promise<void>;
483
503
  getMemories(params: {
484
504
  entityId?: UUID;
@@ -532,14 +552,14 @@ export declare class AgentRuntime implements IAgentRuntime {
532
552
  redactSecrets(text: string): string;
533
553
  clearAllAgentMemories(): Promise<void>;
534
554
  deleteAllMemories(roomIds: UUID[], tableName: string): Promise<void>;
535
- countMemories(params: {
536
- roomIds?: UUID[];
555
+ countMemories(roomIdOrParams: UUID | {
556
+ roomId?: UUID;
537
557
  unique?: boolean;
538
558
  tableName?: string;
539
559
  entityId?: UUID;
540
560
  agentId?: UUID;
541
561
  metadata?: Record<string, unknown>;
542
- }): Promise<number>;
562
+ }, unique?: boolean, tableName?: string): Promise<number>;
543
563
  getLogs(params: {
544
564
  entityId?: UUID;
545
565
  roomId?: UUID;
@@ -576,34 +596,25 @@ export declare class AgentRuntime implements IAgentRuntime {
576
596
  createRoom({ id, name, source, type, channelId, messageServerId, worldId, }: Room): Promise<UUID>;
577
597
  createRooms(rooms: Room[]): Promise<UUID[]>;
578
598
  upsertRooms(rooms: Room[]): Promise<void>;
579
- deleteRoomsByWorldIds(worldIds: UUID[]): Promise<void>;
580
- getRoomsByWorlds(worldIds: UUID[], limit?: number, offset?: number): Promise<Room[]>;
581
- getRoomsForParticipants(entityIds: UUID[]): Promise<UUID[]>;
582
599
  deleteRoomsByWorldId(worldId: UUID): Promise<void>;
583
- /** Single-id convenience: returns room IDs where this entity participates. */
584
600
  getRoomsForParticipant(entityId: UUID): Promise<UUID[]>;
601
+ getRoomsForParticipants(entityIds: UUID[]): Promise<UUID[]>;
585
602
  getRooms(worldId: UUID): Promise<Room[]>;
586
603
  getRoomsByWorld(worldId: UUID): Promise<Room[]>;
604
+ getParticipantUserState(roomId: UUID, entityId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
605
+ updateParticipantUserState(roomId: UUID, entityId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
587
606
  getParticipantUserStates(pairs: Array<{
588
607
  roomId: UUID;
589
608
  entityId: UUID;
590
609
  }>): Promise<("FOLLOWED" | "MUTED" | null)[]>;
591
- getParticipantUserState(roomId: UUID, entityId: UUID): Promise<"FOLLOWED" | "MUTED" | null>;
592
610
  updateParticipantUserStates(updates: Array<{
593
611
  roomId: UUID;
594
612
  entityId: UUID;
595
613
  state: "FOLLOWED" | "MUTED" | null;
596
614
  }>): Promise<void>;
597
- updateParticipantUserState(roomId: UUID, entityId: UUID, state: "FOLLOWED" | "MUTED" | null): Promise<void>;
598
- getRelationshipsByPairs(pairs: Array<{
599
- sourceEntityId: UUID;
600
- targetEntityId: UUID;
601
- }>): Promise<(Relationship | null)[]>;
602
615
  getRelationships(params: {
603
- entityIds?: UUID[];
616
+ entityId: UUID;
604
617
  tags?: string[];
605
- limit?: number;
606
- offset?: number;
607
618
  }): Promise<Relationship[]>;
608
619
  getCaches<T>(keys: string[]): Promise<Map<string, T>>;
609
620
  setCaches<T>(entries: Array<{
@@ -615,11 +626,10 @@ export declare class AgentRuntime implements IAgentRuntime {
615
626
  roomId?: UUID;
616
627
  tags?: string[];
617
628
  entityId?: UUID;
618
- agentIds: UUID[];
619
- limit?: number;
620
- offset?: number;
621
629
  }): Promise<Task[]>;
622
630
  getTasksByName(name: string): Promise<Task[]>;
631
+ /** WHY fire-and-forget: Notify companion that tasks changed so it can poll/process; no need to block. */
632
+ private _notifyCompanionTasksDirty;
623
633
  createTask(task: Task): Promise<UUID>;
624
634
  getTask(id: UUID): Promise<Task | null>;
625
635
  updateTask(id: UUID, task: Partial<Task>): Promise<void>;
@@ -678,12 +688,6 @@ export declare class AgentRuntime implements IAgentRuntime {
678
688
  updateComponents(components: Component[]): Promise<void>;
679
689
  deleteComponents(componentIds: UUID[]): Promise<void>;
680
690
  createComponent(component: Component): Promise<boolean>;
681
- getComponentsByNaturalKeys(keys: Array<{
682
- entityId: UUID;
683
- type: string;
684
- worldId?: UUID;
685
- sourceEntityId?: UUID;
686
- }>): Promise<(Component | null)[]>;
687
691
  getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
688
692
  updateComponent(component: Component): Promise<void>;
689
693
  deleteComponent(componentId: UUID): Promise<void>;
@@ -691,15 +695,15 @@ export declare class AgentRuntime implements IAgentRuntime {
691
695
  upsertComponents(components: Component[], options?: {
692
696
  entityContext?: UUID;
693
697
  }): Promise<void>;
698
+ patchComponent(componentId: UUID, ops: PatchOp[], options?: {
699
+ entityContext?: UUID;
700
+ }): Promise<void>;
694
701
  patchComponents(updates: Array<{
695
702
  componentId: UUID;
696
703
  ops: PatchOp[];
697
704
  }>, options?: {
698
705
  entityContext?: UUID;
699
706
  }): Promise<void>;
700
- patchComponent(componentId: UUID, ops: PatchOp[], options?: {
701
- entityContext?: UUID;
702
- }): Promise<void>;
703
707
  patchComponentField(componentId: UUID, op: PatchOp, options?: {
704
708
  entityContext?: UUID;
705
709
  }): Promise<void>;
@@ -722,6 +726,10 @@ export declare class AgentRuntime implements IAgentRuntime {
722
726
  metadata?: Metadata;
723
727
  }>): Promise<UUID[]>;
724
728
  getRelationshipsByIds(relationshipIds: UUID[]): Promise<Relationship[]>;
729
+ getRelationshipsByPairs(pairs: Array<{
730
+ sourceEntityId: UUID;
731
+ targetEntityId: UUID;
732
+ }>): Promise<(Relationship | null)[]>;
725
733
  updateRelationships(relationships: Relationship[]): Promise<void>;
726
734
  deleteRelationships(relationshipIds: UUID[]): Promise<void>;
727
735
  createRelationship(params: {
@@ -777,31 +785,22 @@ export declare class AgentRuntime implements IAgentRuntime {
777
785
  registerSendHandler(source: string, handler: SendHandlerFunction): void;
778
786
  sendMessageToTarget(target: TargetInfo, content: Content): Promise<void>;
779
787
  getMemoriesByWorldId(params: {
780
- worldIds?: UUID[];
788
+ worldId: UUID;
781
789
  count?: number;
782
- limit?: number;
783
790
  tableName?: string;
784
791
  }): Promise<Memory[]>;
785
792
  runMigrations(migrationsPaths?: string[]): Promise<void>;
786
793
  isReady(): Promise<boolean>;
794
+ getPairingRequestsForChannel(channel: PairingChannel, agentId: UUID): Promise<PairingRequest[]>;
787
795
  getPairingRequests(queries: Array<{
788
796
  channel: PairingChannel;
789
797
  agentId: UUID;
790
- }>): Promise<Array<{
791
- channel: PairingChannel;
792
- agentId: UUID;
793
- requests: PairingRequest[];
794
- }>>;
795
- getPairingRequests(channel: PairingChannel, agentId: UUID): Promise<PairingRequest[]>;
798
+ }>): Promise<import("./types/database").PairingRequestsResult>;
799
+ getPairingAllowlistForChannel(channel: PairingChannel, agentId: UUID): Promise<PairingAllowlistEntry[]>;
796
800
  getPairingAllowlists(queries: Array<{
797
801
  channel: PairingChannel;
798
802
  agentId: UUID;
799
- }>): Promise<Array<{
800
- channel: PairingChannel;
801
- agentId: UUID;
802
- entries: PairingAllowlistEntry[];
803
- }>>;
804
- getPairingAllowlist(channel: PairingChannel, agentId: UUID): Promise<PairingAllowlistEntry[]>;
803
+ }>): Promise<import("./types/database").PairingAllowlistsResult>;
805
804
  createPairingRequests(requests: PairingRequest[]): Promise<UUID[]>;
806
805
  updatePairingRequests(requests: PairingRequest[]): Promise<void>;
807
806
  deletePairingRequests(ids: UUID[]): Promise<void>;
@@ -813,5 +812,7 @@ export declare class AgentRuntime implements IAgentRuntime {
813
812
  deletePairingRequest(id: UUID): Promise<void>;
814
813
  createPairingAllowlistEntry(entry: PairingAllowlistEntry): Promise<UUID>;
815
814
  deletePairingAllowlistEntry(id: UUID): Promise<void>;
815
+ deleteRoomsByWorldIds(worldIds: UUID[]): Promise<void>;
816
+ getRoomsByWorlds(worldIds: UUID[], limit?: number, offset?: number): Promise<Room[]>;
816
817
  }
817
818
  //# sourceMappingURL=runtime.d.ts.map