@elizaos/ui 2.0.0-alpha.344 → 2.0.0-alpha.345

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 (43) hide show
  1. package/package.json +1 -1
  2. package/packages/typescript/src/features/basic-capabilities/providers/actionState.d.ts.map +1 -1
  3. package/packages/typescript/src/features/basic-capabilities/providers/actionState.js +8 -51
  4. package/packages/typescript/src/features/basic-capabilities/providers/actions.d.ts.map +1 -1
  5. package/packages/typescript/src/features/basic-capabilities/providers/actions.js +2 -2
  6. package/packages/typescript/src/features/basic-capabilities/providers/non-actionable-chatter.d.ts.map +1 -1
  7. package/packages/typescript/src/features/basic-capabilities/providers/non-actionable-chatter.js +2 -4
  8. package/packages/typescript/src/features/basic-capabilities/providers/providers.d.ts.map +1 -1
  9. package/packages/typescript/src/features/basic-capabilities/providers/providers.js +2 -2
  10. package/packages/typescript/src/features/knowledge/utils.d.ts.map +1 -1
  11. package/packages/typescript/src/features/knowledge/utils.js +4 -3
  12. package/packages/typescript/src/runtime.d.ts +2 -0
  13. package/packages/typescript/src/runtime.d.ts.map +1 -1
  14. package/packages/typescript/src/runtime.js +80 -0
  15. package/packages/typescript/src/services/message.d.ts +3 -1
  16. package/packages/typescript/src/services/message.d.ts.map +1 -1
  17. package/packages/typescript/src/services/message.js +29 -35
  18. package/packages/typescript/src/utils/action-results.d.ts +33 -0
  19. package/packages/typescript/src/utils/action-results.d.ts.map +1 -0
  20. package/packages/typescript/src/utils/action-results.js +169 -0
  21. package/packages/typescript/src/utils/context-catalog.d.ts.map +1 -1
  22. package/packages/typescript/src/utils/context-catalog.js +11 -0
  23. package/packages/typescript/src/utils/context-routing.d.ts +3 -0
  24. package/packages/typescript/src/utils/context-routing.d.ts.map +1 -1
  25. package/packages/typescript/src/utils/context-routing.js +88 -0
  26. package/packages/typescript/src/utils/message-text.d.ts +5 -0
  27. package/packages/typescript/src/utils/message-text.d.ts.map +1 -0
  28. package/packages/typescript/src/utils/message-text.js +24 -0
  29. package/packages/typescript/src/utils.d.ts +2 -1
  30. package/packages/typescript/src/utils.d.ts.map +1 -1
  31. package/packages/typescript/src/utils.js +2 -1
  32. package/packages/ui/src/components/composites/chat/chat-composer.d.ts.map +1 -1
  33. package/packages/ui/src/components/composites/chat/chat-composer.js +101 -19
  34. package/packages/ui/src/layouts/page-layout/page-layout-mobile-drawer.d.ts.map +1 -1
  35. package/packages/ui/src/layouts/page-layout/page-layout-mobile-drawer.js +23 -4
  36. package/packages/ui/src/layouts/workspace-layout/index.d.ts +1 -0
  37. package/packages/ui/src/layouts/workspace-layout/index.d.ts.map +1 -1
  38. package/packages/ui/src/layouts/workspace-layout/index.js +1 -0
  39. package/packages/ui/src/layouts/workspace-layout/workspace-layout.d.ts.map +1 -1
  40. package/packages/ui/src/layouts/workspace-layout/workspace-layout.js +8 -2
  41. package/packages/ui/src/layouts/workspace-layout/workspace-mobile-sidebar-controls.d.ts +13 -0
  42. package/packages/ui/src/layouts/workspace-layout/workspace-mobile-sidebar-controls.d.ts.map +1 -0
  43. package/packages/ui/src/layouts/workspace-layout/workspace-mobile-sidebar-controls.js +5 -0
@@ -13,7 +13,9 @@ import { ModelType } from "../types/model";
13
13
  import { incomingPipelineHookContext, modelStreamChunkPipelineHookContext, outgoingPipelineHookContext, parallelWithShouldRespondPipelineHookContext, preShouldRespondPipelineHookContext, } from "../types/pipeline-hooks";
14
14
  import { asUUID, ChannelType, ContentType } from "../types/primitives";
15
15
  import { composePromptFromState, getLocalServerUrl, parseBooleanFromText, parseJSONObjectFromText, parseKeyValueXml, truncateToCompleteSentence, } from "../utils";
16
+ import { collectActionResultSizeWarnings, formatActionResultsForPrompt, trimActionResultForPromptState, } from "../utils/action-results";
16
17
  import { AVAILABLE_CONTEXTS_STATE_KEY, attachAvailableContexts, CONTEXT_ROUTING_STATE_KEY, getActiveRoutingContexts, mergeContextRouting, parseContextRoutingMetadata, setContextRoutingMetadata, } from "../utils/context-routing";
