@elizaos/core 1.7.1-alpha.2 → 1.7.1-alpha.4

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.
@@ -28003,7 +28003,7 @@ function uuid7FromTime(timestamp) {
28003
28003
  return v72({ msecs, seq: 0 });
28004
28004
  }
28005
28005
  // ../../node_modules/langsmith/dist/index.js
28006
- var __version__ = "0.4.2";
28006
+ var __version__ = "0.4.4";
28007
28007
 
28008
28008
  // ../../node_modules/langsmith/dist/utils/env.js
28009
28009
  var globalEnv;
@@ -32841,6 +32841,12 @@ class RunTree {
32841
32841
  writable: true,
32842
32842
  value: undefined
32843
32843
  });
32844
+ Object.defineProperty(this, "_awaitInputsOnPost", {
32845
+ enumerable: true,
32846
+ configurable: true,
32847
+ writable: true,
32848
+ value: undefined
32849
+ });
32844
32850
  if (isRunTree(originalConfig)) {
32845
32851
  Object.assign(this, { ...originalConfig });
32846
32852
  return;
@@ -33134,6 +33140,9 @@ class RunTree {
33134
33140
  };
33135
33141
  }
33136
33142
  async postRun(excludeChildRuns = true) {
33143
+ if (this._awaitInputsOnPost) {
33144
+ this.inputs = await this.inputs;
33145
+ }
33137
33146
  try {
33138
33147
  const runtimeEnv = getRuntimeEnvironment2();
33139
33148
  if (this.replicas && this.replicas.length > 0) {
@@ -46804,43 +46813,81 @@ class DefaultMessageService {
46804
46813
  runtime.logger.warn({ src: "service:message", iteration: iterationCount }, "No providers or action specified, forcing completion");
46805
46814
  break;
46806
46815
  }
46807
- for (const providerName of providersArray) {
46808
- if (typeof providerName !== "string")
46809
- continue;
46816
+ const PROVIDERS_TOTAL_TIMEOUT_MS = parseInt(String(runtime.getSetting("PROVIDERS_TOTAL_TIMEOUT_MS") || "1000"));
46817
+ const completedProviders = new Set;
46818
+ const providerPromises = providersArray.filter((name) => typeof name === "string").map(async (providerName) => {
46810
46819
  const provider = runtime.providers.find((p) => p.name === providerName);
46811
46820
  if (!provider) {
46812
46821
  runtime.logger.warn({ src: "service:message", providerName }, "Provider not found");
46813
- traceActionResult.push({
46814
- data: { actionName: providerName },
46815
- success: false,
46816
- error: `Provider not found: ${providerName}`
46817
- });
46818
- continue;
46822
+ completedProviders.add(providerName);
46823
+ return { providerName, success: false, error: `Provider not found: ${providerName}` };
46819
46824
  }
46820
- const providerResult = await provider.get(runtime, message, state);
46821
- if (!providerResult) {
46822
- runtime.logger.warn({ src: "service:message", providerName }, "Provider returned no result");
46823
- traceActionResult.push({
46824
- data: { actionName: providerName },
46825
- success: false,
46826
- error: `Provider returned no result`
46827
- });
46828
- continue;
46825
+ try {
46826
+ const providerResult = await provider.get(runtime, message, state);
46827
+ completedProviders.add(providerName);
46828
+ if (!providerResult) {
46829
+ runtime.logger.warn({ src: "service:message", providerName }, "Provider returned no result");
46830
+ return { providerName, success: false, error: "Provider returned no result" };
46831
+ }
46832
+ const success = !!providerResult.text;
46833
+ return {
46834
+ providerName,
46835
+ success,
46836
+ text: success ? providerResult.text : undefined,
46837
+ error: success ? undefined : "Provider returned no result"
46838
+ };
46839
+ } catch (err) {
46840
+ completedProviders.add(providerName);
46841
+ const errorMsg = err instanceof Error ? err.message : String(err);
46842
+ runtime.logger.error({ src: "service:message", providerName, error: errorMsg }, "Provider execution failed");
46843
+ return { providerName, success: false, error: errorMsg };
46829
46844
  }
46830
- const success = !!providerResult.text;
46831
- traceActionResult.push({
46832
- data: { actionName: providerName },
46833
- success,
46834
- text: success ? providerResult.text : undefined,
46835
- error: success ? undefined : "Provider returned no result"
46836
- });
46845
+ });
46846
+ let timeoutId;
46847
+ const timeoutPromise = new Promise((resolve) => {
46848
+ timeoutId = setTimeout(() => resolve("timeout"), PROVIDERS_TOTAL_TIMEOUT_MS);
46849
+ });
46850
+ const allProvidersPromise = Promise.allSettled(providerPromises);
46851
+ const raceResult = await Promise.race([allProvidersPromise, timeoutPromise]);
46852
+ clearTimeout(timeoutId);
46853
+ if (raceResult === "timeout") {
46854
+ const allProviderNames = providersArray.filter((name) => typeof name === "string");
46855
+ const pendingProviders = allProviderNames.filter((name) => !completedProviders.has(name));
46856
+ runtime.logger.error({
46857
+ src: "service:message",
46858
+ timeoutMs: PROVIDERS_TOTAL_TIMEOUT_MS,
46859
+ pendingProviders,
46860
+ completedProviders: Array.from(completedProviders)
46861
+ }, `Providers took too long (>${PROVIDERS_TOTAL_TIMEOUT_MS}ms) - slow providers: ${pendingProviders.join(", ")}`);
46837
46862
  if (callback) {
46838
46863
  await callback({
46839
- text: `\uD83D\uDD0E Provider executed: ${providerName}`,
46840
- actions: [providerName],
46841
- thought: typeof thought === "string" ? thought : ""
46864
+ text: "Providers took too long to respond. Please optimize your providers or use caching.",
46865
+ actions: [],
46866
+ thought: "Provider timeout - pipeline aborted"
46842
46867
  });
46843
46868
  }
46869
+ return { responseContent: null, responseMessages: [], state, mode: "none" };
46870
+ }
46871
+ const providerResults = raceResult;
46872
+ for (const result of providerResults) {
46873
+ if (result.status === "fulfilled") {
46874
+ const { providerName, success, text, error } = result.value;
46875
+ traceActionResult.push({
46876
+ data: { actionName: providerName },
46877
+ success,
46878
+ text,
46879
+ error
46880
+ });
46881
+ if (callback) {
46882
+ await callback({
46883
+ text: `\uD83D\uDD0E Provider executed: ${providerName}`,
46884
+ actions: [providerName],
46885
+ thought: typeof thought === "string" ? thought : ""
46886
+ });
46887
+ }
46888
+ } else {
46889
+ runtime.logger.error({ src: "service:message", error: result.reason || "Unknown provider failure" }, "Unexpected provider promise rejection");
46890
+ }
46844
46891
  }
46845
46892
  if (action) {
46846
46893
  const actionContent = {
@@ -49130,6 +49177,41 @@ class AgentRuntime {
49130
49177
  modelSettings.presencePenalty = presencePenalty;
49131
49178
  return Object.keys(modelSettings).length > 0 ? modelSettings : null;
49132
49179
  }
49180
+ logModelCall(modelType, modelKey, params, promptContent, elapsedTime, provider, response) {
49181
+ if (modelKey !== ModelType.TEXT_EMBEDDING && promptContent) {
49182
+ if (this.currentActionContext) {
49183
+ this.currentActionContext.prompts.push({
49184
+ modelType: modelKey,
49185
+ prompt: promptContent,
49186
+ timestamp: Date.now()
49187
+ });
49188
+ }
49189
+ }
49190
+ this.adapter.log({
49191
+ entityId: this.agentId,
49192
+ roomId: this.currentRoomId ?? this.agentId,
49193
+ body: {
49194
+ modelType,
49195
+ modelKey,
49196
+ params: {
49197
+ ...typeof params === "object" && !Array.isArray(params) && params ? params : {},
49198
+ prompt: promptContent
49199
+ },
49200
+ prompt: promptContent,
49201
+ systemPrompt: this.character?.system || null,
49202
+ runId: this.getCurrentRunId(),
49203
+ timestamp: Date.now(),
49204
+ executionTime: elapsedTime,
49205
+ provider: provider || this.models.get(modelKey)?.[0]?.provider || "unknown",
49206
+ actionContext: this.currentActionContext ? {
49207
+ actionName: this.currentActionContext.actionName,
49208
+ actionId: this.currentActionContext.actionId
49209
+ } : undefined,
49210
+ response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
49211
+ },
49212
+ type: `useModel:${modelKey}`
49213
+ });
49214
+ }
49133
49215
  async useModel(modelType, params, provider) {
49134
49216
  const modelKey = typeof modelType === "string" ? modelType : ModelType[modelType];
49135
49217
  const paramsObj = params;
@@ -49224,6 +49306,7 @@ class AgentRuntime {
49224
49306
  duration: Number(elapsedTime2.toFixed(2)),
49225
49307
  streaming: true
49226
49308
  }, "Model output (stream with callback complete)");
49309
+ this.logModelCall(modelType, modelKey, params, promptContent, elapsedTime2, provider, fullText);
49227
49310
  return fullText;
49228
49311
  }
49229
49312
  const elapsedTime = (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now()) - startTime;
@@ -49233,39 +49316,7 @@ class AgentRuntime {
49233
49316
  model: modelKey,
49234
49317
  duration: Number(elapsedTime.toFixed(2))
49235
49318
  }, "Model output");
49236
- if (modelKey !== ModelType.TEXT_EMBEDDING && promptContent) {
49237
- if (this.currentActionContext) {
49238
- this.currentActionContext.prompts.push({
49239
- modelType: modelKey,
49240
- prompt: promptContent,
49241
- timestamp: Date.now()
49242
- });
49243
- }
49244
- }
49245
- this.adapter.log({
49246
- entityId: this.agentId,
49247
- roomId: this.currentRoomId ?? this.agentId,
49248
- body: {
49249
- modelType,
49250
- modelKey,
49251
- params: {
49252
- ...typeof params === "object" && !Array.isArray(params) && params ? params : {},
49253
- prompt: promptContent
49254
- },
49255
- prompt: promptContent,
49256
- systemPrompt: this.character?.system || null,
49257
- runId: this.getCurrentRunId(),
49258
- timestamp: Date.now(),
49259
- executionTime: elapsedTime,
49260
- provider: provider || this.models.get(modelKey)?.[0]?.provider || "unknown",
49261
- actionContext: this.currentActionContext ? {
49262
- actionName: this.currentActionContext.actionName,
49263
- actionId: this.currentActionContext.actionId
49264
- } : undefined,
49265
- response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
49266
- },
49267
- type: `useModel:${modelKey}`
49268
- });
49319
+ this.logModelCall(modelType, modelKey, params, promptContent, elapsedTime, provider, response);
49269
49320
  return response;
49270
49321
  }
49271
49322
  async generateText(input, options) {
@@ -51214,5 +51265,5 @@ export {
51214
51265
  ActionStreamFilter
51215
51266
  };
51216
51267
 
51217
- //# debugId=108305E81D5AB81564756E2164756E21
51268
+ //# debugId=B5101D8C783AC7F864756E2164756E21
51218
51269
  //# sourceMappingURL=index.node.js.map