mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-22 15:38:23 +00:00
* plan: mcp-activity * plan: mcp-activity list format * plan: mcp-activity answers and live step lines * mcp: a silent line per step of Claude's work, completed at its end * plan: mcp-activity as implemented * mcp: finalize step lines within a day and load only the hook's modules * plan: mcp-activity review decisions as implemented * plan: mcp-allow-tool * mcp: approve a tool for the rest of a session with one tap * plan: mcp-allow-tool as implemented * mcp: docs of the approval of a tool for the rest of a session * mcp: record the checks of the PreToolUse hook with Claude Code * plan: mcp-allow-tool citations of the new code * mcp: keep the approvals of tools while the session's process re-attaches * plan: mcp-allow-tool review round 1 * mcp: end the approvals of tools when the session's group is lost * mcp: tool approvals end when the session's group is lost, docs and tests * mcp: tool approvals follow the process that opened the session last A process is identified by its ID and its start time, read from /proc/PID/stat on Linux and from ps on macOS. A registration from a process with the same ID and another start time ends the approvals. /attach has the session server's parent process ID. While two processes have the session attached, only the attachments of the process of the last /session get the approved tools; the others get an empty list. Tests cover the end of the approvals at a load of a lost group. * plan: mcp-allow-tool decisions 36 and 37, the group's loss in the rules and the design * mcp: a process whose start time is unknown counts as another process A registration of the session's process ends the tool approvals when its start time can't be read, on systems other than Linux and macOS and after a failed read. The start time is read only for a process ID that is a positive integer; on macOS, /bin/ps runs with a 2 s timeout.
130 lines
2.9 KiB
TypeScript
130 lines
2.9 KiB
TypeScript
import {CallToolResult} from "@modelcontextprotocol/server"
|
|
import {Config} from "./config"
|
|
import {ToolName} from "./tools"
|
|
|
|
// spec: spec/architecture.md#protocol-protocolversion
|
|
export const protocolVersion = 1
|
|
// spec: spec/architecture.md#protocol-protocolversion
|
|
export const unattendedStatus = 403
|
|
|
|
export interface ServiceInfo {
|
|
version: string
|
|
protocol: number
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-owners
|
|
export interface Owners {
|
|
owners: string[]
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-owners
|
|
export interface OwnerState extends Owners {
|
|
link?: string
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-sessionrequest
|
|
export interface SessionRequest {
|
|
id: string
|
|
pid?: number
|
|
project: string
|
|
name?: string
|
|
config: Config
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-sessionrequest
|
|
export interface TitleRequest {
|
|
id: string
|
|
pid?: number
|
|
at?: number
|
|
name?: string
|
|
project: string
|
|
model?: string
|
|
config: Config
|
|
unattended?: boolean
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-permissionrequest
|
|
export interface PermissionRequest {
|
|
id: string
|
|
requestId: string
|
|
toolName: string
|
|
description: string
|
|
inputPreview: string
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-permissionrequest
|
|
export interface TurnRequest {
|
|
id: string
|
|
pid?: number
|
|
at?: number
|
|
prompt?: string
|
|
typed?: boolean
|
|
note?: string
|
|
midTurn?: boolean
|
|
answer?: string
|
|
model?: string
|
|
effort?: string
|
|
step?: Step
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-step
|
|
export interface Step {
|
|
id: string
|
|
text: string
|
|
end?: boolean
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-attachline
|
|
export interface AttachLine {
|
|
prompt?: {text: string; from: string; item: number; file?: string; replyTo?: {item?: number; from?: string}}
|
|
permission?: {requestId: string; behavior: "allow" | "deny"}
|
|
tools?: ApprovedTool[]
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-attachline
|
|
export interface ApprovedTool {
|
|
tool: string
|
|
approvedBy: string
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-titlereply
|
|
export interface TitleReply extends ServiceInfo {
|
|
mainGroup: string
|
|
owner: OwnerState
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-titlereply
|
|
export interface SessionReply extends ServiceInfo {
|
|
number: number
|
|
displayName: string
|
|
owner: Owners
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-titlereply
|
|
export interface AttachRequest {
|
|
id: string
|
|
pid?: number
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-titlereply
|
|
export interface CallRequest {
|
|
id: string
|
|
tool: ToolName
|
|
input: unknown
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-titlereply
|
|
export type CallLine = {progress: string} | {result: CallToolResult | null}
|
|
|
|
// spec: spec/architecture.md#protocol-statusreply
|
|
export interface StatusReply extends ServiceInfo {
|
|
mainGroup: string
|
|
owner: Owners
|
|
sessions: {number: number; name: string; attached: number}[]
|
|
}
|
|
|
|
// spec: spec/architecture.md#protocol-statusreply
|
|
export interface ResetReply {
|
|
link: string
|
|
}
|