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.

2.5 KB
Raw Blame
import { S, str, type McpTool } from "./tool-kit";
import { proposeJevActions, executeJevAction, type JevActionCandidate } from "@/lib/workflow/jev-action-layer";
import { listJevDecisionDefinitions } from "@/lib/workflow/jev-decision-registry";
import { readJevCalibration, readJevTelemetryWindows } from "@/lib/workflow/jev-telemetry";

const candidateSchema={type:"array",items:{type:"object",properties:{id:{type:"string"},tool:{type:"string"},arguments:{type:"object"},rationale:{type:"string"},risk:{type:"string",enum:["safe","review","destructive"]}},required:["id","tool"]}};
export const JEV_TOOLS:McpTool[]=[
 {name:"jev_action",title:"JEV Decision Gate",scope:"read",description:"Score bounded host-generated action candidates with JEV, explicitly execute a previously selected safe read action through MSO Capability Runtime, or inspect decision telemetry. Proposal never executes; write/destructive/review actions cannot use this execution path.",chatgptDescription:"JEV-score bounded actions; safe reads only.",annotations:{readOnlyHint:true,destructiveHint:false,openWorldHint:false,idempotentHint:false},limit:{key:"jev.action",max:30,windowMs:60_000},actionContract:{phase:"validate",target:"jev-action",sourceOfTruth:"live",validators:["tool-catalog","capability-digest","scope","token-allowlist","argument-constraints","workflow-policy"],verify:["post-action-jev","capability-outcome"],confirmation:"contextual",concurrency:"contextual",presentation:"structured"},inputSchema:S({action:{type:"string",enum:["propose","execute","metrics"]},state:{type:"object",additionalProperties:true},candidates:candidateSchema,proposal_id:{type:"string",maxLength:96},action_id:{type:"string",maxLength:80}},["action"]),run:async(a,context)=>{const{TOOLS_BY_NAME}=await import("./tools"),resolve=(name:string)=>TOOLS_BY_NAME.get(name),ctx={...(context.sessionId?{correlationId:context.sessionId}:{}),...(context.workflowId?{workflowRef:context.workflowId}:{})};if(a.action==="propose")return proposeJevActions(a.state&&typeof a.state==="object"&&!Array.isArray(a.state)?a.state as Record<string,unknown>:{},Array.isArray(a.candidates)?a.candidates as JevActionCandidate[]:[],resolve,undefined,ctx);if(a.action==="execute")return executeJevAction(str(a,"proposal_id"),str(a,"action_id"),{scope:context.scope,actor:context.actor,context},resolve);if(a.action==="metrics")return{kind:"mso.jev-metrics.v1",registry:listJevDecisionDefinitions(),windows:await readJevTelemetryWindows(),calibration:await readJevCalibration()};throw new Error("action must be propose, execute, or metrics");}}
];