mavis_session_new
Create a new standalone Mavis session for isolated tasks. Use --from root to ensure independence from any parent session.
Instructions
Create a new standalone Mavis session (use --from root for isolated, independent session). For child sessions linked to a parent, use mavis_spawn_worker instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent | Yes | Agent name (e.g. mavis, coder, general, verifier) | |
| prompt | No | Initial prompt to send to the new session | |
| title | No | Optional session title | |
| workspace | No | Session workspace directory path | |
| model | No | Override LLM model (providerID/modelID format) |
Implementation Reference
- src/index.js:142-159 (registration)Tool registration entry in the tools array. Defines name, description, inputSchema (zod validation), and buildArgs for the mavis_session_new tool.
{ name: 'mavis_session_new', description: 'Create a new standalone Mavis session (use --from root for isolated, independent session). For child sessions linked to a parent, use mavis_spawn_worker instead.', inputSchema: z.object({ agent: z.string().describe('Agent name (e.g. mavis, coder, general, verifier)'), prompt: z.string().optional().describe('Initial prompt to send to the new session'), title: z.string().optional().describe('Optional session title'), workspace: z.string().optional().describe('Session workspace directory path'), model: z.string().optional().describe('Override LLM model (providerID/modelID format)') }), buildArgs: ({ agent, prompt, title, workspace, model }) => { const args = ['session', 'new', agent, '--from', 'root', '--prompt', prompt || 'hello']; if (title) args.push('--title', title); if (workspace) args.push('--workspace', workspace); if (model) args.push('--model', model); return args; } }, - src/index.js:145-151 (schema)Input validation schema using zod for mavis_session_new. Validates: agent (required string), prompt (optional string), title (optional string), workspace (optional string), model (optional string).
inputSchema: z.object({ agent: z.string().describe('Agent name (e.g. mavis, coder, general, verifier)'), prompt: z.string().optional().describe('Initial prompt to send to the new session'), title: z.string().optional().describe('Optional session title'), workspace: z.string().optional().describe('Session workspace directory path'), model: z.string().optional().describe('Override LLM model (providerID/modelID format)') }), - src/index.js:152-158 (handler)buildArgs function that constructs CLI arguments for the Mavis CLI binary. Calls `session new <agent> --from root --prompt <prompt>` with optional --title, --workspace, --model flags. Default prompt is 'hello'.
buildArgs: ({ agent, prompt, title, workspace, model }) => { const args = ['session', 'new', agent, '--from', 'root', '--prompt', prompt || 'hello']; if (title) args.push('--title', title); if (workspace) args.push('--workspace', workspace); if (model) args.push('--model', model); return args; } - src/index.js:77-92 (helper)runTool function — the generic handler runner that uses buildArgs from the tool spec, calls execMavis or execMavisJSON, formats output as text or raw.
function runTool(spec, parsedArgs) { const { execFn, outputMode, stdin, buildArgs } = spec; const args = buildArgs(parsedArgs); const input = typeof stdin === 'function' ? stdin(parsedArgs) : stdin; const execPromise = execFn ? execMavis(args, input || '') : execMavisJSON(args); return execPromise.then(result => { const text = outputMode === OUTPUT_RAW ? (result || '') : JSON.stringify(result, null, 2); return [{ type: 'text', text }]; }); } - src/index.js:32-53 (helper)execMavis helper — spawns the Mavis CLI binary with given args, optionally injecting parent session ID via --session flag.
function execMavis(args, input = '') { return new Promise((resolve, reject) => { const SESSION_COMMANDS = new Set(['communication', 'session', 'spawn']); const sessionId = process.env.__MAVIS_PARENT_SESSION_ID; const subcmd = args[0]; const needsSession = SESSION_COMMANDS.has(subcmd) && sessionId; const finalArgs = needsSession ? [...args, '--session', sessionId] : args; const proc = spawn(MAVIS_BIN, finalArgs, { stdio: ['pipe', 'pipe', 'pipe'] }); let stdout = ''; let stderr = ''; proc.stdout.on('data', d => stdout += d.toString()); proc.stderr.on('data', d => stderr += d.toString()); proc.on('close', code => { if (code === 0) resolve(stdout.trim()); else reject(new Error(stderr.split('\n')[0] || `exit code ${code}`)); }); proc.on('error', reject); if (input) proc.stdin.write(input), proc.stdin.end(); }); }