@elizaos/core 2.0.0-alpha.92 → 2.0.0-alpha.93
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/dist/actions.d.ts +11 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/advanced-capabilities/actions/createTask.d.ts +3 -0
- package/dist/advanced-capabilities/actions/createTask.d.ts.map +1 -0
- package/dist/advanced-memory/actions/resetSession.d.ts +11 -0
- package/dist/advanced-memory/actions/resetSession.d.ts.map +1 -0
- package/dist/advanced-memory/services/autoCompaction.d.ts +24 -0
- package/dist/advanced-memory/services/autoCompaction.d.ts.map +1 -0
- package/dist/autonomy/autonomousState.d.ts +5 -0
- package/dist/autonomy/autonomousState.d.ts.map +1 -0
- package/dist/basic-capabilities/actions/status.d.ts +10 -0
- package/dist/basic-capabilities/actions/status.d.ts.map +1 -0
- package/dist/basic-capabilities/providers/capabilities.d.ts +14 -0
- package/dist/basic-capabilities/providers/capabilities.d.ts.map +1 -0
- package/dist/bootstrap/actions/addContact.d.ts +3 -0
- package/dist/bootstrap/actions/addContact.d.ts.map +1 -0
- package/dist/bootstrap/actions/choice.d.ts +3 -0
- package/dist/bootstrap/actions/choice.d.ts.map +1 -0
- package/dist/bootstrap/actions/followRoom.d.ts +3 -0
- package/dist/bootstrap/actions/followRoom.d.ts.map +1 -0
- package/dist/bootstrap/actions/ignore.d.ts +3 -0
- package/dist/bootstrap/actions/ignore.d.ts.map +1 -0
- package/dist/bootstrap/actions/imageGeneration.d.ts +2 -0
- package/dist/bootstrap/actions/imageGeneration.d.ts.map +1 -0
- package/dist/bootstrap/actions/index.d.ts +14 -0
- package/dist/bootstrap/actions/index.d.ts.map +1 -0
- package/dist/bootstrap/actions/muteRoom.d.ts +3 -0
- package/dist/bootstrap/actions/muteRoom.d.ts.map +1 -0
- package/dist/bootstrap/actions/none.d.ts +3 -0
- package/dist/bootstrap/actions/none.d.ts.map +1 -0
- package/dist/bootstrap/actions/removeContact.d.ts +3 -0
- package/dist/bootstrap/actions/removeContact.d.ts.map +1 -0
- package/dist/bootstrap/actions/reply.d.ts +3 -0
- package/dist/bootstrap/actions/reply.d.ts.map +1 -0
- package/dist/bootstrap/actions/resetSession.d.ts +2 -0
- package/dist/bootstrap/actions/resetSession.d.ts.map +1 -0
- package/dist/bootstrap/actions/roles.d.ts +13 -0
- package/dist/bootstrap/actions/roles.d.ts.map +1 -0
- package/dist/bootstrap/actions/scheduleFollowUp.d.ts +3 -0
- package/dist/bootstrap/actions/scheduleFollowUp.d.ts.map +1 -0
- package/dist/bootstrap/actions/searchContacts.d.ts +3 -0
- package/dist/bootstrap/actions/searchContacts.d.ts.map +1 -0
- package/dist/bootstrap/actions/sendMessage.d.ts +14 -0
- package/dist/bootstrap/actions/sendMessage.d.ts.map +1 -0
- package/dist/bootstrap/actions/settings.d.ts +7 -0
- package/dist/bootstrap/actions/settings.d.ts.map +1 -0
- package/dist/bootstrap/actions/status.d.ts +10 -0
- package/dist/bootstrap/actions/status.d.ts.map +1 -0
- package/dist/bootstrap/actions/unfollowRoom.d.ts +13 -0
- package/dist/bootstrap/actions/unfollowRoom.d.ts.map +1 -0
- package/dist/bootstrap/actions/unmuteRoom.d.ts +14 -0
- package/dist/bootstrap/actions/unmuteRoom.d.ts.map +1 -0
- package/dist/bootstrap/actions/updateContact.d.ts +3 -0
- package/dist/bootstrap/actions/updateContact.d.ts.map +1 -0
- package/dist/bootstrap/actions/updateEntity.d.ts +42 -0
- package/dist/bootstrap/actions/updateEntity.d.ts.map +1 -0
- package/dist/bootstrap/evaluators/index.d.ts +2 -0
- package/dist/bootstrap/evaluators/index.d.ts.map +1 -0
- package/dist/bootstrap/evaluators/reflection.d.ts +3 -0
- package/dist/bootstrap/evaluators/reflection.d.ts.map +1 -0
- package/dist/bootstrap/evaluators/relationshipExtraction.d.ts +3 -0
- package/dist/bootstrap/evaluators/relationshipExtraction.d.ts.map +1 -0
- package/dist/bootstrap/index.d.ts +64 -0
- package/dist/bootstrap/index.d.ts.map +1 -0
- package/dist/bootstrap/providers/actionState.d.ts +7 -0
- package/dist/bootstrap/providers/actionState.d.ts.map +1 -0
- package/dist/bootstrap/providers/actions.d.ts +4 -0
- package/dist/bootstrap/providers/actions.d.ts.map +1 -0
- package/dist/bootstrap/providers/attachments.d.ts +20 -0
- package/dist/bootstrap/providers/attachments.d.ts.map +1 -0
- package/dist/bootstrap/providers/capabilities.d.ts +13 -0
- package/dist/bootstrap/providers/capabilities.d.ts.map +1 -0
- package/dist/bootstrap/providers/character.d.ts +17 -0
- package/dist/bootstrap/providers/character.d.ts.map +1 -0
- package/dist/bootstrap/providers/choice.d.ts +10 -0
- package/dist/bootstrap/providers/choice.d.ts.map +1 -0
- package/dist/bootstrap/providers/contacts.d.ts +3 -0
- package/dist/bootstrap/providers/contacts.d.ts.map +1 -0
- package/dist/bootstrap/providers/contextBench.d.ts +12 -0
- package/dist/bootstrap/providers/contextBench.d.ts.map +1 -0
- package/dist/bootstrap/providers/entities.d.ts +7 -0
- package/dist/bootstrap/providers/entities.d.ts.map +1 -0
- package/dist/bootstrap/providers/evaluators.d.ts +3 -0
- package/dist/bootstrap/providers/evaluators.d.ts.map +1 -0
- package/dist/bootstrap/providers/facts.d.ts +11 -0
- package/dist/bootstrap/providers/facts.d.ts.map +1 -0
- package/dist/bootstrap/providers/followUps.d.ts +3 -0
- package/dist/bootstrap/providers/followUps.d.ts.map +1 -0
- package/dist/bootstrap/providers/index.d.ts +16 -0
- package/dist/bootstrap/providers/index.d.ts.map +1 -0
- package/dist/bootstrap/providers/knowledge.d.ts +9 -0
- package/dist/bootstrap/providers/knowledge.d.ts.map +1 -0
- package/dist/bootstrap/providers/providers.d.ts +18 -0
- package/dist/bootstrap/providers/providers.d.ts.map +1 -0
- package/dist/bootstrap/providers/recentMessages.d.ts +14 -0
- package/dist/bootstrap/providers/recentMessages.d.ts.map +1 -0
- package/dist/bootstrap/providers/relationships.d.ts +15 -0
- package/dist/bootstrap/providers/relationships.d.ts.map +1 -0
- package/dist/bootstrap/providers/roles.d.ts +18 -0
- package/dist/bootstrap/providers/roles.d.ts.map +1 -0
- package/dist/bootstrap/providers/settings.d.ts +7 -0
- package/dist/bootstrap/providers/settings.d.ts.map +1 -0
- package/dist/bootstrap/providers/time.d.ts +16 -0
- package/dist/bootstrap/providers/time.d.ts.map +1 -0
- package/dist/bootstrap/providers/world.d.ts +7 -0
- package/dist/bootstrap/providers/world.d.ts.map +1 -0
- package/dist/bootstrap/services/autoCompaction.d.ts +2 -0
- package/dist/bootstrap/services/autoCompaction.d.ts.map +1 -0
- package/dist/browser/index.browser.js +376 -331
- package/dist/browser/index.browser.js.map +11 -11
- package/dist/deterministic.d.ts +31 -0
- package/dist/deterministic.d.ts.map +1 -0
- package/dist/edge/index.edge.js +503 -720
- package/dist/edge/index.edge.js.map +14 -14
- package/dist/generated/action-docs.d.ts.map +1 -1
- package/dist/network/sandbox-fetch-proxy.d.ts +25 -0
- package/dist/network/sandbox-fetch-proxy.d.ts.map +1 -0
- package/dist/node/index.node.js +517 -740
- package/dist/node/index.node.js.map +17 -17
- package/dist/packages/typescript/tsconfig.tsbuildinfo +1 -0
- package/dist/prompts.d.ts +6 -6
- package/dist/prompts.d.ts.map +1 -1
- package/dist/providers/sessionKeys.d.ts +24 -0
- package/dist/providers/sessionKeys.d.ts.map +1 -0
- package/dist/request-context.d.ts +143 -0
- package/dist/request-context.d.ts.map +1 -0
- package/dist/security/sandbox-token-manager.d.ts +33 -0
- package/dist/security/sandbox-token-manager.d.ts.map +1 -0
- package/dist/services/action-filter.d.ts +195 -0
- package/dist/services/action-filter.d.ts.map +1 -0
- package/dist/services/bm25.d.ts +51 -0
- package/dist/services/bm25.d.ts.map +1 -0
- package/dist/services/cosine-similarity.d.ts +5 -0
- package/dist/services/cosine-similarity.d.ts.map +1 -0
- package/dist/services/message.d.ts.map +1 -1
- package/dist/services/triggerScheduling.d.ts +29 -0
- package/dist/services/triggerScheduling.d.ts.map +1 -0
- package/dist/services/triggerWorker.d.ts +17 -0
- package/dist/services/triggerWorker.d.ts.map +1 -0
- package/dist/utils/time-format.d.ts +28 -0
- package/dist/utils/time-format.d.ts.map +1 -0
- package/dist/validation/keywords.d.ts +26 -0
- package/dist/validation/keywords.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/prompts.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const shouldRespondTemplate = "<task>Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>Decide if {{agentName}} should respond to or interact with the conversation.\n\nIMPORTANT RULES FOR RESPONDING:\n- If YOUR name ({{agentName}}) is directly mentioned \u2192 RESPOND\n- If someone uses a DIFFERENT name (not {{agentName}}) \u2192 IGNORE (they're talking to someone else)\n- If you're actively participating in a conversation and the message continues that thread \u2192 RESPOND\n- If someone tells you to stop or be quiet \u2192 STOP\n- Otherwise \u2192 IGNORE\n\nThe key distinction is:\n- \"Talking TO {{agentName}}\" (your name mentioned, replies to you, continuing your conversation) \u2192 RESPOND\n- \"Talking ABOUT {{agentName}}\" or to someone else \u2192 IGNORE\n</instructions>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <name>{{agentName}}</name>\n <reasoning>Your reasoning here</reasoning>\n <action>RESPOND | IGNORE | STOP</action>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
2
|
-
export declare const messageHandlerTemplate = "<task>Generate dialog and actions for the character {{agentName}}.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>\nWrite a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.\n\nIMPORTANT ACTION ORDERING RULES:\n- Actions are executed in the ORDER you list them - the order MATTERS!\n- REPLY should come FIRST to acknowledge the user's request before executing other actions\n- Common patterns:\n - For requests requiring tool use: REPLY,CALL_MCP_TOOL (acknowledge first, then gather info)\n - For task execution: REPLY,
|
|
3
|
-
export declare const postCreationTemplate = "# Task: Create a post in the voice and style and perspective of {{agentName}} @{{xUserName}}.\n\nExample task outputs:\n1. A post about the importance of AI in our lives\n<response>\n <thought>I am thinking about writing a post about the importance of AI in our lives</thought>\n <post>AI is changing the world and it is important to understand how it works</post>\n <imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>\n</response>\n\n2. A post about dogs\n<response>\n <thought>I am thinking about writing a post about dogs</thought>\n <post>Dogs are man's best friend and they are loyal and loving</post>\n <imagePrompt>A dog playing with a ball in a park</imagePrompt>\n</response>\n\n3. A post about finding a new job\n<response>\n <thought>Getting a job is hard, I bet there's a good post in that</thought>\n <post>Just keep going!</post>\n <imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>\n</response>\n\n{{providers}}\n\nWrite a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.\nYour response should be 1, 2, or 3 sentences (choose the length at random).\nYour response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.\n\nYour output should be formatted in XML like this:\n<response>\n <thought>Your thought here</thought>\n <post>Your post text here</post>\n <imagePrompt>Optional image prompt here</imagePrompt>\n</response>\n\nThe \"post\" field should be the post you want to send. Do not including any thinking or internal reflection in the \"post\" field.\nThe \"imagePrompt\" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.\nThe \"thought\" field should be a short description of what the agent is thinking about before responding, including a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.\n\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
|
2
|
+
export declare const messageHandlerTemplate = "<task>Generate dialog and actions for the character {{agentName}}.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>\nWrite a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.\n\nIMPORTANT ACTION ORDERING RULES:\n- Actions are executed in the ORDER you list them - the order MATTERS!\n- REPLY should come FIRST to acknowledge the user's request before executing other actions\n- Common patterns:\n - For requests requiring tool use: REPLY,CALL_MCP_TOOL (acknowledge first, then gather info)\n - For task execution: REPLY,MAIN_TASK_ACTION (acknowledge first, then do the task)\n - For multi-step operations: REPLY,ACTION1,ACTION2,REPLY (acknowledge first, then complete all steps, then acknowledge all done)\n- REPLY is used to acknowledge and inform the user about what you're going to do\n- Follow-up actions execute the actual tasks after acknowledgment\n- Use IGNORE only when you should not respond at all\n- If you use IGNORE, do not include any other actions. IGNORE should be used alone when you should not respond or take any actions.\n\nIMPORTANT ACTION PARAMETERS:\n- When an action has parameters listed in its description, include a <params> block for that action\n- Extract parameter values from the user's message and conversation context\n- Required parameters MUST be provided; optional parameters can be omitted if not mentioned\n- If you cannot determine a required parameter value, ask the user for clarification in your <text>\n\nEXAMPLE (action parameters):\nUser message: \"Send a message to @dev_guru on telegram saying Hello!\"\n<actions>\n <action>\n <name>REPLY</name>\n </action>\n <action>\n <name>SEND_MESSAGE</name>\n <params>\n <targetType>user</targetType>\n <source>telegram</source>\n <target>dev_guru</target>\n <text>Hello!</text>\n </params>\n </action>\n</actions>\n\nIMPORTANT PROVIDER SELECTION RULES:\n- Only include providers if they are needed to respond accurately.\n- If the message mentions images, photos, pictures, attachments, or visual content, OR if you see \"(Attachments:\" in the conversation, you MUST include \"ATTACHMENTS\" in your providers list\n- If the message asks about or references specific people, include \"ENTITIES\" in your providers list \n- If the message asks about relationships or connections between people, include \"RELATIONSHIPS\" in your providers list\n- If the message asks about facts or specific information, include \"FACTS\" in your providers list\n- If the message asks about the environment or world context, include \"WORLD\" in your providers list\n- If no additional context is needed, you may leave the providers list empty.\n\nIMPORTANT CODE BLOCK FORMATTING RULES:\n- If {{agentName}} includes code examples, snippets, or multi-line code in the response, ALWAYS wrap the code with ``` fenced code blocks (specify the language if known, e.g., ```python).\n- ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.\n- If including inline code (short single words or function names), use single backticks (`) as appropriate.\n- This ensures the user sees clearly formatted and copyable code when relevant.\n</instructions>\n\n<keys>\n\"thought\" should be a short description of what the agent is thinking about and planning.\n\"actions\" should be a list of <action> elements IN THE ORDER THEY SHOULD BE EXECUTED (if none, use a single <action><name>IGNORE</name></action>, if simply responding with text, use <action><name>REPLY</name></action>). Each action that requires parameters should include a <params> child element.\n\"providers\" should be a comma-separated list of the providers that {{agentName}} will use to have the right context for responding and acting (NEVER use \"IGNORE\" as a provider - use specific provider names like ATTACHMENTS, ENTITIES, FACTS, KNOWLEDGE, etc.)\n\"text\" should be the text of the next message for {{agentName}} which they will send to the conversation.\n</keys>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <thought>Your thought here</thought>\n <actions>\n <action>\n <name>ACTION1</name>\n <params>\n <paramName1>value1</paramName1>\n <paramName2>value2</paramName2>\n </params>\n </action>\n <action>\n <name>ACTION2</name>\n <params>\n <paramName1>value1</paramName1>\n </params>\n </action>\n </actions>\n <providers>PROVIDER1,PROVIDER2</providers>\n <text>Your response text here</text>\n</response>\n\nThe <params> block inside each <action> is optional - only include it when that action requires input parameters.\nIf an action has no parameters (e.g. REPLY or IGNORE), omit the <params> child entirely.\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
3
|
+
export declare const postCreationTemplate = "# Task: Create a post in the voice and style and perspective of {{agentName}} @{{xUserName}}.\n\nExample task outputs:\n1. A post about the importance of AI in our lives\n<response>\n <thought>I am thinking about writing a post about the importance of AI in our lives</thought>\n <post>AI is changing the world and it is important to understand how it works</post>\n <imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>\n</response>\n\n2. A post about dogs\n<response>\n <thought>I am thinking about writing a post about dogs</thought>\n <post>Dogs are man's best friend and they are loyal and loving</post>\n <imagePrompt>A dog playing with a ball in a park</imagePrompt>\n</response>\n\n3. A post about finding a new job\n<response>\n <thought>Getting a job is hard, I bet there's a good post in that</thought>\n <post>Just keep going!</post>\n <imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>\n</response>\n\n{{providers}}\n\nWrite a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.\nYour response should be 1, 2, or 3 sentences (choose the length at random).\nYour response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.\n\nYour output should be formatted in XML like this:\n<response>\n <thought>Your thought here</thought>\n <post>Your post text here</post>\n <imagePrompt>Optional image prompt here</imagePrompt>\n</response>\n\nThe \"post\" field should be the post you want to send. Do not including any thinking or internal reflection in the \"post\" field.\nThe \"imagePrompt\" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.\nThe \"thought\" field should be a short description of what the agent is thinking about before responding, including a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.\n\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
|
4
4
|
export declare const booleanFooter = "Respond with only a YES or a NO.";
|
|
5
|
-
export declare const imageDescriptionTemplate = "<task>Analyze the provided image and generate a comprehensive description with multiple levels of detail.</task>\n\n<instructions>\nCarefully examine the image and provide:\n1. A concise, descriptive title that captures the main subject or scene\n2. A brief summary description (1-2 sentences) highlighting the key elements\n3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details\n\nBe objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.\n</instructions>\n\n<output>\n\nRespond using XML format like this:\n<response>\n <title>A concise, descriptive title for the image</title>\n <description>A brief 1-2 sentence summary of the key elements in the image</description>\n <text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
5
|
+
export declare const imageDescriptionTemplate = "<task>Analyze the provided image and generate a comprehensive description with multiple levels of detail.</task>\n\n<instructions>\nCarefully examine the image and provide:\n1. A concise, descriptive title that captures the main subject or scene\n2. A brief summary description (1-2 sentences) highlighting the key elements\n3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details\n\nBe objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.\n</instructions>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <title>A concise, descriptive title for the image</title>\n <description>A brief 1-2 sentence summary of the key elements in the image</description>\n <text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
6
6
|
export declare const multiStepDecisionTemplate = "<task>\nDetermine the next step the assistant should take in this conversation to help the user reach their goal.\n</task>\n\n{{recentMessages}}\n\n# Multi-Step Workflow\n\nIn each step, decide:\n\n1. **Which providers (if any)** should be called to gather necessary data.\n2. **Which action (if any)** should be executed after providers return.\n3. Decide whether the task is complete. If so, set `isFinish: true`. Do not select the `REPLY` action; replies are handled separately after task completion.\n\nYou can select **multiple providers** and at most **one action** per step.\n\nIf the task is fully resolved and no further steps are needed, mark the step as `isFinish: true`.\n\n---\n\n{{actionsWithDescriptions}}\n\n{{providersWithDescriptions}}\n\nThese are the actions or data provider calls that have already been used in this run. Use this to avoid redundancy and guide your next move.\n\n{{actionResults}}\n\n<keys>\n\"thought\" Clearly explain your reasoning for the selected providers and/or action, and how this step contributes to resolving the user's request.\n\"action\" Name of the action to execute after providers return (can be empty if no action is needed).\n\"providers\" List of provider names to call in this step (can be empty if none are needed).\n\"isFinish\" Set to true only if the task is fully complete.\n</keys>\n\n\u26A0\uFE0F IMPORTANT: Do **not** mark the task as `isFinish: true` immediately after calling an action. Wait for the action to complete before deciding the task is finished.\n\n<output>\n<response>\n <thought>Your thought here</thought>\n <action>ACTION</action>\n <providers>PROVIDER1,PROVIDER2</providers>\n <isFinish>true | false</isFinish>\n</response>\n</output>";
|
|
7
7
|
export declare const multiStepSummaryTemplate = "<task>\nSummarize what the assistant has done so far and provide a final response to the user based on the completed steps.\n</task>\n\n# Context Information\n{{bio}}\n\n---\n\n{{system}}\n\n---\n\n{{messageDirections}}\n\n# Conversation Summary\nBelow is the user's original request and conversation so far:\n{{recentMessages}}\n\n# Execution Trace\nHere are the actions taken by the assistant to fulfill the request:\n{{actionResults}}\n\n# Assistant's Last Reasoning Step\n{{recentMessage}}\n\n# Instructions\n\n - Review the execution trace and last reasoning step carefully\n\n - Your final output MUST be in this XML format:\n<output>\n<response>\n <thought>Your thought here</thought>\n <text>Your final message to the user</text>\n</response>\n</output>\n";
|
|
8
8
|
export declare const replyTemplate = "# Task: Generate dialog for the character {{agentName}}.\n\n{{providers}}\n\n# Instructions: Write the next message for {{agentName}}.\n\"thought\" should be a short description of what the agent is thinking about and planning.\n\"text\" should be the next message for {{agentName}} which they will send to the conversation.\n\nIMPORTANT CODE BLOCK FORMATTING RULES:\n- If {{agentName}} includes code examples, snippets, or multi-line code in the response, ALWAYS wrap the code with ``` fenced code blocks (specify the language if known, e.g., ```python).\n- ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.\n- If including inline code (short single words or function names), use single backticks (`) as appropriate.\n- This ensures the user sees clearly formatted and copyable code when relevant.\n\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <thought>Your thought here</thought>\n <text>Your message here</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
|
@@ -13,10 +13,10 @@ export declare const updateSettingsTemplate = "# Task: Update settings based on
|
|
|
13
13
|
export declare const updateEntityTemplate = "# Task: Update entity information.\n\n{{providers}}\n\n# Current Entity Information:\n{{entityInfo}}\n\n# Instructions:\nBased on the request, determine what information about the entity should be updated.\nOnly update fields that the user has explicitly requested to change.\n\nRespond using XML format like this:\n<response>\n <thought>Your reasoning for the entity update</thought>\n <entity_id>The entity ID to update</entity_id>\n <updates>\n <field>\n <name>field_name</name>\n <value>new_value</value>\n </field>\n </updates>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above.";
|
|
14
14
|
export declare const optionExtractionTemplate = "# Task: Extract selected task and option from user message\n\n# Available Tasks:\n{{tasks}}\n\n# Recent Messages:\n{{recentMessages}}\n\n# Instructions:\n1. Review the user's message and identify which task and option they are selecting\n2. Match against the available tasks and their options, including ABORT\n3. Return the task ID (shortened UUID) and selected option name exactly as listed above\n4. If no clear selection is made, return null for both fields\n\n\nReturn in XML format:\n<response>\n <taskId>string_or_null</taskId>\n <selectedOption>OPTION_NAME_or_null</selectedOption>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
|
15
15
|
export declare const SHOULD_RESPOND_TEMPLATE = "<task>Decide on behalf of {{agentName}} whether they should respond to the message, ignore it or stop the conversation.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>Decide if {{agentName}} should respond to or interact with the conversation.\n\nIMPORTANT RULES FOR RESPONDING:\n- If YOUR name ({{agentName}}) is directly mentioned \u2192 RESPOND\n- If someone uses a DIFFERENT name (not {{agentName}}) \u2192 IGNORE (they're talking to someone else)\n- If you're actively participating in a conversation and the message continues that thread \u2192 RESPOND\n- If someone tells you to stop or be quiet \u2192 STOP\n- Otherwise \u2192 IGNORE\n\nThe key distinction is:\n- \"Talking TO {{agentName}}\" (your name mentioned, replies to you, continuing your conversation) \u2192 RESPOND\n- \"Talking ABOUT {{agentName}}\" or to someone else \u2192 IGNORE\n</instructions>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <name>{{agentName}}</name>\n <reasoning>Your reasoning here</reasoning>\n <action>RESPOND | IGNORE | STOP</action>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
16
|
-
export declare const MESSAGE_HANDLER_TEMPLATE = "<task>Generate dialog and actions for the character {{agentName}}.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>\nWrite a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.\n\nIMPORTANT ACTION ORDERING RULES:\n- Actions are executed in the ORDER you list them - the order MATTERS!\n- REPLY should come FIRST to acknowledge the user's request before executing other actions\n- Common patterns:\n - For requests requiring tool use: REPLY,CALL_MCP_TOOL (acknowledge first, then gather info)\n - For task execution: REPLY,
|
|
17
|
-
export declare const POST_CREATION_TEMPLATE = "# Task: Create a post in the voice and style and perspective of {{agentName}} @{{xUserName}}.\n\nExample task outputs:\n1. A post about the importance of AI in our lives\n<response>\n <thought>I am thinking about writing a post about the importance of AI in our lives</thought>\n <post>AI is changing the world and it is important to understand how it works</post>\n <imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>\n</response>\n\n2. A post about dogs\n<response>\n <thought>I am thinking about writing a post about dogs</thought>\n <post>Dogs are man's best friend and they are loyal and loving</post>\n <imagePrompt>A dog playing with a ball in a park</imagePrompt>\n</response>\n\n3. A post about finding a new job\n<response>\n <thought>Getting a job is hard, I bet there's a good post in that</thought>\n <post>Just keep going!</post>\n <imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>\n</response>\n\n{{providers}}\n\nWrite a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.\nYour response should be 1, 2, or 3 sentences (choose the length at random).\nYour response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.\n\nYour output should be formatted in XML like this:\n<response>\n <thought>Your thought here</thought>\n <post>Your post text here</post>\n <imagePrompt>Optional image prompt here</imagePrompt>\n</response>\n\nThe \"post\" field should be the post you want to send. Do not including any thinking or internal reflection in the \"post\" field.\nThe \"imagePrompt\" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.\nThe \"thought\" field should be a short description of what the agent is thinking about before responding, including a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.\n\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
|
16
|
+
export declare const MESSAGE_HANDLER_TEMPLATE = "<task>Generate dialog and actions for the character {{agentName}}.</task>\n\n<providers>\n{{providers}}\n</providers>\n\n<instructions>\nWrite a thought and plan for {{agentName}} and decide what actions to take. Also include the providers that {{agentName}} will use to have the right context for responding and acting, if any.\n\nIMPORTANT ACTION ORDERING RULES:\n- Actions are executed in the ORDER you list them - the order MATTERS!\n- REPLY should come FIRST to acknowledge the user's request before executing other actions\n- Common patterns:\n - For requests requiring tool use: REPLY,CALL_MCP_TOOL (acknowledge first, then gather info)\n - For task execution: REPLY,MAIN_TASK_ACTION (acknowledge first, then do the task)\n - For multi-step operations: REPLY,ACTION1,ACTION2,REPLY (acknowledge first, then complete all steps, then acknowledge all done)\n- REPLY is used to acknowledge and inform the user about what you're going to do\n- Follow-up actions execute the actual tasks after acknowledgment\n- Use IGNORE only when you should not respond at all\n- If you use IGNORE, do not include any other actions. IGNORE should be used alone when you should not respond or take any actions.\n\nIMPORTANT ACTION PARAMETERS:\n- When an action has parameters listed in its description, include a <params> block for that action\n- Extract parameter values from the user's message and conversation context\n- Required parameters MUST be provided; optional parameters can be omitted if not mentioned\n- If you cannot determine a required parameter value, ask the user for clarification in your <text>\n\nEXAMPLE (action parameters):\nUser message: \"Send a message to @dev_guru on telegram saying Hello!\"\n<actions>\n <action>\n <name>REPLY</name>\n </action>\n <action>\n <name>SEND_MESSAGE</name>\n <params>\n <targetType>user</targetType>\n <source>telegram</source>\n <target>dev_guru</target>\n <text>Hello!</text>\n </params>\n </action>\n</actions>\n\nIMPORTANT PROVIDER SELECTION RULES:\n- Only include providers if they are needed to respond accurately.\n- If the message mentions images, photos, pictures, attachments, or visual content, OR if you see \"(Attachments:\" in the conversation, you MUST include \"ATTACHMENTS\" in your providers list\n- If the message asks about or references specific people, include \"ENTITIES\" in your providers list \n- If the message asks about relationships or connections between people, include \"RELATIONSHIPS\" in your providers list\n- If the message asks about facts or specific information, include \"FACTS\" in your providers list\n- If the message asks about the environment or world context, include \"WORLD\" in your providers list\n- If no additional context is needed, you may leave the providers list empty.\n\nIMPORTANT CODE BLOCK FORMATTING RULES:\n- If {{agentName}} includes code examples, snippets, or multi-line code in the response, ALWAYS wrap the code with ``` fenced code blocks (specify the language if known, e.g., ```python).\n- ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.\n- If including inline code (short single words or function names), use single backticks (`) as appropriate.\n- This ensures the user sees clearly formatted and copyable code when relevant.\n</instructions>\n\n<keys>\n\"thought\" should be a short description of what the agent is thinking about and planning.\n\"actions\" should be a list of <action> elements IN THE ORDER THEY SHOULD BE EXECUTED (if none, use a single <action><name>IGNORE</name></action>, if simply responding with text, use <action><name>REPLY</name></action>). Each action that requires parameters should include a <params> child element.\n\"providers\" should be a comma-separated list of the providers that {{agentName}} will use to have the right context for responding and acting (NEVER use \"IGNORE\" as a provider - use specific provider names like ATTACHMENTS, ENTITIES, FACTS, KNOWLEDGE, etc.)\n\"text\" should be the text of the next message for {{agentName}} which they will send to the conversation.\n</keys>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <thought>Your thought here</thought>\n <actions>\n <action>\n <name>ACTION1</name>\n <params>\n <paramName1>value1</paramName1>\n <paramName2>value2</paramName2>\n </params>\n </action>\n <action>\n <name>ACTION2</name>\n <params>\n <paramName1>value1</paramName1>\n </params>\n </action>\n </actions>\n <providers>PROVIDER1,PROVIDER2</providers>\n <text>Your response text here</text>\n</response>\n\nThe <params> block inside each <action> is optional - only include it when that action requires input parameters.\nIf an action has no parameters (e.g. REPLY or IGNORE), omit the <params> child entirely.\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
17
|
+
export declare const POST_CREATION_TEMPLATE = "# Task: Create a post in the voice and style and perspective of {{agentName}} @{{xUserName}}.\n\nExample task outputs:\n1. A post about the importance of AI in our lives\n<response>\n <thought>I am thinking about writing a post about the importance of AI in our lives</thought>\n <post>AI is changing the world and it is important to understand how it works</post>\n <imagePrompt>A futuristic cityscape with flying cars and people using AI to do things</imagePrompt>\n</response>\n\n2. A post about dogs\n<response>\n <thought>I am thinking about writing a post about dogs</thought>\n <post>Dogs are man's best friend and they are loyal and loving</post>\n <imagePrompt>A dog playing with a ball in a park</imagePrompt>\n</response>\n\n3. A post about finding a new job\n<response>\n <thought>Getting a job is hard, I bet there's a good post in that</thought>\n <post>Just keep going!</post>\n <imagePrompt>A person looking at a computer screen with a job search website</imagePrompt>\n</response>\n\n{{providers}}\n\nWrite a post that is {{adjective}} about {{topic}} (without mentioning {{topic}} directly), from the perspective of {{agentName}}. Do not add commentary or acknowledge this request, just write the post.\nYour response should be 1, 2, or 3 sentences (choose the length at random).\nYour response should not contain any questions. Brief, concise statements only. The total character count MUST be less than 280. No emojis. Use \\n\\n (double spaces) between statements if there are multiple statements in your response.\n\nYour output should be formatted in XML like this:\n<response>\n <thought>Your thought here</thought>\n <post>Your post text here</post>\n <imagePrompt>Optional image prompt here</imagePrompt>\n</response>\n\nThe \"post\" field should be the post you want to send. Do not including any thinking or internal reflection in the \"post\" field.\nThe \"imagePrompt\" field is optional and should be a prompt for an image that is relevant to the post. It should be a single sentence that captures the essence of the post. ONLY USE THIS FIELD if it makes sense that the post would benefit from an image.\nThe \"thought\" field should be a short description of what the agent is thinking about before responding, including a brief justification for the response. Includate an explanation how the post is relevant to the topic but unique and different than other posts.\n\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
|
18
18
|
export declare const BOOLEAN_FOOTER = "Respond with only a YES or a NO.";
|
|
19
|
-
export declare const IMAGE_DESCRIPTION_TEMPLATE = "<task>Analyze the provided image and generate a comprehensive description with multiple levels of detail.</task>\n\n<instructions>\nCarefully examine the image and provide:\n1. A concise, descriptive title that captures the main subject or scene\n2. A brief summary description (1-2 sentences) highlighting the key elements\n3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details\n\nBe objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.\n</instructions>\n\n<output>\n\nRespond using XML format like this:\n<response>\n <title>A concise, descriptive title for the image</title>\n <description>A brief 1-2 sentence summary of the key elements in the image</description>\n <text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
19
|
+
export declare const IMAGE_DESCRIPTION_TEMPLATE = "<task>Analyze the provided image and generate a comprehensive description with multiple levels of detail.</task>\n\n<instructions>\nCarefully examine the image and provide:\n1. A concise, descriptive title that captures the main subject or scene\n2. A brief summary description (1-2 sentences) highlighting the key elements\n3. An extensive, detailed description that covers all visible elements, composition, lighting, colors, mood, and any other relevant details\n\nBe objective and descriptive. Focus on what you can actually see in the image rather than making assumptions about context or meaning.\n</instructions>\n\n<output>\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <title>A concise, descriptive title for the image</title>\n <description>A brief 1-2 sentence summary of the key elements in the image</description>\n <text>An extensive, detailed description covering all visible elements, composition, lighting, colors, mood, setting, objects, people, activities, and any other relevant details you can observe in the image</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.\n</output>";
|
|
20
20
|
export declare const MULTI_STEP_DECISION_TEMPLATE = "<task>\nDetermine the next step the assistant should take in this conversation to help the user reach their goal.\n</task>\n\n{{recentMessages}}\n\n# Multi-Step Workflow\n\nIn each step, decide:\n\n1. **Which providers (if any)** should be called to gather necessary data.\n2. **Which action (if any)** should be executed after providers return.\n3. Decide whether the task is complete. If so, set `isFinish: true`. Do not select the `REPLY` action; replies are handled separately after task completion.\n\nYou can select **multiple providers** and at most **one action** per step.\n\nIf the task is fully resolved and no further steps are needed, mark the step as `isFinish: true`.\n\n---\n\n{{actionsWithDescriptions}}\n\n{{providersWithDescriptions}}\n\nThese are the actions or data provider calls that have already been used in this run. Use this to avoid redundancy and guide your next move.\n\n{{actionResults}}\n\n<keys>\n\"thought\" Clearly explain your reasoning for the selected providers and/or action, and how this step contributes to resolving the user's request.\n\"action\" Name of the action to execute after providers return (can be empty if no action is needed).\n\"providers\" List of provider names to call in this step (can be empty if none are needed).\n\"isFinish\" Set to true only if the task is fully complete.\n</keys>\n\n\u26A0\uFE0F IMPORTANT: Do **not** mark the task as `isFinish: true` immediately after calling an action. Wait for the action to complete before deciding the task is finished.\n\n<output>\n<response>\n <thought>Your thought here</thought>\n <action>ACTION</action>\n <providers>PROVIDER1,PROVIDER2</providers>\n <isFinish>true | false</isFinish>\n</response>\n</output>";
|
|
21
21
|
export declare const MULTI_STEP_SUMMARY_TEMPLATE = "<task>\nSummarize what the assistant has done so far and provide a final response to the user based on the completed steps.\n</task>\n\n# Context Information\n{{bio}}\n\n---\n\n{{system}}\n\n---\n\n{{messageDirections}}\n\n# Conversation Summary\nBelow is the user's original request and conversation so far:\n{{recentMessages}}\n\n# Execution Trace\nHere are the actions taken by the assistant to fulfill the request:\n{{actionResults}}\n\n# Assistant's Last Reasoning Step\n{{recentMessage}}\n\n# Instructions\n\n - Review the execution trace and last reasoning step carefully\n\n - Your final output MUST be in this XML format:\n<output>\n<response>\n <thought>Your thought here</thought>\n <text>Your final message to the user</text>\n</response>\n</output>\n";
|
|
22
22
|
export declare const REPLY_TEMPLATE = "# Task: Generate dialog for the character {{agentName}}.\n\n{{providers}}\n\n# Instructions: Write the next message for {{agentName}}.\n\"thought\" should be a short description of what the agent is thinking about and planning.\n\"text\" should be the next message for {{agentName}} which they will send to the conversation.\n\nIMPORTANT CODE BLOCK FORMATTING RULES:\n- If {{agentName}} includes code examples, snippets, or multi-line code in the response, ALWAYS wrap the code with ``` fenced code blocks (specify the language if known, e.g., ```python).\n- ONLY use fenced code blocks for actual code. Do NOT wrap non-code text, instructions, or single words in fenced code blocks.\n- If including inline code (short single words or function names), use single backticks (`) as appropriate.\n- This ensures the user sees clearly formatted and copyable code when relevant.\n\nDo NOT include any thinking, reasoning, or <think> sections in your response.\nGo directly to the XML response format without any preamble or explanation.\n\nRespond using XML format like this:\n<response>\n <thought>Your thought here</thought>\n <text>Your message here</text>\n</response>\n\nIMPORTANT: Your response must ONLY contain the <response></response> XML block above. Do not include any text, thinking, or reasoning before or after this XML block. Start your response immediately with <response> and end with </response>.";
|
package/dist/prompts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,49CAgCxB,CAAC;AAEX,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,49CAgCxB,CAAC;AAEX,eAAO,MAAM,sBAAsB,uxKAiGzB,CAAC;AAEX,eAAO,MAAM,oBAAoB,gwFA4C+M,CAAC;AAEjP,eAAO,MAAM,aAAa,qCAAqC,CAAC;AAEhE,eAAO,MAAM,wBAAwB,w8CAuB3B,CAAC;AAEX,eAAO,MAAM,yBAAyB,isDA4C5B,CAAC;AAEX,eAAO,MAAM,wBAAwB,kwBAqCpC,CAAC;AAGF,eAAO,MAAM,aAAa,64CAuBsN,CAAC;AAEjP,eAAO,MAAM,oBAAoB,8hBAiBqD,CAAC;AAEvF,eAAO,MAAM,uBAAuB,ojBAiBkD,CAAC;AAEvF,eAAO,MAAM,kBAAkB,6xBAuBuD,CAAC;AAEvF,eAAO,MAAM,sBAAsB,2lBAsBmD,CAAC;AAEvF,eAAO,MAAM,oBAAoB,+qBAuBqD,CAAC;AAEvF,eAAO,MAAM,wBAAwB,o1BAqB2M,CAAC;AAGjP,eAAO,MAAM,uBAAuB,49CAAwB,CAAC;AAC7D,eAAO,MAAM,wBAAwB,uxKAAyB,CAAC;AAC/D,eA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AACjE,eAAO,MAAM,uBAAuB,shBAAwB,CAAC;AAC7D,eAAO,MAAM,4BAA4B,4rBAA6B,CAAC;AAGvE,eAAO,MAAM,+BAA+B,seAUkC,CAAC;AAE/E,eAAO,MAAM,kCAAkC,2gBAYkB,CAAC;AAElE,eAAO,MAAM,yBAAyB,ulBAWmC,CAAC;AAE1E,eAAO,MAAM,4BAA4B,6nBAaoB,CAAC;AAG9D,eAAO,MAAM,kCAAkC,seACf,CAAC;AACjC,eAAO,MAAM,qCAAqC,2gBACf,CAAC;AACpC,eAAO,MAAM,4BAA4B,ulBAA4B,CAAC;AACtE,eAAO,MAAM,+BAA+B,6nBAA+B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges Milady session keys with ElizaOS rooms.
|
|
3
|
+
*
|
|
4
|
+
* Milady keys: agent:{agentId}:main (DMs), agent:{agentId}:{channel}:group:{id} (groups)
|
|
5
|
+
* ElizaOS rooms: per-agent UUIDs via createUniqueUuid(runtime, channelId)
|
|
6
|
+
*/
|
|
7
|
+
import { type Provider, type Room } from "../types";
|
|
8
|
+
/**
|
|
9
|
+
* Resolve an Milady session key from an ElizaOS room.
|
|
10
|
+
*
|
|
11
|
+
* DMs -> agent:{agentId}:main
|
|
12
|
+
* Groups -> agent:{agentId}:{channel}:group:{groupId}
|
|
13
|
+
* Channels -> agent:{agentId}:{channel}:channel:{channelId}
|
|
14
|
+
* Threads append :thread:{threadId}
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveSessionKeyFromRoom(agentId: string, room: Room, meta?: {
|
|
17
|
+
threadId?: string;
|
|
18
|
+
groupId?: string;
|
|
19
|
+
channel?: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function createSessionKeyProvider(options?: {
|
|
22
|
+
defaultAgentId?: string;
|
|
23
|
+
}): Provider;
|
|
24
|
+
//# sourceMappingURL=sessionKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionKeys.d.ts","sourceRoot":"","sources":["../../src/providers/sessionKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAIL,KAAK,QAAQ,EAEb,KAAK,IAAI,EAEV,MAAM,UAAU,CAAC;AA6ClB;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D,MAAM,CAiBR;AAED,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,QAAQ,CAoDX"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request context management for per-entity settings in multi-tenant deployments.
|
|
3
|
+
*
|
|
4
|
+
* Follows the OpenTelemetry ContextManager pattern (same as streaming-context.ts):
|
|
5
|
+
* - Interface for context management
|
|
6
|
+
* - Platform-specific implementations (Node.js AsyncLocalStorage, Browser Stack)
|
|
7
|
+
* - Global singleton configured at startup
|
|
8
|
+
*
|
|
9
|
+
* This enables sharing a single agent runtime across multiple users while ensuring
|
|
10
|
+
* each user's API keys, OAuth tokens, and configuration are used for their specific requests.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Before processing a user's message
|
|
15
|
+
* const entitySettings = await prefetchEntitySettings(userId, agentId);
|
|
16
|
+
*
|
|
17
|
+
* await runWithRequestContext({
|
|
18
|
+
* entityId: userId,
|
|
19
|
+
* agentId: agentId,
|
|
20
|
+
* entitySettings: new Map([
|
|
21
|
+
* ['OPENAI_API_KEY', 'sk-user-specific-key'],
|
|
22
|
+
* ['TWITTER_ACCESS_TOKEN', 'oauth-token-for-user'],
|
|
23
|
+
* ]),
|
|
24
|
+
* requestStartTime: Date.now(),
|
|
25
|
+
* }, async () => {
|
|
26
|
+
* // All getSetting() calls here check entitySettings first
|
|
27
|
+
* await runtime.handleMessage(message);
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
import type { UUID } from "./types";
|
|
32
|
+
/**
|
|
33
|
+
* The value types that can be stored in entity settings.
|
|
34
|
+
* Matches the return type of getSetting().
|
|
35
|
+
*/
|
|
36
|
+
export type EntitySettingValue = string | boolean | number | null;
|
|
37
|
+
/**
|
|
38
|
+
* Request-scoped context containing per-entity settings.
|
|
39
|
+
* Used to isolate user settings across concurrent requests sharing the same runtime.
|
|
40
|
+
*/
|
|
41
|
+
export interface RequestContext {
|
|
42
|
+
/**
|
|
43
|
+
* The entity (user) ID for this request.
|
|
44
|
+
* Used to identify which user's settings should be used.
|
|
45
|
+
*/
|
|
46
|
+
entityId: UUID;
|
|
47
|
+
/**
|
|
48
|
+
* The agent ID for this request.
|
|
49
|
+
* Used for agent-specific entity settings lookup.
|
|
50
|
+
*/
|
|
51
|
+
agentId: UUID;
|
|
52
|
+
/**
|
|
53
|
+
* Pre-fetched entity-specific settings.
|
|
54
|
+
* These take highest priority in getSetting() resolution chain.
|
|
55
|
+
*
|
|
56
|
+
* The Map contains setting keys and their values:
|
|
57
|
+
* - string/boolean/number: The actual setting value to use
|
|
58
|
+
* - null: Explicitly unset (use agent default)
|
|
59
|
+
* - undefined (key not present): Fall through to agent settings
|
|
60
|
+
*/
|
|
61
|
+
entitySettings: Map<string, EntitySettingValue>;
|
|
62
|
+
/**
|
|
63
|
+
* Request start timestamp for observability and debugging.
|
|
64
|
+
* Useful for tracking request duration and timeout handling.
|
|
65
|
+
*/
|
|
66
|
+
requestStartTime: number;
|
|
67
|
+
/**
|
|
68
|
+
* Optional trace ID for distributed tracing.
|
|
69
|
+
* Can be passed from incoming request headers (e.g., X-Trace-Id).
|
|
70
|
+
*/
|
|
71
|
+
traceId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Optional organization ID for multi-tenant deployments.
|
|
74
|
+
* Used for logging and auditing purposes.
|
|
75
|
+
*/
|
|
76
|
+
organizationId?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Interface for request context managers.
|
|
80
|
+
* Different implementations exist for Node.js (AsyncLocalStorage) and Browser (fallback).
|
|
81
|
+
*/
|
|
82
|
+
export interface IRequestContextManager {
|
|
83
|
+
/**
|
|
84
|
+
* Run a function with a request context.
|
|
85
|
+
* The context will be available to all nested async calls via `active()`.
|
|
86
|
+
*
|
|
87
|
+
* @param context - The request context to make available, or undefined to clear context
|
|
88
|
+
* @param fn - The function to run within the context
|
|
89
|
+
* @returns The result of the function
|
|
90
|
+
*/
|
|
91
|
+
run<T>(context: RequestContext | undefined, fn: () => T): T;
|
|
92
|
+
/**
|
|
93
|
+
* Get the currently active request context.
|
|
94
|
+
* Returns undefined if no context is active (e.g., during plugin init).
|
|
95
|
+
*
|
|
96
|
+
* @returns The current request context or undefined
|
|
97
|
+
*/
|
|
98
|
+
active(): RequestContext | undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Set the global request context manager.
|
|
102
|
+
* Called during initialization by platform-specific entry points.
|
|
103
|
+
*
|
|
104
|
+
* @param manager - The context manager to use globally
|
|
105
|
+
*/
|
|
106
|
+
export declare function setRequestContextManager(manager: IRequestContextManager): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get the global request context manager.
|
|
109
|
+
* Useful for testing or advanced use cases.
|
|
110
|
+
*
|
|
111
|
+
* @returns The current global request context manager
|
|
112
|
+
*/
|
|
113
|
+
export declare function getRequestContextManager(): IRequestContextManager;
|
|
114
|
+
/**
|
|
115
|
+
* Run a function with a request context.
|
|
116
|
+
* All getSetting() calls within this function will check entitySettings first.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const result = await runWithRequestContext({
|
|
121
|
+
* entityId: userId as UUID,
|
|
122
|
+
* agentId: agentId as UUID,
|
|
123
|
+
* entitySettings: new Map([['API_KEY', 'user-specific-key']]),
|
|
124
|
+
* requestStartTime: Date.now(),
|
|
125
|
+
* }, async () => {
|
|
126
|
+
* // Inside here, runtime.getSetting('API_KEY') returns 'user-specific-key'
|
|
127
|
+
* return await runtime.processMessage(message);
|
|
128
|
+
* });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param context - The request context with entitySettings
|
|
132
|
+
* @param fn - The function to run with request context
|
|
133
|
+
* @returns The result of the function
|
|
134
|
+
*/
|
|
135
|
+
export declare function runWithRequestContext<T>(context: RequestContext | undefined, fn: () => T): T;
|
|
136
|
+
/**
|
|
137
|
+
* Get the currently active request context.
|
|
138
|
+
* Called by getSetting() to check for entity-specific settings.
|
|
139
|
+
*
|
|
140
|
+
* @returns The current request context or undefined if not in a request
|
|
141
|
+
*/
|
|
142
|
+
export declare function getRequestContext(): RequestContext | undefined;
|
|
143
|
+
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../src/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,QAAQ,EAAE,IAAI,CAAC;IAEf;;;OAGG;IACH,OAAO,EAAE,IAAI,CAAC;IAEd;;;;;;;;OAQG;IACH,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAEhD;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,MAAM,IAAI,cAAc,GAAG,SAAS,CAAC;CACtC;AAqBD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,sBAAsB,CAEjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,EAAE,EAAE,MAAM,CAAC,GACV,CAAC,CAEH;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAE9D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sandbox secret token manager.
|
|
3
|
+
*
|
|
4
|
+
* Maps real secrets to opaque `stok_` prefixed tokens. Plugins see tokens;
|
|
5
|
+
* the fetch proxy resolves them to real values at the network boundary.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SANDBOX_TOKEN_PREFIX = "stok_";
|
|
8
|
+
export interface SecretTokenMetadata {
|
|
9
|
+
settingKey: string;
|
|
10
|
+
secretType: "api_key" | "oauth_token" | "password" | "private_key" | "other";
|
|
11
|
+
createdAt: number;
|
|
12
|
+
owner?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class SandboxTokenManager {
|
|
15
|
+
private tokenToEntry;
|
|
16
|
+
private realValueToToken;
|
|
17
|
+
private settingKeyToToken;
|
|
18
|
+
/** Register a secret, returning its stable token. Idempotent per key. */
|
|
19
|
+
registerSecret(settingKey: string, realValue: string, metadata?: Partial<SecretTokenMetadata>): string;
|
|
20
|
+
resolveToken(token: string): string | null;
|
|
21
|
+
getTokenForKey(settingKey: string): string | null;
|
|
22
|
+
getTokenForValue(realValue: string): string | null;
|
|
23
|
+
getMetadata(token: string): SecretTokenMetadata | null;
|
|
24
|
+
/** Replace tokens → real values (outbound). */
|
|
25
|
+
detokenizeString(input: string): string;
|
|
26
|
+
/** Replace real values → tokens (inbound). Longest-first to avoid partial matches. */
|
|
27
|
+
tokenizeString(input: string): string;
|
|
28
|
+
static isToken(value: string): boolean;
|
|
29
|
+
get size(): number;
|
|
30
|
+
clear(): void;
|
|
31
|
+
listKeys(): string[];
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=sandbox-token-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-token-manager.d.ts","sourceRoot":"","sources":["../../src/security/sandbox-token-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,YAAY,CAAiC;IACrD,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,iBAAiB,CAA6B;IAEtD,yEAAyE;IACzE,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,MAAM;IAgCT,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAI1C,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIjD,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIlD,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAItD,+CAA+C;IAC/C,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAWvC,sFAAsF;IACtF,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAcrC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAItC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,KAAK,IAAI,IAAI;IAMb,QAAQ,IAAI,MAAM,EAAE;CAGrB"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionFilterService — dynamically filters which actions are shown to the LLM
|
|
3
|
+
* based on relevance to the current message.
|
|
4
|
+
*
|
|
5
|
+
* Two-tier ranking:
|
|
6
|
+
* 1. Vector search: embed action descriptions + similes at registration time.
|
|
7
|
+
* At message time, embed the query (user message + context). Use cosine
|
|
8
|
+
* similarity to get the top candidates.
|
|
9
|
+
* 2. BM25 reranking: rerank the vector-search candidates using BM25
|
|
10
|
+
* (term-frequency * inverse-document-frequency). BM25 is especially good
|
|
11
|
+
* at matching specific keywords that vector search might miss.
|
|
12
|
+
*
|
|
13
|
+
* Graceful degradation:
|
|
14
|
+
* - If the embedding model is unavailable → BM25-only ranking.
|
|
15
|
+
* - If BM25 also fails → return all actions (same as before).
|
|
16
|
+
*/
|
|
17
|
+
import type { Action, IAgentRuntime, Memory, Provider } from "../types/index.ts";
|
|
18
|
+
import { Service } from "../types/service.ts";
|
|
19
|
+
import type { State } from "../types/state.ts";
|
|
20
|
+
declare module "../types/service.ts" {
|
|
21
|
+
interface ServiceTypeRegistry {
|
|
22
|
+
ACTION_FILTER: "action_filter";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export interface RankedAction {
|
|
26
|
+
action: Action;
|
|
27
|
+
/** Cosine similarity against the query embedding (0-1 range, 0 if unavailable). */
|
|
28
|
+
vectorScore: number;
|
|
29
|
+
/** BM25 score against the query text (0+ range, 0 if unavailable). */
|
|
30
|
+
bm25Score: number;
|
|
31
|
+
/** Weighted combination of vectorScore and bm25Score, plus momentum boost. */
|
|
32
|
+
combinedScore: number;
|
|
33
|
+
}
|
|
34
|
+
export interface FilterConfig {
|
|
35
|
+
/** Master switch — if false the service is a no-op. */
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
/** Minimum registered action count before filtering kicks in. */
|
|
38
|
+
threshold: number;
|
|
39
|
+
/** How many candidates to pull from the vector search stage. */
|
|
40
|
+
vectorTopK: number;
|
|
41
|
+
/** Final number of actions returned after reranking. */
|
|
42
|
+
finalTopK: number;
|
|
43
|
+
/** Weight for the normalized vector score in the combined score (0-1). */
|
|
44
|
+
vectorWeight: number;
|
|
45
|
+
/** Weight for the normalized BM25 score in the combined score (0-1). */
|
|
46
|
+
bm25Weight: number;
|
|
47
|
+
/** Action names that always bypass filtering (in addition to per-action alwaysInclude). */
|
|
48
|
+
alwaysIncludeActions: string[];
|
|
49
|
+
/** Time window (ms) for conversation momentum decay. */
|
|
50
|
+
momentumDecayMs: number;
|
|
51
|
+
/** Score boost for recently used actions (0-1). */
|
|
52
|
+
momentumBoost: number;
|
|
53
|
+
}
|
|
54
|
+
export interface FilterMetrics {
|
|
55
|
+
/** Total number of filter() invocations. */
|
|
56
|
+
filterCalls: number;
|
|
57
|
+
/** How many times filtering was actually applied (vs. passthrough). */
|
|
58
|
+
filteredCalls: number;
|
|
59
|
+
/** How many times we fell back to BM25-only (embedding unavailable). */
|
|
60
|
+
bm25OnlyFallbacks: number;
|
|
61
|
+
/** How many times we fell back to returning all actions (complete failure). */
|
|
62
|
+
fullFallbacks: number;
|
|
63
|
+
/** Reported misses — actions that were filtered out but then selected by the LLM. */
|
|
64
|
+
missCount: number;
|
|
65
|
+
/** Names of missed actions for debugging (bounded ring buffer). */
|
|
66
|
+
missedActions: string[];
|
|
67
|
+
/** Average combined-score of returned actions (last call). */
|
|
68
|
+
lastAvgScore: number;
|
|
69
|
+
/** Number of actions in the embedding index. */
|
|
70
|
+
indexedActionCount: number;
|
|
71
|
+
/** Number of actions whose embedding failed during buildIndex or addAction. */
|
|
72
|
+
embedFailureCount: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build a rich text blob from an action's metadata, suitable for both
|
|
76
|
+
* embedding and BM25 indexing.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getActionEmbeddingText(action: Action): string;
|
|
79
|
+
/**
|
|
80
|
+
* Build a text blob from a provider's metadata for BM25 indexing.
|
|
81
|
+
* Includes name, description, and relevanceKeywords.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getProviderIndexText(provider: Provider): string;
|
|
84
|
+
/**
|
|
85
|
+
* Build the query text used for vector + BM25 matching against the action
|
|
86
|
+
* index. Includes the user message, recent conversation context, and any
|
|
87
|
+
* detected intent keywords.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildQueryText(message: Memory, state: State): string;
|
|
90
|
+
/**
|
|
91
|
+
* Normalize an array of scores to [0, 1] using min-max normalization.
|
|
92
|
+
* Returns an array of the same length. If all values are the same,
|
|
93
|
+
* returns an array of 1s (or 0s if all are 0).
|
|
94
|
+
*
|
|
95
|
+
* NaN and Infinity values are sanitized to 0 before normalization.
|
|
96
|
+
*/
|
|
97
|
+
export declare function minMaxNormalize(scores: number[]): number[];
|
|
98
|
+
export declare class ActionFilterService extends Service {
|
|
99
|
+
static serviceType: "action_filter";
|
|
100
|
+
capabilityDescription: string;
|
|
101
|
+
private actionEmbeddings;
|
|
102
|
+
private bm25Index;
|
|
103
|
+
/** Separate BM25 index for provider descriptions, used by filterProviders(). */
|
|
104
|
+
private providerBM25Index;
|
|
105
|
+
private filterConfig;
|
|
106
|
+
private recentActions;
|
|
107
|
+
private readonly maxRecentActions;
|
|
108
|
+
private lastFilteredByRoom;
|
|
109
|
+
private readonly maxTrackedRooms;
|
|
110
|
+
private metrics;
|
|
111
|
+
private embeddingAvailable;
|
|
112
|
+
constructor(runtime?: IAgentRuntime, config?: Partial<FilterConfig>);
|
|
113
|
+
/** Start the service. Reads ACTION_FILTER_* from runtime settings, then builds indices. */
|
|
114
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
115
|
+
stop(): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Build (or rebuild) the vector + BM25 index for all registered actions.
|
|
118
|
+
* Also builds the provider BM25 index for dynamic provider filtering.
|
|
119
|
+
*/
|
|
120
|
+
buildIndex(runtime: IAgentRuntime): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Add a single action to the index at runtime (e.g. when a plugin
|
|
123
|
+
* registers a new action after startup).
|
|
124
|
+
*/
|
|
125
|
+
addAction(action: Action, runtime: IAgentRuntime): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Remove an action from both indices (e.g. when a plugin is unloaded).
|
|
128
|
+
*/
|
|
129
|
+
removeAction(actionName: string): void;
|
|
130
|
+
/**
|
|
131
|
+
* Filter the registered actions to the most relevant subset for this message.
|
|
132
|
+
*
|
|
133
|
+
* Flow:
|
|
134
|
+
* 1. If action count <= threshold → return all (same as validate-all path).
|
|
135
|
+
* 2. Always-include actions bypass filtering and are prepended to results.
|
|
136
|
+
* 3. Vector search: embed query → cosine similarity → top vectorTopK.
|
|
137
|
+
* 4. BM25 rerank: score vectorTopK candidates → combine scores.
|
|
138
|
+
* 5. Apply momentum boost for recently used actions.
|
|
139
|
+
* 6. Return top finalTopK actions.
|
|
140
|
+
*
|
|
141
|
+
* The returned actions have NOT been validated — the caller (actionsProvider)
|
|
142
|
+
* is responsible for running `validate()` on the returned set.
|
|
143
|
+
*/
|
|
144
|
+
filter(runtime: IAgentRuntime, message: Memory, state: State): Promise<Action[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Score providers by relevance to the current message using BM25.
|
|
147
|
+
* Returns provider names sorted by relevance score, highest first.
|
|
148
|
+
* Only scores providers that have been indexed (i.e. have a description).
|
|
149
|
+
*
|
|
150
|
+
* This is used by composeState() to auto-include dynamic providers
|
|
151
|
+
* that are relevant to the current message, without requiring explicit
|
|
152
|
+
* relevanceKeywords on each provider.
|
|
153
|
+
*
|
|
154
|
+
* @param providers - The candidate providers to score (typically dynamic providers).
|
|
155
|
+
* @param message - The current message being processed.
|
|
156
|
+
* @param state - The current state (used to build query context).
|
|
157
|
+
* @param topK - Maximum number of provider names to return (default: 5).
|
|
158
|
+
* @returns Provider names sorted by descending BM25 relevance score.
|
|
159
|
+
*/
|
|
160
|
+
filterProviders(providers: Provider[], message: Memory, state: State, topK?: number): string[];
|
|
161
|
+
/**
|
|
162
|
+
* Record that an action was used, so future queries in the same room
|
|
163
|
+
* receive a momentum boost for that action.
|
|
164
|
+
*/
|
|
165
|
+
recordActionUse(actionName: string, roomId: string): void;
|
|
166
|
+
getMetrics(): FilterMetrics;
|
|
167
|
+
reportMiss(actionName: string): void;
|
|
168
|
+
hasAction(actionName: string): boolean;
|
|
169
|
+
getConfig(): Readonly<FilterConfig>;
|
|
170
|
+
/**
|
|
171
|
+
* Check whether an action was in the most recent filtered set for a room.
|
|
172
|
+
* Returns `true` if filtering was active for that room and the action
|
|
173
|
+
* WAS in the filtered set, `false` if it was filtered OUT, or `null` if
|
|
174
|
+
* filtering wasn't active for that room (so the caller should skip
|
|
175
|
+
* false-negative reporting).
|
|
176
|
+
*/
|
|
177
|
+
wasActionInFilteredSet(actionName: string, roomId: string): boolean | null;
|
|
178
|
+
/**
|
|
179
|
+
* Override the tracked action set for a room with the exact list that was
|
|
180
|
+
* presented in the prompt. This keeps miss detection accurate when callers
|
|
181
|
+
* use filter() for ranking but still include additional actions.
|
|
182
|
+
*/
|
|
183
|
+
setRoomActionSet(roomId: string, actionNames: Iterable<string>): void;
|
|
184
|
+
/**
|
|
185
|
+
* Run the full two-tier ranking pipeline on a set of candidate actions.
|
|
186
|
+
* Returns RankedAction[] sorted by combinedScore descending.
|
|
187
|
+
*/
|
|
188
|
+
private rankActions;
|
|
189
|
+
/**
|
|
190
|
+
* Compute per-action momentum boosts based on recently used actions
|
|
191
|
+
* in the same room as the current message.
|
|
192
|
+
*/
|
|
193
|
+
private computeMomentumBoosts;
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=action-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-filter.d.ts","sourceRoot":"","sources":["../../src/services/action-filter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,MAAM,EACN,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,mBAAmB;QAC3B,aAAa,EAAE,eAAe,CAAC;KAChC;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,OAAO,EAAE,OAAO,CAAC;IACjB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,wDAAwD;IACxD,eAAe,EAAE,MAA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OAIG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI;IAUrE;;;OAGG;YACW,WAAW;IAyIzB;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CA6B9B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BM25 index with incremental add/remove support.
|
|
3
|
+
*
|
|
4
|
+
* Uses the shared Tokenizer from search.ts as the primary text processor
|
|
5
|
+
* (Unicode normalization, optional Porter2 stemming, configurable stopwords).
|
|
6
|
+
* Falls back to a unicode-aware regex tokenizer for scripts the shared
|
|
7
|
+
* Tokenizer doesn't cover (Cyrillic, Arabic, etc.).
|
|
8
|
+
*
|
|
9
|
+
* Scoring formula:
|
|
10
|
+
* score(q, d) = Σ IDF(qi) * (f(qi, d) * (k1 + 1)) / (f(qi, d) + k1 * (1 - b + b * |d| / avgdl))
|
|
11
|
+
*/
|
|
12
|
+
import { type TokenizerOptions } from "../search.ts";
|
|
13
|
+
export interface BM25Result {
|
|
14
|
+
id: string;
|
|
15
|
+
score: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* BM25 index for text documents with incremental add/remove.
|
|
19
|
+
*
|
|
20
|
+
* Primary tokenization: shared Tokenizer (stemming, Unicode normalization).
|
|
21
|
+
* Fallback: unicode-aware regex split for scripts the Tokenizer strips
|
|
22
|
+
* (Cyrillic, Arabic, Devanagari, etc.). The fallback tokens are merged
|
|
23
|
+
* with the primary tokens so all scripts are searchable.
|
|
24
|
+
*/
|
|
25
|
+
export declare class BM25Index {
|
|
26
|
+
private documents;
|
|
27
|
+
private documentFrequencies;
|
|
28
|
+
private avgDocLength;
|
|
29
|
+
private totalTermCount;
|
|
30
|
+
private k1;
|
|
31
|
+
private b;
|
|
32
|
+
private sharedTokenizer;
|
|
33
|
+
private stopWords;
|
|
34
|
+
constructor(k1?: number, b?: number, tokenizerOptions?: TokenizerOptions);
|
|
35
|
+
addDocument(id: string, text: string): void;
|
|
36
|
+
removeDocument(id: string): void;
|
|
37
|
+
search(query: string, topK?: number): BM25Result[];
|
|
38
|
+
searchSubset(query: string, documentIds: string[], topK?: number): BM25Result[];
|
|
39
|
+
get size(): number;
|
|
40
|
+
has(id: string): boolean;
|
|
41
|
+
private scoreDocument;
|
|
42
|
+
private recomputeAvgDocLength;
|
|
43
|
+
/**
|
|
44
|
+
* Tokenize text using the shared Tokenizer (for English, CJK, Hangul)
|
|
45
|
+
* merged with a unicode-aware regex fallback (for Cyrillic, Arabic, etc.).
|
|
46
|
+
* This ensures all scripts are searchable while still benefiting from
|
|
47
|
+
* the Tokenizer's stemming and normalization for supported scripts.
|
|
48
|
+
*/
|
|
49
|
+
private tokenize;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=bm25.d.ts.map
|