@a3s-lab/code 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,1512 @@
1
+ syntax = "proto3";
2
+
3
+ package a3s.code.agent.v1;
4
+
5
+ // ============================================================================
6
+ // A3S Code Agent Service
7
+ // ============================================================================
8
+ // Standard coding agent interface. Any agent implementing this interface
9
+ // can be integrated into A3S Box.
10
+
11
+ service CodeAgentService {
12
+ // === Lifecycle Management ===
13
+ rpc HealthCheck(HealthCheckRequest) returns (HealthCheckResponse);
14
+ rpc GetCapabilities(GetCapabilitiesRequest) returns (GetCapabilitiesResponse);
15
+ rpc Initialize(InitializeRequest) returns (InitializeResponse);
16
+ rpc Shutdown(ShutdownRequest) returns (ShutdownResponse);
17
+
18
+ // === Session Management ===
19
+ rpc CreateSession(CreateSessionRequest) returns (CreateSessionResponse);
20
+ rpc DestroySession(DestroySessionRequest) returns (DestroySessionResponse);
21
+ rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse);
22
+ rpc GetSession(GetSessionRequest) returns (GetSessionResponse);
23
+ rpc ConfigureSession(ConfigureSessionRequest) returns (ConfigureSessionResponse);
24
+ rpc GetMessages(GetMessagesRequest) returns (GetMessagesResponse);
25
+
26
+ // === Code Generation ===
27
+ rpc Generate(GenerateRequest) returns (GenerateResponse);
28
+ rpc StreamGenerate(GenerateRequest) returns (stream GenerateChunk);
29
+ rpc GenerateStructured(GenerateStructuredRequest) returns (GenerateStructuredResponse);
30
+ rpc StreamGenerateStructured(GenerateStructuredRequest) returns (stream GenerateStructuredChunk);
31
+
32
+ // === Skill Management ===
33
+ rpc LoadSkill(LoadSkillRequest) returns (LoadSkillResponse);
34
+ rpc UnloadSkill(UnloadSkillRequest) returns (UnloadSkillResponse);
35
+ rpc ListSkills(ListSkillsRequest) returns (ListSkillsResponse);
36
+ rpc GetClaudeCodeSkills(GetClaudeCodeSkillsRequest) returns (GetClaudeCodeSkillsResponse);
37
+
38
+ // === Context Management ===
39
+ rpc GetContextUsage(GetContextUsageRequest) returns (GetContextUsageResponse);
40
+ rpc CompactContext(CompactContextRequest) returns (CompactContextResponse);
41
+ rpc ClearContext(ClearContextRequest) returns (ClearContextResponse);
42
+
43
+ // === Event Streaming ===
44
+ rpc SubscribeEvents(SubscribeEventsRequest) returns (stream AgentEvent);
45
+
46
+ // === Control Operations ===
47
+ rpc Cancel(CancelRequest) returns (CancelResponse);
48
+ rpc Pause(PauseRequest) returns (PauseResponse);
49
+ rpc Resume(ResumeRequest) returns (ResumeResponse);
50
+
51
+ // === Human-in-the-Loop (HITL) ===
52
+ rpc ConfirmToolExecution(ConfirmToolExecutionRequest) returns (ConfirmToolExecutionResponse);
53
+ rpc SetConfirmationPolicy(SetConfirmationPolicyRequest) returns (SetConfirmationPolicyResponse);
54
+ rpc GetConfirmationPolicy(GetConfirmationPolicyRequest) returns (GetConfirmationPolicyResponse);
55
+
56
+ // === External Task Handling (Pluggable Handlers) ===
57
+ rpc SetLaneHandler(SetLaneHandlerRequest) returns (SetLaneHandlerResponse);
58
+ rpc GetLaneHandler(GetLaneHandlerRequest) returns (GetLaneHandlerResponse);
59
+ rpc CompleteExternalTask(CompleteExternalTaskRequest) returns (CompleteExternalTaskResponse);
60
+ rpc ListPendingExternalTasks(ListPendingExternalTasksRequest) returns (ListPendingExternalTasksResponse);
61
+
62
+ // === Permission System (Allow/Deny/Ask Rules) ===
63
+ rpc SetPermissionPolicy(SetPermissionPolicyRequest) returns (SetPermissionPolicyResponse);
64
+ rpc GetPermissionPolicy(GetPermissionPolicyRequest) returns (GetPermissionPolicyResponse);
65
+ rpc CheckPermission(CheckPermissionRequest) returns (CheckPermissionResponse);
66
+ rpc AddPermissionRule(AddPermissionRuleRequest) returns (AddPermissionRuleResponse);
67
+
68
+ // === Todo/Task Tracking ===
69
+ rpc GetTodos(GetTodosRequest) returns (GetTodosResponse);
70
+ rpc SetTodos(SetTodosRequest) returns (SetTodosResponse);
71
+
72
+ // === Provider Configuration ===
73
+ rpc ListProviders(ListProvidersRequest) returns (ListProvidersResponse);
74
+ rpc GetProvider(GetProviderRequest) returns (GetProviderResponse);
75
+ rpc AddProvider(AddProviderRequest) returns (AddProviderResponse);
76
+ rpc UpdateProvider(UpdateProviderRequest) returns (UpdateProviderResponse);
77
+ rpc RemoveProvider(RemoveProviderRequest) returns (RemoveProviderResponse);
78
+ rpc SetDefaultModel(SetDefaultModelRequest) returns (SetDefaultModelResponse);
79
+ rpc GetDefaultModel(GetDefaultModelRequest) returns (GetDefaultModelResponse);
80
+
81
+ // === Planning & Goal Tracking (Phase 1) ===
82
+ rpc CreatePlan(CreatePlanRequest) returns (CreatePlanResponse);
83
+ rpc GetPlan(GetPlanRequest) returns (GetPlanResponse);
84
+ rpc ExtractGoal(ExtractGoalRequest) returns (ExtractGoalResponse);
85
+ rpc CheckGoalAchievement(CheckGoalAchievementRequest) returns (CheckGoalAchievementResponse);
86
+
87
+ // === Memory System (Phase 3) ===
88
+ rpc StoreMemory(StoreMemoryRequest) returns (StoreMemoryResponse);
89
+ rpc RetrieveMemory(RetrieveMemoryRequest) returns (RetrieveMemoryResponse);
90
+ rpc SearchMemories(SearchMemoriesRequest) returns (SearchMemoriesResponse);
91
+ rpc GetMemoryStats(GetMemoryStatsRequest) returns (GetMemoryStatsResponse);
92
+ rpc ClearMemories(ClearMemoriesRequest) returns (ClearMemoriesResponse);
93
+
94
+ // === MCP (Model Context Protocol) ===
95
+ rpc RegisterMcpServer(RegisterMcpServerRequest) returns (RegisterMcpServerResponse);
96
+ rpc ConnectMcpServer(ConnectMcpServerRequest) returns (ConnectMcpServerResponse);
97
+ rpc DisconnectMcpServer(DisconnectMcpServerRequest) returns (DisconnectMcpServerResponse);
98
+ rpc ListMcpServers(ListMcpServersRequest) returns (ListMcpServersResponse);
99
+ rpc GetMcpTools(GetMcpToolsRequest) returns (GetMcpToolsResponse);
100
+
101
+ // === LSP (Language Server Protocol) ===
102
+ rpc StartLspServer(StartLspServerRequest) returns (StartLspServerResponse);
103
+ rpc StopLspServer(StopLspServerRequest) returns (StopLspServerResponse);
104
+ rpc ListLspServers(ListLspServersRequest) returns (ListLspServersResponse);
105
+ rpc LspHover(LspHoverRequest) returns (LspHoverResponse);
106
+ rpc LspDefinition(LspDefinitionRequest) returns (LspDefinitionResponse);
107
+ rpc LspReferences(LspReferencesRequest) returns (LspReferencesResponse);
108
+ rpc LspSymbols(LspSymbolsRequest) returns (LspSymbolsResponse);
109
+ rpc LspDiagnostics(LspDiagnosticsRequest) returns (LspDiagnosticsResponse);
110
+
111
+ // === Cron (Scheduled Tasks) ===
112
+ rpc ListCronJobs(ListCronJobsRequest) returns (ListCronJobsResponse);
113
+ rpc CreateCronJob(CreateCronJobRequest) returns (CreateCronJobResponse);
114
+ rpc GetCronJob(GetCronJobRequest) returns (GetCronJobResponse);
115
+ rpc UpdateCronJob(UpdateCronJobRequest) returns (UpdateCronJobResponse);
116
+ rpc PauseCronJob(PauseCronJobRequest) returns (PauseCronJobResponse);
117
+ rpc ResumeCronJob(ResumeCronJobRequest) returns (ResumeCronJobResponse);
118
+ rpc DeleteCronJob(DeleteCronJobRequest) returns (DeleteCronJobResponse);
119
+ rpc GetCronHistory(GetCronHistoryRequest) returns (GetCronHistoryResponse);
120
+ rpc RunCronJob(RunCronJobRequest) returns (RunCronJobResponse);
121
+ rpc ParseCronSchedule(ParseCronScheduleRequest) returns (ParseCronScheduleResponse);
122
+ }
123
+
124
+ // ============================================================================
125
+ // Lifecycle Management Messages
126
+ // ============================================================================
127
+
128
+ message HealthCheckRequest {}
129
+
130
+ message HealthCheckResponse {
131
+ enum Status {
132
+ STATUS_UNKNOWN = 0;
133
+ STATUS_HEALTHY = 1;
134
+ STATUS_DEGRADED = 2;
135
+ STATUS_UNHEALTHY = 3;
136
+ }
137
+
138
+ Status status = 1;
139
+ string message = 2;
140
+ map<string, string> details = 3;
141
+ }
142
+
143
+ message GetCapabilitiesRequest {}
144
+
145
+ message GetCapabilitiesResponse {
146
+ AgentInfo info = 1;
147
+ repeated string features = 2;
148
+ repeated ToolCapability tools = 3;
149
+ repeated ModelCapability models = 4;
150
+ ResourceLimits limits = 5;
151
+ map<string, string> metadata = 6;
152
+ }
153
+
154
+ message AgentInfo {
155
+ string name = 1;
156
+ string version = 2;
157
+ string description = 3;
158
+ string author = 4;
159
+ string license = 5;
160
+ string homepage = 6;
161
+ }
162
+
163
+ message ToolCapability {
164
+ string name = 1;
165
+ string description = 2;
166
+ repeated string parameters = 3;
167
+ bool async = 4;
168
+ }
169
+
170
+ message ModelCapability {
171
+ string provider = 1;
172
+ string model = 2;
173
+ repeated string features = 3;
174
+ }
175
+
176
+ message ResourceLimits {
177
+ uint64 max_context_tokens = 1;
178
+ uint32 max_concurrent_sessions = 2;
179
+ uint32 max_tools_per_request = 3;
180
+ }
181
+
182
+ message InitializeRequest {
183
+ string workspace = 1;
184
+ map<string, string> env = 2;
185
+ }
186
+
187
+ message InitializeResponse {
188
+ bool success = 1;
189
+ string message = 2;
190
+ AgentInfo info = 3;
191
+ }
192
+
193
+ message LLMConfig {
194
+ string provider = 1;
195
+ string model = 2;
196
+ string api_key = 3;
197
+ string base_url = 4;
198
+ float temperature = 5;
199
+ uint32 max_tokens = 6;
200
+ }
201
+
202
+ message ShutdownRequest {}
203
+
204
+ message ShutdownResponse {
205
+ bool success = 1;
206
+ string message = 2;
207
+ }
208
+
209
+ // ============================================================================
210
+ // Session Management Messages
211
+ // ============================================================================
212
+
213
+ message CreateSessionRequest {
214
+ optional string session_id = 1;
215
+ SessionConfig config = 2;
216
+ repeated Message initial_context = 3;
217
+ }
218
+
219
+ message CreateSessionResponse {
220
+ string session_id = 1;
221
+ Session session = 2;
222
+ }
223
+
224
+ message SessionConfig {
225
+ string name = 1;
226
+ string workspace = 2;
227
+ optional LLMConfig llm = 3;
228
+ string system_prompt = 4;
229
+ uint32 max_context_length = 5;
230
+ bool auto_compact = 6;
231
+ StorageType storage_type = 7;
232
+ }
233
+
234
+ enum StorageType {
235
+ STORAGE_TYPE_UNSPECIFIED = 0;
236
+ STORAGE_TYPE_MEMORY = 1;
237
+ STORAGE_TYPE_FILE = 2;
238
+ }
239
+
240
+ message Session {
241
+ string session_id = 1;
242
+ SessionConfig config = 2;
243
+ SessionState state = 3;
244
+ ContextUsage context_usage = 4;
245
+ int64 created_at = 5;
246
+ int64 updated_at = 6;
247
+ }
248
+
249
+ enum SessionState {
250
+ SESSION_STATE_UNKNOWN = 0;
251
+ SESSION_STATE_ACTIVE = 1;
252
+ SESSION_STATE_PAUSED = 2;
253
+ SESSION_STATE_COMPLETED = 3;
254
+ SESSION_STATE_ERROR = 4;
255
+ }
256
+
257
+ message ContextUsage {
258
+ uint32 total_tokens = 1;
259
+ uint32 prompt_tokens = 2;
260
+ uint32 completion_tokens = 3;
261
+ uint32 message_count = 4;
262
+ }
263
+
264
+ message DestroySessionRequest {
265
+ string session_id = 1;
266
+ }
267
+
268
+ message DestroySessionResponse {
269
+ bool success = 1;
270
+ }
271
+
272
+ message ListSessionsRequest {}
273
+
274
+ message ListSessionsResponse {
275
+ repeated Session sessions = 1;
276
+ }
277
+
278
+ message GetSessionRequest {
279
+ string session_id = 1;
280
+ }
281
+
282
+ message GetSessionResponse {
283
+ Session session = 1;
284
+ }
285
+
286
+ message ConfigureSessionRequest {
287
+ string session_id = 1;
288
+ SessionConfig config = 2;
289
+ }
290
+
291
+ message ConfigureSessionResponse {
292
+ Session session = 1;
293
+ }
294
+
295
+ // Get messages (conversation history) for a session
296
+ message GetMessagesRequest {
297
+ string session_id = 1;
298
+ optional uint32 limit = 2; // Max number of messages to return (default: all)
299
+ optional uint32 offset = 3; // Skip first N messages (for pagination)
300
+ }
301
+
302
+ message GetMessagesResponse {
303
+ repeated ConversationMessage messages = 1;
304
+ uint32 total_count = 2; // Total number of messages in session
305
+ bool has_more = 3; // Whether there are more messages after this batch
306
+ }
307
+
308
+ // Rich message format for conversation history
309
+ message ConversationMessage {
310
+ string id = 1; // Unique message ID
311
+ string role = 2; // "user", "assistant", "system"
312
+ repeated ContentBlock content = 3;
313
+ int64 timestamp = 4; // Unix timestamp (milliseconds)
314
+ map<string, string> metadata = 5;
315
+ }
316
+
317
+ // Content block within a message
318
+ message ContentBlock {
319
+ oneof block {
320
+ TextContent text = 1;
321
+ ToolUseContent tool_use = 2;
322
+ ToolResultContent tool_result = 3;
323
+ }
324
+ }
325
+
326
+ message TextContent {
327
+ string text = 1;
328
+ }
329
+
330
+ message ToolUseContent {
331
+ string id = 1;
332
+ string name = 2;
333
+ string arguments = 3; // JSON string
334
+ }
335
+
336
+ message ToolResultContent {
337
+ string tool_use_id = 1;
338
+ string content = 2;
339
+ bool is_error = 3;
340
+ }
341
+
342
+ // ============================================================================
343
+ // Code Generation Messages
344
+ // ============================================================================
345
+
346
+ message GenerateRequest {
347
+ string session_id = 1;
348
+ repeated Message messages = 2;
349
+ }
350
+
351
+ // OpenAI-compatible message format
352
+ message Message {
353
+ string role = 1; // "user", "assistant", "system", "tool"
354
+ string content = 2;
355
+ map<string, string> metadata = 3;
356
+ }
357
+
358
+ message GenerateResponse {
359
+ string session_id = 1;
360
+ Message message = 2;
361
+ repeated ToolCall tool_calls = 3;
362
+ Usage usage = 4;
363
+ string finish_reason = 5; // OpenAI-compatible: "stop", "length", "tool_calls", "content_filter", "error"
364
+ map<string, string> metadata = 6;
365
+ }
366
+
367
+ message ToolCall {
368
+ string id = 1;
369
+ string name = 2;
370
+ string arguments = 3;
371
+ optional ToolResult result = 4;
372
+ }
373
+
374
+ message ToolResult {
375
+ bool success = 1;
376
+ string output = 2;
377
+ string error = 3;
378
+ map<string, string> metadata = 4;
379
+ }
380
+
381
+ message Usage {
382
+ uint32 prompt_tokens = 1;
383
+ uint32 completion_tokens = 2;
384
+ uint32 total_tokens = 3;
385
+ }
386
+
387
+ // OpenAI-compatible finish reason (string values)
388
+ // Values: "stop", "length", "tool_calls", "content_filter", "error"
389
+ // Note: Using string instead of enum for OpenAI compatibility
390
+
391
+ message GenerateChunk {
392
+ // OpenAI-compatible chunk type (string values)
393
+ // Values: "content", "tool_call", "tool_result", "metadata", "done"
394
+ string type = 1;
395
+ string session_id = 2;
396
+ string content = 3;
397
+ optional ToolCall tool_call = 4;
398
+ optional ToolResult tool_result = 5;
399
+ map<string, string> metadata = 6;
400
+ string finish_reason = 7; // OpenAI-compatible: "stop", "length", "tool_calls", etc.
401
+ }
402
+
403
+ message GenerateStructuredRequest {
404
+ string session_id = 1;
405
+ repeated Message messages = 2;
406
+ string schema = 3; // JSON Schema
407
+ }
408
+
409
+ message GenerateStructuredResponse {
410
+ string session_id = 1;
411
+ string data = 2; // JSON format
412
+ Usage usage = 3;
413
+ map<string, string> metadata = 4;
414
+ }
415
+
416
+ message GenerateStructuredChunk {
417
+ string session_id = 1;
418
+ string data = 2;
419
+ bool done = 3;
420
+ }
421
+
422
+ // ============================================================================
423
+ // Skill Management Messages
424
+ // ============================================================================
425
+
426
+ message LoadSkillRequest {
427
+ string session_id = 1;
428
+ string skill_name = 2;
429
+ optional string skill_content = 3;
430
+ }
431
+
432
+ message LoadSkillResponse {
433
+ bool success = 1;
434
+ repeated string tool_names = 2;
435
+ }
436
+
437
+ message UnloadSkillRequest {
438
+ string session_id = 1;
439
+ string skill_name = 2;
440
+ }
441
+
442
+ message UnloadSkillResponse {
443
+ bool success = 1;
444
+ repeated string removed_tools = 2;
445
+ }
446
+
447
+ message ListSkillsRequest {
448
+ optional string session_id = 1;
449
+ }
450
+
451
+ message ListSkillsResponse {
452
+ repeated Skill skills = 1;
453
+ }
454
+
455
+ message Skill {
456
+ string name = 1;
457
+ string description = 2;
458
+ repeated string tools = 3;
459
+ map<string, string> metadata = 4;
460
+ }
461
+
462
+ // Claude Code skill format (compatible with Claude Code skills)
463
+ message ClaudeCodeSkill {
464
+ string name = 1;
465
+ string description = 2;
466
+ optional string allowed_tools = 3; // Tool permissions (e.g., "Bash(gh:*)")
467
+ bool disable_model_invocation = 4;
468
+ string content = 5; // Markdown instructions
469
+ }
470
+
471
+ // Tool permission pattern
472
+ message ToolPermission {
473
+ string tool = 1; // Tool name (e.g., "Bash")
474
+ string pattern = 2; // Pattern to match (e.g., "gh:*")
475
+ }
476
+
477
+ message GetClaudeCodeSkillsRequest {
478
+ optional string name = 1; // If set, get specific skill by name
479
+ }
480
+
481
+ message GetClaudeCodeSkillsResponse {
482
+ repeated ClaudeCodeSkill skills = 1;
483
+ }
484
+
485
+ // ============================================================================
486
+ // Context Management Messages
487
+ // ============================================================================
488
+
489
+ message GetContextUsageRequest {
490
+ string session_id = 1;
491
+ }
492
+
493
+ message GetContextUsageResponse {
494
+ ContextUsage usage = 1;
495
+ }
496
+
497
+ message CompactContextRequest {
498
+ string session_id = 1;
499
+ }
500
+
501
+ message CompactContextResponse {
502
+ bool success = 1;
503
+ ContextUsage before = 2;
504
+ ContextUsage after = 3;
505
+ }
506
+
507
+ message ClearContextRequest {
508
+ string session_id = 1;
509
+ }
510
+
511
+ message ClearContextResponse {
512
+ bool success = 1;
513
+ }
514
+
515
+ // ============================================================================
516
+ // Event Streaming Messages
517
+ // ============================================================================
518
+
519
+ message SubscribeEventsRequest {
520
+ optional string session_id = 1;
521
+ repeated string event_types = 2;
522
+ }
523
+
524
+ message AgentEvent {
525
+ enum EventType {
526
+ EVENT_TYPE_UNKNOWN = 0;
527
+ EVENT_TYPE_SESSION_CREATED = 1;
528
+ EVENT_TYPE_SESSION_DESTROYED = 2;
529
+ EVENT_TYPE_GENERATION_STARTED = 3;
530
+ EVENT_TYPE_GENERATION_COMPLETED = 4;
531
+ EVENT_TYPE_TOOL_CALLED = 5;
532
+ EVENT_TYPE_TOOL_COMPLETED = 6;
533
+ EVENT_TYPE_ERROR = 7;
534
+ EVENT_TYPE_WARNING = 8;
535
+ EVENT_TYPE_INFO = 9;
536
+ // HITL events
537
+ EVENT_TYPE_CONFIRMATION_REQUIRED = 10;
538
+ EVENT_TYPE_CONFIRMATION_RECEIVED = 11;
539
+ EVENT_TYPE_CONFIRMATION_TIMEOUT = 12;
540
+ // External task events
541
+ EVENT_TYPE_EXTERNAL_TASK_PENDING = 13;
542
+ EVENT_TYPE_EXTERNAL_TASK_COMPLETED = 14;
543
+ // Permission events
544
+ EVENT_TYPE_PERMISSION_DENIED = 15;
545
+ // Memory System events (Phase 3)
546
+ EVENT_TYPE_MEMORY_STORED = 16;
547
+ EVENT_TYPE_MEMORY_RECALLED = 17;
548
+ EVENT_TYPE_MEMORIES_SEARCHED = 18;
549
+ EVENT_TYPE_MEMORY_CLEARED = 19;
550
+ }
551
+
552
+ EventType type = 1;
553
+ optional string session_id = 2;
554
+ int64 timestamp = 3;
555
+ string message = 4;
556
+ map<string, string> data = 5;
557
+ }
558
+
559
+ // ============================================================================
560
+ // Control Operations Messages
561
+ // ============================================================================
562
+
563
+ message CancelRequest {
564
+ string session_id = 1;
565
+ optional string operation_id = 2;
566
+ }
567
+
568
+ message CancelResponse {
569
+ bool success = 1;
570
+ }
571
+
572
+ message PauseRequest {
573
+ string session_id = 1;
574
+ }
575
+
576
+ message PauseResponse {
577
+ bool success = 1;
578
+ }
579
+
580
+ message ResumeRequest {
581
+ string session_id = 1;
582
+ }
583
+
584
+ message ResumeResponse {
585
+ bool success = 1;
586
+ }
587
+
588
+ // ============================================================================
589
+ // Human-in-the-Loop (HITL) Messages
590
+ // ============================================================================
591
+
592
+ // Confirm tool execution request
593
+ message ConfirmToolExecutionRequest {
594
+ string session_id = 1;
595
+ string tool_id = 2;
596
+ bool approved = 3;
597
+ optional string reason = 4;
598
+ }
599
+
600
+ message ConfirmToolExecutionResponse {
601
+ bool success = 1;
602
+ string error = 2;
603
+ }
604
+
605
+ // Session queue lane type
606
+ enum SessionLane {
607
+ SESSION_LANE_UNKNOWN = 0;
608
+ SESSION_LANE_CONTROL = 1; // P0 - pause, resume, cancel
609
+ SESSION_LANE_QUERY = 2; // P1 - read, glob, ls, grep
610
+ SESSION_LANE_EXECUTE = 3; // P2 - bash, write, edit
611
+ SESSION_LANE_GENERATE = 4; // P3 - LLM calls
612
+ }
613
+
614
+ // Timeout behavior
615
+ enum TimeoutAction {
616
+ TIMEOUT_ACTION_UNKNOWN = 0;
617
+ TIMEOUT_ACTION_REJECT = 1; // Reject on timeout
618
+ TIMEOUT_ACTION_AUTO_APPROVE = 2; // Auto-approve on timeout
619
+ }
620
+
621
+ // Confirmation policy configuration
622
+ message ConfirmationPolicy {
623
+ bool enabled = 1; // Whether HITL is enabled (default: false)
624
+ repeated string auto_approve_tools = 2; // Tools to auto-approve
625
+ repeated string require_confirm_tools = 3; // Tools requiring confirmation
626
+ uint64 default_timeout_ms = 4; // Default timeout (30s)
627
+ TimeoutAction timeout_action = 5; // Timeout behavior
628
+ repeated SessionLane yolo_lanes = 6; // YOLO mode: tasks in these lanes auto-approve
629
+ }
630
+
631
+ // Set confirmation policy request
632
+ message SetConfirmationPolicyRequest {
633
+ string session_id = 1;
634
+ ConfirmationPolicy policy = 2;
635
+ }
636
+
637
+ message SetConfirmationPolicyResponse {
638
+ bool success = 1;
639
+ ConfirmationPolicy policy = 2;
640
+ }
641
+
642
+ // Get confirmation policy request
643
+ message GetConfirmationPolicyRequest {
644
+ string session_id = 1;
645
+ }
646
+
647
+ message GetConfirmationPolicyResponse {
648
+ ConfirmationPolicy policy = 1;
649
+ }
650
+
651
+ // ============================================================================
652
+ // External Task Handling (Pluggable Handlers) Messages
653
+ // ============================================================================
654
+
655
+ // Task handler mode
656
+ enum TaskHandlerMode {
657
+ TASK_HANDLER_MODE_UNKNOWN = 0;
658
+ TASK_HANDLER_MODE_INTERNAL = 1; // Internal handling (default)
659
+ TASK_HANDLER_MODE_EXTERNAL = 2; // External handling (send to SDK, wait for callback)
660
+ TASK_HANDLER_MODE_HYBRID = 3; // Hybrid mode (internal handling with external notification)
661
+ }
662
+
663
+ // Lane handler configuration
664
+ message LaneHandlerConfig {
665
+ TaskHandlerMode mode = 1;
666
+ uint64 timeout_ms = 2; // External handling timeout (milliseconds)
667
+ }
668
+
669
+ // Set lane handler request
670
+ message SetLaneHandlerRequest {
671
+ string session_id = 1;
672
+ SessionLane lane = 2;
673
+ LaneHandlerConfig config = 3;
674
+ }
675
+
676
+ message SetLaneHandlerResponse {
677
+ bool success = 1;
678
+ LaneHandlerConfig config = 2;
679
+ }
680
+
681
+ // Get lane handler request
682
+ message GetLaneHandlerRequest {
683
+ string session_id = 1;
684
+ SessionLane lane = 2;
685
+ }
686
+
687
+ message GetLaneHandlerResponse {
688
+ LaneHandlerConfig config = 1;
689
+ }
690
+
691
+ // External task
692
+ message ExternalTask {
693
+ string task_id = 1;
694
+ string session_id = 2;
695
+ SessionLane lane = 3;
696
+ string command_type = 4;
697
+ string payload = 5; // Task data in JSON format
698
+ uint64 timeout_ms = 6;
699
+ uint64 remaining_ms = 7; // Remaining timeout
700
+ }
701
+
702
+ // Complete external task request
703
+ message CompleteExternalTaskRequest {
704
+ string session_id = 1;
705
+ string task_id = 2;
706
+ bool success = 3;
707
+ string result = 4; // Result in JSON format
708
+ string error = 5; // Error message (if failed)
709
+ }
710
+
711
+ message CompleteExternalTaskResponse {
712
+ bool success = 1;
713
+ string error = 2;
714
+ }
715
+
716
+ // List pending external tasks request
717
+ message ListPendingExternalTasksRequest {
718
+ string session_id = 1;
719
+ }
720
+
721
+ message ListPendingExternalTasksResponse {
722
+ repeated ExternalTask tasks = 1;
723
+ }
724
+
725
+ // ============================================================================
726
+ // Permission System (Allow/Deny/Ask Rules) Messages
727
+ // ============================================================================
728
+
729
+ // Permission decision
730
+ enum PermissionDecision {
731
+ PERMISSION_DECISION_UNKNOWN = 0;
732
+ PERMISSION_DECISION_ALLOW = 1; // Auto-allow
733
+ PERMISSION_DECISION_DENY = 2; // Deny
734
+ PERMISSION_DECISION_ASK = 3; // Requires confirmation
735
+ }
736
+
737
+ // Permission rule
738
+ message PermissionRule {
739
+ string rule = 1; // e.g., "Bash(cargo:*)", "Read(src/**/*.rs)"
740
+ }
741
+
742
+ // Permission policy
743
+ message PermissionPolicy {
744
+ repeated PermissionRule deny = 1; // Deny rules (highest priority)
745
+ repeated PermissionRule allow = 2; // Allow rules
746
+ repeated PermissionRule ask = 3; // Ask rules
747
+ PermissionDecision default_decision = 4; // Default decision
748
+ bool enabled = 5; // Whether permission system is enabled
749
+ }
750
+
751
+ // Set permission policy request
752
+ message SetPermissionPolicyRequest {
753
+ string session_id = 1;
754
+ PermissionPolicy policy = 2;
755
+ }
756
+
757
+ message SetPermissionPolicyResponse {
758
+ bool success = 1;
759
+ PermissionPolicy policy = 2;
760
+ }
761
+
762
+ // Get permission policy request
763
+ message GetPermissionPolicyRequest {
764
+ string session_id = 1;
765
+ }
766
+
767
+ message GetPermissionPolicyResponse {
768
+ PermissionPolicy policy = 1;
769
+ }
770
+
771
+ // Check permission request
772
+ message CheckPermissionRequest {
773
+ string session_id = 1;
774
+ string tool_name = 2;
775
+ string arguments = 3; // JSON format
776
+ }
777
+
778
+ message CheckPermissionResponse {
779
+ PermissionDecision decision = 1;
780
+ repeated string matching_rules = 2; // Matching rules (for debugging)
781
+ }
782
+
783
+ // Add permission rule request
784
+ message AddPermissionRuleRequest {
785
+ string session_id = 1;
786
+ string rule_type = 2; // "allow", "deny", or "ask"
787
+ string rule = 3; // e.g., "Bash(cargo:*)"
788
+ }
789
+
790
+ message AddPermissionRuleResponse {
791
+ bool success = 1;
792
+ string error = 2;
793
+ }
794
+
795
+ // ============================================================================
796
+ // Todo/Task Tracking Messages
797
+ // ============================================================================
798
+
799
+ // Todo item for task tracking
800
+ message Todo {
801
+ string id = 1;
802
+ string content = 2;
803
+ string status = 3; // pending, in_progress, completed, cancelled
804
+ string priority = 4; // high, medium, low
805
+ }
806
+
807
+ // Get todos request
808
+ message GetTodosRequest {
809
+ string session_id = 1;
810
+ }
811
+
812
+ message GetTodosResponse {
813
+ repeated Todo todos = 1;
814
+ }
815
+
816
+ // Set todos request (replaces entire list)
817
+ message SetTodosRequest {
818
+ string session_id = 1;
819
+ repeated Todo todos = 2;
820
+ }
821
+
822
+ message SetTodosResponse {
823
+ bool success = 1;
824
+ repeated Todo todos = 2;
825
+ }
826
+
827
+ // ============================================================================
828
+ // Provider Configuration Messages
829
+ // ============================================================================
830
+
831
+ // Model cost information (per million tokens)
832
+ message ModelCostInfo {
833
+ double input = 1; // Input token cost
834
+ double output = 2; // Output token cost
835
+ double cache_read = 3; // Cache read cost
836
+ double cache_write = 4; // Cache write cost
837
+ }
838
+
839
+ // Model token limits
840
+ message ModelLimitInfo {
841
+ uint32 context = 1; // Maximum context tokens
842
+ uint32 output = 2; // Maximum output tokens
843
+ }
844
+
845
+ // Model modalities (input/output types)
846
+ message ModelModalitiesInfo {
847
+ repeated string input = 1; // Supported input types (text, image, pdf)
848
+ repeated string output = 2; // Supported output types (text)
849
+ }
850
+
851
+ // Model configuration
852
+ message ModelInfo {
853
+ string id = 1; // Model ID (e.g., "claude-sonnet-4-20250514")
854
+ string name = 2; // Display name
855
+ string family = 3; // Model family (e.g., "claude-sonnet")
856
+ optional string api_key = 4; // Per-model API key override
857
+ optional string base_url = 5; // Per-model base URL override
858
+ bool attachment = 6; // Supports file attachments
859
+ bool reasoning = 7; // Supports reasoning/thinking
860
+ bool tool_call = 8; // Supports tool calling
861
+ bool temperature = 9; // Supports temperature setting
862
+ optional string release_date = 10; // Release date
863
+ ModelModalitiesInfo modalities = 11;
864
+ ModelCostInfo cost = 12;
865
+ ModelLimitInfo limit = 13;
866
+ }
867
+
868
+ // Provider configuration
869
+ message ProviderInfo {
870
+ string name = 1; // Provider name (e.g., "anthropic", "openai")
871
+ optional string api_key = 2; // API key for this provider
872
+ optional string base_url = 3; // Base URL for the API
873
+ repeated ModelInfo models = 4; // Available models
874
+ }
875
+
876
+ // List all providers
877
+ message ListProvidersRequest {}
878
+
879
+ message ListProvidersResponse {
880
+ repeated ProviderInfo providers = 1;
881
+ optional string default_provider = 2;
882
+ optional string default_model = 3;
883
+ }
884
+
885
+ // Get a specific provider
886
+ message GetProviderRequest {
887
+ string name = 1;
888
+ }
889
+
890
+ message GetProviderResponse {
891
+ ProviderInfo provider = 1;
892
+ }
893
+
894
+ // Add a new provider
895
+ message AddProviderRequest {
896
+ ProviderInfo provider = 1;
897
+ }
898
+
899
+ message AddProviderResponse {
900
+ bool success = 1;
901
+ string error = 2;
902
+ ProviderInfo provider = 3;
903
+ }
904
+
905
+ // Update an existing provider
906
+ message UpdateProviderRequest {
907
+ ProviderInfo provider = 1; // Provider name identifies which to update
908
+ }
909
+
910
+ message UpdateProviderResponse {
911
+ bool success = 1;
912
+ string error = 2;
913
+ ProviderInfo provider = 3;
914
+ }
915
+
916
+ // Remove a provider
917
+ message RemoveProviderRequest {
918
+ string name = 1;
919
+ }
920
+
921
+ message RemoveProviderResponse {
922
+ bool success = 1;
923
+ string error = 2;
924
+ }
925
+
926
+ // Set default provider and model
927
+ message SetDefaultModelRequest {
928
+ string provider = 1; // Provider name
929
+ string model = 2; // Model ID
930
+ }
931
+
932
+ message SetDefaultModelResponse {
933
+ bool success = 1;
934
+ string error = 2;
935
+ string provider = 3;
936
+ string model = 4;
937
+ }
938
+
939
+ // Get current default provider and model
940
+ message GetDefaultModelRequest {}
941
+
942
+ message GetDefaultModelResponse {
943
+ optional string provider = 1;
944
+ optional string model = 2;
945
+ }
946
+
947
+ // ============================================================================
948
+ // Planning & Goal Tracking Messages (Phase 1)
949
+ // ============================================================================
950
+
951
+ // Task complexity level
952
+ enum Complexity {
953
+ COMPLEXITY_UNKNOWN = 0;
954
+ COMPLEXITY_SIMPLE = 1;
955
+ COMPLEXITY_MEDIUM = 2;
956
+ COMPLEXITY_COMPLEX = 3;
957
+ COMPLEXITY_VERY_COMPLEX = 4;
958
+ }
959
+
960
+ // Step status in execution plan
961
+ enum StepStatus {
962
+ STEP_STATUS_UNKNOWN = 0;
963
+ STEP_STATUS_PENDING = 1;
964
+ STEP_STATUS_IN_PROGRESS = 2;
965
+ STEP_STATUS_COMPLETED = 3;
966
+ STEP_STATUS_FAILED = 4;
967
+ STEP_STATUS_SKIPPED = 5;
968
+ }
969
+
970
+ // Individual execution step
971
+ message PlanStep {
972
+ string id = 1;
973
+ string description = 2;
974
+ optional string tool = 3;
975
+ repeated string dependencies = 4;
976
+ StepStatus status = 5;
977
+ repeated string success_criteria = 6;
978
+ }
979
+
980
+ // Complete execution plan
981
+ message ExecutionPlan {
982
+ string goal = 1;
983
+ repeated PlanStep steps = 2;
984
+ Complexity complexity = 3;
985
+ repeated string required_tools = 4;
986
+ uint32 estimated_steps = 5;
987
+ }
988
+
989
+ // Agent goal with success criteria
990
+ message AgentGoal {
991
+ string description = 1;
992
+ repeated string success_criteria = 2;
993
+ float progress = 3;
994
+ bool achieved = 4;
995
+ int64 created_at = 5;
996
+ optional int64 achieved_at = 6;
997
+ }
998
+
999
+ // Create an execution plan
1000
+ message CreatePlanRequest {
1001
+ string session_id = 1;
1002
+ string prompt = 2;
1003
+ optional string context = 3;
1004
+ }
1005
+
1006
+ message CreatePlanResponse {
1007
+ ExecutionPlan plan = 1;
1008
+ }
1009
+
1010
+ // Get an existing plan
1011
+ message GetPlanRequest {
1012
+ string session_id = 1;
1013
+ string plan_id = 2;
1014
+ }
1015
+
1016
+ message GetPlanResponse {
1017
+ ExecutionPlan plan = 1;
1018
+ }
1019
+
1020
+ // Extract goal from prompt
1021
+ message ExtractGoalRequest {
1022
+ string session_id = 1;
1023
+ string prompt = 2;
1024
+ }
1025
+
1026
+ message ExtractGoalResponse {
1027
+ AgentGoal goal = 1;
1028
+ }
1029
+
1030
+ // Check if goal is achieved
1031
+ message CheckGoalAchievementRequest {
1032
+ string session_id = 1;
1033
+ AgentGoal goal = 2;
1034
+ string current_state = 3;
1035
+ }
1036
+
1037
+ message CheckGoalAchievementResponse {
1038
+ bool achieved = 1;
1039
+ float progress = 2;
1040
+ repeated string remaining_criteria = 3;
1041
+ }
1042
+
1043
+ // ============================================================================
1044
+ // Memory System Messages (Phase 3)
1045
+ // ============================================================================
1046
+
1047
+ // Memory type classification
1048
+ enum MemoryType {
1049
+ MEMORY_TYPE_UNKNOWN = 0;
1050
+ MEMORY_TYPE_EPISODIC = 1;
1051
+ MEMORY_TYPE_SEMANTIC = 2;
1052
+ MEMORY_TYPE_PROCEDURAL = 3;
1053
+ MEMORY_TYPE_WORKING = 4;
1054
+ }
1055
+
1056
+ // Single memory item
1057
+ message MemoryItem {
1058
+ string id = 1;
1059
+ string content = 2;
1060
+ int64 timestamp = 3;
1061
+ float importance = 4;
1062
+ repeated string tags = 5;
1063
+ MemoryType memory_type = 6;
1064
+ map<string, string> metadata = 7;
1065
+ uint32 access_count = 8;
1066
+ optional int64 last_accessed = 9;
1067
+ }
1068
+
1069
+ // Memory statistics
1070
+ message MemoryStats {
1071
+ uint64 long_term_count = 1;
1072
+ uint64 short_term_count = 2;
1073
+ uint64 working_count = 3;
1074
+ }
1075
+
1076
+ // Store a memory
1077
+ message StoreMemoryRequest {
1078
+ string session_id = 1;
1079
+ MemoryItem memory = 2;
1080
+ }
1081
+
1082
+ message StoreMemoryResponse {
1083
+ bool success = 1;
1084
+ string memory_id = 2;
1085
+ }
1086
+
1087
+ // Retrieve a memory by ID
1088
+ message RetrieveMemoryRequest {
1089
+ string session_id = 1;
1090
+ string memory_id = 2;
1091
+ }
1092
+
1093
+ message RetrieveMemoryResponse {
1094
+ optional MemoryItem memory = 1;
1095
+ }
1096
+
1097
+ // Search memories
1098
+ message SearchMemoriesRequest {
1099
+ string session_id = 1;
1100
+ optional string query = 2;
1101
+ repeated string tags = 3;
1102
+ uint32 limit = 4;
1103
+ bool recent_only = 5;
1104
+ optional float min_importance = 6;
1105
+ }
1106
+
1107
+ message SearchMemoriesResponse {
1108
+ repeated MemoryItem memories = 1;
1109
+ uint32 total_count = 2;
1110
+ }
1111
+
1112
+ // Get memory statistics
1113
+ message GetMemoryStatsRequest {
1114
+ string session_id = 1;
1115
+ }
1116
+
1117
+ message GetMemoryStatsResponse {
1118
+ MemoryStats stats = 1;
1119
+ }
1120
+
1121
+ // Clear memories
1122
+ message ClearMemoriesRequest {
1123
+ string session_id = 1;
1124
+ bool clear_long_term = 2;
1125
+ bool clear_short_term = 3;
1126
+ bool clear_working = 4;
1127
+ }
1128
+
1129
+ message ClearMemoriesResponse {
1130
+ bool success = 1;
1131
+ uint64 cleared_count = 2;
1132
+ }
1133
+
1134
+ // ============================================================================
1135
+ // MCP (Model Context Protocol) Messages
1136
+ // ============================================================================
1137
+
1138
+ // MCP transport configuration
1139
+ message McpTransport {
1140
+ oneof transport {
1141
+ McpStdioTransport stdio = 1;
1142
+ McpHttpTransport http = 2;
1143
+ }
1144
+ }
1145
+
1146
+ message McpStdioTransport {
1147
+ string command = 1;
1148
+ repeated string args = 2;
1149
+ }
1150
+
1151
+ message McpHttpTransport {
1152
+ string url = 1;
1153
+ map<string, string> headers = 2;
1154
+ }
1155
+
1156
+ // MCP server configuration
1157
+ message McpServerConfigProto {
1158
+ string name = 1;
1159
+ McpTransport transport = 2;
1160
+ bool enabled = 3;
1161
+ map<string, string> env = 4;
1162
+ }
1163
+
1164
+ // Register MCP server
1165
+ message RegisterMcpServerRequest {
1166
+ McpServerConfigProto config = 1;
1167
+ }
1168
+
1169
+ message RegisterMcpServerResponse {
1170
+ bool success = 1;
1171
+ string message = 2;
1172
+ }
1173
+
1174
+ // Connect to MCP server
1175
+ message ConnectMcpServerRequest {
1176
+ string name = 1;
1177
+ }
1178
+
1179
+ message ConnectMcpServerResponse {
1180
+ bool success = 1;
1181
+ string message = 2;
1182
+ repeated string tool_names = 3;
1183
+ }
1184
+
1185
+ // Disconnect from MCP server
1186
+ message DisconnectMcpServerRequest {
1187
+ string name = 1;
1188
+ }
1189
+
1190
+ message DisconnectMcpServerResponse {
1191
+ bool success = 1;
1192
+ }
1193
+
1194
+ // List MCP servers
1195
+ message ListMcpServersRequest {}
1196
+
1197
+ message ListMcpServersResponse {
1198
+ repeated McpServerInfo servers = 1;
1199
+ }
1200
+
1201
+ message McpServerInfo {
1202
+ string name = 1;
1203
+ bool connected = 2;
1204
+ bool enabled = 3;
1205
+ uint32 tool_count = 4;
1206
+ optional string error = 5;
1207
+ }
1208
+
1209
+ // Get MCP tools
1210
+ message GetMcpToolsRequest {
1211
+ optional string server_name = 1; // If set, only return tools from this server
1212
+ }
1213
+
1214
+ message GetMcpToolsResponse {
1215
+ repeated McpToolInfo tools = 1;
1216
+ }
1217
+
1218
+ message McpToolInfo {
1219
+ string full_name = 1; // mcp__server__tool
1220
+ string server_name = 2;
1221
+ string tool_name = 3;
1222
+ string description = 4;
1223
+ string input_schema = 5; // JSON Schema as string
1224
+ }
1225
+
1226
+ // ============================================================================
1227
+ // LSP (Language Server Protocol) Messages
1228
+ // ============================================================================
1229
+
1230
+ // Start LSP server for a language
1231
+ message StartLspServerRequest {
1232
+ string language = 1; // Language name (e.g., "rust", "python", "typescript")
1233
+ string root_uri = 2; // Workspace root URI (e.g., "file:///path/to/project")
1234
+ }
1235
+
1236
+ message StartLspServerResponse {
1237
+ bool success = 1;
1238
+ string message = 2;
1239
+ optional LspServerInfo server_info = 3;
1240
+ }
1241
+
1242
+ // Stop LSP server
1243
+ message StopLspServerRequest {
1244
+ string language = 1;
1245
+ }
1246
+
1247
+ message StopLspServerResponse {
1248
+ bool success = 1;
1249
+ }
1250
+
1251
+ // List LSP servers
1252
+ message ListLspServersRequest {}
1253
+
1254
+ message ListLspServersResponse {
1255
+ repeated LspServerInfo servers = 1;
1256
+ }
1257
+
1258
+ message LspServerInfo {
1259
+ string language = 1;
1260
+ string name = 2; // Server name (e.g., "rust-analyzer")
1261
+ optional string version = 3;
1262
+ bool running = 4;
1263
+ }
1264
+
1265
+ // LSP Hover
1266
+ message LspHoverRequest {
1267
+ string file_path = 1;
1268
+ uint32 line = 2; // 0-indexed
1269
+ uint32 column = 3; // 0-indexed
1270
+ }
1271
+
1272
+ message LspHoverResponse {
1273
+ bool found = 1;
1274
+ string content = 2; // Hover content (markdown)
1275
+ optional LspRange range = 3;
1276
+ }
1277
+
1278
+ // LSP Definition
1279
+ message LspDefinitionRequest {
1280
+ string file_path = 1;
1281
+ uint32 line = 2;
1282
+ uint32 column = 3;
1283
+ }
1284
+
1285
+ message LspDefinitionResponse {
1286
+ repeated LspLocation locations = 1;
1287
+ }
1288
+
1289
+ // LSP References
1290
+ message LspReferencesRequest {
1291
+ string file_path = 1;
1292
+ uint32 line = 2;
1293
+ uint32 column = 3;
1294
+ bool include_declaration = 4;
1295
+ }
1296
+
1297
+ message LspReferencesResponse {
1298
+ repeated LspLocation locations = 1;
1299
+ }
1300
+
1301
+ // LSP Symbols
1302
+ message LspSymbolsRequest {
1303
+ string query = 1; // Search query
1304
+ uint32 limit = 2; // Max results (default: 20)
1305
+ }
1306
+
1307
+ message LspSymbolsResponse {
1308
+ repeated LspSymbol symbols = 1;
1309
+ }
1310
+
1311
+ // LSP Diagnostics
1312
+ message LspDiagnosticsRequest {
1313
+ optional string file_path = 1; // If not set, returns all diagnostics
1314
+ }
1315
+
1316
+ message LspDiagnosticsResponse {
1317
+ repeated LspDiagnostic diagnostics = 1;
1318
+ }
1319
+
1320
+ // LSP Common Types
1321
+ message LspPosition {
1322
+ uint32 line = 1;
1323
+ uint32 character = 2;
1324
+ }
1325
+
1326
+ message LspRange {
1327
+ LspPosition start = 1;
1328
+ LspPosition end = 2;
1329
+ }
1330
+
1331
+ message LspLocation {
1332
+ string uri = 1;
1333
+ LspRange range = 2;
1334
+ }
1335
+
1336
+ message LspSymbol {
1337
+ string name = 1;
1338
+ string kind = 2; // "function", "class", "variable", etc.
1339
+ LspLocation location = 3;
1340
+ optional string container_name = 4;
1341
+ }
1342
+
1343
+ message LspDiagnostic {
1344
+ string uri = 1;
1345
+ LspRange range = 2;
1346
+ string severity = 3; // "error", "warning", "info", "hint"
1347
+ string message = 4;
1348
+ optional string code = 5;
1349
+ optional string source = 6;
1350
+ }
1351
+
1352
+ // ============================================================================
1353
+ // Cron (Scheduled Tasks) Messages
1354
+ // ============================================================================
1355
+
1356
+ // Cron job status
1357
+ enum CronJobStatus {
1358
+ CRON_JOB_STATUS_UNKNOWN = 0;
1359
+ CRON_JOB_STATUS_ACTIVE = 1;
1360
+ CRON_JOB_STATUS_PAUSED = 2;
1361
+ CRON_JOB_STATUS_RUNNING = 3;
1362
+ }
1363
+
1364
+ // Cron execution status
1365
+ enum CronExecutionStatus {
1366
+ CRON_EXECUTION_STATUS_UNKNOWN = 0;
1367
+ CRON_EXECUTION_STATUS_SUCCESS = 1;
1368
+ CRON_EXECUTION_STATUS_FAILED = 2;
1369
+ CRON_EXECUTION_STATUS_TIMEOUT = 3;
1370
+ CRON_EXECUTION_STATUS_CANCELLED = 4;
1371
+ }
1372
+
1373
+ // Cron job definition
1374
+ message CronJob {
1375
+ string id = 1; // Unique job identifier
1376
+ string name = 2; // Human-readable job name
1377
+ string schedule = 3; // Cron expression (5 fields: min hour day month weekday)
1378
+ string command = 4; // Command to execute
1379
+ CronJobStatus status = 5; // Current job status
1380
+ uint64 timeout_ms = 6; // Execution timeout in milliseconds
1381
+ int64 created_at = 7; // Creation timestamp (Unix ms)
1382
+ int64 updated_at = 8; // Last update timestamp (Unix ms)
1383
+ optional int64 last_run = 9; // Last execution timestamp (Unix ms)
1384
+ optional int64 next_run = 10; // Next scheduled run timestamp (Unix ms)
1385
+ uint64 run_count = 11; // Total successful run count
1386
+ uint64 fail_count = 12; // Total failed run count
1387
+ optional string working_dir = 13; // Working directory for command execution
1388
+ }
1389
+
1390
+ // Cron job execution record
1391
+ message CronExecution {
1392
+ string id = 1; // Execution ID
1393
+ string job_id = 2; // Job ID
1394
+ CronExecutionStatus status = 3; // Execution status
1395
+ int64 started_at = 4; // Start timestamp (Unix ms)
1396
+ optional int64 ended_at = 5; // End timestamp (Unix ms)
1397
+ optional uint64 duration_ms = 6; // Duration in milliseconds
1398
+ optional int32 exit_code = 7; // Exit code (if available)
1399
+ string stdout = 8; // Standard output (truncated if too long)
1400
+ string stderr = 9; // Standard error (truncated if too long)
1401
+ optional string error = 10; // Error message (if failed)
1402
+ }
1403
+
1404
+ // List all cron jobs
1405
+ message ListCronJobsRequest {}
1406
+
1407
+ message ListCronJobsResponse {
1408
+ repeated CronJob jobs = 1;
1409
+ }
1410
+
1411
+ // Create a new cron job
1412
+ message CreateCronJobRequest {
1413
+ string name = 1; // Job name (required)
1414
+ string schedule = 2; // Schedule expression - cron syntax or natural language
1415
+ string command = 3; // Command to execute (required)
1416
+ optional uint64 timeout_ms = 4; // Execution timeout (default: 60000)
1417
+ }
1418
+
1419
+ message CreateCronJobResponse {
1420
+ bool success = 1;
1421
+ CronJob job = 2;
1422
+ string error = 3;
1423
+ }
1424
+
1425
+ // Get a cron job by ID or name
1426
+ message GetCronJobRequest {
1427
+ optional string id = 1; // Job ID
1428
+ optional string name = 2; // Job name (alternative to ID)
1429
+ }
1430
+
1431
+ message GetCronJobResponse {
1432
+ optional CronJob job = 1;
1433
+ }
1434
+
1435
+ // Update a cron job
1436
+ message UpdateCronJobRequest {
1437
+ string id = 1; // Job ID (required)
1438
+ optional string schedule = 2; // New schedule expression
1439
+ optional string command = 3; // New command
1440
+ optional uint64 timeout_ms = 4; // New timeout
1441
+ }
1442
+
1443
+ message UpdateCronJobResponse {
1444
+ bool success = 1;
1445
+ CronJob job = 2;
1446
+ string error = 3;
1447
+ }
1448
+
1449
+ // Pause a cron job
1450
+ message PauseCronJobRequest {
1451
+ string id = 1; // Job ID
1452
+ }
1453
+
1454
+ message PauseCronJobResponse {
1455
+ bool success = 1;
1456
+ CronJob job = 2;
1457
+ string error = 3;
1458
+ }
1459
+
1460
+ // Resume a paused cron job
1461
+ message ResumeCronJobRequest {
1462
+ string id = 1; // Job ID
1463
+ }
1464
+
1465
+ message ResumeCronJobResponse {
1466
+ bool success = 1;
1467
+ CronJob job = 2;
1468
+ string error = 3;
1469
+ }
1470
+
1471
+ // Delete a cron job
1472
+ message DeleteCronJobRequest {
1473
+ string id = 1; // Job ID
1474
+ }
1475
+
1476
+ message DeleteCronJobResponse {
1477
+ bool success = 1;
1478
+ string error = 2;
1479
+ }
1480
+
1481
+ // Get execution history for a cron job
1482
+ message GetCronHistoryRequest {
1483
+ string id = 1; // Job ID
1484
+ optional uint32 limit = 2; // Max records to return (default: 10)
1485
+ }
1486
+
1487
+ message GetCronHistoryResponse {
1488
+ repeated CronExecution executions = 1;
1489
+ }
1490
+
1491
+ // Manually run a cron job
1492
+ message RunCronJobRequest {
1493
+ string id = 1; // Job ID
1494
+ }
1495
+
1496
+ message RunCronJobResponse {
1497
+ bool success = 1;
1498
+ CronExecution execution = 2;
1499
+ string error = 3;
1500
+ }
1501
+
1502
+ // Parse natural language schedule to cron expression
1503
+ message ParseCronScheduleRequest {
1504
+ string input = 1; // Natural language or cron expression
1505
+ }
1506
+
1507
+ message ParseCronScheduleResponse {
1508
+ bool success = 1;
1509
+ string cron_expression = 2; // Parsed cron expression
1510
+ string description = 3; // Human-readable description
1511
+ string error = 4;
1512
+ }