Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

feat(agent): add restart and new session

Rahmane05650827fa2
diff --git a/README.md b/README.md
index ddab1014..1b066047 100644
--- a/README.md
+++ b/README.md
@@ -213,8 +213,12 @@ Interactive model/provider menus use a native picker: **↑/↓** moves, typing
selects, and **Esc** cancels. No provider/model number has to be memorized. `/session` and bare
`/resume` open one recent-session picker directly: newest modified session first, human session title
as the primary label, and compact `modified …` metadata. Durable session IDs stay hidden in the normal
-picker UI but remain accepted by scriptable `--resume`/`/resume` queries. In the Agent slash
-palette, executable skills carry lifecycle markers so their state is visible before and after use:
+picker UI but remain accepted by scriptable `--resume`/`/resume` queries. `/new [name]` persists the
+current session and switches the same terminal to a fresh durable session. `/restart` is a soft Agent
+runtime reload: it persists the current session, closes the composer, then relaunches the current CLI
+against that same session id. It does **not** restart the MSO service or VPS; it exists so updated CLI
+code plus the latest dynamic skill/tool/plugin catalog are picked up without abandoning the conversation.
+In the Agent slash palette, executable skills carry lifecycle markers so their state is visible before and after use:
`◇ ready` → `◆ queued` (selected for the next message) → `✓ invoked` (actually sent with a model turn).
The compact status line mirrors queued/invoked skill state and the current permission mode. MSO defaults
to `ask`; use `mso --yolo` or `mso -yolo` when you explicitly want write+exec calls auto-approved for
diff --git a/bin/mso b/bin/mso
index a81598fb..f5fc8e5c 100755
--- a/bin/mso
+++ b/bin/mso
@@ -127,7 +127,7 @@
# Docs: https://github.com/rahmanef63/mso
set -euo pipefail
-VERSION="1.8.0"
+VERSION="1.8.1"
ROOT="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
die() { echo "mso: $*" >&2; exit 1; }
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index b0d1afbf..84bd6677 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.
**Added**
+- `agent` add restart and new session
- `a2a` enable local and inbound defaults
- ship authenticated and local A2A
- `agent` add eval-gated tool forge
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 0ab1e23b..260c8b59 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -2,6 +2,13 @@
Running log of what shipped each phase. Newest at top.
+## 2026-09-02 — MSO 1.8.1 Agent soft restart + new session
+
+- **`/restart`:** soft-reloads the interactive Agent process, not the MSO service/VPS. The current durable session is persisted, the composer closes cleanly, then the current CLI is relaunched with `--resume <same-session-id>`, so updated CLI modules plus the latest dynamic tool/skill/plugin catalog are loaded without abandoning conversation history.
+- **Process-local UX:** current permission mode and status-bar preference are forwarded only across this explicit soft restart and immediately consumed by the child; they are not persisted into durable session state or leaked to later child processes.
+- **`/new [name]`:** persists the current session, creates a fresh durable CLI session in the same terminal, clears conversation/queued-skill/usage state, and refreshes the capability catalog. An omitted name preserves normal first-prompt auto-title behavior.
+- **Verification:** lifecycle/session transition tests, slash/terminal contracts, permission/session regressions, TypeScript, targeted ESLint, and a real PTY soft-reload smoke test pass.
+
## 2026-09-02 — MSO 1.8.0 authenticated inbound A2A
- **Shipped surface:** A2A v1 outbound credentials/streaming plus authenticated inbound Agent Card and JSON-RPC/SSE server, with owner Settings → A2A management for peers, credentials, tasks, and audit activity.
diff --git a/scripts/mso-agent-commands.mjs b/scripts/mso-agent-commands.mjs
index 5e871d4f..6278ee57 100644
--- a/scripts/mso-agent-commands.mjs
+++ b/scripts/mso-agent-commands.mjs
@@ -11,6 +11,7 @@ import {
persistSession,
renameCurrentSession,
resumeInto,
+ startNewSession,
resumePicker,
} from "./mso-agent-session-ui.mjs";
import { printDetailedStatus } from "./mso-agent-status.mjs";
@@ -63,6 +64,8 @@ async function selectSlashSkill(rl, session, requested, prompt, runTurn) {
function printHelp() {
console.log(
[
+ " /new [name] create and switch to a fresh durable session",
+ " /restart soft-reload Agent runtime; keep this session",
" /session [query] open picker or resume latest/index/id/title",
" /resume [query] alias-style resume command; bare opens same picker",
" /title <name> rename the durable session",
@@ -106,6 +109,12 @@ export async function handleSlash(rl, line, session, { runTurn }) {
case "/help":
printHelp();
return "handled";
+ case "/new":
+ await startNewSession(rl, session, args.join(" "));
+ session.state = await state();
+ return "refresh";
+ case "/restart":
+ return "restart";
case "/session":
case "/sessions":
case "/resume":
diff --git a/scripts/mso-agent-contract.test.ts b/scripts/mso-agent-contract.test.ts
index 756fc47a..849cdf76 100644
--- a/scripts/mso-agent-contract.test.ts
+++ b/scripts/mso-agent-contract.test.ts
@@ -2,7 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
-const files = ["mso-agent.mjs", "mso-agent-runtime.mjs", "mso-agent-ui.mjs", "mso-agent-slash.mjs", "mso-agent-status.mjs", "mso-agent-sessions.mjs", "mso-agent-session-ui.mjs", "mso-agent-commands.mjs", "mso-agent-composer.mjs", "mso-agent-permissions.mjs"].map((name) => path.join(__dirname, name));
+const files = ["mso-agent.mjs", "mso-agent-runtime.mjs", "mso-agent-ui.mjs", "mso-agent-slash.mjs", "mso-agent-status.mjs", "mso-agent-sessions.mjs", "mso-agent-session-ui.mjs", "mso-agent-lifecycle.mjs", "mso-agent-commands.mjs", "mso-agent-composer.mjs", "mso-agent-permissions.mjs"].map((name) => path.join(__dirname, name));
const src = files.map((file) => fs.readFileSync(file, "utf8")).join("\n");
describe("MSO terminal agent contract", () => {
@@ -30,7 +30,7 @@ describe("MSO terminal agent contract", () => {
expect(src).toContain("MSO_TITLE_COLORS");
for (const command of [
"/models", "/model", "/status", "/context", "/statusbar", "/title",
- "/session", "/resume", "/setup", "/providers", "/provider",
+ "/new", "/restart", "/session", "/resume", "/setup", "/providers", "/provider",
"/doctor", "/tools", "/skills", "/skill", "/<skill>", "/clear", "/exit", "/quit",
]) expect(src).toContain(command);
expect(src).toContain("Configure AI providers and authentication");
@@ -66,6 +66,9 @@ describe("MSO terminal agent contract", () => {
expect(src).toContain("renameCliSession");
expect(src).toContain('action: "rename"');
expect(src).toContain("syncPromptHistory");
+ expect(src).toContain("startNewSession");
+ expect(src).toContain("relaunchAgentSession");
+ expect(src).toContain('["agent", "--resume", id]');
expect(src).toContain("permissionCompletionItems");
expect(src).toContain("approvesTool");
expect(src).toContain("--yolo");
diff --git a/scripts/mso-agent-lifecycle.mjs b/scripts/mso-agent-lifecycle.mjs
new file mode 100644
index 00000000..0f88709c
--- /dev/null
+++ b/scripts/mso-agent-lifecycle.mjs
@@ -0,0 +1,47 @@
+import { spawnSync } from "node:child_process";
+import process from "node:process";
+import { CLI } from "./mso-agent-runtime.mjs";
+
+const RESTART_PERMISSION_ENV = "MSO_AGENT_RESTART_PERMISSION";
+const RESTART_STATUSBAR_ENV = "MSO_AGENT_RESTART_STATUSBAR";
+
+export function consumeRestartUiState() {
+ const permission = String(process.env[RESTART_PERMISSION_ENV] || "").trim();
+ const statusBarRaw = String(process.env[RESTART_STATUSBAR_ENV] || "").trim().toLowerCase();
+ delete process.env[RESTART_PERMISSION_ENV];
+ delete process.env[RESTART_STATUSBAR_ENV];
+ return {
+ permission: ["ask", "auto", "yolo"].includes(permission) ? permission : null,
+ statusBar: statusBarRaw === "off" ? false : statusBarRaw === "on" ? true : null,
+ };
+}
+
+export function relaunchAgentSession(
+ { cli, sessionId, permission = "ask", statusBar = true },
+ runner = spawnSync,
+) {
+ const id = String(sessionId || "").trim();
+ if (!id) throw new Error("cannot restart MSO Agent without a durable session id");
+ const env = {
+ ...process.env,
+ [RESTART_PERMISSION_ENV]: ["ask", "auto", "yolo"].includes(permission)
+ ? permission
+ : "ask",
+ [RESTART_STATUSBAR_ENV]: statusBar === false ? "off" : "on",
+ };
+ const result = runner(String(cli || "mso"), ["agent", "--resume", id], {
+ stdio: "inherit",
+ env,
+ });
+ if (result?.error) throw result.error;
+ return Number.isInteger(result?.status) ? result.status : 1;
+}
+
+export function relaunchCurrentAgentSession(session) {
+ return relaunchAgentSession({
+ cli: CLI,
+ sessionId: session?.agentSession?.id,
+ permission: session?.permission,
+ statusBar: session?.statusBar,
+ });
+}
diff --git a/scripts/mso-agent-lifecycle.test.ts b/scripts/mso-agent-lifecycle.test.ts
new file mode 100644
index 00000000..b6a07f80
--- /dev/null
+++ b/scripts/mso-agent-lifecycle.test.ts
@@ -0,0 +1,49 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { consumeRestartUiState, relaunchAgentSession } from "./mso-agent-lifecycle.mjs";
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+ delete process.env.MSO_AGENT_RESTART_PERMISSION;
+ delete process.env.MSO_AGENT_RESTART_STATUSBAR;
+});
+
+describe("MSO Agent soft restart", () => {
+ it("relaunches the same durable session in the same inherited terminal", () => {
+ const calls: unknown[][] = [];
+ const runner = (...args: unknown[]) => {
+ calls.push(args);
+ return { status: 0 };
+ };
+ const status = relaunchAgentSession(
+ {
+ cli: "/opt/mso/bin/mso",
+ sessionId: "sess_same_123",
+ permission: "auto",
+ statusBar: false,
+ },
+ runner as never,
+ );
+ expect(status).toBe(0);
+ expect(calls).toHaveLength(1);
+ const [command, args, options] = calls[0] as [string, string[], { stdio: string; env: NodeJS.ProcessEnv }];
+ expect(command).toBe("/opt/mso/bin/mso");
+ expect(args).toEqual(["agent", "--resume", "sess_same_123"]);
+ expect(options.stdio).toBe("inherit");
+ expect(options.env.MSO_AGENT_RESTART_PERMISSION).toBe("auto");
+ expect(options.env.MSO_AGENT_RESTART_STATUSBAR).toBe("off");
+ });
+
+ it("consumes restart-only UI state so it does not leak into later child processes", () => {
+ process.env.MSO_AGENT_RESTART_PERMISSION = "yolo";
+ process.env.MSO_AGENT_RESTART_STATUSBAR = "on";
+ expect(consumeRestartUiState()).toEqual({ permission: "yolo", statusBar: true });
+ expect(process.env.MSO_AGENT_RESTART_PERMISSION).toBeUndefined();
+ expect(process.env.MSO_AGENT_RESTART_STATUSBAR).toBeUndefined();
+ });
+
+ it("fails closed when no durable session id exists", () => {
+ expect(() =>
+ relaunchAgentSession({ cli: "mso", sessionId: "" }, (() => ({ status: 0 })) as never),
+ ).toThrow(/durable session id/);
+ });
+});
diff --git a/scripts/mso-agent-session-ui-state.test.ts b/scripts/mso-agent-session-ui-state.test.ts
new file mode 100644
index 00000000..751722ef
--- /dev/null
+++ b/scripts/mso-agent-session-ui-state.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from "vitest";
+import { applyNewSessionState } from "./mso-agent-session-ui.mjs";
+
+describe("MSO Agent /new session transition", () => {
+ it("switches to a new durable id and clears conversation-local state", () => {
+ const session = {
+ agentSession: { id: "old", source: "cli", title: "old session" },
+ history: [{ role: "user", text: "old prompt" }],
+ pendingSkill: { id: "old-skill" },
+ activeSkill: { id: "running" },
+ lastInvokedSkill: { id: "done" },
+ titleOverride: "old title",
+ usage: { inputTokens: 10, outputTokens: 20, totalTokens: 30 },
+ lastElapsedMs: 500,
+ };
+ applyNewSessionState(
+ session,
+ { id: "new", source: "cli", title: "MSO Agent session", history: [] },
+ "",
+ );
+ expect(session.agentSession.id).toBe("new");
+ expect(session.history).toEqual([]);
+ expect(session.pendingSkill).toBeNull();
+ expect(session.activeSkill).toBeNull();
+ expect(session.lastInvokedSkill).toBeNull();
+ expect(session.titleOverride).toBeNull();
+ expect(session.usage).toEqual({ inputTokens: 0, outputTokens: 0, totalTokens: 0 });
+ expect(session.lastElapsedMs).toBe(0);
+ });
+
+ it("keeps an explicit /new title authoritative", () => {
+ const session: any = {};
+ applyNewSessionState(
+ session,
+ { id: "new", source: "cli", title: "baco-2", history: [] },
+ "baco-2",
+ );
+ expect(session.titleOverride).toBe("baco-2");
+ });
+});
diff --git a/scripts/mso-agent-session-ui.mjs b/scripts/mso-agent-session-ui.mjs
index 0d04d01a..ded571ff 100644
--- a/scripts/mso-agent-session-ui.mjs
+++ b/scripts/mso-agent-session-ui.mjs
@@ -26,6 +26,32 @@ export async function renameCurrentSession(session, title) {
return session.titleOverride;
}
+
+export function applyNewSessionState(session, loaded, requestedTitle = "") {
+ Object.assign(session, {
+ agentSession: loaded,
+ history: Array.isArray(loaded.history) ? loaded.history : [],
+ pendingSkill: null,
+ activeSkill: null,
+ lastInvokedSkill: null,
+ titleOverride: requestedTitle ? (loaded.title || requestedTitle) : null,
+ usage: { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
+ lastElapsedMs: 0,
+ });
+ return session;
+}
+
+export async function startNewSession(rl, session, title = "") {
+ await persistSession(session);
+ const requestedTitle = String(title || "").replace(/[\r\n\t]+/g, " ").trim().slice(0, 120);
+ const loaded = await createCliSession(requestedTitle || undefined);
+ if (!loaded || loaded.source !== "cli") throw new Error("could not create a new CLI MSO Agent session");
+ applyNewSessionState(session, loaded, requestedTitle);
+ syncPromptHistory(rl, session);
+ console.log(`${C.c}new session ${loaded.title || "MSO Agent session"}${C.reset}`);
+ return true;
+}
+
export async function resumeInto(rl, session, query) {
const loaded = await resumeCliSession(query);
if (!loaded || loaded.source !== "cli") throw new Error("could not create a CLI continuation session");
diff --git a/scripts/mso-agent-slash.mjs b/scripts/mso-agent-slash.mjs
index 30ffe17e..61ce9837 100644
--- a/scripts/mso-agent-slash.mjs
+++ b/scripts/mso-agent-slash.mjs
@@ -18,6 +18,8 @@ export const BUILTIN_SLASH_ITEMS = [
meta: "Select the active model from connected providers",
kind: "command",
},
+ { text: "/new", meta: "Create and switch to a fresh durable session", kind: "command" },
+ { text: "/restart", meta: "Soft-reload runtime, skills, tools, and updated CLI code", kind: "command" },
{ text: "/session", meta: "Open the recent-session picker", kind: "command" },
{
text: "/resume",
diff --git a/scripts/mso-agent-slash.test.ts b/scripts/mso-agent-slash.test.ts
index ce7320b4..03daf4d0 100644
--- a/scripts/mso-agent-slash.test.ts
+++ b/scripts/mso-agent-slash.test.ts
@@ -17,6 +17,8 @@ describe("MSO Agent slash completion catalog", () => {
expect(rows.map((row) => row.text)).toContain("/design");
expect(rows.map((row) => row.text)).toContain("/quit");
expect(rows.map((row) => row.text)).toContain("/agents");
+ expect(rows.map((row) => row.text)).toContain("/new");
+ expect(rows.map((row) => row.text)).toContain("/restart");
expect(rows.map((row) => row.text)).toContain("/delegate");
expect(rows.map((row) => row.text)).not.toContain("/unsafe");
});
diff --git a/scripts/mso-agent.mjs b/scripts/mso-agent.mjs
index 157e9710..bc08ba29 100644
--- a/scripts/mso-agent.mjs
+++ b/scripts/mso-agent.mjs
@@ -9,7 +9,8 @@ import { addUsage, renderStatusBar } from "./mso-agent-status.mjs";
import { persistSession, resumeArg, startupSession, syncPromptHistory } from "./mso-agent-session-ui.mjs";
import { C, api, printBanner, state, streamTurn } from "./mso-agent-runtime.mjs";
import { handleSlash } from "./mso-agent-commands.mjs";
-import { approvesTool, nextPermissionMode, permissionPrompt } from "./mso-agent-permissions.mjs";
+import { approvesTool, nextPermissionMode, permissionMode, permissionPrompt } from "./mso-agent-permissions.mjs";
+import { consumeRestartUiState, relaunchCurrentAgentSession } from "./mso-agent-lifecycle.mjs";
import { oneShotApproves, oneShotHelp, parseOneShot } from "./mso-agent-oneshot.mjs";
async function executeTool(rl, tool, call, agentSession, permission = "ask", signal = undefined, onInterrupt = null, options = {}) {
@@ -147,7 +148,10 @@ async function main() {
process.exit(2);
}
const requested = resumeArg(argv);
- const forcedPermission = argv.some((arg) => ["--yolo", "-yolo", "-y"].includes(arg)) ? "yolo" : "ask";
+ const restartUi = consumeRestartUiState();
+ const forcedPermission = argv.some((arg) => ["--yolo", "-yolo", "-y"].includes(arg))
+ ? "yolo"
+ : (permissionMode(restartUi.permission)?.id || "ask");
const [s, agentSession] = await Promise.all([
state(),
startupSession(requested),
@@ -164,7 +168,7 @@ async function main() {
titleOverride: requested ? (agentSession.title || null) : null,
usage: { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
lastElapsedMs: 0,
- statusBar: true,
+ statusBar: restartUi.statusBar ?? true,
permission: forcedPermission,
};
const rl = new AgentComposer({ input: process.stdin, output: process.stdout, colors: C });
@@ -180,6 +184,7 @@ async function main() {
};
process.on("SIGINT", onSigint);
const completeSlash = (line) => slashCompletionItems(session.state.skills, line, process.cwd(), session);
+ let restartRequested = false;
try {
while (true) {
if (interrupts.exitRequested) break;
@@ -199,6 +204,7 @@ async function main() {
try {
const result = await handleSlash(rl, line, session, { runTurn: (skill) => runInteractiveRound(rl, session, skill, interrupts) });
if (result === "exit") break;
+ if (result === "restart") { restartRequested = true; break; }
if (result === "unknown") console.log("unknown command; /help lists commands.");
} catch (error) {
console.error(`${C.err}${error instanceof Error ? error.message : String(error)}${C.reset}`);
@@ -216,9 +222,14 @@ async function main() {
process.off("SIGINT", onSigint);
await persistSession(session).catch(() => undefined);
const sessionTitle = String(session.agentSession.title || "MSO Agent session").replace(/[\r\n\t]+/g, " ").trim().slice(0, 80);
- console.log(`${C.dim}session ${sessionTitle} · resume: mso --continue · switch: /sessions${C.reset}`);
+ if (!restartRequested) console.log(`${C.dim}session ${sessionTitle} · resume: mso --continue · switch: /sessions${C.reset}`);
rl.close();
}
+ if (restartRequested) {
+ console.log(`${C.dim}↻ refreshing Agent runtime · keeping ${session.agentSession.title || "current session"}${C.reset}`);
+ const code = relaunchCurrentAgentSession(session);
+ if (code !== 0) process.exitCode = code;
+ }
}
main().catch((error) => { console.error(`${C.err}mso agent: ${error instanceof Error ? error.message : String(error)}${C.reset}`); process.exit(1); });
diff --git a/scripts/mso-model-dx-contract.test.ts b/scripts/mso-model-dx-contract.test.ts
index 27fa39a5..bd37d031 100644
--- a/scripts/mso-model-dx-contract.test.ts
+++ b/scripts/mso-model-dx-contract.test.ts
@@ -29,7 +29,7 @@ const all = [cli, agentCli, configRoute, oauthRoute, slash, picker].join("\n");
describe("MSO model/provider/session CLI contract", () => {
it("keeps provider auth (`models`) separate from active selection (`model`)", () => {
- expect(cli).toContain('VERSION="1.8.0"');
+ expect(cli).toContain('VERSION="1.8.1"');
expect(cli).toContain("models * Configure AI providers/auth");
expect(cli).toContain("model [ref] Select active model");
expect(agentCli).toContain("run_models()");