18
+ import { getUserMessageText } from "../utils/message-text";
17
19
  import { createStreamingContext, MarkableExtractor, ResponseStreamExtractor, } from "../utils/streaming";
18
20
  import { extractFirstSentence, hasFirstSentence, } from "../utils/text-splitting";
19
21
  import { OPTIMIZED_PROMPT_SERVICE, } from "./optimized-prompt";
@@ -1146,9 +1148,7 @@ function findDirectOwnedActionSuggestion(runtime, messageText) {
1146
1148
  return null;
1147
1149
  }
1148
1150
  export function suggestOwnedActionFromMetadata(runtime, message) {
1149
- const messageText = typeof message.content?.text === "string"
1150
- ? message.content.text.trim()
1151
- : "";
1151
+ const messageText = getUserMessageText(message);
1152
1152
  if (messageText.length === 0 ||
1153
1153
  !ACTION_OWNERSHIP_TRIGGER_PATTERNS.some((pattern) => pattern.test(messageText))) {
1154
1154
  return null;
@@ -1247,7 +1247,7 @@ function shouldAttemptActionRescue(runtime, message, state, responseContent) {
1247
1247
  return true;
1248
1248
  }
1249
1249
  function getMessageText(message) {
1250
- return typeof message.content?.text === "string" ? message.content.text : "";
1250
+ return getUserMessageText(message);
1251
1251
  }
1252
1252
  function looksLikeOwnershipSensitiveRequest(message) {
1253
1253
  const text = getMessageText(message).toLowerCase();
@@ -1768,34 +1768,7 @@ function shouldWaitForUserAfterIncompleteReflection(responseContent, actionResul
1768
1768
  return normalizeActionIdentifier(actionName) === "REPLY";
1769
1769
  });
1770
1770
  }
1771
- function formatActionResultsForPrompt(actionResults) {
1772
- if (actionResults.length === 0) {
1773
- return "No action results available.";
1774
- }
1775
- return [
1776
- "# Action Results",
1777
- ...actionResults.map((result, index) => {
1778
- const actionNameValue = result.data?.actionName;
1779
- const actionName = typeof actionNameValue === "string"
1780
- ? actionNameValue
1781
- : "Unknown Action";
1782
- const lines = [
1783
- `${index + 1}. ${actionName} - ${result.success === false ? "failed" : "succeeded"}`,
1784
- ];
1785
- if (typeof result.text === "string" && result.text.trim()) {
1786
- lines.push(`Output: ${result.text.trim().slice(0, 2000)}`);
1787
- }
1788
- if (result.error) {
1789
- const errorText = result.error instanceof Error
1790
- ? result.error.message
1791
- : String(result.error);
1792
- lines.push(`Error: ${errorText.slice(0, 1000)}`);
1793
- }
1794
- return lines.join("\n");
1795
- }),
1796
- ].join("\n\n");
1797
- }
1798
- function withActionResults(state, actionResults) {
1771
+ export function withActionResultsForPrompt(state, actionResults) {
1799
1772
  return {
1800
1773
  ...state,
1801
1774
  values: {
@@ -1808,6 +1781,23 @@ function withActionResults(state, actionResults) {
1808
1781
  },
1809
1782
  };
1810
1783
  }
1784
+ const withActionResults = withActionResultsForPrompt;
1785
+ function preparePromptActionResult(runtime, message, result) {
1786
+ for (const warning of collectActionResultSizeWarnings(result)) {
1787
+ runtime.logger.warn({
1788
+ src: "service:message",
1789
+ agentId: runtime.agentId,
1790
+ messageId: message.id,
1791
+ roomId: message.roomId,
1792
+ action: warning.actionName,
1793
+ field: warning.field,
1794
+ rawCharLength: warning.rawCharLength,
1795
+ estimatedTokens: warning.estimatedTokens,
1796
+ thresholdTokens: warning.thresholdTokens,
1797
+ }, "Action result exceeds prompt-size warning threshold");
1798
+ }
1799
+ return trimActionResultForPromptState(result);
1800
+ }
1811
1801
  function withTaskCompletion(state, taskCompletion) {
1812
1802
  if (!taskCompletion) {
1813
1803
  return state;
@@ -2406,6 +2396,9 @@ export class DefaultMessageService {
2406
2396
  // Ensure latestResponseIds is cleaned up even if processMessage
2407
2397
  // threw before reaching its own cleanup at the end of the method.
2408
2398
  clearLatestResponseId(runtime.agentId, message.roomId, responseId);
2399
+ if (message.id) {
2400
+ runtime.stateCache.delete(`${message.id}_action_results`);
2401
+ }
2409
2402
  }
2410
2403
  });
2411
2404
  }
@@ -4483,7 +4476,7 @@ Output ONLY the continuation, starting immediately after the last character abov
4483
4476
  maxIterations: opts.maxMultiStepIterations,
4484
4477
  }, "Starting multi-step iteration");
