UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

148 lines (147 loc) • 9.2 kB
import { CYBER_RISK, executionEnvironmentBlockFor, URL_SAFETY, SUMMARIZE_TOOL_RESULTS, WORKTREE_NOTICE, SUBAGENT_CONSENT_NOTICE, SUBAGENT_DELIVERY_NOTES, harnessHeadLines, } from "../../prompts/default.js"; import { GOAL_COMPLETION_GUIDANCE, ORCHESTRATION_AWARENESS, ORCHESTRATION_GUIDANCE, ORCHESTRATION_GUIDANCE_DEFERRED, SUPERVISOR_PROMPT, } from "../../prompts/supervisor.js"; import { TEAMMATE_COMMUNICATION_ADDENDUM } from "../../prompts/coordinator.js"; import { reminderMarkDeclaration } from "../../core/reminder-mint.js"; import { SIMPLE_ACTION_CAUTION, SIMPLE_ACT_DONT_REDERIVE, SIMPLE_AUTONOMY_FABLE, SIMPLE_COMMUNICATING_FABLE, SIMPLE_CORRECTIONS_FABLE, SIMPLE_DELIVERING_WORK_FABLE, SIMPLE_COMMUNICATING_LEAN, SIMPLE_CONTEXT_MANAGEMENT, SIMPLE_PRONOUNS, SIMPLE_TOOL_PARAM_JSON, SEMA_VERIFY_FRESH, SEMA_EVIDENCE_AUDIT, } from "../../prompts/simple-sections.js"; function harnessHeadText(inputs) { return harnessHeadLines(inputs.facts); } const CORE = { owner: "core", trust: "locked", mutability: "locked", cadence: "epoch", cacheClass: "prefix-stable", carrier: "system.block", }; const MODE = { ...CORE, trust: "operator", mutability: "selectable" }; export const SEMA_DEFAULT_PACK = { packId: "sema-default@1", assemblyApi: 1, sections: [ { id: "core/role.base", slot: "identity", rank: 100, owner: "deployment", trust: "operator", mutability: "replaceable", cadence: "epoch", cacheClass: "prefix-stable", carrier: "system.block", content: (i) => i.roleBase, blockId: "role.base", }, { id: "core/harness.head", slot: "harness", rank: 200, ...CORE, content: harnessHeadText, blockId: "harness.context" }, { id: "core/security.cyber-risk", slot: "security", rank: 210, ...CORE, content: () => CYBER_RISK, blockId: "harness.context" }, { id: "core/security.url-safety", slot: "security", rank: 220, ...CORE, content: () => URL_SAFETY, blockId: "harness.context" }, { id: "core/harness.tool-result-retention", slot: "harness", rank: 230, ...CORE, content: () => SUMMARIZE_TOOL_RESULTS, blockId: "harness.context" }, { id: "core/harness.execution-environment", slot: "harness", rank: 240, ...CORE, admit: (i) => i.facts.policyEnabled || i.facts.isolationEnabled, content: (i) => executionEnvironmentBlockFor({ readOpen: i.facts.readFaceOpen === true, writeOpen: i.facts.writeFaceOpen === true }), blockId: "harness.context", }, { id: "core/simple.communicating", slot: "harness", rank: 250, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: (i) => (i.facts.fableMitigations === true ? SIMPLE_COMMUNICATING_FABLE : SIMPLE_COMMUNICATING_LEAN), blockId: "harness.context" }, { id: "core/simple.pronouns", slot: "harness", rank: 252, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: () => SIMPLE_PRONOUNS, blockId: "harness.context" }, { id: "core/simple.action-caution", slot: "harness", rank: 254, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: () => SIMPLE_ACTION_CAUTION, blockId: "harness.context" }, { id: "core/simple.tool-param-json", slot: "harness", rank: 258, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: () => SIMPLE_TOOL_PARAM_JSON, blockId: "harness.context" }, { id: "core/simple.context-management", slot: "harness", rank: 262, ...CORE, admit: (i) => i.facts.promptProfile !== "classic" && i.facts.withinTaskCompactionEnabled, content: () => SIMPLE_CONTEXT_MANAGEMENT, blockId: "harness.context" }, { id: "core/simple.act-dont-rederive", slot: "harness", rank: 264, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: () => SIMPLE_ACT_DONT_REDERIVE, blockId: "harness.context" }, { id: "core/simple.delivering-work", slot: "harness", rank: 265, ...CORE, admit: (i) => i.facts.promptProfile !== "classic" && i.facts.fableMitigations === true, content: () => SIMPLE_DELIVERING_WORK_FABLE, blockId: "harness.context" }, { id: "core/simple.corrections", slot: "harness", rank: 267, ...CORE, admit: (i) => i.facts.promptProfile !== "classic" && i.facts.fableMitigations === true, content: () => SIMPLE_CORRECTIONS_FABLE, blockId: "harness.context" }, { id: "core/simple.autonomy", slot: "harness", rank: 270, ...CORE, admit: (i) => i.facts.promptProfile !== "classic" && i.facts.fableMitigations === true, content: () => SIMPLE_AUTONOMY_FABLE, blockId: "harness.context" }, { id: "core/sema.verify-fresh", slot: "harness", rank: 272, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: () => SEMA_VERIFY_FRESH, blockId: "harness.context" }, { id: "core/sema.evidence-audit", slot: "harness", rank: 274, ...CORE, admit: (i) => i.facts.promptProfile !== "classic", content: () => SEMA_EVIDENCE_AUDIT, blockId: "harness.context" }, { id: "core/mode.subagent-consent", slot: "scenario", rank: 280, ...CORE, admit: (i) => i.facts.isSubagent === true, content: () => SUBAGENT_CONSENT_NOTICE, blockId: "mode.subagent-consent" }, { id: "core/mode.subagent-notes", slot: "scenario", rank: 282, ...CORE, admit: (i) => i.facts.isSubagent === true, content: () => SUBAGENT_DELIVERY_NOTES, blockId: "mode.subagent-notes" }, { id: "core/mode.supervisor", slot: "mode", rank: 300, ...MODE, admit: (i) => i.facts.supervisorEnabled, content: () => SUPERVISOR_PROMPT, blockId: "mode.supervisor" }, { id: "core/mode.orchestration", slot: "mode", rank: 310, ...MODE, admit: (i) => i.facts.orchestrationEnabled, content: (i) => (i.facts.orchestrationDeferred === true ? ORCHESTRATION_GUIDANCE_DEFERRED : ORCHESTRATION_GUIDANCE), blockId: "mode.orchestration" }, { id: "core/mode.awareness", slot: "mode", rank: 320, ...MODE, admit: (i) => i.facts.awarenessEnabled, content: () => ORCHESTRATION_AWARENESS, blockId: "mode.awareness" }, { id: "core/mode.worktree", slot: "mode", rank: 330, ...MODE, admit: (i) => i.facts.worktreeIsolated, content: () => WORKTREE_NOTICE, blockId: "mode.worktree" }, { id: "core/mode.goal", slot: "mode", rank: 340, ...MODE, admit: (i) => i.facts.goalEnabled, content: () => GOAL_COMPLETION_GUIDANCE, blockId: "mode.goal" }, { id: "core/role.append", slot: "scenario", rank: 400, owner: "deployment", trust: "operator", mutability: "append-only", cadence: "epoch", cacheClass: "prefix-stable", carrier: "system.block", content: (i) => i.roleAppend, blockId: "role.append", }, { id: "core/mode.teammate", slot: "scenario", rank: 405, ...CORE, admit: (i) => i.facts.teammateEnabled, content: () => TEAMMATE_COMMUNICATION_ADDENDUM, blockId: "mode.teammate" }, { id: "core/discovery.mcp-instructions", slot: "discovery", rank: 500, owner: "extension", trust: "external", mutability: "locked", cadence: "epoch", cacheClass: "prefix-stable", carrier: "system.block", content: (i) => i.mcpInstructionsBlock, blockId: "mcp.instructions", }, { id: "core/harness.reminder-mark", slot: "harness", rank: 590, owner: "core", trust: "locked", mutability: "locked", cadence: "epoch", cacheClass: "epoch-stable", carrier: "system.block", admit: (i) => i.facts.reminderMark !== undefined, content: (i) => (i.facts.reminderMark !== undefined ? reminderMarkDeclaration(i.facts.reminderMark) : undefined), blockId: "harness.reminder-mark", }, { id: "core/environment.context", slot: "environment", rank: 600, owner: "core", trust: "locked", mutability: "locked", cadence: "run", cacheClass: "volatile", carrier: "system.block", content: (i) => i.environmentBlock, blockId: "env.context", }, { id: "core/memory.tail", slot: "memory", rank: 700, owner: "session", trust: "user-derived", mutability: "locked", cadence: "run", cacheClass: "volatile", carrier: "system.block", content: (i) => i.memoryBlock, blockId: "memory.tail", }, { id: "core/behavior.model-guidance", slot: "behavior", rank: 450, owner: "core", trust: "operator", mutability: "selectable", cadence: "epoch", cacheClass: "prefix-stable", carrier: "system.block", content: (i) => i.modelGuidance, blockId: "model.guidance", }, ], };