@2389research/coven-openclaw 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,641 @@
1
+ // ABOUTME: Protocol buffer definitions for agent-server communication.
2
+ // ABOUTME: Defines the bidirectional streaming protocol for coven control.
3
+
4
+ syntax = "proto3";
5
+ package coven;
6
+
7
+ import "google/protobuf/empty.proto";
8
+
9
+ // Agent connects to server, receives commands, sends results
10
+ service CovenControl {
11
+ // Agent registration - bidirectional stream for lifecycle
12
+ rpc AgentStream(stream AgentMessage) returns (stream ServerMessage);
13
+ }
14
+
15
+ // Messages from agent to server
16
+ message AgentMessage {
17
+ oneof payload {
18
+ RegisterAgent register = 1;
19
+ MessageResponse response = 2;
20
+ Heartbeat heartbeat = 3;
21
+ InjectionAck injection_ack = 4; // Acknowledge context injection
22
+ ExecutePackTool execute_pack_tool = 5; // Request pack tool execution
23
+ }
24
+ }
25
+
26
+ // Git repository state (optional - agent may not be in a git repo)
27
+ message GitInfo {
28
+ string branch = 1;
29
+ string commit = 2;
30
+ bool dirty = 3;
31
+ string remote = 4;
32
+ int32 ahead = 5;
33
+ int32 behind = 6;
34
+ }
35
+
36
+ // Environment metadata sent during registration
37
+ message AgentMetadata {
38
+ string working_directory = 1;
39
+ GitInfo git = 2;
40
+ string hostname = 3;
41
+ string os = 4;
42
+ repeated string workspaces = 5; // Workspace tags for filtering
43
+ string backend = 6; // Backend type: "mux", "cli", "acp", "direct"
44
+ }
45
+
46
+ // Agent registration
47
+ message RegisterAgent {
48
+ string agent_id = 1; // Unique agent identifier
49
+ string name = 2; // Human-readable name
50
+ repeated string capabilities = 3; // What this agent can do
51
+ AgentMetadata metadata = 4; // Environment context
52
+ repeated string protocol_features = 5; // Supported features: "token_usage", "tool_states", "injection", "cancellation"
53
+ }
54
+
55
+ // Response to a message request
56
+ message MessageResponse {
57
+ string request_id = 1; // Correlates with SendMessage
58
+ oneof event {
59
+ string thinking = 2;
60
+ string text = 3;
61
+ ToolUse tool_use = 4;
62
+ ToolResult tool_result = 5;
63
+ Done done = 6;
64
+ string error = 7;
65
+ FileData file = 8;
66
+ ToolApprovalRequest tool_approval_request = 9;
67
+ SessionInit session_init = 10;
68
+ SessionOrphaned session_orphaned = 11;
69
+ TokenUsage usage = 12; // Token consumption update
70
+ ToolStateUpdate tool_state = 13; // Tool lifecycle update
71
+ Cancelled cancelled = 14; // Request was cancelled
72
+ }
73
+ }
74
+
75
+ // Backend session initialized (session_id assigned/confirmed)
76
+ message SessionInit {
77
+ string session_id = 1;
78
+ }
79
+
80
+ // Backend session was orphaned (expired, lost, needs retry)
81
+ message SessionOrphaned {
82
+ string reason = 1;
83
+ }
84
+
85
+ // Token usage statistics from the LLM provider
86
+ message TokenUsage {
87
+ int32 input_tokens = 1; // Tokens in the prompt
88
+ int32 output_tokens = 2; // Tokens generated
89
+ int32 cache_read_tokens = 3; // Tokens read from cache (Anthropic)
90
+ int32 cache_write_tokens = 4; // Tokens written to cache (Anthropic)
91
+ int32 thinking_tokens = 5; // Extended thinking tokens (Claude)
92
+ }
93
+
94
+ // Tool execution state
95
+ enum ToolState {
96
+ TOOL_STATE_UNSPECIFIED = 0;
97
+ TOOL_STATE_PENDING = 1; // Tool identified, not yet started
98
+ TOOL_STATE_AWAITING_APPROVAL = 2; // Waiting for human approval
99
+ TOOL_STATE_RUNNING = 3; // Actively executing
100
+ TOOL_STATE_COMPLETED = 4; // Finished successfully
101
+ TOOL_STATE_FAILED = 5; // Execution error
102
+ TOOL_STATE_DENIED = 6; // Approval denied
103
+ TOOL_STATE_TIMEOUT = 7; // Execution timed out
104
+ TOOL_STATE_CANCELLED = 8; // Cancelled by user/system
105
+ }
106
+
107
+ // Tool state transition notification
108
+ message ToolStateUpdate {
109
+ string id = 1; // Tool invocation ID (matches ToolUse.id)
110
+ ToolState state = 2; // New state
111
+ optional string detail = 3; // Optional detail (error message, etc.)
112
+ }
113
+
114
+ // Cancellation acknowledgment (agent → server)
115
+ message Cancelled {
116
+ string reason = 1; // Echo back the reason
117
+ }
118
+
119
+ // Priority for context injection
120
+ enum InjectionPriority {
121
+ INJECTION_PRIORITY_UNSPECIFIED = 0;
122
+ INJECTION_PRIORITY_IMMEDIATE = 1; // Process before current turn completes
123
+ INJECTION_PRIORITY_NORMAL = 2; // Standard priority
124
+ INJECTION_PRIORITY_DEFERRED = 3; // Process after current work
125
+ }
126
+
127
+ // Context injection request (server → agent)
128
+ message InjectContext {
129
+ string injection_id = 1; // Unique ID for acknowledgment
130
+ string content = 2; // Content to inject
131
+ InjectionPriority priority = 3; // When to process
132
+ optional string source = 4; // Origin (e.g., "pack:elevenlabs", "system")
133
+ }
134
+
135
+ // Context injection acknowledgment (agent → server)
136
+ message InjectionAck {
137
+ string injection_id = 1; // Matches InjectContext.injection_id
138
+ bool accepted = 2; // Whether agent accepted the injection
139
+ optional string reason = 3; // Why rejected (if not accepted)
140
+ }
141
+
142
+ // Request cancellation (server → agent)
143
+ message CancelRequest {
144
+ string request_id = 1; // Request to cancel
145
+ optional string reason = 2; // Why cancelled (e.g., "user_requested")
146
+ }
147
+
148
+ // Request for tool approval before execution (agent → server)
149
+ message ToolApprovalRequest {
150
+ string id = 1; // Correlates with ToolUse.id
151
+ string name = 2; // Tool name
152
+ string input_json = 3; // Tool input for display
153
+ }
154
+
155
+ message ToolUse {
156
+ string id = 1;
157
+ string name = 2;
158
+ string input_json = 3;
159
+ }
160
+
161
+ message ToolResult {
162
+ string id = 1;
163
+ string output = 2;
164
+ bool is_error = 3;
165
+ }
166
+
167
+ message Done {
168
+ string full_response = 1;
169
+ }
170
+
171
+ message FileData {
172
+ string filename = 1;
173
+ string mime_type = 2;
174
+ bytes data = 3;
175
+ }
176
+
177
+ message Heartbeat {
178
+ int64 timestamp_ms = 1;
179
+ }
180
+
181
+ // Agent requests pack tool execution (agent → server)
182
+ message ExecutePackTool {
183
+ string request_id = 1; // Unique ID for correlation
184
+ string tool_name = 2; // Name of the pack tool to execute
185
+ string input_json = 3; // Tool input as JSON
186
+ }
187
+
188
+ // Server returns pack tool execution result (server → agent)
189
+ message PackToolResult {
190
+ string request_id = 1; // Correlates with ExecutePackTool.request_id
191
+ oneof result {
192
+ string output_json = 2; // Success: tool output as JSON
193
+ string error = 3; // Failure: error message
194
+ }
195
+ }
196
+
197
+ // Messages from server to agent
198
+ message ServerMessage {
199
+ oneof payload {
200
+ Welcome welcome = 1;
201
+ SendMessage send_message = 2;
202
+ Shutdown shutdown = 3;
203
+ ToolApprovalResponse tool_approval = 4;
204
+ RegistrationError registration_error = 5;
205
+ InjectContext inject_context = 6; // Push context to agent mid-turn
206
+ CancelRequest cancel_request = 7; // Cancel in-flight request
207
+ PackToolResult pack_tool_result = 8; // Result of pack tool execution
208
+ }
209
+ }
210
+
211
+ // Server rejects registration (e.g., agent_id already taken)
212
+ message RegistrationError {
213
+ string reason = 1; // Human-readable error message
214
+ string suggested_id = 2; // Optional: server-suggested alternative ID
215
+ }
216
+
217
+ // Response to tool approval request (server → agent)
218
+ message ToolApprovalResponse {
219
+ string id = 1; // Correlates with ToolApprovalRequest.id
220
+ bool approved = 2; // True = execute, False = skip
221
+ bool approve_all = 3; // If true, auto-approve remaining tools this request
222
+ }
223
+
224
+ // Server acknowledges registration
225
+ message Welcome {
226
+ string server_id = 1;
227
+ string agent_id = 2; // Confirmed agent ID (instance name)
228
+ string instance_id = 3; // Short code for binding commands
229
+ string principal_id = 4; // Principal UUID for reference
230
+ repeated ToolDefinition available_tools = 5; // Pack tools available to this agent
231
+ string mcp_token = 6; // Token for MCP endpoint authentication (capability-scoped)
232
+ string mcp_endpoint = 7; // Base MCP endpoint URL (e.g., "http://gateway:8080/mcp")
233
+ map<string, string> secrets = 8; // Resolved env vars for this agent (global + overrides)
234
+ }
235
+
236
+ // Server tells agent to process a message
237
+ message SendMessage {
238
+ string request_id = 1; // Unique request ID for correlation
239
+ string thread_id = 2; // Conversation thread
240
+ string sender = 3; // Who sent the message
241
+ string content = 4; // Message content
242
+ repeated FileAttachment attachments = 5;
243
+ }
244
+
245
+ message FileAttachment {
246
+ string filename = 1;
247
+ string mime_type = 2;
248
+ bytes data = 3;
249
+ }
250
+
251
+ // Server tells agent to shut down
252
+ message Shutdown {
253
+ string reason = 1;
254
+ }
255
+
256
+ // AdminService provides administrative operations for managing the gateway.
257
+ // All methods require admin or owner role (enforced by RequireAdmin interceptor).
258
+ service AdminService {
259
+ rpc ListBindings(ListBindingsRequest) returns (ListBindingsResponse);
260
+ rpc CreateBinding(CreateBindingRequest) returns (Binding);
261
+ rpc UpdateBinding(UpdateBindingRequest) returns (Binding);
262
+ rpc DeleteBinding(DeleteBindingRequest) returns (DeleteBindingResponse);
263
+
264
+ // Token management
265
+ rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse);
266
+
267
+ // Principal management
268
+ rpc ListPrincipals(ListPrincipalsRequest) returns (ListPrincipalsResponse);
269
+ rpc CreatePrincipal(CreatePrincipalRequest) returns (Principal);
270
+ rpc DeletePrincipal(DeletePrincipalRequest) returns (DeletePrincipalResponse);
271
+ }
272
+
273
+ // Binding represents a channel-to-agent mapping for message routing
274
+ message Binding {
275
+ string id = 1;
276
+ string frontend = 2;
277
+ string channel_id = 3;
278
+ string agent_id = 4;
279
+ string created_at = 5; // ISO-8601
280
+ optional string created_by = 6;
281
+ }
282
+
283
+ message ListBindingsRequest {
284
+ optional string frontend = 1;
285
+ optional string agent_id = 2;
286
+ }
287
+
288
+ message ListBindingsResponse {
289
+ repeated Binding bindings = 1;
290
+ }
291
+
292
+ message CreateBindingRequest {
293
+ string frontend = 1;
294
+ string channel_id = 2;
295
+ string agent_id = 3;
296
+ }
297
+
298
+ message UpdateBindingRequest {
299
+ string id = 1;
300
+ string agent_id = 2;
301
+ }
302
+
303
+ message DeleteBindingRequest {
304
+ string id = 1;
305
+ }
306
+
307
+ message DeleteBindingResponse {
308
+ // Empty response indicates success
309
+ }
310
+
311
+ // Token management messages
312
+ message CreateTokenRequest {
313
+ string principal_id = 1; // Principal to create token for
314
+ int64 ttl_seconds = 2; // Token lifetime in seconds (default: 30 days)
315
+ }
316
+
317
+ message CreateTokenResponse {
318
+ string token = 1; // The generated JWT token
319
+ string expires_at = 2; // ISO-8601 expiration timestamp
320
+ }
321
+
322
+ // Principal management messages
323
+ message Principal {
324
+ string id = 1;
325
+ string type = 2; // "client", "agent", "pack"
326
+ string display_name = 3;
327
+ string status = 4; // "pending", "approved", "online", "offline", "revoked"
328
+ optional string pubkey_fp = 5; // SSH public key fingerprint (for agents)
329
+ string created_at = 6; // ISO-8601
330
+ repeated string roles = 7;
331
+ }
332
+
333
+ message ListPrincipalsRequest {
334
+ optional string type = 1; // Filter by type
335
+ optional string status = 2; // Filter by status
336
+ }
337
+
338
+ message ListPrincipalsResponse {
339
+ repeated Principal principals = 1;
340
+ }
341
+
342
+ message CreatePrincipalRequest {
343
+ string type = 1; // "client" or "agent"
344
+ string display_name = 2;
345
+ optional string pubkey = 3; // Full SSH public key (for agents)
346
+ optional string pubkey_fp = 4; // Or just the fingerprint
347
+ repeated string roles = 5; // Roles to assign (e.g., "member")
348
+ }
349
+
350
+ message DeletePrincipalRequest {
351
+ string id = 1;
352
+ }
353
+
354
+ message DeletePrincipalResponse {
355
+ // Empty response indicates success
356
+ }
357
+
358
+ // ClientService provides client-facing operations for interacting with agents.
359
+ // Requires authenticated principal (member role or higher).
360
+ service ClientService {
361
+ rpc GetEvents(GetEventsRequest) returns (GetEventsResponse);
362
+ rpc GetMe(google.protobuf.Empty) returns (MeResponse);
363
+ rpc SendMessage(ClientSendMessageRequest) returns (ClientSendMessageResponse);
364
+
365
+ // Real-time streaming of events for a conversation
366
+ rpc StreamEvents(StreamEventsRequest) returns (stream ClientStreamEvent);
367
+
368
+ // List available agents for this principal
369
+ rpc ListAgents(ListAgentsRequest) returns (ListAgentsResponse);
370
+
371
+ // Register an agent (members can self-register agents)
372
+ rpc RegisterAgent(RegisterAgentRequest) returns (RegisterAgentResponse);
373
+
374
+ // Register a client (members can self-register clients like TUI)
375
+ rpc RegisterClient(RegisterClientRequest) returns (RegisterClientResponse);
376
+
377
+ // Respond to a tool approval request
378
+ rpc ApproveTool(ApproveToolRequest) returns (ApproveToolResponse);
379
+
380
+ // Respond to a user question (from ask_user tool)
381
+ rpc AnswerQuestion(AnswerQuestionRequest) returns (AnswerQuestionResponse);
382
+ }
383
+
384
+ // Request to answer a user question
385
+ message AnswerQuestionRequest {
386
+ string agent_id = 1; // Which agent asked the question
387
+ string question_id = 2; // Correlates with UserQuestionRequest.question_id
388
+ repeated string selected = 3; // Selected option label(s)
389
+ optional string custom_text = 4; // If user typed a custom "Other" response
390
+ }
391
+
392
+ // Response to answering a question
393
+ message AnswerQuestionResponse {
394
+ bool success = 1;
395
+ optional string error = 2;
396
+ }
397
+
398
+ // Request to approve or deny a tool execution
399
+ message ApproveToolRequest {
400
+ string agent_id = 1; // Which agent's tool to approve
401
+ string tool_id = 2; // Correlates with ClientToolApprovalRequest.tool_id
402
+ bool approved = 3; // True = execute, False = skip
403
+ bool approve_all = 4; // If true, auto-approve remaining tools this request
404
+ }
405
+
406
+ // Response to tool approval
407
+ message ApproveToolResponse {
408
+ bool success = 1; // Whether the approval was processed
409
+ optional string error = 2; // Error message if not successful
410
+ }
411
+
412
+ // Request to stream events for a conversation
413
+ message StreamEventsRequest {
414
+ string conversation_key = 1; // Which conversation to stream
415
+ optional string since_event_id = 2; // Resume from this event ID (for reconnection)
416
+ }
417
+
418
+ // Streaming event sent to clients - wraps all possible event types
419
+ message ClientStreamEvent {
420
+ string conversation_key = 1;
421
+ string timestamp = 2; // ISO-8601
422
+
423
+ oneof payload {
424
+ // Text content events
425
+ TextChunk text = 3;
426
+ ThinkingChunk thinking = 4;
427
+
428
+ // Tool lifecycle events
429
+ ToolUse tool_use = 5;
430
+ ToolResult tool_result = 6;
431
+ ToolStateUpdate tool_state = 7;
432
+
433
+ // Session events
434
+ TokenUsage usage = 8;
435
+ StreamDone done = 9;
436
+ StreamError error = 10;
437
+
438
+ // Full message (for history replay)
439
+ Event event = 11;
440
+
441
+ // Tool approval request (needs human decision)
442
+ ClientToolApprovalRequest tool_approval = 12;
443
+
444
+ // User question request (agent asking user a question via ask_user tool)
445
+ UserQuestionRequest user_question = 13;
446
+ }
447
+ }
448
+
449
+ // User question request sent to clients (from ask_user builtin tool)
450
+ message UserQuestionRequest {
451
+ string agent_id = 1; // Which agent is asking
452
+ string question_id = 2; // Unique ID for correlation
453
+ string question = 3; // The question text
454
+ repeated QuestionOption options = 4; // Multiple choice options
455
+ bool multi_select = 5; // Can select multiple answers
456
+ optional string header = 6; // Short label/category for the question
457
+ int32 timeout_seconds = 7; // How long client has to respond
458
+ }
459
+
460
+ // A single option in a user question
461
+ message QuestionOption {
462
+ string label = 1; // Display text (also used as the value)
463
+ optional string description = 2; // Optional explanation
464
+ }
465
+
466
+ // Tool approval request sent to clients (wraps ToolApprovalRequest with agent context)
467
+ message ClientToolApprovalRequest {
468
+ string agent_id = 1; // Which agent is requesting approval
469
+ string request_id = 2; // Correlates with the message request
470
+ string tool_id = 3; // Correlates with ToolUse.id
471
+ string tool_name = 4; // Tool name for display
472
+ string input_json = 5; // Tool input for display
473
+ }
474
+
475
+ // Incremental text chunk
476
+ message TextChunk {
477
+ string content = 1;
478
+ }
479
+
480
+ // Incremental thinking chunk
481
+ message ThinkingChunk {
482
+ string content = 1;
483
+ }
484
+
485
+ // Stream completed successfully
486
+ message StreamDone {
487
+ optional string full_response = 1; // Complete concatenated response
488
+ }
489
+
490
+ // Stream error
491
+ message StreamError {
492
+ string message = 1;
493
+ bool recoverable = 2; // Can client retry?
494
+ }
495
+
496
+ // Agent info for client listing
497
+ message AgentInfo {
498
+ string id = 1;
499
+ string name = 2;
500
+ string backend = 3; // "mux", "cli", "acp", "direct"
501
+ string working_dir = 4;
502
+ bool connected = 5;
503
+ optional AgentMetadata metadata = 6;
504
+ }
505
+
506
+ message ListAgentsRequest {
507
+ optional string workspace = 1; // Filter by workspace tag
508
+ }
509
+
510
+ message ListAgentsResponse {
511
+ repeated AgentInfo agents = 1;
512
+ }
513
+
514
+ // RegisterAgentRequest allows a linked device to register an agent
515
+ message RegisterAgentRequest {
516
+ string display_name = 1; // Name for the agent
517
+ string fingerprint = 2; // SSH key fingerprint (SHA256 hex, 64 chars)
518
+ }
519
+
520
+ // RegisterAgentResponse returns the created principal info
521
+ message RegisterAgentResponse {
522
+ string principal_id = 1;
523
+ string status = 2; // "approved"
524
+ }
525
+
526
+ // RegisterClientRequest allows a linked device to register a client (TUI, CLI)
527
+ message RegisterClientRequest {
528
+ string display_name = 1; // Name for the client
529
+ string fingerprint = 2; // SSH key fingerprint (SHA256 hex, 64 chars)
530
+ }
531
+
532
+ // RegisterClientResponse returns the created principal info
533
+ message RegisterClientResponse {
534
+ string principal_id = 1;
535
+ string status = 2; // "approved"
536
+ }
537
+
538
+ // ClientSendMessageRequest is the request for direct client message sending.
539
+ // The idempotency_key is required and must be unique per message to prevent duplicates.
540
+ message ClientSendMessageRequest {
541
+ string conversation_key = 1;
542
+ string content = 2;
543
+ repeated FileAttachment attachments = 3;
544
+ string idempotency_key = 4; // required, 1-100 chars
545
+ }
546
+
547
+ // ClientSendMessageResponse is the response for direct client message sending.
548
+ message ClientSendMessageResponse {
549
+ string status = 1; // "accepted" or "duplicate"
550
+ string message_id = 2; // assigned message ID (empty for duplicates)
551
+ }
552
+
553
+ // MeResponse contains the authenticated principal's identity information
554
+ message MeResponse {
555
+ string principal_id = 1;
556
+ string principal_type = 2;
557
+ string display_name = 3;
558
+ string status = 4;
559
+ repeated string roles = 5;
560
+ optional string member_id = 6;
561
+ optional string member_display_name = 7;
562
+ }
563
+
564
+ // Event represents a ledger event in conversation history
565
+ message Event {
566
+ string id = 1;
567
+ string conversation_key = 2;
568
+ string direction = 3; // "inbound_to_agent" or "outbound_from_agent"
569
+ string author = 4;
570
+ string timestamp = 5; // ISO-8601
571
+ string type = 6; // "message", "tool_call", "tool_result", "system", "error"
572
+ optional string text = 7;
573
+ optional string raw_transport = 8;
574
+ optional string raw_payload_ref = 9;
575
+ optional string actor_principal_id = 10;
576
+ optional string actor_member_id = 11;
577
+ }
578
+
579
+ message GetEventsRequest {
580
+ string conversation_key = 1;
581
+ optional string since = 2; // ISO-8601
582
+ optional string until = 3; // ISO-8601
583
+ optional int32 limit = 4; // 1-500
584
+ optional string cursor = 5;
585
+ }
586
+
587
+ message GetEventsResponse {
588
+ repeated Event events = 1;
589
+ optional string next_cursor = 2;
590
+ bool has_more = 3;
591
+ }
592
+
593
+ // Tool definitions for packs
594
+ message ToolDefinition {
595
+ string name = 1;
596
+ string description = 2;
597
+ string input_schema_json = 3; // MCP-compatible JSON Schema
598
+ repeated string required_capabilities = 4;
599
+ int32 timeout_seconds = 5; // optional, default 30
600
+ }
601
+
602
+ message PackManifest {
603
+ string pack_id = 1;
604
+ string version = 2;
605
+ repeated ToolDefinition tools = 3;
606
+ }
607
+
608
+ // Tool execution messages
609
+ message ExecuteToolRequest {
610
+ string tool_name = 1;
611
+ string input_json = 2;
612
+ string request_id = 3;
613
+ }
614
+
615
+ message ExecuteToolResponse {
616
+ string request_id = 1;
617
+ oneof result {
618
+ string output_json = 2;
619
+ string error = 3;
620
+ }
621
+ }
622
+
623
+ // Pack registration acknowledgment
624
+ message PackWelcome {
625
+ string pack_id = 1;
626
+ repeated string rejected_tools = 2; // Tools that collided with existing names
627
+ }
628
+
629
+ // Available tools list for agents
630
+ message AvailableTools {
631
+ repeated ToolDefinition tools = 1;
632
+ }
633
+
634
+ // PackService allows tool packs to connect and provide tools to agents
635
+ service PackService {
636
+ // Pack registers with manifest, receives tool execution requests
637
+ rpc Register(PackManifest) returns (stream ExecuteToolRequest);
638
+
639
+ // Pack sends tool execution results back
640
+ rpc ToolResult(ExecuteToolResponse) returns (google.protobuf.Empty);
641
+ }
package/src/.gitkeep ADDED
File without changes