@elizaos/core 1.7.0 → 1.7.1-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/index.browser.js +19 -19
- package/dist/browser/index.browser.js.map +4 -4
- package/dist/node/index.node.js +104 -62
- package/dist/node/index.node.js.map +4 -4
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/services/default-message-service.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +1 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/node/index.node.js
CHANGED
|
@@ -46534,43 +46534,81 @@ class DefaultMessageService {
|
|
|
46534
46534
|
runtime.logger.warn({ src: "service:message", iteration: iterationCount }, "No providers or action specified, forcing completion");
|
|
46535
46535
|
break;
|
|
46536
46536
|
}
|
|
46537
|
-
|
|
46538
|
-
|
|
46539
|
-
|
|
46537
|
+
const PROVIDERS_TOTAL_TIMEOUT_MS = parseInt(String(runtime.getSetting("PROVIDERS_TOTAL_TIMEOUT_MS") || "1000"));
|
|
46538
|
+
const completedProviders = new Set;
|
|
46539
|
+
const providerPromises = providersArray.filter((name) => typeof name === "string").map(async (providerName) => {
|
|
46540
46540
|
const provider = runtime.providers.find((p) => p.name === providerName);
|
|
46541
46541
|
if (!provider) {
|
|
46542
46542
|
runtime.logger.warn({ src: "service:message", providerName }, "Provider not found");
|
|
46543
|
-
|
|
46544
|
-
|
|
46545
|
-
success: false,
|
|
46546
|
-
error: `Provider not found: ${providerName}`
|
|
46547
|
-
});
|
|
46548
|
-
continue;
|
|
46543
|
+
completedProviders.add(providerName);
|
|
46544
|
+
return { providerName, success: false, error: `Provider not found: ${providerName}` };
|
|
46549
46545
|
}
|
|
46550
|
-
|
|
46551
|
-
|
|
46552
|
-
|
|
46553
|
-
|
|
46554
|
-
|
|
46555
|
-
success: false,
|
|
46556
|
-
|
|
46557
|
-
|
|
46558
|
-
|
|
46546
|
+
try {
|
|
46547
|
+
const providerResult = await provider.get(runtime, message, state);
|
|
46548
|
+
completedProviders.add(providerName);
|
|
46549
|
+
if (!providerResult) {
|
|
46550
|
+
runtime.logger.warn({ src: "service:message", providerName }, "Provider returned no result");
|
|
46551
|
+
return { providerName, success: false, error: "Provider returned no result" };
|
|
46552
|
+
}
|
|
46553
|
+
const success = !!providerResult.text;
|
|
46554
|
+
return {
|
|
46555
|
+
providerName,
|
|
46556
|
+
success,
|
|
46557
|
+
text: success ? providerResult.text : undefined,
|
|
46558
|
+
error: success ? undefined : "Provider returned no result"
|
|
46559
|
+
};
|
|
46560
|
+
} catch (err) {
|
|
46561
|
+
completedProviders.add(providerName);
|
|
46562
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
46563
|
+
runtime.logger.error({ src: "service:message", providerName, error: errorMsg }, "Provider execution failed");
|
|
46564
|
+
return { providerName, success: false, error: errorMsg };
|
|
46559
46565
|
}
|
|
46560
|
-
|
|
46561
|
-
|
|
46562
|
-
|
|
46563
|
-
|
|
46564
|
-
|
|
46565
|
-
|
|
46566
|
-
|
|
46566
|
+
});
|
|
46567
|
+
let timeoutId;
|
|
46568
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
46569
|
+
timeoutId = setTimeout(() => resolve("timeout"), PROVIDERS_TOTAL_TIMEOUT_MS);
|
|
46570
|
+
});
|
|
46571
|
+
const allProvidersPromise = Promise.allSettled(providerPromises);
|
|
46572
|
+
const raceResult = await Promise.race([allProvidersPromise, timeoutPromise]);
|
|
46573
|
+
clearTimeout(timeoutId);
|
|
46574
|
+
if (raceResult === "timeout") {
|
|
46575
|
+
const allProviderNames = providersArray.filter((name) => typeof name === "string");
|
|
46576
|
+
const pendingProviders = allProviderNames.filter((name) => !completedProviders.has(name));
|
|
46577
|
+
runtime.logger.error({
|
|
46578
|
+
src: "service:message",
|
|
46579
|
+
timeoutMs: PROVIDERS_TOTAL_TIMEOUT_MS,
|
|
46580
|
+
pendingProviders,
|
|
46581
|
+
completedProviders: Array.from(completedProviders)
|
|
46582
|
+
}, `Providers took too long (>${PROVIDERS_TOTAL_TIMEOUT_MS}ms) - slow providers: ${pendingProviders.join(", ")}`);
|
|
46567
46583
|
if (callback) {
|
|
46568
46584
|
await callback({
|
|
46569
|
-
text:
|
|
46570
|
-
actions: [
|
|
46571
|
-
thought:
|
|
46585
|
+
text: "Providers took too long to respond. Please optimize your providers or use caching.",
|
|
46586
|
+
actions: [],
|
|
46587
|
+
thought: "Provider timeout - pipeline aborted"
|
|
46572
46588
|
});
|
|
46573
46589
|
}
|
|
46590
|
+
return { responseContent: null, responseMessages: [], state, mode: "none" };
|
|
46591
|
+
}
|
|
46592
|
+
const providerResults = raceResult;
|
|
46593
|
+
for (const result of providerResults) {
|
|
46594
|
+
if (result.status === "fulfilled") {
|
|
46595
|
+
const { providerName, success, text, error } = result.value;
|
|
46596
|
+
traceActionResult.push({
|
|
46597
|
+
data: { actionName: providerName },
|
|
46598
|
+
success,
|
|
46599
|
+
text,
|
|
46600
|
+
error
|
|
46601
|
+
});
|
|
46602
|
+
if (callback) {
|
|
46603
|
+
await callback({
|
|
46604
|
+
text: `\uD83D\uDD0E Provider executed: ${providerName}`,
|
|
46605
|
+
actions: [providerName],
|
|
46606
|
+
thought: typeof thought === "string" ? thought : ""
|
|
46607
|
+
});
|
|
46608
|
+
}
|
|
46609
|
+
} else {
|
|
46610
|
+
runtime.logger.error({ src: "service:message", error: result.reason || "Unknown provider failure" }, "Unexpected provider promise rejection");
|
|
46611
|
+
}
|
|
46574
46612
|
}
|
|
46575
46613
|
if (action) {
|
|
46576
46614
|
const actionContent = {
|
|
@@ -48860,6 +48898,41 @@ class AgentRuntime {
|
|
|
48860
48898
|
modelSettings.presencePenalty = presencePenalty;
|
|
48861
48899
|
return Object.keys(modelSettings).length > 0 ? modelSettings : null;
|
|
48862
48900
|
}
|
|
48901
|
+
logModelCall(modelType, modelKey, params, promptContent, elapsedTime, provider, response) {
|
|
48902
|
+
if (modelKey !== ModelType.TEXT_EMBEDDING && promptContent) {
|
|
48903
|
+
if (this.currentActionContext) {
|
|
48904
|
+
this.currentActionContext.prompts.push({
|
|
48905
|
+
modelType: modelKey,
|
|
48906
|
+
prompt: promptContent,
|
|
48907
|
+
timestamp: Date.now()
|
|
48908
|
+
});
|
|
48909
|
+
}
|
|
48910
|
+
}
|
|
48911
|
+
this.adapter.log({
|
|
48912
|
+
entityId: this.agentId,
|
|
48913
|
+
roomId: this.currentRoomId ?? this.agentId,
|
|
48914
|
+
body: {
|
|
48915
|
+
modelType,
|
|
48916
|
+
modelKey,
|
|
48917
|
+
params: {
|
|
48918
|
+
...typeof params === "object" && !Array.isArray(params) && params ? params : {},
|
|
48919
|
+
prompt: promptContent
|
|
48920
|
+
},
|
|
48921
|
+
prompt: promptContent,
|
|
48922
|
+
systemPrompt: this.character?.system || null,
|
|
48923
|
+
runId: this.getCurrentRunId(),
|
|
48924
|
+
timestamp: Date.now(),
|
|
48925
|
+
executionTime: elapsedTime,
|
|
48926
|
+
provider: provider || this.models.get(modelKey)?.[0]?.provider || "unknown",
|
|
48927
|
+
actionContext: this.currentActionContext ? {
|
|
48928
|
+
actionName: this.currentActionContext.actionName,
|
|
48929
|
+
actionId: this.currentActionContext.actionId
|
|
48930
|
+
} : undefined,
|
|
48931
|
+
response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
|
|
48932
|
+
},
|
|
48933
|
+
type: `useModel:${modelKey}`
|
|
48934
|
+
});
|
|
48935
|
+
}
|
|
48863
48936
|
async useModel(modelType, params, provider) {
|
|
48864
48937
|
const modelKey = typeof modelType === "string" ? modelType : ModelType[modelType];
|
|
48865
48938
|
const paramsObj = params;
|
|
@@ -48954,6 +49027,7 @@ class AgentRuntime {
|
|
|
48954
49027
|
duration: Number(elapsedTime2.toFixed(2)),
|
|
48955
49028
|
streaming: true
|
|
48956
49029
|
}, "Model output (stream with callback complete)");
|
|
49030
|
+
this.logModelCall(modelType, modelKey, params, promptContent, elapsedTime2, provider, fullText);
|
|
48957
49031
|
return fullText;
|
|
48958
49032
|
}
|
|
48959
49033
|
const elapsedTime = (typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now()) - startTime;
|
|
@@ -48963,39 +49037,7 @@ class AgentRuntime {
|
|
|
48963
49037
|
model: modelKey,
|
|
48964
49038
|
duration: Number(elapsedTime.toFixed(2))
|
|
48965
49039
|
}, "Model output");
|
|
48966
|
-
|
|
48967
|
-
if (this.currentActionContext) {
|
|
48968
|
-
this.currentActionContext.prompts.push({
|
|
48969
|
-
modelType: modelKey,
|
|
48970
|
-
prompt: promptContent,
|
|
48971
|
-
timestamp: Date.now()
|
|
48972
|
-
});
|
|
48973
|
-
}
|
|
48974
|
-
}
|
|
48975
|
-
this.adapter.log({
|
|
48976
|
-
entityId: this.agentId,
|
|
48977
|
-
roomId: this.currentRoomId ?? this.agentId,
|
|
48978
|
-
body: {
|
|
48979
|
-
modelType,
|
|
48980
|
-
modelKey,
|
|
48981
|
-
params: {
|
|
48982
|
-
...typeof params === "object" && !Array.isArray(params) && params ? params : {},
|
|
48983
|
-
prompt: promptContent
|
|
48984
|
-
},
|
|
48985
|
-
prompt: promptContent,
|
|
48986
|
-
systemPrompt: this.character?.system || null,
|
|
48987
|
-
runId: this.getCurrentRunId(),
|
|
48988
|
-
timestamp: Date.now(),
|
|
48989
|
-
executionTime: elapsedTime,
|
|
48990
|
-
provider: provider || this.models.get(modelKey)?.[0]?.provider || "unknown",
|
|
48991
|
-
actionContext: this.currentActionContext ? {
|
|
48992
|
-
actionName: this.currentActionContext.actionName,
|
|
48993
|
-
actionId: this.currentActionContext.actionId
|
|
48994
|
-
} : undefined,
|
|
48995
|
-
response: Array.isArray(response) && response.every((x) => typeof x === "number") ? "[array]" : response
|
|
48996
|
-
},
|
|
48997
|
-
type: `useModel:${modelKey}`
|
|
48998
|
-
});
|
|
49040
|
+
this.logModelCall(modelType, modelKey, params, promptContent, elapsedTime, provider, response);
|
|
48999
49041
|
return response;
|
|
49000
49042
|
}
|
|
49001
49043
|
async generateText(input, options) {
|
|
@@ -50944,5 +50986,5 @@ export {
|
|
|
50944
50986
|
ActionStreamFilter
|
|
50945
50987
|
};
|
|
50946
50988
|
|
|
50947
|
-
//# debugId=
|
|
50989
|
+
//# debugId=EE3A137370E73D0264756E2164756E21
|
|
50948
50990
|
//# sourceMappingURL=index.node.js.map
|