Skip to content

@arivie/agent

@arivie/agent builds the Mastra Agent with analytics and workspace tools attached directly. Single-agent architecture — no supervisor, no sub-agents.

import { makeAgent } from "@arivie/agent";
const agent = makeAgent({
ownerId: "acme",
model: google("gemini-2.5-flash"),
semantic, // SemanticLayer
contextMode: "preload", // "preload" | "indexed"
sources, // resolved source adapters
sourceMetadata, // descriptions for system prompt
workspace, // Mastra Workspace
skillsProcessor, // skill loader
skillsMode: "auto", // "eager" | "on-demand" | "auto"
compileMetric: true,
limits: { rowsPerQuery: 5000 },
hooks: { onToolCall: async (e) => audit(e) },
});

You typically don’t call makeAgent directly — defineArivie calls it for you. Use this reference to understand the parameters.

ModeBehavior
preloadFull semantic layer in system prompt. Best for fewer than ~30 entities.
indexedEmbedding-based retrieval. Requires vector store + embeddings config.

autoDetectMode(semantic) picks the mode based on token count.

ToolConditionPurpose
execute_<source>Always (one per source)Read-only SQL execution
compile_metriccompileMetric: trueCanonical metric definitions
mastra_workspace_write_fileWorkspace configuredWrite files
mastra_workspace_read_fileWorkspace configuredRead files
mastra_workspace_grepWorkspace configuredSearch file contents
mastra_workspace_list_filesWorkspace configuredList directory
mastra_workspace_edit_fileWorkspace configuredFind/replace in file
mastra_workspace_mkdirWorkspace configuredCreate directory
mastra_workspace_deleteWorkspace configuredDelete file/directory
mastra_workspace_file_statWorkspace configuredFile metadata
workspace_bashbash: trueShell access in sandbox
finalize_reportSandbox FSReport completion signal
search_skills / load_skill / skill_readskillsMode: "on-demand"Lazy skill loading

The agent’s system prompt is built from composable constants exported by @arivie/agent:

ExportPurpose
buildSystemPrompt(opts)Assembles the full system prompt
buildSystemPromptIndexed(opts)Indexed-mode variant
WORKSPACE_NAVIGATION_RULEInstructs agent on workspace usage
ASSUMPTION_STATING_RULE”State assumptions explicitly” rule
SELF_CORRECTION_RULESZero-row / all-null / implausible checks
SKILL_DISCIPLINE_EAGERSkill-following rules (eager mode)
SKILL_DISCIPLINE_ONDEMANDSkill-loading rules (on-demand mode)

validateExecuteSql(sql) from @arivie/db-postgres uses a state-machine token scanner to enforce:

  • Must start with SELECT or WITH
  • No multi-statement queries
  • No CTE-DML hybrids
  • No DML/DDL operations
  • ContextMode = "preload" | "indexed"
  • SkillsMode = "eager" | "on-demand" | "none"
  • MakeAgentOptions — full options interface