UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

72 lines (71 loc) • 9.79 kB
const engineMessage = (id, text, attribution) => ({ id, variants: [{ id: "default", when: {}, text }], attribution }); const headlineRow = (id, text) => ({ id, variants: [{ id: "default", when: {}, text }], attribution: SEMA, securityBearing: true }); const SEMA = { form: "sema-owned" }; const MCP_DELTA = { form: "verbatim", cc: ["cli316.js B[22433497,22433900) `mcp_instructions_delta`"] }; const TOOL_MISS = { form: "adapted", cc: ['cli316.js B[26552585,26552700) "No such tool available"'] }; const WORKFLOW_SIZE = { form: "verbatim", cc: ['cli321.js:280086 "This is a guideline, not a hard limit"'] }; const SHELL_ABSENT_WAY_OUT = "this is the deployment's setup, which no command can change — carry on with the tools listed below, and tell the user if the task needs a shell"; const DEGENERATE_RECOVERY = "Your previous reply degenerated into repetition and was cut off. Do NOT repeat or continue that text. Take a DIFFERENT approach: state your next concrete step or conclusion in one short sentence, then proceed normally."; export const ENGINE_MESSAGES = Object.freeze([ engineMessage("core/engine.mcp-header", "# MCP Server Instructions", MCP_DELTA), engineMessage("core/engine.mcp-intro", "The following MCP servers have provided instructions for how to use their tools and resources:", MCP_DELTA), engineMessage("core/engine.mcp-disconnected", "The following MCP servers have disconnected. Their instructions above no longer apply:", MCP_DELTA), engineMessage("core/engine.mcp-entry-truncated", "(Truncated by the agent runtime: this server's instructions exceeded {{max}} characters.)", SEMA), { ...engineMessage("core/engine.mcp-authorization-place", "where the host shows the server's authorization prompt", SEMA), securityBearing: true }, engineMessage("core/engine.degenerate-recovery", DEGENERATE_RECOVERY, SEMA), engineMessage("core/engine.tool-not-found", "Tool {{name}} not found.", TOOL_MISS), engineMessage("core/engine.tool-not-found-retired", "Tool {{name}} not found. That name is retired: {{detail}}.", TOOL_MISS), engineMessage("core/engine.tool-not-found-unmounted", "Tool {{name}} not found. It is not offered here: {{detail}}.", TOOL_MISS), engineMessage("core/engine.model-shell-absent-undeclared", `the execution environment does not start the model's commands (it declares no ExecutionEnv.modelShell); ${SHELL_ABSENT_WAY_OUT}`, SEMA), engineMessage("core/engine.model-shell-absent-unavailable", `the execution environment does not start the model's commands (its start is unavailable); ${SHELL_ABSENT_WAY_OUT}`, SEMA), engineMessage("core/engine.model-shell-absent-unavailable-cause", `the execution environment does not start the model's commands (its start is unavailable: {{cause}}); ${SHELL_ABSENT_WAY_OUT}`, SEMA), engineMessage("core/engine.roster-recovery", "Available tools: {{listing}}", SEMA), engineMessage("core/engine.roster-recovery-search", "Available tools: {{listing}}. Use {{search}} to look up a tool by name.", SEMA), engineMessage("core/engine.roster-listing-withheld", "{{shown}} … and {{withheld}} more", SEMA), engineMessage("core/engine.image-prefix-one", "[Image from tool result {{ids}}]", SEMA), engineMessage("core/engine.image-prefix-many", "[Images from tool result {{ids}}]", SEMA), engineMessage("core/engine.continuation-continuing", "The response stopped arriving before it finished. Asking the model to continue it.", SEMA), engineMessage("core/engine.continuation-recovered", "The cut response was continued.", SEMA), engineMessage("core/engine.continuation-gave-up", "The response stopped arriving and could not be continued. The answer above may be incomplete.", SEMA), headlineRow("core/engine.ask-headline.hook", "A check this deployment runs before tools wants you to decide this step."), headlineRow("core/engine.ask-headline.ancestor", "The agent that started this one needs your approval for this step."), headlineRow("core/engine.ask-headline.dangerous_delete", "This deletes a top-level, home or workspace folder, or a folder that holds one."), headlineRow("core/engine.ask-headline.unverifiable_delete", "This deletes files, and the command does not say which ones."), headlineRow("core/engine.ask-headline.unverifiable_shell_text", "The engine cannot read exactly what this command will run, so it cannot be checked first."), headlineRow("core/engine.ask-headline.transcript_write", "This changes the record of this session's own conversation."), headlineRow("core/engine.ask-headline.org_rule", "Your organization's policy asks for your approval here."), headlineRow("core/engine.ask-headline.org_unreadable", "Your organization's policy cannot be read right now, so you are asked to approve this step instead."), headlineRow("core/engine.ask-headline.rule_unreadable", "A permission rule that may cover this could not be read, so you are asked instead."), headlineRow("core/engine.ask-headline.call_unreadable", "This step could not be checked against a permission rule that may cover it, so you are asked instead."), headlineRow("core/engine.ask-headline.ask_rule", "A rule in the settings asks before steps like this."), headlineRow("core/engine.ask-headline.denial_limit_fallback", "Automatic approval has turned down as many steps as this session allows, so this one comes to you."), headlineRow("core/engine.ask-headline.classifier_no_ruling", "Automatic approval could not decide on this step, so it comes to you."), headlineRow("core/engine.ask-headline.requires_user_interaction", "This tool says you have to take part in this step."), headlineRow("core/engine.ask-headline.cross_boundary", "This session may run on a device outside the deployment's trusted network, and this step may cross between the two."), headlineRow("core/engine.ask-headline.operator_forced", "This deployment marks steps like this as needing your approval."), headlineRow("core/engine.ask-headline.shell_floor", "This deployment asks you before every command."), headlineRow("core/engine.ask-headline.target_unresolved", "Where this writes cannot be worked out before it runs."), headlineRow("core/engine.ask-headline.probe", "This may reach outside this session's folders or be hard to undo, and a check could not rule that out."), headlineRow("core/engine.ask-headline.write_protection_on_disk", "This writes to a protected file through a link or another spelling of its path."), headlineRow("core/engine.ask-headline.write_protection", "This writes to a protected file, such as the agent's own settings."), headlineRow("core/engine.ask-headline.tool_marks_mcp", "The tool's server marks this as sending data out or as not undoable."), headlineRow("core/engine.ask-headline.tool_marks_a2a", "This sends a request to another agent service, which may act on it."), headlineRow("core/engine.ask-headline.unfinished_check", "The permission check for this command did not finish, so its safety checks did not run."), headlineRow("core/engine.ask-headline.policy_rra", "This deployment's policy asks for your approval here."), headlineRow("core/engine.ask-headline.artifact_shared_read", "This reads something another task shared."), headlineRow("core/engine.ask-headline.mode", "Your current permission mode asks before this step."), headlineRow("core/engine.ask-headline.a2a_inside", "This sends a request to an agent service registered inside your organization, which may act on it."), headlineRow("core/engine.ask-headline.sandbox_override", "This command asks to run outside the sandbox, without its limits on files and the network."), headlineRow("core/engine.ask-headline.sandbox_network", "A command running in the sandbox wants to connect to a host the sandbox's network settings do not list."), headlineRow("core/engine.ask-headline.unstated", "This tool does not say what it needs permission for, so you are asked."), headlineRow("core/engine.ask-headline.ordinary", "No rule or check singled this step out — steps like it are just not allowed on their own yet."), headlineRow("core/engine.ask-headline-remedy.rule-clears", "Saving an allow rule for it would stop it being asked again."), headlineRow("core/engine.ask-headline-remedy.rule-cannot", "Saving an allow rule would not stop it being asked again."), headlineRow("core/engine.ask-headline-remedy.rule-clears-bound", "Saving an allow rule bound to this service's current identity would stop it being asked again, until that identity changes."), headlineRow("core/engine.ask-headline-remedy.probe", "Allowing this command, or the whole tool, would not stop it being asked again. If it is asked only because it reads outside this session's folders, adding the folder to this session would, and so would a saved read rule `Read(//<folder>/**)`, or `Read(//<file>)` naming the file itself (not a link to it) — though not the file rule while an organization's, an operator's or the active skills' rules over reads are in force, and neither under an organization rule that refuses reads. On a task that refuses reads outside its directories, none of them would."), headlineRow("core/engine.ask-headline-join", "{{why}} {{remedy}}"), engineMessage("core/engine.mcp-fence-label", 'MCP server "{{server}}" instructions', SEMA), engineMessage("core/engine.workflow-size.tier", "{{size}} — keep workflows under {{cap}} agents", WORKFLOW_SIZE), engineMessage("core/engine.workflow-size.not-hard-limit", "This is a guideline, not a hard limit — follow it unless the user's prompt calls for a different scale.", WORKFLOW_SIZE), headlineRow("core/engine.ask-outside-sandbox", "Runs outside the sandbox. {{rest}}"), ]);