-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathgenerated_rpc.go
More file actions
636 lines (557 loc) · 17.3 KB
/
Copy pathgenerated_rpc.go
File metadata and controls
636 lines (557 loc) · 17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
// AUTO-GENERATED FILE - DO NOT EDIT
// Generated from: api.schema.json
package rpc
import (
"context"
"encoding/json"
"github.com/github/copilot-sdk/go/internal/jsonrpc2"
)
type PingResult struct {
// Echoed message (or default greeting)
Message string `json:"message"`
// Server protocol version number
ProtocolVersion float64 `json:"protocolVersion"`
// Server timestamp in milliseconds
Timestamp float64 `json:"timestamp"`
}
type PingParams struct {
// Optional message to echo back
Message *string `json:"message,omitempty"`
}
type ModelsListResult struct {
// List of available models with full metadata
Models []Model `json:"models"`
}
type Model struct {
// Billing information
Billing *Billing `json:"billing,omitempty"`
// Model capabilities and limits
Capabilities Capabilities `json:"capabilities"`
// Default reasoning effort level (only present if model supports reasoning effort)
DefaultReasoningEffort *string `json:"defaultReasoningEffort,omitempty"`
// Model identifier (e.g., "claude-sonnet-4.5")
ID string `json:"id"`
// Display name
Name string `json:"name"`
// Policy state (if applicable)
Policy *Policy `json:"policy,omitempty"`
// Supported reasoning effort levels (only present if model supports reasoning effort)
SupportedReasoningEfforts []string `json:"supportedReasoningEfforts,omitempty"`
}
// Billing information
type Billing struct {
Multiplier float64 `json:"multiplier"`
}
// Model capabilities and limits
type Capabilities struct {
Limits Limits `json:"limits"`
Supports Supports `json:"supports"`
}
type Limits struct {
MaxContextWindowTokens float64 `json:"max_context_window_tokens"`
MaxOutputTokens *float64 `json:"max_output_tokens,omitempty"`
MaxPromptTokens *float64 `json:"max_prompt_tokens,omitempty"`
}
type Supports struct {
// Whether this model supports reasoning effort configuration
ReasoningEffort bool `json:"reasoningEffort"`
Vision bool `json:"vision"`
}
// Policy state (if applicable)
type Policy struct {
State string `json:"state"`
Terms string `json:"terms"`
}
type ToolsListResult struct {
// List of available built-in tools with metadata
Tools []Tool `json:"tools"`
}
type Tool struct {
// Description of what the tool does
Description string `json:"description"`
// Optional instructions for how to use this tool effectively
Instructions *string `json:"instructions,omitempty"`
// Tool identifier (e.g., "bash", "grep", "str_replace_editor")
Name string `json:"name"`
// Optional namespaced name for declarative filtering (e.g., "playwright/navigate" for MCP
// tools)
NamespacedName *string `json:"namespacedName,omitempty"`
// JSON Schema for the tool's input parameters
Parameters map[string]interface{} `json:"parameters,omitempty"`
}
type ToolsListParams struct {
// Optional model ID — when provided, the returned tool list reflects model-specific
// overrides
Model *string `json:"model,omitempty"`
}
type AccountGetQuotaResult struct {
// Quota snapshots keyed by type (e.g., chat, completions, premium_interactions)
QuotaSnapshots map[string]QuotaSnapshot `json:"quotaSnapshots"`
}
type QuotaSnapshot struct {
// Number of requests included in the entitlement
EntitlementRequests float64 `json:"entitlementRequests"`
// Number of overage requests made this period
Overage float64 `json:"overage"`
// Whether pay-per-request usage is allowed when quota is exhausted
OverageAllowedWithExhaustedQuota bool `json:"overageAllowedWithExhaustedQuota"`
// Percentage of entitlement remaining
RemainingPercentage float64 `json:"remainingPercentage"`
// Date when the quota resets (ISO 8601)
ResetDate *string `json:"resetDate,omitempty"`
// Number of requests used so far this period
UsedRequests float64 `json:"usedRequests"`
}
type SessionModelGetCurrentResult struct {
ModelID *string `json:"modelId,omitempty"`
}
type SessionModelSwitchToResult struct {
ModelID *string `json:"modelId,omitempty"`
}
type SessionModelSwitchToParams struct {
ModelID string `json:"modelId"`
}
type SessionModeGetResult struct {
// The current agent mode.
Mode Mode `json:"mode"`
}
type SessionModeSetResult struct {
// The agent mode after switching.
Mode Mode `json:"mode"`
}
type SessionModeSetParams struct {
// The mode to switch to. Valid values: "interactive", "plan", "autopilot".
Mode Mode `json:"mode"`
}
type SessionPlanReadResult struct {
// The content of plan.md, or null if it does not exist
Content *string `json:"content"`
// Whether plan.md exists in the workspace
Exists bool `json:"exists"`
}
type SessionPlanUpdateResult struct {
}
type SessionPlanUpdateParams struct {
// The new content for plan.md
Content string `json:"content"`
}
type SessionPlanDeleteResult struct {
}
type SessionWorkspaceListFilesResult struct {
// Relative file paths in the workspace files directory
Files []string `json:"files"`
}
type SessionWorkspaceReadFileResult struct {
// File content as a UTF-8 string
Content string `json:"content"`
}
type SessionWorkspaceReadFileParams struct {
// Relative path within the workspace files directory
Path string `json:"path"`
}
type SessionWorkspaceCreateFileResult struct {
}
type SessionWorkspaceCreateFileParams struct {
// File content to write as a UTF-8 string
Content string `json:"content"`
// Relative path within the workspace files directory
Path string `json:"path"`
}
type SessionFleetStartResult struct {
// Whether fleet mode was successfully activated
Started bool `json:"started"`
}
type SessionFleetStartParams struct {
// Optional user prompt to combine with fleet instructions
Prompt *string `json:"prompt,omitempty"`
}
type SessionAgentListResult struct {
// Available custom agents
Agents []AgentElement `json:"agents"`
}
type AgentElement struct {
// Description of the agent's purpose
Description string `json:"description"`
// Human-readable display name
DisplayName string `json:"displayName"`
// Unique identifier of the custom agent
Name string `json:"name"`
}
type SessionAgentGetCurrentResult struct {
// Currently selected custom agent, or null if using the default agent
Agent *SessionAgentGetCurrentResultAgent `json:"agent"`
}
type SessionAgentGetCurrentResultAgent struct {
// Description of the agent's purpose
Description string `json:"description"`
// Human-readable display name
DisplayName string `json:"displayName"`
// Unique identifier of the custom agent
Name string `json:"name"`
}
type SessionAgentSelectResult struct {
// The newly selected custom agent
Agent SessionAgentSelectResultAgent `json:"agent"`
}
// The newly selected custom agent
type SessionAgentSelectResultAgent struct {
// Description of the agent's purpose
Description string `json:"description"`
// Human-readable display name
DisplayName string `json:"displayName"`
// Unique identifier of the custom agent
Name string `json:"name"`
}
type SessionAgentSelectParams struct {
// Name of the custom agent to select
Name string `json:"name"`
}
type SessionAgentDeselectResult struct {
}
type SessionCompactionCompactResult struct {
// Number of messages removed during compaction
MessagesRemoved float64 `json:"messagesRemoved"`
// Whether compaction completed successfully
Success bool `json:"success"`
// Number of tokens freed by compaction
TokensRemoved float64 `json:"tokensRemoved"`
}
// The current agent mode.
//
// The agent mode after switching.
//
// The mode to switch to. Valid values: "interactive", "plan", "autopilot".
type Mode string
const (
Autopilot Mode = "autopilot"
Interactive Mode = "interactive"
Plan Mode = "plan"
)
type ModelsRpcApi struct{ client *jsonrpc2.Client }
func (a *ModelsRpcApi) List(ctx context.Context) (*ModelsListResult, error) {
raw, err := a.client.Request("models.list", map[string]interface{}{})
if err != nil {
return nil, err
}
var result ModelsListResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type ToolsRpcApi struct{ client *jsonrpc2.Client }
func (a *ToolsRpcApi) List(ctx context.Context, params *ToolsListParams) (*ToolsListResult, error) {
raw, err := a.client.Request("tools.list", params)
if err != nil {
return nil, err
}
var result ToolsListResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type AccountRpcApi struct{ client *jsonrpc2.Client }
func (a *AccountRpcApi) GetQuota(ctx context.Context) (*AccountGetQuotaResult, error) {
raw, err := a.client.Request("account.getQuota", map[string]interface{}{})
if err != nil {
return nil, err
}
var result AccountGetQuotaResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
// ServerRpc provides typed server-scoped RPC methods.
type ServerRpc struct {
client *jsonrpc2.Client
Models *ModelsRpcApi
Tools *ToolsRpcApi
Account *AccountRpcApi
}
func (a *ServerRpc) Ping(ctx context.Context, params *PingParams) (*PingResult, error) {
raw, err := a.client.Request("ping", params)
if err != nil {
return nil, err
}
var result PingResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func NewServerRpc(client *jsonrpc2.Client) *ServerRpc {
return &ServerRpc{client: client,
Models: &ModelsRpcApi{client: client},
Tools: &ToolsRpcApi{client: client},
Account: &AccountRpcApi{client: client},
}
}
type ModelRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *ModelRpcApi) GetCurrent(ctx context.Context) (*SessionModelGetCurrentResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.model.getCurrent", req)
if err != nil {
return nil, err
}
var result SessionModelGetCurrentResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *ModelRpcApi) SwitchTo(ctx context.Context, params *SessionModelSwitchToParams) (*SessionModelSwitchToResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
req["modelId"] = params.ModelID
}
raw, err := a.client.Request("session.model.switchTo", req)
if err != nil {
return nil, err
}
var result SessionModelSwitchToResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type ModeRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *ModeRpcApi) Get(ctx context.Context) (*SessionModeGetResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.mode.get", req)
if err != nil {
return nil, err
}
var result SessionModeGetResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *ModeRpcApi) Set(ctx context.Context, params *SessionModeSetParams) (*SessionModeSetResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
req["mode"] = params.Mode
}
raw, err := a.client.Request("session.mode.set", req)
if err != nil {
return nil, err
}
var result SessionModeSetResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type PlanRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *PlanRpcApi) Read(ctx context.Context) (*SessionPlanReadResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.plan.read", req)
if err != nil {
return nil, err
}
var result SessionPlanReadResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *PlanRpcApi) Update(ctx context.Context, params *SessionPlanUpdateParams) (*SessionPlanUpdateResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
req["content"] = params.Content
}
raw, err := a.client.Request("session.plan.update", req)
if err != nil {
return nil, err
}
var result SessionPlanUpdateResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *PlanRpcApi) Delete(ctx context.Context) (*SessionPlanDeleteResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.plan.delete", req)
if err != nil {
return nil, err
}
var result SessionPlanDeleteResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type WorkspaceRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *WorkspaceRpcApi) ListFiles(ctx context.Context) (*SessionWorkspaceListFilesResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.workspace.listFiles", req)
if err != nil {
return nil, err
}
var result SessionWorkspaceListFilesResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *WorkspaceRpcApi) ReadFile(ctx context.Context, params *SessionWorkspaceReadFileParams) (*SessionWorkspaceReadFileResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
req["path"] = params.Path
}
raw, err := a.client.Request("session.workspace.readFile", req)
if err != nil {
return nil, err
}
var result SessionWorkspaceReadFileResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *WorkspaceRpcApi) CreateFile(ctx context.Context, params *SessionWorkspaceCreateFileParams) (*SessionWorkspaceCreateFileResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
req["path"] = params.Path
req["content"] = params.Content
}
raw, err := a.client.Request("session.workspace.createFile", req)
if err != nil {
return nil, err
}
var result SessionWorkspaceCreateFileResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type FleetRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *FleetRpcApi) Start(ctx context.Context, params *SessionFleetStartParams) (*SessionFleetStartResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
if params.Prompt != nil {
req["prompt"] = *params.Prompt
}
}
raw, err := a.client.Request("session.fleet.start", req)
if err != nil {
return nil, err
}
var result SessionFleetStartResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type AgentRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *AgentRpcApi) List(ctx context.Context) (*SessionAgentListResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.agent.list", req)
if err != nil {
return nil, err
}
var result SessionAgentListResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *AgentRpcApi) GetCurrent(ctx context.Context) (*SessionAgentGetCurrentResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.agent.getCurrent", req)
if err != nil {
return nil, err
}
var result SessionAgentGetCurrentResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *AgentRpcApi) Select(ctx context.Context, params *SessionAgentSelectParams) (*SessionAgentSelectResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
if params != nil {
req["name"] = params.Name
}
raw, err := a.client.Request("session.agent.select", req)
if err != nil {
return nil, err
}
var result SessionAgentSelectResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
func (a *AgentRpcApi) Deselect(ctx context.Context) (*SessionAgentDeselectResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.agent.deselect", req)
if err != nil {
return nil, err
}
var result SessionAgentDeselectResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
type CompactionRpcApi struct {
client *jsonrpc2.Client
sessionID string
}
func (a *CompactionRpcApi) Compact(ctx context.Context) (*SessionCompactionCompactResult, error) {
req := map[string]interface{}{"sessionId": a.sessionID}
raw, err := a.client.Request("session.compaction.compact", req)
if err != nil {
return nil, err
}
var result SessionCompactionCompactResult
if err := json.Unmarshal(raw, &result); err != nil {
return nil, err
}
return &result, nil
}
// SessionRpc provides typed session-scoped RPC methods.
type SessionRpc struct {
client *jsonrpc2.Client
sessionID string
Model *ModelRpcApi
Mode *ModeRpcApi
Plan *PlanRpcApi
Workspace *WorkspaceRpcApi
Fleet *FleetRpcApi
Agent *AgentRpcApi
Compaction *CompactionRpcApi
}
func NewSessionRpc(client *jsonrpc2.Client, sessionID string) *SessionRpc {
return &SessionRpc{client: client, sessionID: sessionID,
Model: &ModelRpcApi{client: client, sessionID: sessionID},
Mode: &ModeRpcApi{client: client, sessionID: sessionID},
Plan: &PlanRpcApi{client: client, sessionID: sessionID},
Workspace: &WorkspaceRpcApi{client: client, sessionID: sessionID},
Fleet: &FleetRpcApi{client: client, sessionID: sessionID},
Agent: &AgentRpcApi{client: client, sessionID: sessionID},
Compaction: &CompactionRpcApi{client: client, sessionID: sessionID},
}
}