nandi/oripublic Fork 0
2434cc7fb724f02b34c0189dfd5fb30c1a8a68e3
Commits
Clone
git clone https://git.rickub.com/nandi/ori.git
git clone ssh://git@rickub.com/nandi/ori.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

forked from bots-garden/ori

protocol.ts · 104 lines · 2.5 KBTypeScript Blame HistoryRaw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
/**
 * Wire contract with the ori backend, mirroring internal/bridge/protocol.go.
 *
 * ACP payloads (session updates, permission requests) arrive verbatim from
 * the agent, so their shapes follow https://agentclientprotocol.com.
 */

/** An ACP content block; only text blocks are rendered in this version. */
export interface AcpContentBlock {
	type: string;
	text?: string;
	[key: string]: unknown;
}

/** One piece of tool-call output: nested content, a file diff, or a terminal. */
export interface AcpToolCallContent {
	type: string;
	content?: AcpContentBlock;
	path?: string;
	oldText?: string | null;
	newText?: string;
	terminalId?: string;
}

/** A file location a tool call touches (Zed uses this to "follow the agent"). */
export interface AcpToolCallLocation {
	path: string;
	line?: number;
}

/** One entry of the agent's execution plan. */
export interface AcpPlanEntry {
	content: string;
	priority: string;
	status: string;
}

/** One choice offered by a permission request. */
export interface AcpPermissionOption {
	optionId: string;
	name: string;
	kind: string;
}

/** The ACP payload of a session/request_permission call. */
export interface AcpPermissionRequest {
	sessionId?: string;
	toolCall?: {
		toolCallId?: string;
		title?: string | null;
		kind?: string;
		[key: string]: unknown;
	};
	options?: AcpPermissionOption[];
}

/**
 * One ACP session/update notification payload, discriminated by
 * sessionUpdate. Message/thought chunks use `content` as a single block;
 * tool calls use it as an array of AcpToolCallContent.
 */
export interface AcpSessionUpdate {
	sessionUpdate: string;
	content?: AcpContentBlock | AcpToolCallContent[];
	toolCallId?: string;
	title?: string | null;
	kind?: string;
	status?: string;
	locations?: AcpToolCallLocation[];
	entries?: AcpPlanEntry[];
	[key: string]: unknown;
}

/** A message sent by the server over the WebSocket. */
export interface ServerMessage {
	type:
		| "hello"
		| "user_message"
		| "session_update"
		| "permission_request"
		| "permission_resolved"
		| "turn_started"
		| "turn_ended"
		| "error";
	sessionId?: string;
	turnActive?: boolean;
	update?: AcpSessionUpdate;
	requestId?: string;
	request?: AcpPermissionRequest;
	text?: string;
	stopReason?: string;
	message?: string;
}

/** A message the browser sends to the server. */
export type ClientMessage =
	| { type: "prompt"; text: string }
	| { type: "cancel" }
	| {
			type: "permission_response";
			requestId: string;
			optionId?: string;
			cancelled?: boolean;
	  };