@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,1107 @@
1
+ /**
2
+ * A3S Code Agent gRPC Client
3
+ *
4
+ * Full implementation of the CodeAgentService interface.
5
+ */
6
+ import { type OpenAIMessage, type OpenAIChatCompletion, type OpenAIChatCompletionChunk } from './openai-compat.js';
7
+ export type HealthStatus = 'STATUS_UNKNOWN' | 'STATUS_HEALTHY' | 'STATUS_DEGRADED' | 'STATUS_UNHEALTHY';
8
+ export type SessionState = 'SESSION_STATE_UNKNOWN' | 'SESSION_STATE_ACTIVE' | 'SESSION_STATE_PAUSED' | 'SESSION_STATE_COMPLETED' | 'SESSION_STATE_ERROR';
9
+ export type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
10
+ export type FinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'error';
11
+ export type ChunkType = 'content' | 'tool_call' | 'tool_result' | 'metadata' | 'done';
12
+ export type EventType = 'EVENT_TYPE_UNKNOWN' | 'EVENT_TYPE_SESSION_CREATED' | 'EVENT_TYPE_SESSION_DESTROYED' | 'EVENT_TYPE_GENERATION_STARTED' | 'EVENT_TYPE_GENERATION_COMPLETED' | 'EVENT_TYPE_TOOL_CALLED' | 'EVENT_TYPE_TOOL_COMPLETED' | 'EVENT_TYPE_ERROR' | 'EVENT_TYPE_WARNING' | 'EVENT_TYPE_INFO' | 'EVENT_TYPE_CONFIRMATION_REQUIRED' | 'EVENT_TYPE_CONFIRMATION_RECEIVED' | 'EVENT_TYPE_CONFIRMATION_TIMEOUT' | 'EVENT_TYPE_EXTERNAL_TASK_PENDING' | 'EVENT_TYPE_EXTERNAL_TASK_COMPLETED' | 'EVENT_TYPE_PERMISSION_DENIED';
13
+ export type SessionLaneType = 'SESSION_LANE_UNKNOWN' | 'SESSION_LANE_CONTROL' | 'SESSION_LANE_QUERY' | 'SESSION_LANE_EXECUTE' | 'SESSION_LANE_GENERATE';
14
+ export type TimeoutActionType = 'TIMEOUT_ACTION_UNKNOWN' | 'TIMEOUT_ACTION_REJECT' | 'TIMEOUT_ACTION_AUTO_APPROVE';
15
+ export type TaskHandlerModeType = 'TASK_HANDLER_MODE_UNKNOWN' | 'TASK_HANDLER_MODE_INTERNAL' | 'TASK_HANDLER_MODE_EXTERNAL' | 'TASK_HANDLER_MODE_HYBRID';
16
+ export type PermissionDecision = 'PERMISSION_DECISION_UNKNOWN' | 'PERMISSION_DECISION_ALLOW' | 'PERMISSION_DECISION_DENY' | 'PERMISSION_DECISION_ASK';
17
+ export type StorageTypeString = 'STORAGE_TYPE_UNSPECIFIED' | 'STORAGE_TYPE_MEMORY' | 'STORAGE_TYPE_FILE';
18
+ export declare const StorageType: {
19
+ readonly STORAGE_TYPE_UNSPECIFIED: 0;
20
+ readonly STORAGE_TYPE_MEMORY: 1;
21
+ readonly STORAGE_TYPE_FILE: 2;
22
+ };
23
+ export declare const SessionLane: {
24
+ readonly SESSION_LANE_UNKNOWN: 0;
25
+ readonly SESSION_LANE_CONTROL: 1;
26
+ readonly SESSION_LANE_QUERY: 2;
27
+ readonly SESSION_LANE_EXECUTE: 3;
28
+ readonly SESSION_LANE_GENERATE: 4;
29
+ };
30
+ export declare const TimeoutAction: {
31
+ readonly TIMEOUT_ACTION_UNKNOWN: 0;
32
+ readonly TIMEOUT_ACTION_REJECT: 1;
33
+ readonly TIMEOUT_ACTION_AUTO_APPROVE: 2;
34
+ };
35
+ export declare const TaskHandlerMode: {
36
+ readonly TASK_HANDLER_MODE_UNKNOWN: 0;
37
+ readonly TASK_HANDLER_MODE_INTERNAL: 1;
38
+ readonly TASK_HANDLER_MODE_EXTERNAL: 2;
39
+ readonly TASK_HANDLER_MODE_HYBRID: 3;
40
+ };
41
+ export interface HealthCheckResponse {
42
+ status: HealthStatus;
43
+ message: string;
44
+ details: Record<string, string>;
45
+ }
46
+ export interface AgentInfo {
47
+ name: string;
48
+ version: string;
49
+ description: string;
50
+ author: string;
51
+ license: string;
52
+ homepage: string;
53
+ }
54
+ export interface ToolCapability {
55
+ name: string;
56
+ description: string;
57
+ parameters: string[];
58
+ async: boolean;
59
+ }
60
+ export interface ModelCapability {
61
+ provider: string;
62
+ model: string;
63
+ features: string[];
64
+ }
65
+ export interface ResourceLimits {
66
+ maxContextTokens: number;
67
+ maxConcurrentSessions: number;
68
+ maxToolsPerRequest: number;
69
+ }
70
+ export interface GetCapabilitiesResponse {
71
+ info?: AgentInfo;
72
+ features: string[];
73
+ tools: ToolCapability[];
74
+ models: ModelCapability[];
75
+ limits?: ResourceLimits;
76
+ metadata: Record<string, string>;
77
+ }
78
+ export interface InitializeResponse {
79
+ success: boolean;
80
+ message: string;
81
+ info?: AgentInfo;
82
+ }
83
+ export interface ShutdownResponse {
84
+ success: boolean;
85
+ message: string;
86
+ }
87
+ export interface LLMConfig {
88
+ provider: string;
89
+ model: string;
90
+ apiKey?: string;
91
+ baseUrl?: string;
92
+ temperature?: number;
93
+ maxTokens?: number;
94
+ }
95
+ export interface SessionConfig {
96
+ name: string;
97
+ workspace: string;
98
+ llm?: LLMConfig;
99
+ systemPrompt?: string;
100
+ maxContextLength?: number;
101
+ autoCompact?: boolean;
102
+ storageType?: number;
103
+ }
104
+ export interface ContextUsage {
105
+ totalTokens: number;
106
+ promptTokens: number;
107
+ completionTokens: number;
108
+ messageCount: number;
109
+ }
110
+ export interface Session {
111
+ sessionId: string;
112
+ config?: SessionConfig;
113
+ state: SessionState;
114
+ contextUsage?: ContextUsage;
115
+ createdAt: number;
116
+ updatedAt: number;
117
+ }
118
+ export interface CreateSessionResponse {
119
+ sessionId: string;
120
+ session?: Session;
121
+ }
122
+ export interface DestroySessionResponse {
123
+ success: boolean;
124
+ }
125
+ export interface ListSessionsResponse {
126
+ sessions: Session[];
127
+ }
128
+ export interface GetSessionResponse {
129
+ session?: Session;
130
+ }
131
+ export interface ConfigureSessionResponse {
132
+ session?: Session;
133
+ }
134
+ export interface Message {
135
+ role: MessageRole;
136
+ content: string;
137
+ metadata?: Record<string, string>;
138
+ }
139
+ export interface TextContent {
140
+ text: string;
141
+ }
142
+ export interface ToolUseContent {
143
+ id: string;
144
+ name: string;
145
+ arguments: string;
146
+ }
147
+ export interface ToolResultContent {
148
+ toolUseId: string;
149
+ content: string;
150
+ isError: boolean;
151
+ }
152
+ export interface ContentBlock {
153
+ text?: TextContent;
154
+ toolUse?: ToolUseContent;
155
+ toolResult?: ToolResultContent;
156
+ }
157
+ export interface ConversationMessage {
158
+ id: string;
159
+ role: string;
160
+ content: ContentBlock[];
161
+ timestamp: number;
162
+ metadata: Record<string, string>;
163
+ }
164
+ export interface GetMessagesResponse {
165
+ messages: ConversationMessage[];
166
+ totalCount: number;
167
+ hasMore: boolean;
168
+ }
169
+ export interface ToolResult {
170
+ success: boolean;
171
+ output: string;
172
+ error: string;
173
+ metadata: Record<string, string>;
174
+ }
175
+ export interface ToolCall {
176
+ id: string;
177
+ name: string;
178
+ arguments: string;
179
+ result?: ToolResult;
180
+ }
181
+ export interface Usage {
182
+ promptTokens: number;
183
+ completionTokens: number;
184
+ totalTokens: number;
185
+ }
186
+ export interface GenerateResponse {
187
+ sessionId: string;
188
+ message?: Message;
189
+ toolCalls: ToolCall[];
190
+ usage?: Usage;
191
+ finishReason: FinishReason;
192
+ metadata: Record<string, string>;
193
+ }
194
+ export interface GenerateChunk {
195
+ type: ChunkType;
196
+ sessionId: string;
197
+ content: string;
198
+ toolCall?: ToolCall;
199
+ toolResult?: ToolResult;
200
+ metadata: Record<string, string>;
201
+ finishReason?: FinishReason;
202
+ }
203
+ export interface GenerateStructuredResponse {
204
+ sessionId: string;
205
+ data: string;
206
+ usage?: Usage;
207
+ metadata: Record<string, string>;
208
+ }
209
+ export interface GenerateStructuredChunk {
210
+ sessionId: string;
211
+ data: string;
212
+ done: boolean;
213
+ }
214
+ export interface Skill {
215
+ name: string;
216
+ description: string;
217
+ tools: string[];
218
+ metadata: Record<string, string>;
219
+ }
220
+ export interface LoadSkillResponse {
221
+ success: boolean;
222
+ toolNames: string[];
223
+ }
224
+ export interface UnloadSkillResponse {
225
+ success: boolean;
226
+ removedTools: string[];
227
+ }
228
+ export interface ListSkillsResponse {
229
+ skills: Skill[];
230
+ }
231
+ export interface ClaudeCodeSkill {
232
+ name: string;
233
+ description: string;
234
+ allowedTools?: string;
235
+ disableModelInvocation: boolean;
236
+ content: string;
237
+ }
238
+ export interface GetClaudeCodeSkillsResponse {
239
+ skills: ClaudeCodeSkill[];
240
+ }
241
+ export interface GetContextUsageResponse {
242
+ usage?: ContextUsage;
243
+ }
244
+ export interface CompactContextResponse {
245
+ success: boolean;
246
+ before?: ContextUsage;
247
+ after?: ContextUsage;
248
+ }
249
+ export interface ClearContextResponse {
250
+ success: boolean;
251
+ }
252
+ export interface AgentEvent {
253
+ type: EventType;
254
+ sessionId?: string;
255
+ timestamp: number;
256
+ message: string;
257
+ data: Record<string, string>;
258
+ }
259
+ export interface CancelResponse {
260
+ success: boolean;
261
+ }
262
+ export interface PauseResponse {
263
+ success: boolean;
264
+ }
265
+ export interface ResumeResponse {
266
+ success: boolean;
267
+ }
268
+ export interface ConfirmationPolicy {
269
+ enabled: boolean;
270
+ autoApproveTools: string[];
271
+ requireConfirmTools: string[];
272
+ defaultTimeoutMs: number;
273
+ timeoutAction: TimeoutActionType;
274
+ yoloLanes: SessionLaneType[];
275
+ }
276
+ export interface ConfirmToolExecutionResponse {
277
+ success: boolean;
278
+ error: string;
279
+ }
280
+ export interface SetConfirmationPolicyResponse {
281
+ success: boolean;
282
+ policy?: ConfirmationPolicy;
283
+ }
284
+ export interface GetConfirmationPolicyResponse {
285
+ policy?: ConfirmationPolicy;
286
+ }
287
+ export interface LaneHandlerConfig {
288
+ mode: TaskHandlerModeType;
289
+ timeoutMs: number;
290
+ }
291
+ export interface ExternalTask {
292
+ taskId: string;
293
+ sessionId: string;
294
+ lane: SessionLaneType;
295
+ commandType: string;
296
+ payload: string;
297
+ timeoutMs: number;
298
+ remainingMs: number;
299
+ }
300
+ export interface SetLaneHandlerResponse {
301
+ success: boolean;
302
+ config?: LaneHandlerConfig;
303
+ }
304
+ export interface GetLaneHandlerResponse {
305
+ config?: LaneHandlerConfig;
306
+ }
307
+ export interface CompleteExternalTaskResponse {
308
+ success: boolean;
309
+ error: string;
310
+ }
311
+ export interface ListPendingExternalTasksResponse {
312
+ tasks: ExternalTask[];
313
+ }
314
+ export interface PermissionRule {
315
+ rule: string;
316
+ }
317
+ export interface PermissionPolicy {
318
+ deny: PermissionRule[];
319
+ allow: PermissionRule[];
320
+ ask: PermissionRule[];
321
+ defaultDecision: PermissionDecision;
322
+ enabled: boolean;
323
+ }
324
+ export interface SetPermissionPolicyResponse {
325
+ success: boolean;
326
+ policy?: PermissionPolicy;
327
+ }
328
+ export interface GetPermissionPolicyResponse {
329
+ policy?: PermissionPolicy;
330
+ }
331
+ export interface CheckPermissionResponse {
332
+ decision: PermissionDecision;
333
+ matchingRules: string[];
334
+ }
335
+ export interface AddPermissionRuleResponse {
336
+ success: boolean;
337
+ error: string;
338
+ }
339
+ export interface Todo {
340
+ id: string;
341
+ content: string;
342
+ status: string;
343
+ priority: string;
344
+ }
345
+ export interface GetTodosResponse {
346
+ todos: Todo[];
347
+ }
348
+ export interface SetTodosResponse {
349
+ success: boolean;
350
+ todos: Todo[];
351
+ }
352
+ export interface ModelCostInfo {
353
+ input: number;
354
+ output: number;
355
+ cacheRead: number;
356
+ cacheWrite: number;
357
+ }
358
+ export interface ModelLimitInfo {
359
+ context: number;
360
+ output: number;
361
+ }
362
+ export interface ModelModalitiesInfo {
363
+ input: string[];
364
+ output: string[];
365
+ }
366
+ export interface ModelInfo {
367
+ id: string;
368
+ name: string;
369
+ family: string;
370
+ apiKey?: string;
371
+ baseUrl?: string;
372
+ attachment: boolean;
373
+ reasoning: boolean;
374
+ toolCall: boolean;
375
+ temperature: boolean;
376
+ releaseDate?: string;
377
+ modalities?: ModelModalitiesInfo;
378
+ cost?: ModelCostInfo;
379
+ limit?: ModelLimitInfo;
380
+ }
381
+ export interface ProviderInfo {
382
+ name: string;
383
+ apiKey?: string;
384
+ baseUrl?: string;
385
+ models: ModelInfo[];
386
+ }
387
+ export interface ListProvidersResponse {
388
+ providers: ProviderInfo[];
389
+ defaultProvider?: string;
390
+ defaultModel?: string;
391
+ }
392
+ export interface GetProviderResponse {
393
+ provider?: ProviderInfo;
394
+ }
395
+ export interface AddProviderResponse {
396
+ success: boolean;
397
+ error: string;
398
+ provider?: ProviderInfo;
399
+ }
400
+ export interface UpdateProviderResponse {
401
+ success: boolean;
402
+ error: string;
403
+ provider?: ProviderInfo;
404
+ }
405
+ export interface RemoveProviderResponse {
406
+ success: boolean;
407
+ error: string;
408
+ }
409
+ export interface SetDefaultModelResponse {
410
+ success: boolean;
411
+ error: string;
412
+ provider: string;
413
+ model: string;
414
+ }
415
+ export interface GetDefaultModelResponse {
416
+ provider?: string;
417
+ model?: string;
418
+ }
419
+ export type Complexity = 'COMPLEXITY_UNKNOWN' | 'COMPLEXITY_SIMPLE' | 'COMPLEXITY_MEDIUM' | 'COMPLEXITY_COMPLEX' | 'COMPLEXITY_VERY_COMPLEX';
420
+ export type StepStatus = 'STEP_STATUS_UNKNOWN' | 'STEP_STATUS_PENDING' | 'STEP_STATUS_IN_PROGRESS' | 'STEP_STATUS_COMPLETED' | 'STEP_STATUS_FAILED' | 'STEP_STATUS_SKIPPED';
421
+ export interface PlanStep {
422
+ id: string;
423
+ description: string;
424
+ tool?: string;
425
+ dependencies: string[];
426
+ status: StepStatus;
427
+ successCriteria: string[];
428
+ }
429
+ export interface ExecutionPlan {
430
+ goal: string;
431
+ steps: PlanStep[];
432
+ complexity: Complexity;
433
+ requiredTools: string[];
434
+ estimatedSteps: number;
435
+ }
436
+ export interface AgentGoal {
437
+ description: string;
438
+ successCriteria: string[];
439
+ progress: number;
440
+ achieved: boolean;
441
+ createdAt: number;
442
+ achievedAt?: number;
443
+ }
444
+ export interface CreatePlanResponse {
445
+ plan?: ExecutionPlan;
446
+ }
447
+ export interface GetPlanResponse {
448
+ plan?: ExecutionPlan;
449
+ }
450
+ export interface ExtractGoalResponse {
451
+ goal?: AgentGoal;
452
+ }
453
+ export interface CheckGoalAchievementResponse {
454
+ achieved: boolean;
455
+ progress: number;
456
+ remainingCriteria: string[];
457
+ }
458
+ export type MemoryType = 'MEMORY_TYPE_UNKNOWN' | 'MEMORY_TYPE_EPISODIC' | 'MEMORY_TYPE_SEMANTIC' | 'MEMORY_TYPE_PROCEDURAL' | 'MEMORY_TYPE_WORKING';
459
+ export interface MemoryItem {
460
+ id: string;
461
+ content: string;
462
+ timestamp: number;
463
+ importance: number;
464
+ tags: string[];
465
+ memoryType: MemoryType;
466
+ metadata: Record<string, string>;
467
+ accessCount: number;
468
+ lastAccessed?: number;
469
+ }
470
+ export interface MemoryStats {
471
+ longTermCount: number;
472
+ shortTermCount: number;
473
+ workingCount: number;
474
+ }
475
+ export interface StoreMemoryResponse {
476
+ success: boolean;
477
+ memoryId: string;
478
+ }
479
+ export interface RetrieveMemoryResponse {
480
+ memory?: MemoryItem;
481
+ }
482
+ export interface SearchMemoriesResponse {
483
+ memories: MemoryItem[];
484
+ totalCount: number;
485
+ }
486
+ export interface GetMemoryStatsResponse {
487
+ stats?: MemoryStats;
488
+ }
489
+ export interface ClearMemoriesResponse {
490
+ success: boolean;
491
+ clearedCount: number;
492
+ }
493
+ export interface McpStdioTransport {
494
+ command: string;
495
+ args: string[];
496
+ }
497
+ export interface McpHttpTransport {
498
+ url: string;
499
+ headers: Record<string, string>;
500
+ }
501
+ export interface McpTransport {
502
+ stdio?: McpStdioTransport;
503
+ http?: McpHttpTransport;
504
+ }
505
+ export interface McpServerConfig {
506
+ name: string;
507
+ transport: McpTransport;
508
+ enabled: boolean;
509
+ env: Record<string, string>;
510
+ }
511
+ export interface RegisterMcpServerResponse {
512
+ success: boolean;
513
+ message: string;
514
+ }
515
+ export interface ConnectMcpServerResponse {
516
+ success: boolean;
517
+ message: string;
518
+ toolNames: string[];
519
+ }
520
+ export interface DisconnectMcpServerResponse {
521
+ success: boolean;
522
+ }
523
+ export interface McpServerInfo {
524
+ name: string;
525
+ connected: boolean;
526
+ enabled: boolean;
527
+ toolCount: number;
528
+ error?: string;
529
+ }
530
+ export interface ListMcpServersResponse {
531
+ servers: McpServerInfo[];
532
+ }
533
+ export interface McpToolInfo {
534
+ fullName: string;
535
+ serverName: string;
536
+ toolName: string;
537
+ description: string;
538
+ inputSchema: string;
539
+ }
540
+ export interface GetMcpToolsResponse {
541
+ tools: McpToolInfo[];
542
+ }
543
+ export interface LspServerInfo {
544
+ language: string;
545
+ name: string;
546
+ version?: string;
547
+ running: boolean;
548
+ }
549
+ export interface LspPosition {
550
+ line: number;
551
+ character: number;
552
+ }
553
+ export interface LspRange {
554
+ start: LspPosition;
555
+ end: LspPosition;
556
+ }
557
+ export interface LspLocation {
558
+ uri: string;
559
+ range?: LspRange;
560
+ }
561
+ export interface LspSymbol {
562
+ name: string;
563
+ kind: string;
564
+ location?: LspLocation;
565
+ containerName?: string;
566
+ }
567
+ export interface LspDiagnostic {
568
+ uri: string;
569
+ range?: LspRange;
570
+ severity: string;
571
+ message: string;
572
+ code?: string;
573
+ source?: string;
574
+ }
575
+ export interface StartLspServerResponse {
576
+ success: boolean;
577
+ message: string;
578
+ serverInfo?: LspServerInfo;
579
+ }
580
+ export interface StopLspServerResponse {
581
+ success: boolean;
582
+ }
583
+ export interface ListLspServersResponse {
584
+ servers: LspServerInfo[];
585
+ }
586
+ export interface LspHoverResponse {
587
+ found: boolean;
588
+ content: string;
589
+ range?: LspRange;
590
+ }
591
+ export interface LspDefinitionResponse {
592
+ locations: LspLocation[];
593
+ }
594
+ export interface LspReferencesResponse {
595
+ locations: LspLocation[];
596
+ }
597
+ export interface LspSymbolsResponse {
598
+ symbols: LspSymbol[];
599
+ }
600
+ export interface LspDiagnosticsResponse {
601
+ diagnostics: LspDiagnostic[];
602
+ }
603
+ export type CronJobStatus = 'CRON_JOB_STATUS_UNKNOWN' | 'CRON_JOB_STATUS_ACTIVE' | 'CRON_JOB_STATUS_PAUSED' | 'CRON_JOB_STATUS_RUNNING';
604
+ export type CronExecutionStatus = 'CRON_EXECUTION_STATUS_UNKNOWN' | 'CRON_EXECUTION_STATUS_SUCCESS' | 'CRON_EXECUTION_STATUS_FAILED' | 'CRON_EXECUTION_STATUS_TIMEOUT' | 'CRON_EXECUTION_STATUS_CANCELLED';
605
+ export declare const CronJobStatusEnum: {
606
+ readonly UNKNOWN: 0;
607
+ readonly ACTIVE: 1;
608
+ readonly PAUSED: 2;
609
+ readonly RUNNING: 3;
610
+ };
611
+ export declare const CronExecutionStatusEnum: {
612
+ readonly UNKNOWN: 0;
613
+ readonly SUCCESS: 1;
614
+ readonly FAILED: 2;
615
+ readonly TIMEOUT: 3;
616
+ readonly CANCELLED: 4;
617
+ };
618
+ export interface CronJob {
619
+ id: string;
620
+ name: string;
621
+ schedule: string;
622
+ command: string;
623
+ status: number;
624
+ timeoutMs: number;
625
+ createdAt: number;
626
+ updatedAt: number;
627
+ lastRun?: number;
628
+ nextRun?: number;
629
+ runCount: number;
630
+ failCount: number;
631
+ workingDir?: string;
632
+ }
633
+ export interface CronExecution {
634
+ id: string;
635
+ jobId: string;
636
+ status: number;
637
+ startedAt: number;
638
+ endedAt?: number;
639
+ durationMs?: number;
640
+ exitCode?: number;
641
+ stdout: string;
642
+ stderr: string;
643
+ error?: string;
644
+ }
645
+ export interface ListCronJobsResponse {
646
+ jobs: CronJob[];
647
+ }
648
+ export interface CreateCronJobResponse {
649
+ success: boolean;
650
+ job?: CronJob;
651
+ error: string;
652
+ }
653
+ export interface GetCronJobResponse {
654
+ job?: CronJob;
655
+ }
656
+ export interface UpdateCronJobResponse {
657
+ success: boolean;
658
+ job?: CronJob;
659
+ error: string;
660
+ }
661
+ export interface PauseCronJobResponse {
662
+ success: boolean;
663
+ job?: CronJob;
664
+ error: string;
665
+ }
666
+ export interface ResumeCronJobResponse {
667
+ success: boolean;
668
+ job?: CronJob;
669
+ error: string;
670
+ }
671
+ export interface DeleteCronJobResponse {
672
+ success: boolean;
673
+ error: string;
674
+ }
675
+ export interface GetCronHistoryResponse {
676
+ executions: CronExecution[];
677
+ }
678
+ export interface RunCronJobResponse {
679
+ success: boolean;
680
+ execution?: CronExecution;
681
+ error: string;
682
+ }
683
+ export interface ParseCronScheduleResponse {
684
+ success: boolean;
685
+ cronExpression: string;
686
+ description: string;
687
+ error: string;
688
+ }
689
+ export interface A3sClientOptions {
690
+ /** gRPC server address (default: localhost:4088) */
691
+ address?: string;
692
+ /** Use TLS for connection */
693
+ useTls?: boolean;
694
+ /** Connection timeout in milliseconds */
695
+ timeout?: number;
696
+ /** Path to config directory containing config.json */
697
+ configDir?: string;
698
+ /** Path to config.json file */
699
+ configPath?: string;
700
+ }
701
+ /**
702
+ * A3S Code Agent gRPC Client
703
+ *
704
+ * Provides a TypeScript interface to all CodeAgentService RPCs.
705
+ *
706
+ * @example
707
+ * ```typescript
708
+ * // Create client with config directory
709
+ * const client = new A3sClient({ configDir: '/path/to/a3s' });
710
+ *
711
+ * // Create client with config file
712
+ * const client = new A3sClient({ configPath: '/path/to/config.json' });
713
+ *
714
+ * // Create client with explicit address
715
+ * const client = new A3sClient({ address: 'localhost:4088' });
716
+ * ```
717
+ */
718
+ export declare class A3sClient {
719
+ private client;
720
+ private address;
721
+ private configDir?;
722
+ constructor(options?: A3sClientOptions);
723
+ /**
724
+ * Get the config directory path
725
+ */
726
+ getConfigDir(): string | undefined;
727
+ /**
728
+ * Get the server address
729
+ */
730
+ getAddress(): string;
731
+ /**
732
+ * Close the client connection
733
+ */
734
+ close(): void;
735
+ private promisify;
736
+ /**
737
+ * Check the health status of the agent
738
+ */
739
+ healthCheck(): Promise<HealthCheckResponse>;
740
+ /**
741
+ * Get agent capabilities
742
+ */
743
+ getCapabilities(): Promise<GetCapabilitiesResponse>;
744
+ /**
745
+ * Initialize the agent with workspace and environment
746
+ */
747
+ initialize(workspace: string, env?: Record<string, string>): Promise<InitializeResponse>;
748
+ /**
749
+ * Shutdown the agent
750
+ */
751
+ shutdown(): Promise<ShutdownResponse>;
752
+ /**
753
+ * Create a new session
754
+ */
755
+ createSession(config?: SessionConfig, sessionId?: string, initialContext?: Message[]): Promise<CreateSessionResponse>;
756
+ /**
757
+ * Destroy a session
758
+ */
759
+ destroySession(sessionId: string): Promise<DestroySessionResponse>;
760
+ /**
761
+ * List all sessions
762
+ */
763
+ listSessions(): Promise<ListSessionsResponse>;
764
+ /**
765
+ * Get a specific session
766
+ */
767
+ getSession(sessionId: string): Promise<GetSessionResponse>;
768
+ /**
769
+ * Configure a session
770
+ */
771
+ configureSession(sessionId: string, config: SessionConfig): Promise<ConfigureSessionResponse>;
772
+ /**
773
+ * Get messages from a session
774
+ */
775
+ getMessages(sessionId: string, limit?: number, offset?: number): Promise<GetMessagesResponse>;
776
+ /**
777
+ * Generate a response (unary)
778
+ *
779
+ * Supports both A3S and OpenAI message formats:
780
+ * - A3S: { role: 'ROLE_USER', content: '...' }
781
+ * - OpenAI: { role: 'user', content: '...' }
782
+ */
783
+ generate(sessionId: string, messages: (Message | OpenAIMessage)[]): Promise<GenerateResponse>;
784
+ /**
785
+ * Generate a response (streaming)
786
+ *
787
+ * Supports both A3S and OpenAI message formats.
788
+ */
789
+ streamGenerate(sessionId: string, messages: (Message | OpenAIMessage)[]): AsyncIterable<GenerateChunk>;
790
+ /**
791
+ * Generate structured output (unary)
792
+ *
793
+ * Supports both A3S and OpenAI message formats.
794
+ */
795
+ generateStructured(sessionId: string, messages: (Message | OpenAIMessage)[], schema: string): Promise<GenerateStructuredResponse>;
796
+ /**
797
+ * Generate structured output (streaming)
798
+ *
799
+ * Supports both A3S and OpenAI message formats.
800
+ */
801
+ streamGenerateStructured(sessionId: string, messages: (Message | OpenAIMessage)[], schema: string): AsyncIterable<GenerateStructuredChunk>;
802
+ /**
803
+ * Generate a response in OpenAI ChatCompletion format
804
+ *
805
+ * This method provides full OpenAI API compatibility.
806
+ *
807
+ * @example
808
+ * ```typescript
809
+ * const completion = await client.chatCompletion(sessionId, [
810
+ * { role: 'user', content: 'Hello!' }
811
+ * ]);
812
+ * console.log(completion.choices[0].message.content);
813
+ * ```
814
+ */
815
+ chatCompletion(sessionId: string, messages: OpenAIMessage[], options?: {
816
+ model?: string;
817
+ }): Promise<OpenAIChatCompletion>;
818
+ /**
819
+ * Stream a response in OpenAI ChatCompletionChunk format
820
+ *
821
+ * This method provides full OpenAI API compatibility for streaming.
822
+ *
823
+ * @example
824
+ * ```typescript
825
+ * for await (const chunk of client.streamChatCompletion(sessionId, [
826
+ * { role: 'user', content: 'Hello!' }
827
+ * ])) {
828
+ * const content = chunk.choices[0].delta.content;
829
+ * if (content) process.stdout.write(content);
830
+ * }
831
+ * ```
832
+ */
833
+ streamChatCompletion(sessionId: string, messages: OpenAIMessage[], options?: {
834
+ model?: string;
835
+ }): AsyncIterable<OpenAIChatCompletionChunk>;
836
+ /**
837
+ * Load a skill into a session
838
+ */
839
+ loadSkill(sessionId: string, skillName: string, skillContent?: string): Promise<LoadSkillResponse>;
840
+ /**
841
+ * Unload a skill from a session
842
+ */
843
+ unloadSkill(sessionId: string, skillName: string): Promise<UnloadSkillResponse>;
844
+ /**
845
+ * List available skills
846
+ */
847
+ listSkills(sessionId?: string): Promise<ListSkillsResponse>;
848
+ /**
849
+ * Get Claude Code skills
850
+ */
851
+ getClaudeCodeSkills(name?: string): Promise<GetClaudeCodeSkillsResponse>;
852
+ /**
853
+ * Get context usage for a session
854
+ */
855
+ getContextUsage(sessionId: string): Promise<GetContextUsageResponse>;
856
+ /**
857
+ * Compact context for a session
858
+ */
859
+ compactContext(sessionId: string): Promise<CompactContextResponse>;
860
+ /**
861
+ * Clear context for a session
862
+ */
863
+ clearContext(sessionId: string): Promise<ClearContextResponse>;
864
+ /**
865
+ * Subscribe to agent events
866
+ */
867
+ subscribeEvents(sessionId?: string, eventTypes?: string[]): AsyncIterable<AgentEvent>;
868
+ /**
869
+ * Cancel an operation
870
+ */
871
+ cancel(sessionId: string, operationId?: string): Promise<CancelResponse>;
872
+ /**
873
+ * Pause a session
874
+ */
875
+ pause(sessionId: string): Promise<PauseResponse>;
876
+ /**
877
+ * Resume a session
878
+ */
879
+ resume(sessionId: string): Promise<ResumeResponse>;
880
+ /**
881
+ * Confirm or reject tool execution
882
+ */
883
+ confirmToolExecution(sessionId: string, toolId: string, approved: boolean, reason?: string): Promise<ConfirmToolExecutionResponse>;
884
+ /**
885
+ * Set confirmation policy for a session
886
+ */
887
+ setConfirmationPolicy(sessionId: string, policy: ConfirmationPolicy): Promise<SetConfirmationPolicyResponse>;
888
+ /**
889
+ * Get confirmation policy for a session
890
+ */
891
+ getConfirmationPolicy(sessionId: string): Promise<GetConfirmationPolicyResponse>;
892
+ /**
893
+ * Set lane handler configuration
894
+ */
895
+ setLaneHandler(sessionId: string, lane: SessionLaneType, config: LaneHandlerConfig): Promise<SetLaneHandlerResponse>;
896
+ /**
897
+ * Get lane handler configuration
898
+ */
899
+ getLaneHandler(sessionId: string, lane: SessionLaneType): Promise<GetLaneHandlerResponse>;
900
+ /**
901
+ * Complete an external task
902
+ */
903
+ completeExternalTask(sessionId: string, taskId: string, success: boolean, result?: string, error?: string): Promise<CompleteExternalTaskResponse>;
904
+ /**
905
+ * List pending external tasks
906
+ */
907
+ listPendingExternalTasks(sessionId: string): Promise<ListPendingExternalTasksResponse>;
908
+ /**
909
+ * Set permission policy for a session
910
+ */
911
+ setPermissionPolicy(sessionId: string, policy: PermissionPolicy): Promise<SetPermissionPolicyResponse>;
912
+ /**
913
+ * Get permission policy for a session
914
+ */
915
+ getPermissionPolicy(sessionId: string): Promise<GetPermissionPolicyResponse>;
916
+ /**
917
+ * Check permission for a tool call
918
+ */
919
+ checkPermission(sessionId: string, toolName: string, args: string): Promise<CheckPermissionResponse>;
920
+ /**
921
+ * Add a permission rule
922
+ */
923
+ addPermissionRule(sessionId: string, ruleType: 'allow' | 'deny' | 'ask', rule: string): Promise<AddPermissionRuleResponse>;
924
+ /**
925
+ * Get todos for a session
926
+ */
927
+ getTodos(sessionId: string): Promise<GetTodosResponse>;
928
+ /**
929
+ * Set todos for a session
930
+ */
931
+ setTodos(sessionId: string, todos: Todo[]): Promise<SetTodosResponse>;
932
+ /**
933
+ * List all providers
934
+ */
935
+ listProviders(): Promise<ListProvidersResponse>;
936
+ /**
937
+ * Get a specific provider
938
+ */
939
+ getProvider(name: string): Promise<GetProviderResponse>;
940
+ /**
941
+ * Add a new provider
942
+ */
943
+ addProvider(provider: ProviderInfo): Promise<AddProviderResponse>;
944
+ /**
945
+ * Update an existing provider
946
+ */
947
+ updateProvider(provider: ProviderInfo): Promise<UpdateProviderResponse>;
948
+ /**
949
+ * Remove a provider
950
+ */
951
+ removeProvider(name: string): Promise<RemoveProviderResponse>;
952
+ /**
953
+ * Set the default model
954
+ */
955
+ setDefaultModel(provider: string, model: string): Promise<SetDefaultModelResponse>;
956
+ /**
957
+ * Get the default model
958
+ */
959
+ getDefaultModel(): Promise<GetDefaultModelResponse>;
960
+ /**
961
+ * Create an execution plan
962
+ */
963
+ createPlan(sessionId: string, prompt: string, context?: string): Promise<CreatePlanResponse>;
964
+ /**
965
+ * Get an existing plan
966
+ */
967
+ getPlan(sessionId: string, planId: string): Promise<GetPlanResponse>;
968
+ /**
969
+ * Extract goal from prompt
970
+ */
971
+ extractGoal(sessionId: string, prompt: string): Promise<ExtractGoalResponse>;
972
+ /**
973
+ * Check if goal is achieved
974
+ */
975
+ checkGoalAchievement(sessionId: string, goal: AgentGoal, currentState: string): Promise<CheckGoalAchievementResponse>;
976
+ /**
977
+ * Store a memory item
978
+ */
979
+ storeMemory(sessionId: string, memory: MemoryItem): Promise<StoreMemoryResponse>;
980
+ /**
981
+ * Retrieve a memory by ID
982
+ */
983
+ retrieveMemory(sessionId: string, memoryId: string): Promise<RetrieveMemoryResponse>;
984
+ /**
985
+ * Search memories
986
+ */
987
+ searchMemories(sessionId: string, query?: string, tags?: string[], limit?: number, recentOnly?: boolean, minImportance?: number): Promise<SearchMemoriesResponse>;
988
+ /**
989
+ * Get memory statistics
990
+ */
991
+ getMemoryStats(sessionId: string): Promise<GetMemoryStatsResponse>;
992
+ /**
993
+ * Clear memories
994
+ */
995
+ clearMemories(sessionId: string, clearLongTerm?: boolean, clearShortTerm?: boolean, clearWorking?: boolean): Promise<ClearMemoriesResponse>;
996
+ /**
997
+ * Register an MCP server
998
+ */
999
+ registerMcpServer(config: McpServerConfig): Promise<RegisterMcpServerResponse>;
1000
+ /**
1001
+ * Connect to an MCP server
1002
+ */
1003
+ connectMcpServer(name: string): Promise<ConnectMcpServerResponse>;
1004
+ /**
1005
+ * Disconnect from an MCP server
1006
+ */
1007
+ disconnectMcpServer(name: string): Promise<DisconnectMcpServerResponse>;
1008
+ /**
1009
+ * List all MCP servers
1010
+ */
1011
+ listMcpServers(): Promise<ListMcpServersResponse>;
1012
+ /**
1013
+ * Get MCP tools
1014
+ */
1015
+ getMcpTools(serverName?: string): Promise<GetMcpToolsResponse>;
1016
+ /**
1017
+ * Start a language server for a specific language
1018
+ */
1019
+ startLspServer(language: string, rootUri?: string): Promise<StartLspServerResponse>;
1020
+ /**
1021
+ * Stop a running language server
1022
+ */
1023
+ stopLspServer(language: string): Promise<StopLspServerResponse>;
1024
+ /**
1025
+ * List all running language servers
1026
+ */
1027
+ listLspServers(): Promise<ListLspServersResponse>;
1028
+ /**
1029
+ * Get hover information at a specific position
1030
+ */
1031
+ lspHover(filePath: string, line: number, column: number): Promise<LspHoverResponse>;
1032
+ /**
1033
+ * Go to definition at a specific position
1034
+ */
1035
+ lspDefinition(filePath: string, line: number, column: number): Promise<LspDefinitionResponse>;
1036
+ /**
1037
+ * Find all references at a specific position
1038
+ */
1039
+ lspReferences(filePath: string, line: number, column: number, includeDeclaration?: boolean): Promise<LspReferencesResponse>;
1040
+ /**
1041
+ * Search for symbols in the workspace
1042
+ */
1043
+ lspSymbols(query: string, limit?: number): Promise<LspSymbolsResponse>;
1044
+ /**
1045
+ * Get diagnostics for a file
1046
+ */
1047
+ lspDiagnostics(filePath?: string): Promise<LspDiagnosticsResponse>;
1048
+ /**
1049
+ * List all cron jobs
1050
+ */
1051
+ listCronJobs(): Promise<ListCronJobsResponse>;
1052
+ /**
1053
+ * Create a new cron job
1054
+ * @param name Job name
1055
+ * @param schedule Schedule expression (cron syntax or natural language)
1056
+ * @param command Command to execute
1057
+ * @param timeoutMs Execution timeout in milliseconds (default: 60000)
1058
+ */
1059
+ createCronJob(name: string, schedule: string, command: string, timeoutMs?: number): Promise<CreateCronJobResponse>;
1060
+ /**
1061
+ * Get a cron job by ID or name
1062
+ * @param id Job ID
1063
+ * @param name Job name (alternative to ID)
1064
+ */
1065
+ getCronJob(id?: string, name?: string): Promise<GetCronJobResponse>;
1066
+ /**
1067
+ * Update a cron job
1068
+ * @param id Job ID
1069
+ * @param schedule New schedule expression
1070
+ * @param command New command
1071
+ * @param timeoutMs New timeout
1072
+ */
1073
+ updateCronJob(id: string, schedule?: string, command?: string, timeoutMs?: number): Promise<UpdateCronJobResponse>;
1074
+ /**
1075
+ * Pause a cron job
1076
+ * @param id Job ID
1077
+ */
1078
+ pauseCronJob(id: string): Promise<PauseCronJobResponse>;
1079
+ /**
1080
+ * Resume a paused cron job
1081
+ * @param id Job ID
1082
+ */
1083
+ resumeCronJob(id: string): Promise<ResumeCronJobResponse>;
1084
+ /**
1085
+ * Delete a cron job
1086
+ * @param id Job ID
1087
+ */
1088
+ deleteCronJob(id: string): Promise<DeleteCronJobResponse>;
1089
+ /**
1090
+ * Get execution history for a cron job
1091
+ * @param id Job ID
1092
+ * @param limit Max records to return (default: 10)
1093
+ */
1094
+ getCronHistory(id: string, limit?: number): Promise<GetCronHistoryResponse>;
1095
+ /**
1096
+ * Manually run a cron job
1097
+ * @param id Job ID
1098
+ */
1099
+ runCronJob(id: string): Promise<RunCronJobResponse>;
1100
+ /**
1101
+ * Parse natural language schedule to cron expression
1102
+ * @param input Natural language or cron expression
1103
+ */
1104
+ parseCronSchedule(input: string): Promise<ParseCronScheduleResponse>;
1105
+ private streamToAsyncIterable;
1106
+ }
1107
+ //# sourceMappingURL=client.d.ts.map