-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtool.go
More file actions
863 lines (747 loc) · 35.3 KB
/
tool.go
File metadata and controls
863 lines (747 loc) · 35.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
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package arcadego
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"slices"
"github.com/ArcadeAI/arcade-go/internal/apijson"
"github.com/ArcadeAI/arcade-go/internal/apiquery"
"github.com/ArcadeAI/arcade-go/internal/param"
"github.com/ArcadeAI/arcade-go/internal/requestconfig"
"github.com/ArcadeAI/arcade-go/option"
"github.com/ArcadeAI/arcade-go/packages/pagination"
"github.com/ArcadeAI/arcade-go/shared"
)
// ToolService contains methods and other services that help with interacting with
// the Arcade API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewToolService] method instead.
type ToolService struct {
Options []option.RequestOption
Scheduled *ToolScheduledService
Formatted *ToolFormattedService
}
// NewToolService generates a new service that applies the given options to each
// request. These options are applied after the parent client's options (if there
// is one), and before any request-specific options.
func NewToolService(opts ...option.RequestOption) (r *ToolService) {
r = &ToolService{}
r.Options = opts
r.Scheduled = NewToolScheduledService(opts...)
r.Formatted = NewToolFormattedService(opts...)
return
}
// Returns a page of tools from the engine configuration, optionally filtered by
// toolkit
func (r *ToolService) List(ctx context.Context, query ToolListParams, opts ...option.RequestOption) (res *pagination.OffsetPage[ToolDefinition], err error) {
var raw *http.Response
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := "v1/tools"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
}
err = cfg.Execute()
if err != nil {
return nil, err
}
res.SetPageConfig(cfg, raw)
return res, nil
}
// Returns a page of tools from the engine configuration, optionally filtered by
// toolkit
func (r *ToolService) ListAutoPaging(ctx context.Context, query ToolListParams, opts ...option.RequestOption) *pagination.OffsetPageAutoPager[ToolDefinition] {
return pagination.NewOffsetPageAutoPager(r.List(ctx, query, opts...))
}
// Authorizes a user for a specific tool by name
func (r *ToolService) Authorize(ctx context.Context, body ToolAuthorizeParams, opts ...option.RequestOption) (res *shared.AuthorizationResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/tools/authorize"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Executes a tool by name and arguments
func (r *ToolService) Execute(ctx context.Context, body ToolExecuteParams, opts ...option.RequestOption) (res *ExecuteToolResponse, err error) {
opts = slices.Concat(r.Options, opts)
path := "v1/tools/execute"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
// Returns the arcade tool specification for a specific tool
func (r *ToolService) Get(ctx context.Context, name string, query ToolGetParams, opts ...option.RequestOption) (res *ToolDefinition, err error) {
opts = slices.Concat(r.Options, opts)
if name == "" {
err = errors.New("missing required name parameter")
return
}
path := fmt.Sprintf("v1/tools/%s", name)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
type AuthorizeToolRequestParam struct {
ToolName param.Field[string] `json:"tool_name,required"`
// Optional: if provided, the user will be redirected to this URI after
// authorization
NextUri param.Field[string] `json:"next_uri"`
// Optional: if not provided, any version is used
ToolVersion param.Field[string] `json:"tool_version"`
// Required only when calling with an API key
UserID param.Field[string] `json:"user_id"`
}
func (r AuthorizeToolRequestParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type ExecuteToolRequestParam struct {
ToolName param.Field[string] `json:"tool_name,required"`
// Whether to include the error stacktrace in the response. If not provided, the
// error stacktrace is not included.
IncludeErrorStacktrace param.Field[bool] `json:"include_error_stacktrace"`
// JSON input to the tool, if any
Input param.Field[map[string]interface{}] `json:"input"`
// The time at which the tool should be run (optional). If not provided, the tool
// is run immediately. Format ISO 8601: YYYY-MM-DDTHH:MM:SS
RunAt param.Field[string] `json:"run_at"`
// The tool version to use (optional). If not provided, any version is used
ToolVersion param.Field[string] `json:"tool_version"`
UserID param.Field[string] `json:"user_id"`
}
func (r ExecuteToolRequestParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type ExecuteToolResponse struct {
ID string `json:"id"`
Duration float64 `json:"duration"`
ExecutionID string `json:"execution_id"`
ExecutionType string `json:"execution_type"`
FinishedAt string `json:"finished_at"`
Output ExecuteToolResponseOutput `json:"output"`
RunAt string `json:"run_at"`
Status string `json:"status"`
// Whether the request was successful. For immediately-executed requests, this will
// be true if the tool call succeeded. For scheduled requests, this will be true if
// the request was scheduled successfully.
Success bool `json:"success"`
JSON executeToolResponseJSON `json:"-"`
}
// executeToolResponseJSON contains the JSON metadata for the struct
// [ExecuteToolResponse]
type executeToolResponseJSON struct {
ID apijson.Field
Duration apijson.Field
ExecutionID apijson.Field
ExecutionType apijson.Field
FinishedAt apijson.Field
Output apijson.Field
RunAt apijson.Field
Status apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ExecuteToolResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r executeToolResponseJSON) RawJSON() string {
return r.raw
}
type ExecuteToolResponseOutput struct {
Authorization shared.AuthorizationResponse `json:"authorization"`
Error ExecuteToolResponseOutputError `json:"error"`
Logs []ExecuteToolResponseOutputLog `json:"logs"`
Value interface{} `json:"value"`
JSON executeToolResponseOutputJSON `json:"-"`
}
// executeToolResponseOutputJSON contains the JSON metadata for the struct
// [ExecuteToolResponseOutput]
type executeToolResponseOutputJSON struct {
Authorization apijson.Field
Error apijson.Field
Logs apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ExecuteToolResponseOutput) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r executeToolResponseOutputJSON) RawJSON() string {
return r.raw
}
type ExecuteToolResponseOutputError struct {
CanRetry bool `json:"can_retry,required"`
Kind ExecuteToolResponseOutputErrorKind `json:"kind,required"`
Message string `json:"message,required"`
AdditionalPromptContent string `json:"additional_prompt_content"`
DeveloperMessage string `json:"developer_message"`
Extra map[string]interface{} `json:"extra"`
RetryAfterMs int64 `json:"retry_after_ms"`
Stacktrace string `json:"stacktrace"`
StatusCode int64 `json:"status_code"`
JSON executeToolResponseOutputErrorJSON `json:"-"`
}
// executeToolResponseOutputErrorJSON contains the JSON metadata for the struct
// [ExecuteToolResponseOutputError]
type executeToolResponseOutputErrorJSON struct {
CanRetry apijson.Field
Kind apijson.Field
Message apijson.Field
AdditionalPromptContent apijson.Field
DeveloperMessage apijson.Field
Extra apijson.Field
RetryAfterMs apijson.Field
Stacktrace apijson.Field
StatusCode apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ExecuteToolResponseOutputError) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r executeToolResponseOutputErrorJSON) RawJSON() string {
return r.raw
}
type ExecuteToolResponseOutputErrorKind string
const (
ExecuteToolResponseOutputErrorKindToolkitLoadFailed ExecuteToolResponseOutputErrorKind = "TOOLKIT_LOAD_FAILED"
ExecuteToolResponseOutputErrorKindToolDefinitionBadDefinition ExecuteToolResponseOutputErrorKind = "TOOL_DEFINITION_BAD_DEFINITION"
ExecuteToolResponseOutputErrorKindToolDefinitionBadInputSchema ExecuteToolResponseOutputErrorKind = "TOOL_DEFINITION_BAD_INPUT_SCHEMA"
ExecuteToolResponseOutputErrorKindToolDefinitionBadOutputSchema ExecuteToolResponseOutputErrorKind = "TOOL_DEFINITION_BAD_OUTPUT_SCHEMA"
ExecuteToolResponseOutputErrorKindToolRequirementsNotMet ExecuteToolResponseOutputErrorKind = "TOOL_REQUIREMENTS_NOT_MET"
ExecuteToolResponseOutputErrorKindToolRuntimeBadInputValue ExecuteToolResponseOutputErrorKind = "TOOL_RUNTIME_BAD_INPUT_VALUE"
ExecuteToolResponseOutputErrorKindToolRuntimeBadOutputValue ExecuteToolResponseOutputErrorKind = "TOOL_RUNTIME_BAD_OUTPUT_VALUE"
ExecuteToolResponseOutputErrorKindToolRuntimeRetry ExecuteToolResponseOutputErrorKind = "TOOL_RUNTIME_RETRY"
ExecuteToolResponseOutputErrorKindToolRuntimeContextRequired ExecuteToolResponseOutputErrorKind = "TOOL_RUNTIME_CONTEXT_REQUIRED"
ExecuteToolResponseOutputErrorKindToolRuntimeFatal ExecuteToolResponseOutputErrorKind = "TOOL_RUNTIME_FATAL"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeBadRequest ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_BAD_REQUEST"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeAuthError ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_AUTH_ERROR"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeNotFound ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_NOT_FOUND"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeValidationError ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_VALIDATION_ERROR"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeRateLimit ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_RATE_LIMIT"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeServerError ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_SERVER_ERROR"
ExecuteToolResponseOutputErrorKindUpstreamRuntimeUnmapped ExecuteToolResponseOutputErrorKind = "UPSTREAM_RUNTIME_UNMAPPED"
ExecuteToolResponseOutputErrorKindUnknown ExecuteToolResponseOutputErrorKind = "UNKNOWN"
)
func (r ExecuteToolResponseOutputErrorKind) IsKnown() bool {
switch r {
case ExecuteToolResponseOutputErrorKindToolkitLoadFailed, ExecuteToolResponseOutputErrorKindToolDefinitionBadDefinition, ExecuteToolResponseOutputErrorKindToolDefinitionBadInputSchema, ExecuteToolResponseOutputErrorKindToolDefinitionBadOutputSchema, ExecuteToolResponseOutputErrorKindToolRequirementsNotMet, ExecuteToolResponseOutputErrorKindToolRuntimeBadInputValue, ExecuteToolResponseOutputErrorKindToolRuntimeBadOutputValue, ExecuteToolResponseOutputErrorKindToolRuntimeRetry, ExecuteToolResponseOutputErrorKindToolRuntimeContextRequired, ExecuteToolResponseOutputErrorKindToolRuntimeFatal, ExecuteToolResponseOutputErrorKindUpstreamRuntimeBadRequest, ExecuteToolResponseOutputErrorKindUpstreamRuntimeAuthError, ExecuteToolResponseOutputErrorKindUpstreamRuntimeNotFound, ExecuteToolResponseOutputErrorKindUpstreamRuntimeValidationError, ExecuteToolResponseOutputErrorKindUpstreamRuntimeRateLimit, ExecuteToolResponseOutputErrorKindUpstreamRuntimeServerError, ExecuteToolResponseOutputErrorKindUpstreamRuntimeUnmapped, ExecuteToolResponseOutputErrorKindUnknown:
return true
}
return false
}
type ExecuteToolResponseOutputLog struct {
Level string `json:"level,required"`
Message string `json:"message,required"`
Subtype string `json:"subtype"`
JSON executeToolResponseOutputLogJSON `json:"-"`
}
// executeToolResponseOutputLogJSON contains the JSON metadata for the struct
// [ExecuteToolResponseOutputLog]
type executeToolResponseOutputLogJSON struct {
Level apijson.Field
Message apijson.Field
Subtype apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ExecuteToolResponseOutputLog) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r executeToolResponseOutputLogJSON) RawJSON() string {
return r.raw
}
type ToolDefinition struct {
FullyQualifiedName string `json:"fully_qualified_name,required"`
Input ToolDefinitionInput `json:"input,required"`
Name string `json:"name,required"`
QualifiedName string `json:"qualified_name,required"`
Toolkit ToolDefinitionToolkit `json:"toolkit,required"`
Description string `json:"description"`
FormattedSchema map[string]interface{} `json:"formatted_schema"`
Output ToolDefinitionOutput `json:"output"`
Requirements ToolDefinitionRequirements `json:"requirements"`
JSON toolDefinitionJSON `json:"-"`
}
// toolDefinitionJSON contains the JSON metadata for the struct [ToolDefinition]
type toolDefinitionJSON struct {
FullyQualifiedName apijson.Field
Input apijson.Field
Name apijson.Field
QualifiedName apijson.Field
Toolkit apijson.Field
Description apijson.Field
FormattedSchema apijson.Field
Output apijson.Field
Requirements apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinition) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionInput struct {
Parameters []ToolDefinitionInputParameter `json:"parameters"`
JSON toolDefinitionInputJSON `json:"-"`
}
// toolDefinitionInputJSON contains the JSON metadata for the struct
// [ToolDefinitionInput]
type toolDefinitionInputJSON struct {
Parameters apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionInput) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionInputJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionInputParameter struct {
Name string `json:"name,required"`
ValueSchema ValueSchema `json:"value_schema,required"`
Description string `json:"description"`
Inferrable bool `json:"inferrable"`
Required bool `json:"required"`
JSON toolDefinitionInputParameterJSON `json:"-"`
}
// toolDefinitionInputParameterJSON contains the JSON metadata for the struct
// [ToolDefinitionInputParameter]
type toolDefinitionInputParameterJSON struct {
Name apijson.Field
ValueSchema apijson.Field
Description apijson.Field
Inferrable apijson.Field
Required apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionInputParameter) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionInputParameterJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionToolkit struct {
Name string `json:"name,required"`
Description string `json:"description"`
Version string `json:"version"`
JSON toolDefinitionToolkitJSON `json:"-"`
}
// toolDefinitionToolkitJSON contains the JSON metadata for the struct
// [ToolDefinitionToolkit]
type toolDefinitionToolkitJSON struct {
Name apijson.Field
Description apijson.Field
Version apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionToolkit) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionToolkitJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionOutput struct {
AvailableModes []string `json:"available_modes"`
Description string `json:"description"`
ValueSchema ValueSchema `json:"value_schema"`
JSON toolDefinitionOutputJSON `json:"-"`
}
// toolDefinitionOutputJSON contains the JSON metadata for the struct
// [ToolDefinitionOutput]
type toolDefinitionOutputJSON struct {
AvailableModes apijson.Field
Description apijson.Field
ValueSchema apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionOutput) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionOutputJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionRequirements struct {
Authorization ToolDefinitionRequirementsAuthorization `json:"authorization"`
Met bool `json:"met"`
Secrets []ToolDefinitionRequirementsSecret `json:"secrets"`
JSON toolDefinitionRequirementsJSON `json:"-"`
}
// toolDefinitionRequirementsJSON contains the JSON metadata for the struct
// [ToolDefinitionRequirements]
type toolDefinitionRequirementsJSON struct {
Authorization apijson.Field
Met apijson.Field
Secrets apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionRequirements) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionRequirementsJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionRequirementsAuthorization struct {
ID string `json:"id"`
Oauth2 ToolDefinitionRequirementsAuthorizationOauth2 `json:"oauth2"`
ProviderID string `json:"provider_id"`
ProviderType string `json:"provider_type"`
Status ToolDefinitionRequirementsAuthorizationStatus `json:"status"`
StatusReason string `json:"status_reason"`
TokenStatus ToolDefinitionRequirementsAuthorizationTokenStatus `json:"token_status"`
JSON toolDefinitionRequirementsAuthorizationJSON `json:"-"`
}
// toolDefinitionRequirementsAuthorizationJSON contains the JSON metadata for the
// struct [ToolDefinitionRequirementsAuthorization]
type toolDefinitionRequirementsAuthorizationJSON struct {
ID apijson.Field
Oauth2 apijson.Field
ProviderID apijson.Field
ProviderType apijson.Field
Status apijson.Field
StatusReason apijson.Field
TokenStatus apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionRequirementsAuthorization) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionRequirementsAuthorizationJSON) RawJSON() string {
return r.raw
}
type ToolDefinitionRequirementsAuthorizationOauth2 struct {
Scopes []string `json:"scopes"`
JSON toolDefinitionRequirementsAuthorizationOauth2JSON `json:"-"`
}
// toolDefinitionRequirementsAuthorizationOauth2JSON contains the JSON metadata for
// the struct [ToolDefinitionRequirementsAuthorizationOauth2]
type toolDefinitionRequirementsAuthorizationOauth2JSON struct {
Scopes apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionRequirementsAuthorizationOauth2) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionRequirementsAuthorizationOauth2JSON) RawJSON() string {
return r.raw
}
type ToolDefinitionRequirementsAuthorizationStatus string
const (
ToolDefinitionRequirementsAuthorizationStatusActive ToolDefinitionRequirementsAuthorizationStatus = "active"
ToolDefinitionRequirementsAuthorizationStatusInactive ToolDefinitionRequirementsAuthorizationStatus = "inactive"
)
func (r ToolDefinitionRequirementsAuthorizationStatus) IsKnown() bool {
switch r {
case ToolDefinitionRequirementsAuthorizationStatusActive, ToolDefinitionRequirementsAuthorizationStatusInactive:
return true
}
return false
}
type ToolDefinitionRequirementsAuthorizationTokenStatus string
const (
ToolDefinitionRequirementsAuthorizationTokenStatusNotStarted ToolDefinitionRequirementsAuthorizationTokenStatus = "not_started"
ToolDefinitionRequirementsAuthorizationTokenStatusPending ToolDefinitionRequirementsAuthorizationTokenStatus = "pending"
ToolDefinitionRequirementsAuthorizationTokenStatusCompleted ToolDefinitionRequirementsAuthorizationTokenStatus = "completed"
ToolDefinitionRequirementsAuthorizationTokenStatusFailed ToolDefinitionRequirementsAuthorizationTokenStatus = "failed"
)
func (r ToolDefinitionRequirementsAuthorizationTokenStatus) IsKnown() bool {
switch r {
case ToolDefinitionRequirementsAuthorizationTokenStatusNotStarted, ToolDefinitionRequirementsAuthorizationTokenStatusPending, ToolDefinitionRequirementsAuthorizationTokenStatusCompleted, ToolDefinitionRequirementsAuthorizationTokenStatusFailed:
return true
}
return false
}
type ToolDefinitionRequirementsSecret struct {
Key string `json:"key,required"`
Met bool `json:"met"`
StatusReason string `json:"status_reason"`
JSON toolDefinitionRequirementsSecretJSON `json:"-"`
}
// toolDefinitionRequirementsSecretJSON contains the JSON metadata for the struct
// [ToolDefinitionRequirementsSecret]
type toolDefinitionRequirementsSecretJSON struct {
Key apijson.Field
Met apijson.Field
StatusReason apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolDefinitionRequirementsSecret) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolDefinitionRequirementsSecretJSON) RawJSON() string {
return r.raw
}
type ToolExecution struct {
ID string `json:"id"`
CreatedAt string `json:"created_at"`
ExecutionStatus string `json:"execution_status"`
ExecutionType string `json:"execution_type"`
FinishedAt string `json:"finished_at"`
RunAt string `json:"run_at"`
StartedAt string `json:"started_at"`
ToolName string `json:"tool_name"`
ToolkitName string `json:"toolkit_name"`
ToolkitVersion string `json:"toolkit_version"`
UpdatedAt string `json:"updated_at"`
UserID string `json:"user_id"`
JSON toolExecutionJSON `json:"-"`
}
// toolExecutionJSON contains the JSON metadata for the struct [ToolExecution]
type toolExecutionJSON struct {
ID apijson.Field
CreatedAt apijson.Field
ExecutionStatus apijson.Field
ExecutionType apijson.Field
FinishedAt apijson.Field
RunAt apijson.Field
StartedAt apijson.Field
ToolName apijson.Field
ToolkitName apijson.Field
ToolkitVersion apijson.Field
UpdatedAt apijson.Field
UserID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolExecution) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolExecutionJSON) RawJSON() string {
return r.raw
}
type ToolExecutionAttempt struct {
ID string `json:"id"`
FinishedAt string `json:"finished_at"`
Output ToolExecutionAttemptOutput `json:"output"`
StartedAt string `json:"started_at"`
Success bool `json:"success"`
SystemErrorMessage string `json:"system_error_message"`
JSON toolExecutionAttemptJSON `json:"-"`
}
// toolExecutionAttemptJSON contains the JSON metadata for the struct
// [ToolExecutionAttempt]
type toolExecutionAttemptJSON struct {
ID apijson.Field
FinishedAt apijson.Field
Output apijson.Field
StartedAt apijson.Field
Success apijson.Field
SystemErrorMessage apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolExecutionAttempt) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolExecutionAttemptJSON) RawJSON() string {
return r.raw
}
type ToolExecutionAttemptOutput struct {
Authorization shared.AuthorizationResponse `json:"authorization"`
Error ToolExecutionAttemptOutputError `json:"error"`
Logs []ToolExecutionAttemptOutputLog `json:"logs"`
Value interface{} `json:"value"`
JSON toolExecutionAttemptOutputJSON `json:"-"`
}
// toolExecutionAttemptOutputJSON contains the JSON metadata for the struct
// [ToolExecutionAttemptOutput]
type toolExecutionAttemptOutputJSON struct {
Authorization apijson.Field
Error apijson.Field
Logs apijson.Field
Value apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolExecutionAttemptOutput) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolExecutionAttemptOutputJSON) RawJSON() string {
return r.raw
}
type ToolExecutionAttemptOutputError struct {
CanRetry bool `json:"can_retry,required"`
Kind ToolExecutionAttemptOutputErrorKind `json:"kind,required"`
Message string `json:"message,required"`
AdditionalPromptContent string `json:"additional_prompt_content"`
DeveloperMessage string `json:"developer_message"`
Extra map[string]interface{} `json:"extra"`
RetryAfterMs int64 `json:"retry_after_ms"`
Stacktrace string `json:"stacktrace"`
StatusCode int64 `json:"status_code"`
JSON toolExecutionAttemptOutputErrorJSON `json:"-"`
}
// toolExecutionAttemptOutputErrorJSON contains the JSON metadata for the struct
// [ToolExecutionAttemptOutputError]
type toolExecutionAttemptOutputErrorJSON struct {
CanRetry apijson.Field
Kind apijson.Field
Message apijson.Field
AdditionalPromptContent apijson.Field
DeveloperMessage apijson.Field
Extra apijson.Field
RetryAfterMs apijson.Field
Stacktrace apijson.Field
StatusCode apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolExecutionAttemptOutputError) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolExecutionAttemptOutputErrorJSON) RawJSON() string {
return r.raw
}
type ToolExecutionAttemptOutputErrorKind string
const (
ToolExecutionAttemptOutputErrorKindToolkitLoadFailed ToolExecutionAttemptOutputErrorKind = "TOOLKIT_LOAD_FAILED"
ToolExecutionAttemptOutputErrorKindToolDefinitionBadDefinition ToolExecutionAttemptOutputErrorKind = "TOOL_DEFINITION_BAD_DEFINITION"
ToolExecutionAttemptOutputErrorKindToolDefinitionBadInputSchema ToolExecutionAttemptOutputErrorKind = "TOOL_DEFINITION_BAD_INPUT_SCHEMA"
ToolExecutionAttemptOutputErrorKindToolDefinitionBadOutputSchema ToolExecutionAttemptOutputErrorKind = "TOOL_DEFINITION_BAD_OUTPUT_SCHEMA"
ToolExecutionAttemptOutputErrorKindToolRequirementsNotMet ToolExecutionAttemptOutputErrorKind = "TOOL_REQUIREMENTS_NOT_MET"
ToolExecutionAttemptOutputErrorKindToolRuntimeBadInputValue ToolExecutionAttemptOutputErrorKind = "TOOL_RUNTIME_BAD_INPUT_VALUE"
ToolExecutionAttemptOutputErrorKindToolRuntimeBadOutputValue ToolExecutionAttemptOutputErrorKind = "TOOL_RUNTIME_BAD_OUTPUT_VALUE"
ToolExecutionAttemptOutputErrorKindToolRuntimeRetry ToolExecutionAttemptOutputErrorKind = "TOOL_RUNTIME_RETRY"
ToolExecutionAttemptOutputErrorKindToolRuntimeContextRequired ToolExecutionAttemptOutputErrorKind = "TOOL_RUNTIME_CONTEXT_REQUIRED"
ToolExecutionAttemptOutputErrorKindToolRuntimeFatal ToolExecutionAttemptOutputErrorKind = "TOOL_RUNTIME_FATAL"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeBadRequest ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_BAD_REQUEST"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeAuthError ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_AUTH_ERROR"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeNotFound ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_NOT_FOUND"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeValidationError ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_VALIDATION_ERROR"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeRateLimit ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_RATE_LIMIT"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeServerError ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_SERVER_ERROR"
ToolExecutionAttemptOutputErrorKindUpstreamRuntimeUnmapped ToolExecutionAttemptOutputErrorKind = "UPSTREAM_RUNTIME_UNMAPPED"
ToolExecutionAttemptOutputErrorKindUnknown ToolExecutionAttemptOutputErrorKind = "UNKNOWN"
)
func (r ToolExecutionAttemptOutputErrorKind) IsKnown() bool {
switch r {
case ToolExecutionAttemptOutputErrorKindToolkitLoadFailed, ToolExecutionAttemptOutputErrorKindToolDefinitionBadDefinition, ToolExecutionAttemptOutputErrorKindToolDefinitionBadInputSchema, ToolExecutionAttemptOutputErrorKindToolDefinitionBadOutputSchema, ToolExecutionAttemptOutputErrorKindToolRequirementsNotMet, ToolExecutionAttemptOutputErrorKindToolRuntimeBadInputValue, ToolExecutionAttemptOutputErrorKindToolRuntimeBadOutputValue, ToolExecutionAttemptOutputErrorKindToolRuntimeRetry, ToolExecutionAttemptOutputErrorKindToolRuntimeContextRequired, ToolExecutionAttemptOutputErrorKindToolRuntimeFatal, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeBadRequest, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeAuthError, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeNotFound, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeValidationError, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeRateLimit, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeServerError, ToolExecutionAttemptOutputErrorKindUpstreamRuntimeUnmapped, ToolExecutionAttemptOutputErrorKindUnknown:
return true
}
return false
}
type ToolExecutionAttemptOutputLog struct {
Level string `json:"level,required"`
Message string `json:"message,required"`
Subtype string `json:"subtype"`
JSON toolExecutionAttemptOutputLogJSON `json:"-"`
}
// toolExecutionAttemptOutputLogJSON contains the JSON metadata for the struct
// [ToolExecutionAttemptOutputLog]
type toolExecutionAttemptOutputLogJSON struct {
Level apijson.Field
Message apijson.Field
Subtype apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ToolExecutionAttemptOutputLog) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r toolExecutionAttemptOutputLogJSON) RawJSON() string {
return r.raw
}
type ValueSchema struct {
ValType string `json:"val_type,required"`
Enum []string `json:"enum"`
InnerValType string `json:"inner_val_type"`
JSON valueSchemaJSON `json:"-"`
}
// valueSchemaJSON contains the JSON metadata for the struct [ValueSchema]
type valueSchemaJSON struct {
ValType apijson.Field
Enum apijson.Field
InnerValType apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ValueSchema) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r valueSchemaJSON) RawJSON() string {
return r.raw
}
type ToolListParams struct {
// Comma separated tool formats that will be included in the response.
IncludeFormat param.Field[[]ToolListParamsIncludeFormat] `query:"include_format"`
// Number of items to return (default: 25, max: 100)
Limit param.Field[int64] `query:"limit"`
// Offset from the start of the list (default: 0)
Offset param.Field[int64] `query:"offset"`
// Toolkit name
Toolkit param.Field[string] `query:"toolkit"`
// User ID
UserID param.Field[string] `query:"user_id"`
}
// URLQuery serializes [ToolListParams]'s query parameters as `url.Values`.
func (r ToolListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type ToolListParamsIncludeFormat string
const (
ToolListParamsIncludeFormatArcade ToolListParamsIncludeFormat = "arcade"
ToolListParamsIncludeFormatOpenAI ToolListParamsIncludeFormat = "openai"
ToolListParamsIncludeFormatAnthropic ToolListParamsIncludeFormat = "anthropic"
)
func (r ToolListParamsIncludeFormat) IsKnown() bool {
switch r {
case ToolListParamsIncludeFormatArcade, ToolListParamsIncludeFormatOpenAI, ToolListParamsIncludeFormatAnthropic:
return true
}
return false
}
type ToolAuthorizeParams struct {
AuthorizeToolRequest AuthorizeToolRequestParam `json:"authorize_tool_request,required"`
}
func (r ToolAuthorizeParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.AuthorizeToolRequest)
}
type ToolExecuteParams struct {
ExecuteToolRequest ExecuteToolRequestParam `json:"execute_tool_request,required"`
}
func (r ToolExecuteParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r.ExecuteToolRequest)
}
type ToolGetParams struct {
// Comma separated tool formats that will be included in the response.
IncludeFormat param.Field[[]ToolGetParamsIncludeFormat] `query:"include_format"`
// User ID
UserID param.Field[string] `query:"user_id"`
}
// URLQuery serializes [ToolGetParams]'s query parameters as `url.Values`.
func (r ToolGetParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
type ToolGetParamsIncludeFormat string
const (
ToolGetParamsIncludeFormatArcade ToolGetParamsIncludeFormat = "arcade"
ToolGetParamsIncludeFormatOpenAI ToolGetParamsIncludeFormat = "openai"
ToolGetParamsIncludeFormatAnthropic ToolGetParamsIncludeFormat = "anthropic"
)
func (r ToolGetParamsIncludeFormat) IsKnown() bool {
switch r {
case ToolGetParamsIncludeFormatArcade, ToolGetParamsIncludeFormatOpenAI, ToolGetParamsIncludeFormatAnthropic:
return true
}
return false
}