diff --git a/go.mod b/go.mod index fc68968e..96deab9a 100644 --- a/go.mod +++ b/go.mod @@ -7,17 +7,18 @@ require ( github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 github.com/adrg/xdg v0.4.0 github.com/chzyer/readline v1.5.1 + github.com/danielgtaylor/huma/v2 v2.32.0 github.com/docker/cli v26.0.0+incompatible github.com/docker/docker-credential-helpers v0.8.1 github.com/fatih/color v1.17.0 - github.com/getkin/kin-openapi v0.124.0 + github.com/getkin/kin-openapi v0.132.0 github.com/go-git/go-git/v5 v5.12.0 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/uuid v1.6.0 github.com/gptscript-ai/broadcaster v0.0.0-20240625175512-c43682019b86 github.com/gptscript-ai/chat-completion-client v0.0.0-20250224164718-139cb4507b1d github.com/gptscript-ai/cmd v0.0.0-20240802230653-326b7baf6fcb - github.com/gptscript-ai/go-gptscript v0.9.6-0.20250204133419-744b25b84a61 + github.com/gptscript-ai/go-gptscript v0.9.6-0.20250520154649-f1616a06f1b0 github.com/gptscript-ai/tui v0.0.0-20250419050840-5e79e16786c9 github.com/hexops/autogold/v2 v2.2.1 github.com/hexops/valast v1.4.4 @@ -29,14 +30,14 @@ require ( github.com/rs/cors v1.11.0 github.com/samber/lo v1.38.1 github.com/sirupsen/logrus v1.9.3 - github.com/spf13/cobra v1.8.0 + github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/tidwall/gjson v1.17.1 github.com/xeipuuv/gojsonschema v1.2.0 golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc - golang.org/x/sync v0.9.0 - golang.org/x/term v0.22.0 + golang.org/x/sync v0.10.0 + golang.org/x/term v0.27.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/v3 v3.5.1 sigs.k8s.io/yaml v1.4.0 @@ -62,7 +63,7 @@ require ( github.com/charmbracelet/x/ansi v0.1.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/console v1.0.4 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.10.0 // indirect @@ -70,8 +71,8 @@ require ( github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect - github.com/go-openapi/jsonpointer v0.20.2 // indirect - github.com/go-openapi/swag v0.22.8 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/gookit/color v1.5.4 // indirect @@ -82,7 +83,6 @@ require ( github.com/hexops/autogold v1.3.1 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/invopop/yaml v0.2.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect @@ -94,7 +94,7 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect github.com/microcosm-cc/bluemonday v1.0.26 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect @@ -102,6 +102,8 @@ require ( github.com/muesli/termenv v0.15.2 // indirect github.com/nightlyone/lockfile v1.0.0 // indirect github.com/nwaples/rardecode/v2 v2.0.0-beta.4.0.20241112120701-034e449c6e78 // indirect + github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect + github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect github.com/olekukonko/tablewriter v0.0.6-0.20230925090304-df64c4bbad77 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect @@ -128,11 +130,11 @@ require ( github.com/yuin/goldmark v1.5.4 // indirect github.com/yuin/goldmark-emoji v1.0.2 // indirect go4.org v0.0.0-20230225012048-214862532bf5 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/mod v0.19.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.20.0 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.23.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect mvdan.cc/gofumpt v0.6.0 // indirect diff --git a/go.sum b/go.sum index 7ce2cd38..02c068cc 100644 --- a/go.sum +++ b/go.sum @@ -98,13 +98,15 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro= github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/danielgtaylor/huma/v2 v2.32.0 h1:ytU9ExG/axC434+soXxwNzv0uaxOb3cyCgjj8y3PmBE= +github.com/danielgtaylor/huma/v2 v2.32.0/go.mod h1:9BxJwkeoPPDEJ2Bg4yPwL1mM1rYpAwCAWFKoo723spk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -131,8 +133,8 @@ github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUork github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= -github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= +github.com/getkin/kin-openapi v0.132.0 h1:3ISeLMsQzcb5v26yeJrBcdTCEQTag36ZjaGk7MIRUwk= +github.com/getkin/kin-openapi v0.132.0/go.mod h1:3OlG51PCYNsPByuiMB0t4fjnNlIDnaEDsjiKUV8nL58= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -145,10 +147,10 @@ github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZt github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= -github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= -github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= -github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -201,8 +203,8 @@ github.com/gptscript-ai/chat-completion-client v0.0.0-20250224164718-139cb4507b1 github.com/gptscript-ai/chat-completion-client v0.0.0-20250224164718-139cb4507b1d/go.mod h1:7P/o6/IWa1KqsntVf68hSnLKuu3+xuqm6lYhch1w4jo= github.com/gptscript-ai/cmd v0.0.0-20240802230653-326b7baf6fcb h1:ky2J2CzBOskC7Jgm2VJAQi2x3p7FVGa+2/PcywkFJuc= github.com/gptscript-ai/cmd v0.0.0-20240802230653-326b7baf6fcb/go.mod h1:DJAo1xTht1LDkNYFNydVjTHd576TC7MlpsVRl3oloVw= -github.com/gptscript-ai/go-gptscript v0.9.6-0.20250204133419-744b25b84a61 h1:QxLjsLOYlsVLPwuRkP0Q8EcAoZT1s8vU2ZBSX0+R6CI= -github.com/gptscript-ai/go-gptscript v0.9.6-0.20250204133419-744b25b84a61/go.mod h1:/FVuLwhz+sIfsWUgUHWKi32qT0i6+IXlUlzs70KKt/Q= +github.com/gptscript-ai/go-gptscript v0.9.6-0.20250520154649-f1616a06f1b0 h1:UXZRFAUPDWOgeTyjZd4M8YrEEgPc7XOfjgbm81w7x0w= +github.com/gptscript-ai/go-gptscript v0.9.6-0.20250520154649-f1616a06f1b0/go.mod h1:t2TyiEa6rhd4reOcorAMUmd5MledmZuTmYrO7rV3Iy8= github.com/gptscript-ai/tui v0.0.0-20250419050840-5e79e16786c9 h1:wQC8sKyeGA50WnCEG+Jo5FNRIkuX3HX8d3ubyWCCoI8= github.com/gptscript-ai/tui v0.0.0-20250419050840-5e79e16786c9/go.mod h1:iwHxuueg2paOak7zIg0ESBWx7A0wIHGopAratbgaPNY= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -229,8 +231,6 @@ github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4Dvx github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= -github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056 h1:iCHtR9CQyktQ5+f3dMVZfwD2KWJUgm7M0gdL9NGr8KA= github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -252,8 +252,8 @@ github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgo github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= -github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU= -github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -287,8 +287,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mholt/archives v0.1.0 h1:FacgJyrjiuyomTuNA92X5GyRBRZjE43Y/lrzKIlF35Q= @@ -305,6 +305,10 @@ github.com/nightlyone/lockfile v1.0.0 h1:RHep2cFKK4PonZJDdEl4GmkabuhbsRMgk/k3uAm github.com/nightlyone/lockfile v1.0.0/go.mod h1:rywoIealpdNse2r832aiD9jRk8ErCatROs6LzC841CI= github.com/nwaples/rardecode/v2 v2.0.0-beta.4.0.20241112120701-034e449c6e78 h1:MYzLheyVx1tJVDqfu3YnN4jtnyALNzLvwl+f58TcvQY= github.com/nwaples/rardecode/v2 v2.0.0-beta.4.0.20241112120701-034e449c6e78/go.mod h1:yntwv/HfMc/Hbvtq9I19D1n58te3h6KsqCf3GxyfBGY= +github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY= +github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw= +github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c= +github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o= github.com/olekukonko/tablewriter v0.0.6-0.20230925090304-df64c4bbad77 h1:3bMMZ1f+GPXFQ1uNaYbO/uECWvSfqEA+ZEXn1rFAT88= github.com/olekukonko/tablewriter v0.0.6-0.20230925090304-df64c4bbad77/go.mod h1:8Hf+pH6thup1sPZPD+NLg7d6vbpsdilu9CPIeikvgMQ= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= @@ -365,8 +369,8 @@ github.com/sourcegraph/go-diff-patch v0.0.0-20240223163233-798fd1e94a8e h1:H+jDT github.com/sourcegraph/go-diff-patch v0.0.0-20240223163233-798fd1e94a8e/go.mod h1:VsUklG6OQo7Ctunu0gS3AtEOCEc2kMB6r5rKzxAes58= github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo= @@ -382,8 +386,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw= github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY= github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= @@ -392,8 +396,8 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= -github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= @@ -433,8 +437,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -493,8 +497,8 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -510,8 +514,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -551,8 +555,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -564,8 +568,8 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -579,8 +583,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -663,7 +667,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/pkg/loader/openapi.go b/pkg/loader/openapi.go index 3ab564e5..ef61adfb 100644 --- a/pkg/loader/openapi.go +++ b/pkg/loader/openapi.go @@ -11,6 +11,7 @@ import ( "strings" "time" + humav2 "github.com/danielgtaylor/huma/v2" "github.com/getkin/kin-openapi/openapi3" "github.com/gptscript-ai/gptscript/pkg/openapi" "github.com/gptscript-ai/gptscript/pkg/types" @@ -150,10 +151,9 @@ func getOpenAPITools(t *openapi3.T, defaultHost, source, targetToolName string) Parameters: types.Parameters{ Name: toolName, Description: toolDesc, - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{}, - Required: []string{}, + Arguments: &humav2.Schema{ + Type: humav2.TypeObject, + Properties: make(map[string]*humav2.Schema), }, }, }, @@ -174,7 +174,7 @@ func getOpenAPITools(t *openapi3.T, defaultHost, source, targetToolName string) } // Add the new arg to the tool's arguments - tool.Arguments.Properties[param.Value.Name] = &openapi3.SchemaRef{Value: arg} + tool.Arguments.Properties[param.Value.Name] = openAPI3SchemaToHumaV2Schema(arg) // Check whether it is required if param.Value.Required { @@ -227,7 +227,7 @@ func getOpenAPITools(t *openapi3.T, defaultHost, source, targetToolName string) } // Unfortunately, the request body doesn't contain any good descriptor for it, // so we just use "requestBodyContent" as the name of the arg. - tool.Arguments.Properties["requestBodyContent"] = &openapi3.SchemaRef{Value: arg} + tool.Arguments.Properties["requestBodyContent"] = openAPI3SchemaToHumaV2Schema(arg) break } @@ -373,6 +373,147 @@ func parseServer(server *openapi3.Server) (string, error) { return s, nil } +// openAPI3SchemaToHumaV2Schema converts an openapi3.Schema to a humav2.Schema +func openAPI3SchemaToHumaV2Schema(schema *openapi3.Schema) *humav2.Schema { + if schema == nil { + return nil + } + + result := &humav2.Schema{ + Title: schema.Title, + Description: schema.Description, + Format: schema.Format, + Nullable: schema.Nullable, + } + + // Convert type + if schema.Type != nil && len(*schema.Type) > 0 { + result.Type = (*schema.Type)[0] + } + + // Convert enum + if schema.Enum != nil { + result.Enum = schema.Enum + } + + // Convert min/max + if schema.Min != nil { + minVal := *schema.Min + result.Minimum = &minVal + + // In OpenAPI 3, ExclusiveMin is a boolean flag that applies to Min + // In OpenAPI 3.1, ExclusiveMinimum is a separate value + if schema.ExclusiveMin { + result.ExclusiveMinimum = &minVal + } + } + if schema.Max != nil { + maxVal := *schema.Max + result.Maximum = &maxVal + + // In OpenAPI 3, ExclusiveMax is a boolean flag that applies to Max + // In OpenAPI 3.1, ExclusiveMaximum is a separate value + if schema.ExclusiveMax { + result.ExclusiveMaximum = &maxVal + } + } + + // Convert minLength/maxLength + if schema.MinLength != 0 { + minLength := int(schema.MinLength) + result.MinLength = &minLength + } + if schema.MaxLength != nil { + maxLength := int(*schema.MaxLength) + result.MaxLength = &maxLength + } + + // Convert pattern + if schema.Pattern != "" { + result.Pattern = schema.Pattern + } + + // Convert minItems/maxItems + if schema.MinItems != 0 { + minItems := int(schema.MinItems) + result.MinItems = &minItems + } + if schema.MaxItems != nil { + maxItems := int(*schema.MaxItems) + result.MaxItems = &maxItems + } + + // Convert uniqueItems + result.UniqueItems = schema.UniqueItems + + // Convert minProperties/maxProperties + if schema.MinProps != 0 { + minProps := int(schema.MinProps) + result.MinProperties = &minProps + } + if schema.MaxProps != nil { + maxProps := int(*schema.MaxProps) + result.MaxProperties = &maxProps + } + + // Convert required + if schema.Required != nil { + result.Required = schema.Required + } + + // Convert properties + if schema.Properties != nil { + result.Properties = make(map[string]*humav2.Schema, len(schema.Properties)) + for name, propRef := range schema.Properties { + if propRef != nil && propRef.Value != nil { + result.Properties[name] = openAPI3SchemaToHumaV2Schema(propRef.Value) + } + } + } + + // Convert items + if schema.Items != nil && schema.Items.Value != nil { + result.Items = openAPI3SchemaToHumaV2Schema(schema.Items.Value) + } + + // Convert oneOf + if schema.OneOf != nil { + result.OneOf = make([]*humav2.Schema, len(schema.OneOf)) + for i, oneOfRef := range schema.OneOf { + if oneOfRef != nil && oneOfRef.Value != nil { + result.OneOf[i] = openAPI3SchemaToHumaV2Schema(oneOfRef.Value) + } + } + } + + // Convert anyOf + if schema.AnyOf != nil { + result.AnyOf = make([]*humav2.Schema, len(schema.AnyOf)) + for i, anyOfRef := range schema.AnyOf { + if anyOfRef != nil && anyOfRef.Value != nil { + result.AnyOf[i] = openAPI3SchemaToHumaV2Schema(anyOfRef.Value) + } + } + } + + // Convert allOf + if schema.AllOf != nil { + result.AllOf = make([]*humav2.Schema, len(schema.AllOf)) + for i, allOfRef := range schema.AllOf { + if allOfRef != nil && allOfRef.Value != nil { + result.AllOf[i] = openAPI3SchemaToHumaV2Schema(allOfRef.Value) + } + } + } + + // Convert not + if schema.Not != nil && schema.Not.Value != nil { + result.Not = openAPI3SchemaToHumaV2Schema(schema.Not.Value) + } + + return result +} + func getOpenAPIToolsRevamp(t *openapi3.T, source, targetToolName string) ([]types.Tool, error) { if t == nil { return nil, fmt.Errorf("OpenAPI spec is nil") @@ -402,16 +543,14 @@ func getOpenAPIToolsRevamp(t *openapi3.T, source, targetToolName string) ([]type Parameters: types.Parameters{ Name: types.ToolNormalizer("get-schema-" + t.Info.Title), Description: fmt.Sprintf("Get the JSONSchema for the arguments for an operation for %s. You must do this before you run the operation.", t.Info.Title), - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{openapi3.TypeObject}, - Properties: openapi3.Schemas{ + Arguments: &humav2.Schema{ + Type: humav2.TypeObject, + Properties: map[string]*humav2.Schema{ "operation": { - Value: &openapi3.Schema{ - Type: &openapi3.Types{openapi3.TypeString}, - Title: "operation", - Description: "the name of the operation to get the schema for", - Required: []string{"operation"}, - }, + Type: humav2.TypeString, + Title: "operation", + Description: "the name of the operation to get the schema for", + Required: []string{"operation"}, }, }, }, @@ -428,24 +567,20 @@ func getOpenAPIToolsRevamp(t *openapi3.T, source, targetToolName string) ([]type Parameters: types.Parameters{ Name: types.ToolNormalizer("run-operation-" + t.Info.Title), Description: fmt.Sprintf("Run an operation for %s. You MUST call %s for the operation before you use this tool.", t.Info.Title, openapi.GetSchemaTool), - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{openapi3.TypeObject}, - Properties: openapi3.Schemas{ + Arguments: &humav2.Schema{ + Type: humav2.TypeObject, + Properties: map[string]*humav2.Schema{ "operation": { - Value: &openapi3.Schema{ - Type: &openapi3.Types{openapi3.TypeString}, - Title: "operation", - Description: "the name of the operation to run", - Required: []string{"operation"}, - }, + Type: humav2.TypeString, + Title: "operation", + Description: "the name of the operation to run", + Required: []string{"operation"}, }, "args": { - Value: &openapi3.Schema{ - Type: &openapi3.Types{openapi3.TypeString}, - Title: "args", - Description: "the JSON string containing arguments; must match the JSONSchema for the operation", - Required: []string{"args"}, - }, + Type: humav2.TypeString, + Title: "args", + Description: "the JSON string containing arguments; must match the JSONSchema for the operation", + Required: []string{"args"}, }, }, }, diff --git a/pkg/loader/testdata/openapi/TestOpenAPIv2.golden b/pkg/loader/testdata/openapi/TestOpenAPIv2.golden index 39b0b2c1..d64c70ea 100644 --- a/pkg/loader/testdata/openapi/TestOpenAPIv2.golden +++ b/pkg/loader/testdata/openapi/TestOpenAPIv2.golden @@ -56,16 +56,17 @@ types.ToolSet{ Name: "listPets", Description: "List all pets", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{ - "object", + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "limit": { + Type: "integer", + Description: "How many items to return at one time (max 100)", + Format: "int32", + Properties: map[string]*huma.Schema{}, + AllOf: []*huma.Schema{}, + }, }, - Required: []string{}, - Properties: openapi3.Schemas{"limit": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"integer"}, - Format: "int32", - Description: "How many items to return at one time (max 100)", - }}}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets","method":"GET","bodyContentMIME":"","securityInfos":null,"queryParameters":[{"name":"limit","style":"","explode":null}],"pathParameters":null,"headerParameters":null,"cookieParameters":null}'`, @@ -86,13 +87,15 @@ types.ToolSet{ Name: "showPetById", Description: "Info for a specific pet", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Required: []string{"petId"}, - Properties: openapi3.Schemas{"petId": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{"petId": { + Type: "string", Description: "The id of the pet to retrieve", - }}}, + Properties: map[string]*huma.Schema{}, + AllOf: []*huma.Schema{}, + }}, + Required: []string{"petId"}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets/{petId}","method":"GET","bodyContentMIME":"","securityInfos":null,"queryParameters":null,"pathParameters":[{"name":"petId","style":"","explode":null}],"headerParameters":null,"cookieParameters":null}'`, diff --git a/pkg/loader/testdata/openapi/TestOpenAPIv2Revamp.golden b/pkg/loader/testdata/openapi/TestOpenAPIv2Revamp.golden index ebe68cc2..d89e976e 100644 --- a/pkg/loader/testdata/openapi/TestOpenAPIv2Revamp.golden +++ b/pkg/loader/testdata/openapi/TestOpenAPIv2Revamp.golden @@ -36,16 +36,18 @@ types.ToolSet{ Name: "getSchemaSwaggerPetstore", Description: "Get the JSONSchema for the arguments for an operation for Swagger Petstore. You must do this before you run the operation.", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{ - "object", + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "operation": { + Type: "string", + Title: "operation", + Description: "the name of the operation to get the schema for", + Required: []string{ + "operation", + }, + }, }, - Properties: openapi3.Schemas{"operation": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, - Title: "operation", - Description: "the name of the operation to get the schema for", - Required: []string{"operation"}, - }}}, }, }, Instructions: "#!sys.openapi get-schema ", @@ -84,21 +86,21 @@ types.ToolSet{ Name: "runOperationSwaggerPetstore", Description: "Run an operation for Swagger Petstore. You MUST call get-schema for the operation before you use this tool.", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{ - "args": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "args": { + Type: "string", Title: "args", Description: "the JSON string containing arguments; must match the JSONSchema for the operation", Required: []string{"args"}, - }}, - "operation": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + }, + "operation": { + Type: "string", Title: "operation", Description: "the name of the operation to run", Required: []string{"operation"}, - }}, + }, }, }, }, diff --git a/pkg/loader/testdata/openapi/TestOpenAPIv3.golden b/pkg/loader/testdata/openapi/TestOpenAPIv3.golden index 37ac2fe2..710440cf 100644 --- a/pkg/loader/testdata/openapi/TestOpenAPIv3.golden +++ b/pkg/loader/testdata/openapi/TestOpenAPIv3.golden @@ -37,30 +37,25 @@ types.ToolSet{ Name: "createPets", Description: "Create a pet", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{ - "object", - }, - Required: []string{}, - Properties: openapi3.Schemas{"requestBodyContent": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Required: []string{ - "id", - "name", - }, - Properties: openapi3.Schemas{ - "id": &openapi3.SchemaRef{ - Value: &openapi3.Schema{ - Type: &openapi3.Types{ - "integer", - }, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "requestBodyContent": { + Type: "object", + Properties: map[string]*huma.Schema{ + "id": { + Type: "integer", Format: "int64", }, + "name": {Type: "string"}, + "tag": {Type: "string"}, + }, + Required: []string{ + "id", + "name", }, - "name": &openapi3.SchemaRef{Value: &openapi3.Schema{Type: &openapi3.Types{"string"}}}, - "tag": &openapi3.SchemaRef{Value: &openapi3.Schema{Type: &openapi3.Types{"string"}}}, }, - }}}, + }, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets","method":"POST","bodyContentMIME":"application/json","securityInfos":null,"queryParameters":null,"pathParameters":null,"headerParameters":null,"cookieParameters":null}'`, @@ -81,15 +76,14 @@ types.ToolSet{ Name: "listPets", Description: "List all pets", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Required: []string{}, - Properties: openapi3.Schemas{"limit": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"integer"}, - Format: "int32", + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{"limit": { + Type: "integer", Description: "How many items to return at one time (max 100)", - Max: valast.Ptr(float64(100)), - }}}, + Format: "int32", + Maximum: valast.Ptr(float64(100)), + }}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets","method":"GET","bodyContentMIME":"","securityInfos":null,"queryParameters":[{"name":"limit","style":"","explode":null}],"pathParameters":null,"headerParameters":null,"cookieParameters":null}'`, @@ -110,13 +104,13 @@ types.ToolSet{ Name: "showPetById", Description: "Info for a specific pet", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Required: []string{"petId"}, - Properties: openapi3.Schemas{"petId": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{"petId": { + Type: "string", Description: "The id of the pet to retrieve", - }}}, + }}, + Required: []string{"petId"}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets/{petId}","method":"GET","bodyContentMIME":"","securityInfos":null,"queryParameters":null,"pathParameters":[{"name":"petId","style":"","explode":null}],"headerParameters":null,"cookieParameters":null}'`, diff --git a/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDs.golden b/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDs.golden index e950e19c..c12c7834 100644 --- a/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDs.golden +++ b/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDs.golden @@ -37,17 +37,16 @@ types.ToolSet{ Name: "get_pets", Description: "List all pets", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{ - "object", + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "limit": { + Type: "integer", + Description: "How many items to return at one time (max 100)", + Format: "int32", + Maximum: valast.Ptr(float64(100)), + }, }, - Required: []string{}, - Properties: openapi3.Schemas{"limit": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"integer"}, - Format: "int32", - Description: "How many items to return at one time (max 100)", - Max: valast.Ptr(float64(100)), - }}}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets","method":"GET","bodyContentMIME":"","securityInfos":null,"queryParameters":[{"name":"limit","style":"","explode":null}],"pathParameters":null,"headerParameters":null,"cookieParameters":null}'`, @@ -68,13 +67,13 @@ types.ToolSet{ Name: "get_pets_petId", Description: "Info for a specific pet", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Required: []string{"petId"}, - Properties: openapi3.Schemas{"petId": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{"petId": { + Type: "string", Description: "The id of the pet to retrieve", - }}}, + }}, + Required: []string{"petId"}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets/{petId}","method":"GET","bodyContentMIME":"","securityInfos":null,"queryParameters":null,"pathParameters":[{"name":"petId","style":"","explode":null}],"headerParameters":null,"cookieParameters":null}'`, @@ -95,28 +94,23 @@ types.ToolSet{ Name: "post_pets", Description: "Create a pet", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Required: []string{}, - Properties: openapi3.Schemas{"requestBodyContent": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{"requestBodyContent": { + Type: "object", + Properties: map[string]*huma.Schema{ + "id": { + Type: "integer", + Format: "int64", + }, + "name": {Type: "string"}, + "tag": {Type: "string"}, + }, Required: []string{ "id", "name", }, - Properties: openapi3.Schemas{ - "id": &openapi3.SchemaRef{ - Value: &openapi3.Schema{ - Type: &openapi3.Types{ - "integer", - }, - Format: "int64", - }, - }, - "name": &openapi3.SchemaRef{Value: &openapi3.Schema{Type: &openapi3.Types{"string"}}}, - "tag": &openapi3.SchemaRef{Value: &openapi3.Schema{Type: &openapi3.Types{"string"}}}, - }, - }}}, + }}, }, }, Instructions: `#!sys.openapi '{"server":"http://petstore.swagger.io/v1","path":"/pets","method":"POST","bodyContentMIME":"application/json","securityInfos":null,"queryParameters":null,"pathParameters":null,"headerParameters":null,"cookieParameters":null}'`, diff --git a/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDsRevamp.golden b/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDsRevamp.golden index ebe68cc2..d89e976e 100644 --- a/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDsRevamp.golden +++ b/pkg/loader/testdata/openapi/TestOpenAPIv3NoOperationIDsRevamp.golden @@ -36,16 +36,18 @@ types.ToolSet{ Name: "getSchemaSwaggerPetstore", Description: "Get the JSONSchema for the arguments for an operation for Swagger Petstore. You must do this before you run the operation.", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{ - "object", + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "operation": { + Type: "string", + Title: "operation", + Description: "the name of the operation to get the schema for", + Required: []string{ + "operation", + }, + }, }, - Properties: openapi3.Schemas{"operation": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, - Title: "operation", - Description: "the name of the operation to get the schema for", - Required: []string{"operation"}, - }}}, }, }, Instructions: "#!sys.openapi get-schema ", @@ -84,21 +86,21 @@ types.ToolSet{ Name: "runOperationSwaggerPetstore", Description: "Run an operation for Swagger Petstore. You MUST call get-schema for the operation before you use this tool.", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{ - "args": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "args": { + Type: "string", Title: "args", Description: "the JSON string containing arguments; must match the JSONSchema for the operation", Required: []string{"args"}, - }}, - "operation": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + }, + "operation": { + Type: "string", Title: "operation", Description: "the name of the operation to run", Required: []string{"operation"}, - }}, + }, }, }, }, diff --git a/pkg/loader/testdata/openapi/TestOpenAPIv3Revamp.golden b/pkg/loader/testdata/openapi/TestOpenAPIv3Revamp.golden index ebe68cc2..d89e976e 100644 --- a/pkg/loader/testdata/openapi/TestOpenAPIv3Revamp.golden +++ b/pkg/loader/testdata/openapi/TestOpenAPIv3Revamp.golden @@ -36,16 +36,18 @@ types.ToolSet{ Name: "getSchemaSwaggerPetstore", Description: "Get the JSONSchema for the arguments for an operation for Swagger Petstore. You must do this before you run the operation.", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{ - "object", + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "operation": { + Type: "string", + Title: "operation", + Description: "the name of the operation to get the schema for", + Required: []string{ + "operation", + }, + }, }, - Properties: openapi3.Schemas{"operation": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, - Title: "operation", - Description: "the name of the operation to get the schema for", - Required: []string{"operation"}, - }}}, }, }, Instructions: "#!sys.openapi get-schema ", @@ -84,21 +86,21 @@ types.ToolSet{ Name: "runOperationSwaggerPetstore", Description: "Run an operation for Swagger Petstore. You MUST call get-schema for the operation before you use this tool.", ModelName: "gpt-4o", - Arguments: &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{ - "args": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + Arguments: &huma.Schema{ + Type: "object", + Properties: map[string]*huma.Schema{ + "args": { + Type: "string", Title: "args", Description: "the JSON string containing arguments; must match the JSONSchema for the operation", Required: []string{"args"}, - }}, - "operation": &openapi3.SchemaRef{Value: &openapi3.Schema{ - Type: &openapi3.Types{"string"}, + }, + "operation": { + Type: "string", Title: "operation", Description: "the name of the operation to run", Required: []string{"operation"}, - }}, + }, }, }, }, diff --git a/pkg/mcp/loader.go b/pkg/mcp/loader.go index b3441719..d31c6503 100644 --- a/pkg/mcp/loader.go +++ b/pkg/mcp/loader.go @@ -10,7 +10,7 @@ import ( "strings" "sync" - "github.com/getkin/kin-openapi/openapi3" + humav2 "github.com/danielgtaylor/huma/v2" "github.com/gptscript-ai/gptscript/pkg/hash" "github.com/gptscript-ai/gptscript/pkg/mvl" "github.com/gptscript-ai/gptscript/pkg/types" @@ -194,19 +194,18 @@ func (l *Local) sessionToTools(ctx context.Context, session *Session, toolName s if !allToolsAllowed && !slices.Contains(allowedTools, tool.Name) { continue } + if tool.Name == "" { + // I dunno, bad tool? + continue + } - var schema openapi3.Schema + var schema humav2.Schema schemaData, err := json.Marshal(tool.InputSchema) if err != nil { panic(err) } - if tool.Name == "" { - // I dunno, bad tool? - continue - } - if err := json.Unmarshal(schemaData, &schema); err != nil { return nil, fmt.Errorf("failed to unmarshal tool input schema: %w", err) } diff --git a/pkg/openai/client.go b/pkg/openai/client.go index 7715c657..69e6621d 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -11,6 +11,7 @@ import ( "strings" "time" + humav2 "github.com/danielgtaylor/huma/v2" openai "github.com/gptscript-ai/chat-completion-client" "github.com/gptscript-ai/gptscript/pkg/cache" "github.com/gptscript-ai/gptscript/pkg/counter" @@ -405,7 +406,7 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques var params any = tool.Function.Parameters if tool.Function.Parameters == nil || len(tool.Function.Parameters.Properties) == 0 { params = map[string]any{ - "type": "object", + "type": humav2.TypeObject, "properties": map[string]any{}, } } diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index b00b1506..e7ec287d 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/getkin/kin-openapi/openapi3" + humav2 "github.com/danielgtaylor/huma/v2" "github.com/gptscript-ai/gptscript/pkg/types" ) @@ -54,9 +54,9 @@ func csv(line string) (result []string) { func addArg(line string, tool *types.Tool) error { if tool.Arguments == nil { - tool.Arguments = &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{}, + tool.Arguments = &humav2.Schema{ + Type: "object", + Properties: make(map[string]*humav2.Schema, 1), } } @@ -65,11 +65,9 @@ func addArg(line string, tool *types.Tool) error { return fmt.Errorf("invalid arg format: %s", line) } - tool.Arguments.Properties[key] = &openapi3.SchemaRef{ - Value: &openapi3.Schema{ - Description: strings.TrimSpace(value), - Type: &openapi3.Types{"string"}, - }, + tool.Arguments.Properties[key] = &humav2.Schema{ + Description: strings.TrimSpace(value), + Type: "string", } return nil diff --git a/pkg/system/prompt.go b/pkg/system/prompt.go index 6b1815fd..a4fe5f26 100644 --- a/pkg/system/prompt.go +++ b/pkg/system/prompt.go @@ -5,7 +5,7 @@ import ( "os" "strings" - "github.com/getkin/kin-openapi/openapi3" + humav2 "github.com/danielgtaylor/huma/v2" ) // Suffix is default suffix of gptscript files @@ -26,26 +26,22 @@ You don't move to the next step until you have a result. // to just send pure text but the interface required JSON (as that is the fundamental interface of tools in OpenAI) var DefaultPromptParameter = "defaultPromptParameter" -var DefaultToolSchema = openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{ - DefaultPromptParameter: &openapi3.SchemaRef{ - Value: &openapi3.Schema{ - Description: "Prompt to send to the tool. This may be an instruction or question.", - Type: &openapi3.Types{"string"}, - }, +var DefaultToolSchema = humav2.Schema{ + Type: "object", + Properties: map[string]*humav2.Schema{ + DefaultPromptParameter: { + Description: "Prompt to send to the tool. This may be an instruction or question.", + Type: "string", }, }, } -var DefaultChatSchema = openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{ - DefaultPromptParameter: &openapi3.SchemaRef{ - Value: &openapi3.Schema{ - Description: "Prompt to send to the assistant. This may be an instruction or question.", - Type: &openapi3.Types{"string"}, - }, +var DefaultChatSchema = humav2.Schema{ + Type: "object", + Properties: map[string]*humav2.Schema{ + DefaultPromptParameter: { + Description: "Prompt to send to the assistant. This may be an instruction or question.", + Type: "string", }, }, } diff --git a/pkg/types/completion.go b/pkg/types/completion.go index 2362071f..fbd2fb3b 100644 --- a/pkg/types/completion.go +++ b/pkg/types/completion.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/getkin/kin-openapi/openapi3" + humav2 "github.com/danielgtaylor/huma/v2" ) type CompletionRequest struct { @@ -31,10 +31,10 @@ type ChatCompletionTool struct { } type CompletionFunctionDefinition struct { - ToolID string `json:"toolID,omitempty"` - Name string `json:"name"` - Description string `json:"description,omitempty"` - Parameters *openapi3.Schema `json:"parameters"` + ToolID string `json:"toolID,omitempty"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + Parameters *humav2.Schema `json:"parameters"` } // Chat message role defined by the OpenAI API. diff --git a/pkg/types/jsonschema.go b/pkg/types/jsonschema.go index 6fd0d4ea..b88e37b6 100644 --- a/pkg/types/jsonschema.go +++ b/pkg/types/jsonschema.go @@ -1,21 +1,17 @@ package types -import ( - "github.com/getkin/kin-openapi/openapi3" -) +import humav2 "github.com/danielgtaylor/huma/v2" -func ObjectSchema(kv ...string) *openapi3.Schema { - s := &openapi3.Schema{ - Type: &openapi3.Types{"object"}, - Properties: openapi3.Schemas{}, +func ObjectSchema(kv ...string) *humav2.Schema { + s := &humav2.Schema{ + Type: humav2.TypeObject, + Properties: make(map[string]*humav2.Schema, len(kv)/2), } for i, v := range kv { if i%2 == 1 { - s.Properties[kv[i-1]] = &openapi3.SchemaRef{ - Value: &openapi3.Schema{ - Description: v, - Type: &openapi3.Types{"string"}, - }, + s.Properties[kv[i-1]] = &humav2.Schema{ + Description: v, + Type: humav2.TypeString, } } } diff --git a/pkg/types/tool.go b/pkg/types/tool.go index 10b47c77..c5346319 100644 --- a/pkg/types/tool.go +++ b/pkg/types/tool.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - "github.com/getkin/kin-openapi/openapi3" + humav2 "github.com/danielgtaylor/huma/v2" "github.com/google/shlex" "github.com/gptscript-ai/gptscript/pkg/system" "golang.org/x/exp/maps" @@ -120,33 +120,33 @@ func (p Program) SetBlocking() Program { type BuiltinFunc func(ctx context.Context, env []string, input string, progress chan<- string) (string, error) type Parameters struct { - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - MaxTokens int `json:"maxTokens,omitempty"` - ModelName string `json:"modelName,omitempty"` - ModelProvider bool `json:"modelProvider,omitempty"` - JSONResponse bool `json:"jsonResponse,omitempty"` - Chat bool `json:"chat,omitempty"` - Temperature *float32 `json:"temperature,omitempty"` - Cache *bool `json:"cache,omitempty"` - InternalPrompt *bool `json:"internalPrompt"` - Arguments *openapi3.Schema `json:"arguments,omitempty"` - Tools []string `json:"tools,omitempty"` - GlobalTools []string `json:"globalTools,omitempty"` - GlobalModelName string `json:"globalModelName,omitempty"` - Context []string `json:"context,omitempty"` - ExportContext []string `json:"exportContext,omitempty"` - Export []string `json:"export,omitempty"` - Agents []string `json:"agents,omitempty"` - Credentials []string `json:"credentials,omitempty"` - ExportCredentials []string `json:"exportCredentials,omitempty"` - InputFilters []string `json:"inputFilters,omitempty"` - ExportInputFilters []string `json:"exportInputFilters,omitempty"` - OutputFilters []string `json:"outputFilters,omitempty"` - ExportOutputFilters []string `json:"exportOutputFilters,omitempty"` - Blocking bool `json:"-"` - Stdin bool `json:"stdin,omitempty"` - Type ToolType `json:"type,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + MaxTokens int `json:"maxTokens,omitempty"` + ModelName string `json:"modelName,omitempty"` + ModelProvider bool `json:"modelProvider,omitempty"` + JSONResponse bool `json:"jsonResponse,omitempty"` + Chat bool `json:"chat,omitempty"` + Temperature *float32 `json:"temperature,omitempty"` + Cache *bool `json:"cache,omitempty"` + InternalPrompt *bool `json:"internalPrompt"` + Arguments *humav2.Schema `json:"arguments,omitempty"` + Tools []string `json:"tools,omitempty"` + GlobalTools []string `json:"globalTools,omitempty"` + GlobalModelName string `json:"globalModelName,omitempty"` + Context []string `json:"context,omitempty"` + ExportContext []string `json:"exportContext,omitempty"` + Export []string `json:"export,omitempty"` + Agents []string `json:"agents,omitempty"` + Credentials []string `json:"credentials,omitempty"` + ExportCredentials []string `json:"exportCredentials,omitempty"` + InputFilters []string `json:"inputFilters,omitempty"` + ExportInputFilters []string `json:"exportInputFilters,omitempty"` + OutputFilters []string `json:"outputFilters,omitempty"` + ExportOutputFilters []string `json:"exportOutputFilters,omitempty"` + Blocking bool `json:"-"` + Stdin bool `json:"stdin,omitempty"` + Type ToolType `json:"type,omitempty"` } func (p Parameters) allExports() []string { @@ -486,7 +486,7 @@ func (t ToolDef) Print() string { sort.Strings(keys) for _, key := range keys { prop := t.Arguments.Properties[key] - _, _ = fmt.Fprintf(buf, "Parameter: %s: %s\n", key, prop.Value.Description) + _, _ = fmt.Fprintf(buf, "Parameter: %s: %s\n", key, prop.Description) } } if t.InternalPrompt != nil {