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.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
feat(a2a): add provider-neutral workflow trace skill
Rahman222aa360c489
diff --git a/bin/mso b/bin/msoindex f46aaa99..5e3da69d 100755--- a/bin/mso+++ b/bin/mso@@ -73,7 +73,7 @@# agent-sessions * Durable MSO Agent sessions: list | show | create# agents * Native local session agents: list | send | inbox# org * Organization chart: units, seats, reporting lines, targets-# a2a * Agent-to-Agent v1: list | discover | add | rm | send | task | cancel | handoff+# a2a * Agent-to-Agent v1 + workflow trace: list | discover | send | handoff | trace# memory * Assistant memories: list | add | rm# memory-graph [project] Knowledge graph: vault notes, project memory, agent memory# config * Advanced raw AI config compatibility surfacediff --git a/claude-skills/a2a/SKILL.md b/claude-skills/a2a/SKILL.mdnew file mode 100644index 00000000..65e07835--- /dev/null+++ b/claude-skills/a2a/SKILL.md@@ -0,0 +1,103 @@+---+name: a2a+description: "Keep work from external AI CLI sessions inside one durable MSO workflow using safe progress and evidence summaries."+metadata:+ mso:+ risk: medium+ policy: trace-resume-verify+---++# /a2a — provider-neutral MSO workflow trace++Use this skill when work performed by Codex CLI, Claude/Cloud CLI, Antigravity, or another Agent Skills-capable runtime must remain visible and resumable in MSO by another agent.++## Trigger and boundaries++- **Use when:** a multi-step external-agent task should share one durable MSO session/workflow, progress trace, evidence trail, or handoff context.+- **Do not use when:** the task is a trivial single call, or the user only wants standard remote A2A peer delegation; use the normal `a2a_*` tools for that protocol.+- **Required context:** task intent, project when known, a short agent/provider label, and authenticated access to the same MSO owner/device identity through MCP or the `mso` CLI.++This skill records **observable progress, not private reasoning**. Never send chain-of-thought, hidden reasoning, system/developer prompts, complete private transcripts, credentials, cookies, tokens, or secret-bearing commands.++## Fast route++### Native MSO/MCP++1. Call `workflow_start` once with the complete intent/project/constraints.+2. Keep its exact `workflow_id` on every later MSO call.+3. If source isolation is returned, do all source-changing work in that exact workspace.+4. At meaningful milestones, call `agent_session_note` with a concise safe note and the same `workflow_id`.+5. Use `agent_session_flow` when another agent needs the semantic context.+6. Finish with `workflow_finish` only after independent verification; otherwise use `workflow_cancel`.++### CLI fallback++When the AI can run shell commands but does not have direct MSO MCP tools, run the bundled `scripts/a2a.mjs` from this skill directory. It forwards to the installed MSO CLI:++```bash+node scripts/a2a.mjs start --intent "Implement the requested change" --project my-project --agent codex+node scripts/a2a.mjs progress --run <run-id> --stage implement --message "Updated the bounded feature surface."+node scripts/a2a.mjs evidence --run <run-id> --stage verify --message "Targeted tests passed."+node scripts/a2a.mjs context --run <run-id>+node scripts/a2a.mjs finish --run <run-id> --summary "Implemented and verified." --evidence @evidence.json+```++The bridge returns `run_id`, `session_id`, `workflow_id`, and any task workspace. Keep those identifiers as operational metadata, not user secrets.++## Event policy++Allowed milestone kinds are:++- `plan` — bounded approach or next phase.+- `progress` — meaningful state change.+- `action` — observable operation completed.+- `evidence` — test/build/health/artifact result.+- `blocker` — concrete blocker and what is needed.+- `result` — intermediate or terminal outcome.+- `handoff` — concise continuation packet for the next agent.++Prefer one update when a phase/result changes. For long external operations, a concise update every tens of seconds is enough; do not stream every token, thought, or command. Exact duplicate events are intentionally deduplicated by the CLI bridge.++## Handoff and resume++On handoff, include:++- current goal and completed outcome;+- changed surface or artifact references;+- verification already run;+- remaining blocker/next action;+- the existing `run_id` plus MSO session/workflow identifiers when the next agent uses the same authenticated MSO identity.++On the same host/device, the next agent can continue with `context --run <run-id>`. A local bridge can also `attach --session <id> --workflow <id> --run <new-run>` when it owns that MSO session. Do not bypass MSO's device/principal isolation to attach a session owned by another identity.++## Tool routing++| Need | Preferred capability |+|---|---|+| Start durable work | `workflow_start` |+| Stream safe milestone | `agent_session_note` + exact workflow id |+| Read cross-agent context | `agent_session_flow` |+| Check live workflow | `workflow_status` or CLI `status` |+| Close verified work | `workflow_finish` |+| Abandon safely | `workflow_cancel` |+| Remote A2A peer delegation | standard `a2a_*` tools, not this trace bridge |++## Verification contract++- **Expected state:** one durable MSO session and one exact workflow represent the external task; milestone notes are visible in the semantic session flow.+- **Targeted checks:** CLI/MCP correlation uses the same workflow id; state files are owner-private; duplicate progress is bounded; hidden reasoning is never an accepted event type.+- **Runtime proof:** `status` returns the active workflow and `context` returns the accumulated safe semantic flow.+- **Visual proof:** not required unless the underlying task changes UI.+- **Diff boundary:** this bridge may record summaries and evidence only; it never grants new project permissions or substitutes self-reported progress for verification.++A successful `finish` still uses MSO's Evidence Receipt rules. High-risk work requires explicit verification evidence; a progress note alone is not proof.++## Failure and rollback++If MSO is unreachable or identity/session ownership does not match, stop claiming the task is synchronized. Preserve local work, report the trace as unsynced, and reconnect explicitly. Never fabricate a workflow id, force ownership, or copy private MSO stores between devices.++Cancel only the exact workflow created or attached by this run. Local trace state under `~/.mso/private/a2a-traces` contains correlation metadata only and must remain owner-only.++## Recipe memory++Store only redacted, replayable workflow receipts. Treat bridge events as context, not truth. Durable learning should come from a verified `workflow_finish`, concrete evidence, and sanitized tool receipts.diff --git a/claude-skills/a2a/agents/openai.yaml b/claude-skills/a2a/agents/openai.yamlnew file mode 100644index 00000000..91480734--- /dev/null+++ b/claude-skills/a2a/agents/openai.yaml@@ -0,0 +1,4 @@+interface:+ display_name: "A2A"+ short_description: "Stream cross-agent progress into durable MSO workflows."+ default_prompt: "Use $a2a for this workflow."diff --git a/claude-skills/a2a/contract.yaml b/claude-skills/a2a/contract.yamlnew file mode 100644index 00000000..47b6446a--- /dev/null+++ b/claude-skills/a2a/contract.yaml@@ -0,0 +1,30 @@+version: 1+routing:+ use_when:+ - "persist external AI or CLI work into one durable MSO workflow for cross-agent progress, evidence, resume, or handoff"+ do_not_use_when:+ - "the request is only standard remote A2A peer delegation or a trivial single operation"+ fallback: false+context:+ target: a2a+ mode: mixed+ actor: operator+lifecycle:+ discover:+ - workflow_start+ - agent_session_current+ validate:+ - session-workflow-correlation+ - redacted-progress-events+ verify:+ - agent_session_flow+ - workflow_finish+state:+ source_of_truth: live+ refresh: before-write+safety:+ risk: medium+ confirmation: contextual+ concurrency: contextual+presentation:+ authority: hybriddiff --git a/claude-skills/a2a/scripts/a2a.mjs b/claude-skills/a2a/scripts/a2a.mjsnew file mode 100755index 00000000..5c03f637--- /dev/null+++ b/claude-skills/a2a/scripts/a2a.mjs@@ -0,0 +1,16 @@+#!/usr/bin/env node+import { spawnSync } from "node:child_process";+import process from "node:process";++const cli = process.env.MSO_CLI || "mso";+const result = spawnSync(cli, ["a2a", "trace", ...process.argv.slice(2)], {+ stdio: "inherit",+ env: process.env+});++if (result.error) {+ process.stderr.write("a2a: MSO CLI is unavailable. Install/connect MSO or use the native MSO MCP workflow tools.\n");+ process.exitCode = 127;+} else {+ process.exitCode = result.status == null ? 1 : result.status;+}diff --git a/docs/A2A.md b/docs/A2A.mdindex d36d9242..9254ae89 100644--- a/docs/A2A.md+++ b/docs/A2A.md@@ -86,6 +86,28 @@ mso a2a inbound rm <tokenId>The Settings → **A2A** panel exposes the same flow, shows the one-time token once, lists/revokes inbound profiles, and surfaces bounded task/audit activity.+## A2A skill — provider-neutral workflow trace++The official `a2a` Agent Skill also exposes an owner-authenticated **workflow trace bridge** for AI runtimes that are doing work locally through Codex CLI, Claude/Cloud CLI, Antigravity, or another Agent Skills-compatible CLI.++This is intentionally separate from A2A protocol message streaming. Remote A2A remains a trust-domain boundary and does not inherit owner memory. The trace bridge runs only through the normal authenticated MSO owner CLI/MCP session and records concise observable milestones into one durable agent session plus one exact MSO workflow.++Native MCP-capable agents should use `workflow_start`, `agent_session_note`, `agent_session_flow`, and `workflow_finish` directly. Shell-capable agents can use:++```bash+mso a2a trace start --intent "Implement the requested feature" --project my-project --agent codex+mso a2a trace progress --run <run-id> --stage implement --message "Bounded implementation is complete."+mso a2a trace evidence --run <run-id> --stage verify --message "Targeted tests passed."+mso a2a trace context --run <run-id>+mso a2a trace finish --run <run-id> --summary "Implemented and verified." --evidence @evidence.json+```++The bridge returns the durable `session_id`, exact `workflow_id`, a local `run_id`, and the isolated workspace when MSO created one. The same workflow id is attached to every milestone call, so semantic session flow and workflow receipts remain correlated for later agents.++Allowed trace kinds are `plan`, `progress`, `action`, `evidence`, `blocker`, `result`, and `handoff`. They are summaries of observable work only. Hidden chain-of-thought, private reasoning, system/developer prompts, complete transcripts, credentials, cookies, and tokens must never be sent as trace events.++Local correlation state lives under `~/.mso/private/a2a-traces` with owner-only permissions and contains identifiers/status only. It does not grant access to sessions from another MSO device/principal. `workflow_finish` still enforces the normal Evidence Receipt rules; streamed progress is context, not verification proof.+## Same-host sessions are native Local Agents, not remote A2AMSO 1.9 separates live same-host session communication from this remote interoperability protocol. `/agents`, `/message`, local `/delegate`, local inbox delivery, and the `local_agent_*` MCP tools use a private **presence lease + durable mailbox + SSE/event-bus** layer. They require no Agent Card, URL, registration, credential, refresh, or restart when another session appears or is renamed.diff --git a/docs/CLI.md b/docs/CLI.mdindex aa21b70b..31690f60 100644--- a/docs/CLI.md+++ b/docs/CLI.md@@ -113,7 +113,7 @@ Commands:agent-sessions * Durable MSO Agent sessions: list | show | createagents * Native local session agents: list | send | inboxorg * Organization chart: units, seats, reporting lines, targets- a2a * Agent-to-Agent v1: list | discover | add | rm | send | task | cancel | handoff+ a2a * Agent-to-Agent v1 + workflow trace: list | discover | send | handoff | tracememory * Assistant memories: list | add | rmmemory-graph [project] Knowledge graph: vault notes, project memory, agent memoryconfig * Advanced raw AI config compatibility surfacediff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex b08f3077..48c8212b 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,7 @@+## 2026-09-29 — Provider-neutral A2A workflow trace skill++Added the official `a2a` skill and `mso a2a trace` bridge so external AI CLIs can keep one owner-authenticated durable MSO session/workflow while they work. The bridge records only concise plan/progress/action/evidence/blocker/result/handoff summaries, correlates every milestone with the exact workflow id, exposes semantic context for later agents, and preserves MSO workflow isolation and Evidence Receipt gates. It explicitly rejects private chain-of-thought as a trace surface. Local run metadata is stored under the owner-private MSO state directory; remote A2A trust boundaries and cross-device session ownership remain unchanged.+## 2026-09-28 — Bounded MANEF application catalogAdded a versioned metadata catalog to manef-web and an Owner-only MSO reader. The site PR merged, but Vercel blocked its production deployment; live publication remains pending hosting access. The remote list may order existing reviewed Managed App adapters or offer a portable connection template; it cannot authorize a new installer, command, URL, credential or grant. Selecting a managed entry follows its existing preflight and setup; selecting a connected entry still requires an instance address and explicit Owner review. The server pins the catalog URL, bounds and validates the whole response, caches a valid copy for a short outage and leaves local installers available without the site. This completes remote discovery for this profile while generic installation recipes, domains and independent package releases remain separate work.diff --git a/scripts/a2a-trace-cli-contract.test.ts b/scripts/a2a-trace-cli-contract.test.tsnew file mode 100644index 00000000..65d0390c--- /dev/null+++ b/scripts/a2a-trace-cli-contract.test.ts@@ -0,0 +1,33 @@+import { readFileSync } from "node:fs";+import path from "node:path";+import { describe, expect, it } from "vitest";++const root = process.cwd();+const commands = readFileSync(path.join(root, "scripts/cli/commands-state.sh"), "utf8");+const usage = readFileSync(path.join(root, "scripts/cli/commands.sh"), "utf8");+const bridge = ["scripts/a2a-trace.mjs", "scripts/a2a-trace-support.mjs"].map((file) => readFileSync(path.join(root, file), "utf8")).join("\n");+const skill = readFileSync(path.join(root, "claude-skills/a2a/SKILL.md"), "utf8");++describe("A2A trace CLI + skill contract", () => {+ it("wires mso a2a trace through the normal authenticated agent-tool route", () => {+ expect(usage).toContain("trace <start|progress|plan|action|evidence|blocker|result|handoff|status|context|attach|finish|cancel|list>");+ expect(commands).toContain('jget "/api/v1/agent-tools" >/dev/null');+ expect(commands).toContain('node "$ROOT/scripts/a2a-trace.mjs" "$@"');+ expect(commands).toContain('MSO_AGENT_JAR="$JAR"');+ });++ it("uses durable workflow/session tools rather than bypassing A2A isolation", () => {+ for (const name of ["workflow_start", "agent_session_note", "workflow_status", "agent_session_flow", "workflow_finish", "workflow_cancel"]) {+ expect(bridge).toContain('"' + name + '"');+ }+ expect(bridge).not.toContain('"agent_memory_remember"');+ expect(bridge).not.toContain('"a2a_message_send"');+ });++ it("defines safe progress summaries, not private chain-of-thought streaming", () => {+ expect(bridge).toContain('["plan", "progress", "action", "evidence", "blocker", "result", "handoff"]');+ expect(skill).toContain("observable progress, not private reasoning");+ expect(skill).toContain("Never send chain-of-thought");+ expect(skill).not.toContain("`reasoning` —");+ });+});diff --git a/scripts/a2a-trace-support.mjs b/scripts/a2a-trace-support.mjsnew file mode 100644index 00000000..399e3c6d--- /dev/null+++ b/scripts/a2a-trace-support.mjs@@ -0,0 +1,164 @@+import { randomUUID } from "node:crypto";+import { promises as fs } from "node:fs";+import os from "node:os";+import path from "node:path";+import process from "node:process";+import { canonicalAgentApproval } from "../lib/agent/approval.mjs";+import { api } from "./mso-agent-api.mjs";++export const EVENT_KINDS = new Set(["plan", "progress", "action", "evidence", "blocker", "result", "handoff"]);+const RUN_RE = /^[a-z0-9][a-z0-9-]{5,80}$/;+const ROOT = process.env.MSO_A2A_TRACE_STATE_DIR || path.join(os.homedir(), ".mso", "private", "a2a-traces");++export function fail(message) {+ const error = new Error(message);+ error.code = "A2A_TRACE";+ throw error;+}++export function clean(value, max) {+ const out = String(value == null ? "" : value).replace(/[\r\n\t]+/g, " ").replace(/\s+/g, " ").trim();+ return max ? out.slice(0, max) : out;+}++export function parseArgs(argv) {+ const command = argv[0] || "help";+ const options = { _: [] };+ for (let i = 1; i < argv.length; i += 1) {+ const value = argv[i];+ if (!value.startsWith("--")) { options._.push(value); continue; }+ const eq = value.indexOf("=");+ if (eq > 2) { options[value.slice(2, eq)] = value.slice(eq + 1); continue; }+ const key = value.slice(2);+ const next = argv[i + 1];+ if (!next || next.startsWith("--")) options[key] = true;+ else { options[key] = next; i += 1; }+ }+ return { command, options };+}++export function csv(value) {+ if (!value) return undefined;+ const rows = String(value).split(",").map((row) => row.trim()).filter(Boolean).slice(0, 80);+ return rows.length ? rows : undefined;+}++export function validRunId(value) {+ const id = clean(value || ("a2a-" + randomUUID().slice(0, 12)), 80).toLowerCase();+ if (!RUN_RE.test(id)) fail("run id must be 6-80 lowercase letters, digits, or hyphens");+ return id;+}++export function freshRunId() {+ return "a2a-" + randomUUID().slice(0, 12);+}++async function ensureStateRoot() {+ await fs.mkdir(ROOT, { recursive: true, mode: 0o700 });+ const stat = await fs.lstat(ROOT);+ if (!stat.isDirectory() || stat.isSymbolicLink()) fail("unsafe A2A trace state directory");+ await fs.chmod(ROOT, 0o700).catch(() => undefined);+}++async function statePath(id) {+ await ensureStateRoot();+ return path.join(ROOT, validRunId(id) + ".json");+}++export async function saveState(state) {+ const file = await statePath(state.runId);+ const temp = file + "." + process.pid + "." + Date.now() + ".tmp";+ await fs.writeFile(temp, JSON.stringify(state, null, 2) + "\n", { mode: 0o600, flag: "wx" });+ await fs.chmod(temp, 0o600).catch(() => undefined);+ await fs.rename(temp, file);+}++export async function readState(id) {+ const file = await statePath(id);+ const stat = await fs.lstat(file).catch(() => null);+ if (!stat || !stat.isFile() || stat.isSymbolicLink()) fail("A2A trace run not found: " + id);+ const state = JSON.parse(await fs.readFile(file, "utf8"));+ if (state && state.version === 1 && state.sessionId && state.workflowId) return state;+ fail("invalid A2A trace state: " + id);+}++export async function resolveState(options) {+ if (options.run) return readState(options.run);+ if (options.session && options.workflow) {+ return {+ version: 1, runId: validRunId(options["run-id"] || "a2a-attached"),+ agent: clean(options.agent || "external", 48), project: clean(options.project || "", 240) || undefined,+ sessionId: clean(options.session, 120), workflowId: clean(options.workflow, 120),+ status: "attached", startedAt: new Date().toISOString(), updatedAt: new Date().toISOString()+ };+ }+ fail("pass --run <id>, or both --session <session-id> --workflow <workflow-id>");+}++function toolResult(out) {+ if (!out || out.ok === false) fail(clean((out && (out.result || out.error)) || "MSO tool call failed", 1200));+ if (typeof out.result !== "string") return out.result;+ try { return JSON.parse(out.result); } catch { return out.result; }+}++export async function callTool(sessionId, name, input, scope) {+ const payload = { name, input, sessionId };+ if (scope !== "read") {+ const approval = canonicalAgentApproval(name, input);+ payload.input = approval.payload.input;+ payload.approved = true;+ payload.approvalDigest = approval.digest;+ }+ const out = await api("/api/v1/agent-tools", { method: "POST", body: JSON.stringify(payload) });+ return toolResult(out);+}++export function findString(value, key) {+ if (!value || typeof value !== "object") return undefined;+ if (Object.hasOwn(value, key) && typeof value[key] === "string") return value[key];+ for (const nested of Object.values(value)) {+ const found = findString(nested, key);+ if (found) return found;+ }+ return undefined;+}++export function output(value) {+ process.stdout.write(JSON.stringify(value, null, 2) + "\n");+}++async function stdinText() {+ let body = "";+ process.stdin.setEncoding("utf8");+ for await (const chunk of process.stdin) body += chunk;+ return body;+}++export async function evidenceInput(value) {+ if (!value) return undefined;+ let raw = String(value);+ if (raw === "-") raw = await stdinText();+ else if (raw.startsWith("@")) raw = await fs.readFile(path.resolve(raw.slice(1)), "utf8");+ let parsed;+ try { parsed = JSON.parse(raw); } catch { fail("--evidence must be JSON, @file, or - for stdin"); }+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) fail("--evidence must be a JSON object");+ return parsed;+}++export async function listRuns() {+ await ensureStateRoot();+ const entries = await fs.readdir(ROOT, { withFileTypes: true });+ const rows = [];+ for (const entry of entries) {+ if (!entry.isFile() || !entry.name.endsWith(".json")) continue;+ try {+ const value = JSON.parse(await fs.readFile(path.join(ROOT, entry.name), "utf8"));+ if (value && value.version === 1) rows.push({+ run_id: value.runId, agent: value.agent, project: value.project, status: value.status,+ workflow_id: value.workflowId, session_label: value.sessionLabel, updated_at: value.updatedAt+ });+ } catch {}+ }+ rows.sort((a, b) => String(b.updated_at || "").localeCompare(String(a.updated_at || "")));+ output({ ok: true, runs: rows.slice(0, 100) });+}diff --git a/scripts/a2a-trace.mjs b/scripts/a2a-trace.mjsnew file mode 100644index 00000000..c54adde5--- /dev/null+++ b/scripts/a2a-trace.mjs@@ -0,0 +1,158 @@+#!/usr/bin/env node+import process from "node:process";+import { pathToFileURL } from "node:url";+import { api } from "./mso-agent-api.mjs";+import {+ EVENT_KINDS, callTool, clean, csv, evidenceInput, fail, findString, freshRunId,+ listRuns, output, parseArgs, resolveState, saveState, validRunId+} from "./a2a-trace-support.mjs";++function usage() {+ return [+ "A2A workflow trace bridge", "", "Usage:",+ " mso a2a trace start --intent <text> [--project <project>] [--agent <name>] [--constraints <text>]",+ " [--affected a,b] [--reserved a,b] [--run <id>]",+ " mso a2a trace progress|plan|action|evidence|blocker|result|handoff --run <id> --message <text> [--stage <name>]",+ " mso a2a trace status --run <id>",+ " mso a2a trace context --run <id> [--limit 120]",+ " mso a2a trace attach --session <id> --workflow <id> [--agent <name>] [--project <project>] [--run <id>]",+ " mso a2a trace finish --run <id> --summary <text> [--failed] [--evidence <JSON|@file|->]",+ " mso a2a trace cancel --run <id> [--reason <text>]", " mso a2a trace list", "",+ "Trace events are observable progress only. Never send secrets, system prompts, hidden reasoning, or private chain-of-thought."+ ].join("\n");+}++async function start(options) {+ const intent = clean(options.intent || options._[0], 1000);+ if (!intent) fail("start requires --intent <text>");+ const agent = clean(options.agent || process.env.MSO_A2A_AGENT || "external", 48) || "external";+ const project = clean(options.project || "", 240) || undefined;+ const constraints = clean(options.constraints || "", 500) || undefined;+ const runId = validRunId(options.run);+ const sessionOut = await api("/api/v1/agent-sessions", {+ method: "POST",+ body: JSON.stringify({ action: "create", title: "A2A " + agent + ": " + intent.slice(0, 88), cwd: process.cwd() })+ });+ const session = sessionOut && sessionOut.session;+ if (!session || !session.id) fail("MSO did not create a durable agent session");+ const affected = csv(options.affected), reserved = csv(options.reserved);+ const workflow = await callTool(session.id, "workflow_start", {+ intent, ...(project ? { project } : {}), ...(constraints ? { constraints } : {}),+ ...(affected ? { affected_paths: affected } : {}), ...(reserved ? { reserved_resources: reserved } : {})+ }, "write");+ const workflowId = clean(+ (workflow && (workflow.workflowId || (workflow.workflow && workflow.workflow.id) || workflow.id)) || "", 120+ );+ if (!workflowId) fail("MSO workflow_start did not return a workflow id");+ const now = new Date().toISOString();+ const state = {+ version: 1, runId, agent, ...(project ? { project } : {}), sessionId: session.id,+ ...(session.label || session.name ? { sessionLabel: session.label || session.name } : {}),+ workflowId, status: "active", startedAt: now, updatedAt: now+ };+ await saveState(state);+ output({+ ok: true, run_id: runId, agent, session_id: session.id, session_label: state.sessionLabel,+ workflow_id: workflowId, workspace: findString(workflow, "workspacePath"),+ instruction: "Use this exact run for progress events. If MSO returned an isolated workspace, perform source-changing work there. Finish only with verification evidence."+ });+}++async function attach(options) {+ if (!options.session || !options.workflow) fail("attach requires --session <id> and --workflow <id>");+ const state = await resolveState({+ ...options, run: undefined, "run-id": options.run || freshRunId()+ });+ state.runId = validRunId(options.run || state.runId);+ state.status = "active";+ state.updatedAt = new Date().toISOString();+ const status = await callTool(state.sessionId, "workflow_status", { workflow_id: state.workflowId }, "read");+ await saveState(state);+ output({ ok: true, run_id: state.runId, session_id: state.sessionId, workflow_id: state.workflowId, status });+}++async function emit(kind, options) {+ const state = await resolveState(options);+ const message = clean(options.message || options._[0], 360);+ if (!message) fail(kind + " requires --message <text>");+ const stage = clean(options.stage || "", 40);+ const note = clean("[A2A:" + (state.agent || "external") + "] " + kind + (stage ? "/" + stage : "") + " - " + message, 490);+ const fingerprint = kind + "|" + stage + "|" + message, nowMs = Date.now();+ if (state.lastFingerprint === fingerprint && nowMs - Number(state.lastEventMs || 0) < 15000) {+ output({ ok: true, deduplicated: true, run_id: state.runId, workflow_id: state.workflowId });+ return;+ }+ await callTool(state.sessionId, "agent_session_note", { note, workflow_id: state.workflowId }, "write");+ if (options.run) {+ state.updatedAt = new Date(nowMs).toISOString();+ state.lastEventMs = nowMs;+ state.lastFingerprint = fingerprint;+ await saveState(state);+ }+ output({ ok: true, run_id: state.runId, workflow_id: state.workflowId, event: { kind, ...(stage ? { stage } : {}), message } });+}++async function status(options) {+ const state = await resolveState(options);+ const workflow = await callTool(state.sessionId, "workflow_status", { workflow_id: state.workflowId }, "read");+ output({ ok: true, run_id: state.runId, session_id: state.sessionId, workflow_id: state.workflowId, workflow });+}++async function context(options) {+ const state = await resolveState(options);+ const limit = Math.max(1, Math.min(120, Number(options.limit) || 120));+ const flow = await callTool(state.sessionId, "agent_session_flow", { session_ref: state.sessionId, limit }, "read");+ output({ ok: true, run_id: state.runId, workflow_id: state.workflowId, flow });+}++async function finish(options) {+ const state = await resolveState(options);+ const summary = clean(options.summary || options._[0], 1200);+ if (!summary) fail("finish requires --summary <text>");+ const success = options.failed !== true && options.success !== "false";+ const evidence = await evidenceInput(options.evidence);+ const result = await callTool(state.sessionId, "workflow_finish", {+ workflow_id: state.workflowId, summary, success, ...(evidence ? { evidence } : {})+ }, "write");+ if (options.run) {+ state.status = success ? "finished" : "failed";+ state.updatedAt = new Date().toISOString();+ await saveState(state);+ }+ output({ ok: true, run_id: state.runId, workflow_id: state.workflowId, success, result });+}++async function cancel(options) {+ const state = await resolveState(options);+ const reason = clean(options.reason || options._[0], 500);+ const result = await callTool(state.sessionId, "workflow_cancel", {+ workflow_id: state.workflowId, ...(reason ? { reason } : {})+ }, "write");+ if (options.run) {+ state.status = "cancelled";+ state.updatedAt = new Date().toISOString();+ await saveState(state);+ }+ output({ ok: true, run_id: state.runId, workflow_id: state.workflowId, result });+}++export async function main(argv = process.argv.slice(2)) {+ const { command, options } = parseArgs(argv);+ if (command === "help" || command === "--help" || command === "-h") { process.stdout.write(usage() + "\n"); return; }+ if (command === "start") return start(options);+ if (command === "attach") return attach(options);+ if (EVENT_KINDS.has(command)) return emit(command, options);+ if (command === "status") return status(options);+ if (command === "context") return context(options);+ if (command === "finish") return finish(options);+ if (command === "cancel") return cancel(options);+ if (command === "list") return listRuns();+ fail("unknown A2A trace command: " + command + "\n" + usage());+}++if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {+ main().catch((error) => {+ process.stderr.write("a2a-trace: " + (error instanceof Error ? error.message : String(error)) + "\n");+ process.exitCode = 1;+ });+}diff --git a/scripts/a2a-trace.test.ts b/scripts/a2a-trace.test.tsnew file mode 100644index 00000000..cc7f1a8d--- /dev/null+++ b/scripts/a2a-trace.test.ts@@ -0,0 +1,87 @@+// @ts-nocheck+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";+import { mkdtemp, readFile, rm, stat } from "node:fs/promises";+import os from "node:os";+import path from "node:path";++describe("A2A workflow trace bridge", () => {+ let stateDir;+ let mod;+ const requests = [];++ beforeAll(async () => {+ stateDir = await mkdtemp(path.join(os.tmpdir(), "mso-a2a-trace-"));+ process.env.MSO_A2A_TRACE_STATE_DIR = stateDir;+ process.env.MSO_AGENT_BASE = "http://127.0.0.1:4005";+ process.env.MSO_AGENT_ORIGIN = "http://127.0.0.1:4005";+ process.env.MSO_AGENT_JAR = "";+ vi.stubGlobal("fetch", vi.fn(async (url, init = {}) => {+ const body = init.body ? JSON.parse(String(init.body)) : null;+ requests.push({ url: String(url), body });+ if (String(url).endsWith("/api/v1/agent-sessions")) {+ return new Response(JSON.stringify({+ session: { id: "session-1", name: "trace-agent", label: "trace-agent-project" }+ }), { status: 200, headers: { "content-type": "application/json" } });+ }+ if (String(url).endsWith("/api/v1/agent-tools")) {+ const name = body && body.name;+ let result = { ok: true };+ if (name === "workflow_start") result = { workflowId: "workflow-1", bootstrap: { orchestration: { workspacePath: "/tmp/worktree" } } };+ if (name === "workflow_status") result = { active: true, workflowId: "workflow-1", stepCount: 1, steps: [] };+ if (name === "agent_session_flow") result = { session: { label: "trace-agent-project" }, steps: [{ ref: "S1", title: "Implement" }] };+ if (name === "workflow_finish") result = { workflow: { id: "workflow-1" }, evidence: { valid: true } };+ return new Response(JSON.stringify({ ok: true, result: JSON.stringify(result) }), {+ status: 200,+ headers: { "content-type": "application/json" }+ });+ }+ return new Response(JSON.stringify({ error: "unexpected route" }), { status: 404 });+ }));+ vi.spyOn(process.stdout, "write").mockImplementation(() => true);+ mod = await import("./a2a-trace.mjs");+ });++ afterAll(async () => {+ vi.restoreAllMocks();+ delete process.env.MSO_A2A_TRACE_STATE_DIR;+ await rm(stateDir, { recursive: true, force: true });+ });++ it("creates one durable session/workflow and correlates safe progress + finish", async () => {+ await mod.main(["start", "--intent", "Implement A2A trace", "--project", "mso", "--agent", "codex", "--run", "a2a-test"]);+ await mod.main(["progress", "--run", "a2a-test", "--stage", "implement", "--message", "Bounded implementation complete"]);+ await mod.main(["status", "--run", "a2a-test"]);+ await mod.main(["context", "--run", "a2a-test"]);+ await mod.main(["finish", "--run", "a2a-test", "--summary", "Implemented and verified", "--evidence", "{\"tests\":[\"targeted test passed\"]}"]);++ const toolBodies = requests.filter((row) => row.body && row.body.name).map((row) => row.body);+ expect(toolBodies.map((row) => row.name)).toEqual([+ "workflow_start",+ "agent_session_note",+ "workflow_status",+ "agent_session_flow",+ "workflow_finish"+ ]);+ const note = toolBodies.find((row) => row.name === "agent_session_note");+ expect(note.input.workflow_id).toBe("workflow-1");+ expect(note.input.note).toContain("[A2A:codex] progress/implement");+ expect(note.approvalDigest).toMatch(/^[a-f0-9]{64}$/);++ const finish = toolBodies.find((row) => row.name === "workflow_finish");+ expect(finish.input.workflow_id).toBe("workflow-1");+ expect(finish.input.evidence.tests).toEqual(["targeted test passed"]);++ const file = path.join(stateDir, "a2a-test.json");+ expect(JSON.parse(await readFile(file, "utf8"))).toMatchObject({+ runId: "a2a-test",+ sessionId: "session-1",+ workflowId: "workflow-1",+ status: "finished"+ });+ expect((await stat(file)).mode & 0o777).toBe(0o600);+ });++ it("does not expose hidden reasoning as a trace event type", async () => {+ await expect(mod.main(["reasoning", "--run", "a2a-test", "--message", "private thoughts"])).rejects.toThrow("unknown A2A trace command");+ });+});diff --git a/scripts/cli/commands-state.sh b/scripts/cli/commands-state.shindex 20cbbf87..75585c6f 100755--- a/scripts/cli/commands-state.sh+++ b/scripts/cli/commands-state.sh@@ -57,6 +57,12 @@ case "$cmd" ina2a)sub="${1:-list}"; shift || truecase "$sub" in+ trace)+ # Explicit CLI invocation is the approval boundary. Reuse the normal owner+ # session + /api/v1/agent-tools path so workflow ownership, audit, redaction+ # and evidence gates stay identical to native MSO MCP calls.+ jget "/api/v1/agent-tools" >/dev/null+ MSO_AGENT_BASE="$B" MSO_AGENT_ORIGIN="$B" MSO_AGENT_JAR="$JAR" node "$ROOT/scripts/a2a-trace.mjs" "$@" ;;list) jget "/api/v1/a2a" ;;state) jget "/api/v1/a2a?action=state" ;;sessions) jget "/api/v1/a2a?action=local-sessions" ;;diff --git a/scripts/cli/commands.sh b/scripts/cli/commands.shindex 542eebfd..0293d805 100755--- a/scripts/cli/commands.sh+++ b/scripts/cli/commands.sh@@ -44,7 +44,7 @@ U_threads="threads list|show <id>|save <json>|rm <id>"U_agent_sessions="agent-sessions list [limit]|show <id>|create [title]"U_agents="agents list [current-session-id]|send <source-session-id> <target> <message> [message|task]|inbox <session-id> [--all]"U_org="org flow-custom-nodes|flow-nodes-move|flow-update|flow-replace|flow-node-upsert|flow-node-delete|flow-edge-upsert|flow-edge-delete <revision> <JSON with unitId|@file>|show|unit-upsert <revision> <JSON|@file>|seat-upsert <revision> <JSON|@file>|unit-delete <revision> <id>|seat-delete <revision> <id>|replace <revision> <JSON|@file>"-U_a2a="a2a list|state|sessions|spawn <source-session> <objective> [title]|inbox <session>|discover <url>|add <url> [alias]|rm <target>|send <target> <message> [--wait]|stream <target> <message>|task <target> <taskId> [history]|cancel <target> <taskId>|handoff <target> <objective> [context] [--wait]|local sessions|local handoff <session> <objective>|local spawn <sourceSession> <objective> [title]|local inbox <session>|auth list [target]|auth add <target> [label] [bearer|api-key|oauth2]|auth use <target> <credentialId|none>|auth rm <credentialId>|inbound list|inbound create [label] [read|write|exec]|inbound rm <tokenId>"+U_a2a="a2a list|state|sessions|spawn <source-session> <objective> [title]|inbox <session>|discover <url>|add <url> [alias]|rm <target>|send <target> <message> [--wait]|stream <target> <message>|task <target> <taskId> [history]|cancel <target> <taskId>|handoff <target> <objective> [context] [--wait]|local sessions|local handoff <session> <objective>|local spawn <sourceSession> <objective> [title]|local inbox <session>|trace <start|progress|plan|action|evidence|blocker|result|handoff|status|context|attach|finish|cancel|list> [...]|auth list [target]|auth add <target> [label] [bearer|api-key|oauth2]|auth use <target> <credentialId|none>|auth rm <credentialId>|inbound list|inbound create [label] [read|write|exec]|inbound rm <tokenId>"U_memory="memory list|add <text>|rm <id>"U_memory_graph="memory-graph [project]"U_config="config show|set <json>|key <provider>|style <off|caveman|ponytail>|rm <provider>"