4485
4478
  accumulatedState = withContextRoutingValues((await runtime.composeState(message, ["RECENT_MESSAGES", "ACTION_STATE", "PROVIDERS"], false, false)), contextRoutingStateValues);
4486
- accumulatedState.data.actionResults = traceActionResult;
4479
+ accumulatedState = withActionResults(accumulatedState, traceActionResult);
4487
4480
  // Use dynamicPromptExecFromState for structured decision output
4488
4481
  const optimizedPlannerService = runtime.getService(OPTIMIZED_PROMPT_SERVICE);
4489
4482
  const baselinePlannerTemplate = runtime.character.templates?.multiStepDecisionTemplate ||
@@ -4680,12 +4673,12 @@ Output ONLY the continuation, starting immediately after the last character abov
4680
4673
  for (const result of providerResults) {
4681
4674
  if (result.status === "fulfilled") {
4682
4675
  const { providerName, success, text, error } = result.value;
4683
- traceActionResult.push({
4676
+ traceActionResult.push(preparePromptActionResult(runtime, message, {
4684
4677
  data: { actionName: providerName },
4685
4678
  success,
4686
4679
  text,
4687
4680
  error,
4688
- });
4681
+ }));
4689
4682
  if (callback) {
4690
4683
  await callback({
4691
4684
  text: `🔎 Provider executed: ${providerName}`,
@@ -4755,6 +4748,7 @@ Output ONLY the continuation, starting immediately after the last character abov
4755
4748
  runtime.logger.warn({ src: "service:message", maxIterations: opts.maxMultiStepIterations }, "Reached maximum iterations, forcing completion");
4756
4749
  }
4757
4750
  accumulatedState = withContextRoutingValues((await runtime.composeState(message, ["RECENT_MESSAGES", "ACTION_STATE"], false, false)), contextRoutingStateValues);
4751
+ accumulatedState = withActionResults(accumulatedState, traceActionResult);
4758
4752
  // Use dynamicPromptExecFromState for final summary generation
4759
4753
  // Stream the final summary for better UX
4760
4754
  const summary = await runtime.dynamicPromptExecFromState({
@@ -0,0 +1,33 @@
1
+ import type { ActionResult } from "../types/components";
2
+ export declare const MAX_PROMPTED_ACTION_RESULTS = 8;
3
+ export declare const MAX_ACTION_RESULT_TEXT_CHARS = 4000;
4
+ export declare const MAX_ACTION_RESULT_ERROR_CHARS = 2000;
5
+ export declare const ACTION_RESULT_OVERSIZE_WARNING_TOKENS = 10000;
6
+ export declare const ACTION_RESULT_TOKEN_ESTIMATE_CHARS = 4;
7
+ export declare const ACTION_RESULT_FULL_OUTPUT_REFERENCE_KEYS: Set<string>;
8
+ export declare const ACTION_RESULT_FULL_ERROR_REFERENCE_KEYS: Set<string>;
9
+ export type ActionResultTextField = "text" | "error";
10
+ export interface ActionResultSizeWarning {
11
+ actionName: string;
12
+ field: ActionResultTextField;
13
+ rawCharLength: number;
14
+ estimatedTokens: number;
15
+ thresholdTokens: number;
16
+ }
17
+ export interface ActionResultReferences {
18
+ text?: string;
19
+ error?: string;
20
+ }
21
+ export declare function estimateActionResultTokens(text: string): number;
22
+ export declare function getActionResultActionName(result: ActionResult): string;
23
+ export declare function stringifyActionResultError(error: ActionResult["error"]): string | undefined;
24
+ export declare function getActionResultReference(result: ActionResult, field: ActionResultTextField): string | undefined;
25
+ export declare function truncateMiddle(text: string, maxChars: number, reference?: string): string;
26
+ export declare function collectActionResultSizeWarnings(result: ActionResult, thresholdTokens?: number): ActionResultSizeWarning[];
27
+ export declare function trimActionResultForPromptState<T extends ActionResult>(result: T, references?: ActionResultReferences): T;
28
+ export declare function formatActionResultsForPrompt(actionResults: ActionResult[], options?: {
29
+ header?: string;
30
+ maxResults?: number;
31
+ preserveAbsoluteIndex?: boolean;
32
+ }): string;
33
+ //# sourceMappingURL=action-results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-results.d.ts","sourceRoot":"","sources":["../../../../../../typescript/src/utils/action-results.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,qBAAqB,CAAC;AAE5E,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,eAAO,MAAM,4BAA4B,OAAO,CAAC;AACjD,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAClD,eAAO,MAAM,qCAAqC,QAAQ,CAAC;AAC3D,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAEpD,eAAO,MAAM,wCAAwC,aAYnD,CAAC;AAEH,eAAO,MAAM,uCAAuC,aASlD,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACvC,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export const MAX_ACTION_RESULT_ERROR_CHARS = 2000;
4
+ export const ACTION_RESULT_OVERSIZE_WARNING_TOKENS = 10000;
5
+ export const ACTION_RESULT_TOKEN_ESTIMATE_CHARS = 4;
6
+ export const ACTION_RESULT_FULL_OUTPUT_REFERENCE_KEYS = new Set([
7
+ "fullOutputPath",
8
+ "fullOutputFile",
9
+ "outputPath",
10
+ "outputFile",
11
+ "outputFilePath",
12
+ "stdoutPath",
13
+ "stdoutFile",
14
+ "artifactPath",
15
+ "resultPath",
16
+ "filePath",
17
+ "path",
18
+ ]);
19
+ export const ACTION_RESULT_FULL_ERROR_REFERENCE_KEYS = new Set([
20
+ "fullErrorPath",
21
+ "fullErrorFile",
22
+ "errorPath",
23
+ "errorFile",
24
+ "stderrPath",
25
+ "stderrFile",
26
+ "logPath",
27
+ "logFile",
28
+ ]);
29
+ export function estimateActionResultTokens(text) {
30
+ return Math.ceil(text.length / ACTION_RESULT_TOKEN_ESTIMATE_CHARS);
31
+ }
32
+ export function getActionResultActionName(result) {
33
+ const actionNameValue = result.data?.actionName;
34
+ return typeof actionNameValue === "string" && actionNameValue.trim()
35
+ ? actionNameValue.trim()
36
+ : "Unknown Action";
37
+ }
38
+ export function stringifyActionResultError(error) {
39
+ if (error === undefined || error === null) {
40
+ return undefined;
41
+ }
42
+ return error instanceof Error ? error.message : String(error);
43
+ }
44
+ function getReferenceFromData(data, keys) {
45
+ if (!data) {
46
+ return undefined;
47
+ }
48
+ for (const key of keys) {
49
+ const value = data[key];
50
+ if (typeof value === "string" && value.trim()) {
51
+ return value.trim();
52
+ }
53
+ }
54
+ return undefined;
55
+ }
56
+ export function getActionResultReference(result, field) {
57
+ return getReferenceFromData(result.data, field === "text"
58
+ ? ACTION_RESULT_FULL_OUTPUT_REFERENCE_KEYS
59
+ : ACTION_RESULT_FULL_ERROR_REFERENCE_KEYS);
60
+ }
61
+ export function truncateMiddle(text, maxChars, reference) {
62
+ const trimmed = text.trim();
63
+ if (trimmed.length <= maxChars) {
64
+ return trimmed;
65
+ }
66
+ let marker = "\n\n[... chars omitted ...]\n\n";
67
+ let available = Math.max(0, maxChars - marker.length);
68
+ let headChars = Math.ceil(available / 2);
69
+ let tailChars = Math.floor(available / 2);
70
+ const omittedChars = Math.max(0, trimmed.length - headChars - tailChars);
71
+ marker = `\n\n[... ${omittedChars} chars omitted ...]\n\n`;
72
+ available = Math.max(0, maxChars - marker.length);
73
+ headChars = Math.ceil(available / 2);
74
+ tailChars = Math.floor(available / 2);
75
+ const rendered = `${trimmed.slice(0, headChars)}${marker}${trimmed.slice(trimmed.length - tailChars)}`;
76
+ return reference ? `${rendered}\n\nFull output: ${reference}` : rendered;
77
+ }
78
+ export function collectActionResultSizeWarnings(result, thresholdTokens = ACTION_RESULT_OVERSIZE_WARNING_TOKENS) {
79
+ const actionName = getActionResultActionName(result);
80
+ const fields = [
81
+ { field: "text", text: result.text },
82
+ { field: "error", text: stringifyActionResultError(result.error) },
83
+ ];
84
+ return fields.flatMap(({ field, text }) => {
85
+ if (!text) {
86
+ return [];
87
+ }
88
+ const estimatedTokens = estimateActionResultTokens(text);
89
+ return estimatedTokens > thresholdTokens
90
+ ? [
91
+ {
92
+ actionName,
93
+ field,
94
+ rawCharLength: text.length,
95
+ estimatedTokens,
96
+ thresholdTokens,
97
+ },
98
+ ]
99
+ : [];
100
+ });
101
+ }
102
+ export function trimActionResultForPromptState(result, references = {}) {
103
+ const textReference = references.text ?? getActionResultReference(result, "text");
104
+ const errorReference = references.error ?? getActionResultReference(result, "error");
105
+ const data = { ...(result.data ?? {}) };
106
+ if (textReference) {
107
+ data.fullOutputPath = textReference;
108
+ }
109
+ if (errorReference) {
110
+ data.fullErrorPath = errorReference;
111
+ }
112
+ const text = typeof result.text === "string"
113
+ ? truncateMiddle(result.text, MAX_ACTION_RESULT_TEXT_CHARS, textReference)
114
+ : result.text;
115
+ const errorText = stringifyActionResultError(result.error);
116
+ const error = errorText === undefined
117
+ ? result.error
118
+ : truncateMiddle(errorText, MAX_ACTION_RESULT_ERROR_CHARS, errorReference);
119
+ return {
120
+ ...result,
121
+ ...(text !== undefined ? { text } : {}),
122
+ ...(error !== undefined ? { error } : {}),
123
+ data,
124
+ };
125
+ }
126
+ export function formatActionResultsForPrompt(actionResults, options = {}) {
127
+ const { header = "# Current Chain Action Results", maxResults = MAX_PROMPTED_ACTION_RESULTS, preserveAbsoluteIndex = true, } = options;
128
+ if (actionResults.length === 0) {
129
+ return "No action results available.";
130
+ }
131
+ const rendered = actionResults.length > maxResults
132
+ ? actionResults.slice(-maxResults)
133
+ : actionResults;
134
+ const truncatedCount = actionResults.length - rendered.length;
135
+ const omittedNote = truncatedCount > 0
136
+ ? [`(${truncatedCount} earlier action result(s) omitted.)`]
137
+ : [];
138
+ return [
139
+ header,
140
+ ...omittedNote,
141
+ ...rendered.map((result, index) => {
142
+ const displayIndex = preserveAbsoluteIndex
143
+ ? truncatedCount + index + 1
144
+ : index + 1;
145
+ const status = result.success === false ? "failed" : "succeeded";
146
+ const lines = [
147
+ `${displayIndex}. ${getActionResultActionName(result)} - ${status}`,
148
+ ];
149
+ if (typeof result.text === "string" && result.text.trim()) {
150
+ lines.push(`Output: ${result.text.trim()}`);
151
+ }
152
+ const errorText = stringifyActionResultError(result.error);
153
+ if (errorText) {
154
+ lines.push(`Error: ${errorText}`);
155
+ }
156
+ const outputReference = getActionResultReference(result, "text");
157
+ if (outputReference &&
158
+ !lines.some((line) => line.includes(outputReference))) {
159
+ lines.push(`Full output: ${outputReference}`);
160
+ }
161
+ const errorReference = getActionResultReference(result, "error");
162
+ if (errorReference &&
163
+ !lines.some((line) => line.includes(errorReference))) {
164
+ lines.push(`Full error: ${errorReference}`);
165
+ }
166
+ return lines.join("\n");
167
+ }),
168
+ ].join("\n\n");
169
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"context-catalog.d.ts","sourceRoot":"","sources":["../../../../../../typescript/src/utils/context-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE1E,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAqG7D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAsB/D,CAAC;AAUF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAOpE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,EAAE,CAO1E"}
1
+ {"version":3,"file":"context-catalog.d.ts","sourceRoot":"","sources":["../../../../../../typescript/src/utils/context-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE1E,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CA8G7D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,CAwB/D,CAAC;AAUF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAOpE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,EAAE,CAO1E"}
@@ -38,6 +38,7 @@ export const ACTION_CONTEXT_MAP = {
38
38
  WEB_SEARCH: ["knowledge", "browser"],
39
39
  SUMMARIZE: ["knowledge"],
40
40
  ANALYZE: ["knowledge"],
41
+ CREATE_TASK: ["code", "automation"],
41
42
  BROWSER_SESSION: ["browser"],
42
43
  BROWSE: ["browser"],
43
44
  SCREENSHOT: ["browser", "media"],
@@ -46,6 +47,14 @@ export const ACTION_CONTEXT_MAP = {
46
47
  TYPE_TEXT: ["browser"],
47
48
  EXTRACT_PAGE: ["browser", "knowledge"],
48
49
  SPAWN_AGENT: ["code", "automation"],
50
+ SEND_TO_AGENT: ["code", "automation"],
51
+ LIST_AGENTS: ["code", "automation"],
52
+ STOP_AGENT: ["code", "automation"],
53
+ TASK_HISTORY: ["code", "automation"],
54
+ TASK_CONTROL: ["code", "automation"],
55
+ TASK_SHARE: ["code", "automation"],
56
+ PROVISION_WORKSPACE: ["code", "automation"],
57
+ FINALIZE_WORKSPACE: ["code", "automation"],
49
58
  KILL_AGENT: ["code", "automation"],
50
59
  UPDATE_AGENT: ["code", "system"],
51
60
  RUN_SCRIPT: ["code", "automation"],
@@ -115,6 +124,8 @@ export const PROVIDER_CONTEXT_MAP = {
115
124
  walletPortfolio: ["wallet"],
116
125
  tokenPrices: ["wallet", "knowledge"],
117
126
  chainInfo: ["wallet"],
127
+ CODING_AGENT_EXAMPLES: ["code", "automation"],
128
+ ACTIVE_WORKSPACE_CONTEXT: ["code", "automation"],
118
129
  contacts: ["social"],
119
130
  trustScores: ["social"],
120
131
  platformIdentity: ["social"],
@@ -15,9 +15,12 @@ export declare function getContextRoutingFromState(state: State | null | undefin
15
15
  export declare function getContextRoutingFromMessage(message: Memory): ContextRoutingDecision;
16
16
  export declare function mergeContextRouting(state: State | null | undefined, message: Memory): ContextRoutingDecision;
17
17
  export declare function getActiveRoutingContexts(routing: ContextRoutingDecision): AgentContext[];
18
+ export declare function getActiveRoutingContextsForTurn(state: State | null | undefined, message: Memory): AgentContext[];
18
19
  export declare function shouldIncludeByContext(declaredContexts: AgentContext[] | undefined, activeContexts: AgentContext[] | undefined): boolean;
19
20
  export declare function setContextRoutingMetadata(message: Memory, routing: ContextRoutingDecision): void;
20
21
  export declare function deriveAvailableContexts(actions: Action[], providers: Provider[]): AgentContext[];
22
+ export declare function inferContextRoutingFromText(text: string | null | undefined): ContextRoutingDecision;
23
+ export declare function inferContextRoutingFromMessage(message: Pick<Memory, "content">): ContextRoutingDecision;
21
24
  export declare function attachAvailableContexts(state: State, runtime: {
22
25
  actions: Action[];
23
26
  providers: Provider[];
@@ -1 +1 @@
1
- {"version":3,"file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AAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GACb,sBAAsB,CAyBxB;AAED,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,sBAAsB,GAC7B,YAAY,EAAE,CAehB;AAED,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,EAAE,MAAM,GACb,YAAY,EAAE,CAEhB;AAED,wBAAgB,sBAAsB,CACrC,gBAAgB,EAAE,YAAY,EAAE,GAAG,SAAS,EAC5C,cAAc,EAAE,YAAY,EAAE,GAAG,SAAS,GACxC,OAAO,CAcT;AAED,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,sBAAsB,GAC7B,IAAI,CAiBN;AAED,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,QAAQ,EAAE,GACnB,YAAY,EAAE,CAmBhB;AA8DD,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC7B,sBAAsB,CA6BxB;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,GAC9B,sBAAsB,CAQxB;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,QAAQ,EAAE,CAAA;CAAE,GACnD,KAAK,CAYP"}
@@ -1,4 +1,5 @@
1
1
  import { resolveActionContexts, resolveProviderContexts, } from "./context-catalog";
2
+ import { normalizeUserMessageText } from "./message-text";
2
3
  export const AVAILABLE_CONTEXTS_STATE_KEY = "availableContexts";
3
4
  export const CONTEXT_ROUTING_METADATA_KEY = "__responseContext";
4
5
  export const CONTEXT_ROUTING_STATE_KEY = "__contextRouting";
@@ -107,6 +108,9 @@ export function getActiveRoutingContexts(routing) {
107
108
  contextSet.add("general");
108
109
  return Array.from(contextSet);
109
110
  }
111
+ export function getActiveRoutingContextsForTurn(state, message) {
112
+ return getActiveRoutingContexts(mergeContextRouting(state, message));
113
+ }
110
114
  export function shouldIncludeByContext(declaredContexts, activeContexts) {
111
115
  if (!declaredContexts || declaredContexts.length === 0) {
112
116
  return true;
@@ -152,6 +156,90 @@ export function deriveAvailableContexts(actions, providers) {
152
156
  }
153
157
  return Array.from(contextSet).sort((a, b) => `${a}`.localeCompare(`${b}`));
154
158
  }
159
+ const CONTEXT_SIGNALS = [
160
+ {
161
+ context: "code",
162
+ patterns: [
163
+ /\b(repo|repository|codebase|branch|commit|pull request|pr|diff|workspace|file|directory)\b/u,
164
+ /\b(code|coding|implement|debug|fix|refactor|patch|test|typecheck|lint|build|component|api|server|client)\b/u,
165
+ /\b(task agents?|sub-?agents?|coding agents?|codex|claude code|spawn an? agent|agent running|what are you working on)\b/u,
166
+ ],
167
+ },
168
+ {
169
+ context: "automation",
170
+ patterns: [
171
+ /\b(schedule|remind|reminder|cron|workflow|automate|automation|run this|execute|deploy|release|monitor)\b/u,
172
+ /\b(task agents?|sub-?agents?|agent running|pause that|resume that|stop that|continue that|what are you working on)\b/u,
173
+ ],
174
+ },
175
+ {
176
+ context: "knowledge",
177
+ patterns: [
178
+ /\b(uploaded|document|file|pdf|knowledge|remember|recall|search|lookup|find|summari[sz]e|analy[sz]e|research)\b/u,
179
+ /\b(what is|what was|where is|tell me about|explain)\b/u,
180
+ ],
181
+ },
182
+ {
183
+ context: "browser",
184
+ patterns: [
185
+ /\b(browser|browse|website|web page|url|click|type into|screenshot|navigate|extract page)\b/u,
186
+ ],
187
+ },
188
+ {
189
+ context: "media",
190
+ patterns: [
191
+ /\b(image|picture|photo|video|audio|voice|transcribe|screenshot|draw|generate an image)\b/u,
192
+ ],
193
+ },
194
+ {
195
+ context: "wallet",
196
+ patterns: [
197
+ /\b(wallet|token|swap|bridge|stake|unstake|balance|portfolio|transaction|sign message|contract)\b/u,
198
+ ],
199
+ },
200
+ {
201
+ context: "social",
202
+ patterns: [
203
+ /\b(message|dm|email|inbox|contact|relationship|follow up|calendar|meeting|call|send .* to)\b/u,
204
+ ],
205
+ },
206
+ {
207
+ context: "system",
208
+ patterns: [
209
+ /\b(settings?|configure|configuration|plugin|secret|api key|model provider|oauth|login|auth)\b/u,
210
+ ],
211
+ },
212
+ ];
213
+ export function inferContextRoutingFromText(text) {
214
+ const normalized = normalizeUserMessageText({
215
+ content: { text: text ?? "" },
216
+ });
217
+ if (!normalized) {
218
+ return { primaryContext: "general", secondaryContexts: [] };
219
+ }
220
+ const scored = CONTEXT_SIGNALS.map((signal) => ({
221
+ context: signal.context,
222
+ score: signal.patterns.reduce((score, pattern) => score + (pattern.test(normalized) ? 1 : 0), 0),
223
+ }))
224
+ .filter((entry) => entry.score > 0)
225
+ .sort((left, right) => right.score - left.score);
226
+ if (scored.length === 0) {
227
+ return { primaryContext: "general", secondaryContexts: [] };
228
+ }
229
+ const primaryContext = scored[0].context;
230
+ const secondaryContexts = scored
231
+ .slice(1)
232
+ .filter((entry) => entry.score >= Math.max(1, scored[0].score - 1))
233
+ .map((entry) => entry.context);
234
+ return { primaryContext, secondaryContexts };
235
+ }
236
+ export function inferContextRoutingFromMessage(message) {
237
+ return inferContextRoutingFromText(typeof message.content === "string"
238
+ ? message.content
239
+ : typeof message.content?.text === "string"
240
+ ? message.content.text
241
+ : "");
242
+ }
155
243
  export function attachAvailableContexts(state, runtime) {
156
244
  const availableContexts = deriveAvailableContexts(runtime.actions, runtime.providers);
157
245
  return {
@@ -0,0 +1,5 @@
1
+ import type { Memory } from "../types/memory";
2
+ export declare function extractUserText(raw: string): string;
3
+ export declare function getUserMessageText(message: Pick<Memory, "content"> | null | undefined): string;
4
+ export declare function normalizeUserMessageText(message: Pick<Memory, "content"> | null | undefined): string;
5
+ //# sourceMappingURL=message-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-text.d.ts","sourceRoot":"","sources":["../../../../../../typescript/src/utils/message-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAO9C,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASnD;AAED,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,GACjD,MAAM,CAQR;AAED,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,GAAG,SAAS,GACjD,MAAM,CAER"}
@@ -0,0 +1,24 @@
1
+ const KNOWLEDGE_AUGMENTATION_PREFIX = "Answer the user request using the contextual knowledge";
2
+ const USER_REQUEST_WRAPPER = /<user_request>\s*([\s\S]*?)\s*<\/user_request>/i;
3
+ const LANGUAGE_INSTRUCTION_SUFFIX = /\n*\[language instruction:[^\]]*\]\s*$/i;
4
+ export function extractUserText(raw) {
5
+ let text = raw;
6
+ if (text.trimStart().startsWith(KNOWLEDGE_AUGMENTATION_PREFIX)) {
7
+ const match = text.match(USER_REQUEST_WRAPPER);
8
+ if (match?.[1]) {
9
+ text = match[1];
10
+ }
11
+ }
12
+ return text.replace(LANGUAGE_INSTRUCTION_SUFFIX, "").trim();
13
+ }
14
+ export function getUserMessageText(message) {
15
+ const raw = typeof message?.content === "string"
16
+ ? message.content
17
+ : typeof message?.content?.text === "string"
18
+ ? message.content.text
19
+ : "";
20
+ return extractUserText(raw);
21
+ }
22
+ export function normalizeUserMessageText(message) {
23
+ return getUserMessageText(message).toLowerCase().replace(/\s+/g, " ").trim();
24
+ }
@@ -185,8 +185,9 @@ export declare function stringToUuid(target: string | number): UUID;
185
185
  */
186
186
  export declare function prewarmUuidCache(values: string[]): Promise<void>;
187
187
  export declare const getContentTypeFromMimeType: (mimeType: string) => ContentType | undefined;
188
- export { AVAILABLE_CONTEXTS_STATE_KEY, attachAvailableContexts, CONTEXT_ROUTING_METADATA_KEY, CONTEXT_ROUTING_STATE_KEY, type ContextRoutingDecision, deriveAvailableContexts, getActiveRoutingContexts, getContextRoutingFromMessage, getContextRoutingFromState, mergeContextRouting, parseContextList, parseContextRoutingMetadata, setContextRoutingMetadata, shouldIncludeByContext, } from "./utils/context-routing";
188
+ export { AVAILABLE_CONTEXTS_STATE_KEY, attachAvailableContexts, CONTEXT_ROUTING_METADATA_KEY, CONTEXT_ROUTING_STATE_KEY, type ContextRoutingDecision, deriveAvailableContexts, getActiveRoutingContexts, getActiveRoutingContextsForTurn, getContextRoutingFromMessage, getContextRoutingFromState, inferContextRoutingFromMessage, inferContextRoutingFromText, mergeContextRouting, parseContextList, parseContextRoutingMetadata, setContextRoutingMetadata, shouldIncludeByContext, } from "./utils/context-routing";
189
189
  export { extractAndParseJSONObjectFromText } from "./utils/json-llm";
190
+ export { extractUserText, getUserMessageText, normalizeUserMessageText, } from "./utils/message-text";
190
191
  export { getLocalServerUrl } from "./utils/node";
191
192
  export { extractFirstSentence, hasFirstSentence } from "./utils/text-splitting";
192
193
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../typescript/src/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEX,MAAM,EACN,aAAa,EACb,MAAM,EACN,KAAK,EACL,YAAY,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,WAAW,EAAa,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAc5D,eAAO,MAAM,+BAA+B,QAAS,CAAC;AACtD,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,OAAQ,CAAC;AAClD,4EAA4E;AAC5E,eAAO,MAAM,2BAA2B,QAAmC,CAAC;AAC5E,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAkKjD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa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0BAA0B,GACtC,UAAU,MAAM,KACd,WAAW,GAAG,SAYhB,CAAC;AAEF,OAAO,EACN,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC5B,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,4BAA4B,EAC5B,0BAA0B,EAC1B,8BAA8B,EAC9B,2BAA2B,EAC3B,mBAAmB,EACnB,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACN,eAAe,EACf,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1111,8 +1111,9 @@ export const getContentTypeFromMimeType = (mimeType) => {
1111
1111
  }
1112
1112
  return undefined;
1113
1113
  };
1114
- export { AVAILABLE_CONTEXTS_STATE_KEY, attachAvailableContexts, CONTEXT_ROUTING_METADATA_KEY, CONTEXT_ROUTING_STATE_KEY, deriveAvailableContexts, getActiveRoutingContexts, getContextRoutingFromMessage, getContextRoutingFromState, mergeContextRouting, parseContextList, parseContextRoutingMetadata, setContextRoutingMetadata, shouldIncludeByContext, } from "./utils/context-routing";
1114
+ export { AVAILABLE_CONTEXTS_STATE_KEY, attachAvailableContexts, CONTEXT_ROUTING_METADATA_KEY, CONTEXT_ROUTING_STATE_KEY, deriveAvailableContexts, getActiveRoutingContexts, getActiveRoutingContextsForTurn, getContextRoutingFromMessage, getContextRoutingFromState, inferContextRoutingFromMessage, inferContextRoutingFromText, mergeContextRouting, parseContextList, parseContextRoutingMetadata, setContextRoutingMetadata, shouldIncludeByContext, } from "./utils/context-routing";
1115
1115
  export { extractAndParseJSONObjectFromText } from "./utils/json-llm";
1116
+ export { extractUserText, getUserMessageText, normalizeUserMessageText, } from "./utils/message-text";
1116
1117
  // `export * from "./utils"` (in index.node.ts etc.) resolves to this file, not
1117
1118
  // to a `./utils/index.ts`. Any helper in the `utils/` directory that needs to be
1118
1119
  // reachable from `@elizaos/core` must be re-exported here.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-composer.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/composites/chat/chat-composer.tsx"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9C,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,CAAC;IACjD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,SAAS,G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ACX,iBAAiB,GAClB,EAAE,iBAAiB,2CA4jBnB"}
1
+ {"version":3,"file":"chat-composer.d.ts","sourceRoot":"","sources":["../../../../../../../src/components/composites/chat/chat-composer.tsx"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiEhD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9C,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,CAAC;IACjD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC9B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,mBAAmB,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