You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -35,161 +35,197 @@ var SafeTools = map[string]struct{}{
35
35
36
36
vartools=map[string]types.Tool{
37
37
"sys.time.now": {
38
-
Parameters: types.Parameters{
39
-
Description: "Returns the current date and time in RFC3339 format",
38
+
ToolDef: types.ToolDef{
39
+
Parameters: types.Parameters{
40
+
Description: "Returns the current date and time in RFC3339 format",
41
+
},
42
+
BuiltinFunc: SysTimeNow,
40
43
},
41
-
BuiltinFunc: SysTimeNow,
42
44
},
43
45
"sys.ls": {
44
-
Parameters: types.Parameters{
45
-
Description: "Lists the contents of a directory",
46
-
Arguments: types.ObjectSchema(
47
-
"dir", "The directory to list"),
46
+
ToolDef: types.ToolDef{
47
+
Parameters: types.Parameters{
48
+
Description: "Lists the contents of a directory",
49
+
Arguments: types.ObjectSchema(
50
+
"dir", "The directory to list"),
51
+
},
52
+
BuiltinFunc: SysLs,
48
53
},
49
-
BuiltinFunc: SysLs,
50
54
},
51
55
"sys.read": {
52
-
Parameters: types.Parameters{
53
-
Description: "Reads the contents of a file",
54
-
Arguments: types.ObjectSchema(
55
-
"filename", "The name of the file to read"),
56
+
ToolDef: types.ToolDef{
57
+
Parameters: types.Parameters{
58
+
Description: "Reads the contents of a file",
59
+
Arguments: types.ObjectSchema(
60
+
"filename", "The name of the file to read"),
61
+
},
62
+
BuiltinFunc: SysRead,
56
63
},
57
-
BuiltinFunc: SysRead,
58
64
},
59
65
"sys.write": {
60
-
Parameters: types.Parameters{
61
-
Description: "Write the contents to a file",
62
-
Arguments: types.ObjectSchema(
63
-
"filename", "The name of the file to write to",
64
-
"content", "The content to write"),
66
+
ToolDef: types.ToolDef{
67
+
Parameters: types.Parameters{
68
+
Description: "Write the contents to a file",
69
+
Arguments: types.ObjectSchema(
70
+
"filename", "The name of the file to write to",
71
+
"content", "The content to write"),
72
+
},
73
+
BuiltinFunc: SysWrite,
65
74
},
66
-
BuiltinFunc: SysWrite,
67
75
},
68
76
"sys.append": {
69
-
Parameters: types.Parameters{
70
-
Description: "Appends the contents to a file",
71
-
Arguments: types.ObjectSchema(
72
-
"filename", "The name of the file to append to",
73
-
"content", "The content to append"),
77
+
ToolDef: types.ToolDef{
78
+
Parameters: types.Parameters{
79
+
Description: "Appends the contents to a file",
80
+
Arguments: types.ObjectSchema(
81
+
"filename", "The name of the file to append to",
82
+
"content", "The content to append"),
83
+
},
84
+
BuiltinFunc: SysAppend,
74
85
},
75
-
BuiltinFunc: SysAppend,
76
86
},
77
87
"sys.http.get": {
78
-
Parameters: types.Parameters{
79
-
Description: "Download the contents of a http or https URL",
80
-
Arguments: types.ObjectSchema(
81
-
"url", "The URL to download"),
88
+
ToolDef: types.ToolDef{
89
+
Parameters: types.Parameters{
90
+
Description: "Download the contents of a http or https URL",
91
+
Arguments: types.ObjectSchema(
92
+
"url", "The URL to download"),
93
+
},
94
+
BuiltinFunc: SysHTTPGet,
82
95
},
83
-
BuiltinFunc: SysHTTPGet,
84
96
},
85
97
"sys.http.html2text": {
86
-
Parameters: types.Parameters{
87
-
Description: "Download the contents of a http or https URL returning the content as rendered text converted from HTML",
88
-
Arguments: types.ObjectSchema(
89
-
"url", "The URL to download"),
98
+
ToolDef: types.ToolDef{
99
+
Parameters: types.Parameters{
100
+
Description: "Download the contents of a http or https URL returning the content as rendered text converted from HTML",
101
+
Arguments: types.ObjectSchema(
102
+
"url", "The URL to download"),
103
+
},
104
+
BuiltinFunc: SysHTTPHtml2Text,
90
105
},
91
-
BuiltinFunc: SysHTTPHtml2Text,
92
106
},
93
107
"sys.abort": {
94
-
Parameters: types.Parameters{
95
-
Description: "Aborts execution",
96
-
Arguments: types.ObjectSchema(
97
-
"message", "The description of the error or unexpected result that caused abort to be called",
98
-
),
108
+
ToolDef: types.ToolDef{
109
+
Parameters: types.Parameters{
110
+
Description: "Aborts execution",
111
+
Arguments: types.ObjectSchema(
112
+
"message", "The description of the error or unexpected result that caused abort to be called",
113
+
),
114
+
},
115
+
BuiltinFunc: SysAbort,
99
116
},
100
-
BuiltinFunc: SysAbort,
101
117
},
102
118
"sys.chat.finish": {
103
-
Parameters: types.Parameters{
104
-
Description: "Concludes the conversation. This can not be used to ask a question.",
105
-
Arguments: types.ObjectSchema(
106
-
"return", "The instructed value to return or a summary of the dialog if no value is instructed",
107
-
),
119
+
ToolDef: types.ToolDef{
120
+
Parameters: types.Parameters{
121
+
Description: "Concludes the conversation. This can not be used to ask a question.",
122
+
Arguments: types.ObjectSchema(
123
+
"return", "The instructed value to return or a summary of the dialog if no value is instructed",
124
+
),
125
+
},
126
+
BuiltinFunc: SysChatFinish,
108
127
},
109
-
BuiltinFunc: SysChatFinish,
110
128
},
111
129
"sys.http.post": {
112
-
Parameters: types.Parameters{
113
-
Description: "Write contents to a http or https URL using the POST method",
114
-
Arguments: types.ObjectSchema(
115
-
"url", "The URL to POST to",
116
-
"content", "The content to POST",
117
-
"contentType", "The \"content type\" of the content such as application/json or text/plain"),
130
+
ToolDef: types.ToolDef{
131
+
Parameters: types.Parameters{
132
+
Description: "Write contents to a http or https URL using the POST method",
133
+
Arguments: types.ObjectSchema(
134
+
"url", "The URL to POST to",
135
+
"content", "The content to POST",
136
+
"contentType", "The \"content type\" of the content such as application/json or text/plain"),
137
+
},
138
+
BuiltinFunc: SysHTTPPost,
118
139
},
119
-
BuiltinFunc: SysHTTPPost,
120
140
},
121
141
"sys.find": {
122
-
Parameters: types.Parameters{
123
-
Description: "Traverse a directory looking for files that match a pattern in the style of the unix find command",
124
-
Arguments: types.ObjectSchema(
125
-
"pattern", "The file pattern to look for. The pattern is a traditional unix glob format with * matching any character and ? matching a single character",
126
-
"directory", "The directory to search in. The current directory \".\" will be used as the default if no argument is passed",
127
-
),
142
+
ToolDef: types.ToolDef{
143
+
Parameters: types.Parameters{
144
+
Description: "Traverse a directory looking for files that match a pattern in the style of the unix find command",
145
+
Arguments: types.ObjectSchema(
146
+
"pattern", "The file pattern to look for. The pattern is a traditional unix glob format with * matching any character and ? matching a single character",
147
+
"directory", "The directory to search in. The current directory \".\" will be used as the default if no argument is passed",
148
+
),
149
+
},
150
+
BuiltinFunc: SysFind,
128
151
},
129
-
BuiltinFunc: SysFind,
130
152
},
131
153
"sys.exec": {
132
-
Parameters: types.Parameters{
133
-
Description: "Execute a command and get the output of the command",
134
-
Arguments: types.ObjectSchema(
135
-
"command", "The command to run including all applicable arguments",
136
-
"directory", "The directory to use as the current working directory of the command. The current directory \".\" will be used if no argument is passed",
137
-
),
154
+
ToolDef: types.ToolDef{
155
+
Parameters: types.Parameters{
156
+
Description: "Execute a command and get the output of the command",
157
+
Arguments: types.ObjectSchema(
158
+
"command", "The command to run including all applicable arguments",
159
+
"directory", "The directory to use as the current working directory of the command. The current directory \".\" will be used if no argument is passed",
160
+
),
161
+
},
162
+
BuiltinFunc: SysExec,
138
163
},
139
-
BuiltinFunc: SysExec,
140
164
},
141
165
"sys.getenv": {
142
-
Parameters: types.Parameters{
143
-
Description: "Gets the value of an OS environment variable",
144
-
Arguments: types.ObjectSchema(
145
-
"name", "The environment variable name to lookup"),
166
+
ToolDef: types.ToolDef{
167
+
Parameters: types.Parameters{
168
+
Description: "Gets the value of an OS environment variable",
169
+
Arguments: types.ObjectSchema(
170
+
"name", "The environment variable name to lookup"),
171
+
},
172
+
BuiltinFunc: SysGetenv,
146
173
},
147
-
BuiltinFunc: SysGetenv,
148
174
},
149
175
"sys.download": {
150
-
Parameters: types.Parameters{
151
-
Description: "Downloads a URL, saving the contents to disk at a given location",
152
-
Arguments: types.ObjectSchema(
153
-
"url", "The URL to download, either http or https.",
154
-
"location", "(optional) The on disk location to store the file. If no location is specified a temp location will be used. If the target file already exists it will fail unless override is set to true.",
155
-
"override", "If true and a file at the location exists, the file will be overwritten, otherwise fail. Default is false"),
176
+
ToolDef: types.ToolDef{
177
+
Parameters: types.Parameters{
178
+
Description: "Downloads a URL, saving the contents to disk at a given location",
179
+
Arguments: types.ObjectSchema(
180
+
"url", "The URL to download, either http or https.",
181
+
"location", "(optional) The on disk location to store the file. If no location is specified a temp location will be used. If the target file already exists it will fail unless override is set to true.",
182
+
"override", "If true and a file at the location exists, the file will be overwritten, otherwise fail. Default is false"),
183
+
},
184
+
BuiltinFunc: SysDownload,
156
185
},
157
-
BuiltinFunc: SysDownload,
158
186
},
159
187
"sys.remove": {
160
-
Parameters: types.Parameters{
161
-
Description: "Removes the specified files",
162
-
Arguments: types.ObjectSchema(
163
-
"location", "The file to remove"),
188
+
ToolDef: types.ToolDef{
189
+
Parameters: types.Parameters{
190
+
Description: "Removes the specified files",
191
+
Arguments: types.ObjectSchema(
192
+
"location", "The file to remove"),
193
+
},
194
+
BuiltinFunc: SysRemove,
164
195
},
165
-
BuiltinFunc: SysRemove,
166
196
},
167
197
"sys.stat": {
168
-
Parameters: types.Parameters{
169
-
Description: "Gets size, modfied time, and mode of the specified file",
170
-
Arguments: types.ObjectSchema(
171
-
"filepath", "The complete path and filename of the file",
172
-
),
198
+
ToolDef: types.ToolDef{
199
+
Parameters: types.Parameters{
200
+
Description: "Gets size, modfied time, and mode of the specified file",
201
+
Arguments: types.ObjectSchema(
202
+
"filepath", "The complete path and filename of the file",
203
+
),
204
+
},
205
+
BuiltinFunc: SysStat,
173
206
},
174
-
BuiltinFunc: SysStat,
175
207
},
176
208
"sys.prompt": {
177
-
Parameters: types.Parameters{
178
-
Description: "Prompts the user for input",
179
-
Arguments: types.ObjectSchema(
180
-
"message", "The message to display to the user",
181
-
"fields", "A comma-separated list of fields to prompt for",
182
-
"sensitive", "(true or false) Whether the input should be hidden",
183
-
),
209
+
ToolDef: types.ToolDef{
210
+
Parameters: types.Parameters{
211
+
Description: "Prompts the user for input",
212
+
Arguments: types.ObjectSchema(
213
+
"message", "The message to display to the user",
214
+
"fields", "A comma-separated list of fields to prompt for",
215
+
"sensitive", "(true or false) Whether the input should be hidden",
216
+
),
217
+
},
218
+
BuiltinFunc: SysPrompt,
184
219
},
185
-
BuiltinFunc: SysPrompt,
186
220
},
187
221
"sys.chat.history": {
188
-
Parameters: types.Parameters{
189
-
Description: "Retrieves the previous chat dialog",
190
-
Arguments: types.ObjectSchema(),
222
+
ToolDef: types.ToolDef{
223
+
Parameters: types.Parameters{
224
+
Description: "Retrieves the previous chat dialog",
0 commit comments